@explorins/pers-sdk-react-native 1.3.2
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/README.md +200 -0
- package/dist/hooks/index.d.ts +8 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +8 -0
- package/dist/hooks/useAuth.d.ts +12 -0
- package/dist/hooks/useAuth.d.ts.map +1 -0
- package/dist/hooks/useAuth.js +16 -0
- package/dist/hooks/useBusiness.d.ts +7 -0
- package/dist/hooks/useBusiness.d.ts.map +1 -0
- package/dist/hooks/useBusiness.js +64 -0
- package/dist/hooks/useCampaigns.d.ts +8 -0
- package/dist/hooks/useCampaigns.d.ts.map +1 -0
- package/dist/hooks/useCampaigns.js +90 -0
- package/dist/hooks/useRedemptions.d.ts +9 -0
- package/dist/hooks/useRedemptions.d.ts.map +1 -0
- package/dist/hooks/useRedemptions.js +121 -0
- package/dist/hooks/useTokens.d.ts +6 -0
- package/dist/hooks/useTokens.d.ts.map +1 -0
- package/dist/hooks/useTokens.js +48 -0
- package/dist/hooks/useTransactions.d.ts +7 -0
- package/dist/hooks/useTransactions.d.ts.map +1 -0
- package/dist/hooks/useTransactions.js +78 -0
- package/dist/hooks/useWeb3.d.ts +11 -0
- package/dist/hooks/useWeb3.d.ts.map +1 -0
- package/dist/hooks/useWeb3.js +63 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.esm.js +1057 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.js +1077 -0
- package/dist/index.js.map +1 -0
- package/dist/polyfills/index.d.ts +3 -0
- package/dist/polyfills/index.d.ts.map +1 -0
- package/dist/polyfills/index.js +13 -0
- package/dist/polyfills/index.simple.d.ts +2 -0
- package/dist/polyfills/index.simple.d.ts.map +1 -0
- package/dist/polyfills/index.simple.js +17 -0
- package/dist/providers/PersSDKProvider.d.ts +29 -0
- package/dist/providers/PersSDKProvider.d.ts.map +1 -0
- package/dist/providers/PersSDKProvider.js +194 -0
- package/dist/providers/react-native-auth-provider.d.ts +92 -0
- package/dist/providers/react-native-auth-provider.d.ts.map +1 -0
- package/dist/providers/react-native-auth-provider.js +268 -0
- package/dist/providers/react-native-http-client.d.ts +29 -0
- package/dist/providers/react-native-http-client.d.ts.map +1 -0
- package/dist/providers/react-native-http-client.js +94 -0
- package/package.json +157 -0
- package/src/hooks/index.ts +8 -0
- package/src/hooks/useAuth.ts +43 -0
- package/src/hooks/useBusiness.ts +69 -0
- package/src/hooks/useCampaigns.ts +96 -0
- package/src/hooks/useRedemptions.ts +129 -0
- package/src/hooks/useTokens.ts +53 -0
- package/src/hooks/useTransactions.ts +85 -0
- package/src/hooks/useWeb3.ts +70 -0
- package/src/index.ts +51 -0
- package/src/polyfills/index.simple.ts +22 -0
- package/src/polyfills/index.ts +16 -0
- package/src/providers/PersSDKProvider.tsx +274 -0
- package/src/providers/react-native-auth-provider.ts +332 -0
- package/src/providers/react-native-http-client.ts +129 -0
- package/src/types/external-modules.d.ts +13 -0
- package/src/types/react-native-globals.d.ts +46 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { useCallback } from 'react';
|
|
2
|
+
import { usePersSDK } from '../providers/PersSDKProvider';
|
|
3
|
+
export const useTransactions = () => {
|
|
4
|
+
const { transactions, isInitialized, isAuthenticated } = usePersSDK();
|
|
5
|
+
if (!isAuthenticated && isInitialized) {
|
|
6
|
+
console.warn('SDK not authenticated. Some transaction operations may fail.');
|
|
7
|
+
}
|
|
8
|
+
const createTransaction = useCallback(async (request) => {
|
|
9
|
+
if (!isInitialized) {
|
|
10
|
+
throw new Error('SDK not initialized. Call initialize() first.');
|
|
11
|
+
}
|
|
12
|
+
if (!transactions?.createTransaction) {
|
|
13
|
+
throw new Error('createTransaction method not available');
|
|
14
|
+
}
|
|
15
|
+
try {
|
|
16
|
+
console.log('🔄 Creating transaction with request:', request);
|
|
17
|
+
const result = await transactions.createTransaction(request);
|
|
18
|
+
// React Native specific: Handle signature URLs
|
|
19
|
+
if (result?.actionable?.actionUrl) {
|
|
20
|
+
try {
|
|
21
|
+
const { Linking } = require('react-native');
|
|
22
|
+
console.log('🔗 Opening signature URL:', result.actionable.actionUrl);
|
|
23
|
+
await Linking.openURL(result.actionable.actionUrl);
|
|
24
|
+
}
|
|
25
|
+
catch (linkingError) {
|
|
26
|
+
console.error('❌ Failed to open signature URL:', linkingError);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
console.log('✅ Transaction created successfully:', result);
|
|
30
|
+
return result;
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
console.error('❌ Failed to create transaction:', error);
|
|
34
|
+
throw error;
|
|
35
|
+
}
|
|
36
|
+
}, [transactions]);
|
|
37
|
+
const getTransactionById = useCallback(async (transactionId) => {
|
|
38
|
+
if (!isInitialized) {
|
|
39
|
+
throw new Error('SDK not initialized. Call initialize() first.');
|
|
40
|
+
}
|
|
41
|
+
if (!transactions?.getTransactionById) {
|
|
42
|
+
throw new Error('getTransactionById method not available');
|
|
43
|
+
}
|
|
44
|
+
try {
|
|
45
|
+
const result = await transactions.getTransactionById(transactionId);
|
|
46
|
+
console.log('✅ Transaction fetched successfully:', result);
|
|
47
|
+
return result;
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
console.error('❌ Failed to fetch transaction:', error);
|
|
51
|
+
throw error;
|
|
52
|
+
}
|
|
53
|
+
}, [transactions]);
|
|
54
|
+
const getTransactionHistory = useCallback(async (filters) => {
|
|
55
|
+
if (!isInitialized) {
|
|
56
|
+
throw new Error('SDK not initialized. Call initialize() first.');
|
|
57
|
+
}
|
|
58
|
+
if (!transactions?.getTransactionHistory) {
|
|
59
|
+
console.warn('getTransactionHistory method not available');
|
|
60
|
+
return [];
|
|
61
|
+
}
|
|
62
|
+
try {
|
|
63
|
+
const result = await transactions.getTransactionHistory(filters);
|
|
64
|
+
console.log('✅ Transaction history fetched successfully:', result);
|
|
65
|
+
return result;
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
console.error('❌ Failed to fetch transaction history:', error);
|
|
69
|
+
throw error;
|
|
70
|
+
}
|
|
71
|
+
}, [transactions]);
|
|
72
|
+
return {
|
|
73
|
+
createTransaction,
|
|
74
|
+
getTransactionById,
|
|
75
|
+
getTransactionHistory,
|
|
76
|
+
isAvailable: isInitialized && !!transactions,
|
|
77
|
+
};
|
|
78
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const useWeb3: () => {
|
|
2
|
+
getTokenBalance: (request: any) => Promise<any>;
|
|
3
|
+
getTokenCollection: (request: any) => Promise<any>;
|
|
4
|
+
getWalletInfo: () => Promise<{
|
|
5
|
+
address: string;
|
|
6
|
+
isConnected: boolean;
|
|
7
|
+
} | null>;
|
|
8
|
+
accountAddress: string | null;
|
|
9
|
+
isAvailable: boolean;
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=useWeb3.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useWeb3.d.ts","sourceRoot":"","sources":["../../src/hooks/useWeb3.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,OAAO;+BAOkC,GAAG;kCAkBA,GAAG;;;;;;;CAyC3D,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { useCallback } from 'react';
|
|
2
|
+
import { usePersSDK } from '../providers/PersSDKProvider';
|
|
3
|
+
export const useWeb3 = () => {
|
|
4
|
+
const { web3, isInitialized, isAuthenticated, accountAddress } = usePersSDK();
|
|
5
|
+
if (!isAuthenticated && isInitialized) {
|
|
6
|
+
console.warn('SDK not authenticated. Some web3 operations may fail.');
|
|
7
|
+
}
|
|
8
|
+
const getTokenBalance = useCallback(async (request) => {
|
|
9
|
+
if (!isInitialized) {
|
|
10
|
+
throw new Error('SDK not initialized. Call initialize() first.');
|
|
11
|
+
}
|
|
12
|
+
if (!web3?.getTokenBalance) {
|
|
13
|
+
throw new Error('getTokenBalance method not available');
|
|
14
|
+
}
|
|
15
|
+
try {
|
|
16
|
+
const result = await web3.getTokenBalance(request);
|
|
17
|
+
console.log('✅ Token balance fetched successfully:', result);
|
|
18
|
+
return result;
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
console.error('❌ Failed to fetch token balance:', error);
|
|
22
|
+
throw error;
|
|
23
|
+
}
|
|
24
|
+
}, [web3]);
|
|
25
|
+
const getTokenCollection = useCallback(async (request) => {
|
|
26
|
+
if (!isInitialized) {
|
|
27
|
+
throw new Error('SDK not initialized. Call initialize() first.');
|
|
28
|
+
}
|
|
29
|
+
if (!web3?.getTokenCollection) {
|
|
30
|
+
console.warn('getTokenCollection method not available');
|
|
31
|
+
return [];
|
|
32
|
+
}
|
|
33
|
+
try {
|
|
34
|
+
const result = await web3.getTokenCollection(request);
|
|
35
|
+
console.log('✅ Token collection fetched successfully:', result);
|
|
36
|
+
return result;
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
console.error('❌ Failed to fetch token collection:', error);
|
|
40
|
+
throw error;
|
|
41
|
+
}
|
|
42
|
+
}, [web3]);
|
|
43
|
+
const getWalletInfo = useCallback(async () => {
|
|
44
|
+
if (!isInitialized) {
|
|
45
|
+
throw new Error('SDK not initialized. Call initialize() first.');
|
|
46
|
+
}
|
|
47
|
+
if (!accountAddress) {
|
|
48
|
+
console.warn('No account address available');
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
address: accountAddress,
|
|
53
|
+
isConnected: !!accountAddress,
|
|
54
|
+
};
|
|
55
|
+
}, [isInitialized, accountAddress]);
|
|
56
|
+
return {
|
|
57
|
+
getTokenBalance,
|
|
58
|
+
getTokenCollection,
|
|
59
|
+
getWalletInfo,
|
|
60
|
+
accountAddress: isInitialized ? accountAddress : null,
|
|
61
|
+
isAvailable: isInitialized && !!web3,
|
|
62
|
+
};
|
|
63
|
+
};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import './polyfills';
|
|
2
|
+
export { BaseReactNativeAuthProvider, ReactNativeAuthProvider, SecureReactNativeAuthProvider, StorageStrategy, type ReactNativeAuthConfig } from './providers/react-native-auth-provider';
|
|
3
|
+
export { PersSDKProvider, usePersSDK, type PersSDKConfig, type PersSDKContext } from './providers/PersSDKProvider';
|
|
4
|
+
export { useAuth, useTokens, useTransactions, useBusiness, useCampaigns, useRedemptions, useWeb3 } from './hooks';
|
|
5
|
+
export { ReactNativeHttpClient } from './providers/react-native-http-client';
|
|
6
|
+
export { initializeReactNativePolyfills, isReactNative } from './polyfills';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,aAAa,CAAC;AAMrB,OAAO,EACL,2BAA2B,EAC3B,uBAAuB,EACvB,6BAA6B,EAC7B,eAAe,EACf,KAAK,qBAAqB,EAC3B,MAAM,wCAAwC,CAAC;AAKhD,OAAO,EACL,eAAe,EACf,UAAU,EACV,KAAK,aAAa,EAClB,KAAK,cAAc,EACpB,MAAM,6BAA6B,CAAC;AAGrC,OAAO,EACL,OAAO,EACP,SAAS,EACT,eAAe,EACf,WAAW,EACX,YAAY,EACZ,cAAc,EACd,OAAO,EACR,MAAM,SAAS,CAAC;AAIjB,OAAO,EACL,qBAAqB,EACtB,MAAM,sCAAsC,CAAC;AAG9C,OAAO,EACL,8BAA8B,EAC9B,aAAa,EACd,MAAM,aAAa,CAAC"}
|