From e95441ddf033b768cb4e52ab7719be5b81449e39 Mon Sep 17 00:00:00 2001 From: paulo-ocean Date: Wed, 18 Dec 2024 12:24:01 +0000 Subject: [PATCH 1/3] pass config argument when we have it --- src/commands.ts | 5 +++-- src/helpers.ts | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/commands.ts b/src/commands.ts index d2c50c0..d35cdac 100644 --- a/src/commands.ts +++ b/src/commands.ts @@ -202,7 +202,7 @@ export class Commands { ? this.macOsProviderUrl : dataDdo.services[0].serviceEndpoint; console.log("Downloading asset using provider: ", providerURI); - const datatoken = new Datatoken(this.signer, this.config.chainId); + const datatoken = new Datatoken(this.signer, this.config.chainId, this.config); const tx = await orderAsset( dataDdo, @@ -291,7 +291,8 @@ export class Commands { const datatoken = new Datatoken( this.signer, - (await this.signer.provider.getNetwork()).chainId + (await this.signer.provider.getNetwork()).chainId, + this.config ); const mytime = new Date(); diff --git a/src/helpers.ts b/src/helpers.ts index 4e38a11..678fe79 100644 --- a/src/helpers.ts +++ b/src/helpers.ts @@ -82,7 +82,7 @@ export async function createAsset( ) { const { chainId } = await owner.provider.getNetwork(); const nft = new Nft(owner, chainId); - const nftFactory = new NftFactory(config.nftFactoryAddress, owner); + const nftFactory = new NftFactory(config.nftFactoryAddress, owner, chainId, config); let wrappedSigner let allowListAddress @@ -91,7 +91,7 @@ export async function createAsset( wrappedSigner = sapphire.wrap(owner); // Create Access List Factory - const accessListFactory = new AccesslistFactory(config.accessListFactory, wrappedSigner, chainId); + const accessListFactory = new AccesslistFactory(config.accessListFactory, wrappedSigner, chainId, config); // Create Allow List allowListAddress = await accessListFactory.deployAccessListContract( From 9d45eb60034471a74a6f1e335e124bcfd07c0169 Mon Sep 17 00:00:00 2001 From: paulo-ocean Date: Thu, 9 Jan 2025 15:21:05 +0000 Subject: [PATCH 2/3] minor unrelated fix on stats price check --- src/helpers.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/helpers.ts b/src/helpers.ts index cc12a45..06d2900 100644 --- a/src/helpers.ts +++ b/src/helpers.ts @@ -118,18 +118,23 @@ export async function createAsset( cap: "100000", feeAmount: "0", paymentCollector: await owner.getAddress(), + // use ocean token as default for fees, only if we don't have another specific fee token feeToken: ddo?.stats?.price?.tokenAddress ? ddo.stats.price.tokenAddress : config.oceanTokenAddress, minter: await owner.getAddress(), mpFeeAddress: ZERO_ADDRESS, }; let bundleNFT; - if (!ddo.stats?.price?.value) { + const hasStatsPrice = ddo.stats && ddo.stats.price // are price stats defined? + const hasPriceValue = hasStatsPrice && !isNaN(ddo.stats.price) // avoid confusion with value '0' + // no price set + if (!hasPriceValue) { // !ddo.stats?.price?.value bundleNFT = await nftFactory.createNftWithDatatoken( nftParamsAsset, datatokenParams ); - } else if (ddo?.stats?.price?.value === "0") { + // price is 0 + } else if (hasPriceValue && Number(ddo.stats.price) === 0) { // ddo?.stats?.price?.value === "0" const dispenserParams: DispenserCreationParams = { dispenserAddress: config.dispenserAddress, maxTokens: "1", @@ -144,6 +149,7 @@ export async function createAsset( dispenserParams ); } else { + // price is <> 0 const fixedPriceParams: FreCreationParams = { fixedRateAddress: config.fixedRateExchangeAddress, baseTokenAddress: config.oceanTokenAddress, @@ -151,7 +157,7 @@ export async function createAsset( marketFeeCollector: await owner.getAddress(), baseTokenDecimals: 18, datatokenDecimals: 18, - fixedRate: ddo.stats.price.value, + fixedRate: ddo.stats.price.value, // we have a fixed rate price here marketFee: "0", allowedConsumer: await owner.getAddress(), withMint: true, From 3d92e2b6dbafbf5745ea57646ac0013c3664eef6 Mon Sep 17 00:00:00 2001 From: paulo-ocean Date: Thu, 9 Jan 2025 15:35:22 +0000 Subject: [PATCH 3/3] fix missing .value --- src/helpers.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/helpers.ts b/src/helpers.ts index 06d2900..45286e3 100644 --- a/src/helpers.ts +++ b/src/helpers.ts @@ -126,7 +126,7 @@ export async function createAsset( let bundleNFT; const hasStatsPrice = ddo.stats && ddo.stats.price // are price stats defined? - const hasPriceValue = hasStatsPrice && !isNaN(ddo.stats.price) // avoid confusion with value '0' + const hasPriceValue = hasStatsPrice && !isNaN(ddo.stats.price.value) // avoid confusion with value '0' // no price set if (!hasPriceValue) { // !ddo.stats?.price?.value bundleNFT = await nftFactory.createNftWithDatatoken( @@ -134,7 +134,7 @@ export async function createAsset( datatokenParams ); // price is 0 - } else if (hasPriceValue && Number(ddo.stats.price) === 0) { // ddo?.stats?.price?.value === "0" + } else if (hasPriceValue && Number(ddo.stats.price.value) === 0) { // ddo?.stats?.price?.value === "0" const dispenserParams: DispenserCreationParams = { dispenserAddress: config.dispenserAddress, maxTokens: "1",