@openfort/react-native 0.1.8 → 0.1.9

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.
@@ -67,7 +67,7 @@ export function useWallets(hookOptions = {}) {
67
67
  isActive: true,
68
68
  isConnecting: false,
69
69
  getProvider: async () => {
70
- return await client.embeddedWallet.getEthereumProvider({ announceProvider: false });
70
+ return await getEthereumProvider();
71
71
  },
72
72
  };
73
73
  }, [activeWalletId, embeddedAccounts, client.embeddedWallet]);
@@ -152,7 +152,7 @@ export function useWallets(hookOptions = {}) {
152
152
  isActive: true,
153
153
  isConnecting: false,
154
154
  getProvider: async () => {
155
- return await client.embeddedWallet.getEthereumProvider({ announceProvider: false });
155
+ return await getEthereumProvider();
156
156
  },
157
157
  };
158
158
  recoverPromiseRef.current = null;
@@ -201,6 +201,24 @@ export function useWallets(hookOptions = {}) {
201
201
  useEffect(() => {
202
202
  fetchEmbeddedWallets();
203
203
  }, [fetchEmbeddedWallets]);
204
+ const getEthereumProvider = useCallback(async () => {
205
+ const resolvePolicy = () => {
206
+ const ethereumProviderPolicyId = walletConfig?.ethereumProviderPolicyId;
207
+ if (!ethereumProviderPolicyId)
208
+ return undefined;
209
+ if (typeof ethereumProviderPolicyId === "string") {
210
+ return ethereumProviderPolicyId;
211
+ }
212
+ if (!hookOptions.chainId)
213
+ return undefined;
214
+ const policy = ethereumProviderPolicyId[hookOptions.chainId];
215
+ if (!policy) {
216
+ return undefined;
217
+ }
218
+ return policy;
219
+ };
220
+ return await client.embeddedWallet.getEthereumProvider({ announceProvider: false, policy: resolvePolicy() });
221
+ }, [client.embeddedWallet]);
204
222
  useEffect(() => {
205
223
  (async () => {
206
224
  try {
@@ -228,7 +246,7 @@ export function useWallets(hookOptions = {}) {
228
246
  isActive: activeWalletId === account.id,
229
247
  isConnecting: status.status === "connecting" && status.address === account.address,
230
248
  getProvider: async () => {
231
- return await client.embeddedWallet.getEthereumProvider({ announceProvider: false });
249
+ return await getEthereumProvider();
232
250
  },
233
251
  }))), [embeddedAccounts, activeWalletId, status.status === "connecting", client.embeddedWallet]);
234
252
  const create = useCallback(async (options) => {
@@ -279,10 +297,7 @@ export function useWallets(hookOptions = {}) {
279
297
  });
280
298
  logger.info('Embedded wallet configured with shield authentication');
281
299
  // Get the Ethereum provider
282
- const provider = await client.embeddedWallet.getEthereumProvider({
283
- announceProvider: false,
284
- ...(options?.policyId && { policy: options.policyId }),
285
- });
300
+ const provider = await getEthereumProvider();
286
301
  // Refetch the list of wallets to ensure the state is up to date
287
302
  await fetchEmbeddedWallets();
288
303
  setActiveWalletId(embeddedAccount.id);
@@ -343,7 +358,7 @@ export function useWallets(hookOptions = {}) {
343
358
  isActive: true,
344
359
  isConnecting: false,
345
360
  getProvider: async () => {
346
- return await client.embeddedWallet.getEthereumProvider({ announceProvider: false });
361
+ return await getEthereumProvider();
347
362
  }
348
363
  }
349
364
  }
@@ -8,11 +8,12 @@ interface CustomAuthConfig {
8
8
  isLoading: boolean;
9
9
  getCustomAccessToken: () => Promise<string | null>;
10
10
  }
11
+ type PolicyConfig = string | Record<number, string>;
11
12
  export type CommonEmbeddedWalletConfiguration = {
12
13
  /** Publishable key for the Shield API */
13
14
  shieldPublishableKey: string;
14
15
  /** Policy ID (pol_...) for the embedded signer */
15
- ethereumProviderPolicyId?: string;
16
+ ethereumProviderPolicyId?: PolicyConfig;
16
17
  accountType?: AccountTypeEnum;
17
18
  debug?: boolean;
18
19
  };
@@ -20,7 +20,6 @@ type CreateWalletResult = SetActiveWalletResult;
20
20
  type CreateWalletOptions = {
21
21
  chainType?: ChainTypeEnum;
22
22
  chainId?: number;
23
- policyId?: string;
24
23
  recoveryPassword?: string;
25
24
  accountType?: AccountTypeEnum;
26
25
  } & OpenfortHookOptions<CreateWalletResult>;
@@ -29,7 +28,9 @@ type SetRecoveryOptions = {
29
28
  previousRecovery: RecoveryParams;
30
29
  newRecovery: RecoveryParams;
31
30
  } & OpenfortHookOptions<CreateWalletResult>;
32
- type WalletOptions = OpenfortHookOptions<SetActiveWalletResult | CreateWalletResult>;
31
+ type WalletOptions = {
32
+ chainId?: number;
33
+ } & OpenfortHookOptions<SetActiveWalletResult | CreateWalletResult>;
33
34
  /**
34
35
  * Hook for interacting with embedded Ethereum wallets
35
36
  *
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@openfort/react-native",
3
3
  "main": "dist/index.js",
4
- "version": "0.1.8",
4
+ "version": "0.1.9",
5
5
  "license": "MIT",
6
6
  "description": "React Native SDK for Openfort platform integration",
7
7
  "scripts": {
@@ -23,7 +23,7 @@
23
23
  }
24
24
  },
25
25
  "dependencies": {
26
- "@openfort/openfort-js": "^0.10.16"
26
+ "@openfort/openfort-js": "^0.10.18"
27
27
  },
28
28
  "peerDependencies": {
29
29
  "expo-apple-authentication": "*",