genlayer-js 0.9.0 → 0.9.2

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.
Files changed (53) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/dist/chains/index.cjs +2 -2
  3. package/dist/chains/index.d.cts +2 -2
  4. package/dist/chains/index.d.ts +2 -2
  5. package/dist/chains/index.js +3 -3
  6. package/dist/chains-BYSCF33g.d.cts +18 -0
  7. package/dist/chains-BYSCF33g.d.ts +18 -0
  8. package/dist/chunk-4FVQ3G7J.js +8039 -0
  9. package/dist/chunk-GACCNOPJ.js +138 -0
  10. package/dist/chunk-H4ZYXVV2.cjs +138 -0
  11. package/dist/chunk-SMCXL465.cjs +8039 -0
  12. package/dist/index-B52a6DSr.d.cts +13 -0
  13. package/dist/index-B_gpaVzJ.d.cts +374 -0
  14. package/dist/index-DNvW8slT.d.ts +13 -0
  15. package/dist/index-to6d0Hzj.d.ts +374 -0
  16. package/dist/index.cjs +4508 -290
  17. package/dist/index.d.cts +6 -6
  18. package/dist/index.d.ts +6 -6
  19. package/dist/index.js +4507 -289
  20. package/dist/types/index.cjs +20 -2
  21. package/dist/types/index.d.cts +3 -3
  22. package/dist/types/index.d.ts +3 -3
  23. package/dist/types/index.js +21 -3
  24. package/package.json +2 -2
  25. package/src/accounts/IAccountActions.ts +2 -2
  26. package/src/accounts/actions.ts +10 -4
  27. package/src/chains/actions.ts +5 -5
  28. package/src/chains/index.ts +1 -1
  29. package/src/chains/localnet.ts +3989 -5
  30. package/src/chains/studionet.ts +4015 -0
  31. package/src/chains/testnetAsimov.ts +4015 -0
  32. package/src/client/client.ts +64 -21
  33. package/src/contracts/actions.ts +198 -127
  34. package/src/transactions/actions.ts +158 -23
  35. package/src/types/accounts.ts +1 -2
  36. package/src/types/chains.ts +8 -2
  37. package/src/types/clients.ts +14 -13
  38. package/src/types/network.ts +1 -1
  39. package/src/types/transactions.ts +254 -8
  40. package/src/wallet/actions.ts +4 -4
  41. package/src/wallet/connect.ts +18 -16
  42. package/tests/client.test.ts +105 -45
  43. package/dist/chains-C5PI_Nr_.d.cts +0 -13
  44. package/dist/chains-C5PI_Nr_.d.ts +0 -13
  45. package/dist/chunk-I6HC44KD.cjs +0 -72
  46. package/dist/chunk-K72OSU5N.js +0 -28
  47. package/dist/chunk-WEXFFND6.js +0 -72
  48. package/dist/chunk-YDFRDDP5.cjs +0 -28
  49. package/dist/index-B8E0qiOq.d.cts +0 -13
  50. package/dist/index-BCbofn6t.d.cts +0 -188
  51. package/dist/index-Ctmshvtv.d.ts +0 -188
  52. package/dist/index-ZoW0HQ_m.d.ts +0 -13
  53. package/src/chains/simulator.ts +0 -30
@@ -0,0 +1,13 @@
1
+ import { G as GenLayerChain } from './chains-BYSCF33g.cjs';
2
+
3
+ declare const localnet: GenLayerChain;
4
+
5
+ declare const testnetAsimov: GenLayerChain;
6
+
7
+ declare const index_localnet: typeof localnet;
8
+ declare const index_testnetAsimov: typeof testnetAsimov;
9
+ declare namespace index {
10
+ export { index_localnet as localnet, index_testnetAsimov as testnetAsimov };
11
+ }
12
+
13
+ export { index as i, localnet as l, testnetAsimov as t };
@@ -0,0 +1,374 @@
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
+ declare enum TransactionHashVariant {
126
+ LATEST_FINAL = "latest-final",
127
+ LATEST_NONFINAL = "latest-nonfinal"
128
+ }
129
+ type DecodedDeployData = {
130
+ code?: Hex;
131
+ constructorArgs?: any;
132
+ leaderOnly?: boolean;
133
+ type?: TransactionType;
134
+ contractAddress?: Address;
135
+ };
136
+ type DecodedCallData = {
137
+ callData?: any;
138
+ leaderOnly?: boolean;
139
+ type: TransactionType;
140
+ };
141
+ type GenLayerTransaction = {
142
+ currentTimestamp?: string;
143
+ from_address?: Address;
144
+ sender?: Address;
145
+ to_address?: Address;
146
+ recipient?: Address;
147
+ numOfInitialValidators?: string;
148
+ txSlot?: string;
149
+ createdTimestamp?: string;
150
+ lastVoteTimestamp?: string;
151
+ randomSeed?: Hash;
152
+ result?: number;
153
+ resultName?: TransactionResult;
154
+ data?: Record<string, unknown>;
155
+ txData?: Hex;
156
+ txDataDecoded?: DecodedDeployData | DecodedCallData;
157
+ txReceipt?: Hash;
158
+ messages?: unknown[];
159
+ queueType?: number;
160
+ queuePosition?: string;
161
+ activator?: Address;
162
+ lastLeader?: Address;
163
+ status?: TransactionStatus | number;
164
+ statusName?: TransactionStatus;
165
+ hash?: TransactionHash;
166
+ txId?: TransactionHash;
167
+ readStateBlockRange?: {
168
+ activationBlock: string;
169
+ processingBlock: string;
170
+ proposalBlock: string;
171
+ };
172
+ numOfRounds?: string;
173
+ lastRound?: {
174
+ round: string;
175
+ leaderIndex: string;
176
+ votesCommitted: string;
177
+ votesRevealed: string;
178
+ appealBond: string;
179
+ rotationsLeft: string;
180
+ result: number;
181
+ roundValidators: Address[];
182
+ validatorVotesHash: Hash[];
183
+ validatorVotes: number[];
184
+ validatorVotesName: VoteType[];
185
+ };
186
+ consensus_data?: {
187
+ final: boolean;
188
+ leader_receipt?: {
189
+ calldata: string;
190
+ class_name: string;
191
+ contract_state: string;
192
+ eq_outputs: Record<string, unknown>;
193
+ error: string | null;
194
+ execution_result: string;
195
+ gas_used: number;
196
+ mode: string;
197
+ node_config: Record<string, unknown>;
198
+ pending_transactions: unknown[];
199
+ vote: string;
200
+ result: string;
201
+ };
202
+ validators?: Record<string, unknown>[];
203
+ votes?: Record<string, string>;
204
+ };
205
+ nonce?: number;
206
+ value?: number;
207
+ type?: number;
208
+ gaslimit?: bigint;
209
+ created_at?: Date;
210
+ r?: number;
211
+ s?: number;
212
+ v?: number;
213
+ };
214
+ type GenLayerRawTransaction = {
215
+ currentTimestamp: bigint;
216
+ sender: Address;
217
+ recipient: Address;
218
+ numOfInitialValidators: bigint;
219
+ txSlot: bigint;
220
+ createdTimestamp: bigint;
221
+ lastVoteTimestamp: bigint;
222
+ randomSeed: Hash;
223
+ result: number;
224
+ txData: Hex | undefined | null;
225
+ txReceipt: Hash;
226
+ messages: unknown[];
227
+ queueType: number;
228
+ queuePosition: bigint;
229
+ activator: Address;
230
+ lastLeader: Address;
231
+ status: number;
232
+ txId: Hash;
233
+ readStateBlockRange: {
234
+ activationBlock: bigint;
235
+ processingBlock: bigint;
236
+ proposalBlock: bigint;
237
+ };
238
+ numOfRounds: bigint;
239
+ lastRound: {
240
+ round: bigint;
241
+ leaderIndex: bigint;
242
+ votesCommitted: bigint;
243
+ votesRevealed: bigint;
244
+ appealBond: bigint;
245
+ rotationsLeft: bigint;
246
+ result: number;
247
+ roundValidators: Address[];
248
+ validatorVotesHash: Hash[];
249
+ validatorVotes: number[];
250
+ };
251
+ };
252
+
253
+ type ContractParamsArraySchemaElement = ContractParamsSchema | {
254
+ $rep: ContractParamsSchema;
255
+ };
256
+ type ContractParamsSchema = "null" | "bool" | "int" | "address" | "string" | "bytes" | "any" | "array" | "dict" | {
257
+ $or: ContractParamsSchema[];
258
+ } | {
259
+ $dict: ContractParamsSchema;
260
+ } | {
261
+ [key: string]: ContractParamsSchema;
262
+ } | ContractParamsArraySchemaElement[];
263
+ interface ContractMethodBase {
264
+ params: [string, ContractParamsSchema][];
265
+ kwparams: {
266
+ [key: string]: ContractParamsSchema;
267
+ };
268
+ }
269
+ interface ContractMethod extends ContractMethodBase {
270
+ ret: ContractParamsSchema;
271
+ readonly: boolean;
272
+ }
273
+ type ContractSchema = {
274
+ ctor: ContractMethodBase;
275
+ methods: ContractMethod[];
276
+ };
277
+
278
+ type Network = "localnet" | "studionet" | "testnetAsimov" | "mainnet";
279
+
280
+ type SnapSource = 'npm' | 'local';
281
+
282
+ type MetaMaskClientResult = {
283
+ isFlask: boolean;
284
+ installedSnaps: Record<string, any>;
285
+ isGenLayerSnapInstalled: boolean;
286
+ };
287
+
288
+ type GenLayerMethod = {
289
+ method: "sim_fundAccount";
290
+ params: [address: Address, amount: number];
291
+ } | {
292
+ method: "eth_getTransactionByHash";
293
+ params: [hash: TransactionHash];
294
+ } | {
295
+ method: "eth_call";
296
+ params: [requestParams: any, blockNumberOrHash: string];
297
+ } | {
298
+ method: "eth_sendRawTransaction";
299
+ params: [signedTransaction: string];
300
+ } | {
301
+ method: "gen_getContractSchema";
302
+ params: [address: Address];
303
+ } | {
304
+ method: "gen_getContractSchemaForCode";
305
+ params: [contractCode: string];
306
+ } | {
307
+ method: "sim_getTransactionsForAddress";
308
+ params: [address: Address, filter?: "all" | "from" | "to"];
309
+ } | {
310
+ method: "eth_getTransactionCount";
311
+ params: [address: Address, block: string];
312
+ } | {
313
+ method: "gen_call";
314
+ params: [requestParams: any];
315
+ };
316
+ type GenLayerClient<TGenLayerChain extends GenLayerChain> = Omit<Client<Transport, TGenLayerChain>, "transport" | "getTransaction" | "readContract"> & Omit<WalletActions<TGenLayerChain>, "deployContract" | "writeContract"> & Omit<PublicActions<Transport, TGenLayerChain>, "readContract" | "getTransaction" | "waitForTransactionReceipt"> & {
317
+ request: Client<Transport, TGenLayerChain>["request"] & {
318
+ <TMethod extends GenLayerMethod>(args: Extract<GenLayerMethod, {
319
+ method: TMethod["method"];
320
+ }>): Promise<unknown>;
321
+ };
322
+ readContract: <RawReturn extends boolean | undefined>(args: {
323
+ account?: Account;
324
+ address: Address;
325
+ functionName: string;
326
+ stateStatus?: TransactionStatus;
327
+ args?: CalldataEncodable[];
328
+ kwargs?: Map<string, CalldataEncodable> | {
329
+ [key: string]: CalldataEncodable;
330
+ };
331
+ rawReturn?: RawReturn;
332
+ }) => Promise<RawReturn extends true ? `0x${string}` : CalldataEncodable>;
333
+ writeContract: (args: {
334
+ account?: Account;
335
+ address: Address;
336
+ functionName: string;
337
+ args?: CalldataEncodable[];
338
+ kwargs?: Map<string, CalldataEncodable> | {
339
+ [key: string]: CalldataEncodable;
340
+ };
341
+ value: bigint;
342
+ leaderOnly?: boolean;
343
+ consensusMaxRotations?: number;
344
+ }) => Promise<any>;
345
+ deployContract: (args: {
346
+ account?: Account;
347
+ code: string | Uint8Array;
348
+ args?: CalldataEncodable[];
349
+ kwargs?: Map<string, CalldataEncodable> | {
350
+ [key: string]: CalldataEncodable;
351
+ };
352
+ leaderOnly?: boolean;
353
+ consensusMaxRotations?: number;
354
+ }) => Promise<`0x${string}`>;
355
+ getTransaction: (args: {
356
+ hash: TransactionHash;
357
+ }) => Promise<GenLayerTransaction>;
358
+ getCurrentNonce: (args: {
359
+ address: Address;
360
+ }) => Promise<number>;
361
+ waitForTransactionReceipt: (args: {
362
+ hash: TransactionHash;
363
+ status?: TransactionStatus;
364
+ interval?: number;
365
+ retries?: number;
366
+ }) => Promise<GenLayerTransaction>;
367
+ getContractSchema: (address: Address) => Promise<ContractSchema>;
368
+ getContractSchemaForCode: (contractCode: string | Uint8Array) => Promise<ContractSchema>;
369
+ initializeConsensusSmartContract: (forceReset?: boolean) => Promise<void>;
370
+ connect: (network?: Network, snapSource?: SnapSource) => Promise<void>;
371
+ metamaskClient: (snapSource?: SnapSource) => Promise<MetaMaskClientResult>;
372
+ };
373
+
374
+ 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, TransactionHashVariant as p, type DecodedCallData as q, type GenLayerTransaction as r, type GenLayerRawTransaction as s, transactionsStatusNumberToName as t, voteTypeNumberToName as v };
@@ -0,0 +1,13 @@
1
+ import { G as GenLayerChain } from './chains-BYSCF33g.js';
2
+
3
+ declare const localnet: GenLayerChain;
4
+
5
+ declare const testnetAsimov: GenLayerChain;
6
+
7
+ declare const index_localnet: typeof localnet;
8
+ declare const index_testnetAsimov: typeof testnetAsimov;
9
+ declare namespace index {
10
+ export { index_localnet as localnet, index_testnetAsimov as testnetAsimov };
11
+ }
12
+
13
+ export { index as i, localnet as l, testnetAsimov as t };