Class: Xpring::Client
- Inherits:
-
Object
- Object
- Xpring::Client
- Defined in:
- lib/xpring/client.rb
Overview
Make GRPC network calls to XRP ledger
Constant Summary collapse
- DEFAULT_DEADLINE_OFFSET =
60
Instance Attribute Summary collapse
-
#credentials ⇒ Object
readonly
Returns the value of attribute credentials.
-
#deadline_offset ⇒ Object
readonly
Returns the value of attribute deadline_offset.
-
#grpc_url ⇒ Object
readonly
Returns the value of attribute grpc_url.
Instance Method Summary collapse
- #balance_of(address) ⇒ Integer?
-
#initialize(grpc_url, credentials: :this_channel_is_insecure, deadline_offset: DEFAULT_DEADLINE_OFFSET) ⇒ Client
constructor
A new instance of Client.
- #send_xrp(amount:, to:, from:) ⇒ Org::Xrpl::Rpc::V1::SubmitTransactionResponse?
- #status_of(transaction) ⇒ Symbol?
Constructor Details
#initialize(grpc_url, credentials: :this_channel_is_insecure, deadline_offset: DEFAULT_DEADLINE_OFFSET) ⇒ Client
Returns a new instance of Client.
29 30 31 32 33 34 35 36 37 |
# File 'lib/xpring/client.rb', line 29 def initialize( grpc_url, credentials: :this_channel_is_insecure, deadline_offset: DEFAULT_DEADLINE_OFFSET ) @grpc_url = grpc_url.to_s @credentials = credentials @deadline_offset = deadline_offset end |
Instance Attribute Details
#credentials ⇒ Object (readonly)
Returns the value of attribute credentials.
22 23 24 |
# File 'lib/xpring/client.rb', line 22 def credentials @credentials end |
#deadline_offset ⇒ Object (readonly)
Returns the value of attribute deadline_offset.
22 23 24 |
# File 'lib/xpring/client.rb', line 22 def deadline_offset @deadline_offset end |
#grpc_url ⇒ Object (readonly)
Returns the value of attribute grpc_url.
22 23 24 |
# File 'lib/xpring/client.rb', line 22 def grpc_url @grpc_url end |
Instance Method Details
#balance_of(address) ⇒ Integer?
41 42 43 44 |
# File 'lib/xpring/client.rb', line 41 def balance_of(address) account_data(address.to_s)&.account_data &.balance&.value&.xrp_amount&.drops end |
#send_xrp(amount:, to:, from:) ⇒ Org::Xrpl::Rpc::V1::SubmitTransactionResponse?
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/xpring/client.rb', line 58 def send_xrp(amount:, to:, from:) classic_from_address, classic_to_address, account_data = validate_and_prepare_sending_xrp(to.to_s, from) transaction_hash = { Account: classic_from_address, Fee: minimum_fee.to_s, # ripple-binary-codec requires string LastLedgerSequence: next_sequence_for_transaction, Sequence: account_data.account_data.sequence.value, SigningPubKey: from.public_key, Amount: amount.to_s, # ripple-binary-codec requires string Destination: classic_to_address, TransactionType: "Payment", } submit_transaction(from_wallet: from, transaction_hash: transaction_hash) end |
#status_of(transaction) ⇒ Symbol?
48 49 50 51 |
# File 'lib/xpring/client.rb', line 48 def status_of(transaction) transaction_data(transaction.to_s)&. &.transaction_result&.result_type end |