genlayer-js 0.9.0 → 0.9.1
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 +2 -0
- package/dist/chains/index.cjs +2 -2
- package/dist/chains/index.d.cts +2 -2
- package/dist/chains/index.d.ts +2 -2
- package/dist/chains/index.js +3 -3
- package/dist/chains-BYSCF33g.d.cts +18 -0
- package/dist/chains-BYSCF33g.d.ts +18 -0
- package/dist/chunk-7YZQQWJZ.js +4056 -0
- package/dist/chunk-AZSICIZ3.cjs +132 -0
- package/dist/chunk-FPFZLPXI.cjs +4056 -0
- package/dist/chunk-RS7NCSOQ.js +132 -0
- package/dist/index-BM9hOtGg.d.cts +13 -0
- package/dist/index-C7Colsnk.d.ts +13 -0
- package/dist/index-DvSbRKD5.d.ts +370 -0
- package/dist/index-kDM_9wW1.d.cts +370 -0
- package/dist/index.cjs +315 -130
- package/dist/index.d.cts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.js +306 -121
- package/dist/types/index.cjs +18 -2
- package/dist/types/index.d.cts +3 -3
- package/dist/types/index.d.ts +3 -3
- package/dist/types/index.js +19 -3
- package/package.json +2 -2
- package/src/accounts/IAccountActions.ts +2 -2
- package/src/accounts/actions.ts +10 -4
- package/src/chains/actions.ts +5 -5
- package/src/chains/index.ts +1 -1
- package/src/chains/localnet.ts +4 -3
- package/src/chains/testnet.ts +4015 -0
- package/src/client/client.ts +64 -21
- package/src/contracts/actions.ts +185 -137
- package/src/transactions/actions.ts +145 -21
- package/src/types/accounts.ts +1 -2
- package/src/types/chains.ts +8 -2
- package/src/types/clients.ts +14 -13
- package/src/types/transactions.ts +249 -8
- package/src/wallet/actions.ts +4 -4
- package/src/wallet/connect.ts +12 -14
- package/tests/client.test.ts +105 -45
- package/dist/chains-C5PI_Nr_.d.cts +0 -13
- package/dist/chains-C5PI_Nr_.d.ts +0 -13
- package/dist/chunk-I6HC44KD.cjs +0 -72
- package/dist/chunk-K72OSU5N.js +0 -28
- package/dist/chunk-WEXFFND6.js +0 -72
- package/dist/chunk-YDFRDDP5.cjs +0 -28
- package/dist/index-B8E0qiOq.d.cts +0 -13
- package/dist/index-BCbofn6t.d.cts +0 -188
- package/dist/index-Ctmshvtv.d.ts +0 -188
- package/dist/index-ZoW0HQ_m.d.ts +0 -13
- package/src/chains/simulator.ts +0 -30
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
import { Hex, Address, Client, Transport, WalletActions, PublicActions, Account } from 'viem';
|
|
2
|
+
import { G as GenLayerChain } from './chains-BYSCF33g.cjs';
|
|
3
|
+
|
|
4
|
+
declare class CalldataAddress {
|
|
5
|
+
bytes: Uint8Array;
|
|
6
|
+
constructor(addr: Uint8Array);
|
|
7
|
+
}
|
|
8
|
+
type CalldataEncodable = null | boolean | CalldataAddress | number | bigint | string | Uint8Array | Array<CalldataEncodable> | Map<string, CalldataEncodable> | {
|
|
9
|
+
[key: string]: CalldataEncodable;
|
|
10
|
+
};
|
|
11
|
+
type MethodDescription = {
|
|
12
|
+
method: string;
|
|
13
|
+
args: Array<CalldataEncodable>;
|
|
14
|
+
};
|
|
15
|
+
type TransactionDataElement = string | number | bigint | boolean | Uint8Array;
|
|
16
|
+
|
|
17
|
+
type Hash = `0x${string}` & {
|
|
18
|
+
length: 66;
|
|
19
|
+
};
|
|
20
|
+
type TransactionHash = Hash;
|
|
21
|
+
declare enum TransactionStatus {
|
|
22
|
+
UNINITIALIZED = "UNINITIALIZED",
|
|
23
|
+
PENDING = "PENDING",
|
|
24
|
+
PROPOSING = "PROPOSING",
|
|
25
|
+
COMMITTING = "COMMITTING",
|
|
26
|
+
REVEALING = "REVEALING",
|
|
27
|
+
ACCEPTED = "ACCEPTED",
|
|
28
|
+
UNDETERMINED = "UNDETERMINED",
|
|
29
|
+
FINALIZED = "FINALIZED",
|
|
30
|
+
CANCELED = "CANCELED",
|
|
31
|
+
APPEAL_REVEALING = "APPEAL_REVEALING",
|
|
32
|
+
APPEAL_COMMITTING = "APPEAL_COMMITTING",
|
|
33
|
+
READY_TO_FINALIZE = "READY_TO_FINALIZE",
|
|
34
|
+
VALIDATORS_TIMEOUT = "VALIDATORS_TIMEOUT",
|
|
35
|
+
LEADER_TIMEOUT = "LEADER_TIMEOUT"
|
|
36
|
+
}
|
|
37
|
+
declare enum TransactionResult {
|
|
38
|
+
SUCCESS = "SUCCESS",
|
|
39
|
+
FAILURE = "FAILURE"
|
|
40
|
+
}
|
|
41
|
+
declare enum TransactionResult {
|
|
42
|
+
IDLE = "IDLE",
|
|
43
|
+
AGREE = "AGREE",
|
|
44
|
+
DISAGREE = "DISAGREE",
|
|
45
|
+
TIMEOUT = "TIMEOUT",
|
|
46
|
+
DETERMINISTIC_VIOLATION = "DETERMINISTIC_VIOLATION",
|
|
47
|
+
NO_MAJORITY = "NO_MAJORITY",
|
|
48
|
+
MAJORITY_AGREE = "MAJORITY_AGREE",
|
|
49
|
+
MAJORITY_DISAGREE = "MAJORITY_DISAGREE"
|
|
50
|
+
}
|
|
51
|
+
declare const transactionsStatusNumberToName: {
|
|
52
|
+
"0": TransactionStatus;
|
|
53
|
+
"1": TransactionStatus;
|
|
54
|
+
"2": TransactionStatus;
|
|
55
|
+
"3": TransactionStatus;
|
|
56
|
+
"4": TransactionStatus;
|
|
57
|
+
"5": TransactionStatus;
|
|
58
|
+
"6": TransactionStatus;
|
|
59
|
+
"7": TransactionStatus;
|
|
60
|
+
"8": TransactionStatus;
|
|
61
|
+
"9": TransactionStatus;
|
|
62
|
+
"10": TransactionStatus;
|
|
63
|
+
"11": TransactionStatus;
|
|
64
|
+
"12": TransactionStatus;
|
|
65
|
+
"13": TransactionStatus;
|
|
66
|
+
};
|
|
67
|
+
declare const transactionsStatusNameToNumber: {
|
|
68
|
+
UNINITIALIZED: string;
|
|
69
|
+
PENDING: string;
|
|
70
|
+
PROPOSING: string;
|
|
71
|
+
COMMITTING: string;
|
|
72
|
+
REVEALING: string;
|
|
73
|
+
ACCEPTED: string;
|
|
74
|
+
UNDETERMINED: string;
|
|
75
|
+
FINALIZED: string;
|
|
76
|
+
CANCELED: string;
|
|
77
|
+
APPEAL_REVEALING: string;
|
|
78
|
+
APPEAL_COMMITTING: string;
|
|
79
|
+
READY_TO_FINALIZE: string;
|
|
80
|
+
VALIDATORS_TIMEOUT: string;
|
|
81
|
+
LEADER_TIMEOUT: string;
|
|
82
|
+
};
|
|
83
|
+
declare const transactionResultNumberToName: {
|
|
84
|
+
"0": TransactionResult;
|
|
85
|
+
"1": TransactionResult;
|
|
86
|
+
"2": TransactionResult;
|
|
87
|
+
"3": TransactionResult;
|
|
88
|
+
"4": TransactionResult;
|
|
89
|
+
"5": TransactionResult;
|
|
90
|
+
"6": TransactionResult;
|
|
91
|
+
"7": TransactionResult;
|
|
92
|
+
};
|
|
93
|
+
declare const TransactionResultNameToNumber: {
|
|
94
|
+
IDLE: string;
|
|
95
|
+
AGREE: string;
|
|
96
|
+
DISAGREE: string;
|
|
97
|
+
TIMEOUT: string;
|
|
98
|
+
DETERMINISTIC_VIOLATION: string;
|
|
99
|
+
NO_MAJORITY: string;
|
|
100
|
+
MAJORITY_AGREE: string;
|
|
101
|
+
MAJORITY_DISAGREE: string;
|
|
102
|
+
};
|
|
103
|
+
declare enum VoteType {
|
|
104
|
+
NOT_VOTED = "NOT_VOTED",
|
|
105
|
+
AGREE = "AGREE",
|
|
106
|
+
DISAGREE = "DISAGREE",
|
|
107
|
+
TIMEOUT = "TIMEOUT",
|
|
108
|
+
DETERMINISTIC_VIOLATION = "DETERMINISTIC_VIOLATION"
|
|
109
|
+
}
|
|
110
|
+
declare const voteTypeNumberToName: {
|
|
111
|
+
"0": VoteType;
|
|
112
|
+
"1": VoteType;
|
|
113
|
+
"2": VoteType;
|
|
114
|
+
"3": VoteType;
|
|
115
|
+
"4": VoteType;
|
|
116
|
+
};
|
|
117
|
+
declare const voteTypeNameToNumber: {
|
|
118
|
+
NOT_VOTED: string;
|
|
119
|
+
AGREE: string;
|
|
120
|
+
DISAGREE: string;
|
|
121
|
+
TIMEOUT: string;
|
|
122
|
+
DETERMINISTIC_VIOLATION: string;
|
|
123
|
+
};
|
|
124
|
+
type TransactionType = "deploy" | "call";
|
|
125
|
+
type DecodedDeployData = {
|
|
126
|
+
code?: Hex;
|
|
127
|
+
constructorArgs?: any;
|
|
128
|
+
leaderOnly?: boolean;
|
|
129
|
+
type?: TransactionType;
|
|
130
|
+
contractAddress?: Address;
|
|
131
|
+
};
|
|
132
|
+
type DecodedCallData = {
|
|
133
|
+
callData?: any;
|
|
134
|
+
leaderOnly?: boolean;
|
|
135
|
+
type: TransactionType;
|
|
136
|
+
};
|
|
137
|
+
type GenLayerTransaction = {
|
|
138
|
+
currentTimestamp?: string;
|
|
139
|
+
from_address?: Address;
|
|
140
|
+
sender?: Address;
|
|
141
|
+
to_address?: Address;
|
|
142
|
+
recipient?: Address;
|
|
143
|
+
numOfInitialValidators?: string;
|
|
144
|
+
txSlot?: string;
|
|
145
|
+
createdTimestamp?: string;
|
|
146
|
+
lastVoteTimestamp?: string;
|
|
147
|
+
randomSeed?: Hash;
|
|
148
|
+
result?: number;
|
|
149
|
+
resultName?: TransactionResult;
|
|
150
|
+
data?: Record<string, unknown>;
|
|
151
|
+
txData?: Hex;
|
|
152
|
+
txDataDecoded?: DecodedDeployData | DecodedCallData;
|
|
153
|
+
txReceipt?: Hash;
|
|
154
|
+
messages?: unknown[];
|
|
155
|
+
queueType?: number;
|
|
156
|
+
queuePosition?: string;
|
|
157
|
+
activator?: Address;
|
|
158
|
+
lastLeader?: Address;
|
|
159
|
+
status?: TransactionStatus | number;
|
|
160
|
+
statusName?: TransactionStatus;
|
|
161
|
+
hash?: TransactionHash;
|
|
162
|
+
txId?: TransactionHash;
|
|
163
|
+
readStateBlockRange?: {
|
|
164
|
+
activationBlock: string;
|
|
165
|
+
processingBlock: string;
|
|
166
|
+
proposalBlock: string;
|
|
167
|
+
};
|
|
168
|
+
numOfRounds?: string;
|
|
169
|
+
lastRound?: {
|
|
170
|
+
round: string;
|
|
171
|
+
leaderIndex: string;
|
|
172
|
+
votesCommitted: string;
|
|
173
|
+
votesRevealed: string;
|
|
174
|
+
appealBond: string;
|
|
175
|
+
rotationsLeft: string;
|
|
176
|
+
result: number;
|
|
177
|
+
roundValidators: Address[];
|
|
178
|
+
validatorVotesHash: Hash[];
|
|
179
|
+
validatorVotes: number[];
|
|
180
|
+
validatorVotesName: VoteType[];
|
|
181
|
+
};
|
|
182
|
+
consensus_data?: {
|
|
183
|
+
final: boolean;
|
|
184
|
+
leader_receipt?: {
|
|
185
|
+
calldata: string;
|
|
186
|
+
class_name: string;
|
|
187
|
+
contract_state: string;
|
|
188
|
+
eq_outputs: Record<string, unknown>;
|
|
189
|
+
error: string | null;
|
|
190
|
+
execution_result: string;
|
|
191
|
+
gas_used: number;
|
|
192
|
+
mode: string;
|
|
193
|
+
node_config: Record<string, unknown>;
|
|
194
|
+
pending_transactions: unknown[];
|
|
195
|
+
vote: string;
|
|
196
|
+
result: string;
|
|
197
|
+
};
|
|
198
|
+
validators?: Record<string, unknown>[];
|
|
199
|
+
votes?: Record<string, string>;
|
|
200
|
+
};
|
|
201
|
+
nonce?: number;
|
|
202
|
+
value?: number;
|
|
203
|
+
type?: number;
|
|
204
|
+
gaslimit?: bigint;
|
|
205
|
+
created_at?: Date;
|
|
206
|
+
r?: number;
|
|
207
|
+
s?: number;
|
|
208
|
+
v?: number;
|
|
209
|
+
};
|
|
210
|
+
type GenLayerRawTransaction = {
|
|
211
|
+
currentTimestamp: bigint;
|
|
212
|
+
sender: Address;
|
|
213
|
+
recipient: Address;
|
|
214
|
+
numOfInitialValidators: bigint;
|
|
215
|
+
txSlot: bigint;
|
|
216
|
+
createdTimestamp: bigint;
|
|
217
|
+
lastVoteTimestamp: bigint;
|
|
218
|
+
randomSeed: Hash;
|
|
219
|
+
result: number;
|
|
220
|
+
txData: Hex | undefined | null;
|
|
221
|
+
txReceipt: Hash;
|
|
222
|
+
messages: unknown[];
|
|
223
|
+
queueType: number;
|
|
224
|
+
queuePosition: bigint;
|
|
225
|
+
activator: Address;
|
|
226
|
+
lastLeader: Address;
|
|
227
|
+
status: number;
|
|
228
|
+
txId: Hash;
|
|
229
|
+
readStateBlockRange: {
|
|
230
|
+
activationBlock: bigint;
|
|
231
|
+
processingBlock: bigint;
|
|
232
|
+
proposalBlock: bigint;
|
|
233
|
+
};
|
|
234
|
+
numOfRounds: bigint;
|
|
235
|
+
lastRound: {
|
|
236
|
+
round: bigint;
|
|
237
|
+
leaderIndex: bigint;
|
|
238
|
+
votesCommitted: bigint;
|
|
239
|
+
votesRevealed: bigint;
|
|
240
|
+
appealBond: bigint;
|
|
241
|
+
rotationsLeft: bigint;
|
|
242
|
+
result: number;
|
|
243
|
+
roundValidators: Address[];
|
|
244
|
+
validatorVotesHash: Hash[];
|
|
245
|
+
validatorVotes: number[];
|
|
246
|
+
};
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
type ContractParamsArraySchemaElement = ContractParamsSchema | {
|
|
250
|
+
$rep: ContractParamsSchema;
|
|
251
|
+
};
|
|
252
|
+
type ContractParamsSchema = "null" | "bool" | "int" | "address" | "string" | "bytes" | "any" | "array" | "dict" | {
|
|
253
|
+
$or: ContractParamsSchema[];
|
|
254
|
+
} | {
|
|
255
|
+
$dict: ContractParamsSchema;
|
|
256
|
+
} | {
|
|
257
|
+
[key: string]: ContractParamsSchema;
|
|
258
|
+
} | ContractParamsArraySchemaElement[];
|
|
259
|
+
interface ContractMethodBase {
|
|
260
|
+
params: [string, ContractParamsSchema][];
|
|
261
|
+
kwparams: {
|
|
262
|
+
[key: string]: ContractParamsSchema;
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
interface ContractMethod extends ContractMethodBase {
|
|
266
|
+
ret: ContractParamsSchema;
|
|
267
|
+
readonly: boolean;
|
|
268
|
+
}
|
|
269
|
+
type ContractSchema = {
|
|
270
|
+
ctor: ContractMethodBase;
|
|
271
|
+
methods: ContractMethod[];
|
|
272
|
+
};
|
|
273
|
+
|
|
274
|
+
type Network = 'localnet' | 'testnet' | 'mainnet';
|
|
275
|
+
|
|
276
|
+
type SnapSource = 'npm' | 'local';
|
|
277
|
+
|
|
278
|
+
type MetaMaskClientResult = {
|
|
279
|
+
isFlask: boolean;
|
|
280
|
+
installedSnaps: Record<string, any>;
|
|
281
|
+
isGenLayerSnapInstalled: boolean;
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
type GenLayerMethod = {
|
|
285
|
+
method: "sim_fundAccount";
|
|
286
|
+
params: [address: Address, amount: number];
|
|
287
|
+
} | {
|
|
288
|
+
method: "eth_getTransactionByHash";
|
|
289
|
+
params: [hash: TransactionHash];
|
|
290
|
+
} | {
|
|
291
|
+
method: "eth_call";
|
|
292
|
+
params: [requestParams: any, blockNumberOrHash: string];
|
|
293
|
+
} | {
|
|
294
|
+
method: "eth_sendRawTransaction";
|
|
295
|
+
params: [signedTransaction: string];
|
|
296
|
+
} | {
|
|
297
|
+
method: "gen_getContractSchema";
|
|
298
|
+
params: [address: Address];
|
|
299
|
+
} | {
|
|
300
|
+
method: "gen_getContractSchemaForCode";
|
|
301
|
+
params: [contractCode: string];
|
|
302
|
+
} | {
|
|
303
|
+
method: "sim_getTransactionsForAddress";
|
|
304
|
+
params: [address: Address, filter?: "all" | "from" | "to"];
|
|
305
|
+
} | {
|
|
306
|
+
method: "eth_getTransactionCount";
|
|
307
|
+
params: [address: Address, block: string];
|
|
308
|
+
} | {
|
|
309
|
+
method: "gen_call";
|
|
310
|
+
params: [requestParams: any];
|
|
311
|
+
};
|
|
312
|
+
type GenLayerClient<TGenLayerChain extends GenLayerChain> = Omit<Client<Transport, TGenLayerChain>, "transport" | "getTransaction" | "readContract"> & Omit<WalletActions<TGenLayerChain>, "deployContract" | "writeContract"> & Omit<PublicActions<Transport, TGenLayerChain>, "readContract" | "getTransaction" | "waitForTransactionReceipt"> & {
|
|
313
|
+
request: Client<Transport, TGenLayerChain>["request"] & {
|
|
314
|
+
<TMethod extends GenLayerMethod>(args: Extract<GenLayerMethod, {
|
|
315
|
+
method: TMethod["method"];
|
|
316
|
+
}>): Promise<unknown>;
|
|
317
|
+
};
|
|
318
|
+
readContract: <RawReturn extends boolean | undefined>(args: {
|
|
319
|
+
account?: Account;
|
|
320
|
+
address: Address;
|
|
321
|
+
functionName: string;
|
|
322
|
+
stateStatus?: TransactionStatus;
|
|
323
|
+
args?: CalldataEncodable[];
|
|
324
|
+
kwargs?: Map<string, CalldataEncodable> | {
|
|
325
|
+
[key: string]: CalldataEncodable;
|
|
326
|
+
};
|
|
327
|
+
rawReturn?: RawReturn;
|
|
328
|
+
}) => Promise<RawReturn extends true ? `0x${string}` : CalldataEncodable>;
|
|
329
|
+
writeContract: (args: {
|
|
330
|
+
account?: Account;
|
|
331
|
+
address: Address;
|
|
332
|
+
functionName: string;
|
|
333
|
+
args?: CalldataEncodable[];
|
|
334
|
+
kwargs?: Map<string, CalldataEncodable> | {
|
|
335
|
+
[key: string]: CalldataEncodable;
|
|
336
|
+
};
|
|
337
|
+
value: bigint;
|
|
338
|
+
leaderOnly?: boolean;
|
|
339
|
+
consensusMaxRotations?: number;
|
|
340
|
+
}) => Promise<any>;
|
|
341
|
+
deployContract: (args: {
|
|
342
|
+
account?: Account;
|
|
343
|
+
code: string | Uint8Array;
|
|
344
|
+
args?: CalldataEncodable[];
|
|
345
|
+
kwargs?: Map<string, CalldataEncodable> | {
|
|
346
|
+
[key: string]: CalldataEncodable;
|
|
347
|
+
};
|
|
348
|
+
leaderOnly?: boolean;
|
|
349
|
+
consensusMaxRotations?: number;
|
|
350
|
+
}) => Promise<`0x${string}`>;
|
|
351
|
+
getTransaction: (args: {
|
|
352
|
+
hash: TransactionHash;
|
|
353
|
+
}) => Promise<GenLayerTransaction>;
|
|
354
|
+
getCurrentNonce: (args: {
|
|
355
|
+
address: Address;
|
|
356
|
+
}) => Promise<number>;
|
|
357
|
+
waitForTransactionReceipt: (args: {
|
|
358
|
+
hash: TransactionHash;
|
|
359
|
+
status?: TransactionStatus;
|
|
360
|
+
interval?: number;
|
|
361
|
+
retries?: number;
|
|
362
|
+
}) => Promise<GenLayerTransaction>;
|
|
363
|
+
getContractSchema: (address: Address) => Promise<ContractSchema>;
|
|
364
|
+
getContractSchemaForCode: (contractCode: string | Uint8Array) => Promise<ContractSchema>;
|
|
365
|
+
initializeConsensusSmartContract: (forceReset?: boolean) => Promise<void>;
|
|
366
|
+
connect: (network?: Network, snapSource?: SnapSource) => Promise<void>;
|
|
367
|
+
metamaskClient: (snapSource?: SnapSource) => Promise<MetaMaskClientResult>;
|
|
368
|
+
};
|
|
369
|
+
|
|
370
|
+
export { type CalldataEncodable as C, type DecodedDeployData as D, type GenLayerClient as G, type Hash as H, type MethodDescription as M, type Network as N, type SnapSource as S, type TransactionDataElement as T, VoteType as V, CalldataAddress as a, type GenLayerMethod as b, type ContractParamsArraySchemaElement as c, type ContractParamsSchema as d, type ContractMethodBase as e, type ContractMethod as f, type ContractSchema as g, type TransactionHash as h, TransactionStatus as i, TransactionResult as j, transactionsStatusNameToNumber as k, transactionResultNumberToName as l, TransactionResultNameToNumber as m, voteTypeNameToNumber as n, type TransactionType as o, type DecodedCallData as p, type GenLayerTransaction as q, type GenLayerRawTransaction as r, transactionsStatusNumberToName as t, voteTypeNumberToName as v };
|