clanker-sdk 4.2.2 → 4.2.3-canary.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/dist/{clankerTokenV4-CYKWWpwe.d.ts → clankerTokenV4-Btn0ZN4v.d.ts} +1 -1
- package/dist/errors-5Gv28Tkr.d.ts +14 -0
- package/dist/index.d.ts +2 -2
- package/dist/legacyFeeClaims/data/token_creators_with_updates.csv +356508 -0
- package/dist/legacyFeeClaims/index.d.ts +2695 -0
- package/dist/legacyFeeClaims/index.js +685 -0
- package/dist/v3/index.d.ts +2 -1
- package/dist/v4/extensions/index.d.ts +3 -2
- package/dist/v4/index.d.ts +4 -3
- package/dist/{write-clanker-contracts-DVM3LXMa.d.ts → write-clanker-contracts-B4LSHPv2.d.ts} +401 -15
- package/package.json +7 -2
|
@@ -0,0 +1,685 @@
|
|
|
1
|
+
// src/legacyFeeClaims/index.ts
|
|
2
|
+
import { StandardMerkleTree } from "@openzeppelin/merkle-tree";
|
|
3
|
+
import { keccak256 } from "viem";
|
|
4
|
+
import { simulateContract, writeContract } from "viem/actions";
|
|
5
|
+
|
|
6
|
+
// src/abi/legacyFeeClaims/ClankerSafeErc20Spender.ts
|
|
7
|
+
var Clanker_v0_abi = [
|
|
8
|
+
{
|
|
9
|
+
type: "constructor",
|
|
10
|
+
inputs: [
|
|
11
|
+
{ name: "owner_", type: "address", internalType: "address" },
|
|
12
|
+
{ name: "teamSpender_", type: "address", internalType: "address" },
|
|
13
|
+
{ name: "teamGrantedTokens_", type: "address[]", internalType: "address[]" }
|
|
14
|
+
],
|
|
15
|
+
stateMutability: "nonpayable"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
type: "function",
|
|
19
|
+
name: "initializeTokenCreator",
|
|
20
|
+
inputs: [
|
|
21
|
+
{ name: "token", type: "address", internalType: "address" },
|
|
22
|
+
{ name: "newCreator", type: "address", internalType: "address" },
|
|
23
|
+
{ name: "proof", type: "bytes32[]", internalType: "bytes32[]" }
|
|
24
|
+
],
|
|
25
|
+
outputs: [],
|
|
26
|
+
stateMutability: "nonpayable"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
type: "function",
|
|
30
|
+
name: "owner",
|
|
31
|
+
inputs: [],
|
|
32
|
+
outputs: [{ name: "", type: "address", internalType: "address" }],
|
|
33
|
+
stateMutability: "view"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
type: "function",
|
|
37
|
+
name: "renounceOwnership",
|
|
38
|
+
inputs: [],
|
|
39
|
+
outputs: [],
|
|
40
|
+
stateMutability: "nonpayable"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
type: "function",
|
|
44
|
+
name: "setTeamSpender",
|
|
45
|
+
inputs: [{ name: "teamSpender_", type: "address", internalType: "address" }],
|
|
46
|
+
outputs: [],
|
|
47
|
+
stateMutability: "nonpayable"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
type: "function",
|
|
51
|
+
name: "setTokenCreatorRoot",
|
|
52
|
+
inputs: [{ name: "tokenCreatorRoot_", type: "bytes32", internalType: "bytes32" }],
|
|
53
|
+
outputs: [],
|
|
54
|
+
stateMutability: "nonpayable"
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
type: "function",
|
|
58
|
+
name: "teamGrantedTokens",
|
|
59
|
+
inputs: [{ name: "", type: "uint256", internalType: "uint256" }],
|
|
60
|
+
outputs: [{ name: "", type: "address", internalType: "address" }],
|
|
61
|
+
stateMutability: "view"
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
type: "function",
|
|
65
|
+
name: "teamGrantedTokensMap",
|
|
66
|
+
inputs: [{ name: "token", type: "address", internalType: "address" }],
|
|
67
|
+
outputs: [{ name: "teamGranted", type: "bool", internalType: "bool" }],
|
|
68
|
+
stateMutability: "view"
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
type: "function",
|
|
72
|
+
name: "teamSpender",
|
|
73
|
+
inputs: [],
|
|
74
|
+
outputs: [{ name: "", type: "address", internalType: "address" }],
|
|
75
|
+
stateMutability: "view"
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
type: "function",
|
|
79
|
+
name: "teamTransfer",
|
|
80
|
+
inputs: [
|
|
81
|
+
{ name: "safe", type: "address", internalType: "address" },
|
|
82
|
+
{ name: "token", type: "address", internalType: "address" },
|
|
83
|
+
{ name: "recipient", type: "address", internalType: "address" },
|
|
84
|
+
{ name: "amount", type: "uint256", internalType: "uint256" }
|
|
85
|
+
],
|
|
86
|
+
outputs: [],
|
|
87
|
+
stateMutability: "nonpayable"
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
type: "function",
|
|
91
|
+
name: "teamTransferEth",
|
|
92
|
+
inputs: [{ name: "safe", type: "address", internalType: "address" }],
|
|
93
|
+
outputs: [],
|
|
94
|
+
stateMutability: "nonpayable"
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
type: "function",
|
|
98
|
+
name: "tokenCreator",
|
|
99
|
+
inputs: [{ name: "token", type: "address", internalType: "address" }],
|
|
100
|
+
outputs: [{ name: "creator", type: "address", internalType: "address" }],
|
|
101
|
+
stateMutability: "view"
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
type: "function",
|
|
105
|
+
name: "tokenCreatorRoot",
|
|
106
|
+
inputs: [],
|
|
107
|
+
outputs: [{ name: "", type: "bytes32", internalType: "bytes32" }],
|
|
108
|
+
stateMutability: "view"
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
type: "function",
|
|
112
|
+
name: "tokenCreatorTransfer",
|
|
113
|
+
inputs: [
|
|
114
|
+
{ name: "safe", type: "address", internalType: "address" },
|
|
115
|
+
{ name: "token", type: "address", internalType: "address" },
|
|
116
|
+
{ name: "recipient", type: "address", internalType: "address" }
|
|
117
|
+
],
|
|
118
|
+
outputs: [],
|
|
119
|
+
stateMutability: "nonpayable"
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
type: "function",
|
|
123
|
+
name: "transferOwnership",
|
|
124
|
+
inputs: [{ name: "newOwner", type: "address", internalType: "address" }],
|
|
125
|
+
outputs: [],
|
|
126
|
+
stateMutability: "nonpayable"
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
type: "function",
|
|
130
|
+
name: "updateTokenCreator",
|
|
131
|
+
inputs: [
|
|
132
|
+
{ name: "token", type: "address", internalType: "address" },
|
|
133
|
+
{ name: "newCreator", type: "address", internalType: "address" }
|
|
134
|
+
],
|
|
135
|
+
outputs: [],
|
|
136
|
+
stateMutability: "nonpayable"
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
type: "event",
|
|
140
|
+
name: "InitializeTokenCreator",
|
|
141
|
+
inputs: [
|
|
142
|
+
{ name: "token", type: "address", indexed: false, internalType: "address" },
|
|
143
|
+
{ name: "initializer", type: "address", indexed: false, internalType: "address" },
|
|
144
|
+
{ name: "creator", type: "address", indexed: false, internalType: "address" }
|
|
145
|
+
],
|
|
146
|
+
anonymous: false
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
type: "event",
|
|
150
|
+
name: "OwnershipTransferred",
|
|
151
|
+
inputs: [
|
|
152
|
+
{ name: "previousOwner", type: "address", indexed: true, internalType: "address" },
|
|
153
|
+
{ name: "newOwner", type: "address", indexed: true, internalType: "address" }
|
|
154
|
+
],
|
|
155
|
+
anonymous: false
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
type: "event",
|
|
159
|
+
name: "SetTeamSpender",
|
|
160
|
+
inputs: [
|
|
161
|
+
{ name: "previousTeamSpender", type: "address", indexed: true, internalType: "address" },
|
|
162
|
+
{ name: "newTeamSpender", type: "address", indexed: true, internalType: "address" }
|
|
163
|
+
],
|
|
164
|
+
anonymous: false
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
type: "event",
|
|
168
|
+
name: "SetTokenCreatorRoot",
|
|
169
|
+
inputs: [
|
|
170
|
+
{ name: "tokenCreatorRoot", type: "bytes32", indexed: false, internalType: "bytes32" }
|
|
171
|
+
],
|
|
172
|
+
anonymous: false
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
type: "event",
|
|
176
|
+
name: "Transfer",
|
|
177
|
+
inputs: [
|
|
178
|
+
{ name: "safe", type: "address", indexed: true, internalType: "address" },
|
|
179
|
+
{ name: "token", type: "address", indexed: true, internalType: "address" },
|
|
180
|
+
{ name: "amount", type: "uint256", indexed: false, internalType: "uint256" },
|
|
181
|
+
{ name: "spender", type: "address", indexed: false, internalType: "address" },
|
|
182
|
+
{ name: "recipient", type: "address", indexed: true, internalType: "address" }
|
|
183
|
+
],
|
|
184
|
+
anonymous: false
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
type: "event",
|
|
188
|
+
name: "UpdateTokenCreator",
|
|
189
|
+
inputs: [
|
|
190
|
+
{ name: "token", type: "address", indexed: false, internalType: "address" },
|
|
191
|
+
{ name: "previousCreator", type: "address", indexed: false, internalType: "address" },
|
|
192
|
+
{ name: "newCreator", type: "address", indexed: false, internalType: "address" }
|
|
193
|
+
],
|
|
194
|
+
anonymous: false
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
type: "error",
|
|
198
|
+
name: "InsufficientBalance",
|
|
199
|
+
inputs: [
|
|
200
|
+
{ name: "safe", type: "address", internalType: "address" },
|
|
201
|
+
{ name: "token", type: "address", internalType: "address" },
|
|
202
|
+
{ name: "balance", type: "uint256", internalType: "uint256" }
|
|
203
|
+
]
|
|
204
|
+
},
|
|
205
|
+
{ type: "error", name: "InvalidProof", inputs: [] },
|
|
206
|
+
{
|
|
207
|
+
type: "error",
|
|
208
|
+
name: "NotAuthorizedToSpend",
|
|
209
|
+
inputs: [
|
|
210
|
+
{ name: "sender", type: "address", internalType: "address" },
|
|
211
|
+
{ name: "token", type: "address", internalType: "address" }
|
|
212
|
+
]
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
type: "error",
|
|
216
|
+
name: "OwnableInvalidOwner",
|
|
217
|
+
inputs: [{ name: "owner", type: "address", internalType: "address" }]
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
type: "error",
|
|
221
|
+
name: "OwnableUnauthorizedAccount",
|
|
222
|
+
inputs: [{ name: "account", type: "address", internalType: "address" }]
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
type: "error",
|
|
226
|
+
name: "TokenCreatorAlreadyInitialized",
|
|
227
|
+
inputs: [
|
|
228
|
+
{ name: "token", type: "address", internalType: "address" },
|
|
229
|
+
{ name: "delegate", type: "address", internalType: "address" }
|
|
230
|
+
]
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
type: "error",
|
|
234
|
+
name: "TokenCreatorRootAlreadySet",
|
|
235
|
+
inputs: [{ name: "tokenCreatorRoot", type: "bytes32", internalType: "bytes32" }]
|
|
236
|
+
},
|
|
237
|
+
{ type: "error", name: "TokenCreatorRootNotSet", inputs: [] },
|
|
238
|
+
{
|
|
239
|
+
type: "error",
|
|
240
|
+
name: "Unauthorized",
|
|
241
|
+
inputs: [{ name: "unauthorized", type: "address", internalType: "address" }]
|
|
242
|
+
}
|
|
243
|
+
];
|
|
244
|
+
|
|
245
|
+
// src/utils/errors.ts
|
|
246
|
+
import { BaseError, ContractFunctionRevertedError, InsufficientFundsError } from "viem";
|
|
247
|
+
var ClankerError = class _ClankerError extends Error {
|
|
248
|
+
constructor(error, data) {
|
|
249
|
+
super(data.label);
|
|
250
|
+
this.error = error;
|
|
251
|
+
this.data = data;
|
|
252
|
+
}
|
|
253
|
+
static unknown(e, name) {
|
|
254
|
+
return new _ClankerError(e, {
|
|
255
|
+
type: "unknown",
|
|
256
|
+
label: "Something went wrong",
|
|
257
|
+
rawName: name || "unknown"
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
};
|
|
261
|
+
var SignatureToError = {
|
|
262
|
+
"0x7e5ba1ad": {
|
|
263
|
+
type: "state",
|
|
264
|
+
label: "Hook not enabled.",
|
|
265
|
+
rawName: "HookNotEnabled"
|
|
266
|
+
},
|
|
267
|
+
"0x8b063d73": {
|
|
268
|
+
type: "state",
|
|
269
|
+
label: "Too little received (likely dev buy).",
|
|
270
|
+
rawName: "V4TooLittleReceived"
|
|
271
|
+
}
|
|
272
|
+
};
|
|
273
|
+
var ErrorMapping = {
|
|
274
|
+
NoFeesToClaim: {
|
|
275
|
+
type: "state",
|
|
276
|
+
label: "No fees to claim",
|
|
277
|
+
rawName: "NoFeesToClaim"
|
|
278
|
+
},
|
|
279
|
+
InvalidVaultConfiguration: {
|
|
280
|
+
type: "caller",
|
|
281
|
+
label: "Invalid vault configuration",
|
|
282
|
+
rawName: "InvalidVault"
|
|
283
|
+
},
|
|
284
|
+
BaseFeeTooLow: {
|
|
285
|
+
type: "caller",
|
|
286
|
+
label: "Base fee is set too low",
|
|
287
|
+
rawName: "BaseFeeTooLow"
|
|
288
|
+
}
|
|
289
|
+
};
|
|
290
|
+
var understandError = (e) => {
|
|
291
|
+
if (!(e instanceof Error)) return ClankerError.unknown(new Error(`${e}`));
|
|
292
|
+
if (!(e instanceof BaseError)) return ClankerError.unknown(e);
|
|
293
|
+
const revertError = e.walk((e2) => e2 instanceof ContractFunctionRevertedError);
|
|
294
|
+
if (revertError instanceof ContractFunctionRevertedError) {
|
|
295
|
+
const errorName = revertError.data?.errorName ?? "";
|
|
296
|
+
const mapping = ErrorMapping[errorName];
|
|
297
|
+
if (mapping) return new ClankerError(e, mapping);
|
|
298
|
+
const signatureToError = SignatureToError[revertError.signature || "0x"];
|
|
299
|
+
if (signatureToError) return new ClankerError(e, signatureToError);
|
|
300
|
+
return ClankerError.unknown(e, errorName);
|
|
301
|
+
}
|
|
302
|
+
const fundsError = e.walk((e2) => e2 instanceof InsufficientFundsError);
|
|
303
|
+
if (fundsError instanceof InsufficientFundsError) {
|
|
304
|
+
return new ClankerError(fundsError, {
|
|
305
|
+
type: "caller",
|
|
306
|
+
label: "Insufficient funds.",
|
|
307
|
+
rawName: "InsufficientFundsError"
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
return ClankerError.unknown(e);
|
|
311
|
+
};
|
|
312
|
+
|
|
313
|
+
// src/legacyFeeClaims/index.ts
|
|
314
|
+
var LEGACY_FEE_CLAIMS_ADDRESS = "0xe6D6cd9C493Ebf28C4b75d95B251eCA684D6b0de";
|
|
315
|
+
var LegacyFeeClaims = class {
|
|
316
|
+
wallet;
|
|
317
|
+
publicClient;
|
|
318
|
+
constructor(config) {
|
|
319
|
+
this.wallet = config?.wallet;
|
|
320
|
+
this.publicClient = config?.publicClient;
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Get an abi-typed transaction for initializing token creator ownership.
|
|
324
|
+
*
|
|
325
|
+
* This must be called once per token by the original creator to claim ownership
|
|
326
|
+
* of the token's fees. During this call, the creator can optionally set a different
|
|
327
|
+
* admin key to manage the token's rewards.
|
|
328
|
+
*
|
|
329
|
+
* @param token The token address to initialize a creator for
|
|
330
|
+
* @param newCreator The address to set as the creator for this token (can be different from msg.sender)
|
|
331
|
+
* @param proof The Merkle proof demonstrating msg.sender is authorized for this token
|
|
332
|
+
* @returns Abi transaction config
|
|
333
|
+
*/
|
|
334
|
+
getInitializeTokenCreatorTransaction({
|
|
335
|
+
token,
|
|
336
|
+
newCreator,
|
|
337
|
+
proof
|
|
338
|
+
}) {
|
|
339
|
+
return {
|
|
340
|
+
address: LEGACY_FEE_CLAIMS_ADDRESS,
|
|
341
|
+
abi: Clanker_v0_abi,
|
|
342
|
+
functionName: "initializeTokenCreator",
|
|
343
|
+
args: [token, newCreator, proof]
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Simulate initializing token creator ownership.
|
|
348
|
+
*
|
|
349
|
+
* @param token The token address to initialize a creator for
|
|
350
|
+
* @param newCreator The address to set as the creator for this token
|
|
351
|
+
* @param proof The Merkle proof demonstrating msg.sender is authorized for this token
|
|
352
|
+
* @param account Optional account to simulate calling for
|
|
353
|
+
* @returns The simulated output
|
|
354
|
+
*/
|
|
355
|
+
async initializeTokenCreatorSimulate({
|
|
356
|
+
token,
|
|
357
|
+
newCreator,
|
|
358
|
+
proof
|
|
359
|
+
}, account) {
|
|
360
|
+
const acc = account || this.wallet?.account;
|
|
361
|
+
if (!acc) throw new Error("Account or wallet client required for simulation");
|
|
362
|
+
if (!this.publicClient) throw new Error("Public client required");
|
|
363
|
+
try {
|
|
364
|
+
return await simulateContract(this.publicClient, {
|
|
365
|
+
address: LEGACY_FEE_CLAIMS_ADDRESS,
|
|
366
|
+
abi: Clanker_v0_abi,
|
|
367
|
+
functionName: "initializeTokenCreator",
|
|
368
|
+
args: [token, newCreator, proof],
|
|
369
|
+
account: acc
|
|
370
|
+
});
|
|
371
|
+
} catch (e) {
|
|
372
|
+
return { error: understandError(e) };
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* Initialize token creator ownership to enable fee claims.
|
|
377
|
+
*
|
|
378
|
+
* This must be called once per token by the original creator. The proof must be
|
|
379
|
+
* obtained from the Clanker team or frontend. During initialization, you can
|
|
380
|
+
* optionally set a different admin address to manage future claims.
|
|
381
|
+
*
|
|
382
|
+
* @param token The token address to initialize a creator for
|
|
383
|
+
* @param newCreator The address to set as the creator for this token (can be different from msg.sender)
|
|
384
|
+
* @param proof The Merkle proof demonstrating msg.sender is authorized for this token
|
|
385
|
+
* @returns Transaction hash or error
|
|
386
|
+
*/
|
|
387
|
+
async initializeTokenCreator({
|
|
388
|
+
token,
|
|
389
|
+
newCreator,
|
|
390
|
+
proof
|
|
391
|
+
}) {
|
|
392
|
+
if (!this.wallet) throw new Error("Wallet client required");
|
|
393
|
+
if (!this.publicClient) throw new Error("Public client required");
|
|
394
|
+
try {
|
|
395
|
+
const txHash = await writeContract(this.wallet, {
|
|
396
|
+
address: LEGACY_FEE_CLAIMS_ADDRESS,
|
|
397
|
+
abi: Clanker_v0_abi,
|
|
398
|
+
functionName: "initializeTokenCreator",
|
|
399
|
+
args: [token, newCreator, proof]
|
|
400
|
+
});
|
|
401
|
+
return { txHash, error: void 0 };
|
|
402
|
+
} catch (e) {
|
|
403
|
+
console.error(JSON.stringify(e, null, 2));
|
|
404
|
+
return { txHash: void 0, error: understandError(e) };
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
/**
|
|
408
|
+
* Get an abi-typed transaction for updating the token creator admin address.
|
|
409
|
+
*
|
|
410
|
+
* This allows the current creator to change the address that can trigger claims.
|
|
411
|
+
* Only callable by the current creator address for the specified token.
|
|
412
|
+
*
|
|
413
|
+
* @param token The token address to update the creator for
|
|
414
|
+
* @param newCreator The new creator/admin address
|
|
415
|
+
* @returns Abi transaction config
|
|
416
|
+
*/
|
|
417
|
+
getUpdateTokenCreatorTransaction({
|
|
418
|
+
token,
|
|
419
|
+
newCreator
|
|
420
|
+
}) {
|
|
421
|
+
return {
|
|
422
|
+
address: LEGACY_FEE_CLAIMS_ADDRESS,
|
|
423
|
+
abi: Clanker_v0_abi,
|
|
424
|
+
functionName: "updateTokenCreator",
|
|
425
|
+
args: [token, newCreator]
|
|
426
|
+
};
|
|
427
|
+
}
|
|
428
|
+
/**
|
|
429
|
+
* Simulate updating the token creator admin address.
|
|
430
|
+
*
|
|
431
|
+
* @param token The token address to update the creator for
|
|
432
|
+
* @param newCreator The new creator/admin address
|
|
433
|
+
* @param account Optional account to simulate calling for
|
|
434
|
+
* @returns The simulated output
|
|
435
|
+
*/
|
|
436
|
+
async updateTokenCreatorSimulate({
|
|
437
|
+
token,
|
|
438
|
+
newCreator
|
|
439
|
+
}, account) {
|
|
440
|
+
const acc = account || this.wallet?.account;
|
|
441
|
+
if (!acc) throw new Error("Account or wallet client required for simulation");
|
|
442
|
+
if (!this.publicClient) throw new Error("Public client required");
|
|
443
|
+
try {
|
|
444
|
+
return await simulateContract(this.publicClient, {
|
|
445
|
+
address: LEGACY_FEE_CLAIMS_ADDRESS,
|
|
446
|
+
abi: Clanker_v0_abi,
|
|
447
|
+
functionName: "updateTokenCreator",
|
|
448
|
+
args: [token, newCreator],
|
|
449
|
+
account: acc
|
|
450
|
+
});
|
|
451
|
+
} catch (e) {
|
|
452
|
+
return { error: understandError(e) };
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
/**
|
|
456
|
+
* Update the token creator admin address.
|
|
457
|
+
*
|
|
458
|
+
* This allows you to change which address can trigger fee claims for your token.
|
|
459
|
+
* Only callable by the current creator address.
|
|
460
|
+
*
|
|
461
|
+
* @param token The token address to update the creator for
|
|
462
|
+
* @param newCreator The new creator/admin address
|
|
463
|
+
* @returns Transaction hash or error
|
|
464
|
+
*/
|
|
465
|
+
async updateTokenCreator({
|
|
466
|
+
token,
|
|
467
|
+
newCreator
|
|
468
|
+
}) {
|
|
469
|
+
if (!this.wallet) throw new Error("Wallet client required");
|
|
470
|
+
if (!this.publicClient) throw new Error("Public client required");
|
|
471
|
+
try {
|
|
472
|
+
const txHash = await writeContract(this.wallet, {
|
|
473
|
+
address: LEGACY_FEE_CLAIMS_ADDRESS,
|
|
474
|
+
abi: Clanker_v0_abi,
|
|
475
|
+
functionName: "updateTokenCreator",
|
|
476
|
+
args: [token, newCreator]
|
|
477
|
+
});
|
|
478
|
+
return { txHash, error: void 0 };
|
|
479
|
+
} catch (e) {
|
|
480
|
+
return { txHash: void 0, error: understandError(e) };
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
/**
|
|
484
|
+
* Get an abi-typed transaction for claiming token creator fees.
|
|
485
|
+
*
|
|
486
|
+
* This allows the authorized creator to transfer all accumulated fees from the
|
|
487
|
+
* Safe wallet to any recipient address. Only callable by the authorized creator
|
|
488
|
+
* for the specified token.
|
|
489
|
+
*
|
|
490
|
+
* @param safe The Safe wallet address holding the fees
|
|
491
|
+
* @param token The ERC20 token address to transfer
|
|
492
|
+
* @param recipient The address to receive the fees
|
|
493
|
+
* @returns Abi transaction config
|
|
494
|
+
*/
|
|
495
|
+
getTokenCreatorTransferTransaction({
|
|
496
|
+
safe,
|
|
497
|
+
token,
|
|
498
|
+
recipient
|
|
499
|
+
}) {
|
|
500
|
+
return {
|
|
501
|
+
address: LEGACY_FEE_CLAIMS_ADDRESS,
|
|
502
|
+
abi: Clanker_v0_abi,
|
|
503
|
+
functionName: "tokenCreatorTransfer",
|
|
504
|
+
args: [safe, token, recipient]
|
|
505
|
+
};
|
|
506
|
+
}
|
|
507
|
+
/**
|
|
508
|
+
* Simulate claiming token creator fees.
|
|
509
|
+
*
|
|
510
|
+
* @param safe The Safe wallet address holding the fees
|
|
511
|
+
* @param token The ERC20 token address to transfer
|
|
512
|
+
* @param recipient The address to receive the fees
|
|
513
|
+
* @param account Optional account to simulate calling for
|
|
514
|
+
* @returns The simulated output
|
|
515
|
+
*/
|
|
516
|
+
async tokenCreatorTransferSimulate({
|
|
517
|
+
safe,
|
|
518
|
+
token,
|
|
519
|
+
recipient
|
|
520
|
+
}, account) {
|
|
521
|
+
const acc = account || this.wallet?.account;
|
|
522
|
+
if (!acc) throw new Error("Account or wallet client required for simulation");
|
|
523
|
+
if (!this.publicClient) throw new Error("Public client required");
|
|
524
|
+
try {
|
|
525
|
+
return await simulateContract(this.publicClient, {
|
|
526
|
+
address: LEGACY_FEE_CLAIMS_ADDRESS,
|
|
527
|
+
abi: Clanker_v0_abi,
|
|
528
|
+
functionName: "tokenCreatorTransfer",
|
|
529
|
+
args: [safe, token, recipient],
|
|
530
|
+
account: acc
|
|
531
|
+
});
|
|
532
|
+
} catch (e) {
|
|
533
|
+
return { error: understandError(e) };
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
/**
|
|
537
|
+
* Claim token creator fees by transferring them from the Safe to a recipient.
|
|
538
|
+
*
|
|
539
|
+
* This transfers all accumulated fees for your token to the specified recipient.
|
|
540
|
+
* Only callable by the authorized creator address for the token.
|
|
541
|
+
*
|
|
542
|
+
* Note: Not all Clanker tokens can be sent to the zero address. If you get an error,
|
|
543
|
+
* consider sending to 0x000000000000000000000000000000000000dEaD instead.
|
|
544
|
+
*
|
|
545
|
+
* @param safe The Safe wallet address holding the fees
|
|
546
|
+
* @param token The ERC20 token address to transfer
|
|
547
|
+
* @param recipient The address to receive the fees
|
|
548
|
+
* @returns Transaction hash or error
|
|
549
|
+
*/
|
|
550
|
+
async tokenCreatorTransfer({
|
|
551
|
+
safe,
|
|
552
|
+
token,
|
|
553
|
+
recipient
|
|
554
|
+
}) {
|
|
555
|
+
if (!this.wallet) throw new Error("Wallet client required");
|
|
556
|
+
if (!this.publicClient) throw new Error("Public client required");
|
|
557
|
+
try {
|
|
558
|
+
const txHash = await writeContract(this.wallet, {
|
|
559
|
+
address: LEGACY_FEE_CLAIMS_ADDRESS,
|
|
560
|
+
abi: Clanker_v0_abi,
|
|
561
|
+
functionName: "tokenCreatorTransfer",
|
|
562
|
+
args: [safe, token, recipient]
|
|
563
|
+
});
|
|
564
|
+
return { txHash, error: void 0 };
|
|
565
|
+
} catch (e) {
|
|
566
|
+
return { txHash: void 0, error: understandError(e) };
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
/**
|
|
570
|
+
* Get the stored creator address for a token.
|
|
571
|
+
*
|
|
572
|
+
* Returns the address that is authorized to claim fees for this token.
|
|
573
|
+
* Returns zero address if the token creator has not been initialized yet.
|
|
574
|
+
*
|
|
575
|
+
* @param token The token address to check
|
|
576
|
+
* @returns The creator address for the token
|
|
577
|
+
*/
|
|
578
|
+
async getTokenCreator({ token }) {
|
|
579
|
+
if (!this.publicClient) throw new Error("Public client required");
|
|
580
|
+
return this.publicClient.readContract({
|
|
581
|
+
address: LEGACY_FEE_CLAIMS_ADDRESS,
|
|
582
|
+
abi: Clanker_v0_abi,
|
|
583
|
+
functionName: "tokenCreator",
|
|
584
|
+
args: [token]
|
|
585
|
+
});
|
|
586
|
+
}
|
|
587
|
+
/**
|
|
588
|
+
* Get the current Merkle root used for verifying token creator proofs.
|
|
589
|
+
*
|
|
590
|
+
* This is used internally by the contract to verify initialization proofs.
|
|
591
|
+
*
|
|
592
|
+
* @returns The current token creator Merkle root
|
|
593
|
+
*/
|
|
594
|
+
async getTokenCreatorRoot() {
|
|
595
|
+
if (!this.publicClient) throw new Error("Public client required");
|
|
596
|
+
return this.publicClient.readContract({
|
|
597
|
+
address: LEGACY_FEE_CLAIMS_ADDRESS,
|
|
598
|
+
abi: Clanker_v0_abi,
|
|
599
|
+
functionName: "tokenCreatorRoot",
|
|
600
|
+
args: []
|
|
601
|
+
});
|
|
602
|
+
}
|
|
603
|
+
};
|
|
604
|
+
function generateLeafHash(tokenAddress, currentCreator) {
|
|
605
|
+
const packed = `0x${tokenAddress.slice(2)}${currentCreator.slice(2)}`;
|
|
606
|
+
return keccak256(packed);
|
|
607
|
+
}
|
|
608
|
+
function getTokenCreatorMerkleProof(entries, targetToken) {
|
|
609
|
+
const normalizedTarget = targetToken.toLowerCase();
|
|
610
|
+
const targetIndex = entries.findIndex((e) => e.tokenAddress.toLowerCase() === normalizedTarget);
|
|
611
|
+
if (targetIndex === -1) {
|
|
612
|
+
return null;
|
|
613
|
+
}
|
|
614
|
+
const targetEntry = entries[targetIndex];
|
|
615
|
+
const values = entries.map((e) => [e.tokenAddress, e.currentCreator]);
|
|
616
|
+
const tree = StandardMerkleTree.of(values, ["address", "address"]);
|
|
617
|
+
const proof = tree.getProof(targetIndex);
|
|
618
|
+
const leafHash = generateLeafHash(targetEntry.tokenAddress, targetEntry.currentCreator);
|
|
619
|
+
return {
|
|
620
|
+
tokenAddress: targetEntry.tokenAddress,
|
|
621
|
+
currentCreator: targetEntry.currentCreator,
|
|
622
|
+
proof,
|
|
623
|
+
leafHash,
|
|
624
|
+
root: tree.root,
|
|
625
|
+
index: targetIndex
|
|
626
|
+
};
|
|
627
|
+
}
|
|
628
|
+
function parseTokenCreatorCSV(csvContent) {
|
|
629
|
+
const lines = csvContent.trim().split("\n");
|
|
630
|
+
const dataLines = lines.slice(1);
|
|
631
|
+
return dataLines.map((line) => {
|
|
632
|
+
const [tokenAddress, currentCreator] = line.split(",").map((s) => s.trim());
|
|
633
|
+
return {
|
|
634
|
+
tokenAddress,
|
|
635
|
+
currentCreator
|
|
636
|
+
};
|
|
637
|
+
});
|
|
638
|
+
}
|
|
639
|
+
var EXPECTED_MERKLE_ROOT = "0xa7dcc91a2136ef1b3c708dbab901cbeb075f6df5cf5987494fedc340c57f7025";
|
|
640
|
+
function getInitializeTokenCreatorTransaction({
|
|
641
|
+
token,
|
|
642
|
+
newCreator,
|
|
643
|
+
proof
|
|
644
|
+
}) {
|
|
645
|
+
return {
|
|
646
|
+
address: LEGACY_FEE_CLAIMS_ADDRESS,
|
|
647
|
+
abi: Clanker_v0_abi,
|
|
648
|
+
functionName: "initializeTokenCreator",
|
|
649
|
+
args: [token, newCreator, proof]
|
|
650
|
+
};
|
|
651
|
+
}
|
|
652
|
+
function getUpdateTokenCreatorTransaction({
|
|
653
|
+
token,
|
|
654
|
+
newCreator
|
|
655
|
+
}) {
|
|
656
|
+
return {
|
|
657
|
+
address: LEGACY_FEE_CLAIMS_ADDRESS,
|
|
658
|
+
abi: Clanker_v0_abi,
|
|
659
|
+
functionName: "updateTokenCreator",
|
|
660
|
+
args: [token, newCreator]
|
|
661
|
+
};
|
|
662
|
+
}
|
|
663
|
+
function getTokenCreatorTransferTransaction({
|
|
664
|
+
safe,
|
|
665
|
+
token,
|
|
666
|
+
recipient
|
|
667
|
+
}) {
|
|
668
|
+
return {
|
|
669
|
+
address: LEGACY_FEE_CLAIMS_ADDRESS,
|
|
670
|
+
abi: Clanker_v0_abi,
|
|
671
|
+
functionName: "tokenCreatorTransfer",
|
|
672
|
+
args: [safe, token, recipient]
|
|
673
|
+
};
|
|
674
|
+
}
|
|
675
|
+
export {
|
|
676
|
+
EXPECTED_MERKLE_ROOT,
|
|
677
|
+
LEGACY_FEE_CLAIMS_ADDRESS,
|
|
678
|
+
LegacyFeeClaims,
|
|
679
|
+
generateLeafHash,
|
|
680
|
+
getInitializeTokenCreatorTransaction,
|
|
681
|
+
getTokenCreatorMerkleProof,
|
|
682
|
+
getTokenCreatorTransferTransaction,
|
|
683
|
+
getUpdateTokenCreatorTransaction,
|
|
684
|
+
parseTokenCreatorCSV
|
|
685
|
+
};
|
package/dist/v3/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { C as ClankerTransactionConfig, a as Clanker_v3_1_abi, b as
|
|
1
|
+
import { C as ClankerTransactionConfig, a as Clanker_v3_1_abi, b as ClankerFactory, c as ClankerResult } from '../write-clanker-contracts-B4LSHPv2.js';
|
|
2
2
|
import * as viem from 'viem';
|
|
3
3
|
import { WalletClient, Transport, Chain, Account, PublicClient } from 'viem';
|
|
4
4
|
import { C as ClankerToken_v3_1_abi } from '../ClankerToken-Dra5lppJ.js';
|
|
5
5
|
import { C as ClankerTokenV3 } from '../clankerTokenV3-BqHTF9QY.js';
|
|
6
|
+
import { C as ClankerError } from '../errors-5Gv28Tkr.js';
|
|
6
7
|
import 'zod/v4';
|
|
7
8
|
|
|
8
9
|
type ClankerConfig = {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { C as ClankerTransactionConfig,
|
|
1
|
+
import { C as ClankerTransactionConfig, f as ClankerAirdrop_v4_abi, c as ClankerResult, g as Clanker_PresaleEthToCreator_v4_1_abi } from '../../write-clanker-contracts-B4LSHPv2.js';
|
|
2
2
|
import { MerkleTree } from '@openzeppelin/merkle-tree/dist/merkletree.js';
|
|
3
3
|
import * as z from 'zod/v4';
|
|
4
|
-
import { a as Chain, C as ClankerTokenV4 } from '../../clankerTokenV4-
|
|
4
|
+
import { a as Chain, C as ClankerTokenV4 } from '../../clankerTokenV4-Btn0ZN4v.js';
|
|
5
5
|
import { Clanker } from '../index.js';
|
|
6
|
+
import { C as ClankerError } from '../../errors-5Gv28Tkr.js';
|
|
6
7
|
import 'viem';
|
|
7
8
|
import '../../ClankerToken-Dra5lppJ.js';
|
|
8
9
|
|