1
0
mirror of https://github.com/oceanprotocol/ocean.js.git synced 2024-11-26 20:39:05 +01:00
ocean.js/test/unit/AssetUtils.test.ts
Maria Carmina a0a8df328f
Add confidential EVM flag when creating a datatoken 4 in NFT class (#1859)
* Add confidential EVM flag when creating a datatoken 4.

* Add comments.

* fix lint.

* fix lint.

* Add chain id check to bundled functions.

* Updating CodeExamples.md

* Updating ComputeExamples.md

* Used config object.

* Added check for sapphire confidential EVM. Fix tests.

* Added sapphire wrap signer for all contracts.

* Make network mandatory field.

* Undo making network mandatory.

* refactor condition.

* refactor condition.

* Add condition when creating NFT.

* Refactor with sdk.

* fix lint.

* tweak.

* tweak.

* Created protected function to get vthe signer according to the sdk from config.

* Fix lint. Add check for sdk within the config.

* Fix lint.

* Updating CodeExamples.md

* Updating ComputeExamples.md

---------

Co-authored-by: GitHub Actions Bot <>
2024-10-16 15:27:41 +03:00

45 lines
1.4 KiB
TypeScript

import { assert } from 'chai'
import { KNOWN_CONFIDENTIAL_EVMS } from '../../src/config'
import { provider, getAddresses } from '../config'
import { calculateActiveTemplateIndex, useOasisSDK } from '../../src/utils'
import { Signer } from 'ethers/lib/ethers'
let nftOwner: Signer
let addresses: any
describe('Asset utils (createAsset)', () => {
before(async () => {
nftOwner = (await provider.getSigner(0)) as Signer
addresses = await getAddresses()
})
it('should check if confidential EVM', async () => {
for (const chain of KNOWN_CONFIDENTIAL_EVMS) {
assert(useOasisSDK(chain) === true, `Chain Id: "${chain}" is not a confidental EVM`)
}
// optimism sepolia
// 11155420
assert(
useOasisSDK(11155420) === false,
`Chain Id: "11155420" is wrongly considered a confidental EVM`
)
})
// checking if active by connecting to the smart contract as well
it('Calculate index - Should get correct template index from contract getId() (using template ID as template)', async () => {
const okTemplate = await calculateActiveTemplateIndex(
nftOwner,
addresses.ERC721Factory,
3
)
assert(okTemplate === 3, 'wrong template index, should be index 3!')
const wrongOne = await calculateActiveTemplateIndex(
nftOwner,
addresses.ERC721Factory,
6
)
assert(wrongOne === -1, 'wrong template index, should only exist 3!')
})
})