Skip to content

Commit

Permalink
update demo
Browse files Browse the repository at this point in the history
  • Loading branch information
confxsd committed Apr 17, 2024
1 parent 875519b commit ca2cf4d
Show file tree
Hide file tree
Showing 3 changed files with 381 additions and 22 deletions.
21 changes: 5 additions & 16 deletions sdk-demo/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import IndexClient from "@indexnetwork/sdk";

// add your key here
const privateKey =
"bf2d4ae856c8fb6a32b07dc40778800ff9dafabbaaf65e96384866008cd3ef59";
const privateKey = "";

async function main() {
try {
Expand All @@ -15,7 +14,7 @@ async function main() {

await indexClient.authenticate();

const teamNode = {
const sampleTeamNode = {
teamId: "cldvnxydg01n5u21kcdgywqa8",
name: "$STYLE Protocol",
logo: "https://files.plnetwork.io",
Expand Down Expand Up @@ -179,10 +178,10 @@ async function main() {

const createdNode = await indexClient.createNode(
"kjzl6hvfrbw6cb9d3i74xp3iuooxhw04k3pumj6zyzxlvkvzyd6qaus3jihej7h",
teamNode,
sampleTeamNode,
);

console.log("createdNode:", createdNode.id, createdNode.name);
console.log("Created Node:", createdNode.id, createdNode.name);

const node = await indexClient.getNodeById(
"kjzl6hvfrbw6cb9d3i74xp3iuooxhw04k3pumj6zyzxlvkvzyd6qaus3jihej7h",
Expand All @@ -191,16 +190,6 @@ async function main() {

console.log("Get Node:", node.id, node.name);

teamNode.name = "Updated $STYLE Protocol";

const updatedNode = await indexClient.updateNode(
"kjzl6hvfrbw6cb9d3i74xp3iuooxhw04k3pumj6zyzxlvkvzyd6qaus3jihej7h",
createdNode.id,
teamNode,
);

console.log("updatedNode:", updatedNode.id, updatedNode.name);

// const did = "";
// const indexes = await indexClient.getAllIndexes(did);
// console.log(indexes);
Expand All @@ -219,7 +208,7 @@ async function main() {

const addedItem = await indexClient.addItemToIndex(
newIndex.id,
updatedNode.id,
createdNode.id,
);
console.log("Added Item to Index:", addedItem);

Expand Down
4 changes: 3 additions & 1 deletion sdk-demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@
"main": "index.js",
"type": "module",
"license": "MIT",
"dependencies": {}
"dependencies": {
"@indexnetwork/sdk": "^0.0.8"
}
}
Loading

0 comments on commit ca2cf4d

Please sign in to comment.