Module: TezosClient::RpcInterface::Helper
- Included in:
- TezosClient::RpcInterface
- Defined in:
- lib/tezos_client/rpc_interface/helper.rb
Instance Method Summary collapse
- #broadcast_operation(data) ⇒ Object
- #forge_operation(args) ⇒ Object
- #operation(args) ⇒ Object
- #origination_operation(args) ⇒ Object
- #preapply_operation(args) ⇒ Object
- #run_operation(args) ⇒ Object
- #transaction_operation(args) ⇒ Object
Instance Method Details
#broadcast_operation(data) ⇒ Object
95 96 97 |
# File 'lib/tezos_client/rpc_interface/helper.rb', line 95 def broadcast_operation(data) post("injection/operation?chain=main", data) end |
#forge_operation(args) ⇒ Object
87 88 89 90 91 92 93 |
# File 'lib/tezos_client/rpc_interface/helper.rb', line 87 def forge_operation(args) content = { branch: args.fetch(:branch), contents: [operation(args)] } post("chains/main/blocks/head/helpers/forge/operations", content) end |
#operation(args) ⇒ Object
41 42 43 44 |
# File 'lib/tezos_client/rpc_interface/helper.rb', line 41 def operation(args) operation_kind = args.fetch(:operation_kind) { raise ArgumentError, ":operation_kind argument missing" } send("#{operation_kind}_operation", args) end |
#origination_operation(args) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/tezos_client/rpc_interface/helper.rb', line 23 def origination_operation(args) operation = { kind: "origination", delegatable: args.fetch(:delegatable), spendable: args.fetch(:spendable), balance: args.fetch(:amount).to_satoshi.to_s, source: args.fetch(:from), gas_limit: args.fetch(:gas_limit).to_satoshi.to_s, storage_limit: args.fetch(:storage_limit).to_satoshi.to_s, counter: args.fetch(:counter).to_s, fee: args.fetch(:fee).to_satoshi.to_s, managerPubkey: args.fetch(:manager) } operation[:script] = args[:script] if args[:script] operation end |
#preapply_operation(args) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/tezos_client/rpc_interface/helper.rb', line 64 def preapply_operation(args) content = { protocol: args.fetch(:protocol), branch: args.fetch(:branch), contents: [operation(args)], signature: args.fetch(:signature) } res = post("chains/main/blocks/head/helpers/preapply/operations", [content]) res[0]["contents"][0] end |
#run_operation(args) ⇒ Object
77 78 79 80 81 82 83 84 85 |
# File 'lib/tezos_client/rpc_interface/helper.rb', line 77 def run_operation(args) content = { branch: args.fetch(:branch), contents: [operation(args)], signature: args.fetch(:signature) } res = post("chains/main/blocks/head/helpers/scripts/run_operation", content) res["contents"][0] end |
#transaction_operation(args) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/tezos_client/rpc_interface/helper.rb', line 8 def transaction_operation(args) operation = { kind: "transaction", amount: args.fetch(:amount).to_satoshi.to_s, source: args.fetch(:from), destination: args.fetch(:to), gas_limit: args.fetch(:gas_limit).to_satoshi.to_s, storage_limit: args.fetch(:storage_limit).to_satoshi.to_s, counter: args.fetch(:counter).to_s, fee: args.fetch(:fee).to_satoshi.to_s } operation[:parameters] = args[:parameters] if args[:parameters] operation end |