Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed config to support V8 envs #152

Open
wants to merge 64 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
8de43db
Changed config to support V8 envs
u-hubar Oct 4, 2024
d06f979
Deprecated Update operation
u-hubar Oct 4, 2024
eea858d
Update paranet create (registerParanet) function
zsculac Oct 7, 2024
f838a1a
Create addCuratedNodes (addParanetCuratedNodes) function
zsculac Oct 7, 2024
9d3ce71
Create removeCuratedNodes (removeParanetCuratedNodes) function
zsculac Oct 7, 2024
479ff7d
Create requestCuratedNodeAccess (requestParanetCuratedNodeAccess) fun…
zsculac Oct 8, 2024
0344cbb
Create approveCuratedNode function
zsculac Oct 8, 2024
054c060
Create rejectCuratedNode function
zsculac Oct 8, 2024
87477c7
Create addCuratedMiners (addParanetCuratedMiners) function
zsculac Oct 8, 2024
93ad469
Create removeCuratedMiners (removeParanetCuratedMiners) function
zsculac Oct 8, 2024
bd5e005
Create requestCuratedMinerAccess (requestParanetCuratedMinerAccess) f…
zsculac Oct 8, 2024
91371a1
Create approveCuratedMiner function
zsculac Oct 8, 2024
122ae41
Create approveCuratedMiner function
zsculac Oct 8, 2024
988fe89
Fix issues
zsculac Oct 8, 2024
1bb4ce2
Add curated paranet demo
zsculac Oct 9, 2024
0f87043
Add curated paranet demo
zsculac Oct 9, 2024
4f4ef37
Better error response logging
zsculac Oct 10, 2024
053d1d6
Add PARANET_NODES_ACCESS_POLICY and PARANET_MINERS_ACCESS_POLICY cons…
zsculac Oct 11, 2024
4504847
Remove unnecessary paranet options
zsculac Oct 11, 2024
db2fba1
Update paranetCreate and add new paranetCreate functon (#151)
Mihajlo-Pavlovic Oct 11, 2024
17048d1
Merge branch 'feature/update-paranets-functionality' into v8/develop
Mihajlo-Pavlovic Oct 11, 2024
6c15ce9
Update paranetCreate and add new paranetCreate functon (#151) (#155)
Mihajlo-Pavlovic Oct 11, 2024
3efea4d
Change optional and required params
zsculac Oct 11, 2024
f2954bf
fixes (#156)
Mihajlo-Pavlovic Oct 11, 2024
e7492ef
version bump
Mihajlo-Pavlovic Oct 11, 2024
624a0aa
Merge branch 'v8/develop' into feature/update-paranets-functionality
zsculac Oct 11, 2024
fc427fb
Remove unsused variables
zsculac Oct 11, 2024
2583f49
Make paranetUAL a mandatory parameter in submitToParanet function
zsculac Oct 14, 2024
28af4e7
Remove unnecessary functions from input service
zsculac Oct 14, 2024
75176f2
Simplify curated-paranet-demo
zsculac Oct 14, 2024
f914a00
Add dynamic fetch of identityIds
zsculac Oct 15, 2024
0b73ab6
Removed identity module, moved getIdentityId to node module
u-hubar Oct 15, 2024
80b0e1a
Update curated paranet demo
u-hubar Oct 15, 2024
2130ffb
Merge pull request #157 from OriginTrail/feature/update-paranets-func…
u-hubar Oct 15, 2024
48fbc76
Minor fixes
u-hubar Oct 15, 2024
7384a9b
Added separate functions for mint/publish/local-store
u-hubar Oct 15, 2024
d8ded87
Rebuilded webpack package
u-hubar Oct 15, 2024
22dc54a
Removed get for unfinalized state
u-hubar Oct 16, 2024
844a8db
Removed mint/local-store/publish
u-hubar Oct 16, 2024
d5b7457
Fixed constants
u-hubar Oct 16, 2024
8502344
Merge pull request #161 from OriginTrail/v8/minor-fixes
u-hubar Oct 16, 2024
4473402
Removed redundant constant
u-hubar Oct 16, 2024
0fb90b9
Fix get
Mihajlo-Pavlovic Oct 17, 2024
f9907c1
Add parenthersis and remove redundant guard
Mihajlo-Pavlovic Oct 17, 2024
b0d2c5e
Rebuilded webpack package
u-hubar Oct 17, 2024
03767ec
Merge pull request #162 from OriginTrail/fix/curated-paranet
u-hubar Oct 17, 2024
5dd3c17
Updated createParanet
u-hubar Oct 18, 2024
657fc28
Renamed createParanet function to localStore
u-hubar Oct 18, 2024
97a3f6d
Merge pull request #163 from OriginTrail/v8/curated-paranet-local-store
u-hubar Oct 21, 2024
15ae508
Updated curated paranet demo
u-hubar Oct 23, 2024
4ee0829
Add catching logic
Mihajlo-Pavlovic Nov 18, 2024
3f1ee07
delete catched file
Mihajlo-Pavlovic Nov 18, 2024
c57fd9b
Delete catche on fail
Mihajlo-Pavlovic Nov 18, 2024
d3bd2a9
Add error handling for axios getOperationResult
Mihajlo-Pavlovic Nov 18, 2024
84d027d
Safe status setup
Mihajlo-Pavlovic Nov 18, 2024
da2ebd7
Safe status setup
Mihajlo-Pavlovic Nov 18, 2024
f936cd7
version bump
Mihajlo-Pavlovic Nov 18, 2024
66ed903
Removed duplicate private assertion id, updated assertion-tools
u-hubar Nov 18, 2024
4416915
Removed demo.js comments
u-hubar Nov 18, 2024
788596e
Merge pull request #170 from OriginTrail/feature/local-store-from-file
u-hubar Nov 18, 2024
eb2ce7b
Merge pull request #172 from OriginTrail/improvement/no-private-asser…
u-hubar Nov 18, 2024
c03e465
Added missing awaits, removed duplicate merkle root calculation for p…
u-hubar Nov 18, 2024
94bdde3
Updated assertion-tools
u-hubar Nov 18, 2024
9545d4f
Fix status check on local store (#173)
Mihajlo-Pavlovic Nov 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 37 additions & 41 deletions constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @constant {number} MAX_FILE_SIZE
* - Max file size for publish
*/
const MAX_FILE_SIZE = 2621440;
const MAX_FILE_SIZE = 524288000;

/**
* @constant {number} DID_PREFIX
Expand All @@ -24,56 +24,38 @@ const BLOCKCHAINS = {
rpc: 'http://localhost:9545',
hubContract: '0x5FbDB2315678afecb367f032d93F642f64180aa3',
},
'otp:2043': {
rpc: 'http://parachain-alphanet-02.origin-trail.network:9933',
hubContract: '0x7585a99C5C150a08f5CDeFD16465C6De8D41EbbD',
},
},
devnet: {
'otp:2160': {
rpc: 'https://lofar-tm-rpc.origin-trail.network',
hubContract: '0x833048F6e6BEa78E0AAdedeCd2Dc2231dda443FB',
},
'gnosis:10200': {
rpc: 'https://rpc.chiadochain.net',
hubContract: '0xD2bA102A0b11944d00180eE8136208ccF87bC39A',
gasPriceOracleLink: 'https://blockscout.chiadochain.net/api/v1/gas-price-oracle',
},
devnet: {},
stabledevnet_staging: {
'base:84532': {
hubContract: '0x6C861Cb69300C34DfeF674F7C00E734e840C29C0',
hubContract: '0xAB4A4794Fc1F415C24807B947280aCa8dC492238',
rpc: 'https://sepolia.base.org',
},
},
testnet: {
'otp:20430': {
rpc: 'https://lofar-testnet.origin-trail.network',
hubContract: '0xBbfF7Ea6b2Addc1f38A0798329e12C08f03750A6',
},
'gnosis:10200': {
rpc: 'https://rpc.chiadochain.net',
hubContract: '0xC06210312C9217A0EdF67453618F5eB96668679A',
gasPriceOracleLink: 'https://blockscout.chiadochain.net/api/v1/gas-price-oracle',
},
stabledevnet_prod: {
'base:84532': {
hubContract: '0x144eDa5cbf8926327cb2cceef168A121F0E4A299',
hubContract: '0xaA849CAC4FA86f6b7484503f3c7a314772AED6d4',
rpc: 'https://sepolia.base.org',
},
},
mainnet: {
'otp:2043': {
rpc: 'https://astrosat-parachain-rpc.origin-trail.network',
hubContract: '0x5fA7916c48Fe6D5F1738d12Ad234b78c90B4cAdA',
},
'gnosis:100': {
rpc: 'https://rpc.gnosischain.com/',
hubContract: '0xbEF14fc04F870c2dD65c13Df4faB6ba01A9c746b',
gasPriceOracleLink: 'https://api.gnosisscan.io/api?module=proxy&action=eth_gasPrice',
},
'base:8453': {
hubContract: '0xaBfcf2ad1718828E7D3ec20435b0d0b5EAfbDf2c',
rpc: 'https://mainnet.base.org',
testnet: {
// This is V8 TESTNET HUB don't use this for V6
'base:84532': {
hubContract: '0xCca0eA14540588A09c85cD6A6Fc53eA3A7010692',
rpc: 'https://sepolia.base.org',
},
},
mainnet: {},
};

const PARANET_NODES_ACCESS_POLICY = {
OPEN: 0,
CURATED: 1,
};

const PARANET_MINERS_ACCESS_POLICY = {
OPEN: 0,
CURATED: 1,
};

const INCENTIVE_TYPE = {
Expand Down Expand Up @@ -111,9 +93,9 @@ const WEBSOCKET_PROVIDER_OPTIONS = {
const OPERATIONS = {
PUBLISH: 'publish',
GET: 'get',
UPDATE: 'update',
LOCAL_STORE: 'local-store',
QUERY: 'query',
PUBLISH_PARANET: 'publishParanet',
};

const OPERATION_STATUSES = {
Expand Down Expand Up @@ -145,6 +127,7 @@ const ASSET_STATES = {

const STORE_TYPES = {
TRIPLE: 'TRIPLE',
TRIPLE_PARANET: 'TRIPLE_PARANET',
PENDING: 'PENDING',
};

Expand Down Expand Up @@ -185,6 +168,12 @@ const DEFAULT_PROXIMITY_SCORE_FUNCTIONS_PAIR_IDS = {
'gnosis:10200': 2,
'base:84532': 2,
},
stabledevnet_staging: {
'base:84532': 2,
},
stabledevnet_prod: {
'base:84532': 2,
},
testnet: {
'otp:20430': 2,
'gnosis:10200': 2,
Expand Down Expand Up @@ -240,6 +229,10 @@ const BID_SUGGESTION_RANGE_ENUM = [
ALL_BID_SUGGESTION,
];

const PARANET_KNOWLEDGE_ASSET_ACCESS_POLICY = {
OPEN: 0,
};

module.exports = {
MAX_FILE_SIZE,
DID_PREFIX,
Expand Down Expand Up @@ -273,4 +266,7 @@ module.exports = {
HIGH_BID_SUGGESTION,
ALL_BID_SUGGESTION,
BID_SUGGESTION_RANGE_ENUM,
PARANET_NODES_ACCESS_POLICY,
PARANET_MINERS_ACCESS_POLICY,
PARANET_KNOWLEDGE_ASSET_ACCESS_POLICY,
};
2 changes: 1 addition & 1 deletion dist/dkg.min.js

Large diffs are not rendered by default.

16 changes: 10 additions & 6 deletions dist/dkg.min.js.LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/*!
* Copyright (c) 2016-2021 Digital Bazaar, Inc. All rights reserved.
*/

/*!
* Copyright (c) 2016-2022 Digital Bazaar, Inc. All rights reserved.
*/

/*!
* The buffer module from node.js, for the browser.
*
Expand All @@ -7,15 +15,11 @@

/*! MIT License. Copyright 2015-2022 Richard Moore <[email protected]>. See LICENSE.txt. */

/*! https://mths.be/punycode v1.4.1 by @mathias */

/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */

/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */

/*! noble-secp256k1 - MIT License (c) 2019 Paul Miller (paulmillr.com) */

/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */

/**
* A JavaScript implementation of the JSON-LD API.
Expand Down
200 changes: 200 additions & 0 deletions examples/curated-paranet-demo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
const jsonld = require('jsonld');
const DKG = require('../index.js');

const ENVIRONMENT = 'development';
const OT_NODE_HOSTNAME = 'http://localhost';
const OT_NODE_PORT = '8900';
const PUBLIC_KEY = '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266';
const PRIVATE_KEY = '0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80';
const {
PARANET_NODES_ACCESS_POLICY,
PARANET_MINERS_ACCESS_POLICY,
} = require('../constants.js');

const DkgClient = new DKG({
environment: ENVIRONMENT,
endpoint: OT_NODE_HOSTNAME,
port: OT_NODE_PORT,
blockchain: {
name: 'hardhat2',
publicKey: PUBLIC_KEY,
privateKey: PRIVATE_KEY,
},
maxNumberOfRetries: 30,
frequency: 2,
contentType: 'all',
});

const NODE1_KEYS = {
publicKey: '0x70997970C51812dc3A010C7d01b50e0d17dc79C8',
privateKey: '0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d'
}

const NODE2_KEYS = {
publicKey: '0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC',
privateKey: '0x5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a'
}

const NODE3_KEYS = {
publicKey: '0x90F79bf6EB2c4f870365E785982E1f101E93b906',
privateKey: '0x7c852118294e51e653712a81e05800f419141751be58f605c371e15141b007a6'
}

const NODE4_KEYS = {
publicKey: '0xe5beaB7853A22f054Ef287EA62aCe7A32528b3eE',
privateKey: '0x9904da7fe786e5d1f8629b565b688425d78053d4325e746c5ad8ac4328248037'
}

const NODE5_KEYS = {
publicKey: '0x8A4673B00B04b59CaC44926ABeDa85ed181fA436',
privateKey: '0xfb07091daf99c1d493820ae8dcbc439b48b13ca844684bb1dcae27c9e680e62b'
}

function divider() {
console.log('==================================================');
console.log('==================================================');
console.log('==================================================');
}

(async () => {

divider();

const nodeInfo = await DkgClient.node.info();
console.log('======================== NODE INFO RECEIVED');
console.log(nodeInfo);

divider();

let content = {
public: {
'@context': ['https://schema.org'],
'@id': 'uuid:1',
company: 'ParanetOperatorsDAO',
user: {
'@id': 'uuid:user:1',
},
city: {
'@id': 'uuid:Belgrade',
},
}
};

divider();

const paranetAssetResult = await DkgClient.asset.create(content, { epochsNum: 2 });
console.log('======================== PARANET KNOWLEDGE ASSET CREATED');
console.log(paranetAssetResult);

divider();

const paranetOptions = {
paranetName: 'FirstParanet',
paranetDescription: 'First ever paranet on DKG!',
paranetNodesAccessPolicy: PARANET_NODES_ACCESS_POLICY.CURATED,
paranetMinersAccessPolicy: PARANET_MINERS_ACCESS_POLICY.CURATED,
};
const paranetRegistered = await DkgClient.paranet.create(paranetAssetResult.UAL, paranetOptions);
console.log('======================== A CURATED PARANET REGISTERED');
console.log(paranetRegistered);
divider();

const node1IdentityId = await DkgClient.node.getIdentityId(NODE1_KEYS.publicKey);
const node2IdentityId = await DkgClient.node.getIdentityId(NODE2_KEYS.publicKey);
const node3IdentityId = await DkgClient.node.getIdentityId(NODE3_KEYS.publicKey);
let identityIds = [node1IdentityId, node2IdentityId, node3IdentityId];
await DkgClient.paranet.addCuratedNodes(paranetAssetResult.UAL, identityIds);
console.log('======================== ADDED NODES TO A CURATED PARANET');
let nodes = await DkgClient.paranet.getCuratedNodes(paranetAssetResult.UAL);
console.log({
paranetUAL: paranetAssetResult.UAL,
curatedNodes: nodes
});
divider();

identityIds = [node2IdentityId, node3IdentityId];
await DkgClient.paranet.removeCuratedNodes(paranetAssetResult.UAL, identityIds);
console.log('======================== REMOVED NODES FROM A CURATED PARANET');
nodes = await DkgClient.paranet.getCuratedNodes(paranetAssetResult.UAL);
console.log({
paranetUAL: paranetAssetResult.UAL,
curatedNodes: nodes
});
divider();

await DkgClient.paranet.requestCuratedNodeAccess(paranetAssetResult.UAL, { blockchain: NODE2_KEYS });
await DkgClient.paranet.rejectCuratedNode(paranetAssetResult.UAL, node2IdentityId);
console.log("======================== REJECT A NODE'S ACCESS REQUEST TO A CURATED PARANET");
nodes = await DkgClient.paranet.getCuratedNodes(paranetAssetResult.UAL);
console.log({
paranetUAL: paranetAssetResult.UAL,
curatedNodes: nodes
});
divider();

await DkgClient.paranet.requestCuratedNodeAccess(paranetAssetResult.UAL, { blockchain: NODE2_KEYS });
await DkgClient.paranet.approveCuratedNode(paranetAssetResult.UAL, node2IdentityId);
console.log("======================== APPROVE A NODE'S ACCESS REQUEST TO A CURATED PARANET");
nodes = await DkgClient.paranet.getCuratedNodes(paranetAssetResult.UAL);
console.log({
paranetUAL: paranetAssetResult.UAL,
curatedNodes: nodes
});
divider();

let minerAddresses = [NODE3_KEYS.publicKey, NODE4_KEYS.publicKey, NODE5_KEYS.publicKey];
await DkgClient.paranet.addCuratedMiners(paranetAssetResult.UAL, minerAddresses);
console.log('======================== ADDED KNOWLEDGE MINERS TO A CURATED PARANET');
let miners = await DkgClient.paranet.getKnowledgeMiners(paranetAssetResult.UAL);
console.log({
paranetUAL: paranetAssetResult.UAL,
knowledgeMiners: miners
});
divider();

minerAddresses = [NODE4_KEYS.publicKey, NODE5_KEYS.publicKey];
await DkgClient.paranet.removeCuratedMiners(paranetAssetResult.UAL, minerAddresses);
console.log('======================== REMOVED KNOWLEDGE MINERS FROM A CURATED PARANET');
miners = await DkgClient.paranet.getKnowledgeMiners(paranetAssetResult.UAL);
console.log({
paranetUAL: paranetAssetResult.UAL,
knowledgeMiners: miners
});
divider();

let minerAddress = NODE4_KEYS.publicKey;
await DkgClient.paranet.requestCuratedMinerAccess(paranetAssetResult.UAL, { blockchain: NODE4_KEYS });
await DkgClient.paranet.rejectCuratedMiner(paranetAssetResult.UAL, minerAddress);
console.log("======================== REJECT A KNOWLEDGE MINER'S ACCESS REQUEST TO A CURATED PARANET");
miners = await DkgClient.paranet.getKnowledgeMiners(paranetAssetResult.UAL);
console.log({
paranetUAL: paranetAssetResult.UAL,
curatedMiners: miners
});
divider();

await DkgClient.paranet.requestCuratedMinerAccess(paranetAssetResult.UAL, { blockchain: NODE4_KEYS });
await DkgClient.paranet.approveCuratedMiner(paranetAssetResult.UAL, minerAddress);
console.log("======================== APPROVE A KNOWLEDGE MINER'S ACCESS REQUEST TO A CURATED PARANET");
miners = await DkgClient.paranet.getKnowledgeMiners(paranetAssetResult.UAL);
console.log({
paranetUAL: paranetAssetResult.UAL,
curatedMiners: miners
});
divider();

const localStoreFirstAssetResult = await DkgClient.asset.localStore(content, { epochsNum: 2, paranetUAL: paranetAssetResult.UAL, blockchain: NODE3_KEYS });
console.log('======================== MINT A KA, LOCAL STORE AND SUBMIT IT TO A CURATED PARANET - KNOWLEDGE MINER IS APPROVED');
console.log(localStoreFirstAssetResult);
divider();

let localStoreSecondAssetResult
try {
await DkgClient.asset.localStore(content, { epochsNum: 2, paranetUAL: paranetAssetResult.UAL, blockchain: NODE5_KEYS });
} catch (error) {
localStoreSecondAssetResult = error.message;
}
console.log('======================== MINT A KA, LOCAL STORE AND SUBMIT IT TO A CURATED PARANET - KNOWLEDGE MINER IS NOT APPROVED');
console.log(localStoreSecondAssetResult);
divider();
})();
Loading