Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sub accounts #596

Draft
wants to merge 26 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 93 additions & 0 deletions examples/typescript/keyless.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,96 @@ const example = async () => {
};

example();

// const testPermissioned = () => {

// const subAccount = AbstractedEd25519Account.generate();

// const receiverAccounts = [Account.generate(), Account.generate()];

// console.log('singleSignerED25519SenderAccount', activeAccount.address.toString());
// console.log('singleSignerAbstractionSenderAccount', subAccount.accountAddress.toString());
// console.log(
// 'receiverAccounts',
// receiverAccounts.map((a) => a.accountAddress.toString()),
// );

// console.log('batcharg', BatchArgument);
// console.log('batcharg', BatchArgument.new_signer(0));

// // fund accounts
// await aptos.fundAccount({ accountAddress: activeAccount.address, amount: 100_000_000 });
// console.log('-----');
// await aptos.fundAccount({
// accountAddress: subAccount.accountAddress,
// amount: 100_000_000,
// });

// console.log('=====================');
// console.log('activeAccount', activeAccount.address.toString());
// console.log('activeSigner', activeSigner.accountAddress.toString());
// console.log('=====================');

// // step 1: setup.
// const transaction = await aptos.transaction.build.batched_intents({
// builder: async (builder) => {
// // convert apt to fa
// await builder.add_batched_calls({
// function: '0x1::coin::migrate_to_fungible_store',
// functionArguments: [BatchArgument.new_signer(0)],
// typeArguments: ['0x1::aptos_coin::AptosCoin'],
// });
// // set up aa with permissioned signer
// const permissioned_signer_handle = await builder.add_batched_calls({
// function: '0x1::permissioned_signer::create_permissioned_handle',
// functionArguments: [BatchArgument.new_signer(0)],
// typeArguments: [],
// });
// const permissioned_signer = await builder.add_batched_calls({
// function: '0x1::permissioned_signer::signer_from_permissioned',
// functionArguments: [permissioned_signer_handle[0].borrow()],
// typeArguments: [],
// });
// await builder.add_batched_calls({
// function: '0x1::fungible_asset::grant_permission',
// functionArguments: [
// BatchArgument.new_signer(0),
// permissioned_signer[0].borrow(),
// AccountAddress.A,
// 10 /* limit */,
// ],
// typeArguments: [],
// });
// await builder.add_batched_calls({
// function: '0x1::permissioned_delegation::add_permissioned_handle',
// functionArguments: [
// BatchArgument.new_signer(0),
// subAccount.publicKey.toUint8Array(),
// permissioned_signer_handle[0],
// ],
// typeArguments: [],
// });
// await builder.add_batched_calls({
// function: '0x1::lite_account::add_dispatchable_authentication_function',
// functionArguments: [
// BatchArgument.new_signer(0),
// AccountAddress.ONE,
// new MoveString('permissioned_delegation'),
// new MoveString('authenticate'),
// ],
// typeArguments: [],
// });
// return builder;
// },
// sender: activeAccount.address,
// });

// const response = await aptos.signAndSubmitTransaction({
// signer: activeSigner,
// transaction,
// });
// await aptos.waitForTransaction({
// transactionHash: response.hash,
// });

// }
5 changes: 3 additions & 2 deletions examples/typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"your_fungible_asset": "ts-node your_fungible_asset.ts",
"federated_keyless": "ts-node federated_keyless.ts",
"jwk_update": "ts-node jwk_update.ts",
"keyless": "ts-node keyless.ts",
"keyless": "tsx keyless.ts",
"keyless_mainnet": "ts-node keyless_mainnet.ts",
"local_node": "ts-node local_node.ts",
"test": "run-s simple_transfer multi_agent_transfer simple_sponsored_transaction transfer_coin custom_client publish_package_from_filepath external_signing sign_struct publish_package_from_filepath external_signing your_coin your_fungible_asset"
Expand All @@ -32,7 +32,8 @@
"dotenv": "^16.3.1",
"npm-run-all": "latest",
"readline-sync": "^1.4.10",
"superagent": "^8.1.2"
"superagent": "^8.1.2",
"tsx": "^4.19.1"
},
"peerDependencies": {
"@aptos-labs/ts-sdk": "link:../.."
Expand Down
Loading
Loading