Skip to content

Commit

Permalink
Merge branch 'main' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
aaitor authored Sep 22, 2023
2 parents 118fac7 + a187c57 commit 4c3d8c3
Show file tree
Hide file tree
Showing 14 changed files with 76 additions and 22 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/testing-node.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
19 changes: 18 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,27 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
- feat: remove getAddress method from ContractBase [`ac14d46`](https://github.com/nevermined-io/sdk-js/commit/ac14d4641e96a8d875ceaecc9a02236877529785)
- feat: replace BigNumber class with ES2020 BigInt [`4ed4b51`](https://github.com/nevermined-io/sdk-js/commit/4ed4b51fad163e189e52b97b965e6ab878017b01)

#### [v1.13.16](https://github.com/nevermined-io/sdk-js/compare/v1.6.1...v1.13.16)
#### [v1.13.16](https://github.com/nevermined-io/sdk-js/compare/v1.6.3...v1.13.16)

> 29 May 2023
#### [v1.6.3](https://github.com/nevermined-io/sdk-js/compare/v1.6.2...v1.6.3)

> 22 September 2023
- Getting url from DDO when claiming NFT [`#582`](https://github.com/nevermined-io/sdk-js/pull/582)
- fix: getting url from DDO when claiming NFT [`b977291`](https://github.com/nevermined-io/sdk-js/commit/b977291276aaafcc9086d7324a30859fb9e15b7d)
- Automated CHANGELOG.md update [`24c5cbd`](https://github.com/nevermined-io/sdk-js/commit/24c5cbd7369995cca7a43cd2ac9def07a39f36d3)

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

> 14 September 2023
- Fix/arbitrum fees [`#577`](https://github.com/nevermined-io/sdk-js/pull/577)
- chore: adding v1.6.1 Changelog updates [`a3b206c`](https://github.com/nevermined-io/sdk-js/commit/a3b206c6bef91bfdab6016f59c7e719e1a0d6072)
- fix: test arbitrum fees [`f3550ec`](https://github.com/nevermined-io/sdk-js/commit/f3550ec82996a171d1d6258ca2f8eca0c7fb31dc)
- fix: revert back to non EIP-1559 transactions in arbitrum [`f44d731`](https://github.com/nevermined-io/sdk-js/commit/f44d731719c05bc7288bbcb55c604975fc3c2fb1)

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

> 31 August 2023
Expand Down
17 changes: 4 additions & 13 deletions integration/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions integration/nevermined/Assets.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ describe('Assets', () => {
console.debug(`It should fail with error: ${err}`)
assert.isDefined(err)
})

})
})

Expand Down
1 change: 0 additions & 1 deletion integration/nevermined/ConsumeAsset.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,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(
Expand Down
1 change: 1 addition & 0 deletions integration/nevermined/Subscriptions.e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ describe('Subscriptions using NFT ERC-721 End-to-End', () => {
let reseller: Account

let nevermined: Nevermined

let token: Token
let escrowPaymentCondition: EscrowPaymentCondition
let transferNft721Condition: TransferNFT721Condition
Expand Down
2 changes: 1 addition & 1 deletion scripts/download-artifacts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
21 changes: 21 additions & 0 deletions src/keeper/ContractHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,13 +255,19 @@ export class ContractHandler extends Instantiable {
}
}


public async getFeeData(gasPrice?: bigint, maxFeePerGas?: bigint, maxPriorityFeePerGas?: bigint) {
// Custom gas fee for polygon networks
const chainId = await this.nevermined.keeper.getNetworkId()
if (chainId === 137 || chainId === 80001) {
return this.getFeeDataPolygon(chainId)
}

// arbitrum
if (networkId === 42161 || networkId === 421613) {

Check failure on line 267 in src/keeper/ContractHandler.ts

View workflow job for this annotation

GitHub Actions / build

Cannot find name 'networkId'.

Check failure on line 267 in src/keeper/ContractHandler.ts

View workflow job for this annotation

GitHub Actions / build

Cannot find name 'networkId'.

Check failure on line 267 in src/keeper/ContractHandler.ts

View workflow job for this annotation

GitHub Actions / unit-tests

Cannot find name 'networkId'.

Check failure on line 267 in src/keeper/ContractHandler.ts

View workflow job for this annotation

GitHub Actions / unit-tests

Cannot find name 'networkId'.

Check failure on line 267 in src/keeper/ContractHandler.ts

View workflow job for this annotation

GitHub Actions / build

Cannot find name 'networkId'.

Check failure on line 267 in src/keeper/ContractHandler.ts

View workflow job for this annotation

GitHub Actions / build

Cannot find name 'networkId'.
return this.getFeeDataArbitrum()
}

const feeData = await this.web3.getFeeData()

// EIP-1559 fee parameters
Expand Down Expand Up @@ -313,4 +319,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,
}
}
}
2 changes: 1 addition & 1 deletion src/keeper/contracts/templates/BaseTemplate.abstract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export abstract class BaseTemplate<Params, S extends Service>
public abstract description(): string
public abstract conditions(): Condition<any, any>[]

public serviceEndpoint(): ServiceType {
public serviceEndpoint(): ServiceType | string {
return this.service()
}

Expand Down
4 changes: 2 additions & 2 deletions src/keeper/contracts/templates/NFT721SalesTemplate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ export class NFT721SalesTemplate extends BaseTemplate<NFT721SalesTemplateParams,
public service(): ServiceType {
return 'nft-sales'
}
public serviceEndpoint(): ServiceType {
return 'nft-sales'
public serviceEndpoint(): ServiceType | string {
return 'nft-transfer'
}

public name(): string {
Expand Down
4 changes: 4 additions & 0 deletions src/keeper/contracts/templates/NFTSalesTemplate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ export class NFTSalesTemplate extends BaseTemplate<NFTSalesTemplateParams, Servi
return 'nft-sales'
}

public serviceEndpoint(): ServiceType | string {
return 'nft-transfer'
}

public name(): string {
return 'nft1155SalesAgreement'
}
Expand Down
21 changes: 18 additions & 3 deletions src/services/node/NeverminedNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export class NeverminedNode extends Instantiable {
return `${this.url}${apiPath}/access-proof`
}

public getServiceEndpoint(service: ServiceType) {
public getServiceEndpoint(service: ServiceType | string) {
return `${this.url}${apiPath}/${service}`
}

Expand Down Expand Up @@ -380,6 +380,19 @@ export class NeverminedNode extends Instantiable {
did?: string,
serviceIndex?: number,
): Promise<boolean> {
let claimNFTEndpoint = this.getClaimNftEndpoint()
try {
if (did) {
// Getting Node endpoint from DDO
const ddo = await this.nevermined.assets.resolve(did)
const salesService = ddo.findServiceByType('nft-sales')
const endpointURL = new URL(salesService.serviceEndpoint)
claimNFTEndpoint = `${endpointURL.protocol}//${endpointURL.host}${apiPath}/nft-transfer`
}
} catch (e) {
this.logger.log(`Unable to get endpoint from DDO: ${did}`)
}

try {
const claimBody = JSON.stringify({
agreementId,
Expand All @@ -390,8 +403,10 @@ export class NeverminedNode extends Instantiable {
nftType: ercType,
serviceIndex: serviceIndex && serviceIndex >= 0 ? serviceIndex : -1,
})

const response = await this.nevermined.utils.fetch.post(this.getClaimNftEndpoint(), claimBody)

this.logger.log(`Claiming NFT using endpoint: ${claimNFTEndpoint}`)
const response = await this.nevermined.utils.fetch.post(claimNFTEndpoint, claimBody)

if (!response.ok) {
throw new HttpError(`${response.statusText} ${response.url}`, response.status)
}
Expand Down
1 change: 1 addition & 0 deletions test/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { LoggerInstance } from '../src/utils'

LoggerInstance.setLevel(LogLevel.Error)


const config = {
marketplaceUri: 'http://localhost:3100',
neverminedNodeUri: 'http://localhost:8030',
Expand Down

0 comments on commit 4c3d8c3

Please sign in to comment.