diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1d0d7e9a..e7b4e61d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,166 +4,149 @@ All notable changes to this project will be documented in this file. See [standa
## [0.24.0](https://github.com/ERC725Alliance/erc725.js/compare/v0.23.1...v0.24.0) (2024-04-02)
-
### Features
-* add dynamic array encoding ([f0f495c](https://github.com/ERC725Alliance/erc725.js/commit/f0f495c69e8b4768468437cad24f1b77d53a379f))
-* replace dynamic part with hex value when parsing schemas for `Mapping` keys ([a9fdb4d](https://github.com/ERC725Alliance/erc725.js/commit/a9fdb4daa69e2aac38aca2393f94e8fe83113656))
-
+- add dynamic array encoding ([f0f495c](https://github.com/ERC725Alliance/erc725.js/commit/f0f495c69e8b4768468437cad24f1b77d53a379f))
+- replace dynamic part with hex value when parsing schemas for `Mapping` keys ([a9fdb4d](https://github.com/ERC725Alliance/erc725.js/commit/a9fdb4daa69e2aac38aca2393f94e8fe83113656))
### Bug Fixes
-* Patch full pretty printed with LF and TAB. ([315fa54](https://github.com/ERC725Alliance/erc725.js/commit/315fa547ab8f2d25db4f771d818afeec0d324bdf))
+- Patch full pretty printed with LF and TAB. ([315fa54](https://github.com/ERC725Alliance/erc725.js/commit/315fa547ab8f2d25db4f771d818afeec0d324bdf))
## [0.23.1](https://github.com/ERC725Alliance/erc725.js/compare/v0.23.0...v0.23.1) (2024-02-23)
-
### Bug Fixes
-* Add check for pretty printed and non-pretty printed versions of JSON ([aa68bf1](https://github.com/ERC725Alliance/erc725.js/commit/aa68bf132d2e4793b4da784c30ae8f306560da8c))
-* Missing line ([d13be00](https://github.com/ERC725Alliance/erc725.js/commit/d13be00ba77be924f914cba1283e9c37250ec9bd))
-* Re-do PR with minimal changes ([17458d6](https://github.com/ERC725Alliance/erc725.js/commit/17458d623f214f026307184357bcf7ff75fad7ed))
-* Repair package-lock to be just as on main ([e793246](https://github.com/ERC725Alliance/erc725.js/commit/e793246e7e09bd80628f19499a5218ce70df8401))
+- Add check for pretty printed and non-pretty printed versions of JSON ([aa68bf1](https://github.com/ERC725Alliance/erc725.js/commit/aa68bf132d2e4793b4da784c30ae8f306560da8c))
+- Missing line ([d13be00](https://github.com/ERC725Alliance/erc725.js/commit/d13be00ba77be924f914cba1283e9c37250ec9bd))
+- Re-do PR with minimal changes ([17458d6](https://github.com/ERC725Alliance/erc725.js/commit/17458d623f214f026307184357bcf7ff75fad7ed))
+- Repair package-lock to be just as on main ([e793246](https://github.com/ERC725Alliance/erc725.js/commit/e793246e7e09bd80628f19499a5218ce70df8401))
## [0.23.0](https://github.com/ERC725Alliance/erc725.js/compare/v0.22.0...v0.23.0) (2024-01-22)
-
### Features
-* add permission related to 4337 ([e7fd19b](https://github.com/ERC725Alliance/erc725.js/commit/e7fd19bc27aa89fae410b9633ef5ccdf13f33f0e))
-* allow to load typed schemas from `schemas/` folder ([c54a370](https://github.com/ERC725Alliance/erc725.js/commit/c54a370c1e4f8d71ba6bb7e62122b89069f521e6))
-
+- add permission related to 4337 ([e7fd19b](https://github.com/ERC725Alliance/erc725.js/commit/e7fd19bc27aa89fae410b9633ef5ccdf13f33f0e))
+- allow to load typed schemas from `schemas/` folder ([c54a370](https://github.com/ERC725Alliance/erc725.js/commit/c54a370c1e4f8d71ba6bb7e62122b89069f521e6))
### Bug Fixes
-* Add workaround to read (bytes4,URI), repair none vs unknown signature. ([204409d](https://github.com/ERC725Alliance/erc725.js/commit/204409df544825041a586865cfb6bb124288e48f))
-* Additional PR repair ([2a18f2b](https://github.com/ERC725Alliance/erc725.js/commit/2a18f2bf1a24547e71cad6953f5144761aa2cc9a))
-* BodyInit should be just string or buffer and not already Uint8Array ([08e0177](https://github.com/ERC725Alliance/erc725.js/commit/08e017778fa42ade5386b8d9e85255225a7f3195))
-* Cleanup ([038d975](https://github.com/ERC725Alliance/erc725.js/commit/038d97584075c89f93f51227666074cf11973a29))
-* Cleanup a bit with comments. ([3d6a5a6](https://github.com/ERC725Alliance/erc725.js/commit/3d6a5a65db5049b678d0d54149e9b11ea2479999))
-* Cleanup and handle situation where one of many keys fails. Return null. ([cdf4583](https://github.com/ERC725Alliance/erc725.js/commit/cdf4583c159d8c8e52a832bfe5af6b650d8945fa))
-* Cleanup error handler inside of getDataFromExternalSources ([fde2e0f](https://github.com/ERC725Alliance/erc725.js/commit/fde2e0f41df3ecee90a4dfd8248dd9c2a7a72965))
-* Debug and repair test scripts. Implement detecting of JSON inside of Uint8Array ([74c0526](https://github.com/ERC725Alliance/erc725.js/commit/74c0526e3f544400ced78f02ff4fed64bd048bfa))
-* Missing commit ([a3dd604](https://github.com/ERC725Alliance/erc725.js/commit/a3dd604964c9c9221ff421fe668faa8fd363101a))
-* More fixes ([620b606](https://github.com/ERC725Alliance/erc725.js/commit/620b60632e50ca59abedae9935f8b75d188278e0))
-* Remove .only call for testing. ([d5ef3c9](https://github.com/ERC725Alliance/erc725.js/commit/d5ef3c9965e2c5ad343f88a9c30a6281e9fa169b))
-* Remove console debugging. ([e349d57](https://github.com/ERC725Alliance/erc725.js/commit/e349d5715c7779c1eeb8d6e08c3ae3bf17eedd9e))
-* Remove unnecessary special case for 0x00000000 ([cd6152a](https://github.com/ERC725Alliance/erc725.js/commit/cd6152a88ca7a1c98184799b6fdc6982ff8a1cd6))
-* Repair and enhance test scripts ([224eb9e](https://github.com/ERC725Alliance/erc725.js/commit/224eb9ecb1b16f373f2ad17ee9d3efab08dda53b))
-* Repair as per PR review ([0a52452](https://github.com/ERC725Alliance/erc725.js/commit/0a5245230455324e9911e4e14992c50e6f645ba2))
-* Repair console.log and expand types of URLs (ar://, ipfs://, https\?://, data:) ([5c8f228](https://github.com/ERC725Alliance/erc725.js/commit/5c8f2285d2d23c59ef9707a54e419b55d25e4136))
-* Repair problems with IPFS, fetch and VerifiableURI ([44834b8](https://github.com/ERC725Alliance/erc725.js/commit/44834b8ed517e869ad99920b2853e30213a8d7b5))
-* Repair to not throw errors when data is not authentica or not accessible withing getDataFromExternalSources. ([25756d0](https://github.com/ERC725Alliance/erc725.js/commit/25756d09cecfec5d13d6e4fb6ed842c4e3d77734))
-* Repair tuples containing numeric types uintX/intX, add Number to output data type. ([01cceea](https://github.com/ERC725Alliance/erc725.js/commit/01cceeac03f719df6eb8be8c238aca4483e7a3e8))
-* Simplify buffer to string conversion. ([0bd1349](https://github.com/ERC725Alliance/erc725.js/commit/0bd1349f863283cf16cc6808bef48990ec118361))
-* Simplify creation of key to detect JSON. ([df2580d](https://github.com/ERC725Alliance/erc725.js/commit/df2580d9434dc386480f7eec2cd6e94a5b4ca7c1))
-* Use a single keccak function since ethereumjs converts it to a Buffer no matter what. ([cdc6c0a](https://github.com/ERC725Alliance/erc725.js/commit/cdc6c0a0f749209352d620db6d60865a276e072c))
+- Add workaround to read (bytes4,URI), repair none vs unknown signature. ([204409d](https://github.com/ERC725Alliance/erc725.js/commit/204409df544825041a586865cfb6bb124288e48f))
+- Additional PR repair ([2a18f2b](https://github.com/ERC725Alliance/erc725.js/commit/2a18f2bf1a24547e71cad6953f5144761aa2cc9a))
+- BodyInit should be just string or buffer and not already Uint8Array ([08e0177](https://github.com/ERC725Alliance/erc725.js/commit/08e017778fa42ade5386b8d9e85255225a7f3195))
+- Cleanup ([038d975](https://github.com/ERC725Alliance/erc725.js/commit/038d97584075c89f93f51227666074cf11973a29))
+- Cleanup a bit with comments. ([3d6a5a6](https://github.com/ERC725Alliance/erc725.js/commit/3d6a5a65db5049b678d0d54149e9b11ea2479999))
+- Cleanup and handle situation where one of many keys fails. Return null. ([cdf4583](https://github.com/ERC725Alliance/erc725.js/commit/cdf4583c159d8c8e52a832bfe5af6b650d8945fa))
+- Cleanup error handler inside of getDataFromExternalSources ([fde2e0f](https://github.com/ERC725Alliance/erc725.js/commit/fde2e0f41df3ecee90a4dfd8248dd9c2a7a72965))
+- Debug and repair test scripts. Implement detecting of JSON inside of Uint8Array ([74c0526](https://github.com/ERC725Alliance/erc725.js/commit/74c0526e3f544400ced78f02ff4fed64bd048bfa))
+- Missing commit ([a3dd604](https://github.com/ERC725Alliance/erc725.js/commit/a3dd604964c9c9221ff421fe668faa8fd363101a))
+- More fixes ([620b606](https://github.com/ERC725Alliance/erc725.js/commit/620b60632e50ca59abedae9935f8b75d188278e0))
+- Remove .only call for testing. ([d5ef3c9](https://github.com/ERC725Alliance/erc725.js/commit/d5ef3c9965e2c5ad343f88a9c30a6281e9fa169b))
+- Remove console debugging. ([e349d57](https://github.com/ERC725Alliance/erc725.js/commit/e349d5715c7779c1eeb8d6e08c3ae3bf17eedd9e))
+- Remove unnecessary special case for 0x00000000 ([cd6152a](https://github.com/ERC725Alliance/erc725.js/commit/cd6152a88ca7a1c98184799b6fdc6982ff8a1cd6))
+- Repair and enhance test scripts ([224eb9e](https://github.com/ERC725Alliance/erc725.js/commit/224eb9ecb1b16f373f2ad17ee9d3efab08dda53b))
+- Repair as per PR review ([0a52452](https://github.com/ERC725Alliance/erc725.js/commit/0a5245230455324e9911e4e14992c50e6f645ba2))
+- Repair console.log and expand types of URLs (ar://, ipfs://, https\?://, data:) ([5c8f228](https://github.com/ERC725Alliance/erc725.js/commit/5c8f2285d2d23c59ef9707a54e419b55d25e4136))
+- Repair problems with IPFS, fetch and VerifiableURI ([44834b8](https://github.com/ERC725Alliance/erc725.js/commit/44834b8ed517e869ad99920b2853e30213a8d7b5))
+- Repair to not throw errors when data is not authentica or not accessible withing getDataFromExternalSources. ([25756d0](https://github.com/ERC725Alliance/erc725.js/commit/25756d09cecfec5d13d6e4fb6ed842c4e3d77734))
+- Repair tuples containing numeric types uintX/intX, add Number to output data type. ([01cceea](https://github.com/ERC725Alliance/erc725.js/commit/01cceeac03f719df6eb8be8c238aca4483e7a3e8))
+- Simplify buffer to string conversion. ([0bd1349](https://github.com/ERC725Alliance/erc725.js/commit/0bd1349f863283cf16cc6808bef48990ec118361))
+- Simplify creation of key to detect JSON. ([df2580d](https://github.com/ERC725Alliance/erc725.js/commit/df2580d9434dc386480f7eec2cd6e94a5b4ca7c1))
+- Use a single keccak function since ethereumjs converts it to a Buffer no matter what. ([cdc6c0a](https://github.com/ERC725Alliance/erc725.js/commit/cdc6c0a0f749209352d620db6d60865a276e072c))
## [0.22.0](https://github.com/ERC725Alliance/erc725.js/compare/v0.21.3...v0.22.0) (2023-12-15)
-
### ⚠ BREAKING CHANGES
-* update new LSP7/8 interface IDs ([#367](https://github.com/ERC725Alliance/erc725.js/issues/367))
-* `JSONURL` and `AssetURL` are now deprecated and have been replaced by `VerifiableURI`. The decoding is backward compatible but if you try to encode `JSONURL` and `AssetURL` value, they will be encoded as [`VerifiableURI`](https://github.com/lukso-network/LIPs/blob/main/LSPs/LSP-2-ERC725YJSONSchema.md#verifiableuri). ([9aa87e5](https://github.com/ERC725Alliance/erc725.js/commit/9aa87e5ccc0fb1caac1f3291387370b3a980324b))
+- update new LSP7/8 interface IDs ([#367](https://github.com/ERC725Alliance/erc725.js/issues/367))
+- `JSONURL` and `AssetURL` are now deprecated and have been replaced by `VerifiableURI`. The decoding is backward compatible but if you try to encode `JSONURL` and `AssetURL` value, they will be encoded as [`VerifiableURI`](https://github.com/lukso-network/LIPs/blob/main/LSPs/LSP-2-ERC725YJSONSchema.md#verifiableuri). ([9aa87e5](https://github.com/ERC725Alliance/erc725.js/commit/9aa87e5ccc0fb1caac1f3291387370b3a980324b))
### Bug Fixes
-* Rename JSONURLDataToEncode ([808f1b3](https://github.com/ERC725Alliance/erc725.js/commit/808f1b362bd2275424cf93ac6333049cde90216e))
+- Rename JSONURLDataToEncode ([808f1b3](https://github.com/ERC725Alliance/erc725.js/commit/808f1b362bd2275424cf93ac6333049cde90216e))
## [0.21.3](https://github.com/ERC725Alliance/erc725.js/compare/v0.21.2...v0.21.3) (2023-11-29)
-
### Features
-* add `encode/decodeValueType` as public callable methods ([#325](https://github.com/ERC725Alliance/erc725.js/issues/325)) ([a6fe7c8](https://github.com/ERC725Alliance/erc725.js/commit/a6fe7c8470688f573426b59fc2023a08da0cbd36))
-* add more schemas available to parse via `getSchema` ([#351](https://github.com/ERC725Alliance/erc725.js/issues/351)) ([b882379](https://github.com/ERC725Alliance/erc725.js/commit/b8823796c5f99d89d56954c894dfb6964adc552a))
-* add support for multi types in mappings ([#357](https://github.com/ERC725Alliance/erc725.js/issues/357)) ([ba92903](https://github.com/ERC725Alliance/erc725.js/commit/ba9290326efad0aab3855ad3f0ed2722180980ed))
-* add support to encode / decode any `uint8` to `uint256` types ([#355](https://github.com/ERC725Alliance/erc725.js/issues/355)) ([417a4e8](https://github.com/ERC725Alliance/erc725.js/commit/417a4e8ff2c74f3f9e35d0018a4973c97c6ac997))
-* allow to encode LSP2 Array length only ([#326](https://github.com/ERC725Alliance/erc725.js/issues/326)) ([3a6be55](https://github.com/ERC725Alliance/erc725.js/commit/3a6be551d889904b7d95e2630ab637f2a31feb50))
-
+- add `encode/decodeValueType` as public callable methods ([#325](https://github.com/ERC725Alliance/erc725.js/issues/325)) ([a6fe7c8](https://github.com/ERC725Alliance/erc725.js/commit/a6fe7c8470688f573426b59fc2023a08da0cbd36))
+- add more schemas available to parse via `getSchema` ([#351](https://github.com/ERC725Alliance/erc725.js/issues/351)) ([b882379](https://github.com/ERC725Alliance/erc725.js/commit/b8823796c5f99d89d56954c894dfb6964adc552a))
+- add support for multi types in mappings ([#357](https://github.com/ERC725Alliance/erc725.js/issues/357)) ([ba92903](https://github.com/ERC725Alliance/erc725.js/commit/ba9290326efad0aab3855ad3f0ed2722180980ed))
+- add support to encode / decode any `uint8` to `uint256` types ([#355](https://github.com/ERC725Alliance/erc725.js/issues/355)) ([417a4e8](https://github.com/ERC725Alliance/erc725.js/commit/417a4e8ff2c74f3f9e35d0018a4973c97c6ac997))
+- allow to encode LSP2 Array length only ([#326](https://github.com/ERC725Alliance/erc725.js/issues/326)) ([3a6be55](https://github.com/ERC725Alliance/erc725.js/commit/3a6be551d889904b7d95e2630ab637f2a31feb50))
### Bug Fixes
-* update lsp6 schema ([75c4044](https://github.com/ERC725Alliance/erc725.js/commit/75c40444e407d93076cc1e49ad706cc0055f383b))
+- update lsp6 schema ([75c4044](https://github.com/ERC725Alliance/erc725.js/commit/75c40444e407d93076cc1e49ad706cc0055f383b))
## [0.21.2](https://github.com/ERC725Alliance/erc725.js/compare/v0.21.1...v0.21.2) (2023-11-07)
-
### Bug Fixes
-* Add for unknown verification method to allow for null verification data in LSP2 ([f205818](https://github.com/ERC725Alliance/erc725.js/commit/f205818af348471bde8f88af2008497b8c13e258))
-* Add more fixes per PR comments ([e7302e4](https://github.com/ERC725Alliance/erc725.js/commit/e7302e4504408e2f4f6304badd2024bfe05fcf47))
-* Change to verification object ([ddd2ab2](https://github.com/ERC725Alliance/erc725.js/commit/ddd2ab23d1c5181745827f338d9abaea48c772f7))
-* More renames _FUNCTIONS to _METHODS ([1a96be1](https://github.com/ERC725Alliance/erc725.js/commit/1a96be1dd15942d2a844bc26b9ab73e053e3b766))
-* Move @types/jest and jest ([852918c](https://github.com/ERC725Alliance/erc725.js/commit/852918c72228b3839ba60730dadef66837008f5a))
+- Add for unknown verification method to allow for null verification data in LSP2 ([f205818](https://github.com/ERC725Alliance/erc725.js/commit/f205818af348471bde8f88af2008497b8c13e258))
+- Add more fixes per PR comments ([e7302e4](https://github.com/ERC725Alliance/erc725.js/commit/e7302e4504408e2f4f6304badd2024bfe05fcf47))
+- Change to verification object ([ddd2ab2](https://github.com/ERC725Alliance/erc725.js/commit/ddd2ab23d1c5181745827f338d9abaea48c772f7))
+- More renames \_FUNCTIONS to \_METHODS ([1a96be1](https://github.com/ERC725Alliance/erc725.js/commit/1a96be1dd15942d2a844bc26b9ab73e053e3b766))
+- Move @types/jest and jest ([852918c](https://github.com/ERC725Alliance/erc725.js/commit/852918c72228b3839ba60730dadef66837008f5a))
## [0.21.1](https://github.com/ERC725Alliance/erc725.js/compare/v0.21.0...v0.21.1) (2023-11-06)
-
### Bug Fixes
-* incorrect hex for `LSP8MetadataTokenURI` ([0500a75](https://github.com/ERC725Alliance/erc725.js/commit/0500a752e3117c5c7e9df8cfed22cb5d6fee20c5))
+- incorrect hex for `LSP8MetadataTokenURI` ([0500a75](https://github.com/ERC725Alliance/erc725.js/commit/0500a752e3117c5c7e9df8cfed22cb5d6fee20c5))
## [0.21.0](https://github.com/ERC725Alliance/erc725.js/compare/v0.20.1...v0.21.0) (2023-11-02)
-
### ⚠ BREAKING CHANGES
-* update lsp3/lsp4 verificationData
+- update lsp3/lsp4 verificationData
### Features
-* new gas parameter ([82e3833](https://github.com/ERC725Alliance/erc725.js/commit/82e383345a712619b5c6a1030b124d2625115fc1))
-
+- new gas parameter ([82e3833](https://github.com/ERC725Alliance/erc725.js/commit/82e383345a712619b5c6a1030b124d2625115fc1))
### Code Refactoring
-* update lsp3/lsp4 verificationData ([9640d9f](https://github.com/ERC725Alliance/erc725.js/commit/9640d9fbf88c7cf694b9e82cc3a711350334b097))
+- update lsp3/lsp4 verificationData ([9640d9f](https://github.com/ERC725Alliance/erc725.js/commit/9640d9fbf88c7cf694b9e82cc3a711350334b097))
## [0.20.1](https://github.com/ERC725Alliance/erc725.js/compare/v0.20.0...v0.20.1) (2023-10-30)
-
### Bug Fixes
-* incorrect permission value for `EXECUTE_RELAY_CALL` ([55b8f5e](https://github.com/ERC725Alliance/erc725.js/commit/55b8f5e64c29c5a85d872f605667c88c1546f6b3))
+- incorrect permission value for `EXECUTE_RELAY_CALL` ([55b8f5e](https://github.com/ERC725Alliance/erc725.js/commit/55b8f5e64c29c5a85d872f605667c88c1546f6b3))
## [0.20.0](https://github.com/ERC725Alliance/erc725.js/compare/v0.19.0...v0.20.0) (2023-10-18)
-
### Features
-* add permission `EXECUTE_RELAY_CALL` ([6db8835](https://github.com/ERC725Alliance/erc725.js/commit/6db8835ccd9d1082d9e8184bb2f14972760bea69))
+- add permission `EXECUTE_RELAY_CALL` ([6db8835](https://github.com/ERC725Alliance/erc725.js/commit/6db8835ccd9d1082d9e8184bb2f14972760bea69))
## [0.19.0](https://github.com/ERC725Alliance/erc725.js/compare/v0.18.0...v0.19.0) (2023-10-05)
-
### ⚠ BREAKING CHANGES
-* change LSP3 to SupportedStandards:LSP3Profile ([#307](https://github.com/ERC725Alliance/erc725.js/issues/307))
-* new encoding for static value types (not arrays `[]`) ([#288](https://github.com/ERC725Alliance/erc725.js/issues/288))
-* change `ArrayLength` value from `uint256` to `uint128` ([#287](https://github.com/ERC725Alliance/erc725.js/issues/287))
+- change LSP3 to SupportedStandards:LSP3Profile ([#307](https://github.com/ERC725Alliance/erc725.js/issues/307))
+- new encoding for static value types (not arrays `[]`) ([#288](https://github.com/ERC725Alliance/erc725.js/issues/288))
+- change `ArrayLength` value from `uint256` to `uint128` ([#287](https://github.com/ERC725Alliance/erc725.js/issues/287))
### Features
-* add checkPermissions function ([17d2258](https://github.com/ERC725Alliance/erc725.js/commit/17d225843c236951ef1515a0ff91095b5ef27cd3))
-* add schemas for LSP8 + LSP17 ([#311](https://github.com/ERC725Alliance/erc725.js/issues/311)) ([1e8dbf7](https://github.com/ERC725Alliance/erc725.js/commit/1e8dbf765c6c5e250539b402e9bd5a395966a8c2))
-
+- add checkPermissions function ([17d2258](https://github.com/ERC725Alliance/erc725.js/commit/17d225843c236951ef1515a0ff91095b5ef27cd3))
+- add schemas for LSP8 + LSP17 ([#311](https://github.com/ERC725Alliance/erc725.js/issues/311)) ([1e8dbf7](https://github.com/ERC725Alliance/erc725.js/commit/1e8dbf765c6c5e250539b402e9bd5a395966a8c2))
### Bug Fixes
-* decode any uint256 as number not string ([#289](https://github.com/ERC725Alliance/erc725.js/issues/289)) ([37203f1](https://github.com/ERC725Alliance/erc725.js/commit/37203f14d313a0caff75724dc74175c741c1b540))
-* dependencies & example ([#302](https://github.com/ERC725Alliance/erc725.js/issues/302)) ([9979e89](https://github.com/ERC725Alliance/erc725.js/commit/9979e89e438cd9f7cc586d7dc271de969f13b125))
-* incorrect value in schema for array length in `...Map` ([#310](https://github.com/ERC725Alliance/erc725.js/issues/310)) ([0d28b13](https://github.com/ERC725Alliance/erc725.js/commit/0d28b1317dc085078090a8babacf4db517d91a87))
-* Remove hardcoded require ([5279278](https://github.com/ERC725Alliance/erc725.js/commit/527927812b1a05b13f8dc6b14aecaa6d24e98d61))
-* variable naming ([44b4785](https://github.com/ERC725Alliance/erc725.js/commit/44b47851ed63b817edc21c63655d67bac13a7e7f))
-
+- decode any uint256 as number not string ([#289](https://github.com/ERC725Alliance/erc725.js/issues/289)) ([37203f1](https://github.com/ERC725Alliance/erc725.js/commit/37203f14d313a0caff75724dc74175c741c1b540))
+- dependencies & example ([#302](https://github.com/ERC725Alliance/erc725.js/issues/302)) ([9979e89](https://github.com/ERC725Alliance/erc725.js/commit/9979e89e438cd9f7cc586d7dc271de969f13b125))
+- incorrect value in schema for array length in `...Map` ([#310](https://github.com/ERC725Alliance/erc725.js/issues/310)) ([0d28b13](https://github.com/ERC725Alliance/erc725.js/commit/0d28b1317dc085078090a8babacf4db517d91a87))
+- Remove hardcoded require ([5279278](https://github.com/ERC725Alliance/erc725.js/commit/527927812b1a05b13f8dc6b14aecaa6d24e98d61))
+- variable naming ([44b4785](https://github.com/ERC725Alliance/erc725.js/commit/44b47851ed63b817edc21c63655d67bac13a7e7f))
### Code Refactoring
-* change `ArrayLength` value from `uint256` to `uint128` ([#287](https://github.com/ERC725Alliance/erc725.js/issues/287)) ([c95ee8a](https://github.com/ERC725Alliance/erc725.js/commit/c95ee8a53bf25bcf47777054af27cae1fbad8b2f))
-* change LSP3 to SupportedStandards:LSP3Profile ([#307](https://github.com/ERC725Alliance/erc725.js/issues/307)) ([73f3481](https://github.com/ERC725Alliance/erc725.js/commit/73f34818fe152c3ab5299177adc0eddfed6886c5))
-* new encoding for static value types (not arrays `[]`) ([#288](https://github.com/ERC725Alliance/erc725.js/issues/288)) ([f0b04da](https://github.com/ERC725Alliance/erc725.js/commit/f0b04daa57a281c537a8f28594439573188f0dce))
+- change `ArrayLength` value from `uint256` to `uint128` ([#287](https://github.com/ERC725Alliance/erc725.js/issues/287)) ([c95ee8a](https://github.com/ERC725Alliance/erc725.js/commit/c95ee8a53bf25bcf47777054af27cae1fbad8b2f))
+- change LSP3 to SupportedStandards:LSP3Profile ([#307](https://github.com/ERC725Alliance/erc725.js/issues/307)) ([73f3481](https://github.com/ERC725Alliance/erc725.js/commit/73f34818fe152c3ab5299177adc0eddfed6886c5))
+- new encoding for static value types (not arrays `[]`) ([#288](https://github.com/ERC725Alliance/erc725.js/issues/288)) ([f0b04da](https://github.com/ERC725Alliance/erc725.js/commit/f0b04daa57a281c537a8f28594439573188f0dce))
## [0.18.0](https://github.com/ERC725Alliance/erc725.js/compare/v0.17.2...v0.18.0) (2023-08-03)
diff --git a/biome.json b/biome.json
index 2a97f8ec..996e03e6 100644
--- a/biome.json
+++ b/biome.json
@@ -7,8 +7,23 @@
"noExplicitAny": "off"
},
"style": {
- "useImportType": "off"
+ "useImportType": "off",
+ "useNodejsImportProtocol": "off"
}
}
+ },
+ "formatter": {
+ "indentWidth": 2,
+ "indentStyle": "space"
+ },
+ "javascript": {
+ "formatter": {
+ "semicolons": "always",
+ "quoteStyle": "single",
+ "trailingComma": "all"
+ }
+ },
+ "files": {
+ "ignore": ["node_modules", "build", "coverage", ".vscode"]
}
}
diff --git a/examples/src/instantiation.js b/examples/src/instantiation.js
index bb1f3809..f3f37f16 100644
--- a/examples/src/instantiation.js
+++ b/examples/src/instantiation.js
@@ -1,5 +1,5 @@
-import Web3 from 'web3';
import { ERC725 } from '@erc725/erc725.js';
+import Web3 from 'web3';
// this is needed because node does not support `fetch` out of the box
// isomorphic-fetch is not needed in a browser environment
diff --git a/package-lock.json b/package-lock.json
index d67c5414..8070ac83 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -16,6 +16,7 @@
"web3-utils": "^1.10.0"
},
"devDependencies": {
+ "@biomejs/biome": "^1.6.4",
"@types/chai": "^4.3.4",
"@types/isomorphic-fetch": "^0.0.36",
"@types/jest": "^27.5.2",
@@ -708,6 +709,161 @@
"integrity": "sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==",
"dev": true
},
+ "node_modules/@biomejs/biome": {
+ "version": "1.6.4",
+ "resolved": "https://registry.npmjs.org/@biomejs/biome/-/biome-1.6.4.tgz",
+ "integrity": "sha512-3groVd2oWsLC0ZU+XXgHSNbq31lUcOCBkCcA7sAQGBopHcmL+jmmdoWlY3S61zIh+f2mqQTQte1g6PZKb3JJjA==",
+ "dev": true,
+ "hasInstallScript": true,
+ "bin": {
+ "biome": "bin/biome"
+ },
+ "engines": {
+ "node": ">=14.21.3"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/biome"
+ },
+ "optionalDependencies": {
+ "@biomejs/cli-darwin-arm64": "1.6.4",
+ "@biomejs/cli-darwin-x64": "1.6.4",
+ "@biomejs/cli-linux-arm64": "1.6.4",
+ "@biomejs/cli-linux-arm64-musl": "1.6.4",
+ "@biomejs/cli-linux-x64": "1.6.4",
+ "@biomejs/cli-linux-x64-musl": "1.6.4",
+ "@biomejs/cli-win32-arm64": "1.6.4",
+ "@biomejs/cli-win32-x64": "1.6.4"
+ }
+ },
+ "node_modules/@biomejs/cli-darwin-arm64": {
+ "version": "1.6.4",
+ "resolved": "https://registry.npmjs.org/@biomejs/cli-darwin-arm64/-/cli-darwin-arm64-1.6.4.tgz",
+ "integrity": "sha512-2WZef8byI9NRzGajGj5RTrroW9BxtfbP9etigW1QGAtwu/6+cLkdPOWRAs7uFtaxBNiKFYA8j/BxV5zeAo5QOQ==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "optional": true,
+ "os": [
+ "darwin"
+ ],
+ "engines": {
+ "node": ">=14.21.3"
+ }
+ },
+ "node_modules/@biomejs/cli-darwin-x64": {
+ "version": "1.6.4",
+ "resolved": "https://registry.npmjs.org/@biomejs/cli-darwin-x64/-/cli-darwin-x64-1.6.4.tgz",
+ "integrity": "sha512-uo1zgM7jvzcoDpF6dbGizejDLCqNpUIRkCj/oEK0PB0NUw8re/cn1EnxuOLZqDpn+8G75COLQTOx8UQIBBN/Kg==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "optional": true,
+ "os": [
+ "darwin"
+ ],
+ "engines": {
+ "node": ">=14.21.3"
+ }
+ },
+ "node_modules/@biomejs/cli-linux-arm64": {
+ "version": "1.6.4",
+ "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-arm64/-/cli-linux-arm64-1.6.4.tgz",
+ "integrity": "sha512-wAOieaMNIpLrxGc2/xNvM//CIZg7ueWy3V5A4T7gDZ3OL/Go27EKE59a+vMKsBCYmTt7jFl4yHz0TUkUbodA/w==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">=14.21.3"
+ }
+ },
+ "node_modules/@biomejs/cli-linux-arm64-musl": {
+ "version": "1.6.4",
+ "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-arm64-musl/-/cli-linux-arm64-musl-1.6.4.tgz",
+ "integrity": "sha512-Hp8Jwt6rjj0wCcYAEN6/cfwrrPLLlGOXZ56Lei4Pt4jy39+UuPeAVFPeclrrCfxyL1wQ2xPrhd/saTHSL6DoJg==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">=14.21.3"
+ }
+ },
+ "node_modules/@biomejs/cli-linux-x64": {
+ "version": "1.6.4",
+ "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-x64/-/cli-linux-x64-1.6.4.tgz",
+ "integrity": "sha512-qTWhuIw+/ePvOkjE9Zxf5OqSCYxtAvcTJtVmZT8YQnmY2I62JKNV2m7tf6O5ViKZUOP0mOQ6NgqHKcHH1eT8jw==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">=14.21.3"
+ }
+ },
+ "node_modules/@biomejs/cli-linux-x64-musl": {
+ "version": "1.6.4",
+ "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-x64-musl/-/cli-linux-x64-musl-1.6.4.tgz",
+ "integrity": "sha512-wqi0hr8KAx5kBO0B+m5u8QqiYFFBJOSJVSuRqTeGWW+GYLVUtXNidykNqf1JsW6jJDpbkSp2xHKE/bTlVaG2Kg==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">=14.21.3"
+ }
+ },
+ "node_modules/@biomejs/cli-win32-arm64": {
+ "version": "1.6.4",
+ "resolved": "https://registry.npmjs.org/@biomejs/cli-win32-arm64/-/cli-win32-arm64-1.6.4.tgz",
+ "integrity": "sha512-Wp3FiEeF6v6C5qMfLkHwf4YsoNHr/n0efvoC8jCKO/kX05OXaVExj+1uVQ1eGT7Pvx0XVm/TLprRO0vq/V6UzA==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "optional": true,
+ "os": [
+ "win32"
+ ],
+ "engines": {
+ "node": ">=14.21.3"
+ }
+ },
+ "node_modules/@biomejs/cli-win32-x64": {
+ "version": "1.6.4",
+ "resolved": "https://registry.npmjs.org/@biomejs/cli-win32-x64/-/cli-win32-x64-1.6.4.tgz",
+ "integrity": "sha512-mz183Di5hTSGP7KjNWEhivcP1wnHLGmOxEROvoFsIxMYtDhzJDad4k5gI/1JbmA0xe4n52vsgqo09tBhrMT/Zg==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "optional": true,
+ "os": [
+ "win32"
+ ],
+ "engines": {
+ "node": ">=14.21.3"
+ }
+ },
"node_modules/@cspotcode/source-map-support": {
"version": "0.8.1",
"resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz",
@@ -13869,6 +14025,78 @@
"integrity": "sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==",
"dev": true
},
+ "@biomejs/biome": {
+ "version": "1.6.4",
+ "resolved": "https://registry.npmjs.org/@biomejs/biome/-/biome-1.6.4.tgz",
+ "integrity": "sha512-3groVd2oWsLC0ZU+XXgHSNbq31lUcOCBkCcA7sAQGBopHcmL+jmmdoWlY3S61zIh+f2mqQTQte1g6PZKb3JJjA==",
+ "dev": true,
+ "requires": {
+ "@biomejs/cli-darwin-arm64": "1.6.4",
+ "@biomejs/cli-darwin-x64": "1.6.4",
+ "@biomejs/cli-linux-arm64": "1.6.4",
+ "@biomejs/cli-linux-arm64-musl": "1.6.4",
+ "@biomejs/cli-linux-x64": "1.6.4",
+ "@biomejs/cli-linux-x64-musl": "1.6.4",
+ "@biomejs/cli-win32-arm64": "1.6.4",
+ "@biomejs/cli-win32-x64": "1.6.4"
+ }
+ },
+ "@biomejs/cli-darwin-arm64": {
+ "version": "1.6.4",
+ "resolved": "https://registry.npmjs.org/@biomejs/cli-darwin-arm64/-/cli-darwin-arm64-1.6.4.tgz",
+ "integrity": "sha512-2WZef8byI9NRzGajGj5RTrroW9BxtfbP9etigW1QGAtwu/6+cLkdPOWRAs7uFtaxBNiKFYA8j/BxV5zeAo5QOQ==",
+ "dev": true,
+ "optional": true
+ },
+ "@biomejs/cli-darwin-x64": {
+ "version": "1.6.4",
+ "resolved": "https://registry.npmjs.org/@biomejs/cli-darwin-x64/-/cli-darwin-x64-1.6.4.tgz",
+ "integrity": "sha512-uo1zgM7jvzcoDpF6dbGizejDLCqNpUIRkCj/oEK0PB0NUw8re/cn1EnxuOLZqDpn+8G75COLQTOx8UQIBBN/Kg==",
+ "dev": true,
+ "optional": true
+ },
+ "@biomejs/cli-linux-arm64": {
+ "version": "1.6.4",
+ "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-arm64/-/cli-linux-arm64-1.6.4.tgz",
+ "integrity": "sha512-wAOieaMNIpLrxGc2/xNvM//CIZg7ueWy3V5A4T7gDZ3OL/Go27EKE59a+vMKsBCYmTt7jFl4yHz0TUkUbodA/w==",
+ "dev": true,
+ "optional": true
+ },
+ "@biomejs/cli-linux-arm64-musl": {
+ "version": "1.6.4",
+ "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-arm64-musl/-/cli-linux-arm64-musl-1.6.4.tgz",
+ "integrity": "sha512-Hp8Jwt6rjj0wCcYAEN6/cfwrrPLLlGOXZ56Lei4Pt4jy39+UuPeAVFPeclrrCfxyL1wQ2xPrhd/saTHSL6DoJg==",
+ "dev": true,
+ "optional": true
+ },
+ "@biomejs/cli-linux-x64": {
+ "version": "1.6.4",
+ "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-x64/-/cli-linux-x64-1.6.4.tgz",
+ "integrity": "sha512-qTWhuIw+/ePvOkjE9Zxf5OqSCYxtAvcTJtVmZT8YQnmY2I62JKNV2m7tf6O5ViKZUOP0mOQ6NgqHKcHH1eT8jw==",
+ "dev": true,
+ "optional": true
+ },
+ "@biomejs/cli-linux-x64-musl": {
+ "version": "1.6.4",
+ "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-x64-musl/-/cli-linux-x64-musl-1.6.4.tgz",
+ "integrity": "sha512-wqi0hr8KAx5kBO0B+m5u8QqiYFFBJOSJVSuRqTeGWW+GYLVUtXNidykNqf1JsW6jJDpbkSp2xHKE/bTlVaG2Kg==",
+ "dev": true,
+ "optional": true
+ },
+ "@biomejs/cli-win32-arm64": {
+ "version": "1.6.4",
+ "resolved": "https://registry.npmjs.org/@biomejs/cli-win32-arm64/-/cli-win32-arm64-1.6.4.tgz",
+ "integrity": "sha512-Wp3FiEeF6v6C5qMfLkHwf4YsoNHr/n0efvoC8jCKO/kX05OXaVExj+1uVQ1eGT7Pvx0XVm/TLprRO0vq/V6UzA==",
+ "dev": true,
+ "optional": true
+ },
+ "@biomejs/cli-win32-x64": {
+ "version": "1.6.4",
+ "resolved": "https://registry.npmjs.org/@biomejs/cli-win32-x64/-/cli-win32-x64-1.6.4.tgz",
+ "integrity": "sha512-mz183Di5hTSGP7KjNWEhivcP1wnHLGmOxEROvoFsIxMYtDhzJDad4k5gI/1JbmA0xe4n52vsgqo09tBhrMT/Zg==",
+ "dev": true,
+ "optional": true
+ },
"@cspotcode/source-map-support": {
"version": "0.8.1",
"resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz",
diff --git a/package.json b/package.json
index dc7ba660..966814ee 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "@erc725/erc725.js",
- "version": "0.24.0",
+ "version": "0.24.1-dev.2",
"description": "Library to interact with ERC725 smart contracts",
"main": "build/main/src/index.js",
"typings": "build/main/src/index.d.ts",
@@ -16,6 +16,8 @@
"build:module": "tsc -p tsconfig.module.json",
"test": "env TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\" }' nyc --reporter=text --reporter=lcov mocha",
"lint": "eslint . --ext .ts",
+ "format:fix": "prettier --write .",
+ "format": "prettier .",
"release": "standard-version"
},
"repository": {
@@ -51,6 +53,7 @@
},
"homepage": "https://github.com/ERC725Alliance/erc725.js#readme",
"devDependencies": {
+ "@biomejs/biome": "^1.6.4",
"@types/chai": "^4.3.4",
"@types/isomorphic-fetch": "^0.0.36",
"@types/jest": "^27.5.2",
diff --git a/src/constants/constants.ts b/src/constants/constants.ts
index f28a6852..036ceed5 100644
--- a/src/constants/constants.ts
+++ b/src/constants/constants.ts
@@ -12,11 +12,11 @@
along with @erc725/erc725.js. If not, see .
*/
-/* eslint-disable @typescript-eslint/ban-types */
-import { numberToHex, keccak256 } from 'web3-utils';
import { arrToBufArr, bufferToHex } from 'ethereumjs-util';
+/* eslint-disable @typescript-eslint/ban-types */
+import { keccak256, numberToHex } from 'web3-utils';
-import { MethodData, Encoding, Method } from '../types/Method';
+import { Encoding, Method, MethodData } from '../types/Method';
// https://github.com/ERC725Alliance/ERC725/blob/develop/docs/ERC-725.md#specification
export const ERC725Y_INTERFACE_IDS = {
@@ -156,31 +156,50 @@ export const HASH_METHODS: {
// TODO: These values can be imported from lsp-smartcontracts lib after release
// prettier-ignore
export const LSP6_DEFAULT_PERMISSIONS = {
- CHANGEOWNER : "0x0000000000000000000000000000000000000000000000000000000000000001",
- ADDCONTROLLER : "0x0000000000000000000000000000000000000000000000000000000000000002",
- EDITPERMISSIONS : "0x0000000000000000000000000000000000000000000000000000000000000004",
- ADDEXTENSIONS : "0x0000000000000000000000000000000000000000000000000000000000000008",
- CHANGEEXTENSIONS : "0x0000000000000000000000000000000000000000000000000000000000000010",
- ADDUNIVERSALRECEIVERDELEGATE : "0x0000000000000000000000000000000000000000000000000000000000000020",
- CHANGEUNIVERSALRECEIVERDELEGATE : "0x0000000000000000000000000000000000000000000000000000000000000040",
- REENTRANCY : "0x0000000000000000000000000000000000000000000000000000000000000080",
- SUPER_TRANSFERVALUE : "0x0000000000000000000000000000000000000000000000000000000000000100",
- TRANSFERVALUE : "0x0000000000000000000000000000000000000000000000000000000000000200",
- SUPER_CALL : "0x0000000000000000000000000000000000000000000000000000000000000400",
- CALL : "0x0000000000000000000000000000000000000000000000000000000000000800",
- SUPER_STATICCALL : "0x0000000000000000000000000000000000000000000000000000000000001000",
- STATICCALL : "0x0000000000000000000000000000000000000000000000000000000000002000",
- SUPER_DELEGATECALL : "0x0000000000000000000000000000000000000000000000000000000000004000",
- DELEGATECALL : "0x0000000000000000000000000000000000000000000000000000000000008000",
- DEPLOY : "0x0000000000000000000000000000000000000000000000000000000000010000",
- SUPER_SETDATA : "0x0000000000000000000000000000000000000000000000000000000000020000",
- SETDATA : "0x0000000000000000000000000000000000000000000000000000000000040000",
- ENCRYPT : "0x0000000000000000000000000000000000000000000000000000000000080000",
- DECRYPT : "0x0000000000000000000000000000000000000000000000000000000000100000",
- SIGN : "0x0000000000000000000000000000000000000000000000000000000000200000",
- EXECUTE_RELAY_CALL : "0x0000000000000000000000000000000000000000000000000000000000400000",
- ERC4337_PERMISSION : "0x0000000000000000000000000000000000000000000000000000000000800000",
- ALL_PERMISSIONS : "0x00000000000000000000000000000000000000000000000000000000007f3f7f" // lsp6 v0.14.0
+ CHANGEOWNER:
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
+ ADDCONTROLLER:
+ '0x0000000000000000000000000000000000000000000000000000000000000002',
+ EDITPERMISSIONS:
+ '0x0000000000000000000000000000000000000000000000000000000000000004',
+ ADDEXTENSIONS:
+ '0x0000000000000000000000000000000000000000000000000000000000000008',
+ CHANGEEXTENSIONS:
+ '0x0000000000000000000000000000000000000000000000000000000000000010',
+ ADDUNIVERSALRECEIVERDELEGATE:
+ '0x0000000000000000000000000000000000000000000000000000000000000020',
+ CHANGEUNIVERSALRECEIVERDELEGATE:
+ '0x0000000000000000000000000000000000000000000000000000000000000040',
+ REENTRANCY:
+ '0x0000000000000000000000000000000000000000000000000000000000000080',
+ SUPER_TRANSFERVALUE:
+ '0x0000000000000000000000000000000000000000000000000000000000000100',
+ TRANSFERVALUE:
+ '0x0000000000000000000000000000000000000000000000000000000000000200',
+ SUPER_CALL:
+ '0x0000000000000000000000000000000000000000000000000000000000000400',
+ CALL: '0x0000000000000000000000000000000000000000000000000000000000000800',
+ SUPER_STATICCALL:
+ '0x0000000000000000000000000000000000000000000000000000000000001000',
+ STATICCALL:
+ '0x0000000000000000000000000000000000000000000000000000000000002000',
+ SUPER_DELEGATECALL:
+ '0x0000000000000000000000000000000000000000000000000000000000004000',
+ DELEGATECALL:
+ '0x0000000000000000000000000000000000000000000000000000000000008000',
+ DEPLOY: '0x0000000000000000000000000000000000000000000000000000000000010000',
+ SUPER_SETDATA:
+ '0x0000000000000000000000000000000000000000000000000000000000020000',
+ SETDATA: '0x0000000000000000000000000000000000000000000000000000000000040000',
+ ENCRYPT: '0x0000000000000000000000000000000000000000000000000000000000080000',
+ DECRYPT: '0x0000000000000000000000000000000000000000000000000000000000100000',
+ SIGN: '0x0000000000000000000000000000000000000000000000000000000000200000',
+ EXECUTE_RELAY_CALL:
+ '0x0000000000000000000000000000000000000000000000000000000000400000',
+ ERC4337_PERMISSION:
+ '0x0000000000000000000000000000000000000000000000000000000000800000',
+ ALL_PERMISSIONS:
+ '0x00000000000000000000000000000000000000000000000000000000007f3f7f', // lsp6 v0.14.0
};
export const LSP6_ALL_PERMISSIONS =
diff --git a/src/index.test.ts b/src/index.test.ts
index db99edaf..5fc6614f 100644
--- a/src/index.test.ts
+++ b/src/index.test.ts
@@ -20,21 +20,20 @@
// Tests for the @erc725/erc725.js package
import { assert } from 'chai';
-import Web3 from 'web3';
import * as sinon from 'sinon';
+import Web3 from 'web3';
import { hexToNumber, leftPad, numberToHex } from 'web3-utils';
// examples of schemas to load (for testing)
-import { LSP1Schema, LSP12Schema, LSP3Schema, LSP6Schema } from './schemas';
-
-import ERC725 from '.';
-import {
- decodeKeyValue,
- encodeKey,
- encodeKeyValue,
- hashData,
-} from './lib/utils';
-import { ERC725JSONSchema } from './types/ERC725JSONSchema';
+import { LSP1Schema, LSP3Schema, LSP6Schema, LSP12Schema } from './schemas';
+
+import ERC725, {
+ checkPermissions,
+ decodePermissions,
+ encodeKeyName,
+ encodePermissions,
+ supportsInterface,
+} from '.';
import { EthereumProvider, HttpProvider } from '../test/mockProviders';
import { mockSchema } from '../test/mockSchema';
import {
@@ -42,6 +41,13 @@ import {
generateAllRawData,
generateAllResults,
} from '../test/testHelpers';
+import {
+ decodeKeyValue,
+ encodeKey,
+ encodeKeyValue,
+ hashData,
+} from './lib/utils';
+import { ERC725JSONSchema } from './types/ERC725JSONSchema';
import 'isomorphic-fetch';
@@ -50,8 +56,8 @@ import {
LSP6_DEFAULT_PERMISSIONS,
SUPPORTED_VERIFICATION_METHOD_STRINGS,
} from './constants/constants';
-import { decodeKey } from './lib/decodeData';
import { INTERFACE_IDS_0_12_0 } from './constants/interfaces';
+import { decodeKey } from './lib/decodeData';
const address = '0x0c03fba782b07bcf810deb3b7f0595024a444f4e';
@@ -609,10 +615,13 @@ describe('Running @erc725/erc725.js tests...', () => {
});
});
- [
+ const contractVersions = [
{ name: 'legacy', interface: ERC725Y_INTERFACE_IDS.legacy },
{ name: 'latest', interface: ERC725Y_INTERFACE_IDS['3.0'] },
- ].forEach((contractVersion) => {
+ ];
+ for (let i = 0; i < contractVersions.length; i++) {
+ const contractVersion = contractVersions[i];
+
describe(`Getting all data in schema by provider [ERC725Y ${contractVersion.name}][mock]`, () => {
// Construct the full data and results
const fullResults = generateAllResults(mockSchema);
@@ -834,11 +843,13 @@ describe('Running @erc725/erc725.js tests...', () => {
});
}
});
- });
+ }
describe('Getting data by schema element by provider', () => {
- mockSchema.forEach((schemaElement) => {
- it(schemaElement.name + ' with web3.currentProvider', async () => {
+ for (let index = 0; index < mockSchema.length; index++) {
+ const schemaElement = mockSchema[index];
+
+ it(`${schemaElement.name} with web3.currentProvider`, async () => {
const returnRawData = generateAllRawData([schemaElement], false);
const provider = new HttpProvider({ returnData: returnRawData }, [
ERC725Y_INTERFACE_IDS.legacy,
@@ -859,7 +870,7 @@ describe('Running @erc725/erc725.js tests...', () => {
});
});
- it(schemaElement.name + ' with ethereumProvider EIP 1193', async () => {
+ it(`${schemaElement.name} with ethereumProvider EIP 1193`, async () => {
const returnRawData = generateAllRawData([schemaElement], false);
const provider = new HttpProvider({ returnData: returnRawData }, [
ERC725Y_INTERFACE_IDS.legacy,
@@ -879,7 +890,7 @@ describe('Running @erc725/erc725.js tests...', () => {
value: schemaElement.expectedResult,
});
});
- });
+ }
});
describe('Testing utility encoding & decoding functions', () => {
@@ -891,7 +902,7 @@ describe('Running @erc725/erc725.js tests...', () => {
// ARRAY type:
if (schemaElement.keyType.toLowerCase() === 'array') {
- it('Encode data values in array: ' + schemaElement.name, async () => {
+ it(`Encode data values in array: ${schemaElement.name}`, async () => {
const results: string[] = [];
// Encode array loop
@@ -915,7 +926,7 @@ describe('Running @erc725/erc725.js tests...', () => {
assert.deepStrictEqual(results, schemaElement.returnGraphData);
});
- it('decodes data values in array: ' + schemaElement.name, async () => {
+ it(`decodes data values in array: ${schemaElement.name}`, async () => {
const results: any[] = [];
// decode array loop
@@ -988,10 +999,11 @@ describe('Running @erc725/erc725.js tests...', () => {
values: [],
};
- keyValuePairs.forEach((keyValuePair) => {
- intendedResult.keys.push(keyValuePair.key);
- intendedResult.values.push(keyValuePair.value);
- });
+ for (let i = 0; i < keyValuePairs.length; i++) {
+ const { key, value } = keyValuePairs[i];
+ intendedResult.keys.push(key);
+ intendedResult.values.push(value);
+ }
const erc725 = new ERC725([schemaElement]);
@@ -1064,7 +1076,7 @@ describe('Running @erc725/erc725.js tests...', () => {
}
// SINGLETON type: This is not an array, assumed 'Singleton'
- it('encodes data value for: ' + schemaElement.name, async () => {
+ it(`encodes data value for: ${schemaElement.name}`, async () => {
const result = encodeKeyValue(
schemaElement.valueContent,
schemaElement.valueType,
@@ -1074,7 +1086,7 @@ describe('Running @erc725/erc725.js tests...', () => {
assert.deepStrictEqual(result, schemaElement.returnGraphData);
});
- it('decodes data value for: ' + schemaElement.name, async () => {
+ it(`decodes data value for: ${schemaElement.name}`, async () => {
const result = decodeKeyValue(
schemaElement.valueContent,
schemaElement.valueType,
@@ -1390,11 +1402,12 @@ describe('Running @erc725/erc725.js tests...', () => {
const erc725Instance = new ERC725([]);
- describe(`encodePermissions`, () => {
- testCases.forEach((testCase) => {
+ describe('encodePermissions', () => {
+ for (let i = 0; i < testCases.length; i++) {
+ const testCase = testCases[i];
it(`Encodes ${testCase.hex} permission correctly`, () => {
assert.deepStrictEqual(
- ERC725.encodePermissions(testCase.permissions),
+ encodePermissions(testCase.permissions),
testCase.hex,
);
assert.deepStrictEqual(
@@ -1402,11 +1415,11 @@ describe('Running @erc725/erc725.js tests...', () => {
testCase.hex,
);
});
- });
+ }
it('Defaults permissions to false if not passed', () => {
assert.deepStrictEqual(
- ERC725.encodePermissions({
+ encodePermissions({
EDITPERMISSIONS: true,
SETDATA: true,
}),
@@ -1425,11 +1438,13 @@ describe('Running @erc725/erc725.js tests...', () => {
describe('Randomized Permissions Encoding', () => {
function convertToPermissionBits(permissions: { [key: string]: string }) {
const permissionBits = {};
- Object.entries(permissions).forEach(([key, hexValue]) => {
+ const entries = Object.entries(permissions);
+ for (let i = 0; i < entries.length; i++) {
+ const [key, hexValue] = entries[i];
// Convert hex to binary, then find the position of the '1' bit
const bitPosition = BigInt(hexValue).toString(2).length - 1;
permissionBits[key] = bitPosition;
- });
+ }
return permissionBits;
}
@@ -1460,12 +1475,14 @@ describe('Running @erc725/erc725.js tests...', () => {
// Function to calculate expected hex based on permissions
const calculateExpectedHex = (permissions) => {
let basePermissions = BigInt(0);
- Object.entries(permissions).forEach(([key, value]) => {
+ const entries = Object.entries(permissions);
+ for (let i = 0; i < entries.length; i++) {
+ const [key, value] = entries[i];
if (value) {
const bitPosition = permissionBits[key];
basePermissions |= BigInt(1) << BigInt(bitPosition);
}
- });
+ }
// Convert to hex string, properly padded
return `0x${basePermissions.toString(16).padStart(64, '0')}`;
};
@@ -1475,7 +1492,7 @@ describe('Running @erc725/erc725.js tests...', () => {
for (let i = 0; i < numberOfTests; i++) {
it(`Randomized test #${i + 1}`, () => {
const randomPermissions = generateRandomPermissions();
- const encoded = ERC725.encodePermissions(randomPermissions);
+ const encoded = encodePermissions(randomPermissions);
const expectedHex = calculateExpectedHex(randomPermissions);
assert.strictEqual(
encoded,
@@ -1489,7 +1506,7 @@ describe('Running @erc725/erc725.js tests...', () => {
describe('all permissions', () => {
it('should encode ALL_PERMISSIONS correctly', () => {
const permissions = { ALL_PERMISSIONS: true };
- const encoded = ERC725.encodePermissions(permissions);
+ const encoded = encodePermissions(permissions);
assert.strictEqual(
encoded,
@@ -1498,12 +1515,59 @@ describe('Running @erc725/erc725.js tests...', () => {
);
});
+ it('should decode ALL_PERMISSIONS', () => {
+ const permissions = { ALL_PERMISSIONS: true };
+ const encoded = encodePermissions(permissions);
+
+ const decodedPermissions = decodePermissions(encoded);
+
+ assert.strictEqual(
+ decodedPermissions.ALL_PERMISSIONS,
+ true,
+ 'Decoded permissions includes ALL_PERMISSIONS',
+ );
+ });
+
+ it('should not decode CALL or ALL_PERMISSIONS if perms are missing', () => {
+ const permissions = { ALL_PERMISSIONS: true, CALL: false };
+ const encoded = encodePermissions(permissions);
+
+ const decodedPermissions = decodePermissions(encoded);
+
+ assert.strictEqual(
+ decodedPermissions.CALL,
+ false,
+ 'Decoded permissions includes CALL',
+ );
+ assert.strictEqual(
+ decodedPermissions.ALL_PERMISSIONS,
+ false,
+ 'Decoded permissions includes ALL_PERMISSIONS',
+ );
+ });
+
+ it('should allow editing of permissions', () => {
+ const permissions = { ALL_PERMISSIONS: true };
+ const encoded = encodePermissions(permissions);
+
+ const decodedPermissions = decodePermissions(encoded);
+ decodedPermissions.CALL = false;
+ const reencodePermissions = encodePermissions(decodedPermissions);
+ const redecodedPermissions = decodePermissions(reencodePermissions);
+
+ assert.strictEqual(
+ redecodedPermissions.CALL,
+ false,
+ 'Re-reencoded permissions includes CALL',
+ );
+ });
+
it('should ignore individual permissions when ALL_PERMISSIONS is set', () => {
const permissions = {
ALL_PERMISSIONS: true,
CHANGEOWNER: true,
};
- const encoded = ERC725.encodePermissions(permissions);
+ const encoded = encodePermissions(permissions);
assert.strictEqual(
encoded,
LSP6_DEFAULT_PERMISSIONS.ALL_PERMISSIONS,
@@ -1516,8 +1580,8 @@ describe('Running @erc725/erc725.js tests...', () => {
CHANGEOWNER: false, // Explicitly disable CHANGEOWNER
};
- const encoded = ERC725.encodePermissions(permissions);
- const decodedPermissions = ERC725.decodePermissions(encoded);
+ const encoded = encodePermissions(permissions);
+ const decodedPermissions = decodePermissions(encoded);
// check that the permission is disabled
assert.strictEqual(
@@ -1529,10 +1593,11 @@ describe('Running @erc725/erc725.js tests...', () => {
});
describe('decodePermissions', () => {
- testCases.forEach((testCase) => {
+ for (let i = 0; i < testCases.length; i++) {
+ const testCase = testCases[i];
it(`Decodes ${testCase.hex} permission correctly`, () => {
assert.deepStrictEqual(
- ERC725.decodePermissions(testCase.hex),
+ decodePermissions(testCase.hex),
testCase.permissions,
);
@@ -1541,10 +1606,10 @@ describe('Running @erc725/erc725.js tests...', () => {
testCase.permissions,
);
});
- });
- it(`Decodes 0xfff...fff admin permission correctly`, () => {
+ }
+ it('Decodes 0xfff...fff admin permission correctly', () => {
assert.deepStrictEqual(
- ERC725.decodePermissions(
+ decodePermissions(
'0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff',
),
{
@@ -1650,7 +1715,7 @@ describe('encodeKeyName', () => {
it('is available on instance and class', () => {
assert.deepStrictEqual(
- ERC725.encodeKeyName('MyKeyName'),
+ encodeKeyName('MyKeyName'),
'0x35e6950bc8d21a1699e58328a3c4066df5803bb0b570d0150cb3819288e764b2',
);
assert.deepStrictEqual(
@@ -1661,7 +1726,7 @@ describe('encodeKeyName', () => {
it('works for dynamic keys', () => {
assert.deepStrictEqual(
- ERC725.encodeKeyName(
+ encodeKeyName(
'FavouriteFood:
',
'0xa4FBbFe353124E6fa6Bb7f8e088a9269dF552EA2',
),
@@ -1681,7 +1746,7 @@ describe('supportsInterface', () => {
const erc725Instance = new ERC725([]);
it('is available on instance and class', () => {
- assert.typeOf(ERC725.supportsInterface, 'function');
+ assert.typeOf(supportsInterface, 'function');
assert.typeOf(erc725Instance.supportsInterface, 'function');
});
@@ -1691,7 +1756,7 @@ describe('supportsInterface', () => {
it('should throw when provided address is not an address', async () => {
try {
- await ERC725.supportsInterface(interfaceId, {
+ await supportsInterface(interfaceId, {
address: 'notAnAddress',
rpcUrl,
});
@@ -1702,7 +1767,7 @@ describe('supportsInterface', () => {
it('should throw when rpcUrl is not provided on non instantiated class', async () => {
try {
- await ERC725.supportsInterface(interfaceId, {
+ await supportsInterface(interfaceId, {
address: contractAddress,
// @ts-ignore
rpcUrl: undefined,
@@ -1736,7 +1801,7 @@ describe('checkPermissions', () => {
});
it('is available on class', () => {
- assert.typeOf(ERC725.checkPermissions, 'function');
+ assert.typeOf(checkPermissions, 'function');
const requiredPermissions = [
'0x0000000000000000000000000000000000000000000000000000000000000004',
@@ -1745,10 +1810,7 @@ describe('checkPermissions', () => {
const grantedPermissions =
'0x000000000000000000000000000000000000000000000000000000000000ff51';
- const result = ERC725.checkPermissions(
- requiredPermissions,
- grantedPermissions,
- );
+ const result = checkPermissions(requiredPermissions, grantedPermissions);
assert.equal(result, false);
});
diff --git a/src/index.ts b/src/index.ts
index 6006945b..badd0a79 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -20,54 +20,55 @@
* @date 2020
*/
-import { isAddress } from 'web3-utils';
import HttpProvider from 'web3-providers-http';
+import { isAddress } from 'web3-utils';
import { ProviderWrapper } from './provider/providerWrapper';
import {
- encodeData,
convertIPFSGatewayUrl,
- generateSchemasFromDynamicKeys,
duplicateMultiTypeERC725SchemaEntry,
+ encodeData,
+ generateSchemasFromDynamicKeys,
} from './lib/utils';
-import { getSchema } from './lib/schemaParser';
import { isValidSignature } from './lib/isValidSignature';
+import { getSchema } from './lib/schemaParser';
import { DEFAULT_GAS_VALUE } from './constants/constants';
import { encodeKeyName, isDynamicKeyName } from './lib/encodeKeyName';
+import { decodeData } from './lib/decodeData';
+import { decodeMappingKey } from './lib/decodeMappingKey';
+import { _supportsInterface, checkPermissions } from './lib/detector';
+import { decodeValueType, encodeValueType } from './lib/encoder';
+import { getData } from './lib/getData';
+import { getDataFromExternalSources } from './lib/getDataFromExternalSources';
+import { decodePermissions, encodePermissions } from './lib/permissions';
// Types
import { ERC725Config, ERC725Options } from './types/Config';
-import { Permissions } from './types/Method';
import {
ERC725JSONSchema,
ERC725JSONSchemaKeyType,
ERC725JSONSchemaValueContent,
ERC725JSONSchemaValueType,
} from './types/ERC725JSONSchema';
+import { GetDataDynamicKey, GetDataInput } from './types/GetData';
+import { Permissions } from './types/Method';
import {
DecodeDataInput,
DecodeDataOutput,
EncodeDataInput,
FetchDataOutput,
} from './types/decodeData';
-import { GetDataDynamicKey, GetDataInput } from './types/GetData';
-import { decodeData } from './lib/decodeData';
-import { getDataFromExternalSources } from './lib/getDataFromExternalSources';
import { DynamicKeyPart, DynamicKeyParts } from './types/dynamicKeys';
-import { getData } from './lib/getData';
-import { decodeValueType, encodeValueType } from './lib/encoder';
-import { supportsInterface, checkPermissions } from './lib/detector';
-import { decodeMappingKey } from './lib/decodeMappingKey';
-import { encodePermissions, decodePermissions } from './lib/permissions';
export {
ERC725JSONSchema,
ERC725JSONSchemaKeyType,
ERC725JSONSchemaValueContent,
ERC725JSONSchemaValueType,
+ Permissions,
};
export { ERC725Config, KeyValuePair, ProviderTypes } from './types';
@@ -82,7 +83,54 @@ export {
} from './lib/encoder';
export { getDataFromExternalSources } from './lib/getDataFromExternalSources';
export { encodePermissions, decodePermissions } from './lib/permissions';
-export { supportsInterface, checkPermissions } from './lib/detector';
+export { checkPermissions } from './lib/detector';
+
+// PRIVATE FUNCTION
+function initializeProvider(providerOrRpcUrl, gasInfo) {
+ // do not fail on no-provider
+ if (!providerOrRpcUrl) return undefined;
+
+ // if provider is a string, assume it's a rpcUrl
+ if (typeof providerOrRpcUrl === 'string') {
+ return new ProviderWrapper(new HttpProvider(providerOrRpcUrl), gasInfo);
+ }
+
+ if (
+ typeof providerOrRpcUrl.request === 'function' ||
+ typeof providerOrRpcUrl.send === 'function'
+ )
+ return new ProviderWrapper(providerOrRpcUrl, gasInfo);
+
+ throw new Error(`Incorrect or unsupported provider ${providerOrRpcUrl}`);
+}
+
+// PUBLIC FUNCTION
+export async function supportsInterface(
+ interfaceIdOrName: string,
+ options: {
+ address: string;
+ rpcUrl: string;
+ gas?: number;
+ provider?: ProviderWrapper;
+ },
+): Promise {
+ if (!isAddress(options.address)) {
+ throw new Error('Invalid address');
+ }
+ if (!options.rpcUrl) {
+ throw new Error('Missing RPC URL');
+ }
+
+ return _supportsInterface(interfaceIdOrName, {
+ address: options.address,
+ provider:
+ options.provider ||
+ initializeProvider(
+ options.rpcUrl,
+ options?.gas ? options?.gas : DEFAULT_GAS_VALUE,
+ ),
+ });
+}
/**
* This package is currently in early stages of development,
use only for testing or experimentation purposes.
@@ -181,21 +229,7 @@ export class ERC725 {
}
private static initializeProvider(providerOrRpcUrl, gasInfo) {
- // do not fail on no-provider
- if (!providerOrRpcUrl) return undefined;
-
- // if provider is a string, assume it's a rpcUrl
- if (typeof providerOrRpcUrl === 'string') {
- return new ProviderWrapper(new HttpProvider(providerOrRpcUrl), gasInfo);
- }
-
- if (
- typeof providerOrRpcUrl.request === 'function' ||
- typeof providerOrRpcUrl.send === 'function'
- )
- return new ProviderWrapper(providerOrRpcUrl, gasInfo);
-
- throw new Error(`Incorrect or unsupported provider ${providerOrRpcUrl}`);
+ return initializeProvider(providerOrRpcUrl, gasInfo);
}
private getAddressAndProvider() {
@@ -561,7 +595,7 @@ export class ERC725 {
async supportsInterface(interfaceIdOrName: string): Promise {
const { address, provider } = this.getAddressAndProvider();
- return supportsInterface(interfaceIdOrName, {
+ return _supportsInterface(interfaceIdOrName, {
address,
provider,
});
@@ -579,20 +613,7 @@ export class ERC725 {
interfaceIdOrName: string,
options: { address: string; rpcUrl: string; gas?: number },
): Promise {
- if (!isAddress(options.address)) {
- throw new Error('Invalid address');
- }
- if (!options.rpcUrl) {
- throw new Error('Missing RPC URL');
- }
-
- return supportsInterface(interfaceIdOrName, {
- address: options.address,
- provider: ERC725.initializeProvider(
- options.rpcUrl,
- options?.gas ? options?.gas : DEFAULT_GAS_VALUE,
- ),
- });
+ return supportsInterface(interfaceIdOrName, options);
}
/**
diff --git a/src/lib/decodeData.test.ts b/src/lib/decodeData.test.ts
index 65845c33..c69dc41b 100644
--- a/src/lib/decodeData.test.ts
+++ b/src/lib/decodeData.test.ts
@@ -308,8 +308,9 @@ describe('tuple', () => {
},
]; // TODO: add more cases? Address, etc.
- testCases.forEach((testCase) => {
- it(`decodes tuple values`, () => {
+ for (let i = 0; i < testCases.length; i++) {
+ const testCase = testCases[i];
+ it('decodes tuple values', () => {
expect(
decodeTupleKeyValue(
testCase.valueContent,
@@ -318,7 +319,7 @@ describe('tuple', () => {
),
).to.eql(testCase.decodedValue);
});
- });
+ }
});
describe('isValidTupleValueType', () => {
@@ -386,7 +387,8 @@ describe('tuple', () => {
},
];
- testCases.forEach((testCase) => {
+ for (let i = 0; i < testCases.length; i++) {
+ const testCase = testCases[i];
it(`detects valueType: ${testCase.valueType} valueContent: ${
testCase.valueContent
} as ${testCase.isTuple ? 'tuple' : 'non tuple'}`, () => {
@@ -401,6 +403,6 @@ describe('tuple', () => {
isValidTuple(testCase.valueType, testCase.valueContent),
).to.equal(testCase.isTuple);
});
- });
+ }
});
});
diff --git a/src/lib/decodeData.ts b/src/lib/decodeData.ts
index 360e35c1..85819b56 100644
--- a/src/lib/decodeData.ts
+++ b/src/lib/decodeData.ts
@@ -22,14 +22,14 @@
import { isHexStrict } from 'web3-utils';
import { COMPACT_BYTES_ARRAY_STRING } from '../constants/constants';
-import { DecodeDataInput, DecodeDataOutput } from '../types/decodeData';
import {
ALL_VALUE_TYPES,
ERC725JSONSchema,
isValidValueType,
} from '../types/ERC725JSONSchema';
+import { DecodeDataInput, DecodeDataOutput } from '../types/decodeData';
import { isDynamicKeyName } from './encodeKeyName';
-import { valueContentEncodingMap, decodeValueType } from './encoder';
+import { decodeValueType, valueContentEncodingMap } from './encoder';
import { getSchemaElement } from './getSchemaElement';
import { decodeKeyValue, encodeArrayKey } from './utils';
@@ -113,7 +113,7 @@ export const isValidTuple = (valueType: string, valueContent: string) => {
// is compatible with the valueType (e.g: bytes4)
const hexLiteralLength = valueContentParts[i].length - 2;
- if (parseInt(valueTypeBytesLength, 10) < hexLiteralLength) {
+ if (Number.parseInt(valueTypeBytesLength, 10) < hexLiteralLength) {
throw new Error(
`Invalid tuple (${valueType},${valueContent}: ${valueContent[i]} cannot fit in ${valueType[i]}`,
);
@@ -144,18 +144,20 @@ export const decodeTupleKeyValue = (
const bytesLengths: number[] = [];
- valueTypeParts.forEach((valueTypePart) => {
+ for (let i = 0; i < valueTypeParts.length; i++) {
+ const valueTypePart = valueTypeParts[i];
const regexMatch = valueTypePart.match(tupleValueTypesRegex);
// if we are dealing with `bytesN`
- if (regexMatch) bytesLengths.push(parseInt(regexMatch[1], 10));
+ if (regexMatch) bytesLengths.push(Number.parseInt(regexMatch[1], 10));
const numericMatch = valueTypePart.match(/u?int(\d+)/);
- if (numericMatch) bytesLengths.push(parseInt(numericMatch[1], 10) / 8);
+ if (numericMatch)
+ bytesLengths.push(Number.parseInt(numericMatch[1], 10) / 8);
if (valueTypePart === 'address') bytesLengths.push(20);
- });
+ }
const totalBytesLength = bytesLengths.reduce(
(acc, bytesLength) => acc + bytesLength,
@@ -289,9 +291,7 @@ export function decodeKey(schema: ERC725JSONSchema, value) {
}
default: {
console.error(
- 'Incorrect data match or keyType in schema from decodeKey(): "' +
- schema.keyType +
- '"',
+ `Incorrect data match or keyType in schema from decodeKey(): "${schema.keyType}"`,
);
return null;
}
diff --git a/src/lib/decodeMappingKey.test.ts b/src/lib/decodeMappingKey.test.ts
index 7f411ece..9a5f619d 100644
--- a/src/lib/decodeMappingKey.test.ts
+++ b/src/lib/decodeMappingKey.test.ts
@@ -145,7 +145,8 @@ describe('decodeDynamicKeyParts', () => {
];
it('decodes each dynamic key part', () => {
- records.forEach((record) => {
+ for (let i = 0; i < records.length; i++) {
+ const record = records[i];
const decodedDynamicKeyParts = decodeMappingKey(
record.key.encoded,
record.key.name,
@@ -157,7 +158,7 @@ describe('decodeDynamicKeyParts', () => {
expect(keyPart.type).to.equal(decodedDynamicKeyParts[index].type);
expect(keyPart.value).to.equal(decodedDynamicKeyParts[index].value);
});
- });
+ }
});
it('decodes each dynamic key part when schema as a param', () => {
@@ -193,7 +194,7 @@ describe('decodeDynamicKeyParts', () => {
'0x3234535343fXXWGWXWDSWDAEDFAEDr5434534grdgrdggrdgdrgdgrd098594334',
'MyKeyName:',
),
- ).to.throw(`Invalid encodedKey, must be a hexadecimal value`);
+ ).to.throw('Invalid encodedKey, must be a hexadecimal value');
});
it('throws if incorrect length key', () => {
@@ -203,7 +204,7 @@ describe('decodeDynamicKeyParts', () => {
'MyKeyName:',
),
).to.throw(
- `Invalid encodedKey length, key must be 32 bytes long hexadecimal value`,
+ 'Invalid encodedKey length, key must be 32 bytes long hexadecimal value',
);
});
});
diff --git a/src/lib/decodeMappingKey.ts b/src/lib/decodeMappingKey.ts
index 4071e2c9..0fd6d07c 100644
--- a/src/lib/decodeMappingKey.ts
+++ b/src/lib/decodeMappingKey.ts
@@ -19,9 +19,9 @@
*/
import { isHex, padLeft } from 'web3-utils';
-import { decodeValueType } from './encoder';
import { ERC725JSONSchema } from '../types/ERC725JSONSchema';
import { DynamicKeyPart } from '../types/dynamicKeys';
+import { decodeValueType } from './encoder';
function isDynamicKeyPart(keyPartName: string): boolean {
return (
@@ -42,14 +42,15 @@ function decodeKeyPart(
): DynamicKeyPart | false {
if (!isDynamicKeyPart(keyPartName)) return false;
- let decodedKey;
+ let decodedKey: string | boolean | number = '';
const type = keyPartName.slice(1, keyPartName.length - 1);
if (type === 'bool')
decodedKey = encodedKeyPart.slice(encodedKeyPart.length - 1) === '1';
- else if (type.includes('uint')) decodedKey = parseInt(encodedKeyPart, 16);
+ else if (type.includes('uint'))
+ decodedKey = Number.parseInt(encodedKeyPart, 16);
else if (type.includes('bytes')) {
- const bytesLength = parseInt(type.replace('bytes', ''), 10) * 2;
+ const bytesLength = Number.parseInt(type.replace('bytes', ''), 10) * 2;
const sliceFrom =
encodedKeyPart.length - bytesLength < 0
? 0
@@ -57,7 +58,7 @@ function decodeKeyPart(
decodedKey = encodedKeyPart.slice(sliceFrom);
} else if (type === 'address') {
// this is required if the 2nd word is an address in a MappingWithGrouping
- const leftPaddedAddress = padLeft('0x' + encodedKeyPart, 40);
+ const leftPaddedAddress = padLeft(`0x${encodedKeyPart}`, 40);
decodedKey = decodeValueType(type, leftPaddedAddress);
} else {
@@ -79,14 +80,14 @@ export function decodeMappingKey(
): DynamicKeyPart[] {
let hashedKey = keyHash;
if (hashedKey.length === 64 && hashedKey.slice(0, 2) !== '0x')
- hashedKey = '0x' + hashedKey;
+ hashedKey = `0x${hashedKey}`;
if (hashedKey.length !== 66)
throw new Error(
- `Invalid encodedKey length, key must be 32 bytes long hexadecimal value`,
+ 'Invalid encodedKey length, key must be 32 bytes long hexadecimal value',
);
if (!isHex(hashedKey.slice(2)))
- throw new Error(`Invalid encodedKey, must be a hexadecimal value`);
+ throw new Error('Invalid encodedKey, must be a hexadecimal value');
let keyParts: string[];
diff --git a/src/lib/detector.test.ts b/src/lib/detector.test.ts
index bfde55c0..ec418d25 100644
--- a/src/lib/detector.test.ts
+++ b/src/lib/detector.test.ts
@@ -24,7 +24,7 @@ import { expect } from 'chai';
import * as sinon from 'sinon';
import { INTERFACE_IDS_0_12_0 } from '../constants/interfaces';
-import { supportsInterface, checkPermissions } from './detector';
+import { _supportsInterface, checkPermissions } from './detector';
describe('supportsInterface', () => {
it('it should return true if the contract supports the interface with name', async () => {
@@ -37,7 +37,7 @@ describe('supportsInterface', () => {
.withArgs(contractAddress, INTERFACE_IDS_0_12_0[interfaceName])
.returns(Promise.resolve(true));
- const doesSupportInterface = await supportsInterface(interfaceName, {
+ const doesSupportInterface = await _supportsInterface(interfaceName, {
address: contractAddress,
provider: providerStub,
});
@@ -55,7 +55,7 @@ describe('supportsInterface', () => {
.withArgs(contractAddress, interfaceId)
.returns(Promise.resolve(true));
- const doesSupportInterface = await supportsInterface(interfaceId, {
+ const doesSupportInterface = await _supportsInterface(interfaceId, {
address: contractAddress,
provider: providerStub,
});
diff --git a/src/lib/detector.ts b/src/lib/detector.ts
index b60fb638..e6b407b2 100644
--- a/src/lib/detector.ts
+++ b/src/lib/detector.ts
@@ -36,7 +36,7 @@ import {
* @param options Object with address and RPC URL.
* @returns {Promise} if interface is supported.
*/
-export const supportsInterface = async (
+export const _supportsInterface = async (
interfaceIdOrName: string,
options: AddressProviderOptions,
): Promise => {
diff --git a/src/lib/encodeKeyName.test.ts b/src/lib/encodeKeyName.test.ts
index 31e44922..acb5688e 100644
--- a/src/lib/encodeKeyName.test.ts
+++ b/src/lib/encodeKeyName.test.ts
@@ -214,14 +214,15 @@ describe('encodeKeyName', () => {
},
];
- testCases.forEach((testCase) => {
+ for (let i = 0; i < testCases.length; i++) {
+ const testCase = testCases[i];
it(`encodes ${testCase.keyName} key name correctly`, () => {
assert.deepStrictEqual(
encodeKeyName(testCase.keyName, testCase.dynamicKeyParts),
testCase.expectedKey,
);
});
- });
+ }
it('throws if trying to encode a dynamic key without any variable', () => {
assert.throws(() => encodeKeyName('MyDynamicKey:'));
@@ -288,7 +289,8 @@ describe('isDynamicKeyName', () => {
},
];
- testCases.forEach((testCase) => {
+ for (let i = 0; i < testCases.length; i++) {
+ const testCase = testCases[i];
it(`detects ${
testCase.isDynamicKeyName ? 'dynamic' : 'non-dynamic'
} key name: ${testCase.keyName} correctly`, () => {
@@ -297,7 +299,7 @@ describe('isDynamicKeyName', () => {
testCase.isDynamicKeyName,
);
});
- });
+ }
});
describe('encodeDynamicKeyPart', () => {
@@ -383,14 +385,15 @@ describe('encodeDynamicKeyPart', () => {
},
];
- testCases.forEach((testCase) => {
+ for (let i = 0; i < testCases.length; i++) {
+ const testCase = testCases[i];
it(`encodes: ${testCase.value} of type: ${testCase.type} correctly`, () => {
assert.deepStrictEqual(
encodeDynamicKeyPart(testCase.type, testCase.value, testCase.bytes),
testCase.expectedEncoding,
);
});
- });
+ }
it('throws if is called with non hex values', () => {
assert.throws(() =>
@@ -435,14 +438,15 @@ describe('generateDynamicKeyName', () => {
},
];
- testCases.forEach((testCase) => {
+ for (let i = 0; i < testCases.length; i++) {
+ const testCase = testCases[i];
it(`generates key name: ${testCase.keyName} correctly`, () => {
assert.deepStrictEqual(
generateDynamicKeyName(testCase.keyName, testCase.dynamicKeyParts),
testCase.expectedKeyName,
);
});
- });
+ }
it('throws if encoding with wrong number of dynamic values', () => {
assert.throws(() =>
diff --git a/src/lib/encodeKeyName.ts b/src/lib/encodeKeyName.ts
index 733146c6..863e56d4 100644
--- a/src/lib/encodeKeyName.ts
+++ b/src/lib/encodeKeyName.ts
@@ -26,8 +26,8 @@ import {
padLeft,
} from 'web3-utils';
-import { guessKeyTypeFromKeyName } from './utils';
import { DynamicKeyParts } from '../types/dynamicKeys';
+import { guessKeyTypeFromKeyName } from './utils';
// https://github.com/lukso-network/LIPs/blob/main/LSPs/LSP-2-ERC725YJSONSchema.md#mapping
@@ -61,7 +61,7 @@ export const encodeDynamicKeyPart = (
// eslint-disable-next-line prefer-destructuring
baseType = regexMatch[1];
- size = parseInt(regexMatch[2], 10);
+ size = Number.parseInt(regexMatch[2], 10);
}
switch (baseType) {
diff --git a/src/lib/encoder.test.ts b/src/lib/encoder.test.ts
index ed170fca..94bcdf3b 100644
--- a/src/lib/encoder.test.ts
+++ b/src/lib/encoder.test.ts
@@ -14,29 +14,29 @@
/* eslint-disable no-unused-expressions */
-import { expect, assert } from 'chai';
+import { assert, expect } from 'chai';
import {
keccak256,
- utf8ToHex,
+ padLeft,
stripHexPrefix,
toBN,
toHex,
- padLeft,
+ utf8ToHex,
} from 'web3-utils';
-import {
- valueContentEncodingMap,
- encodeValueType,
- decodeValueType,
- encodeValueContent,
- decodeValueContent,
-} from './encoder';
import {
NONE_VERIFICATION_METHOD,
SUPPORTED_VERIFICATION_METHOD_HASHES,
SUPPORTED_VERIFICATION_METHOD_STRINGS,
} from '../constants/constants';
import { URLDataToEncode, URLDataWithHash } from '../types';
+import {
+ decodeValueContent,
+ decodeValueType,
+ encodeValueContent,
+ encodeValueType,
+ valueContentEncodingMap,
+} from './encoder';
describe('encoder', () => {
describe('valueType', () => {
@@ -64,7 +64,8 @@ describe('encoder', () => {
},
];
- validTestCases.forEach((testCase) => {
+ for (let i = 0; i < validTestCases.length; i++) {
+ const testCase = validTestCases[i];
it(`encodes/decodes: ${testCase.decodedValue} as ${testCase.valueType}`, () => {
const encodedValue = encodeValueType(
testCase.valueType,
@@ -77,7 +78,7 @@ describe('encoder', () => {
testCase.decodedValue,
);
});
- });
+ }
});
describe('`bytes4` type', () => {
@@ -94,7 +95,8 @@ describe('encoder', () => {
},
];
- validTestCases.forEach((testCase) => {
+ for (let i = 0; i < validTestCases.length; i++) {
+ const testCase = validTestCases[i];
it(`encodes/decodes: ${testCase.decodedValue} as ${testCase.valueType}`, () => {
const encodedValue = encodeValueType(
testCase.valueType,
@@ -107,7 +109,7 @@ describe('encoder', () => {
testCase.decodedValue,
);
});
- });
+ }
const errorEncodingTestCases = [
{
@@ -128,13 +130,14 @@ describe('encoder', () => {
},
];
- errorEncodingTestCases.forEach((testCase) => {
+ for (let i = 0; i < errorEncodingTestCases.length; i++) {
+ const testCase = errorEncodingTestCases[i];
it(`should throw when trying to encode ${testCase.input} as ${testCase.valueType}`, async () => {
assert.throws(() =>
encodeValueType(testCase.valueType, testCase.input),
);
});
- });
+ }
// these cases are not symetric. The input is converted + encoded.
// When decoding, we do not get the same input back, but its bytes4 hex representation
@@ -153,7 +156,8 @@ describe('encoder', () => {
},
];
- oneWayEncodingTestCases.forEach((testCase) => {
+ for (let i = 0; i < oneWayEncodingTestCases.length; i++) {
+ const testCase = oneWayEncodingTestCases[i];
it(`encodes one way \`input\` = ${testCase.input} as ${testCase.valueType}, but does not decode back as the same input`, async () => {
const encodedValue = encodeValueType(
testCase.valueType,
@@ -166,7 +170,7 @@ describe('encoder', () => {
testCase.decodedValue,
);
});
- });
+ }
// these cases are not symetric and right pad the value
const rightPaddedTestCases = [
@@ -184,7 +188,8 @@ describe('encoder', () => {
},
];
- rightPaddedTestCases.forEach((testCase) => {
+ for (let i = 0; i < rightPaddedTestCases.length; i++) {
+ const testCase = rightPaddedTestCases[i];
it(`encodes + right pad \`input\` = ${testCase.input} as ${testCase.valueType} padded on the right with \`00\`s`, async () => {
const encodedValue = encodeValueType(
testCase.valueType,
@@ -197,7 +202,7 @@ describe('encoder', () => {
testCase.decodedValue,
);
});
- });
+ }
});
describe('`bytes32` type', () => {
@@ -218,7 +223,8 @@ describe('encoder', () => {
},
];
- validTestCases.forEach((testCase) => {
+ for (let i = 0; i < validTestCases.length; i++) {
+ const testCase = validTestCases[i];
it(`encodes/decodes: ${testCase.decodedValue} as ${testCase.valueType}`, () => {
const encodedValue = encodeValueType(
testCase.valueType,
@@ -231,7 +237,7 @@ describe('encoder', () => {
testCase.decodedValue,
);
});
- });
+ }
const errorEncodingTestCases = [
{
@@ -250,20 +256,20 @@ describe('encoder', () => {
// over the max uint256 allowed, does not fit in 32 bytes
input: toHex(
toBN(
- '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff' +
- 1,
- ),
+ '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff',
+ ).add(toBN(1)),
),
},
];
- errorEncodingTestCases.forEach((testCase) => {
+ for (let i = 0; i < errorEncodingTestCases.length; i++) {
+ const testCase = errorEncodingTestCases[i];
it(`should throw when trying to encode ${testCase.input} as ${testCase.valueType}`, async () => {
assert.throws(() =>
encodeValueType(testCase.valueType, testCase.input),
);
});
- });
+ }
const oneWayEncodingTestCases = [
{
@@ -284,7 +290,8 @@ describe('encoder', () => {
},
];
- oneWayEncodingTestCases.forEach((testCase) => {
+ for (let i = 0; i < oneWayEncodingTestCases.length; i++) {
+ const testCase = oneWayEncodingTestCases[i];
it(`encodes one way \`input\` = ${testCase.input} as ${testCase.valueType}, but does not decode back as the same input`, async () => {
const encodedValue = encodeValueType(
testCase.valueType,
@@ -297,7 +304,7 @@ describe('encoder', () => {
testCase.decodedValue,
);
});
- });
+ }
// these cases are not symetric and right pad the value
const rightPaddedTestCases = [
@@ -319,7 +326,8 @@ describe('encoder', () => {
},
];
- rightPaddedTestCases.forEach((testCase) => {
+ for (let i = 0; i < rightPaddedTestCases.length; i++) {
+ const testCase = rightPaddedTestCases[i];
it(`encodes + right pad \`input\` = ${testCase.input} as ${testCase.valueType} padded on the right with \`00\`s`, async () => {
const encodedValue = encodeValueType(
testCase.valueType,
@@ -332,7 +340,7 @@ describe('encoder', () => {
testCase.decodedValue,
);
});
- });
+ }
});
describe('`uintN` type', () => {
@@ -375,7 +383,8 @@ describe('encoder', () => {
},
];
- validTestCases.forEach((testCase) => {
+ for (let i = 0; i < validTestCases.length; i++) {
+ const testCase = validTestCases[i];
it(`encodes/decodes: ${testCase.decodedValue} as ${testCase.valueType}`, () => {
const encodedValue = encodeValueType(
testCase.valueType,
@@ -388,7 +397,7 @@ describe('encoder', () => {
testCase.decodedValue,
);
});
- });
+ }
it('should throw an error when trying to encode/decode with an invalid `uintN` type', async () => {
for (let ii = 1; ii <= 256; ii++) {
@@ -427,7 +436,8 @@ describe('encoder', () => {
},
];
- validTestCases.forEach((testCase) => {
+ for (let i = 0; i < validTestCases.length; i++) {
+ const testCase = validTestCases[i];
it(`encodes/decodes: ${testCase.decodedValue} as ${testCase.valueType}`, () => {
const encodedValue = encodeValueType(
testCase.valueType,
@@ -440,7 +450,7 @@ describe('encoder', () => {
testCase.decodedValue,
);
});
- });
+ }
it('should encode each letter in a number as a utf8 character, and decode it back as a string', () => {
const testCase = {
@@ -472,7 +482,8 @@ describe('encoder', () => {
},
];
- validTestCases.forEach((testCase) => {
+ for (let i = 0; i < validTestCases.length; i++) {
+ const testCase = validTestCases[i];
it(`encodes/decodes: ${testCase.decodedValue} as ${testCase.valueType}`, () => {
const encodedValue = encodeValueType(
testCase.valueType,
@@ -485,7 +496,7 @@ describe('encoder', () => {
testCase.decodedValue,
);
});
- });
+ }
const errorEncodingTestCases = [
{
@@ -498,13 +509,14 @@ describe('encoder', () => {
},
];
- errorEncodingTestCases.forEach((testCase) => {
+ for (let i = 0; i < errorEncodingTestCases.length; i++) {
+ const testCase = errorEncodingTestCases[i];
it(`should throw when trying to encode ${testCase.input} as ${testCase.valueType}`, async () => {
assert.throws(() =>
encodeValueType(testCase.valueType, testCase.input),
);
});
- });
+ }
});
describe('`bytes` type', () => {
@@ -528,7 +540,8 @@ describe('encoder', () => {
},
];
- validTestCases.forEach((testCase) => {
+ for (let i = 0; i < validTestCases.length; i++) {
+ const testCase = validTestCases[i];
it(`encodes/decodes: ${testCase.decodedValue} as ${testCase.valueType}`, () => {
const encodedValue = encodeValueType(
testCase.valueType,
@@ -541,7 +554,7 @@ describe('encoder', () => {
testCase.decodedValue,
);
});
- });
+ }
});
describe('arrays `[]` of static types', () => {
@@ -617,7 +630,8 @@ describe('encoder', () => {
},
];
- validTestCases.forEach((testCase) => {
+ for (let i = 0; i < validTestCases.length; i++) {
+ const testCase = validTestCases[i];
it(`encodes/decodes: ${testCase.decodedValue} as ${testCase.valueType}`, () => {
const encodedValue = encodeValueType(
testCase.valueType,
@@ -630,7 +644,7 @@ describe('encoder', () => {
testCase.decodedValue,
);
});
- });
+ }
});
describe('when encoding a value that exceeds the maximal length of bytes than its type', () => {
@@ -644,13 +658,14 @@ describe('encoder', () => {
},
];
- validTestCases.forEach((testCase) => {
+ for (let i = 0; i < validTestCases.length; i++) {
+ const testCase = validTestCases[i];
it('should throw', async () => {
assert.throws(() =>
encodeValueType(testCase.valueType, testCase.decodedValue),
);
});
- });
+ }
});
describe('when encoding/decoding a value that is not a number as a `uint128`', () => {
@@ -728,7 +743,8 @@ describe('encoder', () => {
},
];
- validTestCases.forEach((testCase) => {
+ for (let i = 0; i < validTestCases.length; i++) {
+ const testCase = validTestCases[i];
it(`encodes/decodes: ${testCase.decodedValue} as ${testCase.valueType}`, () => {
const encodedValue = encodeValueType(
testCase.valueType,
@@ -741,7 +757,7 @@ describe('encoder', () => {
testCase.decodedValue,
);
});
- });
+ }
describe('when encoding bytes[CompactBytesArray]', () => {
it('should encode `0x` elements as `0x0000`', async () => {
@@ -787,7 +803,7 @@ describe('encoder', () => {
it('should throw when trying to encode a `bytes[CompactBytesArray]` with a bytes length bigger than 65_535', async () => {
expect(() => {
encodeValueType('bytes[CompactBytesArray]', [
- '0x' + 'ab'.repeat(66_0000),
+ `0x${'ab'.repeat(66_0000)}`,
]);
}).to.throw(
"Couldn't encode bytes[CompactBytesArray], value at index 0 exceeds 65_535 bytes",
@@ -963,7 +979,8 @@ describe('encoder', () => {
},
];
- testCases.forEach((testCase) => {
+ for (let i = 0; i < testCases.length; i++) {
+ const testCase = testCases[i];
it(`encodes/decodes: ${testCase.valueContent}`, () => {
const encodedValue = encodeValueContent(
testCase.valueContent,
@@ -983,7 +1000,7 @@ describe('encoder', () => {
testCase.decodedValue,
);
});
- });
+ }
it('encodes/decodes: JSONURL', () => {
const dataToEncode: URLDataToEncode = {
diff --git a/src/lib/encoder.ts b/src/lib/encoder.ts
index 7092f3b6..94712faf 100644
--- a/src/lib/encoder.ts
+++ b/src/lib/encoder.ts
@@ -28,6 +28,8 @@
import AbiCoder from 'web3-eth-abi';
import {
+ bytesToHex,
+ hexToBytes,
hexToNumber,
hexToUtf8,
isAddress,
@@ -35,30 +37,28 @@ import {
keccak256,
numberToHex,
padLeft,
- toChecksumAddress,
- utf8ToHex,
stripHexPrefix,
- hexToBytes,
- bytesToHex,
- toHex,
toBN,
+ toChecksumAddress,
+ toHex,
+ utf8ToHex,
} from 'web3-utils';
import { URLDataToEncode, URLDataWithHash, Verification } from '../types';
import { AssetURLEncode } from '../types/encodeData';
import {
- SUPPORTED_VERIFICATION_METHOD_STRINGS,
NONE_VERIFICATION_METHOD,
+ SUPPORTED_VERIFICATION_METHOD_STRINGS,
} from '../constants/constants';
+import { ERC725JSONSchemaValueType } from '../types/ERC725JSONSchema';
import {
+ countNumberOfBytes,
+ countSignificantBits,
getVerificationMethod,
hashData,
- countNumberOfBytes,
isValidUintSize,
- countSignificantBits,
} from './utils';
-import { ERC725JSONSchemaValueType } from '../types/ERC725JSONSchema';
const abiCoder = AbiCoder;
@@ -119,7 +119,7 @@ const decodeDataSourceWithHash = (value: string): URLDataWithHash => {
const encodedLength = `0x${value.slice(14, 18)}`; // Rest of data string after function hash
const dataLength = hexToNumber(encodedLength, false) as number;
const dataHash = `0x${value.slice(18, 18 + dataLength * 2)}`; // Get jsonHash 32 bytes
- const dataSource = hexToUtf8('0x' + value.slice(18 + dataLength * 2)); // Get remainder as URI
+ const dataSource = hexToUtf8(`0x${value.slice(18 + dataLength * 2)}`); // Get remainder as URI
return {
verification: {
@@ -144,7 +144,7 @@ const decodeDataSourceWithHash = (value: string): URLDataWithHash => {
// Special case where JSONURL is really (bytes4,URI) as specified
// by the old version of LSP8TokenMetadataBaseURI
// Catch error in case the buffor is not convertable to utf8.
- const dataSource = hexToUtf8('0x' + encodedData); // Get as URI
+ const dataSource = hexToUtf8(`0x${encodedData}`); // Get as URI
if (encodedData.length < 64 || /^[a-z]{2,}:[/\S]/.test(dataSource)) {
// If the verification data starts with a utf8 sequence that looks like https:/ or data: or ar:/ for example.
return {
@@ -159,8 +159,8 @@ const decodeDataSourceWithHash = (value: string): URLDataWithHash => {
// ignore
}
- const dataHash = '0x' + encodedData.slice(0, 64); // Get jsonHash 32 bytes
- const dataSource = hexToUtf8('0x' + encodedData.slice(64)); // Get remainder as URI
+ const dataHash = `0x${encodedData.slice(0, 64)}`; // Get jsonHash 32 bytes
+ const dataSource = hexToUtf8(`0x${encodedData.slice(64)}`); // Get remainder as URI
return {
verification: {
@@ -187,7 +187,7 @@ const encodeToBytesN = (
valueToEncode = value;
}
- const numberOfBytesInType = parseInt(bytesN.split('bytes')[1], 10);
+ const numberOfBytesInType = Number.parseInt(bytesN.split('bytes')[1], 10);
const numberOfBytesInValue = countNumberOfBytes(valueToEncode);
if (numberOfBytesInValue > numberOfBytesInType) {
@@ -256,7 +256,7 @@ const decodeCompactBytesArray = (compactBytesArray: string): string[] => {
while (pointer < strippedCompactBytesArray.length) {
const length = Number(
- hexToNumber('0x' + strippedCompactBytesArray.slice(pointer, pointer + 4)),
+ hexToNumber(`0x${strippedCompactBytesArray.slice(pointer, pointer + 4)}`),
);
if (length === 0) {
@@ -264,11 +264,10 @@ const decodeCompactBytesArray = (compactBytesArray: string): string[] => {
encodedValues.push('');
} else {
encodedValues.push(
- '0x' +
- strippedCompactBytesArray.slice(
- pointer + 4,
- pointer + 2 * (length + 2),
- ),
+ `0x${strippedCompactBytesArray.slice(
+ pointer + 4,
+ pointer + 2 * (length + 2),
+ )}`,
);
}
@@ -444,7 +443,7 @@ const valueTypeEncodingMap = (
const uintNRegexMatch = type.match(uintNValueTypeRegex);
const uintLength = uintNRegexMatch
- ? parseInt(uintNRegexMatch[0].slice(4), 10)
+ ? Number.parseInt(uintNRegexMatch[0].slice(4), 10)
: '';
if (type.includes('[CompactBytesArray]')) {
@@ -604,7 +603,7 @@ const valueTypeEncodingMap = (
// we want to return an array of numbers as [1, 2, 3], not an array of strings as [ '1', '2', '3']
return abiCoder
.decodeParameter('uint256[]', value)
- .map((numberAsString) => parseInt(numberAsString, 10));
+ .map((numberAsString) => Number.parseInt(numberAsString, 10));
},
};
case 'bytes32[]':
@@ -661,7 +660,9 @@ export const valueContentEncodingMap = (
decode: (value: string) => any;
} => {
const bytesNRegexMatch = valueContent.match(BytesNValueContentRegex);
- const bytesLength = bytesNRegexMatch ? parseInt(bytesNRegexMatch[1], 10) : '';
+ const bytesLength = bytesNRegexMatch
+ ? Number.parseInt(bytesNRegexMatch[1], 10)
+ : '';
switch (valueContent) {
case 'Keccak256': {
@@ -677,7 +678,7 @@ export const valueContentEncodingMap = (
encode: (value: string) => {
let parsedValue: number;
try {
- parsedValue = parseInt(value, 10);
+ parsedValue = Number.parseInt(value, 10);
} catch (error: any) {
throw new Error(error);
}
@@ -696,7 +697,7 @@ export const valueContentEncodingMap = (
return value.toLowerCase();
}
- throw new Error('Address: "' + value + '" is an invalid address.');
+ throw new Error(`Address: "${value}" is an invalid address.`);
},
decode: (value: string) => toChecksumAddress(value),
};
diff --git a/src/lib/getData.ts b/src/lib/getData.ts
index acff7746..09ef3c79 100644
--- a/src/lib/getData.ts
+++ b/src/lib/getData.ts
@@ -1,15 +1,15 @@
-import { DecodeDataOutput } from '../types/decodeData';
+import { KeyValuePair } from '../types';
+import { ERC725Options } from '../types/Config';
+import { ERC725JSONSchema } from '../types/ERC725JSONSchema';
import { GetDataDynamicKey, GetDataInput } from '../types/GetData';
+import { DecodeDataOutput } from '../types/decodeData';
+import { decodeData } from './decodeData';
import { isDynamicKeyName } from './encodeKeyName';
import {
decodeKeyValue,
encodeArrayKey,
generateSchemasFromDynamicKeys,
} from './utils';
-import { KeyValuePair } from '../types';
-import { decodeData } from './decodeData';
-import { ERC725JSONSchema } from '../types/ERC725JSONSchema';
-import { ERC725Options } from '../types/Config';
/**
* @internal
@@ -160,8 +160,9 @@ const getDataMultiple = async (
export const getData = async (
erc725Options: ERC725Options,
- keyOrKeys?: GetDataInput,
+ _keyOrKeys?: GetDataInput,
): Promise => {
+ let keyOrKeys = _keyOrKeys;
if (!keyOrKeys) {
// eslint-disable-next-line no-param-reassign
keyOrKeys = erc725Options.schemas
diff --git a/src/lib/getDataFromExternalSources.test.ts b/src/lib/getDataFromExternalSources.test.ts
index c8cd7659..6dcec1af 100644
--- a/src/lib/getDataFromExternalSources.test.ts
+++ b/src/lib/getDataFromExternalSources.test.ts
@@ -18,8 +18,8 @@ import { expect } from 'chai';
import { ERC725JSONSchema } from '../types/ERC725JSONSchema';
-import { getDataFromExternalSources } from './getDataFromExternalSources';
import { DecodeDataOutput } from '../types/decodeData';
+import { getDataFromExternalSources } from './getDataFromExternalSources';
const IPFS_GATEWAY_MOCK = 'https://mock-ipfs.mock/ipfs/';
diff --git a/src/lib/getDataFromExternalSources.ts b/src/lib/getDataFromExternalSources.ts
index dd6416ff..599dd881 100644
--- a/src/lib/getDataFromExternalSources.ts
+++ b/src/lib/getDataFromExternalSources.ts
@@ -21,13 +21,13 @@
import { arrToBufArr } from 'ethereumjs-util';
+import { URLDataWithHash } from '../types';
+import { ERC725JSONSchema } from '../types/ERC725JSONSchema';
import {
DecodeDataOutput,
GetDataExternalSourcesOutput,
} from '../types/decodeData';
-import { ERC725JSONSchema } from '../types/ERC725JSONSchema';
import { isDataAuthentic, patchIPFSUrlsIfApplicable } from './utils';
-import { URLDataWithHash } from '../types';
export const getDataFromExternalSources = (
schemas: ERC725JSONSchema[],
diff --git a/src/lib/getSchemaElement.ts b/src/lib/getSchemaElement.ts
index 139f70d1..cbe8c3c7 100644
--- a/src/lib/getSchemaElement.ts
+++ b/src/lib/getSchemaElement.ts
@@ -18,8 +18,8 @@
*/
import { isHex, isHexStrict } from 'web3-utils';
-import { DynamicKeyParts } from '../types/dynamicKeys';
import { ERC725JSONSchema } from '../types/ERC725JSONSchema';
+import { DynamicKeyParts } from '../types/dynamicKeys';
import {
encodeKeyName,
generateDynamicKeyName,
diff --git a/src/lib/permissions.ts b/src/lib/permissions.ts
index ce27dc81..b3319bec 100644
--- a/src/lib/permissions.ts
+++ b/src/lib/permissions.ts
@@ -1,56 +1,33 @@
import { hexToNumber, leftPad, toHex } from 'web3-utils';
-import {
- LSP6_ALL_PERMISSIONS,
- LSP6_DEFAULT_PERMISSIONS,
-} from '../constants/constants';
+import { LSP6_DEFAULT_PERMISSIONS } from '../constants/constants';
import { Permissions } from '../types/Method';
export function encodePermissions(permissions: Permissions): string {
let basePermissions = BigInt(0);
- // If ALL_PERMISSIONS is requested, start with that as the base
- if (permissions.ALL_PERMISSIONS) {
- basePermissions = BigInt(
- hexToNumber(LSP6_DEFAULT_PERMISSIONS.ALL_PERMISSIONS),
- );
- }
-
- // Explicitly add REENTRANCY, DELEGATECALL, and SUPER_DELEGATECALL if requested (they are not included in ALL_PERMISSIONS)
- const additionalPermissions = [
- LSP6_DEFAULT_PERMISSIONS.REENTRANCY,
- LSP6_DEFAULT_PERMISSIONS.DELEGATECALL,
- LSP6_DEFAULT_PERMISSIONS.SUPER_DELEGATECALL,
- ];
- // Do not use an for of loop here to not require the regenerator runtime
- for (let i = 0; i < additionalPermissions.length; i += 1) {
- const permission = additionalPermissions[i];
- if (permissions[permission]) {
- basePermissions |= BigInt(
- hexToNumber(LSP6_DEFAULT_PERMISSIONS[permission]),
- );
- }
- }
-
// Process each permission to potentially switch off permissions included in ALL_PERMISSIONS
- const keys = Object.keys(permissions);
+ // Deal with ALL_PERMISSIONS first IMPORTANT!
+ const keys = Object.keys(permissions).filter(
+ (key) => key !== 'ALL_PERMISSIONS',
+ );
+ keys.splice(0, 0, 'ALL_PERMISSIONS');
// Do not use an for of loop here to not require the regenerator runtime
for (let i = 0; i < keys.length; i += 1) {
const key = keys[i];
- const permissionValue = BigInt(hexToNumber(LSP6_DEFAULT_PERMISSIONS[key]));
-
+ const permissionValue = BigInt(
+ hexToNumber(LSP6_DEFAULT_PERMISSIONS[key], true),
+ );
+ console.log(
+ 'update',
+ key,
+ permissions[key],
+ permissionValue,
+ basePermissions,
+ );
if (permissions[key]) {
- // If not dealing with ALL_PERMISSIONS or additional permissions, ensure they are added
- if (
- !additionalPermissions.includes(key) &&
- key !== LSP6_DEFAULT_PERMISSIONS.ALL_PERMISSIONS
- ) {
- basePermissions |= permissionValue;
- }
- } else if (
- LSP6_DEFAULT_PERMISSIONS[key] !== LSP6_DEFAULT_PERMISSIONS.ALL_PERMISSIONS
- ) {
- // If permission is set to false, remove it from the basePermissions
- basePermissions &= ~permissionValue;
+ basePermissions |= permissionValue;
+ } else {
+ basePermissions = basePermissions & ~permissionValue;
}
}
// Convert the final BigInt permission value back to a hex string, properly padded
@@ -87,22 +64,16 @@ export function decodePermissions(permissionHex: string) {
};
const permissionsToTest = Object.keys(LSP6_DEFAULT_PERMISSIONS);
- if (permissionHex === LSP6_ALL_PERMISSIONS) {
- // Do not use an for of loop here to not require the regenerator runtime
- for (let i = 0; i < permissionsToTest.length; i += 1) {
- const testPermission = permissionsToTest[i];
- result[testPermission] = true;
- }
- return result;
- }
-
- const passedPermissionDecimal = Number(hexToNumber(permissionHex));
+ const passedPermissionDecimal = BigInt(hexToNumber(permissionHex, true));
// Do not use an for of loop here to not require the regenerator runtime
+ // Deal with ALL_PERMISSIONS the same way. So as long as all the bits in ALL_PERMISSIONS
+ // are set the same way as in ALL_PERMISSIONS then this flag will return as true.
+ // It does not mean some extra permissions are not included.
for (let i = 0; i < permissionsToTest.length; i += 1) {
const testPermission = permissionsToTest[i];
- const decimalTestPermission = Number(
- hexToNumber(LSP6_DEFAULT_PERMISSIONS[testPermission]),
+ const decimalTestPermission = BigInt(
+ hexToNumber(LSP6_DEFAULT_PERMISSIONS[testPermission], true),
);
const isPermissionIncluded =
(passedPermissionDecimal & decimalTestPermission) ===
diff --git a/src/lib/schemaParser.ts b/src/lib/schemaParser.ts
index 2d7ae125..d2e94c52 100644
--- a/src/lib/schemaParser.ts
+++ b/src/lib/schemaParser.ts
@@ -74,7 +74,7 @@ const findArraySchemaForKey = (
return null;
}
- const elementIndex = parseInt(key.substring(34), 10);
+ const elementIndex = Number.parseInt(key.substring(34), 10);
return {
...arraySchema,
diff --git a/src/lib/utils.test.ts b/src/lib/utils.test.ts
index 27a75b2a..30000c3a 100644
--- a/src/lib/utils.test.ts
+++ b/src/lib/utils.test.ts
@@ -14,8 +14,8 @@
/* eslint-disable no-unused-expressions */
-import { expect } from 'chai';
import assert from 'assert';
+import { expect } from 'chai';
import { keccak256, utf8ToHex } from 'web3-utils';
import {
@@ -26,22 +26,22 @@ import {
import { GetDataDynamicKey } from '../types/GetData';
import { SUPPORTED_VERIFICATION_METHOD_STRINGS } from '../constants/constants';
+import { decodeKey } from './decodeData';
+import { isDynamicKeyName } from './encodeKeyName';
import {
- guessKeyTypeFromKeyName,
- isDataAuthentic,
- encodeKeyValue,
+ convertIPFSGatewayUrl,
+ countSignificantBits,
decodeKeyValue,
- encodeKey,
+ duplicateMultiTypeERC725SchemaEntry,
encodeData,
- convertIPFSGatewayUrl,
- generateSchemasFromDynamicKeys,
+ encodeKey,
+ encodeKeyValue,
encodeTupleKeyValue,
- duplicateMultiTypeERC725SchemaEntry,
+ generateSchemasFromDynamicKeys,
+ guessKeyTypeFromKeyName,
+ isDataAuthentic,
splitMultiDynamicKeyNamePart,
- countSignificantBits,
} from './utils';
-import { isDynamicKeyName } from './encodeKeyName';
-import { decodeKey } from './decodeData';
describe('utils', () => {
describe('encodeKey/decodeKey', () => {
@@ -223,7 +223,8 @@ describe('utils', () => {
},
];
- testCases.forEach((testCase) => {
+ for (let i = 0; i < testCases.length; i++) {
+ const testCase = testCases[i];
it(`encodes/decodes keyType Array / tuples (valueContent: ${testCase.schema.valueContent}, valueType: ${testCase.schema.valueType}`, () => {
assert.deepStrictEqual(
encodeKey(testCase.schema as ERC725JSONSchema, testCase.decodedValue),
@@ -235,7 +236,7 @@ describe('utils', () => {
testCase.decodedValue,
);
});
- });
+ }
it('should encode the array length only if passing a number', async () => {
const schema: ERC725JSONSchema = {
@@ -266,11 +267,12 @@ describe('utils', () => {
{ value: '0x1000', result: 13 },
{ value: '0x000f', result: 4 },
];
- testCases.forEach(({ value, result }) => {
+ for (let i = 0; i < testCases.length; i++) {
+ const { value, result } = testCases[i];
it(`should count the number of bits in ${value}`, () => {
assert.equal(countSignificantBits(value), result);
});
- });
+ }
});
describe('encodeKeyValue/decodeKeyValue', () => {
@@ -382,7 +384,8 @@ describe('utils', () => {
},
];
- testCases.forEach((testCase) => {
+ for (let i = 0; i < testCases.length; i++) {
+ const testCase = testCases[i];
it(`encodes correctly valueContent ${testCase.valueContent} to valueType: ${testCase.valueType}`, () => {
assert.strictEqual(
encodeKeyValue(
@@ -403,7 +406,7 @@ describe('utils', () => {
testCase.decodedValue,
);
});
- });
+ }
});
describe('encodeTupleKeyValue', () => {
@@ -416,8 +419,9 @@ describe('utils', () => {
},
]; // we may need to add more test cases! Address, etc.
- testCases.forEach((testCase) => {
- it(`encodes tuple values`, () => {
+ for (let i = 0; i < testCases.length; i++) {
+ const testCase = testCases[i];
+ it('encodes tuple values', () => {
expect(
encodeTupleKeyValue(
testCase.valueContent,
@@ -426,7 +430,7 @@ describe('utils', () => {
),
).to.eq(testCase.encodedValue);
});
- });
+ }
});
describe('encodeArrayKey', () => {
@@ -941,14 +945,15 @@ describe('utils', () => {
},
];
- testCases.forEach((testCase) => {
+ for (let i = 0; i < testCases.length; i++) {
+ const testCase = testCases[i];
it(`guesses ${testCase.keyType}`, () => {
assert.deepStrictEqual(
guessKeyTypeFromKeyName(testCase.keyName),
testCase.keyType,
);
});
- });
+ }
});
describe('convertIPFSGatewayUrl', () => {
@@ -1018,12 +1023,13 @@ describe('utils', () => {
expect(generatedSchemas.length).to.equal(keys.length);
- generatedSchemas.forEach((schema) => {
+ for (let i = 0; i < generatedSchemas.length; i++) {
+ const schema = generatedSchemas[i];
expect(
isDynamicKeyName(schema.name),
'generated schema key should not be dynamic',
).to.be.false;
- });
+ }
});
});
diff --git a/src/lib/utils.ts b/src/lib/utils.ts
index 155c0b72..6b3e8fcf 100644
--- a/src/lib/utils.ts
+++ b/src/lib/utils.ts
@@ -30,8 +30,8 @@ import {
} from 'web3-utils';
import {
- URLDataToEncode,
EncodeDataReturn,
+ URLDataToEncode,
URLDataWithHash,
Verification,
} from '../types';
@@ -42,11 +42,16 @@ import {
} from '../types/ERC725JSONSchema';
import {
+ COMPACT_BYTES_ARRAY_STRING,
HASH_METHODS,
SUPPORTED_VERIFICATION_METHODS,
SUPPORTED_VERIFICATION_METHODS_LIST,
- COMPACT_BYTES_ARRAY_STRING,
} from '../constants/constants';
+import { GetDataDynamicKey } from '../types/GetData';
+import { EncodeDataInput } from '../types/decodeData';
+import { AssetURLEncode } from '../types/encodeData';
+import { isValidTuple } from './decodeData';
+import { isDynamicKeyName } from './encodeKeyName';
import {
decodeValueContent,
decodeValueType,
@@ -54,12 +59,7 @@ import {
encodeValueType,
valueContentEncodingMap as valueContentMap,
} from './encoder';
-import { AssetURLEncode } from '../types/encodeData';
-import { isDynamicKeyName } from './encodeKeyName';
import { getSchemaElement } from './getSchemaElement';
-import { EncodeDataInput } from '../types/decodeData';
-import { GetDataDynamicKey } from '../types/GetData';
-import { isValidTuple } from './decodeData';
/**
*
diff --git a/src/provider/providerWrapper.ts b/src/provider/providerWrapper.ts
index 9ec748e4..fde376ec 100644
--- a/src/provider/providerWrapper.ts
+++ b/src/provider/providerWrapper.ts
@@ -24,11 +24,11 @@
import AbiCoder from 'web3-eth-abi';
+import { ERC725Y_INTERFACE_IDS, ERC725_VERSION } from '../constants/constants';
+import { constructJSONRPC, decodeResult } from '../lib/provider-wrapper-utils';
import { JsonRpc } from '../types/JsonRpc';
import { Method } from '../types/Method';
-import { constructJSONRPC, decodeResult } from '../lib/provider-wrapper-utils';
import { ProviderTypes } from '../types/provider';
-import { ERC725_VERSION, ERC725Y_INTERFACE_IDS } from '../constants/constants';
const abiCoder = AbiCoder;
diff --git a/src/types/provider.ts b/src/types/provider.ts
index 0b3fd8cb..6d5d87a1 100644
--- a/src/types/provider.ts
+++ b/src/types/provider.ts
@@ -1,4 +1,4 @@
-export const enum ProviderTypes {
+export enum ProviderTypes {
ETHEREUM = 'ETHEREUM',
WEB3 = 'WEB3',
}
diff --git a/test/mockProviders.ts b/test/mockProviders.ts
index c57e725b..79d007c9 100644
--- a/test/mockProviders.ts
+++ b/test/mockProviders.ts
@@ -64,7 +64,7 @@ export class HttpProvider {
{
const foundResult = this.returnData.find((element) => {
// get call param (key)
- const keyParam = '0x' + payload[index].params[0].data.slice(10);
+ const keyParam = `0x${payload[index].params[0].data.slice(10)}`;
return element.key === keyParam;
});
@@ -143,7 +143,7 @@ export class HttpProvider {
break;
case METHODS[Method.GET_DATA_LEGACY].sig:
{
- const keyParam = '0x' + payload.params[0].data.slice(10);
+ const keyParam = `0x${payload.params[0].data.slice(10)}`;
const foundResult = this.returnData.find((e) => e.key === keyParam);
result = foundResult ? foundResult.value : '0x';
}
@@ -151,7 +151,7 @@ export class HttpProvider {
case METHODS[Method.GET_DATA_BATCH].sig:
case METHODS[Method.GET_DATA].sig:
{
- const keyParam = '0x' + payload.params[0].data.slice(138);
+ const keyParam = `0x${payload.params[0].data.slice(138)}`;
const foundResult = this.returnData.find((e) => e.key === keyParam);
result = foundResult ? foundResult.value : '0x';
}
@@ -224,7 +224,7 @@ export class EthereumProvider {
break;
case METHODS[Method.GET_DATA_LEGACY].sig:
{
- const keyParam = '0x' + payload.params[0].data.slice(10);
+ const keyParam = `0x${payload.params[0].data.slice(10)}`;
result = this.returnData.find((e) => e.key === keyParam)?.value;
}