Skip to content

Commit f88ec5a

Browse files
committed
feat(app/reputation): support Monad testnet for NFT minting
1 parent 665a8a6 commit f88ec5a

File tree

4 files changed

+28
-17
lines changed

4 files changed

+28
-17
lines changed

src/domain/reputation/views/my-reputation-list/MyReputationItem.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import { toast } from 'react-toastify';
2121
import { useAccount, useSwitchNetwork } from 'wagmi';
2222

2323
import { Button } from '@/components/Button';
24-
import { NFT_SUPPORTED_CHAIN } from '@/constants/chain';
2524
import { contracts } from '@/constants/contract';
2625
import { formatTime } from '@/utils/date';
2726

@@ -37,14 +36,14 @@ export default function MyReputationItem({ dataSource, onNotConnected, onMint })
3736
const [mintLoading, setMintLoading] = useState(null);
3837
const mediaUrl = useMediaUrl();
3938

40-
const { wrap } = useEnsureRightEnv({ chainId: NFT_SUPPORTED_CHAIN(), autoConnect: true, walletRequired: true });
39+
const { wrap } = useEnsureRightEnv({ chainId: dataSource.mint_chain_id, autoConnect: true, walletRequired: true });
4140

4241
const mint = wrap(async ({ id, mint_chain_id }) => {
4342
setMintLoading(id);
4443
await mintNft({
4544
id,
4645
chainId: mint_chain_id,
47-
contract: contracts[NFT_SUPPORTED_CHAIN()].nft,
46+
contract: contracts[mint_chain_id].nft,
4847
address,
4948
userId: user?.base.user_id,
5049
})

src/shared/constants/chain.js

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,34 @@ import {
2828
trustWallet,
2929
} from '@rainbow-me/rainbowkit/wallets';
3030
import { bsc } from '@wagmi/chains';
31+
import { defineChain } from 'viem';
3132
import { configureChains, createConfig } from 'wagmi';
3233
import { bscTestnet } from 'wagmi/chains';
3334
import { alchemyProvider } from 'wagmi/providers/alchemy';
3435
import { infuraProvider } from 'wagmi/providers/infura';
3536
import { publicProvider } from 'wagmi/providers/public';
3637

37-
const supportedChains = [bsc];
38+
const monadTestnet = defineChain({
39+
id: 10143,
40+
name: 'Monad Testnet',
41+
network: 'monad-testnet',
42+
nativeCurrency: {
43+
decimals: 18,
44+
name: 'MON',
45+
symbol: 'MON',
46+
},
47+
rpcUrls: {
48+
default: { http: ['https://testnet-rpc.monad.xyz'] },
49+
public: { http: ['https://testnet-rpc.monad.xyz'] },
50+
},
51+
blockExplorers: {
52+
etherscan: { name: 'MonadExplorer', url: 'https://testnet.monadexplorer.com' },
53+
default: { name: 'MonadExplorer', url: 'https://testnet.monadexplorer.com' },
54+
},
55+
testnet: true,
56+
});
57+
58+
const supportedChains = [bsc, monadTestnet];
3859

3960
if (process.env.NODE_ENV !== 'production') {
4061
supportedChains.push(bscTestnet);
@@ -95,12 +116,3 @@ export function BOUNTY_SUPPORTED_CHAIN() {
95116
return 56;
96117
}
97118
}
98-
99-
export function NFT_SUPPORTED_CHAIN() {
100-
if (process.env.NEXT_PUBLIC_DOMAIN_ENV === 'development' || process.env.NEXT_PUBLIC_DOMAIN_ENV === 'test') {
101-
return 97;
102-
} else {
103-
return 56;
104-
}
105-
}
106-

src/shared/constants/contract.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ export const contracts = {
2727
nft: '0xD3763ccfb312b14758848f47575b20Be6bE5AD04',
2828
bounty: '0x728206E44A0AD7E4226D3Ca6f2a3E79e344373E3',
2929
},
30-
30+
10143: {
31+
nft: '0xD27b2f759dD59B32401aBa3B94D5d27f44164832',
32+
},
3133
};
3234

3335
// nft: `0x${string}`

src/state/application/updater.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@ import { useCallback, useEffect } from 'react';
2020

2121
import { useMediaQuery } from '@/hooks/useMediaQuery';
2222

23-
import { useAppDispatch } from '#/state/hooks';
24-
25-
// import { getConfig } from '#/services/common'
23+
import { useAppDispatch } from '../hooks';
2624
import { updateConfig, updateOpenFilter, updateLessonMenu } from './reducer';
2725

2826
export default function Updater({ datas }) {

0 commit comments

Comments
 (0)