Skip to content

Commit

Permalink
feat: add as an option in the config
Browse files Browse the repository at this point in the history
  • Loading branch information
eruizgar91 committed Oct 25, 2023
1 parent 24099bf commit 6f610b4
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 38 deletions.
1 change: 1 addition & 0 deletions aave_integration/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ export default {
treasuryAddress: '0xd0A1E359811322d97991E03f863a0C30C2cF029C',
agreementFee: 15,
},
testNet: true,
} as NeverminedOptions
1 change: 1 addition & 0 deletions integration/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const configBase: NeverminedOptions = {
ipfsProjectId,
ipfsProjectSecret,
verbose: logLevel,
testNet: true,
}

if (process.env.NETWORK_NAME === 'testing') {
Expand Down
38 changes: 4 additions & 34 deletions src/keeper/Keeper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,18 +152,10 @@ export class Keeper extends Instantiable {
)
}

// Optionals
// try {
// this.instances.dispenser = await Dispenser.getInstance(this.instantiableConfig)
// } catch {
// this.logger.debug('Dispenser not available on this network.')
// }

// try {
// this.instances.token = await Token.getInstance(this.instantiableConfig)
// } catch {
// this.logger.debug('Token not available on this network.')
// }
if (this.config.testNet) {
this.instances.dispenser = await Dispenser.getInstance(this.instantiableConfig)
this.instances.token = await Token.getInstance(this.instantiableConfig)
}

// Main contracts
this.dispenser = this.instances.dispenser
Expand Down Expand Up @@ -464,28 +456,6 @@ export class Keeper extends Instantiable {
}
return this.royalties.curve
}

public async loadDispenserInstance() {
if (this.instances.dispenser) return this.instances.dispenser
try {
this.instances.dispenser = await Dispenser.getInstance(this.instantiableConfig)
this.dispenser = await Dispenser.getInstance(this.instantiableConfig)
} catch {
this.logger.debug('Dispenser not available on this network.')
}
return this.instances.dispenser
}

public async loadTokenInstance() {
if (this.instances.token) return this.instances.token
try {
this.instances.token = await Token.getInstance(this.instantiableConfig)
this.token = await Token.getInstance(this.instantiableConfig)
} catch {
this.logger.debug('Token not available on this network.')
}
return this.instances.token
}
}

export default Keeper
2 changes: 2 additions & 0 deletions src/models/NeverminedOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,6 @@ export class NeverminedOptions {
* Use a gas station to calculate transaction fees
*/
public gasStationUri?: string

public testNet?: boolean
}
1 change: 1 addition & 0 deletions test/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const config = {
treasuryAddress: '0xd0A1E359811322d97991E03f863a0C30C2cF029C',
agreementFee: 15,
},
testNet: true,
} as NeverminedOptions

if (process.env.SEED_WORDS) {
Expand Down
2 changes: 0 additions & 2 deletions test/keeper/ContractEvent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ describe('ContractEvent', () => {
before(async () => {
await TestContractHandler.prepareContracts()
nevermined = await Nevermined.getInstance(config)
nevermined.keeper.dispenser = await nevermined.keeper.loadDispenserInstance()
nevermined.keeper.token = await nevermined.keeper.loadTokenInstance()
web3 = await Web3Provider.getWeb3(config)
;[account1, account2, account3, account4] = await nevermined.accounts.list()
})
Expand Down
2 changes: 0 additions & 2 deletions test/nevermined/Accounts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ describe('Accounts', () => {
before(async () => {
// eslint-disable-next-line @typescript-eslint/no-extra-semi
nevermined = await Nevermined.getInstance(config)
nevermined.keeper.dispenser = await nevermined.keeper.loadDispenserInstance()
nevermined.keeper.token = await nevermined.keeper.loadTokenInstance()
accounts = nevermined.accounts
})

Expand Down

0 comments on commit 6f610b4

Please sign in to comment.