thirdweb 5.105.16 → 5.105.17-nightly-31d7173432d7437000787434da91f2b1608128fb-20250719000426
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.map +1 -1
- package/dist/cjs/bridge/Sell.js.map +1 -1
- package/dist/cjs/chains/chain-definitions/etherlink-testnet.js +24 -0
- package/dist/cjs/chains/chain-definitions/etherlink-testnet.js.map +1 -0
- package/dist/cjs/chains/chain-definitions/etherlink.js +23 -0
- package/dist/cjs/chains/chain-definitions/etherlink.js.map +1 -0
- package/dist/cjs/engine/create-server-wallet.js +1 -1
- package/dist/cjs/engine/server-wallet.js +1 -2
- package/dist/cjs/engine/server-wallet.js.map +1 -1
- package/dist/cjs/exports/chains.js +6 -2
- package/dist/cjs/exports/chains.js.map +1 -1
- package/dist/cjs/react/core/hooks/usePaymentMethods.js +32 -10
- package/dist/cjs/react/core/hooks/usePaymentMethods.js.map +1 -1
- package/dist/cjs/react/web/ui/Bridge/BuyWidget.js +12 -1
- package/dist/cjs/react/web/ui/Bridge/BuyWidget.js.map +1 -1
- package/dist/cjs/react/web/ui/Bridge/TransactionPayment.js +6 -4
- package/dist/cjs/react/web/ui/Bridge/TransactionPayment.js.map +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/version.js.map +1 -1
- package/dist/esm/bridge/Buy.js.map +1 -1
- package/dist/esm/bridge/Sell.js.map +1 -1
- package/dist/esm/chains/chain-definitions/etherlink-testnet.js +21 -0
- package/dist/esm/chains/chain-definitions/etherlink-testnet.js.map +1 -0
- package/dist/esm/chains/chain-definitions/etherlink.js +20 -0
- package/dist/esm/chains/chain-definitions/etherlink.js.map +1 -0
- package/dist/esm/engine/create-server-wallet.js +1 -1
- package/dist/esm/engine/server-wallet.js +1 -2
- package/dist/esm/engine/server-wallet.js.map +1 -1
- package/dist/esm/exports/chains.js +2 -0
- package/dist/esm/exports/chains.js.map +1 -1
- package/dist/esm/react/core/hooks/usePaymentMethods.js +32 -10
- package/dist/esm/react/core/hooks/usePaymentMethods.js.map +1 -1
- package/dist/esm/react/web/ui/Bridge/BuyWidget.js +12 -1
- package/dist/esm/react/web/ui/Bridge/BuyWidget.js.map +1 -1
- package/dist/esm/react/web/ui/Bridge/TransactionPayment.js +6 -4
- package/dist/esm/react/web/ui/Bridge/TransactionPayment.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/types/bridge/Buy.d.ts +50 -0
- package/dist/types/bridge/Buy.d.ts.map +1 -1
- package/dist/types/bridge/Chains.d.ts +17 -0
- package/dist/types/bridge/Chains.d.ts.map +1 -1
- package/dist/types/bridge/Onramp.d.ts +30 -0
- package/dist/types/bridge/Onramp.d.ts.map +1 -1
- package/dist/types/bridge/Routes.d.ts +27 -0
- package/dist/types/bridge/Routes.d.ts.map +1 -1
- package/dist/types/bridge/Sell.d.ts +49 -0
- package/dist/types/bridge/Sell.d.ts.map +1 -1
- package/dist/types/bridge/Status.d.ts +23 -0
- package/dist/types/bridge/Status.d.ts.map +1 -1
- package/dist/types/bridge/Transfer.d.ts +24 -0
- package/dist/types/bridge/Transfer.d.ts.map +1 -1
- package/dist/types/chains/chain-definitions/etherlink-testnet.d.ts +7 -0
- package/dist/types/chains/chain-definitions/etherlink-testnet.d.ts.map +1 -0
- package/dist/types/chains/chain-definitions/etherlink.d.ts +7 -0
- package/dist/types/chains/chain-definitions/etherlink.d.ts.map +1 -0
- package/dist/types/engine/create-server-wallet.d.ts +1 -1
- package/dist/types/engine/server-wallet.d.ts +1 -2
- package/dist/types/engine/server-wallet.d.ts.map +1 -1
- package/dist/types/exports/chains.d.ts +2 -0
- package/dist/types/exports/chains.d.ts.map +1 -1
- package/dist/types/react/core/hooks/usePaymentMethods.d.ts.map +1 -1
- package/dist/types/react/web/ui/Bridge/BuyWidget.d.ts.map +1 -1
- package/dist/types/react/web/ui/Bridge/TransactionPayment.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/dist/types/version.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/bridge/Buy.ts +50 -0
- package/src/bridge/Chains.ts +17 -0
- package/src/bridge/Onramp.ts +30 -0
- package/src/bridge/Routes.ts +27 -0
- package/src/bridge/Sell.ts +49 -0
- package/src/bridge/Status.ts +23 -0
- package/src/bridge/Transfer.ts +24 -0
- package/src/chains/chain-definitions/etherlink-testnet.ts +21 -0
- package/src/chains/chain-definitions/etherlink.ts +20 -0
- package/src/engine/create-server-wallet.ts +1 -1
- package/src/engine/server-wallet.ts +1 -2
- package/src/exports/chains.ts +2 -0
- package/src/react/core/hooks/usePaymentMethods.ts +49 -13
- package/src/react/web/ui/Bridge/BuyWidget.tsx +12 -1
- package/src/react/web/ui/Bridge/TransactionPayment.tsx +22 -16
- package/src/version.ts +1 -1
@@ -0,0 +1,21 @@
|
|
1
|
+
import { defineChain } from "../utils.js";
|
2
|
+
|
3
|
+
/**
|
4
|
+
* @chain
|
5
|
+
*/
|
6
|
+
export const etherlinkTestnet = /* @__PURE__ */ defineChain({
|
7
|
+
blockExplorers: [
|
8
|
+
{
|
9
|
+
name: "Etherlink Testnet Explorer",
|
10
|
+
url: "https://testnet.explorer.etherlink.com/",
|
11
|
+
},
|
12
|
+
],
|
13
|
+
id: 128123,
|
14
|
+
name: "Etherlink Testnet",
|
15
|
+
nativeCurrency: {
|
16
|
+
decimals: 18,
|
17
|
+
name: "Etherlink",
|
18
|
+
symbol: "XTZ",
|
19
|
+
},
|
20
|
+
testnet: true,
|
21
|
+
});
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import { defineChain } from "../utils.js";
|
2
|
+
|
3
|
+
/**
|
4
|
+
* @chain
|
5
|
+
*/
|
6
|
+
export const etherlink = /* @__PURE__ */ defineChain({
|
7
|
+
blockExplorers: [
|
8
|
+
{
|
9
|
+
name: "Etherlink Explorer",
|
10
|
+
url: "https://explorer.etherlink.com/",
|
11
|
+
},
|
12
|
+
],
|
13
|
+
id: 42793,
|
14
|
+
name: "Etherlink",
|
15
|
+
nativeCurrency: {
|
16
|
+
decimals: 18,
|
17
|
+
name: "Etherlink",
|
18
|
+
symbol: "XTZ",
|
19
|
+
},
|
20
|
+
});
|
@@ -10,7 +10,7 @@ export type CreateServerWalletArgs = {
|
|
10
10
|
};
|
11
11
|
|
12
12
|
/**
|
13
|
-
* Create a server wallet.
|
13
|
+
* Create a new server wallet.
|
14
14
|
* @param params - The parameters for the server wallet.
|
15
15
|
* @param params.client - The thirdweb client to use.
|
16
16
|
* @param params.label - The label for the server wallet.
|
@@ -64,7 +64,7 @@ export type ServerWallet = Account & {
|
|
64
64
|
};
|
65
65
|
|
66
66
|
/**
|
67
|
-
*
|
67
|
+
* Use a server wallet for sending transactions and signing messages via engine (v3+).
|
68
68
|
* @param options - The server wallet options.
|
69
69
|
* @returns An account object that can be used to send transactions and sign messages.
|
70
70
|
* @engine
|
@@ -80,7 +80,6 @@ export type ServerWallet = Account & {
|
|
80
80
|
* const myServerWallet = Engine.serverWallet({
|
81
81
|
* client,
|
82
82
|
* address: "<your-server-wallet-address>",
|
83
|
-
* vaultAccessToken: "<your-vault-access-token>",
|
84
83
|
* });
|
85
84
|
* ```
|
86
85
|
*
|
package/src/exports/chains.ts
CHANGED
@@ -30,6 +30,8 @@ export { cronos } from "../chains/chain-definitions/cronos.js";
|
|
30
30
|
export { degen } from "../chains/chain-definitions/degen.js";
|
31
31
|
// mainnet = alias for ethereum
|
32
32
|
export { ethereum, mainnet } from "../chains/chain-definitions/ethereum.js";
|
33
|
+
export { etherlink } from "../chains/chain-definitions/etherlink.js";
|
34
|
+
export { etherlinkTestnet } from "../chains/chain-definitions/etherlink-testnet.js";
|
33
35
|
export { fantom } from "../chains/chain-definitions/fantom.js";
|
34
36
|
export { fantomTestnet } from "../chains/chain-definitions/fantom-testnet.js";
|
35
37
|
export { frameTestnet } from "../chains/chain-definitions/frame-testnet.js";
|
@@ -10,6 +10,10 @@ import type { ThirdwebClient } from "../../../client/client.js";
|
|
10
10
|
import { getOwnedTokens } from "../../../insight/get-tokens.js";
|
11
11
|
import { toTokens } from "../../../utils/units.js";
|
12
12
|
import type { Wallet } from "../../../wallets/interfaces/wallet.js";
|
13
|
+
import {
|
14
|
+
type GetWalletBalanceResult,
|
15
|
+
getWalletBalance,
|
16
|
+
} from "../../../wallets/utils/getWalletBalance.js";
|
13
17
|
import type { PaymentMethod } from "../machines/paymentMachine.js";
|
14
18
|
import { useActiveWallet } from "./wallets/useActiveWallet.js";
|
15
19
|
|
@@ -80,16 +84,42 @@ export function usePaymentMethods(options: {
|
|
80
84
|
const limit = 500;
|
81
85
|
|
82
86
|
while (true) {
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
87
|
+
let batch: GetWalletBalanceResult[];
|
88
|
+
try {
|
89
|
+
batch = await getOwnedTokens({
|
90
|
+
chains: insightEnabledChains.map((c) => getCachedChain(c.chainId)),
|
91
|
+
client,
|
92
|
+
ownerAddress: wallet.getAccount()?.address || "",
|
93
|
+
queryOptions: {
|
94
|
+
limit,
|
95
|
+
metadata: "false",
|
96
|
+
page,
|
97
|
+
},
|
98
|
+
});
|
99
|
+
} catch (error) {
|
100
|
+
// If the batch fails, fall back to getting native balance for each chain
|
101
|
+
console.warn(`Failed to get owned tokens for batch ${page}:`, error);
|
102
|
+
|
103
|
+
const chainsInBatch = insightEnabledChains.map((c) =>
|
104
|
+
getCachedChain(c.chainId),
|
105
|
+
);
|
106
|
+
const nativeBalances = await Promise.allSettled(
|
107
|
+
chainsInBatch.map(async (chain) => {
|
108
|
+
const balance = await getWalletBalance({
|
109
|
+
address: wallet.getAccount()?.address || "",
|
110
|
+
chain,
|
111
|
+
client,
|
112
|
+
});
|
113
|
+
return balance;
|
114
|
+
}),
|
115
|
+
);
|
116
|
+
|
117
|
+
// Transform successful native balances into the same format as getOwnedTokens results
|
118
|
+
batch = nativeBalances
|
119
|
+
.filter((result) => result.status === "fulfilled")
|
120
|
+
.map((result) => result.value)
|
121
|
+
.filter((balance) => balance.value > 0n);
|
122
|
+
}
|
93
123
|
|
94
124
|
if (batch.length === 0) {
|
95
125
|
break;
|
@@ -126,7 +156,9 @@ export function usePaymentMethods(options: {
|
|
126
156
|
|
127
157
|
// Add destination token if included
|
128
158
|
if (includeDestinationToken) {
|
129
|
-
const tokenKey = `${
|
159
|
+
const tokenKey = `${
|
160
|
+
destinationToken.chainId
|
161
|
+
}-${destinationToken.address.toLowerCase()}`;
|
130
162
|
allValidOriginTokens.set(tokenKey, destinationToken);
|
131
163
|
}
|
132
164
|
|
@@ -155,7 +187,9 @@ export function usePaymentMethods(options: {
|
|
155
187
|
) {
|
156
188
|
continue;
|
157
189
|
}
|
158
|
-
const tokenKey = `${
|
190
|
+
const tokenKey = `${
|
191
|
+
route.originToken.chainId
|
192
|
+
}-${route.originToken.address.toLowerCase()}`;
|
159
193
|
allValidOriginTokens.set(tokenKey, route.originToken);
|
160
194
|
}
|
161
195
|
} catch (error) {
|
@@ -169,7 +203,9 @@ export function usePaymentMethods(options: {
|
|
169
203
|
const validOwnedTokens: OwnedTokenWithQuote[] = [];
|
170
204
|
|
171
205
|
for (const ownedToken of allOwnedTokens) {
|
172
|
-
const tokenKey = `${
|
206
|
+
const tokenKey = `${
|
207
|
+
ownedToken.originToken.chainId
|
208
|
+
}-${ownedToken.originToken.address.toLowerCase()}`;
|
173
209
|
const validOriginToken = allValidOriginTokens.get(tokenKey);
|
174
210
|
|
175
211
|
if (validOriginToken) {
|
@@ -312,7 +312,18 @@ export function BuyWidget(props: BuyWidgetProps) {
|
|
312
312
|
props.client,
|
313
313
|
NATIVE_TOKEN_ADDRESS,
|
314
314
|
props.chain.id,
|
315
|
-
)
|
315
|
+
).catch((err) => {
|
316
|
+
err.message.includes("not supported")
|
317
|
+
? undefined
|
318
|
+
: Promise.reject(err);
|
319
|
+
});
|
320
|
+
if (!ETH) {
|
321
|
+
return {
|
322
|
+
chain: props.chain,
|
323
|
+
tokenAddress: props.tokenAddress || NATIVE_TOKEN_ADDRESS,
|
324
|
+
type: "unsupported_token",
|
325
|
+
};
|
326
|
+
}
|
316
327
|
return {
|
317
328
|
data: {
|
318
329
|
destinationToken: ETH,
|
@@ -212,22 +212,28 @@ export function TransactionPayment({
|
|
212
212
|
<Spacer y="md" />
|
213
213
|
|
214
214
|
{/* Contract Info */}
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
215
|
+
{contractName !== "UnknownContract" &&
|
216
|
+
contractName !== undefined &&
|
217
|
+
contractName !== "Unknown Contract" && (
|
218
|
+
<>
|
219
|
+
<Container
|
220
|
+
flex="row"
|
221
|
+
style={{
|
222
|
+
alignItems: "center",
|
223
|
+
justifyContent: "space-between",
|
224
|
+
}}
|
225
|
+
>
|
226
|
+
<Text color="secondaryText" size="sm">
|
227
|
+
Contract
|
228
|
+
</Text>
|
229
|
+
<Text color="primaryText" size="sm">
|
230
|
+
{contractName}
|
231
|
+
</Text>
|
232
|
+
</Container>
|
233
|
+
|
234
|
+
<Spacer y="xs" />
|
235
|
+
</>
|
236
|
+
)}
|
231
237
|
|
232
238
|
{/* Address */}
|
233
239
|
<Container
|
package/src/version.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export const version = "5.105.
|
1
|
+
export const version = "5.105.17-nightly-31d7173432d7437000787434da91f2b1608128fb-20250719000426";
|