@semaphore-protocol/group 2.1.0 → 2.4.0

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/README.md CHANGED
@@ -6,11 +6,11 @@
6
6
  </p>
7
7
 
8
8
  <p align="center">
9
- <a href="https://github.com/semaphore-protocol/semaphore.js">
10
- <img src="https://img.shields.io/badge/project-semaphore-blue.svg?style=flat-square">
9
+ <a href="https://github.com/semaphore-protocol">
10
+ <img src="https://img.shields.io/badge/project-Semaphore-blue.svg?style=flat-square">
11
11
  </a>
12
- <a href="https://github.com/semaphore-protocol/semaphore.js/blob/main/packages/group/LICENSE">
13
- <img alt="Github license" src="https://img.shields.io/github/license/semaphore-protocol/semaphore.js.svg?style=flat-square">
12
+ <a href="https://github.com/semaphore-protocol/semaphore/blob/main/LICENSE">
13
+ <img alt="Github license" src="https://img.shields.io/github/license/semaphore-protocol/semaphore.svg?style=flat-square">
14
14
  </a>
15
15
  <a href="https://www.npmjs.com/package/@semaphore-protocol/group">
16
16
  <img alt="NPM version" src="https://img.shields.io/npm/v/@semaphore-protocol/group?style=flat-square" />
@@ -28,12 +28,20 @@
28
28
 
29
29
  <div align="center">
30
30
  <h4>
31
- <a href="https://t.me/joinchat/B-PQx1U3GtAh--Z4Fwo56A">
32
- 🗣️ Chat &amp; Support
31
+ <a href="https://github.com/semaphore-protocol/semaphore/blob/main/CONTRIBUTING.md">
32
+ 👥 Contributing
33
+ </a>
34
+ <span>&nbsp;&nbsp;|&nbsp;&nbsp;</span>
35
+ <a href="https://github.com/semaphore-protocol/semaphore/blob/main/CODE_OF_CONDUCT.md">
36
+ 🤝 Code of conduct
33
37
  </a>
34
38
  <span>&nbsp;&nbsp;|&nbsp;&nbsp;</span>
35
- <a href="https://semaphore-protocol.github.io/semaphore.js/group">
36
- 📘 Docs
39
+ <a href="https://github.com/semaphore-protocol/semaphore/contribute">
40
+ 🔎 Issues
41
+ </a>
42
+ <span>&nbsp;&nbsp;|&nbsp;&nbsp;</span>
43
+ <a href="https://discord.gg/6mSdGHnstH">
44
+ 🗣️ Chat &amp; Support
37
45
  </a>
38
46
  </h4>
39
47
  </div>
package/dist/index.mjs CHANGED
@@ -1,10 +1,10 @@
1
1
  /**
2
2
  * @module @semaphore-protocol/group
3
- * @version 2.1.0
3
+ * @version 2.4.0
4
4
  * @file A library to create and manage Semaphore groups.
5
5
  * @copyright Ethereum Foundation 2022
6
6
  * @license MIT
7
- * @see [Github]{@link https://github.com/semaphore-protocol/semaphore.js/tree/main/packages/group}
7
+ * @see [Github]{@link https://github.com/semaphore-protocol/semaphore/tree/main/packages/group}
8
8
  */
9
9
  import { IncrementalMerkleTree } from '@zk-kit/incremental-merkle-tree';
10
10
  import { poseidon } from 'circomlibjs';
@@ -92,6 +92,14 @@ var Group = /** @class */ (function () {
92
92
  this.addMember(identityCommitment);
93
93
  }
94
94
  };
95
+ /**
96
+ * Updates a member in the group.
97
+ * @param index Index of the member to be updated.
98
+ * @param identityCommitment New member value.
99
+ */
100
+ Group.prototype.updateMember = function (index, identityCommitment) {
101
+ this._merkleTree.update(index, identityCommitment);
102
+ };
95
103
  /**
96
104
  * Removes a member from the group.
97
105
  * @param index Index of the member to be removed.
@@ -1,10 +1,10 @@
1
1
  /**
2
2
  * @module @semaphore-protocol/group
3
- * @version 2.1.0
3
+ * @version 2.4.0
4
4
  * @file A library to create and manage Semaphore groups.
5
5
  * @copyright Ethereum Foundation 2022
6
6
  * @license MIT
7
- * @see [Github]{@link https://github.com/semaphore-protocol/semaphore.js/tree/main/packages/group}
7
+ * @see [Github]{@link https://github.com/semaphore-protocol/semaphore/tree/main/packages/group}
8
8
  */
9
9
  'use strict';
10
10
 
@@ -96,6 +96,14 @@ var Group = /** @class */ (function () {
96
96
  this.addMember(identityCommitment);
97
97
  }
98
98
  };
99
+ /**
100
+ * Updates a member in the group.
101
+ * @param index Index of the member to be updated.
102
+ * @param identityCommitment New member value.
103
+ */
104
+ Group.prototype.updateMember = function (index, identityCommitment) {
105
+ this._merkleTree.update(index, identityCommitment);
106
+ };
99
107
  /**
100
108
  * Removes a member from the group.
101
109
  * @param index Index of the member to be removed.
@@ -44,6 +44,12 @@ export default class Group {
44
44
  * @param identityCommitments New members.
45
45
  */
46
46
  addMembers(identityCommitments: Member[]): void;
47
+ /**
48
+ * Updates a member in the group.
49
+ * @param index Index of the member to be updated.
50
+ * @param identityCommitment New member value.
51
+ */
52
+ updateMember(index: number, identityCommitment: Member): void;
47
53
  /**
48
54
  * Removes a member from the group.
49
55
  * @param index Index of the member to be removed.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@semaphore-protocol/group",
3
- "version": "2.1.0",
3
+ "version": "2.4.0",
4
4
  "description": "A library to create and manage Semaphore groups.",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.node.js",
@@ -15,8 +15,11 @@
15
15
  "LICENSE",
16
16
  "README.md"
17
17
  ],
18
- "repository": "https://github.com/semaphore-protocol/semaphore.js",
19
- "homepage": "https://github.com/semaphore-protocol/semaphore.js/tree/main/packages/group",
18
+ "repository": "https://github.com/semaphore-protocol/semaphore",
19
+ "homepage": "https://github.com/semaphore-protocol/semaphore/tree/main/packages/group",
20
+ "bugs": {
21
+ "url": "https://github.com/semaphore-protocol/semaphore.git/issues"
22
+ },
20
23
  "scripts": {
21
24
  "build:watch": "rollup -c rollup.config.ts -w --configPlugin typescript",
22
25
  "build": "rimraf dist && rollup -c rollup.config.ts --configPlugin typescript",
@@ -32,7 +35,7 @@
32
35
  "typedoc": "^0.22.11"
33
36
  },
34
37
  "dependencies": {
35
- "@zk-kit/incremental-merkle-tree": "0.4.3",
38
+ "@zk-kit/incremental-merkle-tree": "1.0.0",
36
39
  "circomlibjs": "0.0.8"
37
40
  }
38
41
  }
package/src/group.test.ts CHANGED
@@ -58,6 +58,18 @@ describe("Group", () => {
58
58
  })
59
59
  })
60
60
 
61
+ describe("# updateMember", () => {
62
+ it("Should update a member in a group", () => {
63
+ const group = new Group()
64
+ group.addMembers([BigInt(1), BigInt(3)])
65
+
66
+ group.updateMember(0, BigInt(1))
67
+
68
+ expect(group.members).toHaveLength(2)
69
+ expect(group.members[0]).toBe(BigInt(1))
70
+ })
71
+ })
72
+
61
73
  describe("# removeMember", () => {
62
74
  it("Should remove a member from a group", () => {
63
75
  const group = new Group()
package/src/group.ts CHANGED
@@ -77,6 +77,15 @@ export default class Group {
77
77
  }
78
78
  }
79
79
 
80
+ /**
81
+ * Updates a member in the group.
82
+ * @param index Index of the member to be updated.
83
+ * @param identityCommitment New member value.
84
+ */
85
+ updateMember(index: number, identityCommitment: Member) {
86
+ this._merkleTree.update(index, identityCommitment)
87
+ }
88
+
80
89
  /**
81
90
  * Removes a member from the group.
82
91
  * @param index Index of the member to be removed.