signet.js 0.0.1-beta.7 → 0.0.1-beta.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/browser/index.browser.cjs +12 -0
- package/browser/index.browser.cjs.map +1 -0
- package/browser/index.browser.js +3927 -0
- package/browser/index.browser.js.map +1 -0
- package/node/index.node.cjs +19 -0
- package/node/index.node.cjs.map +1 -0
- package/node/index.node.js +4099 -0
- package/node/index.node.js.map +1 -0
- package/package.json +18 -12
- package/types/chains/Bitcoin/BTCRpcAdapter/BTCRpcAdapter.d.ts +10 -0
- package/types/chains/Bitcoin/BTCRpcAdapter/Mempool/Mempool.d.ts +15 -0
- package/types/chains/Bitcoin/BTCRpcAdapter/Mempool/index.d.ts +1 -0
- package/types/chains/Bitcoin/BTCRpcAdapter/Mempool/types.d.ts +69 -0
- package/types/chains/Bitcoin/BTCRpcAdapter/index.d.ts +5 -0
- package/types/chains/Bitcoin/Bitcoin.d.ts +42 -0
- package/types/chains/Bitcoin/types.d.ts +42 -0
- package/types/chains/Bitcoin/utils.d.ts +2 -0
- package/types/chains/Chain.d.ts +21 -0
- package/types/chains/ChainSignatureContract.d.ts +18 -0
- package/types/chains/Cosmos/Cosmos.d.ts +38 -0
- package/types/chains/Cosmos/types.d.ts +30 -0
- package/types/chains/Cosmos/utils.d.ts +2 -0
- package/types/chains/EVM/EVM.d.ts +32 -0
- package/types/chains/EVM/types.d.ts +5 -0
- package/types/chains/EVM/utils.d.ts +7 -0
- package/types/chains/index.d.ts +11 -0
- package/types/chains/types.d.ts +18 -0
- package/types/index.d.ts +2 -0
- package/types/utils/chains/index.d.ts +1 -0
- package/types/utils/chains/near/ChainSignatureContract.d.ts +35 -0
- package/types/utils/chains/near/account.d.ts +13 -0
- package/types/utils/chains/near/constants.d.ts +3 -0
- package/types/utils/chains/near/index.d.ts +3 -0
- package/types/utils/chains/near/relayer/index.d.ts +1 -0
- package/types/utils/chains/near/relayer/relayer.d.ts +3 -0
- package/types/utils/chains/near/relayer/types.d.ts +22 -0
- package/types/utils/chains/near/signAndSend/index.d.ts +1 -0
- package/types/utils/chains/near/signAndSend/keypair.d.ts +5 -0
- package/types/utils/chains/near/transactionBuilder.d.ts +26 -0
- package/types/utils/chains/near/types.d.ts +54 -0
- package/types/utils/cryptography.d.ts +3 -0
- package/types/utils/index.d.ts +2 -0
- package/.eslintrc.json +0 -55
- package/.prettierrc +0 -1
- package/babel.config.js +0 -6
- package/docs/pages/chain-signatures-contract.mdx +0 -56
- package/docs/pages/chain.mdx +0 -45
- package/docs/pages/chains/bitcoin/bitcoin.mdx +0 -191
- package/docs/pages/chains/bitcoin/btc-rpc-adapter.mdx +0 -307
- package/docs/pages/chains/cosmos.mdx +0 -181
- package/docs/pages/chains/evm.mdx +0 -189
- package/docs/pages/index.mdx +0 -99
- package/docs/snippets/contract.ts +0 -21
- package/docs/snippets/env.ts +0 -13
- package/jest.config.ts +0 -199
- package/src/chains/Bitcoin/BTCRpcAdapter/BTCRpcAdapter.ts +0 -11
- package/src/chains/Bitcoin/BTCRpcAdapter/Mempool/Mempool.ts +0 -96
- package/src/chains/Bitcoin/BTCRpcAdapter/Mempool/index.ts +0 -1
- package/src/chains/Bitcoin/BTCRpcAdapter/Mempool/types.ts +0 -72
- package/src/chains/Bitcoin/BTCRpcAdapter/index.ts +0 -6
- package/src/chains/Bitcoin/Bitcoin.ts +0 -301
- package/src/chains/Bitcoin/types.ts +0 -45
- package/src/chains/Bitcoin/utils.ts +0 -14
- package/src/chains/Chain.ts +0 -96
- package/src/chains/ChainSignatureContract.ts +0 -48
- package/src/chains/Cosmos/Cosmos.ts +0 -279
- package/src/chains/Cosmos/types.ts +0 -35
- package/src/chains/Cosmos/utils.ts +0 -45
- package/src/chains/EVM/EVM.ts +0 -180
- package/src/chains/EVM/types.ts +0 -7
- package/src/chains/EVM/utils.ts +0 -26
- package/src/chains/index.ts +0 -34
- package/src/chains/types.ts +0 -35
- package/src/chains/utils.ts +0 -40
- package/src/index.ts +0 -2
- package/src/utils/chains/index.ts +0 -1
- package/src/utils/chains/near/ChainSignatureContract.ts +0 -195
- package/src/utils/chains/near/account.ts +0 -42
- package/src/utils/chains/near/constants.ts +0 -4
- package/src/utils/chains/near/index.ts +0 -3
- package/src/utils/chains/near/relayer/index.ts +0 -1
- package/src/utils/chains/near/relayer/relayer.ts +0 -39
- package/src/utils/chains/near/relayer/types.ts +0 -24
- package/src/utils/chains/near/signAndSend/index.ts +0 -1
- package/src/utils/chains/near/signAndSend/keypair.ts +0 -180
- package/src/utils/chains/near/transactionBuilder.ts +0 -138
- package/src/utils/chains/near/types.ts +0 -67
- package/src/utils/index.ts +0 -1
- package/tsconfig.eslint.json +0 -8
- package/tsconfig.json +0 -116
- package/vite.config.ts +0 -47
- package/vocs.config.ts +0 -60
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";const sn=require("bn.js"),re=require("@cosmjs/encoding"),W=require("ethers"),cn=require("bitcoinjs-lib"),He=require("@near-js/accounts"),zt=require("@near-js/crypto"),un=require("@near-js/transactions"),dn=require("bs58"),fn=require("path"),ln=require("@near-js/keystores"),pn=require("coinselect"),yn=require("@cosmjs/amino"),Ue=require("@cosmjs/crypto"),ge=require("@cosmjs/proto-signing"),Te=require("@cosmjs/stargate"),nt=require("bech32"),rt=require("chain-registry");function Ce(n){return n&&n.__esModule?n:{default:n}}function hn(n){if(n&&n.__esModule)return n;const i=Object.create(null);if(n){for(const d in n)if(d!=="default"){const c=Object.getOwnPropertyDescriptor(n,d);Object.defineProperty(i,d,c.get?c:{enumerable:!0,get:function(){return n[d]}})}}return i.default=n,Object.freeze(i)}const fe=Ce(sn),ie=hn(cn),Gt=Ce(dn),gn=Ce(fn),mn=Ce(pn);var it=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Le={},H={},te={},me={},ot;function je(){return ot||(ot=1,me.__esModule=!0,me.integers=void 0,me.integers=["u8","u16","u32","u64","u128","i8","i16","i32","i64","i128","f32","f64"]),me}var se={},at;function $t(){if(at)return se;at=1,se.__esModule=!0,se.DecodeBuffer=se.EncodeBuffer=void 0;var n=function(){function d(){this.offset=0,this.buffer_size=256,this.buffer=new ArrayBuffer(this.buffer_size),this.view=new DataView(this.buffer)}return d.prototype.resize_if_necessary=function(c){if(this.buffer_size-this.offset<c){this.buffer_size=Math.max(this.buffer_size*2,this.buffer_size+c);var o=new ArrayBuffer(this.buffer_size);new Uint8Array(o).set(new Uint8Array(this.buffer)),this.buffer=o,this.view=new DataView(o)}},d.prototype.get_used_buffer=function(){return new Uint8Array(this.buffer).slice(0,this.offset)},d.prototype.store_value=function(c,o){var a=o.substring(1),s=parseInt(a)/8;this.resize_if_necessary(s);var u=o[0]==="f"?"setFloat".concat(a):o[0]==="i"?"setInt".concat(a):"setUint".concat(a);this.view[u](this.offset,c,!0),this.offset+=s},d.prototype.store_bytes=function(c){this.resize_if_necessary(c.length),new Uint8Array(this.buffer).set(new Uint8Array(c),this.offset),this.offset+=c.length},d}();se.EncodeBuffer=n;var i=function(){function d(c){this.offset=0,this.buffer_size=c.length,this.buffer=new ArrayBuffer(c.length),new Uint8Array(this.buffer).set(c),this.view=new DataView(this.buffer)}return d.prototype.assert_enough_buffer=function(c){if(this.offset+c>this.buffer.byteLength)throw new Error("Error in schema, the buffer is smaller than expected")},d.prototype.consume_value=function(c){var o=c.substring(1),a=parseInt(o)/8;this.assert_enough_buffer(a);var s=c[0]==="f"?"getFloat".concat(o):c[0]==="i"?"getInt".concat(o):"getUint".concat(o),u=this.view[s](this.offset,!0);return this.offset+=a,u},d.prototype.consume_bytes=function(c){this.assert_enough_buffer(c);var o=this.buffer.slice(this.offset,this.offset+c);return this.offset+=c,o},d}();return se.DecodeBuffer=i,se}var K={},st;function Vt(){if(st)return K;st=1;var n=K.__extends||function(){var h=function(m,w){return h=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(B,R){B.__proto__=R}||function(B,R){for(var t in R)Object.prototype.hasOwnProperty.call(R,t)&&(B[t]=R[t])},h(m,w)};return function(m,w){if(typeof w!="function"&&w!==null)throw new TypeError("Class extends value "+String(w)+" is not a constructor or null");h(m,w);function B(){this.constructor=m}m.prototype=w===null?Object.create(w):(B.prototype=w.prototype,new B)}}();K.__esModule=!0,K.validate_schema=K.ErrorSchema=K.expect_enum=K.expect_same_size=K.expect_bigint=K.expect_type=K.isArrayLike=void 0;var i=je();function d(h){return Array.isArray(h)||!!h&&typeof h=="object"&&"length"in h&&typeof h.length=="number"&&(h.length===0||h.length>0&&h.length-1 in h)}K.isArrayLike=d;function c(h,m,w){if(typeof h!==m)throw new Error("Expected ".concat(m," not ").concat(typeof h,"(").concat(h,") at ").concat(w.join(".")))}K.expect_type=c;function o(h,m){var w=["number","string","bigint","boolean"].includes(typeof h),B=typeof h=="object"&&h!==null&&"toString"in h;if(!w&&!B)throw new Error("Expected bigint, number, boolean or string not ".concat(typeof h,"(").concat(h,") at ").concat(m.join(".")))}K.expect_bigint=o;function a(h,m,w){if(h!==m)throw new Error("Array length ".concat(h," does not match schema length ").concat(m," at ").concat(w.join(".")))}K.expect_same_size=a;function s(h,m){if(typeof h!="object"||h===null)throw new Error("Expected object not ".concat(typeof h,"(").concat(h,") at ").concat(m.join(".")))}K.expect_enum=s;var u=i.integers.concat(["bool","string"]),f=["option","enum","array","set","map","struct"],y=function(h){n(m,h);function m(w,B){var R="Invalid schema: ".concat(JSON.stringify(w)," expected ").concat(B);return h.call(this,R)||this}return m}(Error);K.ErrorSchema=y;function b(h){if(!(typeof h=="string"&&u.includes(h))){if(h&&typeof h=="object"){var m=Object.keys(h);if(m.length===1&&f.includes(m[0])){var w=m[0];if(w==="option")return b(h[w]);if(w==="enum")return l(h[w]);if(w==="array")return I(h[w]);if(w==="set")return b(h[w]);if(w==="map")return p(h[w]);if(w==="struct")return g(h[w])}}throw new y(h,f.join(", ")+" or "+u.join(", "))}}K.validate_schema=b;function l(h){if(!Array.isArray(h))throw new y(h,"Array");for(var m=0,w=h;m<w.length;m++){var B=w[m];if(typeof B!="object"||!("struct"in B))throw new Error('Missing "struct" key in enum schema');if(typeof B.struct!="object"||Object.keys(B.struct).length!==1)throw new Error('The "struct" in each enum must have a single key');b({struct:B.struct})}}function I(h){if(typeof h!="object")throw new y(h,"{ type, len? }");if(h.len&&typeof h.len!="number")throw new Error("Invalid schema: ".concat(h));if("type"in h)return b(h.type);throw new y(h,"{ type, len? }")}function p(h){if(typeof h=="object"&&"key"in h&&"value"in h)b(h.key),b(h.value);else throw new y(h,"{ key, value }")}function g(h){if(typeof h!="object")throw new y(h,"object");for(var m in h)b(h[m])}return K}var ct;function bn(){if(ct)return te;ct=1;var n=te.__createBinding||(Object.create?function(u,f,y,b){b===void 0&&(b=y);var l=Object.getOwnPropertyDescriptor(f,y);(!l||("get"in l?!f.__esModule:l.writable||l.configurable))&&(l={enumerable:!0,get:function(){return f[y]}}),Object.defineProperty(u,b,l)}:function(u,f,y,b){b===void 0&&(b=y),u[b]=f[y]}),i=te.__setModuleDefault||(Object.create?function(u,f){Object.defineProperty(u,"default",{enumerable:!0,value:f})}:function(u,f){u.default=f}),d=te.__importStar||function(u){if(u&&u.__esModule)return u;var f={};if(u!=null)for(var y in u)y!=="default"&&Object.prototype.hasOwnProperty.call(u,y)&&n(f,u,y);return i(f,u),f};te.__esModule=!0,te.BorshSerializer=void 0;var c=je(),o=$t(),a=d(Vt()),s=function(){function u(f){this.encoded=new o.EncodeBuffer,this.fieldPath=["value"],this.checkTypes=f}return u.prototype.encode=function(f,y){return this.encode_value(f,y),this.encoded.get_used_buffer()},u.prototype.encode_value=function(f,y){if(typeof y=="string"){if(c.integers.includes(y))return this.encode_integer(f,y);if(y==="string")return this.encode_string(f);if(y==="bool")return this.encode_boolean(f)}if(typeof y=="object"){if("option"in y)return this.encode_option(f,y);if("enum"in y)return this.encode_enum(f,y);if("array"in y)return this.encode_array(f,y);if("set"in y)return this.encode_set(f,y);if("map"in y)return this.encode_map(f,y);if("struct"in y)return this.encode_struct(f,y)}},u.prototype.encode_integer=function(f,y){var b=parseInt(y.substring(1));b<=32||y=="f64"?(this.checkTypes&&a.expect_type(f,"number",this.fieldPath),this.encoded.store_value(f,y)):(this.checkTypes&&a.expect_bigint(f,this.fieldPath),this.encode_bigint(BigInt(f),b))},u.prototype.encode_bigint=function(f,y){for(var b=y/8,l=new Uint8Array(b),I=0;I<b;I++)l[I]=Number(f&BigInt(255)),f=f>>BigInt(8);this.encoded.store_bytes(new Uint8Array(l))},u.prototype.encode_string=function(f){this.checkTypes&&a.expect_type(f,"string",this.fieldPath);var y=f;this.encoded.store_value(y.length,"u32");for(var b=0;b<y.length;b++)this.encoded.store_value(y.charCodeAt(b),"u8")},u.prototype.encode_boolean=function(f){this.checkTypes&&a.expect_type(f,"boolean",this.fieldPath),this.encoded.store_value(f?1:0,"u8")},u.prototype.encode_option=function(f,y){f==null?this.encoded.store_value(0,"u8"):(this.encoded.store_value(1,"u8"),this.encode_value(f,y.option))},u.prototype.encode_enum=function(f,y){this.checkTypes&&a.expect_enum(f,this.fieldPath);for(var b=Object.keys(f)[0],l=0;l<y.enum.length;l++){var I=y.enum[l];if(b===Object.keys(I.struct)[0])return this.encoded.store_value(l,"u8"),this.encode_struct(f,I)}throw new Error("Enum key (".concat(b,") not found in enum schema: ").concat(JSON.stringify(y)," at ").concat(this.fieldPath.join(".")))},u.prototype.encode_array=function(f,y){if(a.isArrayLike(f))return this.encode_arraylike(f,y);if(f instanceof ArrayBuffer)return this.encode_buffer(f,y);throw new Error("Expected Array-like not ".concat(typeof f,"(").concat(f,") at ").concat(this.fieldPath.join(".")))},u.prototype.encode_arraylike=function(f,y){y.array.len?a.expect_same_size(f.length,y.array.len,this.fieldPath):this.encoded.store_value(f.length,"u32");for(var b=0;b<f.length;b++)this.encode_value(f[b],y.array.type)},u.prototype.encode_buffer=function(f,y){y.array.len?a.expect_same_size(f.byteLength,y.array.len,this.fieldPath):this.encoded.store_value(f.byteLength,"u32"),this.encoded.store_bytes(new Uint8Array(f))},u.prototype.encode_set=function(f,y){this.checkTypes&&a.expect_type(f,"object",this.fieldPath);var b=f instanceof Set,l=b?Array.from(f.values()):Object.values(f);this.encoded.store_value(l.length,"u32");for(var I=0,p=l;I<p.length;I++){var g=p[I];this.encode_value(g,y.set)}},u.prototype.encode_map=function(f,y){this.checkTypes&&a.expect_type(f,"object",this.fieldPath);var b=f instanceof Map,l=b?Array.from(f.keys()):Object.keys(f);this.encoded.store_value(l.length,"u32");for(var I=0,p=l;I<p.length;I++){var g=p[I];this.encode_value(g,y.map.key),this.encode_value(b?f.get(g):f[g],y.map.value)}},u.prototype.encode_struct=function(f,y){this.checkTypes&&a.expect_type(f,"object",this.fieldPath);for(var b=0,l=Object.keys(y.struct);b<l.length;b++){var I=l[b];this.fieldPath.push(I),this.encode_value(f[I],y.struct[I]),this.fieldPath.pop()}},u}();return te.BorshSerializer=s,te}var be={},ut;function _n(){if(ut)return be;ut=1,be.__esModule=!0,be.BorshDeserializer=void 0;var n=je(),i=$t(),d=function(){function c(o){this.buffer=new i.DecodeBuffer(o)}return c.prototype.decode=function(o){return this.decode_value(o)},c.prototype.decode_value=function(o){if(typeof o=="string"){if(n.integers.includes(o))return this.decode_integer(o);if(o==="string")return this.decode_string();if(o==="bool")return this.decode_boolean()}if(typeof o=="object"){if("option"in o)return this.decode_option(o);if("enum"in o)return this.decode_enum(o);if("array"in o)return this.decode_array(o);if("set"in o)return this.decode_set(o);if("map"in o)return this.decode_map(o);if("struct"in o)return this.decode_struct(o)}throw new Error("Unsupported type: ".concat(o))},c.prototype.decode_integer=function(o){var a=parseInt(o.substring(1));return a<=32||o=="f64"?this.buffer.consume_value(o):this.decode_bigint(a,o.startsWith("i"))},c.prototype.decode_bigint=function(o,a){a===void 0&&(a=!1);var s=o/8,u=new Uint8Array(this.buffer.consume_bytes(s)),f=u.reduceRight(function(y,b){return y+b.toString(16).padStart(2,"0")},"");return a&&u[s-1]?BigInt.asIntN(o,BigInt("0x".concat(f))):BigInt("0x".concat(f))},c.prototype.decode_string=function(){var o=this.decode_integer("u32"),a=new Uint8Array(this.buffer.consume_bytes(o));return String.fromCharCode.apply(null,a)},c.prototype.decode_boolean=function(){return this.buffer.consume_value("u8")>0},c.prototype.decode_option=function(o){var a=this.buffer.consume_value("u8");if(a===1)return this.decode_value(o.option);if(a!==0)throw new Error("Invalid option ".concat(a));return null},c.prototype.decode_enum=function(o){var a,s=this.buffer.consume_value("u8");if(s>o.enum.length)throw new Error("Enum option ".concat(s," is not available"));var u=o.enum[s].struct,f=Object.keys(u)[0];return a={},a[f]=this.decode_value(u[f]),a},c.prototype.decode_array=function(o){for(var a=[],s=o.array.len?o.array.len:this.decode_integer("u32"),u=0;u<s;++u)a.push(this.decode_value(o.array.type));return a},c.prototype.decode_set=function(o){for(var a=this.decode_integer("u32"),s=new Set,u=0;u<a;++u)s.add(this.decode_value(o.set));return s},c.prototype.decode_map=function(o){for(var a=this.decode_integer("u32"),s=new Map,u=0;u<a;++u){var f=this.decode_value(o.map.key),y=this.decode_value(o.map.value);s.set(f,y)}return s},c.prototype.decode_struct=function(o){var a={};for(var s in o.struct)a[s]=this.decode_value(o.struct[s]);return a},c}();return be.BorshDeserializer=d,be}var dt;function vn(){if(dt)return H;dt=1;var n=H.__createBinding||(Object.create?function(f,y,b,l){l===void 0&&(l=b);var I=Object.getOwnPropertyDescriptor(y,b);(!I||("get"in I?!y.__esModule:I.writable||I.configurable))&&(I={enumerable:!0,get:function(){return y[b]}}),Object.defineProperty(f,l,I)}:function(f,y,b,l){l===void 0&&(l=b),f[l]=y[b]}),i=H.__setModuleDefault||(Object.create?function(f,y){Object.defineProperty(f,"default",{enumerable:!0,value:y})}:function(f,y){f.default=y}),d=H.__importStar||function(f){if(f&&f.__esModule)return f;var y={};if(f!=null)for(var b in f)b!=="default"&&Object.prototype.hasOwnProperty.call(f,b)&&n(y,f,b);return i(y,f),y};H.__esModule=!0,H.deserialize=H.serialize=void 0;var c=bn(),o=_n(),a=d(Vt());function s(f,y,b){b===void 0&&(b=!0),b&&a.validate_schema(f);var l=new c.BorshSerializer(b);return l.encode(y,f)}H.serialize=s;function u(f,y,b){b===void 0&&(b=!0),b&&a.validate_schema(f);var l=new o.BorshDeserializer(y);return l.decode(f)}return H.deserialize=u,H}var _e={},le={},ft;function Sn(){if(ft)return le;ft=1;var n=le.__importDefault||function(d){return d&&d.__esModule?d:{default:d}};Object.defineProperty(le,"__esModule",{value:!0}),le.DEFAULT_FUNCTION_CALL_GAS=void 0;const i=n(fe.default);return le.DEFAULT_FUNCTION_CALL_GAS=new i.default("30000000000000"),le}var Je={},ve={},Ke={},Se={},Ie={},lt;function In(){if(lt)return Ie;lt=1,Object.defineProperty(Ie,"__esModule",{value:!0}),Ie.ConsoleLogger=void 0;class n{constructor(d){this.logLevels=d,this.isLevelEnabled=c=>this.logLevels.includes(c)}print(d,c,...o){switch(d){case"error":case"fatal":return console.error(c,...o);case"warn":return console.warn(c,...o);case"log":return console.log(c,...o);case"debug":case"verbose":return console.debug(c,...o)}}verbose(d,...c){this.isLevelEnabled("verbose")&&this.print("verbose",d,...c)}debug(d,...c){this.isLevelEnabled("debug")&&this.print("debug",d,...c)}log(d,...c){this.isLevelEnabled("log")&&this.print("log",d,...c)}warn(d,...c){this.isLevelEnabled("warn")&&this.print("warn",d,...c)}error(d,...c){this.isLevelEnabled("error")&&this.print("error",d,...c)}fatal(d,...c){this.isLevelEnabled("fatal")&&this.print("fatal",d,...c)}}return Ie.ConsoleLogger=n,Ie}var pt;function wn(){if(pt)return Se;pt=1;var n;Object.defineProperty(Se,"__esModule",{value:!0}),Se.Logger=void 0;const i=In(),d=["verbose","debug","log","warn","error","fatal"],c=typeof process=="object"&&process.env.NEAR_NO_LOGS?void 0:new i.ConsoleLogger(d);class o{static error(s,...u){var f;(f=this.instanceRef)===null||f===void 0||f.error(s,...u)}static log(s,...u){var f;(f=this.instanceRef)===null||f===void 0||f.log(s,...u)}static warn(s,...u){var f;(f=this.instanceRef)===null||f===void 0||f.warn(s,...u)}static debug(s,...u){var f,y;(y=(f=this.instanceRef)===null||f===void 0?void 0:f.debug)===null||y===void 0||y.call(f,s,...u)}static verbose(s,...u){var f,y;(y=(f=this.instanceRef)===null||f===void 0?void 0:f.verbose)===null||y===void 0||y.call(f,s,...u)}static fatal(s,...u){var f,y;(y=(f=this.instanceRef)===null||f===void 0?void 0:f.fatal)===null||y===void 0||y.call(f,s,...u)}}return Se.Logger=o,n=o,o.instanceRef=c,o.overrideLogger=a=>{n.instanceRef=a},Se}var yt;function Xe(){return yt||(yt=1,function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.Logger=void 0;var i=wn();Object.defineProperty(n,"Logger",{enumerable:!0,get:function(){return i.Logger}})}(Ke)),Ke}var ht;function En(){if(ht)return ve;ht=1,Object.defineProperty(ve,"__esModule",{value:!0}),ve.logWarning=void 0;const n=Xe();function i(...d){const[c,...o]=d;n.Logger.warn(c,...o)}return ve.logWarning=i,ve}var z={},we={},Ee={},gt;function An(){if(gt)return Ee;gt=1,Object.defineProperty(Ee,"__esModule",{value:!0}),Ee.Assignable=void 0;class n{constructor(d){Object.keys(d).map(c=>{this[c]=d[c]})}}return Ee.Assignable=n,Ee}var V={},mt;function Nn(){if(mt)return V;mt=1,Object.defineProperty(V,"__esModule",{value:!0}),V.ErrorContext=V.TypedError=V.ArgumentTypeError=V.PositionalArgsError=void 0;class n extends Error{constructor(){super("Contract method calls expect named arguments wrapped in object, e.g. { argName1: argValue1, argName2: argValue2 }")}}V.PositionalArgsError=n;class i extends Error{constructor(a,s,u){super(`Expected ${s} for '${a}' argument, but got '${JSON.stringify(u)}'`)}}V.ArgumentTypeError=i;class d extends Error{constructor(a,s,u){super(a),this.type=s||"UntypedError",this.context=u}}V.TypedError=d;class c{constructor(a){this.transactionHash=a}}return V.ErrorContext=c,V}var qe={},ze={},bt;function Bn(){return bt||(bt=1,function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.IdType=void 0,function(i){i.Transaction="transaction",i.Receipt="receipt"}(n.IdType||(n.IdType={}))}(ze)),ze}var Ge={},_t;function On(){return _t||(_t=1,function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.FinalExecutionStatusBasic=n.ExecutionStatusBasic=void 0,function(i){i.Unknown="Unknown",i.Pending="Pending",i.Failure="Failure"}(n.ExecutionStatusBasic||(n.ExecutionStatusBasic={})),function(i){i.NotStarted="NotStarted",i.Started="Started",i.Failure="Failure"}(n.FinalExecutionStatusBasic||(n.FinalExecutionStatusBasic={}))}(Ge)),Ge}var vt;function Tn(){return vt||(vt=1,function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.FinalExecutionStatusBasic=n.ExecutionStatusBasic=n.IdType=void 0;var i=Bn();Object.defineProperty(n,"IdType",{enumerable:!0,get:function(){return i.IdType}});var d=On();Object.defineProperty(n,"ExecutionStatusBasic",{enumerable:!0,get:function(){return d.ExecutionStatusBasic}}),Object.defineProperty(n,"FinalExecutionStatusBasic",{enumerable:!0,get:function(){return d.FinalExecutionStatusBasic}})}(qe)),qe}var St;function Dn(){return St||(St=1,function(n){var i=we.__createBinding||(Object.create?function(c,o,a,s){s===void 0&&(s=a);var u=Object.getOwnPropertyDescriptor(o,a);(!u||("get"in u?!o.__esModule:u.writable||u.configurable))&&(u={enumerable:!0,get:function(){return o[a]}}),Object.defineProperty(c,s,u)}:function(c,o,a,s){s===void 0&&(s=a),c[s]=o[a]}),d=we.__exportStar||function(c,o){for(var a in c)a!=="default"&&!Object.prototype.hasOwnProperty.call(o,a)&&i(o,c,a)};Object.defineProperty(n,"__esModule",{value:!0}),d(An(),n),d(Nn(),n),d(Tn(),n)}(we)),we}var xe={exports:{}},kn=xe.exports,It;function xn(){return It||(It=1,function(n,i){(function(d,c){n.exports=c()})(kn,function(){/*!
|
|
2
|
+
* mustache.js - Logic-less {{mustache}} templates with JavaScript
|
|
3
|
+
* http://github.com/janl/mustache.js
|
|
4
|
+
*/var d=Object.prototype.toString,c=Array.isArray||function(E){return d.call(E)==="[object Array]"};function o(A){return typeof A=="function"}function a(A){return c(A)?"array":typeof A}function s(A){return A.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function u(A,E){return A!=null&&typeof A=="object"&&E in A}function f(A,E){return A!=null&&typeof A!="object"&&A.hasOwnProperty&&A.hasOwnProperty(E)}var y=RegExp.prototype.test;function b(A,E){return y.call(A,E)}var l=/\S/;function I(A){return!b(l,A)}var p={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/","`":"`","=":"="};function g(A){return String(A).replace(/[&<>"'`=\/]/g,function(N){return p[N]})}var h=/\s*/,m=/\s+/,w=/\s*=/,B=/\s*\}/,R=/#|\^|\/|>|\{|&|=|!/;function t(A,E){if(!A)return[];var N=!1,O=[],D=[],k=[],x=!1,P=!1,U="",L=0;function Q(){if(x&&!P)for(;k.length;)delete D[k.pop()];else k=[];x=!1,P=!1}var oe,ye,et;function tt(j){if(typeof j=="string"&&(j=j.split(m,2)),!c(j)||j.length!==2)throw new Error("Invalid tags: "+j);oe=new RegExp(s(j[0])+"\\s*"),ye=new RegExp("\\s*"+s(j[1])),et=new RegExp("\\s*"+s("}"+j[1]))}tt(E||T.tags);for(var J=new v(A),ee,q,$,he,Oe,ae;!J.eos();){if(ee=J.pos,$=J.scanUntil(oe),$)for(var Fe=0,an=$.length;Fe<an;++Fe)he=$.charAt(Fe),I(he)?(k.push(D.length),U+=he):(P=!0,N=!0,U+=" "),D.push(["text",he,ee,ee+1]),ee+=1,he===`
|
|
5
|
+
`&&(Q(),U="",L=0,N=!1);if(!J.scan(oe))break;if(x=!0,q=J.scan(R)||"name",J.scan(h),q==="="?($=J.scanUntil(w),J.scan(w),J.scanUntil(ye)):q==="{"?($=J.scanUntil(et),J.scan(B),J.scanUntil(ye),q="&"):$=J.scanUntil(ye),!J.scan(ye))throw new Error("Unclosed tag at "+J.pos);if(q==">"?Oe=[q,$,ee,J.pos,U,L,N]:Oe=[q,$,ee,J.pos],L++,D.push(Oe),q==="#"||q==="^")O.push(Oe);else if(q==="/"){if(ae=O.pop(),!ae)throw new Error('Unopened section "'+$+'" at '+ee);if(ae[1]!==$)throw new Error('Unclosed section "'+ae[1]+'" at '+ee)}else q==="name"||q==="{"||q==="&"?P=!0:q==="="&&tt($)}if(Q(),ae=O.pop(),ae)throw new Error('Unclosed section "'+ae[1]+'" at '+J.pos);return r(e(D))}function e(A){for(var E=[],N,O,D=0,k=A.length;D<k;++D)N=A[D],N&&(N[0]==="text"&&O&&O[0]==="text"?(O[1]+=N[1],O[3]=N[3]):(E.push(N),O=N));return E}function r(A){for(var E=[],N=E,O=[],D,k,x=0,P=A.length;x<P;++x)switch(D=A[x],D[0]){case"#":case"^":N.push(D),O.push(D),N=D[4]=[];break;case"/":k=O.pop(),k[5]=D[2],N=O.length>0?O[O.length-1][4]:E;break;default:N.push(D)}return E}function v(A){this.string=A,this.tail=A,this.pos=0}v.prototype.eos=function(){return this.tail===""},v.prototype.scan=function(E){var N=this.tail.match(E);if(!N||N.index!==0)return"";var O=N[0];return this.tail=this.tail.substring(O.length),this.pos+=O.length,O},v.prototype.scanUntil=function(E){var N=this.tail.search(E),O;switch(N){case-1:O=this.tail,this.tail="";break;case 0:O="";break;default:O=this.tail.substring(0,N),this.tail=this.tail.substring(N)}return this.pos+=O.length,O};function _(A,E){this.view=A,this.cache={".":this.view},this.parent=E}_.prototype.push=function(E){return new _(E,this)},_.prototype.lookup=function(E){var N=this.cache,O;if(N.hasOwnProperty(E))O=N[E];else{for(var D=this,k,x,P,U=!1;D;){if(E.indexOf(".")>0)for(k=D.view,x=E.split("."),P=0;k!=null&&P<x.length;)P===x.length-1&&(U=u(k,x[P])||f(k,x[P])),k=k[x[P++]];else k=D.view[E],U=u(D.view,E);if(U){O=k;break}D=D.parent}N[E]=O}return o(O)&&(O=O.call(this.view)),O};function S(){this.templateCache={_cache:{},set:function(E,N){this._cache[E]=N},get:function(E){return this._cache[E]},clear:function(){this._cache={}}}}S.prototype.clearCache=function(){typeof this.templateCache<"u"&&this.templateCache.clear()},S.prototype.parse=function(E,N){var O=this.templateCache,D=E+":"+(N||T.tags).join(":"),k=typeof O<"u",x=k?O.get(D):void 0;return x==null&&(x=t(E,N),k&&O.set(D,x)),x},S.prototype.render=function(E,N,O,D){var k=this.parse(E,D),x=N instanceof _?N:new _(N,void 0);return this.renderTokens(k,x,O,E,D)},S.prototype.renderTokens=function(E,N,O,D,k){for(var x="",P,U,L,Q=0,oe=E.length;Q<oe;++Q)L=void 0,P=E[Q],U=P[0],U==="#"?L=this.renderSection(P,N,O,D):U==="^"?L=this.renderInverted(P,N,O,D):U===">"?L=this.renderPartial(P,N,O,k):U==="&"?L=this.unescapedValue(P,N):U==="name"?L=this.escapedValue(P,N):U==="text"&&(L=this.rawValue(P)),L!==void 0&&(x+=L);return x},S.prototype.renderSection=function(E,N,O,D){var k=this,x="",P=N.lookup(E[1]);function U(oe){return k.render(oe,N,O)}if(P){if(c(P))for(var L=0,Q=P.length;L<Q;++L)x+=this.renderTokens(E[4],N.push(P[L]),O,D);else if(typeof P=="object"||typeof P=="string"||typeof P=="number")x+=this.renderTokens(E[4],N.push(P),O,D);else if(o(P)){if(typeof D!="string")throw new Error("Cannot use higher-order sections without the original template");P=P.call(N.view,D.slice(E[3],E[5]),U),P!=null&&(x+=P)}else x+=this.renderTokens(E[4],N,O,D);return x}},S.prototype.renderInverted=function(E,N,O,D){var k=N.lookup(E[1]);if(!k||c(k)&&k.length===0)return this.renderTokens(E[4],N,O,D)},S.prototype.indentPartial=function(E,N,O){for(var D=N.replace(/[^ \t]/g,""),k=E.split(`
|
|
6
|
+
`),x=0;x<k.length;x++)k[x].length&&(x>0||!O)&&(k[x]=D+k[x]);return k.join(`
|
|
7
|
+
`)},S.prototype.renderPartial=function(E,N,O,D){if(O){var k=o(O)?O(E[1]):O[E[1]];if(k!=null){var x=E[6],P=E[5],U=E[4],L=k;return P==0&&U&&(L=this.indentPartial(k,U,x)),this.renderTokens(this.parse(L,D),N,O,L)}}},S.prototype.unescapedValue=function(E,N){var O=N.lookup(E[1]);if(O!=null)return O},S.prototype.escapedValue=function(E,N){var O=N.lookup(E[1]);if(O!=null)return T.escape(O)},S.prototype.rawValue=function(E){return E[1]};var T={name:"mustache.js",version:"4.0.0",tags:["{{","}}"],clearCache:void 0,escape:void 0,parse:void 0,render:void 0,Scanner:void 0,Context:void 0,Writer:void 0,set templateCache(A){C.templateCache=A},get templateCache(){return C.templateCache}},C=new S;return T.clearCache=function(){return C.clearCache()},T.parse=function(E,N){return C.parse(E,N)},T.render=function(E,N,O,D){if(typeof E!="string")throw new TypeError('Invalid template! Template should be a "string" but "'+a(E)+'" was given as the first argument for mustache#render(template, view, partials)');return C.render(E,N,O,D)},T.escape=g,T.Scanner=v,T.Context=_,T.Writer=S,T})}(xe)),xe.exports}var De={},wt;function Wt(){return wt||(wt=1,function(n){var i=De.__importDefault||function(g){return g&&g.__esModule?g:{default:g}};Object.defineProperty(n,"__esModule",{value:!0}),n.baseDecode=n.baseEncode=n.parseNearAmount=n.formatNearAmount=n.NEAR_NOMINATION=n.NEAR_NOMINATION_EXP=void 0;const d=i(fe.default),c=i(Gt.default);n.NEAR_NOMINATION_EXP=24,n.NEAR_NOMINATION=new d.default("10",10).pow(new d.default(n.NEAR_NOMINATION_EXP,10));const o=[],a=new d.default(10);for(let g=0,h=new d.default(5);g<n.NEAR_NOMINATION_EXP;g++,h=h.mul(a))o[g]=h;function s(g,h=n.NEAR_NOMINATION_EXP){const m=new d.default(g,10);if(h!==n.NEAR_NOMINATION_EXP){const R=n.NEAR_NOMINATION_EXP-h-1;R>0&&m.iadd(o[R])}g=m.toString();const w=g.substring(0,g.length-n.NEAR_NOMINATION_EXP)||"0",B=g.substring(g.length-n.NEAR_NOMINATION_EXP).padStart(n.NEAR_NOMINATION_EXP,"0").substring(0,h);return y(`${l(w)}.${B}`)}n.formatNearAmount=s;function u(g){if(!g)return null;g=f(g);const h=g.split("."),m=h[0],w=h[1]||"";if(h.length>2||w.length>n.NEAR_NOMINATION_EXP)throw new Error(`Cannot parse '${g}' as NEAR amount`);return b(m+w.padEnd(n.NEAR_NOMINATION_EXP,"0"))}n.parseNearAmount=u;function f(g){return g.replace(/,/g,"").trim()}function y(g){return g.replace(/\.?0*$/,"")}function b(g){return g=g.replace(/^0+/,""),g===""?"0":g}function l(g){const h=/(-?\d+)(\d{3})/;for(;h.test(g);)g=g.replace(h,"$1,$2");return g}function I(g){if(typeof g=="string"){const h=[];for(let m=0;m<g.length;m++)h.push(g.charCodeAt(m));g=new Uint8Array(h)}return c.default.encode(g)}n.baseEncode=I;function p(g){return new Uint8Array(c.default.decode(g))}n.baseDecode=p}(De)),De}const Pn="Exceeded the maximum amount of gas allowed to burn per contract",Cn="Method name is empty",Mn="Wasmer compilation error: {{msg}}",Rn="Smart contract panicked: {{panic_msg}}",Fn="Error creating Wasm memory",Un="Exceeded the prepaid gas",Ln="Method name is not valid UTF8 string",Jn="String encoding is bad UTF-16 sequence",Kn="WebAssembly trap: {{msg}}",qn="Gas instrumentation failed or contract has denied instructions.",zn="{{promise_idx}} does not correspond to existing promises",Gn="Accessed invalid promise result index: {{result_idx}}",$n="Error happened while deserializing the module",Vn="Contract method is not found",Wn="Accessed invalid register id: {{register_id}}",Hn="VM Logic returned an invalid receipt index: {{receipt_index}}",jn="Method name is empty in contract call",Xn="Returning joint promise is currently prohibited",Zn="Stack instrumentation failed",Yn="Cannot find contract code for account {{account_id}}",Qn="Invalid method signature",er="Integer overflow happened during contract execution",tr="MemoryAccessViolation",nr="Iterator index {{iterator_index}} does not exist",rr="Iterator {{iterator_index}} was invalidated after its creation by performing a mutable operation on trie",ir="VM Logic returned an invalid account id",or="Error happened while serializing the module",ar="Actions can only be appended to non-joint promise.",sr="Internal memory declaration has been found in the module",cr="Error happened during instantiation",ur="{{method_name}} is not allowed in view calls",dr="VM Logic returned an invalid method name",fr="String encoding is bad UTF-8 sequence",lr="Exceeded the account balance",pr="Wasm contract link error: {{msg}}",yr="VM Logic provided an invalid public key",hr="Actor {{actor_id}} doesn't have permission to account {{account_id}} to complete the action",gr="The account {{account_id}} wouldn't have enough balance to cover storage, required to have {{amount}} yoctoNEAR more",mr="Wrong AccessKey used for transaction: transaction is sent to receiver_id={{tx_receiver}}, but is signed with function call access key that restricted to only use with receiver_id={{ak_receiver}}. Either change receiver_id in your transaction or switch to use a FullAccessKey.",br="Transaction gas or balance cost is too high",_r="Transaction is not signed with the given public key",vr=`Signer "{{account_id}}" doesn't have access key with the given public_key {{public_key}}`,Sr="Sender {{signer_id}} does not have enough balance {{#formatNear}}{{balance}}{{/formatNear}} for operation costing {{#formatNear}}{{cost}}{{/formatNear}}",Ir="Access Key {account_id}:{public_key} does not have enough balance {{#formatNear}}{{allowance}}{{/formatNear}} for transaction costing {{#formatNear}}{{cost}}{{/formatNear}}",wr="Transaction has expired",Er="Account {{account_id}} is staking and can not be deleted",Ar="Signer {{signer_id}} does not exist",Nr="Account {{account_id}} tried to stake {{#formatNear}}{{stake}}{{/formatNear}}, but has staked {{#formatNear}}{{locked}}{{/formatNear}} and only has {{#formatNear}}{{balance}}{{/formatNear}}",Br="The public key {{public_key}} is already used for an existing access key",Or="Invalid signer account ID {{signer_id}} according to requirements",Tr="The new account_id {{account_id}} can't be created by {{predecessor_id}}",Dr="The transaction contains more then one action, but it was signed with an access key which allows transaction to apply only one specific action. To apply more then one actions TX must be signed with a full access key",kr="Account {{account_id}} is not yet staked, but tried to unstake",xr="Transaction nonce {{tx_nonce}} must be larger than nonce of the used access key {{ak_nonce}}",Pr="Can't create a new account {{account_id}}, because it already exists",Cr="Transaction parent block hash doesn't belong to the current chain",Mr="Can't complete the action because account {{account_id}} doesn't exist",Rr="Can't complete the action because access key {{public_key}} doesn't exist",Fr="Transaction method name {{method_name}} isn't allowed by the access key",Ur="Account {{account_id}} can't be deleted. It has {{#formatNear}}{{balance}}{{/formatNear}}, which is enough to cover the rent",Lr="Account {{account_id}} can't be deleted. It has {{#formatNear}}{{balance}}{{/formatNear}}, which is enough to cover it's storage",Jr="Invalid receiver account ID {{receiver_id}} according to requirements",Kr="Account {{account_id}} tries to remove an access key that doesn't exist",qr="Timeout exceeded",zr="Connection closed",Gr={GasLimitExceeded:Pn,MethodEmptyName:Cn,WasmerCompileError:Mn,GuestPanic:Rn,Memory:Fn,GasExceeded:Un,MethodUTF8Error:Ln,BadUTF16:Jn,WasmTrap:Kn,GasInstrumentation:qn,InvalidPromiseIndex:zn,InvalidPromiseResultIndex:Gn,Deserialization:$n,MethodNotFound:Vn,InvalidRegisterId:Wn,InvalidReceiptIndex:Hn,EmptyMethodName:jn,CannotReturnJointPromise:Xn,StackHeightInstrumentation:Zn,CodeDoesNotExist:Yn,MethodInvalidSignature:Qn,IntegerOverflow:er,MemoryAccessViolation:tr,InvalidIteratorIndex:nr,IteratorWasInvalidated:rr,InvalidAccountId:ir,Serialization:or,CannotAppendActionToJointPromise:ar,InternalMemoryDeclared:sr,Instantiate:cr,ProhibitedInView:ur,InvalidMethodName:dr,BadUTF8:fr,BalanceExceeded:lr,LinkError:pr,InvalidPublicKey:yr,ActorNoPermission:hr,LackBalanceForState:gr,ReceiverMismatch:mr,CostOverflow:br,InvalidSignature:_r,AccessKeyNotFound:vr,NotEnoughBalance:Sr,NotEnoughAllowance:Ir,Expired:wr,DeleteAccountStaking:Er,SignerDoesNotExist:Ar,TriesToStake:Nr,AddKeyAlreadyExists:Br,InvalidSigner:Or,CreateAccountNotAllowed:Tr,RequiresFullAccess:Dr,TriesToUnstake:kr,InvalidNonce:xr,AccountAlreadyExists:Pr,InvalidChain:Cr,AccountDoesNotExist:Mr,AccessKeyDoesNotExist:Rr,MethodNameMismatch:Fr,DeleteAccountHasRent:Ur,DeleteAccountHasEnoughBalance:Lr,InvalidReceiver:Jr,DeleteKeyDoesNotExist:Kr,Timeout:qr,Closed:zr},$r=JSON.parse('{"AccessKeyNotFound":{"name":"AccessKeyNotFound","subtypes":[],"props":{"account_id":"","public_key":""}},"AccountAlreadyExists":{"name":"AccountAlreadyExists","subtypes":[],"props":{"account_id":""}},"AccountDoesNotExist":{"name":"AccountDoesNotExist","subtypes":[],"props":{"account_id":""}},"ActionError":{"name":"ActionError","subtypes":["AccountAlreadyExists","AccountDoesNotExist","CreateAccountOnlyByRegistrar","CreateAccountNotAllowed","ActorNoPermission","DeleteKeyDoesNotExist","AddKeyAlreadyExists","DeleteAccountStaking","LackBalanceForState","TriesToUnstake","TriesToStake","InsufficientStake","FunctionCallError","NewReceiptValidationError","OnlyImplicitAccountCreationAllowed","DeleteAccountWithLargeState","DelegateActionInvalidSignature","DelegateActionSenderDoesNotMatchTxReceiver","DelegateActionExpired","DelegateActionAccessKeyError","DelegateActionInvalidNonce","DelegateActionNonceTooLarge"],"props":{"index":""}},"ActionsValidationError":{"name":"ActionsValidationError","subtypes":["DeleteActionMustBeFinal","TotalPrepaidGasExceeded","TotalNumberOfActionsExceeded","AddKeyMethodNamesNumberOfBytesExceeded","AddKeyMethodNameLengthExceeded","IntegerOverflow","InvalidAccountId","ContractSizeExceeded","FunctionCallMethodNameLengthExceeded","FunctionCallArgumentsLengthExceeded","UnsuitableStakingKey","FunctionCallZeroAttachedGas","DelegateActionMustBeOnlyOne","UnsupportedProtocolFeature"],"props":{}},"ActorNoPermission":{"name":"ActorNoPermission","subtypes":[],"props":{"account_id":"","actor_id":""}},"AddKeyAlreadyExists":{"name":"AddKeyAlreadyExists","subtypes":[],"props":{"account_id":"","public_key":""}},"AddKeyMethodNameLengthExceeded":{"name":"AddKeyMethodNameLengthExceeded","subtypes":[],"props":{"length":"","limit":""}},"AddKeyMethodNamesNumberOfBytesExceeded":{"name":"AddKeyMethodNamesNumberOfBytesExceeded","subtypes":[],"props":{"limit":"","total_number_of_bytes":""}},"AltBn128InvalidInput":{"name":"AltBn128InvalidInput","subtypes":[],"props":{"msg":""}},"BadUTF16":{"name":"BadUTF16","subtypes":[],"props":{}},"BadUTF8":{"name":"BadUTF8","subtypes":[],"props":{}},"BalanceExceeded":{"name":"BalanceExceeded","subtypes":[],"props":{}},"BalanceMismatchError":{"name":"BalanceMismatchError","subtypes":[],"props":{"final_accounts_balance":"","final_postponed_receipts_balance":"","incoming_receipts_balance":"","incoming_validator_rewards":"","initial_accounts_balance":"","initial_postponed_receipts_balance":"","new_delayed_receipts_balance":"","other_burnt_amount":"","outgoing_receipts_balance":"","processed_delayed_receipts_balance":"","slashed_burnt_amount":"","tx_burnt_amount":""}},"CallIndirectOOB":{"name":"CallIndirectOOB","subtypes":[],"props":{}},"CannotAppendActionToJointPromise":{"name":"CannotAppendActionToJointPromise","subtypes":[],"props":{}},"CannotReturnJointPromise":{"name":"CannotReturnJointPromise","subtypes":[],"props":{}},"CodeDoesNotExist":{"name":"CodeDoesNotExist","subtypes":[],"props":{"account_id":""}},"CompilationError":{"name":"CompilationError","subtypes":["CodeDoesNotExist","PrepareError","WasmerCompileError"],"props":{}},"ContractSizeExceeded":{"name":"ContractSizeExceeded","subtypes":[],"props":{"limit":"","size":""}},"CostOverflow":{"name":"CostOverflow","subtypes":[],"props":{}},"CreateAccountNotAllowed":{"name":"CreateAccountNotAllowed","subtypes":[],"props":{"account_id":"","predecessor_id":""}},"CreateAccountOnlyByRegistrar":{"name":"CreateAccountOnlyByRegistrar","subtypes":[],"props":{"account_id":"","predecessor_id":"","registrar_account_id":""}},"DelegateActionExpired":{"name":"DelegateActionExpired","subtypes":[],"props":{}},"DelegateActionInvalidNonce":{"name":"DelegateActionInvalidNonce","subtypes":[],"props":{"ak_nonce":"","delegate_nonce":""}},"DelegateActionInvalidSignature":{"name":"DelegateActionInvalidSignature","subtypes":[],"props":{}},"DelegateActionMustBeOnlyOne":{"name":"DelegateActionMustBeOnlyOne","subtypes":[],"props":{}},"DelegateActionNonceTooLarge":{"name":"DelegateActionNonceTooLarge","subtypes":[],"props":{"delegate_nonce":"","upper_bound":""}},"DelegateActionSenderDoesNotMatchTxReceiver":{"name":"DelegateActionSenderDoesNotMatchTxReceiver","subtypes":[],"props":{"receiver_id":"","sender_id":""}},"DeleteAccountStaking":{"name":"DeleteAccountStaking","subtypes":[],"props":{"account_id":""}},"DeleteAccountWithLargeState":{"name":"DeleteAccountWithLargeState","subtypes":[],"props":{"account_id":""}},"DeleteActionMustBeFinal":{"name":"DeleteActionMustBeFinal","subtypes":[],"props":{}},"DeleteKeyDoesNotExist":{"name":"DeleteKeyDoesNotExist","subtypes":[],"props":{"account_id":"","public_key":""}},"DepositWithFunctionCall":{"name":"DepositWithFunctionCall","subtypes":[],"props":{}},"Deprecated":{"name":"Deprecated","subtypes":[],"props":{"method_name":""}},"Deserialization":{"name":"Deserialization","subtypes":[],"props":{}},"ECRecoverError":{"name":"ECRecoverError","subtypes":[],"props":{"msg":""}},"Ed25519VerifyInvalidInput":{"name":"Ed25519VerifyInvalidInput","subtypes":[],"props":{"msg":""}},"EmptyMethodName":{"name":"EmptyMethodName","subtypes":[],"props":{}},"Expired":{"name":"Expired","subtypes":[],"props":{}},"FunctionCallArgumentsLengthExceeded":{"name":"FunctionCallArgumentsLengthExceeded","subtypes":[],"props":{"length":"","limit":""}},"FunctionCallMethodNameLengthExceeded":{"name":"FunctionCallMethodNameLengthExceeded","subtypes":[],"props":{"length":"","limit":""}},"FunctionCallZeroAttachedGas":{"name":"FunctionCallZeroAttachedGas","subtypes":[],"props":{}},"GasExceeded":{"name":"GasExceeded","subtypes":[],"props":{}},"GasInstrumentation":{"name":"GasInstrumentation","subtypes":[],"props":{}},"GasLimitExceeded":{"name":"GasLimitExceeded","subtypes":[],"props":{}},"GenericTrap":{"name":"GenericTrap","subtypes":[],"props":{}},"GuestPanic":{"name":"GuestPanic","subtypes":[],"props":{"panic_msg":""}},"HostError":{"name":"HostError","subtypes":["BadUTF16","BadUTF8","GasExceeded","GasLimitExceeded","BalanceExceeded","EmptyMethodName","GuestPanic","IntegerOverflow","InvalidPromiseIndex","CannotAppendActionToJointPromise","CannotReturnJointPromise","InvalidPromiseResultIndex","InvalidRegisterId","IteratorWasInvalidated","MemoryAccessViolation","InvalidReceiptIndex","InvalidIteratorIndex","InvalidAccountId","InvalidMethodName","InvalidPublicKey","ProhibitedInView","NumberOfLogsExceeded","KeyLengthExceeded","ValueLengthExceeded","TotalLogLengthExceeded","NumberPromisesExceeded","NumberInputDataDependenciesExceeded","ReturnedValueLengthExceeded","ContractSizeExceeded","Deprecated","ECRecoverError","AltBn128InvalidInput","Ed25519VerifyInvalidInput"],"props":{}},"IllegalArithmetic":{"name":"IllegalArithmetic","subtypes":[],"props":{}},"IncorrectCallIndirectSignature":{"name":"IncorrectCallIndirectSignature","subtypes":[],"props":{}},"IndirectCallToNull":{"name":"IndirectCallToNull","subtypes":[],"props":{}},"Instantiate":{"name":"Instantiate","subtypes":[],"props":{}},"InsufficientStake":{"name":"InsufficientStake","subtypes":[],"props":{"account_id":"","minimum_stake":"","stake":""}},"IntegerOverflow":{"name":"IntegerOverflow","subtypes":[],"props":{}},"InternalMemoryDeclared":{"name":"InternalMemoryDeclared","subtypes":[],"props":{}},"InvalidAccessKeyError":{"name":"InvalidAccessKeyError","subtypes":["AccessKeyNotFound","ReceiverMismatch","MethodNameMismatch","RequiresFullAccess","NotEnoughAllowance","DepositWithFunctionCall"],"props":{}},"InvalidAccountId":{"name":"InvalidAccountId","subtypes":[],"props":{}},"InvalidChain":{"name":"InvalidChain","subtypes":[],"props":{}},"InvalidDataReceiverId":{"name":"InvalidDataReceiverId","subtypes":[],"props":{"account_id":""}},"InvalidIteratorIndex":{"name":"InvalidIteratorIndex","subtypes":[],"props":{"iterator_index":""}},"InvalidMethodName":{"name":"InvalidMethodName","subtypes":[],"props":{}},"InvalidNonce":{"name":"InvalidNonce","subtypes":[],"props":{"ak_nonce":"","tx_nonce":""}},"InvalidPredecessorId":{"name":"InvalidPredecessorId","subtypes":[],"props":{"account_id":""}},"InvalidPromiseIndex":{"name":"InvalidPromiseIndex","subtypes":[],"props":{"promise_idx":""}},"InvalidPromiseResultIndex":{"name":"InvalidPromiseResultIndex","subtypes":[],"props":{"result_idx":""}},"InvalidPublicKey":{"name":"InvalidPublicKey","subtypes":[],"props":{}},"InvalidReceiptIndex":{"name":"InvalidReceiptIndex","subtypes":[],"props":{"receipt_index":""}},"InvalidReceiverId":{"name":"InvalidReceiverId","subtypes":[],"props":{"account_id":""}},"InvalidRegisterId":{"name":"InvalidRegisterId","subtypes":[],"props":{"register_id":""}},"InvalidSignature":{"name":"InvalidSignature","subtypes":[],"props":{}},"InvalidSignerId":{"name":"InvalidSignerId","subtypes":[],"props":{"account_id":""}},"InvalidTxError":{"name":"InvalidTxError","subtypes":["InvalidAccessKeyError","InvalidSignerId","SignerDoesNotExist","InvalidNonce","NonceTooLarge","InvalidReceiverId","InvalidSignature","NotEnoughBalance","LackBalanceForState","CostOverflow","InvalidChain","Expired","ActionsValidation","TransactionSizeExceeded"],"props":{}},"IteratorWasInvalidated":{"name":"IteratorWasInvalidated","subtypes":[],"props":{"iterator_index":""}},"KeyLengthExceeded":{"name":"KeyLengthExceeded","subtypes":[],"props":{"length":"","limit":""}},"LackBalanceForState":{"name":"LackBalanceForState","subtypes":[],"props":{"account_id":"","amount":""}},"Memory":{"name":"Memory","subtypes":[],"props":{}},"MemoryAccessViolation":{"name":"MemoryAccessViolation","subtypes":[],"props":{}},"MemoryOutOfBounds":{"name":"MemoryOutOfBounds","subtypes":[],"props":{}},"MethodEmptyName":{"name":"MethodEmptyName","subtypes":[],"props":{}},"MethodInvalidSignature":{"name":"MethodInvalidSignature","subtypes":[],"props":{}},"MethodNameMismatch":{"name":"MethodNameMismatch","subtypes":[],"props":{"method_name":""}},"MethodNotFound":{"name":"MethodNotFound","subtypes":[],"props":{}},"MethodResolveError":{"name":"MethodResolveError","subtypes":["MethodEmptyName","MethodNotFound","MethodInvalidSignature"],"props":{}},"MisalignedAtomicAccess":{"name":"MisalignedAtomicAccess","subtypes":[],"props":{}},"NonceTooLarge":{"name":"NonceTooLarge","subtypes":[],"props":{"tx_nonce":"","upper_bound":""}},"NotEnoughAllowance":{"name":"NotEnoughAllowance","subtypes":[],"props":{"account_id":"","allowance":"","cost":"","public_key":""}},"NotEnoughBalance":{"name":"NotEnoughBalance","subtypes":[],"props":{"balance":"","cost":"","signer_id":""}},"NumberInputDataDependenciesExceeded":{"name":"NumberInputDataDependenciesExceeded","subtypes":[],"props":{"limit":"","number_of_input_data_dependencies":""}},"NumberOfLogsExceeded":{"name":"NumberOfLogsExceeded","subtypes":[],"props":{"limit":""}},"NumberPromisesExceeded":{"name":"NumberPromisesExceeded","subtypes":[],"props":{"limit":"","number_of_promises":""}},"OnlyImplicitAccountCreationAllowed":{"name":"OnlyImplicitAccountCreationAllowed","subtypes":[],"props":{"account_id":""}},"PrepareError":{"name":"PrepareError","subtypes":["Serialization","Deserialization","InternalMemoryDeclared","GasInstrumentation","StackHeightInstrumentation","Instantiate","Memory","TooManyFunctions","TooManyLocals"],"props":{}},"ProhibitedInView":{"name":"ProhibitedInView","subtypes":[],"props":{"method_name":""}},"ReceiptValidationError":{"name":"ReceiptValidationError","subtypes":["InvalidPredecessorId","InvalidReceiverId","InvalidSignerId","InvalidDataReceiverId","ReturnedValueLengthExceeded","NumberInputDataDependenciesExceeded","ActionsValidation"],"props":{}},"ReceiverMismatch":{"name":"ReceiverMismatch","subtypes":[],"props":{"ak_receiver":"","tx_receiver":""}},"RequiresFullAccess":{"name":"RequiresFullAccess","subtypes":[],"props":{}},"ReturnedValueLengthExceeded":{"name":"ReturnedValueLengthExceeded","subtypes":[],"props":{"length":"","limit":""}},"Serialization":{"name":"Serialization","subtypes":[],"props":{}},"SignerDoesNotExist":{"name":"SignerDoesNotExist","subtypes":[],"props":{"signer_id":""}},"StackHeightInstrumentation":{"name":"StackHeightInstrumentation","subtypes":[],"props":{}},"StackOverflow":{"name":"StackOverflow","subtypes":[],"props":{}},"TooManyFunctions":{"name":"TooManyFunctions","subtypes":[],"props":{}},"TooManyLocals":{"name":"TooManyLocals","subtypes":[],"props":{}},"TotalLogLengthExceeded":{"name":"TotalLogLengthExceeded","subtypes":[],"props":{"length":"","limit":""}},"TotalNumberOfActionsExceeded":{"name":"TotalNumberOfActionsExceeded","subtypes":[],"props":{"limit":"","total_number_of_actions":""}},"TotalPrepaidGasExceeded":{"name":"TotalPrepaidGasExceeded","subtypes":[],"props":{"limit":"","total_prepaid_gas":""}},"TransactionSizeExceeded":{"name":"TransactionSizeExceeded","subtypes":[],"props":{"limit":"","size":""}},"TriesToStake":{"name":"TriesToStake","subtypes":[],"props":{"account_id":"","balance":"","locked":"","stake":""}},"TriesToUnstake":{"name":"TriesToUnstake","subtypes":[],"props":{"account_id":""}},"TxExecutionError":{"name":"TxExecutionError","subtypes":["ActionError","InvalidTxError"],"props":{}},"Unreachable":{"name":"Unreachable","subtypes":[],"props":{}},"UnsuitableStakingKey":{"name":"UnsuitableStakingKey","subtypes":[],"props":{"public_key":""}},"UnsupportedProtocolFeature":{"name":"UnsupportedProtocolFeature","subtypes":[],"props":{"protocol_feature":"","version":""}},"ValueLengthExceeded":{"name":"ValueLengthExceeded","subtypes":[],"props":{"length":"","limit":""}},"WasmTrap":{"name":"WasmTrap","subtypes":["Unreachable","IncorrectCallIndirectSignature","MemoryOutOfBounds","CallIndirectOOB","IllegalArithmetic","MisalignedAtomicAccess","IndirectCallToNull","StackOverflow","GenericTrap"],"props":{}},"WasmerCompileError":{"name":"WasmerCompileError","subtypes":[],"props":{"msg":""}},"Closed":{"name":"Closed","subtypes":[],"props":{}},"ServerError":{"name":"ServerError","subtypes":["TxExecutionError","Timeout","Closed"],"props":{}},"Timeout":{"name":"Timeout","subtypes":[],"props":{}}}'),Vr={schema:$r};var Et;function Wr(){if(Et)return z;Et=1;var n=z.__importDefault||function(m){return m&&m.__esModule?m:{default:m}};Object.defineProperty(z,"__esModule",{value:!0}),z.getErrorTypeFromErrorMessage=z.formatError=z.parseResultError=z.parseRpcError=z.ServerError=void 0;const i=Dn(),d=n(xn()),c=Wt(),o=n(Gr),a=n(Vr),s={formatNear:()=>(m,w)=>(0,c.formatNearAmount)(w(m))};class u extends i.TypedError{}z.ServerError=u;class f extends u{}function y(m){const w={},B=I(m,a.default.schema,w,""),R=new u(l(B,w),B);return Object.assign(R,w),R}z.parseRpcError=y;function b(m){const w=y(m.status.Failure),B=new f;return Object.assign(B,w),B.type=w.type,B.message=w.message,B.transaction_outcome=m.transaction_outcome,B}z.parseResultError=b;function l(m,w){return typeof o.default[m]=="string"?d.default.render(o.default[m],Object.assign(Object.assign({},w),s)):JSON.stringify(w)}z.formatError=l;function I(m,w,B,R){let t,e,r;for(const v in w){if(h(m[v]))return m[v];if(g(m[v]))t=m[v],e=w[v],r=v;else if(g(m.kind)&&g(m.kind[v]))t=m.kind[v],e=w[v],r=v;else continue}if(t&&e){for(const v of Object.keys(e.props))B[v]=t[v];return I(t,w,B,r)}else return B.kind=m,R}function p(m,w){switch(!0){case/^account .*? does not exist while viewing$/.test(m):return"AccountDoesNotExist";case/^Account .*? doesn't exist$/.test(m):return"AccountDoesNotExist";case/^access key .*? does not exist while viewing$/.test(m):return"AccessKeyDoesNotExist";case/wasm execution failed with error: FunctionCallError\(CompilationError\(CodeDoesNotExist/.test(m):return"CodeDoesNotExist";case/wasm execution failed with error: CompilationError\(CodeDoesNotExist/.test(m):return"CodeDoesNotExist";case/wasm execution failed with error: FunctionCallError\(MethodResolveError\(MethodNotFound/.test(m):return"MethodNotFound";case/wasm execution failed with error: MethodResolveError\(MethodNotFound/.test(m):return"MethodNotFound";case/Transaction nonce \d+ must be larger than nonce of the used access key \d+/.test(m):return"InvalidNonce";default:return w}}z.getErrorTypeFromErrorMessage=p;function g(m){return Object.prototype.toString.call(m)==="[object Object]"}function h(m){return Object.prototype.toString.call(m)==="[object String]"}return z}var At;function Ht(){return At||(At=1,function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.parseRpcError=n.parseResultError=n.getErrorTypeFromErrorMessage=n.formatError=n.ServerError=n.logWarning=void 0;var i=En();Object.defineProperty(n,"logWarning",{enumerable:!0,get:function(){return i.logWarning}});var d=Wr();Object.defineProperty(n,"ServerError",{enumerable:!0,get:function(){return d.ServerError}}),Object.defineProperty(n,"formatError",{enumerable:!0,get:function(){return d.formatError}}),Object.defineProperty(n,"getErrorTypeFromErrorMessage",{enumerable:!0,get:function(){return d.getErrorTypeFromErrorMessage}}),Object.defineProperty(n,"parseResultError",{enumerable:!0,get:function(){return d.parseResultError}}),Object.defineProperty(n,"parseRpcError",{enumerable:!0,get:function(){return d.parseRpcError}})}(Je)),Je}var ce={},Nt;function Hr(){if(Nt)return ce;Nt=1,Object.defineProperty(ce,"__esModule",{value:!0}),ce.printTxOutcomeLogs=ce.printTxOutcomeLogsAndFailures=void 0;const n=Ht(),i=Xe();function d({contractId:o,outcome:a}){const s=[a.transaction_outcome,...a.receipts_outcome].reduce((u,f)=>{const y=typeof f.outcome.status=="object"&&typeof f.outcome.status.Failure=="object";return f.outcome.logs.length||y?u.concat({receiptIds:f.outcome.receipt_ids,logs:f.outcome.logs,failure:typeof f.outcome.status=="object"&&f.outcome.status.Failure!==void 0?(0,n.parseRpcError)(f.outcome.status.Failure):null}):u},[]);for(const u of s)i.Logger.log(`Receipt${u.receiptIds.length>1?"s":""}: ${u.receiptIds.join(", ")}`),c({contractId:o,logs:u.logs,prefix:" "}),u.failure&&i.Logger.warn(` Failure [${o}]: ${u.failure}`)}ce.printTxOutcomeLogsAndFailures=d;function c({contractId:o,logs:a,prefix:s=""}){for(const u of a)i.Logger.log(`${s}Log [${o}]: ${u}`)}return ce.printTxOutcomeLogs=c,ce}var Ae={},Bt;function jr(){if(Bt)return Ae;Bt=1,Object.defineProperty(Ae,"__esModule",{value:!0}),Ae.getTransactionLastResult=void 0;function n(i){if(typeof i.status=="object"&&typeof i.status.SuccessValue=="string"){const d=Buffer.from(i.status.SuccessValue,"base64").toString();try{return JSON.parse(d)}catch{return d}}return null}return Ae.getTransactionLastResult=n,Ae}var ne={};/*!
|
|
8
|
+
* depd
|
|
9
|
+
* Copyright(c) 2014-2018 Douglas Christopher Wilson
|
|
10
|
+
* MIT Licensed
|
|
11
|
+
*/var $e,Ot;function Xr(){if(Ot)return $e;Ot=1;var n=gn.default.relative;$e=s;var i=process.cwd();function d(e,r){for(var v=e.split(/[ ,]+/),_=String(r).toLowerCase(),S=0;S<v.length;S++){var T=v[S];if(T&&(T==="*"||T.toLowerCase()===_))return!0}return!1}function c(e,r,v){var _=Object.getOwnPropertyDescriptor(e,r),S=_.value;return _.get=function(){return S},_.writable&&(_.set=function(C){return S=C}),delete _.value,delete _.writable,Object.defineProperty(e,r,_),_}function o(e){for(var r="",v=0;v<e;v++)r+=", arg"+v;return r.substr(2)}function a(e){var r=this.name+": "+this.namespace;this.message&&(r+=" deprecated "+this.message);for(var v=0;v<e.length;v++)r+=`
|
|
12
|
+
at `+e[v].toString();return r}function s(e){if(!e)throw new TypeError("argument namespace is required");var r=m(),v=l(r[1]),_=v[0];function S(T){b.call(S,T)}return S._file=_,S._ignored=f(e),S._namespace=e,S._traced=y(e),S._warned=Object.create(null),S.function=B,S.property=R,S}function u(e,r){var v=typeof e.listenerCount!="function"?e.listeners(r).length:e.listenerCount(r);return v>0}function f(e){if(process.noDeprecation)return!0;var r=process.env.NO_DEPRECATION||"";return d(r,e)}function y(e){if(process.traceDeprecation)return!0;var r=process.env.TRACE_DEPRECATION||"";return d(r,e)}function b(e,r){var v=u(process,"deprecation");if(!(!v&&this._ignored)){var _,S,T,C,A=0,E=!1,N=m(),O=this._file;for(r?(C=r,T=l(N[1]),T.name=C.name,O=T[0]):(A=2,C=l(N[A]),T=C);A<N.length;A++)if(_=l(N[A]),S=_[0],S===O)E=!0;else if(S===this._file)O=this._file;else if(E)break;var D=_?C.join(":")+"__"+_.join(":"):void 0;if(!(D!==void 0&&D in this._warned)){this._warned[D]=!0;var k=e;if(k||(k=T===C||!T.name?I(C):I(T)),v){var x=t(this._namespace,k,N.slice(A));process.emit("deprecation",x);return}var P=process.stderr.isTTY?g:p,U=P.call(this,k,_,N.slice(A));process.stderr.write(U+`
|
|
13
|
+
`,"utf8")}}}function l(e){var r=e.getFileName()||"<anonymous>",v=e.getLineNumber(),_=e.getColumnNumber();e.isEval()&&(r=e.getEvalOrigin()+", "+r);var S=[r,v,_];return S.callSite=e,S.name=e.getFunctionName(),S}function I(e){var r=e.callSite,v=e.name;v||(v="<anonymous@"+h(e)+">");var _=r.getThis(),S=_&&r.getTypeName();return S==="Object"&&(S=void 0),S==="Function"&&(S=_.name||S),S&&r.getMethodName()?S+"."+v:v}function p(e,r,v){var _=new Date().toUTCString(),S=_+" "+this._namespace+" deprecated "+e;if(this._traced){for(var T=0;T<v.length;T++)S+=`
|
|
14
|
+
at `+v[T].toString();return S}return r&&(S+=" at "+h(r)),S}function g(e,r,v){var _="\x1B[36;1m"+this._namespace+"\x1B[22;39m \x1B[33;1mdeprecated\x1B[22;39m \x1B[0m"+e+"\x1B[39m";if(this._traced){for(var S=0;S<v.length;S++)_+=`
|
|
15
|
+
\x1B[36mat `+v[S].toString()+"\x1B[39m";return _}return r&&(_+=" \x1B[36m"+h(r)+"\x1B[39m"),_}function h(e){return n(i,e[0])+":"+e[1]+":"+e[2]}function m(){var e=Error.stackTraceLimit,r={},v=Error.prepareStackTrace;Error.prepareStackTrace=w,Error.stackTraceLimit=Math.max(10,e),Error.captureStackTrace(r);var _=r.stack.slice(1);return Error.prepareStackTrace=v,Error.stackTraceLimit=e,_}function w(e,r){return r}function B(e,r){if(typeof e!="function")throw new TypeError("argument fn must be a function");var v=o(e.length),_=m(),S=l(_[1]);S.name=e.name;var T=new Function("fn","log","deprecate","message","site",`"use strict"
|
|
16
|
+
return function (`+v+`) {log.call(deprecate, message, site)
|
|
17
|
+
return fn.apply(this, arguments)
|
|
18
|
+
}`)(e,b,this,r,S);return T}function R(e,r,v){if(!e||typeof e!="object"&&typeof e!="function")throw new TypeError("argument obj must be object");var _=Object.getOwnPropertyDescriptor(e,r);if(!_)throw new TypeError("must call property on owner object");if(!_.configurable)throw new TypeError("property must be configurable");var S=this,T=m(),C=l(T[1]);C.name=r,"value"in _&&(_=c(e,r));var A=_.get,E=_.set;typeof A=="function"&&(_.get=function(){return b.call(S,v,C),A.apply(this,arguments)}),typeof E=="function"&&(_.set=function(){return b.call(S,v,C),E.apply(this,arguments)}),Object.defineProperty(e,r,_)}function t(e,r,v){var _=new Error,S;return Object.defineProperty(_,"constructor",{value:t}),Object.defineProperty(_,"message",{configurable:!0,enumerable:!1,value:r,writable:!0}),Object.defineProperty(_,"name",{enumerable:!1,configurable:!0,value:"DeprecationError",writable:!0}),Object.defineProperty(_,"namespace",{configurable:!0,enumerable:!1,value:e,writable:!0}),Object.defineProperty(_,"stack",{configurable:!0,enumerable:!1,get:function(){return S!==void 0?S:S=a.call(this,v)},set:function(C){S=C}}),_}return $e}var Tt;function Zr(){if(Tt)return ne;Tt=1;var n=ne.__importDefault||function(u){return u&&u.__esModule?u:{default:u}};Object.defineProperty(ne,"__esModule",{value:!0}),ne.diffEpochValidators=ne.findSeatPrice=void 0;const i=n(fe.default),d=n(Xr());function c(u,f,y,b){return b&&b<49?o(u,f):(y||((0,d.default)("findSeatPrice(validators, maxNumberOfSeats)")("`use `findSeatPrice(validators, maxNumberOfSeats, minimumStakeRatio)` instead"),y=[1,6250]),a(u,f,y))}ne.findSeatPrice=c;function o(u,f){const y=u.map(g=>new i.default(g.stake,10)).sort((g,h)=>g.cmp(h)),b=new i.default(f),l=y.reduce((g,h)=>g.add(h));if(l.lt(b))throw new Error("Stakes are below seats");let I=new i.default(1),p=l.add(new i.default(1));for(;!I.eq(p.sub(new i.default(1)));){const g=I.add(p).div(new i.default(2));let h=!1,m=new i.default(0);for(let w=0;w<y.length;++w)if(m=m.add(y[w].div(g)),m.gte(b)){I=g,h=!0;break}h||(p=g)}return I}function a(u,f,y){if(y.length!=2)throw Error("minimumStakeRatio should have 2 elements");const b=u.map(I=>new i.default(I.stake,10)).sort((I,p)=>I.cmp(p)),l=b.reduce((I,p)=>I.add(p));return u.length<f?l.mul(new i.default(y[0])).div(new i.default(y[1])):b[0].add(new i.default(1))}function s(u,f){const y=new Map;u.forEach(l=>y.set(l.account_id,l));const b=new Set(f.map(l=>l.account_id));return{newValidators:f.filter(l=>!y.has(l.account_id)),removedValidators:u.filter(l=>!b.has(l.account_id)),changedValidators:f.filter(l=>y.has(l.account_id)&&y.get(l.account_id).stake!=l.stake).map(l=>({current:y.get(l.account_id),next:l}))}}return ne.diffEpochValidators=s,ne}var Dt;function Yr(){return Dt||(Dt=1,function(n){var i=_e.__createBinding||(Object.create?function(c,o,a,s){s===void 0&&(s=a);var u=Object.getOwnPropertyDescriptor(o,a);(!u||("get"in u?!o.__esModule:u.writable||u.configurable))&&(u={enumerable:!0,get:function(){return o[a]}}),Object.defineProperty(c,s,u)}:function(c,o,a,s){s===void 0&&(s=a),c[s]=o[a]}),d=_e.__exportStar||function(c,o){for(var a in c)a!=="default"&&!Object.prototype.hasOwnProperty.call(o,a)&&i(o,c,a)};Object.defineProperty(n,"__esModule",{value:!0}),d(Sn(),n),d(Ht(),n),d(Wt(),n),d(Hr(),n),d(jr(),n),d(Zr(),n),d(Xe(),n)}(_e)),_e}var kt;function Qr(){return kt||(kt=1,function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.base_decode=n.base_encode=n.deserialize=n.serialize=void 0;var i=vn();Object.defineProperty(n,"serialize",{enumerable:!0,get:function(){return i.serialize}}),Object.defineProperty(n,"deserialize",{enumerable:!0,get:function(){return i.deserialize}});var d=Yr();Object.defineProperty(n,"base_encode",{enumerable:!0,get:function(){return d.baseEncode}}),Object.defineProperty(n,"base_decode",{enumerable:!0,get:function(){return d.baseDecode}})}(Le)),Le}var ei=Qr();class ti{}let jt=class extends ti{};const Pe=new fe.default("300000000000000"),Ze="dontcare",Me=async({networkId:n,accountId:i=Ze,keypair:d=zt.KeyPair.fromRandom("ed25519")})=>{const c=new ln.InMemoryKeyStore;await c.setKey(n,i,d);const o=He.Connection.fromConfig({networkId:n,provider:{type:"JsonRpcProvider",args:{url:{testnet:"https://rpc.testnet.near.org",mainnet:"https://rpc.mainnet.near.org"}[n]}},signer:{type:"InMemorySigner",keyStore:c}});return new He.Account(o,i)};function ni(n){return{delegate_action:{actions:n.delegateAction.actions.map(i=>{if(i.functionCall)return{FunctionCall:{method_name:i.functionCall.methodName,args:Buffer.from(i.functionCall.args).toString("base64"),gas:Number(i.functionCall.gas),deposit:i.functionCall.deposit.toString()}}}).flatMap(i=>i?[i]:[]),nonce:Number(n.delegateAction.nonce),max_block_height:Number(n.delegateAction.maxBlockHeight),public_key:n.delegateAction.publicKey.toString(),receiver_id:n.delegateAction.receiverId,sender_id:n.delegateAction.senderId},signature:`ed25519:${Gt.default.encode(n.signature.data)}`}}const xt=n=>`04${Buffer.from(ei.base_decode(n.split(":")[1])).toString("hex")}`,ri=n=>{if(n===Ze)throw new Error("A valid account ID and keypair are required for change methods. Please instantiate a new contract with valid credentials.")};class pe extends jt{constructor({networkId:i,contractId:d,accountId:c=Ze,keypair:o=zt.KeyPair.fromRandom("ed25519")}){super(),this.networkId=i,this.contractId=d,this.accountId=c,this.keypair=o}async getContract(){const i=await Me({networkId:this.networkId,accountId:this.accountId,keypair:this.keypair});return new He.Contract(i,this.contractId,{viewMethods:["public_key","experimental_signature_deposit","derived_public_key"],changeMethods:["sign"],useLocalViewExecution:!1})}async getCurrentSignatureDeposit(){const i=await this.getContract();return new fe.default((await i.experimental_signature_deposit()).toLocaleString("fullwide",{useGrouping:!1}))}async getDerivedPublicKey(i){const c=await(await this.getContract()).derived_public_key(i);return xt(c)}async getPublicKey(){const d=await(await this.getContract()).public_key();return xt(d)}async sign(i){ri(this.accountId);const d=await this.getContract(),c=await this.getCurrentSignatureDeposit(),o=await d.sign({args:{request:i},gas:Pe,amount:c});return Ye(o)}static async signWithRelayer({account:i,contract:d,signArgs:c,deposit:o,relayerUrl:a}){const s=un.actionCreators.functionCall("sign",{request:c},BigInt(Pe.toString()),BigInt(o.toString())),u=await i.signedDelegate({receiverId:d,actions:[s],blockHeightTtl:60});delete i.accessKeyByPublicKeyCache[u.delegateAction.publicKey.toString()];const y=await(await fetch(`${a}/send_meta_tx_async`,{method:"POST",mode:"cors",body:JSON.stringify(ni(u)),headers:new Headers({"Content-Type":"application/json"})})).text(),b=await i.connection.provider.txStatus(y,i.accountId,"FINAL"),l=Xt({response:b});if(!l)throw new Error("Signature error, please retry");return l}}const ii=async({networkId:n,contractId:i,mpcPayloads:d,path:c})=>{const a=await new pe({networkId:n,contractId:i}).getCurrentSignatureDeposit();return{receiverId:i,actions:d.map(s=>({type:"FunctionCall",params:{methodName:"sign",args:{request:{payload:Array.from(s),path:c,key_version:0}},gas:Pe.div(new fe.default(d.length)).toString(),deposit:a?.toString()||"1"}}))}},oi=async({networkId:n,chainSigContract:i,nftKeysContract:d,mpcPayloads:c,path:o,tokenId:a})=>{const u=await new pe({networkId:n,contractId:i}).getCurrentSignatureDeposit();return{receiverId:d,actions:c.map(f=>({type:"FunctionCall",params:{methodName:"ckt_sign_hash",args:{token_id:a,path:o,payload:Array.from(f)},gas:Pe.div(new fe.default(c.length)).toString(),deposit:u?.toString()||"1"}}))}},Xt=({response:n})=>{const i=n.receipts_outcome.reduce((d,c)=>{if(d)return d;const{status:o}=c.outcome;return typeof o=="object"&&o.SuccessValue&&o.SuccessValue!==""&&Buffer.from(o.SuccessValue,"base64").toString("utf-8")||""},"");if(i){const d=JSON.parse(i);return Ye(d.Ok)}else return},ai=Object.freeze({__proto__:null,mpcPayloadsToChainSigTransaction:ii,mpcPayloadsToNFTKeysTransaction:oi,responseToMpcSignature:Xt});class Re{}async function Zt(n,i){const d=new W.ethers.JsonRpcProvider(n),c=await d.estimateGas(i),o=await d.getFeeData(),a=o.maxFeePerGas??W.ethers.parseUnits("10","gwei"),s=o.maxPriorityFeePerGas??W.ethers.parseUnits("10","gwei");return{gasLimit:c,maxFeePerGas:a,maxPriorityFeePerGas:s,maxFee:a*c}}class Yt extends Re{constructor({rpcUrl:i,contract:d}){super(),this.contract=d,this.provider=new W.ethers.JsonRpcProvider(i)}async attachGasAndNonce(i){const d=await Zt(this.provider._getConnection().url,i),c=await this.provider.getTransactionCount(i.from,"latest"),{from:o,...a}=i;return{...d,chainId:this.provider._network.chainId,nonce:c,type:2,...a}}parseSignature(i){return W.ethers.Signature.from({r:`0x${i.r}`,s:`0x${i.s}`,v:i.v})}async deriveAddressAndPublicKey(i,d){const c=await this.contract.getDerivedPublicKey({path:d,predecessor:i});if(!c)throw new Error("Failed to get derived public key");const o=c.startsWith("04")?c.substring(2):c,a=W.ethers.keccak256(re.fromHex(o));return{address:`0x${a.substring(a.length-40)}`,publicKey:c}}async getBalance(i){try{const d=await this.provider.getBalance(i);return W.ethers.formatEther(d)}catch(d){throw console.error(`Failed to fetch balance for address ${i}:`,d),new Error("Failed to fetch balance.")}}setTransaction(i,d){const c=JSON.stringify(i,(o,a)=>typeof a=="bigint"?a.toString():a);window.localStorage.setItem(d,c)}getTransaction(i,d){const c=window.localStorage.getItem(i);return d?.remove&&window.localStorage.removeItem(i),c?JSON.parse(c):void 0}async getMPCPayloadAndTransaction(i){const d=await this.attachGasAndNonce(i),c=W.ethers.Transaction.from(d).unsignedSerialized,o=W.keccak256(c),a=Array.from(W.ethers.getBytes(o));return{transaction:d,mpcPayloads:[a]}}addSignature({transaction:i,mpcSignatures:d}){return W.ethers.Transaction.from({...i,signature:this.parseSignature(d[0])}).serialized}async broadcastTx(i){try{return(await this.provider.broadcastTransaction(i)).hash}catch(d){throw console.error("Transaction broadcast failed:",d),new Error("Failed to broadcast transaction.")}}}function Pt(n){switch(n.toLowerCase()){case"mainnet":return ie.networks.bitcoin;case"testnet":return ie.networks.testnet;case"regtest":return ie.networks.regtest;default:throw new Error(`Unknown Bitcoin network: ${n}`)}}class de extends Re{static{this.SATOSHIS_PER_BTC=1e8}constructor({network:i,contract:d,btcRpcAdapter:c}){super(),this.network=i,this.btcRpcAdapter=c,this.contract=d}static toBTC(i){return i/de.SATOSHIS_PER_BTC}static toSatoshi(i){return Math.round(i*de.SATOSHIS_PER_BTC)}async fetchTransaction(i){const d=await this.btcRpcAdapter.getTransaction(i),c=new ie.Transaction;return d.vout.forEach(o=>{const a=Buffer.from(o.scriptpubkey,"hex");c.addOutput(a,Number(o.value))}),c}static parseRSVSignature(i){const d=i.r.padStart(64,"0"),c=i.s.padStart(64,"0"),o=Buffer.from(d+c,"hex");if(o.length!==64)throw new Error("Invalid signature length.");return o}async createPSBT({transactionRequest:i}){const{inputs:d,outputs:c}=i.inputs&&i.outputs?i:await this.btcRpcAdapter.selectUTXOs(i.from,[{address:i.to,value:parseFloat(i.value)}]),o=new ie.Psbt({network:Pt(this.network)});return await Promise.all(d.map(async a=>{if(!a.scriptPubKey){const u=(await this.fetchTransaction(a.txid)).outs[a.vout];a.scriptPubKey=u.script}o.addInput({hash:a.txid,index:a.vout,witnessUtxo:{script:a.scriptPubKey,value:a.value}})})),c.forEach(a=>{a.address?o.addOutput({address:a.address,value:a.value}):a.script&&o.addOutput({script:a.script,value:a.value})}),o}async getBalance(i){const d=await this.btcRpcAdapter.getBalance(i);return de.toBTC(d).toString()}async deriveAddressAndPublicKey(i,d){const c=await this.contract.getDerivedPublicKey({path:d,predecessor:i});if(!c)throw new Error("Failed to get derived public key");const o=Qe(c),a=Buffer.from(o,"hex"),s=Pt(this.network),u=ie.payments.p2wpkh({pubkey:a,network:s}),{address:f}=u;if(!f)throw new Error("Failed to generate Bitcoin address");return{address:f,publicKey:o}}setTransaction(i,d){window.localStorage.setItem(d,JSON.stringify({psbt:i.psbt.toHex(),publicKey:i.publicKey}))}getTransaction(i,d){const c=window.localStorage.getItem(i);if(!c)return;d?.remove&&window.localStorage.removeItem(i);const o=JSON.parse(c);return{psbt:ie.Psbt.fromHex(o.psbt),publicKey:o.publicKey}}async getMPCPayloadAndTransaction(i){const d=Buffer.from(i.publicKey,"hex"),c=await this.createPSBT({transactionRequest:i}),o=c.toHex(),a=[],s=u=>({publicKey:d,sign:f=>(a[u]=Array.from(f),Buffer.alloc(64))});for(let u=0;u<c.inputCount;u++)c.signInput(u,s(u));return{transaction:{psbt:ie.Psbt.fromHex(o),publicKey:i.publicKey},mpcPayloads:a}}addSignature({transaction:{psbt:i,publicKey:d},mpcSignatures:c}){const o=Buffer.from(d,"hex"),a=s=>({publicKey:o,sign:()=>{const u=c[s];return de.parseRSVSignature(u)}});for(let s=0;s<i.inputCount;s++)i.signInput(s,a(s));return i.finalizeAllInputs(),i.extractTransaction().toHex()}async broadcastTx(i){return await this.btcRpcAdapter.broadcastTransaction(i)}}class Qt{}class si extends Qt{constructor(i){super(),this.providerUrl=i}async fetchFeeRate(i=6){const c=await(await fetch(`${this.providerUrl}/v1/fees/recommended`)).json();return i<=1?c.fastestFee:i<=3?c.halfHourFee:i<=6?c.hourFee:c.economyFee}async fetchUTXOs(i){try{return await(await fetch(`${this.providerUrl}/address/${i}/utxo`)).json()}catch(d){return console.error("Failed to fetch UTXOs:",d),[]}}async selectUTXOs(i,d,c=6){const o=await this.fetchUTXOs(i),a=await this.fetchFeeRate(c),s=mn.default(o,d,Math.ceil(a+1));if(!s.inputs||!s.outputs)throw new Error("Invalid transaction: coinselect failed to find a suitable set of inputs and outputs. This could be due to insufficient funds, or no inputs being available that meet the criteria.");return{inputs:s.inputs,outputs:s.outputs}}async broadcastTransaction(i){const d=await fetch(`${this.providerUrl}/tx`,{method:"POST",body:i});if(d.ok)return await d.text();throw new Error(`Failed to broadcast transaction: ${await d.text()}`)}async getBalance(i){const c=await(await fetch(`${this.providerUrl}/address/${i}`)).json();return c.chain_stats.funded_txo_sum-c.chain_stats.spent_txo_sum}async getTransaction(i){return await(await fetch(`${this.providerUrl}/tx/${i}`)).json()}}const en={Mempool:si};var Ve={},X={},Z={},Y={},Ct;function ci(){if(Ct)return Y;Ct=1,Object.defineProperty(Y,"__esModule",{value:!0}),Y.utf8Write=Y.utf8Read=Y.utf8Length=void 0;function n(c){let o=0,a=0;for(let s=0;s<c.length;++s)a=c.charCodeAt(s),a<128?o+=1:a<2048?o+=2:(a&64512)===55296&&(c.charCodeAt(s+1)&64512)===56320?(++s,o+=4):o+=3;return o}Y.utf8Length=n;function i(c,o,a){if(a-o<1)return"";const u=[];let f=[],y=0,b;for(;o<a;)b=c[o++],b<128?u[y++]=b:b>191&&b<224?u[y++]=(b&31)<<6|c[o++]&63:b>239&&b<365?(b=((b&7)<<18|(c[o++]&63)<<12|(c[o++]&63)<<6|c[o++]&63)-65536,u[y++]=55296+(b>>10),u[y++]=56320+(b&1023)):u[y++]=(b&15)<<12|(c[o++]&63)<<6|c[o++]&63,y>8191&&(f.push(String.fromCharCode(...u)),y=0);return y&&f.push(String.fromCharCode(...u.slice(0,y))),f.join("")}Y.utf8Read=i;function d(c,o,a){const s=a;let u,f;for(let y=0;y<c.length;++y)u=c.charCodeAt(y),u<128?o[a++]=u:u<2048?(o[a++]=u>>6|192,o[a++]=u&63|128):(u&64512)===55296&&((f=c.charCodeAt(y+1))&64512)===56320?(u=65536+((u&1023)<<10)+(f&1023),++y,o[a++]=u>>18|240,o[a++]=u>>12&63|128,o[a++]=u>>6&63|128,o[a++]=u&63|128):(o[a++]=u>>12|224,o[a++]=u>>6&63|128,o[a++]=u&63|128);return a-s}return Y.utf8Write=d,Y}var M={},Mt;function ui(){if(Mt)return M;Mt=1,Object.defineProperty(M,"__esModule",{value:!0}),M.writeByte=M.writeFixed32=M.int64Length=M.writeVarint64=M.writeVarint32=M.readInt32=M.readUInt32=M.zzDecode=M.zzEncode=M.varint32read=M.varint32write=M.uInt64ToString=M.int64ToString=M.int64FromString=M.varint64write=M.varint64read=void 0;function n(){let e=0,r=0;for(let _=0;_<28;_+=7){let S=this.buf[this.pos++];if(e|=(S&127)<<_,!(S&128))return this.assertBounds(),[e,r]}let v=this.buf[this.pos++];if(e|=(v&15)<<28,r=(v&112)>>4,!(v&128))return this.assertBounds(),[e,r];for(let _=3;_<=31;_+=7){let S=this.buf[this.pos++];if(r|=(S&127)<<_,!(S&128))return this.assertBounds(),[e,r]}throw new Error("invalid varint")}M.varint64read=n;function i(e,r,v){for(let T=0;T<28;T=T+7){const C=e>>>T,A=!(!(C>>>7)&&r==0),E=(A?C|128:C)&255;if(v.push(E),!A)return}const _=e>>>28&15|(r&7)<<4,S=!!(r>>3);if(v.push((S?_|128:_)&255),!!S){for(let T=3;T<31;T=T+7){const C=r>>>T,A=!!(C>>>7),E=(A?C|128:C)&255;if(v.push(E),!A)return}v.push(r>>>31&1)}}M.varint64write=i;const d=4294967296;function c(e){const r=e[0]==="-";r&&(e=e.slice(1));const v=1e6;let _=0,S=0;function T(C,A){const E=Number(e.slice(C,A));S*=v,_=_*v+E,_>=d&&(S=S+(_/d|0),_=_%d)}return T(-24,-18),T(-18,-12),T(-12,-6),T(-6),r?f(_,S):u(_,S)}M.int64FromString=c;function o(e,r){let v=u(e,r);const _=v.hi&2147483648;_&&(v=f(v.lo,v.hi));const S=a(v.lo,v.hi);return _?"-"+S:S}M.int64ToString=o;function a(e,r){if({lo:e,hi:r}=s(e,r),r<=2097151)return String(d*r+e);const v=e&16777215,_=(e>>>24|r<<8)&16777215,S=r>>16&65535;let T=v+_*6777216+S*6710656,C=_+S*8147497,A=S*2;const E=1e7;return T>=E&&(C+=Math.floor(T/E),T%=E),C>=E&&(A+=Math.floor(C/E),C%=E),A.toString()+y(C)+y(T)}M.uInt64ToString=a;function s(e,r){return{lo:e>>>0,hi:r>>>0}}function u(e,r){return{lo:e|0,hi:r|0}}function f(e,r){return r=~r,e?e=~e+1:r+=1,u(e,r)}const y=e=>{const r=String(e);return"0000000".slice(r.length)+r};function b(e,r){if(e>=0){for(;e>127;)r.push(e&127|128),e=e>>>7;r.push(e)}else{for(let v=0;v<9;v++)r.push(e&127|128),e=e>>7;r.push(1)}}M.varint32write=b;function l(){let e=this.buf[this.pos++],r=e&127;if(!(e&128))return this.assertBounds(),r;if(e=this.buf[this.pos++],r|=(e&127)<<7,!(e&128))return this.assertBounds(),r;if(e=this.buf[this.pos++],r|=(e&127)<<14,!(e&128))return this.assertBounds(),r;if(e=this.buf[this.pos++],r|=(e&127)<<21,!(e&128))return this.assertBounds(),r;e=this.buf[this.pos++],r|=(e&15)<<28;for(let v=5;e&128&&v<10;v++)e=this.buf[this.pos++];if(e&128)throw new Error("invalid varint");return this.assertBounds(),r>>>0}M.varint32read=l;function I(e,r){let v=r>>31;return r=((r<<1|e>>>31)^v)>>>0,e=(e<<1^v)>>>0,[e,r]}M.zzEncode=I;function p(e,r){let v=-(e&1);return e=((e>>>1|r<<31)^v)>>>0,r=(r>>>1^v)>>>0,[e,r]}M.zzDecode=p;function g(e,r){return(e[r]|e[r+1]<<8|e[r+2]<<16)+e[r+3]*16777216}M.readUInt32=g;function h(e,r){return(e[r]|e[r+1]<<8|e[r+2]<<16)+(e[r+3]<<24)}M.readInt32=h;function m(e,r,v){for(;e>127;)r[v++]=e&127|128,e>>>=7;r[v]=e}M.writeVarint32=m;function w(e,r,v){for(;e.hi;)r[v++]=e.lo&127|128,e.lo=(e.lo>>>7|e.hi<<25)>>>0,e.hi>>>=7;for(;e.lo>127;)r[v++]=e.lo&127|128,e.lo=e.lo>>>7;r[v++]=e.lo}M.writeVarint64=w;function B(e,r){let v=e,_=(e>>>28|r<<4)>>>0,S=r>>>24;return S===0?_===0?v<16384?v<128?1:2:v<2097152?3:4:_<16384?_<128?5:6:_<2097152?7:8:S<128?9:10}M.int64Length=B;function R(e,r,v){r[v]=e&255,r[v+1]=e>>>8&255,r[v+2]=e>>>16&255,r[v+3]=e>>>24}M.writeFixed32=R;function t(e,r,v){r[v]=e&255}return M.writeByte=t,M}var Rt;function Ne(){if(Rt)return Z;Rt=1,Object.defineProperty(Z,"__esModule",{value:!0}),Z.BinaryWriter=Z.BinaryReader=Z.WireType=void 0;const n=ci(),i=ui();var d;(function(b){b[b.Varint=0]="Varint",b[b.Fixed64=1]="Fixed64",b[b.Bytes=2]="Bytes",b[b.Fixed32=5]="Fixed32"})(d||(Z.WireType=d={}));class c{assertBounds(){if(this.pos>this.len)throw new RangeError("premature EOF")}constructor(l){this.buf=l?new Uint8Array(l):new Uint8Array(0),this.pos=0,this.type=0,this.len=this.buf.length}tag(){const l=this.uint32(),I=l>>>3,p=l&7;if(I<=0||p<0||p>5)throw new Error("illegal tag: field no "+I+" wire type "+p);return[I,p,l]}skip(l){if(typeof l=="number"){if(this.pos+l>this.len)throw y(this,l);this.pos+=l}else do if(this.pos>=this.len)throw y(this);while(this.buf[this.pos++]&128);return this}skipType(l){switch(l){case d.Varint:this.skip();break;case d.Fixed64:this.skip(8);break;case d.Bytes:this.skip(this.uint32());break;case 3:for(;(l=this.uint32()&7)!==4;)this.skipType(l);break;case d.Fixed32:this.skip(4);break;default:throw Error("invalid wire type "+l+" at offset "+this.pos)}return this}uint32(){return i.varint32read.bind(this)()}int32(){return this.uint32()|0}sint32(){const l=this.uint32();return l%2===1?(l+1)/-2:l/2}fixed32(){const l=(0,i.readUInt32)(this.buf,this.pos);return this.pos+=4,l}sfixed32(){const l=(0,i.readInt32)(this.buf,this.pos);return this.pos+=4,l}int64(){const[l,I]=i.varint64read.bind(this)();return BigInt((0,i.int64ToString)(l,I))}uint64(){const[l,I]=i.varint64read.bind(this)();return BigInt((0,i.uInt64ToString)(l,I))}sint64(){let[l,I]=i.varint64read.bind(this)();return[l,I]=(0,i.zzDecode)(l,I),BigInt((0,i.int64ToString)(l,I))}fixed64(){const l=this.sfixed32(),I=this.sfixed32();return BigInt((0,i.uInt64ToString)(l,I))}sfixed64(){const l=this.sfixed32(),I=this.sfixed32();return BigInt((0,i.int64ToString)(l,I))}float(){throw new Error("float not supported")}double(){throw new Error("double not supported")}bool(){const[l,I]=i.varint64read.bind(this)();return l!==0||I!==0}bytes(){const l=this.uint32(),I=this.pos;return this.pos+=l,this.assertBounds(),this.buf.subarray(I,I+l)}string(){const l=this.bytes();return(0,n.utf8Read)(l,0,l.length)}}Z.BinaryReader=c;class o{constructor(l,I,p){this.fn=l,this.len=I,this.val=p}proceed(l,I){this.fn&&this.fn(this.val,l,I)}}class a{constructor(l){this.head=l.head,this.tail=l.tail,this.len=l.len,this.next=l.states}}class s{constructor(){this.len=0,this.uint64=s.prototype.int64,this.sfixed64=s.prototype.fixed64,this.sfixed32=s.prototype.fixed32,this.head=new o(null,0,0),this.tail=this.head,this.states=null}static create(){return new s}static alloc(l){return typeof Uint8Array<"u"?f(I=>new Uint8Array(I),Uint8Array.prototype.subarray)(l):new Array(l)}_push(l,I,p){return this.tail=this.tail.next=new o(l,I,p),this.len+=I,this}finish(){let l=this.head.next,I=0;const p=s.alloc(this.len);for(;l;)l.proceed(p,I),I+=l.len,l=l.next;return p}fork(){return this.states=new a(this),this.head=this.tail=new o(null,0,0),this.len=0,this}reset(){return this.states?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new o(null,0,0),this.len=0),this}ldelim(){const l=this.head,I=this.tail,p=this.len;return this.reset().uint32(p),p&&(this.tail.next=l.next,this.tail=I,this.len+=p),this}tag(l,I){return this.uint32((l<<3|I)>>>0)}uint32(l){return this.len+=(this.tail=this.tail.next=new o(i.writeVarint32,(l=l>>>0)<128?1:l<16384?2:l<2097152?3:l<268435456?4:5,l)).len,this}int32(l){return l<0?this._push(i.writeVarint64,10,(0,i.int64FromString)(l.toString())):this.uint32(l)}sint32(l){return this.uint32((l<<1^l>>31)>>>0)}int64(l){const{lo:I,hi:p}=(0,i.int64FromString)(l.toString());return this._push(i.writeVarint64,(0,i.int64Length)(I,p),{lo:I,hi:p})}sint64(l){let{lo:I,hi:p}=(0,i.int64FromString)(l.toString());return[I,p]=(0,i.zzEncode)(I,p),this._push(i.writeVarint64,(0,i.int64Length)(I,p),{lo:I,hi:p})}fixed64(l){const{lo:I,hi:p}=(0,i.int64FromString)(l.toString());return this._push(i.writeFixed32,4,I)._push(i.writeFixed32,4,p)}bool(l){return this._push(i.writeByte,1,l?1:0)}fixed32(l){return this._push(i.writeFixed32,4,l>>>0)}float(l){throw new Error("float not supported"+l)}double(l){throw new Error("double not supported"+l)}bytes(l){const I=l.length>>>0;return I?this.uint32(I)._push(u,I,l):this._push(i.writeByte,1,0)}string(l){const I=(0,n.utf8Length)(l);return I?this.uint32(I)._push(n.utf8Write,I,l):this._push(i.writeByte,1,0)}}Z.BinaryWriter=s;function u(b,l,I){if(typeof Uint8Array<"u")l.set(b,I);else for(let p=0;p<b.length;++p)l[I+p]=b[p]}function f(b,l,I){let h=null,m=8192;return function(B){if(B<1||B>4096)return b(B);m+B>8192&&(h=b(8192),m=0);const R=l.call(h,m,m+=B);return m&7&&(m=(m|7)+1),R}}function y(b,l){return RangeError("index out of range: "+b.pos+" + "+(l||1)+" > "+b.len)}return Z}var F={},Ft;function Be(){if(Ft)return F;Ft=1,Object.defineProperty(F,"__esModule",{value:!0}),F.fromJsonTimestamp=F.fromTimestamp=F.toTimestamp=F.setPaginationParams=F.isObject=F.isSet=F.fromDuration=F.toDuration=F.omitDefault=F.base64FromBytes=F.bytesFromBase64=void 0;var n=(()=>{if(typeof n<"u")return n;if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof it<"u")return it;throw"Unable to locate global object"})();const i=n.atob||(m=>n.Buffer.from(m,"base64").toString("binary"));function d(m){const w=i(m),B=new Uint8Array(w.length);for(let R=0;R<w.length;++R)B[R]=w.charCodeAt(R);return B}F.bytesFromBase64=d;const c=n.btoa||(m=>n.Buffer.from(m,"binary").toString("base64"));function o(m){const w=[];return m.forEach(B=>{w.push(String.fromCharCode(B))}),c(w.join(""))}F.base64FromBytes=o;function a(m){if(typeof m=="string")return m===""?void 0:m;if(typeof m=="number")return m===0?void 0:m;if(typeof m=="bigint")return m===BigInt(0)?void 0:m;throw new Error(`Got unsupported type ${typeof m}`)}F.omitDefault=a;function s(m){return{seconds:BigInt(Math.floor(parseInt(m)/1e9)),nanos:parseInt(m)%1e9}}F.toDuration=s;function u(m){return(parseInt(m.seconds.toString())*1e9+m.nanos).toString()}F.fromDuration=u;function f(m){return m!=null}F.isSet=f;function y(m){return typeof m=="object"&&m!==null}F.isObject=y;const b=(m,w)=>(w&&(typeof w?.countTotal<"u"&&(m.params["pagination.count_total"]=w.countTotal),typeof w?.key<"u"&&(m.params["pagination.key"]=Buffer.from(w.key).toString("base64")),typeof w?.limit<"u"&&(m.params["pagination.limit"]=w.limit.toString()),typeof w?.offset<"u"&&(m.params["pagination.offset"]=w.offset.toString()),typeof w?.reverse<"u"&&(m.params["pagination.reverse"]=w.reverse)),m);F.setPaginationParams=b;function l(m){const w=h(m.getTime()/1e3),B=m.getTime()%1e3*1e6;return{seconds:w,nanos:B}}F.toTimestamp=l;function I(m){let w=Number(m.seconds)*1e3;return w+=m.nanos/1e6,new Date(w)}F.fromTimestamp=I;const p=m=>({seconds:f(m.seconds)?BigInt(m.seconds.toString()):BigInt(0),nanos:f(m.nanos)?Number(m.nanos):0});function g(m){return m instanceof Date?l(m):typeof m=="string"?l(new Date(m)):p(m)}F.fromJsonTimestamp=g;function h(m){return BigInt(Math.trunc(m))}return F}var Ut;function tn(){if(Ut)return X;Ut=1,Object.defineProperty(X,"__esModule",{value:!0}),X.CompactBitArray=X.MultiSignature=X.protobufPackage=void 0;const n=Ne(),i=Be();X.protobufPackage="cosmos.crypto.multisig.v1beta1";function d(){return{signatures:[]}}X.MultiSignature={typeUrl:"/cosmos.crypto.multisig.v1beta1.MultiSignature",encode(o,a=n.BinaryWriter.create()){for(const s of o.signatures)a.uint32(10).bytes(s);return a},decode(o,a){const s=o instanceof n.BinaryReader?o:new n.BinaryReader(o);let u=a===void 0?s.len:s.pos+a;const f=d();for(;s.pos<u;){const y=s.uint32();switch(y>>>3){case 1:f.signatures.push(s.bytes());break;default:s.skipType(y&7);break}}return f},fromJSON(o){const a=d();return Array.isArray(o?.signatures)&&(a.signatures=o.signatures.map(s=>(0,i.bytesFromBase64)(s))),a},toJSON(o){const a={};return o.signatures?a.signatures=o.signatures.map(s=>(0,i.base64FromBytes)(s!==void 0?s:new Uint8Array)):a.signatures=[],a},fromPartial(o){const a=d();return a.signatures=o.signatures?.map(s=>s)||[],a}};function c(){return{extraBitsStored:0,elems:new Uint8Array}}return X.CompactBitArray={typeUrl:"/cosmos.crypto.multisig.v1beta1.CompactBitArray",encode(o,a=n.BinaryWriter.create()){return o.extraBitsStored!==0&&a.uint32(8).uint32(o.extraBitsStored),o.elems.length!==0&&a.uint32(18).bytes(o.elems),a},decode(o,a){const s=o instanceof n.BinaryReader?o:new n.BinaryReader(o);let u=a===void 0?s.len:s.pos+a;const f=c();for(;s.pos<u;){const y=s.uint32();switch(y>>>3){case 1:f.extraBitsStored=s.uint32();break;case 2:f.elems=s.bytes();break;default:s.skipType(y&7);break}}return f},fromJSON(o){const a=c();return(0,i.isSet)(o.extraBitsStored)&&(a.extraBitsStored=Number(o.extraBitsStored)),(0,i.isSet)(o.elems)&&(a.elems=(0,i.bytesFromBase64)(o.elems)),a},toJSON(o){const a={};return o.extraBitsStored!==void 0&&(a.extraBitsStored=Math.round(o.extraBitsStored)),o.elems!==void 0&&(a.elems=(0,i.base64FromBytes)(o.elems!==void 0?o.elems:new Uint8Array)),a},fromPartial(o){const a=c();return a.extraBitsStored=o.extraBitsStored??0,a.elems=o.elems??new Uint8Array,a}},X}var ue={},Lt;function nn(){if(Lt)return ue;Lt=1,Object.defineProperty(ue,"__esModule",{value:!0}),ue.Any=ue.protobufPackage=void 0;const n=Ne(),i=Be();ue.protobufPackage="google.protobuf";function d(){return{typeUrl:"",value:new Uint8Array}}return ue.Any={typeUrl:"/google.protobuf.Any",encode(c,o=n.BinaryWriter.create()){return c.typeUrl!==""&&o.uint32(10).string(c.typeUrl),c.value.length!==0&&o.uint32(18).bytes(c.value),o},decode(c,o){const a=c instanceof n.BinaryReader?c:new n.BinaryReader(c);let s=o===void 0?a.len:a.pos+o;const u=d();for(;a.pos<s;){const f=a.uint32();switch(f>>>3){case 1:u.typeUrl=a.string();break;case 2:u.value=a.bytes();break;default:a.skipType(f&7);break}}return u},fromJSON(c){const o=d();return(0,i.isSet)(c.typeUrl)&&(o.typeUrl=String(c.typeUrl)),(0,i.isSet)(c.value)&&(o.value=(0,i.bytesFromBase64)(c.value)),o},toJSON(c){const o={};return c.typeUrl!==void 0&&(o.typeUrl=c.typeUrl),c.value!==void 0&&(o.value=(0,i.base64FromBytes)(c.value!==void 0?c.value:new Uint8Array)),o},fromPartial(c){const o=d();return o.typeUrl=c.typeUrl??"",o.value=c.value??new Uint8Array,o}},ue}var Jt;function rn(){return Jt||(Jt=1,function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.SignatureDescriptor_Data_Multi=n.SignatureDescriptor_Data_Single=n.SignatureDescriptor_Data=n.SignatureDescriptor=n.SignatureDescriptors=n.signModeToJSON=n.signModeFromJSON=n.SignMode=n.protobufPackage=void 0;const i=tn(),d=nn(),c=Ne(),o=Be();n.protobufPackage="cosmos.tx.signing.v1beta1";var a;(function(p){p[p.SIGN_MODE_UNSPECIFIED=0]="SIGN_MODE_UNSPECIFIED",p[p.SIGN_MODE_DIRECT=1]="SIGN_MODE_DIRECT",p[p.SIGN_MODE_TEXTUAL=2]="SIGN_MODE_TEXTUAL",p[p.SIGN_MODE_DIRECT_AUX=3]="SIGN_MODE_DIRECT_AUX",p[p.SIGN_MODE_LEGACY_AMINO_JSON=127]="SIGN_MODE_LEGACY_AMINO_JSON",p[p.SIGN_MODE_EIP_191=191]="SIGN_MODE_EIP_191",p[p.UNRECOGNIZED=-1]="UNRECOGNIZED"})(a||(n.SignMode=a={}));function s(p){switch(p){case 0:case"SIGN_MODE_UNSPECIFIED":return a.SIGN_MODE_UNSPECIFIED;case 1:case"SIGN_MODE_DIRECT":return a.SIGN_MODE_DIRECT;case 2:case"SIGN_MODE_TEXTUAL":return a.SIGN_MODE_TEXTUAL;case 3:case"SIGN_MODE_DIRECT_AUX":return a.SIGN_MODE_DIRECT_AUX;case 127:case"SIGN_MODE_LEGACY_AMINO_JSON":return a.SIGN_MODE_LEGACY_AMINO_JSON;case 191:case"SIGN_MODE_EIP_191":return a.SIGN_MODE_EIP_191;case-1:case"UNRECOGNIZED":default:return a.UNRECOGNIZED}}n.signModeFromJSON=s;function u(p){switch(p){case a.SIGN_MODE_UNSPECIFIED:return"SIGN_MODE_UNSPECIFIED";case a.SIGN_MODE_DIRECT:return"SIGN_MODE_DIRECT";case a.SIGN_MODE_TEXTUAL:return"SIGN_MODE_TEXTUAL";case a.SIGN_MODE_DIRECT_AUX:return"SIGN_MODE_DIRECT_AUX";case a.SIGN_MODE_LEGACY_AMINO_JSON:return"SIGN_MODE_LEGACY_AMINO_JSON";case a.SIGN_MODE_EIP_191:return"SIGN_MODE_EIP_191";case a.UNRECOGNIZED:default:return"UNRECOGNIZED"}}n.signModeToJSON=u;function f(){return{signatures:[]}}n.SignatureDescriptors={typeUrl:"/cosmos.tx.signing.v1beta1.SignatureDescriptors",encode(p,g=c.BinaryWriter.create()){for(const h of p.signatures)n.SignatureDescriptor.encode(h,g.uint32(10).fork()).ldelim();return g},decode(p,g){const h=p instanceof c.BinaryReader?p:new c.BinaryReader(p);let m=g===void 0?h.len:h.pos+g;const w=f();for(;h.pos<m;){const B=h.uint32();switch(B>>>3){case 1:w.signatures.push(n.SignatureDescriptor.decode(h,h.uint32()));break;default:h.skipType(B&7);break}}return w},fromJSON(p){const g=f();return Array.isArray(p?.signatures)&&(g.signatures=p.signatures.map(h=>n.SignatureDescriptor.fromJSON(h))),g},toJSON(p){const g={};return p.signatures?g.signatures=p.signatures.map(h=>h?n.SignatureDescriptor.toJSON(h):void 0):g.signatures=[],g},fromPartial(p){const g=f();return g.signatures=p.signatures?.map(h=>n.SignatureDescriptor.fromPartial(h))||[],g}};function y(){return{publicKey:void 0,data:void 0,sequence:BigInt(0)}}n.SignatureDescriptor={typeUrl:"/cosmos.tx.signing.v1beta1.SignatureDescriptor",encode(p,g=c.BinaryWriter.create()){return p.publicKey!==void 0&&d.Any.encode(p.publicKey,g.uint32(10).fork()).ldelim(),p.data!==void 0&&n.SignatureDescriptor_Data.encode(p.data,g.uint32(18).fork()).ldelim(),p.sequence!==BigInt(0)&&g.uint32(24).uint64(p.sequence),g},decode(p,g){const h=p instanceof c.BinaryReader?p:new c.BinaryReader(p);let m=g===void 0?h.len:h.pos+g;const w=y();for(;h.pos<m;){const B=h.uint32();switch(B>>>3){case 1:w.publicKey=d.Any.decode(h,h.uint32());break;case 2:w.data=n.SignatureDescriptor_Data.decode(h,h.uint32());break;case 3:w.sequence=h.uint64();break;default:h.skipType(B&7);break}}return w},fromJSON(p){const g=y();return(0,o.isSet)(p.publicKey)&&(g.publicKey=d.Any.fromJSON(p.publicKey)),(0,o.isSet)(p.data)&&(g.data=n.SignatureDescriptor_Data.fromJSON(p.data)),(0,o.isSet)(p.sequence)&&(g.sequence=BigInt(p.sequence.toString())),g},toJSON(p){const g={};return p.publicKey!==void 0&&(g.publicKey=p.publicKey?d.Any.toJSON(p.publicKey):void 0),p.data!==void 0&&(g.data=p.data?n.SignatureDescriptor_Data.toJSON(p.data):void 0),p.sequence!==void 0&&(g.sequence=(p.sequence||BigInt(0)).toString()),g},fromPartial(p){const g=y();return p.publicKey!==void 0&&p.publicKey!==null&&(g.publicKey=d.Any.fromPartial(p.publicKey)),p.data!==void 0&&p.data!==null&&(g.data=n.SignatureDescriptor_Data.fromPartial(p.data)),p.sequence!==void 0&&p.sequence!==null&&(g.sequence=BigInt(p.sequence.toString())),g}};function b(){return{single:void 0,multi:void 0}}n.SignatureDescriptor_Data={typeUrl:"/cosmos.tx.signing.v1beta1.Data",encode(p,g=c.BinaryWriter.create()){return p.single!==void 0&&n.SignatureDescriptor_Data_Single.encode(p.single,g.uint32(10).fork()).ldelim(),p.multi!==void 0&&n.SignatureDescriptor_Data_Multi.encode(p.multi,g.uint32(18).fork()).ldelim(),g},decode(p,g){const h=p instanceof c.BinaryReader?p:new c.BinaryReader(p);let m=g===void 0?h.len:h.pos+g;const w=b();for(;h.pos<m;){const B=h.uint32();switch(B>>>3){case 1:w.single=n.SignatureDescriptor_Data_Single.decode(h,h.uint32());break;case 2:w.multi=n.SignatureDescriptor_Data_Multi.decode(h,h.uint32());break;default:h.skipType(B&7);break}}return w},fromJSON(p){const g=b();return(0,o.isSet)(p.single)&&(g.single=n.SignatureDescriptor_Data_Single.fromJSON(p.single)),(0,o.isSet)(p.multi)&&(g.multi=n.SignatureDescriptor_Data_Multi.fromJSON(p.multi)),g},toJSON(p){const g={};return p.single!==void 0&&(g.single=p.single?n.SignatureDescriptor_Data_Single.toJSON(p.single):void 0),p.multi!==void 0&&(g.multi=p.multi?n.SignatureDescriptor_Data_Multi.toJSON(p.multi):void 0),g},fromPartial(p){const g=b();return p.single!==void 0&&p.single!==null&&(g.single=n.SignatureDescriptor_Data_Single.fromPartial(p.single)),p.multi!==void 0&&p.multi!==null&&(g.multi=n.SignatureDescriptor_Data_Multi.fromPartial(p.multi)),g}};function l(){return{mode:0,signature:new Uint8Array}}n.SignatureDescriptor_Data_Single={typeUrl:"/cosmos.tx.signing.v1beta1.Single",encode(p,g=c.BinaryWriter.create()){return p.mode!==0&&g.uint32(8).int32(p.mode),p.signature.length!==0&&g.uint32(18).bytes(p.signature),g},decode(p,g){const h=p instanceof c.BinaryReader?p:new c.BinaryReader(p);let m=g===void 0?h.len:h.pos+g;const w=l();for(;h.pos<m;){const B=h.uint32();switch(B>>>3){case 1:w.mode=h.int32();break;case 2:w.signature=h.bytes();break;default:h.skipType(B&7);break}}return w},fromJSON(p){const g=l();return(0,o.isSet)(p.mode)&&(g.mode=s(p.mode)),(0,o.isSet)(p.signature)&&(g.signature=(0,o.bytesFromBase64)(p.signature)),g},toJSON(p){const g={};return p.mode!==void 0&&(g.mode=u(p.mode)),p.signature!==void 0&&(g.signature=(0,o.base64FromBytes)(p.signature!==void 0?p.signature:new Uint8Array)),g},fromPartial(p){const g=l();return g.mode=p.mode??0,g.signature=p.signature??new Uint8Array,g}};function I(){return{bitarray:void 0,signatures:[]}}n.SignatureDescriptor_Data_Multi={typeUrl:"/cosmos.tx.signing.v1beta1.Multi",encode(p,g=c.BinaryWriter.create()){p.bitarray!==void 0&&i.CompactBitArray.encode(p.bitarray,g.uint32(10).fork()).ldelim();for(const h of p.signatures)n.SignatureDescriptor_Data.encode(h,g.uint32(18).fork()).ldelim();return g},decode(p,g){const h=p instanceof c.BinaryReader?p:new c.BinaryReader(p);let m=g===void 0?h.len:h.pos+g;const w=I();for(;h.pos<m;){const B=h.uint32();switch(B>>>3){case 1:w.bitarray=i.CompactBitArray.decode(h,h.uint32());break;case 2:w.signatures.push(n.SignatureDescriptor_Data.decode(h,h.uint32()));break;default:h.skipType(B&7);break}}return w},fromJSON(p){const g=I();return(0,o.isSet)(p.bitarray)&&(g.bitarray=i.CompactBitArray.fromJSON(p.bitarray)),Array.isArray(p?.signatures)&&(g.signatures=p.signatures.map(h=>n.SignatureDescriptor_Data.fromJSON(h))),g},toJSON(p){const g={};return p.bitarray!==void 0&&(g.bitarray=p.bitarray?i.CompactBitArray.toJSON(p.bitarray):void 0),p.signatures?g.signatures=p.signatures.map(h=>h?n.SignatureDescriptor_Data.toJSON(h):void 0):g.signatures=[],g},fromPartial(p){const g=I();return p.bitarray!==void 0&&p.bitarray!==null&&(g.bitarray=i.CompactBitArray.fromPartial(p.bitarray)),g.signatures=p.signatures?.map(h=>n.SignatureDescriptor_Data.fromPartial(h))||[],g}}}(Ve)),Ve}var di=rn(),We={},G={},Kt;function fi(){if(Kt)return G;Kt=1,Object.defineProperty(G,"__esModule",{value:!0}),G.DecProto=G.IntProto=G.DecCoin=G.Coin=G.protobufPackage=void 0;const n=Ne(),i=Be();G.protobufPackage="cosmos.base.v1beta1";function d(){return{denom:"",amount:""}}G.Coin={typeUrl:"/cosmos.base.v1beta1.Coin",encode(s,u=n.BinaryWriter.create()){return s.denom!==""&&u.uint32(10).string(s.denom),s.amount!==""&&u.uint32(18).string(s.amount),u},decode(s,u){const f=s instanceof n.BinaryReader?s:new n.BinaryReader(s);let y=u===void 0?f.len:f.pos+u;const b=d();for(;f.pos<y;){const l=f.uint32();switch(l>>>3){case 1:b.denom=f.string();break;case 2:b.amount=f.string();break;default:f.skipType(l&7);break}}return b},fromJSON(s){const u=d();return(0,i.isSet)(s.denom)&&(u.denom=String(s.denom)),(0,i.isSet)(s.amount)&&(u.amount=String(s.amount)),u},toJSON(s){const u={};return s.denom!==void 0&&(u.denom=s.denom),s.amount!==void 0&&(u.amount=s.amount),u},fromPartial(s){const u=d();return u.denom=s.denom??"",u.amount=s.amount??"",u}};function c(){return{denom:"",amount:""}}G.DecCoin={typeUrl:"/cosmos.base.v1beta1.DecCoin",encode(s,u=n.BinaryWriter.create()){return s.denom!==""&&u.uint32(10).string(s.denom),s.amount!==""&&u.uint32(18).string(s.amount),u},decode(s,u){const f=s instanceof n.BinaryReader?s:new n.BinaryReader(s);let y=u===void 0?f.len:f.pos+u;const b=c();for(;f.pos<y;){const l=f.uint32();switch(l>>>3){case 1:b.denom=f.string();break;case 2:b.amount=f.string();break;default:f.skipType(l&7);break}}return b},fromJSON(s){const u=c();return(0,i.isSet)(s.denom)&&(u.denom=String(s.denom)),(0,i.isSet)(s.amount)&&(u.amount=String(s.amount)),u},toJSON(s){const u={};return s.denom!==void 0&&(u.denom=s.denom),s.amount!==void 0&&(u.amount=s.amount),u},fromPartial(s){const u=c();return u.denom=s.denom??"",u.amount=s.amount??"",u}};function o(){return{int:""}}G.IntProto={typeUrl:"/cosmos.base.v1beta1.IntProto",encode(s,u=n.BinaryWriter.create()){return s.int!==""&&u.uint32(10).string(s.int),u},decode(s,u){const f=s instanceof n.BinaryReader?s:new n.BinaryReader(s);let y=u===void 0?f.len:f.pos+u;const b=o();for(;f.pos<y;){const l=f.uint32();switch(l>>>3){case 1:b.int=f.string();break;default:f.skipType(l&7);break}}return b},fromJSON(s){const u=o();return(0,i.isSet)(s.int)&&(u.int=String(s.int)),u},toJSON(s){const u={};return s.int!==void 0&&(u.int=s.int),u},fromPartial(s){const u=o();return u.int=s.int??"",u}};function a(){return{dec:""}}return G.DecProto={typeUrl:"/cosmos.base.v1beta1.DecProto",encode(s,u=n.BinaryWriter.create()){return s.dec!==""&&u.uint32(10).string(s.dec),u},decode(s,u){const f=s instanceof n.BinaryReader?s:new n.BinaryReader(s);let y=u===void 0?f.len:f.pos+u;const b=a();for(;f.pos<y;){const l=f.uint32();switch(l>>>3){case 1:b.dec=f.string();break;default:f.skipType(l&7);break}}return b},fromJSON(s){const u=a();return(0,i.isSet)(s.dec)&&(u.dec=String(s.dec)),u},toJSON(s){const u={};return s.dec!==void 0&&(u.dec=s.dec),u},fromPartial(s){const u=a();return u.dec=s.dec??"",u}},G}var qt;function li(){return qt||(qt=1,function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.AuxSignerData=n.Tip=n.Fee=n.ModeInfo_Multi=n.ModeInfo_Single=n.ModeInfo=n.SignerInfo=n.AuthInfo=n.TxBody=n.SignDocDirectAux=n.SignDoc=n.TxRaw=n.Tx=n.protobufPackage=void 0;const i=nn(),d=rn(),c=tn(),o=fi(),a=Ne(),s=Be();n.protobufPackage="cosmos.tx.v1beta1";function u(){return{body:void 0,authInfo:void 0,signatures:[]}}n.Tx={typeUrl:"/cosmos.tx.v1beta1.Tx",encode(t,e=a.BinaryWriter.create()){t.body!==void 0&&n.TxBody.encode(t.body,e.uint32(10).fork()).ldelim(),t.authInfo!==void 0&&n.AuthInfo.encode(t.authInfo,e.uint32(18).fork()).ldelim();for(const r of t.signatures)e.uint32(26).bytes(r);return e},decode(t,e){const r=t instanceof a.BinaryReader?t:new a.BinaryReader(t);let v=e===void 0?r.len:r.pos+e;const _=u();for(;r.pos<v;){const S=r.uint32();switch(S>>>3){case 1:_.body=n.TxBody.decode(r,r.uint32());break;case 2:_.authInfo=n.AuthInfo.decode(r,r.uint32());break;case 3:_.signatures.push(r.bytes());break;default:r.skipType(S&7);break}}return _},fromJSON(t){const e=u();return(0,s.isSet)(t.body)&&(e.body=n.TxBody.fromJSON(t.body)),(0,s.isSet)(t.authInfo)&&(e.authInfo=n.AuthInfo.fromJSON(t.authInfo)),Array.isArray(t?.signatures)&&(e.signatures=t.signatures.map(r=>(0,s.bytesFromBase64)(r))),e},toJSON(t){const e={};return t.body!==void 0&&(e.body=t.body?n.TxBody.toJSON(t.body):void 0),t.authInfo!==void 0&&(e.authInfo=t.authInfo?n.AuthInfo.toJSON(t.authInfo):void 0),t.signatures?e.signatures=t.signatures.map(r=>(0,s.base64FromBytes)(r!==void 0?r:new Uint8Array)):e.signatures=[],e},fromPartial(t){const e=u();return t.body!==void 0&&t.body!==null&&(e.body=n.TxBody.fromPartial(t.body)),t.authInfo!==void 0&&t.authInfo!==null&&(e.authInfo=n.AuthInfo.fromPartial(t.authInfo)),e.signatures=t.signatures?.map(r=>r)||[],e}};function f(){return{bodyBytes:new Uint8Array,authInfoBytes:new Uint8Array,signatures:[]}}n.TxRaw={typeUrl:"/cosmos.tx.v1beta1.TxRaw",encode(t,e=a.BinaryWriter.create()){t.bodyBytes.length!==0&&e.uint32(10).bytes(t.bodyBytes),t.authInfoBytes.length!==0&&e.uint32(18).bytes(t.authInfoBytes);for(const r of t.signatures)e.uint32(26).bytes(r);return e},decode(t,e){const r=t instanceof a.BinaryReader?t:new a.BinaryReader(t);let v=e===void 0?r.len:r.pos+e;const _=f();for(;r.pos<v;){const S=r.uint32();switch(S>>>3){case 1:_.bodyBytes=r.bytes();break;case 2:_.authInfoBytes=r.bytes();break;case 3:_.signatures.push(r.bytes());break;default:r.skipType(S&7);break}}return _},fromJSON(t){const e=f();return(0,s.isSet)(t.bodyBytes)&&(e.bodyBytes=(0,s.bytesFromBase64)(t.bodyBytes)),(0,s.isSet)(t.authInfoBytes)&&(e.authInfoBytes=(0,s.bytesFromBase64)(t.authInfoBytes)),Array.isArray(t?.signatures)&&(e.signatures=t.signatures.map(r=>(0,s.bytesFromBase64)(r))),e},toJSON(t){const e={};return t.bodyBytes!==void 0&&(e.bodyBytes=(0,s.base64FromBytes)(t.bodyBytes!==void 0?t.bodyBytes:new Uint8Array)),t.authInfoBytes!==void 0&&(e.authInfoBytes=(0,s.base64FromBytes)(t.authInfoBytes!==void 0?t.authInfoBytes:new Uint8Array)),t.signatures?e.signatures=t.signatures.map(r=>(0,s.base64FromBytes)(r!==void 0?r:new Uint8Array)):e.signatures=[],e},fromPartial(t){const e=f();return e.bodyBytes=t.bodyBytes??new Uint8Array,e.authInfoBytes=t.authInfoBytes??new Uint8Array,e.signatures=t.signatures?.map(r=>r)||[],e}};function y(){return{bodyBytes:new Uint8Array,authInfoBytes:new Uint8Array,chainId:"",accountNumber:BigInt(0)}}n.SignDoc={typeUrl:"/cosmos.tx.v1beta1.SignDoc",encode(t,e=a.BinaryWriter.create()){return t.bodyBytes.length!==0&&e.uint32(10).bytes(t.bodyBytes),t.authInfoBytes.length!==0&&e.uint32(18).bytes(t.authInfoBytes),t.chainId!==""&&e.uint32(26).string(t.chainId),t.accountNumber!==BigInt(0)&&e.uint32(32).uint64(t.accountNumber),e},decode(t,e){const r=t instanceof a.BinaryReader?t:new a.BinaryReader(t);let v=e===void 0?r.len:r.pos+e;const _=y();for(;r.pos<v;){const S=r.uint32();switch(S>>>3){case 1:_.bodyBytes=r.bytes();break;case 2:_.authInfoBytes=r.bytes();break;case 3:_.chainId=r.string();break;case 4:_.accountNumber=r.uint64();break;default:r.skipType(S&7);break}}return _},fromJSON(t){const e=y();return(0,s.isSet)(t.bodyBytes)&&(e.bodyBytes=(0,s.bytesFromBase64)(t.bodyBytes)),(0,s.isSet)(t.authInfoBytes)&&(e.authInfoBytes=(0,s.bytesFromBase64)(t.authInfoBytes)),(0,s.isSet)(t.chainId)&&(e.chainId=String(t.chainId)),(0,s.isSet)(t.accountNumber)&&(e.accountNumber=BigInt(t.accountNumber.toString())),e},toJSON(t){const e={};return t.bodyBytes!==void 0&&(e.bodyBytes=(0,s.base64FromBytes)(t.bodyBytes!==void 0?t.bodyBytes:new Uint8Array)),t.authInfoBytes!==void 0&&(e.authInfoBytes=(0,s.base64FromBytes)(t.authInfoBytes!==void 0?t.authInfoBytes:new Uint8Array)),t.chainId!==void 0&&(e.chainId=t.chainId),t.accountNumber!==void 0&&(e.accountNumber=(t.accountNumber||BigInt(0)).toString()),e},fromPartial(t){const e=y();return e.bodyBytes=t.bodyBytes??new Uint8Array,e.authInfoBytes=t.authInfoBytes??new Uint8Array,e.chainId=t.chainId??"",t.accountNumber!==void 0&&t.accountNumber!==null&&(e.accountNumber=BigInt(t.accountNumber.toString())),e}};function b(){return{bodyBytes:new Uint8Array,publicKey:void 0,chainId:"",accountNumber:BigInt(0),sequence:BigInt(0),tip:void 0}}n.SignDocDirectAux={typeUrl:"/cosmos.tx.v1beta1.SignDocDirectAux",encode(t,e=a.BinaryWriter.create()){return t.bodyBytes.length!==0&&e.uint32(10).bytes(t.bodyBytes),t.publicKey!==void 0&&i.Any.encode(t.publicKey,e.uint32(18).fork()).ldelim(),t.chainId!==""&&e.uint32(26).string(t.chainId),t.accountNumber!==BigInt(0)&&e.uint32(32).uint64(t.accountNumber),t.sequence!==BigInt(0)&&e.uint32(40).uint64(t.sequence),t.tip!==void 0&&n.Tip.encode(t.tip,e.uint32(50).fork()).ldelim(),e},decode(t,e){const r=t instanceof a.BinaryReader?t:new a.BinaryReader(t);let v=e===void 0?r.len:r.pos+e;const _=b();for(;r.pos<v;){const S=r.uint32();switch(S>>>3){case 1:_.bodyBytes=r.bytes();break;case 2:_.publicKey=i.Any.decode(r,r.uint32());break;case 3:_.chainId=r.string();break;case 4:_.accountNumber=r.uint64();break;case 5:_.sequence=r.uint64();break;case 6:_.tip=n.Tip.decode(r,r.uint32());break;default:r.skipType(S&7);break}}return _},fromJSON(t){const e=b();return(0,s.isSet)(t.bodyBytes)&&(e.bodyBytes=(0,s.bytesFromBase64)(t.bodyBytes)),(0,s.isSet)(t.publicKey)&&(e.publicKey=i.Any.fromJSON(t.publicKey)),(0,s.isSet)(t.chainId)&&(e.chainId=String(t.chainId)),(0,s.isSet)(t.accountNumber)&&(e.accountNumber=BigInt(t.accountNumber.toString())),(0,s.isSet)(t.sequence)&&(e.sequence=BigInt(t.sequence.toString())),(0,s.isSet)(t.tip)&&(e.tip=n.Tip.fromJSON(t.tip)),e},toJSON(t){const e={};return t.bodyBytes!==void 0&&(e.bodyBytes=(0,s.base64FromBytes)(t.bodyBytes!==void 0?t.bodyBytes:new Uint8Array)),t.publicKey!==void 0&&(e.publicKey=t.publicKey?i.Any.toJSON(t.publicKey):void 0),t.chainId!==void 0&&(e.chainId=t.chainId),t.accountNumber!==void 0&&(e.accountNumber=(t.accountNumber||BigInt(0)).toString()),t.sequence!==void 0&&(e.sequence=(t.sequence||BigInt(0)).toString()),t.tip!==void 0&&(e.tip=t.tip?n.Tip.toJSON(t.tip):void 0),e},fromPartial(t){const e=b();return e.bodyBytes=t.bodyBytes??new Uint8Array,t.publicKey!==void 0&&t.publicKey!==null&&(e.publicKey=i.Any.fromPartial(t.publicKey)),e.chainId=t.chainId??"",t.accountNumber!==void 0&&t.accountNumber!==null&&(e.accountNumber=BigInt(t.accountNumber.toString())),t.sequence!==void 0&&t.sequence!==null&&(e.sequence=BigInt(t.sequence.toString())),t.tip!==void 0&&t.tip!==null&&(e.tip=n.Tip.fromPartial(t.tip)),e}};function l(){return{messages:[],memo:"",timeoutHeight:BigInt(0),extensionOptions:[],nonCriticalExtensionOptions:[]}}n.TxBody={typeUrl:"/cosmos.tx.v1beta1.TxBody",encode(t,e=a.BinaryWriter.create()){for(const r of t.messages)i.Any.encode(r,e.uint32(10).fork()).ldelim();t.memo!==""&&e.uint32(18).string(t.memo),t.timeoutHeight!==BigInt(0)&&e.uint32(24).uint64(t.timeoutHeight);for(const r of t.extensionOptions)i.Any.encode(r,e.uint32(8186).fork()).ldelim();for(const r of t.nonCriticalExtensionOptions)i.Any.encode(r,e.uint32(16378).fork()).ldelim();return e},decode(t,e){const r=t instanceof a.BinaryReader?t:new a.BinaryReader(t);let v=e===void 0?r.len:r.pos+e;const _=l();for(;r.pos<v;){const S=r.uint32();switch(S>>>3){case 1:_.messages.push(i.Any.decode(r,r.uint32()));break;case 2:_.memo=r.string();break;case 3:_.timeoutHeight=r.uint64();break;case 1023:_.extensionOptions.push(i.Any.decode(r,r.uint32()));break;case 2047:_.nonCriticalExtensionOptions.push(i.Any.decode(r,r.uint32()));break;default:r.skipType(S&7);break}}return _},fromJSON(t){const e=l();return Array.isArray(t?.messages)&&(e.messages=t.messages.map(r=>i.Any.fromJSON(r))),(0,s.isSet)(t.memo)&&(e.memo=String(t.memo)),(0,s.isSet)(t.timeoutHeight)&&(e.timeoutHeight=BigInt(t.timeoutHeight.toString())),Array.isArray(t?.extensionOptions)&&(e.extensionOptions=t.extensionOptions.map(r=>i.Any.fromJSON(r))),Array.isArray(t?.nonCriticalExtensionOptions)&&(e.nonCriticalExtensionOptions=t.nonCriticalExtensionOptions.map(r=>i.Any.fromJSON(r))),e},toJSON(t){const e={};return t.messages?e.messages=t.messages.map(r=>r?i.Any.toJSON(r):void 0):e.messages=[],t.memo!==void 0&&(e.memo=t.memo),t.timeoutHeight!==void 0&&(e.timeoutHeight=(t.timeoutHeight||BigInt(0)).toString()),t.extensionOptions?e.extensionOptions=t.extensionOptions.map(r=>r?i.Any.toJSON(r):void 0):e.extensionOptions=[],t.nonCriticalExtensionOptions?e.nonCriticalExtensionOptions=t.nonCriticalExtensionOptions.map(r=>r?i.Any.toJSON(r):void 0):e.nonCriticalExtensionOptions=[],e},fromPartial(t){const e=l();return e.messages=t.messages?.map(r=>i.Any.fromPartial(r))||[],e.memo=t.memo??"",t.timeoutHeight!==void 0&&t.timeoutHeight!==null&&(e.timeoutHeight=BigInt(t.timeoutHeight.toString())),e.extensionOptions=t.extensionOptions?.map(r=>i.Any.fromPartial(r))||[],e.nonCriticalExtensionOptions=t.nonCriticalExtensionOptions?.map(r=>i.Any.fromPartial(r))||[],e}};function I(){return{signerInfos:[],fee:void 0,tip:void 0}}n.AuthInfo={typeUrl:"/cosmos.tx.v1beta1.AuthInfo",encode(t,e=a.BinaryWriter.create()){for(const r of t.signerInfos)n.SignerInfo.encode(r,e.uint32(10).fork()).ldelim();return t.fee!==void 0&&n.Fee.encode(t.fee,e.uint32(18).fork()).ldelim(),t.tip!==void 0&&n.Tip.encode(t.tip,e.uint32(26).fork()).ldelim(),e},decode(t,e){const r=t instanceof a.BinaryReader?t:new a.BinaryReader(t);let v=e===void 0?r.len:r.pos+e;const _=I();for(;r.pos<v;){const S=r.uint32();switch(S>>>3){case 1:_.signerInfos.push(n.SignerInfo.decode(r,r.uint32()));break;case 2:_.fee=n.Fee.decode(r,r.uint32());break;case 3:_.tip=n.Tip.decode(r,r.uint32());break;default:r.skipType(S&7);break}}return _},fromJSON(t){const e=I();return Array.isArray(t?.signerInfos)&&(e.signerInfos=t.signerInfos.map(r=>n.SignerInfo.fromJSON(r))),(0,s.isSet)(t.fee)&&(e.fee=n.Fee.fromJSON(t.fee)),(0,s.isSet)(t.tip)&&(e.tip=n.Tip.fromJSON(t.tip)),e},toJSON(t){const e={};return t.signerInfos?e.signerInfos=t.signerInfos.map(r=>r?n.SignerInfo.toJSON(r):void 0):e.signerInfos=[],t.fee!==void 0&&(e.fee=t.fee?n.Fee.toJSON(t.fee):void 0),t.tip!==void 0&&(e.tip=t.tip?n.Tip.toJSON(t.tip):void 0),e},fromPartial(t){const e=I();return e.signerInfos=t.signerInfos?.map(r=>n.SignerInfo.fromPartial(r))||[],t.fee!==void 0&&t.fee!==null&&(e.fee=n.Fee.fromPartial(t.fee)),t.tip!==void 0&&t.tip!==null&&(e.tip=n.Tip.fromPartial(t.tip)),e}};function p(){return{publicKey:void 0,modeInfo:void 0,sequence:BigInt(0)}}n.SignerInfo={typeUrl:"/cosmos.tx.v1beta1.SignerInfo",encode(t,e=a.BinaryWriter.create()){return t.publicKey!==void 0&&i.Any.encode(t.publicKey,e.uint32(10).fork()).ldelim(),t.modeInfo!==void 0&&n.ModeInfo.encode(t.modeInfo,e.uint32(18).fork()).ldelim(),t.sequence!==BigInt(0)&&e.uint32(24).uint64(t.sequence),e},decode(t,e){const r=t instanceof a.BinaryReader?t:new a.BinaryReader(t);let v=e===void 0?r.len:r.pos+e;const _=p();for(;r.pos<v;){const S=r.uint32();switch(S>>>3){case 1:_.publicKey=i.Any.decode(r,r.uint32());break;case 2:_.modeInfo=n.ModeInfo.decode(r,r.uint32());break;case 3:_.sequence=r.uint64();break;default:r.skipType(S&7);break}}return _},fromJSON(t){const e=p();return(0,s.isSet)(t.publicKey)&&(e.publicKey=i.Any.fromJSON(t.publicKey)),(0,s.isSet)(t.modeInfo)&&(e.modeInfo=n.ModeInfo.fromJSON(t.modeInfo)),(0,s.isSet)(t.sequence)&&(e.sequence=BigInt(t.sequence.toString())),e},toJSON(t){const e={};return t.publicKey!==void 0&&(e.publicKey=t.publicKey?i.Any.toJSON(t.publicKey):void 0),t.modeInfo!==void 0&&(e.modeInfo=t.modeInfo?n.ModeInfo.toJSON(t.modeInfo):void 0),t.sequence!==void 0&&(e.sequence=(t.sequence||BigInt(0)).toString()),e},fromPartial(t){const e=p();return t.publicKey!==void 0&&t.publicKey!==null&&(e.publicKey=i.Any.fromPartial(t.publicKey)),t.modeInfo!==void 0&&t.modeInfo!==null&&(e.modeInfo=n.ModeInfo.fromPartial(t.modeInfo)),t.sequence!==void 0&&t.sequence!==null&&(e.sequence=BigInt(t.sequence.toString())),e}};function g(){return{single:void 0,multi:void 0}}n.ModeInfo={typeUrl:"/cosmos.tx.v1beta1.ModeInfo",encode(t,e=a.BinaryWriter.create()){return t.single!==void 0&&n.ModeInfo_Single.encode(t.single,e.uint32(10).fork()).ldelim(),t.multi!==void 0&&n.ModeInfo_Multi.encode(t.multi,e.uint32(18).fork()).ldelim(),e},decode(t,e){const r=t instanceof a.BinaryReader?t:new a.BinaryReader(t);let v=e===void 0?r.len:r.pos+e;const _=g();for(;r.pos<v;){const S=r.uint32();switch(S>>>3){case 1:_.single=n.ModeInfo_Single.decode(r,r.uint32());break;case 2:_.multi=n.ModeInfo_Multi.decode(r,r.uint32());break;default:r.skipType(S&7);break}}return _},fromJSON(t){const e=g();return(0,s.isSet)(t.single)&&(e.single=n.ModeInfo_Single.fromJSON(t.single)),(0,s.isSet)(t.multi)&&(e.multi=n.ModeInfo_Multi.fromJSON(t.multi)),e},toJSON(t){const e={};return t.single!==void 0&&(e.single=t.single?n.ModeInfo_Single.toJSON(t.single):void 0),t.multi!==void 0&&(e.multi=t.multi?n.ModeInfo_Multi.toJSON(t.multi):void 0),e},fromPartial(t){const e=g();return t.single!==void 0&&t.single!==null&&(e.single=n.ModeInfo_Single.fromPartial(t.single)),t.multi!==void 0&&t.multi!==null&&(e.multi=n.ModeInfo_Multi.fromPartial(t.multi)),e}};function h(){return{mode:0}}n.ModeInfo_Single={typeUrl:"/cosmos.tx.v1beta1.Single",encode(t,e=a.BinaryWriter.create()){return t.mode!==0&&e.uint32(8).int32(t.mode),e},decode(t,e){const r=t instanceof a.BinaryReader?t:new a.BinaryReader(t);let v=e===void 0?r.len:r.pos+e;const _=h();for(;r.pos<v;){const S=r.uint32();switch(S>>>3){case 1:_.mode=r.int32();break;default:r.skipType(S&7);break}}return _},fromJSON(t){const e=h();return(0,s.isSet)(t.mode)&&(e.mode=(0,d.signModeFromJSON)(t.mode)),e},toJSON(t){const e={};return t.mode!==void 0&&(e.mode=(0,d.signModeToJSON)(t.mode)),e},fromPartial(t){const e=h();return e.mode=t.mode??0,e}};function m(){return{bitarray:void 0,modeInfos:[]}}n.ModeInfo_Multi={typeUrl:"/cosmos.tx.v1beta1.Multi",encode(t,e=a.BinaryWriter.create()){t.bitarray!==void 0&&c.CompactBitArray.encode(t.bitarray,e.uint32(10).fork()).ldelim();for(const r of t.modeInfos)n.ModeInfo.encode(r,e.uint32(18).fork()).ldelim();return e},decode(t,e){const r=t instanceof a.BinaryReader?t:new a.BinaryReader(t);let v=e===void 0?r.len:r.pos+e;const _=m();for(;r.pos<v;){const S=r.uint32();switch(S>>>3){case 1:_.bitarray=c.CompactBitArray.decode(r,r.uint32());break;case 2:_.modeInfos.push(n.ModeInfo.decode(r,r.uint32()));break;default:r.skipType(S&7);break}}return _},fromJSON(t){const e=m();return(0,s.isSet)(t.bitarray)&&(e.bitarray=c.CompactBitArray.fromJSON(t.bitarray)),Array.isArray(t?.modeInfos)&&(e.modeInfos=t.modeInfos.map(r=>n.ModeInfo.fromJSON(r))),e},toJSON(t){const e={};return t.bitarray!==void 0&&(e.bitarray=t.bitarray?c.CompactBitArray.toJSON(t.bitarray):void 0),t.modeInfos?e.modeInfos=t.modeInfos.map(r=>r?n.ModeInfo.toJSON(r):void 0):e.modeInfos=[],e},fromPartial(t){const e=m();return t.bitarray!==void 0&&t.bitarray!==null&&(e.bitarray=c.CompactBitArray.fromPartial(t.bitarray)),e.modeInfos=t.modeInfos?.map(r=>n.ModeInfo.fromPartial(r))||[],e}};function w(){return{amount:[],gasLimit:BigInt(0),payer:"",granter:""}}n.Fee={typeUrl:"/cosmos.tx.v1beta1.Fee",encode(t,e=a.BinaryWriter.create()){for(const r of t.amount)o.Coin.encode(r,e.uint32(10).fork()).ldelim();return t.gasLimit!==BigInt(0)&&e.uint32(16).uint64(t.gasLimit),t.payer!==""&&e.uint32(26).string(t.payer),t.granter!==""&&e.uint32(34).string(t.granter),e},decode(t,e){const r=t instanceof a.BinaryReader?t:new a.BinaryReader(t);let v=e===void 0?r.len:r.pos+e;const _=w();for(;r.pos<v;){const S=r.uint32();switch(S>>>3){case 1:_.amount.push(o.Coin.decode(r,r.uint32()));break;case 2:_.gasLimit=r.uint64();break;case 3:_.payer=r.string();break;case 4:_.granter=r.string();break;default:r.skipType(S&7);break}}return _},fromJSON(t){const e=w();return Array.isArray(t?.amount)&&(e.amount=t.amount.map(r=>o.Coin.fromJSON(r))),(0,s.isSet)(t.gasLimit)&&(e.gasLimit=BigInt(t.gasLimit.toString())),(0,s.isSet)(t.payer)&&(e.payer=String(t.payer)),(0,s.isSet)(t.granter)&&(e.granter=String(t.granter)),e},toJSON(t){const e={};return t.amount?e.amount=t.amount.map(r=>r?o.Coin.toJSON(r):void 0):e.amount=[],t.gasLimit!==void 0&&(e.gasLimit=(t.gasLimit||BigInt(0)).toString()),t.payer!==void 0&&(e.payer=t.payer),t.granter!==void 0&&(e.granter=t.granter),e},fromPartial(t){const e=w();return e.amount=t.amount?.map(r=>o.Coin.fromPartial(r))||[],t.gasLimit!==void 0&&t.gasLimit!==null&&(e.gasLimit=BigInt(t.gasLimit.toString())),e.payer=t.payer??"",e.granter=t.granter??"",e}};function B(){return{amount:[],tipper:""}}n.Tip={typeUrl:"/cosmos.tx.v1beta1.Tip",encode(t,e=a.BinaryWriter.create()){for(const r of t.amount)o.Coin.encode(r,e.uint32(10).fork()).ldelim();return t.tipper!==""&&e.uint32(18).string(t.tipper),e},decode(t,e){const r=t instanceof a.BinaryReader?t:new a.BinaryReader(t);let v=e===void 0?r.len:r.pos+e;const _=B();for(;r.pos<v;){const S=r.uint32();switch(S>>>3){case 1:_.amount.push(o.Coin.decode(r,r.uint32()));break;case 2:_.tipper=r.string();break;default:r.skipType(S&7);break}}return _},fromJSON(t){const e=B();return Array.isArray(t?.amount)&&(e.amount=t.amount.map(r=>o.Coin.fromJSON(r))),(0,s.isSet)(t.tipper)&&(e.tipper=String(t.tipper)),e},toJSON(t){const e={};return t.amount?e.amount=t.amount.map(r=>r?o.Coin.toJSON(r):void 0):e.amount=[],t.tipper!==void 0&&(e.tipper=t.tipper),e},fromPartial(t){const e=B();return e.amount=t.amount?.map(r=>o.Coin.fromPartial(r))||[],e.tipper=t.tipper??"",e}};function R(){return{address:"",signDoc:void 0,mode:0,sig:new Uint8Array}}n.AuxSignerData={typeUrl:"/cosmos.tx.v1beta1.AuxSignerData",encode(t,e=a.BinaryWriter.create()){return t.address!==""&&e.uint32(10).string(t.address),t.signDoc!==void 0&&n.SignDocDirectAux.encode(t.signDoc,e.uint32(18).fork()).ldelim(),t.mode!==0&&e.uint32(24).int32(t.mode),t.sig.length!==0&&e.uint32(34).bytes(t.sig),e},decode(t,e){const r=t instanceof a.BinaryReader?t:new a.BinaryReader(t);let v=e===void 0?r.len:r.pos+e;const _=R();for(;r.pos<v;){const S=r.uint32();switch(S>>>3){case 1:_.address=r.string();break;case 2:_.signDoc=n.SignDocDirectAux.decode(r,r.uint32());break;case 3:_.mode=r.int32();break;case 4:_.sig=r.bytes();break;default:r.skipType(S&7);break}}return _},fromJSON(t){const e=R();return(0,s.isSet)(t.address)&&(e.address=String(t.address)),(0,s.isSet)(t.signDoc)&&(e.signDoc=n.SignDocDirectAux.fromJSON(t.signDoc)),(0,s.isSet)(t.mode)&&(e.mode=(0,d.signModeFromJSON)(t.mode)),(0,s.isSet)(t.sig)&&(e.sig=(0,s.bytesFromBase64)(t.sig)),e},toJSON(t){const e={};return t.address!==void 0&&(e.address=t.address),t.signDoc!==void 0&&(e.signDoc=t.signDoc?n.SignDocDirectAux.toJSON(t.signDoc):void 0),t.mode!==void 0&&(e.mode=(0,d.signModeToJSON)(t.mode)),t.sig!==void 0&&(e.sig=(0,s.base64FromBytes)(t.sig!==void 0?t.sig:new Uint8Array)),e},fromPartial(t){const e=R();return e.address=t.address??"",t.signDoc!==void 0&&t.signDoc!==null&&(e.signDoc=n.SignDocDirectAux.fromPartial(t.signDoc)),e.mode=t.mode??0,e.sig=t.sig??new Uint8Array,e}}}(We)),We}var ke=li();const pi=async n=>{const i=rt.chains.find(l=>l.chain_id===n);if(!i)throw new Error(`Chain info not found for chainId: ${n}`);const{bech32_prefix:d,chain_id:c}=i,o=i.staking?.staking_tokens?.[0]?.denom,a=i.apis?.rpc?.[0]?.address,s=i.apis?.rest?.[0]?.address,u=i.fees?.fee_tokens?.[0]?.average_gas_price;if(!d||!o||!a||!s||!c||u===void 0)throw new Error(`Missing required chain information for ${i.chain_name}`);const y=rt.assets.find(l=>l.chain_name===i.chain_name)?.assets.find(l=>l.base===o),b=y?.denom_units.find(l=>l.denom===y.display)?.exponent;if(b===void 0)throw new Error(`Could not find decimals for ${o} on chain ${i.chain_name}`);return{prefix:d,denom:o,rpcUrl:a,restUrl:s,expectedChainId:c,gasPrice:u,decimals:b}};class on extends Re{constructor({chainId:i,contract:d,endpoints:c}){super(),this.contract=d,this.registry=new ge.Registry,this.chainId=i,this.endpoints=c}parseRSVSignature(i){return new Uint8Array([...re.fromHex(i.r),...re.fromHex(i.s)])}async getChainInfo(){return{...await pi(this.chainId),...this.endpoints}}async getBalance(i){try{const{restUrl:d,denom:c,decimals:o}=await this.getChainInfo(),a=await fetch(`${d}/cosmos/bank/v1beta1/balances/${i}`);if(!a.ok)throw new Error(`HTTP error! status: ${a.status}`);const f=(await a.json()).balances.find(b=>b.denom===c)?.amount??"0";return(parseInt(f)/Math.pow(10,o)).toString()}catch(d){throw console.error("Failed to fetch Cosmos balance:",d),new Error("Failed to fetch Cosmos balance")}}async deriveAddressAndPublicKey(i,d){const{prefix:c}=await this.getChainInfo(),o=await this.contract.getDerivedPublicKey({path:d,predecessor:i});if(!o)throw new Error("Failed to get derived public key");const a=Qe(o),s=Ue.sha256(re.fromHex(a)),u=Ue.ripemd160(s);return{address:nt.bech32.encode(c,nt.bech32.toWords(u)),publicKey:a}}setTransaction(i,d){const c=ke.TxRaw.encode(i).finish();window.localStorage.setItem(d,re.toBase64(c))}getTransaction(i,d){const c=window.localStorage.getItem(i);if(c)return d?.remove&&window.localStorage.removeItem(i),ke.TxRaw.decode(re.fromBase64(c))}async getMPCPayloadAndTransaction(i){const{denom:d,rpcUrl:c,gasPrice:o}=await this.getChainInfo(),a=re.fromHex(i.publicKey),s=i.gas||2e5,u=Te.calculateFee(s,Te.GasPrice.fromString(`${o}${d}`)),y=await(await Te.StargateClient.connect(c)).getAccount(i.address);if(!y)throw new Error(`Account ${i.address} does not exist on chain`);const{accountNumber:b,sequence:l}=y,I={typeUrl:"/cosmos.tx.v1beta1.TxBody",value:{messages:i.messages,memo:i.memo||""}},p=this.registry.encode(I),g=ge.encodePubkey(yn.encodeSecp256k1Pubkey(a)),h=ge.makeAuthInfoBytes([{pubkey:g,sequence:l}],u.amount,Number(u.gas),void 0,void 0,di.SignMode.SIGN_MODE_DIRECT),m=ge.makeSignDoc(p,h,this.chainId,b),w=ge.makeSignBytes(m),B=Array.from(Ue.sha256(w));return{transaction:ke.TxRaw.fromPartial({bodyBytes:p,authInfoBytes:h,signatures:[]}),mpcPayloads:[B]}}addSignature({transaction:i,mpcSignatures:d}){i.signatures=d.map(o=>this.parseRSVSignature(o));const c=ke.TxRaw.encode(i).finish();return Buffer.from(c).toString("hex")}async broadcastTx(i){try{const{rpcUrl:d}=await this.getChainInfo(),c=await Te.StargateClient.connect(d),o=re.fromHex(i),a=await c.broadcastTx(o);if(a.code!==0)throw new Error(`Broadcast error: ${a.rawLog}`);return a.transactionHash}catch(d){throw console.error("Transaction broadcast failed:",d),new Error("Failed to broadcast transaction.")}}}const yi=async(n,i)=>{try{const d=await Me({networkId:n.nearAuthentication.networkId,accountId:n.nearAuthentication.accountId,keypair:i}),c=new pe({networkId:n.nearAuthentication.networkId,contractId:n.chainConfig.contract,accountId:d.accountId,keypair:i}),o=new Yt({rpcUrl:n.chainConfig.providerUrl,contract:c}),{transaction:a,mpcPayloads:s}=await o.getMPCPayloadAndTransaction(n.transaction),u=await c.sign({payload:s[0],path:n.derivationPath,key_version:0}),f=o.addSignature({transaction:a,mpcSignatures:[u]});return{transactionHash:await o.broadcastTx(f),success:!0}}catch(d){return console.error(d),{success:!1,errorMessage:d instanceof Error?d.message:String(d)}}},hi=async(n,i)=>{try{const d=await Me({networkId:n.nearAuthentication.networkId,accountId:n.nearAuthentication.accountId,keypair:i}),c=new pe({networkId:n.nearAuthentication.networkId,contractId:n.chainConfig.contract,accountId:d.accountId,keypair:i}),o=new de({btcRpcAdapter:new en.Mempool(n.chainConfig.providerUrl),contract:c,network:n.chainConfig.network}),{transaction:a,mpcPayloads:s}=await o.getMPCPayloadAndTransaction(n.transaction),u=await Promise.all(s.map(async b=>await c.sign({payload:b,path:n.derivationPath,key_version:0}))),f=o.addSignature({transaction:a,mpcSignatures:u});return{transactionHash:await o.broadcastTx(f),success:!0}}catch(d){return{success:!1,errorMessage:d instanceof Error?d.message:String(d)}}},gi=async(n,i)=>{try{const d=await Me({networkId:n.nearAuthentication.networkId,accountId:n.nearAuthentication.accountId,keypair:i}),c=new pe({networkId:n.nearAuthentication.networkId,contractId:n.chainConfig.contract,accountId:d.accountId,keypair:i}),o=new on({contract:c,chainId:n.chainConfig.chainId}),{transaction:a,mpcPayloads:s}=await o.getMPCPayloadAndTransaction(n.transaction),u=await Promise.all(s.map(async b=>await c.sign({payload:b,path:n.derivationPath,key_version:0}))),f=o.addSignature({transaction:a,mpcSignatures:u});return{transactionHash:await o.broadcastTx(f),success:!0}}catch(d){return console.error(d),{success:!1,errorMessage:d instanceof Error?d.message:String(d)}}},mi=Object.freeze({__proto__:null,BTCTransaction:hi,CosmosTransaction:gi,EVMTransaction:yi}),bi=Object.freeze({__proto__:null,keypair:mi}),_i=Object.freeze({__proto__:null,ChainSignatureContract:pe,signAndSend:bi,transactionBuilder:ai}),vi=Object.freeze({__proto__:null,near:_i}),Ye=n=>({r:n.big_r.affine_point.substring(2),s:n.s.scalar,v:n.recovery_id}),Qe=n=>{const i=n.slice(2);if(i.length!==128)throw new Error("Invalid uncompressed public key length");const d=i.slice(0,64),c=i.slice(64);return(parseInt(c.slice(-1),16)%2===0?"02":"03")+d},Si=Object.freeze({__proto__:null,compressPubKey:Qe,toRSV:Ye}),Ii=Object.freeze({__proto__:null,chains:vi,cryptography:Si});exports.BTCRpcAdapter=Qt;exports.BTCRpcAdapters=en;exports.Bitcoin=de;exports.Chain=Re;exports.ChainSignatureContract=jt;exports.Cosmos=on;exports.EVM=Yt;exports.fetchEVMFeeProperties=Zt;exports.utils=Ii;
|
|
19
|
+
//# sourceMappingURL=index.node.cjs.map
|