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

pass config argument when we have it #84

Merged
merged 4 commits into from
Jan 10, 2025
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
5 changes: 3 additions & 2 deletions src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,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,
Expand Down Expand Up @@ -296,7 +296,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();
Expand Down
16 changes: 11 additions & 5 deletions src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@
name: string,
symbol: string,
owner: Signer,
assetUrl: any,

Check warning on line 74 in src/helpers.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
ddo: any,

Check warning on line 75 in src/helpers.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
providerUrl: string,
config: Config,
aquariusInstance: Aquarius,
Expand All @@ -82,7 +82,7 @@
) {
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
Expand All @@ -91,7 +91,7 @@
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(
Expand All @@ -118,18 +118,23 @@
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.value) // 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.value) === 0) { // ddo?.stats?.price?.value === "0"
const dispenserParams: DispenserCreationParams = {
dispenserAddress: config.dispenserAddress,
maxTokens: "1",
Expand All @@ -144,14 +149,15 @@
dispenserParams
);
} else {
// price is <> 0
const fixedPriceParams: FreCreationParams = {
fixedRateAddress: config.fixedRateExchangeAddress,
baseTokenAddress: config.oceanTokenAddress,
owner: await owner.getAddress(),
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,
Expand Down
Loading