arweave 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/LICENSE.txt +1 -1
- data/README.md +22 -3
- data/lib/arweave/transaction.rb +29 -3
- data/lib/arweave/version.rb +1 -1
- metadata +2 -3
- data/Gemfile.lock +0 -65
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: df6c4a7ec670a6671f84a3e7e480eeae4a9169523944c50696d2b46aa5818e26
|
4
|
+
data.tar.gz: 11bfed6127a26a338a28c480b0c6b97490a09bbef275aec75f9fa3a8d9424117
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: accb1b93ee65e402799bcc882d6961327cf51e3dd2492120b6c14c52c882385d13f36754f0440d39f0070847b4fc8da5bba6706d6065f2a55d85ac71c9032253
|
7
|
+
data.tar.gz: 9694281e4f4a6b57f15536f4d779bdd3fdd16833fe864ee7efe5e0d19359c2dcec613c44a099e8917337dfd7425c72b506b36c5ee68df90bf7aa79ae878f100d
|
data/.gitignore
CHANGED
data/LICENSE.txt
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
GNU GENERAL PUBLIC LICENSE
|
2
2
|
Version 3, 29 June 2007
|
3
3
|
|
4
|
-
Copyright (C)
|
4
|
+
Copyright (C) 2020 license.rocks GmbH <https://license.rocks;
|
5
5
|
Everyone is permitted to copy and distribute verbatim copies
|
6
6
|
of this license document, but changing it is not allowed.
|
7
7
|
|
data/README.md
CHANGED
@@ -1,7 +1,10 @@
|
|
1
1
|
# Arweave Ruby SDK
|
2
|
-
|
2
|
+
Got any important data that should be accessable for mankind in the future?
|
3
|
+
Love to build great things with Ruby?
|
4
|
+
Here comes your Ruby flavoured Arweave SDK solution.
|
5
|
+
Combine arweave's permanent storage solution and Ruby, so that your data will be stored for 200 years plus and create like that your own precious data Ruby.
|
3
6
|
|
4
|
-
##
|
7
|
+
## Installation
|
5
8
|
Run `gem install arweave`
|
6
9
|
|
7
10
|
or put the gem into your gemfile:
|
@@ -42,12 +45,28 @@ Arweave::Transaction.new(data: 'test').sign(wallet).commit
|
|
42
45
|
# => #<Arweavev::Transaction:0x00007f9b61299330 @attributes={...}>
|
43
46
|
```
|
44
47
|
|
45
|
-
You can get the transaction attributes from the
|
48
|
+
You can get the transaction attributes from the attributes hash:
|
46
49
|
```ruby
|
47
50
|
transaction.attributes[:id]
|
48
51
|
# => "tSF6pxiknBk0hBUTkdzq02E0zvsrT0xe4UtCzZit-bz"
|
49
52
|
```
|
50
53
|
|
54
|
+
### Adding tags
|
55
|
+
You can add tags to a transaction using `add_tag` method:
|
56
|
+
```ruby
|
57
|
+
transaction.add_tag(name: 'tag_name', value: 'tag_value')
|
58
|
+
# => #<Arweavev::Transaction:0x00007f9b61299330 @attributes={...}>
|
59
|
+
```
|
60
|
+
|
61
|
+
**NOTE**: You should add tags before commiting the transaction, because once the
|
62
|
+
transcation created, then you can't modify it and add tags to it.
|
63
|
+
|
64
|
+
You can also retrieve tags using `tags` method on the transaction instance:
|
65
|
+
```ruby
|
66
|
+
transaction.tags
|
67
|
+
# => [{ :name => "tag_name", :value => "tag_value" }]
|
68
|
+
```
|
69
|
+
|
51
70
|
### Find transaction by id
|
52
71
|
```ruby
|
53
72
|
Arweave::Transaction.find('tSF6pxiknBk0hBUTkdzq02E0zvsrT0xe4UtCzZit-bz')
|
data/lib/arweave/transaction.rb
CHANGED
@@ -50,6 +50,27 @@ module Arweave
|
|
50
50
|
self
|
51
51
|
end
|
52
52
|
|
53
|
+
def add_tag(name:, value:)
|
54
|
+
attributes[:tags].push(
|
55
|
+
{
|
56
|
+
name: Base64.urlsafe_encode64(name, padding: false),
|
57
|
+
value: Base64.urlsafe_encode64(value, padding: false)
|
58
|
+
}
|
59
|
+
)
|
60
|
+
|
61
|
+
self
|
62
|
+
end
|
63
|
+
|
64
|
+
def tags
|
65
|
+
attributes[:tags].map do |tag|
|
66
|
+
tag.transform_keys!(&:to_sym)
|
67
|
+
{
|
68
|
+
name: Base64.urlsafe_decode64(tag[:name]),
|
69
|
+
value: Base64.urlsafe_decode64(tag[:value])
|
70
|
+
}
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
53
74
|
class << self
|
54
75
|
def anchor
|
55
76
|
Api.instance.get_transaction_anchor.body
|
@@ -78,7 +99,10 @@ module Arweave
|
|
78
99
|
res = Api.instance.get_transaction_status(id)
|
79
100
|
raise TransactionNotFound if res.not_found?
|
80
101
|
|
81
|
-
create_status_object(
|
102
|
+
create_status_object(
|
103
|
+
:accepted,
|
104
|
+
JSON.parse(res.body).transform_keys!(&:to_sym)
|
105
|
+
)
|
82
106
|
rescue JSON::ParserError
|
83
107
|
create_status_object(:pending, {})
|
84
108
|
end
|
@@ -123,8 +147,10 @@ module Arweave
|
|
123
147
|
end
|
124
148
|
|
125
149
|
def tags_string
|
126
|
-
|
127
|
-
|
150
|
+
attributes.fetch(:tags).reduce('') do |acc, tag|
|
151
|
+
acc + Base64.urlsafe_decode64(tag[:name]) +
|
152
|
+
Base64.urlsafe_decode64(tag[:value])
|
153
|
+
end
|
128
154
|
end
|
129
155
|
end
|
130
156
|
end
|
data/lib/arweave/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: arweave
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aref Aslani
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-06-
|
11
|
+
date: 2020-06-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json-jwt
|
@@ -64,7 +64,6 @@ files:
|
|
64
64
|
- ".travis.yml"
|
65
65
|
- CODE_OF_CONDUCT.md
|
66
66
|
- Gemfile
|
67
|
-
- Gemfile.lock
|
68
67
|
- LICENSE.txt
|
69
68
|
- README.md
|
70
69
|
- Rakefile
|
data/Gemfile.lock
DELETED
@@ -1,65 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
arweave (0.1.0)
|
5
|
-
httparty (~> 0.18.1)
|
6
|
-
json-jwt (~> 1.13)
|
7
|
-
|
8
|
-
GEM
|
9
|
-
remote: https://rubygems.org/
|
10
|
-
specs:
|
11
|
-
activesupport (6.0.3.1)
|
12
|
-
concurrent-ruby (~> 1.0, >= 1.0.2)
|
13
|
-
i18n (>= 0.7, < 2)
|
14
|
-
minitest (~> 5.1)
|
15
|
-
tzinfo (~> 1.1)
|
16
|
-
zeitwerk (~> 2.2, >= 2.2.2)
|
17
|
-
aes_key_wrap (1.0.1)
|
18
|
-
bindata (2.4.7)
|
19
|
-
byebug (11.1.3)
|
20
|
-
concurrent-ruby (1.1.6)
|
21
|
-
diff-lcs (1.3)
|
22
|
-
httparty (0.18.1)
|
23
|
-
mime-types (~> 3.0)
|
24
|
-
multi_xml (>= 0.5.2)
|
25
|
-
i18n (1.8.3)
|
26
|
-
concurrent-ruby (~> 1.0)
|
27
|
-
json-jwt (1.13.0)
|
28
|
-
activesupport (>= 4.2)
|
29
|
-
aes_key_wrap
|
30
|
-
bindata
|
31
|
-
mime-types (3.3.1)
|
32
|
-
mime-types-data (~> 3.2015)
|
33
|
-
mime-types-data (3.2020.0512)
|
34
|
-
minitest (5.14.1)
|
35
|
-
multi_xml (0.6.0)
|
36
|
-
rake (12.3.3)
|
37
|
-
rspec (3.9.0)
|
38
|
-
rspec-core (~> 3.9.0)
|
39
|
-
rspec-expectations (~> 3.9.0)
|
40
|
-
rspec-mocks (~> 3.9.0)
|
41
|
-
rspec-core (3.9.2)
|
42
|
-
rspec-support (~> 3.9.3)
|
43
|
-
rspec-expectations (3.9.2)
|
44
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
45
|
-
rspec-support (~> 3.9.0)
|
46
|
-
rspec-mocks (3.9.1)
|
47
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
48
|
-
rspec-support (~> 3.9.0)
|
49
|
-
rspec-support (3.9.3)
|
50
|
-
thread_safe (0.3.6)
|
51
|
-
tzinfo (1.2.7)
|
52
|
-
thread_safe (~> 0.1)
|
53
|
-
zeitwerk (2.3.0)
|
54
|
-
|
55
|
-
PLATFORMS
|
56
|
-
ruby
|
57
|
-
|
58
|
-
DEPENDENCIES
|
59
|
-
arweave!
|
60
|
-
byebug (~> 11.1)
|
61
|
-
rake (~> 12.0)
|
62
|
-
rspec (~> 3.0)
|
63
|
-
|
64
|
-
BUNDLED WITH
|
65
|
-
2.1.4
|