@0xsplits/splits-sdk
Version:
SDK for the 0xSplits protocol
724 lines • 37.5 kB
JavaScript
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (g && (g = 0, op[0] && (_ = 0)), _) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.WaterfallClient = void 0;
var viem_1 = require("viem");
var base_1 = require("./base");
var constants_1 = require("../constants");
var waterfallFactory_1 = require("../constants/abi/waterfallFactory");
var waterfall_1 = require("../constants/abi/waterfall");
var errors_1 = require("../errors");
var mixin_1 = require("./mixin");
var utils_1 = require("../utils");
var validation_1 = require("../utils/validation");
var WaterfallTransactions = /** @class */ (function (_super) {
__extends(WaterfallTransactions, _super);
function WaterfallTransactions(transactionClientArgs) {
return _super.call(this, __assign({ supportedChainIds: constants_1.WATERFALL_CHAIN_IDS }, transactionClientArgs)) || this;
}
WaterfallTransactions.prototype._createWaterfallModuleTransaction = function (_a) {
return __awaiter(this, arguments, void 0, function (_b) {
var functionChainId, publicClient, formattedToken, formattedNonWaterfallRecipient, _c, recipients, trancheSizes, result;
var token = _b.token, tranches = _b.tranches, _d = _b.nonWaterfallRecipient, nonWaterfallRecipient = _d === void 0 ? viem_1.zeroAddress : _d, chainId = _b.chainId, _e = _b.transactionOverrides, transactionOverrides = _e === void 0 ? {} : _e;
return __generator(this, function (_f) {
switch (_f.label) {
case 0:
(0, validation_1.validateAddress)(token);
(0, validation_1.validateAddress)(nonWaterfallRecipient);
(0, validation_1.validateWaterfallTranches)(tranches);
if (this._shouldRequireWalletClient)
this._requireWalletClient();
functionChainId = this._getFunctionChainId(chainId);
publicClient = this._getPublicClient(functionChainId);
formattedToken = (0, viem_1.getAddress)(token);
formattedNonWaterfallRecipient = (0, viem_1.getAddress)(nonWaterfallRecipient);
return [4 /*yield*/, (0, utils_1.getTrancheRecipientsAndSizes)(functionChainId, formattedToken, tranches, publicClient)];
case 1:
_c = __read.apply(void 0, [_f.sent(), 2]), recipients = _c[0], trancheSizes = _c[1];
return [4 /*yield*/, this._executeContractFunction({
contractAddress: (0, constants_1.getWaterfallFactoryAddress)(functionChainId),
contractAbi: waterfallFactory_1.waterfallFactoryAbi,
functionName: 'createWaterfallModule',
functionArgs: [
formattedToken,
formattedNonWaterfallRecipient,
recipients,
trancheSizes,
],
transactionOverrides: transactionOverrides,
})];
case 2:
result = _f.sent();
return [2 /*return*/, result];
}
});
});
};
WaterfallTransactions.prototype._waterfallFundsTransaction = function (_a) {
return __awaiter(this, arguments, void 0, function (_b) {
var result;
var waterfallModuleAddress = _b.waterfallModuleAddress, _c = _b.usePull, usePull = _c === void 0 ? false : _c, _d = _b.transactionOverrides, transactionOverrides = _d === void 0 ? {} : _d;
return __generator(this, function (_e) {
switch (_e.label) {
case 0:
(0, validation_1.validateAddress)(waterfallModuleAddress);
if (this._shouldRequireWalletClient)
this._requireWalletClient();
return [4 /*yield*/, this._executeContractFunction({
contractAddress: (0, viem_1.getAddress)(waterfallModuleAddress),
contractAbi: waterfall_1.waterfallAbi,
functionName: usePull ? 'waterfallFundsPull' : 'waterfallFunds',
transactionOverrides: transactionOverrides,
})];
case 1:
result = _e.sent();
return [2 /*return*/, result];
}
});
});
};
WaterfallTransactions.prototype._recoverNonWaterfallFundsTransaction = function (_a) {
return __awaiter(this, arguments, void 0, function (_b) {
var functionChainId, result;
var waterfallModuleAddress = _b.waterfallModuleAddress, token = _b.token, _c = _b.recipient, recipient = _c === void 0 ? viem_1.zeroAddress : _c, chainId = _b.chainId, _d = _b.transactionOverrides, transactionOverrides = _d === void 0 ? {} : _d;
return __generator(this, function (_e) {
switch (_e.label) {
case 0:
(0, validation_1.validateAddress)(waterfallModuleAddress);
(0, validation_1.validateAddress)(token);
(0, validation_1.validateAddress)(recipient);
this._requireWalletClient();
functionChainId = this._getFunctionChainId(chainId);
return [4 /*yield*/, this._validateRecoverTokensWaterfallData({
waterfallModuleAddress: waterfallModuleAddress,
token: token,
recipient: recipient,
chainId: functionChainId,
})];
case 1:
_e.sent();
return [4 /*yield*/, this._executeContractFunction({
contractAddress: (0, viem_1.getAddress)(waterfallModuleAddress),
contractAbi: waterfall_1.waterfallAbi,
functionName: 'recoverNonWaterfallFunds',
functionArgs: [token, recipient],
transactionOverrides: transactionOverrides,
})];
case 2:
result = _e.sent();
return [2 /*return*/, result];
}
});
});
};
WaterfallTransactions.prototype._withdrawPullFundsTransaction = function (_a) {
return __awaiter(this, arguments, void 0, function (_b) {
var result;
var waterfallModuleAddress = _b.waterfallModuleAddress, address = _b.address, _c = _b.transactionOverrides, transactionOverrides = _c === void 0 ? {} : _c;
return __generator(this, function (_d) {
switch (_d.label) {
case 0:
(0, validation_1.validateAddress)(waterfallModuleAddress);
(0, validation_1.validateAddress)(address);
this._requireWalletClient();
return [4 /*yield*/, this._executeContractFunction({
contractAddress: (0, viem_1.getAddress)(waterfallModuleAddress),
contractAbi: waterfall_1.waterfallAbi,
functionName: 'withdraw',
functionArgs: [address],
transactionOverrides: transactionOverrides,
})];
case 1:
result = _d.sent();
return [2 /*return*/, result];
}
});
});
};
WaterfallTransactions.prototype._validateRecoverTokensWaterfallData = function (_a) {
return __awaiter(this, arguments, void 0, function (_b) {
var waterfallMetadata, foundRecipient;
var waterfallModuleAddress = _b.waterfallModuleAddress, token = _b.token, recipient = _b.recipient, chainId = _b.chainId;
return __generator(this, function (_c) {
switch (_c.label) {
case 0:
this._requireDataClient();
return [4 /*yield*/, this._dataClient.getWaterfallMetadata({
chainId: chainId,
waterfallModuleAddress: waterfallModuleAddress,
})];
case 1:
waterfallMetadata = _c.sent();
if (token.toLowerCase() === waterfallMetadata.token.address.toLowerCase())
throw new errors_1.InvalidArgumentError("You must call recover tokens with a token other than the given waterfall's primary token. Primary token: ".concat(waterfallMetadata.token.address, ", given token: ").concat(token));
if (waterfallMetadata.nonWaterfallRecipient &&
waterfallMetadata.nonWaterfallRecipient.address !== viem_1.zeroAddress) {
if (recipient.toLowerCase() !==
waterfallMetadata.nonWaterfallRecipient.address.toLowerCase())
throw new errors_1.InvalidArgumentError("The passed in recipient (".concat(recipient, ") must match the non waterfall recipient for this module: ").concat(waterfallMetadata.nonWaterfallRecipient));
}
else {
foundRecipient = waterfallMetadata.tranches.reduce(function (acc, tranche) {
if (acc)
return acc;
return (tranche.recipient.address.toLowerCase() === recipient.toLowerCase());
}, false);
if (!foundRecipient)
throw new errors_1.InvalidArgumentError("You must pass in a valid recipient address for the given waterfall. Address ".concat(recipient, " not found in any tranche for waterfall ").concat(waterfallModuleAddress, "."));
}
return [2 /*return*/];
}
});
});
};
WaterfallTransactions.prototype._getWaterfallContract = function (waterfallModule, chainId) {
var publicClient = this._getPublicClient(chainId);
return (0, viem_1.getContract)({
address: (0, viem_1.getAddress)(waterfallModule),
abi: waterfall_1.waterfallAbi,
client: publicClient,
});
};
return WaterfallTransactions;
}(base_1.BaseTransactions));
// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
var WaterfallClient = /** @class */ (function (_super) {
__extends(WaterfallClient, _super);
function WaterfallClient(clientArgs) {
var _this = _super.call(this, __assign({ transactionType: constants_1.TransactionType.Transaction }, clientArgs)) || this;
_this.eventTopics = {
createWaterfallModule: [
(0, viem_1.encodeEventTopics)({
abi: waterfallFactory_1.waterfallFactoryAbi,
eventName: 'CreateWaterfallModule',
})[0],
],
waterfallFunds: [
(0, viem_1.encodeEventTopics)({
abi: waterfall_1.waterfallAbi,
eventName: 'WaterfallFunds',
})[0],
],
recoverNonWaterfallFunds: [
(0, viem_1.encodeEventTopics)({
abi: waterfall_1.waterfallAbi,
eventName: 'RecoverNonWaterfallFunds',
})[0],
],
withdrawPullFunds: [
(0, viem_1.encodeEventTopics)({
abi: waterfall_1.waterfallAbi,
eventName: 'Withdrawal',
})[0],
],
};
_this.callData = new WaterfallCallData(clientArgs);
_this.estimateGas = new WaterfallGasEstimates(clientArgs);
return _this;
}
// Write actions
WaterfallClient.prototype._submitCreateWaterfallModuleTransaction = function (createWaterfallArgs) {
return __awaiter(this, void 0, void 0, function () {
var txHash;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this._createWaterfallModuleTransaction(createWaterfallArgs)];
case 1:
txHash = _a.sent();
if (!this._isContractTransaction(txHash))
throw new Error('Invalid response');
return [2 /*return*/, { txHash: txHash }];
}
});
});
};
WaterfallClient.prototype.createWaterfallModule = function (createWaterfallArgs) {
return __awaiter(this, void 0, void 0, function () {
var txHash, events, event, log;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this._submitCreateWaterfallModuleTransaction(createWaterfallArgs)];
case 1:
txHash = (_a.sent()).txHash;
return [4 /*yield*/, this.getTransactionEvents({
txHash: txHash,
eventTopics: this.eventTopics.createWaterfallModule,
})];
case 2:
events = _a.sent();
event = events.length > 0 ? events[0] : undefined;
if (event) {
log = (0, viem_1.decodeEventLog)({
abi: waterfallFactory_1.waterfallFactoryAbi,
data: event.data,
topics: event.topics,
});
return [2 /*return*/, {
waterfallModuleAddress: log.args.waterfallModule,
event: event,
}];
}
throw new errors_1.TransactionFailedError();
}
});
});
};
WaterfallClient.prototype._submitWaterfallFundsTransaction = function (waterfallFundsArgs) {
return __awaiter(this, void 0, void 0, function () {
var txHash;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this._waterfallFundsTransaction(waterfallFundsArgs)];
case 1:
txHash = _a.sent();
if (!this._isContractTransaction(txHash))
throw new Error('Invalid response');
return [2 /*return*/, { txHash: txHash }];
}
});
});
};
WaterfallClient.prototype.waterfallFunds = function (waterfallFundsArgs) {
return __awaiter(this, void 0, void 0, function () {
var txHash, events, event;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this._submitWaterfallFundsTransaction(waterfallFundsArgs)];
case 1:
txHash = (_a.sent()).txHash;
return [4 /*yield*/, this.getTransactionEvents({
txHash: txHash,
eventTopics: this.eventTopics.waterfallFunds,
})];
case 2:
events = _a.sent();
event = events.length > 0 ? events[0] : undefined;
if (event)
return [2 /*return*/, {
event: event,
}];
throw new errors_1.TransactionFailedError();
}
});
});
};
WaterfallClient.prototype._submitRecoverNonWaterfallFundsTransaction = function (recoverFundsArgs) {
return __awaiter(this, void 0, void 0, function () {
var txHash;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this._recoverNonWaterfallFundsTransaction(recoverFundsArgs)];
case 1:
txHash = _a.sent();
if (!this._isContractTransaction(txHash))
throw new Error('Invalid response');
return [2 /*return*/, { txHash: txHash }];
}
});
});
};
WaterfallClient.prototype.recoverNonWaterfallFunds = function (recoverFundsArgs) {
return __awaiter(this, void 0, void 0, function () {
var txHash, events, event;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this._submitRecoverNonWaterfallFundsTransaction(recoverFundsArgs)];
case 1:
txHash = (_a.sent()).txHash;
return [4 /*yield*/, this.getTransactionEvents({
txHash: txHash,
eventTopics: this.eventTopics.recoverNonWaterfallFunds,
})];
case 2:
events = _a.sent();
event = events.length > 0 ? events[0] : undefined;
if (event)
return [2 /*return*/, {
event: event,
}];
throw new errors_1.TransactionFailedError();
}
});
});
};
WaterfallClient.prototype._submitWithdrawPullFundsTransaction = function (withdrawFundsArgs) {
return __awaiter(this, void 0, void 0, function () {
var txHash;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this._withdrawPullFundsTransaction(withdrawFundsArgs)];
case 1:
txHash = _a.sent();
if (!this._isContractTransaction(txHash))
throw new Error('Invalid response');
return [2 /*return*/, { txHash: txHash }];
}
});
});
};
WaterfallClient.prototype.withdrawPullFunds = function (withdrawFundsArgs) {
return __awaiter(this, void 0, void 0, function () {
var txHash, events, event;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this._submitWithdrawPullFundsTransaction(withdrawFundsArgs)];
case 1:
txHash = (_a.sent()).txHash;
return [4 /*yield*/, this.getTransactionEvents({
txHash: txHash,
eventTopics: this.eventTopics.withdrawPullFunds,
})];
case 2:
events = _a.sent();
event = events.length > 0 ? events[0] : undefined;
if (event)
return [2 /*return*/, {
event: event,
}];
throw new errors_1.TransactionFailedError();
}
});
});
};
// Read actions
WaterfallClient.prototype.getDistributedFunds = function (_a) {
return __awaiter(this, arguments, void 0, function (_b) {
var functionChainId, contract, distributedFunds;
var waterfallModuleAddress = _b.waterfallModuleAddress, chainId = _b.chainId;
return __generator(this, function (_c) {
switch (_c.label) {
case 0:
(0, validation_1.validateAddress)(waterfallModuleAddress);
functionChainId = this._getReadOnlyFunctionChainId(chainId);
contract = this._getWaterfallContract(waterfallModuleAddress, functionChainId);
return [4 /*yield*/, contract.read.distributedFunds()];
case 1:
distributedFunds = _c.sent();
return [2 /*return*/, {
distributedFunds: distributedFunds,
}];
}
});
});
};
WaterfallClient.prototype.getFundsPendingWithdrawal = function (_a) {
return __awaiter(this, arguments, void 0, function (_b) {
var functionChainId, waterfallContract, fundsPendingWithdrawal;
var waterfallModuleAddress = _b.waterfallModuleAddress, chainId = _b.chainId;
return __generator(this, function (_c) {
switch (_c.label) {
case 0:
(0, validation_1.validateAddress)(waterfallModuleAddress);
functionChainId = this._getReadOnlyFunctionChainId(chainId);
waterfallContract = this._getWaterfallContract(waterfallModuleAddress, functionChainId);
return [4 /*yield*/, waterfallContract.read.fundsPendingWithdrawal()];
case 1:
fundsPendingWithdrawal = _c.sent();
return [2 /*return*/, {
fundsPendingWithdrawal: fundsPendingWithdrawal,
}];
}
});
});
};
WaterfallClient.prototype.getTranches = function (_a) {
return __awaiter(this, arguments, void 0, function (_b) {
var functionChainId, waterfallContract, _c, recipients, thresholds;
var waterfallModuleAddress = _b.waterfallModuleAddress, chainId = _b.chainId;
return __generator(this, function (_d) {
switch (_d.label) {
case 0:
(0, validation_1.validateAddress)(waterfallModuleAddress);
functionChainId = this._getReadOnlyFunctionChainId(chainId);
waterfallContract = this._getWaterfallContract(waterfallModuleAddress, functionChainId);
return [4 /*yield*/, waterfallContract.read.getTranches()];
case 1:
_c = __read.apply(void 0, [_d.sent(), 2]), recipients = _c[0], thresholds = _c[1];
return [2 /*return*/, {
recipients: recipients.slice(),
thresholds: thresholds.slice(),
}];
}
});
});
};
WaterfallClient.prototype.getNonWaterfallRecipient = function (_a) {
return __awaiter(this, arguments, void 0, function (_b) {
var functionChainId, waterfallContract, nonWaterfallRecipient;
var waterfallModuleAddress = _b.waterfallModuleAddress, chainId = _b.chainId;
return __generator(this, function (_c) {
switch (_c.label) {
case 0:
(0, validation_1.validateAddress)(waterfallModuleAddress);
functionChainId = this._getReadOnlyFunctionChainId(chainId);
waterfallContract = this._getWaterfallContract(waterfallModuleAddress, functionChainId);
return [4 /*yield*/, waterfallContract.read.nonWaterfallRecipient()];
case 1:
nonWaterfallRecipient = _c.sent();
return [2 /*return*/, {
nonWaterfallRecipient: nonWaterfallRecipient,
}];
}
});
});
};
WaterfallClient.prototype.getToken = function (_a) {
return __awaiter(this, arguments, void 0, function (_b) {
var functionChainId, waterfallContract, token;
var waterfallModuleAddress = _b.waterfallModuleAddress, chainId = _b.chainId;
return __generator(this, function (_c) {
switch (_c.label) {
case 0:
(0, validation_1.validateAddress)(waterfallModuleAddress);
functionChainId = this._getReadOnlyFunctionChainId(chainId);
waterfallContract = this._getWaterfallContract(waterfallModuleAddress, functionChainId);
return [4 /*yield*/, waterfallContract.read.token()];
case 1:
token = _c.sent();
return [2 /*return*/, {
token: token,
}];
}
});
});
};
WaterfallClient.prototype.getPullBalance = function (_a) {
return __awaiter(this, arguments, void 0, function (_b) {
var functionChainId, waterfallContract, pullBalance;
var waterfallModuleAddress = _b.waterfallModuleAddress, address = _b.address, chainId = _b.chainId;
return __generator(this, function (_c) {
switch (_c.label) {
case 0:
(0, validation_1.validateAddress)(waterfallModuleAddress);
functionChainId = this._getReadOnlyFunctionChainId(chainId);
waterfallContract = this._getWaterfallContract(waterfallModuleAddress, functionChainId);
return [4 /*yield*/, waterfallContract.read.getPullBalance([
(0, viem_1.getAddress)(address),
])];
case 1:
pullBalance = _c.sent();
return [2 /*return*/, {
pullBalance: pullBalance,
}];
}
});
});
};
return WaterfallClient;
}(WaterfallTransactions));
exports.WaterfallClient = WaterfallClient;
(0, mixin_1.applyMixins)(WaterfallClient, [base_1.BaseClientMixin]);
// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
var WaterfallGasEstimates = /** @class */ (function (_super) {
__extends(WaterfallGasEstimates, _super);
function WaterfallGasEstimates(clientArgs) {
return _super.call(this, __assign({ transactionType: constants_1.TransactionType.GasEstimate }, clientArgs)) || this;
}
WaterfallGasEstimates.prototype.createWaterfallModule = function (createWaterfallArgs) {
return __awaiter(this, void 0, void 0, function () {
var gasEstimate;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this._createWaterfallModuleTransaction(createWaterfallArgs)];
case 1:
gasEstimate = _a.sent();
if (!this._isBigInt(gasEstimate))
throw new Error('Invalid response');
return [2 /*return*/, gasEstimate];
}
});
});
};
WaterfallGasEstimates.prototype.waterfallFunds = function (waterfallFundsArgs) {
return __awaiter(this, void 0, void 0, function () {
var gasEstimate;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this._waterfallFundsTransaction(waterfallFundsArgs)];
case 1:
gasEstimate = _a.sent();
if (!this._isBigInt(gasEstimate))
throw new Error('Invalid response');
return [2 /*return*/, gasEstimate];
}
});
});
};
WaterfallGasEstimates.prototype.recoverNonWaterfallFunds = function (recoverFundsArgs) {
return __awaiter(this, void 0, void 0, function () {
var gasEstimate;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this._recoverNonWaterfallFundsTransaction(recoverFundsArgs)];
case 1:
gasEstimate = _a.sent();
if (!this._isBigInt(gasEstimate))
throw new Error('Invalid response');
return [2 /*return*/, gasEstimate];
}
});
});
};
WaterfallGasEstimates.prototype.withdrawPullFunds = function (withdrawArgs) {
return __awaiter(this, void 0, void 0, function () {
var gasEstimate;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this._withdrawPullFundsTransaction(withdrawArgs)];
case 1:
gasEstimate = _a.sent();
if (!this._isBigInt(gasEstimate))
throw new Error('Invalid response');
return [2 /*return*/, gasEstimate];
}
});
});
};
return WaterfallGasEstimates;
}(WaterfallTransactions));
(0, mixin_1.applyMixins)(WaterfallGasEstimates, [base_1.BaseGasEstimatesMixin]);
var WaterfallCallData = /** @class */ (function (_super) {
__extends(WaterfallCallData, _super);
function WaterfallCallData(clientArgs) {
return _super.call(this, __assign({ transactionType: constants_1.TransactionType.CallData }, clientArgs)) || this;
}
WaterfallCallData.prototype.createWaterfallModule = function (args) {
return __awaiter(this, void 0, void 0, function () {
var callData;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this._createWaterfallModuleTransaction(args)];
case 1:
callData = _a.sent();
if (!this._isCallData(callData))
throw new Error('Invalid response');
return [2 /*return*/, callData];
}
});
});
};
WaterfallCallData.prototype.waterfallFunds = function (args) {
return __awaiter(this, void 0, void 0, function () {
var callData;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this._waterfallFundsTransaction(args)];
case 1:
callData = _a.sent();
if (!this._isCallData(callData))
throw new Error('Invalid response');
return [2 /*return*/, callData];
}
});
});
};
WaterfallCallData.prototype.recoverNonWaterfallFunds = function (args) {
return __awaiter(this, void 0, void 0, function () {
var callData;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this._recoverNonWaterfallFundsTransaction(args)];
case 1:
callData = _a.sent();
if (!this._isCallData(callData))
throw new Error('Invalid response');
return [2 /*return*/, callData];
}
});
});
};
WaterfallCallData.prototype.withdrawPullFunds = function (args) {
return __awaiter(this, void 0, void 0, function () {
var callData;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this._withdrawPullFundsTransaction(args)];
case 1:
callData = _a.sent();
if (!this._isCallData(callData))
throw new Error('Invalid response');
return [2 /*return*/, callData];
}
});
});
};
return WaterfallCallData;
}(WaterfallTransactions));
//# sourceMappingURL=waterfall.js.map