diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..07e7ef1 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,7 @@ +# Release Notes +All notable changes to this project will be documented in this file. + +## 0.26.1 - Sep 16, 2020 + +### Fixed +- test contracts BankCollector & ContractDeployer to pass with new compiler diff --git a/package.json b/package.json index 26ff734..67753a6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ton-client-node-js", - "version": "0.26.0", + "version": "0.26.1", "description": "TON Client Library for Node.Js", "main": "index.js", "scripts": { diff --git a/sample/__tests__/contracts/BankCollector.sol b/sample/__tests__/contracts/BankCollector.sol index e9c3012..88592f0 100644 --- a/sample/__tests__/contracts/BankCollector.sol +++ b/sample/__tests__/contracts/BankCollector.sol @@ -1,4 +1,5 @@ pragma solidity >=0.5.0; + // Interface to the bank client. abstract contract IBankClient { function demandDebt(uint amount) public virtual; @@ -7,8 +8,8 @@ abstract contract IBankClient { // Interface to the bank collector. abstract contract IBankCollector { - function receivePayment() public payable virtual; - function getDebtAmount() public payable virtual; + function receivePayment() public virtual; + function getDebtAmount() public virtual; } @@ -17,7 +18,7 @@ contract BankCollector is IBankCollector { // Modifier that allows public function to accept all external calls. modifier onlyOwner { - // Runtime functions to obtain message sender pubkey and contract pubkey. + // Runtime functions to obtain message sender pubkey and contract pubkey. require(msg.pubkey() == tvm.pubkey()); // Runtime function that allows contract to process inbound messages spending @@ -43,37 +44,39 @@ contract BankCollector is IBankCollector { // Add client to database. function addClient(address addr, uint debtAmount) public onlyOwner { // Mapping member function to obtain value from mapping if it exists. - (bool exists, ClientInfo info) = clientDB.fetch(addr); - if (exists) { - info.debtAmount += debtAmount; - clientDB[addr] = info; + optional(ClientInfo) info = clientDB.fetch(addr); + if (info.hasValue()) { + ClientInfo i = info.get(); + i.debtAmount += debtAmount; + clientDB[addr] = i; } else { clientDB[addr] = ClientInfo(debtAmount, uint32(now) + EXPIRATION_PERIOD); } } // Function for client to get his debt amount. - function getDebtAmount() public payable override { + function getDebtAmount() public override { // Mapping member function to obtain value from mapping if it exists. - (bool exists, ClientInfo info) = clientDB.fetch(msg.sender); - if (exists) { - IBankClient(msg.sender).setDebtAmount(info.debtAmount); + optional(ClientInfo) info = clientDB.fetch(msg.sender); + if (info.hasValue()) { + IBankClient(msg.sender).setDebtAmount(info.get().debtAmount); } else { IBankClient(msg.sender).setDebtAmount(0); } } // Function for client to return debt. - function receivePayment() public payable override { + function receivePayment() public override { address addr = msg.sender; // Mapping member function to obtain value from mapping if it exists. - (bool exists, ClientInfo info) = clientDB.fetch(addr); - if (exists) { - if (info.debtAmount <= msg.value) { + optional(ClientInfo) info = clientDB.fetch(addr); + if (info.hasValue()) { + ClientInfo i = info.get(); + if (i.debtAmount <= msg.value) { delete clientDB[addr]; } else { - info.debtAmount -= msg.value; - clientDB[addr] = info; + i.debtAmount -= msg.value; + clientDB[addr] = i; } } } @@ -82,13 +85,14 @@ contract BankCollector is IBankCollector { function demandExpiredDebts() public view onlyOwner { uint32 curTime = uint32(now); // Mapping member function to obtain minimal key and associated value from mapping if it exists. - (address addr, ClientInfo info, bool exists) = clientDB.min(); - while(exists) { + optional(address, ClientInfo) client = clientDB.min(); + while(client.hasValue()) { + (address addr, ClientInfo info) = client.get(); if (info.expiredTimestamp <= curTime) IBankClient(addr).demandDebt(info.debtAmount); // Mapping member function to obtain next key and associated value from mapping if it exists. - (addr, info, exists) = clientDB.next(addr); + client = clientDB.next(addr); } } -} +} \ No newline at end of file diff --git a/sample/__tests__/contracts/ContractDeployer.sol b/sample/__tests__/contracts/ContractDeployer.sol index 840f16c..9646150 100644 --- a/sample/__tests__/contracts/ContractDeployer.sol +++ b/sample/__tests__/contracts/ContractDeployer.sol @@ -80,9 +80,9 @@ contract ContractDeployer { // Function that allows to get information about contract with given ID. function getContractInfo(uint ID) public view acceptOnlyOwner returns (bool, address, TvmCell, uint256) { - (bool exists, DeployedContract contr) = contracts.fetch(ID); - if (exists) - return (true, contr.addr, contr.stateInit, contr.pubkey); + optional(DeployedContract) contr = contracts.fetch(ID); + if (contr.hasValue()) + return (true, contr.get().addr, contr.get().stateInit, contr.get().pubkey); TvmCell cell; return (false, address(0), cell, 0); } diff --git a/sample/__tests__/contracts/ContractDeployer.tvc b/sample/__tests__/contracts/ContractDeployer.tvc index 4be58f6..f003bb7 100644 Binary files a/sample/__tests__/contracts/ContractDeployer.tvc and b/sample/__tests__/contracts/ContractDeployer.tvc differ