@swapkit/wallet-keystore 4.0.43 → 4.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/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- var K=Object.create;var{getPrototypeOf:B,defineProperty:u,getOwnPropertyNames:g,getOwnPropertyDescriptor:D}=Object,v=Object.prototype.hasOwnProperty;var y=(t,a,r)=>{r=t!=null?K(B(t)):{};let n=a||!t||!t.__esModule?u(r,"default",{value:t,enumerable:!0}):r;for(let s of g(t))if(!v.call(n,s))u(n,s,{get:()=>t[s],enumerable:!0});return n},x=new WeakMap,E=(t)=>{var a=x.get(t),r;if(a)return a;if(a=u({},"__esModule",{value:!0}),t&&typeof t==="object"||typeof t==="function")g(t).map((n)=>!v.call(a,n)&&u(a,n,{get:()=>t[n],enumerable:!(r=D(t,n))||r.enumerable}));return x.set(t,a),a};var A=(t,a)=>{for(var r in a)u(t,r,{get:a[r],enumerable:!0,configurable:!0,set:(n)=>a[r]=()=>n})};var O={};A(O,{validatePhrase:()=>R,keystoreWallet:()=>S,generatePhrase:()=>F,encryptToKeyStore:()=>W,decryptFromKeystore:()=>_,createKeystoreWallet:()=>T,KEYSTORE_SUPPORTED_CHAINS:()=>C});module.exports=E(O);var e=require("@swapkit/helpers"),d=require("@swapkit/wallet-core");var p=require("node:crypto"),m=require("@scure/bip39"),w=require("@scure/bip39/wordlists/english");async function k(t){let a=await import("blakejs"),{blake2bFinal:r,blake2bInit:n,blake2bUpdate:s}=a?.default||a,o=t;if(!(o instanceof Buffer))o=Buffer.from(o,"hex");let i=n(32);return s(i,o),Array.from(r(i)).map((c)=>c<16?`0${c.toString(16)}`:c.toString(16)).join("")}async function W(t,a){let n=p.randomBytes(16),s=p.randomBytes(32),o={c:262144,dklen:32,prf:"hmac-sha256",salt:s.toString("hex")},i=p.pbkdf2Sync(a,s,o.c,o.dklen,"sha256"),c=p.createCipheriv("aes-128-ctr",i.subarray(0,16),n),f=Buffer.concat([c.update(Buffer.from(t,"utf8")),c.final()]),l=Buffer.concat([i.subarray(16,32),Buffer.from(f)]),h=await k(l);return{crypto:{cipher:"aes-128-ctr",cipherparams:{iv:n.toString("hex")},ciphertext:f.toString("hex"),kdf:"pbkdf2",kdfparams:o,mac:h},meta:"xchain-keystore",version:1}}function F(t=12){return m.generateMnemonic(w.wordlist,t===12?128:256)}function R(t){return m.validateMnemonic(t,w.wordlist)}async function _(t,a){let{SwapKitError:r}=await import("@swapkit/helpers");switch(t.version){case 1:{let n=t.crypto.kdfparams,s=Buffer.from(n.salt,"hex"),o=p.pbkdf2Sync(a,s,n.c,n.dklen,"sha256"),i=Buffer.from(t.crypto.ciphertext,"hex"),c=Buffer.concat([o.subarray(16,32),i]);if(await k(c)!==t.crypto.mac)throw new r("wallet_keystore_invalid_password");let l=p.createDecipheriv(t.crypto.cipher,o.subarray(0,16),Buffer.from(t.crypto.cipherparams.iv,"hex"));return Buffer.concat([l.update(i),l.final()]).toString("utf8")}default:throw new r("wallet_keystore_unsupported_version")}}var S=d.createWallet({connect:({addChain:t})=>async function(r,n,s){let o=await T({chains:r,derivationPathMapOrIndex:s,phrase:n});for(let i of Object.values(o))t({...i,chain:i.chain,walletType:e.WalletOption.KEYSTORE});return!0},name:"connectKeystore",supportedChains:[...e.EVMChains,...e.UTXOChains,...e.CosmosChains.filter((t)=>t!==e.Chain.Harbor),...e.SubstrateChains,e.Chain.Cardano,e.Chain.Polkadot,e.Chain.Chainflip,e.Chain.Ripple,e.Chain.Solana,e.Chain.Sui,e.Chain.Ton,e.Chain.Tron,e.Chain.Near],walletType:e.WalletOption.KEYSTORE}),C=d.getWalletSupportedChains(S);async function T({chains:t,phrase:a,derivationPathMapOrIndex:r}){let n=e.filterSupportedChains({chains:t,supportedChains:C,walletType:e.WalletOption.KEYSTORE});return(await Promise.all(n.map(async(o)=>{let{getToolbox:i}=await import("@swapkit/toolboxes"),c=typeof r==="number"?r:0,f=r&&typeof r==="object"?r[o]:void 0,l=e.NetworkDerivationPath[o].slice(0,o===e.Chain.Solana?4:5),h=f||e.updateDerivationPath(l,{index:c}),b=await i(o,{derivationPath:h,phrase:a}),P=await b.getAddress()||"";return{...b,address:P,chain:o}}))).reduce((o,i)=>{return o[i.chain]=i,o},{})}
1
+ var N=Object.create;var{getPrototypeOf:H,defineProperty:s,getOwnPropertyNames:w,getOwnPropertyDescriptor:U}=Object,O=Object.prototype.hasOwnProperty;var S=(n,l,t)=>{t=n!=null?N(H(n)):{};let a=l||!n||!n.__esModule?s(t,"default",{value:n,enumerable:!0}):t;for(let r of w(n))if(!O.call(a,r))s(a,r,{get:()=>n[r],enumerable:!0});return a},R=new WeakMap,_=(n)=>{var l=R.get(n),t;if(l)return l;if(l=s({},"__esModule",{value:!0}),n&&typeof n==="object"||typeof n==="function")w(n).map((a)=>!O.call(l,a)&&s(l,a,{get:()=>n[a],enumerable:!(t=U(n,a))||t.enumerable}));return R.set(n,l),l};var e=(n,l)=>{for(var t in l)s(n,t,{get:l[t],enumerable:!0,configurable:!0,set:(a)=>l[t]=()=>a})};var q={};e(q,{validatePhrase:()=>X,keystoreWallet:()=>p,generatePhrase:()=>K,encryptToKeyStore:()=>x,decryptFromKeystore:()=>j,createKeystoreWallet:()=>g,KEYSTORE_SUPPORTED_CHAINS:()=>Y});module.exports=_(q);var o=require("@swapkit/helpers"),E=require("@swapkit/wallet-core");var c=require("node:crypto"),A=require("@scure/bip39"),W=require("@scure/bip39/wordlists/english.js");async function P(n){let l=await import("blakejs"),{blake2bFinal:t,blake2bInit:a,blake2bUpdate:r}=l?.default||l,u=n instanceof Buffer?n:Buffer.from(n,"hex"),T=a(32);return r(T,u),Array.from(t(T)).map((C)=>C<16?`0${C.toString(16)}`:C.toString(16)).join("")}async function x(n,l){let a=c.randomBytes(16),r=c.randomBytes(32),u={c:262144,dklen:32,prf:"hmac-sha256",salt:r.toString("hex")},T=c.pbkdf2Sync(l,r,u.c,u.dklen,"sha256"),C=c.createCipheriv("aes-128-ctr",T.subarray(0,16),a),h=Buffer.concat([C.update(Buffer.from(n,"utf8")),C.final()]),i=Buffer.concat([T.subarray(16,32),Buffer.from(h)]),m=await P(i);return{crypto:{cipher:"aes-128-ctr",cipherparams:{iv:a.toString("hex")},ciphertext:h.toString("hex"),kdf:"pbkdf2",kdfparams:u,mac:m},meta:"xchain-keystore",version:1}}function K(n=12){return A.generateMnemonic(W.wordlist,n===12?128:256)}function X(n){return A.validateMnemonic(n,W.wordlist)}async function j(n,l){let{SwapKitError:t}=await import("@swapkit/helpers");switch(n.version){case 1:{let a=n.crypto.kdfparams,r=Buffer.from(a.salt,"hex"),u=c.pbkdf2Sync(l,r,a.c,a.dklen,"sha256"),T=Buffer.from(n.crypto.ciphertext,"hex"),C=Buffer.concat([u.subarray(16,32),T]);if(await P(C)!==n.crypto.mac)throw new t("wallet_keystore_invalid_password");let i=c.createDecipheriv(n.crypto.cipher,u.subarray(0,16),Buffer.from(n.crypto.cipherparams.iv,"hex"));return Buffer.concat([i.update(T),i.final()]).toString("utf8")}default:throw new t("wallet_keystore_unsupported_version")}}var p=E.createWallet({connect:({addChain:n})=>async function(t,a,r){let u=await g({chains:t,derivationPathMapOrIndex:r,phrase:a});for(let T of Object.values(u))n({...T,chain:T.chain,walletType:o.WalletOption.KEYSTORE});return!0},name:"connectKeystore",supportedChains:[...o.EVMChains,...o.UTXOChains,...o.CosmosChains.filter((n)=>n!==o.Chain.Harbor),...o.SubstrateChains,o.Chain.Cardano,o.Chain.Polkadot,o.Chain.Chainflip,o.Chain.Ripple,o.Chain.Solana,o.Chain.Sui,o.Chain.Ton,o.Chain.Tron,o.Chain.Near],walletType:o.WalletOption.KEYSTORE}),Y=E.getWalletSupportedChains(p);async function g({chains:n,phrase:l,derivationPathMapOrIndex:t}){let a=o.filterSupportedChains({chains:n,supportedChains:Y,walletType:o.WalletOption.KEYSTORE});return(await Promise.all(a.map(async(u)=>{let{getToolbox:T}=await import("@swapkit/toolboxes"),C=typeof t==="number"?t:0,h=t&&typeof t==="object"?t[u]:void 0,i=o.NetworkDerivationPath[u].slice(0,u===o.Chain.Solana?4:5),m=h||o.updateDerivationPath(i,{index:C}),f=await T(u,{derivationPath:m,phrase:l}),F=await f.getAddress()||"";return{...f,address:F,chain:u}}))).reduce((u,T)=>{return u[T.chain]=T,u},{})}
2
2
 
3
- //# debugId=8A3BCE36A63726EA64756E2164756E21
3
+ //# debugId=BCE7458E9E3E0FBE64756E2164756E21
4
4
  //# sourceMappingURL=index.cjs.map
@@ -3,9 +3,9 @@
3
3
  "sources": ["../src/index.ts", "../src/helpers.ts"],
4
4
  "sourcesContent": [
5
5
  "import {\n Chain,\n CosmosChains,\n type DerivationPathArray,\n EVMChains,\n filterSupportedChains,\n NetworkDerivationPath,\n SubstrateChains,\n UTXOChains,\n updateDerivationPath,\n WalletOption,\n} from \"@swapkit/helpers\";\nimport type { FullWallet } from \"@swapkit/toolboxes\";\nimport { createWallet, getWalletSupportedChains } from \"@swapkit/wallet-core\";\n\nexport const keystoreWallet = createWallet({\n connect: ({ addChain }) =>\n async function connectKeystore(\n chains: Chain[],\n phrase: string,\n derivationPathMapOrIndex?: { [chain in Chain]?: DerivationPathArray } | number,\n ) {\n const wallets = await createKeystoreWallet({ chains, derivationPathMapOrIndex, phrase });\n\n for (const wallet of Object.values(wallets)) {\n addChain({ ...wallet, chain: wallet.chain, walletType: WalletOption.KEYSTORE });\n }\n\n return true;\n },\n name: \"connectKeystore\",\n supportedChains: [\n ...EVMChains,\n ...UTXOChains,\n ...CosmosChains.filter((chain) => chain !== Chain.Harbor),\n ...SubstrateChains,\n Chain.Cardano,\n Chain.Polkadot,\n Chain.Chainflip,\n Chain.Ripple,\n Chain.Solana,\n Chain.Sui,\n Chain.Ton,\n Chain.Tron,\n Chain.Near,\n ],\n walletType: WalletOption.KEYSTORE,\n});\n\nexport const KEYSTORE_SUPPORTED_CHAINS = getWalletSupportedChains(keystoreWallet);\n\nexport async function createKeystoreWallet<T extends Chain[]>({\n chains,\n phrase,\n derivationPathMapOrIndex,\n}: {\n chains: T;\n phrase: string;\n derivationPathMapOrIndex?: { [chain in Chain]?: DerivationPathArray } | number;\n}) {\n const filteredChains = filterSupportedChains({\n chains,\n supportedChains: KEYSTORE_SUPPORTED_CHAINS,\n walletType: WalletOption.KEYSTORE,\n });\n\n const wallets = await Promise.all(\n filteredChains.map(async (chain) => {\n const { getToolbox } = await import(\"@swapkit/toolboxes\");\n\n const derivationPathIndex = typeof derivationPathMapOrIndex === \"number\" ? derivationPathMapOrIndex : 0;\n const derivationPathFromMap =\n derivationPathMapOrIndex && typeof derivationPathMapOrIndex === \"object\"\n ? derivationPathMapOrIndex[chain]\n : undefined;\n\n const derivationArrayToUpdate = NetworkDerivationPath[chain].slice(\n 0,\n chain === Chain.Solana ? 4 : 5,\n ) as DerivationPathArray;\n\n const derivationPath: DerivationPathArray =\n derivationPathFromMap || updateDerivationPath(derivationArrayToUpdate, { index: derivationPathIndex });\n\n const toolbox = await getToolbox(chain, { derivationPath, phrase });\n const address = (await toolbox.getAddress()) || \"\";\n const wallet = { ...toolbox, address, chain };\n\n return wallet;\n }),\n );\n\n return wallets.reduce(\n (acc, wallet) => {\n acc[wallet.chain as T[number]] = wallet as FullWallet[T[number]];\n return acc;\n },\n {} as { [key in T[number]]: FullWallet[key] },\n );\n}\n\nexport * from \"./helpers\";\n",
6
- "import { createCipheriv, createDecipheriv, pbkdf2Sync, randomBytes } from \"node:crypto\";\nimport { generateMnemonic, validateMnemonic } from \"@scure/bip39\";\nimport { wordlist } from \"@scure/bip39/wordlists/english\";\n\nexport type Keystore = {\n version: number;\n meta: string;\n crypto: {\n cipher: string;\n cipherparams: { iv: string };\n ciphertext: string;\n kdf: string;\n kdfparams: { prf: string; dklen: number; salt: string; c: number };\n mac: string;\n };\n};\n\nasync function blake256(initData: Buffer | string) {\n const blakeModule = await import(\"blakejs\");\n const { blake2bFinal, blake2bInit, blake2bUpdate } = blakeModule?.default || blakeModule;\n let data = initData;\n\n if (!(data instanceof Buffer)) {\n // @ts-expect-error\n data = Buffer.from(data, \"hex\");\n }\n\n const context = blake2bInit(32);\n blake2bUpdate(context, data);\n\n return Array.from(blake2bFinal(context))\n .map((byte) => (byte < 0x10 ? `0${byte.toString(16)}` : byte.toString(16)))\n .join(\"\");\n}\n\nexport async function encryptToKeyStore(phrase: string, password: string) {\n const cipher = \"aes-128-ctr\";\n const iv = randomBytes(16);\n const salt = randomBytes(32);\n const kdfParams = { c: 262144, dklen: 32, prf: \"hmac-sha256\", salt: salt.toString(\"hex\") };\n\n const derivedKey = pbkdf2Sync(password, salt, kdfParams.c, kdfParams.dklen, \"sha256\");\n const cipherIV = createCipheriv(cipher, derivedKey.subarray(0, 16), iv);\n const ciphertext = Buffer.concat([cipherIV.update(Buffer.from(phrase, \"utf8\")), cipherIV.final()]);\n const initData = Buffer.concat([derivedKey.subarray(16, 32), Buffer.from(ciphertext)]);\n const mac = await blake256(initData);\n\n return {\n crypto: {\n cipher,\n cipherparams: { iv: iv.toString(\"hex\") },\n ciphertext: ciphertext.toString(\"hex\"),\n kdf: \"pbkdf2\",\n kdfparams: kdfParams,\n mac,\n },\n meta: \"xchain-keystore\",\n version: 1,\n };\n}\n\nexport function generatePhrase(size: 12 | 24 = 12) {\n return generateMnemonic(wordlist, size === 12 ? 128 : 256);\n}\n\nexport function validatePhrase(phrase: string) {\n return validateMnemonic(phrase, wordlist);\n}\n\nexport async function decryptFromKeystore(keystore: Keystore, password: string) {\n const { SwapKitError } = await import(\"@swapkit/helpers\");\n\n switch (keystore.version) {\n case 1: {\n const kdfParams = keystore.crypto.kdfparams;\n const salt = Buffer.from(kdfParams.salt, \"hex\");\n const derivedKey = pbkdf2Sync(password, salt, kdfParams.c, kdfParams.dklen, \"sha256\");\n\n const ciphertext = Buffer.from(keystore.crypto.ciphertext, \"hex\");\n const initData = Buffer.concat([derivedKey.subarray(16, 32), ciphertext]);\n const mac = await blake256(initData);\n\n if (mac !== keystore.crypto.mac) {\n throw new SwapKitError(\"wallet_keystore_invalid_password\");\n }\n\n const decipher = createDecipheriv(\n keystore.crypto.cipher,\n derivedKey.subarray(0, 16),\n Buffer.from(keystore.crypto.cipherparams.iv, \"hex\"),\n );\n\n const phrase = Buffer.concat([decipher.update(ciphertext), decipher.final()]);\n return phrase.toString(\"utf8\");\n }\n\n default:\n throw new SwapKitError(\"wallet_keystore_unsupported_version\");\n }\n}\n"
6
+ "import { createCipheriv, createDecipheriv, pbkdf2Sync, randomBytes } from \"node:crypto\";\nimport { generateMnemonic, validateMnemonic } from \"@scure/bip39\";\nimport { wordlist } from \"@scure/bip39/wordlists/english.js\";\n\nexport type Keystore = {\n version: number;\n meta: string;\n crypto: {\n cipher: string;\n cipherparams: { iv: string };\n ciphertext: string;\n kdf: string;\n kdfparams: { prf: string; dklen: number; salt: string; c: number };\n mac: string;\n };\n};\n\nasync function blake256(initData: Buffer | string) {\n const blakeModule = await import(\"blakejs\");\n const { blake2bFinal, blake2bInit, blake2bUpdate } = blakeModule?.default || blakeModule;\n const data = initData instanceof Buffer ? initData : Buffer.from(initData as string, \"hex\");\n\n const context = blake2bInit(32);\n blake2bUpdate(context, data);\n\n return Array.from(blake2bFinal(context))\n .map((byte) => (byte < 0x10 ? `0${byte.toString(16)}` : byte.toString(16)))\n .join(\"\");\n}\n\nexport async function encryptToKeyStore(phrase: string, password: string) {\n const cipher = \"aes-128-ctr\";\n const iv = randomBytes(16);\n const salt = randomBytes(32);\n const kdfParams = { c: 262144, dklen: 32, prf: \"hmac-sha256\", salt: salt.toString(\"hex\") };\n\n const derivedKey = pbkdf2Sync(password, salt, kdfParams.c, kdfParams.dklen, \"sha256\");\n const cipherIV = createCipheriv(cipher, derivedKey.subarray(0, 16), iv);\n const ciphertext = Buffer.concat([cipherIV.update(Buffer.from(phrase, \"utf8\")), cipherIV.final()]);\n const initData = Buffer.concat([derivedKey.subarray(16, 32), Buffer.from(ciphertext)]);\n const mac = await blake256(initData);\n\n return {\n crypto: {\n cipher,\n cipherparams: { iv: iv.toString(\"hex\") },\n ciphertext: ciphertext.toString(\"hex\"),\n kdf: \"pbkdf2\",\n kdfparams: kdfParams,\n mac,\n },\n meta: \"xchain-keystore\",\n version: 1,\n };\n}\n\nexport function generatePhrase(size: 12 | 24 = 12) {\n return generateMnemonic(wordlist, size === 12 ? 128 : 256);\n}\n\nexport function validatePhrase(phrase: string) {\n return validateMnemonic(phrase, wordlist);\n}\n\nexport async function decryptFromKeystore(keystore: Keystore, password: string) {\n const { SwapKitError } = await import(\"@swapkit/helpers\");\n\n switch (keystore.version) {\n case 1: {\n const kdfParams = keystore.crypto.kdfparams;\n const salt = Buffer.from(kdfParams.salt, \"hex\");\n const derivedKey = pbkdf2Sync(password, salt, kdfParams.c, kdfParams.dklen, \"sha256\");\n\n const ciphertext = Buffer.from(keystore.crypto.ciphertext, \"hex\");\n const initData = Buffer.concat([derivedKey.subarray(16, 32), ciphertext]);\n const mac = await blake256(initData);\n\n if (mac !== keystore.crypto.mac) {\n throw new SwapKitError(\"wallet_keystore_invalid_password\");\n }\n\n const decipher = createDecipheriv(\n keystore.crypto.cipher,\n derivedKey.subarray(0, 16),\n Buffer.from(keystore.crypto.cipherparams.iv, \"hex\"),\n );\n\n const phrase = Buffer.concat([decipher.update(ciphertext), decipher.final()]);\n return phrase.toString(\"utf8\");\n }\n\n default:\n throw new SwapKitError(\"wallet_keystore_unsupported_version\");\n }\n}\n"
7
7
  ],
8
- "mappings": "m3BAWO,IAXP,8BAaA,kCCb0E,IAA1E,yBACA,0BACA,4CAeA,eAAe,CAAQ,CAAC,EAA2B,CACjD,IAAM,EAAc,KAAa,oBACzB,eAAc,cAAa,iBAAkB,GAAa,SAAW,EACzE,EAAO,EAEX,GAAI,EAAE,aAAgB,QAEpB,EAAO,OAAO,KAAK,EAAM,KAAK,EAGhC,IAAM,EAAU,EAAY,EAAE,EAG9B,OAFA,EAAc,EAAS,CAAI,EAEpB,MAAM,KAAK,EAAa,CAAO,CAAC,EACpC,IAAI,CAAC,IAAU,E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+1,4 @@
1
- var k=Object.create;var{getPrototypeOf:S,defineProperty:y,getOwnPropertyNames:C}=Object;var T=Object.prototype.hasOwnProperty;var u=(t,o,r)=>{r=t!=null?k(S(t)):{};let a=o||!t||!t.__esModule?y(r,"default",{value:t,enumerable:!0}):r;for(let i of C(t))if(!T.call(a,i))y(a,i,{get:()=>t[i],enumerable:!0});return a};var h=((t)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(o,r)=>(typeof require<"u"?require:o)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});import{Chain as s,CosmosChains as E,EVMChains as A,filterSupportedChains as W,NetworkDerivationPath as F,SubstrateChains as R,UTXOChains as _,updateDerivationPath as O,WalletOption as m}from"@swapkit/helpers";import{createWallet as U,getWalletSupportedChains as Y}from"@swapkit/wallet-core";import{createCipheriv as P,createDecipheriv as K,pbkdf2Sync as b,randomBytes as w}from"node:crypto";import{generateMnemonic as B,validateMnemonic as D}from"@scure/bip39";import{wordlist as x}from"@scure/bip39/wordlists/english";async function g(t){let o=await import("blakejs"),{blake2bFinal:r,blake2bInit:a,blake2bUpdate:i}=o?.default||o,e=t;if(!(e instanceof Buffer))e=Buffer.from(e,"hex");let n=a(32);return i(n,e),Array.from(r(n)).map((c)=>c<16?`0${c.toString(16)}`:c.toString(16)).join("")}async function q(t,o){let a=w(16),i=w(32),e={c:262144,dklen:32,prf:"hmac-sha256",salt:i.toString("hex")},n=b(o,i,e.c,e.dklen,"sha256"),c=P("aes-128-ctr",n.subarray(0,16),a),l=Buffer.concat([c.update(Buffer.from(t,"utf8")),c.final()]),p=Buffer.concat([n.subarray(16,32),Buffer.from(l)]),f=await g(p);return{crypto:{cipher:"aes-128-ctr",cipherparams:{iv:a.toString("hex")},ciphertext:l.toString("hex"),kdf:"pbkdf2",kdfparams:e,mac:f},meta:"xchain-keystore",version:1}}function z(t=12){return B(x,t===12?128:256)}function G(t){return D(t,x)}async function J(t,o){let{SwapKitError:r}=await import("@swapkit/helpers");switch(t.version){case 1:{let a=t.crypto.kdfparams,i=Buffer.from(a.salt,"hex"),e=b(o,i,a.c,a.dklen,"sha256"),n=Buffer.from(t.crypto.ciphertext,"hex"),c=Buffer.concat([e.subarray(16,32),n]);if(await g(c)!==t.crypto.mac)throw new r("wallet_keystore_invalid_password");let p=K(t.crypto.cipher,e.subarray(0,16),Buffer.from(t.crypto.cipherparams.iv,"hex"));return Buffer.concat([p.update(n),p.final()]).toString("utf8")}default:throw new r("wallet_keystore_unsupported_version")}}var j=U({connect:({addChain:t})=>async function(r,a,i){let e=await H({chains:r,derivationPathMapOrIndex:i,phrase:a});for(let n of Object.values(e))t({...n,chain:n.chain,walletType:m.KEYSTORE});return!0},name:"connectKeystore",supportedChains:[...A,..._,...E.filter((t)=>t!==s.Harbor),...R,s.Cardano,s.Polkadot,s.Chainflip,s.Ripple,s.Solana,s.Sui,s.Ton,s.Tron,s.Near],walletType:m.KEYSTORE}),N=Y(j);async function H({chains:t,phrase:o,derivationPathMapOrIndex:r}){let a=W({chains:t,supportedChains:N,walletType:m.KEYSTORE});return(await Promise.all(a.map(async(e)=>{let{getToolbox:n}=await import("@swapkit/toolboxes"),c=typeof r==="number"?r:0,l=r&&typeof r==="object"?r[e]:void 0,p=F[e].slice(0,e===s.Solana?4:5),f=l||O(p,{index:c}),d=await n(e,{derivationPath:f,phrase:o}),v=await d.getAddress()||"";return{...d,address:v,chain:e}}))).reduce((e,n)=>{return e[n.chain]=n,e},{})}export{G as validatePhrase,j as keystoreWallet,z as generatePhrase,q as encryptToKeyStore,J as decryptFromKeystore,H as createKeystoreWallet,N as KEYSTORE_SUPPORTED_CHAINS};
1
+ var P=Object.create;var{getPrototypeOf:p,defineProperty:S,getOwnPropertyNames:Y}=Object;var g=Object.prototype.hasOwnProperty;var s=(n,u,o)=>{o=n!=null?P(p(n)):{};let l=u||!n||!n.__esModule?S(o,"default",{value:n,enumerable:!0}):o;for(let T of Y(n))if(!g.call(l,T))S(l,T,{get:()=>n[T],enumerable:!0});return l};var m=((n)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(n,{get:(u,o)=>(typeof require<"u"?require:u)[o]}):n)(function(n){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+n+'" is not supported')});import{Chain as r,CosmosChains as _,EVMChains as e,filterSupportedChains as x,NetworkDerivationPath as K,SubstrateChains as X,UTXOChains as j,updateDerivationPath as q,WalletOption as A}from"@swapkit/helpers";import{createWallet as v,getWalletSupportedChains as G}from"@swapkit/wallet-core";import{createCipheriv as F,createDecipheriv as N,pbkdf2Sync as f,randomBytes as W}from"node:crypto";import{generateMnemonic as H,validateMnemonic as U}from"@scure/bip39";import{wordlist as R}from"@scure/bip39/wordlists/english.js";async function w(n){let u=await import("blakejs"),{blake2bFinal:o,blake2bInit:l,blake2bUpdate:T}=u?.default||u,t=n instanceof Buffer?n:Buffer.from(n,"hex"),a=l(32);return T(a,t),Array.from(o(a)).map((C)=>C<16?`0${C.toString(16)}`:C.toString(16)).join("")}async function B(n,u){let l=W(16),T=W(32),t={c:262144,dklen:32,prf:"hmac-sha256",salt:T.toString("hex")},a=f(u,T,t.c,t.dklen,"sha256"),C=F("aes-128-ctr",a.subarray(0,16),l),i=Buffer.concat([C.update(Buffer.from(n,"utf8")),C.final()]),c=Buffer.concat([a.subarray(16,32),Buffer.from(i)]),h=await w(c);return{crypto:{cipher:"aes-128-ctr",cipherparams:{iv:l.toString("hex")},ciphertext:i.toString("hex"),kdf:"pbkdf2",kdfparams:t,mac:h},meta:"xchain-keystore",version:1}}function y(n=12){return H(R,n===12?128:256)}function I(n){return U(n,R)}async function M(n,u){let{SwapKitError:o}=await import("@swapkit/helpers");switch(n.version){case 1:{let l=n.crypto.kdfparams,T=Buffer.from(l.salt,"hex"),t=f(u,T,l.c,l.dklen,"sha256"),a=Buffer.from(n.crypto.ciphertext,"hex"),C=Buffer.concat([t.subarray(16,32),a]);if(await w(C)!==n.crypto.mac)throw new o("wallet_keystore_invalid_password");let c=N(n.crypto.cipher,t.subarray(0,16),Buffer.from(n.crypto.cipherparams.iv,"hex"));return Buffer.concat([c.update(a),c.final()]).toString("utf8")}default:throw new o("wallet_keystore_unsupported_version")}}var J=v({connect:({addChain:n})=>async function(o,l,T){let t=await Q({chains:o,derivationPathMapOrIndex:T,phrase:l});for(let a of Object.values(t))n({...a,chain:a.chain,walletType:A.KEYSTORE});return!0},name:"connectKeystore",supportedChains:[...e,...j,..._.filter((n)=>n!==r.Harbor),...X,r.Cardano,r.Polkadot,r.Chainflip,r.Ripple,r.Solana,r.Sui,r.Ton,r.Tron,r.Near],walletType:A.KEYSTORE}),L=G(J);async function Q({chains:n,phrase:u,derivationPathMapOrIndex:o}){let l=x({chains:n,supportedChains:L,walletType:A.KEYSTORE});return(await Promise.all(l.map(async(t)=>{let{getToolbox:a}=await import("@swapkit/toolboxes"),C=typeof o==="number"?o:0,i=o&&typeof o==="object"?o[t]:void 0,c=K[t].slice(0,t===r.Solana?4:5),h=i||q(c,{index:C}),E=await a(t,{derivationPath:h,phrase:u}),O=await E.getAddress()||"";return{...E,address:O,chain:t}}))).reduce((t,a)=>{return t[a.chain]=a,t},{})}export{I as validatePhrase,J as keystoreWallet,y as generatePhrase,B as encryptToKeyStore,M as decryptFromKeystore,Q as createKeystoreWallet,L as KEYSTORE_SUPPORTED_CHAINS};
2
2
 
3
- //# debugId=31836B745A48F76964756E2164756E21
3
+ //# debugId=A6DEB2136C92EE1564756E2164756E21
4
4
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -3,9 +3,9 @@
3
3
  "sources": ["../src/index.ts", "../src/helpers.ts"],
4
4
  "sourcesContent": [
5
5
  "import {\n Chain,\n CosmosChains,\n type DerivationPathArray,\n EVMChains,\n filterSupportedChains,\n NetworkDerivationPath,\n SubstrateChains,\n UTXOChains,\n updateDerivationPath,\n WalletOption,\n} from \"@swapkit/helpers\";\nimport type { FullWallet } from \"@swapkit/toolboxes\";\nimport { createWallet, getWalletSupportedChains } from \"@swapkit/wallet-core\";\n\nexport const keystoreWallet = createWallet({\n connect: ({ addChain }) =>\n async function connectKeystore(\n chains: Chain[],\n phrase: string,\n derivationPathMapOrIndex?: { [chain in Chain]?: DerivationPathArray } | number,\n ) {\n const wallets = await createKeystoreWallet({ chains, derivationPathMapOrIndex, phrase });\n\n for (const wallet of Object.values(wallets)) {\n addChain({ ...wallet, chain: wallet.chain, walletType: WalletOption.KEYSTORE });\n }\n\n return true;\n },\n name: \"connectKeystore\",\n supportedChains: [\n ...EVMChains,\n ...UTXOChains,\n ...CosmosChains.filter((chain) => chain !== Chain.Harbor),\n ...SubstrateChains,\n Chain.Cardano,\n Chain.Polkadot,\n Chain.Chainflip,\n Chain.Ripple,\n Chain.Solana,\n Chain.Sui,\n Chain.Ton,\n Chain.Tron,\n Chain.Near,\n ],\n walletType: WalletOption.KEYSTORE,\n});\n\nexport const KEYSTORE_SUPPORTED_CHAINS = getWalletSupportedChains(keystoreWallet);\n\nexport async function createKeystoreWallet<T extends Chain[]>({\n chains,\n phrase,\n derivationPathMapOrIndex,\n}: {\n chains: T;\n phrase: string;\n derivationPathMapOrIndex?: { [chain in Chain]?: DerivationPathArray } | number;\n}) {\n const filteredChains = filterSupportedChains({\n chains,\n supportedChains: KEYSTORE_SUPPORTED_CHAINS,\n walletType: WalletOption.KEYSTORE,\n });\n\n const wallets = await Promise.all(\n filteredChains.map(async (chain) => {\n const { getToolbox } = await import(\"@swapkit/toolboxes\");\n\n const derivationPathIndex = typeof derivationPathMapOrIndex === \"number\" ? derivationPathMapOrIndex : 0;\n const derivationPathFromMap =\n derivationPathMapOrIndex && typeof derivationPathMapOrIndex === \"object\"\n ? derivationPathMapOrIndex[chain]\n : undefined;\n\n const derivationArrayToUpdate = NetworkDerivationPath[chain].slice(\n 0,\n chain === Chain.Solana ? 4 : 5,\n ) as DerivationPathArray;\n\n const derivationPath: DerivationPathArray =\n derivationPathFromMap || updateDerivationPath(derivationArrayToUpdate, { index: derivationPathIndex });\n\n const toolbox = await getToolbox(chain, { derivationPath, phrase });\n const address = (await toolbox.getAddress()) || \"\";\n const wallet = { ...toolbox, address, chain };\n\n return wallet;\n }),\n );\n\n return wallets.reduce(\n (acc, wallet) => {\n acc[wallet.chain as T[number]] = wallet as FullWallet[T[number]];\n return acc;\n },\n {} as { [key in T[number]]: FullWallet[key] },\n );\n}\n\nexport * from \"./helpers\";\n",
6
- "import { createCipheriv, createDecipheriv, pbkdf2Sync, randomBytes } from \"node:crypto\";\nimport { generateMnemonic, validateMnemonic } from \"@scure/bip39\";\nimport { wordlist } from \"@scure/bip39/wordlists/english\";\n\nexport type Keystore = {\n version: number;\n meta: string;\n crypto: {\n cipher: string;\n cipherparams: { iv: string };\n ciphertext: string;\n kdf: string;\n kdfparams: { prf: string; dklen: number; salt: string; c: number };\n mac: string;\n };\n};\n\nasync function blake256(initData: Buffer | string) {\n const blakeModule = await import(\"blakejs\");\n const { blake2bFinal, blake2bInit, blake2bUpdate } = blakeModule?.default || blakeModule;\n let data = initData;\n\n if (!(data instanceof Buffer)) {\n // @ts-expect-error\n data = Buffer.from(data, \"hex\");\n }\n\n const context = blake2bInit(32);\n blake2bUpdate(context, data);\n\n return Array.from(blake2bFinal(context))\n .map((byte) => (byte < 0x10 ? `0${byte.toString(16)}` : byte.toString(16)))\n .join(\"\");\n}\n\nexport async function encryptToKeyStore(phrase: string, password: string) {\n const cipher = \"aes-128-ctr\";\n const iv = randomBytes(16);\n const salt = randomBytes(32);\n const kdfParams = { c: 262144, dklen: 32, prf: \"hmac-sha256\", salt: salt.toString(\"hex\") };\n\n const derivedKey = pbkdf2Sync(password, salt, kdfParams.c, kdfParams.dklen, \"sha256\");\n const cipherIV = createCipheriv(cipher, derivedKey.subarray(0, 16), iv);\n const ciphertext = Buffer.concat([cipherIV.update(Buffer.from(phrase, \"utf8\")), cipherIV.final()]);\n const initData = Buffer.concat([derivedKey.subarray(16, 32), Buffer.from(ciphertext)]);\n const mac = await blake256(initData);\n\n return {\n crypto: {\n cipher,\n cipherparams: { iv: iv.toString(\"hex\") },\n ciphertext: ciphertext.toString(\"hex\"),\n kdf: \"pbkdf2\",\n kdfparams: kdfParams,\n mac,\n },\n meta: \"xchain-keystore\",\n version: 1,\n };\n}\n\nexport function generatePhrase(size: 12 | 24 = 12) {\n return generateMnemonic(wordlist, size === 12 ? 128 : 256);\n}\n\nexport function validatePhrase(phrase: string) {\n return validateMnemonic(phrase, wordlist);\n}\n\nexport async function decryptFromKeystore(keystore: Keystore, password: string) {\n const { SwapKitError } = await import(\"@swapkit/helpers\");\n\n switch (keystore.version) {\n case 1: {\n const kdfParams = keystore.crypto.kdfparams;\n const salt = Buffer.from(kdfParams.salt, \"hex\");\n const derivedKey = pbkdf2Sync(password, salt, kdfParams.c, kdfParams.dklen, \"sha256\");\n\n const ciphertext = Buffer.from(keystore.crypto.ciphertext, \"hex\");\n const initData = Buffer.concat([derivedKey.subarray(16, 32), ciphertext]);\n const mac = await blake256(initData);\n\n if (mac !== keystore.crypto.mac) {\n throw new SwapKitError(\"wallet_keystore_invalid_password\");\n }\n\n const decipher = createDecipheriv(\n keystore.crypto.cipher,\n derivedKey.subarray(0, 16),\n Buffer.from(keystore.crypto.cipherparams.iv, \"hex\"),\n );\n\n const phrase = Buffer.concat([decipher.update(ciphertext), decipher.final()]);\n return phrase.toString(\"utf8\");\n }\n\n default:\n throw new SwapKitError(\"wallet_keystore_unsupported_version\");\n }\n}\n"
6
+ "import { createCipheriv, createDecipheriv, pbkdf2Sync, randomBytes } from \"node:crypto\";\nimport { generateMnemonic, validateMnemonic } from \"@scure/bip39\";\nimport { wordlist } from \"@scure/bip39/wordlists/english.js\";\n\nexport type Keystore = {\n version: number;\n meta: string;\n crypto: {\n cipher: string;\n cipherparams: { iv: string };\n ciphertext: string;\n kdf: string;\n kdfparams: { prf: string; dklen: number; salt: string; c: number };\n mac: string;\n };\n};\n\nasync function blake256(initData: Buffer | string) {\n const blakeModule = await import(\"blakejs\");\n const { blake2bFinal, blake2bInit, blake2bUpdate } = blakeModule?.default || blakeModule;\n const data = initData instanceof Buffer ? initData : Buffer.from(initData as string, \"hex\");\n\n const context = blake2bInit(32);\n blake2bUpdate(context, data);\n\n return Array.from(blake2bFinal(context))\n .map((byte) => (byte < 0x10 ? `0${byte.toString(16)}` : byte.toString(16)))\n .join(\"\");\n}\n\nexport async function encryptToKeyStore(phrase: string, password: string) {\n const cipher = \"aes-128-ctr\";\n const iv = randomBytes(16);\n const salt = randomBytes(32);\n const kdfParams = { c: 262144, dklen: 32, prf: \"hmac-sha256\", salt: salt.toString(\"hex\") };\n\n const derivedKey = pbkdf2Sync(password, salt, kdfParams.c, kdfParams.dklen, \"sha256\");\n const cipherIV = createCipheriv(cipher, derivedKey.subarray(0, 16), iv);\n const ciphertext = Buffer.concat([cipherIV.update(Buffer.from(phrase, \"utf8\")), cipherIV.final()]);\n const initData = Buffer.concat([derivedKey.subarray(16, 32), Buffer.from(ciphertext)]);\n const mac = await blake256(initData);\n\n return {\n crypto: {\n cipher,\n cipherparams: { iv: iv.toString(\"hex\") },\n ciphertext: ciphertext.toString(\"hex\"),\n kdf: \"pbkdf2\",\n kdfparams: kdfParams,\n mac,\n },\n meta: \"xchain-keystore\",\n version: 1,\n };\n}\n\nexport function generatePhrase(size: 12 | 24 = 12) {\n return generateMnemonic(wordlist, size === 12 ? 128 : 256);\n}\n\nexport function validatePhrase(phrase: string) {\n return validateMnemonic(phrase, wordlist);\n}\n\nexport async function decryptFromKeystore(keystore: Keystore, password: string) {\n const { SwapKitError } = await import(\"@swapkit/helpers\");\n\n switch (keystore.version) {\n case 1: {\n const kdfParams = keystore.crypto.kdfparams;\n const salt = Buffer.from(kdfParams.salt, \"hex\");\n const derivedKey = pbkdf2Sync(password, salt, kdfParams.c, kdfParams.dklen, \"sha256\");\n\n const ciphertext = Buffer.from(keystore.crypto.ciphertext, \"hex\");\n const initData = Buffer.concat([derivedKey.subarray(16, 32), ciphertext]);\n const mac = await blake256(initData);\n\n if (mac !== keystore.crypto.mac) {\n throw new SwapKitError(\"wallet_keystore_invalid_password\");\n }\n\n const decipher = createDecipheriv(\n keystore.crypto.cipher,\n derivedKey.subarray(0, 16),\n Buffer.from(keystore.crypto.cipherparams.iv, \"hex\"),\n );\n\n const phrase = Buffer.concat([decipher.update(ciphertext), decipher.final()]);\n return phrase.toString(\"utf8\");\n }\n\n default:\n throw new SwapKitError(\"wallet_keystore_unsupported_version\");\n }\n}\n"
7
7
  ],
8
- "mappings": "kjBAAA,gBACE,kBACA,eAEA,2BACA,2BACA,qBACA,gBACA,0BACA,kBACA,yBAGF,uBAAS,8BAAc,6BCbvB,yBAAS,sBAAgB,gBAAkB,iBAAY,oBACvD,2BAAS,sBAAkB,qBAC3B,mBAAS,uCAeT,eAAe,CAAQ,CAAC,EAA2B,CACjD,IAAM,EAAc,KAAa,oBACzB,eAAc,cAAa,iBAAkB,GAAa,SAAW,EACzE,EAAO,EAEX,GAAI,EAAE,aAAgB,QAEpB,EAAO,OAAO,KAAK,EAAM,KAAK,EAGhC,IAAM,EAAU,EAAY,EAAE,EAG9B,OAFA,EAAc,EAAS,CAAI,EAEpB,MAAM,KAAK,EAAa,CAAO,CAAC,EACpC,IAAI,CAAC,IAAU,EAAO,GAAO,IAAI,EAAK,SAAS,EAAE,IAAM,EAAK,SAAS,EAAE,CAAE,EACzE,KAAK,EAAE,EAGZ,eAAsB,CAAiB,CAAC,EAAgB,EAAkB,CAExE,IAAM,EAAK,EAAY,EAAE,EACnB,EAAO,EAAY,EAAE,EACrB,EAAY,CAAE,EAAG,OAAQ,MAAO,GAAI,IAAK,cAAe,KAAM,EAAK,SAAS,KAAK,CAAE,EAEnF,EAAa,EAAW,EAAU,EAAM,EAAU,EAAG,EAAU,MAAO,QAAQ,EAC9E,EAAW,EANF,cAMyB,EAAW,SAAS,EAAG,EAAE,EAAG,CAAE,EAChE,EAAa,OAAO,OAAO,CAAC,EAAS,OAAO,OAAO,KAAK,EAAQ,MAAM,CA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,EAAM,OACN,EAAM,IACN,EAAM,IACN,EAAM,KACN,EAAM,IACR,EACA,WAAY,EAAa,QAC3B,CAAC,EAEY,EAA4B,EAAyB,CAAc,EAEhF,eAAsB,CAAuC,EAC3D,SACA,SACA,4BAKC,CACD,IAAM,EAAiB,EAAsB,CAC3C,SACA,gBAAiB,EACjB,WAAY,EAAa,QAC3B,CAAC,EA4BD,OA1BgB,MAAM,QAAQ,IAC5B,EAAe,IAAI,MAAO,IAAU,CAClC,IAAQ,cAAe,KAAa,8BAE9B,EAAsB,OAAO,IAA6B,SAAW,EAA2B,EAChG,EACJ,GAA4B,OAAO,IAA6B,SAC5D,EAAyB,GACzB,OAEA,EAA0B,EAAsB,GAAO,MAC3D,EACA,IAAU,EAAM,OAAS,EAAI,CAC/B,EAEM,EACJ,GAAyB,EAAqB,EAAyB,CAAE,MAAO,CAAoB,CAAC,EAEjG,EAAU,MAAM,EAAW,EAAO,CAAE,iBAAgB,QAAO,CAAC,EAC5D,EAAW,MAAM,EAAQ,WAAW,GAAM,GAGhD,MAFe,IAAK,EAAS,UAAS,OAAM,EAG7C,CACH,GAEe,OACb,CAAC,EAAK,IAAW,CAEf,OADA,EAAI,EAAO,OAAsB,EAC1B,GAET,CAAC,CACH",
9
+ "debugId": "A6DEB2136C92EE1564756E2164756E21",
10
10
  "names": []
11
11
  }
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/helpers.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,QAAQ,GAAG;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE;QACN,MAAM,EAAE,MAAM,CAAC;QACf,YAAY,EAAE;YAAE,EAAE,EAAE,MAAM,CAAA;SAAE,CAAC;QAC7B,UAAU,EAAE,MAAM,CAAC;QACnB,GAAG,EAAE,MAAM,CAAC;QACZ,SAAS,EAAE;YAAE,GAAG,EAAE,MAAM,CAAC;YAAC,KAAK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AQ,EAAE,QAAQ,EAAE,MAAM,mBA8B7E"}
@@ -11,14 +11,15 @@ export declare const keystoreWallet: {
11
11
  BASE?: [44, 118, 0, 0, 0] | [44, 931, 0, 0, 0] | [number, number, number, number, number] | [44, 397, 0, 0, 0] | [0, 0, 0, 0, 0] | [44, 144, 0, 0, 0] | [44, 501, 0, 0, 0] | [44, 607, 0, 0, 0] | [44, 195, 0, 0, 0] | [44, 784, 0, 0, 0] | [1852, 1815, 0, 0, 0] | [number, number, number, number, (number | undefined)?] | [44, 145, 0, 0, 0] | [84, 2, 0, 0, 0] | [44, 3, 0, 0, 0] | [44, 5, 0, 0, 0] | [44, 133, 0, 0, 0] | undefined;
12
12
  BERA?: [44, 118, 0, 0, 0] | [44, 931, 0, 0, 0] | [number, number, number, number, number] | [44, 397, 0, 0, 0] | [0, 0, 0, 0, 0] | [44, 144, 0, 0, 0] | [44, 501, 0, 0, 0] | [44, 607, 0, 0, 0] | [44, 195, 0, 0, 0] | [44, 784, 0, 0, 0] | [1852, 1815, 0, 0, 0] | [number, number, number, number, (number | undefined)?] | [44, 145, 0, 0, 0] | [84, 2, 0, 0, 0] | [44, 3, 0, 0, 0] | [44, 5, 0, 0, 0] | [44, 133, 0, 0, 0] | undefined;
13
13
  BSC?: [44, 118, 0, 0, 0] | [44, 931, 0, 0, 0] | [number, number, number, number, number] | [44, 397, 0, 0, 0] | [0, 0, 0, 0, 0] | [44, 144, 0, 0, 0] | [44, 501, 0, 0, 0] | [44, 607, 0, 0, 0] | [44, 195, 0, 0, 0] | [44, 784, 0, 0, 0] | [1852, 1815, 0, 0, 0] | [number, number, number, number, (number | undefined)?] | [44, 145, 0, 0, 0] | [84, 2, 0, 0, 0] | [44, 3, 0, 0, 0] | [44, 5, 0, 0, 0] | [44, 133, 0, 0, 0] | undefined;
14
- ADA?: [44, 118, 0, 0, 0] | [44, 931, 0, 0, 0] | [number, number, number, number, number] | [44, 397, 0, 0, 0] | [0, 0, 0, 0, 0] | [44, 144, 0, 0, 0] | [44, 501, 0, 0, 0] | [44, 607, 0, 0, 0] | [44, 195, 0, 0, 0] | [44, 784, 0, 0, 0] | [1852, 1815, 0, 0, 0] | [number, number, number, number, (number | undefined)?] | [44, 145, 0, 0, 0] | [84, 2, 0, 0, 0] | [44, 3, 0, 0, 0] | [44, 5, 0, 0, 0] | [44, 133, 0, 0, 0] | undefined;
14
+ BTC?: [44, 118, 0, 0, 0] | [44, 931, 0, 0, 0] | [number, number, number, number, number] | [44, 397, 0, 0, 0] | [0, 0, 0, 0, 0] | [44, 144, 0, 0, 0] | [44, 501, 0, 0, 0] | [44, 607, 0, 0, 0] | [44, 195, 0, 0, 0] | [44, 784, 0, 0, 0] | [1852, 1815, 0, 0, 0] | [number, number, number, number, (number | undefined)?] | [44, 145, 0, 0, 0] | [84, 2, 0, 0, 0] | [44, 3, 0, 0, 0] | [44, 5, 0, 0, 0] | [44, 133, 0, 0, 0] | undefined;
15
+ BCH?: [44, 118, 0, 0, 0] | [44, 931, 0, 0, 0] | [number, number, number, number, number] | [44, 397, 0, 0, 0] | [0, 0, 0, 0, 0] | [44, 144, 0, 0, 0] | [44, 501, 0, 0, 0] | [44, 607, 0, 0, 0] | [44, 195, 0, 0, 0] | [44, 784, 0, 0, 0] | [1852, 1815, 0, 0, 0] | [number, number, number, number, (number | undefined)?] | [44, 145, 0, 0, 0] | [84, 2, 0, 0, 0] | [44, 3, 0, 0, 0] | [44, 5, 0, 0, 0] | [44, 133, 0, 0, 0] | undefined;
15
16
  BOTANIX?: [44, 118, 0, 0, 0] | [44, 931, 0, 0, 0] | [number, number, number, number, number] | [44, 397, 0, 0, 0] | [0, 0, 0, 0, 0] | [44, 144, 0, 0, 0] | [44, 501, 0, 0, 0] | [44, 607, 0, 0, 0] | [44, 195, 0, 0, 0] | [44, 784, 0, 0, 0] | [1852, 1815, 0, 0, 0] | [number, number, number, number, (number | undefined)?] | [44, 145, 0, 0, 0] | [84, 2, 0, 0, 0] | [44, 3, 0, 0, 0] | [44, 5, 0, 0, 0] | [44, 133, 0, 0, 0] | undefined;
17
+ ADA?: [44, 118, 0, 0, 0] | [44, 931, 0, 0, 0] | [number, number, number, number, number] | [44, 397, 0, 0, 0] | [0, 0, 0, 0, 0] | [44, 144, 0, 0, 0] | [44, 501, 0, 0, 0] | [44, 607, 0, 0, 0] | [44, 195, 0, 0, 0] | [44, 784, 0, 0, 0] | [1852, 1815, 0, 0, 0] | [number, number, number, number, (number | undefined)?] | [44, 145, 0, 0, 0] | [84, 2, 0, 0, 0] | [44, 3, 0, 0, 0] | [44, 5, 0, 0, 0] | [44, 133, 0, 0, 0] | undefined;
18
+ FLIP?: [44, 118, 0, 0, 0] | [44, 931, 0, 0, 0] | [number, number, number, number, number] | [44, 397, 0, 0, 0] | [0, 0, 0, 0, 0] | [44, 144, 0, 0, 0] | [44, 501, 0, 0, 0] | [44, 607, 0, 0, 0] | [44, 195, 0, 0, 0] | [44, 784, 0, 0, 0] | [1852, 1815, 0, 0, 0] | [number, number, number, number, (number | undefined)?] | [44, 145, 0, 0, 0] | [84, 2, 0, 0, 0] | [44, 3, 0, 0, 0] | [44, 5, 0, 0, 0] | [44, 133, 0, 0, 0] | undefined;
16
19
  CORE?: [44, 118, 0, 0, 0] | [44, 931, 0, 0, 0] | [number, number, number, number, number] | [44, 397, 0, 0, 0] | [0, 0, 0, 0, 0] | [44, 144, 0, 0, 0] | [44, 501, 0, 0, 0] | [44, 607, 0, 0, 0] | [44, 195, 0, 0, 0] | [44, 784, 0, 0, 0] | [1852, 1815, 0, 0, 0] | [number, number, number, number, (number | undefined)?] | [44, 145, 0, 0, 0] | [84, 2, 0, 0, 0] | [44, 3, 0, 0, 0] | [44, 5, 0, 0, 0] | [44, 133, 0, 0, 0] | undefined;
17
20
  CORN?: [44, 118, 0, 0, 0] | [44, 931, 0, 0, 0] | [number, number, number, number, number] | [44, 397, 0, 0, 0] | [0, 0, 0, 0, 0] | [44, 144, 0, 0, 0] | [44, 501, 0, 0, 0] | [44, 607, 0, 0, 0] | [44, 195, 0, 0, 0] | [44, 784, 0, 0, 0] | [1852, 1815, 0, 0, 0] | [number, number, number, number, (number | undefined)?] | [44, 145, 0, 0, 0] | [84, 2, 0, 0, 0] | [44, 3, 0, 0, 0] | [44, 5, 0, 0, 0] | [44, 133, 0, 0, 0] | undefined;
18
- CRO?: [44, 118, 0, 0, 0] | [44, 931, 0, 0, 0] | [number, number, number, number, number] | [44, 397, 0, 0, 0] | [0, 0, 0, 0, 0] | [44, 144, 0, 0, 0] | [44, 501, 0, 0, 0] | [44, 607, 0, 0, 0] | [44, 195, 0, 0, 0] | [44, 784, 0, 0, 0] | [1852, 1815, 0, 0, 0] | [number, number, number, number, (number | undefined)?] | [44, 145, 0, 0, 0] | [84, 2, 0, 0, 0] | [44, 3, 0, 0, 0] | [44, 5, 0, 0, 0] | [44, 133, 0, 0, 0] | undefined;
19
- BTC?: [44, 118, 0, 0, 0] | [44, 931, 0, 0, 0] | [number, number, number, number, number] | [44, 397, 0, 0, 0] | [0, 0, 0, 0, 0] | [44, 144, 0, 0, 0] | [44, 501, 0, 0, 0] | [44, 607, 0, 0, 0] | [44, 195, 0, 0, 0] | [44, 784, 0, 0, 0] | [1852, 1815, 0, 0, 0] | [number, number, number, number, (number | undefined)?] | [44, 145, 0, 0, 0] | [84, 2, 0, 0, 0] | [44, 3, 0, 0, 0] | [44, 5, 0, 0, 0] | [44, 133, 0, 0, 0] | undefined;
20
- BCH?: [44, 118, 0, 0, 0] | [44, 931, 0, 0, 0] | [number, number, number, number, number] | [44, 397, 0, 0, 0] | [0, 0, 0, 0, 0] | [44, 144, 0, 0, 0] | [44, 501, 0, 0, 0] | [44, 607, 0, 0, 0] | [44, 195, 0, 0, 0] | [44, 784, 0, 0, 0] | [1852, 1815, 0, 0, 0] | [number, number, number, number, (number | undefined)?] | [44, 145, 0, 0, 0] | [84, 2, 0, 0, 0] | [44, 3, 0, 0, 0] | [44, 5, 0, 0, 0] | [44, 133, 0, 0, 0] | undefined;
21
21
  GAIA?: [44, 118, 0, 0, 0] | [44, 931, 0, 0, 0] | [number, number, number, number, number] | [44, 397, 0, 0, 0] | [0, 0, 0, 0, 0] | [44, 144, 0, 0, 0] | [44, 501, 0, 0, 0] | [44, 607, 0, 0, 0] | [44, 195, 0, 0, 0] | [44, 784, 0, 0, 0] | [1852, 1815, 0, 0, 0] | [number, number, number, number, (number | undefined)?] | [44, 145, 0, 0, 0] | [84, 2, 0, 0, 0] | [44, 3, 0, 0, 0] | [44, 5, 0, 0, 0] | [44, 133, 0, 0, 0] | undefined;
22
+ CRO?: [44, 118, 0, 0, 0] | [44, 931, 0, 0, 0] | [number, number, number, number, number] | [44, 397, 0, 0, 0] | [0, 0, 0, 0, 0] | [44, 144, 0, 0, 0] | [44, 501, 0, 0, 0] | [44, 607, 0, 0, 0] | [44, 195, 0, 0, 0] | [44, 784, 0, 0, 0] | [1852, 1815, 0, 0, 0] | [number, number, number, number, (number | undefined)?] | [44, 145, 0, 0, 0] | [84, 2, 0, 0, 0] | [44, 3, 0, 0, 0] | [44, 5, 0, 0, 0] | [44, 133, 0, 0, 0] | undefined;
22
23
  DASH?: [44, 118, 0, 0, 0] | [44, 931, 0, 0, 0] | [number, number, number, number, number] | [44, 397, 0, 0, 0] | [0, 0, 0, 0, 0] | [44, 144, 0, 0, 0] | [44, 501, 0, 0, 0] | [44, 607, 0, 0, 0] | [44, 195, 0, 0, 0] | [44, 784, 0, 0, 0] | [1852, 1815, 0, 0, 0] | [number, number, number, number, (number | undefined)?] | [44, 145, 0, 0, 0] | [84, 2, 0, 0, 0] | [44, 3, 0, 0, 0] | [44, 5, 0, 0, 0] | [44, 133, 0, 0, 0] | undefined;
23
24
  DOGE?: [44, 118, 0, 0, 0] | [44, 931, 0, 0, 0] | [number, number, number, number, number] | [44, 397, 0, 0, 0] | [0, 0, 0, 0, 0] | [44, 144, 0, 0, 0] | [44, 501, 0, 0, 0] | [44, 607, 0, 0, 0] | [44, 195, 0, 0, 0] | [44, 784, 0, 0, 0] | [1852, 1815, 0, 0, 0] | [number, number, number, number, (number | undefined)?] | [44, 145, 0, 0, 0] | [84, 2, 0, 0, 0] | [44, 3, 0, 0, 0] | [44, 5, 0, 0, 0] | [44, 133, 0, 0, 0] | undefined;
24
25
  ETH?: [44, 118, 0, 0, 0] | [44, 931, 0, 0, 0] | [number, number, number, number, number] | [44, 397, 0, 0, 0] | [0, 0, 0, 0, 0] | [44, 144, 0, 0, 0] | [44, 501, 0, 0, 0] | [44, 607, 0, 0, 0] | [44, 195, 0, 0, 0] | [44, 784, 0, 0, 0] | [1852, 1815, 0, 0, 0] | [number, number, number, number, (number | undefined)?] | [44, 145, 0, 0, 0] | [84, 2, 0, 0, 0] | [44, 3, 0, 0, 0] | [44, 5, 0, 0, 0] | [44, 133, 0, 0, 0] | undefined;
@@ -26,30 +27,31 @@ export declare const keystoreWallet: {
26
27
  HARBOR?: [44, 118, 0, 0, 0] | [44, 931, 0, 0, 0] | [number, number, number, number, number] | [44, 397, 0, 0, 0] | [0, 0, 0, 0, 0] | [44, 144, 0, 0, 0] | [44, 501, 0, 0, 0] | [44, 607, 0, 0, 0] | [44, 195, 0, 0, 0] | [44, 784, 0, 0, 0] | [1852, 1815, 0, 0, 0] | [number, number, number, number, (number | undefined)?] | [44, 145, 0, 0, 0] | [84, 2, 0, 0, 0] | [44, 3, 0, 0, 0] | [44, 5, 0, 0, 0] | [44, 133, 0, 0, 0] | undefined;
27
28
  HYPEREVM?: [44, 118, 0, 0, 0] | [44, 931, 0, 0, 0] | [number, number, number, number, number] | [44, 397, 0, 0, 0] | [0, 0, 0, 0, 0] | [44, 144, 0, 0, 0] | [44, 501, 0, 0, 0] | [44, 607, 0, 0, 0] | [44, 195, 0, 0, 0] | [44, 784, 0, 0, 0] | [1852, 1815, 0, 0, 0] | [number, number, number, number, (number | undefined)?] | [44, 145, 0, 0, 0] | [84, 2, 0, 0, 0] | [44, 3, 0, 0, 0] | [44, 5, 0, 0, 0] | [44, 133, 0, 0, 0] | undefined;
28
29
  KUJI?: [44, 118, 0, 0, 0] | [44, 931, 0, 0, 0] | [number, number, number, number, number] | [44, 397, 0, 0, 0] | [0, 0, 0, 0, 0] | [44, 144, 0, 0, 0] | [44, 501, 0, 0, 0] | [44, 607, 0, 0, 0] | [44, 195, 0, 0, 0] | [44, 784, 0, 0, 0] | [1852, 1815, 0, 0, 0] | [number, number, number, number, (number | undefined)?] | [44, 145, 0, 0, 0] | [84, 2, 0, 0, 0] | [44, 3, 0, 0, 0] | [44, 5, 0, 0, 0] | [44, 133, 0, 0, 0] | undefined;
29
- SONIC?: [44, 118, 0, 0, 0] | [44, 931, 0, 0, 0] | [number, number, number, number, number] | [44, 397, 0, 0, 0] | [0, 0, 0, 0, 0] | [44, 144, 0, 0, 0] | [44, 501, 0, 0, 0] | [44, 607, 0, 0, 0] | [44, 195, 0, 0, 0] | [44, 784, 0, 0, 0] | [1852, 1815, 0, 0, 0] | [number, number, number, number, (number | undefined)?] | [44, 145, 0, 0, 0] | [84, 2, 0, 0, 0] | [44, 3, 0, 0, 0] | [44, 5, 0, 0, 0] | [44, 133, 0, 0, 0] | undefined;
30
- UNI?: [44, 118, 0, 0, 0] | [44, 931, 0, 0, 0] | [number, number, number, number, number] | [44, 397, 0, 0, 0] | [0, 0, 0, 0, 0] | [44, 144, 0, 0, 0] | [44, 501, 0, 0, 0] | [44, 607, 0, 0, 0] | [44, 195, 0, 0, 0] | [44, 784, 0, 0, 0] | [1852, 1815, 0, 0, 0] | [number, number, number, number, (number | undefined)?] | [44, 145, 0, 0, 0] | [84, 2, 0, 0, 0] | [44, 3, 0, 0, 0] | [44, 5, 0, 0, 0] | [44, 133, 0, 0, 0] | undefined;
31
- XLAYER?: [44, 118, 0, 0, 0] | [44, 931, 0, 0, 0] | [number, number, number, number, number] | [44, 397, 0, 0, 0] | [0, 0, 0, 0, 0] | [44, 144, 0, 0, 0] | [44, 501, 0, 0, 0] | [44, 607, 0, 0, 0] | [44, 195, 0, 0, 0] | [44, 784, 0, 0, 0] | [1852, 1815, 0, 0, 0] | [number, number, number, number, (number | undefined)?] | [44, 145, 0, 0, 0] | [84, 2, 0, 0, 0] | [44, 3, 0, 0, 0] | [44, 5, 0, 0, 0] | [44, 133, 0, 0, 0] | undefined;
32
30
  LTC?: [44, 118, 0, 0, 0] | [44, 931, 0, 0, 0] | [number, number, number, number, number] | [44, 397, 0, 0, 0] | [0, 0, 0, 0, 0] | [44, 144, 0, 0, 0] | [44, 501, 0, 0, 0] | [44, 607, 0, 0, 0] | [44, 195, 0, 0, 0] | [44, 784, 0, 0, 0] | [1852, 1815, 0, 0, 0] | [number, number, number, number, (number | undefined)?] | [44, 145, 0, 0, 0] | [84, 2, 0, 0, 0] | [44, 3, 0, 0, 0] | [44, 5, 0, 0, 0] | [44, 133, 0, 0, 0] | undefined;
33
31
  MAYA?: [44, 118, 0, 0, 0] | [44, 931, 0, 0, 0] | [number, number, number, number, number] | [44, 397, 0, 0, 0] | [0, 0, 0, 0, 0] | [44, 144, 0, 0, 0] | [44, 501, 0, 0, 0] | [44, 607, 0, 0, 0] | [44, 195, 0, 0, 0] | [44, 784, 0, 0, 0] | [1852, 1815, 0, 0, 0] | [number, number, number, number, (number | undefined)?] | [44, 145, 0, 0, 0] | [84, 2, 0, 0, 0] | [44, 3, 0, 0, 0] | [44, 5, 0, 0, 0] | [44, 133, 0, 0, 0] | undefined;
32
+ MEGAETH?: [44, 118, 0, 0, 0] | [44, 931, 0, 0, 0] | [number, number, number, number, number] | [44, 397, 0, 0, 0] | [0, 0, 0, 0, 0] | [44, 144, 0, 0, 0] | [44, 501, 0, 0, 0] | [44, 607, 0, 0, 0] | [44, 195, 0, 0, 0] | [44, 784, 0, 0, 0] | [1852, 1815, 0, 0, 0] | [number, number, number, number, (number | undefined)?] | [44, 145, 0, 0, 0] | [84, 2, 0, 0, 0] | [44, 3, 0, 0, 0] | [44, 5, 0, 0, 0] | [44, 133, 0, 0, 0] | undefined;
33
+ MONAD?: [44, 118, 0, 0, 0] | [44, 931, 0, 0, 0] | [number, number, number, number, number] | [44, 397, 0, 0, 0] | [0, 0, 0, 0, 0] | [44, 144, 0, 0, 0] | [44, 501, 0, 0, 0] | [44, 607, 0, 0, 0] | [44, 195, 0, 0, 0] | [44, 784, 0, 0, 0] | [1852, 1815, 0, 0, 0] | [number, number, number, number, (number | undefined)?] | [44, 145, 0, 0, 0] | [84, 2, 0, 0, 0] | [44, 3, 0, 0, 0] | [44, 5, 0, 0, 0] | [44, 133, 0, 0, 0] | undefined;
34
34
  NEAR?: [44, 118, 0, 0, 0] | [44, 931, 0, 0, 0] | [number, number, number, number, number] | [44, 397, 0, 0, 0] | [0, 0, 0, 0, 0] | [44, 144, 0, 0, 0] | [44, 501, 0, 0, 0] | [44, 607, 0, 0, 0] | [44, 195, 0, 0, 0] | [44, 784, 0, 0, 0] | [1852, 1815, 0, 0, 0] | [number, number, number, number, (number | undefined)?] | [44, 145, 0, 0, 0] | [84, 2, 0, 0, 0] | [44, 3, 0, 0, 0] | [44, 5, 0, 0, 0] | [44, 133, 0, 0, 0] | undefined;
35
35
  NOBLE?: [44, 118, 0, 0, 0] | [44, 931, 0, 0, 0] | [number, number, number, number, number] | [44, 397, 0, 0, 0] | [0, 0, 0, 0, 0] | [44, 144, 0, 0, 0] | [44, 501, 0, 0, 0] | [44, 607, 0, 0, 0] | [44, 195, 0, 0, 0] | [44, 784, 0, 0, 0] | [1852, 1815, 0, 0, 0] | [number, number, number, number, (number | undefined)?] | [44, 145, 0, 0, 0] | [84, 2, 0, 0, 0] | [44, 3, 0, 0, 0] | [44, 5, 0, 0, 0] | [44, 133, 0, 0, 0] | undefined;
36
36
  OP?: [44, 118, 0, 0, 0] | [44, 931, 0, 0, 0] | [number, number, number, number, number] | [44, 397, 0, 0, 0] | [0, 0, 0, 0, 0] | [44, 144, 0, 0, 0] | [44, 501, 0, 0, 0] | [44, 607, 0, 0, 0] | [44, 195, 0, 0, 0] | [44, 784, 0, 0, 0] | [1852, 1815, 0, 0, 0] | [number, number, number, number, (number | undefined)?] | [44, 145, 0, 0, 0] | [84, 2, 0, 0, 0] | [44, 3, 0, 0, 0] | [44, 5, 0, 0, 0] | [44, 133, 0, 0, 0] | undefined;
37
37
  DOT?: [44, 118, 0, 0, 0] | [44, 931, 0, 0, 0] | [number, number, number, number, number] | [44, 397, 0, 0, 0] | [0, 0, 0, 0, 0] | [44, 144, 0, 0, 0] | [44, 501, 0, 0, 0] | [44, 607, 0, 0, 0] | [44, 195, 0, 0, 0] | [44, 784, 0, 0, 0] | [1852, 1815, 0, 0, 0] | [number, number, number, number, (number | undefined)?] | [44, 145, 0, 0, 0] | [84, 2, 0, 0, 0] | [44, 3, 0, 0, 0] | [44, 5, 0, 0, 0] | [44, 133, 0, 0, 0] | undefined;
38
- FLIP?: [44, 118, 0, 0, 0] | [44, 931, 0, 0, 0] | [number, number, number, number, number] | [44, 397, 0, 0, 0] | [0, 0, 0, 0, 0] | [44, 144, 0, 0, 0] | [44, 501, 0, 0, 0] | [44, 607, 0, 0, 0] | [44, 195, 0, 0, 0] | [44, 784, 0, 0, 0] | [1852, 1815, 0, 0, 0] | [number, number, number, number, (number | undefined)?] | [44, 145, 0, 0, 0] | [84, 2, 0, 0, 0] | [44, 3, 0, 0, 0] | [44, 5, 0, 0, 0] | [44, 133, 0, 0, 0] | undefined;
39
38
  POL?: [44, 118, 0, 0, 0] | [44, 931, 0, 0, 0] | [number, number, number, number, number] | [44, 397, 0, 0, 0] | [0, 0, 0, 0, 0] | [44, 144, 0, 0, 0] | [44, 501, 0, 0, 0] | [44, 607, 0, 0, 0] | [44, 195, 0, 0, 0] | [44, 784, 0, 0, 0] | [1852, 1815, 0, 0, 0] | [number, number, number, number, (number | undefined)?] | [44, 145, 0, 0, 0] | [84, 2, 0, 0, 0] | [44, 3, 0, 0, 0] | [44, 5, 0, 0, 0] | [44, 133, 0, 0, 0] | undefined;
40
39
  XRD?: [44, 118, 0, 0, 0] | [44, 931, 0, 0, 0] | [number, number, number, number, number] | [44, 397, 0, 0, 0] | [0, 0, 0, 0, 0] | [44, 144, 0, 0, 0] | [44, 501, 0, 0, 0] | [44, 607, 0, 0, 0] | [44, 195, 0, 0, 0] | [44, 784, 0, 0, 0] | [1852, 1815, 0, 0, 0] | [number, number, number, number, (number | undefined)?] | [44, 145, 0, 0, 0] | [84, 2, 0, 0, 0] | [44, 3, 0, 0, 0] | [44, 5, 0, 0, 0] | [44, 133, 0, 0, 0] | undefined;
41
40
  XRP?: [44, 118, 0, 0, 0] | [44, 931, 0, 0, 0] | [number, number, number, number, number] | [44, 397, 0, 0, 0] | [0, 0, 0, 0, 0] | [44, 144, 0, 0, 0] | [44, 501, 0, 0, 0] | [44, 607, 0, 0, 0] | [44, 195, 0, 0, 0] | [44, 784, 0, 0, 0] | [1852, 1815, 0, 0, 0] | [number, number, number, number, (number | undefined)?] | [44, 145, 0, 0, 0] | [84, 2, 0, 0, 0] | [44, 3, 0, 0, 0] | [44, 5, 0, 0, 0] | [44, 133, 0, 0, 0] | undefined;
42
- THOR?: [44, 118, 0, 0, 0] | [44, 931, 0, 0, 0] | [number, number, number, number, number] | [44, 397, 0, 0, 0] | [0, 0, 0, 0, 0] | [44, 144, 0, 0, 0] | [44, 501, 0, 0, 0] | [44, 607, 0, 0, 0] | [44, 195, 0, 0, 0] | [44, 784, 0, 0, 0] | [1852, 1815, 0, 0, 0] | [number, number, number, number, (number | undefined)?] | [44, 145, 0, 0, 0] | [84, 2, 0, 0, 0] | [44, 3, 0, 0, 0] | [44, 5, 0, 0, 0] | [44, 133, 0, 0, 0] | undefined;
43
41
  SOL?: [44, 118, 0, 0, 0] | [44, 931, 0, 0, 0] | [number, number, number, number, number] | [44, 397, 0, 0, 0] | [0, 0, 0, 0, 0] | [44, 144, 0, 0, 0] | [44, 501, 0, 0, 0] | [44, 607, 0, 0, 0] | [44, 195, 0, 0, 0] | [44, 784, 0, 0, 0] | [1852, 1815, 0, 0, 0] | [number, number, number, number, (number | undefined)?] | [44, 145, 0, 0, 0] | [84, 2, 0, 0, 0] | [44, 3, 0, 0, 0] | [44, 5, 0, 0, 0] | [44, 133, 0, 0, 0] | undefined;
42
+ SONIC?: [44, 118, 0, 0, 0] | [44, 931, 0, 0, 0] | [number, number, number, number, number] | [44, 397, 0, 0, 0] | [0, 0, 0, 0, 0] | [44, 144, 0, 0, 0] | [44, 501, 0, 0, 0] | [44, 607, 0, 0, 0] | [44, 195, 0, 0, 0] | [44, 784, 0, 0, 0] | [1852, 1815, 0, 0, 0] | [number, number, number, number, (number | undefined)?] | [44, 145, 0, 0, 0] | [84, 2, 0, 0, 0] | [44, 3, 0, 0, 0] | [44, 5, 0, 0, 0] | [44, 133, 0, 0, 0] | undefined;
44
43
  SUI?: [44, 118, 0, 0, 0] | [44, 931, 0, 0, 0] | [number, number, number, number, number] | [44, 397, 0, 0, 0] | [0, 0, 0, 0, 0] | [44, 144, 0, 0, 0] | [44, 501, 0, 0, 0] | [44, 607, 0, 0, 0] | [44, 195, 0, 0, 0] | [44, 784, 0, 0, 0] | [1852, 1815, 0, 0, 0] | [number, number, number, number, (number | undefined)?] | [44, 145, 0, 0, 0] | [84, 2, 0, 0, 0] | [44, 3, 0, 0, 0] | [44, 5, 0, 0, 0] | [44, 133, 0, 0, 0] | undefined;
44
+ THOR?: [44, 118, 0, 0, 0] | [44, 931, 0, 0, 0] | [number, number, number, number, number] | [44, 397, 0, 0, 0] | [0, 0, 0, 0, 0] | [44, 144, 0, 0, 0] | [44, 501, 0, 0, 0] | [44, 607, 0, 0, 0] | [44, 195, 0, 0, 0] | [44, 784, 0, 0, 0] | [1852, 1815, 0, 0, 0] | [number, number, number, number, (number | undefined)?] | [44, 145, 0, 0, 0] | [84, 2, 0, 0, 0] | [44, 3, 0, 0, 0] | [44, 5, 0, 0, 0] | [44, 133, 0, 0, 0] | undefined;
45
45
  TON?: [44, 118, 0, 0, 0] | [44, 931, 0, 0, 0] | [number, number, number, number, number] | [44, 397, 0, 0, 0] | [0, 0, 0, 0, 0] | [44, 144, 0, 0, 0] | [44, 501, 0, 0, 0] | [44, 607, 0, 0, 0] | [44, 195, 0, 0, 0] | [44, 784, 0, 0, 0] | [1852, 1815, 0, 0, 0] | [number, number, number, number, (number | undefined)?] | [44, 145, 0, 0, 0] | [84, 2, 0, 0, 0] | [44, 3, 0, 0, 0] | [44, 5, 0, 0, 0] | [44, 133, 0, 0, 0] | undefined;
46
46
  TRON?: [44, 118, 0, 0, 0] | [44, 931, 0, 0, 0] | [number, number, number, number, number] | [44, 397, 0, 0, 0] | [0, 0, 0, 0, 0] | [44, 144, 0, 0, 0] | [44, 501, 0, 0, 0] | [44, 607, 0, 0, 0] | [44, 195, 0, 0, 0] | [44, 784, 0, 0, 0] | [1852, 1815, 0, 0, 0] | [number, number, number, number, (number | undefined)?] | [44, 145, 0, 0, 0] | [84, 2, 0, 0, 0] | [44, 3, 0, 0, 0] | [44, 5, 0, 0, 0] | [44, 133, 0, 0, 0] | undefined;
47
+ UNI?: [44, 118, 0, 0, 0] | [44, 931, 0, 0, 0] | [number, number, number, number, number] | [44, 397, 0, 0, 0] | [0, 0, 0, 0, 0] | [44, 144, 0, 0, 0] | [44, 501, 0, 0, 0] | [44, 607, 0, 0, 0] | [44, 195, 0, 0, 0] | [44, 784, 0, 0, 0] | [1852, 1815, 0, 0, 0] | [number, number, number, number, (number | undefined)?] | [44, 145, 0, 0, 0] | [84, 2, 0, 0, 0] | [44, 3, 0, 0, 0] | [44, 5, 0, 0, 0] | [44, 133, 0, 0, 0] | undefined;
48
+ XLAYER?: [44, 118, 0, 0, 0] | [44, 931, 0, 0, 0] | [number, number, number, number, number] | [44, 397, 0, 0, 0] | [0, 0, 0, 0, 0] | [44, 144, 0, 0, 0] | [44, 501, 0, 0, 0] | [44, 607, 0, 0, 0] | [44, 195, 0, 0, 0] | [44, 784, 0, 0, 0] | [1852, 1815, 0, 0, 0] | [number, number, number, number, (number | undefined)?] | [44, 145, 0, 0, 0] | [84, 2, 0, 0, 0] | [44, 3, 0, 0, 0] | [44, 5, 0, 0, 0] | [44, 133, 0, 0, 0] | undefined;
47
49
  ZEC?: [44, 118, 0, 0, 0] | [44, 931, 0, 0, 0] | [number, number, number, number, number] | [44, 397, 0, 0, 0] | [0, 0, 0, 0, 0] | [44, 144, 0, 0, 0] | [44, 501, 0, 0, 0] | [44, 607, 0, 0, 0] | [44, 195, 0, 0, 0] | [44, 784, 0, 0, 0] | [1852, 1815, 0, 0, 0] | [number, number, number, number, (number | undefined)?] | [44, 145, 0, 0, 0] | [84, 2, 0, 0, 0] | [44, 3, 0, 0, 0] | [44, 5, 0, 0, 0] | [44, 133, 0, 0, 0] | undefined;
48
50
  } | undefined) => Promise<boolean>;
49
- supportedChains: (Chain.Arbitrum | Chain.Aurora | Chain.Avalanche | Chain.Base | Chain.Berachain | Chain.BinanceSmartChain | Chain.Cardano | Chain.Botanix | Chain.Core | Chain.Corn | Chain.Cronos | Chain.Bitcoin | Chain.BitcoinCash | Chain.Cosmos | Chain.Dash | Chain.Dogecoin | Chain.Ethereum | Chain.Gnosis | Chain.Hyperevm | Chain.Kujira | Chain.Sonic | Chain.Unichain | Chain.XLayer | Chain.Litecoin | Chain.Maya | Chain.Near | Chain.Noble | Chain.Optimism | Chain.Polkadot | Chain.Chainflip | Chain.Polygon | Chain.Ripple | Chain.THORChain | Chain.Solana | Chain.Sui | Chain.Ton | Chain.Tron | Chain.Zcash)[];
51
+ supportedChains: (Chain.Arbitrum | Chain.Aurora | Chain.Avalanche | Chain.Base | Chain.Berachain | Chain.BinanceSmartChain | Chain.Bitcoin | Chain.BitcoinCash | Chain.Botanix | Chain.Cardano | Chain.Chainflip | Chain.Core | Chain.Corn | Chain.Cosmos | Chain.Cronos | Chain.Dash | Chain.Dogecoin | Chain.Ethereum | Chain.Gnosis | Chain.Hyperevm | Chain.Kujira | Chain.Litecoin | Chain.Maya | Chain.Monad | Chain.Near | Chain.Noble | Chain.Optimism | Chain.Polkadot | Chain.Polygon | Chain.Ripple | Chain.Solana | Chain.Sonic | Chain.Sui | Chain.THORChain | Chain.Ton | Chain.Tron | Chain.Unichain | Chain.XLayer | Chain.Zcash)[];
50
52
  };
51
53
  };
52
- export declare const KEYSTORE_SUPPORTED_CHAINS: (Chain.Arbitrum | Chain.Aurora | Chain.Avalanche | Chain.Base | Chain.Berachain | Chain.BinanceSmartChain | Chain.Cardano | Chain.Botanix | Chain.Core | Chain.Corn | Chain.Cronos | Chain.Bitcoin | Chain.BitcoinCash | Chain.Cosmos | Chain.Dash | Chain.Dogecoin | Chain.Ethereum | Chain.Gnosis | Chain.Hyperevm | Chain.Kujira | Chain.Sonic | Chain.Unichain | Chain.XLayer | Chain.Litecoin | Chain.Maya | Chain.Near | Chain.Noble | Chain.Optimism | Chain.Polkadot | Chain.Chainflip | Chain.Polygon | Chain.Ripple | Chain.THORChain | Chain.Solana | Chain.Sui | Chain.Ton | Chain.Tron | Chain.Zcash)[];
54
+ export declare const KEYSTORE_SUPPORTED_CHAINS: (Chain.Arbitrum | Chain.Aurora | Chain.Avalanche | Chain.Base | Chain.Berachain | Chain.BinanceSmartChain | Chain.Bitcoin | Chain.BitcoinCash | Chain.Botanix | Chain.Cardano | Chain.Chainflip | Chain.Core | Chain.Corn | Chain.Cosmos | Chain.Cronos | Chain.Dash | Chain.Dogecoin | Chain.Ethereum | Chain.Gnosis | Chain.Hyperevm | Chain.Kujira | Chain.Litecoin | Chain.Maya | Chain.Monad | Chain.Near | Chain.Noble | Chain.Optimism | Chain.Polkadot | Chain.Polygon | Chain.Ripple | Chain.Solana | Chain.Sonic | Chain.Sui | Chain.THORChain | Chain.Ton | Chain.Tron | Chain.Unichain | Chain.XLayer | Chain.Zcash)[];
53
55
  export declare function createKeystoreWallet<T extends Chain[]>({ chains, phrase, derivationPathMapOrIndex, }: {
54
56
  chains: T;
55
57
  phrase: string;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EAEL,KAAK,mBAAmB,EAQ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2
  "author": "swapkit-oss",
3
- "dependencies": { "@swapkit/helpers": "4.4.5", "@swapkit/toolboxes": "4.2.1", "@swapkit/wallet-core": "4.0.43" },
3
+ "dependencies": {
4
+ "@scure/bip39": "2.0.1",
5
+ "@swapkit/helpers": "4.5.3",
6
+ "@swapkit/toolboxes": "4.3.3",
7
+ "@swapkit/wallet-core": "4.0.47",
8
+ "blakejs": "1.2.1"
9
+ },
4
10
  "description": "SwapKit - Wallet Keystore",
5
11
  "exports": {
6
- ".": { "import": "./dist/index.js", "require": "./dist/index.cjs", "types": "./dist/types/index.d.ts" }
12
+ ".": {
13
+ "bun": "./src/index.ts",
14
+ "import": "./dist/index.js",
15
+ "require": "./dist/index.cjs",
16
+ "types": "./dist/types/index.d.ts"
17
+ }
7
18
  },
8
- "files": ["dist/"],
19
+ "files": ["dist/", "src/"],
9
20
  "homepage": "https://github.com/swapkit/SwapKit",
10
21
  "license": "Apache-2.0",
11
22
  "name": "@swapkit/wallet-keystore",
@@ -24,5 +35,5 @@
24
35
  "type-check:go": "tsgo"
25
36
  },
26
37
  "type": "module",
27
- "version": "4.0.43"
38
+ "version": "4.1.3"
28
39
  }
package/src/helpers.ts ADDED
@@ -0,0 +1,95 @@
1
+ import { createCipheriv, createDecipheriv, pbkdf2Sync, randomBytes } from "node:crypto";
2
+ import { generateMnemonic, validateMnemonic } from "@scure/bip39";
3
+ import { wordlist } from "@scure/bip39/wordlists/english.js";
4
+
5
+ export type Keystore = {
6
+ version: number;
7
+ meta: string;
8
+ crypto: {
9
+ cipher: string;
10
+ cipherparams: { iv: string };
11
+ ciphertext: string;
12
+ kdf: string;
13
+ kdfparams: { prf: string; dklen: number; salt: string; c: number };
14
+ mac: string;
15
+ };
16
+ };
17
+
18
+ async function blake256(initData: Buffer | string) {
19
+ const blakeModule = await import("blakejs");
20
+ const { blake2bFinal, blake2bInit, blake2bUpdate } = blakeModule?.default || blakeModule;
21
+ const data = initData instanceof Buffer ? initData : Buffer.from(initData as string, "hex");
22
+
23
+ const context = blake2bInit(32);
24
+ blake2bUpdate(context, data);
25
+
26
+ return Array.from(blake2bFinal(context))
27
+ .map((byte) => (byte < 0x10 ? `0${byte.toString(16)}` : byte.toString(16)))
28
+ .join("");
29
+ }
30
+
31
+ export async function encryptToKeyStore(phrase: string, password: string) {
32
+ const cipher = "aes-128-ctr";
33
+ const iv = randomBytes(16);
34
+ const salt = randomBytes(32);
35
+ const kdfParams = { c: 262144, dklen: 32, prf: "hmac-sha256", salt: salt.toString("hex") };
36
+
37
+ const derivedKey = pbkdf2Sync(password, salt, kdfParams.c, kdfParams.dklen, "sha256");
38
+ const cipherIV = createCipheriv(cipher, derivedKey.subarray(0, 16), iv);
39
+ const ciphertext = Buffer.concat([cipherIV.update(Buffer.from(phrase, "utf8")), cipherIV.final()]);
40
+ const initData = Buffer.concat([derivedKey.subarray(16, 32), Buffer.from(ciphertext)]);
41
+ const mac = await blake256(initData);
42
+
43
+ return {
44
+ crypto: {
45
+ cipher,
46
+ cipherparams: { iv: iv.toString("hex") },
47
+ ciphertext: ciphertext.toString("hex"),
48
+ kdf: "pbkdf2",
49
+ kdfparams: kdfParams,
50
+ mac,
51
+ },
52
+ meta: "xchain-keystore",
53
+ version: 1,
54
+ };
55
+ }
56
+
57
+ export function generatePhrase(size: 12 | 24 = 12) {
58
+ return generateMnemonic(wordlist, size === 12 ? 128 : 256);
59
+ }
60
+
61
+ export function validatePhrase(phrase: string) {
62
+ return validateMnemonic(phrase, wordlist);
63
+ }
64
+
65
+ export async function decryptFromKeystore(keystore: Keystore, password: string) {
66
+ const { SwapKitError } = await import("@swapkit/helpers");
67
+
68
+ switch (keystore.version) {
69
+ case 1: {
70
+ const kdfParams = keystore.crypto.kdfparams;
71
+ const salt = Buffer.from(kdfParams.salt, "hex");
72
+ const derivedKey = pbkdf2Sync(password, salt, kdfParams.c, kdfParams.dklen, "sha256");
73
+
74
+ const ciphertext = Buffer.from(keystore.crypto.ciphertext, "hex");
75
+ const initData = Buffer.concat([derivedKey.subarray(16, 32), ciphertext]);
76
+ const mac = await blake256(initData);
77
+
78
+ if (mac !== keystore.crypto.mac) {
79
+ throw new SwapKitError("wallet_keystore_invalid_password");
80
+ }
81
+
82
+ const decipher = createDecipheriv(
83
+ keystore.crypto.cipher,
84
+ derivedKey.subarray(0, 16),
85
+ Buffer.from(keystore.crypto.cipherparams.iv, "hex"),
86
+ );
87
+
88
+ const phrase = Buffer.concat([decipher.update(ciphertext), decipher.final()]);
89
+ return phrase.toString("utf8");
90
+ }
91
+
92
+ default:
93
+ throw new SwapKitError("wallet_keystore_unsupported_version");
94
+ }
95
+ }
package/src/index.ts ADDED
@@ -0,0 +1,102 @@
1
+ import {
2
+ Chain,
3
+ CosmosChains,
4
+ type DerivationPathArray,
5
+ EVMChains,
6
+ filterSupportedChains,
7
+ NetworkDerivationPath,
8
+ SubstrateChains,
9
+ UTXOChains,
10
+ updateDerivationPath,
11
+ WalletOption,
12
+ } from "@swapkit/helpers";
13
+ import type { FullWallet } from "@swapkit/toolboxes";
14
+ import { createWallet, getWalletSupportedChains } from "@swapkit/wallet-core";
15
+
16
+ export const keystoreWallet = createWallet({
17
+ connect: ({ addChain }) =>
18
+ async function connectKeystore(
19
+ chains: Chain[],
20
+ phrase: string,
21
+ derivationPathMapOrIndex?: { [chain in Chain]?: DerivationPathArray } | number,
22
+ ) {
23
+ const wallets = await createKeystoreWallet({ chains, derivationPathMapOrIndex, phrase });
24
+
25
+ for (const wallet of Object.values(wallets)) {
26
+ addChain({ ...wallet, chain: wallet.chain, walletType: WalletOption.KEYSTORE });
27
+ }
28
+
29
+ return true;
30
+ },
31
+ name: "connectKeystore",
32
+ supportedChains: [
33
+ ...EVMChains,
34
+ ...UTXOChains,
35
+ ...CosmosChains.filter((chain) => chain !== Chain.Harbor),
36
+ ...SubstrateChains,
37
+ Chain.Cardano,
38
+ Chain.Polkadot,
39
+ Chain.Chainflip,
40
+ Chain.Ripple,
41
+ Chain.Solana,
42
+ Chain.Sui,
43
+ Chain.Ton,
44
+ Chain.Tron,
45
+ Chain.Near,
46
+ ],
47
+ walletType: WalletOption.KEYSTORE,
48
+ });
49
+
50
+ export const KEYSTORE_SUPPORTED_CHAINS = getWalletSupportedChains(keystoreWallet);
51
+
52
+ export async function createKeystoreWallet<T extends Chain[]>({
53
+ chains,
54
+ phrase,
55
+ derivationPathMapOrIndex,
56
+ }: {
57
+ chains: T;
58
+ phrase: string;
59
+ derivationPathMapOrIndex?: { [chain in Chain]?: DerivationPathArray } | number;
60
+ }) {
61
+ const filteredChains = filterSupportedChains({
62
+ chains,
63
+ supportedChains: KEYSTORE_SUPPORTED_CHAINS,
64
+ walletType: WalletOption.KEYSTORE,
65
+ });
66
+
67
+ const wallets = await Promise.all(
68
+ filteredChains.map(async (chain) => {
69
+ const { getToolbox } = await import("@swapkit/toolboxes");
70
+
71
+ const derivationPathIndex = typeof derivationPathMapOrIndex === "number" ? derivationPathMapOrIndex : 0;
72
+ const derivationPathFromMap =
73
+ derivationPathMapOrIndex && typeof derivationPathMapOrIndex === "object"
74
+ ? derivationPathMapOrIndex[chain]
75
+ : undefined;
76
+
77
+ const derivationArrayToUpdate = NetworkDerivationPath[chain].slice(
78
+ 0,
79
+ chain === Chain.Solana ? 4 : 5,
80
+ ) as DerivationPathArray;
81
+
82
+ const derivationPath: DerivationPathArray =
83
+ derivationPathFromMap || updateDerivationPath(derivationArrayToUpdate, { index: derivationPathIndex });
84
+
85
+ const toolbox = await getToolbox(chain, { derivationPath, phrase });
86
+ const address = (await toolbox.getAddress()) || "";
87
+ const wallet = { ...toolbox, address, chain };
88
+
89
+ return wallet;
90
+ }),
91
+ );
92
+
93
+ return wallets.reduce(
94
+ (acc, wallet) => {
95
+ acc[wallet.chain as T[number]] = wallet as FullWallet[T[number]];
96
+ return acc;
97
+ },
98
+ {} as { [key in T[number]]: FullWallet[key] },
99
+ );
100
+ }
101
+
102
+ export * from "./helpers";