@account-kit/wallet-client 4.58.0 → 4.59.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/client/actions/signPreparedCalls.d.ts +1 -1
- package/dist/esm/client/actions/signPreparedCalls.js +19 -4
- package/dist/esm/client/actions/signPreparedCalls.js.map +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/types/client/actions/signPreparedCalls.d.ts +1 -1
- package/dist/types/client/actions/signPreparedCalls.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +6 -6
- package/src/client/actions/signPreparedCalls.ts +34 -12
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { PrepareCallsResult } from "./prepareCalls.ts";
|
|
2
|
-
import type
|
|
2
|
+
import { type SmartAccountSigner } from "@aa-sdk/core";
|
|
3
3
|
import type { Static } from "@sinclair/typebox";
|
|
4
4
|
import { wallet_sendPreparedCalls } from "@alchemy/wallet-api-types/rpc";
|
|
5
5
|
export type SignPreparedCallsParams = PrepareCallsResult;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { BaseError } from "@aa-sdk/core";
|
|
1
2
|
import { signSignatureRequest } from "./signSignatureRequest.js";
|
|
2
3
|
import { wallet_sendPreparedCalls } from "@alchemy/wallet-api-types/rpc";
|
|
3
4
|
import {} from "@alchemy/wallet-api-types";
|
|
4
5
|
import { metrics } from "../../metrics.js";
|
|
6
|
+
import { assertNever } from "../../utils.js";
|
|
5
7
|
/**
|
|
6
8
|
* Signs prepared calls using the provided signer.
|
|
7
9
|
*
|
|
@@ -32,19 +34,32 @@ export async function signPreparedCalls(signer, params) {
|
|
|
32
34
|
};
|
|
33
35
|
const signUserOperationCall = async (call) => {
|
|
34
36
|
const { signatureRequest, ...rest } = call;
|
|
37
|
+
if (!signatureRequest) {
|
|
38
|
+
throw new BaseError("Signature request is required for signing user operation calls. Ensure `onlyEstimation` is set to `false` when calling `prepareCalls`.");
|
|
39
|
+
}
|
|
35
40
|
const signature = await signSignatureRequest(signer, signatureRequest);
|
|
36
41
|
return {
|
|
37
42
|
...rest,
|
|
38
43
|
signature,
|
|
39
44
|
};
|
|
40
45
|
};
|
|
41
|
-
|
|
42
|
-
|
|
46
|
+
if (params.type === "array") {
|
|
47
|
+
return {
|
|
43
48
|
type: "array",
|
|
44
49
|
data: await Promise.all(params.data.map((call) => call.type === "authorization"
|
|
45
50
|
? signAuthorizationCall(call)
|
|
46
51
|
: signUserOperationCall(call))),
|
|
47
|
-
}
|
|
48
|
-
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
else if (params.type === "user-operation-v060" ||
|
|
55
|
+
params.type === "user-operation-v070") {
|
|
56
|
+
return signUserOperationCall(params);
|
|
57
|
+
}
|
|
58
|
+
else if (params.type === "paymaster-permit") {
|
|
59
|
+
throw new BaseError(`Invalid call type ${params.type} for signing prepared calls`);
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
return assertNever(params, `Unexpected call type in ${params} for signing prepared calls`);
|
|
63
|
+
}
|
|
49
64
|
}
|
|
50
65
|
//# sourceMappingURL=signPreparedCalls.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signPreparedCalls.js","sourceRoot":"","sources":["../../../../src/client/actions/signPreparedCalls.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"signPreparedCalls.js","sourceRoot":"","sources":["../../../../src/client/actions/signPreparedCalls.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAA2B,MAAM,cAAc,CAAC;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEjE,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,EAIN,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,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ACvB,IAAI,CAAC,IAAI,KAAK,eAAe;gBAC3B,CAAC,CAAC,qBAAqB,CAAC,IAAI,CAAC;gBAC7B,CAAC,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAChC,CACF;SACF,CAAC;IACJ,CAAC;SAAM,IACL,MAAM,CAAC,IAAI,KAAK,qBAAqB;QACrC,MAAM,CAAC,IAAI,KAAK,qBAAqB,EACrC,CAAC;QACD,OAAO,qBAAqB,CAAC,MAAM,CAAC,CAAC;IACvC,CAAC;SAAM,IAAI,MAAM,CAAC,IAAI,KAAK,kBAAkB,EAAE,CAAC;QAC9C,MAAM,IAAI,SAAS,CACjB,qBAAqB,MAAM,CAAC,IAAI,6BAA6B,CAC9D,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,OAAO,WAAW,CAChB,MAAM,EACN,2BAA2B,MAAM,6BAA6B,CAC/D,CAAC;IACJ,CAAC;AACH,CAAC","sourcesContent":["import type { PrepareCallsResult } from \"./prepareCalls.ts\";\nimport { BaseError, type SmartAccountSigner } from \"@aa-sdk/core\";\nimport { signSignatureRequest } from \"./signSignatureRequest.js\";\nimport type { Static } from \"@sinclair/typebox\";\nimport { wallet_sendPreparedCalls } from \"@alchemy/wallet-api-types/rpc\";\nimport {\n type PreparedCall_Authorization,\n type PreparedCall_UserOpV060,\n type PreparedCall_UserOpV070,\n} from \"@alchemy/wallet-api-types\";\nimport { metrics } from \"../../metrics.js\";\nimport { assertNever } from \"../../utils.js\";\n\nexport type SignPreparedCallsParams = PrepareCallsResult;\n\nexport type SignPreparedCallsResult = Static<\n (typeof wallet_sendPreparedCalls)[\"properties\"][\"Request\"][\"properties\"][\"params\"]\n>[0];\n\n/**\n * Signs prepared calls using the provided signer.\n *\n * @param {SmartAccountSigner} signer - The signer to use\n * @param {SignPreparedCallsParams} params - The prepared calls with signature requests\n * @returns {Promise<SignPreparedCallsResult>} A Promise that resolves to the signed calls\n */\nexport async function signPreparedCalls(\n signer: SmartAccountSigner,\n params: SignPreparedCallsParams,\n): Promise<SignPreparedCallsResult> {\n metrics.trackEvent({\n name: \"sign_prepared_calls\",\n data: {\n type: params.type,\n },\n });\n\n const signAuthorizationCall = async (call: PreparedCall_Authorization) => {\n const { signatureRequest: _signatureRequest, ...rest } = call;\n const signature = await signSignatureRequest(signer, {\n type: \"eip7702Auth\",\n data: {\n ...rest.data,\n chainId: call.chainId,\n },\n });\n return {\n ...rest,\n signature,\n };\n };\n\n const signUserOperationCall = async (\n call: PreparedCall_UserOpV060 | PreparedCall_UserOpV070,\n ) => {\n const { signatureRequest, ...rest } = call;\n\n if (!signatureRequest) {\n throw new BaseError(\n \"Signature request is required for signing user operation calls. Ensure `onlyEstimation` is set to `false` when calling `prepareCalls`.\",\n );\n }\n\n const signature = await signSignatureRequest(signer, signatureRequest);\n return {\n ...rest,\n signature,\n };\n };\n\n if (params.type === \"array\") {\n return {\n type: \"array\" as const,\n data: await Promise.all(\n params.data.map((call) =>\n call.type === \"authorization\"\n ? signAuthorizationCall(call)\n : signUserOperationCall(call),\n ),\n ),\n };\n } else if (\n params.type === \"user-operation-v060\" ||\n params.type === \"user-operation-v070\"\n ) {\n return signUserOperationCall(params);\n } else if (params.type === \"paymaster-permit\") {\n throw new BaseError(\n `Invalid call type ${params.type} for signing prepared calls`,\n );\n } else {\n return assertNever(\n params,\n `Unexpected call type in ${params} for signing prepared calls`,\n );\n }\n}\n"]}
|
package/dist/esm/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "4.
|
|
1
|
+
export declare const VERSION = "4.59.0";
|
package/dist/esm/version.js
CHANGED
package/dist/esm/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,yBAAyB;AACzB,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC","sourcesContent":["// This file is autogenerated by inject-version.ts. Any changes will be\n// overwritten on commit!\nexport const VERSION = \"4.
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,yBAAyB;AACzB,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC","sourcesContent":["// This file is autogenerated by inject-version.ts. Any changes will be\n// overwritten on commit!\nexport const VERSION = \"4.59.0\";\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { PrepareCallsResult } from "./prepareCalls.ts";
|
|
2
|
-
import type
|
|
2
|
+
import { type SmartAccountSigner } from "@aa-sdk/core";
|
|
3
3
|
import type { Static } from "@sinclair/typebox";
|
|
4
4
|
import { wallet_sendPreparedCalls } from "@alchemy/wallet-api-types/rpc";
|
|
5
5
|
export type SignPreparedCallsParams = PrepareCallsResult;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signPreparedCalls.d.ts","sourceRoot":"","sources":["../../../../src/client/actions/signPreparedCalls.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"signPreparedCalls.d.ts","sourceRoot":"","sources":["../../../../src/client/actions/signPreparedCalls.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAa,KAAK,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAElE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AASzE,MAAM,MAAM,uBAAuB,GAAG,kBAAkB,CAAC;AAEzD,MAAM,MAAM,uBAAuB,GAAG,MAAM,CAC1C,CAAC,OAAO,wBAAwB,CAAC,CAAC,YAAY,CAAC,CAAC,SAAS,CAAC,CAAC,YAAY,CAAC,CAAC,QAAQ,CAAC,CACnF,CAAC,CAAC,CAAC,CAAC;AAEL;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,kBAAkB,EAC1B,MAAM,EAAE,uBAAuB,GAC9B,OAAO,CAAC,uBAAuB,CAAC,CAmElC"}
|
package/dist/types/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "4.
|
|
1
|
+
export declare const VERSION = "4.59.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@account-kit/wallet-client",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.59.0",
|
|
4
4
|
"description": "Wallet Client for Alchemy Account Kit",
|
|
5
5
|
"author": "Alchemy",
|
|
6
6
|
"license": "MIT",
|
|
@@ -40,10 +40,10 @@
|
|
|
40
40
|
"test:e2e": "bun test ./src/**/*.e2e.test.*"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@aa-sdk/core": "^4.
|
|
44
|
-
"@account-kit/infra": "^4.
|
|
45
|
-
"@account-kit/smart-contracts": "^4.
|
|
46
|
-
"@alchemy/wallet-api-types": "0.1.0-alpha.
|
|
43
|
+
"@aa-sdk/core": "^4.59.0",
|
|
44
|
+
"@account-kit/infra": "^4.59.0",
|
|
45
|
+
"@account-kit/smart-contracts": "^4.59.0",
|
|
46
|
+
"@alchemy/wallet-api-types": "0.1.0-alpha.16",
|
|
47
47
|
"deep-equal": "^2.2.3",
|
|
48
48
|
"ox": "^0.6.12"
|
|
49
49
|
},
|
|
@@ -69,5 +69,5 @@
|
|
|
69
69
|
"url": "https://github.com/alchemyplatform/aa-sdk/issues"
|
|
70
70
|
},
|
|
71
71
|
"homepage": "https://github.com/alchemyplatform/aa-sdk#readme",
|
|
72
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "0ede8e46b6529f38da1ad86bcf31faacf34e123b"
|
|
73
73
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { PrepareCallsResult } from "./prepareCalls.ts";
|
|
2
|
-
import type
|
|
2
|
+
import { BaseError, type SmartAccountSigner } from "@aa-sdk/core";
|
|
3
3
|
import { signSignatureRequest } from "./signSignatureRequest.js";
|
|
4
4
|
import type { Static } from "@sinclair/typebox";
|
|
5
5
|
import { wallet_sendPreparedCalls } from "@alchemy/wallet-api-types/rpc";
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
type PreparedCall_UserOpV070,
|
|
10
10
|
} from "@alchemy/wallet-api-types";
|
|
11
11
|
import { metrics } from "../../metrics.js";
|
|
12
|
+
import { assertNever } from "../../utils.js";
|
|
12
13
|
|
|
13
14
|
export type SignPreparedCallsParams = PrepareCallsResult;
|
|
14
15
|
|
|
@@ -53,6 +54,13 @@ export async function signPreparedCalls(
|
|
|
53
54
|
call: PreparedCall_UserOpV060 | PreparedCall_UserOpV070,
|
|
54
55
|
) => {
|
|
55
56
|
const { signatureRequest, ...rest } = call;
|
|
57
|
+
|
|
58
|
+
if (!signatureRequest) {
|
|
59
|
+
throw new BaseError(
|
|
60
|
+
"Signature request is required for signing user operation calls. Ensure `onlyEstimation` is set to `false` when calling `prepareCalls`.",
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
|
|
56
64
|
const signature = await signSignatureRequest(signer, signatureRequest);
|
|
57
65
|
return {
|
|
58
66
|
...rest,
|
|
@@ -60,16 +68,30 @@ export async function signPreparedCalls(
|
|
|
60
68
|
};
|
|
61
69
|
};
|
|
62
70
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
),
|
|
71
|
+
if (params.type === "array") {
|
|
72
|
+
return {
|
|
73
|
+
type: "array" as const,
|
|
74
|
+
data: await Promise.all(
|
|
75
|
+
params.data.map((call) =>
|
|
76
|
+
call.type === "authorization"
|
|
77
|
+
? signAuthorizationCall(call)
|
|
78
|
+
: signUserOperationCall(call),
|
|
72
79
|
),
|
|
73
|
-
|
|
74
|
-
|
|
80
|
+
),
|
|
81
|
+
};
|
|
82
|
+
} else if (
|
|
83
|
+
params.type === "user-operation-v060" ||
|
|
84
|
+
params.type === "user-operation-v070"
|
|
85
|
+
) {
|
|
86
|
+
return signUserOperationCall(params);
|
|
87
|
+
} else if (params.type === "paymaster-permit") {
|
|
88
|
+
throw new BaseError(
|
|
89
|
+
`Invalid call type ${params.type} for signing prepared calls`,
|
|
90
|
+
);
|
|
91
|
+
} else {
|
|
92
|
+
return assertNever(
|
|
93
|
+
params,
|
|
94
|
+
`Unexpected call type in ${params} for signing prepared calls`,
|
|
95
|
+
);
|
|
96
|
+
}
|
|
75
97
|
}
|