Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor improvements #24

Merged
merged 4 commits into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,9 @@

Convenient code snippets to interact with [LSP](https://docs.lukso.tech/standards/standards-roadmap) standards on LUKSO. Code examples are taken from the [LUKSO Tech Docs](https://docs.lukso.tech/) and are working as standalone scripts.

### IPFS Servers

We highly recommend that developers fetch and store profile or asset data using **their own IPFS gateway** solutions like [Pinata](https://docs.pinata.cloud/docs/welcome-to-pinata) or [Infura](https://docs.infura.io/networks/ipfs). For development purposes, this repository uses the following RPC to fetch mainnet and testnet data:

- IPFS Gateway: `https://api.universalprofile.cloud/ipfs`

> LUKSO does not provide an official gateway for uploading asset data.

## Contents

- [`convenience`](./convenience): Address Checks and EOA creation
- [`create-profile`](./create-profile): Universal Profile Creation
- [`universal-profile`](./universal-profile): Universal Profile
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- [`universal-profile`](./universal-profile): Universal Profile
- [`universal-profile`](./universal-profile): Universal Profile Creation and Interaction

I am not 100% sure about the description, but it should indicate what to expect within the folder.

- [`extract-data`](./extract-data): Extract LSP3 and LSP4 JSON Data
- [`fetch-asset`](./fetch-asset): Asset-related Data Fetches and Operations
- [`fetch-profile`](./fetch-profile): Profile-related Data and Controller Fetches
Expand All @@ -23,13 +14,14 @@ We highly recommend that developers fetch and store profile or asset data using
- [`metadata-detection`](./metadata-detection): Verify ERC725Y Storage Compatability
- [`transfer-lyx`](./transfer-lyx): Coin Transfers for Backend and Exetnsion
- [`transfer-token`](./transfer-token/): Token Transfers for Backend and Exetnsion
- [`update-profile`](./update-profile/): Update Universal Profile Data

### LUKSO Libraries

- [`@erc725/erc725.js`](https://docs.lukso.tech/tools/erc725js/getting-started): 0.22.0
- [`@lukso/lsp-factory.js`](https://docs.lukso.tech/tools/lsp-factoryjs/getting-started): 3.1.1
- [`@lukso/lsp-smart-contracts`](https://docs.lukso.tech/tools/lsp-smart-contracts/getting-started): 0.14.0
- [`@erc725/erc725.js`](https://docs.lukso.tech/tools/erc725js/getting-started)
- [`@lukso/lsp-factory.js`](https://docs.lukso.tech/tools/lsp-factoryjs/getting-started)
- [`@lukso/lsp-smart-contracts`](https://docs.lukso.tech/tools/lsp-smart-contracts/getting-started)

Please check the versions used in the [`package.json`](./package.json)

## Development

Expand All @@ -53,6 +45,14 @@ Run the Typescript code of one file within the terminal using `bun`.
bun file-path/script.ts
```

## IPFS Server

We highly recommend that developers fetch and store profile or asset data using **their own IPFS gateway** solutions like [Pinata](https://docs.pinata.cloud/docs/welcome-to-pinata) or [Infura](https://docs.infura.io/networks/ipfs). For development purposes, this repository uses the following RPC to fetch mainnet and testnet data:

- IPFS Gateway: `https://api.universalprofile.cloud/ipfs`

> LUKSO does not provide an official gateway for uploading asset data.

### Run in browser

Open this project on [StackBlitz](https://stackblitz.com/github/lukso-network/lukso-playground) and start coding right away.
28 changes: 0 additions & 28 deletions convenience/check_address.ts

This file was deleted.

8 changes: 0 additions & 8 deletions convenience/create-eoa.js

This file was deleted.

1 change: 0 additions & 1 deletion extract-data/extract-asset-data.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// Imports
import { ERC725 } from '@erc725/erc725.js';
import LSP4Schema from '@erc725/erc725.js/schemas/LSP4DigitalAsset.json';
import 'isomorphic-fetch';
Expand Down
1 change: 0 additions & 1 deletion extract-data/extract-profile-data.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// Imports
import { ERC725 } from '@erc725/erc725.js';
import erc725schema from '@erc725/erc725.js/schemas/LSP3ProfileMetadata.json';
import 'isomorphic-fetch';
Expand Down
3 changes: 2 additions & 1 deletion interface-detection/erc165-interface-check.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
// Imports
import { ethers } from 'ethers';
import { ERC725 } from '@erc725/erc725.js';
import lsp4Schema from '@erc725/erc725.js/schemas/LSP4DigitalAsset.json';
import UniversalProfile from '@lukso/lsp-smart-contracts/artifacts/UniversalProfile.json';
import { INTERFACE_IDS } from '@lukso/lsp-smart-contracts';

// https://docs.lukso.tech/contracts/interface-ids

// Asset Example
const myAsset = new ERC725(
lsp4Schema,
Expand Down
1 change: 0 additions & 1 deletion key-manager/set-permissions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// Imports
import { ethers } from 'ethers';
import {
PERMISSIONS,
Expand Down
3 changes: 3 additions & 0 deletions transfer-lyx/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Transfer LYX

- https://docs.lukso.tech/learn/dapp-developer/transfer-lyx
1 change: 0 additions & 1 deletion transfer-lyx/backend-lyx-transaction.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// Imports
import { ethers } from 'ethers';
import UniversalProfile from '@lukso/lsp-smart-contracts/artifacts/UniversalProfile.json';

Expand Down
4 changes: 3 additions & 1 deletion transfer-lyx/regular-lyx-transaction.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
// Imports
import { ethers } from 'ethers';

// Check if the Ethereum provider is available
// @ts-expect-error This is for the browser
const provider = new ethers.BrowserProvider(window.ethereum);

// https://docs.lukso.tech/learn/dapp-developer/transfer-lyx

try {
// Request user accounts (connect to wallet)
const accounts = await provider.send('eth_requestAccounts', []);
Expand Down
3 changes: 3 additions & 0 deletions transfer-token/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Transfer tokens

- https://docs.lukso.tech/learn/dapp-developer/transfer-lsp7-token
1 change: 0 additions & 1 deletion transfer-token/backend-token-transaction.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// Imports
import { ethers } from 'ethers';
import LSP7Mintable from '@lukso/lsp-smart-contracts/artifacts/LSP7Mintable.json';
import UniversalProfile from '@lukso/lsp-smart-contracts/artifacts/UniversalProfile.json';
Expand Down
1 change: 1 addition & 0 deletions transfer-token/regular-token-transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { ethers } from 'ethers';
import LSP7Mintable from '@lukso/lsp-smart-contracts/artifacts/LSP7Mintable.json';

// Connect to Ethereum via MetaMask or similar
// @ts-expect-error This is for the browser
const provider = new ethers.BrowserProvider(window.ethereum);

try {
Expand Down
3 changes: 3 additions & 0 deletions universal-profile/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Universal Profile

- https://docs.lukso.tech/standards/universal-profile/introduction
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// Imports
import { ethers } from 'ethers';

// Static variables
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
// Imports
import { LSPFactory } from '@lukso/lsp-factory.js';
import { ethers } from 'ethers';

// Static variables
// https://docs.lukso.tech/networks/testnet/parameters
const RPC_ENDPOINT = 'https://rpc.testnet.lukso.network';
const CHAIN_ID = 4201;
const CHAIN_ID = 4201; // LUKSO testnet
const PRIVATE_KEY = '0x...'; // Add the private key of your EOA from ../convenience/create-eoa.js

// Initialize ethers.js provider
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// Imports
import { ethers } from 'ethers';
import { ERC725 } from '@erc725/erc725.js';
import { LSPFactory } from '@lukso/lsp-factory.js';
Expand All @@ -8,7 +7,7 @@ import KeyManager from '@lukso/lsp-smart-contracts/artifacts/LSP6KeyManager.json
// Static variables
const RPC_ENDPOINT = 'https://rpc.testnet.lukso.gateway.fm';
const IPFS_GATEWAY = 'https://api.universalprofile.cloud/ipfs';
const CHAIN_ID = 2828;
const CHAIN_ID = 4201;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

haha, good catch ✅

If this is (or we have) a script for dApp devs, maybe these should not be static.

import { ethers } from 'ethers';
const provider = new ethers.BrowserProvider(window.lukso);

const {chainId } = provider.getNetwork()
const universalProfileAddress = await provider.send('eth_requestAccounts', []);

Just as a side note.

const PRIVATE_KEY = '0x...'; // Replace with your private key
const UNIVERSAL_PROFILE_ADDRESS = '0x...'; // Replace with the Universal Profile address

Expand Down