diff --git a/lib/index.ts b/lib/index.ts
index 13e3fe5..48edee2 100644
--- a/lib/index.ts
+++ b/lib/index.ts
@@ -18,7 +18,7 @@ along with the library. If not, see .
import mainnetTokenList from '../tokens/mainnet.json'
import testnetTokenList from '../tokens/testnet.json'
-import { TokenInfo, TokenList } from './types'
+import { NetworkId, TokenInfo, TokenList } from './types'
export * from './types'
@@ -28,6 +28,6 @@ export const testnet = testnetTokenList as TokenList
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
export const ALPH: TokenInfo = mainnet.tokens.find((token) => token.symbol === 'ALPH')!
-export function getTokensURL(networkId: 'mainnet' | 'testnet'): string {
+export function getTokensURL(networkId: NetworkId): string {
return `https://raw.githubusercontent.com/alephium/token-list/master/tokens/${networkId}.json`
}
diff --git a/lib/types.ts b/lib/types.ts
index 1fb5588..8c2ad82 100644
--- a/lib/types.ts
+++ b/lib/types.ts
@@ -29,3 +29,5 @@ export interface TokenInfo {
description: string
logoURI: string
}
+
+export type NetworkId = 'mainnet' | 'testnet'
diff --git a/test/token-list/devnet.json b/test/token-list/devnet.json
index a69d92c..3c2958a 100644
--- a/test/token-list/devnet.json
+++ b/test/token-list/devnet.json
@@ -1,6 +1,14 @@
{
"networkId": 2,
"tokens": [
+ {
+ "id": "0000000000000000000000000000000000000000000000000000000000000000",
+ "name": "Alephium",
+ "symbol": "ALPH",
+ "decimals": 18,
+ "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": "8342e4f9a27d1f9c31eb85bde36a4b39332648fef67dd43a0d5dc2771de0abc5",
"name": "Shiny Token",
@@ -8,7 +16,8 @@
"decimals": 0,
"description": "Sniny Token (SHNY) is a decentralized token for the Alephium community.",
"logoURI": "https://raw.githubusercontent.com/alephium/token-list/master/logos/SHNY.png"
- },{
+ },
+ {
"id": "141af4f9a27d1f9c31eb85bde36a4b39332648fef67dd43a0d5dc2771de0a381",
"name": "Steak Token",
"symbol": "STK",
diff --git a/test/token-list/token-list.test.ts b/test/token-list/token-list.test.ts
index 8f52a38..c56c32b 100644
--- a/test/token-list/token-list.test.ts
+++ b/test/token-list/token-list.test.ts
@@ -18,7 +18,6 @@ along with the library. If not, see .
import { FungibleTokenMetaData, hexToString, NodeProvider } from '@alephium/web3'
-import { ALPH } from '../../lib/index'
import { TokenInfo, TokenList } from '../../lib/types'
import mainnetJson from '../../tokens/mainnet.json'
import testnetJson from '../../tokens/testnet.json'
@@ -82,7 +81,7 @@ describe('TokenList', function () {
})
it('should have ALPH token', () => {
- const expected: TokenInfo = {
+ const expectedALPH: TokenInfo = {
id: ''.padStart(64, '0'),
name: 'Alephium',
symbol: 'ALPH',
@@ -91,15 +90,20 @@ describe('TokenList', function () {
'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'
}
- expect(ALPH).toEqual(expected)
+
+ tokenLists.forEach((tokenList) => {
+ expect(tokenList.tokens.find((token) => token.symbol === 'ALPH')).toEqual(expectedALPH)
+ })
})
const testnetNodeProvider = new NodeProvider(testnetURL)
testnetTokenList.tokens.forEach((token) => {
- it(`validate testnet ${token.name}`, async () => {
- await validateTokenMetadata(token, testnetNodeProvider)
- await validateTokenType(token, testnetNodeProvider)
- })
+ if (token.symbol !== 'ALPH') {
+ it(`validate testnet ${token.name}`, async () => {
+ await validateTokenMetadata(token, testnetNodeProvider)
+ await validateTokenType(token, testnetNodeProvider)
+ })
+ }
})
async function validateTokenType(token: TokenInfo, nodeProvider: NodeProvider) {
diff --git a/tokens/testnet.json b/tokens/testnet.json
index 0b404c5..5932abc 100644
--- a/tokens/testnet.json
+++ b/tokens/testnet.json
@@ -1,6 +1,14 @@
{
"networkId": 1,
"tokens": [
+ {
+ "id": "0000000000000000000000000000000000000000000000000000000000000000",
+ "name": "Alephium",
+ "symbol": "ALPH",
+ "decimals": 18,
+ "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": "bed35ce97166170f91a8cdb35948b8696aa67dbd573ee0c5cc572bb8c44ddb01",
"name": "Test BTC",