Skip to content

Commit

Permalink
Merge pull request #506 from docknetwork/legacy-docs
Browse files Browse the repository at this point in the history
Legacy documents support for `testnet`
  • Loading branch information
cykoder authored Jan 22, 2025
2 parents 9c2ba4c + 3e521ef commit 99ae5cd
Show file tree
Hide file tree
Showing 21 changed files with 889 additions and 102 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.10.0

### Minor Changes

- Legacy documents support for `testnet`

### Patch Changes

- Updated dependencies
- @docknetwork/dock-blockchain-modules@0.16.0
- @docknetwork/dock-blockchain-api@0.12.0
- @docknetwork/credential-sdk@0.27.0

## 0.9.0

### Minor 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.9.0",
"version": "0.10.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.26.0",
"@docknetwork/dock-blockchain-api": "0.11.0",
"@docknetwork/dock-blockchain-modules": "0.15.0"
"@docknetwork/credential-sdk": "0.27.0",
"@docknetwork/dock-blockchain-api": "0.12.0",
"@docknetwork/dock-blockchain-modules": "0.16.0"
},
"devDependencies": {
"babel-eslint": "^10.1.0",
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.21.0

### Minor Changes

- Legacy documents support for `testnet`

### Patch Changes

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

## 0.20.0

### Minor Changes
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.20.0",
"version": "0.21.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.26.0"
"@docknetwork/credential-sdk": "0.27.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.18.0

### Minor Changes

- Legacy documents support for `testnet`

### Patch Changes

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

## 0.17.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.17.0",
"version": "0.18.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.26.0"
"@docknetwork/credential-sdk": "0.27.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.20.0",
"@docknetwork/cheqd-blockchain-api": "0.21.0",
"@rollup/plugin-alias": "^4.0.2",
"@rollup/plugin-babel": "^6.0.4",
"@rollup/plugin-commonjs": "^24.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe("AccumulatorModule", () => {

beforeAll(async () => {
await cheqd.init({
url: url,
url,
wallet: await faucet.wallet(),
network,
});
Expand Down
13 changes: 8 additions & 5 deletions packages/cheqd-blockchain-modules/tests/constants.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import { DirectSecp256k1HdWallet } from '@docknetwork/cheqd-blockchain-api/wallet';
import { CheqdNetwork } from '@docknetwork/cheqd-blockchain-api';
import { DirectSecp256k1HdWallet } from "@docknetwork/cheqd-blockchain-api/wallet";
import { CheqdNetwork } from "@docknetwork/cheqd-blockchain-api";

export const faucet = {
prefix: "cheqd",
minimalDenom: "ncheq",
mnemonic: process.env.CHEQD_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",
async wallet() {
return await DirectSecp256k1HdWallet.fromMnemonic(this.mnemonic, { prefix: this.prefix })
}
return await DirectSecp256k1HdWallet.fromMnemonic(this.mnemonic, {
prefix: this.prefix,
});
},
};

export const url = process.env.CHEQD_RPC_URL || "http://localhost:26657";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import { CheqdAPI } from "@docknetwork/cheqd-blockchain-api";
import {
CheqdTestnetDid,
CheqdOffchainSignatureParamsRef,
} from "@docknetwork/credential-sdk/types";
import generateOffchainSignaturesModuleTests from "@docknetwork/credential-sdk/modules/tests/offchain-signatures-module";
import { MultiApiCoreModules } from "@docknetwork/credential-sdk/modules";
import { faucet, url, network } from "./constants";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
import { CheqdAPI } from "@docknetwork/cheqd-blockchain-api";
import {
CheqdTestnetDid,
CheqdStatusListCredentialId,
} from "@docknetwork/credential-sdk/types";
import { StatusList2021Credential } from "@docknetwork/credential-sdk/vc";
import { MultiApiStatusListCredentialModule } from "@docknetwork/credential-sdk/modules";
import generateStatusListCredentialModuleTests from "@docknetwork/credential-sdk/modules/tests/status-list-credential-module";
import CheqdDIDModule from "../src/did/module";
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.27.0

### Minor Changes

- Legacy documents support for `testnet`

## 0.26.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.26.0",
"version": "0.27.0",
"license": "MIT",
"type": "module",
"files": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,54 @@ import {
CheqdVerificationMethodAssertion,
CheqdMainnetVerificationMethodAssertion,
CheqdTestnetVerificationMethodAssertion,
CheqdVerificationMethodAssertionLegacy,
CheqdTestnetVerificationMethodAssertionLegacy,
} from './verification-method';
import {
CheqdMainnetVerificationMethodRef,
CheqdTestnetVerificationMethodRef,
CheqdVerificationMethodRef,
} from './verification-method-ref';
import { CheqdVerificationMethodRef } from './verification-method-ref';
import { withFrom } from '../../generic';

export class CheqdVerificationMethodRefOrCheqdVerificationMethod extends withFrom(
CheqdVerificationMethodRef,
function from(value) {
try {
return this.Base.from(value);
} catch (err) {
return this.Or.from(value);
return this.First.from(value);
} catch (firstErr) {
try {
return this.Second.from(value);
} catch (secondErr) {
secondErr.message = `${firstErr.message}; ${secondErr.message}`;

if (this.Third == null) {
throw secondErr;
}
try {
return this.Third.from(value);
} catch (thirdErr) {
thirdErr.message = `${secondErr.message}; ${thirdErr.message}`;

throw thirdErr;
}
}
}
},
) {
static Base = CheqdVerificationMethodAssertion;
static First = CheqdVerificationMethodAssertion;

static Second = CheqdVerificationMethodAssertionLegacy;

static Or = CheqdVerificationMethodRef;
static Third = CheqdVerificationMethodRef;
}

export class CheqdVerificationMethodRefOrCheqdTestnetVerificationMethod extends CheqdVerificationMethodRefOrCheqdVerificationMethod {
static Base = CheqdTestnetVerificationMethodAssertion;
static First = CheqdTestnetVerificationMethodAssertion;

static Second = CheqdTestnetVerificationMethodAssertionLegacy;

static Or = CheqdTestnetVerificationMethodRef;
static Third = CheqdVerificationMethodRef;
}

export class CheqdVerificationMethodRefOrCheqdMainnetVerificationMethod extends CheqdVerificationMethodRefOrCheqdVerificationMethod {
static Base = CheqdMainnetVerificationMethodAssertion;
static First = CheqdMainnetVerificationMethodAssertion;

static Or = CheqdMainnetVerificationMethodRef;
static Second = CheqdVerificationMethodRef;
}
Original file line number Diff line number Diff line change
Expand Up @@ -337,20 +337,8 @@ export class CheqdTestnetVerificationMethodAssertion extends withProp(
option(CheqdTestnetPublicKeyMetadata),
) {}

export class CheqdMainnetVerificationMethodAssertion extends withFrom(
withProp(
withProp(
withProp(
CheqdVerificationMethod,
'id',
CheqdMainnetVerificationMethodRef,
),
'controller',
CheqdMainnetDid,
),
'metadata',
option(CheqdMainnetPublicKeyMetadata),
),
export class CheqdVerificationMethodAssertionLegacy extends withFrom(
CheqdVerificationMethod,
(value, from) => {
const self = from(value);
const verMethod = self.toVerificationMethod();
Expand Down Expand Up @@ -397,3 +385,31 @@ export class CheqdMainnetVerificationMethodAssertion extends withFrom(
: super.from(obj);
}
}

export class CheqdMainnetVerificationMethodAssertion extends withProp(
withProp(
withProp(
CheqdVerificationMethodAssertionLegacy,
'id',
CheqdMainnetVerificationMethodRef,
),
'controller',
CheqdMainnetDid,
),
'metadata',
option(CheqdMainnetPublicKeyMetadata),
) {}

export class CheqdTestnetVerificationMethodAssertionLegacy extends withProp(
withProp(
withProp(
CheqdVerificationMethodAssertionLegacy,
'id',
CheqdTestnetVerificationMethodRef,
),
'controller',
CheqdTestnetDid,
),
'metadata',
option(CheqdTestnetPublicKeyMetadata),
) {}
9 changes: 8 additions & 1 deletion packages/credential-sdk/src/types/generic/typed-uuid.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,14 @@ export default class TypedUUID extends TypedBytes {
}

static fromDockIdent(dockIdent, prefix = []) {
const prefixBytes = normalizeOrConvertStringToU8a(prefix);
const { CHEQD_MIGRATION_PREFIX } = process.env;

let prefixBytes = normalizeOrConvertStringToU8a(prefix);
if (CHEQD_MIGRATION_PREFIX) {
prefixBytes = prefixBytes.concat(
normalizeOrConvertStringToU8a(CHEQD_MIGRATION_PREFIX),
);
}
const identBytes = valueNumberOrBytes(dockIdent);
const hash = sha256.digest([...prefixBytes, ...identBytes]);

Expand Down
Loading

0 comments on commit 99ae5cd

Please sign in to comment.