diff --git a/.github/workflows/testing-node.yml b/.github/workflows/testing-node.yml index 1012a0c98..b32a90b1e 100644 --- a/.github/workflows/testing-node.yml +++ b/.github/workflows/testing-node.yml @@ -7,6 +7,8 @@ jobs: 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: diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index edc0361fe..9381265b5 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -7,6 +7,8 @@ jobs: 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: diff --git a/integration/config.ts b/integration/config.ts index 5afc4ca70..c2dda42f7 100644 --- a/integration/config.ts +++ b/integration/config.ts @@ -35,15 +35,6 @@ if (process.env.NETWORK_NAME === 'testing') { } as NeverminedOptions) } -if (process.env.NETWORK_NAME === 'goerli') { - Object.assign(configBase, { - marketplaceUri: 'https://metadata.goerli.nevermined.network', - neverminedNodeUri: 'https://node.goerli.nevermined.network', - web3ProviderUri: `https://goerli.infura.io/v3/${infuraToken}`, - neverminedNodeAddress: '0x068Ed00cF0441e4829D9784fCBe7b9e26D4BD8d0', - } as NeverminedOptions) -} - if (process.env.NETWORK_NAME === 'mumbai') { Object.assign(configBase, { marketplaceUri: 'https://marketplace-api.mumbai.nevermined.app', @@ -74,11 +65,11 @@ if (process.env.NETWORK_NAME === 'gnosis') { } as NeverminedOptions) } -if (process.env.NETWORK_NAME === 'nvm-one') { +if (process.env.NETWORK_NAME === 'one-staging') { Object.assign(configBase, { - marketplaceUri: 'https://marketplace-api.mumbai.nevermined.one', - neverminedNodeUri: 'https://node.mumbai.nevermined.one', - web3ProviderUri: `https://polygon-mumbai.infura.io/v3/${infuraToken}`, + marketplaceUri: 'https://marketplace-api.goerli.nevermined.one', + neverminedNodeUri: 'https://node.goerli.nevermined.one', + web3ProviderUri: `https://arbitrum-goerli.infura.io/v3/${infuraToken}`, neverminedNodeAddress: '0x5838B5512cF9f12FE9f2beccB20eb47211F9B0bc', graphHttpUri: 'https://api.thegraph.com/subgraphs/name/nevermined-io/public', } as NeverminedOptions) diff --git a/integration/nevermined/Assets.test.ts b/integration/nevermined/Assets.test.ts index 0dd65b812..19661a317 100644 --- a/integration/nevermined/Assets.test.ts +++ b/integration/nevermined/Assets.test.ts @@ -172,7 +172,7 @@ describe('Assets', () => { it('should be able to download the updated files', async () => { const folder = '/tmp/sdk-js/updated-files' - if (!fs.existsSync(folder)) fs.mkdirSync(folder, { recursive: true}) + if (!fs.existsSync(folder)) fs.mkdirSync(folder, { recursive: true }) const path = (await nevermined.assets.download(ddo.id, publisher, folder, -1)) as string assert.include(path, folder, 'The storage path is not correct.') @@ -229,7 +229,7 @@ describe('Assets', () => { }) it('new rating must be between 0 and 1', async () => { - // Trying to add a vote with a rating out of range + // Trying to add a vote with a rating out of range await assert.isRejected(nevermined.assets.addRating(ddo.shortId(), 2, 1, publisher)) }) }) diff --git a/integration/nevermined/ConsumeAsset.test.ts b/integration/nevermined/ConsumeAsset.test.ts index f6147ebd7..e7c6e81e0 100644 --- a/integration/nevermined/ConsumeAsset.test.ts +++ b/integration/nevermined/ConsumeAsset.test.ts @@ -124,7 +124,6 @@ describe('Consume Asset', () => { assert.isTrue(paid, 'The asset has not been paid correctly') }) - // The test will fail because Nevermined Node grants the access faster it('should grant the access by the publisher', async () => { try { const granted = await nevermined.agreements.conditions.grantAccess( diff --git a/package.json b/package.json index ffc02aaf8..25cdba2f6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@nevermined-io/sdk", - "version": "1.6.1", + "version": "1.6.2", "description": "Javascript SDK for connecting with Nevermined Data Platform ", "main": "./dist/node/sdk.js", "typings": "./dist/node/sdk.d.ts", diff --git a/scripts/download-artifacts.sh b/scripts/download-artifacts.sh index 7b2977252..79b34b59a 100755 --- a/scripts/download-artifacts.sh +++ b/scripts/download-artifacts.sh @@ -20,7 +20,7 @@ fi REPO_URL=https://artifacts.nevermined.network declare -A NETWORKS_MAP -NETWORKS_MAP=( ["mainnet"]="1" ["rinkeby"]="4" ["kovan"]="42" ["matic"]="137" ["mumbai"]="80001" ["celo-alfajores"]="44787" ["celo"]="42220" ["aurora"]="1313161554" ["aurora-testnet"]="1313161555" ) +NETWORKS_MAP=( ["mainnet"]="1" ["rinkeby"]="4" ["kovan"]="42" ["matic"]="137" ["mumbai"]="80001" ["celo-alfajores"]="44787" ["celo"]="42220" ["aurora"]="1313161554" ["aurora-testnet"]="1313161555" ["arbitrum-one"]="42161" ["arbitrum-goerli"]="421613" ) SCRIPT_DIR=$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd) UNPACK_DIR="$SCRIPT_DIR/../artifacts" diff --git a/src/keeper/ContractHandler.ts b/src/keeper/ContractHandler.ts index fd384b0c2..ea4b8513a 100644 --- a/src/keeper/ContractHandler.ts +++ b/src/keeper/ContractHandler.ts @@ -255,12 +255,19 @@ export class ContractHandler extends Instantiable { maxFeePerGas?: BigNumber, maxPriorityFeePerGas?: BigNumber, ) { - // Custom gas fee for polygon networks + // Custom gas fee calculation for different networks const networkId = await this.nevermined.keeper.getNetworkId() + + // polygon if (networkId === 137 || networkId === 80001) { return this.getFeeDataPolygon(networkId) } + // arbitrum + if (networkId === 42161 || networkId === 421613) { + return this.getFeeDataArbitrum() + } + const feeData = await this.web3.getFeeData() // EIP-1559 fee parameters @@ -315,4 +322,19 @@ export class ContractHandler extends Instantiable { type: 2, } } + + private async getFeeDataArbitrum() { + /** + * See https://docs.arbitrum.io/arbos/gas + * + * The sequencer prioritizes transactions on a first-come first-served basis. + * Because tips do not make sense in this model, they are ignored. + * Arbitrum users always just pay the basefee regardless of the tip they choose. + */ + const feeData = await this.web3.getFeeData() + + return { + gasPrice: feeData.gasPrice, + } + } } diff --git a/src/keeper/Keeper.ts b/src/keeper/Keeper.ts index 3182d19b3..7793e0800 100644 --- a/src/keeper/Keeper.ts +++ b/src/keeper/Keeper.ts @@ -72,7 +72,7 @@ export class Keeper extends Instantiable { // Main contracts dispenser: undefined, // Optional token: undefined, // Optional - curveRoyalties: undefined, // Optional + curveRoyalties: undefined, // Optional nvmConfig: NeverminedConfig.getInstance(this.instanceConfig), didRegistry: DIDRegistry.getInstance(this.instanceConfig), // Managers @@ -101,8 +101,6 @@ export class Keeper extends Instantiable { aaveRepayCondition: undefined, aaveCreditTemplate: undefined, - - nft721LockCondition: NFT721LockCondition.getInstance(this.instanceConfig), distributeNftCollateralCondition: DistributeNFTCollateralCondition.getInstance( this.instanceConfig, @@ -207,7 +205,7 @@ export class Keeper extends Instantiable { nft721AccessTemplate: this.instances.nft721AccessTemplate, nftSalesTemplate: this.instances.nftSalesTemplate, nft721SalesTemplate: this.instances.nft721SalesTemplate, - aaveCreditTemplate: undefined + aaveCreditTemplate: undefined, } this.templateList = [ this.instances.accessTemplate, @@ -409,12 +407,10 @@ export class Keeper extends Instantiable { this.logger.debug('Loading Aave contracts') this.instances.aaveBorrowCondition = await AaveBorrowCondition.getInstance(this.instanceConfig) - this.instances.aaveCollateralDepositCondition = await AaveCollateralDepositCondition.getInstance( - this.instanceConfig, - ) - this.instances.aaveCollateralWithdrawCondition = await AaveCollateralWithdrawCondition.getInstance( - this.instanceConfig, - ) + this.instances.aaveCollateralDepositCondition = + await AaveCollateralDepositCondition.getInstance(this.instanceConfig) + this.instances.aaveCollateralWithdrawCondition = + await AaveCollateralWithdrawCondition.getInstance(this.instanceConfig) this.instances.aaveRepayCondition = await AaveRepayCondition.getInstance(this.instanceConfig) this.conditions.aaveBorrowCondition = this.instances.aaveBorrowCondition diff --git a/test/bookmarks/Bookmarks.test.ts b/test/bookmarks/Bookmarks.test.ts index 3b1cf150b..b2741215a 100644 --- a/test/bookmarks/Bookmarks.test.ts +++ b/test/bookmarks/Bookmarks.test.ts @@ -26,7 +26,7 @@ describe('Bookmarks', () => { nevermined = await Nevermined.getInstance(config) }) - beforeEach(async () => { + beforeEach(async () => { bookmarks = nevermined.services.bookmarks // eslint-disable-line prefer-destructuring newBookmark = { diff --git a/test/config.ts b/test/config.ts index 1cc6afc54..ce1a67b79 100644 --- a/test/config.ts +++ b/test/config.ts @@ -3,7 +3,7 @@ import { LoggerInstance } from '../src/utils' LoggerInstance.setLevel(LogLevel.Error) -export default { +export default { marketplaceUri: 'http://localhost:3100', neverminedNodeUri: 'http://localhost:8030', neverminedNodeAddress: '0x068ed00cf0441e4829d9784fcbe7b9e26d4bd8d0', diff --git a/test/keeper/conditions/AaveBorrowCondition.test.ts b/test/keeper/conditions/AaveBorrowCondition.test.ts index 3d096053e..81792a14f 100644 --- a/test/keeper/conditions/AaveBorrowCondition.test.ts +++ b/test/keeper/conditions/AaveBorrowCondition.test.ts @@ -27,12 +27,8 @@ describe('AaveBorrowCondition', () => { nevermined = await Nevermined.getInstance(config) ;[user] = await nevermined.accounts.list() ;({ didRegistry } = nevermined.keeper) - condition = - (await ( - await Nevermined.getInstance(config)) - .keeper.loadAaveInstances()) - .conditions.aaveBorrowCondition - + condition = (await (await Nevermined.getInstance(config)).keeper.loadAaveInstances()).conditions + .aaveBorrowCondition }) beforeEach(async () => { diff --git a/test/keeper/conditions/AaveCollateralDepositCondition.test.ts b/test/keeper/conditions/AaveCollateralDepositCondition.test.ts index b882b53cc..f8c433af9 100644 --- a/test/keeper/conditions/AaveCollateralDepositCondition.test.ts +++ b/test/keeper/conditions/AaveCollateralDepositCondition.test.ts @@ -29,11 +29,8 @@ describe('AaveCollateralDepositCondition', () => { nevermined = await Nevermined.getInstance(config) ;[user] = await nevermined.accounts.list() ;({ didRegistry } = nevermined.keeper) - condition = - (await ( - await Nevermined.getInstance(config)) - .keeper.loadAaveInstances()) - .conditions.aaveCollateralDepositCondition + condition = (await (await Nevermined.getInstance(config)).keeper.loadAaveInstances()).conditions + .aaveCollateralDepositCondition }) beforeEach(async () => { diff --git a/test/keeper/conditions/AaveCollateralWithdrawCondition.test.ts b/test/keeper/conditions/AaveCollateralWithdrawCondition.test.ts index 828b454c2..5c85f3bc2 100644 --- a/test/keeper/conditions/AaveCollateralWithdrawCondition.test.ts +++ b/test/keeper/conditions/AaveCollateralWithdrawCondition.test.ts @@ -24,11 +24,8 @@ describe('AaveCollateralWithdrawCondition', () => { nevermined = await Nevermined.getInstance(config) ;[user] = await nevermined.accounts.list() ;({ didRegistry } = nevermined.keeper) - condition = - (await ( - await Nevermined.getInstance(config)) - .keeper.loadAaveInstances()) - .conditions.aaveCollateralWithdrawCondition + condition = (await (await Nevermined.getInstance(config)).keeper.loadAaveInstances()).conditions + .aaveCollateralWithdrawCondition }) beforeEach(async () => { diff --git a/test/keeper/conditions/AaveRepayCondition.test.ts b/test/keeper/conditions/AaveRepayCondition.test.ts index 6926ff270..9cb36f36f 100644 --- a/test/keeper/conditions/AaveRepayCondition.test.ts +++ b/test/keeper/conditions/AaveRepayCondition.test.ts @@ -27,11 +27,8 @@ describe('AaveRepayCondition', () => { nevermined = await Nevermined.getInstance(config) ;[user] = await nevermined.accounts.list() ;({ didRegistry } = nevermined.keeper) - condition = - (await ( - await Nevermined.getInstance(config)) - .keeper.loadAaveInstances()) - .conditions.aaveRepayCondition + condition = (await (await Nevermined.getInstance(config)).keeper.loadAaveInstances()).conditions + .aaveRepayCondition }) beforeEach(async () => {