Skip to content

Commit

Permalink
Merge pull request #111 from terra-money/feature/archway
Browse files Browse the repository at this point in the history
Feature/archway
  • Loading branch information
simke9445 authored Mar 28, 2024
2 parents 685efe4 + fb90efd commit ff0f8da
Show file tree
Hide file tree
Showing 11 changed files with 100 additions and 15 deletions.
3 changes: 3 additions & 0 deletions apps/shared/hooks/useChainSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { ReactComponent as NeutronIcon } from 'components/assets/Neutron.svg';
import { ReactComponent as NibiruIcon } from 'components/assets/Nibiru.svg';
import { ReactComponent as MigalooIcon } from 'components/assets/Migaloo.svg';
import { ReactComponent as OsmoIcon } from 'components/assets/Osmo.svg';
import { ReactComponent as ArchwayIcon } from 'components/assets/Archway.svg';
import {
ChainMetadata as SdkChainMetadata,
TERRA_CHAIN,
Expand Down Expand Up @@ -45,6 +46,8 @@ const getChainMetadata = (sdkMetadata: SdkChainMetadata) => {
return { ...sdkMetadata, icon: <MigalooIcon className={styles.chain_icon} /> };
case 'osmosis':
return { ...sdkMetadata, icon: <OsmoIcon className={styles.chain_icon} /> };
case 'archway':
return { ...sdkMetadata, icon: <ArchwayIcon className={styles.chain_icon} /> };
}
};

Expand Down
2 changes: 1 addition & 1 deletion apps/shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"@mui/material": "^5.10.2",
"@terra-money/feather.js": "1.0.11",
"@terra-money/wallet-kit": "1.0.11",
"@terra-money/warp-sdk": "^0.2.21",
"@terra-money/warp-sdk": "^0.2.25",
"assert": "^2.0.0",
"big.js": "^6.2.1",
"buffer": "^6.0.3",
Expand Down
19 changes: 17 additions & 2 deletions apps/shared/queries/tokens/useNativeTokensQuery.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,37 @@
import { useQuery, UseQueryResult } from 'react-query';
import { useChainSelector } from '../../hooks';
import { INJ, LUNA, NativeTokensResponse, NEUTRON, NIBIRU, WHALE, OSMO } from '../../types';
import { INJ, LUNA, NativeTokensResponse, NEUTRON, NIBIRU, WHALE, OSMO, ARCHWAY, ARCHWAY_TESTNET } from '../../types';

export const useNativeTokensQuery = (
queryName: string = 'QUERY:NATIVE_TOKENS'
): UseQueryResult<NativeTokensResponse> => {
const { selectedChain } = useChainSelector();
const { selectedChain, selectedChainId } = useChainSelector();

return useQuery(
[queryName],
() => {
let archwayTokens = {};

if (selectedChain.name === 'archway') {
if (selectedChainId === 'constantine-3') {
archwayTokens = {
[ARCHWAY_TESTNET.key]: ARCHWAY_TESTNET,
};
} else {
archwayTokens = {
[ARCHWAY.key]: ARCHWAY,
};
}
}

return {
...(selectedChain.name === 'terra' && { [LUNA.key]: LUNA }),
...(selectedChain.name === 'injective' && { [INJ.key]: INJ }),
...(selectedChain.name === 'neutron' && { [NEUTRON.key]: NEUTRON }),
...(selectedChain.name === 'nibiru' && { [NIBIRU.key]: NIBIRU }),
...(selectedChain.name === 'migaloo' && { [WHALE.key]: WHALE }),
...(selectedChain.name === 'osmosis' && { [OSMO.key]: OSMO }),
...archwayTokens,
};
},
{
Expand Down
22 changes: 22 additions & 0 deletions apps/shared/types/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,28 @@ export const OSMO: NativeToken = {
coinGeckoId: 'osmosis',
};

export const ARCHWAY: NativeToken = {
key: 'aarch',
type: 'native',
denom: 'aarch',
name: 'Archway',
symbol: 'ARCH',
decimals: 18,
icon: 'https://station-assets.terra.dev/img/chains/Osmosis.svg',
coinGeckoId: 'archway',
};

export const ARCHWAY_TESTNET: NativeToken = {
key: 'aconst',
type: 'native',
denom: 'aconst',
name: 'Constantine',
symbol: 'CONST',
decimals: 18,
icon: 'https://station-assets.terra.dev/img/chains/Osmosis.svg',
coinGeckoId: 'archway',
};

export interface NativeTokensResponse {
[tokenAddr: string]: NativeToken;
}
Expand Down
2 changes: 1 addition & 1 deletion apps/warp-protocol/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"@terra-money/feather.js": "1.0.11",
"@terra-money/terra-station-mobile": "1.0.8",
"@terra-money/wallet-kit": "1.0.11",
"@terra-money/warp-sdk": "^0.2.21",
"@terra-money/warp-sdk": "^0.2.25",
"assert": "^2.0.0",
"big.js": "^6.2.1",
"brace": "^0.11.1",
Expand Down
4 changes: 4 additions & 0 deletions apps/warp-protocol/src/components/assets/Archway.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 19 additions & 3 deletions apps/warp-protocol/src/hooks/useNativeToken.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
import { useChainSelector } from '@terra-money/apps/hooks';
import { INJ, LUNA, NativeToken, NEUTRON, NIBIRU, OSMO, WHALE } from '@terra-money/apps/types';
import {
ARCHWAY,
ARCHWAY_TESTNET,
INJ,
LUNA,
NativeToken,
NEUTRON,
NIBIRU,
OSMO,
WHALE,
} from '@terra-money/apps/types';
import { useMemo } from 'react';

export const useNativeToken = (): NativeToken => {
const { selectedChain } = useChainSelector();
const { selectedChain, selectedChainId } = useChainSelector();

return useMemo(() => {
if (selectedChain.name === 'archway' && selectedChainId === 'constantine-3') {
return ARCHWAY_TESTNET;
}

switch (selectedChain.name) {
case 'terra':
return LUNA;
Expand All @@ -19,6 +33,8 @@ export const useNativeToken = (): NativeToken => {
return WHALE;
case 'osmosis':
return OSMO;
case 'archway':
return ARCHWAY;
}
}, [selectedChain.name]);
}, [selectedChain.name, selectedChainId]);
};
10 changes: 10 additions & 0 deletions apps/warp-protocol/src/utils/finder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ const injectiveFinderTxUrl = (network: string, txHash: string) =>
const neutronFinderTxUrl = (chainId: string, txHash: string) => `https://neutron.celat.one/${chainId}/txs/${txHash}`;
const osmoFinderTxUrl = (chainId: string, txHash: string) => `https://celatone.osmosis.zone/${chainId}/txs/${txHash}`;

const archwayFinderTxUrl = (chainId: string, txHash: string) => {
if (chainId === 'archway-1') {
return `https://www.mintscan.io/archway/tx/${txHash}`;
}

return `https://www.mintscan.io/archway-testnet/tx/${txHash}`;
};

export const useFinderTxUrl = () => {
const { connectedWallet, chain, chainId } = useLocalWallet();

Expand All @@ -27,6 +35,8 @@ export const useFinderTxUrl = () => {
return injectiveFinderTxUrl(connectedWallet.network!, txHash);
case 'osmosis':
return osmoFinderTxUrl(connectedWallet.network!, txHash);
case 'archway':
return archwayFinderTxUrl(connectedWallet.network!, txHash);
// TODO: add nibiru and whale when supported
}
},
Expand Down
2 changes: 1 addition & 1 deletion indexers/warp-protocol/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"@aws-sdk/client-dynamodb": "^3.159.0",
"@aws-sdk/util-dynamodb": "^3.159.0",
"@terra-money/feather.js": "1.0.11",
"@terra-money/warp-sdk": "^0.2.21",
"@terra-money/warp-sdk": "^0.2.25",
"@types/node": "^16.11.56",
"axios": "^1.1.2",
"big.js": "^6.2.1",
Expand Down
15 changes: 15 additions & 0 deletions indexers/warp-protocol/src/utils/Environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,21 @@ export class Environment {
}
}

if (chainName === 'archway') {
// this is testnet, switch with mainnet data when deployed
if (process.env.NETWORK === 'mainnet') {
return {
height: 3905130,
timestamp: 1711632224,
};
} else {
return {
height: 5159503,
timestamp: 1711559554,
};
}
}

// if (chainName === 'migaloo') {
// if (process.env.NETWORK === 'testnet') {
// // testnet
Expand Down
14 changes: 7 additions & 7 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4346,7 +4346,7 @@ __metadata:
"@mui/material": ^5.10.2
"@terra-money/feather.js": 1.0.11
"@terra-money/wallet-kit": 1.0.11
"@terra-money/warp-sdk": ^0.2.21
"@terra-money/warp-sdk": ^0.2.25
"@testing-library/jest-dom": ^5.16.5
"@testing-library/react": ^13.3.0
"@testing-library/user-event": ^13.5.0
Expand Down Expand Up @@ -4521,9 +4521,9 @@ __metadata:
languageName: node
linkType: hard

"@terra-money/warp-sdk@npm:^0.2.21":
version: 0.2.21
resolution: "@terra-money/warp-sdk@npm:0.2.21"
"@terra-money/warp-sdk@npm:^0.2.25":
version: 0.2.25
resolution: "@terra-money/warp-sdk@npm:0.2.25"
dependencies:
"@terra-money/feather.js": 1.0.11
"@types/node": ^16.11.56
Expand All @@ -4536,7 +4536,7 @@ __metadata:
lodash: ^4.17.21
pino: ^8.4.2
typescript: ^4.8.2
checksum: dc35ff5bcd3d6741b5eb611a24da9024461355af19734902a4fcb1c669cd664c10cf77b5e8d6d048193c07f8156872c607f40811eb936916269aae9327f68965
checksum: cf4fed73e82142ed19a324bfd6ecbe1e50df7879e076983efb8256f8b9b4d3db16847c14e3fa7b5aec45b8d3ed268309553747837a29db75954bea31f31f55a0
languageName: node
linkType: hard

Expand Down Expand Up @@ -5628,7 +5628,7 @@ __metadata:
"@terra-money/feather.js": 1.0.11
"@terra-money/terra-station-mobile": 1.0.8
"@terra-money/wallet-kit": 1.0.11
"@terra-money/warp-sdk": ^0.2.21
"@terra-money/warp-sdk": ^0.2.25
"@testing-library/jest-dom": ^5.16.5
"@testing-library/react": ^13.3.0
"@testing-library/user-event": ^13.5.0
Expand Down Expand Up @@ -5708,7 +5708,7 @@ __metadata:
"@aws-sdk/client-dynamodb": ^3.159.0
"@aws-sdk/util-dynamodb": ^3.159.0
"@terra-money/feather.js": 1.0.11
"@terra-money/warp-sdk": ^0.2.21
"@terra-money/warp-sdk": ^0.2.25
"@types/d3-array": ^3.0.3
"@types/node": ^16.11.56
axios: ^1.1.2
Expand Down

0 comments on commit ff0f8da

Please sign in to comment.