From 6f1454778c86c28ca78f966778fa8349d03669c6 Mon Sep 17 00:00:00 2001 From: Felix Hildebrandt Date: Fri, 16 Feb 2024 19:36:36 +0100 Subject: [PATCH 1/3] Update LSP6 controller script --- .../get-controller-permissions.ts | 28 +++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/universal-profile/get-controller-permissions.ts b/universal-profile/get-controller-permissions.ts index cdd1968..93b4f22 100644 --- a/universal-profile/get-controller-permissions.ts +++ b/universal-profile/get-controller-permissions.ts @@ -1,43 +1,49 @@ import { ERC725 } from '@erc725/erc725.js'; import LSP6Schema from '@erc725/erc725.js/schemas/LSP6KeyManager.json'; -const myUniversalProfileAddress = '0xEda145b45f76EDB44F112B0d46654044E7B8F319'; - // 💡 Note: You can debug any smart contract by using the ERC725 Tools // 👉 https://erc725-inspect.lukso.tech/inspector?address=0xEda145b45f76EDB44F112B0d46654044E7B8F319&network=testnet -// https://docs.lukso.tech/networks/testnet/parameters -const RPC_ENDPOINT = 'https://rpc.testnet.lukso.network'; - -const erc725 = new ERC725(LSP6Schema, myUniversalProfileAddress, RPC_ENDPOINT); +// Set up Universal Profile on the LUKSO Testnet +const erc725 = new ERC725( + LSP6Schema, + // Sample Profile Address + '0xEda145b45f76EDB44F112B0d46654044E7B8F319', + // LUKSO Testnet RPC + 'https://rpc.testnet.lukso.network', +); // 💡 You can debug permissions from ERC725 Tools // 👉 https://erc725-inspect.lukso.tech/key-manager async function getPermissionedAddresses() { // Get the list of addresses that have permissions on the Universal Profile + // https://docs.lukso.tech/standards/universal-profile/lsp6-key-manager/#permissions + // https://docs.lukso.tech/tools/erc725js/classes/ERC725#getdata const result = await erc725.getData('AddressPermissions[]'); if (!result) { - console.error('No controllers listed under UP at address ', myUniversalProfileAddress); + console.error('No controllers listed under this Universal Profile '); } if (Array.isArray(result.value)) { - // Get the permissions of each address - for (let ii = 0; ii < result.value.length; ii++) { - const address = result.value[ii] as string; + // Get the permissions of each controller of the UP + for (let i = 0; i < result.value.length; i++) { + const address = result.value[i] as string; + // https://docs.lukso.tech/tools/erc725js/classes/ERC725#getdata const addressPermission = await erc725.getData({ keyName: 'AddressPermissions:Permissions:
', dynamicKeyParts: address, }); // Decode the permission of each address + // https://docs.lukso.tech/tools/erc725js/classes/ERC725#decodepermissions const decodedPermission = erc725.decodePermissions(addressPermission.value as string); // Display the permission in a readable format console.log( - `decoded permission for ${address} = ` + JSON.stringify(decodedPermission, null, 2), + `Decoded permission for ${address} = ` + JSON.stringify(decodedPermission, null, 2), ); } } From 8449eb415e9c1a8f4fe2d78ecd01ffb01f82ca8c Mon Sep 17 00:00:00 2001 From: Felix Hildebrandt Date: Mon, 19 Feb 2024 19:07:28 +0100 Subject: [PATCH 2/3] apply suggestions --- universal-profile/get-controller-permissions.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/universal-profile/get-controller-permissions.ts b/universal-profile/get-controller-permissions.ts index 93b4f22..aeeccb2 100644 --- a/universal-profile/get-controller-permissions.ts +++ b/universal-profile/get-controller-permissions.ts @@ -4,7 +4,7 @@ import LSP6Schema from '@erc725/erc725.js/schemas/LSP6KeyManager.json'; // 💡 Note: You can debug any smart contract by using the ERC725 Tools // 👉 https://erc725-inspect.lukso.tech/inspector?address=0xEda145b45f76EDB44F112B0d46654044E7B8F319&network=testnet -// Set up Universal Profile on the LUKSO Testnet +// Instantiate erc725.js with a Universal Profile address on Testnet const erc725 = new ERC725( LSP6Schema, // Sample Profile Address @@ -20,16 +20,16 @@ async function getPermissionedAddresses() { // Get the list of addresses that have permissions on the Universal Profile // https://docs.lukso.tech/standards/universal-profile/lsp6-key-manager/#permissions // https://docs.lukso.tech/tools/erc725js/classes/ERC725#getdata - const result = await erc725.getData('AddressPermissions[]'); + const controllerAddresses = await erc725.getData('AddressPermissions[]'); - if (!result) { + if (!controllerAddresses) { console.error('No controllers listed under this Universal Profile '); } - if (Array.isArray(result.value)) { + if (Array.isArray(controllerAddresses.value)) { // Get the permissions of each controller of the UP - for (let i = 0; i < result.value.length; i++) { - const address = result.value[i] as string; + for (let i = 0; i < controllerAddresses.value.length; i++) { + const address = controllerAddresses.value[i] as string; // https://docs.lukso.tech/tools/erc725js/classes/ERC725#getdata const addressPermission = await erc725.getData({ From 6c0a8b0c2bc92f13c35db18e9fe4806683734fb6 Mon Sep 17 00:00:00 2001 From: Hugo Masclet Date: Thu, 22 Feb 2024 16:48:41 +0100 Subject: [PATCH 3/3] Split CI for harhdat and the rest --- .github/workflows/build-lint.yaml | 22 +++++++++++++++++----- smart-contracts-hardhat/package.json | 3 ++- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-lint.yaml b/.github/workflows/build-lint.yaml index c4e9d20..4729767 100644 --- a/.github/workflows/build-lint.yaml +++ b/.github/workflows/build-lint.yaml @@ -14,18 +14,30 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - name: 🔄 Checkout + uses: actions/checkout@v4 - - name: Setup Bun + - name: 🛠️ Setup Bun uses: oven-sh/setup-bun@v1 with: bun-version: latest + # Everything for the root scripts - name: 📦 Install dependencies run: bun install - - name: 🎨 Run ESLint on JS/TS files + - name: 🎨 Lint run: bun run lint - - name: 👷 Build contracts on Hardhat folders - run: cd smart-contracts-hardhat && bun install && bun run build + # Everything Hardhat related + - name: 📦 Install Hardhat dependencies + working-directory: ./smart-contracts-hardhat + run: bun install + + - name: 🎨 Lint Hardhat folder + working-directory: ./smart-contracts-hardhat + run: bun run lint + + - name: 👷 Build contracts + working-directory: ./smart-contracts-hardhat + run: bun run build diff --git a/smart-contracts-hardhat/package.json b/smart-contracts-hardhat/package.json index b9ec641..c161ebf 100644 --- a/smart-contracts-hardhat/package.json +++ b/smart-contracts-hardhat/package.json @@ -1,7 +1,8 @@ { "name": "hardhat-project", "scripts": { - "build": "hardhat compile --show-stack-traces" + "build": "hardhat compile --show-stack-traces", + "lint": "eslint ." }, "devDependencies": { "@nomicfoundation/hardhat-toolbox": "^3.0.0",