@hashgraph/sdk
Version:
3 lines (2 loc) • 1.11 kB
JavaScript
import o from"long";import r from"../token/TokenId.js";import t from"./AccountId.js";import e from"../ObjectMap.js";class s extends e{constructor(){super((o=>r.fromString(o)))}__set(o,r){const t=o.toString();let e=this._map.get(t);null==e&&(e=[],this._map.set(t,e),this.__map.set(o,e)),e.push(r)}static _fromProtobuf(e){const n=new s;for(const s of e){const e=r._fromProtobuf(s.token);for(const r of null!=s.nftTransfers?s.nftTransfers:[]){const s=t._fromProtobuf(r.senderAccountID),f=t._fromProtobuf(r.receiverAccountID);n.__set(e,{sender:s,recipient:f,serial:o.fromValue(r.serialNumber),isApproved:!1})}}return n}_toProtobuf(){const o=[];for(const[r,t]of this){const e=[];for(const o of t)e.push({senderAccountID:o.sender._toProtobuf(),receiverAccountID:o.recipient._toProtobuf(),serialNumber:o.serial});o.push({token:r._toProtobuf(),nftTransfers:e})}return o}toJSON(){const o={};return this._map.forEach(((r,t)=>{o[t]=r.map((o=>({sender:o.sender.toString(),recipient:o.recipient.toString(),serial:o.serial,isApproved:o.isApproved})))})),o}}export{s as default};
//# sourceMappingURL=TokenNftTransferMap.js.map