thirdweb 5.60.0 → 5.60.1-nightly-985c4b08048c3676dc9be0c2069fefc73a742a3a-20241003000322
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/contract/actions/compiler-metadata.js +3 -3
- package/dist/cjs/contract/actions/compiler-metadata.js.map +1 -1
- package/dist/cjs/contract/deployment/deploy-via-autofactory.js +1 -1
- package/dist/cjs/contract/deployment/deploy-via-autofactory.js.map +1 -1
- package/dist/cjs/contract/deployment/publisher.js +0 -2
- package/dist/cjs/contract/deployment/publisher.js.map +1 -1
- package/dist/cjs/contract/deployment/utils/bootstrap.js +8 -4
- package/dist/cjs/contract/deployment/utils/bootstrap.js.map +1 -1
- package/dist/cjs/extensions/erc1155/drops/write/claimTo.js +13 -0
- package/dist/cjs/extensions/erc1155/drops/write/claimTo.js.map +1 -1
- package/dist/cjs/extensions/erc20/drops/write/claimTo.js +13 -0
- package/dist/cjs/extensions/erc20/drops/write/claimTo.js.map +1 -1
- package/dist/cjs/extensions/erc721/drops/write/claimTo.js +13 -0
- package/dist/cjs/extensions/erc721/drops/write/claimTo.js.map +1 -1
- package/dist/cjs/extensions/prebuilts/deploy-published.js +14 -8
- package/dist/cjs/extensions/prebuilts/deploy-published.js.map +1 -1
- package/dist/cjs/extensions/prebuilts/get-required-transactions.js +4 -3
- package/dist/cjs/extensions/prebuilts/get-required-transactions.js.map +1 -1
- package/dist/cjs/utils/any-evm/compute-published-contract-deploy-info.js +6 -1
- package/dist/cjs/utils/any-evm/compute-published-contract-deploy-info.js.map +1 -1
- package/dist/cjs/utils/any-evm/deploy-metadata.js +29 -21
- package/dist/cjs/utils/any-evm/deploy-metadata.js.map +1 -1
- package/dist/cjs/utils/any-evm/zksync/isZkSyncChain.js +30 -3
- package/dist/cjs/utils/any-evm/zksync/isZkSyncChain.js.map +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/version.js.map +1 -1
- package/dist/cjs/wallets/coinbase/coinbaseWebSDK.js +10 -2
- package/dist/cjs/wallets/coinbase/coinbaseWebSDK.js.map +1 -1
- package/dist/cjs/wallets/in-app/native/ecosystem.js +1 -0
- package/dist/cjs/wallets/in-app/native/ecosystem.js.map +1 -1
- package/dist/cjs/wallets/in-app/web/ecosystem.js +1 -0
- package/dist/cjs/wallets/in-app/web/ecosystem.js.map +1 -1
- package/dist/cjs/wallets/smart/index.js +1 -1
- package/dist/cjs/wallets/smart/index.js.map +1 -1
- package/dist/cjs/wallets/smart/lib/bundler.js +1 -3
- package/dist/cjs/wallets/smart/lib/bundler.js.map +1 -1
- package/dist/cjs/wallets/smart/lib/constants.js +3 -3
- package/dist/cjs/wallets/smart/lib/constants.js.map +1 -1
- package/dist/cjs/wallets/smart/lib/paymaster.js +1 -3
- package/dist/cjs/wallets/smart/lib/paymaster.js.map +1 -1
- package/dist/cjs/wallets/smart/lib/userop.js +1 -3
- package/dist/cjs/wallets/smart/lib/userop.js.map +1 -1
- package/dist/esm/contract/actions/compiler-metadata.js +3 -3
- package/dist/esm/contract/actions/compiler-metadata.js.map +1 -1
- package/dist/esm/contract/deployment/deploy-via-autofactory.js +1 -1
- package/dist/esm/contract/deployment/deploy-via-autofactory.js.map +1 -1
- package/dist/esm/contract/deployment/publisher.js +0 -2
- package/dist/esm/contract/deployment/publisher.js.map +1 -1
- package/dist/esm/contract/deployment/utils/bootstrap.js +8 -4
- package/dist/esm/contract/deployment/utils/bootstrap.js.map +1 -1
- package/dist/esm/extensions/erc1155/drops/write/claimTo.js +13 -0
- package/dist/esm/extensions/erc1155/drops/write/claimTo.js.map +1 -1
- package/dist/esm/extensions/erc20/drops/write/claimTo.js +13 -0
- package/dist/esm/extensions/erc20/drops/write/claimTo.js.map +1 -1
- package/dist/esm/extensions/erc721/drops/write/claimTo.js +13 -0
- package/dist/esm/extensions/erc721/drops/write/claimTo.js.map +1 -1
- package/dist/esm/extensions/prebuilts/deploy-published.js +14 -8
- package/dist/esm/extensions/prebuilts/deploy-published.js.map +1 -1
- package/dist/esm/extensions/prebuilts/get-required-transactions.js +4 -3
- package/dist/esm/extensions/prebuilts/get-required-transactions.js.map +1 -1
- package/dist/esm/utils/any-evm/compute-published-contract-deploy-info.js +6 -1
- package/dist/esm/utils/any-evm/compute-published-contract-deploy-info.js.map +1 -1
- package/dist/esm/utils/any-evm/deploy-metadata.js +28 -21
- package/dist/esm/utils/any-evm/deploy-metadata.js.map +1 -1
- package/dist/esm/utils/any-evm/zksync/isZkSyncChain.js +30 -3
- package/dist/esm/utils/any-evm/zksync/isZkSyncChain.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/esm/wallets/coinbase/coinbaseWebSDK.js +11 -3
- package/dist/esm/wallets/coinbase/coinbaseWebSDK.js.map +1 -1
- package/dist/esm/wallets/in-app/native/ecosystem.js +1 -0
- package/dist/esm/wallets/in-app/native/ecosystem.js.map +1 -1
- package/dist/esm/wallets/in-app/web/ecosystem.js +1 -0
- package/dist/esm/wallets/in-app/web/ecosystem.js.map +1 -1
- package/dist/esm/wallets/smart/index.js +1 -1
- package/dist/esm/wallets/smart/index.js.map +1 -1
- package/dist/esm/wallets/smart/lib/bundler.js +2 -4
- package/dist/esm/wallets/smart/lib/bundler.js.map +1 -1
- package/dist/esm/wallets/smart/lib/constants.js +3 -3
- package/dist/esm/wallets/smart/lib/constants.js.map +1 -1
- package/dist/esm/wallets/smart/lib/paymaster.js +2 -4
- package/dist/esm/wallets/smart/lib/paymaster.js.map +1 -1
- package/dist/esm/wallets/smart/lib/userop.js +1 -3
- package/dist/esm/wallets/smart/lib/userop.js.map +1 -1
- package/dist/types/contract/actions/compiler-metadata.d.ts +1 -1
- package/dist/types/contract/actions/compiler-metadata.d.ts.map +1 -1
- package/dist/types/contract/deployment/publisher.d.ts +0 -2
- package/dist/types/contract/deployment/publisher.d.ts.map +1 -1
- package/dist/types/contract/deployment/utils/bootstrap.d.ts +1 -2
- package/dist/types/contract/deployment/utils/bootstrap.d.ts.map +1 -1
- package/dist/types/extensions/erc1155/drops/write/claimTo.d.ts +13 -0
- package/dist/types/extensions/erc1155/drops/write/claimTo.d.ts.map +1 -1
- package/dist/types/extensions/erc20/drops/write/claimTo.d.ts +13 -0
- package/dist/types/extensions/erc20/drops/write/claimTo.d.ts.map +1 -1
- package/dist/types/extensions/erc721/drops/write/claimTo.d.ts +13 -0
- package/dist/types/extensions/erc721/drops/write/claimTo.d.ts.map +1 -1
- package/dist/types/extensions/prebuilts/deploy-published.d.ts +0 -2
- package/dist/types/extensions/prebuilts/deploy-published.d.ts.map +1 -1
- package/dist/types/extensions/prebuilts/get-required-transactions.d.ts.map +1 -1
- package/dist/types/utils/any-evm/compute-published-contract-deploy-info.d.ts +1 -1
- package/dist/types/utils/any-evm/compute-published-contract-deploy-info.d.ts.map +1 -1
- package/dist/types/utils/any-evm/deploy-metadata.d.ts +9 -6
- package/dist/types/utils/any-evm/deploy-metadata.d.ts.map +1 -1
- package/dist/types/utils/any-evm/zksync/isZkSyncChain.d.ts +1 -1
- package/dist/types/utils/any-evm/zksync/isZkSyncChain.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/coinbase/coinbaseWebSDK.d.ts.map +1 -1
- package/dist/types/wallets/in-app/native/ecosystem.d.ts.map +1 -1
- package/dist/types/wallets/in-app/web/ecosystem.d.ts.map +1 -1
- package/dist/types/wallets/smart/lib/bundler.d.ts.map +1 -1
- package/dist/types/wallets/smart/lib/constants.d.ts +1 -1
- package/dist/types/wallets/smart/lib/constants.d.ts.map +1 -1
- package/dist/types/wallets/smart/lib/paymaster.d.ts.map +1 -1
- package/dist/types/wallets/smart/lib/userop.d.ts.map +1 -1
- package/package.json +16 -16
- package/src/contract/actions/compiler-metadata.ts +2 -3
- package/src/contract/deployment/deploy-via-autofactory.ts +1 -1
- package/src/contract/deployment/publisher.ts +0 -4
- package/src/contract/deployment/utils/bootstrap.ts +10 -6
- package/src/extensions/erc1155/drops/write/claimTo.ts +13 -0
- package/src/extensions/erc20/drops/write/claimTo.ts +13 -0
- package/src/extensions/erc721/drops/write/claimTo.ts +13 -0
- package/src/extensions/pack/createNewPack.test.ts +179 -170
- package/src/extensions/prebuilts/deploy-published.ts +15 -11
- package/src/extensions/prebuilts/get-required-transactions.ts +5 -3
- package/src/extensions/thirdweb/write/publish.test.ts +0 -1
- package/src/utils/any-evm/compute-published-contract-deploy-info.ts +9 -2
- package/src/utils/any-evm/deploy-metadata.ts +44 -33
- package/src/utils/any-evm/zksync/isZkSyncChain.ts +37 -2
- package/src/version.ts +1 -1
- package/src/wallets/coinbase/coinbaseWebSDK.ts +11 -2
- package/src/wallets/in-app/native/ecosystem.ts +1 -0
- package/src/wallets/in-app/web/ecosystem.ts +1 -0
- package/src/wallets/smart/index.ts +1 -1
- package/src/wallets/smart/lib/bundler.ts +1 -7
- package/src/wallets/smart/lib/constants.ts +3 -3
- package/src/wallets/smart/lib/paymaster.ts +1 -4
- package/src/wallets/smart/lib/userop.ts +1 -6
- package/src/wallets/smart/smart-wallet-zksync.test.ts +25 -1
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "thirdweb",
|
3
|
-
"version": "5.60.
|
3
|
+
"version": "5.60.1-nightly-985c4b08048c3676dc9be0c2069fefc73a742a3a-20241003000322",
|
4
4
|
"repository": {
|
5
5
|
"type": "git",
|
6
6
|
"url": "git+https://github.com/thirdweb-dev/js.git#main"
|
@@ -199,7 +199,7 @@
|
|
199
199
|
"!tsconfig.build.json"
|
200
200
|
],
|
201
201
|
"dependencies": {
|
202
|
-
"@coinbase/wallet-sdk": "4.0
|
202
|
+
"@coinbase/wallet-sdk": "4.1.0",
|
203
203
|
"@emotion/react": "11.13.3",
|
204
204
|
"@emotion/styled": "11.13.0",
|
205
205
|
"@google/model-viewer": "2.1.1",
|
@@ -211,14 +211,14 @@
|
|
211
211
|
"@radix-ui/react-icons": "1.3.0",
|
212
212
|
"@radix-ui/react-tooltip": "1.1.2",
|
213
213
|
"@tanstack/react-query": "5.56.2",
|
214
|
-
"@walletconnect/ethereum-provider": "2.16.
|
214
|
+
"@walletconnect/ethereum-provider": "2.16.3",
|
215
215
|
"@walletconnect/sign-client": "2.16.3",
|
216
216
|
"abitype": "1.0.5",
|
217
217
|
"fuse.js": "7.0.0",
|
218
218
|
"input-otp": "^1.2.4",
|
219
219
|
"mipd": "0.0.7",
|
220
220
|
"uqr": "0.1.2",
|
221
|
-
"viem": "2.21.
|
221
|
+
"viem": "2.21.16"
|
222
222
|
},
|
223
223
|
"peerDependencies": {
|
224
224
|
"@aws-sdk/client-lambda": "^3",
|
@@ -288,28 +288,28 @@
|
|
288
288
|
},
|
289
289
|
"devDependencies": {
|
290
290
|
"@aws-sdk/client-lambda": "3.659.0",
|
291
|
-
"@aws-sdk/credential-providers": "3.
|
291
|
+
"@aws-sdk/credential-providers": "3.658.1",
|
292
292
|
"@biomejs/biome": "1.9.2",
|
293
293
|
"@chromatic-com/storybook": "2.0.2",
|
294
294
|
"@codspeed/vitest-plugin": "3.1.1",
|
295
295
|
"@coinbase/wallet-mobile-sdk": "1.1.2",
|
296
296
|
"@mobile-wallet-protocol/client": "0.0.3",
|
297
297
|
"@react-native-async-storage/async-storage": "1.24.0",
|
298
|
-
"@size-limit/preset-big-lib": "11.1.
|
299
|
-
"@storybook/addon-essentials": "8.3.
|
298
|
+
"@size-limit/preset-big-lib": "11.1.6",
|
299
|
+
"@storybook/addon-essentials": "8.3.4",
|
300
300
|
"@storybook/addon-interactions": "8.3.4",
|
301
|
-
"@storybook/addon-links": "8.3.
|
302
|
-
"@storybook/addon-onboarding": "8.3.
|
301
|
+
"@storybook/addon-links": "8.3.4",
|
302
|
+
"@storybook/addon-onboarding": "8.3.4",
|
303
303
|
"@storybook/react": "8.3.4",
|
304
304
|
"@storybook/react-vite": "8.3.4",
|
305
|
-
"@storybook/test": "8.3.
|
305
|
+
"@storybook/test": "8.3.4",
|
306
306
|
"@testing-library/jest-dom": "^6.4.7",
|
307
307
|
"@testing-library/react": "^16.0.0",
|
308
308
|
"@testing-library/user-event": "^14.5.2",
|
309
309
|
"@types/cross-spawn": "^6.0.6",
|
310
|
-
"@types/react": "^18.3.
|
310
|
+
"@types/react": "^18.3.10",
|
311
311
|
"@viem/anvil": "0.0.10",
|
312
|
-
"@vitejs/plugin-react": "^4.3.
|
312
|
+
"@vitejs/plugin-react": "^4.3.2",
|
313
313
|
"@vitest/coverage-v8": "2.1.1",
|
314
314
|
"@vitest/ui": "2.1.1",
|
315
315
|
"cross-spawn": "7.0.3",
|
@@ -319,7 +319,7 @@
|
|
319
319
|
"expo-linking": "6.3.1",
|
320
320
|
"expo-web-browser": "13.0.3",
|
321
321
|
"happy-dom": "^15.7.4",
|
322
|
-
"knip": "^5.30.
|
322
|
+
"knip": "^5.30.6",
|
323
323
|
"msw": "^2.4.9",
|
324
324
|
"prettier": "^3.3.2",
|
325
325
|
"react": "18.3.1",
|
@@ -330,11 +330,11 @@
|
|
330
330
|
"react-native-svg": "15.7.1",
|
331
331
|
"rimraf": "6.0.1",
|
332
332
|
"sharp": "^0.33.5",
|
333
|
-
"size-limit": "11.1.
|
334
|
-
"storybook": "8.3.
|
333
|
+
"size-limit": "11.1.6",
|
334
|
+
"storybook": "8.3.4",
|
335
335
|
"typedoc": "0.26.7",
|
336
336
|
"typescript": "5.6.2",
|
337
|
-
"vite": "5.4.
|
337
|
+
"vite": "5.4.8",
|
338
338
|
"vitest": "2.1.1"
|
339
339
|
},
|
340
340
|
"scripts": {
|
@@ -30,11 +30,10 @@ export type CompilerMetadata = {
|
|
30
30
|
export function formatCompilerMetadata(
|
31
31
|
// biome-ignore lint/suspicious/noExplicitAny: TODO: fix later
|
32
32
|
metadata: any,
|
33
|
-
compilerType?: "solc" | "zksolc",
|
34
33
|
): CompilerMetadata {
|
35
34
|
let meta = metadata;
|
36
|
-
if (
|
37
|
-
meta = metadata.source_metadata
|
35
|
+
if ("source_metadata" in metadata) {
|
36
|
+
meta = metadata.source_metadata;
|
38
37
|
}
|
39
38
|
const compilationTarget = meta.settings.compilationTarget;
|
40
39
|
const targets = Object.keys(compilationTarget);
|
@@ -24,7 +24,6 @@ export async function fetchPublishedContractMetadata(options: {
|
|
24
24
|
contractId: string;
|
25
25
|
publisher?: string;
|
26
26
|
version?: string;
|
27
|
-
compilerType?: "solc" | "zksolc";
|
28
27
|
}): Promise<FetchDeployMetadataResult> {
|
29
28
|
const cacheKey = `${options.contractId}-${options.publisher}-${options.version}`;
|
30
29
|
return withCache(
|
@@ -34,7 +33,6 @@ export async function fetchPublishedContractMetadata(options: {
|
|
34
33
|
publisherAddress: options.publisher || THIRDWEB_DEPLOYER,
|
35
34
|
contractId: options.contractId,
|
36
35
|
version: options.version,
|
37
|
-
compilerType: options.compilerType,
|
38
36
|
});
|
39
37
|
if (!publishedContract.publishMetadataUri) {
|
40
38
|
throw new Error(
|
@@ -44,7 +42,6 @@ export async function fetchPublishedContractMetadata(options: {
|
|
44
42
|
const data = await fetchDeployMetadata({
|
45
43
|
client: options.client,
|
46
44
|
uri: publishedContract.publishMetadataUri,
|
47
|
-
compilerType: options.compilerType,
|
48
45
|
});
|
49
46
|
return data;
|
50
47
|
},
|
@@ -214,7 +211,6 @@ type FetchPublishedContractOptions = {
|
|
214
211
|
contractId: string;
|
215
212
|
version?: string;
|
216
213
|
client: ThirdwebClient;
|
217
|
-
compilerType?: "solc" | "zksolc";
|
218
214
|
};
|
219
215
|
|
220
216
|
/**
|
@@ -1,5 +1,8 @@
|
|
1
1
|
import { sendAndConfirmTransaction } from "../../../transaction/actions/send-and-confirm-transaction.js";
|
2
|
-
import
|
2
|
+
import {
|
3
|
+
type FetchDeployMetadataResult,
|
4
|
+
fetchBytecodeFromCompilerMetadata,
|
5
|
+
} from "../../../utils/any-evm/deploy-metadata.js";
|
3
6
|
import { isZkSyncChain } from "../../../utils/any-evm/zksync/isZkSyncChain.js";
|
4
7
|
import type { ClientAndChainAndAccount } from "../../../utils/types.js";
|
5
8
|
import { type ThirdwebContract, getContract } from "../../contract.js";
|
@@ -27,7 +30,6 @@ export async function getOrDeployInfraForPublishedContract(
|
|
27
30
|
constructorParams?: Record<string, unknown>;
|
28
31
|
publisher?: string;
|
29
32
|
version?: string;
|
30
|
-
compilerType?: "solc" | "zksolc";
|
31
33
|
},
|
32
34
|
): Promise<{
|
33
35
|
cloneFactoryContract: ThirdwebContract;
|
@@ -41,10 +43,9 @@ export async function getOrDeployInfraForPublishedContract(
|
|
41
43
|
constructorParams,
|
42
44
|
publisher,
|
43
45
|
version,
|
44
|
-
compilerType,
|
45
46
|
} = args;
|
46
47
|
|
47
|
-
if (isZkSyncChain(chain)) {
|
48
|
+
if (await isZkSyncChain(chain)) {
|
48
49
|
const cloneFactoryContract = await zkDeployCreate2Factory({
|
49
50
|
chain,
|
50
51
|
client,
|
@@ -55,14 +56,17 @@ export async function getOrDeployInfraForPublishedContract(
|
|
55
56
|
contractId,
|
56
57
|
publisher,
|
57
58
|
version,
|
58
|
-
compilerType,
|
59
59
|
});
|
60
60
|
const implementationContract = await zkDeployContractDeterministic({
|
61
61
|
chain,
|
62
62
|
client,
|
63
63
|
account,
|
64
64
|
abi: compilerMetadata.abi,
|
65
|
-
bytecode:
|
65
|
+
bytecode: await fetchBytecodeFromCompilerMetadata({
|
66
|
+
compilerMetadata,
|
67
|
+
client,
|
68
|
+
chain,
|
69
|
+
}),
|
66
70
|
params: constructorParams,
|
67
71
|
});
|
68
72
|
return {
|
@@ -19,6 +19,7 @@ export type ClaimToParams = {
|
|
19
19
|
* @param options - The options for the transaction
|
20
20
|
* @extension ERC1155
|
21
21
|
* @example
|
22
|
+
* ### Basic usage
|
22
23
|
* ```ts
|
23
24
|
* import { claimTo } from "thirdweb/extensions/erc1155";
|
24
25
|
* import { sendTransaction } from "thirdweb";
|
@@ -32,6 +33,18 @@ export type ClaimToParams = {
|
|
32
33
|
*
|
33
34
|
* await sendTransaction({ transaction, account });
|
34
35
|
* ```
|
36
|
+
*
|
37
|
+
* ### For Drops with allowlists
|
38
|
+
* You need to specify the claimer address as the `from` param to avoid any issue with the allowlist
|
39
|
+
* ```ts
|
40
|
+
* const transaction = claimTo({
|
41
|
+
* contract,
|
42
|
+
* to: "0x...",
|
43
|
+
* tokenId: 0n,
|
44
|
+
* quantity: 1n,
|
45
|
+
* from: "0x...", // address of the one claiming
|
46
|
+
* });
|
47
|
+
* ```
|
35
48
|
* @throws If no claim condition is set
|
36
49
|
* @returns The prepared transaction
|
37
50
|
*/
|
@@ -20,6 +20,8 @@ export type ClaimToParams = {
|
|
20
20
|
* @param options - The options for the transaction
|
21
21
|
* @extension ERC20
|
22
22
|
* @example
|
23
|
+
*
|
24
|
+
* ### Basic usage
|
23
25
|
* ```ts
|
24
26
|
* import { claimTo } from "thirdweb/extensions/erc20";
|
25
27
|
* import { sendTransaction } from "thirdweb";
|
@@ -32,6 +34,17 @@ export type ClaimToParams = {
|
|
32
34
|
*
|
33
35
|
* await sendTransaction({ transaction, account });
|
34
36
|
* ```
|
37
|
+
*
|
38
|
+
* ### For Drops with allowlists
|
39
|
+
* You need to specify the claimer address as the `from` param to avoid any issue with the allowlist
|
40
|
+
* ```ts
|
41
|
+
* const transaction = claimTo({
|
42
|
+
* contract,
|
43
|
+
* to: "0x...",
|
44
|
+
* quantity: 100n,
|
45
|
+
* from: "0x...", // address of the one claiming
|
46
|
+
* });
|
47
|
+
* ```
|
35
48
|
* @throws If no claim condition is set
|
36
49
|
* @returns A promise that resolves with the submitted transaction hash.
|
37
50
|
*/
|
@@ -23,6 +23,8 @@ export type ClaimToParams = {
|
|
23
23
|
* @param options - The options for the transaction
|
24
24
|
* @extension ERC721
|
25
25
|
* @example
|
26
|
+
*
|
27
|
+
* ### Basic usage
|
26
28
|
* ```ts
|
27
29
|
* import { claimTo } from "thirdweb/extensions/erc721";
|
28
30
|
* import { sendTransaction } from "thirdweb";
|
@@ -35,6 +37,17 @@ export type ClaimToParams = {
|
|
35
37
|
*
|
36
38
|
* await sendTransaction({ transaction, account });
|
37
39
|
* ```
|
40
|
+
*
|
41
|
+
* ### For Drops with allowlists
|
42
|
+
* You need to specify the claimer address as the `from` param to avoid any issue with the allowlist
|
43
|
+
* ```ts
|
44
|
+
* const transaction = claimTo({
|
45
|
+
* contract,
|
46
|
+
* to: "0x...",
|
47
|
+
* quantity: 1n,
|
48
|
+
* from: "0x...", // address of the one claiming
|
49
|
+
* });
|
50
|
+
* ```
|
38
51
|
* @throws If no claim condition is set
|
39
52
|
* @returns A promise that resolves with the submitted transaction hash.
|
40
53
|
*/
|
@@ -26,182 +26,191 @@ const account = TEST_ACCOUNT_A;
|
|
26
26
|
const client = TEST_CLIENT;
|
27
27
|
const chain = ANVIL_CHAIN;
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
address: packAddress,
|
42
|
-
chain,
|
43
|
-
client,
|
44
|
-
});
|
45
|
-
|
46
|
-
const erc20Address = await deployERC20Contract({
|
47
|
-
client: TEST_CLIENT,
|
48
|
-
chain: ANVIL_CHAIN,
|
49
|
-
account: TEST_ACCOUNT_A,
|
50
|
-
type: "TokenERC20",
|
51
|
-
params: {
|
52
|
-
name: "Token",
|
53
|
-
contractURI: TEST_CONTRACT_URI,
|
54
|
-
},
|
55
|
-
});
|
56
|
-
|
57
|
-
const erc20Contract = getContract({ address: erc20Address, chain, client });
|
58
|
-
|
59
|
-
const erc721Address = await deployERC721Contract({
|
60
|
-
client: TEST_CLIENT,
|
61
|
-
chain: ANVIL_CHAIN,
|
62
|
-
account: TEST_ACCOUNT_A,
|
63
|
-
type: "TokenERC721",
|
64
|
-
params: {
|
65
|
-
name: "NFTCollection",
|
66
|
-
contractURI: TEST_CONTRACT_URI,
|
67
|
-
},
|
68
|
-
});
|
69
|
-
|
70
|
-
const erc721Contract = getContract({
|
71
|
-
address: erc721Address,
|
72
|
-
chain,
|
73
|
-
client,
|
74
|
-
});
|
75
|
-
// Mint some ERC20 tokens
|
76
|
-
await sendAndConfirmTransaction({
|
77
|
-
transaction: mintToERC20({
|
78
|
-
contract: erc20Contract,
|
79
|
-
to: account.address,
|
80
|
-
amount: "100",
|
81
|
-
}),
|
82
|
-
account,
|
83
|
-
});
|
84
|
-
|
85
|
-
// Set allowance for Pack contract
|
86
|
-
await sendAndConfirmTransaction({
|
87
|
-
transaction: approve({
|
88
|
-
contract: erc20Contract,
|
89
|
-
amount: "1000000000000000",
|
90
|
-
spender: packContract.address,
|
91
|
-
}),
|
92
|
-
account,
|
93
|
-
});
|
29
|
+
// TODO Make this test works!
|
30
|
+
describe.skip("createNewPack", () => {
|
31
|
+
describe.runIf(process.env.TW_SECRET_KEY)("createPack", () => {
|
32
|
+
it("should create a Pack and open it to receive rewards", async () => {
|
33
|
+
const packAddress = await deployPackContract({
|
34
|
+
account,
|
35
|
+
client,
|
36
|
+
chain,
|
37
|
+
params: {
|
38
|
+
name: "pack-contract",
|
39
|
+
},
|
40
|
+
});
|
94
41
|
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
42
|
+
const packContract = getContract({
|
43
|
+
address: packAddress,
|
44
|
+
chain,
|
45
|
+
client,
|
46
|
+
});
|
47
|
+
|
48
|
+
const erc20Address = await deployERC20Contract({
|
49
|
+
client: TEST_CLIENT,
|
50
|
+
chain: ANVIL_CHAIN,
|
51
|
+
account: TEST_ACCOUNT_A,
|
52
|
+
type: "TokenERC20",
|
53
|
+
params: {
|
54
|
+
name: "Token",
|
55
|
+
contractURI: TEST_CONTRACT_URI,
|
56
|
+
},
|
57
|
+
});
|
104
58
|
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
59
|
+
const erc20Contract = getContract({
|
60
|
+
address: erc20Address,
|
61
|
+
chain,
|
62
|
+
client,
|
63
|
+
});
|
64
|
+
|
65
|
+
const erc721Address = await deployERC721Contract({
|
66
|
+
client: TEST_CLIENT,
|
67
|
+
chain: ANVIL_CHAIN,
|
68
|
+
account: TEST_ACCOUNT_A,
|
69
|
+
type: "TokenERC721",
|
70
|
+
params: {
|
71
|
+
name: "NFTCollection",
|
72
|
+
contractURI: TEST_CONTRACT_URI,
|
73
|
+
},
|
74
|
+
});
|
114
75
|
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
76
|
+
const erc721Contract = getContract({
|
77
|
+
address: erc721Address,
|
78
|
+
chain,
|
79
|
+
client,
|
80
|
+
});
|
81
|
+
// Mint some ERC20 tokens
|
82
|
+
await sendAndConfirmTransaction({
|
83
|
+
transaction: mintToERC20({
|
84
|
+
contract: erc20Contract,
|
85
|
+
to: account.address,
|
86
|
+
amount: "100",
|
87
|
+
}),
|
88
|
+
account,
|
89
|
+
});
|
90
|
+
|
91
|
+
// Set allowance for Pack contract
|
92
|
+
await sendAndConfirmTransaction({
|
93
|
+
transaction: approve({
|
94
|
+
contract: erc20Contract,
|
95
|
+
amount: "1000000000000000",
|
96
|
+
spender: packContract.address,
|
97
|
+
}),
|
98
|
+
account,
|
99
|
+
});
|
100
|
+
|
101
|
+
// Mint some ERC721 tokens
|
102
|
+
await sendAndConfirmTransaction({
|
103
|
+
transaction: mintToERC721({
|
104
|
+
contract: erc721Contract,
|
105
|
+
to: account.address,
|
106
|
+
nft: { name: "token #0" },
|
107
|
+
}),
|
108
|
+
account,
|
109
|
+
});
|
110
|
+
|
111
|
+
// set erc721 approval
|
112
|
+
await sendAndConfirmTransaction({
|
113
|
+
transaction: setApprovalForAll({
|
114
|
+
contract: erc721Contract,
|
115
|
+
approved: true,
|
116
|
+
operator: packContract.address,
|
117
|
+
}),
|
118
|
+
account,
|
119
|
+
});
|
120
|
+
|
121
|
+
// Create pack
|
122
|
+
await sendAndConfirmTransaction({
|
123
|
+
transaction: createNewPack({
|
124
|
+
contract: packContract,
|
125
|
+
erc20Rewards: [
|
126
|
+
{
|
127
|
+
contractAddress: erc20Contract.address,
|
128
|
+
totalRewards: 1,
|
129
|
+
quantityPerReward: 1,
|
130
|
+
},
|
131
|
+
],
|
132
|
+
erc721Rewards: [
|
133
|
+
{ contractAddress: erc721Contract.address, tokenId: 0n },
|
134
|
+
],
|
135
|
+
client,
|
136
|
+
packMetadata: {
|
137
|
+
name: "Pack #0",
|
138
|
+
},
|
139
|
+
recipient: account.address,
|
140
|
+
tokenOwner: account.address,
|
141
|
+
openStartTimestamp: new Date(),
|
142
|
+
amountDistributedPerOpen: 1n,
|
143
|
+
}),
|
144
|
+
account,
|
145
|
+
});
|
146
|
+
|
147
|
+
// Read the info of the new Pack
|
148
|
+
const [
|
149
|
+
packContent,
|
150
|
+
tokenCountOfBundle,
|
151
|
+
bundleUri,
|
152
|
+
erc20BalanceAfterCreatePack,
|
153
|
+
erc721BalanceAfterCreatePack,
|
154
|
+
] = await Promise.all([
|
155
|
+
getPackContents({ contract: packContract, packId: 0n }),
|
156
|
+
getTokenCountOfBundle({ contract: packContract, bundleId: 0n }),
|
157
|
+
getUriOfBundle({ contract: packContract, bundleId: 0n }),
|
158
|
+
balanceOfERC20({ contract: erc20Contract, address: account.address }),
|
159
|
+
balanceOfERC721({ contract: erc721Contract, owner: account.address }),
|
160
|
+
]);
|
161
|
+
|
162
|
+
// After this, the account should have 99 ERC20 tokens, and 0 (zero) ERC721 token
|
163
|
+
expect(erc20BalanceAfterCreatePack).toBe(99n * 10n ** 18n);
|
164
|
+
expect(erc721BalanceAfterCreatePack).toBe(0n);
|
165
|
+
|
166
|
+
// Make sure the content is correct
|
167
|
+
expect(packContent).toStrictEqual([
|
168
|
+
[
|
120
169
|
{
|
121
|
-
|
122
|
-
|
123
|
-
|
170
|
+
assetContract: erc20Contract.address,
|
171
|
+
tokenType: 0,
|
172
|
+
tokenId: 0n,
|
173
|
+
totalAmount: 1000000000000000000n,
|
174
|
+
},
|
175
|
+
{
|
176
|
+
assetContract: erc721Contract.address,
|
177
|
+
tokenType: 1,
|
178
|
+
tokenId: 0n,
|
179
|
+
totalAmount: 1n,
|
124
180
|
},
|
125
181
|
],
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
expect(erc721BalanceAfterCreatePack).toBe(0n);
|
159
|
-
|
160
|
-
// Make sure the content is correct
|
161
|
-
expect(packContent).toStrictEqual([
|
162
|
-
[
|
163
|
-
{
|
164
|
-
assetContract: erc20Contract.address,
|
165
|
-
tokenType: 0,
|
166
|
-
tokenId: 0n,
|
167
|
-
totalAmount: 1000000000000000000n,
|
168
|
-
},
|
169
|
-
{
|
170
|
-
assetContract: erc721Contract.address,
|
171
|
-
tokenType: 1,
|
172
|
-
tokenId: 0n,
|
173
|
-
totalAmount: 1n,
|
174
|
-
},
|
175
|
-
],
|
176
|
-
[1000000000000000000n, 1n],
|
177
|
-
]);
|
178
|
-
expect(tokenCountOfBundle).toBe(2n);
|
179
|
-
|
180
|
-
// Make sure the Pack metadata is correct
|
181
|
-
expect(bundleUri).toBeDefined();
|
182
|
-
const metadata = await (await download({ client, uri: bundleUri })).json();
|
183
|
-
expect(metadata?.name).toBe("Pack #0");
|
184
|
-
|
185
|
-
// Make sure you can open the Pack, since the open-date was set to "now"
|
186
|
-
await sendAndConfirmTransaction({
|
187
|
-
account,
|
188
|
-
transaction: openPack({
|
189
|
-
contract: packContract,
|
190
|
-
packId: 0n,
|
191
|
-
amountToOpen: 1n,
|
192
|
-
}),
|
182
|
+
[1000000000000000000n, 1n],
|
183
|
+
]);
|
184
|
+
expect(tokenCountOfBundle).toBe(2n);
|
185
|
+
|
186
|
+
// Make sure the Pack metadata is correct
|
187
|
+
expect(bundleUri).toBeDefined();
|
188
|
+
const metadata = await (
|
189
|
+
await download({ client, uri: bundleUri })
|
190
|
+
).json();
|
191
|
+
expect(metadata?.name).toBe("Pack #0");
|
192
|
+
|
193
|
+
// Make sure you can open the Pack, since the open-date was set to "now"
|
194
|
+
await sendAndConfirmTransaction({
|
195
|
+
account,
|
196
|
+
transaction: openPack({
|
197
|
+
contract: packContract,
|
198
|
+
packId: 0n,
|
199
|
+
amountToOpen: 1n,
|
200
|
+
}),
|
201
|
+
});
|
202
|
+
|
203
|
+
const [erc20Balance, erc721Owner] = await Promise.all([
|
204
|
+
balanceOfERC20({ contract: erc20Contract, address: account.address }),
|
205
|
+
ownerOf({ contract: erc721Contract, tokenId: 0n }),
|
206
|
+
]);
|
207
|
+
|
208
|
+
// Since opening a Pack gives "random" rewards, in this case we can check if
|
209
|
+
// the recipient received either 1. <one ERC20 token>, or 2. <one ERC721 token>
|
210
|
+
expect(
|
211
|
+
erc20Balance === 100n * 10n ** 18n ||
|
212
|
+
erc721Owner.toLowerCase() === account.address.toLowerCase(),
|
213
|
+
).toBe(true);
|
193
214
|
});
|
194
|
-
|
195
|
-
const [erc20Balance, erc721Owner] = await Promise.all([
|
196
|
-
balanceOfERC20({ contract: erc20Contract, address: account.address }),
|
197
|
-
ownerOf({ contract: erc721Contract, tokenId: 0n }),
|
198
|
-
]);
|
199
|
-
|
200
|
-
// Since opening a Pack gives "random" rewards, in this case we can check if
|
201
|
-
// the recipient received either 1. <one ERC20 token>, or 2. <one ERC721 token>
|
202
|
-
expect(
|
203
|
-
erc20Balance === 100n * 10n ** 18n ||
|
204
|
-
erc721Owner.toLowerCase() === account.address.toLowerCase(),
|
205
|
-
).toBe(true);
|
206
215
|
});
|
207
216
|
});
|