Skip to content

Commit

Permalink
Merge pull request #1249 from mars-protocol/develop
Browse files Browse the repository at this point in the history
On-Chain Contract fetching
  • Loading branch information
linkielink authored Dec 3, 2024
2 parents d2366c3 + 97ef828 commit 7c9bcc5
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 99 deletions.
6 changes: 6 additions & 0 deletions src/chains/neutron/neutron-1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,13 @@ const Neutron1: ChainConfig = {
sell: 'ibc/B559A80D62249C8AA07A380E2A2BEA6E5CA9A6F079C912C3A9E9B494105E4F81',
},
contracts: {
redBank: 'neutron1n97wnm7q6d2hrcna3rqlnyqw2we6k0l8uqvmyqq6gsml92epdu7quugyph',
incentives: 'neutron1aszpdh35zsaz0yj80mz7f5dtl9zq5jfl8hgm094y0j0vsychfekqxhzd39',
oracle: 'neutron1dwp6m7pdrz6rnhdyrx5ha0acsduydqcpzkylvfgspsz60pj2agxqaqrr7g',
params: 'neutron1x4rgd7ry23v2n49y7xdzje0743c5tgrnqrqsvwyya2h6m48tz4jqqex06x',
creditManager: 'neutron1qdzn3l4kn7gsjna2tfpg3g3mwd6kunx4p50lfya59k02846xas6qslgs3r',
accountNft: 'neutron184kvu96rqtetmunkkmhu5hru8yaqg7qfhd8ldu5avjnamdqu69squrh3f5',
perps: 'neutron14v9g7regs90qvful7djcajsvrfep5pg9qau7qm6wya6c2lzcpnms692dlt',
pyth: 'neutron1m2emc93m9gpwgsrsf2vylv9xvgqh654630v7dfrhrkmr5slly53spg85wv',
},
endpoints: {
Expand Down
6 changes: 6 additions & 0 deletions src/chains/neutron/pion-1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@ const Pion1: ChainConfig = {
sell: 'factory/neutron1ke0vqqzyymlp5esr8gjwuzh94ysnpvj8er5hm7/UUSDC',
},
contracts: {
redBank: 'neutron19ucpt6vyha2k6tgnex880sladcqsguwynst4f8krh9vuxhktwkvq3yc3nl',
incentives: 'neutron1xqfgy03gulfyv6dnz9ezsjkgcvsvlaajskw35cluux9g05cmcu4sfdkuvc',
oracle: 'neutron12vejgch3jd74j99kdrpjf57f6zjlu425yyfscdjnmnn4vvyrazvqgvcp24',
params: 'neutron14a0qr0ahrg3f3yml06m9f0xmvw30ldf3scgashcjw5mrtyrc4aaq0v4tm9',
creditManager: 'neutron1zkxezh5e6jvg0h3kj50hz5d0yrgagkp0c3gcdr6stulw7fye9xlqygj2gz',
accountNft: 'neutron1pgk4ttz3ned9xvqlg79f4jumjet0443uqh2rga9ahalzgxqngtrqrszdna',
perps: 'neutron1dcv8sy6mhgjaum5tj8lghxgxx2jgf3gmcw6kg73rj70sx5sjpguslzv0xu',
pyth: 'neutron15ldst8t80982akgr8w8ekcytejzkmfpgdkeq4xgtge48qs7435jqp87u3t',
},
endpoints: {
Expand Down
6 changes: 6 additions & 0 deletions src/chains/osmosis/osmosis-1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,14 @@ const Osmosis1: ChainConfig = {
},
bech32Config: Bech32Address.defaultBech32Config('osmo'),
contracts: {
redBank: 'osmo1c3ljch9dfw5kf52nfwpxd2zmj2ese7agnx0p9tenkrryasrle5sqf3ftpg',
accountNft: 'osmo1450hrg6dv2l58c0rvdwx8ec2a0r6dd50hn4frk370tpvqjhy8khqw7sw09',
oracle: 'osmo1mhznfr60vjdp2gejhyv2gax9nvyyzhd3z0qcwseyetkfustjauzqycsy2g',
creditManager: 'osmo1f2m24wktq0sw3c0lexlg7fv4kngwyttvzws3a3r3al9ld2s2pvds87jqvf',
incentives: 'osmo1nkahswfr8shg8rlxqwup0vgahp0dk4x8w6tkv3rra8rratnut36sk22vrm',
params: 'osmo1nlmdxt9ctql2jr47qd4fpgzg84cjswxyw6q99u4y4u4q6c2f5ksq7ysent',
pyth: 'osmo13ge29x4e2s63a8ytz2px8gurtyznmue4a69n5275692v3qn3ks8q7cwck7',
perps: '',
},
defaultCurrency: {
coinDenom: 'OSMO',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@ export default function WalletAssetsModalContent(props: Props) {
const filteredAssets: Asset[] = useMemo(() => {
return assetsInWallet.filter(
(asset) =>
asset.name.toLowerCase().includes(searchString.toLowerCase()) ||
asset.denom.toLowerCase().includes(searchString.toLowerCase()) ||
asset.symbol.toLowerCase().includes(searchString.toLowerCase()),
(asset.name.toLowerCase().includes(searchString.toLowerCase()) ||
asset.denom.toLowerCase().includes(searchString.toLowerCase()) ||
asset.symbol.toLowerCase().includes(searchString.toLowerCase())) &&
!asset.isDeprecated,
)
}, [assetsInWallet, searchString])

Expand Down
34 changes: 5 additions & 29 deletions src/hooks/chain/useChainConfig.ts
Original file line number Diff line number Diff line change
@@ -1,47 +1,23 @@
import chains from 'chains'
import { LocalStorageKeys } from 'constants/localStorageKeys'
import { getCurrentChainId } from 'utils/getCurrentChainId'
import useCreditManagerConfig from 'hooks/chain/useCreditManagerConfig'
import { setNodeError } from 'utils/error'

export default function useChainConfig() {
const chainId = getCurrentChainId()
const baseConfig = chains[chainId]
const { data: creditManagerConfig, error } = useCreditManagerConfig()

const rpcEndpoint =
localStorage.getItem(`${chainId}/${LocalStorageKeys.RPC_ENDPOINT}`) ?? baseConfig.endpoints.rpc
localStorage.getItem(`${chainId}/${LocalStorageKeys.RPC_ENDPOINT}`) ??
chains[chainId].endpoints.rpc
const restEndpoint =
localStorage.getItem(`${chainId}/${LocalStorageKeys.REST_ENDPOINT}`) ??
baseConfig.endpoints.rest

if (error || !creditManagerConfig) {
return {
...baseConfig,
endpoints: {
...baseConfig.endpoints,
rpc: rpcEndpoint,
rest: restEndpoint,
},
contracts: baseConfig.contracts,
}
}
chains[chainId].endpoints.rest

return {
...baseConfig,
...chains[chainId],
endpoints: {
...baseConfig.endpoints,
...chains[chainId].endpoints,
rpc: rpcEndpoint,
rest: restEndpoint,
},
contracts: {
...baseConfig.contracts,
accountNft: creditManagerConfig.account_nft,
oracle: creditManagerConfig.oracle,
params: creditManagerConfig.params,
redBank: creditManagerConfig.red_bank,
incentives: creditManagerConfig.incentives,
perps: creditManagerConfig.perps,
},
}
}
61 changes: 0 additions & 61 deletions src/hooks/chain/useCreditManagerConfig.ts

This file was deleted.

12 changes: 6 additions & 6 deletions src/types/app.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,12 +236,12 @@ interface ChainConfig {
defaultTradingPair: TradingPair
bech32Config: import('@keplr-wallet/types').Bech32Config
contracts: {
redBank?: string
incentives?: string
oracle?: string
params?: string
accountNft?: string
perps?: string
redBank: string
incentives: string
oracle: string
params: string
accountNft: string
perps: string
creditManager: string
pyth: string
}
Expand Down

0 comments on commit 7c9bcc5

Please sign in to comment.