1
0
mirror of https://github.com/oceanprotocol/ocean.js.git synced 2024-11-26 20:39:05 +01:00

Add checks for ddo chain id and did. (#1868)

This commit is contained in:
Maria Carmina 2024-11-04 15:12:29 +02:00 committed by GitHub
parent dc64981aa1
commit 6e0d0e85a6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 19 additions and 12 deletions

View File

@ -167,7 +167,7 @@ Next, we define the metadata that will describe our data asset. This is what we
'@context': ['https://w3id.org/did/v1'],
id: '',
version: '4.1.0',
chainId: 4,
chainId: 8996,
nftAddress: '0x0',
metadata: {
created: '2021-12-20T14:35:20Z',

View File

@ -183,7 +183,7 @@ const DATASET_DDO: DDO = {
'@context': ['https://w3id.org/did/v1'],
id: 'id:op:efba17455c127a885ec7830d687a8f6e64f5ba559f8506f8723c1f10f05c049c',
version: '4.1.0',
chainId: 5,
chainId: 8996,
nftAddress: '0x0',
metadata: {
created: '2021-12-20T14:35:20Z',
@ -219,7 +219,7 @@ const ALGORITHM_DDO: DDO = {
'@context': ['https://w3id.org/did/v1'],
id: 'did:op:efba17455c127a885ec7830d687a8f6e64f5ba559f8506f8723c1f10f05c049c',
version: '4.1.0',
chainId: 5,
chainId: 8996,
nftAddress: '0x0',
metadata: {
created: '2021-12-20T14:35:20Z',

View File

@ -153,6 +153,13 @@ export async function createAsset(
}
const chainID = (await owner.provider.getNetwork()).chainId
if (ddo.chainId !== chainID) {
throw new Error('Chain ID from DDO is different than the configured network.')
}
if (ddo.id) {
throw new Error('DID already filled in.')
}
const config = new ConfigHelper().getConfig(parseInt(String(chainID)))
let templateIndex = await calculateActiveTemplateIndex(

View File

@ -167,7 +167,7 @@ describe('Marketplace flow tests', async () => {
'@context': ['https://w3id.org/did/v1'],
id: '',
version: '4.1.0',
chainId: 4,
chainId: 8996,
nftAddress: '0x0',
metadata: {
created: '2021-12-20T14:35:20Z',

View File

@ -183,7 +183,7 @@ const DATASET_DDO: DDO = {
'@context': ['https://w3id.org/did/v1'],
id: 'id:op:efba17455c127a885ec7830d687a8f6e64f5ba559f8506f8723c1f10f05c049c',
version: '4.1.0',
chainId: 5,
chainId: 8996,
nftAddress: '0x0',
metadata: {
created: '2021-12-20T14:35:20Z',
@ -219,7 +219,7 @@ const ALGORITHM_DDO: DDO = {
'@context': ['https://w3id.org/did/v1'],
id: 'did:op:efba17455c127a885ec7830d687a8f6e64f5ba559f8506f8723c1f10f05c049c',
version: '4.1.0',
chainId: 5,
chainId: 8996,
nftAddress: '0x0',
metadata: {
created: '2021-12-20T14:35:20Z',

View File

@ -56,7 +56,7 @@ const ddoWithNoTimeout = {
'@context': ['https://w3id.org/did/v1'],
id: 'did:op:efba17455c127a885ec7830d687a8f6e64f5ba559f8506f8723c1f10f05c049c',
version: '4.1.0',
chainId: 4,
chainId: 8996,
nftAddress: '0x0',
metadata: {
created: '2021-12-20T14:35:20Z',
@ -93,7 +93,7 @@ const ddoWith5mTimeout = {
'@context': ['https://w3id.org/did/v1'],
id: 'did:op:efba17455c127a885ec7830d687a8f6e64f5ba559f8506f8723c1f10f05c049c',
version: '4.1.0',
chainId: 4,
chainId: 8996,
nftAddress: '0x0',
metadata: {
created: '2021-12-20T14:35:20Z',
@ -140,7 +140,7 @@ const algoDdoWithNoTimeout = {
'@context': ['https://w3id.org/did/v1'],
id: 'did:op:efba17455c127a885ec7830d687a8f6e64f5ba559f8506f8723c1f10f05c049c',
version: '4.1.0',
chainId: 4,
chainId: 8996,
nftAddress: '0x0',
metadata: {
created: '2021-12-20T14:35:20Z',
@ -182,7 +182,7 @@ const algoDdoWith5mTimeout = {
'@context': ['https://w3id.org/did/v1'],
id: 'did:op:efba17455c127a885ec7830d687a8f6e64f5ba559f8506f8723c1f10f05c049c',
version: '4.1.0',
chainId: 4,
chainId: 8996,
nftAddress: '0x0',
metadata: {
created: '2021-12-20T14:35:20Z',

View File

@ -102,7 +102,7 @@ const assetDdo = {
'@context': ['https://w3id.org/did/v1'],
id: 'did:op:efba17455c127a885ec7830d687a8f6e64f5ba559f8506f8723c1f10f05c049c',
version: '4.1.0',
chainId: 4,
chainId: 8996,
nftAddress: '0x0',
metadata: {
created: '2021-12-20T14:35:20Z',

View File

@ -56,7 +56,7 @@ describe('Publish tests', async () => {
'@context': ['https://w3id.org/did/v1'],
id: '',
version: '4.1.0',
chainId: 4,
chainId: 8996,
nftAddress: '0x0',
metadata: {
created: '2021-12-20T14:35:20Z',