Skip to content

Commit

Permalink
Rename getSemaphoreV4PublicKey -> getPublicKey
Browse files Browse the repository at this point in the history
  • Loading branch information
robknight committed Sep 19, 2024
1 parent ca0bd66 commit b816b09
Show file tree
Hide file tree
Showing 16 changed files with 72 additions and 14 deletions.
9 changes: 9 additions & 0 deletions apps/client-web/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# client-web

## 0.0.4

### Patch Changes

- Rename getSemaphoreV4PublicKey -> getPublicKey
- Updated dependencies
- @parcnet-js/client-rpc@0.0.3
- @parcnet-js/client-helpers@0.0.4

## 0.0.3

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion apps/client-web/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "client-web",
"private": true,
"version": "0.0.3",
"version": "0.0.4",
"type": "module",
"scripts": {
"dev": "vite",
Expand Down
2 changes: 1 addition & 1 deletion apps/client-web/src/client/identity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export class ParcnetIdentityProcessor implements ParcnetIdentityRPC {
async getSemaphoreV4Commitment(): Promise<bigint> {
return this.v4Identity.commitment;
}
async getSemaphoreV4PublicKey(): Promise<string> {
async getPublicKey(): Promise<string> {
return encodePublicKey(this.v4Identity.publicKey);
}
}
4 changes: 2 additions & 2 deletions apps/docs/src/content/docs/guides/getting-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -301,12 +301,12 @@ const commitment = await z.identity.getSemaphoreV4Commitment();
The commitment is a `bigint` and uniquely identifies the user.


### Semaphore v4 public key
### Public key

The user's [Semaphore](https://semaphore.pse.dev/) v4 public key can be retrieved like this:

```ts wrap=true title="src/main.ts"
const commitment = await z.identity.getSemaphoreV4PublicKey();
const commitment = await z.identity.getPublicKey();
```

The public key is a `string` and uniquely identifies the user.
8 changes: 8 additions & 0 deletions examples/test-app/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# test-app

## 1.0.3

### Patch Changes

- Rename getSemaphoreV4PublicKey -> getPublicKey
- Updated dependencies
- @parcnet-js/app-connector@0.0.3

## 1.0.2

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion examples/test-app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "test-app",
"version": "1.0.2",
"version": "1.0.3",
"private": true,
"type": "module",
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions examples/test-app/src/apis/Identity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ export function Identity(): ReactNode {
<p>
Getting the v4 identity public key is done like this:
<code className="block text-xs font-base rounded-md p-2">
await z.identity.getSemaphoreV4PublicKey();
await z.identity.getPublicKey();
</code>
</p>
<TryIt
onClick={async () => {
try {
const publicKey = await z.identity.getSemaphoreV4PublicKey();
const publicKey = await z.identity.getPublicKey();
setPublicKey(publicKey);
} catch (e) {
console.log(e);
Expand Down
8 changes: 8 additions & 0 deletions packages/app-connector/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @parcnet-js/app-connector

## 0.0.3

### Patch Changes

- Rename getSemaphoreV4PublicKey -> getPublicKey
- Updated dependencies
- @parcnet-js/client-rpc@0.0.3

## 0.0.2

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/app-connector/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@parcnet-js/app-connector",
"version": "0.0.2",
"version": "0.0.3",
"license": "GPL-3.0-or-later",
"type": "module",
"main": "dist/index.cjs",
Expand Down
24 changes: 22 additions & 2 deletions packages/app-connector/src/api_wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,19 +121,39 @@ export class ParcnetGPCWrapper {
}
}

export class ParcnetIdentityWrapper {
#api: ParcnetIdentityRPC;

constructor(api: ParcnetIdentityRPC) {
this.#api = api;
}

async getPublicKey(): Promise<string> {
return this.#api.getPublicKey();
}

async getSemaphoreV3Commitment(): Promise<bigint> {
return this.#api.getSemaphoreV3Commitment();
}

async getSemaphoreV4Commitment(): Promise<bigint> {
return this.#api.getSemaphoreV4Commitment();
}
}

/**
* Wraps the Parcnet RPC API to provide a more user-friendly interface.
* Specifically, this handles serialization and deserialization of PODs and
* query data.
*/
export class ParcnetAPI {
public pod: ParcnetPODWrapper;
public identity: ParcnetIdentityRPC;
public identity: ParcnetIdentityWrapper;
public gpc: ParcnetGPCWrapper;

constructor(api: ParcnetRPCConnector) {
this.pod = new ParcnetPODWrapper(api);
this.identity = api.identity;
this.identity = new ParcnetIdentityWrapper(api.identity);
this.gpc = new ParcnetGPCWrapper(api);
}
}
7 changes: 7 additions & 0 deletions packages/client-helpers/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @parcnet-js/client-helpers

## 0.0.4

### Patch Changes

- Updated dependencies
- @parcnet-js/client-rpc@0.0.3

## 0.0.3

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/client-helpers/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@parcnet-js/client-helpers",
"version": "0.0.3",
"version": "0.0.4",
"license": "GPL-3.0-or-later",
"type": "module",
"main": "dist/index.js",
Expand Down
6 changes: 6 additions & 0 deletions packages/client-rpc/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @parcnet-js/client-rpc

## 0.0.3

### Patch Changes

- Rename getSemaphoreV4PublicKey -> getPublicKey

## 0.0.2

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/client-rpc/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@parcnet-js/client-rpc",
"type": "module",
"version": "0.0.2",
"version": "0.0.3",
"license": "GPL-3.0-or-later",
"main": "dist/index.js",
"module": "dist/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/client-rpc/src/rpc_interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export interface ParcnetGPCRPC {
export interface ParcnetIdentityRPC {
getSemaphoreV3Commitment: () => Promise<bigint>;
getSemaphoreV4Commitment: () => Promise<bigint>;
getSemaphoreV4PublicKey: () => Promise<string>;
getPublicKey: () => Promise<string>;
}

export interface ParcnetPODRPC {
Expand Down
2 changes: 1 addition & 1 deletion packages/client-rpc/src/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ export const ParcnetRPCSchema = {
input: v.tuple([]),
output: v.bigint()
},
getSemaphoreV4PublicKey: {
getPublicKey: {
input: v.tuple([]),
output: v.string()
}
Expand Down

0 comments on commit b816b09

Please sign in to comment.