@rango-dev/provider-ledger 0.21.1-next.2 → 0.21.1-next.4
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-HLLU77MH.js → Eth-Y5JFGVQA.js} +2 -2
- package/dist/{chunk-OOX2UCLJ.js → Solana-UB4SGWQ3.js} +2 -2
- package/dist/{TransportWebHID-HV53OYSS.js → TransportWebHID-JLT4ETY3.js} +2 -2
- package/dist/mod.js +1 -1
- package/dist/mod.js.map +4 -4
- package/dist/provider-ledger.build.json +1 -1
- package/package.json +3 -2
- package/src/signer.ts +3 -7
- package/src/signers/ethereum.ts +19 -9
- package/src/signers/solana.ts +13 -4
- package/src/utils.ts +15 -11
- package/dist/Eth-5PCPPYSI.js +0 -2
- package/dist/Eth-5PCPPYSI.js.map +0 -7
- package/dist/Solana-NJS3LWGA.js +0 -2
- package/dist/Solana-NJS3LWGA.js.map +0 -7
- package/dist/chunk-I25CJMQS.js +0 -2
- package/dist/chunk-I25CJMQS.js.map +0 -7
- package/dist/ethereum-J6U6B3NU.js +0 -2
- package/dist/ethereum-J6U6B3NU.js.map +0 -7
- package/dist/solana-Q7LP23TP.js +0 -2
- package/dist/solana-Q7LP23TP.js.map +0 -7
- /package/dist/{chunk-HLLU77MH.js.map → Eth-Y5JFGVQA.js.map} +0 -0
- /package/dist/{chunk-OOX2UCLJ.js.map → Solana-UB4SGWQ3.js.map} +0 -0
- /package/dist/{TransportWebHID-HV53OYSS.js.map → TransportWebHID-JLT4ETY3.js.map} +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rango-dev/provider-ledger",
|
|
3
|
-
"version": "0.21.1-next.
|
|
3
|
+
"version": "0.21.1-next.4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"source": "./src/mod.ts",
|
|
@@ -28,7 +28,8 @@
|
|
|
28
28
|
"@ledgerhq/types-cryptoassets": "^7.11.0",
|
|
29
29
|
"@ledgerhq/types-devices": "^6.24.0",
|
|
30
30
|
"@rango-dev/signer-solana": "^0.44.0",
|
|
31
|
-
"@rango-dev/wallets-
|
|
31
|
+
"@rango-dev/wallets-core": "^0.49.1-next.3",
|
|
32
|
+
"@rango-dev/wallets-shared": "^0.50.1-next.3",
|
|
32
33
|
"@solana/web3.js": "^1.91.4",
|
|
33
34
|
"@types/w3c-web-hid": "^1.0.2",
|
|
34
35
|
"bs58": "^5.0.0",
|
package/src/signer.ts
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
import type { SignerFactory } from 'rango-types';
|
|
2
2
|
|
|
3
|
-
import { dynamicImportWithRefinedError } from '@rango-dev/wallets-shared';
|
|
4
3
|
import { DefaultSignerFactory, TransactionType as TxType } from 'rango-types';
|
|
5
4
|
|
|
5
|
+
import { EthereumSigner } from './signers/ethereum';
|
|
6
|
+
import { SolanaSigner } from './signers/solana';
|
|
7
|
+
|
|
6
8
|
export default async function getSigners(): Promise<SignerFactory> {
|
|
7
9
|
const signers = new DefaultSignerFactory();
|
|
8
|
-
const { EthereumSigner } = await dynamicImportWithRefinedError(
|
|
9
|
-
async () => await import('./signers/ethereum.js')
|
|
10
|
-
);
|
|
11
|
-
const { SolanaSigner } = await dynamicImportWithRefinedError(
|
|
12
|
-
async () => await import('./signers/solana.js')
|
|
13
|
-
);
|
|
14
10
|
signers.registerSigner(TxType.EVM, new EthereumSigner());
|
|
15
11
|
signers.registerSigner(TxType.SOLANA, new SolanaSigner());
|
|
16
12
|
return signers;
|
package/src/signers/ethereum.ts
CHANGED
|
@@ -2,8 +2,10 @@ import type { TransactionLike } from 'ethers';
|
|
|
2
2
|
import type { GenericSigner } from 'rango-types';
|
|
3
3
|
import type { EvmTransaction } from 'rango-types/mainApi';
|
|
4
4
|
|
|
5
|
-
import
|
|
6
|
-
|
|
5
|
+
import {
|
|
6
|
+
DEFAULT_ETHEREUM_RPC_URL,
|
|
7
|
+
dynamicImportWithRefinedError,
|
|
8
|
+
} from '@rango-dev/wallets-shared';
|
|
7
9
|
import { JsonRpcProvider, Transaction } from 'ethers';
|
|
8
10
|
import { SignerError, SignerErrorCode } from 'rango-types';
|
|
9
11
|
|
|
@@ -18,8 +20,13 @@ export class EthereumSigner implements GenericSigner<EvmTransaction> {
|
|
|
18
20
|
async signMessage(msg: string): Promise<string> {
|
|
19
21
|
try {
|
|
20
22
|
const transport = await transportConnect();
|
|
23
|
+
const LedgerAppEth = (
|
|
24
|
+
await dynamicImportWithRefinedError(
|
|
25
|
+
async () => await import('@ledgerhq/hw-app-eth')
|
|
26
|
+
)
|
|
27
|
+
).default;
|
|
28
|
+
const eth = new LedgerAppEth(transport);
|
|
21
29
|
|
|
22
|
-
const eth = new Eth(transport);
|
|
23
30
|
const result = await eth.signPersonalMessage(
|
|
24
31
|
getDerivationPath(),
|
|
25
32
|
Buffer.from(msg).toString('hex')
|
|
@@ -60,16 +67,19 @@ export class EthereumSigner implements GenericSigner<EvmTransaction> {
|
|
|
60
67
|
const unsignedTx =
|
|
61
68
|
Transaction.from(transaction).unsignedSerialized.substring(2); // Create unsigned transaction
|
|
62
69
|
|
|
63
|
-
const
|
|
70
|
+
const transport = await transportConnect();
|
|
71
|
+
const LedgerHqAppEth = await dynamicImportWithRefinedError(
|
|
72
|
+
async () => await import('@ledgerhq/hw-app-eth')
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
const LedgerAppEth = LedgerHqAppEth.default;
|
|
76
|
+
const eth = new LedgerAppEth(transport);
|
|
77
|
+
|
|
78
|
+
const resolution = await LedgerHqAppEth.ledgerService.resolveTransaction(
|
|
64
79
|
unsignedTx,
|
|
65
80
|
{},
|
|
66
81
|
{}
|
|
67
82
|
); // metadata necessary to allow the device to clear sign information
|
|
68
|
-
|
|
69
|
-
const transport = await transportConnect();
|
|
70
|
-
|
|
71
|
-
const eth = new Eth(transport);
|
|
72
|
-
|
|
73
83
|
const signature = await eth.signTransaction(
|
|
74
84
|
getDerivationPath(),
|
|
75
85
|
unsignedTx,
|
package/src/signers/solana.ts
CHANGED
|
@@ -2,8 +2,8 @@ import type { SolanaWeb3Signer } from '@rango-dev/signer-solana';
|
|
|
2
2
|
import type { Transaction, VersionedTransaction } from '@solana/web3.js';
|
|
3
3
|
import type { GenericSigner, SolanaTransaction } from 'rango-types';
|
|
4
4
|
|
|
5
|
-
import Solana from '@ledgerhq/hw-app-solana';
|
|
6
5
|
import { generalSolanaTransactionExecutor } from '@rango-dev/signer-solana';
|
|
6
|
+
import { dynamicImportWithRefinedError } from '@rango-dev/wallets-shared';
|
|
7
7
|
import { PublicKey } from '@solana/web3.js';
|
|
8
8
|
import { SignerError, SignerErrorCode } from 'rango-types';
|
|
9
9
|
|
|
@@ -24,8 +24,12 @@ export class SolanaSigner implements GenericSigner<SolanaTransaction> {
|
|
|
24
24
|
async signMessage(msg: string): Promise<string> {
|
|
25
25
|
try {
|
|
26
26
|
const transport = await transportConnect();
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
const LedgerAppSolana = (
|
|
28
|
+
await dynamicImportWithRefinedError(
|
|
29
|
+
async () => await import('@ledgerhq/hw-app-solana')
|
|
30
|
+
)
|
|
31
|
+
).default;
|
|
32
|
+
const solana = new LedgerAppSolana(transport);
|
|
29
33
|
|
|
30
34
|
const result = await solana.signOffchainMessage(
|
|
31
35
|
getDerivationPath(),
|
|
@@ -43,7 +47,12 @@ export class SolanaSigner implements GenericSigner<SolanaTransaction> {
|
|
|
43
47
|
solanaWeb3Transaction: Transaction | VersionedTransaction
|
|
44
48
|
) => {
|
|
45
49
|
const transport = await transportConnect();
|
|
46
|
-
const
|
|
50
|
+
const LedgerAppSolana = (
|
|
51
|
+
await dynamicImportWithRefinedError(
|
|
52
|
+
async () => await import('@ledgerhq/hw-app-solana')
|
|
53
|
+
)
|
|
54
|
+
).default;
|
|
55
|
+
const solana = new LedgerAppSolana(transport);
|
|
47
56
|
|
|
48
57
|
let signResult;
|
|
49
58
|
if (isVersionedTransaction(solanaWeb3Transaction)) {
|
package/src/utils.ts
CHANGED
|
@@ -65,13 +65,13 @@ export function standardizeAndThrowLedgerError(_: unknown, error: unknown) {
|
|
|
65
65
|
export async function getEthereumAccounts(): Promise<ProviderConnectResult> {
|
|
66
66
|
try {
|
|
67
67
|
const transport = await transportConnect();
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
const eth = new (
|
|
68
|
+
const LedgerAppEth = (
|
|
71
69
|
await dynamicImportWithRefinedError(
|
|
72
70
|
async () => await import('@ledgerhq/hw-app-eth')
|
|
73
71
|
)
|
|
74
|
-
).default
|
|
72
|
+
).default;
|
|
73
|
+
const eth = new LedgerAppEth(transport);
|
|
74
|
+
const derivationPath = getDerivationPath();
|
|
75
75
|
|
|
76
76
|
const accounts: string[] = [];
|
|
77
77
|
|
|
@@ -93,13 +93,13 @@ export async function getEthereumAccounts(): Promise<ProviderConnectResult> {
|
|
|
93
93
|
export async function getSolanaAccounts(): Promise<ProviderConnectResult> {
|
|
94
94
|
try {
|
|
95
95
|
const transport = await transportConnect();
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
const solana = new (
|
|
96
|
+
const LedgerAppSolana = (
|
|
99
97
|
await dynamicImportWithRefinedError(
|
|
100
98
|
async () => await import('@ledgerhq/hw-app-solana')
|
|
101
99
|
)
|
|
102
|
-
).default
|
|
100
|
+
).default;
|
|
101
|
+
const solana = new LedgerAppSolana(transport);
|
|
102
|
+
const derivationPath = getDerivationPath();
|
|
103
103
|
|
|
104
104
|
const accounts: string[] = [];
|
|
105
105
|
|
|
@@ -121,9 +121,13 @@ export async function getSolanaAccounts(): Promise<ProviderConnectResult> {
|
|
|
121
121
|
let transportConnection: Transport | null = null;
|
|
122
122
|
|
|
123
123
|
export async function transportConnect() {
|
|
124
|
-
|
|
125
|
-
await
|
|
126
|
-
|
|
124
|
+
const TransportWebHID = (
|
|
125
|
+
await dynamicImportWithRefinedError(
|
|
126
|
+
async () => await import('@ledgerhq/hw-transport-webhid')
|
|
127
|
+
)
|
|
128
|
+
).default;
|
|
129
|
+
|
|
130
|
+
transportConnection = await TransportWebHID.create();
|
|
127
131
|
|
|
128
132
|
return transportConnection;
|
|
129
133
|
}
|
package/dist/Eth-5PCPPYSI.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a,b,c,d,e,f,g,h,i,j,k,l,m,n}from"./chunk-HLLU77MH.js";import"./chunk-5QSDSOWH.js";import"./chunk-CVKDPNYM.js";export{c as ERC1155_CLEAR_SIGNED_SELECTORS,a as ERC20_CLEAR_SIGNED_SELECTORS,b as ERC721_CLEAR_SIGNED_SELECTORS,h as decodeTxInfo,n as default,f as hexBuffer,i as intAsHexBytes,m as ledgerService,g as maybeHexBuffer,l as mergeResolutions,k as nftSelectors,d as padHexString,e as splitPath,j as tokenSelectors};
|
|
2
|
-
//# sourceMappingURL=Eth-5PCPPYSI.js.map
|
package/dist/Eth-5PCPPYSI.js.map
DELETED
package/dist/Solana-NJS3LWGA.js
DELETED
package/dist/chunk-I25CJMQS.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as i,d as le,m as X}from"./chunk-CVKDPNYM.js";var St="";function cn(t){St=t}i(cn,"setDerivationPath");function q(){return St}i(q,"getDerivationPath");var fe=Object.defineProperty,S=i((t,e)=>fe(t,"name",{value:e,configurable:!0}),"r"),y=(t=>(t.BTC="BTC",t.BSC="BSC",t.LTC="LTC",t.THORCHAIN="THOR",t.BCH="BCH",t.BINANCE="BNB",t.ETHEREUM="ETH",t.POLYGON="POLYGON",t.TERRA="TERRA",t.POLKADOT="",t.TRON="TRON",t.DOGE="DOGE",t.HARMONY="HARMONY",t.AVAX_CCHAIN="AVAX_CCHAIN",t.FANTOM="FANTOM",t.MOONBEAM="MOONBEAM",t.ARBITRUM="ARBITRUM",t.BOBA="BOBA",t.OPTIMISM="OPTIMISM",t.FUSE="FUSE",t.CRONOS="CRONOS",t.SOLANA="SOLANA",t.MOONRIVER="MOONRIVER",t.GNOSIS="GNOSIS",t.COSMOS="COSMOS",t.OSMOSIS="OSMOSIS",t.AXELAR="AXELAR",t.MARS="MARS",t.STRIDE="STRIDE",t.MAYA="MAYA",t.AKASH="AKASH",t.IRIS="IRIS",t.PERSISTENCE="PERSISTENCE",t.SENTINEL="SENTINEL",t.REGEN="REGEN",t.CRYPTO_ORG="CRYPTO_ORG",t.SIF="SIF",t.CHIHUAHUA="CHIHUAHUA",t.JUNO="JUNO",t.KUJIRA="KUJIRA",t.STARNAME="STARNAME",t.COMDEX="COMDEX",t.STARGAZE="STARGAZE",t.DESMOS="DESMOS",t.BITCANNA="BITCANNA",t.SECRET="SECRET",t.INJECTIVE="INJECTIVE",t.LUMNETWORK="LUMNETWORK",t.BANDCHAIN="BANDCHAIN",t.EMONEY="EMONEY",t.BITSONG="BITSONG",t.KI="KI",t.MEDIBLOC="MEDIBLOC",t.KONSTELLATION="KONSTELLATION",t.UMEE="UMEE",t.STARKNET="STARKNET",t.TON="TON",t.BASE="BASE",t.SUI="SUI",t.Unknown="Unkown",t))(y||{}),pe=(t=>(t.CONNECTED="connected",t.CONNECTING="connecting",t.REACHABLE="reachable",t.INSTALLED="installed",t.ACCOUNTS="accounts",t.NETWORK="network",t.NAMESPACE_DISCONNECTED="namespace_disconnected",t.PROVIDER_DISCONNECTED="provider_disconnected",t))(pe||{}),dn=class{static{i(this,"E")}static{S(this,"Persistor")}getItem(t){let e=localStorage.getItem(t);return e?JSON.parse(e):null}setItem(t,e){localStorage.setItem(t,JSON.stringify(e))}removeItem(t){localStorage.removeItem(t)}};function _t(t,e){return`${e||""}:${t}`}i(_t,"w");S(_t,"formatAddressWithNetwork");function F(t,e){return t?t.map(n=>_t(n,e)):[]}i(F,"y");S(F,"accountAddressesWithNetwork");function me(t){let[e,n]=t.split(":");return{network:e,address:n}}i(me,"b");S(me,"readAccountAddress");function U(t){let{checkInstallation:e=!0}=t.config;return e}i(U,"S");S(U,"needsCheckInstallation");var z=S((t,e)=>(t=typeof t=="string"&&t.startsWith("0x")?parseInt(t):t,Object.values(y).includes(String(t))?t:t==="Binance-Chain-Tigris"?"BNB":e.filter(n=>!!n.chainId).find(n=>(n.chainId?.startsWith("0x")?parseInt(n.chainId):n.chainId)==t)?.name||null),"getBlockChainNameFromId");async function Et(t){if(await t.canEagerConnect())return await t.connectHandler();throw new Error(`can't restore connection for ${t.providerName}.`)}i(Et,"T");S(Et,"eagerConnectHandler");function ge(t){return t.namespace==="EVM"}i(ge,"B");S(ge,"isEvmNamespace");var ln=class{static{i(this,"A")}static{S(this,"Wallet")}provider;actions;state;options;info;cleanupSubscribe;constructor(t,e){this.actions=e,this.options=t,this.provider=null,this.info={supportedBlockchains:[],isContractWallet:!1,isHub:!1},this.state={connected:!1,connecting:!1,reachable:!1,installed:!1,accounts:null,network:null},U(t)||this.setInstalledAs(!0)}async suggestAndConnect(t){return this.actions.suggest&&await this.actions.suggest({instance:this.provider,meta:this.info.supportedBlockchains,network:t}),await this.connect(t)}async connect(t,e){if(this.state.connecting)throw new Error("Connecting...");let n=await this.getConnectionFromState(),r=this.state.network,s=t||r||this.options.config.defaultNetwork;if(n){let d=r!==s&&!!s;if(r===s)return n;let p=!0;if(this.actions.canSwitchNetworkTo&&(p=this.actions.canSwitchNetworkTo({provider:this.provider,meta:this.info.supportedBlockchains,network:s||""})),d&&p&&this.actions.switchNetwork)return await this.actions.switchNetwork({instance:this.provider,meta:this.info.supportedBlockchains,network:s,newInstance:this.tryGetInstance.bind(this),getState:this.getState.bind(this),updateChainId:this.updateChainId.bind(this)}),s!==this.state.network&&!this.options.config.isAsyncSwitchNetwork&&this.updateState({network:t}),{accounts:n.accounts,network:s,provider:this.provider}}let o=await this.tryGetInstance({network:t});this.updateState({connecting:!0}),this.setInstalledAs(!0);try{var a=await this.actions.connect({instance:o,network:s||void 0,meta:this.info.supportedBlockchains||[],namespaces:e})}catch(d){throw this.resetState(),d}this.updateState({connected:!0,reachable:!0,connecting:!1});let c=[],h=null,l;if(Array.isArray(a)){let d=null;c=a.flatMap(p=>{let w=p.chainId||"Unkown",O=z(w,this.info.supportedBlockchains)||"Unkown";return l=p.derivationPath?p.derivationPath:l,!d&&O!=="Unkown"&&this.info.supportedBlockchains.find(Z=>Z.name===O)?.info?.infoType==="EvmMetaInfo"&&(d=O),F(p.accounts,O)}).filter(Boolean),h=d||s||this.options.config.defaultNetwork}else{let d=a.chainId||"Unkown",p=z(d,this.info.supportedBlockchains)||"Unkown",w=a.derivationPath;c=F(a.accounts,p),h=p,l=w}return c.length>0&&this.updateState({accounts:c,network:h,derivationPath:l}),{accounts:this.state.accounts,network:this.state.network,provider:this.provider}}async disconnect(){this.resetState(),this.actions.disconnect&&this.actions.disconnect({instance:this.provider,destroyInstance:()=>{this.setProvider(null)}})}async eagerConnect(){let t=await this.tryGetInstance({network:void 0}),{canEagerConnect:e}=this.actions,n=this.options.config.type;return await Et({canEagerConnect:async()=>{if(!e)throw new Error(`${n} provider hasn't implemented canEagerConnect.`);return await e({instance:t,meta:this.info.supportedBlockchains})},connectHandler:async()=>await this.connect(),providerName:n})}async getSigners(t){return await this.actions.getSigners(t)}getWalletInfo(t){return this.actions.getWalletInfo(t)}canSwitchNetworkTo(t,e){let n=this.actions.canSwitchNetworkTo;return n?n({network:t,meta:this.info.supportedBlockchains,provider:e}):!1}onInit(){if(!this.actions.getInstance)throw new Error(`Provider hasn't defined how to get wallet's instance. provider: ${this.options.config.type} on: onInit`);this.options.config.isAsyncInstance?U(this.options)&&this.actions.getInstance().then(t=>{t&&this.setInstalledAs(!0)}):this.actions.getInstance()&&!this.state.installed&&this.setInstalledAs(!0)}setProvider(t){if(this.provider=t,t&&this.actions.subscribe){let e=this.actions.subscribe({instance:t,state:this.state,meta:this.info.supportedBlockchains,connect:this.connect.bind(this),disconnect:this.disconnect.bind(this),updateAccounts:(n,r)=>{let s=this.state.network;r&&(s=z(r,this.info.supportedBlockchains)||"Unkown");let o=F(n,s);o.length>0&&this.updateState({accounts:o})},updateChainId:this.updateChainId.bind(this)});this.cleanupSubscribe=e}else!t&&this.cleanupSubscribe&&this.cleanupSubscribe()}setInfo(t){typeof t.supportedBlockchains<"u"&&(this.info.supportedBlockchains=t.supportedBlockchains),typeof t.isContractWallet<"u"&&(this.info.isContractWallet=t.isContractWallet)}setHandler(t){this.options.handler=t}getState(){return this.state}updateState(t){let e=[];typeof t.connected<"u"&&(this.state.connected=t.connected,e.push(["connected",t.connected])),typeof t.connecting<"u"&&(this.state.connecting=t.connecting,e.push(["connecting",t.connecting])),typeof t.reachable<"u"&&(this.state.reachable=t.reachable,e.push(["reachable",t.reachable])),typeof t.installed<"u"&&(this.state.installed=t.installed,e.push(["installed",t.installed])),typeof t.accounts<"u"&&(this.state.accounts=t.accounts,this.state.derivationPath=t.derivationPath,e.push(["accounts",t.accounts])),typeof t.network<"u"&&(this.state.network=t.network,e.push(["network",t.network]));let n=this.getState();e.forEach(([r,s])=>{let o={supportedBlockchains:this.info.supportedBlockchains,isContractWallet:this.info.isContractWallet,isHub:!1};this.options.handler(this.options.config.type,r,s,n,o)})}resetState(){this.updateState({connected:!1,connecting:!1,reachable:!1,accounts:null,network:null})}async getConnectionFromState(){return this.state.connected&&this.provider?{accounts:this.state.accounts,network:this.state.network,provider:this.provider}:null}updateChainId(t){let e=t?z(t,this.info.supportedBlockchains):"Unkown";this.updateState({network:e})}setInstalledAs(t){!U(this.options)&&t===!1||this.updateState({installed:t})}async tryGetInstance({network:t,force:e}){let n=null;if(this.setProvider(null),this.options.config.isAsyncInstance){let r={currentProvider:this.provider,meta:this.info.supportedBlockchains,force:e||!1,updateChainId:this.updateChainId.bind(this),getState:this.getState.bind(this)};t&&(r.network=t),n=await this.actions.getInstance(r)}else n=this.actions.getInstance();if(!n){this.setInstalledAs(!1),this.resetState();let r=`It seems your selected wallet (${this.options.config.type}) isn't installed.`;throw new Error(r)}return this.setProvider(n),n}};var Se={};le(Se,{AccountId:()=>_,AssetId:()=>Nt,AssetType:()=>At,ChainId:()=>E});function Q(){return Q=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},Q.apply(this,arguments)}i(Q,"_extends");var tt={name:"chainId",regex:"[-:a-zA-Z0-9]{5,41}",parameters:{delimiter:":",values:{0:{name:"namespace",regex:"[-a-z0-9]{3,8}"},1:{name:"reference",regex:"[-a-zA-Z0-9]{1,32}"}}}},ve={name:"accountId",regex:"[-:a-zA-Z0-9]{7,106}",parameters:{delimiter:":",values:{0:{name:"namespace",regex:"[-a-z0-9]{3,8}"},1:{name:"reference",regex:"[-a-zA-Z0-9]{1,32}"},2:{name:"address",regex:"[a-zA-Z0-9]{1,64}"}}}},et={name:"assetName",regex:"[-:a-zA-Z0-9]{5,73}",parameters:{delimiter:":",values:{0:{name:"namespace",regex:"[-a-z0-9]{3,8}"},1:{name:"reference",regex:"[-a-zA-Z0-9]{1,64}"}}}},ye={name:"assetType",regex:"[-:a-zA-Z0-9]{11,115}",parameters:{delimiter:"/",values:{0:tt,1:et}}},we={name:"assetId",regex:"[-:a-zA-Z0-9]{13,148}",parameters:{delimiter:"/",values:{0:tt,1:et,2:{name:"tokenId",regex:"[-a-zA-Z0-9]{1,32}"}}}},T={2:tt,10:ve,19:{assetName:et,assetType:ye,assetId:we}};function It(t,e){return t.split(e.parameters.delimiter)}i(It,"splitParams");function R(t,e){var n=It(t,e),r={};return n.forEach(function(s,o){r[e.parameters.values[o].name]=s}),r}i(R,"getParams");function C(t,e){return Object.values(e.parameters.values).map(function(n){var r=t[n.name];return typeof r=="string"?r:C(r,n)}).join(e.parameters.delimiter)}i(C,"joinParams");function x(t,e){if(!new RegExp(e.regex).test(t))return!1;var n=It(t,e);if(n.length!==Object.keys(e.parameters.values).length)return!1;var r=n.map(function(s,o){return new RegExp(e.parameters.values[o].regex).test(s)}).filter(function(s){return!!s});return r.length===n.length}i(x,"isValidId");var E=function(){function t(n){typeof n=="string"&&(n=t.parse(n)),this.namespace=n.namespace,this.reference=n.reference}i(t,"ChainId"),t.parse=i(function(r){if(!x(r,this.spec))throw new Error("Invalid "+this.spec.name+" provided: "+r);return new t(R(r,this.spec)).toJSON()},"parse"),t.format=i(function(r){return C(r,this.spec)},"format");var e=t.prototype;return e.toString=i(function(){return t.format(this.toJSON())},"toString"),e.toJSON=i(function(){return{namespace:this.namespace,reference:this.reference}},"toJSON"),t}();E.spec=T[2];var _=function(){function t(n){typeof n=="string"&&(n=t.parse(n)),this.chainId=new E(n.chainId),this.address=n.address}i(t,"AccountId"),t.parse=i(function(r){if(!x(r,this.spec))throw new Error("Invalid "+this.spec.name+" provided: "+r);var s=R(r,this.spec),o=s.namespace,a=s.reference,c=s.address,h=new E({namespace:o,reference:a});return new t({chainId:h,address:c}).toJSON()},"parse"),t.format=i(function(r){var s=new E(r.chainId),o=Q({},s.toJSON(),{address:r.address});return C(o,this.spec)},"format");var e=t.prototype;return e.toString=i(function(){return t.format(this.toJSON())},"toString"),e.toJSON=i(function(){return{chainId:this.chainId.toJSON(),address:this.address}},"toJSON"),t}();_.spec=T[10];var nt=function(){function t(n){typeof n=="string"&&(n=t.parse(n)),this.namespace=n.namespace,this.reference=n.reference}i(t,"AssetName"),t.parse=i(function(r){if(!x(r,this.spec))throw new Error("Invalid "+this.spec.name+" provided: "+r);return new t(R(r,this.spec)).toJSON()},"parse"),t.format=i(function(r){return C(r,this.spec)},"format");var e=t.prototype;return e.toString=i(function(){return t.format(this.toJSON())},"toString"),e.toJSON=i(function(){return{namespace:this.namespace,reference:this.reference}},"toJSON"),t}();nt.spec=T[19].assetName;var At=function(){function t(n){typeof n=="string"&&(n=t.parse(n)),this.chainId=new E(n.chainId),this.assetName=new nt(n.assetName)}i(t,"AssetType"),t.parse=i(function(r){if(!x(r,this.spec))throw new Error("Invalid "+this.spec.name+" provided: "+r);return new t(R(r,this.spec)).toJSON()},"parse"),t.format=i(function(r){return C(r,this.spec)},"format");var e=t.prototype;return e.toString=i(function(){return t.format(this.toJSON())},"toString"),e.toJSON=i(function(){return{chainId:this.chainId.toJSON(),assetName:this.assetName}},"toJSON"),t}();At.spec=T[19].assetType;var Nt=function(){function t(n){typeof n=="string"&&(n=t.parse(n)),this.chainId=new E(n.chainId),this.assetName=new nt(n.assetName),this.tokenId=n.tokenId}i(t,"AssetId"),t.parse=i(function(r){if(!x(r,this.spec))throw new Error("Invalid "+this.spec.name+" provided: "+r);return new t(R(r,this.spec)).toJSON()},"parse"),t.format=i(function(r){return C(r,this.spec)},"format");var e=t.prototype;return e.toString=i(function(){return t.format(this.toJSON())},"toString"),e.toJSON=i(function(){return{chainId:this.chainId.toJSON(),assetName:this.assetName.toJSON(),tokenId:this.tokenId}},"toJSON"),t}();Nt.spec=T[19].assetId;var bt=i(t=>{let e,n=new Set,r=i((d,p)=>{let w=typeof d=="function"?d(e):d;if(!Object.is(w,e)){let O=e;e=p??(typeof w!="object"||w===null)?w:Object.assign({},e,w),n.forEach(Z=>Z(e,O))}},"setState"),s=i(()=>e,"getState"),h={setState:r,getState:s,getInitialState:i(()=>l,"getInitialState"),subscribe:i(d=>(n.add(d),()=>n.delete(d)),"subscribe"),destroy:i(()=>{(import.meta.env?import.meta.env.MODE:void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()},"destroy")},l=e=t(r,s,h);return h},"createStoreImpl"),Ot=i(t=>t?bt(t):bt,"createStore");var Rt=Symbol.for("immer-nothing"),Ct=Symbol.for("immer-draftable"),m=Symbol.for("immer-state");function v(t,...e){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}i(v,"die");var P=Object.getPrototypeOf;function k(t){return!!t&&!!t[m]}i(k,"isDraft");function A(t){return t?xt(t)||Array.isArray(t)||!!t[Ct]||!!t.constructor?.[Ct]||Y(t)||V(t):!1}i(A,"isDraftable");var _e=Object.prototype.constructor.toString();function xt(t){if(!t||typeof t!="object")return!1;let e=P(t);if(e===null)return!0;let n=Object.hasOwnProperty.call(e,"constructor")&&e.constructor;return n===Object?!0:typeof n=="function"&&Function.toString.call(n)===_e}i(xt,"isPlainObject");function H(t,e){W(t)===0?Reflect.ownKeys(t).forEach(n=>{e(n,t[n],t)}):t.forEach((n,r)=>e(r,n,t))}i(H,"each");function W(t){let e=t[m];return e?e.type_:Array.isArray(t)?1:Y(t)?2:V(t)?3:0}i(W,"getArchtype");function it(t,e){return W(t)===2?t.has(e):Object.prototype.hasOwnProperty.call(t,e)}i(it,"has");function Dt(t,e,n){let r=W(t);r===2?t.set(e,n):r===3?t.add(n):t[e]=n}i(Dt,"set");function Ee(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}i(Ee,"is");function Y(t){return t instanceof Map}i(Y,"isMap");function V(t){return t instanceof Set}i(V,"isSet");function I(t){return t.copy_||t.base_}i(I,"latest");function ot(t,e){if(Y(t))return new Map(t);if(V(t))return new Set(t);if(Array.isArray(t))return Array.prototype.slice.call(t);let n=xt(t);if(e===!0||e==="class_only"&&!n){let r=Object.getOwnPropertyDescriptors(t);delete r[m];let s=Reflect.ownKeys(r);for(let o=0;o<s.length;o++){let a=s[o],c=r[a];c.writable===!1&&(c.writable=!0,c.configurable=!0),(c.get||c.set)&&(r[a]={configurable:!0,writable:!0,enumerable:c.enumerable,value:t[a]})}return Object.create(P(t),r)}else{let r=P(t);if(r!==null&&n)return{...t};let s=Object.create(r);return Object.assign(s,t)}}i(ot,"shallowCopy");function dt(t,e=!1){return G(t)||k(t)||!A(t)||(W(t)>1&&(t.set=t.add=t.clear=t.delete=Ie),Object.freeze(t),e&&Object.entries(t).forEach(([n,r])=>dt(r,!0))),t}i(dt,"freeze");function Ie(){v(2)}i(Ie,"dontMutateFrozenCollections");function G(t){return Object.isFrozen(t)}i(G,"isFrozen");var Ae={};function N(t){let e=Ae[t];return e||v(0,t),e}i(N,"getPlugin");var D;function Bt(){return D}i(Bt,"getCurrentScope");function Ne(t,e){return{drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}i(Ne,"createScope");function Pt(t,e){e&&(N("Patches"),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}i(Pt,"usePatchesInScope");function at(t){ct(t),t.drafts_.forEach(be),t.drafts_=null}i(at,"revokeScope");function ct(t){t===D&&(D=t.parent_)}i(ct,"leaveScope");function kt(t){return D=Ne(D,t)}i(kt,"enterScope");function be(t){let e=t[m];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}i(be,"revokeDraft");function Mt(t,e){e.unfinalizedDrafts_=e.drafts_.length;let n=e.drafts_[0];return t!==void 0&&t!==n?(n[m].modified_&&(at(e),v(4)),A(t)&&(t=$(e,t),e.parent_||J(e,t)),e.patches_&&N("Patches").generateReplacementPatches_(n[m].base_,t,e.patches_,e.inversePatches_)):t=$(e,n,[]),at(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==Rt?t:void 0}i(Mt,"processResult");function $(t,e,n){if(G(e))return e;let r=e[m];if(!r)return H(e,(s,o)=>Tt(t,r,e,s,o,n)),e;if(r.scope_!==t)return e;if(!r.modified_)return J(t,r.base_,!0),r.base_;if(!r.finalized_){r.finalized_=!0,r.scope_.unfinalizedDrafts_--;let s=r.copy_,o=s,a=!1;r.type_===3&&(o=new Set(s),s.clear(),a=!0),H(o,(c,h)=>Tt(t,r,s,c,h,n,a)),J(t,s,!1),n&&t.patches_&&N("Patches").generatePatches_(r,n,t.patches_,t.inversePatches_)}return r.copy_}i($,"finalize");function Tt(t,e,n,r,s,o,a){if(k(s)){let c=o&&e&&e.type_!==3&&!it(e.assigned_,r)?o.concat(r):void 0,h=$(t,s,c);if(Dt(n,r,h),k(h))t.canAutoFreeze_=!1;else return}else a&&n.add(s);if(A(s)&&!G(s)){if(!t.immer_.autoFreeze_&&t.unfinalizedDrafts_<1)return;$(t,s),(!e||!e.scope_.parent_)&&typeof r!="symbol"&&Object.prototype.propertyIsEnumerable.call(n,r)&&J(t,s)}}i(Tt,"finalizeProperty");function J(t,e,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&dt(e,n)}i(J,"maybeFreeze");function Oe(t,e){let n=Array.isArray(t),r={type_:n?1:0,scope_:e?e.scope_:Bt(),modified_:!1,finalized_:!1,assigned_:{},parent_:e,base_:t,draft_:null,copy_:null,revoke_:null,isManual_:!1},s=r,o=lt;n&&(s=[r],o=B);let{revoke:a,proxy:c}=Proxy.revocable(s,o);return r.draft_=c,r.revoke_=a,c}i(Oe,"createProxyProxy");var lt={get(t,e){if(e===m)return t;let n=I(t);if(!it(n,e))return Ce(t,n,e);let r=n[e];return t.finalized_||!A(r)?r:r===rt(t.base_,e)?(st(t),t.copy_[e]=ht(r,t)):r},has(t,e){return e in I(t)},ownKeys(t){return Reflect.ownKeys(I(t))},set(t,e,n){let r=Lt(I(t),e);if(r?.set)return r.set.call(t.draft_,n),!0;if(!t.modified_){let s=rt(I(t),e),o=s?.[m];if(o&&o.base_===n)return t.copy_[e]=n,t.assigned_[e]=!1,!0;if(Ee(n,s)&&(n!==void 0||it(t.base_,e)))return!0;st(t),ut(t)}return t.copy_[e]===n&&(n!==void 0||e in t.copy_)||Number.isNaN(n)&&Number.isNaN(t.copy_[e])||(t.copy_[e]=n,t.assigned_[e]=!0),!0},deleteProperty(t,e){return rt(t.base_,e)!==void 0||e in t.base_?(t.assigned_[e]=!1,st(t),ut(t)):delete t.assigned_[e],t.copy_&&delete t.copy_[e],!0},getOwnPropertyDescriptor(t,e){let n=I(t),r=Reflect.getOwnPropertyDescriptor(n,e);return r&&{writable:!0,configurable:t.type_!==1||e!=="length",enumerable:r.enumerable,value:n[e]}},defineProperty(){v(11)},getPrototypeOf(t){return P(t.base_)},setPrototypeOf(){v(12)}},B={};H(lt,(t,e)=>{B[t]=function(){return arguments[0]=arguments[0][0],e.apply(this,arguments)}});B.deleteProperty=function(t,e){return B.set.call(this,t,e,void 0)};B.set=function(t,e,n){return lt.set.call(this,t[0],e,n,t[0])};function rt(t,e){let n=t[m];return(n?I(n):t)[e]}i(rt,"peek");function Ce(t,e,n){let r=Lt(e,n);return r?"value"in r?r.value:r.get?.call(t.draft_):void 0}i(Ce,"readPropFromProto");function Lt(t,e){if(!(e in t))return;let n=P(t);for(;n;){let r=Object.getOwnPropertyDescriptor(n,e);if(r)return r;n=P(n)}}i(Lt,"getDescriptorFromProto");function ut(t){t.modified_||(t.modified_=!0,t.parent_&&ut(t.parent_))}i(ut,"markChanged");function st(t){t.copy_||(t.copy_=ot(t.base_,t.scope_.immer_.useStrictShallowCopy_))}i(st,"prepareCopy");var Pe=class{static{i(this,"Immer2")}constructor(t){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(e,n,r)=>{if(typeof e=="function"&&typeof n!="function"){let o=n;n=e;let a=this;return i(function(h=o,...l){return a.produce(h,d=>n.call(this,d,...l))},"curriedProduce")}typeof n!="function"&&v(6),r!==void 0&&typeof r!="function"&&v(7);let s;if(A(e)){let o=kt(this),a=ht(e,void 0),c=!0;try{s=n(a),c=!1}finally{c?at(o):ct(o)}return Pt(o,r),Mt(s,o)}else if(!e||typeof e!="object"){if(s=n(e),s===void 0&&(s=e),s===Rt&&(s=void 0),this.autoFreeze_&&dt(s,!0),r){let o=[],a=[];N("Patches").generateReplacementPatches_(e,s,o,a),r(o,a)}return s}else v(1,e)},this.produceWithPatches=(e,n)=>{if(typeof e=="function")return(a,...c)=>this.produceWithPatches(a,h=>e(h,...c));let r,s;return[this.produce(e,n,(a,c)=>{r=a,s=c}),r,s]},typeof t?.autoFreeze=="boolean"&&this.setAutoFreeze(t.autoFreeze),typeof t?.useStrictShallowCopy=="boolean"&&this.setUseStrictShallowCopy(t.useStrictShallowCopy)}createDraft(t){A(t)||v(8),k(t)&&(t=ke(t));let e=kt(this),n=ht(t,void 0);return n[m].isManual_=!0,ct(e),n}finishDraft(t,e){let n=t&&t[m];(!n||!n.isManual_)&&v(9);let{scope_:r}=n;return Pt(r,e),Mt(void 0,r)}setAutoFreeze(t){this.autoFreeze_=t}setUseStrictShallowCopy(t){this.useStrictShallowCopy_=t}applyPatches(t,e){let n;for(n=e.length-1;n>=0;n--){let s=e[n];if(s.path.length===0&&s.op==="replace"){t=s.value;break}}n>-1&&(e=e.slice(n+1));let r=N("Patches").applyPatches_;return k(t)?r(t,e):this.produce(t,s=>r(s,e))}};function ht(t,e){let n=Y(t)?N("MapSet").proxyMap_(t,e):V(t)?N("MapSet").proxySet_(t,e):Oe(t,e);return(e?e.scope_:Bt()).drafts_.push(n),n}i(ht,"createProxy");function ke(t){return k(t)||v(10,t),zt(t)}i(ke,"current");function zt(t){if(!A(t)||G(t))return t;let e=t[m],n;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,n=ot(t,e.scope_.immer_.useStrictShallowCopy_)}else n=ot(t,!0);return H(n,(r,s)=>{Dt(n,r,zt(s))}),e&&(e.finalized_=!1),n}i(zt,"currentImpl");var g=new Pe,b=g.produce,Sn=g.produceWithPatches.bind(g),_n=g.setAutoFreeze.bind(g),En=g.setUseStrictShallowCopy.bind(g),In=g.applyPatches.bind(g),An=g.createDraft.bind(g),Nn=g.finishDraft.bind(g);var Ft=Object.defineProperty,f=i((t,e)=>Ft(t,"name",{value:e,configurable:!0}),"t"),M=i((t,e)=>{for(var n in e)Ft(t,n,{get:e[n],enumerable:!0})},"s"),Me={};M(Me,{connect:()=>Wt,recommended:()=>Re});function Ut(t){let[,e]=t.state();e("network",null),e("accounts",null),e("connected",!1),e("connecting",!1)}i(Ut,"T");f(Ut,"disconnect");var Te=[["disconnect",Ut]],Ht="solana",K="5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp";async function $t(t){return{accounts:[(await t.connect()).publicKey.toString()],chainId:"SOLANA"}}i($t,"O");f($t,"getAccounts");function Jt(t){return t.map(e=>_.format({address:e.toString(),chainId:{namespace:Ht,reference:K}}))}i(Jt,"R");f(Jt,"formatAccountsToCAIP");var Re=[...Te];function Wt(t){return async()=>{let e=t(),n=await $t(e);if(Array.isArray(n))throw new Error("Expecting solana response to be a single value, not an array.");return n.accounts.map(r=>_.format({address:r,chainId:{namespace:Ht,reference:K}}))}}i(Wt,"J");f(Wt,"connect");var xe={};M(xe,{changeAccountSubscriber:()=>Yt});function Yt(t){return Gt.changeAccountSubscriber(t).build()}i(Yt,"X");f(Yt,"changeAccountSubscriber");var De={};M(De,{recommended:()=>Le});function ft(t){let[,e]=t.state();e("connecting",!1)}i(ft,"m");f(ft,"intoConnectionFinished");var Be=[["connect",ft]],Le=[...Be],ze={};M(ze,{recommended:()=>He});var Fe=class{static{i(this,"r")}static{f(this,"ActionBuilder")}name;#t=new Map;#n=new Map;#s=new Map;#e=new Map;#r;constructor(t){this.name=t}and(t){return this.#t.has(this.name)||this.#t.set(this.name,[]),this.#t.get(this.name)?.push(t),this}or(t){return this.#n.has(this.name)||this.#n.set(this.name,[]),this.#n.get(this.name)?.push(t),this}before(t){return this.#e.has(this.name)||this.#e.set(this.name,[]),this.#e.get(this.name)?.push(t),this}after(t){return this.#s.has(this.name)||this.#s.set(this.name,[]),this.#s.get(this.name)?.push(t),this}action(t){return this.#r=t,this}build(){if(!this.#r)throw new Error("Your action builder should includes an action.");return{actionName:this.name,action:this.#r,before:this.#e,after:this.#s,and:this.#t,or:this.#n}}};function Vt(t){try{return _.parse(t),!0}catch{return!1}}i(Vt,"j");f(Vt,"isValidCaipAddress");function pt(t,e){if(!e.every(Vt))throw new Error(`Your provider should format account addresses in CAIP-10 format. Your provided accounts: ${e}`);let[,n]=t.state();return n("accounts",e),n("connected",!0),e}i(pt,"p");f(pt,"connectAndUpdateStateForSingleNetwork");function mt(t){let[,e]=t.state();e("connecting",!0)}i(mt,"h");f(mt,"intoConnecting");var Ue=[["connect",mt]],He=[["connect",pt]],$e={};M($e,{recommended:()=>Je});var Je=[...Ue],Gt={};M(Gt,{changeAccountSubscriber:()=>Ve,connect:()=>Ye});var We=class{static{i(this,"f")}static{f(this,"ChangeAccountSubscriberBuilder")}#t=null;#n=null;#s=null;#e=null;#r=null;getInstance(t){return this.#t=t,this}format(t){return this.#n=t,this}validateEventPayload(t){return this.#s=t,this}addEventListener(t){return this.#e=t,this}removeEventListener(t){return this.#r=t,this}build(){if(this.#t===null)throw new Error(this.#i("getInstance"));if(this.#n===null)throw new Error(this.#i("format"));if(this.#e===null)throw new Error(this.#i("addEventListener"));if(this.#r===null)throw new Error(this.#i("removeEventListener"));let t=this.#t,e=this.#n,n=this.#e,r=this.#r,s=this.#s,o,a;return[async c=>{let[,h]=c.state(),l=t();if(!l)throw new Error("Trying to subscribe to your wallet, but seems its instance is not available.");o=f(async d=>{if(s&&!s(d)){c.action("disconnect");return}h("accounts",await e(l,d))},"subscriber"),a=n(l,o)},(c,h)=>{a&&typeof a=="function"&&a();let l=t();return r(l,o),h}]}#i(t){return`Required "${t}" operation has not been set for "changeAccountSubscriber"`}},Ye=f(()=>new Fe("connect").and(pt).before(mt).after(ft),"connect"),Ve=f(t=>new We().getInstance(t).validateEventPayload(e=>!!e).format(async(e,n)=>Jt([n])).addEventListener((e,n)=>{e.on("accountChanged",n)}).removeEventListener((e,n)=>{e.off("accountChanged",n)}),"changeAccountSubscriber");import{dynamicImportWithRefinedError as ce,ETHEREUM_CHAIN_ID as ue}from"@rango-dev/wallets-shared";import on from"bs58";var Ge=Object.defineProperty,u=i((t,e)=>Ge(t,"name",{value:e,configurable:!0}),"a");function Xt(t){return t.constructor.name==="AsyncFunction"}i(Xt,"w");u(Xt,"isAsync");function qt(t,e){return`${t}$$${e}`}i(qt,"l");u(qt,"generateStoreId");var gt=u(t=>`Couldn't find "${t}" action. Are you sure you've added the action?`,"ACTION_NOT_FOUND_ERROR"),Ke=u(t=>`An error occurred during running ${t}`,"OR_ELSE_ACTION_FAILED_ERROR"),Kt=u(t=>`An error occurred during running before for "${t}" action`,"BEFORE_ACTION_FAILED_ERROR"),je="For setup store, you should set `store` first.",Ze=class{static{i(this,"u")}static{u(this,"Namespace")}namespaceId;providerId;#t;#n=new Map;#s=new Map;#e=new Map;#r=new Map;#i=!1;#o;#c;constructor(t,e,n){let{configs:r,actions:s}=n;this.namespaceId=t,this.providerId=e,this.#c=r||new Map,this.#t=s,n.store&&this.store(n.store)}init(){if(this.#i)return;let t=this.#t.get("init");t&&t(this.#a()),this.#i=!0}state(){let t=this.#o;if(!t)throw new Error("You need to set your store using `.store` method first.");let e=this.#p();return[u(n=>{let r=t.getState().namespaces.getNamespaceData(e);return n?r[n]:r},"getState"),u((n,r)=>{t.getState().namespaces.updateStatus(e,n,r)},"setState")]}store(t){return this.#o&&console.warn("You've already set an store for your Namespace. Old store will be replaced by the new one."),this.#o=t,this.#g(),this}and_then(t,e){let n=this.#n.get(t)||[];return this.#n.set(t,n.concat(e)),this}or_else(t,e){let n=this.#s.get(t)||[];return this.#s.set(t,n.concat(e)),this}after(t,e,n){let r=this.#r.get(t)||[],s={hook:e,options:{context:n?.context}};return this.#r.set(t,r.concat(s)),this}before(t,e,n){let r=this.#e.get(t)||[],s={hook:e,options:{context:n?.context}};return this.#e.set(t,r.concat(s)),this}has(t){return!!this.#t.get(t)}run(t,...e){let n=this.#t.get(t);if(!n)throw new Error(gt(t.toString()));return Xt(n)?this.#m(t,e):this.#h(t,e)}#h(t,e){try{this.#d(t)}catch(o){throw this.#u(t),new Error(Kt(t.toString()),{cause:o})}let n=this.#t.get(t);if(!n)throw new Error(gt(t.toString()));let r=this.#a(),s;try{s=n(r,...e),s=this.#l(t,s)}catch(o){s=this.#f(t,o)}finally{this.#u(t)}return s}async#m(t,e){try{this.#d(t)}catch(s){throw this.#u(t),new Error(Kt(t.toString()),{cause:s})}let n=this.#t.get(t);if(!n)throw new Error(gt(t.toString()));let r=this.#a();return await n(r,...e).then(s=>this.#l(t,s)).catch(s=>this.#f(t,s)).finally(()=>this.#u(t))}#u(t){let e=this.#r.get(t);e&&e.forEach(n=>{let r=n.options?.context||this.#a();n.hook(r)})}#d(t){let e=this.#e.get(t);e&&e.forEach(n=>{let r=n.options?.context||this.#a();n.hook(r)})}#l(t,e){let n=this.#n.get(t);if(n){let r=this.#a();e=n.reduce((s,o)=>o(r,s),e)}return e}#f(t,e){let n=this.#s.get(t);if(n)try{let r=this.#a();return n.reduce((s,o)=>o(r,s),e)}catch(r){if(r instanceof Error)throw r.cause=e,r;let s=Ke(`${t.toString()} for ${this.namespaceId} namespace.`),o=new Error(String(r),{cause:e});throw new Error(s,{cause:o})}else throw e}#g(){let t=this.#o;if(!t)throw new Error(je);let e=this.#p();t.getState().namespaces.addNamespace(e,{namespaceId:this.namespaceId,providerId:this.providerId})}#p(){return qt(this.providerId,this.namespaceId)}#a(){return{state:this.state.bind(this),action:this.run.bind(this)}}},Xe="1.0",qe=class{static{i(this,"m")}static{u(this,"Provider")}id;version=Xe;#t;#n=!1;#s={};#e;#r;constructor(t,e,n,r){this.id=t,this.#r=n,this.#s=r?.extendInternalActions||{},this.#t=e,r?.store&&(this.#e=r.store,this.#o())}init(){if(this.#n)return;let t=this.#s.init;t&&t(this.#c()),this.#n=!0}state(){let t=this.#e;if(!t)throw new Error(`Any store detected for ${this.id}. You need to set your store using '.store' method first.`);return[u(e=>{let n=t.getState().providers.guessNamespacesState(this.id);if(!e)return n;switch(e){case"installed":case"connected":case"connecting":return n[e];default:throw new Error("Unhandled state for provider")}},"getState"),u((e,n)=>{switch(e){case"installed":return t.getState().providers.updateStatus(this.id,e,n);default:throw new Error(`Unhandled state update for provider. (provider id: ${this.id}, state name: ${e})`)}},"setState")]}store(t){return this.#e&&console.warn("You've already set an store for your Provider. Old store will be replaced by the new one."),this.#e=t,this.#o(),this}info(){let t=this.#e;if(!t)return this.#r;let e=t.getState().providers.list[this.id].config;return{metadata:e.metadata,deepLink:e.deepLink}}getAll(){return this.#t}get(t){return this.#t.get(t)}findByNamespace(t){let e;return this.#t.forEach(n=>{n.namespaceId===t&&(e=n)}),e}before(t,e){return this.#i("before",t,e),this}after(t,e){return this.#i("after",t,e),this}#i(t,e,n){let r={state:this.state.bind(this)};return this.#t.forEach(s=>{if(t==="after")s.after(e,n,{context:r});else if(t==="before")s.before(e,n,{context:r});else throw new Error(`You hook name is invalid: ${t}`)}),this}#o(){let t=this.#e;if(!t)throw new Error("For setup store, you should set `store` first.");t.getState().providers.addProvider(this.id,this.#r),this.#t.forEach(e=>{e.store(t)})}#c(){return{state:this.state.bind(this)}}},Ln=class{static{i(this,"g")}static{u(this,"Hub")}#t=new Map;#n;constructor(t){this.#n=t??{}}init(){this.runAll("init")}runAll(t){let e=[],n=this.#t.values();for(let r of n){let s={id:r.id,provider:void 0,namespaces:[]},o=r[t];typeof o=="function"&&(s.provider=o.call(r));let a=r.getAll().values();for(let c of a){let h=c[t];if(typeof h=="function"){let l=h();s.namespaces.push(l)}}e.push(s)}return e}add(t,e){return this.#n.store&&e.store(this.#n.store),this.#t.set(t,e),this}remove(t){if(!this.#t.get(t))throw new Error(`Provider not found: No provider exists with ID "${t}"`);return this.#n.store?.getState().providers.removeProvider(t),this.#t.delete(t),this}get(t){return this.#t.get(t)}getAll(){return this.#t}state(){let t=this.runAll("state"),e={};return t.forEach(n=>{let r=[];n.namespaces.forEach(o=>{let[a]=o;r.push(a())});let[s]=n.provider;e[n.id]={...s()||{},namespaces:r}}),e}};function j(t,e){let n=t.namespaces.list,r=Object.keys(n).filter(c=>n[c].info.providerId===e),s=!!t.providers.list[e]?.data.installed,o=r.length>0?r.some(c=>n[c].data.connected):!1,a=r.length>0?r.some(c=>n[c].data.connecting):!1;return{installed:s,connected:o,connecting:a}}i(j,"d");u(j,"guessProviderStateSelector");function Qt(t,e){return t.namespaces.list[e].data}i(Qt,"v");u(Qt,"namespaceStateSelector");function te(t){let e=u(n=>r=>{let s=u((o,a,c)=>{for(let h of o)r(h,a,c)},"executeListener");return n.subscribe((o,a)=>{let c=ee(o,a),h=[...vt(o),...c];s(h,o,a)}),{flushEvents:()=>{let o=n.getState(),a=vt(o);s(a,o,o)}}},"extendedSubscribe");return new Proxy(t,{get:function(n,r,s){return r==="subscribe"?e(n):Reflect.get(n,r,s)}})}i(te,"T");u(te,"extend");function vt(t){return[...t.providers.events,...t.namespaces.events]}i(vt,"k");u(vt,"tryConsumeEvents");function ee(t,e){let n=[];for(let r of Object.keys(t.providers.list)){let s=j(t,r),o=j(e,r);if(o.connecting!==s.connecting){let a={type:"provider_connecting",provider:r,value:s.connecting};n.push(a)}if(!o.connected&&s.connected){let a={type:"provider_connected",provider:r};n.push(a)}if(o.connected&&!s.connected){let a={type:"provider_disconnected",provider:r};n.push(a)}}return n}i(ee,"W");u(ee,"getEventsLike");var Qe=u(()=>({config:{}}),"hubStore"),ne=class{static{i(this,"h")}static{u(this,"ConsumableEvents")}#t=[];push(t){this.#t.push(t)}[Symbol.iterator](){return{next:()=>this.#t.length==0?{done:!0,value:void 0}:{done:!1,value:this.#t.shift()}}}},tn=u((t,e)=>({events:new ne,list:{},addNamespace:(n,r)=>{let s={data:{accounts:null,network:null,connected:!1,connecting:!1},error:"",info:r};t(b(o=>{o.namespaces.list[n]=s}))},updateStatus:(n,r,s)=>{let o=e().namespaces.list[n];if(!o)throw new Error(`No namespace with '${n}' found.`);e().namespaces._produceEventsWhenUpdatingStatus(o,n,r,s),t(b(a=>{a.namespaces.list[n].data[r]=s}))},getNamespaceData(n){return Qt(e(),n)},_produceEventsWhenUpdatingStatus:(n,r,s,o)=>{if(s==="accounts")if(Object.is(o,null)||Array.isArray(o)&&o.length===0){if(e().namespaces.list[r].data.connected){let a={type:"namespace_disconnected",provider:n.info.providerId,namespace:n.info.namespaceId};e().namespaces.events.push(a)}}else{let a=e().namespaces.list[r].data.accounts;if(a){if(a.sort().toString()!==o.sort().toString()){let c={type:"namespace_account_switched",provider:n.info.providerId,namespace:n.info.namespaceId,previousAccounts:a,accounts:o};e().namespaces.events.push(c)}}else{let c={type:"namespace_connected",provider:n.info.providerId,namespace:n.info.namespaceId,accounts:o};e().namespaces.events.push(c)}}else if(s==="network"){let a=e().namespaces.list[r].data.network,c={type:"namespace_network_switched",provider:n.info.providerId,namespace:n.info.namespaceId,network:o,previousNetwork:a};e().namespaces.events.push(c)}}}),"namespacesStore"),en=u((t,e)=>({events:new ne,list:{},addProvider:(n,r)=>{let s={data:{installed:!1},error:"",config:r};t(b(o=>{o.providers.list[n]=s}))},removeProvider:n=>{t(b(r=>{delete r.providers.list[n]}))},updateStatus:(n,r,s)=>{let o=e().providers.list[n];if(!o)throw new Error(`No namespace namespace with '${n}' found.`);e().providers._produceEventsWhenUpdatingStatus(o,n,r,s),t(b(a=>{a.providers.list[n].data[r]=s}))},guessNamespacesState:n=>j(e(),n),_produceEventsWhenUpdatingStatus:(n,r,s,o)=>{if(s==="installed"){let a={type:"provider_detected",provider:r};e().providers.events.push(a)}}}),"providersStore"),Hn=u(()=>{let t=Ot((...e)=>({hub:Qe(...e),providers:en(...e),namespaces:tn(...e)}));return te(t)},"createStore"),jt=["init","state","after","before","and_then","or_else","store"],Zt=["string","number"],$n=class{static{i(this,"S")}static{u(this,"NamespaceBuilder")}#t;#n;#s=new Map;#e=[];#r;constructor(t,e){this.#t=t,this.#n=e,this.#r={}}config(t,e){return this.#r[t]=e,this}action(t,e){return Array.isArray(t)?(t.forEach(([n,r])=>{this.#s.set(n,r)}),this):typeof t=="object"&&t?.actionName?(this.#e.push(t),this):(e&&this.#s.set(t,e),this)}build(){if(this.#i(this.#r))return this.#h(this.#r);throw new Error("You namespace config isn't valid.")}#i(t){return!0}#o(t){this.#e.forEach(e=>{e.after.forEach(n=>{n.map(r=>{t.after(e.actionName,r)})}),e.before.forEach(n=>{n.map(r=>{t.before(e.actionName,r)})}),e.and.forEach(n=>{n.map(r=>{t.and_then(e.actionName,r)})}),e.or.forEach(n=>{n.map(r=>{t.or_else(e.actionName,r)})})})}#c(){this.#e.forEach(t=>{this.#s.set(t.actionName,t.action)})}#h(t){this.#c();let e=new Ze(this.#t,this.#n,{configs:t,actions:this.#s});return this.#o(e),new Proxy(e,{has:(n,r)=>{if(typeof r!="string")throw new Error("You can use string as your property on Namespace instance.");return jt.includes(r)||Zt.includes(typeof e[r])?!0:e.has(r)},get:(n,r)=>{if(typeof r!="string")throw new Error("You can use string as your property on Namespace instance.");let s=e[r];return jt.includes(r)?s.bind(e):Zt.includes(typeof s)?s:e.run.bind(e,r)},set:()=>{throw new Error("You can not set anything on this object.")}})}},Jn=class{static{i(this,"x")}static{u(this,"ProviderBuilder")}#t;#n=new Map;#s={};#e={};#r;constructor(t,e){this.#t=t,this.#r=e||{}}add(t,e){return this.#r.store&&e.store(this.#r.store),this.#n.set(t,e),this}config(t,e){return this.#e[t]=e,this}init(t){return this.#s.init=t,this}build(){if(this.#i(this.#e))return new qe(this.#t,this.#n,this.#e,{extendInternalActions:this.#s,store:this.#r.store});throw new Error("You need to set all required configs.")}#i(t){return!!t.metadata}},Wn=class{static{i(this,"b")}static{u(this,"ActionBuilder")}name;#t=new Map;#n=new Map;#s=new Map;#e=new Map;#r;constructor(t){this.name=t}and(t){return this.#t.has(this.name)||this.#t.set(this.name,[]),this.#t.get(this.name)?.push(t),this}or(t){return this.#n.has(this.name)||this.#n.set(this.name,[]),this.#n.get(this.name)?.push(t),this}before(t){return this.#e.has(this.name)||this.#e.set(this.name,[]),this.#e.get(this.name)?.push(t),this}after(t){return this.#s.has(this.name)||this.#s.set(this.name,[]),this.#s.get(this.name)?.push(t),this}action(t){return this.#r=t,this}build(){if(!this.#r)throw new Error("Your action builder should includes an action.");return{actionName:this.name,action:this.#r,before:this.#e,after:this.#s,and:this.#t,or:this.#n}}};function nn(t,e){if(!e)throw new Error("You should provide a valid semver, e.g 1.0.0.");let n=t.find(([r])=>r===e);if(!n)throw new Error(`You target version hasn't been found. Available versions: ${Object.keys(t).join(", ")}`);return n}i(nn,"L");u(nn,"pickVersion");function rn(){let t=[],e={version:(n,r)=>(t.push([n,r]),e),build:()=>t};return e}i(rn,"H");u(rn,"defineVersions");import{Networks as ie}from"@rango-dev/wallets-shared";import"rango-types";import{dynamicImportWithRefinedError as re}from"@rango-dev/wallets-shared";import{DefaultSignerFactory as sn,TransactionType as se}from"rango-types";async function yt(){let t=new sn,{EthereumSigner:e}=await re(async()=>await import("./ethereum-J6U6B3NU.js")),{SolanaSigner:n}=await re(async()=>await import("./solana-Q7LP23TP.js"));return t.registerSigner(se.EVM,new e),t.registerSigner(se.SOLANA,new n),t}i(yt,"getSigners");var hr=[y.ETHEREUM,y.POLYGON,y.BASE],oe=16,dr="ledger",lr={name:"Ledger",icon:"https://raw.githubusercontent.com/rango-exchange/assets/main/wallets/ledger/icon.svg",extensions:{homepage:"https://support.ledger.com/hc/en-us/articles/4404389606417-Download-and-install-Ledger-Live?docs=true"},properties:[{name:"namespaces",value:{selection:"single",data:[{label:"Ethereum",value:"EVM",id:"ETH",getSupportedChains:t=>t.filter(e=>e.name===ie.ETHEREUM)},{label:"Solana",value:"Solana",id:"SOLANA",getSupportedChains:t=>t.filter(e=>e.name===ie.SOLANA)}]}},{name:"derivationPath",value:{data:[{id:"metamask",label:"Metamask (m/44'/60'/0'/0/index)",namespace:"EVM",generateDerivationPath:t=>`44'/60'/0'/0/${t}`},{id:"ledgerLive",label:"LedgerLive (m/44'/60'/index'/0/0)",namespace:"EVM",generateDerivationPath:t=>`44'/60'/${t}'/0/0`},{id:"legacy",label:"Legacy (m/44'/60'/0'/index)",namespace:"EVM",generateDerivationPath:t=>`44'/60'/0'/${t}`},{id:"(m/44'/501'/index')",label:"(m/44'/501'/index')",namespace:"Solana",generateDerivationPath:t=>`44'/501'/${t}'`},{id:"(m/44'/501'/0'/index)",label:"(m/44'/501'/0'/index)",namespace:"Solana",generateDerivationPath:t=>`44'/501'/0'/${t}`}]}},{name:"signers",value:{getSigners:async()=>yt()}}]};function _r(){let t=new Map;return t.set(y.ETHEREUM,{chainId:ue}),t.set(y.SOLANA,{chainId:y.SOLANA}),t}i(_r,"ledger");var ae={21781:"The device is locked",25871:"Related application is not ready on your device",27013:"Action denied by user"};function an(t){return ae[t]?ae[t]:X(t)?X(t):`Ledger device unknown error 0x${t.toString(oe)}`}i(an,"getLedgerErrorMessage");function wt(t){return t?.statusCode?new Error(an(t.statusCode)):t?.code==="INSUFFICIENT_FUNDS"?new Error("Insufficient funds for transaction"):t}i(wt,"getLedgerError");function Er(t,e){throw wt(e)}i(Er,"standardizeAndThrowLedgerError");async function Ir(){try{let t=await he(),e=q(),n=new(await ce(async()=>await import("./Eth-5PCPPYSI.js"))).default(t),r=[],s=await n.getAddress(e,!1,!0);return r.push(s.address),{accounts:r,chainId:ue,derivationPath:e}}catch(t){throw wt(t)}finally{await de()}}i(Ir,"getEthereumAccounts");async function Ar(){try{let t=await he(),e=q(),n=new(await ce(async()=>await import("./Solana-NJS3LWGA.js"))).default(t),r=[],s=await n.getAddress(e);return r.push(on.encode(s.address)),{accounts:r,chainId:K,derivationPath:e}}catch(t){throw wt(t)}finally{await de()}}i(Ar,"getSolanaAccounts");var L=null;async function he(){return L=await(await import("./TransportWebHID-HV53OYSS.js")).default.create(),L}i(he,"transportConnect");async function de(){L&&(await L.close(),L=null)}i(de,"transportDisconnect");export{_ as a,Se as b,cn as c,q as d,Ht as e,Gt as f,$n as g,Jn as h,dr as i,lr as j,_r as k,wt as l,Er as m,Ir as n,Ar as o,he as p,de as q,yt as r};
|
|
2
|
-
//# sourceMappingURL=chunk-I25CJMQS.js.map
|