arweave 1.0.3 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +44 -0
- data/arweave.gemspec +1 -1
- data/lib/arweave.rb +1 -0
- data/lib/arweave/directory.rb +39 -0
- data/lib/arweave/errors.rb +1 -0
- data/lib/arweave/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1b5d27312d0da2f5857127b809dca34c0f1006e313ca0735f3caed5ea8799706
|
4
|
+
data.tar.gz: e089e33e425386c2c09e1a46a775915b2fcc9af70c78cb4836080bbcd672d17a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 32adbb4d74b2089454c47830e00f8a7ea7d48cda4c04bfe3aa9cd77f6b28a60e5e84bd6c41fcb8a8365fa00f6923fefe44a5360032f75d7e00944c22311cef9e
|
7
|
+
data.tar.gz: 3f5dda23ca893584111fac85393c0d4fafb9406b33ff37e52e5671165724ab517c6ee1f2e0e03671eea276333ff04e8c3f82e1f2753a97e4aa7e72deab2fb81c
|
data/README.md
CHANGED
@@ -130,3 +130,47 @@ balance.winston.to_i # => 249891527825
|
|
130
130
|
```ruby
|
131
131
|
wallet.last_transaction_id # => "BsHjWHBwSlmW_VgOcgLmsQacQjpohmvVDLMMVyuAkie"
|
132
132
|
```
|
133
|
+
|
134
|
+
## Directories
|
135
|
+
Directories are an abstract logical grouping around transactions which is implemented using path manifests. For more information, you can take a look at [path manifests](https://github.com/ArweaveTeam/arweave/wiki/Path-Manifests) documentation.
|
136
|
+
|
137
|
+
### Create a directory
|
138
|
+
To create a directory, first you must have transaction ids you want to put under the new directory and then specify a name for them.
|
139
|
+
```ruby
|
140
|
+
directory = Arweave::Directory.new(paths: { 'index.html' => 'BsHjWHBwSlmW_VgOcgLmsQacQjpohmvVDLMMVyuAkie' })
|
141
|
+
# => #<Arweave::Directory:0x00007ff3400b2350 @paths={...}>
|
142
|
+
```
|
143
|
+
Then you should get the transaction out of the directory instance and commit it.
|
144
|
+
```ruby
|
145
|
+
transaction = directory.transaction
|
146
|
+
# => #<Arweavev::Transaction:0x00007f9b61299330 @attributes={...}>
|
147
|
+
transaction.sign(wallet).commit
|
148
|
+
# => #<Arweavev::Transaction:0x00007f9b61299330 @attributes={...}>
|
149
|
+
```
|
150
|
+
Then you can check your files in the directory using the name you've specified for the files. The endpoint for checking directory files is `/:dir_transaction_id/:filename`. For example
|
151
|
+
```
|
152
|
+
https:/arweave.net/JxiKsfr2es55AuCTSZg5oJLz7j4phRgireZt5SpChE/index.html
|
153
|
+
```
|
154
|
+
|
155
|
+
### Directory index
|
156
|
+
Arweave creates an HTML file to index your files in a directory, but if you like, you can set one of the files in the paths argument as index file.
|
157
|
+
```ruby
|
158
|
+
directory =
|
159
|
+
Arweave::Directory.new(
|
160
|
+
index: 'index.html',
|
161
|
+
paths: {
|
162
|
+
'index.html' => 'BsHjWHBwSlmW_VgOcgLmsQacQjpohmvVDLMMVyuAkie',
|
163
|
+
'contact.html' => '-3U2-Oks289pQPH0Umz9Fy0G1Ti2UMlQYIr7NGIYL_M',
|
164
|
+
}
|
165
|
+
) # => #<Arweave::Directory:0x00007ff3400b2350 @index="...", @paths={...}>
|
166
|
+
```
|
167
|
+
|
168
|
+
### Adding files to a directory
|
169
|
+
You can add files to a directory using the `add` method on a directory instance.
|
170
|
+
```ruby
|
171
|
+
directory.add('about.html' => 'LhT2WHBwFbv9_Pey67LmsQacQjpZxsyjDLMMVyuAkie')
|
172
|
+
# => #<Arweave::Directory:0x00007ff3400b2350 @index="...", @paths={...}>
|
173
|
+
```
|
174
|
+
**NOTE**: You should add the files to the directory before commiting the transaction,
|
175
|
+
else nothing will be added to the directory. In case you want to modify your directory,
|
176
|
+
you should create a new transaction for that.
|
data/arweave.gemspec
CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.summary = %q{Arweave SDK}
|
10
10
|
spec.description = %q{Ruby SDK for Arweave decentralized services}
|
11
11
|
spec.homepage = 'https://github.com/LicenseRocks/arweave-ruby'
|
12
|
-
spec.license = 'GPL
|
12
|
+
spec.license = 'GPL-3.0'
|
13
13
|
spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
|
14
14
|
|
15
15
|
spec.metadata['homepage_uri'] = spec.homepage
|
data/lib/arweave.rb
CHANGED
@@ -0,0 +1,39 @@
|
|
1
|
+
module Arweave
|
2
|
+
class Directory
|
3
|
+
MANIFEST = 'arweave/paths'
|
4
|
+
VERSION = '0.1.0'
|
5
|
+
|
6
|
+
def initialize(index: nil, paths: {})
|
7
|
+
if index && !paths.keys.include?(index)
|
8
|
+
raise PathDoesNotExist.new('`index` path should be included in `paths` argument')
|
9
|
+
end
|
10
|
+
|
11
|
+
@index = index
|
12
|
+
@paths = paths
|
13
|
+
end
|
14
|
+
|
15
|
+
def add(paths)
|
16
|
+
@paths.merge!(paths)
|
17
|
+
self
|
18
|
+
end
|
19
|
+
|
20
|
+
def paths
|
21
|
+
@paths.reduce({}) do |acc, (key, value)|
|
22
|
+
acc.merge(key => { id: value })
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def as_json(options = {})
|
27
|
+
{
|
28
|
+
manifest: MANIFEST,
|
29
|
+
version: VERSION,
|
30
|
+
**(@index ? { index: { path: @index } } : {}),
|
31
|
+
paths: paths
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
def transaction
|
36
|
+
Transaction.new(data: self.to_json).add_tag(name: 'Content-Type', value: 'application/x.arweave-manifest+json')
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/lib/arweave/errors.rb
CHANGED
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.1.0
|
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-
|
11
|
+
date: 2020-07-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json-jwt
|
@@ -73,13 +73,14 @@ files:
|
|
73
73
|
- lib/arweave.rb
|
74
74
|
- lib/arweave/api.rb
|
75
75
|
- lib/arweave/client.rb
|
76
|
+
- lib/arweave/directory.rb
|
76
77
|
- lib/arweave/errors.rb
|
77
78
|
- lib/arweave/transaction.rb
|
78
79
|
- lib/arweave/version.rb
|
79
80
|
- lib/arweave/wallet.rb
|
80
81
|
homepage: https://github.com/LicenseRocks/arweave-ruby
|
81
82
|
licenses:
|
82
|
-
- GPL
|
83
|
+
- GPL-3.0
|
83
84
|
metadata:
|
84
85
|
homepage_uri: https://github.com/LicenseRocks/arweave-ruby
|
85
86
|
source_code_uri: https://github.com/LicenseRocks/arweave-ruby
|