Skip to content

Commit d2a62b3

Browse files
authored
Merge branch 'main' into ds/docs-ci-improvements
2 parents cf5e60d + 2b7df77 commit d2a62b3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+132
-287
lines changed

aa-sdk/core/src/errors/client.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -118,20 +118,6 @@ export class InvalidModularAccountV2Mode extends BaseError {
118118
}
119119
}
120120

121-
/**
122-
* Error class denoting that the deferred action mode used is invalid.
123-
*/
124-
export class InvalidDeferredActionMode extends BaseError {
125-
override name = "InvalidDeferredActionMode";
126-
127-
/**
128-
* Initializes a new instance of the error message with a default message indicating that the provided deferred action mode is invalid.
129-
*/
130-
constructor() {
131-
super(`The provided deferred action mode is invalid`);
132-
}
133-
}
134-
135121
/**
136122
* Error class denoting that the deferred action nonce used is invalid.
137123
*/

aa-sdk/core/src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ export {
7777
InvalidNonceKeyError,
7878
EntityIdOverrideError,
7979
InvalidModularAccountV2Mode,
80-
InvalidDeferredActionMode,
8180
InvalidDeferredActionNonce,
8281
} from "./errors/client.js";
8382
export {

account-kit/infra/src/chains.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ import {
2121
arbitrumNova as vabn,
2222
zora as vzora,
2323
zoraSepolia as vzoras,
24-
sonic as vsonic,
25-
sonicTestnet as vsonict,
2624
} from "viem/chains";
2725

2826
export type AlchemyChainConfig = {
@@ -240,20 +238,6 @@ export const zoraSepolia: Chain = {
240238
},
241239
};
242240

243-
export const sonic: Chain = {
244-
...vsonic,
245-
rpcUrls: {
246-
...vsonic.rpcUrls,
247-
},
248-
};
249-
250-
export const sonicTestnet: Chain = {
251-
...vsonict,
252-
rpcUrls: {
253-
...vsonict.rpcUrls,
254-
},
255-
};
256-
257241
export const worldChainSepolia: Chain = defineChain({
258242
id: 4801,
259243
name: "World Chain Sepolia",

account-kit/infra/src/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ export {
4444
openlootSepolia,
4545
gensynTestnet,
4646
riseTestnet,
47-
sonic,
48-
sonicTestnet,
4947
} from "./chains.js";
5048
export type * from "./client/decorators/alchemyEnhancedApis.js";
5149
export { alchemyEnhancedApiActions } from "./client/decorators/alchemyEnhancedApis.js";

account-kit/smart-contracts/src/ma-v2/account/common/modularAccountV2Base.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,13 @@ import {
44
InvalidEntityIdError,
55
InvalidNonceKeyError,
66
InvalidDeferredActionNonce,
7-
InvalidDeferredActionMode,
87
toSmartContractAccount,
98
type AccountOp,
109
type SmartAccountSigner,
1110
type SmartContractAccountWithSigner,
1211
type ToSmartContractAccountParams,
1312
} from "@aa-sdk/core";
14-
import { DEFAULT_OWNER_ENTITY_ID } from "../../utils.js";
13+
import { DEFAULT_OWNER_ENTITY_ID, parseDeferredAction } from "../../utils.js";
1514
import {
1615
type Hex,
1716
type Address,
@@ -136,9 +135,9 @@ export async function createMAv2Base<
136135
let hasAssociatedExecHooks: boolean = false;
137136

138137
if (deferredAction) {
139-
if (deferredAction.slice(2, 4) !== "00") {
140-
throw new InvalidDeferredActionMode();
141-
}
138+
({ nonce, deferredActionData, hasAssociatedExecHooks } =
139+
parseDeferredAction(deferredAction));
140+
142141
// Set these values if the deferred action has not been consumed. We check this with the EP
143142
const nextNonceForDeferredAction: bigint =
144143
(await entryPointContract.read.getNonce([
@@ -148,10 +147,7 @@ export async function createMAv2Base<
148147

149148
// we only add the deferred action in if the nonce has not been consumed
150149
if (nonce === nextNonceForDeferredAction) {
151-
nonce = BigInt(`0x${deferredAction.slice(6, 70)}`);
152150
useDeferredAction = true;
153-
deferredActionData = `0x${deferredAction.slice(70)}`;
154-
hasAssociatedExecHooks = deferredAction[5] === "1";
155151
} else if (nonce > nextNonceForDeferredAction) {
156152
throw new InvalidDeferredActionNonce();
157153
}

account-kit/smart-contracts/src/ma-v2/actions/deferralActions.test.ts

Lines changed: 12 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,7 @@ import {
33
LocalAccountSigner,
44
type SmartAccountSigner,
55
} from "@aa-sdk/core";
6-
import {
7-
custom,
8-
parseEther,
9-
publicActions,
10-
testActions,
11-
type TestActions,
12-
} from "viem";
6+
import { custom, parseEther } from "viem";
137
import {
148
createModularAccountV2Client,
159
type SignerEntity,
@@ -28,17 +22,6 @@ import { alchemyGasAndPaymasterAndDataMiddleware } from "@account-kit/infra";
2822
describe("MA v2 deferral actions tests", async () => {
2923
const instance = local070Instance;
3024

31-
let client: ReturnType<typeof instance.getClient> &
32-
ReturnType<typeof publicActions> &
33-
TestActions;
34-
35-
beforeAll(async () => {
36-
client = instance
37-
.getClient()
38-
.extend(publicActions)
39-
.extend(testActions({ mode: "anvil" }));
40-
});
41-
4225
const signer: SmartAccountSigner = new LocalAccountSigner(
4326
accounts.fundedAccountOwner
4427
);
@@ -73,25 +56,22 @@ describe("MA v2 deferral actions tests", async () => {
7356
});
7457

7558
const { typedData, fullPreSignatureDeferredActionDigest } =
76-
await new PermissionBuilder(serverClient)
77-
.configure({
78-
key: {
79-
publicKey: await sessionKey.getAddress(),
80-
type: "secp256k1",
81-
},
82-
entityId,
83-
nonce: nonce,
84-
})
59+
await new PermissionBuilder({
60+
client: serverClient,
61+
key: {
62+
publicKey: await sessionKey.getAddress(),
63+
type: "secp256k1",
64+
},
65+
entityId,
66+
nonce: nonce,
67+
deadline: 0,
68+
})
8569
.addPermission({
8670
permission: {
8771
type: PermissionType.ROOT,
8872
},
8973
})
90-
.compileDeferred({
91-
deadline: 0,
92-
uoValidationEntityId: entityId,
93-
uoIsGlobalValidation: true,
94-
});
74+
.compileDeferred();
9575

9676
const sig = await provider.account.signTypedData(typedData);
9777

account-kit/smart-contracts/src/ma-v2/client/client.test.ts

Lines changed: 35 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -356,15 +356,16 @@ describe("MA v2 Tests", async () => {
356356
// Must be built with the client that's going to sign the deferred action
357357
// OR a client with the same set signer entity as the signing client (entityId + isGlobal)
358358
const { typedData, fullPreSignatureDeferredActionDigest } =
359-
await new PermissionBuilder(provider)
360-
.configure({
361-
key: {
362-
publicKey: await sessionKey.getAddress(),
363-
type: "secp256k1",
364-
},
365-
entityId: entityId,
366-
nonce: nonce,
367-
})
359+
await new PermissionBuilder({
360+
client: provider,
361+
key: {
362+
publicKey: await sessionKey.getAddress(),
363+
type: "secp256k1",
364+
},
365+
entityId: entityId,
366+
nonce: nonce,
367+
deadline: 0,
368+
})
368369
.addPermission({
369370
permission: {
370371
type: PermissionType.GAS_LIMIT,
@@ -381,11 +382,7 @@ describe("MA v2 Tests", async () => {
381382
},
382383
},
383384
})
384-
.compileDeferred({
385-
deadline: 0,
386-
uoValidationEntityId: entityId,
387-
uoIsGlobalValidation: false,
388-
});
385+
.compileDeferred();
389386

390387
// Sign the typed data using the owner (fallback) validation, this must be done via the account to skip 6492
391388
const deferredValidationSig = await provider.account.signTypedData(
@@ -473,21 +470,22 @@ describe("MA v2 Tests", async () => {
473470
// const sessionKeyEntityId = 1;
474471
// these can be default values or from call arguments
475472
const { entityId, nonce } = await provider.getEntityIdAndNonce({
476-
isGlobalValidation: false,
473+
isGlobalValidation: false, // assumes the session key is used to sign the UO
477474
});
478475

479476
// Must be built with the client that's going to sign the deferred action
480477
// OR a client with the same set signer entity as the signing client (entityId + isGlobal)
481478
const { typedData, fullPreSignatureDeferredActionDigest } =
482-
await new PermissionBuilder(provider)
483-
.configure({
484-
key: {
485-
publicKey: await sessionKey.getAddress(),
486-
type: "secp256k1",
487-
},
488-
entityId: entityId,
489-
nonce: nonce,
490-
})
479+
await new PermissionBuilder({
480+
client: provider,
481+
key: {
482+
publicKey: await sessionKey.getAddress(),
483+
type: "secp256k1",
484+
},
485+
entityId: entityId,
486+
nonce: nonce,
487+
deadline: 0,
488+
})
491489
.addPermission({
492490
permission: {
493491
type: PermissionType.ERC20_TOKEN_TRANSFER,
@@ -497,11 +495,7 @@ describe("MA v2 Tests", async () => {
497495
},
498496
},
499497
})
500-
.compileDeferred({
501-
deadline: 0,
502-
uoValidationEntityId: entityId,
503-
uoIsGlobalValidation: false,
504-
});
498+
.compileDeferred();
505499

506500
// Sign the typed data using the owner (fallback) validation, this must be done via the account to skip 6492
507501
const deferredValidationSig = await provider.account.signTypedData(
@@ -619,7 +613,7 @@ describe("MA v2 Tests", async () => {
619613

620614
// version 00, preExecHooks 00, nonce, deferredActionDigest
621615
const fullDeferredAction = concatHex([
622-
"0x0000",
616+
"0x00",
623617
toHex(nonce, { size: 32 }),
624618
deferredActionDigest,
625619
]);
@@ -710,35 +704,29 @@ describe("MA v2 Tests", async () => {
710704
randomWallet
711705
);
712706

713-
// Test variables
714-
const isGlobalValidation = true;
715-
716707
const { entityId, nonce } = await provider.getEntityIdAndNonce({
717708
isGlobalValidation: true,
718709
});
719710

720711
// Must be built with the client that's going to sign the deferred action
721712
// OR a client with the same set signer entity as the signing client (entityId + isGlobal)
722713
const { typedData, fullPreSignatureDeferredActionDigest } =
723-
await new PermissionBuilder(sessionKeyClient)
724-
.configure({
725-
key: {
726-
publicKey: await newSessionKey.getAddress(),
727-
type: "secp256k1",
728-
},
729-
entityId: entityId,
730-
nonce: nonce,
731-
})
714+
await new PermissionBuilder({
715+
client: sessionKeyClient,
716+
key: {
717+
publicKey: await newSessionKey.getAddress(),
718+
type: "secp256k1",
719+
},
720+
entityId: entityId,
721+
nonce: nonce,
722+
deadline: 0,
723+
})
732724
.addPermission({
733725
permission: {
734726
type: PermissionType.ROOT,
735727
},
736728
})
737-
.compileDeferred({
738-
deadline: 0,
739-
uoValidationEntityId: entityId,
740-
uoIsGlobalValidation: isGlobalValidation,
741-
});
729+
.compileDeferred();
742730

743731
// Sign the typed data using the first session key
744732
const deferredValidationSig = await sessionKeyClient.account.signTypedData(

0 commit comments

Comments
 (0)