From deceb826039de52893dea8417e545956bb828a8d Mon Sep 17 00:00:00 2001 From: tipusinghaw Date: Tue, 9 Jan 2024 16:51:39 +0530 Subject: [PATCH] feat: updated testnet contract address Signed-off-by: tipusinghaw --- package.json | 2 +- pnpm-lock.yaml | 8 ++++---- src/config.ts | 2 +- src/resolver.ts | 12 +++++++----- tests/fixtures/test.data.ts | 4 ++-- 5 files changed, 15 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index 8631130..8cc74ec 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "release": "release-it" }, "dependencies": { - "@ayanworks/polygon-did-registry-contract": "2.0.1-alpha.1", + "@ayanworks/polygon-did-registry-contract": "2.0.1-alpha.3", "did-resolver": "^4.1.0", "ethers": "^5.1.0" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 503f060..edbbab9 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -6,8 +6,8 @@ settings: dependencies: '@ayanworks/polygon-did-registry-contract': - specifier: 2.0.1-alpha.1 - version: 2.0.1-alpha.1 + specifier: 2.0.1-alpha.3 + version: 2.0.1-alpha.3 did-resolver: specifier: ^4.1.0 version: 4.1.0 @@ -34,8 +34,8 @@ devDependencies: packages: - /@ayanworks/polygon-did-registry-contract@2.0.1-alpha.1: - resolution: {integrity: sha512-KxDgk/ql/CClSeB3+PXOBoHjSb4yPzTL0mQYb5T8IPWFQxSqUFD7HhU5XP7KWkVy+eZiGCeMEzmiVW7RRrjZVQ==} + /@ayanworks/polygon-did-registry-contract@2.0.1-alpha.3: + resolution: {integrity: sha512-8FZZVAmzXZn0pjZasuxdRblL0obK91JoaoXzpM4oZ7hD5VRUbiWf7BTh17WsWc6Oaf6XtafT4csuBo11fZiUoQ==} dev: false /@babel/code-frame@7.22.10: diff --git a/src/config.ts b/src/config.ts index 1992edf..69b1676 100644 --- a/src/config.ts +++ b/src/config.ts @@ -1,7 +1,7 @@ export const networkConfig = { testnet: { URL: 'https://rpc-mumbai.maticvigil.com/', - CONTRACT_ADDRESS: '0x8B335A167DA81CCef19C53eE629cf2F6291F2255', + CONTRACT_ADDRESS: '0x12513116875BB3E4F098Ce74624739Ee51bAf023', }, mainnet: { URL: 'https://polygon-rpc.com', diff --git a/src/resolver.ts b/src/resolver.ts index 60effc6..c099dc2 100644 --- a/src/resolver.ts +++ b/src/resolver.ts @@ -10,7 +10,6 @@ import { parseDid, validateDid } from './utils/did' */ export function getResolver(): Record { async function resolve(did: string): Promise { - const didDocumentMetadata = {} try { const isValidDid = validateDid(did) if (!isValidDid) { @@ -18,7 +17,6 @@ export function getResolver(): Record { } const parsedDid = parseDid(did) - const provider = new providers.JsonRpcProvider(parsedDid.networkUrl) const registry = new Contract( parsedDid.contractAddress, @@ -31,13 +29,17 @@ export function getResolver(): Record { parsedDid.didAddress, ) - if (!didDocument) { + if (!didDocument[0]) { throw new Error(`The DID document for the given DID was not found!`) } - // TODO: return only the did document instead of array + return { didDocument: JSON.parse(didDocument[0]), - didDocumentMetadata, + didDocumentMetadata: { + linkedResourceMetadata: didDocument[1].map((element: string) => { + return JSON.parse(element) + }), + }, didResolutionMetadata: { contentType: 'application/did+ld+json' }, } } catch (error) { diff --git a/tests/fixtures/test.data.ts b/tests/fixtures/test.data.ts index 30748c2..73921f5 100644 --- a/tests/fixtures/test.data.ts +++ b/tests/fixtures/test.data.ts @@ -1,9 +1,9 @@ export const testDid = - 'did:polygon:testnet:0x794b781493AeD65b9ceBD680716fec257e118993' + 'did:polygon:testnet:0x13cd23928Ae515b86592C630f56C138aE4c7B79a' export const url = 'https://rpc-mumbai.maticvigil.com/' -export const contractAddress = '0x8B335A167DA81CCef19C53eE629cf2F6291F2255' +export const contractAddress = '0x12513116875BB3E4F098Ce74624739Ee51bAf023' export const DIDS = [ {