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 "Ont.h"
8
#include "Data.h"
9
#include "ParamsBuilder.h"
10

11
#include <unordered_map>
12

13
using namespace TW;
14
using namespace TW::Ontology;
15

16 1
Transaction Ont::decimals(uint32_t nonce) {
17 1
    auto builder = ParamsBuilder();
18
    auto invokeCode =
19 1
        ParamsBuilder::buildNativeInvokeCode(contractAddress(), version, "decimals", Data());
20 1
    auto tx = Transaction((uint8_t)0, txType, nonce, (uint64_t)0, (uint64_t)0, (std::string) "",
21 1
                          invokeCode);
22 1
    return tx;
23
}
24

25 1
Transaction Ont::balanceOf(const Address &address, uint32_t nonce) {
26 1
    auto builder = ParamsBuilder();
27
    auto invokeCode =
28 1
        ParamsBuilder::buildNativeInvokeCode(contractAddress(), version, "balanceOf", address.data);
29 1
    auto tx = Transaction((uint8_t)0, txType, nonce, (uint64_t)0, (uint64_t)0,
30 1
                          (std::string) "", invokeCode);
31 1
    return tx;
32
}
33

34 1
Transaction Ont::transfer(const Signer &from, const Address &to, uint64_t amount,
35
                          const Signer &payer, uint64_t gasPrice, uint64_t gasLimit,
36
                          uint32_t nonce) {
37 1
    std::list<boost::any> transferParam{from.getAddress().data, to.data, amount};
38 1
    std::vector<boost::any> args{transferParam};
39
    auto invokeCode =
40 1
        ParamsBuilder::buildNativeInvokeCode(contractAddress(), 0x00, "transfer", args);
41 1
    auto tx = Transaction(version, txType, nonce, gasPrice, gasLimit,
42 1
                          payer.getAddress().string(), invokeCode);
43 1
    from.sign(tx);
44 1
    payer.addSign(tx);
45 1
    return tx;
46
}

Read our documentation on viewing source code .

Loading