arweave 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +13 -16
- data/lib/arweave/transaction.rb +26 -4
- data/lib/arweave/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0ab0aff4582e1f661f4eea102563257fb2ac2f440f5d40d2202c38d9ef7f0310
|
4
|
+
data.tar.gz: 38a77a892cfaec95a04f700560866615ea792b0092cf93606c835c4294ab318e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9e479b0ddbe4d39f032ff7ed606c3456c8f53a57f6940b4cb0a3ec504c120100b4801bfc293352bf54ca25cea0c9251329f1a824590bc92fee67662fefcba405
|
7
|
+
data.tar.gz: b16520d519034614a80c6217f1033f93ceeb622ff8309813e7c6b909036eae60086aecc5d5205c1ee3c43e3cbc97ba80ff62e816ffbec9082bc50c8187173650
|
data/README.md
CHANGED
@@ -8,9 +8,8 @@ Simply run
|
|
8
8
|
|
9
9
|
or put the gem into your gemfile:
|
10
10
|
```ruby
|
11
|
-
gem 'arweave'
|
11
|
+
gem 'arweave', '~> 1.0.0'
|
12
12
|
```
|
13
|
-
## Usage
|
14
13
|
|
15
14
|
## Configuration
|
16
15
|
The default node that this package uses is `https://arweave.net`. But you can simply configure it:
|
@@ -25,11 +24,6 @@ end
|
|
25
24
|
|
26
25
|
## Transaction methods
|
27
26
|
|
28
|
-
### Getting transaction anchor
|
29
|
-
```ruby
|
30
|
-
anchor = Arweave::Transaction.anchor
|
31
|
-
```
|
32
|
-
|
33
27
|
### Creating transactions
|
34
28
|
For a complete list of arguments you can pass to the `new` method,
|
35
29
|
checkout the [documentation](https://docs.arweave.org/developers/server/http-api#submit-a-transaction).
|
@@ -70,17 +64,20 @@ Arweave::Transaction.data('tSF6pxiknBk0hBUTkdzq02E0zvsrT0xe4UtCzZit-bz')
|
|
70
64
|
```
|
71
65
|
|
72
66
|
### Getting transaction status
|
73
|
-
the `status` class method returns
|
74
|
-
|
67
|
+
the `status` class method returns an open struct that responds to `pending?` and
|
68
|
+
`accepted?` methods. If you need the text status, you can use `to_s` and
|
69
|
+
`to_sym` methods. To see the status JSON data, use the `data` method.
|
75
70
|
```ruby
|
76
|
-
Arweave::Transaction.status('tSF6pxiknBk0hBUTkdzq02E0zvsrT0xe4UtCzZit-bz')
|
71
|
+
status = Arweave::Transaction.status('tSF6pxiknBk0hBUTkdzq02E0zvsrT0xe4UtCzZit-bz')
|
72
|
+
status.pending? # => false
|
73
|
+
status.accepted? # => true
|
74
|
+
status.to_s # => "accepted"
|
75
|
+
status.to_sym # => :accepted
|
76
|
+
status.data
|
77
77
|
# => {
|
78
|
-
# "
|
79
|
-
# "
|
80
|
-
#
|
81
|
-
# "block_indep_hash": "hh0ceHGfEOuTQWYMXGNzb2AabezqZUhtSw5vtUPKTtGmkViPArX5WeLBKBYZIwlS",
|
82
|
-
# "number_of_confirmations": 388
|
83
|
-
# }
|
78
|
+
# "block_height": 468306,
|
79
|
+
# "block_indep_hash": "hh0ceHGfEOuTQWYMXGNzb2AabezqZUhtSw5vtUPKTtGmkViPArX5WeLBKBYZIwlS",
|
80
|
+
# "number_of_confirmations": 388
|
84
81
|
# }
|
85
82
|
```
|
86
83
|
|
data/lib/arweave/transaction.rb
CHANGED
@@ -78,11 +78,33 @@ module Arweave
|
|
78
78
|
res = Api.instance.get_transaction_status(id)
|
79
79
|
raise TransactionNotFound if res.not_found?
|
80
80
|
|
81
|
-
|
82
|
-
status: :accepted, data: JSON.parse(res.body).transform_keys(&:to_sym)
|
83
|
-
}
|
81
|
+
create_status_object(:accepted, JSON.parse(res.body).transform_keys!(&:to_sym))
|
84
82
|
rescue JSON::ParserError
|
85
|
-
|
83
|
+
create_status_object(:pending, {})
|
84
|
+
end
|
85
|
+
|
86
|
+
def create_status_object(status, data)
|
87
|
+
status_object = OpenStruct.new(status: status, data: data)
|
88
|
+
|
89
|
+
status_object.instance_eval do
|
90
|
+
def accepted?
|
91
|
+
status == :accepted
|
92
|
+
end
|
93
|
+
|
94
|
+
def pending?
|
95
|
+
status == :pending
|
96
|
+
end
|
97
|
+
|
98
|
+
def to_s
|
99
|
+
status.to_s
|
100
|
+
end
|
101
|
+
|
102
|
+
def to_sym
|
103
|
+
status
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
status_object
|
86
108
|
end
|
87
109
|
end
|
88
110
|
|
data/lib/arweave/version.rb
CHANGED