Remove the code handling NYM to uNYM conversion
This commit is contained in:
parent
053d7f5618
commit
1124805bb7
@ -1,6 +1,5 @@
|
|||||||
REACT_APP_WALLET_CONNECT_PROJECT_ID=
|
REACT_APP_WALLET_CONNECT_PROJECT_ID=
|
||||||
|
|
||||||
REACT_APP_DEFAULT_GAS_PRICE=0.025
|
|
||||||
# Reference: https://github.com/cosmos/cosmos-sdk/issues/16020
|
# Reference: https://github.com/cosmos/cosmos-sdk/issues/16020
|
||||||
REACT_APP_GAS_ADJUSTMENT=2
|
REACT_APP_GAS_ADJUSTMENT=2
|
||||||
REACT_APP_LACONICD_RPC_URL=https://laconicd-sapo.laconic.com
|
REACT_APP_LACONICD_RPC_URL=https://laconicd-sapo.laconic.com
|
||||||
|
@ -111,19 +111,12 @@ export const useWebViewHandler = () => {
|
|||||||
|
|
||||||
// Handle incoming transfer requests
|
// Handle incoming transfer requests
|
||||||
const navigateToTransfer = useCallback(async (to: string, amount: string, namespace: String, chainId: string, memo: string) => {
|
const navigateToTransfer = useCallback(async (to: string, amount: string, namespace: String, chainId: string, memo: string) => {
|
||||||
const chainSpecs = {
|
|
||||||
namespace,
|
|
||||||
chainId,
|
|
||||||
};
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const unymAmount = chainSpecs.chainId === 'nyx'
|
// TODO: Pass the account info for transferring tokens
|
||||||
? Math.round(parseFloat(amount) * 1_000_000).toString()
|
|
||||||
: amount;
|
|
||||||
|
|
||||||
// Get all accounts
|
// Get all accounts
|
||||||
const chainAccounts = await retrieveAccountsForNetwork(
|
const chainAccounts = await retrieveAccountsForNetwork(
|
||||||
`${chainSpecs.namespace}:${chainSpecs.chainId}`,
|
`${namespace}:${chainId}`,
|
||||||
'0' // Use the first account
|
'0' // Use the first account
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -137,7 +130,7 @@ export const useWebViewHandler = () => {
|
|||||||
}
|
}
|
||||||
const chainAccount = chainAccounts[0]; // Use the first account
|
const chainAccount = chainAccounts[0]; // Use the first account
|
||||||
|
|
||||||
const path = `/transfer/${chainSpecs.namespace}/${chainSpecs.chainId}/${chainAccount.address}/${to}/${unymAmount}`;
|
const path = `/transfer/${namespace}/${chainId}/${chainAccount.address}/${to}/${amount}`;
|
||||||
|
|
||||||
navigation.reset({
|
navigation.reset({
|
||||||
index: 0,
|
index: 0,
|
||||||
@ -146,13 +139,12 @@ export const useWebViewHandler = () => {
|
|||||||
name: 'ApproveTransfer',
|
name: 'ApproveTransfer',
|
||||||
path: path,
|
path: path,
|
||||||
params: {
|
params: {
|
||||||
namespace: chainSpecs.namespace,
|
namespace: namespace,
|
||||||
chainId: `${chainSpecs.namespace}:${chainSpecs.chainId}`,
|
chainId: `${namespace}:${chainId}`,
|
||||||
transaction: {
|
transaction: {
|
||||||
from: chainAccount.address,
|
from: chainAccount.address,
|
||||||
to: to,
|
to: to,
|
||||||
value: unymAmount,
|
value: amount
|
||||||
data: ''
|
|
||||||
},
|
},
|
||||||
accountInfo: chainAccount,
|
accountInfo: chainAccount,
|
||||||
memo: memo
|
memo: memo
|
||||||
@ -161,7 +153,6 @@ export const useWebViewHandler = () => {
|
|||||||
],
|
],
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Navigation error:', error);
|
|
||||||
if (window.Android?.onTransferError) {
|
if (window.Android?.onTransferError) {
|
||||||
window.Android.onTransferError(`Navigation error: ${error}`);
|
window.Android.onTransferError(`Navigation error: ${error}`);
|
||||||
}
|
}
|
||||||
|
@ -56,14 +56,13 @@ const ApproveTransfer = ({ route }: ApproveTransferProps) => {
|
|||||||
// Extract data from route params or path
|
// Extract data from route params or path
|
||||||
const requestSession = route.params.requestSessionData;
|
const requestSession = route.params.requestSessionData;
|
||||||
const requestName = requestSession?.peer.metadata.name;
|
const requestName = requestSession?.peer.metadata.name;
|
||||||
const requestIcon = requestSession?.peer.metadata.icons?.[0];
|
const requestIcon = requestSession?.peer.metadata.icons[0];
|
||||||
const requestURL = requestSession?.peer.metadata.url;
|
const requestURL = requestSession?.peer.metadata.url;
|
||||||
const transaction = route.params.transaction;
|
const transaction = route.params.transaction;
|
||||||
const requestEvent = route.params.requestEvent;
|
const requestEvent = route.params.requestEvent;
|
||||||
const chainId = requestEvent?.params.chainId || route.params.chainId;
|
const chainId = requestEvent?.params.chainId || route.params.chainId;
|
||||||
const requestMethod = requestEvent?.params.request.method;
|
const requestMethod = requestEvent?.params.request.method;
|
||||||
const customMemo = route.params.memo;
|
const finalMemo = route.params.memo || MEMO;
|
||||||
const finalMemo = customMemo || MEMO;
|
|
||||||
|
|
||||||
const [account, setAccount] = useState<Account>();
|
const [account, setAccount] = useState<Account>();
|
||||||
const [isLoading, setIsLoading] = useState(true);
|
const [isLoading, setIsLoading] = useState(true);
|
||||||
@ -206,6 +205,7 @@ const ApproveTransfer = ({ route }: ApproveTransferProps) => {
|
|||||||
[navigation, requestedNetwork],
|
[navigation, requestedNetwork],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//TODO: Handle ETH transactions
|
||||||
const handleIntent = async () => {
|
const handleIntent = async () => {
|
||||||
if (!account) {
|
if (!account) {
|
||||||
throw new Error('Account is not valid');
|
throw new Error('Account is not valid');
|
||||||
@ -215,7 +215,7 @@ const ApproveTransfer = ({ route }: ApproveTransferProps) => {
|
|||||||
from: account.address,
|
from: account.address,
|
||||||
to: transaction.to,
|
to: transaction.to,
|
||||||
amount: transaction.value,
|
amount: transaction.value,
|
||||||
denom: requestedNetwork?.nativeDenom,
|
denom: requestedNetwork!.nativeDenom,
|
||||||
memo: finalMemo,
|
memo: finalMemo,
|
||||||
gas: cosmosGasLimit,
|
gas: cosmosGasLimit,
|
||||||
fees: fees
|
fees: fees
|
||||||
@ -390,7 +390,6 @@ const ApproveTransfer = ({ route }: ApproveTransferProps) => {
|
|||||||
|
|
||||||
const { topic } = requestEvent;
|
const { topic } = requestEvent;
|
||||||
await web3wallet!.respondSessionRequest({ topic, response });
|
await web3wallet!.respondSessionRequest({ topic, response });
|
||||||
navigation.navigate('Home');
|
|
||||||
} else {
|
} else {
|
||||||
await handleIntent();
|
await handleIntent();
|
||||||
navigation.navigate('Home');
|
navigation.navigate('Home');
|
||||||
@ -407,6 +406,8 @@ const ApproveTransfer = ({ route }: ApproveTransferProps) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const rejectRequestHandler = async () => {
|
const rejectRequestHandler = async () => {
|
||||||
|
setIsTxLoading(true);
|
||||||
|
try {
|
||||||
if (requestEvent) {
|
if (requestEvent) {
|
||||||
const response = rejectWalletConnectRequest(requestEvent);
|
const response = rejectWalletConnectRequest(requestEvent);
|
||||||
const { topic } = requestEvent;
|
const { topic } = requestEvent;
|
||||||
@ -421,6 +422,15 @@ const ApproveTransfer = ({ route }: ApproveTransferProps) => {
|
|||||||
} else {
|
} else {
|
||||||
navigation.navigate('Home');
|
navigation.navigate('Home');
|
||||||
}
|
}
|
||||||
|
} catch (error) {
|
||||||
|
if (!(error instanceof Error)) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
|
||||||
|
setTxError(error.message);
|
||||||
|
setIsTxErrorDialogOpen(true);
|
||||||
|
}
|
||||||
|
setIsTxLoading(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -52,6 +52,8 @@ export const DEFAULT_NETWORKS: NetworksFormData[] = [
|
|||||||
gasPrice: '0.025',
|
gasPrice: '0.025',
|
||||||
isDefault: true,
|
isDefault: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
//TODO: Add network from android app
|
||||||
{
|
{
|
||||||
chainId: 'nyx',
|
chainId: 'nyx',
|
||||||
networkName: 'Nym',
|
networkName: 'Nym',
|
||||||
@ -61,6 +63,8 @@ export const DEFAULT_NETWORKS: NetworksFormData[] = [
|
|||||||
nativeDenom: 'unym',
|
nativeDenom: 'unym',
|
||||||
addressPrefix: 'n',
|
addressPrefix: 'n',
|
||||||
coinType: '118',
|
coinType: '118',
|
||||||
|
|
||||||
|
// Ref: https://nym.com/docs/operators/nodes/validator-setup#apptoml-configuration
|
||||||
gasPrice: '0.025',
|
gasPrice: '0.025',
|
||||||
isDefault: true,
|
isDefault: true,
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user