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

New API #33

Merged
merged 59 commits into from
Aug 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
3f691f5
refactor(encode): merge encode + encodeAll
rryter Jul 26, 2021
7b1ae79
chore(docs): make it possible to generate both, html and markdown
rryter Jul 26, 2021
7dca6cb
chore(graphql-provider): update query to match latest version
rryter Jul 30, 2021
09b6766
chore(web3Provider): add type
rryter Jul 30, 2021
51bcfc7
refactor(api): make the API more consistent and easier to understand
rryter Jul 30, 2021
04c4f4a
chore(docs): remove html for now
rryter Jul 30, 2021
b9dce85
Merge branch 'develop' into feature/simplify-api
rryter Jul 30, 2021
e7e9402
chore(deps): remove unneeded deps
rryter Jul 30, 2021
c9a6cd4
chore(test): set apollo test to pending
rryter Jul 30, 2021
9fc1155
refactor(Erc725Schema): rename to ERC725JSONSchema
rryter Jul 30, 2021
a137816
chore(docs): update docs for encode & provide an examples folder
rryter Jul 30, 2021
91ec1c3
chore(naming): make it consistent
rryter Jul 30, 2021
bd1dfd9
chore(example): remove personal reference
rryter Jul 30, 2021
82b373f
chore(encoder): remove obsolete comment
rryter Jul 30, 2021
af3d6bd
chore(naming): make file names consistent with class names
rryter Aug 1, 2021
c50ecd7
refactor(providers): remove obsolete code
rryter Aug 1, 2021
b934374
refactor(encoder): simplify
rryter Aug 1, 2021
1cf3e8d
chore(docs): revert move to subfolder, it's pointless
rryter Aug 1, 2021
f78534b
chore(node): add version file
rryter Aug 1, 2021
41237e9
chore(github): add standard templates
rryter Aug 2, 2021
8cdcf97
chore(fetchData): increase readability
rryter Aug 2, 2021
7a288e2
chore(naming): make JSONURLData more generic
rryter Aug 2, 2021
0abd867
chore(docs): update docs accordingly
rryter Aug 2, 2021
a98d3fb
chore(ERC725): remove invalid imports
rryter Aug 2, 2021
2b7a747
chore(docs): wrapping up
rryter Aug 2, 2021
00ce808
chore(typo): fixed
rryter Aug 3, 2021
5fe6243
chore(examples): update them
rryter Aug 4, 2021
c3a1125
chore(examples): fix async examples
rryter Aug 4, 2021
50c1814
chore(examples): add missing case
rryter Aug 4, 2021
1fbec3b
chore(examples): provide npm commands to run them
rryter Aug 4, 2021
e25cb4e
chore(examples): update stackblitz references
rryter Aug 4, 2021
7a90a3b
chore(readme): pimp it
rryter Aug 4, 2021
99e74a0
chore(readme): fix example on readme
rryter Aug 4, 2021
719875b
chore(readme): add clarification
rryter Aug 4, 2021
5dfcf18
chore(readme): optics
rryter Aug 4, 2021
73b130a
chore(readme): consistency
rryter Aug 4, 2021
8a5d174
chore(readme): optics
rryter Aug 5, 2021
4c6bc79
chore(docs): update guide, fix typo
rryter Aug 6, 2021
414d6d5
chore(utils): add helper function for flattening
rryter Aug 6, 2021
3eef8fb
chore(pr-feedback): first batch of fixes
rryter Aug 10, 2021
19d6764
chore(pr-feedback): cleanup provider tests
rryter Aug 11, 2021
c09a223
chore(pr-feedback): improve readability
rryter Aug 11, 2021
912c2d8
chore(pr-feedback): improve readability
rryter Aug 11, 2021
8d9f3d2
chore(pr-feedback): improve readability
rryter Aug 11, 2021
5dccd75
chore(pr-feedback): improve readability
rryter Aug 11, 2021
d9c2445
chore(pr-feedback): update url for docs examples
rryter Aug 11, 2021
a1e37e0
chore(pr-feedback): avoid npm link in post-install
rryter Aug 11, 2021
4293846
chore(pr-feedback): remove conditional commits docs
rryter Aug 11, 2021
c46647f
chore(docs): remove unclosed code block
rryter Aug 11, 2021
dc00404
chore(docs): remove unnecessary colon
rryter Aug 11, 2021
cf311bf
chore(docs): remove unnecessary colon
rryter Aug 11, 2021
fcca4be
Merge pull request #31 from ERC725Alliance/feature/simplify-api
rryter Aug 13, 2021
b7ce1a0
fix(mocha): increase timeout time
rryter Aug 13, 2021
93476f0
chore(cleanup): move generatedSchema into test folder, for not it's o…
rryter Aug 13, 2021
91b5e16
chore(release): 0.5.8
rryter Aug 13, 2021
bfdf95f
chore(examples): update to latest version
rryter Aug 13, 2021
201161f
chore(docs): update import statements
rryter Aug 13, 2021
cd314d0
chore(npm): do not trigger npm script on npm publish
rryter Aug 13, 2021
5afb6f9
chore(release): 0.6.0
rryter Aug 13, 2021
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
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