thirdweb 5.67.0 → 5.67.1-nightly-07af64706797927a9793a5452bd253e493de38f1-20241110000350
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/analytics/track/connect.js +2 -1
- package/dist/cjs/analytics/track/connect.js.map +1 -1
- package/dist/cjs/client/client.js +1 -1
- package/dist/cjs/contract/deployment/zksync/zkDeployContract.js +1 -1
- package/dist/cjs/contract/deployment/zksync/zkDeployContract.js.map +1 -1
- package/dist/cjs/contract/deployment/zksync/zkDeployCreate2Factory.js +5 -1
- package/dist/cjs/contract/deployment/zksync/zkDeployCreate2Factory.js.map +1 -1
- package/dist/cjs/contract/deployment/zksync/zkDeployProxy.js +4 -3
- package/dist/cjs/contract/deployment/zksync/zkDeployProxy.js.map +1 -1
- package/dist/cjs/exports/transaction.js +3 -1
- package/dist/cjs/exports/transaction.js.map +1 -1
- package/dist/cjs/exports/utils.js +5 -1
- package/dist/cjs/exports/utils.js.map +1 -1
- package/dist/cjs/exports/wallets/smart.js +3 -1
- package/dist/cjs/exports/wallets/smart.js.map +1 -1
- package/dist/cjs/extensions/prebuilts/get-required-transactions.js +28 -24
- package/dist/cjs/extensions/prebuilts/get-required-transactions.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/Details.js +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/TransactionModeScreen.js +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/TransactionModeScreen.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/WalletSelectorButton.js +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/WalletSelectorButton.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/ConfirmationScreen.js +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/ConfirmationScreen.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/PayWithCrypto.js +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/PayWithCrypto.js.map +1 -1
- package/dist/cjs/react/web/ui/TransactionButton/TransactionModal.js +1 -0
- package/dist/cjs/react/web/ui/TransactionButton/TransactionModal.js.map +1 -1
- package/dist/cjs/transaction/actions/estimate-gas-cost.js +6 -5
- package/dist/cjs/transaction/actions/estimate-gas-cost.js.map +1 -1
- package/dist/cjs/transaction/actions/send-transaction.js +9 -2
- package/dist/cjs/transaction/actions/send-transaction.js.map +1 -1
- package/dist/cjs/utils/any-evm/zksync/isZkSyncChain.js +2 -1
- package/dist/cjs/utils/any-evm/zksync/isZkSyncChain.js.map +1 -1
- package/dist/cjs/utils/config.js +16 -0
- package/dist/cjs/utils/config.js.map +1 -0
- package/dist/cjs/utils/fetch.js +15 -2
- package/dist/cjs/utils/fetch.js.map +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/version.js.map +1 -1
- package/dist/cjs/wallets/coinbase/coinbase-wallet.js +2 -0
- package/dist/cjs/wallets/coinbase/coinbase-wallet.js.map +1 -1
- package/dist/cjs/wallets/create-wallet.js +4 -0
- package/dist/cjs/wallets/create-wallet.js.map +1 -1
- package/dist/cjs/wallets/in-app/core/wallet/in-app-core.js +2 -0
- package/dist/cjs/wallets/in-app/core/wallet/in-app-core.js.map +1 -1
- package/dist/cjs/wallets/native/create-wallet.js +2 -0
- package/dist/cjs/wallets/native/create-wallet.js.map +1 -1
- package/dist/cjs/wallets/smart/index.js +2 -1
- package/dist/cjs/wallets/smart/index.js.map +1 -1
- package/dist/cjs/wallets/smart/smart-wallet.js +2 -0
- package/dist/cjs/wallets/smart/smart-wallet.js.map +1 -1
- package/dist/esm/analytics/track/connect.js +2 -1
- package/dist/esm/analytics/track/connect.js.map +1 -1
- package/dist/esm/client/client.js +1 -1
- package/dist/esm/contract/deployment/zksync/zkDeployContract.js +1 -1
- package/dist/esm/contract/deployment/zksync/zkDeployContract.js.map +1 -1
- package/dist/esm/contract/deployment/zksync/zkDeployCreate2Factory.js +5 -1
- package/dist/esm/contract/deployment/zksync/zkDeployCreate2Factory.js.map +1 -1
- package/dist/esm/contract/deployment/zksync/zkDeployProxy.js +4 -3
- package/dist/esm/contract/deployment/zksync/zkDeployProxy.js.map +1 -1
- package/dist/esm/exports/transaction.js +1 -0
- package/dist/esm/exports/transaction.js.map +1 -1
- package/dist/esm/exports/utils.js +1 -0
- package/dist/esm/exports/utils.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/extensions/prebuilts/get-required-transactions.js +28 -24
- package/dist/esm/extensions/prebuilts/get-required-transactions.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/Details.js +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/TransactionModeScreen.js +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/TransactionModeScreen.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/WalletSelectorButton.js +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/WalletSelectorButton.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/ConfirmationScreen.js +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/ConfirmationScreen.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/PayWithCrypto.js +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/PayWithCrypto.js.map +1 -1
- package/dist/esm/react/web/ui/TransactionButton/TransactionModal.js +1 -0
- package/dist/esm/react/web/ui/TransactionButton/TransactionModal.js.map +1 -1
- package/dist/esm/transaction/actions/estimate-gas-cost.js +6 -5
- package/dist/esm/transaction/actions/estimate-gas-cost.js.map +1 -1
- package/dist/esm/transaction/actions/send-transaction.js +9 -2
- package/dist/esm/transaction/actions/send-transaction.js.map +1 -1
- package/dist/esm/utils/any-evm/zksync/isZkSyncChain.js +2 -1
- package/dist/esm/utils/any-evm/zksync/isZkSyncChain.js.map +1 -1
- package/dist/esm/utils/config.js +11 -0
- package/dist/esm/utils/config.js.map +1 -0
- package/dist/esm/utils/fetch.js +15 -2
- package/dist/esm/utils/fetch.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/esm/wallets/coinbase/coinbase-wallet.js +2 -0
- package/dist/esm/wallets/coinbase/coinbase-wallet.js.map +1 -1
- package/dist/esm/wallets/create-wallet.js +4 -0
- package/dist/esm/wallets/create-wallet.js.map +1 -1
- package/dist/esm/wallets/in-app/core/wallet/in-app-core.js +2 -0
- package/dist/esm/wallets/in-app/core/wallet/in-app-core.js.map +1 -1
- package/dist/esm/wallets/native/create-wallet.js +2 -0
- package/dist/esm/wallets/native/create-wallet.js.map +1 -1
- package/dist/esm/wallets/smart/index.js +2 -1
- package/dist/esm/wallets/smart/index.js.map +1 -1
- package/dist/esm/wallets/smart/smart-wallet.js +2 -0
- package/dist/esm/wallets/smart/smart-wallet.js.map +1 -1
- package/dist/types/analytics/track/connect.d.ts +1 -0
- package/dist/types/analytics/track/connect.d.ts.map +1 -1
- package/dist/types/client/client.d.ts +1 -1
- package/dist/types/contract/deployment/zksync/zkDeployContract.d.ts +1 -0
- package/dist/types/contract/deployment/zksync/zkDeployContract.d.ts.map +1 -1
- package/dist/types/contract/deployment/zksync/zkDeployCreate2Factory.d.ts.map +1 -1
- package/dist/types/contract/deployment/zksync/zkDeployProxy.d.ts.map +1 -1
- package/dist/types/exports/transaction.d.ts +1 -0
- package/dist/types/exports/transaction.d.ts.map +1 -1
- package/dist/types/exports/utils.d.ts +1 -0
- package/dist/types/exports/utils.d.ts.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/extensions/prebuilts/get-required-transactions.d.ts.map +1 -1
- package/dist/types/react/web/ui/TransactionButton/TransactionModal.d.ts.map +1 -1
- package/dist/types/transaction/actions/estimate-gas-cost.d.ts.map +1 -1
- package/dist/types/transaction/actions/send-transaction.d.ts.map +1 -1
- package/dist/types/utils/any-evm/zksync/isZkSyncChain.d.ts.map +1 -1
- package/dist/types/utils/config.d.ts +18 -0
- package/dist/types/utils/config.d.ts.map +1 -0
- package/dist/types/utils/fetch.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/coinbase-wallet.d.ts.map +1 -1
- package/dist/types/wallets/create-wallet.d.ts.map +1 -1
- package/dist/types/wallets/in-app/core/wallet/in-app-core.d.ts.map +1 -1
- package/dist/types/wallets/in-app/web/types.d.ts +1 -1
- package/dist/types/wallets/interfaces/wallet.d.ts +2 -1
- package/dist/types/wallets/interfaces/wallet.d.ts.map +1 -1
- package/dist/types/wallets/native/create-wallet.d.ts.map +1 -1
- package/dist/types/wallets/smart/smart-wallet.d.ts.map +1 -1
- package/package.json +11 -11
- package/src/analytics/track/connect.ts +3 -1
- package/src/client/client.ts +1 -1
- package/src/contract/deployment/zksync/zkDeployContract.ts +3 -1
- package/src/contract/deployment/zksync/zkDeployCreate2Factory.ts +9 -1
- package/src/contract/deployment/zksync/zkDeployProxy.ts +4 -3
- package/src/exports/transaction.ts +1 -0
- package/src/exports/utils.ts +5 -0
- package/src/exports/wallets/smart.ts +1 -0
- package/src/extensions/prebuilts/get-required-transactions.ts +34 -30
- package/src/react/web/ui/ConnectWallet/Details.tsx +1 -1
- package/src/react/web/ui/ConnectWallet/screens/Buy/TransactionModeScreen.tsx +1 -1
- package/src/react/web/ui/ConnectWallet/screens/Buy/WalletSelectorButton.tsx +1 -1
- package/src/react/web/ui/ConnectWallet/screens/Buy/swap/ConfirmationScreen.tsx +1 -1
- package/src/react/web/ui/ConnectWallet/screens/Buy/swap/PayWithCrypto.tsx +1 -1
- package/src/react/web/ui/TransactionButton/TransactionModal.tsx +1 -0
- package/src/transaction/actions/estimate-gas-cost.test.ts +9 -9
- package/src/transaction/actions/estimate-gas-cost.ts +11 -5
- package/src/transaction/actions/send-transaction.ts +11 -2
- package/src/utils/any-evm/zksync/isZkSyncChain.ts +2 -1
- package/src/utils/config.ts +26 -0
- package/src/utils/fetch.ts +19 -2
- package/src/version.ts +1 -1
- package/src/wallets/coinbase/coinbase-wallet.ts +2 -0
- package/src/wallets/create-wallet.ts +4 -0
- package/src/wallets/in-app/core/wallet/in-app-core.ts +2 -0
- package/src/wallets/in-app/web/types.ts +1 -1
- package/src/wallets/interfaces/wallet.ts +5 -1
- package/src/wallets/native/create-wallet.ts +2 -0
- package/src/wallets/smart/index.ts +2 -1
- package/src/wallets/smart/smart-wallet-dev.test.ts +28 -3
- package/src/wallets/smart/smart-wallet-integration.test.ts +1 -22
- package/src/wallets/smart/smart-wallet.ts +2 -0
@@ -10,8 +10,9 @@ export async function trackConnect(args: {
|
|
10
10
|
ecosystem?: Ecosystem;
|
11
11
|
walletType: string;
|
12
12
|
walletAddress: string;
|
13
|
+
chainId?: number;
|
13
14
|
}) {
|
14
|
-
const { client, ecosystem, walletType, walletAddress } = args;
|
15
|
+
const { client, ecosystem, walletType, walletAddress, chainId } = args;
|
15
16
|
return track({
|
16
17
|
client,
|
17
18
|
ecosystem,
|
@@ -20,6 +21,7 @@ export async function trackConnect(args: {
|
|
20
21
|
action: "connect",
|
21
22
|
walletType,
|
22
23
|
walletAddress,
|
24
|
+
chainId,
|
23
25
|
},
|
24
26
|
});
|
25
27
|
}
|
package/src/client/client.ts
CHANGED
@@ -73,7 +73,7 @@ export type ThirdwebClient = {
|
|
73
73
|
/**
|
74
74
|
* Creates a Thirdweb client using the provided client ID (client-side) or secret key (server-side).
|
75
75
|
*
|
76
|
-
* Get your client ID and secret key from the Thirdweb dashboard [here](https://thirdweb.com/
|
76
|
+
* Get your client ID and secret key from the Thirdweb dashboard [here](https://thirdweb.com/create-api-key).
|
77
77
|
* **Never share your secret key with anyone.
|
78
78
|
*
|
79
79
|
* A client is necessary for most functions in the thirdweb SDK. It provides access to thirdweb APIs including built-in RPC, storage, and more.
|
@@ -19,6 +19,7 @@ export async function zkDeployContract(
|
|
19
19
|
bytecode: Hex;
|
20
20
|
params?: Record<string, unknown>;
|
21
21
|
salt?: string;
|
22
|
+
deploymentType?: "create" | "create2";
|
22
23
|
},
|
23
24
|
) {
|
24
25
|
if (options.salt !== undefined) {
|
@@ -29,7 +30,7 @@ export async function zkDeployContract(
|
|
29
30
|
const data = encodeDeployData({
|
30
31
|
abi: options.abi,
|
31
32
|
bytecode: options.bytecode,
|
32
|
-
deploymentType: "create",
|
33
|
+
deploymentType: options.deploymentType ?? "create",
|
33
34
|
args: normalizeFunctionParams(
|
34
35
|
options.abi.find((abi) => abi.type === "constructor"),
|
35
36
|
options.params,
|
@@ -56,6 +57,7 @@ export async function zkDeployContract(
|
|
56
57
|
});
|
57
58
|
|
58
59
|
const contractAddress = events[0]?.args.contractAddress;
|
60
|
+
|
59
61
|
if (!contractAddress) {
|
60
62
|
throw new Error("Contract creation failed");
|
61
63
|
}
|
@@ -30,10 +30,17 @@ export async function zkDeployCreate2Factory(
|
|
30
30
|
return ZKSYNC_SINGLETON_FACTORY;
|
31
31
|
}
|
32
32
|
|
33
|
+
if (!PUBLISHED_PRIVATE_KEY) {
|
34
|
+
throw new Error(
|
35
|
+
`Unable to deploy create2 factory on chain ${options.chain.id} - please contact us via https://thirdweb.com/support to enable this chain`,
|
36
|
+
);
|
37
|
+
}
|
38
|
+
|
33
39
|
const create2Signer = privateKeyToAccount({
|
34
40
|
client: options.client,
|
35
41
|
privateKey: PUBLISHED_PRIVATE_KEY,
|
36
42
|
});
|
43
|
+
|
37
44
|
const valueToSend = toWei("0.01");
|
38
45
|
const balance = await getWalletBalance({
|
39
46
|
address: create2Signer.address,
|
@@ -56,9 +63,10 @@ export async function zkDeployCreate2Factory(
|
|
56
63
|
await zkDeployContract({
|
57
64
|
client: options.client,
|
58
65
|
chain: options.chain,
|
59
|
-
account:
|
66
|
+
account: create2Signer,
|
60
67
|
abi: parseAbi(singletonFactoryAbi),
|
61
68
|
bytecode: singletonFactoryBytecode,
|
69
|
+
deploymentType: "create2",
|
62
70
|
});
|
63
71
|
|
64
72
|
return ZKSYNC_SINGLETON_FACTORY;
|
@@ -6,9 +6,10 @@ import {
|
|
6
6
|
} from "../../../utils/any-evm/zksync/constants.js";
|
7
7
|
import { isContractDeployed } from "../../../utils/bytecode/is-contract-deployed.js";
|
8
8
|
import { resolvePromisedValue } from "../../../utils/promise/resolve-promised-value.js";
|
9
|
+
import { randomBytesHex } from "../../../utils/random.js";
|
9
10
|
import type { ClientAndChainAndAccount } from "../../../utils/types.js";
|
10
11
|
import type { ThirdwebContract } from "../../contract.js";
|
11
|
-
import {
|
12
|
+
import { zkDeployContractDeterministic } from "./zkDeployDeterministic.js";
|
12
13
|
|
13
14
|
/**
|
14
15
|
* @internal
|
@@ -38,7 +39,7 @@ export async function zkDeployProxy(
|
|
38
39
|
);
|
39
40
|
}
|
40
41
|
// deploy tw proxy of the implementation
|
41
|
-
const proxyAddress = await
|
42
|
+
const proxyAddress = await zkDeployContractDeterministic({
|
42
43
|
client: options.client,
|
43
44
|
chain: options.chain,
|
44
45
|
account: options.account,
|
@@ -48,7 +49,7 @@ export async function zkDeployProxy(
|
|
48
49
|
_logic: implementationAddress,
|
49
50
|
_data: await encode(options.initializeTransaction),
|
50
51
|
},
|
51
|
-
salt: options.salt,
|
52
|
+
salt: options.salt || randomBytesHex(32),
|
52
53
|
});
|
53
54
|
|
54
55
|
// return address of proxy
|
package/src/exports/utils.ts
CHANGED
@@ -147,6 +147,11 @@ export { encodePacked } from "viem";
|
|
147
147
|
// Useful helpers
|
148
148
|
export { setThirdwebDomains } from "../utils/domains.js";
|
149
149
|
export { resolvePromisedValue } from "../utils/promise/resolve-promised-value.js";
|
150
|
+
export {
|
151
|
+
setTransactionDecorator,
|
152
|
+
getTransactionDecorator,
|
153
|
+
clearTransactionDecorator,
|
154
|
+
} from "../utils/config.js";
|
150
155
|
|
151
156
|
// ------------------------------------------------
|
152
157
|
// json
|
@@ -21,6 +21,7 @@ export {
|
|
21
21
|
} from "../../wallets/smart/lib/calls.js";
|
22
22
|
|
23
23
|
export { getPaymasterAndData } from "../../wallets/smart/lib/paymaster.js";
|
24
|
+
export { getZkPaymasterData } from "../../wallets/smart/lib/bundler.js";
|
24
25
|
|
25
26
|
export type {
|
26
27
|
SmartWalletConnectionOptions,
|
@@ -51,39 +51,43 @@ export async function getRequiredTransactions(
|
|
51
51
|
| DeployTransactionResult[]
|
52
52
|
| null
|
53
53
|
)[] = await Promise.all([
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
c || isZkSync
|
68
|
-
? null
|
69
|
-
: ({ type: "infra", contractId: "Forwarder" } as const),
|
70
|
-
),
|
71
|
-
getDeployedInfraContract({
|
72
|
-
chain,
|
73
|
-
client,
|
74
|
-
contractId: "TWCloneFactory",
|
75
|
-
constructorParams: {
|
76
|
-
_trustedForwarder: await computePublishedContractAddress({
|
54
|
+
isZkSync
|
55
|
+
? null
|
56
|
+
: getDeployedCreate2Factory({
|
57
|
+
chain,
|
58
|
+
client,
|
59
|
+
}).then((c) =>
|
60
|
+
c
|
61
|
+
? null
|
62
|
+
: ({ type: "infra", contractId: "Create2Factory" } as const),
|
63
|
+
),
|
64
|
+
isZkSync
|
65
|
+
? null
|
66
|
+
: getDeployedInfraContract({
|
77
67
|
chain,
|
78
68
|
client,
|
79
69
|
contractId: "Forwarder",
|
80
|
-
})
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
70
|
+
}).then((c) =>
|
71
|
+
c ? null : ({ type: "infra", contractId: "Forwarder" } as const),
|
72
|
+
),
|
73
|
+
isZkSync
|
74
|
+
? null
|
75
|
+
: getDeployedInfraContract({
|
76
|
+
chain,
|
77
|
+
client,
|
78
|
+
contractId: "TWCloneFactory",
|
79
|
+
constructorParams: {
|
80
|
+
_trustedForwarder: await computePublishedContractAddress({
|
81
|
+
chain,
|
82
|
+
client,
|
83
|
+
contractId: "Forwarder",
|
84
|
+
}),
|
85
|
+
},
|
86
|
+
}).then((c) =>
|
87
|
+
c
|
88
|
+
? null
|
89
|
+
: ({ type: "infra", contractId: "TWCloneFactory" } as const),
|
90
|
+
),
|
87
91
|
// TODO (deploy): add WETH contract check for implementations that need it (check implementation constructor params)
|
88
92
|
getTransactionsForImplementation({
|
89
93
|
chain,
|
@@ -363,7 +363,7 @@ function DetailsModal(props: {
|
|
363
363
|
{chainNameQuery.name || `Unknown chain #${walletChain?.id}`}
|
364
364
|
<Text color="secondaryText" size="xs">
|
365
365
|
{balanceQuery.data ? (
|
366
|
-
formatNumber(Number(balanceQuery.data.displayValue),
|
366
|
+
formatNumber(Number(balanceQuery.data.displayValue), 9)
|
367
367
|
) : (
|
368
368
|
<Skeleton height="1em" width="100px" />
|
369
369
|
)}{" "}
|
@@ -125,7 +125,7 @@ export function TransactionModeScreen(props: {
|
|
125
125
|
{balanceQuery.data ? (
|
126
126
|
<Container flex="row" gap="3xs" center="y">
|
127
127
|
<Text size="xs" color="secondaryText" weight={500}>
|
128
|
-
{formatTokenBalance(balanceQuery.data, false
|
128
|
+
{formatTokenBalance(balanceQuery.data, false)}
|
129
129
|
</Text>
|
130
130
|
<TokenSymbol
|
131
131
|
token={transactionCostAndData.token}
|
@@ -115,7 +115,7 @@ function TokenBalanceRow(props: {
|
|
115
115
|
<div style={{ flex: 1 }} />
|
116
116
|
<Container flex="row" center="y" gap="3xs">
|
117
117
|
<Text size="xs" color="secondaryText">
|
118
|
-
{formatTokenBalance(tokenBalance.balance, true
|
118
|
+
{formatTokenBalance(tokenBalance.balance, true)}
|
119
119
|
</Text>
|
120
120
|
</Container>
|
121
121
|
</StyledButton>
|
@@ -279,7 +279,7 @@ export function SwapConfirmationScreen(props: {
|
|
279
279
|
fromAmount: props.quote.swapDetails.fromAmountWei,
|
280
280
|
toToken: props.quote.swapDetails.toToken.tokenAddress,
|
281
281
|
toAmount: props.quote.swapDetails.toAmountWei,
|
282
|
-
chainId: props.quote.swapDetails.
|
282
|
+
chainId: props.quote.swapDetails.fromToken.chainId,
|
283
283
|
dstChainId: props.quote.swapDetails.toToken.chainId,
|
284
284
|
});
|
285
285
|
|
@@ -74,7 +74,7 @@ export function PayWithCryptoQuoteInfo(props: {
|
|
74
74
|
{balanceQuery.data ? (
|
75
75
|
<Container flex="row" gap="3xs" center="y">
|
76
76
|
<Text size="xs" color="secondaryText" weight={500}>
|
77
|
-
{formatTokenBalance(balanceQuery.data, false
|
77
|
+
{formatTokenBalance(balanceQuery.data, false)}
|
78
78
|
</Text>
|
79
79
|
<TokenSymbol
|
80
80
|
token={props.token}
|
@@ -22,11 +22,11 @@ describe.runIf(process.env.TW_SECRET_KEY)("estimateGasCost", () => {
|
|
22
22
|
transaction: tx,
|
23
23
|
});
|
24
24
|
expect(result).toMatchInlineSnapshot(`
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
25
|
+
{
|
26
|
+
"ether": "0.002468675264234022",
|
27
|
+
"wei": 2468675264234022n,
|
28
|
+
}
|
29
|
+
`);
|
30
30
|
});
|
31
31
|
|
32
32
|
it("should estimateGasCost native token", async () => {
|
@@ -41,8 +41,8 @@ describe.runIf(process.env.TW_SECRET_KEY)("estimateGasCost", () => {
|
|
41
41
|
});
|
42
42
|
expect(result).toMatchInlineSnapshot(`
|
43
43
|
{
|
44
|
-
"ether": "0.
|
45
|
-
"wei":
|
44
|
+
"ether": "0.00107647061028156",
|
45
|
+
"wei": 1076470610281560n,
|
46
46
|
}
|
47
47
|
`);
|
48
48
|
});
|
@@ -61,8 +61,8 @@ describe.runIf(process.env.TW_SECRET_KEY)("estimateGasCost", () => {
|
|
61
61
|
});
|
62
62
|
expect(result).toMatchInlineSnapshot(`
|
63
63
|
{
|
64
|
-
"ether": "0.
|
65
|
-
"wei":
|
64
|
+
"ether": "0.000023420415571618",
|
65
|
+
"wei": 23420415571618n,
|
66
66
|
}
|
67
67
|
`);
|
68
68
|
});
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { isOpStackChain } from "../../chains/constants.js";
|
2
|
-
import {
|
2
|
+
import { getDefaultGasOverrides } from "../../gas/fee-data.js";
|
3
3
|
import { resolvePromisedValue } from "../../utils/promise/resolve-promised-value.js";
|
4
4
|
import { toEther } from "../../utils/units.js";
|
5
5
|
import { type EstimateGasOptions, estimateGas } from "./estimate-gas.js";
|
@@ -33,10 +33,16 @@ export async function estimateGasCost(
|
|
33
33
|
const gasLimit =
|
34
34
|
(await resolvePromisedValue(transaction.gas)) ||
|
35
35
|
(await estimateGas({ transaction, from }));
|
36
|
-
const
|
37
|
-
|
38
|
-
|
39
|
-
|
36
|
+
const fees = await getDefaultGasOverrides(
|
37
|
+
transaction.client,
|
38
|
+
transaction.chain,
|
39
|
+
);
|
40
|
+
const gasPrice = fees.maxFeePerGas || fees.gasPrice;
|
41
|
+
if (!gasPrice) {
|
42
|
+
throw new Error(
|
43
|
+
`Unable to determine gas price for chain ${transaction.chain.id}`,
|
44
|
+
);
|
45
|
+
}
|
40
46
|
let l1Fee: bigint;
|
41
47
|
if (isOpStackChain(transaction.chain)) {
|
42
48
|
const { estimateL1Fee } = await import("../../gas/estimate-l1-fee.js");
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import { getTransactionDecorator } from "../../utils/config.js";
|
1
2
|
import type { Account } from "../../wallets/interfaces/wallet.js";
|
2
3
|
import type { PreparedTransaction } from "../prepare-transaction.js";
|
3
4
|
import { addTransactionToStore } from "../transaction-store.js";
|
@@ -138,14 +139,22 @@ export interface SendTransactionOptions {
|
|
138
139
|
export async function sendTransaction(
|
139
140
|
options: SendTransactionOptions,
|
140
141
|
): Promise<WaitForReceiptOptions> {
|
141
|
-
|
142
|
+
let { account, transaction, gasless } = options;
|
143
|
+
|
144
|
+
const decorator = getTransactionDecorator();
|
145
|
+
if (decorator) {
|
146
|
+
const { account: decoratedAccount, transaction: decoratedTransaction } =
|
147
|
+
await decorator({ account, transaction });
|
148
|
+
account = decoratedAccount;
|
149
|
+
transaction = decoratedTransaction;
|
150
|
+
}
|
142
151
|
|
143
152
|
if (account.onTransactionRequested) {
|
144
153
|
await account.onTransactionRequested(transaction);
|
145
154
|
}
|
146
155
|
|
147
156
|
// if zksync transaction params are set, send with eip712
|
148
|
-
if (
|
157
|
+
if (transaction.eip712) {
|
149
158
|
const { sendEip712Transaction } = await import(
|
150
159
|
"./zksync/send-eip712-transaction.js"
|
151
160
|
);
|
@@ -0,0 +1,26 @@
|
|
1
|
+
import type { PreparedTransaction } from "../transaction/prepare-transaction.js";
|
2
|
+
import type { Account } from "../wallets/interfaces/wallet.js";
|
3
|
+
|
4
|
+
let transactionDecorator:
|
5
|
+
| ((args: {
|
6
|
+
account: Account;
|
7
|
+
transaction: PreparedTransaction;
|
8
|
+
}) => Promise<{ account: Account; transaction: PreparedTransaction }>)
|
9
|
+
| null = null;
|
10
|
+
|
11
|
+
export function setTransactionDecorator(
|
12
|
+
decoratorFunction: (args: {
|
13
|
+
account: Account;
|
14
|
+
transaction: PreparedTransaction;
|
15
|
+
}) => Promise<{ account: Account; transaction: PreparedTransaction }>,
|
16
|
+
) {
|
17
|
+
transactionDecorator = decoratorFunction;
|
18
|
+
}
|
19
|
+
|
20
|
+
export function clearTransactionDecorator() {
|
21
|
+
transactionDecorator = null;
|
22
|
+
}
|
23
|
+
|
24
|
+
export function getTransactionDecorator() {
|
25
|
+
return transactionDecorator;
|
26
|
+
}
|
package/src/utils/fetch.ts
CHANGED
@@ -45,9 +45,14 @@ export function getClientFetch(client: ThirdwebClient, ecosystem?: Ecosystem) {
|
|
45
45
|
: undefined;
|
46
46
|
const clientId = client.clientId;
|
47
47
|
|
48
|
-
// if we have an auth token set, use that (thirdweb
|
48
|
+
// if we have an auth token set, use that (thirdweb dashboard sets this for the user)
|
49
49
|
// pay urls should never send the auth token, because we always want the "developer" to be the one making the request, not the "end user"
|
50
|
-
if (
|
50
|
+
if (
|
51
|
+
authToken &&
|
52
|
+
!isPayUrl(url) &&
|
53
|
+
!isInAppWalletUrl(url) &&
|
54
|
+
!isBundlerUrl(url)
|
55
|
+
) {
|
51
56
|
headers.set("authorization", `Bearer ${authToken}`);
|
52
57
|
} else if (secretKey) {
|
53
58
|
headers.set("x-secret-key", secretKey);
|
@@ -153,6 +158,18 @@ function isInAppWalletUrl(url: string): boolean {
|
|
153
158
|
}
|
154
159
|
}
|
155
160
|
|
161
|
+
function isBundlerUrl(url: string): boolean {
|
162
|
+
try {
|
163
|
+
const { hostname } = new URL(url);
|
164
|
+
return (
|
165
|
+
hostname.endsWith(".bundler.thirdweb.com") ||
|
166
|
+
hostname.endsWith(".bundler.thirdweb-dev.com")
|
167
|
+
);
|
168
|
+
} catch {
|
169
|
+
return false;
|
170
|
+
}
|
171
|
+
}
|
172
|
+
|
156
173
|
const SDK_NAME = "unified-sdk";
|
157
174
|
|
158
175
|
let previousPlatform: [string, string][] | undefined;
|
package/src/version.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export const version = "5.67.
|
1
|
+
export const version = "5.67.1-nightly-07af64706797927a9793a5452bd253e493de38f1-20241110000350";
|
@@ -81,6 +81,7 @@ export function coinbaseWalletSDK(args: {
|
|
81
81
|
client: options.client,
|
82
82
|
walletType: COINBASE,
|
83
83
|
walletAddress: account.address,
|
84
|
+
chainId: chain.id,
|
84
85
|
});
|
85
86
|
// return account
|
86
87
|
return account;
|
@@ -100,6 +101,7 @@ export function coinbaseWalletSDK(args: {
|
|
100
101
|
client: options.client,
|
101
102
|
walletType: COINBASE,
|
102
103
|
walletAddress: account.address,
|
104
|
+
chainId: chain.id,
|
103
105
|
});
|
104
106
|
// return account
|
105
107
|
return account;
|
@@ -250,6 +250,7 @@ export function createWallet<const ID extends WalletId>(
|
|
250
250
|
client: options.client,
|
251
251
|
walletType: id,
|
252
252
|
walletAddress: account.address,
|
253
|
+
chainId: chain.id,
|
253
254
|
});
|
254
255
|
// return account
|
255
256
|
return account;
|
@@ -281,6 +282,7 @@ export function createWallet<const ID extends WalletId>(
|
|
281
282
|
client: options.client,
|
282
283
|
walletType: id,
|
283
284
|
walletAddress: account.address,
|
285
|
+
chainId: chain.id,
|
284
286
|
});
|
285
287
|
// return account
|
286
288
|
return account;
|
@@ -314,6 +316,7 @@ export function createWallet<const ID extends WalletId>(
|
|
314
316
|
client: wcOptions.client,
|
315
317
|
walletType: id,
|
316
318
|
walletAddress: account.address,
|
319
|
+
chainId: chain.id,
|
317
320
|
});
|
318
321
|
return account;
|
319
322
|
}
|
@@ -359,6 +362,7 @@ export function createWallet<const ID extends WalletId>(
|
|
359
362
|
client: options.client,
|
360
363
|
walletType: id,
|
361
364
|
walletAddress: account.address,
|
365
|
+
chainId: chain.id,
|
362
366
|
});
|
363
367
|
// return account
|
364
368
|
return account;
|
@@ -106,6 +106,7 @@ export function createInAppWallet(args: {
|
|
106
106
|
ecosystem,
|
107
107
|
walletType: walletId,
|
108
108
|
walletAddress: account.address,
|
109
|
+
chainId: chain.id,
|
109
110
|
});
|
110
111
|
// return only the account
|
111
112
|
return account;
|
@@ -153,6 +154,7 @@ export function createInAppWallet(args: {
|
|
153
154
|
ecosystem,
|
154
155
|
walletType: walletId,
|
155
156
|
walletAddress: account.address,
|
157
|
+
chainId: chain.id,
|
156
158
|
});
|
157
159
|
// return only the account
|
158
160
|
return account;
|
@@ -9,7 +9,7 @@ import type { InAppWalletIframeCommunicator } from "./utils/iFrameCommunication/
|
|
9
9
|
// Open to PRs from whoever sees this and knows of a cleaner way to handle things
|
10
10
|
type ClientIdConstructorType = {
|
11
11
|
/**
|
12
|
-
* the clientId
|
12
|
+
* the clientId of your API Key. You can create an API key by creating a project on thirdweb dashboard.
|
13
13
|
*/
|
14
14
|
client: ThirdwebClient;
|
15
15
|
};
|
@@ -7,7 +7,10 @@ import type {
|
|
7
7
|
TypedDataDefinition,
|
8
8
|
} from "viem";
|
9
9
|
import type { Chain } from "../../chains/types.js";
|
10
|
-
import type {
|
10
|
+
import type {
|
11
|
+
EIP712TransactionOptions,
|
12
|
+
PreparedTransaction,
|
13
|
+
} from "../../transaction/prepare-transaction.js";
|
11
14
|
import type { SendTransactionResult } from "../../transaction/types.js";
|
12
15
|
import type { WalletEmitter } from "../wallet-emitter.js";
|
13
16
|
import type {
|
@@ -19,6 +22,7 @@ import type {
|
|
19
22
|
|
20
23
|
export type SendTransactionOption = TransactionSerializable & {
|
21
24
|
chainId: number;
|
25
|
+
eip712?: EIP712TransactionOptions;
|
22
26
|
};
|
23
27
|
|
24
28
|
type SendRawTransactionOptions = {
|
@@ -169,6 +169,7 @@ export function createWallet<const ID extends WalletId>(
|
|
169
169
|
client: options.client,
|
170
170
|
walletType: id,
|
171
171
|
walletAddress: account.address,
|
172
|
+
chainId: chain.id,
|
172
173
|
});
|
173
174
|
// return account
|
174
175
|
return account;
|
@@ -202,6 +203,7 @@ export function createWallet<const ID extends WalletId>(
|
|
202
203
|
client: wcOptions.client,
|
203
204
|
walletType: id,
|
204
205
|
walletAddress: account.address,
|
206
|
+
chainId: chain.id,
|
205
207
|
});
|
206
208
|
return account;
|
207
209
|
}
|
@@ -501,6 +501,7 @@ function createZkSyncAccount(args: {
|
|
501
501
|
value: transaction.value ?? 0n,
|
502
502
|
chain: getCachedChain(transaction.chainId),
|
503
503
|
client: connectionOptions.client,
|
504
|
+
eip712: transaction.eip712,
|
504
505
|
};
|
505
506
|
|
506
507
|
let serializableTransaction = await populateEip712Transaction({
|
@@ -508,7 +509,7 @@ function createZkSyncAccount(args: {
|
|
508
509
|
transaction: prepTx,
|
509
510
|
});
|
510
511
|
|
511
|
-
if (args.sponsorGas) {
|
512
|
+
if (args.sponsorGas && !serializableTransaction.paymaster) {
|
512
513
|
// get paymaster input
|
513
514
|
const pmData = await getZkPaymasterData({
|
514
515
|
options: {
|
@@ -1,9 +1,10 @@
|
|
1
1
|
import { beforeAll, describe, expect, it } from "vitest";
|
2
2
|
import { TEST_CLIENT } from "../../../test/src/test-clients.js";
|
3
|
-
import {
|
3
|
+
import { defineChain } from "../../chains/utils.js";
|
4
4
|
import { type ThirdwebContract, getContract } from "../../contract/contract.js";
|
5
5
|
import { balanceOf } from "../../extensions/erc1155/__generated__/IERC1155/read/balanceOf.js";
|
6
6
|
import { claimTo } from "../../extensions/erc1155/drops/write/claimTo.js";
|
7
|
+
import { deployPublishedContract } from "../../extensions/prebuilts/deploy-published.js";
|
7
8
|
import { sendAndConfirmTransaction } from "../../transaction/actions/send-and-confirm-transaction.js";
|
8
9
|
import { sendTransaction } from "../../transaction/actions/send-transaction.js";
|
9
10
|
import { prepareTransaction } from "../../transaction/prepare-transaction.js";
|
@@ -20,7 +21,7 @@ let smartWalletAddress: Address;
|
|
20
21
|
let personalAccount: Account;
|
21
22
|
let accountContract: ThirdwebContract;
|
22
23
|
|
23
|
-
const chain =
|
24
|
+
const chain = defineChain(531050104);
|
24
25
|
const client = TEST_CLIENT;
|
25
26
|
const contract = getContract({
|
26
27
|
client,
|
@@ -69,7 +70,7 @@ describe.runIf(process.env.TW_SECRET_KEY).skip.sequential(
|
|
69
70
|
expect(isDeployed).toEqual(true);
|
70
71
|
});
|
71
72
|
|
72
|
-
it("should send a transaction", async () => {
|
73
|
+
it.skip("should send a transaction", async () => {
|
73
74
|
const tx = prepareTransaction({
|
74
75
|
client,
|
75
76
|
chain,
|
@@ -106,5 +107,29 @@ describe.runIf(process.env.TW_SECRET_KEY).skip.sequential(
|
|
106
107
|
});
|
107
108
|
expect(balance).toEqual(1n);
|
108
109
|
});
|
110
|
+
|
111
|
+
it("should deploy a published autofactory contract", async () => {
|
112
|
+
const address = await deployPublishedContract({
|
113
|
+
client: TEST_CLIENT,
|
114
|
+
chain,
|
115
|
+
account: smartAccount,
|
116
|
+
contractId: "DropERC721",
|
117
|
+
contractParams: {
|
118
|
+
defaultAdmin: smartAccount.address, // defaultAdmin
|
119
|
+
name: "test", // name
|
120
|
+
symbol: "test", // symbol
|
121
|
+
contractURI: "", // contractURI
|
122
|
+
trustedForwarders: [], // trustedForwarders
|
123
|
+
saleRecipient: smartAccount.address, // saleRecipient
|
124
|
+
royaltyRecipient: smartAccount.address, // royaltyRecipient
|
125
|
+
royaltyBps: 0n, // royaltyBps
|
126
|
+
platformFeeBps: 0n, // platformFeeBps
|
127
|
+
platformFeeRecipient: smartAccount.address, // platformFeeRecipient
|
128
|
+
},
|
129
|
+
});
|
130
|
+
console.log("deployed address", address);
|
131
|
+
expect(address).toBeDefined();
|
132
|
+
expect(address.length).toBe(42);
|
133
|
+
});
|
109
134
|
},
|
110
135
|
);
|