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