@hiero-ledger/sdk
Version:
3 lines (2 loc) • 2.08 kB
JavaScript
import t from"./TokenRejectTransaction.js";import e from"./TokenDissociateTransaction.js";class i{constructor(){this._ownerId=null,this._tokenIds=[],this._nftIds=[],this._freezeWithClient=null,this._signPrivateKey=null,this._signPublicKey=null,this._transactionSigner=null}setOwnerId(t){return this.requireNotFrozen(),this._ownerId=t,this}get ownerId(){return this._ownerId}setTokenIds(t){return this.requireNotFrozen(),this._tokenIds=t,this}addTokenId(t){return this.requireNotFrozen(),this._tokenIds.push(t),this}get tokenIds(){return this._tokenIds}setNftIds(t){return this.requireNotFrozen(),this._nftIds=t,this}addNftId(t){return this.requireNotFrozen(),this._nftIds.push(t),this}get nftIds(){return this._nftIds}sign(t){return this._signPrivateKey=t,this._signPublicKey=null,this._transactionSigner=null,this}signWith(t,e){return this._signPublicKey=t,this._transactionSigner=e,this._signPrivateKey=null,this}signWithOperator(t){const e=t.getOperator();if(null==e)throw new Error("Client operator must be set");return this._signPublicKey=e.publicKey,this._transactionSigner=e.transactionSigner,this._signPrivateKey=null,this}fillOutTransaction(t){this._freezeWithClient&&t.freezeWith(this._freezeWithClient),this._signPrivateKey?t.sign(this._signPrivateKey):this._signPublicKey&&this._transactionSigner&&t.signWith(this._signPublicKey,this._transactionSigner)}freezeWith(t){return this._freezeWithClient=t,this}async execute(i){const n=(new t).setTokenIds(this.tokenIds).setNftIds(this.nftIds);this.ownerId&&n.setOwnerId(this.ownerId),this.fillOutTransaction(n);const s=this.nftIds.map((t=>t.tokenId)).filter((function(t,e,i){return i.indexOf(t)===e})),r=(new e).setTokenIds([...this.tokenIds,...s]);null!=this.ownerId&&r.setAccountId(this.ownerId),this.fillOutTransaction(r);const o=await n.execute(i);await o.getReceipt(i);const h=await r.execute(i);return await h.getReceipt(i),o}requireNotFrozen(){if(null!=this._freezeWithClient)throw new Error("Transaction is already frozen and cannot be modified")}}export{i as default};
//# sourceMappingURL=TokenRejectFlow.js.map