Skip to content

Commit

Permalink
Merge pull request #68 from TalismanSociety/fix/mythos-balance
Browse files Browse the repository at this point in the history
fix: add mythos coingecko id
  • Loading branch information
chrisling-dev authored Aug 23, 2024
2 parents 4cb0659 + 636aad4 commit 52fb2f4
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 65 deletions.
1 change: 0 additions & 1 deletion apps/multisig/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@
"react-app-alias": "^2.2.2",
"react-scripts": "5.0.1",
"relay-compiler": "^15.0.0",
"storybook-preset-craco": "artisanofcode/storybook-preset-craco",
"tailwindcss": "^3.3.5",
"ts-node": "^10.9.2",
"typescript": "^4.9.5"
Expand Down
28 changes: 27 additions & 1 deletion apps/multisig/src/domains/balances/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { BaseToken, supportedChains } from '@domains/chains'
import { aggregatedMultisigsState, selectedMultisigState } from '@domains/multisig'
import { Balance, Balances } from '@talismn/balances'
import { useBalances, useSetBalancesAddresses } from '@talismn/balances-react'
import { useBalances, useChaindataProvider, useSetBalancesAddresses, useTokenRates } from '@talismn/balances-react'
import { useUser } from '@domains/auth'
import { useEffect, useMemo } from 'react'
import { atom, useRecoilValue, useSetRecoilState } from 'recoil'
import { Address } from '../../util/addresses'
import { ALL_TOKENS_BY_ID } from '@domains/chains/all-tokens'

export const balancesState = atom<Balances | undefined>({
key: 'Balances',
Expand Down Expand Up @@ -78,7 +79,32 @@ export const BalancesWatcher = () => {
const selectedMultisig = useRecoilValue(selectedMultisigState)
const setBalances = useSetRecoilState(balancesState)
const { user } = useUser()
const provider = useChaindataProvider()
const multisigAddresses = useMemo(() => multisigs.map(({ proxyAddress }) => proxyAddress), [multisigs])
const rates = useTokenRates()

// TODO: this is only temp solution to fix mythos token not being added balances library
// we should improve this by checking for all networks and tokens that the user has
// and dynamically add to custom tokens list
useEffect(() => {
if (Object.values(rates).length === 0) return

const mythosToken = ALL_TOKENS_BY_ID['mythos-substrate-native']
if (mythosToken && !rates[mythosToken.id]) {
provider.addCustomToken({
type: 'substrate-native',
id: 'mythos-substrate-native',
chain: { id: 'mythos' },
decimals: mythosToken.decimals,
existentialDeposit: '1n',
isCustom: true,
isTestnet: false,
logo: mythosToken.logo || '',
symbol: mythosToken.symbol,
coingeckoId: mythosToken.coingeckoId,
})
}
}, [provider, rates])

// clean up for loading state
useEffect(() => {
Expand Down
1 change: 1 addition & 0 deletions apps/multisig/src/domains/chains/all-tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6769,6 +6769,7 @@ export const ALL_TOKENS = [
chain: {
id: 'mythos',
},
coingeckoId: 'mythos',
},
]

Expand Down
65 changes: 2 additions & 63 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5165,7 +5165,7 @@ __metadata:
languageName: node
linkType: hard

"@pmmmwh/react-refresh-webpack-plugin@npm:^0.5.1, @pmmmwh/react-refresh-webpack-plugin@npm:^0.5.3":
"@pmmmwh/react-refresh-webpack-plugin@npm:^0.5.3":
version: 0.5.11
resolution: "@pmmmwh/react-refresh-webpack-plugin@npm:0.5.11"
dependencies:
Expand Down Expand Up @@ -9459,24 +9459,6 @@ __metadata:
languageName: node
linkType: hard

"@storybook/preset-create-react-app@npm:>=3.1.5":
version: 7.6.15
resolution: "@storybook/preset-create-react-app@npm:7.6.15"
dependencies:
"@pmmmwh/react-refresh-webpack-plugin": ^0.5.1
"@storybook/react-docgen-typescript-plugin": 1.0.6--canary.9.0c3f3b7.0
"@storybook/types": 7.6.15
"@types/babel__core": ^7.1.7
"@types/semver": ^7.3.4
pnp-webpack-plugin: ^1.7.0
semver: ^7.3.5
peerDependencies:
"@babel/core": "*"
react-scripts: ">=5.0.0"
checksum: 03a13dcb426ffa774d1a7b64862d6f7d87dbb4bb57681b748c8e42599c98633b77aecba15c95b0c38e10aeceabce72f95db3ff1d8401c9e480b8b95bffc67f25
languageName: node
linkType: hard

"@storybook/preview-api@npm:7.6.15":
version: 7.6.15
resolution: "@storybook/preview-api@npm:7.6.15"
Expand Down Expand Up @@ -9551,24 +9533,6 @@ __metadata:
languageName: node
linkType: hard

"@storybook/react-docgen-typescript-plugin@npm:1.0.6--canary.9.0c3f3b7.0":
version: 1.0.6--canary.9.0c3f3b7.0
resolution: "@storybook/react-docgen-typescript-plugin@npm:1.0.6--canary.9.0c3f3b7.0"
dependencies:
debug: ^4.1.1
endent: ^2.0.1
find-cache-dir: ^3.3.1
flat-cache: ^3.0.4
micromatch: ^4.0.2
react-docgen-typescript: ^2.2.2
tslib: ^2.0.0
peerDependencies:
typescript: ">= 4.x"
webpack: ">= 4"
checksum: 38c59c1dd7f9cdf5533e5ffe1991034f563f8d33c59e3cd33fa86719c72f5fe922276fde50315dd24f23f225d1ad5f3a261ecf4c70e82522805d09782272faff
languageName: node
linkType: hard

"@storybook/react-dom-shim@npm:7.6.15":
version: 7.6.15
resolution: "@storybook/react-dom-shim@npm:7.6.15"
Expand Down Expand Up @@ -10673,7 +10637,6 @@ __metadata:
relay-runtime: ^15.0.0
rmrk-tools: ^1.0.64
safety-match: ^0.4.4
storybook-preset-craco: artisanofcode/storybook-preset-craco
stream-browserify: ^3.0.0
swr: ^1.3.0
tailwind-merge: ^2.0.0
Expand Down Expand Up @@ -11069,7 +11032,7 @@ __metadata:
languageName: node
linkType: hard

"@types/babel__core@npm:^7.0.0, @types/babel__core@npm:^7.1.14, @types/babel__core@npm:^7.1.7, @types/babel__core@npm:^7.18.0":
"@types/babel__core@npm:^7.0.0, @types/babel__core@npm:^7.1.14, @types/babel__core@npm:^7.18.0":
version: 7.20.5
resolution: "@types/babel__core@npm:7.20.5"
dependencies:
Expand Down Expand Up @@ -26708,15 +26671,6 @@ __metadata:
languageName: node
linkType: hard

"pnp-webpack-plugin@npm:^1.7.0":
version: 1.7.0
resolution: "pnp-webpack-plugin@npm:1.7.0"
dependencies:
ts-pnp: ^1.1.6
checksum: a41716d13607be5a3e06ba58b17e9e619cf07da3a0a7b10bd41cd89362873041054fd2b7966ad30a1b26b826cfb8fecc0469a95902d5b1b8ba8f591e2fe6b96d
languageName: node
linkType: hard

"polished@npm:^4.2.2":
version: 4.3.1
resolution: "polished@npm:4.3.1"
Expand Down Expand Up @@ -31065,21 +31019,6 @@ __metadata:
languageName: node
linkType: hard

storybook-preset-craco@artisanofcode/storybook-preset-craco:
version: 0.0.6
resolution: "storybook-preset-craco@https://github.com/artisanofcode/storybook-preset-craco.git#commit=7a14059de5d1f74187ad01c01832abc2a4f51ec2"
dependencies:
"@storybook/preset-create-react-app": ">=3.1.5"
peerDependencies:
"@babel/core": "*"
"@craco/craco": ">=5.0.0"
"@storybook/node-logger": "*"
"@storybook/react": ">=5.2"
react-scripts: ">=3.0.0"
checksum: f95e34ee963ea6a9c961e59b987534a2eed1cb072ab85f5f1501fc8ced7eca62d4c12627bef88d46e3d90ec9d9edc2159bd42e9ca8ed98db290c3a1047a4380a
languageName: node
linkType: hard

"storybook@npm:^7.0.12":
version: 7.6.15
resolution: "storybook@npm:7.6.15"
Expand Down

0 comments on commit 52fb2f4

Please sign in to comment.