Class: IcAgent::Common::CyclesWallet
- Inherits:
-
Object
- Object
- IcAgent::Common::CyclesWallet
- Defined in:
- lib/ic_agent/common/cycles_wallet.rb
Constant Summary collapse
- DID_FILE =
"type EventKind = variant {\n CyclesSent: record {\n to: principal;\n amount: nat64;\n refund: nat64;\n };\n CyclesReceived: record {\n from: principal;\n amount: nat64;\n memo: opt text;\n };\n AddressAdded: record {\n id: principal;\n name: opt text;\n role: Role;\n };\n AddressRemoved: record {\n id: principal;\n };\n CanisterCreated: record {\n canister: principal;\n cycles: nat64;\n };\n CanisterCalled: record {\n canister: principal;\n method_name: text;\n cycles: nat64;\n };\n WalletDeployed: record {\n canister: principal;\n }\n};\n\ntype EventKind128 = variant {\n CyclesSent: record {\n to: principal;\n amount: nat;\n refund: nat;\n };\n CyclesReceived: record {\n from: principal;\n amount: nat;\n memo: opt text;\n };\n AddressAdded: record {\n id: principal;\n name: opt text;\n role: Role;\n };\n AddressRemoved: record {\n id: principal;\n };\n CanisterCreated: record {\n canister: principal;\n cycles: nat;\n };\n CanisterCalled: record {\n canister: principal;\n method_name: text;\n cycles: nat;\n };\n WalletDeployed: record {\n canister: principal;\n };\n};\n\ntype Event = record {\n id: nat32;\n timestamp: nat64;\n kind: EventKind;\n};\n\ntype Event128 = record {\n id: nat32;\n timestamp: nat64;\n kind: EventKind128;\n};\n\ntype Role = variant {\n Contact;\n Custodian;\n Controller;\n};\n\ntype Kind = variant {\n Unknown;\n User;\n Canister;\n};\n\n// An entry in the address book. It must have an ID and a role.\ntype AddressEntry = record {\n id: principal;\n name: opt text;\n kind: Kind;\n role: Role;\n};\n\ntype ManagedCanisterInfo = record {\n id: principal;\n name: opt text;\n created_at: nat64;\n};\n\ntype ManagedCanisterEventKind = variant {\n CyclesSent: record {\n amount: nat64;\n refund: nat64;\n };\n Called: record {\n method_name: text;\n cycles: nat64;\n };\n Created: record {\n cycles: nat64;\n };\n};\n\ntype ManagedCanisterEventKind128 = variant {\n CyclesSent: record {\n amount: nat;\n refund: nat;\n };\n Called: record {\n method_name: text;\n cycles: nat;\n };\n Created: record {\n cycles: nat;\n };\n};\n\ntype ManagedCanisterEvent = record {\n id: nat32;\n timestamp: nat64;\n kind: ManagedCanisterEventKind;\n};\n\ntype ManagedCanisterEvent128 = record {\n id: nat32;\n timestamp: nat64;\n kind: ManagedCanisterEventKind128;\n};\n\ntype ReceiveOptions = record {\n memo: opt text;\n};\n\ntype WalletResultCreate = variant {\n Ok : record { canister_id: principal };\n Err: text;\n};\n\ntype WalletResult = variant {\n Ok : null;\n Err : text;\n};\n\ntype WalletResultCall = variant {\n Ok : record { return: blob };\n Err : text;\n};\n\ntype CanisterSettings = record {\n controller: opt principal;\n controllers: opt vec principal;\n compute_allocation: opt nat;\n memory_allocation: opt nat;\n freezing_threshold: opt nat;\n};\n\ntype CreateCanisterArgs = record {\n cycles: nat64;\n settings: CanisterSettings;\n};\n\ntype CreateCanisterArgs128 = record {\n cycles: nat;\n settings: CanisterSettings;\n};\n\n// Assets\ntype HeaderField = record { text; text; };\n\ntype HttpRequest = record {\n method: text;\n url: text;\n headers: vec HeaderField;\n body: blob;\n};\n\ntype HttpResponse = record {\n status_code: nat16;\n headers: vec HeaderField;\n body: blob;\n streaming_strategy: opt StreamingStrategy;\n};\n\ntype StreamingCallbackHttpResponse = record {\n body: blob;\n token: opt Token;\n};\n\ntype Token = record {};\n\ntype StreamingStrategy = variant {\n Callback: record {\n callback: func (Token) -> (StreamingCallbackHttpResponse) query;\n token: Token;\n };\n};\n\nservice : {\n wallet_api_version: () -> (text) query;\n name: () -> (opt text) query;\n set_name: (text) -> ();\n get_controllers: () -> (vec principal) query;\n add_controller: (principal) -> ();\n remove_controller: (principal) -> (WalletResult);\n get_custodians: () -> (vec principal) query;\n authorize: (principal) -> ();\n deauthorize: (principal) -> (WalletResult);\n wallet_balance: () -> (record { amount: nat64 }) query;\n wallet_balance128: () -> (record { amount: nat }) query;\n wallet_send: (record { canister: principal; amount: nat64 }) -> (WalletResult);\n wallet_send128: (record { canister: principal; amount: nat }) -> (WalletResult);\n wallet_receive: (opt ReceiveOptions) -> ();\n wallet_create_canister: (CreateCanisterArgs) -> (WalletResultCreate);\n wallet_create_canister128: (CreateCanisterArgs128) -> (WalletResultCreate);\n wallet_create_wallet: (CreateCanisterArgs) -> (WalletResultCreate);\n wallet_create_wallet128: (CreateCanisterArgs128) -> (WalletResultCreate);\n wallet_store_wallet_wasm: (record {\n wasm_module: blob;\n }) -> ();\n wallet_call: (record {\n canister: principal;\n method_name: text;\n args: blob;\n cycles: nat64;\n }) -> (WalletResultCall);\n wallet_call128: (record {\n canister: principal;\n method_name: text;\n args: blob;\n cycles: nat;\n }) -> (WalletResultCall);\n list_addresses: () -> (vec AddressEntry) query;\n get_events: (opt record { from: opt nat32; to: opt nat32; }) -> (vec Event) query;\n get_events128: (opt record { from: opt nat32; to: opt nat32; }) -> (vec Event128) query;\n get_chart: (opt record { count: opt nat32; precision: opt nat64; } ) -> (vec record { nat64; nat64; }) query;\n list_managed_canisters: (record { from: opt nat32; to: opt nat32; }) -> (vec ManagedCanisterInfo, nat32) query;\n get_managed_canister_events: (record { canister: principal; from: opt nat32; to: opt nat32; }) -> (opt vec ManagedCanisterEvent) query;\n get_managed_canister_events128: (record { canister: principal; from: opt nat32; to: opt nat32; }) -> (opt vec ManagedCanisterEvent128) query;\n set_short_name: (principal, opt text) -> (opt ManagedCanisterInfo);\n}\n"
Instance Attribute Summary collapse
-
#agent ⇒ Object
Returns the value of attribute agent.
-
#canister ⇒ Object
Returns the value of attribute canister.
-
#client ⇒ Object
Returns the value of attribute client.
-
#identity ⇒ Object
Returns the value of attribute identity.
Instance Method Summary collapse
-
#initialize(iden = nil, wallet_id) ⇒ CyclesWallet
constructor
A new instance of CyclesWallet.
Constructor Details
#initialize(iden = nil, wallet_id) ⇒ CyclesWallet
Returns a new instance of CyclesWallet.
264 265 266 267 268 269 |
# File 'lib/ic_agent/common/cycles_wallet.rb', line 264 def initialize(iden = nil, wallet_id) @identity = iden.nil? ? IcAgent::Identity.new : iden @client = IcAgent::Client.new @agent = IcAgent::Agent.new(@identity, @client) @canister = IcAgent::Canister.new(@agent, wallet_id, DID_FILE) end |
Instance Attribute Details
#agent ⇒ Object
Returns the value of attribute agent.
262 263 264 |
# File 'lib/ic_agent/common/cycles_wallet.rb', line 262 def agent @agent end |
#canister ⇒ Object
Returns the value of attribute canister.
262 263 264 |
# File 'lib/ic_agent/common/cycles_wallet.rb', line 262 def canister @canister end |
#client ⇒ Object
Returns the value of attribute client.
262 263 264 |
# File 'lib/ic_agent/common/cycles_wallet.rb', line 262 def client @client end |
#identity ⇒ Object
Returns the value of attribute identity.
262 263 264 |
# File 'lib/ic_agent/common/cycles_wallet.rb', line 262 def identity @identity end |