Skip to content

Commit

Permalink
Update with new abstraction function names
Browse files Browse the repository at this point in the history
  • Loading branch information
GhostWalker562 committed Feb 4, 2025
1 parent c0d3cad commit 5648bb3
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 24 deletions.
26 changes: 13 additions & 13 deletions src/api/account/abstraction.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { AccountAddress, AccountAddressInput } from "../../core";
import {
addDispatchableAuthenticationFunctionTransaction,
removeDispatchableAuthenticationFunctionTransaction,
addAuthenticationFunctionTransaction,
removeAuthenticationFunctionTransaction,
removeDispatchableAuthenticatorTransaction,
} from "../../internal/abstraction";
import { view } from "../../internal/view";
Expand All @@ -18,7 +18,7 @@ export class AccountAbstraction {
*
* @example
* ```ts
* const txn = await aptos.abstraction.addDispatchableAuthenticationFunctionTransaction({
* const txn = await aptos.abstraction.addAuthenticationFunctionTransaction({
* accountAddress: alice.accountAddress,
* authenticationFunction: `${alice.accountAddress}::any_authenticator::authenticate`,
* });
Expand All @@ -32,13 +32,13 @@ export class AccountAbstraction {
* @param args.options - The options for the transaction.
* @returns A transaction to add the authentication function to the account.
*/
public async addDispatchableAuthenticationFunctionTransaction(args: {
public async addAuthenticationFunctionTransaction(args: {
accountAddress: AccountAddressInput;
authenticationFunction: string;
options?: InputGenerateTransactionOptions;
}) {
const { accountAddress, authenticationFunction, options } = args;
return addDispatchableAuthenticationFunctionTransaction({
return addAuthenticationFunctionTransaction({
aptosConfig: this.config,
authenticationFunction,
sender: accountAddress,
Expand All @@ -51,7 +51,7 @@ export class AccountAbstraction {
*
* @example
* ```ts
* const txn = await aptos.abstraction.removeDispatchableAuthenticationFunctionTransaction({
* const txn = await aptos.abstraction.removeAuthenticationFunctionTransaction({
* accountAddress: alice.accountAddress,
* authenticationFunction: `${alice.accountAddress}::any_authenticator::authenticate`,
* });
Expand All @@ -65,13 +65,13 @@ export class AccountAbstraction {
* @param args.options - The options for the transaction.
* @returns A transaction to remove the authentication function from the account.
*/
public async removeDispatchableAuthenticationFunctionTransaction(args: {
public async removeAuthenticationFunctionTransaction(args: {
accountAddress: AccountAddressInput;
authenticationFunction: string;
options?: InputGenerateTransactionOptions;
}) {
const { accountAddress, authenticationFunction, options } = args;
return removeDispatchableAuthenticationFunctionTransaction({
return removeAuthenticationFunctionTransaction({
aptosConfig: this.config,
sender: accountAddress,
authenticationFunction,
Expand Down Expand Up @@ -109,7 +109,7 @@ export class AccountAbstraction {
*
* @example
* ```ts
* const functionInfos = await aptos.abstraction.getDispatchableAuthenticationFunction({
* const functionInfos = await aptos.abstraction.getAuthenticationFunction({
* accountAddress: alice.accountAddress,
* });
*
Expand All @@ -123,7 +123,7 @@ export class AccountAbstraction {
* @param args.accountAddress - The account to get the dispatchable authentication function for.
* @returns The dispatchable authentication function for the account.
*/
public async getDispatchableAuthenticationFunction(args: { accountAddress: AccountAddressInput }) {
public async getAuthenticationFunction(args: { accountAddress: AccountAddressInput }) {
const { accountAddress } = args;
const [{ vec: functionInfoOption }] = await view<
[{ vec: { function_name: string; module_name: string; module_address: string }[][] }]
Expand Down Expand Up @@ -168,7 +168,7 @@ export class AccountAbstraction {
accountAddress: AccountAddressInput;
authenticationFunction: string;
}) => {
const functionInfos = await this.getDispatchableAuthenticationFunction(args);
const functionInfos = await this.getAuthenticationFunction(args);
const { moduleAddress, moduleName, functionName } = getFunctionParts(args.authenticationFunction as MoveFunctionId);
return (
functionInfos?.some(
Expand Down Expand Up @@ -199,7 +199,7 @@ export class AccountAbstraction {
* @param args.options - The options for the transaction.
* @returns A transaction to enable account abstraction for the account.
*/
public enableAccountAbstractionTransaction = this.addDispatchableAuthenticationFunctionTransaction;
public enableAccountAbstractionTransaction = this.addAuthenticationFunctionTransaction;

/**
* Creates a transaction to disable account abstraction. If an authentication function is provided, it will specify to
Expand Down Expand Up @@ -228,7 +228,7 @@ export class AccountAbstraction {
}) => {
const { accountAddress, authenticationFunction, options } = args;
if (authenticationFunction) {
return this.removeDispatchableAuthenticationFunctionTransaction({
return this.removeAuthenticationFunctionTransaction({
accountAddress,
authenticationFunction,
options,
Expand Down
10 changes: 5 additions & 5 deletions src/internal/abstraction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { MoveFunctionId } from "../types";
import { AptosConfig } from "../api/aptosConfig";
import { getFunctionParts } from "../utils/helpers";

export async function addDispatchableAuthenticationFunctionTransaction(args: {
export async function addAuthenticationFunctionTransaction(args: {
aptosConfig: AptosConfig;
sender: AccountAddressInput;
authenticationFunction: string;
Expand All @@ -23,7 +23,7 @@ export async function addDispatchableAuthenticationFunctionTransaction(args: {
aptosConfig,
sender,
data: {
function: "0x1::account_abstraction::add_dispatchable_authentication_function",
function: "0x1::account_abstraction::add_authentication_function",
typeArguments: [],
functionArguments: [moduleAddress, moduleName, functionName],
abi: {
Expand All @@ -35,7 +35,7 @@ export async function addDispatchableAuthenticationFunctionTransaction(args: {
});
}

export async function removeDispatchableAuthenticationFunctionTransaction(args: {
export async function removeAuthenticationFunctionTransaction(args: {
aptosConfig: AptosConfig;
sender: AccountAddressInput;
authenticationFunction: string;
Expand All @@ -47,7 +47,7 @@ export async function removeDispatchableAuthenticationFunctionTransaction(args:
aptosConfig,
sender,
data: {
function: "0x1::account_abstraction::remove_dispatchable_authentication_function",
function: "0x1::account_abstraction::remove_authentication_function",
typeArguments: [],
functionArguments: [moduleAddress, moduleName, functionName],
abi: {
Expand All @@ -69,7 +69,7 @@ export async function removeDispatchableAuthenticatorTransaction(args: {
aptosConfig,
sender,
data: {
function: "0x1::account_abstraction::remove_dispatchable_authenticator",
function: "0x1::account_abstraction::remove_authenticator",
typeArguments: [],
functionArguments: [],
abi: { typeParameters: [], parameters: [] },
Expand Down
10 changes: 8 additions & 2 deletions tests/e2e/api/abstraction.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,14 +189,20 @@ describe("abstraction api", () => {
beforeAll(async () => {
await aptos.fundAccount({ accountAddress: alice.accountAddress, amount: FUND_AMOUNT });
await aptos.fundAccount({ accountAddress: recipient.accountAddress, amount: FUND_AMOUNT });
const txn = await aptos.transaction.build.simple({
let txn = await aptos.transaction.build.simple({
sender: alice.accountAddress,
data: {
bytecode: addPermissionDelegationScriptBytecode,
functionArguments: [MoveVector.U8(bob.publicKey.toUint8Array())],
},
});
const pendingTxn = await aptos.signAndSubmitTransaction({ signer: alice, transaction: txn });
let pendingTxn = await aptos.signAndSubmitTransaction({ signer: alice, transaction: txn });
await aptos.waitForTransaction({ transactionHash: pendingTxn.hash });
txn = await aptos.abstraction.enableAccountAbstractionTransaction({
accountAddress: alice.accountAddress,
authenticationFunction: "0x1::permissioned_delegation::authenticate",
});
pendingTxn = await aptos.signAndSubmitTransaction({ signer: alice, transaction: txn });
await aptos.waitForTransaction({ transactionHash: pendingTxn.hash });
});

Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/transaction/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ export async function publishTransferPackage(aptos: Aptos, senderAccount: Accoun

export const addPermissionDelegationScriptBytecode =
// eslint-disable-next-line max-len
"a11ceb0b0700000a0901001402141a032e38046604056a4807b201a70308d904400699054d10e6051f0103010401060109010d010e01120114011601190002080002080700030b0700040c0f000510070100000818070001050301010001020704050001030a05060001050f01080100010311090a000106130b01000107150b0100010817040c0001091a0d0100010002030702060c0a020001080001060c010a02010801010802010803010b0401090004060c08020b0401080303010c03060c060c0301080504060c0508050805050802030b04010803060c0c083c53454c463e5f30046d61696e094170746f73436f696e0a6170746f735f636f696e04636f696e196d6967726174655f746f5f66756e6769626c655f73746f72650765643235353139256e65775f756e76616c6964617465645f7075626c69635f6b65795f66726f6d5f627974657314556e76616c6964617465645075626c69634b6579177065726d697373696f6e65645f64656c65676174696f6e0f67656e5f656432353531395f6b65790d44656c65676174696f6e4b65790b526174654c696d697465720c726174655f6c696d69746572066f7074696f6e046e6f6e65064f7074696f6e176164645f7065726d697373696f6e65645f68616e646c65167072696d6172795f66756e6769626c655f73746f7265146772616e745f6170745f7065726d697373696f6e167472616e73616374696f6e5f76616c69646174696f6e146772616e745f6761735f7065726d697373696f6e06737472696e67047574663806537472696e67136163636f756e745f6162737472616374696f6e286164645f646973706174636861626c655f61757468656e7469636174696f6e5f66756e6374696f6effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000000000000000000000000000000000001052000000000000000000000000000000000000000000000000000000000000000010a0218177065726d697373696f6e65645f64656c65676174696f6e0a020d0c61757468656e74696361746514636f6d70696c6174696f6e5f6d65746164617461090003322e3003322e3100000e1e0a0038000b01110111020c020a0038010c040b020b040600a0724e1809000011040c060a000e060600e1f5050000000011050a000e060600e1f5050000000011060b0007000701110707021107110802";
"a11ceb0b0700000a0801001002101603262c04520405563d079301d70208ea034010aa041f0103010401060109010d010e011201140002080002080700030b0700040c0f0005100701000001050301010001020704050001030a05060001050f01080100010311090a000106130b01000107150b0100010002030702060c0a020001080001060c010a02010801010802010803010b0401090004060c08020b0401080303010c03060c060c03050802030b04010803060c0c083c53454c463e5f30046d61696e094170746f73436f696e0a6170746f735f636f696e04636f696e196d6967726174655f746f5f66756e6769626c655f73746f72650765643235353139256e65775f756e76616c6964617465645f7075626c69635f6b65795f66726f6d5f627974657314556e76616c6964617465645075626c69634b6579177065726d697373696f6e65645f64656c65676174696f6e0f67656e5f656432353531395f6b65790d44656c65676174696f6e4b65790b526174654c696d697465720c726174655f6c696d69746572066f7074696f6e046e6f6e65064f7074696f6e176164645f7065726d697373696f6e65645f68616e646c65167072696d6172795f66756e6769626c655f73746f7265146772616e745f6170745f7065726d697373696f6e167472616e73616374696f6e5f76616c69646174696f6e146772616e745f6761735f7065726d697373696f6effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000000000000000000000000000000000000000000000000000000000000114636f6d70696c6174696f6e5f6d65746164617461090003322e3003322e3100000c170a0038000b01110111020c020a0038010c040b020b040600a0724e1809000011040c060a000e060600e1f5050000000011050b000e060600e1f50500000000110602";

export async function publishAnyAuthenticatorAAPackage(aptos: Aptos, senderAccount: Account) {
return publishPackage(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ script {
use aptos_framework::coin::{Self};
use aptos_framework::transaction_validation::{Self};
use aptos_framework::primary_fungible_store::{Self};
use aptos_framework::account_abstraction::{Self};
use aptos_framework::permissioned_delegation::{Self};
use aptos_std::ed25519;
use std::string::utf8;
use std::option;

fun main(sender: &signer, sender_public_key: vector<u8>) {
Expand All @@ -14,6 +12,5 @@ script {
let permissioned_signer = permissioned_delegation::add_permissioned_handle(sender, key, option::none(), 10000000000000);
primary_fungible_store::grant_apt_permission(sender, &permissioned_signer, 100000000);
transaction_validation::grant_gas_permission(sender, &permissioned_signer, 100000000);
account_abstraction::add_dispatchable_authentication_function(sender, @aptos_framework, utf8(b"permissioned_delegation"), utf8(b"authenticate"));
}
}

0 comments on commit 5648bb3

Please sign in to comment.