Skip to content

Commit

Permalink
Make it possible to adjust token metadata (solana-labs#1059)
Browse files Browse the repository at this point in the history
  • Loading branch information
nramadas authored Sep 23, 2022
1 parent fc98220 commit 3a4f37f
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 1 deletion.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
"@streamflow/stream": "3.0.10",
"@switchboard-xyz/switchboard-v2": "^0.0.110",
"@tippyjs/react": "^4.2.6",
"@types/ramda": "^0.28.15",
"@urql/exchange-auth": "^1.0.0",
"@urql/exchange-graphcache": "^5.0.1",
"@urql/exchange-multipart-fetch": "^1.0.1",
Expand Down Expand Up @@ -122,6 +123,7 @@
"psyfi-euros-test": "^0.0.1-rc.33",
"pyth-staking-api": "^1.2.17",
"qr-code-styling": "^1.6.0-rc.1",
"ramda": "^0.28.0",
"rc-slider": "^9.7.5",
"react": "^18.1.0",
"react-dom": "^18.0.0",
Expand Down
8 changes: 8 additions & 0 deletions public/realms/token-overrides.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"METAewgxyPbgwsseH8T16a39CQ5VyVxZi9zXiDPY18m": {
"symbol": "MPLX",
"extensions": {
"coingeckoId": "metaplex"
}
}
}
14 changes: 13 additions & 1 deletion utils/services/token.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import axios from 'axios'
import { TokenListProvider, TokenInfo } from '@solana/spl-token-registry'
import { mergeDeepRight } from 'ramda'

import { notify } from '@utils/notifications'
import { WSOL_MINT } from '@components/instructions/tools'
import { MANGO_MINT } from 'Strategies/protocols/mango/tools'
import overrides from 'public/realms/token-overrides.json'

const coingeckoPriceEndpoint = 'https://api.coingecko.com/api/v3/simple/price'

class TokenService {
Expand All @@ -17,7 +21,15 @@ class TokenService {
const tokens = await new TokenListProvider().resolve()
const tokenList = tokens.filterByClusterSlug('mainnet-beta').getList()
if (tokenList && tokenList.length) {
this._tokenList = tokenList
this._tokenList = tokenList.map((token) => {
const override = overrides[token.address]

if (override) {
return mergeDeepRight(token, override)
}

return token
})
}
} catch (e) {
console.log(e)
Expand Down
12 changes: 12 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6923,6 +6923,13 @@
resolved "https://registry.npmjs.org/@types/qs/-/qs-6.9.7.tgz"
integrity sha512-FGa1F62FT09qcrueBA6qYTrJPVDzah9a+493+o2PCXsesWHIn27G98TsSMs3WPNbZIEj4+VJf6saSFpvD+3Zsw==

"@types/ramda@^0.28.15":
version "0.28.15"
resolved "https://registry.yarnpkg.com/@types/ramda/-/ramda-0.28.15.tgz#36bb4c8de430e3bbcd29590537569aef64409716"
integrity sha512-FCaLNVZry65jW8x/FDnKgjgkCNQxgc5AYMQwdNn6yW5M+62R+0nt2Y36U43dTNora9hcquemfrY5gxhE5pcilQ==
dependencies:
ts-toolbelt "^6.15.1"

"@types/range-parser@*":
version "1.2.4"
resolved "https://registry.npmjs.org/@types/range-parser/-/range-parser-1.2.4.tgz"
Expand Down Expand Up @@ -19109,6 +19116,11 @@ ts-proto@^1.79.0:
ts-poet "^4.5.0"
ts-proto-descriptors "1.6.0"

ts-toolbelt@^6.15.1:
version "6.15.5"
resolved "https://registry.yarnpkg.com/ts-toolbelt/-/ts-toolbelt-6.15.5.tgz#cb3b43ed725cb63644782c64fbcad7d8f28c0a83"
integrity sha512-FZIXf1ksVyLcfr7M317jbB67XFJhOO1YqdTcuGaq9q5jLUoTikukZ+98TPjKiP2jC5CgmYdWWYs0s2nLSU0/1A==

tsconfig-paths@^3.14.1:
version "3.14.1"
resolved "https://registry.yarnpkg.com/tsconfig-paths/-/tsconfig-paths-3.14.1.tgz#ba0734599e8ea36c862798e920bcf163277b137a"
Expand Down

0 comments on commit 3a4f37f

Please sign in to comment.