stackswap-front-api-test-02 1.3.4 → 1.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/index.js +0 -13
- package/dist/esm/index.js.map +1 -1
- package/dist/index.js +0 -13
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +2 -2
- package/package.json +1 -1
- package/src/index.ts +0 -19
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -145,23 +145,15 @@ export class StackswapMainnetAPI implements StackswapAPI{
|
|
|
145
145
|
walletConnect(callback: (err: any, result: any) => void): void {
|
|
146
146
|
connect()
|
|
147
147
|
.then((result) => {
|
|
148
|
-
// DEBUG: Log connect() result to understand address selection
|
|
149
|
-
console.log('[walletConnect] connect() raw result:', JSON.stringify(result, null, 2));
|
|
150
|
-
|
|
151
148
|
// STX addresses start with 'SP' (mainnet) or 'ST' (testnet)
|
|
152
149
|
const stxAddresses = result.addresses.filter(a =>
|
|
153
150
|
a.address.startsWith('SP') || a.address.startsWith('ST')
|
|
154
151
|
);
|
|
155
152
|
|
|
156
|
-
console.log('[walletConnect] STX addresses found:', stxAddresses);
|
|
157
|
-
console.log('[walletConnect] isMainnet:', this.config.isMainnet());
|
|
158
|
-
|
|
159
153
|
const address = this.config.isMainnet()
|
|
160
154
|
? stxAddresses.find(a => a.address.startsWith('SP'))?.address
|
|
161
155
|
: stxAddresses.find(a => a.address.startsWith('ST'))?.address;
|
|
162
156
|
|
|
163
|
-
console.log('[walletConnect] Selected address:', address);
|
|
164
|
-
|
|
165
157
|
if (address) {
|
|
166
158
|
// Save current address to localStorage for isConnected() to use
|
|
167
159
|
if (typeof window !== 'undefined' && window.localStorage) {
|
|
@@ -230,7 +222,6 @@ export class StackswapMainnetAPI implements StackswapAPI{
|
|
|
230
222
|
|
|
231
223
|
isConnected(): boolean {
|
|
232
224
|
try {
|
|
233
|
-
console.log('[isConnected] isWalletConnected():', isWalletConnected());
|
|
234
225
|
if (!isWalletConnected()) {
|
|
235
226
|
return false;
|
|
236
227
|
}
|
|
@@ -239,7 +230,6 @@ export class StackswapMainnetAPI implements StackswapAPI{
|
|
|
239
230
|
let savedAddress: string | null = null;
|
|
240
231
|
if (typeof window !== 'undefined' && window.localStorage) {
|
|
241
232
|
savedAddress = window.localStorage.getItem('currentStxAddress');
|
|
242
|
-
console.log('[isConnected] Saved currentStxAddress:', savedAddress);
|
|
243
233
|
}
|
|
244
234
|
|
|
245
235
|
// Validate saved address matches network (SP for mainnet, ST for testnet)
|
|
@@ -249,7 +239,6 @@ export class StackswapMainnetAPI implements StackswapAPI{
|
|
|
249
239
|
: savedAddress.startsWith('ST');
|
|
250
240
|
|
|
251
241
|
if (isValidForNetwork) {
|
|
252
|
-
console.log('[isConnected] Using saved address:', savedAddress);
|
|
253
242
|
this.senderAdderss = savedAddress;
|
|
254
243
|
this.connected = true;
|
|
255
244
|
return true;
|
|
@@ -258,24 +247,17 @@ export class StackswapMainnetAPI implements StackswapAPI{
|
|
|
258
247
|
|
|
259
248
|
// Fallback: use getLocalStorage() if no saved address
|
|
260
249
|
const storage = getLocalStorage();
|
|
261
|
-
console.log('[isConnected] getLocalStorage():', JSON.stringify(storage, null, 2));
|
|
262
|
-
|
|
263
250
|
if (!storage || !storage.addresses?.stx?.length) {
|
|
264
|
-
console.log('[isConnected] No storage or no STX addresses');
|
|
265
251
|
return false;
|
|
266
252
|
}
|
|
267
253
|
|
|
268
254
|
const stxAddresses = storage.addresses.stx;
|
|
269
|
-
console.log('[isConnected] STX addresses:', stxAddresses);
|
|
270
|
-
console.log('[isConnected] isMainnet:', this.config.isMainnet());
|
|
271
255
|
|
|
272
256
|
// SP = mainnet, ST = testnet
|
|
273
257
|
const address = this.config.isMainnet()
|
|
274
258
|
? stxAddresses.find(a => a.address.startsWith('SP'))?.address
|
|
275
259
|
: stxAddresses.find(a => a.address.startsWith('ST'))?.address;
|
|
276
260
|
|
|
277
|
-
console.log('[isConnected] Selected address:', address);
|
|
278
|
-
|
|
279
261
|
if (address) {
|
|
280
262
|
this.senderAdderss = address;
|
|
281
263
|
this.connected = true;
|
|
@@ -283,7 +265,6 @@ export class StackswapMainnetAPI implements StackswapAPI{
|
|
|
283
265
|
}
|
|
284
266
|
return false;
|
|
285
267
|
} catch (e) {
|
|
286
|
-
console.log('[isConnected] Error:', e);
|
|
287
268
|
return false;
|
|
288
269
|
}
|
|
289
270
|
}
|