@openzeppelin/adapter-stellar 1.0.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.
Files changed (165) hide show
  1. package/README.md +272 -0
  2. package/dist/config.cjs +21 -0
  3. package/dist/config.cjs.map +1 -0
  4. package/dist/config.d.cts +8 -0
  5. package/dist/config.d.cts.map +1 -0
  6. package/dist/config.d.mts +8 -0
  7. package/dist/config.d.mts.map +1 -0
  8. package/dist/config.mjs +20 -0
  9. package/dist/config.mjs.map +1 -0
  10. package/dist/index.cjs +7564 -0
  11. package/dist/index.cjs.map +1 -0
  12. package/dist/index.d.cts +261 -0
  13. package/dist/index.d.cts.map +1 -0
  14. package/dist/index.d.mts +263 -0
  15. package/dist/index.d.mts.map +1 -0
  16. package/dist/index.mjs +7529 -0
  17. package/dist/index.mjs.map +1 -0
  18. package/dist/metadata.cjs +22 -0
  19. package/dist/metadata.cjs.map +1 -0
  20. package/dist/metadata.d.cts +7 -0
  21. package/dist/metadata.d.cts.map +1 -0
  22. package/dist/metadata.d.mts +7 -0
  23. package/dist/metadata.d.mts.map +1 -0
  24. package/dist/metadata.mjs +21 -0
  25. package/dist/metadata.mjs.map +1 -0
  26. package/dist/networks-BrV516-R.d.cts +15 -0
  27. package/dist/networks-BrV516-R.d.cts.map +1 -0
  28. package/dist/networks-C0MmhJcu.d.mts +15 -0
  29. package/dist/networks-C0MmhJcu.d.mts.map +1 -0
  30. package/dist/networks-DgUFSTiC.cjs +76 -0
  31. package/dist/networks-DgUFSTiC.cjs.map +1 -0
  32. package/dist/networks-QbEPbaGT.mjs +46 -0
  33. package/dist/networks-QbEPbaGT.mjs.map +1 -0
  34. package/dist/networks.cjs +8 -0
  35. package/dist/networks.d.cts +2 -0
  36. package/dist/networks.d.mts +2 -0
  37. package/dist/networks.mjs +3 -0
  38. package/dist/vite-config.cjs +43 -0
  39. package/dist/vite-config.cjs.map +1 -0
  40. package/dist/vite-config.d.cts +35 -0
  41. package/dist/vite-config.d.cts.map +1 -0
  42. package/dist/vite-config.d.mts +35 -0
  43. package/dist/vite-config.d.mts.map +1 -0
  44. package/dist/vite-config.mjs +42 -0
  45. package/dist/vite-config.mjs.map +1 -0
  46. package/package.json +114 -0
  47. package/src/__tests__/getDefaultServiceConfig.test.ts +105 -0
  48. package/src/access-control/actions.ts +214 -0
  49. package/src/access-control/feature-detection.ts +238 -0
  50. package/src/access-control/index.ts +54 -0
  51. package/src/access-control/indexer-client.ts +1474 -0
  52. package/src/access-control/onchain-reader.ts +446 -0
  53. package/src/access-control/service.ts +1431 -0
  54. package/src/access-control/validation.ts +256 -0
  55. package/src/adapter.ts +659 -0
  56. package/src/config.ts +43 -0
  57. package/src/configuration/__tests__/explorer.test.ts +80 -0
  58. package/src/configuration/__tests__/rpc.test.ts +355 -0
  59. package/src/configuration/execution.ts +83 -0
  60. package/src/configuration/explorer.ts +105 -0
  61. package/src/configuration/index.ts +5 -0
  62. package/src/configuration/network-services.ts +210 -0
  63. package/src/configuration/rpc.ts +270 -0
  64. package/src/configuration.ts +2 -0
  65. package/src/contract/__tests__/complete-type-coverage.test.ts +78 -0
  66. package/src/contract/index.ts +3 -0
  67. package/src/contract/loader.ts +498 -0
  68. package/src/contract/transformer.ts +1 -0
  69. package/src/contract/type.ts +65 -0
  70. package/src/index.ts +23 -0
  71. package/src/mapping/constants.ts +89 -0
  72. package/src/mapping/enum-metadata.ts +237 -0
  73. package/src/mapping/field-generator.ts +296 -0
  74. package/src/mapping/index.ts +5 -0
  75. package/src/mapping/struct-fields.ts +106 -0
  76. package/src/mapping/tuple-components.ts +43 -0
  77. package/src/mapping/type-coverage-validator.ts +151 -0
  78. package/src/mapping/type-mapper.ts +203 -0
  79. package/src/metadata.ts +16 -0
  80. package/src/networks/README.md +84 -0
  81. package/src/networks/index.ts +19 -0
  82. package/src/networks/mainnet.ts +20 -0
  83. package/src/networks/testnet.ts +20 -0
  84. package/src/networks.ts +2 -0
  85. package/src/query/handler.ts +411 -0
  86. package/src/query/index.ts +4 -0
  87. package/src/query/view-checker.ts +32 -0
  88. package/src/sac/spec-cache.ts +68 -0
  89. package/src/sac/spec-source.ts +35 -0
  90. package/src/sac/xdr.ts +101 -0
  91. package/src/transaction/components/AdvancedInfo.tsx +34 -0
  92. package/src/transaction/components/FeeConfiguration.tsx +41 -0
  93. package/src/transaction/components/StellarRelayerOptions.tsx +60 -0
  94. package/src/transaction/components/TransactionTiming.tsx +77 -0
  95. package/src/transaction/components/index.ts +5 -0
  96. package/src/transaction/components/useStellarRelayerOptions.ts +114 -0
  97. package/src/transaction/eoa.ts +229 -0
  98. package/src/transaction/execution-strategy.ts +33 -0
  99. package/src/transaction/formatter.ts +296 -0
  100. package/src/transaction/index.ts +4 -0
  101. package/src/transaction/relayer.ts +575 -0
  102. package/src/transaction/sender.ts +156 -0
  103. package/src/transform/index.ts +4 -0
  104. package/src/transform/input-parser.ts +9 -0
  105. package/src/transform/output-formatter.ts +133 -0
  106. package/src/transform/parsers/complex-parser.ts +157 -0
  107. package/src/transform/parsers/generic-parser.ts +171 -0
  108. package/src/transform/parsers/index.ts +86 -0
  109. package/src/transform/parsers/primitive-parser.ts +123 -0
  110. package/src/transform/parsers/scval-converter.ts +405 -0
  111. package/src/transform/parsers/struct-parser.ts +324 -0
  112. package/src/transform/parsers/types.ts +35 -0
  113. package/src/types/__tests__/artifacts.test.ts +89 -0
  114. package/src/types/artifacts.ts +19 -0
  115. package/src/utils/__tests__/artifacts.test.ts +77 -0
  116. package/src/utils/artifacts.ts +30 -0
  117. package/src/utils/formatting.ts +122 -0
  118. package/src/utils/index.ts +6 -0
  119. package/src/utils/input-parsing.ts +336 -0
  120. package/src/utils/safe-type-parser.ts +303 -0
  121. package/src/utils/stellar-types.ts +35 -0
  122. package/src/utils/type-detection.ts +163 -0
  123. package/src/utils/xdr-ordering.ts +36 -0
  124. package/src/validation/__tests__/address.test.ts +267 -0
  125. package/src/validation/address.ts +136 -0
  126. package/src/validation/eoa.ts +33 -0
  127. package/src/validation/index.ts +3 -0
  128. package/src/validation/relayer.ts +13 -0
  129. package/src/vite-config.ts +67 -0
  130. package/src/wallet/README.md +93 -0
  131. package/src/wallet/__tests__/connection.test.ts +72 -0
  132. package/src/wallet/components/StellarWalletUiRoot.tsx +161 -0
  133. package/src/wallet/components/account/AccountDisplay.tsx +50 -0
  134. package/src/wallet/components/connect/ConnectButton.tsx +100 -0
  135. package/src/wallet/components/connect/ConnectorDialog.tsx +125 -0
  136. package/src/wallet/components/index.ts +3 -0
  137. package/src/wallet/connection.ts +151 -0
  138. package/src/wallet/context/StellarWalletContext.ts +32 -0
  139. package/src/wallet/context/index.ts +4 -0
  140. package/src/wallet/context/useStellarWalletContext.ts +17 -0
  141. package/src/wallet/hooks/facade-hooks.ts +31 -0
  142. package/src/wallet/hooks/index.ts +7 -0
  143. package/src/wallet/hooks/useStellarAccount.ts +27 -0
  144. package/src/wallet/hooks/useStellarConnect.ts +60 -0
  145. package/src/wallet/hooks/useStellarDisconnect.ts +47 -0
  146. package/src/wallet/hooks/useUiKitConfig.ts +40 -0
  147. package/src/wallet/implementation/wallets-kit-implementation.ts +379 -0
  148. package/src/wallet/index.ts +11 -0
  149. package/src/wallet/services/__tests__/configResolutionService.test.ts +163 -0
  150. package/src/wallet/services/configResolutionService.ts +65 -0
  151. package/src/wallet/stellar-wallets-kit/StellarWalletsKitConnectButton.tsx +82 -0
  152. package/src/wallet/stellar-wallets-kit/__mocks__/@creit.tech/stellar-wallets-kit.ts +48 -0
  153. package/src/wallet/stellar-wallets-kit/__tests__/export-service.test.ts +93 -0
  154. package/src/wallet/stellar-wallets-kit/__tests__/stellarUiKitManager.test.ts +0 -0
  155. package/src/wallet/stellar-wallets-kit/config-generator.ts +75 -0
  156. package/src/wallet/stellar-wallets-kit/export-service.ts +19 -0
  157. package/src/wallet/stellar-wallets-kit/index.ts +3 -0
  158. package/src/wallet/stellar-wallets-kit/stellarUiKitManager.ts +235 -0
  159. package/src/wallet/types.ts +19 -0
  160. package/src/wallet/utils/__tests__/filterWalletComponents.test.ts +150 -0
  161. package/src/wallet/utils/__tests__/uiKitService.test.ts +189 -0
  162. package/src/wallet/utils/filterWalletComponents.ts +89 -0
  163. package/src/wallet/utils/index.ts +3 -0
  164. package/src/wallet/utils/stellarWalletImplementationManager.ts +118 -0
  165. package/src/wallet/utils/uiKitService.ts +74 -0
@@ -0,0 +1,151 @@
1
+ import type { Connector } from '@openzeppelin/ui-types';
2
+ import { logger } from '@openzeppelin/ui-utils';
3
+
4
+ import {
5
+ getInitializedStellarWalletImplementation,
6
+ getStellarWalletImplementation,
7
+ } from './utils/stellarWalletImplementationManager';
8
+
9
+ import { stellarUiKitManager } from './stellar-wallets-kit';
10
+ import { StellarConnectionStatusListener } from './types';
11
+
12
+ /**
13
+ * Indicates if this adapter supports wallet connection
14
+ * @returns Whether wallet connection is supported by this adapter
15
+ */
16
+ export function supportsStellarWalletConnection(): boolean {
17
+ return true;
18
+ }
19
+
20
+ /**
21
+ * Get available Stellar wallet connectors
22
+ */
23
+ export async function getStellarAvailableConnectors(): Promise<Connector[]> {
24
+ const impl = await getStellarWalletImplementation();
25
+ return impl.getAvailableConnectors();
26
+ }
27
+
28
+ /**
29
+ * Connect to a Stellar wallet
30
+ * @param connectorId - The ID of the wallet to connect to
31
+ */
32
+ export async function connectStellarWallet(
33
+ connectorId: string
34
+ ): Promise<{ connected: boolean; address?: string; error?: string }> {
35
+ const impl = await getStellarWalletImplementation();
36
+ return impl.connect(connectorId);
37
+ }
38
+
39
+ /**
40
+ * Disconnect from the current Stellar wallet
41
+ */
42
+ export async function disconnectStellarWallet(): Promise<{
43
+ disconnected: boolean;
44
+ error?: string;
45
+ }> {
46
+ const impl = await getStellarWalletImplementation();
47
+ return impl.disconnect();
48
+ }
49
+
50
+ /**
51
+ * Get the current wallet connection status
52
+ * @inheritdoc
53
+ */
54
+ export function getStellarWalletConnectionStatus(): {
55
+ isConnected: boolean;
56
+ address?: string;
57
+ chainId?: string;
58
+ walletId?: string;
59
+ } {
60
+ const impl = getInitializedStellarWalletImplementation();
61
+ if (!impl) {
62
+ logger.warn(
63
+ 'getStellarWalletConnectionStatus',
64
+ 'Wallet implementation not ready. Returning default disconnected state.'
65
+ );
66
+ return {
67
+ isConnected: false,
68
+ address: undefined,
69
+ chainId: stellarUiKitManager.getState().networkConfig?.id || 'stellar-testnet',
70
+ walletId: undefined,
71
+ };
72
+ }
73
+
74
+ const status = impl.getWalletConnectionStatus();
75
+ return {
76
+ isConnected: status.isConnected,
77
+ address: status.address,
78
+ chainId: typeof status.chainId === 'number' ? status.chainId.toString() : status.chainId,
79
+ walletId: status.walletId,
80
+ };
81
+ }
82
+
83
+ /**
84
+ * Update the cached Stellar wallet connection state.
85
+ * Used by provider code that derives the address directly from the kit.
86
+ */
87
+ export function setStellarConnectedAddress(address: string | null, walletId?: string | null): void {
88
+ const impl = getInitializedStellarWalletImplementation();
89
+ if (impl) {
90
+ impl.updateConnectionStatus(address, walletId);
91
+ } else {
92
+ logger.warn(
93
+ 'setStellarConnectedAddress',
94
+ 'Wallet implementation not ready. Cannot update connection status.'
95
+ );
96
+ }
97
+ }
98
+
99
+ // StellarConnectionStatusListener is now imported from the implementation file
100
+
101
+ /**
102
+ * Subscribe to Stellar wallet connection status changes
103
+ * @param callback Function to call when connection status changes
104
+ * @returns Unsubscribe function
105
+ */
106
+ export function onStellarWalletConnectionChange(
107
+ callback: StellarConnectionStatusListener
108
+ ): () => void {
109
+ const impl = getInitializedStellarWalletImplementation();
110
+ if (!impl) {
111
+ logger.warn(
112
+ 'onStellarWalletConnectionChange',
113
+ 'Wallet implementation not ready. Returning no-op.'
114
+ );
115
+ return () => {};
116
+ }
117
+
118
+ // Convert from implementation status format to connection format
119
+ return impl.onWalletConnectionChange((currentImplStatus, prevImplStatus) => {
120
+ const currentStatus = {
121
+ isConnected: currentImplStatus.isConnected,
122
+ address: currentImplStatus.address,
123
+ chainId: currentImplStatus.chainId,
124
+ walletId: currentImplStatus.walletId,
125
+ };
126
+ const previousStatus = {
127
+ isConnected: prevImplStatus.isConnected,
128
+ address: prevImplStatus.address,
129
+ chainId: prevImplStatus.chainId,
130
+ walletId: prevImplStatus.walletId,
131
+ };
132
+
133
+ try {
134
+ callback(currentStatus, previousStatus);
135
+ } catch (error) {
136
+ logger.error('Error in Stellar connection status listener:', String(error));
137
+ }
138
+ });
139
+ }
140
+
141
+ /**
142
+ * Sign a transaction using the connected wallet
143
+ * @internal
144
+ */
145
+ export async function signTransaction(
146
+ xdr: string,
147
+ address: string
148
+ ): Promise<{ signedTxXdr: string }> {
149
+ const impl = await getStellarWalletImplementation();
150
+ return impl.signTransaction(xdr, address);
151
+ }
@@ -0,0 +1,32 @@
1
+ import type { ISupportedWallet, StellarWalletsKit } from '@creit.tech/stellar-wallets-kit';
2
+ import { createContext } from 'react';
3
+
4
+ import type { StellarUiKitManagerState } from '../stellar-wallets-kit';
5
+
6
+ /**
7
+ * Stellar wallet context type
8
+ */
9
+ export interface StellarWalletContextType {
10
+ // Connection state
11
+ address: string | null;
12
+ isConnected: boolean;
13
+ isConnecting: boolean;
14
+
15
+ // Available wallets
16
+ availableWallets: ISupportedWallet[];
17
+
18
+ // Connection methods
19
+ connect: (walletId: string) => Promise<void>;
20
+ disconnect: () => Promise<void>;
21
+
22
+ // UI Kit manager state
23
+ uiKitManagerState: StellarUiKitManagerState;
24
+
25
+ // Kit instance (for advanced usage)
26
+ kit: StellarWalletsKit | null;
27
+ }
28
+
29
+ /**
30
+ * Create the context with undefined default value
31
+ */
32
+ export const StellarWalletContext = createContext<StellarWalletContextType | undefined>(undefined);
@@ -0,0 +1,4 @@
1
+ // Re-export from components directory to maintain backwards compatibility
2
+ export { StellarWalletUiRoot } from '../components/StellarWalletUiRoot';
3
+ export * from './StellarWalletContext';
4
+ export * from './useStellarWalletContext';
@@ -0,0 +1,17 @@
1
+ import { useContext } from 'react';
2
+
3
+ import { StellarWalletContext, type StellarWalletContextType } from './StellarWalletContext';
4
+
5
+ /**
6
+ * Hook to use the Stellar wallet context
7
+ * @throws Error if used outside of StellarWalletUiRoot
8
+ */
9
+ export function useStellarWalletContext(): StellarWalletContextType {
10
+ const context = useContext(StellarWalletContext);
11
+
12
+ if (context === undefined) {
13
+ throw new Error('useStellarWalletContext must be used within a StellarWalletUiRoot');
14
+ }
15
+
16
+ return context;
17
+ }
@@ -0,0 +1,31 @@
1
+ import type { EcosystemSpecificReactHooks } from '@openzeppelin/ui-types';
2
+
3
+ import { useStellarAccount } from './useStellarAccount';
4
+ import { useStellarConnect } from './useStellarConnect';
5
+ import { useStellarDisconnect } from './useStellarDisconnect';
6
+
7
+ /**
8
+ * Stellar-specific facade hooks following the EcosystemSpecificReactHooks interface
9
+ * These hooks provide a standardized interface for wallet operations in the Stellar ecosystem
10
+ */
11
+ export const stellarFacadeHooks: EcosystemSpecificReactHooks = {
12
+ // Account management
13
+ useAccount: useStellarAccount,
14
+
15
+ // Connection management
16
+ useConnect: useStellarConnect,
17
+ useDisconnect: useStellarDisconnect,
18
+
19
+ // Stellar doesn't have the same network switching capabilities as EVM
20
+ // These are included for interface compatibility but may not be fully functional
21
+ useSwitchChain: () => ({ switchChain: undefined }),
22
+ useChainId: () => 'stellar',
23
+ useChains: () => [],
24
+
25
+ // Transaction and signing hooks - to be implemented as needed
26
+ useBalance: () => ({ data: undefined, isLoading: false }),
27
+ useSendTransaction: () => ({ sendTransaction: undefined }),
28
+ useWaitForTransactionReceipt: () => ({ data: undefined }),
29
+ useSignMessage: () => ({ signMessage: undefined }),
30
+ useSignTypedData: () => ({ signTypedData: undefined }),
31
+ };
@@ -0,0 +1,7 @@
1
+ // Barrel file for Stellar wallet hooks
2
+
3
+ export * from './facade-hooks';
4
+ export * from './useStellarAccount';
5
+ export * from './useStellarConnect';
6
+ export * from './useStellarDisconnect';
7
+ export * from './useUiKitConfig';
@@ -0,0 +1,27 @@
1
+ import { useStellarWalletContext } from '../context';
2
+
3
+ /**
4
+ * Account information returned by the hook
5
+ */
6
+ export interface StellarAccountInfo {
7
+ /** The connected wallet address */
8
+ address: string | null;
9
+ /** Whether a wallet is currently connected */
10
+ isConnected: boolean;
11
+ /** Whether a connection is in progress */
12
+ isConnecting: boolean;
13
+ }
14
+
15
+ /**
16
+ * Hook to get the current Stellar account information
17
+ * @returns Account information including address and connection status
18
+ */
19
+ export function useStellarAccount(): StellarAccountInfo {
20
+ const { address, isConnected, isConnecting } = useStellarWalletContext();
21
+
22
+ return {
23
+ address,
24
+ isConnected,
25
+ isConnecting,
26
+ };
27
+ }
@@ -0,0 +1,60 @@
1
+ import type { ISupportedWallet } from '@creit.tech/stellar-wallets-kit';
2
+ import { useCallback, useState } from 'react';
3
+
4
+ import type { Connector } from '@openzeppelin/ui-types';
5
+
6
+ import { useStellarWalletContext } from '../context';
7
+
8
+ /**
9
+ * Connect hook return type - matches what react-core expects
10
+ */
11
+ export interface StellarConnectReturnType {
12
+ connect: (args: { connector: Connector }) => Promise<void>;
13
+ connectors: Connector[];
14
+ isLoading: boolean;
15
+ isPending: boolean;
16
+ error: Error | null;
17
+ }
18
+
19
+ /**
20
+ * Hook to get the wallet connect function and status
21
+ * @returns An object with connect function and connection status
22
+ */
23
+ export function useStellarConnect(): StellarConnectReturnType {
24
+ const { connect, isConnecting, availableWallets } = useStellarWalletContext();
25
+ const [error, setError] = useState<Error | null>(null);
26
+
27
+ const connectFunction = useCallback(
28
+ async ({ connector }: { connector: Connector }) => {
29
+ try {
30
+ // Clear any previous errors
31
+ setError(null);
32
+ await connect(connector.id);
33
+ } catch (err) {
34
+ // Store the error for access by the consumer
35
+ const connectError = err instanceof Error ? err : new Error(String(err));
36
+ setError(connectError);
37
+ // Re-throw to maintain the same behavior for error handling in UI components
38
+ throw connectError;
39
+ }
40
+ },
41
+ [connect]
42
+ );
43
+
44
+ // Convert ISupportedWallet[] to Connector[]
45
+ const connectors: Connector[] = availableWallets.map((wallet: ISupportedWallet) => ({
46
+ id: wallet.id,
47
+ name: wallet.name,
48
+ icon: wallet.icon,
49
+ installed: wallet.isAvailable,
50
+ type: (wallet.type as string) || 'browser',
51
+ }));
52
+
53
+ return {
54
+ connect: connectFunction,
55
+ connectors,
56
+ isLoading: isConnecting,
57
+ isPending: isConnecting,
58
+ error,
59
+ };
60
+ }
@@ -0,0 +1,47 @@
1
+ import { useCallback, useState } from 'react';
2
+
3
+ import { useStellarWalletContext } from '../context';
4
+
5
+ /**
6
+ * Disconnect hook return type - matches what react-core expects
7
+ */
8
+ export interface StellarDisconnectReturnType {
9
+ disconnect: () => Promise<void>;
10
+ isLoading: boolean;
11
+ isPending: boolean;
12
+ error: Error | null;
13
+ }
14
+
15
+ /**
16
+ * Hook to get the wallet disconnect function and status
17
+ * @returns An object with disconnect function and disconnection status
18
+ */
19
+ export function useStellarDisconnect(): StellarDisconnectReturnType {
20
+ const { disconnect } = useStellarWalletContext();
21
+ const [isDisconnecting, setIsDisconnecting] = useState(false);
22
+ const [error, setError] = useState<Error | null>(null);
23
+
24
+ const disconnectFunction = useCallback(async () => {
25
+ try {
26
+ // Clear any previous errors
27
+ setError(null);
28
+ setIsDisconnecting(true);
29
+ await disconnect();
30
+ } catch (err) {
31
+ // Store the error for access by the consumer
32
+ const disconnectError = err instanceof Error ? err : new Error(String(err));
33
+ setError(disconnectError);
34
+ // Re-throw to maintain the same behavior for error handling in UI components
35
+ throw disconnectError;
36
+ } finally {
37
+ setIsDisconnecting(false);
38
+ }
39
+ }, [disconnect]);
40
+
41
+ return {
42
+ disconnect: disconnectFunction,
43
+ isLoading: isDisconnecting,
44
+ isPending: isDisconnecting,
45
+ error,
46
+ };
47
+ }
@@ -0,0 +1,40 @@
1
+ import type { UiKitConfiguration } from '@openzeppelin/ui-types';
2
+ import { appConfigService, logger } from '@openzeppelin/ui-utils';
3
+
4
+ /**
5
+ * Default configuration when no specific configuration is provided
6
+ */
7
+ const defaultConfig: UiKitConfiguration = {
8
+ kitName: 'custom', // Default to using our custom implementation for Stellar
9
+ kitConfig: {},
10
+ };
11
+
12
+ /**
13
+ * Loads the initial UI kit configuration from the AppConfigService
14
+ * @returns The UI kit configuration from app.config.local.json or defaults
15
+ */
16
+ export function loadInitialConfigFromAppService(): UiKitConfiguration {
17
+ logger.debug(
18
+ 'stellar:useUiKitConfig',
19
+ 'Attempting to load initial config from AppConfigService...'
20
+ );
21
+ const configObj = appConfigService.getWalletUIConfig<UiKitConfiguration>('stellar');
22
+
23
+ if (configObj && configObj.kitName) {
24
+ logger.info(
25
+ 'stellar:useUiKitConfig',
26
+ `Loaded initial config from AppConfigService: kitName=${configObj.kitName}`,
27
+ configObj.kitConfig
28
+ );
29
+ // Merge with defaults to ensure all base keys are present if AppConfigService only provides partial config
30
+ return {
31
+ kitName: configObj.kitName,
32
+ kitConfig: { ...defaultConfig.kitConfig, ...(configObj.kitConfig || {}) },
33
+ };
34
+ }
35
+ logger.debug(
36
+ 'stellar:useUiKitConfig',
37
+ 'No initial config found in AppConfigService, using module default.'
38
+ );
39
+ return { ...defaultConfig };
40
+ }