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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3735532e9b91e9cbe5e84b671ae9f7685fdd8328f2fd8ae644e0f069bcb75d3e
4
- data.tar.gz: 4df8ea22c8f6a20ae9299deb6043c798a23cf071c0cfc9e7222ce843aa5b5da2
3
+ metadata.gz: 0ab0aff4582e1f661f4eea102563257fb2ac2f440f5d40d2202c38d9ef7f0310
4
+ data.tar.gz: 38a77a892cfaec95a04f700560866615ea792b0092cf93606c835c4294ab318e
5
5
  SHA512:
6
- metadata.gz: 804ebaacd0bfe841f3a38b586dba8ae7e271248b80e35b6755c5affc0aa90fb292dfd0125fb3c029f2fab43afbe585b1a578a6759cda5c6ddaf4df63b14cec53
7
- data.tar.gz: 25bc0d61ab800180e4066b9c171d1a383cd1a7f5d13ed7a803dea078b70c6ec01f8d207c35c8a6c9a5dea479ed9573f31e3ffb89f7c92cd7238c21361331bd43
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 a hash containing transaction status
74
- (which is pending or accepted) and the and the data and a hash about the block.
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
- # "status": "accepted",
79
- # "data": {
80
- # "block_height": 468306,
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
 
@@ -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
- { status: :pending, data: {} }
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
 
@@ -1,3 +1,3 @@
1
1
  module Arweave
2
- VERSION = '1.0.0'
2
+ VERSION = '1.0.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arweave
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aref Aslani