thirdweb 5.60.0-nightly-e552fda9e5364ce6e5d36f99eebc7d69b082f3d7-20241001000401 → 5.60.1-nightly-79c50cb311ffef769b7bdba3006ae67ddf257caf-20241002000323
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/deployment/deploy-via-autofactory.js +1 -1
- package/dist/cjs/contract/deployment/deploy-via-autofactory.js.map +1 -1
- package/dist/cjs/contract/deployment/utils/bootstrap.js +1 -1
- 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 +1 -1
- 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/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/TransferConfirmationScreen.js +2 -2
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/TransferConfirmationScreen.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/TransferFlow.js.map +1 -1
- package/dist/cjs/utils/any-evm/zksync/isZkSyncChain.js +30 -8
- package/dist/cjs/utils/any-evm/zksync/isZkSyncChain.js.map +1 -1
- package/dist/cjs/version.js +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/smart/index.js +1 -1
- package/dist/cjs/wallets/smart/index.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/utils/bootstrap.js +1 -1
- 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 +1 -1
- 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/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/TransferConfirmationScreen.js +2 -2
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/TransferConfirmationScreen.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/TransferFlow.js.map +1 -1
- package/dist/esm/utils/any-evm/zksync/isZkSyncChain.js +30 -8
- package/dist/esm/utils/any-evm/zksync/isZkSyncChain.js.map +1 -1
- package/dist/esm/version.js +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/smart/index.js +1 -1
- package/dist/esm/wallets/smart/index.js.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/get-required-transactions.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/TransferConfirmationScreen.d.ts +4 -2
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/TransferConfirmationScreen.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/TransferFlow.d.ts +4 -2
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/TransferFlow.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/wallets/coinbase/coinbaseWebSDK.d.ts.map +1 -1
- package/package.json +16 -16
- package/src/contract/deployment/deploy-via-autofactory.ts +1 -1
- package/src/contract/deployment/utils/bootstrap.ts +1 -1
- 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 +1 -1
- package/src/extensions/prebuilts/get-required-transactions.ts +5 -3
- package/src/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.tsx +1 -0
- package/src/react/web/ui/ConnectWallet/screens/Buy/swap/TransferConfirmationScreen.tsx +6 -3
- package/src/react/web/ui/ConnectWallet/screens/Buy/swap/TransferFlow.tsx +4 -2
- package/src/utils/any-evm/zksync/isZkSyncChain.ts +40 -8
- package/src/version.ts +1 -1
- package/src/wallets/coinbase/coinbaseWebSDK.ts +11 -2
- package/src/wallets/smart/index.ts +1 -1
@@ -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
|
});
|
@@ -267,7 +267,7 @@ async function directDeploy(options: {
|
|
267
267
|
const { account, client, chain, compilerMetadata, contractParams, salt } =
|
268
268
|
options;
|
269
269
|
|
270
|
-
if (isZkSyncChain(chain)) {
|
270
|
+
if (await isZkSyncChain(chain)) {
|
271
271
|
return zkDeployContract({
|
272
272
|
account,
|
273
273
|
client,
|
@@ -43,6 +43,8 @@ export async function getRequiredTransactions(
|
|
43
43
|
modules = [],
|
44
44
|
} = options;
|
45
45
|
|
46
|
+
const isZkSync = await isZkSyncChain(chain);
|
47
|
+
|
46
48
|
if (deployMetadata?.deployType === "autoFactory") {
|
47
49
|
const results: (
|
48
50
|
| DeployTransactionResult
|
@@ -53,7 +55,7 @@ export async function getRequiredTransactions(
|
|
53
55
|
chain,
|
54
56
|
client,
|
55
57
|
}).then((c) =>
|
56
|
-
c ||
|
58
|
+
c || isZkSync
|
57
59
|
? null
|
58
60
|
: ({ type: "infra", contractId: "Create2Factory" } as const),
|
59
61
|
),
|
@@ -62,7 +64,7 @@ export async function getRequiredTransactions(
|
|
62
64
|
client,
|
63
65
|
contractId: "Forwarder",
|
64
66
|
}).then((c) =>
|
65
|
-
c ||
|
67
|
+
c || isZkSync
|
66
68
|
? null
|
67
69
|
: ({ type: "infra", contractId: "Forwarder" } as const),
|
68
70
|
),
|
@@ -78,7 +80,7 @@ export async function getRequiredTransactions(
|
|
78
80
|
}),
|
79
81
|
},
|
80
82
|
}).then((c) =>
|
81
|
-
c ||
|
83
|
+
c || isZkSync
|
82
84
|
? null
|
83
85
|
: ({ type: "infra", contractId: "TWCloneFactory" } as const),
|
84
86
|
),
|
@@ -357,6 +357,7 @@ function BuyScreenContent(props: BuyScreenContentProps) {
|
|
357
357
|
tokenAmount={tokenAmount}
|
358
358
|
receiverAddress={receiverAddress}
|
359
359
|
transactionMode={props.payOptions.mode === "transaction"}
|
360
|
+
payOptions={payOptions}
|
360
361
|
isEmbed={props.isEmbed}
|
361
362
|
onDone={onDone}
|
362
363
|
onTryAgain={() => {
|
@@ -11,6 +11,7 @@ import { sendTransaction } from "../../../../../../../transaction/actions/send-t
|
|
11
11
|
import { prepareTransaction } from "../../../../../../../transaction/prepare-transaction.js";
|
12
12
|
import { toWei } from "../../../../../../../utils/units.js";
|
13
13
|
import { iconSize } from "../../../../../../core/design-system/index.js";
|
14
|
+
import type { PayUIOptions } from "../../../../../../core/hooks/connection/ConnectButtonProps.js";
|
14
15
|
import { useChainSymbol } from "../../../../../../core/hooks/others/useChainQuery.js";
|
15
16
|
import { Spacer } from "../../../../components/Spacer.js";
|
16
17
|
import { Spinner } from "../../../../components/Spinner.js";
|
@@ -26,7 +27,7 @@ import { TokenInfoRow } from "../pay-transactions/TokenInfoRow.js";
|
|
26
27
|
import type { PayerInfo } from "../types.js";
|
27
28
|
import { ConnectorLine } from "./ConfirmationScreen.js";
|
28
29
|
|
29
|
-
type
|
30
|
+
type TransferConfirmationScreenProps = {
|
30
31
|
title: string;
|
31
32
|
onBack?: () => void;
|
32
33
|
setTransactionHash: (txHash: string) => void;
|
@@ -38,10 +39,11 @@ type TrasnferConfirmationScreenProps = {
|
|
38
39
|
token: ERC20OrNativeToken;
|
39
40
|
tokenAmount: string;
|
40
41
|
transactionMode?: boolean;
|
42
|
+
payOptions?: PayUIOptions;
|
41
43
|
};
|
42
44
|
|
43
45
|
export function TransferConfirmationScreen(
|
44
|
-
props:
|
46
|
+
props: TransferConfirmationScreenProps,
|
45
47
|
) {
|
46
48
|
const {
|
47
49
|
title,
|
@@ -55,6 +57,7 @@ export function TransferConfirmationScreen(
|
|
55
57
|
tokenAmount,
|
56
58
|
transactionMode,
|
57
59
|
setTransactionHash,
|
60
|
+
payOptions,
|
58
61
|
} = props;
|
59
62
|
const [step, setStep] = useState<"approve" | "transfer" | "execute">(
|
60
63
|
"transfer",
|
@@ -242,7 +245,7 @@ export function TransferConfirmationScreen(
|
|
242
245
|
? NATIVE_TOKEN_ADDRESS
|
243
246
|
: token.address,
|
244
247
|
amount: tokenAmount,
|
245
|
-
purchaseData:
|
248
|
+
purchaseData: payOptions?.purchaseData,
|
246
249
|
});
|
247
250
|
|
248
251
|
if (transferResponse.approval) {
|
@@ -2,12 +2,13 @@ import { useState } from "react";
|
|
2
2
|
import type { Chain } from "../../../../../../../chains/types.js";
|
3
3
|
import type { ThirdwebClient } from "../../../../../../../client/client.js";
|
4
4
|
import type { BuyWithCryptoStatus } from "../../../../../../../pay/buyWithCrypto/getStatus.js";
|
5
|
+
import type { PayUIOptions } from "../../../../../../core/hooks/connection/ConnectButtonProps.js";
|
5
6
|
import type { ERC20OrNativeToken } from "../../nativeToken.js";
|
6
7
|
import type { PayerInfo } from "../types.js";
|
7
8
|
import { SwapStatusScreen } from "./SwapStatusScreen.js";
|
8
9
|
import { TransferConfirmationScreen } from "./TransferConfirmationScreen.js";
|
9
10
|
|
10
|
-
type
|
11
|
+
type TransferFlowProps = {
|
11
12
|
title: string;
|
12
13
|
onBack?: () => void;
|
13
14
|
payer: PayerInfo;
|
@@ -21,9 +22,10 @@ type TrasnferFlowProps = {
|
|
21
22
|
token: ERC20OrNativeToken;
|
22
23
|
tokenAmount: string;
|
23
24
|
transactionMode?: boolean;
|
25
|
+
payOptions?: PayUIOptions;
|
24
26
|
};
|
25
27
|
|
26
|
-
export function TransferFlow(props:
|
28
|
+
export function TransferFlow(props: TransferFlowProps) {
|
27
29
|
const [transferTxHash, setTransferTxHash] = useState<string | undefined>();
|
28
30
|
|
29
31
|
if (transferTxHash) {
|
@@ -1,12 +1,44 @@
|
|
1
1
|
import type { Chain } from "../../../chains/types.js";
|
2
|
+
import { withCache } from "../../promise/withCache.js";
|
2
3
|
|
3
|
-
export function isZkSyncChain(chain: Chain) {
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
4
|
+
export async function isZkSyncChain(chain: Chain) {
|
5
|
+
if (chain.id === 1337 || chain.id === 31337) {
|
6
|
+
return false;
|
7
|
+
}
|
8
|
+
|
9
|
+
const stack = await getChainStack(chain.id).catch(() => {
|
10
|
+
// fall back to checking against these zksync chain-ids
|
11
|
+
if (
|
12
|
+
chain.id === 324 ||
|
13
|
+
chain.id === 300 ||
|
14
|
+
chain.id === 302 ||
|
15
|
+
chain.id === 11124 ||
|
16
|
+
chain.id === 282 || // cronos zkevm testnet
|
17
|
+
chain.id === 388 // cronos zkevm mainnet
|
18
|
+
) {
|
19
|
+
return "zksync-stack";
|
20
|
+
}
|
21
|
+
|
22
|
+
return "";
|
23
|
+
});
|
24
|
+
|
25
|
+
return stack === "zksync-stack";
|
26
|
+
}
|
27
|
+
|
28
|
+
async function getChainStack(chainId: number): Promise<string> {
|
29
|
+
return withCache(
|
30
|
+
async () => {
|
31
|
+
const res = await fetch(`https://${chainId}.rpc.thirdweb.com/stack`);
|
32
|
+
|
33
|
+
if (!res.ok) {
|
34
|
+
res.body?.cancel();
|
35
|
+
throw new Error(`Error fetching stack for ${chainId}`);
|
36
|
+
}
|
37
|
+
|
38
|
+
const data = await res.json();
|
39
|
+
|
40
|
+
return data.stack;
|
41
|
+
},
|
42
|
+
{ cacheKey: `stack:${chainId}`, cacheTime: 24 * 60 * 60 * 1000 },
|
11
43
|
);
|
12
44
|
}
|
package/src/version.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export const version = "5.60.
|
1
|
+
export const version = "5.60.1-nightly-79c50cb311ffef769b7bdba3006ae67ddf257caf-20241002000323";
|
@@ -3,6 +3,7 @@ import type { Address } from "abitype";
|
|
3
3
|
import {
|
4
4
|
type SignTypedDataParameters,
|
5
5
|
getTypesForEIP712Domain,
|
6
|
+
isHex,
|
6
7
|
serializeTypedData,
|
7
8
|
validateTypedData,
|
8
9
|
} from "viem";
|
@@ -314,10 +315,14 @@ function createAccount(provider: ProviderInterface, _address: string) {
|
|
314
315
|
return message.raw;
|
315
316
|
})();
|
316
317
|
|
317
|
-
|
318
|
+
const res = await provider.request({
|
318
319
|
method: "personal_sign",
|
319
320
|
params: [messageToSign, account.address],
|
320
321
|
});
|
322
|
+
if (!isHex(res)) {
|
323
|
+
throw new Error("Invalid signature returned");
|
324
|
+
}
|
325
|
+
return res;
|
321
326
|
},
|
322
327
|
async signTypedData(_typedData) {
|
323
328
|
if (!account.address) {
|
@@ -343,10 +348,14 @@ function createAccount(provider: ProviderInterface, _address: string) {
|
|
343
348
|
types,
|
344
349
|
});
|
345
350
|
|
346
|
-
|
351
|
+
const res = await provider.request({
|
347
352
|
method: "eth_signTypedData_v4",
|
348
353
|
params: [account.address, stringifiedData],
|
349
354
|
});
|
355
|
+
if (!isHex(res)) {
|
356
|
+
throw new Error("Invalid signed payload returned");
|
357
|
+
}
|
358
|
+
return res;
|
350
359
|
},
|
351
360
|
onTransactionRequested: async () => {
|
352
361
|
// make sure to show the coinbase popup BEFORE doing any transaction preprocessing
|
@@ -104,7 +104,7 @@ export async function connectSmartWallet(
|
|
104
104
|
const sponsorGas =
|
105
105
|
"gasless" in options ? options.gasless : options.sponsorGas;
|
106
106
|
|
107
|
-
if (isZkSyncChain(chain)) {
|
107
|
+
if (await isZkSyncChain(chain)) {
|
108
108
|
return [
|
109
109
|
createZkSyncAccount({
|
110
110
|
creationOptions,
|