filecoin 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +39 -0
- data/CHANGELOG.md +7 -1
- data/Gemfile +2 -0
- data/Gemfile.lock +44 -1
- data/README.md +110 -29
- data/filecoin.gemspec +2 -0
- data/lib/filecoin.rb +3 -0
- data/lib/filecoin/client.rb +7 -7
- data/lib/filecoin/client/node.rb +4 -2
- data/lib/filecoin/configuration.rb +20 -0
- data/lib/filecoin/deal.rb +39 -0
- data/lib/filecoin/deals/state.rb +63 -0
- data/lib/filecoin/types/start_deal_params.rb +2 -2
- data/lib/filecoin/version.rb +1 -1
- metadata +21 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 51d924d8ec129371f94374405e003a802de0b7952fdeb9ae8eec0df93ed4f2f1
|
4
|
+
data.tar.gz: d3f27b9ee0a0a5b252d6523740be7d3fb2302a89ea528503e9081f7cbcb7d328
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a6021bf20aa984240b5839418aa29913007e40889f9dbbae25ec9a1a84a74577ba771fe6b9ad548f9312b7088cf957f3f6ec5d8643168a364e876ef64e6ecad3
|
7
|
+
data.tar.gz: d893ffd092e50be52cd458eb0e277897df5305ce670d0134da287a62cf658afd39e8f6dec200e66920dde56b86e53ec29117ce223b916d26488f8b35957610ad
|
@@ -0,0 +1,39 @@
|
|
1
|
+
name: Ruby
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ master ]
|
6
|
+
pull_request:
|
7
|
+
branches: [ master ]
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
lint:
|
11
|
+
runs-on: ubuntu-latest
|
12
|
+
steps:
|
13
|
+
- uses: actions/checkout@v2
|
14
|
+
- uses: ruby/setup-ruby@v1
|
15
|
+
with:
|
16
|
+
ruby-version: 2.7
|
17
|
+
- name: Install dependencies
|
18
|
+
run: bundle install
|
19
|
+
- name: Run tests
|
20
|
+
run: bundle exec rake lint
|
21
|
+
test:
|
22
|
+
strategy:
|
23
|
+
fail-fast: false
|
24
|
+
matrix:
|
25
|
+
os: [ubuntu, macos]
|
26
|
+
ruby: [2.5, 2.6, 2.7, head, debug, jruby, jruby-head, truffleruby, truffleruby-head]
|
27
|
+
runs-on: ${{ matrix.os }}-latest
|
28
|
+
continue-on-error: ${{ endsWith(matrix.ruby, 'head') || matrix.ruby == 'debug' }}
|
29
|
+
steps:
|
30
|
+
- uses: actions/checkout@v2
|
31
|
+
- uses: ruby/setup-ruby@v1
|
32
|
+
with:
|
33
|
+
ruby-version: ${{ matrix.ruby }}
|
34
|
+
- name: Install dependencies
|
35
|
+
run: bundle install
|
36
|
+
- name: Run tests
|
37
|
+
env:
|
38
|
+
FILECOIN_URL: ${{ secrets.FILECOIN_URL }}
|
39
|
+
run: bundle exec rake spec
|
data/CHANGELOG.md
CHANGED
@@ -10,7 +10,13 @@ The format is based on [Keep a Changelog], and this project adheres to
|
|
10
10
|
Unreleased
|
11
11
|
----------
|
12
12
|
|
13
|
-
|
13
|
+
- Add optional argument to extract the deal CID automatically from the response
|
14
|
+
when submitting a proposal;
|
15
|
+
- Make wallet for deal proposals optional, falling back on the configured
|
16
|
+
default wallet;
|
17
|
+
- Add configuration object to set default wallet for deal proposals;
|
18
|
+
- Fix defaults overriding provided nil values in `Filecoin::Client`;
|
19
|
+
- Add abstraction for deals and their state with client lifecycle helpers.
|
14
20
|
|
15
21
|
|
16
22
|
v0.2.0 - 2020-06-12
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,22 +1,57 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
filecoin (0.
|
4
|
+
filecoin (0.3.0)
|
5
|
+
dry-struct (~> 1.0)
|
5
6
|
|
6
7
|
GEM
|
7
8
|
remote: https://rubygems.org/
|
8
9
|
specs:
|
10
|
+
addressable (2.7.0)
|
11
|
+
public_suffix (>= 2.0.2, < 5.0)
|
9
12
|
ast (2.4.0)
|
10
13
|
concurrent-ruby (1.1.6)
|
14
|
+
crack (0.4.3)
|
15
|
+
safe_yaml (~> 1.0.0)
|
11
16
|
diff-lcs (1.3)
|
17
|
+
dry-configurable (0.11.6)
|
18
|
+
concurrent-ruby (~> 1.0)
|
19
|
+
dry-core (~> 0.4, >= 0.4.7)
|
20
|
+
dry-equalizer (~> 0.2)
|
21
|
+
dry-container (0.7.2)
|
22
|
+
concurrent-ruby (~> 1.0)
|
23
|
+
dry-configurable (~> 0.1, >= 0.1.3)
|
24
|
+
dry-core (0.4.9)
|
25
|
+
concurrent-ruby (~> 1.0)
|
26
|
+
dry-equalizer (0.3.0)
|
27
|
+
dry-inflector (0.2.0)
|
28
|
+
dry-logic (1.0.6)
|
29
|
+
concurrent-ruby (~> 1.0)
|
30
|
+
dry-core (~> 0.2)
|
31
|
+
dry-equalizer (~> 0.2)
|
32
|
+
dry-struct (1.3.0)
|
33
|
+
dry-core (~> 0.4, >= 0.4.4)
|
34
|
+
dry-equalizer (~> 0.3)
|
35
|
+
dry-types (~> 1.3)
|
36
|
+
ice_nine (~> 0.11)
|
37
|
+
dry-types (1.4.0)
|
38
|
+
concurrent-ruby (~> 1.0)
|
39
|
+
dry-container (~> 0.3)
|
40
|
+
dry-core (~> 0.4, >= 0.4.4)
|
41
|
+
dry-equalizer (~> 0.3)
|
42
|
+
dry-inflector (~> 0.1, >= 0.1.2)
|
43
|
+
dry-logic (~> 1.0, >= 1.0.2)
|
12
44
|
faker (2.12.0)
|
13
45
|
i18n (>= 1.6, < 2)
|
46
|
+
hashdiff (1.0.1)
|
14
47
|
i18n (1.8.2)
|
15
48
|
concurrent-ruby (~> 1.0)
|
49
|
+
ice_nine (0.11.2)
|
16
50
|
parallel (1.19.1)
|
17
51
|
parser (2.7.1.3)
|
18
52
|
ast (~> 2.4.0)
|
19
53
|
permafrost (1.0.0)
|
54
|
+
public_suffix (4.0.5)
|
20
55
|
rainbow (3.0.0)
|
21
56
|
rake (12.3.3)
|
22
57
|
rexml (3.2.4)
|
@@ -48,7 +83,13 @@ GEM
|
|
48
83
|
rubocop-rspec (1.39.0)
|
49
84
|
rubocop (>= 0.68.1)
|
50
85
|
ruby-progressbar (1.10.1)
|
86
|
+
safe_yaml (1.0.5)
|
51
87
|
unicode-display_width (1.7.0)
|
88
|
+
vcr (6.0.0)
|
89
|
+
webmock (3.8.3)
|
90
|
+
addressable (>= 2.3.6)
|
91
|
+
crack (>= 0.3.2)
|
92
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
52
93
|
|
53
94
|
PLATFORMS
|
54
95
|
ruby
|
@@ -62,6 +103,8 @@ DEPENDENCIES
|
|
62
103
|
rubocop (~> 0.84.0)
|
63
104
|
rubocop-performance (~> 1.6.0)
|
64
105
|
rubocop-rspec (~> 1.39.0)
|
106
|
+
vcr (~> 6.0)
|
107
|
+
webmock (~> 3.0)
|
65
108
|
|
66
109
|
BUNDLED WITH
|
67
110
|
2.1.4
|
data/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
filecoin-ruby
|
2
2
|
=============
|
3
3
|
|
4
|
+
![Ruby](https://github.com/subvisual/filecoin-ruby/workflows/Ruby/badge.svg)
|
5
|
+
|
4
6
|
Interface to the Filecoin network APIs in Ruby.
|
5
7
|
|
6
8
|
|
@@ -198,33 +200,106 @@ The state of a deal has a numerical value which links it to a constant in the
|
|
198
200
|
Filecoin Lotus client. At the time of writing, these states are
|
199
201
|
([source][states]):
|
200
202
|
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
deal
|
214
|
-
|
215
|
-
|
216
|
-
deal
|
217
|
-
14
|
218
|
-
15
|
219
|
-
16
|
220
|
-
17
|
221
|
-
18
|
222
|
-
19
|
223
|
-
20
|
224
|
-
21
|
225
|
-
22
|
226
|
-
23
|
227
|
-
24
|
203
|
+
| Value | State | Description |
|
204
|
+
| :---: | :--- | :--- |
|
205
|
+
| 0 | Unknown | Status of the deal is undefined. |
|
206
|
+
| 1 | Not found | Deal can not be located. |
|
207
|
+
| 2 | Proposal rejected | Storage miner chose not to accept this deal proposal. |
|
208
|
+
| 3 | Proposal accepted | Storage miner chose to accept this deal proposal. |
|
209
|
+
| 4 | Staged | Deal has been published and data is ready to be put into a sector. |
|
210
|
+
| 5 | Sealing | Deal is in sector that's being sealed. |
|
211
|
+
| 6 | Active | Deal is in a sealed sector and the miner is providing proofs for this deal. |
|
212
|
+
| 7 | Expired | Deal has passed its final epoch and is expired. |
|
213
|
+
| 8 | Slashed | Deal was in a sector that got slashed from failing to produce proofs. |
|
214
|
+
| 9 | Failing | Something has gone wrong in the deal. Data is being cleaned. |
|
215
|
+
| 10 | Funds ensured | The funds necessary to create the deal have been deposited. |
|
216
|
+
| 11 | Waiting for data request | Client is waiting for provider to request the deal data. |
|
217
|
+
| 12 | Validating | Storage provider is validating whether the deal parameters are good for a proposal. |
|
218
|
+
| 13 | Waiting for acceptance | Storage provider is running some custom decision logic to decide whether to accept the deal. |
|
219
|
+
| 14 | Transferring | Data is being sent from the client to the storage provider. |
|
220
|
+
| 15 | Waiting for data | Deal is for a manual data transfer, or the storage provider has not yet received a request to transfer data from the client. |
|
221
|
+
| 16 | Verifying data | Data has been transferred and the storage provider is verifying it against the provided piece CID. |
|
222
|
+
| 17 | Ensure provider funds | Storage provider is making sure it has adequate funds for the deal. |
|
223
|
+
| 18 | Ensure client funds | Client is making sure it has adequate funds for the deal. |
|
224
|
+
| 19 | Provider is funding | Storage provider has deposited funds and is waiting for funds to show up in balance. |
|
225
|
+
| 20 | Client is funding | Client has deposited funds and is waiting for funds to show up in balance. |
|
226
|
+
| 21 | Publish | Deal is ready to be published on chain. |
|
227
|
+
| 22 | Publishing | Deal has been published, currently waiting for it to appear on chain. |
|
228
|
+
| 23 | Error | Deal has failed due to an error, no further updates will occur. |
|
229
|
+
| 24 | Completed | Deal is active and information for retrieval is recorded. |
|
230
|
+
|
231
|
+
The lifecycle of a deal is slightly different from the point-of-view of the
|
232
|
+
client (the node proposing a deal) and the miner. Please refer to [the
|
233
|
+
storage market technical documentation] for up-to-date diagrams.
|
234
|
+
|
235
|
+
This gem provides an abstraction in `Filecoin::Deals::State` of the **client
|
236
|
+
deal lifecycle** reducing them to 4 general states for general deal
|
237
|
+
health-checks and tracking.
|
238
|
+
|
239
|
+
<table>
|
240
|
+
<thead>
|
241
|
+
<tr>
|
242
|
+
<th>Abstract State</th>
|
243
|
+
<th>Description</th>
|
244
|
+
<th>Positive States</th>
|
245
|
+
</tr>
|
246
|
+
</thead>
|
247
|
+
<tbody>
|
248
|
+
<tr>
|
249
|
+
<td>Pending</td>
|
250
|
+
<td>Deal has been proposed and is pending acceptance or rejection.</td>
|
251
|
+
<td>
|
252
|
+
<ul>
|
253
|
+
<li>Ensure client funds</li>
|
254
|
+
<li>Client is funding</li>
|
255
|
+
<li>Funds ensured</li>
|
256
|
+
<li>Waiting for data</li>
|
257
|
+
<li>Transferring</li>
|
258
|
+
<li>Validating</li>
|
259
|
+
</ul>
|
260
|
+
</td>
|
261
|
+
</tr>
|
262
|
+
<tr>
|
263
|
+
<td>Good</td>
|
264
|
+
<td>Deal has been accepted and is active or on its way to become active.</td>
|
265
|
+
<td>
|
266
|
+
<ul>
|
267
|
+
<li>Proposal accepted</li>
|
268
|
+
<li>Sealing</li>
|
269
|
+
<li>Active</li>
|
270
|
+
</ul>
|
271
|
+
</td>
|
272
|
+
</tr>
|
273
|
+
<tr>
|
274
|
+
<td>Bad</td>
|
275
|
+
<td>Something has gone wrong with the deal and it is now invalid.</td>
|
276
|
+
<td>
|
277
|
+
<ul>
|
278
|
+
<li>Failing</li>
|
279
|
+
<li>Error</li>
|
280
|
+
</ul>
|
281
|
+
</td>
|
282
|
+
</tr>
|
283
|
+
<tr>
|
284
|
+
<td>Finished</td>
|
285
|
+
<td>The deal has followed its natural course and is no longer active.</td>
|
286
|
+
<td>
|
287
|
+
<ul>
|
288
|
+
<li>Slashed</li>
|
289
|
+
<li>Expired</li>
|
290
|
+
</ul>
|
291
|
+
</td>
|
292
|
+
</tr>
|
293
|
+
</tbody>
|
294
|
+
</table>
|
295
|
+
|
296
|
+
To make use of this abstraction, initialize `Filecoin::Deal` with the result
|
297
|
+
of `Filecoin.ClientGetDealInfo`.
|
298
|
+
|
299
|
+
```ruby
|
300
|
+
response = Filecoin.client_get_deal_info("bafyreigc4b4fqsval4pjmfncaqdezhe5y3anwavjyzpj4mar73e6n7mvj4")
|
301
|
+
deal = Filecoin::Deal.new(response["result"])
|
302
|
+
```
|
228
303
|
|
229
304
|
|
230
305
|
### Filecoin.ClientQueryAsk
|
@@ -266,6 +341,7 @@ start_deal_params = Filecoin::Types::StartDealParams.new(
|
|
266
341
|
# Description of the data the deal refers to
|
267
342
|
data: data_ref,
|
268
343
|
# Address of the wallet in the node to use to pay for the deal
|
344
|
+
# (optional if `Filecoin.config.default_wallet` is set)
|
269
345
|
wallet: "t13nqjc55m3h327646cwcu4lchdx4lkw7ccxnx4ca",
|
270
346
|
# Address ot the miner to whom this deal is to be proposed
|
271
347
|
miner: "t1234567",
|
@@ -277,7 +353,7 @@ start_deal_params = Filecoin::Types::StartDealParams.new(
|
|
277
353
|
deal_start_epoch: 1591979600,
|
278
354
|
)
|
279
355
|
|
280
|
-
Filecoin.client_start_deal(start_deal_params)
|
356
|
+
Filecoin.client_start_deal(start_deal_params, extract_response: false)
|
281
357
|
```
|
282
358
|
|
283
359
|
```json
|
@@ -290,6 +366,10 @@ Filecoin.client_start_deal(start_deal_params)
|
|
290
366
|
}
|
291
367
|
```
|
292
368
|
|
369
|
+
This method accepts an optional keyword argument `extract_response`. If truthy,
|
370
|
+
the method returns the deal CID directly, or `nil`, instead of the JSON RPC
|
371
|
+
full response. Defaults to `false`.
|
372
|
+
|
293
373
|
|
294
374
|
### Filecoin.NetPeers
|
295
375
|
|
@@ -364,7 +444,8 @@ filecoin-ruby was created and is maintained with :heart: by
|
|
364
444
|
|
365
445
|
[Filecoin Node API]: https://github.com/filecoin-project/lotus/blob/master/api/api_full.go
|
366
446
|
[permissions]: https://lotu.sh/en+api#what-authorization-level-should-i-use-21853
|
367
|
-
[states]: https://github.com/filecoin-project/go-fil-markets/blob/
|
447
|
+
[states]: https://github.com/filecoin-project/go-fil-markets/blob/master/storagemarket/dealstatus.go
|
448
|
+
[the storage market technical documentation]: https://github.com/filecoin-project/go-fil-markets/tree/master/storagemarket#technical-documentation
|
368
449
|
[license]: ./LICENSE.txt
|
369
450
|
[rubygems.org]: https://rubygems.org
|
370
451
|
[subvisual]: http://subvisual.com
|
data/filecoin.gemspec
CHANGED
data/lib/filecoin.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require "filecoin/client"
|
2
|
+
require "filecoin/configuration"
|
2
3
|
require "filecoin/types"
|
3
4
|
require "filecoin/version"
|
4
5
|
require "forwardable"
|
@@ -7,6 +8,8 @@ module Filecoin
|
|
7
8
|
class << self
|
8
9
|
extend Forwardable
|
9
10
|
|
11
|
+
include Configurable
|
12
|
+
|
10
13
|
def_delegators :client, *Client::Node.public_instance_methods
|
11
14
|
|
12
15
|
def client
|
data/lib/filecoin/client.rb
CHANGED
@@ -7,23 +7,23 @@ module Filecoin
|
|
7
7
|
|
8
8
|
attr_reader :uri, :token
|
9
9
|
|
10
|
-
def initialize(
|
11
|
-
@uri = initialize_uri(
|
12
|
-
@token = initialize_token(
|
10
|
+
def initialize(opts = {})
|
11
|
+
@uri = initialize_uri(opts)
|
12
|
+
@token = initialize_token(opts)
|
13
13
|
end
|
14
14
|
|
15
15
|
private
|
16
16
|
|
17
|
-
def initialize_uri(
|
18
|
-
uri
|
17
|
+
def initialize_uri(opts)
|
18
|
+
uri = opts.fetch(:uri, ENV["FILECOIN_URL"])
|
19
19
|
|
20
20
|
return if uri.nil?
|
21
21
|
|
22
22
|
URI(uri)
|
23
23
|
end
|
24
24
|
|
25
|
-
def initialize_token(
|
26
|
-
token
|
25
|
+
def initialize_token(opts)
|
26
|
+
opts.fetch(:token, ENV["FILECOIN_TOKEN"])
|
27
27
|
end
|
28
28
|
|
29
29
|
def json_rpc_call(method, *params)
|
data/lib/filecoin/client/node.rb
CHANGED
@@ -17,14 +17,16 @@ module Filecoin
|
|
17
17
|
json_rpc_call "Filecoin.ClientQueryAsk", peer_id, miner_id
|
18
18
|
end
|
19
19
|
|
20
|
-
def client_start_deal(start_deal_params)
|
20
|
+
def client_start_deal(start_deal_params, extract_response: false)
|
21
21
|
params = if start_deal_params.is_a?(Hash)
|
22
22
|
start_deal_params
|
23
23
|
else
|
24
24
|
start_deal_params.as_json
|
25
25
|
end
|
26
26
|
|
27
|
-
json_rpc_call("Filecoin.ClientStartDeal", params)
|
27
|
+
response = json_rpc_call("Filecoin.ClientStartDeal", params)
|
28
|
+
|
29
|
+
extract_response ? response.dig("result", "/") : response
|
28
30
|
end
|
29
31
|
|
30
32
|
def net_peers
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Filecoin
|
2
|
+
class Configuration
|
3
|
+
attr_writer :default_wallet
|
4
|
+
|
5
|
+
def default_wallet
|
6
|
+
@default_wallet || ENV["FILECOIN_WALLET"]
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
module Configurable
|
11
|
+
def configuration
|
12
|
+
@configuration ||= Configuration.new
|
13
|
+
end
|
14
|
+
alias config configuration
|
15
|
+
|
16
|
+
def configure
|
17
|
+
yield configuration
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require "dry-struct"
|
2
|
+
require "filecoin/deals/state"
|
3
|
+
|
4
|
+
module Filecoin
|
5
|
+
class Deal < Dry::Struct
|
6
|
+
attribute? :deal_id, Dry::Types["integer"].optional
|
7
|
+
attribute? :duration, Dry::Types["integer"].optional
|
8
|
+
attribute? :message, Dry::Types["string"].optional
|
9
|
+
attribute? :piece_cid, Dry::Types["string"].optional
|
10
|
+
attribute? :price_per_epoch, Dry::Types["string"].optional
|
11
|
+
attribute? :proposal_cid, Dry::Types["string"].optional
|
12
|
+
attribute? :provider, Dry::Types["string"].optional
|
13
|
+
attribute? :size, Dry::Types["integer"].optional
|
14
|
+
attribute? :state, Dry::Types["integer"].optional
|
15
|
+
|
16
|
+
module ClassMethods
|
17
|
+
def from_deal_info(deal_info) # rubocop:disable Metrics/MethodLength
|
18
|
+
new(
|
19
|
+
deal_id: deal_info["DealID"],
|
20
|
+
duration: deal_info["Duration"],
|
21
|
+
message: deal_info["Message"],
|
22
|
+
piece_cid: deal_info.dig("PieceCID", "/"),
|
23
|
+
price_per_epoch: deal_info["PricePerEpoch"],
|
24
|
+
proposal_cid: deal_info.dig("ProposalCid", "/"),
|
25
|
+
provider: deal_info["Provider"],
|
26
|
+
size: deal_info["Size"],
|
27
|
+
state: deal_info["State"],
|
28
|
+
)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
extend ClassMethods
|
33
|
+
include Deals::State
|
34
|
+
|
35
|
+
def initialize(attrs = {})
|
36
|
+
super
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
module Filecoin
|
2
|
+
module Deals
|
3
|
+
module State
|
4
|
+
STATES = %i[
|
5
|
+
unknown
|
6
|
+
not_found
|
7
|
+
proposal_rejected
|
8
|
+
proposal_accepted
|
9
|
+
staged
|
10
|
+
sealing
|
11
|
+
active
|
12
|
+
expired
|
13
|
+
slashed
|
14
|
+
failing
|
15
|
+
funds_ensured
|
16
|
+
waiting_for_data_request
|
17
|
+
validating
|
18
|
+
waiting_for_acceptance
|
19
|
+
transferring
|
20
|
+
waiting_for_data
|
21
|
+
verifying_data
|
22
|
+
ensure_provider_funds
|
23
|
+
ensure_client_funds
|
24
|
+
provider_funding
|
25
|
+
client_funding
|
26
|
+
publish
|
27
|
+
publishing
|
28
|
+
error
|
29
|
+
completed
|
30
|
+
].freeze
|
31
|
+
|
32
|
+
STATES.each_with_index do |state, index|
|
33
|
+
define_method("#{state}?") do
|
34
|
+
self.state == index
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
GOOD_STATES = %i[proposal_accepted sealing active].freeze
|
39
|
+
BAD_STATES = %i[failing error].freeze
|
40
|
+
PENDING_STATES = %i[
|
41
|
+
ensure_client_funds client_funding funds_ensured
|
42
|
+
waiting_for_data_request transferring validating
|
43
|
+
].freeze
|
44
|
+
FINISHED_STATES = %i[slashed expired].freeze
|
45
|
+
|
46
|
+
def bad?
|
47
|
+
BAD_STATES.include?(STATES[state])
|
48
|
+
end
|
49
|
+
|
50
|
+
def finished?
|
51
|
+
FINISHED_STATES.include?(STATES[state])
|
52
|
+
end
|
53
|
+
|
54
|
+
def good?
|
55
|
+
GOOD_STATES.include?(STATES[state])
|
56
|
+
end
|
57
|
+
|
58
|
+
def pending?
|
59
|
+
PENDING_STATES.include?(STATES[state])
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -3,9 +3,9 @@ module Filecoin
|
|
3
3
|
class StartDealParams
|
4
4
|
attr_reader :data, :wallet, :miner, :epoch_price, :min_blocks_duration, :deal_start_epoch
|
5
5
|
|
6
|
-
def initialize(data:, wallet
|
6
|
+
def initialize(data:, wallet: nil, miner:, epoch_price:, min_blocks_duration: nil, deal_start_epoch: nil)
|
7
7
|
@data = data
|
8
|
-
@wallet = wallet
|
8
|
+
@wallet = wallet || Filecoin.config.default_wallet
|
9
9
|
@miner = miner
|
10
10
|
@epoch_price = epoch_price
|
11
11
|
@min_blocks_duration = min_blocks_duration
|
data/lib/filecoin/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: filecoin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pedro Costa
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
12
|
-
dependencies:
|
11
|
+
date: 2020-07-07 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: dry-struct
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.0'
|
13
27
|
description: |
|
14
28
|
Filecoin (https://filecoin.io/) is a distributed storage network based on a
|
15
29
|
blockchain mechanism. Filecoin miners provide storage capacity for the
|
@@ -29,6 +43,7 @@ executables: []
|
|
29
43
|
extensions: []
|
30
44
|
extra_rdoc_files: []
|
31
45
|
files:
|
46
|
+
- ".github/workflows/ruby.yml"
|
32
47
|
- ".gitignore"
|
33
48
|
- ".rspec"
|
34
49
|
- ".rubocop.yml"
|
@@ -46,6 +61,9 @@ files:
|
|
46
61
|
- lib/filecoin.rb
|
47
62
|
- lib/filecoin/client.rb
|
48
63
|
- lib/filecoin/client/node.rb
|
64
|
+
- lib/filecoin/configuration.rb
|
65
|
+
- lib/filecoin/deal.rb
|
66
|
+
- lib/filecoin/deals/state.rb
|
49
67
|
- lib/filecoin/http.rb
|
50
68
|
- lib/filecoin/types.rb
|
51
69
|
- lib/filecoin/types/cid.rb
|