-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created
addtokens
helper + script to generate ESR.
- Loading branch information
Showing
6 changed files
with
102 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import {APIClient, Asset} from '@wharfkit/antelope' | ||
import {SigningRequest} from '@wharfkit/signing-request' | ||
import zlib from 'pako' | ||
|
||
import {Contract} from '../../codegen/api' | ||
import ABICache from '@wharfkit/abicache' | ||
|
||
const client = new APIClient({ | ||
url: 'https://eos.greymass.com', | ||
}) | ||
|
||
const contract = new Contract({ | ||
client, | ||
}) | ||
|
||
interface Token { | ||
key: string | ||
symbol: string | ||
account: string | ||
chain: string | ||
supply: { | ||
circulating: number | ||
max: number | ||
precision: number | ||
last_update: string | ||
} | ||
metadata: { | ||
name: string | ||
website: string | ||
logo: string | ||
created_at: string | ||
desc: string | ||
} | ||
chain_rank: string | ||
} | ||
|
||
async function fetchTokens(): Promise<Token[]> { | ||
const url = | ||
'https://raw.githubusercontent.com/greymass/antelope-tokens.json/refs/heads/main/tokens.json' | ||
const response = await fetch(url) | ||
if (!response.ok) { | ||
throw new Error(`HTTP error! status: ${response.status}`) | ||
} | ||
return response.json() | ||
} | ||
|
||
const tokens = await fetchTokens() | ||
|
||
const action = { | ||
tokens: [], | ||
} | ||
|
||
tokens | ||
.filter((token) => { | ||
return token.chain === 'eos' | ||
}) | ||
.forEach((token) => { | ||
action.tokens.push({ | ||
contract: token.account, | ||
symbol: Asset.Symbol.from(`${token.supply.precision},${token.symbol.toUpperCase()}`), | ||
}) | ||
}) | ||
|
||
const abiProvider = new ABICache(client) | ||
|
||
const request = await SigningRequest.create( | ||
{ | ||
action: contract.action('addtokens', action), | ||
}, | ||
{abiProvider, zlib} | ||
) | ||
|
||
console.log(String(request)) |