@@ -3,52 +3,74 @@ import {
3
3
CachingTokenListProvider ,
4
4
ITokenListProvider ,
5
5
ITokenProvider ,
6
- log ,
7
6
NodeJSCache ,
8
7
} from '@sky-mavis/smart-order-router'
9
- import { TokenList } from '@uniswap/token-lists'
10
- import S3 from 'aws-sdk/clients/s3'
11
8
import NodeCache from 'node-cache'
12
9
13
- const TOKEN_LIST_CACHE = new NodeCache ( { stdTTL : 600 , useClones : false } )
10
+ // const TOKEN_LIST_CACHE = new NodeCache({ stdTTL: 600, useClones: false })
11
+
12
+ const DEFAULT_TEMPLATE = {
13
+ "name" : "Uniswap Labs Default" ,
14
+ "timestamp" : "2024-11-18T15:56:01.725Z" ,
15
+ "version" : {
16
+ "major" : 12 ,
17
+ "minor" : 26 ,
18
+ "patch" : 0
19
+ } ,
20
+ "tags" : { } ,
21
+ "logoURI" : "ipfs://QmNa8mQkrNKp1WEEeGjFezDmDeodkWRevGFN8JCV7b4Xir" ,
22
+ "keywords" : [
23
+ "uniswap" ,
24
+ "default"
25
+ ] ,
26
+ "tokens" : [
27
+ {
28
+ "chainId" : 1 ,
29
+ "address" : "0x3E5A19c91266aD8cE2477B91585d1856B84062dF" ,
30
+ "name" : "Ancient8" ,
31
+ "symbol" : "A8" ,
32
+ "decimals" : 18 ,
33
+ "logoURI" : "https://assets.coingecko.com/coins/images/39170/standard/A8_Token-04_200x200.png?1720798300"
34
+ } ,
35
+ ]
36
+ }
14
37
15
38
export class AWSTokenListProvider extends CachingTokenListProvider {
16
39
public static async fromTokenListS3Bucket (
17
40
chainId : ChainId ,
18
- bucket : string ,
19
- tokenListURI : string
41
+ // bucket: string,
42
+ // tokenListURI: string
20
43
) : Promise < ITokenListProvider & ITokenProvider > {
21
- const s3 = new S3 ( { correctClockSkew : true , maxRetries : 3 } )
22
-
23
- const cachedTokenList = TOKEN_LIST_CACHE . get < TokenList > ( tokenListURI )
24
-
44
+ // const s3 = new S3({ correctClockSkew: true, maxRetries: 3 })
45
+ // const cachedTokenList = TOKEN_LIST_CACHE.get<TokenList>(tokenListURI)
25
46
const tokenCache = new NodeCache ( { stdTTL : 360 , useClones : false } )
47
+ return super . fromTokenList ( chainId , DEFAULT_TEMPLATE , new NodeJSCache ( tokenCache ) )
26
48
27
- if ( cachedTokenList ) {
28
- log . info ( `Found token lists for ${ tokenListURI } in local cache` )
29
- return super . fromTokenList ( chainId , cachedTokenList , new NodeJSCache ( tokenCache ) )
30
- }
49
+ // if (cachedTokenList) {
50
+ // log.info(`Found token lists for ${tokenListURI} in local cache`)
51
+ // return super.fromTokenList(chainId, DEFAULT_TEMPLATE , new NodeJSCache(tokenCache))
52
+ // }
31
53
32
- try {
33
- log . info ( `Getting tokenLists from s3.` )
34
- const tokenListResult = await s3 . getObject ( { Key : encodeURIComponent ( tokenListURI ) , Bucket : bucket } ) . promise ( )
54
+ // try {
55
+ // log.info(`Getting tokenLists from s3.`)
56
+ // const tokenListResult = await s3.getObject({ Key: encodeURIComponent(tokenListURI), Bucket: bucket }).promise()
35
57
36
- const { Body : tokenListBuffer } = tokenListResult
58
+ // const { Body: tokenListBuffer } = tokenListResult
37
59
38
- if ( ! tokenListBuffer ) {
39
- return super . fromTokenListURI ( chainId , tokenListURI , new NodeJSCache ( tokenCache ) )
40
- }
60
+ // if (!tokenListBuffer) {
61
+ // return super.fromTokenListURI(chainId, tokenListURI, new NodeJSCache(tokenCache))
62
+ // }
41
63
42
- const tokenList = JSON . parse ( tokenListBuffer . toString ( 'utf-8' ) ) as TokenList
64
+ // const tokenList = JSON.parse(tokenListBuffer.toString('utf-8')) as TokenList
43
65
44
- log . info ( `Got both tokenLists from s3. ${ tokenList . tokens . length } tokens in main list.` )
66
+ // log.info(`Got both tokenLists from s3. ${tokenList.tokens.length} tokens in main list.`)
45
67
46
- TOKEN_LIST_CACHE . set < TokenList > ( tokenListURI , tokenList )
68
+ // TOKEN_LIST_CACHE.set<TokenList>(tokenListURI, tokenList)
47
69
48
- return new CachingTokenListProvider ( chainId , tokenList , new NodeJSCache ( tokenCache ) )
49
- } catch ( err ) {
50
- log . info ( { err } , `Failed to get tokenLists from s3.` )
51
- return super . fromTokenListURI ( chainId , tokenListURI , new NodeJSCache ( tokenCache ) )
52
- }
70
+ // return new CachingTokenListProvider(chainId, tokenList, new NodeJSCache(tokenCache))
71
+ // } catch (err) {
72
+ // log.info({ err }, `Failed to get tokenLists from s3.`)
73
+ // return super.fromTokenListURI(chainId, tokenListURI, new NodeJSCache(tokenCache))
74
+ // }
53
75
}
54
76
}
0 commit comments