cardano_wallet 0.3.25 → 0.3.27
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +38 -27
- data/cardano_wallet.gemspec +1 -1
- data/lib/cardano_wallet/base.rb +3 -3
- data/lib/cardano_wallet/shared.rb +2 -2
- data/lib/cardano_wallet/utils.rb +45 -0
- data/lib/cardano_wallet/version.rb +1 -1
- data/lib/cardano_wallet.rb +1 -0
- metadata +9 -10
- data/bin/run_all_tests +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '083f459db029fab491c2d7fddad1f0a6bfff596e08344af6e31ea75dfb9e2a21'
|
4
|
+
data.tar.gz: eb50ebc2b10e841c941fc36250bc0d035d52b785fc2920961b9c563b0410c9ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 14ca8505a76dc7d21474b92a7e444d76b4b436e8f33ec7553b3a0a49eb1bb83e415eedc0ade4d6fb50353981eb20f56c129f786576ad1c0ed5c1ac216eeb6205
|
7
|
+
data.tar.gz: 94ae2907f02096c838b97c9097ee71668ddbbdb293ec2b1786d3ecd505ecfc2c6344c45d9f82016846d5031f22bac7b55ef137621d0bd994290ee03c28558c16
|
data/README.md
CHANGED
@@ -13,11 +13,9 @@
|
|
13
13
|
|
14
14
|
# cardano-wallet-rb
|
15
15
|
|
16
|
-
Ruby wrapper over [cardano-wallet's](https://github.com/input-output-hk/cardano-wallet) REST [API](https://input-output-hk.github.io/cardano-wallet/api/edge/).
|
16
|
+
Ruby wrapper over [cardano-wallet's](https://github.com/input-output-hk/cardano-wallet) REST [API](https://input-output-hk.github.io/cardano-wallet/api/edge/). Requires running `cardano-wallet`.
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
Cardano-wallet-rb is used for e2e testing of [cardano-wallet](https://github.com/input-output-hk/cardano-wallet/test/e2e) against public testnet.
|
18
|
+
Cardano-wallet-rb is used for e2e testing of [cardano-wallet](https://github.com/input-output-hk/cardano-wallet/test/e2e) and also as a backend of [Ikar](https://github.com/piotr-iohk/ikar).
|
21
19
|
|
22
20
|
|
23
21
|
## Installation
|
@@ -38,7 +36,7 @@ For ruby doc see: https://rubydoc.info/gems/cardano_wallet.
|
|
38
36
|
|
39
37
|
For `cardano-wallet` REST Api see: https://input-output-hk.github.io/cardano-wallet/api/edge/.
|
40
38
|
|
41
|
-
##
|
39
|
+
## Examples
|
42
40
|
|
43
41
|
```ruby
|
44
42
|
CW = CardanoWallet.new
|
@@ -48,16 +46,48 @@ SHELLEY = CW.shelley
|
|
48
46
|
MISC = CW.misc
|
49
47
|
|
50
48
|
#Byron
|
49
|
+
BYRON.wallets.create({name: "Byron",
|
50
|
+
style: "random",
|
51
|
+
mnemonic_sentence: CW.utils.mnemonic_sentence,
|
52
|
+
passphrase: "Secure Passphrase"})
|
53
|
+
|
51
54
|
BYRON.wallets.list.each_with_index do |wal, i|
|
52
55
|
BYRON.wallets.update_metadata(wal['id'], {name: "Wallet number #{i}"})
|
53
56
|
end
|
54
57
|
|
58
|
+
BYRON.wallets.list.each do |wal|
|
59
|
+
puts wal['name']
|
60
|
+
end
|
61
|
+
|
55
62
|
#Shelley
|
56
|
-
w = SHELLEY.wallets.create{name: "
|
57
|
-
mnemonic_sentence:
|
58
|
-
passphrase: "Secure Passphrase"}
|
63
|
+
w = SHELLEY.wallets.create({name: "Shelley",
|
64
|
+
mnemonic_sentence: CW.utils.mnemonic_sentence,
|
65
|
+
passphrase: "Secure Passphrase"})
|
59
66
|
|
60
67
|
SHELLEY.wallets.get(w['id'])
|
68
|
+
SHELLEY.wallets.delete(w['id'])
|
69
|
+
|
70
|
+
# Transaction
|
71
|
+
wid = '1f82e...ccd95'
|
72
|
+
metadata = { "1" => "test"}
|
73
|
+
tx_c = SHELLEY.transactions.construct(wid, payments = nil, withdrawal = nil, metadata)
|
74
|
+
tx_s = SHELLEY.transactions.sign(wid, 'Secure Passphrase', tx_c['transaction'])
|
75
|
+
tx_sub = SHELLEY.transactions.submit(wid, tx_s['transaction'])
|
76
|
+
puts SHELLEY.transactions.get(wid, tx_sub['id'])
|
77
|
+
|
78
|
+
# Delegation
|
79
|
+
wid = '1f82e...ccd95'
|
80
|
+
random_stake_pool_id = SHELLEY.stake_pools.list({stake: 10000}).sample['id']
|
81
|
+
delegation = [{
|
82
|
+
"join" => {
|
83
|
+
"pool" => random_stake_pool_id,
|
84
|
+
"stake_key_index" => "0H"
|
85
|
+
}
|
86
|
+
}]
|
87
|
+
tx_c = SHELLEY.transactions.construct(wid, payments = nil, withdrawal = nil, metadata = nil, delegation)
|
88
|
+
tx_s = SHELLEY.transactions.sign(wid, 'Secure Passphrase', tx_c['transaction'])
|
89
|
+
tx_sub = SHELLEY.transactions.submit(wid, tx_s['transaction'])
|
90
|
+
puts SHELLEY.transactions.get(wid, tx_sub['id'])
|
61
91
|
|
62
92
|
#Misc
|
63
93
|
MISC.network.information
|
@@ -68,25 +98,6 @@ MISC.utils.addresses("addr_test1vqrlltfahghjxl5sy5h5mvfrrlt6me5fqphhwjqvj5jd88cc
|
|
68
98
|
|
69
99
|
Refer to [documentation](https://rubydoc.info/gems/cardano_wallet) for more details.
|
70
100
|
|
71
|
-
## Development
|
72
|
-
|
73
|
-
In order to spin up environment for development and testing `docker-compose` can be used. For instance:
|
74
|
-
|
75
|
-
# Byron testnet
|
76
|
-
$ NETWORK=testnet WALLET=dev-master-byron NODE=latest docker-compose up --detach
|
77
|
-
|
78
|
-
or
|
79
|
-
|
80
|
-
# Shelley testnet
|
81
|
-
$ NODE=1.13.0 WALLET=dev-master-shelley NODE_CONFIG_PATH=`pwd`/spec/shelley-testnet/ docker-compose -f docker-compose-shelley.yml up
|
82
|
-
|
83
|
-
Run tests on top of that:
|
84
|
-
|
85
|
-
$ rake
|
86
|
-
|
87
|
-
Clean up docker stuff after, e.g.:
|
88
|
-
|
89
|
-
$ NETWORK=... docker-compose down --rmi all --remove-orphans
|
90
101
|
|
91
102
|
## Contributing
|
92
103
|
|
data/cardano_wallet.gemspec
CHANGED
@@ -30,9 +30,9 @@ Gem::Specification.new do |spec|
|
|
30
30
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
31
31
|
spec.require_paths = ['lib']
|
32
32
|
|
33
|
+
spec.add_runtime_dependency 'bip_mnemonic', '~> 0.0.4'
|
33
34
|
spec.add_runtime_dependency 'httparty', '~> 0.18.0'
|
34
35
|
|
35
|
-
spec.add_development_dependency 'bip_mnemonic', '~> 0.0.4'
|
36
36
|
spec.add_development_dependency 'codecov', '0.2.8'
|
37
37
|
spec.add_development_dependency 'rake', '~> 12.3'
|
38
38
|
spec.add_development_dependency 'rspec', '~> 3.7'
|
data/lib/cardano_wallet/base.rb
CHANGED
@@ -92,7 +92,7 @@ module CardanoWallet
|
|
92
92
|
'transaction' => transaction
|
93
93
|
}
|
94
94
|
payload[:encoding] = encoding if encoding
|
95
|
-
self.class.post("/wallets/#{wid}/transactions-sign",
|
95
|
+
self.class.post("/shared-wallets/#{wid}/transactions-sign",
|
96
96
|
body: payload.to_json,
|
97
97
|
headers: { 'Content-Type' => 'application/json' })
|
98
98
|
end
|
@@ -103,7 +103,7 @@ module CardanoWallet
|
|
103
103
|
# @param transaction [String] CBOR transaction data
|
104
104
|
def submit(wid, transaction)
|
105
105
|
payload = { 'transaction' => transaction }
|
106
|
-
self.class.post("/wallets/#{wid}/transactions-submit",
|
106
|
+
self.class.post("/shared-wallets/#{wid}/transactions-submit",
|
107
107
|
body: payload.to_json,
|
108
108
|
headers: { 'Content-Type' => 'application/json' })
|
109
109
|
end
|
data/lib/cardano_wallet/utils.rb
CHANGED
@@ -4,6 +4,51 @@ module CardanoWallet
|
|
4
4
|
##
|
5
5
|
# General Utils not connected to API
|
6
6
|
module Utils
|
7
|
+
def self.new(opt)
|
8
|
+
Init.new opt
|
9
|
+
end
|
10
|
+
|
11
|
+
# Init
|
12
|
+
class Init < Base
|
13
|
+
# Generate mnemonic sentence
|
14
|
+
#
|
15
|
+
# @example Default 24-word English mnemonic sentence
|
16
|
+
# CardanoWallet.new.utils.mnemonic_sentence
|
17
|
+
# ["kiwi", "rent", "denial",...]
|
18
|
+
#
|
19
|
+
# @example 15-word French mnemonic sentence
|
20
|
+
# CardanoWallet.new.utils.mnemonic_sentence(15, 'french')
|
21
|
+
# ["ruser", "malaxer", "forgeron",...]
|
22
|
+
def mnemonic_sentence(word_count = 24, language = 'english')
|
23
|
+
languages = %w[english french spanish korean japanese
|
24
|
+
italian chinese_traditional chinese_simplified]
|
25
|
+
unless languages.include?(language)
|
26
|
+
raise ArgumentError,
|
27
|
+
%(Not supported language: '#{language}'. Supported languages are: #{languages}.)
|
28
|
+
end
|
29
|
+
|
30
|
+
words = [9, 12, 15, 18, 21, 24]
|
31
|
+
case word_count
|
32
|
+
when 9
|
33
|
+
bits = 96
|
34
|
+
when 12
|
35
|
+
bits = 128
|
36
|
+
when 15
|
37
|
+
bits = 164
|
38
|
+
when 18
|
39
|
+
bits = 196
|
40
|
+
when 21
|
41
|
+
bits = 224
|
42
|
+
when 24
|
43
|
+
bits = 256
|
44
|
+
else
|
45
|
+
raise ArgumentError,
|
46
|
+
%(Not supported count of words #{word_count}. Supported counts are: #{words}.)
|
47
|
+
end
|
48
|
+
BipMnemonic.to_mnemonic(bits: bits, language: language).split
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
7
52
|
def self.verify_param_is_hash!(param)
|
8
53
|
raise ArgumentError, 'argument should be Hash' unless param.is_a?(Hash)
|
9
54
|
end
|
data/lib/cardano_wallet.rb
CHANGED
metadata
CHANGED
@@ -1,43 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cardano_wallet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.27
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Stachyra
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-09-
|
11
|
+
date: 2022-09-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: bip_mnemonic
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.0.4
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.
|
26
|
+
version: 0.0.4
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: httparty
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.0
|
34
|
-
type: :
|
33
|
+
version: 0.18.0
|
34
|
+
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.0
|
40
|
+
version: 0.18.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: codecov
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -128,7 +128,6 @@ files:
|
|
128
128
|
- README.md
|
129
129
|
- Rakefile
|
130
130
|
- bin/console
|
131
|
-
- bin/run_all_tests
|
132
131
|
- bin/setup
|
133
132
|
- cardano_wallet.gemspec
|
134
133
|
- dev
|