@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/.github/workflows/pipeline.yaml +85 -0
- package/.prettierignore +5 -1
- package/.release-it.json +4 -2
- package/README.md +22 -23
- package/artifacts/PolygonDidRegistry.json +25308 -1
- package/build/artifacts/PolygonDidRegistry.json +25308 -1
- package/compile.ts +1 -3
- package/migrations/1_initial_migration.js +3 -3
- package/migrations/2_deploy_contract.js +5 -5
- package/package.json +6 -6
- package/sst-config.json +3 -1
- package/tests/polygon_did_registry_test.js +104 -110
- package/truffle-config.js +48 -49
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
name: 'Pipeline'
|
|
2
|
+
|
|
3
|
+
concurrency:
|
|
4
|
+
# Cancel previous runs that are not completed yet
|
|
5
|
+
group: ${{ github.workflow }}-${{ github.ref }}
|
|
6
|
+
cancel-in-progress: true
|
|
7
|
+
|
|
8
|
+
on:
|
|
9
|
+
push:
|
|
10
|
+
branches: ['main']
|
|
11
|
+
|
|
12
|
+
pull_request:
|
|
13
|
+
types: [opened, synchronize]
|
|
14
|
+
|
|
15
|
+
workflow_dispatch:
|
|
16
|
+
inputs:
|
|
17
|
+
release-type:
|
|
18
|
+
description: 'Type of release (major, minor, patch, alpha)'
|
|
19
|
+
required: true
|
|
20
|
+
default: alpha
|
|
21
|
+
type: choice
|
|
22
|
+
options:
|
|
23
|
+
- major
|
|
24
|
+
- minor
|
|
25
|
+
- patch
|
|
26
|
+
- alpha
|
|
27
|
+
|
|
28
|
+
jobs:
|
|
29
|
+
continuous-integration:
|
|
30
|
+
name: 'Continuous Integration'
|
|
31
|
+
runs-on: ubuntu-latest
|
|
32
|
+
|
|
33
|
+
steps:
|
|
34
|
+
- uses: actions/checkout@v3
|
|
35
|
+
|
|
36
|
+
- uses: pnpm/action-setup@v2
|
|
37
|
+
with:
|
|
38
|
+
version: 8.6.0
|
|
39
|
+
|
|
40
|
+
- name: Install dependencies
|
|
41
|
+
run: pnpm install
|
|
42
|
+
|
|
43
|
+
- name: Check formatting
|
|
44
|
+
run: pnpm check-format
|
|
45
|
+
|
|
46
|
+
continuous-deployment:
|
|
47
|
+
if: github.event_name == 'workflow_dispatch'
|
|
48
|
+
|
|
49
|
+
name: 'Continuous Deployment'
|
|
50
|
+
runs-on: ubuntu-latest
|
|
51
|
+
needs: ['continuous-integration']
|
|
52
|
+
|
|
53
|
+
steps:
|
|
54
|
+
- uses: actions/checkout@v3
|
|
55
|
+
with:
|
|
56
|
+
token: ${{ secrets.GH_TOKEN }}
|
|
57
|
+
|
|
58
|
+
- uses: pnpm/action-setup@v2
|
|
59
|
+
with:
|
|
60
|
+
version: 8.6.0
|
|
61
|
+
|
|
62
|
+
- name: Install dependencies
|
|
63
|
+
run: pnpm install
|
|
64
|
+
|
|
65
|
+
- name: Build
|
|
66
|
+
run: pnpm build
|
|
67
|
+
|
|
68
|
+
- name: Initialize the NPM config
|
|
69
|
+
env:
|
|
70
|
+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
71
|
+
run: npm config set //registry.npmjs.org/:_authToken $NPM_TOKEN
|
|
72
|
+
|
|
73
|
+
- name: Publish
|
|
74
|
+
env:
|
|
75
|
+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
76
|
+
run: |
|
|
77
|
+
echo ${{ inputs.release-type }}
|
|
78
|
+
git config --global user.email "amit.padmani@ayanworks.com"
|
|
79
|
+
git config --global user.name "Amit Padmani"
|
|
80
|
+
|
|
81
|
+
if [ ${{ inputs.release-type }} == 'alpha' ]; then
|
|
82
|
+
pnpm release --preRelease=${{ inputs.release-type }} --npm.tag=alpha
|
|
83
|
+
else
|
|
84
|
+
pnpm release ${{ inputs.release-type }} --npm.tag=latest
|
|
85
|
+
fi
|
package/.prettierignore
CHANGED
package/.release-it.json
CHANGED
package/README.md
CHANGED
|
@@ -4,34 +4,34 @@ This library is an implementation of a registry contract that supports the Polyg
|
|
|
4
4
|
|
|
5
5
|
## Overview
|
|
6
6
|
|
|
7
|
-
The Polygon registry contract acts as a public ledger, where the Polygon-Identity specified Decentralised Identifiers will be logged. The specifications related to polygon DID method are mentioned in the
|
|
7
|
+
The Polygon registry contract acts as a public ledger, where the Polygon-Identity specified Decentralised Identifiers will be logged. The specifications related to polygon DID method are mentioned in the document. A DID generated using the Polygon DID generator, can be stored and managed on the ledger using this contract library.
|
|
8
8
|
|
|
9
9
|
## Contract Deployment
|
|
10
10
|
|
|
11
|
-
|
|
|
12
|
-
|
|
|
13
|
-
| Polygon Mainnet |
|
|
14
|
-
| Polygon Testnet |
|
|
11
|
+
| Network | ChainId | Registry Address |
|
|
12
|
+
| :-------------: | :-----: | :----------------------------------------: |
|
|
13
|
+
| Polygon Mainnet | 137 | 0x98bF771e1E93Db917A89986bcdaBa3b43643F367 |
|
|
14
|
+
| Polygon Testnet | 80001 | 0x8B335A167DA81CCef19C53eE629cf2F6291F2255 |
|
|
15
15
|
|
|
16
16
|
## Methods
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
- `createDID(address, string)` : The method createDID is used to create and log a new DID on the polygon chain. The parameter of address type, will act as the reference key, to refer the did document stored on the chain. The string type variable will contain the did document, that will be stored on the matic chain.
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
- `updateDIDDoc(address, string)` : The method updateDID is included in contract, which will facilitate the controller, and only the controller of the did, to update the document if need arises. Though the Polygon DID method, defines how the DID doc is defined as per standards, and that can be resolved.
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
- `deleteDIDDoc(address)` : The method deleteDID is included in the contract, that only the controller of DID can access, to delete a particular DID from ledger.
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
- `getDIDDoc(address)` : The method getDID helps to resolve the DID document.
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
- `transferOwnership(address)` : The method transferOwnership, helps in transferring the ownership of contract to a new owner. Only the current owner can access this function.
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
- `getOwner()` : the method getOwner helps one to fetch the current owner of the contract.
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
- `getTotalNumberOfDIDs()` : the method getTotalNumberOfDIDs helps one to fetch the total number of DIDs ever written on Polygon Ledger, with the number of currently active DIDs.
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
- `getTotalNumberOfDeletedDIDs()`: the method getTotalNumberOfDeletedDIDs helps one fetch the total number of DIDs deleted from Polygon Ledger.
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
- `getDIDDOcByIndex(uint256)` : The method getDIDDOcByIndex helps,to resolve DID document by index.
|
|
35
35
|
|
|
36
36
|
## Example ethers code
|
|
37
37
|
|
|
@@ -57,7 +57,6 @@ let returnHashValues = await registry.functions.createDID(<DID address>, DidDoc)
|
|
|
57
57
|
|
|
58
58
|
## Updating a DID
|
|
59
59
|
|
|
60
|
-
|
|
61
60
|
```
|
|
62
61
|
let returnHashValues = await registry.functions.updateDIDDoc(<DID address>, DidDoc)
|
|
63
62
|
```
|
|
@@ -68,7 +67,7 @@ let returnHashValues = await registry.functions.updateDIDDoc(<DID address>, DidD
|
|
|
68
67
|
let returnHashValues = await registry.functions.deleteDIDDoc(<DID address>)
|
|
69
68
|
```
|
|
70
69
|
|
|
71
|
-
## Resolving a DID
|
|
70
|
+
## Resolving a DID
|
|
72
71
|
|
|
73
72
|
```
|
|
74
73
|
let returnDidDoc = await registry.functions.getDIDDoc(<DID address>);
|
|
@@ -78,27 +77,26 @@ let returnDidDoc = await registry.functions.getDIDDoc(<DID address>);
|
|
|
78
77
|
|
|
79
78
|
Pre-requisites
|
|
80
79
|
|
|
81
|
-
|
|
80
|
+
- NodeJS
|
|
82
81
|
|
|
83
82
|
```
|
|
84
83
|
https://nodejs.org/en/download/
|
|
85
84
|
```
|
|
86
85
|
|
|
87
|
-
|
|
86
|
+
- Truffle
|
|
88
87
|
|
|
89
88
|
```
|
|
90
89
|
https://www.trufflesuite.com/docs/truffle/getting-started/truffle-with-metamask
|
|
91
90
|
```
|
|
92
91
|
|
|
93
|
-
|
|
92
|
+
- Ganache
|
|
94
93
|
|
|
95
94
|
```
|
|
96
95
|
https://www.trufflesuite.com/ganache
|
|
97
96
|
```
|
|
98
97
|
|
|
99
|
-
|
|
98
|
+
- A wallet connected to polygon network, with Matic token in it. One can receive the Matic Test Tokens from their faucet.
|
|
100
99
|
|
|
101
|
-
|
|
102
100
|
## Deployment
|
|
103
101
|
|
|
104
102
|
Clone the above repository
|
|
@@ -113,7 +111,7 @@ Install Dependencies
|
|
|
113
111
|
npm i
|
|
114
112
|
```
|
|
115
113
|
|
|
116
|
-
Run a ganache instance (only required for Local Deployment)
|
|
114
|
+
Run a ganache instance (only required for Local Deployment)
|
|
117
115
|
|
|
118
116
|
```
|
|
119
117
|
ganache-cli
|
|
@@ -139,4 +137,5 @@ For Testing use the command
|
|
|
139
137
|
```
|
|
140
138
|
truffle test
|
|
141
139
|
```
|
|
142
|
-
|
|
140
|
+
|
|
141
|
+
The test cases run on a ganache setup.
|