@dynamic-labs/spark 4.30.0
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/CHANGELOG.md +6064 -0
- package/LICENSE +21 -0
- package/README.md +267 -0
- package/_virtual/_tslib.cjs +36 -0
- package/_virtual/_tslib.js +32 -0
- package/package.cjs +8 -0
- package/package.js +4 -0
- package/package.json +28 -0
- package/src/connectors/MagicEdenSparkConnector/MagicEdenSparkConnector.cjs +57 -0
- package/src/connectors/MagicEdenSparkConnector/MagicEdenSparkConnector.d.ts +29 -0
- package/src/connectors/MagicEdenSparkConnector/MagicEdenSparkConnector.js +53 -0
- package/src/connectors/MagicEdenSparkConnector/index.d.ts +1 -0
- package/src/connectors/SparkWalletConnector/SparkWalletConnector.cjs +247 -0
- package/src/connectors/SparkWalletConnector/SparkWalletConnector.d.ts +128 -0
- package/src/connectors/SparkWalletConnector/SparkWalletConnector.js +243 -0
- package/src/connectors/SparkWalletConnector/index.d.ts +1 -0
- package/src/connectors/index.d.ts +2 -0
- package/src/index.cjs +19 -0
- package/src/index.d.ts +6 -0
- package/src/index.js +13 -0
- package/src/types.d.ts +146 -0
- package/src/utils/address.cjs +27 -0
- package/src/utils/address.d.ts +12 -0
- package/src/utils/address.js +23 -0
- package/src/utils/connection.d.ts +9 -0
- package/src/utils/provider.cjs +23 -0
- package/src/utils/provider.d.ts +19 -0
- package/src/utils/provider.js +19 -0
- package/src/wallet/SparkWallet.cjs +42 -0
- package/src/wallet/SparkWallet.d.ts +20 -0
- package/src/wallet/SparkWallet.js +38 -0
- package/src/wallet/index.d.ts +2 -0
- package/src/wallet/isSparkWallet/index.d.ts +1 -0
- package/src/wallet/isSparkWallet/isSparkWallet.cjs +8 -0
- package/src/wallet/isSparkWallet/isSparkWallet.d.ts +3 -0
- package/src/wallet/isSparkWallet/isSparkWallet.js +4 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Dynamic Labs, Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
# @dynamic-labs/spark
|
|
2
|
+
|
|
3
|
+
A Spark wallet connector package for the Dynamic SDK that enables seamless integration with Spark network wallets.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Magic Eden Wallet Support** - Full integration with Magic Eden's Spark wallet
|
|
8
|
+
- **Flexible Provider Interface** - Easy to add support for additional Spark wallets
|
|
9
|
+
- **Bitcoin Transfers** - Send Bitcoin to Spark addresses with optional Taproot support
|
|
10
|
+
- **Token Transfers** - Transfer tokens between Spark addresses
|
|
11
|
+
- **Message Signing** - Sign messages for authentication with optional Taproot support
|
|
12
|
+
- **Mainnet Support** - Currently supports Spark mainnet (chain ID 301)
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install @dynamic-labs/spark
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## 🔌 Supported Wallets
|
|
21
|
+
|
|
22
|
+
### Magic Eden
|
|
23
|
+
|
|
24
|
+
The package includes full support for Magic Eden's Spark wallet implementation, which provides:
|
|
25
|
+
|
|
26
|
+
- **Connection Management** - Seamless wallet connection and disconnection
|
|
27
|
+
- **Address Retrieval** - Get current wallet address
|
|
28
|
+
- **Message Signing** - Sign messages for authentication with optional Taproot support
|
|
29
|
+
- **Bitcoin Transfers** - Send Bitcoin to other Spark addresses
|
|
30
|
+
- **Token Transfers** - Transfer tokens between Spark addresses
|
|
31
|
+
|
|
32
|
+
## Architecture
|
|
33
|
+
|
|
34
|
+
### Base Connector Class
|
|
35
|
+
|
|
36
|
+
The `SparkWalletConnector` provides a robust foundation for all Spark wallet integrations:
|
|
37
|
+
|
|
38
|
+
- **Abstract Implementation** - Handles common wallet operations
|
|
39
|
+
- **Error Handling** - Comprehensive error handling and logging
|
|
40
|
+
- **Mainnet Focus** - Currently optimized for mainnet usage
|
|
41
|
+
|
|
42
|
+
### Provider Interface
|
|
43
|
+
|
|
44
|
+
All Spark wallet providers must implement the `ISparkProvider` interface:
|
|
45
|
+
|
|
46
|
+
```typescript
|
|
47
|
+
interface ISparkProvider {
|
|
48
|
+
isConnected: boolean;
|
|
49
|
+
chainId?: string;
|
|
50
|
+
network?: string;
|
|
51
|
+
|
|
52
|
+
connect(): Promise<SparkConnectionResult | string>;
|
|
53
|
+
disconnect(): Promise<void>;
|
|
54
|
+
getAddress(): Promise<SparkAddressResult>;
|
|
55
|
+
signMessage(
|
|
56
|
+
message: string | SparkSignMessageRequest,
|
|
57
|
+
): Promise<SparkSignatureResult>;
|
|
58
|
+
signMessageWithTaproot(message: string): Promise<SparkSignatureResult>;
|
|
59
|
+
transferBitcoin(params: {
|
|
60
|
+
receiverSparkAddress: string;
|
|
61
|
+
amountSats: bigint;
|
|
62
|
+
isTaproot?: boolean;
|
|
63
|
+
}): Promise<string>;
|
|
64
|
+
transferTokens(params: {
|
|
65
|
+
tokenPublicKey: string;
|
|
66
|
+
receiverSparkAddress: string;
|
|
67
|
+
tokenAmount: number;
|
|
68
|
+
isTaproot?: boolean;
|
|
69
|
+
}): Promise<string>;
|
|
70
|
+
request(method: string, params?: unknown): Promise<unknown>;
|
|
71
|
+
|
|
72
|
+
[key: string]: unknown; // Extensible for additional properties
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## 🌐 Supported Networks
|
|
77
|
+
|
|
78
|
+
| Network | Chain ID | Description | Block Explorer |
|
|
79
|
+
| ----------- | -------- | ------------------ | -------------------------------------- |
|
|
80
|
+
| **Mainnet** | 301 | Production network | [mempool.space](https://mempool.space) |
|
|
81
|
+
|
|
82
|
+
> **Note**: Currently only mainnet is supported. Testnet, signet, and regtest support may be added in future versions.
|
|
83
|
+
|
|
84
|
+
## 📖 Usage
|
|
85
|
+
|
|
86
|
+
### Basic Integration
|
|
87
|
+
|
|
88
|
+
```typescript
|
|
89
|
+
import { DynamicContextProvider } from '@dynamic-labs/sdk-react-core';
|
|
90
|
+
import { SparkWalletConnectors } from '@dynamic-labs/spark';
|
|
91
|
+
|
|
92
|
+
function App() {
|
|
93
|
+
return (
|
|
94
|
+
<DynamicContextProvider
|
|
95
|
+
settings={{
|
|
96
|
+
environmentId: 'your-environment-id',
|
|
97
|
+
walletConnectors: [SparkWalletConnectors()],
|
|
98
|
+
}}
|
|
99
|
+
>
|
|
100
|
+
{/* Your app content */}
|
|
101
|
+
</DynamicContextProvider>
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Using the SparkWallet
|
|
107
|
+
|
|
108
|
+
```typescript
|
|
109
|
+
import { useDynamicContext } from '@dynamic-labs/sdk-react-core';
|
|
110
|
+
import { SparkWallet } from '@dynamic-labs/spark';
|
|
111
|
+
|
|
112
|
+
function MyComponent() {
|
|
113
|
+
const { primaryWallet } = useDynamicContext();
|
|
114
|
+
|
|
115
|
+
const handleSendBitcoin = async () => {
|
|
116
|
+
if (primaryWallet instanceof SparkWallet) {
|
|
117
|
+
// Send Bitcoin
|
|
118
|
+
const txHash = await primaryWallet.sendBalance({
|
|
119
|
+
amount: '100000', // 100,000 satoshis
|
|
120
|
+
toAddress: 'sp1recipient123456789abcdef',
|
|
121
|
+
isTaproot: false,
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
// Or use the direct transferBitcoin method
|
|
125
|
+
const txHash2 = await primaryWallet.transferBitcoin({
|
|
126
|
+
amount: '50000',
|
|
127
|
+
toAddress: 'sp1recipient123456789abcdef',
|
|
128
|
+
isTaproot: true,
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
const handleSendTokens = async () => {
|
|
134
|
+
if (primaryWallet instanceof SparkWallet) {
|
|
135
|
+
const txHash = await primaryWallet.transferTokens({
|
|
136
|
+
tokenPublicKey: 'token123',
|
|
137
|
+
receiverSparkAddress: 'sp1recipient123456789abcdef',
|
|
138
|
+
tokenAmount: 1000,
|
|
139
|
+
isTaproot: false,
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
return (
|
|
145
|
+
<div>
|
|
146
|
+
<button onClick={handleSendBitcoin}>Send Bitcoin</button>
|
|
147
|
+
<button onClick={handleSendTokens}>Send Tokens</button>
|
|
148
|
+
</div>
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### Custom Connector Implementation
|
|
154
|
+
|
|
155
|
+
To add support for a new Spark wallet:
|
|
156
|
+
|
|
157
|
+
```typescript
|
|
158
|
+
import { SparkWalletConnector } from '@dynamic-labs/spark';
|
|
159
|
+
|
|
160
|
+
export class YourSparkConnector extends SparkWalletConnector {
|
|
161
|
+
override name = 'Your Spark Wallet';
|
|
162
|
+
override overrideKey = 'yourspark';
|
|
163
|
+
|
|
164
|
+
public override getProvider(): ISparkProvider | undefined {
|
|
165
|
+
return window.yourProvider;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### Type Checking
|
|
171
|
+
|
|
172
|
+
Use the `isSparkWallet` type guard to safely work with Spark wallets:
|
|
173
|
+
|
|
174
|
+
```typescript
|
|
175
|
+
import { isSparkWallet } from '@dynamic-labs/spark';
|
|
176
|
+
|
|
177
|
+
function handleWallet(wallet: Wallet) {
|
|
178
|
+
if (isSparkWallet(wallet)) {
|
|
179
|
+
// TypeScript now knows this is a SparkWallet
|
|
180
|
+
wallet.transferBitcoin({
|
|
181
|
+
amount: '100000',
|
|
182
|
+
toAddress: 'sp1recipient123456789abcdef',
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
## 🧪 Testing
|
|
189
|
+
|
|
190
|
+
### Run Tests
|
|
191
|
+
|
|
192
|
+
```bash
|
|
193
|
+
npx nx test spark
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### Build Package
|
|
197
|
+
|
|
198
|
+
```bash
|
|
199
|
+
npx nx build spark
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
### Test in Demo App
|
|
203
|
+
|
|
204
|
+
1. Start the demo app: `npm run start`
|
|
205
|
+
2. Navigate to the Spark wallet section
|
|
206
|
+
3. Test connection, address retrieval, and message signing
|
|
207
|
+
|
|
208
|
+
## 📚 API Reference
|
|
209
|
+
|
|
210
|
+
### Core Exports
|
|
211
|
+
|
|
212
|
+
- `SparkWalletConnectors()` - Factory function returning all available connectors
|
|
213
|
+
- `SparkWalletConnector` - Base class for custom implementations
|
|
214
|
+
- `SparkWallet` - Wallet class with Bitcoin and token transfer methods
|
|
215
|
+
- `ISparkProvider` - Interface for wallet providers
|
|
216
|
+
- `isSparkWallet` - Type guard for Spark wallets
|
|
217
|
+
|
|
218
|
+
### SparkWallet Methods
|
|
219
|
+
|
|
220
|
+
- `sendBalance(params)` - Send Bitcoin (alias for transferBitcoin)
|
|
221
|
+
- `transferBitcoin(params)` - Send Bitcoin to a Spark address
|
|
222
|
+
- `transferTokens(params)` - Send tokens to a Spark address
|
|
223
|
+
|
|
224
|
+
### Type Definitions
|
|
225
|
+
|
|
226
|
+
- `SparkConnectionResult` - Result from wallet connection
|
|
227
|
+
- `SparkAddressResult` - Result from address retrieval
|
|
228
|
+
- `SparkSignMessageRequest` - Message signing request options
|
|
229
|
+
- `SparkSignatureResult` - Result from message signing
|
|
230
|
+
|
|
231
|
+
## 🔗 Related Packages
|
|
232
|
+
|
|
233
|
+
- **@dynamic-labs/sdk-react-core** - React SDK core functionality
|
|
234
|
+
- **@dynamic-labs/wallet-connector-core** - Base wallet connector classes
|
|
235
|
+
- **@dynamic-labs/types** - Common type definitions
|
|
236
|
+
|
|
237
|
+
## 🤝 Contributing
|
|
238
|
+
|
|
239
|
+
We welcome contributions! Please see our [contributing guidelines](https://github.com/dynamic-labs/dynamic-sdk/blob/main/CONTRIBUTING.md) for details.
|
|
240
|
+
|
|
241
|
+
### Development Setup
|
|
242
|
+
|
|
243
|
+
1. Clone the repository
|
|
244
|
+
2. Install dependencies: `npm install`
|
|
245
|
+
3. Run tests: `npx nx test spark`
|
|
246
|
+
4. Build package: `npx nx build spark`
|
|
247
|
+
|
|
248
|
+
### Adding New Wallets
|
|
249
|
+
|
|
250
|
+
1. Create a new connector class extending `SparkWalletConnector`
|
|
251
|
+
2. Implement the `getProvider()` method
|
|
252
|
+
3. Add comprehensive tests
|
|
253
|
+
4. Update the `SparkWalletConnectors()` factory function
|
|
254
|
+
|
|
255
|
+
## 📄 License
|
|
256
|
+
|
|
257
|
+
This package is part of the Dynamic SDK and follows the same licensing terms. See [LICENSE](https://github.com/dynamic-labs/dynamic-sdk/blob/main/LICENSE) for details.
|
|
258
|
+
|
|
259
|
+
## 🆘 Support
|
|
260
|
+
|
|
261
|
+
- **Documentation**: [docs.dynamic.xyz](https://docs.dynamic.xyz)
|
|
262
|
+
- **GitHub Issues**: [Report bugs or request features](https://github.com/dynamic-labs/dynamic-sdk/issues)
|
|
263
|
+
- **Discord**: [Join our community](https://discord.gg/dynamic)
|
|
264
|
+
|
|
265
|
+
---
|
|
266
|
+
|
|
267
|
+
**Built with ❤️ by the Dynamic Labs team**
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
/******************************************************************************
|
|
7
|
+
Copyright (c) Microsoft Corporation.
|
|
8
|
+
|
|
9
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
10
|
+
purpose with or without fee is hereby granted.
|
|
11
|
+
|
|
12
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
13
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
14
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
15
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
16
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
17
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
18
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
19
|
+
***************************************************************************** */
|
|
20
|
+
|
|
21
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
22
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
23
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
24
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
25
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
26
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
27
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
32
|
+
var e = new Error(message);
|
|
33
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
exports.__awaiter = __awaiter;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
/******************************************************************************
|
|
3
|
+
Copyright (c) Microsoft Corporation.
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
purpose with or without fee is hereby granted.
|
|
7
|
+
|
|
8
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
9
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
10
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
11
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
12
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
13
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
14
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
15
|
+
***************************************************************************** */
|
|
16
|
+
|
|
17
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
18
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
28
|
+
var e = new Error(message);
|
|
29
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export { __awaiter };
|
package/package.cjs
ADDED
package/package.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dynamic-labs/spark",
|
|
3
|
+
"version": "4.30.0",
|
|
4
|
+
"description": "A React SDK for implementing wallet web3 authentication and authorization to your website.",
|
|
5
|
+
"author": "Dynamic Labs, Inc.",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"main": "./src/index.cjs",
|
|
8
|
+
"module": "./src/index.js",
|
|
9
|
+
"types": "./src/index.d.ts",
|
|
10
|
+
"type": "module",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./src/index.d.ts",
|
|
14
|
+
"import": "./src/index.js",
|
|
15
|
+
"require": "./src/index.cjs"
|
|
16
|
+
},
|
|
17
|
+
"./package.json": "./package.json"
|
|
18
|
+
},
|
|
19
|
+
"homepage": "https://www.dynamic.xyz/",
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@dynamic-labs/assert-package-version": "4.30.0",
|
|
22
|
+
"@dynamic-labs/types": "4.30.0",
|
|
23
|
+
"@dynamic-labs/utils": "4.30.0",
|
|
24
|
+
"@dynamic-labs/wallet-book": "4.30.0",
|
|
25
|
+
"@dynamic-labs/wallet-connector-core": "4.30.0"
|
|
26
|
+
},
|
|
27
|
+
"peerDependencies": {}
|
|
28
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var _tslib = require('../../../_virtual/_tslib.cjs');
|
|
7
|
+
var walletBook = require('@dynamic-labs/wallet-book');
|
|
8
|
+
var utils = require('@dynamic-labs/utils');
|
|
9
|
+
var SparkWalletConnector = require('../SparkWalletConnector/SparkWalletConnector.cjs');
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Magic Eden Spark wallet connector implementation.
|
|
13
|
+
*
|
|
14
|
+
* Handles Magic Eden's specific interface requirements while leveraging
|
|
15
|
+
* the base class's flexible type handling.
|
|
16
|
+
*/
|
|
17
|
+
class MagicEdenSparkConnector extends SparkWalletConnector.SparkWalletConnector {
|
|
18
|
+
/**
|
|
19
|
+
* Creates a new Magic Eden Spark connector
|
|
20
|
+
* @param opts - Configuration options
|
|
21
|
+
*/
|
|
22
|
+
constructor(opts) {
|
|
23
|
+
super(opts);
|
|
24
|
+
/** Human-readable connector name */
|
|
25
|
+
this.name = 'Magic Eden Spark';
|
|
26
|
+
/** Unique identifier for this connector type */
|
|
27
|
+
this.overrideKey = 'magicedenspark';
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Returns the Magic Eden Spark provider from the window object
|
|
31
|
+
* @returns The SparkProvider instance, or undefined if not available
|
|
32
|
+
*/
|
|
33
|
+
getProvider() {
|
|
34
|
+
const providers = utils.getProvidersFromWindow('magicEden.spark');
|
|
35
|
+
return providers[0];
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Retrieves the wallet address with Magic Eden specific error handling
|
|
39
|
+
* @returns The wallet address as a string, or undefined if unavailable
|
|
40
|
+
*/
|
|
41
|
+
getAddress() {
|
|
42
|
+
const _super = Object.create(null, {
|
|
43
|
+
getAddress: { get: () => super.getAddress }
|
|
44
|
+
});
|
|
45
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
46
|
+
try {
|
|
47
|
+
return yield _super.getAddress.call(this);
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
walletBook.logger.warn('Failed to get address from Magic Eden Spark wallet:', error);
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
exports.MagicEdenSparkConnector = MagicEdenSparkConnector;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { SparkWalletConnector, SparkWalletConnectorOpts } from '../SparkWalletConnector';
|
|
2
|
+
import type { ISparkProvider } from '../../types';
|
|
3
|
+
/**
|
|
4
|
+
* Magic Eden Spark wallet connector implementation.
|
|
5
|
+
*
|
|
6
|
+
* Handles Magic Eden's specific interface requirements while leveraging
|
|
7
|
+
* the base class's flexible type handling.
|
|
8
|
+
*/
|
|
9
|
+
export declare class MagicEdenSparkConnector extends SparkWalletConnector {
|
|
10
|
+
/** Human-readable connector name */
|
|
11
|
+
name: string;
|
|
12
|
+
/** Unique identifier for this connector type */
|
|
13
|
+
overrideKey: string;
|
|
14
|
+
/**
|
|
15
|
+
* Creates a new Magic Eden Spark connector
|
|
16
|
+
* @param opts - Configuration options
|
|
17
|
+
*/
|
|
18
|
+
constructor(opts: SparkWalletConnectorOpts);
|
|
19
|
+
/**
|
|
20
|
+
* Returns the Magic Eden Spark provider from the window object
|
|
21
|
+
* @returns The SparkProvider instance, or undefined if not available
|
|
22
|
+
*/
|
|
23
|
+
getProvider(): ISparkProvider | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* Retrieves the wallet address with Magic Eden specific error handling
|
|
26
|
+
* @returns The wallet address as a string, or undefined if unavailable
|
|
27
|
+
*/
|
|
28
|
+
getAddress(): Promise<string | undefined>;
|
|
29
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { __awaiter } from '../../../_virtual/_tslib.js';
|
|
3
|
+
import { logger } from '@dynamic-labs/wallet-book';
|
|
4
|
+
import { getProvidersFromWindow } from '@dynamic-labs/utils';
|
|
5
|
+
import { SparkWalletConnector } from '../SparkWalletConnector/SparkWalletConnector.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Magic Eden Spark wallet connector implementation.
|
|
9
|
+
*
|
|
10
|
+
* Handles Magic Eden's specific interface requirements while leveraging
|
|
11
|
+
* the base class's flexible type handling.
|
|
12
|
+
*/
|
|
13
|
+
class MagicEdenSparkConnector extends SparkWalletConnector {
|
|
14
|
+
/**
|
|
15
|
+
* Creates a new Magic Eden Spark connector
|
|
16
|
+
* @param opts - Configuration options
|
|
17
|
+
*/
|
|
18
|
+
constructor(opts) {
|
|
19
|
+
super(opts);
|
|
20
|
+
/** Human-readable connector name */
|
|
21
|
+
this.name = 'Magic Eden Spark';
|
|
22
|
+
/** Unique identifier for this connector type */
|
|
23
|
+
this.overrideKey = 'magicedenspark';
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Returns the Magic Eden Spark provider from the window object
|
|
27
|
+
* @returns The SparkProvider instance, or undefined if not available
|
|
28
|
+
*/
|
|
29
|
+
getProvider() {
|
|
30
|
+
const providers = getProvidersFromWindow('magicEden.spark');
|
|
31
|
+
return providers[0];
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Retrieves the wallet address with Magic Eden specific error handling
|
|
35
|
+
* @returns The wallet address as a string, or undefined if unavailable
|
|
36
|
+
*/
|
|
37
|
+
getAddress() {
|
|
38
|
+
const _super = Object.create(null, {
|
|
39
|
+
getAddress: { get: () => super.getAddress }
|
|
40
|
+
});
|
|
41
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
42
|
+
try {
|
|
43
|
+
return yield _super.getAddress.call(this);
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
logger.warn('Failed to get address from Magic Eden Spark wallet:', error);
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export { MagicEdenSparkConnector };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './MagicEdenSparkConnector';
|