thirdweb 5.105.3-nightly-6d1d344c48302d45aeb63532c84cc8e79c93e26f-20250628000422 → 5.105.3
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/cjs/engine/server-wallet.js +64 -19
- package/dist/cjs/engine/server-wallet.js.map +1 -1
- package/dist/cjs/engine/wait-for-tx-hash.js +1 -1
- package/dist/cjs/engine/wait-for-tx-hash.js.map +1 -1
- package/dist/cjs/exports/wallets/in-app.js +5 -1
- package/dist/cjs/exports/wallets/in-app.js.map +1 -1
- package/dist/cjs/exports/wallets/in-app.native.js +5 -1
- package/dist/cjs/exports/wallets/in-app.native.js.map +1 -1
- package/dist/cjs/extensions/erc7702/account/createSessionKey.js +127 -0
- package/dist/cjs/extensions/erc7702/account/createSessionKey.js.map +1 -0
- package/dist/cjs/extensions/erc7702/account/types.js +57 -0
- package/dist/cjs/extensions/erc7702/account/types.js.map +1 -0
- package/dist/cjs/react/web/ui/Bridge/payment-details/PaymentDetails.js +1 -1
- package/dist/cjs/react/web/ui/Bridge/payment-details/PaymentDetails.js.map +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/version.js.map +1 -1
- package/dist/cjs/wallets/in-app/core/authentication/backend.js +2 -1
- package/dist/cjs/wallets/in-app/core/authentication/backend.js.map +1 -1
- package/dist/cjs/wallets/in-app/core/eip7702/minimal-account.js +1 -1
- package/dist/esm/engine/server-wallet.js +65 -20
- package/dist/esm/engine/server-wallet.js.map +1 -1
- package/dist/esm/engine/wait-for-tx-hash.js +1 -1
- package/dist/esm/engine/wait-for-tx-hash.js.map +1 -1
- package/dist/esm/exports/wallets/in-app.js +2 -0
- package/dist/esm/exports/wallets/in-app.js.map +1 -1
- package/dist/esm/exports/wallets/in-app.native.js +2 -0
- package/dist/esm/exports/wallets/in-app.native.js.map +1 -1
- package/dist/esm/extensions/erc7702/account/createSessionKey.js +123 -0
- package/dist/esm/extensions/erc7702/account/createSessionKey.js.map +1 -0
- package/dist/esm/extensions/erc7702/account/types.js +54 -0
- package/dist/esm/extensions/erc7702/account/types.js.map +1 -0
- package/dist/esm/react/web/ui/Bridge/payment-details/PaymentDetails.js +1 -1
- package/dist/esm/react/web/ui/Bridge/payment-details/PaymentDetails.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/esm/wallets/in-app/core/authentication/backend.js +2 -1
- package/dist/esm/wallets/in-app/core/authentication/backend.js.map +1 -1
- package/dist/esm/wallets/in-app/core/eip7702/minimal-account.js +1 -1
- package/dist/types/engine/server-wallet.d.ts +5 -2
- package/dist/types/engine/server-wallet.d.ts.map +1 -1
- package/dist/types/exports/wallets/in-app.d.ts +2 -0
- package/dist/types/exports/wallets/in-app.d.ts.map +1 -1
- package/dist/types/exports/wallets/in-app.native.d.ts +2 -0
- package/dist/types/exports/wallets/in-app.native.d.ts.map +1 -1
- package/dist/types/extensions/erc7702/account/createSessionKey.d.ts +69 -0
- package/dist/types/extensions/erc7702/account/createSessionKey.d.ts.map +1 -0
- package/dist/types/extensions/erc7702/account/types.d.ts +107 -0
- package/dist/types/extensions/erc7702/account/types.d.ts.map +1 -0
- package/dist/types/react/web/ui/Bridge/payment-details/PaymentDetails.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/dist/types/version.d.ts.map +1 -1
- package/dist/types/wallets/in-app/core/authentication/backend.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/engine/server-wallet.test.ts +23 -28
- package/src/engine/server-wallet.ts +80 -26
- package/src/engine/wait-for-tx-hash.ts +1 -1
- package/src/exports/wallets/in-app.native.ts +10 -0
- package/src/exports/wallets/in-app.ts +10 -0
- package/src/extensions/erc7702/account/createSessionKey.ts +181 -0
- package/src/extensions/erc7702/account/sessionkey.test.ts +132 -0
- package/src/extensions/erc7702/account/types.ts +94 -0
- package/src/react/web/ui/Bridge/payment-details/PaymentDetails.tsx +3 -7
- package/src/version.ts +1 -1
- package/src/wallets/in-app/core/authentication/backend.ts +2 -1
- package/src/wallets/in-app/core/eip7702/minimal-account.ts +1 -1
- package/src/wallets/in-app/web/lib/in-app-gateway.test.ts +126 -0
@@ -0,0 +1,69 @@
|
|
1
|
+
import type { BaseTransactionOptions } from "../../../transaction/types.js";
|
2
|
+
import type { Account } from "../../../wallets/interfaces/wallet.js";
|
3
|
+
import { type CallSpecInput, type TransferSpecInput } from "./types.js";
|
4
|
+
/**
|
5
|
+
* @extension ERC7702
|
6
|
+
*/
|
7
|
+
export type CreateSessionKeyOptions = {
|
8
|
+
/**
|
9
|
+
* The admin account that will perform the operation.
|
10
|
+
*/
|
11
|
+
account: Account;
|
12
|
+
/**
|
13
|
+
* The address to add as a session key.
|
14
|
+
*/
|
15
|
+
sessionKeyAddress: string;
|
16
|
+
/**
|
17
|
+
* How long the session key should be valid for, in seconds.
|
18
|
+
*/
|
19
|
+
durationInSeconds: number;
|
20
|
+
/**
|
21
|
+
* Whether to grant full execution permissions to the session key.
|
22
|
+
*/
|
23
|
+
grantFullPermissions?: boolean;
|
24
|
+
/**
|
25
|
+
* Smart contract interaction policies to apply to the session key, ignored if grantFullPermissions is true.
|
26
|
+
*/
|
27
|
+
callPolicies?: CallSpecInput[];
|
28
|
+
/**
|
29
|
+
* Value transfer policies to apply to the session key, ignored if grantFullPermissions is true.
|
30
|
+
*/
|
31
|
+
transferPolicies?: TransferSpecInput[];
|
32
|
+
};
|
33
|
+
/**
|
34
|
+
* Creates session key permissions for a specified address.
|
35
|
+
* @param options - The options for the createSessionKey function.
|
36
|
+
* @param {Contract} options.contract - The EIP-7702 smart EOA contract to create the session key from
|
37
|
+
* @returns The transaction object to be sent.
|
38
|
+
* @example
|
39
|
+
* ```ts
|
40
|
+
* import { createSessionKey } from 'thirdweb/extensions/7702';
|
41
|
+
* import { sendTransaction } from 'thirdweb';
|
42
|
+
*
|
43
|
+
* const transaction = createSessionKey({
|
44
|
+
* account: account,
|
45
|
+
* contract: accountContract,
|
46
|
+
* sessionKeyAddress: TEST_ACCOUNT_A.address,
|
47
|
+
* durationInSeconds: 86400, // 1 day
|
48
|
+
* grantFullPermissions: true
|
49
|
+
*})
|
50
|
+
*
|
51
|
+
* await sendTransaction({ transaction, account });
|
52
|
+
* ```
|
53
|
+
* @extension ERC7702
|
54
|
+
*/
|
55
|
+
export declare function createSessionKey(options: BaseTransactionOptions<CreateSessionKeyOptions>): import("../../../transaction/prepare-transaction.js").PreparedTransaction<any, import("abitype").AbiFunction, import("../../../transaction/prepare-transaction.js").PrepareTransactionOptions>;
|
56
|
+
/**
|
57
|
+
* Checks if the `isCreateSessionKeySupported` method is supported by the given contract.
|
58
|
+
* @param availableSelectors An array of 4byte function selectors of the contract. You can get this in various ways, such as using "whatsabi" or if you have the ABI of the contract available you can use it to generate the selectors.
|
59
|
+
* @returns A boolean indicating if the `isAddSessionKeySupported` method is supported.
|
60
|
+
* @extension ERC7702
|
61
|
+
* @example
|
62
|
+
* ```ts
|
63
|
+
* import { isCreateSessionKeySupported } from "thirdweb/extensions/erc7702";
|
64
|
+
*
|
65
|
+
* const supported = isCreateSessionKeySupported(["0x..."]);
|
66
|
+
* ```
|
67
|
+
*/
|
68
|
+
export declare function isCreateSessionKeySupported(availableSelectors: string[]): boolean;
|
69
|
+
//# sourceMappingURL=createSessionKey.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"createSessionKey.d.ts","sourceRoot":"","sources":["../../../../../src/extensions/erc7702/account/createSessionKey.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAE5E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uCAAuC,CAAC;AAKrE,OAAO,EACL,KAAK,aAAa,EAIlB,KAAK,iBAAiB,EAGvB,MAAM,YAAY,CAAC;AAEpB;;GAEG;AACH,MAAM,MAAM,uBAAuB,GAAG;IACpC;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;IACjB;;OAEG;IACH,iBAAiB,EAAE,MAAM,CAAC;IAC1B;;OAEG;IACH,iBAAiB,EAAE,MAAM,CAAC;IAC1B;;OAEG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B;;OAEG;IACH,YAAY,CAAC,EAAE,aAAa,EAAE,CAAC;IAC/B;;OAEG;IACH,gBAAgB,CAAC,EAAE,iBAAiB,EAAE,CAAC;CACxC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,sBAAsB,CAAC,uBAAuB,CAAC,kMA8FzD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,2BAA2B,CAAC,kBAAkB,EAAE,MAAM,EAAE,WAEvE"}
|
@@ -0,0 +1,107 @@
|
|
1
|
+
export declare enum LimitType {
|
2
|
+
Unlimited = 0,
|
3
|
+
Lifetime = 1,
|
4
|
+
Allowance = 2
|
5
|
+
}
|
6
|
+
export declare enum Condition {
|
7
|
+
Unconstrained = 0,
|
8
|
+
Equal = 1,
|
9
|
+
Greater = 2,
|
10
|
+
Less = 3,
|
11
|
+
GreaterOrEqual = 4,
|
12
|
+
LessOrEqual = 5,
|
13
|
+
NotEqual = 6
|
14
|
+
}
|
15
|
+
interface UsageLimitInput {
|
16
|
+
limitType: LimitType;
|
17
|
+
limit: bigint;
|
18
|
+
period: bigint;
|
19
|
+
}
|
20
|
+
interface ConstraintInput {
|
21
|
+
condition: Condition;
|
22
|
+
index: bigint;
|
23
|
+
refValue: `0x${string}`;
|
24
|
+
limit?: UsageLimitInput;
|
25
|
+
}
|
26
|
+
export interface CallSpecInput {
|
27
|
+
target: `0x${string}`;
|
28
|
+
selector: `0x${string}`;
|
29
|
+
maxValuePerUse?: bigint;
|
30
|
+
valueLimit?: UsageLimitInput;
|
31
|
+
constraints?: ConstraintInput[];
|
32
|
+
}
|
33
|
+
export interface TransferSpecInput {
|
34
|
+
target: `0x${string}`;
|
35
|
+
maxValuePerUse?: bigint;
|
36
|
+
valueLimit?: UsageLimitInput;
|
37
|
+
}
|
38
|
+
export declare const UsageLimitRequest: readonly [{
|
39
|
+
readonly name: "limitType";
|
40
|
+
readonly type: "uint8";
|
41
|
+
}, {
|
42
|
+
readonly name: "limit";
|
43
|
+
readonly type: "uint256";
|
44
|
+
}, {
|
45
|
+
readonly name: "period";
|
46
|
+
readonly type: "uint256";
|
47
|
+
}];
|
48
|
+
export declare const ConstraintRequest: readonly [{
|
49
|
+
readonly name: "condition";
|
50
|
+
readonly type: "uint8";
|
51
|
+
}, {
|
52
|
+
readonly name: "index";
|
53
|
+
readonly type: "uint64";
|
54
|
+
}, {
|
55
|
+
readonly name: "refValue";
|
56
|
+
readonly type: "bytes32";
|
57
|
+
}, {
|
58
|
+
readonly name: "limit";
|
59
|
+
readonly type: "UsageLimit";
|
60
|
+
}];
|
61
|
+
export declare const CallSpecRequest: readonly [{
|
62
|
+
readonly name: "target";
|
63
|
+
readonly type: "address";
|
64
|
+
}, {
|
65
|
+
readonly name: "selector";
|
66
|
+
readonly type: "bytes4";
|
67
|
+
}, {
|
68
|
+
readonly name: "maxValuePerUse";
|
69
|
+
readonly type: "uint256";
|
70
|
+
}, {
|
71
|
+
readonly name: "valueLimit";
|
72
|
+
readonly type: "UsageLimit";
|
73
|
+
}, {
|
74
|
+
readonly name: "constraints";
|
75
|
+
readonly type: "Constraint[]";
|
76
|
+
}];
|
77
|
+
export declare const TransferSpecRequest: readonly [{
|
78
|
+
readonly name: "target";
|
79
|
+
readonly type: "address";
|
80
|
+
}, {
|
81
|
+
readonly name: "maxValuePerUse";
|
82
|
+
readonly type: "uint256";
|
83
|
+
}, {
|
84
|
+
readonly name: "valueLimit";
|
85
|
+
readonly type: "UsageLimit";
|
86
|
+
}];
|
87
|
+
export declare const SessionSpecRequest: readonly [{
|
88
|
+
readonly name: "signer";
|
89
|
+
readonly type: "address";
|
90
|
+
}, {
|
91
|
+
readonly name: "isWildcard";
|
92
|
+
readonly type: "bool";
|
93
|
+
}, {
|
94
|
+
readonly name: "expiresAt";
|
95
|
+
readonly type: "uint256";
|
96
|
+
}, {
|
97
|
+
readonly name: "callPolicies";
|
98
|
+
readonly type: "CallSpec[]";
|
99
|
+
}, {
|
100
|
+
readonly name: "transferPolicies";
|
101
|
+
readonly type: "TransferSpec[]";
|
102
|
+
}, {
|
103
|
+
readonly name: "uid";
|
104
|
+
readonly type: "bytes32";
|
105
|
+
}];
|
106
|
+
export {};
|
107
|
+
//# sourceMappingURL=types.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/extensions/erc7702/account/types.ts"],"names":[],"mappings":"AAIA,oBAAY,SAAS;IACnB,SAAS,IAAI;IACb,QAAQ,IAAI;IACZ,SAAS,IAAI;CACd;AAED,oBAAY,SAAS;IACnB,aAAa,IAAI;IACjB,KAAK,IAAI;IACT,OAAO,IAAI;IACX,IAAI,IAAI;IACR,cAAc,IAAI;IAClB,WAAW,IAAI;IACf,QAAQ,IAAI;CACb;AAOD,UAAU,eAAe;IACvB,SAAS,EAAE,SAAS,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAGD,UAAU,eAAe;IACvB,SAAS,EAAE,SAAS,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,KAAK,MAAM,EAAE,CAAC;IACxB,KAAK,CAAC,EAAE,eAAe,CAAC;CACzB;AAGD,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,KAAK,MAAM,EAAE,CAAC;IACtB,QAAQ,EAAE,KAAK,MAAM,EAAE,CAAC;IACxB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,UAAU,CAAC,EAAE,eAAe,CAAC;IAC7B,WAAW,CAAC,EAAE,eAAe,EAAE,CAAC;CACjC;AAGD,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,KAAK,MAAM,EAAE,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,UAAU,CAAC,EAAE,eAAe,CAAC;CAC9B;AAMD,eAAO,MAAM,iBAAiB;;;;;;;;;EAIpB,CAAC;AAEX,eAAO,MAAM,iBAAiB;;;;;;;;;;;;EAKpB,CAAC;AAEX,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;EAMlB,CAAC;AAEX,eAAO,MAAM,mBAAmB;;;;;;;;;EAItB,CAAC;AAEX,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;EAOrB,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"PaymentDetails.d.ts","sourceRoot":"","sources":["../../../../../../../src/react/web/ui/Bridge/payment-details/PaymentDetails.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAItE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4CAA4C,CAAC;AACtF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6CAA6C,CAAC;AASjF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAG1D,MAAM,WAAW,mBAAmB;IAClC;;OAEG;IACH,SAAS,EAAE,SAAS,CAAC;IACrB;;OAEG;IACH,MAAM,EAAE,cAAc,CAAC;IACvB;;OAEG;IACH,aAAa,EAAE,aAAa,CAAC;IAC7B;;OAEG;IACH,aAAa,EAAE,mBAAmB,CAAC;IAEnC;;OAEG;IACH,SAAS,EAAE,MAAM,IAAI,CAAC;IAEtB;;OAEG;IACH,MAAM,EAAE,MAAM,IAAI,CAAC;IAEnB;;OAEG;IACH,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CACjC;AAED,wBAAgB,cAAc,CAAC,EAC7B,SAAS,EACT,MAAM,EACN,aAAa,EACb,aAAa,EACb,SAAS,EACT,MAAM,EACN,OAAO,GACR,EAAE,mBAAmB,
|
1
|
+
{"version":3,"file":"PaymentDetails.d.ts","sourceRoot":"","sources":["../../../../../../../src/react/web/ui/Bridge/payment-details/PaymentDetails.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAItE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4CAA4C,CAAC;AACtF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6CAA6C,CAAC;AASjF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAG1D,MAAM,WAAW,mBAAmB;IAClC;;OAEG;IACH,SAAS,EAAE,SAAS,CAAC;IACrB;;OAEG;IACH,MAAM,EAAE,cAAc,CAAC;IACvB;;OAEG;IACH,aAAa,EAAE,aAAa,CAAC;IAC7B;;OAEG;IACH,aAAa,EAAE,mBAAmB,CAAC;IAEnC;;OAEG;IACH,SAAS,EAAE,MAAM,IAAI,CAAC;IAEtB;;OAEG;IACH,MAAM,EAAE,MAAM,IAAI,CAAC;IAEnB;;OAEG;IACH,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CACjC;AAED,wBAAgB,cAAc,CAAC,EAC7B,SAAS,EACT,MAAM,EACN,aAAa,EACb,aAAa,EACb,SAAS,EACT,MAAM,EACN,OAAO,GACR,EAAE,mBAAmB,2CA6UrB"}
|
package/dist/types/version.d.ts
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
export declare const version = "5.105.3
|
1
|
+
export declare const version = "5.105.3";
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,YAAY,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"backend.d.ts","sourceRoot":"","sources":["../../../../../../src/wallets/in-app/core/authentication/backend.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAGnE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD,OAAO,KAAK,EAAE,mCAAmC,EAAE,MAAM,YAAY,CAAC;AAEtE;;;GAGG;AACH,wBAAsB,mBAAmB,CAAC,IAAI,EAAE;IAC9C,MAAM,EAAE,cAAc,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB,GAAG,OAAO,CAAC,mCAAmC,CAAC,
|
1
|
+
{"version":3,"file":"backend.d.ts","sourceRoot":"","sources":["../../../../../../src/wallets/in-app/core/authentication/backend.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAGnE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD,OAAO,KAAK,EAAE,mCAAmC,EAAE,MAAM,YAAY,CAAC;AAEtE;;;GAGG;AACH,wBAAsB,mBAAmB,CAAC,IAAI,EAAE;IAC9C,MAAM,EAAE,cAAc,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB,GAAG,OAAO,CAAC,mCAAmC,CAAC,CAuB/C"}
|
package/package.json
CHANGED
@@ -38,7 +38,7 @@
|
|
38
38
|
"uqr": "0.1.2",
|
39
39
|
"viem": "2.28.1",
|
40
40
|
"zod": "3.25.67",
|
41
|
-
"@thirdweb-dev/engine": "3.
|
41
|
+
"@thirdweb-dev/engine": "3.2.0",
|
42
42
|
"@thirdweb-dev/insight": "1.1.0"
|
43
43
|
},
|
44
44
|
"devDependencies": {
|
@@ -375,7 +375,7 @@
|
|
375
375
|
}
|
376
376
|
},
|
377
377
|
"typings": "./dist/types/exports/thirdweb.d.ts",
|
378
|
-
"version": "5.105.3
|
378
|
+
"version": "5.105.3",
|
379
379
|
"scripts": {
|
380
380
|
"bench": "vitest -c ./test/vitest.config.ts bench",
|
381
381
|
"bench:compare": "bun run ./benchmarks/run.ts",
|
@@ -8,14 +8,11 @@ import { baseSepolia } from "../chains/chain-definitions/base-sepolia.js";
|
|
8
8
|
import { sepolia } from "../chains/chain-definitions/sepolia.js";
|
9
9
|
import { getContract } from "../contract/contract.js";
|
10
10
|
import { setContractURI } from "../extensions/common/__generated__/IContractMetadata/write/setContractURI.js";
|
11
|
-
import {
|
11
|
+
import { setApprovalForAll } from "../extensions/erc1155/__generated__/IERC1155/write/setApprovalForAll.js";
|
12
12
|
import { claimTo } from "../extensions/erc1155/drops/write/claimTo.js";
|
13
13
|
import { getAllActiveSigners } from "../extensions/erc4337/__generated__/IAccountPermissions/read/getAllActiveSigners.js";
|
14
14
|
import { sendTransaction } from "../transaction/actions/send-transaction.js";
|
15
|
-
import {
|
16
|
-
DEFAULT_ACCOUNT_FACTORY_V0_6,
|
17
|
-
ENTRYPOINT_ADDRESS_v0_6,
|
18
|
-
} from "../wallets/smart/lib/constants.js";
|
15
|
+
import { setThirdwebDomains } from "../utils/domains.js";
|
19
16
|
import { smartWallet } from "../wallets/smart/smart-wallet.js";
|
20
17
|
import { generateAccount } from "../wallets/utils/generateAccount.js";
|
21
18
|
import * as Engine from "./index.js";
|
@@ -34,15 +31,16 @@ describe.runIf(
|
|
34
31
|
let serverWallet: Engine.ServerWallet;
|
35
32
|
|
36
33
|
beforeAll(async () => {
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
34
|
+
setThirdwebDomains({
|
35
|
+
bundler: "bundler.thirdweb-dev.com",
|
36
|
+
engineCloud: "engine.thirdweb-dev.com",
|
37
|
+
// engineCloud: "localhost:3009",
|
38
|
+
rpc: "rpc.thirdweb-dev.com",
|
39
|
+
storage: "storage.thirdweb-dev.com",
|
40
|
+
});
|
43
41
|
serverWallet = Engine.serverWallet({
|
44
42
|
address: process.env.ENGINE_CLOUD_WALLET_ADDRESS as string,
|
45
|
-
chain:
|
43
|
+
chain: sepolia,
|
46
44
|
client: TEST_CLIENT,
|
47
45
|
vaultAccessToken: process.env.VAULT_TOKEN as string,
|
48
46
|
});
|
@@ -81,13 +79,9 @@ describe.runIf(
|
|
81
79
|
|
82
80
|
it("should sign typed data for EOA execution options", async () => {
|
83
81
|
const eoaServerWallet = Engine.serverWallet({
|
84
|
-
address: process.env.
|
82
|
+
address: process.env.ENGINE_CLOUD_WALLET_ADDRESS_EOA as string,
|
85
83
|
chain: arbitrumSepolia,
|
86
84
|
client: TEST_CLIENT,
|
87
|
-
executionOptions: {
|
88
|
-
address: process.env.ENGINE_CLOUD_WALLET_ADDRESS_EOA as string,
|
89
|
-
type: "eoa",
|
90
|
-
},
|
91
85
|
vaultAccessToken: process.env.VAULT_TOKEN as string,
|
92
86
|
});
|
93
87
|
|
@@ -157,14 +151,14 @@ describe.runIf(
|
|
157
151
|
|
158
152
|
it("should send a extension tx", async () => {
|
159
153
|
const tokenContract = getContract({
|
160
|
-
address: "
|
154
|
+
address: "0x638263e3eAa3917a53630e61B1fBa685308024fa",
|
161
155
|
chain: baseSepolia,
|
162
156
|
client: TEST_CLIENT,
|
163
157
|
});
|
164
|
-
const claimTx =
|
165
|
-
|
158
|
+
const claimTx = setApprovalForAll({
|
159
|
+
approved: true,
|
166
160
|
contract: tokenContract,
|
167
|
-
|
161
|
+
operator: "0x4b8ceC1Eb227950F0bfd034449B2781e689242A1",
|
168
162
|
});
|
169
163
|
const tx = await sendTransaction({
|
170
164
|
account: serverWallet,
|
@@ -175,19 +169,21 @@ describe.runIf(
|
|
175
169
|
|
176
170
|
it("should enqueue a batch of txs", async () => {
|
177
171
|
const tokenContract = getContract({
|
178
|
-
address: "
|
172
|
+
address: "0x638263e3eAa3917a53630e61B1fBa685308024fa",
|
179
173
|
chain: baseSepolia,
|
180
174
|
client: TEST_CLIENT,
|
181
175
|
});
|
182
|
-
const claimTx1 =
|
183
|
-
amount: "0.001",
|
176
|
+
const claimTx1 = claimTo({
|
184
177
|
contract: tokenContract,
|
178
|
+
quantity: 1n,
|
185
179
|
to: serverWallet.address,
|
180
|
+
tokenId: 2n,
|
186
181
|
});
|
187
|
-
const claimTx2 =
|
188
|
-
amount: "0.002",
|
182
|
+
const claimTx2 = claimTo({
|
189
183
|
contract: tokenContract,
|
184
|
+
quantity: 1n,
|
190
185
|
to: serverWallet.address,
|
186
|
+
tokenId: 2n,
|
191
187
|
});
|
192
188
|
const tx = await serverWallet.enqueueBatchTransaction({
|
193
189
|
transactions: [claimTx1, claimTx2],
|
@@ -257,8 +253,7 @@ describe.runIf(
|
|
257
253
|
chain: sepolia,
|
258
254
|
client: TEST_CLIENT,
|
259
255
|
executionOptions: {
|
260
|
-
|
261
|
-
factoryAddress: DEFAULT_ACCOUNT_FACTORY_V0_6,
|
256
|
+
entrypointVersion: "0.6",
|
262
257
|
signerAddress: sessionKeyAccountAddress,
|
263
258
|
smartAccountAddress: smartAccount.address,
|
264
259
|
type: "ERC4337",
|
@@ -1,7 +1,8 @@
|
|
1
1
|
import {
|
2
|
-
|
3
|
-
type
|
4
|
-
type
|
2
|
+
isSuccessResponse,
|
3
|
+
type SendTransactionData,
|
4
|
+
type SignMessageData,
|
5
|
+
type SpecificExecutionOptions,
|
5
6
|
sendTransaction,
|
6
7
|
signMessage,
|
7
8
|
signTypedData,
|
@@ -16,12 +17,15 @@ import { type Hex, toHex } from "../utils/encoding/hex.js";
|
|
16
17
|
import { getClientFetch } from "../utils/fetch.js";
|
17
18
|
import { stringify } from "../utils/json.js";
|
18
19
|
import { resolvePromisedValue } from "../utils/promise/resolve-promised-value.js";
|
20
|
+
import type { Prettify } from "../utils/type-utils.js";
|
19
21
|
import type {
|
20
22
|
Account,
|
21
23
|
SendTransactionOption,
|
22
24
|
} from "../wallets/interfaces/wallet.js";
|
23
25
|
import { waitForTransactionHash } from "./wait-for-tx-hash.js";
|
24
26
|
|
27
|
+
type ExecutionOptions = Prettify<SpecificExecutionOptions>;
|
28
|
+
|
25
29
|
/**
|
26
30
|
* Options for creating an server wallet.
|
27
31
|
*/
|
@@ -45,10 +49,7 @@ export type ServerWalletOptions = {
|
|
45
49
|
/**
|
46
50
|
* Optional custom execution options to use for sending transactions and signing data.
|
47
51
|
*/
|
48
|
-
executionOptions?:
|
49
|
-
| Omit<AaExecutionOptions, "chainId">
|
50
|
-
| Omit<AaZksyncExecutionOptions, "chainId">
|
51
|
-
| Omit<EoaExecutionOptions, "chainId">;
|
52
|
+
executionOptions?: ExecutionOptions;
|
52
53
|
};
|
53
54
|
|
54
55
|
export type ServerWallet = Account & {
|
@@ -150,20 +151,74 @@ export type ServerWallet = Account & {
|
|
150
151
|
export function serverWallet(options: ServerWalletOptions): ServerWallet {
|
151
152
|
const { client, vaultAccessToken, address, chain, executionOptions } =
|
152
153
|
options;
|
154
|
+
|
153
155
|
const headers: HeadersInit = {
|
154
156
|
"x-vault-access-token": vaultAccessToken,
|
155
157
|
};
|
156
158
|
|
157
|
-
const
|
158
|
-
|
159
|
-
|
159
|
+
const getExecutionOptionsWithChainId = (
|
160
|
+
chainId: number,
|
161
|
+
): SendTransactionData["body"]["executionOptions"] => {
|
162
|
+
if (!executionOptions) {
|
163
|
+
return {
|
164
|
+
chainId,
|
165
|
+
from: address,
|
166
|
+
type: "auto",
|
167
|
+
};
|
168
|
+
}
|
169
|
+
switch (executionOptions.type) {
|
170
|
+
case "auto":
|
171
|
+
return {
|
172
|
+
chainId,
|
173
|
+
from: address,
|
174
|
+
type: "auto",
|
175
|
+
};
|
176
|
+
case "ERC4337":
|
177
|
+
return {
|
178
|
+
...executionOptions,
|
179
|
+
chainId,
|
180
|
+
type: "ERC4337",
|
181
|
+
};
|
182
|
+
}
|
183
|
+
};
|
184
|
+
|
185
|
+
const getSigningOptions = (
|
186
|
+
chainId: number | undefined,
|
187
|
+
): SignMessageData["body"]["signingOptions"] => {
|
188
|
+
// if no chainId passed specifically for this signature
|
189
|
+
// we HAVE TO fallback to EOA signature
|
190
|
+
if (!chainId) {
|
191
|
+
return {
|
192
|
+
from: address,
|
193
|
+
type: "eoa",
|
194
|
+
};
|
195
|
+
}
|
196
|
+
|
197
|
+
if (!executionOptions) {
|
198
|
+
return {
|
199
|
+
chainId,
|
200
|
+
from: address,
|
201
|
+
type: "auto",
|
202
|
+
};
|
203
|
+
}
|
204
|
+
|
205
|
+
switch (executionOptions.type) {
|
206
|
+
case "ERC4337": {
|
207
|
+
return {
|
208
|
+
chainId,
|
160
209
|
...executionOptions,
|
161
|
-
|
162
|
-
}
|
163
|
-
|
164
|
-
|
210
|
+
type: "ERC4337",
|
211
|
+
};
|
212
|
+
}
|
213
|
+
|
214
|
+
case "auto": {
|
215
|
+
return {
|
216
|
+
chainId,
|
165
217
|
from: address,
|
218
|
+
type: "auto",
|
166
219
|
};
|
220
|
+
}
|
221
|
+
}
|
167
222
|
};
|
168
223
|
|
169
224
|
const enqueueTx = async (transaction: SendTransactionOption[]) => {
|
@@ -184,10 +239,10 @@ export function serverWallet(options: ServerWalletOptions): ServerWallet {
|
|
184
239
|
}
|
185
240
|
}
|
186
241
|
const body = {
|
187
|
-
executionOptions:
|
242
|
+
executionOptions: getExecutionOptionsWithChainId(chainId),
|
188
243
|
params: transaction.map((t) => ({
|
189
244
|
data: t.data,
|
190
|
-
to: t.to
|
245
|
+
to: t.to,
|
191
246
|
value: t.value?.toString(),
|
192
247
|
})),
|
193
248
|
};
|
@@ -307,17 +362,16 @@ export function serverWallet(options: ServerWalletOptions): ServerWallet {
|
|
307
362
|
if (!signingChainId) {
|
308
363
|
throw new Error("Chain ID is required for signing messages");
|
309
364
|
}
|
310
|
-
|
311
365
|
const signResult = await signMessage({
|
312
366
|
baseUrl: getThirdwebBaseUrl("engineCloud"),
|
313
367
|
body: {
|
314
|
-
executionOptions: getExecutionOptions(signingChainId),
|
315
368
|
params: [
|
316
369
|
{
|
370
|
+
format: isBytes ? "hex" : "text",
|
317
371
|
message: engineMessage,
|
318
|
-
messageFormat: isBytes ? "hex" : "text",
|
319
372
|
},
|
320
373
|
],
|
374
|
+
signingOptions: getSigningOptions(signingChainId),
|
321
375
|
},
|
322
376
|
bodySerializer: stringify,
|
323
377
|
fetch: getClientFetch(client),
|
@@ -330,13 +384,13 @@ export function serverWallet(options: ServerWalletOptions): ServerWallet {
|
|
330
384
|
);
|
331
385
|
}
|
332
386
|
|
333
|
-
const signatureResult = signResult.data?.result
|
334
|
-
if (signatureResult
|
387
|
+
const signatureResult = signResult.data?.result[0];
|
388
|
+
if (signatureResult && isSuccessResponse(signatureResult)) {
|
335
389
|
return signatureResult.result.signature as Hex;
|
336
390
|
}
|
337
391
|
|
338
392
|
throw new Error(
|
339
|
-
`Failed to sign message: ${signatureResult?.error
|
393
|
+
`Failed to sign message: ${stringify(signatureResult?.error) || "Unknown error"}`,
|
340
394
|
);
|
341
395
|
},
|
342
396
|
signTypedData: async (typedData) => {
|
@@ -348,9 +402,9 @@ export function serverWallet(options: ServerWalletOptions): ServerWallet {
|
|
348
402
|
const signResult = await signTypedData({
|
349
403
|
baseUrl: getThirdwebBaseUrl("engineCloud"),
|
350
404
|
body: {
|
351
|
-
executionOptions: getExecutionOptions(signingChainId),
|
352
405
|
// biome-ignore lint/suspicious/noExplicitAny: TODO: fix ts / hey-api type clash
|
353
406
|
params: [typedData as any],
|
407
|
+
signingOptions: getSigningOptions(signingChainId),
|
354
408
|
},
|
355
409
|
bodySerializer: stringify,
|
356
410
|
fetch: getClientFetch(client),
|
@@ -363,13 +417,13 @@ export function serverWallet(options: ServerWalletOptions): ServerWallet {
|
|
363
417
|
);
|
364
418
|
}
|
365
419
|
|
366
|
-
const signatureResult = signResult.data?.result
|
367
|
-
if (signatureResult
|
420
|
+
const signatureResult = signResult.data?.result[0];
|
421
|
+
if (signatureResult && isSuccessResponse(signatureResult)) {
|
368
422
|
return signatureResult.result.signature as Hex;
|
369
423
|
}
|
370
424
|
|
371
425
|
throw new Error(
|
372
|
-
`Failed to sign message: ${signatureResult?.error
|
426
|
+
`Failed to sign message: ${stringify(signatureResult?.error) || "Unknown error"}`,
|
373
427
|
);
|
374
428
|
},
|
375
429
|
};
|
@@ -38,7 +38,7 @@ export async function waitForTransactionHash(args: {
|
|
38
38
|
switch (status) {
|
39
39
|
case "FAILED": {
|
40
40
|
throw new Error(
|
41
|
-
`Transaction failed: ${executionResult.error || "Unknown error"}`,
|
41
|
+
`Transaction failed: ${stringify(executionResult.error) || "Unknown error"}`,
|
42
42
|
);
|
43
43
|
}
|
44
44
|
case "CONFIRMED": {
|
@@ -1,5 +1,15 @@
|
|
1
1
|
// --- KEEEP IN SYNC with exports/wallets/in-app.ts ---
|
2
2
|
|
3
|
+
//ACCOUNT
|
4
|
+
export {
|
5
|
+
type CreateSessionKeyOptions,
|
6
|
+
createSessionKey,
|
7
|
+
isCreateSessionKeySupported,
|
8
|
+
} from "../../extensions/erc7702/account/createSessionKey.js";
|
9
|
+
export type {
|
10
|
+
Condition,
|
11
|
+
LimitType,
|
12
|
+
} from "../../extensions/erc7702/account/types.js";
|
3
13
|
export type {
|
4
14
|
GetAuthenticatedUserParams,
|
5
15
|
MultiStepAuthArgsType,
|
@@ -1,5 +1,15 @@
|
|
1
1
|
// --- KEEEP IN SYNC with exports/wallets/in-app.native.ts ---
|
2
2
|
|
3
|
+
//ACCOUNT
|
4
|
+
export {
|
5
|
+
type CreateSessionKeyOptions,
|
6
|
+
createSessionKey,
|
7
|
+
isCreateSessionKeySupported,
|
8
|
+
} from "../../extensions/erc7702/account/createSessionKey.js";
|
9
|
+
export type {
|
10
|
+
Condition,
|
11
|
+
LimitType,
|
12
|
+
} from "../../extensions/erc7702/account/types.js";
|
3
13
|
export {
|
4
14
|
getSocialIcon,
|
5
15
|
socialIcons,
|