Skip to content

Commit 24e4aed

Browse files
authored
Revert "feat: add signer in did registrar and schema manager" (#14)
* Revert "feat: add signer in did registrar and schema manager (#12)" This reverts commit 029cb6b. Signed-off-by: Sai Ranjit Tummalapalli <sairanjit.tummalapalli@ayanworks.com> * docs(changeset): remove the signer and keep signing key as before Signed-off-by: Sai Ranjit Tummalapalli <sairanjit.tummalapalli@ayanworks.com> --------- Signed-off-by: Sai Ranjit Tummalapalli <sairanjit.tummalapalli@ayanworks.com>
1 parent 89cd375 commit 24e4aed

14 files changed

Lines changed: 25 additions & 318 deletions

File tree

.changeset/sour-falcons-kick.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@ayanworks/polygon-schema-manager": minor
3+
"@ayanworks/polygon-did-registrar": minor
4+
---
5+
6+
remove the signer and keep signing key as before
Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
export { KMSSigner } from './kms'
21
export {
32
PolygonDID,
43
type PolygonDidInitOptions,
54
type PolygonDidRegisterOptions,
65
} from './registrar'
7-
export type { GenericSigner } from './signer'
8-
export { SignerError } from './signer'

packages/did-registrar/src/kms.ts

Lines changed: 0 additions & 87 deletions
This file was deleted.

packages/did-registrar/src/registrar.ts

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,14 @@ import { getResolver } from '@ayanworks/polygon-did-resolver'
44
import { Base58 } from '@ethersproject/basex'
55
import { computePublicKey } from '@ethersproject/signing-key'
66
import { Resolver } from 'did-resolver'
7-
import { Contract, computeAddress, JsonRpcProvider, Network, Wallet } from 'ethers'
7+
import { Contract, computeAddress, JsonRpcProvider, Network, SigningKey, Wallet } from 'ethers'
88
import { v4 as uuidv4 } from 'uuid'
9-
import { KMSSigner } from './kms'
10-
import type { GenericSigner } from './signer'
119
import { parseDid, validateDid, validateResourcePayload } from './utils'
1210

1311
export type PolygonDidInitOptions = {
1412
contractAddress: string
1513
rpcUrl: string
16-
/**
17-
* Generic signer interface for signing operations.
18-
* it supports external signers like KMS, HSM, etc.
19-
*/
20-
signer: GenericSigner
21-
/**
22-
* Signer address to be used for transaction
23-
*/
24-
address: string
14+
signingKey: SigningKey
2515
}
2616

2717
export type DidDocument = Record<string, unknown>
@@ -61,13 +51,13 @@ export class PolygonDID {
6151
private rpcUrl: string
6252
public resolver: Resolver
6353

64-
public constructor({ contractAddress, rpcUrl, signer, address }: PolygonDidInitOptions) {
54+
public constructor({ contractAddress, rpcUrl, signingKey }: PolygonDidInitOptions) {
6555
this.resolver = new Resolver(getResolver())
6656
this.contractAddress = contractAddress
6757
this.rpcUrl = rpcUrl
6858
const provider = new JsonRpcProvider(rpcUrl)
69-
const kmsSigner = new KMSSigner(provider, signer, address)
70-
this.registry = new Contract(contractAddress, DidRegistryContract.abi, kmsSigner)
59+
const wallet = new Wallet(signingKey, provider)
60+
this.registry = new Contract(contractAddress, DidRegistryContract.abi, wallet)
7161
}
7262

7363
static createKeyPair(network: string) {

packages/did-registrar/src/signer.ts

Lines changed: 0 additions & 25 deletions
This file was deleted.

packages/did-registrar/tests/fixtures/test.data.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export const testResourceId = 'b5db4a5f-2f97-4449-a755-9af0b43119ae' // Add your
2929
export const testDidDetails = {
3030
address: '0x4487cB2567De2Ca6dc5F79A7f6ae944522C4b698',
3131
did: 'did:polygon:testnet:0x4487cB2567De2Ca6dc5F79A7f6ae944522C4b698',
32-
privateKey: '0x6320c5bcc5edfb1f3324b94a67c0e69916d828d6374ddb1dfeae92c27e3098de', //test key
32+
privateKey: '6320c5bcc5edfb1f3324b94a67c0e69916d828d6374ddb1dfeae92c27e3098de', //test key
3333
publicKeyBase58: '7Lnm1Zi2K75KVgHPrHADCpfa9cLAtRRocBgLsFVLw5NRPUgoLBBv1Se8ttjx4P7fXfNS5gazJmKqohNmwEqx8VjDYfPvw',
3434
}
3535

packages/did-registrar/tests/index.test.ts

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import { computeAddress, SigningKey } from 'ethers'
1+
import { SigningKey } from 'ethers'
22
import { assert, beforeAll, describe, it } from 'vitest'
33
import { PolygonDID } from '../src/registrar'
4-
import type { GenericSigner } from '../src/signer'
54
import { testContractDetails, testDidDetails } from './fixtures/test.data'
65
import { buildTestDidDoc } from './utils/array'
76

@@ -35,25 +34,10 @@ describe('Polygon-did-registrar', () => {
3534
polygonDID = keyPair.did
3635
}
3736

38-
// Create GenericSigner from private key
39-
const signingKey = new SigningKey(keyPair.privateKey)
40-
const address = computeAddress(signingKey.publicKey)
41-
42-
const signer: GenericSigner = {
43-
async sign(data: Uint8Array): Promise<string> {
44-
// Use the sign method from SigningKey
45-
const signature = signingKey.sign(data)
46-
// Convert signature components to hex string (0x + r + s + v)
47-
const v = signature.v < 27 ? signature.v + 27 : signature.v
48-
return signature.r + signature.s.slice(2) + v.toString(16).padStart(2, '0')
49-
},
50-
}
51-
5237
polygonDidRegistrar = new PolygonDID({
5338
contractAddress: CONTRACT_ADDRESS,
5439
rpcUrl: NETWORK_URL,
55-
signer,
56-
address,
40+
signingKey: new SigningKey(`0x${keyPair.privateKey}`),
5741
})
5842
})
5943

packages/did-registrar/tests/polygon.test.ts

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import { computeAddress, SigningKey } from 'ethers'
1+
import { SigningKey } from 'ethers'
22
import { assert, beforeAll, describe, it } from 'vitest'
33
import { PolygonDID } from '../src/registrar'
4-
import type { GenericSigner } from '../src/signer'
54
import { resourceJson, testContractDetails, testDidDetails, updateDidDocument } from './fixtures/test.data'
65
import { arrayHasKeys, buildTestDidDoc } from './utils/array'
76

@@ -35,25 +34,10 @@ describe('Registrar', () => {
3534
polygonDID = keyPair.did
3635
}
3736

38-
// Create GenericSigner from private key
39-
const signingKey = new SigningKey(keyPair.privateKey)
40-
const address = computeAddress(signingKey.publicKey)
41-
42-
const signer: GenericSigner = {
43-
async sign(data: Uint8Array): Promise<string> {
44-
// Use the sign method from SigningKey
45-
const signature = signingKey.sign(data)
46-
// Convert signature components to hex string (0x + r + s + v)
47-
const v = signature.v < 27 ? signature.v + 27 : signature.v
48-
return signature.r + signature.s.slice(2) + v.toString(16).padStart(2, '0')
49-
},
50-
}
51-
5237
polygonDidRegistrar = new PolygonDID({
5338
contractAddress: CONTRACT_ADDRESS,
5439
rpcUrl: NETWORK_URL,
55-
signer,
56-
address,
40+
signingKey: new SigningKey(`0x${keyPair.privateKey}`),
5741
})
5842
await new Promise((r) => setTimeout(r, 5000))
5943
})
Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
1-
export { KMSSigner } from './kms'
21
export * from './schema-manager'
3-
export type { GenericSigner } from './signer'
4-
export { SignerError } from './signer'

packages/schema-manager/src/kms.ts

Lines changed: 0 additions & 87 deletions
This file was deleted.

0 commit comments

Comments
 (0)