UNPKG

@hashgraph/sdk

Version:
3 lines (2 loc) 1.3 kB
import t from"./Key.js";import e from"./Cache.js";class s extends t{constructor(e,s){super(),this._keys=null==e?[]:e instanceof t?[e]:e,this._threshold=null==s?null:s}static of(...t){return new s(t,null)}static from(t,e,r){return new s(null==e?Array.from(t):Array.from(t,e,r))}get threshold(){return this._threshold}setThreshold(t){return this._threshold=t,this}push(...t){return this._keys.push(...t)}splice(t,e,...r){return new s(this._keys.splice(t,e,...r),this.threshold)}slice(t,e){return new s(this._keys.slice(t,e),this.threshold)}[Symbol.iterator](){return this._keys[Symbol.iterator]()}toArray(){return this._keys.slice()}toString(){return JSON.stringify({threshold:this._threshold,keys:this._keys.toString()})}_toProtobufKey(){const t=this._keys.map(t=>t._toProtobufKey());return null==this.threshold?{keyList:{keys:t}}:{thresholdKey:{threshold:this.threshold,keys:{keys:t}}}}static __fromProtobufKeyList(e){const r=(null!=e.keys?e.keys:[]).map(e=>t._fromProtobufKey(e));return new s(r)}static __fromProtobufThresoldKey(t){const e=s.__fromProtobufKeyList(null!=t.keys?t.keys:{});return e.setThreshold(null!=t.threshold?t.threshold:0),e}}e.setKeyList(t=>s.__fromProtobufKeyList(t)),e.setThresholdKey(t=>s.__fromProtobufThresoldKey(t));export{s as default}; //# sourceMappingURL=KeyList.js.map