UNPKG

@hashgraph/sdk

Version:
3 lines (2 loc) 1.92 kB
import e from"../token/TokenId.js";import r from"./AccountId.js";import n from"long";class o{constructor(e){this.tokenId=e.tokenId,this.spenderAccountId=e.spenderAccountId,this.ownerAccountId=e.ownerAccountId,this.serialNumbers=e.serialNumbers,this.allSerials=e.allSerials,this.delegatingSpender=e.delegatingSpender,Object.freeze(this)}static _fromProtobuf(l){const t=null!=l.approvedForAll&&1==l.approvedForAll.value;return new o({tokenId:e._fromProtobuf(l.tokenId),spenderAccountId:null!=l.spender?r._fromProtobuf(l.spender):null,ownerAccountId:null!=l.owner?r._fromProtobuf(l.owner):null,serialNumbers:t?null:null!=l.serialNumbers?l.serialNumbers.map(e=>n.fromValue(e)):[],allSerials:t,delegatingSpender:null!=l.delegatingSpender?r._fromProtobuf(l.delegatingSpender):null})}static _fromGrantedProtobuf(n,l){return new o({tokenId:e._fromProtobuf(n.tokenId),spenderAccountId:r._fromProtobuf(n.spender),ownerAccountId:l,serialNumbers:[],allSerials:null,delegatingSpender:null})}static _fromRemoveProtobuf(l){return new o({tokenId:e._fromProtobuf(l.tokenId),spenderAccountId:null,ownerAccountId:null!=l.owner?r._fromProtobuf(l.owner):null,serialNumbers:null!=l.serialNumbers?l.serialNumbers.map(e=>n.fromValue(e)):[],allSerials:null,delegatingSpender:null})}_toProtobuf(){return{tokenId:this.tokenId._toProtobuf(),spender:null!=this.spenderAccountId?this.spenderAccountId._toProtobuf():null,owner:null!=this.ownerAccountId?this.ownerAccountId._toProtobuf():null,approvedForAll:null==this.serialNumbers?{value:this.allSerials}:null,serialNumbers:this.serialNumbers,delegatingSpender:null!=this.delegatingSpender?this.delegatingSpender._toProtobuf():null}}_validateChecksums(e){this.tokenId.validateChecksum(e),null!=this.ownerAccountId&&this.ownerAccountId.validateChecksum(e),null!=this.spenderAccountId&&this.spenderAccountId.validateChecksum(e)}}export{o as default}; //# sourceMappingURL=TokenNftAllowance.js.map