Skip to content

Commit

Permalink
feat: updated testnet contract address
Browse files Browse the repository at this point in the history
Signed-off-by: tipusinghaw <[email protected]>
  • Loading branch information
tipusinghaw committed Jan 9, 2024
1 parent a8494cf commit deceb82
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
8 changes: 4 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
@@ -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',
Expand Down
12 changes: 7 additions & 5 deletions src/resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,13 @@ import { parseDid, validateDid } from './utils/did'
*/
export function getResolver(): Record<string, DIDResolver> {
async function resolve(did: string): Promise<DIDResolutionResult> {
const didDocumentMetadata = {}
try {
const isValidDid = validateDid(did)
if (!isValidDid) {
throw new Error('invalid did provided')
}

const parsedDid = parseDid(did)

const provider = new providers.JsonRpcProvider(parsedDid.networkUrl)
const registry = new Contract(
parsedDid.contractAddress,
Expand All @@ -31,13 +29,17 @@ export function getResolver(): Record<string, DIDResolver> {
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) {
Expand Down
4 changes: 2 additions & 2 deletions tests/fixtures/test.data.ts
Original file line number Diff line number Diff line change
@@ -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 = [
{
Expand Down

0 comments on commit deceb82

Please sign in to comment.