MoveDID
Mix.install([:poison, :jason, {:web3_move_ex, "~> 1.2.2"}])
{:ok, acct} = Web3MoveEx.Aptos.Account.from_private_key("0xd2d80074a422d0fca374aeb9bf0ed154c4b3e995818a2a21f2135adedd1fbb21")
{:ok, rpc} = Aptos.RPC.connect("https://fullnode.testnet.aptoslabs.com/v1")
f = %Web3MoveEx.Aptos.Types.Function{
address: 0xdea79e568e00066f60fbfe6ac6d8a9ef2fabbeadc6aae1ec9158d50f6efe4ac8,
is_entry: true,
module: "addr_aggregator",
name: "create_addr_aggregator",
params: [:u64, :string],
param_names: ["type", "description"],
return: [],
type_params: [%{"constraints" => []}],
visibility: :public
}
# public entry fun create_addr_aggregator(acct: &signer, type: u64, description: String) acquires CreateAddrAggregatorEventSet {
# let addr_aggr = AddrAggregator {
# key_addr: signer::address_of(acct),
# addr_infos_map: table::new(),
# addrs: vector::empty(),
# type,
# description,
# max_id: 0,
# add_addr_events: account::new_event_handle(acct),
# update_addr_signature_events: account::new_event_handle(acct),
# update_addr_events: account::new_event_handle(acct),
# delete_addr_events: account::new_event_handle(acct),
# modified_counter:0,
# };
# emit_create_addr_aggregator_event(signer::address_of(acct), type, description);
# move_to(acct, addr_aggr);
# }
f2 = %Web3MoveEx.Aptos.Types.Function{
address: "0xdea79e568e00066f60fbfe6ac6d8a9ef2fabbeadc6aae1ec9158d50f6efe4ac8",
is_entry: true,
module: "addr_aggregator",
name: "add_addr",
params: [:u64, :string, :string, {:vector, :string}, :string, :u64],
param_names: ["addr_type", "addr", "pubkey", "chains", "description", "expired_at"],
return: [],
type_params: [%{"constraints" => []}],
visibility: :public
}
# // Add addr.
# public entry fun add_addr(
# acct: &signer,
# addr_type: u64,
# addr: String,
# pubkey: String,
# chains: vector,
# description: String,
# expired_at: u64
# ) acquires AddrAggregator {
# let send_addr = signer::address_of(acct);
# let addr_aggr = borrow_global_mut(send_addr);
# do_add_addr(addr_aggr, send_addr, addr_type, addr, pubkey, chains, description, expired_at);
# }
payload = Aptos.call_function(f, [], [1, "testAcct"])
{:ok, account_ol} = Aptos.load_account(rpc, acct)
Aptos.submit_txn(rpc, account_ol, payload)
# Check events
## build event path.
### get the register_events(index)
Aptos.RPC.build_event_path(client, "0xdea79e568e00066f60fbfe6ac6d8a9ef2fabbeadc6aae1ec9158d50f6efe4ac8", "0xdea79e568e00066f60fbfe6ac6d8a9ef2fabbeadc6aae1ec9158d50f6efe4ac8::addr_aggregator::CreateAddrAggregatorEventSet", "create_addr_aggregator_events")
Aptos.RPC.get_events(client, "0xdea79e568e00066f60fbfe6ac6d8a9ef2fabbeadc6aae1ec9158d50f6efe4ac8", "0xdea79e568e00066f60fbfe6ac6d8a9ef2fabbeadc6aae1ec9158d50f6efe4ac8::addr_aggregator::CreateAddrAggregatorEventSet", "create_addr_aggregator_events")