diff --git a/docs/devdocs/Encryption and Privacy/Permits-Access-Control.md b/docs/devdocs/Encryption and Privacy/Permits-Access-Control.md index 70bc309e..2e0f0976 100644 --- a/docs/devdocs/Encryption and Privacy/Permits-Access-Control.md +++ b/docs/devdocs/Encryption and Privacy/Permits-Access-Control.md @@ -22,13 +22,21 @@ The inclusion of this public key into the permit enables a secure process of dat #### How to Generate a Permit -Permits are generated using the `getPermit` method in `fhenix.js`. This method requires the following parameters: +Permits are generated using the `generatePermit` method in `fhenix.js`. This method receives the following parameters: * `contractAddress` (required, string): The address of the contract. -* `provider` (required): An `ethers` (or compatible) object that can sign EIP-712 formatted data. (Note that if you want to unseal data using your wallet's encryption key you can't use "JsonRpcProvider") +* `provider` (optional): An `ethers` (or compatible) object that can sign EIP-712 formatted data. (Note that if you want to unseal data using your wallet's encryption key you can't use "JsonRpcProvider") +* `signer` (optional): Another `ethers` (or compatible) signer if you want to use a different signer than the one in the provider (chain-id requests are still made via the provider) ```javascript -const permit = await getPermit(contractAddress); +const permit = await generatePermit(contractAddress); + +// passing a custom signer +let permit = await fhenixjs.generatePermit( + contractAddress, + undefined, // use the internal provider + signer, // created from, e.g. `ethers.getSigners()[0]` +); ``` #### What is a Permission? @@ -57,9 +65,8 @@ import { FhenixClient, getPermit } from "fhenixjs"; const provider = new BrowserProvider(window.ethereum); const client = new FhenixClient({ provider }); -const permit = await getPermit(contractAddress, provider); +const permit = await generatePermit(contractAddress, provider); const permission = client.extractPemitPermissions(permit); -client.storePermit(permit); // Stores a permit for a specific contract address. const response = await contract.connect(owner).getValue(permission); // Calling "getValue" which is a view function in "contract" const plaintext = await client.unseal(contractAddress, response); ``` diff --git a/docs/devdocs/Examples and References/Templates.md b/docs/devdocs/Examples and References/Templates.md index 1df5ca0e..fc0ce2e8 100644 --- a/docs/devdocs/Examples and References/Templates.md +++ b/docs/devdocs/Examples and References/Templates.md @@ -9,7 +9,7 @@ We compiled a list of a few templates that you can use as a reference to build y https://github.com/FhenixProtocol/fhenix-hardhat-example -Has a basic contract, some tasks and a simple frontend (TODO: copy over from playground). +Has a basic contract, some tasks and a simple frontend. ### Nuxt 3 + Fhenixjs + Ethers.js + Bootstrap Starter diff --git a/docs/devdocs/FhenixJS/Decryption.md b/docs/devdocs/FhenixJS/Decryption.md index 345c624b..802abbad 100644 --- a/docs/devdocs/FhenixJS/Decryption.md +++ b/docs/devdocs/FhenixJS/Decryption.md @@ -33,14 +33,12 @@ This is done in 3 steps: generating a permit, querying the contract and unsealin #### 1. Creating a Permit ```javascript -import { FhenixClient, getPermit } from 'fhenixjs'; +import { FhenixClient, generatePermit } from 'fhenixjs'; const provider = new ethers.JsonRpcProvider('https://api.helium.fhenix.zone/'); const client = new FhenixClient({ provider }); - -const permit = await getPermit(contractAddress, provider); -client.storePermit(permit); +const permit = await generatePermit(contractAddress, provider); ``` :::tip[Did you know?] @@ -74,18 +72,16 @@ Permits are currently limited to support a single contract #### Putting it all Together ```typescript -import { FhenixClient, getPermit } from 'fhenixjs'; +import { FhenixClient, generatePermit } from 'fhenixjs'; import { JsonRpcProvider } from 'ethers'; const provider = new ethers.JsonRpcProvider('https://api.helium.fhenix.zone/'); const client = new FhenixClient({provider}); -const permit = await getPermit(contractAddress, provider); -client.storePermit(permit); - +const permit = await generatePermit(contractAddress, provider); const permission = client.extractPermitPermission(permit); -const response = await contract.balanceOf(permission); +const response = await contract.balanceOf(permission); const plaintext = client.unseal(contractAddress, response); console.log(`My Balance: ${plaintext}`) diff --git a/docs/devdocs/FhenixJS/Encryption.md b/docs/devdocs/FhenixJS/Encryption.md index 9d9e2683..9f980f68 100644 --- a/docs/devdocs/FhenixJS/Encryption.md +++ b/docs/devdocs/FhenixJS/Encryption.md @@ -57,6 +57,7 @@ The `EncryptedUint` types sound scary, but are actually pretty simple. It's just ```typescript export interface EncryptedNumber { data: Uint8Array; + securityZone: number; // defaults to 0 } export interface EncryptedUint8 extends EncryptedNumber {}