UNPKG

croak-wallet-sdk

Version:

Guide for installation and usage of Croak's Web3 walllet.

1 lines 1.69 MB
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.croakWalletSdk=f()}})(function(){var define,module,exports;return function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r}()({1:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.version=void 0;exports.version="abi/5.6.3"},{}],2:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.defaultAbiCoder=exports.AbiCoder=void 0;var bytes_1=require("@ethersproject/bytes");var properties_1=require("@ethersproject/properties");var logger_1=require("@ethersproject/logger");var _version_1=require("./_version");var logger=new logger_1.Logger(_version_1.version);var abstract_coder_1=require("./coders/abstract-coder");var address_1=require("./coders/address");var array_1=require("./coders/array");var boolean_1=require("./coders/boolean");var bytes_2=require("./coders/bytes");var fixed_bytes_1=require("./coders/fixed-bytes");var null_1=require("./coders/null");var number_1=require("./coders/number");var string_1=require("./coders/string");var tuple_1=require("./coders/tuple");var fragments_1=require("./fragments");var paramTypeBytes=new RegExp(/^bytes([0-9]*)$/);var paramTypeNumber=new RegExp(/^(u?int)([0-9]*)$/);var AbiCoder=function(){function AbiCoder(coerceFunc){(0,properties_1.defineReadOnly)(this,"coerceFunc",coerceFunc||null)}AbiCoder.prototype._getCoder=function(param){var _this=this;switch(param.baseType){case"address":return new address_1.AddressCoder(param.name);case"bool":return new boolean_1.BooleanCoder(param.name);case"string":return new string_1.StringCoder(param.name);case"bytes":return new bytes_2.BytesCoder(param.name);case"array":return new array_1.ArrayCoder(this._getCoder(param.arrayChildren),param.arrayLength,param.name);case"tuple":return new tuple_1.TupleCoder((param.components||[]).map(function(component){return _this._getCoder(component)}),param.name);case"":return new null_1.NullCoder(param.name)}var match=param.type.match(paramTypeNumber);if(match){var size=parseInt(match[2]||"256");if(size===0||size>256||size%8!==0){logger.throwArgumentError("invalid "+match[1]+" bit length","param",param)}return new number_1.NumberCoder(size/8,match[1]==="int",param.name)}match=param.type.match(paramTypeBytes);if(match){var size=parseInt(match[1]);if(size===0||size>32){logger.throwArgumentError("invalid bytes length","param",param)}return new fixed_bytes_1.FixedBytesCoder(size,param.name)}return logger.throwArgumentError("invalid type","type",param.type)};AbiCoder.prototype._getWordSize=function(){return 32};AbiCoder.prototype._getReader=function(data,allowLoose){return new abstract_coder_1.Reader(data,this._getWordSize(),this.coerceFunc,allowLoose)};AbiCoder.prototype._getWriter=function(){return new abstract_coder_1.Writer(this._getWordSize())};AbiCoder.prototype.getDefaultValue=function(types){var _this=this;var coders=types.map(function(type){return _this._getCoder(fragments_1.ParamType.from(type))});var coder=new tuple_1.TupleCoder(coders,"_");return coder.defaultValue()};AbiCoder.prototype.encode=function(types,values){var _this=this;if(types.length!==values.length){logger.throwError("types/values length mismatch",logger_1.Logger.errors.INVALID_ARGUMENT,{count:{types:types.length,values:values.length},value:{types:types,values:values}})}var coders=types.map(function(type){return _this._getCoder(fragments_1.ParamType.from(type))});var coder=new tuple_1.TupleCoder(coders,"_");var writer=this._getWriter();coder.encode(writer,values);return writer.data};AbiCoder.prototype.decode=function(types,data,loose){var _this=this;var coders=types.map(function(type){return _this._getCoder(fragments_1.ParamType.from(type))});var coder=new tuple_1.TupleCoder(coders,"_");return coder.decode(this._getReader((0,bytes_1.arrayify)(data),loose))};return AbiCoder}();exports.AbiCoder=AbiCoder;exports.defaultAbiCoder=new AbiCoder},{"./_version":1,"./coders/abstract-coder":3,"./coders/address":4,"./coders/array":6,"./coders/boolean":7,"./coders/bytes":8,"./coders/fixed-bytes":9,"./coders/null":10,"./coders/number":11,"./coders/string":12,"./coders/tuple":13,"./fragments":14,"@ethersproject/bytes":31,"@ethersproject/logger":55,"@ethersproject/properties":61}],3:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.Reader=exports.Writer=exports.Coder=exports.checkResultErrors=void 0;var bytes_1=require("@ethersproject/bytes");var bignumber_1=require("@ethersproject/bignumber");var properties_1=require("@ethersproject/properties");var logger_1=require("@ethersproject/logger");var _version_1=require("../_version");var logger=new logger_1.Logger(_version_1.version);function checkResultErrors(result){var errors=[];var checkErrors=function(path,object){if(!Array.isArray(object)){return}for(var key in object){var childPath=path.slice();childPath.push(key);try{checkErrors(childPath,object[key])}catch(error){errors.push({path:childPath,error:error})}}};checkErrors([],result);return errors}exports.checkResultErrors=checkResultErrors;var Coder=function(){function Coder(name,type,localName,dynamic){this.name=name;this.type=type;this.localName=localName;this.dynamic=dynamic}Coder.prototype._throwError=function(message,value){logger.throwArgumentError(message,this.localName,value)};return Coder}();exports.Coder=Coder;var Writer=function(){function Writer(wordSize){(0,properties_1.defineReadOnly)(this,"wordSize",wordSize||32);this._data=[];this._dataLength=0;this._padding=new Uint8Array(wordSize)}Object.defineProperty(Writer.prototype,"data",{get:function(){return(0,bytes_1.hexConcat)(this._data)},enumerable:false,configurable:true});Object.defineProperty(Writer.prototype,"length",{get:function(){return this._dataLength},enumerable:false,configurable:true});Writer.prototype._writeData=function(data){this._data.push(data);this._dataLength+=data.length;return data.length};Writer.prototype.appendWriter=function(writer){return this._writeData((0,bytes_1.concat)(writer._data))};Writer.prototype.writeBytes=function(value){var bytes=(0,bytes_1.arrayify)(value);var paddingOffset=bytes.length%this.wordSize;if(paddingOffset){bytes=(0,bytes_1.concat)([bytes,this._padding.slice(paddingOffset)])}return this._writeData(bytes)};Writer.prototype._getValue=function(value){var bytes=(0,bytes_1.arrayify)(bignumber_1.BigNumber.from(value));if(bytes.length>this.wordSize){logger.throwError("value out-of-bounds",logger_1.Logger.errors.BUFFER_OVERRUN,{length:this.wordSize,offset:bytes.length})}if(bytes.length%this.wordSize){bytes=(0,bytes_1.concat)([this._padding.slice(bytes.length%this.wordSize),bytes])}return bytes};Writer.prototype.writeValue=function(value){return this._writeData(this._getValue(value))};Writer.prototype.writeUpdatableValue=function(){var _this=this;var offset=this._data.length;this._data.push(this._padding);this._dataLength+=this.wordSize;return function(value){_this._data[offset]=_this._getValue(value)}};return Writer}();exports.Writer=Writer;var Reader=function(){function Reader(data,wordSize,coerceFunc,allowLoose){(0,properties_1.defineReadOnly)(this,"_data",(0,bytes_1.arrayify)(data));(0,properties_1.defineReadOnly)(this,"wordSize",wordSize||32);(0,properties_1.defineReadOnly)(this,"_coerceFunc",coerceFunc);(0,properties_1.defineReadOnly)(this,"allowLoose",allowLoose);this._offset=0}Object.defineProperty(Reader.prototype,"data",{get:function(){return(0,bytes_1.hexlify)(this._data)},enumerable:false,configurable:true});Object.defineProperty(Reader.prototype,"consumed",{get:function(){return this._offset},enumerable:false,configurable:true});Reader.coerce=function(name,value){var match=name.match("^u?int([0-9]+)$");if(match&&parseInt(match[1])<=48){value=value.toNumber()}return value};Reader.prototype.coerce=function(name,value){if(this._coerceFunc){return this._coerceFunc(name,value)}return Reader.coerce(name,value)};Reader.prototype._peekBytes=function(offset,length,loose){var alignedLength=Math.ceil(length/this.wordSize)*this.wordSize;if(this._offset+alignedLength>this._data.length){if(this.allowLoose&&loose&&this._offset+length<=this._data.length){alignedLength=length}else{logger.throwError("data out-of-bounds",logger_1.Logger.errors.BUFFER_OVERRUN,{length:this._data.length,offset:this._offset+alignedLength})}}return this._data.slice(this._offset,this._offset+alignedLength)};Reader.prototype.subReader=function(offset){return new Reader(this._data.slice(this._offset+offset),this.wordSize,this._coerceFunc,this.allowLoose)};Reader.prototype.readBytes=function(length,loose){var bytes=this._peekBytes(0,length,!!loose);this._offset+=bytes.length;return bytes.slice(0,length)};Reader.prototype.readValue=function(){return bignumber_1.BigNumber.from(this.readBytes(this.wordSize))};return Reader}();exports.Reader=Reader},{"../_version":1,"@ethersproject/bignumber":29,"@ethersproject/bytes":31,"@ethersproject/logger":55,"@ethersproject/properties":61}],4:[function(require,module,exports){"use strict";var __extends=this&&this.__extends||function(){var extendStatics=function(d,b){extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b}||function(d,b){for(var p in b)if(Object.prototype.hasOwnProperty.call(b,p))d[p]=b[p]};return extendStatics(d,b)};return function(d,b){if(typeof b!=="function"&&b!==null)throw new TypeError("Class extends value "+String(b)+" is not a constructor or null");extendStatics(d,b);function __(){this.constructor=d}d.prototype=b===null?Object.create(b):(__.prototype=b.prototype,new __)}}();Object.defineProperty(exports,"__esModule",{value:true});exports.AddressCoder=void 0;var address_1=require("@ethersproject/address");var bytes_1=require("@ethersproject/bytes");var abstract_coder_1=require("./abstract-coder");var AddressCoder=function(_super){__extends(AddressCoder,_super);function AddressCoder(localName){return _super.call(this,"address","address",localName,false)||this}AddressCoder.prototype.defaultValue=function(){return"0x0000000000000000000000000000000000000000"};AddressCoder.prototype.encode=function(writer,value){try{value=(0,address_1.getAddress)(value)}catch(error){this._throwError(error.message,value)}return writer.writeValue(value)};AddressCoder.prototype.decode=function(reader){return(0,address_1.getAddress)((0,bytes_1.hexZeroPad)(reader.readValue().toHexString(),20))};return AddressCoder}(abstract_coder_1.Coder);exports.AddressCoder=AddressCoder},{"./abstract-coder":3,"@ethersproject/address":22,"@ethersproject/bytes":31}],5:[function(require,module,exports){"use strict";var __extends=this&&this.__extends||function(){var extendStatics=function(d,b){extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b}||function(d,b){for(var p in b)if(Object.prototype.hasOwnProperty.call(b,p))d[p]=b[p]};return extendStatics(d,b)};return function(d,b){if(typeof b!=="function"&&b!==null)throw new TypeError("Class extends value "+String(b)+" is not a constructor or null");extendStatics(d,b);function __(){this.constructor=d}d.prototype=b===null?Object.create(b):(__.prototype=b.prototype,new __)}}();Object.defineProperty(exports,"__esModule",{value:true});exports.AnonymousCoder=void 0;var abstract_coder_1=require("./abstract-coder");var AnonymousCoder=function(_super){__extends(AnonymousCoder,_super);function AnonymousCoder(coder){var _this=_super.call(this,coder.name,coder.type,undefined,coder.dynamic)||this;_this.coder=coder;return _this}AnonymousCoder.prototype.defaultValue=function(){return this.coder.defaultValue()};AnonymousCoder.prototype.encode=function(writer,value){return this.coder.encode(writer,value)};AnonymousCoder.prototype.decode=function(reader){return this.coder.decode(reader)};return AnonymousCoder}(abstract_coder_1.Coder);exports.AnonymousCoder=AnonymousCoder},{"./abstract-coder":3}],6:[function(require,module,exports){"use strict";var __extends=this&&this.__extends||function(){var extendStatics=function(d,b){extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b}||function(d,b){for(var p in b)if(Object.prototype.hasOwnProperty.call(b,p))d[p]=b[p]};return extendStatics(d,b)};return function(d,b){if(typeof b!=="function"&&b!==null)throw new TypeError("Class extends value "+String(b)+" is not a constructor or null");extendStatics(d,b);function __(){this.constructor=d}d.prototype=b===null?Object.create(b):(__.prototype=b.prototype,new __)}}();Object.defineProperty(exports,"__esModule",{value:true});exports.ArrayCoder=exports.unpack=exports.pack=void 0;var logger_1=require("@ethersproject/logger");var _version_1=require("../_version");var logger=new logger_1.Logger(_version_1.version);var abstract_coder_1=require("./abstract-coder");var anonymous_1=require("./anonymous");function pack(writer,coders,values){var arrayValues=null;if(Array.isArray(values)){arrayValues=values}else if(values&&typeof values==="object"){var unique_1={};arrayValues=coders.map(function(coder){var name=coder.localName;if(!name){logger.throwError("cannot encode object for signature with missing names",logger_1.Logger.errors.INVALID_ARGUMENT,{argument:"values",coder:coder,value:values})}if(unique_1[name]){logger.throwError("cannot encode object for signature with duplicate names",logger_1.Logger.errors.INVALID_ARGUMENT,{argument:"values",coder:coder,value:values})}unique_1[name]=true;return values[name]})}else{logger.throwArgumentError("invalid tuple value","tuple",values)}if(coders.length!==arrayValues.length){logger.throwArgumentError("types/value length mismatch","tuple",values)}var staticWriter=new abstract_coder_1.Writer(writer.wordSize);var dynamicWriter=new abstract_coder_1.Writer(writer.wordSize);var updateFuncs=[];coders.forEach(function(coder,index){var value=arrayValues[index];if(coder.dynamic){var dynamicOffset_1=dynamicWriter.length;coder.encode(dynamicWriter,value);var updateFunc_1=staticWriter.writeUpdatableValue();updateFuncs.push(function(baseOffset){updateFunc_1(baseOffset+dynamicOffset_1)})}else{coder.encode(staticWriter,value)}});updateFuncs.forEach(function(func){func(staticWriter.length)});var length=writer.appendWriter(staticWriter);length+=writer.appendWriter(dynamicWriter);return length}exports.pack=pack;function unpack(reader,coders){var values=[];var baseReader=reader.subReader(0);coders.forEach(function(coder){var value=null;if(coder.dynamic){var offset=reader.readValue();var offsetReader=baseReader.subReader(offset.toNumber());try{value=coder.decode(offsetReader)}catch(error){if(error.code===logger_1.Logger.errors.BUFFER_OVERRUN){throw error}value=error;value.baseType=coder.name;value.name=coder.localName;value.type=coder.type}}else{try{value=coder.decode(reader)}catch(error){if(error.code===logger_1.Logger.errors.BUFFER_OVERRUN){throw error}value=error;value.baseType=coder.name;value.name=coder.localName;value.type=coder.type}}if(value!=undefined){values.push(value)}});var uniqueNames=coders.reduce(function(accum,coder){var name=coder.localName;if(name){if(!accum[name]){accum[name]=0}accum[name]++}return accum},{});coders.forEach(function(coder,index){var name=coder.localName;if(!name||uniqueNames[name]!==1){return}if(name==="length"){name="_length"}if(values[name]!=null){return}var value=values[index];if(value instanceof Error){Object.defineProperty(values,name,{enumerable:true,get:function(){throw value}})}else{values[name]=value}});var _loop_1=function(i){var value=values[i];if(value instanceof Error){Object.defineProperty(values,i,{enumerable:true,get:function(){throw value}})}};for(var i=0;i<values.length;i++){_loop_1(i)}return Object.freeze(values)}exports.unpack=unpack;var ArrayCoder=function(_super){__extends(ArrayCoder,_super);function ArrayCoder(coder,length,localName){var _this=this;var type=coder.type+"["+(length>=0?length:"")+"]";var dynamic=length===-1||coder.dynamic;_this=_super.call(this,"array",type,localName,dynamic)||this;_this.coder=coder;_this.length=length;return _this}ArrayCoder.prototype.defaultValue=function(){var defaultChild=this.coder.defaultValue();var result=[];for(var i=0;i<this.length;i++){result.push(defaultChild)}return result};ArrayCoder.prototype.encode=function(writer,value){if(!Array.isArray(value)){this._throwError("expected array value",value)}var count=this.length;if(count===-1){count=value.length;writer.writeValue(value.length)}logger.checkArgumentCount(value.length,count,"coder array"+(this.localName?" "+this.localName:""));var coders=[];for(var i=0;i<value.length;i++){coders.push(this.coder)}return pack(writer,coders,value)};ArrayCoder.prototype.decode=function(reader){var count=this.length;if(count===-1){count=reader.readValue().toNumber();if(count*32>reader._data.length){logger.throwError("insufficient data length",logger_1.Logger.errors.BUFFER_OVERRUN,{length:reader._data.length,count:count})}}var coders=[];for(var i=0;i<count;i++){coders.push(new anonymous_1.AnonymousCoder(this.coder))}return reader.coerce(this.name,unpack(reader,coders))};return ArrayCoder}(abstract_coder_1.Coder);exports.ArrayCoder=ArrayCoder},{"../_version":1,"./abstract-coder":3,"./anonymous":5,"@ethersproject/logger":55}],7:[function(require,module,exports){"use strict";var __extends=this&&this.__extends||function(){var extendStatics=function(d,b){extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b}||function(d,b){for(var p in b)if(Object.prototype.hasOwnProperty.call(b,p))d[p]=b[p]};return extendStatics(d,b)};return function(d,b){if(typeof b!=="function"&&b!==null)throw new TypeError("Class extends value "+String(b)+" is not a constructor or null");extendStatics(d,b);function __(){this.constructor=d}d.prototype=b===null?Object.create(b):(__.prototype=b.prototype,new __)}}();Object.defineProperty(exports,"__esModule",{value:true});exports.BooleanCoder=void 0;var abstract_coder_1=require("./abstract-coder");var BooleanCoder=function(_super){__extends(BooleanCoder,_super);function BooleanCoder(localName){return _super.call(this,"bool","bool",localName,false)||this}BooleanCoder.prototype.defaultValue=function(){return false};BooleanCoder.prototype.encode=function(writer,value){return writer.writeValue(value?1:0)};BooleanCoder.prototype.decode=function(reader){return reader.coerce(this.type,!reader.readValue().isZero())};return BooleanCoder}(abstract_coder_1.Coder);exports.BooleanCoder=BooleanCoder},{"./abstract-coder":3}],8:[function(require,module,exports){"use strict";var __extends=this&&this.__extends||function(){var extendStatics=function(d,b){extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b}||function(d,b){for(var p in b)if(Object.prototype.hasOwnProperty.call(b,p))d[p]=b[p]};return extendStatics(d,b)};return function(d,b){if(typeof b!=="function"&&b!==null)throw new TypeError("Class extends value "+String(b)+" is not a constructor or null");extendStatics(d,b);function __(){this.constructor=d}d.prototype=b===null?Object.create(b):(__.prototype=b.prototype,new __)}}();Object.defineProperty(exports,"__esModule",{value:true});exports.BytesCoder=exports.DynamicBytesCoder=void 0;var bytes_1=require("@ethersproject/bytes");var abstract_coder_1=require("./abstract-coder");var DynamicBytesCoder=function(_super){__extends(DynamicBytesCoder,_super);function DynamicBytesCoder(type,localName){return _super.call(this,type,type,localName,true)||this}DynamicBytesCoder.prototype.defaultValue=function(){return"0x"};DynamicBytesCoder.prototype.encode=function(writer,value){value=(0,bytes_1.arrayify)(value);var length=writer.writeValue(value.length);length+=writer.writeBytes(value);return length};DynamicBytesCoder.prototype.decode=function(reader){return reader.readBytes(reader.readValue().toNumber(),true)};return DynamicBytesCoder}(abstract_coder_1.Coder);exports.DynamicBytesCoder=DynamicBytesCoder;var BytesCoder=function(_super){__extends(BytesCoder,_super);function BytesCoder(localName){return _super.call(this,"bytes",localName)||this}BytesCoder.prototype.decode=function(reader){return reader.coerce(this.name,(0,bytes_1.hexlify)(_super.prototype.decode.call(this,reader)))};return BytesCoder}(DynamicBytesCoder);exports.BytesCoder=BytesCoder},{"./abstract-coder":3,"@ethersproject/bytes":31}],9:[function(require,module,exports){"use strict";var __extends=this&&this.__extends||function(){var extendStatics=function(d,b){extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b}||function(d,b){for(var p in b)if(Object.prototype.hasOwnProperty.call(b,p))d[p]=b[p]};return extendStatics(d,b)};return function(d,b){if(typeof b!=="function"&&b!==null)throw new TypeError("Class extends value "+String(b)+" is not a constructor or null");extendStatics(d,b);function __(){this.constructor=d}d.prototype=b===null?Object.create(b):(__.prototype=b.prototype,new __)}}();Object.defineProperty(exports,"__esModule",{value:true});exports.FixedBytesCoder=void 0;var bytes_1=require("@ethersproject/bytes");var abstract_coder_1=require("./abstract-coder");var FixedBytesCoder=function(_super){__extends(FixedBytesCoder,_super);function FixedBytesCoder(size,localName){var _this=this;var name="bytes"+String(size);_this=_super.call(this,name,name,localName,false)||this;_this.size=size;return _this}FixedBytesCoder.prototype.defaultValue=function(){return"0x0000000000000000000000000000000000000000000000000000000000000000".substring(0,2+this.size*2)};FixedBytesCoder.prototype.encode=function(writer,value){var data=(0,bytes_1.arrayify)(value);if(data.length!==this.size){this._throwError("incorrect data length",value)}return writer.writeBytes(data)};FixedBytesCoder.prototype.decode=function(reader){return reader.coerce(this.name,(0,bytes_1.hexlify)(reader.readBytes(this.size)))};return FixedBytesCoder}(abstract_coder_1.Coder);exports.FixedBytesCoder=FixedBytesCoder},{"./abstract-coder":3,"@ethersproject/bytes":31}],10:[function(require,module,exports){"use strict";var __extends=this&&this.__extends||function(){var extendStatics=function(d,b){extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b}||function(d,b){for(var p in b)if(Object.prototype.hasOwnProperty.call(b,p))d[p]=b[p]};return extendStatics(d,b)};return function(d,b){if(typeof b!=="function"&&b!==null)throw new TypeError("Class extends value "+String(b)+" is not a constructor or null");extendStatics(d,b);function __(){this.constructor=d}d.prototype=b===null?Object.create(b):(__.prototype=b.prototype,new __)}}();Object.defineProperty(exports,"__esModule",{value:true});exports.NullCoder=void 0;var abstract_coder_1=require("./abstract-coder");var NullCoder=function(_super){__extends(NullCoder,_super);function NullCoder(localName){return _super.call(this,"null","",localName,false)||this}NullCoder.prototype.defaultValue=function(){return null};NullCoder.prototype.encode=function(writer,value){if(value!=null){this._throwError("not null",value)}return writer.writeBytes([])};NullCoder.prototype.decode=function(reader){reader.readBytes(0);return reader.coerce(this.name,null)};return NullCoder}(abstract_coder_1.Coder);exports.NullCoder=NullCoder},{"./abstract-coder":3}],11:[function(require,module,exports){"use strict";var __extends=this&&this.__extends||function(){var extendStatics=function(d,b){extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b}||function(d,b){for(var p in b)if(Object.prototype.hasOwnProperty.call(b,p))d[p]=b[p]};return extendStatics(d,b)};return function(d,b){if(typeof b!=="function"&&b!==null)throw new TypeError("Class extends value "+String(b)+" is not a constructor or null");extendStatics(d,b);function __(){this.constructor=d}d.prototype=b===null?Object.create(b):(__.prototype=b.prototype,new __)}}();Object.defineProperty(exports,"__esModule",{value:true});exports.NumberCoder=void 0;var bignumber_1=require("@ethersproject/bignumber");var constants_1=require("@ethersproject/constants");var abstract_coder_1=require("./abstract-coder");var NumberCoder=function(_super){__extends(NumberCoder,_super);function NumberCoder(size,signed,localName){var _this=this;var name=(signed?"int":"uint")+size*8;_this=_super.call(this,name,name,localName,false)||this;_this.size=size;_this.signed=signed;return _this}NumberCoder.prototype.defaultValue=function(){return 0};NumberCoder.prototype.encode=function(writer,value){var v=bignumber_1.BigNumber.from(value);var maxUintValue=constants_1.MaxUint256.mask(writer.wordSize*8);if(this.signed){var bounds=maxUintValue.mask(this.size*8-1);if(v.gt(bounds)||v.lt(bounds.add(constants_1.One).mul(constants_1.NegativeOne))){this._throwError("value out-of-bounds",value)}}else if(v.lt(constants_1.Zero)||v.gt(maxUintValue.mask(this.size*8))){this._throwError("value out-of-bounds",value)}v=v.toTwos(this.size*8).mask(this.size*8);if(this.signed){v=v.fromTwos(this.size*8).toTwos(8*writer.wordSize)}return writer.writeValue(v)};NumberCoder.prototype.decode=function(reader){var value=reader.readValue().mask(this.size*8);if(this.signed){value=value.fromTwos(this.size*8)}return reader.coerce(this.name,value)};return NumberCoder}(abstract_coder_1.Coder);exports.NumberCoder=NumberCoder},{"./abstract-coder":3,"@ethersproject/bignumber":29,"@ethersproject/constants":35}],12:[function(require,module,exports){"use strict";var __extends=this&&this.__extends||function(){var extendStatics=function(d,b){extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b}||function(d,b){for(var p in b)if(Object.prototype.hasOwnProperty.call(b,p))d[p]=b[p]};return extendStatics(d,b)};return function(d,b){if(typeof b!=="function"&&b!==null)throw new TypeError("Class extends value "+String(b)+" is not a constructor or null");extendStatics(d,b);function __(){this.constructor=d}d.prototype=b===null?Object.create(b):(__.prototype=b.prototype,new __)}}();Object.defineProperty(exports,"__esModule",{value:true});exports.StringCoder=void 0;var strings_1=require("@ethersproject/strings");var bytes_1=require("./bytes");var StringCoder=function(_super){__extends(StringCoder,_super);function StringCoder(localName){return _super.call(this,"string",localName)||this}StringCoder.prototype.defaultValue=function(){return""};StringCoder.prototype.encode=function(writer,value){return _super.prototype.encode.call(this,writer,(0,strings_1.toUtf8Bytes)(value))};StringCoder.prototype.decode=function(reader){return(0,strings_1.toUtf8String)(_super.prototype.decode.call(this,reader))};return StringCoder}(bytes_1.DynamicBytesCoder);exports.StringCoder=StringCoder},{"./bytes":8,"@ethersproject/strings":99}],13:[function(require,module,exports){"use strict";var __extends=this&&this.__extends||function(){var extendStatics=function(d,b){extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b}||function(d,b){for(var p in b)if(Object.prototype.hasOwnProperty.call(b,p))d[p]=b[p]};return extendStatics(d,b)};return function(d,b){if(typeof b!=="function"&&b!==null)throw new TypeError("Class extends value "+String(b)+" is not a constructor or null");extendStatics(d,b);function __(){this.constructor=d}d.prototype=b===null?Object.create(b):(__.prototype=b.prototype,new __)}}();Object.defineProperty(exports,"__esModule",{value:true});exports.TupleCoder=void 0;var abstract_coder_1=require("./abstract-coder");var array_1=require("./array");var TupleCoder=function(_super){__extends(TupleCoder,_super);function TupleCoder(coders,localName){var _this=this;var dynamic=false;var types=[];coders.forEach(function(coder){if(coder.dynamic){dynamic=true}types.push(coder.type)});var type="tuple("+types.join(",")+")";_this=_super.call(this,"tuple",type,localName,dynamic)||this;_this.coders=coders;return _this}TupleCoder.prototype.defaultValue=function(){var values=[];this.coders.forEach(function(coder){values.push(coder.defaultValue())});var uniqueNames=this.coders.reduce(function(accum,coder){var name=coder.localName;if(name){if(!accum[name]){accum[name]=0}accum[name]++}return accum},{});this.coders.forEach(function(coder,index){var name=coder.localName;if(!name||uniqueNames[name]!==1){return}if(name==="length"){name="_length"}if(values[name]!=null){return}values[name]=values[index]});return Object.freeze(values)};TupleCoder.prototype.encode=function(writer,value){return(0,array_1.pack)(writer,this.coders,value)};TupleCoder.prototype.decode=function(reader){return reader.coerce(this.name,(0,array_1.unpack)(reader,this.coders))};return TupleCoder}(abstract_coder_1.Coder);exports.TupleCoder=TupleCoder},{"./abstract-coder":3,"./array":6}],14:[function(require,module,exports){"use strict";var __extends=this&&this.__extends||function(){var extendStatics=function(d,b){extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b}||function(d,b){for(var p in b)if(Object.prototype.hasOwnProperty.call(b,p))d[p]=b[p]};return extendStatics(d,b)};return function(d,b){if(typeof b!=="function"&&b!==null)throw new TypeError("Class extends value "+String(b)+" is not a constructor or null");extendStatics(d,b);function __(){this.constructor=d}d.prototype=b===null?Object.create(b):(__.prototype=b.prototype,new __)}}();Object.defineProperty(exports,"__esModule",{value:true});exports.ErrorFragment=exports.FunctionFragment=exports.ConstructorFragment=exports.EventFragment=exports.Fragment=exports.ParamType=exports.FormatTypes=void 0;var bignumber_1=require("@ethersproject/bignumber");var properties_1=require("@ethersproject/properties");var logger_1=require("@ethersproject/logger");var _version_1=require("./_version");var logger=new logger_1.Logger(_version_1.version);var _constructorGuard={};var ModifiersBytes={calldata:true,memory:true,storage:true};var ModifiersNest={calldata:true,memory:true};function checkModifier(type,name){if(type==="bytes"||type==="string"){if(ModifiersBytes[name]){return true}}else if(type==="address"){if(name==="payable"){return true}}else if(type.indexOf("[")>=0||type==="tuple"){if(ModifiersNest[name]){return true}}if(ModifiersBytes[name]||name==="payable"){logger.throwArgumentError("invalid modifier","name",name)}return false}function parseParamType(param,allowIndexed){var originalParam=param;function throwError(i){logger.throwArgumentError("unexpected character at position "+i,"param",param)}param=param.replace(/\s/g," ");function newNode(parent){var node={type:"",name:"",parent:parent,state:{allowType:true}};if(allowIndexed){node.indexed=false}return node}var parent={type:"",name:"",state:{allowType:true}};var node=parent;for(var i=0;i<param.length;i++){var c=param[i];switch(c){case"(":if(node.state.allowType&&node.type===""){node.type="tuple"}else if(!node.state.allowParams){throwError(i)}node.state.allowType=false;node.type=verifyType(node.type);node.components=[newNode(node)];node=node.components[0];break;case")":delete node.state;if(node.name==="indexed"){if(!allowIndexed){throwError(i)}node.indexed=true;node.name=""}if(checkModifier(node.type,node.name)){node.name=""}node.type=verifyType(node.type);var child=node;node=node.parent;if(!node){throwError(i)}delete child.parent;node.state.allowParams=false;node.state.allowName=true;node.state.allowArray=true;break;case",":delete node.state;if(node.name==="indexed"){if(!allowIndexed){throwError(i)}node.indexed=true;node.name=""}if(checkModifier(node.type,node.name)){node.name=""}node.type=verifyType(node.type);var sibling=newNode(node.parent);node.parent.components.push(sibling);delete node.parent;node=sibling;break;case" ":if(node.state.allowType){if(node.type!==""){node.type=verifyType(node.type);delete node.state.allowType;node.state.allowName=true;node.state.allowParams=true}}if(node.state.allowName){if(node.name!==""){if(node.name==="indexed"){if(!allowIndexed){throwError(i)}if(node.indexed){throwError(i)}node.indexed=true;node.name=""}else if(checkModifier(node.type,node.name)){node.name=""}else{node.state.allowName=false}}}break;case"[":if(!node.state.allowArray){throwError(i)}node.type+=c;node.state.allowArray=false;node.state.allowName=false;node.state.readArray=true;break;case"]":if(!node.state.readArray){throwError(i)}node.type+=c;node.state.readArray=false;node.state.allowArray=true;node.state.allowName=true;break;default:if(node.state.allowType){node.type+=c;node.state.allowParams=true;node.state.allowArray=true}else if(node.state.allowName){node.name+=c;delete node.state.allowArray}else if(node.state.readArray){node.type+=c}else{throwError(i)}}}if(node.parent){logger.throwArgumentError("unexpected eof","param",param)}delete parent.state;if(node.name==="indexed"){if(!allowIndexed){throwError(originalParam.length-7)}if(node.indexed){throwError(originalParam.length-7)}node.indexed=true;node.name=""}else if(checkModifier(node.type,node.name)){node.name=""}parent.type=verifyType(parent.type);return parent}function populate(object,params){for(var key in params){(0,properties_1.defineReadOnly)(object,key,params[key])}}exports.FormatTypes=Object.freeze({sighash:"sighash",minimal:"minimal",full:"full",json:"json"});var paramTypeArray=new RegExp(/^(.*)\[([0-9]*)\]$/);var ParamType=function(){function ParamType(constructorGuard,params){if(constructorGuard!==_constructorGuard){logger.throwError("use fromString",logger_1.Logger.errors.UNSUPPORTED_OPERATION,{operation:"new ParamType()"})}populate(this,params);var match=this.type.match(paramTypeArray);if(match){populate(this,{arrayLength:parseInt(match[2]||"-1"),arrayChildren:ParamType.fromObject({type:match[1],components:this.components}),baseType:"array"})}else{populate(this,{arrayLength:null,arrayChildren:null,baseType:this.components!=null?"tuple":this.type})}this._isParamType=true;Object.freeze(this)}ParamType.prototype.format=function(format){if(!format){format=exports.FormatTypes.sighash}if(!exports.FormatTypes[format]){logger.throwArgumentError("invalid format type","format",format)}if(format===exports.FormatTypes.json){var result_1={type:this.baseType==="tuple"?"tuple":this.type,name:this.name||undefined};if(typeof this.indexed==="boolean"){result_1.indexed=this.indexed}if(this.components){result_1.components=this.components.map(function(comp){return JSON.parse(comp.format(format))})}return JSON.stringify(result_1)}var result="";if(this.baseType==="array"){result+=this.arrayChildren.format(format);result+="["+(this.arrayLength<0?"":String(this.arrayLength))+"]"}else{if(this.baseType==="tuple"){if(format!==exports.FormatTypes.sighash){result+=this.type}result+="("+this.components.map(function(comp){return comp.format(format)}).join(format===exports.FormatTypes.full?", ":",")+")"}else{result+=this.type}}if(format!==exports.FormatTypes.sighash){if(this.indexed===true){result+=" indexed"}if(format===exports.FormatTypes.full&&this.name){result+=" "+this.name}}return result};ParamType.from=function(value,allowIndexed){if(typeof value==="string"){return ParamType.fromString(value,allowIndexed)}return ParamType.fromObject(value)};ParamType.fromObject=function(value){if(ParamType.isParamType(value)){return value}return new ParamType(_constructorGuard,{name:value.name||null,type:verifyType(value.type),indexed:value.indexed==null?null:!!value.indexed,components:value.components?value.components.map(ParamType.fromObject):null})};ParamType.fromString=function(value,allowIndexed){function ParamTypify(node){return ParamType.fromObject({name:node.name,type:node.type,indexed:node.indexed,components:node.components})}return ParamTypify(parseParamType(value,!!allowIndexed))};ParamType.isParamType=function(value){return!!(value!=null&&value._isParamType)};return ParamType}();exports.ParamType=ParamType;function parseParams(value,allowIndex){return splitNesting(value).map(function(param){return ParamType.fromString(param,allowIndex)})}var Fragment=function(){function Fragment(constructorGuard,params){if(constructorGuard!==_constructorGuard){logger.throwError("use a static from method",logger_1.Logger.errors.UNSUPPORTED_OPERATION,{operation:"new Fragment()"})}populate(this,params);this._isFragment=true;Object.freeze(this)}Fragment.from=function(value){if(Fragment.isFragment(value)){return value}if(typeof value==="string"){return Fragment.fromString(value)}return Fragment.fromObject(value)};Fragment.fromObject=function(value){if(Fragment.isFragment(value)){return value}switch(value.type){case"function":return FunctionFragment.fromObject(value);case"event":return EventFragment.fromObject(value);case"constructor":return ConstructorFragment.fromObject(value);case"error":return ErrorFragment.fromObject(value);case"fallback":case"receive":return null}return logger.throwArgumentError("invalid fragment object","value",value)};Fragment.fromString=function(value){value=value.replace(/\s/g," ");value=value.replace(/\(/g," (").replace(/\)/g,") ").replace(/\s+/g," ");value=value.trim();if(value.split(" ")[0]==="event"){return EventFragment.fromString(value.substring(5).trim())}else if(value.split(" ")[0]==="function"){return FunctionFragment.fromString(value.substring(8).trim())}else if(value.split("(")[0].trim()==="constructor"){return ConstructorFragment.fromString(value.trim())}else if(value.split(" ")[0]==="error"){return ErrorFragment.fromString(value.substring(5).trim())}return logger.throwArgumentError("unsupported fragment","value",value)};Fragment.isFragment=function(value){return!!(value&&value._isFragment)};return Fragment}();exports.Fragment=Fragment;var EventFragment=function(_super){__extends(EventFragment,_super);function EventFragment(){return _super!==null&&_super.apply(this,arguments)||this}EventFragment.prototype.format=function(format){if(!format){format=exports.FormatTypes.sighash}if(!exports.FormatTypes[format]){logger.throwArgumentError("invalid format type","format",format)}if(format===exports.FormatTypes.json){return JSON.stringify({type:"event",anonymous:this.anonymous,name:this.name,inputs:this.inputs.map(function(input){return JSON.parse(input.format(format))})})}var result="";if(format!==exports.FormatTypes.sighash){result+="event "}result+=this.name+"("+this.inputs.map(function(input){return input.format(format)}).join(format===exports.FormatTypes.full?", ":",")+") ";if(format!==exports.FormatTypes.sighash){if(this.anonymous){result+="anonymous "}}return result.trim()};EventFragment.from=function(value){if(typeof value==="string"){return EventFragment.fromString(value)}return EventFragment.fromObject(value)};EventFragment.fromObject=function(value){if(EventFragment.isEventFragment(value)){return value}if(value.type!=="event"){logger.throwArgumentError("invalid event object","value",value)}var params={name:verifyIdentifier(value.name),anonymous:value.anonymous,inputs:value.inputs?value.inputs.map(ParamType.fromObject):[],type:"event"};return new EventFragment(_constructorGuard,params)};EventFragment.fromString=function(value){var match=value.match(regexParen);if(!match){logger.throwArgumentError("invalid event string","value",value)}var anonymous=false;match[3].split(" ").forEach(function(modifier){switch(modifier.trim()){case"anonymous":anonymous=true;break;case"":break;default:logger.warn("unknown modifier: "+modifier)}});return EventFragment.fromObject({name:match[1].trim(),anonymous:anonymous,inputs:parseParams(match[2],true),type:"event"})};EventFragment.isEventFragment=function(value){return value&&value._isFragment&&value.type==="event"};return EventFragment}(Fragment);exports.EventFragment=EventFragment;function parseGas(value,params){params.gas=null;var comps=value.split("@");if(comps.length!==1){if(comps.length>2){logger.throwArgumentError("invalid human-readable ABI signature","value",value)}if(!comps[1].match(/^[0-9]+$/)){logger.throwArgumentError("invalid human-readable ABI signature gas","value",value)}params.gas=bignumber_1.BigNumber.from(comps[1]);return comps[0]}return value}function parseModifiers(value,params){params.constant=false;params.payable=false;params.stateMutability="nonpayable";value.split(" ").forEach(function(modifier){switch(modifier.trim()){case"constant":params.constant=true;break;case"payable":params.payable=true;params.stateMutability="payable";break;case"nonpayable":params.payable=false;params.stateMutability="nonpayable";break;case"pure":params.constant=true;params.stateMutability="pure";break;case"view":params.constant=true;params.stateMutability="view";break;case"external":case"public":case"":break;default:console.log("unknown modifier: "+modifier)}})}function verifyState(value){var result={constant:false,payable:true,stateMutability:"payable"};if(value.stateMutability!=null){result.stateMutability=value.stateMutability;result.constant=result.stateMutability==="view"||result.stateMutability==="pure";if(value.constant!=null){if(!!value.constant!==result.constant){logger.throwArgumentError("cannot have constant function with mutability "+result.stateMutability,"value",value)}}result.payable=result.stateMutability==="payable";if(value.payable!=null){if(!!value.payable!==result.payable){logger.throwArgumentError("cannot have payable function with mutability "+result.stateMutability,"value",value)}}}else if(value.payable!=null){result.payable=!!value.payable;if(value.constant==null&&!result.payable&&value.type!=="constructor"){logger.throwArgumentError("unable to determine stateMutability","value",value)}result.constant=!!value.constant;if(result.constant){result.stateMutability="view"}else{result.stateMutability=result.payable?"payable":"nonpayable"}if(result.payable&&result.constant){logger.throwArgumentError("cannot have constant payable function","value",value)}}else if(value.constant!=null){result.constant=!!value.constant;result.payable=!result.constant;result.stateMutability=result.constant?"view":"payable"}else if(value.type!=="constructor"){logger.throwArgumentError("unable to determine stateMutability","value",value)}return result}var ConstructorFragment=function(_super){__extends(ConstructorFragment,_super);function ConstructorFragment(){return _super!==null&&_super.apply(this,arguments)||this}ConstructorFragment.prototype.format=function(format){if(!format){format=exports.FormatTypes.sighash}if(!exports.FormatTypes[format]){logger.throwArgumentError("invalid format type","format",format)}if(format===exports.FormatTypes.json){return JSON.stringify({type:"constructor",stateMutability:this.stateMutability!=="nonpayable"?this.stateMutability:undefined,payable:this.payable,gas:this.gas?this.gas.toNumber():undefined,inputs:this.inputs.map(function(input){return JSON.parse(input.format(format))})})}if(format===exports.FormatTypes.sighash){logger.throwError("cannot format a constructor for sighash",logger_1.Logger.errors.UNSUPPORTED_OPERATION,{operation:"format(sighash)"})}var result="constructor("+this.inputs.map(function(input){return input.format(format)}).join(format===exports.FormatTypes.full?", ":",")+") ";if(this.stateMutability&&this.stateMutability!=="nonpayable"){result+=this.stateMutability+" "}return result.trim()};ConstructorFragment.from=function(value){if(typeof value==="string"){return ConstructorFragment.fromString(value)}return ConstructorFragment.fromObject(value)};ConstructorFragment.fromObject=function(value){if(ConstructorFragment.isConstructorFragment(value)){return value}if(value.type!=="constructor"){logger.throwArgumentError("invalid constructor object","value",value)}var state=verifyState(value);if(state.constant){logger.throwArgumentError("constructor cannot be constant","value",value)}var params={name:null,type:value.type,inputs:value.inputs?value.inputs.map(ParamType.fromObject):[],payable:state.payable,stateMutability:state.stateMutability,gas:value.gas?bignumber_1.BigNumber.from(value.gas):null};return new ConstructorFragment(_constructorGuard,params)};ConstructorFragment.fromString=function(value){var params={type:"constructor"};value=parseGas(value,params);var parens=value.match(regexParen);if(!parens||parens[1].trim()!=="constructor"){logger.throwArgumentError("invalid constructor string","value",value)}params.inputs=parseParams(parens[2].trim(),false);parseModifiers(parens[3].trim(),params);return ConstructorFragment.fromObject(params)};ConstructorFragment.isConstructorFragment=function(value){return value&&value._isFragment&&value.type==="constructor"};return ConstructorFragment}(Fragment);exports.ConstructorFragment=ConstructorFragment;var FunctionFragment=function(_super){__extends(FunctionFragment,_super);function FunctionFragment(){return _super!==null&&_super.apply(this,arguments)||this}FunctionFragment.prototype.format=function(format){if(!format){format=exports.FormatTypes.sighash}if(!exports.FormatTypes[format]){logger.throwArgumentError("invalid format type","format",format)}if(format===exports.FormatTypes.json){return JSON.stringify({type:"function",name:this.name,constant:this.constant,stateMutability:this.stateMutability!=="nonpayable"?this.stateMutability:undefined,payable:this.payable,gas:this.gas?this.gas.toNumber():undefined,inputs:this.inputs.map(function(input){return JSON.parse(input.format(format))}),outputs:this.outputs.map(function(output){return JSON.parse(output.format(format))})})}var result="";if(format!==exports.FormatTypes.sighash){result+="function "}result+=this.name+"("+this.inputs.map(function(input){return input.format(format)}).join(format===exports.FormatTypes.full?", ":",")+") ";if(format!==exports.FormatTypes.sighash){if(this.stateMutability){if(this.stateMutability!=="nonpayable"){result+=this.stateMutability+" "}}else if(this.constant){result+="view "}if(this.outputs&&this.outputs.length){result+="returns ("+this.outputs.map(function(output){return output.format(format)}).join(", ")+") "}if(this.gas!=null){result+="@"+this.gas.toString()+" "}}return result.trim()};FunctionFragment.from=function(value){if(typeof value==="string"){return FunctionFragment.fromString(value)}return FunctionFragment.fromObject(value)};FunctionFragment.fromObject=function(value){if(FunctionFragment.isFunctionFragment(value)){return value}if(value.type!=="function"){logger.throwArgumentError("invalid function object","value",value)}var state=verifyState(value);var params={type:value.type,name:verifyIdentifier(value.name),constant:state.constant,inputs:value.inputs?value.inputs.map(ParamType.fromObject):[],outputs:value.outputs?value.outputs.map(ParamType.fromObject):[],payable:state.payable,stateMutability:state.stateMutability,gas:value.gas?bignumber_1.BigNumber.from(value.gas):null};return new FunctionFragment(_constructorGuard,params)};FunctionFragment.fromString=function(value){var params={type:"function"};value=parseGas(value,params);var comps=value.split(" returns ");if(comps.length>2){logger.throwArgumentError("invalid function string","value",value)}var parens=comps[0].match(regexParen);if(!parens){logger.throwArgumentError("invalid function signature","value",value)}params.name=parens[1].trim();if(params.name){verifyIdentifier(params.name)}params.inputs=parseParams(parens[2],false);parseModifiers(parens[3].trim(),params);if(comps.length>1){var returns=comps[1].match(regexParen);if(returns[1].trim()!=""||returns[3].trim()!=""){logger.throwArgumentError("unexpected tokens","value",value)}params.outputs=parseParams(returns[2],false)}else{params.outputs=[]}return FunctionFragment.fromObject(params)};FunctionFragment.isFunctionFragment=function(value){return value&&value._isFragment&&value.type==="function"};return FunctionFragment}(ConstructorFragment);exports.FunctionFragment=FunctionFragment;function checkForbidden(fragment){var sig=fragment.format();if(sig==="Error(string)"||sig==="Panic(uint256)"){logger.throwArgumentError("cannot specify user defined "+sig+" error","fragment",fragment)}return fragment}var ErrorFragment=function(_super){__extends(ErrorFragment,_super);function ErrorFragment(){return _super!==null&&_super.apply(this,arguments)||this}ErrorFragment.prototype.format=function(format){if(!format){format=exports.FormatTypes.sighash}if(!exports.FormatTypes[format]){logger.throwArgumentError("invalid format type","format",format)}if(format===exports.FormatTypes.json){return JSON.stringify({type:"error",name:this.name,inputs:this.inputs.map(function(input){return JSON.parse(input.format(format))})})}var result="";if(format!==exports.FormatTypes.sighash){result+="error "}result+=this.name+"("+this.inputs.map(function(input){return input.format(format)}).join(format===exports.FormatTypes.full?", ":",")+") ";return result.trim()};ErrorFragment.from=function(value){if(typeof value==="string"){return ErrorFragment.fromString(value)}return ErrorFragment.fromObject(value)};ErrorFragment.fromObject=function(value){if(ErrorFragment.isErrorFragment(value)){return value}if(value.type!=="error"){logger.throwArgumentError("invalid error object","value",value)}var params={type:value.type,name:verifyIdentifier(value.name),inputs:value.inputs?value.inputs.map(ParamType.fromObject):[]};return checkForbidden(new ErrorFragment(_constructorGuard,params))};ErrorFragment.fromString=function(value){var params={type:"error"};var parens=value.match(regexParen);if(!parens){logger.throwArgumentError("invalid error signature","value",value)}params.name=parens[1].trim();if(params.name){verifyIdentifier(params.name)}params.inputs=parseParams(parens[2],false);return checkForbi