@cfxdevkit/core 0.1.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/CHANGELOG.md +35 -0
- package/LICENSE +72 -0
- package/README.md +257 -0
- package/dist/clients/index.cjs +2053 -0
- package/dist/clients/index.cjs.map +1 -0
- package/dist/clients/index.d.cts +7 -0
- package/dist/clients/index.d.ts +7 -0
- package/dist/clients/index.js +2043 -0
- package/dist/clients/index.js.map +1 -0
- package/dist/config/index.cjs +423 -0
- package/dist/config/index.cjs.map +1 -0
- package/dist/config/index.d.cts +99 -0
- package/dist/config/index.d.ts +99 -0
- package/dist/config/index.js +380 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config-BMtaWM0X.d.cts +165 -0
- package/dist/config-BMtaWM0X.d.ts +165 -0
- package/dist/core-C5qe16RS.d.ts +352 -0
- package/dist/core-RZA4aKwj.d.cts +352 -0
- package/dist/index-BhCpy6Fz.d.cts +165 -0
- package/dist/index-Qz84U9Oq.d.ts +165 -0
- package/dist/index.cjs +3773 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +945 -0
- package/dist/index.d.ts +945 -0
- package/dist/index.js +3730 -0
- package/dist/index.js.map +1 -0
- package/dist/types/index.cjs +44 -0
- package/dist/types/index.cjs.map +1 -0
- package/dist/types/index.d.cts +5 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.js +17 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/index.cjs +83 -0
- package/dist/utils/index.cjs.map +1 -0
- package/dist/utils/index.d.cts +11 -0
- package/dist/utils/index.d.ts +11 -0
- package/dist/utils/index.js +56 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/wallet/index.cjs +852 -0
- package/dist/wallet/index.cjs.map +1 -0
- package/dist/wallet/index.d.cts +726 -0
- package/dist/wallet/index.d.ts +726 -0
- package/dist/wallet/index.js +815 -0
- package/dist/wallet/index.js.map +1 -0
- package/package.json +119 -0
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
interface NodeConfig {
|
|
2
|
+
readonly chainId?: number;
|
|
3
|
+
readonly evmChainId?: number;
|
|
4
|
+
readonly jsonrpcHttpPort?: number;
|
|
5
|
+
readonly jsonrpcHttpEthPort?: number;
|
|
6
|
+
readonly jsonrpcWsPort?: number;
|
|
7
|
+
readonly jsonrpcWsEthPort?: number;
|
|
8
|
+
readonly confluxDataDir?: string;
|
|
9
|
+
readonly log?: boolean;
|
|
10
|
+
readonly logConf?: string;
|
|
11
|
+
readonly genesisSecrets?: readonly string[];
|
|
12
|
+
readonly genesisEvmSecrets?: readonly string[];
|
|
13
|
+
readonly miningAuthor?: string;
|
|
14
|
+
readonly nodeType?: 'full' | 'archive' | 'light';
|
|
15
|
+
readonly blockDbType?: 'rocksdb' | 'sqlite';
|
|
16
|
+
}
|
|
17
|
+
interface ExtendedNodeConfig extends NodeConfig {
|
|
18
|
+
readonly accountCount?: number;
|
|
19
|
+
readonly silent?: boolean;
|
|
20
|
+
readonly fundAccounts?: boolean;
|
|
21
|
+
readonly enabledChains?: readonly ('core' | 'evm')[];
|
|
22
|
+
readonly derivationPaths?: {
|
|
23
|
+
readonly core: string;
|
|
24
|
+
readonly evm: string;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
type Address = string;
|
|
28
|
+
type CoreAddress = string;
|
|
29
|
+
type EvmAddress = string;
|
|
30
|
+
type Hash = string;
|
|
31
|
+
type ChainType = 'core' | 'evm';
|
|
32
|
+
interface UnifiedAccount {
|
|
33
|
+
readonly id: string;
|
|
34
|
+
readonly name: string;
|
|
35
|
+
readonly index: number;
|
|
36
|
+
readonly privateKey: string;
|
|
37
|
+
readonly derivationPath: string;
|
|
38
|
+
readonly coreAddress: CoreAddress;
|
|
39
|
+
readonly evmAddress: EvmAddress;
|
|
40
|
+
readonly coreBalance: bigint;
|
|
41
|
+
readonly evmBalance: bigint;
|
|
42
|
+
readonly coreNonce: number;
|
|
43
|
+
readonly evmNonce: number;
|
|
44
|
+
readonly isActive: boolean;
|
|
45
|
+
readonly createdAt: Date;
|
|
46
|
+
readonly updatedAt: Date;
|
|
47
|
+
}
|
|
48
|
+
interface ChainStatus {
|
|
49
|
+
readonly isRunning: boolean;
|
|
50
|
+
readonly chainId: number;
|
|
51
|
+
readonly blockNumber: bigint;
|
|
52
|
+
readonly gasPrice: bigint;
|
|
53
|
+
readonly peerCount: number;
|
|
54
|
+
readonly syncStatus: 'syncing' | 'synced';
|
|
55
|
+
readonly latestBlockHash: string;
|
|
56
|
+
readonly mining: boolean;
|
|
57
|
+
readonly pendingTransactions: number;
|
|
58
|
+
readonly rpcEndpoint: string;
|
|
59
|
+
readonly wsEndpoint?: string;
|
|
60
|
+
}
|
|
61
|
+
interface NodeStatus {
|
|
62
|
+
readonly isRunning: boolean;
|
|
63
|
+
readonly uptime: number;
|
|
64
|
+
readonly startTime: Date | null;
|
|
65
|
+
readonly core: ChainStatus;
|
|
66
|
+
readonly evm: ChainStatus;
|
|
67
|
+
readonly dataDir: string;
|
|
68
|
+
readonly config: NodeConfig;
|
|
69
|
+
readonly mining: MiningStatus;
|
|
70
|
+
}
|
|
71
|
+
interface MiningStatus {
|
|
72
|
+
readonly isRunning: boolean;
|
|
73
|
+
readonly interval: number;
|
|
74
|
+
readonly blocksMined: number;
|
|
75
|
+
readonly startTime: Date | null;
|
|
76
|
+
readonly lastBlockTime: Date | null;
|
|
77
|
+
}
|
|
78
|
+
interface BaseTransaction {
|
|
79
|
+
readonly to?: string;
|
|
80
|
+
readonly value?: bigint;
|
|
81
|
+
readonly data?: string;
|
|
82
|
+
readonly gasLimit?: bigint;
|
|
83
|
+
readonly gasPrice?: bigint;
|
|
84
|
+
readonly nonce?: number;
|
|
85
|
+
}
|
|
86
|
+
interface TransactionReceipt {
|
|
87
|
+
readonly hash: string;
|
|
88
|
+
readonly blockNumber: bigint;
|
|
89
|
+
readonly blockHash: string;
|
|
90
|
+
readonly transactionIndex: number;
|
|
91
|
+
readonly status: 'success' | 'reverted';
|
|
92
|
+
readonly gasUsed: bigint;
|
|
93
|
+
readonly contractAddress?: string;
|
|
94
|
+
readonly logs: readonly Log[];
|
|
95
|
+
}
|
|
96
|
+
interface Log {
|
|
97
|
+
readonly address: string;
|
|
98
|
+
readonly topics: readonly string[];
|
|
99
|
+
readonly data: string;
|
|
100
|
+
readonly blockNumber: bigint;
|
|
101
|
+
readonly transactionHash: string;
|
|
102
|
+
readonly logIndex: number;
|
|
103
|
+
}
|
|
104
|
+
interface ConfluxNodeError extends Error {
|
|
105
|
+
readonly code: string;
|
|
106
|
+
readonly chain?: ChainType;
|
|
107
|
+
readonly context?: Record<string, unknown>;
|
|
108
|
+
}
|
|
109
|
+
declare class NodeError extends Error implements ConfluxNodeError {
|
|
110
|
+
readonly code: string;
|
|
111
|
+
readonly chain?: ChainType;
|
|
112
|
+
readonly context?: Record<string, unknown>;
|
|
113
|
+
constructor(message: string, code: string, chain?: ChainType, context?: Record<string, unknown>);
|
|
114
|
+
}
|
|
115
|
+
interface BlockEvent {
|
|
116
|
+
readonly chainType: ChainType;
|
|
117
|
+
readonly blockNumber: bigint;
|
|
118
|
+
readonly blockHash: string;
|
|
119
|
+
readonly timestamp: number;
|
|
120
|
+
readonly transactionCount: number;
|
|
121
|
+
}
|
|
122
|
+
interface TransactionEvent {
|
|
123
|
+
readonly chainType: ChainType;
|
|
124
|
+
readonly hash: string;
|
|
125
|
+
readonly from: string;
|
|
126
|
+
readonly to?: string;
|
|
127
|
+
readonly value: bigint;
|
|
128
|
+
readonly blockNumber: bigint;
|
|
129
|
+
}
|
|
130
|
+
type EventCallback<T> = (event: T) => void;
|
|
131
|
+
type UnwatchFunction = () => void;
|
|
132
|
+
type ServerStatus = 'stopped' | 'starting' | 'running' | 'stopping' | 'error';
|
|
133
|
+
interface ServerConfig {
|
|
134
|
+
readonly coreRpcPort?: number;
|
|
135
|
+
readonly evmRpcPort?: number;
|
|
136
|
+
readonly wsPort?: number;
|
|
137
|
+
readonly chainId?: number;
|
|
138
|
+
readonly evmChainId?: number;
|
|
139
|
+
readonly accounts?: number;
|
|
140
|
+
readonly balance?: string;
|
|
141
|
+
readonly mnemonic?: string;
|
|
142
|
+
readonly logging?: boolean;
|
|
143
|
+
readonly detached?: boolean;
|
|
144
|
+
readonly mining?: MiningConfig;
|
|
145
|
+
readonly devBlockIntervalMs?: number;
|
|
146
|
+
readonly devPackTxImmediately?: boolean;
|
|
147
|
+
readonly dataDir?: string;
|
|
148
|
+
}
|
|
149
|
+
interface MiningConfig {
|
|
150
|
+
readonly enabled: boolean;
|
|
151
|
+
readonly interval: number;
|
|
152
|
+
readonly autoStart: boolean;
|
|
153
|
+
}
|
|
154
|
+
interface AccountInfo {
|
|
155
|
+
readonly index: number;
|
|
156
|
+
readonly privateKey: string;
|
|
157
|
+
readonly coreAddress: string;
|
|
158
|
+
readonly evmAddress: string;
|
|
159
|
+
readonly mnemonic: string;
|
|
160
|
+
readonly path: string;
|
|
161
|
+
readonly evmPrivateKey?: string;
|
|
162
|
+
readonly evmPath?: string;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export { type Address as A, type BaseTransaction as B, type ChainType as C, type EventCallback as E, type Hash as H, type Log as L, type MiningConfig as M, type NodeConfig as N, type ServerConfig as S, type TransactionReceipt as T, type UnwatchFunction as U, type BlockEvent as a, type TransactionEvent as b, type AccountInfo as c, type ConfluxNodeError as d, type CoreAddress as e, type EvmAddress as f, type ExtendedNodeConfig as g, NodeError as h, type NodeStatus as i, type ServerStatus as j, type UnifiedAccount as k };
|
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
import './config/index.js';
|
|
2
|
+
import { C as ChainType, A as Address, B as BaseTransaction, T as TransactionReceipt, E as EventCallback, a as BlockEvent, U as UnwatchFunction, b as TransactionEvent } from './config-BMtaWM0X.js';
|
|
3
|
+
import { Address as Address$2, PublicClient as PublicClient$1, WalletClient as WalletClient$2, TestClient as TestClient$1 } from 'cive';
|
|
4
|
+
import { PublicClient, Chain, Address as Address$1, WalletClient as WalletClient$1 } from 'viem';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Unified interface for both Core and EVM clients
|
|
8
|
+
* Abstracts away the differences between cive and viem
|
|
9
|
+
*/
|
|
10
|
+
interface ChainClient {
|
|
11
|
+
readonly chainType: ChainType;
|
|
12
|
+
readonly chainId: number;
|
|
13
|
+
readonly address: Address;
|
|
14
|
+
getBlockNumber(): Promise<bigint>;
|
|
15
|
+
getBalance(address: Address): Promise<string>;
|
|
16
|
+
getGasPrice(): Promise<bigint>;
|
|
17
|
+
estimateGas(tx: BaseTransaction): Promise<bigint>;
|
|
18
|
+
sendTransaction(tx: BaseTransaction): Promise<string>;
|
|
19
|
+
waitForTransaction(hash: string): Promise<TransactionReceipt>;
|
|
20
|
+
getTokenBalance(tokenAddress: Address, holderAddress?: Address): Promise<string>;
|
|
21
|
+
watchBlocks(callback: EventCallback<BlockEvent>): UnwatchFunction;
|
|
22
|
+
watchTransactions(callback: EventCallback<TransactionEvent>): UnwatchFunction;
|
|
23
|
+
isValidAddress(address: string): boolean;
|
|
24
|
+
formatAmount(amount: bigint): string;
|
|
25
|
+
parseAmount(amount: string): bigint;
|
|
26
|
+
getInternalClient(): unknown;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Wallet client interface for signing transactions
|
|
30
|
+
*/
|
|
31
|
+
interface WalletClient {
|
|
32
|
+
readonly address: Address;
|
|
33
|
+
readonly chainType: ChainType;
|
|
34
|
+
sendTransaction(tx: BaseTransaction): Promise<string>;
|
|
35
|
+
signMessage(message: string): Promise<string>;
|
|
36
|
+
getInternalClient(): unknown;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Test client interface for development operations
|
|
40
|
+
*/
|
|
41
|
+
interface TestClient extends ChainClient {
|
|
42
|
+
mine(blocks?: number): Promise<void>;
|
|
43
|
+
setNextBlockTimestamp(timestamp: number): Promise<void>;
|
|
44
|
+
increaseTime(seconds: number): Promise<void>;
|
|
45
|
+
impersonateAccount(address: Address): Promise<void>;
|
|
46
|
+
stopImpersonatingAccount(address: Address): Promise<void>;
|
|
47
|
+
setBalance(address: Address, balance: bigint): Promise<void>;
|
|
48
|
+
getStorageAt(address: Address, slot: string): Promise<string>;
|
|
49
|
+
setStorageAt(address: Address, slot: string, value: string): Promise<void>;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Client factory interface
|
|
53
|
+
*/
|
|
54
|
+
interface ClientFactory {
|
|
55
|
+
createPublicClient(chainType: ChainType, config: ClientConfig): ChainClient;
|
|
56
|
+
createWalletClient(chainType: ChainType, config: WalletConfig): WalletClient;
|
|
57
|
+
createTestClient(chainType: ChainType, config: TestConfig): TestClient;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Configuration interfaces for client creation
|
|
61
|
+
*/
|
|
62
|
+
interface ClientConfig {
|
|
63
|
+
readonly rpcUrl: string;
|
|
64
|
+
readonly wsUrl?: string;
|
|
65
|
+
readonly chainId: number;
|
|
66
|
+
readonly pollingInterval?: number;
|
|
67
|
+
readonly account?: string | {
|
|
68
|
+
privateKey: string;
|
|
69
|
+
accountIndex?: number;
|
|
70
|
+
};
|
|
71
|
+
readonly testMode?: boolean;
|
|
72
|
+
}
|
|
73
|
+
interface WalletConfig extends ClientConfig {
|
|
74
|
+
readonly privateKey: string;
|
|
75
|
+
readonly accountIndex?: number;
|
|
76
|
+
}
|
|
77
|
+
interface TestConfig extends ClientConfig {
|
|
78
|
+
readonly enableTestMode: boolean;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Client manager interface
|
|
82
|
+
* Manages lifecycle of both Core and EVM clients
|
|
83
|
+
*/
|
|
84
|
+
interface ClientManager {
|
|
85
|
+
initialize(): Promise<void>;
|
|
86
|
+
shutdown(): Promise<void>;
|
|
87
|
+
getCoreClient(): ChainClient;
|
|
88
|
+
getEvmClient(): ChainClient;
|
|
89
|
+
getCoreWalletClient(accountIndex?: number): WalletClient;
|
|
90
|
+
getEvmWalletClient(accountIndex?: number): WalletClient;
|
|
91
|
+
getCoreTestClient(): TestClient;
|
|
92
|
+
getEvmTestClient(): TestClient;
|
|
93
|
+
isInitialized(): boolean;
|
|
94
|
+
getStatus(): {
|
|
95
|
+
core: {
|
|
96
|
+
isConnected: boolean;
|
|
97
|
+
blockNumber: bigint;
|
|
98
|
+
};
|
|
99
|
+
evm: {
|
|
100
|
+
isConnected: boolean;
|
|
101
|
+
blockNumber: bigint;
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
checkHealth(): Promise<boolean>;
|
|
105
|
+
on(event: 'block', callback: EventCallback<BlockEvent>): void;
|
|
106
|
+
on(event: 'transaction', callback: EventCallback<TransactionEvent>): void;
|
|
107
|
+
on(event: 'error', callback: EventCallback<Error>): void;
|
|
108
|
+
off(event: 'block', callback: EventCallback<BlockEvent>): void;
|
|
109
|
+
off(event: 'transaction', callback: EventCallback<TransactionEvent>): void;
|
|
110
|
+
off(event: 'error', callback: EventCallback<Error>): void;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* EVM Space (eSpace) Client Implementation
|
|
115
|
+
* Provides unified interface for Ethereum-compatible operations on Conflux eSpace
|
|
116
|
+
*/
|
|
117
|
+
declare class EspaceClient implements ChainClient {
|
|
118
|
+
readonly chainId: number;
|
|
119
|
+
readonly chainType: "evm";
|
|
120
|
+
readonly publicClient: PublicClient;
|
|
121
|
+
protected readonly chain: Chain;
|
|
122
|
+
address: Address$1;
|
|
123
|
+
constructor(config: ClientConfig);
|
|
124
|
+
getBlockNumber(): Promise<bigint>;
|
|
125
|
+
getBalance(address: Address$1): Promise<string>;
|
|
126
|
+
estimateGas(tx: BaseTransaction): Promise<bigint>;
|
|
127
|
+
waitForTransaction(hash: string): Promise<TransactionReceipt>;
|
|
128
|
+
getGasPrice(): Promise<bigint>;
|
|
129
|
+
/**
|
|
130
|
+
* Get the current chain ID from the network
|
|
131
|
+
*/
|
|
132
|
+
getChainId(): Promise<number>;
|
|
133
|
+
/**
|
|
134
|
+
* Check if the client is connected to the network
|
|
135
|
+
*/
|
|
136
|
+
isConnected(): Promise<boolean>;
|
|
137
|
+
sendTransaction(_tx: BaseTransaction): Promise<string>;
|
|
138
|
+
getTokenBalance(_address: string, _tokenAddress: string): Promise<string>;
|
|
139
|
+
watchBlocks(callback: EventCallback<BlockEvent>): () => void;
|
|
140
|
+
watchTransaction(_hash: string, _callback: (receipt: TransactionReceipt) => void): Promise<() => void>;
|
|
141
|
+
getInternalClient(): PublicClient | WalletClient$1;
|
|
142
|
+
watchTransactions(_callback: EventCallback<TransactionEvent>): () => void;
|
|
143
|
+
isValidAddress(address: string): boolean;
|
|
144
|
+
formatAmount(amount: bigint): string;
|
|
145
|
+
parseAmount(amount: string): bigint;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* EVM Space Wallet Client
|
|
149
|
+
* Extends EspaceClient with transaction and account functionality
|
|
150
|
+
*/
|
|
151
|
+
declare class EspaceWalletClient extends EspaceClient implements WalletClient {
|
|
152
|
+
private readonly walletClient;
|
|
153
|
+
private readonly account;
|
|
154
|
+
constructor(config: ClientConfig & {
|
|
155
|
+
privateKey: string;
|
|
156
|
+
});
|
|
157
|
+
getAddress(): Address$1;
|
|
158
|
+
sendTransaction(tx: BaseTransaction): Promise<string>;
|
|
159
|
+
signMessage(message: string): Promise<string>;
|
|
160
|
+
deployContract(abi: unknown[], bytecode: string, constructorArgs?: unknown[]): Promise<string>;
|
|
161
|
+
callContract<T = unknown>(address: string, abi: unknown[], functionName: string, args?: unknown[]): Promise<T>;
|
|
162
|
+
writeContract(address: string, abi: unknown[], functionName: string, args?: unknown[], value?: bigint): Promise<string>;
|
|
163
|
+
/**
|
|
164
|
+
* Transfer CFX from eSpace to Core Space
|
|
165
|
+
* Uses the built-in withdrawal mechanism
|
|
166
|
+
*/
|
|
167
|
+
faucetToCore(coreAddress: string, amount: string): Promise<string>;
|
|
168
|
+
getInternalClient(): PublicClient | WalletClient$1;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* EVM Space Test Client
|
|
172
|
+
* Extends EspaceWalletClient with additional testing utilities
|
|
173
|
+
*/
|
|
174
|
+
declare class EspaceTestClient extends EspaceWalletClient implements TestClient {
|
|
175
|
+
private readonly testClient;
|
|
176
|
+
constructor(config: TestConfig & {
|
|
177
|
+
privateKey: string;
|
|
178
|
+
});
|
|
179
|
+
mine(blocks?: number): Promise<void>;
|
|
180
|
+
setNextBlockTimestamp(timestamp: number): Promise<void>;
|
|
181
|
+
increaseTime(seconds: number): Promise<void>;
|
|
182
|
+
impersonateAccount(address: string): Promise<void>;
|
|
183
|
+
stopImpersonatingAccount(address: string): Promise<void>;
|
|
184
|
+
setBalance(address: string, balance: bigint): Promise<void>;
|
|
185
|
+
snapshot(): Promise<string>;
|
|
186
|
+
revert(snapshotId: string): Promise<void>;
|
|
187
|
+
getStorageAt(address: string, slot: string): Promise<string>;
|
|
188
|
+
setStorageAt(address: string, slot: string, value: string): Promise<void>;
|
|
189
|
+
watchTransactions(callback: EventCallback<TransactionEvent>): () => void;
|
|
190
|
+
isValidAddress(address: string): boolean;
|
|
191
|
+
getCurrentEpoch(): Promise<bigint>;
|
|
192
|
+
generateAccounts(count: number): Promise<string[]>;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
type HealthStatus = 'healthy' | 'unhealthy' | 'disconnected' | 'unknown';
|
|
196
|
+
|
|
197
|
+
interface CoreClientInstance {
|
|
198
|
+
publicClient: CoreClient;
|
|
199
|
+
walletClient?: CoreWalletClient;
|
|
200
|
+
testClient?: CoreTestClient;
|
|
201
|
+
}
|
|
202
|
+
interface EspaceClientInstance {
|
|
203
|
+
publicClient: EspaceClient;
|
|
204
|
+
walletClient?: EspaceWalletClient;
|
|
205
|
+
testClient?: EspaceTestClient;
|
|
206
|
+
}
|
|
207
|
+
interface StartOptions {
|
|
208
|
+
mining?: boolean;
|
|
209
|
+
waitForBlocks?: number;
|
|
210
|
+
fundingAmount?: string;
|
|
211
|
+
}
|
|
212
|
+
interface DeployOptions {
|
|
213
|
+
abi: unknown[];
|
|
214
|
+
bytecode: string;
|
|
215
|
+
args?: unknown[];
|
|
216
|
+
account: number;
|
|
217
|
+
chain?: 'core' | 'evm';
|
|
218
|
+
chains?: ('core' | 'evm')[];
|
|
219
|
+
value?: bigint;
|
|
220
|
+
}
|
|
221
|
+
interface ReadOptions {
|
|
222
|
+
address: string;
|
|
223
|
+
abi: unknown[];
|
|
224
|
+
functionName: string;
|
|
225
|
+
args?: unknown[];
|
|
226
|
+
chain: 'core' | 'evm';
|
|
227
|
+
}
|
|
228
|
+
interface WriteOptions {
|
|
229
|
+
address: string;
|
|
230
|
+
abi: unknown[];
|
|
231
|
+
functionName: string;
|
|
232
|
+
args?: unknown[];
|
|
233
|
+
account: number;
|
|
234
|
+
chain: 'core' | 'evm';
|
|
235
|
+
value?: bigint;
|
|
236
|
+
waitForConfirmation?: boolean;
|
|
237
|
+
}
|
|
238
|
+
interface ContractResult {
|
|
239
|
+
core?: string;
|
|
240
|
+
evm?: string;
|
|
241
|
+
}
|
|
242
|
+
interface ChainStatus {
|
|
243
|
+
core: {
|
|
244
|
+
connected: boolean;
|
|
245
|
+
status: string;
|
|
246
|
+
};
|
|
247
|
+
evm: {
|
|
248
|
+
connected: boolean;
|
|
249
|
+
status: string;
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
interface FaucetBalances {
|
|
253
|
+
coreBalance: string;
|
|
254
|
+
evmBalance: string;
|
|
255
|
+
}
|
|
256
|
+
interface MiningStatus {
|
|
257
|
+
isRunning: boolean;
|
|
258
|
+
interval: number;
|
|
259
|
+
blocksMined: number;
|
|
260
|
+
startTime?: Date;
|
|
261
|
+
}
|
|
262
|
+
interface ChainBalances {
|
|
263
|
+
core: string;
|
|
264
|
+
evm: string;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* Core Space Client Implementation
|
|
269
|
+
* Wraps cive client with unified interface
|
|
270
|
+
*/
|
|
271
|
+
declare class CoreClient implements ChainClient {
|
|
272
|
+
readonly chainType: "core";
|
|
273
|
+
readonly chainId: number;
|
|
274
|
+
readonly address: Address$2;
|
|
275
|
+
private readonly publicClient;
|
|
276
|
+
private readonly chain;
|
|
277
|
+
constructor(config: ClientConfig);
|
|
278
|
+
getBlockNumber(): Promise<bigint>;
|
|
279
|
+
getBalance(address: Address$2): Promise<string>;
|
|
280
|
+
getGasPrice(): Promise<bigint>;
|
|
281
|
+
estimateGas(tx: BaseTransaction): Promise<bigint>;
|
|
282
|
+
sendTransaction(_tx: BaseTransaction): Promise<string>;
|
|
283
|
+
waitForTransaction(hash: string): Promise<TransactionReceipt>;
|
|
284
|
+
getTokenBalance(tokenAddress: Address$2, holderAddress?: Address$2): Promise<string>;
|
|
285
|
+
watchBlocks(callback: EventCallback<BlockEvent>): UnwatchFunction;
|
|
286
|
+
watchTransactions(callback: EventCallback<TransactionEvent>): UnwatchFunction;
|
|
287
|
+
isValidAddress(address: string): boolean;
|
|
288
|
+
formatAmount(amount: bigint): string;
|
|
289
|
+
parseAmount(amount: string): bigint;
|
|
290
|
+
getInternalClient(): PublicClient$1;
|
|
291
|
+
private formatTokenAmount;
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Core Space Wallet Client Implementation
|
|
295
|
+
*/
|
|
296
|
+
declare class CoreWalletClient implements WalletClient {
|
|
297
|
+
readonly chainType: "core";
|
|
298
|
+
readonly address: Address$2;
|
|
299
|
+
readonly chainId: number;
|
|
300
|
+
private readonly walletClient;
|
|
301
|
+
private readonly publicClient;
|
|
302
|
+
private readonly account;
|
|
303
|
+
private readonly chain;
|
|
304
|
+
constructor(config: WalletConfig);
|
|
305
|
+
sendTransaction(tx: BaseTransaction): Promise<string>;
|
|
306
|
+
signMessage(message: string): Promise<string>;
|
|
307
|
+
getInternalClient(): WalletClient$2;
|
|
308
|
+
waitForTransaction(hash: string): Promise<TransactionReceipt>;
|
|
309
|
+
/**
|
|
310
|
+
* Unified faucet functionality
|
|
311
|
+
* Automatically detects address type and sends CFX accordingly:
|
|
312
|
+
* - Core address: Direct transfer
|
|
313
|
+
* - eSpace address: Cross-chain transfer via internal contract
|
|
314
|
+
*/
|
|
315
|
+
faucet(address: string, amount: string): Promise<string>;
|
|
316
|
+
/**
|
|
317
|
+
* Cross-chain faucet functionality (Core → eSpace)
|
|
318
|
+
* Sends CFX from Core space to eSpace address via internal contract
|
|
319
|
+
* @deprecated Use faucet() instead which auto-detects address type
|
|
320
|
+
*/
|
|
321
|
+
faucetToEspace(espaceAddress: string, amount: string): Promise<string>;
|
|
322
|
+
/**
|
|
323
|
+
* Deploy a contract to Core Space
|
|
324
|
+
*/
|
|
325
|
+
deployContract(abi: unknown[], bytecode: string, constructorArgs?: unknown[]): Promise<string>;
|
|
326
|
+
/**
|
|
327
|
+
* Call a contract method (read-only)
|
|
328
|
+
*/
|
|
329
|
+
callContract<T = unknown>(address: string, abi: unknown[], functionName: string, args?: unknown[]): Promise<T>;
|
|
330
|
+
/**
|
|
331
|
+
* Write to a contract (transaction)
|
|
332
|
+
*/
|
|
333
|
+
writeContract(address: string, abi: unknown[], functionName: string, args?: unknown[], value?: bigint): Promise<string>;
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* Core Space Test Client Implementation
|
|
337
|
+
*/
|
|
338
|
+
declare class CoreTestClient extends CoreClient implements TestClient {
|
|
339
|
+
private readonly testClient;
|
|
340
|
+
constructor(config: TestConfig);
|
|
341
|
+
mine(blocks?: number): Promise<void>;
|
|
342
|
+
setNextBlockTimestamp(_timestamp: number): Promise<void>;
|
|
343
|
+
increaseTime(_seconds: number): Promise<void>;
|
|
344
|
+
impersonateAccount(_address: Address$2): Promise<void>;
|
|
345
|
+
stopImpersonatingAccount(_address: Address$2): Promise<void>;
|
|
346
|
+
setBalance(_address: Address$2, _balance: bigint): Promise<void>;
|
|
347
|
+
getStorageAt(_address: Address$2, _slot: string): Promise<string>;
|
|
348
|
+
setStorageAt(_address: Address$2, _slot: string, _value: string): Promise<void>;
|
|
349
|
+
getInternalTestClient(): TestClient$1;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
export { CoreClient as C, type DeployOptions as D, EspaceClient as E, type FaucetBalances as F, type HealthStatus as H, type MiningStatus as M, type ReadOptions as R, type StartOptions as S, type TestClient as T, type WalletClient as W, CoreTestClient as a, CoreWalletClient as b, EspaceTestClient as c, EspaceWalletClient as d, type ClientConfig as e, type CoreClientInstance as f, type EspaceClientInstance as g, type ChainBalances as h, type ChainClient as i, type ChainStatus as j, type ClientFactory as k, type ClientManager as l, type ContractResult as m, type TestConfig as n, type WalletConfig as o, type WriteOptions as p };
|