Skip to content

Commit

Permalink
Tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
olegnn committed Jan 9, 2025
1 parent 469ac04 commit ec4637e
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 64 deletions.
5 changes: 0 additions & 5 deletions packages/cheqd-blockchain-modules/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,4 @@ expect((await attestModule.getDocument(did)).attests.toJSON()).toEqual(iri);

## TODO:

- Accumulator
- Anchor
- Blob
- OffchainSignatures params (BBS/BBSPlus/PS)
- StatusListCredential
- TrustRegistry
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@ export class CheqdAccumulatorIdValue extends withQualifier(DidRef) {
prefix = 'mainnet';
} else {
throw new Error(
`Can't determine DID type: \`${cheqdDid}\`, instance of \`${cheqdDid.constructor.name}\``,
`Can't determine DID type: \`${cheqdDid(did)}\`, instance of \`${
cheqdDid(did).constructor.name
}\``,
);
}

Expand Down
4 changes: 3 additions & 1 deletion packages/credential-sdk/src/types/blob/blob-id.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ export class CheqdBlobIdValue extends withQualifier(DidRef) {
prefix = 'mainnet';
} else {
throw new Error(
`Can't determine DID type: \`${cheqdDid}\`, instance of \`${cheqdDid.constructor.name}\``,
`Can't determine DID type: \`${cheqdDid(did)}\`, instance of \`${
cheqdDid(did).constructor.name
}\``,
);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/dock-blockchain-modules/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
"docs": "rm -rf out && mkdir out && touch out/.nojekyll && jsdoc src -r -c ../../.jsdoc -d out/reference",
"prepublishOnly": "yarn build",
"dev-node": "../../scripts/run_dock_node_in_docker --dev --rpc-external --ws-external --rpc-cors=all",
"test": "LOG_STATE_CHANGE=1 NODE_ENV=production jest --verbose --runInBand --forceExit ./tests/integration/modules/offchain-signatures-module.test.js",
"test": "LOG_STATE_CHANGE=1 NODE_ENV=production jest --verbose --runInBand --forceExit ./tests/integration/*",
"test-with-node": "../../scripts/with_dock_docker_test_node yarn test",
"test-with-all-nodes": "../../scripts/with_all_dock_docker_test_nodes yarn test-integration"
}
Expand Down
60 changes: 4 additions & 56 deletions scripts/migration/src/migration.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ import {
DockStatusListCredentialModule,
DockCoreModules,
} from '@docknetwork/dock-blockchain-modules';
import { CheqdAccumulatorModule, CheqdCoreModules } from '@docknetwork/cheqd-blockchain-modules';
import {
CheqdAccumulatorModule,
CheqdCoreModules,
} from '@docknetwork/cheqd-blockchain-modules';
import { MultiApiCoreModules } from '@docknetwork/credential-sdk/modules';
import { TypedUUID } from '@docknetwork/credential-sdk/types/generic';

Expand Down Expand Up @@ -47,61 +50,6 @@ const nullIfThrows = async (fn, Err) => {
}
};

const detectAllCycles = (documents) => {
const graph = new Map();

// Build the dependency graph
for (const [did, { controller: controllers }] of documents) {
if (!graph.has(String(did))) graph.set(String(did), []);
for (const controller of controllers) {
if (!graph.has(String(controller))) graph.set(String(controller), []);
graph.get(String(controller)).push(String(did));
}
}

const visited = new Set();
const recStack = new Set();
const allCycles = new Set(); // Store unique cycles as strings

const dfs = (node, path) => {
if (!graph.has(node)) return;

// Mark as visited and add to the recursive stack
visited.add(node);
recStack.add(node);
path.push(node);

for (const neighbor of graph.get(node)) {
if (!visited.has(neighbor)) {
dfs(neighbor, path);
} else if (recStack.has(neighbor)) {
// Cycle detected
const cycle = [];
for (let i = path.length - 1; i >= 0; i--) {
cycle.push(path[i]);
if (path[i] === neighbor) break;
}
cycle.reverse();
allCycles.add(JSON.stringify(cycle)); // Store cycle as a string for uniqueness
}
}

// Remove from the recursive stack after exploring
recStack.delete(node);
path.pop();
};

// Start DFS for all nodes
for (const node of graph.keys()) {
if (!visited.has(node)) {
dfs(node, []);
}
}

// Convert cycles back to arrays
return Array.from(allCycles).map((cycle) => JSON.parse(cycle));
};

const topologicalSort = (documents) => {
// Step 1: Build the dependency graph
const graph = new Map();
Expand Down

0 comments on commit ec4637e

Please sign in to comment.