Skip to content

Commit

Permalink
Merge pull request #33 from ERC725Alliance/develop
Browse files Browse the repository at this point in the history
New API
  • Loading branch information
rryter authored Aug 13, 2021
2 parents 66e68f1 + 5afb6f9 commit 0c53b1f
Show file tree
Hide file tree
Showing 53 changed files with 7,436 additions and 2,046 deletions.
3 changes: 2 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@
"lines-between-class-members": "off",
"prefer-template": 0, // Allow simple string concatenation
"no-await-in-loop": 0, // NOTE: This should be removed?
"import/prefer-default-export": 0
"import/prefer-default-export": 0,
"arrow-body-style": "off"
},
"ignorePatterns": ["node_modules/**/*", "build/**/*"]
}
2 changes: 1 addition & 1 deletion CONTRIBUTING.md → .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Also follow architectural guidelines (_TODO_)

After you have written your code contributions, make a pull request from your branch.

Use the pull request template (_TODO_) to fill in the request
Use the pull request template to fill in the request

Tests will have to be performed on the PR before it is considered.

Expand Down
9 changes: 9 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
- **I'm submitting a ...**
[ ] bug report
[ ] feature request
[ ] question about the decisions made in the repository
[ ] question about how to use this project

- **Summary**

- **Other information** (e.g. detailed explanation, stack traces, related issues, suggestions how to fix, links for us to have context, eg. StackOverflow, personal fork, etc.)
7 changes: 7 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
- **What kind of change does this PR introduce?** (Bug fix, feature, docs update, ...)

- **What is the current behavior?** (You can also link to an open issue here)

- **What is the new behavior (if this is a feature change)?**

- **Other information**:
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/node_modules
node_modules
/build
/docs/build
docs/html
.vscode/*
.nyc_output
coverage
3 changes: 2 additions & 1 deletion .mocharc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"extension": ["ts"],
"spec": "**/*.test.ts",
"require": "ts-node/register"
"require": "ts-node/register",
"timeout": 5000
}
1 change: 1 addition & 0 deletions .node-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
14.17.0
8 changes: 7 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,10 @@ test
docs
.idea
.vscode
.github
.github
examples
.nyc_output/
generatedSchema.ts
typedoc.html.json
typedoc.json
.mocharc.json
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

### [0.6.0](https://github.com/ERC725Alliance/erc725.js/compare/v0.5.7...v0.6.0) (2021-08-13)

### Feature

- **API:** Adjusted API to be more consistent
- https://github.com/ERC725Alliance/erc725.js/issues/30
- https://github.com/ERC725Alliance/erc725.js/pull/31

### Bug Fixes

- **mocha:** increase timeout time ([b7ce1a0](https://github.com/ERC725Alliance/erc725.js/commit/b7ce1a07711b8251f4447d613c4c5a522b5e263f))

### [0.5.7](https://github.com/ERC725Alliance/erc725.js/compare/v0.2.0...v0.5.7) (2021-07-30)

### Bug Fixes
Expand Down
86 changes: 53 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,47 @@
# erc725.js

Allows for interfacing with ERC725Y compliant contracts on an EVM blockchain using the [ERC725YJSONSchema](https://github.com/lukso-network/LIPs/blob/master/LSPs/LSP-2-ERC725YJSONSchema.md) standard.

![NPM Version](https://badge.fury.io/js/erc725.js.svg)

For more information see [Documentation](https://docs.lukso.tech/tools/erc725js/getting-started).

⚠️⚠️⚠️<br/>
_This package is currently in early stages of development, use only for testing or experimentation purposes_
⚠️⚠️⚠️<br/>
<p align="center">
<h2 align="center"><strong>erc725.js</strong></h2>
<p align="center">Allows for interfacing with <a href="https://github.com/lukso-network/LIPs/blob/master/LSPs/LSP-2-ERC725YJSONSchema.md">ERC725Y</a> compliant contracts on an EVM blockchain.</p>
</p>

<p align="center">
<a href="https://github.com/ERC725Alliance/erc725.js/actions">
<img alt="Version" src="https://badge.fury.io/js/erc725.js.svg" />
</a>

<a href="https://github.com/ERC725Alliance/erc725.js/actions">
<img alt="Tests Passing" src="https://github.com/ERC725Alliance/erc725.js/actions/workflows/node.js.yml/badge.svg" />
</a>
<a href="https://codecov.io/gh/ERC725Alliance/erc725.js">
<img src="https://codecov.io/gh/ERC725Alliance/erc725.js/branch/main/graph/badge.svg" />
</a>
<a href="https://github.com/ERC725Alliance/erc725.js/issues">
<img alt="Issues" src="https://img.shields.io/github/issues/ERC725Alliance/erc725.js?color=0088ff" />
</a>
<a href="https://github.com/ERC725Alliance/erc725.js/pulls">
<img alt="GitHub pull requests" src="https://img.shields.io/github/issues-pr/ERC725Alliance/erc725.js?color=0088ff" />
</a>
</p>
<p align="center">For more information see <a href="https://docs.lukso.tech/tools/erc725js/getting-started">Documentation</a>.</p>

## Installation

| :warning: | _This package is currently in early stages of development,<br/> use for testing or experimentation purposes only._ |
| :-------: | :----------------------------------------------------------------------------------------------------------------- |

```shell script
$ npm install erc725.js
```

```js
import { ERC725 } from 'erc725.js';
import { ERC725 } from '@erc725/erc725.js';
// Or alternatively the default export
import ERC725 from 'erc725.js';
```

## Example Instantiation

```js
import { ERC725 } from 'erc725.js';
import { ERC725 } from '@erc725/erc725.js';
import Web3 from 'web3';

// Part of LSP3-UniversalProfile Schema
Expand Down Expand Up @@ -54,7 +70,7 @@ const schema = [
},
];

const address = '0x0c03fba782b07bcf810deb3b7f0595024a444f4e';
const address = '0x3000783905Cc7170cCCe49a4112Deda952DDBe24';
const provider = new Web3.providers.HttpProvider(
'https://rpc.l14.lukso.network',
);
Expand All @@ -72,40 +88,44 @@ await erc725.getOwner();
// > '0x28D25E70819140daF65b724158D00c373D1a18ee'

await erc725.getData('SupportedStandards:ERC725Account');
// > '0xafdeb5d6'
/* > {
'SupportedStandards:ERC725Account': '0xafdeb5d6'
}
*/

await erc725.getData('LSP3Profile');
/* >
{
url: 'ipfs://QmXybv2LdJWscy1C6yRKUjvnaj6aqKktZX4g4xmz2nyYj2',
hash: '0xb4f9d72e83bbe7e250ed9ec80332c493b7b3d73e0d72f7b2c7ab01c39216eb1a',
hashFunction: 'keccak256(utf8)'
/* > {
LSP3Profile: {
hashFunction: 'keccak256(utf8)',
hash: '0xd96ff7776660095f661d16010c4349aa7478a9129ce0670f771596a6ff2d864a',
url: 'ipfs://QmbTmcbp8ZW23vkQrqkasMFqNg2z1iP4e3BCUMz9PKDsSV'
}
}
*/

await erc725.fetchData('LSP3Profile'); // downloads and verifies the linked JSON
/* >
{
LSP3Profile: {
name: 'frozeman',
description: 'The inventor of ERC725 and ERC20...',
links: [
{ title: 'Twitter', url: 'https://twitter.com/feindura' },
{ title: 'lukso.network', url: 'https://lukso.network' }
],
...
/* > {
LSP3Profile: { // key of the schema
LSP3Profile: { // content of the JSON structure as per https://github.com/lukso-network/LIPs/blob/master/LSPs/LSP-3-UniversalProfile.md
name: '...',
links: [Array],
description: "...",
profileImage: [Array],
backgroundImage: [Array],
tags: [Array]
}
}
}
*/
```

## Bundling for typescript
## Building

```shell script
$ npm run build
```

This will build the library into `/lib`
This will build the library into `/build`

## Testing

Expand All @@ -116,7 +136,7 @@ $ npm test
## Publishing

```shell script
$ npm run build-publish
$ npm run publish
```

Will build and then publish the package to npm.
2 changes: 0 additions & 2 deletions docs/_category_.yml

This file was deleted.

62 changes: 48 additions & 14 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ The `erc725.js` package allows you to easily interact with the ERC-725 schemas.
## Instantiation

```js
import { ERC725 } from 'erc725.js';
import * as Web3 from 'web3';
import { ERC725 } from '@erc725/erc725.js';
import Web3 from 'web3';

// Part of LSP3-UniversalProfile Schema
// https://github.com/lukso-network/LIPs/blob/master/LSPs/LSP-3-UniversalProfile.md
Expand All @@ -45,34 +45,68 @@ const schema = [
valueContent: 'Address',
valueType: 'address',
},
{
name: 'LSP3IssuedAssets[]',
key: '0x3a47ab5bd3a594c3a8995f8fa58d0876c96819ca4516bd76100c92462f2f9dc0',
keyType: 'Array',
valueContent: 'Number',
valueType: 'uint256',
elementValueContent: 'Address',
elementValueType: 'address',
},
];

const address = '0x3000783905Cc7170cCCe49a4112Deda952DDBe24';
const address = '0x0c03fba782b07bcf810deb3b7f0595024a444f4e';
const provider = new Web3.providers.HttpProvider(
'https://rpc.l14.lukso.network',
);
const config = {
ipfsGateway: 'https://ipfs.lukso.network/ipfs/',
};

const myERC725 = new ERC725(schema, address, provider, config);
const erc725 = new ERC725(schema, address, provider, config);
```

## Usage

```js
await erc725.getOwner();
// > '0x28D25E70819140daF65b724158D00c373D1a18ee'

await erc725.getData('SupportedStandards:ERC725Account');
/* >
{
'SupportedStandards:ERC725Account': '0xafdeb5d6'
}
*/

await erc725.getData(['LSP3Profile', 'SupportedStandards:ERC725Account']);
/* >
{
LSP3Profile: {
url: 'ipfs://QmXybv2LdJWscy1C6yRKUjvnaj6aqKktZX4g4xmz2nyYj2',
hash: '0xb4f9d72e83bbe7e250ed9ec80332c493b7b3d73e0d72f7b2c7ab01c39216eb1a',
hashFunction: 'keccak256(utf8)'
},
'SupportedStandards:ERC725Account': '0xafdeb5d6'
}
*/

await erc725.fetchData('LSP3Profile'); // downloads and verifies the linked JSON
/* >
{
LSP3Profile: {
LSP3Profile: {
name: 'frozeman',
description: 'The inventor of ERC725 and ERC20...',
links: [
{ title: 'Twitter', url: 'https://twitter.com/feindura' },
{ title: 'lukso.network', url: 'https://lukso.network' }
],
...
}
}
}
*/
```

:::tip Try it
https://stackblitz.com/edit/erc725js-instantiation?devtoolsheight=66&file=index.js
:::

:::note
Whenever you can you should import `ERC725` via the named export. However currently we are also providing a default export:
Whenever you can you should import `ERC725` via the named export. However currently we are also providing a default export.

```javascript
import ERC725 from 'erc725.js';
Expand Down
14 changes: 8 additions & 6 deletions docs/guides/read-up-with-erc725.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function getData(bytes32 key) external view returns(bytes value)
function setData(bytes32 _key, bytes memory _value) external
```

Without surpise, the [Universal Profile contract](https://github.com/lukso-network/universalprofile-smart-contracts/blob/main/contracts/LSP3Account.sol) implements the ERC725Y standard.
Without surprise, the [Universal Profile contract](https://github.com/lukso-network/universalprofile-smart-contracts/blob/main/contracts/LSP3Account.sol) implements the ERC725Y standard.

Let's take a look at this Universal Profile smart contract: `0x23a86EF830708204646abFE631cA1a60d04c4FbE`.

Expand Down Expand Up @@ -193,11 +193,13 @@ console.log(profileData);
```js title="output"
{
LSP3Profile: {
name: 'hugo',
description: 'Everything tech @ LUKSO 👾',
links: [ [Object] ],
profileImage: [ [Object], [Object], [Object], [Object], [Object] ],
backgroundImage: [ [Object], [Object], [Object], [Object], [Object] ]
LSP3Profile: {
name: 'hugo',
description: 'Everything tech @ LUKSO 👾',
links: [ [Object] ],
profileImage: [ [Object], [Object], [Object], [Object], [Object] ],
backgroundImage: [ [Object], [Object], [Object], [Object], [Object] ]
}
}
}
```
Expand Down
2 changes: 1 addition & 1 deletion docs/providers.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const providerParam = {
};
```

:::note Note
:::info Note
Currently the `link` property of the options object for the Apollo client
is not supported, and known to not function correctly.
:::
Loading

0 comments on commit 0c53b1f

Please sign in to comment.