Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use createAsset function from SDK. #73

Merged
merged 32 commits into from
Jan 28, 2025
Merged

Conversation

mariacarmina
Copy link
Member

@mariacarmina mariacarmina commented Nov 7, 2024

Fixes # .

Changes proposed in this PR:

  • use createAsset function from SDK
  • replace all hardcoded chain IDs value with null, because the chain ID will be automatically & correctly filled in by SDK

@paulo-ocean paulo-ocean mentioned this pull request Nov 11, 2024
@mariacarmina mariacarmina marked this pull request as draft November 18, 2024 13:21
src/helpers.ts Outdated Show resolved Hide resolved
@paulo-ocean
Copy link
Contributor

paulo-ocean commented Nov 19, 2024

btw, just published an asset on ganache from this branch... all good on my side

> [email protected] cli
> TS_NODE_PROJECT='./tsconfig.json' ./node_modules/ts-node/dist/bin.js src/index.ts publish metadata/simpleDownloadDataset.json

Using RPC: http://127.0.0.1:8545
Using account: 0x6c957a45C801035d3297d43d0Ce83a237Ec5E0d1
Using Provider : http://localhost:8001
Using Aquarius : http://localhost:8001
start publishing
No config found for given network 'undefined'
No config found for given network 'undefined'
did:  did:op:fadce5db248397ccccc43d4ea36a727ef000c0d4c5dd0e45d0f430c9d1cf2432
Asset published. ID:  did:op:fadce5db248397ccccc43d4ea36a727ef000c0d4c5dd0e45d0f430c9d1cf2432
paulo@paulo-VivoBook-ASUSLaptop-X515EA-F515EA:~/workspace/OCEAN/ocean-cli$ npm run cli getDDO did:op:fadce5db248397ccccc43d4ea36a727ef000c0d4c5dd0e45d0f430c9d1cf2432 

> [email protected] cli
> TS_NODE_PROJECT='./tsconfig.json' ./node_modules/ts-node/dist/bin.js src/index.ts getDDO did:op:fadce5db248397ccccc43d4ea36a727ef000c0d4c5dd0e45d0f430c9d1cf2432

Using RPC: http://127.0.0.1:8545
Using account: 0x6c957a45C801035d3297d43d0Ce83a237Ec5E0d1
Using Provider : http://localhost:8001
Using Aquarius : http://localhost:8001
Resolving Asset with DID: did:op:fadce5db248397ccccc43d4ea36a727ef000c0d4c5dd0e45d0f430c9d1cf2432
{
  '@context': [ 'https://w3id.org/did/v1' ],
  id: 'did:op:fadce5db248397ccccc43d4ea36a727ef000c0d4c5dd0e45d0f430c9d1cf2432',
  nftAddress: '0x53d1456E80AE480E6C38b7d057EdAddB53D8583f',
  version: '4.1.0',
  chainId: 8996,
  metadata: {
    created: '2021-12-20T14:35:20Z',
    updated: '2021-12-20T14:35:20Z',
    type: 'dataset',
    name: 'ocean-cli demo asset',
    description: 'asset published using ocean cli tool',
    tags: [ 'test' ],
    author: 'oceanprotocol',
    license: 'https://market.oceanprotocol.com/terms',
    additionalInformation: { termsAndConditions: true }
  },
  services: [
    {
      id: 'ccb398c50d6abd5b456e8d7242bd856a1767a890b537c2f8c10ba8b8a10e6025',
      type: 'access',
      files: '0x040000f7cdc53f2ca20b4e407bedb5a345cd54f1ccd4541f6008821a7d9831d96793d2115db8c252d5652ccba9af1363b2e6bd5a48480ac72e6645015ef34b77ad84006c82a889e2b78263602f7f6c514d1a0062e5d9ad8efd704ea046c14136ef7521e08b74f7c0ef9bf5a31ec03efa9ce6b6863ae1607de6f00304cefd170f80c14a86adf1a65ae1737bf993a0a41d4d7da793bdad66732977ae3bb27d0bdc50b495498bd367d6dcc0de3988c771957cd63cf1e82b59ba0800aefebc78fac394d828121fab0c0afb8e1e6b82b1c163caa56725bd0816f5f2d0bf8d8b8e9ecc5a12e4b6440bb5fcba5fa07efd1b5afdc1272bb7de6a37969479ee377c8adbb15cf8a28d781f1440e72a77607d751cc44490c8809c690666c99c1c3d2ffeaf3122a4a473b730b65604823234279cca31fd2316b79bafa27056d3d0e71b759e52c79681781b0f306ec3b23b93299882e23e5005553033816093e1ab85e7af',
      datatokenAddress: '0x0c6aEB6238BAB5FB328Aca29dc7B8b2dBEc49768',
      serviceEndpoint: 'http://localhost:8001',
      timeout: 86400
    }
  ],
  event: {
    tx: '0xd7c4eeb718767c75da379d7cdbb884dd28412e5ba1b3ffacb567203f985e7082',
    from: '0x6c957a45C801035d3297d43d0Ce83a237Ec5E0d1',
    contract: '0x53d1456E80AE480E6C38b7d057EdAddB53D8583f',
    block: 1061,
    datetime: '2024-11-19T14:45:53.000Z'
  },
  nft: {
    state: 0,
    address: '0x53d1456E80AE480E6C38b7d057EdAddB53D8583f',
    name: 'Ocean Data NFT',
    symbol: 'OCEAN-NFT',
    owner: '0x6c957a45C801035d3297d43d0Ce83a237Ec5E0d1',
    created: '2024-11-19T14:45:53Z',
    tokenURI: 'aaa'
  },
  purgatory: { state: false },
  datatokens: [
    {
      address: '0x0c6aEB6238BAB5FB328Aca29dc7B8b2dBEc49768',
      name: 'Datatoken',
      symbol: 'DT1',
      serviceId: 'ccb398c50d6abd5b456e8d7242bd856a1767a890b537c2f8c10ba8b8a10e6025'
    }
  ],
  stats: { allocated: 0, orders: 0, price: { value: '2' } }
}

@paulo-ocean
Copy link
Contributor

paulo-ocean commented Nov 19, 2024

@mariacarmina Check the chain id on the tests.
I think you're victim of you own code :-)
https://github.com/oceanprotocol/ocean.js/blob/6e0d0e85a656850b3d2d1899244269be733652ce/src/utils/Assets.ts#L157
The test fails because the chain id of simpleComputeDataset.json is not the expected one.. That's why i was against these "check chain" changes, its easy to get confusing...

better also use a try/catch on the caller side... so we know whats happening (as we throw errors)

@mariacarmina
Copy link
Member Author

@mariacarmina Check the chain id on the tests. I think you're victim of you own code :-) https://github.com/oceanprotocol/ocean.js/blob/6e0d0e85a656850b3d2d1899244269be733652ce/src/utils/Assets.ts#L157 The test fails because the chain id of simpleComputeDataset.json is not the expected one.. That's why i was against these "check chain" changes, its easy to get confusing...

better also use a try/catch on the caller side... so we know whats happening (as we throw errors)

Hello @paulo-ocean, if you tested on barge, the chain id from simpleComputeDataset.json is set correctly, maybe the issue was on simpleDownloadDataset.json which is the mumbai chain id, I updated in the code the chain id to see if the tests pass.
Btw, when you did the test with successfully publsihed the ddo, did you also update the chain id in the sample before publishing?

@mariacarmina
Copy link
Member Author

better also use a try/catch on the caller side... so we know whats happening (as we throw errors)

I've seen that within the commands and publish.ts file there are try/catch blocks and they print the errors when they are raised, one spot was missing when publishing the algo, I've added right now, is there any other place that you were referring to?

@mariacarmina
Copy link
Member Author

@mariacarmina Check the chain id on the tests. I think you're victim of you own code :-) https://github.com/oceanprotocol/ocean.js/blob/6e0d0e85a656850b3d2d1899244269be733652ce/src/utils/Assets.ts#L157 The test fails because the chain id of simpleComputeDataset.json is not the expected one.. That's why i was against these "check chain" changes, its easy to get confusing...
better also use a try/catch on the caller side... so we know whats happening (as we throw errors)

Hello @paulo-ocean, if you tested on barge, the chain id from simpleComputeDataset.json is set correctly, maybe the issue was on simpleDownloadDataset.json which is the mumbai chain id, I updated in the code the chain id to see if the tests pass. Btw, when you did the test with successfully publsihed the ddo, did you also update the chain id in the sample before publishing?

The test are still failing can you share how did you receive the chain id error? the tests from CI indicate another type of error.

@mariacarmina
Copy link
Member Author

@paulo-ocean I have updated the chain ids, now it helped to advance the tests suite, PR to fix the check on ocean.js is merged, I think we need to do a minor release for ocean.js. Thank you!

@mariacarmina mariacarmina marked this pull request as ready for review November 20, 2024 13:36
@paulo-ocean
Copy link
Contributor

simpleDownloadDataset

Yes, the wrong one was simpleDownloadDataset

@paulo-ocean
Copy link
Contributor

The test are still failing can you share how did you receive the chain id error? the tests from CI indicate another type of error.

We don't get any errors when we code like "throw new Error()" and don't use try/catch :-)

@mariacarmina
Copy link
Member Author

mariacarmina commented Nov 25, 2024

i'm still not sure this is enough.. the template id = 4 could be used on any other network..

if(templateId === 4){
		// Wrap the signer for Sapphire
		const wrappedSigner = sapphire.wrap(owner);

We're assuming that every time we have template 4 is sapphire network wich might not always be true (i have no idea of what happens if we wrap the signer for any other network using sapphire SDK)

Right, we also need to check the sdk part, I'm fixing it right now.

src/publishAsset.ts Outdated Show resolved Hide resolved
@jamiehewitt15
Copy link
Member

Do you know why the tests are failing?

@paulo-ocean
Copy link
Contributor

paulo-ocean commented Jan 23, 2025

Do you know why the tests are failing?

we need to fix node modules and package-lock
it fails on npm run ci
npm ERR! Invalid: lock file's @oceanprotocol/[email protected] does not satisfy @oceanprotocol/[email protected]
we have to delete the node modules and the package-lock.json .. install everything and commit the updated package-lock
(+ adding the missing shappire deps mentioned above)

@paulo-ocean
Copy link
Contributor

better update the ci.yml workflow as well, add the -f flag on the docker image removal commands

- name: Delete default runner images
        run: |
          docker image rm -f node:20
          docker image rm -f node:20-alpine
          docker image rm -f node:18
          docker image rm -f node:18-alpine
          docker image rm -f debian:10
          docker image rm -f debian:11
          docker image rm -f ubuntu:22.04
          docker image rm -f ubuntu:20.04
          docker image rm -f moby/buildkit:latest
          rm -rf /usr/share/swift/

@paulo-ocean
Copy link
Contributor

paulo-ocean commented Jan 23, 2025

@mariacarmina if you can duplicate the calculateActiveTemplateIndex here, and update the ci.yml the issues should be gone
Again, on the ci.yml its about adding the '-f' flag.... not removing image entries

- name: Delete default runner images
        run: |
          docker image rm -f node:20
          docker image rm -f node:20-alpine
          docker image rm -f node:18
          docker image rm -f node:18-alpine
          docker image rm -f debian:10
          docker image rm -f debian:11
          docker image rm -f ubuntu:22.04
          docker image rm -f ubuntu:20.04
          docker image rm -f moby/buildkit:latest
          rm -rf /usr/share/swift/

@mariacarmina
Copy link
Member Author

@mariacarmina if you can duplicate the calculateActiveTemplateIndex here, and update the ci.yml the issues should be gone Again, on the ci.yml its about adding the '-f' flag.... not removing image entries

- name: Delete default runner images
        run: |
          docker image rm -f node:20
          docker image rm -f node:20-alpine
          docker image rm -f node:18
          docker image rm -f node:18-alpine
          docker image rm -f debian:10
          docker image rm -f debian:11
          docker image rm -f ubuntu:22.04
          docker image rm -f ubuntu:20.04
          docker image rm -f moby/buildkit:latest
          rm -rf /usr/share/swift/

If those images do not exists in dockerhub, then we should maintain them up to date, we used to remove those docker images to not load runner resources and to have enough resources to run barge.

@paulo-ocean
Copy link
Contributor

@mariacarmina if you can duplicate the calculateActiveTemplateIndex here, and update the ci.yml the issues should be gone Again, on the ci.yml its about adding the '-f' flag.... not removing image entries

- name: Delete default runner images
        run: |
          docker image rm -f node:20
          docker image rm -f node:20-alpine
          docker image rm -f node:18
          docker image rm -f node:18-alpine
          docker image rm -f debian:10
          docker image rm -f debian:11
          docker image rm -f ubuntu:22.04
          docker image rm -f ubuntu:20.04
          docker image rm -f moby/buildkit:latest
          rm -rf /usr/share/swift/

If those images do not exists in dockerhub, then we should maintain them up to date, we used to remove those docker images to not load runner resources and to have enough resources to run barge.

Its not about that... the images exist. Take a break, listen :-)...

src/helpers.ts Outdated Show resolved Hide resolved
src/helpers.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@paulo-ocean paulo-ocean left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@mariacarmina mariacarmina merged commit 72c2f05 into main Jan 28, 2025
3 checks passed
@mariacarmina mariacarmina deleted the utilize-create-asset-function branch January 28, 2025 20:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants