@swapkit/wallets 4.0.0-beta.38 → 4.0.0-beta.40
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/chunk-10h87ecy.js +4 -0
- package/dist/chunk-10h87ecy.js.map +10 -0
- package/dist/chunk-2aa1w78q.js +1 -0
- package/dist/chunk-31bmhjxx.js +4 -0
- package/dist/chunk-31bmhjxx.js.map +10 -0
- package/dist/chunk-3t5jkca2.js +5 -0
- package/dist/chunk-3t5jkca2.js.map +10 -0
- package/dist/{chunk-th8ggrmx.js → chunk-3vygfd50.js} +4 -3
- package/dist/{chunk-th8ggrmx.js.map → chunk-3vygfd50.js.map} +3 -3
- package/dist/{chunk-yah6cf33.js → chunk-940zcsgd.js} +3 -2
- package/dist/{chunk-yah6cf33.js.map → chunk-940zcsgd.js.map} +3 -3
- package/dist/{chunk-dcj9twam.js → chunk-bnnq9hg1.js} +3 -2
- package/dist/{chunk-dcj9twam.js.map → chunk-bnnq9hg1.js.map} +1 -1
- package/dist/chunk-bp34qnvm.js +5 -0
- package/dist/chunk-bp34qnvm.js.map +10 -0
- package/dist/chunk-etm8zfkk.js +4 -0
- package/dist/chunk-etm8zfkk.js.map +10 -0
- package/dist/{chunk-qwd1kp32.js → chunk-fa0psb24.js} +3 -2
- package/dist/{chunk-qwd1kp32.js.map → chunk-fa0psb24.js.map} +1 -1
- package/dist/chunk-kfw1mys1.js +4 -0
- package/dist/chunk-kfw1mys1.js.map +10 -0
- package/dist/chunk-vb4wtm2w.js +1 -0
- package/dist/chunk-wfattb4a.js +1 -0
- package/dist/{chunk-0qaxr89s.js → chunk-xwda1ncj.js} +3 -2
- package/dist/{chunk-0qaxr89s.js.map → chunk-xwda1ncj.js.map} +1 -1
- package/dist/src/bitget/index.cjs +3 -2
- package/dist/src/bitget/index.cjs.map +4 -4
- package/dist/src/bitget/index.js +3 -2
- package/dist/src/bitget/index.js.map +4 -4
- package/dist/src/coinbase/index.cjs +1 -0
- package/dist/src/coinbase/index.js +3 -2
- package/dist/src/coinbase/index.js.map +1 -1
- package/dist/src/cosmostation/index.cjs +1 -0
- package/dist/src/cosmostation/index.js +3 -2
- package/dist/src/cosmostation/index.js.map +1 -1
- package/dist/src/ctrl/index.cjs +1 -0
- package/dist/src/ctrl/index.js +3 -2
- package/dist/src/ctrl/index.js.map +2 -2
- package/dist/src/evm-extensions/index.cjs +1 -0
- package/dist/src/evm-extensions/index.js +3 -2
- package/dist/src/evm-extensions/index.js.map +1 -1
- package/dist/src/exodus/index.cjs +1 -0
- package/dist/src/exodus/index.js +3 -2
- package/dist/src/exodus/index.js.map +1 -1
- package/dist/src/index.cjs +3 -2
- package/dist/src/index.cjs.map +1 -1
- package/dist/src/index.js +3 -2
- package/dist/src/index.js.map +1 -1
- package/dist/src/keepkey/index.cjs +3 -2
- package/dist/src/keepkey/index.cjs.map +4 -5
- package/dist/src/keepkey/index.js +3 -2
- package/dist/src/keepkey/index.js.map +4 -5
- package/dist/src/keepkey-bex/index.cjs +3 -2
- package/dist/src/keepkey-bex/index.cjs.map +3 -3
- package/dist/src/keepkey-bex/index.js +3 -2
- package/dist/src/keepkey-bex/index.js.map +3 -3
- package/dist/src/keplr/index.cjs +1 -0
- package/dist/src/keplr/index.js +3 -2
- package/dist/src/keplr/index.js.map +1 -1
- package/dist/src/keystore/index.cjs +1 -0
- package/dist/src/keystore/index.js +3 -2
- package/dist/src/keystore/index.js.map +1 -1
- package/dist/src/ledger/index.cjs +4 -3
- package/dist/src/ledger/index.cjs.map +7 -6
- package/dist/src/ledger/index.js +4 -3
- package/dist/src/ledger/index.js.map +7 -6
- package/dist/src/okx/index.cjs +3 -2
- package/dist/src/okx/index.cjs.map +4 -4
- package/dist/src/okx/index.js +3 -2
- package/dist/src/okx/index.js.map +4 -4
- package/dist/src/onekey/index.cjs +3 -2
- package/dist/src/onekey/index.cjs.map +3 -3
- package/dist/src/onekey/index.js +3 -2
- package/dist/src/onekey/index.js.map +3 -3
- package/dist/src/phantom/index.cjs +1 -0
- package/dist/src/phantom/index.js +3 -2
- package/dist/src/phantom/index.js.map +1 -1
- package/dist/src/polkadotjs/index.cjs +1 -0
- package/dist/src/polkadotjs/index.js +3 -2
- package/dist/src/polkadotjs/index.js.map +1 -1
- package/dist/src/radix/index.cjs +1 -0
- package/dist/src/radix/index.js +3 -2
- package/dist/src/radix/index.js.map +1 -1
- package/dist/src/talisman/index.cjs +1 -0
- package/dist/src/talisman/index.js +3 -2
- package/dist/src/talisman/index.js.map +1 -1
- package/dist/src/trezor/index.cjs +3 -2
- package/dist/src/trezor/index.cjs.map +3 -3
- package/dist/src/trezor/index.js +3 -2
- package/dist/src/trezor/index.js.map +3 -3
- package/dist/src/walletconnect/index.cjs +3 -2
- package/dist/src/walletconnect/index.cjs.map +5 -5
- package/dist/src/walletconnect/index.js +3 -2
- package/dist/src/walletconnect/index.js.map +5 -5
- package/dist/src/xaman/index.cjs +4 -0
- package/dist/src/xaman/index.cjs.map +12 -0
- package/dist/src/xaman/index.js +4 -0
- package/dist/src/xaman/index.js.map +12 -0
- package/package.json +14 -6
- package/src/bitget/helpers.ts +65 -30
- package/src/bitget/index.ts +1 -1
- package/src/keepkey/chains/ripple.ts +118 -0
- package/src/keepkey/coins.ts +1 -0
- package/src/keepkey/index.ts +5 -0
- package/src/keepkey-bex/index.ts +1 -0
- package/src/ledger/clients/tron.ts +92 -0
- package/src/ledger/helpers/getLedgerAddress.ts +5 -0
- package/src/ledger/helpers/getLedgerClient.ts +3 -0
- package/src/ledger/index.ts +10 -0
- package/src/ledger/types.ts +2 -0
- package/src/okx/helpers.ts +71 -38
- package/src/okx/index.ts +1 -0
- package/src/onekey/index.ts +2 -2
- package/src/trezor/index.ts +8 -10
- package/src/types.ts +35 -0
- package/src/utils.ts +1 -0
- package/src/walletconnect/constants.ts +13 -0
- package/src/walletconnect/helpers.ts +11 -1
- package/src/walletconnect/index.ts +34 -0
- package/src/walletconnect/namespaces.ts +6 -0
- package/src/xaman/README.md +66 -0
- package/src/xaman/helpers.ts +59 -0
- package/src/xaman/index.ts +79 -0
- package/src/xaman/types.ts +26 -0
- package/src/xaman/walletMethods.ts +126 -0
- package/dist/chunk-bexr8da2.js +0 -4
- package/dist/chunk-bexr8da2.js.map +0 -10
- package/dist/chunk-sn6pgje5.js +0 -3
- package/dist/chunk-sn6pgje5.js.map +0 -10
package/dist/src/keplr/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{H as b,I as f}from"../../chunk-fa0psb24.js";import{Chain as a,ChainId as r,ChainToChainId as y,SwapKitError as t,WalletOption as p,createWallet as F,filterSupportedChains as I}from"@swapkit/helpers";import{ChainId as l}from"@swapkit/helpers";var h=new Map([[l.Kujira,{chainId:"kaiyo-1",chainName:"Kujira",chainSymbolImageUrl:"https://raw.githubusercontent.com/chainapsis/keplr-chain-registry/main/images/kaiyo/chain.png",rpc:"https://kujira-rpc.nodes.defiantlabs.net",rest:"https://rest.cosmos.directory/kujira/",nodeProvider:{name:"PFC",email:"pfc-validator@protonmail.com",website:"https://pfc.zone/"},bip44:{coinType:118},bech32Config:{bech32PrefixAccAddr:"kujira",bech32PrefixAccPub:"kujirapub",bech32PrefixValAddr:"kujiravaloper",bech32PrefixValPub:"kujiravaloperpub",bech32PrefixConsAddr:"kujiravalcons",bech32PrefixConsPub:"kujiravalconspub"},currencies:[{coinDenom:"KUJI",coinMinimalDenom:"ukuji",coinDecimals:6,coinGeckoId:"kujira",coinImageUrl:"https://raw.githubusercontent.com/chainapsis/keplr-chain-registry/main/images/kaiyo/ukuji.png"},{coinDenom:"USK",coinMinimalDenom:"factory/kujira1qk00h5atutpsv900x202pxx42npjr9thg58dnqpa72f2p7m2luase444a7/uusk",coinDecimals:6,coinGeckoId:"usk"},{coinDenom:"MNTA",coinMinimalDenom:"factory/kujira1643jxg8wasy5cfcn7xm8rd742yeazcksqlg4d7/umnta",coinDecimals:6,coinGeckoId:"mantadao"},{coinDenom:"bKUJI",coinMinimalDenom:"factory/kujira15e8q5wzlk5k38gjxlhse3vu6vqnafysncx2ltexd6y9gx50vuj2qpt7dgv/boneKuji",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/chainapsis/keplr-chain-registry/main/images/kaiyo/factory/kujira15e8q5wzlk5k38gjxlhse3vu6vqnafysncx2ltexd6y9gx50vuj2qpt7dgv/bKUJI.png"},{coinDenom:"AQLA",coinMinimalDenom:"factory/kujira1xe0awk5planmtsmjel5xtx2hzhqdw5p8z66yqd/uaqla",coinDecimals:6,coinGeckoId:"aqualibre",coinImageUrl:"https://raw.githubusercontent.com/chainapsis/keplr-chain-registry/main/images/kaiyo/factory/kujira1xe0awk5planmtsmjel5xtx2hzhqdw5p8z66yqd/AQLA.png"}],feeCurrencies:[{coinDenom:"KUJI",coinMinimalDenom:"ukuji",coinDecimals:6,coinGeckoId:"kujira",coinImageUrl:"https://raw.githubusercontent.com/chainapsis/keplr-chain-registry/main/images/kaiyo/ukuji.png"},{coinDenom:"USK",coinMinimalDenom:"factory/kujira1qk00h5atutpsv900x202pxx42npjr9thg58dnqpa72f2p7m2luase444a7/uusk",coinDecimals:6,coinGeckoId:"usk"},{coinDenom:"axlUSDC",coinMinimalDenom:"ibc/295548A78785A1007F232DE286149A6FF512F180AF5657780FC89C009E2C348F",coinDecimals:6,coinGeckoId:"usd-coin"},{coinDenom:"ATOM",coinMinimalDenom:"ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2",coinDecimals:6,coinGeckoId:"cosmos"},{coinDenom:"OSMO",coinMinimalDenom:"ibc/47BD209179859CDE4A2806763D7189B6E6FE13A17880FE2B42DE1E6C1E329E23",coinDecimals:6,coinGeckoId:"osmosis"},{coinDenom:"CMDX",coinMinimalDenom:"ibc/3607EB5B5E64DD1C0E12E07F077FF470D5BC4706AFCBC98FE1BA960E5AE4CE07",coinDecimals:6,coinGeckoId:"comdex"},{coinDenom:"EVMOS",coinMinimalDenom:"ibc/F3AA7EF362EC5E791FE78A0F4CCC69FEE1F9A7485EB1A8CAB3F6601C00522F10",coinDecimals:6,coinGeckoId:"evmos"},{coinDenom:"JUNO",coinMinimalDenom:"ibc/EFF323CC632EC4F747C61BCE238A758EFDB7699C3226565F7C20DA06509D59A5",coinDecimals:6,coinGeckoId:"juno-network"},{coinDenom:"MNTA",coinMinimalDenom:"factory/kujira1643jxg8wasy5cfcn7xm8rd742yeazcksqlg4d7/umnta",coinDecimals:6,coinGeckoId:"mantadao"},{coinDenom:"SCRT",coinMinimalDenom:"ibc/A358D7F19237777AF6D8AD0E0F53268F8B18AE8A53ED318095C14D6D7F3B2DB5",coinDecimals:6,coinGeckoId:"secret"},{coinDenom:"STARS",coinMinimalDenom:"ibc/4F393C3FCA4190C0A6756CE7F6D897D5D1BE57D6CCB80D0BC87393566A7B6602",coinDecimals:6,coinGeckoId:"stargaze"},{coinDenom:"wAVAX",coinMinimalDenom:"ibc/004EBF085BBED1029326D56BE8A2E67C08CECE670A94AC1947DF413EF5130EB2",coinDecimals:18,coinGeckoId:"avalanche-2"},{coinDenom:"wETH",coinMinimalDenom:"ibc/1B38805B1C75352B28169284F96DF56BDEBD9E8FAC005BDCC8CF0378C82AA8E7",coinDecimals:18,coinGeckoId:"ethereum"}],stakeCurrency:{coinDenom:"KUJI",coinMinimalDenom:"ukuji",coinDecimals:6,coinGeckoId:"kujira",coinImageUrl:"https://raw.githubusercontent.com/chainapsis/keplr-chain-registry/main/images/kaiyo/ukuji.png"},features:["cosmwasm"]}],[l.THORChain,{chainId:"thorchain-1",chainName:"THORChain",chainSymbolImageUrl:"https://raw.githubusercontent.com/chainapsis/keplr-chain-registry/main/images/thorchain/chain.png",rpc:"https://rpc-thorchain.keplr.app",rest:"https://lcd-thorchain.keplr.app",bip44:{coinType:931},bech32Config:{bech32PrefixAccAddr:"thor",bech32PrefixAccPub:"thorpub",bech32PrefixValAddr:"thorvaloper",bech32PrefixValPub:"thorvaloperpub",bech32PrefixConsAddr:"thorvalcons",bech32PrefixConsPub:"thorvalconspub"},currencies:[{coinDenom:"RUNE",coinMinimalDenom:"rune",coinDecimals:8,coinGeckoId:"thorchain",coinImageUrl:"https://raw.githubusercontent.com/chainapsis/keplr-chain-registry/main/images/thorchain/rune.png"}],feeCurrencies:[{coinDenom:"RUNE",coinMinimalDenom:"rune",coinDecimals:8,coinGeckoId:"thorchain",coinImageUrl:"https://raw.githubusercontent.com/chainapsis/keplr-chain-registry/main/images/thorchain/rune.png",gasPriceStep:{low:0.02,average:0.02,high:0.03}}],features:[]}]]);var x=[r.Cosmos,r.Kujira,r.THORChain],v=F({name:"connectKeplr",supportedChains:[a.Cosmos,a.Kujira,a.THORChain],connect:({addChain:u,supportedChains:D})=>async function j(k,o=p.KEPLR){let C=o===p.LEAP?"leap":"keplr",d=I({chains:k,supportedChains:D,walletType:o}),e=window[C];return await Promise.all(d.map(async(i)=>{let n=y[i];if(!x.includes(n)){let m=h.get(n);if(!m)throw new t("wallet_keplr_chain_not_supported",{chain:i});await e.experimentalSuggestChain(m)}e?.enable(n);let c=e?.getOfflineSignerOnlyAmino(n);if(!c)throw new t("wallet_keplr_signer_not_found");let{getCosmosToolbox:g}=await import("@swapkit/toolboxes/cosmos"),s=await c.getAccounts();if(!s?.[0]?.address)throw new t("wallet_keplr_no_accounts");let[{address:A}]=s,E=g(i,{signer:c});u({...E,chain:i,address:A,walletType:o})})),!0}});export{v as keplrWallet};
|
|
2
2
|
|
|
3
|
-
//# debugId=
|
|
3
|
+
//# debugId=E0F18EAFC803184064756E2164756E21
|
|
4
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -6,6 +6,6 @@
|
|
|
6
6
|
"import type { ChainInfo } from \"@keplr-wallet/types\";\nimport { ChainId } from \"@swapkit/helpers\";\n\nexport const chainRegistry = new Map<ChainId, ChainInfo>([\n [\n ChainId.Kujira,\n {\n chainId: \"kaiyo-1\",\n chainName: \"Kujira\",\n chainSymbolImageUrl:\n \"https://raw.githubusercontent.com/chainapsis/keplr-chain-registry/main/images/kaiyo/chain.png\",\n rpc: \"https://kujira-rpc.nodes.defiantlabs.net\",\n rest: \"https://rest.cosmos.directory/kujira/\",\n nodeProvider: {\n name: \"PFC\",\n email: \"pfc-validator@protonmail.com\",\n website: \"https://pfc.zone/\",\n },\n bip44: {\n coinType: 118,\n },\n bech32Config: {\n bech32PrefixAccAddr: \"kujira\",\n bech32PrefixAccPub: \"kujirapub\",\n bech32PrefixValAddr: \"kujiravaloper\",\n bech32PrefixValPub: \"kujiravaloperpub\",\n bech32PrefixConsAddr: \"kujiravalcons\",\n bech32PrefixConsPub: \"kujiravalconspub\",\n },\n currencies: [\n {\n coinDenom: \"KUJI\",\n coinMinimalDenom: \"ukuji\",\n coinDecimals: 6,\n coinGeckoId: \"kujira\",\n coinImageUrl:\n \"https://raw.githubusercontent.com/chainapsis/keplr-chain-registry/main/images/kaiyo/ukuji.png\",\n },\n {\n coinDenom: \"USK\",\n coinMinimalDenom:\n \"factory/kujira1qk00h5atutpsv900x202pxx42npjr9thg58dnqpa72f2p7m2luase444a7/uusk\",\n coinDecimals: 6,\n coinGeckoId: \"usk\",\n },\n {\n coinDenom: \"MNTA\",\n coinMinimalDenom: \"factory/kujira1643jxg8wasy5cfcn7xm8rd742yeazcksqlg4d7/umnta\",\n coinDecimals: 6,\n coinGeckoId: \"mantadao\",\n },\n {\n coinDenom: \"bKUJI\",\n coinMinimalDenom:\n \"factory/kujira15e8q5wzlk5k38gjxlhse3vu6vqnafysncx2ltexd6y9gx50vuj2qpt7dgv/boneKuji\",\n coinDecimals: 6,\n coinImageUrl:\n \"https://raw.githubusercontent.com/chainapsis/keplr-chain-registry/main/images/kaiyo/factory/kujira15e8q5wzlk5k38gjxlhse3vu6vqnafysncx2ltexd6y9gx50vuj2qpt7dgv/bKUJI.png\",\n },\n {\n coinDenom: \"AQLA\",\n coinMinimalDenom: \"factory/kujira1xe0awk5planmtsmjel5xtx2hzhqdw5p8z66yqd/uaqla\",\n coinDecimals: 6,\n coinGeckoId: \"aqualibre\",\n coinImageUrl:\n \"https://raw.githubusercontent.com/chainapsis/keplr-chain-registry/main/images/kaiyo/factory/kujira1xe0awk5planmtsmjel5xtx2hzhqdw5p8z66yqd/AQLA.png\",\n },\n ],\n feeCurrencies: [\n {\n coinDenom: \"KUJI\",\n coinMinimalDenom: \"ukuji\",\n coinDecimals: 6,\n coinGeckoId: \"kujira\",\n coinImageUrl:\n \"https://raw.githubusercontent.com/chainapsis/keplr-chain-registry/main/images/kaiyo/ukuji.png\",\n },\n {\n coinDenom: \"USK\",\n coinMinimalDenom:\n \"factory/kujira1qk00h5atutpsv900x202pxx42npjr9thg58dnqpa72f2p7m2luase444a7/uusk\",\n coinDecimals: 6,\n coinGeckoId: \"usk\",\n },\n {\n coinDenom: \"axlUSDC\",\n coinMinimalDenom: \"ibc/295548A78785A1007F232DE286149A6FF512F180AF5657780FC89C009E2C348F\",\n coinDecimals: 6,\n coinGeckoId: \"usd-coin\",\n },\n {\n coinDenom: \"ATOM\",\n coinMinimalDenom: \"ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2\",\n coinDecimals: 6,\n coinGeckoId: \"cosmos\",\n },\n {\n coinDenom: \"OSMO\",\n coinMinimalDenom: \"ibc/47BD209179859CDE4A2806763D7189B6E6FE13A17880FE2B42DE1E6C1E329E23\",\n coinDecimals: 6,\n coinGeckoId: \"osmosis\",\n },\n {\n coinDenom: \"CMDX\",\n coinMinimalDenom: \"ibc/3607EB5B5E64DD1C0E12E07F077FF470D5BC4706AFCBC98FE1BA960E5AE4CE07\",\n coinDecimals: 6,\n coinGeckoId: \"comdex\",\n },\n {\n coinDenom: \"EVMOS\",\n coinMinimalDenom: \"ibc/F3AA7EF362EC5E791FE78A0F4CCC69FEE1F9A7485EB1A8CAB3F6601C00522F10\",\n coinDecimals: 6,\n coinGeckoId: \"evmos\",\n },\n {\n coinDenom: \"JUNO\",\n coinMinimalDenom: \"ibc/EFF323CC632EC4F747C61BCE238A758EFDB7699C3226565F7C20DA06509D59A5\",\n coinDecimals: 6,\n coinGeckoId: \"juno-network\",\n },\n {\n coinDenom: \"MNTA\",\n coinMinimalDenom: \"factory/kujira1643jxg8wasy5cfcn7xm8rd742yeazcksqlg4d7/umnta\",\n coinDecimals: 6,\n coinGeckoId: \"mantadao\",\n },\n {\n coinDenom: \"SCRT\",\n coinMinimalDenom: \"ibc/A358D7F19237777AF6D8AD0E0F53268F8B18AE8A53ED318095C14D6D7F3B2DB5\",\n coinDecimals: 6,\n coinGeckoId: \"secret\",\n },\n {\n coinDenom: \"STARS\",\n coinMinimalDenom: \"ibc/4F393C3FCA4190C0A6756CE7F6D897D5D1BE57D6CCB80D0BC87393566A7B6602\",\n coinDecimals: 6,\n coinGeckoId: \"stargaze\",\n },\n {\n coinDenom: \"wAVAX\",\n coinMinimalDenom: \"ibc/004EBF085BBED1029326D56BE8A2E67C08CECE670A94AC1947DF413EF5130EB2\",\n coinDecimals: 18,\n coinGeckoId: \"avalanche-2\",\n },\n {\n coinDenom: \"wETH\",\n coinMinimalDenom: \"ibc/1B38805B1C75352B28169284F96DF56BDEBD9E8FAC005BDCC8CF0378C82AA8E7\",\n coinDecimals: 18,\n coinGeckoId: \"ethereum\",\n },\n ],\n stakeCurrency: {\n coinDenom: \"KUJI\",\n coinMinimalDenom: \"ukuji\",\n coinDecimals: 6,\n coinGeckoId: \"kujira\",\n coinImageUrl:\n \"https://raw.githubusercontent.com/chainapsis/keplr-chain-registry/main/images/kaiyo/ukuji.png\",\n },\n features: [\"cosmwasm\"],\n },\n ],\n [\n ChainId.THORChain,\n {\n chainId: \"thorchain-1\",\n chainName: \"THORChain\",\n chainSymbolImageUrl:\n \"https://raw.githubusercontent.com/chainapsis/keplr-chain-registry/main/images/thorchain/chain.png\",\n rpc: \"https://rpc-thorchain.keplr.app\",\n rest: \"https://lcd-thorchain.keplr.app\",\n bip44: {\n coinType: 931,\n },\n bech32Config: {\n bech32PrefixAccAddr: \"thor\",\n bech32PrefixAccPub: \"thorpub\",\n bech32PrefixValAddr: \"thorvaloper\",\n bech32PrefixValPub: \"thorvaloperpub\",\n bech32PrefixConsAddr: \"thorvalcons\",\n bech32PrefixConsPub: \"thorvalconspub\",\n },\n currencies: [\n {\n coinDenom: \"RUNE\",\n coinMinimalDenom: \"rune\",\n coinDecimals: 8,\n coinGeckoId: \"thorchain\",\n coinImageUrl:\n \"https://raw.githubusercontent.com/chainapsis/keplr-chain-registry/main/images/thorchain/rune.png\",\n },\n ],\n feeCurrencies: [\n {\n coinDenom: \"RUNE\",\n coinMinimalDenom: \"rune\",\n coinDecimals: 8,\n coinGeckoId: \"thorchain\",\n coinImageUrl:\n \"https://raw.githubusercontent.com/chainapsis/keplr-chain-registry/main/images/thorchain/rune.png\",\n gasPriceStep: {\n low: 0.02,\n average: 0.02,\n high: 0.03,\n },\n },\n ],\n features: [],\n },\n ],\n]);\n"
|
|
7
7
|
],
|
|
8
8
|
"mappings": "mDAAA,gBACE,aACA,oBACA,kBACA,kBACA,kBACA,2BACA,yBCNF,kBAAS,yBAEF,IAAM,EAAgB,IAAI,IAAwB,CACvD,CACE,EAAQ,OACR,CACE,QAAS,UACT,UAAW,SACX,oBACE,gGACF,IAAK,2CACL,KAAM,wCACN,aAAc,CACZ,KAAM,MACN,MAAO,+BACP,QAAS,mBACX,EACA,MAAO,CACL,SAAU,GACZ,EACA,aAAc,CACZ,oBAAqB,SACrB,mBAAoB,YACpB,oBAAqB,gBACrB,mBAAoB,mBACpB,qBAAsB,gBACtB,oBAAqB,kBACvB,EACA,WAAY,CACV,CACE,UAAW,OACX,iBAAkB,QAClB,aAAc,EACd,YAAa,SACb,aACE,+FACJ,EACA,CACE,UAAW,MACX,iBACE,iFACF,aAAc,EACd,YAAa,KACf,EACA,CACE,UAAW,OACX,iBAAkB,8DAClB,aAAc,EACd,YAAa,UACf,EACA,CACE,UAAW,QACX,iBACE,qFACF,aAAc,EACd,aACE,yKACJ,EACA,CACE,UAAW,OACX,iBAAkB,8DAClB,aAAc,EACd,YAAa,YACb,aACE,oJACJ,CACF,EACA,cAAe,CACb,CACE,UAAW,OACX,iBAAkB,QAClB,aAAc,EACd,YAAa,SACb,aACE,+FACJ,EACA,CACE,UAAW,MACX,iBACE,iFACF,aAAc,EACd,YAAa,KACf,EACA,CACE,UAAW,UACX,iBAAkB,uEAClB,aAAc,EACd,YAAa,UACf,EACA,CACE,UAAW,OACX,iBAAkB,uEAClB,aAAc,EACd,YAAa,QACf,EACA,CACE,UAAW,OACX,iBAAkB,uEAClB,aAAc,EACd,YAAa,SACf,EACA,CACE,UAAW,OACX,iBAAkB,uEAClB,aAAc,EACd,YAAa,QACf,EACA,CACE,UAAW,QACX,iBAAkB,uEAClB,aAAc,EACd,YAAa,OACf,EACA,CACE,UAAW,OACX,iBAAkB,uEAClB,aAAc,EACd,YAAa,cACf,EACA,CACE,UAAW,OACX,iBAAkB,8DAClB,aAAc,EACd,YAAa,UACf,EACA,CACE,UAAW,OACX,iBAAkB,uEAClB,aAAc,EACd,YAAa,QACf,EACA,CACE,UAAW,QACX,iBAAkB,uEAClB,aAAc,EACd,YAAa,UACf,EACA,CACE,UAAW,QACX,iBAAkB,uEAClB,aAAc,GACd,YAAa,aACf,EACA,CACE,UAAW,OACX,iBAAkB,uEAClB,aAAc,GACd,YAAa,UACf,CACF,EACA,cAAe,CACb,UAAW,OACX,iBAAkB,QAClB,aAAc,EACd,YAAa,SACb,aACE,+FACJ,EACA,SAAU,CAAC,UAAU,CACvB,CACF,EACA,CACE,EAAQ,UACR,CACE,QAAS,cACT,UAAW,YACX,oBACE,oGACF,IAAK,kCACL,KAAM,kCACN,MAAO,CACL,SAAU,GACZ,EACA,aAAc,CACZ,oBAAqB,OACrB,mBAAoB,UACpB,oBAAqB,cACrB,mBAAoB,iBACpB,qBAAsB,cACtB,oBAAqB,gBACvB,EACA,WAAY,CACV,CACE,UAAW,OACX,iBAAkB,OAClB,aAAc,EACd,YAAa,YACb,aACE,kGACJ,CACF,EACA,cAAe,CACb,CACE,UAAW,OACX,iBAAkB,OAClB,aAAc,EACd,YAAa,YACb,aACE,mGACF,aAAc,CACZ,IAAK,KACL,QAAS,KACT,KAAM,IACR,CACF,CACF,EACA,SAAU,CAAC,CACb,CACF,CACF,CAAC,EDvMD,IAAM,EAAyB,CAAC,EAAQ,OAAQ,EAAQ,OAAQ,EAAQ,SAAS,EAEpE,EAAc,EAAa,CACtC,KAAM,eACN,gBAAiB,CAAC,EAAM,OAAQ,EAAM,OAAQ,EAAM,SAAS,EAC7D,QAAS,EAAG,WAAU,qBACpB,eAAe,CAAY,CACzB,EACA,EAAqD,EAAa,MAClE,CACA,IAAM,EAAe,IAAe,EAAa,KAAO,OAAS,QAC3D,EAAiB,EAAsB,CAAE,SAAQ,kBAAiB,YAAW,CAAC,EAC9E,EAAc,OAAO,GA6B3B,OA3BA,MAAM,QAAQ,IACZ,EAAe,IAAI,MAAO,IAAU,CAClC,IAAM,EAAU,EAAe,GAE/B,IAAK,EAAuB,SAAS,CAAO,EAAG,CAC7C,IAAM,EAAc,EAAc,IAAI,CAAO,EAC7C,IAAK,EAAa,MAAM,IAAI,EAAa,mCAAoC,CAAE,OAAM,CAAC,EAEtF,MAAM,EAAY,yBAAyB,CAAW,EAGxD,GAAa,OAAO,CAAO,EAC3B,IAAM,EAAS,GAAa,0BAA0B,CAAO,EAC7D,IAAK,EAAQ,MAAM,IAAI,EAAa,+BAA+B,EAEnE,IAAQ,oBAAqB,KAAa,qCAEpC,EAAW,MAAM,EAAO,YAAY,EAC1C,IAAK,IAAW,IAAI,QAAS,MAAM,IAAI,EAAa,0BAA0B,EAE9E,KAAS,YAAa,EAChB,EAAU,EAAiB,EAAO,CAAE,QAAO,CAAC,EAElD,EAAS,IAAK,EAAS,QAAO,UAAS,YAAW,CAAC,EACpD,CACH,EAEO,GAEb,CAAC",
|
|
9
|
-
"debugId": "
|
|
9
|
+
"debugId": "E0F18EAFC803184064756E2164756E21",
|
|
10
10
|
"names": []
|
|
11
11
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
var _={};E(_,{validatePhrase:()=>K,keystoreWallet:()=>x,generatePhrase:()=>P,encryptToKeyStore:()=>B,decryptFromKeystore:()=>T,KEYSTORE_SUPPORTED_CHAINS:()=>A});module.exports=D(_);var t=require("@swapkit/helpers");var o=require("node:crypto"),h=require("@scure/bip39"),d=require("@scure/bip39/wordlists/english");async function g(r){let{blake2bFinal:c,blake2bInit:p,blake2bUpdate:i}=(await import("blakejs")).default,a=r;if(!(a instanceof Buffer))a=Buffer.from(a,"hex");let n=p(32);return i(n,a),Array.from(c(n)).map((e)=>e<16?`0${e.toString(16)}`:e.toString(16)).join("")}async function B(r,c){let i=o.randomBytes(16),a=o.randomBytes(32),n={c:262144,prf:"hmac-sha256",dklen:32,salt:a.toString("hex")},e=o.pbkdf2Sync(c,a,n.c,n.dklen,"sha256"),f=o.createCipheriv("aes-128-ctr",e.subarray(0,16),i),s=Buffer.concat([f.update(Buffer.from(r,"utf8")),f.final()]),l=Buffer.concat([e.subarray(16,32),Buffer.from(s)]),m=await g(l);return{meta:"xchain-keystore",version:1,crypto:{cipher:"aes-128-ctr",cipherparams:{iv:i.toString("hex")},ciphertext:s.toString("hex"),kdf:"pbkdf2",kdfparams:n,mac:m}}}function P(r=12){return h.generateMnemonic(d.wordlist,r===12?128:256)}function K(r){return h.validateMnemonic(r,d.wordlist)}async function T(r,c){let{SwapKitError:p}=await import("@swapkit/helpers");switch(r.version){case 1:{let i=r.crypto.kdfparams,a=Buffer.from(i.salt,"hex"),n=o.pbkdf2Sync(c,a,i.c,i.dklen,"sha256"),e=Buffer.from(r.crypto.ciphertext,"hex"),f=Buffer.concat([n.subarray(16,32),e]);if(await g(f)!==r.crypto.mac)throw new p("wallet_keystore_invalid_password");let l=o.createDecipheriv(r.crypto.cipher,n.subarray(0,16),Buffer.from(r.crypto.cipherparams.iv,"hex"));return Buffer.concat([l.update(e),l.final()]).toString("utf8")}default:throw new p("wallet_keystore_unsupported_version")}}var x=t.createWallet({name:"connectKeystore",walletType:t.WalletOption.KEYSTORE,supportedChains:[...t.EVMChains,...t.UTXOChains,...t.CosmosChains,t.Chain.Polkadot,t.Chain.Chainflip,t.Chain.Ripple,t.Chain.Solana,t.Chain.Tron,t.Chain.Near],connect:({addChain:r,supportedChains:c,walletType:p})=>async function i(a,n,e){let f=t.filterSupportedChains({chains:a,supportedChains:c,walletType:p});return await Promise.all(f.map(async(s)=>{let l=typeof e==="number"?e:0,m=e&&typeof e==="object"?e[s]:void 0,v=t.NetworkDerivationPath[s].slice(0,s===t.Chain.Solana?4:5),b=m||t.updateDerivationPath(v,{index:l}),{getToolbox:k}=await import("@swapkit/toolboxes"),y=await k(s,{phrase:n,derivationPath:b}),S=await y.getAddress()||"",C={...y,address:S};r({...C,chain:s,walletType:t.WalletOption.KEYSTORE})})),!0}}),A=w(x);
|
|
2
2
|
|
|
3
3
|
//# debugId=8B787A2A3639BA0C64756E2164756E21
|
|
4
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{F as v}from"../../chunk-3vygfd50.js";import{H as m,I as h}from"../../chunk-fa0psb24.js";import{Chain as c,CosmosChains as E,EVMChains as A,NetworkDerivationPath as _,UTXOChains as R,WalletOption as w,createWallet as U,filterSupportedChains as W,updateDerivationPath as F}from"@swapkit/helpers";import{createCipheriv as P,createDecipheriv as K,pbkdf2Sync as y,randomBytes as d}from"node:crypto";import{generateMnemonic as T,validateMnemonic as D}from"@scure/bip39";import{wordlist as g}from"@scure/bip39/wordlists/english";async function x(t){let{blake2bFinal:i,blake2bInit:s,blake2bUpdate:n}=(await import("blakejs")).default,e=t;if(!(e instanceof Buffer))e=Buffer.from(e,"hex");let a=s(32);return n(a,e),Array.from(i(a)).map((r)=>r<16?`0${r.toString(16)}`:r.toString(16)).join("")}async function V(t,i){let n=d(16),e=d(32),a={c:262144,prf:"hmac-sha256",dklen:32,salt:e.toString("hex")},r=y(i,e,a.c,a.dklen,"sha256"),p=P("aes-128-ctr",r.subarray(0,16),n),o=Buffer.concat([p.update(Buffer.from(t,"utf8")),p.final()]),f=Buffer.concat([r.subarray(16,32),Buffer.from(o)]),l=await x(f);return{meta:"xchain-keystore",version:1,crypto:{cipher:"aes-128-ctr",cipherparams:{iv:n.toString("hex")},ciphertext:o.toString("hex"),kdf:"pbkdf2",kdfparams:a,mac:l}}}function H(t=12){return T(g,t===12?128:256)}function X(t){return D(t,g)}async function $(t,i){let{SwapKitError:s}=await import("@swapkit/helpers");switch(t.version){case 1:{let n=t.crypto.kdfparams,e=Buffer.from(n.salt,"hex"),a=y(i,e,n.c,n.dklen,"sha256"),r=Buffer.from(t.crypto.ciphertext,"hex"),p=Buffer.concat([a.subarray(16,32),r]);if(await x(p)!==t.crypto.mac)throw new s("wallet_keystore_invalid_password");let f=K(t.crypto.cipher,a.subarray(0,16),Buffer.from(t.crypto.cipherparams.iv,"hex"));return Buffer.concat([f.update(r),f.final()]).toString("utf8")}default:throw new s("wallet_keystore_unsupported_version")}}var N=U({name:"connectKeystore",walletType:w.KEYSTORE,supportedChains:[...A,...R,...E,c.Polkadot,c.Chainflip,c.Ripple,c.Solana,c.Tron,c.Near],connect:({addChain:t,supportedChains:i,walletType:s})=>async function n(e,a,r){let p=W({chains:e,supportedChains:i,walletType:s});return await Promise.all(p.map(async(o)=>{let f=typeof r==="number"?r:0,l=r&&typeof r==="object"?r[o]:void 0,b=_[o].slice(0,o===c.Solana?4:5),k=l||F(b,{index:f}),{getToolbox:S}=await import("@swapkit/toolboxes"),u=await S(o,{phrase:a,derivationPath:k}),C=await u.getAddress()||"",B={...u,address:C};t({...B,chain:o,walletType:w.KEYSTORE})})),!0}}),I=v(N);export{X as validatePhrase,N as keystoreWallet,H as generatePhrase,V as encryptToKeyStore,$ as decryptFromKeystore,I as KEYSTORE_SUPPORTED_CHAINS};
|
|
2
2
|
|
|
3
|
-
//# debugId=
|
|
3
|
+
//# debugId=E28F1ED5D0FD24A764756E2164756E21
|
|
4
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -6,6 +6,6 @@
|
|
|
6
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 { blake2bFinal, blake2bInit, blake2bUpdate } = (await import(\"blakejs\")).default;\n let data = initData;\n\n if (!(data instanceof Buffer)) {\n // @ts-ignore\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, prf: \"hmac-sha256\", dklen: 32, 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([\n cipherIV.update(Buffer.from(phrase, \"utf8\")),\n cipherIV.final(),\n ]);\n const initData = Buffer.concat([derivedKey.subarray(16, 32), Buffer.from(ciphertext)]);\n const mac = await blake256(initData);\n\n return {\n meta: \"xchain-keystore\",\n version: 1,\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 };\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
8
|
"mappings": "iGAAA,cACE,kBACA,eAEA,2BACA,gBACA,kBACA,kBACA,2BACA,0BACA,yBCVF,yBAAS,sBAAgB,gBAAkB,iBAAY,oBACvD,2BAAS,sBAAkB,qBAC3B,mBAAS,uCAeT,eAAe,CAAQ,CAAC,EAA2B,CACjD,IAAQ,eAAc,cAAa,kBAAmB,KAAa,oBAAY,QAC3E,EAAO,EAEX,KAAM,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,IAAK,cAAe,MAAO,GAAI,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,CAC/B,EAAS,OAAO,OAAO,KAAK,EAAQ,MAAM,CAAC,EAC3C,EAAS,MAAM,CACjB,CAAC,EACK,EAAW,OAAO,OAAO,CAAC,EAAW,SAAS,GAAI,EAAE,EAAG,OAAO,KAAK,CAAU,CAAC,CAAC,EAC/E,EAAM,MAAM,EAAS,CAAQ,EAEnC,MAAO,CACL,KAAM,kBACN,QAAS,EACT,OAAQ,CACN,OAlBW,cAmBX,aAAc,CAAE,GAAI,EAAG,SAAS,KAAK,CAAE,EACvC,WAAY,EAAW,SAAS,KAAK,EACrC,IAAK,SACL,UAAW,EACX,KACF,CACF,EAGK,SAAS,CAAc,CAAC,EAAgB,GAAI,CACjD,OAAO,EAAiB,EAAU,IAAS,GAAK,IAAM,GAAG,EAGpD,SAAS,CAAc,CAAC,EAAgB,CAC7C,OAAO,EAAiB,EAAQ,CAAQ,EAG1C,eAAsB,CAAmB,CAAC,EAAoB,EAAkB,CAC9E,IAAQ,gBAAiB,KAAa,4BAEtC,OAAQ,EAAS,aACV,GAAG,CACN,IAAM,EAAY,EAAS,OAAO,UAC5B,EAAO,OAAO,KAAK,EAAU,KAAM,KAAK,EACxC,EAAa,EAAW,EAAU,EAAM,EAAU,EAAG,EAAU,MAAO,QAAQ,EAE9E,EAAa,OAAO,KAAK,EAAS,OAAO,WAAY,KAAK,EAC1D,EAAW,OAAO,OAAO,CAAC,EAAW,SAAS,GAAI,EAAE,EAAG,CAAU,CAAC,EAGxE,GAFY,MAAM,EAAS,CAAQ,IAEvB,EAAS,OAAO,IAC1B,MAAM,IAAI,EAAa,kCAAkC,EAG3D,IAAM,EAAW,EACf,EAAS,OAAO,OAChB,EAAW,SAAS,EAAG,EAAE,EACzB,OAAO,KAAK,EAAS,OAAO,aAAa,GAAI,KAAK,CACpD,EAGA,OADe,OAAO,OAAO,CAAC,EAAS,OAAO,CAAU,EAAG,EAAS,MAAM,CAAC,CAAC,EAC9D,SAAS,MAAM,CAC/B,SAGE,MAAM,IAAI,EAAa,qCAAqC,GDrF3D,IAAM,EAAiB,EAAa,CACzC,KAAM,kBACN,WAAY,EAAa,SACzB,gBAAiB,CACf,GAAG,EACH,GAAG,EACH,GAAG,EACH,EAAM,SACN,EAAM,UACN,EAAM,OACN,EAAM,OACN,EAAM,KACN,EAAM,IACR,EACA,QAAS,EAAG,WAAU,kBAAiB,gBACrC,eAAe,CAAe,CAC5B,EACA,EACA,EACA,CACA,IAAM,EAAiB,EAAsB,CAAE,SAAQ,kBAAiB,YAAW,CAAC,EAgCpF,OA9BA,MAAM,QAAQ,IACZ,EAAe,IAAI,MAAO,IAAU,CAClC,IAAM,EACJ,OAAO,IAA6B,SAAW,EAA2B,EAEtE,EACJ,GAA4B,OAAO,IAA6B,SAC5D,EAAyB,GACzB,OAEA,EAA0B,EAAsB,GAAO,MAC3D,EACA,IAAU,EAAM,OAAS,EAAI,CAC/B,EAEM,EACJ,GACA,EAAqB,EAAyB,CAAE,MAAO,CAAoB,CAAC,GAEtE,cAAe,KAAa,8BAE9B,EAAU,MAAM,EAAW,EAAO,CAAE,SAAQ,gBAAe,CAAC,EAC5D,EAAW,MAAM,EAAQ,WAAW,GAAM,GAE1C,EAAS,IAAK,EAAS,SAAQ,EAErC,EAAS,IAAK,EAAQ,QAAO,WAAY,EAAa,QAAS,CAAC,EACjE,CACH,EAEO,GAEb,CAAC,EAEY,EAA4B,EAAyB,CAAc",
|
|
9
|
-
"debugId": "
|
|
9
|
+
"debugId": "E28F1ED5D0FD24A764756E2164756E21",
|
|
10
10
|
"names": []
|
|
11
11
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
var WL={};XL(WL,{ledgerWallet:()=>K0,LEDGER_SUPPORTED_CHAINS:()=>BL});module.exports=TL(WL);var T=require("@swapkit/helpers");var j=require("@swapkit/helpers"),V=async({chain:L,ledgerClient:m})=>{if(!m)return"";switch(L){case j.Chain.Cosmos:case j.Chain.THORChain:return m.connect();case j.Chain.Ethereum:case j.Chain.BinanceSmartChain:case j.Chain.Avalanche:case j.Chain.Polygon:case j.Chain.Arbitrum:case j.Chain.Optimism:case j.Chain.Base:return m.getAddress();case j.Chain.Bitcoin:case j.Chain.BitcoinCash:case j.Chain.Dash:case j.Chain.Dogecoin:case j.Chain.Litecoin:{let _=m;await _.connect();let O=await _.getAddress();return L===j.Chain.BitcoinCash?O.replace("bitcoincash:",""):O}case j.Chain.Near:return await m.getAddress();case j.Chain.Ripple:return m.address;default:throw new j.SwapKitError("wallet_chain_not_supported",{wallet:j.WalletOption.LEDGER,chain:L})}};var $=require("@swapkit/helpers");var A=require("@swapkit/helpers");var w=require("@swapkit/helpers");var r=require("@swapkit/helpers");var E=85,p=250;var S={GET_VERSION:0,INS_PUBLIC_KEY_SECP256K1:1,SIGN_SECP256K1:2,GET_ADDR_SECP256K1:4},i={INIT:0,ADD:1,LAST:2},a={ONLY_RETRIEVE:0,SHOW_ADDRESS_IN_DEVICE:1},k={JSON:0},z={NoError:36864},F0={1:"U2F: Unknown",2:"U2F: Bad request",3:"U2F: Configuration unsupported",4:"U2F: Device Ineligible",5:"U2F: Timeout",14:"Timeout",36864:"No errors",36865:"Device is busy",26626:"Error deriving keys",25600:"Execution Error",26368:"Wrong Length",27010:"Empty Buffer",27011:"Output buffer too small",27012:"Data is invalid",27013:"Conditions not satisfied",27014:"Transaction rejected",27264:"Bad key handle",27392:"Invalid P1/P2",27904:"Instruction not supported",28160:"App does not seem to be open",28416:"Unknown error",28417:"Sign/verify error"};function H(L){if(L in F0)return F0[L];return`Unknown Status Code: ${L}`}function s0(L){return typeof L==="object"&&L!==null&&!Array.isArray(L)&&!(L instanceof Date)}function Z(L){if(L){if(s0(L)){if(Object.prototype.hasOwnProperty.call(L,"statusCode"))return{return_code:L.statusCode,error_message:H(L.statusCode)};if(Object.prototype.hasOwnProperty.call(L,"return_code")&&Object.prototype.hasOwnProperty.call(L,"error_message"))return L}return{return_code:65535,error_message:L.toString()}}return{return_code:65535,error_message:L.toString()}}async function s(L){return L.send(85,S.GET_VERSION,0,0).then((m)=>{let _=m.slice(-2),O=_[0]*256+_[1],y=0;if(m.length>=9)y=(m[5]<<24)+(m[6]<<16)+(m[7]<<8)+(m[8]<<0);return{return_code:O,error_message:H(O),test_mode:m[0]!==0,major:m[1],minor:m[2],patch:m[3],device_locked:m[4]===1,target_id:y.toString(16)}},Z)}var x=require("@swapkit/helpers");function R0(L){if(L==null||L.length<3)throw new x.SwapKitError("wallet_ledger_invalid_params",{reason:"Path too short"});if(L.length>10)throw new x.SwapKitError("wallet_ledger_invalid_params",{reason:"Path too long"});let m=Buffer.alloc(1+4*L.length);m.writeUInt8(L.length,0);for(let _=0;_<L.length;_+=1){let O=L[_]||0;if(_<3)O|=2147483648;m.writeInt32LE(O,1+_*4)}return m}async function e(L,m,_,O,y=k.JSON){return L.transport.send(E,S.SIGN_SECP256K1,m,y,O,[z.NoError,27012,27264]).then((X)=>{let G=X.slice(-2),B=G[0]*256+G[1],F=H(B);if(B===27264||B===27012)F=`${F} : ${X.slice(0,X.length-2).toString("ascii")}`;let R=null;if(X.length>2)R=X.slice(0,X.length-2);return{signature:R,return_code:B,error_message:F}},Z)}function e0(L){if(L.length!==65)throw new x.SwapKitError("wallet_ledger_invalid_params",{reason:"decompressed public key length should be 65 bytes"});let m=L.slice(33,65),_=Buffer.from([2+(m[m.length-1]&1)]);return Buffer.concat([_,L.slice(1,33)])}async function W0(L,m){return L.transport.send(E,S.INS_PUBLIC_KEY_SECP256K1,0,0,m,[z.NoError]).then((_)=>{let O=_.slice(-2),y=O[0]*256+O[1],X=Buffer.from(_.slice(0,65));return{pk:X,compressed_pk:e0(X),return_code:y,error_message:H(y)}},Z)}function J0(L){if(!L||L.length!==5)throw new x.SwapKitError("wallet_ledger_invalid_params",{reason:"Path must be exactly 5 elements"});let m=Buffer.alloc(20);return m.writeUInt32LE(2147483648+L[0],0),m.writeUInt32LE(2147483648+L[1],4),m.writeUInt32LE(2147483648+L[2],8),m.writeUInt32LE(L[3],12),m.writeUInt32LE(L[4],16),m}function $0(L,m,_,O,y=k.JSON){let X=i.ADD;if(m===1)X=i.INIT;if(m===_)X=i.LAST;return e(L,X,0,O,y)}async function j0(L,m){return L.transport.send(E,S.GET_ADDR_SECP256K1,0,0,m,[z.NoError]).then((_)=>{let O=_.slice(-2),y=O[0]*256+O[1];return{pk:"OBSOLETE PROPERTY",compressed_pk:Buffer.from(_.slice(0,33)),return_code:y,error_message:H(y)}},Z)}class g{transport;versionResponse;constructor(L){if(!L)throw new r.SwapKitError("wallet_ledger_transport_not_defined");this.transport=L}static serializeHRP(L){if(L==null||L.length<3||L.length>83)throw new r.SwapKitError("wallet_ledger_invalid_params",{reason:"Invalid HRP"});let m=Buffer.alloc(1+L.length);return m.writeUInt8(L.length,0),m.write(L,1),m}async serializePath(L){if(this.versionResponse=await s(this.transport),this.versionResponse.return_code!==z.NoError)throw this.versionResponse;switch(this.versionResponse.major){case 1:return R0(L);case 2:return J0(L);default:return Buffer.alloc(0)}}async signGetChunks(L,m){let _=await this.serializePath(L),O=[];O.push(_);for(let y=0;y<m.length;y+=p){let X=y+p;if(y>m.length)X=m.length;O.push(m.slice(y,X))}return O}async getVersion(){try{return this.versionResponse=await s(this.transport),this.versionResponse}catch(L){return Z(L)}}async appInfo(){return this.transport.send(176,1,0,0).then((L)=>{let m=L.slice(-2),_=m[0]*256+m[1],O="",y="",X=0,G=0;if(L[0]!==1)return{return_code:36865,error_message:"response format ID not recognized"};let B=L[1];O=L.slice(2,2+B).toString("ascii");let F=2+B,R=L[F];F+=1,y=L.slice(F,F+R).toString("ascii"),F+=R;let J=L[F];return F+=1,X=J,G=L[F],{return_code:_,error_message:H(_),appName:O,appVersion:y,flagLen:X,flagsValue:G,flag_recovery:(G&1)!==0,flag_signed_mcu_code:(G&2)!==0,flag_onboarded:(G&4)!==0,flag_pin_validated:(G&128)!==0}},Z)}async deviceInfo(){return this.transport.send(224,1,0,0,Buffer.from([]),[z.NoError,28160]).then((L)=>{let m=L.slice(-2),_=m[0]*256+m[1];if(_===28160)return{return_code:_,error_message:"This command is only available in the Dashboard"};let O=L.slice(0,4).toString("hex"),y=4,X=L[y];y+=1;let G=L.slice(y,y+X).toString();y+=X;let B=L[y];y+=1;let F=L.slice(y,y+B).toString("hex");y+=B;let R=L[y];y+=1;let J=L.slice(y,y+R);if(J[R-1]===0)J=L.slice(y,y+R-1);let M=J.toString();return{return_code:_,error_message:H(_),targetId:O,seVersion:G,flag:F,mcuVersion:M}},Z)}async publicKey(L){try{let m=await this.serializePath(L);switch(this.versionResponse.major){case 1:return W0(this,m);case 2:{let _=Buffer.concat([g.serializeHRP("thor"),m]);return j0(this,_)}default:return{return_code:25600,error_message:"App Version is not supported"}}}catch(m){return Z(m)}}async getAddressAndPubKey(L,m,_=!1){return this.serializePath(L).then((O)=>{let y=Buffer.concat([g.serializeHRP(m),O]);return this.transport.send(E,S.GET_ADDR_SECP256K1,_?a.SHOW_ADDRESS_IN_DEVICE:a.ONLY_RETRIEVE,0,y,[z.NoError]).then((X)=>{let G=X.slice(-2),B=G[0]*256+G[1],F=Buffer.from(X.slice(0,33));return{bech32_address:Buffer.from(X.slice(33,-2)).toString(),compressed_pk:F,return_code:B,error_message:H(B)}},Z)}).catch((O)=>Z(O))}showAddressAndPubKey(L,m){return this.getAddressAndPubKey(L,m,!0)}signSendChunk(L,m,_,O=k.JSON){switch(this.versionResponse.major){case 1:return e(this,L,m,_,O);case 2:return $0(this,L,m,_,O);default:return{return_code:25600,error_message:"App Version is not supported"}}}async sign(L,m,_=k.JSON){let O=Buffer.from(m),y=[],X;try{y=await this.signGetChunks(L,O),X=await this.signSendChunk(1,y.length,y[0],_)}catch(B){Z(B)}let G={return_code:X.return_code,error_message:X.error_message,signature:null};for(let B=1;B<y.length;B+=1)if(G=await this.signSendChunk(1+B,y.length,y[B],_),G.return_code!==z.NoError)break;return{return_code:G.return_code,error_message:G.error_message,signature:G.signature}}}var c=require("@swapkit/helpers"),L0=()=>navigator?.usb,r0=async()=>{let L=L0();if(typeof L?.getDevices!=="function")return[];let{ledgerUSBVendorId:m}=await import("@ledgerhq/devices"),O=(await L?.getDevices()).filter((y)=>y.vendorId===m);if(O.length>0)return O[0];return L?.requestDevice({filters:[{vendorId:m}]})},N=async()=>{let L=await r0();if(!L)throw new c.SwapKitError("wallet_ledger_device_not_found");if(await L.open(),L.configuration===null)await L.selectConfiguration(1);try{await L.reset()}catch{}let m=L.configurations[0].interfaces.find(({alternates:B})=>B.some(({interfaceClass:F})=>F===255));if(!m)throw await L.close(),new c.SwapKitError("wallet_ledger_connection_error");try{await L.claimInterface(m.interfaceNumber)}catch(B){throw await L.close(),new c.SwapKitError("wallet_ledger_connection_claimed",B)}let _=(await import("@ledgerhq/hw-transport-webusb")).default;if(!await _.isSupported())throw new c.SwapKitError("wallet_ledger_webusb_not_supported");let{DisconnectedDevice:y}=await import("@ledgerhq/errors"),X=new _(L,m.interfaceNumber),G=(B)=>{if(L===B.device)L0()?.removeEventListener("disconnect",G),X._emitDisconnect(new y)};return L0()?.addEventListener("disconnect",G),X};class v{ledgerTimeout=50000;derivationPath=w.NetworkDerivationPath.GAIA;transport;ledgerApp;chain="thor";checkOrCreateTransportAndLedger=async(L=!1)=>{if(!L&&this.transport&&this.ledgerApp)return;try{switch(this.transport=L||!this.transport?await N():this.transport,this.chain){case"thor":{this.ledgerApp=L||!this.ledgerApp?new g(this.transport):this.ledgerApp;break}case"cosmos":{let m=(await import("@ledgerhq/hw-app-cosmos")).default;this.ledgerApp=L||!this.ledgerApp?new m(this.transport):this.ledgerApp}}return this.ledgerApp}catch(m){throw new w.SwapKitError("wallet_ledger_connection_error",m)}};validateResponse=(L,m)=>{switch(L){case w.LedgerErrorCode.NoError:return;case w.LedgerErrorCode.LockedDevice:throw new w.SwapKitError("wallet_ledger_device_locked",{message:`Ledger is locked: ${m}`});case w.LedgerErrorCode.TC_NotFound:throw new w.SwapKitError("wallet_ledger_device_not_found");default:break}}}class m0 extends v{pubKey=null;derivationPath;constructor(L=A.NetworkDerivationPath.GAIA){super();this.chain="cosmos",this.derivationPath=A.derivationPathToString(L)}connect=async()=>{await this.checkOrCreateTransportAndLedger(!0);let{publicKey:L,address:m}=await this.getAddressAndPubKey();return this.pubKey=Buffer.from(L,"hex").toString("base64"),m};getAddressAndPubKey=async()=>{return await this.checkOrCreateTransportAndLedger(!0),await this.ledgerApp.getAddress(this.derivationPath,this.chain)};signTransaction=async(L,m="0")=>{await this.checkOrCreateTransportAndLedger(!0);let{return_code:_,error_message:O,signature:y}=await this.ledgerApp.sign(this.derivationPath,L);if(!this.pubKey)throw new A.SwapKitError("wallet_ledger_pubkey_not_found");return this.validateResponse(_,O),[{pub_key:{type:"tendermint/PubKeySecp256k1",value:this.pubKey},sequence:m,signature:y}]};signAmino=async(L,m)=>{await this.checkOrCreateTransportAndLedger(!0);let _=await this.getAccounts();if(_.findIndex((J)=>J.address===L)===-1)throw new A.SwapKitError("wallet_ledger_address_not_found",{address:L});let{encodeSecp256k1Signature:y,serializeSignDoc:X}=(await import("@cosmjs/amino")).default,{Secp256k1Signature:G}=(await import("@cosmjs/crypto")).default,B=X(m),F=await this.ledgerApp.sign(this.derivationPath,B);this.validateResponse(F.return_code,F.error_message);let R=G.fromDer(F.signature).toFixedLength();return{signed:m,signature:y(_[0].pubkey,R)}};getAccounts=async()=>{await this.checkOrCreateTransportAndLedger(!0);let L=await this.getAddressAndPubKey();return[{address:L.address,algo:"secp256k1",pubkey:Buffer.from(L.publicKey,"hex")}]}}var Q=require("@swapkit/helpers"),Q0=require("ethers");class q extends Q0.AbstractSigner{chainId=Q.ChainId.Ethereum;derivationPath="";ledgerApp=null;ledgerTimeout=50000;constructor({provider:L,derivationPath:m=Q.NetworkDerivationPath.OP,chainId:_=Q.ChainId.Optimism}){super(L);this.chainId=_||Q.ChainId.Ethereum,this.derivationPath=typeof m==="string"?m:Q.derivationPathToString(m),Object.defineProperty(this,"provider",{enumerable:!0,value:L||null,writable:!1})}connect=(L)=>new q({provider:L,derivationPath:this.derivationPath,chainId:this.chainId});checkOrCreateTransportAndLedger=async()=>{if(this.ledgerApp)return;await this.createTransportAndLedger()};createTransportAndLedger=async()=>{let L=await N(),m=(await import("@ledgerhq/hw-app-eth")).default;this.ledgerApp=new m(L)};getAddress=async()=>{let L=await this.getAddressAndPubKey();if(!L)throw new Q.SwapKitError("wallet_ledger_failed_to_get_address");return L.address};getAddressAndPubKey=async()=>{return await this.createTransportAndLedger(),this.ledgerApp?.getAddress(this.derivationPath)};showAddressAndPubKey=async()=>{return await this.createTransportAndLedger(),this.ledgerApp?.getAddress(this.derivationPath,!0)};signMessage=async(L)=>{let{Signature:m}=await import("ethers");await this.createTransportAndLedger();let _=await this.ledgerApp?.signPersonalMessage(this.derivationPath,L);if(!_)throw new Q.SwapKitError("wallet_ledger_signing_error");return _.r=`0x${_.r}`,_.s=`0x${_.s}`,m.from(_).serialized};sendTransaction=async(L)=>{if(!this.provider)throw new Q.SwapKitError("wallet_ledger_no_provider");let m=await this.signTransaction(L);return await this.provider.broadcastTransaction(m)};signTypedData(){throw new Q.SwapKitError("wallet_ledger_method_not_supported",{method:"signTypedData"})}signTransaction=async(L)=>{let{Transaction:m}=await import("ethers");await this.createTransportAndLedger();let _=await this.provider?.getTransactionCount(L.from||await this.getAddress()),O={chainId:L.chainId||this.chainId,data:L.data,gasLimit:L.gasLimit,...L.gasPrice&&{gasPrice:L.gasPrice},...!L.gasPrice&&L.maxFeePerGas&&{maxFeePerGas:L.maxFeePerGas,maxPriorityFeePerGas:L.maxPriorityFeePerGas},nonce:L.nonce!==void 0?Number((L.nonce||_||0).toString()):_,to:L.to?.toString(),value:L.value,type:L.type&&!Number.isNaN(L.type)?L.type:L.maxFeePerGas?2:0},y=m.from(O).unsignedSerialized.slice(2),{ledgerService:X}=await import("@ledgerhq/hw-app-eth"),G=await X.resolveTransaction(y,{},{externalPlugins:!0,erc20:!0}),B=await this.ledgerApp?.signTransaction(this.derivationPath,y,G);if(!B)throw new Q.SwapKitError("wallet_ledger_signing_error");let{r:F,s:R,v:J}=B;return m.from({...O,signature:{v:Number(BigInt(J)),r:`0x${F}`,s:`0x${R}`}}).serialized}}var Y0=({provider:L,derivationPath:m})=>new q({chainId:Q.ChainId.Ethereum,provider:L,derivationPath:m}),M0=({provider:L,derivationPath:m})=>new q({chainId:Q.ChainId.Avalanche,provider:L,derivationPath:m}),Z0=({provider:L,derivationPath:m})=>new q({chainId:Q.ChainId.BinanceSmartChain,provider:L,derivationPath:m}),N0=({provider:L,derivationPath:m})=>new q({chainId:Q.ChainId.Arbitrum,provider:L,derivationPath:m}),C0=({provider:L,derivationPath:m})=>new q({chainId:Q.ChainId.Polygon,provider:L,derivationPath:m}),U0=({provider:L,derivationPath:m})=>new q({chainId:Q.ChainId.Optimism,provider:L,derivationPath:m}),H0=({provider:L,derivationPath:m})=>new q({chainId:Q.ChainId.Base,provider:L,derivationPath:m});async function w0(L,m){let _=await import("@ledgerhq/hw-app-near"),{Chain:O,DerivationPath:y,derivationPathToString:X,SwapKitError:G}=await import("@swapkit/helpers"),B=new _.default(L),F=m?X(m):y[O.Near],{address:R,publicKey:J}=await B.getAddress(F);return{async getPublicKey(){let{utils:Y}=await import("near-api-js");return Y.PublicKey.fromString(`ed25519:${J}`)},signNep413Message(Y,C,f,U,K){return Promise.reject(new G("wallet_ledger_method_not_supported",{wallet:"Ledger",method:"signNep413Message"}))},getAddress(){return Promise.resolve(R)},async signTransaction(Y){let{Signature:C,SignedTransaction:f}=await import("near-api-js/lib/transaction");try{let U=await B.signTransaction(Y.encode(),F);if(!U)throw new Error("Signature undefined");let K=new C({keyType:0,data:U}),d=new f({transaction:Y,signature:K});return[U,d]}catch(U){throw new G("wallet_ledger_signing_error",{error:U})}},signDelegateAction(Y){return Promise.reject(new G("wallet_ledger_method_not_supported",{wallet:"Ledger",method:"signDelegateAction"}))}}}var f0=require("@scure/base"),h=require("@swapkit/helpers");var D0=require("@scure/base"),D=require("@swapkit/helpers"),_0=(L)=>{if(L.length<64)throw new D.SwapKitError("wallet_ledger_invalid_signature",{reason:"Too short"});if(L[0]!==48)throw new D.SwapKitError("wallet_ledger_invalid_signature",{reason:"TLV encoding: expected first byte 0x30"});if(L[1]+2!==L.length)throw new D.SwapKitError("wallet_ledger_invalid_signature",{reason:"signature length does not match TLV"});if(L[2]!==2)throw new D.SwapKitError("wallet_ledger_invalid_signature",{reason:"TLV encoding: expected length type 0x02"});let m=L[3],_=L.slice(4,m+4);if(_.length===33&&_[0]===0)_=_.slice(1,33);else if(_.length===33)throw new D.SwapKitError("wallet_ledger_invalid_signature",{reason:"r too long"});while(_.length<32)_.unshift(0);if(L[m+4]!==2)throw new D.SwapKitError("wallet_ledger_invalid_signature",{reason:"TLV encoding: expected length type 0x02 for s"});let O=L[m+5];if(4+m+2+O!==L.length)throw new D.SwapKitError("wallet_ledger_invalid_signature",{reason:"TLV byte lengths do not match message length"});let y=L.slice(m+6,L.length);if(y.length===33&&y[0]===0)y=y.slice(1,33);else if(y.length===33)throw new D.SwapKitError("wallet_ledger_invalid_signature",{reason:"s too long"});while(y.length<32)y.unshift(0);if(_.length!==32||y.length!==32)throw new D.SwapKitError("wallet_ledger_invalid_signature",{reason:"must be 32 bytes each"});return D0.base64.encode(Buffer.concat([_,y]))};class y0 extends v{pubKey=null;derivationPath;constructor(L=h.NetworkDerivationPath.THOR){super();this.chain="thor",this.derivationPath=L}get pubkey(){return this.pubKey}connect=async()=>{await this.checkOrCreateTransportAndLedger();let{compressed_pk:L,bech32_address:m}=await this.getAddressAndPubKey();return this.pubKey=f0.base64.encode(L),m};getAddressAndPubKey=async()=>{await this.checkOrCreateTransportAndLedger(!0);let L=await this.ledgerApp.getAddressAndPubKey(this.derivationPath,this.chain);return this.validateResponse(L.return_code,L.error_message),L};showAddressAndPubKey=async()=>{await this.checkOrCreateTransportAndLedger(!0);let L=await this.ledgerApp.showAddressAndPubKey(this.derivationPath,this.chain);return this.validateResponse(L.return_code,L.error_message),L};signTransaction=async(L,m="0")=>{await this.checkOrCreateTransportAndLedger(!0);let{return_code:_,error_message:O,signature:y}=await this.ledgerApp.sign(this.derivationPath,L);if(!this.pubKey)throw new h.SwapKitError("wallet_ledger_pubkey_not_found");return this.validateResponse(_,O),[{pub_key:{type:"tendermint/PubKeySecp256k1",value:this.pubKey},sequence:m,signature:_0(y)}]};sign=async(L)=>{await this.checkOrCreateTransportAndLedger(!0);let{return_code:m,error_message:_,signature:O}=await this.ledgerApp.sign(this.derivationPath,L);if(!this.pubKey)throw new h.SwapKitError("wallet_ledger_pubkey_not_found");return this.validateResponse(m,_),_0(O)}}var I=require("@swapkit/helpers"),z0=require("bitcoinjs-lib");var LL=async({psbt:L,inputUtxos:m,btcApp:_,derivationPath:O},y)=>{let X=m.map((J)=>{let M=z0.Transaction.fromHex(J.txHex||"");return[_.splitTransaction(M.toHex(),M.hasWitnesses()),J.index,void 0,void 0]}),G=L.data.globalMap.unsignedTx.toBuffer().toString("hex"),B=_.splitTransaction(G,!0),F=_.serializeTransactionOutputs(B).toString("hex"),R={additionals:["bech32"],associatedKeysets:X.map(()=>O),inputs:X,outputScriptHex:F,segwit:!0,useTrustedInputForSegwit:!0};return _.createPaymentTransaction({...R,...y})},u=({chain:L,additionalSignParams:m})=>{let _,O=null;async function y(G=!0){if(G&&!_)new I.SwapKitError("wallet_ledger_connection_error",{message:`Ledger connection failed:
|
|
2
|
-
${JSON.stringify({checkBtcApp:G,btcApp:
|
|
1
|
+
var jm={};Fm(jm,{ledgerWallet:()=>b0,LEDGER_SUPPORTED_CHAINS:()=>Rm});module.exports=Gm(jm);var T=require("@swapkit/helpers");var j=require("@swapkit/helpers"),I=async({chain:m,ledgerClient:L})=>{if(!L)return"";switch(m){case j.Chain.Cosmos:case j.Chain.THORChain:return L.connect();case j.Chain.Ethereum:case j.Chain.BinanceSmartChain:case j.Chain.Avalanche:case j.Chain.Polygon:case j.Chain.Arbitrum:case j.Chain.Optimism:case j.Chain.Base:return L.getAddress();case j.Chain.Bitcoin:case j.Chain.BitcoinCash:case j.Chain.Dash:case j.Chain.Dogecoin:case j.Chain.Litecoin:{let y=L;await y.connect();let O=await y.getAddress();return m===j.Chain.BitcoinCash?O.replace("bitcoincash:",""):O}case j.Chain.Near:return await L.getAddress();case j.Chain.Ripple:return L.address;case j.Chain.Tron:return L.getAddress();default:throw new j.SwapKitError("wallet_chain_not_supported",{wallet:j.WalletOption.LEDGER,chain:m})}};var $=require("@swapkit/helpers");var V=require("@swapkit/helpers");var D=require("@swapkit/helpers");var m0=require("@swapkit/helpers");var b=85,a=250;var S={GET_VERSION:0,INS_PUBLIC_KEY_SECP256K1:1,SIGN_SECP256K1:2,GET_ADDR_SECP256K1:4},o={INIT:0,ADD:1,LAST:2},s={ONLY_RETRIEVE:0,SHOW_ADDRESS_IN_DEVICE:1},k={JSON:0},q={NoError:36864},R0={1:"U2F: Unknown",2:"U2F: Bad request",3:"U2F: Configuration unsupported",4:"U2F: Device Ineligible",5:"U2F: Timeout",14:"Timeout",36864:"No errors",36865:"Device is busy",26626:"Error deriving keys",25600:"Execution Error",26368:"Wrong Length",27010:"Empty Buffer",27011:"Output buffer too small",27012:"Data is invalid",27013:"Conditions not satisfied",27014:"Transaction rejected",27264:"Bad key handle",27392:"Invalid P1/P2",27904:"Instruction not supported",28160:"App does not seem to be open",28416:"Unknown error",28417:"Sign/verify error"};function H(m){if(m in R0)return R0[m];return`Unknown Status Code: ${m}`}function mm(m){return typeof m==="object"&&m!==null&&!Array.isArray(m)&&!(m instanceof Date)}function C(m){if(m){if(mm(m)){if(Object.prototype.hasOwnProperty.call(m,"statusCode"))return{return_code:m.statusCode,error_message:H(m.statusCode)};if(Object.prototype.hasOwnProperty.call(m,"return_code")&&Object.prototype.hasOwnProperty.call(m,"error_message"))return m}return{return_code:65535,error_message:m.toString()}}return{return_code:65535,error_message:m.toString()}}async function e(m){return m.send(85,S.GET_VERSION,0,0).then((L)=>{let y=L.slice(-2),O=y[0]*256+y[1],_=0;if(L.length>=9)_=(L[5]<<24)+(L[6]<<16)+(L[7]<<8)+(L[8]<<0);return{return_code:O,error_message:H(O),test_mode:L[0]!==0,major:L[1],minor:L[2],patch:L[3],device_locked:L[4]===1,target_id:_.toString(16)}},C)}var g=require("@swapkit/helpers");function W0(m){if(m==null||m.length<3)throw new g.SwapKitError("wallet_ledger_invalid_params",{reason:"Path too short"});if(m.length>10)throw new g.SwapKitError("wallet_ledger_invalid_params",{reason:"Path too long"});let L=Buffer.alloc(1+4*m.length);L.writeUInt8(m.length,0);for(let y=0;y<m.length;y+=1){let O=m[y]||0;if(y<3)O|=2147483648;L.writeInt32LE(O,1+y*4)}return L}async function r(m,L,y,O,_=k.JSON){return m.transport.send(b,S.SIGN_SECP256K1,L,_,O,[q.NoError,27012,27264]).then((X)=>{let G=X.slice(-2),B=G[0]*256+G[1],F=H(B);if(B===27264||B===27012)F=`${F} : ${X.slice(0,X.length-2).toString("ascii")}`;let R=null;if(X.length>2)R=X.slice(0,X.length-2);return{signature:R,return_code:B,error_message:F}},C)}function Lm(m){if(m.length!==65)throw new g.SwapKitError("wallet_ledger_invalid_params",{reason:"decompressed public key length should be 65 bytes"});let L=m.slice(33,65),y=Buffer.from([2+(L[L.length-1]&1)]);return Buffer.concat([y,m.slice(1,33)])}async function J0(m,L){return m.transport.send(b,S.INS_PUBLIC_KEY_SECP256K1,0,0,L,[q.NoError]).then((y)=>{let O=y.slice(-2),_=O[0]*256+O[1],X=Buffer.from(y.slice(0,65));return{pk:X,compressed_pk:Lm(X),return_code:_,error_message:H(_)}},C)}function $0(m){if(!m||m.length!==5)throw new g.SwapKitError("wallet_ledger_invalid_params",{reason:"Path must be exactly 5 elements"});let L=Buffer.alloc(20);return L.writeUInt32LE(2147483648+m[0],0),L.writeUInt32LE(2147483648+m[1],4),L.writeUInt32LE(2147483648+m[2],8),L.writeUInt32LE(m[3],12),L.writeUInt32LE(m[4],16),L}function j0(m,L,y,O,_=k.JSON){let X=o.ADD;if(L===1)X=o.INIT;if(L===y)X=o.LAST;return r(m,X,0,O,_)}async function M0(m,L){return m.transport.send(b,S.GET_ADDR_SECP256K1,0,0,L,[q.NoError]).then((y)=>{let O=y.slice(-2),_=O[0]*256+O[1];return{pk:"OBSOLETE PROPERTY",compressed_pk:Buffer.from(y.slice(0,33)),return_code:_,error_message:H(_)}},C)}class c{transport;versionResponse;constructor(m){if(!m)throw new m0.SwapKitError("wallet_ledger_transport_not_defined");this.transport=m}static serializeHRP(m){if(m==null||m.length<3||m.length>83)throw new m0.SwapKitError("wallet_ledger_invalid_params",{reason:"Invalid HRP"});let L=Buffer.alloc(1+m.length);return L.writeUInt8(m.length,0),L.write(m,1),L}async serializePath(m){if(this.versionResponse=await e(this.transport),this.versionResponse.return_code!==q.NoError)throw this.versionResponse;switch(this.versionResponse.major){case 1:return W0(m);case 2:return $0(m);default:return Buffer.alloc(0)}}async signGetChunks(m,L){let y=await this.serializePath(m),O=[];O.push(y);for(let _=0;_<L.length;_+=a){let X=_+a;if(_>L.length)X=L.length;O.push(L.slice(_,X))}return O}async getVersion(){try{return this.versionResponse=await e(this.transport),this.versionResponse}catch(m){return C(m)}}async appInfo(){return this.transport.send(176,1,0,0).then((m)=>{let L=m.slice(-2),y=L[0]*256+L[1],O="",_="",X=0,G=0;if(m[0]!==1)return{return_code:36865,error_message:"response format ID not recognized"};let B=m[1];O=m.slice(2,2+B).toString("ascii");let F=2+B,R=m[F];F+=1,_=m.slice(F,F+R).toString("ascii"),F+=R;let J=m[F];return F+=1,X=J,G=m[F],{return_code:y,error_message:H(y),appName:O,appVersion:_,flagLen:X,flagsValue:G,flag_recovery:(G&1)!==0,flag_signed_mcu_code:(G&2)!==0,flag_onboarded:(G&4)!==0,flag_pin_validated:(G&128)!==0}},C)}async deviceInfo(){return this.transport.send(224,1,0,0,Buffer.from([]),[q.NoError,28160]).then((m)=>{let L=m.slice(-2),y=L[0]*256+L[1];if(y===28160)return{return_code:y,error_message:"This command is only available in the Dashboard"};let O=m.slice(0,4).toString("hex"),_=4,X=m[_];_+=1;let G=m.slice(_,_+X).toString();_+=X;let B=m[_];_+=1;let F=m.slice(_,_+B).toString("hex");_+=B;let R=m[_];_+=1;let J=m.slice(_,_+R);if(J[R-1]===0)J=m.slice(_,_+R-1);let Z=J.toString();return{return_code:y,error_message:H(y),targetId:O,seVersion:G,flag:F,mcuVersion:Z}},C)}async publicKey(m){try{let L=await this.serializePath(m);switch(this.versionResponse.major){case 1:return J0(this,L);case 2:{let y=Buffer.concat([c.serializeHRP("thor"),L]);return M0(this,y)}default:return{return_code:25600,error_message:"App Version is not supported"}}}catch(L){return C(L)}}async getAddressAndPubKey(m,L,y=!1){return this.serializePath(m).then((O)=>{let _=Buffer.concat([c.serializeHRP(L),O]);return this.transport.send(b,S.GET_ADDR_SECP256K1,y?s.SHOW_ADDRESS_IN_DEVICE:s.ONLY_RETRIEVE,0,_,[q.NoError]).then((X)=>{let G=X.slice(-2),B=G[0]*256+G[1],F=Buffer.from(X.slice(0,33));return{bech32_address:Buffer.from(X.slice(33,-2)).toString(),compressed_pk:F,return_code:B,error_message:H(B)}},C)}).catch((O)=>C(O))}showAddressAndPubKey(m,L){return this.getAddressAndPubKey(m,L,!0)}signSendChunk(m,L,y,O=k.JSON){switch(this.versionResponse.major){case 1:return r(this,m,L,y,O);case 2:return j0(this,m,L,y,O);default:return{return_code:25600,error_message:"App Version is not supported"}}}async sign(m,L,y=k.JSON){let O=Buffer.from(L),_=[],X;try{_=await this.signGetChunks(m,O),X=await this.signSendChunk(1,_.length,_[0],y)}catch(B){C(B)}let G={return_code:X.return_code,error_message:X.error_message,signature:null};for(let B=1;B<_.length;B+=1)if(G=await this.signSendChunk(1+B,_.length,_[B],y),G.return_code!==q.NoError)break;return{return_code:G.return_code,error_message:G.error_message,signature:G.signature}}}var v=require("@swapkit/helpers"),L0=()=>navigator?.usb,ym=async()=>{let m=L0();if(typeof m?.getDevices!=="function")return[];let{ledgerUSBVendorId:L}=await import("@ledgerhq/devices"),O=(await m?.getDevices()).filter((_)=>_.vendorId===L);if(O.length>0)return O[0];return m?.requestDevice({filters:[{vendorId:L}]})},Y=async()=>{let m=await ym();if(!m)throw new v.SwapKitError("wallet_ledger_device_not_found");if(await m.open(),m.configuration===null)await m.selectConfiguration(1);try{await m.reset()}catch{}let L=m.configurations[0].interfaces.find(({alternates:B})=>B.some(({interfaceClass:F})=>F===255));if(!L)throw await m.close(),new v.SwapKitError("wallet_ledger_connection_error");try{await m.claimInterface(L.interfaceNumber)}catch(B){throw await m.close(),new v.SwapKitError("wallet_ledger_connection_claimed",B)}let y=(await import("@ledgerhq/hw-transport-webusb")).default;if(!await y.isSupported())throw new v.SwapKitError("wallet_ledger_webusb_not_supported");let{DisconnectedDevice:_}=await import("@ledgerhq/errors"),X=new y(m,L.interfaceNumber),G=(B)=>{if(m===B.device)L0()?.removeEventListener("disconnect",G),X._emitDisconnect(new _)};return L0()?.addEventListener("disconnect",G),X};class u{ledgerTimeout=50000;derivationPath=D.NetworkDerivationPath.GAIA;transport;ledgerApp;chain="thor";checkOrCreateTransportAndLedger=async(m=!1)=>{if(!m&&this.transport&&this.ledgerApp)return;try{switch(this.transport=m||!this.transport?await Y():this.transport,this.chain){case"thor":{this.ledgerApp=m||!this.ledgerApp?new c(this.transport):this.ledgerApp;break}case"cosmos":{let L=(await import("@ledgerhq/hw-app-cosmos")).default;this.ledgerApp=m||!this.ledgerApp?new L(this.transport):this.ledgerApp}}return this.ledgerApp}catch(L){throw new D.SwapKitError("wallet_ledger_connection_error",L)}};validateResponse=(m,L)=>{switch(m){case D.LedgerErrorCode.NoError:return;case D.LedgerErrorCode.LockedDevice:throw new D.SwapKitError("wallet_ledger_device_locked",{message:`Ledger is locked: ${L}`});case D.LedgerErrorCode.TC_NotFound:throw new D.SwapKitError("wallet_ledger_device_not_found");default:break}}}class y0 extends u{pubKey=null;derivationPath;constructor(m=V.NetworkDerivationPath.GAIA){super();this.chain="cosmos",this.derivationPath=V.derivationPathToString(m)}connect=async()=>{await this.checkOrCreateTransportAndLedger(!0);let{publicKey:m,address:L}=await this.getAddressAndPubKey();return this.pubKey=Buffer.from(m,"hex").toString("base64"),L};getAddressAndPubKey=async()=>{return await this.checkOrCreateTransportAndLedger(!0),await this.ledgerApp.getAddress(this.derivationPath,this.chain)};signTransaction=async(m,L="0")=>{await this.checkOrCreateTransportAndLedger(!0);let{return_code:y,error_message:O,signature:_}=await this.ledgerApp.sign(this.derivationPath,m);if(!this.pubKey)throw new V.SwapKitError("wallet_ledger_pubkey_not_found");return this.validateResponse(y,O),[{pub_key:{type:"tendermint/PubKeySecp256k1",value:this.pubKey},sequence:L,signature:_}]};signAmino=async(m,L)=>{await this.checkOrCreateTransportAndLedger(!0);let y=await this.getAccounts();if(y.findIndex((J)=>J.address===m)===-1)throw new V.SwapKitError("wallet_ledger_address_not_found",{address:m});let{encodeSecp256k1Signature:_,serializeSignDoc:X}=(await import("@cosmjs/amino")).default,{Secp256k1Signature:G}=(await import("@cosmjs/crypto")).default,B=X(L),F=await this.ledgerApp.sign(this.derivationPath,B);this.validateResponse(F.return_code,F.error_message);let R=G.fromDer(F.signature).toFixedLength();return{signed:L,signature:_(y[0].pubkey,R)}};getAccounts=async()=>{await this.checkOrCreateTransportAndLedger(!0);let m=await this.getAddressAndPubKey();return[{address:m.address,algo:"secp256k1",pubkey:Buffer.from(m.publicKey,"hex")}]}}var M=require("@swapkit/helpers"),Q0=require("ethers");class l extends Q0.AbstractSigner{chainId=M.ChainId.Ethereum;derivationPath="";ledgerApp=null;ledgerTimeout=50000;constructor({provider:m,derivationPath:L=M.NetworkDerivationPath.OP,chainId:y=M.ChainId.Optimism}){super(m);this.chainId=y||M.ChainId.Ethereum,this.derivationPath=typeof L==="string"?L:M.derivationPathToString(L),Object.defineProperty(this,"provider",{enumerable:!0,value:m||null,writable:!1})}connect=(m)=>new l({provider:m,derivationPath:this.derivationPath,chainId:this.chainId});checkOrCreateTransportAndLedger=async()=>{if(this.ledgerApp)return;await this.createTransportAndLedger()};createTransportAndLedger=async()=>{let m=await Y(),L=(await import("@ledgerhq/hw-app-eth")).default;this.ledgerApp=new L(m)};getAddress=async()=>{let m=await this.getAddressAndPubKey();if(!m)throw new M.SwapKitError("wallet_ledger_failed_to_get_address");return m.address};getAddressAndPubKey=async()=>{return await this.createTransportAndLedger(),this.ledgerApp?.getAddress(this.derivationPath)};showAddressAndPubKey=async()=>{return await this.createTransportAndLedger(),this.ledgerApp?.getAddress(this.derivationPath,!0)};signMessage=async(m)=>{let{Signature:L}=await import("ethers");await this.createTransportAndLedger();let y=await this.ledgerApp?.signPersonalMessage(this.derivationPath,m);if(!y)throw new M.SwapKitError("wallet_ledger_signing_error");return y.r=`0x${y.r}`,y.s=`0x${y.s}`,L.from(y).serialized};sendTransaction=async(m)=>{if(!this.provider)throw new M.SwapKitError("wallet_ledger_no_provider");let L=await this.signTransaction(m);return await this.provider.broadcastTransaction(L)};signTypedData(){throw new M.SwapKitError("wallet_ledger_method_not_supported",{method:"signTypedData"})}signTransaction=async(m)=>{let{Transaction:L}=await import("ethers");await this.createTransportAndLedger();let y=await this.provider?.getTransactionCount(m.from||await this.getAddress()),O={chainId:m.chainId||this.chainId,data:m.data,gasLimit:m.gasLimit,...m.gasPrice&&{gasPrice:m.gasPrice},...!m.gasPrice&&m.maxFeePerGas&&{maxFeePerGas:m.maxFeePerGas,maxPriorityFeePerGas:m.maxPriorityFeePerGas},nonce:m.nonce!==void 0?Number((m.nonce||y||0).toString()):y,to:m.to?.toString(),value:m.value,type:m.type&&!Number.isNaN(m.type)?m.type:m.maxFeePerGas?2:0},_=L.from(O).unsignedSerialized.slice(2),{ledgerService:X}=await import("@ledgerhq/hw-app-eth"),G=await X.resolveTransaction(_,{},{externalPlugins:!0,erc20:!0}),B=await this.ledgerApp?.signTransaction(this.derivationPath,_,G);if(!B)throw new M.SwapKitError("wallet_ledger_signing_error");let{r:F,s:R,v:J}=B;return L.from({...O,signature:{v:Number(BigInt(J)),r:`0x${F}`,s:`0x${R}`}}).serialized}}var Y0=({provider:m,derivationPath:L})=>new l({chainId:M.ChainId.Ethereum,provider:m,derivationPath:L}),Z0=({provider:m,derivationPath:L})=>new l({chainId:M.ChainId.Avalanche,provider:m,derivationPath:L}),C0=({provider:m,derivationPath:L})=>new l({chainId:M.ChainId.BinanceSmartChain,provider:m,derivationPath:L}),N0=({provider:m,derivationPath:L})=>new l({chainId:M.ChainId.Arbitrum,provider:m,derivationPath:L}),U0=({provider:m,derivationPath:L})=>new l({chainId:M.ChainId.Polygon,provider:m,derivationPath:L}),H0=({provider:m,derivationPath:L})=>new l({chainId:M.ChainId.Optimism,provider:m,derivationPath:L}),D0=({provider:m,derivationPath:L})=>new l({chainId:M.ChainId.Base,provider:m,derivationPath:L});async function f0(m,L){let y=await import("@ledgerhq/hw-app-near"),{Chain:O,DerivationPath:_,derivationPathToString:X,SwapKitError:G}=await import("@swapkit/helpers"),B=new y.default(m),F=L?X(L):_[O.Near],{address:R,publicKey:J}=await B.getAddress(F);return{async getPublicKey(){let{utils:Q}=await import("near-api-js");return Q.PublicKey.fromString(`ed25519:${J}`)},signNep413Message(Q,N,z,U,E){return Promise.reject(new G("wallet_ledger_method_not_supported",{wallet:"Ledger",method:"signNep413Message"}))},getAddress(){return Promise.resolve(R)},async signTransaction(Q){let{Signature:N,SignedTransaction:z}=await import("near-api-js/lib/transaction");try{let U=await B.signTransaction(Q.encode(),F);if(!U)throw new Error("Signature undefined");let E=new N({keyType:0,data:U}),i=new z({transaction:Q,signature:E});return[U,i]}catch(U){throw new G("wallet_ledger_signing_error",{error:U})}},signDelegateAction(Q){return Promise.reject(new G("wallet_ledger_method_not_supported",{wallet:"Ledger",method:"signDelegateAction"}))}}}var z0=require("@scure/base"),h=require("@swapkit/helpers");var w0=require("@scure/base"),f=require("@swapkit/helpers"),_0=(m)=>{if(m.length<64)throw new f.SwapKitError("wallet_ledger_invalid_signature",{reason:"Too short"});if(m[0]!==48)throw new f.SwapKitError("wallet_ledger_invalid_signature",{reason:"TLV encoding: expected first byte 0x30"});if(m[1]+2!==m.length)throw new f.SwapKitError("wallet_ledger_invalid_signature",{reason:"signature length does not match TLV"});if(m[2]!==2)throw new f.SwapKitError("wallet_ledger_invalid_signature",{reason:"TLV encoding: expected length type 0x02"});let L=m[3],y=m.slice(4,L+4);if(y.length===33&&y[0]===0)y=y.slice(1,33);else if(y.length===33)throw new f.SwapKitError("wallet_ledger_invalid_signature",{reason:"r too long"});while(y.length<32)y.unshift(0);if(m[L+4]!==2)throw new f.SwapKitError("wallet_ledger_invalid_signature",{reason:"TLV encoding: expected length type 0x02 for s"});let O=m[L+5];if(4+L+2+O!==m.length)throw new f.SwapKitError("wallet_ledger_invalid_signature",{reason:"TLV byte lengths do not match message length"});let _=m.slice(L+6,m.length);if(_.length===33&&_[0]===0)_=_.slice(1,33);else if(_.length===33)throw new f.SwapKitError("wallet_ledger_invalid_signature",{reason:"s too long"});while(_.length<32)_.unshift(0);if(y.length!==32||_.length!==32)throw new f.SwapKitError("wallet_ledger_invalid_signature",{reason:"must be 32 bytes each"});return w0.base64.encode(Buffer.concat([y,_]))};class O0 extends u{pubKey=null;derivationPath;constructor(m=h.NetworkDerivationPath.THOR){super();this.chain="thor",this.derivationPath=m}get pubkey(){return this.pubKey}connect=async()=>{await this.checkOrCreateTransportAndLedger();let{compressed_pk:m,bech32_address:L}=await this.getAddressAndPubKey();return this.pubKey=z0.base64.encode(m),L};getAddressAndPubKey=async()=>{await this.checkOrCreateTransportAndLedger(!0);let m=await this.ledgerApp.getAddressAndPubKey(this.derivationPath,this.chain);return this.validateResponse(m.return_code,m.error_message),m};showAddressAndPubKey=async()=>{await this.checkOrCreateTransportAndLedger(!0);let m=await this.ledgerApp.showAddressAndPubKey(this.derivationPath,this.chain);return this.validateResponse(m.return_code,m.error_message),m};signTransaction=async(m,L="0")=>{await this.checkOrCreateTransportAndLedger(!0);let{return_code:y,error_message:O,signature:_}=await this.ledgerApp.sign(this.derivationPath,m);if(!this.pubKey)throw new h.SwapKitError("wallet_ledger_pubkey_not_found");return this.validateResponse(y,O),[{pub_key:{type:"tendermint/PubKeySecp256k1",value:this.pubKey},sequence:L,signature:_0(_)}]};sign=async(m)=>{await this.checkOrCreateTransportAndLedger(!0);let{return_code:L,error_message:y,signature:O}=await this.ledgerApp.sign(this.derivationPath,m);if(!this.pubKey)throw new h.SwapKitError("wallet_ledger_pubkey_not_found");return this.validateResponse(L,y),_0(O)}}var w=require("@swapkit/helpers");class q0{derivationPath;ledgerApp=null;ledgerTimeout=50000;constructor(m){this.derivationPath=typeof m==="string"?m:w.derivationPathToString(m||w.NetworkDerivationPath.TRX)}checkOrCreateTransportAndLedger=async()=>{if(this.ledgerApp)return;await this.createTransportAndLedger()};createTransportAndLedger=async()=>{let m=await Y(),L=(await import("@ledgerhq/hw-app-trx")).default;this.ledgerApp=new L(m)};getAddress=async()=>{let m=await this.getAddressAndPubKey();if(!m)throw new w.SwapKitError("wallet_ledger_failed_to_get_address");return m.address};getAddressAndPubKey=async()=>{await this.createTransportAndLedger();let m=await this.ledgerApp?.getAddress(this.derivationPath);if(!m)throw new w.SwapKitError("wallet_ledger_failed_to_get_address");return{address:m.address,publicKey:m.publicKey}};showAddressAndPubKey=async()=>{return await this.createTransportAndLedger(),this.ledgerApp?.getAddress(this.derivationPath,!0)};signTransaction=async(m)=>{if(await this.createTransportAndLedger(),!this.ledgerApp)throw new w.SwapKitError("wallet_ledger_transport_error");let L=JSON.stringify(m);try{let y=await this.ledgerApp.signTransaction(this.derivationPath,L,[]);if(!y)throw new w.SwapKitError("wallet_ledger_signing_error");return{...m,signature:[y]}}catch(y){throw new w.SwapKitError("wallet_ledger_signing_error",{error:y})}}}var l0=(m)=>new q0(m);var K=require("@swapkit/helpers"),A0=require("bitcoinjs-lib");var _m=async({psbt:m,inputUtxos:L,btcApp:y,derivationPath:O},_)=>{let X=L.map((J)=>{let Z=A0.Transaction.fromHex(J.txHex||"");return[y.splitTransaction(Z.toHex(),Z.hasWitnesses()),J.index,void 0,void 0]}),G=m.data.globalMap.unsignedTx.toBuffer().toString("hex"),B=y.splitTransaction(G,!0),F=y.serializeTransactionOutputs(B).toString("hex"),R={additionals:["bech32"],associatedKeysets:X.map(()=>O),inputs:X,outputScriptHex:F,segwit:!0,useTrustedInputForSegwit:!0};return y.createPaymentTransaction({...R,..._})},d=({chain:m,additionalSignParams:L})=>{let y,O=null;async function _(G=!0){if(G&&!y)new K.SwapKitError("wallet_ledger_connection_error",{message:`Ledger connection failed:
|
|
2
|
+
${JSON.stringify({checkBtcApp:G,btcApp:y})}`});O||=await Y()}async function X(){O=await Y(),y=new(await import("@ledgerhq/hw-app-btc")).default({transport:O,currency:m})}return(G)=>{let B=typeof G==="string"?G:K.derivationPathToString(G),F=K.getWalletFormatFor(B);return{connect:async()=>{await _(!1),y=new(await import("@ledgerhq/hw-app-btc")).default({transport:O,currency:m})},getExtendedPublicKey:async(R="84'/0'/0'",J=76067358)=>{return await _(!1),y.getWalletXpub({path:R,xpubVersion:J})},signTransaction:async(R,J)=>{return await X(),_m({psbt:R,derivationPath:B,btcApp:y,inputUtxos:J},L)},getAddress:async()=>{let{toCashAddress:R}=await import("@swapkit/toolboxes/utxo");await _(!1);let{bitcoinAddress:J}=await y.getWalletPublicKey(B,{format:F});if(!J)throw new K.SwapKitError("wallet_ledger_get_address_error",{message:`Cannot get ${m} address from ledger derivation path: ${B}`});return m==="bitcoin-cash"&&F==="legacy"?R(J).replace(/(bchtest:|bitcoincash:)/,""):J}}}},P0=d({chain:"bitcoin"}),I0=d({chain:"litecoin"}),S0=d({chain:"bitcoin-cash",additionalSignParams:{segwit:!1,additionals:["abc"],sigHashType:65}}),V0=d({chain:"dogecoin",additionalSignParams:{additionals:[],segwit:!1,useTrustedInputForSegwit:!1}}),K0=d({chain:"dash",additionalSignParams:{additionals:[],segwit:!1,useTrustedInputForSegwit:!1}});var x=require("@swapkit/helpers"),T0=require("ripple-binary-codec");var Om=2147483648;function Tm(m){let L={};for(let y in m)if(m[y]!==null&&m[y]!==void 0)L[y]=m[y];return L}async function Xm(m){let{default:L}=await import("@ledgerhq/hw-app-xrp");return new L(m)}function Bm({instance:m,derivationPath:L}){return m.getAddress(L)}var E0=async(m)=>{let L=x.derivationPathToString(m||x.NetworkDerivationPath[x.Chain.Ripple]),y=await Y(),O=await Xm(y),{address:_,publicKey:X}=await Bm({instance:O,derivationPath:L});async function G(B){let{hashes:F}=await import("@swapkit/toolboxes/ripple"),J={...Tm(B),Flags:B.Flags||Om,SigningPubKey:X.toUpperCase()},Z=T0.encode(J),Q=await O.signTransaction(L,Z),N=T0.encode({...J,TxnSignature:Q}),z=F.hashSignedTx(N);return{tx_blob:N,hash:z}}return{address:_,sign:G}};var A=async({chain:m,derivationPath:L})=>{let{match:y}=await import("ts-pattern");return y(m).returnType().with($.Chain.THORChain,()=>Promise.resolve(new O0(L))).with($.Chain.Cosmos,()=>Promise.resolve(new y0(L))).with($.Chain.Bitcoin,()=>Promise.resolve(P0(L))).with($.Chain.BitcoinCash,()=>Promise.resolve(S0(L))).with($.Chain.Dash,()=>Promise.resolve(K0(L))).with($.Chain.Dogecoin,()=>Promise.resolve(V0(L))).with($.Chain.Litecoin,()=>Promise.resolve(I0(L))).with($.Chain.Ripple,()=>Promise.resolve(E0(L))).with($.Chain.Tron,()=>Promise.resolve(l0(L))).with($.Chain.Near,async()=>{let O=await Y();return f0(O,L)}).with($.Chain.Arbitrum,$.Chain.Avalanche,$.Chain.BinanceSmartChain,$.Chain.Ethereum,$.Chain.Optimism,$.Chain.Polygon,$.Chain.Base,async()=>{let{getProvider:O}=await import("@swapkit/toolboxes/evm"),_={provider:await O(m),derivationPath:L};return y(m).with($.Chain.BinanceSmartChain,()=>C0(_)).with($.Chain.Avalanche,()=>Z0(_)).with($.Chain.Arbitrum,()=>N0(_)).with($.Chain.Optimism,()=>H0(_)).with($.Chain.Polygon,()=>U0(_)).with($.Chain.Base,()=>D0(_)).otherwise(()=>Y0(_))}).otherwise(()=>{throw new $.SwapKitError("wallet_chain_not_supported",{wallet:$.WalletOption.LEDGER,chain:m})})};var b0=T.createWallet({name:"connectLedger",supportedChains:[T.Chain.Arbitrum,T.Chain.Avalanche,T.Chain.Base,T.Chain.BinanceSmartChain,T.Chain.Bitcoin,T.Chain.BitcoinCash,T.Chain.Cosmos,T.Chain.Dash,T.Chain.Dogecoin,T.Chain.Ethereum,T.Chain.Litecoin,T.Chain.Near,T.Chain.Optimism,T.Chain.Polygon,T.Chain.Ripple,T.Chain.THORChain,T.Chain.Tron],walletType:T.WalletOption.LEDGER,connect:({addChain:m,supportedChains:L,walletType:y})=>async function O(_,X){let[G]=T.filterSupportedChains({chains:_,supportedChains:L,walletType:y});if(!G)return!1;let B=await $m({chain:G,derivationPath:X});return m({...B,chain:G,walletType:T.WalletOption.LEDGER}),!0}}),Rm=k0(b0);function Wm(m,L="t"){if(!m?.includes("=:"))return m;let y=m.includes(`:${L}:`)?m.split(`:${L}:`)[0]:m;return y?.substring(0,y.lastIndexOf(":"))}function n(m){if(Array.isArray(m))return m.forEach((O,_)=>{m[_]=n(O)}),m;if(typeof m!=="object")return m;let L={},y=Object.keys(m).sort();for(let O of y)L[O]=n(m[O]);return L}function Jm(m){return JSON.stringify(n(m))}async function $m({chain:m,derivationPath:L}){switch(m){case T.Chain.BitcoinCash:case T.Chain.Bitcoin:case T.Chain.Dash:case T.Chain.Dogecoin:case T.Chain.Litecoin:{let{getUtxoToolbox:y}=await import("@swapkit/toolboxes/utxo"),O=await y(m),_=await A({chain:m,derivationPath:L}),X=await I({chain:m,ledgerClient:_});return{...O,address:X,transfer:async(B)=>{let F=B.feeRate||(await O.getFeeRates())[T.FeeOption.Average],R=[T.Chain.Bitcoin].includes(m)?B.memo:Wm(B.memo),{psbt:J,inputs:Z}=await O.createTransaction({...B,feeRate:F,memo:R,sender:X,fetchTxHex:!0}),Q=await _.signTransaction(J,Z);return await O.broadcastTx(Q)}}}case T.Chain.Ethereum:case T.Chain.Avalanche:case T.Chain.Arbitrum:case T.Chain.Optimism:case T.Chain.Polygon:case T.Chain.BinanceSmartChain:case T.Chain.Base:{let{getEvmToolbox:y}=await import("@swapkit/toolboxes/evm"),O=await A({chain:m,derivationPath:L}),_=await I({chain:m,ledgerClient:O});return{...await y(m,{signer:O}),address:_}}case T.Chain.Cosmos:{let{createSigningStargateClient:y,getMsgSendDenom:O,getCosmosToolbox:_}=await import("@swapkit/toolboxes/cosmos"),X=await _(T.Chain.Cosmos),G=await A({chain:m,derivationPath:L}),B=await I({chain:m,ledgerClient:G});return{...X,address:B,transfer:async({assetValue:R,recipient:J,memo:Z})=>{if(!R)throw new T.SwapKitError("wallet_ledger_invalid_asset");let Q={amount:[{amount:R.getBaseValue("string"),denom:O(`u${R.symbol}`).toLowerCase()}],fromAddress:B,toAddress:J},N=await y(T.SKConfig.get("rpcUrls")[m],G,"0.007uatom"),{transactionHash:z}=await N.signAndBroadcast(B,[{typeUrl:"/cosmos.bank.v1beta1.MsgSend",value:Q}],2,Z);return z}}}case T.Chain.THORChain:{let{SignMode:y}=await import("cosmjs-types/cosmos/tx/signing/v1beta1/signing.js"),{TxRaw:O}=await import("cosmjs-types/cosmos/tx/v1beta1/tx.js"),{encodePubkey:_,makeAuthInfoBytes:X}=(await import("@cosmjs/proto-signing")).default,{createStargateClient:G,buildEncodedTxBody:B,getCosmosToolbox:F,buildAminoMsg:R,getDefaultChainFee:J,fromBase64:Z,parseAminoMessageForDirectSigning:Q}=await import("@swapkit/toolboxes/cosmos"),N=await F(m),z=await A({chain:m,derivationPath:L}),U=await I({chain:m,ledgerClient:z}),E=J(m),{pubkey:i,signTransaction:x0,sign:g0}=z,X0=async({memo:P="",assetValue:B0,...c0})=>{let G0=await N.getAccount(U);if(!G0)throw new T.SwapKitError("wallet_ledger_invalid_account");if(!B0)throw new T.SwapKitError("wallet_ledger_invalid_asset");if(!i)throw new T.SwapKitError("wallet_ledger_pubkey_not_found");let{accountNumber:v0,sequence:u0}=G0,t=(u0||0).toString(),F0=n([R({sender:U,assetValue:B0,memo:P,...c0})]),h0=Jm({account_number:v0?.toString(),chain_id:T.ChainId.THORChain,fee:E,memo:P,msgs:F0,sequence:t}),p=await x0(h0,t);if(!p)throw new T.SwapKitError("wallet_ledger_signing_error");let d0=_({type:"tendermint/PubKeySecp256k1",value:i}),i0=F0.map(Q),o0=await B({msgs:i0,chain:m,memo:P}),n0=X([{pubkey:d0,sequence:Number(t)}],E.amount,Number.parseInt(E.gas),void 0,void 0,y.SIGN_MODE_LEGACY_AMINO_JSON),t0=p?.[0]?.signature?Z(p[0].signature):Uint8Array.from([]),p0=O.fromPartial({bodyBytes:o0,authInfoBytes:n0,signatures:[t0]}),a0=O.encode(p0).finish(),{isStagenet:s0}=T.SKConfig.get("envs"),e0=await G(T.SKConfig.get("rpcUrls")[s0?T.StagenetChain.THORChain:T.Chain.THORChain]),{transactionHash:r0}=await e0.broadcastTx(a0);return r0};return{...N,address:U,deposit:(P)=>X0(P),transfer:(P)=>X0(P),signMessage:g0}}case T.Chain.Near:{let{getNearToolbox:y}=await import("@swapkit/toolboxes/near"),O=await A({chain:m,derivationPath:L}),_=await O.getAddress();return{...await y({signer:O}),address:_}}case T.Chain.Ripple:{let{getRippleToolbox:y}=await import("@swapkit/toolboxes/ripple"),O=await A({chain:m,derivationPath:L}),_=O.address;return{...await y({signer:O}),address:_}}case T.Chain.Tron:{let{createTronToolbox:y}=await import("@swapkit/toolboxes/tron"),O=await A({chain:m,derivationPath:L}),_=await I({chain:m,ledgerClient:O});return{...await y({signer:O}),address:_}}default:throw new T.SwapKitError("wallet_ledger_chain_not_supported",{chain:m})}}
|
|
3
3
|
|
|
4
|
-
//# debugId=
|
|
4
|
+
//# debugId=8137D34D51CE666864756E2164756E21
|
|
5
|
+
//# sourceMappingURL=index.cjs.map
|