From 617058a71762c0983c5fe9ff4033460bc4825ba5 Mon Sep 17 00:00:00 2001 From: oceans404 Date: Tue, 2 Apr 2024 20:07:48 -0700 Subject: [PATCH 1/3] use user_id and party_id members rather than methods --- packages/nextjs/app/nillion-compute/page.tsx | 2 +- packages/nextjs/app/nillion-hello-world-complete/page.tsx | 2 +- packages/nextjs/utils/nillion/compute.ts | 2 +- packages/nextjs/utils/nillion/storeProgram.ts | 2 +- packages/nextjs/utils/nillion/storeSecretsBlob.ts | 2 +- packages/nextjs/utils/nillion/storeSecretsInteger.ts | 4 ++-- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/nextjs/app/nillion-compute/page.tsx b/packages/nextjs/app/nillion-compute/page.tsx index 2e8dcab..3a8e37e 100644 --- a/packages/nextjs/app/nillion-compute/page.tsx +++ b/packages/nextjs/app/nillion-compute/page.tsx @@ -85,7 +85,7 @@ const Home: NextPage = () => { return libraries.nillionClient; }; getNillionClientLibrary().then(nillionClient => { - const user_id = nillionClient.user_id(); + const user_id = nillionClient.user_id; setUserId(user_id); }); } diff --git a/packages/nextjs/app/nillion-hello-world-complete/page.tsx b/packages/nextjs/app/nillion-hello-world-complete/page.tsx index 5bd610c..2318e99 100644 --- a/packages/nextjs/app/nillion-hello-world-complete/page.tsx +++ b/packages/nextjs/app/nillion-hello-world-complete/page.tsx @@ -58,7 +58,7 @@ const Home: NextPage = () => { // call getNillionClientLibrary, then use the returned nillionClient getNillionClientLibrary().then(nillionClient => { // get the user_id from the instance of nillionClient - const user_id = nillionClient.user_id(); + const user_id = nillionClient.user_id; // update state: set user_id setUserId(user_id); }); diff --git a/packages/nextjs/utils/nillion/compute.ts b/packages/nextjs/utils/nillion/compute.ts index d190c8e..9069184 100644 --- a/packages/nextjs/utils/nillion/compute.ts +++ b/packages/nextjs/utils/nillion/compute.ts @@ -20,7 +20,7 @@ export async function compute( // add input and output party details (name and party id) to program bindings const partyName = "Party1"; - const party_id = await nillionClient.party_id(); + const party_id = nillionClient.party_id; program_bindings.add_input_party(partyName, party_id); program_bindings.add_output_party(partyName, party_id); diff --git a/packages/nextjs/utils/nillion/storeProgram.ts b/packages/nextjs/utils/nillion/storeProgram.ts index 75282ed..a6809f5 100644 --- a/packages/nextjs/utils/nillion/storeProgram.ts +++ b/packages/nextjs/utils/nillion/storeProgram.ts @@ -15,7 +15,7 @@ export async function storeProgram(nillionClient: any, programName: string): Pro console.log("Stored program - action_id", action_id); // return the program id - const userId = nillionClient.user_id(); + const userId = nillionClient.user_id; const program_id = `${userId}/${programName}`; return program_id; } catch (error: any) { diff --git a/packages/nextjs/utils/nillion/storeSecretsBlob.ts b/packages/nextjs/utils/nillion/storeSecretsBlob.ts index afe7bce..7d32237 100644 --- a/packages/nextjs/utils/nillion/storeSecretsBlob.ts +++ b/packages/nextjs/utils/nillion/storeSecretsBlob.ts @@ -33,7 +33,7 @@ export async function storeSecretsBlob( const empty_blob_bindings = null; // get user id for user storing the secret - const user_id = await nillionClient.user_id(); + const user_id = await nillionClient.user_id; // create a permissions object, give the storer default perissions const permissions = nillion.Permissions.default_for_user(user_id); diff --git a/packages/nextjs/utils/nillion/storeSecretsInteger.ts b/packages/nextjs/utils/nillion/storeSecretsInteger.ts index c69a86c..cdad738 100644 --- a/packages/nextjs/utils/nillion/storeSecretsInteger.ts +++ b/packages/nextjs/utils/nillion/storeSecretsInteger.ts @@ -33,12 +33,12 @@ export async function storeSecretsInteger( const secret_program_bindings = new nillion.ProgramBindings(program_id); // set the input party to the bindings to specify which party will provide the secret - const party_id = await nillionClient.party_id(); + const party_id = nillionClient.party_id; secret_program_bindings.add_input_party(party_name, party_id); console.log("bindings, party_name:", party_name, "party_id", party_id); // get user id for user storing the secret - const user_id = await nillionClient.user_id(); + const user_id = await nillionClient.user_id; // create a permissions object, give the storer default permissions, including compute permissions with the program id const permissions = nillion.Permissions.default_for_user(user_id, program_id); From 01207b58be6abca529df33c37eb2ea6ce48ef49c Mon Sep 17 00:00:00 2001 From: oceans404 Date: Tue, 2 Apr 2024 20:20:43 -0700 Subject: [PATCH 2/3] remove await for user_id --- packages/nextjs/utils/nillion/storeSecretsBlob.ts | 2 +- packages/nextjs/utils/nillion/storeSecretsInteger.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/nextjs/utils/nillion/storeSecretsBlob.ts b/packages/nextjs/utils/nillion/storeSecretsBlob.ts index 7d32237..fe7133b 100644 --- a/packages/nextjs/utils/nillion/storeSecretsBlob.ts +++ b/packages/nextjs/utils/nillion/storeSecretsBlob.ts @@ -33,7 +33,7 @@ export async function storeSecretsBlob( const empty_blob_bindings = null; // get user id for user storing the secret - const user_id = await nillionClient.user_id; + const user_id = nillionClient.user_id; // create a permissions object, give the storer default perissions const permissions = nillion.Permissions.default_for_user(user_id); diff --git a/packages/nextjs/utils/nillion/storeSecretsInteger.ts b/packages/nextjs/utils/nillion/storeSecretsInteger.ts index cdad738..2d91fc1 100644 --- a/packages/nextjs/utils/nillion/storeSecretsInteger.ts +++ b/packages/nextjs/utils/nillion/storeSecretsInteger.ts @@ -38,7 +38,7 @@ export async function storeSecretsInteger( console.log("bindings, party_name:", party_name, "party_id", party_id); // get user id for user storing the secret - const user_id = await nillionClient.user_id; + const user_id = nillionClient.user_id; // create a permissions object, give the storer default permissions, including compute permissions with the program id const permissions = nillion.Permissions.default_for_user(user_id, program_id); From cb92dd67a5fc71eaca28af03ae5998e239f751a1 Mon Sep 17 00:00:00 2001 From: oceans404 Date: Wed, 3 Apr 2024 05:42:42 -0700 Subject: [PATCH 3/3] bump js version --- packages/nextjs/package.json | 2 +- packages/nillion/bootstrap-local-env.sh | 2 +- yarn.lock | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/nextjs/package.json b/packages/nextjs/package.json index 3f2b9a5..8940a28 100644 --- a/packages/nextjs/package.json +++ b/packages/nextjs/package.json @@ -16,7 +16,7 @@ "dependencies": { "@ethersproject/providers": "^5.7.2", "@heroicons/react": "^2.0.11", - "@nillion/nillion-client-js-browser": "^0.0.9", + "@nillion/nillion-client-js-browser": "^0.1.1", "@rainbow-me/rainbowkit": "1.3.5", "@uniswap/sdk-core": "^4.0.1", "@uniswap/v2-sdk": "^3.0.1", diff --git a/packages/nillion/bootstrap-local-env.sh b/packages/nillion/bootstrap-local-env.sh index 60538f2..959a215 100755 --- a/packages/nillion/bootstrap-local-env.sh +++ b/packages/nillion/bootstrap-local-env.sh @@ -15,7 +15,7 @@ done OUTFILE=$(mktemp); PIDFILE=$(mktemp); -"$NILLION_DEVNET" >"$OUTFILE" & echo $! >"$PIDFILE"; +"$NILLION_DEVNET" --seed scaffold-nillion >"$OUTFILE" & echo $! >"$PIDFILE"; ENV_TO_UPDATE=".env ../nextjs/.env" echo "--------------------" echo "Updating your ${ENV_TO_UPDATE} files with nillion-devnet environment info... This may take a minute." diff --git a/yarn.lock b/yarn.lock index 8218e3c..6f1a921 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1155,10 +1155,10 @@ __metadata: languageName: node linkType: hard -"@nillion/nillion-client-js-browser@npm:^0.0.9": - version: 0.0.9 - resolution: "@nillion/nillion-client-js-browser@npm:0.0.9" - checksum: 445feeb669823be209cd16892f0af41bcedee5789953d8fb29d8fa69701c1ea542b021537d9b4a4bc63f27d246390e872d63fb72ae50307b42c8b619ee641cf1 +"@nillion/nillion-client-js-browser@npm:^0.1.1": + version: 0.1.1 + resolution: "@nillion/nillion-client-js-browser@npm:0.1.1" + checksum: 981e9acc9d56c688c3ec1d4d78559faa107e87b9f2d1f8f8835f75b7434a9ab94f6d9a9e6dd5b90e4de71b51662b31f1a21760b2c42083b650d4c3f1dc3373c9 languageName: node linkType: hard @@ -1931,7 +1931,7 @@ __metadata: dependencies: "@ethersproject/providers": ^5.7.2 "@heroicons/react": ^2.0.11 - "@nillion/nillion-client-js-browser": ^0.0.9 + "@nillion/nillion-client-js-browser": ^0.1.1 "@rainbow-me/rainbowkit": 1.3.5 "@trivago/prettier-plugin-sort-imports": ^4.1.1 "@types/node": ^17.0.35