Skip to content

Commit

Permalink
fix mns on send confirm
Browse files Browse the repository at this point in the history
  • Loading branch information
pivilartisant committed May 15, 2024
1 parent fb2be1c commit c4b2b27
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 20 deletions.
41 changes: 22 additions & 19 deletions web-frontend/src/custom/useMNS.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,32 @@ export function useMNS() {

const { client, account, chainId } = usePrepareScCall();

const accountAddress = account?.address() ?? '';

const currentNetwork =
chainId === MAINNET_CHAIN_ID ? networks.mainnet : networks.buildnet;

const reverseResolveCallData = {
targetAddress: contracts[currentNetwork].mnsContract,
targetFunction: 'dnsReverseResolve',
parameter: new Args().addString(accountAddress).serialize(),
} as ICallData;
const reverseResolveDns = useCallback(
async (address = '') => {
const targetAddress = address || account?.address() || '';
const reverseResolveCallData = {
targetAddress: contracts[currentNetwork].mnsContract,
targetFunction: 'dnsReverseResolve',
parameter: new Args().addString(targetAddress).serialize(),
} as ICallData;

const reverseResolveDns = useCallback(async () => {
if (!client) return;
try {
const result = await client
.smartContracts()
.readSmartContract(reverseResolveCallData);
setMns(bytesToStr(result.returnValue));
} catch (e) {
setMns('');
console.error(e);
}
}, [client, reverseResolveCallData]);
if (!client) return;

try {
const result = await client
.smartContracts()
.readSmartContract(reverseResolveCallData);
setMns(bytesToStr(result.returnValue));
} catch (e) {
setMns('');
console.error(e);
}
},
[client],

Check warning on line 39 in web-frontend/src/custom/useMNS.tsx

View workflow job for this annotation

GitHub Actions / lint-web-frontend

React Hook useCallback has missing dependencies: 'account' and 'currentNetwork'. Either include them or remove the dependency array
);

async function resolveDns(domain: string): Promise<string | undefined> {
if (!client) return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export function SendConfirmation(props: SendConfirmationProps) {
const { reverseResolveDns, mns } = useMNS();

useEffect(() => {
reverseResolveDns();
reverseResolveDns(recipientAddress);
}, [reverseResolveDns]);

Check warning on line 61 in web-frontend/src/pages/TransferCoins/SendCoins/SendConfirmation.tsx

View workflow job for this annotation

GitHub Actions / lint-web-frontend

React Hook useEffect has a missing dependency: 'recipientAddress'. Either include it or remove the dependency array

let selectedFees;
Expand Down

0 comments on commit c4b2b27

Please sign in to comment.