Skip to content

Commit

Permalink
Tweaks for lastPublicKeyId and lastParamsId (#484)
Browse files Browse the repository at this point in the history
* Tweaks for `lastPublicKeyId` and `nextPublicKeyId`

* CHANGELOG + bump up version

* Corrections

* Tweak
  • Loading branch information
olegnn authored Nov 22, 2024
1 parent 591f037 commit cf62e35
Show file tree
Hide file tree
Showing 25 changed files with 137 additions and 47 deletions.
13 changes: 13 additions & 0 deletions examples/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# @docknetwork/sdk-examples

## 0.5.0

### Minor Changes

- Tweaks for `lastPublicKeyId` and `nextPublicKeyId`

### Patch Changes

- Updated dependencies
- @docknetwork/dock-blockchain-modules@0.7.0
- @docknetwork/dock-blockchain-api@0.6.0
- @docknetwork/credential-sdk@0.11.0

## 0.4.5

### Patch Changes
Expand Down
8 changes: 4 additions & 4 deletions examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@docknetwork/sdk-examples",
"private": true,
"type": "module",
"version": "0.4.5",
"version": "0.5.0",
"scripts": {
"bbs-dock-example": "babel-node ./bbs-dock.js",
"claim-deduction-example": "babel-node ./claim-deduction.js",
Expand All @@ -19,9 +19,9 @@
"lint": "eslint \"*.js\""
},
"dependencies": {
"@docknetwork/credential-sdk": "0.10.0",
"@docknetwork/dock-blockchain-api": "0.5.1",
"@docknetwork/dock-blockchain-modules": "0.6.1"
"@docknetwork/credential-sdk": "0.11.0",
"@docknetwork/dock-blockchain-api": "0.6.0",
"@docknetwork/dock-blockchain-modules": "0.7.0"
},
"devDependencies": {
"babel-eslint": "^10.1.0",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "root",
"version": "0.11.0",
"version": "0.14.0",
"private": true,
"workspaces": [
"packages/*",
Expand Down
11 changes: 11 additions & 0 deletions packages/cheqd-blockchain-api/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# @docknetwork/cheqd-blockchain-api

## 0.10.0

### Minor Changes

- Tweaks for `lastPublicKeyId` and `nextPublicKeyId`

### Patch Changes

- Updated dependencies
- @docknetwork/credential-sdk@0.11.0

## 0.9.0

- Allow to use `MultiApiCoreModules` with `CheqdCoreModules`
Expand Down
4 changes: 2 additions & 2 deletions packages/cheqd-blockchain-api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@docknetwork/cheqd-blockchain-api",
"version": "0.9.0",
"version": "0.10.0",
"license": "MIT",
"main": "./dist/esm/index.js",
"type": "module",
Expand Down Expand Up @@ -34,7 +34,7 @@
},
"dependencies": {
"@cheqd/sdk": "cjs",
"@docknetwork/credential-sdk": "0.10.0"
"@docknetwork/credential-sdk": "0.11.0"
},
"devDependencies": {
"@babel/cli": "^7.24.1",
Expand Down
11 changes: 11 additions & 0 deletions packages/cheqd-blockchain-modules/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# @docknetwork/cheqd-blockchain-modules

## 0.9.0

### Minor Changes

- Tweaks for `lastPublicKeyId` and `nextPublicKeyId`

### Patch Changes

- Updated dependencies
- @docknetwork/credential-sdk@0.11.0

## 0.8.0

### Minor Changes
Expand Down
6 changes: 3 additions & 3 deletions packages/cheqd-blockchain-modules/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@docknetwork/cheqd-blockchain-modules",
"version": "0.8.0",
"version": "0.9.0",
"type": "module",
"license": "MIT",
"main": "./dist/esm/index.js",
Expand Down Expand Up @@ -33,7 +33,7 @@
"node": ">=18.0.0"
},
"dependencies": {
"@docknetwork/credential-sdk": "0.10.0"
"@docknetwork/credential-sdk": "0.11.0"
},
"devDependencies": {
"@babel/cli": "^7.24.1",
Expand All @@ -42,7 +42,7 @@
"@babel/plugin-syntax-import-attributes": "^7.25.6",
"@babel/plugin-transform-modules-commonjs": "^7.24.1",
"@babel/preset-env": "^7.24.3",
"@docknetwork/cheqd-blockchain-api": "0.9.0",
"@docknetwork/cheqd-blockchain-api": "0.10.0",
"@rollup/plugin-alias": "^4.0.2",
"@rollup/plugin-babel": "^6.0.4",
"@rollup/plugin-commonjs": "^24.0.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/cheqd-blockchain-modules/tests/attest-module.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import { CheqdTestnetDid } from "@docknetwork/credential-sdk/types";
import { MultiApiDIDModule, MultiApiAttestModule } from "@docknetwork/credential-sdk/modules";
import generateAttestModuleTests from "@docknetwork/credential-sdk/modules/tests/attest-module";
import CheqdDIDModule from "../src/did/module";
import { faucet } from "./constants";
import { faucet, url } from "./constants";
import CheqdAttestModule from "../src/attest/module";

describe("AttestModule", () => {
const cheqd = new CheqdAPI();

beforeAll(async () => {
await cheqd.init({
url: process.env.ENDPOINT_URL || "http://localhost:26657",
url: url,
mnemonic: faucet.mnemonic,
network: "testnet",
});
Expand Down
4 changes: 2 additions & 2 deletions packages/cheqd-blockchain-modules/tests/blob-module.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
import { MultiApiBlobModule } from "@docknetwork/credential-sdk/modules";
import generateBlobModuleTests from "@docknetwork/credential-sdk/modules/tests/blob-module";
import CheqdDIDModule from "../src/did/module";
import { faucet } from "./constants";
import { faucet, url } from "./constants";
import CheqdBlobModule from "../src/blob/module";
import { MultiApiDIDModule } from "@docknetwork/credential-sdk/modules";

Expand All @@ -15,7 +15,7 @@ describe("BlobModule", () => {

beforeAll(async () => {
await cheqd.init({
url: process.env.ENDPOINT_URL || "http://localhost:26657",
url,
mnemonic: faucet.mnemonic,
network: "testnet",
});
Expand Down
6 changes: 4 additions & 2 deletions packages/cheqd-blockchain-modules/tests/constants.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
export const faucet = {
prefix: "cheqd",
minimalDenom: "ncheq",
mnemonic:
mnemonic: process.env.CHEQD_MNEMONIC ||
"steak come surprise obvious remain black trouble measure design volume retreat float coach amused match album moment radio stuff crack orphan ranch dose endorse",
address: "cheqd1fgl67nvjdkrnaemjzg5sqvck9fcst4vt99gmma",
address: process.env.CHEQD_SENDER_ADDRESS || "cheqd1fgl67nvjdkrnaemjzg5sqvck9fcst4vt99gmma",
};

export const url = process.env.CHEQD_RPC_URL || "http://localhost:26657";
4 changes: 2 additions & 2 deletions packages/cheqd-blockchain-modules/tests/did-module.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import { CheqdAPI } from "@docknetwork/cheqd-blockchain-api";
import { CheqdTestnetDid } from "@docknetwork/credential-sdk/types";
import didModuleTests from "@docknetwork/credential-sdk/modules/tests/did-module";
import CheqdDIDModule from "../src/did/module";
import { faucet } from "./constants";
import { faucet, url } from "./constants";
import { MultiApiDIDModule } from "@docknetwork/credential-sdk/modules";

describe("DIDModule", () => {
const cheqd = new CheqdAPI();

beforeAll(async () => {
await cheqd.init({
url: process.env.ENDPOINT_URL || "http://localhost:26657",
url,
mnemonic: faucet.mnemonic,
network: "testnet",
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
} from "@docknetwork/credential-sdk/types";
import { MultiApiOffchainSignaturesModule } from "@docknetwork/credential-sdk/modules";
import generateOffchainSignaturesModuleTests from "@docknetwork/credential-sdk/modules/tests/offchain-signatures-module";
import { faucet } from "./constants";
import { faucet, url } from "./constants";
import {
CheqdOffchainSignaturesModule,
CheqdDIDModule,
Expand All @@ -21,7 +21,7 @@ describe("OffchainSignaturesModule", () => {

beforeAll(async () => {
await cheqd.init({
url: process.env.ENDPOINT_URL || "http://localhost:26657",
url,
mnemonic: faucet.mnemonic,
network: "testnet",
});
Expand Down
6 changes: 6 additions & 0 deletions packages/credential-sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @docknetwork/credential-sdk

## 0.11.0

### Minor Changes

- Tweaks for `lastPublicKeyId` and `nextPublicKeyId`

## 0.10.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/credential-sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@docknetwork/credential-sdk",
"version": "0.10.0",
"version": "0.11.0",
"license": "MIT",
"type": "module",
"files": [
Expand Down
11 changes: 11 additions & 0 deletions packages/dock-blockchain-api/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# @docknetwork/dock-blockchain-api

## 0.6.0

### Minor Changes

- Tweaks for `lastPublicKeyId` and `nextPublicKeyId`

### Patch Changes

- Updated dependencies
- @docknetwork/credential-sdk@0.11.0

## 0.5.1

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/dock-blockchain-api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@docknetwork/dock-blockchain-api",
"version": "0.5.1",
"version": "0.6.0",
"license": "MIT",
"main": "./dist/esm/index.js",
"type": "module",
Expand Down Expand Up @@ -89,7 +89,7 @@
"@polkadot/api": "10.12.4"
},
"dependencies": {
"@docknetwork/credential-sdk": "0.10.0",
"@docknetwork/credential-sdk": "0.11.0",
"@docknetwork/node-types": "^0.17.0",
"@juanelas/base64": "^1.0.5",
"@polkadot/api": "10.12.4",
Expand Down
11 changes: 11 additions & 0 deletions packages/dock-blockchain-modules/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# @docknetwork/dock-blockchain-modules

## 0.7.0

### Minor Changes

- Tweaks for `lastPublicKeyId` and `nextPublicKeyId`

### Patch Changes

- Updated dependencies
- @docknetwork/credential-sdk@0.11.0

## 0.6.1

### Patch Changes
Expand Down
6 changes: 3 additions & 3 deletions packages/dock-blockchain-modules/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@docknetwork/dock-blockchain-modules",
"version": "0.6.1",
"version": "0.7.0",
"license": "MIT",
"type": "module",
"main": "./dist/esm/index.js",
Expand Down Expand Up @@ -33,7 +33,7 @@
"node": ">=18.0.0"
},
"dependencies": {
"@docknetwork/credential-sdk": "0.10.0"
"@docknetwork/credential-sdk": "0.11.0"
},
"devDependencies": {
"@babel/cli": "^7.24.1",
Expand All @@ -42,7 +42,7 @@
"@babel/plugin-syntax-import-attributes": "^7.25.6",
"@babel/plugin-transform-modules-commonjs": "^7.24.1",
"@babel/preset-env": "^7.24.3",
"@docknetwork/dock-blockchain-api": "0.5.1",
"@docknetwork/dock-blockchain-api": "0.6.0",
"@rollup/plugin-alias": "^4.0.2",
"@rollup/plugin-babel": "^6.0.4",
"@rollup/plugin-commonjs": "^24.0.0",
Expand Down
8 changes: 8 additions & 0 deletions packages/dock-blockchain-modules/src/accumulator/internal.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,14 @@ export default class DockInternalAccumulatorModule extends injectParams(
return (await this.counters(did)).keyCounter;
}

async lastParamsId(did) {
return await this.paramsCounter(did);
}

async lastPublicKeyId(did) {
return await this.keysCounter(did);
}

/**
* Update given witness by downloading necessary blocks and applying the updates if found. Both start and end are inclusive
* @param accumulatorId
Expand Down
6 changes: 5 additions & 1 deletion packages/dock-blockchain-modules/src/common/inject-params.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export default function injectParams(klass) {
const hexDid = DockDidOrDidMethodKey.from(did);
const paramsMap = new this.constructor.ParamsMap();

const paramsCounter = await this.paramsCounter(hexDid);
const paramsCounter = await this.lastParamsId(hexDid);
for (let idx = 1; idx <= paramsCounter; idx++) {
// eslint-disable-next-line no-await-in-loop
const params = await this.getParams(hexDid, idx);
Expand All @@ -74,6 +74,10 @@ export default function injectParams(klass) {

return paramsMap;
}

async lastParamsId(_did) {
throw new Error('Unimplemented');
}
},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
TypedMap,
withNullIfNotAVariant,
} from '@docknetwork/credential-sdk/types/generic';
import { isEqualToOrPrototypeOf, withExtendedStaticProperties } from '@docknetwork/credential-sdk/utils';
import { isEqualToOrPrototypeOf, withExtendedStaticProperties, withExtendedPrototypeProperties } from '@docknetwork/credential-sdk/utils';
import { DockDidOrDidMethodKey } from '@docknetwork/credential-sdk/types';
import { createInternalDockModule } from './builders';

Expand Down Expand Up @@ -85,7 +85,7 @@ export default function injectPublicKeys(klass) {
const hexDid = DockDidOrDidMethodKey.from(did);
const publicKeysMap = new this.constructor.PublicKeysMap();

const keysCounter = await this.keysCounter(hexDid);
const keysCounter = await this.lastPublicKeyId(hexDid);
for (let idx = 1; idx <= keysCounter; idx++) {
// eslint-disable-next-line no-await-in-loop
const publicKey = await this.getPublicKey(hexDid, idx, includeParams);
Expand All @@ -97,14 +97,18 @@ export default function injectPublicKeys(klass) {

return publicKeysMap;
}

async lastPublicKeyId(_did) {
throw new Error('Unimplemented');
}
},
};

return createInternalDockModule(
{ didMethods },
withExtendedStaticProperties(
withExtendedPrototypeProperties(['lastPublicKeyId'], withExtendedStaticProperties(
['PublicKey', 'ParamsRef', 'PublicKeyOwner', 'PublicKeyQuery'],
obj[name],
),
)),
);
}
Loading

0 comments on commit cf62e35

Please sign in to comment.