@hashgraph/sdk
Version:
108 lines (99 loc) • 4.5 kB
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _PendingAirdropId = _interopRequireDefault(require("../token/PendingAirdropId.cjs"));
var _Transaction = _interopRequireWildcard(require("../transaction/Transaction.cjs"));
var _AirdropPendingTransaction = _interopRequireDefault(require("./AirdropPendingTransaction.cjs"));
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
// SPDX-License-Identifier: Apache-2.0
/**
* @typedef {import("@hashgraph/proto").proto.ITransaction} HieroProto.proto.ITransaction
* @typedef {import("@hashgraph/proto").proto.ITransactionResponse} HieroProto.proto.ITransactionResponse
* @typedef {import("@hashgraph/proto").proto.TransactionBody} HieroProto.proto.TransactionBody
* @typedef {import("@hashgraph/proto").proto.ISignedTransaction} HieroProto.proto.ISignedTransaction
* @typedef {import("@hashgraph/proto").proto.ITransactionBody} HieroProto.proto.ITransactionBody
* @typedef {import("@hashgraph/proto").proto.ITokenCancelAirdropTransactionBody} HieroProto.proto.ITokenCancelAirdropTransactionBody
*/
/**
* @typedef {import("../channel/Channel.js").default} Channel
* @typedef {import("../transaction/TransactionId.js").default} TransactionId
* @typedef {import("../account/AccountId.js").default} AccountId
*/
/**
* A transaction that allows the cancellation of pending airdrops.
* This transaction can be used by authorized accounts to cancel airdrop operations
* that have been initiated but not yet claimed by recipients.
*/
class TokenCancelAirdropTransaction extends _AirdropPendingTransaction.default {
/**
* @param {object} props
* @param {PendingAirdropId[]} [props.pendingAirdropIds]
*/
constructor(props = {}) {
super(props);
}
/**
* @override
* @internal
* @returns {HieroProto.proto.ITokenCancelAirdropTransactionBody}
*/
_makeTransactionData() {
return {
pendingAirdrops: this.pendingAirdropIds.map(pendingAirdropId => pendingAirdropId.toBytes())
};
}
/**
* @override
* @internal
* @param {Channel} channel
* @param {HieroProto.proto.ITransaction} request
* @returns {Promise<HieroProto.proto.ITransactionResponse>}
*/
_execute(channel, request) {
return channel.token.cancelAirdrop(request);
}
/**
* @override
* @protected
* @returns {NonNullable<HieroProto.proto.TransactionBody["data"]>}
*/
_getTransactionDataCase() {
return "tokenCancelAirdrop";
}
/**
* @internal
* @param {HieroProto.proto.ITransaction[]} transactions
* @param {HieroProto.proto.ISignedTransaction[]} signedTransactions
* @param {TransactionId[]} transactionIds
* @param {AccountId[]} nodeIds
* @param {HieroProto.proto.ITransactionBody[]} bodies
* @returns {TokenCancelAirdropTransaction}
*/
static _fromProtobuf(transactions, signedTransactions, transactionIds, nodeIds, bodies) {
const body = bodies[0];
const {
pendingAirdrops
} = /** @type {HieroProto.proto.ITokenCancelAirdropTransactionBody} */
body.tokenCancelAirdrop;
return _Transaction.default._fromProtobufTransactions(new TokenCancelAirdropTransaction({
pendingAirdropIds: pendingAirdrops?.map(pendingAirdrop => {
return _PendingAirdropId.default.fromBytes(pendingAirdrop);
})
}), transactions, signedTransactions, transactionIds, nodeIds, bodies);
}
/**
* @returns {string}
*/
_getLogId() {
const timestamp = /** @type {import("../Timestamp.js").default} */
this._transactionIds.current.validStart;
return `TokenCancelAirdrop:${timestamp.toString()}`;
}
}
exports.default = TokenCancelAirdropTransaction;
_Transaction.TRANSACTION_REGISTRY.set("tokenCancelAirdrop",
// eslint-disable-next-line @typescript-eslint/unbound-method
TokenCancelAirdropTransaction._fromProtobuf);
;