Class: IcAgent::Common::Management

Inherits:
Object
  • Object
show all
Defined in:
lib/ic_agent/common/management.rb

Constant Summary collapse

CANISTER_ID =
'aaaaa-aa'
DID_FILE =
"type canister_id = principal;\ntype wasm_module = blob;\n\ntype canister_settings = record {\n  controllers : opt vec principal;\n  compute_allocation : opt nat;\n  memory_allocation : opt nat;\n  freezing_threshold : opt nat;\n};\n\ntype definite_canister_settings = record {\n  controllers : vec principal;\n  compute_allocation : nat;\n  memory_allocation : nat;\n  freezing_threshold : nat;\n};\n\ntype change_origin = variant {\n  from_user : record {\n    user_id : principal;\n  };\n  from_canister : record {\n    canister_id : principal;\n    canister_version : opt nat64;\n  };\n};\n\ntype change_details = variant {\n  creation : record {\n    controllers : vec principal;\n  };\n  code_uninstall;\n  code_deployment : record {\n    mode : variant {install; reinstall; upgrade};\n    module_hash : blob;\n  };\n  controllers_change : record {\n    controllers : vec principal;\n  };\n};\n\ntype change = record {\n  timestamp_nanos : nat64;\n  canister_version : nat64;\n  origin : change_origin;\n  details : change_details;\n};\n\ntype http_header = record { name: text; value: text };\n\ntype ecdsa_curve = variant { secp256k1; };\n\ntype satoshi = nat64;\n\ntype bitcoin_network = variant {\n  mainnet;\n  testnet;\n};\n\ntype bitcoin_address = text;\n\ntype block_hash = blob;\n\ntype outpoint = record {\n  txid : blob;\n  vout : nat32\n};\n\ntype utxo = record {\n  outpoint: outpoint;\n  value: satoshi;\n  height: nat32;\n};\n\ntype get_utxos_request = record {\n  address : bitcoin_address;\n  network: bitcoin_network;\n  filter: opt variant {\n    min_confirmations: nat32;\n    page: blob;\n  };\n};\n\ntype get_current_fee_percentiles_request = record {\n  network: bitcoin_network;\n};\n\ntype get_utxos_response = record {\n  utxos: vec utxo;\n  tip_block_hash: block_hash;\n  tip_height: nat32;\n  next_page: opt blob;\n};\n\ntype get_balance_request = record {\n  address : bitcoin_address;\n  network: bitcoin_network;\n  min_confirmations: opt nat32;\n};\n\ntype send_transaction_request = record {\n  transaction: blob;\n  network: bitcoin_network;\n};\n\ntype millisatoshi_per_byte = nat64;\n\nservice : {\n  create_canister : (record {\n    settings : opt canister_settings;\n    sender_canister_version : opt nat64;\n  }) -> (record {canister_id : canister_id});\n  update_settings : (record {\n    canister_id : principal;\n    settings : canister_settings;\n    sender_canister_version : opt nat64;\n  }) -> ();\n  install_code : (record {\n    mode : variant {install; reinstall; upgrade};\n    canister_id : canister_id;\n    wasm_module : wasm_module;\n    arg : blob;\n    sender_canister_version : opt nat64;\n  }) -> ();\n  uninstall_code : (record {\n    canister_id : canister_id;\n    sender_canister_version : opt nat64;\n  }) -> ();\n  start_canister : (record {canister_id : canister_id}) -> ();\n  stop_canister : (record {canister_id : canister_id}) -> ();\n  canister_status : (record {canister_id : canister_id}) -> (record {\n      status : variant { running; stopping; stopped };\n      settings: definite_canister_settings;\n      module_hash: opt blob;\n      memory_size: nat;\n      cycles: nat;\n      idle_cycles_burned_per_day: nat;\n  });\n  canister_info : (record {\n      canister_id : canister_id;\n      num_requested_changes : opt nat64;\n  }) -> (record {\n      total_num_changes : nat64;\n      recent_changes : vec change;\n      module_hash : opt blob;\n      controllers : vec principal;\n  });\n  delete_canister : (record {canister_id : canister_id}) -> ();\n  deposit_cycles : (record {canister_id : canister_id}) -> ();\n  raw_rand : () -> (blob);\n\n  ecdsa_public_key : (record {\n    canister_id : opt canister_id;\n    derivation_path : vec blob;\n    key_id : record { curve: ecdsa_curve; name: text };\n  }) -> (record { public_key : blob; chain_code : blob; });\n  sign_with_ecdsa : (record {\n    message_hash : blob;\n    derivation_path : vec blob;\n    key_id : record { curve: ecdsa_curve; name: text };\n  }) -> (record { signature : blob });\n\n  bitcoin_get_balance: (get_balance_request) -> (satoshi);\n  bitcoin_get_utxos: (get_utxos_request) -> (get_utxos_response);\n  bitcoin_send_transaction: (send_transaction_request) -> ();\n  bitcoin_get_current_fee_percentiles: (get_current_fee_percentiles_request) -> (vec millisatoshi_per_byte);\n\n  provisional_create_canister_with_cycles : (record {\n    amount: opt nat;\n    settings : opt canister_settings;\n    specified_id: opt canister_id;\n  }) -> (record {canister_id : canister_id});\n  provisional_top_up_canister :\n    (record { canister_id: canister_id; amount: nat }) -> ();\n}\n"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(iden = nil) ⇒ Management



185
186
187
188
189
190
# File 'lib/ic_agent/common/management.rb', line 185

def initialize(iden = nil)
  @identity = iden.nil? ? IcAgent::Identity.new : iden
  @client = IcAgent::Client.new
  @agent = IcAgent::Agent.new(@identity, @client)
  @canister = IcAgent::Canister.new(@agent, CANISTER_ID, DID_FILE)
end

Instance Attribute Details

#agentObject

Returns the value of attribute agent.



183
184
185
# File 'lib/ic_agent/common/management.rb', line 183

def agent
  @agent
end

#canisterObject

Returns the value of attribute canister.



183
184
185
# File 'lib/ic_agent/common/management.rb', line 183

def canister
  @canister
end

#clientObject

Returns the value of attribute client.



183
184
185
# File 'lib/ic_agent/common/management.rb', line 183

def client
  @client
end

#identityObject

Returns the value of attribute identity.



183
184
185
# File 'lib/ic_agent/common/management.rb', line 183

def identity
  @identity
end