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

Adapting to SDKv2 #109

Merged
merged 13 commits into from
Nov 27, 2023
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
2 changes: 1 addition & 1 deletion .github/workflows/push-to-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v1
with:
node-version: '16'
node-version: '18'
- name: Install dependencies
run: |
yarn install --ignore-engines
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-github.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
# Build process
- uses: actions/setup-node@v3
with:
node-version: "14.x"
node-version: '18'

- name: Set version to env
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '16'
node-version: '18'
registry-url: https://registry.npmjs.org/
- run: yarn install --frozen-lockfile
- run: yarn build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/testing-nigthly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
node-version: 18
- name: Install dependencies
run: |
yarn install --ignore-engines
Expand Down
33 changes: 17 additions & 16 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,31 @@
name: Testing

on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
on: [push]

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Reclaim some disk space
run: docker system prune --all --volumes -f
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
node-version: 18

- name: Install dependencies
run: |
yarn
- name: Run linters
run: yarn lint
- name: Build
run: |
yarn build
yarn start --help

- uses: nevermined-io/nvm-tools-actions@v0.12.0
- uses: nevermined-io/nvm-tools-actions@v0.15.0
with:
token: ${{ secrets.API_TOKEN_GITHUB }}
opengsn: 'true'
estuary: 'true'
contracts-version: 'v3.2.1'
contracts-version: 'v3.5.4'
node-version: 'latest'
- name: Check artifacts and circuits
run: |
nvm-tools copy-artifacts /tmp/.nevermined/artifacts
Expand All @@ -39,16 +34,22 @@ jobs:
nvm-tools copy-circuits /tmp/.nevermined/circuits
ls -l /tmp/.nevermined/circuits/keytransfer.wasm

- name: Build
run: |
yarn build
yarn start --help

- name: Run integration tests
env:
LOCAL_CONF_DIR: '/tmp/.nevermined'
SEED_WORDS: ${{ secrets.TEST_MNEMONIC }}
INFURA_TOKEN: ${{ secrets.INFURA_TOKEN }}
IPFS_PROJECT_ID: ${{ secrets.IPFS_PROJECT_ID }}
IPFS_PROJECT_SECRET: ${{ secrets.IPFS_PROJECT_SECRET }}
LOCAL_CONF_DIR: '/tmp/.nevermined'
TOKEN_ADDRESS: '0x0000000000000000000000000000000000000000'
WEB3_PROVIDER_URL: 'http://contracts.nevermined.localnet'
NETWORK: 'geth-localnet'
IPFS_PROJECT_ID: ${{ secrets.IPFS_PROJECT_ID }}
IPFS_PROJECT_SECRET: ${{ secrets.IPFS_PROJECT_SECRET }}
NO_GRAPH: 'true'

run: |
yarn test:integration
- name: Upload logs
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ package-lock.json
yarn.lock
artifacts/
.idea
.yalc*
40 changes: 20 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nevermined-io/cli",
"version": "1.2.5",
"version": "2.0.0",
"main": "index.js",
"repository": "git@github.com:nevermined-io/cli.git",
"author": "Nevermined",
Expand All @@ -13,6 +13,7 @@
"format": "prettier --parser typescript --ignore-path .gitignore --write '**/*.{js,jsx,ts,tsx}'",
"clean": "rm -rf ./dist/ ./doc/ ./.nyc_output",
"build:watch": "npm build --watch",
"dev": "ts-node src/index.ts",
"start": "node dist/src/index.js",
"generate-doc": "ts-node src/generateDoc.ts",
"test": "jest --coverage --rootDir test -w 1",
Expand All @@ -24,41 +25,40 @@
"ncli": "./dist/src/index.js"
},
"dependencies": {
"@nevermined-io/sdk": "1.6.0",
"@nevermined-io/sdk-dtp": "0.6.1",
"@truffle/hdwallet-provider": "^2.0.9",
"@nevermined-io/sdk": "^2.0.7",
"@nevermined-io/sdk-dtp": "^0.7.0-rc5",
"log4js": "^6.9.1",
"chalk": "^4.1.2",
"cross-fetch": "~3.1.5",
"dotenv": "^16.0.1",
"eta": "1.12.3",
"ethers": "^6.7.1",
"ipfs-http-client-lite": "^0.3.0",
"log4js": "^6.5.2",
"tar": "^6.1.11",
"yargs": "^17.5.1"
},
"devDependencies": {
"ethers": "^5.6.9",
"jose": "^4.5.1",
"@types/jest": "^27.0.2",
"@types/jest": "^29.5.2",
"@types/node-fetch": "^2.5.7",
"@types/tar": "^6.1.1",
"@types/yargs": "^17.0.2",
"@types/node-fetch": "^2.5.7",
"node-fetch": "^2.6.1",
"@typescript-eslint/eslint-plugin": "^4.33.0",
"@typescript-eslint/parser": "^4.33.0",
"eslint": "^7.32.0",
"@typescript-eslint/eslint-plugin": "^5.16.0",
"@typescript-eslint/parser": "^5.16.0",
"eslint": "^8.11.0",
"eslint-config-alloy": "^4.3.0",
"eslint-config-nevermined": "^0.2.0",
"eslint-config-next": "^12.3.1",
"eslint-config-prettier": "^8.5.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-prettier": "^4.0.0",
"jest": "^27.2.5",
"prettier": "^2.4.1",
"prettier-package-json": "^2.7.0",
"jest": "^29.5.0",
"jose": "^4.13.0",
"node-fetch": "^2.6.1",
"prettier": "^2.8.8",
"prettier-package-json": "^2.8.0",
"rollup": "^2.58.0",
"ts-jest": "^27.0.6",
"ts-node": "^10.3.0",
"typescript": "^4.4.4"
"ts-jest": "^29.1.0",
"ts-node": "^10.8.1",
"typescript": "^5.1.6"
}
}
50 changes: 47 additions & 3 deletions resources/commands.json
Original file line number Diff line number Diff line change
Expand Up @@ -158,15 +158,15 @@
"description": "Load NFT (ERC-721) inventory as well"
}]
}, {
"name": "fund [account]",
"name": "fund [addressToFund]",
"description": "Funds an account with ERC20 tokens on a testnet",
"details": "In the test environments all tokens lack real value. Typically in Nevermined you need to use different type of tokens. The Native token (`ETH`, `MATIC`, etc) to pay for the gas resulting to write into a blockchain network, and optionally with a `ERC20` token to do some payments. This command allows to get some funds in a testnet environment allowing to a user to run different processes on a testnet. This command will not work in production environments where the tokens have actual value.",
"examples": ["ncli accounts fund 0xe2DD09d719Da89e5a3D0F2549c7E24566e947260"],
"commandHandler": "accountsFund",
"positionalArguments": [{
"name": "account",
"name": "addressToFund",
"type": "string",
"description": "The account to fund"
"description": "The account address to fund"
}],
"optionalArguments": []
}]
Expand Down Expand Up @@ -579,6 +579,50 @@
"type": "string",
"description": "Password for receiving encrypted files"
}]
}, {
"name": "get-providers [did]",
"description": "Gets the list of provider addresses granted to an asset",
"details": "This method gest the complete list of providers granted to an asset",
"examples": ["ncli assets get-providers did:nv:912e7a547bcd675ffbc5d2063ef770e15744029f048f706f6bb0281df4f4700f"],
"commandHandler": "getAssetProviders",
"positionalArguments": [{
"name": "did",
"type": "string",
"description": "The asset DID"
}],
"optionalArguments": []
}, {
"name": "grant-provider [did] [providerAddress]",
"description": "Grant an address as provider of an asset",
"details": "This method adds an address as provider of an asset",
"examples": ["ncli assets grant-provider did:nv:912e7a547bcd675ffbc5d2063ef770e15744029f048f706f6bb0281df4f4700f 0x736DCC96D89cB2F9E2316cD826668f4E1c4861B0"],
"commandHandler": "grantAssetProvider",
"positionalArguments": [{
"name": "did",
"type": "string",
"description": "The asset DID"
}, {
"name": "providerAddress",
"type": "string",
"description": "The provider address"
}],
"optionalArguments": []
}, {
"name": "revoke-provider [did] [providerAddress]",
"description": "Revokes an address as provider of an asset",
"details": "This method revokes an address as provider of an asset",
"examples": ["ncli assets revoke-provider did:nv:912e7a547bcd675ffbc5d2063ef770e15744029f048f706f6bb0281df4f4700f 0x736DCC96D89cB2F9E2316cD826668f4E1c4861B0"],
"commandHandler": "revokeAssetProvider",
"positionalArguments": [{
"name": "did",
"type": "string",
"description": "The asset DID"
}, {
"name": "providerAddress",
"type": "string",
"description": "The provider address"
}],
"optionalArguments": []
}, {
"name": "get [did]",
"description": "Order & download or download directly a previously purchased asset",
Expand Down
16 changes: 8 additions & 8 deletions resources/networks.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"nativeToken": "MATIC",
"networkId": "80001",
"networkName": "mumbai",
"contractsVersion": "3.2.1",
"contractsVersion": "3.5.4",
"tagName": "public",
"etherscanUrl": "https://mumbai.polygonscan.com",
"erc20TokenAddress": "0xe11A86849d99F524cAC3E7A0Ec1241828e332C62",
Expand Down Expand Up @@ -88,7 +88,7 @@
"gasPriceMultiplier": 0,
"externalNetwork": true
},
"oneStaging": {
"appStaging": {
"envDescription": "Nevermined One internal environment where Nevermined developers can integrate new versions of the application.",
"envUrl": "https://goerli.nevermined.one/",
"isProduction": false,
Expand All @@ -103,7 +103,7 @@
"nativeToken": "ETH",
"networkId": "421613",
"networkName": "arbitrum-goerli",
"contractsVersion": "3.2.2",
"contractsVersion": "3.5.4",
"tagName": "public",
"etherscanUrl": "https://goerli.arbiscan.io",
"erc20TokenAddress": "0xfd064A18f3BF249cf1f87FC203E90D8f650f2d63",
Expand All @@ -126,7 +126,7 @@
"nativeToken": "MATIC",
"networkId": "80001",
"networkName": "mumbai",
"contractsVersion": "3.2.1",
"contractsVersion": "3.4.0",
"tagName": "public",
"etherscanUrl": "https://mumbai.polygonscan.com",
"erc20TokenAddress": "0x2058a9d7613eee744279e3856ef0eada5fcbaa7e",
Expand All @@ -149,7 +149,7 @@
"nativeToken": "MATIC",
"networkId": "137",
"networkName": "matic",
"contractsVersion": "3.2.1",
"contractsVersion": "3.5.4",
"tagName": "public",
"etherscanUrl": "https://polygonscan.com",
"erc20TokenAddress": "0x2791bca1f2de4661ed88a30c99a7a9449aa84174",
Expand All @@ -172,7 +172,7 @@
"nativeToken": "ETH",
"networkId": "421613",
"networkName": "arbitrum-goerli",
"contractsVersion": "3.2.2",
"contractsVersion": "3.5.4",
"tagName": "public",
"etherscanUrl": "https://goerli.arbiscan.io",
"erc20TokenAddress": "0xfd064A18f3BF249cf1f87FC203E90D8f650f2d63",
Expand All @@ -195,7 +195,7 @@
"nativeToken": "ETH",
"networkId": "42161",
"networkName": "arbitrum-one",
"contractsVersion": "3.2.2",
"contractsVersion": "3.5.4",
"tagName": "public",
"etherscanUrl": "https://arbiscan.io",
"erc20TokenAddress": "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
Expand All @@ -218,7 +218,7 @@
"nativeToken": "xDAI",
"networkId": "100",
"networkName": "gnosis",
"contractsVersion": "3.2.1",
"contractsVersion": "3.5.4",
"tagName": "public",
"etherscanUrl": "https://gnosisscan.io",
"erc20TokenAddress": "0xDDAfbb505ad214D7b80b1f830fcCc89B60fb7A83",
Expand Down
12 changes: 10 additions & 2 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const cmdHandler = async (
if (process.env.NETWORK) network = process.env.NETWORK

try {
config = getConfig(network as string, requiresAccount, accountIndex)
config = await getConfig(network as string, requiresAccount, accountIndex)
await configureLocalEnvironment(network as string, config)
} catch (err) {
console.error(`Error setting up the CLI: ${(err as Error).message}`)
Expand Down Expand Up @@ -99,6 +99,7 @@ const cmdHandler = async (
`Please, check if you are connected to the right node url. Currently using: ${config.nvm.web3ProviderUri}\n`
)
}

userAccount = loadAccountFromSeedWords(config.seed!, accountIndex)

logger.debug(
Expand All @@ -107,8 +108,15 @@ const cmdHandler = async (
)
)
const token = await loadToken(nvm, config, argv.verbose)
if (token)
if (token) {
nvm.keeper.token = token
}

logger.debug(
chalk.dim(
`Login to Marketplace API with account: '${userAccount.getId()}'\n`
)
)

await loginMarketplaceApi(nvm, userAccount)
}
Expand Down
Loading