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

Remove checks from publishing. ADded chain ID check for ordering. #1875

Merged
merged 5 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/@types/DDO/DDO.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Service, Metadata, Credentials, Event } from '..'

/**
* DID Descriptor Object.
* Contains metadata about the asset, and define access in at least one service.
Expand Down
9 changes: 4 additions & 5 deletions src/utils/Assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,10 @@ 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.')
if (ddo.chainId) {
if (ddo.chainId !== chainID) {
throw new Error('Chain ID from DDO is different than the configured network.')
}
}

const config = new ConfigHelper().getConfig(parseInt(String(chainID)))
Expand Down
4 changes: 4 additions & 0 deletions src/utils/OrderUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ export async function orderAsset(
consumeMarketFeeToken:
asset.stats.price.tokenAddress || '0x0000000000000000000000000000000000000000'
}
const chainID = (await consumerAccount.provider.getNetwork()).chainId
if (asset.chainId !== chainID) {
throw new Error('Chain ID from DDO is different than the configured network.')
}

if (!asset.datatokens[datatokenIndex].address)
throw new Error(
Expand Down
4 changes: 4 additions & 0 deletions test/integration/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ export async function handleComputeOrder(
- have validOrder and providerFees -> then order is valid but providerFees are not valid, we need to call reuseOrder and pay only providerFees
- no validOrder -> we need to call startOrder, to pay 1 DT & providerFees
*/
const chainID = (await payerAccount.provider.getNetwork()).chainId
if (config.chainId !== chainID) {
throw new Error('Chain ID from DDO is different than the configured network.')
}
if (order.providerFee && order.providerFee.providerFeeAmount) {
await approveWei(
payerAccount,
Expand Down
Loading