diff --git a/package-lock.json b/package-lock.json index d2aae38..7a0a16e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "xype-resolver", - "version": "1.0.0", + "version": "1.1.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "xype-resolver", - "version": "1.0.0", + "version": "1.1.0", "license": "MIT", "devDependencies": { "@ryansonshine/commitizen": "^4.2.8", diff --git a/package.json b/package.json index 9c30122..a934eb3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xype-resolver", - "version": "1.1.0", + "version": "1.2.0", "description": "The Xype Name Resolver Library", "main": "./lib/index.js", "types": "./lib/index.d.ts", diff --git a/src/constants.ts b/src/constants.ts index 5b31735..88fb912 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -1,6 +1,6 @@ export const XYPE_REGISTRY_ADDRESS = { - 1: '0x2C1E6E5F4cd8Aa0f103e8653ea109A0b8b1aAf70', - 5: '0x2C1E6E5F4cd8Aa0f103e8653ea109A0b8b1aAf70', + 1: '0x5db0E9eD56EF5B3760cE7887BAf215a39dE8d61E', + 5: '', 11155111: '0x2C1E6E5F4cd8Aa0f103e8653ea109A0b8b1aAf70', } as Record; diff --git a/src/resolver.ts b/src/resolver.ts index 1163746..c36eb70 100644 --- a/src/resolver.ts +++ b/src/resolver.ts @@ -25,9 +25,13 @@ export class XypeResolver { * Creates the XypeResolver instance with specified Web3Connection type * * @param connection A string representing RPC URL or the JsonRpcProvider object + * @param chainId An optional number representing the chain id * @returns New XypeResolver instance */ - public static async init(connection: Web3Connection): Promise { + public static async init( + connection: Web3Connection, + chainId?: number + ): Promise { const provider = connection instanceof ethers.providers.JsonRpcProvider ? connection @@ -35,7 +39,9 @@ export class XypeResolver { // add network support check const xypeRegistry = new Contract( - XYPE_REGISTRY_ADDRESS[Number((await provider.getNetwork()).chainId)], + XYPE_REGISTRY_ADDRESS[ + chainId ? chainId : Number((await provider.getNetwork()).chainId) + ], REGISTRY_ABI, provider ); diff --git a/test/resolver.spec.ts b/test/resolver.spec.ts index 53ee335..73ce379 100644 --- a/test/resolver.spec.ts +++ b/test/resolver.spec.ts @@ -20,6 +20,12 @@ describe('XypeResolver', () => { expect((xypeResolver = await XypeResolver.init(provider))); expect((xypeResolver = await XypeResolver.init(PUBLIC_RPC_NODES[0]))); + expect( + (xypeResolver = await XypeResolver.init( + provider, + Number((await provider.getNetwork()).chainId) + )) + ); }); }); @@ -47,9 +53,9 @@ describe('XypeResolver', () => { describe('lookupAddress', () => { it('lookupAddress: 0xb305c1f2200a17E0502416B1746aB88C9B5C449f - success resolution', async () => { const addr = await xypeResolver.lookupAddress( - '0xc46DA945f66EBe2E55f49EF9e401ec9eA7C3eC61' + '0xcefc9fcc056a8c888698b50fd88453cc66c6abc6' ); - expect(addr).toEqual('qwery.sxt'); + expect(addr).toEqual('abc55.trustyfy'); }); it('lookupAddress: 0xf2EA5Fd6538EAb3B0466f1b1A447C742d8b30eFe - expired', async () => {