@galacticcouncil/common 0.1.2 → 0.1.3

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/build/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var K=Object.create;var p=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var L=Object.getPrototypeOf,M=Object.prototype.hasOwnProperty;var u=(t,r)=>{for(var e in r)p(t,e,{get:r[e],enumerable:!0})},k=(t,r,e,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of j(r))!M.call(t,o)&&o!==e&&p(t,o,{get:()=>r[o],enumerable:!(n=O(r,o))||n.enumerable});return t};var $=(t,r,e)=>(e=t!=null?K(L(t)):{},k(r||!t||!t.__esModule?p(e,"default",{value:t,enumerable:!0}):e,t)),G=t=>k(p({},"__esModule",{value:!0}),t);var et={};u(et,{HYDRATION_SS58_PREFIX:()=>m,RUNTIME_DECIMALS:()=>ot,big:()=>d,encodeAssetId:()=>I,encodeLocation:()=>E,enums:()=>y,erc20:()=>g,h160:()=>b,hex:()=>v,transform:()=>i,version:()=>tt,xc:()=>S,xcm:()=>w});module.exports=G(et);var ot=18,m=63;var d={};u(d,{asBigInt:()=>q,convertDecimals:()=>z,hasDecimalOverflow:()=>C,toBigInt:()=>F,toDecimal:()=>H});var f=$(require("big.js"));f.default.NE=-18;function H(t,r,e=6,n){let o=(0,f.default)(t.toString().replace(/[^0-9]/g,"")),l=(0,f.default)(10).pow(r);return o.div(l).round(e,n).toString()}function F(t,r){if(typeof t=="bigint")return t;let e=(0,f.default)(10).pow(r),n=(0,f.default)(t).mul(e);return BigInt(n.toFixed(0,f.default.roundDown))}function q(t){return BigInt(t.round(0,f.default.roundDown).toFixed(0))}function z(t,r,e){let n=H(t,r,r);return F(n.toString(),e)}function C(t,r){let e=t.toString().split(".");return e.length>1&&e[1].length>r}var y={};u(y,{enumPath:()=>W});function W(t){let r=[],e=t;for(;e&&typeof e=="object"&&"type"in e;)r.push(e.type),e=e.value;return r.join(".")}var g={};u(g,{ERC20:()=>x});var x=class{static fromAssetId(r){let e=Buffer.alloc(20,0);return e[15]=1,e.writeUInt32BE(r,16),"0x"+e.toString("hex")}static toAssetId(r){let e=Buffer.from(r.replace("0x",""),"hex");return e.length!==20||!this.isAssetAddress(r)?null:e.readUInt32BE(16)}static isAssetAddress(r){let e=Buffer.from("0000000000000000000000000000000100000000","hex"),n=Buffer.from(r.replace("0x",""),"hex");return n.length!==20?!1:n.subarray(0,16).equals(e.subarray(0,16))}};var b={};u(b,{H160:()=>A,isEvmAccount:()=>R,isEvmAddress:()=>N,isSs58Address:()=>P});var a=require("polkadot-api"),B=require("@polkadot-api/utils"),s=require("buffer");var h="ETH\0";function R(t){if(!t)return!1;try{let r=(0,a.AccountId)().enc(t),e=s.Buffer.from(h);return s.Buffer.from(r.subarray(0,e.length)).equals(e)}catch{return!1}}function N(t){return!!/^0x[a-fA-F0-9]{40}$/.test(t)}function P(t){try{return(0,a.AccountId)(63).enc(t),!0}catch{return!1}}var A=class t{static toAccount=r=>{let e=s.Buffer.from(r.slice(2),"hex"),n=s.Buffer.from(h),o=Uint8Array.from(s.Buffer.concat([n,e,s.Buffer.alloc(8)])),l=(0,B.toHex)(o);return(0,a.AccountId)(63).dec(l)};static fromAccount=r=>{let e=(0,a.AccountId)().enc(r),n=s.Buffer.from(h),o=e.slice(n.length,-8);return"0x"+s.Buffer.from(o).toString("hex")};static fromSS58=r=>{let n=(0,a.AccountId)().enc(r).slice(0,20);return(0,B.toHex)(n)};static fromAny=r=>{if(N(r))return r;if(R(r))return t.fromAccount(r);if(P(r))return t.fromSS58(r);throw new Error("Unknown address type")}};var v={};u(v,{assertHexLen:()=>V,ensureHexPrefix:()=>_,hexNormalize:()=>Q,isHex:()=>D,stripHexPrefix:()=>J});var Y=/^0x[0-9a-fA-F]*$/;function D(t,r=!1){return t==="0x"?!0:!Y.test(t)||!r&&t.length<4?!1:r||t.length%2===0}function J(t){return t.startsWith("0x")?t.slice(2):t}function _(t){return t.startsWith("0x")?t:`0x${t}`}function Q(t){return _(t.toLowerCase())}function V(t,r){if(!D(t)||t.length-2!==r*2)throw new Error(`Expected 0x hex of ${r} bytes`)}var w={};u(w,{encodeAssetId:()=>I,encodeLocation:()=>E,toAccountId32:()=>U,toAccountKey20:()=>T,transform:()=>i});var c=require("polkadot-api"),U=t=>{let r=(0,c.AccountId)().enc(t);return{type:"AccountId32",value:{network:void 0,id:c.FixedSizeBinary.fromBytes(r)}}},T=t=>({type:"AccountKey20",value:{network:void 0,key:c.FixedSizeBinary.fromHex(t)}}),i=t=>{if(Array.isArray(t))return t.map(i);if(typeof t=="object"&&t!==null){let r=Object.keys(t);if(r.length===1){let e=r[0],n=t[e];if(e==="AccountKey20"&&typeof n=="object"){let o=T(n.key);return n.network&&(o.value.network=i(n.network)),o}if(e==="AccountId32"&&typeof n=="object"){let o=U(n.id);return n.network&&(o.value.network=i(n.network)),o}return e==="GeneralKey"&&typeof n=="object"&&"data"in n?{type:e,value:{length:n.length,data:typeof n.data=="string"?c.Binary.fromHex(n.data):n.data}}:e==="GlobalConsensus"&&typeof n=="object"&&("Polkadot"in n||"Kusama"in n)?{type:e,value:n}:e==="Ethereum"?{type:e,value:{chain_id:BigInt("chainId"in n?n.chainId:n.chain_id)}}:e==="PalletInstance"?{type:e,value:n}:e==="GeneralIndex"?{type:e,value:BigInt(n)}:e==="X1"&&Array.isArray(n)?{type:e,value:n.length===1?i(n[0]):n.map(i)}:typeof n=="string"?{type:e,value:{type:n}}:typeof n=="number"?{type:e,value:n}:{type:e,value:i(n)}}else{let e={};for(let n of r){let o=t[n];e[n]=i(o)}return e}}else return t};function E(t){if(!t||typeof t!="object")return t;let{parents:r,interior:e}=t;return!e||e==="Here"?{parents:r,interior:{type:"Here"}}:{parents:r,interior:i(e)}}function I(t){if(typeof t=="number"||typeof t=="string"||typeof t=="bigint"||t==null)return t;if(typeof t=="object"&&!Array.isArray(t))return i(t)}var S={};u(S,{convertToId:()=>Z});var X=require("buffer");function Z(t){let e=X.Buffer.from(t.replace("0x",""),"hex").subarray(16);return e.readUIntBE(0,e.length)}var tt="0.1.0";0&&(module.exports={HYDRATION_SS58_PREFIX,RUNTIME_DECIMALS,big,encodeAssetId,encodeLocation,enums,erc20,h160,hex,transform,version,xc,xcm});
1
+ "use strict";var K=Object.create;var p=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var L=Object.getPrototypeOf,M=Object.prototype.hasOwnProperty;var u=(t,r)=>{for(var e in r)p(t,e,{get:r[e],enumerable:!0})},k=(t,r,e,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of j(r))!M.call(t,o)&&o!==e&&p(t,o,{get:()=>r[o],enumerable:!(n=O(r,o))||n.enumerable});return t};var $=(t,r,e)=>(e=t!=null?K(L(t)):{},k(r||!t||!t.__esModule?p(e,"default",{value:t,enumerable:!0}):e,t)),G=t=>k(p({},"__esModule",{value:!0}),t);var et={};u(et,{HYDRATION_SS58_PREFIX:()=>m,RUNTIME_DECIMALS:()=>ot,big:()=>y,encodeAssetId:()=>I,encodeLocation:()=>E,enums:()=>d,erc20:()=>g,h160:()=>b,hex:()=>v,transform:()=>i,version:()=>tt,xc:()=>S,xcm:()=>w});module.exports=G(et);var ot=18,m=63;var y={};u(y,{asBigInt:()=>q,convertDecimals:()=>z,hasDecimalOverflow:()=>C,toBigInt:()=>F,toDecimal:()=>H});var f=$(require("big.js"));f.default.NE=-18;function H(t,r,e=6,n){let o=(0,f.default)(t.toString().replace(/[^0-9]/g,"")),l=(0,f.default)(10).pow(r);return o.div(l).round(e,n).toString()}function F(t,r){if(typeof t=="bigint")return t;let e=(0,f.default)(10).pow(r),n=(0,f.default)(t).mul(e);return BigInt(n.toFixed(0,f.default.roundDown))}function q(t){return BigInt(t.round(0,f.default.roundDown).toFixed(0))}function z(t,r,e){let n=H(t,r,r);return F(n.toString(),e)}function C(t,r){let e=t.toString().split(".");return e.length>1&&e[1].length>r}var d={};u(d,{enumPath:()=>W});function W(t){let r=[],e=t;for(;e&&typeof e=="object"&&"type"in e;)r.push(e.type),e=e.value;return r.join(".")}var g={};u(g,{ERC20:()=>x});var x=class{static fromAssetId(r){let e=Buffer.alloc(20,0);return e[15]=1,e.writeUInt32BE(r,16),"0x"+e.toString("hex")}static toAssetId(r){let e=Buffer.from(r.replace("0x",""),"hex");return e.length!==20||!this.isAssetAddress(r)?null:e.readUInt32BE(16)}static isAssetAddress(r){let e=Buffer.from("0000000000000000000000000000000100000000","hex"),n=Buffer.from(r.replace("0x",""),"hex");return n.length!==20?!1:n.subarray(0,16).equals(e.subarray(0,16))}};var b={};u(b,{H160:()=>A,isEvmAccount:()=>R,isEvmAddress:()=>N,isSs58Address:()=>P});var a=require("polkadot-api"),B=require("@polkadot-api/utils"),s=require("buffer");var h="ETH\0";function R(t){if(!t)return!1;try{let r=(0,a.AccountId)().enc(t),e=s.Buffer.from(h);return s.Buffer.from(r.subarray(0,e.length)).equals(e)}catch{return!1}}function N(t){return!!/^0x[a-fA-F0-9]{40}$/.test(t)}function P(t){try{return(0,a.AccountId)(63).enc(t),!0}catch{return!1}}var A=class t{static toAccount=r=>{let e=s.Buffer.from(r.slice(2),"hex"),n=s.Buffer.from(h),o=Uint8Array.from(s.Buffer.concat([n,e,s.Buffer.alloc(8)])),l=(0,B.toHex)(o);return(0,a.AccountId)(63).dec(l)};static fromAccount=r=>{let e=(0,a.AccountId)().enc(r),n=s.Buffer.from(h),o=e.slice(n.length,-8);return"0x"+s.Buffer.from(o).toString("hex")};static fromSS58=r=>{let n=(0,a.AccountId)().enc(r).slice(0,20);return(0,B.toHex)(n)};static fromAny=r=>{if(N(r))return r;if(R(r))return t.fromAccount(r);if(P(r))return t.fromSS58(r);throw new Error("Unknown address type")}};var v={};u(v,{assertHexLen:()=>V,ensureHexPrefix:()=>_,hexNormalize:()=>Q,isHex:()=>D,stripHexPrefix:()=>J});var Y=/^0x[0-9a-fA-F]*$/;function D(t,r=!1){return t==="0x"?!0:!Y.test(t)||!r&&t.length<4?!1:r||t.length%2===0}function J(t){return t.startsWith("0x")?t.slice(2):t}function _(t){return t.startsWith("0x")?t:`0x${t}`}function Q(t){return _(t.toLowerCase())}function V(t,r){if(!D(t)||t.length-2!==r*2)throw new Error(`Expected 0x hex of ${r} bytes`)}var w={};u(w,{encodeAssetId:()=>I,encodeLocation:()=>E,toAccountId32:()=>U,toAccountKey20:()=>T,transform:()=>i});var c=require("polkadot-api"),U=t=>{let r=(0,c.AccountId)().enc(t);return{type:"AccountId32",value:{network:void 0,id:c.FixedSizeBinary.fromBytes(r)}}},T=t=>({type:"AccountKey20",value:{network:void 0,key:c.FixedSizeBinary.fromHex(t)}}),i=t=>{if(Array.isArray(t))return t.map(i);if(typeof t=="object"&&t!==null){let r=Object.keys(t);if(r.length===1){let e=r[0],n=t[e];if(e==="AccountKey20"&&typeof n=="object"){let o=T(n.key);return n.network&&(o.value.network=i(n.network)),o}if(e==="AccountId32"&&typeof n=="object"){let o=U(n.id);return n.network&&(o.value.network=i(n.network)),o}return e==="GeneralKey"&&typeof n=="object"&&"data"in n?{type:e,value:{length:n.length,data:typeof n.data=="string"?c.Binary.fromHex(n.data):n.data}}:e==="GlobalConsensus"&&typeof n=="object"&&("Polkadot"in n||"Kusama"in n)?{type:e,value:n}:e==="Ethereum"?{type:e,value:{chain_id:BigInt("chainId"in n?n.chainId:n.chain_id)}}:e==="PalletInstance"?{type:e,value:n}:e==="GeneralIndex"?{type:e,value:BigInt(n)}:e==="X1"&&Array.isArray(n)?{type:e,value:n.length===1?i(n[0]):n.map(i)}:typeof n=="string"?{type:e,value:{type:n}}:typeof n=="number"?{type:e,value:n}:{type:e,value:i(n)}}else{let e={};for(let n of r){let o=t[n];e[n]=i(o)}return e}}else return t};function E(t){if(!t||typeof t!="object")return t;let{parents:r,interior:e}=t;return!e||e==="Here"?{parents:r,interior:{type:"Here"}}:{parents:r,interior:i(e)}}function I(t){if(typeof t=="string")return BigInt(t);if(typeof t=="number"||typeof t=="bigint"||t==null)return t;if(typeof t=="object"&&!Array.isArray(t))return i(t)}var S={};u(S,{convertToId:()=>Z});var X=require("buffer");function Z(t){let e=X.Buffer.from(t.replace("0x",""),"hex").subarray(16);return e.readUIntBE(0,e.length)}var tt="0.1.0";0&&(module.exports={HYDRATION_SS58_PREFIX,RUNTIME_DECIMALS,big,encodeAssetId,encodeLocation,enums,erc20,h160,hex,transform,version,xc,xcm});
package/build/index.mjs CHANGED
@@ -1 +1 @@
1
- var U=Object.defineProperty;var u=(t,r)=>{for(var e in r)U(t,e,{get:r[e],enumerable:!0})};var J=18,p=63;var g={};u(g,{asBigInt:()=>T,convertDecimals:()=>X,hasDecimalOverflow:()=>K,toBigInt:()=>x,toDecimal:()=>y});import f from"big.js";f.NE=-18;function y(t,r,e=6,n){let o=f(t.toString().replace(/[^0-9]/g,"")),a=f(10).pow(r);return o.div(a).round(e,n).toString()}function x(t,r){if(typeof t=="bigint")return t;let e=f(10).pow(r),n=f(t).mul(e);return BigInt(n.toFixed(0,f.roundDown))}function T(t){return BigInt(t.round(0,f.roundDown).toFixed(0))}function X(t,r,e){let n=y(t,r,r);return x(n.toString(),e)}function K(t,r){let e=t.toString().split(".");return e.length>1&&e[1].length>r}var B={};u(B,{enumPath:()=>O});function O(t){let r=[],e=t;for(;e&&typeof e=="object"&&"type"in e;)r.push(e.type),e=e.value;return r.join(".")}var h={};u(h,{ERC20:()=>l});var l=class{static fromAssetId(r){let e=Buffer.alloc(20,0);return e[15]=1,e.writeUInt32BE(r,16),"0x"+e.toString("hex")}static toAssetId(r){let e=Buffer.from(r.replace("0x",""),"hex");return e.length!==20||!this.isAssetAddress(r)?null:e.readUInt32BE(16)}static isAssetAddress(r){let e=Buffer.from("0000000000000000000000000000000100000000","hex"),n=Buffer.from(r.replace("0x",""),"hex");return n.length!==20?!1:n.subarray(0,16).equals(e.subarray(0,16))}};var I={};u(I,{H160:()=>d,isEvmAccount:()=>b,isEvmAddress:()=>v,isSs58Address:()=>E});import{AccountId as c}from"polkadot-api";import{toHex as A}from"@polkadot-api/utils";import{Buffer as s}from"buffer";var m="ETH\0";function b(t){if(!t)return!1;try{let r=c().enc(t),e=s.from(m);return s.from(r.subarray(0,e.length)).equals(e)}catch{return!1}}function v(t){return!!/^0x[a-fA-F0-9]{40}$/.test(t)}function E(t){try{return c(63).enc(t),!0}catch{return!1}}var d=class t{static toAccount=r=>{let e=s.from(r.slice(2),"hex"),n=s.from(m),o=Uint8Array.from(s.concat([n,e,s.alloc(8)])),a=A(o);return c(63).dec(a)};static fromAccount=r=>{let e=c().enc(r),n=s.from(m),o=e.slice(n.length,-8);return"0x"+s.from(o).toString("hex")};static fromSS58=r=>{let n=c().enc(r).slice(0,20);return A(n)};static fromAny=r=>{if(v(r))return r;if(b(r))return t.fromAccount(r);if(E(r))return t.fromSS58(r);throw new Error("Unknown address type")}};var k={};u(k,{assertHexLen:()=>$,ensureHexPrefix:()=>S,hexNormalize:()=>M,isHex:()=>w,stripHexPrefix:()=>L});var j=/^0x[0-9a-fA-F]*$/;function w(t,r=!1){return t==="0x"?!0:!j.test(t)||!r&&t.length<4?!1:r||t.length%2===0}function L(t){return t.startsWith("0x")?t.slice(2):t}function S(t){return t.startsWith("0x")?t:`0x${t}`}function M(t){return S(t.toLowerCase())}function $(t,r){if(!w(t)||t.length-2!==r*2)throw new Error(`Expected 0x hex of ${r} bytes`)}var D={};u(D,{encodeAssetId:()=>P,encodeLocation:()=>N,toAccountId32:()=>F,toAccountKey20:()=>R,transform:()=>i});import{AccountId as G,Binary as q,FixedSizeBinary as H}from"polkadot-api";var F=t=>{let r=G().enc(t);return{type:"AccountId32",value:{network:void 0,id:H.fromBytes(r)}}},R=t=>({type:"AccountKey20",value:{network:void 0,key:H.fromHex(t)}}),i=t=>{if(Array.isArray(t))return t.map(i);if(typeof t=="object"&&t!==null){let r=Object.keys(t);if(r.length===1){let e=r[0],n=t[e];if(e==="AccountKey20"&&typeof n=="object"){let o=R(n.key);return n.network&&(o.value.network=i(n.network)),o}if(e==="AccountId32"&&typeof n=="object"){let o=F(n.id);return n.network&&(o.value.network=i(n.network)),o}return e==="GeneralKey"&&typeof n=="object"&&"data"in n?{type:e,value:{length:n.length,data:typeof n.data=="string"?q.fromHex(n.data):n.data}}:e==="GlobalConsensus"&&typeof n=="object"&&("Polkadot"in n||"Kusama"in n)?{type:e,value:n}:e==="Ethereum"?{type:e,value:{chain_id:BigInt("chainId"in n?n.chainId:n.chain_id)}}:e==="PalletInstance"?{type:e,value:n}:e==="GeneralIndex"?{type:e,value:BigInt(n)}:e==="X1"&&Array.isArray(n)?{type:e,value:n.length===1?i(n[0]):n.map(i)}:typeof n=="string"?{type:e,value:{type:n}}:typeof n=="number"?{type:e,value:n}:{type:e,value:i(n)}}else{let e={};for(let n of r){let o=t[n];e[n]=i(o)}return e}}else return t};function N(t){if(!t||typeof t!="object")return t;let{parents:r,interior:e}=t;return!e||e==="Here"?{parents:r,interior:{type:"Here"}}:{parents:r,interior:i(e)}}function P(t){if(typeof t=="number"||typeof t=="string"||typeof t=="bigint"||t==null)return t;if(typeof t=="object"&&!Array.isArray(t))return i(t)}var _={};u(_,{convertToId:()=>C});import{Buffer as z}from"buffer";function C(t){let e=z.from(t.replace("0x",""),"hex").subarray(16);return e.readUIntBE(0,e.length)}var ft="0.1.0";export{p as HYDRATION_SS58_PREFIX,J as RUNTIME_DECIMALS,g as big,P as encodeAssetId,N as encodeLocation,B as enums,h as erc20,I as h160,k as hex,i as transform,ft as version,_ as xc,D as xcm};
1
+ var U=Object.defineProperty;var u=(t,r)=>{for(var e in r)U(t,e,{get:r[e],enumerable:!0})};var J=18,p=63;var g={};u(g,{asBigInt:()=>T,convertDecimals:()=>X,hasDecimalOverflow:()=>K,toBigInt:()=>x,toDecimal:()=>d});import f from"big.js";f.NE=-18;function d(t,r,e=6,n){let o=f(t.toString().replace(/[^0-9]/g,"")),a=f(10).pow(r);return o.div(a).round(e,n).toString()}function x(t,r){if(typeof t=="bigint")return t;let e=f(10).pow(r),n=f(t).mul(e);return BigInt(n.toFixed(0,f.roundDown))}function T(t){return BigInt(t.round(0,f.roundDown).toFixed(0))}function X(t,r,e){let n=d(t,r,r);return x(n.toString(),e)}function K(t,r){let e=t.toString().split(".");return e.length>1&&e[1].length>r}var B={};u(B,{enumPath:()=>O});function O(t){let r=[],e=t;for(;e&&typeof e=="object"&&"type"in e;)r.push(e.type),e=e.value;return r.join(".")}var h={};u(h,{ERC20:()=>l});var l=class{static fromAssetId(r){let e=Buffer.alloc(20,0);return e[15]=1,e.writeUInt32BE(r,16),"0x"+e.toString("hex")}static toAssetId(r){let e=Buffer.from(r.replace("0x",""),"hex");return e.length!==20||!this.isAssetAddress(r)?null:e.readUInt32BE(16)}static isAssetAddress(r){let e=Buffer.from("0000000000000000000000000000000100000000","hex"),n=Buffer.from(r.replace("0x",""),"hex");return n.length!==20?!1:n.subarray(0,16).equals(e.subarray(0,16))}};var I={};u(I,{H160:()=>y,isEvmAccount:()=>b,isEvmAddress:()=>v,isSs58Address:()=>E});import{AccountId as c}from"polkadot-api";import{toHex as A}from"@polkadot-api/utils";import{Buffer as s}from"buffer";var m="ETH\0";function b(t){if(!t)return!1;try{let r=c().enc(t),e=s.from(m);return s.from(r.subarray(0,e.length)).equals(e)}catch{return!1}}function v(t){return!!/^0x[a-fA-F0-9]{40}$/.test(t)}function E(t){try{return c(63).enc(t),!0}catch{return!1}}var y=class t{static toAccount=r=>{let e=s.from(r.slice(2),"hex"),n=s.from(m),o=Uint8Array.from(s.concat([n,e,s.alloc(8)])),a=A(o);return c(63).dec(a)};static fromAccount=r=>{let e=c().enc(r),n=s.from(m),o=e.slice(n.length,-8);return"0x"+s.from(o).toString("hex")};static fromSS58=r=>{let n=c().enc(r).slice(0,20);return A(n)};static fromAny=r=>{if(v(r))return r;if(b(r))return t.fromAccount(r);if(E(r))return t.fromSS58(r);throw new Error("Unknown address type")}};var k={};u(k,{assertHexLen:()=>$,ensureHexPrefix:()=>S,hexNormalize:()=>M,isHex:()=>w,stripHexPrefix:()=>L});var j=/^0x[0-9a-fA-F]*$/;function w(t,r=!1){return t==="0x"?!0:!j.test(t)||!r&&t.length<4?!1:r||t.length%2===0}function L(t){return t.startsWith("0x")?t.slice(2):t}function S(t){return t.startsWith("0x")?t:`0x${t}`}function M(t){return S(t.toLowerCase())}function $(t,r){if(!w(t)||t.length-2!==r*2)throw new Error(`Expected 0x hex of ${r} bytes`)}var D={};u(D,{encodeAssetId:()=>P,encodeLocation:()=>N,toAccountId32:()=>F,toAccountKey20:()=>R,transform:()=>i});import{AccountId as G,Binary as q,FixedSizeBinary as H}from"polkadot-api";var F=t=>{let r=G().enc(t);return{type:"AccountId32",value:{network:void 0,id:H.fromBytes(r)}}},R=t=>({type:"AccountKey20",value:{network:void 0,key:H.fromHex(t)}}),i=t=>{if(Array.isArray(t))return t.map(i);if(typeof t=="object"&&t!==null){let r=Object.keys(t);if(r.length===1){let e=r[0],n=t[e];if(e==="AccountKey20"&&typeof n=="object"){let o=R(n.key);return n.network&&(o.value.network=i(n.network)),o}if(e==="AccountId32"&&typeof n=="object"){let o=F(n.id);return n.network&&(o.value.network=i(n.network)),o}return e==="GeneralKey"&&typeof n=="object"&&"data"in n?{type:e,value:{length:n.length,data:typeof n.data=="string"?q.fromHex(n.data):n.data}}:e==="GlobalConsensus"&&typeof n=="object"&&("Polkadot"in n||"Kusama"in n)?{type:e,value:n}:e==="Ethereum"?{type:e,value:{chain_id:BigInt("chainId"in n?n.chainId:n.chain_id)}}:e==="PalletInstance"?{type:e,value:n}:e==="GeneralIndex"?{type:e,value:BigInt(n)}:e==="X1"&&Array.isArray(n)?{type:e,value:n.length===1?i(n[0]):n.map(i)}:typeof n=="string"?{type:e,value:{type:n}}:typeof n=="number"?{type:e,value:n}:{type:e,value:i(n)}}else{let e={};for(let n of r){let o=t[n];e[n]=i(o)}return e}}else return t};function N(t){if(!t||typeof t!="object")return t;let{parents:r,interior:e}=t;return!e||e==="Here"?{parents:r,interior:{type:"Here"}}:{parents:r,interior:i(e)}}function P(t){if(typeof t=="string")return BigInt(t);if(typeof t=="number"||typeof t=="bigint"||t==null)return t;if(typeof t=="object"&&!Array.isArray(t))return i(t)}var _={};u(_,{convertToId:()=>C});import{Buffer as z}from"buffer";function C(t){let e=z.from(t.replace("0x",""),"hex").subarray(16);return e.readUIntBE(0,e.length)}var ft="0.1.0";export{p as HYDRATION_SS58_PREFIX,J as RUNTIME_DECIMALS,g as big,P as encodeAssetId,N as encodeLocation,B as enums,h as erc20,I as h160,k as hex,i as transform,ft as version,_ as xc,D as xcm};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@galacticcouncil/common",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Common utilities shared across Galactic SDK packages",
5
5
  "author": "GalacticCouncil",
6
6
  "repository": {