thirdweb 5.99.2 → 5.100.0-nightly-713ebe0a2d6d8a409e41ce0f0317fc34b1f221bb-20250520000414
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 +16 -12
- package/dist/cjs/bridge/Buy.js.map +1 -1
- package/dist/cjs/bridge/Chains.js +2 -2
- package/dist/cjs/bridge/Chains.js.map +1 -1
- package/dist/cjs/bridge/Routes.js +2 -2
- package/dist/cjs/bridge/Routes.js.map +1 -1
- package/dist/cjs/bridge/Sell.js +17 -13
- package/dist/cjs/bridge/Sell.js.map +1 -1
- package/dist/cjs/bridge/Status.js +15 -2
- package/dist/cjs/bridge/Status.js.map +1 -1
- package/dist/cjs/bridge/Transfer.js +229 -0
- package/dist/cjs/bridge/Transfer.js.map +1 -0
- package/dist/cjs/bridge/index.js +2 -1
- package/dist/cjs/bridge/index.js.map +1 -1
- package/dist/cjs/bridge/types/Token.js +3 -0
- package/dist/cjs/bridge/types/Token.js.map +1 -0
- package/dist/cjs/exports/wallets.js +3 -1
- package/dist/cjs/exports/wallets.js.map +1 -1
- package/dist/cjs/pay/buyWithCrypto/getQuote.js +159 -53
- package/dist/cjs/pay/buyWithCrypto/getQuote.js.map +1 -1
- package/dist/cjs/pay/buyWithCrypto/getStatus.js +160 -14
- package/dist/cjs/pay/buyWithCrypto/getStatus.js.map +1 -1
- package/dist/cjs/pay/buyWithCrypto/getTransfer.js +95 -37
- package/dist/cjs/pay/buyWithCrypto/getTransfer.js.map +1 -1
- package/dist/cjs/pay/utils/definitions.js +1 -31
- package/dist/cjs/pay/utils/definitions.js.map +1 -1
- package/dist/cjs/react/core/hooks/transaction/useSendTransaction.js +23 -21
- package/dist/cjs/react/core/hooks/transaction/useSendTransaction.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/TransactionsScreen.js +2 -15
- package/dist/cjs/react/web/ui/ConnectWallet/TransactionsScreen.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/useBuyTransactionsToShow.js +0 -135
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/useBuyTransactionsToShow.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/WalletRow.js +3 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/WalletRow.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/fetchBalancesForWallet.js +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/fetchBalancesForWallet.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/pendingSwapTx.js +4 -4
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/pendingSwapTx.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/useSwapSupportedChains.js +83 -34
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/useSwapSupportedChains.js.map +1 -1
- package/dist/cjs/react/web/ui/TransactionButton/ExecutingScreen.js +2 -2
- package/dist/cjs/react/web/ui/TransactionButton/ExecutingScreen.js.map +1 -1
- package/dist/cjs/utils/any-evm/zksync/constants.js +1 -0
- package/dist/cjs/utils/any-evm/zksync/constants.js.map +1 -1
- package/dist/cjs/utils/domains.js +3 -0
- package/dist/cjs/utils/domains.js.map +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/version.js.map +1 -1
- package/dist/cjs/wallets/injected/mipdStore.js +12 -0
- package/dist/cjs/wallets/injected/mipdStore.js.map +1 -1
- package/dist/esm/bridge/Buy.js +16 -12
- package/dist/esm/bridge/Buy.js.map +1 -1
- package/dist/esm/bridge/Chains.js +2 -2
- package/dist/esm/bridge/Chains.js.map +1 -1
- package/dist/esm/bridge/Routes.js +2 -2
- package/dist/esm/bridge/Routes.js.map +1 -1
- package/dist/esm/bridge/Sell.js +17 -13
- package/dist/esm/bridge/Sell.js.map +1 -1
- package/dist/esm/bridge/Status.js +15 -2
- package/dist/esm/bridge/Status.js.map +1 -1
- package/dist/esm/bridge/Transfer.js +226 -0
- package/dist/esm/bridge/Transfer.js.map +1 -0
- package/dist/esm/bridge/index.js +1 -0
- package/dist/esm/bridge/index.js.map +1 -1
- package/dist/esm/bridge/types/Token.js +2 -0
- package/dist/esm/bridge/types/Token.js.map +1 -0
- package/dist/esm/exports/wallets.js +1 -0
- package/dist/esm/exports/wallets.js.map +1 -1
- package/dist/esm/pay/buyWithCrypto/getQuote.js +159 -53
- package/dist/esm/pay/buyWithCrypto/getQuote.js.map +1 -1
- package/dist/esm/pay/buyWithCrypto/getStatus.js +160 -14
- package/dist/esm/pay/buyWithCrypto/getStatus.js.map +1 -1
- package/dist/esm/pay/buyWithCrypto/getTransfer.js +95 -37
- package/dist/esm/pay/buyWithCrypto/getTransfer.js.map +1 -1
- package/dist/esm/pay/utils/definitions.js +0 -25
- package/dist/esm/pay/utils/definitions.js.map +1 -1
- package/dist/esm/react/core/hooks/transaction/useSendTransaction.js +23 -21
- package/dist/esm/react/core/hooks/transaction/useSendTransaction.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/TransactionsScreen.js +2 -15
- package/dist/esm/react/web/ui/ConnectWallet/TransactionsScreen.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/useBuyTransactionsToShow.js +1 -134
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/useBuyTransactionsToShow.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/WalletRow.js +3 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/WalletRow.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/fetchBalancesForWallet.js +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/fetchBalancesForWallet.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/pendingSwapTx.js +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/pendingSwapTx.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/useSwapSupportedChains.js +84 -34
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/useSwapSupportedChains.js.map +1 -1
- package/dist/esm/react/web/ui/TransactionButton/ExecutingScreen.js +2 -2
- package/dist/esm/react/web/ui/TransactionButton/ExecutingScreen.js.map +1 -1
- package/dist/esm/utils/any-evm/zksync/constants.js +1 -0
- package/dist/esm/utils/any-evm/zksync/constants.js.map +1 -1
- package/dist/esm/utils/domains.js +3 -0
- package/dist/esm/utils/domains.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/esm/wallets/injected/mipdStore.js +11 -0
- package/dist/esm/wallets/injected/mipdStore.js.map +1 -1
- package/dist/types/bridge/Buy.d.ts +10 -8
- package/dist/types/bridge/Buy.d.ts.map +1 -1
- package/dist/types/bridge/Sell.d.ts +12 -10
- 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 +199 -0
- package/dist/types/bridge/Transfer.d.ts.map +1 -0
- package/dist/types/bridge/index.d.ts +1 -0
- package/dist/types/bridge/index.d.ts.map +1 -1
- package/dist/types/bridge/types/Route.d.ts +3 -17
- package/dist/types/bridge/types/Route.d.ts.map +1 -1
- package/dist/types/bridge/types/Status.d.ts +15 -0
- package/dist/types/bridge/types/Status.d.ts.map +1 -1
- package/dist/types/bridge/types/Token.d.ts +10 -0
- package/dist/types/bridge/types/Token.d.ts.map +1 -0
- package/dist/types/exports/wallets.d.ts +1 -0
- package/dist/types/exports/wallets.d.ts.map +1 -1
- package/dist/types/pay/buyWithCrypto/commonTypes.d.ts +0 -9
- package/dist/types/pay/buyWithCrypto/commonTypes.d.ts.map +1 -1
- package/dist/types/pay/buyWithCrypto/getQuote.d.ts.map +1 -1
- package/dist/types/pay/buyWithCrypto/getStatus.d.ts +1 -1
- package/dist/types/pay/buyWithCrypto/getStatus.d.ts.map +1 -1
- package/dist/types/pay/buyWithCrypto/getTransfer.d.ts.map +1 -1
- package/dist/types/pay/utils/definitions.d.ts +0 -25
- package/dist/types/pay/utils/definitions.d.ts.map +1 -1
- package/dist/types/react/core/hooks/transaction/useSendTransaction.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/TransactionsScreen.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/useBuyTransactionsToShow.d.ts +2 -13
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/useBuyTransactionsToShow.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/WalletRow.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/pendingSwapTx.d.ts +0 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/pendingSwapTx.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/useSwapSupportedChains.d.ts +8 -4
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/useSwapSupportedChains.d.ts.map +1 -1
- package/dist/types/react/web/ui/MediaRenderer/MediaRenderer.d.ts +1 -1
- package/dist/types/react/web/ui/TransactionButton/ExecutingScreen.d.ts.map +1 -1
- package/dist/types/utils/any-evm/zksync/constants.d.ts.map +1 -1
- package/dist/types/utils/domains.d.ts +6 -0
- package/dist/types/utils/domains.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/injected/mipdStore.d.ts +7 -0
- package/dist/types/wallets/injected/mipdStore.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/bridge/Buy.ts +18 -12
- package/src/bridge/Chains.ts +2 -2
- package/src/bridge/Routes.ts +2 -2
- package/src/bridge/Sell.ts +19 -13
- package/src/bridge/Status.ts +15 -2
- package/src/bridge/Transfer.test.ts +76 -0
- package/src/bridge/Transfer.ts +270 -0
- package/src/bridge/index.ts +1 -0
- package/src/bridge/types/Route.ts +3 -17
- package/src/bridge/types/Status.ts +15 -1
- package/src/bridge/types/Token.ts +10 -0
- package/src/exports/wallets.ts +1 -0
- package/src/extensions/prebuilts/deploy-modular-core.test.ts +2 -1
- package/src/pay/buyWithCrypto/commonTypes.ts +0 -10
- package/src/pay/buyWithCrypto/getQuote.ts +210 -100
- package/src/pay/buyWithCrypto/getStatus.ts +213 -20
- package/src/pay/buyWithCrypto/getTransfer.ts +129 -61
- package/src/pay/utils/definitions.ts +0 -34
- package/src/react/core/hooks/transaction/useSendTransaction.ts +27 -33
- package/src/react/web/ui/ConnectWallet/TransactionsScreen.tsx +29 -35
- package/src/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.tsx +3 -1
- package/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/useBuyTransactionsToShow.ts +2 -181
- package/src/react/web/ui/ConnectWallet/screens/Buy/swap/WalletRow.tsx +3 -1
- package/src/react/web/ui/ConnectWallet/screens/Buy/swap/fetchBalancesForWallet.tsx +1 -1
- package/src/react/web/ui/ConnectWallet/screens/Buy/swap/pendingSwapTx.ts +1 -3
- package/src/react/web/ui/ConnectWallet/screens/Buy/swap/useSwapSupportedChains.ts +118 -63
- package/src/react/web/ui/TransactionButton/ExecutingScreen.tsx +0 -2
- package/src/utils/any-evm/zksync/constants.ts +1 -0
- package/src/utils/domain.test.ts +1 -0
- package/src/utils/domains.ts +8 -0
- package/src/version.ts +1 -1
- package/src/wallets/injected/mipdStore.ts +14 -0
- package/dist/cjs/bridge/constants.js +0 -5
- package/dist/cjs/bridge/constants.js.map +0 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistory.js +0 -54
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistory.js.map +0 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistoryButton.js +0 -52
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistoryButton.js.map +0 -1
- package/dist/esm/bridge/constants.js +0 -2
- package/dist/esm/bridge/constants.js.map +0 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistory.js +0 -51
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistory.js.map +0 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistoryButton.js +0 -48
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistoryButton.js.map +0 -1
- package/dist/types/bridge/constants.d.ts +0 -2
- package/dist/types/bridge/constants.d.ts.map +0 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistory.d.ts +0 -10
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistory.d.ts.map +0 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistoryButton.d.ts +0 -9
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistoryButton.d.ts.map +0 -1
- package/src/bridge/constants.ts +0 -1
- package/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistory.tsx +0 -163
- package/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistoryButton.tsx +0 -127
package/dist/esm/bridge/Buy.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import { defineChain } from "../chains/utils.js";
|
2
|
+
import { getThirdwebBaseUrl } from "../utils/domains.js";
|
2
3
|
import { getClientFetch } from "../utils/fetch.js";
|
3
4
|
import { stringify } from "../utils/json.js";
|
4
|
-
import { UNIVERSAL_BRIDGE_URL } from "./constants.js";
|
5
5
|
/**
|
6
6
|
* Retrieves a Universal Bridge quote for the provided buy intent. The quote will specify the necessary `originAmount` to receive the desired `destinationAmount`, which is specified with the `buyAmountWei` option.
|
7
7
|
*
|
@@ -100,12 +100,13 @@ export async function quote(options) {
|
|
100
100
|
const { originChainId, originTokenAddress, destinationChainId, destinationTokenAddress, client, maxSteps, } = options;
|
101
101
|
const amount = "buyAmountWei" in options ? options.buyAmountWei : options.amount;
|
102
102
|
const clientFetch = getClientFetch(client);
|
103
|
-
const url = new URL(`${
|
103
|
+
const url = new URL(`${getThirdwebBaseUrl("bridge")}/v1/buy/quote`);
|
104
104
|
url.searchParams.set("originChainId", originChainId.toString());
|
105
105
|
url.searchParams.set("originTokenAddress", originTokenAddress);
|
106
106
|
url.searchParams.set("destinationChainId", destinationChainId.toString());
|
107
107
|
url.searchParams.set("destinationTokenAddress", destinationTokenAddress);
|
108
108
|
url.searchParams.set("buyAmountWei", amount.toString());
|
109
|
+
url.searchParams.set("amount", amount.toString());
|
109
110
|
if (maxSteps) {
|
110
111
|
url.searchParams.set("maxSteps", maxSteps.toString());
|
111
112
|
}
|
@@ -152,7 +153,7 @@ export async function quote(options) {
|
|
152
153
|
* This will return a quote that might look like:
|
153
154
|
* ```typescript
|
154
155
|
* {
|
155
|
-
* originAmount:
|
156
|
+
* originAmount: 2000030000n,
|
156
157
|
* destinationAmount: 1000000000000000000n,
|
157
158
|
* blockNumber: 22026509n,
|
158
159
|
* timestamp: 1741730936680,
|
@@ -161,11 +162,11 @@ export async function quote(options) {
|
|
161
162
|
* {
|
162
163
|
* originToken: {
|
163
164
|
* chainId: 1,
|
164
|
-
* address: "
|
165
|
-
* symbol: "
|
166
|
-
* name: "
|
167
|
-
* decimals:
|
168
|
-
* priceUsd:
|
165
|
+
* address: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
166
|
+
* symbol: "USDC",
|
167
|
+
* name: "USDC",
|
168
|
+
* decimals: 6,
|
169
|
+
* priceUsd: 1,
|
169
170
|
* iconUri: "https://..."
|
170
171
|
* },
|
171
172
|
* destinationToken: {
|
@@ -177,7 +178,7 @@ export async function quote(options) {
|
|
177
178
|
* priceUsd: 2000,
|
178
179
|
* iconUri: "https://..."
|
179
180
|
* },
|
180
|
-
* originAmount:
|
181
|
+
* originAmount: 2000030000n,
|
181
182
|
* destinationAmount: 1000000000000000000n,
|
182
183
|
* estimatedExecutionTimeMs: 1000
|
183
184
|
* transactions: [
|
@@ -203,7 +204,7 @@ export async function quote(options) {
|
|
203
204
|
* expiration: 1741730936680,
|
204
205
|
* intent: {
|
205
206
|
* originChainId: 1,
|
206
|
-
* originTokenAddress: "
|
207
|
+
* originTokenAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
207
208
|
* destinationChainId: 10,
|
208
209
|
* destinationTokenAddress: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
|
209
210
|
* amount: 1000000000000000000n
|
@@ -273,14 +274,15 @@ export async function quote(options) {
|
|
273
274
|
export async function prepare(options) {
|
274
275
|
const { originChainId, originTokenAddress, destinationChainId, destinationTokenAddress, sender, receiver, client, amount, purchaseData, maxSteps, } = options;
|
275
276
|
const clientFetch = getClientFetch(client);
|
276
|
-
const url = new URL(`${
|
277
|
+
const url = new URL(`${getThirdwebBaseUrl("bridge")}/v1/buy/prepare`);
|
277
278
|
const response = await clientFetch(url.toString(), {
|
278
279
|
method: "POST",
|
279
280
|
headers: {
|
280
281
|
"Content-Type": "application/json",
|
281
282
|
},
|
282
283
|
body: stringify({
|
283
|
-
buyAmountWei: amount.toString(),
|
284
|
+
buyAmountWei: amount.toString(), // legacy
|
285
|
+
amount: amount.toString(),
|
284
286
|
originChainId: originChainId.toString(),
|
285
287
|
originTokenAddress,
|
286
288
|
destinationChainId: destinationChainId.toString(),
|
@@ -317,6 +319,8 @@ export async function prepare(options) {
|
|
317
319
|
destinationChainId,
|
318
320
|
destinationTokenAddress,
|
319
321
|
amount,
|
322
|
+
sender,
|
323
|
+
receiver,
|
320
324
|
},
|
321
325
|
};
|
322
326
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Buy.js","sourceRoot":"","sources":["../../../src/bridge/Buy.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,OAAO,EAAE,
|
1
|
+
{"version":3,"file":"Buy.js","sourceRoot":"","sources":["../../../src/bridge/Buy.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAG7C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6FG;AACH,MAAM,CAAC,KAAK,UAAU,KAAK,CAAC,OAAsB;IAChD,MAAM,EACJ,aAAa,EACb,kBAAkB,EAClB,kBAAkB,EAClB,uBAAuB,EACvB,MAAM,EACN,QAAQ,GACT,GAAG,OAAO,CAAC;IACZ,MAAM,MAAM,GACV,cAAc,IAAI,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC;IAEpE,MAAM,WAAW,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;IAC3C,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,kBAAkB,CAAC,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,kBAAkB;YAClB,uBAAuB;YACvB,MAAM;YACN,MAAM;YACN,QAAQ;SACT;KACF,CAAC;AACJ,CAAC"}
|
@@ -1,5 +1,5 @@
|
|
1
|
+
import { getThirdwebBaseUrl } from "../utils/domains.js";
|
1
2
|
import { getClientFetch } from "../utils/fetch.js";
|
2
|
-
import { UNIVERSAL_BRIDGE_URL } from "./constants.js";
|
3
3
|
/**
|
4
4
|
* Retrieves supported Universal Bridge chains.
|
5
5
|
*
|
@@ -50,7 +50,7 @@ import { UNIVERSAL_BRIDGE_URL } from "./constants.js";
|
|
50
50
|
export async function chains(options) {
|
51
51
|
const { client } = options;
|
52
52
|
const clientFetch = getClientFetch(client);
|
53
|
-
const url = new URL(`${
|
53
|
+
const url = new URL(`${getThirdwebBaseUrl("bridge")}/v1/chains`);
|
54
54
|
const response = await clientFetch(url.toString());
|
55
55
|
if (!response.ok) {
|
56
56
|
const errorJson = await response.json();
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Chains.js","sourceRoot":"","sources":["../../../src/bridge/Chains.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,
|
1
|
+
{"version":3,"file":"Chains.js","sourceRoot":"","sources":["../../../src/bridge/Chains.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAGnD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,OAAuB;IAClD,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAE3B,MAAM,WAAW,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;IAC3C,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,kBAAkB,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;IAEjE,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC;IACnD,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACjB,MAAM,SAAS,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QACxC,MAAM,IAAI,KAAK,CAAC,GAAG,SAAS,CAAC,IAAI,MAAM,SAAS,CAAC,OAAO,EAAE,CAAC,CAAC;IAC9D,CAAC;IAED,MAAM,EAAE,IAAI,EAAE,GAAsB,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;IAC1D,OAAO,IAAI,CAAC;AACd,CAAC"}
|
@@ -1,5 +1,5 @@
|
|
1
|
+
import { getThirdwebBaseUrl } from "../utils/domains.js";
|
1
2
|
import { getClientFetch } from "../utils/fetch.js";
|
2
|
-
import { UNIVERSAL_BRIDGE_URL } from "./constants.js";
|
3
3
|
/**
|
4
4
|
* Retrieves supported Universal Bridge routes based on the provided filters.
|
5
5
|
*
|
@@ -118,7 +118,7 @@ import { UNIVERSAL_BRIDGE_URL } from "./constants.js";
|
|
118
118
|
export async function routes(options) {
|
119
119
|
const { client, originChainId, originTokenAddress, destinationChainId, destinationTokenAddress, maxSteps, sortBy, limit, offset, } = options;
|
120
120
|
const clientFetch = getClientFetch(client);
|
121
|
-
const url = new URL(`${
|
121
|
+
const url = new URL(`${getThirdwebBaseUrl("bridge")}/v1/routes`);
|
122
122
|
if (originChainId) {
|
123
123
|
url.searchParams.set("originChainId", originChainId.toString());
|
124
124
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Routes.js","sourceRoot":"","sources":["../../../src/bridge/Routes.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,
|
1
|
+
{"version":3,"file":"Routes.js","sourceRoot":"","sources":["../../../src/bridge/Routes.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAGnD;;;;;;;;;;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E,CAAC,CAAC;IAClD,CAAC;IACD,IAAI,MAAM,EAAE,CAAC;QACX,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;IACpD,CAAC;IACD,IAAI,MAAM,EAAE,CAAC;QACX,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IACzC,CAAC;IAED,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC;IACnD,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACjB,MAAM,SAAS,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QACxC,MAAM,IAAI,KAAK,CAAC,GAAG,SAAS,CAAC,IAAI,MAAM,SAAS,CAAC,OAAO,EAAE,CAAC,CAAC;IAC9D,CAAC;IAED,MAAM,EAAE,IAAI,EAAE,GAAsB,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;IAC1D,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/dist/esm/bridge/Sell.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import { defineChain } from "../chains/utils.js";
|
2
|
+
import { getThirdwebBaseUrl } from "../utils/domains.js";
|
2
3
|
import { getClientFetch } from "../utils/fetch.js";
|
3
4
|
import { stringify } from "../utils/json.js";
|
4
|
-
import { UNIVERSAL_BRIDGE_URL } from "./constants.js";
|
5
5
|
/**
|
6
6
|
* Retrieves a Universal Bridge quote for the provided sell intent. The quote will specify the expected `destinationAmount` that will be received in exchange for the specified `originAmount`, which is specified with the `sellAmountWei` option.
|
7
7
|
*
|
@@ -99,12 +99,13 @@ import { UNIVERSAL_BRIDGE_URL } from "./constants.js";
|
|
99
99
|
export async function quote(options) {
|
100
100
|
const { originChainId, originTokenAddress, destinationChainId, destinationTokenAddress, amount, client, maxSteps, } = options;
|
101
101
|
const clientFetch = getClientFetch(client);
|
102
|
-
const url = new URL(`${
|
102
|
+
const url = new URL(`${getThirdwebBaseUrl("bridge")}/v1/sell/quote`);
|
103
103
|
url.searchParams.set("originChainId", originChainId.toString());
|
104
104
|
url.searchParams.set("originTokenAddress", originTokenAddress);
|
105
105
|
url.searchParams.set("destinationChainId", destinationChainId.toString());
|
106
106
|
url.searchParams.set("destinationTokenAddress", destinationTokenAddress);
|
107
107
|
url.searchParams.set("sellAmountWei", amount.toString());
|
108
|
+
url.searchParams.set("amount", amount.toString());
|
108
109
|
if (typeof maxSteps !== "undefined") {
|
109
110
|
url.searchParams.set("maxSteps", maxSteps.toString());
|
110
111
|
}
|
@@ -150,7 +151,7 @@ export async function quote(options) {
|
|
150
151
|
* This will return a quote that might look like:
|
151
152
|
* ```typescript
|
152
153
|
* {
|
153
|
-
* originAmount:
|
154
|
+
* originAmount: 2000000000n,
|
154
155
|
* destinationAmount: 9980000000000000000n,
|
155
156
|
* blockNumber: 22026509n,
|
156
157
|
* timestamp: 1741730936680,
|
@@ -159,11 +160,11 @@ export async function quote(options) {
|
|
159
160
|
* {
|
160
161
|
* originToken: {
|
161
162
|
* chainId: 1,
|
162
|
-
* address: "
|
163
|
-
* symbol: "
|
164
|
-
* name: "
|
165
|
-
* decimals:
|
166
|
-
* priceUsd:
|
163
|
+
* address: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
164
|
+
* symbol: "USDC",
|
165
|
+
* name: "USDC",
|
166
|
+
* decimals: 6,
|
167
|
+
* priceUsd: 1,
|
167
168
|
* iconUri: "https://..."
|
168
169
|
* },
|
169
170
|
* destinationToken: {
|
@@ -175,7 +176,7 @@ export async function quote(options) {
|
|
175
176
|
* priceUsd: 2000,
|
176
177
|
* iconUri: "https://..."
|
177
178
|
* },
|
178
|
-
* originAmount:
|
179
|
+
* originAmount: 2000000000n,
|
179
180
|
* destinationAmount: 9980000000000000000n,
|
180
181
|
* estimatedExecutionTimeMs: 1000
|
181
182
|
* }
|
@@ -201,10 +202,10 @@ export async function quote(options) {
|
|
201
202
|
* expiration: 1741730936680,
|
202
203
|
* intent: {
|
203
204
|
* originChainId: 1,
|
204
|
-
* originTokenAddress:
|
205
|
+
* originTokenAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
205
206
|
* destinationChainId: 10,
|
206
|
-
* destinationTokenAddress:
|
207
|
-
* amount:
|
207
|
+
* destinationTokenAddress: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
|
208
|
+
* amount: 2000000000n
|
208
209
|
* }
|
209
210
|
* }
|
210
211
|
* ```
|
@@ -271,7 +272,7 @@ export async function quote(options) {
|
|
271
272
|
export async function prepare(options) {
|
272
273
|
const { originChainId, originTokenAddress, destinationChainId, destinationTokenAddress, amount, sender, receiver, client, purchaseData, maxSteps, } = options;
|
273
274
|
const clientFetch = getClientFetch(client);
|
274
|
-
const url = new URL(`${
|
275
|
+
const url = new URL(`${getThirdwebBaseUrl("bridge")}/v1/sell/prepare`);
|
275
276
|
const response = await clientFetch(url.toString(), {
|
276
277
|
method: "POST",
|
277
278
|
headers: {
|
@@ -279,6 +280,7 @@ export async function prepare(options) {
|
|
279
280
|
},
|
280
281
|
body: stringify({
|
281
282
|
sellAmountWei: amount.toString(),
|
283
|
+
amount: amount.toString(),
|
282
284
|
originChainId: originChainId.toString(),
|
283
285
|
originTokenAddress,
|
284
286
|
destinationChainId: destinationChainId.toString(),
|
@@ -316,6 +318,8 @@ export async function prepare(options) {
|
|
316
318
|
destinationChainId,
|
317
319
|
destinationTokenAddress,
|
318
320
|
amount,
|
321
|
+
sender,
|
322
|
+
receiver,
|
319
323
|
purchaseData,
|
320
324
|
},
|
321
325
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Sell.js","sourceRoot":"","sources":["../../../src/bridge/Sell.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,OAAO,EAAE,
|
1
|
+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C;QACjD,WAAW,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS;QACpE,SAAS,EAAE,IAAI,CAAC,SAAS;QACzB,wBAAwB,EAAE,IAAI,CAAC,wBAAwB;QACvD,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;YAC/B,GAAG,IAAI;YACP,YAAY,EAAE,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;gBACpD,GAAG,WAAW;gBACd,KAAK,EAAE,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS;gBAChE,MAAM;gBACN,KAAK,EAAE,WAAW,CAAC,WAAW,CAAC,OAAO,CAAC;aACxC,CAAC,CAAC;SACJ,CAAC,CAAC;QACH,UAAU,EAAE,IAAI,CAAC,UAAU;QAC3B,MAAM,EAAE;YACN,aAAa;YACb,kBAAkB;YAClB,kBAAkB;YAClB,uBAAuB;YACvB,MAAM;YACN,MAAM;YACN,QAAQ;YACR,YAAY;SACb;KACF,CAAC;AACJ,CAAC"}
|
@@ -1,5 +1,5 @@
|
|
1
|
+
import { getThirdwebBaseUrl } from "../utils/domains.js";
|
1
2
|
import { getClientFetch } from "../utils/fetch.js";
|
2
|
-
import { UNIVERSAL_BRIDGE_URL } from "./constants.js";
|
3
3
|
/**
|
4
4
|
* Retrieves a Universal Bridge quote for the provided sell intent. The quote will specify the expected `destinationAmount` that will be received in exchange for the specified `originAmount`, which is specified with the `sellAmountWei` option.
|
5
5
|
*
|
@@ -102,7 +102,7 @@ export async function status(options) {
|
|
102
102
|
const { transactionHash, client } = options;
|
103
103
|
const chainId = "chainId" in options ? options.chainId : options.chain.id;
|
104
104
|
const clientFetch = getClientFetch(client);
|
105
|
-
const url = new URL(`${
|
105
|
+
const url = new URL(`${getThirdwebBaseUrl("bridge")}/v1/status`);
|
106
106
|
url.searchParams.set("transactionHash", transactionHash);
|
107
107
|
url.searchParams.set("chainId", chainId.toString());
|
108
108
|
const response = await clientFetch(url.toString());
|
@@ -114,6 +114,7 @@ export async function status(options) {
|
|
114
114
|
if (data.status === "FAILED") {
|
115
115
|
return {
|
116
116
|
status: "FAILED",
|
117
|
+
paymentId: data.paymentId,
|
117
118
|
transactions: data.transactions,
|
118
119
|
};
|
119
120
|
}
|
@@ -126,11 +127,18 @@ export async function status(options) {
|
|
126
127
|
originTokenAddress: data.originTokenAddress,
|
127
128
|
destinationTokenAddress: data.destinationTokenAddress,
|
128
129
|
transactions: data.transactions,
|
130
|
+
originToken: data.originToken,
|
131
|
+
destinationToken: data.destinationToken,
|
132
|
+
sender: data.sender,
|
133
|
+
receiver: data.receiver,
|
134
|
+
paymentId: data.paymentId,
|
135
|
+
purchaseData: data.purchaseData,
|
129
136
|
};
|
130
137
|
}
|
131
138
|
if (data.status === "NOT_FOUND") {
|
132
139
|
return {
|
133
140
|
status: "NOT_FOUND",
|
141
|
+
paymentId: data.paymentId,
|
134
142
|
transactions: [],
|
135
143
|
};
|
136
144
|
}
|
@@ -143,6 +151,11 @@ export async function status(options) {
|
|
143
151
|
originTokenAddress: data.originTokenAddress,
|
144
152
|
destinationTokenAddress: data.destinationTokenAddress,
|
145
153
|
transactions: data.transactions,
|
154
|
+
originToken: data.originToken,
|
155
|
+
destinationToken: data.destinationToken,
|
156
|
+
sender: data.sender,
|
157
|
+
receiver: data.receiver,
|
158
|
+
paymentId: data.paymentId,
|
146
159
|
purchaseData: data.purchaseData,
|
147
160
|
};
|
148
161
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Status.js","sourceRoot":"","sources":["../../../src/bridge/Status.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,
|
1
|
+
{"version":3,"file":"Status.js","sourceRoot":"","sources":["../../../src/b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,uBAAuB;QACrD,YAAY,EAAE,IAAI,CAAC,YAAY;QAC/B,WAAW,EAAE,IAAI,CAAC,WAAW;QAC7B,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;QACvC,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,SAAS,EAAE,IAAI,CAAC,SAAS;QACzB,YAAY,EAAE,IAAI,CAAC,YAAY;KAChC,CAAC;AACJ,CAAC"}
|
@@ -0,0 +1,226 @@
|
|
1
|
+
import { defineChain } from "../chains/utils.js";
|
2
|
+
import { getThirdwebBaseUrl } from "../utils/domains.js";
|
3
|
+
import { getClientFetch } from "../utils/fetch.js";
|
4
|
+
import { stringify } from "../utils/json.js";
|
5
|
+
/**
|
6
|
+
* Prepares a **finalized** Universal Bridge quote for the provided transfer request with transaction data.
|
7
|
+
*
|
8
|
+
* @example
|
9
|
+
* ```typescript
|
10
|
+
* import { Bridge, NATIVE_TOKEN_ADDRESS } from "thirdweb";
|
11
|
+
*
|
12
|
+
* const quote = await Bridge.Transfer.prepare({
|
13
|
+
* chainId: 1,
|
14
|
+
* tokenAddress: NATIVE_TOKEN_ADDRESS,
|
15
|
+
* amount: toWei("0.01"),
|
16
|
+
* sender: "0x...",
|
17
|
+
* receiver: "0x...",
|
18
|
+
* client: thirdwebClient,
|
19
|
+
* });
|
20
|
+
* ```
|
21
|
+
*
|
22
|
+
* This will return a quote that might look like:
|
23
|
+
* ```typescript
|
24
|
+
* {
|
25
|
+
* originAmount: 10000026098875381n,
|
26
|
+
* destinationAmount: 10000000000000000n,
|
27
|
+
* blockNumber: 22026509n,
|
28
|
+
* timestamp: 1741730936680,
|
29
|
+
* estimatedExecutionTimeMs: 1000
|
30
|
+
* steps: [
|
31
|
+
* {
|
32
|
+
* originToken: {
|
33
|
+
* chainId: 1,
|
34
|
+
* address: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
|
35
|
+
* symbol: "ETH",
|
36
|
+
* name: "Ethereum",
|
37
|
+
* decimals: 18,
|
38
|
+
* priceUsd: 2000,
|
39
|
+
* iconUri: "https://..."
|
40
|
+
* },
|
41
|
+
* destinationToken: {
|
42
|
+
* chainId: 1,
|
43
|
+
* address: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
|
44
|
+
* symbol: "ETH",
|
45
|
+
* name: "Ethereum",
|
46
|
+
* decimals: 18,
|
47
|
+
* priceUsd: 2000,
|
48
|
+
* iconUri: "https://..."
|
49
|
+
* },
|
50
|
+
* originAmount: 10000026098875381n,
|
51
|
+
* destinationAmount: 10000000000000000n,
|
52
|
+
* estimatedExecutionTimeMs: 1000
|
53
|
+
* transactions: [
|
54
|
+
* {
|
55
|
+
* action: "approval",
|
56
|
+
* id: "0x",
|
57
|
+
* to: "0x...",
|
58
|
+
* data: "0x...",
|
59
|
+
* chainId: 1,
|
60
|
+
* type: "eip1559"
|
61
|
+
* },
|
62
|
+
* {
|
63
|
+
* action: "transfer",
|
64
|
+
* to: "0x...",
|
65
|
+
* value: 10000026098875381n,
|
66
|
+
* data: "0x...",
|
67
|
+
* chainId: 1,
|
68
|
+
* type: "eip1559"
|
69
|
+
* }
|
70
|
+
* ]
|
71
|
+
* }
|
72
|
+
* ],
|
73
|
+
* expiration: 1741730936680,
|
74
|
+
* intent: {
|
75
|
+
* chainId: 1,
|
76
|
+
* tokenAddress: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
|
77
|
+
* amount: 10000000000000000n,
|
78
|
+
* sender: "0x...",
|
79
|
+
* receiver: "0x..."
|
80
|
+
* }
|
81
|
+
* }
|
82
|
+
* ```
|
83
|
+
*
|
84
|
+
* ## Sending the transactions
|
85
|
+
* The `transactions` array is a series of [ox](https://oxlib.sh) EIP-1559 transactions that must be executed one after the other in order to fulfill the complete route. There are a few things to keep in mind when executing these transactions:
|
86
|
+
* - Approvals will have the `approval` action specified. You can perform approvals with `sendAndConfirmTransaction`, then proceed to the next transaction.
|
87
|
+
* - All transactions are assumed to be executed by the `sender` address, regardless of which chain they are on. The final transaction will use the `receiver` as the recipient address.
|
88
|
+
* - If an `expiration` timestamp is provided, all transactions must be executed before that time to guarantee successful execution at the specified price.
|
89
|
+
*
|
90
|
+
* NOTE: To get the status of each non-approval transaction, use `Bridge.status` rather than checking for transaction inclusion. This function will ensure full completion of the transfer.
|
91
|
+
*
|
92
|
+
* You can access this functions input and output types with `Transfer.prepare.Options` and `Transfer.prepare.Result`, respectively.
|
93
|
+
*
|
94
|
+
* You can include arbitrary data to be included on any webhooks and status responses with the `purchaseData` option.
|
95
|
+
*
|
96
|
+
* ```ts
|
97
|
+
* const quote = await Bridge.Transfer.prepare({
|
98
|
+
* chainId: 1,
|
99
|
+
* tokenAddress: NATIVE_TOKEN_ADDRESS,
|
100
|
+
* amount: toWei("0.01"),
|
101
|
+
* sender: "0x...",
|
102
|
+
* receiver: "0x...",
|
103
|
+
* purchaseData: {
|
104
|
+
* reference: "payment-123",
|
105
|
+
* metadata: {
|
106
|
+
* note: "Transfer to Alice"
|
107
|
+
* }
|
108
|
+
* },
|
109
|
+
* client: thirdwebClient,
|
110
|
+
* });
|
111
|
+
* ```
|
112
|
+
*
|
113
|
+
* ## Fees
|
114
|
+
* There may be fees associated with the transfer. These fees are paid by the `feePayer` address, which defaults to the `sender` address. You can specify a different address with the `feePayer` option. If you do not specify an option or explicitly specify `sender`, the fees will be added to the input amount. If you specify the `receiver` as the fee payer the fees will be subtracted from the destination amount.
|
115
|
+
*
|
116
|
+
* For example, if you were to request a transfer with `feePayer` set to `receiver`:
|
117
|
+
* ```typescript
|
118
|
+
* const quote = await Bridge.Transfer.prepare({
|
119
|
+
* chainId: 1,
|
120
|
+
* tokenAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC
|
121
|
+
* amount: 100_000_000n, // 100 USDC
|
122
|
+
* sender: "0x...",
|
123
|
+
* receiver: "0x...",
|
124
|
+
* feePayer: "receiver",
|
125
|
+
* client: thirdwebClient,
|
126
|
+
* });
|
127
|
+
* ```
|
128
|
+
*
|
129
|
+
* The returned quote might look like:
|
130
|
+
* ```typescript
|
131
|
+
* {
|
132
|
+
* originAmount: 100_000_000n, // 100 USDC
|
133
|
+
* destinationAmount: 99_970_000n, // 99.97 USDC
|
134
|
+
* ...
|
135
|
+
* }
|
136
|
+
* ```
|
137
|
+
*
|
138
|
+
* If you were to request a transfer with `feePayer` set to `sender`:
|
139
|
+
* ```typescript
|
140
|
+
* const quote = await Bridge.Transfer.prepare({
|
141
|
+
* chainId: 1,
|
142
|
+
* tokenAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC
|
143
|
+
* amount: 100_000_000n, // 100 USDC
|
144
|
+
* sender: "0x...",
|
145
|
+
* receiver: "0x...",
|
146
|
+
* feePayer: "sender",
|
147
|
+
* client: thirdwebClient,
|
148
|
+
* });
|
149
|
+
* ```
|
150
|
+
*
|
151
|
+
* The returned quote might look like:
|
152
|
+
* ```typescript
|
153
|
+
* {
|
154
|
+
* originAmount: 100_030_000n, // 100.03 USDC
|
155
|
+
* destinationAmount: 100_000_000n, // 100 USDC
|
156
|
+
* ...
|
157
|
+
* }
|
158
|
+
* ```
|
159
|
+
*
|
160
|
+
* @param options - The options for the quote.
|
161
|
+
* @param options.chainId - The chain ID of the token.
|
162
|
+
* @param options.tokenAddress - The address of the token.
|
163
|
+
* @param options.amount - The amount of the token to transfer.
|
164
|
+
* @param options.sender - The address of the sender.
|
165
|
+
* @param options.receiver - The address of the recipient.
|
166
|
+
* @param options.purchaseData - Arbitrary data to be passed to the transfer function and included with any webhooks or status calls.
|
167
|
+
* @param options.client - Your thirdweb client.
|
168
|
+
* @param [options.feePayer] - The address that will pay the fees for the transfer. If not specified, the sender will be used. Values can be "sender" or "receiver".
|
169
|
+
*
|
170
|
+
* @returns A promise that resolves to a finalized quote and transactions for the requested transfer.
|
171
|
+
*
|
172
|
+
* @throws Will throw an error if there is an issue fetching the quote.
|
173
|
+
* @bridge Transfer
|
174
|
+
* @beta
|
175
|
+
*/
|
176
|
+
export async function prepare(options) {
|
177
|
+
const { chainId, tokenAddress, sender, receiver, client, amount, purchaseData, feePayer, } = options;
|
178
|
+
const clientFetch = getClientFetch(client);
|
179
|
+
const url = new URL(`${getThirdwebBaseUrl("bridge")}/v1/transfer/prepare`);
|
180
|
+
const response = await clientFetch(url.toString(), {
|
181
|
+
method: "POST",
|
182
|
+
headers: {
|
183
|
+
"Content-Type": "application/json",
|
184
|
+
},
|
185
|
+
body: stringify({
|
186
|
+
transferAmountWei: amount.toString(), // legacy
|
187
|
+
amount: amount.toString(),
|
188
|
+
chainId: chainId.toString(),
|
189
|
+
tokenAddress,
|
190
|
+
sender,
|
191
|
+
receiver,
|
192
|
+
purchaseData,
|
193
|
+
feePayer,
|
194
|
+
}),
|
195
|
+
});
|
196
|
+
if (!response.ok) {
|
197
|
+
const errorJson = await response.json();
|
198
|
+
throw new Error(`${errorJson.code} | ${errorJson.message} - ${errorJson.correlationId}`);
|
199
|
+
}
|
200
|
+
const { data } = await response.json();
|
201
|
+
return {
|
202
|
+
originAmount: BigInt(data.originAmount),
|
203
|
+
destinationAmount: BigInt(data.destinationAmount),
|
204
|
+
blockNumber: data.blockNumber ? BigInt(data.blockNumber) : undefined,
|
205
|
+
timestamp: data.timestamp,
|
206
|
+
estimatedExecutionTimeMs: data.estimatedExecutionTimeMs,
|
207
|
+
steps: data.steps.map((step) => ({
|
208
|
+
...step,
|
209
|
+
transactions: step.transactions.map((transaction) => ({
|
210
|
+
...transaction,
|
211
|
+
value: transaction.value ? BigInt(transaction.value) : undefined,
|
212
|
+
client,
|
213
|
+
chain: defineChain(transaction.chainId),
|
214
|
+
})),
|
215
|
+
})),
|
216
|
+
intent: {
|
217
|
+
chainId,
|
218
|
+
tokenAddress,
|
219
|
+
amount,
|
220
|
+
sender,
|
221
|
+
receiver,
|
222
|
+
feePayer,
|
223
|
+
},
|
224
|
+
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ACT;KACF,CAAC;AACJ,CAAC"}
|
package/dist/esm/bridge/index.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/bridge/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAChC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC"}
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/bridge/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAChC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Token.js","sourceRoot":"","sources":["../../../../src/bridge/types/Token.ts"],"names":[],"mappings":""}
|
@@ -31,6 +31,7 @@ export * as EIP1193 from "../adapters/eip1193/index.js";
|
|
31
31
|
// WEB ONLY EXPORTS
|
32
32
|
// injected
|
33
33
|
export { injectedProvider } from "../wallets/injected/mipdStore.js";
|
34
|
+
export { getInstalledWallets } from "../wallets/injected/mipdStore.js";
|
34
35
|
export { autoConnect } from "../wallets/connection/autoConnect.js";
|
35
36
|
export { deploySmartAccount } from "../wallets/smart/lib/signing.js";
|
36
37
|
//# sourceMappingURL=wallets.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"wallets.js","sourceRoot":"","sources":["../../../src/exports/wallets.ts"],"names":[],"mappings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