@sudobility/contracts 1.12.0 → 1.13.1

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.
Files changed (128) hide show
  1. package/dist/evm/src/evm/{mailer-client.d.ts → evm-mailer-client.d.ts} +146 -50
  2. package/dist/evm/src/evm/evm-mailer-client.d.ts.map +1 -0
  3. package/dist/evm/src/evm/evm-mailer-client.js +924 -0
  4. package/dist/evm/src/evm/evm-mailer-client.js.map +1 -0
  5. package/dist/evm/src/evm/index.d.ts +1 -1
  6. package/dist/evm/src/evm/index.d.ts.map +1 -1
  7. package/dist/evm/src/evm/index.js +4 -4
  8. package/dist/evm/src/evm/index.js.map +1 -1
  9. package/dist/solana/solana/index.d.ts +1 -1
  10. package/dist/solana/solana/index.d.ts.map +1 -1
  11. package/dist/solana/solana/index.js +4 -3
  12. package/dist/solana/solana/index.js.map +1 -1
  13. package/dist/solana/solana/solana-mailer-client.d.ts +209 -0
  14. package/dist/solana/solana/solana-mailer-client.d.ts.map +1 -0
  15. package/dist/solana/solana/solana-mailer-client.js +1004 -0
  16. package/dist/solana/solana/solana-mailer-client.js.map +1 -0
  17. package/dist/solana/solana/types.d.ts +3 -2
  18. package/dist/solana/solana/types.d.ts.map +1 -1
  19. package/dist/solana/solana/types.js.map +1 -1
  20. package/dist/{unified-esm/src/evm/mailer-client.d.ts → unified/src/evm/evm-mailer-client.d.ts} +146 -50
  21. package/dist/unified/src/evm/evm-mailer-client.d.ts.map +1 -0
  22. package/dist/unified/src/evm/evm-mailer-client.js +924 -0
  23. package/dist/unified/src/evm/evm-mailer-client.js.map +1 -0
  24. package/dist/unified/src/evm/index.d.ts +1 -1
  25. package/dist/unified/src/evm/index.d.ts.map +1 -1
  26. package/dist/unified/src/evm/index.js +4 -4
  27. package/dist/unified/src/evm/index.js.map +1 -1
  28. package/dist/unified/src/react/context/MailerProvider.d.ts +26 -20
  29. package/dist/unified/src/react/context/MailerProvider.d.ts.map +1 -1
  30. package/dist/unified/src/react/context/MailerProvider.js +26 -26
  31. package/dist/unified/src/react/context/MailerProvider.js.map +1 -1
  32. package/dist/unified/src/react/hooks/useMailerMutations.d.ts +225 -192
  33. package/dist/unified/src/react/hooks/useMailerMutations.d.ts.map +1 -1
  34. package/dist/unified/src/react/hooks/useMailerMutations.js +263 -266
  35. package/dist/unified/src/react/hooks/useMailerMutations.js.map +1 -1
  36. package/dist/unified/src/react/hooks/useMailerQueries.d.ts +117 -63
  37. package/dist/unified/src/react/hooks/useMailerQueries.d.ts.map +1 -1
  38. package/dist/unified/src/react/hooks/useMailerQueries.js +239 -104
  39. package/dist/unified/src/react/hooks/useMailerQueries.js.map +1 -1
  40. package/dist/unified/src/react/index.d.ts +5 -3
  41. package/dist/unified/src/react/index.d.ts.map +1 -1
  42. package/dist/unified/src/react/index.js +41 -26
  43. package/dist/unified/src/react/index.js.map +1 -1
  44. package/dist/unified/src/solana/index.d.ts +1 -1
  45. package/dist/unified/src/solana/index.d.ts.map +1 -1
  46. package/dist/unified/src/solana/index.js +4 -3
  47. package/dist/unified/src/solana/index.js.map +1 -1
  48. package/dist/unified/src/solana/solana-mailer-client.d.ts +209 -0
  49. package/dist/unified/src/solana/solana-mailer-client.d.ts.map +1 -0
  50. package/dist/unified/src/solana/solana-mailer-client.js +1004 -0
  51. package/dist/unified/src/solana/solana-mailer-client.js.map +1 -0
  52. package/dist/unified/src/solana/types.d.ts +3 -2
  53. package/dist/unified/src/solana/types.d.ts.map +1 -1
  54. package/dist/unified/src/solana/types.js.map +1 -1
  55. package/dist/unified/src/unified/index.d.ts +1 -1
  56. package/dist/unified/src/unified/index.d.ts.map +1 -1
  57. package/dist/unified/src/unified/onchain-mailer-client.d.ts +187 -268
  58. package/dist/unified/src/unified/onchain-mailer-client.d.ts.map +1 -1
  59. package/dist/unified/src/unified/onchain-mailer-client.js +539 -1614
  60. package/dist/unified/src/unified/onchain-mailer-client.js.map +1 -1
  61. package/dist/unified/src/unified/types.d.ts +23 -6
  62. package/dist/unified/src/unified/types.d.ts.map +1 -1
  63. package/dist/{unified/src/evm/mailer-client.d.ts → unified-esm/src/evm/evm-mailer-client.d.ts} +146 -50
  64. package/dist/unified-esm/src/evm/evm-mailer-client.d.ts.map +1 -0
  65. package/dist/unified-esm/src/evm/evm-mailer-client.js +920 -0
  66. package/dist/unified-esm/src/evm/evm-mailer-client.js.map +1 -0
  67. package/dist/unified-esm/src/evm/index.d.ts +1 -1
  68. package/dist/unified-esm/src/evm/index.d.ts.map +1 -1
  69. package/dist/unified-esm/src/evm/index.js +2 -2
  70. package/dist/unified-esm/src/evm/index.js.map +1 -1
  71. package/dist/unified-esm/src/react/context/MailerProvider.d.ts +26 -20
  72. package/dist/unified-esm/src/react/context/MailerProvider.d.ts.map +1 -1
  73. package/dist/unified-esm/src/react/context/MailerProvider.js +25 -26
  74. package/dist/unified-esm/src/react/context/MailerProvider.js.map +1 -1
  75. package/dist/unified-esm/src/react/hooks/useMailerMutations.d.ts +225 -192
  76. package/dist/unified-esm/src/react/hooks/useMailerMutations.d.ts.map +1 -1
  77. package/dist/unified-esm/src/react/hooks/useMailerMutations.js +254 -262
  78. package/dist/unified-esm/src/react/hooks/useMailerMutations.js.map +1 -1
  79. package/dist/unified-esm/src/react/hooks/useMailerQueries.d.ts +117 -63
  80. package/dist/unified-esm/src/react/hooks/useMailerQueries.d.ts.map +1 -1
  81. package/dist/unified-esm/src/react/hooks/useMailerQueries.js +232 -102
  82. package/dist/unified-esm/src/react/hooks/useMailerQueries.js.map +1 -1
  83. package/dist/unified-esm/src/react/index.d.ts +5 -3
  84. package/dist/unified-esm/src/react/index.d.ts.map +1 -1
  85. package/dist/unified-esm/src/react/index.js +9 -5
  86. package/dist/unified-esm/src/react/index.js.map +1 -1
  87. package/dist/unified-esm/src/solana/index.d.ts +1 -1
  88. package/dist/unified-esm/src/solana/index.d.ts.map +1 -1
  89. package/dist/unified-esm/src/solana/index.js +2 -1
  90. package/dist/unified-esm/src/solana/index.js.map +1 -1
  91. package/dist/unified-esm/src/solana/solana-mailer-client.d.ts +209 -0
  92. package/dist/unified-esm/src/solana/solana-mailer-client.d.ts.map +1 -0
  93. package/dist/unified-esm/src/solana/solana-mailer-client.js +1000 -0
  94. package/dist/unified-esm/src/solana/solana-mailer-client.js.map +1 -0
  95. package/dist/unified-esm/src/solana/types.d.ts +3 -2
  96. package/dist/unified-esm/src/solana/types.d.ts.map +1 -1
  97. package/dist/unified-esm/src/solana/types.js.map +1 -1
  98. package/dist/unified-esm/src/unified/index.d.ts +1 -1
  99. package/dist/unified-esm/src/unified/index.d.ts.map +1 -1
  100. package/dist/unified-esm/src/unified/onchain-mailer-client.d.ts +187 -268
  101. package/dist/unified-esm/src/unified/onchain-mailer-client.d.ts.map +1 -1
  102. package/dist/unified-esm/src/unified/onchain-mailer-client.js +539 -1614
  103. package/dist/unified-esm/src/unified/onchain-mailer-client.js.map +1 -1
  104. package/dist/unified-esm/src/unified/types.d.ts +23 -6
  105. package/dist/unified-esm/src/unified/types.d.ts.map +1 -1
  106. package/package.json +5 -4
  107. package/programs/mailer/Cargo.toml +1 -1
  108. package/dist/evm/src/evm/mailer-client.d.ts.map +0 -1
  109. package/dist/evm/src/evm/mailer-client.js +0 -619
  110. package/dist/evm/src/evm/mailer-client.js.map +0 -1
  111. package/dist/solana/solana/mailer-client.d.ts +0 -282
  112. package/dist/solana/solana/mailer-client.d.ts.map +0 -1
  113. package/dist/solana/solana/mailer-client.js +0 -989
  114. package/dist/solana/solana/mailer-client.js.map +0 -1
  115. package/dist/unified/src/evm/mailer-client.d.ts.map +0 -1
  116. package/dist/unified/src/evm/mailer-client.js +0 -619
  117. package/dist/unified/src/evm/mailer-client.js.map +0 -1
  118. package/dist/unified/src/solana/mailer-client.d.ts +0 -282
  119. package/dist/unified/src/solana/mailer-client.d.ts.map +0 -1
  120. package/dist/unified/src/solana/mailer-client.js +0 -989
  121. package/dist/unified/src/solana/mailer-client.js.map +0 -1
  122. package/dist/unified-esm/src/evm/mailer-client.d.ts.map +0 -1
  123. package/dist/unified-esm/src/evm/mailer-client.js +0 -615
  124. package/dist/unified-esm/src/evm/mailer-client.js.map +0 -1
  125. package/dist/unified-esm/src/solana/mailer-client.d.ts +0 -282
  126. package/dist/unified-esm/src/solana/mailer-client.d.ts.map +0 -1
  127. package/dist/unified-esm/src/solana/mailer-client.js +0 -985
  128. package/dist/unified-esm/src/solana/mailer-client.js.map +0 -1
@@ -1,417 +1,414 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useMessaging = useMessaging;
4
+ exports.useClaims = useClaims;
5
+ exports.useDelegation = useDelegation;
6
+ exports.usePermissions = usePermissions;
7
+ exports.useContractControl = useContractControl;
8
+ exports.useOwnerOperations = useOwnerOperations;
3
9
  exports.useSendMessage = useSendMessage;
4
10
  exports.useSendPrepared = useSendPrepared;
5
- exports.useSendToEmail = useSendToEmail;
6
- exports.useSendPreparedToEmail = useSendPreparedToEmail;
7
11
  exports.useClaimRevenue = useClaimRevenue;
8
12
  exports.useClaimOwnerShare = useClaimOwnerShare;
9
13
  exports.useClaimExpiredShares = useClaimExpiredShares;
10
14
  exports.useDelegateTo = useDelegateTo;
11
15
  exports.useRejectDelegation = useRejectDelegation;
12
- exports.useSetFee = useSetFee;
13
- exports.useSetDelegationFee = useSetDelegationFee;
16
+ exports.useSetPermission = useSetPermission;
17
+ exports.useRemovePermission = useRemovePermission;
18
+ exports.useSetFees = useSetFees;
14
19
  exports.usePause = usePause;
15
20
  exports.useUnpause = useUnpause;
16
21
  exports.useEmergencyUnpause = useEmergencyUnpause;
17
22
  exports.useDistributeClaimableFunds = useDistributeClaimableFunds;
18
23
  const react_query_1 = require("@tanstack/react-query");
19
- const MailerProvider_1 = require("../context/MailerProvider");
20
24
  const useMailerQueries_1 = require("./useMailerQueries");
21
25
  /**
22
- * Hook to send a message
26
+ * Hook for message-related operations
23
27
  *
24
28
  * @example
25
29
  * ```tsx
26
- * function SendMessageForm() {
27
- * const sendMessage = useSendMessage();
30
+ * function MessageSender() {
31
+ * const client = useMailerClient(); // Get client from context or create it
32
+ * const { sendMessage, sendPrepared } = useMessaging(client, wallet, chainInfo);
28
33
  *
29
34
  * const handleSend = () => {
30
35
  * sendMessage.mutate({
31
36
  * subject: 'Hello',
32
37
  * body: 'World!',
33
- * priority: true,
34
- * resolveSenderToName: false
38
+ * priority: true
35
39
  * });
36
40
  * };
37
41
  *
38
42
  * return (
39
43
  * <button onClick={handleSend} disabled={sendMessage.isPending}>
40
- * {sendMessage.isPending ? 'Sending...' : 'Send Message'}
44
+ * Send Message
41
45
  * </button>
42
46
  * );
43
47
  * }
44
48
  * ```
45
49
  */
46
- function useSendMessage(options) {
47
- const client = (0, MailerProvider_1.useMailerClient)();
50
+ function useMessaging(client, connectedWallet, chainInfo, options) {
48
51
  const queryClient = (0, react_query_1.useQueryClient)();
49
- return (0, react_query_1.useMutation)({
50
- mutationFn: async ({ subject, body, priority = false, resolveSenderToName = false }) => client.sendMessage(subject, body, priority, resolveSenderToName),
52
+ const sendMessage = (0, react_query_1.useMutation)({
53
+ mutationFn: async ({ subject, body, priority = false, resolveSenderToName = false }) => client.sendMessage(connectedWallet, chainInfo, subject, body, { priority, resolveSenderToName }),
51
54
  onSuccess: () => {
52
- // Invalidate claimable amounts as sending affects balances
53
55
  queryClient.invalidateQueries({ queryKey: useMailerQueries_1.mailerQueryKeys.claimableAmount() });
54
56
  queryClient.invalidateQueries({ queryKey: useMailerQueries_1.mailerQueryKeys.ownerClaimable() });
55
57
  },
56
- ...options,
58
+ ...options?.sendMessage,
57
59
  });
58
- }
59
- /**
60
- * Hook to send a prepared message
61
- *
62
- * @example
63
- * ```tsx
64
- * function SendPreparedButton() {
65
- * const sendPrepared = useSendPrepared();
66
- *
67
- * return (
68
- * <button
69
- * onClick={() => sendPrepared.mutate({
70
- * to: '0x123...',
71
- * mailId: 'template-001',
72
- * priority: true
73
- * })}
74
- * disabled={sendPrepared.isPending}
75
- * >
76
- * Send Prepared
77
- * </button>
78
- * );
79
- * }
80
- * ```
81
- */
82
- function useSendPrepared(options) {
83
- const client = (0, MailerProvider_1.useMailerClient)();
84
- const queryClient = (0, react_query_1.useQueryClient)();
85
- return (0, react_query_1.useMutation)({
86
- mutationFn: async ({ to, mailId, priority = false, resolveSenderToName = false }) => client.sendPrepared(to, mailId, priority, resolveSenderToName),
60
+ const sendPrepared = (0, react_query_1.useMutation)({
61
+ mutationFn: async ({ to, mailId, priority = false, resolveSenderToName = false }) => client.sendPrepared(connectedWallet, chainInfo, to, mailId, { priority, resolveSenderToName }),
87
62
  onSuccess: () => {
88
63
  queryClient.invalidateQueries({ queryKey: useMailerQueries_1.mailerQueryKeys.claimableAmount() });
89
64
  queryClient.invalidateQueries({ queryKey: useMailerQueries_1.mailerQueryKeys.ownerClaimable() });
90
65
  },
91
- ...options,
92
- });
93
- }
94
- /**
95
- * Hook to send message to email address
96
- *
97
- * @example
98
- * ```tsx
99
- * function SendToEmailForm() {
100
- * const sendToEmail = useSendToEmail();
101
- *
102
- * return (
103
- * <button
104
- * onClick={() => sendToEmail.mutate({
105
- * toEmail: 'user@example.com',
106
- * subject: 'Hello',
107
- * body: 'Welcome!'
108
- * })}
109
- * >
110
- * Send to Email
111
- * </button>
112
- * );
113
- * }
114
- * ```
115
- */
116
- function useSendToEmail(options) {
117
- const client = (0, MailerProvider_1.useMailerClient)();
118
- const queryClient = (0, react_query_1.useQueryClient)();
119
- return (0, react_query_1.useMutation)({
120
- mutationFn: async ({ toEmail, subject, body }) => client.sendToEmail(toEmail, subject, body),
121
- onSuccess: () => {
122
- queryClient.invalidateQueries({ queryKey: useMailerQueries_1.mailerQueryKeys.ownerClaimable() });
123
- },
124
- ...options,
125
- });
126
- }
127
- /**
128
- * Hook to send prepared message to email address
129
- */
130
- function useSendPreparedToEmail(options) {
131
- const client = (0, MailerProvider_1.useMailerClient)();
132
- const queryClient = (0, react_query_1.useQueryClient)();
133
- return (0, react_query_1.useMutation)({
134
- mutationFn: async ({ toEmail, mailId }) => client.sendPreparedToEmail(toEmail, mailId),
135
- onSuccess: () => {
136
- queryClient.invalidateQueries({ queryKey: useMailerQueries_1.mailerQueryKeys.ownerClaimable() });
137
- },
138
- ...options,
66
+ ...options?.sendPrepared,
139
67
  });
68
+ return {
69
+ sendMessage,
70
+ sendPrepared,
71
+ };
140
72
  }
141
73
  /**
142
- * Hook to claim revenue share
74
+ * Hook for claim-related operations
143
75
  *
144
76
  * @example
145
77
  * ```tsx
146
- * function ClaimButton() {
147
- * const { data: claimable } = useGetClaimableAmount();
148
- * const claimRevenue = useClaimRevenue();
149
- *
150
- * if (!claimable || claimable === 0n) return null;
78
+ * function ClaimPanel() {
79
+ * const { claimRevenue, claimOwnerShare, claimExpiredShares } = useClaims(client, wallet, chainInfo);
151
80
  *
152
81
  * return (
153
- * <button
154
- * onClick={() => claimRevenue.mutate()}
155
- * disabled={claimRevenue.isPending}
156
- * >
157
- * Claim {Number(claimable) / 1_000_000} USDC
158
- * </button>
82
+ * <div>
83
+ * <button onClick={() => claimRevenue.mutate()}>
84
+ * Claim Revenue
85
+ * </button>
86
+ * <button onClick={() => claimOwnerShare.mutate()}>
87
+ * Claim Owner Share
88
+ * </button>
89
+ * </div>
159
90
  * );
160
91
  * }
161
92
  * ```
162
93
  */
163
- function useClaimRevenue(options) {
164
- const client = (0, MailerProvider_1.useMailerClient)();
94
+ function useClaims(client, connectedWallet, chainInfo, options) {
165
95
  const queryClient = (0, react_query_1.useQueryClient)();
166
- return (0, react_query_1.useMutation)({
167
- mutationFn: () => client.claimRevenue(),
96
+ const claimRevenue = (0, react_query_1.useMutation)({
97
+ mutationFn: () => client.claimRevenue(connectedWallet, chainInfo),
168
98
  onSuccess: () => {
169
- // Invalidate claimable amount after successful claim
170
99
  queryClient.invalidateQueries({ queryKey: useMailerQueries_1.mailerQueryKeys.claimableAmount() });
171
100
  },
172
- ...options,
101
+ ...options?.claimRevenue,
173
102
  });
174
- }
175
- /**
176
- * Hook to claim owner share (owner only)
177
- *
178
- * @example
179
- * ```tsx
180
- * function OwnerClaimButton() {
181
- * const { data: ownerClaimable } = useGetOwnerClaimable();
182
- * const claimOwner = useClaimOwnerShare();
183
- *
184
- * return (
185
- * <button onClick={() => claimOwner.mutate()}>
186
- * Claim Owner Fees: {Number(ownerClaimable) / 1_000_000} USDC
187
- * </button>
188
- * );
189
- * }
190
- * ```
191
- */
192
- function useClaimOwnerShare(options) {
193
- const client = (0, MailerProvider_1.useMailerClient)();
194
- const queryClient = (0, react_query_1.useQueryClient)();
195
- return (0, react_query_1.useMutation)({
196
- mutationFn: () => client.claimOwnerShare(),
103
+ const claimOwnerShare = (0, react_query_1.useMutation)({
104
+ mutationFn: () => client.claimOwnerShare(connectedWallet, chainInfo),
197
105
  onSuccess: () => {
198
106
  queryClient.invalidateQueries({ queryKey: useMailerQueries_1.mailerQueryKeys.ownerClaimable() });
199
107
  },
200
- ...options,
108
+ ...options?.claimOwnerShare,
201
109
  });
202
- }
203
- /**
204
- * Hook to reclaim expired recipient shares (owner only)
205
- */
206
- function useClaimExpiredShares(options) {
207
- const client = (0, MailerProvider_1.useMailerClient)();
208
- const queryClient = (0, react_query_1.useQueryClient)();
209
- return (0, react_query_1.useMutation)({
210
- mutationFn: async ({ recipient }) => client.claimExpiredShares(recipient),
110
+ const claimExpiredShares = (0, react_query_1.useMutation)({
111
+ mutationFn: async ({ recipient }) => client.claimExpiredShares(connectedWallet, chainInfo, recipient),
211
112
  onSuccess: (_, variables) => {
212
113
  queryClient.invalidateQueries({ queryKey: useMailerQueries_1.mailerQueryKeys.claimableAmount(variables.recipient) });
213
114
  queryClient.invalidateQueries({ queryKey: useMailerQueries_1.mailerQueryKeys.ownerClaimable() });
214
115
  },
215
- ...options,
116
+ ...options?.claimExpiredShares,
216
117
  });
118
+ return {
119
+ claimRevenue,
120
+ claimOwnerShare,
121
+ claimExpiredShares,
122
+ };
217
123
  }
218
124
  /**
219
- * Hook to delegate to another address
125
+ * Hook for delegation-related operations
220
126
  *
221
127
  * @example
222
128
  * ```tsx
223
- * function DelegateButton() {
224
- * const delegate = useDelegateTo();
129
+ * function DelegationManager() {
130
+ * const { delegateTo, rejectDelegation } = useDelegation(client, wallet, chainInfo);
225
131
  *
226
132
  * return (
227
- * <button
228
- * onClick={() => delegate.mutate({ delegate: '0xABC...' })}
229
- * disabled={delegate.isPending}
230
- * >
231
- * Delegate
232
- * </button>
133
+ * <>
134
+ * <button onClick={() => delegateTo.mutate({ delegate: '0xABC...' })}>
135
+ * Delegate
136
+ * </button>
137
+ * <button onClick={() => rejectDelegation.mutate({ delegatorAddress: '0xDEF...' })}>
138
+ * Reject Delegation
139
+ * </button>
140
+ * </>
233
141
  * );
234
142
  * }
235
143
  * ```
236
144
  */
237
- function useDelegateTo(options) {
238
- const client = (0, MailerProvider_1.useMailerClient)();
145
+ function useDelegation(client, connectedWallet, chainInfo, options) {
239
146
  const queryClient = (0, react_query_1.useQueryClient)();
240
- return (0, react_query_1.useMutation)({
241
- mutationFn: async ({ delegate }) => client.delegateTo(delegate),
147
+ const delegateTo = (0, react_query_1.useMutation)({
148
+ mutationFn: async ({ delegate }) => client.delegateTo(connectedWallet, chainInfo, delegate),
242
149
  onSuccess: () => {
243
150
  queryClient.invalidateQueries({ queryKey: useMailerQueries_1.mailerQueryKeys.delegation() });
244
151
  },
245
- ...options,
152
+ ...options?.delegateTo,
246
153
  });
247
- }
248
- /**
249
- * Hook to reject a delegation made to you
250
- *
251
- * @example
252
- * ```tsx
253
- * function RejectDelegationButton({ delegatorAddress }: { delegatorAddress: string }) {
254
- * const rejectDelegation = useRejectDelegation();
255
- *
256
- * return (
257
- * <button
258
- * onClick={() => rejectDelegation.mutate({ delegatorAddress })}
259
- * >
260
- * Reject Delegation
261
- * </button>
262
- * );
263
- * }
264
- * ```
265
- */
266
- function useRejectDelegation(options) {
267
- const client = (0, MailerProvider_1.useMailerClient)();
268
- const queryClient = (0, react_query_1.useQueryClient)();
269
- return (0, react_query_1.useMutation)({
270
- mutationFn: async ({ delegatorAddress }) => client.rejectDelegation(delegatorAddress),
154
+ const rejectDelegation = (0, react_query_1.useMutation)({
155
+ mutationFn: async ({ delegatorAddress }) => client.rejectDelegation(connectedWallet, chainInfo, delegatorAddress),
271
156
  onSuccess: () => {
272
157
  queryClient.invalidateQueries({ queryKey: useMailerQueries_1.mailerQueryKeys.delegation() });
273
158
  },
274
- ...options,
159
+ ...options?.rejectDelegation,
275
160
  });
161
+ return {
162
+ delegateTo,
163
+ rejectDelegation,
164
+ };
276
165
  }
277
166
  /**
278
- * Hook to set send fee (owner only)
167
+ * Hook for permission-related operations (EVM only)
279
168
  *
280
169
  * @example
281
170
  * ```tsx
282
- * function SetFeeForm() {
283
- * const setFee = useSetFee();
171
+ * function PermissionManager() {
172
+ * const { setPermission, removePermission } = usePermissions(client, wallet, chainInfo);
284
173
  *
285
174
  * return (
286
- * <button onClick={() => setFee.mutate({ newFee: 200000n })}>
287
- * Update Fee to 0.2 USDC
288
- * </button>
175
+ * <>
176
+ * <button onClick={() => setPermission.mutate({ contractAddress: '0xABC...' })}>
177
+ * Grant Permission
178
+ * </button>
179
+ * <button onClick={() => removePermission.mutate({ contractAddress: '0xABC...' })}>
180
+ * Revoke Permission
181
+ * </button>
182
+ * </>
289
183
  * );
290
184
  * }
291
185
  * ```
292
186
  */
293
- function useSetFee(options) {
294
- const client = (0, MailerProvider_1.useMailerClient)();
187
+ function usePermissions(client, connectedWallet, chainInfo, options) {
295
188
  const queryClient = (0, react_query_1.useQueryClient)();
296
- return (0, react_query_1.useMutation)({
297
- mutationFn: async ({ newFee }) => client.setFee(newFee),
189
+ const setPermission = (0, react_query_1.useMutation)({
190
+ mutationFn: async ({ contractAddress }) => client.setPermission(connectedWallet, chainInfo, contractAddress),
298
191
  onSuccess: () => {
299
- queryClient.invalidateQueries({ queryKey: useMailerQueries_1.mailerQueryKeys.sendFee() });
192
+ queryClient.invalidateQueries({ queryKey: useMailerQueries_1.mailerQueryKeys.permissions() });
300
193
  },
301
- ...options,
194
+ ...options?.setPermission,
302
195
  });
303
- }
304
- /**
305
- * Hook to set delegation fee (owner only)
306
- */
307
- function useSetDelegationFee(options) {
308
- const client = (0, MailerProvider_1.useMailerClient)();
309
- const queryClient = (0, react_query_1.useQueryClient)();
310
- return (0, react_query_1.useMutation)({
311
- mutationFn: async ({ newFee }) => client.setDelegationFee(newFee),
196
+ const removePermission = (0, react_query_1.useMutation)({
197
+ mutationFn: async ({ contractAddress }) => client.removePermission(connectedWallet, chainInfo, contractAddress),
312
198
  onSuccess: () => {
313
- queryClient.invalidateQueries({ queryKey: useMailerQueries_1.mailerQueryKeys.delegationFee() });
199
+ queryClient.invalidateQueries({ queryKey: useMailerQueries_1.mailerQueryKeys.permissions() });
314
200
  },
315
- ...options,
201
+ ...options?.removePermission,
316
202
  });
203
+ return {
204
+ setPermission,
205
+ removePermission,
206
+ };
317
207
  }
318
208
  /**
319
- * Hook to pause the contract (owner only)
209
+ * Hook for contract control operations (owner only)
320
210
  *
321
211
  * @example
322
212
  * ```tsx
323
- * function PauseButton() {
324
- * const pause = usePause();
213
+ * function ContractControls() {
214
+ * const { pause, unpause, emergencyUnpause } = useContractControl(client, wallet, chainInfo);
325
215
  *
326
216
  * return (
327
- * <button
328
- * onClick={() => pause.mutate()}
329
- * disabled={pause.isPending}
330
- * >
331
- * Pause Contract
332
- * </button>
217
+ * <>
218
+ * <button onClick={() => pause.mutate()}>Pause</button>
219
+ * <button onClick={() => unpause.mutate()}>Unpause</button>
220
+ * <button onClick={() => emergencyUnpause.mutate()}>Emergency Unpause</button>
221
+ * </>
333
222
  * );
334
223
  * }
335
224
  * ```
336
225
  */
337
- function usePause(options) {
338
- const client = (0, MailerProvider_1.useMailerClient)();
226
+ function useContractControl(client, connectedWallet, chainInfo, options) {
339
227
  const queryClient = (0, react_query_1.useQueryClient)();
340
- return (0, react_query_1.useMutation)({
341
- mutationFn: () => client.pause(),
228
+ const pause = (0, react_query_1.useMutation)({
229
+ mutationFn: () => client.pause(connectedWallet, chainInfo),
342
230
  onSuccess: () => {
343
231
  queryClient.invalidateQueries({ queryKey: useMailerQueries_1.mailerQueryKeys.isPaused() });
344
232
  queryClient.invalidateQueries({ queryKey: useMailerQueries_1.mailerQueryKeys.ownerClaimable() });
345
233
  },
346
- ...options,
234
+ ...options?.pause,
347
235
  });
348
- }
349
- /**
350
- * Hook to unpause the contract (owner only)
351
- *
352
- * @example
353
- * ```tsx
354
- * function UnpauseButton() {
355
- * const unpause = useUnpause();
356
- *
357
- * return (
358
- * <button onClick={() => unpause.mutate()}>
359
- * Unpause Contract
360
- * </button>
361
- * );
362
- * }
363
- * ```
364
- */
365
- function useUnpause(options) {
366
- const client = (0, MailerProvider_1.useMailerClient)();
367
- const queryClient = (0, react_query_1.useQueryClient)();
368
- return (0, react_query_1.useMutation)({
369
- mutationFn: () => client.unpause(),
236
+ const unpause = (0, react_query_1.useMutation)({
237
+ mutationFn: () => client.unpause(connectedWallet, chainInfo),
370
238
  onSuccess: () => {
371
239
  queryClient.invalidateQueries({ queryKey: useMailerQueries_1.mailerQueryKeys.isPaused() });
372
240
  },
373
- ...options,
241
+ ...options?.unpause,
374
242
  });
375
- }
376
- /**
377
- * Hook to emergency unpause (owner only)
378
- */
379
- function useEmergencyUnpause(options) {
380
- const client = (0, MailerProvider_1.useMailerClient)();
381
- const queryClient = (0, react_query_1.useQueryClient)();
382
- return (0, react_query_1.useMutation)({
383
- mutationFn: () => client.emergencyUnpause(),
243
+ const emergencyUnpause = (0, react_query_1.useMutation)({
244
+ mutationFn: () => client.emergencyUnpause(connectedWallet, chainInfo),
384
245
  onSuccess: () => {
385
246
  queryClient.invalidateQueries({ queryKey: useMailerQueries_1.mailerQueryKeys.isPaused() });
386
247
  },
387
- ...options,
248
+ ...options?.emergencyUnpause,
388
249
  });
250
+ return {
251
+ pause,
252
+ unpause,
253
+ emergencyUnpause,
254
+ };
389
255
  }
390
256
  /**
391
- * Hook to distribute claimable funds (anyone can call when paused)
257
+ * Hook for owner-specific operations
392
258
  *
393
259
  * @example
394
260
  * ```tsx
395
- * function DistributeFundsButton({ recipient }: { recipient: string }) {
396
- * const distribute = useDistributeClaimableFunds();
261
+ * function OwnerPanel() {
262
+ * const { setFees, distributeClaimableFunds } = useOwnerOperations(client, wallet, chainInfo);
397
263
  *
398
264
  * return (
399
- * <button onClick={() => distribute.mutate({ recipient })}>
400
- * Distribute Funds to {recipient}
401
- * </button>
265
+ * <>
266
+ * <button onClick={() => setFees.mutate({ sendFee: 200000n, delegationFee: 10000000n })}>
267
+ * Update Fees
268
+ * </button>
269
+ * <button onClick={() => distributeClaimableFunds.mutate({ recipient: '0xABC...' })}>
270
+ * Distribute Funds
271
+ * </button>
272
+ * </>
402
273
  * );
403
274
  * }
404
275
  * ```
405
276
  */
406
- function useDistributeClaimableFunds(options) {
407
- const client = (0, MailerProvider_1.useMailerClient)();
277
+ function useOwnerOperations(client, connectedWallet, chainInfo, options) {
408
278
  const queryClient = (0, react_query_1.useQueryClient)();
409
- return (0, react_query_1.useMutation)({
410
- mutationFn: async ({ recipient }) => client.distributeClaimableFunds(recipient),
279
+ const setFees = (0, react_query_1.useMutation)({
280
+ mutationFn: async ({ sendFee, delegationFee }) => client.setFees(connectedWallet, chainInfo, sendFee, delegationFee),
281
+ onSuccess: () => {
282
+ queryClient.invalidateQueries({ queryKey: useMailerQueries_1.mailerQueryKeys.sendFee() });
283
+ queryClient.invalidateQueries({ queryKey: useMailerQueries_1.mailerQueryKeys.delegationFee() });
284
+ },
285
+ ...options?.setFees,
286
+ });
287
+ const distributeClaimableFunds = (0, react_query_1.useMutation)({
288
+ mutationFn: async ({ recipient }) => client.distributeClaimableFunds(connectedWallet, chainInfo, recipient),
411
289
  onSuccess: (_, variables) => {
412
290
  queryClient.invalidateQueries({ queryKey: useMailerQueries_1.mailerQueryKeys.claimableAmount(variables.recipient) });
413
291
  },
414
- ...options,
292
+ ...options?.distributeClaimableFunds,
415
293
  });
294
+ return {
295
+ setFees,
296
+ distributeClaimableFunds,
297
+ };
298
+ }
299
+ // ========== Legacy individual hooks for backward compatibility ==========
300
+ // These use context for convenience but the grouped hooks above are preferred
301
+ const MailerProvider_1 = require("../context/MailerProvider");
302
+ /**
303
+ * @deprecated Use useMessaging() instead
304
+ */
305
+ function useSendMessage(options) {
306
+ const { client, wallet, chainInfo } = (0, MailerProvider_1.useMailerContext)();
307
+ const { sendMessage } = useMessaging(client, wallet, chainInfo, { sendMessage: options });
308
+ return sendMessage;
309
+ }
310
+ /**
311
+ * @deprecated Use useMessaging() instead
312
+ */
313
+ function useSendPrepared(options) {
314
+ const { client, wallet, chainInfo } = (0, MailerProvider_1.useMailerContext)();
315
+ const { sendPrepared } = useMessaging(client, wallet, chainInfo, { sendPrepared: options });
316
+ return sendPrepared;
317
+ }
318
+ /**
319
+ * @deprecated Use useClaims() instead
320
+ */
321
+ function useClaimRevenue(options) {
322
+ const { client, wallet, chainInfo } = (0, MailerProvider_1.useMailerContext)();
323
+ const { claimRevenue } = useClaims(client, wallet, chainInfo, { claimRevenue: options });
324
+ return claimRevenue;
325
+ }
326
+ /**
327
+ * @deprecated Use useClaims() instead
328
+ */
329
+ function useClaimOwnerShare(options) {
330
+ const { client, wallet, chainInfo } = (0, MailerProvider_1.useMailerContext)();
331
+ const { claimOwnerShare } = useClaims(client, wallet, chainInfo, { claimOwnerShare: options });
332
+ return claimOwnerShare;
333
+ }
334
+ /**
335
+ * @deprecated Use useClaims() instead
336
+ */
337
+ function useClaimExpiredShares(options) {
338
+ const { client, wallet, chainInfo } = (0, MailerProvider_1.useMailerContext)();
339
+ const { claimExpiredShares } = useClaims(client, wallet, chainInfo, { claimExpiredShares: options });
340
+ return claimExpiredShares;
341
+ }
342
+ /**
343
+ * @deprecated Use useDelegation() instead
344
+ */
345
+ function useDelegateTo(options) {
346
+ const { client, wallet, chainInfo } = (0, MailerProvider_1.useMailerContext)();
347
+ const { delegateTo } = useDelegation(client, wallet, chainInfo, { delegateTo: options });
348
+ return delegateTo;
349
+ }
350
+ /**
351
+ * @deprecated Use useDelegation() instead
352
+ */
353
+ function useRejectDelegation(options) {
354
+ const { client, wallet, chainInfo } = (0, MailerProvider_1.useMailerContext)();
355
+ const { rejectDelegation } = useDelegation(client, wallet, chainInfo, { rejectDelegation: options });
356
+ return rejectDelegation;
357
+ }
358
+ /**
359
+ * @deprecated Use usePermissions() instead
360
+ */
361
+ function useSetPermission(options) {
362
+ const { client, wallet, chainInfo } = (0, MailerProvider_1.useMailerContext)();
363
+ const { setPermission } = usePermissions(client, wallet, chainInfo, { setPermission: options });
364
+ return setPermission;
365
+ }
366
+ /**
367
+ * @deprecated Use usePermissions() instead
368
+ */
369
+ function useRemovePermission(options) {
370
+ const { client, wallet, chainInfo } = (0, MailerProvider_1.useMailerContext)();
371
+ const { removePermission } = usePermissions(client, wallet, chainInfo, { removePermission: options });
372
+ return removePermission;
373
+ }
374
+ /**
375
+ * @deprecated Use useOwnerOperations() instead
376
+ */
377
+ function useSetFees(options) {
378
+ const { client, wallet, chainInfo } = (0, MailerProvider_1.useMailerContext)();
379
+ const { setFees } = useOwnerOperations(client, wallet, chainInfo, { setFees: options });
380
+ return setFees;
381
+ }
382
+ /**
383
+ * @deprecated Use useContractControl() instead
384
+ */
385
+ function usePause(options) {
386
+ const { client, wallet, chainInfo } = (0, MailerProvider_1.useMailerContext)();
387
+ const { pause } = useContractControl(client, wallet, chainInfo, { pause: options });
388
+ return pause;
389
+ }
390
+ /**
391
+ * @deprecated Use useContractControl() instead
392
+ */
393
+ function useUnpause(options) {
394
+ const { client, wallet, chainInfo } = (0, MailerProvider_1.useMailerContext)();
395
+ const { unpause } = useContractControl(client, wallet, chainInfo, { unpause: options });
396
+ return unpause;
397
+ }
398
+ /**
399
+ * @deprecated Use useContractControl() instead
400
+ */
401
+ function useEmergencyUnpause(options) {
402
+ const { client, wallet, chainInfo } = (0, MailerProvider_1.useMailerContext)();
403
+ const { emergencyUnpause } = useContractControl(client, wallet, chainInfo, { emergencyUnpause: options });
404
+ return emergencyUnpause;
405
+ }
406
+ /**
407
+ * @deprecated Use useOwnerOperations() instead
408
+ */
409
+ function useDistributeClaimableFunds(options) {
410
+ const { client, wallet, chainInfo } = (0, MailerProvider_1.useMailerContext)();
411
+ const { distributeClaimableFunds } = useOwnerOperations(client, wallet, chainInfo, { distributeClaimableFunds: options });
412
+ return distributeClaimableFunds;
416
413
  }
417
414
  //# sourceMappingURL=useMailerMutations.js.map