diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5b51e5fe..c7f1126b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -61,7 +61,7 @@ jobs: run: | bash -x start_ocean.sh --no-aquarius --no-elasticsearch --no-provider --no-dashboard 2>&1 > start_ocean.log & env: - CONTRACTS_VERSION: v1.1.3 + CONTRACTS_VERSION: v1.1.4 - run: npm ci - name: Wait for contracts deployment working-directory: ${{ github.workspace }}/barge @@ -118,6 +118,8 @@ jobs: working-directory: ${{ github.workspace }}/barge run: | bash -x start_ocean.sh --with-provider2 --no-dashboard --with-c2d 2>&1 > start_ocean.log & + env: + CONTRACTS_VERSION: v1.1.3 - run: npm ci - run: npm run build:metadata diff --git a/CodeExamples.md b/CodeExamples.md index 50801a50..d84982f9 100644 --- a/CodeExamples.md +++ b/CodeExamples.md @@ -85,6 +85,7 @@ Start by importing all of the necessary dependencies ```Typescript +import { AbiItem } from 'web3-utils' import { SHA256 } from 'crypto-js' import { approve, @@ -106,7 +107,9 @@ import { ProviderFees, ProviderInstance, transfer, - ZERO_ADDRESS + ZERO_ADDRESS, + calculateEstimatedGas, + sendTx } from '../../src' import { getAddresses, getTestConfig, web3 } from '../config' ``` @@ -202,7 +205,13 @@ As we go along it's a good idea to console log the values so that you check they ``` ## 5. Initialize accounts and deploy contracts - ### 5.1 Initialize accounts + ### 5.1 Next, lets get the address of the deployed contracts +```Typescript + addresses = getAddresses() + +``` + + ### 5.2 Initialize accounts ```Typescript const accounts = await web3.eth.getAccounts() publisherAccount = accounts[0] @@ -214,6 +223,39 @@ Again, lets console log the values so that we can check that they have been save console.log(`Publisher account address: ${publisherAccount}`) console.log(`Consumer account address: ${consumerAccount}`) console.log(`Staker account address: ${stakerAccount}`) + ``` diff --git a/package-lock.json b/package-lock.json index 66b39c29..8f584507 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "2.0.0", "license": "Apache-2.0", "dependencies": { - "@oceanprotocol/contracts": "^1.1.3", + "@oceanprotocol/contracts": "^1.1.4", "bignumber.js": "^9.0.2", "cross-fetch": "^3.1.5", "crypto-js": "^4.1.1", @@ -2615,9 +2615,9 @@ } }, "node_modules/@oceanprotocol/contracts": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/@oceanprotocol/contracts/-/contracts-1.1.3.tgz", - "integrity": "sha512-pn0rm4QKF8sVfDeJVlt18TV4Qj5oGgR/qQNO7O0GO2DQ3q8KHXRS15uRjmLTr5wW1kGcCHcTqEndXEEC7Elzkw==" + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/@oceanprotocol/contracts/-/contracts-1.1.4.tgz", + "integrity": "sha512-fIJjtyj1fxF3GNaITUDaUJbQ2FBCLqB6Hlg72k5SzBK2//yuSPfdZVAqomul0qQjgiKl0jlJRmWVpfer/a5z2g==" }, "node_modules/@octokit/auth-token": { "version": "3.0.1", @@ -19612,9 +19612,9 @@ } }, "@oceanprotocol/contracts": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/@oceanprotocol/contracts/-/contracts-1.1.3.tgz", - "integrity": "sha512-pn0rm4QKF8sVfDeJVlt18TV4Qj5oGgR/qQNO7O0GO2DQ3q8KHXRS15uRjmLTr5wW1kGcCHcTqEndXEEC7Elzkw==" + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/@oceanprotocol/contracts/-/contracts-1.1.4.tgz", + "integrity": "sha512-fIJjtyj1fxF3GNaITUDaUJbQ2FBCLqB6Hlg72k5SzBK2//yuSPfdZVAqomul0qQjgiKl0jlJRmWVpfer/a5z2g==" }, "@octokit/auth-token": { "version": "3.0.1", diff --git a/package.json b/package.json index 25aeb048..4dd16ee4 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "web3": "^1.7.4" }, "dependencies": { - "@oceanprotocol/contracts": "^1.1.3", + "@oceanprotocol/contracts": "^1.1.4", "bignumber.js": "^9.0.2", "cross-fetch": "^3.1.5", "crypto-js": "^4.1.1", diff --git a/src/@types/File.ts b/src/@types/File.ts index c48bfad6..481606f7 100644 --- a/src/@types/File.ts +++ b/src/@types/File.ts @@ -20,8 +20,29 @@ export interface UrlFile { method: string } +export interface GraphqlQuery { + type: 'graphql' + + /** + * @type {number} + */ + index?: number + + /** + * Endpoint URL + * @type {string} + */ + url: string + + /** + * query + * @type {string} + */ + query: string +} + export interface Files { nftAddress: string datatokenAddress: string - files: UrlFile[] + files: UrlFile[] | GraphqlQuery[] } diff --git a/src/contracts/index.ts b/src/contracts/index.ts index 2db33363..d1b99fce 100644 --- a/src/contracts/index.ts +++ b/src/contracts/index.ts @@ -8,6 +8,7 @@ export * from './NFT' export * from './NFTFactory' export * from './ve/VeOcean' export * from './ve/VeFeeDistributor' +export * from './ve/VeFeeEstimate' export * from './ve/VeAllocate' export * from './df/DfRewards' export * from './df/DfStrategyV1' diff --git a/src/contracts/ve/VeFeeEstimate.ts b/src/contracts/ve/VeFeeEstimate.ts new file mode 100644 index 00000000..ea2348c1 --- /dev/null +++ b/src/contracts/ve/VeFeeEstimate.ts @@ -0,0 +1,27 @@ +import { AbiItem } from 'web3-utils' +import veFeeEstimate from '@oceanprotocol/contracts/artifacts/contracts/ve/veFeeEstimate.vy/veFeeEstimate.json' +import { SmartContractWithAddress } from '../SmartContractWithAddress' +import { VeOcean } from './VeOcean' +/** + * Provides an interface for veOcean contract + */ +export class VeFeeEstimate extends SmartContractWithAddress { + getDefaultAbi(): AbiItem | AbiItem[] { + return veFeeEstimate.abi as AbiItem[] + } + + /** + * estimateClaim + * @param {String} userAddress user address + * @return {Promise} + */ + public async estimateClaim(userAddress: string): Promise { + const amount = await this.contract.methods.estimateClaim(userAddress).call() + const veOcean = new VeOcean( + await this.contract.methods.voting_escrow().call(), + this.web3 + ) + const amountFormated = await this.unitsToAmount(await veOcean.getToken(), amount) + return amountFormated + } +} diff --git a/test/integration/CodeExamples.test.ts b/test/integration/CodeExamples.test.ts index a7a4e773..9e0f48e4 100644 --- a/test/integration/CodeExamples.test.ts +++ b/test/integration/CodeExamples.test.ts @@ -85,6 +85,7 @@ /// ```Typescript import { assert } from 'chai' +import { AbiItem } from 'web3-utils' import { SHA256 } from 'crypto-js' import { approve, @@ -106,7 +107,9 @@ import { ProviderFees, ProviderInstance, transfer, - ZERO_ADDRESS + ZERO_ADDRESS, + calculateEstimatedGas, + sendTx } from '../../src' import { getAddresses, getTestConfig, web3 } from '../config' /// ``` @@ -202,7 +205,13 @@ describe('Marketplace flow tests', async () => { /// ``` /// ## 5. Initialize accounts and deploy contracts - it('5.1 Initialize accounts', async () => { + it('5.1 Next, lets get the address of the deployed contracts', async () => { + /// ```Typescript + addresses = getAddresses() + }) /// + /// ``` + + it('5.2 Initialize accounts', async () => { /// ```Typescript const accounts = await web3.eth.getAccounts() publisherAccount = accounts[0] @@ -214,6 +223,39 @@ describe('Marketplace flow tests', async () => { console.log(`Publisher account address: ${publisherAccount}`) console.log(`Consumer account address: ${consumerAccount}`) console.log(`Staker account address: ${stakerAccount}`) + /// }) /// /// ``` diff --git a/test/integration/ComputeFlow.test.ts b/test/integration/ComputeFlow.test.ts index feef4687..44a7bbd5 100644 --- a/test/integration/ComputeFlow.test.ts +++ b/test/integration/ComputeFlow.test.ts @@ -1,5 +1,6 @@ import { assert } from 'chai' import { SHA256 } from 'crypto-js' +import { AbiItem } from 'web3-utils' import { web3, getTestConfig, getAddresses } from '../config' import { Config, @@ -10,7 +11,9 @@ import { Datatoken, Nft, ZERO_ADDRESS, - approveWei + approveWei, + calculateEstimatedGas, + sendTx } from '../../src' import { DatatokenCreateParams, @@ -360,6 +363,40 @@ describe('Simple compute tests', async () => { const accounts = await web3.eth.getAccounts() publisherAccount = accounts[0] consumerAccount = accounts[1] + // mint Ocean + ///