UNPKG

dimension-js-sdk

Version:
1 lines 133 kB
(()=>{"use strict";var e={5601:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DEFAULT_DEPLOY_TTL=void 0,t.DEFAULT_DEPLOY_TTL=18e5},3607:function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||t.hasOwnProperty(r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),o(r(1999),t),o(r(3915),t);var i=r(1417);Object.defineProperty(t,"base64to16",{enumerable:!0,get:function(){return i.base64to16}}),Object.defineProperty(t,"encodeBase16",{enumerable:!0,get:function(){return i.encodeBase16}}),Object.defineProperty(t,"decodeBase16",{enumerable:!0,get:function(){return i.decodeBase16}}),Object.defineProperty(t,"encodeBase64",{enumerable:!0,get:function(){return i.encodeBase64}}),Object.defineProperty(t,"decodeBase64",{enumerable:!0,get:function(){return i.decodeBase64}})},6138:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.toBytesBytesArray=t.toBytesVectorNew=t.toBytesVector=t.toBytesArrayU8=t.fromBytesString=t.toBytesString=t.toBytesDeployHash=t.toBytesU512=t.toBytesU256=t.toBytesU128=t.toBytesI64=t.toBytesU64=t.toBytesU32=t.toBytesI32=t.toBytesU8=t.toBytesNumber=void 0;var n=r(1446),o=r(6148),i=r(4103),a=r(9486);t.toBytesNumber=function(e,t){return function(r){var a=n.BigNumber.from(r),s=o.MaxUint256.mask(e);if(t){var u=s.mask(e-1);if(a.gt(u)||a.lt(u.add(o.One).mul(o.NegativeOne)))throw new Error("value out-of-bounds, value: "+r)}else if(a.lt(o.Zero)||a.gt(s.mask(e)))throw new Error("value out-of-bounds, value: "+r);var c=a.toTwos(e).mask(e),p=i.arrayify(c);if(c.gte(0)){if(e>64)return c.eq(0)?p:i.concat([p,Uint8Array.from([p.length])]).slice().reverse();var y=e/8;return i.concat([p.slice().reverse(),new Uint8Array(y-p.length)])}return p.reverse()}},t.toBytesU8=t.toBytesNumber(8,!1),t.toBytesI32=t.toBytesNumber(32,!0),t.toBytesU32=t.toBytesNumber(32,!1),t.toBytesU64=t.toBytesNumber(64,!1),t.toBytesI64=t.toBytesNumber(64,!0),t.toBytesU128=t.toBytesNumber(128,!1),t.toBytesU256=t.toBytesNumber(256,!1),t.toBytesU512=t.toBytesNumber(512,!1),t.toBytesDeployHash=function(e){return e},t.toBytesString=function(e){var r=Uint8Array.from(Buffer.from(e));return i.concat([t.toBytesU32(r.byteLength),r])},t.fromBytesString=function(e){return Buffer.from(e).toString()},t.toBytesArrayU8=function(e){return i.concat([t.toBytesU32(e.length),e])},t.toBytesVector=function(e){var r=e.map((function(e){return e.toBytes()})).map((function(e){return e.unwrap()}));return r.splice(0,0,t.toBytesU32(e.length)),i.concat(r)},t.toBytesVectorNew=function(e){var r=e.map((function(e){return a.CLValueParsers.toBytes(e).unwrap()}));return r.splice(0,0,t.toBytesU32(e.length)),i.concat(r)},t.toBytesBytesArray=function(e){return e}},7066:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CLValueBytesParsers=t.CLValueParsers=t.CLValue=t.ToBytes=t.CLType=t.resultHelper=void 0;var n=r(7107),o=r(4103),i=r(6138),a=r(7009),s=r(9591),u=r(9486),c=r(1417);t.resultHelper=function(e,t){return{result:e,remainder:t}};var p=function(){function e(){}return e.prototype.toBytes=function(){return Uint8Array.from([this.tag])},e}();t.CLType=p;t.ToBytes=function(){};t.CLValue=function(){this.isCLValue=!0};var y=function(){function e(){}return e.fromJSON=function(t){var r=s.matchTypeToCLType(t.cl_type),o=c.decodeBase16(t.bytes),i=e.fromBytes(o,r).unwrap();return n.Ok(i)},e.fromBytes=function(e,t){return s.matchByteParserByCLType(t).unwrap().fromBytes(e,t)},e.toJSON=function(t){var r=e.toBytes(t).unwrap(),o=c.encodeBase16(r),i=t.clType().toJSON();return n.Ok({bytes:o,cl_type:i})},e.toBytes=function(e){return s.matchByteParserByCLType(e.clType()).unwrap().toBytes(e)},e.toBytesWithType=function(e){var t=e.clType().toBytes(),r=s.matchByteParserByCLType(e.clType()).unwrap().toBytes(e).unwrap(),a=o.concat([i.toBytesArrayU8(r),t]);return n.Ok(a)},e.fromBytesWithType=function(e){var t=(new u.CLU32BytesParser).fromBytesWithRemainder(e),r=t.result,o=t.remainder,i=r.unwrap().value().toNumber();if(!o)return n.Err(a.CLErrorCodes.EarlyEndOfStream);var c=o.subarray(0,i),p=o.subarray(i),y=s.matchBytesToCLType(p).result,l=s.matchByteParserByCLType(y.unwrap()).unwrap().fromBytes(c,y.unwrap()).unwrap();return n.Ok(l)},e}();t.CLValueParsers=y;var l=function(){function e(){}return e.prototype.fromBytes=function(e,t){var r=this.fromBytesWithRemainder(e,t),o=r.result,i=r.remainder;return i&&i.length?n.Err(a.CLErrorCodes.LeftOverBytes):o},e}();t.CLValueBytesParsers=l},305:function(e,t,r){var n,o=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0}),t.CLAccountHash=t.CLAccountHashBytesParser=t.CLAccountHashType=void 0;var i=r(7107),a=r(9486),s=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.linksTo=c,t.tag=-1,t}return o(t,e),t.prototype.toString=function(){return a.ACCOUNT_HASH_ID},t.prototype.toJSON=function(){return this.toString()},t}(a.CLType);t.CLAccountHashType=s;var u=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return o(t,e),t.prototype.toBytes=function(e){return i.Ok(e.data)},t.prototype.fromBytesWithRemainder=function(e){if(e.length<a.ACCOUNT_HASH_LENGTH)return a.resultHelper(i.Err(a.CLErrorCodes.EarlyEndOfStream));var t=e.subarray(0,a.ACCOUNT_HASH_LENGTH),r=new c(t);return a.resultHelper(i.Ok(r))},t}(a.CLValueBytesParsers);t.CLAccountHashBytesParser=u;var c=function(e){function t(t){var r=e.call(this)||this;return r.data=t,r}return o(t,e),t.prototype.clType=function(){return new s},t.prototype.value=function(){return this.data},t}(a.CLValue);t.CLAccountHash=c},5110:function(e,t,r){var n,o=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0}),t.CLBool=t.CLBoolBytesParser=t.CLBoolType=void 0;var i=r(7107),a=r(9486),s=r(7009),u=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.linksTo=p,t.tag=s.CLTypeTag.Bool,t}return o(t,e),t.prototype.toString=function(){return s.BOOL_ID},t.prototype.toJSON=function(){return this.toString()},t}(a.CLType);t.CLBoolType=u;var c=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return o(t,e),t.prototype.toBytes=function(e){return i.Ok(new Uint8Array([e.value()?1:0]))},t.prototype.fromBytesWithRemainder=function(e){return 0===e.length?a.resultHelper(i.Err(a.CLErrorCodes.EarlyEndOfStream)):1===e[0]?a.resultHelper(i.Ok(new p(!0)),e.subarray(1)):0===e[0]?a.resultHelper(i.Ok(new p(!1)),e.subarray(1)):a.resultHelper(i.Err(a.CLErrorCodes.Formatting))},t}(a.CLValueBytesParsers);t.CLBoolBytesParser=c;var p=function(e){function t(t){var r=e.call(this)||this;return r.data=t,r}return o(t,e),t.prototype.clType=function(){return new u},t.prototype.value=function(){return this.data},t.fromBytesWithRemainder=function(e){return 0===e.length?a.resultHelper(i.Err(a.CLErrorCodes.EarlyEndOfStream)):1===e[0]?a.resultHelper(i.Ok(new t(!0)),e.subarray(1)):0===e[0]?a.resultHelper(i.Ok(new t(!1)),e.subarray(1)):a.resultHelper(i.Err(a.CLErrorCodes.Formatting))},t}(a.CLValue);t.CLBool=p},4259:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CLValueBuilder=t.CLTypeBuilder=void 0;var n=r(9486),o=function(){function e(){}return e.list=function(e){return new n.CLListType(e)},e.tuple1=function(e){var t=e[0];return new n.CLTuple1Type([t])},e.tuple2=function(e){var t=e[0],r=e[1];return new n.CLTuple2Type([t,r])},e.tuple3=function(e){var t=e[0],r=e[1],o=e[2];return new n.CLTuple3Type([t,r,o])},e.option=function(e){return new n.CLOptionType(e)},e.map=function(e){return new n.CLMapType(e)},e.publicKey=function(){return new n.CLPublicKeyType},e.byteArray=function(e){return new n.CLByteArrayType(e)},e.bool=function(){return new n.CLBoolType},e.u8=function(){return new n.CLU8Type},e.u32=function(){return new n.CLU32Type},e.i32=function(){return new n.CLI32Type},e.u64=function(){return new n.CLU64Type},e.i64=function(){return new n.CLI64Type},e.u128=function(){return new n.CLU128Type},e.u256=function(){return new n.CLU256Type},e.u512=function(){return new n.CLU512Type},e.unit=function(){return new n.CLUnitType},e.string=function(){return new n.CLStringType},e.key=function(){return new n.CLKeyType},e.uref=function(){return new n.CLURefType},e}();t.CLTypeBuilder=o;var i=function(){function e(){}return e.list=function(e){return new n.CLList(e)},e.tuple1=function(e){var t=e[0];return new n.CLTuple1([t])},e.tuple2=function(e){var t=e[0],r=e[1];return new n.CLTuple2([t,r])},e.tuple3=function(e){var t=e[0],r=e[1],o=e[2];return new n.CLTuple3([t,r,o])},e.option=function(e,t){return new n.CLOption(e,t)},e.map=function(e){return new n.CLMap(e)},e.publicKey=function(e,t){return new n.CLPublicKey(e,t)},e.byteArray=function(e){return new n.CLByteArray(e)},e.bool=function(e){return new n.CLBool(e)},e.u8=function(e){return new n.CLU8(e)},e.u32=function(e){return new n.CLU32(e)},e.i32=function(e){return new n.CLI32(e)},e.u64=function(e){return new n.CLU64(e)},e.i64=function(e){return new n.CLI64(e)},e.u128=function(e){return new n.CLU128(e)},e.u256=function(e){return new n.CLU256(e)},e.u512=function(e){return new n.CLU512(e)},e.unit=function(){return new n.CLUnit},e.string=function(e){return new n.CLString(e)},e.key=function(e){return new n.CLKey(e)},e.uref=function(e,t){return new n.CLURef(e,t)},e}();t.CLValueBuilder=i},401:function(e,t,r){var n,o=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0}),t.CLByteArray=t.CLByteArrayBytesParser=t.CLByteArrayType=t.CL_BYTE_ARRAY_MAX_LENGTH=void 0;var i=r(7107),a=r(4103),s=r(9486),u=r(7009),c=r(6138);t.CL_BYTE_ARRAY_MAX_LENGTH=32;var p=function(e){function t(t){var r=e.call(this)||this;return r.linksTo=l,r.tag=u.CLTypeTag.ByteArray,r.size=t,r}return o(t,e),t.prototype.toString=function(){return u.BYTE_ARRAY_ID},t.prototype.toBytes=function(){return a.concat([Uint8Array.from([this.tag]),c.toBytesU32(this.size)])},t.prototype.toJSON=function(){var e;return(e={})[u.BYTE_ARRAY_ID]=this.size,e},t}(s.CLType);t.CLByteArrayType=p;var y=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return o(t,e),t.prototype.toBytes=function(e){return i.Ok(e.data)},t.prototype.fromBytesWithRemainder=function(e,t){var r=new l(e.subarray(0,t.size));return s.resultHelper(i.Ok(r),e.subarray(t.size))},t}(s.CLValueBytesParsers);t.CLByteArrayBytesParser=y;var l=function(e){function t(t){var r=e.call(this)||this;return r.data=t,r}return o(t,e),t.prototype.clType=function(){return new p(this.data.length)},t.prototype.value=function(){return this.data},t}(s.CLValue);t.CLByteArray=l},4381:function(e,t,r){var n,o=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0}),t.CLKey=t.CLKeyBytesParser=t.CLKeyType=void 0;var i=r(4103),a=r(7107),s=r(9486),u=r(7009),c=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.linksTo=y,t.tag=u.CLTypeTag.Key,t}return o(t,e),t.prototype.toString=function(){return u.KEY_ID},t.prototype.toJSON=function(){return this.toString()},t}(s.CLType);t.CLKeyType=c;var p=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return o(t,e),t.prototype.toBytes=function(e){if(e.isAccount())return a.Ok(i.concat([Uint8Array.from([s.KeyVariant.Account]),(new s.CLAccountHashBytesParser).toBytes(e.data).unwrap()]));if(e.isHash())return a.Ok(i.concat([Uint8Array.from([s.KeyVariant.Hash]),(new s.CLByteArrayBytesParser).toBytes(e.data).unwrap()]));if(e.isURef())return a.Ok(i.concat([Uint8Array.from([s.KeyVariant.URef]),s.CLValueParsers.toBytes(e.data).unwrap()]));throw new Error("Unknown byte types")},t.prototype.fromBytesWithRemainder=function(e){if(e.length<1)return s.resultHelper(a.Err(s.CLErrorCodes.EarlyEndOfStream));var t=e[0];if(t===s.KeyVariant.Hash){var r=e.subarray(1),n=(new s.CLByteArrayBytesParser).fromBytesWithRemainder(r,new s.CLByteArrayType(32)),o=n.result,i=n.remainder,u=o.unwrap(),c=new y(u);return s.resultHelper(a.Ok(c),i)}if(t===s.KeyVariant.URef){var p=(new s.CLURefBytesParser).fromBytesWithRemainder(e.subarray(1)),l=p.result,f=p.remainder;return l.ok?(c=new y(l.val),s.resultHelper(a.Ok(c),f)):s.resultHelper(a.Err(l.val))}if(t===s.KeyVariant.Account){var d=(new s.CLAccountHashBytesParser).fromBytesWithRemainder(e.subarray(1)),h=d.result,g=d.remainder;return h.ok?(c=new y(h.val),s.resultHelper(a.Ok(c),g)):s.resultHelper(a.Err(h.val))}return s.resultHelper(a.Err(s.CLErrorCodes.Formatting))},t}(s.CLValueBytesParsers);t.CLKeyBytesParser=p;var y=function(e){function t(t){var r=e.call(this)||this;if(!t.isCLValue)throw Error("Provided parameter is not a valid CLValue");return t.clType().toString()===s.PUBLIC_KEY_ID?(r.data=new s.CLAccountHash(t.toAccountHash()),r):(r.data=t,r)}return o(t,e),t.prototype.clType=function(){return new c},t.prototype.value=function(){return this.data},t.prototype.isHash=function(){return this.data.clType().toString()===s.BYTE_ARRAY_ID},t.prototype.isURef=function(){return this.data.clType().toString()===s.UREF_ID},t.prototype.isAccount=function(){return this.data.clType().toString()===s.ACCOUNT_HASH_ID},t}(s.CLValue);t.CLKey=y},9403:function(e,t,r){var n,o=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0}),t.CLList=t.CLListBytesParser=t.CLListType=void 0;var i=r(7107),a=r(4103),s=r(9486),u=r(6138),c=r(7009),p=function(e){function t(t){var r=e.call(this)||this;return r.linksTo=l,r.tag=c.CLTypeTag.List,r.inner=t,r}return o(t,e),t.prototype.toString=function(){return c.LIST_ID+" ("+this.inner.toString()+")"},t.prototype.toBytes=function(){return a.concat([Uint8Array.from([this.tag]),this.inner.toBytes()])},t.prototype.toJSON=function(){var e,t=this.inner.toJSON();return(e={})[c.LIST_ID]=t,e},t}(s.CLType);t.CLListType=p;var y=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return o(t,e),t.prototype.toBytes=function(e){return i.Ok(u.toBytesVectorNew(e.data))},t.prototype.fromBytesWithRemainder=function(e,t){var r=(new s.CLU32BytesParser).fromBytesWithRemainder(e),n=r.result,o=r.remainder;if(!n.ok)return s.resultHelper(i.Err(n.val));for(var a=n.val.value().toNumber(),u=[],c=o,p=s.matchByteParserByCLType(t.inner).unwrap(),y=0;y<a;y++){if(!c)return s.resultHelper(i.Err(s.CLErrorCodes.EarlyEndOfStream));var f=p.fromBytesWithRemainder(c,t.inner),d=f.result,h=f.remainder;if(!d.ok)return s.resultHelper(i.Err(d.val));u.push(d.val),c=h}return 0===u.length?s.resultHelper(i.Ok(new l(t.inner)),c):s.resultHelper(i.Ok(new l(u)),c)},t}(s.CLValueBytesParsers);t.CLListBytesParser=y;var l=function(e){function t(t){var r=e.call(this)||this;if(Array.isArray(t)&&t[0].clType){var n=t[0].clType();if(!t.every((function(e){return e.clType().toString()===n.toString()})))throw Error("Invalid data provided.");r.data=t,r.vectorType=n}else{if(!(t instanceof s.CLType))throw Error("Invalid data type(s) provided.");r.vectorType=t,r.data=[]}return r}return o(t,e),t.prototype.value=function(){return this.data},t.prototype.clType=function(){return new p(this.vectorType)},t.prototype.get=function(e){if(e>=this.data.length)throw new Error("List index out of bounds.");return this.data[e]},t.prototype.set=function(e,t){if(e>=this.data.length)throw new Error("List index out of bounds.");this.data[e]=t},t.prototype.push=function(e){if(e.clType().toString()!==this.vectorType.toString())throw Error("Incosnsistent data type, use "+this.vectorType.toString()+".");this.data.push(e)},t.prototype.remove=function(e){this.data.splice(e,1)},t.prototype.pop=function(){return this.data.pop()},t.prototype.size=function(){return this.data.length},t}(s.CLValue);t.CLList=l},547:function(e,t,r){var n,o=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),i=this&&this.__spreadArrays||function(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;var n=Array(e),o=0;for(t=0;t<r;t++)for(var i=arguments[t],a=0,s=i.length;a<s;a++,o++)n[o]=i[a];return n};Object.defineProperty(t,"__esModule",{value:!0}),t.CLMap=t.CLMapBytesParser=t.CLMapType=void 0;var a=r(4103),s=r(7107),u=r(9486),c=r(7009),p=r(6138),y=function(e){function t(t){var r=t[0],n=t[1],o=e.call(this)||this;return o.tag=c.CLTypeTag.Map,o.linksTo=f,o.innerKey=r,o.innerValue=n,o}return o(t,e),t.prototype.toString=function(){return c.MAP_ID+" ("+this.innerKey.toString()+": "+this.innerValue.toString()+")"},t.prototype.toBytes=function(){return a.concat([Uint8Array.from([this.tag]),this.innerKey.toBytes(),this.innerValue.toBytes()])},t.prototype.toJSON=function(){var e;return(e={})[c.MAP_ID]={key:this.innerKey.toJSON(),value:this.innerValue.toJSON()},e},t}(u.CLType);t.CLMapType=y;var l=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return o(t,e),t.prototype.toBytes=function(e){var t=Array.from(e.data).map((function(e){var t=e[0],r=e[1],n=u.CLValueParsers.toBytes(t).unwrap(),o=u.CLValueParsers.toBytes(r).unwrap();return a.concat([n,o])}));return s.Ok(a.concat(i([p.toBytesU32(e.data.length)],t)))},t.prototype.fromBytesWithRemainder=function(e,t){var r=(new u.CLU32BytesParser).fromBytesWithRemainder(e),n=r.result,o=r.remainder,i=n.unwrap().value().toNumber(),a=[],c=o;if(0===i)return u.resultHelper(s.Ok(new f([t.innerKey,t.innerValue])),c);for(var p=0;p<i;p++){if(!c)return u.resultHelper(s.Err(u.CLErrorCodes.EarlyEndOfStream));var y=u.matchByteParserByCLType(t.innerKey).unwrap().fromBytesWithRemainder(c,t.innerKey),l=y.result,d=y.remainder,h=l.unwrap();if(!(c=d))return u.resultHelper(s.Err(u.CLErrorCodes.EarlyEndOfStream));var g=u.matchByteParserByCLType(t.innerValue).unwrap().fromBytesWithRemainder(c,t.innerValue),m=g.result,v=g.remainder,b=m.unwrap();c=v,a.push([h,b])}return u.resultHelper(s.Ok(new f(a)),c)},t}(u.CLValueBytesParsers);t.CLMapBytesParser=l;var f=function(e){function t(t){var r=e.call(this)||this;if(function(e){return Array.isArray(e)&&Array.isArray(e[0])&&2===e[0].length&&!!e[0][0].clType&&!!e[0][1].clType}(t)){if(r.refType=[t[0][0].clType(),t[0][1].clType()],!t.every((function(e){var t=e[0],n=e[1];return t.clType().toString()===r.refType[0].toString()&&n.clType().toString()===r.refType[1].toString()})))throw Error("Invalid data provided.");r.data=t}else{if(!(t[0]instanceof u.CLType&&t[1]instanceof u.CLType))throw Error("Invalid data type(s) provided.");r.refType=t,r.data=[]}return r}return o(t,e),t.prototype.clType=function(){return new y(this.refType)},t.prototype.value=function(){return this.data},t.prototype.get=function(e){var t=this.data.find((function(t){return t[0].value()===e.value()}));return t?t[1]:void 0},t.prototype.set=function(e,t){this.get(e)?this.data=this.data.map((function(r){return r[0].value()===e.value()?[r[0],t]:r})):this.data=i(this.data,[[e,t]])},t.prototype.delete=function(e){this.data=this.data.filter((function(t){return t[0].value()!==e.value()}))},t.prototype.size=function(){return this.data.length},t}(u.CLValue);t.CLMap=f},9439:function(e,t,r){var n,o=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0}),t.CLU512=t.CLU512BytesParser=t.CLU512Type=t.CLU256=t.CLU256BytesParser=t.CLU256Type=t.CLU128=t.CLU128BytesParser=t.CLU128Type=t.CLU64=t.CLU64BytesParser=t.CLU64Type=t.CLU32=t.CLU32BytesParser=t.CLU32Type=t.CLU8=t.CLU8BytesParser=t.CLU8Type=t.CLI64=t.CLI64BytesParser=t.CLI64Type=t.CLI32=t.CLI32BytesParser=t.CLI32Type=void 0;var i=r(7107),a=r(7066),s=r(7009),u=r(1446),c=r(6138),p=r(7009),y=r(4922),l=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return o(t,e),t.prototype.toBytes=function(e){return(128===e.bitSize||256===e.bitSize||512===e.bitSize)&&e.originalBytes&&y.arrayEquals(e.originalBytes,Uint8Array.from([1,0]))?i.Ok(e.originalBytes):i.Ok(c.toBytesNumber(e.bitSize,e.signed)(e.data))},t}(a.CLValueBytesParsers),f=function(e){function t(t,r,n,o){var i=e.call(this)||this;if(!1===r&&Math.sign(n)<0)throw new Error("Can't provide negative numbers with isSigned=false");return o&&(i.originalBytes=o),i.bitSize=t,i.signed=r,i.data=u.BigNumber.from(n),i}return o(t,e),t.prototype.value=function(){return this.data},t}(a.CLValue),d=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.linksTo=g,t.tag=p.CLTypeTag.I32,t}return o(t,e),t.prototype.toString=function(){return p.I32_ID},t.prototype.toJSON=function(){return this.toString()},t}(a.CLType);t.CLI32Type=d;var h=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return o(t,e),t.prototype.fromBytesWithRemainder=function(e){if(e.length<4)return a.resultHelper(i.Err(s.CLErrorCodes.EarlyEndOfStream));var t=Uint8Array.from(e.subarray(0,4)),r=u.BigNumber.from(t.slice().reverse()).fromTwos(32),n=e.subarray(4);return a.resultHelper(i.Ok(new g(r)),n)},t}(l);t.CLI32BytesParser=h;var g=function(e){function t(t){return e.call(this,32,!0,t)||this}return o(t,e),t.prototype.clType=function(){return new d},t}(f);t.CLI32=g;var m=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.linksTo=b,t.tag=p.CLTypeTag.I64,t}return o(t,e),t.prototype.toString=function(){return p.I64_ID},t.prototype.toJSON=function(){return this.toString()},t}(a.CLType);t.CLI64Type=m;var v=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return o(t,e),t.prototype.fromBytesWithRemainder=function(e){if(e.length<8)return a.resultHelper(i.Err(s.CLErrorCodes.EarlyEndOfStream));var t=Uint8Array.from(e.subarray(0,8)),r=u.BigNumber.from(t.slice().reverse()).fromTwos(64),n=e.subarray(8);return a.resultHelper(i.Ok(new b(r)),n)},t}(l);t.CLI64BytesParser=v;var b=function(e){function t(t){return e.call(this,64,!0,t)||this}return o(t,e),t.prototype.clType=function(){return new m},t}(f);t.CLI64=b;var C=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.linksTo=w,t.tag=p.CLTypeTag.U8,t}return o(t,e),t.prototype.toString=function(){return p.U8_ID},t.prototype.toJSON=function(){return this.toString()},t}(a.CLType);t.CLU8Type=C;var T=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return o(t,e),t.prototype.fromBytesWithRemainder=function(e){return 0===e.length?a.resultHelper(i.Err(s.CLErrorCodes.EarlyEndOfStream)):a.resultHelper(i.Ok(new w(e[0])),e.subarray(1))},t}(l);t.CLU8BytesParser=T;var w=function(e){function t(t){return e.call(this,8,!1,t)||this}return o(t,e),t.prototype.clType=function(){return new C},t}(f);t.CLU8=w;var B=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.linksTo=L,t.tag=p.CLTypeTag.U32,t}return o(t,e),t.prototype.toString=function(){return p.U32_ID},t.prototype.toJSON=function(){return this.toString()},t}(a.CLType);t.CLU32Type=B;var _=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return o(t,e),t.prototype.fromBytesWithRemainder=function(e){if(e.length<4)return a.resultHelper(i.Err(s.CLErrorCodes.EarlyEndOfStream));var t=Uint8Array.from(e.subarray(0,4)),r=u.BigNumber.from(t.slice().reverse());return a.resultHelper(i.Ok(new L(r)),e.subarray(4))},t}(l);t.CLU32BytesParser=_;var L=function(e){function t(t){return e.call(this,32,!1,t)||this}return o(t,e),t.prototype.clType=function(){return new B},t}(f);t.CLU32=L;var S=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.linksTo=O,t.tag=p.CLTypeTag.U64,t}return o(t,e),t.prototype.toString=function(){return p.U64_ID},t.prototype.toJSON=function(){return this.toString()},t}(a.CLType);t.CLU64Type=S;var P=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return o(t,e),t.prototype.fromBytesWithRemainder=function(e){if(e.length<8)return a.resultHelper(i.Err(s.CLErrorCodes.EarlyEndOfStream));var t=Uint8Array.from(e.subarray(0,8)),r=u.BigNumber.from(t.slice().reverse());return a.resultHelper(i.Ok(new O(r)),e.subarray(8))},t}(l);t.CLU64BytesParser=P;var O=function(e){function t(t){return e.call(this,64,!1,t)||this}return o(t,e),t.prototype.clType=function(){return new S},t}(f);t.CLU64=O;var E=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.linksTo=U,t.tag=p.CLTypeTag.U128,t}return o(t,e),t.prototype.toString=function(){return p.U128_ID},t.prototype.toJSON=function(){return this.toString()},t}(a.CLType);t.CLU128Type=E;var A=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return o(t,e),t.prototype.fromBytesWithRemainder=function(e){return K(e,128)},t}(l);t.CLU128BytesParser=A;var U=function(e){function t(t,r){return e.call(this,128,!1,t,r)||this}return o(t,e),t.prototype.clType=function(){return new E},t}(f);t.CLU128=U;var j=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.linksTo=H,t.tag=p.CLTypeTag.U256,t}return o(t,e),t.prototype.toString=function(){return p.U256_ID},t.prototype.toJSON=function(){return this.toString()},t}(a.CLType);t.CLU256Type=j;var k=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return o(t,e),t.prototype.fromBytesWithRemainder=function(e){return K(e,256)},t}(l);t.CLU256BytesParser=k;var H=function(e){function t(t,r){return e.call(this,256,!1,t,r)||this}return o(t,e),t.prototype.clType=function(){return new j},t}(f);t.CLU256=H;var D=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.linksTo=M,t.tag=p.CLTypeTag.U512,t}return o(t,e),t.prototype.toString=function(){return p.U512_ID},t.prototype.toJSON=function(){return this.toString()},t}(a.CLType);t.CLU512Type=D;var I=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return o(t,e),t.prototype.fromBytesWithRemainder=function(e){return K(e,512)},t}(l);t.CLU512BytesParser=I;var M=function(e){function t(t,r){return e.call(this,512,!1,t,r)||this}return o(t,e),t.prototype.clType=function(){return new D},t}(f);t.CLU512=M;var K=function(e,t){if(e.length<1)return a.resultHelper(i.Err(s.CLErrorCodes.EarlyEndOfStream));var r=t/8,n=e[0];if(n>r)return a.resultHelper(i.Err(s.CLErrorCodes.Formatting));if(n+1>e.length)return a.resultHelper(i.Err(s.CLErrorCodes.EarlyEndOfStream));var o=0===n?[0]:e.subarray(1,1+n),c=e.subarray(1+n),p=u.BigNumber.from(o.slice().reverse());return 128===t?a.resultHelper(i.Ok(new U(p,e)),c):256===t?a.resultHelper(i.Ok(new H(p,e)),c):512===t?a.resultHelper(i.Ok(new M(p,e)),c):a.resultHelper(i.Err(s.CLErrorCodes.Formatting))}},2285:function(e,t,r){var n,o=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0}),t.CLOption=t.CLOptionBytesParser=t.CLOptionType=void 0;var i=r(7107),a=r(4103),s=r(9486),u=r(7009),c=function(e){function t(t){var r=e.call(this)||this;return r.tag=u.CLTypeTag.Option,r.linksTo=y,r.inner=t,r}return o(t,e),t.prototype.toString=function(){return null===this.inner?u.OPTION_ID+" (None)":u.OPTION_ID+" ("+this.inner.toString()+")"},t.prototype.toBytes=function(){return a.concat([Uint8Array.from([this.tag]),this.inner.toBytes()])},t.prototype.toJSON=function(){var e;return(e={})[u.OPTION_ID]=this.inner.toJSON(),e},t}(s.CLType);t.CLOptionType=c;var p=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return o(t,e),t.prototype.toBytes=function(e){return e.data.none?i.Ok(Uint8Array.from([0])):e.data.some?i.Ok(a.concat([Uint8Array.from([1]),s.CLValueParsers.toBytes(e.data.unwrap()).unwrap()])):i.Err(s.CLErrorCodes.UnknownValue)},t.prototype.fromBytesWithRemainder=function(e,t){var r=(new s.CLU8BytesParser).fromBytesWithRemainder(e),n=r.result,o=r.remainder,a=n.unwrap().value().toNumber();if(0===a)return s.resultHelper(i.Ok(new y(i.None,t.inner)),o);if(1===a){if(!o)return s.resultHelper(i.Err(s.CLErrorCodes.EarlyEndOfStream));var u=s.matchByteParserByCLType(t.inner).unwrap().fromBytesWithRemainder(o,t.inner),c=u.result,p=u.remainder,l=c.unwrap();return s.resultHelper(i.Ok(new y(i.Some(l))),p)}return s.resultHelper(i.Err(s.CLErrorCodes.Formatting))},t}(s.CLValueBytesParsers);t.CLOptionBytesParser=p;var y=function(e){function t(t,r){var n=e.call(this)||this;if(n.data=t,t.none){if(!r)throw new Error("You had to assign innerType for None");n.innerType=r}else n.innerType=t.val.clType();return e.call(this)||this}return o(t,e),t.prototype.isNone=function(){return this.data.none},t.prototype.isSome=function(){return this.data.some},t.prototype.value=function(){return this.data},t.prototype.clType=function(){return new c(this.innerType)},t}(s.CLValue);t.CLOption=y},1533:function(e,t,r){var n,o=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0}),t.CLPublicKey=t.CLPublicKeyBytesParser=t.CLPublicKeyType=t.CLPublicKeyTag=void 0;var i,a=r(4103),s=r(7107),u=r(9486),c=r(7009),p=r(1417),y=r(3492),l=r(2964);!function(e){e[e.ED25519=1]="ED25519",e[e.SECP256K1=2]="SECP256K1"}(i=t.CLPublicKeyTag||(t.CLPublicKeyTag={}));var f=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.linksTo=h,t.tag=c.CLTypeTag.PublicKey,t}return o(t,e),t.prototype.toString=function(){return c.PUBLIC_KEY_ID},t.prototype.toJSON=function(){return this.toString()},t}(u.CLType);t.CLPublicKeyType=f;var d=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return o(t,e),t.prototype.toBytes=function(e){return s.Ok(a.concat([Uint8Array.from([e.tag]),e.data]))},t.prototype.fromBytesWithRemainder=function(e){if(e.length<1)return u.resultHelper(s.Err(u.CLErrorCodes.EarlyEndOfStream));var t,r=e[0];if(r===i.ED25519)t=32;else{if(r!==i.SECP256K1)return u.resultHelper(s.Err(u.CLErrorCodes.Formatting));t=33}var n=e.subarray(1,t+1),o=new h(n,r);return u.resultHelper(s.Ok(o),e.subarray(t+1))},t}(u.CLValueBytesParsers);t.CLPublicKeyBytesParser=d;var h=function(e){function t(t,r){var n=e.call(this)||this;if(r===i.ED25519||r===l.SignatureAlgorithm.Ed25519){if(32!==t.length)throw new Error("Wrong length of ED25519 key. Expected 32, but got "+t.length+".");return n.data=t,n.tag=i.ED25519,n}if(r===i.SECP256K1||r===l.SignatureAlgorithm.Secp256K1){if(33!==t.length)throw new Error("Wrong length of SECP256K1 key. Expected 33, but got "+t.length+".");return n.data=t,n.tag=i.SECP256K1,n}throw new Error("Unsupported type of public key")}return o(t,e),t.prototype.clType=function(){return new f},t.prototype.isEd25519=function(){return this.tag===i.ED25519},t.prototype.isSecp256K1=function(){return this.tag===i.SECP256K1},t.prototype.toHex=function(){return"0"+this.tag+p.encodeBase16(this.data)},t.prototype.toAccountHash=function(){var e=i[this.tag],t=Uint8Array.from([0]),r=Buffer.concat([Buffer.from(e.toLowerCase()),t]);return 0===this.data.length?Uint8Array.from([]):y.byteHash(a.concat([r,this.data]))},t.prototype.toAccountHashStr=function(){var e=this.toAccountHash();return"account-hash-"+Buffer.from(e).toString("hex")},t.prototype.value=function(){return this.data},t.fromEd25519=function(e){return new t(e,i.ED25519)},t.fromSecp256K1=function(e){return new t(e,i.SECP256K1)},t.fromHex=function(e){if(e.length<2)throw new Error("Asymmetric key error: too short");if(!/^0(1[0-9a-fA-F]{64}|2[0-9a-fA-F]{66})$/.test(e))throw new Error("Invalid public key");var r=p.decodeBase16(e);return new t(r.subarray(1),r[0])},t}(u.CLValue);t.CLPublicKey=h},5159:function(e,t,r){var n,o=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0}),t.CLResult=t.CLResultBytesParser=t.CLResultType=void 0;var i=r(7107),a=r(4103),s=r(9486),u=r(7009),c=function(e){function t(t){var r=t.ok,n=t.err,o=e.call(this)||this;return o.linksTo=y,o.tag=u.CLTypeTag.Result,o.innerOk=r,o.innerErr=n,o}return o(t,e),t.prototype.toString=function(){return u.RESULT_ID+" (OK: "+this.innerOk.toString()+", ERR: "+this.innerOk.toString()+")"},t.prototype.toBytes=function(){return a.concat([Uint8Array.from([this.tag]),this.innerOk.toBytes(),this.innerErr.toBytes()])},t.prototype.toJSON=function(){var e;return(e={})[u.RESULT_ID]={ok:this.innerOk.toJSON(),err:this.innerErr.toJSON()},e},t}(s.CLType);t.CLResultType=c;var p=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return o(t,e),t.prototype.toBytes=function(e){if(e.isOk()&&e.data.val.isCLValue)return i.Ok(a.concat([Uint8Array.from([1]),s.CLValueParsers.toBytes(e.data.val).unwrap()]));if(e.isError())return i.Ok(a.concat([Uint8Array.from([0]),s.CLValueParsers.toBytes(e.data.val).unwrap()]));throw new Error("Unproper data stored in CLResult")},t.prototype.fromBytesWithRemainder=function(e,t){var r=(new s.CLU8BytesParser).fromBytesWithRemainder(e),n=r.result,o=r.remainder;if(!o)return s.resultHelper(i.Err(s.CLErrorCodes.EarlyEndOfStream));var a=n.unwrap().value().toNumber(),u=t.innerErr,c=t.innerOk;if(0===a){var p=s.matchByteParserByCLType(u).unwrap().fromBytesWithRemainder(o,t.innerErr),l=p.result,f=p.remainder,d=new y(i.Err(l.unwrap()),{ok:c,err:u});return s.resultHelper(i.Ok(d),f)}if(1===a){var h=s.matchByteParserByCLType(c).unwrap().fromBytesWithRemainder(o,t.innerOk);return l=h.result,f=h.remainder,d=new y(i.Ok(l.unwrap()),{ok:c,err:u}),s.resultHelper(i.Ok(d),f)}return s.resultHelper(i.Err(s.CLErrorCodes.Formatting))},t}(s.CLValueBytesParsers);t.CLResultBytesParser=p;var y=function(e){function t(t,r){var n=r.ok,o=r.err,i=e.call(this)||this;return i.data=t,i.innerOk=n,i.innerErr=o,i}return o(t,e),t.prototype.value=function(){return this.data},t.prototype.isError=function(){return this.data.err&&!this.data.ok},t.prototype.isOk=function(){return this.data.ok&&!this.data.err},t.prototype.clType=function(){return new c({ok:this.innerOk,err:this.innerErr})},t}(s.CLValue);t.CLResult=y},8641:function(e,t,r){var n,o=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0}),t.CLString=t.CLStringBytesParser=t.CLStringType=void 0;var i=r(7107),a=r(9486),s=r(7009),u=r(6138),c=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.linksTo=y,t.tag=s.CLTypeTag.String,t}return o(t,e),t.prototype.toString=function(){return s.STRING_ID},t.prototype.toJSON=function(){return this.toString()},t}(a.CLType);t.CLStringType=c;var p=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return o(t,e),t.prototype.toBytes=function(e){return i.Ok(u.toBytesString(e.data))},t.prototype.fromBytesWithRemainder=function(e){var t=(new a.CLU32BytesParser).fromBytesWithRemainder(e),r=t.result,n=t.remainder,o=r.unwrap().value().toNumber();if(n){var s=u.fromBytesString(n.subarray(0,o));return a.resultHelper(i.Ok(new y(s)),n.subarray(o))}return a.resultHelper(i.Err(a.CLErrorCodes.EarlyEndOfStream))},t}(a.CLValueBytesParsers);t.CLStringBytesParser=p;var y=function(e){function t(t){var r=e.call(this)||this;if("string"!=typeof t)throw new Error("Wrong data type, you should provide string, but you provided "+typeof t);return r.data=t,r}return o(t,e),t.prototype.clType=function(){return new c},t.prototype.value=function(){return this.data},t.prototype.size=function(){return this.data.length},t}(a.CLValue);t.CLString=y},932:function(e,t,r){var n,o=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),i=this&&this.__spreadArrays||function(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;var n=Array(e),o=0;for(t=0;t<r;t++)for(var i=arguments[t],a=0,s=i.length;a<s;a++,o++)n[o]=i[a];return n};Object.defineProperty(t,"__esModule",{value:!0}),t.CLTuple3=t.CLTuple3Type=t.CLTuple2=t.CLTuple2Type=t.CLTuple1=t.CLTuple1Type=t.CLTupleBytesParser=t.CLTupleType=void 0;var a=r(7107),s=r(4103),u=r(9486),c=r(9591),p=r(7009),y=function(e){function t(t,r,n){var o=e.call(this)||this;return o.inner=t,o.linksTo=r,o.tag=n,o}return o(t,e),t.prototype.toString=function(){var e=this.inner.map((function(e){return e.toString()})).join(", ");return"Tuple"+this.inner.length+" ("+e+")"},t.prototype.toJSON=function(){var e;return(e={})[c.TUPLE_MATCH_LEN_TO_ID[this.inner.length-1]]=this.inner.map((function(e){return e.toJSON()})),e},t.prototype.toBytes=function(){var e=this.inner.map((function(e){return e.toBytes()}));return s.concat(i([Uint8Array.from([this.tag])],e))},t}(u.CLType);t.CLTupleType=y;var l=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return o(t,e),t.prototype.toBytes=function(e){return a.Ok(s.concat(e.data.map((function(e){return u.CLValueParsers.toBytes(e).unwrap()}))))},t.prototype.fromBytesWithRemainder=function(e,t){var r=e,n=t.inner.map((function(e){var t=u.matchByteParserByCLType(e).unwrap().fromBytesWithRemainder(r,e),n=t.result,o=t.remainder;return r=o,n.unwrap()}));return 1===n.length?u.resultHelper(a.Ok(new h(n)),r):2===n.length?u.resultHelper(a.Ok(new m(n)),r):3===n.length?u.resultHelper(a.Ok(new b(n)),r):u.resultHelper(a.Err(u.CLErrorCodes.Formatting))},t}(u.CLValueBytesParsers);t.CLTupleBytesParser=l;var f=function(e){function t(t,r){var n=e.call(this)||this;if(r.length>t)throw new Error("Too many elements!");if(!r.every((function(e){return e instanceof u.CLValue})))throw Error("Invalid data type(s) provided.");return n.tupleSize=t,n.data=r,n}return o(t,e),t.prototype.get=function(e){return this.data[e]},t.prototype.set=function(e,t){if(e>=this.tupleSize)throw new Error("Tuple index out of bounds.");this.data[e]=t},t.prototype.push=function(e){if(!(this.data.length<this.tupleSize))throw new Error("No more space in this tuple!");this.data.push(e)},t.prototype.value=function(){return this.data},t}(u.CLValue),d=function(e){function t(t){return e.call(this,t,h,p.CLTypeTag.Tuple1)||this}return o(t,e),t}(y);t.CLTuple1Type=d;var h=function(e){function t(t){return e.call(this,1,t)||this}return o(t,e),t.prototype.clType=function(){return new d(this.data.map((function(e){return e.clType()})))},t}(f);t.CLTuple1=h;var g=function(e){function t(t){return e.call(this,t,m,p.CLTypeTag.Tuple2)||this}return o(t,e),t}(y);t.CLTuple2Type=g;var m=function(e){function t(t){return e.call(this,2,t)||this}return o(t,e),t.prototype.clType=function(){return new g(this.data.map((function(e){return e.clType()})))},t}(f);t.CLTuple2=m;var v=function(e){function t(t){return e.call(this,t,b,p.CLTypeTag.Tuple3)||this}return o(t,e),t}(y);t.CLTuple3Type=v;var b=function(e){function t(t){return e.call(this,3,t)||this}return o(t,e),t.prototype.clType=function(){return new v(this.data.map((function(e){return e.clType()})))},t}(f);t.CLTuple3=b},3300:function(e,t,r){var n,o=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0}),t.CLURef=t.CLURefBytesParser=t.CLURefType=t.AccessRights=void 0;var i,a=r(4103),s=r(7107),u=r(9486),c=r(7009),p=r(1417);!function(e){e[e.None=0]="None",e[e.READ=1]="READ",e[e.WRITE=2]="WRITE",e[e.ADD=4]="ADD",e[e.READ_WRITE=3]="READ_WRITE",e[e.READ_ADD=5]="READ_ADD",e[e.ADD_WRITE=6]="ADD_WRITE",e[e.READ_ADD_WRITE=7]="READ_ADD_WRITE"}(i=t.AccessRights||(t.AccessRights={}));var y=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.linksTo=d,t.tag=c.CLTypeTag.URef,t}return o(t,e),t.prototype.toString=function(){return c.UREF_ID},t.prototype.toJSON=function(){return this.toString()},t}(u.CLType);t.CLURefType=y;var l="uref",f=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return o(t,e),t.prototype.toBytes=function(e){return s.Ok(a.concat([e.data,Uint8Array.from([e.accessRights])]))},t.prototype.fromBytesWithRemainder=function(e){if(e.length<33)return u.resultHelper(s.Err(u.CLErrorCodes.EarlyEndOfStream));var t=e.subarray(0,32),r=e[32],n=new d(t,r);return u.resultHelper(s.Ok(n),e.subarray(33))},t}(u.CLValueBytesParsers);t.CLURefBytesParser=f;var d=function(e){function t(t,r){var n=e.call(this)||this;if(32!==t.byteLength)throw new Error("The length of URefAddr should be 32");if(!Object.values(i).includes(r))throw new Error("Unsuported AccessRights");return n.data=t,n.accessRights=r,n}return o(t,e),t.fromFormattedStr=function(e){if(!e.startsWith(l+"-"))throw new Error("Prefix is not 'uref-'");var r=e.substring((l+"-").length).split("-",2);if(2!==r.length)throw new Error("No access rights as suffix");return new t(p.decodeBase16(r[0]),parseInt(r[1],8))},t.prototype.toFormattedStr=function(){return[l,p.encodeBase16(this.data),u.padNum(this.accessRights.toString(8),3)].join("-")},t.prototype.clType=function(){return new y},t.prototype.value=function(){return{data:this.data,accessRights:this.accessRights}},t}(u.CLValue);t.CLURef=d},8830:function(e,t,r){var n,o=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0}),t.CLUnit=t.CLUnitBytesParser=t.CLUnitType=void 0;var i=r(7107),a=r(9486),s=r(7009),u=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.tag=s.CLTypeTag.Unit,t.linksTo=p,t}return o(t,e),t.prototype.toString=function(){return s.UNIT_ID},t.prototype.toJSON=function(){return this.toString()},t}(a.CLType);t.CLUnitType=u;var c=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return o(t,e),t.prototype.toBytes=function(){return i.Ok(Uint8Array.from([]))},t.prototype.fromBytesWithRemainder=function(e){return a.resultHelper(i.Ok(new p),e)},t}(a.CLValueBytesParsers);t.CLUnitBytesParser=c;var p=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.data=void 0,t}return o(t,e),t.prototype.clType=function(){return new u},t.prototype.value=function(){return this.data},t}(a.CLValue);t.CLUnit=p},7009:(e,t)=>{var r,n,o;Object.defineProperty(t,"__esModule",{value:!0}),t.ACCOUNT_HASH_ID=t.TUPLE3_ID=t.TUPLE2_ID=t.TUPLE1_ID=t.RESULT_ID=t.OPTION_ID=t.MAP_ID=t.LIST_ID=t.BYTE_ARRAY_ID=t.U512_ID=t.U256_ID=t.U128_ID=t.U64_ID=t.U32_ID=t.U8_ID=t.I64_ID=t.I32_ID=t.UNIT_ID=t.UREF_ID=t.STRING_ID=t.PUBLIC_KEY_ID=t.KEY_ID=t.BOOL_ID=t.CLTypeTag=t.KeyVariant=t.CLErrorCodes=t.ACCOUNT_HASH_LENGTH=void 0,t.ACCOUNT_HASH_LENGTH=32,(o=t.CLErrorCodes||(t.CLErrorCodes={}))[o.EarlyEndOfStream=0]="EarlyEndOfStream",o[o.Formatting=1]="Formatting",o.LeftOverBytes="Left over bytes",o.OutOfMemory="Out of memory exception",o.UnknownValue="Unknown value",(n=t.KeyVariant||(t.KeyVariant={}))[n.Account=0]="Account",n[n.Hash=1]="Hash",n[n.URef=2]="URef",(r=t.CLTypeTag||(t.CLTypeTag={}))[r.Bool=0]="Bool",r[r.I32=1]="I32",r[r.I64=2]="I64",r[r.U8=3]="U8",r[r.U32=4]="U32",r[r.U64=5]="U64",r[r.U128=6]="U128",r[r.U256=7]="U256",r[r.U512=8]="U512",r[r.Unit=9]="Unit",r[r.String=10]="String",r[r.Key=11]="Key",r[r.URef=12]="URef",r[r.Option=13]="Option",r[r.List=14]="List",r[r.ByteArray=15]="ByteArray",r[r.Result=16]="Result",r[r.Map=17]="Map",r[r.Tuple1=18]="Tuple1",r[r.Tuple2=19]="Tuple2",r[r.Tuple3=20]="Tuple3",r[r.Any=21]="Any",r[r.PublicKey=22]="PublicKey",t.BOOL_ID="Bool",t.KEY_ID="Key",t.PUBLIC_KEY_ID="PublicKey",t.STRING_ID="String",t.UREF_ID="URef",t.UNIT_ID="Unit",t.I32_ID="I32",t.I64_ID="I64",t.U8_ID="U8",t.U32_ID="U32",t.U64_ID="U64",t.U128_ID="U128",t.U256_ID="U256",t.U512_ID="U512",t.BYTE_ARRAY_ID="ByteArray",t.LIST_ID="List",t.MAP_ID="Map",t.OPTION_ID="Option",t.RESULT_ID="Result",t.TUPLE1_ID="Tuple1",t.TUPLE2_ID="Tuple2",t.TUPLE3_ID="Tuple3",t.ACCOUNT_HASH_ID="AccountHash"},9486:function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||t.hasOwnProperty(r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),o(r(7066),t),o(r(4259),t),o(r(401),t),o(r(4381),t),o(r(9403),t),o(r(547),t),o(r(9439),t),o(r(1533),t),o(r(8641),t),o(r(932),t),o(r(3300),t),o(r(8830),t),o(r(305),t),o(r(5110),t),o(r(3300),t),o(r(5159),t),o(r(2285),t),o(r(7009),t),o(r(9591),t)},9591:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.padNum=t.matchBytesToCLType=t.matchByteParserByCLType=t.matchTypeToCLType=t.TUPLE_MATCH_LEN_TO_ID=void 0;var n=r(7107),o=r(7009),i=r(9486);t.TUPLE_MATCH_LEN_TO_ID=[o.TUPLE1_ID,o.TUPLE2_ID,o.TUPLE3_ID],t.matchTypeToCLType=function(e){if("string"==typeof e)switch(e){case o.BOOL_ID:return new i.CLBoolType;case o.KEY_ID:return new i.CLKeyType;case o.PUBLIC_KEY_ID:return new i.CLPublicKeyType;case o.STRING_ID:return new i.CLStringType;case o.UREF_ID:return new i.CLURefType;case o.UNIT_ID:return new i.CLUnitType;case o.I32_ID:return new i.CLI32Type;case o.I64_ID:return new i.CLI64Type;case o.U8_ID:return new i.CLU8Type;case o.U32_ID:return new i.CLU32Type;case o.U64_ID:return new i.CLU64Type;case o.U128_ID:return new i.CLU128Type;case o.U256_ID:return new i.CLU256Type;case o.U512_ID:return new i.CLU512Type;default:throw new Error("The simple type "+e+" is not supported")}if(typeof e==typeof{}){if(o.LIST_ID in e){var r=t.matchTypeToCLType(e[o.LIST_ID]);return new i.CLListType(r)}if(o.BYTE_ARRAY_ID in e){var n=e[o.BYTE_ARRAY_ID];return new i.CLByteArrayType(n)}if(o.MAP_ID in e){var a=t.matchTypeToCLType(e[o.MAP_ID].key),s=t.matchTypeToCLType(e[o.MAP_ID].value);return new i.CLMapType([a,s])}if(o.TUPLE1_ID in e){var u=e[o.TUPLE1_ID].map((function(e){return t.matchTypeToCLType(e)}));return new i.CLTuple1Type(u)}if(o.TUPLE2_ID in e)return u=e[o.TUPLE2_ID].map((function(e){return t.matchTypeToCLType(e)})),new i.CLTuple2Type(u);if(o.TUPLE3_ID in e)return u=e[o.TUPLE3_ID].map((function(e){return t.matchTypeToCLType(e)})),new i.CLTuple3Type(u);if(o.OPTION_ID in e)return r=t.matchTypeToCLType(e[o.OPTION_ID]),new i.CLOptionType(r);if(o.RESULT_ID in e){var c=t.matchTypeToCLType(e[o.RESULT_ID].ok),p=t.matchTypeToCLType(e[o.RESULT_ID].err);return new i.CLResultType({ok:c,err:p})}throw new Error("The complex type "+e+" is not supported")}throw new Error("Unknown data provided.")},t.matchByteParserByCLType=function(e){return e.tag===o.CLTypeTag.Bool?n.Ok(new i.CLBoolBytesParser):e.tag===o.CLTypeTag.I32?n.Ok(new i.CLI32BytesParser):e.tag===o.CLTypeTag.I64?n.Ok(new i.CLI64BytesParser):e.tag===o.CLTypeTag.U8?n.Ok(new i.CLU8BytesParser):e.tag===o.CLTypeTag.U32?n.Ok(new i.CLU32BytesParser):e.tag===o.CLTypeTag.U64?n.Ok(new i.CLU64BytesParser):e.tag===o.CLTypeTag.U128?n.Ok(new i.CLU128BytesParser):e.tag===o.CLTypeTag.U256?n.Ok(new i.CLU256BytesParser):e.tag===o.CLTypeTag.U512?n.Ok(new i.CLU512BytesParser):e.tag===o.CLTypeTag.ByteArray?n.Ok(new i.CLByteArrayBytesParser):e.tag===o.CLTypeTag.URef?n.Ok(new i.CLURefBytesParser):e