@layerswap/wallets 2.0.1 → 2.1.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.
@@ -1,6 +1,7 @@
1
+ import KnownInternalNames from "@layerswap/utils/known-ids";
1
2
  import { defineWalletDescriptor } from "./defineWalletDescriptor";
2
3
  import { readStorageJson } from "./persistedSession";
3
- const BITCOIN_NETWORKS = ['BITCOIN_MAINNET', 'BITCOIN_TESTNET'];
4
+ const BITCOIN_NETWORKS = [KnownInternalNames.Networks.BitcoinMainnet, KnownInternalNames.Networks.BitcoinTestnet];
4
5
  /**
5
6
  * Tree-shake-safe stand-in for `createBitcoinProvider`. Defers `bitcoinjs-lib`,
6
7
  * `@bigmi/client`, `bn.js`, and `tweetnacl` — combined ~280 KB parsed /
@@ -1,6 +1,11 @@
1
+ import KnownInternalNames from "@layerswap/utils/known-ids";
1
2
  import { defineWalletDescriptor } from "./defineWalletDescriptor";
2
3
  import { hasStorageKey } from "./persistedSession";
3
- const FUEL_NETWORKS = ['FUEL_MAINNET', 'FUEL_TESTNET', 'FUEL_DEVNET'];
4
+ const FUEL_NETWORKS = [
5
+ KnownInternalNames.Networks.FuelMainnet,
6
+ KnownInternalNames.Networks.FuelTestnet,
7
+ KnownInternalNames.Networks.FuelDevnet,
8
+ ];
4
9
  /**
5
10
  * Tree-shake-safe stand-in for `createFuelProvider`. Defers `@fuel-ts/*` +
6
11
  * `@fuels/vm-asm` — ~373 KB parsed / ~116 KB gzip — out of the host's entry
@@ -1,9 +1,7 @@
1
+ import KnownInternalNames from "@layerswap/utils/known-ids";
1
2
  import { defineWalletDescriptor } from "./defineWalletDescriptor";
2
3
  import { readStorageJson } from "./persistedSession";
3
- // Inlined importing Paradex's runtime constants drags `starknet` (~884 KB
4
- // parsed) into the host entry chunk. Keep in sync with the
5
- // `ParadexMainnet`/`ParadexTestnet` entries in widget's `knownIds.ts`.
6
- const PARADEX_NETWORKS = ['PARADEX_MAINNET', 'PARADEX_TESTNET'];
4
+ const PARADEX_NETWORKS = [KnownInternalNames.Networks.ParadexMainnet, KnownInternalNames.Networks.ParadexTestnet];
7
5
  /**
8
6
  * Tree-shake-safe stand-in for `createParadexProvider` — defers
9
7
  * `@paradex/sdk` → `starknet` out of the host's entry chunk.
@@ -1,8 +1,11 @@
1
+ import KnownInternalNames from "@layerswap/utils/known-ids";
1
2
  import { defineWalletDescriptor } from "./defineWalletDescriptor";
2
3
  import { readStorageJson } from "./persistedSession";
3
- // Inlined importing `KnownInternalNames` pulls a runtime barrel that
4
- // defeats lazy-loading. Keep in sync with packages/wallets/adapters/starknet/src/constants.ts.
5
- const STARKNET_NETWORKS = ['STARKNET_MAINNET', 'STARKNET_SEPOLIA', 'STARKNET_GOERLI'];
4
+ const STARKNET_NETWORKS = [
5
+ KnownInternalNames.Networks.StarkNetMainnet,
6
+ KnownInternalNames.Networks.StarkNetSepolia,
7
+ KnownInternalNames.Networks.StarkNetGoerli,
8
+ ];
6
9
  /**
7
10
  * Tree-shake-safe stand-in for `createStarknetProvider` — defers
8
11
  * `@layerswap/wallet-starknet` (`starknet`, starknetkit) out of the host's
@@ -0,0 +1,28 @@
1
+ import KnownInternalNames from '@layerswap/utils/known-ids';
2
+ import { defineWalletDescriptor } from './defineWalletDescriptor';
3
+ import { readStorageJson } from './persistedSession';
4
+ const STELLAR_NETWORKS = [KnownInternalNames.Networks.StellarMainnet, KnownInternalNames.Networks.StellarTestnet];
5
+ const STELLAR_SESSION_KEY = 'layerswap:stellar-wallet';
6
+ export function createStellarDescriptor(walletConnect, options) {
7
+ const supportedNetworks = options?.supportedNetworks ?? STELLAR_NETWORKS;
8
+ return defineWalletDescriptor({
9
+ id: 'stellar',
10
+ name: 'Stellar',
11
+ capabilities: walletConnect?.projectId ? {
12
+ walletConnectRegistry: {
13
+ networkTypes: ['stellar'],
14
+ },
15
+ } : undefined,
16
+ autofillSupportedNetworks: supportedNetworks,
17
+ withdrawalSupportedNetworks: supportedNetworks,
18
+ asSourceSupportedNetworks: supportedNetworks,
19
+ hasPersistedSession: () => {
20
+ const persisted = readStorageJson(STELLAR_SESSION_KEY);
21
+ return typeof persisted?.walletId === 'string' && typeof persisted.address === 'string';
22
+ },
23
+ loadProvider: async () => {
24
+ const mod = await import('@layerswap/wallet-stellar');
25
+ return mod.createStellarProvider({ walletConnect });
26
+ },
27
+ });
28
+ }
@@ -1,11 +1,16 @@
1
+ import KnownInternalNames from "@layerswap/utils/known-ids";
1
2
  import { defineWalletDescriptor } from "./defineWalletDescriptor";
2
3
  import { hasStorageKey } from "./persistedSession";
3
4
  // SVM's runtime list is built dynamically from `NetworkType.Solana` networks
4
5
  // in `SvmConnectionService` — for static gating we mirror the universe of
5
- // Solana network ids from widget's `knownIds.ts`. Extras don't hurt the
6
+ // Solana network ids from utils. Extras don't hurt the
6
7
  // route filter (it intersects with the active networks list); missing entries
7
8
  // would.
8
- const SVM_NETWORKS = ['SOLANA_MAINNET', 'SOLANA_TESTNET', 'SOLANA_DEVNET'];
9
+ const SVM_NETWORKS = [
10
+ KnownInternalNames.Networks.SolanaMainnet,
11
+ KnownInternalNames.Networks.SolanaTestnet,
12
+ KnownInternalNames.Networks.SolanaDevnet,
13
+ ];
9
14
  /**
10
15
  * Tree-shake-safe stand-in for `createSVMProvider`. Defers the eager portion
11
16
  * of `@solana/web3.js` (~142 KB parsed) and `@walletconnect` adapters dragged
@@ -17,8 +22,7 @@ export function createSVMDescriptor(walletConnectConfigs, options) {
17
22
  return defineWalletDescriptor({
18
23
  id: 'solana',
19
24
  name: 'Solana',
20
- // Keep this descriptor's module graph type-only; loading the widget or
21
- // Solana runtime here would defeat the lazy-provider boundary.
25
+ // Keep widget and wallet imports type-only to preserve lazy loading.
22
26
  capabilities: {
23
27
  walletConnectRegistry: {
24
28
  networkTypes: ['solana'],
@@ -1,9 +1,7 @@
1
+ import KnownInternalNames from "@layerswap/utils/known-ids";
1
2
  import { defineWalletDescriptor } from "./defineWalletDescriptor";
2
3
  import { hasStorageKey } from "./persistedSession";
3
- // Inlined see notes in ./starknet.ts on why we don't import the chain
4
- // package's constants (it would drag the SDK). Keep in sync with
5
- // packages/wallets/adapters/ton/src/constants.ts and widget's `knownIds.ts`.
6
- const TON_NETWORKS = ['TON_MAINNET', 'TON_TESTNET'];
4
+ const TON_NETWORKS = [KnownInternalNames.Networks.TONMainnet, KnownInternalNames.Networks.TONTestnet];
7
5
  /**
8
6
  * Tree-shake-safe stand-in for `createTONProvider`. Defers `@tonconnect/sdk`
9
7
  * + `@ton/*` (~404 KB parsed / 139 KB gzip on `apps/bridge`) out of the
@@ -1,6 +1,7 @@
1
+ import KnownInternalNames from "@layerswap/utils/known-ids";
1
2
  import { defineWalletDescriptor } from "./defineWalletDescriptor";
2
3
  import { readStorageJson } from "./persistedSession";
3
- const TRON_NETWORKS = ['TRON_MAINNET', 'TRON_TESTNET'];
4
+ const TRON_NETWORKS = [KnownInternalNames.Networks.TronMainnet, KnownInternalNames.Networks.TronTestnet];
4
5
  /**
5
6
  * Tree-shake-safe stand-in for `createTronProvider`. Defers `tronweb` +
6
7
  * `validator` (a transitive 125 KB dep of tronweb) + `bignumber.js` +
package/dist/esm/index.js CHANGED
@@ -16,6 +16,7 @@ import { createStarknetDescriptor } from "./descriptors/starknet";
16
16
  import { createSVMDescriptor } from "./descriptors/svm";
17
17
  import { createTONDescriptor } from "./descriptors/ton";
18
18
  import { createTronDescriptor } from "./descriptors/tron";
19
+ import { createStellarDescriptor } from "./descriptors/stellar";
19
20
  export { defineWalletDescriptor } from "./descriptors/defineWalletDescriptor";
20
21
  export { createBitcoinDescriptor };
21
22
  export { createEVMProvider };
@@ -28,6 +29,7 @@ export { createStarknetDescriptor };
28
29
  export { createSVMDescriptor };
29
30
  export { createTONDescriptor };
30
31
  export { createTronDescriptor };
32
+ export { createStellarDescriptor };
31
33
  /**
32
34
  * Creates and returns a default configuration of all wallet providers.
33
35
  *
@@ -35,7 +37,8 @@ export { createTronDescriptor };
35
37
  * other chain ships as a `WalletProviderDescriptor` — the real SDK is
36
38
  * dynamic-imported on first connect-modal open. This keeps starknet,
37
39
  * @paradex/sdk, @ton/*, @tonconnect/sdk, @fuel-ts/*, @solana/web3.js,
38
- * tronweb (+ its transitive `validator`/`bignumber.js`), bitcoinjs-lib,
40
+ * tronweb (+ its transitive `validator`/`bignumber.js`), Stellar Wallets Kit,
41
+ * @stellar/stellar-sdk, bitcoinjs-lib,
39
42
  * @bigmi, and the connector adapters out of the host's entry chunk.
40
43
  *
41
44
  * @param config - Configuration options for the wallet providers
@@ -91,6 +94,8 @@ export function getDefaultProviders(config = {}) {
91
94
  createSVMDescriptor(walletConnect),
92
95
  // Tron — lazy. Pulls tronweb + its transitive validator/bignumber/protobuf.
93
96
  createTronDescriptor(),
97
+ // Stellar — lazy. Pulls Wallets Kit, Reown, and the Stellar SDK on connect.
98
+ createStellarDescriptor(walletConnect),
94
99
  // Immutable Passport — lazy and conditional. The SDK + service
95
100
  // init chain pulls ~993 KB Brotli; deferring it to first
96
101
  // connect-modal open removes that from the home page waterfall.