Skip to content

Commit

Permalink
Merge branch 'main' into lsp23-script
Browse files Browse the repository at this point in the history
  • Loading branch information
fhildeb authored Feb 28, 2024
2 parents 6b6d53b + cb933e7 commit 6d84fc6
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 22 deletions.
22 changes: 17 additions & 5 deletions .github/workflows/build-lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 2 additions & 1 deletion smart-contracts-hardhat/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
34 changes: 18 additions & 16 deletions universal-profile/get-controller-permissions.ts
Original file line number Diff line number Diff line change
@@ -1,35 +1,37 @@
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);
// Instantiate erc725.js with a Universal Profile address on 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
const result = await erc725.getData('AddressPermissions[]');
// https://docs.lukso.tech/standards/universal-profile/lsp6-key-manager/#permissions
// https://docs.lukso.tech/tools/erc725js/classes/ERC725#getdata
const controllerAddresses = await erc725.getData('AddressPermissions[]');

if (!result) {
console.error(
'No controllers listed under UP at address ',
myUniversalProfileAddress,
);
if (!controllerAddresses) {
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;
if (Array.isArray(controllerAddresses.value)) {
// Get the permissions of each controller of the UP
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({
keyName: 'AddressPermissions:Permissions:<address>',
dynamicKeyParts: address,
Expand Down

0 comments on commit 6d84fc6

Please sign in to comment.