UNPKG

dp-contract-proxy-kit

Version:

Enable batched transactions and contract account interactions using a unique deterministic Gnosis Safe.

51 lines 1.96 kB
var __rest = (this && this.__rest) || function (s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; }; import { defaultTxData, defaultTxOperation, defaultTxValue } from './constants'; import { toHex } from './hexData'; export var OperationType; (function (OperationType) { OperationType[OperationType["Call"] = 0] = "Call"; OperationType[OperationType["DelegateCall"] = 1] = "DelegateCall"; // 1 })(OperationType || (OperationType = {})); export class TransactionError extends Error { constructor(message, revertData, revertMessage) { super(message); this.revertData = revertData; this.revertMessage = revertMessage; } } export function standardizeTransaction(tx) { return { operation: tx.operation ? tx.operation : defaultTxOperation, to: tx.to, value: tx.value ? tx.value.toString() : defaultTxValue.toString(), data: tx.data ? tx.data : defaultTxData }; } export function normalizeGasLimit(options) { const { gas, gasLimit } = options, rest = __rest(options, ["gas", "gasLimit"]); if (gas != null && gasLimit != null) { throw new Error(`specified both gas and gasLimit on options: ${options}`); } return Object.assign(Object.assign({}, rest), { gas: gas || gasLimit }); } export function formatCallTx(tx) { const { from, to, value, data, gas } = normalizeGasLimit(tx); return { from, to, value: !value ? undefined : toHex(value), data, gas: !gas ? undefined : toHex(gas) }; } //# sourceMappingURL=transactions.js.map