four-flap-meme-sdk 1.9.21 → 1.9.23
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.
|
@@ -62,8 +62,16 @@ export declare class FairPoolQuery {
|
|
|
62
62
|
}
|
|
63
63
|
/**
|
|
64
64
|
* 构建 Pool claim 交易
|
|
65
|
+
* @param sharedProvider 可选的共享 provider,避免重复创建连接
|
|
66
|
+
* @param sharedFeeData 可选的共享 feeData,避免重复 RPC 调用
|
|
65
67
|
*/
|
|
66
|
-
export declare function claimFromPool(params: PoolClaimParams
|
|
68
|
+
export declare function claimFromPool(params: PoolClaimParams & {
|
|
69
|
+
sharedProvider?: JsonRpcProvider;
|
|
70
|
+
sharedFeeData?: {
|
|
71
|
+
maxFeePerGas: bigint;
|
|
72
|
+
maxPriorityFeePerGas: bigint;
|
|
73
|
+
};
|
|
74
|
+
}): Promise<PoolClaimResult>;
|
|
67
75
|
/**
|
|
68
76
|
* 构建 Pool claim 交易 — ForSubmit 版本
|
|
69
77
|
* 自动追加利润转账,兼容 emitservice submit_blockrazor 接口
|
|
@@ -84,14 +84,30 @@ export class FairPoolQuery {
|
|
|
84
84
|
// ============================================================================
|
|
85
85
|
/**
|
|
86
86
|
* 构建 Pool claim 交易
|
|
87
|
+
* @param sharedProvider 可选的共享 provider,避免重复创建连接
|
|
88
|
+
* @param sharedFeeData 可选的共享 feeData,避免重复 RPC 调用
|
|
87
89
|
*/
|
|
88
90
|
export async function claimFromPool(params) {
|
|
89
|
-
const { rpcUrl = ENI_RPC_URL, privateKey, poolAddress, amountToken, inviteCode = '', value = 0n, gasPrice, } = params;
|
|
90
|
-
const provider = new JsonRpcProvider(rpcUrl, ENI_CHAIN_ID, { staticNetwork: true });
|
|
91
|
+
const { rpcUrl = ENI_RPC_URL, privateKey, poolAddress, amountToken, inviteCode = '', value = 0n, gasPrice, sharedProvider, sharedFeeData, } = params;
|
|
92
|
+
const provider = sharedProvider ?? new JsonRpcProvider(rpcUrl, ENI_CHAIN_ID, { staticNetwork: true });
|
|
91
93
|
const wallet = new Wallet(privateKey, provider);
|
|
92
94
|
const calldata = poolIface.encodeFunctionData('claim', [amountToken, inviteCode]);
|
|
93
95
|
const nonce = await wallet.getNonce();
|
|
94
|
-
|
|
96
|
+
let maxFeePerGas;
|
|
97
|
+
let maxPriorityFeePerGas;
|
|
98
|
+
if (gasPrice) {
|
|
99
|
+
maxFeePerGas = gasPrice;
|
|
100
|
+
maxPriorityFeePerGas = sharedFeeData?.maxPriorityFeePerGas ?? 0n;
|
|
101
|
+
}
|
|
102
|
+
else if (sharedFeeData) {
|
|
103
|
+
maxFeePerGas = sharedFeeData.maxFeePerGas;
|
|
104
|
+
maxPriorityFeePerGas = sharedFeeData.maxPriorityFeePerGas;
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
const feeData = await provider.getFeeData();
|
|
108
|
+
maxFeePerGas = feeData.maxFeePerGas ?? feeData.gasPrice ?? 1000000000n;
|
|
109
|
+
maxPriorityFeePerGas = feeData.maxPriorityFeePerGas ?? 0n;
|
|
110
|
+
}
|
|
95
111
|
const signedTx = await wallet.signTransaction({
|
|
96
112
|
to: poolAddress,
|
|
97
113
|
data: calldata,
|
|
@@ -99,8 +115,8 @@ export async function claimFromPool(params) {
|
|
|
99
115
|
nonce,
|
|
100
116
|
chainId: ENI_CHAIN_ID,
|
|
101
117
|
type: 2,
|
|
102
|
-
maxFeePerGas
|
|
103
|
-
maxPriorityFeePerGas
|
|
118
|
+
maxFeePerGas,
|
|
119
|
+
maxPriorityFeePerGas,
|
|
104
120
|
gasLimit: 500000n,
|
|
105
121
|
});
|
|
106
122
|
return { signedTx, from: wallet.address, nonce };
|
|
@@ -148,10 +164,12 @@ export async function batchClaimForSubmit(params) {
|
|
|
148
164
|
if (claims.length === 0) {
|
|
149
165
|
return { signedTransactions: [], totalValue: 0n };
|
|
150
166
|
}
|
|
167
|
+
// 复用单个 provider 和 feeData,减少 RPC 调用
|
|
151
168
|
const provider = new JsonRpcProvider(rpcUrl, ENI_CHAIN_ID, { staticNetwork: true });
|
|
152
169
|
const feeData = await provider.getFeeData();
|
|
153
170
|
const maxFeePerGas = gasPrice ?? feeData.maxFeePerGas ?? feeData.gasPrice ?? 1000000000n;
|
|
154
171
|
const maxPriorityFeePerGas = feeData.maxPriorityFeePerGas ?? 0n;
|
|
172
|
+
const sharedFeeData = { maxFeePerGas, maxPriorityFeePerGas };
|
|
155
173
|
const signedTransactions = [];
|
|
156
174
|
let totalValue = 0n;
|
|
157
175
|
let totalQuoteAmount = 0n;
|
|
@@ -165,6 +183,8 @@ export async function batchClaimForSubmit(params) {
|
|
|
165
183
|
inviteCode: claim.inviteCode ?? '',
|
|
166
184
|
value: claim.value,
|
|
167
185
|
gasPrice: maxFeePerGas,
|
|
186
|
+
sharedProvider: provider,
|
|
187
|
+
sharedFeeData,
|
|
168
188
|
});
|
|
169
189
|
signedTransactions.push(result.signedTx);
|
|
170
190
|
totalValue += claim.value;
|
|
@@ -165,9 +165,18 @@ export function validateLaunchParams(params) {
|
|
|
165
165
|
if (params.buybackRate < 0n || params.buybackRate > RATE_BASE) {
|
|
166
166
|
errors.push(`buybackRate ${params.buybackRate} out of range [0, ${RATE_BASE}]`);
|
|
167
167
|
}
|
|
168
|
+
if (params.buybackRate > 0n && params.buybackPath.length === 0) {
|
|
169
|
+
errors.push('buybackPath must not be empty when buybackRate > 0');
|
|
170
|
+
}
|
|
168
171
|
if (params.lpAddRate < 0n || params.lpAddRate > RATE_BASE) {
|
|
169
172
|
errors.push(`lpAddRate ${params.lpAddRate} out of range [0, ${RATE_BASE}]`);
|
|
170
173
|
}
|
|
174
|
+
if (params.whitelistEnabled && params.whitelistAddrs.length === 0) {
|
|
175
|
+
errors.push('whitelistAddrs must not be empty when whitelistEnabled is true');
|
|
176
|
+
}
|
|
177
|
+
if (params.inviteCodeEnabled && params.inviteCodes.length === 0) {
|
|
178
|
+
errors.push('inviteCodes must not be empty when inviteCodeEnabled is true');
|
|
179
|
+
}
|
|
171
180
|
if (params.vestingAmount > 0n) {
|
|
172
181
|
if (params.vestingReleaseEndTime < params.vestingLockEndTime) {
|
|
173
182
|
errors.push('vestingReleaseEndTime must be >= vestingLockEndTime');
|