@openfort/react-native 0.1.7 → 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.
- package/dist/constants/config.js +1 -1
- package/dist/hooks/wallet/useWallets.js +23 -8
- package/dist/index.js +1 -1
- package/dist/types/constants/config.d.ts +1 -1
- package/dist/types/core/provider.d.ts +2 -1
- package/dist/types/hooks/wallet/useWallets.d.ts +3 -2
- package/dist/types/index.d.ts +1 -1
- package/package.json +5 -3
package/dist/constants/config.js
CHANGED
|
@@ -67,7 +67,7 @@ export function useWallets(hookOptions = {}) {
|
|
|
67
67
|
isActive: true,
|
|
68
68
|
isConnecting: false,
|
|
69
69
|
getProvider: async () => {
|
|
70
|
-
return await
|
|
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
|
|
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
|
|
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
|
|
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
|
|
361
|
+
return await getEthereumProvider();
|
|
347
362
|
}
|
|
348
363
|
}
|
|
349
364
|
}
|
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* for building decentralized applications on React Native.
|
|
7
7
|
*
|
|
8
8
|
* @author Openfort
|
|
9
|
-
* @version 0.1.
|
|
9
|
+
* @version 0.1.8
|
|
10
10
|
*/
|
|
11
11
|
// Re-export commonly used types from @openfort/openfort-js
|
|
12
12
|
export { OpenfortError, RecoveryMethod, Openfort as OpenfortClient, OpenfortConfiguration, ShieldConfiguration, EmbeddedState, } from '@openfort/openfort-js';
|
|
@@ -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?:
|
|
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 =
|
|
31
|
+
type WalletOptions = {
|
|
32
|
+
chainId?: number;
|
|
33
|
+
} & OpenfortHookOptions<SetActiveWalletResult | CreateWalletResult>;
|
|
33
34
|
/**
|
|
34
35
|
* Hook for interacting with embedded Ethereum wallets
|
|
35
36
|
*
|
package/dist/types/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* for building decentralized applications on React Native.
|
|
7
7
|
*
|
|
8
8
|
* @author Openfort
|
|
9
|
-
* @version 0.1.
|
|
9
|
+
* @version 0.1.8
|
|
10
10
|
*/
|
|
11
11
|
export { AuthPlayerResponse, OpenfortError, RecoveryMethod, Openfort as OpenfortClient, Provider, OpenfortConfiguration, ShieldConfiguration, EmbeddedState, } from '@openfort/openfort-js';
|
|
12
12
|
export { OAuthProvider, } from '@openfort/openfort-js';
|
package/package.json
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openfort/react-native",
|
|
3
3
|
"main": "dist/index.js",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.9",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "React Native SDK for Openfort platform integration",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"build": "rimraf dist && tsc",
|
|
9
9
|
"lint": "eslint . --ignore-pattern dist",
|
|
10
10
|
"link": "yarn link",
|
|
11
|
-
"unlink": "yarn unlink"
|
|
11
|
+
"unlink": "yarn unlink",
|
|
12
|
+
"docs:build": "typedoc"
|
|
12
13
|
},
|
|
13
14
|
"types": "dist/types/index.d.ts",
|
|
14
15
|
"files": [
|
|
@@ -22,7 +23,7 @@
|
|
|
22
23
|
}
|
|
23
24
|
},
|
|
24
25
|
"dependencies": {
|
|
25
|
-
"@openfort/openfort-js": "^0.10.
|
|
26
|
+
"@openfort/openfort-js": "^0.10.18"
|
|
26
27
|
},
|
|
27
28
|
"peerDependencies": {
|
|
28
29
|
"expo-apple-authentication": "*",
|
|
@@ -51,6 +52,7 @@
|
|
|
51
52
|
"react": "^18.3.1",
|
|
52
53
|
"react-native": "0.77.1",
|
|
53
54
|
"react-native-webview": "^13.15.0",
|
|
55
|
+
"typedoc": "^0.26.5",
|
|
54
56
|
"typescript": "^5.5.3",
|
|
55
57
|
"typescript-eslint": "^8.19.0"
|
|
56
58
|
},
|