@ayanworks/polygon-did-registry-contract 2.0.1-alpha.1 → 2.0.1-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/compile.ts CHANGED
@@ -34,9 +34,7 @@ function convertToHex(inputString: string) {
34
34
  return hex
35
35
  }
36
36
 
37
- const sourceHash = ethers.utils.sha256(
38
- '0x' + convertToHex(JSON.stringify(sources)),
39
- )
37
+ const sourceHash = ethers.sha256('0x' + convertToHex(JSON.stringify(sources)))
40
38
 
41
39
  console.log('\n'.repeat(process.stdout.rows))
42
40
 
@@ -1,5 +1,5 @@
1
- const Migrations = artifacts.require("Migrations");
1
+ const Migrations = artifacts.require('Migrations')
2
2
 
3
3
  module.exports = function (deployer) {
4
- deployer.deploy(Migrations);
5
- };
4
+ deployer.deploy(Migrations)
5
+ }
@@ -1,8 +1,8 @@
1
- const { deployProxy } = require('@openzeppelin/truffle-upgrades');
1
+ const { deployProxy } = require('@openzeppelin/truffle-upgrades')
2
2
 
3
- const PolygonDidRegistry = artifacts.require("PolygonDidRegistry");
3
+ const PolygonDidRegistry = artifacts.require('PolygonDidRegistry')
4
4
 
5
5
  module.exports = async function (deployer) {
6
- const instance = await deployProxy(PolygonDidRegistry, { deployer });
7
- console.log('Deployed', instance.address);
8
- };
6
+ const instance = await deployProxy(PolygonDidRegistry, { deployer })
7
+ console.log('Deployed', instance.address)
8
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ayanworks/polygon-did-registry-contract",
3
- "version": "2.0.1-alpha.1",
3
+ "version": "2.0.1-alpha.2",
4
4
  "description": "Smart Contract to register DID on Polygon",
5
5
  "main": "build/index.js",
6
6
  "directories": {
@@ -11,13 +11,13 @@
11
11
  "test": "node compile.js && mocha --timeout 30000",
12
12
  "clean": "rm -rf build",
13
13
  "clean:deps": "pnpm clean && rm -rf node_modules",
14
- "build": "pnpm build:sol && tsc",
14
+ "build": "pnpm clean && pnpm build:sol && tsc",
15
15
  "build:sol": "node --require ts-node/register ./compile.ts",
16
- "prettier": "prettier --ignore-path .gitignore .",
16
+ "prettier": "prettier --ignore-path .prettierignore .",
17
17
  "check-format": "pnpm prettier --list-different",
18
18
  "check-types": "pnpm build --noEmit",
19
19
  "format": "pnpm prettier --write",
20
- "release": "release-it"
20
+ "release": "git status && release-it"
21
21
  },
22
22
  "license": "MIT",
23
23
  "devDependencies": {
@@ -27,12 +27,12 @@
27
27
  "@types/node": "^18.17.0",
28
28
  "dotenv": "^16.0.2",
29
29
  "eslint": "^8.23.1",
30
- "ethers": "^5.6.9",
30
+ "ethers": "^6.9.0",
31
31
  "fs-extra": "^11.1.1",
32
32
  "ganache-cli": "6.12.2",
33
33
  "mocha": "^7.0.0",
34
34
  "prettier": "^3.0.2",
35
- "release-it": "^16.1.5",
35
+ "release-it": "^16.3.0",
36
36
  "solc": "^0.8.21",
37
37
  "truffle": "^5.5.20",
38
38
  "ts-node": "^10.9.1",
package/sst-config.json CHANGED
@@ -1 +1,3 @@
1
- {"sourceHash":"0xd34bb18b8a1a061e975b0850a1887bacdf0b8891d51e51399492bb038c05ff96"}
1
+ {
2
+ "sourceHash": "0xd34bb18b8a1a061e975b0850a1887bacdf0b8891d51e51399492bb038c05ff96"
3
+ }
@@ -1,15 +1,15 @@
1
- const ethers = require("ethers")
2
- const ganache = require("ganache-cli")
3
- const assert = require("assert")
4
- const { deployProxy } = require("@openzeppelin/truffle-upgrades")
5
- const PolygonDidRegistry = artifacts.require("PolygonDidRegistry")
1
+ const ethers = require('ethers')
2
+ const ganache = require('ganache-cli')
3
+ const assert = require('assert')
4
+ const { deployProxy } = require('@openzeppelin/truffle-upgrades')
5
+ const PolygonDidRegistry = artifacts.require('PolygonDidRegistry')
6
6
 
7
7
  // Library initialization that will talk with Blockchain
8
8
  const provider = new ethers.providers.Web3Provider(
9
- ganache.provider({ gasLimit: 8000000 })
9
+ ganache.provider({ gasLimit: 8000000 }),
10
10
  )
11
11
  // Initializing the build files
12
- const PolygonDIDRegistryJSON = require("../build/contracts/PolygonDidRegistry.json")
12
+ const PolygonDIDRegistryJSON = require('../build/contracts/PolygonDidRegistry.json')
13
13
 
14
14
  let accounts,
15
15
  PolygonDIDRegistryInstance,
@@ -19,39 +19,39 @@ let accounts,
19
19
 
20
20
  // Describing the 1st Test
21
21
  // This will setup Ganache with some test address
22
- describe("Ganache Setup", async () => {
23
- it("Ganache setup with Test Accounts", async () => {
22
+ describe('Ganache Setup', async () => {
23
+ it('Ganache setup with Test Accounts', async () => {
24
24
  // List of accounts are fetched here
25
25
  accounts = await provider.listAccounts()
26
26
 
27
27
  // We will check that atleast 2 accounts are loaded
28
- assert.ok(accounts.length >= 1, "2 Accounts are present minimum")
28
+ assert.ok(accounts.length >= 1, '2 Accounts are present minimum')
29
29
  })
30
30
  })
31
31
 
32
32
  // Upgradable with Proxy
33
33
  // Deployment Testing 1.0
34
- describe("Setting up the Upgradable Smart Contract", async () => {
35
- describe("Setting up the contract", async () => {
36
- it("Should deploy contract with Proxy, with no parameters/Constructor", async () => {
34
+ describe('Setting up the Upgradable Smart Contract', async () => {
35
+ describe('Setting up the contract', async () => {
36
+ it('Should deploy contract with Proxy, with no parameters/Constructor', async () => {
37
37
  PolygonUpgradableInstance = await deployProxy(PolygonDidRegistry)
38
38
  PolygonUpgradableInstance_test = new ethers.Contract(
39
39
  PolygonUpgradableInstance.address,
40
40
  PolygonDIDRegistryJSON.abi,
41
- provider.getSigner(accounts[3])
41
+ provider.getSigner(accounts[3]),
42
42
  )
43
43
  assert.ok(
44
44
  PolygonUpgradableInstance.address,
45
- "Upgradeable contract is deployed"
45
+ 'Upgradeable contract is deployed',
46
46
  )
47
47
  })
48
48
  })
49
49
 
50
50
  //Check Create Function test 1.1
51
- describe("Checking the Create function using Upgradeable Contract", async () => {
52
- it("This should store the DID doc on Upgradable Contract and will read and check if the value stored is correct", async () => {
51
+ describe('Checking the Create function using Upgradeable Contract', async () => {
52
+ it('This should store the DID doc on Upgradable Contract and will read and check if the value stored is correct', async () => {
53
53
  // This will send the value to local ganache blockchain
54
- const did = "0x2f65b747440deaf596892dfc7965040be8b99100"
54
+ const did = '0x2f65b747440deaf596892dfc7965040be8b99100'
55
55
  const doc =
56
56
  '{"@context":"https://w3id.org/did/v1","id":"did:polygon:0x2f65b747440deaf596892dfc7965040be8b99100","verificationMethod":[{"id":"did:polygon:0x2f65b747440deaf596892dfc7965040be8b99100","type":"EcdsaSecp256k1VerificationKey2019","controller":"did:polygon:0x2f65b747440deaf596892dfc7965040be8b99100","publicKeyBase58":"NDaEdTguJV39Ns8BZkxQ3XR6GUinZAJfVoyEMkK9fP7XQmpSkT3UsLHB52cFpDqoM6m4Hevtba8pkmjvEG3Ur7ji"}]}'
57
57
  const tx = await PolygonUpgradableInstance.createDID(did, doc)
@@ -60,26 +60,26 @@ describe("Setting up the Upgradable Smart Contract", async () => {
60
60
  const currentValue = await PolygonUpgradableInstance.getDID(did)
61
61
 
62
62
  // Comparing the set value to confirm
63
- assert.equal(currentValue, doc, "value set must be able to get")
63
+ assert.equal(currentValue, doc, 'value set must be able to get')
64
64
 
65
- assert.notEqual(currentValue, null, "value should not be empty")
65
+ assert.notEqual(currentValue, null, 'value should not be empty')
66
66
  })
67
67
  })
68
68
 
69
69
  //Describing the 1.2 Test Case
70
- describe("Checking the getTotalNumberOfDIDs Function", async () => {
71
- it("This should get correct number of DIDs registered", async () => {
70
+ describe('Checking the getTotalNumberOfDIDs Function', async () => {
71
+ it('This should get correct number of DIDs registered', async () => {
72
72
  const currentValue =
73
73
  await PolygonUpgradableInstance.getTotalNumberOfDIDs()
74
- assert.equal(currentValue, 1, "value should be matching")
74
+ assert.equal(currentValue, 1, 'value should be matching')
75
75
  })
76
76
  })
77
77
 
78
78
  // Describing the 1.3 Test case
79
- describe("Checking the Update function in Upgradable Contract", async () => {
80
- it("This should update the DID doc on Upgradable Contract and will read and check if the value stored is correct", async () => {
79
+ describe('Checking the Update function in Upgradable Contract', async () => {
80
+ it('This should update the DID doc on Upgradable Contract and will read and check if the value stored is correct', async () => {
81
81
  // This will send the value to local ganache blockchain
82
- const did = "0x2f65b747440deaf596892dfc7965040be8b99100"
82
+ const did = '0x2f65b747440deaf596892dfc7965040be8b99100'
83
83
  //changed the controller
84
84
  const doc =
85
85
  '{"@context":"https://w3id.org/did/v1","id":"did:polygon:0x2f65b747440deaf596892dfc7965040be8b99100","verificationMethod":[{"id":"did:polygon:0x2f65b747440deaf596892dfc7965040be8b99100","type":"EcdsaSecp256k1VerificationKey2019","controller":"did:polygon:0x2f65b747440deaf596892dfc7965040be8c66666","publicKeyBase58":"NDaEdTguJV39Ns8BZkxQ3XR6GUinZAJfVoyEMkK9fP7XQmpSkT3UsLHB52cFpDqoM6m4Hevtba8pkmjvEG3Ur7ji"}]}'
@@ -89,45 +89,45 @@ describe("Setting up the Upgradable Smart Contract", async () => {
89
89
  const currentValue = await PolygonUpgradableInstance.getDID(did)
90
90
 
91
91
  // Comparing the set value to confirm
92
- assert.equal(currentValue, doc, "value set must be able to get")
92
+ assert.equal(currentValue, doc, 'value set must be able to get')
93
93
  })
94
94
  })
95
95
 
96
96
  //Describing test 1.4 to check if test fails if we update with different controller
97
- describe("Checking update with wrong controller", async () => {
98
- it("This should not update DID doc ", async () => {
99
- const did = "0x2f65b747440deaf596892dfc7965040be8b99100"
97
+ describe('Checking update with wrong controller', async () => {
98
+ it('This should not update DID doc ', async () => {
99
+ const did = '0x2f65b747440deaf596892dfc7965040be8b99100'
100
100
  const doc =
101
101
  '{"@context":"https://w3id.org/did/v1","id":"did:polygon:0x2f65b747440deaf596892dfc7965040be8b99100","verificationMethod":[{"id":"did:polygon:0x2f65b747440deaf596892dfc7965040be8b99100","type":"EcdsaSecp256k1VerificationKey2019","controller":"did:polygon:0x2f65b747440deaf596892dfc7965040be8c66666","publicKeyBase58":"NDaEdTguJV39Ns8BZkxQ3XR6GUinZAJfVoyEMkK9fP7XQmpSkT3UsLHB52cFpDqoM6m4Hevtba8pkmjvEG3Ur7ji"}]}'
102
102
  try {
103
103
  assert.ifError(
104
104
  //sending transaction using different controller
105
- await PolygonUpgradableInstance_test.functions.updateDID(did, doc)
105
+ await PolygonUpgradableInstance_test.functions.updateDID(did, doc),
106
106
  )
107
107
  } catch (error) {}
108
108
  })
109
109
  })
110
110
 
111
111
  // Describing the 1.5 Test case
112
- describe("Checking the Delete function in Upgradable Contract", async () => {
113
- it("This should delete the DID doc on Upgradable Contract and will read and check if the value is now an empty string", async () => {
112
+ describe('Checking the Delete function in Upgradable Contract', async () => {
113
+ it('This should delete the DID doc on Upgradable Contract and will read and check if the value is now an empty string', async () => {
114
114
  // This will send the value to local ganache blockchain
115
- const did = "0x2f65b747440deaf596892dfc7965040be8b99100"
115
+ const did = '0x2f65b747440deaf596892dfc7965040be8b99100'
116
116
  const tx = await PolygonUpgradableInstance.deleteDID(did)
117
117
 
118
118
  // Getting the set value in ganache blockchain
119
119
  const currentValue = await PolygonUpgradableInstance.getDID(did)
120
120
 
121
121
  // Comparing the set value to confirm
122
- assert.equal(currentValue, "", "value should be matching")
122
+ assert.equal(currentValue, '', 'value should be matching')
123
123
  })
124
124
  })
125
125
 
126
126
  // Describing the 1.6 Test case
127
- describe("Checking the Create function in Upgradable Contract", async () => {
128
- it("This should store the DID doc on Upgradable Contract and will read and check if the value stored is not null", async () => {
127
+ describe('Checking the Create function in Upgradable Contract', async () => {
128
+ it('This should store the DID doc on Upgradable Contract and will read and check if the value stored is not null', async () => {
129
129
  // This will send the value to local ganache blockchain
130
- const did = "0x54ec7be8b24f7139f870f277cf99c527ff43892b"
130
+ const did = '0x54ec7be8b24f7139f870f277cf99c527ff43892b'
131
131
  const doc =
132
132
  '{"@context":"https://w3id.org/did/v1","id":"did:polygon:0x54ec7be8b24f7139f870f277cf99c527ff43892b","verificationMethod":[{"id":"did:polygon:0x54ec7be8b24f7139f870f277cf99c527ff43892b","type":"EcdsaSecp256k1VerificationKey2019","controller":"did:polygon:0x54ec7be8b24f7139f870f277cf99c527ff43892b","publicKeyBase58":"RwHysxjkzFdJDqi2irHRVRFHX9uUj5aVAXVoufnk5PDA4qcn1ejJMgGhqCsFdQqXRCTdi4TbEQFJjDUAdi2JvYmH"}]}'
133
133
  const doctest =
@@ -139,15 +139,15 @@ describe("Setting up the Upgradable Smart Contract", async () => {
139
139
 
140
140
  // Checking value is not null
141
141
 
142
- assert.notEqual(currentValue, "", "value should not match")
142
+ assert.notEqual(currentValue, '', 'value should not match')
143
143
  })
144
144
  })
145
145
 
146
146
  // Describing the 1.7 Test case
147
- describe("Checking the Update function in Upgradable Contract", async () => {
148
- it("This should update the DID doc on Upgradable Contract and will read and check if the value stored has changed", async () => {
147
+ describe('Checking the Update function in Upgradable Contract', async () => {
148
+ it('This should update the DID doc on Upgradable Contract and will read and check if the value stored has changed', async () => {
149
149
  // This will send the value to local ganache blockchain
150
- const did = "0x54ec7be8b24f7139f870f277cf99c527ff43892b"
150
+ const did = '0x54ec7be8b24f7139f870f277cf99c527ff43892b'
151
151
  //changed the controller
152
152
  const doc =
153
153
  '{"@context":"https://w3id.org/did/v1","id":"did:polygon:0x2f65b747440deaf596892dfc7965040be8b99100","verificationMethod":[{"id":"did:polygon:0x2f65b747440deaf596892dfc7965040be8b99100","type":"EcdsaSecp256k1VerificationKey2019","controller":"did:polygon:0x2f65b747440deaf596892dfc7965040be8c66666","publicKeyBase58":"NDaEdTguJV39Ns8BZkxQ3XR6GUinZAJfVoyEMkK9fP7XQmpSkT3UsLHB52cFpDqoM6m4Hevtba8pkmjvEG3Ur7ji"}]}'
@@ -159,15 +159,15 @@ describe("Setting up the Upgradable Smart Contract", async () => {
159
159
  const currentValue = await PolygonUpgradableInstance.getDID(did)
160
160
 
161
161
  // Comparing the set value to confirm
162
- assert.notEqual(currentValue, docoriginal, "value should not match")
162
+ assert.notEqual(currentValue, docoriginal, 'value should not match')
163
163
  })
164
164
  })
165
165
 
166
166
  // Describing the 1.8 Test Case
167
- describe("Checking the Delete function in Upgradable Contract", async () => {
168
- it("This should delete the DID doc on Upgradable Contract and will read and check if the value is now not equal to the updated doc", async () => {
167
+ describe('Checking the Delete function in Upgradable Contract', async () => {
168
+ it('This should delete the DID doc on Upgradable Contract and will read and check if the value is now not equal to the updated doc', async () => {
169
169
  // This will send the value to local ganache blockchain
170
- const did = "0x54ec7be8b24f7139f870f277cf99c527ff43892b"
170
+ const did = '0x54ec7be8b24f7139f870f277cf99c527ff43892b'
171
171
  const doc =
172
172
  '{"@context":"https://w3id.org/did/v1","id":"did:polygon:0x2f65b747440deaf596892dfc7965040be8b99100","verificationMethod":[{"id":"did:polygon:0x2f65b747440deaf596892dfc7965040be8b99100","type":"EcdsaSecp256k1VerificationKey2019","controller":"did:polygon:0x2f65b747440deaf596892dfc7965040be8c66666","publicKeyBase58":"NDaEdTguJV39Ns8BZkxQ3XR6GUinZAJfVoyEMkK9fP7XQmpSkT3UsLHB52cFpDqoM6m4Hevtba8pkmjvEG3Ur7ji"}]}'
173
173
  const tx = await PolygonUpgradableInstance.deleteDID(did)
@@ -176,43 +176,43 @@ describe("Setting up the Upgradable Smart Contract", async () => {
176
176
  const currentValue = await PolygonUpgradableInstance.getDID(did)
177
177
 
178
178
  // Comparing the set value to confirm
179
- assert.notEqual(currentValue, doc, "value should not be matching")
179
+ assert.notEqual(currentValue, doc, 'value should not be matching')
180
180
  })
181
181
  })
182
182
 
183
183
  //Describing the 1.9 Test Case
184
- describe("Checking the getTotalNumberOfDIDs Function", async () => {
185
- it("This should get correct number of DIDs registered", async () => {
184
+ describe('Checking the getTotalNumberOfDIDs Function', async () => {
185
+ it('This should get correct number of DIDs registered', async () => {
186
186
  const totalValue = await PolygonUpgradableInstance.getTotalNumberOfDIDs()
187
187
  const deltedValue =
188
188
  await PolygonUpgradableInstance.getTotalNumberOfDeletedDIDs()
189
189
  const currentValue = totalValue - deltedValue
190
- assert.equal(currentValue, 0, "value should be matching")
190
+ assert.equal(currentValue, 0, 'value should be matching')
191
191
  })
192
192
  })
193
193
 
194
194
  //Describing the 1.10 Test Case
195
- describe("Checking the Transafer Ownership Function", async () => {
196
- it("This should transfer ownership of contract to another user", async () => {
195
+ describe('Checking the Transafer Ownership Function', async () => {
196
+ it('This should transfer ownership of contract to another user', async () => {
197
197
  const newOwner = accounts[5]
198
198
  const owner = await PolygonUpgradableInstance.getOwner()
199
199
  const tx = await PolygonUpgradableInstance.transferOwnership(newOwner)
200
200
  const currentOwner = await PolygonUpgradableInstance.getOwner()
201
201
 
202
- assert.notEqual(owner, currentOwner, "value should not be equal")
202
+ assert.notEqual(owner, currentOwner, 'value should not be equal')
203
203
  })
204
204
  })
205
205
 
206
206
  //Describing the 1.11 Test Case
207
- describe("Checking the Transafer Ownership Function", async () => {
208
- it("This should not transfer ownership of contract to another user since the transaction is being initiated by different owner", async () => {
207
+ describe('Checking the Transafer Ownership Function', async () => {
208
+ it('This should not transfer ownership of contract to another user since the transaction is being initiated by different owner', async () => {
209
209
  const newOwner = accounts[6]
210
210
  try {
211
211
  assert.ifError(
212
212
  //sending transaction using different controller
213
213
  await PolygonUpgradableInstance_test.functions.transferOwnership(
214
- newOwner
215
- )
214
+ newOwner,
215
+ ),
216
216
  )
217
217
  } catch (error) {}
218
218
  })
@@ -221,34 +221,34 @@ describe("Setting up the Upgradable Smart Contract", async () => {
221
221
 
222
222
  // basic Contract Testing
223
223
  // Deployment Testing 2.0
224
- describe("Basic Contract Testing", async () => {
224
+ describe('Basic Contract Testing', async () => {
225
225
  // Describing a SubTest case
226
- describe("Setting up the contract", async () => {
227
- it("This Deploys Polygon Smart contract from 1st account with no Parameters/Constructor", async () => {
226
+ describe('Setting up the contract', async () => {
227
+ it('This Deploys Polygon Smart contract from 1st account with no Parameters/Constructor', async () => {
228
228
  // Creating a contract factory for deploying contract.
229
229
  const PolygonDIDRegistry = new ethers.ContractFactory(
230
230
  PolygonDIDRegistryJSON.abi,
231
231
  PolygonDIDRegistryJSON.bytecode,
232
- provider.getSigner(accounts[2])
232
+ provider.getSigner(accounts[2]),
233
233
  )
234
234
  PolygonDIDRegistryInstance = await PolygonDIDRegistry.deploy()
235
235
  PolygonDIDRegistryInstance_test = new ethers.Contract(
236
236
  PolygonDIDRegistryInstance.address,
237
237
  PolygonDIDRegistryJSON.abi,
238
- provider.getSigner(accounts[3])
238
+ provider.getSigner(accounts[3]),
239
239
  )
240
240
  assert.ok(
241
241
  PolygonDIDRegistryInstance.address,
242
- "conract address should be present"
242
+ 'conract address should be present',
243
243
  )
244
244
  })
245
245
  })
246
246
 
247
247
  // Describing the 2.1 Test case
248
- describe("Checking the Create function in Contract", async () => {
249
- it("This should store the DID doc on Contract and will read and check if the value stored is correct", async () => {
248
+ describe('Checking the Create function in Contract', async () => {
249
+ it('This should store the DID doc on Contract and will read and check if the value stored is correct', async () => {
250
250
  // This will send the value to local ganache blockchain
251
- const did = "0x2f65b747440deaf596892dfc7965040be8b99100"
251
+ const did = '0x2f65b747440deaf596892dfc7965040be8b99100'
252
252
  const doc =
253
253
  '{"@context":"https://w3id.org/did/v1","id":"did:polygon:0x2f65b747440deaf596892dfc7965040be8b99100","verificationMethod":[{"id":"did:polygon:0x2f65b747440deaf596892dfc7965040be8b99100","type":"EcdsaSecp256k1VerificationKey2019","controller":"did:polygon:0x2f65b747440deaf596892dfc7965040be8b99100","publicKeyBase58":"NDaEdTguJV39Ns8BZkxQ3XR6GUinZAJfVoyEMkK9fP7XQmpSkT3UsLHB52cFpDqoM6m4Hevtba8pkmjvEG3Ur7ji"}]}'
254
254
  const tx = await PolygonDIDRegistryInstance.functions.createDID(did, doc)
@@ -257,22 +257,21 @@ describe("Basic Contract Testing", async () => {
257
257
  await tx.wait()
258
258
 
259
259
  // Getting the set value in ganache blockchain
260
- const currentValue = await PolygonDIDRegistryInstance.functions.getDID(
261
- did
262
- )
260
+ const currentValue =
261
+ await PolygonDIDRegistryInstance.functions.getDID(did)
263
262
 
264
263
  // Comparing the set value to confirm
265
- assert.equal(currentValue, doc, "value set must be able to get")
264
+ assert.equal(currentValue, doc, 'value set must be able to get')
266
265
 
267
- assert.notEqual(currentValue, null, "value should not be empty")
266
+ assert.notEqual(currentValue, null, 'value should not be empty')
268
267
  })
269
268
  })
270
269
 
271
270
  // Describing the 2.2 Test case
272
- describe("Checking the Update function in Contract", async () => {
273
- it("This should update the DID doc on Contract and will read and check if the value stored is correct", async () => {
271
+ describe('Checking the Update function in Contract', async () => {
272
+ it('This should update the DID doc on Contract and will read and check if the value stored is correct', async () => {
274
273
  // This will send the value to local ganache blockchain
275
- const did = "0x2f65b747440deaf596892dfc7965040be8b99100"
274
+ const did = '0x2f65b747440deaf596892dfc7965040be8b99100'
276
275
  //changed the controller
277
276
  const doc =
278
277
  '{"@context":"https://w3id.org/did/v1","id":"did:polygon:0x2f65b747440deaf596892dfc7965040be8b99100","verificationMethod":[{"id":"did:polygon:0x2f65b747440deaf596892dfc7965040be8b99100","type":"EcdsaSecp256k1VerificationKey2019","controller":"did:polygon:0x2f65b747440deaf596892dfc7965040be8c66666","publicKeyBase58":"NDaEdTguJV39Ns8BZkxQ3XR6GUinZAJfVoyEMkK9fP7XQmpSkT3UsLHB52cFpDqoM6m4Hevtba8pkmjvEG3Ur7ji"}]}'
@@ -282,54 +281,52 @@ describe("Basic Contract Testing", async () => {
282
281
  await tx.wait()
283
282
 
284
283
  // Getting the set value in ganache blockchain
285
- const currentValue = await PolygonDIDRegistryInstance.functions.getDID(
286
- did
287
- )
284
+ const currentValue =
285
+ await PolygonDIDRegistryInstance.functions.getDID(did)
288
286
 
289
287
  // Comparing the set value to confirm
290
- assert.equal(currentValue, doc, "value set must be able to get")
288
+ assert.equal(currentValue, doc, 'value set must be able to get')
291
289
  })
292
290
  })
293
291
  //Describing test 2.3 to check if test fails if we update with different controller
294
- describe("Checking update with wrong controller", async () => {
295
- it("This should not update DID doc ", async () => {
296
- const did = "0x2f65b747440deaf596892dfc7965040be8b99100"
292
+ describe('Checking update with wrong controller', async () => {
293
+ it('This should not update DID doc ', async () => {
294
+ const did = '0x2f65b747440deaf596892dfc7965040be8b99100'
297
295
  const doc =
298
296
  '{"@context":"https://w3id.org/did/v1","id":"did:polygon:0x2f65b747440deaf596892dfc7965040be8b99100","verificationMethod":[{"id":"did:polygon:0x2f65b747440deaf596892dfc7965040be8b99100","type":"EcdsaSecp256k1VerificationKey2019","controller":"did:polygon:0x2f65b747440deaf596892dfc7965040be8c66666","publicKeyBase58":"NDaEdTguJV39Ns8BZkxQ3XR6GUinZAJfVoyEMkK9fP7XQmpSkT3UsLHB52cFpDqoM6m4Hevtba8pkmjvEG3Ur7ji"}]}'
299
297
  try {
300
298
  assert.ifError(
301
299
  //sending transaction using different controller
302
- await PolygonDIDRegistryInstance_test.functions.updateDID(did, doc)
300
+ await PolygonDIDRegistryInstance_test.functions.updateDID(did, doc),
303
301
  )
304
302
  } catch (error) {}
305
303
  })
306
304
  })
307
305
 
308
306
  // Describing the 2.4 Test case
309
- describe("Checking the Delete function in Contract", async () => {
310
- it("This should delete the DID doc on Contract and will read and check if the value is now an empty string", async () => {
307
+ describe('Checking the Delete function in Contract', async () => {
308
+ it('This should delete the DID doc on Contract and will read and check if the value is now an empty string', async () => {
311
309
  // This will send the value to local ganache blockchain
312
- const did = "0x2f65b747440deaf596892dfc7965040be8b99100"
310
+ const did = '0x2f65b747440deaf596892dfc7965040be8b99100'
313
311
  const tx = await PolygonDIDRegistryInstance.functions.deleteDID(did)
314
312
 
315
313
  // Transfer confirmation
316
314
  await tx.wait()
317
315
 
318
316
  // Getting the set value in ganache blockchain
319
- const currentValue = await PolygonDIDRegistryInstance.functions.getDID(
320
- did
321
- )
317
+ const currentValue =
318
+ await PolygonDIDRegistryInstance.functions.getDID(did)
322
319
 
323
320
  // Comparing the set value to confirm
324
- assert.equal(currentValue, "", "value should be matching")
321
+ assert.equal(currentValue, '', 'value should be matching')
325
322
  })
326
323
  })
327
324
 
328
325
  // Describing the 2.5 Test case
329
- describe("Checking the Create function in Contract", async () => {
330
- it("This should store the DID doc on Contract and will read and check if the value stored is not null", async () => {
326
+ describe('Checking the Create function in Contract', async () => {
327
+ it('This should store the DID doc on Contract and will read and check if the value stored is not null', async () => {
331
328
  // This will send the value to local ganache blockchain
332
- const did = "0x54ec7be8b24f7139f870f277cf99c527ff43892b"
329
+ const did = '0x54ec7be8b24f7139f870f277cf99c527ff43892b'
333
330
  const doc =
334
331
  '{"@context":"https://w3id.org/did/v1","id":"did:polygon:0x54ec7be8b24f7139f870f277cf99c527ff43892b","verificationMethod":[{"id":"did:polygon:0x54ec7be8b24f7139f870f277cf99c527ff43892b","type":"EcdsaSecp256k1VerificationKey2019","controller":"did:polygon:0x54ec7be8b24f7139f870f277cf99c527ff43892b","publicKeyBase58":"RwHysxjkzFdJDqi2irHRVRFHX9uUj5aVAXVoufnk5PDA4qcn1ejJMgGhqCsFdQqXRCTdi4TbEQFJjDUAdi2JvYmH"}]}'
335
332
  const doctest =
@@ -340,21 +337,20 @@ describe("Basic Contract Testing", async () => {
340
337
  await tx.wait()
341
338
 
342
339
  // Getting the set value in ganache blockchain
343
- const currentValue = await PolygonDIDRegistryInstance.functions.getDID(
344
- did
345
- )
340
+ const currentValue =
341
+ await PolygonDIDRegistryInstance.functions.getDID(did)
346
342
 
347
343
  // Checking value is not null
348
344
 
349
- assert.notEqual(currentValue, doctest, "value should not match")
345
+ assert.notEqual(currentValue, doctest, 'value should not match')
350
346
  })
351
347
  })
352
348
 
353
349
  // Describing the 2.6 Test case
354
- describe("Checking the Update function in Contract", async () => {
355
- it("This should update the DID doc on Contract and will read and check if the value stored has changed", async () => {
350
+ describe('Checking the Update function in Contract', async () => {
351
+ it('This should update the DID doc on Contract and will read and check if the value stored has changed', async () => {
356
352
  // This will send the value to local ganache blockchain
357
- const did = "0x54ec7be8b24f7139f870f277cf99c527ff43892b"
353
+ const did = '0x54ec7be8b24f7139f870f277cf99c527ff43892b'
358
354
  //changed the controller
359
355
  const doc =
360
356
  '{"@context":"https://w3id.org/did/v1","id":"did:polygon:0x2f65b747440deaf596892dfc7965040be8b99100","verificationMethod":[{"id":"did:polygon:0x2f65b747440deaf596892dfc7965040be8b99100","type":"EcdsaSecp256k1VerificationKey2019","controller":"did:polygon:0x2f65b747440deaf596892dfc7965040be8c66666","publicKeyBase58":"NDaEdTguJV39Ns8BZkxQ3XR6GUinZAJfVoyEMkK9fP7XQmpSkT3UsLHB52cFpDqoM6m4Hevtba8pkmjvEG3Ur7ji"}]}'
@@ -366,20 +362,19 @@ describe("Basic Contract Testing", async () => {
366
362
  await tx.wait()
367
363
 
368
364
  // Getting the set value in ganache blockchain
369
- const currentValue = await PolygonDIDRegistryInstance.functions.getDID(
370
- did
371
- )
365
+ const currentValue =
366
+ await PolygonDIDRegistryInstance.functions.getDID(did)
372
367
 
373
368
  // Comparing the set value to confirm
374
- assert.notEqual(currentValue, docoriginal, "value should not match")
369
+ assert.notEqual(currentValue, docoriginal, 'value should not match')
375
370
  })
376
371
  })
377
372
 
378
373
  // Describing the 2.7 Test case
379
- describe("Checking the Delete function in Contract", async () => {
380
- it("This should delete the DID doc on Contract and will read and check if the value is now not equal to the updated doc", async () => {
374
+ describe('Checking the Delete function in Contract', async () => {
375
+ it('This should delete the DID doc on Contract and will read and check if the value is now not equal to the updated doc', async () => {
381
376
  // This will send the value to local ganache blockchain
382
- const did = "0x54ec7be8b24f7139f870f277cf99c527ff43892b"
377
+ const did = '0x54ec7be8b24f7139f870f277cf99c527ff43892b'
383
378
  const doc =
384
379
  '{"@context":"https://w3id.org/did/v1","id":"did:polygon:0x2f65b747440deaf596892dfc7965040be8b99100","verificationMethod":[{"id":"did:polygon:0x2f65b747440deaf596892dfc7965040be8b99100","type":"EcdsaSecp256k1VerificationKey2019","controller":"did:polygon:0x2f65b747440deaf596892dfc7965040be8c66666","publicKeyBase58":"NDaEdTguJV39Ns8BZkxQ3XR6GUinZAJfVoyEMkK9fP7XQmpSkT3UsLHB52cFpDqoM6m4Hevtba8pkmjvEG3Ur7ji"}]}'
385
380
  const tx = await PolygonDIDRegistryInstance.functions.deleteDID(did)
@@ -388,12 +383,11 @@ describe("Basic Contract Testing", async () => {
388
383
  await tx.wait()
389
384
 
390
385
  // Getting the set value in ganache blockchain
391
- const currentValue = await PolygonDIDRegistryInstance.functions.getDID(
392
- did
393
- )
386
+ const currentValue =
387
+ await PolygonDIDRegistryInstance.functions.getDID(did)
394
388
 
395
389
  // Comparing the set value to confirm
396
- assert.notEqual(currentValue, doc, "value should not be matching")
390
+ assert.notEqual(currentValue, doc, 'value should not be matching')
397
391
  })
398
392
  })
399
393
  })