Class: SafeEthRuby::TransactionServiceApi
- Inherits:
-
Object
- Object
- SafeEthRuby::TransactionServiceApi
- Defined in:
- lib/safe_eth_ruby/transaction_service_api.rb
Constant Summary collapse
- VERSION =
"v1/"
Instance Attribute Summary collapse
-
#base_url ⇒ Object
readonly
Returns the value of attribute base_url.
-
#safe_address ⇒ Object
readonly
Returns the value of attribute safe_address.
Instance Method Summary collapse
- #add_delegate(label:, delegate_address:, owner:) ⇒ Object
- #delegates ⇒ Object
- #delete_delegate(delegate_address:, owner:) ⇒ Object
-
#initialize(chain_id:, safe_address:) ⇒ TransactionServiceApi
constructor
A new instance of TransactionServiceApi.
- #multisig_transaction(transaction) ⇒ Object
Constructor Details
#initialize(chain_id:, safe_address:) ⇒ TransactionServiceApi
Returns a new instance of TransactionServiceApi.
12 13 14 15 16 |
# File 'lib/safe_eth_ruby/transaction_service_api.rb', line 12 def initialize(chain_id:, safe_address:) (@network = network_name(chain_id)) || raise(ArgumentError, "Invalid network") @base_url = "https://safe-transaction-#{@network}.safe.global/api/#{VERSION}" @safe_address = safe_address end |
Instance Attribute Details
#base_url ⇒ Object (readonly)
Returns the value of attribute base_url.
10 11 12 |
# File 'lib/safe_eth_ruby/transaction_service_api.rb', line 10 def base_url @base_url end |
#safe_address ⇒ Object (readonly)
Returns the value of attribute safe_address.
10 11 12 |
# File 'lib/safe_eth_ruby/transaction_service_api.rb', line 10 def safe_address @safe_address end |
Instance Method Details
#add_delegate(label:, delegate_address:, owner:) ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/safe_eth_ruby/transaction_service_api.rb', line 25 def add_delegate(label:, delegate_address:, owner:) signature = sign_data(delegate_address, owner) post("delegates/", { safe: @safe_address, delegate: delegate_address, delegator: owner.address.to_s, label: label, signature: signature, }) end |
#delegates ⇒ Object
18 19 20 21 22 23 |
# File 'lib/safe_eth_ruby/transaction_service_api.rb', line 18 def delegates response = get("delegates/?safe=#{@safe_address}") return response unless response[:error] response[:data]["results"] end |
#delete_delegate(delegate_address:, owner:) ⇒ Object
36 37 38 39 40 41 42 43 |
# File 'lib/safe_eth_ruby/transaction_service_api.rb', line 36 def delete_delegate(delegate_address:, owner:) signature = sign_data(delegate_address, owner) delete("delegates/#{delegate_address}/", { delegate: delegate_address, delegator: owner.address.to_s, signature: signature, }) end |
#multisig_transaction(transaction) ⇒ Object
45 46 47 |
# File 'lib/safe_eth_ruby/transaction_service_api.rb', line 45 def multisig_transaction(transaction) post("safes/#{@safe_address}/multisig-transactions/", transaction) end |