GithubHelp home page GithubHelp logo

mikehibbert / arweave-python-client Goto Github PK

View Code? Open in Web Editor NEW
102.0 102.0 43.0 1.21 MB

This client allows you to integrate your python apps with the Arweave network allowing you to perform wallet operations and transactions

License: MIT License

Python 96.29% JavaScript 3.71%
arweave cryptocurrency python transaction wallet

arweave-python-client's People

Contributors

fabianriewe avatar gcbsumid avatar guberti avatar jespern avatar ldmberman avatar libcthorne avatar m30m avatar mikehibbert avatar snyk-bot avatar theblazehen avatar wwhchung avatar xiaojay avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

arweave-python-client's Issues

arweave_lib portion erroring, but appears to still complete?

Running this query: https://github.com/MikeHibbert/arweave-python-client#uploading-large-files
with:

from arweave.arweave_lib import Wallet, Transaction

It throws an error in the response JSON but appears(?) to be OK and complete the transaction successfully.

The error is:
ERROR:arweave.arweave_lib:{"data": "eyduYW1lJzo....

Expected behavior
I'm not sure of "expected" behavior, or if I may just be missing because it seems(?) it more of a warning, than an error maybe?

Can't upload

Hello!

I use this code

`
wallet_file_path = "mywallet.json"
wallet = arweave.Wallet(wallet_file_path)

with open('myPicture.jpg', 'rb') as file:
data_file = file.read()

transaction = Transaction(wallet, data=data_file)
transaction.sign()
c = transaction.send()
print(c)

`

9/10 times I get 'Connection reset by peer'. But during this 1 normal try I see some hash info like "yAq2A-AHCmXwyFSO_jzXNct_yPBUi8P3_ZdS_Dx3GoK7c3PGtg". But I don't see image in my ARDRIVE. What is a problem? What I do wrong?

Uploader doesn't work on Windows 10

Describe the bug
On Windows 10, importing the uploader fails, due to it importing signal

Version Used
My version is 1.0.14

To Reproduce
Steps to reproduce the behavior:

from arweave.transaction_uploader import get_uploader

The issue is in transaction_uploader.py:

from signal import signal, SIGPIPE, SIG_DFL

signal(SIGPIPE, SIG_DFL)

Which causes ImportError: cannot import name 'SIGPIPE' from 'signal' (C:\Python38\lib\signal.py)

This post explains how it's not supported on Windows 10 - explanation

I'm not 100% sure what it does but I hope there's an alternative. FYI - by commenting those 2 lines out It works as expected with no errors

Variable 'reward' referenced before assignment

Describe the bug
The get_reward() function from arweave_lib.py fails randomly because of poor variable usage.

My guess is that the following code fails when the status.code is different than 200.

if response.status_code == 200:
            reward = response.text

return reward

Here is the traceback:

File "/home/user/.local/lib/python3.8/site-packages/arweave/arweave_lib.py", line 192, in sign
  data_to_sign = self.get_signature_data()
File "/home/user/.local/lib/python3.8/site-packages/arweave/arweave_lib.py", line 204, in get_signature_data
  self.reward = self.get_reward(self.data_size, target_address=self.target if len(self.target) > 0 else None)
File "/home/user/.local/lib/python3.8/site-packages/arweave/arweave_lib.py", line 178, in get_reward
  return reward
UnboundLocalError: local variable 'reward' referenced before assignment

How to upload a png?

I'm trying to use this lib to upload a PNG to arweave, I have something like this:

image = cv2.imread('./build/images/0.png')
transaction = arweave.Transaction(arweave_wallet, data=image)
transaction.sign()
transaction.send()

But get an error:

AppData\Local\Programs\Python\Python310\lib\site-packages\arweave\arweave_lib.py", line 118, in __init__
    self.data = base64url_encode(data.encode('utf-8'))
AttributeError: 'numpy.ndarray' object has no attribute 'encode'

Any ideas how I could accomplish this?

Thanks

SIGPIPE not supported on windows

Describe the bug
SIGPIPE is not supported on Windows. Uploading any transactions fail on windows. I've just made the following changes locally, so it's up to you guys however you would like to fix it.

Version Used
My version is the latest version.

Proposed Solution
Put the SIGPIPE attempt in a try and ignore if it fails.

try:
    from signal import signal, SIGPIPE, SIG_DFL
    signal(SIGPIPE, SIG_DFL)
except ImportError:  # If SIGPIPE is not available (win32),
    pass   

Suggest removal of ArQL, and replacement with GraphQL

Describe the bug
ArQL is old, slow and unmaintained. You cannot just deprecate the immutable, but the endpoint is as close to this as is possible. ArQL queries are getting slower as time goes on. This is deliberate and will not be fixed. This is similar to how format 1 txs are treated compared to format 2.

Expected behavior
Use the replacement GraphQL endpoint: /graphql

Great initiative!

Thanks a lot @MikeHibbert for your implementation of the Arweave SDK to a python library! Apart from the previous prize, you get an extra $300 paid in DAI for your great work.

Load wallet directly with the wallet address

I have my wallet address saved in aws secret manager. I can fetch the address at runtime but the wallet init method only allow loading the wallet from a file. Is there a way to load the Wallet with an address ?

arweave.arweave_lib.ArweaveTransactionException: Too Many Requests

Describe the bug
Got an error: arweave.arweave_lib.ArweaveTransactionException: Too Many Requests

Version Used
Current

To Reproduce
Steps to reproduce the behavior:
Upload a lot of images one after the other (this time just got to 51)

Expected behavior
Upload all my images without any issues

Data is uploaded incorrectly when uses_uploader=False

There is a bug where data passed directly to a Transaction object is not uploaded correctly. It computes data_root from the Base64URL encoded data so the nodes do not recognize it and do not accept the original data.

An example. data_root computed from the raw data is yiIbdak6AXJ17hGF5EJC_FpleCvd3pBe2c4jSZpRDVM whereas the tx was signed with XTcZfQOhQ0byq0NjAfJbYynVMyX6fkd4IBIfRR3S0IA - the value consistent with computing data_root from a Base64URL encoded blob.

To fix the issue it should be sufficient to decode here and here.

Unable to import SIGPIPE from signal on Windows

Describe the bug
When using the library on Windows (because sometimes you just have to), you will encounter an error in
from signal import signal, SIGPIPE, SIG_DFL

Version Used
My version is 'latest'

To Reproduce
Steps to reproduce the behavior:

  1. from arweave import Wallet, Transaction
  2. from arweave.transaction_uploader import get_uploader

Expected behavior
Clean import

Additional context
Add any other context about the problem here.

  1. https://stackoverflow.com/questions/58718659/cannot-import-name-sigpipe-from-signal-in-windows-10

tx_data_size_data_root_mismatch error

Hi! I followed the example in the Readme file for storing data. This seems to be unsuccessful due to an error message: tx_data_size_data_root_mismatch. What should I change?

Throw an error when wallet has insufficient balance.

I ran into the problem where my wallet had insufficient balance for sending a transaction. When sending the request, the server returned 200 OK but the status of the transaction was always 404 Not Found. It took me some time to figure out, that the sum of reward and quantity was higher than my actual balance. We could implement a check before sending a transaction and throw an error when the sum of quantity and reward is higher than the wallets balance. Any thoughts on this?

Kind regards,
Fabian

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.