@@ -13,6 +13,7 @@ import {
1313 Erc1155Coin ,
1414 Erc20Coin ,
1515 Erc721Coin ,
16+ Erc7984Coin ,
1617 EthLikeERC20Token ,
1718 EthLikeERC721Token ,
1819 FlrERC20Token ,
@@ -68,6 +69,7 @@ export type EosTokenConfig = BaseContractAddressConfig & {
6869 contractAddress : string ;
6970} ;
7071export type Erc20TokenConfig = BaseContractAddressConfig ;
72+ export type Erc7984TokenConfig = BaseContractAddressConfig ;
7173export type TrxTokenConfig = BaseContractAddressConfig ;
7274export type StellarTokenConfig = BaseNetworkConfig ;
7375
@@ -191,12 +193,14 @@ export type TokenConfig =
191193 | PolyxTokenConfig
192194 | JettonTokenConfig
193195 | EthLikeERC721TokenConfig
194- | Tip20TokenConfig ;
196+ | Tip20TokenConfig
197+ | Erc7984TokenConfig ;
195198
196199export interface TokenNetwork {
197200 eth : {
198201 tokens : Erc20TokenConfig [ ] ;
199202 nfts : EthLikeTokenConfig [ ] ;
203+ confidentialTokens : Erc7984TokenConfig [ ] ;
200204 } ;
201205 xlm : { tokens : StellarTokenConfig [ ] } ;
202206 algo : { tokens : AlgoTokenConfig [ ] } ;
@@ -342,6 +346,44 @@ export const getFormattedErc20Tokens = (customCoinMap = coins) =>
342346 return acc ;
343347 } , [ ] ) ;
344348
349+ function getErc7984TokenConfig ( coin : Erc7984Coin ) : Erc7984TokenConfig {
350+ let baseCoin : string ;
351+ switch ( coin . network . name ) {
352+ case Networks . main . ethereum . name :
353+ baseCoin = 'eth' ;
354+ break ;
355+ case Networks . test . kovan . name :
356+ baseCoin = 'teth' ;
357+ break ;
358+ case Networks . test . goerli . name :
359+ baseCoin = 'gteth' ;
360+ break ;
361+ case Networks . test . holesky . name :
362+ case Networks . test . hoodi . name :
363+ baseCoin = 'hteth' ;
364+ break ;
365+ default :
366+ throw new Error ( `ERC-7984 token ${ coin . name } has an unsupported network` ) ;
367+ }
368+ return {
369+ type : coin . name ,
370+ coin : baseCoin ,
371+ network : coin . network . type === NetworkType . MAINNET ? 'Mainnet' : 'Testnet' ,
372+ name : coin . fullName ,
373+ tokenContractAddress : coin . contractAddress . toString ( ) . toLowerCase ( ) ,
374+ decimalPlaces : coin . decimalPlaces ,
375+ } ;
376+ }
377+
378+ // Get the list of ERC-7984 confidential tokens from statics and format it properly
379+ export const getFormattedErc7984Tokens = ( customCoinMap = coins ) =>
380+ customCoinMap . reduce ( ( acc : Erc7984TokenConfig [ ] , coin ) => {
381+ if ( coin instanceof Erc7984Coin ) {
382+ acc . push ( getErc7984TokenConfig ( coin ) ) ;
383+ }
384+ return acc ;
385+ } , [ ] ) ;
386+
345387export const ethGasConfigs = {
346388 minimumGasPrice : 1000000000 , // minimum gas price a user can provide (1 Gwei)
347389 defaultGasPrice : 20000000000 , // default gas price if estimation fails (20 Gwei)
@@ -1152,6 +1194,7 @@ type EthLikeTokenMap = {
11521194export enum TokenTypeEnum {
11531195 ERC20 = 'erc20' ,
11541196 ERC721 = 'erc721' ,
1197+ ERC7984 = 'erc7984' ,
11551198}
11561199
11571200function getEthLikeTokenConfig ( coin : EthLikeERC20Token ) : EthLikeTokenConfig {
@@ -1257,6 +1300,7 @@ export const getFormattedTokensByNetwork = (network: 'Mainnet' | 'Testnet', coin
12571300 eth : {
12581301 tokens : getFormattedErc20Tokens ( coinMap ) . filter ( ( token ) => token . network === network ) ,
12591302 nfts : getFormattedErc721Tokens ( coinMap ) . filter ( ( token ) => token . network === network ) ,
1303+ confidentialTokens : getFormattedErc7984Tokens ( coinMap ) . filter ( ( token ) => token . network === network ) ,
12601304 } ,
12611305 xlm : {
12621306 tokens : getFormattedStellarTokens ( coinMap ) . filter ( ( token ) => token . network === network ) ,
@@ -1443,13 +1487,25 @@ export const formattedAlgoTokens = getFormattedAlgoTokens();
14431487
14441488const mainnetErc20Tokens = verifyTokens ( tokens . bitcoin . eth . tokens ) ;
14451489const mainnetErc721Tokens = verifyTokens ( tokens . bitcoin . eth . nfts ) ;
1490+ const mainnetErc7984Tokens = verifyTokens ( tokens . bitcoin . eth . confidentialTokens ) ;
14461491const mainnetStellarTokens = verifyTokens ( tokens . bitcoin . xlm . tokens ) ;
1447- export const mainnetTokens = { ...mainnetErc20Tokens , ...mainnetErc721Tokens , ...mainnetStellarTokens } ;
1492+ export const mainnetTokens = {
1493+ ...mainnetErc20Tokens ,
1494+ ...mainnetErc721Tokens ,
1495+ ...mainnetErc7984Tokens ,
1496+ ...mainnetStellarTokens ,
1497+ } ;
14481498
14491499const testnetErc20Tokens = verifyTokens ( tokens . testnet . eth . tokens ) ;
14501500const testnetErc721Tokens = verifyTokens ( tokens . testnet . eth . nfts ) ;
1501+ const testnetErc7984Tokens = verifyTokens ( tokens . testnet . eth . confidentialTokens ) ;
14511502const testnetStellarTokens = verifyTokens ( tokens . testnet . xlm . tokens ) ;
1452- export const testnetTokens = { ...testnetErc20Tokens , ...testnetErc721Tokens , ...testnetStellarTokens } ;
1503+ export const testnetTokens = {
1504+ ...testnetErc20Tokens ,
1505+ ...testnetErc721Tokens ,
1506+ ...testnetErc7984Tokens ,
1507+ ...testnetStellarTokens ,
1508+ } ;
14531509
14541510/**
14551511 * Get formatted token configuration for a single coin
@@ -1459,6 +1515,8 @@ export const testnetTokens = { ...testnetErc20Tokens, ...testnetErc721Tokens, ..
14591515export function getFormattedTokenConfigForCoin ( coin : Readonly < BaseCoin > ) : TokenConfig | undefined {
14601516 if ( coin instanceof Erc20Coin ) {
14611517 return getErc20TokenConfig ( coin ) ;
1518+ } else if ( coin instanceof Erc7984Coin ) {
1519+ return getErc7984TokenConfig ( coin ) ;
14621520 } else if ( coin instanceof StellarCoin ) {
14631521 return getStellarTokenConfig ( coin ) ;
14641522 } else if ( coin instanceof OfcCoin ) {
0 commit comments