thirdweb 5.100.1 → 5.100.2-nightly-5ab59ff400cc32caa414354855fa07831ed90f3a-20250523000413
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/bridge/Buy.js +15 -3
- package/dist/cjs/bridge/Buy.js.map +1 -1
- package/dist/cjs/bridge/Chains.js +7 -1
- package/dist/cjs/bridge/Chains.js.map +1 -1
- package/dist/cjs/bridge/Onramp.js +11 -2
- package/dist/cjs/bridge/Onramp.js.map +1 -1
- package/dist/cjs/bridge/OnrampStatus.js +7 -1
- package/dist/cjs/bridge/OnrampStatus.js.map +1 -1
- package/dist/cjs/bridge/Routes.js +7 -1
- package/dist/cjs/bridge/Routes.js.map +1 -1
- package/dist/cjs/bridge/Sell.js +15 -3
- package/dist/cjs/bridge/Sell.js.map +1 -1
- package/dist/cjs/bridge/Status.js +7 -1
- package/dist/cjs/bridge/Status.js.map +1 -1
- package/dist/cjs/bridge/Transfer.js +9 -2
- package/dist/cjs/bridge/Transfer.js.map +1 -1
- package/dist/cjs/bridge/types/Errors.js +31 -0
- package/dist/cjs/bridge/types/Errors.js.map +1 -0
- package/dist/cjs/exports/react.js +6 -4
- package/dist/cjs/exports/react.js.map +1 -1
- package/dist/cjs/exports/react.native.js +6 -4
- package/dist/cjs/exports/react.native.js.map +1 -1
- package/dist/cjs/pay/buyWithCrypto/getQuote.js +2 -0
- package/dist/cjs/pay/buyWithCrypto/getQuote.js.map +1 -1
- package/dist/cjs/pay/buyWithCrypto/getTransfer.js +1 -0
- package/dist/cjs/pay/buyWithCrypto/getTransfer.js.map +1 -1
- package/dist/cjs/pay/buyWithFiat/getPostOnRampQuote.js +2 -1
- package/dist/cjs/pay/buyWithFiat/getPostOnRampQuote.js.map +1 -1
- package/dist/cjs/pay/buyWithFiat/getQuote.js +1 -0
- package/dist/cjs/pay/buyWithFiat/getQuote.js.map +1 -1
- package/dist/cjs/react/core/hooks/wallets/useAuthToken.js +42 -0
- package/dist/cjs/react/core/hooks/wallets/useAuthToken.js.map +1 -0
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js +4 -4
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/PayWIthCreditCard.js +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatScreenContent.js +4 -8
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatScreenContent.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/OnRampScreen.js +3 -0
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/OnRampScreen.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/SwapScreenContent.js +3 -6
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/SwapScreenContent.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/TransferConfirmationScreen.js +2 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/TransferConfirmationScreen.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/TransferFlow.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/useSwapSupportedChains.js +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/useSwapSupportedChains.js.map +1 -1
- package/dist/cjs/react/web/ui/PayEmbed.js +1 -1
- package/dist/cjs/react/web/ui/PayEmbed.js.map +1 -1
- package/dist/cjs/react/web/utils/errors.js +20 -1
- package/dist/cjs/react/web/utils/errors.js.map +1 -1
- package/dist/cjs/utils/ens/avatar.js +1 -1
- package/dist/cjs/utils/ens/avatar.js.map +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/version.js.map +1 -1
- package/dist/cjs/wallets/in-app/core/wallet/in-app-core.js +17 -0
- package/dist/cjs/wallets/in-app/core/wallet/in-app-core.js.map +1 -1
- package/dist/cjs/wallets/in-app/native/native-connector.js.map +1 -1
- package/dist/cjs/wallets/in-app/web/lib/web-connector.js.map +1 -1
- package/dist/esm/bridge/Buy.js +15 -3
- package/dist/esm/bridge/Buy.js.map +1 -1
- package/dist/esm/bridge/Chains.js +7 -1
- package/dist/esm/bridge/Chains.js.map +1 -1
- package/dist/esm/bridge/Onramp.js +11 -2
- package/dist/esm/bridge/Onramp.js.map +1 -1
- package/dist/esm/bridge/OnrampStatus.js +7 -1
- package/dist/esm/bridge/OnrampStatus.js.map +1 -1
- package/dist/esm/bridge/Routes.js +7 -1
- package/dist/esm/bridge/Routes.js.map +1 -1
- package/dist/esm/bridge/Sell.js +15 -3
- package/dist/esm/bridge/Sell.js.map +1 -1
- package/dist/esm/bridge/Status.js +7 -1
- package/dist/esm/bridge/Status.js.map +1 -1
- package/dist/esm/bridge/Transfer.js +9 -2
- package/dist/esm/bridge/Transfer.js.map +1 -1
- package/dist/esm/bridge/types/Errors.js +27 -0
- package/dist/esm/bridge/types/Errors.js.map +1 -0
- package/dist/esm/exports/react.js +2 -1
- package/dist/esm/exports/react.js.map +1 -1
- package/dist/esm/exports/react.native.js +2 -1
- package/dist/esm/exports/react.native.js.map +1 -1
- package/dist/esm/pay/buyWithCrypto/getQuote.js +2 -0
- package/dist/esm/pay/buyWithCrypto/getQuote.js.map +1 -1
- package/dist/esm/pay/buyWithCrypto/getTransfer.js +1 -0
- package/dist/esm/pay/buyWithCrypto/getTransfer.js.map +1 -1
- package/dist/esm/pay/buyWithFiat/getPostOnRampQuote.js +2 -1
- package/dist/esm/pay/buyWithFiat/getPostOnRampQuote.js.map +1 -1
- package/dist/esm/pay/buyWithFiat/getQuote.js +1 -0
- package/dist/esm/pay/buyWithFiat/getQuote.js.map +1 -1
- package/dist/esm/react/core/hooks/wallets/useAuthToken.js +39 -0
- package/dist/esm/react/core/hooks/wallets/useAuthToken.js.map +1 -0
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js +4 -4
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/PayWIthCreditCard.js +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatScreenContent.js +4 -8
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatScreenContent.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/OnRampScreen.js +3 -0
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/OnRampScreen.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/SwapScreenContent.js +3 -6
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/SwapScreenContent.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/TransferConfirmationScreen.js +2 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/TransferConfirmationScreen.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/TransferFlow.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/useSwapSupportedChains.js +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/useSwapSupportedChains.js.map +1 -1
- package/dist/esm/react/web/ui/PayEmbed.js +1 -1
- package/dist/esm/react/web/ui/PayEmbed.js.map +1 -1
- package/dist/esm/react/web/utils/errors.js +20 -1
- package/dist/esm/react/web/utils/errors.js.map +1 -1
- package/dist/esm/utils/ens/avatar.js +1 -1
- package/dist/esm/utils/ens/avatar.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/esm/wallets/in-app/core/wallet/in-app-core.js +17 -0
- package/dist/esm/wallets/in-app/core/wallet/in-app-core.js.map +1 -1
- package/dist/esm/wallets/in-app/native/native-connector.js.map +1 -1
- package/dist/esm/wallets/in-app/web/lib/web-connector.js.map +1 -1
- package/dist/types/bridge/Buy.d.ts +4 -0
- package/dist/types/bridge/Buy.d.ts.map +1 -1
- package/dist/types/bridge/Chains.d.ts.map +1 -1
- package/dist/types/bridge/Onramp.d.ts +4 -0
- package/dist/types/bridge/Onramp.d.ts.map +1 -1
- package/dist/types/bridge/OnrampStatus.d.ts.map +1 -1
- package/dist/types/bridge/Routes.d.ts.map +1 -1
- package/dist/types/bridge/Sell.d.ts +4 -0
- package/dist/types/bridge/Sell.d.ts.map +1 -1
- package/dist/types/bridge/Status.d.ts.map +1 -1
- package/dist/types/bridge/Transfer.d.ts +4 -0
- package/dist/types/bridge/Transfer.d.ts.map +1 -1
- package/dist/types/bridge/index.d.ts +2 -1
- package/dist/types/bridge/index.d.ts.map +1 -1
- package/dist/types/bridge/types/BridgeAction.d.ts +1 -1
- package/dist/types/bridge/types/BridgeAction.d.ts.map +1 -1
- package/dist/types/bridge/types/Errors.d.ts +14 -0
- package/dist/types/bridge/types/Errors.d.ts.map +1 -0
- package/dist/types/bridge/types/Route.d.ts +2 -2
- package/dist/types/bridge/types/Route.d.ts.map +1 -1
- package/dist/types/exports/react.d.ts +2 -1
- package/dist/types/exports/react.d.ts.map +1 -1
- package/dist/types/exports/react.native.d.ts +2 -1
- package/dist/types/exports/react.native.d.ts.map +1 -1
- package/dist/types/pay/buyWithCrypto/getQuote.d.ts +4 -0
- package/dist/types/pay/buyWithCrypto/getQuote.d.ts.map +1 -1
- package/dist/types/pay/buyWithCrypto/getTransfer.d.ts +4 -0
- package/dist/types/pay/buyWithCrypto/getTransfer.d.ts.map +1 -1
- package/dist/types/pay/buyWithFiat/getPostOnRampQuote.d.ts +5 -1
- package/dist/types/pay/buyWithFiat/getPostOnRampQuote.d.ts.map +1 -1
- package/dist/types/pay/buyWithFiat/getQuote.d.ts +4 -0
- package/dist/types/pay/buyWithFiat/getQuote.d.ts.map +1 -1
- package/dist/types/react/core/hooks/wallets/useAuthToken.d.ts +26 -0
- package/dist/types/react/core/hooks/wallets/useAuthToken.d.ts.map +1 -0
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.d.ts +1 -0
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatScreenContent.d.ts +1 -0
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatScreenContent.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/fiat/OnRampScreen.d.ts +1 -0
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/fiat/OnRampScreen.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/SwapScreenContent.d.ts +1 -0
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/SwapScreenContent.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/TransferConfirmationScreen.d.ts +1 -0
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/TransferConfirmationScreen.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/TransferFlow.d.ts +1 -0
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/TransferFlow.d.ts.map +1 -1
- package/dist/types/react/web/ui/PayEmbed.d.ts +4 -0
- package/dist/types/react/web/ui/PayEmbed.d.ts.map +1 -1
- package/dist/types/react/web/utils/errors.d.ts +2 -8
- package/dist/types/react/web/utils/errors.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/in-app/core/interfaces/connector.d.ts +2 -0
- package/dist/types/wallets/in-app/core/interfaces/connector.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/native/native-connector.d.ts +2 -1
- package/dist/types/wallets/in-app/native/native-connector.d.ts.map +1 -1
- package/dist/types/wallets/in-app/web/lib/web-connector.d.ts +2 -1
- package/dist/types/wallets/in-app/web/lib/web-connector.d.ts.map +1 -1
- package/dist/types/wallets/interfaces/wallet.d.ts +10 -0
- package/dist/types/wallets/interfaces/wallet.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/bridge/Buy.ts +19 -6
- package/src/bridge/Chains.ts +7 -1
- package/src/bridge/Onramp.ts +16 -3
- package/src/bridge/OnrampStatus.ts +7 -3
- package/src/bridge/Routes.test.ts +1 -1
- package/src/bridge/Routes.ts +7 -1
- package/src/bridge/Sell.ts +19 -6
- package/src/bridge/Status.ts +7 -3
- package/src/bridge/Transfer.ts +13 -3
- package/src/bridge/index.ts +2 -1
- package/src/bridge/types/BridgeAction.ts +1 -1
- package/src/bridge/types/Errors.ts +24 -0
- package/src/bridge/types/Route.ts +2 -2
- package/src/exports/react.native.ts +2 -1
- package/src/exports/react.ts +2 -1
- package/src/pay/buyWithCrypto/getQuote.ts +7 -0
- package/src/pay/buyWithCrypto/getTransfer.ts +6 -0
- package/src/pay/buyWithFiat/getPostOnRampQuote.ts +7 -0
- package/src/pay/buyWithFiat/getQuote.ts +6 -0
- package/src/react/core/hooks/wallets/useAuthToken.ts +41 -0
- package/src/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.tsx +6 -0
- package/src/react/web/ui/ConnectWallet/screens/Buy/PayWIthCreditCard.tsx +1 -1
- package/src/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatScreenContent.tsx +36 -69
- package/src/react/web/ui/ConnectWallet/screens/Buy/fiat/OnRampScreen.tsx +6 -0
- package/src/react/web/ui/ConnectWallet/screens/Buy/swap/SwapScreenContent.tsx +10 -39
- package/src/react/web/ui/ConnectWallet/screens/Buy/swap/TransferConfirmationScreen.tsx +3 -0
- package/src/react/web/ui/ConnectWallet/screens/Buy/swap/TransferFlow.tsx +1 -0
- package/src/react/web/ui/ConnectWallet/screens/Buy/swap/useSwapSupportedChains.ts +1 -1
- package/src/react/web/ui/PayEmbed.tsx +6 -0
- package/src/react/web/utils/errors.ts +24 -8
- package/src/utils/ens/avatar.ts +1 -1
- package/src/version.ts +1 -1
- package/src/wallets/in-app/core/interfaces/connector.ts +2 -0
- package/src/wallets/in-app/core/wallet/in-app-core.ts +15 -0
- package/src/wallets/in-app/native/native-connector.ts +1 -1
- package/src/wallets/in-app/web/lib/web-connector.ts +1 -1
- package/src/wallets/interfaces/wallet.ts +11 -1
package/src/bridge/Sell.ts
CHANGED
@@ -4,6 +4,7 @@ import type { ThirdwebClient } from "../client/client.js";
|
|
4
4
|
import { getThirdwebBaseUrl } from "../utils/domains.js";
|
5
5
|
import { getClientFetch } from "../utils/fetch.js";
|
6
6
|
import { stringify } from "../utils/json.js";
|
7
|
+
import { ApiError } from "./types/Errors.js";
|
7
8
|
import type { PreparedQuote, Quote } from "./types/Quote.js";
|
8
9
|
|
9
10
|
/**
|
@@ -126,9 +127,12 @@ export async function quote(options: quote.Options): Promise<quote.Result> {
|
|
126
127
|
const response = await clientFetch(url.toString());
|
127
128
|
if (!response.ok) {
|
128
129
|
const errorJson = await response.json();
|
129
|
-
throw new
|
130
|
-
|
131
|
-
|
130
|
+
throw new ApiError({
|
131
|
+
code: errorJson.code || "UNKNOWN_ERROR",
|
132
|
+
message: errorJson.message || response.statusText,
|
133
|
+
correlationId: errorJson.correlationId || undefined,
|
134
|
+
statusCode: response.status,
|
135
|
+
});
|
132
136
|
}
|
133
137
|
|
134
138
|
const { data }: { data: Quote } = await response.json();
|
@@ -323,6 +327,7 @@ export async function prepare(
|
|
323
327
|
client,
|
324
328
|
purchaseData,
|
325
329
|
maxSteps,
|
330
|
+
paymentLinkId,
|
326
331
|
} = options;
|
327
332
|
|
328
333
|
const clientFetch = getClientFetch(client);
|
@@ -344,13 +349,17 @@ export async function prepare(
|
|
344
349
|
receiver,
|
345
350
|
purchaseData,
|
346
351
|
maxSteps,
|
352
|
+
paymentLinkId,
|
347
353
|
}),
|
348
354
|
});
|
349
355
|
if (!response.ok) {
|
350
356
|
const errorJson = await response.json();
|
351
|
-
throw new
|
352
|
-
|
353
|
-
|
357
|
+
throw new ApiError({
|
358
|
+
code: errorJson.code || "UNKNOWN_ERROR",
|
359
|
+
message: errorJson.message || response.statusText,
|
360
|
+
correlationId: errorJson.correlationId || undefined,
|
361
|
+
statusCode: response.status,
|
362
|
+
});
|
354
363
|
}
|
355
364
|
|
356
365
|
const { data }: { data: PreparedQuote } = await response.json();
|
@@ -395,6 +404,10 @@ export declare namespace prepare {
|
|
395
404
|
client: ThirdwebClient;
|
396
405
|
purchaseData?: unknown;
|
397
406
|
maxSteps?: number;
|
407
|
+
/**
|
408
|
+
* @hidden
|
409
|
+
*/
|
410
|
+
paymentLinkId?: string;
|
398
411
|
};
|
399
412
|
|
400
413
|
type Result = PreparedQuote & {
|
package/src/bridge/Status.ts
CHANGED
@@ -3,6 +3,7 @@ import type { Chain } from "../chains/types.js";
|
|
3
3
|
import type { ThirdwebClient } from "../client/client.js";
|
4
4
|
import { getThirdwebBaseUrl } from "../utils/domains.js";
|
5
5
|
import { getClientFetch } from "../utils/fetch.js";
|
6
|
+
import { ApiError } from "./types/Errors.js";
|
6
7
|
import type { Status } from "./types/Status.js";
|
7
8
|
|
8
9
|
/**
|
@@ -115,9 +116,12 @@ export async function status(options: status.Options): Promise<status.Result> {
|
|
115
116
|
const response = await clientFetch(url.toString());
|
116
117
|
if (!response.ok) {
|
117
118
|
const errorJson = await response.json();
|
118
|
-
throw new
|
119
|
-
|
120
|
-
|
119
|
+
throw new ApiError({
|
120
|
+
code: errorJson.code || "UNKNOWN_ERROR",
|
121
|
+
message: errorJson.message || response.statusText,
|
122
|
+
correlationId: errorJson.correlationId || undefined,
|
123
|
+
statusCode: response.status,
|
124
|
+
});
|
121
125
|
}
|
122
126
|
|
123
127
|
const { data }: { data: Status } = await response.json();
|
package/src/bridge/Transfer.ts
CHANGED
@@ -4,6 +4,7 @@ import type { ThirdwebClient } from "../client/client.js";
|
|
4
4
|
import { getThirdwebBaseUrl } from "../utils/domains.js";
|
5
5
|
import { getClientFetch } from "../utils/fetch.js";
|
6
6
|
import { stringify } from "../utils/json.js";
|
7
|
+
import { ApiError } from "./types/Errors.js";
|
7
8
|
import type { PreparedQuote } from "./types/Quote.js";
|
8
9
|
|
9
10
|
/**
|
@@ -189,6 +190,7 @@ export async function prepare(
|
|
189
190
|
amount,
|
190
191
|
purchaseData,
|
191
192
|
feePayer,
|
193
|
+
paymentLinkId,
|
192
194
|
} = options;
|
193
195
|
|
194
196
|
const clientFetch = getClientFetch(client);
|
@@ -208,13 +210,17 @@ export async function prepare(
|
|
208
210
|
receiver,
|
209
211
|
purchaseData,
|
210
212
|
feePayer,
|
213
|
+
paymentLinkId,
|
211
214
|
}),
|
212
215
|
});
|
213
216
|
if (!response.ok) {
|
214
217
|
const errorJson = await response.json();
|
215
|
-
throw new
|
216
|
-
|
217
|
-
|
218
|
+
throw new ApiError({
|
219
|
+
code: errorJson.code || "UNKNOWN_ERROR",
|
220
|
+
message: errorJson.message || response.statusText,
|
221
|
+
correlationId: errorJson.correlationId || undefined,
|
222
|
+
statusCode: response.status,
|
223
|
+
});
|
218
224
|
}
|
219
225
|
|
220
226
|
const { data }: { data: PreparedQuote } = await response.json();
|
@@ -254,6 +260,10 @@ export declare namespace prepare {
|
|
254
260
|
client: ThirdwebClient;
|
255
261
|
purchaseData?: unknown;
|
256
262
|
feePayer?: "sender" | "receiver";
|
263
|
+
/**
|
264
|
+
* @hidden
|
265
|
+
*/
|
266
|
+
paymentLinkId?: string;
|
257
267
|
};
|
258
268
|
|
259
269
|
type Result = PreparedQuote & {
|
package/src/bridge/index.ts
CHANGED
@@ -16,4 +16,5 @@ export type {
|
|
16
16
|
} from "./types/Route.js";
|
17
17
|
export type { Status } from "./types/Status.js";
|
18
18
|
export type { Token } from "./types/Token.js";
|
19
|
-
export type {
|
19
|
+
export type { Action } from "./types/BridgeAction.js";
|
20
|
+
export type { ApiError } from "./types/Errors.js";
|
@@ -1 +1 @@
|
|
1
|
-
export type
|
1
|
+
export type Action = "approval" | "transfer" | "buy" | "sell";
|
@@ -0,0 +1,24 @@
|
|
1
|
+
type ErrorCode =
|
2
|
+
| "INVALID_INPUT"
|
3
|
+
| "ROUTE_NOT_FOUND"
|
4
|
+
| "AMOUNT_TOO_LOW"
|
5
|
+
| "AMOUNT_TOO_HIGH"
|
6
|
+
| "UNKNOWN_ERROR";
|
7
|
+
|
8
|
+
export class ApiError extends Error {
|
9
|
+
code: ErrorCode;
|
10
|
+
correlationId?: string;
|
11
|
+
statusCode: number;
|
12
|
+
|
13
|
+
constructor(args: {
|
14
|
+
code: ErrorCode;
|
15
|
+
message: string;
|
16
|
+
statusCode: number;
|
17
|
+
correlationId?: string;
|
18
|
+
}) {
|
19
|
+
super(args.message);
|
20
|
+
this.code = args.code;
|
21
|
+
this.correlationId = args.correlationId;
|
22
|
+
this.statusCode = args.statusCode;
|
23
|
+
}
|
24
|
+
}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import type { Hex as ox__Hex } from "ox";
|
2
2
|
import type { Chain } from "../../chains/types.js";
|
3
3
|
import type { ThirdwebClient } from "../../client/client.js";
|
4
|
-
import type {
|
4
|
+
import type { Action } from "./BridgeAction.js";
|
5
5
|
import type { Token } from "./Token.js";
|
6
6
|
|
7
7
|
export type Route = {
|
@@ -35,7 +35,7 @@ export type RouteTransaction = {
|
|
35
35
|
/**
|
36
36
|
* The action this transaction performs. This can be "approval", "transfer", "buy", or "sell".
|
37
37
|
*/
|
38
|
-
action:
|
38
|
+
action: Action;
|
39
39
|
/**
|
40
40
|
* The transaction ID, used for tracking purposes.
|
41
41
|
*/
|
@@ -9,10 +9,11 @@ export type {
|
|
9
9
|
|
10
10
|
// wallet hooks
|
11
11
|
export { useActiveWallet } from "../react/core/hooks/wallets/useActiveWallet.js";
|
12
|
-
export { useAdminWallet } from "../react/core/hooks/wallets/useAdminWallet.js";
|
13
12
|
export { useActiveWalletChain } from "../react/core/hooks/wallets/useActiveWalletChain.js";
|
14
13
|
export { useActiveWalletConnectionStatus } from "../react/core/hooks/wallets/useActiveWalletConnectionStatus.js";
|
15
14
|
export { useActiveAccount } from "../react/core/hooks/wallets/useActiveAccount.js";
|
15
|
+
export { useAdminWallet } from "../react/core/hooks/wallets/useAdminWallet.js";
|
16
|
+
export { useAuthToken } from "../react/core/hooks/wallets/useAuthToken.js";
|
16
17
|
export { useAutoConnect } from "../react/native/hooks/wallets/useAutoConnect.js";
|
17
18
|
export { useConnect } from "../react/core/hooks/wallets/useConnect.js";
|
18
19
|
export { useConnectedWallets } from "../react/core/hooks/wallets/useConnectedWallets.js";
|
package/src/exports/react.ts
CHANGED
@@ -40,10 +40,11 @@ export type { MediaRendererProps } from "../react/web/ui/MediaRenderer/types.js"
|
|
40
40
|
|
41
41
|
// wallet hooks
|
42
42
|
export { useActiveWallet } from "../react/core/hooks/wallets/useActiveWallet.js";
|
43
|
-
export { useAdminWallet } from "../react/core/hooks/wallets/useAdminWallet.js";
|
44
43
|
export { useActiveWalletChain } from "../react/core/hooks/wallets/useActiveWalletChain.js";
|
45
44
|
export { useActiveWalletConnectionStatus } from "../react/core/hooks/wallets/useActiveWalletConnectionStatus.js";
|
46
45
|
export { useActiveAccount } from "../react/core/hooks/wallets/useActiveAccount.js";
|
46
|
+
export { useAdminWallet } from "../react/core/hooks/wallets/useAdminWallet.js";
|
47
|
+
export { useAuthToken } from "../react/core/hooks/wallets/useAuthToken.js";
|
47
48
|
export { useAutoConnect } from "../react/web/hooks/wallets/useAutoConnect.js";
|
48
49
|
export { useConnect } from "../react/core/hooks/wallets/useConnect.js";
|
49
50
|
export { useConnectedWallets } from "../react/core/hooks/wallets/useConnectedWallets.js";
|
@@ -83,6 +83,11 @@ export type GetBuyWithCryptoQuoteParams = {
|
|
83
83
|
* For example, if you want to allow a maximum slippage of 0.5%, you should specify `50` bps.
|
84
84
|
*/
|
85
85
|
maxSlippageBPS?: number;
|
86
|
+
|
87
|
+
/**
|
88
|
+
* @hidden
|
89
|
+
*/
|
90
|
+
paymentLinkId?: string;
|
86
91
|
} & (
|
87
92
|
| {
|
88
93
|
/**
|
@@ -203,6 +208,7 @@ export async function getBuyWithCryptoQuote(
|
|
203
208
|
amount: amount,
|
204
209
|
purchaseData: params.purchaseData,
|
205
210
|
client: params.client,
|
211
|
+
paymentLinkId: params.paymentLinkId,
|
206
212
|
});
|
207
213
|
} else if (params.fromAmount) {
|
208
214
|
const originTokenContract = getContract({
|
@@ -224,6 +230,7 @@ export async function getBuyWithCryptoQuote(
|
|
224
230
|
amount: amount,
|
225
231
|
purchaseData: params.purchaseData,
|
226
232
|
client: params.client,
|
233
|
+
paymentLinkId: params.paymentLinkId,
|
227
234
|
});
|
228
235
|
}
|
229
236
|
throw new Error(
|
@@ -60,6 +60,11 @@ export type GetBuyWithCryptoTransferParams = {
|
|
60
60
|
* For direct transfers, specify who will pay for the transfer fee. Can be "sender" or "receiver".
|
61
61
|
*/
|
62
62
|
feePayer?: "sender" | "receiver";
|
63
|
+
|
64
|
+
/**
|
65
|
+
* @hidden
|
66
|
+
*/
|
67
|
+
paymentLinkId?: string;
|
63
68
|
};
|
64
69
|
|
65
70
|
/**
|
@@ -127,6 +132,7 @@ export async function getBuyWithCryptoTransfer(
|
|
127
132
|
receiver: params.toAddress,
|
128
133
|
client: params.client,
|
129
134
|
feePayer: params.feePayer,
|
135
|
+
paymentLinkId: params.paymentLinkId,
|
130
136
|
});
|
131
137
|
|
132
138
|
const firstStep = quote.steps[0];
|
@@ -21,6 +21,11 @@ export type GetPostOnRampQuoteParams = {
|
|
21
21
|
* The "Buy with fiat" transaction status object returned by [`getBuyWithFiatStatus`](https://portal.thirdweb.com/typescript/v5/getBuyWithFiatStatus) function
|
22
22
|
*/
|
23
23
|
buyWithFiatStatus: BuyWithFiatStatus;
|
24
|
+
|
25
|
+
/**
|
26
|
+
* @hidden
|
27
|
+
*/
|
28
|
+
paymentLinkId?: string;
|
24
29
|
};
|
25
30
|
|
26
31
|
/**
|
@@ -61,6 +66,7 @@ export type GetPostOnRampQuoteParams = {
|
|
61
66
|
export async function getPostOnRampQuote({
|
62
67
|
client,
|
63
68
|
buyWithFiatStatus,
|
69
|
+
paymentLinkId,
|
64
70
|
}: GetPostOnRampQuoteParams): Promise<BuyWithCryptoQuote> {
|
65
71
|
if (buyWithFiatStatus.status === "NOT_FOUND") {
|
66
72
|
throw new Error("Invalid buyWithFiatStatus");
|
@@ -77,5 +83,6 @@ export async function getPostOnRampQuote({
|
|
77
83
|
toChainId: buyWithFiatStatus.quote.toToken.chainId,
|
78
84
|
toTokenAddress: buyWithFiatStatus.quote.toToken.tokenAddress,
|
79
85
|
toAmount: buyWithFiatStatus.quote.estimatedToTokenAmount,
|
86
|
+
paymentLinkId: paymentLinkId,
|
80
87
|
});
|
81
88
|
}
|
@@ -95,6 +95,11 @@ export type GetBuyWithFiatQuoteParams = {
|
|
95
95
|
* By default, we choose a recommended provider based on the location of the user, KYC status, and currency.
|
96
96
|
*/
|
97
97
|
preferredProvider?: FiatProvider;
|
98
|
+
|
99
|
+
/**
|
100
|
+
* @hidden
|
101
|
+
*/
|
102
|
+
paymentLinkId?: string;
|
98
103
|
};
|
99
104
|
|
100
105
|
/**
|
@@ -321,6 +326,7 @@ export async function getBuyWithFiatQuote(
|
|
321
326
|
currency: params.fromCurrencySymbol,
|
322
327
|
maxSteps: 2,
|
323
328
|
onrampTokenAddress: NATIVE_TOKEN_ADDRESS, // force onramp to native token to avoid missing gas issues
|
329
|
+
paymentLinkId: params.paymentLinkId,
|
324
330
|
});
|
325
331
|
|
326
332
|
// Determine tokens based on steps rules
|
@@ -0,0 +1,41 @@
|
|
1
|
+
import { useActiveAccount } from "./useActiveAccount.js";
|
2
|
+
import { useActiveWallet } from "./useActiveWallet.js";
|
3
|
+
|
4
|
+
/**
|
5
|
+
* A hook that returns the authentication token (JWT) for the currently active wallet.
|
6
|
+
* This token can be used to authorize API calls to your backend server.
|
7
|
+
*
|
8
|
+
* @returns The JWT string if the active wallet is an in-app wallet and matches the active account, null otherwise
|
9
|
+
*
|
10
|
+
* @example
|
11
|
+
* ```tsx
|
12
|
+
* function MyComponent() {
|
13
|
+
* const authToken = useAuthToken();
|
14
|
+
*
|
15
|
+
* const fetchData = async () => {
|
16
|
+
* const response = await fetch('https://api.example.com/data', {
|
17
|
+
* headers: {
|
18
|
+
* 'Authorization': `Bearer ${authToken}`
|
19
|
+
* }
|
20
|
+
* });
|
21
|
+
* // ... handle response
|
22
|
+
* };
|
23
|
+
* }
|
24
|
+
* ```
|
25
|
+
*
|
26
|
+
* @wallet
|
27
|
+
*/
|
28
|
+
export function useAuthToken() {
|
29
|
+
const activeWallet = useActiveWallet();
|
30
|
+
const activeAccount = useActiveAccount();
|
31
|
+
// if the active wallet is an in-app wallet and the active account is the same as the active wallet's account, return the auth token for the in-app wallet
|
32
|
+
if (
|
33
|
+
activeWallet?.getAuthToken &&
|
34
|
+
activeAccount &&
|
35
|
+
activeAccount.address === activeWallet.getAccount()?.address
|
36
|
+
) {
|
37
|
+
return activeWallet.getAuthToken();
|
38
|
+
}
|
39
|
+
// all other wallets don't expose an auth token for now
|
40
|
+
return null;
|
41
|
+
}
|
@@ -83,6 +83,7 @@ export type BuyScreenProps = {
|
|
83
83
|
connectOptions: PayEmbedConnectOptions | undefined;
|
84
84
|
hiddenWallets?: WalletId[];
|
85
85
|
isEmbed: boolean;
|
86
|
+
paymentLinkId?: string;
|
86
87
|
};
|
87
88
|
|
88
89
|
/**
|
@@ -151,6 +152,7 @@ type BuyScreenContentProps = {
|
|
151
152
|
hiddenWallets?: WalletId[];
|
152
153
|
connectOptions: PayEmbedConnectOptions | undefined;
|
153
154
|
isEmbed: boolean;
|
155
|
+
paymentLinkId?: string;
|
154
156
|
};
|
155
157
|
|
156
158
|
/**
|
@@ -347,6 +349,7 @@ function BuyScreenContent(props: BuyScreenContentProps) {
|
|
347
349
|
<OnRampScreen
|
348
350
|
title={props.title}
|
349
351
|
transactionMode={payOptions.mode === "transaction"}
|
352
|
+
paymentLinkId={props.paymentLinkId}
|
350
353
|
quote={screen.quote}
|
351
354
|
onBack={() => {
|
352
355
|
setScreen({
|
@@ -395,6 +398,7 @@ function BuyScreenContent(props: BuyScreenContentProps) {
|
|
395
398
|
});
|
396
399
|
}}
|
397
400
|
onSuccess={onSwapSuccess}
|
401
|
+
paymentLinkId={props.paymentLinkId}
|
398
402
|
/>
|
399
403
|
);
|
400
404
|
}
|
@@ -530,6 +534,7 @@ function BuyScreenContent(props: BuyScreenContentProps) {
|
|
530
534
|
{screen.id === "buy-with-crypto" && activeAccount && (
|
531
535
|
<SwapScreenContent
|
532
536
|
setScreen={setScreen}
|
537
|
+
paymentLinkId={props.paymentLinkId}
|
533
538
|
tokenAmount={deferredTokenAmount}
|
534
539
|
toChain={toChain}
|
535
540
|
toToken={toToken}
|
@@ -585,6 +590,7 @@ function BuyScreenContent(props: BuyScreenContentProps) {
|
|
585
590
|
payer={payer}
|
586
591
|
setTokenAmount={setTokenAmount}
|
587
592
|
setHasEditedAmount={setHasEditedAmount}
|
593
|
+
paymentLinkId={props.paymentLinkId}
|
588
594
|
/>
|
589
595
|
)}
|
590
596
|
|
@@ -5,7 +5,6 @@ import type { Chain } from "../../../../../../../chains/types.js";
|
|
5
5
|
import type { ThirdwebClient } from "../../../../../../../client/client.js";
|
6
6
|
import { NATIVE_TOKEN_ADDRESS } from "../../../../../../../constants/addresses.js";
|
7
7
|
import type { FiatProvider } from "../../../../../../../pay/utils/commonTypes.js";
|
8
|
-
import { formatNumber } from "../../../../../../../utils/formatNumber.js";
|
9
8
|
import {
|
10
9
|
type Theme,
|
11
10
|
iconSize,
|
@@ -25,7 +24,6 @@ import { Spinner } from "../../../../components/Spinner.js";
|
|
25
24
|
import { Container } from "../../../../components/basic.js";
|
26
25
|
import { Button } from "../../../../components/buttons.js";
|
27
26
|
import { Text } from "../../../../components/text.js";
|
28
|
-
import { TokenSymbol } from "../../../../components/token/TokenSymbol.js";
|
29
27
|
import { type ERC20OrNativeToken, isNativeToken } from "../../nativeToken.js";
|
30
28
|
import { EstimatedTimeAndFees } from "../EstimatedTimeAndFees.js";
|
31
29
|
import { PayWithCreditCard } from "../PayWIthCreditCard.js";
|
@@ -50,6 +48,7 @@ export function FiatScreenContent(props: {
|
|
50
48
|
payer: PayerInfo;
|
51
49
|
setTokenAmount: (amount: string) => void;
|
52
50
|
setHasEditedAmount: (hasEdited: boolean) => void;
|
51
|
+
paymentLinkId: undefined | string;
|
53
52
|
}) {
|
54
53
|
const {
|
55
54
|
toToken,
|
@@ -60,6 +59,7 @@ export function FiatScreenContent(props: {
|
|
60
59
|
toChain,
|
61
60
|
showCurrencySelector,
|
62
61
|
selectedCurrency,
|
62
|
+
paymentLinkId,
|
63
63
|
} = props;
|
64
64
|
const defaultRecipientAddress = (
|
65
65
|
props.payOptions as Extract<PayUIOptions, { mode: "direct_payment" }>
|
@@ -99,6 +99,7 @@ export function FiatScreenContent(props: {
|
|
99
99
|
purchaseData: props.payOptions.purchaseData,
|
100
100
|
fromAddress: payer.account.address,
|
101
101
|
preferredProvider: preferredProvider,
|
102
|
+
paymentLinkId: paymentLinkId,
|
102
103
|
}
|
103
104
|
: undefined,
|
104
105
|
);
|
@@ -227,77 +228,43 @@ export function FiatScreenContent(props: {
|
|
227
228
|
{/* Error message */}
|
228
229
|
{errorMsg && (
|
229
230
|
<div>
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
chain={toChain}
|
237
|
-
size="sm"
|
238
|
-
inline
|
239
|
-
color="danger"
|
240
|
-
/>
|
241
|
-
</Text>
|
242
|
-
) : (
|
243
|
-
<div>
|
244
|
-
<Text color="danger" size="xs" center multiline>
|
245
|
-
{errorMsg.title}
|
246
|
-
</Text>
|
247
|
-
<Text size="xs" center multiline>
|
248
|
-
{errorMsg.message}
|
249
|
-
</Text>
|
250
|
-
</div>
|
251
|
-
)}
|
231
|
+
<Text color="danger" size="xs" center multiline>
|
232
|
+
{errorMsg.title}
|
233
|
+
</Text>
|
234
|
+
<Text size="xs" center multiline>
|
235
|
+
{errorMsg.message}
|
236
|
+
</Text>
|
252
237
|
</div>
|
253
238
|
)}
|
254
239
|
</Container>
|
255
240
|
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
walletType: payer.wallet.id,
|
284
|
-
toChainId: toChain.id,
|
285
|
-
toToken: isNativeToken(toToken) ? undefined : toToken.address,
|
286
|
-
});
|
287
|
-
handleSubmit();
|
288
|
-
}}
|
289
|
-
gap="xs"
|
290
|
-
>
|
291
|
-
{fiatQuoteQuery.isLoading ? (
|
292
|
-
<>
|
293
|
-
Getting price quote
|
294
|
-
<Spinner size="sm" color="accentText" />
|
295
|
-
</>
|
296
|
-
) : (
|
297
|
-
"Continue"
|
298
|
-
)}
|
299
|
-
</Button>
|
300
|
-
)}
|
241
|
+
<Button
|
242
|
+
variant={disableSubmit ? "outline" : "accent"}
|
243
|
+
data-disabled={disableSubmit}
|
244
|
+
disabled={disableSubmit}
|
245
|
+
fullWidth
|
246
|
+
onClick={() => {
|
247
|
+
trackPayEvent({
|
248
|
+
event: "confirm_onramp_quote",
|
249
|
+
client: client,
|
250
|
+
walletAddress: payer.account.address,
|
251
|
+
walletType: payer.wallet.id,
|
252
|
+
toChainId: toChain.id,
|
253
|
+
toToken: isNativeToken(toToken) ? undefined : toToken.address,
|
254
|
+
});
|
255
|
+
handleSubmit();
|
256
|
+
}}
|
257
|
+
gap="xs"
|
258
|
+
>
|
259
|
+
{fiatQuoteQuery.isLoading ? (
|
260
|
+
<>
|
261
|
+
Getting price quote
|
262
|
+
<Spinner size="sm" color="accentButtonText" />
|
263
|
+
</>
|
264
|
+
) : (
|
265
|
+
"Continue"
|
266
|
+
)}
|
267
|
+
</Button>
|
301
268
|
</Container>
|
302
269
|
);
|
303
270
|
}
|
@@ -71,6 +71,7 @@ export function OnRampScreen(props: {
|
|
71
71
|
payer: PayerInfo;
|
72
72
|
onSuccess: (status: BuyWithFiatStatus) => void;
|
73
73
|
receiverAddress: string;
|
74
|
+
paymentLinkId?: string;
|
74
75
|
}) {
|
75
76
|
const connectedWallets = useConnectedWallets();
|
76
77
|
const isAutoMode = isInAppSigner({
|
@@ -85,6 +86,7 @@ export function OnRampScreen(props: {
|
|
85
86
|
payer: props.payer,
|
86
87
|
theme: props.theme,
|
87
88
|
isAutoMode,
|
89
|
+
paymentLinkId: props.paymentLinkId,
|
88
90
|
});
|
89
91
|
const firstStepChainId = state.steps[0]?.step.token.chainId;
|
90
92
|
return (
|
@@ -288,6 +290,7 @@ function useOnRampScreenState(props: {
|
|
288
290
|
payer: PayerInfo;
|
289
291
|
theme: "light" | "dark";
|
290
292
|
isAutoMode?: boolean;
|
293
|
+
paymentLinkId?: string;
|
291
294
|
}): OnRampScreenState {
|
292
295
|
const onRampSteps = getOnRampSteps(props.quote);
|
293
296
|
const [currentStepIndex, setCurrentStepIndex] = useState(0);
|
@@ -322,6 +325,7 @@ function useOnRampScreenState(props: {
|
|
322
325
|
client: props.client,
|
323
326
|
payer: props.payer,
|
324
327
|
isFiatFlow: true,
|
328
|
+
paymentLinkId: props.paymentLinkId,
|
325
329
|
});
|
326
330
|
|
327
331
|
// Track swap status
|
@@ -615,6 +619,7 @@ function useSwapMutation(props: {
|
|
615
619
|
client: ThirdwebClient;
|
616
620
|
payer: PayerInfo;
|
617
621
|
isFiatFlow: boolean;
|
622
|
+
paymentLinkId?: string;
|
618
623
|
}) {
|
619
624
|
const queryClient = useQueryClient();
|
620
625
|
return useMutation({
|
@@ -646,6 +651,7 @@ function useSwapMutation(props: {
|
|
646
651
|
toTokenAddress: toToken.tokenAddress,
|
647
652
|
fromAddress: account.address,
|
648
653
|
toAddress: account.address,
|
654
|
+
paymentLinkId: props.paymentLinkId,
|
649
655
|
client: props.client,
|
650
656
|
});
|
651
657
|
|