thirdweb 5.105.38 → 5.105.39
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/Token.js +4 -1
- package/dist/cjs/bridge/Token.js.map +1 -1
- package/dist/cjs/react/web/ui/Bridge/BridgeOrchestrator.js.map +1 -1
- package/dist/cjs/react/web/ui/Bridge/DirectPayment.js.map +1 -1
- package/dist/cjs/react/web/ui/Bridge/FundWallet.js.map +1 -1
- package/dist/cjs/react/web/ui/Bridge/TransactionPayment.js.map +1 -1
- package/dist/cjs/stories/Bridge/fixtures.js.map +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/bridge/Token.js +4 -1
- package/dist/esm/bridge/Token.js.map +1 -1
- package/dist/esm/react/web/ui/Bridge/BridgeOrchestrator.js.map +1 -1
- package/dist/esm/react/web/ui/Bridge/DirectPayment.js.map +1 -1
- package/dist/esm/react/web/ui/Bridge/FundWallet.js.map +1 -1
- package/dist/esm/react/web/ui/Bridge/TransactionPayment.js.map +1 -1
- package/dist/esm/stories/Bridge/fixtures.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/types/bridge/Onramp.d.ts +2 -2
- package/dist/types/bridge/Onramp.d.ts.map +1 -1
- package/dist/types/bridge/Token.d.ts +7 -5
- package/dist/types/bridge/Token.d.ts.map +1 -1
- package/dist/types/bridge/index.d.ts +1 -1
- package/dist/types/bridge/index.d.ts.map +1 -1
- package/dist/types/bridge/types/Route.d.ts +7 -7
- package/dist/types/bridge/types/Route.d.ts.map +1 -1
- package/dist/types/bridge/types/Token.d.ts +2 -0
- package/dist/types/bridge/types/Token.d.ts.map +1 -1
- package/dist/types/pay/convert/get-token.d.ts +2 -2
- package/dist/types/pay/convert/get-token.d.ts.map +1 -1
- package/dist/types/react/core/hooks/usePaymentMethods.d.ts.map +1 -1
- package/dist/types/react/core/hooks/useTransactionDetails.d.ts +2 -2
- package/dist/types/react/core/hooks/useTransactionDetails.d.ts.map +1 -1
- package/dist/types/react/core/machines/paymentMachine.d.ts +4 -4
- package/dist/types/react/core/machines/paymentMachine.d.ts.map +1 -1
- package/dist/types/react/web/ui/Bridge/BridgeOrchestrator.d.ts +3 -3
- package/dist/types/react/web/ui/Bridge/BridgeOrchestrator.d.ts.map +1 -1
- package/dist/types/react/web/ui/Bridge/DirectPayment.d.ts +2 -2
- package/dist/types/react/web/ui/Bridge/DirectPayment.d.ts.map +1 -1
- package/dist/types/react/web/ui/Bridge/FundWallet.d.ts +2 -2
- package/dist/types/react/web/ui/Bridge/FundWallet.d.ts.map +1 -1
- package/dist/types/react/web/ui/Bridge/TransactionPayment.d.ts +2 -2
- package/dist/types/react/web/ui/Bridge/TransactionPayment.d.ts.map +1 -1
- package/dist/types/stories/Bridge/BridgeOrchestrator.stories.d.ts +1 -1
- package/dist/types/stories/Bridge/BridgeOrchestrator.stories.d.ts.map +1 -1
- package/dist/types/stories/Bridge/DirectPayment.stories.d.ts +2 -2
- package/dist/types/stories/Bridge/DirectPayment.stories.d.ts.map +1 -1
- package/dist/types/stories/Bridge/FundWallet.stories.d.ts +2 -2
- package/dist/types/stories/Bridge/FundWallet.stories.d.ts.map +1 -1
- package/dist/types/stories/Bridge/PaymentDetails.stories.d.ts +1 -1
- package/dist/types/stories/Bridge/PaymentSelection.stories.d.ts +1 -1
- package/dist/types/stories/Bridge/SuccessScreen.stories.d.ts +1 -1
- package/dist/types/stories/Bridge/SuccessScreen.stories.d.ts.map +1 -1
- package/dist/types/stories/Bridge/TransactionPayment.stories.d.ts +1 -1
- package/dist/types/stories/Bridge/TransactionPayment.stories.d.ts.map +1 -1
- package/dist/types/stories/Bridge/fixtures.d.ts +4 -4
- package/dist/types/stories/Bridge/fixtures.d.ts.map +1 -1
- package/dist/types/stories/TokenBalanceRow.stories.d.ts +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +1 -1
- package/src/bridge/Onramp.ts +2 -2
- package/src/bridge/Token.test.ts +20 -2
- package/src/bridge/Token.ts +25 -9
- package/src/bridge/index.ts +1 -1
- package/src/bridge/types/Route.ts +7 -7
- package/src/bridge/types/Token.ts +3 -0
- package/src/pay/convert/get-token.ts +2 -2
- package/src/react/core/hooks/usePaymentMethods.ts +2 -2
- package/src/react/core/hooks/useTransactionDetails.ts +2 -2
- package/src/react/core/machines/paymentMachine.ts +4 -4
- package/src/react/web/ui/Bridge/BridgeOrchestrator.tsx +4 -4
- package/src/react/web/ui/Bridge/DirectPayment.tsx +6 -2
- package/src/react/web/ui/Bridge/FundWallet.tsx +6 -2
- package/src/react/web/ui/Bridge/TransactionPayment.tsx +6 -2
- package/src/stories/Bridge/fixtures.ts +4 -4
- package/src/version.ts +1 -1
package/src/bridge/Token.ts
CHANGED
@@ -2,7 +2,7 @@ import type { ThirdwebClient } from "../client/client.js";
|
|
2
2
|
import { getThirdwebBaseUrl } from "../utils/domains.js";
|
3
3
|
import { getClientFetch } from "../utils/fetch.js";
|
4
4
|
import { ApiError } from "./types/Errors.js";
|
5
|
-
import type { Token } from "./types/Token.js";
|
5
|
+
import type { Token, TokenWithPrices } from "./types/Token.js";
|
6
6
|
|
7
7
|
/**
|
8
8
|
* Retrieves supported Universal Bridge tokens based on the provided filters.
|
@@ -128,9 +128,20 @@ import type { Token } from "./types/Token.js";
|
|
128
128
|
* @bridge
|
129
129
|
* @beta
|
130
130
|
*/
|
131
|
-
export async function tokens
|
132
|
-
|
133
|
-
|
131
|
+
export async function tokens<
|
132
|
+
IncludePrices extends boolean = true,
|
133
|
+
R extends Token | TokenWithPrices = TokenWithPrices,
|
134
|
+
>(options: tokens.Options<IncludePrices>): Promise<R[]> {
|
135
|
+
const {
|
136
|
+
client,
|
137
|
+
chainId,
|
138
|
+
tokenAddress,
|
139
|
+
symbol,
|
140
|
+
name,
|
141
|
+
limit,
|
142
|
+
offset,
|
143
|
+
includePrices,
|
144
|
+
} = options;
|
134
145
|
|
135
146
|
const clientFetch = getClientFetch(client);
|
136
147
|
const url = new URL(`${getThirdwebBaseUrl("bridge")}/v1/tokens`);
|
@@ -153,6 +164,9 @@ export async function tokens(options: tokens.Options): Promise<tokens.Result> {
|
|
153
164
|
if (offset !== null && offset !== undefined) {
|
154
165
|
url.searchParams.set("offset", offset.toString());
|
155
166
|
}
|
167
|
+
if (includePrices !== undefined) {
|
168
|
+
url.searchParams.set("includePrices", includePrices.toString());
|
169
|
+
}
|
156
170
|
|
157
171
|
const response = await clientFetch(url.toString());
|
158
172
|
if (!response.ok) {
|
@@ -165,7 +179,7 @@ export async function tokens(options: tokens.Options): Promise<tokens.Result> {
|
|
165
179
|
});
|
166
180
|
}
|
167
181
|
|
168
|
-
const { data }: { data:
|
182
|
+
const { data }: { data: R[] } = await response.json();
|
169
183
|
return data;
|
170
184
|
}
|
171
185
|
|
@@ -173,7 +187,7 @@ export declare namespace tokens {
|
|
173
187
|
/**
|
174
188
|
* Input parameters for {@link tokens}.
|
175
189
|
*/
|
176
|
-
type Options = {
|
190
|
+
type Options<IncludePrices extends boolean> = {
|
177
191
|
/** Your {@link ThirdwebClient} instance. */
|
178
192
|
client: ThirdwebClient;
|
179
193
|
/** Filter by a specific chain ID. */
|
@@ -188,12 +202,14 @@ export declare namespace tokens {
|
|
188
202
|
limit?: number;
|
189
203
|
/** Number of tokens to skip (min: 0, default: 0). */
|
190
204
|
offset?: number | null;
|
205
|
+
/** Whether or not to include prices for the tokens. Setting this to false will speed up the request. */
|
206
|
+
includePrices?: IncludePrices;
|
191
207
|
};
|
192
208
|
|
193
209
|
/**
|
194
210
|
* The result returned from {@link Bridge.tokens}.
|
195
211
|
*/
|
196
|
-
type Result =
|
212
|
+
type Result<T extends Token | TokenWithPrices> = T[];
|
197
213
|
}
|
198
214
|
|
199
215
|
/**
|
@@ -254,7 +270,7 @@ export async function add(options: add.Options): Promise<add.Result> {
|
|
254
270
|
});
|
255
271
|
}
|
256
272
|
|
257
|
-
const { data }: { data:
|
273
|
+
const { data }: { data: TokenWithPrices } = await response.json();
|
258
274
|
return data;
|
259
275
|
}
|
260
276
|
|
@@ -274,5 +290,5 @@ export declare namespace add {
|
|
274
290
|
/**
|
275
291
|
* The result returned from {@link Bridge.add}.
|
276
292
|
*/
|
277
|
-
type Result =
|
293
|
+
type Result = TokenWithPrices;
|
278
294
|
}
|
package/src/bridge/index.ts
CHANGED
@@ -17,7 +17,7 @@ export type {
|
|
17
17
|
RouteTransaction,
|
18
18
|
} from "./types/Route.js";
|
19
19
|
export type { Status } from "./types/Status.js";
|
20
|
-
export type { Token } from "./types/Token.js";
|
20
|
+
export type { Token, TokenWithPrices } from "./types/Token.js";
|
21
21
|
export type { WebhookPayload } from "./Webhook.js";
|
22
22
|
export * as Webhook from "./Webhook.js";
|
23
23
|
export { parse } from "./Webhook.js";
|
@@ -2,24 +2,24 @@ 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
4
|
import type { Action } from "./BridgeAction.js";
|
5
|
-
import type {
|
5
|
+
import type { TokenWithPrices } from "./Token.js";
|
6
6
|
|
7
7
|
export type Route = {
|
8
|
-
originToken:
|
9
|
-
destinationToken:
|
8
|
+
originToken: TokenWithPrices;
|
9
|
+
destinationToken: TokenWithPrices;
|
10
10
|
};
|
11
11
|
|
12
12
|
export type RouteQuoteStep = {
|
13
|
-
originToken:
|
14
|
-
destinationToken:
|
13
|
+
originToken: TokenWithPrices;
|
14
|
+
destinationToken: TokenWithPrices;
|
15
15
|
originAmount: bigint;
|
16
16
|
destinationAmount: bigint;
|
17
17
|
estimatedExecutionTimeMs: number;
|
18
18
|
};
|
19
19
|
|
20
20
|
export type RouteStep = {
|
21
|
-
originToken:
|
22
|
-
destinationToken:
|
21
|
+
originToken: TokenWithPrices;
|
22
|
+
destinationToken: TokenWithPrices;
|
23
23
|
originAmount: bigint;
|
24
24
|
destinationAmount: bigint;
|
25
25
|
estimatedExecutionTimeMs: number;
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { add, tokens } from "../../bridge/Token.js";
|
2
|
-
import type {
|
2
|
+
import type { TokenWithPrices } from "../../bridge/types/Token.js";
|
3
3
|
import type { ThirdwebClient } from "../../client/client.js";
|
4
4
|
import { withCache } from "../../utils/promise/withCache.js";
|
5
5
|
|
@@ -7,7 +7,7 @@ export async function getToken(
|
|
7
7
|
client: ThirdwebClient,
|
8
8
|
tokenAddress: string,
|
9
9
|
chainId: number,
|
10
|
-
): Promise<
|
10
|
+
): Promise<TokenWithPrices> {
|
11
11
|
return withCache(
|
12
12
|
async () => {
|
13
13
|
const result = await tokens({
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { useQuery } from "@tanstack/react-query";
|
2
2
|
import type { Quote } from "../../../bridge/index.js";
|
3
3
|
import { ApiError } from "../../../bridge/types/Errors.js";
|
4
|
-
import type { Token } from "../../../bridge/types/Token.js";
|
4
|
+
import type { Token, TokenWithPrices } from "../../../bridge/types/Token.js";
|
5
5
|
import type { ThirdwebClient } from "../../../client/client.js";
|
6
6
|
import { getThirdwebBaseUrl } from "../../../utils/domains.js";
|
7
7
|
import { getClientFetch } from "../../../utils/fetch.js";
|
@@ -82,7 +82,7 @@ export function usePaymentMethods(options: {
|
|
82
82
|
|
83
83
|
const {
|
84
84
|
data: allValidOriginTokens,
|
85
|
-
}: { data: { quote: Quote; balance: string; token:
|
85
|
+
}: { data: { quote: Quote; balance: string; token: TokenWithPrices }[] } =
|
86
86
|
await response.json();
|
87
87
|
|
88
88
|
// Sort by enough balance to pay THEN gross balance
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { useQuery } from "@tanstack/react-query";
|
2
2
|
import type { AbiFunction } from "abitype";
|
3
3
|
import { toFunctionSelector } from "viem";
|
4
|
-
import type {
|
4
|
+
import type { TokenWithPrices } from "../../../bridge/index.js";
|
5
5
|
import type { ThirdwebClient } from "../../../client/client.js";
|
6
6
|
import { NATIVE_TOKEN_ADDRESS } from "../../../constants/addresses.js";
|
7
7
|
import type { CompilerMetadata } from "../../../contract/actions/compiler-metadata.js";
|
@@ -34,7 +34,7 @@ interface TransactionDetails {
|
|
34
34
|
usdValueDisplay: string | null;
|
35
35
|
txCostDisplay: string;
|
36
36
|
gasCostDisplay: string | null;
|
37
|
-
tokenInfo:
|
37
|
+
tokenInfo: TokenWithPrices | null;
|
38
38
|
costWei: bigint;
|
39
39
|
gasCostWei: bigint | null;
|
40
40
|
totalCost: string;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { useCallback, useState } from "react";
|
2
2
|
import type { Quote } from "../../../bridge/index.js";
|
3
|
-
import type {
|
3
|
+
import type { TokenWithPrices } from "../../../bridge/types/Token.js";
|
4
4
|
import type { Address } from "../../../utils/address.js";
|
5
5
|
import type { AsyncStorage } from "../../../utils/storage/AsyncStorage.js";
|
6
6
|
import type { Wallet } from "../../../wallets/interfaces/wallet.js";
|
@@ -23,7 +23,7 @@ export type PaymentMethod =
|
|
23
23
|
| {
|
24
24
|
type: "wallet";
|
25
25
|
payerWallet: Wallet;
|
26
|
-
originToken:
|
26
|
+
originToken: TokenWithPrices;
|
27
27
|
balance: bigint;
|
28
28
|
quote: Quote;
|
29
29
|
}
|
@@ -43,7 +43,7 @@ export interface PaymentMachineContext {
|
|
43
43
|
|
44
44
|
// Target requirements (resolved in init state)
|
45
45
|
destinationAmount?: string;
|
46
|
-
destinationToken?:
|
46
|
+
destinationToken?: TokenWithPrices;
|
47
47
|
receiverAddress?: Address;
|
48
48
|
|
49
49
|
// User selections (set in methodSelection state)
|
@@ -73,7 +73,7 @@ export interface PaymentMachineContext {
|
|
73
73
|
type PaymentMachineEvent =
|
74
74
|
| {
|
75
75
|
type: "DESTINATION_CONFIRMED";
|
76
|
-
destinationToken:
|
76
|
+
destinationToken: TokenWithPrices;
|
77
77
|
destinationAmount: string;
|
78
78
|
receiverAddress: Address;
|
79
79
|
}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
"use client";
|
2
2
|
import { useCallback, useMemo } from "react";
|
3
|
-
import type {
|
3
|
+
import type { TokenWithPrices } from "../../../../bridge/types/Token.js";
|
4
4
|
import type { ThirdwebClient } from "../../../../client/client.js";
|
5
5
|
import type { SupportedFiatCurrency } from "../../../../pay/convert/type.js";
|
6
6
|
import type { PurchaseData } from "../../../../pay/types.js";
|
@@ -46,7 +46,7 @@ export type UIOptions = Prettify<
|
|
46
46
|
} & (
|
47
47
|
| {
|
48
48
|
mode: "fund_wallet";
|
49
|
-
destinationToken:
|
49
|
+
destinationToken: TokenWithPrices;
|
50
50
|
initialAmount?: string;
|
51
51
|
presetOptions?: [number, number, number];
|
52
52
|
}
|
@@ -54,7 +54,7 @@ export type UIOptions = Prettify<
|
|
54
54
|
mode: "direct_payment";
|
55
55
|
paymentInfo: {
|
56
56
|
sellerAddress: Address;
|
57
|
-
token:
|
57
|
+
token: TokenWithPrices;
|
58
58
|
amount: string;
|
59
59
|
feePayer?: "sender" | "receiver";
|
60
60
|
};
|
@@ -235,7 +235,7 @@ export function BridgeOrchestrator({
|
|
235
235
|
|
236
236
|
// Handle requirements resolved from FundWallet and DirectPayment
|
237
237
|
const handleRequirementsResolved = useCallback(
|
238
|
-
(amount: string, token:
|
238
|
+
(amount: string, token: TokenWithPrices, receiverAddress: Address) => {
|
239
239
|
send({
|
240
240
|
destinationAmount: amount,
|
241
241
|
destinationToken: token,
|
@@ -1,5 +1,5 @@
|
|
1
1
|
"use client";
|
2
|
-
import type {
|
2
|
+
import type { TokenWithPrices } from "../../../../bridge/types/Token.js";
|
3
3
|
import { defineChain } from "../../../../chains/utils.js";
|
4
4
|
import type { ThirdwebClient } from "../../../../client/client.js";
|
5
5
|
import type { Address } from "../../../../utils/address.js";
|
@@ -28,7 +28,11 @@ export interface DirectPaymentProps {
|
|
28
28
|
/**
|
29
29
|
* Called when user continues with the payment
|
30
30
|
*/
|
31
|
-
onContinue: (
|
31
|
+
onContinue: (
|
32
|
+
amount: string,
|
33
|
+
token: TokenWithPrices,
|
34
|
+
receiverAddress: Address,
|
35
|
+
) => void;
|
32
36
|
|
33
37
|
/**
|
34
38
|
* Whether to show thirdweb branding in the widget.
|
@@ -1,7 +1,7 @@
|
|
1
1
|
/** biome-ignore-all lint/a11y/useSemanticElements: FIXME */
|
2
2
|
"use client";
|
3
3
|
import { useRef, useState } from "react";
|
4
|
-
import type {
|
4
|
+
import type { TokenWithPrices } from "../../../../bridge/types/Token.js";
|
5
5
|
import type { ThirdwebClient } from "../../../../client/client.js";
|
6
6
|
import { type Address, getAddress } from "../../../../utils/address.js";
|
7
7
|
import { numberToPlainString } from "../../../../utils/formatNumber.js";
|
@@ -46,7 +46,11 @@ export interface FundWalletProps {
|
|
46
46
|
/**
|
47
47
|
* Called when continue is clicked with the resolved requirements
|
48
48
|
*/
|
49
|
-
onContinue: (
|
49
|
+
onContinue: (
|
50
|
+
amount: string,
|
51
|
+
token: TokenWithPrices,
|
52
|
+
receiverAddress: Address,
|
53
|
+
) => void;
|
50
54
|
|
51
55
|
/**
|
52
56
|
* Quick buy amounts
|
@@ -1,6 +1,6 @@
|
|
1
1
|
"use client";
|
2
2
|
import { useQuery } from "@tanstack/react-query";
|
3
|
-
import type {
|
3
|
+
import type { TokenWithPrices } from "../../../../bridge/types/Token.js";
|
4
4
|
import type { ThirdwebClient } from "../../../../client/client.js";
|
5
5
|
import { NATIVE_TOKEN_ADDRESS } from "../../../../constants/addresses.js";
|
6
6
|
import {
|
@@ -46,7 +46,11 @@ export interface TransactionPaymentProps {
|
|
46
46
|
/**
|
47
47
|
* Called when user confirms transaction execution
|
48
48
|
*/
|
49
|
-
onContinue: (
|
49
|
+
onContinue: (
|
50
|
+
amount: string,
|
51
|
+
token: TokenWithPrices,
|
52
|
+
receiverAddress: Address,
|
53
|
+
) => void;
|
50
54
|
|
51
55
|
/**
|
52
56
|
* Request to execute the transaction immediately (skips funding flow)
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { stringify } from "viem";
|
2
|
-
import type {
|
2
|
+
import type { TokenWithPrices } from "../../bridge/types/Token.js";
|
3
3
|
import { base } from "../../chains/chain-definitions/base.js";
|
4
4
|
import { baseSepolia } from "../../chains/chain-definitions/base-sepolia.js";
|
5
5
|
import { polygon } from "../../chains/chain-definitions/polygon.js";
|
@@ -19,7 +19,7 @@ import { toWei } from "../../utils/units.js";
|
|
19
19
|
import type { Account, Wallet } from "../../wallets/interfaces/wallet.js";
|
20
20
|
import { storyClient } from "../utils.js";
|
21
21
|
|
22
|
-
export const ETH:
|
22
|
+
export const ETH: TokenWithPrices = {
|
23
23
|
address: NATIVE_TOKEN_ADDRESS,
|
24
24
|
chainId: 10,
|
25
25
|
decimals: 18,
|
@@ -32,7 +32,7 @@ export const ETH: Token = {
|
|
32
32
|
symbol: "ETH",
|
33
33
|
};
|
34
34
|
|
35
|
-
export const USDC:
|
35
|
+
export const USDC: TokenWithPrices = {
|
36
36
|
address: getDefaultToken(base, "USDC")?.address ?? "",
|
37
37
|
chainId: base.id,
|
38
38
|
decimals: 6,
|
@@ -45,7 +45,7 @@ export const USDC: Token = {
|
|
45
45
|
symbol: "USDC",
|
46
46
|
};
|
47
47
|
|
48
|
-
export const UNI:
|
48
|
+
export const UNI: TokenWithPrices = {
|
49
49
|
address: "0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984",
|
50
50
|
chainId: 10,
|
51
51
|
decimals: 18,
|
package/src/version.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export const version = "5.105.
|
1
|
+
export const version = "5.105.39";
|