Skip to content

Commit

Permalink
Merge pull request #167 from tonlabs/1.6.0-rc
Browse files Browse the repository at this point in the history
1.6.0 rc
  • Loading branch information
d3p authored Feb 17, 2023
2 parents f291986 + 12cf96e commit 4b8c8b0
Show file tree
Hide file tree
Showing 24 changed files with 291 additions and 151 deletions.
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,26 @@

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

## [1.6.0] - 2023-02-13

### New

- Added [support of Signature ID](https://github.com/tonlabs/ever-sdk/blob/master/CHANGELOG.md) on the networks with
`CapSignatureWithId` capability enabled.
- Added new option `everdev contract deploy --workchain` to specify in which workchain to deploy a contract.
- `everdev contract decode-tvc` command renamed to `everdev contract decode-stateinit`.
- Add a reference to stable solc and sold versions to the output of the
`everdev sold version` and `everdev sol version` commands.

### Fixed

- Double error messages generated by `everdev sol compile` command.
- Error: `unrecognized option '-i` which occurred when using a solidity compiler version below 0.57.0
- The "constructor" function excluded from the list of callable functions
- Incorrect `GiverV1.abi.json` file has been replaced with the correct one.
- Set the `se` network as the default network if there is no default network.
- Set the `seGiver` giver as the default signer if there is no default signer.

## [1.5.1] - 2022-12-23

### New
Expand Down
37 changes: 14 additions & 23 deletions contracts/GiverV1.abi.json
Original file line number Diff line number Diff line change
@@ -1,29 +1,20 @@
{
"ABI version": 2,
"version": "2.2",
"header": [
"pubkey",
"time",
"expire"
],
"functions": [
{
"name": "sendGrams",
"inputs": [
"ABI version": 1,
"functions": [
{
"name": "dest",
"type": "address"
"name": "constructor",
"inputs": [],
"outputs": []
},
{
"name": "amount",
"type": "uint64"
"name": "sendGrams",
"inputs": [
{ "name": "dest", "type": "address" },
{ "name": "amount", "type": "uint64" }
],
"outputs": []
}
],
"outputs": [
]
}
],
"data": [],
"events": [],
"fields": []
],
"events": [],
"data": []
}
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,uint64)"}
]
"ABI version": 2,
"version": "2.3",
"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":"uint32"}],"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)"}
]
}
4 changes: 0 additions & 4 deletions contracts/GiverV3.keys.json

This file was deleted.

22 changes: 11 additions & 11 deletions contracts/GiverV3.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma ton-solidity >= 0.59.0;
pragma ever-solidity >= 0.61.2;
pragma AbiHeader time;
pragma AbiHeader expire;

Expand All @@ -22,7 +22,7 @@ abstract contract Upgradable {
contract GiverV3 is Upgradable {

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

modifier acceptOnlyOwner {
require(msg.pubkey() == tvm.pubkey(), 101);
Expand All @@ -49,33 +49,33 @@ contract GiverV3 is Upgradable {

/// @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
function afterSignatureCheck(TvmSlice body, TvmCell) private inline
returns (TvmSlice)
{
// owner check
require(msg.pubkey() == tvm.pubkey(), 101);
uint256 bodyHash = tvm.hash(body);
// load and drop message timestamp (uint64)
(, uint64 expireAt) = body.decode(uint64, uint32);
(, uint32 expireAt) = body.decode(uint64, uint32);
require(expireAt > now, 57);
uint256 msgHash = tvm.hash(message);
require(!m_messages.exists(msgHash), 102);
require(!m_messages.exists(bodyHash), 102);

tvm.accept();
m_messages[msgHash] = expireAt;
m_messages[bodyHash] = 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) {
for ((uint256 bodyHash, uint32 expireAt) : m_messages) {
if (counter >= MAX_CLEANUP_MSGS) {
break;
}
counter++;
if (expireAt <= now) {
delete m_messages[msgHash];
delete m_messages[bodyHash];
}
}
}
Expand All @@ -85,10 +85,10 @@ contract GiverV3 is Upgradable {
*/
struct Message {
uint256 hash;
uint64 expireAt;
uint32 expireAt;
}
function getMessages() public view returns (Message[] messages) {
for ((uint256 msgHash, uint64 expireAt) : m_messages) {
for ((uint256 msgHash, uint32 expireAt) : m_messages) {
messages.push(Message(msgHash, expireAt));
}
}
Expand Down
Binary file added contracts/GiverV3.tvc
Binary file not shown.
File renamed without changes.
2 changes: 1 addition & 1 deletion docs/guides/quick-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ $ everdev s l
Signer Public Key Used
-------------------- ---------------------------------------------------------------- ---------------------------
giver_keys 2ada2e65ab8eeab09490e3521415f45b6e42df9c760a639bcf53957550b25a16 se network giver signer
seGiver 2ada2e65ab8eeab09490e3521415f45b6e42df9c760a639bcf53957550b25a16 se network giver signer EverNode SE Default Giver Keys
owner_keys (Default) 3826202b129ea8c041b8d49a655512648fc94377d1958a7a4fc9f4b3051ecf7b
```

Expand Down
57 changes: 30 additions & 27 deletions docs/guides/work-with-devnet.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
- [Working with DevNet: deploy and start using your own giver in Developer Network](#working-with-devnet-deploy-and-start-using-your-own-giver-in-developer-network)
- [Contents](#contents)
- [Deploying your own Giver](#deploying-your-own-giver)
- [Get your Devnet credentials](#get-your-devnet-credentials)
- [Generate Giver keys](#generate-giver-keys)
- [Compile Giver code](#compile-giver-code)
- [Get giver code](#get-giver-code)
- [Calculate Giver address](#calculate-giver-address)
- [Sponsor Giver with public faucet](#sponsor-giver-with-public-faucet)
- [Deploy Giver contract](#deploy-giver-contract)
Expand All @@ -19,6 +20,17 @@ Working with DevNet is similar to working with SE except you usually don't have

In order to deploy the Giver, do the following steps, like for an ordinary contract:

### Get your Devnet credentials

First, go to https://www.evercloud.dev/ and register in the dashboard.
Follow this instruction: https://docs.evercloud.dev/products/evercloud/get-started.
Save your project ID and secret, if you enabled it.

Now, run this command. Specifying secret is optional - only if you enabled it:
```
$ everdev network credentials dev --project "Project Id" --access-key "Project secret"
```

### Generate Giver keys

```
Expand All @@ -31,29 +43,20 @@ test (Default) de101cde5c94540926fe862e965cf109b1b803989e7048657cf7c4caaa2a2
devnet_giver_keys 5a343ccbd62c15e3df1076bc34957ad2717469d84e4d6b3ef26112db80ac8e1b
```

### Compile Giver code
### Get giver code

You can find compiled giver v2 contract with code [here](https://github.com/tonlabs/evernode-se/tree/master/contracts/giver_v2). You need to recompile code only if you want to change its code, so you can use compiled `GiverV2.tvc` file and move to the next step.

**Attention!**
The code in repo is not compatible with the latest Solidity compilers, so if you would like to compile it yourself, you would need to migrate code to the latest Solidity version first.

After modifying code, compile it:
```
$ everdev sol compile GiverV2.sol
```
In a case of success, compiler will generate two files: compiled code (`GiverV2.tvc`) and ABI (`GiverV2.abi.json`). You need these files for the next steps.
You can find the compiled giver v3 contract [here](https://github.com/tonlabs/evernode-se/tree/master/contracts/giver_v3). You will need `GiverV3.tvc` file.

### Calculate Giver address

In order to deploy contract, you need to know its address:

```
$ everdev contract info -n dev -s devnet_giver_keys GiverV2.tvc
$ everdev contract info -n dev -s devnet_giver_keys GiverV3.tvc
Configuration
Network: dev (net.ton.dev, net1.ton.dev, net5.ton.dev)
Network: dev
Signer: devnet_giver_keys (public 5a343ccbd62c15e3df1076bc34957ad2717469d84e4d6b3ef26112db80ac8e1b)
Address: 0:93139197f2f58d674bee4ee71a42d8f1e7b6a3c3e041ded7a54d330bcc44f3b3 (calculated from TVC and signer public)
Expand All @@ -75,14 +78,14 @@ Wait for operation completion. Check address balance in [Blockchain Explorer](ht

### Deploy Giver contract

For contract deployment you need to have compiled contract files (`GiverV2.tvc` and `GiverV2.abi.json`) and giver keys. To deploy contract execute next command:
For contract deployment you need to have compiled contract files (`GiverV3.tvc` and `GiverV3.abi.json`) and giver keys. To deploy contract execute next command:

```
$ everdev contract deploy -n dev -s devnet_giver_keys GiverV2.tvc
$ everdev contract deploy -n dev -s devnet_giver_keys GiverV3.tvc
Configuration
Network: dev (eri01.net.everos.dev, rbx01.net.everos.dev, gra01.net.everos.dev)
Network: dev
Signer: devnet_giver_keys (public 5a343ccbd62c15e3df1076bc34957ad2717469d84e4d6b3ef26112db80ac8e1b)
Address: 0:93139197f2f58d674bee4ee71a42d8f1e7b6a3c3e041ded7a54d330bcc44f3b3 (calculated from TVC and signer public)
Expand All @@ -98,20 +101,20 @@ Done, now you have your own Giver, deployed to the DevNet! Let's configure `ever
For convenience, you might need to configure `everdev` in order to use your Giver as default. To do it, execute the next command (change address to your Giver's address, obtained on previous steps):

```
$ everdev network giver dev 0:93139197f2f58d674bee4ee71a42d8f1e7b6a3c3e041ded7a54d330bcc44f3b3 --signer devnet_giver_keys
$ everdev n g dev 0:93139197f2f58d674bee4ee71a42d8f1e7b6a3c3e041ded7a54d330bcc44f3b3 --signer devnet_giver_keys --type GiverV3
```

Check:

```
$ everdev n l
Network Endpoints Giver
------------ ----------------------------------------------- ------------------------------------------------------------------
se (Default) http://localhost 0:b5e9240fc2d2f1ff8cbb1d1dee7fb7cae155e5f6320e585fcc685698994a19a5
GiverV2
dev eri01.net.everos.dev, rbx01.net.everos.dev, gra01.net.everos.dev 0:93139197f2f58d674bee4ee71a42d8f1e7b6a3c3e041ded7a54d330bcc44f3b3
GiverV2 signed by devnet_giver_keys
main eri01.main.everos.dev, gra01.main.everos.dev, gra02.main.everos.dev ...
everdev n l
Network Endpoints Giver
------------ --------------------- ------------------------------------------------------------------
se (Default) http://localhost 0:ece57bcc6c530283becbbd8a3b24d3c5987cdddc3c8b7b33be6e4a6312490415
GiverV3 signed by seGiver
dev devnet.evercloud.dev 0:93139197f2f58d674bee4ee71a42d8f1e7b6a3c3e041ded7a54d330bcc44f3b3
GiverV3 signed by devnet_giver_keys
main mainnet.evercloud.dev
```

If Giver is set, you will see you Giver's address and keypair name for the `dev` network.
Expand All @@ -125,7 +128,7 @@ $ everdev contract topup --network dev --address <address> --value 10000
Configuration
Network: dev (eri01.net.everos.dev, rbx01.net.everos.dev, gra01.net.everos.dev)
Network: dev
Signer: test (public de101cde5c94540926fe862e965cf109b1b803989e7048657cf7c4caaa2a257d)
Address: <address>
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "everdev",
"version": "1.5.1",
"version": "1.6.0",
"description": "Everscale Dev Environment",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down Expand Up @@ -46,8 +46,8 @@
},
"dependencies": {
"@eversdk/appkit": "^0.3.4",
"@eversdk/core": "^1.39.0",
"@eversdk/lib-node": "^1.39.0",
"@eversdk/core": "^1.41.1",
"@eversdk/lib-node": "^1.41.1",
"chalk": "^2.4.2",
"dockerode": "^3.3.1",
"fs-extra": "^9.1.0",
Expand Down
Loading

0 comments on commit 4b8c8b0

Please sign in to comment.