nano_rpc 0.17.0 → 0.18.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/lib/nano_rpc/helpers/accounts_helper.rb +1 -1
- data/lib/nano_rpc/methods/account_methods.rb +59 -0
- data/lib/nano_rpc/methods/accounts_methods.rb +24 -0
- data/lib/nano_rpc/methods/node_methods.rb +132 -0
- data/lib/nano_rpc/methods/wallet_methods.rb +81 -0
- data/lib/nano_rpc/node.rb +4 -80
- data/lib/nano_rpc/proxies/account.rb +5 -28
- data/lib/nano_rpc/proxies/accounts.rb +5 -11
- data/lib/nano_rpc/proxies/wallet.rb +4 -36
- data/lib/nano_rpc/proxy.rb +15 -51
- data/lib/nano_rpc/version.rb +1 -1
- data/lib/nano_rpc.rb +9 -3
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cf8be3c6d2bd25560020572dc8cbd1dba8b65a607ea73b2d9c6bc93dfbc33ed1
|
4
|
+
data.tar.gz: 9a2ea203060e6f87eaccd7fc025285c44141c863187599adcce8c498f78f2cce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ecabcb82404154f872356760c16e75be8509195c27867a968053807ce5c4ba3750dcf1ae00ff14110a644376ae666501b7468291828e126fc03a6f5ff593f41f
|
7
|
+
data.tar.gz: b1acca37bba5ebf7d970fb795681681863fbbb313772387827cec46976d05dd70c36e39d7a421052ff672dbc70b99d15500d5940de4d5d222cf9a04d38d5a059
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module NanoRpc::AccountMethods
|
3
|
+
def proxy_params
|
4
|
+
{ account: :address }
|
5
|
+
end
|
6
|
+
|
7
|
+
def proxy_methods # rubocop:disable Metrics/MethodLength
|
8
|
+
{
|
9
|
+
account_balance: {},
|
10
|
+
account_block_count: {},
|
11
|
+
|
12
|
+
account_create: {
|
13
|
+
required: %i[wallet],
|
14
|
+
optional: %i[work]
|
15
|
+
},
|
16
|
+
account_history: {
|
17
|
+
required: %i[count]
|
18
|
+
},
|
19
|
+
account_info: {},
|
20
|
+
account_key: {},
|
21
|
+
account_move: {
|
22
|
+
required: %i[wallet source accounts]
|
23
|
+
},
|
24
|
+
account_remove: {
|
25
|
+
required: %i[wallet]
|
26
|
+
},
|
27
|
+
account_representative: {},
|
28
|
+
account_representative_set: {
|
29
|
+
required: %i[wallet representative]
|
30
|
+
},
|
31
|
+
account_weight: {},
|
32
|
+
delegators: {},
|
33
|
+
delegators_count: {},
|
34
|
+
frontiers: {
|
35
|
+
required: %i[count]
|
36
|
+
},
|
37
|
+
ledger: {
|
38
|
+
required: %i[count],
|
39
|
+
optional: %i[representative weight pending modified_since sorting]
|
40
|
+
},
|
41
|
+
payment_wait: {
|
42
|
+
required: %i[amount timeout]
|
43
|
+
},
|
44
|
+
pending: {
|
45
|
+
required: %i[count],
|
46
|
+
optional: %i[threshold exists source]
|
47
|
+
},
|
48
|
+
receive: {
|
49
|
+
required: %i[wallet block],
|
50
|
+
optional: %i[work]
|
51
|
+
},
|
52
|
+
validate_account_number: {},
|
53
|
+
work_get: {
|
54
|
+
required: %i[wallet]
|
55
|
+
},
|
56
|
+
work_set: {}
|
57
|
+
}
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module NanoRpc::AccountsMethods
|
3
|
+
def proxy_params
|
4
|
+
{ accounts: :addresses }
|
5
|
+
end
|
6
|
+
|
7
|
+
def proxy_methods # rubocop:disable Metrics/MethodLength
|
8
|
+
{
|
9
|
+
account_move: {
|
10
|
+
required: %i[wallet source]
|
11
|
+
},
|
12
|
+
accounts_balances: {},
|
13
|
+
accounts_create: {
|
14
|
+
required: %i[wallet count],
|
15
|
+
optional: %i[work]
|
16
|
+
},
|
17
|
+
accounts_frontiers: {},
|
18
|
+
accounts_pending: {
|
19
|
+
required: %i[count],
|
20
|
+
optional: %i[threshold source]
|
21
|
+
}
|
22
|
+
}
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,132 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module NanoRpc::NodeMethods
|
3
|
+
def proxy_params
|
4
|
+
{}
|
5
|
+
end
|
6
|
+
|
7
|
+
def proxy_methods # rubocop:disable Metrics/MethodLength
|
8
|
+
{
|
9
|
+
available_supply: {},
|
10
|
+
block: {
|
11
|
+
required: %i[hash]
|
12
|
+
},
|
13
|
+
block_account: {
|
14
|
+
required: %i[hash]
|
15
|
+
},
|
16
|
+
block_confirm: {
|
17
|
+
required: %i[hash]
|
18
|
+
},
|
19
|
+
block_count: {},
|
20
|
+
block_count_type: {},
|
21
|
+
block_create: {
|
22
|
+
required: %i[type key representative source],
|
23
|
+
optional: %i[work]
|
24
|
+
},
|
25
|
+
blocks: {
|
26
|
+
required: %i[hashes]
|
27
|
+
},
|
28
|
+
blocks_info: {
|
29
|
+
required: %i[hashes],
|
30
|
+
optional: %i[pending source balance]
|
31
|
+
},
|
32
|
+
bootstrap: {
|
33
|
+
required: %i[address port]
|
34
|
+
},
|
35
|
+
bootstrap_any: {},
|
36
|
+
chain: {
|
37
|
+
required: %i[block count]
|
38
|
+
},
|
39
|
+
confirmation_history: {},
|
40
|
+
deterministic_key: {
|
41
|
+
required: %i[seed index]
|
42
|
+
},
|
43
|
+
frontier_count: {},
|
44
|
+
history: {
|
45
|
+
required: %i[hash count]
|
46
|
+
},
|
47
|
+
keepalive: {
|
48
|
+
required: %i[address port]
|
49
|
+
},
|
50
|
+
key_create: {},
|
51
|
+
key_expand: {
|
52
|
+
required: %i[key]
|
53
|
+
},
|
54
|
+
krai_from_raw: {
|
55
|
+
required: %i[amount]
|
56
|
+
},
|
57
|
+
krai_to_raw: {
|
58
|
+
required: %i[amount]
|
59
|
+
},
|
60
|
+
mrai_from_raw: {
|
61
|
+
required: %i[amount]
|
62
|
+
},
|
63
|
+
mrai_to_raw: {
|
64
|
+
required: %i[amount]
|
65
|
+
},
|
66
|
+
payment_wait: {
|
67
|
+
required: %i[account amount timeout]
|
68
|
+
},
|
69
|
+
peers: {},
|
70
|
+
pending_exists: {
|
71
|
+
required: %i[hash]
|
72
|
+
},
|
73
|
+
process: {
|
74
|
+
required: %i[block]
|
75
|
+
},
|
76
|
+
rai_from_raw: {
|
77
|
+
required: %i[amount]
|
78
|
+
},
|
79
|
+
rai_to_raw: {
|
80
|
+
required: %i[amount]
|
81
|
+
},
|
82
|
+
receive_minimum: {},
|
83
|
+
receive_minimum_set: {
|
84
|
+
required: %i[amount]
|
85
|
+
},
|
86
|
+
representatives: {},
|
87
|
+
representatives_online: {},
|
88
|
+
republish: {
|
89
|
+
required: %i[hash],
|
90
|
+
optional: %i[count sources destinations]
|
91
|
+
},
|
92
|
+
search_pending: {
|
93
|
+
required: %i[wallet]
|
94
|
+
},
|
95
|
+
search_pending_all: {},
|
96
|
+
stats: {
|
97
|
+
required: %i[type]
|
98
|
+
},
|
99
|
+
stop: {},
|
100
|
+
successors: {
|
101
|
+
required: %i[block count]
|
102
|
+
},
|
103
|
+
unchecked: {
|
104
|
+
required: %i[count]
|
105
|
+
},
|
106
|
+
unchecked_clear: {},
|
107
|
+
unchecked_get: {
|
108
|
+
required: %i[hash]
|
109
|
+
},
|
110
|
+
unchecked_keys: {
|
111
|
+
required: %i[key count]
|
112
|
+
},
|
113
|
+
version: {},
|
114
|
+
wallet_create: {},
|
115
|
+
work_cancel: {
|
116
|
+
required: %i[hash]
|
117
|
+
},
|
118
|
+
work_generate: {
|
119
|
+
required: %i[hash],
|
120
|
+
optional: %i[use_peers]
|
121
|
+
},
|
122
|
+
work_peer_add: {
|
123
|
+
required: %i[address port]
|
124
|
+
},
|
125
|
+
work_peers: {},
|
126
|
+
work_peers_clear: {},
|
127
|
+
work_validate: {
|
128
|
+
required: %i[work hash]
|
129
|
+
}
|
130
|
+
}
|
131
|
+
end
|
132
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module NanoRpc::WalletMethods
|
3
|
+
def proxy_params
|
4
|
+
{ wallet: :id }
|
5
|
+
end
|
6
|
+
|
7
|
+
def proxy_methods # rubocop:disable Metrics/MethodLength
|
8
|
+
{
|
9
|
+
account_create: {
|
10
|
+
optional: %i[work]
|
11
|
+
},
|
12
|
+
account_list: {},
|
13
|
+
account_remove: {
|
14
|
+
required: %i[account]
|
15
|
+
},
|
16
|
+
accounts_create: {
|
17
|
+
required: %i[count],
|
18
|
+
optional: %i[work]
|
19
|
+
},
|
20
|
+
password_change: {
|
21
|
+
required: %i[password]
|
22
|
+
},
|
23
|
+
password_enter: {
|
24
|
+
required: %i[password]
|
25
|
+
},
|
26
|
+
password_valid: {},
|
27
|
+
payment_begin: {},
|
28
|
+
payment_end: {
|
29
|
+
required: %i[account]
|
30
|
+
},
|
31
|
+
payment_init: {},
|
32
|
+
receive: {
|
33
|
+
required: %i[account block],
|
34
|
+
optional: %i[work]
|
35
|
+
},
|
36
|
+
search_pending: {},
|
37
|
+
send: {
|
38
|
+
required: %i[wallet source destination amount],
|
39
|
+
optional: %i[id work]
|
40
|
+
},
|
41
|
+
wallet_add: {
|
42
|
+
required: %i[key],
|
43
|
+
optional: %i[work]
|
44
|
+
},
|
45
|
+
wallet_add_watch: {
|
46
|
+
required: %i[accounts]
|
47
|
+
},
|
48
|
+
wallet_balance_total: {},
|
49
|
+
wallet_balances: {
|
50
|
+
optional: %i[threshold]
|
51
|
+
},
|
52
|
+
wallet_change_seed: {
|
53
|
+
required: %i[seed]
|
54
|
+
},
|
55
|
+
wallet_contains: {
|
56
|
+
required: %i[account]
|
57
|
+
},
|
58
|
+
wallet_destroy: {},
|
59
|
+
wallet_export: {},
|
60
|
+
wallet_frontiers: {},
|
61
|
+
wallet_ledger: {},
|
62
|
+
wallet_locked: {},
|
63
|
+
wallet_pending: {
|
64
|
+
required: %i[count],
|
65
|
+
optional: %i[threshold source]
|
66
|
+
},
|
67
|
+
wallet_representative: {},
|
68
|
+
wallet_representative_set: {
|
69
|
+
required: %i[representative]
|
70
|
+
},
|
71
|
+
wallet_republish: {
|
72
|
+
required: %i[count]
|
73
|
+
},
|
74
|
+
wallet_work_get: {},
|
75
|
+
work_get: {
|
76
|
+
required: %i[account]
|
77
|
+
},
|
78
|
+
work_set: {}
|
79
|
+
}
|
80
|
+
end
|
81
|
+
end
|
data/lib/nano_rpc/node.rb
CHANGED
@@ -9,8 +9,9 @@ module NanoRpc
|
|
9
9
|
end
|
10
10
|
|
11
11
|
class NanoRpc::Node
|
12
|
-
include NanoRpc::Proxy
|
13
12
|
include NanoRpc::NodeHelper
|
13
|
+
include NanoRpc::NodeMethods
|
14
|
+
include NanoRpc::Proxy
|
14
15
|
|
15
16
|
attr_reader :host, :port, :auth, :headers, :node, :timeout
|
16
17
|
|
@@ -40,98 +41,21 @@ class NanoRpc::Node
|
|
40
41
|
rpc_post(args)
|
41
42
|
end
|
42
43
|
|
43
|
-
# Condense host/port on object inspection
|
44
44
|
def inspect
|
45
45
|
"#{inspect_prefix}, @url=\"#{@host}:#{port}\">"
|
46
46
|
end
|
47
47
|
|
48
|
-
proxy_method :available_supply
|
49
|
-
proxy_method :block, required: %i[hash]
|
50
|
-
proxy_method :block_account, required: %i[hash]
|
51
|
-
proxy_method :block_confirm, required: %i[hash]
|
52
|
-
proxy_method :block_count
|
53
|
-
proxy_method :block_count_type
|
54
|
-
proxy_method :block_create,
|
55
|
-
required: %i[type key representative source],
|
56
|
-
optional: %i[work]
|
57
|
-
proxy_method :blocks, required: %i[hashes]
|
58
|
-
proxy_method :blocks_info,
|
59
|
-
required: %i[hashes],
|
60
|
-
optional: %i[pending source balance]
|
61
|
-
proxy_method :bootstrap, required: %i[address port]
|
62
|
-
proxy_method :bootstrap_any
|
63
|
-
proxy_method :chain, required: %i[block count]
|
64
|
-
proxy_method :confirmation_history
|
65
|
-
proxy_method :deterministic_key, required: %i[seed index]
|
66
|
-
proxy_method :frontier_count
|
67
|
-
proxy_method :history, required: %i[hash count]
|
68
|
-
proxy_method :keepalive, required: %i[address port]
|
69
|
-
proxy_method :key_create
|
70
|
-
proxy_method :key_expand, required: %i[key]
|
71
|
-
proxy_method :krai_from_raw, required: %i[amount]
|
72
|
-
proxy_method :krai_to_raw, required: %i[amount]
|
73
|
-
proxy_method :mrai_from_raw, required: %i[amount]
|
74
|
-
proxy_method :mrai_to_raw, required: %i[amount]
|
75
|
-
proxy_method :payment_wait, required: %i[account amount timeout]
|
76
|
-
proxy_method :peers
|
77
|
-
proxy_method :pending_exists, required: %i[hash]
|
78
|
-
proxy_method :process, required: %i[block]
|
79
|
-
proxy_method :rai_from_raw, required: %i[amount]
|
80
|
-
proxy_method :rai_to_raw, required: %i[amount]
|
81
|
-
proxy_method :receive_minimum
|
82
|
-
proxy_method :receive_minimum_set, required: %i[amount]
|
83
|
-
proxy_method :representatives
|
84
|
-
proxy_method :representatives_online
|
85
|
-
proxy_method :republish,
|
86
|
-
required: %i[hash],
|
87
|
-
optional: %i[count sources destinations]
|
88
|
-
proxy_method :search_pending, required: %i[wallet]
|
89
|
-
proxy_method :search_pending_all
|
90
|
-
proxy_method :stats, required: %i[type]
|
91
|
-
proxy_method :stop
|
92
|
-
proxy_method :successors, required: %i[block count]
|
93
|
-
proxy_method :unchecked, required: %i[count]
|
94
|
-
proxy_method :unchecked_clear
|
95
|
-
proxy_method :unchecked_get, required: %i[hash]
|
96
|
-
proxy_method :unchecked_keys, required: %i[key count]
|
97
|
-
proxy_method :receive_minimum
|
98
|
-
proxy_method :receive_minimum_set, required: %i[amount]
|
99
|
-
proxy_method :representatives
|
100
|
-
proxy_method :representatives_online
|
101
|
-
proxy_method :republish,
|
102
|
-
required: %i[hash],
|
103
|
-
optional: %i[count sources destinations]
|
104
|
-
proxy_method :search_pending, required: %i[wallet]
|
105
|
-
proxy_method :search_pending_all
|
106
|
-
proxy_method :stats, required: %i[type]
|
107
|
-
proxy_method :stop
|
108
|
-
proxy_method :successors, required: %i[block count]
|
109
|
-
proxy_method :unchecked, required: %i[count]
|
110
|
-
proxy_method :unchecked_clear
|
111
|
-
proxy_method :unchecked_get, required: %i[hash]
|
112
|
-
proxy_method :unchecked_keys, required: %i[key count]
|
113
|
-
proxy_method :version
|
114
|
-
proxy_method :wallet_create
|
115
|
-
proxy_method :work_cancel, required: %i[hash]
|
116
|
-
proxy_method :work_generate,
|
117
|
-
required: %i[hash],
|
118
|
-
optional: %i[use_peers]
|
119
|
-
proxy_method :work_peer_add, required: %i[address port]
|
120
|
-
proxy_method :work_peers
|
121
|
-
proxy_method :work_peers_clear
|
122
|
-
proxy_method :work_validate, required: %i[work hash]
|
123
|
-
|
124
48
|
private
|
125
49
|
|
126
50
|
def extract_proxy_args(args)
|
127
51
|
args.each do |k, v|
|
128
|
-
m =
|
52
|
+
m = proxy_method_name(v)
|
129
53
|
args[k] = v.send(m) if m
|
130
54
|
end
|
131
55
|
args
|
132
56
|
end
|
133
57
|
|
134
|
-
def
|
58
|
+
def proxy_method_name(obj)
|
135
59
|
if obj.is_a?(NanoRpc::Wallet)
|
136
60
|
:id
|
137
61
|
elsif obj.is_a?(NanoRpc::Accounts)
|
@@ -1,7 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
class NanoRpc::Account
|
3
|
-
include NanoRpc::Proxy
|
4
3
|
include NanoRpc::AccountHelper
|
4
|
+
include NanoRpc::AccountMethods
|
5
|
+
include NanoRpc::Proxy
|
5
6
|
|
6
7
|
attr_reader :address
|
7
8
|
|
@@ -15,31 +16,7 @@ class NanoRpc::Account
|
|
15
16
|
super(opts)
|
16
17
|
end
|
17
18
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
proxy_method :account_block_count
|
22
|
-
proxy_method :account_info
|
23
|
-
proxy_method :account_create, required: %i[wallet], optional: %i[work]
|
24
|
-
proxy_method :account_history, required: %i[count]
|
25
|
-
proxy_method :account_move, required: %i[wallet source accounts]
|
26
|
-
proxy_method :account_key
|
27
|
-
proxy_method :account_remove, required: %i[wallet]
|
28
|
-
proxy_method :account_representative
|
29
|
-
proxy_method :account_representative_set, required: %i[wallet representative]
|
30
|
-
proxy_method :account_weight
|
31
|
-
proxy_method :delegators
|
32
|
-
proxy_method :delegators_count
|
33
|
-
proxy_method :frontiers, required: %i[count]
|
34
|
-
proxy_method :ledger,
|
35
|
-
required: %i[count],
|
36
|
-
optional: %i[
|
37
|
-
representative weight pending modified_since sorting
|
38
|
-
]
|
39
|
-
proxy_method :validate_account_number
|
40
|
-
proxy_method :pending, required: %i[count], optional: %i[threshold exists source]
|
41
|
-
proxy_method :payment_wait, required: %i[amount timeout]
|
42
|
-
proxy_method :receive, required: %i[wallet block], optional: %i[work]
|
43
|
-
proxy_method :work_get, required: %i[wallet]
|
44
|
-
proxy_method :work_set
|
19
|
+
def inspect
|
20
|
+
"#{inspect_prefix}, @address=\"#{@address}\">"
|
21
|
+
end
|
45
22
|
end
|
@@ -1,7 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
class NanoRpc::Accounts
|
3
|
-
include NanoRpc::Proxy
|
4
3
|
include NanoRpc::AccountsHelper
|
4
|
+
include NanoRpc::AccountsMethods
|
5
|
+
include NanoRpc::Proxy
|
5
6
|
|
6
7
|
attr_reader :addresses
|
7
8
|
|
@@ -15,14 +16,7 @@ class NanoRpc::Accounts
|
|
15
16
|
super(opts)
|
16
17
|
end
|
17
18
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
proxy_method :accounts_balances
|
22
|
-
proxy_method :accounts_create,
|
23
|
-
required: %i[wallet count],
|
24
|
-
optional: %i[work]
|
25
|
-
proxy_method :accounts_frontiers
|
26
|
-
proxy_method :accounts_pending,
|
27
|
-
required: %i[count], optional: %i[threshold source]
|
19
|
+
def inspect
|
20
|
+
"#{inspect_prefix}, @addresses=\"#{@addresses}\">"
|
21
|
+
end
|
28
22
|
end
|
@@ -2,6 +2,7 @@
|
|
2
2
|
class NanoRpc::Wallet
|
3
3
|
include NanoRpc::Proxy
|
4
4
|
include NanoRpc::WalletHelper
|
5
|
+
include NanoRpc::WalletMethods
|
5
6
|
|
6
7
|
attr_reader :id
|
7
8
|
|
@@ -15,40 +16,7 @@ class NanoRpc::Wallet
|
|
15
16
|
super(opts)
|
16
17
|
end
|
17
18
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
proxy_method :accounts_create, required: %i[count], optional: %i[work]
|
22
|
-
proxy_method :account_list
|
23
|
-
proxy_method :account_remove, required: %i[account]
|
24
|
-
proxy_method :password_change, required: %i[password]
|
25
|
-
proxy_method :password_enter, required: %i[password]
|
26
|
-
proxy_method :password_valid
|
27
|
-
proxy_method :payment_begin
|
28
|
-
proxy_method :payment_init
|
29
|
-
proxy_method :payment_end, required: %i[account]
|
30
|
-
proxy_method :receive, required: %i[account block], optional: %i[work]
|
31
|
-
proxy_method :send,
|
32
|
-
required: %i[wallet source destination amount],
|
33
|
-
optional: %i[id work]
|
34
|
-
proxy_method :search_pending
|
35
|
-
proxy_method :wallet_add, required: %i[key], optional: %i[work]
|
36
|
-
proxy_method :wallet_add_watch, required: %i[accounts]
|
37
|
-
proxy_method :wallet_balance_total
|
38
|
-
proxy_method :wallet_balances, optional: %i[threshold]
|
39
|
-
proxy_method :wallet_change_seed, required: %i[seed]
|
40
|
-
proxy_method :wallet_contains, required: %i[account]
|
41
|
-
proxy_method :wallet_destroy
|
42
|
-
proxy_method :wallet_export
|
43
|
-
proxy_method :wallet_frontiers
|
44
|
-
proxy_method :wallet_ledger
|
45
|
-
proxy_method :wallet_locked
|
46
|
-
proxy_method :wallet_pending,
|
47
|
-
required: %i[count], optional: %i[threshold source]
|
48
|
-
proxy_method :wallet_representative
|
49
|
-
proxy_method :wallet_representative_set, required: %i[representative]
|
50
|
-
proxy_method :wallet_republish, required: %i[count]
|
51
|
-
proxy_method :wallet_work_get
|
52
|
-
proxy_method :work_get, required: %i[account]
|
53
|
-
proxy_method :work_set
|
19
|
+
def inspect
|
20
|
+
"#{inspect_prefix}, @id=\"#{@id}\">"
|
21
|
+
end
|
54
22
|
end
|
data/lib/nano_rpc/proxy.rb
CHANGED
@@ -4,38 +4,13 @@ module NanoRpc::Proxy
|
|
4
4
|
|
5
5
|
def initialize(opts = {})
|
6
6
|
@node ||= opts[:node] || NanoRpc.node
|
7
|
-
|
8
|
-
end
|
9
|
-
|
10
|
-
def self.included(base)
|
11
|
-
base.extend(ClassMethods)
|
12
|
-
end
|
13
|
-
module ClassMethods
|
14
|
-
attr_reader :proxy_method_def, :proxy_param_def
|
15
|
-
|
16
|
-
def proxy_params(param_def = nil)
|
17
|
-
@proxy_param_def = param_def
|
18
|
-
end
|
19
|
-
|
20
|
-
def proxy_method(name, signature = nil)
|
21
|
-
@proxy_method_def ||= {}
|
22
|
-
@proxy_method_def[name] = signature
|
23
|
-
end
|
24
|
-
|
25
|
-
def proxy_methods
|
26
|
-
proxy_method_def&.keys&.sort
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
def proxy_methods
|
31
|
-
self.class.proxy_methods
|
7
|
+
proxy_methods.each { |meth, _| define_proxy_method(meth) }
|
32
8
|
end
|
33
9
|
|
34
10
|
private
|
35
11
|
|
36
12
|
def define_proxy_method(meth)
|
37
|
-
self.class
|
38
|
-
.send(:define_method, method_alias(meth)) do |args = {}|
|
13
|
+
self.class.send(:define_method, method_alias(meth)) do |args = {}|
|
39
14
|
@meth = meth
|
40
15
|
@call_args = args
|
41
16
|
validate_params
|
@@ -49,14 +24,10 @@ module NanoRpc::Proxy
|
|
49
24
|
end
|
50
25
|
|
51
26
|
def base_params
|
52
|
-
@base_params ||=
|
53
|
-
|
54
|
-
self.class
|
55
|
-
.proxy_param_def
|
56
|
-
.each_with_object({}) do |(k, v), params|
|
27
|
+
@base_params ||=
|
28
|
+
proxy_params.each_with_object({}) do |(k, v), params|
|
57
29
|
params[k] ||= send(v)
|
58
30
|
end
|
59
|
-
end
|
60
31
|
end
|
61
32
|
|
62
33
|
# Nano `send` action is also the method caller in Ruby ;)
|
@@ -82,11 +53,12 @@ module NanoRpc::Proxy
|
|
82
53
|
def prepare_params
|
83
54
|
# Allow non-Hash literal argument if this method requires single param
|
84
55
|
# Ex `create('new')` vs `create(name: 'new')`
|
85
|
-
@call_args =
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
56
|
+
@call_args =
|
57
|
+
if required_params.size == 1 && !@call_args.is_a?(Hash)
|
58
|
+
{ required_params.first => @call_args }
|
59
|
+
else
|
60
|
+
@call_args.is_a?(Hash) ? @call_args : {}
|
61
|
+
end
|
90
62
|
@call_args.merge!(base_params) if base_params
|
91
63
|
end
|
92
64
|
|
@@ -117,24 +89,16 @@ module NanoRpc::Proxy
|
|
117
89
|
end
|
118
90
|
|
119
91
|
def required_params
|
120
|
-
return [] unless
|
121
|
-
|
92
|
+
return [] unless proxy_methods[@meth]
|
93
|
+
proxy_methods[@meth][:required] || []
|
122
94
|
end
|
123
95
|
|
124
96
|
def optional_params
|
125
|
-
return [] unless
|
126
|
-
|
97
|
+
return [] unless proxy_methods[@meth]
|
98
|
+
proxy_methods[@meth][:optional] || []
|
127
99
|
end
|
128
100
|
|
129
101
|
def base_param_keys
|
130
|
-
|
131
|
-
end
|
132
|
-
|
133
|
-
def method_def
|
134
|
-
self.class.proxy_method_def
|
135
|
-
end
|
136
|
-
|
137
|
-
def param_def
|
138
|
-
self.class.proxy_param_def
|
102
|
+
proxy_params.keys
|
139
103
|
end
|
140
104
|
end
|
data/lib/nano_rpc/version.rb
CHANGED
data/lib/nano_rpc.rb
CHANGED
@@ -7,11 +7,17 @@ require 'nano_rpc/helpers/accounts_helper'
|
|
7
7
|
require 'nano_rpc/helpers/node_helper'
|
8
8
|
require 'nano_rpc/helpers/wallet_helper'
|
9
9
|
|
10
|
+
require 'nano_rpc/methods/account_methods'
|
11
|
+
require 'nano_rpc/methods/accounts_methods'
|
12
|
+
require 'nano_rpc/methods/node_methods'
|
13
|
+
require 'nano_rpc/methods/wallet_methods'
|
14
|
+
|
10
15
|
require 'nano_rpc/proxy'
|
16
|
+
require 'nano_rpc/proxies/account'
|
17
|
+
require 'nano_rpc/proxies/accounts'
|
18
|
+
require 'nano_rpc/proxies/wallet'
|
19
|
+
|
11
20
|
require 'nano_rpc/node'
|
12
21
|
require 'nano_rpc/errors'
|
13
22
|
require 'nano_rpc/response'
|
14
23
|
require 'nano_rpc/numeric'
|
15
|
-
require 'nano_rpc/proxies/account'
|
16
|
-
require 'nano_rpc/proxies/accounts'
|
17
|
-
require 'nano_rpc/proxies/wallet'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nano_rpc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.18.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Craig-Kuhn (JCK)
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-08-
|
11
|
+
date: 2018-08-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -172,6 +172,10 @@ files:
|
|
172
172
|
- lib/nano_rpc/helpers/application_helper.rb
|
173
173
|
- lib/nano_rpc/helpers/node_helper.rb
|
174
174
|
- lib/nano_rpc/helpers/wallet_helper.rb
|
175
|
+
- lib/nano_rpc/methods/account_methods.rb
|
176
|
+
- lib/nano_rpc/methods/accounts_methods.rb
|
177
|
+
- lib/nano_rpc/methods/node_methods.rb
|
178
|
+
- lib/nano_rpc/methods/wallet_methods.rb
|
175
179
|
- lib/nano_rpc/node.rb
|
176
180
|
- lib/nano_rpc/numeric.rb
|
177
181
|
- lib/nano_rpc/proxies/account.rb
|