From 2ff8002d0b785ffae34f84db89f293bdca809b25 Mon Sep 17 00:00:00 2001 From: Ilyar <761285+ilyar@users.noreply.github.com> Date: Thu, 3 Feb 2022 12:38:55 +0200 Subject: [PATCH 1/2] make project accman up-to-date and fix build execution --- accman/AccMan.sol | 24 ++++++++++++------------ accman/deploy_debot.sh | 4 ++-- accman/deployerDebot.sol | 14 +++++++------- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/accman/AccMan.sol b/accman/AccMan.sol index a9d5199..bd40452 100644 --- a/accman/AccMan.sol +++ b/accman/AccMan.sol @@ -87,7 +87,7 @@ contract AccMan is Debot, Upgradable { /// @notice Entry point function for DeBot. function start() public override { - + } /// @notice Returns Metadata about DeBot. @@ -158,6 +158,7 @@ contract AccMan is Debot, Upgradable { m_invokeType = Invoke.QueryAccounts; m_invoker = msg.sender; m_ownerKey = ownerKey; + // FIXME Sdk.substring(tvm.functionId(uint32 callbackFunctionId), bytes str, uint32 start, uint32 count); Sdk.getAccountsDataByHash( tvm.functionId(setInvites), tvm.hash(buildInviteCode(InviteType.Self, _calcRoot())), @@ -245,23 +246,23 @@ contract AccMan is Debot, Upgradable { /// @notice API function. function invokeRemoveInvites() public { - + } */ ///////////////////////////////////////////////////////////////////////////////////////////////// - + function createPrivInvite() public { // TODO: check that nonce is valid; m_deployFlags |= CREATE_INVITE; - TvmCell body = tvm.encodeBody(AccMan.deployInvite, m_ownerKey, + TvmCell body = tvm.encodeBody(AccMan.deployInvite, m_ownerKey, InviteType.Private, m_account, m_nonce, m_deployFlags); this.callMultisig(address(this), body, _calcFee(m_deployFlags, 1), tvm.functionId(completePrivInvite)); } function createPubInvite() public { m_deployFlags |= CREATE_INVITE; - TvmCell body = tvm.encodeBody(AccMan.deployInvite, m_ownerKey, + TvmCell body = tvm.encodeBody(AccMan.deployInvite, m_ownerKey, InviteType.Public, m_account, "", m_deployFlags); this.callMultisig(address(this), body, _calcFee(m_deployFlags, 1), tvm.functionId(completePubInvite)); } @@ -368,8 +369,8 @@ contract AccMan is Debot, Upgradable { } totalFee += _calcFee(m_deployFlags, ownerCount); TvmCell body = tvm.encodeBody( - AccMan.deployAccount, m_ownerKey, m_ownerKeys, m_currentSeqno, - m_accountImage.toSlice().loadRef(), signature, m_args, + AccMan.deployAccount, m_ownerKey, m_ownerKeys, m_currentSeqno, + m_accountImage.toSlice().loadRef(), signature, m_args, m_deployFlags ); this.callMultisig(address(this), body, totalFee, tvm.functionId(checkAccount)); @@ -423,7 +424,6 @@ contract AccMan is Debot, Upgradable { // TODO: allow transfer only from multisig with 1 custodian. IMultisig(m_wallet).sendTransaction{ abiVer: 2, - extMsg: true, sign: true, pubkey: pubkey, time: 0, @@ -431,7 +431,7 @@ contract AccMan is Debot, Upgradable { signBoxHandle: sbhandle, callbackId: tvm.functionId(onSuccess), onErrorId: tvm.functionId(onError) - }(m_callArgs.dest, m_callArgs.value, true, 3, m_callArgs.payload); + }(m_callArgs.dest, m_callArgs.value, true, 3, m_callArgs.payload).extMsg; delete m_callArgs; } @@ -620,7 +620,7 @@ contract AccMan is Debot, Upgradable { if (flags & CREATE_ROOT != 0) { deployInviteRoot(ownerKey); } - + TvmCell rootImage = tvm.insertPubkey(m_inviteRootImage, ownerKey); address root = address(tvm.hash(rootImage)); if (invType == InviteType.Public) { @@ -655,7 +655,7 @@ contract AccMan is Debot, Upgradable { // function onCodeUpgrade() internal override { - + } -} \ No newline at end of file +} diff --git a/accman/deploy_debot.sh b/accman/deploy_debot.sh index 767fa46..ed71285 100755 --- a/accman/deploy_debot.sh +++ b/accman/deploy_debot.sh @@ -1,5 +1,5 @@ +#!/usr/bin/env bash -#!/bin/bash set -e tos=tonos-cli @@ -77,4 +77,4 @@ echo client $DEBOT_ADDRESS echo debot $ACCMAN_ADDRESS echo msig $MSIG_ADDRESS -$tos --url $NETWORK debot fetch $DEBOT_ADDRESS \ No newline at end of file +$tos --url $NETWORK debot fetch $DEBOT_ADDRESS diff --git a/accman/deployerDebot.sol b/accman/deployerDebot.sol index ee6c402..a8dd8dc 100644 --- a/accman/deployerDebot.sol +++ b/accman/deployerDebot.sol @@ -41,7 +41,7 @@ contract DeployerDebot is Debot, IAccManCallbacks, IonQueryAccounts { MenuItem("Deploy new account", "", tvm.functionId(menuDeployAccount)), MenuItem("Show all your accounts", "", tvm.functionId(menuViewAccounts)) ]); - + } function menuViewAccounts(uint32 index) public { @@ -164,13 +164,13 @@ contract DeployerDebot is Debot, IAccManCallbacks, IonQueryAccounts { // function _parseKey(string value) private returns (bool) { - (uint256 key, bool res) = stoi("0x" + value); - if (!res) { + optional(int) res = stoi("0x" + value); + if (!res.hasValue()) { Terminal.print(tvm.functionId(Debot.start), "Invalid public key."); - return res; + return false; } - m_ownerKey = key; - return res; + m_ownerKey = uint256(res.get()); + return true; } -} \ No newline at end of file +} From fe836c2c28514d62c7912f0ccd8878b945480d8f Mon Sep 17 00:00:00 2001 From: Ilyar <761285+ilyar@users.noreply.github.com> Date: Thu, 3 Feb 2022 13:33:05 +0200 Subject: [PATCH 2/2] make abi size smaller --- accman/deploy_debot.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/accman/deploy_debot.sh b/accman/deploy_debot.sh index ed71285..04b15bb 100755 --- a/accman/deploy_debot.sh +++ b/accman/deploy_debot.sh @@ -24,7 +24,7 @@ echo GIVER $1 ------------------------------------------------ giver $DEBOT_ADDRESS echo DEPLOY $1 ----------------------------------------------- $tos --url $NETWORK deploy $1.tvc "{}" --sign $1.keys.json --abi $1.abi.json -DEBOT_ABI=$(cat $1.abi.json | xxd -ps -c 20000) +DEBOT_ABI=$(cat $1.abi.json | jq --compact-output | xxd -ps -c 20000) $tos --url $NETWORK call $DEBOT_ADDRESS setABI "{\"dabi\":\"$DEBOT_ABI\"}" --sign $1.keys.json --abi $1.abi.json echo -n $DEBOT_ADDRESS > $1.addr }