1
// Copyright © 2017-2020 Trust Wallet.
2
//
3
// This file is part of Trust. The full Trust copyright notice, including
4
// terms governing use, modification, and redistribution, is contained in the
5
// file LICENSE at the root of the source code distribution tree.
6

7
#include "Contract.h"
8
#include "../Data.h"
9
#include "../HexCoding.h"
10

11
#include <cassert>
12

13
namespace TW::TON {
14

15
using namespace TW;
16

17
//static const char* walletContract1 = "FF0020DDA4F260810200D71820D70B1FED44D0D31FD3FFD15112BAF2A122F901541044F910F2A2F80001D31F3120D74A96D307D402FB00DED1A4C8CB1FCBFFC9ED54";
18
//static const char* walletContract2 = "FF0020DDA4F260810200D71820D70B1FED44D0D7091FD709FFD15112BAF2A122F901541044F910F2A2F80001D7091F3120D74A97D70907D402FB00DED1A4C8CB1FCBFFC9ED54";
19
// Obtained from ton-lite-client new-wallet.fif, len=81
20
static const char* walletContract3 = "FF0020DD2082014C97BA9730ED44D0D70B1FE0A4F260810200D71820D70B1FED44D0D31FD3FFD15112BAF2A122F901541044F910F2A2F80001D31F3120D74A96D307D402FB00DED1A4C8CB1FCBFFC9ED54";
21
// Obtained from released testnet desktop wallet, len=96
22
//static const char* walletContract4 = "FF0020DD2082014C97BA9730ED44D0D70B1FE0A4F2608308D71820D31FD31FD31FF82313BBF263ED44D0D31FD31FD3FFD15132BAF2A15144BAF2A204F901541055F910F2A3F8009320D74A96D307D402FB00E8D101A4C8CB1FCB1FCBFFC9ED54";
23 1
Data Contract::walletContractDefault() {
24 1
    return parse_hex(walletContract3);
25
}
26

27 1
Cell Contract::createStateInit(const PublicKey& pubkey) {
28
    // smart contract code -- constant
29 1
    auto ccode = std::make_shared<Cell>();
30 1
    ccode->setSliceBytes(walletContractDefault());
31

32
    // data: 4 byte serial num (0), 32 byte public key
33 1
    Data data;
34 1
    append(data, Data(4));
35 1
    append(data, pubkey.bytes);
36 1
    assert(data.size() == 4 + 32);
37 1
    auto cdata = std::make_shared<Cell>();
38 1
    cdata->setSliceBytes(data);
39

40 1
    Cell stateInit;
41 1
    stateInit.setSliceBitsStr("30", 5); // b{00110}
42 1
    stateInit.addCell(ccode);
43 1
    stateInit.addCell(cdata);
44

45 1
    return stateInit;
46
}
47

48
} // namespace TW::TON

Read our documentation on viewing source code .

Loading