@bigmaxwatermelon/sdk 0.4.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 +326 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +5845 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +580 -0
- package/dist/index.js +4802 -0
- package/dist/index.js.map +1 -0
- package/package.json +67 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,580 @@
|
|
|
1
|
+
import { ContractRunner, Contract, ethers } from 'ethers';
|
|
2
|
+
|
|
3
|
+
interface ContractAddresses {
|
|
4
|
+
platform?: string;
|
|
5
|
+
factory?: string;
|
|
6
|
+
beacon?: string;
|
|
7
|
+
}
|
|
8
|
+
declare function getContracts(addresses: ContractAddresses, runner: ContractRunner): {
|
|
9
|
+
platform: Contract;
|
|
10
|
+
factory: Contract;
|
|
11
|
+
beacon: Contract;
|
|
12
|
+
};
|
|
13
|
+
declare function getStableCoin(address: string, runner: ContractRunner): Contract;
|
|
14
|
+
|
|
15
|
+
interface PlatformInfo {
|
|
16
|
+
address: string;
|
|
17
|
+
paused: boolean;
|
|
18
|
+
tokenCount: bigint;
|
|
19
|
+
platformAdminCount: bigint;
|
|
20
|
+
approvedIssuerCount: bigint;
|
|
21
|
+
accessUserCount: bigint;
|
|
22
|
+
}
|
|
23
|
+
interface PlatformRoles {
|
|
24
|
+
address: string;
|
|
25
|
+
isOwner: boolean;
|
|
26
|
+
isPlatformAdmin: boolean;
|
|
27
|
+
isApprovedIssuer: boolean;
|
|
28
|
+
isAccessUser: boolean;
|
|
29
|
+
}
|
|
30
|
+
declare class PlatformRpcService {
|
|
31
|
+
private contracts;
|
|
32
|
+
private platform;
|
|
33
|
+
constructor(addresses: ContractAddresses, runner: ContractRunner);
|
|
34
|
+
getPlatformInfo(): Promise<PlatformInfo>;
|
|
35
|
+
getAllTokens(): Promise<string[]>;
|
|
36
|
+
getAccountRoles(account: string): Promise<PlatformRoles>;
|
|
37
|
+
isPaused(): Promise<boolean>;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
declare class FactoryRpcService {
|
|
41
|
+
private addresses;
|
|
42
|
+
private runner;
|
|
43
|
+
constructor(addresses: ContractAddresses, runner: ContractRunner);
|
|
44
|
+
getBeaconAddress(): Promise<string>;
|
|
45
|
+
getPlatformAddress(): Promise<string>;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
interface TokenInfo {
|
|
49
|
+
address: string;
|
|
50
|
+
name: string;
|
|
51
|
+
symbol: string;
|
|
52
|
+
decimals: number;
|
|
53
|
+
totalSupply: bigint;
|
|
54
|
+
paused: boolean;
|
|
55
|
+
}
|
|
56
|
+
interface TokenStats {
|
|
57
|
+
address: string;
|
|
58
|
+
holdersTotal: bigint;
|
|
59
|
+
totalMinted: bigint;
|
|
60
|
+
totalBurned: bigint;
|
|
61
|
+
totalAllowance: bigint;
|
|
62
|
+
mintersCount: bigint;
|
|
63
|
+
blacklistCount: bigint;
|
|
64
|
+
}
|
|
65
|
+
interface TokenRoles {
|
|
66
|
+
address: string;
|
|
67
|
+
account: string;
|
|
68
|
+
isTokenOwner: boolean;
|
|
69
|
+
isMasterMinter: boolean;
|
|
70
|
+
isMinter: boolean;
|
|
71
|
+
isBlacklistManager: boolean;
|
|
72
|
+
isMasterStatus: boolean;
|
|
73
|
+
}
|
|
74
|
+
declare class StableCoinRpcService {
|
|
75
|
+
private runner;
|
|
76
|
+
constructor(_addresses: ContractAddresses, runner: ContractRunner);
|
|
77
|
+
getTokenInfo(address: string): Promise<TokenInfo>;
|
|
78
|
+
getTokenStats(address: string): Promise<TokenStats>;
|
|
79
|
+
getUserRoles(address: string, account: string): Promise<TokenRoles>;
|
|
80
|
+
isPaused(address: string): Promise<boolean>;
|
|
81
|
+
isBlacklisted(address: string, user: string): Promise<boolean>;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
type WalletMode = 'eip1193' | 'privatekey' | 'readonly';
|
|
85
|
+
interface IWallet {
|
|
86
|
+
readonly mode: WalletMode;
|
|
87
|
+
/** For read operations */
|
|
88
|
+
readonly provider: ethers.Provider;
|
|
89
|
+
/** For write operations (may equal provider in read-only mode) */
|
|
90
|
+
readonly signer: ethers.Signer | null;
|
|
91
|
+
getAddress(): Promise<string | null>;
|
|
92
|
+
isConnected(): boolean;
|
|
93
|
+
}
|
|
94
|
+
declare class ReadOnlyWallet implements IWallet {
|
|
95
|
+
readonly mode: WalletMode;
|
|
96
|
+
readonly provider: ethers.Provider;
|
|
97
|
+
readonly signer: null;
|
|
98
|
+
constructor(rpcUrl: string);
|
|
99
|
+
getAddress(): Promise<string | null>;
|
|
100
|
+
isConnected(): boolean;
|
|
101
|
+
}
|
|
102
|
+
declare class PrivateKeyWallet implements IWallet {
|
|
103
|
+
readonly mode: WalletMode;
|
|
104
|
+
readonly provider: ethers.Provider;
|
|
105
|
+
readonly signer: ethers.Signer;
|
|
106
|
+
constructor(rpcUrl: string, privateKey: string);
|
|
107
|
+
getAddress(): Promise<string | null>;
|
|
108
|
+
isConnected(): boolean;
|
|
109
|
+
}
|
|
110
|
+
declare function createWallet(rpcUrl: string, privateKey?: string): IWallet;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* WriteExecutor — unified write transaction executor
|
|
114
|
+
*
|
|
115
|
+
* Consistent interface for all write operations:
|
|
116
|
+
* - simulate: dry-run via estimateGas only
|
|
117
|
+
* - execute: real transaction with receipt
|
|
118
|
+
* - unified error model with human-readable codes
|
|
119
|
+
* - CLI output helpers with --json / --simulate support
|
|
120
|
+
*/
|
|
121
|
+
|
|
122
|
+
interface SimulateResult {
|
|
123
|
+
ok: true;
|
|
124
|
+
estimatedGas: bigint;
|
|
125
|
+
functionFragment: string;
|
|
126
|
+
params: Record<string, unknown>;
|
|
127
|
+
}
|
|
128
|
+
interface TxReceipt {
|
|
129
|
+
txHash: string;
|
|
130
|
+
blockNumber: number | null;
|
|
131
|
+
blockHash: string | null;
|
|
132
|
+
status: number | null;
|
|
133
|
+
gasUsed: bigint;
|
|
134
|
+
effectiveGasPrice: bigint;
|
|
135
|
+
from: string;
|
|
136
|
+
to: string | null;
|
|
137
|
+
nonce: number;
|
|
138
|
+
logs: Array<{
|
|
139
|
+
address: string;
|
|
140
|
+
topics: string[];
|
|
141
|
+
data: string;
|
|
142
|
+
blockNumber: number | null;
|
|
143
|
+
}>;
|
|
144
|
+
}
|
|
145
|
+
interface ExecuteResult {
|
|
146
|
+
ok: true;
|
|
147
|
+
receipt: TxReceipt;
|
|
148
|
+
}
|
|
149
|
+
type WriteErrorCode = 'NO_SIGNER' | 'INVALID_KEY' | 'INVALID_ARGUMENT' | 'SIMULATION_FAILED' | 'REVERT' | 'ACCESS_DENIED' | 'INSUFFICIENT_BALANCE' | 'INSUFFICIENT_ALLOWANCE' | 'PAUSED' | 'BLACKLISTED' | 'NOT_APPROVED_ISSUER' | 'FACTORY_SYMBOL_EXISTS' | 'ZERO_ADDRESS' | 'RPC_ERROR' | 'UNKNOWN';
|
|
150
|
+
interface WriteError {
|
|
151
|
+
ok: false;
|
|
152
|
+
code: WriteErrorCode;
|
|
153
|
+
message: string;
|
|
154
|
+
details?: unknown;
|
|
155
|
+
}
|
|
156
|
+
type WriteResult = SimulateResult | ExecuteResult | WriteError;
|
|
157
|
+
interface WriteCall {
|
|
158
|
+
method: string;
|
|
159
|
+
args: unknown[];
|
|
160
|
+
overrides?: Record<string, unknown>;
|
|
161
|
+
}
|
|
162
|
+
interface WriteExecutorConfig {
|
|
163
|
+
wallet: IWallet;
|
|
164
|
+
contract: Contract;
|
|
165
|
+
}
|
|
166
|
+
declare class WriteExecutor {
|
|
167
|
+
private config;
|
|
168
|
+
constructor(config: WriteExecutorConfig);
|
|
169
|
+
/** Dry-run: estimate gas without signing. Returns gas estimate or decoded error. */
|
|
170
|
+
simulate(call: WriteCall): Promise<SimulateResult | WriteError>;
|
|
171
|
+
/** Execute: sign and broadcast, wait for receipt. */
|
|
172
|
+
execute(call: WriteCall, confirmations?: number): Promise<ExecuteResult | WriteError>;
|
|
173
|
+
private parseRevertError;
|
|
174
|
+
}
|
|
175
|
+
interface WriteOpts {
|
|
176
|
+
simulate: boolean;
|
|
177
|
+
json: boolean;
|
|
178
|
+
}
|
|
179
|
+
interface WriteMeta {
|
|
180
|
+
chainId: number;
|
|
181
|
+
source: 'rpc';
|
|
182
|
+
timestamp: number;
|
|
183
|
+
command?: string;
|
|
184
|
+
}
|
|
185
|
+
declare function makeWriteMeta(command?: string): WriteMeta;
|
|
186
|
+
|
|
187
|
+
declare class GraphError extends Error {
|
|
188
|
+
readonly code: 'NETWORK_ERROR' | 'SUBGRAPH_ERROR' | 'PARSE_ERROR' | 'UNKNOWN';
|
|
189
|
+
readonly details?: unknown | undefined;
|
|
190
|
+
constructor(message: string, code: 'NETWORK_ERROR' | 'SUBGRAPH_ERROR' | 'PARSE_ERROR' | 'UNKNOWN', details?: unknown | undefined);
|
|
191
|
+
}
|
|
192
|
+
interface GraphClientConfig {
|
|
193
|
+
endpoint: string;
|
|
194
|
+
/** Optional headers (e.g. authorization) */
|
|
195
|
+
headers?: Record<string, string>;
|
|
196
|
+
}
|
|
197
|
+
declare class GraphClient {
|
|
198
|
+
private client;
|
|
199
|
+
constructor(config: GraphClientConfig);
|
|
200
|
+
/**
|
|
201
|
+
* Execute a raw GraphQL query.
|
|
202
|
+
* @param query - GraphQL query string
|
|
203
|
+
* @param variables - Optional query variables
|
|
204
|
+
*/
|
|
205
|
+
query<T>(query: string, variables?: Record<string, unknown>): Promise<T>;
|
|
206
|
+
/**
|
|
207
|
+
* Ping the subgraph — useful for health checks.
|
|
208
|
+
* Returns current block number or throws.
|
|
209
|
+
*/
|
|
210
|
+
ping(): Promise<{
|
|
211
|
+
number: number;
|
|
212
|
+
hash: string;
|
|
213
|
+
deployment: string;
|
|
214
|
+
}>;
|
|
215
|
+
private normalizeError;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/** Bytes in subgraph = hex string with 0x prefix */
|
|
219
|
+
type Bytes = string;
|
|
220
|
+
/** BigInt in subgraph = decimal string */
|
|
221
|
+
type BigInt = string;
|
|
222
|
+
type TokenStatus = 'ACTIVE' | 'PAUSED';
|
|
223
|
+
interface Token {
|
|
224
|
+
id: Bytes;
|
|
225
|
+
address: Bytes;
|
|
226
|
+
name: string;
|
|
227
|
+
symbol: string;
|
|
228
|
+
decimals: number;
|
|
229
|
+
creator: Bytes;
|
|
230
|
+
createdAt: BigInt;
|
|
231
|
+
status: TokenStatus;
|
|
232
|
+
activeHolderCount: BigInt;
|
|
233
|
+
totalMintCount: BigInt;
|
|
234
|
+
totalMintAmount: BigInt;
|
|
235
|
+
totalBurnCount: BigInt;
|
|
236
|
+
totalBurnAmount: BigInt;
|
|
237
|
+
lastUpdatedAt: BigInt;
|
|
238
|
+
}
|
|
239
|
+
interface TokenHolder {
|
|
240
|
+
id: string;
|
|
241
|
+
token: Bytes;
|
|
242
|
+
address: Bytes;
|
|
243
|
+
balance: BigInt;
|
|
244
|
+
firstSeenAt: BigInt;
|
|
245
|
+
hasMinted: boolean;
|
|
246
|
+
hasBurned: boolean;
|
|
247
|
+
}
|
|
248
|
+
interface Token24hSnapshot {
|
|
249
|
+
id: string;
|
|
250
|
+
token: Bytes;
|
|
251
|
+
mintAmount24h: BigInt;
|
|
252
|
+
burnAmount24h: BigInt;
|
|
253
|
+
mintCount24h: BigInt;
|
|
254
|
+
burnCount24h: BigInt;
|
|
255
|
+
lastUpdatedAt: BigInt;
|
|
256
|
+
}
|
|
257
|
+
interface TokenRegisteredEvent {
|
|
258
|
+
id: string;
|
|
259
|
+
operator: Bytes;
|
|
260
|
+
token: Bytes;
|
|
261
|
+
name: string;
|
|
262
|
+
symbol: string;
|
|
263
|
+
memo: string;
|
|
264
|
+
blockNumber: BigInt;
|
|
265
|
+
timestamp: BigInt;
|
|
266
|
+
transactionHash: Bytes;
|
|
267
|
+
}
|
|
268
|
+
interface MintEvent {
|
|
269
|
+
id: string;
|
|
270
|
+
token: Bytes;
|
|
271
|
+
operator: Bytes;
|
|
272
|
+
to: Bytes;
|
|
273
|
+
amount: BigInt;
|
|
274
|
+
memo: string;
|
|
275
|
+
blockNumber: BigInt;
|
|
276
|
+
timestamp: BigInt;
|
|
277
|
+
transactionHash: Bytes;
|
|
278
|
+
}
|
|
279
|
+
interface BurnEvent {
|
|
280
|
+
id: string;
|
|
281
|
+
token: Bytes;
|
|
282
|
+
operator: Bytes;
|
|
283
|
+
from: Bytes;
|
|
284
|
+
amount: BigInt;
|
|
285
|
+
memo: string;
|
|
286
|
+
blockNumber: BigInt;
|
|
287
|
+
timestamp: BigInt;
|
|
288
|
+
transactionHash: Bytes;
|
|
289
|
+
}
|
|
290
|
+
interface TransferEvent {
|
|
291
|
+
id: string;
|
|
292
|
+
token: Bytes;
|
|
293
|
+
from: Bytes;
|
|
294
|
+
to: Bytes;
|
|
295
|
+
amount: BigInt;
|
|
296
|
+
blockNumber: BigInt;
|
|
297
|
+
timestamp: BigInt;
|
|
298
|
+
transactionHash: Bytes;
|
|
299
|
+
}
|
|
300
|
+
interface PauseEvent {
|
|
301
|
+
id: string;
|
|
302
|
+
token: Bytes;
|
|
303
|
+
account: Bytes;
|
|
304
|
+
action: string;
|
|
305
|
+
blockNumber: BigInt;
|
|
306
|
+
timestamp: BigInt;
|
|
307
|
+
transactionHash: Bytes;
|
|
308
|
+
}
|
|
309
|
+
interface PausedByOwnerEvent {
|
|
310
|
+
id: string;
|
|
311
|
+
token: Bytes;
|
|
312
|
+
account: Bytes;
|
|
313
|
+
memo: string;
|
|
314
|
+
blockNumber: BigInt;
|
|
315
|
+
timestamp: BigInt;
|
|
316
|
+
transactionHash: Bytes;
|
|
317
|
+
}
|
|
318
|
+
interface UnpausedByOwnerEvent {
|
|
319
|
+
id: string;
|
|
320
|
+
token: Bytes;
|
|
321
|
+
account: Bytes;
|
|
322
|
+
memo: string;
|
|
323
|
+
blockNumber: BigInt;
|
|
324
|
+
timestamp: BigInt;
|
|
325
|
+
transactionHash: Bytes;
|
|
326
|
+
}
|
|
327
|
+
interface BlacklistEvent {
|
|
328
|
+
id: string;
|
|
329
|
+
token: Bytes;
|
|
330
|
+
operator: Bytes;
|
|
331
|
+
user: Bytes;
|
|
332
|
+
action: string;
|
|
333
|
+
memo: string;
|
|
334
|
+
blockNumber: BigInt;
|
|
335
|
+
timestamp: BigInt;
|
|
336
|
+
transactionHash: Bytes;
|
|
337
|
+
}
|
|
338
|
+
interface PlatformAdmin {
|
|
339
|
+
id: string;
|
|
340
|
+
account: Bytes;
|
|
341
|
+
isActive: boolean;
|
|
342
|
+
lastOperator: Bytes;
|
|
343
|
+
addedAt: BigInt;
|
|
344
|
+
removedAt: BigInt | null;
|
|
345
|
+
addedCount: BigInt;
|
|
346
|
+
removedCount: BigInt;
|
|
347
|
+
lastUpdatedAt: BigInt;
|
|
348
|
+
}
|
|
349
|
+
interface ApprovedIssuer {
|
|
350
|
+
id: string;
|
|
351
|
+
account: Bytes;
|
|
352
|
+
isActive: boolean;
|
|
353
|
+
lastOperator: Bytes;
|
|
354
|
+
addedAt: BigInt;
|
|
355
|
+
removedAt: BigInt | null;
|
|
356
|
+
addedCount: BigInt;
|
|
357
|
+
removedCount: BigInt;
|
|
358
|
+
lastUpdatedAt: BigInt;
|
|
359
|
+
}
|
|
360
|
+
interface AccessUser {
|
|
361
|
+
id: string;
|
|
362
|
+
account: Bytes;
|
|
363
|
+
isActive: boolean;
|
|
364
|
+
lastOperator: Bytes;
|
|
365
|
+
addedAt: BigInt;
|
|
366
|
+
removedAt: BigInt | null;
|
|
367
|
+
addedCount: BigInt;
|
|
368
|
+
removedCount: BigInt;
|
|
369
|
+
lastUpdatedAt: BigInt;
|
|
370
|
+
}
|
|
371
|
+
interface FactoryInitializedEvent {
|
|
372
|
+
id: string;
|
|
373
|
+
version: BigInt;
|
|
374
|
+
blockNumber: BigInt;
|
|
375
|
+
timestamp: BigInt;
|
|
376
|
+
transactionHash: Bytes;
|
|
377
|
+
}
|
|
378
|
+
interface FactorySetEvent {
|
|
379
|
+
id: string;
|
|
380
|
+
operator: Bytes;
|
|
381
|
+
oldFactory: Bytes;
|
|
382
|
+
newFactory: Bytes;
|
|
383
|
+
blockNumber: BigInt;
|
|
384
|
+
timestamp: BigInt;
|
|
385
|
+
transactionHash: Bytes;
|
|
386
|
+
}
|
|
387
|
+
interface MinterAddedEvent {
|
|
388
|
+
id: string;
|
|
389
|
+
token: Bytes;
|
|
390
|
+
operator: Bytes;
|
|
391
|
+
minter: Bytes;
|
|
392
|
+
memo: string;
|
|
393
|
+
blockNumber: BigInt;
|
|
394
|
+
timestamp: BigInt;
|
|
395
|
+
transactionHash: Bytes;
|
|
396
|
+
}
|
|
397
|
+
interface MinterRemovedEvent {
|
|
398
|
+
id: string;
|
|
399
|
+
token: Bytes;
|
|
400
|
+
operator: Bytes;
|
|
401
|
+
minter: Bytes;
|
|
402
|
+
memo: string;
|
|
403
|
+
blockNumber: BigInt;
|
|
404
|
+
timestamp: BigInt;
|
|
405
|
+
transactionHash: Bytes;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
declare class TokenHistoryService {
|
|
409
|
+
private client;
|
|
410
|
+
constructor(client: GraphClient);
|
|
411
|
+
getToken(address: string): Promise<Token | null>;
|
|
412
|
+
getTokens(first?: number, skip?: number): Promise<Token[]>;
|
|
413
|
+
getTokenCreatedEvents(first?: number, skip?: number): Promise<TokenRegisteredEvent[]>;
|
|
414
|
+
getMintHistory(tokenAddress: string, first?: number, skip?: number): Promise<MintEvent[]>;
|
|
415
|
+
getBurnHistory(tokenAddress: string, first?: number, skip?: number): Promise<BurnEvent[]>;
|
|
416
|
+
getTransferHistory(tokenAddress: string, first?: number, skip?: number): Promise<TransferEvent[]>;
|
|
417
|
+
getPauseHistory(tokenAddress: string, first?: number, skip?: number): Promise<PauseEvent[]>;
|
|
418
|
+
getPausedByOwnerHistory(tokenAddress: string, first?: number, skip?: number): Promise<PausedByOwnerEvent[]>;
|
|
419
|
+
getUnpausedByOwnerHistory(tokenAddress: string, first?: number, skip?: number): Promise<UnpausedByOwnerEvent[]>;
|
|
420
|
+
getBlacklistHistory(tokenAddress: string, first?: number, skip?: number): Promise<BlacklistEvent[]>;
|
|
421
|
+
getHolders(tokenAddress: string, first?: number, skip?: number): Promise<TokenHolder[]>;
|
|
422
|
+
get24hSnapshot(tokenAddress: string): Promise<Token24hSnapshot | null>;
|
|
423
|
+
getMinterAddedHistory(tokenAddress: string, first?: number, skip?: number): Promise<MinterAddedEvent[]>;
|
|
424
|
+
getMinterRemovedHistory(tokenAddress: string, first?: number, skip?: number): Promise<MinterRemovedEvent[]>;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
declare class PlatformHistoryService {
|
|
428
|
+
private client;
|
|
429
|
+
constructor(client: GraphClient);
|
|
430
|
+
getPlatformAdmins(first?: number, skip?: number): Promise<PlatformAdmin[]>;
|
|
431
|
+
getActivePlatformAdins(): Promise<PlatformAdmin[]>;
|
|
432
|
+
getApprovedIssuers(first?: number, skip?: number): Promise<ApprovedIssuer[]>;
|
|
433
|
+
getActiveApprovedIssuers(): Promise<ApprovedIssuer[]>;
|
|
434
|
+
getAccessUsers(first?: number, skip?: number): Promise<AccessUser[]>;
|
|
435
|
+
getActiveAccessUsers(): Promise<AccessUser[]>;
|
|
436
|
+
getFactoryInitializedEvents(first?: number, skip?: number): Promise<FactoryInitializedEvent[]>;
|
|
437
|
+
getFactorySetEvents(first?: number, skip?: number): Promise<FactorySetEvent[]>;
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
declare class AnalyticsService {
|
|
441
|
+
readonly token: TokenHistoryService;
|
|
442
|
+
readonly platform: PlatformHistoryService;
|
|
443
|
+
constructor(graph: GraphClient);
|
|
444
|
+
/**
|
|
445
|
+
* Get a quick supply summary for a token.
|
|
446
|
+
* Combines live token stats (from GQL) with 24h snapshot.
|
|
447
|
+
*/
|
|
448
|
+
getTokenSupplySummary(tokenAddress: string): Promise<{
|
|
449
|
+
tokenAddress: string;
|
|
450
|
+
name: string;
|
|
451
|
+
symbol: string;
|
|
452
|
+
status: TokenStatus;
|
|
453
|
+
totalMintAmount: bigint;
|
|
454
|
+
totalBurnAmount: bigint;
|
|
455
|
+
netSupply: bigint;
|
|
456
|
+
activeHolderCount: number;
|
|
457
|
+
snapshot: {
|
|
458
|
+
mintAmount24h: bigint;
|
|
459
|
+
burnAmount24h: bigint;
|
|
460
|
+
mintCount24h: number;
|
|
461
|
+
burnCount24h: number;
|
|
462
|
+
} | null;
|
|
463
|
+
} | null>;
|
|
464
|
+
/**
|
|
465
|
+
* Get top N holders for a token.
|
|
466
|
+
* Returns address + balance sorted by balance descending.
|
|
467
|
+
*/
|
|
468
|
+
getTopHolders(tokenAddress: string, limit?: number): Promise<{
|
|
469
|
+
address: string;
|
|
470
|
+
balance: bigint;
|
|
471
|
+
}[]>;
|
|
472
|
+
/**
|
|
473
|
+
* Get recent activity (mint + burn events) for a token.
|
|
474
|
+
* Useful for a quick activity feed.
|
|
475
|
+
*/
|
|
476
|
+
getRecentActivity(tokenAddress: string, limit?: number): Promise<{
|
|
477
|
+
type: "mint" | "burn";
|
|
478
|
+
txHash: string;
|
|
479
|
+
blockNumber: bigint;
|
|
480
|
+
timestamp: bigint;
|
|
481
|
+
amount: bigint;
|
|
482
|
+
actor: string;
|
|
483
|
+
}[]>;
|
|
484
|
+
/**
|
|
485
|
+
* Get a holder balance across all their holdings.
|
|
486
|
+
* Useful for an address summary view.
|
|
487
|
+
*/
|
|
488
|
+
getAccountPortfolio(ethAddress: string): Promise<Array<{
|
|
489
|
+
token: string;
|
|
490
|
+
balance: bigint;
|
|
491
|
+
}>>;
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
interface IsometryGraphConfig {
|
|
495
|
+
endpoint: string;
|
|
496
|
+
headers?: Record<string, string>;
|
|
497
|
+
}
|
|
498
|
+
/**
|
|
499
|
+
* Create all graph services from a single config.
|
|
500
|
+
* Convenience wrapper — individual services are also importable directly.
|
|
501
|
+
*/
|
|
502
|
+
declare function createGraphClient(config: IsometryGraphConfig): {
|
|
503
|
+
client: GraphClient;
|
|
504
|
+
token: TokenHistoryService;
|
|
505
|
+
platform: PlatformHistoryService;
|
|
506
|
+
analytics: AnalyticsService;
|
|
507
|
+
};
|
|
508
|
+
|
|
509
|
+
/**
|
|
510
|
+
* IsometryClient — RPC + Graph 双通道聚合
|
|
511
|
+
*/
|
|
512
|
+
|
|
513
|
+
interface IsometryConfig {
|
|
514
|
+
chainId?: number;
|
|
515
|
+
rpcUrl?: string;
|
|
516
|
+
graphUrl?: string;
|
|
517
|
+
addresses?: ContractAddresses;
|
|
518
|
+
privateKey?: string;
|
|
519
|
+
}
|
|
520
|
+
declare const SDK_VERSION = "0.4.0";
|
|
521
|
+
declare class IsometryClient {
|
|
522
|
+
readonly rpc: {
|
|
523
|
+
platform: PlatformRpcService;
|
|
524
|
+
factory: FactoryRpcService;
|
|
525
|
+
token: StableCoinRpcService;
|
|
526
|
+
};
|
|
527
|
+
readonly graph: ReturnType<typeof createGraphClient>;
|
|
528
|
+
readonly config: {
|
|
529
|
+
chainId: number;
|
|
530
|
+
rpcUrl: string;
|
|
531
|
+
graphUrl: string;
|
|
532
|
+
addresses: ContractAddresses;
|
|
533
|
+
privateKey: string | undefined;
|
|
534
|
+
walletMode: string;
|
|
535
|
+
};
|
|
536
|
+
private _wallet;
|
|
537
|
+
private _addresses;
|
|
538
|
+
private _chainId;
|
|
539
|
+
constructor(config?: IsometryConfig);
|
|
540
|
+
/** Validate chain ID matches configured value */
|
|
541
|
+
validateChain(): Promise<void>;
|
|
542
|
+
/** Get connected address (null if read-only) */
|
|
543
|
+
getAddress(): Promise<string | null>;
|
|
544
|
+
destroy(): Promise<void>;
|
|
545
|
+
}
|
|
546
|
+
declare function createClient(config?: IsometryConfig): IsometryClient;
|
|
547
|
+
|
|
548
|
+
/**
|
|
549
|
+
* Error selector → human-readable code mapping
|
|
550
|
+
*
|
|
551
|
+
* Observed on Sepolia (from live testing):
|
|
552
|
+
* - 0xe2517d3f = OpenZeppelin AccessControlUnauthorizedAccount
|
|
553
|
+
* - 0x08c379a0 = Error(string) — "Not authorized", "Not approved issuer"
|
|
554
|
+
*
|
|
555
|
+
* Extend this map as new selectors are observed on-chain.
|
|
556
|
+
*/
|
|
557
|
+
interface DecodedError {
|
|
558
|
+
code: string;
|
|
559
|
+
message: string;
|
|
560
|
+
}
|
|
561
|
+
/**
|
|
562
|
+
* Maps 4-byte error selector (0x...) to { code, message }.
|
|
563
|
+
* Code is a SCREAMING_SNAKE_CASE identifier suitable for JSON output.
|
|
564
|
+
*/
|
|
565
|
+
declare const ERROR_SELECTOR_MAP: Record<string, DecodedError>;
|
|
566
|
+
/**
|
|
567
|
+
* Decode an ethers CALL_EXCEPTION error details object.
|
|
568
|
+
* Returns a DecodedError if the selector is known, otherwise null.
|
|
569
|
+
*/
|
|
570
|
+
declare function decodeError(details: {
|
|
571
|
+
data?: string;
|
|
572
|
+
revert?: {
|
|
573
|
+
signature?: string;
|
|
574
|
+
name?: string;
|
|
575
|
+
args?: unknown[];
|
|
576
|
+
};
|
|
577
|
+
reason?: string | null;
|
|
578
|
+
}): DecodedError | null;
|
|
579
|
+
|
|
580
|
+
export { AnalyticsService, type ContractAddresses, type DecodedError, ERROR_SELECTOR_MAP, type ExecuteResult, GraphClient, GraphError, type IWallet, IsometryClient, type IsometryConfig, type IsometryGraphConfig, PlatformHistoryService, type PlatformInfo, type PlatformRoles, PrivateKeyWallet, ReadOnlyWallet, SDK_VERSION, type SimulateResult, TokenHistoryService, type TokenInfo, type TokenRoles, type TokenStats, type TxReceipt, type WalletMode, type WriteError, type WriteErrorCode, WriteExecutor, type WriteMeta, type WriteOpts, type WriteResult, createClient, createGraphClient, createWallet, decodeError, getContracts, getStableCoin, makeWriteMeta };
|