Skip to content

Commit

Permalink
Merge pull request #155 from tonlabs/1.5.1-rc
Browse files Browse the repository at this point in the history
Version 1.5.1
  • Loading branch information
d3p authored Dec 27, 2022
2 parents 94b4444 + 047cede commit f291986
Show file tree
Hide file tree
Showing 22 changed files with 472 additions and 240 deletions.
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,24 @@

All notable changes to this project will be documented in this file.

## [1.5.1] - 2022-12-23

### New

- Include network giver account details in `network info <network>` command.
- Giver's signer must be specified explicitly (default network signer will not be used).
- Include EverNode SE Default Giver Keys to signers repository.
- Solidity compiler accepts file name without extension.
- `network giver` parameters `signer` and `type` are mandatory.

### Fixed

- Some `contract` commands failed with `Wait for operation failed` message in case
when account does not exist.
- Changing SE GraphQL port did not affect network endpoints related to this SE container.
- Contract commands that expects contract file name as an arg will report more detailed
error message in case when contract file does not exist.

## [1.5.0] - 2022-12-23

### New
Expand Down
104 changes: 40 additions & 64 deletions contracts/GiverV2.abi.json
Original file line number Diff line number Diff line change
@@ -1,64 +1,40 @@
{
"ABI version": 2,
"header": [
"time",
"expire"
],
"functions": [
{
"name": "sendTransaction",
"inputs": [
{
"name": "dest",
"type": "address"
},
{
"name": "value",
"type": "uint128"
},
{
"name": "bounce",
"type": "bool"
}
],
"outputs": []
},
{
"name": "getMessages",
"inputs": [],
"outputs": [
{
"components": [
{
"name": "hash",
"type": "uint256"
},
{
"name": "expireAt",
"type": "uint64"
}
],
"name": "messages",
"type": "tuple[]"
}
]
},
{
"name": "upgrade",
"inputs": [
{
"name": "newcode",
"type": "cell"
}
],
"outputs": []
},
{
"name": "constructor",
"inputs": [],
"outputs": []
}
],
"data": [],
"events": []
}
{"ABI version": 2,
"header": ["time", "expire"],
"functions": [
{
"name": "upgrade",
"inputs": [
{"name":"newcode","type":"cell"}
],
"outputs": [
]
},
{
"name": "sendTransaction",
"inputs": [
{"name":"dest","type":"address"},
{"name":"value","type":"uint128"},
{"name":"bounce","type":"bool"}
],
"outputs": [
]
},
{
"name": "getMessages",
"inputs": [
],
"outputs": [
{"components":[{"name":"hash","type":"uint256"},{"name":"expireAt","type":"uint64"}],"name":"messages","type":"tuple[]"}
]
},
{
"name": "constructor",
"inputs": [
],
"outputs": [
]
}
],
"events": [
]
}
4 changes: 4 additions & 0 deletions contracts/GiverV2.keys.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"public": "2ada2e65ab8eeab09490e3521415f45b6e42df9c760a639bcf53957550b25a16",
"secret": "172af540e43a524763dd53b26a066d472a97c4de37d5498170564510608250c3"
}
Binary file added contracts/GiverV2.tvc
Binary file not shown.
94 changes: 47 additions & 47 deletions contracts/GiverV3.abi.json
Original file line number Diff line number Diff line change
@@ -1,49 +1,49 @@
{
"ABI version": 2,
"version": "2.2",
"header": ["time", "expire"],
"functions": [
{
"name": "sendTransaction",
"inputs": [
{"name":"dest","type":"address"},
{"name":"value","type":"uint128"},
{"name":"bounce","type":"bool"}
],
"outputs": [
]
},
{
"name": "getMessages",
"inputs": [
],
"outputs": [
{"components":[{"name":"hash","type":"uint256"},{"name":"expireAt","type":"uint64"}],"name":"messages","type":"tuple[]"}
]
},
{
"name": "upgrade",
"inputs": [
{"name":"newcode","type":"cell"}
],
"outputs": [
]
},
{
"name": "constructor",
"inputs": [
],
"outputs": [
]
}
],
"data": [
],
"events": [
],
"fields": [
{"name":"_pubkey","type":"uint256"},
{"name":"_constructorFlag","type":"bool"},
{"name":"m_messages","type":"map(uint256,uint32)"}
]
"ABI version": 2,
"version": "2.2",
"header": ["time", "expire"],
"functions": [
{
"name": "sendTransaction",
"inputs": [
{"name":"dest","type":"address"},
{"name":"value","type":"uint128"},
{"name":"bounce","type":"bool"}
],
"outputs": [
]
},
{
"name": "getMessages",
"inputs": [
],
"outputs": [
{"components":[{"name":"hash","type":"uint256"},{"name":"expireAt","type":"uint64"}],"name":"messages","type":"tuple[]"}
]
},
{
"name": "upgrade",
"inputs": [
{"name":"newcode","type":"cell"}
],
"outputs": [
]
},
{
"name": "constructor",
"inputs": [
],
"outputs": [
]
}
],
"data": [
],
"events": [
],
"fields": [
{"name":"_pubkey","type":"uint256"},
{"name":"_constructorFlag","type":"bool"},
{"name":"m_messages","type":"map(uint256,uint64)"}
]
}
4 changes: 4 additions & 0 deletions contracts/GiverV3.keys.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"public": "2ada2e65ab8eeab09490e3521415f45b6e42df9c760a639bcf53957550b25a16",
"secret": "172af540e43a524763dd53b26a066d472a97c4de37d5498170564510608250c3"
}
97 changes: 97 additions & 0 deletions contracts/GiverV3.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
pragma ton-solidity >= 0.59.0;
pragma AbiHeader time;
pragma AbiHeader expire;

abstract contract Upgradable {
/*
* Set code
*/

function upgrade(TvmCell newcode) public virtual {
require(msg.pubkey() == tvm.pubkey(), 101);
tvm.accept();
tvm.commit();
tvm.setcode(newcode);
tvm.setCurrentCode(newcode);
onCodeUpgrade();
}

function onCodeUpgrade() internal virtual;
}

contract GiverV3 is Upgradable {

uint8 constant MAX_CLEANUP_MSGS = 30;
mapping(uint256 => uint64) m_messages;

modifier acceptOnlyOwner {
require(msg.pubkey() == tvm.pubkey(), 101);
tvm.accept();
_;
}

/*
* Publics
*/

/// @notice Allows to accept simple transfers.
receive() external {}

/// @notice Transfers grams to other contracts.
function sendTransaction(address dest, uint128 value, bool bounce) public {
dest.transfer(value, bounce, 3);
gc();
}

/*
* Privates
*/

/// @notice Function with predefined name called after signature check. Used to
/// implement custom replay protection with parallel access.
function afterSignatureCheck(TvmSlice body, TvmCell message) private inline
returns (TvmSlice)
{
// owner check
require(msg.pubkey() == tvm.pubkey(), 101);
// load and drop message timestamp (uint64)
(, uint64 expireAt) = body.decode(uint64, uint32);
require(expireAt > now, 57);
uint256 msgHash = tvm.hash(message);
require(!m_messages.exists(msgHash), 102);

tvm.accept();
m_messages[msgHash] = expireAt;

return body;
}

/// @notice Allows to delete expired messages from dict.
function gc() private inline {
uint counter = 0;
for ((uint256 msgHash, uint64 expireAt) : m_messages) {
if (counter >= MAX_CLEANUP_MSGS) {
break;
}
counter++;
if (expireAt <= now) {
delete m_messages[msgHash];
}
}
}

/*
* Get methods
*/
struct Message {
uint256 hash;
uint64 expireAt;
}
function getMessages() public view returns (Message[] messages) {
for ((uint256 msgHash, uint64 expireAt) : m_messages) {
messages.push(Message(msgHash, expireAt));
}
}

function onCodeUpgrade() internal override {}
}
4 changes: 4 additions & 0 deletions contracts/SafeMultisigWallet.keys.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"public": "99c84f920c299b5d80e4fcce2d2054b05466ec9df19532a688c10eb6dd8d6b33",
"secret": "73b60dc6a5b1d30a56a81ea85e0e453f6957dbfbeefb57325ca9f7be96d3fe1a"
}
21 changes: 11 additions & 10 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
module.exports = {
globals: {
'ts-jest': {
tsconfig: 'tsconfig.json',
globals: {
"ts-jest": {
tsconfig: "tsconfig.json",
},
},
},
moduleFileExtensions: ['ts', 'js'],
transform: {
'^.+\\.(ts|tsx)$': 'ts-jest',
},
testMatch: ['**/test/**/*.+(ts|js)', '**/__tests__/**/*.+(ts|tsx|js)'],
testEnvironment: 'node',
moduleFileExtensions: ["ts", "js"],
transform: {
"^.+\\.(ts|tsx)$": "ts-jest",
},
modulePathIgnorePatterns: [".*\\.d\\.ts"],
testMatch: ["**/test/**/*.+(ts)", "**/__tests__/**/*.+(ts|tsx)"],
testEnvironment: "node",
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "everdev",
"version": "1.5.0",
"version": "1.5.1",
"description": "Everscale Dev Environment",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
Loading

0 comments on commit f291986

Please sign in to comment.