thirdweb 5.88.5 → 5.88.6
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/adapters/viem.js +110 -0
- package/dist/cjs/adapters/viem.js.map +1 -1
- package/dist/cjs/chains/chain-definitions/arbitrum-nova.js +1 -1
- package/dist/cjs/chains/chain-definitions/arbitrum-nova.js.map +1 -1
- package/dist/cjs/contract/deployment/zksync/zkDeployDeterministic.js +5 -1
- package/dist/cjs/contract/deployment/zksync/zkDeployDeterministic.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js +5 -14
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/TokenSelectorScreen.js +34 -3
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/TokenSelectorScreen.js.map +1 -1
- package/dist/cjs/utils/any-evm/compute-deployment-address.js +4 -1
- package/dist/cjs/utils/any-evm/compute-deployment-address.js.map +1 -1
- package/dist/cjs/utils/any-evm/compute-published-contract-deploy-info.js +1 -0
- package/dist/cjs/utils/any-evm/compute-published-contract-deploy-info.js.map +1 -1
- package/dist/cjs/utils/any-evm/get-init-bytecode-with-salt.js +3 -1
- package/dist/cjs/utils/any-evm/get-init-bytecode-with-salt.js.map +1 -1
- package/dist/cjs/utils/any-evm/zksync/computeDeploymentAddress.js +6 -1
- package/dist/cjs/utils/any-evm/zksync/computeDeploymentAddress.js.map +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/adapters/viem.js +110 -0
- package/dist/esm/adapters/viem.js.map +1 -1
- package/dist/esm/chains/chain-definitions/arbitrum-nova.js +1 -1
- package/dist/esm/chains/chain-definitions/arbitrum-nova.js.map +1 -1
- package/dist/esm/contract/deployment/zksync/zkDeployDeterministic.js +6 -2
- package/dist/esm/contract/deployment/zksync/zkDeployDeterministic.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js +5 -14
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/TokenSelectorScreen.js +34 -3
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/TokenSelectorScreen.js.map +1 -1
- package/dist/esm/utils/any-evm/compute-deployment-address.js +4 -1
- package/dist/esm/utils/any-evm/compute-deployment-address.js.map +1 -1
- package/dist/esm/utils/any-evm/compute-published-contract-deploy-info.js +1 -0
- package/dist/esm/utils/any-evm/compute-published-contract-deploy-info.js.map +1 -1
- package/dist/esm/utils/any-evm/get-init-bytecode-with-salt.js +4 -2
- package/dist/esm/utils/any-evm/get-init-bytecode-with-salt.js.map +1 -1
- package/dist/esm/utils/any-evm/zksync/computeDeploymentAddress.js +6 -1
- package/dist/esm/utils/any-evm/zksync/computeDeploymentAddress.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/types/adapters/viem.d.ts +65 -1
- package/dist/types/adapters/viem.d.ts.map +1 -1
- package/dist/types/contract/deployment/zksync/zkDeployDeterministic.d.ts.map +1 -1
- package/dist/types/utils/any-evm/compute-deployment-address.d.ts.map +1 -1
- package/dist/types/utils/any-evm/compute-published-contract-deploy-info.d.ts +3 -0
- package/dist/types/utils/any-evm/compute-published-contract-deploy-info.d.ts.map +1 -1
- package/dist/types/utils/any-evm/get-init-bytecode-with-salt.d.ts.map +1 -1
- package/dist/types/utils/any-evm/zksync/computeDeploymentAddress.d.ts +1 -1
- package/dist/types/utils/any-evm/zksync/computeDeploymentAddress.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +1 -1
- package/src/adapters/viem-legacy.test.ts +159 -0
- package/src/adapters/viem.test.ts +30 -14
- package/src/adapters/viem.ts +132 -1
- package/src/chains/chain-definitions/arbitrum-nova.ts +1 -1
- package/src/contract/deployment/deploy-deterministic.test.ts +45 -2
- package/src/contract/deployment/zksync/zkDeployDeterministic.ts +10 -2
- package/src/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.tsx +6 -21
- package/src/react/web/ui/ConnectWallet/screens/Buy/swap/TokenSelectorScreen.tsx +71 -9
- package/src/utils/any-evm/compute-deployment-address.ts +4 -1
- package/src/utils/any-evm/compute-published-contract-deploy-info.ts +1 -0
- package/src/utils/any-evm/get-init-bytecode-with-salt.ts +5 -2
- package/src/utils/any-evm/zksync/computeDeploymentAddress.ts +6 -2
- package/src/version.ts +1 -1
@@ -3,7 +3,7 @@ import { type GetContractReturnType, type PublicClient, type WalletClient } from
|
|
3
3
|
import type { Chain } from "../chains/types.js";
|
4
4
|
import type { ThirdwebClient } from "../client/client.js";
|
5
5
|
import { type ThirdwebContract } from "../contract/contract.js";
|
6
|
-
import type { Account } from "../wallets/interfaces/wallet.js";
|
6
|
+
import type { Account, Wallet } from "../wallets/interfaces/wallet.js";
|
7
7
|
/**
|
8
8
|
* Converts thirdweb accounts and contracts to viem wallet clients and contract objects or the other way around.
|
9
9
|
* @example
|
@@ -129,6 +129,7 @@ export declare const viemAdapter: {
|
|
129
129
|
* walletClient,
|
130
130
|
* });
|
131
131
|
* ```
|
132
|
+
* @deprecated use viemAdapter.wallet instead
|
132
133
|
*/
|
133
134
|
walletClient: {
|
134
135
|
/**
|
@@ -141,6 +142,7 @@ export declare const viemAdapter: {
|
|
141
142
|
* import { viemAdapter } from "thirdweb/adapters";
|
142
143
|
* const walletClient = viemAdapter.walletClient.toViem({ account, client, chain });
|
143
144
|
* ```
|
145
|
+
* @deprecated use viemAdapter.wallet instead
|
144
146
|
*/
|
145
147
|
toViem: typeof toViemWalletClient;
|
146
148
|
/**
|
@@ -153,9 +155,62 @@ export declare const viemAdapter: {
|
|
153
155
|
* import { viemAdapter } from "thirdweb/adapters";
|
154
156
|
* const account = viemAdapter.walletClient.fromViem({ walletClient });
|
155
157
|
* ```
|
158
|
+
* @deprecated use viemAdapter.wallet instead
|
156
159
|
*/
|
157
160
|
fromViem: typeof fromViemWalletClient;
|
158
161
|
};
|
162
|
+
/**
|
163
|
+
* Converts a thirdweb account to a Viem Wallet client or the other way around.
|
164
|
+
* @param options - The options for creating the Viem Wallet client.
|
165
|
+
* @returns The Viem Wallet client.
|
166
|
+
* @example
|
167
|
+
*
|
168
|
+
* ### toViem
|
169
|
+
* ```ts
|
170
|
+
* import { viemAdapter } from "thirdweb/adapters/viem";
|
171
|
+
*
|
172
|
+
* const walletClient = viemAdapter.wallet.toViem({
|
173
|
+
* wallet,
|
174
|
+
* client,
|
175
|
+
* chain: ethereum,
|
176
|
+
* });
|
177
|
+
* ```
|
178
|
+
*
|
179
|
+
* ### fromViem
|
180
|
+
* ```ts
|
181
|
+
* import { viemAdapter } from "thirdweb/adapters";
|
182
|
+
*
|
183
|
+
* const wallet = viemAdapter.wallet.fromViem({
|
184
|
+
* walletClient,
|
185
|
+
* });
|
186
|
+
* ```
|
187
|
+
*/
|
188
|
+
wallet: {
|
189
|
+
/**
|
190
|
+
* Converts a Thirdweb wallet to a Viem wallet client.
|
191
|
+
* @param options - The options for converting a Thirdweb wallet to a Viem wallet client.
|
192
|
+
* @param options.wallet - The Thirdweb wallet to convert.
|
193
|
+
* @returns A Promise that resolves to a Viem wallet client.
|
194
|
+
* @example
|
195
|
+
* ```ts
|
196
|
+
* import { viemAdapter } from "thirdweb/adapters";
|
197
|
+
* const walletClient = viemAdapter.wallet.toViem({ wallet, client, chain });
|
198
|
+
* ```
|
199
|
+
*/
|
200
|
+
toViem: typeof walletToViem;
|
201
|
+
/**
|
202
|
+
* Converts a Viem wallet client to a Thirdweb wallet.
|
203
|
+
* @param options - The options for converting a Viem wallet client to a Thirdweb wallet.
|
204
|
+
* @param options.walletClient - The Viem wallet client to convert.
|
205
|
+
* @returns A Promise that resolves to a Thirdweb wallet.
|
206
|
+
* @example
|
207
|
+
* ```ts
|
208
|
+
* import { viemAdapter } from "thirdweb/adapters";
|
209
|
+
* const wallet = viemAdapter.wallet.fromViem({ walletClient });
|
210
|
+
* ```
|
211
|
+
*/
|
212
|
+
fromViem: typeof walletFromViem;
|
213
|
+
};
|
159
214
|
};
|
160
215
|
type FromViemContractOptions<TAbi extends Abi> = {
|
161
216
|
client: ThirdwebClient;
|
@@ -183,5 +238,14 @@ declare function toViemWalletClient(options: ToViemWalletClientOptions): WalletC
|
|
183
238
|
declare function fromViemWalletClient(options: {
|
184
239
|
walletClient: WalletClient;
|
185
240
|
}): Account;
|
241
|
+
type WalletToViemOptions = {
|
242
|
+
client: ThirdwebClient;
|
243
|
+
chain: Chain;
|
244
|
+
wallet: Wallet;
|
245
|
+
};
|
246
|
+
declare function walletToViem(options: WalletToViemOptions): WalletClient;
|
247
|
+
declare function walletFromViem(options: {
|
248
|
+
walletClient: WalletClient;
|
249
|
+
}): Wallet;
|
186
250
|
export {};
|
187
251
|
//# sourceMappingURL=viem.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"viem.d.ts","sourceRoot":"","sources":["../../../src/adapters/viem.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAEL,KAAK,qBAAqB,EAC1B,KAAK,YAAY,EAGjB,KAAK,YAAY,EAIlB,MAAM,MAAM,CAAC;AACd,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1D,OAAO,EAAE,KAAK,gBAAgB,EAAe,MAAM,yBAAyB,CAAC;AAM7E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAC;
|
1
|
+
{"version":3,"file":"viem.d.ts","sourceRoot":"","sources":["../../../src/adapters/viem.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAEL,KAAK,qBAAqB,EAC1B,KAAK,YAAY,EAGjB,KAAK,YAAY,EAIlB,MAAM,MAAM,CAAC;AACd,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1D,OAAO,EAAE,KAAK,gBAAgB,EAAe,MAAM,yBAAyB,CAAC;AAM7E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAC;AAIvE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AACH,eAAO,MAAM,WAAW;IACtB;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;;;;;IAMH;;;;;;;;;;;;;OAaG;;;;IAKH;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;;QAED;;;;;;;;;;;WAWG;;QAEH;;;;;;;;;;;WAWG;;;IAGL;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;;QAED;;;;;;;;;;WAUG;;QAEH;;;;;;;;;;WAUG;;;CAGN,CAAC;AAEF,KAAK,uBAAuB,CAAC,IAAI,SAAS,GAAG,IAAI;IAC/C,MAAM,EAAE,cAAc,CAAC;IACvB,YAAY,EAAE,qBAAqB,CAAC,IAAI,CAAC,CAAC;IAC1C,KAAK,EAAE,KAAK,CAAC;CACd,CAAC;AAEF,iBAAS,gBAAgB,CAAC,KAAK,CAAC,IAAI,SAAS,GAAG,EAC9C,OAAO,EAAE,uBAAuB,CAAC,IAAI,CAAC,GACrC,gBAAgB,CAAC,IAAI,CAAC,CAOxB;AAED;;GAEG;AACH,wBAAsB,cAAc,CAAC,KAAK,CAAC,IAAI,SAAS,GAAG,EAAE,OAAO,EAAE;IACpE,gBAAgB,EAAE,gBAAgB,CAAC,IAAI,CAAC,CAAC;CAC1C,GAAG,OAAO,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC,CAKvC;AAED,KAAK,yBAAyB,GAAG;IAC/B,MAAM,EAAE,cAAc,CAAC;IACvB,KAAK,EAAE,KAAK,CAAC;CACd,CAAC;AAEF,iBAAS,kBAAkB,CAAC,OAAO,EAAE,yBAAyB,GAAG,YAAY,CA2B5E;AAED,KAAK,yBAAyB,GAAG;IAC/B,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,cAAc,CAAC;IACvB,KAAK,EAAE,KAAK,CAAC;CACd,CAAC;AAGF,iBAAS,kBAAkB,CAAC,OAAO,EAAE,yBAAyB,GAAG,YAAY,CA4E5E;AAGD,iBAAS,oBAAoB,CAAC,OAAO,EAAE;IACrC,YAAY,EAAE,YAAY,CAAC;CAC5B,GAAG,OAAO,CAmCV;AAED,KAAK,mBAAmB,GAAG;IACzB,MAAM,EAAE,cAAc,CAAC;IACvB,KAAK,EAAE,KAAK,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,iBAAS,YAAY,CAAC,OAAO,EAAE,mBAAmB,GAAG,YAAY,CAkChE;AAED,iBAAS,cAAc,CAAC,OAAO,EAAE;IAC/B,YAAY,EAAE,YAAY,CAAC;CAC5B,GAAG,MAAM,CAkBT"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"zkDeployDeterministic.d.ts","sourceRoot":"","sources":["../../../../../src/contract/deployment/zksync/zkDeployDeterministic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,GAAG,EAAiC,MAAM,SAAS,CAAC;AAelE,OAAO,
|
1
|
+
{"version":3,"file":"zkDeployDeterministic.d.ts","sourceRoot":"","sources":["../../../../../src/contract/deployment/zksync/zkDeployDeterministic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,GAAG,EAAiC,MAAM,SAAS,CAAC;AAelE,OAAO,EACL,KAAK,GAAG,EAGT,MAAM,gCAAgC,CAAC;AACxC,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AAKxE;;GAEG;AACH,wBAAsB,6BAA6B,CACjD,OAAO,EAAE,wBAAwB,GAAG;IAClC,GAAG,EAAE,GAAG,CAAC;IACT,QAAQ,EAAE,GAAG,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,mBA8EF"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"compute-deployment-address.d.ts","sourceRoot":"","sources":["../../../../src/utils/any-evm/compute-deployment-address.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,GAAG,EAAgB,MAAM,MAAM,CAAC;
|
1
|
+
{"version":3,"file":"compute-deployment-address.d.ts","sourceRoot":"","sources":["../../../../src/utils/any-evm/compute-deployment-address.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,GAAG,EAAgB,MAAM,MAAM,CAAC;AAQ9C,KAAK,+BAA+B,GAAG;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,GAAG,CAAC;IACjB,qBAAqB,EAAE,MAAM,CAAC;IAC9B,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,+BAA+B,UAiCzC"}
|
@@ -19,6 +19,7 @@ export declare function computeDeploymentInfoFromContractId(args: {
|
|
19
19
|
initBytecodeWithsalt: `0x${string}`;
|
20
20
|
encodedArgs: `0x${string}`;
|
21
21
|
create2FactoryAddress: string;
|
22
|
+
salt: string | undefined;
|
22
23
|
}>;
|
23
24
|
/**
|
24
25
|
* @internal
|
@@ -34,6 +35,7 @@ export declare function computeDeploymentInfoFromMetadata(args: {
|
|
34
35
|
initBytecodeWithsalt: `0x${string}`;
|
35
36
|
encodedArgs: `0x${string}`;
|
36
37
|
create2FactoryAddress: string;
|
38
|
+
salt: string | undefined;
|
37
39
|
}>;
|
38
40
|
export declare function computeDeploymentInfoFromBytecode(args: {
|
39
41
|
client: ThirdwebClient;
|
@@ -47,5 +49,6 @@ export declare function computeDeploymentInfoFromBytecode(args: {
|
|
47
49
|
initBytecodeWithsalt: `0x${string}`;
|
48
50
|
encodedArgs: `0x${string}`;
|
49
51
|
create2FactoryAddress: string;
|
52
|
+
salt: string | undefined;
|
50
53
|
}>;
|
51
54
|
//# sourceMappingURL=compute-published-contract-deploy-info.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"compute-published-contract-deploy-info.d.ts","sourceRoot":"","sources":["../../../../src/utils/any-evm/compute-published-contract-deploy-info.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAkB,MAAM,SAAS,CAAC;AACnD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAM7D,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EACL,KAAK,yBAAyB,EAE/B,MAAM,sBAAsB,CAAC;AAG9B;;GAEG;AACH,wBAAsB,mCAAmC,CAAC,IAAI,EAAE;IAC9D,MAAM,EAAE,cAAc,CAAC;IACvB,KAAK,EAAE,KAAK,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC5C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf
|
1
|
+
{"version":3,"file":"compute-published-contract-deploy-info.d.ts","sourceRoot":"","sources":["../../../../src/utils/any-evm/compute-published-contract-deploy-info.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAkB,MAAM,SAAS,CAAC;AACnD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAM7D,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EACL,KAAK,yBAAyB,EAE/B,MAAM,sBAAsB,CAAC;AAG9B;;GAEG;AACH,wBAAsB,mCAAmC,CAAC,IAAI,EAAE;IAC9D,MAAM,EAAE,cAAc,CAAC;IACvB,KAAK,EAAE,KAAK,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC5C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;;;;;;GAeA;AAED;;GAEG;AACH,wBAAsB,iCAAiC,CAAC,IAAI,EAAE;IAC5D,MAAM,EAAE,cAAc,CAAC;IACvB,KAAK,EAAE,KAAK,CAAC;IACb,gBAAgB,EAAE,yBAAyB,CAAC;IAC5C,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC5C,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;;;;;;GAaA;AAED,wBAAsB,iCAAiC,CAAC,IAAI,EAAE;IAC5D,MAAM,EAAE,cAAc,CAAC;IACvB,KAAK,EAAE,KAAK,CAAC;IACb,GAAG,EAAE,GAAG,CAAC;IACT,QAAQ,EAAE,GAAG,CAAC;IACd,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC5C,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;;;;;;GA0BA"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"get-init-bytecode-with-salt.d.ts","sourceRoot":"","sources":["../../../../src/utils/any-evm/get-init-bytecode-with-salt.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,GAAG,
|
1
|
+
{"version":3,"file":"get-init-bytecode-with-salt.d.ts","sourceRoot":"","sources":["../../../../src/utils/any-evm/get-init-bytecode-with-salt.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,GAAG,EAA0B,MAAM,oBAAoB,CAAC;AAItE,KAAK,+BAA+B,GAAG;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,GAAG,GAAG,UAAU,CAAC;IAC9B,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,+BAA+B,GACvC,GAAG,CAkBL"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"computeDeploymentAddress.d.ts","sourceRoot":"","sources":["../../../../../src/utils/any-evm/zksync/computeDeploymentAddress.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,KAAK,
|
1
|
+
{"version":3,"file":"computeDeploymentAddress.d.ts","sourceRoot":"","sources":["../../../../../src/utils/any-evm/zksync/computeDeploymentAddress.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,KAAK,GAAG,EAAS,MAAM,uBAAuB,CAAC;AAIxD,KAAK,+BAA+B,GAAG;IACrC,YAAY,EAAE,GAAG,CAAC;IAClB,WAAW,EAAE,GAAG,CAAC;IACjB,qBAAqB,EAAE,OAAO,CAAC;IAC/B,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,+BAA+B,UAczC"}
|
package/dist/types/version.d.ts
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
export declare const version = "5.88.
|
1
|
+
export declare const version = "5.88.6";
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/package.json
CHANGED
@@ -0,0 +1,159 @@
|
|
1
|
+
import type { Account as ViemAccount } from "viem";
|
2
|
+
import { privateKeyToAccount as viemPrivateKeyToAccount } from "viem/accounts";
|
3
|
+
import { beforeAll, describe, expect, test } from "vitest";
|
4
|
+
import { USDT_ABI } from "~test/abis/usdt.js";
|
5
|
+
import {
|
6
|
+
USDT_CONTRACT_ADDRESS,
|
7
|
+
USDT_CONTRACT_WITH_ABI,
|
8
|
+
} from "~test/test-contracts.js";
|
9
|
+
import { ANVIL_PKEY_A, TEST_ACCOUNT_B } from "~test/test-wallets.js";
|
10
|
+
import { typedData } from "~test/typed-data.js";
|
11
|
+
|
12
|
+
import { ANVIL_CHAIN, FORKED_ETHEREUM_CHAIN } from "../../test/src/chains.js";
|
13
|
+
import { TEST_CLIENT } from "../../test/src/test-clients.js";
|
14
|
+
import { randomBytesBuffer } from "../utils/random.js";
|
15
|
+
import { privateKeyToAccount } from "../wallets/private-key.js";
|
16
|
+
import { toViemContract, viemAdapter } from "./viem.js";
|
17
|
+
|
18
|
+
const account = privateKeyToAccount({
|
19
|
+
privateKey: ANVIL_PKEY_A,
|
20
|
+
client: TEST_CLIENT,
|
21
|
+
});
|
22
|
+
|
23
|
+
describe("walletClient.toViem", () => {
|
24
|
+
let walletClient: ReturnType<typeof viemAdapter.walletClient.toViem>;
|
25
|
+
|
26
|
+
beforeAll(() => {
|
27
|
+
walletClient = viemAdapter.walletClient.toViem({
|
28
|
+
client: TEST_CLIENT,
|
29
|
+
account,
|
30
|
+
chain: ANVIL_CHAIN,
|
31
|
+
});
|
32
|
+
});
|
33
|
+
|
34
|
+
test("should return an viem wallet client", async () => {
|
35
|
+
expect(walletClient).toBeDefined();
|
36
|
+
expect(walletClient.signMessage).toBeDefined();
|
37
|
+
});
|
38
|
+
|
39
|
+
test("should sign message", async () => {
|
40
|
+
if (!walletClient.account) {
|
41
|
+
throw new Error("Account not found");
|
42
|
+
}
|
43
|
+
const expectedSig = await account.signMessage({ message: "hello world" });
|
44
|
+
const sig = await walletClient.signMessage({
|
45
|
+
account: walletClient.account,
|
46
|
+
message: "hello world",
|
47
|
+
});
|
48
|
+
expect(sig).toBe(expectedSig);
|
49
|
+
});
|
50
|
+
|
51
|
+
test("should sign raw message", async () => {
|
52
|
+
if (!walletClient.account) {
|
53
|
+
throw new Error("Account not found");
|
54
|
+
}
|
55
|
+
const bytes = randomBytesBuffer(32);
|
56
|
+
const expectedSig = await account.signMessage({ message: { raw: bytes } });
|
57
|
+
const sig = await walletClient.signMessage({
|
58
|
+
account: walletClient.account,
|
59
|
+
message: { raw: bytes },
|
60
|
+
});
|
61
|
+
expect(sig).toBe(expectedSig);
|
62
|
+
});
|
63
|
+
|
64
|
+
test("should sign typed data", async () => {
|
65
|
+
expect(walletClient.signTypedData).toBeDefined();
|
66
|
+
|
67
|
+
if (!walletClient.account) {
|
68
|
+
throw new Error("Account not found");
|
69
|
+
}
|
70
|
+
|
71
|
+
const signature = await walletClient.signTypedData({
|
72
|
+
...typedData.basic,
|
73
|
+
primaryType: "Mail",
|
74
|
+
account: walletClient.account,
|
75
|
+
});
|
76
|
+
|
77
|
+
expect(signature).toMatchInlineSnapshot(
|
78
|
+
`"0x32f3d5975ba38d6c2fba9b95d5cbed1febaa68003d3d588d51f2de522ad54117760cfc249470a75232552e43991f53953a3d74edf6944553c6bef2469bb9e5921b"`,
|
79
|
+
);
|
80
|
+
});
|
81
|
+
|
82
|
+
test("should contain a json-rpc account", async () => {
|
83
|
+
expect(walletClient.account?.type).toBe("json-rpc");
|
84
|
+
});
|
85
|
+
|
86
|
+
test("should send a transaction", async () => {
|
87
|
+
if (!walletClient.account) {
|
88
|
+
throw new Error("Account not found");
|
89
|
+
}
|
90
|
+
|
91
|
+
const txHash = await walletClient.sendTransaction({
|
92
|
+
account: walletClient.account,
|
93
|
+
chain: {
|
94
|
+
id: ANVIL_CHAIN.id,
|
95
|
+
name: ANVIL_CHAIN.name || "",
|
96
|
+
rpcUrls: {
|
97
|
+
default: { http: [ANVIL_CHAIN.rpc] },
|
98
|
+
},
|
99
|
+
nativeCurrency: {
|
100
|
+
name: ANVIL_CHAIN.nativeCurrency?.name || "Ether",
|
101
|
+
symbol: ANVIL_CHAIN.nativeCurrency?.symbol || "ETH",
|
102
|
+
decimals: ANVIL_CHAIN.nativeCurrency?.decimals || 18,
|
103
|
+
},
|
104
|
+
},
|
105
|
+
to: TEST_ACCOUNT_B.address,
|
106
|
+
value: 10n,
|
107
|
+
});
|
108
|
+
expect(txHash).toBeDefined();
|
109
|
+
expect(txHash.slice(0, 2)).toBe("0x");
|
110
|
+
});
|
111
|
+
|
112
|
+
test("should get address on live chain", async () => {
|
113
|
+
walletClient = viemAdapter.walletClient.toViem({
|
114
|
+
client: TEST_CLIENT,
|
115
|
+
account,
|
116
|
+
chain: FORKED_ETHEREUM_CHAIN,
|
117
|
+
});
|
118
|
+
|
119
|
+
const address = await walletClient.getAddresses();
|
120
|
+
expect(address[0]).toBeDefined();
|
121
|
+
expect(address[0]).toBe(account.address);
|
122
|
+
});
|
123
|
+
|
124
|
+
test("should match thirdweb account signature", async () => {
|
125
|
+
const message = "testing123";
|
126
|
+
|
127
|
+
const rawViemAccount = viemPrivateKeyToAccount(ANVIL_PKEY_A);
|
128
|
+
const twSignature = await account.signMessage({ message });
|
129
|
+
const viemTwSignature = await walletClient.signMessage({
|
130
|
+
message,
|
131
|
+
account: walletClient.account as ViemAccount,
|
132
|
+
});
|
133
|
+
const viemSignature = await rawViemAccount.signMessage({ message });
|
134
|
+
|
135
|
+
expect(viemSignature).toEqual(twSignature);
|
136
|
+
expect(viemTwSignature).toEqual(twSignature);
|
137
|
+
});
|
138
|
+
|
139
|
+
test("should convert thirdweb contract to viem contract", async () => {
|
140
|
+
const result = await toViemContract({
|
141
|
+
thirdwebContract: USDT_CONTRACT_WITH_ABI,
|
142
|
+
});
|
143
|
+
expect(result.abi).toEqual(USDT_ABI);
|
144
|
+
expect(result.address).toBe(USDT_CONTRACT_ADDRESS);
|
145
|
+
});
|
146
|
+
|
147
|
+
test("should throw when switching chain", async () => {
|
148
|
+
await expect(
|
149
|
+
walletClient.switchChain({
|
150
|
+
id: FORKED_ETHEREUM_CHAIN.id,
|
151
|
+
}),
|
152
|
+
).rejects.toThrowErrorMatchingInlineSnapshot(`
|
153
|
+
[UnknownRpcError: An unknown RPC error occurred.
|
154
|
+
|
155
|
+
Details: Can't switch chains because only an account was passed to 'viemAdapter.walletClient.toViem()', please pass a connected wallet instance instead.
|
156
|
+
Version: viem@2.22.17]
|
157
|
+
`);
|
158
|
+
});
|
159
|
+
});
|
@@ -6,27 +6,26 @@ import {
|
|
6
6
|
USDT_CONTRACT_ADDRESS,
|
7
7
|
USDT_CONTRACT_WITH_ABI,
|
8
8
|
} from "~test/test-contracts.js";
|
9
|
-
import {
|
9
|
+
import {
|
10
|
+
ANVIL_PKEY_A,
|
11
|
+
TEST_ACCOUNT_B,
|
12
|
+
TEST_IN_APP_WALLET_A,
|
13
|
+
} from "~test/test-wallets.js";
|
10
14
|
import { typedData } from "~test/typed-data.js";
|
11
|
-
|
12
15
|
import { ANVIL_CHAIN, FORKED_ETHEREUM_CHAIN } from "../../test/src/chains.js";
|
13
16
|
import { TEST_CLIENT } from "../../test/src/test-clients.js";
|
14
17
|
import { randomBytesBuffer } from "../utils/random.js";
|
15
|
-
import { privateKeyToAccount } from "../wallets/private-key.js";
|
16
18
|
import { toViemContract, viemAdapter } from "./viem.js";
|
17
19
|
|
18
|
-
const
|
19
|
-
privateKey: ANVIL_PKEY_A,
|
20
|
-
client: TEST_CLIENT,
|
21
|
-
});
|
20
|
+
const wallet = TEST_IN_APP_WALLET_A;
|
22
21
|
|
23
22
|
describe("walletClient.toViem", () => {
|
24
|
-
let walletClient: ReturnType<typeof viemAdapter.
|
23
|
+
let walletClient: ReturnType<typeof viemAdapter.wallet.toViem>;
|
25
24
|
|
26
25
|
beforeAll(() => {
|
27
|
-
walletClient = viemAdapter.
|
26
|
+
walletClient = viemAdapter.wallet.toViem({
|
28
27
|
client: TEST_CLIENT,
|
29
|
-
|
28
|
+
wallet,
|
30
29
|
chain: ANVIL_CHAIN,
|
31
30
|
});
|
32
31
|
});
|
@@ -37,7 +36,8 @@ describe("walletClient.toViem", () => {
|
|
37
36
|
});
|
38
37
|
|
39
38
|
test("should sign message", async () => {
|
40
|
-
|
39
|
+
const account = wallet.getAccount();
|
40
|
+
if (!walletClient.account || !account) {
|
41
41
|
throw new Error("Account not found");
|
42
42
|
}
|
43
43
|
const expectedSig = await account.signMessage({ message: "hello world" });
|
@@ -49,7 +49,8 @@ describe("walletClient.toViem", () => {
|
|
49
49
|
});
|
50
50
|
|
51
51
|
test("should sign raw message", async () => {
|
52
|
-
|
52
|
+
const account = wallet.getAccount();
|
53
|
+
if (!walletClient.account || !account) {
|
53
54
|
throw new Error("Account not found");
|
54
55
|
}
|
55
56
|
const bytes = randomBytesBuffer(32);
|
@@ -110,12 +111,16 @@ describe("walletClient.toViem", () => {
|
|
110
111
|
});
|
111
112
|
|
112
113
|
test("should get address on live chain", async () => {
|
113
|
-
walletClient = viemAdapter.
|
114
|
+
walletClient = viemAdapter.wallet.toViem({
|
114
115
|
client: TEST_CLIENT,
|
115
|
-
|
116
|
+
wallet,
|
116
117
|
chain: FORKED_ETHEREUM_CHAIN,
|
117
118
|
});
|
118
119
|
|
120
|
+
const account = wallet.getAccount();
|
121
|
+
if (!walletClient.account || !account) {
|
122
|
+
throw new Error("Account not found");
|
123
|
+
}
|
119
124
|
const address = await walletClient.getAddresses();
|
120
125
|
expect(address[0]).toBeDefined();
|
121
126
|
expect(address[0]).toBe(account.address);
|
@@ -123,6 +128,10 @@ describe("walletClient.toViem", () => {
|
|
123
128
|
|
124
129
|
test("should match thirdweb account signature", async () => {
|
125
130
|
const message = "testing123";
|
131
|
+
const account = wallet.getAccount();
|
132
|
+
if (!walletClient.account || !account) {
|
133
|
+
throw new Error("Account not found");
|
134
|
+
}
|
126
135
|
|
127
136
|
const rawViemAccount = viemPrivateKeyToAccount(ANVIL_PKEY_A);
|
128
137
|
const twSignature = await account.signMessage({ message });
|
@@ -143,4 +152,11 @@ describe("walletClient.toViem", () => {
|
|
143
152
|
expect(result.abi).toEqual(USDT_ABI);
|
144
153
|
expect(result.address).toBe(USDT_CONTRACT_ADDRESS);
|
145
154
|
});
|
155
|
+
|
156
|
+
test("should switch chain", async () => {
|
157
|
+
await walletClient.switchChain({
|
158
|
+
id: FORKED_ETHEREUM_CHAIN.id,
|
159
|
+
});
|
160
|
+
expect(await walletClient.getChainId()).toBe(FORKED_ETHEREUM_CHAIN.id);
|
161
|
+
});
|
146
162
|
});
|
package/src/adapters/viem.ts
CHANGED
@@ -20,7 +20,9 @@ import { estimateGas } from "../transaction/actions/estimate-gas.js";
|
|
20
20
|
import { sendTransaction } from "../transaction/actions/send-transaction.js";
|
21
21
|
import { prepareTransaction } from "../transaction/prepare-transaction.js";
|
22
22
|
import { getAddress } from "../utils/address.js";
|
23
|
-
import type { Account } from "../wallets/interfaces/wallet.js";
|
23
|
+
import type { Account, Wallet } from "../wallets/interfaces/wallet.js";
|
24
|
+
import { fromProvider } from "./eip1193/from-eip1193.js";
|
25
|
+
import { toProvider } from "./eip1193/to-eip1193.js";
|
24
26
|
|
25
27
|
/**
|
26
28
|
* Converts thirdweb accounts and contracts to viem wallet clients and contract objects or the other way around.
|
@@ -149,6 +151,7 @@ export const viemAdapter = {
|
|
149
151
|
* walletClient,
|
150
152
|
* });
|
151
153
|
* ```
|
154
|
+
* @deprecated use viemAdapter.wallet instead
|
152
155
|
*/
|
153
156
|
walletClient: {
|
154
157
|
/**
|
@@ -161,6 +164,7 @@ export const viemAdapter = {
|
|
161
164
|
* import { viemAdapter } from "thirdweb/adapters";
|
162
165
|
* const walletClient = viemAdapter.walletClient.toViem({ account, client, chain });
|
163
166
|
* ```
|
167
|
+
* @deprecated use viemAdapter.wallet instead
|
164
168
|
*/
|
165
169
|
toViem: toViemWalletClient,
|
166
170
|
/**
|
@@ -173,9 +177,62 @@ export const viemAdapter = {
|
|
173
177
|
* import { viemAdapter } from "thirdweb/adapters";
|
174
178
|
* const account = viemAdapter.walletClient.fromViem({ walletClient });
|
175
179
|
* ```
|
180
|
+
* @deprecated use viemAdapter.wallet instead
|
176
181
|
*/
|
177
182
|
fromViem: fromViemWalletClient,
|
178
183
|
},
|
184
|
+
/**
|
185
|
+
* Converts a thirdweb account to a Viem Wallet client or the other way around.
|
186
|
+
* @param options - The options for creating the Viem Wallet client.
|
187
|
+
* @returns The Viem Wallet client.
|
188
|
+
* @example
|
189
|
+
*
|
190
|
+
* ### toViem
|
191
|
+
* ```ts
|
192
|
+
* import { viemAdapter } from "thirdweb/adapters/viem";
|
193
|
+
*
|
194
|
+
* const walletClient = viemAdapter.wallet.toViem({
|
195
|
+
* wallet,
|
196
|
+
* client,
|
197
|
+
* chain: ethereum,
|
198
|
+
* });
|
199
|
+
* ```
|
200
|
+
*
|
201
|
+
* ### fromViem
|
202
|
+
* ```ts
|
203
|
+
* import { viemAdapter } from "thirdweb/adapters";
|
204
|
+
*
|
205
|
+
* const wallet = viemAdapter.wallet.fromViem({
|
206
|
+
* walletClient,
|
207
|
+
* });
|
208
|
+
* ```
|
209
|
+
*/
|
210
|
+
wallet: {
|
211
|
+
/**
|
212
|
+
* Converts a Thirdweb wallet to a Viem wallet client.
|
213
|
+
* @param options - The options for converting a Thirdweb wallet to a Viem wallet client.
|
214
|
+
* @param options.wallet - The Thirdweb wallet to convert.
|
215
|
+
* @returns A Promise that resolves to a Viem wallet client.
|
216
|
+
* @example
|
217
|
+
* ```ts
|
218
|
+
* import { viemAdapter } from "thirdweb/adapters";
|
219
|
+
* const walletClient = viemAdapter.wallet.toViem({ wallet, client, chain });
|
220
|
+
* ```
|
221
|
+
*/
|
222
|
+
toViem: walletToViem,
|
223
|
+
/**
|
224
|
+
* Converts a Viem wallet client to a Thirdweb wallet.
|
225
|
+
* @param options - The options for converting a Viem wallet client to a Thirdweb wallet.
|
226
|
+
* @param options.walletClient - The Viem wallet client to convert.
|
227
|
+
* @returns A Promise that resolves to a Thirdweb wallet.
|
228
|
+
* @example
|
229
|
+
* ```ts
|
230
|
+
* import { viemAdapter } from "thirdweb/adapters";
|
231
|
+
* const wallet = viemAdapter.wallet.fromViem({ walletClient });
|
232
|
+
* ```
|
233
|
+
*/
|
234
|
+
fromViem: walletFromViem,
|
235
|
+
},
|
179
236
|
};
|
180
237
|
|
181
238
|
type FromViemContractOptions<TAbi extends Abi> = {
|
@@ -247,6 +304,7 @@ type ToViemWalletClientOptions = {
|
|
247
304
|
chain: Chain;
|
248
305
|
};
|
249
306
|
|
307
|
+
// DEPRECATED
|
250
308
|
function toViemWalletClient(options: ToViemWalletClientOptions): WalletClient {
|
251
309
|
const { account, chain, client } = options;
|
252
310
|
if (!account) {
|
@@ -305,6 +363,14 @@ function toViemWalletClient(options: ToViemWalletClientOptions): WalletClient {
|
|
305
363
|
if (request.method === "eth_accounts") {
|
306
364
|
return [account.address];
|
307
365
|
}
|
366
|
+
if (
|
367
|
+
request.method === "wallet_switchEthereumChain" ||
|
368
|
+
request.method === "wallet_addEthereumChain"
|
369
|
+
) {
|
370
|
+
throw new Error(
|
371
|
+
"Can't switch chains because only an account was passed to 'viemAdapter.walletClient.toViem()', please pass a connected wallet instance instead.",
|
372
|
+
);
|
373
|
+
}
|
308
374
|
return rpcClient(request);
|
309
375
|
},
|
310
376
|
});
|
@@ -317,6 +383,7 @@ function toViemWalletClient(options: ToViemWalletClientOptions): WalletClient {
|
|
317
383
|
});
|
318
384
|
}
|
319
385
|
|
386
|
+
// DEPRECATED
|
320
387
|
function fromViemWalletClient(options: {
|
321
388
|
walletClient: WalletClient;
|
322
389
|
}): Account {
|
@@ -355,3 +422,67 @@ function fromViemWalletClient(options: {
|
|
355
422
|
},
|
356
423
|
};
|
357
424
|
}
|
425
|
+
|
426
|
+
type WalletToViemOptions = {
|
427
|
+
client: ThirdwebClient;
|
428
|
+
chain: Chain;
|
429
|
+
wallet: Wallet;
|
430
|
+
};
|
431
|
+
|
432
|
+
function walletToViem(options: WalletToViemOptions): WalletClient {
|
433
|
+
const { wallet, chain, client } = options;
|
434
|
+
|
435
|
+
if (!wallet.getAccount()) {
|
436
|
+
throw new Error("Wallet is not connected.");
|
437
|
+
}
|
438
|
+
|
439
|
+
const rpcUrl = getRpcUrlForChain({ chain, client });
|
440
|
+
const viemChain: ViemChain = {
|
441
|
+
id: chain.id,
|
442
|
+
name: chain.name || "",
|
443
|
+
rpcUrls: {
|
444
|
+
default: { http: [rpcUrl] },
|
445
|
+
},
|
446
|
+
nativeCurrency: {
|
447
|
+
name: chain.nativeCurrency?.name || "Ether",
|
448
|
+
symbol: chain.nativeCurrency?.symbol || "ETH",
|
449
|
+
decimals: chain.nativeCurrency?.decimals || 18,
|
450
|
+
},
|
451
|
+
};
|
452
|
+
|
453
|
+
const eip1193Provider = toProvider({
|
454
|
+
chain,
|
455
|
+
client,
|
456
|
+
wallet,
|
457
|
+
});
|
458
|
+
return createWalletClient({
|
459
|
+
transport: custom({
|
460
|
+
request: (request) => eip1193Provider.request(request),
|
461
|
+
}),
|
462
|
+
account: wallet.getAccount()?.address,
|
463
|
+
chain: viemChain,
|
464
|
+
key: "thirdweb-wallet",
|
465
|
+
});
|
466
|
+
}
|
467
|
+
|
468
|
+
function walletFromViem(options: {
|
469
|
+
walletClient: WalletClient;
|
470
|
+
}): Wallet {
|
471
|
+
const viemAccount = options.walletClient.account;
|
472
|
+
if (!viemAccount) {
|
473
|
+
throw new Error(
|
474
|
+
"Account not found in walletClient, please pass it explicitly.",
|
475
|
+
);
|
476
|
+
}
|
477
|
+
|
478
|
+
const wallet = fromProvider({
|
479
|
+
provider: {
|
480
|
+
request: (request) => options.walletClient.request(request),
|
481
|
+
on: () => {},
|
482
|
+
removeListener: () => {},
|
483
|
+
},
|
484
|
+
walletId: "adapter",
|
485
|
+
});
|
486
|
+
|
487
|
+
return wallet;
|
488
|
+
}
|