@account-kit/wallet-client 0.1.0-alpha.9 → 4.50.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/LICENSE +21 -0
- package/dist/esm/client/actions/formatSign.d.ts +30 -0
- package/dist/esm/client/actions/formatSign.js +32 -0
- package/dist/esm/client/actions/formatSign.js.map +1 -0
- package/dist/esm/client/actions/getCallsStatus.d.ts +6 -3
- package/dist/esm/client/actions/getCallsStatus.js +3 -0
- package/dist/esm/client/actions/getCallsStatus.js.map +1 -1
- package/dist/esm/client/actions/grantPermissions.d.ts +10 -11
- package/dist/esm/client/actions/grantPermissions.js +26 -12
- package/dist/esm/client/actions/grantPermissions.js.map +1 -1
- package/dist/esm/client/actions/listAccounts.d.ts +10 -3
- package/dist/esm/client/actions/listAccounts.js +14 -2
- package/dist/esm/client/actions/listAccounts.js.map +1 -1
- package/dist/esm/client/actions/prepareCalls.d.ts +6 -3
- package/dist/esm/client/actions/prepareCalls.js +12 -8
- package/dist/esm/client/actions/prepareCalls.js.map +1 -1
- package/dist/esm/client/actions/prepareSign.d.ts +28 -0
- package/dist/esm/client/actions/prepareSign.js +31 -0
- package/dist/esm/client/actions/prepareSign.js.map +1 -0
- package/dist/esm/client/actions/requestAccount.d.ts +3 -1
- package/dist/esm/client/actions/requestAccount.js +5 -3
- package/dist/esm/client/actions/requestAccount.js.map +1 -1
- package/dist/esm/client/actions/sendPreparedCalls.d.ts +3 -1
- package/dist/esm/client/actions/sendPreparedCalls.js +2 -0
- package/dist/esm/client/actions/sendPreparedCalls.js.map +1 -1
- package/dist/esm/client/actions/signMessage.d.ts +5 -2
- package/dist/esm/client/actions/signMessage.js +5 -2
- package/dist/esm/client/actions/signMessage.js.map +1 -1
- package/dist/esm/client/actions/signPreparedCalls.d.ts +2 -2
- package/dist/esm/client/actions/signPreparedCalls.js +3 -3
- package/dist/esm/client/actions/signPreparedCalls.js.map +1 -1
- package/dist/esm/client/actions/signSignatureRequest.d.ts +6 -10
- package/dist/esm/client/actions/signSignatureRequest.js +4 -7
- package/dist/esm/client/actions/signSignatureRequest.js.map +1 -1
- package/dist/esm/client/actions/signTypedData.d.ts +2 -0
- package/dist/esm/client/actions/signTypedData.js +2 -0
- package/dist/esm/client/actions/signTypedData.js.map +1 -1
- package/dist/esm/client/decorator.d.ts +0 -2
- package/dist/esm/client/decorator.js +1 -3
- package/dist/esm/client/decorator.js.map +1 -1
- package/dist/esm/client/index.d.ts +10 -6
- package/dist/esm/client/index.js +18 -21
- package/dist/esm/client/index.js.map +1 -1
- package/dist/esm/exports/index.d.ts +1 -5
- package/dist/esm/exports/index.js +1 -6
- package/dist/esm/exports/index.js.map +1 -1
- package/dist/esm/internal/account.d.ts +33 -0
- package/dist/esm/{isomorphic/utils/createAccount.js → internal/account.js} +25 -49
- package/dist/esm/internal/account.js.map +1 -0
- package/dist/esm/types.d.ts +5 -11
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/utils.d.ts +13 -1
- package/dist/esm/utils.js +13 -1
- package/dist/esm/utils.js.map +1 -1
- package/dist/esm/version.d.ts +1 -0
- package/dist/esm/version.js +4 -0
- package/dist/esm/version.js.map +1 -0
- package/dist/types/client/actions/formatSign.d.ts +31 -0
- package/dist/types/client/actions/formatSign.d.ts.map +1 -0
- package/dist/types/client/actions/getCallsStatus.d.ts +6 -3
- package/dist/types/client/actions/getCallsStatus.d.ts.map +1 -1
- package/dist/types/client/actions/grantPermissions.d.ts +10 -11
- package/dist/types/client/actions/grantPermissions.d.ts.map +1 -1
- package/dist/types/client/actions/listAccounts.d.ts +10 -3
- package/dist/types/client/actions/listAccounts.d.ts.map +1 -1
- package/dist/types/client/actions/prepareCalls.d.ts +6 -3
- package/dist/types/client/actions/prepareCalls.d.ts.map +1 -1
- package/dist/types/client/actions/prepareSign.d.ts +29 -0
- package/dist/types/client/actions/prepareSign.d.ts.map +1 -0
- package/dist/types/client/actions/requestAccount.d.ts +3 -1
- package/dist/types/client/actions/requestAccount.d.ts.map +1 -1
- package/dist/types/client/actions/sendPreparedCalls.d.ts +3 -1
- package/dist/types/client/actions/sendPreparedCalls.d.ts.map +1 -1
- package/dist/types/client/actions/signMessage.d.ts +5 -2
- package/dist/types/client/actions/signMessage.d.ts.map +1 -1
- package/dist/types/client/actions/signPreparedCalls.d.ts +2 -2
- package/dist/types/client/actions/signPreparedCalls.d.ts.map +1 -1
- package/dist/types/client/actions/signSignatureRequest.d.ts +6 -10
- package/dist/types/client/actions/signSignatureRequest.d.ts.map +1 -1
- package/dist/types/client/actions/signTypedData.d.ts +2 -0
- package/dist/types/client/actions/signTypedData.d.ts.map +1 -1
- package/dist/types/client/decorator.d.ts +0 -2
- package/dist/types/client/decorator.d.ts.map +1 -1
- package/dist/types/client/index.d.ts +10 -6
- package/dist/types/client/index.d.ts.map +1 -1
- package/dist/types/exports/index.d.ts +1 -5
- package/dist/types/exports/index.d.ts.map +1 -1
- package/dist/types/internal/account.d.ts +34 -0
- package/dist/types/internal/account.d.ts.map +1 -0
- package/dist/types/types.d.ts +5 -11
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/utils.d.ts +13 -1
- package/dist/types/utils.d.ts.map +1 -1
- package/dist/types/version.d.ts +2 -0
- package/dist/types/version.d.ts.map +1 -0
- package/package.json +33 -28
- package/src/client/actions/formatSign.ts +55 -0
- package/src/client/actions/getCallsStatus.ts +10 -6
- package/src/client/actions/grantPermissions.ts +46 -18
- package/src/client/actions/listAccounts.ts +22 -5
- package/src/client/actions/prepareCalls.ts +22 -16
- package/src/client/actions/prepareSign.ts +51 -0
- package/src/client/actions/requestAccount.ts +6 -4
- package/src/client/actions/sendPreparedCalls.ts +3 -1
- package/src/client/actions/signMessage.ts +5 -2
- package/src/client/actions/signPreparedCalls.ts +8 -12
- package/src/client/actions/signSignatureRequest.ts +12 -15
- package/src/client/actions/signTypedData.ts +2 -0
- package/src/client/decorator.ts +1 -8
- package/src/client/index.ts +41 -33
- package/src/exports/index.ts +1 -13
- package/src/internal/account.ts +120 -0
- package/src/types.ts +7 -18
- package/src/utils.ts +13 -1
- package/src/version.ts +3 -0
- package/dist/esm/capabilities/eip7702Auth.d.ts +0 -4
- package/dist/esm/capabilities/eip7702Auth.js +0 -18
- package/dist/esm/capabilities/eip7702Auth.js.map +0 -1
- package/dist/esm/capabilities/index.d.ts +0 -41
- package/dist/esm/capabilities/index.js +0 -14
- package/dist/esm/capabilities/index.js.map +0 -1
- package/dist/esm/capabilities/multiDimensionalNonce.d.ts +0 -3
- package/dist/esm/capabilities/multiDimensionalNonce.js +0 -7
- package/dist/esm/capabilities/multiDimensionalNonce.js.map +0 -1
- package/dist/esm/capabilities/overrides.d.ts +0 -26
- package/dist/esm/capabilities/overrides.js +0 -14
- package/dist/esm/capabilities/overrides.js.map +0 -1
- package/dist/esm/capabilities/paymaster.d.ts +0 -3
- package/dist/esm/capabilities/paymaster.js +0 -5
- package/dist/esm/capabilities/paymaster.js.map +0 -1
- package/dist/esm/capabilities/permissions/index.d.ts +0 -145
- package/dist/esm/capabilities/permissions/index.js +0 -83
- package/dist/esm/capabilities/permissions/index.js.map +0 -1
- package/dist/esm/capabilities/permissions/mav2.d.ts +0 -36
- package/dist/esm/capabilities/permissions/mav2.js +0 -88
- package/dist/esm/capabilities/permissions/mav2.js.map +0 -1
- package/dist/esm/client/actions/createAccount.d.ts +0 -35
- package/dist/esm/client/actions/createAccount.js +0 -32
- package/dist/esm/client/actions/createAccount.js.map +0 -1
- package/dist/esm/client/client.e2e-test.d.ts +0 -1
- package/dist/esm/client/client.e2e-test.js +0 -375
- package/dist/esm/client/client.e2e-test.js.map +0 -1
- package/dist/esm/exports/internal.d.ts +0 -14
- package/dist/esm/exports/internal.js +0 -16
- package/dist/esm/exports/internal.js.map +0 -1
- package/dist/esm/isomorphic/actions/createSession.d.ts +0 -14
- package/dist/esm/isomorphic/actions/createSession.js +0 -95
- package/dist/esm/isomorphic/actions/createSession.js.map +0 -1
- package/dist/esm/isomorphic/actions/getCallsStatus.d.ts +0 -21
- package/dist/esm/isomorphic/actions/getCallsStatus.js +0 -113
- package/dist/esm/isomorphic/actions/getCallsStatus.js.map +0 -1
- package/dist/esm/isomorphic/actions/prepareCalls.d.ts +0 -8
- package/dist/esm/isomorphic/actions/prepareCalls.js +0 -116
- package/dist/esm/isomorphic/actions/prepareCalls.js.map +0 -1
- package/dist/esm/isomorphic/actions/sendPreparedCalls.d.ts +0 -8
- package/dist/esm/isomorphic/actions/sendPreparedCalls.js +0 -157
- package/dist/esm/isomorphic/actions/sendPreparedCalls.js.map +0 -1
- package/dist/esm/isomorphic/client.d.ts +0 -239
- package/dist/esm/isomorphic/client.js +0 -37
- package/dist/esm/isomorphic/client.js.map +0 -1
- package/dist/esm/isomorphic/utils/7702.d.ts +0 -23
- package/dist/esm/isomorphic/utils/7702.js +0 -75
- package/dist/esm/isomorphic/utils/7702.js.map +0 -1
- package/dist/esm/isomorphic/utils/createAccount.d.ts +0 -24
- package/dist/esm/isomorphic/utils/createAccount.js.map +0 -1
- package/dist/esm/isomorphic/utils/createDummySigner.d.ts +0 -3
- package/dist/esm/isomorphic/utils/createDummySigner.js +0 -17
- package/dist/esm/isomorphic/utils/createDummySigner.js.map +0 -1
- package/dist/esm/isomorphic/utils/decodeSignature.d.ts +0 -3
- package/dist/esm/isomorphic/utils/decodeSignature.js +0 -13
- package/dist/esm/isomorphic/utils/decodeSignature.js.map +0 -1
- package/dist/esm/isomorphic/utils/parsePermissionsContext.d.ts +0 -21
- package/dist/esm/isomorphic/utils/parsePermissionsContext.js +0 -34
- package/dist/esm/isomorphic/utils/parsePermissionsContext.js.map +0 -1
- package/dist/esm/isomorphic/utils/supportsFeature.d.ts +0 -4
- package/dist/esm/isomorphic/utils/supportsFeature.js +0 -21
- package/dist/esm/isomorphic/utils/supportsFeature.js.map +0 -1
- package/dist/esm/local/client.d.ts +0 -3
- package/dist/esm/local/client.js +0 -97
- package/dist/esm/local/client.js.map +0 -1
- package/dist/esm/remote/client.d.ts +0 -9
- package/dist/esm/remote/client.js +0 -41
- package/dist/esm/remote/client.js.map +0 -1
- package/dist/esm/rpc/examples.d.ts +0 -230
- package/dist/esm/rpc/examples.js +0 -314
- package/dist/esm/rpc/examples.js.map +0 -1
- package/dist/esm/rpc/request.d.ts +0 -755
- package/dist/esm/rpc/request.js +0 -214
- package/dist/esm/rpc/request.js.map +0 -1
- package/dist/esm/rpc/schema.d.ts +0 -703
- package/dist/esm/rpc/schema.js +0 -5
- package/dist/esm/rpc/schema.js.map +0 -1
- package/dist/esm/schemas.d.ts +0 -712
- package/dist/esm/schemas.js +0 -463
- package/dist/esm/schemas.js.map +0 -1
- package/dist/types/capabilities/eip7702Auth.d.ts +0 -5
- package/dist/types/capabilities/eip7702Auth.d.ts.map +0 -1
- package/dist/types/capabilities/index.d.ts +0 -42
- package/dist/types/capabilities/index.d.ts.map +0 -1
- package/dist/types/capabilities/multiDimensionalNonce.d.ts +0 -4
- package/dist/types/capabilities/multiDimensionalNonce.d.ts.map +0 -1
- package/dist/types/capabilities/overrides.d.ts +0 -27
- package/dist/types/capabilities/overrides.d.ts.map +0 -1
- package/dist/types/capabilities/paymaster.d.ts +0 -4
- package/dist/types/capabilities/paymaster.d.ts.map +0 -1
- package/dist/types/capabilities/permissions/index.d.ts +0 -146
- package/dist/types/capabilities/permissions/index.d.ts.map +0 -1
- package/dist/types/capabilities/permissions/mav2.d.ts +0 -37
- package/dist/types/capabilities/permissions/mav2.d.ts.map +0 -1
- package/dist/types/client/actions/createAccount.d.ts +0 -36
- package/dist/types/client/actions/createAccount.d.ts.map +0 -1
- package/dist/types/client/client.e2e-test.d.ts +0 -2
- package/dist/types/client/client.e2e-test.d.ts.map +0 -1
- package/dist/types/exports/internal.d.ts +0 -15
- package/dist/types/exports/internal.d.ts.map +0 -1
- package/dist/types/isomorphic/actions/createSession.d.ts +0 -15
- package/dist/types/isomorphic/actions/createSession.d.ts.map +0 -1
- package/dist/types/isomorphic/actions/getCallsStatus.d.ts +0 -22
- package/dist/types/isomorphic/actions/getCallsStatus.d.ts.map +0 -1
- package/dist/types/isomorphic/actions/prepareCalls.d.ts +0 -9
- package/dist/types/isomorphic/actions/prepareCalls.d.ts.map +0 -1
- package/dist/types/isomorphic/actions/sendPreparedCalls.d.ts +0 -9
- package/dist/types/isomorphic/actions/sendPreparedCalls.d.ts.map +0 -1
- package/dist/types/isomorphic/client.d.ts +0 -240
- package/dist/types/isomorphic/client.d.ts.map +0 -1
- package/dist/types/isomorphic/utils/7702.d.ts +0 -24
- package/dist/types/isomorphic/utils/7702.d.ts.map +0 -1
- package/dist/types/isomorphic/utils/createAccount.d.ts +0 -25
- package/dist/types/isomorphic/utils/createAccount.d.ts.map +0 -1
- package/dist/types/isomorphic/utils/createDummySigner.d.ts +0 -4
- package/dist/types/isomorphic/utils/createDummySigner.d.ts.map +0 -1
- package/dist/types/isomorphic/utils/decodeSignature.d.ts +0 -4
- package/dist/types/isomorphic/utils/decodeSignature.d.ts.map +0 -1
- package/dist/types/isomorphic/utils/parsePermissionsContext.d.ts +0 -22
- package/dist/types/isomorphic/utils/parsePermissionsContext.d.ts.map +0 -1
- package/dist/types/isomorphic/utils/supportsFeature.d.ts +0 -5
- package/dist/types/isomorphic/utils/supportsFeature.d.ts.map +0 -1
- package/dist/types/local/client.d.ts +0 -4
- package/dist/types/local/client.d.ts.map +0 -1
- package/dist/types/remote/client.d.ts +0 -10
- package/dist/types/remote/client.d.ts.map +0 -1
- package/dist/types/rpc/examples.d.ts +0 -231
- package/dist/types/rpc/examples.d.ts.map +0 -1
- package/dist/types/rpc/request.d.ts +0 -756
- package/dist/types/rpc/request.d.ts.map +0 -1
- package/dist/types/rpc/schema.d.ts +0 -704
- package/dist/types/rpc/schema.d.ts.map +0 -1
- package/dist/types/schemas.d.ts +0 -713
- package/dist/types/schemas.d.ts.map +0 -1
- package/src/capabilities/eip7702Auth.ts +0 -26
- package/src/capabilities/index.ts +0 -14
- package/src/capabilities/multiDimensionalNonce.ts +0 -7
- package/src/capabilities/overrides.ts +0 -35
- package/src/capabilities/paymaster.ts +0 -5
- package/src/capabilities/permissions/index.ts +0 -163
- package/src/capabilities/permissions/mav2.ts +0 -138
- package/src/client/actions/createAccount.ts +0 -53
- package/src/client/client.e2e-test.ts +0 -463
- package/src/exports/internal.ts +0 -17
- package/src/isomorphic/actions/createSession.ts +0 -159
- package/src/isomorphic/actions/getCallsStatus.ts +0 -170
- package/src/isomorphic/actions/prepareCalls.ts +0 -170
- package/src/isomorphic/actions/sendPreparedCalls.ts +0 -232
- package/src/isomorphic/client.ts +0 -94
- package/src/isomorphic/utils/7702.ts +0 -143
- package/src/isomorphic/utils/createAccount.ts +0 -170
- package/src/isomorphic/utils/createDummySigner.ts +0 -27
- package/src/isomorphic/utils/decodeSignature.ts +0 -18
- package/src/isomorphic/utils/parsePermissionsContext.ts +0 -49
- package/src/isomorphic/utils/supportsFeature.ts +0 -34
- package/src/local/client.ts +0 -136
- package/src/remote/client.ts +0 -67
- package/src/rpc/examples.ts +0 -342
- package/src/rpc/request.ts +0 -300
- package/src/rpc/schema.ts +0 -40
- package/src/schemas.ts +0 -657
|
@@ -2,8 +2,8 @@ import {} from "@aa-sdk/core";
|
|
|
2
2
|
import { Value } from "@sinclair/typebox/value";
|
|
3
3
|
import deepEqual from "deep-equal";
|
|
4
4
|
import { custom } from "viem";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { SerializedInitcode } from "@alchemy/wallet-api-types";
|
|
6
|
+
import { createAccount } from "../../internal/account.js";
|
|
7
7
|
/**
|
|
8
8
|
* Requests an account for the provided signer using the wallet API client.
|
|
9
9
|
* If an account already exists for the signer, it will always return that account unless a new ID is specified.
|
|
@@ -17,9 +17,11 @@ import { TypeSerializedInitcode } from "../../schemas.js";
|
|
|
17
17
|
* @returns {Promise<RequestAccountResult>} A Promise that resolves to a SmartContractAccount instance
|
|
18
18
|
*
|
|
19
19
|
* @example
|
|
20
|
+
* ```ts
|
|
20
21
|
* // Request an account with default parameters using a local signer
|
|
21
22
|
* const signer = LocalAccountSigner.privateKeyToAccountSigner("0x...");
|
|
22
23
|
* const account = await client.requestAccount(signer);
|
|
24
|
+
* ```
|
|
23
25
|
*/
|
|
24
26
|
export async function requestAccount(client, signer, params) {
|
|
25
27
|
const args = (client.account && !params) || params?.accountAddress
|
|
@@ -46,7 +48,7 @@ export async function requestAccount(client, signer, params) {
|
|
|
46
48
|
const account = await createAccount({
|
|
47
49
|
accountAddress,
|
|
48
50
|
counterfactualInfo: counterfactualInfo
|
|
49
|
-
? Value.Parse(
|
|
51
|
+
? Value.Parse(SerializedInitcode, counterfactualInfo)
|
|
50
52
|
: undefined,
|
|
51
53
|
delegation,
|
|
52
54
|
chain: client.chain,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"requestAccount.js","sourceRoot":"","sources":["../../../../src/client/actions/requestAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAEhD,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"requestAccount.js","sourceRoot":"","sources":["../../../../src/client/actions/requestAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAEhD,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAE9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE/D,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAY1D;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,MAA4B,EAC5B,MAA0B,EAC1B,MAA6B;IAE7B,MAAM,IAAI,GACR,CAAC,MAAM,CAAC,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,MAAM,EAAE,cAAc;QACnD,CAAC,CAAC;YACE,cAAc,EAAE,MAAM,EAAE,cAAc,IAAI,MAAM,CAAC,OAAQ,CAAC,OAAO;YACjE,yBAAyB,EAAE,IAAI;SAChC;QACH,CAAC,CAAC;YACE,GAAG,MAAM;YACT,aAAa,EAAE,MAAM,MAAM,CAAC,UAAU,EAAE;YACxC,yBAAyB,EAAE,IAAI;SAChC,CAAC;IAER,MAAM,aAAa,GAAG,MAAM,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC;IAEnD,IACE,aAAa;QACb,CAAC,CAAC,IAAI,CAAC,cAAc;YACnB,aAAa,CAAC,OAAO,CAAC,OAAO,KAAK,IAAI,CAAC,cAAc,CAAC;YACtD,SAAS,CAAC,aAAa,CAAC,aAAa,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,EACjE,CAAC;QACD,OAAO,aAAa,CAAC,OAAO,CAAC;IAC/B,CAAC;IAED,MAAM,EAAE,cAAc,EAAE,kBAAkB,EAAE,UAAU,EAAE,GACtD,MAAM,MAAM,CAAC,OAAO,CAAC;QACnB,MAAM,EAAE,uBAAuB;QAC/B,MAAM,EAAE,CAAC,IAAI,CAAC;KACf,CAAC,CAAC;IAEL,MAAM,OAAO,GAAG,MAAM,aAAa,CAAC;QAClC,cAAc;QACd,kBAAkB,EAAE,kBAAkB;YACpC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,kBAAkB,EAAE,kBAAkB,CAAC;YACrD,CAAC,CAAC,SAAS;QACb,UAAU;QACV,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC;QACnC,MAAM;KACP,CAAC,CAAC;IAEH,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;IAE7D,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import {\n type SmartAccountSigner,\n type SmartContractAccount,\n} from \"@aa-sdk/core\";\nimport type { Static } from \"@sinclair/typebox\";\nimport { Value } from \"@sinclair/typebox/value\";\nimport type { Address } from \"abitype\";\nimport deepEqual from \"deep-equal\";\nimport { custom } from \"viem\";\nimport type { wallet_requestAccount } from \"@alchemy/wallet-api-types/rpc\";\nimport { SerializedInitcode } from \"@alchemy/wallet-api-types\";\nimport type { InnerWalletApiClient } from \"../../types.js\";\nimport { createAccount } from \"../../internal/account.js\";\n\nexport type RequestAccountParams = Omit<\n Extract<\n Static<typeof wallet_requestAccount>[\"Request\"][\"params\"][0],\n { signerAddress: Address }\n >,\n \"signerAddress\" | \"includeCounterfactualInfo\"\n> & { accountAddress?: Address };\n\nexport type RequestAccountResult = SmartContractAccount;\n\n/**\n * Requests an account for the provided signer using the wallet API client.\n * If an account already exists for the signer, it will always return that account unless a new ID is specified.\n * If an account already exists, the creationHint will be ignored.\n *\n * @param {InnerWalletApiClient} client - The wallet API client to use for the request\n * @param {SmartAccountSigner} signer - The signer that will be associated with the account\n * @param {RequestAccountParams} [params] - Optional parameters for requesting a specific account\n * @param {string} [params.id] - Optional identifier for the account. If specified, a new account with this ID will be created even if one already exists for the signer\n * @param {object} [params.creationHint] - Optional hints to guide account creation. These are ignored if an account already exists\n * @returns {Promise<RequestAccountResult>} A Promise that resolves to a SmartContractAccount instance\n *\n * @example\n * ```ts\n * // Request an account with default parameters using a local signer\n * const signer = LocalAccountSigner.privateKeyToAccountSigner(\"0x...\");\n * const account = await client.requestAccount(signer);\n * ```\n */\nexport async function requestAccount(\n client: InnerWalletApiClient,\n signer: SmartAccountSigner,\n params?: RequestAccountParams,\n): Promise<RequestAccountResult> {\n const args =\n (client.account && !params) || params?.accountAddress\n ? {\n accountAddress: params?.accountAddress ?? client.account!.address,\n includeCounterfactualInfo: true,\n }\n : {\n ...params,\n signerAddress: await signer.getAddress(),\n includeCounterfactualInfo: true,\n };\n\n const cachedAccount = client.internal.getAccount();\n\n if (\n cachedAccount &&\n ((args.accountAddress &&\n cachedAccount.account.address === args.accountAddress) ||\n deepEqual(cachedAccount.requestParams, args, { strict: true }))\n ) {\n return cachedAccount.account;\n }\n\n const { accountAddress, counterfactualInfo, delegation } =\n await client.request({\n method: \"wallet_requestAccount\",\n params: [args],\n });\n\n const account = await createAccount({\n accountAddress,\n counterfactualInfo: counterfactualInfo\n ? Value.Parse(SerializedInitcode, counterfactualInfo)\n : undefined,\n delegation,\n chain: client.chain,\n transport: custom(client.transport),\n signer,\n });\n\n client.internal.setAccount({ account, requestParams: args });\n\n return account;\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Static } from "@sinclair/typebox";
|
|
2
|
-
import type { wallet_sendPreparedCalls } from "
|
|
2
|
+
import type { wallet_sendPreparedCalls } from "@alchemy/wallet-api-types/rpc";
|
|
3
3
|
import type { InnerWalletApiClient, WithoutChainId } from "../../types.ts";
|
|
4
4
|
export type SendPreparedCallsParams = WithoutChainId<Static<(typeof wallet_sendPreparedCalls)["properties"]["Request"]["properties"]["params"]>[0]>;
|
|
5
5
|
export type SendPreparedCallsResult = Static<typeof wallet_sendPreparedCalls>["ReturnType"];
|
|
@@ -12,6 +12,7 @@ export type SendPreparedCallsResult = Static<typeof wallet_sendPreparedCalls>["R
|
|
|
12
12
|
* @returns {Promise<SendPreparedCallsResult>} A Promise that resolves to the result containing the prepared call IDs
|
|
13
13
|
*
|
|
14
14
|
* @example
|
|
15
|
+
* ```ts
|
|
15
16
|
* // First prepare the calls
|
|
16
17
|
* const preparedCalls = await client.prepareCalls({
|
|
17
18
|
* calls: [{
|
|
@@ -31,5 +32,6 @@ export type SendPreparedCallsResult = Static<typeof wallet_sendPreparedCalls>["R
|
|
|
31
32
|
* const result = await client.sendPreparedCalls({
|
|
32
33
|
* signedCalls,
|
|
33
34
|
* });
|
|
35
|
+
* ```
|
|
34
36
|
*/
|
|
35
37
|
export declare function sendPreparedCalls(client: InnerWalletApiClient, params: SendPreparedCallsParams): Promise<SendPreparedCallsResult>;
|
|
@@ -8,6 +8,7 @@ import { toHex } from "viem";
|
|
|
8
8
|
* @returns {Promise<SendPreparedCallsResult>} A Promise that resolves to the result containing the prepared call IDs
|
|
9
9
|
*
|
|
10
10
|
* @example
|
|
11
|
+
* ```ts
|
|
11
12
|
* // First prepare the calls
|
|
12
13
|
* const preparedCalls = await client.prepareCalls({
|
|
13
14
|
* calls: [{
|
|
@@ -27,6 +28,7 @@ import { toHex } from "viem";
|
|
|
27
28
|
* const result = await client.sendPreparedCalls({
|
|
28
29
|
* signedCalls,
|
|
29
30
|
* });
|
|
31
|
+
* ```
|
|
30
32
|
*/
|
|
31
33
|
export async function sendPreparedCalls(client, params) {
|
|
32
34
|
return client.request({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sendPreparedCalls.js","sourceRoot":"","sources":["../../../../src/client/actions/sendPreparedCalls.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAc7B
|
|
1
|
+
{"version":3,"file":"sendPreparedCalls.js","sourceRoot":"","sources":["../../../../src/client/actions/sendPreparedCalls.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAc7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,MAA4B,EAC5B,MAA+B;IAE/B,OAAO,MAAM,CAAC,OAAO,CAAC;QACpB,MAAM,EAAE,0BAA0B;QAClC,MAAM,EAAE;YACN,MAAM,CAAC,IAAI,KAAK,OAAO;gBACrB,CAAC,CAAC,MAAM;gBACR,CAAC,CAAC;oBACE,GAAG,MAAM;oBACT,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;iBAChC;SACN;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { Static } from \"@sinclair/typebox\";\nimport { toHex } from \"viem\";\nimport type { wallet_sendPreparedCalls } from \"@alchemy/wallet-api-types/rpc\";\nimport type { InnerWalletApiClient, WithoutChainId } from \"../../types.ts\";\n\nexport type SendPreparedCallsParams = WithoutChainId<\n Static<\n (typeof wallet_sendPreparedCalls)[\"properties\"][\"Request\"][\"properties\"][\"params\"]\n >[0]\n>;\n\nexport type SendPreparedCallsResult = Static<\n typeof wallet_sendPreparedCalls\n>[\"ReturnType\"];\n\n/**\n * Sends prepared calls by submitting a signed user operation.\n * This method is used after signing the signature request returned from prepareCalls.\n *\n * @param {InnerWalletApiClient} client - The wallet API client to use for the request\n * @param {SendPreparedCallsParams} params - Parameters for sending prepared calls\n * @returns {Promise<SendPreparedCallsResult>} A Promise that resolves to the result containing the prepared call IDs\n *\n * @example\n * ```ts\n * // First prepare the calls\n * const preparedCalls = await client.prepareCalls({\n * calls: [{\n * to: \"0x1234...\",\n * data: \"0xabcdef...\",\n * value: \"0x0\"\n * }],\n * capabilities: {\n * paymasterService: { policyId: \"your-policy-id\" }\n * }\n * });\n *\n * // Then sign the calls\n * const signedCalls = await client.signPreparedCalls(preparedCalls);\n *\n * // Then send the prepared calls with the signature\n * const result = await client.sendPreparedCalls({\n * signedCalls,\n * });\n * ```\n */\nexport async function sendPreparedCalls(\n client: InnerWalletApiClient,\n params: SendPreparedCallsParams,\n): Promise<SendPreparedCallsResult> {\n return client.request({\n method: \"wallet_sendPreparedCalls\",\n params: [\n params.type === \"array\"\n ? params\n : {\n ...params,\n chainId: toHex(client.chain.id),\n },\n ],\n });\n}\n"]}
|
|
@@ -12,15 +12,18 @@ export type SignMessageResult = Hex;
|
|
|
12
12
|
*
|
|
13
13
|
* @param {InnerWalletApiClient} client - The wallet API client to use for the request
|
|
14
14
|
* @param {SmartAccountSigner} signer - The signer of the smart account
|
|
15
|
-
* @param {
|
|
15
|
+
* @param {SignMessageParams} params - Parameters for signing the message
|
|
16
|
+
* @param {SignableMessage} params.message - The message to sign using EIP-191. Can be a string, or object with raw bytes.
|
|
17
|
+
* @param {Address} [params.account] - Optional account address to use for signing. If not provided, uses the client's current account.
|
|
16
18
|
* @returns {Promise<SignMessageResult>} A Promise that resolves to the signed message as a hex string
|
|
17
19
|
*
|
|
18
20
|
* @example
|
|
21
|
+
* ```ts
|
|
19
22
|
* // Sign a simple text message
|
|
20
23
|
* const signature = await client.signMessage("Hello, world!");
|
|
21
24
|
*
|
|
22
|
-
* @example
|
|
23
25
|
* // Sign a raw hex message
|
|
24
26
|
* const signature = await client.signMessage({ raw: "0x48656c6c6f2c20776f726c6421" });
|
|
27
|
+
* ```
|
|
25
28
|
*/
|
|
26
29
|
export declare function signMessage(client: InnerWalletApiClient, signer: SmartAccountSigner, params: SignMessageParams): Promise<SignMessageResult>;
|
|
@@ -7,16 +7,19 @@ import { requestAccount } from "./requestAccount.js";
|
|
|
7
7
|
*
|
|
8
8
|
* @param {InnerWalletApiClient} client - The wallet API client to use for the request
|
|
9
9
|
* @param {SmartAccountSigner} signer - The signer of the smart account
|
|
10
|
-
* @param {
|
|
10
|
+
* @param {SignMessageParams} params - Parameters for signing the message
|
|
11
|
+
* @param {SignableMessage} params.message - The message to sign using EIP-191. Can be a string, or object with raw bytes.
|
|
12
|
+
* @param {Address} [params.account] - Optional account address to use for signing. If not provided, uses the client's current account.
|
|
11
13
|
* @returns {Promise<SignMessageResult>} A Promise that resolves to the signed message as a hex string
|
|
12
14
|
*
|
|
13
15
|
* @example
|
|
16
|
+
* ```ts
|
|
14
17
|
* // Sign a simple text message
|
|
15
18
|
* const signature = await client.signMessage("Hello, world!");
|
|
16
19
|
*
|
|
17
|
-
* @example
|
|
18
20
|
* // Sign a raw hex message
|
|
19
21
|
* const signature = await client.signMessage({ raw: "0x48656c6c6f2c20776f726c6421" });
|
|
22
|
+
* ```
|
|
20
23
|
*/
|
|
21
24
|
export async function signMessage(client, signer, params) {
|
|
22
25
|
const account = await requestAccount(client, signer, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signMessage.js","sourceRoot":"","sources":["../../../../src/client/actions/signMessage.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,MAAM,cAAc,CAAC;AACvD,OAAO,EAAgD,MAAM,MAAM,CAAC;AAEpE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAMrD
|
|
1
|
+
{"version":3,"file":"signMessage.js","sourceRoot":"","sources":["../../../../src/client/actions/signMessage.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,MAAM,cAAc,CAAC;AACvD,OAAO,EAAgD,MAAM,MAAM,CAAC;AAEpE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAMrD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,MAA4B,EAC5B,MAA0B,EAC1B,MAAyB;IAEzB,MAAM,OAAO,GAAG,MAAM,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE;QACnD,cAAc,EAAE,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,OAAO,EAAE,OAAO;KAC1D,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC,mBAAmB,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;AAClE,CAAC","sourcesContent":["import { type SmartAccountSigner } from \"@aa-sdk/core\";\nimport { type Address, type Hex, type SignableMessage } from \"viem\";\nimport type { InnerWalletApiClient } from \"../../types.ts\";\nimport { requestAccount } from \"./requestAccount.js\";\n\nexport type SignMessageParams = { message: SignableMessage; account?: Address };\n\nexport type SignMessageResult = Hex;\n\n/**\n * Signs a message using the smart account.\n * This method requests the account associated with the signer and uses it to sign the message.\n *\n * @param {InnerWalletApiClient} client - The wallet API client to use for the request\n * @param {SmartAccountSigner} signer - The signer of the smart account\n * @param {SignMessageParams} params - Parameters for signing the message\n * @param {SignableMessage} params.message - The message to sign using EIP-191. Can be a string, or object with raw bytes.\n * @param {Address} [params.account] - Optional account address to use for signing. If not provided, uses the client's current account.\n * @returns {Promise<SignMessageResult>} A Promise that resolves to the signed message as a hex string\n *\n * @example\n * ```ts\n * // Sign a simple text message\n * const signature = await client.signMessage(\"Hello, world!\");\n *\n * // Sign a raw hex message\n * const signature = await client.signMessage({ raw: \"0x48656c6c6f2c20776f726c6421\" });\n * ```\n */\nexport async function signMessage(\n client: InnerWalletApiClient,\n signer: SmartAccountSigner,\n params: SignMessageParams,\n): Promise<SignMessageResult> {\n const account = await requestAccount(client, signer, {\n accountAddress: params.account ?? client.account?.address,\n });\n\n return account.signMessageWith6492({ message: params.message });\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { PrepareCallsResult } from "./prepareCalls.ts";
|
|
2
2
|
import type { SmartAccountSigner } from "@aa-sdk/core";
|
|
3
3
|
import type { Static } from "@sinclair/typebox";
|
|
4
|
-
import { wallet_sendPreparedCalls } from "
|
|
4
|
+
import { wallet_sendPreparedCalls } from "@alchemy/wallet-api-types/rpc";
|
|
5
5
|
export type SignPreparedCallsParams = PrepareCallsResult;
|
|
6
6
|
export type SignPreparedCallsResult = Static<(typeof wallet_sendPreparedCalls)["properties"]["Request"]["properties"]["params"]>[0];
|
|
7
7
|
/**
|
|
@@ -10,5 +10,5 @@ export type SignPreparedCallsResult = Static<(typeof wallet_sendPreparedCalls)["
|
|
|
10
10
|
* @param {SmartAccountSigner} signer - The signer to use
|
|
11
11
|
* @param {SignPreparedCallsParams} params - The prepared calls with signature requests
|
|
12
12
|
* @returns {Promise<SignPreparedCallsResult>} A Promise that resolves to the signed calls
|
|
13
|
-
|
|
13
|
+
*/
|
|
14
14
|
export declare function signPreparedCalls(signer: SmartAccountSigner, params: SignPreparedCallsParams): Promise<SignPreparedCallsResult>;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { signSignatureRequest } from "./signSignatureRequest.js";
|
|
2
|
-
import { wallet_sendPreparedCalls } from "
|
|
3
|
-
import {
|
|
2
|
+
import { wallet_sendPreparedCalls } from "@alchemy/wallet-api-types/rpc";
|
|
3
|
+
import {} from "@alchemy/wallet-api-types";
|
|
4
4
|
/**
|
|
5
5
|
* Signs prepared calls using the provided signer.
|
|
6
6
|
*
|
|
7
7
|
* @param {SmartAccountSigner} signer - The signer to use
|
|
8
8
|
* @param {SignPreparedCallsParams} params - The prepared calls with signature requests
|
|
9
9
|
* @returns {Promise<SignPreparedCallsResult>} A Promise that resolves to the signed calls
|
|
10
|
-
|
|
10
|
+
*/
|
|
11
11
|
export async function signPreparedCalls(signer, params) {
|
|
12
12
|
const signAuthorizationCall = async (call) => {
|
|
13
13
|
const { signatureRequest: _signatureRequest, ...rest } = call;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signPreparedCalls.js","sourceRoot":"","sources":["../../../../src/client/actions/signPreparedCalls.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEjE,OAAO,EAAE,wBAAwB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"signPreparedCalls.js","sourceRoot":"","sources":["../../../../src/client/actions/signPreparedCalls.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEjE,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,EAIN,MAAM,2BAA2B,CAAC;AAQnC;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,MAA0B,EAC1B,MAA+B;IAE/B,MAAM,qBAAqB,GAAG,KAAK,EAAE,IAAgC,EAAE,EAAE;QACvE,MAAM,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,GAAG,IAAI,EAAE,GAAG,IAAI,CAAC;QAC9D,MAAM,SAAS,GAAG,MAAM,oBAAoB,CAAC,MAAM,EAAE;YACnD,IAAI,EAAE,aAAa;YACnB,IAAI,EAAE;gBACJ,GAAG,IAAI,CAAC,IAAI;gBACZ,OAAO,EAAE,IAAI,CAAC,OAAO;aACtB;SACF,CAAC,CAAC;QACH,OAAO;YACL,GAAG,IAAI;YACP,SAAS;SACV,CAAC;IACJ,CAAC,CAAC;IAEF,MAAM,qBAAqB,GAAG,KAAK,EACjC,IAAuD,EACvD,EAAE;QACF,MAAM,EAAE,gBAAgB,EAAE,GAAG,IAAI,EAAE,GAAG,IAAI,CAAC;QAC3C,MAAM,SAAS,GAAG,MAAM,oBAAoB,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;QACvE,OAAO;YACL,GAAG,IAAI;YACP,SAAS;SACV,CAAC;IACJ,CAAC,CAAC;IAEF,OAAO,MAAM,CAAC,IAAI,KAAK,OAAO;QAC5B,CAAC,CAAC;YACE,IAAI,EAAE,OAAgB;YACtB,IAAI,EAAE,MAAM,OAAO,CAAC,GAAG,CACrB,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CACvB,IAAI,CAAC,IAAI,KAAK,eAAe;gBAC3B,CAAC,CAAC,qBAAqB,CAAC,IAAI,CAAC;gBAC7B,CAAC,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAChC,CACF;SACF;QACH,CAAC,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAC;AACpC,CAAC","sourcesContent":["import type { PrepareCallsResult } from \"./prepareCalls.ts\";\nimport 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\";\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 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 const signature = await signSignatureRequest(signer, signatureRequest);\n return {\n ...rest,\n signature,\n };\n };\n\n return params.type === \"array\"\n ? {\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 : signUserOperationCall(params);\n}\n"]}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import type { SmartAccountSigner } from "@aa-sdk/core";
|
|
2
|
-
import type { Static } from "@sinclair/typebox";
|
|
3
2
|
import { type Hex } from "viem";
|
|
4
|
-
import {
|
|
5
|
-
import { TypeEip7702UnsignedAuth } from "../../schemas.js";
|
|
3
|
+
import { type PersonalSignSignatureRequest, type TypedDataSignatureRequest, type AuthorizationSignatureRequest, type Eip7702UnsignedAuth } from "@alchemy/wallet-api-types";
|
|
6
4
|
import type { WithoutRawPayload } from "../../types.ts";
|
|
7
|
-
export type SignSignatureRequestParams = WithoutRawPayload<
|
|
8
|
-
data:
|
|
5
|
+
export type SignSignatureRequestParams = WithoutRawPayload<PersonalSignSignatureRequest | TypedDataSignatureRequest | (AuthorizationSignatureRequest & {
|
|
6
|
+
data: Eip7702UnsignedAuth;
|
|
9
7
|
})>;
|
|
10
8
|
export type SignSignatureRequestResult = {
|
|
11
9
|
type: "secp256k1";
|
|
@@ -18,20 +16,17 @@ export type SignSignatureRequestResult = {
|
|
|
18
16
|
* @param {SmartAccountSigner} signer - The signer to use for signing the request
|
|
19
17
|
* @param {SignSignatureRequestParams} params - The signature request parameters
|
|
20
18
|
* @param {string} params.type - The type of signature request ('personal_sign', 'eth_signTypedData_v4', or 'signature_with_authorization')
|
|
21
|
-
* @param {
|
|
19
|
+
* @param {SignSignatureRequestParams["data"]} params.data - The data to sign, format depends on the signature type
|
|
22
20
|
* @returns {Promise<SignSignatureRequestResult>} A Promise that resolves to the signature result
|
|
23
|
-
* @returns {string} result.type - The signature type (currently only 'secp256k1' is supported)
|
|
24
|
-
* @returns {Hex} result.signature - The hex-encoded signature
|
|
25
|
-
* @returns {Eip7702ExtendedFields["eip7702Auth"]} result.signedAuthorization - The signed EIP-7702 authorization, if applicable
|
|
26
21
|
*
|
|
27
22
|
* @example
|
|
23
|
+
* ```ts
|
|
28
24
|
* // Sign a personal message
|
|
29
25
|
* const result = await client.signSignatureRequest({
|
|
30
26
|
* type: 'personal_sign',
|
|
31
27
|
* data: 'Hello, world!'
|
|
32
28
|
* });
|
|
33
29
|
*
|
|
34
|
-
* @example
|
|
35
30
|
* // Sign typed data (EIP-712)
|
|
36
31
|
* const result = await client.signSignatureRequest({
|
|
37
32
|
* type: 'eth_signTypedData_v4',
|
|
@@ -42,5 +37,6 @@ export type SignSignatureRequestResult = {
|
|
|
42
37
|
* message: { ... }
|
|
43
38
|
* }
|
|
44
39
|
* });
|
|
40
|
+
* ```
|
|
45
41
|
*/
|
|
46
42
|
export declare function signSignatureRequest(signer: SmartAccountSigner, params: SignSignatureRequestParams): Promise<SignSignatureRequestResult>;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { hexToNumber, serializeSignature } from "viem";
|
|
2
2
|
import { assertNever } from "../../utils.js";
|
|
3
|
-
import {
|
|
4
|
-
import { TypeEip7702UnsignedAuth } from "../../schemas.js";
|
|
3
|
+
import {} from "@alchemy/wallet-api-types";
|
|
5
4
|
import { vToYParity } from "ox/Signature";
|
|
6
5
|
/**
|
|
7
6
|
* Signs a signature request using the provided signer.
|
|
@@ -10,20 +9,17 @@ import { vToYParity } from "ox/Signature";
|
|
|
10
9
|
* @param {SmartAccountSigner} signer - The signer to use for signing the request
|
|
11
10
|
* @param {SignSignatureRequestParams} params - The signature request parameters
|
|
12
11
|
* @param {string} params.type - The type of signature request ('personal_sign', 'eth_signTypedData_v4', or 'signature_with_authorization')
|
|
13
|
-
* @param {
|
|
12
|
+
* @param {SignSignatureRequestParams["data"]} params.data - The data to sign, format depends on the signature type
|
|
14
13
|
* @returns {Promise<SignSignatureRequestResult>} A Promise that resolves to the signature result
|
|
15
|
-
* @returns {string} result.type - The signature type (currently only 'secp256k1' is supported)
|
|
16
|
-
* @returns {Hex} result.signature - The hex-encoded signature
|
|
17
|
-
* @returns {Eip7702ExtendedFields["eip7702Auth"]} result.signedAuthorization - The signed EIP-7702 authorization, if applicable
|
|
18
14
|
*
|
|
19
15
|
* @example
|
|
16
|
+
* ```ts
|
|
20
17
|
* // Sign a personal message
|
|
21
18
|
* const result = await client.signSignatureRequest({
|
|
22
19
|
* type: 'personal_sign',
|
|
23
20
|
* data: 'Hello, world!'
|
|
24
21
|
* });
|
|
25
22
|
*
|
|
26
|
-
* @example
|
|
27
23
|
* // Sign typed data (EIP-712)
|
|
28
24
|
* const result = await client.signSignatureRequest({
|
|
29
25
|
* type: 'eth_signTypedData_v4',
|
|
@@ -34,6 +30,7 @@ import { vToYParity } from "ox/Signature";
|
|
|
34
30
|
* message: { ... }
|
|
35
31
|
* }
|
|
36
32
|
* });
|
|
33
|
+
* ```
|
|
37
34
|
*/
|
|
38
35
|
export async function signSignatureRequest(signer, params) {
|
|
39
36
|
switch (params.type) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signSignatureRequest.js","sourceRoot":"","sources":["../../../../src/client/actions/signSignatureRequest.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"signSignatureRequest.js","sourceRoot":"","sources":["../../../../src/client/actions/signSignatureRequest.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,WAAW,EAAE,kBAAkB,EAAE,MAAM,MAAM,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAKN,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAgB1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,MAA0B,EAC1B,MAAkC;IAElC,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC;QACpB,KAAK,eAAe,CAAC,CAAC,CAAC;YACrB,OAAO;gBACL,IAAI,EAAE,WAAW;gBACjB,IAAI,EAAE,MAAM,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC;aAC5C,CAAC;QACJ,CAAC;QACD,KAAK,sBAAsB,CAAC,CAAC,CAAC;YAC5B,OAAO;gBACL,IAAI,EAAE,WAAW;gBACjB,IAAI,EAAE,MAAM,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC;aAC9C,CAAC;QACJ,CAAC;QACD,KAAK,aAAa,CAAC,CAAC,CAAC;YACnB,IAAI,CAAC,MAAM,CAAC,iBAAiB,EAAE,CAAC;gBAC9B,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;YACjE,CAAC;YACD,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,OAAO,EAAE,GAAG,MAAM,MAAM,CAAC,iBAAiB,CAAC;gBAC1D,GAAG,MAAM,CAAC,IAAI;gBACd,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC;gBACzC,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC;aACtC,CAAC,CAAC;YAEH,OAAO;gBACL,IAAI,EAAE,WAAW;gBACjB,IAAI,EAAE,kBAAkB,CAAC;oBACvB,CAAC;oBACD,CAAC;oBACD,OAAO,EAAE,OAAO,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;iBAC1C,CAAC;aACH,CAAC;QACJ,CAAC;QACD;YACE,OAAO,WAAW,CAAC,MAAM,EAAE,oCAAoC,CAAC,CAAC;IACrE,CAAC;AACH,CAAC","sourcesContent":["import type { SmartAccountSigner } from \"@aa-sdk/core\";\nimport { type Hex, hexToNumber, serializeSignature } from \"viem\";\nimport { assertNever } from \"../../utils.js\";\nimport {\n type PersonalSignSignatureRequest,\n type TypedDataSignatureRequest,\n type AuthorizationSignatureRequest,\n type Eip7702UnsignedAuth,\n} from \"@alchemy/wallet-api-types\";\nimport { vToYParity } from \"ox/Signature\";\nimport type { WithoutRawPayload } from \"../../types.ts\";\n\nexport type SignSignatureRequestParams = WithoutRawPayload<\n | PersonalSignSignatureRequest\n | TypedDataSignatureRequest\n | (AuthorizationSignatureRequest & {\n data: Eip7702UnsignedAuth;\n })\n>;\n\nexport type SignSignatureRequestResult = {\n type: \"secp256k1\";\n data: Hex;\n};\n\n/**\n * Signs a signature request using the provided signer.\n * This method handles different types of signature requests including personal_sign, eth_signTypedData_v4, and authorization.\n *\n * @param {SmartAccountSigner} signer - The signer to use for signing the request\n * @param {SignSignatureRequestParams} params - The signature request parameters\n * @param {string} params.type - The type of signature request ('personal_sign', 'eth_signTypedData_v4', or 'signature_with_authorization')\n * @param {SignSignatureRequestParams[\"data\"]} params.data - The data to sign, format depends on the signature type\n * @returns {Promise<SignSignatureRequestResult>} A Promise that resolves to the signature result\n *\n * @example\n * ```ts\n * // Sign a personal message\n * const result = await client.signSignatureRequest({\n * type: 'personal_sign',\n * data: 'Hello, world!'\n * });\n *\n * // Sign typed data (EIP-712)\n * const result = await client.signSignatureRequest({\n * type: 'eth_signTypedData_v4',\n * data: {\n * domain: { ... },\n * types: { ... },\n * primaryType: '...',\n * message: { ... }\n * }\n * });\n * ```\n */\n\nexport async function signSignatureRequest(\n signer: SmartAccountSigner,\n params: SignSignatureRequestParams,\n): Promise<SignSignatureRequestResult> {\n switch (params.type) {\n case \"personal_sign\": {\n return {\n type: \"secp256k1\",\n data: await signer.signMessage(params.data),\n };\n }\n case \"eth_signTypedData_v4\": {\n return {\n type: \"secp256k1\",\n data: await signer.signTypedData(params.data),\n };\n }\n case \"eip7702Auth\": {\n if (!signer.signAuthorization) {\n throw new Error(\"Signer does not implement signAuthorization\");\n }\n const { r, s, v, yParity } = await signer.signAuthorization({\n ...params.data,\n chainId: hexToNumber(params.data.chainId),\n nonce: hexToNumber(params.data.nonce),\n });\n\n return {\n type: \"secp256k1\",\n data: serializeSignature({\n r,\n s,\n yParity: yParity ?? vToYParity(Number(v)),\n }),\n };\n }\n default:\n return assertNever(params, `Unexpected signature request type.`);\n }\n}\n"]}
|
|
@@ -15,6 +15,7 @@ export type SignTypedDataResult = Hex;
|
|
|
15
15
|
* @returns {Promise<SignTypedDataResult>} A Promise that resolves to the signature as a hex string
|
|
16
16
|
*
|
|
17
17
|
* @example
|
|
18
|
+
* ```ts
|
|
18
19
|
* // Sign typed data
|
|
19
20
|
* const signature = await client.signTypedData({
|
|
20
21
|
* domain: {
|
|
@@ -35,5 +36,6 @@ export type SignTypedDataResult = Hex;
|
|
|
35
36
|
* wallet: '0xAaAaAaAaAaAaAaAaAaAAAAAAAAaaaAaAaAaaAaAa'
|
|
36
37
|
* }
|
|
37
38
|
* });
|
|
39
|
+
* ```
|
|
38
40
|
*/
|
|
39
41
|
export declare function signTypedData(client: InnerWalletApiClient, signer: SmartAccountSigner, params: SignTypedDataParams): Promise<SignTypedDataResult>;
|
|
@@ -10,6 +10,7 @@ import { requestAccount } from "./requestAccount.js";
|
|
|
10
10
|
* @returns {Promise<SignTypedDataResult>} A Promise that resolves to the signature as a hex string
|
|
11
11
|
*
|
|
12
12
|
* @example
|
|
13
|
+
* ```ts
|
|
13
14
|
* // Sign typed data
|
|
14
15
|
* const signature = await client.signTypedData({
|
|
15
16
|
* domain: {
|
|
@@ -30,6 +31,7 @@ import { requestAccount } from "./requestAccount.js";
|
|
|
30
31
|
* wallet: '0xAaAaAaAaAaAaAaAaAaAAAAAAAAaaaAaAaAaaAaAa'
|
|
31
32
|
* }
|
|
32
33
|
* });
|
|
34
|
+
* ```
|
|
33
35
|
*/
|
|
34
36
|
export async function signTypedData(client, signer, params) {
|
|
35
37
|
const account = await requestAccount(client, signer, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signTypedData.js","sourceRoot":"","sources":["../../../../src/client/actions/signTypedData.ts"],"names":[],"mappings":"AACA,OAAO,EAAoD,MAAM,MAAM,CAAC;AAExE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAQrD
|
|
1
|
+
{"version":3,"file":"signTypedData.js","sourceRoot":"","sources":["../../../../src/client/actions/signTypedData.ts"],"names":[],"mappings":"AACA,OAAO,EAAoD,MAAM,MAAM,CAAC;AAExE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAQrD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,MAA4B,EAC5B,MAA0B,EAC1B,MAA2B;IAE3B,MAAM,OAAO,GAAG,MAAM,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE;QACnD,cAAc,EAAE,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,OAAO,EAAE,OAAO;KAC1D,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAC;AAC/C,CAAC","sourcesContent":["import type { SmartAccountSigner } from \"@aa-sdk/core\";\nimport { type Address, type Hex, type TypedDataDefinition } from \"viem\";\nimport type { InnerWalletApiClient } from \"../../types.ts\";\nimport { requestAccount } from \"./requestAccount.js\";\n\nexport type SignTypedDataParams = TypedDataDefinition & {\n account?: Address;\n};\n\nexport type SignTypedDataResult = Hex;\n\n/**\n * Signs typed data (EIP-712) using the smart account.\n * This method requests the account associated with the signer and uses it to sign the typed data.\n *\n * @param {InnerWalletApiClient} client - The wallet API client to use for the request\n * @param {SmartAccountSigner} signer - The signer of the smart account\n * @param {TypedDataDefinition} params - The typed data to sign, following EIP-712 format\n * @returns {Promise<SignTypedDataResult>} A Promise that resolves to the signature as a hex string\n *\n * @example\n * ```ts\n * // Sign typed data\n * const signature = await client.signTypedData({\n * domain: {\n * name: 'Example DApp',\n * version: '1',\n * chainId: 1,\n * verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC'\n * },\n * types: {\n * Person: [\n * { name: 'name', type: 'string' },\n * { name: 'wallet', type: 'address' }\n * ]\n * },\n * primaryType: 'Person',\n * message: {\n * name: 'John Doe',\n * wallet: '0xAaAaAaAaAaAaAaAaAaAAAAAAAAaaaAaAaAaaAaAa'\n * }\n * });\n * ```\n */\nexport async function signTypedData(\n client: InnerWalletApiClient,\n signer: SmartAccountSigner,\n params: SignTypedDataParams,\n): Promise<SignTypedDataResult> {\n const account = await requestAccount(client, signer, {\n accountAddress: params.account ?? client.account?.address,\n });\n\n return account.signTypedDataWith6492(params);\n}\n"]}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { SmartAccountSigner } from "@aa-sdk/core";
|
|
2
2
|
import type { Address, Hex } from "viem";
|
|
3
3
|
import type { InnerWalletApiClient } from "../types.ts";
|
|
4
|
-
import { type CreateAccountParams, type CreateAccountResult } from "./actions/createAccount.js";
|
|
5
4
|
import { type GetCallsStatusParams, type GetCallsStatusResult } from "./actions/getCallsStatus.js";
|
|
6
5
|
import { type GrantPermissionsParams, type GrantPermissionsResult } from "./actions/grantPermissions.js";
|
|
7
6
|
import { type ListAccountsParams, type ListAccountsResult } from "./actions/listAccounts.js";
|
|
@@ -16,7 +15,6 @@ export type SmartWalletActions<TAccount extends Address | undefined = Address |
|
|
|
16
15
|
requestAccount: (params?: RequestAccountParams) => Promise<RequestAccountResult>;
|
|
17
16
|
prepareCalls: (params: PrepareCallsParams<TAccount>) => Promise<PrepareCallsResult>;
|
|
18
17
|
sendPreparedCalls: (params: SendPreparedCallsParams) => Promise<SendPreparedCallsResult>;
|
|
19
|
-
createAccount: (params: CreateAccountParams) => Promise<CreateAccountResult>;
|
|
20
18
|
listAccounts: (params: ListAccountsParams) => Promise<ListAccountsResult>;
|
|
21
19
|
getCallsStatus: (params: GetCallsStatusParams) => Promise<GetCallsStatusResult>;
|
|
22
20
|
signSignatureRequest: (params: SignSignatureRequestParams) => Promise<SignSignatureRequestResult>;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { createAccount, } from "./actions/createAccount.js";
|
|
2
1
|
import { getCallsStatus, } from "./actions/getCallsStatus.js";
|
|
3
2
|
import { grantPermissions, } from "./actions/grantPermissions.js";
|
|
4
3
|
import { listAccounts, } from "./actions/listAccounts.js";
|
|
@@ -12,9 +11,8 @@ import { signPreparedCalls, } from "./actions/signPreparedCalls.js";
|
|
|
12
11
|
export function smartWalletClientActions(client, signer) {
|
|
13
12
|
return {
|
|
14
13
|
requestAccount: (params) => requestAccount(client, signer, params),
|
|
15
|
-
createAccount: (params) => createAccount(client, signer, params),
|
|
16
14
|
prepareCalls: (params) => prepareCalls(client, params),
|
|
17
|
-
listAccounts: (params) => listAccounts(client, params),
|
|
15
|
+
listAccounts: (params) => listAccounts(client, signer, params),
|
|
18
16
|
sendPreparedCalls: (params) => sendPreparedCalls(client, params),
|
|
19
17
|
getCallsStatus: (params) => getCallsStatus(client, params),
|
|
20
18
|
signSignatureRequest: (params) => signSignatureRequest(signer, params),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decorator.js","sourceRoot":"","sources":["../../../src/client/decorator.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"decorator.js","sourceRoot":"","sources":["../../../src/client/decorator.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,cAAc,GAGf,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,gBAAgB,GAGjB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,YAAY,GAGb,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,YAAY,GAGb,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,cAAc,GAGf,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,iBAAiB,GAGlB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,WAAW,EAA0B,MAAM,0BAA0B,CAAC;AAC/E,OAAO,EACL,oBAAoB,GAGrB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACL,aAAa,GAEd,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,iBAAiB,GAGlB,MAAM,gCAAgC,CAAC;AA+BxC,MAAM,UAAU,wBAAwB,CAGtC,MAA4B,EAC5B,MAA0B;IAE1B,OAAO;QACL,cAAc,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;QAClE,YAAY,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC;QACtD,YAAY,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;QAC9D,iBAAiB,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,iBAAiB,CAAC,MAAM,EAAE,MAAM,CAAC;QAChE,cAAc,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC;QAC1D,oBAAoB,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,oBAAoB,CAAC,MAAM,EAAE,MAAM,CAAC;QACtE,iBAAiB,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,iBAAiB,CAAC,MAAM,EAAE,MAAM,CAAC;QAChE,WAAW,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;QAC5D,aAAa,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;QAChE,gBAAgB,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;KACvE,CAAC;AACJ,CAAC","sourcesContent":["import type { SmartAccountSigner } from \"@aa-sdk/core\";\nimport type { Address, Hex } from \"viem\";\nimport type { InnerWalletApiClient } from \"../types.ts\";\nimport {\n getCallsStatus,\n type GetCallsStatusParams,\n type GetCallsStatusResult,\n} from \"./actions/getCallsStatus.js\";\nimport {\n grantPermissions,\n type GrantPermissionsParams,\n type GrantPermissionsResult,\n} from \"./actions/grantPermissions.js\";\nimport {\n listAccounts,\n type ListAccountsParams,\n type ListAccountsResult,\n} from \"./actions/listAccounts.js\";\nimport {\n prepareCalls,\n type PrepareCallsParams,\n type PrepareCallsResult,\n} from \"./actions/prepareCalls.js\";\nimport {\n requestAccount,\n type RequestAccountParams,\n type RequestAccountResult,\n} from \"./actions/requestAccount.js\";\nimport {\n sendPreparedCalls,\n type SendPreparedCallsParams,\n type SendPreparedCallsResult,\n} from \"./actions/sendPreparedCalls.js\";\nimport { signMessage, type SignMessageParams } from \"./actions/signMessage.js\";\nimport {\n signSignatureRequest,\n type SignSignatureRequestParams,\n type SignSignatureRequestResult,\n} from \"./actions/signSignatureRequest.js\";\nimport {\n signTypedData,\n type SignTypedDataParams,\n} from \"./actions/signTypedData.js\";\nimport {\n signPreparedCalls,\n type SignPreparedCallsParams,\n type SignPreparedCallsResult,\n} from \"./actions/signPreparedCalls.js\";\n\nexport type SmartWalletActions<\n TAccount extends Address | undefined = Address | undefined,\n> = {\n requestAccount: (\n params?: RequestAccountParams,\n ) => Promise<RequestAccountResult>;\n prepareCalls: (\n params: PrepareCallsParams<TAccount>,\n ) => Promise<PrepareCallsResult>;\n sendPreparedCalls: (\n params: SendPreparedCallsParams,\n ) => Promise<SendPreparedCallsResult>;\n listAccounts: (params: ListAccountsParams) => Promise<ListAccountsResult>;\n getCallsStatus: (\n params: GetCallsStatusParams,\n ) => Promise<GetCallsStatusResult>;\n signSignatureRequest: (\n params: SignSignatureRequestParams,\n ) => Promise<SignSignatureRequestResult>;\n signPreparedCalls: (\n params: SignPreparedCallsParams,\n ) => Promise<SignPreparedCallsResult>;\n signMessage: (params: SignMessageParams) => Promise<Hex>;\n signTypedData: (params: SignTypedDataParams) => Promise<Hex>;\n grantPermissions: (\n params: GrantPermissionsParams<TAccount>,\n ) => Promise<GrantPermissionsResult>;\n};\n\nexport function smartWalletClientActions<\n TAccount extends Address | undefined = Address | undefined,\n>(\n client: InnerWalletApiClient,\n signer: SmartAccountSigner,\n): SmartWalletActions<TAccount> {\n return {\n requestAccount: (params) => requestAccount(client, signer, params),\n prepareCalls: (params) => prepareCalls(client, params),\n listAccounts: (params) => listAccounts(client, signer, params),\n sendPreparedCalls: (params) => sendPreparedCalls(client, params),\n getCallsStatus: (params) => getCallsStatus(client, params),\n signSignatureRequest: (params) => signSignatureRequest(signer, params),\n signPreparedCalls: (params) => signPreparedCalls(signer, params),\n signMessage: (params) => signMessage(client, signer, params),\n signTypedData: (params) => signTypedData(client, signer, params),\n grantPermissions: (params) => grantPermissions(client, signer, params),\n };\n}\n"]}
|
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
import type { SmartAccountSigner } from "@aa-sdk/core";
|
|
2
2
|
import type { AlchemyTransport } from "@account-kit/infra";
|
|
3
|
-
import type
|
|
3
|
+
import { type Address, type Chain, type Prettify } from "viem";
|
|
4
4
|
import type { InnerWalletApiClient } from "../types.ts";
|
|
5
5
|
import { type SmartWalletActions } from "./decorator.js";
|
|
6
6
|
export type SmartWalletClientParams<TAccount extends Address | undefined = Address | undefined> = Prettify<{
|
|
7
7
|
transport: AlchemyTransport;
|
|
8
8
|
chain: Chain;
|
|
9
9
|
signer: SmartAccountSigner;
|
|
10
|
-
mode: "local" | "remote";
|
|
11
|
-
policyId?: string;
|
|
12
10
|
account?: TAccount | Address | undefined;
|
|
13
|
-
}
|
|
11
|
+
} & ({
|
|
12
|
+
policyId?: string;
|
|
13
|
+
policyIds?: never;
|
|
14
|
+
} | {
|
|
15
|
+
policyIds?: string[];
|
|
16
|
+
policyId?: never;
|
|
17
|
+
})>;
|
|
14
18
|
export type SmartWalletClient<TAccount extends Address | undefined = Address | undefined> = InnerWalletApiClient & SmartWalletActions<TAccount>;
|
|
15
19
|
/**
|
|
16
20
|
* Creates a smart wallet client that can be used to interact with a smart account.
|
|
@@ -19,12 +23,12 @@ export type SmartWalletClient<TAccount extends Address | undefined = Address | u
|
|
|
19
23
|
* @param {AlchemyTransport} params.transport - The Alchemy transport to use
|
|
20
24
|
* @param {Chain} params.chain - The chain to use
|
|
21
25
|
* @param {SmartAccountSigner} params.signer - The signer to use for the smart account
|
|
22
|
-
* @param {"local" | "remote"} params.mode - The client's mode (local or remote).
|
|
23
26
|
* @param {string} [params.policyId] - The policy ID for gas sponsorship (optional)
|
|
24
27
|
* @param {Address} [params.account] - The smart account address to use (optional)
|
|
25
28
|
* @returns {SmartWalletClient} - A viem-compatible client
|
|
26
29
|
*
|
|
27
30
|
* @example
|
|
31
|
+
* ```ts
|
|
28
32
|
* import { LocalAccountSigner } from "@aa-sdk/core";
|
|
29
33
|
* import { alchemy, arbitrumSepolia } from "@account-kit/infra";
|
|
30
34
|
* import { generatePrivateKey } from "viem/accounts";
|
|
@@ -37,8 +41,8 @@ export type SmartWalletClient<TAccount extends Address | undefined = Address | u
|
|
|
37
41
|
* const client = createSmartWalletClient({
|
|
38
42
|
* transport,
|
|
39
43
|
* chain: arbitrumSepolia,
|
|
40
|
-
* mode: "remote",
|
|
41
44
|
* signer,
|
|
42
45
|
* });
|
|
46
|
+
* ```
|
|
43
47
|
*/
|
|
44
48
|
export declare function createSmartWalletClient<TAccount extends Address | undefined = undefined>(params: SmartWalletClientParams<TAccount>): SmartWalletClient<TAccount>;
|
package/dist/esm/client/index.js
CHANGED
|
@@ -1,24 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { createRemoteClient } from "../remote/client.js";
|
|
1
|
+
import { createClient, custom, } from "viem";
|
|
3
2
|
import { smartWalletClientActions, } from "./decorator.js";
|
|
3
|
+
import { Provider } from "ox";
|
|
4
|
+
import { WalletServerRpcSchema } from "@alchemy/wallet-api-types/rpc";
|
|
5
|
+
import { internalStateDecorator } from "../internal/decorator.js";
|
|
4
6
|
export function createSmartWalletClient(params) {
|
|
5
|
-
const { transport, chain,
|
|
6
|
-
const
|
|
7
|
-
?
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
})
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
// TODO: we need to do a few things here:
|
|
20
|
-
// 1. decorate the client with the wallet api actions
|
|
21
|
-
// 2. potentially we might want to make this client async and have it use `requestAccount` so that it can create a SCA client with an account attached to it
|
|
7
|
+
const { transport, chain, account, signer } = params;
|
|
8
|
+
const policyIds = params.policyId
|
|
9
|
+
? [params.policyId]
|
|
10
|
+
: params.policyIds
|
|
11
|
+
? params.policyIds
|
|
12
|
+
: undefined;
|
|
13
|
+
const innerClient = createClient({
|
|
14
|
+
transport: (opts) => custom(Provider.from(transport(opts), { schema: WalletServerRpcSchema }))(opts),
|
|
15
|
+
chain,
|
|
16
|
+
account,
|
|
17
|
+
}).extend(() => ({
|
|
18
|
+
policyIds,
|
|
19
|
+
internal: internalStateDecorator(),
|
|
20
|
+
}));
|
|
22
21
|
return innerClient.extend((client) => smartWalletClientActions(client, signer));
|
|
23
22
|
}
|
|
24
23
|
// Example usage:
|
|
@@ -26,14 +25,12 @@ export function createSmartWalletClient(params) {
|
|
|
26
25
|
// transport: alchemy({ apiKey: "123" }),
|
|
27
26
|
// chain: baseSepolia,
|
|
28
27
|
// signer: createDummySigner(zeroAddress),
|
|
29
|
-
// mode: "local",
|
|
30
28
|
// });
|
|
31
29
|
// const account1 = await clientWithoutAccount.requestAccount();
|
|
32
30
|
// const clientWithAccount = createSmartWalletClient({
|
|
33
31
|
// transport: alchemy({ apiKey: "123" }),
|
|
34
32
|
// chain: baseSepolia,
|
|
35
33
|
// signer: createDummySigner(zeroAddress),
|
|
36
|
-
// mode: "local",
|
|
37
34
|
// account: zeroAddress,
|
|
38
35
|
// });
|
|
39
36
|
// const account2 = await clientWithAccount.requestAccount();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAIL,YAAY,EACZ,MAAM,GACP,MAAM,MAAM,CAAC;AAEd,OAAO,EACL,wBAAwB,GAEzB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AAC9B,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAqDlE,MAAM,UAAU,uBAAuB,CACrC,MAA+B;IAE/B,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;IAErD,MAAM,SAAS,GAAG,MAAM,CAAC,QAAQ;QAC/B,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC;QACnB,CAAC,CAAC,MAAM,CAAC,SAAS;YAChB,CAAC,CAAC,MAAM,CAAC,SAAS;YAClB,CAAC,CAAC,SAAS,CAAC;IAEhB,MAAM,WAAW,GAAG,YAAY,CAAC;QAC/B,SAAS,EAAE,CAAC,IAAI,EAAE,EAAE,CAClB,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,qBAAqB,EAAE,CAAC,CAAC,CACvE,IAAI,CACL;QACH,KAAK;QACL,OAAO;KACR,CAAC,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC;QACf,SAAS;QACT,QAAQ,EAAE,sBAAsB,EAAE;KACnC,CAAC,CAAC,CAAC;IAEJ,OAAO,WAAW,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CACnC,wBAAwB,CAAC,MAAM,EAAE,MAAM,CAAC,CACzC,CAAC;AACJ,CAAC;AAED,iBAAiB;AACjB,yDAAyD;AACzD,2CAA2C;AAC3C,wBAAwB;AACxB,4CAA4C;AAC5C,MAAM;AAEN,gEAAgE;AAEhE,sDAAsD;AACtD,2CAA2C;AAC3C,wBAAwB;AACxB,4CAA4C;AAC5C,0BAA0B;AAC1B,MAAM;AAEN,6DAA6D","sourcesContent":["import type { SmartAccountSigner } from \"@aa-sdk/core\";\nimport type { AlchemyTransport } from \"@account-kit/infra\";\nimport {\n type Address,\n type Chain,\n type Prettify,\n createClient,\n custom,\n} from \"viem\";\nimport type { InnerWalletApiClient } from \"../types.ts\";\nimport {\n smartWalletClientActions,\n type SmartWalletActions,\n} from \"./decorator.js\";\nimport { Provider } from \"ox\";\nimport { WalletServerRpcSchema } from \"@alchemy/wallet-api-types/rpc\";\nimport { internalStateDecorator } from \"../internal/decorator.js\";\n\nexport type SmartWalletClientParams<\n TAccount extends Address | undefined = Address | undefined,\n> = Prettify<\n {\n transport: AlchemyTransport;\n chain: Chain;\n signer: SmartAccountSigner;\n account?: TAccount | Address | undefined;\n } & (\n | { policyId?: string; policyIds?: never }\n | { policyIds?: string[]; policyId?: never }\n )\n>;\n\nexport type SmartWalletClient<\n TAccount extends Address | undefined = Address | undefined,\n> = InnerWalletApiClient & SmartWalletActions<TAccount>;\n\n/**\n * Creates a smart wallet client that can be used to interact with a smart account.\n *\n * @param {SmartWalletClientParams} params - The parameters for creating the smart wallet client\n * @param {AlchemyTransport} params.transport - The Alchemy transport to use\n * @param {Chain} params.chain - The chain to use\n * @param {SmartAccountSigner} params.signer - The signer to use for the smart account\n * @param {string} [params.policyId] - The policy ID for gas sponsorship (optional)\n * @param {Address} [params.account] - The smart account address to use (optional)\n * @returns {SmartWalletClient} - A viem-compatible client\n *\n * @example\n * ```ts\n * import { LocalAccountSigner } from \"@aa-sdk/core\";\n * import { alchemy, arbitrumSepolia } from \"@account-kit/infra\";\n * import { generatePrivateKey } from \"viem/accounts\";\n * import { createSmartWalletClient } from \"@account-kit/wallet-client\";\n *\n * const signer = LocalAccountSigner.privateKeyToAccountSigner(generatePrivateKey());\n * const transport = alchemy({\n * apiKey: \"your-alchemy-api-key\",\n * });\n * const client = createSmartWalletClient({\n * transport,\n * chain: arbitrumSepolia,\n * signer,\n * });\n * ```\n */\nexport function createSmartWalletClient<\n TAccount extends Address | undefined = undefined,\n>(params: SmartWalletClientParams<TAccount>): SmartWalletClient<TAccount>;\n\nexport function createSmartWalletClient(\n params: SmartWalletClientParams,\n): SmartWalletClient {\n const { transport, chain, account, signer } = params;\n\n const policyIds = params.policyId\n ? [params.policyId]\n : params.policyIds\n ? params.policyIds\n : undefined;\n\n const innerClient = createClient({\n transport: (opts) =>\n custom(Provider.from(transport(opts), { schema: WalletServerRpcSchema }))(\n opts,\n ),\n chain,\n account,\n }).extend(() => ({\n policyIds,\n internal: internalStateDecorator(),\n }));\n\n return innerClient.extend((client) =>\n smartWalletClientActions(client, signer),\n );\n}\n\n// Example usage:\n// const clientWithoutAccount = createSmartWalletClient({\n// transport: alchemy({ apiKey: \"123\" }),\n// chain: baseSepolia,\n// signer: createDummySigner(zeroAddress),\n// });\n\n// const account1 = await clientWithoutAccount.requestAccount();\n\n// const clientWithAccount = createSmartWalletClient({\n// transport: alchemy({ apiKey: \"123\" }),\n// chain: baseSepolia,\n// signer: createDummySigner(zeroAddress),\n// account: zeroAddress,\n// });\n\n// const account2 = await clientWithAccount.requestAccount();\n"]}
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
export { createSmartWalletClient, type SmartWalletClient, type SmartWalletClientParams, } from "../client/index.js";
|
|
2
|
-
export { WalletServerRpcSchema, type WalletServerRpcSchemaType,
|
|
3
|
-
export { Capabilities } from "../capabilities/index.js";
|
|
4
|
-
export { PaymasterCapability } from "../capabilities/paymaster.js";
|
|
5
|
-
export { PermissionsArray, PermissionsCapability, PermissionsContext, PermissionsData, } from "../capabilities/permissions/index.js";
|
|
6
|
-
export { createAccount } from "../client/actions/createAccount.js";
|
|
2
|
+
export { WalletServerRpcSchema, type WalletServerRpcSchemaType, } from "@alchemy/wallet-api-types/rpc";
|
|
7
3
|
export { getCallsStatus } from "../client/actions/getCallsStatus.js";
|
|
8
4
|
export { grantPermissions } from "../client/actions/grantPermissions.js";
|
|
9
5
|
export { listAccounts } from "../client/actions/listAccounts.js";
|