Class: Bluzelle::Swarm::Cosmos
- Inherits:
-
Object
- Object
- Bluzelle::Swarm::Cosmos
- Defined in:
- lib/bluzelle/swarm/cosmos.rb
Constant Summary
Constants included from Constants
Constants::BLOCK_TIME_IN_SECONDS, Constants::BROADCAST_RETRY_SECONDS, Constants::PATH, Constants::PREFIX, Constants::TOKEN_NAME, Constants::TX_COMMAND
Instance Attribute Summary collapse
-
#account_info ⇒ Object
Returns the value of attribute account_info.
-
#address ⇒ Object
readonly
Returns the value of attribute address.
-
#chain_id ⇒ Object
readonly
Returns the value of attribute chain_id.
-
#endpoint ⇒ Object
readonly
Returns the value of attribute endpoint.
-
#mnemonic ⇒ Object
readonly
Returns the value of attribute mnemonic.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Cosmos
constructor
A new instance of Cosmos.
- #query(endpoint) ⇒ Object
- #send_transaction(method, endpoint, data, gas_info) ⇒ Object
Methods included from Utils
bech32_convert_bits, bech32_encode, bip32_from_seed, bip39_mnemonic_to_seed, compressed_pub_key, convert_lease, create_ec_pair, decode_json, ecdsa_sign, encode_json, extract_error_message, get_address, get_ec_private_key, get_ec_public_key_from_priv, hex_to_bin, make_random_string, open_key, rmd_160_digest, sha_256_digest, sort_hash, stringify_keys, to_base64, to_bytes, validate_address
Constructor Details
#initialize(options = {}) ⇒ Cosmos
Returns a new instance of Cosmos.
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/bluzelle/swarm/cosmos.rb', line 17 def initialize( = {}) @mnemonic = [:mnemonic] @chain_id = [:chain_id] @endpoint = [:endpoint] @account_info = {} @private_key = get_ec_private_key(@mnemonic) @address = address_from_mnemonic account end |
Instance Attribute Details
#account_info ⇒ Object
Returns the value of attribute account_info.
15 16 17 |
# File 'lib/bluzelle/swarm/cosmos.rb', line 15 def account_info @account_info end |
#address ⇒ Object (readonly)
Returns the value of attribute address.
14 15 16 |
# File 'lib/bluzelle/swarm/cosmos.rb', line 14 def address @address end |
#chain_id ⇒ Object (readonly)
Returns the value of attribute chain_id.
14 15 16 |
# File 'lib/bluzelle/swarm/cosmos.rb', line 14 def chain_id @chain_id end |
#endpoint ⇒ Object (readonly)
Returns the value of attribute endpoint.
14 15 16 |
# File 'lib/bluzelle/swarm/cosmos.rb', line 14 def endpoint @endpoint end |
#mnemonic ⇒ Object (readonly)
Returns the value of attribute mnemonic.
14 15 16 |
# File 'lib/bluzelle/swarm/cosmos.rb', line 14 def mnemonic @mnemonic end |
Instance Method Details
#query(endpoint) ⇒ Object
29 30 31 |
# File 'lib/bluzelle/swarm/cosmos.rb', line 29 def query(endpoint) Request.execute(method: 'get', url: "#{@endpoint}/#{endpoint}") end |
#send_transaction(method, endpoint, data, gas_info) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/bluzelle/swarm/cosmos.rb', line 33 def send_transaction(method, endpoint, data, gas_info) txn = Transaction.new(method, endpoint, data) txn.set_gas(gas_info) # fetch skeleton skeleton = fetch_txn_skeleton(txn) # set gas skeleton = update_gas(txn, skeleton) # sort skeleton = sort_hash(skeleton) broadcast_transaction(Transaction.new('post', TX_COMMAND, skeleton)) end |