Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chalabi/cross chain x #194

Merged
merged 70 commits into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
2c7c09d
chore: remove hardcoded chainNames
chalabi2 Jan 9, 2025
a7aceac
feat: add osmosis balances
chalabi2 Jan 9, 2025
2d1826e
chore: add ibc mocks, token filters/queries, addresses etc
chalabi2 Jan 10, 2025
178dd55
successful ibc tx generation
chalabi2 Jan 10, 2025
27b7338
fix: timeout time/height in ibcTransfer
chalabi2 Jan 10, 2025
0020ea8
Merge branch 'main' into chalabi/cross-chain-x
chalabi2 Jan 10, 2025
758500e
feat: add switcher to ibc chain selectors
chalabi2 Jan 10, 2025
2a4826a
chore: add group ibc functionality
chalabi2 Jan 11, 2025
03619b3
fix: show ibc assets in history
chalabi2 Jan 11, 2025
0ec0be6
Merge branch 'main' into chalabi/cross-chain-x
chalabi2 Jan 11, 2025
dc163e0
chore: add back uppercase
chalabi2 Jan 11, 2025
aa9301f
chore: code rabbit suggestions
chalabi2 Jan 11, 2025
6f565da
chore: code rabbit suggestions
chalabi2 Jan 11, 2025
dbeeec5
fix: merge conflicts
chalabi2 Jan 14, 2025
5a0f4c1
chore: add osmosis related .env variables to readme
chalabi2 Jan 14, 2025
f7ce672
fix: re-add proper rendering logic to bank page
chalabi2 Jan 14, 2025
5cea9f3
Update README.md
chalabi2 Jan 14, 2025
fb9cfff
Update README.md
chalabi2 Jan 14, 2025
09bf705
Update config/env.ts
chalabi2 Jan 14, 2025
7b1a642
chore: add coderabbit changes
chalabi2 Jan 14, 2025
6d570b0
Update config/env.ts
chalabi2 Jan 14, 2025
bd0319f
Update config/env.ts
chalabi2 Jan 14, 2025
958a27f
Update components/bank/components/sendBox.tsx
chalabi2 Jan 14, 2025
de95589
Update pages/_app.tsx
chalabi2 Jan 14, 2025
1e474cf
Update pages/bank.tsx
chalabi2 Jan 14, 2025
036be3f
Update scripts/ibcTransferAll.ts
chalabi2 Jan 14, 2025
65dbb12
Update scripts/ibcTransferAll.ts
chalabi2 Jan 14, 2025
f0e7e8d
Update components/bank/forms/ibcSendForm.tsx
chalabi2 Jan 14, 2025
52672ce
Update components/bank/forms/ibcSendForm.tsx
chalabi2 Jan 14, 2025
d7bcb83
Update components/bank/forms/ibcSendForm.tsx
chalabi2 Jan 14, 2025
3e1c22f
Update components/bank/forms/ibcSendForm.tsx
chalabi2 Jan 14, 2025
38129b1
Update components/bank/forms/ibcSendForm.tsx
chalabi2 Jan 14, 2025
16da549
Update components/bank/forms/ibcSendForm.tsx
chalabi2 Jan 14, 2025
ed1b3ee
Update components/bank/forms/ibcSendForm.tsx
chalabi2 Jan 14, 2025
c748bc0
Update hooks/useLcdQueryClient.ts
chalabi2 Jan 14, 2025
3ff70b4
Update hooks/useLcdQueryClient.ts
chalabi2 Jan 14, 2025
e50afae
Update hooks/useTx.tsx
chalabi2 Jan 14, 2025
891c4b6
chore: add transfer script instructions
chalabi2 Jan 14, 2025
2cd2f92
chore: prettier
chalabi2 Jan 14, 2025
5fef3a4
fix: fix form tests
chalabi2 Jan 14, 2025
6562154
fix: add mocked osmosis asset list
chalabi2 Jan 14, 2025
915a268
fix: move chain selection test to ibc test file
chalabi2 Jan 14, 2025
d6d8ddb
fix: incrase wait time for slow ci machine
chalabi2 Jan 14, 2025
e367ae2
remove loading state from ibc form mock in sendbox
chalabi2 Jan 14, 2025
a47b3d2
fix: proper module mock path for ibcSendForm in sendbox test
chalabi2 Jan 14, 2025
c09f5a5
add skip go
chalabi2 Jan 31, 2025
8b41049
check chain tier when rendering cross chain transfers
chalabi2 Jan 31, 2025
02866fa
add skip routes and messages
chalabi2 Feb 2, 2025
a26855d
add skip routes and messages
chalabi2 Feb 2, 2025
48591bb
pass cosmos kit signers to skipClient context provider
chalabi2 Feb 2, 2025
09ece7b
bring to most recent
chalabi2 Feb 2, 2025
3e39891
update and add ibc denom scripts
chalabi2 Feb 3, 2025
625ce3a
make skip hook more type safe
chalabi2 Feb 4, 2025
d9af353
Merge branch 'main' into chalabi/cross-chain-x
chalabi2 Feb 4, 2025
5e98218
fix tests
chalabi2 Feb 4, 2025
fceee94
use registry | add ibc assets to formatDenom
chalabi2 Feb 5, 2025
4b61039
Merge branch 'main' into chalabi/cross-chain-x
chalabi2 Feb 5, 2025
8157758
fix conflicts
chalabi2 Feb 5, 2025
e81a6d9
add chain-registry chains to test render
chalabi2 Feb 5, 2025
ff6887c
fix tests in CI
chalabi2 Feb 5, 2025
00f9268
fix tests in CI
chalabi2 Feb 5, 2025
9690b24
fix tests in CI
chalabi2 Feb 5, 2025
135038d
wait for ibc send form to be rendered
chalabi2 Feb 5, 2025
1ed0bc4
fix: tests
fmorency Feb 6, 2025
ceb1953
chore: bump typescript
fmorency Feb 6, 2025
30cb4a8
fix: build error
fmorency Feb 6, 2025
ec9481d
fix: build
fmorency Feb 6, 2025
06d7ee5
Merge branch 'main' into chalabi/cross-chain-x
chalabi2 Feb 6, 2025
e61d629
fix denom info modal
chalabi2 Feb 6, 2025
3387cf8
remoce duplicate config files
chalabi2 Feb 6, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 42 additions & 5 deletions components/bank/components/historyBox.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import React, { useMemo, useState, useEffect } from 'react';
import { TruncatedAddressWithCopy } from '@/components/react/addressCopy';
import TxInfoModal from '../modals/txInfo';
import { shiftDigits, truncateString } from '@/utils';
import { denomToAsset, shiftDigits, truncateString } from '@/utils';
import { BurnIcon, DenomImage, formatDenom, MintIcon } from '@/components';
import { HistoryTxType, useTokenFactoryDenomsMetadata } from '@/hooks';
import { ReceiveIcon, SendIcon } from '@/components/icons';

import useIsMobile from '@/hooks/useIsMobile';
import env from '@/config/env';

interface Transaction {
tx_type: HistoryTxType;
Expand Down Expand Up @@ -216,7 +217,26 @@ export function HistoryBox({
</div>

{tx.data.amount.map((amt, index) => {
const metadata = metadatas?.metadatas.find(m => m.base === amt.denom);
const assetInfo = denomToAsset(env.chain, amt.denom);
let metadata = metadatas?.metadatas.find(m => m.base === amt.denom);

if (amt.denom.startsWith('ibc/')) {
metadata = {
description: assetInfo?.description ?? '',
denom_units:
assetInfo?.denom_units?.map(unit => ({
...unit,
aliases: unit.aliases || [],
})) ?? [],
base: assetInfo?.base ?? '',
display: assetInfo?.display ?? '',
name: assetInfo?.name ?? '',
symbol: assetInfo?.symbol ?? '',
uri: assetInfo?.logo_URIs?.svg ?? assetInfo?.logo_URIs?.png ?? '',
uri_hash: assetInfo?.logo_URIs?.svg ?? assetInfo?.logo_URIs?.png ?? '',
};
}
chalabi2 marked this conversation as resolved.
Show resolved Hide resolved

return <DenomImage key={index} denom={metadata} />;
})}

Expand All @@ -228,8 +248,16 @@ export function HistoryBox({
<p className="font-semibold text-[#161616] dark:text-white">
{tx.data.amount.map((amt, index) => {
const metadata = metadatas?.metadatas.find(m => m.base === amt.denom);
const display = metadata?.display ?? metadata?.symbol ?? '';
return metadata?.display.startsWith('factory')
let display = metadata?.display ?? metadata?.symbol ?? '';

if (amt.denom.startsWith('ibc/')) {
const assetInfo = denomToAsset(env.chain, amt.denom);
if (assetInfo?.traces?.[0]?.counterparty?.base_denom) {
display = assetInfo.traces[0].counterparty.base_denom.slice(1);
}
}

return metadata?.display?.startsWith('factory')
chalabi2 marked this conversation as resolved.
Show resolved Hide resolved
? metadata?.display?.split('/').pop()?.toUpperCase()
: display.length > 4
? display.slice(0, 4).toUpperCase() + '...'
Expand Down Expand Up @@ -269,7 +297,16 @@ export function HistoryBox({
const metadata = metadatas?.metadatas.find(m => m.base === amt.denom);
const exponent = Number(metadata?.denom_units[1]?.exponent) || 6;
const amount = Number(shiftDigits(amt.amount, -exponent));
return `${formatLargeNumber(amount)} ${formatDenom(amt.denom)}`;
let baseDenom = formatDenom(amt.denom);

if (amt.denom.startsWith('ibc/')) {
const assetInfo = denomToAsset(env.chain, amt.denom);
if (assetInfo?.traces?.[0]?.counterparty?.base_denom) {
baseDenom = assetInfo.traces[0].counterparty.base_denom.slice(1);
}
}

return `${formatLargeNumber(amount)} ${baseDenom.toUpperCase()}`;
chalabi2 marked this conversation as resolved.
Show resolved Hide resolved
})
.join(', ')}
</p>
Expand Down
54 changes: 40 additions & 14 deletions components/bank/components/sendBox.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useState } from 'react';
import { useMemo, useState } from 'react';
import SendForm from '../forms/sendForm';
import IbcSendForm from '../forms/ibcSendForm';

import env from '@/config/env';
import { CombinedBalanceInfo } from '@/utils/types';

export interface IbcChain {
Expand All @@ -21,6 +21,10 @@ export default function SendBox({
isGroup,
admin,
refetchProposals,
osmosisBalances,
isOsmosisBalancesLoading,
refetchOsmosisBalances,
resolveOsmosisRefetch,
}: {
address: string;
balances: CombinedBalanceInfo[];
Expand All @@ -31,17 +35,31 @@ export default function SendBox({
selectedDenom?: string;
isGroup?: boolean;
admin?: string;
osmosisBalances: CombinedBalanceInfo[];
isOsmosisBalancesLoading: boolean;
refetchOsmosisBalances: () => void;
resolveOsmosisRefetch: () => void;
}) {
const [activeTab, setActiveTab] = useState<'send' | 'cross-chain'>('send');
const [selectedChain, setSelectedChain] = useState('');
const ibcChains: IbcChain[] = [
{
id: 'osmosis',
name: 'Osmosis',
icon: 'https://osmosis.zone/assets/icons/osmo-logo-icon.svg',
prefix: 'osmo',
},
];
const [selectedFromChain, setSelectedFromChain] = useState('');
const [selectedToChain, setSelectedToChain] = useState('');
const ibcChains = useMemo<IbcChain[]>(
() => [
{
id: env.chain,
name: 'Manifest',
icon: '/logo.svg',
prefix: 'manifest',
},
{
id: env.osmosisTestnetChain,
name: 'Osmosis',
chalabi2 marked this conversation as resolved.
Show resolved Hide resolved
icon: '/osmosis.svg',
prefix: 'osmo',
},
],
[]
);

chalabi2 marked this conversation as resolved.
Show resolved Hide resolved
return (
<div className="rounded-2xl w-full ">
Expand Down Expand Up @@ -79,16 +97,24 @@ export default function SendBox({
<IbcSendForm
isIbcTransfer={true}
ibcChains={ibcChains}
selectedChain={selectedChain}
setSelectedChain={setSelectedChain}
selectedFromChain={selectedFromChain}
setSelectedFromChain={setSelectedFromChain}
selectedToChain={selectedToChain}
setSelectedToChain={setSelectedToChain}
address={address}
destinationChain={selectedChain}
destinationChain={selectedToChain}
balances={balances}
isBalancesLoading={isBalancesLoading}
refetchBalances={refetchBalances}
refetchHistory={refetchHistory}
selectedDenom={selectedDenom}
osmosisBalances={osmosisBalances}
isGroup={isGroup}
admin={admin}
refetchProposals={refetchProposals}
isOsmosisBalancesLoading={isOsmosisBalancesLoading}
refetchOsmosisBalances={refetchOsmosisBalances}
resolveOsmosisRefetch={resolveOsmosisRefetch}
/>
) : (
<SendForm
Expand Down
25 changes: 22 additions & 3 deletions components/bank/components/tokenList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ interface TokenListProps {
admin?: string;
refetchProposals?: () => void;
searchTerm?: string;
osmosisBalances?: CombinedBalanceInfo[] | undefined;
isOsmosisBalancesLoading?: boolean;
refetchOsmosisBalances?: () => void;
resolveOsmosisRefetch?: () => void;
}

export function TokenList(props: Readonly<TokenListProps>) {
Expand All @@ -30,6 +34,10 @@ export function TokenList(props: Readonly<TokenListProps>) {
admin,
refetchProposals,
searchTerm = '',
osmosisBalances,
isOsmosisBalancesLoading,
refetchOsmosisBalances,
resolveOsmosisRefetch,
} = props;
const [selectedDenom, setSelectedDenom] = useState<any>(null);
const [isSendModalOpen, setIsSendModalOpen] = useState(false);
Expand Down Expand Up @@ -107,9 +115,16 @@ export function TokenList(props: Readonly<TokenListProps>) {
<div className=" flex items-center justify-center">
<DenomImage denom={balance.metadata} />
</div>
<p className="font-semibold text-[#161616] dark:text-white">
{truncateString(balance.metadata?.display ?? '', 12).toUpperCase()}
</p>
<div>
<p className="font-semibold text-[#161616] dark:text-white">
{truncateString(balance.metadata?.display ?? '', 12).toUpperCase()}
</p>
<p className="text-sm text-[#00000099] dark:text-[#FFFFFF99]">
{balance.metadata?.denom_units[0]?.denom.startsWith('ibc')
? balance.metadata?.denom_units[0]?.aliases[0]
: balance.metadata?.denom_units[0]?.denom.split('/').pop()}
</p>
</div>
</div>
<div className="text-center hidden sm:block md:block lg:hidden xl:block">
<p className="font-semibold text-[#161616] dark:text-white">
Expand Down Expand Up @@ -233,6 +248,10 @@ export function TokenList(props: Readonly<TokenListProps>) {
isGroup={isGroup}
admin={admin}
refetchProposals={refetchProposals}
osmosisBalances={osmosisBalances ?? []}
isOsmosisBalancesLoading={isOsmosisBalancesLoading ?? false}
refetchOsmosisBalances={refetchOsmosisBalances ?? (() => {})}
resolveOsmosisRefetch={resolveOsmosisRefetch ?? (() => {})}
/>
</div>
);
Expand Down
Loading
Loading