@tuwaio/satellite-core 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +97 -0
- package/dist/index.d.mts +272 -0
- package/dist/index.d.ts +272 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +2 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +62 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2025 FOP Tkach Oleksandr
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# Satellite Connect Core
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@tuwaio/satellite-core)
|
|
4
|
+
[](./LICENSE)
|
|
5
|
+
[](https://github.com/TuwaIO/satellite-core/actions)
|
|
6
|
+
|
|
7
|
+
Core of the Satellite ecosystem for Web3 wallet interactions, providing a universal interface for connecting and interacting with various blockchain wallets.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## 🏛️ What is `@tuwaio/satellite-core`?
|
|
12
|
+
|
|
13
|
+
`@tuwaio/satellite-core` is the foundation package of the Satellite ecosystem, designed to unify Web3 wallet interactions. It provides a single interface for connecting and interacting with wallets across different blockchains (EVM, Solana).
|
|
14
|
+
|
|
15
|
+
Built with TypeScript, it leverages modern tools for state management and type-safe development.
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## ✨ Key Features
|
|
20
|
+
|
|
21
|
+
- **Universal Interface:** Single API for interacting with different blockchain wallets
|
|
22
|
+
- **Type Safety:** Full TypeScript support
|
|
23
|
+
- **Modular Architecture:** Easy extension for new wallet types
|
|
24
|
+
- **State Management:** Built-in connection state management system
|
|
25
|
+
- **Bundle Optimization:** Efficient tree-shaking optimization
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## 💾 Installation
|
|
30
|
+
|
|
31
|
+
### Requirements
|
|
32
|
+
- Node.js 20+
|
|
33
|
+
- TypeScript 5.9+
|
|
34
|
+
```bash
|
|
35
|
+
# Using pnpm (recommended)
|
|
36
|
+
pnpm add @tuwaio/satellite-core @tuwaio/orbit-core @wagmi/core @wallet-standard/ui immer zustand
|
|
37
|
+
|
|
38
|
+
# Using npm
|
|
39
|
+
npm install @tuwaio/satellite-core @tuwaio/orbit-core @wagmi/core @wallet-standard/ui immer zustand
|
|
40
|
+
|
|
41
|
+
# Using yarn
|
|
42
|
+
yarn add @tuwaio/satellite-core @tuwaio/orbit-core @wagmi/core @wallet-standard/ui immer zustand
|
|
43
|
+
```
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## 🚀 Quick Start
|
|
47
|
+
|
|
48
|
+
### Basic Usage
|
|
49
|
+
```typescript
|
|
50
|
+
import { getAdapterFromWalletType } from '@tuwaio/satellite-core';
|
|
51
|
+
// Determine adapter type from wallet type
|
|
52
|
+
const adapter = getAdapterFromWalletType('evm:metamask');
|
|
53
|
+
```
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## 🔧 Architecture
|
|
57
|
+
|
|
58
|
+
The package is structured around these core components:
|
|
59
|
+
|
|
60
|
+
### Build System
|
|
61
|
+
- Built with `tsup`
|
|
62
|
+
- Supports CommonJS and ESM formats
|
|
63
|
+
- Generates TypeScript declarations
|
|
64
|
+
|
|
65
|
+
### Core Modules
|
|
66
|
+
- **Store:** Connection state management system
|
|
67
|
+
- **Utils:** Wallet interaction utilities
|
|
68
|
+
- **Types:** Type system for unified wallet operations
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## ✨ Ecosystem Integration
|
|
73
|
+
|
|
74
|
+
Satellite Core works in conjunction with other ecosystem packages:
|
|
75
|
+
|
|
76
|
+
- **`@tuwaio/satellite-core`:** Base functionality (this package)
|
|
77
|
+
- **`@tuwaio/satellite-evm`:** EVM wallet integration
|
|
78
|
+
- **`@tuwaio/satellite-solana`:** Solana wallet integration
|
|
79
|
+
- **`@tuwaio/satellite-react`:** React hooks and components
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
## 🤝 Contributing & Support
|
|
84
|
+
|
|
85
|
+
Contributions are welcome! Please read our main **[Contribution Guidelines](https://github.com/TuwaIO/workflows/blob/main/CONTRIBUTING.md)**.
|
|
86
|
+
|
|
87
|
+
If you find this library useful, please consider supporting its development. Every contribution helps!
|
|
88
|
+
|
|
89
|
+
[**➡️ View Support Options**](https://github.com/TuwaIO/workflows/blob/main/Donation.md)
|
|
90
|
+
|
|
91
|
+
## 📄 License
|
|
92
|
+
|
|
93
|
+
This project is licensed under the **Apache-2.0 License** - see the [LICENSE](./LICENSE) file for details.
|
|
94
|
+
|
|
95
|
+
## 👥 Contributors
|
|
96
|
+
|
|
97
|
+
- **Oleksandr Tkach** - [GitHub](https://github.com/Argeare5)
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
import * as zustand from 'zustand';
|
|
2
|
+
import { OrbitGenericAdapter, OrbitAdapter } from '@tuwaio/orbit-core';
|
|
3
|
+
import { Connector as Connector$1, CreateConnectorFn } from '@wagmi/core';
|
|
4
|
+
import { UiWallet, UiWalletAccount } from '@wallet-standard/ui';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Type representing a wallet identifier in format "chain:wallet"
|
|
8
|
+
* @example "evm:metamask" | "solana:phantom"
|
|
9
|
+
*/
|
|
10
|
+
type WalletType = `${OrbitAdapter}:${string}`;
|
|
11
|
+
/**
|
|
12
|
+
* Configuration properties for initializing wallet connectors
|
|
13
|
+
*/
|
|
14
|
+
type ConnectorsInitProps = {
|
|
15
|
+
/** Application name displayed in wallet interfaces */
|
|
16
|
+
appName: string;
|
|
17
|
+
/** Logo URL for Coinbase Wallet */
|
|
18
|
+
appLogoUrl?: string;
|
|
19
|
+
/** WalletConnect project ID (required for WalletConnect functionality) */
|
|
20
|
+
projectId?: string;
|
|
21
|
+
/** Logo for WalletConnect interface */
|
|
22
|
+
appLogo?: string;
|
|
23
|
+
/** Application description for WalletConnect */
|
|
24
|
+
description?: string;
|
|
25
|
+
/** Application URL for WalletConnect */
|
|
26
|
+
appUrl?: string;
|
|
27
|
+
/** Array of icon URLs for WalletConnect */
|
|
28
|
+
appIcons?: string[];
|
|
29
|
+
/** Function to get impersonated account address for testing */
|
|
30
|
+
getImpersonatedAccount?: () => string | `0x${string}` | undefined;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Base interface for connected wallet information
|
|
34
|
+
*/
|
|
35
|
+
interface BaseWallet {
|
|
36
|
+
/** Unique identifier of the wallet */
|
|
37
|
+
walletType: WalletType;
|
|
38
|
+
/** Wallet's public address */
|
|
39
|
+
address: string | `0x${string}`;
|
|
40
|
+
/** Connected chain ID */
|
|
41
|
+
chainId: string | number;
|
|
42
|
+
/** RPC endpoint URL */
|
|
43
|
+
rpcURL: string;
|
|
44
|
+
/** Indicates if the address is a smart contract */
|
|
45
|
+
isContractAddress: boolean;
|
|
46
|
+
/** Connection status */
|
|
47
|
+
isConnected: boolean;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Extended wallet interface for Solana-specific properties
|
|
51
|
+
*/
|
|
52
|
+
interface SolanaWallet extends BaseWallet {
|
|
53
|
+
/** Connected Wallet Standard account */
|
|
54
|
+
connectedAccount?: UiWalletAccount;
|
|
55
|
+
/** Connected Wallet Standard wallet instance */
|
|
56
|
+
connectedWallet?: UiWallet;
|
|
57
|
+
}
|
|
58
|
+
/** Union type for all supported wallet types */
|
|
59
|
+
type Wallet = BaseWallet | SolanaWallet;
|
|
60
|
+
/** EVM-specific connector type */
|
|
61
|
+
type ConnectorEVM = Connector$1<CreateConnectorFn>;
|
|
62
|
+
/** Solana-specific connector type */
|
|
63
|
+
type ConnectorSolana = UiWallet;
|
|
64
|
+
/** Union type for all supported connector types */
|
|
65
|
+
type Connector = ConnectorEVM | ConnectorSolana;
|
|
66
|
+
/**
|
|
67
|
+
* Interface for blockchain network adapters
|
|
68
|
+
* @remarks
|
|
69
|
+
* Adapters provide chain-specific implementation for wallet interactions
|
|
70
|
+
*/
|
|
71
|
+
type SatelliteAdapter = {
|
|
72
|
+
/** Unique identifier for the adapter */
|
|
73
|
+
key: OrbitAdapter;
|
|
74
|
+
/**
|
|
75
|
+
* Initiates wallet connection
|
|
76
|
+
* @returns Promise resolving to connected wallet instance
|
|
77
|
+
*/
|
|
78
|
+
connect: ({ walletType, chainId, connectors, }: {
|
|
79
|
+
walletType: WalletType;
|
|
80
|
+
chainId: number | string;
|
|
81
|
+
connectors: Connector[];
|
|
82
|
+
}) => Promise<Wallet>;
|
|
83
|
+
/** Disconnects current wallet session */
|
|
84
|
+
disconnect: () => Promise<void>;
|
|
85
|
+
/** Retrieves available wallet connectors for this adapter */
|
|
86
|
+
getConnectors: () => Promise<{
|
|
87
|
+
adapter: OrbitAdapter;
|
|
88
|
+
connectors: Connector[];
|
|
89
|
+
}>;
|
|
90
|
+
/**
|
|
91
|
+
* Handles network switching for connected wallet
|
|
92
|
+
* @param chainId - Target chain ID
|
|
93
|
+
* @param currentChainId - Current chain ID
|
|
94
|
+
* @param updateActiveWallet - Callback to update wallet state
|
|
95
|
+
*/
|
|
96
|
+
checkAndSwitchNetwork: (chainId: string | number, currentChainId?: string | number, updateActiveWallet?: (wallet: Partial<Wallet>) => void) => Promise<void>;
|
|
97
|
+
/**
|
|
98
|
+
* Generates blockchain explorer URL
|
|
99
|
+
* @returns Explorer URL or undefined if not available
|
|
100
|
+
*/
|
|
101
|
+
getExplorerUrl: (url?: string, chainId?: string | number) => string | undefined;
|
|
102
|
+
/** Optional method to resolve ENS-like names */
|
|
103
|
+
getName?: (address: string) => Promise<string | null>;
|
|
104
|
+
/** Optional method to get avatar for resolved names */
|
|
105
|
+
getAvatar?: (name: string) => Promise<string | null>;
|
|
106
|
+
/** Optional method to check if address is a smart contract */
|
|
107
|
+
checkIsContractWallet?: ({ address, chainId }: {
|
|
108
|
+
address: string;
|
|
109
|
+
chainId: string | number;
|
|
110
|
+
}) => Promise<boolean>;
|
|
111
|
+
};
|
|
112
|
+
/**
|
|
113
|
+
* Store interface for managing wallet connections
|
|
114
|
+
*/
|
|
115
|
+
type ISatelliteConnectStore = {
|
|
116
|
+
/** Returns configured adapter(s) */
|
|
117
|
+
getAdapter: () => SatelliteAdapter | SatelliteAdapter[];
|
|
118
|
+
/** Information about last connected wallet */
|
|
119
|
+
lastConnectedWallet?: {
|
|
120
|
+
walletType: WalletType;
|
|
121
|
+
chainId: number | string;
|
|
122
|
+
};
|
|
123
|
+
/** Available connectors mapped by adapter type */
|
|
124
|
+
availableConnectors: Partial<Record<OrbitAdapter, Connector[]>>;
|
|
125
|
+
/** Initializes wallet connectors */
|
|
126
|
+
initializeAppConnectors: ({ autoConnect }: {
|
|
127
|
+
autoConnect?: boolean;
|
|
128
|
+
}) => Promise<void>;
|
|
129
|
+
/** Connects to specified wallet */
|
|
130
|
+
connect: ({ walletType, chainId }: {
|
|
131
|
+
walletType: WalletType;
|
|
132
|
+
chainId: number | string;
|
|
133
|
+
}) => Promise<void>;
|
|
134
|
+
/** Disconnects active wallet */
|
|
135
|
+
disconnect: () => Promise<void>;
|
|
136
|
+
/** Indicates ongoing connection attempt */
|
|
137
|
+
walletConnecting: boolean;
|
|
138
|
+
/** Contains error message if connection failed */
|
|
139
|
+
walletConnectionError?: string;
|
|
140
|
+
/** Currently connected wallet */
|
|
141
|
+
activeWallet?: Wallet;
|
|
142
|
+
/** Clears connection error state */
|
|
143
|
+
resetWalletConnectionError: () => void;
|
|
144
|
+
/** Updates active wallet properties */
|
|
145
|
+
updateActiveWallet: (wallet: Partial<Wallet>) => void;
|
|
146
|
+
/** Switches network for connected wallet */
|
|
147
|
+
switchNetwork: (chainId: string | number) => Promise<void>;
|
|
148
|
+
/** Contains error message if network switch failed */
|
|
149
|
+
switchNetworkError?: string;
|
|
150
|
+
/** Clears network switch error state */
|
|
151
|
+
resetSwitchNetworkError: () => void;
|
|
152
|
+
};
|
|
153
|
+
/**
|
|
154
|
+
* Callback type for successful wallet connections
|
|
155
|
+
*/
|
|
156
|
+
type WalletConnectedCallback = (wallet: Wallet) => void | Promise<void>;
|
|
157
|
+
/**
|
|
158
|
+
* Configuration parameters for initializing Satellite Connect store
|
|
159
|
+
*/
|
|
160
|
+
type SatelliteConnectStoreInitialParameters = OrbitGenericAdapter<SatelliteAdapter> & {
|
|
161
|
+
/** Optional callback executed after successful wallet connection */
|
|
162
|
+
callbackAfterConnected?: WalletConnectedCallback;
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Creates a Satellite Connect store instance for managing wallet connections and state
|
|
167
|
+
*
|
|
168
|
+
* @param params - Configuration parameters for the store
|
|
169
|
+
* @param params.adapter - Single adapter or array of adapters for different chains
|
|
170
|
+
* @param params.callbackAfterConnected - Optional callback function called after successful wallet connection
|
|
171
|
+
*
|
|
172
|
+
* @returns A Zustand store instance with wallet connection state and methods
|
|
173
|
+
*/
|
|
174
|
+
declare function createSatelliteConnectStore({ adapter, callbackAfterConnected, }: SatelliteConnectStoreInitialParameters): zustand.StoreApi<ISatelliteConnectStore>;
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Extracts the adapter type from a wallet type string
|
|
178
|
+
*
|
|
179
|
+
* @example
|
|
180
|
+
* ```typescript
|
|
181
|
+
* // Returns OrbitAdapter.EVM
|
|
182
|
+
* getAdapterFromWalletType('evm:metamask');
|
|
183
|
+
*
|
|
184
|
+
* // Returns OrbitAdapter.SOLANA
|
|
185
|
+
* getAdapterFromWalletType('solana:phantom');
|
|
186
|
+
*
|
|
187
|
+
* // Returns OrbitAdapter.EVM (default)
|
|
188
|
+
* getAdapterFromWalletType('unknown');
|
|
189
|
+
* ```
|
|
190
|
+
*
|
|
191
|
+
* @param walletType - Wallet type in format "chain:wallet" (e.g. "evm:metamask", "solana:phantom")
|
|
192
|
+
* @returns The corresponding {@link OrbitAdapter} type or EVM as default
|
|
193
|
+
*
|
|
194
|
+
* @remarks
|
|
195
|
+
* The function splits the wallet type string by ":" and takes the first part as the adapter type.
|
|
196
|
+
* If the split fails or the first part is empty, it defaults to EVM adapter.
|
|
197
|
+
*/
|
|
198
|
+
declare function getAdapterFromWalletType(walletType: WalletType): OrbitAdapter;
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Generates a standardized wallet type identifier from adapter type and connector name
|
|
202
|
+
*
|
|
203
|
+
* @example
|
|
204
|
+
* ```typescript
|
|
205
|
+
* // Returns "evm:metamask"
|
|
206
|
+
* getWalletTypeFromConnectorName(OrbitAdapter.EVM, "MetaMask");
|
|
207
|
+
*
|
|
208
|
+
* // Returns "solana:phantom"
|
|
209
|
+
* getWalletTypeFromConnectorName(OrbitAdapter.SOLANA, "Phantom");
|
|
210
|
+
*
|
|
211
|
+
* // Returns "evm:coinbasewallet" (removes spaces)
|
|
212
|
+
* getWalletTypeFromConnectorName(OrbitAdapter.EVM, "Coinbase Wallet");
|
|
213
|
+
* ```
|
|
214
|
+
*
|
|
215
|
+
* @param adapter - The blockchain adapter type (e.g. EVM, SOLANA)
|
|
216
|
+
* @param name - The wallet connector name (e.g. "MetaMask", "Phantom")
|
|
217
|
+
* @returns A formatted wallet type string in format "chain:wallet"
|
|
218
|
+
*
|
|
219
|
+
* @remarks
|
|
220
|
+
* The function:
|
|
221
|
+
* 1. Combines adapter type with connector name using ":" as separator
|
|
222
|
+
* 2. Removes all whitespace from connector name
|
|
223
|
+
* 3. Converts connector name to lowercase
|
|
224
|
+
* This ensures consistent wallet type identifiers across the application
|
|
225
|
+
*/
|
|
226
|
+
declare function getWalletTypeFromConnectorName(adapter: OrbitAdapter, name: string): string;
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Helper utilities for managing impersonated wallet addresses
|
|
230
|
+
*
|
|
231
|
+
* @remarks
|
|
232
|
+
* These utilities are primarily used for development and testing purposes.
|
|
233
|
+
* They provide a way to simulate different wallet addresses without actually connecting a wallet.
|
|
234
|
+
* All data is stored in localStorage with the 'satellite-connect:impersonatedAddress' key.
|
|
235
|
+
* Functions are safe to use in both browser and SSR environments.
|
|
236
|
+
*/
|
|
237
|
+
declare const impersonatedHelpers: {
|
|
238
|
+
/**
|
|
239
|
+
* Currently impersonated address from localStorage
|
|
240
|
+
* Returns empty string if not set or in SSR context
|
|
241
|
+
*/
|
|
242
|
+
impersonatedAddress: string;
|
|
243
|
+
/**
|
|
244
|
+
* Stores an impersonated address in localStorage
|
|
245
|
+
*
|
|
246
|
+
* @example
|
|
247
|
+
* ```typescript
|
|
248
|
+
* // Set impersonated address
|
|
249
|
+
* impersonatedHelpers.setImpersonated('0x1234...5678');
|
|
250
|
+
* ```
|
|
251
|
+
*
|
|
252
|
+
* @param address - Ethereum or Solana address to impersonate
|
|
253
|
+
* @returns undefined in SSR context, void in browser
|
|
254
|
+
*/
|
|
255
|
+
setImpersonated: (address: string) => void;
|
|
256
|
+
/**
|
|
257
|
+
* Retrieves the current impersonated address from localStorage
|
|
258
|
+
*
|
|
259
|
+
* @example
|
|
260
|
+
* ```typescript
|
|
261
|
+
* // Get current impersonated address
|
|
262
|
+
* const address = impersonatedHelpers.getImpersonated();
|
|
263
|
+
* if (address) {
|
|
264
|
+
* console.log('Currently impersonating:', address);
|
|
265
|
+
* }
|
|
266
|
+
* ```
|
|
267
|
+
* @returns The impersonated address or undefined if not set or in SSR context
|
|
268
|
+
*/
|
|
269
|
+
getImpersonated: () => string | null | undefined;
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
export { type BaseWallet, type Connector, type ConnectorEVM, type ConnectorSolana, type ConnectorsInitProps, type ISatelliteConnectStore, type SatelliteAdapter, type SatelliteConnectStoreInitialParameters, type SolanaWallet, type Wallet, type WalletConnectedCallback, type WalletType, createSatelliteConnectStore, getAdapterFromWalletType, getWalletTypeFromConnectorName, impersonatedHelpers };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
import * as zustand from 'zustand';
|
|
2
|
+
import { OrbitGenericAdapter, OrbitAdapter } from '@tuwaio/orbit-core';
|
|
3
|
+
import { Connector as Connector$1, CreateConnectorFn } from '@wagmi/core';
|
|
4
|
+
import { UiWallet, UiWalletAccount } from '@wallet-standard/ui';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Type representing a wallet identifier in format "chain:wallet"
|
|
8
|
+
* @example "evm:metamask" | "solana:phantom"
|
|
9
|
+
*/
|
|
10
|
+
type WalletType = `${OrbitAdapter}:${string}`;
|
|
11
|
+
/**
|
|
12
|
+
* Configuration properties for initializing wallet connectors
|
|
13
|
+
*/
|
|
14
|
+
type ConnectorsInitProps = {
|
|
15
|
+
/** Application name displayed in wallet interfaces */
|
|
16
|
+
appName: string;
|
|
17
|
+
/** Logo URL for Coinbase Wallet */
|
|
18
|
+
appLogoUrl?: string;
|
|
19
|
+
/** WalletConnect project ID (required for WalletConnect functionality) */
|
|
20
|
+
projectId?: string;
|
|
21
|
+
/** Logo for WalletConnect interface */
|
|
22
|
+
appLogo?: string;
|
|
23
|
+
/** Application description for WalletConnect */
|
|
24
|
+
description?: string;
|
|
25
|
+
/** Application URL for WalletConnect */
|
|
26
|
+
appUrl?: string;
|
|
27
|
+
/** Array of icon URLs for WalletConnect */
|
|
28
|
+
appIcons?: string[];
|
|
29
|
+
/** Function to get impersonated account address for testing */
|
|
30
|
+
getImpersonatedAccount?: () => string | `0x${string}` | undefined;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Base interface for connected wallet information
|
|
34
|
+
*/
|
|
35
|
+
interface BaseWallet {
|
|
36
|
+
/** Unique identifier of the wallet */
|
|
37
|
+
walletType: WalletType;
|
|
38
|
+
/** Wallet's public address */
|
|
39
|
+
address: string | `0x${string}`;
|
|
40
|
+
/** Connected chain ID */
|
|
41
|
+
chainId: string | number;
|
|
42
|
+
/** RPC endpoint URL */
|
|
43
|
+
rpcURL: string;
|
|
44
|
+
/** Indicates if the address is a smart contract */
|
|
45
|
+
isContractAddress: boolean;
|
|
46
|
+
/** Connection status */
|
|
47
|
+
isConnected: boolean;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Extended wallet interface for Solana-specific properties
|
|
51
|
+
*/
|
|
52
|
+
interface SolanaWallet extends BaseWallet {
|
|
53
|
+
/** Connected Wallet Standard account */
|
|
54
|
+
connectedAccount?: UiWalletAccount;
|
|
55
|
+
/** Connected Wallet Standard wallet instance */
|
|
56
|
+
connectedWallet?: UiWallet;
|
|
57
|
+
}
|
|
58
|
+
/** Union type for all supported wallet types */
|
|
59
|
+
type Wallet = BaseWallet | SolanaWallet;
|
|
60
|
+
/** EVM-specific connector type */
|
|
61
|
+
type ConnectorEVM = Connector$1<CreateConnectorFn>;
|
|
62
|
+
/** Solana-specific connector type */
|
|
63
|
+
type ConnectorSolana = UiWallet;
|
|
64
|
+
/** Union type for all supported connector types */
|
|
65
|
+
type Connector = ConnectorEVM | ConnectorSolana;
|
|
66
|
+
/**
|
|
67
|
+
* Interface for blockchain network adapters
|
|
68
|
+
* @remarks
|
|
69
|
+
* Adapters provide chain-specific implementation for wallet interactions
|
|
70
|
+
*/
|
|
71
|
+
type SatelliteAdapter = {
|
|
72
|
+
/** Unique identifier for the adapter */
|
|
73
|
+
key: OrbitAdapter;
|
|
74
|
+
/**
|
|
75
|
+
* Initiates wallet connection
|
|
76
|
+
* @returns Promise resolving to connected wallet instance
|
|
77
|
+
*/
|
|
78
|
+
connect: ({ walletType, chainId, connectors, }: {
|
|
79
|
+
walletType: WalletType;
|
|
80
|
+
chainId: number | string;
|
|
81
|
+
connectors: Connector[];
|
|
82
|
+
}) => Promise<Wallet>;
|
|
83
|
+
/** Disconnects current wallet session */
|
|
84
|
+
disconnect: () => Promise<void>;
|
|
85
|
+
/** Retrieves available wallet connectors for this adapter */
|
|
86
|
+
getConnectors: () => Promise<{
|
|
87
|
+
adapter: OrbitAdapter;
|
|
88
|
+
connectors: Connector[];
|
|
89
|
+
}>;
|
|
90
|
+
/**
|
|
91
|
+
* Handles network switching for connected wallet
|
|
92
|
+
* @param chainId - Target chain ID
|
|
93
|
+
* @param currentChainId - Current chain ID
|
|
94
|
+
* @param updateActiveWallet - Callback to update wallet state
|
|
95
|
+
*/
|
|
96
|
+
checkAndSwitchNetwork: (chainId: string | number, currentChainId?: string | number, updateActiveWallet?: (wallet: Partial<Wallet>) => void) => Promise<void>;
|
|
97
|
+
/**
|
|
98
|
+
* Generates blockchain explorer URL
|
|
99
|
+
* @returns Explorer URL or undefined if not available
|
|
100
|
+
*/
|
|
101
|
+
getExplorerUrl: (url?: string, chainId?: string | number) => string | undefined;
|
|
102
|
+
/** Optional method to resolve ENS-like names */
|
|
103
|
+
getName?: (address: string) => Promise<string | null>;
|
|
104
|
+
/** Optional method to get avatar for resolved names */
|
|
105
|
+
getAvatar?: (name: string) => Promise<string | null>;
|
|
106
|
+
/** Optional method to check if address is a smart contract */
|
|
107
|
+
checkIsContractWallet?: ({ address, chainId }: {
|
|
108
|
+
address: string;
|
|
109
|
+
chainId: string | number;
|
|
110
|
+
}) => Promise<boolean>;
|
|
111
|
+
};
|
|
112
|
+
/**
|
|
113
|
+
* Store interface for managing wallet connections
|
|
114
|
+
*/
|
|
115
|
+
type ISatelliteConnectStore = {
|
|
116
|
+
/** Returns configured adapter(s) */
|
|
117
|
+
getAdapter: () => SatelliteAdapter | SatelliteAdapter[];
|
|
118
|
+
/** Information about last connected wallet */
|
|
119
|
+
lastConnectedWallet?: {
|
|
120
|
+
walletType: WalletType;
|
|
121
|
+
chainId: number | string;
|
|
122
|
+
};
|
|
123
|
+
/** Available connectors mapped by adapter type */
|
|
124
|
+
availableConnectors: Partial<Record<OrbitAdapter, Connector[]>>;
|
|
125
|
+
/** Initializes wallet connectors */
|
|
126
|
+
initializeAppConnectors: ({ autoConnect }: {
|
|
127
|
+
autoConnect?: boolean;
|
|
128
|
+
}) => Promise<void>;
|
|
129
|
+
/** Connects to specified wallet */
|
|
130
|
+
connect: ({ walletType, chainId }: {
|
|
131
|
+
walletType: WalletType;
|
|
132
|
+
chainId: number | string;
|
|
133
|
+
}) => Promise<void>;
|
|
134
|
+
/** Disconnects active wallet */
|
|
135
|
+
disconnect: () => Promise<void>;
|
|
136
|
+
/** Indicates ongoing connection attempt */
|
|
137
|
+
walletConnecting: boolean;
|
|
138
|
+
/** Contains error message if connection failed */
|
|
139
|
+
walletConnectionError?: string;
|
|
140
|
+
/** Currently connected wallet */
|
|
141
|
+
activeWallet?: Wallet;
|
|
142
|
+
/** Clears connection error state */
|
|
143
|
+
resetWalletConnectionError: () => void;
|
|
144
|
+
/** Updates active wallet properties */
|
|
145
|
+
updateActiveWallet: (wallet: Partial<Wallet>) => void;
|
|
146
|
+
/** Switches network for connected wallet */
|
|
147
|
+
switchNetwork: (chainId: string | number) => Promise<void>;
|
|
148
|
+
/** Contains error message if network switch failed */
|
|
149
|
+
switchNetworkError?: string;
|
|
150
|
+
/** Clears network switch error state */
|
|
151
|
+
resetSwitchNetworkError: () => void;
|
|
152
|
+
};
|
|
153
|
+
/**
|
|
154
|
+
* Callback type for successful wallet connections
|
|
155
|
+
*/
|
|
156
|
+
type WalletConnectedCallback = (wallet: Wallet) => void | Promise<void>;
|
|
157
|
+
/**
|
|
158
|
+
* Configuration parameters for initializing Satellite Connect store
|
|
159
|
+
*/
|
|
160
|
+
type SatelliteConnectStoreInitialParameters = OrbitGenericAdapter<SatelliteAdapter> & {
|
|
161
|
+
/** Optional callback executed after successful wallet connection */
|
|
162
|
+
callbackAfterConnected?: WalletConnectedCallback;
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Creates a Satellite Connect store instance for managing wallet connections and state
|
|
167
|
+
*
|
|
168
|
+
* @param params - Configuration parameters for the store
|
|
169
|
+
* @param params.adapter - Single adapter or array of adapters for different chains
|
|
170
|
+
* @param params.callbackAfterConnected - Optional callback function called after successful wallet connection
|
|
171
|
+
*
|
|
172
|
+
* @returns A Zustand store instance with wallet connection state and methods
|
|
173
|
+
*/
|
|
174
|
+
declare function createSatelliteConnectStore({ adapter, callbackAfterConnected, }: SatelliteConnectStoreInitialParameters): zustand.StoreApi<ISatelliteConnectStore>;
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Extracts the adapter type from a wallet type string
|
|
178
|
+
*
|
|
179
|
+
* @example
|
|
180
|
+
* ```typescript
|
|
181
|
+
* // Returns OrbitAdapter.EVM
|
|
182
|
+
* getAdapterFromWalletType('evm:metamask');
|
|
183
|
+
*
|
|
184
|
+
* // Returns OrbitAdapter.SOLANA
|
|
185
|
+
* getAdapterFromWalletType('solana:phantom');
|
|
186
|
+
*
|
|
187
|
+
* // Returns OrbitAdapter.EVM (default)
|
|
188
|
+
* getAdapterFromWalletType('unknown');
|
|
189
|
+
* ```
|
|
190
|
+
*
|
|
191
|
+
* @param walletType - Wallet type in format "chain:wallet" (e.g. "evm:metamask", "solana:phantom")
|
|
192
|
+
* @returns The corresponding {@link OrbitAdapter} type or EVM as default
|
|
193
|
+
*
|
|
194
|
+
* @remarks
|
|
195
|
+
* The function splits the wallet type string by ":" and takes the first part as the adapter type.
|
|
196
|
+
* If the split fails or the first part is empty, it defaults to EVM adapter.
|
|
197
|
+
*/
|
|
198
|
+
declare function getAdapterFromWalletType(walletType: WalletType): OrbitAdapter;
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Generates a standardized wallet type identifier from adapter type and connector name
|
|
202
|
+
*
|
|
203
|
+
* @example
|
|
204
|
+
* ```typescript
|
|
205
|
+
* // Returns "evm:metamask"
|
|
206
|
+
* getWalletTypeFromConnectorName(OrbitAdapter.EVM, "MetaMask");
|
|
207
|
+
*
|
|
208
|
+
* // Returns "solana:phantom"
|
|
209
|
+
* getWalletTypeFromConnectorName(OrbitAdapter.SOLANA, "Phantom");
|
|
210
|
+
*
|
|
211
|
+
* // Returns "evm:coinbasewallet" (removes spaces)
|
|
212
|
+
* getWalletTypeFromConnectorName(OrbitAdapter.EVM, "Coinbase Wallet");
|
|
213
|
+
* ```
|
|
214
|
+
*
|
|
215
|
+
* @param adapter - The blockchain adapter type (e.g. EVM, SOLANA)
|
|
216
|
+
* @param name - The wallet connector name (e.g. "MetaMask", "Phantom")
|
|
217
|
+
* @returns A formatted wallet type string in format "chain:wallet"
|
|
218
|
+
*
|
|
219
|
+
* @remarks
|
|
220
|
+
* The function:
|
|
221
|
+
* 1. Combines adapter type with connector name using ":" as separator
|
|
222
|
+
* 2. Removes all whitespace from connector name
|
|
223
|
+
* 3. Converts connector name to lowercase
|
|
224
|
+
* This ensures consistent wallet type identifiers across the application
|
|
225
|
+
*/
|
|
226
|
+
declare function getWalletTypeFromConnectorName(adapter: OrbitAdapter, name: string): string;
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Helper utilities for managing impersonated wallet addresses
|
|
230
|
+
*
|
|
231
|
+
* @remarks
|
|
232
|
+
* These utilities are primarily used for development and testing purposes.
|
|
233
|
+
* They provide a way to simulate different wallet addresses without actually connecting a wallet.
|
|
234
|
+
* All data is stored in localStorage with the 'satellite-connect:impersonatedAddress' key.
|
|
235
|
+
* Functions are safe to use in both browser and SSR environments.
|
|
236
|
+
*/
|
|
237
|
+
declare const impersonatedHelpers: {
|
|
238
|
+
/**
|
|
239
|
+
* Currently impersonated address from localStorage
|
|
240
|
+
* Returns empty string if not set or in SSR context
|
|
241
|
+
*/
|
|
242
|
+
impersonatedAddress: string;
|
|
243
|
+
/**
|
|
244
|
+
* Stores an impersonated address in localStorage
|
|
245
|
+
*
|
|
246
|
+
* @example
|
|
247
|
+
* ```typescript
|
|
248
|
+
* // Set impersonated address
|
|
249
|
+
* impersonatedHelpers.setImpersonated('0x1234...5678');
|
|
250
|
+
* ```
|
|
251
|
+
*
|
|
252
|
+
* @param address - Ethereum or Solana address to impersonate
|
|
253
|
+
* @returns undefined in SSR context, void in browser
|
|
254
|
+
*/
|
|
255
|
+
setImpersonated: (address: string) => void;
|
|
256
|
+
/**
|
|
257
|
+
* Retrieves the current impersonated address from localStorage
|
|
258
|
+
*
|
|
259
|
+
* @example
|
|
260
|
+
* ```typescript
|
|
261
|
+
* // Get current impersonated address
|
|
262
|
+
* const address = impersonatedHelpers.getImpersonated();
|
|
263
|
+
* if (address) {
|
|
264
|
+
* console.log('Currently impersonating:', address);
|
|
265
|
+
* }
|
|
266
|
+
* ```
|
|
267
|
+
* @returns The impersonated address or undefined if not set or in SSR context
|
|
268
|
+
*/
|
|
269
|
+
getImpersonated: () => string | null | undefined;
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
export { type BaseWallet, type Connector, type ConnectorEVM, type ConnectorSolana, type ConnectorsInitProps, type ISatelliteConnectStore, type SatelliteAdapter, type SatelliteConnectStoreInitialParameters, type SolanaWallet, type Wallet, type WalletConnectedCallback, type WalletType, createSatelliteConnectStore, getAdapterFromWalletType, getWalletTypeFromConnectorName, impersonatedHelpers };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';var orbitCore=require('@tuwaio/orbit-core'),immer=require('immer'),vanilla=require('zustand/vanilla');function l(r){return r.split(":")[0]??orbitCore.OrbitAdapter.EVM}function S({adapter:r,callbackAfterConnected:c}){return vanilla.createStore()((a,i)=>({getAdapter:()=>r,availableConnectors:{},initializeAppConnectors:async({autoConnect:t})=>{if(Array.isArray(r))(await Promise.all(r.map(o=>o.getConnectors()))).forEach(o=>{a(e=>immer.produce(e,p=>{p.availableConnectors[o.adapter]=o.connectors;}));});else {let n=await r.getConnectors();a(o=>immer.produce(o,e=>{e.availableConnectors[n.adapter]=n.connectors;}));}if(t){let n=i().lastConnectedWallet;n&&await i().connect({walletType:n.walletType,chainId:n.chainId});}},connect:async({walletType:t,chainId:n})=>{a({walletConnecting:true,walletConnectionError:void 0});let o=orbitCore.selectAdapterByKey({adapter:r,adapterKey:l(t)});try{let e=await o?.connect({walletType:t,chainId:n,connectors:i().availableConnectors[l(t)]??[]});a({activeWallet:e}),o?.checkIsContractWallet&&e&&(i().updateActiveWallet({isContractAddress:await o.checkIsContractWallet({address:e.address,chainId:n})}),c&&await c(e)),a({walletConnecting:!1,lastConnectedWallet:{walletType:t,chainId:n}});}catch(e){a({walletConnecting:false,walletConnectionError:"Wallet connection failed: "+(e instanceof Error?e.message:String(e))});}},disconnect:async()=>{let t=i().activeWallet;t&&(await orbitCore.selectAdapterByKey({adapter:r,adapterKey:l(t.walletType)})?.disconnect(),a({activeWallet:void 0,lastConnectedWallet:void 0}));},walletConnecting:false,resetWalletConnectionError:()=>{a({walletConnectionError:void 0});},updateActiveWallet:t=>{i().activeWallet?a(o=>immer.produce(o,e=>{e.activeWallet&&(e.activeWallet={...e.activeWallet,...t});})):t.walletType!==void 0&&t.chainId!==void 0&&t.address!==void 0&&a({activeWallet:t});},switchNetwork:async t=>{a({switchNetworkError:void 0});let n=i().activeWallet;if(n){let o=orbitCore.selectAdapterByKey({adapter:r,adapterKey:l(n.walletType)});try{await o?.checkAndSwitchNetwork(t,n.chainId,i().updateActiveWallet);}catch(e){a({switchNetworkError:"Switch network failed: "+(e instanceof Error?e.message:String(e))});}}},resetSwitchNetworkError:()=>a({switchNetworkError:void 0})}))}function h(r,c){return `${r}:${c.replace(/\s+/g,"").toLowerCase()}`}var E={impersonatedAddress:typeof window<"u"?window.localStorage.getItem("satellite-connect:impersonatedAddress")??"":"",setImpersonated:r=>typeof window<"u"?window.localStorage.setItem("satellite-connect:impersonatedAddress",r):void 0,getImpersonated:()=>typeof window<"u"?window.localStorage.getItem("satellite-connect:impersonatedAddress"):void 0};exports.createSatelliteConnectStore=S;exports.getAdapterFromWalletType=l;exports.getWalletTypeFromConnectorName=h;exports.impersonatedHelpers=E;//# sourceMappingURL=index.js.map
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/getAdapterFromWalletType.ts","../src/store/satelliteConnectStore.ts","../src/utils/getWalletTypeFromConnectorName.ts","../src/utils/impersonatedHelpers.ts"],"names":["getAdapterFromWalletType","walletType","OrbitAdapter","createSatelliteConnectStore","adapter","callbackAfterConnected","createStore","set","get","autoConnect","a","connectors","state","produce","draft","lastConnectedWallet","chainId","foundAdapter","selectAdapterByKey","wallet","activeWallet","getWalletTypeFromConnectorName","name","impersonatedHelpers","address"],"mappings":"mHA0BO,SAASA,CAAAA,CAAyBC,CAAAA,CAAsC,CAC7E,OAAQA,CAAAA,CAAW,KAAA,CAAM,GAAG,CAAA,CAAE,CAAC,CAAA,EAAKC,sBAAAA,CAAa,GACnD,CCZO,SAASC,CAAAA,CAA4B,CAC1C,OAAA,CAAAC,CAAAA,CACA,sBAAA,CAAAC,CACF,CAAA,CAA2C,CACzC,OAAOC,mBAAAA,EAAoC,CAAE,CAACC,EAAKC,CAAAA,IAAS,CAI1D,UAAA,CAAY,IAAMJ,CAAAA,CAKlB,mBAAA,CAAqB,EAAC,CAMtB,uBAAA,CAAyB,MAAO,CAAE,WAAA,CAAAK,CAAY,CAAA,GAAM,CAClD,GAAI,KAAA,CAAM,OAAA,CAAQL,CAAO,CAAA,CAAA,CACJ,MAAM,OAAA,CAAQ,GAAA,CAAIA,CAAAA,CAAQ,GAAA,CAAKM,CAAAA,EAAMA,CAAAA,CAAE,aAAA,EAAe,CAAC,CAAA,EAC/D,OAAA,CAASC,CAAAA,EAAe,CACjCJ,CAAAA,CAAKK,CAAAA,EACHC,aAAAA,CAAQD,CAAAA,CAAQE,CAAAA,EAAU,CACxBA,CAAAA,CAAM,mBAAA,CAAoBH,CAAAA,CAAW,OAAO,EAAIA,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AkBC,CAAAA,EAChB,OAAO,MAAA,CAAW,GAAA,CACd,MAAA,CAAO,YAAA,CAAa,OAAA,CAAQ,uCAAA,CAAyCA,CAAO,CAAA,CAC5E,MAAA,CAeN,eAAA,CAAiB,IACf,OAAO,MAAA,CAAW,GAAA,CAAc,MAAA,CAAO,YAAA,CAAa,OAAA,CAAQ,uCAAuC,CAAA,CAAI,MAC3G","file":"index.js","sourcesContent":["import { OrbitAdapter } from '@tuwaio/orbit-core';\n\nimport { WalletType } from '../types';\n\n/**\n * Extracts the adapter type from a wallet type string\n *\n * @example\n * ```typescript\n * // Returns OrbitAdapter.EVM\n * getAdapterFromWalletType('evm:metamask');\n *\n * // Returns OrbitAdapter.SOLANA\n * getAdapterFromWalletType('solana:phantom');\n *\n * // Returns OrbitAdapter.EVM (default)\n * getAdapterFromWalletType('unknown');\n * ```\n *\n * @param walletType - Wallet type in format \"chain:wallet\" (e.g. \"evm:metamask\", \"solana:phantom\")\n * @returns The corresponding {@link OrbitAdapter} type or EVM as default\n *\n * @remarks\n * The function splits the wallet type string by \":\" and takes the first part as the adapter type.\n * If the split fails or the first part is empty, it defaults to EVM adapter.\n */\nexport function getAdapterFromWalletType(walletType: WalletType): OrbitAdapter {\n return (walletType.split(':')[0] ?? OrbitAdapter.EVM) as OrbitAdapter;\n}\n","import { selectAdapterByKey } from '@tuwaio/orbit-core';\nimport { Draft, produce } from 'immer';\nimport { createStore } from 'zustand/vanilla';\n\nimport { Connector, ISatelliteConnectStore, SatelliteConnectStoreInitialParameters, Wallet } from '../types';\nimport { getAdapterFromWalletType } from '../utils/getAdapterFromWalletType';\n\n/**\n * Creates a Satellite Connect store instance for managing wallet connections and state\n *\n * @param params - Configuration parameters for the store\n * @param params.adapter - Single adapter or array of adapters for different chains\n * @param params.callbackAfterConnected - Optional callback function called after successful wallet connection\n *\n * @returns A Zustand store instance with wallet connection state and methods\n */\nexport function createSatelliteConnectStore({\n adapter,\n callbackAfterConnected,\n}: SatelliteConnectStoreInitialParameters) {\n return createStore<ISatelliteConnectStore>()((set, get) => ({\n /**\n * Returns configured adapter(s)\n */\n getAdapter: () => adapter,\n\n /**\n * Available wallet connectors for each chain\n */\n availableConnectors: {},\n\n /**\n * Initializes wallet connectors for all configured adapters\n * @param autoConnect - Whether to automatically reconnect to last used wallet\n */\n initializeAppConnectors: async ({ autoConnect }) => {\n if (Array.isArray(adapter)) {\n const connectors = await Promise.all(adapter.map((a) => a.getConnectors()));\n connectors.forEach((connectors) => {\n set((state) =>\n produce(state, (draft) => {\n draft.availableConnectors[connectors.adapter] = connectors.connectors as Draft<Connector[]>;\n }),\n );\n });\n } else {\n const connectors = await adapter.getConnectors();\n set((state) =>\n produce(state, (draft) => {\n draft.availableConnectors[connectors.adapter] = connectors.connectors as Draft<Connector[]>;\n }),\n );\n }\n if (autoConnect) {\n const lastConnectedWallet = get().lastConnectedWallet;\n if (lastConnectedWallet) {\n await get().connect({ walletType: lastConnectedWallet.walletType, chainId: lastConnectedWallet.chainId });\n }\n }\n },\n\n /**\n * Connects to a wallet\n * @param walletType - Type of wallet to connect to\n * @param chainId - Chain ID to connect on\n */\n connect: async ({ walletType, chainId }) => {\n set({ walletConnecting: true, walletConnectionError: undefined });\n const foundAdapter = selectAdapterByKey({ adapter, adapterKey: getAdapterFromWalletType(walletType) });\n try {\n const wallet = await foundAdapter?.connect({\n walletType,\n chainId,\n connectors: get().availableConnectors[getAdapterFromWalletType(walletType)] ?? [],\n });\n set({ activeWallet: wallet });\n if (foundAdapter?.checkIsContractWallet && wallet) {\n get().updateActiveWallet({\n isContractAddress: await foundAdapter.checkIsContractWallet({\n address: wallet.address,\n chainId,\n }),\n });\n if (callbackAfterConnected) {\n await callbackAfterConnected(wallet);\n }\n }\n set({ walletConnecting: false, lastConnectedWallet: { walletType, chainId } });\n } catch (e) {\n set({\n walletConnecting: false,\n walletConnectionError: 'Wallet connection failed: ' + (e instanceof Error ? e.message : String(e)),\n });\n }\n },\n\n /**\n * Disconnects the currently active wallet\n */\n disconnect: async () => {\n const activeWallet = get().activeWallet;\n if (activeWallet) {\n const foundAdapter = selectAdapterByKey({\n adapter,\n adapterKey: getAdapterFromWalletType(activeWallet.walletType),\n });\n await foundAdapter?.disconnect();\n set({ activeWallet: undefined, lastConnectedWallet: undefined });\n }\n },\n\n walletConnecting: false,\n\n /**\n * Resets any wallet connection errors\n */\n resetWalletConnectionError: () => {\n set({ walletConnectionError: undefined });\n },\n\n /**\n * Updates the active wallet's properties\n * @param wallet - Partial wallet object with properties to update\n */\n updateActiveWallet: (wallet: Partial<Wallet>) => {\n const activeWallet = get().activeWallet;\n if (activeWallet) {\n set((state) =>\n produce(state, (draft) => {\n if (draft.activeWallet) {\n draft.activeWallet = {\n ...draft.activeWallet,\n ...wallet,\n };\n }\n }),\n );\n } else {\n if (wallet.walletType !== undefined && wallet.chainId !== undefined && wallet.address !== undefined) {\n set({ activeWallet: wallet as Wallet });\n }\n }\n },\n\n /**\n * Switches the connected wallet to a different network\n * @param chainId - Target chain ID to switch to\n */\n switchNetwork: async (chainId: string | number) => {\n set({ switchNetworkError: undefined });\n const activeWallet = get().activeWallet;\n if (activeWallet) {\n const foundAdapter = selectAdapterByKey({\n adapter,\n adapterKey: getAdapterFromWalletType(activeWallet.walletType),\n });\n try {\n await foundAdapter?.checkAndSwitchNetwork(chainId, activeWallet.chainId, get().updateActiveWallet);\n } catch (e) {\n set({ switchNetworkError: 'Switch network failed: ' + (e instanceof Error ? e.message : String(e)) });\n }\n }\n },\n\n /**\n * Resets any network switching errors\n */\n resetSwitchNetworkError: () => set({ switchNetworkError: undefined }),\n }));\n}\n","import { OrbitAdapter } from '@tuwaio/orbit-core';\n\n/**\n * Generates a standardized wallet type identifier from adapter type and connector name\n *\n * @example\n * ```typescript\n * // Returns \"evm:metamask\"\n * getWalletTypeFromConnectorName(OrbitAdapter.EVM, \"MetaMask\");\n *\n * // Returns \"solana:phantom\"\n * getWalletTypeFromConnectorName(OrbitAdapter.SOLANA, \"Phantom\");\n *\n * // Returns \"evm:coinbasewallet\" (removes spaces)\n * getWalletTypeFromConnectorName(OrbitAdapter.EVM, \"Coinbase Wallet\");\n * ```\n *\n * @param adapter - The blockchain adapter type (e.g. EVM, SOLANA)\n * @param name - The wallet connector name (e.g. \"MetaMask\", \"Phantom\")\n * @returns A formatted wallet type string in format \"chain:wallet\"\n *\n * @remarks\n * The function:\n * 1. Combines adapter type with connector name using \":\" as separator\n * 2. Removes all whitespace from connector name\n * 3. Converts connector name to lowercase\n * This ensures consistent wallet type identifiers across the application\n */\nexport function getWalletTypeFromConnectorName(adapter: OrbitAdapter, name: string): string {\n return `${adapter}:${name.replace(/\\s+/g, '').toLowerCase()}`;\n}\n","/**\n * Helper utilities for managing impersonated wallet addresses\n *\n * @remarks\n * These utilities are primarily used for development and testing purposes.\n * They provide a way to simulate different wallet addresses without actually connecting a wallet.\n * All data is stored in localStorage with the 'satellite-connect:impersonatedAddress' key.\n * Functions are safe to use in both browser and SSR environments.\n */\nexport const impersonatedHelpers = {\n /**\n * Currently impersonated address from localStorage\n * Returns empty string if not set or in SSR context\n */\n impersonatedAddress:\n typeof window !== 'undefined' ? (window.localStorage.getItem('satellite-connect:impersonatedAddress') ?? '') : '',\n\n /**\n * Stores an impersonated address in localStorage\n *\n * @example\n * ```typescript\n * // Set impersonated address\n * impersonatedHelpers.setImpersonated('0x1234...5678');\n * ```\n *\n * @param address - Ethereum or Solana address to impersonate\n * @returns undefined in SSR context, void in browser\n */\n setImpersonated: (address: string) =>\n typeof window !== 'undefined'\n ? window.localStorage.setItem('satellite-connect:impersonatedAddress', address)\n : undefined,\n\n /**\n * Retrieves the current impersonated address from localStorage\n *\n * @example\n * ```typescript\n * // Get current impersonated address\n * const address = impersonatedHelpers.getImpersonated();\n * if (address) {\n * console.log('Currently impersonating:', address);\n * }\n * ```\n * @returns The impersonated address or undefined if not set or in SSR context\n */\n getImpersonated: () =>\n typeof window !== 'undefined' ? window.localStorage.getItem('satellite-connect:impersonatedAddress') : undefined,\n};\n"]}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {OrbitAdapter,selectAdapterByKey}from'@tuwaio/orbit-core';import {produce}from'immer';import {createStore}from'zustand/vanilla';function l(r){return r.split(":")[0]??OrbitAdapter.EVM}function S({adapter:r,callbackAfterConnected:c}){return createStore()((a,i)=>({getAdapter:()=>r,availableConnectors:{},initializeAppConnectors:async({autoConnect:t})=>{if(Array.isArray(r))(await Promise.all(r.map(o=>o.getConnectors()))).forEach(o=>{a(e=>produce(e,p=>{p.availableConnectors[o.adapter]=o.connectors;}));});else {let n=await r.getConnectors();a(o=>produce(o,e=>{e.availableConnectors[n.adapter]=n.connectors;}));}if(t){let n=i().lastConnectedWallet;n&&await i().connect({walletType:n.walletType,chainId:n.chainId});}},connect:async({walletType:t,chainId:n})=>{a({walletConnecting:true,walletConnectionError:void 0});let o=selectAdapterByKey({adapter:r,adapterKey:l(t)});try{let e=await o?.connect({walletType:t,chainId:n,connectors:i().availableConnectors[l(t)]??[]});a({activeWallet:e}),o?.checkIsContractWallet&&e&&(i().updateActiveWallet({isContractAddress:await o.checkIsContractWallet({address:e.address,chainId:n})}),c&&await c(e)),a({walletConnecting:!1,lastConnectedWallet:{walletType:t,chainId:n}});}catch(e){a({walletConnecting:false,walletConnectionError:"Wallet connection failed: "+(e instanceof Error?e.message:String(e))});}},disconnect:async()=>{let t=i().activeWallet;t&&(await selectAdapterByKey({adapter:r,adapterKey:l(t.walletType)})?.disconnect(),a({activeWallet:void 0,lastConnectedWallet:void 0}));},walletConnecting:false,resetWalletConnectionError:()=>{a({walletConnectionError:void 0});},updateActiveWallet:t=>{i().activeWallet?a(o=>produce(o,e=>{e.activeWallet&&(e.activeWallet={...e.activeWallet,...t});})):t.walletType!==void 0&&t.chainId!==void 0&&t.address!==void 0&&a({activeWallet:t});},switchNetwork:async t=>{a({switchNetworkError:void 0});let n=i().activeWallet;if(n){let o=selectAdapterByKey({adapter:r,adapterKey:l(n.walletType)});try{await o?.checkAndSwitchNetwork(t,n.chainId,i().updateActiveWallet);}catch(e){a({switchNetworkError:"Switch network failed: "+(e instanceof Error?e.message:String(e))});}}},resetSwitchNetworkError:()=>a({switchNetworkError:void 0})}))}function h(r,c){return `${r}:${c.replace(/\s+/g,"").toLowerCase()}`}var E={impersonatedAddress:typeof window<"u"?window.localStorage.getItem("satellite-connect:impersonatedAddress")??"":"",setImpersonated:r=>typeof window<"u"?window.localStorage.setItem("satellite-connect:impersonatedAddress",r):void 0,getImpersonated:()=>typeof window<"u"?window.localStorage.getItem("satellite-connect:impersonatedAddress"):void 0};export{S as createSatelliteConnectStore,l as getAdapterFromWalletType,h as getWalletTypeFromConnectorName,E as impersonatedHelpers};//# sourceMappingURL=index.mjs.map
|
|
2
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/getAdapterFromWalletType.ts","../src/store/satelliteConnectStore.ts","../src/utils/getWalletTypeFromConnectorName.ts","../src/utils/impersonatedHelpers.ts"],"names":["getAdapterFromWalletType","walletType","OrbitAdapter","createSatelliteConnectStore","adapter","callbackAfterConnected","createStore","set","get","autoConnect","a","connectors","state","produce","draft","lastConnectedWallet","chainId","foundAdapter","selectAdapterByKey","wallet","activeWallet","getWalletTypeFromConnectorName","name","impersonatedHelpers","address"],"mappings":"uIA0BO,SAASA,CAAAA,CAAyBC,CAAAA,CAAsC,CAC7E,OAAQA,CAAAA,CAAW,KAAA,CAAM,GAAG,CAAA,CAAE,CAAC,CAAA,EAAKC,YAAAA,CAAa,GACnD,CCZO,SAASC,CAAAA,CAA4B,CAC1C,OAAA,CAAAC,CAAAA,CACA,sBAAA,CAAAC,CACF,CAAA,CAA2C,CACzC,OAAOC,WAAAA,EAAoC,CAAE,CAACC,EAAKC,CAAAA,IAAS,CAI1D,UAAA,CAAY,IAAMJ,CAAAA,CAKlB,mBAAA,CAAqB,EAAC,CAMtB,uBAAA,CAAyB,MAAO,CAAE,WAA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CAAA,CAAE,CACJ,CC7IO,SAASc,CAAAA,CAA+BjB,CAAAA,CAAuBkB,CAAAA,CAAsB,CAC1F,OAAO,CAAA,EAAGlB,CAAO,CAAA,CAAA,EAAIkB,CAAAA,CAAK,OAAA,CAAQ,OAAQ,EAAE,CAAA,CAAE,WAAA,EAAa,CAAA,CAC7D,CCrBO,IAAMC,CAAAA,CAAsB,CAKjC,mBAAA,CACE,OAAO,MAAA,CAAW,GAAA,CAAe,MAAA,CAAO,aAAa,OAAA,CAAQ,uCAAuC,CAAA,EAAK,EAAA,CAAM,EAAA,CAcjH,eAAA,CAAkBC,CAAAA,EAChB,OAAO,MAAA,CAAW,GAAA,CACd,MAAA,CAAO,YAAA,CAAa,OAAA,CAAQ,uCAAA,CAAyCA,CAAO,CAAA,CAC5E,MAAA,CAeN,eAAA,CAAiB,IACf,OAAO,MAAA,CAAW,GAAA,CAAc,MAAA,CAAO,YAAA,CAAa,OAAA,CAAQ,uCAAuC,CAAA,CAAI,MAC3G","file":"index.mjs","sourcesContent":["import { OrbitAdapter } from '@tuwaio/orbit-core';\n\nimport { WalletType } from '../types';\n\n/**\n * Extracts the adapter type from a wallet type string\n *\n * @example\n * ```typescript\n * // Returns OrbitAdapter.EVM\n * getAdapterFromWalletType('evm:metamask');\n *\n * // Returns OrbitAdapter.SOLANA\n * getAdapterFromWalletType('solana:phantom');\n *\n * // Returns OrbitAdapter.EVM (default)\n * getAdapterFromWalletType('unknown');\n * ```\n *\n * @param walletType - Wallet type in format \"chain:wallet\" (e.g. \"evm:metamask\", \"solana:phantom\")\n * @returns The corresponding {@link OrbitAdapter} type or EVM as default\n *\n * @remarks\n * The function splits the wallet type string by \":\" and takes the first part as the adapter type.\n * If the split fails or the first part is empty, it defaults to EVM adapter.\n */\nexport function getAdapterFromWalletType(walletType: WalletType): OrbitAdapter {\n return (walletType.split(':')[0] ?? OrbitAdapter.EVM) as OrbitAdapter;\n}\n","import { selectAdapterByKey } from '@tuwaio/orbit-core';\nimport { Draft, produce } from 'immer';\nimport { createStore } from 'zustand/vanilla';\n\nimport { Connector, ISatelliteConnectStore, SatelliteConnectStoreInitialParameters, Wallet } from '../types';\nimport { getAdapterFromWalletType } from '../utils/getAdapterFromWalletType';\n\n/**\n * Creates a Satellite Connect store instance for managing wallet connections and state\n *\n * @param params - Configuration parameters for the store\n * @param params.adapter - Single adapter or array of adapters for different chains\n * @param params.callbackAfterConnected - Optional callback function called after successful wallet connection\n *\n * @returns A Zustand store instance with wallet connection state and methods\n */\nexport function createSatelliteConnectStore({\n adapter,\n callbackAfterConnected,\n}: SatelliteConnectStoreInitialParameters) {\n return createStore<ISatelliteConnectStore>()((set, get) => ({\n /**\n * Returns configured adapter(s)\n */\n getAdapter: () => adapter,\n\n /**\n * Available wallet connectors for each chain\n */\n availableConnectors: {},\n\n /**\n * Initializes wallet connectors for all configured adapters\n * @param autoConnect - Whether to automatically reconnect to last used wallet\n */\n initializeAppConnectors: async ({ autoConnect }) => {\n if (Array.isArray(adapter)) {\n const connectors = await Promise.all(adapter.map((a) => a.getConnectors()));\n connectors.forEach((connectors) => {\n set((state) =>\n produce(state, (draft) => {\n draft.availableConnectors[connectors.adapter] = connectors.connectors as Draft<Connector[]>;\n }),\n );\n });\n } else {\n const connectors = await adapter.getConnectors();\n set((state) =>\n produce(state, (draft) => {\n draft.availableConnectors[connectors.adapter] = connectors.connectors as Draft<Connector[]>;\n }),\n );\n }\n if (autoConnect) {\n const lastConnectedWallet = get().lastConnectedWallet;\n if (lastConnectedWallet) {\n await get().connect({ walletType: lastConnectedWallet.walletType, chainId: lastConnectedWallet.chainId });\n }\n }\n },\n\n /**\n * Connects to a wallet\n * @param walletType - Type of wallet to connect to\n * @param chainId - Chain ID to connect on\n */\n connect: async ({ walletType, chainId }) => {\n set({ walletConnecting: true, walletConnectionError: undefined });\n const foundAdapter = selectAdapterByKey({ adapter, adapterKey: getAdapterFromWalletType(walletType) });\n try {\n const wallet = await foundAdapter?.connect({\n walletType,\n chainId,\n connectors: get().availableConnectors[getAdapterFromWalletType(walletType)] ?? [],\n });\n set({ activeWallet: wallet });\n if (foundAdapter?.checkIsContractWallet && wallet) {\n get().updateActiveWallet({\n isContractAddress: await foundAdapter.checkIsContractWallet({\n address: wallet.address,\n chainId,\n }),\n });\n if (callbackAfterConnected) {\n await callbackAfterConnected(wallet);\n }\n }\n set({ walletConnecting: false, lastConnectedWallet: { walletType, chainId } });\n } catch (e) {\n set({\n walletConnecting: false,\n walletConnectionError: 'Wallet connection failed: ' + (e instanceof Error ? e.message : String(e)),\n });\n }\n },\n\n /**\n * Disconnects the currently active wallet\n */\n disconnect: async () => {\n const activeWallet = get().activeWallet;\n if (activeWallet) {\n const foundAdapter = selectAdapterByKey({\n adapter,\n adapterKey: getAdapterFromWalletType(activeWallet.walletType),\n });\n await foundAdapter?.disconnect();\n set({ activeWallet: undefined, lastConnectedWallet: undefined });\n }\n },\n\n walletConnecting: false,\n\n /**\n * Resets any wallet connection errors\n */\n resetWalletConnectionError: () => {\n set({ walletConnectionError: undefined });\n },\n\n /**\n * Updates the active wallet's properties\n * @param wallet - Partial wallet object with properties to update\n */\n updateActiveWallet: (wallet: Partial<Wallet>) => {\n const activeWallet = get().activeWallet;\n if (activeWallet) {\n set((state) =>\n produce(state, (draft) => {\n if (draft.activeWallet) {\n draft.activeWallet = {\n ...draft.activeWallet,\n ...wallet,\n };\n }\n }),\n );\n } else {\n if (wallet.walletType !== undefined && wallet.chainId !== undefined && wallet.address !== undefined) {\n set({ activeWallet: wallet as Wallet });\n }\n }\n },\n\n /**\n * Switches the connected wallet to a different network\n * @param chainId - Target chain ID to switch to\n */\n switchNetwork: async (chainId: string | number) => {\n set({ switchNetworkError: undefined });\n const activeWallet = get().activeWallet;\n if (activeWallet) {\n const foundAdapter = selectAdapterByKey({\n adapter,\n adapterKey: getAdapterFromWalletType(activeWallet.walletType),\n });\n try {\n await foundAdapter?.checkAndSwitchNetwork(chainId, activeWallet.chainId, get().updateActiveWallet);\n } catch (e) {\n set({ switchNetworkError: 'Switch network failed: ' + (e instanceof Error ? e.message : String(e)) });\n }\n }\n },\n\n /**\n * Resets any network switching errors\n */\n resetSwitchNetworkError: () => set({ switchNetworkError: undefined }),\n }));\n}\n","import { OrbitAdapter } from '@tuwaio/orbit-core';\n\n/**\n * Generates a standardized wallet type identifier from adapter type and connector name\n *\n * @example\n * ```typescript\n * // Returns \"evm:metamask\"\n * getWalletTypeFromConnectorName(OrbitAdapter.EVM, \"MetaMask\");\n *\n * // Returns \"solana:phantom\"\n * getWalletTypeFromConnectorName(OrbitAdapter.SOLANA, \"Phantom\");\n *\n * // Returns \"evm:coinbasewallet\" (removes spaces)\n * getWalletTypeFromConnectorName(OrbitAdapter.EVM, \"Coinbase Wallet\");\n * ```\n *\n * @param adapter - The blockchain adapter type (e.g. EVM, SOLANA)\n * @param name - The wallet connector name (e.g. \"MetaMask\", \"Phantom\")\n * @returns A formatted wallet type string in format \"chain:wallet\"\n *\n * @remarks\n * The function:\n * 1. Combines adapter type with connector name using \":\" as separator\n * 2. Removes all whitespace from connector name\n * 3. Converts connector name to lowercase\n * This ensures consistent wallet type identifiers across the application\n */\nexport function getWalletTypeFromConnectorName(adapter: OrbitAdapter, name: string): string {\n return `${adapter}:${name.replace(/\\s+/g, '').toLowerCase()}`;\n}\n","/**\n * Helper utilities for managing impersonated wallet addresses\n *\n * @remarks\n * These utilities are primarily used for development and testing purposes.\n * They provide a way to simulate different wallet addresses without actually connecting a wallet.\n * All data is stored in localStorage with the 'satellite-connect:impersonatedAddress' key.\n * Functions are safe to use in both browser and SSR environments.\n */\nexport const impersonatedHelpers = {\n /**\n * Currently impersonated address from localStorage\n * Returns empty string if not set or in SSR context\n */\n impersonatedAddress:\n typeof window !== 'undefined' ? (window.localStorage.getItem('satellite-connect:impersonatedAddress') ?? '') : '',\n\n /**\n * Stores an impersonated address in localStorage\n *\n * @example\n * ```typescript\n * // Set impersonated address\n * impersonatedHelpers.setImpersonated('0x1234...5678');\n * ```\n *\n * @param address - Ethereum or Solana address to impersonate\n * @returns undefined in SSR context, void in browser\n */\n setImpersonated: (address: string) =>\n typeof window !== 'undefined'\n ? window.localStorage.setItem('satellite-connect:impersonatedAddress', address)\n : undefined,\n\n /**\n * Retrieves the current impersonated address from localStorage\n *\n * @example\n * ```typescript\n * // Get current impersonated address\n * const address = impersonatedHelpers.getImpersonated();\n * if (address) {\n * console.log('Currently impersonating:', address);\n * }\n * ```\n * @returns The impersonated address or undefined if not set or in SSR context\n */\n getImpersonated: () =>\n typeof window !== 'undefined' ? window.localStorage.getItem('satellite-connect:impersonatedAddress') : undefined,\n};\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@tuwaio/satellite-core",
|
|
3
|
+
"version": "0.0.3",
|
|
4
|
+
"private": false,
|
|
5
|
+
"author": "Oleksandr Tkach",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"description": "The core, with store.",
|
|
8
|
+
"main": "./dist/index.js",
|
|
9
|
+
"module": "./dist/index.mjs",
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"publishConfig": {
|
|
12
|
+
"access": "public"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"keywords": [
|
|
18
|
+
"web3",
|
|
19
|
+
"wallets",
|
|
20
|
+
"connect",
|
|
21
|
+
"zustand",
|
|
22
|
+
"immer",
|
|
23
|
+
"typescript",
|
|
24
|
+
"core",
|
|
25
|
+
"headless"
|
|
26
|
+
],
|
|
27
|
+
"repository": {
|
|
28
|
+
"type": "git",
|
|
29
|
+
"url": "git+https://github.com/TuwaIO/satellite-connect.git",
|
|
30
|
+
"directory": "packages/satellite-core"
|
|
31
|
+
},
|
|
32
|
+
"homepage": "https://github.com/TuwaIO/satellite-connect",
|
|
33
|
+
"bugs": {
|
|
34
|
+
"url": "https://github.com/TuwaIO/satellite-connect/issues"
|
|
35
|
+
},
|
|
36
|
+
"contributors": [
|
|
37
|
+
{
|
|
38
|
+
"name": "Oleksandr Tkach",
|
|
39
|
+
"url": "https://github.com/Argeare5"
|
|
40
|
+
}
|
|
41
|
+
],
|
|
42
|
+
"peerDependencies": {
|
|
43
|
+
"@wagmi/core": ">=2.2",
|
|
44
|
+
"@wallet-standard/ui": ">=1",
|
|
45
|
+
"@tuwaio/orbit-core": ">=0",
|
|
46
|
+
"immer": ">=10",
|
|
47
|
+
"zustand": ">=5"
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"@wagmi/core": "^2.21.1",
|
|
51
|
+
"@wallet-standard/ui": "^1.0.1",
|
|
52
|
+
"immer": "^10.1.3",
|
|
53
|
+
"tsup": "^8.5.0",
|
|
54
|
+
"typescript": "^5.9.2",
|
|
55
|
+
"zustand": "^5.0.8",
|
|
56
|
+
"@tuwaio/orbit-core": "^0.0.3"
|
|
57
|
+
},
|
|
58
|
+
"scripts": {
|
|
59
|
+
"start": "tsup src/index.ts --watch",
|
|
60
|
+
"build": "tsup"
|
|
61
|
+
}
|
|
62
|
+
}
|