From beea422f84196472faaf42c50ff3f0d5c8a1c4fb Mon Sep 17 00:00:00 2001 From: Aleksandr Kukharenko Date: Thu, 21 Sep 2023 14:23:57 +0300 Subject: [PATCH] feat: contract version --- package.json | 4 ++-- src/plugins/contracts/api.js | 13 ++++++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index f3928a1..a36258d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@lumerin/wallet-core", - "version": "1.0.68", + "version": "1.0.69", "author": { "name": "Lumerin", "email": "developer@lumerin.io", @@ -36,7 +36,7 @@ "axios-cookiejar-support": "1.0.1", "chalk": "^2.4.2", "cheerio": "^1.0.0-rc.12", - "contracts-js": "github:Lumerin-protocol/contracts-js#v0.0.26", + "contracts-js": "github:Lumerin-protocol/contracts-js#v0.0.27", "cross-port-killer": "^1.4.0", "debug": "4.1.1", "ecies-geth": "^1.6.2", diff --git a/src/plugins/contracts/api.js b/src/plugins/contracts/api.js index bd7913a..934cf82 100644 --- a/src/plugins/contracts/api.js +++ b/src/plugins/contracts/api.js @@ -50,6 +50,7 @@ async function _loadContractInstance( _isDeleted: isDead, // check if contract is dead _balance: balance, _hasFutureTerms: hasFutureTerms, + _version: version, } = contract let futureTerms = null @@ -60,6 +61,7 @@ async function _loadContractInstance( speed: data._speed, length: data._length, limit: data._limit, + version: data._version, } } @@ -84,6 +86,7 @@ async function _loadContractInstance( hasFutureTerms, futureTerms, history: buyerHistory, + version, }, } } catch (err) { @@ -324,7 +327,7 @@ function setContractDeleteStatus(web3, cloneFactory, onUpdate) { */ function purchaseContract(web3, cloneFactory, lumerin) { return async (params) => { - const { walletId, contractId, url, privateKey, price } = params + const { walletId, contractId, url, privateKey, price, version } = params const sendOptions = { from: walletId, gas: 1_000_000 } //getting pubkey from contract to be purchased @@ -355,14 +358,14 @@ function purchaseContract(web3, cloneFactory, lumerin) { const marketplaceFee = await cloneFactory.methods.marketplaceFee().call(); const purchaseGas = await cloneFactory.methods - .setPurchaseRentalContract(contractId, ciphertext.toString('hex')) + .setPurchaseRentalContract(contractId, ciphertext.toString('hex'), version) .estimateGas({ from: sendOptions.from, value: marketplaceFee }) const purchaseResult = await cloneFactory.methods - .setPurchaseRentalContract(contractId, ciphertext.toString('hex')) + .setPurchaseRentalContract(contractId, ciphertext.toString('hex'), version) .send({ ...sendOptions, gas: purchaseGas, @@ -396,10 +399,13 @@ function editContract(web3, cloneFactory, lumerin) { const account = web3.eth.accounts.privateKeyToAccount(privateKey) web3.eth.accounts.wallet.create(0).add(account) + const marketplaceFee = await cloneFactory.methods.marketplaceFee().call(); + const editGas = await cloneFactory.methods .setUpdateContractInformation(contractId, price, limit, speed, duration) .estimateGas({ from: sendOptions.from, + value: marketplaceFee, }) const editResult = await cloneFactory.methods @@ -407,6 +413,7 @@ function editContract(web3, cloneFactory, lumerin) { .send({ ...sendOptions, gas: editGas, + value: marketplaceFee, }) logger.debug('Finished edit contract transaction', editResult)