@swapkit/wallet-keystore 1.0.0-rc.3 → 1.0.0-rc.7

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.
@@ -0,0 +1,4 @@
1
+ const e = {};
2
+ export {
3
+ e as default
4
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e={};exports.default=e;
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var Ie=Object.create;var W=Object.defineProperty;var _e=Object.getOwnPropertyDescriptor;var we=Object.getOwnPropertyNames;var Ae=Object.getPrototypeOf,Se=Object.prototype.hasOwnProperty;var ve=(e,r,t,a)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of we(r))!Se.call(e,o)&&o!==t&&W(e,o,{get:()=>r[o],enumerable:!(a=_e(r,o))||a.enumerable});return e};var D=(e,r,t)=>(t=e!=null?Ie(Ae(e)):{},ve(r||!e||!e.__esModule?W(t,"default",{value:e,enumerable:!0}):t,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const $=require("@scure/bip39"),X=`abandon
1
+ "use strict";var ye=Object.create;var W=Object.defineProperty;var Ee=Object.getOwnPropertyDescriptor;var Ie=Object.getOwnPropertyNames;var we=Object.getPrototypeOf,_e=Object.prototype.hasOwnProperty;var Ae=(e,r,t,a)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of Ie(r))!_e.call(e,o)&&o!==t&&W(e,o,{get:()=>r[o],enumerable:!(a=Ee(r,o))||a.enumerable});return e};var k=(e,r,t)=>(t=e!=null?ye(we(e)):{},Ae(r||!e||!e.__esModule?W(t,"default",{value:e,enumerable:!0}):t,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Se=require("@scure/bip39"),ve=`abandon
2
2
  ability
3
3
  able
4
4
  about
@@ -2046,6 +2046,6 @@ zebra
2046
2046
  zero
2047
2047
  zone
2048
2048
  zoo`.split(`
2049
- `),Re="Input must be an string, Buffer or Uint8Array";function Ne(e){let r;if(e instanceof Uint8Array)r=e;else if(typeof e=="string")r=new TextEncoder().encode(e);else throw new Error(Re);return r}function Te(e){return Array.prototype.map.call(e,function(r){return(r<16?"0":"")+r.toString(16)}).join("")}function P(e){return(4294967296+e).toString(16).substring(1)}function ke(e,r,t){let a=`
2050
- `+e+" = ";for(let o=0;o<r.length;o+=2){if(t===32)a+=P(r[o]).toUpperCase(),a+=" ",a+=P(r[o+1]).toUpperCase();else if(t===64)a+=P(r[o+1]).toUpperCase(),a+=P(r[o]).toUpperCase();else throw new Error("Invalid size "+t);o%6===4?a+=`
2051
- `+new Array(e.length+4).join(" "):o<r.length-2&&(a+=" ")}console.log(a)}function De(e,r,t){let a=new Date().getTime();const o=new Uint8Array(r);for(let d=0;d<r;d++)o[d]=d%256;const l=new Date().getTime();console.log("Generated random input in "+(l-a)+"ms"),a=l;for(let d=0;d<t;d++){const I=e(o),_=new Date().getTime(),S=_-a;a=_,console.log("Hashed in "+S+"ms: "+I.substring(0,20)+"..."),console.log(Math.round(r/(1<<20)/(S/1e3)*100)/100+" MB PER SECOND")}}var ee={normalizeInput:Ne,toHex:Te,debugPrint:ke,testSpeed:De};const V=ee;function M(e,r,t){const a=e[r]+e[t];let o=e[r+1]+e[t+1];a>=4294967296&&o++,e[r]=a,e[r+1]=o}function Q(e,r,t,a){let o=e[r]+t;t<0&&(o+=4294967296);let l=e[r+1]+a;o>=4294967296&&l++,e[r]=o,e[r+1]=l}function te(e,r){return e[r]^e[r+1]<<8^e[r+2]<<16^e[r+3]<<24}function N(e,r,t,a,o,l){const d=B[o],I=B[o+1],_=B[l],S=B[l+1];M(i,e,r),Q(i,e,d,I);let u=i[a]^i[e],s=i[a+1]^i[e+1];i[a]=s,i[a+1]=u,M(i,t,a),u=i[r]^i[t],s=i[r+1]^i[t+1],i[r]=u>>>24^s<<8,i[r+1]=s>>>24^u<<8,M(i,e,r),Q(i,e,_,S),u=i[a]^i[e],s=i[a+1]^i[e+1],i[a]=u>>>16^s<<16,i[a+1]=s>>>16^u<<16,M(i,t,a),u=i[r]^i[t],s=i[r+1]^i[t+1],i[r]=s>>>31^u<<1,i[r+1]=u>>>31^s<<1}const re=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),Oe=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3],y=new Uint8Array(Oe.map(function(e){return e*2})),i=new Uint32Array(32),B=new Uint32Array(32);function ae(e,r){let t=0;for(t=0;t<16;t++)i[t]=e.h[t],i[t+16]=re[t];for(i[24]=i[24]^e.t,i[25]=i[25]^e.t/4294967296,r&&(i[28]=~i[28],i[29]=~i[29]),t=0;t<32;t++)B[t]=te(e.b,4*t);for(t=0;t<12;t++)N(0,8,16,24,y[t*16+0],y[t*16+1]),N(2,10,18,26,y[t*16+2],y[t*16+3]),N(4,12,20,28,y[t*16+4],y[t*16+5]),N(6,14,22,30,y[t*16+6],y[t*16+7]),N(0,10,20,30,y[t*16+8],y[t*16+9]),N(2,12,22,24,y[t*16+10],y[t*16+11]),N(4,14,16,26,y[t*16+12],y[t*16+13]),N(6,8,18,28,y[t*16+14],y[t*16+15]);for(t=0;t<16;t++)e.h[t]=e.h[t]^i[t]^i[t+16]}const T=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]);function oe(e,r,t,a){if(e===0||e>64)throw new Error("Illegal output length, expected 0 < length <= 64");if(r&&r.length>64)throw new Error("Illegal key, expected Uint8Array with 0 < length <= 64");if(t&&t.length!==16)throw new Error("Illegal salt, expected Uint8Array with length is 16");if(a&&a.length!==16)throw new Error("Illegal personal, expected Uint8Array with length is 16");const o={b:new Uint8Array(128),h:new Uint32Array(16),t:0,c:0,outlen:e};T.fill(0),T[0]=e,r&&(T[1]=r.length),T[2]=1,T[3]=1,t&&T.set(t,32),a&&T.set(a,48);for(let l=0;l<16;l++)o.h[l]=re[l]^te(T,l*4);return r&&(j(o,r),o.c=128),o}function j(e,r){for(let t=0;t<r.length;t++)e.c===128&&(e.t+=e.c,ae(e,!1),e.c=0),e.b[e.c++]=r[t]}function ne(e){for(e.t+=e.c;e.c<128;)e.b[e.c++]=0;ae(e,!0);const r=new Uint8Array(e.outlen);for(let t=0;t<e.outlen;t++)r[t]=e.h[t>>2]>>8*(t&3);return r}function ie(e,r,t,a,o){t=t||64,e=V.normalizeInput(e),a&&(a=V.normalizeInput(a)),o&&(o=V.normalizeInput(o));const l=oe(t,r,a,o);return j(l,e),ne(l)}function Ue(e,r,t,a,o){const l=ie(e,r,t,a,o);return V.toHex(l)}var Ce={blake2b:ie,blake2bHex:Ue,blake2bInit:oe,blake2bUpdate:j,blake2bFinal:ne};const se=ee;function xe(e,r){return e[r]^e[r+1]<<8^e[r+2]<<16^e[r+3]<<24}function k(e,r,t,a,o,l){c[e]=c[e]+c[r]+o,c[a]=L(c[a]^c[e],16),c[t]=c[t]+c[a],c[r]=L(c[r]^c[t],12),c[e]=c[e]+c[r]+l,c[a]=L(c[a]^c[e],8),c[t]=c[t]+c[a],c[r]=L(c[r]^c[t],7)}function L(e,r){return e>>>r^e<<32-r}const le=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),E=new Uint8Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0]),c=new Uint32Array(16),f=new Uint32Array(16);function ce(e,r){let t=0;for(t=0;t<8;t++)c[t]=e.h[t],c[t+8]=le[t];for(c[12]^=e.t,c[13]^=e.t/4294967296,r&&(c[14]=~c[14]),t=0;t<16;t++)f[t]=xe(e.b,4*t);for(t=0;t<10;t++)k(0,4,8,12,f[E[t*16+0]],f[E[t*16+1]]),k(1,5,9,13,f[E[t*16+2]],f[E[t*16+3]]),k(2,6,10,14,f[E[t*16+4]],f[E[t*16+5]]),k(3,7,11,15,f[E[t*16+6]],f[E[t*16+7]]),k(0,5,10,15,f[E[t*16+8]],f[E[t*16+9]]),k(1,6,11,12,f[E[t*16+10]],f[E[t*16+11]]),k(2,7,8,13,f[E[t*16+12]],f[E[t*16+13]]),k(3,4,9,14,f[E[t*16+14]],f[E[t*16+15]]);for(t=0;t<8;t++)e.h[t]^=c[t]^c[t+8]}function ue(e,r){if(!(e>0&&e<=32))throw new Error("Incorrect output length, should be in [1, 32]");const t=r?r.length:0;if(r&&!(t>0&&t<=32))throw new Error("Incorrect key length, should be in [1, 32]");const a={h:new Uint32Array(le),b:new Uint8Array(64),c:0,t:0,outlen:e};return a.h[0]^=16842752^t<<8^e,t>0&&(z(a,r),a.c=64),a}function z(e,r){for(let t=0;t<r.length;t++)e.c===64&&(e.t+=e.c,ce(e,!1),e.c=0),e.b[e.c++]=r[t]}function de(e){for(e.t+=e.c;e.c<64;)e.b[e.c++]=0;ce(e,!0);const r=new Uint8Array(e.outlen);for(let t=0;t<e.outlen;t++)r[t]=e.h[t>>2]>>8*(t&3)&255;return r}function pe(e,r,t){t=t||32,e=se.normalizeInput(e);const a=ue(t,r);return z(a,e),de(a)}function Be(e,r,t){const a=pe(e,r,t);return se.toHex(a)}var Pe={blake2s:pe,blake2sHex:Be,blake2sInit:ue,blake2sUpdate:z,blake2sFinal:de};const C=Ce,x=Pe;var F={blake2b:C.blake2b,blake2bHex:C.blake2bHex,blake2bInit:C.blake2bInit,blake2bUpdate:C.blake2bUpdate,blake2bFinal:C.blake2bFinal,blake2s:x.blake2s,blake2sHex:x.blake2sHex,blake2sInit:x.blake2sInit,blake2sUpdate:x.blake2sUpdate,blake2sFinal:x.blake2sFinal};const O={};let H;const Me=new Uint8Array(16);function Le(){if(!H&&(H=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!H))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return H(Me)}const b=[];for(let e=0;e<256;++e)b.push((e+256).toString(16).slice(1));function He(e,r=0){return(b[e[r+0]]+b[e[r+1]]+b[e[r+2]]+b[e[r+3]]+"-"+b[e[r+4]]+b[e[r+5]]+"-"+b[e[r+6]]+b[e[r+7]]+"-"+b[e[r+8]]+b[e[r+9]]+"-"+b[e[r+10]]+b[e[r+11]]+b[e[r+12]]+b[e[r+13]]+b[e[r+14]]+b[e[r+15]]).toLowerCase()}const Ve=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),J={randomUUID:Ve};function Ge(e,r,t){if(J.randomUUID&&!r&&!e)return J.randomUUID();e=e||{};const a=e.random||(e.rng||Le)();if(a[6]=a[6]&15|64,a[8]=a[8]&63|128,r){t=t||0;for(let o=0;o<16;++o)r[t+o]=a[o];return r}return He(a)}const Z="aes-128-ctr",Fe="pbkdf2",je="hmac-sha256",ze=32,qe=262144,me="sha256",Ke="xchain-keystore",Ye=e=>e<16?`0${e.toString(16)}`:e.toString(16),We=e=>Array.from(e).map(Ye).join(""),q=e=>{e instanceof Buffer||(e=Buffer.from(e,"hex"));const r=F.blake2bInit(32);return F.blake2bUpdate(r,e),We(F.blake2bFinal(r))},he=async(e,r,t,a,o)=>new Promise((l,d)=>{O.pbkdf2(e,r,t,a,o,(I,_)=>{I?d(I):l(_)})}),ge=()=>typeof window>"u",$e=async(e,r)=>{const t=ge()?require("uuid").v4():Ge(),a=O.randomBytes(32),o=O.randomBytes(16),l={prf:je,dklen:ze,salt:a.toString("hex"),c:qe},d={iv:o.toString("hex")},I=await he(Buffer.from(r),a,l.c,l.dklen,me),_=O.createCipheriv(Z,I.slice(0,16),o),S=Buffer.concat([_.update(Buffer.from(e,"utf8")),_.final()]),u=q(Buffer.concat([I.slice(16,32),Buffer.from(S)]));return{crypto:{cipher:Z,ciphertext:S.toString("hex"),cipherparams:d,kdf:Fe,kdfparams:l,mac:u},id:t,version:1,meta:Ke}},Xe=(e=12)=>{const r=e===12?128:256;return ge()?$.entropyToMnemonic(O.randomBytes(r/8),X):$.generateMnemonic(X,r)},Qe=async(e,r)=>{const t=e.crypto.kdfparams,a=await he(Buffer.from(r),Buffer.from(t.salt,"hex"),t.c,t.dklen,me),o=Buffer.from(e.crypto.ciphertext,"hex");if(q(Buffer.concat([a.slice(16,32),o]))!==e.crypto.mac)throw new Error("Invalid password");const d=O.createDecipheriv(e.crypto.cipher,a.slice(0,16),Buffer.from(e.crypto.cipherparams.iv,"hex"));return Buffer.concat([d.update(o),d.final()]).toString("utf8")};var n=(e=>(e.INVALID_INPUT_PARAMETERS="1000",e.UNKNOWN_PROVIDERS="1001",e.CANNOT_FIND_INBOUND_ADDRESS="1002",e.NO_INBOUND_ADDRESSES="1003",e.CHAIN_HALTED_OR_UNSUPPORTED="1004",e.MISSING_INPUT_PARAMETER="1005",e.INVALID_TYPE_GENERIC="1100",e.INVALID_NUMBER_STRING="1101",e.INVALID_NUMBER="1102",e.INVALID_BOOLEAN="1103",e.INVALID_OBJECT="1104",e.INVALID_ARRAY="1105",e.SELL_AMOUNT_MUST_BE_POSITIVE_INTEGER="2000",e.SELL_BUY_ASSETS_ARE_THE_SAME="2001",e.MISSING_SOURCE_ADDRESS_FOR_SYNTH="2002",e.AFF_ADDRESS_AND_BPS_OR_NEITHER="2003",e.AFF_ADDRESS_TOO_LONG="2004",e.AFF_BPS_INTEGER_0_100="2005",e.SOURCE_ADDRESS_INVALID_FOR_SELL_CHAIN="2006",e.DESTINATION_ADDRESS_INVALID_FOR_BUY_CHAIN="2007",e.PREFERRED_PROFVIDER_NOT_SUPPORTED="2008",e.DESTINATION_ADDRESS_SMART_CONTRACT="2009",e.BUY_AMOUNT_MUST_BE_POSITIVE_INTEGER="2010",e.SOURCE_ADDRESS_SMART_CONTRACT="2011",e.INVALID_PROVIDER="2100",e.MISSING_CROSS_CHAIN_PROVIDER="2101",e.MISSING_AVAX_PROVIDER="2102",e.MISSING_BSC_PROVIDER="2103",e.MISSING_ETH_PROVIDER="2104",e.INVALID_PROVIDER_FOR_SWAP_OUT="2105",e.MISSING_ARB_PROVIDER="2106",e.INVALID_CHAIN="2200",e.INVALID_ASSET="2201",e.INVALID_ASSET_IDENTIFIER="2202",e.UNSUPPORTED_CHAIN="2204",e.UNSUPPORTED_ASSET="2203",e.UNSUPPORTED_ASSET_FOR_SWAPOUT="2205",e.INVALID_SOURCE_ADDRESS="2300",e.INVALID_DESTINATION_ADDRESS="2301",e.THORNODE_QUOTE_GENERIC_ERROR="3000",e.NOT_ENOUGH_SYNTH_BALANCE="3001",e.SYNTH_MINTING_CAP_REACHED="3002",e.INVALID_QUOTE_MODE="4000",e.NO_QUOTES="4001",e.SERVICE_UNAVAILABLE_GENERIC="5000",e.MISSING_GAS_DATA_GENERIC="5100",e.MISSING_TOKEN_INFO_GENERIC="5200",e.CANT_FIND_TOKEN_LIST="5201",e.NO_PRICE="5202",e.PRICE_IS_STALE="5203",e.ADDRESS_NOT_WHITELISTED="6000",e.ADDRESS_ALREADY_CLAIMED="6001",e.TEMPORARY_ERROR="9999",e))(n||{});n.INVALID_INPUT_PARAMETERS+"",n.UNKNOWN_PROVIDERS+"",n.CANNOT_FIND_INBOUND_ADDRESS+"",n.NO_INBOUND_ADDRESSES+"",n.CHAIN_HALTED_OR_UNSUPPORTED+"",n.MISSING_INPUT_PARAMETER+"",n.INVALID_TYPE_GENERIC+"",n.INVALID_NUMBER_STRING+"",n.INVALID_NUMBER+"",n.INVALID_BOOLEAN+"",n.INVALID_OBJECT+"",n.INVALID_ARRAY+"",n.SELL_AMOUNT_MUST_BE_POSITIVE_INTEGER+"",n.SELL_BUY_ASSETS_ARE_THE_SAME+"",n.MISSING_SOURCE_ADDRESS_FOR_SYNTH+"",n.AFF_ADDRESS_AND_BPS_OR_NEITHER+"",n.AFF_ADDRESS_TOO_LONG+"",n.AFF_BPS_INTEGER_0_100+"",n.SOURCE_ADDRESS_INVALID_FOR_SELL_CHAIN+"",n.DESTINATION_ADDRESS_INVALID_FOR_BUY_CHAIN+"",n.PREFERRED_PROFVIDER_NOT_SUPPORTED+"",n.DESTINATION_ADDRESS_SMART_CONTRACT+"",n.BUY_AMOUNT_MUST_BE_POSITIVE_INTEGER+"",n.INVALID_PROVIDER+"",n.MISSING_CROSS_CHAIN_PROVIDER+"",n.MISSING_AVAX_PROVIDER+"",n.MISSING_BSC_PROVIDER+"",n.MISSING_ETH_PROVIDER+"",n.MISSING_ARB_PROVIDER+"",n.INVALID_PROVIDER_FOR_SWAP_OUT+"",n.INVALID_CHAIN+"",n.INVALID_ASSET+"",n.UNSUPPORTED_CHAIN+"",n.UNSUPPORTED_ASSET+"",n.UNSUPPORTED_ASSET_FOR_SWAPOUT+"",n.THORNODE_QUOTE_GENERIC_ERROR+"",n.INVALID_SOURCE_ADDRESS+"",n.INVALID_DESTINATION_ADDRESS+"",n.NOT_ENOUGH_SYNTH_BALANCE+"",n.SYNTH_MINTING_CAP_REACHED+"",n.INVALID_QUOTE_MODE+"",n.NO_QUOTES+"",n.SERVICE_UNAVAILABLE_GENERIC+"",n.MISSING_GAS_DATA_GENERIC+"",n.MISSING_TOKEN_INFO_GENERIC+"",n.CANT_FIND_TOKEN_LIST+"",n.NO_PRICE+"",n.PRICE_IS_STALE+"",n.ADDRESS_NOT_WHITELISTED+"",n.ADDRESS_ALREADY_CLAIMED+"";var m=(e=>(e.Arbitrum="ARB",e.Avalanche="AVAX",e.Binance="BNB",e.BinanceSmartChain="BSC",e.Bitcoin="BTC",e.BitcoinCash="BCH",e.Cosmos="GAIA",e.Dogecoin="DOGE",e.Ethereum="ETH",e.Litecoin="LTC",e.Maya="MAYA",e.Optimism="OP",e.Polygon="MATIC",e.THORChain="THOR",e))(m||{}),fe=(e=>(e.ARB="m/44'/60'/0'/0",e.AVAX="m/44'/60'/0'/0",e.BCH="m/44'/145'/0'/0",e.BNB="m/44'/714'/0'/0",e.BSC="m/44'/60'/0'/0",e.BTC="m/84'/0'/0'/0",e.DOGE="m/44'/3'/0'/0",e.ETH="m/44'/60'/0'/0",e.GAIA="m/44'/118'/0'/0",e.LTC="m/84'/2'/0'/0",e.MATIC="m/44'/60'/0'/0",e.MAYA="m/44'/931'/0'/0",e.OP="m/44'/60'/0'/0",e.THOR="m/44'/931'/0'/0",e))(fe||{}),K=(e=>(e.Arbitrum="42161",e.ArbitrumHex="0xa4b1",e.Avalanche="43114",e.AvalancheHex="0xa86a",e.Binance="Binance-Chain-Tigris",e.BinanceSmartChain="56",e.BinanceSmartChainHex="0x38",e.Bitcoin="bitcoin",e.BitcoinCash="bitcoincash",e.Cosmos="cosmoshub-4",e.Dogecoin="dogecoin",e.Ethereum="1",e.EthereumHex="0x1",e.Litecoin="litecoin",e.Maya="mayachain-mainnet-v1",e.MayaStagenet="mayachain-stagenet-v1",e.Optimism="10",e.OptimismHex="0xa",e.Polygon="137",e.PolygonHex="0x89",e.THORChain="thorchain-mainnet-v1",e.THORChainStagenet="thorchain-stagenet-v2",e))(K||{}),be=(e=>(e.Arbitrum="https://arb1.arbitrum.io/rpc",e.Avalanche="https://node-router.thorswap.net/avalanche-c",e.Binance="",e.BinanceSmartChain="https://bsc-dataseed.binance.org",e.Bitcoin="https://node-router.thorswap.net/bitcoin",e.BitcoinCash="https://node-router.thorswap.net/bitcoin-cash",e.Cosmos="https://node-router.thorswap.net/cosmos/rpc",e.Dogecoin="https://node-router.thorswap.net/dogecoin",e.Ethereum="https://node-router.thorswap.net/ethereum",e.Litecoin="https://node-router.thorswap.net/litecoin",e.Maya="https://tendermint.mayachain.info",e.MayaStagenet="https://stagenet.tendermint.mayachain.info",e.Optimism="https://mainnet.optimism.io",e.Polygon="https://polygon-rpc.com",e.THORChain="https://rpc.thorswap.net",e.THORChainStagenet="https://stagenet-rpc.ninerealms.com",e))(be||{});const G=Object.values(m),Je=Object.keys(m),Y=G.reduce((e,r)=>{const t=Je.find(a=>m[a]===r);return t&&(e[r]=t),e},{});G.reduce((e,r)=>(e[r]=K[Y[r]],e),{});G.reduce((e,r)=>(e[r]=be[Y[r]],e),{});G.reduce((e,r)=>{const t=`${Y[r]}Hex`;return e[r]=K[t],e},{});var ye=(e=>(e.KEYSTORE="KEYSTORE",e.XDEFI="XDEFI",e.METAMASK="METAMASK",e.COINBASE_WEB="COINBASE_WEB",e.TREZOR="TREZOR",e.TRUSTWALLET_WEB="TRUSTWALLET_WEB",e.LEDGER="LEDGER",e.KEPLR="KEPLR",e.OKX="OKX",e.BRAVE="BRAVE",e.WALLETCONNECT="WALLETCONNECT",e))(ye||{});const Ze=async({api:e,rpcUrl:r,chain:t,phrase:a,ethplorerApiKey:o,covalentApiKey:l,utxoApiKey:d,index:I,stagenet:_})=>{const S=`${fe[t]}/${I}`;switch(t){case m.BinanceSmartChain:case m.Avalanche:case m.Ethereum:{if(t===m.Ethereum&&!o)throw new Error("Ethplorer API key not found");if(!l)throw new Error("Covalent API key not found");const{HDNodeWallet:u}=await import("ethers"),{getProvider:s,ETHToolbox:h,AVAXToolbox:p,BSCToolbox:w}=await import("@swapkit/toolbox-evm"),v=s(t,r),g=u.fromPhrase(a).connect(v),A={api:e,provider:v,signer:g},R=t===m.Ethereum?h({...A,ethplorerApiKey:o}):t===m.Avalanche?p({...A,covalentApiKey:l}):w({...A,covalentApiKey:l});return{address:g.address,walletMethods:{...R,getAddress:()=>g.address}}}case m.BitcoinCash:{if(!d)throw new Error("UTXO API key not found");const{BCHToolbox:u}=await import("@swapkit/toolbox-utxo"),s=u({rpcUrl:r,apiKey:d,apiClient:e}),h=await s.createKeysForPath({phrase:a,derivationPath:S}),p=s.getAddressFromKeys(h),w=async({builder:g,utxos:A})=>(A.forEach((R,U)=>{g.sign(U,h,void 0,65,R.witnessUtxo.value)}),g.build()),v={...s,getAddress:()=>p,transfer:g=>s.transfer({...g,from:p,signTransaction:w})};return{address:p,walletMethods:v}}case m.Bitcoin:case m.Dogecoin:case m.Litecoin:{const u={rpcUrl:r,apiKey:d,apiClient:e},{BTCToolbox:s,LTCToolbox:h,DOGEToolbox:p}=await import("@swapkit/toolbox-utxo"),w=t===m.Bitcoin?s(u):t===m.Litecoin?h(u):p(u),v=await w.createKeysForPath({phrase:a,derivationPath:S}),g=w.getAddressFromKeys(v),A=async R=>(R.signAllInputs(v),R);return{address:g,walletMethods:{...w,getAddress:()=>g,transfer:R=>w.transfer({...R,from:g,signTransaction:A})}}}case m.Binance:{const{BinanceToolbox:u}=await import("@swapkit/toolbox-cosmos"),s=u(),h=await s.createKeyPair(a),p=await s.getAddressFromMnemonic(a);return{address:p,walletMethods:{...s,transfer:({assetValue:v,recipient:g,memo:A})=>s.transfer({from:p,recipient:g,assetValue:v,privkey:h,memo:A}),getAddress:()=>p}}}case m.Cosmos:{const{GaiaToolbox:u}=await import("@swapkit/toolbox-cosmos"),s=u({server:e}),h=await s.getSigner(a),p=await s.getAddressFromMnemonic(a);return{address:p,walletMethods:{...s,transfer:({assetValue:v,recipient:g,memo:A})=>s.transfer({from:p,recipient:g,signer:h,assetValue:v,memo:A}),getAddress:()=>p}}}case m.Maya:case m.THORChain:{const{MayaToolbox:u,ThorchainToolbox:s}=await import("@swapkit/toolbox-cosmos"),h=t===m.THORChain?s({stagenet:_}):u({stagenet:_}),p=await h.getAddressFromMnemonic(a),w=await h.getSigner(a),A={...h,deposit:async({assetValue:R,memo:U})=>h.deposit({assetValue:R,memo:U,from:p,signer:w}),transfer:async({assetValue:R,recipient:U,memo:Ee})=>h.transfer({from:p,recipient:U,signer:w,assetValue:R,memo:Ee}),getAddress:()=>p};return{address:p,walletMethods:A}}default:throw new Error(`Unsupported chain ${t}`)}},et=({addChain:e,apis:r,rpcUrls:t,config:{covalentApiKey:a,ethplorerApiKey:o,utxoApiKey:l,stagenet:d}})=>async(I,_,S=0)=>{const u=I.map(async s=>{const{address:h,walletMethods:p}=await Ze({index:S,chain:s,api:r[s],rpcUrl:t[s],covalentApiKey:a,ethplorerApiKey:o,phrase:_,utxoApiKey:l,stagenet:d});e({chain:s,walletMethods:p,wallet:{address:h,balance:[],walletType:ye.KEYSTORE}})});return await Promise.all(u),!0},tt={connectMethodName:"connectKeystore",connect:et};exports.blake256=q;exports.decryptFromKeystore=Qe;exports.encryptToKeyStore=$e;exports.generatePhrase=Xe;exports.keystoreWallet=tt;
2049
+ `),Re="Input must be an string, Buffer or Uint8Array";function ke(e){let r;if(e instanceof Uint8Array)r=e;else if(typeof e=="string")r=new TextEncoder().encode(e);else throw new Error(Re);return r}function Ne(e){return Array.prototype.map.call(e,function(r){return(r<16?"0":"")+r.toString(16)}).join("")}function B(e){return(4294967296+e).toString(16).substring(1)}function Te(e,r,t){let a=`
2050
+ `+e+" = ";for(let o=0;o<r.length;o+=2){if(t===32)a+=B(r[o]).toUpperCase(),a+=" ",a+=B(r[o+1]).toUpperCase();else if(t===64)a+=B(r[o+1]).toUpperCase(),a+=B(r[o]).toUpperCase();else throw new Error("Invalid size "+t);o%6===4?a+=`
2051
+ `+new Array(e.length+4).join(" "):o<r.length-2&&(a+=" ")}console.log(a)}function De(e,r,t){let a=new Date().getTime();const o=new Uint8Array(r);for(let p=0;p<r;p++)o[p]=p%256;const l=new Date().getTime();console.log("Generated random input in "+(l-a)+"ms"),a=l;for(let p=0;p<t;p++){const _=e(o),y=new Date().getTime(),A=y-a;a=y,console.log("Hashed in "+A+"ms: "+_.substring(0,20)+"..."),console.log(Math.round(r/(1<<20)/(A/1e3)*100)/100+" MB PER SECOND")}}var J={normalizeInput:ke,toHex:Ne,debugPrint:Te,testSpeed:De};const H=J;function P(e,r,t){const a=e[r]+e[t];let o=e[r+1]+e[t+1];a>=4294967296&&o++,e[r]=a,e[r+1]=o}function X(e,r,t,a){let o=e[r]+t;t<0&&(o+=4294967296);let l=e[r+1]+a;o>=4294967296&&l++,e[r]=o,e[r+1]=l}function Z(e,r){return e[r]^e[r+1]<<8^e[r+2]<<16^e[r+3]<<24}function N(e,r,t,a,o,l){const p=x[o],_=x[o+1],y=x[l],A=x[l+1];P(s,e,r),X(s,e,p,_);let u=s[a]^s[e],i=s[a+1]^s[e+1];s[a]=i,s[a+1]=u,P(s,t,a),u=s[r]^s[t],i=s[r+1]^s[t+1],s[r]=u>>>24^i<<8,s[r+1]=i>>>24^u<<8,P(s,e,r),X(s,e,y,A),u=s[a]^s[e],i=s[a+1]^s[e+1],s[a]=u>>>16^i<<16,s[a+1]=i>>>16^u<<16,P(s,t,a),u=s[r]^s[t],i=s[r+1]^s[t+1],s[r]=i>>>31^u<<1,s[r+1]=u>>>31^i<<1}const ee=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),Oe=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3],E=new Uint8Array(Oe.map(function(e){return e*2})),s=new Uint32Array(32),x=new Uint32Array(32);function te(e,r){let t=0;for(t=0;t<16;t++)s[t]=e.h[t],s[t+16]=ee[t];for(s[24]=s[24]^e.t,s[25]=s[25]^e.t/4294967296,r&&(s[28]=~s[28],s[29]=~s[29]),t=0;t<32;t++)x[t]=Z(e.b,4*t);for(t=0;t<12;t++)N(0,8,16,24,E[t*16+0],E[t*16+1]),N(2,10,18,26,E[t*16+2],E[t*16+3]),N(4,12,20,28,E[t*16+4],E[t*16+5]),N(6,14,22,30,E[t*16+6],E[t*16+7]),N(0,10,20,30,E[t*16+8],E[t*16+9]),N(2,12,22,24,E[t*16+10],E[t*16+11]),N(4,14,16,26,E[t*16+12],E[t*16+13]),N(6,8,18,28,E[t*16+14],E[t*16+15]);for(t=0;t<16;t++)e.h[t]=e.h[t]^s[t]^s[t+16]}const T=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]);function re(e,r,t,a){if(e===0||e>64)throw new Error("Illegal output length, expected 0 < length <= 64");if(r&&r.length>64)throw new Error("Illegal key, expected Uint8Array with 0 < length <= 64");if(t&&t.length!==16)throw new Error("Illegal salt, expected Uint8Array with length is 16");if(a&&a.length!==16)throw new Error("Illegal personal, expected Uint8Array with length is 16");const o={b:new Uint8Array(128),h:new Uint32Array(16),t:0,c:0,outlen:e};T.fill(0),T[0]=e,r&&(T[1]=r.length),T[2]=1,T[3]=1,t&&T.set(t,32),a&&T.set(a,48);for(let l=0;l<16;l++)o.h[l]=ee[l]^Z(T,l*4);return r&&(F(o,r),o.c=128),o}function F(e,r){for(let t=0;t<r.length;t++)e.c===128&&(e.t+=e.c,te(e,!1),e.c=0),e.b[e.c++]=r[t]}function ae(e){for(e.t+=e.c;e.c<128;)e.b[e.c++]=0;te(e,!0);const r=new Uint8Array(e.outlen);for(let t=0;t<e.outlen;t++)r[t]=e.h[t>>2]>>8*(t&3);return r}function oe(e,r,t,a,o){t=t||64,e=H.normalizeInput(e),a&&(a=H.normalizeInput(a)),o&&(o=H.normalizeInput(o));const l=re(t,r,a,o);return F(l,e),ae(l)}function Ue(e,r,t,a,o){const l=oe(e,r,t,a,o);return H.toHex(l)}var Ce={blake2b:oe,blake2bHex:Ue,blake2bInit:re,blake2bUpdate:F,blake2bFinal:ae};const ne=J;function xe(e,r){return e[r]^e[r+1]<<8^e[r+2]<<16^e[r+3]<<24}function D(e,r,t,a,o,l){c[e]=c[e]+c[r]+o,c[a]=M(c[a]^c[e],16),c[t]=c[t]+c[a],c[r]=M(c[r]^c[t],12),c[e]=c[e]+c[r]+l,c[a]=M(c[a]^c[e],8),c[t]=c[t]+c[a],c[r]=M(c[r]^c[t],7)}function M(e,r){return e>>>r^e<<32-r}const ie=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),I=new Uint8Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0]),c=new Uint32Array(16),f=new Uint32Array(16);function se(e,r){let t=0;for(t=0;t<8;t++)c[t]=e.h[t],c[t+8]=ie[t];for(c[12]^=e.t,c[13]^=e.t/4294967296,r&&(c[14]=~c[14]),t=0;t<16;t++)f[t]=xe(e.b,4*t);for(t=0;t<10;t++)D(0,4,8,12,f[I[t*16+0]],f[I[t*16+1]]),D(1,5,9,13,f[I[t*16+2]],f[I[t*16+3]]),D(2,6,10,14,f[I[t*16+4]],f[I[t*16+5]]),D(3,7,11,15,f[I[t*16+6]],f[I[t*16+7]]),D(0,5,10,15,f[I[t*16+8]],f[I[t*16+9]]),D(1,6,11,12,f[I[t*16+10]],f[I[t*16+11]]),D(2,7,8,13,f[I[t*16+12]],f[I[t*16+13]]),D(3,4,9,14,f[I[t*16+14]],f[I[t*16+15]]);for(t=0;t<8;t++)e.h[t]^=c[t]^c[t+8]}function le(e,r){if(!(e>0&&e<=32))throw new Error("Incorrect output length, should be in [1, 32]");const t=r?r.length:0;if(r&&!(t>0&&t<=32))throw new Error("Incorrect key length, should be in [1, 32]");const a={h:new Uint32Array(ie),b:new Uint8Array(64),c:0,t:0,outlen:e};return a.h[0]^=16842752^t<<8^e,t>0&&(j(a,r),a.c=64),a}function j(e,r){for(let t=0;t<r.length;t++)e.c===64&&(e.t+=e.c,se(e,!1),e.c=0),e.b[e.c++]=r[t]}function ce(e){for(e.t+=e.c;e.c<64;)e.b[e.c++]=0;se(e,!0);const r=new Uint8Array(e.outlen);for(let t=0;t<e.outlen;t++)r[t]=e.h[t>>2]>>8*(t&3)&255;return r}function ue(e,r,t){t=t||32,e=ne.normalizeInput(e);const a=le(t,r);return j(a,e),ce(a)}function Be(e,r,t){const a=ue(e,r,t);return ne.toHex(a)}var Pe={blake2s:ue,blake2sHex:Be,blake2sInit:le,blake2sUpdate:j,blake2sFinal:ce};const U=Ce,C=Pe;var G={blake2b:U.blake2b,blake2bHex:U.blake2bHex,blake2bInit:U.blake2bInit,blake2bUpdate:U.blake2bUpdate,blake2bFinal:U.blake2bFinal,blake2s:C.blake2s,blake2sHex:C.blake2sHex,blake2sInit:C.blake2sInit,blake2sUpdate:C.blake2sUpdate,blake2sFinal:C.blake2sFinal};let L;const Me=new Uint8Array(16);function Le(){if(!L&&(L=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!L))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return L(Me)}const b=[];for(let e=0;e<256;++e)b.push((e+256).toString(16).slice(1));function He(e,r=0){return(b[e[r+0]]+b[e[r+1]]+b[e[r+2]]+b[e[r+3]]+"-"+b[e[r+4]]+b[e[r+5]]+"-"+b[e[r+6]]+b[e[r+7]]+"-"+b[e[r+8]]+b[e[r+9]]+"-"+b[e[r+10]]+b[e[r+11]]+b[e[r+12]]+b[e[r+13]]+b[e[r+14]]+b[e[r+15]]).toLowerCase()}const Ve=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),$={randomUUID:Ve};function Ge(e,r,t){if($.randomUUID&&!r&&!e)return $.randomUUID();e=e||{};const a=e.random||(e.rng||Le)();if(a[6]=a[6]&15|64,a[8]=a[8]&63|128,r){t=t||0;for(let o=0;o<16;++o)r[t+o]=a[o];return r}return He(a)}const Q="aes-128-ctr",Fe="pbkdf2",je="hmac-sha256",ze=32,Ke=262144,de="sha256",qe="xchain-keystore",Ye=e=>e<16?`0${e.toString(16)}`:e.toString(16),We=e=>Array.from(e).map(Ye).join(""),pe=()=>typeof window>"u",z=()=>pe()?crypto:Promise.resolve().then(()=>require("./__vite-browser-external-b3701507.cjs")).then(({default:e})=>e),K=e=>{e instanceof Buffer||(e=Buffer.from(e,"hex"));const r=G.blake2bInit(32);return G.blake2bUpdate(r,e),We(G.blake2bFinal(r))},me=async(e,r,t,a,o)=>{const l=await z();return new Promise((p,_)=>{l.pbkdf2(e,r,t,a,o,(y,A)=>{y?_(y):p(A)})})},Xe=async(e,r)=>{const t=pe()?require("uuid").v4():Ge(),a=await z(),o=a.randomBytes(32),l=a.randomBytes(16),p={prf:je,dklen:ze,salt:o.toString("hex"),c:Ke},_={iv:l.toString("hex")},y=await me(Buffer.from(r),o,p.c,p.dklen,de),A=a.createCipheriv(Q,y.slice(0,16),l),u=Buffer.concat([A.update(Buffer.from(e,"utf8")),A.final()]),i=K(Buffer.concat([y.slice(16,32),Buffer.from(u)]));return{crypto:{cipher:Q,ciphertext:u.toString("hex"),cipherparams:_,kdf:Fe,kdfparams:p,mac:i},id:t,version:1,meta:qe}},$e=(e=12)=>{const r=e===12?128:256;return Se.generateMnemonic(ve,r)},Qe=async(e,r)=>{const t=await z(),a=e.crypto.kdfparams,o=await me(Buffer.from(r),Buffer.from(a.salt,"hex"),a.c,a.dklen,de),l=Buffer.from(e.crypto.ciphertext,"hex");if(K(Buffer.concat([o.slice(16,32),l]))!==e.crypto.mac)throw new Error("Invalid password");const _=t.createDecipheriv(e.crypto.cipher,o.slice(0,16),Buffer.from(e.crypto.cipherparams.iv,"hex"));return Buffer.concat([_.update(l),_.final()]).toString("utf8")};var n=(e=>(e.INVALID_INPUT_PARAMETERS="1000",e.UNKNOWN_PROVIDERS="1001",e.CANNOT_FIND_INBOUND_ADDRESS="1002",e.NO_INBOUND_ADDRESSES="1003",e.CHAIN_HALTED_OR_UNSUPPORTED="1004",e.MISSING_INPUT_PARAMETER="1005",e.INVALID_TYPE_GENERIC="1100",e.INVALID_NUMBER_STRING="1101",e.INVALID_NUMBER="1102",e.INVALID_BOOLEAN="1103",e.INVALID_OBJECT="1104",e.INVALID_ARRAY="1105",e.SELL_AMOUNT_MUST_BE_POSITIVE_INTEGER="2000",e.SELL_BUY_ASSETS_ARE_THE_SAME="2001",e.MISSING_SOURCE_ADDRESS_FOR_SYNTH="2002",e.AFF_ADDRESS_AND_BPS_OR_NEITHER="2003",e.AFF_ADDRESS_TOO_LONG="2004",e.AFF_BPS_INTEGER_0_100="2005",e.SOURCE_ADDRESS_INVALID_FOR_SELL_CHAIN="2006",e.DESTINATION_ADDRESS_INVALID_FOR_BUY_CHAIN="2007",e.PREFERRED_PROFVIDER_NOT_SUPPORTED="2008",e.DESTINATION_ADDRESS_SMART_CONTRACT="2009",e.BUY_AMOUNT_MUST_BE_POSITIVE_INTEGER="2010",e.SOURCE_ADDRESS_SMART_CONTRACT="2011",e.INVALID_PROVIDER="2100",e.MISSING_CROSS_CHAIN_PROVIDER="2101",e.MISSING_AVAX_PROVIDER="2102",e.MISSING_BSC_PROVIDER="2103",e.MISSING_ETH_PROVIDER="2104",e.INVALID_PROVIDER_FOR_SWAP_OUT="2105",e.MISSING_ARB_PROVIDER="2106",e.INVALID_CHAIN="2200",e.INVALID_ASSET="2201",e.INVALID_ASSET_IDENTIFIER="2202",e.UNSUPPORTED_CHAIN="2204",e.UNSUPPORTED_ASSET="2203",e.UNSUPPORTED_ASSET_FOR_SWAPOUT="2205",e.INVALID_SOURCE_ADDRESS="2300",e.INVALID_DESTINATION_ADDRESS="2301",e.THORNODE_QUOTE_GENERIC_ERROR="3000",e.NOT_ENOUGH_SYNTH_BALANCE="3001",e.SYNTH_MINTING_CAP_REACHED="3002",e.INVALID_QUOTE_MODE="4000",e.NO_QUOTES="4001",e.SERVICE_UNAVAILABLE_GENERIC="5000",e.MISSING_GAS_DATA_GENERIC="5100",e.MISSING_TOKEN_INFO_GENERIC="5200",e.CANT_FIND_TOKEN_LIST="5201",e.NO_PRICE="5202",e.PRICE_IS_STALE="5203",e.ADDRESS_NOT_WHITELISTED="6000",e.ADDRESS_ALREADY_CLAIMED="6001",e.TEMPORARY_ERROR="9999",e))(n||{});n.INVALID_INPUT_PARAMETERS+"",n.UNKNOWN_PROVIDERS+"",n.CANNOT_FIND_INBOUND_ADDRESS+"",n.NO_INBOUND_ADDRESSES+"",n.CHAIN_HALTED_OR_UNSUPPORTED+"",n.MISSING_INPUT_PARAMETER+"",n.INVALID_TYPE_GENERIC+"",n.INVALID_NUMBER_STRING+"",n.INVALID_NUMBER+"",n.INVALID_BOOLEAN+"",n.INVALID_OBJECT+"",n.INVALID_ARRAY+"",n.SELL_AMOUNT_MUST_BE_POSITIVE_INTEGER+"",n.SELL_BUY_ASSETS_ARE_THE_SAME+"",n.MISSING_SOURCE_ADDRESS_FOR_SYNTH+"",n.AFF_ADDRESS_AND_BPS_OR_NEITHER+"",n.AFF_ADDRESS_TOO_LONG+"",n.AFF_BPS_INTEGER_0_100+"",n.SOURCE_ADDRESS_INVALID_FOR_SELL_CHAIN+"",n.DESTINATION_ADDRESS_INVALID_FOR_BUY_CHAIN+"",n.PREFERRED_PROFVIDER_NOT_SUPPORTED+"",n.DESTINATION_ADDRESS_SMART_CONTRACT+"",n.BUY_AMOUNT_MUST_BE_POSITIVE_INTEGER+"",n.INVALID_PROVIDER+"",n.MISSING_CROSS_CHAIN_PROVIDER+"",n.MISSING_AVAX_PROVIDER+"",n.MISSING_BSC_PROVIDER+"",n.MISSING_ETH_PROVIDER+"",n.MISSING_ARB_PROVIDER+"",n.INVALID_PROVIDER_FOR_SWAP_OUT+"",n.INVALID_CHAIN+"",n.INVALID_ASSET+"",n.UNSUPPORTED_CHAIN+"",n.UNSUPPORTED_ASSET+"",n.UNSUPPORTED_ASSET_FOR_SWAPOUT+"",n.THORNODE_QUOTE_GENERIC_ERROR+"",n.INVALID_SOURCE_ADDRESS+"",n.INVALID_DESTINATION_ADDRESS+"",n.NOT_ENOUGH_SYNTH_BALANCE+"",n.SYNTH_MINTING_CAP_REACHED+"",n.INVALID_QUOTE_MODE+"",n.NO_QUOTES+"",n.SERVICE_UNAVAILABLE_GENERIC+"",n.MISSING_GAS_DATA_GENERIC+"",n.MISSING_TOKEN_INFO_GENERIC+"",n.CANT_FIND_TOKEN_LIST+"",n.NO_PRICE+"",n.PRICE_IS_STALE+"",n.ADDRESS_NOT_WHITELISTED+"",n.ADDRESS_ALREADY_CLAIMED+"";var m=(e=>(e.Arbitrum="ARB",e.Avalanche="AVAX",e.Binance="BNB",e.BinanceSmartChain="BSC",e.Bitcoin="BTC",e.BitcoinCash="BCH",e.Cosmos="GAIA",e.Dogecoin="DOGE",e.Ethereum="ETH",e.Kujira="KUJI",e.Litecoin="LTC",e.Maya="MAYA",e.Optimism="OP",e.Polygon="MATIC",e.THORChain="THOR",e))(m||{}),he=(e=>(e.ARB="m/44'/60'/0'/0",e.AVAX="m/44'/60'/0'/0",e.BCH="m/44'/145'/0'/0",e.BNB="m/44'/714'/0'/0",e.BSC="m/44'/60'/0'/0",e.BTC="m/84'/0'/0'/0",e.DOGE="m/44'/3'/0'/0",e.ETH="m/44'/60'/0'/0",e.GAIA="m/44'/118'/0'/0",e.KUJI="m/44'/118'/0'/0",e.LTC="m/84'/2'/0'/0",e.MATIC="m/44'/60'/0'/0",e.MAYA="m/44'/931'/0'/0",e.OP="m/44'/60'/0'/0",e.THOR="m/44'/931'/0'/0",e))(he||{}),q=(e=>(e.Arbitrum="42161",e.ArbitrumHex="0xa4b1",e.Avalanche="43114",e.AvalancheHex="0xa86a",e.Binance="Binance-Chain-Tigris",e.BinanceSmartChain="56",e.BinanceSmartChainHex="0x38",e.Bitcoin="bitcoin",e.BitcoinCash="bitcoincash",e.Cosmos="cosmoshub-4",e.Dogecoin="dogecoin",e.Kujira="kaiyo-1",e.Ethereum="1",e.EthereumHex="0x1",e.Litecoin="litecoin",e.Maya="mayachain-mainnet-v1",e.MayaStagenet="mayachain-stagenet-v1",e.Optimism="10",e.OptimismHex="0xa",e.Polygon="137",e.PolygonHex="0x89",e.THORChain="thorchain-mainnet-v1",e.THORChainStagenet="thorchain-stagenet-v2",e))(q||{}),ge=(e=>(e.Arbitrum="https://arb1.arbitrum.io/rpc",e.Avalanche="https://node-router.thorswap.net/avalanche-c",e.Binance="",e.BinanceSmartChain="https://bsc-dataseed.binance.org",e.Bitcoin="https://node-router.thorswap.net/bitcoin",e.BitcoinCash="https://node-router.thorswap.net/bitcoin-cash",e.Cosmos="https://node-router.thorswap.net/cosmos/rpc",e.Kujira="https://rpc-kujira.synergynodes.com/",e.Dogecoin="https://node-router.thorswap.net/dogecoin",e.Ethereum="https://node-router.thorswap.net/ethereum",e.Litecoin="https://node-router.thorswap.net/litecoin",e.Maya="https://tendermint.mayachain.info",e.MayaStagenet="https://stagenet.tendermint.mayachain.info",e.Optimism="https://mainnet.optimism.io",e.Polygon="https://polygon-rpc.com",e.THORChain="https://rpc.thorswap.net",e.THORChainStagenet="https://stagenet-rpc.ninerealms.com",e))(ge||{});const V=Object.values(m),Je=Object.keys(m),Y=V.reduce((e,r)=>{const t=Je.find(a=>m[a]===r);return t&&(e[r]=t),e},{});V.reduce((e,r)=>(e[r]=q[Y[r]],e),{});V.reduce((e,r)=>(e[r]=ge[Y[r]],e),{});V.reduce((e,r)=>{const t=`${Y[r]}Hex`;return e[r]=q[t],e},{});var fe=(e=>(e.KEYSTORE="KEYSTORE",e.XDEFI="XDEFI",e.METAMASK="METAMASK",e.COINBASE_WEB="COINBASE_WEB",e.TREZOR="TREZOR",e.TRUSTWALLET_WEB="TRUSTWALLET_WEB",e.LEDGER="LEDGER",e.KEPLR="KEPLR",e.OKX="OKX",e.BRAVE="BRAVE",e.WALLETCONNECT="WALLETCONNECT",e))(fe||{});const Ze=async({api:e,rpcUrl:r,chain:t,phrase:a,ethplorerApiKey:o,covalentApiKey:l,utxoApiKey:p,index:_,stagenet:y})=>{const A=`${he[t]}/${_}`;switch(t){case m.BinanceSmartChain:case m.Avalanche:case m.Ethereum:{if(t===m.Ethereum&&!o)throw new Error("Ethplorer API key not found");if(!l)throw new Error("Covalent API key not found");const{HDNodeWallet:u}=await import("ethers"),{getProvider:i,ETHToolbox:h,AVAXToolbox:d,BSCToolbox:S}=await import("@swapkit/toolbox-evm"),v=i(t,r),g=u.fromPhrase(a).connect(v),w={api:e,provider:v,signer:g},R=t===m.Ethereum?h({...w,ethplorerApiKey:o}):t===m.Avalanche?d({...w,covalentApiKey:l}):S({...w,covalentApiKey:l});return{address:g.address,walletMethods:{...R,getAddress:()=>g.address}}}case m.BitcoinCash:{if(!p)throw new Error("UTXO API key not found");const{BCHToolbox:u}=await import("@swapkit/toolbox-utxo"),i=u({rpcUrl:r,apiKey:p,apiClient:e}),h=await i.createKeysForPath({phrase:a,derivationPath:A}),d=i.getAddressFromKeys(h),S=async({builder:g,utxos:w})=>(w.forEach((R,O)=>{g.sign(O,h,void 0,65,R.witnessUtxo.value)}),g.build()),v={...i,getAddress:()=>d,transfer:g=>i.transfer({...g,from:d,signTransaction:S})};return{address:d,walletMethods:v}}case m.Bitcoin:case m.Dogecoin:case m.Litecoin:{const u={rpcUrl:r,apiKey:p,apiClient:e},{BTCToolbox:i,LTCToolbox:h,DOGEToolbox:d}=await import("@swapkit/toolbox-utxo"),S=t===m.Bitcoin?i(u):t===m.Litecoin?h(u):d(u),v=await S.createKeysForPath({phrase:a,derivationPath:A}),g=S.getAddressFromKeys(v),w=async R=>(R.signAllInputs(v),R);return{address:g,walletMethods:{...S,getAddress:()=>g,transfer:R=>S.transfer({...R,from:g,signTransaction:w})}}}case m.Binance:{const{BinanceToolbox:u}=await import("@swapkit/toolbox-cosmos"),i=u(),h=await i.createKeyPair(a),d=await i.getAddressFromMnemonic(a);return{address:d,walletMethods:{...i,transfer:({assetValue:v,recipient:g,memo:w})=>i.transfer({from:d,recipient:g,assetValue:v,privkey:h,memo:w}),getAddress:()=>d}}}case m.Cosmos:{const{GaiaToolbox:u}=await import("@swapkit/toolbox-cosmos"),i=u({server:e}),h=await i.getSigner(a),d=await i.getAddressFromMnemonic(a);return{address:d,walletMethods:{...i,transfer:({assetValue:v,recipient:g,memo:w})=>i.transfer({from:d,recipient:g,signer:h,assetValue:v,memo:w}),getAddress:()=>d}}}case m.Kujira:{const{KujiraToolbox:u}=await import("@swapkit/toolbox-cosmos"),i=u({server:e}),h=await i.getSigner(a),d=await i.getAddressFromMnemonic(a);return{address:d,walletMethods:{...i,transfer:({assetValue:v,recipient:g,memo:w})=>i.transfer({from:d,recipient:g,signer:h,assetValue:v,memo:w}),getAddress:()=>d}}}case m.Maya:case m.THORChain:{const{MayaToolbox:u,ThorchainToolbox:i}=await import("@swapkit/toolbox-cosmos"),h=t===m.THORChain?i({stagenet:y}):u({stagenet:y}),d=await h.getAddressFromMnemonic(a),S=await h.getSigner(a),w={...h,deposit:async({assetValue:R,memo:O})=>h.deposit({assetValue:R,memo:O,from:d,signer:S}),transfer:async({assetValue:R,recipient:O,memo:be})=>h.transfer({from:d,recipient:O,signer:S,assetValue:R,memo:be}),getAddress:()=>d};return{address:d,walletMethods:w}}default:throw new Error(`Unsupported chain ${t}`)}},et=({addChain:e,apis:r,rpcUrls:t,config:{covalentApiKey:a,ethplorerApiKey:o,utxoApiKey:l,stagenet:p}})=>async(_,y,A=0)=>{const u=_.map(async i=>{const{address:h,walletMethods:d}=await Ze({index:A,chain:i,api:r[i],rpcUrl:t[i],covalentApiKey:a,ethplorerApiKey:o,phrase:y,utxoApiKey:l,stagenet:p});e({chain:i,walletMethods:d,wallet:{address:h,balance:[],walletType:fe.KEYSTORE}})});return await Promise.all(u),!0},tt={connectMethodName:"connectKeystore",connect:et};exports.blake256=K;exports.decryptFromKeystore=Qe;exports.encryptToKeyStore=Xe;exports.generatePhrase=$e;exports.keystoreWallet=tt;
package/dist/index.d.ts CHANGED
@@ -15,13 +15,13 @@ export declare const encryptToKeyStore: (phrase: string, password: string) => Pr
15
15
  cipher: string;
16
16
  ciphertext: string;
17
17
  cipherparams: {
18
- iv: string;
18
+ iv: any;
19
19
  };
20
20
  kdf: string;
21
21
  kdfparams: {
22
22
  prf: string;
23
23
  dklen: number;
24
- salt: string;
24
+ salt: any;
25
25
  c: number;
26
26
  };
27
27
  mac: string;
package/dist/index.es.js CHANGED
@@ -1,5 +1,5 @@
1
- import { entropyToMnemonic as be, generateMnemonic as ye } from "@scure/bip39";
2
- const K = `abandon
1
+ import { generateMnemonic as fe } from "@scure/bip39";
2
+ const be = `abandon
3
3
  ability
4
4
  able
5
5
  about
@@ -2047,23 +2047,23 @@ zebra
2047
2047
  zero
2048
2048
  zone
2049
2049
  zoo`.split(`
2050
- `), Ee = "Input must be an string, Buffer or Uint8Array";
2051
- function Ie(e) {
2050
+ `), ye = "Input must be an string, Buffer or Uint8Array";
2051
+ function Ee(e) {
2052
2052
  let r;
2053
2053
  if (e instanceof Uint8Array)
2054
2054
  r = e;
2055
2055
  else if (typeof e == "string")
2056
2056
  r = new TextEncoder().encode(e);
2057
2057
  else
2058
- throw new Error(Ee);
2058
+ throw new Error(ye);
2059
2059
  return r;
2060
2060
  }
2061
- function _e(e) {
2061
+ function Ie(e) {
2062
2062
  return Array.prototype.map.call(e, function(r) {
2063
2063
  return (r < 16 ? "0" : "") + r.toString(16);
2064
2064
  }).join("");
2065
2065
  }
2066
- function B(e) {
2066
+ function x(e) {
2067
2067
  return (4294967296 + e).toString(16).substring(1);
2068
2068
  }
2069
2069
  function we(e, r, t) {
@@ -2071,9 +2071,9 @@ function we(e, r, t) {
2071
2071
  ` + e + " = ";
2072
2072
  for (let o = 0; o < r.length; o += 2) {
2073
2073
  if (t === 32)
2074
- a += B(r[o]).toUpperCase(), a += " ", a += B(r[o + 1]).toUpperCase();
2074
+ a += x(r[o]).toUpperCase(), a += " ", a += x(r[o + 1]).toUpperCase();
2075
2075
  else if (t === 64)
2076
- a += B(r[o + 1]).toUpperCase(), a += B(r[o]).toUpperCase();
2076
+ a += x(r[o + 1]).toUpperCase(), a += x(r[o]).toUpperCase();
2077
2077
  else
2078
2078
  throw new Error("Invalid size " + t);
2079
2079
  o % 6 === 4 ? a += `
@@ -2081,48 +2081,48 @@ function we(e, r, t) {
2081
2081
  }
2082
2082
  console.log(a);
2083
2083
  }
2084
- function Ae(e, r, t) {
2084
+ function _e(e, r, t) {
2085
2085
  let a = (/* @__PURE__ */ new Date()).getTime();
2086
2086
  const o = new Uint8Array(r);
2087
- for (let d = 0; d < r; d++)
2088
- o[d] = d % 256;
2087
+ for (let p = 0; p < r; p++)
2088
+ o[p] = p % 256;
2089
2089
  const l = (/* @__PURE__ */ new Date()).getTime();
2090
2090
  console.log("Generated random input in " + (l - a) + "ms"), a = l;
2091
- for (let d = 0; d < t; d++) {
2092
- const I = e(o), _ = (/* @__PURE__ */ new Date()).getTime(), S = _ - a;
2093
- a = _, console.log("Hashed in " + S + "ms: " + I.substring(0, 20) + "..."), console.log(
2094
- Math.round(r / (1 << 20) / (S / 1e3) * 100) / 100 + " MB PER SECOND"
2091
+ for (let p = 0; p < t; p++) {
2092
+ const _ = e(o), y = (/* @__PURE__ */ new Date()).getTime(), A = y - a;
2093
+ a = y, console.log("Hashed in " + A + "ms: " + _.substring(0, 20) + "..."), console.log(
2094
+ Math.round(r / (1 << 20) / (A / 1e3) * 100) / 100 + " MB PER SECOND"
2095
2095
  );
2096
2096
  }
2097
2097
  }
2098
2098
  var X = {
2099
- normalizeInput: Ie,
2100
- toHex: _e,
2099
+ normalizeInput: Ee,
2100
+ toHex: Ie,
2101
2101
  debugPrint: we,
2102
- testSpeed: Ae
2102
+ testSpeed: _e
2103
2103
  };
2104
- const H = X;
2105
- function P(e, r, t) {
2104
+ const L = X;
2105
+ function B(e, r, t) {
2106
2106
  const a = e[r] + e[t];
2107
2107
  let o = e[r + 1] + e[t + 1];
2108
2108
  a >= 4294967296 && o++, e[r] = a, e[r + 1] = o;
2109
2109
  }
2110
- function Y(e, r, t, a) {
2110
+ function q(e, r, t, a) {
2111
2111
  let o = e[r] + t;
2112
2112
  t < 0 && (o += 4294967296);
2113
2113
  let l = e[r + 1] + a;
2114
2114
  o >= 4294967296 && l++, e[r] = o, e[r + 1] = l;
2115
2115
  }
2116
- function Q(e, r) {
2116
+ function $(e, r) {
2117
2117
  return e[r] ^ e[r + 1] << 8 ^ e[r + 2] << 16 ^ e[r + 3] << 24;
2118
2118
  }
2119
2119
  function N(e, r, t, a, o, l) {
2120
- const d = x[o], I = x[o + 1], _ = x[l], S = x[l + 1];
2121
- P(i, e, r), Y(i, e, d, I);
2122
- let u = i[a] ^ i[e], s = i[a + 1] ^ i[e + 1];
2123
- i[a] = s, i[a + 1] = u, P(i, t, a), u = i[r] ^ i[t], s = i[r + 1] ^ i[t + 1], i[r] = u >>> 24 ^ s << 8, i[r + 1] = s >>> 24 ^ u << 8, P(i, e, r), Y(i, e, _, S), u = i[a] ^ i[e], s = i[a + 1] ^ i[e + 1], i[a] = u >>> 16 ^ s << 16, i[a + 1] = s >>> 16 ^ u << 16, P(i, t, a), u = i[r] ^ i[t], s = i[r + 1] ^ i[t + 1], i[r] = s >>> 31 ^ u << 1, i[r + 1] = u >>> 31 ^ s << 1;
2120
+ const p = C[o], _ = C[o + 1], y = C[l], A = C[l + 1];
2121
+ B(s, e, r), q(s, e, p, _);
2122
+ let u = s[a] ^ s[e], i = s[a + 1] ^ s[e + 1];
2123
+ s[a] = i, s[a + 1] = u, B(s, t, a), u = s[r] ^ s[t], i = s[r + 1] ^ s[t + 1], s[r] = u >>> 24 ^ i << 8, s[r + 1] = i >>> 24 ^ u << 8, B(s, e, r), q(s, e, y, A), u = s[a] ^ s[e], i = s[a + 1] ^ s[e + 1], s[a] = u >>> 16 ^ i << 16, s[a + 1] = i >>> 16 ^ u << 16, B(s, t, a), u = s[r] ^ s[t], i = s[r + 1] ^ s[t + 1], s[r] = i >>> 31 ^ u << 1, s[r + 1] = u >>> 31 ^ i << 1;
2124
2124
  }
2125
- const J = new Uint32Array([
2125
+ const Q = new Uint32Array([
2126
2126
  4089235720,
2127
2127
  1779033703,
2128
2128
  2227873595,
@@ -2139,7 +2139,7 @@ const J = new Uint32Array([
2139
2139
  528734635,
2140
2140
  327033209,
2141
2141
  1541459225
2142
- ]), Se = [
2142
+ ]), Ae = [
2143
2143
  0,
2144
2144
  1,
2145
2145
  2,
@@ -2332,23 +2332,23 @@ const J = new Uint32Array([
2332
2332
  7,
2333
2333
  5,
2334
2334
  3
2335
- ], y = new Uint8Array(
2336
- Se.map(function(e) {
2335
+ ], E = new Uint8Array(
2336
+ Ae.map(function(e) {
2337
2337
  return e * 2;
2338
2338
  })
2339
- ), i = new Uint32Array(32), x = new Uint32Array(32);
2340
- function Z(e, r) {
2339
+ ), s = new Uint32Array(32), C = new Uint32Array(32);
2340
+ function J(e, r) {
2341
2341
  let t = 0;
2342
2342
  for (t = 0; t < 16; t++)
2343
- i[t] = e.h[t], i[t + 16] = J[t];
2344
- for (i[24] = i[24] ^ e.t, i[25] = i[25] ^ e.t / 4294967296, r && (i[28] = ~i[28], i[29] = ~i[29]), t = 0; t < 32; t++)
2345
- x[t] = Q(e.b, 4 * t);
2343
+ s[t] = e.h[t], s[t + 16] = Q[t];
2344
+ for (s[24] = s[24] ^ e.t, s[25] = s[25] ^ e.t / 4294967296, r && (s[28] = ~s[28], s[29] = ~s[29]), t = 0; t < 32; t++)
2345
+ C[t] = $(e.b, 4 * t);
2346
2346
  for (t = 0; t < 12; t++)
2347
- N(0, 8, 16, 24, y[t * 16 + 0], y[t * 16 + 1]), N(2, 10, 18, 26, y[t * 16 + 2], y[t * 16 + 3]), N(4, 12, 20, 28, y[t * 16 + 4], y[t * 16 + 5]), N(6, 14, 22, 30, y[t * 16 + 6], y[t * 16 + 7]), N(0, 10, 20, 30, y[t * 16 + 8], y[t * 16 + 9]), N(2, 12, 22, 24, y[t * 16 + 10], y[t * 16 + 11]), N(4, 14, 16, 26, y[t * 16 + 12], y[t * 16 + 13]), N(6, 8, 18, 28, y[t * 16 + 14], y[t * 16 + 15]);
2347
+ N(0, 8, 16, 24, E[t * 16 + 0], E[t * 16 + 1]), N(2, 10, 18, 26, E[t * 16 + 2], E[t * 16 + 3]), N(4, 12, 20, 28, E[t * 16 + 4], E[t * 16 + 5]), N(6, 14, 22, 30, E[t * 16 + 6], E[t * 16 + 7]), N(0, 10, 20, 30, E[t * 16 + 8], E[t * 16 + 9]), N(2, 12, 22, 24, E[t * 16 + 10], E[t * 16 + 11]), N(4, 14, 16, 26, E[t * 16 + 12], E[t * 16 + 13]), N(6, 8, 18, 28, E[t * 16 + 14], E[t * 16 + 15]);
2348
2348
  for (t = 0; t < 16; t++)
2349
- e.h[t] = e.h[t] ^ i[t] ^ i[t + 16];
2349
+ e.h[t] = e.h[t] ^ s[t] ^ s[t + 16];
2350
2350
  }
2351
- const T = new Uint8Array([
2351
+ const k = new Uint8Array([
2352
2352
  0,
2353
2353
  0,
2354
2354
  0,
@@ -2430,7 +2430,7 @@ const T = new Uint8Array([
2430
2430
  0
2431
2431
  // 60: personal
2432
2432
  ]);
2433
- function ee(e, r, t, a) {
2433
+ function Z(e, r, t, a) {
2434
2434
  if (e === 0 || e > 64)
2435
2435
  throw new Error("Illegal output length, expected 0 < length <= 64");
2436
2436
  if (r && r.length > 64)
@@ -2449,51 +2449,51 @@ function ee(e, r, t, a) {
2449
2449
  outlen: e
2450
2450
  // output length in bytes
2451
2451
  };
2452
- T.fill(0), T[0] = e, r && (T[1] = r.length), T[2] = 1, T[3] = 1, t && T.set(t, 32), a && T.set(a, 48);
2452
+ k.fill(0), k[0] = e, r && (k[1] = r.length), k[2] = 1, k[3] = 1, t && k.set(t, 32), a && k.set(a, 48);
2453
2453
  for (let l = 0; l < 16; l++)
2454
- o.h[l] = J[l] ^ Q(T, l * 4);
2455
- return r && (F(o, r), o.c = 128), o;
2454
+ o.h[l] = Q[l] ^ $(k, l * 4);
2455
+ return r && (G(o, r), o.c = 128), o;
2456
2456
  }
2457
- function F(e, r) {
2457
+ function G(e, r) {
2458
2458
  for (let t = 0; t < r.length; t++)
2459
- e.c === 128 && (e.t += e.c, Z(e, !1), e.c = 0), e.b[e.c++] = r[t];
2459
+ e.c === 128 && (e.t += e.c, J(e, !1), e.c = 0), e.b[e.c++] = r[t];
2460
2460
  }
2461
- function te(e) {
2461
+ function ee(e) {
2462
2462
  for (e.t += e.c; e.c < 128; )
2463
2463
  e.b[e.c++] = 0;
2464
- Z(e, !0);
2464
+ J(e, !0);
2465
2465
  const r = new Uint8Array(e.outlen);
2466
2466
  for (let t = 0; t < e.outlen; t++)
2467
2467
  r[t] = e.h[t >> 2] >> 8 * (t & 3);
2468
2468
  return r;
2469
2469
  }
2470
- function re(e, r, t, a, o) {
2471
- t = t || 64, e = H.normalizeInput(e), a && (a = H.normalizeInput(a)), o && (o = H.normalizeInput(o));
2472
- const l = ee(t, r, a, o);
2473
- return F(l, e), te(l);
2470
+ function te(e, r, t, a, o) {
2471
+ t = t || 64, e = L.normalizeInput(e), a && (a = L.normalizeInput(a)), o && (o = L.normalizeInput(o));
2472
+ const l = Z(t, r, a, o);
2473
+ return G(l, e), ee(l);
2474
2474
  }
2475
- function ve(e, r, t, a, o) {
2476
- const l = re(e, r, t, a, o);
2477
- return H.toHex(l);
2475
+ function Se(e, r, t, a, o) {
2476
+ const l = te(e, r, t, a, o);
2477
+ return L.toHex(l);
2478
2478
  }
2479
- var Re = {
2480
- blake2b: re,
2481
- blake2bHex: ve,
2482
- blake2bInit: ee,
2483
- blake2bUpdate: F,
2484
- blake2bFinal: te
2479
+ var ve = {
2480
+ blake2b: te,
2481
+ blake2bHex: Se,
2482
+ blake2bInit: Z,
2483
+ blake2bUpdate: G,
2484
+ blake2bFinal: ee
2485
2485
  };
2486
- const ae = X;
2487
- function Ne(e, r) {
2486
+ const re = X;
2487
+ function Re(e, r) {
2488
2488
  return e[r] ^ e[r + 1] << 8 ^ e[r + 2] << 16 ^ e[r + 3] << 24;
2489
2489
  }
2490
- function k(e, r, t, a, o, l) {
2491
- c[e] = c[e] + c[r] + o, c[a] = M(c[a] ^ c[e], 16), c[t] = c[t] + c[a], c[r] = M(c[r] ^ c[t], 12), c[e] = c[e] + c[r] + l, c[a] = M(c[a] ^ c[e], 8), c[t] = c[t] + c[a], c[r] = M(c[r] ^ c[t], 7);
2490
+ function T(e, r, t, a, o, l) {
2491
+ c[e] = c[e] + c[r] + o, c[a] = P(c[a] ^ c[e], 16), c[t] = c[t] + c[a], c[r] = P(c[r] ^ c[t], 12), c[e] = c[e] + c[r] + l, c[a] = P(c[a] ^ c[e], 8), c[t] = c[t] + c[a], c[r] = P(c[r] ^ c[t], 7);
2492
2492
  }
2493
- function M(e, r) {
2493
+ function P(e, r) {
2494
2494
  return e >>> r ^ e << 32 - r;
2495
2495
  }
2496
- const oe = new Uint32Array([
2496
+ const ae = new Uint32Array([
2497
2497
  1779033703,
2498
2498
  3144134277,
2499
2499
  1013904242,
@@ -2502,7 +2502,7 @@ const oe = new Uint32Array([
2502
2502
  2600822924,
2503
2503
  528734635,
2504
2504
  1541459225
2505
- ]), E = new Uint8Array([
2505
+ ]), I = new Uint8Array([
2506
2506
  0,
2507
2507
  1,
2508
2508
  2,
@@ -2664,25 +2664,25 @@ const oe = new Uint32Array([
2664
2664
  13,
2665
2665
  0
2666
2666
  ]), c = new Uint32Array(16), f = new Uint32Array(16);
2667
- function ne(e, r) {
2667
+ function oe(e, r) {
2668
2668
  let t = 0;
2669
2669
  for (t = 0; t < 8; t++)
2670
- c[t] = e.h[t], c[t + 8] = oe[t];
2670
+ c[t] = e.h[t], c[t + 8] = ae[t];
2671
2671
  for (c[12] ^= e.t, c[13] ^= e.t / 4294967296, r && (c[14] = ~c[14]), t = 0; t < 16; t++)
2672
- f[t] = Ne(e.b, 4 * t);
2672
+ f[t] = Re(e.b, 4 * t);
2673
2673
  for (t = 0; t < 10; t++)
2674
- k(0, 4, 8, 12, f[E[t * 16 + 0]], f[E[t * 16 + 1]]), k(1, 5, 9, 13, f[E[t * 16 + 2]], f[E[t * 16 + 3]]), k(2, 6, 10, 14, f[E[t * 16 + 4]], f[E[t * 16 + 5]]), k(3, 7, 11, 15, f[E[t * 16 + 6]], f[E[t * 16 + 7]]), k(0, 5, 10, 15, f[E[t * 16 + 8]], f[E[t * 16 + 9]]), k(1, 6, 11, 12, f[E[t * 16 + 10]], f[E[t * 16 + 11]]), k(2, 7, 8, 13, f[E[t * 16 + 12]], f[E[t * 16 + 13]]), k(3, 4, 9, 14, f[E[t * 16 + 14]], f[E[t * 16 + 15]]);
2674
+ T(0, 4, 8, 12, f[I[t * 16 + 0]], f[I[t * 16 + 1]]), T(1, 5, 9, 13, f[I[t * 16 + 2]], f[I[t * 16 + 3]]), T(2, 6, 10, 14, f[I[t * 16 + 4]], f[I[t * 16 + 5]]), T(3, 7, 11, 15, f[I[t * 16 + 6]], f[I[t * 16 + 7]]), T(0, 5, 10, 15, f[I[t * 16 + 8]], f[I[t * 16 + 9]]), T(1, 6, 11, 12, f[I[t * 16 + 10]], f[I[t * 16 + 11]]), T(2, 7, 8, 13, f[I[t * 16 + 12]], f[I[t * 16 + 13]]), T(3, 4, 9, 14, f[I[t * 16 + 14]], f[I[t * 16 + 15]]);
2675
2675
  for (t = 0; t < 8; t++)
2676
2676
  e.h[t] ^= c[t] ^ c[t + 8];
2677
2677
  }
2678
- function ie(e, r) {
2678
+ function ne(e, r) {
2679
2679
  if (!(e > 0 && e <= 32))
2680
2680
  throw new Error("Incorrect output length, should be in [1, 32]");
2681
2681
  const t = r ? r.length : 0;
2682
2682
  if (r && !(t > 0 && t <= 32))
2683
2683
  throw new Error("Incorrect key length, should be in [1, 32]");
2684
2684
  const a = {
2685
- h: new Uint32Array(oe),
2685
+ h: new Uint32Array(ae),
2686
2686
  // hash state
2687
2687
  b: new Uint8Array(64),
2688
2688
  // input block
@@ -2693,177 +2693,176 @@ function ie(e, r) {
2693
2693
  outlen: e
2694
2694
  // output length in bytes
2695
2695
  };
2696
- return a.h[0] ^= 16842752 ^ t << 8 ^ e, t > 0 && (j(a, r), a.c = 64), a;
2696
+ return a.h[0] ^= 16842752 ^ t << 8 ^ e, t > 0 && (F(a, r), a.c = 64), a;
2697
2697
  }
2698
- function j(e, r) {
2698
+ function F(e, r) {
2699
2699
  for (let t = 0; t < r.length; t++)
2700
- e.c === 64 && (e.t += e.c, ne(e, !1), e.c = 0), e.b[e.c++] = r[t];
2700
+ e.c === 64 && (e.t += e.c, oe(e, !1), e.c = 0), e.b[e.c++] = r[t];
2701
2701
  }
2702
- function se(e) {
2702
+ function ie(e) {
2703
2703
  for (e.t += e.c; e.c < 64; )
2704
2704
  e.b[e.c++] = 0;
2705
- ne(e, !0);
2705
+ oe(e, !0);
2706
2706
  const r = new Uint8Array(e.outlen);
2707
2707
  for (let t = 0; t < e.outlen; t++)
2708
2708
  r[t] = e.h[t >> 2] >> 8 * (t & 3) & 255;
2709
2709
  return r;
2710
2710
  }
2711
- function le(e, r, t) {
2712
- t = t || 32, e = ae.normalizeInput(e);
2713
- const a = ie(t, r);
2714
- return j(a, e), se(a);
2711
+ function se(e, r, t) {
2712
+ t = t || 32, e = re.normalizeInput(e);
2713
+ const a = ne(t, r);
2714
+ return F(a, e), ie(a);
2715
2715
  }
2716
- function Te(e, r, t) {
2717
- const a = le(e, r, t);
2718
- return ae.toHex(a);
2716
+ function Ne(e, r, t) {
2717
+ const a = se(e, r, t);
2718
+ return re.toHex(a);
2719
2719
  }
2720
2720
  var ke = {
2721
- blake2s: le,
2722
- blake2sHex: Te,
2723
- blake2sInit: ie,
2724
- blake2sUpdate: j,
2725
- blake2sFinal: se
2721
+ blake2s: se,
2722
+ blake2sHex: Ne,
2723
+ blake2sInit: ne,
2724
+ blake2sUpdate: F,
2725
+ blake2sFinal: ie
2726
2726
  };
2727
- const U = Re, C = ke;
2728
- var G = {
2729
- blake2b: U.blake2b,
2730
- blake2bHex: U.blake2bHex,
2731
- blake2bInit: U.blake2bInit,
2732
- blake2bUpdate: U.blake2bUpdate,
2733
- blake2bFinal: U.blake2bFinal,
2734
- blake2s: C.blake2s,
2735
- blake2sHex: C.blake2sHex,
2736
- blake2sInit: C.blake2sInit,
2737
- blake2sUpdate: C.blake2sUpdate,
2738
- blake2sFinal: C.blake2sFinal
2727
+ const O = ve, U = ke;
2728
+ var V = {
2729
+ blake2b: O.blake2b,
2730
+ blake2bHex: O.blake2bHex,
2731
+ blake2bInit: O.blake2bInit,
2732
+ blake2bUpdate: O.blake2bUpdate,
2733
+ blake2bFinal: O.blake2bFinal,
2734
+ blake2s: U.blake2s,
2735
+ blake2sHex: U.blake2sHex,
2736
+ blake2sInit: U.blake2sInit,
2737
+ blake2sUpdate: U.blake2sUpdate,
2738
+ blake2sFinal: U.blake2sFinal
2739
2739
  };
2740
- const D = {};
2741
- let L;
2742
- const De = new Uint8Array(16);
2743
- function Oe() {
2744
- if (!L && (L = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !L))
2740
+ let M;
2741
+ const Te = new Uint8Array(16);
2742
+ function De() {
2743
+ if (!M && (M = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !M))
2745
2744
  throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
2746
- return L(De);
2745
+ return M(Te);
2747
2746
  }
2748
2747
  const b = [];
2749
2748
  for (let e = 0; e < 256; ++e)
2750
2749
  b.push((e + 256).toString(16).slice(1));
2751
- function Ue(e, r = 0) {
2750
+ function Oe(e, r = 0) {
2752
2751
  return (b[e[r + 0]] + b[e[r + 1]] + b[e[r + 2]] + b[e[r + 3]] + "-" + b[e[r + 4]] + b[e[r + 5]] + "-" + b[e[r + 6]] + b[e[r + 7]] + "-" + b[e[r + 8]] + b[e[r + 9]] + "-" + b[e[r + 10]] + b[e[r + 11]] + b[e[r + 12]] + b[e[r + 13]] + b[e[r + 14]] + b[e[r + 15]]).toLowerCase();
2753
2752
  }
2754
- const Ce = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), W = {
2755
- randomUUID: Ce
2753
+ const Ue = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), Y = {
2754
+ randomUUID: Ue
2756
2755
  };
2757
- function xe(e, r, t) {
2758
- if (W.randomUUID && !r && !e)
2759
- return W.randomUUID();
2756
+ function Ce(e, r, t) {
2757
+ if (Y.randomUUID && !r && !e)
2758
+ return Y.randomUUID();
2760
2759
  e = e || {};
2761
- const a = e.random || (e.rng || Oe)();
2760
+ const a = e.random || (e.rng || De)();
2762
2761
  if (a[6] = a[6] & 15 | 64, a[8] = a[8] & 63 | 128, r) {
2763
2762
  t = t || 0;
2764
2763
  for (let o = 0; o < 16; ++o)
2765
2764
  r[t + o] = a[o];
2766
2765
  return r;
2767
2766
  }
2768
- return Ue(a);
2767
+ return Oe(a);
2769
2768
  }
2770
- const $ = "aes-128-ctr", Be = "pbkdf2", Pe = "hmac-sha256", Me = 32, Le = 262144, ce = "sha256", He = "xchain-keystore", Ve = (e) => e < 16 ? `0${e.toString(16)}` : e.toString(16), Ge = (e) => Array.from(e).map(Ve).join(""), ue = (e) => {
2769
+ const W = "aes-128-ctr", xe = "pbkdf2", Be = "hmac-sha256", Pe = 32, Me = 262144, le = "sha256", Le = "xchain-keystore", He = (e) => e < 16 ? `0${e.toString(16)}` : e.toString(16), Ve = (e) => Array.from(e).map(He).join(""), ce = () => typeof window > "u", j = () => ce() ? crypto : import("./__vite-browser-external-2447137e.js").then(({ default: e }) => e), ue = (e) => {
2771
2770
  e instanceof Buffer || (e = Buffer.from(e, "hex"));
2772
- const r = G.blake2bInit(32);
2773
- return G.blake2bUpdate(r, e), Ge(G.blake2bFinal(r));
2774
- }, de = async (e, r, t, a, o) => new Promise((l, d) => {
2775
- D.pbkdf2(e, r, t, a, o, (I, _) => {
2776
- I ? d(I) : l(_);
2771
+ const r = V.blake2bInit(32);
2772
+ return V.blake2bUpdate(r, e), Ve(V.blake2bFinal(r));
2773
+ }, de = async (e, r, t, a, o) => {
2774
+ const l = await j();
2775
+ return new Promise((p, _) => {
2776
+ l.pbkdf2(e, r, t, a, o, (y, A) => {
2777
+ y ? _(y) : p(A);
2778
+ });
2777
2779
  });
2778
- }), pe = () => typeof window > "u", Ke = async (e, r) => {
2779
- const t = pe() ? require("uuid").v4() : xe(), a = D.randomBytes(32), o = D.randomBytes(16), l = {
2780
- prf: Pe,
2781
- dklen: Me,
2782
- salt: a.toString("hex"),
2783
- c: Le
2784
- }, d = {
2785
- iv: o.toString("hex")
2786
- }, I = await de(
2780
+ }, Ke = async (e, r) => {
2781
+ const t = ce() ? require("uuid").v4() : Ce(), a = await j(), o = a.randomBytes(32), l = a.randomBytes(16), p = {
2782
+ prf: Be,
2783
+ dklen: Pe,
2784
+ salt: o.toString("hex"),
2785
+ c: Me
2786
+ }, _ = {
2787
+ iv: l.toString("hex")
2788
+ }, y = await de(
2787
2789
  Buffer.from(r),
2788
- a,
2789
- l.c,
2790
- l.dklen,
2791
- ce
2792
- ), _ = D.createCipheriv($, I.slice(0, 16), o), S = Buffer.concat([
2793
- _.update(Buffer.from(e, "utf8")),
2794
- _.final()
2795
- ]), u = ue(Buffer.concat([I.slice(16, 32), Buffer.from(S)]));
2790
+ o,
2791
+ p.c,
2792
+ p.dklen,
2793
+ le
2794
+ ), A = a.createCipheriv(W, y.slice(0, 16), l), u = Buffer.concat([
2795
+ A.update(Buffer.from(e, "utf8")),
2796
+ A.final()
2797
+ ]), i = ue(Buffer.concat([y.slice(16, 32), Buffer.from(u)]));
2796
2798
  return {
2797
2799
  crypto: {
2798
- cipher: $,
2799
- ciphertext: S.toString("hex"),
2800
- cipherparams: d,
2801
- kdf: Be,
2802
- kdfparams: l,
2803
- mac: u
2800
+ cipher: W,
2801
+ ciphertext: u.toString("hex"),
2802
+ cipherparams: _,
2803
+ kdf: xe,
2804
+ kdfparams: p,
2805
+ mac: i
2804
2806
  },
2805
2807
  id: t,
2806
2808
  version: 1,
2807
- meta: He
2809
+ meta: Le
2808
2810
  };
2809
- }, Ye = (e = 12) => {
2810
- const r = e === 12 ? 128 : 256;
2811
- return pe() ? be(D.randomBytes(r / 8), K) : ye(K, r);
2812
- }, We = async (e, r) => {
2813
- const t = e.crypto.kdfparams, a = await de(
2811
+ }, qe = (e = 12) => fe(be, e === 12 ? 128 : 256), Ye = async (e, r) => {
2812
+ const t = await j(), a = e.crypto.kdfparams, o = await de(
2814
2813
  Buffer.from(r),
2815
- Buffer.from(t.salt, "hex"),
2816
- t.c,
2817
- t.dklen,
2818
- ce
2819
- ), o = Buffer.from(e.crypto.ciphertext, "hex");
2820
- if (ue(Buffer.concat([a.slice(16, 32), o])) !== e.crypto.mac)
2814
+ Buffer.from(a.salt, "hex"),
2815
+ a.c,
2816
+ a.dklen,
2817
+ le
2818
+ ), l = Buffer.from(e.crypto.ciphertext, "hex");
2819
+ if (ue(Buffer.concat([o.slice(16, 32), l])) !== e.crypto.mac)
2821
2820
  throw new Error("Invalid password");
2822
- const d = D.createDecipheriv(
2821
+ const _ = t.createDecipheriv(
2823
2822
  e.crypto.cipher,
2824
- a.slice(0, 16),
2823
+ o.slice(0, 16),
2825
2824
  Buffer.from(e.crypto.cipherparams.iv, "hex")
2826
2825
  );
2827
- return Buffer.concat([d.update(o), d.final()]).toString("utf8");
2826
+ return Buffer.concat([_.update(l), _.final()]).toString("utf8");
2828
2827
  };
2829
2828
  var n = /* @__PURE__ */ ((e) => (e.INVALID_INPUT_PARAMETERS = "1000", e.UNKNOWN_PROVIDERS = "1001", e.CANNOT_FIND_INBOUND_ADDRESS = "1002", e.NO_INBOUND_ADDRESSES = "1003", e.CHAIN_HALTED_OR_UNSUPPORTED = "1004", e.MISSING_INPUT_PARAMETER = "1005", e.INVALID_TYPE_GENERIC = "1100", e.INVALID_NUMBER_STRING = "1101", e.INVALID_NUMBER = "1102", e.INVALID_BOOLEAN = "1103", e.INVALID_OBJECT = "1104", e.INVALID_ARRAY = "1105", e.SELL_AMOUNT_MUST_BE_POSITIVE_INTEGER = "2000", e.SELL_BUY_ASSETS_ARE_THE_SAME = "2001", e.MISSING_SOURCE_ADDRESS_FOR_SYNTH = "2002", e.AFF_ADDRESS_AND_BPS_OR_NEITHER = "2003", e.AFF_ADDRESS_TOO_LONG = "2004", e.AFF_BPS_INTEGER_0_100 = "2005", e.SOURCE_ADDRESS_INVALID_FOR_SELL_CHAIN = "2006", e.DESTINATION_ADDRESS_INVALID_FOR_BUY_CHAIN = "2007", e.PREFERRED_PROFVIDER_NOT_SUPPORTED = "2008", e.DESTINATION_ADDRESS_SMART_CONTRACT = "2009", e.BUY_AMOUNT_MUST_BE_POSITIVE_INTEGER = "2010", e.SOURCE_ADDRESS_SMART_CONTRACT = "2011", e.INVALID_PROVIDER = "2100", e.MISSING_CROSS_CHAIN_PROVIDER = "2101", e.MISSING_AVAX_PROVIDER = "2102", e.MISSING_BSC_PROVIDER = "2103", e.MISSING_ETH_PROVIDER = "2104", e.INVALID_PROVIDER_FOR_SWAP_OUT = "2105", e.MISSING_ARB_PROVIDER = "2106", e.INVALID_CHAIN = "2200", e.INVALID_ASSET = "2201", e.INVALID_ASSET_IDENTIFIER = "2202", e.UNSUPPORTED_CHAIN = "2204", e.UNSUPPORTED_ASSET = "2203", e.UNSUPPORTED_ASSET_FOR_SWAPOUT = "2205", e.INVALID_SOURCE_ADDRESS = "2300", e.INVALID_DESTINATION_ADDRESS = "2301", e.THORNODE_QUOTE_GENERIC_ERROR = "3000", e.NOT_ENOUGH_SYNTH_BALANCE = "3001", e.SYNTH_MINTING_CAP_REACHED = "3002", e.INVALID_QUOTE_MODE = "4000", e.NO_QUOTES = "4001", e.SERVICE_UNAVAILABLE_GENERIC = "5000", e.MISSING_GAS_DATA_GENERIC = "5100", e.MISSING_TOKEN_INFO_GENERIC = "5200", e.CANT_FIND_TOKEN_LIST = "5201", e.NO_PRICE = "5202", e.PRICE_IS_STALE = "5203", e.ADDRESS_NOT_WHITELISTED = "6000", e.ADDRESS_ALREADY_CLAIMED = "6001", e.TEMPORARY_ERROR = "9999", e))(n || {});
2830
2829
  n.INVALID_INPUT_PARAMETERS + "", n.UNKNOWN_PROVIDERS + "", n.CANNOT_FIND_INBOUND_ADDRESS + "", n.NO_INBOUND_ADDRESSES + "", n.CHAIN_HALTED_OR_UNSUPPORTED + "", n.MISSING_INPUT_PARAMETER + "", n.INVALID_TYPE_GENERIC + "", n.INVALID_NUMBER_STRING + "", n.INVALID_NUMBER + "", n.INVALID_BOOLEAN + "", n.INVALID_OBJECT + "", n.INVALID_ARRAY + "", n.SELL_AMOUNT_MUST_BE_POSITIVE_INTEGER + "", n.SELL_BUY_ASSETS_ARE_THE_SAME + "", n.MISSING_SOURCE_ADDRESS_FOR_SYNTH + "", n.AFF_ADDRESS_AND_BPS_OR_NEITHER + "", n.AFF_ADDRESS_TOO_LONG + "", n.AFF_BPS_INTEGER_0_100 + "", n.SOURCE_ADDRESS_INVALID_FOR_SELL_CHAIN + "", n.DESTINATION_ADDRESS_INVALID_FOR_BUY_CHAIN + "", n.PREFERRED_PROFVIDER_NOT_SUPPORTED + "", n.DESTINATION_ADDRESS_SMART_CONTRACT + "", n.BUY_AMOUNT_MUST_BE_POSITIVE_INTEGER + "", n.INVALID_PROVIDER + "", n.MISSING_CROSS_CHAIN_PROVIDER + "", n.MISSING_AVAX_PROVIDER + "", n.MISSING_BSC_PROVIDER + "", n.MISSING_ETH_PROVIDER + "", n.MISSING_ARB_PROVIDER + "", n.INVALID_PROVIDER_FOR_SWAP_OUT + "", n.INVALID_CHAIN + "", n.INVALID_ASSET + "", n.UNSUPPORTED_CHAIN + "", n.UNSUPPORTED_ASSET + "", n.UNSUPPORTED_ASSET_FOR_SWAPOUT + "", n.THORNODE_QUOTE_GENERIC_ERROR + "", n.INVALID_SOURCE_ADDRESS + "", n.INVALID_DESTINATION_ADDRESS + "", n.NOT_ENOUGH_SYNTH_BALANCE + "", n.SYNTH_MINTING_CAP_REACHED + "", n.INVALID_QUOTE_MODE + "", n.NO_QUOTES + "", n.SERVICE_UNAVAILABLE_GENERIC + "", n.MISSING_GAS_DATA_GENERIC + "", n.MISSING_TOKEN_INFO_GENERIC + "", n.CANT_FIND_TOKEN_LIST + "", n.NO_PRICE + "", n.PRICE_IS_STALE + "", n.ADDRESS_NOT_WHITELISTED + "", n.ADDRESS_ALREADY_CLAIMED + "";
2831
- var m = /* @__PURE__ */ ((e) => (e.Arbitrum = "ARB", e.Avalanche = "AVAX", e.Binance = "BNB", e.BinanceSmartChain = "BSC", e.Bitcoin = "BTC", e.BitcoinCash = "BCH", e.Cosmos = "GAIA", e.Dogecoin = "DOGE", e.Ethereum = "ETH", e.Litecoin = "LTC", e.Maya = "MAYA", e.Optimism = "OP", e.Polygon = "MATIC", e.THORChain = "THOR", e))(m || {}), me = /* @__PURE__ */ ((e) => (e.ARB = "m/44'/60'/0'/0", e.AVAX = "m/44'/60'/0'/0", e.BCH = "m/44'/145'/0'/0", e.BNB = "m/44'/714'/0'/0", e.BSC = "m/44'/60'/0'/0", e.BTC = "m/84'/0'/0'/0", e.DOGE = "m/44'/3'/0'/0", e.ETH = "m/44'/60'/0'/0", e.GAIA = "m/44'/118'/0'/0", e.LTC = "m/84'/2'/0'/0", e.MATIC = "m/44'/60'/0'/0", e.MAYA = "m/44'/931'/0'/0", e.OP = "m/44'/60'/0'/0", e.THOR = "m/44'/931'/0'/0", e))(me || {}), z = /* @__PURE__ */ ((e) => (e.Arbitrum = "42161", e.ArbitrumHex = "0xa4b1", e.Avalanche = "43114", e.AvalancheHex = "0xa86a", e.Binance = "Binance-Chain-Tigris", e.BinanceSmartChain = "56", e.BinanceSmartChainHex = "0x38", e.Bitcoin = "bitcoin", e.BitcoinCash = "bitcoincash", e.Cosmos = "cosmoshub-4", e.Dogecoin = "dogecoin", e.Ethereum = "1", e.EthereumHex = "0x1", e.Litecoin = "litecoin", e.Maya = "mayachain-mainnet-v1", e.MayaStagenet = "mayachain-stagenet-v1", e.Optimism = "10", e.OptimismHex = "0xa", e.Polygon = "137", e.PolygonHex = "0x89", e.THORChain = "thorchain-mainnet-v1", e.THORChainStagenet = "thorchain-stagenet-v2", e))(z || {}), he = /* @__PURE__ */ ((e) => (e.Arbitrum = "https://arb1.arbitrum.io/rpc", e.Avalanche = "https://node-router.thorswap.net/avalanche-c", e.Binance = "", e.BinanceSmartChain = "https://bsc-dataseed.binance.org", e.Bitcoin = "https://node-router.thorswap.net/bitcoin", e.BitcoinCash = "https://node-router.thorswap.net/bitcoin-cash", e.Cosmos = "https://node-router.thorswap.net/cosmos/rpc", e.Dogecoin = "https://node-router.thorswap.net/dogecoin", e.Ethereum = "https://node-router.thorswap.net/ethereum", e.Litecoin = "https://node-router.thorswap.net/litecoin", e.Maya = "https://tendermint.mayachain.info", e.MayaStagenet = "https://stagenet.tendermint.mayachain.info", e.Optimism = "https://mainnet.optimism.io", e.Polygon = "https://polygon-rpc.com", e.THORChain = "https://rpc.thorswap.net", e.THORChainStagenet = "https://stagenet-rpc.ninerealms.com", e))(he || {});
2832
- const V = Object.values(m), Fe = Object.keys(m), q = V.reduce(
2830
+ var m = /* @__PURE__ */ ((e) => (e.Arbitrum = "ARB", e.Avalanche = "AVAX", e.Binance = "BNB", e.BinanceSmartChain = "BSC", e.Bitcoin = "BTC", e.BitcoinCash = "BCH", e.Cosmos = "GAIA", e.Dogecoin = "DOGE", e.Ethereum = "ETH", e.Kujira = "KUJI", e.Litecoin = "LTC", e.Maya = "MAYA", e.Optimism = "OP", e.Polygon = "MATIC", e.THORChain = "THOR", e))(m || {}), pe = /* @__PURE__ */ ((e) => (e.ARB = "m/44'/60'/0'/0", e.AVAX = "m/44'/60'/0'/0", e.BCH = "m/44'/145'/0'/0", e.BNB = "m/44'/714'/0'/0", e.BSC = "m/44'/60'/0'/0", e.BTC = "m/84'/0'/0'/0", e.DOGE = "m/44'/3'/0'/0", e.ETH = "m/44'/60'/0'/0", e.GAIA = "m/44'/118'/0'/0", e.KUJI = "m/44'/118'/0'/0", e.LTC = "m/84'/2'/0'/0", e.MATIC = "m/44'/60'/0'/0", e.MAYA = "m/44'/931'/0'/0", e.OP = "m/44'/60'/0'/0", e.THOR = "m/44'/931'/0'/0", e))(pe || {}), z = /* @__PURE__ */ ((e) => (e.Arbitrum = "42161", e.ArbitrumHex = "0xa4b1", e.Avalanche = "43114", e.AvalancheHex = "0xa86a", e.Binance = "Binance-Chain-Tigris", e.BinanceSmartChain = "56", e.BinanceSmartChainHex = "0x38", e.Bitcoin = "bitcoin", e.BitcoinCash = "bitcoincash", e.Cosmos = "cosmoshub-4", e.Dogecoin = "dogecoin", e.Kujira = "kaiyo-1", e.Ethereum = "1", e.EthereumHex = "0x1", e.Litecoin = "litecoin", e.Maya = "mayachain-mainnet-v1", e.MayaStagenet = "mayachain-stagenet-v1", e.Optimism = "10", e.OptimismHex = "0xa", e.Polygon = "137", e.PolygonHex = "0x89", e.THORChain = "thorchain-mainnet-v1", e.THORChainStagenet = "thorchain-stagenet-v2", e))(z || {}), me = /* @__PURE__ */ ((e) => (e.Arbitrum = "https://arb1.arbitrum.io/rpc", e.Avalanche = "https://node-router.thorswap.net/avalanche-c", e.Binance = "", e.BinanceSmartChain = "https://bsc-dataseed.binance.org", e.Bitcoin = "https://node-router.thorswap.net/bitcoin", e.BitcoinCash = "https://node-router.thorswap.net/bitcoin-cash", e.Cosmos = "https://node-router.thorswap.net/cosmos/rpc", e.Kujira = "https://rpc-kujira.synergynodes.com/", e.Dogecoin = "https://node-router.thorswap.net/dogecoin", e.Ethereum = "https://node-router.thorswap.net/ethereum", e.Litecoin = "https://node-router.thorswap.net/litecoin", e.Maya = "https://tendermint.mayachain.info", e.MayaStagenet = "https://stagenet.tendermint.mayachain.info", e.Optimism = "https://mainnet.optimism.io", e.Polygon = "https://polygon-rpc.com", e.THORChain = "https://rpc.thorswap.net", e.THORChainStagenet = "https://stagenet-rpc.ninerealms.com", e))(me || {});
2831
+ const H = Object.values(m), Ge = Object.keys(m), K = H.reduce(
2833
2832
  (e, r) => {
2834
- const t = Fe.find((a) => m[a] === r);
2833
+ const t = Ge.find((a) => m[a] === r);
2835
2834
  return t && (e[r] = t), e;
2836
2835
  },
2837
2836
  {}
2838
2837
  );
2839
- V.reduce(
2840
- (e, r) => (e[r] = z[q[r]], e),
2838
+ H.reduce(
2839
+ (e, r) => (e[r] = z[K[r]], e),
2841
2840
  {}
2842
2841
  );
2843
- V.reduce(
2844
- (e, r) => (e[r] = he[q[r]], e),
2842
+ H.reduce(
2843
+ (e, r) => (e[r] = me[K[r]], e),
2845
2844
  {}
2846
2845
  );
2847
- V.reduce(
2846
+ H.reduce(
2848
2847
  (e, r) => {
2849
- const t = `${q[r]}Hex`;
2848
+ const t = `${K[r]}Hex`;
2850
2849
  return e[r] = z[t], e;
2851
2850
  },
2852
2851
  {}
2853
2852
  );
2854
- var ge = /* @__PURE__ */ ((e) => (e.KEYSTORE = "KEYSTORE", e.XDEFI = "XDEFI", e.METAMASK = "METAMASK", e.COINBASE_WEB = "COINBASE_WEB", e.TREZOR = "TREZOR", e.TRUSTWALLET_WEB = "TRUSTWALLET_WEB", e.LEDGER = "LEDGER", e.KEPLR = "KEPLR", e.OKX = "OKX", e.BRAVE = "BRAVE", e.WALLETCONNECT = "WALLETCONNECT", e))(ge || {});
2855
- const je = async ({
2853
+ var he = /* @__PURE__ */ ((e) => (e.KEYSTORE = "KEYSTORE", e.XDEFI = "XDEFI", e.METAMASK = "METAMASK", e.COINBASE_WEB = "COINBASE_WEB", e.TREZOR = "TREZOR", e.TRUSTWALLET_WEB = "TRUSTWALLET_WEB", e.LEDGER = "LEDGER", e.KEPLR = "KEPLR", e.OKX = "OKX", e.BRAVE = "BRAVE", e.WALLETCONNECT = "WALLETCONNECT", e))(he || {});
2854
+ const Fe = async ({
2856
2855
  api: e,
2857
2856
  rpcUrl: r,
2858
2857
  chain: t,
2859
2858
  phrase: a,
2860
2859
  ethplorerApiKey: o,
2861
2860
  covalentApiKey: l,
2862
- utxoApiKey: d,
2863
- index: I,
2864
- stagenet: _
2861
+ utxoApiKey: p,
2862
+ index: _,
2863
+ stagenet: y
2865
2864
  }) => {
2866
- const S = `${me[t]}/${I}`;
2865
+ const A = `${pe[t]}/${_}`;
2867
2866
  switch (t) {
2868
2867
  case m.BinanceSmartChain:
2869
2868
  case m.Avalanche:
@@ -2872,7 +2871,7 @@ const je = async ({
2872
2871
  throw new Error("Ethplorer API key not found");
2873
2872
  if (!l)
2874
2873
  throw new Error("Covalent API key not found");
2875
- const { HDNodeWallet: u } = await import("ethers"), { getProvider: s, ETHToolbox: h, AVAXToolbox: p, BSCToolbox: w } = await import("@swapkit/toolbox-evm"), v = s(t, r), g = u.fromPhrase(a).connect(v), A = { api: e, provider: v, signer: g }, R = t === m.Ethereum ? h({ ...A, ethplorerApiKey: o }) : t === m.Avalanche ? p({ ...A, covalentApiKey: l }) : w({ ...A, covalentApiKey: l });
2874
+ const { HDNodeWallet: u } = await import("ethers"), { getProvider: i, ETHToolbox: h, AVAXToolbox: d, BSCToolbox: S } = await import("@swapkit/toolbox-evm"), v = i(t, r), g = u.fromPhrase(a).connect(v), w = { api: e, provider: v, signer: g }, R = t === m.Ethereum ? h({ ...w, ethplorerApiKey: o }) : t === m.Avalanche ? d({ ...w, covalentApiKey: l }) : S({ ...w, covalentApiKey: l });
2876
2875
  return {
2877
2876
  address: g.address,
2878
2877
  walletMethods: {
@@ -2882,106 +2881,119 @@ const je = async ({
2882
2881
  };
2883
2882
  }
2884
2883
  case m.BitcoinCash: {
2885
- if (!d)
2884
+ if (!p)
2886
2885
  throw new Error("UTXO API key not found");
2887
- const { BCHToolbox: u } = await import("@swapkit/toolbox-utxo"), s = u({ rpcUrl: r, apiKey: d, apiClient: e }), h = await s.createKeysForPath({ phrase: a, derivationPath: S }), p = s.getAddressFromKeys(h), w = async ({
2886
+ const { BCHToolbox: u } = await import("@swapkit/toolbox-utxo"), i = u({ rpcUrl: r, apiKey: p, apiClient: e }), h = await i.createKeysForPath({ phrase: a, derivationPath: A }), d = i.getAddressFromKeys(h), S = async ({
2888
2887
  builder: g,
2889
- utxos: A
2890
- }) => (A.forEach((R, O) => {
2891
- g.sign(O, h, void 0, 65, R.witnessUtxo.value);
2888
+ utxos: w
2889
+ }) => (w.forEach((R, D) => {
2890
+ g.sign(D, h, void 0, 65, R.witnessUtxo.value);
2892
2891
  }), g.build()), v = {
2893
- ...s,
2894
- getAddress: () => p,
2895
- transfer: (g) => s.transfer({ ...g, from: p, signTransaction: w })
2892
+ ...i,
2893
+ getAddress: () => d,
2894
+ transfer: (g) => i.transfer({ ...g, from: d, signTransaction: S })
2896
2895
  };
2897
- return { address: p, walletMethods: v };
2896
+ return { address: d, walletMethods: v };
2898
2897
  }
2899
2898
  case m.Bitcoin:
2900
2899
  case m.Dogecoin:
2901
2900
  case m.Litecoin: {
2902
- const u = { rpcUrl: r, apiKey: d, apiClient: e }, { BTCToolbox: s, LTCToolbox: h, DOGEToolbox: p } = await import("@swapkit/toolbox-utxo"), w = t === m.Bitcoin ? s(u) : t === m.Litecoin ? h(u) : p(u), v = await w.createKeysForPath({ phrase: a, derivationPath: S }), g = w.getAddressFromKeys(v), A = async (R) => (R.signAllInputs(v), R);
2901
+ const u = { rpcUrl: r, apiKey: p, apiClient: e }, { BTCToolbox: i, LTCToolbox: h, DOGEToolbox: d } = await import("@swapkit/toolbox-utxo"), S = t === m.Bitcoin ? i(u) : t === m.Litecoin ? h(u) : d(u), v = await S.createKeysForPath({ phrase: a, derivationPath: A }), g = S.getAddressFromKeys(v), w = async (R) => (R.signAllInputs(v), R);
2903
2902
  return {
2904
2903
  address: g,
2905
2904
  walletMethods: {
2906
- ...w,
2905
+ ...S,
2907
2906
  getAddress: () => g,
2908
- transfer: (R) => w.transfer({ ...R, from: g, signTransaction: A })
2907
+ transfer: (R) => S.transfer({ ...R, from: g, signTransaction: w })
2909
2908
  }
2910
2909
  };
2911
2910
  }
2912
2911
  case m.Binance: {
2913
- const { BinanceToolbox: u } = await import("@swapkit/toolbox-cosmos"), s = u(), h = await s.createKeyPair(a), p = await s.getAddressFromMnemonic(a);
2912
+ const { BinanceToolbox: u } = await import("@swapkit/toolbox-cosmos"), i = u(), h = await i.createKeyPair(a), d = await i.getAddressFromMnemonic(a);
2914
2913
  return {
2915
- address: p,
2916
- walletMethods: { ...s, transfer: ({ assetValue: v, recipient: g, memo: A }) => s.transfer({
2917
- from: p,
2914
+ address: d,
2915
+ walletMethods: { ...i, transfer: ({ assetValue: v, recipient: g, memo: w }) => i.transfer({
2916
+ from: d,
2918
2917
  recipient: g,
2919
2918
  assetValue: v,
2920
2919
  privkey: h,
2921
- memo: A
2922
- }), getAddress: () => p }
2920
+ memo: w
2921
+ }), getAddress: () => d }
2923
2922
  };
2924
2923
  }
2925
2924
  case m.Cosmos: {
2926
- const { GaiaToolbox: u } = await import("@swapkit/toolbox-cosmos"), s = u({ server: e }), h = await s.getSigner(a), p = await s.getAddressFromMnemonic(a);
2925
+ const { GaiaToolbox: u } = await import("@swapkit/toolbox-cosmos"), i = u({ server: e }), h = await i.getSigner(a), d = await i.getAddressFromMnemonic(a);
2926
+ return {
2927
+ address: d,
2928
+ walletMethods: { ...i, transfer: ({ assetValue: v, recipient: g, memo: w }) => i.transfer({
2929
+ from: d,
2930
+ recipient: g,
2931
+ signer: h,
2932
+ assetValue: v,
2933
+ memo: w
2934
+ }), getAddress: () => d }
2935
+ };
2936
+ }
2937
+ case m.Kujira: {
2938
+ const { KujiraToolbox: u } = await import("@swapkit/toolbox-cosmos"), i = u({ server: e }), h = await i.getSigner(a), d = await i.getAddressFromMnemonic(a);
2927
2939
  return {
2928
- address: p,
2929
- walletMethods: { ...s, transfer: ({ assetValue: v, recipient: g, memo: A }) => s.transfer({
2930
- from: p,
2940
+ address: d,
2941
+ walletMethods: { ...i, transfer: ({ assetValue: v, recipient: g, memo: w }) => i.transfer({
2942
+ from: d,
2931
2943
  recipient: g,
2932
2944
  signer: h,
2933
2945
  assetValue: v,
2934
- memo: A
2935
- }), getAddress: () => p }
2946
+ memo: w
2947
+ }), getAddress: () => d }
2936
2948
  };
2937
2949
  }
2938
2950
  case m.Maya:
2939
2951
  case m.THORChain: {
2940
- const { MayaToolbox: u, ThorchainToolbox: s } = await import("@swapkit/toolbox-cosmos"), h = t === m.THORChain ? s({ stagenet: _ }) : u({ stagenet: _ }), p = await h.getAddressFromMnemonic(a), w = await h.getSigner(a), A = { ...h, deposit: async ({ assetValue: R, memo: O }) => h.deposit({ assetValue: R, memo: O, from: p, signer: w }), transfer: async ({ assetValue: R, recipient: O, memo: fe }) => h.transfer({
2941
- from: p,
2942
- recipient: O,
2943
- signer: w,
2952
+ const { MayaToolbox: u, ThorchainToolbox: i } = await import("@swapkit/toolbox-cosmos"), h = t === m.THORChain ? i({ stagenet: y }) : u({ stagenet: y }), d = await h.getAddressFromMnemonic(a), S = await h.getSigner(a), w = { ...h, deposit: async ({ assetValue: R, memo: D }) => h.deposit({ assetValue: R, memo: D, from: d, signer: S }), transfer: async ({ assetValue: R, recipient: D, memo: ge }) => h.transfer({
2953
+ from: d,
2954
+ recipient: D,
2955
+ signer: S,
2944
2956
  assetValue: R,
2945
- memo: fe
2946
- }), getAddress: () => p };
2947
- return { address: p, walletMethods: A };
2957
+ memo: ge
2958
+ }), getAddress: () => d };
2959
+ return { address: d, walletMethods: w };
2948
2960
  }
2949
2961
  default:
2950
2962
  throw new Error(`Unsupported chain ${t}`);
2951
2963
  }
2952
- }, ze = ({
2964
+ }, je = ({
2953
2965
  addChain: e,
2954
2966
  apis: r,
2955
2967
  rpcUrls: t,
2956
- config: { covalentApiKey: a, ethplorerApiKey: o, utxoApiKey: l, stagenet: d }
2957
- }) => async (I, _, S = 0) => {
2958
- const u = I.map(async (s) => {
2959
- const { address: h, walletMethods: p } = await je({
2960
- index: S,
2961
- chain: s,
2962
- api: r[s],
2963
- rpcUrl: t[s],
2968
+ config: { covalentApiKey: a, ethplorerApiKey: o, utxoApiKey: l, stagenet: p }
2969
+ }) => async (_, y, A = 0) => {
2970
+ const u = _.map(async (i) => {
2971
+ const { address: h, walletMethods: d } = await Fe({
2972
+ index: A,
2973
+ chain: i,
2974
+ api: r[i],
2975
+ rpcUrl: t[i],
2964
2976
  covalentApiKey: a,
2965
2977
  ethplorerApiKey: o,
2966
- phrase: _,
2978
+ phrase: y,
2967
2979
  utxoApiKey: l,
2968
- stagenet: d
2980
+ stagenet: p
2969
2981
  });
2970
2982
  e({
2971
- chain: s,
2972
- walletMethods: p,
2973
- wallet: { address: h, balance: [], walletType: ge.KEYSTORE }
2983
+ chain: i,
2984
+ walletMethods: d,
2985
+ wallet: { address: h, balance: [], walletType: he.KEYSTORE }
2974
2986
  });
2975
2987
  });
2976
2988
  return await Promise.all(u), !0;
2977
- }, $e = {
2989
+ }, We = {
2978
2990
  connectMethodName: "connectKeystore",
2979
- connect: ze
2991
+ connect: je
2980
2992
  };
2981
2993
  export {
2982
2994
  ue as blake256,
2983
- We as decryptFromKeystore,
2995
+ Ye as decryptFromKeystore,
2984
2996
  Ke as encryptToKeyStore,
2985
- Ye as generatePhrase,
2986
- $e as keystoreWallet
2997
+ qe as generatePhrase,
2998
+ We as keystoreWallet
2987
2999
  };
package/package.json CHANGED
@@ -7,6 +7,7 @@
7
7
  },
8
8
  "description": "SwapKit Lib keystore",
9
9
  "devDependencies": {
10
+ "@rollup/plugin-node-resolve": "15.2.3",
10
11
  "@scure/bip39": "1.2.1",
11
12
  "@types/long": "4.0.2",
12
13
  "@types/uniqid": "5.3.2",
@@ -18,9 +19,9 @@
18
19
  "vitest": "0.34.4",
19
20
  "@internal/config": "0.0.0-internal.0",
20
21
  "@swapkit/helpers": "1.0.0-rc.1",
21
- "@swapkit/toolbox-cosmos": "1.0.0-rc.2",
22
+ "@swapkit/toolbox-cosmos": "1.0.0-rc.3",
22
23
  "@swapkit/toolbox-evm": "1.0.0-rc.2",
23
- "@swapkit/toolbox-utxo": "1.0.0-rc.1"
24
+ "@swapkit/toolbox-utxo": "1.0.0-rc.2"
24
25
  },
25
26
  "eslintConfig": {
26
27
  "extends": "../../../internal/eslint-config"
@@ -46,9 +47,9 @@
46
47
  "ethers": "^6.7.1",
47
48
  "bitcoinjs-lib": "^5.2.0",
48
49
  "@swapkit/helpers": "1.0.0-rc.1",
49
- "@swapkit/toolbox-cosmos": "1.0.0-rc.2",
50
+ "@swapkit/toolbox-cosmos": "1.0.0-rc.3",
50
51
  "@swapkit/toolbox-evm": "1.0.0-rc.2",
51
- "@swapkit/toolbox-utxo": "1.0.0-rc.1"
52
+ "@swapkit/toolbox-utxo": "1.0.0-rc.2"
52
53
  },
53
54
  "publishConfig": {
54
55
  "access": "public"
@@ -57,7 +58,7 @@
57
58
  "repository": "https://github.com/thorswap/SwapKit.git",
58
59
  "type": "module",
59
60
  "types": "./dist/index.d.ts",
60
- "version": "1.0.0-rc.3",
61
+ "version": "1.0.0-rc.7",
61
62
  "scripts": {
62
63
  "build": "vite build",
63
64
  "clean": "rm -rf dist vite.config.ts.* .turbo node_modules",
package/src/helpers.ts CHANGED
@@ -1,7 +1,6 @@
1
- import { entropyToMnemonic, generateMnemonic } from '@scure/bip39';
1
+ import { generateMnemonic } from '@scure/bip39';
2
2
  import { wordlist } from '@scure/bip39/wordlists/english';
3
3
  import { blake2bFinal, blake2bInit, blake2bUpdate } from 'blakejs';
4
- import crypto from 'crypto';
5
4
  import { v4 as uuidv4 } from 'uuid';
6
5
 
7
6
  const cipher = 'aes-128-ctr';
@@ -38,6 +37,10 @@ export type Keystore = {
38
37
  */
39
38
  const toHexByte = (byte: number) => (byte < 0x10 ? `0${byte.toString(16)}` : byte.toString(16));
40
39
  const toHex = (buffer: Buffer | Uint8Array) => Array.from(buffer).map(toHexByte).join('');
40
+ const _isNode = () => typeof window === 'undefined';
41
+
42
+ const getCrypto = () =>
43
+ _isNode() ? (crypto as any) : import('crypto').then(({ default: crypto }) => crypto);
41
44
 
42
45
  /**
43
46
  * Gets data's 256 bit blake hash.
@@ -60,8 +63,9 @@ const pbkdf2Async = async (
60
63
  keylen: number,
61
64
  digest: string,
62
65
  ) => {
66
+ const crypto = await getCrypto();
63
67
  return new Promise<Buffer>((resolve, reject) => {
64
- crypto.pbkdf2(passphrase, salt, iterations, keylen, digest, (err, drived) => {
68
+ crypto.pbkdf2(passphrase, salt, iterations, keylen, digest, (err: any, drived: any) => {
65
69
  if (err) {
66
70
  reject(err);
67
71
  } else {
@@ -71,12 +75,9 @@ const pbkdf2Async = async (
71
75
  });
72
76
  };
73
77
 
74
- const _isNode = () => {
75
- return typeof window === 'undefined';
76
- };
77
-
78
78
  export const encryptToKeyStore = async (phrase: string, password: string) => {
79
79
  const ID = _isNode() ? require('uuid').v4() : uuidv4();
80
+ const crypto = await getCrypto();
80
81
  const salt = crypto.randomBytes(32);
81
82
  const iv = crypto.randomBytes(16);
82
83
  const kdfParams = {
@@ -124,14 +125,11 @@ export const encryptToKeyStore = async (phrase: string, password: string) => {
124
125
 
125
126
  export const generatePhrase = (size = 12) => {
126
127
  const entropy = size === 12 ? 128 : 256;
127
- if (_isNode()) {
128
- return entropyToMnemonic(crypto.randomBytes(entropy / 8), wordlist);
129
- } else {
130
- return generateMnemonic(wordlist, entropy);
131
- }
128
+ return generateMnemonic(wordlist, entropy);
132
129
  };
133
130
 
134
131
  export const decryptFromKeystore = async (keystore: Keystore, password: string) => {
132
+ const crypto = await getCrypto();
135
133
  const kdfparams = keystore.crypto.kdfparams;
136
134
  const derivedKey = await pbkdf2Async(
137
135
  Buffer.from(password),
package/src/keystore.ts CHANGED
@@ -179,6 +179,27 @@ const getWalletMethodsForChain = async ({
179
179
  };
180
180
  }
181
181
 
182
+ case Chain.Kujira: {
183
+ const { KujiraToolbox } = await import('@swapkit/toolbox-cosmos');
184
+ const toolbox = KujiraToolbox({ server: api });
185
+ const signer = await toolbox.getSigner(phrase);
186
+ const address = await toolbox.getAddressFromMnemonic(phrase);
187
+
188
+ const transfer = ({ assetValue, recipient, memo }: TransferParams) =>
189
+ toolbox.transfer({
190
+ from: address,
191
+ recipient,
192
+ signer,
193
+ assetValue,
194
+ memo,
195
+ });
196
+
197
+ return {
198
+ address,
199
+ walletMethods: { ...toolbox, transfer, getAddress: () => address },
200
+ };
201
+ }
202
+
182
203
  case Chain.Maya:
183
204
  case Chain.THORChain: {
184
205
  const { MayaToolbox, ThorchainToolbox } = await import('@swapkit/toolbox-cosmos');