UNPKG

@hashgraph/sdk

Version:
3 lines (2 loc) 1.16 kB
import t from"long";import o from"../account/AccountId.js";import e from"./TokenId.js";class n{constructor(n){this.tokenId=n.tokenId instanceof e?n.tokenId:e.fromString(n.tokenId),this.accountId=n.accountId instanceof o?n.accountId:o.fromString(n.accountId),this.expectedDecimals=n.expectedDecimals,this.amount=t.fromValue(n.amount),this.isApproved=n.isApproved}static _fromProtobuf(c){const s=[];for(const r of c){const c=e._fromProtobuf(r.token),i=null!=r.expectedDecimals&&Object.hasOwn(r.expectedDecimals,"value")?r.expectedDecimals.value:null;for(const e of null!=r.transfers?r.transfers:[])s.push(new n({tokenId:c,accountId:o._fromProtobuf(e.accountID),expectedDecimals:i||null,amount:null!=e.amount?e.amount:t.ZERO,isApproved:1==e.isApproval}))}return s}_toProtobuf(){return{accountID:this.accountId._toProtobuf(),amount:this.amount,isApproval:this.isApproved}}toJSON(){return{tokenId:this.tokenId.toString(),accountId:this.accountId.toString(),expectedDecimals:this.expectedDecimals,amount:this.amount.toString(),isApproved:this.isApproved}}toString(){return JSON.stringify(this.toJSON())}}export{n as default}; //# sourceMappingURL=TokenTransfer.js.map