@openzeppelin/ui-builder-adapter-stellar 0.13.0 → 0.14.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.
@@ -3,6 +3,8 @@ import { allowAllModules, StellarWalletsKit, WalletNetwork } from '@creit.tech/s
3
3
  import type { StellarNetworkConfig, UiKitConfiguration } from '@openzeppelin/ui-builder-types';
4
4
  import { logger } from '@openzeppelin/ui-builder-utils';
5
5
 
6
+ import { getStellarWalletImplementation } from '../utils/stellarWalletImplementationManager';
7
+
6
8
  export interface StellarUiKitManagerState {
7
9
  isConfigured: boolean;
8
10
  isInitializing: boolean;
@@ -112,6 +114,26 @@ async function configure(newFullUiKitConfig: UiKitConfiguration): Promise<void>
112
114
  state.kitProviderComponent = null;
113
115
  state.isKitAssetsLoaded = true;
114
116
  state.error = null;
117
+
118
+ // Wire the active kit into the wallet implementation
119
+ // This ensures signing and other operations use the correct kit instance
120
+ if (state.networkConfig) {
121
+ try {
122
+ const impl = await getStellarWalletImplementation(state.networkConfig);
123
+ impl.setActiveStellarKit(kit);
124
+ logger.debug(
125
+ 'StellarUiKitManager:configure',
126
+ 'Active kit wired into wallet implementation for stellar-wallets-kit'
127
+ );
128
+ } catch (error) {
129
+ logger.warn(
130
+ 'StellarUiKitManager:configure',
131
+ 'Failed to attach active kit to wallet implementation:',
132
+ error
133
+ );
134
+ }
135
+ }
136
+
115
137
  logger.info(
116
138
  'StellarUiKitManager:configure',
117
139
  'Stellar Wallets Kit configured with built-in UI and all wallet modules'
@@ -128,6 +150,26 @@ async function configure(newFullUiKitConfig: UiKitConfiguration): Promise<void>
128
150
  state.kitProviderComponent = null;
129
151
  state.isKitAssetsLoaded = true;
130
152
  state.error = null;
153
+
154
+ // Wire the active kit into the wallet implementation
155
+ // This ensures signing and other operations use the correct kit instance
156
+ if (state.networkConfig) {
157
+ try {
158
+ const impl = await getStellarWalletImplementation(state.networkConfig);
159
+ impl.setActiveStellarKit(kit);
160
+ logger.debug(
161
+ 'StellarUiKitManager:configure',
162
+ 'Active kit wired into wallet implementation for custom'
163
+ );
164
+ } catch (error) {
165
+ logger.warn(
166
+ 'StellarUiKitManager:configure',
167
+ 'Failed to attach active kit to wallet implementation:',
168
+ error
169
+ );
170
+ }
171
+ }
172
+
131
173
  logger.info(
132
174
  'StellarUiKitManager:configure',
133
175
  'Stellar Wallets Kit configured for custom UI components'
@@ -138,6 +180,25 @@ async function configure(newFullUiKitConfig: UiKitConfiguration): Promise<void>
138
180
  state.kitProviderComponent = null;
139
181
  state.isKitAssetsLoaded = false;
140
182
  state.error = null;
183
+
184
+ // Clear the active kit from the wallet implementation
185
+ if (state.networkConfig) {
186
+ try {
187
+ const impl = await getStellarWalletImplementation(state.networkConfig);
188
+ impl.setActiveStellarKit(null);
189
+ logger.debug(
190
+ 'StellarUiKitManager:configure',
191
+ 'Active kit cleared from wallet implementation for none'
192
+ );
193
+ } catch (error) {
194
+ logger.warn(
195
+ 'StellarUiKitManager:configure',
196
+ 'Failed to clear active kit from wallet implementation:',
197
+ error
198
+ );
199
+ }
200
+ }
201
+
141
202
  logger.info('StellarUiKitManager:configure', 'UI kit set to "none", no wallet UI provided');
142
203
  } else {
143
204
  throw new Error(`Unknown UI kit name: ${newKitName}`);