@psalomo/jsonrpc-client 0.5.0 → 1.0.1
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/README.md +62 -14
- package/dist/browser-standalone.js +1685 -3655
- package/dist/browser-standalone.min.js +1 -1
- package/dist/client.d.ts +21 -20
- package/dist/client.d.ts.map +1 -1
- package/dist/{convenience.mini.d.ts → convenience.d.ts} +3 -3
- package/dist/convenience.d.ts.map +1 -0
- package/dist/{generated-functions.mini.d.ts → generated-functions.d.ts} +3 -3
- package/dist/generated-functions.d.ts.map +1 -0
- package/dist/generated-types.d.ts +29 -0
- package/dist/generated-types.d.ts.map +1 -1
- package/dist/index.d.mts +133 -71
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +335 -104
- package/dist/index.mjs +307 -109
- package/dist/{validation.mini.d.ts → validation.d.ts} +5 -3
- package/dist/validation.d.ts.map +1 -0
- package/package.json +2 -7
- package/dist/browser-standalone-mini.js +0 -1245
- package/dist/browser-standalone-mini.min.js +0 -1
- package/dist/client.mini.d.ts +0 -58
- package/dist/client.mini.d.ts.map +0 -1
- package/dist/convenience.mini.d.ts.map +0 -1
- package/dist/generated-functions.mini.d.ts.map +0 -1
- package/dist/generated-types.mini.d.ts +0 -84
- package/dist/generated-types.mini.d.ts.map +0 -1
- package/dist/index.mini.cjs +0 -421
- package/dist/index.mini.d.mts +0 -198
- package/dist/index.mini.d.ts +0 -10
- package/dist/index.mini.d.ts.map +0 -1
- package/dist/index.mini.mjs +0 -361
- package/dist/validation.mini.d.ts.map +0 -1
@@ -1 +0,0 @@
|
|
1
|
-
function e(e){return e.replace(/[A-Z]/g,e=>`_${e.toLowerCase()}`)}function t(e){return e.replace(/_([a-z])/g,(e,t)=>t.toUpperCase())}function n(t){if(null===t||"object"!=typeof t)return t;if(Array.isArray(t))return t.map(n);const s={};for(const[o,r]of Object.entries(t)){s[e(o)]=n(r)}return s}function s(e){if(null===e||"object"!=typeof e)return e;if(Array.isArray(e))return e.map(s);const n={};for(const[o,r]of Object.entries(e)){n[t(o)]=s(r)}return n}class o extends Error{code;data;constructor(e,t,n){super(e),this.code=t,this.data=n,this.name="JsonRpcClientError"}}class r extends Error{cause;constructor(e,t){super(e),this.cause=t,this.name="JsonRpcNetworkError"}}class i{endpoint;headers;timeout;retries;validation;constructor(e){this.endpoint=e.endpoint,this.headers=e.headers||{},this.timeout=e.timeout||3e4,this.retries=e.retries||3,e.validation&&(this.validation=e.validation)}async makeRequest(e,t){const i={jsonrpc:"2.0",id:"dontcare",method:e,params:t?n(t):t};this.validation&&this.validation.validateRequest(i);let a=null;for(let e=0;e<=this.retries;e++)try{const e=new AbortController,t=setTimeout(()=>e.abort(),this.timeout),n=await fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json",...this.headers},body:JSON.stringify(i),signal:e.signal});if(clearTimeout(t),!n.ok)throw new r(`HTTP error! status: ${n.status}`);const a=await n.json();if(this.validation&&this.validation.validateResponse(a),a.error)throw new o(a.error.message,a.error.code,a.error.data);return a.result?s(a.result):a.result}catch(t){if(a=t,t instanceof o)throw t;if(e===this.retries)break;await new Promise(t=>setTimeout(t,1e3*Math.pow(2,e)))}throw a||new r("Request failed after all retries")}withConfig(e){return new i({endpoint:e.endpoint??this.endpoint,headers:e.headers??this.headers,timeout:e.timeout??this.timeout,retries:e.retries??this.retries,...void 0!==e.validation?{validation:e.validation}:void 0!==this.validation?{validation:this.validation}:{}})}}const a=new i({endpoint:"https://rpc.mainnet.near.org"});class c extends Error{code;data;constructor(e,t,n){super(t),this.code=e,this.data=n,this.name="NearRpcError"}}function u(e,t,n){function s(n,s){var o;Object.defineProperty(n,"_zod",{value:n._zod??{},enumerable:!1}),(o=n._zod).traits??(o.traits=new Set),n._zod.traits.add(e),t(n,s);for(const e in i.prototype)e in n||Object.defineProperty(n,e,{value:i.prototype[e].bind(n)});n._zod.constr=i,n._zod.def=s}const o=n?.Parent??Object;class r extends o{}function i(e){var t;const o=n?.Parent?new r:this;s(o,e),(t=o._zod).deferred??(t.deferred=[]);for(const e of o._zod.deferred)e();return o}return Object.defineProperty(r,"name",{value:e}),Object.defineProperty(i,"init",{value:s}),Object.defineProperty(i,Symbol.hasInstance,{value:t=>!!(n?.Parent&&t instanceof n.Parent)||t?._zod?.traits?.has(e)}),Object.defineProperty(i,"name",{value:e}),i}class l extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}const d={};function p(e){return d}function f(e,t){return"bigint"==typeof t?t.toString():t}function h(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function _(e,t,n){Object.defineProperty(e,t,{get(){{const s=n();return e[t]=s,s}},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function y(e){return JSON.stringify(e)}const m=Error.captureStackTrace?Error.captureStackTrace:(...e)=>{};function v(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}const E=h(()=>{if("undefined"!=typeof navigator&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function g(e,t=0){for(let n=t;n<e.issues.length;n++)if(!0!==e.issues[n]?.continue)return!0;return!1}function w(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function b(e){return"string"==typeof e?e:e?.message}function k(e,t,n){const s={...e,path:e.path??[]};if(!e.message){const o=b(e.inst?._zod.def?.error?.(e))??b(t?.error?.(e))??b(n.customError?.(e))??b(n.localeError?.(e))??"Invalid input";s.message=o}return delete s.inst,delete s.continue,t?.reportInput||delete s.input,s}const R=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),Object.defineProperty(e,"message",{get:()=>JSON.stringify(t,f,2),enumerable:!0}),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},z=u("$ZodError",R),P=u("$ZodError",R,{Parent:Error}),I=(e=>(t,n,s,o)=>{const r=s?Object.assign(s,{async:!1}):{async:!1},i=t._zod.run({value:n,issues:[]},r);if(i instanceof Promise)throw new l;if(i.issues.length){const t=new(o?.Err??e)(i.issues.map(e=>k(e,r,p())));throw m(t,o?.callee),t}return i.value})(P),T=(e=>async(t,n,s,o)=>{const r=s?Object.assign(s,{async:!0}):{async:!0};let i=t._zod.run({value:n,issues:[]},r);if(i instanceof Promise&&(i=await i),i.issues.length){const t=new(o?.Err??e)(i.issues.map(e=>k(e,r,p())));throw m(t,o?.callee),t}return i.value})(P),N=(e=>(t,n,s)=>{const o=s?{...s,async:!1}:{async:!1},r=t._zod.run({value:n,issues:[]},o);if(r instanceof Promise)throw new l;return r.issues.length?{success:!1,error:new(e??z)(r.issues.map(e=>k(e,o,p())))}:{success:!0,data:r.value}})(P),$=(e=>async(t,n,s)=>{const o=s?Object.assign(s,{async:!0}):{async:!0};let r=t._zod.run({value:n,issues:[]},o);return r instanceof Promise&&(r=await r),r.issues.length?{success:!1,error:new e(r.issues.map(e=>k(e,o,p())))}:{success:!0,data:r.value}})(P),A=/^-?\d+(?:\.\d+)?/i;class M{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if("function"==typeof e)return e(this,{execution:"sync"}),void e(this,{execution:"async"});const t=e.split("\n").filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),s=t.map(e=>e.slice(n)).map(e=>" ".repeat(2*this.indent)+e);for(const e of s)this.content.push(e)}compile(){const e=Function,t=this?.args;return new e(...t,[...(this?.content??[""]).map(e=>` ${e}`)].join("\n"))}}const j={major:4,minor:0,patch:5},q=u("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=j;const s=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&s.unshift(e);for(const t of s)for(const n of t._zod.onattach)n(e);if(0===s.length)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const t=(e,t,n)=>{let s,o=g(e);for(const r of t){if(r._zod.def.when){if(!r._zod.def.when(e))continue}else if(o)continue;const t=e.issues.length,i=r._zod.check(e);if(i instanceof Promise&&!1===n?.async)throw new l;if(s||i instanceof Promise)s=(s??Promise.resolve()).then(async()=>{await i;e.issues.length!==t&&(o||(o=g(e,t)))});else{if(e.issues.length===t)continue;o||(o=g(e,t))}}return s?s.then(()=>e):e};e._zod.run=(n,o)=>{const r=e._zod.parse(n,o);if(r instanceof Promise){if(!1===o.async)throw new l;return r.then(e=>t(e,s,o))}return t(r,s,o)}}e["~standard"]={validate:t=>{try{const n=N(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch(n){return $(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:"zod",version:1}}),L=u("$ZodString",(e,t)=>{var n;q.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??(n=e._zod.bag,new RegExp(`^${n?`[\\s\\S]{${n?.minimum??0},${n?.maximum??""}}`:"[\\s\\S]*"}$`)),e._zod.parse=(n,s)=>{if(t.coerce)try{n.value=String(n.value)}catch(s){}return"string"==typeof n.value||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),x=u("$ZodNumber",(e,t)=>{q.init(e,t),e._zod.pattern=e._zod.bag.pattern??A,e._zod.parse=(n,s)=>{if(t.coerce)try{n.value=Number(n.value)}catch(e){}const o=n.value;if("number"==typeof o&&!Number.isNaN(o)&&Number.isFinite(o))return n;const r="number"==typeof o?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...r?{received:r}:{}}),n}}),X=u("$ZodUnknown",(e,t)=>{q.init(e,t),e._zod.parse=e=>e});function O(e,t,n){e.issues.length&&t.issues.push(...w(n,e.issues)),t.value[n]=e.value}function S(e,t,n,s){e.issues.length?void 0===s[n]?t.value[n]=n in s?void 0:e.value:t.issues.push(...w(n,e.issues)):void 0===e.value?n in s&&(t.value[n]=void 0):t.value[n]=e.value}const Z=u("$ZodObject",(e,t)=>{q.init(e,t);const n=h(()=>{const e=Object.keys(t.shape);for(const n of e)if(!(t.shape[n]instanceof q))throw new Error(`Invalid element at key "${n}": expected a Zod schema`);const n=(s=t.shape,Object.keys(s).filter(e=>"optional"===s[e]._zod.optin&&"optional"===s[e]._zod.optout));var s;return{shape:t.shape,keys:e,keySet:new Set(e),numKeys:e.length,optionalKeys:new Set(n)}});_(e._zod,"propValues",()=>{const e=t.shape,n={};for(const t in e){const s=e[t]._zod;if(s.values){n[t]??(n[t]=new Set);for(const e of s.values)n[t].add(e)}}return n});let s;const o=v,r=!d.jitless,i=r&&E.value,a=t.catchall;let c;e._zod.parse=(u,l)=>{c??(c=n.value);const d=u.value;if(!o(d))return u.issues.push({expected:"object",code:"invalid_type",input:d,inst:e}),u;const p=[];if(r&&i&&!1===l?.async&&!0!==l.jitless)s||(s=(e=>{const t=new M(["shape","payload","ctx"]),s=n.value,o=e=>{const t=y(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write("const input = payload.value;");const r=Object.create(null);let i=0;for(const e of s.keys)r[e]="key_"+i++;t.write("const newResult = {}");for(const e of s.keys)if(s.optionalKeys.has(e)){const n=r[e];t.write(`const ${n} = ${o(e)};`);const s=y(e);t.write(`\n if (${n}.issues.length) {\n if (input[${s}] === undefined) {\n if (${s} in input) {\n newResult[${s}] = undefined;\n }\n } else {\n payload.issues = payload.issues.concat(\n ${n}.issues.map((iss) => ({\n ...iss,\n path: iss.path ? [${s}, ...iss.path] : [${s}],\n }))\n );\n }\n } else if (${n}.value === undefined) {\n if (${s} in input) newResult[${s}] = undefined;\n } else {\n newResult[${s}] = ${n}.value;\n }\n `)}else{const n=r[e];t.write(`const ${n} = ${o(e)};`),t.write(`\n if (${n}.issues.length) payload.issues = payload.issues.concat(${n}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${y(e)}, ...iss.path] : [${y(e)}]\n })));`),t.write(`newResult[${y(e)}] = ${n}.value`)}t.write("payload.value = newResult;"),t.write("return payload;");const a=t.compile();return(t,n)=>a(e,t,n)})(t.shape)),u=s(u,l);else{u.value={};const e=c.shape;for(const t of c.keys){const n=e[t],s=n._zod.run({value:d[t],issues:[]},l),o="optional"===n._zod.optin&&"optional"===n._zod.optout;s instanceof Promise?p.push(s.then(e=>o?S(e,u,t,d):O(e,u,t))):o?S(s,u,t,d):O(s,u,t)}}if(!a)return p.length?Promise.all(p).then(()=>u):u;const f=[],h=c.keySet,_=a._zod,m=_.def.type;for(const e of Object.keys(d)){if(h.has(e))continue;if("never"===m){f.push(e);continue}const t=_.run({value:d[e],issues:[]},l);t instanceof Promise?p.push(t.then(t=>O(t,u,e))):O(t,u,e)}return f.length&&u.issues.push({code:"unrecognized_keys",keys:f,input:d,inst:e}),p.length?Promise.all(p).then(()=>u):u}}),C=u("$ZodLiteral",(e,t)=>{q.init(e,t),e._zod.values=new Set(t.values),e._zod.pattern=new RegExp(`^(${t.values.map(e=>"string"==typeof e?e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"):e?e.toString():String(e)).join("|")})$`),e._zod.parse=(n,s)=>{const o=n.value;return e._zod.values.has(o)||n.issues.push({code:"invalid_value",values:t.values,input:o,inst:e}),n}}),K=u("$ZodOptional",(e,t)=>{q.init(e,t),e._zod.optin="optional",e._zod.optout="optional",_(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),_(e._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${function(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>"optional"===t.innerType._zod.optin?t.innerType._zod.run(e,n):void 0===e.value?e:t.innerType._zod.run(e,n)});const U=u("ZodMiniType",(e,t)=>{if(!e._zod)throw new Error("Uninitialized schema in ZodMiniType.");q.init(e,t),e.def=t,e.parse=(t,n)=>I(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>N(e,t,n),e.parseAsync=async(t,n)=>T(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>$(e,t,n),e.check=(...n)=>e.clone({...t,checks:[...t.checks??[],...n.map(e=>"function"==typeof e?{_zod:{check:e,def:{check:"custom"},onattach:[]}}:e)]}),e.clone=(t,n)=>function(e,t,n){const s=new e._zod.constr(t??e._zod.def);return t&&!n?.parent||(s._zod.parent=e),s}(e,t,n),e.brand=()=>e,e.register=(t,n)=>(t.add(e,n),e)}),J=u("ZodMiniString",(e,t)=>{L.init(e,t),U.init(e,t)});function F(e){return new J({type:"string"})}const B=u("ZodMiniNumber",(e,t)=>{x.init(e,t),U.init(e,t)});const W=u("ZodMiniUnknown",(e,t)=>{X.init(e,t),U.init(e,t)});function H(){return new W({type:"unknown"})}const V=u("ZodMiniObject",(e,t)=>{Z.init(e,t),U.init(e,t),_(e,"shape",()=>t.shape)});function D(e,t){return new V({type:"object",get shape(){var t,n,s;return t=this,n="shape",s={...e},Object.defineProperty(t,n,{value:s,writable:!0,enumerable:!0,configurable:!0}),this.shape}})}const G=u("ZodMiniLiteral",(e,t)=>{C.init(e,t),U.init(e,t)});function Q(e,t){return new G({type:"literal",values:Array.isArray(e)?e:[e]})}const Y=u("ZodMiniOptional",(e,t)=>{K.init(e,t),U.init(e,t)});function ee(e){return new Y({type:"optional",innerType:e})}var te=()=>D({jsonrpc:Q("2.0"),id:F(),method:F(),params:ee(H())}),ne=()=>D({jsonrpc:Q("2.0"),id:F(),result:ee(H()),error:ee(D({code:new B({type:"number",checks:[]}),message:F(),data:ee(H())}))}),se={"/EXPERIMENTAL_changes":"EXPERIMENTAL_changes","/EXPERIMENTAL_changes_in_block":"EXPERIMENTAL_changes_in_block","/EXPERIMENTAL_congestion_level":"EXPERIMENTAL_congestion_level","/EXPERIMENTAL_genesis_config":"EXPERIMENTAL_genesis_config","/EXPERIMENTAL_light_client_block_proof":"EXPERIMENTAL_light_client_block_proof","/EXPERIMENTAL_light_client_proof":"EXPERIMENTAL_light_client_proof","/EXPERIMENTAL_maintenance_windows":"EXPERIMENTAL_maintenance_windows","/EXPERIMENTAL_protocol_config":"EXPERIMENTAL_protocol_config","/EXPERIMENTAL_receipt":"EXPERIMENTAL_receipt","/EXPERIMENTAL_split_storage_info":"EXPERIMENTAL_split_storage_info","/EXPERIMENTAL_tx_status":"EXPERIMENTAL_tx_status","/EXPERIMENTAL_validators_ordered":"EXPERIMENTAL_validators_ordered","/block":"block","/broadcast_tx_async":"broadcast_tx_async","/broadcast_tx_commit":"broadcast_tx_commit","/changes":"changes","/chunk":"chunk","/client_config":"client_config","/gas_price":"gas_price","/health":"health","/light_client_proof":"light_client_proof","/network_info":"network_info","/next_light_client_block":"next_light_client_block","/query":"query","/send_tx":"send_tx","/status":"status","/tx":"tx","/validators":"validators"};Object.entries(se).forEach(([e,t])=>{});var oe=Object.values(se);async function re(e,t){return e.makeRequest("EXPERIMENTAL_changes",t)}async function ie(e,t){return e.makeRequest("EXPERIMENTAL_changes_in_block",t)}async function ae(e,t){return e.makeRequest("EXPERIMENTAL_congestion_level",t)}async function ce(e,t){return e.makeRequest("EXPERIMENTAL_genesis_config",t)}async function ue(e,t){return e.makeRequest("EXPERIMENTAL_light_client_block_proof",t)}async function le(e,t){return e.makeRequest("EXPERIMENTAL_light_client_proof",t)}async function de(e,t){return e.makeRequest("EXPERIMENTAL_maintenance_windows",t)}async function pe(e,t){return e.makeRequest("EXPERIMENTAL_protocol_config",t)}async function fe(e,t){return e.makeRequest("EXPERIMENTAL_receipt",t)}async function he(e,t){return e.makeRequest("EXPERIMENTAL_split_storage_info",t)}async function _e(e,t){return e.makeRequest("EXPERIMENTAL_tx_status",t)}async function ye(e,t){return e.makeRequest("EXPERIMENTAL_validators_ordered",t)}async function me(e,t){return e.makeRequest("block",t)}async function ve(e,t){return e.makeRequest("broadcast_tx_async",t)}async function Ee(e,t){return e.makeRequest("broadcast_tx_commit",t)}async function ge(e,t){return e.makeRequest("changes",t)}async function we(e,t){return e.makeRequest("chunk",t)}async function be(e,t){return e.makeRequest("client_config",t)}async function ke(e,t){return e.makeRequest("gas_price",t)}async function Re(e,t){return e.makeRequest("health",t)}async function ze(e,t){return e.makeRequest("light_client_proof",t)}async function Pe(e,t){return e.makeRequest("network_info",t)}async function Ie(e,t){return e.makeRequest("next_light_client_block",t)}async function Te(e,t){return e.makeRequest("query",t)}async function Ne(e,t){return e.makeRequest("send_tx",t)}async function $e(e,t){return e.makeRequest("status",t)}async function Ae(e,t){return e.makeRequest("tx",t)}async function Me(e,t){return e.makeRequest("validators",t)}async function je(e,t){return Te(e,t.blockId?{requestType:"view_account",accountId:t.accountId,blockId:t.blockId}:{requestType:"view_account",accountId:t.accountId,finality:t.finality||"final"})}async function qe(e,t){const n={requestType:"call_function",accountId:t.accountId,methodName:t.methodName,argsBase64:t.argsBase64??""};return Te(e,t.blockId?{...n,blockId:t.blockId}:{...n,finality:t.finality||"final"})}async function Le(e,t){return Te(e,t.blockId?{requestType:"view_access_key",accountId:t.accountId,publicKey:t.publicKey,blockId:t.blockId}:{requestType:"view_access_key",accountId:t.accountId,publicKey:t.publicKey,finality:t.finality||"final"})}function xe(){const e=te(),t=ne();return{validateRequest:t=>{try{e.parse(t)}catch(e){throw new r(`Invalid request format: ${e instanceof Error?e.message:"Unknown error"}`,e)}},validateResponse:e=>{try{t.parse(e)}catch(e){throw new o(`Invalid response format: ${e instanceof Error?e.message:"Unknown error"}`)}}}}export{o as JsonRpcClientError,r as JsonRpcNetworkError,te as JsonRpcRequestSchema,ne as JsonRpcResponseSchema,i as NearRpcClient,c as NearRpcError,oe as RPC_METHODS,me as block,ve as broadcastTxAsync,Ee as broadcastTxCommit,ge as changes,we as chunk,be as clientConfig,i as default,a as defaultClient,xe as enableValidation,re as experimentalChanges,ie as experimentalChangesInBlock,ae as experimentalCongestionLevel,ce as experimentalGenesisConfig,ue as experimentalLightClientBlockProof,le as experimentalLightClientProof,de as experimentalMaintenanceWindows,pe as experimentalProtocolConfig,fe as experimentalReceipt,he as experimentalSplitStorageInfo,_e as experimentalTxStatus,ye as experimentalValidatorsOrdered,ke as gasPrice,Re as health,ze as lightClientProof,Pe as networkInfo,Ie as nextLightClientBlock,Te as query,Ne as sendTx,$e as status,Ae as tx,Me as validators,Le as viewAccessKey,je as viewAccount,qe as viewFunction};
|
package/dist/client.mini.d.ts
DELETED
@@ -1,58 +0,0 @@
|
|
1
|
-
import type { ValidationResult } from './validation.mini.js';
|
2
|
-
export interface MiniClientConfig {
|
3
|
-
endpoint: string;
|
4
|
-
headers?: Record<string, string>;
|
5
|
-
timeout?: number;
|
6
|
-
retries?: number;
|
7
|
-
validation?: ValidationResult;
|
8
|
-
}
|
9
|
-
export interface JsonRpcRequest<T = unknown> {
|
10
|
-
jsonrpc: '2.0';
|
11
|
-
id: string;
|
12
|
-
method: string;
|
13
|
-
params?: T;
|
14
|
-
}
|
15
|
-
export interface JsonRpcResponse<T = unknown> {
|
16
|
-
jsonrpc: '2.0';
|
17
|
-
id: string;
|
18
|
-
result?: T;
|
19
|
-
error?: JsonRpcError;
|
20
|
-
}
|
21
|
-
export interface JsonRpcError {
|
22
|
-
code: number;
|
23
|
-
message: string;
|
24
|
-
data?: unknown;
|
25
|
-
}
|
26
|
-
export declare class JsonRpcClientError extends Error {
|
27
|
-
code?: number | undefined;
|
28
|
-
data?: unknown | undefined;
|
29
|
-
constructor(message: string, code?: number | undefined, data?: unknown | undefined);
|
30
|
-
}
|
31
|
-
export declare class JsonRpcNetworkError extends Error {
|
32
|
-
cause?: Error | undefined;
|
33
|
-
constructor(message: string, cause?: Error | undefined);
|
34
|
-
}
|
35
|
-
/**
|
36
|
-
* Simplified NEAR RPC Client for mini version
|
37
|
-
* This client only holds configuration and provides a makeRequest method
|
38
|
-
* Individual RPC methods are provided as standalone functions that take this client as a parameter
|
39
|
-
*/
|
40
|
-
export declare class NearRpcClient {
|
41
|
-
readonly endpoint: string;
|
42
|
-
readonly headers: Record<string, string>;
|
43
|
-
readonly timeout: number;
|
44
|
-
readonly retries: number;
|
45
|
-
private readonly validation?;
|
46
|
-
constructor(config: MiniClientConfig);
|
47
|
-
/**
|
48
|
-
* Make a raw JSON-RPC request
|
49
|
-
* This is used internally by the standalone RPC functions
|
50
|
-
*/
|
51
|
-
makeRequest<TParams = unknown, TResult = unknown>(method: string, params?: TParams): Promise<TResult>;
|
52
|
-
/**
|
53
|
-
* Create a new client with modified configuration
|
54
|
-
*/
|
55
|
-
withConfig(config: Partial<MiniClientConfig>): NearRpcClient;
|
56
|
-
}
|
57
|
-
export declare const defaultClient: NearRpcClient;
|
58
|
-
//# sourceMappingURL=client.mini.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"client.mini.d.ts","sourceRoot":"","sources":["../src/client.mini.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAiD7D,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,gBAAgB,CAAC;CAC/B;AAGD,MAAM,WAAW,cAAc,CAAC,CAAC,GAAG,OAAO;IACzC,OAAO,EAAE,KAAK,CAAC;IACf,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,CAAC,CAAC;CACZ;AAGD,MAAM,WAAW,eAAe,CAAC,CAAC,GAAG,OAAO;IAC1C,OAAO,EAAE,KAAK,CAAC;IACf,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,CAAC,EAAE,CAAC,CAAC;IACX,KAAK,CAAC,EAAE,YAAY,CAAC;CACtB;AAG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ACV,aAAa,EACd,MAAM,6BAA6B,CAAC;AAErC,wBAAsB,WAAW,CAC/B,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE;IACN,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,GAAG,YAAY,GAAG,YAAY,CAAC;IACjD,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CAC3B,GACA,OAAO,CAAC,WAAW,CAAC,CAetB;AAED,wBAAsB,YAAY,CAChC,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE;IACN,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,GAAG,YAAY,GAAG,YAAY,CAAC;IACjD,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CAC3B,GACA,OAAO,CAAC,UAAU,CAAC,CAcrB;AAED,wBAAsB,aAAa,CACjC,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE;IACN,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,GAAG,YAAY,GAAG,YAAY,CAAC;IACjD,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CAC3B,GACA,OAAO,CAAC,aAAa,CAAC,CAiBxB"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"generated-functions.mini.d.ts","sourceRoot":"","sources":["../src/generated-functions.mini.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,mBAAmB,EACnB,0BAA0B,EAC1B,2BAA2B,EAC3B,yBAAyB,EACzB,iCAAiC,EACjC,4BAA4B,EAC5B,8BAA8B,EAC9B,0BAA0B,EAC1B,mBAAmB,EACnB,4BAA4B,EAC5B,oBAAoB,EACpB,6BAA6B,EAC7B,KAAK,EACL,gBAAgB,EAChB,iBAAiB,EACjB,OAAO,EACP,KAAK,EACL,YAAY,EACZ,QAAQ,EACR,MAAM,EACN,gBAAgB,EAChB,WAAW,EACX,oBAAoB,EACpB,KAAK,EACL,MAAM,EACN,MAAM,EACN,EAAE,EACF,UAAU,GACX,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC"}
|
@@ -1,84 +0,0 @@
|
|
1
|
-
import type { AccessKeyView, AccountView, CallResult, CryptoHash, EXPERIMENTALMaintenanceWindowsResponse, EXPERIMENTALValidatorsOrderedResponse, GenesisConfig, GenesisConfigRequest, RpcBlockRequest, RpcBlockResponse, RpcChunkRequest, RpcChunkResponse, RpcClientConfigRequest, RpcClientConfigResponse, RpcCongestionLevelRequest, RpcCongestionLevelResponse, RpcGasPriceRequest, RpcGasPriceResponse, RpcHealthRequest, RpcHealthResponse, RpcLightClientBlockProofRequest, RpcLightClientBlockProofResponse, RpcLightClientExecutionProofRequest, RpcLightClientExecutionProofResponse, RpcLightClientNextBlockRequest, RpcLightClientNextBlockResponse, RpcMaintenanceWindowsRequest, RpcNetworkInfoRequest, RpcNetworkInfoResponse, RpcProtocolConfigRequest, RpcProtocolConfigResponse, RpcQueryRequest, RpcQueryResponse, RpcReceiptRequest, RpcReceiptResponse, RpcSendTransactionRequest, RpcSplitStorageInfoRequest, RpcSplitStorageInfoResponse, RpcStateChangesInBlockByTypeRequest, RpcStateChangesInBlockByTypeResponse, RpcStateChangesInBlockRequest, RpcStateChangesInBlockResponse, RpcStatusRequest, RpcStatusResponse, RpcTransactionResponse, RpcTransactionStatusRequest, RpcValidatorRequest, RpcValidatorResponse, RpcValidatorsOrderedRequest } from '@near-js/jsonrpc-types/mini';
|
2
|
-
import type { NearRpcClient } from './client.mini';
|
3
|
-
export interface DynamicRpcMethods {
|
4
|
-
experimentalChanges(params?: RpcStateChangesInBlockByTypeRequest): Promise<RpcStateChangesInBlockResponse>;
|
5
|
-
experimentalChangesInBlock(params?: RpcStateChangesInBlockRequest): Promise<RpcStateChangesInBlockByTypeResponse>;
|
6
|
-
experimentalCongestionLevel(params?: RpcCongestionLevelRequest): Promise<RpcCongestionLevelResponse>;
|
7
|
-
experimentalGenesisConfig(params?: GenesisConfigRequest): Promise<GenesisConfig>;
|
8
|
-
experimentalLightClientBlockProof(params?: RpcLightClientBlockProofRequest): Promise<RpcLightClientBlockProofResponse>;
|
9
|
-
experimentalLightClientProof(params?: RpcLightClientExecutionProofRequest): Promise<RpcLightClientExecutionProofResponse>;
|
10
|
-
experimentalMaintenanceWindows(params?: RpcMaintenanceWindowsRequest): Promise<EXPERIMENTALMaintenanceWindowsResponse>;
|
11
|
-
experimentalProtocolConfig(params?: RpcProtocolConfigRequest): Promise<RpcProtocolConfigResponse>;
|
12
|
-
experimentalReceipt(params?: RpcReceiptRequest): Promise<RpcReceiptResponse>;
|
13
|
-
experimentalSplitStorageInfo(params?: RpcSplitStorageInfoRequest): Promise<RpcSplitStorageInfoResponse>;
|
14
|
-
experimentalTxStatus(params?: RpcTransactionStatusRequest): Promise<RpcTransactionResponse>;
|
15
|
-
experimentalValidatorsOrdered(params?: RpcValidatorsOrderedRequest): Promise<EXPERIMENTALValidatorsOrderedResponse>;
|
16
|
-
block(params?: RpcBlockRequest): Promise<RpcBlockResponse>;
|
17
|
-
broadcastTxAsync(params?: RpcSendTransactionRequest): Promise<CryptoHash>;
|
18
|
-
broadcastTxCommit(params?: RpcSendTransactionRequest): Promise<RpcTransactionResponse>;
|
19
|
-
changes(params?: RpcStateChangesInBlockByTypeRequest): Promise<RpcStateChangesInBlockResponse>;
|
20
|
-
chunk(params?: RpcChunkRequest): Promise<RpcChunkResponse>;
|
21
|
-
clientConfig(params?: RpcClientConfigRequest): Promise<RpcClientConfigResponse>;
|
22
|
-
gasPrice(params?: RpcGasPriceRequest): Promise<RpcGasPriceResponse>;
|
23
|
-
health(params?: RpcHealthRequest): Promise<RpcHealthResponse>;
|
24
|
-
lightClientProof(params?: RpcLightClientExecutionProofRequest): Promise<RpcLightClientExecutionProofResponse>;
|
25
|
-
networkInfo(params?: RpcNetworkInfoRequest): Promise<RpcNetworkInfoResponse>;
|
26
|
-
nextLightClientBlock(params?: RpcLightClientNextBlockRequest): Promise<RpcLightClientNextBlockResponse>;
|
27
|
-
query(params?: RpcQueryRequest): Promise<RpcQueryResponse>;
|
28
|
-
sendTx(params?: RpcSendTransactionRequest): Promise<RpcTransactionResponse>;
|
29
|
-
status(params?: RpcStatusRequest): Promise<RpcStatusResponse>;
|
30
|
-
tx(params?: RpcTransactionStatusRequest): Promise<RpcTransactionResponse>;
|
31
|
-
validators(params?: RpcValidatorRequest): Promise<RpcValidatorResponse>;
|
32
|
-
}
|
33
|
-
export interface ConvenienceMethods {
|
34
|
-
viewAccount(params: {
|
35
|
-
accountId: string;
|
36
|
-
finality?: 'final' | 'near-final' | 'optimistic';
|
37
|
-
blockId?: string | number;
|
38
|
-
}): Promise<AccountView>;
|
39
|
-
viewFunction(params: {
|
40
|
-
accountId: string;
|
41
|
-
methodName: string;
|
42
|
-
argsBase64?: string;
|
43
|
-
finality?: 'final' | 'near-final' | 'optimistic';
|
44
|
-
blockId?: string | number;
|
45
|
-
}): Promise<CallResult>;
|
46
|
-
viewAccessKey(params: {
|
47
|
-
accountId: string;
|
48
|
-
publicKey: string;
|
49
|
-
finality?: 'final' | 'near-final' | 'optimistic';
|
50
|
-
blockId?: string | number;
|
51
|
-
}): Promise<AccessKeyView>;
|
52
|
-
}
|
53
|
-
export interface CompleteClientInterface extends DynamicRpcMethods, ConvenienceMethods {
|
54
|
-
call<TParams = unknown, TResult = unknown>(method: string, params?: TParams): Promise<TResult>;
|
55
|
-
}
|
56
|
-
export declare function experimentalChanges(client: NearRpcClient, params?: RpcStateChangesInBlockByTypeRequest): Promise<RpcStateChangesInBlockResponse>;
|
57
|
-
export declare function experimentalChangesInBlock(client: NearRpcClient, params?: RpcStateChangesInBlockRequest): Promise<RpcStateChangesInBlockByTypeResponse>;
|
58
|
-
export declare function experimentalCongestionLevel(client: NearRpcClient, params?: RpcCongestionLevelRequest): Promise<RpcCongestionLevelResponse>;
|
59
|
-
export declare function experimentalGenesisConfig(client: NearRpcClient, params?: GenesisConfigRequest): Promise<GenesisConfig>;
|
60
|
-
export declare function experimentalLightClientBlockProof(client: NearRpcClient, params?: RpcLightClientBlockProofRequest): Promise<RpcLightClientBlockProofResponse>;
|
61
|
-
export declare function experimentalLightClientProof(client: NearRpcClient, params?: RpcLightClientExecutionProofRequest): Promise<RpcLightClientExecutionProofResponse>;
|
62
|
-
export declare function experimentalMaintenanceWindows(client: NearRpcClient, params?: RpcMaintenanceWindowsRequest): Promise<EXPERIMENTALMaintenanceWindowsResponse>;
|
63
|
-
export declare function experimentalProtocolConfig(client: NearRpcClient, params?: RpcProtocolConfigRequest): Promise<RpcProtocolConfigResponse>;
|
64
|
-
export declare function experimentalReceipt(client: NearRpcClient, params?: RpcReceiptRequest): Promise<RpcReceiptResponse>;
|
65
|
-
export declare function experimentalSplitStorageInfo(client: NearRpcClient, params?: RpcSplitStorageInfoRequest): Promise<RpcSplitStorageInfoResponse>;
|
66
|
-
export declare function experimentalTxStatus(client: NearRpcClient, params?: RpcTransactionStatusRequest): Promise<RpcTransactionResponse>;
|
67
|
-
export declare function experimentalValidatorsOrdered(client: NearRpcClient, params?: RpcValidatorsOrderedRequest): Promise<EXPERIMENTALValidatorsOrderedResponse>;
|
68
|
-
export declare function block(client: NearRpcClient, params?: RpcBlockRequest): Promise<RpcBlockResponse>;
|
69
|
-
export declare function broadcastTxAsync(client: NearRpcClient, params?: RpcSendTransactionRequest): Promise<CryptoHash>;
|
70
|
-
export declare function broadcastTxCommit(client: NearRpcClient, params?: RpcSendTransactionRequest): Promise<RpcTransactionResponse>;
|
71
|
-
export declare function changes(client: NearRpcClient, params?: RpcStateChangesInBlockByTypeRequest): Promise<RpcStateChangesInBlockResponse>;
|
72
|
-
export declare function chunk(client: NearRpcClient, params?: RpcChunkRequest): Promise<RpcChunkResponse>;
|
73
|
-
export declare function clientConfig(client: NearRpcClient, params?: RpcClientConfigRequest): Promise<RpcClientConfigResponse>;
|
74
|
-
export declare function gasPrice(client: NearRpcClient, params?: RpcGasPriceRequest): Promise<RpcGasPriceResponse>;
|
75
|
-
export declare function health(client: NearRpcClient, params?: RpcHealthRequest): Promise<RpcHealthResponse>;
|
76
|
-
export declare function lightClientProof(client: NearRpcClient, params?: RpcLightClientExecutionProofRequest): Promise<RpcLightClientExecutionProofResponse>;
|
77
|
-
export declare function networkInfo(client: NearRpcClient, params?: RpcNetworkInfoRequest): Promise<RpcNetworkInfoResponse>;
|
78
|
-
export declare function nextLightClientBlock(client: NearRpcClient, params?: RpcLightClientNextBlockRequest): Promise<RpcLightClientNextBlockResponse>;
|
79
|
-
export declare function query(client: NearRpcClient, params?: RpcQueryRequest): Promise<RpcQueryResponse>;
|
80
|
-
export declare function sendTx(client: NearRpcClient, params?: RpcSendTransactionRequest): Promise<RpcTransactionResponse>;
|
81
|
-
export declare function status(client: NearRpcClient, params?: RpcStatusRequest): Promise<RpcStatusResponse>;
|
82
|
-
export declare function tx(client: NearRpcClient, params?: RpcTransactionStatusRequest): Promise<RpcTransactionResponse>;
|
83
|
-
export declare function validators(client: NearRpcClient, params?: RpcValidatorRequest): Promise<RpcValidatorResponse>;
|
84
|
-
//# sourceMappingURL=generated-types.mini.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"generated-types.mini.d.ts","sourceRoot":"","sources":["../src/generated-types.mini.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,aAAa,EACb,WAAW,EACX,UAAU,EACV,UAAU,EACV,sCAAsC,EACtC,qCAAqC,EACrC,aAAa,EACb,oBAAoB,EACpB,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,sBAAsB,EACtB,uBAAuB,EACvB,yBAAyB,EACzB,0BAA0B,EAC1B,kBAAkB,EAClB,mBAAmB,EACnB,gBAAgB,EAChB,iBAAiB,EACjB,+BAA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,CAC1B,MAAM,EAAE,aAAa,EACrB,MAAM,CAAC,EAAE,gBAAgB,GACxB,OAAO,CAAC,iBAAiB,CAAC,CAE5B;AAGD,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,aAAa,EACrB,MAAM,CAAC,EAAE,mCAAmC,GAC3C,OAAO,CAAC,oCAAoC,CAAC,CAE/C;AAGD,wBAAsB,WAAW,CAC/B,MAAM,EAAE,aAAa,EACrB,MAAM,CAAC,EAAE,qBAAqB,GAC7B,OAAO,CAAC,sBAAsB,CAAC,CAEjC;AAGD,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,aAAa,EACrB,MAAM,CAAC,EAAE,8BAA8B,GACtC,OAAO,CAAC,+BAA+B,CAAC,CAE1C;AAGD,wBAAsB,KAAK,CACzB,MAAM,EAAE,aAAa,EACrB,MAAM,CAAC,EAAE,eAAe,GACvB,OAAO,CAAC,gBAAgB,CAAC,CAE3B;AAGD,wBAAsB,MAAM,CAC1B,MAAM,EAAE,aAAa,EACrB,MAAM,CAAC,EAAE,yBAAyB,GACjC,OAAO,CAAC,sBAAsB,CAAC,CAEjC;AAGD,wBAAsB,MAAM,CAC1B,MAAM,EAAE,aAAa,EACrB,MAAM,CAAC,EAAE,gBAAgB,GACxB,OAAO,CAAC,iBAAiB,CAAC,CAE5B;AAGD,wBAAsB,EAAE,CACtB,MAAM,EAAE,aAAa,EACrB,MAAM,CAAC,EAAE,2BAA2B,GACnC,OAAO,CAAC,sBAAsB,CAAC,CAEjC;AAGD,wBAAsB,UAAU,CAC9B,MAAM,EAAE,aAAa,EACrB,MAAM,CAAC,EAAE,mBAAmB,GAC3B,OAAO,CAAC,oBAAoB,CAAC,CAE/B"}
|
package/dist/index.mini.cjs
DELETED
@@ -1,421 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __defProp = Object.defineProperty;
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
-
var __export = (target, all) => {
|
7
|
-
for (var name in all)
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
9
|
-
};
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
12
|
-
for (let key of __getOwnPropNames(from))
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
15
|
-
}
|
16
|
-
return to;
|
17
|
-
};
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
19
|
-
|
20
|
-
// src/index.mini.ts
|
21
|
-
var index_mini_exports = {};
|
22
|
-
__export(index_mini_exports, {
|
23
|
-
JsonRpcClientError: () => JsonRpcClientError,
|
24
|
-
JsonRpcNetworkError: () => JsonRpcNetworkError,
|
25
|
-
JsonRpcRequestSchema: () => import_mini2.JsonRpcRequestSchema,
|
26
|
-
JsonRpcResponseSchema: () => import_mini2.JsonRpcResponseSchema,
|
27
|
-
NearRpcClient: () => NearRpcClient,
|
28
|
-
NearRpcError: () => NearRpcError,
|
29
|
-
RPC_METHODS: () => import_mini3.RPC_METHODS,
|
30
|
-
block: () => block,
|
31
|
-
broadcastTxAsync: () => broadcastTxAsync,
|
32
|
-
broadcastTxCommit: () => broadcastTxCommit,
|
33
|
-
changes: () => changes,
|
34
|
-
chunk: () => chunk,
|
35
|
-
clientConfig: () => clientConfig,
|
36
|
-
default: () => NearRpcClient,
|
37
|
-
defaultClient: () => defaultClient,
|
38
|
-
enableValidation: () => enableValidation,
|
39
|
-
experimentalChanges: () => experimentalChanges,
|
40
|
-
experimentalChangesInBlock: () => experimentalChangesInBlock,
|
41
|
-
experimentalCongestionLevel: () => experimentalCongestionLevel,
|
42
|
-
experimentalGenesisConfig: () => experimentalGenesisConfig,
|
43
|
-
experimentalLightClientBlockProof: () => experimentalLightClientBlockProof,
|
44
|
-
experimentalLightClientProof: () => experimentalLightClientProof,
|
45
|
-
experimentalMaintenanceWindows: () => experimentalMaintenanceWindows,
|
46
|
-
experimentalProtocolConfig: () => experimentalProtocolConfig,
|
47
|
-
experimentalReceipt: () => experimentalReceipt,
|
48
|
-
experimentalSplitStorageInfo: () => experimentalSplitStorageInfo,
|
49
|
-
experimentalTxStatus: () => experimentalTxStatus,
|
50
|
-
experimentalValidatorsOrdered: () => experimentalValidatorsOrdered,
|
51
|
-
gasPrice: () => gasPrice,
|
52
|
-
health: () => health,
|
53
|
-
lightClientProof: () => lightClientProof,
|
54
|
-
networkInfo: () => networkInfo,
|
55
|
-
nextLightClientBlock: () => nextLightClientBlock,
|
56
|
-
query: () => query,
|
57
|
-
sendTx: () => sendTx,
|
58
|
-
status: () => status,
|
59
|
-
tx: () => tx,
|
60
|
-
validators: () => validators,
|
61
|
-
viewAccessKey: () => viewAccessKey,
|
62
|
-
viewAccount: () => viewAccount,
|
63
|
-
viewFunction: () => viewFunction
|
64
|
-
});
|
65
|
-
module.exports = __toCommonJS(index_mini_exports);
|
66
|
-
|
67
|
-
// src/client.mini.ts
|
68
|
-
function camelToSnake(str) {
|
69
|
-
return str.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
|
70
|
-
}
|
71
|
-
function snakeToCamel(str) {
|
72
|
-
return str.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase());
|
73
|
-
}
|
74
|
-
function convertKeysToSnakeCase(obj) {
|
75
|
-
if (obj === null || typeof obj !== "object") {
|
76
|
-
return obj;
|
77
|
-
}
|
78
|
-
if (Array.isArray(obj)) {
|
79
|
-
return obj.map(convertKeysToSnakeCase);
|
80
|
-
}
|
81
|
-
const converted = {};
|
82
|
-
for (const [key, value] of Object.entries(obj)) {
|
83
|
-
const snakeKey = camelToSnake(key);
|
84
|
-
converted[snakeKey] = convertKeysToSnakeCase(value);
|
85
|
-
}
|
86
|
-
return converted;
|
87
|
-
}
|
88
|
-
function convertKeysToCamelCase(obj) {
|
89
|
-
if (obj === null || typeof obj !== "object") {
|
90
|
-
return obj;
|
91
|
-
}
|
92
|
-
if (Array.isArray(obj)) {
|
93
|
-
return obj.map(convertKeysToCamelCase);
|
94
|
-
}
|
95
|
-
const converted = {};
|
96
|
-
for (const [key, value] of Object.entries(obj)) {
|
97
|
-
const camelKey = snakeToCamel(key);
|
98
|
-
converted[camelKey] = convertKeysToCamelCase(value);
|
99
|
-
}
|
100
|
-
return converted;
|
101
|
-
}
|
102
|
-
var REQUEST_ID = "dontcare";
|
103
|
-
var JsonRpcClientError = class extends Error {
|
104
|
-
constructor(message, code, data) {
|
105
|
-
super(message);
|
106
|
-
this.code = code;
|
107
|
-
this.data = data;
|
108
|
-
this.name = "JsonRpcClientError";
|
109
|
-
}
|
110
|
-
};
|
111
|
-
var JsonRpcNetworkError = class extends Error {
|
112
|
-
constructor(message, cause) {
|
113
|
-
super(message);
|
114
|
-
this.cause = cause;
|
115
|
-
this.name = "JsonRpcNetworkError";
|
116
|
-
}
|
117
|
-
};
|
118
|
-
var NearRpcClient = class _NearRpcClient {
|
119
|
-
endpoint;
|
120
|
-
headers;
|
121
|
-
timeout;
|
122
|
-
retries;
|
123
|
-
validation;
|
124
|
-
constructor(config) {
|
125
|
-
this.endpoint = config.endpoint;
|
126
|
-
this.headers = config.headers || {};
|
127
|
-
this.timeout = config.timeout || 3e4;
|
128
|
-
this.retries = config.retries || 3;
|
129
|
-
if (config.validation) {
|
130
|
-
this.validation = config.validation;
|
131
|
-
}
|
132
|
-
}
|
133
|
-
/**
|
134
|
-
* Make a raw JSON-RPC request
|
135
|
-
* This is used internally by the standalone RPC functions
|
136
|
-
*/
|
137
|
-
async makeRequest(method, params) {
|
138
|
-
const snakeCaseParams = params ? convertKeysToSnakeCase(params) : params;
|
139
|
-
const request = {
|
140
|
-
jsonrpc: "2.0",
|
141
|
-
id: REQUEST_ID,
|
142
|
-
method,
|
143
|
-
params: snakeCaseParams
|
144
|
-
};
|
145
|
-
if (this.validation) {
|
146
|
-
this.validation.validateRequest(request);
|
147
|
-
}
|
148
|
-
let lastError = null;
|
149
|
-
for (let attempt = 0; attempt <= this.retries; attempt++) {
|
150
|
-
try {
|
151
|
-
const controller = new AbortController();
|
152
|
-
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
153
|
-
const response = await fetch(this.endpoint, {
|
154
|
-
method: "POST",
|
155
|
-
headers: {
|
156
|
-
"Content-Type": "application/json",
|
157
|
-
...this.headers
|
158
|
-
},
|
159
|
-
body: JSON.stringify(request),
|
160
|
-
signal: controller.signal
|
161
|
-
});
|
162
|
-
clearTimeout(timeoutId);
|
163
|
-
if (!response.ok) {
|
164
|
-
throw new JsonRpcNetworkError(
|
165
|
-
`HTTP error! status: ${response.status}`
|
166
|
-
);
|
167
|
-
}
|
168
|
-
const jsonResponse = await response.json();
|
169
|
-
if (this.validation) {
|
170
|
-
this.validation.validateResponse(jsonResponse);
|
171
|
-
}
|
172
|
-
if (jsonResponse.error) {
|
173
|
-
throw new JsonRpcClientError(
|
174
|
-
jsonResponse.error.message,
|
175
|
-
jsonResponse.error.code,
|
176
|
-
jsonResponse.error.data
|
177
|
-
);
|
178
|
-
}
|
179
|
-
const camelCaseResult = jsonResponse.result ? convertKeysToCamelCase(jsonResponse.result) : jsonResponse.result;
|
180
|
-
return camelCaseResult;
|
181
|
-
} catch (error) {
|
182
|
-
lastError = error;
|
183
|
-
if (error instanceof JsonRpcClientError) {
|
184
|
-
throw error;
|
185
|
-
}
|
186
|
-
if (attempt === this.retries) {
|
187
|
-
break;
|
188
|
-
}
|
189
|
-
await new Promise(
|
190
|
-
(resolve) => setTimeout(resolve, Math.pow(2, attempt) * 1e3)
|
191
|
-
);
|
192
|
-
}
|
193
|
-
}
|
194
|
-
throw lastError || new JsonRpcNetworkError("Request failed after all retries");
|
195
|
-
}
|
196
|
-
/**
|
197
|
-
* Create a new client with modified configuration
|
198
|
-
*/
|
199
|
-
withConfig(config) {
|
200
|
-
return new _NearRpcClient({
|
201
|
-
endpoint: config.endpoint ?? this.endpoint,
|
202
|
-
headers: config.headers ?? this.headers,
|
203
|
-
timeout: config.timeout ?? this.timeout,
|
204
|
-
retries: config.retries ?? this.retries,
|
205
|
-
...config.validation !== void 0 ? { validation: config.validation } : this.validation !== void 0 ? { validation: this.validation } : {}
|
206
|
-
});
|
207
|
-
}
|
208
|
-
};
|
209
|
-
var defaultClient = new NearRpcClient({
|
210
|
-
endpoint: "https://rpc.mainnet.near.org"
|
211
|
-
});
|
212
|
-
|
213
|
-
// src/types.ts
|
214
|
-
var NearRpcError = class extends Error {
|
215
|
-
constructor(code, message, data) {
|
216
|
-
super(message);
|
217
|
-
this.code = code;
|
218
|
-
this.data = data;
|
219
|
-
this.name = "NearRpcError";
|
220
|
-
}
|
221
|
-
};
|
222
|
-
|
223
|
-
// src/index.mini.ts
|
224
|
-
var import_mini2 = require("@near-js/jsonrpc-types/mini");
|
225
|
-
var import_mini3 = require("@near-js/jsonrpc-types/mini");
|
226
|
-
|
227
|
-
// src/generated-types.mini.ts
|
228
|
-
async function experimentalChanges(client, params) {
|
229
|
-
return client.makeRequest("EXPERIMENTAL_changes", params);
|
230
|
-
}
|
231
|
-
async function experimentalChangesInBlock(client, params) {
|
232
|
-
return client.makeRequest("EXPERIMENTAL_changes_in_block", params);
|
233
|
-
}
|
234
|
-
async function experimentalCongestionLevel(client, params) {
|
235
|
-
return client.makeRequest("EXPERIMENTAL_congestion_level", params);
|
236
|
-
}
|
237
|
-
async function experimentalGenesisConfig(client, params) {
|
238
|
-
return client.makeRequest("EXPERIMENTAL_genesis_config", params);
|
239
|
-
}
|
240
|
-
async function experimentalLightClientBlockProof(client, params) {
|
241
|
-
return client.makeRequest("EXPERIMENTAL_light_client_block_proof", params);
|
242
|
-
}
|
243
|
-
async function experimentalLightClientProof(client, params) {
|
244
|
-
return client.makeRequest("EXPERIMENTAL_light_client_proof", params);
|
245
|
-
}
|
246
|
-
async function experimentalMaintenanceWindows(client, params) {
|
247
|
-
return client.makeRequest("EXPERIMENTAL_maintenance_windows", params);
|
248
|
-
}
|
249
|
-
async function experimentalProtocolConfig(client, params) {
|
250
|
-
return client.makeRequest("EXPERIMENTAL_protocol_config", params);
|
251
|
-
}
|
252
|
-
async function experimentalReceipt(client, params) {
|
253
|
-
return client.makeRequest("EXPERIMENTAL_receipt", params);
|
254
|
-
}
|
255
|
-
async function experimentalSplitStorageInfo(client, params) {
|
256
|
-
return client.makeRequest("EXPERIMENTAL_split_storage_info", params);
|
257
|
-
}
|
258
|
-
async function experimentalTxStatus(client, params) {
|
259
|
-
return client.makeRequest("EXPERIMENTAL_tx_status", params);
|
260
|
-
}
|
261
|
-
async function experimentalValidatorsOrdered(client, params) {
|
262
|
-
return client.makeRequest("EXPERIMENTAL_validators_ordered", params);
|
263
|
-
}
|
264
|
-
async function block(client, params) {
|
265
|
-
return client.makeRequest("block", params);
|
266
|
-
}
|
267
|
-
async function broadcastTxAsync(client, params) {
|
268
|
-
return client.makeRequest("broadcast_tx_async", params);
|
269
|
-
}
|
270
|
-
async function broadcastTxCommit(client, params) {
|
271
|
-
return client.makeRequest("broadcast_tx_commit", params);
|
272
|
-
}
|
273
|
-
async function changes(client, params) {
|
274
|
-
return client.makeRequest("changes", params);
|
275
|
-
}
|
276
|
-
async function chunk(client, params) {
|
277
|
-
return client.makeRequest("chunk", params);
|
278
|
-
}
|
279
|
-
async function clientConfig(client, params) {
|
280
|
-
return client.makeRequest("client_config", params);
|
281
|
-
}
|
282
|
-
async function gasPrice(client, params) {
|
283
|
-
return client.makeRequest("gas_price", params);
|
284
|
-
}
|
285
|
-
async function health(client, params) {
|
286
|
-
return client.makeRequest("health", params);
|
287
|
-
}
|
288
|
-
async function lightClientProof(client, params) {
|
289
|
-
return client.makeRequest("light_client_proof", params);
|
290
|
-
}
|
291
|
-
async function networkInfo(client, params) {
|
292
|
-
return client.makeRequest("network_info", params);
|
293
|
-
}
|
294
|
-
async function nextLightClientBlock(client, params) {
|
295
|
-
return client.makeRequest("next_light_client_block", params);
|
296
|
-
}
|
297
|
-
async function query(client, params) {
|
298
|
-
return client.makeRequest("query", params);
|
299
|
-
}
|
300
|
-
async function sendTx(client, params) {
|
301
|
-
return client.makeRequest("send_tx", params);
|
302
|
-
}
|
303
|
-
async function status(client, params) {
|
304
|
-
return client.makeRequest("status", params);
|
305
|
-
}
|
306
|
-
async function tx(client, params) {
|
307
|
-
return client.makeRequest("tx", params);
|
308
|
-
}
|
309
|
-
async function validators(client, params) {
|
310
|
-
return client.makeRequest("validators", params);
|
311
|
-
}
|
312
|
-
|
313
|
-
// src/convenience.mini.ts
|
314
|
-
async function viewAccount(client, params) {
|
315
|
-
const queryParams = params.blockId ? {
|
316
|
-
requestType: "view_account",
|
317
|
-
accountId: params.accountId,
|
318
|
-
blockId: params.blockId
|
319
|
-
} : {
|
320
|
-
requestType: "view_account",
|
321
|
-
accountId: params.accountId,
|
322
|
-
finality: params.finality || "final"
|
323
|
-
};
|
324
|
-
return query(client, queryParams);
|
325
|
-
}
|
326
|
-
async function viewFunction(client, params) {
|
327
|
-
const baseParams = {
|
328
|
-
requestType: "call_function",
|
329
|
-
accountId: params.accountId,
|
330
|
-
methodName: params.methodName,
|
331
|
-
argsBase64: params.argsBase64 ?? ""
|
332
|
-
// Default to empty string if no arguments
|
333
|
-
};
|
334
|
-
const queryParams = params.blockId ? { ...baseParams, blockId: params.blockId } : { ...baseParams, finality: params.finality || "final" };
|
335
|
-
return query(client, queryParams);
|
336
|
-
}
|
337
|
-
async function viewAccessKey(client, params) {
|
338
|
-
const queryParams = params.blockId ? {
|
339
|
-
requestType: "view_access_key",
|
340
|
-
accountId: params.accountId,
|
341
|
-
publicKey: params.publicKey,
|
342
|
-
blockId: params.blockId
|
343
|
-
} : {
|
344
|
-
requestType: "view_access_key",
|
345
|
-
accountId: params.accountId,
|
346
|
-
publicKey: params.publicKey,
|
347
|
-
finality: params.finality || "final"
|
348
|
-
};
|
349
|
-
return query(client, queryParams);
|
350
|
-
}
|
351
|
-
|
352
|
-
// src/validation.mini.ts
|
353
|
-
var import_mini = require("@near-js/jsonrpc-types/mini");
|
354
|
-
function enableValidation() {
|
355
|
-
const requestSchema = (0, import_mini.JsonRpcRequestSchema)();
|
356
|
-
const responseSchema = (0, import_mini.JsonRpcResponseSchema)();
|
357
|
-
return {
|
358
|
-
validateRequest: (request) => {
|
359
|
-
try {
|
360
|
-
requestSchema.parse(request);
|
361
|
-
} catch (error) {
|
362
|
-
throw new JsonRpcNetworkError(
|
363
|
-
`Invalid request format: ${error instanceof Error ? error.message : "Unknown error"}`,
|
364
|
-
error
|
365
|
-
);
|
366
|
-
}
|
367
|
-
},
|
368
|
-
validateResponse: (response) => {
|
369
|
-
try {
|
370
|
-
responseSchema.parse(response);
|
371
|
-
} catch (error) {
|
372
|
-
throw new JsonRpcClientError(
|
373
|
-
`Invalid response format: ${error instanceof Error ? error.message : "Unknown error"}`
|
374
|
-
);
|
375
|
-
}
|
376
|
-
}
|
377
|
-
};
|
378
|
-
}
|
379
|
-
// Annotate the CommonJS export names for ESM import in node:
|
380
|
-
0 && (module.exports = {
|
381
|
-
JsonRpcClientError,
|
382
|
-
JsonRpcNetworkError,
|
383
|
-
JsonRpcRequestSchema,
|
384
|
-
JsonRpcResponseSchema,
|
385
|
-
NearRpcClient,
|
386
|
-
NearRpcError,
|
387
|
-
RPC_METHODS,
|
388
|
-
block,
|
389
|
-
broadcastTxAsync,
|
390
|
-
broadcastTxCommit,
|
391
|
-
changes,
|
392
|
-
chunk,
|
393
|
-
clientConfig,
|
394
|
-
defaultClient,
|
395
|
-
enableValidation,
|
396
|
-
experimentalChanges,
|
397
|
-
experimentalChangesInBlock,
|
398
|
-
experimentalCongestionLevel,
|
399
|
-
experimentalGenesisConfig,
|
400
|
-
experimentalLightClientBlockProof,
|
401
|
-
experimentalLightClientProof,
|
402
|
-
experimentalMaintenanceWindows,
|
403
|
-
experimentalProtocolConfig,
|
404
|
-
experimentalReceipt,
|
405
|
-
experimentalSplitStorageInfo,
|
406
|
-
experimentalTxStatus,
|
407
|
-
experimentalValidatorsOrdered,
|
408
|
-
gasPrice,
|
409
|
-
health,
|
410
|
-
lightClientProof,
|
411
|
-
networkInfo,
|
412
|
-
nextLightClientBlock,
|
413
|
-
query,
|
414
|
-
sendTx,
|
415
|
-
status,
|
416
|
-
tx,
|
417
|
-
validators,
|
418
|
-
viewAccessKey,
|
419
|
-
viewAccount,
|
420
|
-
viewFunction
|
421
|
-
});
|