Skip to content

Commit

Permalink
add osmosis support
Browse files Browse the repository at this point in the history
  • Loading branch information
simke9445 committed Mar 12, 2024
1 parent eb9b32d commit c3e280c
Show file tree
Hide file tree
Showing 11 changed files with 130 additions and 12 deletions.
3 changes: 3 additions & 0 deletions apps/shared/hooks/useChainSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { ReactComponent as InjectiveIcon } from 'components/assets/Injective.svg
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 {
ChainMetadata as SdkChainMetadata,
TERRA_CHAIN,
Expand Down Expand Up @@ -42,6 +43,8 @@ const getChainMetadata = (sdkMetadata: SdkChainMetadata) => {
return { ...sdkMetadata, icon: <NibiruIcon className={styles.chain_icon} /> };
case 'migaloo':
return { ...sdkMetadata, icon: <MigalooIcon className={styles.chain_icon} /> };
case 'osmosis':
return { ...sdkMetadata, icon: <OsmoIcon 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.10",
"@terra-money/warp-sdk": "^0.2.13",
"assert": "^2.0.0",
"big.js": "^6.2.1",
"buffer": "^6.0.3",
Expand Down
3 changes: 2 additions & 1 deletion apps/shared/queries/tokens/useNativeTokensQuery.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useQuery, UseQueryResult } from 'react-query';
import { useChainSelector } from '../../hooks';
import { INJ, LUNA, NativeTokensResponse, NEUTRON, NIBIRU, WHALE } from '../../types';
import { INJ, LUNA, NativeTokensResponse, NEUTRON, NIBIRU, WHALE, OSMO } from '../../types';

export const useNativeTokensQuery = (
queryName: string = 'QUERY:NATIVE_TOKENS'
Expand All @@ -16,6 +16,7 @@ export const useNativeTokensQuery = (
...(selectedChain.name === 'neutron' && { [NEUTRON.key]: NEUTRON }),
...(selectedChain.name === 'nibiru' && { [NIBIRU.key]: NIBIRU }),
...(selectedChain.name === 'migaloo' && { [WHALE.key]: WHALE }),
...(selectedChain.name === 'osmosis' && { [OSMO.key]: OSMO }),
};
},
{
Expand Down
11 changes: 11 additions & 0 deletions apps/shared/types/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,17 @@ export const INJ: NativeToken = {
coinGeckoId: 'injective-protocol',
};

export const OSMO: NativeToken = {
key: 'uosmo',
type: 'native',
denom: 'uosmo',
name: 'Osmosis',
symbol: 'OSMO',
decimals: 6,
icon: 'https://station-assets.terra.dev/img/chains/Osmosis.svg',
coinGeckoId: 'osmosis',
};

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.10",
"@terra-money/warp-sdk": "^0.2.13",
"assert": "^2.0.0",
"big.js": "^6.2.1",
"brace": "^0.11.1",
Expand Down
83 changes: 83 additions & 0 deletions apps/warp-protocol/src/components/assets/Osmo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion apps/warp-protocol/src/hooks/useNativeToken.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useChainSelector } from '@terra-money/apps/hooks';
import { INJ, LUNA, NativeToken, NEUTRON, NIBIRU, WHALE } from '@terra-money/apps/types';
import { INJ, LUNA, NativeToken, NEUTRON, NIBIRU, OSMO, WHALE } from '@terra-money/apps/types';
import { useMemo } from 'react';

export const useNativeToken = (): NativeToken => {
Expand All @@ -17,6 +17,8 @@ export const useNativeToken = (): NativeToken => {
return NIBIRU;
case 'migaloo':
return WHALE;
case 'osmosis':
return OSMO;
}
}, [selectedChain.name]);
};
3 changes: 3 additions & 0 deletions apps/warp-protocol/src/utils/finder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const injectiveFinderTxUrl = (network: string, txHash: string) =>
? `https://explorer.injective.network/transaction/${txHash}`
: `https://testnet.explorer.injective.network/transaction/${txHash}`;
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}`;

export const useFinderTxUrl = () => {
const { connectedWallet, chain, chainId } = useLocalWallet();
Expand All @@ -24,6 +25,8 @@ export const useFinderTxUrl = () => {
return neutronFinderTxUrl(chainId, txHash);
case 'injective':
return injectiveFinderTxUrl(connectedWallet.network!, txHash);
case 'osmosis':
return osmoFinderTxUrl(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.10",
"@terra-money/warp-sdk": "^0.2.13",
"@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 @@ -79,6 +79,21 @@ export class Environment {
}
}

if (chainName === 'osmosis') {
if (process.env.NETWORK === 'mainnet') {
return {
height: 14266867,
timestamp: 1710262192,
};
} else {
// testnet (this is mainnet, switch with testnet data when testnet is added)
return {
height: 14266867,
timestamp: 1710262192,
};
}
}

// 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.10
"@terra-money/warp-sdk": ^0.2.13
"@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.10":
version: 0.2.10
resolution: "@terra-money/warp-sdk@npm:0.2.10"
"@terra-money/warp-sdk@npm:^0.2.13":
version: 0.2.13
resolution: "@terra-money/warp-sdk@npm:0.2.13"
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: 1e41c08c950b38554f4695bb87d2d27ea853f1f0d9d1f542fd3b3399556a6c4bdbf2517d4c7125985820877b5fa369e9078a8e613fcf885ee2901775b523dad4
checksum: c37e3ef3e334bd2dfaf30aa3577f3cc83fb755c23961fa7b2ee69e64cbb7c1c65d74df3d1d82ca1a19ac64f69d8cb29c7ba22cf6b3eb053f762e0b488cf9a861
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.10
"@terra-money/warp-sdk": ^0.2.13
"@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.10
"@terra-money/warp-sdk": ^0.2.13
"@types/d3-array": ^3.0.3
"@types/node": ^16.11.56
axios: ^1.1.2
Expand Down

0 comments on commit c3e280c

Please sign in to comment.