@parity/api
Version:
The Parity Promise-based API library for interfacing with Ethereum over RPC
63 lines (62 loc) • 2.94 kB
JavaScript
;
// Copyright 2015-2019 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Parity is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
var _a = require('../../format/input'), inBlockNumber = _a.inBlockNumber, inData = _a.inData, inHex = _a.inHex, inNumber16 = _a.inNumber16, inOptions = _a.inOptions, inTraceFilter = _a.inTraceFilter, inTraceType = _a.inTraceType;
var _b = require('../../format/output'), outTraces = _b.outTraces, outTraceReplay = _b.outTraceReplay;
var Trace = /** @class */ (function () {
function Trace(provider) {
this._provider = provider;
}
Trace.prototype.block = function (blockNumber) {
if (blockNumber === void 0) { blockNumber = 'latest'; }
return this._provider
.send('trace_block', inBlockNumber(blockNumber))
.then(outTraces);
};
Trace.prototype.call = function (options, whatTrace, blockNumber) {
if (whatTrace === void 0) { whatTrace = ['trace']; }
if (blockNumber === void 0) { blockNumber = 'latest'; }
return this._provider
.send('trace_call', inOptions(options), inTraceType(whatTrace), inBlockNumber(blockNumber))
.then(outTraceReplay);
};
Trace.prototype.filter = function (filterObj) {
return this._provider
.send('trace_filter', inTraceFilter(filterObj))
.then(outTraces);
};
Trace.prototype.get = function (txHash, position) {
return this._provider
.send('trace_get', inHex(txHash), inNumber16(position))
.then(outTraces);
};
Trace.prototype.rawTransaction = function (data, whatTrace) {
if (whatTrace === void 0) { whatTrace = ['trace']; }
return this._provider
.send('trace_rawTransaction', inData(data), inTraceType(whatTrace))
.then(outTraceReplay);
};
Trace.prototype.replayTransaction = function (txHash, whatTrace) {
if (whatTrace === void 0) { whatTrace = ['trace']; }
return this._provider
.send('trace_replayTransaction', txHash, inTraceType(whatTrace))
.then(outTraceReplay);
};
Trace.prototype.transaction = function (txHash) {
return this._provider
.send('trace_transaction', inHex(txHash))
.then(outTraces);
};
return Trace;
}());
module.exports = Trace;