Skip to content

Commit

Permalink
feat: utility improvements and typo
Browse files Browse the repository at this point in the history
  • Loading branch information
aaitor committed Oct 5, 2023
1 parent 1108aba commit af30abe
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/Instantiable.abstract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export interface InstantiableConfig {
circuitsFolder?: string
}

export async function generateIntantiableConfigFromConfig(
export async function generateInstantiableConfigFromConfig(
config: NeverminedOptions,
): Promise<Partial<InstantiableConfig>> {
const logLevel =
Expand Down
4 changes: 2 additions & 2 deletions src/keeper/Keeper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export class Keeper extends Instantiable {
nftSalesTemplate: NFTSalesTemplate.getInstance(this.instanceConfig),
nft721SalesTemplate: NFT721SalesTemplate.getInstance(this.instanceConfig),
standardRoyalties: StandardRoyalties.getInstance(this.instanceConfig), // optional
rewardsDistributor: RewardsDistributor.getInstance(this.instanceConfig),
rewardsDistributor: undefined, // RewardsDistributor.getInstance(this.instanceConfig), // optional
nftUpgradeable: Nft1155Contract.getInstance(this.instanceConfig),
})

Expand All @@ -125,7 +125,7 @@ export class Keeper extends Instantiable {
curve: undefined,
}

this.rewardsDistributor = this.instances.rewardsDistributor
this.rewardsDistributor = undefined // this.instances.rewardsDistributor

const templates = [
this.instances.accessTemplate,
Expand Down
4 changes: 2 additions & 2 deletions src/nevermined/Nevermined.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ProvenanceApi } from './api/ProvenanceApi'
import { UtilsApi } from './api/UtilsApi'
import { Keeper, CustomToken, Nft1155Contract, Nft721Contract } from '../keeper'
import { NeverminedOptions } from '../models'
import { Instantiable, generateIntantiableConfigFromConfig } from '../Instantiable.abstract'
import { Instantiable, generateInstantiableConfigFromConfig } from '../Instantiable.abstract'
import { NFT1155Api } from './api/nfts/NFT1155Api'
import { NFT721Api } from './api/nfts/NFT721Api'
import { SearchApi } from './api/SearchApi'
Expand Down Expand Up @@ -35,7 +35,7 @@ export class Nevermined extends Instantiable {
const instance = new Nevermined()

const instanceConfig = {
...(await generateIntantiableConfigFromConfig(config)),
...(await generateInstantiableConfigFromConfig(config)),
nevermined: instance,
}
instance.setInstanceConfig(instanceConfig)
Expand Down
12 changes: 10 additions & 2 deletions src/utils/MakeAccounts.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
import { Mnemonic, ethers, getIndexedAccountPath } from 'ethers'

export function makeAccounts(seedphrase: string): ethers.Wallet[] {
export function makeAccounts(seedphrase: string, numAccounts = 10): ethers.Wallet[] {
const mnemonic = Mnemonic.fromPhrase(seedphrase)
const node = ethers.HDNodeWallet.fromSeed(mnemonic.computeSeed())
const accounts: ethers.Wallet[] = []

for (let i = 0; i < 10; i++) {
for (let i = 0; i < numAccounts; i++) {
const acc = node.derivePath(getIndexedAccountPath(i))
const wallet = new ethers.Wallet(acc.privateKey)
accounts.push(wallet)
}
return accounts
}

export function makeAccount(seedphrase: string, accountIndex: number = 0): ethers.Wallet {
const mnemonic = Mnemonic.fromPhrase(seedphrase)
const node = ethers.HDNodeWallet.fromSeed(mnemonic.computeSeed())

const acc = node.derivePath(getIndexedAccountPath(accountIndex))
return new ethers.Wallet(acc.privateKey)
}

0 comments on commit af30abe

Please sign in to comment.