thirdweb 5.97.2 → 5.97.3

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.
Files changed (112) hide show
  1. package/dist/cjs/contract/verification/constructor-params.js +1 -1
  2. package/dist/cjs/contract/verification/constructor-params.js.map +1 -1
  3. package/dist/cjs/engine/get-status.js +110 -0
  4. package/dist/cjs/engine/get-status.js.map +1 -0
  5. package/dist/cjs/engine/index.js +9 -0
  6. package/dist/cjs/engine/index.js.map +1 -0
  7. package/dist/cjs/engine/server-wallet.js +214 -0
  8. package/dist/cjs/engine/server-wallet.js.map +1 -0
  9. package/dist/cjs/exports/engine.js +5 -0
  10. package/dist/cjs/exports/engine.js.map +1 -0
  11. package/dist/cjs/exports/thirdweb.js +6 -2
  12. package/dist/cjs/exports/thirdweb.js.map +1 -1
  13. package/dist/cjs/extensions/prebuilts/get-required-transactions.js +5 -5
  14. package/dist/cjs/extensions/prebuilts/get-required-transactions.js.map +1 -1
  15. package/dist/cjs/react/web/ui/prebuilt/NFT/utils.js +1 -0
  16. package/dist/cjs/react/web/ui/prebuilt/NFT/utils.js.map +1 -1
  17. package/dist/cjs/react/web/wallets/in-app/InAppWalletConnectUI.js +1 -1
  18. package/dist/cjs/react/web/wallets/in-app/InAppWalletConnectUI.js.map +1 -1
  19. package/dist/cjs/storage/upload/mobile.js +1 -1
  20. package/dist/cjs/storage/upload/mobile.js.map +1 -1
  21. package/dist/cjs/utils/domains.js +3 -0
  22. package/dist/cjs/utils/domains.js.map +1 -1
  23. package/dist/cjs/utils/fetch.js +7 -3
  24. package/dist/cjs/utils/fetch.js.map +1 -1
  25. package/dist/cjs/version.js +1 -1
  26. package/dist/cjs/wallets/engine/index.js +1 -0
  27. package/dist/cjs/wallets/engine/index.js.map +1 -1
  28. package/dist/cjs/wallets/smart/lib/calls.js +2 -2
  29. package/dist/cjs/wallets/smart/lib/calls.js.map +1 -1
  30. package/dist/cjs/wallets/smart/lib/paymaster.js +2 -2
  31. package/dist/cjs/wallets/smart/lib/paymaster.js.map +1 -1
  32. package/dist/esm/contract/verification/constructor-params.js +1 -1
  33. package/dist/esm/contract/verification/constructor-params.js.map +1 -1
  34. package/dist/esm/engine/get-status.js +106 -0
  35. package/dist/esm/engine/get-status.js.map +1 -0
  36. package/dist/esm/engine/index.js +3 -0
  37. package/dist/esm/engine/index.js.map +1 -0
  38. package/dist/esm/engine/server-wallet.js +211 -0
  39. package/dist/esm/engine/server-wallet.js.map +1 -0
  40. package/dist/esm/exports/engine.js +2 -0
  41. package/dist/esm/exports/engine.js.map +1 -0
  42. package/dist/esm/exports/thirdweb.js +4 -0
  43. package/dist/esm/exports/thirdweb.js.map +1 -1
  44. package/dist/esm/extensions/prebuilts/get-required-transactions.js +5 -5
  45. package/dist/esm/extensions/prebuilts/get-required-transactions.js.map +1 -1
  46. package/dist/esm/react/web/ui/prebuilt/NFT/utils.js +1 -0
  47. package/dist/esm/react/web/ui/prebuilt/NFT/utils.js.map +1 -1
  48. package/dist/esm/react/web/wallets/in-app/InAppWalletConnectUI.js +1 -1
  49. package/dist/esm/react/web/wallets/in-app/InAppWalletConnectUI.js.map +1 -1
  50. package/dist/esm/storage/upload/mobile.js +1 -1
  51. package/dist/esm/storage/upload/mobile.js.map +1 -1
  52. package/dist/esm/utils/domains.js +3 -0
  53. package/dist/esm/utils/domains.js.map +1 -1
  54. package/dist/esm/utils/fetch.js +7 -3
  55. package/dist/esm/utils/fetch.js.map +1 -1
  56. package/dist/esm/version.js +1 -1
  57. package/dist/esm/wallets/engine/index.js +1 -0
  58. package/dist/esm/wallets/engine/index.js.map +1 -1
  59. package/dist/esm/wallets/smart/lib/calls.js +2 -2
  60. package/dist/esm/wallets/smart/lib/calls.js.map +1 -1
  61. package/dist/esm/wallets/smart/lib/paymaster.js +2 -2
  62. package/dist/esm/wallets/smart/lib/paymaster.js.map +1 -1
  63. package/dist/types/engine/get-status.d.ts +81 -0
  64. package/dist/types/engine/get-status.d.ts.map +1 -0
  65. package/dist/types/engine/index.d.ts +3 -0
  66. package/dist/types/engine/index.d.ts.map +1 -0
  67. package/dist/types/engine/server-wallet.d.ts +95 -0
  68. package/dist/types/engine/server-wallet.d.ts.map +1 -0
  69. package/dist/types/exports/engine.d.ts +2 -0
  70. package/dist/types/exports/engine.d.ts.map +1 -0
  71. package/dist/types/exports/thirdweb.d.ts +4 -0
  72. package/dist/types/exports/thirdweb.d.ts.map +1 -1
  73. package/dist/types/react/native/ui/prebuilt/Account/balance.d.ts +1 -1
  74. package/dist/types/react/native/ui/prebuilt/Wallet/name.d.ts +1 -1
  75. package/dist/types/react/web/ui/prebuilt/Account/balance.d.ts +1 -1
  76. package/dist/types/react/web/ui/prebuilt/Chain/name.d.ts +1 -1
  77. package/dist/types/react/web/ui/prebuilt/NFT/utils.d.ts.map +1 -1
  78. package/dist/types/react/web/ui/prebuilt/Token/name.d.ts +1 -1
  79. package/dist/types/react/web/ui/prebuilt/Token/symbol.d.ts +1 -1
  80. package/dist/types/react/web/ui/prebuilt/Wallet/name.d.ts +1 -1
  81. package/dist/types/utils/domains.d.ts +6 -0
  82. package/dist/types/utils/domains.d.ts.map +1 -1
  83. package/dist/types/utils/fetch.d.ts.map +1 -1
  84. package/dist/types/version.d.ts +1 -1
  85. package/dist/types/wallets/engine/index.d.ts +1 -0
  86. package/dist/types/wallets/engine/index.d.ts.map +1 -1
  87. package/package.json +7 -1
  88. package/src/contract/verification/constructor-params.ts +1 -1
  89. package/src/engine/get-status.ts +180 -0
  90. package/src/engine/index.ts +11 -0
  91. package/src/engine/server-wallet.test.ts +196 -0
  92. package/src/engine/server-wallet.ts +284 -0
  93. package/src/exports/engine.ts +1 -0
  94. package/src/exports/thirdweb.ts +5 -0
  95. package/src/extensions/prebuilts/get-required-transactions.ts +5 -5
  96. package/src/react/native/ui/prebuilt/Account/balance.tsx +1 -1
  97. package/src/react/native/ui/prebuilt/Wallet/name.tsx +1 -1
  98. package/src/react/web/ui/prebuilt/Account/balance.tsx +1 -1
  99. package/src/react/web/ui/prebuilt/Chain/name.tsx +1 -1
  100. package/src/react/web/ui/prebuilt/NFT/utils.ts +1 -0
  101. package/src/react/web/ui/prebuilt/Token/name.tsx +1 -1
  102. package/src/react/web/ui/prebuilt/Token/symbol.tsx +1 -1
  103. package/src/react/web/ui/prebuilt/Wallet/name.tsx +1 -1
  104. package/src/react/web/wallets/in-app/InAppWalletConnectUI.tsx +1 -1
  105. package/src/storage/upload/mobile.ts +1 -1
  106. package/src/utils/domain.test.ts +1 -0
  107. package/src/utils/domains.ts +9 -0
  108. package/src/utils/fetch.ts +11 -3
  109. package/src/version.ts +1 -1
  110. package/src/wallets/engine/index.ts +1 -0
  111. package/src/wallets/smart/lib/calls.ts +2 -2
  112. package/src/wallets/smart/lib/paymaster.ts +2 -2
@@ -0,0 +1,284 @@
1
+ import {
2
+ type AaExecutionOptions,
3
+ type AaZksyncExecutionOptions,
4
+ sendTransaction,
5
+ signMessage,
6
+ signTypedData,
7
+ } from "@thirdweb-dev/engine";
8
+ import type { Chain } from "../chains/types.js";
9
+ import type { ThirdwebClient } from "../client/client.js";
10
+ import { encode } from "../transaction/actions/encode.js";
11
+ import { toSerializableTransaction } from "../transaction/actions/to-serializable-transaction.js";
12
+ import type { PreparedTransaction } from "../transaction/prepare-transaction.js";
13
+ import { getThirdwebBaseUrl } from "../utils/domains.js";
14
+ import { type Hex, toHex } from "../utils/encoding/hex.js";
15
+ import { getClientFetch } from "../utils/fetch.js";
16
+ import { stringify } from "../utils/json.js";
17
+ import { resolvePromisedValue } from "../utils/promise/resolve-promised-value.js";
18
+ import type {
19
+ Account,
20
+ SendTransactionOption,
21
+ } from "../wallets/interfaces/wallet.js";
22
+ import { waitForTransactionHash } from "./get-status.js";
23
+
24
+ /**
25
+ * Options for creating an server wallet.
26
+ */
27
+ export type ServerWalletOptions = {
28
+ /**
29
+ * The thirdweb client to use for authentication to thirdweb services.
30
+ */
31
+ client: ThirdwebClient;
32
+ /**
33
+ * The vault access token to use your server wallet.
34
+ */
35
+ vaultAccessToken: string;
36
+ /**
37
+ * The server wallet address to use for sending transactions inside engine.
38
+ */
39
+ address: string;
40
+ /**
41
+ * The chain to use for signing messages and typed data (smart server wallet only).
42
+ */
43
+ chain?: Chain;
44
+ /**
45
+ * Optional custom execution options to use for sending transactions and signing data.
46
+ */
47
+ executionOptions?:
48
+ | Omit<AaExecutionOptions, "chainId">
49
+ | Omit<AaZksyncExecutionOptions, "chainId">;
50
+ };
51
+
52
+ export type ServerWallet = Account & {
53
+ enqueueTransaction: (args: {
54
+ transaction: PreparedTransaction;
55
+ simulate?: boolean;
56
+ }) => Promise<{ transactionId: string }>;
57
+ };
58
+
59
+ /**
60
+ * Create a server wallet for sending transactions and signing messages via engine (v3+).
61
+ * @param options - The server wallet options.
62
+ * @returns An account object that can be used to send transactions and sign messages.
63
+ * @engine
64
+ * @example
65
+ * ### Creating a server wallet
66
+ * ```ts
67
+ * import { Engine } from "thirdweb";
68
+ *
69
+ * const client = createThirdwebClient({
70
+ * secretKey: "<your-project-secret-key>",
71
+ * });
72
+ *
73
+ * const myServerWallet = Engine.serverWallet({
74
+ * client,
75
+ * address: "<your-server-wallet-address>",
76
+ * vaultAccessToken: "<your-vault-access-token>",
77
+ * });
78
+ * ```
79
+ *
80
+ * ### Sending a transaction
81
+ * ```ts
82
+ * // prepare the transaction
83
+ * const transaction = claimTo({
84
+ * contract,
85
+ * to: "0x...",
86
+ * quantity: 1n,
87
+ * });
88
+ *
89
+ * // enqueue the transaction
90
+ * const { transactionId } = await myServerWallet.enqueueTransaction({
91
+ * transaction,
92
+ * });
93
+ * ```
94
+ *
95
+ * ### Polling for the transaction to be submitted onchain
96
+ * ```ts
97
+ * // optionally poll for the transaction to be submitted onchain
98
+ * const { transactionHash } = await Engine.waitForTransactionHash({
99
+ * client,
100
+ * transactionId,
101
+ * });
102
+ * console.log("Transaction sent:", transactionHash);
103
+ * ```
104
+ *
105
+ * ### Getting the execution status of a transaction
106
+ * ```ts
107
+ * const executionResult = await Engine.getTransactionStatus({
108
+ * client,
109
+ * transactionId,
110
+ * });
111
+ * console.log("Transaction status:", executionResult.status);
112
+ * ```
113
+ */
114
+ export function serverWallet(options: ServerWalletOptions): ServerWallet {
115
+ const { client, vaultAccessToken, address, chain, executionOptions } =
116
+ options;
117
+ const headers: HeadersInit = {
118
+ "x-vault-access-token": vaultAccessToken,
119
+ };
120
+
121
+ const getExecutionOptions = (chainId: number) => {
122
+ return executionOptions
123
+ ? {
124
+ ...executionOptions,
125
+ chainId: chainId.toString(),
126
+ }
127
+ : {
128
+ from: address,
129
+ chainId: chainId.toString(),
130
+ };
131
+ };
132
+
133
+ const enqueueTx = async (transaction: SendTransactionOption) => {
134
+ const body = {
135
+ executionOptions: getExecutionOptions(transaction.chainId),
136
+ params: [
137
+ {
138
+ to: transaction.to ?? undefined,
139
+ data: transaction.data,
140
+ value: transaction.value?.toString(),
141
+ },
142
+ ],
143
+ };
144
+
145
+ const result = await sendTransaction({
146
+ baseUrl: getThirdwebBaseUrl("engineCloud"),
147
+ fetch: getClientFetch(client),
148
+ headers,
149
+ body,
150
+ });
151
+
152
+ if (result.error) {
153
+ throw new Error(`Error sending transaction: ${result.error}`);
154
+ }
155
+
156
+ const data = result.data?.result;
157
+ if (!data) {
158
+ throw new Error("No data returned from engine");
159
+ }
160
+ const transactionId = data.transactions?.[0]?.id;
161
+ if (!transactionId) {
162
+ throw new Error("No transactionId returned from engine");
163
+ }
164
+ return transactionId;
165
+ };
166
+
167
+ return {
168
+ address,
169
+ enqueueTransaction: async (args: {
170
+ transaction: PreparedTransaction;
171
+ simulate?: boolean;
172
+ }) => {
173
+ let serializedTransaction: SendTransactionOption;
174
+ if (args.simulate) {
175
+ serializedTransaction = await toSerializableTransaction({
176
+ transaction: args.transaction,
177
+ });
178
+ } else {
179
+ const [to, data, value] = await Promise.all([
180
+ args.transaction.to
181
+ ? resolvePromisedValue(args.transaction.to)
182
+ : null,
183
+ encode(args.transaction),
184
+ args.transaction.value
185
+ ? resolvePromisedValue(args.transaction.value)
186
+ : null,
187
+ ]);
188
+ serializedTransaction = {
189
+ chainId: args.transaction.chain.id,
190
+ data,
191
+ to: to ?? undefined,
192
+ value: value ?? undefined,
193
+ };
194
+ }
195
+ const transactionId = await enqueueTx(serializedTransaction);
196
+ return { transactionId };
197
+ },
198
+ sendTransaction: async (transaction: SendTransactionOption) => {
199
+ const transactionId = await enqueueTx(transaction);
200
+ return waitForTransactionHash({
201
+ client,
202
+ transactionId,
203
+ });
204
+ },
205
+ signMessage: async (data) => {
206
+ const { message, chainId } = data;
207
+ let engineMessage: string | Hex;
208
+ let isBytes = false;
209
+ if (typeof message === "string") {
210
+ engineMessage = message;
211
+ } else {
212
+ engineMessage = toHex(message.raw);
213
+ isBytes = true;
214
+ }
215
+
216
+ const signingChainId = chainId || chain?.id;
217
+ if (!signingChainId) {
218
+ throw new Error("Chain ID is required for signing messages");
219
+ }
220
+
221
+ const signResult = await signMessage({
222
+ baseUrl: getThirdwebBaseUrl("engineCloud"),
223
+ fetch: getClientFetch(client),
224
+ headers,
225
+ body: {
226
+ executionOptions: getExecutionOptions(signingChainId),
227
+ params: [
228
+ {
229
+ message: engineMessage,
230
+ messageFormat: isBytes ? "hex" : "text",
231
+ },
232
+ ],
233
+ },
234
+ });
235
+
236
+ if (signResult.error) {
237
+ throw new Error(
238
+ `Error signing message: ${stringify(signResult.error)}`,
239
+ );
240
+ }
241
+
242
+ const signatureResult = signResult.data?.result.results[0];
243
+ if (signatureResult?.success) {
244
+ return signatureResult.result.signature as Hex;
245
+ }
246
+
247
+ throw new Error(
248
+ `Failed to sign message: ${signatureResult?.error?.message || "Unknown error"}`,
249
+ );
250
+ },
251
+ signTypedData: async (typedData) => {
252
+ const signingChainId = chain?.id;
253
+ if (!signingChainId) {
254
+ throw new Error("Chain ID is required for signing messages");
255
+ }
256
+
257
+ const signResult = await signTypedData({
258
+ baseUrl: getThirdwebBaseUrl("engineCloud"),
259
+ fetch: getClientFetch(client),
260
+ headers,
261
+ body: {
262
+ executionOptions: getExecutionOptions(signingChainId),
263
+ // biome-ignore lint/suspicious/noExplicitAny: TODO: fix ts / hey-api type clash
264
+ params: [typedData as any],
265
+ },
266
+ });
267
+
268
+ if (signResult.error) {
269
+ throw new Error(
270
+ `Error signing message: ${stringify(signResult.error)}`,
271
+ );
272
+ }
273
+
274
+ const signatureResult = signResult.data?.result.results[0];
275
+ if (signatureResult?.success) {
276
+ return signatureResult.result.signature as Hex;
277
+ }
278
+
279
+ throw new Error(
280
+ `Failed to sign message: ${signatureResult?.error?.message || "Unknown error"}`,
281
+ );
282
+ },
283
+ };
284
+ }
@@ -0,0 +1 @@
1
+ export * from "../engine/index.js";
@@ -81,6 +81,11 @@ export * as Bridge from "../bridge/index.js";
81
81
  */
82
82
  export * as Insight from "../insight/index.js";
83
83
 
84
+ /**
85
+ * ENGINE
86
+ */
87
+ export * as Engine from "../engine/index.js";
88
+
84
89
  /**
85
90
  * WALLETS
86
91
  */
@@ -178,7 +178,7 @@ async function getTransactionsForMaketplaceV3(options: {
178
178
  client: ThirdwebClient;
179
179
  }): Promise<DeployTransactionResult[]> {
180
180
  const { chain, client } = options;
181
- const WETHAdress = await computePublishedContractAddress({
181
+ const WETHAddress = await computePublishedContractAddress({
182
182
  chain,
183
183
  client,
184
184
  contractId: "WETH9",
@@ -195,7 +195,7 @@ async function getTransactionsForMaketplaceV3(options: {
195
195
  chain,
196
196
  client,
197
197
  contractId: "DirectListingsLogic",
198
- constructorParams: { _nativeTokenWrapper: WETHAdress },
198
+ constructorParams: { _nativeTokenWrapper: WETHAddress },
199
199
  }).then((c) =>
200
200
  c
201
201
  ? null
@@ -205,7 +205,7 @@ async function getTransactionsForMaketplaceV3(options: {
205
205
  chain,
206
206
  client,
207
207
  contractId: "EnglishAuctionsLogic",
208
- constructorParams: { _nativeTokenWrapper: WETHAdress },
208
+ constructorParams: { _nativeTokenWrapper: WETHAddress },
209
209
  }).then((c) =>
210
210
  c
211
211
  ? null
@@ -233,7 +233,7 @@ async function getTransactionsForDynamicContract(options: {
233
233
  deployMetadata: FetchDeployMetadataResult;
234
234
  }): Promise<DeployTransactionResult[]> {
235
235
  const { chain, client } = options;
236
- const WETHAdress = await computePublishedContractAddress({
236
+ const WETHAddress = await computePublishedContractAddress({
237
237
  chain,
238
238
  client,
239
239
  contractId: "WETH9",
@@ -255,7 +255,7 @@ async function getTransactionsForDynamicContract(options: {
255
255
  contractId: e.extensionName,
256
256
  publisher: e.publisherAddress,
257
257
  version: e.extensionVersion || "latest",
258
- constructorParams: { _nativeTokenWrapper: WETHAdress },
258
+ constructorParams: { _nativeTokenWrapper: WETHAddress },
259
259
  }).then((c) =>
260
260
  c
261
261
  ? null
@@ -55,7 +55,7 @@ export interface AccountBalanceProps extends Omit<TextProps, "children"> {
55
55
  * If not passed, the component will return `null`.
56
56
  *
57
57
  * You can/should pass a descriptive text/component to this prop, indicating that the
58
- * balance was not fetched succesfully
58
+ * balance was not fetched successfully
59
59
  * @example
60
60
  * ```tsx
61
61
  * <AccountBalance
@@ -25,7 +25,7 @@ export interface WalletNameProps extends Omit<TextProps, "children"> {
25
25
  * If not passed, the component will return `null`.
26
26
  *
27
27
  * You can/should pass a descriptive text/component to this prop, indicating that the
28
- * name was not fetched succesfully
28
+ * name was not fetched successfully
29
29
  * @example
30
30
  * ```tsx
31
31
  * <WalletName fallbackComponent={<span>Failed to load</span>}
@@ -57,7 +57,7 @@ export interface AccountBalanceProps
57
57
  * If not passed, the component will return `null`.
58
58
  *
59
59
  * You can/should pass a descriptive text/component to this prop, indicating that the
60
- * balance was not fetched succesfully
60
+ * balance was not fetched successfully
61
61
  * @example
62
62
  * ```tsx
63
63
  * <AccountBalance
@@ -45,7 +45,7 @@ export interface ChainNameProps
45
45
  * If not passed, the component will return `null`.
46
46
  *
47
47
  * You can/should pass a descriptive text/component to this prop, indicating that the
48
- * name was not fetched succesfully
48
+ * name was not fetched successfully
49
49
  * @example
50
50
  * ```tsx
51
51
  * <ChainName fallbackComponent={<span>Failed to load</span>}
@@ -17,6 +17,7 @@ export async function getNFTInfo(options: NFTProviderProps): Promise<NFT> {
17
17
  }),
18
18
  getNFT1155({
19
19
  ...options,
20
+ useIndexer: false, // TODO (insight): switch this call to only call insight once
20
21
  }),
21
22
  ]).then(([possibleNFT721, possibleNFT1155]) => {
22
23
  // getNFT extension always return an NFT object
@@ -50,7 +50,7 @@ export interface TokenNameProps
50
50
  * If not passed, the component will return `null`.
51
51
  *
52
52
  * You can/should pass a descriptive text/component to this prop, indicating that the
53
- * name was not fetched succesfully
53
+ * name was not fetched successfully
54
54
  * @example
55
55
  * ```tsx
56
56
  * <TokenName fallbackComponent={"Failed to load"}
@@ -50,7 +50,7 @@ export interface TokenSymbolProps
50
50
  * If not passed, the component will return `null`.
51
51
  *
52
52
  * You can/should pass a descriptive text/component to this prop, indicating that the
53
- * symbol was not fetched succesfully
53
+ * symbol was not fetched successfully
54
54
  * @example
55
55
  * ```tsx
56
56
  * <TokenSymbol fallbackComponent={"Failed to load"}
@@ -27,7 +27,7 @@ export interface WalletNameProps
27
27
  * If not passed, the component will return `null`.
28
28
  *
29
29
  * You can/should pass a descriptive text/component to this prop, indicating that the
30
- * name was not fetched succesfully
30
+ * name was not fetched successfully
31
31
  * @example
32
32
  * ```tsx
33
33
  * <WalletName fallbackComponent={<span>Failed to load</span>}
@@ -51,7 +51,7 @@ function InAppWalletConnectUI(props: {
51
51
  return <LoadingScreen />;
52
52
  }
53
53
 
54
- // if the the modal starts out with the wallet's connect ui instead of wallet selector - going back to main screen requires staying on the same component and clearing the selection data
54
+ // if the modal starts out with the wallet's connect ui instead of wallet selector - going back to main screen requires staying on the same component and clearing the selection data
55
55
  // otherwise, we go back to the wallet selector by calling props.goBack
56
56
  const goBackToMain = () => {
57
57
  if (initialScreen === props.wallet) {
@@ -104,7 +104,7 @@ export async function uploadBatchMobile(
104
104
  );
105
105
  }
106
106
 
107
- return reject(new Error("Unknown upload error occured"));
107
+ return reject(new Error("Unknown upload error occurred"));
108
108
  });
109
109
 
110
110
  xhr.open("POST", `https://${getThirdwebDomains().storage}/ipfs/upload`);
@@ -16,6 +16,7 @@ describe("Thirdweb Domains", () => {
16
16
  bundler: "bundler.thirdweb.com",
17
17
  analytics: "c.thirdweb.com",
18
18
  insight: "insight.thirdweb.com",
19
+ engineCloud: "engine.thirdweb.com",
19
20
  };
20
21
 
21
22
  beforeEach(() => {
@@ -39,6 +39,11 @@ type DomainOverrides = {
39
39
  * @default "insight.thirdweb.com"
40
40
  */
41
41
  insight?: string;
42
+ /**
43
+ * The base URL for the engine cloud server.
44
+ * @default "engine.thirdweb.com"
45
+ */
46
+ engineCloud?: string;
42
47
  };
43
48
 
44
49
  export const DEFAULT_RPC_URL = "rpc.thirdweb.com";
@@ -49,6 +54,8 @@ const DEFAULT_STORAGE_URL = "storage.thirdweb.com";
49
54
  const DEFAULT_BUNDLER_URL = "bundler.thirdweb.com";
50
55
  const DEFAULT_ANALYTICS_URL = "c.thirdweb.com";
51
56
  const DEFAULT_INSIGHT_URL = "insight.thirdweb.com";
57
+ const DEFAULT_ENGINE_CLOUD_URL = "engine.thirdweb.com";
58
+
52
59
  let domains: { [k in keyof DomainOverrides]-?: string } = {
53
60
  rpc: DEFAULT_RPC_URL,
54
61
  inAppWallet: DEFAULT_IN_APP_WALLET_URL,
@@ -58,6 +65,7 @@ let domains: { [k in keyof DomainOverrides]-?: string } = {
58
65
  bundler: DEFAULT_BUNDLER_URL,
59
66
  analytics: DEFAULT_ANALYTICS_URL,
60
67
  insight: DEFAULT_INSIGHT_URL,
68
+ engineCloud: DEFAULT_ENGINE_CLOUD_URL,
61
69
  };
62
70
 
63
71
  export const setThirdwebDomains = (DomainOverrides: DomainOverrides) => {
@@ -70,6 +78,7 @@ export const setThirdwebDomains = (DomainOverrides: DomainOverrides) => {
70
78
  bundler: DomainOverrides.bundler ?? DEFAULT_BUNDLER_URL,
71
79
  analytics: DomainOverrides.analytics ?? DEFAULT_ANALYTICS_URL,
72
80
  insight: DomainOverrides.insight ?? DEFAULT_INSIGHT_URL,
81
+ engineCloud: DomainOverrides.engineCloud ?? DEFAULT_ENGINE_CLOUD_URL,
73
82
  };
74
83
  };
75
84
 
@@ -27,7 +27,11 @@ export function getClientFetch(client: ThirdwebClient, ecosystem?: Ecosystem) {
27
27
  const { requestTimeoutMs = DEFAULT_REQUEST_TIMEOUT, ...restInit } =
28
28
  init || {};
29
29
 
30
- let headers = restInit.headers ? new Headers(restInit.headers) : undefined;
30
+ let headers = restInit.headers
31
+ ? new Headers(restInit.headers)
32
+ : typeof url === "object"
33
+ ? url.headers
34
+ : undefined;
31
35
  const urlString = typeof url === "string" ? url : url.url;
32
36
 
33
37
  // check if we are making a request to a thirdweb service (we don't want to send any headers to non-thirdweb services)
@@ -60,9 +64,13 @@ export function getClientFetch(client: ThirdwebClient, ecosystem?: Ecosystem) {
60
64
  if (client.teamId) {
61
65
  headers.set("x-team-id", client.teamId);
62
66
  }
63
- } else if (secretKey) {
67
+ }
68
+
69
+ if (secretKey) {
64
70
  headers.set("x-secret-key", secretKey);
65
- } else if (clientId) {
71
+ }
72
+
73
+ if (clientId) {
66
74
  headers.set("x-client-id", clientId);
67
75
  }
68
76
 
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = "5.97.2";
1
+ export const version = "5.97.3";
@@ -42,6 +42,7 @@ export type EngineAccountOptions = {
42
42
 
43
43
  /**
44
44
  * Creates an account that uses your engine backend wallet for sending transactions and signing messages.
45
+ * @deprecated This for v2 dedicated engine instances, for v3 and engine cloud use Engine.serverWallet()
45
46
  *
46
47
  * @param options - The options for the engine account.
47
48
  * @returns An account that uses your engine backend wallet.
@@ -184,7 +184,7 @@ export function prepareExecute(args: {
184
184
  let value = transaction.value || 0n;
185
185
  // special handling of hedera chains, decimals for native value is 8 instead of 18 when passed as contract params
186
186
  if (transaction.chainId === 295 || transaction.chainId === 296) {
187
- value = value / BigInt(10 ** 10);
187
+ value = BigInt(value) / BigInt(10 ** 10);
188
188
  }
189
189
  return prepareContractCall({
190
190
  contract: accountContract,
@@ -220,7 +220,7 @@ export function prepareBatchExecute(args: {
220
220
  const chainId = transactions[0]?.chainId;
221
221
  // special handling of hedera chains, decimals for native value is 8 instead of 18 when passed as contract params
222
222
  if (chainId === 295 || chainId === 296) {
223
- values = values.map((value) => value / BigInt(10 ** 10));
223
+ values = values.map((value) => BigInt(value) / BigInt(10 ** 10));
224
224
  }
225
225
  return prepareContractCall({
226
226
  contract: accountContract,
@@ -82,9 +82,9 @@ export async function getPaymasterAndData(args: {
82
82
  };
83
83
  }
84
84
  // check for policy errors
85
- if (res.result.policyId && res.result.reason) {
85
+ if (res.result.reason) {
86
86
  console.warn(
87
- `Paymaster policy rejected this transaction with reason: ${res.result.reason} (policyId: ${res.result.policyId})`,
87
+ `Paymaster policy rejected this transaction with reason: ${res.result.reason} ${res.result.policyId ? `(policyId: ${res.result.policyId})` : ""}`,
88
88
  );
89
89
  }
90
90