UNPKG

@debridge-finance/desdk

Version:

Send, track and claim arbitrary cross-chain messages over the deBridge protocol programmatically

46 lines 1.68 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Claim = void 0; const context_1 = require("./context"); class Claim { constructor(args, ctx) { this.ctx = ctx; Object.assign(this, args); } // TODO reasonable to introduce per-chain caching here async getRequiredSignaturesCount() { const contract = (0, context_1.getDeBridgeGate)(this.ctx); const excessConfirmations = await (0, context_1.getDeBridgeGate)(this.ctx).excessConfirmations(); return Number(excessConfirmations); } async isSigned() { const signatures = await this.getSignatures(); const minRequiredSignatures = await this.getRequiredSignaturesCount(); return signatures.length >= minRequiredSignatures; } async isExecuted() { return this.isClaimed(); } async isClaimed() { const contract = (0, context_1.getDeBridgeGate)(this.ctx); return contract.isSubmissionUsed(this.submissionId); } async getSignatures() { const storage = (0, context_1.getSignatureStorage)(this.ctx); return storage.getSignatures(this.submissionId); } async getEncodedArgs() { const signatures = await this.getSignatures(); return [ this.debridgeId.toString(), this.amount.toString(), this.chainIdFrom.toString(), this.receiver.toString(), this.nonce.toString(), "0x" + signatures.map((s) => s.replace(/^0x/, "")).join(""), this.autoParams ? this.autoParams.encode() : "0x", ]; } } exports.Claim = Claim; //# sourceMappingURL=claim.js.map