@qorechain/evm 0.3.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 +96 -0
- package/dist/index.cjs +1010 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1145 -0
- package/dist/index.d.ts +1145 -0
- package/dist/index.js +967 -0
- package/dist/index.js.map +1 -0
- package/package.json +51 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,1145 @@
|
|
|
1
|
+
import { Transport, PublicClient, Account, WalletClient, Chain, Hex, PrivateKeyAccount, Address, Hash, Abi, WatchBlocksParameters, WatchContractEventParameters, WatchEventParameters, WatchPendingTransactionsParameters } from 'viem';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Client factory for the QoreChain EVM Engine.
|
|
5
|
+
*
|
|
6
|
+
* This is a thin convenience layer over viem: it builds a viem `Chain` object
|
|
7
|
+
* from the network's EVM endpoints, resolves the numeric EVM chain id (either
|
|
8
|
+
* supplied explicitly or auto-detected via `eth_chainId`), and returns ready-to-
|
|
9
|
+
* use viem public and wallet clients.
|
|
10
|
+
*
|
|
11
|
+
* The numeric EVM chain id for QoreChain networks is intentionally not hardcoded
|
|
12
|
+
* here: it is auto-detected at connect time unless the caller provides it.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/** Subset of a qorechain-sdk network's endpoints relevant to the EVM Engine. */
|
|
16
|
+
interface EvmEndpoints {
|
|
17
|
+
/** EVM JSON-RPC HTTP endpoint. */
|
|
18
|
+
evmRpc: string;
|
|
19
|
+
/** EVM JSON-RPC WebSocket endpoint (optional). */
|
|
20
|
+
evmWs?: string;
|
|
21
|
+
}
|
|
22
|
+
/** Options for {@link createEvmClient}. */
|
|
23
|
+
interface CreateEvmClientOptions {
|
|
24
|
+
/** EVM JSON-RPC HTTP URL. Mutually exclusive with `endpoints`. */
|
|
25
|
+
rpcUrl?: string;
|
|
26
|
+
/** EVM JSON-RPC WebSocket URL. */
|
|
27
|
+
wsUrl?: string;
|
|
28
|
+
/** A qorechain-sdk network endpoints object (uses `evmRpc`/`evmWs`). */
|
|
29
|
+
endpoints?: EvmEndpoints;
|
|
30
|
+
/**
|
|
31
|
+
* Numeric EVM chain id. If omitted, it is auto-detected via `eth_chainId`.
|
|
32
|
+
*
|
|
33
|
+
* The canonical chain id for QoreChain networks is not pinned in this package
|
|
34
|
+
* on purpose — always detect it, or pass it explicitly here.
|
|
35
|
+
*/
|
|
36
|
+
chainId?: number;
|
|
37
|
+
/**
|
|
38
|
+
* Native currency decimals for EVM display. Defaults to 18 (the EVM
|
|
39
|
+
* convention). Note: this is the EVM-side representation of QOR and is
|
|
40
|
+
* distinct from the Cosmos `uqor` base denomination (10^6). Confirm the
|
|
41
|
+
* canonical wrapped/native EVM decimals against your target node.
|
|
42
|
+
*/
|
|
43
|
+
decimals?: number;
|
|
44
|
+
/**
|
|
45
|
+
* Custom viem transport. When provided it is used instead of an HTTP
|
|
46
|
+
* transport built from the resolved RPC URL — primarily for testing.
|
|
47
|
+
*/
|
|
48
|
+
transport?: Transport;
|
|
49
|
+
}
|
|
50
|
+
/** A configured QoreChain EVM client bundle. */
|
|
51
|
+
interface EvmClient {
|
|
52
|
+
/** viem public (read) client bound to the resolved chain + transport. */
|
|
53
|
+
publicClient: PublicClient;
|
|
54
|
+
/** Build a viem wallet (write) client for the given account. */
|
|
55
|
+
getWalletClient: (account: Account) => WalletClient;
|
|
56
|
+
/** The viem `Chain` object describing the connected network. */
|
|
57
|
+
chain: Chain;
|
|
58
|
+
/** Return the resolved numeric EVM chain id. */
|
|
59
|
+
getChainId: () => Promise<number>;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Create a QoreChain EVM client bundle.
|
|
63
|
+
*
|
|
64
|
+
* Auto-detects the EVM chain id via `eth_chainId` unless `chainId` is supplied.
|
|
65
|
+
*/
|
|
66
|
+
declare function createEvmClient(opts: CreateEvmClientOptions): Promise<EvmClient>;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Account helpers for the QoreChain EVM Engine.
|
|
70
|
+
*
|
|
71
|
+
* These re-expose viem's account utilities so callers don't need a second import
|
|
72
|
+
* path. `@qorechain/sdk`'s `deriveEvmAccount` returns a `privateKey` you can pass
|
|
73
|
+
* straight into {@link evmAccountFromPrivateKey}.
|
|
74
|
+
*/
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Create a viem account from a `0x`-prefixed private key.
|
|
78
|
+
*
|
|
79
|
+
* Pair with `@qorechain/sdk`'s `deriveEvmAccount(mnemonic)`, which provides the
|
|
80
|
+
* `privateKey` derived for the EVM coin type.
|
|
81
|
+
*/
|
|
82
|
+
declare function evmAccountFromPrivateKey(privateKey: Hex): PrivateKeyAccount;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* ERC-20 conveniences over viem's `readContract` / `writeContract`, using a
|
|
86
|
+
* bundled minimal ERC-20 ABI. Read helpers take a viem `PublicClient`; write
|
|
87
|
+
* helpers take a viem `WalletClient`.
|
|
88
|
+
*/
|
|
89
|
+
|
|
90
|
+
/** Token metadata returned by {@link metadata}. */
|
|
91
|
+
interface Erc20Metadata {
|
|
92
|
+
name: string;
|
|
93
|
+
symbol: string;
|
|
94
|
+
decimals: number;
|
|
95
|
+
}
|
|
96
|
+
/** Read the token balance of `account`. */
|
|
97
|
+
declare function balanceOf$2(client: PublicClient, token: Address, account: Address): Promise<bigint>;
|
|
98
|
+
/** Read the remaining allowance `spender` may draw from `owner`. */
|
|
99
|
+
declare function allowance(client: PublicClient, token: Address, owner: Address, spender: Address): Promise<bigint>;
|
|
100
|
+
/** Read name/symbol/decimals in parallel. */
|
|
101
|
+
declare function metadata$1(client: PublicClient, token: Address): Promise<Erc20Metadata>;
|
|
102
|
+
/** Transfer `amount` tokens to `to`. Returns the transaction hash. */
|
|
103
|
+
declare function transfer(client: WalletClient, token: Address, to: Address, amount: bigint): Promise<Hash>;
|
|
104
|
+
/** Approve `spender` to draw up to `amount`. Returns the transaction hash. */
|
|
105
|
+
declare function approve$1(client: WalletClient, token: Address, spender: Address, amount: bigint): Promise<Hash>;
|
|
106
|
+
/** Namespaced ERC-20 helpers. */
|
|
107
|
+
declare const erc20: {
|
|
108
|
+
readonly balanceOf: typeof balanceOf$2;
|
|
109
|
+
readonly allowance: typeof allowance;
|
|
110
|
+
readonly metadata: typeof metadata$1;
|
|
111
|
+
readonly transfer: typeof transfer;
|
|
112
|
+
readonly approve: typeof approve$1;
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* ERC-721 conveniences over viem's `readContract` / `writeContract`, using a
|
|
117
|
+
* bundled minimal ERC-721 ABI. Read helpers take a viem `PublicClient`; write
|
|
118
|
+
* helpers take a viem `WalletClient`. Mirrors the {@link erc20} style.
|
|
119
|
+
*/
|
|
120
|
+
|
|
121
|
+
/** Collection metadata returned by {@link metadata}. */
|
|
122
|
+
interface Erc721Metadata {
|
|
123
|
+
name: string;
|
|
124
|
+
symbol: string;
|
|
125
|
+
}
|
|
126
|
+
/** Read the number of tokens owned by `owner`. */
|
|
127
|
+
declare function balanceOf$1(client: PublicClient, token: Address, owner: Address): Promise<bigint>;
|
|
128
|
+
/** Read the owner of `tokenId`. */
|
|
129
|
+
declare function ownerOf(client: PublicClient, token: Address, tokenId: bigint): Promise<Address>;
|
|
130
|
+
/** Read the metadata URI for `tokenId`. */
|
|
131
|
+
declare function tokenURI(client: PublicClient, token: Address, tokenId: bigint): Promise<string>;
|
|
132
|
+
/** Read the approved address for a single `tokenId`. */
|
|
133
|
+
declare function getApproved(client: PublicClient, token: Address, tokenId: bigint): Promise<Address>;
|
|
134
|
+
/** Read whether `operator` is approved to manage all of `owner`'s tokens. */
|
|
135
|
+
declare function isApprovedForAll$1(client: PublicClient, token: Address, owner: Address, operator: Address): Promise<boolean>;
|
|
136
|
+
/** Read the collection name. */
|
|
137
|
+
declare function name(client: PublicClient, token: Address): Promise<string>;
|
|
138
|
+
/** Read the collection symbol. */
|
|
139
|
+
declare function symbol(client: PublicClient, token: Address): Promise<string>;
|
|
140
|
+
/** Read name/symbol in parallel. */
|
|
141
|
+
declare function metadata(client: PublicClient, token: Address): Promise<Erc721Metadata>;
|
|
142
|
+
/** Approve `to` to transfer `tokenId`. Returns the transaction hash. */
|
|
143
|
+
declare function approve(client: WalletClient, token: Address, to: Address, tokenId: bigint): Promise<Hash>;
|
|
144
|
+
/** Set or revoke `operator` as an approved manager for all caller tokens. */
|
|
145
|
+
declare function setApprovalForAll$1(client: WalletClient, token: Address, operator: Address, approved: boolean): Promise<Hash>;
|
|
146
|
+
/** Transfer `tokenId` from `from` to `to`. Returns the transaction hash. */
|
|
147
|
+
declare function transferFrom(client: WalletClient, token: Address, from: Address, to: Address, tokenId: bigint): Promise<Hash>;
|
|
148
|
+
/**
|
|
149
|
+
* Safe-transfer `tokenId` from `from` to `to`. Pass `data` to invoke the
|
|
150
|
+
* 4-argument `safeTransferFrom(from,to,tokenId,bytes)` overload.
|
|
151
|
+
*/
|
|
152
|
+
declare function safeTransferFrom$1(client: WalletClient, token: Address, from: Address, to: Address, tokenId: bigint, data?: Hex): Promise<Hash>;
|
|
153
|
+
/** Namespaced ERC-721 helpers. */
|
|
154
|
+
declare const erc721: {
|
|
155
|
+
readonly balanceOf: typeof balanceOf$1;
|
|
156
|
+
readonly ownerOf: typeof ownerOf;
|
|
157
|
+
readonly tokenURI: typeof tokenURI;
|
|
158
|
+
readonly getApproved: typeof getApproved;
|
|
159
|
+
readonly isApprovedForAll: typeof isApprovedForAll$1;
|
|
160
|
+
readonly name: typeof name;
|
|
161
|
+
readonly symbol: typeof symbol;
|
|
162
|
+
readonly metadata: typeof metadata;
|
|
163
|
+
readonly approve: typeof approve;
|
|
164
|
+
readonly setApprovalForAll: typeof setApprovalForAll$1;
|
|
165
|
+
readonly transferFrom: typeof transferFrom;
|
|
166
|
+
readonly safeTransferFrom: typeof safeTransferFrom$1;
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* ERC-1155 conveniences over viem's `readContract` / `writeContract`, using a
|
|
171
|
+
* bundled minimal ERC-1155 ABI. Read helpers take a viem `PublicClient`; write
|
|
172
|
+
* helpers take a viem `WalletClient`. Mirrors the {@link erc20} style.
|
|
173
|
+
*/
|
|
174
|
+
|
|
175
|
+
/** Read the balance of token `id` held by `account`. */
|
|
176
|
+
declare function balanceOf(client: PublicClient, token: Address, account: Address, id: bigint): Promise<bigint>;
|
|
177
|
+
/** Read balances of `(accounts[i], ids[i])` pairs in a single call. */
|
|
178
|
+
declare function balanceOfBatch(client: PublicClient, token: Address, accounts: readonly Address[], ids: readonly bigint[]): Promise<readonly bigint[]>;
|
|
179
|
+
/** Read the metadata URI template for token `id`. */
|
|
180
|
+
declare function uri(client: PublicClient, token: Address, id: bigint): Promise<string>;
|
|
181
|
+
/** Read whether `operator` is approved to manage all of `account`'s tokens. */
|
|
182
|
+
declare function isApprovedForAll(client: PublicClient, token: Address, account: Address, operator: Address): Promise<boolean>;
|
|
183
|
+
/** Set or revoke `operator` as an approved manager for all caller tokens. */
|
|
184
|
+
declare function setApprovalForAll(client: WalletClient, token: Address, operator: Address, approved: boolean): Promise<Hash>;
|
|
185
|
+
/** Transfer `amount` of token `id` from `from` to `to`. */
|
|
186
|
+
declare function safeTransferFrom(client: WalletClient, token: Address, from: Address, to: Address, id: bigint, amount: bigint, data?: Hex): Promise<Hash>;
|
|
187
|
+
/** Batch-transfer `amounts[i]` of token `ids[i]` from `from` to `to`. */
|
|
188
|
+
declare function safeBatchTransferFrom(client: WalletClient, token: Address, from: Address, to: Address, ids: readonly bigint[], amounts: readonly bigint[], data?: Hex): Promise<Hash>;
|
|
189
|
+
/** Namespaced ERC-1155 helpers. */
|
|
190
|
+
declare const erc1155: {
|
|
191
|
+
readonly balanceOf: typeof balanceOf;
|
|
192
|
+
readonly balanceOfBatch: typeof balanceOfBatch;
|
|
193
|
+
readonly uri: typeof uri;
|
|
194
|
+
readonly isApprovedForAll: typeof isApprovedForAll;
|
|
195
|
+
readonly setApprovalForAll: typeof setApprovalForAll;
|
|
196
|
+
readonly safeTransferFrom: typeof safeTransferFrom;
|
|
197
|
+
readonly safeBatchTransferFrom: typeof safeBatchTransferFrom;
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Fee estimation conveniences over viem.
|
|
202
|
+
*
|
|
203
|
+
* {@link estimateEip1559Fees} wraps viem's `estimateFeesPerGas` to return the
|
|
204
|
+
* EIP-1559 `maxFeePerGas` / `maxPriorityFeePerGas` pair; {@link gasPrice} is a
|
|
205
|
+
* legacy helper returning a single gas price. Both take a viem `PublicClient`.
|
|
206
|
+
*/
|
|
207
|
+
|
|
208
|
+
/** EIP-1559 fee suggestion. */
|
|
209
|
+
interface Eip1559Fees {
|
|
210
|
+
/** Maximum total fee per gas (base + priority). */
|
|
211
|
+
maxFeePerGas: bigint;
|
|
212
|
+
/** Maximum priority (miner tip) fee per gas. */
|
|
213
|
+
maxPriorityFeePerGas: bigint;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Suggest EIP-1559 fees from the network, via viem's `estimateFeesPerGas`.
|
|
217
|
+
*
|
|
218
|
+
* @returns `{ maxFeePerGas, maxPriorityFeePerGas }`.
|
|
219
|
+
*/
|
|
220
|
+
declare function estimateEip1559Fees(client: PublicClient): Promise<Eip1559Fees>;
|
|
221
|
+
/** Legacy (pre-EIP-1559) gas price via viem's `getGasPrice`. */
|
|
222
|
+
declare function gasPrice(client: PublicClient): Promise<bigint>;
|
|
223
|
+
/** Namespaced fee helpers. */
|
|
224
|
+
declare const fees: {
|
|
225
|
+
readonly estimateEip1559Fees: typeof estimateEip1559Fees;
|
|
226
|
+
readonly gasPrice: typeof gasPrice;
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Thin contract deploy/call wrappers over viem that default to the QoreChain
|
|
231
|
+
* chain bound on the supplied client. These exist so the common cases need no
|
|
232
|
+
* extra `chain`/`account` plumbing; for advanced use, call viem directly.
|
|
233
|
+
*/
|
|
234
|
+
|
|
235
|
+
/** Arguments for {@link deployContract}. */
|
|
236
|
+
interface DeployContractArgs {
|
|
237
|
+
/** Contract ABI (used for typed constructor args). */
|
|
238
|
+
abi: Abi;
|
|
239
|
+
/** Creation bytecode (`0x`-prefixed). */
|
|
240
|
+
bytecode: Hex;
|
|
241
|
+
/** Constructor arguments, if any. */
|
|
242
|
+
args?: readonly unknown[];
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Deploy a contract using the wallet client's bound account and chain.
|
|
246
|
+
* Returns the deployment transaction hash.
|
|
247
|
+
*/
|
|
248
|
+
declare function deployContract(client: WalletClient, { abi, bytecode, args }: DeployContractArgs): Promise<Hash>;
|
|
249
|
+
/**
|
|
250
|
+
* Typed `readContract` passthrough. Defaults nothing beyond viem; provided so
|
|
251
|
+
* callers can stay on a single import surface.
|
|
252
|
+
*/
|
|
253
|
+
declare function readContract(client: PublicClient, params: Parameters<PublicClient["readContract"]>[0]): ReturnType<PublicClient["readContract"]>;
|
|
254
|
+
/**
|
|
255
|
+
* Typed `writeContract` wrapper that defaults `account` and `chain` from the
|
|
256
|
+
* wallet client when the caller omits them.
|
|
257
|
+
*/
|
|
258
|
+
declare function writeContract(client: WalletClient, params: Parameters<WalletClient["writeContract"]>[0]): Promise<Hash>;
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Typed bindings for QoreChain's EVM precompiles — the headline capability of
|
|
262
|
+
* the QoreChain EVM Engine. Each helper issues an `eth_call` against the fixed
|
|
263
|
+
* precompile address using the corresponding bundled interface ABI.
|
|
264
|
+
*
|
|
265
|
+
* Availability note: on a default or community node these precompiles may return
|
|
266
|
+
* a "not available" error; they are available on QoreChain network nodes. Handle
|
|
267
|
+
* a thrown error from any of these helpers as "feature not present on this node".
|
|
268
|
+
*/
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* Fixed 20-byte precompile addresses (zero-padded), matching the chain's
|
|
272
|
+
* published interface registrations.
|
|
273
|
+
*/
|
|
274
|
+
declare const PRECOMPILE_ADDRESSES: {
|
|
275
|
+
/** CrossVM Bridge precompile. */
|
|
276
|
+
readonly crossVmBridge: "0x0000000000000000000000000000000000000901";
|
|
277
|
+
/** PQC signature verification (`IQorePQC.pqcVerify`). */
|
|
278
|
+
readonly pqcVerify: "0x0000000000000000000000000000000000000A01";
|
|
279
|
+
/** PQC key registration status (`IQorePQC.pqcKeyStatus`). */
|
|
280
|
+
readonly pqcKeyStatus: "0x0000000000000000000000000000000000000A02";
|
|
281
|
+
/** AI transaction risk score (`IQoreAI.aiRiskScore`). */
|
|
282
|
+
readonly aiRiskScore: "0x0000000000000000000000000000000000000B01";
|
|
283
|
+
/** AI anomaly check (`IQoreAI.aiAnomalyCheck`). */
|
|
284
|
+
readonly aiAnomalyCheck: "0x0000000000000000000000000000000000000B02";
|
|
285
|
+
/** Consensus parameters (`IQoreConsensus.rlConsensusParams`). */
|
|
286
|
+
readonly rlConsensusParams: "0x0000000000000000000000000000000000000C01";
|
|
287
|
+
};
|
|
288
|
+
/** Arguments for {@link pqcVerify}. */
|
|
289
|
+
interface PqcVerifyArgs {
|
|
290
|
+
pubkey: Hex;
|
|
291
|
+
signature: Hex;
|
|
292
|
+
message: Hex;
|
|
293
|
+
}
|
|
294
|
+
/** Verify a post-quantum signature on-chain. Returns `true` when valid. */
|
|
295
|
+
declare function pqcVerify(client: PublicClient, { pubkey, signature, message }: PqcVerifyArgs): Promise<boolean>;
|
|
296
|
+
/** Result of {@link pqcKeyStatus}. */
|
|
297
|
+
interface PqcKeyStatus {
|
|
298
|
+
registered: boolean;
|
|
299
|
+
algorithmId: number;
|
|
300
|
+
pubkey: Hex;
|
|
301
|
+
}
|
|
302
|
+
/** Query the on-chain post-quantum key registration status for an account. */
|
|
303
|
+
declare function pqcKeyStatus(client: PublicClient, account: Address): Promise<PqcKeyStatus>;
|
|
304
|
+
/** Result of {@link aiRiskScore}. */
|
|
305
|
+
interface AiRiskScore {
|
|
306
|
+
score: bigint;
|
|
307
|
+
level: number;
|
|
308
|
+
}
|
|
309
|
+
/** Compute an on-chain risk score for raw transaction data. */
|
|
310
|
+
declare function aiRiskScore(client: PublicClient, txData: Hex): Promise<AiRiskScore>;
|
|
311
|
+
/** Arguments for {@link aiAnomalyCheck}. */
|
|
312
|
+
interface AiAnomalyCheckArgs {
|
|
313
|
+
sender: Address;
|
|
314
|
+
amount: bigint;
|
|
315
|
+
}
|
|
316
|
+
/** Result of {@link aiAnomalyCheck}. */
|
|
317
|
+
interface AiAnomalyCheck {
|
|
318
|
+
anomalyScore: bigint;
|
|
319
|
+
flagged: boolean;
|
|
320
|
+
}
|
|
321
|
+
/** Check whether a (sender, amount) pair is anomalous. */
|
|
322
|
+
declare function aiAnomalyCheck(client: PublicClient, { sender, amount }: AiAnomalyCheckArgs): Promise<AiAnomalyCheck>;
|
|
323
|
+
/** Result of {@link rlConsensusParams}. */
|
|
324
|
+
interface ConsensusParams {
|
|
325
|
+
blockTime: bigint;
|
|
326
|
+
baseGasPrice: bigint;
|
|
327
|
+
validatorSetSize: bigint;
|
|
328
|
+
epoch: bigint;
|
|
329
|
+
}
|
|
330
|
+
/** Read the live, adaptively-tuned consensus parameters. */
|
|
331
|
+
declare function rlConsensusParams(client: PublicClient): Promise<ConsensusParams>;
|
|
332
|
+
/** Namespaced precompile helpers. */
|
|
333
|
+
declare const precompiles: {
|
|
334
|
+
readonly pqcVerify: typeof pqcVerify;
|
|
335
|
+
readonly pqcKeyStatus: typeof pqcKeyStatus;
|
|
336
|
+
readonly aiRiskScore: typeof aiRiskScore;
|
|
337
|
+
readonly aiAnomalyCheck: typeof aiAnomalyCheck;
|
|
338
|
+
readonly rlConsensusParams: typeof rlConsensusParams;
|
|
339
|
+
};
|
|
340
|
+
|
|
341
|
+
/**
|
|
342
|
+
* Bundled ABIs used by the QoreChain EVM adapter.
|
|
343
|
+
*
|
|
344
|
+
* These are declared `as const` so viem can infer fully typed argument and
|
|
345
|
+
* return types from them. The QoreChain precompile ABIs mirror the chain's
|
|
346
|
+
* published Solidity interfaces exactly.
|
|
347
|
+
*/
|
|
348
|
+
/** Minimal ERC-20 ABI covering the helpers this package exposes. */
|
|
349
|
+
declare const ERC20_ABI: readonly [{
|
|
350
|
+
readonly type: "function";
|
|
351
|
+
readonly name: "name";
|
|
352
|
+
readonly stateMutability: "view";
|
|
353
|
+
readonly inputs: readonly [];
|
|
354
|
+
readonly outputs: readonly [{
|
|
355
|
+
readonly name: "";
|
|
356
|
+
readonly type: "string";
|
|
357
|
+
}];
|
|
358
|
+
}, {
|
|
359
|
+
readonly type: "function";
|
|
360
|
+
readonly name: "symbol";
|
|
361
|
+
readonly stateMutability: "view";
|
|
362
|
+
readonly inputs: readonly [];
|
|
363
|
+
readonly outputs: readonly [{
|
|
364
|
+
readonly name: "";
|
|
365
|
+
readonly type: "string";
|
|
366
|
+
}];
|
|
367
|
+
}, {
|
|
368
|
+
readonly type: "function";
|
|
369
|
+
readonly name: "decimals";
|
|
370
|
+
readonly stateMutability: "view";
|
|
371
|
+
readonly inputs: readonly [];
|
|
372
|
+
readonly outputs: readonly [{
|
|
373
|
+
readonly name: "";
|
|
374
|
+
readonly type: "uint8";
|
|
375
|
+
}];
|
|
376
|
+
}, {
|
|
377
|
+
readonly type: "function";
|
|
378
|
+
readonly name: "totalSupply";
|
|
379
|
+
readonly stateMutability: "view";
|
|
380
|
+
readonly inputs: readonly [];
|
|
381
|
+
readonly outputs: readonly [{
|
|
382
|
+
readonly name: "";
|
|
383
|
+
readonly type: "uint256";
|
|
384
|
+
}];
|
|
385
|
+
}, {
|
|
386
|
+
readonly type: "function";
|
|
387
|
+
readonly name: "balanceOf";
|
|
388
|
+
readonly stateMutability: "view";
|
|
389
|
+
readonly inputs: readonly [{
|
|
390
|
+
readonly name: "account";
|
|
391
|
+
readonly type: "address";
|
|
392
|
+
}];
|
|
393
|
+
readonly outputs: readonly [{
|
|
394
|
+
readonly name: "";
|
|
395
|
+
readonly type: "uint256";
|
|
396
|
+
}];
|
|
397
|
+
}, {
|
|
398
|
+
readonly type: "function";
|
|
399
|
+
readonly name: "allowance";
|
|
400
|
+
readonly stateMutability: "view";
|
|
401
|
+
readonly inputs: readonly [{
|
|
402
|
+
readonly name: "owner";
|
|
403
|
+
readonly type: "address";
|
|
404
|
+
}, {
|
|
405
|
+
readonly name: "spender";
|
|
406
|
+
readonly type: "address";
|
|
407
|
+
}];
|
|
408
|
+
readonly outputs: readonly [{
|
|
409
|
+
readonly name: "";
|
|
410
|
+
readonly type: "uint256";
|
|
411
|
+
}];
|
|
412
|
+
}, {
|
|
413
|
+
readonly type: "function";
|
|
414
|
+
readonly name: "transfer";
|
|
415
|
+
readonly stateMutability: "nonpayable";
|
|
416
|
+
readonly inputs: readonly [{
|
|
417
|
+
readonly name: "to";
|
|
418
|
+
readonly type: "address";
|
|
419
|
+
}, {
|
|
420
|
+
readonly name: "amount";
|
|
421
|
+
readonly type: "uint256";
|
|
422
|
+
}];
|
|
423
|
+
readonly outputs: readonly [{
|
|
424
|
+
readonly name: "";
|
|
425
|
+
readonly type: "bool";
|
|
426
|
+
}];
|
|
427
|
+
}, {
|
|
428
|
+
readonly type: "function";
|
|
429
|
+
readonly name: "approve";
|
|
430
|
+
readonly stateMutability: "nonpayable";
|
|
431
|
+
readonly inputs: readonly [{
|
|
432
|
+
readonly name: "spender";
|
|
433
|
+
readonly type: "address";
|
|
434
|
+
}, {
|
|
435
|
+
readonly name: "amount";
|
|
436
|
+
readonly type: "uint256";
|
|
437
|
+
}];
|
|
438
|
+
readonly outputs: readonly [{
|
|
439
|
+
readonly name: "";
|
|
440
|
+
readonly type: "bool";
|
|
441
|
+
}];
|
|
442
|
+
}, {
|
|
443
|
+
readonly type: "event";
|
|
444
|
+
readonly name: "Transfer";
|
|
445
|
+
readonly inputs: readonly [{
|
|
446
|
+
readonly indexed: true;
|
|
447
|
+
readonly name: "from";
|
|
448
|
+
readonly type: "address";
|
|
449
|
+
}, {
|
|
450
|
+
readonly indexed: true;
|
|
451
|
+
readonly name: "to";
|
|
452
|
+
readonly type: "address";
|
|
453
|
+
}, {
|
|
454
|
+
readonly indexed: false;
|
|
455
|
+
readonly name: "value";
|
|
456
|
+
readonly type: "uint256";
|
|
457
|
+
}];
|
|
458
|
+
}, {
|
|
459
|
+
readonly type: "event";
|
|
460
|
+
readonly name: "Approval";
|
|
461
|
+
readonly inputs: readonly [{
|
|
462
|
+
readonly indexed: true;
|
|
463
|
+
readonly name: "owner";
|
|
464
|
+
readonly type: "address";
|
|
465
|
+
}, {
|
|
466
|
+
readonly indexed: true;
|
|
467
|
+
readonly name: "spender";
|
|
468
|
+
readonly type: "address";
|
|
469
|
+
}, {
|
|
470
|
+
readonly indexed: false;
|
|
471
|
+
readonly name: "value";
|
|
472
|
+
readonly type: "uint256";
|
|
473
|
+
}];
|
|
474
|
+
}];
|
|
475
|
+
/** Minimal ERC-721 ABI covering the helpers this package exposes. */
|
|
476
|
+
declare const ERC721_ABI: readonly [{
|
|
477
|
+
readonly type: "function";
|
|
478
|
+
readonly name: "name";
|
|
479
|
+
readonly stateMutability: "view";
|
|
480
|
+
readonly inputs: readonly [];
|
|
481
|
+
readonly outputs: readonly [{
|
|
482
|
+
readonly name: "";
|
|
483
|
+
readonly type: "string";
|
|
484
|
+
}];
|
|
485
|
+
}, {
|
|
486
|
+
readonly type: "function";
|
|
487
|
+
readonly name: "symbol";
|
|
488
|
+
readonly stateMutability: "view";
|
|
489
|
+
readonly inputs: readonly [];
|
|
490
|
+
readonly outputs: readonly [{
|
|
491
|
+
readonly name: "";
|
|
492
|
+
readonly type: "string";
|
|
493
|
+
}];
|
|
494
|
+
}, {
|
|
495
|
+
readonly type: "function";
|
|
496
|
+
readonly name: "balanceOf";
|
|
497
|
+
readonly stateMutability: "view";
|
|
498
|
+
readonly inputs: readonly [{
|
|
499
|
+
readonly name: "owner";
|
|
500
|
+
readonly type: "address";
|
|
501
|
+
}];
|
|
502
|
+
readonly outputs: readonly [{
|
|
503
|
+
readonly name: "";
|
|
504
|
+
readonly type: "uint256";
|
|
505
|
+
}];
|
|
506
|
+
}, {
|
|
507
|
+
readonly type: "function";
|
|
508
|
+
readonly name: "ownerOf";
|
|
509
|
+
readonly stateMutability: "view";
|
|
510
|
+
readonly inputs: readonly [{
|
|
511
|
+
readonly name: "tokenId";
|
|
512
|
+
readonly type: "uint256";
|
|
513
|
+
}];
|
|
514
|
+
readonly outputs: readonly [{
|
|
515
|
+
readonly name: "";
|
|
516
|
+
readonly type: "address";
|
|
517
|
+
}];
|
|
518
|
+
}, {
|
|
519
|
+
readonly type: "function";
|
|
520
|
+
readonly name: "tokenURI";
|
|
521
|
+
readonly stateMutability: "view";
|
|
522
|
+
readonly inputs: readonly [{
|
|
523
|
+
readonly name: "tokenId";
|
|
524
|
+
readonly type: "uint256";
|
|
525
|
+
}];
|
|
526
|
+
readonly outputs: readonly [{
|
|
527
|
+
readonly name: "";
|
|
528
|
+
readonly type: "string";
|
|
529
|
+
}];
|
|
530
|
+
}, {
|
|
531
|
+
readonly type: "function";
|
|
532
|
+
readonly name: "getApproved";
|
|
533
|
+
readonly stateMutability: "view";
|
|
534
|
+
readonly inputs: readonly [{
|
|
535
|
+
readonly name: "tokenId";
|
|
536
|
+
readonly type: "uint256";
|
|
537
|
+
}];
|
|
538
|
+
readonly outputs: readonly [{
|
|
539
|
+
readonly name: "";
|
|
540
|
+
readonly type: "address";
|
|
541
|
+
}];
|
|
542
|
+
}, {
|
|
543
|
+
readonly type: "function";
|
|
544
|
+
readonly name: "isApprovedForAll";
|
|
545
|
+
readonly stateMutability: "view";
|
|
546
|
+
readonly inputs: readonly [{
|
|
547
|
+
readonly name: "owner";
|
|
548
|
+
readonly type: "address";
|
|
549
|
+
}, {
|
|
550
|
+
readonly name: "operator";
|
|
551
|
+
readonly type: "address";
|
|
552
|
+
}];
|
|
553
|
+
readonly outputs: readonly [{
|
|
554
|
+
readonly name: "";
|
|
555
|
+
readonly type: "bool";
|
|
556
|
+
}];
|
|
557
|
+
}, {
|
|
558
|
+
readonly type: "function";
|
|
559
|
+
readonly name: "approve";
|
|
560
|
+
readonly stateMutability: "nonpayable";
|
|
561
|
+
readonly inputs: readonly [{
|
|
562
|
+
readonly name: "to";
|
|
563
|
+
readonly type: "address";
|
|
564
|
+
}, {
|
|
565
|
+
readonly name: "tokenId";
|
|
566
|
+
readonly type: "uint256";
|
|
567
|
+
}];
|
|
568
|
+
readonly outputs: readonly [];
|
|
569
|
+
}, {
|
|
570
|
+
readonly type: "function";
|
|
571
|
+
readonly name: "setApprovalForAll";
|
|
572
|
+
readonly stateMutability: "nonpayable";
|
|
573
|
+
readonly inputs: readonly [{
|
|
574
|
+
readonly name: "operator";
|
|
575
|
+
readonly type: "address";
|
|
576
|
+
}, {
|
|
577
|
+
readonly name: "approved";
|
|
578
|
+
readonly type: "bool";
|
|
579
|
+
}];
|
|
580
|
+
readonly outputs: readonly [];
|
|
581
|
+
}, {
|
|
582
|
+
readonly type: "function";
|
|
583
|
+
readonly name: "transferFrom";
|
|
584
|
+
readonly stateMutability: "nonpayable";
|
|
585
|
+
readonly inputs: readonly [{
|
|
586
|
+
readonly name: "from";
|
|
587
|
+
readonly type: "address";
|
|
588
|
+
}, {
|
|
589
|
+
readonly name: "to";
|
|
590
|
+
readonly type: "address";
|
|
591
|
+
}, {
|
|
592
|
+
readonly name: "tokenId";
|
|
593
|
+
readonly type: "uint256";
|
|
594
|
+
}];
|
|
595
|
+
readonly outputs: readonly [];
|
|
596
|
+
}, {
|
|
597
|
+
readonly type: "function";
|
|
598
|
+
readonly name: "safeTransferFrom";
|
|
599
|
+
readonly stateMutability: "nonpayable";
|
|
600
|
+
readonly inputs: readonly [{
|
|
601
|
+
readonly name: "from";
|
|
602
|
+
readonly type: "address";
|
|
603
|
+
}, {
|
|
604
|
+
readonly name: "to";
|
|
605
|
+
readonly type: "address";
|
|
606
|
+
}, {
|
|
607
|
+
readonly name: "tokenId";
|
|
608
|
+
readonly type: "uint256";
|
|
609
|
+
}];
|
|
610
|
+
readonly outputs: readonly [];
|
|
611
|
+
}, {
|
|
612
|
+
readonly type: "function";
|
|
613
|
+
readonly name: "safeTransferFrom";
|
|
614
|
+
readonly stateMutability: "nonpayable";
|
|
615
|
+
readonly inputs: readonly [{
|
|
616
|
+
readonly name: "from";
|
|
617
|
+
readonly type: "address";
|
|
618
|
+
}, {
|
|
619
|
+
readonly name: "to";
|
|
620
|
+
readonly type: "address";
|
|
621
|
+
}, {
|
|
622
|
+
readonly name: "tokenId";
|
|
623
|
+
readonly type: "uint256";
|
|
624
|
+
}, {
|
|
625
|
+
readonly name: "data";
|
|
626
|
+
readonly type: "bytes";
|
|
627
|
+
}];
|
|
628
|
+
readonly outputs: readonly [];
|
|
629
|
+
}, {
|
|
630
|
+
readonly type: "event";
|
|
631
|
+
readonly name: "Transfer";
|
|
632
|
+
readonly inputs: readonly [{
|
|
633
|
+
readonly indexed: true;
|
|
634
|
+
readonly name: "from";
|
|
635
|
+
readonly type: "address";
|
|
636
|
+
}, {
|
|
637
|
+
readonly indexed: true;
|
|
638
|
+
readonly name: "to";
|
|
639
|
+
readonly type: "address";
|
|
640
|
+
}, {
|
|
641
|
+
readonly indexed: true;
|
|
642
|
+
readonly name: "tokenId";
|
|
643
|
+
readonly type: "uint256";
|
|
644
|
+
}];
|
|
645
|
+
}, {
|
|
646
|
+
readonly type: "event";
|
|
647
|
+
readonly name: "Approval";
|
|
648
|
+
readonly inputs: readonly [{
|
|
649
|
+
readonly indexed: true;
|
|
650
|
+
readonly name: "owner";
|
|
651
|
+
readonly type: "address";
|
|
652
|
+
}, {
|
|
653
|
+
readonly indexed: true;
|
|
654
|
+
readonly name: "approved";
|
|
655
|
+
readonly type: "address";
|
|
656
|
+
}, {
|
|
657
|
+
readonly indexed: true;
|
|
658
|
+
readonly name: "tokenId";
|
|
659
|
+
readonly type: "uint256";
|
|
660
|
+
}];
|
|
661
|
+
}, {
|
|
662
|
+
readonly type: "event";
|
|
663
|
+
readonly name: "ApprovalForAll";
|
|
664
|
+
readonly inputs: readonly [{
|
|
665
|
+
readonly indexed: true;
|
|
666
|
+
readonly name: "owner";
|
|
667
|
+
readonly type: "address";
|
|
668
|
+
}, {
|
|
669
|
+
readonly indexed: true;
|
|
670
|
+
readonly name: "operator";
|
|
671
|
+
readonly type: "address";
|
|
672
|
+
}, {
|
|
673
|
+
readonly indexed: false;
|
|
674
|
+
readonly name: "approved";
|
|
675
|
+
readonly type: "bool";
|
|
676
|
+
}];
|
|
677
|
+
}];
|
|
678
|
+
/** Minimal ERC-1155 ABI covering the helpers this package exposes. */
|
|
679
|
+
declare const ERC1155_ABI: readonly [{
|
|
680
|
+
readonly type: "function";
|
|
681
|
+
readonly name: "balanceOf";
|
|
682
|
+
readonly stateMutability: "view";
|
|
683
|
+
readonly inputs: readonly [{
|
|
684
|
+
readonly name: "account";
|
|
685
|
+
readonly type: "address";
|
|
686
|
+
}, {
|
|
687
|
+
readonly name: "id";
|
|
688
|
+
readonly type: "uint256";
|
|
689
|
+
}];
|
|
690
|
+
readonly outputs: readonly [{
|
|
691
|
+
readonly name: "";
|
|
692
|
+
readonly type: "uint256";
|
|
693
|
+
}];
|
|
694
|
+
}, {
|
|
695
|
+
readonly type: "function";
|
|
696
|
+
readonly name: "balanceOfBatch";
|
|
697
|
+
readonly stateMutability: "view";
|
|
698
|
+
readonly inputs: readonly [{
|
|
699
|
+
readonly name: "accounts";
|
|
700
|
+
readonly type: "address[]";
|
|
701
|
+
}, {
|
|
702
|
+
readonly name: "ids";
|
|
703
|
+
readonly type: "uint256[]";
|
|
704
|
+
}];
|
|
705
|
+
readonly outputs: readonly [{
|
|
706
|
+
readonly name: "";
|
|
707
|
+
readonly type: "uint256[]";
|
|
708
|
+
}];
|
|
709
|
+
}, {
|
|
710
|
+
readonly type: "function";
|
|
711
|
+
readonly name: "uri";
|
|
712
|
+
readonly stateMutability: "view";
|
|
713
|
+
readonly inputs: readonly [{
|
|
714
|
+
readonly name: "id";
|
|
715
|
+
readonly type: "uint256";
|
|
716
|
+
}];
|
|
717
|
+
readonly outputs: readonly [{
|
|
718
|
+
readonly name: "";
|
|
719
|
+
readonly type: "string";
|
|
720
|
+
}];
|
|
721
|
+
}, {
|
|
722
|
+
readonly type: "function";
|
|
723
|
+
readonly name: "isApprovedForAll";
|
|
724
|
+
readonly stateMutability: "view";
|
|
725
|
+
readonly inputs: readonly [{
|
|
726
|
+
readonly name: "account";
|
|
727
|
+
readonly type: "address";
|
|
728
|
+
}, {
|
|
729
|
+
readonly name: "operator";
|
|
730
|
+
readonly type: "address";
|
|
731
|
+
}];
|
|
732
|
+
readonly outputs: readonly [{
|
|
733
|
+
readonly name: "";
|
|
734
|
+
readonly type: "bool";
|
|
735
|
+
}];
|
|
736
|
+
}, {
|
|
737
|
+
readonly type: "function";
|
|
738
|
+
readonly name: "setApprovalForAll";
|
|
739
|
+
readonly stateMutability: "nonpayable";
|
|
740
|
+
readonly inputs: readonly [{
|
|
741
|
+
readonly name: "operator";
|
|
742
|
+
readonly type: "address";
|
|
743
|
+
}, {
|
|
744
|
+
readonly name: "approved";
|
|
745
|
+
readonly type: "bool";
|
|
746
|
+
}];
|
|
747
|
+
readonly outputs: readonly [];
|
|
748
|
+
}, {
|
|
749
|
+
readonly type: "function";
|
|
750
|
+
readonly name: "safeTransferFrom";
|
|
751
|
+
readonly stateMutability: "nonpayable";
|
|
752
|
+
readonly inputs: readonly [{
|
|
753
|
+
readonly name: "from";
|
|
754
|
+
readonly type: "address";
|
|
755
|
+
}, {
|
|
756
|
+
readonly name: "to";
|
|
757
|
+
readonly type: "address";
|
|
758
|
+
}, {
|
|
759
|
+
readonly name: "id";
|
|
760
|
+
readonly type: "uint256";
|
|
761
|
+
}, {
|
|
762
|
+
readonly name: "amount";
|
|
763
|
+
readonly type: "uint256";
|
|
764
|
+
}, {
|
|
765
|
+
readonly name: "data";
|
|
766
|
+
readonly type: "bytes";
|
|
767
|
+
}];
|
|
768
|
+
readonly outputs: readonly [];
|
|
769
|
+
}, {
|
|
770
|
+
readonly type: "function";
|
|
771
|
+
readonly name: "safeBatchTransferFrom";
|
|
772
|
+
readonly stateMutability: "nonpayable";
|
|
773
|
+
readonly inputs: readonly [{
|
|
774
|
+
readonly name: "from";
|
|
775
|
+
readonly type: "address";
|
|
776
|
+
}, {
|
|
777
|
+
readonly name: "to";
|
|
778
|
+
readonly type: "address";
|
|
779
|
+
}, {
|
|
780
|
+
readonly name: "ids";
|
|
781
|
+
readonly type: "uint256[]";
|
|
782
|
+
}, {
|
|
783
|
+
readonly name: "amounts";
|
|
784
|
+
readonly type: "uint256[]";
|
|
785
|
+
}, {
|
|
786
|
+
readonly name: "data";
|
|
787
|
+
readonly type: "bytes";
|
|
788
|
+
}];
|
|
789
|
+
readonly outputs: readonly [];
|
|
790
|
+
}, {
|
|
791
|
+
readonly type: "event";
|
|
792
|
+
readonly name: "TransferSingle";
|
|
793
|
+
readonly inputs: readonly [{
|
|
794
|
+
readonly indexed: true;
|
|
795
|
+
readonly name: "operator";
|
|
796
|
+
readonly type: "address";
|
|
797
|
+
}, {
|
|
798
|
+
readonly indexed: true;
|
|
799
|
+
readonly name: "from";
|
|
800
|
+
readonly type: "address";
|
|
801
|
+
}, {
|
|
802
|
+
readonly indexed: true;
|
|
803
|
+
readonly name: "to";
|
|
804
|
+
readonly type: "address";
|
|
805
|
+
}, {
|
|
806
|
+
readonly indexed: false;
|
|
807
|
+
readonly name: "id";
|
|
808
|
+
readonly type: "uint256";
|
|
809
|
+
}, {
|
|
810
|
+
readonly indexed: false;
|
|
811
|
+
readonly name: "value";
|
|
812
|
+
readonly type: "uint256";
|
|
813
|
+
}];
|
|
814
|
+
}, {
|
|
815
|
+
readonly type: "event";
|
|
816
|
+
readonly name: "ApprovalForAll";
|
|
817
|
+
readonly inputs: readonly [{
|
|
818
|
+
readonly indexed: true;
|
|
819
|
+
readonly name: "account";
|
|
820
|
+
readonly type: "address";
|
|
821
|
+
}, {
|
|
822
|
+
readonly indexed: true;
|
|
823
|
+
readonly name: "operator";
|
|
824
|
+
readonly type: "address";
|
|
825
|
+
}, {
|
|
826
|
+
readonly indexed: false;
|
|
827
|
+
readonly name: "approved";
|
|
828
|
+
readonly type: "bool";
|
|
829
|
+
}];
|
|
830
|
+
}];
|
|
831
|
+
/**
|
|
832
|
+
* Post-quantum cryptography precompile interface (`IQorePQC`).
|
|
833
|
+
*
|
|
834
|
+
* Exposes signature verification and on-chain key registration status for
|
|
835
|
+
* QoreChain's quantum-resistant key material (Dilithium / ML-DSA family).
|
|
836
|
+
*/
|
|
837
|
+
declare const IQORE_PQC_ABI: readonly [{
|
|
838
|
+
readonly type: "function";
|
|
839
|
+
readonly name: "pqcVerify";
|
|
840
|
+
readonly stateMutability: "view";
|
|
841
|
+
readonly inputs: readonly [{
|
|
842
|
+
readonly name: "pubkey";
|
|
843
|
+
readonly type: "bytes";
|
|
844
|
+
}, {
|
|
845
|
+
readonly name: "signature";
|
|
846
|
+
readonly type: "bytes";
|
|
847
|
+
}, {
|
|
848
|
+
readonly name: "message";
|
|
849
|
+
readonly type: "bytes";
|
|
850
|
+
}];
|
|
851
|
+
readonly outputs: readonly [{
|
|
852
|
+
readonly name: "valid";
|
|
853
|
+
readonly type: "bool";
|
|
854
|
+
}];
|
|
855
|
+
}, {
|
|
856
|
+
readonly type: "function";
|
|
857
|
+
readonly name: "pqcKeyStatus";
|
|
858
|
+
readonly stateMutability: "view";
|
|
859
|
+
readonly inputs: readonly [{
|
|
860
|
+
readonly name: "account";
|
|
861
|
+
readonly type: "address";
|
|
862
|
+
}];
|
|
863
|
+
readonly outputs: readonly [{
|
|
864
|
+
readonly name: "registered";
|
|
865
|
+
readonly type: "bool";
|
|
866
|
+
}, {
|
|
867
|
+
readonly name: "algorithmId";
|
|
868
|
+
readonly type: "uint8";
|
|
869
|
+
}, {
|
|
870
|
+
readonly name: "pubkey";
|
|
871
|
+
readonly type: "bytes";
|
|
872
|
+
}];
|
|
873
|
+
}];
|
|
874
|
+
/**
|
|
875
|
+
* On-chain risk/anomaly intelligence precompile interface (`IQoreAI`).
|
|
876
|
+
*/
|
|
877
|
+
declare const IQORE_AI_ABI: readonly [{
|
|
878
|
+
readonly type: "function";
|
|
879
|
+
readonly name: "aiRiskScore";
|
|
880
|
+
readonly stateMutability: "view";
|
|
881
|
+
readonly inputs: readonly [{
|
|
882
|
+
readonly name: "txData";
|
|
883
|
+
readonly type: "bytes";
|
|
884
|
+
}];
|
|
885
|
+
readonly outputs: readonly [{
|
|
886
|
+
readonly name: "score";
|
|
887
|
+
readonly type: "uint256";
|
|
888
|
+
}, {
|
|
889
|
+
readonly name: "level";
|
|
890
|
+
readonly type: "uint8";
|
|
891
|
+
}];
|
|
892
|
+
}, {
|
|
893
|
+
readonly type: "function";
|
|
894
|
+
readonly name: "aiAnomalyCheck";
|
|
895
|
+
readonly stateMutability: "view";
|
|
896
|
+
readonly inputs: readonly [{
|
|
897
|
+
readonly name: "sender";
|
|
898
|
+
readonly type: "address";
|
|
899
|
+
}, {
|
|
900
|
+
readonly name: "amount";
|
|
901
|
+
readonly type: "uint256";
|
|
902
|
+
}];
|
|
903
|
+
readonly outputs: readonly [{
|
|
904
|
+
readonly name: "anomalyScore";
|
|
905
|
+
readonly type: "uint256";
|
|
906
|
+
}, {
|
|
907
|
+
readonly name: "flagged";
|
|
908
|
+
readonly type: "bool";
|
|
909
|
+
}];
|
|
910
|
+
}];
|
|
911
|
+
/**
|
|
912
|
+
* Consensus parameters precompile interface (`IQoreConsensus`).
|
|
913
|
+
*
|
|
914
|
+
* Surfaces live, adaptively-tuned consensus parameters from the network.
|
|
915
|
+
*/
|
|
916
|
+
declare const IQORE_CONSENSUS_ABI: readonly [{
|
|
917
|
+
readonly type: "function";
|
|
918
|
+
readonly name: "rlConsensusParams";
|
|
919
|
+
readonly stateMutability: "view";
|
|
920
|
+
readonly inputs: readonly [];
|
|
921
|
+
readonly outputs: readonly [{
|
|
922
|
+
readonly name: "blockTime";
|
|
923
|
+
readonly type: "uint256";
|
|
924
|
+
}, {
|
|
925
|
+
readonly name: "baseGasPrice";
|
|
926
|
+
readonly type: "uint256";
|
|
927
|
+
}, {
|
|
928
|
+
readonly name: "validatorSetSize";
|
|
929
|
+
readonly type: "uint256";
|
|
930
|
+
}, {
|
|
931
|
+
readonly name: "epoch";
|
|
932
|
+
readonly type: "uint256";
|
|
933
|
+
}];
|
|
934
|
+
}];
|
|
935
|
+
|
|
936
|
+
/**
|
|
937
|
+
* EVM browser-wallet integration for QoreChain (MetaMask and any EIP-1193
|
|
938
|
+
* provider, with optional EIP-6963 multi-wallet discovery).
|
|
939
|
+
*
|
|
940
|
+
* Builds a viem `WalletClient` over an injected provider so dApps can request
|
|
941
|
+
* accounts, add/switch the QoreChain EVM network, and sign + send transactions.
|
|
942
|
+
*
|
|
943
|
+
* ```ts
|
|
944
|
+
* import { getEvmWalletClient, addQoreChainNetwork } from "@qorechain/evm";
|
|
945
|
+
* import { getNetwork } from "@qorechain/sdk";
|
|
946
|
+
*
|
|
947
|
+
* await addQoreChainNetwork(window.ethereum, getNetwork("mainnet"));
|
|
948
|
+
* const { walletClient, address } = await getEvmWalletClient();
|
|
949
|
+
* ```
|
|
950
|
+
*/
|
|
951
|
+
|
|
952
|
+
/**
|
|
953
|
+
* The minimal EIP-1193 provider surface used here. Declared structurally so no
|
|
954
|
+
* wallet types package is required; `window.ethereum` is structurally
|
|
955
|
+
* compatible.
|
|
956
|
+
*/
|
|
957
|
+
interface Eip1193Provider {
|
|
958
|
+
request(args: {
|
|
959
|
+
method: string;
|
|
960
|
+
params?: unknown[] | object;
|
|
961
|
+
}): Promise<unknown>;
|
|
962
|
+
on?(event: string, listener: (...args: unknown[]) => void): void;
|
|
963
|
+
removeListener?(event: string, listener: (...args: unknown[]) => void): void;
|
|
964
|
+
}
|
|
965
|
+
/** Subset of a qorechain-sdk network needed to add the EVM chain to a wallet. */
|
|
966
|
+
interface EvmNetworkInfo {
|
|
967
|
+
/** EVM endpoints (`evmRpc`, optional `evmWs`). */
|
|
968
|
+
endpoints: {
|
|
969
|
+
evmRpc: string;
|
|
970
|
+
evmWs?: string;
|
|
971
|
+
};
|
|
972
|
+
/** Display coin info (used for the native currency). */
|
|
973
|
+
coin: {
|
|
974
|
+
display: string;
|
|
975
|
+
};
|
|
976
|
+
}
|
|
977
|
+
/** Options for {@link getEvmWalletClient}. */
|
|
978
|
+
interface GetEvmWalletClientOptions {
|
|
979
|
+
/** The EIP-1193 provider to use. Defaults to `window.ethereum`. */
|
|
980
|
+
provider?: Eip1193Provider;
|
|
981
|
+
/**
|
|
982
|
+
* Numeric EVM chain id. If omitted, it is auto-detected via `eth_chainId` on
|
|
983
|
+
* the connected provider.
|
|
984
|
+
*/
|
|
985
|
+
chainId?: number;
|
|
986
|
+
/** Native currency decimals for the viem chain. Defaults to 18. */
|
|
987
|
+
decimals?: number;
|
|
988
|
+
}
|
|
989
|
+
/** The result of {@link getEvmWalletClient}. */
|
|
990
|
+
interface EvmWalletConnection {
|
|
991
|
+
/** viem wallet client bound to the connected account and chain. */
|
|
992
|
+
walletClient: WalletClient;
|
|
993
|
+
/** The connected (first) account address. */
|
|
994
|
+
address: Address;
|
|
995
|
+
/** The underlying EIP-1193 provider. */
|
|
996
|
+
provider: Eip1193Provider;
|
|
997
|
+
/** The viem `Chain` object describing the connected network. */
|
|
998
|
+
chain: Chain;
|
|
999
|
+
}
|
|
1000
|
+
/** Convert a numeric chain id to its `0x`-prefixed hex form. */
|
|
1001
|
+
declare function toHexChainId(chainId: number): `0x${string}`;
|
|
1002
|
+
/**
|
|
1003
|
+
* Request the provider's accounts via `eth_requestAccounts`.
|
|
1004
|
+
*
|
|
1005
|
+
* @returns The authorized account addresses (the first is the active account).
|
|
1006
|
+
*/
|
|
1007
|
+
declare function requestAccounts(provider: Eip1193Provider): Promise<Address[]>;
|
|
1008
|
+
/**
|
|
1009
|
+
* Add the QoreChain EVM network to the wallet via `wallet_addEthereumChain`.
|
|
1010
|
+
*
|
|
1011
|
+
* The EVM chain id is auto-detected (via `eth_chainId` against the network's
|
|
1012
|
+
* `evmRpc`) unless provided. Native currency is QOR with 18 decimals (the EVM
|
|
1013
|
+
* convention).
|
|
1014
|
+
*/
|
|
1015
|
+
declare function addQoreChainNetwork(provider: Eip1193Provider, network: EvmNetworkInfo, opts?: {
|
|
1016
|
+
chainId?: number;
|
|
1017
|
+
blockExplorerUrl?: string;
|
|
1018
|
+
}): Promise<void>;
|
|
1019
|
+
/**
|
|
1020
|
+
* Switch the wallet to the given EVM chain via `wallet_switchEthereumChain`.
|
|
1021
|
+
*/
|
|
1022
|
+
declare function switchChain(provider: Eip1193Provider, chainId: number): Promise<void>;
|
|
1023
|
+
/**
|
|
1024
|
+
* Connect to an injected EVM wallet and return a viem `WalletClient`.
|
|
1025
|
+
*
|
|
1026
|
+
* Requests accounts (`eth_requestAccounts`), resolves the EVM chain id (supplied
|
|
1027
|
+
* or auto-detected), and builds a wallet client over a viem `custom` transport.
|
|
1028
|
+
*
|
|
1029
|
+
* Browser-only: throws a clear error if no `window` or no injected provider.
|
|
1030
|
+
*/
|
|
1031
|
+
declare function getEvmWalletClient(opts?: GetEvmWalletClientOptions): Promise<EvmWalletConnection>;
|
|
1032
|
+
/** A provider announced via the EIP-6963 discovery protocol. */
|
|
1033
|
+
interface Eip6963ProviderDetail {
|
|
1034
|
+
info: {
|
|
1035
|
+
uuid: string;
|
|
1036
|
+
name: string;
|
|
1037
|
+
icon: string;
|
|
1038
|
+
rdns: string;
|
|
1039
|
+
};
|
|
1040
|
+
provider: Eip1193Provider;
|
|
1041
|
+
}
|
|
1042
|
+
/**
|
|
1043
|
+
* Discover injected EVM providers via EIP-6963 (`eip6963:requestProvider`).
|
|
1044
|
+
*
|
|
1045
|
+
* Returns the providers that announce themselves within `timeoutMs` (default
|
|
1046
|
+
* 200ms). `window.ethereum` remains the baseline default for the other helpers;
|
|
1047
|
+
* use this when you want to let the user pick among multiple installed wallets.
|
|
1048
|
+
*
|
|
1049
|
+
* Resolves to an empty array outside a browser environment.
|
|
1050
|
+
*/
|
|
1051
|
+
declare function discoverEvmProviders(timeoutMs?: number): Promise<Eip6963ProviderDetail[]>;
|
|
1052
|
+
|
|
1053
|
+
/**
|
|
1054
|
+
* Human-readable decoding of EVM execution errors.
|
|
1055
|
+
*
|
|
1056
|
+
* viem throws richly-typed error objects, but the useful detail (a revert
|
|
1057
|
+
* reason, a custom-error name and args, or a low-level RPC message) is often
|
|
1058
|
+
* buried several layers deep in the error's `cause` chain. {@link decodeEvmError}
|
|
1059
|
+
* walks that chain with viem's `BaseError.walk`, decodes custom-error revert
|
|
1060
|
+
* data against an optional ABI via `decodeErrorResult`, and returns a flat,
|
|
1061
|
+
* readable summary.
|
|
1062
|
+
*/
|
|
1063
|
+
|
|
1064
|
+
/** A decoded EVM error. */
|
|
1065
|
+
interface DecodedEvmError {
|
|
1066
|
+
/** A readable summary message. */
|
|
1067
|
+
message: string;
|
|
1068
|
+
/** A short, stable kind discriminator. */
|
|
1069
|
+
kind: "revert" | "custom_error" | "panic" | "rpc" | "execution" | "unknown";
|
|
1070
|
+
/** The custom-error or revert function name, when decoded. */
|
|
1071
|
+
errorName?: string;
|
|
1072
|
+
/** Decoded custom-error arguments, when available. */
|
|
1073
|
+
args?: readonly unknown[];
|
|
1074
|
+
/** The raw revert data, when present. */
|
|
1075
|
+
data?: Hex;
|
|
1076
|
+
}
|
|
1077
|
+
/**
|
|
1078
|
+
* Decode an EVM error thrown by viem into a readable, structured form.
|
|
1079
|
+
*
|
|
1080
|
+
* @param error - The thrown error (a viem `BaseError`, an RPC error, or any value).
|
|
1081
|
+
* @param abi - Optional contract ABI used to decode custom-error revert data.
|
|
1082
|
+
* @returns A {@link DecodedEvmError}.
|
|
1083
|
+
*/
|
|
1084
|
+
declare function decodeEvmError(error: unknown, abi?: Abi): DecodedEvmError;
|
|
1085
|
+
|
|
1086
|
+
/**
|
|
1087
|
+
* Real-time EVM watchers for QoreChain, over a viem websocket transport.
|
|
1088
|
+
*
|
|
1089
|
+
* {@link createEvmSubscriptionClient} builds a viem public client on a
|
|
1090
|
+
* `webSocket` transport pointed at the network's `evmWs` endpoint, and the
|
|
1091
|
+
* `watch*` helpers are thin passthroughs to viem's polling/subscription
|
|
1092
|
+
* watchers scoped to that client. Each returns viem's `unwatch` function.
|
|
1093
|
+
*
|
|
1094
|
+
* These are deliberately minimal: viem owns the subscription lifecycle and
|
|
1095
|
+
* reconnection; this module just wires the QoreChain endpoint and re-exports a
|
|
1096
|
+
* focused surface so callers don't construct the transport themselves.
|
|
1097
|
+
*/
|
|
1098
|
+
|
|
1099
|
+
/** Subset of a qorechain-sdk network's endpoints relevant to EVM subscriptions. */
|
|
1100
|
+
interface EvmWsEndpoints {
|
|
1101
|
+
/** EVM JSON-RPC WebSocket endpoint. */
|
|
1102
|
+
evmWs: string;
|
|
1103
|
+
}
|
|
1104
|
+
/** Options for {@link createEvmSubscriptionClient}. */
|
|
1105
|
+
interface CreateEvmSubscriptionClientOptions {
|
|
1106
|
+
/** EVM websocket URL. Mutually exclusive with `endpoints`. */
|
|
1107
|
+
wsUrl?: string;
|
|
1108
|
+
/** A qorechain-sdk network endpoints object (uses `evmWs`). */
|
|
1109
|
+
endpoints?: EvmWsEndpoints;
|
|
1110
|
+
/** Optional viem `Chain` to bind. */
|
|
1111
|
+
chain?: Chain;
|
|
1112
|
+
/** Custom viem transport (primarily for testing). Overrides `wsUrl`/`endpoints`. */
|
|
1113
|
+
transport?: Transport;
|
|
1114
|
+
}
|
|
1115
|
+
/** A function that stops a watcher. */
|
|
1116
|
+
type Unwatch = () => void;
|
|
1117
|
+
/**
|
|
1118
|
+
* Create a viem public client on a websocket transport for subscriptions.
|
|
1119
|
+
*
|
|
1120
|
+
* The returned client is a standard viem `PublicClient`; the `watch*` helpers in
|
|
1121
|
+
* this module accept it (or any viem public client).
|
|
1122
|
+
*/
|
|
1123
|
+
declare function createEvmSubscriptionClient(opts: CreateEvmSubscriptionClientOptions): PublicClient;
|
|
1124
|
+
/** Watch for new blocks. Returns viem's `unwatch`. */
|
|
1125
|
+
declare function watchBlocks(client: PublicClient, args: WatchBlocksParameters): Unwatch;
|
|
1126
|
+
/** Watch for logs matching an event filter. Returns viem's `unwatch`. */
|
|
1127
|
+
declare function watchEvent(client: PublicClient, args: WatchEventParameters): Unwatch;
|
|
1128
|
+
/** Watch a specific contract's events (decoded). Returns viem's `unwatch`. */
|
|
1129
|
+
declare function watchContractEvent(client: PublicClient, args: WatchContractEventParameters): Unwatch;
|
|
1130
|
+
/** Watch the mempool for pending transaction hashes. Returns viem's `unwatch`. */
|
|
1131
|
+
declare function watchPendingTransactions(client: PublicClient, args: WatchPendingTransactionsParameters): Unwatch;
|
|
1132
|
+
|
|
1133
|
+
/**
|
|
1134
|
+
* `@qorechain/evm` — a thin, type-safe adapter over [viem](https://viem.sh) for
|
|
1135
|
+
* the QoreChain EVM Engine.
|
|
1136
|
+
*
|
|
1137
|
+
* It does not reimplement an EVM client; viem is a peer dependency. This package
|
|
1138
|
+
* adds QoreChain-specific conveniences: a chain-aware client factory with EVM
|
|
1139
|
+
* chain-id auto-detection, ERC-20 helpers, contract deploy/call wrappers, and
|
|
1140
|
+
* typed bindings for QoreChain's EVM precompiles.
|
|
1141
|
+
*/
|
|
1142
|
+
/** Package version. */
|
|
1143
|
+
declare const VERSION = "0.3.0";
|
|
1144
|
+
|
|
1145
|
+
export { type AiAnomalyCheck, type AiAnomalyCheckArgs, type AiRiskScore, type ConsensusParams, type CreateEvmClientOptions, type CreateEvmSubscriptionClientOptions, type DecodedEvmError, type DeployContractArgs, ERC1155_ABI, ERC20_ABI, ERC721_ABI, type Eip1193Provider, type Eip1559Fees, type Eip6963ProviderDetail, type Erc20Metadata, type Erc721Metadata, type EvmClient, type EvmEndpoints, type EvmNetworkInfo, type EvmWalletConnection, type EvmWsEndpoints, type GetEvmWalletClientOptions, IQORE_AI_ABI, IQORE_CONSENSUS_ABI, IQORE_PQC_ABI, PRECOMPILE_ADDRESSES, type PqcKeyStatus, type PqcVerifyArgs, type Unwatch, VERSION, addQoreChainNetwork, aiAnomalyCheck, aiRiskScore, allowance, approve$1 as approve, balanceOf$2 as balanceOf, createEvmClient, createEvmSubscriptionClient, decodeEvmError, deployContract, discoverEvmProviders, erc1155, erc20, erc721, estimateEip1559Fees, evmAccountFromPrivateKey, fees, gasPrice, getEvmWalletClient, metadata$1 as metadata, pqcKeyStatus, pqcVerify, precompiles, readContract, requestAccounts, rlConsensusParams, switchChain, toHexChainId, transfer, watchBlocks, watchContractEvent, watchEvent, watchPendingTransactions, writeContract };
|