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

Issue 1841 pub flow - createAsset Fn #1843

Open
wants to merge 47 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
17603be
wip: create asset
paulo-ocean Sep 3, 2024
6bca7d6
few more changes, use config
paulo-ocean Sep 3, 2024
f5166bd
wip... refactroing..
paulo-ocean Sep 5, 2024
57ffc12
wip: calculate template index
paulo-ocean Sep 5, 2024
f59f3da
add base network config settings for oasis testnet
paulo-ocean Sep 5, 2024
995a7f0
wip: add unit test
paulo-ocean Sep 5, 2024
b48c48b
fix import style
paulo-ocean Sep 5, 2024
ee02a0e
more unit tests, template index
paulo-ocean Sep 5, 2024
1ca2362
add test unit file, renamed
paulo-ocean Sep 5, 2024
9277847
fixes on the checks, also consider name typos, as we currently have
paulo-ocean Sep 6, 2024
f0e571e
wip: try add integration test
paulo-ocean Sep 6, 2024
fe3fbc4
debug test
paulo-ocean Sep 6, 2024
92a5ff9
more debugging
paulo-ocean Sep 6, 2024
e245795
try add erc 20 templates to config obj
paulo-ocean Sep 6, 2024
e855f78
remove debug comments, add comment for todo
paulo-ocean Sep 6, 2024
a049a1a
use hardhat getContractAt
paulo-ocean Sep 9, 2024
2ce5a77
try add a hardhat config file so we can use th elibs
paulo-ocean Sep 9, 2024
9ec89b6
debug ethers on hardhat
paulo-ocean Sep 9, 2024
4d14dae
debug ethers on hardhat
paulo-ocean Sep 9, 2024
36f1865
more debug, try fn workaround
paulo-ocean Sep 9, 2024
df2d5dd
try another way, debug
paulo-ocean Sep 9, 2024
1382700
test/unit/AssetUtils.test.ts
paulo-ocean Sep 9, 2024
5611eab
remove hardhat deps
paulo-ocean Sep 9, 2024
0bd720a
try debug tests
paulo-ocean Sep 9, 2024
4e95457
fix test fn
paulo-ocean Sep 9, 2024
f3c44d4
cleaning the house
paulo-ocean Sep 9, 2024
0e06347
fix minor logic issue
paulo-ocean Sep 9, 2024
d141ddc
remove hardhat config file
paulo-ocean Sep 9, 2024
fb81079
update proper abi json file
paulo-ocean Sep 10, 2024
d9bbaff
some refactor and commenst
paulo-ocean Sep 10, 2024
7332252
fix lint
paulo-ocean Sep 10, 2024
dc25a90
Release 3.3.4-next.0
paulo-ocean Sep 10, 2024
61fff34
fix review
paulo-ocean Sep 11, 2024
14894c7
Release 3.3.4-next.1
paulo-ocean Sep 12, 2024
470c2ee
put version 3.3.3 back
paulo-ocean Sep 12, 2024
0eeacbc
restore changelog
paulo-ocean Sep 12, 2024
06fd7f8
restore package lock
paulo-ocean Sep 12, 2024
51ddf52
some fix and refactor
paulo-ocean Sep 12, 2024
b5a2a64
added changes for access lists
paulo-ocean Sep 12, 2024
442eef7
update github artifacts
paulo-ocean Sep 13, 2024
4bcb1d9
some fixes + cleaning
paulo-ocean Sep 13, 2024
fdc35ab
fix create erc params
paulo-ocean Sep 13, 2024
c7ad0d5
fix name of artifacts
paulo-ocean Sep 13, 2024
d4272f4
fix download artifact name
paulo-ocean Sep 13, 2024
a06a5c5
fix files, string, cannot be null
paulo-ocean Sep 13, 2024
3255ce1
small changes for order
paulo-ocean Sep 17, 2024
6ea2ea2
update files object
paulo-ocean Sep 18, 2024
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
33 changes: 18 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v2
- uses: actions/setup-node@v4
with:
node-version: '20'
- name: Cache node_modules
uses: actions/cache@v2
uses: actions/cache@v4
env:
cache-name: cache-node-modules
with:
Expand All @@ -35,11 +35,11 @@ jobs:

steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v2
- uses: actions/setup-node@v4
with:
node-version: '20'
- name: Cache node_modules
uses: actions/cache@v2
uses: actions/cache@v4
env:
cache-name: cache-node-modules
with:
Expand Down Expand Up @@ -71,21 +71,21 @@ jobs:
ls -la "$HOME/.ocean/ocean-contracts/artifacts/"
- run: npm run build:metadata
- run: npm run test:unit:cover
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v4
with:
name: coverage
name: coverage-unit
path: coverage/

test_integration:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v2
- uses: actions/setup-node@v4
with:
node-version: '20'
- name: Cache node_modules
uses: actions/cache@v2
uses: actions/cache@v4
env:
cache-name: cache-node-modules
with:
Expand Down Expand Up @@ -143,9 +143,9 @@ jobs:
run: docker logs ocean_aquarius_1 && docker logs ocean_provider_1 && docker logs ocean_provider2_1 && docker logs ocean_computetodata_1
if: ${{ failure() }}
- name: Upload coverage
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: coverage
name: coverage-integration
path: coverage/

build:
Expand All @@ -159,11 +159,11 @@ jobs:

steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v2
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
- name: Cache node_modules
uses: actions/cache@v2
uses: actions/cache@v4
env:
cache-name: cache-node-modules
with:
Expand All @@ -180,9 +180,12 @@ jobs:
if: ${{ success() && github.actor != 'dependabot[bot]' }}
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v4
with:
name: coverage
name: coverage-unit
- uses: actions/download-artifact@v4
with:
name: coverage-integration

- uses: paambaati/codeclimate-action@v2.7.5
env:
Expand All @@ -197,7 +200,7 @@ jobs:
needs: [test_unit, test_integration]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v2
- uses: actions/setup-node@v4
with:
node-version: '20'

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v2
- uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: https://registry.npmjs.org/
Expand Down
15 changes: 8 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"web3": "^1.8.0"
},
"dependencies": {
"@oceanprotocol/contracts": "^2.0.3",
"@oceanprotocol/contracts": "^2.2.0",
"cross-fetch": "^4.0.0",
"crypto-js": "^4.1.1",
"decimal.js": "^10.4.1",
Expand Down
4 changes: 4 additions & 0 deletions src/@types/Datatoken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ export interface DatatokenCreateParams {
cap: string
name?: string
symbol?: string
filesObject?: any // file object for template 4
accessListFactory?: string // access list factory address
allowAccessList?: string // Allow List Contract (if any)
denyAccessList?: string // Deny List Contract (if any)
}

export interface ConsumeMarketFee {
Expand Down
4 changes: 4 additions & 0 deletions src/config/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,4 +179,8 @@ export class Config {
DFRewards?: string
DFStrategyV1?: string
veFeeEstimate?: string

// is confidential evm
confidentialEVM?: boolean
accessListFactory?: string
}
42 changes: 39 additions & 3 deletions src/config/ConfigHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,16 @@ export const configHelperNetworks: Config[] = [
explorerUri: 'https://explorer.oasis.io/mainnet/sapphire/',
gasFeeMultiplier: 1
},
{
...configHelperNetworksBase,
chainId: 23295,
network: 'oasis_sapphire_testnet',
nodeUri: 'https://testnet.sapphire.oasis.dev',
subgraphUri:
'https://v4.subgraph.sapphire-testnet.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph',
explorerUri: 'https://explorer.oasis.io/testnet/sapphire/',
gasFeeMultiplier: 1
},
{
...configHelperNetworksBase,
chainId: 32456,
Expand All @@ -168,6 +178,11 @@ export const configHelperNetworks: Config[] = [
}
]

export const KNOWN_CONFIDENTIAL_EVMS = [
23294, // oasis_sapphire
23295 // oasis_sapphire_testnet
]

export class ConfigHelper {
/* Load contract addresses from env ADDRESS_FILE (generated by ocean-contracts) */
public getAddressesFromEnv(network: string, customAddresses?: any): Partial<Config> {
Expand All @@ -190,7 +205,8 @@ export class ConfigHelper {
veDelegationProxy,
DFRewards,
DFStrategyV1,
veFeeEstimate
veFeeEstimate,
AccessListFactory
} = customAddresses[network]
configAddresses = {
nftFactoryAddress: ERC721Factory,
Expand All @@ -208,6 +224,7 @@ export class ConfigHelper {
DFRewards,
DFStrategyV1,
veFeeEstimate,
accessListFactory: AccessListFactory,
...(process.env.AQUARIUS_URL && { metadataCacheUri: process.env.AQUARIUS_URL }),
...(process.env.PROVIDER_URL && { providerUri: process.env.PROVIDER_URL })
}
Expand All @@ -229,7 +246,8 @@ export class ConfigHelper {
veDelegationProxy,
DFRewards,
DFStrategyV1,
veFeeEstimate
veFeeEstimate,
AccessListFactory
} = DefaultContractsAddresses[network]
configAddresses = {
nftFactoryAddress: ERC721Factory,
Expand All @@ -247,6 +265,7 @@ export class ConfigHelper {
DFRewards,
DFStrategyV1,
veFeeEstimate,
accessListFactory: AccessListFactory,
...(process.env.AQUARIUS_URL && { metadataCacheUri: process.env.AQUARIUS_URL }),
...(process.env.PROVIDER_URL && { providerUri: process.env.PROVIDER_URL })
}
Expand All @@ -263,6 +282,7 @@ export class ConfigHelper {
*/
public getConfig(network: string | number, infuraProjectId?: string): Config {
const filterBy = typeof network === 'string' ? 'network' : 'chainId'

let config = configHelperNetworks.find((c) => c[filterBy] === network)

if (!config) {
Expand All @@ -282,7 +302,23 @@ export class ConfigHelper {
console.log(e)
addresses = null
}
const contractAddressesConfig = this.getAddressesFromEnv(config.network, addresses)

let contractAddressesConfig = this.getAddressesFromEnv(config.network, addresses)
// check oasis network name typos on addresses.json
if (!contractAddressesConfig && KNOWN_CONFIDENTIAL_EVMS.includes(config.chainId)) {
contractAddressesConfig = this.getAddressesFromEnv(
config.network.replace('sapph', 'saph'),
addresses
)
}
config.confidentialEVM =
filterBy === 'chainId'
? KNOWN_CONFIDENTIAL_EVMS.includes(Number(network))
: network.toString().includes('oasis_sap')
if (config.confidentialEVM) {
config.accessListFactory = contractAddressesConfig.accessListFactory
}

config = { ...config, ...contractAddressesConfig }

const nodeUri = infuraProjectId
Expand Down
35 changes: 27 additions & 8 deletions src/contracts/NFTFactory.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BigNumber } from 'ethers'
import { BigNumber, ethers } from 'ethers'
import ERC721Factory from '@oceanprotocol/contracts/artifacts/contracts/ERC721Factory.sol/ERC721Factory.json'
import {
generateDtName,
Expand Down Expand Up @@ -570,20 +570,39 @@ export class NftFactory extends SmartContractWithAddress {
}
}

// common stuff for other templates
const addresses = [
dtParams.minter,
dtParams.paymentCollector,
dtParams.mpFeeAddress,
dtParams.feeToken
]

if (dtParams.filesObject) {
// template 4 only, ignored for others
if (dtParams.accessListFactory) {
addresses.push(dtParams.accessListFactory)
}
if (dtParams.allowAccessList) {
addresses.push(dtParams.allowAccessList)
}

if (dtParams.denyAccessList) {
addresses.push(dtParams.denyAccessList)
}
}

return {
templateIndex: dtParams.templateIndex,
strings: [dtParams.name || name, dtParams.symbol || symbol],
addresses: [
dtParams.minter,
dtParams.paymentCollector,
dtParams.mpFeeAddress,
dtParams.feeToken
],
addresses,
uints: [
await this.amountToUnits(null, dtParams.cap, 18),
await this.amountToUnits(null, dtParams.feeAmount, feeTokenDecimals)
],
bytess: []
bytess: dtParams.filesObject
? [ethers.utils.toUtf8Bytes(JSON.stringify(dtParams.filesObject))]
: []
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/services/Provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ export class Provider {
)) + 1
).toString()

const signature = await this.signProviderRequest(signer, did + nonce)
const signature = await this.signProviderRequest(signer, did + nonce) // did + nonce
let consumeUrl = downloadUrl
consumeUrl += `?fileIndex=${fileIndex}`
consumeUrl += `&documentId=${did}`
Expand Down
Loading
Loading