Skip to content

Commit 7c17a23

Browse files
authored
feat: add retry logic for crypto payment and top-up forms; enhance Wagmi provider configuration (#3256)
1 parent 981cbd6 commit 7c17a23

File tree

3 files changed

+47
-15
lines changed

3 files changed

+47
-15
lines changed

packages/apps/job-launcher/client/src/components/Jobs/Create/CryptoPayForm.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,8 @@ export const CryptoPayForm = ({
205205
hash,
206206
confirmations:
207207
Number(import.meta.env.VITE_APP_MIN_CONFIRMATIONS) ?? 1,
208+
retryCount: 10,
209+
retryDelay: ({ count }) => Math.min(1000 * 2 ** count, 30000),
208210
});
209211

210212
// create crypto payment record

packages/apps/job-launcher/client/src/components/TopUpAccount/CryptoTopUpForm.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ export const CryptoTopUpForm = () => {
8989
await publicClient?.waitForTransactionReceipt({
9090
hash: transactionHash,
9191
confirmations: Number(import.meta.env.VITE_APP_MIN_CONFIRMATIONS) ?? 1,
92+
retryCount: 10,
93+
retryDelay: ({ count }) => Math.min(1000 * 2 ** count, 30000),
9294
});
9395

9496
// create crypto payment record

packages/apps/job-launcher/client/src/providers/WagmiProvider.tsx

Lines changed: 43 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
import { FC, PropsWithChildren } from 'react';
2-
import { createConfig, http, WagmiProvider as WWagmiProvider } from 'wagmi';
2+
import {
3+
createConfig,
4+
WagmiProvider as WWagmiProvider,
5+
fallback,
6+
http,
7+
unstable_connector,
8+
} from 'wagmi';
39
import * as wagmiChains from 'wagmi/chains';
4-
import { coinbaseWallet, walletConnect } from 'wagmi/connectors';
10+
import { coinbaseWallet, walletConnect, metaMask } from 'wagmi/connectors';
511

612
import { LOCALHOST } from '../constants/chains';
713

@@ -31,21 +37,43 @@ export const wagmiConfig = createConfig({
3137
coinbaseWallet({
3238
appName: 'human-job-launcher',
3339
}),
40+
metaMask(),
3441
],
3542
transports: {
36-
[wagmiChains.mainnet.id]: http(),
37-
[wagmiChains.sepolia.id]: http(),
38-
[wagmiChains.bsc.id]: http(),
39-
[wagmiChains.bscTestnet.id]: http(),
40-
[wagmiChains.polygon.id]: http(),
41-
[wagmiChains.polygonAmoy.id]: http(),
42-
[wagmiChains.moonbeam.id]: http(),
43-
[wagmiChains.moonbaseAlpha.id]: http(),
44-
[wagmiChains.avalanche.id]: http(),
45-
[wagmiChains.avalancheFuji.id]: http(),
46-
[wagmiChains.xLayer.id]: http(),
47-
[wagmiChains.xLayerTestnet.id]: http(),
48-
[LOCALHOST.id]: http(LOCALHOST.rpcUrls.default.http[0]),
43+
[wagmiChains.mainnet.id]: fallback([unstable_connector(metaMask), http()]),
44+
[wagmiChains.sepolia.id]: fallback([unstable_connector(metaMask), http()]),
45+
[wagmiChains.bsc.id]: fallback([unstable_connector(metaMask), http()]),
46+
[wagmiChains.bscTestnet.id]: fallback([
47+
unstable_connector(metaMask),
48+
http(),
49+
]),
50+
[wagmiChains.polygon.id]: fallback([unstable_connector(metaMask), http()]),
51+
[wagmiChains.polygonAmoy.id]: fallback([
52+
unstable_connector(metaMask),
53+
http(),
54+
]),
55+
[wagmiChains.moonbeam.id]: fallback([unstable_connector(metaMask), http()]),
56+
[wagmiChains.moonbaseAlpha.id]: fallback([
57+
unstable_connector(metaMask),
58+
http(),
59+
]),
60+
[wagmiChains.avalanche.id]: fallback([
61+
unstable_connector(metaMask),
62+
http(),
63+
]),
64+
[wagmiChains.avalancheFuji.id]: fallback([
65+
unstable_connector(metaMask),
66+
http(),
67+
]),
68+
[wagmiChains.xLayer.id]: fallback([unstable_connector(metaMask), http()]),
69+
[wagmiChains.xLayerTestnet.id]: fallback([
70+
unstable_connector(metaMask),
71+
http(),
72+
]),
73+
[LOCALHOST.id]: fallback([
74+
unstable_connector(metaMask),
75+
http(LOCALHOST.rpcUrls.default.http[0]),
76+
]),
4977
},
5078
});
5179

0 commit comments

Comments
 (0)