Skip to content

Commit

Permalink
Self button fix (#87)
Browse files Browse the repository at this point in the history
* toString amount

* Ensure self button uses correct cosmos chain (#86)

---------

Co-authored-by: nambrot <[email protected]>
  • Loading branch information
jmrossy and nambrot authored Nov 21, 2023
1 parent 17137ab commit 84dd0b4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
6 changes: 5 additions & 1 deletion src/features/transfer/TransferTokenForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,11 @@ function SelfButton({ disabled }: { disabled?: boolean }) {
if (disabled) return;
if (address) setFieldValue('recipientAddress', address);
else
toast.warn(`No wallet connected for chain ${getChainDisplayName(values.destinationCaip2Id)}`);
toast.warn(
`No account found for for chain ${getChainDisplayName(
values.destinationCaip2Id,
)}, is your wallet connected?`,
);
};
return (
<SolidButton
Expand Down
4 changes: 2 additions & 2 deletions src/features/transfer/useTokenTransfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,10 +268,10 @@ async function executeEvmTransfer({
logger.debug('Quoted gas payment', gasPayment);
// If sending native tokens (e.g. Eth), the gasPayment must be added to the tx value and sent together
const txValue = isRouteFromNative(tokenRoute)
? BigNumber.from(gasPayment).add(weiAmountOrId)
? BigNumber.from(gasPayment).add(weiAmountOrId.toString())
: gasPayment;
const transferTxRequest = (await hypTokenAdapter.populateTransferRemoteTx({
weiAmountOrId,
weiAmountOrId: weiAmountOrId.toString(),
recipient: recipientAddress,
destination: destinationDomainId,
txValue: txValue.toString(),
Expand Down
12 changes: 6 additions & 6 deletions src/features/wallet/hooks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,12 @@ export function getAccountAddressForChain(
account?: AccountInfo,
): Address | undefined {
if (!chainCaip2Id || !account?.addresses.length) return undefined;
// Return the address for the chain if it exists, otherwise return the first address
// We fallback to first because only cosmos has the notion of per-chain addresses
return (
account.addresses.find((a) => a.chainCaip2Id === chainCaip2Id)?.address ||
account.addresses[0].address
);
if (account.protocol === ProtocolType.Cosmos) {
return account.addresses.find((a) => a.chainCaip2Id === chainCaip2Id)?.address;
} else {
// Use first because only cosmos has the notion of per-chain addresses
return account.addresses[0].address;
}
}

export function useConnectFns(): Record<ProtocolType, () => void> {
Expand Down

0 comments on commit 84dd0b4

Please sign in to comment.