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