thirdweb 5.94.0 → 5.94.2
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/react/web/ui/ConnectWallet/screens/Buy/Stepper.js +2 -2
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/Stepper.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/TransactionModeScreen.js +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/TransactionModeScreen.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatScreenContent.js +2 -2
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatScreenContent.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/ConfirmationScreen.js +31 -3
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/ConfirmationScreen.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/ErrorText.js +12 -0
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/ErrorText.js.map +1 -0
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/SwapScreenContent.js +1 -1
- 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/TokenSelectorScreen.js +2 -2
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/TokenSelectorScreen.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/TransferConfirmationScreen.js +31 -3
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/TransferConfirmationScreen.js.map +1 -1
- package/dist/cjs/react/web/utils/errors.js +5 -4
- package/dist/cjs/react/web/utils/errors.js.map +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/wallets/injected/index.js +15 -0
- package/dist/cjs/wallets/injected/index.js.map +1 -1
- package/dist/cjs/wallets/smart/lib/calls.js +26 -5
- package/dist/cjs/wallets/smart/lib/calls.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/Stepper.js +2 -2
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/Stepper.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/TransactionModeScreen.js +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/TransactionModeScreen.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatScreenContent.js +3 -3
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatScreenContent.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/ConfirmationScreen.js +32 -4
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/ConfirmationScreen.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/ErrorText.js +9 -0
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/ErrorText.js.map +1 -0
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/SwapScreenContent.js +2 -2
- 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/TokenSelectorScreen.js +2 -2
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/TokenSelectorScreen.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/TransferConfirmationScreen.js +32 -4
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/TransferConfirmationScreen.js.map +1 -1
- package/dist/esm/react/web/utils/errors.js +5 -3
- package/dist/esm/react/web/utils/errors.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/wallets/injected/index.js +15 -0
- package/dist/esm/wallets/injected/index.js.map +1 -1
- package/dist/esm/wallets/smart/lib/calls.js +26 -5
- package/dist/esm/wallets/smart/lib/calls.js.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/TransactionModeScreen.d.ts.map +1 -1
- 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/swap/ConfirmationScreen.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/ErrorText.d.ts +5 -0
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/ErrorText.d.ts.map +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.map +1 -1
- package/dist/types/react/web/utils/errors.d.ts +2 -2
- package/dist/types/react/web/utils/errors.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/dist/types/wallets/injected/index.d.ts.map +1 -1
- package/dist/types/wallets/smart/lib/calls.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/extensions/erc1155/customDrop1155.test.ts +1 -0
- package/src/react/web/ui/ConnectWallet/screens/Buy/Stepper.tsx +2 -2
- package/src/react/web/ui/ConnectWallet/screens/Buy/TransactionModeScreen.tsx +8 -3
- package/src/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatScreenContent.tsx +10 -8
- package/src/react/web/ui/ConnectWallet/screens/Buy/swap/ConfirmationScreen.tsx +41 -11
- package/src/react/web/ui/ConnectWallet/screens/Buy/swap/ErrorText.tsx +23 -0
- package/src/react/web/ui/ConnectWallet/screens/Buy/swap/SwapScreenContent.tsx +13 -8
- package/src/react/web/ui/ConnectWallet/screens/Buy/swap/TokenSelectorScreen.tsx +2 -2
- package/src/react/web/ui/ConnectWallet/screens/Buy/swap/TransferConfirmationScreen.tsx +43 -9
- package/src/react/web/utils/errors.ts +11 -4
- package/src/version.ts +1 -1
- package/src/wallets/injected/index.ts +16 -0
- package/src/wallets/smart/lib/calls.ts +29 -5
@@ -12,10 +12,7 @@ import type { Account } from "../../../../../../../wallets/interfaces/wallet.js"
|
|
12
12
|
import type { PayUIOptions } from "../../../../../../core/hooks/connection/ConnectButtonProps.js";
|
13
13
|
import { useWalletBalance } from "../../../../../../core/hooks/others/useWalletBalance.js";
|
14
14
|
import { useBuyWithCryptoQuote } from "../../../../../../core/hooks/pay/useBuyWithCryptoQuote.js";
|
15
|
-
import {
|
16
|
-
defaultMessage,
|
17
|
-
getErrorMessage,
|
18
|
-
} from "../../../../../utils/errors.js";
|
15
|
+
import { getErrorMessage } from "../../../../../utils/errors.js";
|
19
16
|
import type { PayEmbedConnectOptions } from "../../../../PayEmbed.js";
|
20
17
|
import {
|
21
18
|
Drawer,
|
@@ -301,9 +298,14 @@ export function SwapScreenContent(props: {
|
|
301
298
|
/>
|
302
299
|
</Text>
|
303
300
|
) : (
|
304
|
-
<
|
305
|
-
|
306
|
-
|
301
|
+
<div>
|
302
|
+
<Text color="danger" size="xs" center multiline>
|
303
|
+
{errorMsg.title}
|
304
|
+
</Text>
|
305
|
+
<Text size="xs" center multiline>
|
306
|
+
{errorMsg.message}
|
307
|
+
</Text>
|
308
|
+
</div>
|
307
309
|
)}
|
308
310
|
</div>
|
309
311
|
)}
|
@@ -311,7 +313,10 @@ export function SwapScreenContent(props: {
|
|
311
313
|
{!errorMsg && isNotEnoughBalance && (
|
312
314
|
<div>
|
313
315
|
<Text color="danger" size="xs" center multiline>
|
314
|
-
Insufficient
|
316
|
+
Insufficient Funds
|
317
|
+
</Text>
|
318
|
+
<Text size="xs" center multiline>
|
319
|
+
Select another token or pay with a debit card.
|
315
320
|
</Text>
|
316
321
|
</div>
|
317
322
|
)}
|
@@ -276,7 +276,7 @@ export function TokenSelectorScreen(props: {
|
|
276
276
|
>
|
277
277
|
<CardStackIcon width={iconSize.md} height={iconSize.md} />
|
278
278
|
<Text size="sm" color="primaryText">
|
279
|
-
Pay with
|
279
|
+
Pay with a debit card
|
280
280
|
</Text>
|
281
281
|
</Container>
|
282
282
|
</Button>
|
@@ -362,7 +362,7 @@ function WalletRowWithBalances(props: {
|
|
362
362
|
) : (
|
363
363
|
<Container style={{ padding: spacing.sm }}>
|
364
364
|
<Text size="sm" color="secondaryText">
|
365
|
-
Insufficient
|
365
|
+
Insufficient Funds
|
366
366
|
</Text>
|
367
367
|
</Container>
|
368
368
|
)}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { CheckCircledIcon } from "@radix-ui/react-icons";
|
2
2
|
import { useQuery } from "@tanstack/react-query";
|
3
|
-
import { useState } from "react";
|
3
|
+
import { useMemo, useState } from "react";
|
4
4
|
import type { Chain } from "../../../../../../../chains/types.js";
|
5
5
|
import { getCachedChain } from "../../../../../../../chains/utils.js";
|
6
6
|
import type { ThirdwebClient } from "../../../../../../../client/client.js";
|
@@ -34,6 +34,7 @@ import { type ERC20OrNativeToken, isNativeToken } from "../../nativeToken.js";
|
|
34
34
|
import { Step } from "../Stepper.js";
|
35
35
|
import type { PayerInfo } from "../types.js";
|
36
36
|
import { ConnectorLine } from "./ConfirmationScreen.js";
|
37
|
+
import { ErrorText } from "./ErrorText.js";
|
37
38
|
import { SwapSummary } from "./SwapSummary.js";
|
38
39
|
|
39
40
|
type TransferConfirmationScreenProps = {
|
@@ -109,6 +110,42 @@ export function TransferConfirmationScreen(
|
|
109
110
|
refetchInterval: 30 * 1000,
|
110
111
|
});
|
111
112
|
|
113
|
+
const uiErrorMessage = useMemo(() => {
|
114
|
+
if (step === "approve" && status.id === "error" && status.error) {
|
115
|
+
if (status.error.toLowerCase().includes("user rejected")) {
|
116
|
+
return {
|
117
|
+
title: "Failed to Approve",
|
118
|
+
message: "Your wallet rejected the approval request.",
|
119
|
+
};
|
120
|
+
}
|
121
|
+
return {
|
122
|
+
title: "Failed to Approve",
|
123
|
+
message:
|
124
|
+
"Your wallet failed to approve the transaction for an unknown reason. Please try again or contact support.",
|
125
|
+
};
|
126
|
+
}
|
127
|
+
|
128
|
+
if (
|
129
|
+
(step === "transfer" || step === "execute") &&
|
130
|
+
status.id === "error" &&
|
131
|
+
status.error
|
132
|
+
) {
|
133
|
+
if (status.error.toLowerCase().includes("user rejected")) {
|
134
|
+
return {
|
135
|
+
title: "Failed to Confirm",
|
136
|
+
message: "Your wallet rejected the confirmation request.",
|
137
|
+
};
|
138
|
+
}
|
139
|
+
return {
|
140
|
+
title: "Failed to Confirm",
|
141
|
+
message:
|
142
|
+
"Your wallet failed to confirm the transaction for an unknown reason. Please try again or contact support.",
|
143
|
+
};
|
144
|
+
}
|
145
|
+
|
146
|
+
return undefined;
|
147
|
+
}, [step, status]);
|
148
|
+
|
112
149
|
if (transferQuery.isLoading) {
|
113
150
|
return (
|
114
151
|
<Container p="lg">
|
@@ -190,15 +227,12 @@ export function TransferConfirmationScreen(
|
|
190
227
|
</>
|
191
228
|
)}
|
192
229
|
|
193
|
-
{
|
230
|
+
{uiErrorMessage && (
|
194
231
|
<>
|
195
|
-
<
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
: "Failed to Execute"}
|
200
|
-
</Text>
|
201
|
-
</Container>
|
232
|
+
<ErrorText
|
233
|
+
title={uiErrorMessage.title}
|
234
|
+
message={uiErrorMessage.message}
|
235
|
+
/>
|
202
236
|
<Spacer y="md" />
|
203
237
|
</>
|
204
238
|
)}
|
@@ -1,6 +1,7 @@
|
|
1
1
|
type ApiError = {
|
2
2
|
code: string;
|
3
|
-
|
3
|
+
title: string;
|
4
|
+
message: string;
|
4
5
|
data?: {
|
5
6
|
minimumAmountUSDCents?: string;
|
6
7
|
requestedAmountUSDCents?: string;
|
@@ -9,19 +10,25 @@ type ApiError = {
|
|
9
10
|
};
|
10
11
|
};
|
11
12
|
|
12
|
-
export const defaultMessage = "Unable to get price quote";
|
13
13
|
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
14
14
|
export function getErrorMessage(err: any): ApiError {
|
15
15
|
if (typeof err.error === "object" && err.error.code) {
|
16
16
|
if (err.error.code === "MINIMUM_PURCHASE_AMOUNT") {
|
17
17
|
return {
|
18
18
|
code: "MINIMUM_PURCHASE_AMOUNT",
|
19
|
-
|
19
|
+
title: "Amount Too Low",
|
20
|
+
message:
|
21
|
+
"The requested amount is less than the minimum purchase. Try another provider or amount.",
|
20
22
|
};
|
21
23
|
}
|
22
24
|
}
|
25
|
+
|
26
|
+
console.error(err);
|
27
|
+
|
23
28
|
return {
|
24
29
|
code: "UNABLE_TO_GET_PRICE_QUOTE",
|
25
|
-
|
30
|
+
title: "Failed to Find Quote",
|
31
|
+
message:
|
32
|
+
"We couldn't get a quote for this token pair. Select another token or pay with a debit card.",
|
26
33
|
};
|
27
34
|
}
|
package/src/version.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export const version = "5.94.
|
1
|
+
export const version = "5.94.2";
|
@@ -63,6 +63,9 @@ export async function connectEip1193Wallet({
|
|
63
63
|
});
|
64
64
|
} catch (e) {
|
65
65
|
console.error(e);
|
66
|
+
if (extractErrorMessage(e)?.toLowerCase()?.includes("rejected")) {
|
67
|
+
throw e;
|
68
|
+
}
|
66
69
|
await new Promise((resolve) => setTimeout(resolve, 500));
|
67
70
|
}
|
68
71
|
attempts++;
|
@@ -375,3 +378,16 @@ async function switchChain(provider: EIP1193Provider, chain: Chain) {
|
|
375
378
|
});
|
376
379
|
}
|
377
380
|
}
|
381
|
+
|
382
|
+
function extractErrorMessage(e: unknown) {
|
383
|
+
if (e instanceof Error) {
|
384
|
+
return e.message;
|
385
|
+
}
|
386
|
+
if (typeof e === "string") {
|
387
|
+
return e;
|
388
|
+
}
|
389
|
+
if (typeof e === "object" && e !== null) {
|
390
|
+
return JSON.stringify(e);
|
391
|
+
}
|
392
|
+
return String(e);
|
393
|
+
}
|
@@ -97,11 +97,35 @@ export async function predictAddress(args: {
|
|
97
97
|
accountSalt && isHex(accountSalt)
|
98
98
|
? accountSalt
|
99
99
|
: stringToHex(accountSalt ?? "");
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
100
|
+
let result: string | undefined;
|
101
|
+
let retries = 0;
|
102
|
+
const maxRetries = 3;
|
103
|
+
|
104
|
+
while (retries <= maxRetries) {
|
105
|
+
try {
|
106
|
+
result = await readContract({
|
107
|
+
contract: factoryContract,
|
108
|
+
method: "function getAddress(address, bytes) returns (address)",
|
109
|
+
params: [adminAddress, saltHex],
|
110
|
+
});
|
111
|
+
break;
|
112
|
+
} catch (error) {
|
113
|
+
if (retries === maxRetries) {
|
114
|
+
throw error;
|
115
|
+
}
|
116
|
+
|
117
|
+
// Exponential backoff: 2^(retries + 1) * 100ms (200ms, 400ms, 800ms)
|
118
|
+
const delay = 2 ** (retries + 1) * 100;
|
119
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
120
|
+
retries++;
|
121
|
+
}
|
122
|
+
}
|
123
|
+
if (!result) {
|
124
|
+
throw new Error(
|
125
|
+
`No smart account address found for admin address ${adminAddress} and salt ${accountSalt}`,
|
126
|
+
);
|
127
|
+
}
|
128
|
+
return result;
|
105
129
|
},
|
106
130
|
{
|
107
131
|
cacheKey: `${args.factoryContract.chain.id}-${args.factoryContract.address}-${args.adminAddress}-${args.accountSalt}`,
|