cardano_wallet 0.1.5 → 0.2.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/nightly.yml +3 -3
- data/.github/workflows/tests.yml +2 -2
- data/cardano_wallet.gemspec +1 -1
- data/dev +1 -1
- data/docker-compose-shelley.yml +2 -2
- data/lib/cardano_wallet.rb +0 -1
- data/lib/cardano_wallet/base.rb +4 -0
- data/lib/cardano_wallet/byron.rb +36 -0
- data/lib/cardano_wallet/misc.rb +39 -0
- data/lib/cardano_wallet/shelley.rb +20 -11
- data/lib/cardano_wallet/version.rb +1 -1
- metadata +6 -7
- data/lib/cardano_wallet/proxy.rb +0 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 00a386b2276f8b8373cd9a89cebdba30a5f151c2b32cee0ae3d8915a6daee980
|
4
|
+
data.tar.gz: 10094b3fb16e9c9e71e61409a314b06d94dd140c01f79641e8bce9dafa21fccc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff0b9ac1b5071acee4be8ad9830adbe082fb01587e4593fa868ed7dd47552609e04ed3a382a47abedba658340a4cad4e25506ad9f0db73e6b6f7f35fe23621a8
|
7
|
+
data.tar.gz: 19e1aad7916ec508822a48e1ac38996236874236c8d7849754fed3922444bae0396c955d62a4a06a11e4aafefbeb33b494035c5e9026aefa36a5885a7d3495ca
|
@@ -12,7 +12,7 @@ jobs:
|
|
12
12
|
steps:
|
13
13
|
- uses: actions/checkout@v2
|
14
14
|
- name: Set up cardano-wallet
|
15
|
-
run: NODE_CONFIG_PATH=`pwd`/spec/
|
15
|
+
run: NODE_CONFIG_PATH=`pwd`/spec/testnet docker-compose -f docker-compose-shelley.yml up --detach
|
16
16
|
- name: Set up Ruby
|
17
17
|
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
|
18
18
|
# change this to (see https://github.com/ruby/setup-ruby#versioning):
|
@@ -25,10 +25,10 @@ jobs:
|
|
25
25
|
- name: Wait until node is synced
|
26
26
|
run: bundle exec rake wait_until_node_synced
|
27
27
|
- name: Run all tests
|
28
|
-
run: bundle exec rspec
|
28
|
+
run: bundle exec rspec .
|
29
29
|
env:
|
30
30
|
CI: true
|
31
31
|
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
32
32
|
NETWORK: testnet
|
33
33
|
WALLET: dev-master-shelley
|
34
|
-
NODE: 1.
|
34
|
+
NODE: 1.20.0
|
data/.github/workflows/tests.yml
CHANGED
@@ -21,7 +21,7 @@ jobs:
|
|
21
21
|
steps:
|
22
22
|
- uses: actions/checkout@v2
|
23
23
|
- name: Set up cardano-wallet
|
24
|
-
run: NODE_CONFIG_PATH=`pwd`/spec/
|
24
|
+
run: NODE_CONFIG_PATH=`pwd`/spec/testnet docker-compose -f docker-compose-shelley.yml up --detach
|
25
25
|
- name: Set up Ruby
|
26
26
|
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
|
27
27
|
# change this to (see https://github.com/ruby/setup-ruby#versioning):
|
@@ -38,4 +38,4 @@ jobs:
|
|
38
38
|
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
39
39
|
NETWORK: testnet
|
40
40
|
WALLET: dev-master-shelley
|
41
|
-
NODE: 1.
|
41
|
+
NODE: 1.20.0
|
data/cardano_wallet.gemspec
CHANGED
@@ -32,7 +32,7 @@ Gem::Specification.new do |spec|
|
|
32
32
|
spec.add_development_dependency 'rake', '~> 12.3'
|
33
33
|
spec.add_development_dependency 'rspec', '~> 3.7'
|
34
34
|
spec.add_development_dependency 'bip_mnemonic', '~> 0.0.4'
|
35
|
-
spec.add_development_dependency 'codecov'
|
35
|
+
spec.add_development_dependency 'codecov', '~> 0.2.8'
|
36
36
|
spec.add_development_dependency 'simplecov'
|
37
37
|
|
38
38
|
end
|
data/dev
CHANGED
@@ -1 +1 @@
|
|
1
|
-
NETWORK=testnet WALLET=dev-master-
|
1
|
+
NETWORK=testnet WALLET=dev-master-shelley NODE=1.19.1 NODE_CONFIG_PATH=`pwd`/spec/testnet docker-compose -f docker-compose-shelley.yml $1
|
data/docker-compose-shelley.yml
CHANGED
@@ -7,7 +7,7 @@ services:
|
|
7
7
|
- node-db:/data
|
8
8
|
- node-ipc:/ipc
|
9
9
|
- ${NODE_CONFIG_PATH}:/config
|
10
|
-
command: run --socket-path /ipc/node.socket --config /config
|
10
|
+
command: run --socket-path /ipc/node.socket --config /config/${NETWORK}-config.json --topology /config/${NETWORK}-topology.json --database-path /data
|
11
11
|
restart: on-failure
|
12
12
|
|
13
13
|
cardano-wallet:
|
@@ -18,7 +18,7 @@ services:
|
|
18
18
|
- ${NODE_CONFIG_PATH}:/config
|
19
19
|
ports:
|
20
20
|
- 8090:8090
|
21
|
-
command: serve --testnet /config
|
21
|
+
command: serve --testnet /config/${NETWORK}-byron-genesis.json --node-socket /ipc/node.socket --database /wallet-db --listen-address 0.0.0.0
|
22
22
|
restart: on-failure
|
23
23
|
|
24
24
|
volumes:
|
data/lib/cardano_wallet.rb
CHANGED
data/lib/cardano_wallet/base.rb
CHANGED
@@ -13,7 +13,11 @@ module CardanoWallet
|
|
13
13
|
opt[:url] ||= "#{opt[:protocol]}://#{opt[:host]}:#{opt[:port]}/v2"
|
14
14
|
opt[:cacert] ||= ''
|
15
15
|
opt[:pem] ||= ''
|
16
|
+
opt[:timeout] ||= -1
|
16
17
|
self.class.base_uri opt[:url]
|
18
|
+
unless(opt[:timeout] == -1)
|
19
|
+
self.class.default_timeout(opt[:timeout].to_i)
|
20
|
+
end
|
17
21
|
|
18
22
|
unless opt[:cacert].empty?
|
19
23
|
ENV['SSL_CERT_FILE'] = opt[:cacert]
|
data/lib/cardano_wallet/byron.rb
CHANGED
@@ -22,6 +22,12 @@ module CardanoWallet
|
|
22
22
|
Addresses.new @opt
|
23
23
|
end
|
24
24
|
|
25
|
+
# API for CoinSelections
|
26
|
+
# @see https://input-output-hk.github.io/cardano-wallet/api/edge/#tag/Byron-Coin-Selections
|
27
|
+
def coin_selections
|
28
|
+
CoinSelections.new @opt
|
29
|
+
end
|
30
|
+
|
25
31
|
# Get API for Byron transactions
|
26
32
|
# @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/postByronTransactionFee
|
27
33
|
def transactions
|
@@ -152,6 +158,36 @@ module CardanoWallet
|
|
152
158
|
self.class.put("/byron-wallets/#{wid}/addresses/#{addr_id}")
|
153
159
|
end
|
154
160
|
|
161
|
+
# Import addresses to Byron wallet.
|
162
|
+
# @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/importAddresses
|
163
|
+
# @param wid [String] wallet id
|
164
|
+
# @param addresses [Array] array of addresses
|
165
|
+
def bulk_import(wid, addresses)
|
166
|
+
self.class.put("/byron-wallets/#{wid}/addresses",
|
167
|
+
:body => { :addresses => addresses
|
168
|
+
}.to_json,
|
169
|
+
:headers => { 'Content-Type' => 'application/json' } )
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
# API for CoinSelections
|
174
|
+
# @see https://input-output-hk.github.io/cardano-wallet/api/edge/#tag/Byron-Coin-Selections
|
175
|
+
class CoinSelections < Base
|
176
|
+
def initialize opt
|
177
|
+
super
|
178
|
+
end
|
179
|
+
|
180
|
+
# Show random coin selection for particular payment
|
181
|
+
# @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/byronSelectCoins
|
182
|
+
#
|
183
|
+
# @example
|
184
|
+
# random(wid, {address1: 123, address2: 456})
|
185
|
+
def random(wid, payments)
|
186
|
+
payments_formatted = Utils.format_payments(payments)
|
187
|
+
self.class.post("/byron-wallets/#{wid}/coin-selections/random",
|
188
|
+
:body => {:payments => payments_formatted}.to_json,
|
189
|
+
:headers => { 'Content-Type' => 'application/json' })
|
190
|
+
end
|
155
191
|
end
|
156
192
|
|
157
193
|
# Byron transactions
|
data/lib/cardano_wallet/misc.rb
CHANGED
@@ -15,6 +15,16 @@ module CardanoWallet
|
|
15
15
|
def network
|
16
16
|
Network.new @opt
|
17
17
|
end
|
18
|
+
|
19
|
+
# @see https://input-output-hk.github.io/cardano-wallet/api/edge/#tag/Utils
|
20
|
+
def utils
|
21
|
+
Utils.new @opt
|
22
|
+
end
|
23
|
+
|
24
|
+
# @see https://input-output-hk.github.io/cardano-wallet/api/edge/#tag/Proxy
|
25
|
+
def proxy
|
26
|
+
Proxy.new @opt
|
27
|
+
end
|
18
28
|
end
|
19
29
|
|
20
30
|
# API for Network
|
@@ -43,5 +53,34 @@ module CardanoWallet
|
|
43
53
|
end
|
44
54
|
|
45
55
|
end
|
56
|
+
|
57
|
+
# @see https://input-output-hk.github.io/cardano-wallet/api/edge/#tag/Utils
|
58
|
+
class Utils < Base
|
59
|
+
def initialize opt
|
60
|
+
super
|
61
|
+
end
|
62
|
+
|
63
|
+
# @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/inspectAddress
|
64
|
+
def addresses(address_id)
|
65
|
+
self.class.get("/addresses/#{address_id}")
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
|
70
|
+
# @see https://input-output-hk.github.io/cardano-wallet/api/edge/#tag/Proxy
|
71
|
+
class Proxy < Base
|
72
|
+
def initialize opt
|
73
|
+
super
|
74
|
+
end
|
75
|
+
|
76
|
+
# Submit a transaction that was created and signed outside of cardano-wallet.
|
77
|
+
# @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/postExternalTransaction
|
78
|
+
# @param binary_blob [String] Signed transaction message binary blob.
|
79
|
+
def submit_external_transaction(binary_blob)
|
80
|
+
self.class.post("/proxy/transactions",
|
81
|
+
:body => binary_blob,
|
82
|
+
:headers => { 'Content-Type' => 'application/octet-stream' })
|
83
|
+
end
|
84
|
+
end
|
46
85
|
end
|
47
86
|
end
|
@@ -195,17 +195,21 @@ module CardanoWallet
|
|
195
195
|
# @param wid [String] source wallet id
|
196
196
|
# @param passphrase [String] source wallet's passphrase
|
197
197
|
# @param payments [Hash] addres, amount pair
|
198
|
-
# @param
|
198
|
+
# @param withdrawal [String or Array] 'self' or mnemonic sentence
|
199
|
+
# @param metadata [Hash] special metadata JSON subset format (cf: https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/postTransaction)
|
199
200
|
#
|
200
201
|
# @example
|
201
|
-
# create(wid, passphrase, {addr1: 1000000},
|
202
|
-
def create(wid, passphrase, payments,
|
202
|
+
# create(wid, passphrase, {addr1: 1000000}, 'self', {"1": "abc"})
|
203
|
+
def create(wid, passphrase, payments, withdrawal = nil, metadata = nil)
|
203
204
|
payments_formatted = Utils.format_payments(payments)
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
205
|
+
payload = { :payments => payments_formatted,
|
206
|
+
:passphrase => passphrase
|
207
|
+
}
|
208
|
+
payload[:withdrawal] = withdrawal if withdrawal
|
209
|
+
payload[:metadata] = metadata if metadata
|
210
|
+
|
211
|
+
self.class.post("/wallets/#{wid}/transactions",
|
212
|
+
:body => payload.to_json,
|
209
213
|
:headers => { 'Content-Type' => 'application/json' } )
|
210
214
|
end
|
211
215
|
|
@@ -213,11 +217,16 @@ module CardanoWallet
|
|
213
217
|
# @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/postTransactionFee
|
214
218
|
#
|
215
219
|
# @example
|
216
|
-
# payment_fees(wid, {addr1: 1000000})
|
217
|
-
def payment_fees(wid, payments)
|
220
|
+
# payment_fees(wid, {addr1: 1000000}, {"1": "abc"})
|
221
|
+
def payment_fees(wid, payments, withdrawal = nil, metadata = nil)
|
218
222
|
payments_formatted = Utils.format_payments(payments)
|
223
|
+
payload = { :payments => payments_formatted }
|
224
|
+
|
225
|
+
payload[:withdrawal] = withdrawal if withdrawal
|
226
|
+
payload[:metadata] = metadata if metadata
|
227
|
+
|
219
228
|
self.class.post("/wallets/#{wid}/payment-fees",
|
220
|
-
:body =>
|
229
|
+
:body => payload.to_json,
|
221
230
|
:headers => { 'Content-Type' => 'application/json' } )
|
222
231
|
end
|
223
232
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cardano_wallet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Stachyra
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-09-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -70,16 +70,16 @@ dependencies:
|
|
70
70
|
name: codecov
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - "
|
73
|
+
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: 0.2.8
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - "
|
80
|
+
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
82
|
+
version: 0.2.8
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: simplecov
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -122,7 +122,6 @@ files:
|
|
122
122
|
- lib/cardano_wallet/base.rb
|
123
123
|
- lib/cardano_wallet/byron.rb
|
124
124
|
- lib/cardano_wallet/misc.rb
|
125
|
-
- lib/cardano_wallet/proxy.rb
|
126
125
|
- lib/cardano_wallet/shelley.rb
|
127
126
|
- lib/cardano_wallet/utils.rb
|
128
127
|
- lib/cardano_wallet/version.rb
|
data/lib/cardano_wallet/proxy.rb
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
module CardanoWallet
|
2
|
-
module Proxy
|
3
|
-
|
4
|
-
# Call API for Proxy
|
5
|
-
# @see https://input-output-hk.github.io/cardano-wallet/api/edge/#tag/Proxy
|
6
|
-
def self.new(opt)
|
7
|
-
Init.new opt
|
8
|
-
end
|
9
|
-
|
10
|
-
class Init < Base
|
11
|
-
def initialize opt
|
12
|
-
super
|
13
|
-
end
|
14
|
-
|
15
|
-
# Submit a transaction that was created and signed outside of cardano-wallet.
|
16
|
-
# @see https://input-output-hk.github.io/cardano-wallet/api/edge/#operation/postExternalTransaction
|
17
|
-
# @param binary_blob [String] Signed transaction message binary blob.
|
18
|
-
def submit_external_transaction(binary_blob)
|
19
|
-
self.class.post("/proxy/transactions",
|
20
|
-
:body => binary_blob,
|
21
|
-
:headers => { 'Content-Type' => 'application/octet-stream' })
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
end
|
26
|
-
end
|