Skip to content

Commit

Permalink
tweak.
Browse files Browse the repository at this point in the history
  • Loading branch information
mariacarmina committed Oct 9, 2024
1 parent 2ce8bc5 commit 87e1f9a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
10 changes: 5 additions & 5 deletions src/utils/Assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ import ERC20Template4 from '@oceanprotocol/contracts/artifacts/contracts/templat

export const DEVELOPMENT_CHAIN_ID = 8996
// template address OR templateId
export function isConfidentialEVM(network: string | number): boolean {
export function useOasisSDK(network: string | number): boolean {
const config = new ConfigHelper().getConfig(network)
return config && config.confidentialEVM
return config && config.sdk === 'oasis'
}

/**
Expand Down Expand Up @@ -196,7 +196,7 @@ export async function createAsset(
}

// include fileObject in the DT constructor
if (config.confidentialEVM) {
if (config.sdk === 'oasis') {
datatokenParams.filesObject = assetUrl
datatokenParams.accessListFactory = accessListFactory || config.accessListFactory
datatokenParams.allowAccessList = allowAccessList
Expand Down Expand Up @@ -256,7 +256,7 @@ export async function createAsset(
assetUrl.datatokenAddress = datatokenAddressAsset
assetUrl.nftAddress = nftAddress

if (config.confidentialEVM) {
if (config.sdk === 'oasis') {
// we need to update files object on the SC otherwise it will fail validation on provider
// because DDO datatokenAddress and nftAddress will not match the values on files object
const contract = new ethers.Contract(datatokenAddressAsset, ERC20Template4.abi, owner)
Expand All @@ -274,7 +274,7 @@ export async function createAsset(
}

// if confidential EVM no need to make encrypt call here
if (config.confidentialEVM) {
if (config.sdk === 'oasis') {
ddo.services[0].files = '' // on confidental EVM it needs to be empty string not null, for schema validation
} else {
ddo.services[0].files = await ProviderInstance.encrypt(assetUrl, chainID, providerUrl)
Expand Down
9 changes: 3 additions & 6 deletions test/unit/AssetUtils.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { assert } from 'chai'
import { KNOWN_CONFIDENTIAL_EVMS } from '../../src/config'
import { provider, getAddresses } from '../config'
import { calculateActiveTemplateIndex, isConfidentialEVM } from '../../src/utils'
import { calculateActiveTemplateIndex, useOasisSDK } from '../../src/utils'
import { Signer } from 'ethers/lib/ethers'

let nftOwner: Signer
Expand All @@ -14,16 +14,13 @@ describe('Asset utils (createAsset)', () => {

it('should check if confidential EVM', async () => {
for (const chain of KNOWN_CONFIDENTIAL_EVMS) {
assert(
isConfidentialEVM(chain) === true,
`Chain Id: "${chain}" is not a confidental EVM`
)
assert(useOasisSDK(chain) === true, `Chain Id: "${chain}" is not a confidental EVM`)
}

// optimism sepolia
// 11155420
assert(
isConfidentialEVM(11155420) === false,
useOasisSDK(11155420) === false,
`Chain Id: "11155420" is wrongly considered a confidental EVM`
)
})
Expand Down

0 comments on commit 87e1f9a

Please sign in to comment.