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
@@ -7,21 +7,60 @@ import { hexToBytes } from "../../../utils/encoding/to-bytes.js";
|
|
7
7
|
import { isThirdwebUrl } from "../../../utils/fetch.js";
|
8
8
|
import { keccak256 } from "../../../utils/hashing/keccak256.js";
|
9
9
|
import { resolvePromisedValue } from "../../../utils/promise/resolve-promised-value.js";
|
10
|
-
import { estimateUserOpGas, getUserOpGasPrice } from "./bundler.js";
|
10
|
+
import { estimateUserOpGas, getUserOpGasPrice, getUserOpReceipt, } from "./bundler.js";
|
11
11
|
import { prepareCreateAccount } from "./calls.js";
|
12
12
|
import { DUMMY_SIGNATURE, ENTRYPOINT_ADDRESS_v0_6, getDefaultBundlerUrl, } from "./constants.js";
|
13
13
|
import { getPaymasterAndData } from "./paymaster.js";
|
14
14
|
import { randomNonce } from "./utils.js";
|
15
15
|
/**
|
16
|
-
*
|
17
|
-
* @
|
16
|
+
* Wait for the user operation to be mined.
|
17
|
+
* @param args - The options and user operation hash
|
18
|
+
* @returns - The transaction receipt
|
19
|
+
*
|
20
|
+
* @example
|
21
|
+
* ```ts
|
22
|
+
* import { waitForUserOpReceipt } from "thirdweb/wallets/smart";
|
23
|
+
*
|
24
|
+
* const receipt = await waitForUserOpReceipt({
|
25
|
+
* chain,
|
26
|
+
* client,
|
27
|
+
* userOpHash,
|
28
|
+
* });
|
29
|
+
* ```
|
30
|
+
* @walletUtils
|
18
31
|
*/
|
32
|
+
export async function waitForUserOpReceipt(args) {
|
33
|
+
const timeout = args.timeoutMs || 120000; // 2mins
|
34
|
+
const interval = args.intervalMs || 1000; // 1s
|
35
|
+
const endtime = Date.now() + timeout;
|
36
|
+
while (Date.now() < endtime) {
|
37
|
+
const userOpReceipt = await getUserOpReceipt(args);
|
38
|
+
if (userOpReceipt) {
|
39
|
+
return userOpReceipt;
|
40
|
+
}
|
41
|
+
await new Promise((resolve) => setTimeout(resolve, interval));
|
42
|
+
}
|
43
|
+
throw new Error("Timeout waiting for userOp to be mined");
|
44
|
+
}
|
19
45
|
/**
|
20
|
-
* Creates an unsigned user operation.
|
21
|
-
* @
|
46
|
+
* Creates an unsigned user operation from a prepared transaction.
|
47
|
+
* @param args - The prepared transaction and options
|
48
|
+
* @returns - The unsigned user operation
|
49
|
+
* @example
|
50
|
+
* ```ts
|
51
|
+
* import { createUnsignedUserOp } from "thirdweb/wallets/smart";
|
52
|
+
*
|
53
|
+
* const transaction = prepareContractCall(...);
|
54
|
+
*
|
55
|
+
* const userOp = await createUnsignedUserOp({
|
56
|
+
* transaction,
|
57
|
+
* options,
|
58
|
+
* });
|
59
|
+
* ```
|
60
|
+
* @walletUtils
|
22
61
|
*/
|
23
62
|
export async function createUnsignedUserOp(args) {
|
24
|
-
const { executeTx, options } = args;
|
63
|
+
const { transaction: executeTx, options } = args;
|
25
64
|
const isDeployed = await isContractDeployed(options.accountContract);
|
26
65
|
const initCode = isDeployed ? "0x" : await getAccountInitCode(options);
|
27
66
|
const callData = await encode(executeTx);
|
@@ -125,9 +164,21 @@ export async function createUnsignedUserOp(args) {
|
|
125
164
|
};
|
126
165
|
}
|
127
166
|
/**
|
128
|
-
* Sign
|
167
|
+
* Sign a user operation.
|
129
168
|
* @param userOp - The UserOperation to sign (with signature field ignored)
|
130
|
-
* @
|
169
|
+
* @returns - The user operation with the signature field populated
|
170
|
+
* @example
|
171
|
+
* ```ts
|
172
|
+
* import { signUserOp } from "thirdweb/wallets/smart";
|
173
|
+
*
|
174
|
+
* const userOp = createUnsignedUserOp(...);
|
175
|
+
*
|
176
|
+
* const signedUserOp = await signUserOp({
|
177
|
+
* userOp,
|
178
|
+
* options,
|
179
|
+
* });
|
180
|
+
* ```
|
181
|
+
* @walletUtils
|
131
182
|
*/
|
132
183
|
export async function signUserOp(args) {
|
133
184
|
const { userOp, options } = args;
|
@@ -158,7 +209,10 @@ async function getAccountInitCode(options) {
|
|
158
209
|
return concat([factoryContract.address, await encode(deployTx)]);
|
159
210
|
}
|
160
211
|
/**
|
161
|
-
*
|
212
|
+
* Get the hash of a user operation.
|
213
|
+
* @param args - The user operation, entrypoint address, and chain ID
|
214
|
+
* @returns - The hash of the user operation
|
215
|
+
* @walletUtils
|
162
216
|
*/
|
163
217
|
function getUserOpHash(args) {
|
164
218
|
const { userOp, entryPoint, chainId } = args;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"userop.js","sourceRoot":"","sources":["../../../../../src/wallets/smart/lib/userop.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAC9B,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,MAAM,EAAE,MAAM,wCAAwC,CAAC;
|
1
|
+
{"version":3,"file":"userop.js","sourceRoot":"","sources":["../../../../../src/wallets/smart/lib/userop.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAC9B,OAAO,EAAE,sBAAsB,EAAE,MA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E,SAAS,EAAE;QACnB,EAAE,IAAI,EAAE,SAAS,EAAE;QACnB,EAAE,IAAI,EAAE,SAAS,EAAE;QACnB,EAAE,IAAI,EAAE,SAAS,EAAE;QACnB,EAAE,IAAI,EAAE,SAAS,EAAE;QACnB,EAAE,IAAI,EAAE,SAAS,EAAE;QACnB,EAAE,IAAI,EAAE,SAAS,EAAE;QACnB,EAAE,IAAI,EAAE,SAAS,EAAE;QACnB,EAAE,IAAI,EAAE,SAAS,EAAE;KACpB,EACD;QACE,MAAM,CAAC,MAAM;QACb,MAAM,CAAC,KAAK;QACZ,cAAc;QACd,cAAc;QACd,MAAM,CAAC,YAAY;QACnB,MAAM,CAAC,oBAAoB;QAC3B,MAAM,CAAC,kBAAkB;QACzB,MAAM,CAAC,YAAY;QACnB,MAAM,CAAC,oBAAoB;QAC3B,sBAAsB;KACvB,CACF,CAAC;IACF,MAAM,OAAO,GAAG,mBAAmB,CACjC,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,EAC/D,CAAC,SAAS,CAAC,YAAY,CAAC,EAAE,UAAU,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC,CACvD,CAAC;IACF,OAAO,SAAS,CAAC,OAAO,CAAC,CAAC;AAC5B,CAAC"}
|
@@ -1,4 +1,5 @@
|
|
1
1
|
export { smartWallet } from "../../wallets/smart/smart-wallet.js";
|
2
|
+
export { waitForUserOpReceipt } from "../../wallets/smart/lib/userop.js";
|
2
3
|
export type { SmartWalletConnectionOptions, SmartWalletOptions, UserOperation, PaymasterResult, } from "../../wallets/smart/types.js";
|
3
4
|
export { ENTRYPOINT_ADDRESS_v0_6, DEFAULT_ACCOUNT_FACTORY, } from "../../wallets/smart/lib/constants.js";
|
4
5
|
//# sourceMappingURL=smart.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"smart.d.ts","sourceRoot":"","sources":["../../../../src/exports/wallets/smart.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,qCAAqC,CAAC;AAElE,YAAY,EACV,4BAA4B,EAC5B,kBAAkB,EAClB,aAAa,EACb,eAAe,GAChB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EACL,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,sCAAsC,CAAC"}
|
1
|
+
{"version":3,"file":"smart.d.ts","sourceRoot":"","sources":["../../../../src/exports/wallets/smart.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,qCAAqC,CAAC;AAElE,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AAEzE,YAAY,EACV,4BAA4B,EAC5B,kBAAkB,EAClB,aAAa,EACb,eAAe,GAChB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EACL,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,sCAAsC,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"get-claim-params.d.ts","sourceRoot":"","sources":["../../../../../src/utils/extensions/drops/get-claim-params.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,MAAM,MAAM,qBAAqB,GAAG;IAClC,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,GAAG,CACA;IACE,IAAI,EAAE,QAAQ,CAAC;CAChB,GACD;IACE,IAAI,EAAE,OAAO,CAAC;IACd,aAAa,EAAE,MAAM,CAAC;CACvB,GACD;IACE,IAAI,EAAE,SAAS,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB,CACJ,CAAC;AAEF,wBAAsB,cAAc,CAAC,OAAO,EAAE,qBAAqB;;;;;;;
|
1
|
+
{"version":3,"file":"get-claim-params.d.ts","sourceRoot":"","sources":["../../../../../src/utils/extensions/drops/get-claim-params.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,MAAM,MAAM,qBAAqB,GAAG;IAClC,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,GAAG,CACA;IACE,IAAI,EAAE,QAAQ,CAAC;CAChB,GACD;IACE,IAAI,EAAE,OAAO,CAAC;IACd,aAAa,EAAE,MAAM,CAAC;CACvB,GACD;IACE,IAAI,EAAE,SAAS,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB,CACJ,CAAC;AAEF,wBAAsB,cAAc,CAAC,OAAO,EAAE,qBAAqB;;;;;;;UAyFjD,GAAG;;;;GAOpB"}
|
package/dist/types/version.d.ts
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
export declare const version = "5.32.1
|
1
|
+
export declare const version = "5.32.1";
|
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,WAAW,CAAC"}
|
@@ -17,23 +17,12 @@ import type { CreateWalletArgs, EcosystemWalletId } from "../../wallet-types.js"
|
|
17
17
|
* });
|
18
18
|
* ```
|
19
19
|
*
|
20
|
-
*
|
20
|
+
* Connect to a restricted ecosystem wallet with your designated partner ID
|
21
|
+
* @note The parnter ID will be provided to you by the ecosystem with which you're integrating.
|
21
22
|
* ```ts
|
22
23
|
* import { ecosystemWallet } from "thirdweb/wallets";
|
23
24
|
* const wallet = ecosystemWallet("ecosystem.hooli", {
|
24
|
-
*
|
25
|
-
* chain: sepolia,
|
26
|
-
* sponsorGas: true,
|
27
|
-
* },
|
28
|
-
* });
|
29
|
-
* ```
|
30
|
-
*
|
31
|
-
* Connect to a restricted ecosystem wallet with your designated integrator ID
|
32
|
-
* @note The integrator ID will be provided to you by the ecosystem with which you're integrating.
|
33
|
-
* ```ts
|
34
|
-
* import { ecosystemWallet } from "thirdweb/wallets";
|
35
|
-
* const wallet = ecosystemWallet("ecosystem.hooli", {
|
36
|
-
* integratorId: "..."
|
25
|
+
* partnerId: "..."
|
37
26
|
* });
|
38
27
|
* ```
|
39
28
|
* @wallet
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ecosystem.d.ts","sourceRoot":"","sources":["../../../../../src/wallets/in-app/web/ecosystem.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,KAAK,EACV,gBAAgB,EAChB,iBAAiB,EAClB,MAAM,uBAAuB,CAAC;AAG/B
|
1
|
+
{"version":3,"file":"ecosystem.d.ts","sourceRoot":"","sources":["../../../../../src/wallets/in-app/web/ecosystem.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,KAAK,EACV,gBAAgB,EAChB,iBAAiB,EAClB,MAAM,uBAAuB,CAAC;AAG/B;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,eAAe,CAC7B,GAAG,IAAI,EAAE,gBAAgB,CAAC,iBAAiB,CAAC,GAC3C,MAAM,CAAC,iBAAiB,CAAC,CAgB3B"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/wallets/smart/index.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/wallets/smart/index.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAUnD,OAAO,KAAK,EACV,OAAO,EAEP,MAAM,EACP,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EACV,gBAAgB,EAChB,sBAAsB,EACtB,QAAQ,EACT,MAAM,oBAAoB,CAAC;AAwB5B;;;;;GAKG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,GACvB,MAAM,IAAI,MAAM,CAAC,OAAO,CAAC,CAE3B;AAED;;;GAGG;AACH,eAAO,MAAM,gCAAgC,mCAG1C,CAAC;AAIJ;;GAEG;AACH,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,EACvB,iBAAiB,EAAE,sBAAsB,CAAC,OAAO,CAAC,EAClD,eAAe,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAC5C,OAAO,CAAC,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAgE3B;AAED;;GAEG;AACH,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,GACtB,OAAO,CAAC,IAAI,CAAC,CAQf"}
|
@@ -25,9 +25,8 @@ export declare function getUserOpGasPrice(args: {
|
|
25
25
|
/**
|
26
26
|
* @internal
|
27
27
|
*/
|
28
|
-
export declare function getUserOpReceipt(args: {
|
28
|
+
export declare function getUserOpReceipt(args: BundlerOptions & {
|
29
29
|
userOpHash: Hex;
|
30
|
-
options: BundlerOptions;
|
31
30
|
}): Promise<TransactionReceipt | undefined>;
|
32
31
|
/**
|
33
32
|
* @internal
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"bundler.d.ts","sourceRoot":"","sources":["../../../../../src/wallets/smart/lib/bundler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,uBAAuB,EAAqB,MAAM,MAAM,CAAC;AAGvE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACxE,OAAO,EAAE,KAAK,GAAG,EAAe,MAAM,gCAAgC,CAAC;AAGvE,OAAO,KAAK,EACV,cAAc,EACd,gBAAgB,EAChB,cAAc,EACd,iBAAiB,EACjB,aAAa,EACd,MAAM,aAAa,CAAC;AASrB;;GAEG;AACH,wBAAsB,YAAY,CAAC,IAAI,EAAE;IACvC,MAAM,EAAE,aAAa,CAAC;IACtB,OAAO,EAAE,cAAc,CAAC;CACzB,GAAG,OAAO,CAAC,GAAG,CAAC,CASf;AAED;;GAEG;AACH,wBAAsB,iBAAiB,CAAC,IAAI,EAAE;IAC5C,MAAM,EAAE,aAAa,CAAC;IACtB,OAAO,EAAE,cAAc,CAAC;CACzB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAiB5B;AAED;;GAEG;AACH,wBAAsB,iBAAiB,CAAC,IAAI,EAAE;IAC5C,OAAO,EAAE,cAAc,CAAC;CACzB,GAAG,OAAO,CAAC,cAAc,CAAC,CAW1B;AAED;;GAEG;AACH,wBAAsB,gBAAgB,
|
1
|
+
{"version":3,"file":"bundler.d.ts","sourceRoot":"","sources":["../../../../../src/wallets/smart/lib/bundler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,uBAAuB,EAAqB,MAAM,MAAM,CAAC;AAGvE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACxE,OAAO,EAAE,KAAK,GAAG,EAAe,MAAM,gCAAgC,CAAC;AAGvE,OAAO,KAAK,EACV,cAAc,EACd,gBAAgB,EAChB,cAAc,EACd,iBAAiB,EACjB,aAAa,EACd,MAAM,aAAa,CAAC;AASrB;;GAEG;AACH,wBAAsB,YAAY,CAAC,IAAI,EAAE;IACvC,MAAM,EAAE,aAAa,CAAC;IACtB,OAAO,EAAE,cAAc,CAAC;CACzB,GAAG,OAAO,CAAC,GAAG,CAAC,CASf;AAED;;GAEG;AACH,wBAAsB,iBAAiB,CAAC,IAAI,EAAE;IAC5C,MAAM,EAAE,aAAa,CAAC;IACtB,OAAO,EAAE,cAAc,CAAC;CACzB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAiB5B;AAED;;GAEG;AACH,wBAAsB,iBAAiB,CAAC,IAAI,EAAE;IAC5C,OAAO,EAAE,cAAc,CAAC;CACzB,GAAG,OAAO,CAAC,cAAc,CAAC,CAW1B;AAED;;GAEG;AACH,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,cAAc,GAAG;IACrB,UAAU,EAAE,GAAG,CAAC;CACjB,GACA,OAAO,CAAC,kBAAkB,GAAG,SAAS,CAAC,CA6BzC;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CAAC,IAAI,EAAE;IAC7C,OAAO,EAAE,cAAc,CAAC;IACxB,WAAW,EAAE,uBAAuB,CAAC;CACtC,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAW7B;AAED,wBAAsB,sBAAsB,CAAC,IAAI,EAAE;IACjD,OAAO,EAAE,cAAc,CAAC;IACxB,WAAW,EAAE,uBAAuB,CAAC;IACrC,iBAAiB,EAAE,GAAG,CAAC;CACxB,GAAG,OAAO,CAAC;IAAE,eAAe,EAAE,GAAG,CAAA;CAAE,CAAC,CAepC"}
|
@@ -1,21 +1,66 @@
|
|
1
1
|
import type { PreparedTransaction } from "../../../transaction/prepare-transaction.js";
|
2
|
-
import type {
|
2
|
+
import type { TransactionReceipt } from "../../../transaction/types.js";
|
3
|
+
import type { Hex } from "../../../utils/encoding/hex.js";
|
4
|
+
import type { BundlerOptions, SmartAccountOptions, UserOperation } from "../types.js";
|
3
5
|
/**
|
4
|
-
*
|
5
|
-
* @
|
6
|
+
* Wait for the user operation to be mined.
|
7
|
+
* @param args - The options and user operation hash
|
8
|
+
* @returns - The transaction receipt
|
9
|
+
*
|
10
|
+
* @example
|
11
|
+
* ```ts
|
12
|
+
* import { waitForUserOpReceipt } from "thirdweb/wallets/smart";
|
13
|
+
*
|
14
|
+
* const receipt = await waitForUserOpReceipt({
|
15
|
+
* chain,
|
16
|
+
* client,
|
17
|
+
* userOpHash,
|
18
|
+
* });
|
19
|
+
* ```
|
20
|
+
* @walletUtils
|
6
21
|
*/
|
22
|
+
export declare function waitForUserOpReceipt(args: BundlerOptions & {
|
23
|
+
userOpHash: Hex;
|
24
|
+
timeoutMs?: number;
|
25
|
+
intervalMs?: number;
|
26
|
+
}): Promise<TransactionReceipt>;
|
7
27
|
/**
|
8
|
-
* Creates an unsigned user operation.
|
9
|
-
* @
|
28
|
+
* Creates an unsigned user operation from a prepared transaction.
|
29
|
+
* @param args - The prepared transaction and options
|
30
|
+
* @returns - The unsigned user operation
|
31
|
+
* @example
|
32
|
+
* ```ts
|
33
|
+
* import { createUnsignedUserOp } from "thirdweb/wallets/smart";
|
34
|
+
*
|
35
|
+
* const transaction = prepareContractCall(...);
|
36
|
+
*
|
37
|
+
* const userOp = await createUnsignedUserOp({
|
38
|
+
* transaction,
|
39
|
+
* options,
|
40
|
+
* });
|
41
|
+
* ```
|
42
|
+
* @walletUtils
|
10
43
|
*/
|
11
44
|
export declare function createUnsignedUserOp(args: {
|
12
|
-
|
45
|
+
transaction: PreparedTransaction;
|
13
46
|
options: SmartAccountOptions;
|
14
47
|
}): Promise<UserOperation>;
|
15
48
|
/**
|
16
|
-
* Sign
|
49
|
+
* Sign a user operation.
|
17
50
|
* @param userOp - The UserOperation to sign (with signature field ignored)
|
18
|
-
* @
|
51
|
+
* @returns - The user operation with the signature field populated
|
52
|
+
* @example
|
53
|
+
* ```ts
|
54
|
+
* import { signUserOp } from "thirdweb/wallets/smart";
|
55
|
+
*
|
56
|
+
* const userOp = createUnsignedUserOp(...);
|
57
|
+
*
|
58
|
+
* const signedUserOp = await signUserOp({
|
59
|
+
* userOp,
|
60
|
+
* options,
|
61
|
+
* });
|
62
|
+
* ```
|
63
|
+
* @walletUtils
|
19
64
|
*/
|
20
65
|
export declare function signUserOp(args: {
|
21
66
|
userOp: UserOperation;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"userop.d.ts","sourceRoot":"","sources":["../../../../../src/wallets/smart/lib/userop.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6CAA6C,CAAC;
|
1
|
+
{"version":3,"file":"userop.d.ts","sourceRoot":"","sources":["../../../../../src/wallets/smart/lib/userop.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6CAA6C,CAAC;AACvF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAGxE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,gCAAgC,CAAC;AAK1D,OAAO,KAAK,EACV,cAAc,EACd,mBAAmB,EACnB,aAAa,EACd,MAAM,aAAa,CAAC;AAerB;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,cAAc,GAAG;IACrB,UAAU,EAAE,GAAG,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,GACA,OAAO,CAAC,kBAAkB,CAAC,CAY7B;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,oBAAoB,CAAC,IAAI,EAAE;IAC/C,WAAW,EAAE,mBAAmB,CAAC;IACjC,OAAO,EAAE,mBAAmB,CAAC;CAC9B,GAAG,OAAO,CAAC,aAAa,CAAC,CAkHzB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,UAAU,CAAC,IAAI,EAAE;IACrC,MAAM,EAAE,aAAa,CAAC;IACtB,OAAO,EAAE,mBAAmB,CAAC;CAC9B,GAAG,OAAO,CAAC,aAAa,CAAC,CAmBzB"}
|
package/package.json
CHANGED
@@ -8,6 +8,8 @@ import {
|
|
8
8
|
} from "../../../test/src/test-wallets.js";
|
9
9
|
import { type ThirdwebContract, getContract } from "../../contract/contract.js";
|
10
10
|
import { sendAndConfirmTransaction } from "../../transaction/actions/send-and-confirm-transaction.js";
|
11
|
+
import { resolvePromisedValue } from "../../utils/promise/resolve-promised-value.js";
|
12
|
+
import { toEther } from "../../utils/units.js";
|
11
13
|
import { getContractMetadata } from "../common/read/getContractMetadata.js";
|
12
14
|
import { deployERC1155Contract } from "../prebuilts/deploy-erc1155.js";
|
13
15
|
import { balanceOf } from "./__generated__/IERC1155/read/balanceOf.js";
|
@@ -135,6 +137,11 @@ describe.runIf(process.env.TW_SECRET_KEY)(
|
|
135
137
|
tokenId: 0n,
|
136
138
|
quantity: 1n,
|
137
139
|
});
|
140
|
+
// assert value is set correctly
|
141
|
+
const value = await resolvePromisedValue(claimTx.value);
|
142
|
+
expect(value).toBeDefined();
|
143
|
+
if (!value) throw new Error("value is undefined");
|
144
|
+
expect(toEther(value)).toBe("0.001");
|
138
145
|
await sendAndConfirmTransaction({
|
139
146
|
transaction: claimTx,
|
140
147
|
account: TEST_ACCOUNT_A,
|
@@ -5,9 +5,12 @@ import { TEST_CLIENT } from "../../../test/src/test-clients.js";
|
|
5
5
|
import {
|
6
6
|
TEST_ACCOUNT_A,
|
7
7
|
TEST_ACCOUNT_B,
|
8
|
+
TEST_ACCOUNT_C,
|
8
9
|
} from "../../../test/src/test-wallets.js";
|
9
10
|
import { type ThirdwebContract, getContract } from "../../contract/contract.js";
|
10
11
|
import { sendAndConfirmTransaction } from "../../transaction/actions/send-and-confirm-transaction.js";
|
12
|
+
import { resolvePromisedValue } from "../../utils/promise/resolve-promised-value.js";
|
13
|
+
import { toEther } from "../../utils/units.js";
|
11
14
|
import { getContractMetadata } from "../common/read/getContractMetadata.js";
|
12
15
|
import { deployERC20Contract } from "../prebuilts/deploy-erc20.js";
|
13
16
|
import { claimTo } from "./drops/write/claimTo.js";
|
@@ -92,6 +95,58 @@ describe.runIf(process.env.TW_SECRET_KEY)(
|
|
92
95
|
`);
|
93
96
|
});
|
94
97
|
|
98
|
+
it("should allow to claim tokens with value", async () => {
|
99
|
+
await expect(
|
100
|
+
getBalance({ contract, address: TEST_ACCOUNT_C.address }),
|
101
|
+
).resolves.toMatchInlineSnapshot(`
|
102
|
+
{
|
103
|
+
"decimals": 18,
|
104
|
+
"displayValue": "0",
|
105
|
+
"name": "Test DropERC20",
|
106
|
+
"symbol": "",
|
107
|
+
"value": 0n,
|
108
|
+
}
|
109
|
+
`);
|
110
|
+
// set cc with price
|
111
|
+
await sendAndConfirmTransaction({
|
112
|
+
transaction: setClaimConditions({
|
113
|
+
contract,
|
114
|
+
phases: [
|
115
|
+
{
|
116
|
+
price: "0.01",
|
117
|
+
},
|
118
|
+
],
|
119
|
+
}),
|
120
|
+
account: TEST_ACCOUNT_A,
|
121
|
+
});
|
122
|
+
const claimTx = claimTo({
|
123
|
+
contract,
|
124
|
+
to: TEST_ACCOUNT_C.address,
|
125
|
+
quantity: "2",
|
126
|
+
});
|
127
|
+
// assert value is set correctly
|
128
|
+
const value = await resolvePromisedValue(claimTx.value);
|
129
|
+
expect(value).toBeDefined();
|
130
|
+
if (!value) throw new Error("value is undefined");
|
131
|
+
expect(toEther(value)).toBe("0.02");
|
132
|
+
// claim
|
133
|
+
await sendAndConfirmTransaction({
|
134
|
+
transaction: claimTx,
|
135
|
+
account: TEST_ACCOUNT_C,
|
136
|
+
});
|
137
|
+
await expect(
|
138
|
+
getBalance({ contract, address: TEST_ACCOUNT_C.address }),
|
139
|
+
).resolves.toMatchInlineSnapshot(`
|
140
|
+
{
|
141
|
+
"decimals": 18,
|
142
|
+
"displayValue": "2",
|
143
|
+
"name": "Test DropERC20",
|
144
|
+
"symbol": "",
|
145
|
+
"value": 2000000000000000000n,
|
146
|
+
}
|
147
|
+
`);
|
148
|
+
});
|
149
|
+
|
95
150
|
describe("Allowlists", () => {
|
96
151
|
it("should allow to claim tokens with an allowlist", async () => {
|
97
152
|
await sendAndConfirmTransaction({
|
@@ -5,9 +5,12 @@ import { TEST_CLIENT } from "../../../test/src/test-clients.js";
|
|
5
5
|
import {
|
6
6
|
TEST_ACCOUNT_A,
|
7
7
|
TEST_ACCOUNT_B,
|
8
|
+
TEST_ACCOUNT_C,
|
8
9
|
} from "../../../test/src/test-wallets.js";
|
9
10
|
import { type ThirdwebContract, getContract } from "../../contract/contract.js";
|
10
11
|
import { sendAndConfirmTransaction } from "../../transaction/actions/send-and-confirm-transaction.js";
|
12
|
+
import { resolvePromisedValue } from "../../utils/promise/resolve-promised-value.js";
|
13
|
+
import { toEther } from "../../utils/units.js";
|
11
14
|
import { getContractMetadata } from "../common/read/getContractMetadata.js";
|
12
15
|
import { deployERC721Contract } from "../prebuilts/deploy-erc721.js";
|
13
16
|
import { balanceOf } from "./__generated__/IERC721A/read/balanceOf.js";
|
@@ -110,6 +113,31 @@ describe.runIf(process.env.TW_SECRET_KEY)(
|
|
110
113
|
).resolves.toBe(1n);
|
111
114
|
});
|
112
115
|
|
116
|
+
it("should allow to claim tokens with value", async () => {
|
117
|
+
// set cc with price
|
118
|
+
await sendAndConfirmTransaction({
|
119
|
+
transaction: setClaimConditions({
|
120
|
+
contract,
|
121
|
+
phases: [
|
122
|
+
{
|
123
|
+
price: "0.01",
|
124
|
+
},
|
125
|
+
],
|
126
|
+
}),
|
127
|
+
account: TEST_ACCOUNT_A,
|
128
|
+
});
|
129
|
+
const claimTx = claimTo({
|
130
|
+
contract,
|
131
|
+
to: TEST_ACCOUNT_C.address,
|
132
|
+
quantity: 2n,
|
133
|
+
});
|
134
|
+
// assert value is set correctly
|
135
|
+
const value = await resolvePromisedValue(claimTx.value);
|
136
|
+
expect(value).toBeDefined();
|
137
|
+
if (!value) throw new Error("value is undefined");
|
138
|
+
expect(toEther(value)).toBe("0.02");
|
139
|
+
});
|
140
|
+
|
113
141
|
describe("Allowlists", () => {
|
114
142
|
it("should allow to claim tokens with an allowlist", async () => {
|
115
143
|
await sendAndConfirmTransaction({
|
@@ -59,6 +59,8 @@ export async function getClaimParams(options: GetClaimParamsOptions) {
|
|
59
59
|
});
|
60
60
|
})();
|
61
61
|
|
62
|
+
const tokenDecimals = options.type === "erc20" ? options.tokenDecimals : 0; // nfts have no decimals
|
63
|
+
|
62
64
|
// compute the allowListProof in an iife
|
63
65
|
const allowlistProof = await (async () => {
|
64
66
|
// early exit if no merkle root is set
|
@@ -79,7 +81,7 @@ export async function getClaimParams(options: GetClaimParamsOptions) {
|
|
79
81
|
contract: options.contract,
|
80
82
|
claimer: options.from || options.to, // receiver and claimer can be different, always prioritize the claimer for allowlists
|
81
83
|
merkleRoot: cc.merkleRoot,
|
82
|
-
tokenDecimals
|
84
|
+
tokenDecimals,
|
83
85
|
});
|
84
86
|
// if no proof is found, we'll try the empty proof
|
85
87
|
if (!allowListProof) {
|
@@ -116,7 +118,7 @@ export async function getClaimParams(options: GetClaimParamsOptions) {
|
|
116
118
|
data: "0x" as Hex,
|
117
119
|
overrides: {
|
118
120
|
value: isNativeTokenAddress(currency)
|
119
|
-
? pricePerToken *
|
121
|
+
? (pricePerToken * options.quantity) / BigInt(10 ** tokenDecimals)
|
120
122
|
: 0n,
|
121
123
|
},
|
122
124
|
};
|
package/src/version.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export const version = "5.32.1
|
1
|
+
export const version = "5.32.1";
|
@@ -23,23 +23,12 @@ import { createEcosystemWallet } from "../core/wallet/ecosystem-core.js";
|
|
23
23
|
* });
|
24
24
|
* ```
|
25
25
|
*
|
26
|
-
*
|
26
|
+
* Connect to a restricted ecosystem wallet with your designated partner ID
|
27
|
+
* @note The parnter ID will be provided to you by the ecosystem with which you're integrating.
|
27
28
|
* ```ts
|
28
29
|
* import { ecosystemWallet } from "thirdweb/wallets";
|
29
30
|
* const wallet = ecosystemWallet("ecosystem.hooli", {
|
30
|
-
*
|
31
|
-
* chain: sepolia,
|
32
|
-
* sponsorGas: true,
|
33
|
-
* },
|
34
|
-
* });
|
35
|
-
* ```
|
36
|
-
*
|
37
|
-
* Connect to a restricted ecosystem wallet with your designated integrator ID
|
38
|
-
* @note The integrator ID will be provided to you by the ecosystem with which you're integrating.
|
39
|
-
* ```ts
|
40
|
-
* import { ecosystemWallet } from "thirdweb/wallets";
|
41
|
-
* const wallet = ecosystemWallet("ecosystem.hooli", {
|
42
|
-
* integratorId: "..."
|
31
|
+
* partnerId: "..."
|
43
32
|
* });
|
44
33
|
* ```
|
45
34
|
* @wallet
|
@@ -14,8 +14,6 @@ import {
|
|
14
14
|
signEip712Transaction,
|
15
15
|
} from "../../transaction/actions/zksync/send-eip712-transaction.js";
|
16
16
|
import type { PreparedTransaction } from "../../transaction/prepare-transaction.js";
|
17
|
-
import type { TransactionReceipt } from "../../transaction/types.js";
|
18
|
-
import type { Hex } from "../../utils/encoding/hex.js";
|
19
17
|
import { parseTypedData } from "../../utils/signatures/helpers/parseTypedData.js";
|
20
18
|
import type {
|
21
19
|
Account,
|
@@ -30,7 +28,6 @@ import type {
|
|
30
28
|
import {
|
31
29
|
broadcastZkTransaction,
|
32
30
|
bundleUserOp,
|
33
|
-
getUserOpReceipt,
|
34
31
|
getZkPaymasterData,
|
35
32
|
} from "./lib/bundler.js";
|
36
33
|
import {
|
@@ -39,7 +36,11 @@ import {
|
|
39
36
|
prepareExecute,
|
40
37
|
} from "./lib/calls.js";
|
41
38
|
import { DEFAULT_ACCOUNT_FACTORY } from "./lib/constants.js";
|
42
|
-
import {
|
39
|
+
import {
|
40
|
+
createUnsignedUserOp,
|
41
|
+
signUserOp,
|
42
|
+
waitForUserOpReceipt,
|
43
|
+
} from "./lib/userop.js";
|
43
44
|
import { isNativeAAChain } from "./lib/utils.js";
|
44
45
|
import type {
|
45
46
|
SmartAccountOptions,
|
@@ -472,7 +473,7 @@ async function _sendUserOp(args: {
|
|
472
473
|
}): Promise<WaitForReceiptOptions> {
|
473
474
|
const { executeTx, options } = args;
|
474
475
|
const unsignedUserOp = await createUnsignedUserOp({
|
475
|
-
executeTx,
|
476
|
+
transaction: executeTx,
|
476
477
|
options,
|
477
478
|
});
|
478
479
|
const signedUserOp = await signUserOp({
|
@@ -485,7 +486,7 @@ async function _sendUserOp(args: {
|
|
485
486
|
});
|
486
487
|
// wait for tx receipt rather than return the userOp hash
|
487
488
|
const receipt = await waitForUserOpReceipt({
|
488
|
-
options,
|
489
|
+
...options,
|
489
490
|
userOpHash,
|
490
491
|
});
|
491
492
|
|
@@ -495,21 +496,3 @@ async function _sendUserOp(args: {
|
|
495
496
|
transactionHash: receipt.transactionHash,
|
496
497
|
};
|
497
498
|
}
|
498
|
-
|
499
|
-
async function waitForUserOpReceipt(args: {
|
500
|
-
options: SmartAccountOptions;
|
501
|
-
userOpHash: Hex;
|
502
|
-
}): Promise<TransactionReceipt> {
|
503
|
-
const { options, userOpHash } = args;
|
504
|
-
const timeout = 120000; // 2mins
|
505
|
-
const interval = 1000;
|
506
|
-
const endtime = Date.now() + timeout;
|
507
|
-
while (Date.now() < endtime) {
|
508
|
-
const userOpReceipt = await getUserOpReceipt({ options, userOpHash });
|
509
|
-
if (userOpReceipt) {
|
510
|
-
return userOpReceipt;
|
511
|
-
}
|
512
|
-
await new Promise((resolve) => setTimeout(resolve, interval));
|
513
|
-
}
|
514
|
-
throw new Error("Timeout waiting for userOp to be mined");
|
515
|
-
}
|
@@ -83,12 +83,13 @@ export async function getUserOpGasPrice(args: {
|
|
83
83
|
/**
|
84
84
|
* @internal
|
85
85
|
*/
|
86
|
-
export async function getUserOpReceipt(
|
87
|
-
|
88
|
-
|
89
|
-
}
|
86
|
+
export async function getUserOpReceipt(
|
87
|
+
args: BundlerOptions & {
|
88
|
+
userOpHash: Hex;
|
89
|
+
},
|
90
|
+
): Promise<TransactionReceipt | undefined> {
|
90
91
|
const res = await sendBundlerRequest({
|
91
|
-
|
92
|
+
options: args,
|
92
93
|
operation: "eth_getUserOperationReceipt",
|
93
94
|
params: [args.userOpHash],
|
94
95
|
});
|