jton-contracts
Version:
Free TON contracts wrapped in jTON
101 lines (100 loc) • 3.52 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.SetcodeMultisigWalletCall = exports.PARAMETERS = void 0;
const jton_1 = require("jton");
const __1 = require("../");
var PARAMETERS;
(function (PARAMETERS) {
PARAMETERS["DEST"] = "dest";
PARAMETERS["VALUE"] = "value";
PARAMETERS["BOUNCE"] = "bounce";
PARAMETERS["FLAGS"] = "flags";
PARAMETERS["PATH_TO_ABI"] = "pathToAbiFile";
PARAMETERS["METHOD"] = "method";
PARAMETERS["PARAMETERS"] = "parameters";
})(PARAMETERS = exports.PARAMETERS || (exports.PARAMETERS = {}));
class SetcodeMultisigWalletCall extends jton_1.Call {
/**
* @param config
* Example:
* {
* net: {
* url: 'http://localhost',
* timeout: 30_000
* },
* locale: 'EN',
* keys: `${__dirname}/../library/keys/GiverV2.se.keys.json`
* }
*/
constructor(config) {
super(config, Object.values(PARAMETERS));
}
/**
* Creates and returns contract.
* @param keys
* Example:
* {
* public: '0x0000111122223333444455556666777788889999aaaabbbbccccddddeeeeffff',
* secret: '0x0000000011111111222222223333333344444444555555556666666677777777'
* }
* @param timeout Time in milliseconds. How much time need wait a collection from graphql.
* Examples:
* 3000
* 5000
*/
_getContract(keys, timeout) {
return new __1.SetcodeMultisigWallet(this._client, keys, timeout);
}
/**
* Create and return target contract object.
* @param map
* Example:
* {
* address: '0:0000111122223333444455556666777788889999aaaabbbbccccddddeeeeffff'
* }
* @param timeout Time in milliseconds. How much time need wait a collection from graphql.
* Examples:
* 3000
* 5000
*/
_getTargetContract(map, timeout) {
return new jton_1.Contract(this._client, {
abi: {},
address: map[PARAMETERS.DEST]
}, timeout);
}
/**
* Call the public method with an external message.
* @param contract A contract on which we call the public method with an external message.
* @param keys
* Example:
* {
* public: '0x0000111122223333444455556666777788889999aaaabbbbccccddddeeeeffff',
* secret: '0x0000000011111111222222223333333344444444555555556666666677777777'
* }
* @param map
* Example:
* {
* address: '0:0000111122223333444455556666777788889999aaaabbbbccccddddeeeeffff ',
* value: '1_000_000_000',
* bounce: 'false'
* }
*/
async _call(contract, map, keys) {
const dest = map[PARAMETERS.DEST];
const value = (0, jton_1.readInt)(map[PARAMETERS.VALUE]);
const bounce = (0, jton_1.readBoolean)(map[PARAMETERS.BOUNCE]);
const flags = (0, jton_1.readInt)(map[PARAMETERS.FLAGS]);
const abi = (0, jton_1.readAbi)(map[PARAMETERS.PATH_TO_ABI]);
const method = map[PARAMETERS.METHOD];
const input = (0, jton_1.readJson)(map[PARAMETERS.PARAMETERS]);
await contract.sendTransaction({
dest,
value,
bounce,
flags,
payload: await (0, jton_1.getPayload)(this._client, abi, method, input)
}, keys);
}
}
exports.SetcodeMultisigWalletCall = SetcodeMultisigWalletCall;