diff --git a/CHANGELOG.md b/CHANGELOG.md index 8bd32b4f6..eac08a716 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,36 @@ All notable changes to this project will be documented in this file. Dates are d Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). +#### [v3.0.16-rc3](https://github.com/nevermined-io/sdk-js/compare/v3.0.16-rc2...v3.0.16-rc3) + +> 2 July 2024 + +- fix: webpack error [`d2984be`](https://github.com/nevermined-io/sdk-js/commit/d2984beeaedaea67b1c5fd3deba35eb7d050e745) +- fix: webpack error [`34fa0f7`](https://github.com/nevermined-io/sdk-js/commit/34fa0f70bad0a89aa3d36d1e168d415ba0868bb5) +- Automated CHANGELOG.md update [`adde181`](https://github.com/nevermined-io/sdk-js/commit/adde181880e815e6003a13bb67850658e7ff6278) + +#### [v3.0.16-rc2](https://github.com/nevermined-io/sdk-js/compare/v3.0.16-rc1...v3.0.16-rc2) + +> 1 July 2024 + +- Automated CHANGELOG.md update [`694ca68`](https://github.com/nevermined-io/sdk-js/commit/694ca680e3ac874fe13b3f37e7f4fda02f7369b9) +- fix: issue loading nft contract when no artifacts folder [`a285fc0`](https://github.com/nevermined-io/sdk-js/commit/a285fc07738569b1b39c35bca4c6099fa4d5c198) + +#### [v3.0.16-rc1](https://github.com/nevermined-io/sdk-js/compare/v3.0.16-rc0...v3.0.16-rc1) + +> 28 June 2024 + +- fix: bug with contracthandler [`e3d3ee6`](https://github.com/nevermined-io/sdk-js/commit/e3d3ee69038e0474ba61e1cde13892b5e8e38bca) +- Automated CHANGELOG.md update [`8a30fd3`](https://github.com/nevermined-io/sdk-js/commit/8a30fd351f1d84d0247cd4bb669572d28aac03a6) + +#### [v3.0.16-rc0](https://github.com/nevermined-io/sdk-js/compare/v3.0.15...v3.0.16-rc0) + +> 28 June 2024 + +- docs: updating documentation [skip actions] [`d1f6dfa`](https://github.com/nevermined-io/sdk-js/commit/d1f6dfa161444337fb8f4e6e633d0de7b5b6c890) +- docs: updating documentation [skip actions] [`f02e652`](https://github.com/nevermined-io/sdk-js/commit/f02e652883df2e6e6a3c21e2c22650c8fc09d69d) +- Automated CHANGELOG.md update [`3d02657`](https://github.com/nevermined-io/sdk-js/commit/3d026574f8051d1cb4151e3441edbece52bfb907) + #### [v3.0.15](https://github.com/nevermined-io/sdk-js/compare/v3.0.15-rc3...v3.0.15) > 26 June 2024 diff --git a/package.json b/package.json index 72d4c7aa9..b9d3c05be 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@nevermined-io/sdk", - "version": "3.0.15", + "version": "3.0.16", "description": "Javascript SDK for connecting with Nevermined Data Platform ", "main": "./dist/node/sdk.js", "typings": "./dist/node/sdk.d.ts", @@ -55,7 +55,7 @@ "@turnkey/viem": "0.4.16", "@zerodev/ecdsa-validator": "5.2.3", "@zerodev/sdk": "5.2.11", - "@zerodev/session-key": "^5.3.0", + "@zerodev/session-key": "5.3.0", "assert": "^2.0.0", "cross-fetch": "^4.0.0", "crypto-browserify": "^3.12.0", @@ -79,6 +79,7 @@ "url": "^0.11.0", "uuid": "^9.0.1", "viem": "2.9.31", + "vm-browserify": "^1.1.2", "whatwg-url": "^14.0.0" }, "peerDependencies": { diff --git a/src/common/helpers.ts b/src/common/helpers.ts index 3942657cd..fd41ee8dc 100644 --- a/src/common/helpers.ts +++ b/src/common/helpers.ts @@ -86,18 +86,18 @@ export async function decryptMessage(encryptedMessage: string, privateKey: strin } export function serializeECIES(ecies: any) { - return btoa( - JSON.stringify({ - iv: Buffer.from(ecies.iv).toString('base64'), - ephemPublicKey: Buffer.from(ecies.ephemPublicKey).toString('base64'), - ciphertext: Buffer.from(ecies.ciphertext).toString('base64'), - mac: Buffer.from(ecies.mac).toString('base64'), - }), - ) + const serialized = JSON.stringify({ + iv: Buffer.from(ecies.iv).toString('base64'), + ephemPublicKey: Buffer.from(ecies.ephemPublicKey).toString('base64'), + ciphertext: Buffer.from(ecies.ciphertext).toString('base64'), + mac: Buffer.from(ecies.mac).toString('base64'), + }) + return Buffer.from(serialized).toString('binary') } export function deserializeECIES(serialized: any) { - const _obj = JSON.parse(atob(serialized)) + const decoded = Buffer.from(serialized, 'binary').toString() + const _obj = JSON.parse(decoded) return { iv: Buffer.from(_obj.iv, 'base64'), ephemPublicKey: Buffer.from(_obj.ephemPublicKey, 'base64'), diff --git a/src/keeper/ContractHandler.ts b/src/keeper/ContractHandler.ts index 7e74af348..1c8cd6415 100644 --- a/src/keeper/ContractHandler.ts +++ b/src/keeper/ContractHandler.ts @@ -160,7 +160,12 @@ export class ContractHandler extends Instantiable { if (networkName && networkName.length > 0) where = `.${networkName}` if (artifactsFolder.startsWith('http')) { - const path = `${artifactsFolder}/${networkId}/public/${contractsVersion}/${contractName}${where}.json` + let path + if (artifactsFolder === 'https://artifacts.nevermined.network') { + path = `${artifactsFolder}/${networkId}/public/${contractsVersion}/${contractName}${where}.json` + } else { + path = `${artifactsFolder}/${contractName}${where}.json` + } const jsonFile = await fetch(path, { method: 'GET', headers: { 'Content-type': 'application/json' }, diff --git a/src/keeper/contracts/Nft1155Contract.ts b/src/keeper/contracts/Nft1155Contract.ts index 0a9cef9c4..3ec5f3455 100644 --- a/src/keeper/contracts/Nft1155Contract.ts +++ b/src/keeper/contracts/Nft1155Contract.ts @@ -23,6 +23,7 @@ export class Nft1155Contract extends NFTContractsBase { if (address) { const networkName = await nft.nevermined.keeper.getNetworkName() + const networkId = await nft.nevermined.keeper.getNetworkId() // We don't have a subgraph for NFT1155 so we can only use ContractEvent const eventEmitter = new EventHandler() @@ -32,6 +33,7 @@ export class Nft1155Contract extends NFTContractsBase { contractName, artifactsFolder, networkName, + networkId, ) nft.contract = await getContractInstance(address, solidityABI.abi, nft.client) diff --git a/src/keeper/contracts/Nft721Contract.ts b/src/keeper/contracts/Nft721Contract.ts index ba633a4f7..4211426c1 100644 --- a/src/keeper/contracts/Nft721Contract.ts +++ b/src/keeper/contracts/Nft721Contract.ts @@ -18,6 +18,7 @@ export class Nft721Contract extends NFTContractsBase { const nft: Nft721Contract = new Nft721Contract(contractName) nft.setInstanceConfig(config) const networkName = await nft.nevermined.keeper.getNetworkName() + const networkId = await nft.nevermined.keeper.getNetworkId() // We don't have a subgraph for NFT721 so we can only use ContractEvent const eventEmitter = new EventHandler() @@ -27,6 +28,7 @@ export class Nft721Contract extends NFTContractsBase { contractName, artifactsFolder, networkName, + networkId, ) nft.contract = await getContractInstance(address, solidityABI.abi, nft.nevermined.client) diff --git a/webpack.common.js b/webpack.common.js index 9f9d2ebf6..058b8af61 100644 --- a/webpack.common.js +++ b/webpack.common.js @@ -21,6 +21,7 @@ module.exports = { assert: require.resolve('assert/'), path: require.resolve('path-browserify'), stream: require.resolve('stream-browserify'), + vm: require.resolve("vm-browserify"), zlib: false, fs: false, }, diff --git a/yarn.lock b/yarn.lock index b98dfb604..745de5020 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2594,7 +2594,7 @@ dependencies: semver "^7.6.0" -"@zerodev/session-key@^5.3.0": +"@zerodev/session-key@5.3.0": version "5.3.0" resolved "https://registry.yarnpkg.com/@zerodev/session-key/-/session-key-5.3.0.tgz#d347134a359d06ec03f6bb8378345d5d2d3f4c22" integrity sha512-HZAFuhUiiG2bx8fqBW1LujH7Rn8zdbraipOoFXh55tDTyA3GX6M4RgiqzZPRoHMYfCYImE6ETBj0a97PjsBRHQ== @@ -11260,6 +11260,11 @@ viem@2.9.31: isows "1.0.3" ws "8.13.0" +vm-browserify@^1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/vm-browserify/-/vm-browserify-1.1.2.tgz#78641c488b8e6ca91a75f511e7a3b32a86e5dda0" + integrity sha512-2ham8XPWTONajOR0ohOKOHXkm3+gaBmGut3SRuu75xLd/RRaY6vqgh8NBYYk7+RW3u5AtzPQZG8F10LHkl0lAQ== + vscode-oniguruma@^1.7.0: version "1.7.0" resolved "https://registry.yarnpkg.com/vscode-oniguruma/-/vscode-oniguruma-1.7.0.tgz#439bfad8fe71abd7798338d1cd3dc53a8beea94b"