Skip to content

Commit

Permalink
Merge pull request #129 from lukso-network/update-erc725.js
Browse files Browse the repository at this point in the history
Update erc725.js
  • Loading branch information
CallumGrindle authored Jun 17, 2022
2 parents a3be140 + 6146640 commit f56b7ee
Show file tree
Hide file tree
Showing 9 changed files with 145 additions and 24 deletions.
6 changes: 6 additions & 0 deletions docs/classes/lsp7-digital-asset.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ lspFactory.LSP7DigitalAsset.deploy(digitalAssetProperties [, options]);

Deploys a mintable [LSP7 Digital Asset](../../../standards/nft-2.0/LSP7-Digital-Asset).

:::info
By default LSPFactory deploys the [`Mintable`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP7DigitalAsset/presets/LSP7Mintable.sol) implementation of LSP7 digital assets. To call the `mint` function import the `LSP7Mintable` abi from the [lsp-smart-contracts library](https://github.com/lukso-network/lsp-smart-contracts).

:::


### Parameters

#### 1. `digitalAssetProperties` - Object
Expand Down
7 changes: 6 additions & 1 deletion docs/classes/lsp8-identifiable-digital-asset.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ sidebar_position: 4
title: LSP8IdentifiableDigitalAsset
---

# LSP8IdentifiableDigtialAsset
# LSP8IdentifiableDigitalAsset

## deploy

Expand All @@ -13,6 +13,11 @@ lspFactory.LSP8IdentifiableDigitalAsset.deploy(digitalAssetProperties [, options

Deploys a mintable [LSP8 Identifiable Digital Asset](../../../standards/nft-2.0/LSP8-Identifiable-Digital-Asset).

:::info
By default LSPFactory deploys the [`Mintable`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8Mintable.sol) implementation of LSP8 digital assets. To call the `mint` function import the `LSP8Mintable` abi from the [lsp-smart-contracts library](https://github.com/lukso-network/lsp-smart-contracts).

:::

### Parameters

#### 1. `digitalAssetProperties` - Object
Expand Down
9 changes: 7 additions & 2 deletions docs/deployment/digital-asset.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,23 @@ title: Digital Asset

LSPFactory enables developers to easily deploy [LSP7] and [LSP8] Digital Asset smart contracts for their [fungible token](./digital-asset.md#fungible-token) or [NFT 2.0](./digital-asset.md#deploying-nft-20) use cases.

To deploy an [LSP7] Digital Asset:
To deploy a mintable [LSP7] Digital Asset:

```javascript
await lspFactory.LSP7DigitalAsset.deploy(digitalAssetProperties [, options]);
```

To deploy an LSP8 Identifiable Digital Asset:
To deploy a mintable LSP8 Identifiable Digital Asset:

```javascript
await lspFactory.LSP8IdentifiableDigitalAsset.deploy(digitalAssetProperties [, options]);
```

:::info
By default LSPFactory deploys the [`Mintable`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP7DigitalAsset/presets/LSP7Mintable.sol) implementation of LSP7 and LSP8 digital assets. To call the `mint` function import the `LSP7Mintable` or `LSP8Mintable` abi from the [lsp-smart-contracts library](https://github.com/lukso-network/lsp-smart-contracts).

:::

## Deploying an NFT 2.0

The [LSP7](./digital-asset.md#lsp7-nft-20) and [LSP8](./digital-asset.md#lsp8-nft-20) Digital Assets standards can both be used for NFT 2.0 contracts.
Expand Down
122 changes: 111 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"node": ">=10"
},
"dependencies": {
"@erc725/erc725.js": "^0.9.0",
"@erc725/erc725.js": "0.14.1",
"@ethersproject/abi": "5.5.0",
"@ethersproject/experimental": "5.5.0",
"@lukso/lsp-smart-contracts": "0.6.0",
Expand Down
8 changes: 7 additions & 1 deletion src/lib/helpers/config.helper.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Permissions } from '@erc725/erc725.js/build/main/src/types/Method';
import { keccak256 } from '@ethersproject/keccak256';
import { toUtf8Bytes } from '@ethersproject/strings';
import { Options } from 'ipfs-http-client';
Expand Down Expand Up @@ -35,7 +36,7 @@ export const ADDRESS_PERMISSIONS_ARRAY_KEY =
export const PREFIX_PERMISSIONS = '0x4b80742de2bf82acb3630000';

// exclude DELEGATECALL for safety
export const DEFAULT_PERMISSIONS = {
export const DEFAULT_PERMISSIONS: Permissions = {
CHANGEOWNER: true,
CHANGEPERMISSIONS: true,
ADDPERMISSIONS: true,
Expand All @@ -46,6 +47,11 @@ export const DEFAULT_PERMISSIONS = {
DEPLOY: true,
TRANSFERVALUE: true,
SIGN: true,
SUPER_CALL: true,
SUPER_DELEGATECALL: false,
SUPER_SETDATA: true,
SUPER_STATICCALL: true,
SUPER_TRANSFERVALUE: true,
};

export const DEFAULT_CONTRACT_VERSION = '0.6.0';
Expand Down
5 changes: 3 additions & 2 deletions src/lib/helpers/erc725.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ export function getERC725(address?: string, provider?: providers.Web3Provider) {
}

export function erc725EncodeData(
data: { LSP4Metadata: LSP4MetadataForEncoding } | { LSP3Profile: LSP3ProfileDataForEncoding }
data: LSP4MetadataForEncoding | LSP3ProfileDataForEncoding,
keyName: string
) {
const myERC725 = getERC725();
return myERC725.encodeData(data);
return myERC725.encodeData([{ keyName, value: data }]);
}
6 changes: 2 additions & 4 deletions src/lib/services/digital-asset.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -420,11 +420,9 @@ export async function getEncodedLSP4Metadata(
lsp4MetadataForEncoding = lsp4Metadata;
}

const encodedLSP4Metadata = erc725EncodeData({
LSP4Metadata: lsp4MetadataForEncoding,
});
const encodedLSP4Metadata = erc725EncodeData(lsp4MetadataForEncoding, 'LSP4Metadata');

return encodedLSP4Metadata.LSP4Metadata.value;
return encodedLSP4Metadata.values[0];
}

export function setMetadataAndTransferOwnership$(
Expand Down
4 changes: 2 additions & 2 deletions src/lib/services/universal-profile.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -343,9 +343,9 @@ async function getEncodedLSP3ProfileData(
lsp3ProfileDataForEncoding = lsp3Profile;
}

const encodedDataResult = erc725EncodeData({ LSP3Profile: lsp3ProfileDataForEncoding });
const encodedDataResult = erc725EncodeData(lsp3ProfileDataForEncoding, 'LSP3Profile');

return encodedDataResult.LSP3Profile.value;
return encodedDataResult.values[0];
}

export function lsp3ProfileUpload$(
Expand Down

0 comments on commit f56b7ee

Please sign in to comment.