Skip to content

Commit

Permalink
fix: using sdk v3.0.x
Browse files Browse the repository at this point in the history
  • Loading branch information
aaitor committed Jun 4, 2024
1 parent 7800d81 commit 986fc5b
Show file tree
Hide file tree
Showing 69 changed files with 399 additions and 579 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
token: ${{ secrets.API_TOKEN_GITHUB }}
opengsn: 'true'
estuary: 'true'
contracts-version: 'v3.5.4'
contracts-version: 'v3.5.7'
node-version: 'latest'
- name: Check artifacts and circuits
run: |
Expand Down
17 changes: 8 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nevermined-io/cli",
"version": "2.1.2",
"version": "2.2.`0",
"main": "index.js",
"repository": "git@github.com:nevermined-io/cli.git",
"author": "Nevermined",
Expand All @@ -25,8 +25,7 @@
"ncli": "./dist/src/index.js"
},
"dependencies": {
"@nevermined-io/sdk": "^2.2.11",
"@nevermined-io/sdk-dtp": "^0.7.0-rc5",
"@nevermined-io/sdk": "3.0.9",
"log4js": "^6.9.1",
"chalk": "^4.1.2",
"cross-fetch": "~3.1.5",
Expand All @@ -44,13 +43,13 @@
"@types/yargs": "^17.0.2",
"@typescript-eslint/eslint-plugin": "^5.16.0",
"@typescript-eslint/parser": "^5.16.0",
"eslint": "^8.11.0",
"eslint": "^8.57.0",
"eslint-config-alloy": "^4.3.0",
"eslint-config-nevermined": "^0.2.0",
"eslint-config-next": "^12.3.1",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-prettier": "^4.0.0",
"eslint-config-next": "^14.1.4",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-prettier": "^5.1.3",
"jest": "^29.5.0",
"jose": "^4.13.0",
"node-fetch": "^2.6.1",
Expand All @@ -59,6 +58,6 @@
"rollup": "^2.58.0",
"ts-jest": "^29.1.0",
"ts-node": "^10.8.1",
"typescript": "^5.1.6"
"typescript": "^5.4.3"
}
}
49 changes: 11 additions & 38 deletions resources/commands.json
Original file line number Diff line number Diff line change
Expand Up @@ -841,8 +841,10 @@
"default": "0",
"description": "The max number of tokens created in this NFT contract. If 0 means unlimitted"
},{
"name": "approve",
"name": "operators",
"type": "array",
"default": [],
"demandOption": false,
"description": "A list of addresses to be approved to manage the NFT contract"
},{
"name": "addOperator",
Expand Down Expand Up @@ -1351,8 +1353,9 @@
"default": "",
"description": "The nft metadata uri"
},{
"name": "approve",
"type": "array",
"name": "operators",
"type": "array",
"demandOption": false,
"description": "A list of addresses to be approved to manage the NFT contract"
},{
"name": "addOperator",
Expand Down Expand Up @@ -1767,41 +1770,6 @@
"default": false,
"description": "If given it encrypts the file with AES and return password"
}]
}, {
"name": "decrypt [file]",
"description": "Decrypt a file",
"details": "It decrypts a previously encrypted file using the password provided.",
"examples": ["ncli utils decrypt README.md --password 12345678"],
"commandHandler": "decryptFile",
"positionalArguments": [{
"name": "file",
"type": "string",
"description": "The path to the file to decrypt"
},
{
"name": "password",
"type": "string",
"default": "",
"description": "The password to be used to decrypt the file"
}],
"optionalArguments": []
}, {
"name": "encrypt [file]",
"description": "Encrypt a file",
"details": "It encrypts a file using the password provided.",
"examples": ["ncli utils encrypt README.md --password 12345678"],
"commandHandler": "encryptFile",
"positionalArguments": [{
"name": "file",
"type": "string",
"description": "The path to the file to encrypt"
}],
"optionalArguments": [{
"name": "password",
"type": "string",
"default": "",
"description": "The password to be used to encrypt the file. If empty, a new password will be generated"
}]
}, {
"name": "publish-nft-metadata",
"description": "It publish the metadata associated to a NFT into external storage",
Expand Down Expand Up @@ -2231,6 +2199,11 @@
"type": "string",
"demandOption": false,
"description": "The identifier of the agreement created by the buyer"
}, {
"name": "numCredits",
"type": "number",
"demandOption": false,
"description": "The number of credits to order"
}
]
}, {
Expand Down
11 changes: 6 additions & 5 deletions resources/networks.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"envName": "Local",
"isProduction": false,
"nvm": {
"chainId": 1337,
"appUrl": "http://localhost:3000",
"web3ProviderUri": "http://contracts.nevermined.localnet",
"marketplaceUri": "http://marketplace.nevermined.localnet",
Expand Down Expand Up @@ -88,7 +89,7 @@
"nativeToken": "MATIC",
"networkId": "137",
"networkName": "matic",
"contractsVersion": "3.5.6",
"contractsVersion": "3.5.7",
"tagName": "public",
"etherscanUrl": "https://polygonscan.com",
"erc20TokenAddress": "0x2791bca1f2de4661ed88a30c99a7a9449aa84174",
Expand Down Expand Up @@ -116,7 +117,7 @@
"contractsVersion": "3.5.6",
"tagName": "public",
"etherscanUrl": "https://sepolia.arbiscan.io",
"erc20TokenAddress": "0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d",
"erc20TokenAddress": "0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d",
"gasMultiplier": 0,
"gasPriceMultiplier": 0,
"externalNetwork": true
Expand All @@ -138,7 +139,7 @@
"nativeToken": "ETH",
"networkId": "42161",
"networkName": "arbitrum-one",
"contractsVersion": "3.5.6",
"contractsVersion": "3.5.7",
"tagName": "public",
"etherscanUrl": "https://arbiscan.io",
"erc20TokenAddress": "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
Expand All @@ -149,11 +150,11 @@
"appBase": {
"envDescription": "The Base production environment where users can interact with Nevermined protocol.",
"envUrl": "https://base.nevermined.app/",
"envName": "Base",
"envName": "base",
"isProduction": true,
"nvm": {
"appUrl": "https://base.nevermined.app",
"web3ProviderUri": "https://mainnet.base.org",
"web3ProviderUri": "https://1rpc.io/base",
"marketplaceUri": "https://marketplace-api.base.nevermined.app",
"graphHttpUri": "https://api.thegraph.com/subgraphs/name/nevermined-io/public",
"neverminedNodeUri": "https://node.base.nevermined.app",
Expand Down
6 changes: 3 additions & 3 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { ExecutionOutput } from './models/ExecutionOutput'
import fs from 'fs'
import * as CliCommands from './commands'
import { CLICommandsDefinition } from './models/CLICommandsDefinition'
import { Account, NvmApp } from '@nevermined-io/sdk'
import { NvmAccount, NvmApp } from '@nevermined-io/sdk'
import { ConfigEntry } from './models/ConfigDefinition'
type CliCommands = typeof CliCommands

Expand All @@ -33,7 +33,7 @@ const cmdHandler = async (

let config: ConfigEntry
let nvmApp: NvmApp
let userAccount: Account
let userAccount: NvmAccount

if (process.env.NETWORK) network = process.env.NETWORK

Expand Down Expand Up @@ -113,7 +113,7 @@ const cmdHandler = async (
`Connected to Network:'${networkId}'\n`
)
)
userAccount = await nvmApp.sdk.accounts.list().then(accounts => accounts[accountIndex])
userAccount = nvmApp.sdk.accounts.list()[accountIndex]

if (!userAccount || !userAccount.getId()) {
throw new Error(
Expand Down
4 changes: 2 additions & 2 deletions src/commands/accounts/export.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Account, NvmApp } from '@nevermined-io/sdk'
import { NvmAccount, NvmApp } from '@nevermined-io/sdk'
import { StatusCodes, printWallet } from '../../utils'
import chalk from 'chalk'
import { Logger } from 'log4js'
Expand All @@ -9,7 +9,7 @@ import fs from 'fs'

export const accountsExport = async (
_nvmApp: NvmApp,
_account: Account,
_account: NvmAccount,
argv: any,
config: ConfigEntry,
logger: Logger
Expand Down
4 changes: 2 additions & 2 deletions src/commands/accounts/fund.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Account, NvmApp } from '@nevermined-io/sdk'
import { NvmAccount, NvmApp } from '@nevermined-io/sdk'
import { StatusCodes } from '../../utils'
import { Logger } from 'log4js'
import chalk from 'chalk'
Expand All @@ -9,7 +9,7 @@ const ERC20_DISPENSED_AMOUNT = 100n

export const accountsFund = async (
nvmApp: NvmApp,
account: Account,
account: NvmAccount,
argv: any,
_config: ConfigEntry,
logger: Logger
Expand Down
8 changes: 4 additions & 4 deletions src/commands/accounts/list.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {
Account,
NvmAccount,
NFT721Api,
parseEther,
formatEther,
Expand All @@ -19,7 +19,7 @@ import { ConfigEntry } from '../../models/ConfigDefinition'

export const accountsList = async (
nvmApp: NvmApp,
_account: Account,
_account: NvmAccount,
argv: any,
config: ConfigEntry,
logger: Logger
Expand All @@ -29,7 +29,7 @@ export const accountsList = async (

const token = await loadToken(nvm, config, verbose)

let accounts: Account[] = []
let accounts: NvmAccount[] = []
if (address) {
logger.info(`Getting balance of account ${address}`)
accounts = [await nvm.accounts.getAccount(address)]
Expand Down Expand Up @@ -60,7 +60,7 @@ export const accountsList = async (
const loadedAccounts = await Promise.all(
accounts.map(async (a, index) => {

const balanceFormatted = formatEther(await a.getEtherBalance())
const balanceFormatted = formatEther(await nvm.accounts.getEtherBalance(a.getId()))
const ethBalance = parseEther(
balanceFormatted
)
Expand Down
4 changes: 2 additions & 2 deletions src/commands/accounts/new.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Account, NvmApp } from '@nevermined-io/sdk'
import { NvmAccount, NvmApp } from '@nevermined-io/sdk'
import { StatusCodes, printWallet } from '../../utils'
import chalk from 'chalk'
import { Logger } from 'log4js'
Expand All @@ -9,7 +9,7 @@ import fs from 'fs'

export const accountsNew = async (
_nvmApp: NvmApp,
_account: Account,
_account: NvmAccount,
argv: any,
_config: ConfigEntry,
logger: Logger
Expand Down
8 changes: 4 additions & 4 deletions src/commands/agreements/abortAgreement.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AccessCondition, Account, ConditionState, DDO, NvmApp, ServiceCommon, ServiceNFTSales, TransferNFT721Condition, TransferNFTCondition } from '@nevermined-io/sdk'
import { AccessCondition, NvmAccount, ConditionState, DDO, NvmApp, ServiceCommon, ServiceNFTSales, TransferNFT721Condition, TransferNFTCondition } from '@nevermined-io/sdk'
import { StatusCodes, getContractNameFromAddress } from '../../utils'
import chalk from 'chalk'
import { Logger } from 'log4js'
Expand All @@ -7,9 +7,9 @@ import { ConfigEntry } from '../../models/ConfigDefinition'

export const abortAgreement = async (
nvmApp: NvmApp,
account: Account,
account: NvmAccount,
argv: any,
config: ConfigEntry,
_config: ConfigEntry,
logger: Logger
): Promise<ExecutionOutput> => {
const { agreementId } = argv
Expand Down Expand Up @@ -109,8 +109,8 @@ export const abortAgreement = async (
assetPrice.getReceivers(),
agreementData.creator,
ddo.shortId(),
assetPrice.getTokenAddress(),
account,
assetPrice.getTokenAddress(),
)

}
Expand Down
6 changes: 3 additions & 3 deletions src/commands/agreements/listAgreements.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Account, ConditionState, NvmApp } from '@nevermined-io/sdk'
import { NvmAccount, ConditionState, NvmApp } from '@nevermined-io/sdk'
import { StatusCodes } from '../../utils'
import chalk from 'chalk'
import { Logger } from 'log4js'
Expand All @@ -7,7 +7,7 @@ import { ConfigEntry } from '../../models/ConfigDefinition'

export const listAgreements = async (
nvmApp: NvmApp,
_account: Account,
_account: NvmAccount,
argv: any,
_config: ConfigEntry,
logger: Logger
Expand All @@ -28,7 +28,7 @@ export const listAgreements = async (
for (const agreement of agreements) {
try {
const status = await nvmApp.sdk.agreements.status(agreement.agreementId, true)
const contractName = await nvmApp.sdk.keeper.getTemplateByAddress(agreement.templateId).contractName
const contractName = await nvmApp.sdk.keeper.getTemplateByAddress(agreement.templateId)?.contractName

logger.info(
chalk.dim(
Expand Down
4 changes: 2 additions & 2 deletions src/commands/agreements/showAgreement.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Account, NvmApp } from '@nevermined-io/sdk'
import { NvmAccount, NvmApp } from '@nevermined-io/sdk'
import { StatusCodes, getContractNameFromAddress } from '../../utils'
import chalk from 'chalk'
import { Logger } from 'log4js'
Expand All @@ -7,7 +7,7 @@ import { ConfigEntry } from '../../models/ConfigDefinition'

export const showAgreement = async (
nvmApp: NvmApp,
_account: Account,
_account: NvmAccount,
argv: any,
_config: ConfigEntry,
logger: Logger
Expand Down
4 changes: 2 additions & 2 deletions src/commands/app/balancePlan.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Account, jsonReplacer, NvmApp, SubscriptionType } from '@nevermined-io/sdk'
import { NvmAccount, jsonReplacer, NvmApp, SubscriptionType } from '@nevermined-io/sdk'
import { StatusCodes } from '../../utils'
import { ExecutionOutput } from '../../models/ExecutionOutput'
import chalk from 'chalk'
Expand All @@ -7,7 +7,7 @@ import { ConfigEntry } from '../../models/ConfigDefinition'

export const balancePlan = async (
nvmApp: NvmApp,
consumerAccount: Account,
consumerAccount: NvmAccount,
argv: any,
_config: ConfigEntry,
logger: Logger
Expand Down
4 changes: 2 additions & 2 deletions src/commands/app/createPlan.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Account, AssetPrice, zeroX, NvmApp, NvmAppMetadata, DDO } from '@nevermined-io/sdk'
import { NvmAccount, AssetPrice, zeroX, NvmApp, NvmAppMetadata, DDO } from '@nevermined-io/sdk'
import {
StatusCodes,
loadToken} from '../../utils'
Expand All @@ -11,7 +11,7 @@ import { ZeroAddress } from 'ethers'

export const createPlan = async (
nvmApp: NvmApp,
publisherAccount: Account,
publisherAccount: NvmAccount,
argv: any,
config: ConfigEntry,
logger: Logger
Expand Down
4 changes: 2 additions & 2 deletions src/commands/app/downloadFiles.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Account, NvmApp } from '@nevermined-io/sdk'
import { NvmAccount, NvmApp } from '@nevermined-io/sdk'
import { StatusCodes } from '../../utils'
import { ExecutionOutput } from '../../models/ExecutionOutput'
import chalk from 'chalk'
Expand All @@ -7,7 +7,7 @@ import { ConfigEntry } from '../../models/ConfigDefinition'

export const downloadFiles = async (
nvmApp: NvmApp,
_buyerAccount: Account,
_buyerAccount: NvmAccount,
argv: any,
_config: ConfigEntry,
logger: Logger
Expand Down
Loading

0 comments on commit 986fc5b

Please sign in to comment.