Skip to content

Commit

Permalink
Merge pull request #592 from nevermined-io/fix/cli_utility
Browse files Browse the repository at this point in the history
Small utility improvements
  • Loading branch information
aaitor authored Oct 6, 2023
2 parents 0e96954 + 176132c commit a3d608a
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 17 deletions.
21 changes: 15 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,19 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
- feat: subscription by credits api [`f97aa61`](https://github.com/nevermined-io/sdk-js/commit/f97aa61c4328a7bc8ea1f14f584b3664876970db)
- chore: adapting nft 1155 to duration and transfer params [`a133315`](https://github.com/nevermined-io/sdk-js/commit/a133315c8b217cec7d41e6f863277dfe94fce98a)

#### [v2.0.0-rc2](https://github.com/nevermined-io/sdk-js/compare/v2.0.0-rc14...v2.0.0-rc2)
#### [v2.0.0-rc2](https://github.com/nevermined-io/sdk-js/compare/v2.0.0-rc15...v2.0.0-rc2)

> 26 July 2023
#### [v2.0.0-rc15](https://github.com/nevermined-io/sdk-js/compare/v2.0.0-rc14...v2.0.0-rc15)

> 6 October 2023
- feat: support search base on nftType [`#590`](https://github.com/nevermined-io/sdk-js/pull/590)
- Automated CHANGELOG.md update [`fb540a1`](https://github.com/nevermined-io/sdk-js/commit/fb540a1a6826f7a163ae00a849167ca5612a0132)
- feat: utility improvements and typo [`af30abe`](https://github.com/nevermined-io/sdk-js/commit/af30abe281a00084ba12ba570f1daf3056c6c175)
- fix: nft1155 test [`7ae842e`](https://github.com/nevermined-io/sdk-js/commit/7ae842e74e72faca84b6945fba9c6d968ee1873a)

#### [v2.0.0-rc14](https://github.com/nevermined-io/sdk-js/compare/v2.0.0-rc13...v2.0.0-rc14)

> 4 October 2023
Expand Down Expand Up @@ -497,7 +506,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
- ci: testing with https services [`bb96077`](https://github.com/nevermined-io/sdk-js/commit/bb96077c9403ea7ae26195a51d8a92e144cea384)
- linting [`d2547ed`](https://github.com/nevermined-io/sdk-js/commit/d2547edfbfebb49b488c97c4ce9e6d6f2ee849e4)

### [v1.0.0](https://github.com/nevermined-io/sdk-js/compare/v1.0.0-rc9...v1.0.0)
#### [v1.0.0](https://github.com/nevermined-io/sdk-js/compare/v1.0.0-rc9...v1.0.0)

> 14 February 2023
Expand Down Expand Up @@ -1236,7 +1245,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

> 2 May 2022
- add aave service agreement to ddo when creating nft721 asset [`#248`](https://github.com/nevermined-io/sdk-js/pull/248)
- add aave service agreement to ddo when creating nft721 asset [`#248`](https://github.com/nevermined-io/sdk-js/pull/248)
- Adding v0.19.21 Changelog updates [`c93cdc5`](https://github.com/nevermined-io/sdk-js/commit/c93cdc55f139a43db4130ccb0f80924d2645a931)

#### [v0.19.21](https://github.com/nevermined-io/sdk-js/compare/v0.19.20...v0.19.21)
Expand Down Expand Up @@ -1499,7 +1508,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

> 18 January 2022
- Removing not used parameter [`#186`](https://github.com/nevermined-io/sdk-js/pull/186)
- Removing not used parameter [`#186`](https://github.com/nevermined-io/sdk-js/pull/186)
- [wip] Create agreement+pay in one transaction [`#183`](https://github.com/nevermined-io/sdk-js/pull/183)
- Adapting to contracts `v1.3.3` [`#177`](https://github.com/nevermined-io/sdk-js/pull/177)
- Adding v0.17.2 Changelog updates [`5eddda4`](https://github.com/nevermined-io/sdk-js/commit/5eddda43954e013e6e6f7344c9a877d801aacb5c)
Expand Down Expand Up @@ -2005,7 +2014,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
- Feature/sync develop [`#268`](https://github.com/nevermined-io/sdk-js/pull/268)
- Quick fix for non-eip1559 networks [`#266`](https://github.com/nevermined-io/sdk-js/pull/266)
- integrate Permissions and refactor search query [`#264`](https://github.com/nevermined-io/sdk-js/pull/264)
- add aave service agreement to ddo when creating nft721 asset [`#248`](https://github.com/nevermined-io/sdk-js/pull/248)
- add aave service agreement to ddo when creating nft721 asset [`#248`](https://github.com/nevermined-io/sdk-js/pull/248)
- Get the keeper version from the artifacts instead of package version [`#244`](https://github.com/nevermined-io/sdk-js/pull/244)
- replace `metadata-api` url by `marketplace-api` and sort type [`#243`](https://github.com/nevermined-io/sdk-js/pull/243)
- fixing issues with BigNumbers [`#246`](https://github.com/nevermined-io/sdk-js/pull/246)
Expand Down Expand Up @@ -2044,7 +2053,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
- Feature/190 add did to sec markets [`#191`](https://github.com/nevermined-io/sdk-js/pull/191)
- Adding utility methods for getting nft token uri [`#189`](https://github.com/nevermined-io/sdk-js/pull/189)
- Lint ... [`#187`](https://github.com/nevermined-io/sdk-js/pull/187)
- Removing not used parameter [`#186`](https://github.com/nevermined-io/sdk-js/pull/186)
- Removing not used parameter [`#186`](https://github.com/nevermined-io/sdk-js/pull/186)
- [wip] Create agreement+pay in one transaction [`#183`](https://github.com/nevermined-io/sdk-js/pull/183)
- Adapting to contracts `v1.3.3` [`#177`](https://github.com/nevermined-io/sdk-js/pull/177)
- Correct typo in route [`#184`](https://github.com/nevermined-io/sdk-js/pull/184)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nevermined-io/sdk",
"version": "2.0.0-rc14",
"version": "2.0.0-rc15",
"description": "Javascript SDK for connecting with Nevermined Data Platform ",
"main": "./dist/node/sdk.js",
"typings": "./dist/node/sdk.d.ts",
Expand Down
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
5 changes: 4 additions & 1 deletion src/keeper/contracts/NFTContractsBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export class NFTContractsBase extends ContractBase {
* @returns Contract Receipt
*/
protected async _createClone(
ercType: 721 | 1155,
name: string,
symbol: string,
uri: string,
Expand All @@ -43,7 +44,9 @@ export class NFTContractsBase extends ContractBase {
try {
const contractReceipt: ContractTransactionReceipt = await this.sendFrom(
'createClone',
cap ? [name, symbol, uri, String(cap), operators] : [name, symbol, uri, operators],
ercType === 721
? [name, symbol, uri, String(cap), operators]
: [name, symbol, uri, operators],
from,
txParams,
)
Expand Down
2 changes: 1 addition & 1 deletion src/keeper/contracts/Nft1155Contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export class Nft1155Contract extends NFTContractsBase {
from?: Account,
txParams?: TxParameters,
) {
return this._createClone(name, symbol, uri, undefined, operators, from, txParams)
return this._createClone(1155, name, symbol, uri, undefined, operators, from, txParams)
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/keeper/contracts/Nft721Contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export class Nft721Contract extends NFTContractsBase {
from?: Account,
txParams?: TxParameters,
) {
return this._createClone(name, symbol, uri, cap, operators, from, txParams)
return this._createClone(721, name, symbol, uri, cap, operators, from, txParams)
}

public async mint(did: string, from: string, txParams?: TxParameters) {
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 a3d608a

Please sign in to comment.