diff --git a/package.json b/package.json index f60db98..ef9de2c 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ }, "husky": { "hooks": { - "pre-commit": "tsdx lint" + "pre-commit": "tsdx lint src test" } }, "prettier": { @@ -61,7 +61,7 @@ "dotenv": "^16.0.0", "esbuild": "^0.14.21", "husky": "^7.0.4", - "nock": "^13.2.2", + "nock": "^13.4.0", "size-limit": "^7.0.5", "tsdx": "^0.14.1", "tslib": "^2.3.1", diff --git a/test/resolver.test.ts b/test/resolver.test.ts index 2bd4672..437a13a 100644 --- a/test/resolver.test.ts +++ b/test/resolver.test.ts @@ -1,4 +1,4 @@ -import { StaticJsonRpcProvider } from '@ethersproject/providers'; +import { JsonRpcProvider } from 'ethers'; import nock from 'nock'; import { AvatarResolver } from '../src'; @@ -14,252 +14,318 @@ const CORS_HEADERS = { 'access-control-allow-origin': 'http://localhost', }; -function nockInfura(method: string, params: any[], response: any) { +function nockInfuraBatch(body: any[], response: any) { + nock(INFURA_URL.origin) + .persist(false) + .post(INFURA_URL.pathname, body) + .reply(200, response); +} + +function mockInfuraChainId(id: number) { nock(INFURA_URL.origin) - .persist() .post(INFURA_URL.pathname, { - method, - params, + method: 'eth_chainId', + params: [], id: /[0-9]/, jsonrpc: '2.0', }) - .reply(200, response); + .reply( + 200, + { + jsonrpc: '2.0', + id: id, + result: '0x1', + }, + CORS_HEADERS as any + ); } -beforeAll(() => { - nockInfura('eth_chainId', [], { - id: 1, +function ethCallParams(to: string, data: string, id: number) { + return { + method: 'eth_call', + params: [{ to, data }, 'latest'], + id, jsonrpc: '2.0', - result: '0x01', // mainnet - }); - nockInfura('net_version', [], { + }; +} + +function chainIdParams(id: number) { + return { + method: 'eth_chainId', + params: [], + id, jsonrpc: '2.0', - id: 1, - result: '1', - }); - nockInfura( - 'eth_call', - [ - { - to: ENSRegistryWithFallback, - data: /^.*$/, - }, - 'latest', - ], - { - result: `0x${PublicResolver.replace('0x', '').padStart(64, '0')}`, - } - ); -}); + }; +} + +function jsonRPCresult(result: string, id: number) { + return { + jsonrpc: '2.0', + id, + result, + }; +} describe('get avatar', () => { - const provider = new StaticJsonRpcProvider( - 'https://mainnet.infura.io/v3/372375d582d843c48a4eaee6aa5c1b3a' - ); - const avt = new AvatarResolver(provider); - it('retrieves image uri with erc1155 spec', async () => { - nockInfura( - 'eth_call', + const provider = new JsonRpcProvider(INFURA_URL.toString(), 'mainnet'); + const avt = new AvatarResolver(provider, { + apiKey: { + opensea: 'a2b184238ee8460d9d2f58b0d3177c23', + }, + }); + it('retrieves image uri with erc721 spec', async () => { + mockInfuraChainId(1); + + nockInfuraBatch( [ - { - to: PublicResolver.toLowerCase(), - data: - '0x3b3b57de05a67c0ee82964c4f7394cdd47fee7f4d9503a23c09c38341779ea012afe6e00', - }, - 'latest', + chainIdParams(2), + ethCallParams( + ENSRegistryWithFallback, + '0x0178b8bf80ee077a908dffcf32972ba13c2df16b42688e1de21bcf17d3469a8507895eae', + 3 + ), + ethCallParams( + ENSRegistryWithFallback, + '0x0178b8bf80ee077a908dffcf32972ba13c2df16b42688e1de21bcf17d3469a8507895eae', + 4 + ), ], - { - result: - '0x000000000000000000000000b8c2c29ee19d8307cb7255e1cd9cbde883a267d5', - } - ); - nockInfura( - 'eth_call', [ - { - to: PublicResolver.toLowerCase(), - data: - '0x59d1d43c05a67c0ee82964c4f7394cdd47fee7f4d9503a23c09c38341779ea012afe6e00000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000066176617461720000000000000000000000000000000000000000000000000000', - }, - 'latest', - ], - { - result: - '0x000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000886569703135353a312f657263313135353a3078343935663934373237363734396365363436663638616338633234383432303034356362376235652f38313132333136303235383733393237373337353035393337383938393135313533373332353830313033393133373034333334303438353132333830343930373937303038353531393337000000000000000000000000000000000000000000000000', - } + jsonRPCresult('0x1', 2), + jsonRPCresult( + '0x0000000000000000000000004976fb03c32e5b8cfe2b6ccb31c09ba78ebaba41', + 3 + ), + jsonRPCresult( + '0x0000000000000000000000004976fb03c32e5b8cfe2b6ccb31c09ba78ebaba41', + 4 + ), + ] ); - nockInfura( - 'eth_call', + nockInfuraBatch( [ - { - to: '0x495f947276749ce646f68ac8c248420045cb7b5e', - data: - '0x0e89341c11ef687cfeb2e353670479f2dcc76af2bc6b3935000000000002c40000000001', - }, - 'latest', + ethCallParams( + PublicResolver.toLowerCase(), + '0x01ffc9a79061b92300000000000000000000000000000000000000000000000000000000', + 5 + ), + chainIdParams(6), ], - { - result: - '0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000005868747470733a2f2f6170692e6f70656e7365612e696f2f6170692f76312f6d657461646174612f3078343935663934373237363734394365363436663638414338633234383432303034356362376235652f30787b69647d0000000000000000', - } - ); - nockInfura( - 'eth_call', [ - { - to: '0x495f947276749ce646f68ac8c248420045cb7b5e', - data: - '0x00fdd58e000000000000000000000000b8c2c29ee19d8307cb7255e1cd9cbde883a267d511ef687cfeb2e353670479f2dcc76af2bc6b3935000000000002c40000000001', - }, - 'latest', - ], - { - result: - '0x0000000000000000000000000000000000000000000000000000000000000001', - } - ); - const MANIFEST_URI_NICK = new URL( - 'https://api.opensea.io/api/v1/metadata/0x495f947276749Ce646f68AC8c248420045cb7b5e/8112316025873927737505937898915153732580103913704334048512380490797008551937' + jsonRPCresult( + '0x0000000000000000000000000000000000000000000000000000000000000000', + 5 + ), + jsonRPCresult('0x1', 6), + ] ); - nock(MANIFEST_URI_NICK.origin) - .get(MANIFEST_URI_NICK.pathname) - .reply( - 200, - { - name: 'Nick Johnson', - description: null, - external_link: null, - image: - 'https://lh3.googleusercontent.com/hKHZTZSTmcznonu8I6xcVZio1IF76fq0XmcxnvUykC-FGuVJ75UPdLDlKJsfgVXH9wOSmkyHw0C39VAYtsGyxT7WNybjQ6s3fM3macE', - animation_url: null, - }, - CORS_HEADERS as any - ); - expect(await avt.getAvatar('nick.eth')).toEqual( - 'https://lh3.googleusercontent.com/hKHZTZSTmcznonu8I6xcVZio1IF76fq0XmcxnvUykC-FGuVJ75UPdLDlKJsfgVXH9wOSmkyHw0C39VAYtsGyxT7WNybjQ6s3fM3macE' - ); - }); - it('retrieves image uri with erc721 spec', async () => { - nockInfura( - 'eth_call', + nockInfuraBatch( [ - { - to: PublicResolver.toLowerCase(), - data: - '0x3b3b57de43fcd34d8589090581e1d2bdcf5dc17feb05b2006401fb1c3fdded335a465b51', - }, - 'latest', + ethCallParams( + PublicResolver.toLowerCase(), + '0x3b3b57de80ee077a908dffcf32972ba13c2df16b42688e1de21bcf17d3469a8507895eae', + 7 + ), + chainIdParams(8), ], - { - result: - '0x000000000000000000000000983110309620d911731ac0932219af06091b6744', - } + [ + jsonRPCresult( + '0x0000000000000000000000005a384227b65fa093dec03ec34e111db80a040615', + 7 + ), + jsonRPCresult('0x1', 8), + ] ); - nockInfura( - 'eth_call', + nockInfuraBatch( [ - { - to: PublicResolver.toLowerCase(), - data: - '0x59d1d43c43fcd34d8589090581e1d2bdcf5dc17feb05b2006401fb1c3fdded335a465b51000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000066176617461720000000000000000000000000000000000000000000000000000', - }, - 'latest', + ethCallParams( + PublicResolver.toLowerCase(), + '0x01ffc9a79061b92300000000000000000000000000000000000000000000000000000000', + 9 + ), + chainIdParams(10), ], - { - result: - '0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000003f6569703135353a312f6572633732313a3078623746374636433532463265326664623139363345616233303433383032343836346333313346362f3234333000', - } + [ + jsonRPCresult( + '0x0000000000000000000000000000000000000000000000000000000000000000', + 9 + ), + jsonRPCresult('0x1', 10), + ] ); - nockInfura( - 'eth_call', + nockInfuraBatch( [ - { - to: '0xb7f7f6c52f2e2fdb1963eab30438024864c313f6', - data: - '0xc87b56dd000000000000000000000000000000000000000000000000000000000000097e', - }, - 'latest', + ethCallParams( + PublicResolver.toLowerCase(), + '0x59d1d43c80ee077a908dffcf32972ba13c2df16b42688e1de21bcf17d3469a8507895eae000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000066176617461720000000000000000000000000000000000000000000000000000', + 11 + ), + chainIdParams(12), ], - { - result: - '0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000003568747470733a2f2f7772617070656470756e6b732e636f6d3a333030302f6170692f70756e6b732f6d657461646174612f323433300000000000000000000000', - } + [ + jsonRPCresult( + '0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000003f6569703135353a312f6572633732313a3078333133383564333532306263656439346637376161653130346234303639393464386632313638632f3934323100', + 11 + ), + jsonRPCresult('0x1', 12), + ] ); - nockInfura( - 'eth_call', + nockInfuraBatch( [ - { - to: '0xb7f7f6c52f2e2fdb1963eab30438024864c313f6', - data: - '0x6352211e000000000000000000000000000000000000000000000000000000000000097e', - }, - 'latest', + ethCallParams( + '0x31385d3520bced94f77aae104b406994d8f2168c', + '0xc87b56dd00000000000000000000000000000000000000000000000000000000000024cd', + 13 + ), + chainIdParams(14), + ethCallParams( + '0x31385d3520bced94f77aae104b406994d8f2168c', + '0x6352211e00000000000000000000000000000000000000000000000000000000000024cd', + 15 + ), ], - { - result: - '0x000000000000000000000000983110309620d911731ac0932219af06091b6744', - } + [ + jsonRPCresult( + '0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002568747470733a2f2f6170692e6261737461726467616e70756e6b732e636c75622f39343231000000000000000000000000000000000000000000000000000000', + 13 + ), + jsonRPCresult('0x1', 14), + jsonRPCresult( + '0x0000000000000000000000005a384227b65fa093dec03ec34e111db80a040615', + 15 + ), + ] ); - const MANIFEST_URI_BRANTLY = new URL( - 'https://wrappedpunks.com:3000/api/punks/metadata/2430' + + const MANIFEST_URI_MATOKEN = new URL( + 'https://api.bastardganpunks.club/9421' ); - const NFT_URI_BRANTLY = new URL( - 'https://api.wrappedpunks.com/images/punks/2430.png' + const NFT_URI_MATOKEN = new URL( + 'https://ipfs.io/ipfs/QmRagxjj2No4T8gNCjpM42mLZGQE3ZwMYdTFUYe6e6LMBG' ); - nock(MANIFEST_URI_BRANTLY.origin) - .get(MANIFEST_URI_BRANTLY.pathname) + nock(MANIFEST_URI_MATOKEN.origin) + .get(MANIFEST_URI_MATOKEN.pathname) .reply( 200, { - title: 'W#2430', - name: 'W#2430', + tokenId: 9421, + name: 'BASTARD GAN PUNK V2 #9421', description: - 'This Punk was wrapped using Wrapped Punks contract, accessible from https://wrappedpunks.com', - image: 'https://api.wrappedpunks.com/images/punks/2430.png', - external_url: 'https://wrappedpunks.com', + "FOR THE CHANCES\nI HAVEN'T GOT A BURIAL IN MY ARMS\nAND I'VE HAD ENOUGH\nTIME IS NOW\nIT'S TIME\nI'VE GOT NOTHING TO PROVE\nI'VE GOT NOTHING TO LOSE\n", + image: + 'https://ipfs.io/ipfs/QmRagxjj2No4T8gNCjpM42mLZGQE3ZwMYdTFUYe6e6LMBG', + imageArweave: + 'https://arweave.net/ve7z_TcSos6nJpjGyuT423B9yyalq5GR4s7CQWGXHpk', + external_url: 'https://www.bastardganpunks.club/v2/9421', }, CORS_HEADERS as any ); - nock(NFT_URI_BRANTLY.origin) - .head(NFT_URI_BRANTLY.pathname) + nock(NFT_URI_MATOKEN.origin) + .head(NFT_URI_MATOKEN.pathname) .reply(200, {}, { ...CORS_HEADERS, 'content-type': 'image/png', } as any); - expect(await avt.getAvatar('brantly.eth')).toEqual( - 'https://api.wrappedpunks.com/images/punks/2430.png' + expect(await avt.getAvatar('matoken.eth')).toEqual( + 'https://ipfs.io/ipfs/QmRagxjj2No4T8gNCjpM42mLZGQE3ZwMYdTFUYe6e6LMBG' ); }); it('retrieves image uri with custom spec', async () => { - nockInfura( - 'eth_call', + mockInfuraChainId(16); + + nockInfuraBatch( [ - { - to: PublicResolver.toLowerCase(), - data: - '0x3b3b57deb47a0edaf3c702800c923ca4c44a113d0d718cb1f42ecdce70c5fd05fa36a63f', - }, - 'latest', + ethCallParams( + ENSRegistryWithFallback.toString(), + '0x0178b8bfb47a0edaf3c702800c923ca4c44a113d0d718cb1f42ecdce70c5fd05fa36a63f', + 17 + ), + chainIdParams(18), + ethCallParams( + ENSRegistryWithFallback.toString(), + '0x0178b8bfb47a0edaf3c702800c923ca4c44a113d0d718cb1f42ecdce70c5fd05fa36a63f', + 19 + ), ], - { - result: + [ + jsonRPCresult( + '0x0000000000000000000000004976fb03c32e5b8cfe2b6ccb31c09ba78ebaba41', + 17 + ), + jsonRPCresult('0x1', 18), + jsonRPCresult( + '0x0000000000000000000000004976fb03c32e5b8cfe2b6ccb31c09ba78ebaba41', + 19 + ), + ] + ); + nockInfuraBatch( + [ + ethCallParams( + PublicResolver.toLowerCase(), + '0x01ffc9a79061b92300000000000000000000000000000000000000000000000000000000', + 20 + ), + chainIdParams(21), + ], + [ + jsonRPCresult( + '0x0000000000000000000000000000000000000000000000000000000000000000', + 20 + ), + jsonRPCresult('0x1', 21), + ] + ); + nockInfuraBatch( + [ + ethCallParams( + PublicResolver.toLowerCase(), + '0x3b3b57deb47a0edaf3c702800c923ca4c44a113d0d718cb1f42ecdce70c5fd05fa36a63f', + 22 + ), + chainIdParams(23), + ], + [ + jsonRPCresult( '0x0000000000000000000000000d59d0f7dcc0fbf0a3305ce0261863aaf7ab685c', - } + 22 + ), + jsonRPCresult('0x1', 23), + ] ); - nockInfura( - 'eth_call', + nockInfuraBatch( [ - { - to: PublicResolver.toLowerCase(), - data: - '0x59d1d43cb47a0edaf3c702800c923ca4c44a113d0d718cb1f42ecdce70c5fd05fa36a63f000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000066176617461720000000000000000000000000000000000000000000000000000', - }, - 'latest', + ethCallParams( + PublicResolver.toLowerCase(), + '0x01ffc9a79061b92300000000000000000000000000000000000000000000000000000000', + 24 + ), + chainIdParams(25), ], - { - result: + [ + jsonRPCresult( + '0x0000000000000000000000000000000000000000000000000000000000000000', + 24 + ), + jsonRPCresult('0x1', 25), + ] + ); + nockInfuraBatch( + [ + ethCallParams( + PublicResolver.toLowerCase(), + '0x59d1d43cb47a0edaf3c702800c923ca4c44a113d0d718cb1f42ecdce70c5fd05fa36a63f000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000066176617461720000000000000000000000000000000000000000000000000000', + 26 + ), + chainIdParams(27), + ], + [ + jsonRPCresult( '0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000004368747470733a2f2f697066732e696f2f697066732f516d55536867666f5a5153484b3354517975546655707363385566654e6644384b77505576444255645a346e6d520000000000000000000000000000000000000000000000000000000000', - } + 26 + ), + jsonRPCresult('0x1', 27), + ] ); const MANIFEST_URI_TANRIKULU = new URL( 'https://ipfs.io/ipfs/QmUShgfoZQSHK3TQyuTfUpsc8UfeNfD8KwPUvDBUdZ4nmR' @@ -282,6 +348,177 @@ describe('get avatar', () => { 'https://ipfs.io/ipfs/QmUShgfoZQSHK3TQyuTfUpsc8UfeNfD8KwPUvDBUdZ4nmR' ); }); + it('retrieves image uri with erc1155 spec', async () => { + mockInfuraChainId(28); + + nockInfuraBatch( + [ + ethCallParams( + ENSRegistryWithFallback.toLowerCase(), + '0x0178b8bf05a67c0ee82964c4f7394cdd47fee7f4d9503a23c09c38341779ea012afe6e00', + 29 + ), + chainIdParams(30), + ethCallParams( + ENSRegistryWithFallback.toLowerCase(), + '0x0178b8bf05a67c0ee82964c4f7394cdd47fee7f4d9503a23c09c38341779ea012afe6e00', + 31 + ), + ], + [ + jsonRPCresult( + '0x0000000000000000000000004976fb03c32e5b8cfe2b6ccb31c09ba78ebaba41', + 29 + ), + jsonRPCresult('0x1', 30), + jsonRPCresult( + '0x0000000000000000000000004976fb03c32e5b8cfe2b6ccb31c09ba78ebaba41', + 31 + ), + ] + ); + nockInfuraBatch( + [ + ethCallParams( + PublicResolver.toLowerCase(), + '0x01ffc9a79061b92300000000000000000000000000000000000000000000000000000000', + 32 + ), + chainIdParams(33), + ], + [ + jsonRPCresult( + '0x0000000000000000000000000000000000000000000000000000000000000000', + 32 + ), + jsonRPCresult('0x1', 33), + ] + ); + nockInfuraBatch( + [ + ethCallParams( + PublicResolver.toLowerCase(), + '0x3b3b57de05a67c0ee82964c4f7394cdd47fee7f4d9503a23c09c38341779ea012afe6e00', + 34 + ), + chainIdParams(35), + ], + [ + jsonRPCresult( + '0x000000000000000000000000b8c2c29ee19d8307cb7255e1cd9cbde883a267d5', + 34 + ), + jsonRPCresult('0x1', 35), + ] + ); + nockInfuraBatch( + [ + ethCallParams( + PublicResolver.toLowerCase(), + '0x01ffc9a79061b92300000000000000000000000000000000000000000000000000000000', + 36 + ), + chainIdParams(37), + ], + [ + jsonRPCresult( + '0x0000000000000000000000000000000000000000000000000000000000000000', + 36 + ), + jsonRPCresult('0x1', 37), + ] + ); + nockInfuraBatch( + [ + ethCallParams( + PublicResolver.toLowerCase(), + '0x59d1d43c05a67c0ee82964c4f7394cdd47fee7f4d9503a23c09c38341779ea012afe6e00000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000066176617461720000000000000000000000000000000000000000000000000000', + 38 + ), + chainIdParams(39), + ], + [ + jsonRPCresult( + '0x000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000886569703135353a312f657263313135353a3078343935663934373237363734396365363436663638616338633234383432303034356362376235652f38313132333136303235383733393237373337353035393337383938393135313533373332353830313033393133373034333334303438353132333830343930373937303038353531393337000000000000000000000000000000000000000000000000', + 38 + ), + jsonRPCresult('0x1', 39), + ] + ); + nockInfuraBatch( + [ + ethCallParams( + '0x495f947276749ce646f68ac8c248420045cb7b5e', + '0x0e89341c11ef687cfeb2e353670479f2dcc76af2bc6b3935000000000002c40000000001', + 40 + ), + chainIdParams(41), + ethCallParams( + '0x495f947276749ce646f68ac8c248420045cb7b5e', + '0x00fdd58e000000000000000000000000b8c2c29ee19d8307cb7255e1cd9cbde883a267d511ef687cfeb2e353670479f2dcc76af2bc6b3935000000000002c40000000001', + 42 + ), + ], + [ + jsonRPCresult( + '0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000005868747470733a2f2f6170692e6f70656e7365612e696f2f6170692f76312f6d657461646174612f3078343935663934373237363734394365363436663638414338633234383432303034356362376235652f30787b69647d0000000000000000', + 40 + ), + jsonRPCresult('0x1', 41), + jsonRPCresult( + '0x0000000000000000000000000000000000000000000000000000000000000001', + 42 + ), + ] + ); + const MANIFEST_URI_NICK = new URL( + 'https://api.opensea.io/api/v1/metadata/0x495f947276749Ce646f68AC8c248420045cb7b5e/8112316025873927737505937898915153732580103913704334048512380490797008551937' + ); + const NFT_URI_NICK = new URL( + 'https://i.seadn.io/gae/hKHZTZSTmcznonu8I6xcVZio1IF76fq0XmcxnvUykC-FGuVJ75UPdLDlKJsfgVXH9wOSmkyHw0C39VAYtsGyxT7WNybjQ6s3fM3macE?w=500&auto=format' + ); + nock(MANIFEST_URI_NICK.origin) + .options(MANIFEST_URI_NICK.pathname) + .reply(200, {}, { + ...CORS_HEADERS, + 'access-control-allow-headers': + 'accept, authorization, content-type, user-agent, x-csrftoken, x-requested-with, x-datadog-origin, x-datadog-parent-id, x-datadog-sampled, x-datadog-sampling-priority, x-datadog-trace-id, i196zqqsyk-a0, i196zqqsyk-a1, i196zqqsyk-a2, i196zqqsyk-a, i196zqqsyk-b, i196zqqsyk-c, i196zqqsyk-d, i196zqqsyk-f, i196zqqsyk-z, x-readme-api-explorer, x-api-key, x-build-id, x-signed-query, x-cache-skip, x-app-id, solana-client', + 'access-control-allow-methods': + 'DELETE, GET, OPTIONS, PATCH, POST, PUT', + 'access-control-max-age': '86400', + 'content-type': 'text/html; charset=utf-8', + 'transfer-encoding': 'chunked', + vary: 'origin', + 'x-content-type-options': 'nosniff', + } as any); + nock(NFT_URI_NICK.origin) + .head(NFT_URI_NICK.pathname + '?' + NFT_URI_NICK.searchParams) + .reply( + 200, + {}, + { + 'accept-ranges': 'bytes', + 'access-control-allow-origin': '*', + 'access-control-expose-headers': '*', + 'content-length': '7229', + 'content-type': 'image/png', + } + ); + nock(MANIFEST_URI_NICK.origin) + .get(MANIFEST_URI_NICK.pathname) + .reply( + 200, + { + name: 'Nick Johnson', + description: null, + external_link: null, + image: NFT_URI_NICK.toString(), + animation_url: null, + }, + CORS_HEADERS as any + ); + expect(await avt.getAvatar('nick.eth')).toEqual(NFT_URI_NICK.toString()); + }); it('sets cache to 1 sec', async () => { const avt = new AvatarResolver(provider, { cache: 1 }); diff --git a/yarn.lock b/yarn.lock index d1b6888..74e1aa2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4970,11 +4970,6 @@ lodash.merge@^4.6.2: resolved "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz" integrity sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ== -lodash.set@^4.3.2: - version "4.3.2" - resolved "https://registry.npmjs.org/lodash.set/-/lodash.set-4.3.2.tgz" - integrity sha1-2HV7HagH3eJIFrDWqEvqGnYjCyM= - lodash.sortby@^4.7.0: version "4.7.0" resolved "https://registry.npmjs.org/lodash.sortby/-/lodash.sortby-4.7.0.tgz" @@ -5247,14 +5242,13 @@ no-case@^3.0.4: lower-case "^2.0.2" tslib "^2.0.3" -nock@^13.2.2: - version "13.2.2" - resolved "https://registry.npmjs.org/nock/-/nock-13.2.2.tgz" - integrity sha512-PcBHuvl9i6zfaJ50A7LS55oU+nFLv8htXIhffJO+FxyfibdZ4jEvd9kTuvkrJireBFIGMZ+oUIRpMK5gU9h//g== +nock@^13.4.0: + version "13.4.0" + resolved "https://registry.yarnpkg.com/nock/-/nock-13.4.0.tgz#60aa3f7a4afa9c12052e74d8fb7550f682ef0115" + integrity sha512-W8NVHjO/LCTNA64yxAPHV/K47LpGYcVzgKd3Q0n6owhwvD0Dgoterc25R4rnZbckJEb6Loxz1f5QMuJpJnbSyQ== dependencies: debug "^4.1.0" json-stringify-safe "^5.0.1" - lodash.set "^4.3.2" propagate "^2.0.0" node-int64@^0.4.0: