UNPKG

@hashgraph/sdk

Version:
3 lines (2 loc) 1.2 kB
import t from"long";import o from"../account/AccountId.js";import e from"./TokenId.js";import{convertAmountToLong as n}from"../util.js";class c{constructor(t){this.tokenId=t.tokenId instanceof e?t.tokenId:e.fromString(t.tokenId),this.accountId=t.accountId instanceof o?t.accountId:o.fromString(t.accountId),this.expectedDecimals=t.expectedDecimals,this.amount=n(t.amount),this.isApproved=t.isApproved}static _fromProtobuf(n){const s=[];for(const r of n){const n=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 c({tokenId:n,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{c as default}; //# sourceMappingURL=TokenTransfer.js.map