Skip to content

Commit

Permalink
Merge pull request #233 from alephium/symbol-variant
Browse files Browse the repository at this point in the history
Support symbol variants
  • Loading branch information
polarker authored Jul 13, 2024
2 parents ee786ae + ff8a0f5 commit fe2ebe3
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 12 deletions.
File renamed without changes
13 changes: 13 additions & 0 deletions logos/ANSo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 24 additions & 8 deletions test/token-list/token-list.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,24 @@ import testnetJson from '../../tokens/testnet.json'
import { checkDuplicates } from '../utils'
import devnetJson from './devnet.json'

const mainnetTokenList = mainnetJson as TokenList
const testnetTokenList = testnetJson as TokenList
const devnetTokenList = devnetJson as TokenList
interface TokenListJson extends TokenList {
networkId: number
tokens: TokenInfoJson[]
}

interface TokenInfoJson extends TokenInfo {
nameOnChain?: string
symbolOnChain?: string
}

const mainnetTokenList = mainnetJson as TokenListJson
const testnetTokenList = testnetJson as TokenListJson
const devnetTokenList = devnetJson as TokenListJson

const tokenLists = [mainnetTokenList, testnetTokenList, devnetTokenList]

const mainnetURL = 'https://wallet-v20.mainnet.alephium.org'
const testnetURL = 'https://wallet-v20.testnet.alephium.org'
const mainnetURL = 'https://node.mainnet.alephium.org'
const testnetURL = 'https://node.testnet.alephium.org'

describe('TokenList', function () {
it('should contains no duplicate', () => {
Expand Down Expand Up @@ -114,9 +124,15 @@ describe('TokenList', function () {
await nodeProvider.fetchFungibleTokenMetaData(token.id).then((metadata) => checkMetadata(metadata, token))
}

function checkMetadata(metadata: FungibleTokenMetaData, token: TokenInfo) {
expect(hexToString(metadata.name)).toEqual(token.name)
expect(hexToString(metadata.symbol)).toEqual(token.symbol)
const tokensWithSymbolVariant = ['ALF', 'ANS']

function checkMetadata(metadata: FungibleTokenMetaData, token: TokenInfoJson) {
expect(hexToString(metadata.name)).toEqual(token.nameOnChain ?? token.name)
expect(hexToString(metadata.symbol)).toEqual(token.symbolOnChain ?? token.symbol)
expect(metadata.decimals).toEqual(token.decimals)

if (token.symbolOnChain !== undefined) {
expect(tokensWithSymbolVariant.includes(token.symbolOnChain)).toBe(true)
}
}
})
30 changes: 26 additions & 4 deletions tokens/mainnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@
"description": "Alephium is a scalable, decentralized, and secure blockchain platform that enables the creation of fast and secure applications.",
"logoURI": "https://raw.githubusercontent.com/alephium/token-list/master/logos/ALPH.png"
},
{
"id": "c0c0af7a481e3e50c50e418bf8ff6923dc4d878ac3744474e8c708a8adccfb00",
"name": "OGAlf",
"nameOnChain": "Alf",
"symbol": "OGALF",
"symbolOnChain": "ALF",
"decimals": 0,
"description": "OG Alf, real first token deployed on the mainnet",
"logoURI": "https://raw.githubusercontent.com/alephium/token-list/master/logos/OGALF.png"
},
{
"id": "66da610efb5129c062e88e5fd65fe810f31efd1597021b2edf887a4360fa0800",
"name": "Alf",
Expand Down Expand Up @@ -611,11 +621,13 @@
},
{
"id": "edcd9b5c59f23d545faa6d5e91d196098f4d0a14146ace422a8b367ef3b34000",
"name": "ANS",
"symbol": "ANS",
"name": "ANS (alephium.domains)",
"nameOnChain": "ANS",
"symbol": "ANSd",
"symbolOnChain": "ANS",
"decimals": 18,
"description": "The token of the Alephium Name Service.",
"logoURI": "https://raw.githubusercontent.com/alephium/token-list/master/logos/ANS.png"
"description": "The token of the Alephium Name Service (alephium.domains).",
"logoURI": "https://raw.githubusercontent.com/alephium/token-list/master/logos/ANSd.png"
},
{
"id": "6b894505030718e45cdf7c59be1f8c6167542e43522e95303871e8280037b000",
Expand Down Expand Up @@ -720,6 +732,16 @@
"decimals": 18,
"description": "shiba meme coin for fun",
"logoURI": "https://raw.githubusercontent.com/alephium/token-list/master/logos/SHIBBO.png"
},
{
"id": "2df4cc8296aa5078f034eedeafec4139f23af440158204a93f76f21b74854500",
"name": "ANS (Open Source)",
"nameOnChain": "Alephium Name Service",
"symbol": "ANSo",
"symbolOnChain": "ANS",
"decimals": 18,
"description": "The token of the Alephium Name Service (alphnames.com).",
"logoURI": "https://raw.githubusercontent.com/alephium/token-list/master/logos/ANSo.svg"
}
]
}

0 comments on commit fe2ebe3

Please sign in to comment.