Add nym chain in the network

This commit is contained in:
pranavjadhav007 2025-06-04 14:12:41 +05:30
parent 43e61b7603
commit 08af9ba20d
5 changed files with 39 additions and 5 deletions

2
src/global.d.ts vendored
View File

@ -29,7 +29,7 @@ declare global {
receiveSignRequestFromAndroid?: (message: string) => void;
// Handles incoming transfer requests from Android
receiveTransferRequestFromAndroid?: (to: string, amount: string, namespace: String, chainId: string) => void;
receiveTransferRequestFromAndroid?: (to: string, amount: string, namespace: String, chainId: string, memo: string) => void;
}
}

View File

@ -75,7 +75,7 @@ export const useWebViewHandler = () => {
}, [selectedNetwork, accounts, currentIndex, navigation]);
// Handle incoming transfer requests
const navigateToTransfer = useCallback(async (to: string, amount: string, namespace: String, chainId: string) => {
const navigateToTransfer = useCallback(async (to: string, amount: string, namespace: String, chainId: string, memo: string) => {
const chainSpecs = {
namespace,
chainId,
@ -117,6 +117,7 @@ export const useWebViewHandler = () => {
data: ''
},
accountInfo: chainAccount,
memo: memo
},
},
],

View File

@ -61,6 +61,8 @@ const ApproveTransfer = ({ route }: ApproveTransferProps) => {
const requestEvent = route.params.requestEvent;
const chainId = requestEvent?.params.chainId || route.params.chainId;
const requestMethod = requestEvent?.params.request.method;
const customMemo = route.params.memo;
const finalMemo = customMemo || MEMO;
const [account, setAccount] = useState<Account>();
const [isLoading, setIsLoading] = useState(true);
@ -208,6 +210,16 @@ const ApproveTransfer = ({ route }: ApproveTransferProps) => {
throw new Error('Account is not valid');
}
console.log('Sending transaction request:', {
from: account.address,
to: transaction.to,
amount: transaction.value,
denom: requestedNetwork?.nativeDenom,
memo: finalMemo,
gas: cosmosGasLimit,
fees: fees
});
if (!requestedNetwork) {
throw new Error('Network not found');
}
@ -228,9 +240,11 @@ const ApproveTransfer = ({ route }: ApproveTransferProps) => {
],
gas: cosmosGasLimit,
},
MEMO,
finalMemo,
);
console.log('Transaction result:', result);
// Convert BigInt values to strings before sending to Android
const serializedResult = JSON.stringify(result, (key, value) =>
typeof value === 'bigint' ? value.toString() : value
@ -520,7 +534,7 @@ const ApproveTransfer = ({ route }: ApproveTransferProps) => {
const gasEstimation = await cosmosStargateClient.simulate(
transaction.from!,
[sendMsg],
MEMO,
finalMemo,
);
setCosmosGasLimit(
@ -538,7 +552,7 @@ const ApproveTransfer = ({ route }: ApproveTransferProps) => {
}
};
getCosmosGas();
}, [cosmosStargateClient, isSufficientFunds, sendMsg, transaction]);
}, [cosmosStargateClient, isSufficientFunds, sendMsg, transaction,finalMemo]);
useEffect(() => {
if (balance && !isSufficientFunds) {
@ -595,6 +609,12 @@ const ApproveTransfer = ({ route }: ApproveTransferProps) => {
transaction.value?.toString(),
).toString()}
/>
{namespace === COSMOS && (
<DataBox
label="Memo"
data={finalMemo}
/>
)}
{namespace === EIP155 ? (
<>

View File

@ -25,6 +25,7 @@ export type StackParamsList = {
transaction: PopulatedTransaction;
requestEvent?: Web3WalletTypes.SessionRequest;
requestSessionData?: SessionTypes.Struct;
memo?: string;
};
InvalidPath: undefined;
WalletConnect: undefined;

View File

@ -52,6 +52,18 @@ export const DEFAULT_NETWORKS: NetworksFormData[] = [
gasPrice: '0.025',
isDefault: true,
},
{
chainId: 'nyx',
networkName: 'Nym',
namespace: COSMOS,
rpcUrl: 'https://rpc.nymtech.net',
blockExplorerUrl: 'https://explorer.nymtech.net',
nativeDenom: 'unym',
addressPrefix: 'n',
coinType: '118',
gasPrice: '0.025',
isDefault: true,
},
];
export const CHAINID_DEBOUNCE_DELAY = 250;