thirdweb 5.32.1-nightly-49ae575211f8484296d4aac16782e94ae89c437d-20240703000329 → 5.32.1
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/exports/wallets/smart.js +3 -1
- package/dist/cjs/exports/wallets/smart.js.map +1 -1
- package/dist/cjs/utils/extensions/drops/get-claim-params.js +3 -2
- package/dist/cjs/utils/extensions/drops/get-claim-params.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/web/ecosystem.js +3 -14
- package/dist/cjs/wallets/in-app/web/ecosystem.js.map +1 -1
- package/dist/cjs/wallets/smart/index.js +3 -17
- package/dist/cjs/wallets/smart/index.js.map +1 -1
- package/dist/cjs/wallets/smart/lib/bundler.js +1 -1
- package/dist/cjs/wallets/smart/lib/bundler.js.map +1 -1
- package/dist/cjs/wallets/smart/lib/userop.js +63 -8
- package/dist/cjs/wallets/smart/lib/userop.js.map +1 -1
- package/dist/esm/exports/wallets/smart.js +1 -0
- package/dist/esm/exports/wallets/smart.js.map +1 -1
- package/dist/esm/utils/extensions/drops/get-claim-params.js +3 -2
- package/dist/esm/utils/extensions/drops/get-claim-params.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/web/ecosystem.js +3 -14
- package/dist/esm/wallets/in-app/web/ecosystem.js.map +1 -1
- package/dist/esm/wallets/smart/index.js +4 -18
- package/dist/esm/wallets/smart/index.js.map +1 -1
- package/dist/esm/wallets/smart/lib/bundler.js +1 -1
- package/dist/esm/wallets/smart/lib/bundler.js.map +1 -1
- package/dist/esm/wallets/smart/lib/userop.js +63 -9
- package/dist/esm/wallets/smart/lib/userop.js.map +1 -1
- package/dist/types/exports/wallets/smart.d.ts +1 -0
- package/dist/types/exports/wallets/smart.d.ts.map +1 -1
- package/dist/types/utils/extensions/drops/get-claim-params.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/web/ecosystem.d.ts +3 -14
- package/dist/types/wallets/in-app/web/ecosystem.d.ts.map +1 -1
- package/dist/types/wallets/smart/index.d.ts.map +1 -1
- package/dist/types/wallets/smart/lib/bundler.d.ts +1 -2
- package/dist/types/wallets/smart/lib/bundler.d.ts.map +1 -1
- package/dist/types/wallets/smart/lib/userop.d.ts +53 -8
- package/dist/types/wallets/smart/lib/userop.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/exports/wallets/smart.ts +2 -0
- package/src/extensions/erc1155/drop1155.test.ts +7 -0
- package/src/extensions/erc20/drop20.test.ts +55 -0
- package/src/extensions/erc721/drop721.test.ts +28 -0
- package/src/utils/extensions/drops/get-claim-params.ts +4 -2
- package/src/version.ts +1 -1
- package/src/wallets/in-app/web/ecosystem.ts +3 -14
- package/src/wallets/smart/index.ts +7 -24
- package/src/wallets/smart/lib/bundler.ts +6 -5
- package/src/wallets/smart/lib/userop.ts +81 -11
@@ -2,6 +2,7 @@ import { concat } from "viem";
|
|
2
2
|
import { getDefaultGasOverrides } from "../../../gas/fee-data.js";
|
3
3
|
import { encode } from "../../../transaction/actions/encode.js";
|
4
4
|
import type { PreparedTransaction } from "../../../transaction/prepare-transaction.js";
|
5
|
+
import type { TransactionReceipt } from "../../../transaction/types.js";
|
5
6
|
import { encodeAbiParameters } from "../../../utils/abi/encodeAbiParameters.js";
|
6
7
|
import { isContractDeployed } from "../../../utils/bytecode/is-contract-deployed.js";
|
7
8
|
import type { Hex } from "../../../utils/encoding/hex.js";
|
@@ -9,8 +10,16 @@ import { hexToBytes } from "../../../utils/encoding/to-bytes.js";
|
|
9
10
|
import { isThirdwebUrl } from "../../../utils/fetch.js";
|
10
11
|
import { keccak256 } from "../../../utils/hashing/keccak256.js";
|
11
12
|
import { resolvePromisedValue } from "../../../utils/promise/resolve-promised-value.js";
|
12
|
-
import type {
|
13
|
-
|
13
|
+
import type {
|
14
|
+
BundlerOptions,
|
15
|
+
SmartAccountOptions,
|
16
|
+
UserOperation,
|
17
|
+
} from "../types.js";
|
18
|
+
import {
|
19
|
+
estimateUserOpGas,
|
20
|
+
getUserOpGasPrice,
|
21
|
+
getUserOpReceipt,
|
22
|
+
} from "./bundler.js";
|
14
23
|
import { prepareCreateAccount } from "./calls.js";
|
15
24
|
import {
|
16
25
|
DUMMY_SIGNATURE,
|
@@ -21,18 +30,64 @@ import { getPaymasterAndData } from "./paymaster.js";
|
|
21
30
|
import { randomNonce } from "./utils.js";
|
22
31
|
|
23
32
|
/**
|
24
|
-
*
|
25
|
-
* @
|
33
|
+
* Wait for the user operation to be mined.
|
34
|
+
* @param args - The options and user operation hash
|
35
|
+
* @returns - The transaction receipt
|
36
|
+
*
|
37
|
+
* @example
|
38
|
+
* ```ts
|
39
|
+
* import { waitForUserOpReceipt } from "thirdweb/wallets/smart";
|
40
|
+
*
|
41
|
+
* const receipt = await waitForUserOpReceipt({
|
42
|
+
* chain,
|
43
|
+
* client,
|
44
|
+
* userOpHash,
|
45
|
+
* });
|
46
|
+
* ```
|
47
|
+
* @walletUtils
|
26
48
|
*/
|
49
|
+
export async function waitForUserOpReceipt(
|
50
|
+
args: BundlerOptions & {
|
51
|
+
userOpHash: Hex;
|
52
|
+
timeoutMs?: number;
|
53
|
+
intervalMs?: number;
|
54
|
+
},
|
55
|
+
): Promise<TransactionReceipt> {
|
56
|
+
const timeout = args.timeoutMs || 120000; // 2mins
|
57
|
+
const interval = args.intervalMs || 1000; // 1s
|
58
|
+
const endtime = Date.now() + timeout;
|
59
|
+
while (Date.now() < endtime) {
|
60
|
+
const userOpReceipt = await getUserOpReceipt(args);
|
61
|
+
if (userOpReceipt) {
|
62
|
+
return userOpReceipt;
|
63
|
+
}
|
64
|
+
await new Promise((resolve) => setTimeout(resolve, interval));
|
65
|
+
}
|
66
|
+
throw new Error("Timeout waiting for userOp to be mined");
|
67
|
+
}
|
68
|
+
|
27
69
|
/**
|
28
|
-
* Creates an unsigned user operation.
|
29
|
-
* @
|
70
|
+
* Creates an unsigned user operation from a prepared transaction.
|
71
|
+
* @param args - The prepared transaction and options
|
72
|
+
* @returns - The unsigned user operation
|
73
|
+
* @example
|
74
|
+
* ```ts
|
75
|
+
* import { createUnsignedUserOp } from "thirdweb/wallets/smart";
|
76
|
+
*
|
77
|
+
* const transaction = prepareContractCall(...);
|
78
|
+
*
|
79
|
+
* const userOp = await createUnsignedUserOp({
|
80
|
+
* transaction,
|
81
|
+
* options,
|
82
|
+
* });
|
83
|
+
* ```
|
84
|
+
* @walletUtils
|
30
85
|
*/
|
31
86
|
export async function createUnsignedUserOp(args: {
|
32
|
-
|
87
|
+
transaction: PreparedTransaction;
|
33
88
|
options: SmartAccountOptions;
|
34
89
|
}): Promise<UserOperation> {
|
35
|
-
const { executeTx, options } = args;
|
90
|
+
const { transaction: executeTx, options } = args;
|
36
91
|
const isDeployed = await isContractDeployed(options.accountContract);
|
37
92
|
const initCode = isDeployed ? "0x" : await getAccountInitCode(options);
|
38
93
|
const callData = await encode(executeTx);
|
@@ -148,9 +203,21 @@ export async function createUnsignedUserOp(args: {
|
|
148
203
|
}
|
149
204
|
|
150
205
|
/**
|
151
|
-
* Sign
|
206
|
+
* Sign a user operation.
|
152
207
|
* @param userOp - The UserOperation to sign (with signature field ignored)
|
153
|
-
* @
|
208
|
+
* @returns - The user operation with the signature field populated
|
209
|
+
* @example
|
210
|
+
* ```ts
|
211
|
+
* import { signUserOp } from "thirdweb/wallets/smart";
|
212
|
+
*
|
213
|
+
* const userOp = createUnsignedUserOp(...);
|
214
|
+
*
|
215
|
+
* const signedUserOp = await signUserOp({
|
216
|
+
* userOp,
|
217
|
+
* options,
|
218
|
+
* });
|
219
|
+
* ```
|
220
|
+
* @walletUtils
|
154
221
|
*/
|
155
222
|
export async function signUserOp(args: {
|
156
223
|
userOp: UserOperation;
|
@@ -186,7 +253,10 @@ async function getAccountInitCode(options: SmartAccountOptions): Promise<Hex> {
|
|
186
253
|
}
|
187
254
|
|
188
255
|
/**
|
189
|
-
*
|
256
|
+
* Get the hash of a user operation.
|
257
|
+
* @param args - The user operation, entrypoint address, and chain ID
|
258
|
+
* @returns - The hash of the user operation
|
259
|
+
* @walletUtils
|
190
260
|
*/
|
191
261
|
function getUserOpHash(args: {
|
192
262
|
userOp: UserOperation;
|