From a29faeeaa949d2705cdd8f52c74ca282b1fe2b98 Mon Sep 17 00:00:00 2001 From: Jamie Hewitt Date: Wed, 9 Oct 2024 11:05:30 +0300 Subject: [PATCH 1/3] Updating oasis exports --- src/contracts/index.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/contracts/index.ts b/src/contracts/index.ts index d1b99fced..af6d2b260 100644 --- a/src/contracts/index.ts +++ b/src/contracts/index.ts @@ -12,3 +12,6 @@ export * from './ve/VeFeeEstimate' export * from './ve/VeAllocate' export * from './df/DfRewards' export * from './df/DfStrategyV1' +export * from './Datatoken4' +export * from './AccessList' +export * from './AccessListFactory' From 9c25342c8efd5823b21975e7eb47921bcc244f9b Mon Sep 17 00:00:00 2001 From: Maria Carmina <50501033+mariacarmina@users.noreply.github.com> Date: Wed, 9 Oct 2024 11:18:46 +0300 Subject: [PATCH 2/3] Fix ipfs CID. (#1851) * Fix ipfs CID. * fix lint * tweaks. * Upgrade Github actions. * fix graphql asset url. * Fix cov. * remove duplicate test. * Surround by it block. * debug log. * added docker logs only for ipfs * increase timeout. * debug log. * Changed to ipfs cluster. * roll back. * put in the same test with arweave. * debug. * Log initialize url. * logs. * tweak condition. * changed cid with the one from cluster. * Rename test. Added back uploading in ipfs. * Fix review. --- .github/workflows/ci.yml | 2 +- src/services/Provider.ts | 2 +- test/integration/PublishEditConsume.test.ts | 71 +++++++++++++-------- 3 files changed, 48 insertions(+), 27 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f348e40d8..2b62ae126 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -224,7 +224,7 @@ jobs: # needs: [test_unit, test_integration] # steps: # - uses: actions/checkout@v3 - # - uses: actions/setup-node@v2 + # - uses: actions/setup-node@v4 # with: # node-version: '16' diff --git a/src/services/Provider.ts b/src/services/Provider.ts index 1552e22c9..fd899f73b 100644 --- a/src/services/Provider.ts +++ b/src/services/Provider.ts @@ -394,7 +394,7 @@ export class Provider { LoggerInstance.error(e) throw new Error(`Provider initialize failed url: ${initializeUrl} `) } - if (response?.ok) { + if (response?.status === 200) { const results: ProviderInitialize = await response.json() return results } diff --git a/test/integration/PublishEditConsume.test.ts b/test/integration/PublishEditConsume.test.ts index e2cc5e42f..8e6e66c27 100644 --- a/test/integration/PublishEditConsume.test.ts +++ b/test/integration/PublishEditConsume.test.ts @@ -72,17 +72,6 @@ const arweaveFile: Files = { ] } -const ifpsFile: Files = { - datatokenAddress: '0x0', - nftAddress: '0x0', - files: [ - { - type: 'ipfs', - hash: 'QmRhsp7eghZtW4PktPC2wAHdKoy2LiF1n6UXMKmAhqQJUA' - } - ] -} - const onchainFile: Files = { datatokenAddress: '0x0', nftAddress: '0x0', @@ -146,6 +135,29 @@ function delay(interval: number) { }).timeout(interval + 100) } +function uploadToIpfs(data: any): Promise { + return new Promise((resolve, reject) => { + fetch('http://172.15.0.16:5001/api/v0/add', { + method: 'POST', + headers: { + 'Content-Type': + 'multipart/form-data; boundary=------------------------a28d68b1c872c96f' + }, + body: + '--------------------------a28d68b1c872c96f\r\nContent-Disposition: form-data; name="file"; filename="ddo.json"\r\nContent-Type: application/octet-stream\r\n\r\n' + + data + + '\r\n--------------------------a28d68b1c872c96f--\r\n' + }) + .then(function (response: any) { + const resp = response.json() + resolve(resp.Hash) + }) + .catch(function (error: any) { + reject(error) + }) + }) +} + describe('Publish consume test', async () => { before(async () => { publisherAccount = (await provider.getSigner(0)) as Signer @@ -210,33 +222,42 @@ describe('Publish consume test', async () => { ) assert(urlAssetId, 'Failed to publish url DDO') }) - - it('Should publish ipfs asset', async () => { - ipfsAssetId = await createAsset( - 'IpfsDatatoken', - 'IPFSDT', + it('Should publish arweave asset', async () => { + arweaveAssetId = await createAsset( + 'ArwaveDatatoken', + 'ARWAVEDT', publisherAccount, - ifpsFile, + arweaveFile, assetDdo, providerUrl, addresses.ERC721Factory, aquarius ) - assert(ipfsAssetId, 'Failed to publish ipfs DDO') + assert(arweaveAssetId, 'Failed to arwave publish DDO') }) - - it('Should publish arwave asset', async () => { - arweaveAssetId = await createAsset( - 'ArweaveDatatoken', - 'ARWEAVEDT', + it('Should publish ipfs asset', async () => { + const ipfsCID = await uploadToIpfs(JSON.stringify(assetDdo)) + const ipfsFile: Files = { + datatokenAddress: '0x0', + nftAddress: '0x0', + files: [ + { + type: 'ipfs', + hash: ipfsCID + } + ] + } + ipfsAssetId = await createAsset( + 'IpfsDatatoken', + 'IPFSDT', publisherAccount, - arweaveFile, + ipfsFile, assetDdo, providerUrl, addresses.ERC721Factory, aquarius ) - assert(arweaveAssetId, 'Failed to publish ipfs DDO') + assert(ipfsAssetId, 'Failed to publish ipfs DDO') }) it('Should publish onchain asset', async () => { From cc91e1d376090137b7f92214a2085ea9b24a974e Mon Sep 17 00:00:00 2001 From: Jamie Hewitt Date: Wed, 9 Oct 2024 11:31:39 +0300 Subject: [PATCH 3/3] Release 3.4.1 --- CHANGELOG.md | 8 ++++++++ package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0aa65e29a..1fa059a67 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,8 +4,16 @@ 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.4.1](https://github.com/oceanprotocol/ocean.js/compare/v3.4.0...v3.4.1) + +- Updating oasis exports [`#1860`](https://github.com/oceanprotocol/ocean.js/pull/1860) +- Fix ipfs CID. [`#1851`](https://github.com/oceanprotocol/ocean.js/pull/1851) +- chore: get router factory address from config [`#1858`](https://github.com/oceanprotocol/ocean.js/pull/1858) + #### [v3.4.0](https://github.com/oceanprotocol/ocean.js/compare/v3.3.4-next.0...v3.4.0) +> 7 October 2024 + - Issue 1841 pub flow - createAsset Fn [`#1843`](https://github.com/oceanprotocol/ocean.js/pull/1843) - add credentials to service type [`#1855`](https://github.com/oceanprotocol/ocean.js/pull/1855) - Integrate contracts v2.2.0 [`#1845`](https://github.com/oceanprotocol/ocean.js/pull/1845) diff --git a/package-lock.json b/package-lock.json index ed8743128..b215bb66a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@oceanprotocol/lib", - "version": "3.4.0", + "version": "3.4.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@oceanprotocol/lib", - "version": "3.4.0", + "version": "3.4.1", "license": "Apache-2.0", "dependencies": { "@oasisprotocol/sapphire-paratime": "^1.3.2", diff --git a/package.json b/package.json index ff5387634..7fc55a3da 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@oceanprotocol/lib", "source": "./src/index.ts", - "version": "3.4.0", + "version": "3.4.1", "description": "JavaScript client library for Ocean Protocol", "main": "./dist/lib.js", "umd:main": "dist/lib.umd.js",