@sudobility/contracts 0.15.1 → 1.10.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.
- package/README.md +2 -3
- package/artifacts/contracts/Mailer.sol/Mailer.d.ts +2 -185
- package/artifacts/contracts/Mailer.sol/Mailer.dbg.json +1 -1
- package/artifacts/contracts/Mailer.sol/Mailer.json +2 -185
- package/artifacts/contracts/MockUSDC.sol/MockUSDC.dbg.json +1 -1
- package/artifacts/contracts/interfaces/IERC20.sol/IERC20.dbg.json +1 -1
- package/dist/evm/src/evm/index.d.ts +1 -1
- package/dist/evm/src/evm/index.d.ts.map +1 -1
- package/dist/evm/src/evm/index.js +4 -4
- package/dist/evm/src/evm/index.js.map +1 -1
- package/dist/evm/src/evm/mailer-client.d.ts +210 -0
- package/dist/evm/src/evm/mailer-client.d.ts.map +1 -0
- package/dist/evm/src/evm/mailer-client.js +417 -0
- package/dist/evm/src/evm/mailer-client.js.map +1 -0
- package/dist/evm/typechain-types/Mailer.d.ts +10 -128
- package/dist/evm/typechain-types/Mailer.d.ts.map +1 -1
- package/dist/evm/typechain-types/factories/Mailer__factory.d.ts +1 -145
- package/dist/evm/typechain-types/factories/Mailer__factory.d.ts.map +1 -1
- package/dist/evm/typechain-types/factories/Mailer__factory.js +1 -184
- package/dist/evm/typechain-types/factories/Mailer__factory.js.map +1 -1
- package/dist/solana/solana/index.d.ts +1 -1
- package/dist/solana/solana/index.d.ts.map +1 -1
- package/dist/solana/solana/index.js +1 -4
- package/dist/solana/solana/index.js.map +1 -1
- package/dist/solana/solana/mailer-client.d.ts +209 -0
- package/dist/solana/solana/mailer-client.d.ts.map +1 -0
- package/dist/solana/solana/mailer-client.js +728 -0
- package/dist/solana/solana/mailer-client.js.map +1 -0
- package/dist/solana/solana/types.d.ts +2 -3
- package/dist/solana/solana/types.d.ts.map +1 -1
- package/dist/solana/solana/types.js.map +1 -1
- package/dist/unified/src/evm/index.d.ts +1 -1
- package/dist/unified/src/evm/index.d.ts.map +1 -1
- package/dist/unified/src/evm/index.js +4 -4
- package/dist/unified/src/evm/index.js.map +1 -1
- package/dist/unified/src/evm/mailer-client.d.ts +210 -0
- package/dist/unified/src/evm/mailer-client.d.ts.map +1 -0
- package/dist/unified/src/evm/mailer-client.js +417 -0
- package/dist/unified/src/evm/mailer-client.js.map +1 -0
- package/dist/unified/src/react/context/MailerProvider.d.ts +20 -26
- package/dist/unified/src/react/context/MailerProvider.d.ts.map +1 -1
- package/dist/unified/src/react/context/MailerProvider.js +26 -26
- package/dist/unified/src/react/context/MailerProvider.js.map +1 -1
- package/dist/unified/src/react/hooks/useMailerMutations.d.ts +192 -225
- package/dist/unified/src/react/hooks/useMailerMutations.d.ts.map +1 -1
- package/dist/unified/src/react/hooks/useMailerMutations.js +266 -263
- package/dist/unified/src/react/hooks/useMailerMutations.js.map +1 -1
- package/dist/unified/src/react/hooks/useMailerQueries.d.ts +63 -117
- package/dist/unified/src/react/hooks/useMailerQueries.d.ts.map +1 -1
- package/dist/unified/src/react/hooks/useMailerQueries.js +104 -239
- package/dist/unified/src/react/hooks/useMailerQueries.js.map +1 -1
- package/dist/unified/src/react/index.d.ts +3 -5
- package/dist/unified/src/react/index.d.ts.map +1 -1
- package/dist/unified/src/react/index.js +26 -41
- package/dist/unified/src/react/index.js.map +1 -1
- package/dist/unified/src/solana/index.d.ts +1 -1
- package/dist/unified/src/solana/index.d.ts.map +1 -1
- package/dist/unified/src/solana/index.js +1 -4
- package/dist/unified/src/solana/index.js.map +1 -1
- package/dist/unified/src/solana/mailer-client.d.ts +209 -0
- package/dist/unified/src/solana/mailer-client.d.ts.map +1 -0
- package/dist/unified/src/solana/mailer-client.js +728 -0
- package/dist/unified/src/solana/mailer-client.js.map +1 -0
- package/dist/unified/src/solana/types.d.ts +2 -3
- package/dist/unified/src/solana/types.d.ts.map +1 -1
- package/dist/unified/src/solana/types.js.map +1 -1
- package/dist/unified/src/unified/index.d.ts +1 -1
- package/dist/unified/src/unified/index.d.ts.map +1 -1
- package/dist/unified/src/unified/onchain-mailer-client.d.ts +247 -192
- package/dist/unified/src/unified/onchain-mailer-client.d.ts.map +1 -1
- package/dist/unified/src/unified/onchain-mailer-client.js +1462 -551
- package/dist/unified/src/unified/onchain-mailer-client.js.map +1 -1
- package/dist/unified/src/unified/types.d.ts +6 -23
- package/dist/unified/src/unified/types.d.ts.map +1 -1
- package/dist/unified/src/utils/chain-config.d.ts +2 -4
- package/dist/unified/src/utils/chain-config.d.ts.map +1 -1
- package/dist/unified/src/utils/chain-config.js +36 -46
- package/dist/unified/src/utils/chain-config.js.map +1 -1
- package/dist/unified/typechain-types/Mailer.d.ts +10 -128
- package/dist/unified/typechain-types/Mailer.d.ts.map +1 -1
- package/dist/unified/typechain-types/factories/Mailer__factory.d.ts +1 -145
- package/dist/unified/typechain-types/factories/Mailer__factory.d.ts.map +1 -1
- package/dist/unified/typechain-types/factories/Mailer__factory.js +1 -184
- package/dist/unified/typechain-types/factories/Mailer__factory.js.map +1 -1
- package/dist/unified-esm/src/evm/index.d.ts +1 -1
- package/dist/unified-esm/src/evm/index.d.ts.map +1 -1
- package/dist/unified-esm/src/evm/index.js +2 -2
- package/dist/unified-esm/src/evm/index.js.map +1 -1
- package/dist/unified-esm/src/evm/mailer-client.d.ts +210 -0
- package/dist/unified-esm/src/evm/mailer-client.d.ts.map +1 -0
- package/dist/unified-esm/src/evm/mailer-client.js +413 -0
- package/dist/unified-esm/src/evm/mailer-client.js.map +1 -0
- package/dist/unified-esm/src/react/context/MailerProvider.d.ts +20 -26
- package/dist/unified-esm/src/react/context/MailerProvider.d.ts.map +1 -1
- package/dist/unified-esm/src/react/context/MailerProvider.js +26 -25
- package/dist/unified-esm/src/react/context/MailerProvider.js.map +1 -1
- package/dist/unified-esm/src/react/hooks/useMailerMutations.d.ts +192 -225
- package/dist/unified-esm/src/react/hooks/useMailerMutations.d.ts.map +1 -1
- package/dist/unified-esm/src/react/hooks/useMailerMutations.js +262 -254
- package/dist/unified-esm/src/react/hooks/useMailerMutations.js.map +1 -1
- package/dist/unified-esm/src/react/hooks/useMailerQueries.d.ts +63 -117
- package/dist/unified-esm/src/react/hooks/useMailerQueries.d.ts.map +1 -1
- package/dist/unified-esm/src/react/hooks/useMailerQueries.js +102 -232
- package/dist/unified-esm/src/react/hooks/useMailerQueries.js.map +1 -1
- package/dist/unified-esm/src/react/index.d.ts +3 -5
- package/dist/unified-esm/src/react/index.d.ts.map +1 -1
- package/dist/unified-esm/src/react/index.js +5 -9
- package/dist/unified-esm/src/react/index.js.map +1 -1
- package/dist/unified-esm/src/solana/index.d.ts +1 -1
- package/dist/unified-esm/src/solana/index.d.ts.map +1 -1
- package/dist/unified-esm/src/solana/index.js +1 -2
- package/dist/unified-esm/src/solana/index.js.map +1 -1
- package/dist/unified-esm/src/solana/mailer-client.d.ts +209 -0
- package/dist/unified-esm/src/solana/mailer-client.d.ts.map +1 -0
- package/dist/unified-esm/src/solana/mailer-client.js +724 -0
- package/dist/unified-esm/src/solana/mailer-client.js.map +1 -0
- package/dist/unified-esm/src/solana/types.d.ts +2 -3
- package/dist/unified-esm/src/solana/types.d.ts.map +1 -1
- package/dist/unified-esm/src/solana/types.js.map +1 -1
- package/dist/unified-esm/src/unified/index.d.ts +1 -1
- package/dist/unified-esm/src/unified/index.d.ts.map +1 -1
- package/dist/unified-esm/src/unified/onchain-mailer-client.d.ts +247 -192
- package/dist/unified-esm/src/unified/onchain-mailer-client.d.ts.map +1 -1
- package/dist/unified-esm/src/unified/onchain-mailer-client.js +1462 -551
- package/dist/unified-esm/src/unified/onchain-mailer-client.js.map +1 -1
- package/dist/unified-esm/src/unified/types.d.ts +6 -23
- package/dist/unified-esm/src/unified/types.d.ts.map +1 -1
- package/dist/unified-esm/src/utils/chain-config.d.ts +2 -4
- package/dist/unified-esm/src/utils/chain-config.d.ts.map +1 -1
- package/dist/unified-esm/src/utils/chain-config.js +35 -46
- package/dist/unified-esm/src/utils/chain-config.js.map +1 -1
- package/dist/unified-esm/typechain-types/Mailer.d.ts +10 -128
- package/dist/unified-esm/typechain-types/Mailer.d.ts.map +1 -1
- package/dist/unified-esm/typechain-types/factories/Mailer__factory.d.ts +1 -145
- package/dist/unified-esm/typechain-types/factories/Mailer__factory.d.ts.map +1 -1
- package/dist/unified-esm/typechain-types/factories/Mailer__factory.js +1 -184
- package/dist/unified-esm/typechain-types/factories/Mailer__factory.js.map +1 -1
- package/package.json +10 -17
- package/programs/mailer/src/lib.rs +145 -764
- package/programs/mailer/tests/integration_tests.rs +65 -586
- package/typechain-types/Mailer.ts +8 -215
- package/typechain-types/factories/Mailer__factory.ts +1 -184
- package/dist/evm/src/evm/evm-mailer-client.d.ts +0 -1062
- package/dist/evm/src/evm/evm-mailer-client.d.ts.map +0 -1
- package/dist/evm/src/evm/evm-mailer-client.js +0 -924
- package/dist/evm/src/evm/evm-mailer-client.js.map +0 -1
- package/dist/solana/solana/solana-mailer-client.d.ts +0 -209
- package/dist/solana/solana/solana-mailer-client.d.ts.map +0 -1
- package/dist/solana/solana/solana-mailer-client.js +0 -1004
- package/dist/solana/solana/solana-mailer-client.js.map +0 -1
- package/dist/unified/src/evm/evm-mailer-client.d.ts +0 -1062
- package/dist/unified/src/evm/evm-mailer-client.d.ts.map +0 -1
- package/dist/unified/src/evm/evm-mailer-client.js +0 -924
- package/dist/unified/src/evm/evm-mailer-client.js.map +0 -1
- package/dist/unified/src/solana/solana-mailer-client.d.ts +0 -209
- package/dist/unified/src/solana/solana-mailer-client.d.ts.map +0 -1
- package/dist/unified/src/solana/solana-mailer-client.js +0 -1004
- package/dist/unified/src/solana/solana-mailer-client.js.map +0 -1
- package/dist/unified-esm/src/evm/evm-mailer-client.d.ts +0 -1062
- package/dist/unified-esm/src/evm/evm-mailer-client.d.ts.map +0 -1
- package/dist/unified-esm/src/evm/evm-mailer-client.js +0 -920
- package/dist/unified-esm/src/evm/evm-mailer-client.js.map +0 -1
- package/dist/unified-esm/src/solana/solana-mailer-client.d.ts +0 -209
- package/dist/unified-esm/src/solana/solana-mailer-client.d.ts.map +0 -1
- package/dist/unified-esm/src/solana/solana-mailer-client.js +0 -1000
- package/dist/unified-esm/src/solana/solana-mailer-client.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useQuery } from '@tanstack/react-query';
|
|
2
|
-
import {
|
|
2
|
+
import { useMailerClient } from '../context/MailerProvider.js';
|
|
3
3
|
/**
|
|
4
4
|
* Query keys for React Query cache management
|
|
5
5
|
*/
|
|
@@ -11,306 +11,176 @@ export const mailerQueryKeys = {
|
|
|
11
11
|
ownerClaimable: () => [...mailerQueryKeys.all, 'ownerClaimable'],
|
|
12
12
|
delegation: (address) => [...mailerQueryKeys.all, 'delegation', address],
|
|
13
13
|
isPaused: () => [...mailerQueryKeys.all, 'isPaused'],
|
|
14
|
-
permissions: (contractAddress, walletAddress) => [...mailerQueryKeys.all, 'permissions', contractAddress, walletAddress],
|
|
15
14
|
};
|
|
16
15
|
/**
|
|
17
|
-
* Hook
|
|
16
|
+
* Hook to get the current send fee
|
|
18
17
|
*
|
|
19
18
|
* @example
|
|
20
19
|
* ```tsx
|
|
21
20
|
* function FeeDisplay() {
|
|
22
|
-
* const {
|
|
21
|
+
* const { data: fee, isLoading } = useGetSendFee();
|
|
23
22
|
*
|
|
24
|
-
* if (
|
|
25
|
-
*
|
|
26
|
-
* return (
|
|
27
|
-
* <div>
|
|
28
|
-
* Send Fee: {Number(sendFee.data) / 1_000_000} USDC
|
|
29
|
-
* Delegation Fee: {Number(delegationFee.data) / 1_000_000} USDC
|
|
30
|
-
* </div>
|
|
31
|
-
* );
|
|
23
|
+
* if (isLoading) return <div>Loading...</div>;
|
|
24
|
+
* return <div>Send Fee: {Number(fee) / 1_000_000} USDC</div>;
|
|
32
25
|
* }
|
|
33
26
|
* ```
|
|
34
27
|
*/
|
|
35
|
-
export function
|
|
36
|
-
const
|
|
28
|
+
export function useGetSendFee(options) {
|
|
29
|
+
const client = useMailerClient();
|
|
30
|
+
return useQuery({
|
|
37
31
|
queryKey: mailerQueryKeys.sendFee(),
|
|
38
|
-
queryFn: () =>
|
|
39
|
-
if (chainInfo.chainType === ChainType.EVM) {
|
|
40
|
-
return client.getSendFee(chainInfo, publicClientOrConnection);
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
return client.getSendFee(chainInfo, undefined, publicClientOrConnection);
|
|
44
|
-
}
|
|
45
|
-
},
|
|
32
|
+
queryFn: () => client.getSendFee(),
|
|
46
33
|
staleTime: 5 * 60 * 1000, // 5 minutes - fees don't change often
|
|
47
|
-
...options
|
|
34
|
+
...options,
|
|
48
35
|
});
|
|
49
|
-
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Hook to get the current delegation fee
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```tsx
|
|
42
|
+
* function DelegationFeeDisplay() {
|
|
43
|
+
* const { data: fee, isLoading } = useGetDelegationFee();
|
|
44
|
+
*
|
|
45
|
+
* if (isLoading) return <div>Loading...</div>;
|
|
46
|
+
* return <div>Delegation Fee: {Number(fee) / 1_000_000} USDC</div>;
|
|
47
|
+
* }
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export function useGetDelegationFee(options) {
|
|
51
|
+
const client = useMailerClient();
|
|
52
|
+
return useQuery({
|
|
50
53
|
queryKey: mailerQueryKeys.delegationFee(),
|
|
51
|
-
queryFn: () =>
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
56
|
-
return client.getDelegationFee(chainInfo, undefined, publicClientOrConnection);
|
|
57
|
-
}
|
|
58
|
-
},
|
|
59
|
-
staleTime: 5 * 60 * 1000,
|
|
60
|
-
...options?.delegationFee,
|
|
54
|
+
queryFn: () => client.getDelegationFee(),
|
|
55
|
+
staleTime: 5 * 60 * 1000, // 5 minutes
|
|
56
|
+
...options,
|
|
61
57
|
});
|
|
62
|
-
return {
|
|
63
|
-
sendFee,
|
|
64
|
-
delegationFee,
|
|
65
|
-
};
|
|
66
58
|
}
|
|
67
59
|
/**
|
|
68
|
-
* Hook
|
|
60
|
+
* Hook to get claimable amount for an address
|
|
69
61
|
*
|
|
62
|
+
* @param address - Address to check (defaults to connected wallet)
|
|
70
63
|
* @example
|
|
71
64
|
* ```tsx
|
|
72
|
-
* function
|
|
73
|
-
* const {
|
|
74
|
-
* client,
|
|
75
|
-
* chainInfo,
|
|
76
|
-
* address
|
|
77
|
-
* );
|
|
65
|
+
* function ClaimableBalance() {
|
|
66
|
+
* const { data: amount, isLoading } = useGetClaimableAmount();
|
|
78
67
|
*
|
|
79
|
-
* return
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
* Owner Claimable: {Number(ownerClaimable.data) / 1_000_000} USDC
|
|
83
|
-
* </div>
|
|
84
|
-
* );
|
|
68
|
+
* if (isLoading) return <div>Loading...</div>;
|
|
69
|
+
* if (!amount || amount === 0n) return <div>No claimable balance</div>;
|
|
70
|
+
* return <div>Claimable: {Number(amount) / 1_000_000} USDC</div>;
|
|
85
71
|
* }
|
|
86
72
|
* ```
|
|
87
73
|
*/
|
|
88
|
-
export function
|
|
89
|
-
const
|
|
74
|
+
export function useGetClaimableAmount(address, options) {
|
|
75
|
+
const client = useMailerClient();
|
|
76
|
+
return useQuery({
|
|
90
77
|
queryKey: mailerQueryKeys.claimableAmount(address),
|
|
91
|
-
queryFn:
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
let result;
|
|
95
|
-
if (chainInfo.chainType === ChainType.EVM) {
|
|
96
|
-
result = await client.getRecipientClaimable(address, chainInfo, publicClientOrConnection);
|
|
97
|
-
}
|
|
98
|
-
else {
|
|
99
|
-
result = await client.getRecipientClaimable(address, chainInfo, undefined, publicClientOrConnection);
|
|
100
|
-
}
|
|
101
|
-
// Extract just the amount from the result
|
|
102
|
-
return result ? result.amount : BigInt(0);
|
|
103
|
-
},
|
|
104
|
-
enabled: Boolean(address),
|
|
105
|
-
staleTime: 30 * 1000, // 30 seconds
|
|
106
|
-
...options?.claimableAmount,
|
|
78
|
+
queryFn: () => client.getClaimableAmount(address),
|
|
79
|
+
staleTime: 30 * 1000, // 30 seconds - balances change more frequently
|
|
80
|
+
...options,
|
|
107
81
|
});
|
|
108
|
-
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Hook to get owner's claimable fee balance
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* ```tsx
|
|
88
|
+
* function OwnerDashboard() {
|
|
89
|
+
* const { data: amount, isLoading } = useGetOwnerClaimable();
|
|
90
|
+
*
|
|
91
|
+
* if (isLoading) return <div>Loading...</div>;
|
|
92
|
+
* return <div>Owner Fees: {Number(amount) / 1_000_000} USDC</div>;
|
|
93
|
+
* }
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
export function useGetOwnerClaimable(options) {
|
|
97
|
+
const client = useMailerClient();
|
|
98
|
+
return useQuery({
|
|
109
99
|
queryKey: mailerQueryKeys.ownerClaimable(),
|
|
110
|
-
queryFn: () =>
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
}
|
|
114
|
-
else {
|
|
115
|
-
return client.getOwnerClaimable(chainInfo, undefined, publicClientOrConnection);
|
|
116
|
-
}
|
|
117
|
-
},
|
|
118
|
-
staleTime: 30 * 1000,
|
|
119
|
-
...options?.ownerClaimable,
|
|
100
|
+
queryFn: () => client.getOwnerClaimable(),
|
|
101
|
+
staleTime: 30 * 1000, // 30 seconds
|
|
102
|
+
...options,
|
|
120
103
|
});
|
|
121
|
-
return {
|
|
122
|
-
claimableAmount,
|
|
123
|
-
ownerClaimable,
|
|
124
|
-
};
|
|
125
104
|
}
|
|
126
105
|
/**
|
|
127
|
-
* Hook
|
|
106
|
+
* Hook to get delegation information for an address
|
|
128
107
|
*
|
|
108
|
+
* @param address - Address to check delegation for (defaults to connected wallet)
|
|
129
109
|
* @example
|
|
130
110
|
* ```tsx
|
|
131
|
-
* function DelegationStatus(
|
|
132
|
-
* const {
|
|
133
|
-
* client,
|
|
134
|
-
* chainInfo,
|
|
135
|
-
* {
|
|
136
|
-
* delegationAddress: address,
|
|
137
|
-
* contractAddress: '0xContract...',
|
|
138
|
-
* walletAddress: address
|
|
139
|
-
* }
|
|
140
|
-
* );
|
|
111
|
+
* function DelegationStatus() {
|
|
112
|
+
* const { data: delegate, isLoading } = useGetDelegation();
|
|
141
113
|
*
|
|
142
|
-
* return
|
|
143
|
-
*
|
|
144
|
-
*
|
|
145
|
-
* Has Permission: {hasPermission.data ? 'Yes' : 'No'}
|
|
146
|
-
* </div>
|
|
147
|
-
* );
|
|
114
|
+
* if (isLoading) return <div>Loading...</div>;
|
|
115
|
+
* if (!delegate) return <div>No delegation set</div>;
|
|
116
|
+
* return <div>Delegated to: {delegate}</div>;
|
|
148
117
|
* }
|
|
149
118
|
* ```
|
|
150
119
|
*/
|
|
151
|
-
export function
|
|
152
|
-
const
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
return client.getDelegation(params.delegationAddress, chainInfo, publicClientOrConnection);
|
|
159
|
-
}
|
|
160
|
-
else {
|
|
161
|
-
return client.getDelegation(params.delegationAddress, chainInfo, undefined, publicClientOrConnection);
|
|
162
|
-
}
|
|
163
|
-
},
|
|
164
|
-
enabled: Boolean(params?.delegationAddress),
|
|
165
|
-
staleTime: 30 * 1000,
|
|
166
|
-
...options?.delegation,
|
|
167
|
-
});
|
|
168
|
-
const hasPermission = useQuery({
|
|
169
|
-
queryKey: mailerQueryKeys.permissions(params?.contractAddress, params?.walletAddress),
|
|
170
|
-
queryFn: async () => {
|
|
171
|
-
if (!params?.contractAddress || !params?.walletAddress) {
|
|
172
|
-
return false;
|
|
173
|
-
}
|
|
174
|
-
return client.hasPermission(chainInfo, params.contractAddress, params.walletAddress, publicClientOrConnection);
|
|
175
|
-
},
|
|
176
|
-
enabled: Boolean(params?.contractAddress && params?.walletAddress),
|
|
177
|
-
staleTime: 30 * 1000,
|
|
178
|
-
...options?.hasPermission,
|
|
120
|
+
export function useGetDelegation(address, options) {
|
|
121
|
+
const client = useMailerClient();
|
|
122
|
+
return useQuery({
|
|
123
|
+
queryKey: mailerQueryKeys.delegation(address),
|
|
124
|
+
queryFn: () => client.getDelegation(address),
|
|
125
|
+
staleTime: 1 * 60 * 1000, // 1 minute
|
|
126
|
+
...options,
|
|
179
127
|
});
|
|
180
|
-
return {
|
|
181
|
-
delegation,
|
|
182
|
-
hasPermission,
|
|
183
|
-
};
|
|
184
128
|
}
|
|
185
129
|
/**
|
|
186
|
-
* Hook
|
|
130
|
+
* Hook to check if contract is currently paused
|
|
187
131
|
*
|
|
188
132
|
* @example
|
|
189
133
|
* ```tsx
|
|
190
|
-
* function
|
|
191
|
-
* const { isPaused } =
|
|
134
|
+
* function PauseStatus() {
|
|
135
|
+
* const { data: isPaused, isLoading } = useIsPaused();
|
|
192
136
|
*
|
|
137
|
+
* if (isLoading) return <div>Loading...</div>;
|
|
193
138
|
* return (
|
|
194
139
|
* <div>
|
|
195
|
-
* Contract: {isPaused
|
|
140
|
+
* Contract Status: {isPaused ? '⏸️ Paused' : '✅ Active'}
|
|
196
141
|
* </div>
|
|
197
142
|
* );
|
|
198
143
|
* }
|
|
199
144
|
* ```
|
|
200
145
|
*/
|
|
201
|
-
export function
|
|
202
|
-
const
|
|
146
|
+
export function useIsPaused(options) {
|
|
147
|
+
const client = useMailerClient();
|
|
148
|
+
return useQuery({
|
|
203
149
|
queryKey: mailerQueryKeys.isPaused(),
|
|
204
|
-
queryFn: () =>
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
else {
|
|
209
|
-
return client.isPaused(chainInfo, undefined, publicClientOrConnection);
|
|
210
|
-
}
|
|
211
|
-
},
|
|
212
|
-
staleTime: 30 * 1000,
|
|
213
|
-
...options?.isPaused,
|
|
150
|
+
queryFn: () => client.isPaused(),
|
|
151
|
+
staleTime: 10 * 1000, // 10 seconds - pause status is critical
|
|
152
|
+
refetchInterval: 30 * 1000, // Refetch every 30 seconds
|
|
153
|
+
...options,
|
|
214
154
|
});
|
|
215
|
-
return {
|
|
216
|
-
isPaused,
|
|
217
|
-
};
|
|
218
155
|
}
|
|
219
156
|
/**
|
|
220
|
-
*
|
|
157
|
+
* Hook to get wallet address from the client
|
|
221
158
|
*
|
|
222
159
|
* @example
|
|
223
160
|
* ```tsx
|
|
224
|
-
* function
|
|
225
|
-
* const address = useWalletAddress(
|
|
226
|
-
* return <div>
|
|
161
|
+
* function WalletAddress() {
|
|
162
|
+
* const address = useWalletAddress();
|
|
163
|
+
* return <div>Connected: {address}</div>;
|
|
227
164
|
* }
|
|
228
165
|
* ```
|
|
229
166
|
*/
|
|
230
|
-
export function useWalletAddress(
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
// For EVM wallets
|
|
234
|
-
if ('walletClient' in wallet && wallet.walletClient) {
|
|
235
|
-
return wallet.walletClient.account?.address;
|
|
236
|
-
}
|
|
237
|
-
// For Solana wallets
|
|
238
|
-
if ('wallet' in wallet && wallet.wallet) {
|
|
239
|
-
return wallet.wallet.publicKey?.toString();
|
|
240
|
-
}
|
|
241
|
-
return undefined;
|
|
167
|
+
export function useWalletAddress() {
|
|
168
|
+
const client = useMailerClient();
|
|
169
|
+
return client.getWalletAddress();
|
|
242
170
|
}
|
|
243
171
|
/**
|
|
244
|
-
*
|
|
172
|
+
* Hook to get chain type (EVM or Solana)
|
|
245
173
|
*
|
|
246
174
|
* @example
|
|
247
175
|
* ```tsx
|
|
248
|
-
* function ChainBadge(
|
|
249
|
-
* const chainType = useChainType(
|
|
176
|
+
* function ChainBadge() {
|
|
177
|
+
* const chainType = useChainType();
|
|
250
178
|
* return <div>Chain: {chainType}</div>;
|
|
251
179
|
* }
|
|
252
180
|
* ```
|
|
253
181
|
*/
|
|
254
|
-
export function useChainType(
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
// ========== Legacy individual hooks for backward compatibility ==========
|
|
258
|
-
// These use context for convenience but the grouped hooks above are preferred
|
|
259
|
-
import { useMailerContext } from '../context/MailerProvider.js';
|
|
260
|
-
/**
|
|
261
|
-
* @deprecated Use useFees() instead
|
|
262
|
-
*/
|
|
263
|
-
export function useGetSendFee(options) {
|
|
264
|
-
const { client, chainInfo } = useMailerContext();
|
|
265
|
-
const { sendFee } = useFees(client, chainInfo, undefined, { sendFee: options });
|
|
266
|
-
return sendFee;
|
|
267
|
-
}
|
|
268
|
-
/**
|
|
269
|
-
* @deprecated Use useFees() instead
|
|
270
|
-
*/
|
|
271
|
-
export function useGetDelegationFee(options) {
|
|
272
|
-
const { client, chainInfo } = useMailerContext();
|
|
273
|
-
const { delegationFee } = useFees(client, chainInfo, undefined, { delegationFee: options });
|
|
274
|
-
return delegationFee;
|
|
275
|
-
}
|
|
276
|
-
/**
|
|
277
|
-
* @deprecated Use useClaimableAmounts() instead
|
|
278
|
-
*/
|
|
279
|
-
export function useGetClaimableAmount(address, options) {
|
|
280
|
-
const { client, chainInfo } = useMailerContext();
|
|
281
|
-
const { claimableAmount } = useClaimableAmounts(client, chainInfo, address, undefined, { claimableAmount: options });
|
|
282
|
-
return claimableAmount;
|
|
283
|
-
}
|
|
284
|
-
/**
|
|
285
|
-
* @deprecated Use useClaimableAmounts() instead
|
|
286
|
-
*/
|
|
287
|
-
export function useGetOwnerClaimable(options) {
|
|
288
|
-
const { client, chainInfo } = useMailerContext();
|
|
289
|
-
const { ownerClaimable } = useClaimableAmounts(client, chainInfo, undefined, undefined, { ownerClaimable: options });
|
|
290
|
-
return ownerClaimable;
|
|
291
|
-
}
|
|
292
|
-
/**
|
|
293
|
-
* @deprecated Use useDelegationAndPermissions() instead
|
|
294
|
-
*/
|
|
295
|
-
export function useGetDelegation(address, options) {
|
|
296
|
-
const { client, chainInfo } = useMailerContext();
|
|
297
|
-
const { delegation } = useDelegationAndPermissions(client, chainInfo, { delegationAddress: address }, undefined, { delegation: options });
|
|
298
|
-
return delegation;
|
|
299
|
-
}
|
|
300
|
-
/**
|
|
301
|
-
* @deprecated Use useContractState() instead
|
|
302
|
-
*/
|
|
303
|
-
export function useIsPaused(options) {
|
|
304
|
-
const { client, chainInfo } = useMailerContext();
|
|
305
|
-
const { isPaused } = useContractState(client, chainInfo, undefined, { isPaused: options });
|
|
306
|
-
return isPaused;
|
|
307
|
-
}
|
|
308
|
-
/**
|
|
309
|
-
* @deprecated Use useDelegationAndPermissions() instead
|
|
310
|
-
*/
|
|
311
|
-
export function useHasPermission(contractAddress, walletAddress, options) {
|
|
312
|
-
const { client, chainInfo } = useMailerContext();
|
|
313
|
-
const { hasPermission } = useDelegationAndPermissions(client, chainInfo, { contractAddress, walletAddress }, undefined, { hasPermission: options });
|
|
314
|
-
return hasPermission;
|
|
182
|
+
export function useChainType() {
|
|
183
|
+
const client = useMailerClient();
|
|
184
|
+
return client.getChainType();
|
|
315
185
|
}
|
|
316
186
|
//# sourceMappingURL=useMailerQueries.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMailerQueries.js","sourceRoot":"","sources":["../../../../../src/react/hooks/useMailerQueries.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAmC,MAAM,uBAAuB,CAAC;AAClF,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"useMailerQueries.js","sourceRoot":"","sources":["../../../../../src/react/hooks/useMailerQueries.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAmC,MAAM,uBAAuB,CAAC;AAClF,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAE5D;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,GAAG,EAAE,CAAC,QAAQ,CAAU;IACxB,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC,GAAG,eAAe,CAAC,GAAG,EAAE,SAAS,CAAU;IAC3D,aAAa,EAAE,GAAG,EAAE,CAAC,CAAC,GAAG,eAAe,CAAC,GAAG,EAAE,eAAe,CAAU;IACvE,eAAe,EAAE,CAAC,OA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E,EAAE,GAAG,IAAI,EAAE,2BAA2B;QACvD,GAAG,OAAO;KACX,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,gBAAgB;IAC9B,MAAM,MAAM,GAAG,eAAe,EAAE,CAAC;IACjC,OAAO,MAAM,CAAC,gBAAgB,EAAE,CAAC;AACnC,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,YAAY;IAC1B,MAAM,MAAM,GAAG,eAAe,EAAE,CAAC;IACjC,OAAO,MAAM,CAAC,YAAY,EAAE,CAAC;AAC/B,CAAC"}
|
|
@@ -30,10 +30,8 @@
|
|
|
30
30
|
* }
|
|
31
31
|
* ```
|
|
32
32
|
*/
|
|
33
|
-
export { MailerProvider, useMailerClient,
|
|
34
|
-
export {
|
|
35
|
-
export {
|
|
36
|
-
export { useGetSendFee, useGetDelegationFee, useGetClaimableAmount, useGetOwnerClaimable, useGetDelegation, useIsPaused, useWalletAddress, useChainType, useHasPermission, } from './hooks/useMailerQueries';
|
|
37
|
-
export { useSendMessage, useSendPrepared, useClaimRevenue, useClaimOwnerShare, useClaimExpiredShares, useDelegateTo, useRejectDelegation, useSetFees, useSetPermission, useRemovePermission, usePause, useUnpause, useEmergencyUnpause, useDistributeClaimableFunds, } from './hooks/useMailerMutations';
|
|
33
|
+
export { MailerProvider, useMailerClient, QueryClient, QueryClientProvider } from './context/MailerProvider';
|
|
34
|
+
export { useGetSendFee, useGetDelegationFee, useGetClaimableAmount, useGetOwnerClaimable, useGetDelegation, useIsPaused, useWalletAddress, useChainType, mailerQueryKeys, } from './hooks/useMailerQueries';
|
|
35
|
+
export { useSendMessage, useSendPrepared, useSendToEmail, useSendPreparedToEmail, useClaimRevenue, useClaimOwnerShare, useClaimExpiredShares, useDelegateTo, useRejectDelegation, useSetFee, useSetDelegationFee, usePause, useUnpause, useEmergencyUnpause, useDistributeClaimableFunds, } from './hooks/useMailerMutations';
|
|
38
36
|
export type { ChainConfig, MessageResult, UnifiedTransaction } from '../unified/types';
|
|
39
37
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/react/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAGH,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/react/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAGH,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAG7G,OAAO,EACL,aAAa,EACb,mBAAmB,EACnB,qBAAqB,EACrB,oBAAoB,EACpB,gBAAgB,EAChB,WAAW,EACX,gBAAgB,EAChB,YAAY,EACZ,eAAe,GAChB,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EACL,cAAc,EACd,eAAe,EACf,cAAc,EACd,sBAAsB,EACtB,eAAe,EACf,kBAAkB,EAClB,qBAAqB,EACrB,aAAa,EACb,mBAAmB,EACnB,SAAS,EACT,mBAAmB,EACnB,QAAQ,EACR,UAAU,EACV,mBAAmB,EACnB,2BAA2B,GAC5B,MAAM,4BAA4B,CAAC;AAGpC,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -31,13 +31,9 @@
|
|
|
31
31
|
* ```
|
|
32
32
|
*/
|
|
33
33
|
// Context and Provider
|
|
34
|
-
export { MailerProvider, useMailerClient,
|
|
35
|
-
//
|
|
36
|
-
export {
|
|
37
|
-
//
|
|
38
|
-
export {
|
|
39
|
-
// Legacy Individual Query Hooks (Deprecated - use grouped hooks above)
|
|
40
|
-
export { useGetSendFee, useGetDelegationFee, useGetClaimableAmount, useGetOwnerClaimable, useGetDelegation, useIsPaused, useWalletAddress, useChainType, useHasPermission, } from './hooks/useMailerQueries.js';
|
|
41
|
-
// Legacy Individual Mutation Hooks (Deprecated - use grouped hooks above)
|
|
42
|
-
export { useSendMessage, useSendPrepared, useClaimRevenue, useClaimOwnerShare, useClaimExpiredShares, useDelegateTo, useRejectDelegation, useSetFees, useSetPermission, useRemovePermission, usePause, useUnpause, useEmergencyUnpause, useDistributeClaimableFunds, } from './hooks/useMailerMutations.js';
|
|
34
|
+
export { MailerProvider, useMailerClient, QueryClient, QueryClientProvider } from './context/MailerProvider.js';
|
|
35
|
+
// Query Hooks (Read Operations)
|
|
36
|
+
export { useGetSendFee, useGetDelegationFee, useGetClaimableAmount, useGetOwnerClaimable, useGetDelegation, useIsPaused, useWalletAddress, useChainType, mailerQueryKeys, } from './hooks/useMailerQueries.js';
|
|
37
|
+
// Mutation Hooks (Write Operations)
|
|
38
|
+
export { useSendMessage, useSendPrepared, useSendToEmail, useSendPreparedToEmail, useClaimRevenue, useClaimOwnerShare, useClaimExpiredShares, useDelegateTo, useRejectDelegation, useSetFee, useSetDelegationFee, usePause, useUnpause, useEmergencyUnpause, useDistributeClaimableFunds, } from './hooks/useMailerMutations.js';
|
|
43
39
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/react/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,uBAAuB;AACvB,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/react/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,uBAAuB;AACvB,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE7G,gCAAgC;AAChC,OAAO,EACL,aAAa,EACb,mBAAmB,EACnB,qBAAqB,EACrB,oBAAoB,EACpB,gBAAgB,EAChB,WAAW,EACX,gBAAgB,EAChB,YAAY,EACZ,eAAe,GAChB,MAAM,0BAA0B,CAAC;AAElC,oCAAoC;AACpC,OAAO,EACL,cAAc,EACd,eAAe,EACf,cAAc,EACd,sBAAsB,EACtB,eAAe,EACf,kBAAkB,EAClB,qBAAqB,EACrB,aAAa,EACb,mBAAmB,EACnB,SAAS,EACT,mBAAmB,EACnB,QAAQ,EACR,UAAU,EACV,mBAAmB,EACnB,2BAA2B,GAC5B,MAAM,4BAA4B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/solana/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/solana/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,YAAY,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/solana/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/solana/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,YAAY,CAAC"}
|