@sudobility/contracts 0.14.0 → 1.9.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.dbg.json +1 -1
- package/artifacts/contracts/Mailer.sol/Mailer.json +2 -278
- 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 +1 -1
- package/dist/evm/src/evm/index.js.map +1 -1
- package/dist/evm/src/evm/mailer-client.d.ts +180 -936
- package/dist/evm/src/evm/mailer-client.d.ts.map +1 -1
- package/dist/evm/src/evm/mailer-client.js +249 -451
- package/dist/evm/src/evm/mailer-client.js.map +1 -1
- package/dist/evm/typechain-types/Mailer.d.ts +10 -177
- package/dist/evm/typechain-types/Mailer.d.ts.map +1 -1
- package/dist/evm/typechain-types/factories/Mailer__factory.d.ts +1 -216
- package/dist/evm/typechain-types/factories/Mailer__factory.d.ts.map +1 -1
- package/dist/evm/typechain-types/factories/Mailer__factory.js +1 -277
- 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 -3
- package/dist/solana/solana/index.js.map +1 -1
- package/dist/solana/solana/mailer-client.d.ts +18 -91
- package/dist/solana/solana/mailer-client.d.ts.map +1 -1
- package/dist/solana/solana/mailer-client.js +55 -316
- package/dist/solana/solana/mailer-client.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 +1 -1
- package/dist/unified/src/evm/index.js.map +1 -1
- package/dist/unified/src/evm/mailer-client.d.ts +180 -936
- package/dist/unified/src/evm/mailer-client.d.ts.map +1 -1
- package/dist/unified/src/evm/mailer-client.js +249 -451
- package/dist/unified/src/evm/mailer-client.js.map +1 -1
- package/dist/unified/src/react/hooks/useMailerMutations.d.ts +1 -1
- package/dist/unified/src/react/hooks/useMailerMutations.js +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 -3
- package/dist/unified/src/solana/index.js.map +1 -1
- package/dist/unified/src/solana/mailer-client.d.ts +18 -91
- package/dist/unified/src/solana/mailer-client.d.ts.map +1 -1
- package/dist/unified/src/solana/mailer-client.js +55 -316
- package/dist/unified/src/solana/mailer-client.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 +251 -111
- package/dist/unified/src/unified/onchain-mailer-client.d.ts.map +1 -1
- package/dist/unified/src/unified/onchain-mailer-client.js +1375 -744
- package/dist/unified/src/unified/onchain-mailer-client.js.map +1 -1
- package/dist/unified/src/unified/types.d.ts +6 -16
- 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 -177
- package/dist/unified/typechain-types/Mailer.d.ts.map +1 -1
- package/dist/unified/typechain-types/factories/Mailer__factory.d.ts +1 -216
- package/dist/unified/typechain-types/factories/Mailer__factory.d.ts.map +1 -1
- package/dist/unified/typechain-types/factories/Mailer__factory.js +1 -277
- 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 +1 -1
- package/dist/unified-esm/src/evm/index.js.map +1 -1
- package/dist/unified-esm/src/evm/mailer-client.d.ts +180 -936
- package/dist/unified-esm/src/evm/mailer-client.d.ts.map +1 -1
- package/dist/unified-esm/src/evm/mailer-client.js +251 -453
- package/dist/unified-esm/src/evm/mailer-client.js.map +1 -1
- package/dist/unified-esm/src/react/hooks/useMailerMutations.d.ts +1 -1
- package/dist/unified-esm/src/react/hooks/useMailerMutations.js +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 -1
- package/dist/unified-esm/src/solana/index.js.map +1 -1
- package/dist/unified-esm/src/solana/mailer-client.d.ts +18 -91
- package/dist/unified-esm/src/solana/mailer-client.d.ts.map +1 -1
- package/dist/unified-esm/src/solana/mailer-client.js +56 -317
- package/dist/unified-esm/src/solana/mailer-client.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 +251 -111
- package/dist/unified-esm/src/unified/onchain-mailer-client.d.ts.map +1 -1
- package/dist/unified-esm/src/unified/onchain-mailer-client.js +1379 -748
- package/dist/unified-esm/src/unified/onchain-mailer-client.js.map +1 -1
- package/dist/unified-esm/src/unified/types.d.ts +6 -16
- 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 -177
- package/dist/unified-esm/typechain-types/Mailer.d.ts.map +1 -1
- package/dist/unified-esm/typechain-types/factories/Mailer__factory.d.ts +1 -216
- 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 -277
- package/dist/unified-esm/typechain-types/factories/Mailer__factory.js.map +1 -1
- package/package.json +9 -20
- package/programs/mailer/src/lib.rs +171 -1026
- package/programs/mailer/tests/integration_tests.rs +65 -586
- package/typechain-types/Mailer.ts +8 -319
- package/typechain-types/factories/Mailer__factory.ts +1 -277
- package/artifacts/contracts/Mailer.sol/Mailer.d.ts +0 -1146
- package/artifacts/contracts/Mailer.sol/artifacts.d.ts +0 -21
- package/artifacts/contracts/MockUSDC.sol/MockUSDC.d.ts +0 -284
- package/artifacts/contracts/MockUSDC.sol/artifacts.d.ts +0 -21
- package/artifacts/contracts/interfaces/IERC20.sol/IERC20.d.ts +0 -157
- package/artifacts/contracts/interfaces/IERC20.sol/artifacts.d.ts +0 -21
|
@@ -1,615 +1,413 @@
|
|
|
1
|
-
import { getAddress
|
|
2
|
-
import { Mailer__factory } from
|
|
1
|
+
import { getAddress } from "viem";
|
|
2
|
+
import { Mailer__factory } from "../../typechain-types/factories/Mailer__factory.js";
|
|
3
|
+
// Get ABI from typechain-generated factories
|
|
3
4
|
const MAILER_ABI = Mailer__factory.abi;
|
|
5
|
+
// Get bytecode from typechain-generated factories
|
|
4
6
|
const MAILER_BYTECODE = Mailer__factory.bytecode;
|
|
5
7
|
/**
|
|
6
|
-
*
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
8
|
+
* @class MailerClient
|
|
9
|
+
* @description High-level TypeScript client for the Mailer contract using viem
|
|
10
|
+
* @notice Provides easy-to-use methods for sending messages with USDC fees and revenue sharing
|
|
11
|
+
*
|
|
12
|
+
* ## Key Features:
|
|
13
|
+
* - **Delegation Management**: Delegate mail handling with rejection capability
|
|
14
|
+
* - **Priority Messages**: Full fee (0.1 USDC) with 90% revenue share to recipient
|
|
15
|
+
* - **Standard Messages**: 10% fee only (0.01 USDC) with no revenue share
|
|
16
|
+
* - **Revenue Claims**: 60-day claim period for priority message revenue shares
|
|
17
|
+
*
|
|
18
|
+
* ## Usage Examples:
|
|
19
|
+
* ```typescript
|
|
20
|
+
* // Connect to existing contract
|
|
21
|
+
* import { createPublicClient, createWalletClient, http } from 'viem';
|
|
22
|
+
* import { mainnet } from 'viem/chains';
|
|
23
|
+
*
|
|
24
|
+
* const publicClient = createPublicClient({
|
|
25
|
+
* chain: mainnet,
|
|
26
|
+
* transport: http()
|
|
27
|
+
* });
|
|
28
|
+
*
|
|
29
|
+
* const mailer = new MailerClient('CONTRACT_ADDRESS', publicClient);
|
|
30
|
+
*
|
|
31
|
+
* // Send message with revenue sharing to recipient
|
|
32
|
+
* const walletClient = createWalletClient({
|
|
33
|
+
* chain: mainnet,
|
|
34
|
+
* transport: http()
|
|
35
|
+
* });
|
|
36
|
+
*
|
|
37
|
+
* await mailer.send('0x...', 'Subject', 'Body', true, walletClient, account);
|
|
38
|
+
*
|
|
39
|
+
* // Claim your revenue share (as recipient)
|
|
40
|
+
* await mailer.claimRecipientShare(walletClient, account);
|
|
41
|
+
* ```
|
|
15
42
|
*/
|
|
16
43
|
export class MailerClient {
|
|
17
|
-
constructor(contractAddress, publicClient) {
|
|
18
|
-
this.defaultGasMultiplier = 1.2; // 20% buffer by default
|
|
19
|
-
this.contractAddress = normalizeAddress(contractAddress);
|
|
20
|
-
this.publicClient = publicClient;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Helper method to estimate gas for a transaction with optional buffer
|
|
24
|
-
*/
|
|
25
|
-
async estimateGasWithBuffer(estimateFn, gasOptions) {
|
|
26
|
-
// If gas limit is explicitly provided, use it
|
|
27
|
-
if (gasOptions?.gasLimit) {
|
|
28
|
-
return gasOptions.gasLimit;
|
|
29
|
-
}
|
|
30
|
-
try {
|
|
31
|
-
// Estimate gas for the transaction
|
|
32
|
-
const estimatedGas = await estimateFn();
|
|
33
|
-
// Apply multiplier for safety buffer
|
|
34
|
-
const multiplier = gasOptions?.gasMultiplier ?? this.defaultGasMultiplier;
|
|
35
|
-
const gasWithBuffer = BigInt(Math.ceil(Number(estimatedGas) * multiplier));
|
|
36
|
-
// Apply max gas limit if specified
|
|
37
|
-
if (gasOptions?.maxGasLimit) {
|
|
38
|
-
return gasWithBuffer > gasOptions.maxGasLimit ? gasOptions.maxGasLimit : gasWithBuffer;
|
|
39
|
-
}
|
|
40
|
-
return gasWithBuffer;
|
|
41
|
-
}
|
|
42
|
-
catch (error) {
|
|
43
|
-
// If estimation fails, throw with helpful message
|
|
44
|
-
if (error instanceof EstimateGasExecutionError) {
|
|
45
|
-
throw new Error(`Gas estimation failed: ${error.message}`);
|
|
46
|
-
}
|
|
47
|
-
throw error;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
44
|
/**
|
|
51
|
-
*
|
|
45
|
+
* @description Creates a new MailerClient instance
|
|
46
|
+
* @param contractAddress The deployed Mailer contract address
|
|
47
|
+
* @param publicClient Viem public client for reading blockchain state
|
|
52
48
|
*/
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
params.maxFeePerGas = gasOptions.maxFeePerGas;
|
|
57
|
-
}
|
|
58
|
-
if (gasOptions?.maxPriorityFeePerGas) {
|
|
59
|
-
params.maxPriorityFeePerGas = gasOptions.maxPriorityFeePerGas;
|
|
60
|
-
}
|
|
61
|
-
return params;
|
|
49
|
+
constructor(contractAddress, publicClient) {
|
|
50
|
+
this.contractAddress = getAddress(contractAddress);
|
|
51
|
+
this.publicClient = publicClient;
|
|
62
52
|
}
|
|
63
53
|
/**
|
|
64
|
-
* Deploy a
|
|
54
|
+
* @description Deploy a new Mailer contract and return a client instance
|
|
55
|
+
* @param walletClient Viem wallet client with deployment permissions
|
|
56
|
+
* @param account Account to deploy from
|
|
57
|
+
* @param usdcTokenAddress Address of the USDC token contract
|
|
58
|
+
* @param ownerAddress Address that will own the deployed contract
|
|
59
|
+
* @returns Promise resolving to a MailerClient instance
|
|
65
60
|
*/
|
|
66
|
-
static async deploy(walletClient, publicClient, account, usdcTokenAddress, ownerAddress
|
|
67
|
-
// For deployment, we need to estimate gas differently
|
|
68
|
-
// Use a reasonable default for deployment gas
|
|
69
|
-
const estimatedGas = BigInt(3000000); // Default deployment gas
|
|
70
|
-
// Apply gas buffer
|
|
71
|
-
const multiplier = gasOptions?.gasMultiplier ?? 1.5; // Higher multiplier for deployment
|
|
72
|
-
const gasLimit = gasOptions?.gasLimit ?? BigInt(Math.ceil(Number(estimatedGas) * multiplier));
|
|
73
|
-
// Deploy with estimated gas
|
|
61
|
+
static async deploy(walletClient, publicClient, account, usdcTokenAddress, ownerAddress) {
|
|
74
62
|
const hash = await walletClient.deployContract({
|
|
75
63
|
abi: MAILER_ABI,
|
|
76
64
|
bytecode: MAILER_BYTECODE,
|
|
77
|
-
args: [
|
|
65
|
+
args: [getAddress(usdcTokenAddress), getAddress(ownerAddress)],
|
|
78
66
|
account,
|
|
79
67
|
chain: walletClient.chain,
|
|
80
|
-
gas: gasLimit,
|
|
81
|
-
...(gasOptions?.maxFeePerGas && { maxFeePerGas: gasOptions.maxFeePerGas }),
|
|
82
|
-
...(gasOptions?.maxPriorityFeePerGas && { maxPriorityFeePerGas: gasOptions.maxPriorityFeePerGas }),
|
|
83
68
|
});
|
|
84
69
|
const receipt = await publicClient.waitForTransactionReceipt({ hash });
|
|
85
70
|
if (!receipt.contractAddress) {
|
|
86
|
-
throw new Error(
|
|
71
|
+
throw new Error("Contract deployment failed");
|
|
87
72
|
}
|
|
88
|
-
return
|
|
89
|
-
client: new MailerClient(receipt.contractAddress, publicClient),
|
|
90
|
-
result: { hash, estimatedGas, gasLimit }
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
getAddress() {
|
|
94
|
-
return this.contractAddress;
|
|
73
|
+
return new MailerClient(receipt.contractAddress, publicClient);
|
|
95
74
|
}
|
|
96
75
|
/**
|
|
97
|
-
*
|
|
76
|
+
* @description Send a message with optional revenue sharing
|
|
77
|
+
* @notice Two modes:
|
|
78
|
+
* - revenueShareToReceiver=true: Sender pays 0.1 USDC, recipient gets 90% claimable
|
|
79
|
+
* - revenueShareToReceiver=false: Sender pays 0.01 USDC only
|
|
80
|
+
* @param to Recipient address who receives the message and potential revenue share
|
|
81
|
+
* @param subject Message subject line
|
|
82
|
+
* @param body Message content
|
|
83
|
+
* @param revenueShareToReceiver If true, recipient gets 90% revenue share; if false, no revenue share
|
|
84
|
+
* @param resolveSenderToName If true, resolve sender address to name via off-chain service
|
|
85
|
+
* @param walletClient Viem wallet client for transaction
|
|
86
|
+
* @param account Account to send from
|
|
87
|
+
* @returns Promise resolving to transaction hash
|
|
88
|
+
* @example
|
|
89
|
+
* ```typescript
|
|
90
|
+
* // Send with revenue share to recipient
|
|
91
|
+
* const hash = await mailer.send('0x...', 'Subject', 'Priority message', true, false, walletClient, account);
|
|
92
|
+
* // Send standard message (no revenue share)
|
|
93
|
+
* const hash2 = await mailer.send('0x...', 'Subject', 'Standard message', false, false, walletClient, account);
|
|
94
|
+
* await publicClient.waitForTransactionReceipt({ hash });
|
|
95
|
+
* ```
|
|
98
96
|
*/
|
|
99
|
-
async send(to, subject, body,
|
|
100
|
-
|
|
101
|
-
const gasLimit = await this.estimateGasWithBuffer(() => this.publicClient.estimateContractGas({
|
|
97
|
+
async send(to, subject, body, revenueShareToReceiver, resolveSenderToName = false, walletClient, account) {
|
|
98
|
+
return await walletClient.writeContract({
|
|
102
99
|
address: this.contractAddress,
|
|
103
100
|
abi: MAILER_ABI,
|
|
104
101
|
functionName: 'send',
|
|
105
|
-
args: [
|
|
106
|
-
normalizeAddress(to),
|
|
107
|
-
subject,
|
|
108
|
-
body,
|
|
109
|
-
normalizeAddress(payer),
|
|
110
|
-
revenueShareToReceiver,
|
|
111
|
-
resolveSenderToName,
|
|
112
|
-
],
|
|
113
|
-
account,
|
|
114
|
-
}), gasOptions);
|
|
115
|
-
const hash = await walletClient.writeContract({
|
|
116
|
-
address: this.contractAddress,
|
|
117
|
-
abi: MAILER_ABI,
|
|
118
|
-
functionName: 'send',
|
|
119
|
-
args: [
|
|
120
|
-
normalizeAddress(to),
|
|
121
|
-
subject,
|
|
122
|
-
body,
|
|
123
|
-
normalizeAddress(payer),
|
|
124
|
-
revenueShareToReceiver,
|
|
125
|
-
resolveSenderToName,
|
|
126
|
-
],
|
|
102
|
+
args: [to, subject, body, revenueShareToReceiver, resolveSenderToName],
|
|
127
103
|
account,
|
|
128
104
|
chain: walletClient.chain,
|
|
129
|
-
...this.buildTxParams(gasLimit, gasOptions),
|
|
130
105
|
});
|
|
131
|
-
return { hash, estimatedGas: gasLimit, gasLimit };
|
|
132
106
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
const hash = await walletClient.writeContract({
|
|
107
|
+
/**
|
|
108
|
+
* @description Send a message using a pre-prepared mail ID with optional revenue sharing
|
|
109
|
+
* @notice Two modes:
|
|
110
|
+
* - revenueShareToReceiver=true: Sender pays 0.1 USDC, recipient gets 90% claimable
|
|
111
|
+
* - revenueShareToReceiver=false: Sender pays 0.01 USDC only
|
|
112
|
+
* @param to Recipient address who receives the message and potential revenue share
|
|
113
|
+
* @param mailId Pre-prepared message identifier
|
|
114
|
+
* @param revenueShareToReceiver If true, recipient gets 90% revenue share; if false, no revenue share
|
|
115
|
+
* @param resolveSenderToName If true, resolve sender address to name via off-chain service
|
|
116
|
+
* @param walletClient Viem wallet client for transaction
|
|
117
|
+
* @param account Account to send from
|
|
118
|
+
* @returns Promise resolving to transaction hash
|
|
119
|
+
*/
|
|
120
|
+
async sendPrepared(to, mailId, revenueShareToReceiver, resolveSenderToName = false, walletClient, account) {
|
|
121
|
+
return await walletClient.writeContract({
|
|
149
122
|
address: this.contractAddress,
|
|
150
123
|
abi: MAILER_ABI,
|
|
151
124
|
functionName: 'sendPrepared',
|
|
152
|
-
args: [
|
|
153
|
-
normalizeAddress(to),
|
|
154
|
-
mailId,
|
|
155
|
-
normalizeAddress(payer),
|
|
156
|
-
revenueShareToReceiver,
|
|
157
|
-
resolveSenderToName,
|
|
158
|
-
],
|
|
125
|
+
args: [to, mailId, revenueShareToReceiver, resolveSenderToName],
|
|
159
126
|
account,
|
|
160
127
|
chain: walletClient.chain,
|
|
161
|
-
...this.buildTxParams(gasLimit, gasOptions),
|
|
162
128
|
});
|
|
163
|
-
return { hash, estimatedGas: gasLimit, gasLimit };
|
|
164
|
-
}
|
|
165
|
-
async sendThroughWebhook(to, webhookId, payer, revenueShareToReceiver, resolveSenderToName, walletClient, account, gasOptions) {
|
|
166
|
-
// Estimate gas for the transaction
|
|
167
|
-
const gasLimit = await this.estimateGasWithBuffer(() => this.publicClient.estimateContractGas({
|
|
168
|
-
address: this.contractAddress,
|
|
169
|
-
abi: MAILER_ABI,
|
|
170
|
-
functionName: 'sendThroughWebhook',
|
|
171
|
-
args: [
|
|
172
|
-
normalizeAddress(to),
|
|
173
|
-
webhookId,
|
|
174
|
-
normalizeAddress(payer),
|
|
175
|
-
revenueShareToReceiver,
|
|
176
|
-
resolveSenderToName,
|
|
177
|
-
],
|
|
178
|
-
account,
|
|
179
|
-
}), gasOptions);
|
|
180
|
-
const hash = await walletClient.writeContract({
|
|
181
|
-
address: this.contractAddress,
|
|
182
|
-
abi: MAILER_ABI,
|
|
183
|
-
functionName: 'sendThroughWebhook',
|
|
184
|
-
args: [
|
|
185
|
-
normalizeAddress(to),
|
|
186
|
-
webhookId,
|
|
187
|
-
normalizeAddress(payer),
|
|
188
|
-
revenueShareToReceiver,
|
|
189
|
-
resolveSenderToName,
|
|
190
|
-
],
|
|
191
|
-
account,
|
|
192
|
-
chain: walletClient.chain,
|
|
193
|
-
...this.buildTxParams(gasLimit, gasOptions),
|
|
194
|
-
});
|
|
195
|
-
return { hash, estimatedGas: gasLimit, gasLimit };
|
|
196
|
-
}
|
|
197
|
-
async sendToEmailAddress(toEmail, subject, body, payer, walletClient, account, gasOptions) {
|
|
198
|
-
// Estimate gas for the transaction
|
|
199
|
-
const gasLimit = await this.estimateGasWithBuffer(() => this.publicClient.estimateContractGas({
|
|
200
|
-
address: this.contractAddress,
|
|
201
|
-
abi: MAILER_ABI,
|
|
202
|
-
functionName: 'sendToEmailAddress',
|
|
203
|
-
args: [toEmail, subject, body, normalizeAddress(payer)],
|
|
204
|
-
account,
|
|
205
|
-
}), gasOptions);
|
|
206
|
-
const hash = await walletClient.writeContract({
|
|
207
|
-
address: this.contractAddress,
|
|
208
|
-
abi: MAILER_ABI,
|
|
209
|
-
functionName: 'sendToEmailAddress',
|
|
210
|
-
args: [toEmail, subject, body, normalizeAddress(payer)],
|
|
211
|
-
account,
|
|
212
|
-
chain: walletClient.chain,
|
|
213
|
-
...this.buildTxParams(gasLimit, gasOptions),
|
|
214
|
-
});
|
|
215
|
-
return { hash, estimatedGas: gasLimit, gasLimit };
|
|
216
|
-
}
|
|
217
|
-
async sendPreparedToEmailAddress(toEmail, mailId, payer, walletClient, account, gasOptions) {
|
|
218
|
-
// Estimate gas for the transaction
|
|
219
|
-
const gasLimit = await this.estimateGasWithBuffer(() => this.publicClient.estimateContractGas({
|
|
220
|
-
address: this.contractAddress,
|
|
221
|
-
abi: MAILER_ABI,
|
|
222
|
-
functionName: 'sendPreparedToEmailAddress',
|
|
223
|
-
args: [toEmail, mailId, normalizeAddress(payer)],
|
|
224
|
-
account,
|
|
225
|
-
}), gasOptions);
|
|
226
|
-
const hash = await walletClient.writeContract({
|
|
227
|
-
address: this.contractAddress,
|
|
228
|
-
abi: MAILER_ABI,
|
|
229
|
-
functionName: 'sendPreparedToEmailAddress',
|
|
230
|
-
args: [toEmail, mailId, normalizeAddress(payer)],
|
|
231
|
-
account,
|
|
232
|
-
chain: walletClient.chain,
|
|
233
|
-
...this.buildTxParams(gasLimit, gasOptions),
|
|
234
|
-
});
|
|
235
|
-
return { hash, estimatedGas: gasLimit, gasLimit };
|
|
236
|
-
}
|
|
237
|
-
async getFee() {
|
|
238
|
-
return (await this.publicClient.readContract({
|
|
239
|
-
address: this.contractAddress,
|
|
240
|
-
abi: MAILER_ABI,
|
|
241
|
-
functionName: 'getFee',
|
|
242
|
-
}));
|
|
243
129
|
}
|
|
244
130
|
async getSendFee() {
|
|
245
|
-
return
|
|
131
|
+
return await this.publicClient.readContract({
|
|
246
132
|
address: this.contractAddress,
|
|
247
133
|
abi: MAILER_ABI,
|
|
248
134
|
functionName: 'sendFee',
|
|
249
|
-
|
|
250
|
-
}
|
|
251
|
-
async setFee(newFee, walletClient, account, gasOptions) {
|
|
252
|
-
// Estimate gas for the transaction
|
|
253
|
-
const gasLimit = await this.estimateGasWithBuffer(() => this.publicClient.estimateContractGas({
|
|
254
|
-
address: this.contractAddress,
|
|
255
|
-
abi: MAILER_ABI,
|
|
256
|
-
functionName: 'setFee',
|
|
257
|
-
args: [newFee],
|
|
258
|
-
account,
|
|
259
|
-
}), gasOptions);
|
|
260
|
-
const hash = await walletClient.writeContract({
|
|
261
|
-
address: this.contractAddress,
|
|
262
|
-
abi: MAILER_ABI,
|
|
263
|
-
functionName: 'setFee',
|
|
264
|
-
args: [newFee],
|
|
265
|
-
account,
|
|
266
|
-
chain: walletClient.chain,
|
|
267
|
-
...this.buildTxParams(gasLimit, gasOptions),
|
|
135
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
268
136
|
});
|
|
269
|
-
return { hash, estimatedGas: gasLimit, gasLimit };
|
|
270
137
|
}
|
|
271
138
|
async getUsdcToken() {
|
|
272
|
-
return
|
|
139
|
+
return await this.publicClient.readContract({
|
|
273
140
|
address: this.contractAddress,
|
|
274
141
|
abi: MAILER_ABI,
|
|
275
142
|
functionName: 'usdcToken',
|
|
276
|
-
|
|
143
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
144
|
+
});
|
|
277
145
|
}
|
|
278
|
-
|
|
279
|
-
return
|
|
280
|
-
address: this.contractAddress,
|
|
281
|
-
abi: MAILER_ABI,
|
|
282
|
-
functionName: 'owner',
|
|
283
|
-
}));
|
|
146
|
+
getAddress() {
|
|
147
|
+
return this.contractAddress;
|
|
284
148
|
}
|
|
285
|
-
async claimRecipientShare(walletClient, account
|
|
286
|
-
|
|
287
|
-
const gasLimit = await this.estimateGasWithBuffer(() => this.publicClient.estimateContractGas({
|
|
288
|
-
address: this.contractAddress,
|
|
289
|
-
abi: MAILER_ABI,
|
|
290
|
-
functionName: 'claimRecipientShare',
|
|
291
|
-
account,
|
|
292
|
-
}), gasOptions);
|
|
293
|
-
const hash = await walletClient.writeContract({
|
|
149
|
+
async claimRecipientShare(walletClient, account) {
|
|
150
|
+
return await walletClient.writeContract({
|
|
294
151
|
address: this.contractAddress,
|
|
295
152
|
abi: MAILER_ABI,
|
|
296
153
|
functionName: 'claimRecipientShare',
|
|
297
154
|
account,
|
|
298
155
|
chain: walletClient.chain,
|
|
299
|
-
...this.buildTxParams(gasLimit, gasOptions),
|
|
300
156
|
});
|
|
301
|
-
return { hash, estimatedGas: gasLimit, gasLimit };
|
|
302
157
|
}
|
|
303
|
-
async claimOwnerShare(walletClient, account
|
|
304
|
-
|
|
305
|
-
const gasLimit = await this.estimateGasWithBuffer(() => this.publicClient.estimateContractGas({
|
|
306
|
-
address: this.contractAddress,
|
|
307
|
-
abi: MAILER_ABI,
|
|
308
|
-
functionName: 'claimOwnerShare',
|
|
309
|
-
account,
|
|
310
|
-
}), gasOptions);
|
|
311
|
-
const hash = await walletClient.writeContract({
|
|
158
|
+
async claimOwnerShare(walletClient, account) {
|
|
159
|
+
return await walletClient.writeContract({
|
|
312
160
|
address: this.contractAddress,
|
|
313
161
|
abi: MAILER_ABI,
|
|
314
162
|
functionName: 'claimOwnerShare',
|
|
315
163
|
account,
|
|
316
164
|
chain: walletClient.chain,
|
|
317
|
-
...this.buildTxParams(gasLimit, gasOptions),
|
|
318
165
|
});
|
|
319
|
-
return { hash, estimatedGas: gasLimit, gasLimit };
|
|
320
166
|
}
|
|
321
|
-
async claimExpiredShares(recipient, walletClient, account
|
|
322
|
-
|
|
323
|
-
const gasLimit = await this.estimateGasWithBuffer(() => this.publicClient.estimateContractGas({
|
|
324
|
-
address: this.contractAddress,
|
|
325
|
-
abi: MAILER_ABI,
|
|
326
|
-
functionName: 'claimExpiredShares',
|
|
327
|
-
args: [normalizeAddress(recipient)],
|
|
328
|
-
account,
|
|
329
|
-
}), gasOptions);
|
|
330
|
-
const hash = await walletClient.writeContract({
|
|
167
|
+
async claimExpiredShares(recipient, walletClient, account) {
|
|
168
|
+
return await walletClient.writeContract({
|
|
331
169
|
address: this.contractAddress,
|
|
332
170
|
abi: MAILER_ABI,
|
|
333
171
|
functionName: 'claimExpiredShares',
|
|
334
|
-
args: [
|
|
172
|
+
args: [getAddress(recipient)],
|
|
335
173
|
account,
|
|
336
174
|
chain: walletClient.chain,
|
|
337
|
-
...this.buildTxParams(gasLimit, gasOptions),
|
|
338
175
|
});
|
|
339
|
-
return { hash, estimatedGas: gasLimit, gasLimit };
|
|
340
176
|
}
|
|
341
177
|
async getRecipientClaimable(recipient) {
|
|
342
|
-
const
|
|
178
|
+
const result = await this.publicClient.readContract({
|
|
343
179
|
address: this.contractAddress,
|
|
344
180
|
abi: MAILER_ABI,
|
|
345
181
|
functionName: 'getRecipientClaimable',
|
|
346
|
-
args: [
|
|
347
|
-
|
|
348
|
-
|
|
182
|
+
args: [getAddress(recipient)],
|
|
183
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
184
|
+
});
|
|
185
|
+
return {
|
|
186
|
+
amount: result[0],
|
|
187
|
+
expiresAt: result[1],
|
|
188
|
+
isExpired: result[2]
|
|
189
|
+
};
|
|
349
190
|
}
|
|
350
191
|
async getOwnerClaimable() {
|
|
351
|
-
return
|
|
192
|
+
return await this.publicClient.readContract({
|
|
352
193
|
address: this.contractAddress,
|
|
353
194
|
abi: MAILER_ABI,
|
|
354
|
-
functionName: 'getOwnerClaimable'
|
|
355
|
-
|
|
195
|
+
functionName: 'getOwnerClaimable'
|
|
196
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
197
|
+
});
|
|
356
198
|
}
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
199
|
+
// Delegation functionality
|
|
200
|
+
/**
|
|
201
|
+
* Delegate mail handling to another address
|
|
202
|
+
* @param delegate Address to delegate to (or 0x0 to clear delegation)
|
|
203
|
+
* @param walletClient Connected wallet client
|
|
204
|
+
* @param account Account to send transaction from
|
|
205
|
+
* @returns Transaction hash
|
|
206
|
+
*/
|
|
207
|
+
async delegateTo(delegate, walletClient, account) {
|
|
208
|
+
return await walletClient.writeContract({
|
|
367
209
|
address: this.contractAddress,
|
|
368
210
|
abi: MAILER_ABI,
|
|
369
211
|
functionName: 'delegateTo',
|
|
370
|
-
args: [
|
|
212
|
+
args: [getAddress(delegate)],
|
|
371
213
|
account,
|
|
372
214
|
chain: walletClient.chain,
|
|
373
|
-
...this.buildTxParams(gasLimit, gasOptions),
|
|
374
215
|
});
|
|
375
|
-
return { hash, estimatedGas: gasLimit, gasLimit };
|
|
376
216
|
}
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
const hash = await walletClient.writeContract({
|
|
217
|
+
/**
|
|
218
|
+
* Reject a delegation made to you by another address
|
|
219
|
+
* @param delegatingAddress Address that delegated to you
|
|
220
|
+
* @param walletClient Connected wallet client
|
|
221
|
+
* @param account Account to send transaction from
|
|
222
|
+
* @returns Transaction hash
|
|
223
|
+
*/
|
|
224
|
+
async rejectDelegation(delegatingAddress, walletClient, account) {
|
|
225
|
+
return await walletClient.writeContract({
|
|
387
226
|
address: this.contractAddress,
|
|
388
227
|
abi: MAILER_ABI,
|
|
389
228
|
functionName: 'rejectDelegation',
|
|
390
|
-
args: [
|
|
229
|
+
args: [getAddress(delegatingAddress)],
|
|
391
230
|
account,
|
|
392
231
|
chain: walletClient.chain,
|
|
393
|
-
...this.buildTxParams(gasLimit, gasOptions),
|
|
394
232
|
});
|
|
395
|
-
return { hash, estimatedGas: gasLimit, gasLimit };
|
|
396
233
|
}
|
|
234
|
+
/**
|
|
235
|
+
* Get current delegation fee in USDC (6 decimals)
|
|
236
|
+
* @returns Delegation fee amount
|
|
237
|
+
*/
|
|
397
238
|
async getDelegationFee() {
|
|
398
|
-
return
|
|
239
|
+
return await this.publicClient.readContract({
|
|
399
240
|
address: this.contractAddress,
|
|
400
241
|
abi: MAILER_ABI,
|
|
401
242
|
functionName: 'getDelegationFee',
|
|
402
|
-
|
|
243
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
244
|
+
});
|
|
403
245
|
}
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
const hash = await walletClient.writeContract({
|
|
246
|
+
/**
|
|
247
|
+
* Update delegation fee (owner only)
|
|
248
|
+
* @param newFee New fee amount in USDC (6 decimals)
|
|
249
|
+
* @param walletClient Connected wallet client
|
|
250
|
+
* @param account Account to send transaction from
|
|
251
|
+
* @returns Transaction hash
|
|
252
|
+
*/
|
|
253
|
+
async setDelegationFee(newFee, walletClient, account) {
|
|
254
|
+
return await walletClient.writeContract({
|
|
414
255
|
address: this.contractAddress,
|
|
415
256
|
abi: MAILER_ABI,
|
|
416
257
|
functionName: 'setDelegationFee',
|
|
417
258
|
args: [newFee],
|
|
418
259
|
account,
|
|
419
260
|
chain: walletClient.chain,
|
|
420
|
-
...this.buildTxParams(gasLimit, gasOptions),
|
|
421
261
|
});
|
|
422
|
-
return { hash, estimatedGas: gasLimit, gasLimit };
|
|
423
262
|
}
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
263
|
+
/**
|
|
264
|
+
* @description Send a message to an email address (no wallet known)
|
|
265
|
+
* @notice Charges only 10% owner fee since recipient wallet is unknown
|
|
266
|
+
* @param toEmail Email address of the recipient
|
|
267
|
+
* @param subject Message subject line
|
|
268
|
+
* @param body Message content
|
|
269
|
+
* @param walletClient Viem wallet client for transaction
|
|
270
|
+
* @param account Account to send from
|
|
271
|
+
* @returns Promise resolving to transaction hash
|
|
272
|
+
* @example
|
|
273
|
+
* ```typescript
|
|
274
|
+
* // Send to email address
|
|
275
|
+
* const hash = await mailer.sendToEmailAddress('user@example.com', 'Subject', 'Body', walletClient, account);
|
|
276
|
+
* await publicClient.waitForTransactionReceipt({ hash });
|
|
277
|
+
* ```
|
|
278
|
+
*/
|
|
279
|
+
async sendToEmailAddress(toEmail, subject, body, walletClient, account) {
|
|
280
|
+
return await walletClient.writeContract({
|
|
434
281
|
address: this.contractAddress,
|
|
435
282
|
abi: MAILER_ABI,
|
|
436
|
-
functionName: '
|
|
437
|
-
args: [
|
|
283
|
+
functionName: 'sendToEmailAddress',
|
|
284
|
+
args: [toEmail, subject, body],
|
|
438
285
|
account,
|
|
439
286
|
chain: walletClient.chain,
|
|
440
|
-
...this.buildTxParams(gasLimit, gasOptions),
|
|
441
287
|
});
|
|
442
|
-
return { hash, estimatedGas: gasLimit, gasLimit };
|
|
443
288
|
}
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
289
|
+
/**
|
|
290
|
+
* @description Send a pre-prepared message to an email address (no wallet known)
|
|
291
|
+
* @notice Charges only 10% owner fee since recipient wallet is unknown
|
|
292
|
+
* @param toEmail Email address of the recipient
|
|
293
|
+
* @param mailId Pre-prepared message identifier
|
|
294
|
+
* @param walletClient Viem wallet client for transaction
|
|
295
|
+
* @param account Account to send from
|
|
296
|
+
* @returns Promise resolving to transaction hash
|
|
297
|
+
*/
|
|
298
|
+
async sendPreparedToEmailAddress(toEmail, mailId, walletClient, account) {
|
|
299
|
+
return await walletClient.writeContract({
|
|
454
300
|
address: this.contractAddress,
|
|
455
301
|
abi: MAILER_ABI,
|
|
456
|
-
functionName: '
|
|
457
|
-
args: [
|
|
302
|
+
functionName: 'sendPreparedToEmailAddress',
|
|
303
|
+
args: [toEmail, mailId],
|
|
458
304
|
account,
|
|
459
305
|
chain: walletClient.chain,
|
|
460
|
-
...this.buildTxParams(gasLimit, gasOptions),
|
|
461
306
|
});
|
|
462
|
-
return { hash, estimatedGas: gasLimit, gasLimit };
|
|
463
|
-
}
|
|
464
|
-
async getCustomFeePercentage(target) {
|
|
465
|
-
const percentage = (await this.publicClient.readContract({
|
|
466
|
-
address: this.contractAddress,
|
|
467
|
-
abi: MAILER_ABI,
|
|
468
|
-
functionName: 'getCustomFeePercentage',
|
|
469
|
-
args: [normalizeAddress(target)],
|
|
470
|
-
}));
|
|
471
|
-
return Number(percentage);
|
|
472
|
-
}
|
|
473
|
-
async getCustomFeeDiscount(target) {
|
|
474
|
-
const discount = (await this.publicClient.readContract({
|
|
475
|
-
address: this.contractAddress,
|
|
476
|
-
abi: MAILER_ABI,
|
|
477
|
-
functionName: 'customFeeDiscount',
|
|
478
|
-
args: [normalizeAddress(target)],
|
|
479
|
-
}));
|
|
480
|
-
return Number(discount);
|
|
481
307
|
}
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
const hash = await walletClient.writeContract({
|
|
308
|
+
/**
|
|
309
|
+
* Set the send fee (owner only)
|
|
310
|
+
* @param newFee New fee amount in USDC (6 decimals)
|
|
311
|
+
* @param walletClient Viem wallet client for transaction
|
|
312
|
+
* @param account Account to send from (must be owner)
|
|
313
|
+
* @returns Promise resolving to transaction hash
|
|
314
|
+
*/
|
|
315
|
+
async setFee(newFee, walletClient, account) {
|
|
316
|
+
return await walletClient.writeContract({
|
|
492
317
|
address: this.contractAddress,
|
|
493
318
|
abi: MAILER_ABI,
|
|
494
|
-
functionName: '
|
|
495
|
-
args: [
|
|
319
|
+
functionName: 'setFee',
|
|
320
|
+
args: [newFee],
|
|
496
321
|
account,
|
|
497
322
|
chain: walletClient.chain,
|
|
498
|
-
...this.buildTxParams(gasLimit, gasOptions),
|
|
499
323
|
});
|
|
500
|
-
return { hash, estimatedGas: gasLimit, gasLimit };
|
|
501
324
|
}
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
args: [normalizeAddress(contractAddress)],
|
|
509
|
-
account,
|
|
510
|
-
}), gasOptions);
|
|
511
|
-
const hash = await walletClient.writeContract({
|
|
325
|
+
/**
|
|
326
|
+
* Get the current send fee
|
|
327
|
+
* @returns Current send fee in USDC (6 decimals)
|
|
328
|
+
*/
|
|
329
|
+
async getFee() {
|
|
330
|
+
return await this.publicClient.readContract({
|
|
512
331
|
address: this.contractAddress,
|
|
513
332
|
abi: MAILER_ABI,
|
|
514
|
-
functionName: '
|
|
515
|
-
|
|
516
|
-
account,
|
|
517
|
-
chain: walletClient.chain,
|
|
518
|
-
...this.buildTxParams(gasLimit, gasOptions),
|
|
333
|
+
functionName: 'getFee',
|
|
334
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
519
335
|
});
|
|
520
|
-
return { hash, estimatedGas: gasLimit, gasLimit };
|
|
521
336
|
}
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
return
|
|
530
|
-
}
|
|
531
|
-
async pause(walletClient, account, gasOptions) {
|
|
532
|
-
// Estimate gas for the transaction
|
|
533
|
-
const gasLimit = await this.estimateGasWithBuffer(() => this.publicClient.estimateContractGas({
|
|
534
|
-
address: this.contractAddress,
|
|
535
|
-
abi: MAILER_ABI,
|
|
536
|
-
functionName: 'pause',
|
|
537
|
-
account,
|
|
538
|
-
}), gasOptions);
|
|
539
|
-
const hash = await walletClient.writeContract({
|
|
337
|
+
/**
|
|
338
|
+
* Pause the contract and distribute all claimable funds (owner only)
|
|
339
|
+
* @param walletClient Viem wallet client for transaction
|
|
340
|
+
* @param account Account to send from (must be owner)
|
|
341
|
+
* @returns Promise resolving to transaction hash
|
|
342
|
+
*/
|
|
343
|
+
async pause(walletClient, account) {
|
|
344
|
+
return await walletClient.writeContract({
|
|
540
345
|
address: this.contractAddress,
|
|
541
346
|
abi: MAILER_ABI,
|
|
542
347
|
functionName: 'pause',
|
|
543
348
|
account,
|
|
544
349
|
chain: walletClient.chain,
|
|
545
|
-
...this.buildTxParams(gasLimit, gasOptions),
|
|
546
350
|
});
|
|
547
|
-
return { hash, estimatedGas: gasLimit, gasLimit };
|
|
548
351
|
}
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
const hash = await walletClient.writeContract({
|
|
352
|
+
/**
|
|
353
|
+
* Unpause the contract (owner only)
|
|
354
|
+
* @param walletClient Viem wallet client for transaction
|
|
355
|
+
* @param account Account to send from (must be owner)
|
|
356
|
+
* @returns Promise resolving to transaction hash
|
|
357
|
+
*/
|
|
358
|
+
async unpause(walletClient, account) {
|
|
359
|
+
return await walletClient.writeContract({
|
|
558
360
|
address: this.contractAddress,
|
|
559
361
|
abi: MAILER_ABI,
|
|
560
362
|
functionName: 'unpause',
|
|
561
363
|
account,
|
|
562
364
|
chain: walletClient.chain,
|
|
563
|
-
...this.buildTxParams(gasLimit, gasOptions),
|
|
564
365
|
});
|
|
565
|
-
return { hash, estimatedGas: gasLimit, gasLimit };
|
|
566
366
|
}
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
const hash = await walletClient.writeContract({
|
|
367
|
+
/**
|
|
368
|
+
* Emergency unpause without fund distribution (owner only)
|
|
369
|
+
* @param walletClient Viem wallet client for transaction
|
|
370
|
+
* @param account Account to send from (must be owner)
|
|
371
|
+
* @returns Promise resolving to transaction hash
|
|
372
|
+
*/
|
|
373
|
+
async emergencyUnpause(walletClient, account) {
|
|
374
|
+
return await walletClient.writeContract({
|
|
576
375
|
address: this.contractAddress,
|
|
577
376
|
abi: MAILER_ABI,
|
|
578
377
|
functionName: 'emergencyUnpause',
|
|
579
378
|
account,
|
|
580
379
|
chain: walletClient.chain,
|
|
581
|
-
...this.buildTxParams(gasLimit, gasOptions),
|
|
582
380
|
});
|
|
583
|
-
return { hash, estimatedGas: gasLimit, gasLimit };
|
|
584
381
|
}
|
|
382
|
+
/**
|
|
383
|
+
* Check if contract is currently paused
|
|
384
|
+
* @returns True if contract is paused, false otherwise
|
|
385
|
+
*/
|
|
585
386
|
async isPaused() {
|
|
586
|
-
return
|
|
387
|
+
return await this.publicClient.readContract({
|
|
587
388
|
address: this.contractAddress,
|
|
588
389
|
abi: MAILER_ABI,
|
|
589
390
|
functionName: 'isPaused',
|
|
590
|
-
|
|
391
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
392
|
+
});
|
|
591
393
|
}
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
394
|
+
/**
|
|
395
|
+
* Distribute a specific recipient's claimable funds during pause
|
|
396
|
+
* Anyone can call this function when contract is paused
|
|
397
|
+
* @param recipient Address to distribute funds for
|
|
398
|
+
* @param walletClient Viem wallet client for transaction
|
|
399
|
+
* @param account Account to send from
|
|
400
|
+
* @returns Promise resolving to transaction hash
|
|
401
|
+
*/
|
|
402
|
+
async distributeClaimableFunds(recipient, walletClient, account) {
|
|
403
|
+
return await walletClient.writeContract({
|
|
602
404
|
address: this.contractAddress,
|
|
603
405
|
abi: MAILER_ABI,
|
|
604
406
|
functionName: 'distributeClaimableFunds',
|
|
605
|
-
args: [
|
|
407
|
+
args: [getAddress(recipient)],
|
|
606
408
|
account,
|
|
607
409
|
chain: walletClient.chain,
|
|
608
|
-
...this.buildTxParams(gasLimit, gasOptions),
|
|
609
410
|
});
|
|
610
|
-
return { hash, estimatedGas: gasLimit, gasLimit };
|
|
611
411
|
}
|
|
612
412
|
}
|
|
613
|
-
MailerClient.abi = MAILER_ABI;
|
|
614
|
-
MailerClient.bytecode = MAILER_BYTECODE;
|
|
615
413
|
//# sourceMappingURL=mailer-client.js.map
|