genlayer-js 0.18.11 → 0.18.12

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 (66) hide show
  1. package/package.json +6 -1
  2. package/.eslintignore +0 -3
  3. package/.eslintrc.cjs +0 -59
  4. package/.github/pull_request_template.md +0 -43
  5. package/.github/workflows/publish.yml +0 -98
  6. package/.github/workflows/smoke.yml +0 -27
  7. package/.github/workflows/test.yml +0 -33
  8. package/.prettierignore +0 -19
  9. package/.prettierrc +0 -12
  10. package/.release-it.json +0 -66
  11. package/CHANGELOG.md +0 -306
  12. package/CLAUDE.md +0 -66
  13. package/CONTRIBUTING.md +0 -87
  14. package/renovate.json +0 -20
  15. package/src/abi/calldata/consts.ts +0 -14
  16. package/src/abi/calldata/decoder.ts +0 -86
  17. package/src/abi/calldata/encoder.ts +0 -178
  18. package/src/abi/calldata/index.ts +0 -3
  19. package/src/abi/calldata/string.ts +0 -83
  20. package/src/abi/index.ts +0 -6
  21. package/src/abi/staking.ts +0 -1501
  22. package/src/abi/transactions.ts +0 -11
  23. package/src/accounts/IAccountActions.ts +0 -5
  24. package/src/accounts/account.ts +0 -9
  25. package/src/accounts/actions.ts +0 -34
  26. package/src/chains/actions.ts +0 -40
  27. package/src/chains/index.ts +0 -4
  28. package/src/chains/localnet.ts +0 -4016
  29. package/src/chains/studionet.ts +0 -4017
  30. package/src/chains/testnetAsimov.ts +0 -4013
  31. package/src/client/client.ts +0 -139
  32. package/src/config/snapID.ts +0 -4
  33. package/src/config/transactions.ts +0 -9
  34. package/src/contracts/actions.ts +0 -387
  35. package/src/global.d.ts +0 -9
  36. package/src/index.ts +0 -12
  37. package/src/staking/actions.ts +0 -690
  38. package/src/staking/index.ts +0 -2
  39. package/src/staking/utils.ts +0 -22
  40. package/src/transactions/ITransactionActions.ts +0 -15
  41. package/src/transactions/actions.ts +0 -113
  42. package/src/transactions/decoders.ts +0 -275
  43. package/src/types/accounts.ts +0 -1
  44. package/src/types/calldata.ts +0 -31
  45. package/src/types/chains.ts +0 -22
  46. package/src/types/clients.ts +0 -106
  47. package/src/types/contracts.ts +0 -32
  48. package/src/types/index.ts +0 -9
  49. package/src/types/metamaskClientResult.ts +0 -5
  50. package/src/types/network.ts +0 -1
  51. package/src/types/snapSource.ts +0 -1
  52. package/src/types/staking.ts +0 -220
  53. package/src/types/transactions.ts +0 -312
  54. package/src/utils/async.ts +0 -3
  55. package/src/utils/jsonifier.ts +0 -119
  56. package/src/wallet/actions.ts +0 -10
  57. package/src/wallet/connect.ts +0 -67
  58. package/src/wallet/metamaskClient.ts +0 -50
  59. package/tests/client.test-d.ts +0 -67
  60. package/tests/client.test.ts +0 -197
  61. package/tests/smoke.test.ts +0 -291
  62. package/tests/transactions.test.ts +0 -142
  63. package/tsconfig.json +0 -119
  64. package/tsconfig.vitest-temp.json +0 -41
  65. package/vitest.config.ts +0 -19
  66. package/vitest.smoke.config.ts +0 -16
@@ -1,22 +0,0 @@
1
- import {parseEther, formatEther} from "viem";
2
-
3
- /**
4
- * Parse staking amount. Use "gen" suffix for GEN tokens (e.g. "42gen"),
5
- * otherwise value is treated as wei (e.g. "42000000000000000000" = 42 GEN).
6
- */
7
- export function parseStakingAmount(amount: string | bigint): bigint {
8
- if (typeof amount === "bigint") return amount;
9
- const trimmed = amount.trim();
10
- const lower = trimmed.toLowerCase();
11
- if (lower.endsWith("gen")) {
12
- return parseEther(lower.slice(0, -3).trim());
13
- }
14
- return BigInt(trimmed);
15
- }
16
-
17
- /**
18
- * Format bigint amount to human-readable GEN string.
19
- */
20
- export function formatStakingAmount(amount: bigint): string {
21
- return `${formatEther(amount)} GEN`;
22
- }
@@ -1,15 +0,0 @@
1
- import {TransactionHash, TransactionStatus, GenLayerTransaction} from "@/types";
2
-
3
- export type ITransactionActions = {
4
- waitForTransactionReceipt: ({
5
- hash,
6
- status,
7
- interval,
8
- retries,
9
- }: {
10
- hash: TransactionHash;
11
- status: TransactionStatus;
12
- interval?: number;
13
- retries?: number;
14
- }) => Promise<GenLayerTransaction>;
15
- };
@@ -1,113 +0,0 @@
1
- import {GenLayerClient} from "../types/clients";
2
- import {
3
- TransactionHash,
4
- TransactionStatus,
5
- GenLayerTransaction,
6
- GenLayerRawTransaction,
7
- transactionsStatusNameToNumber,
8
- isDecidedState,
9
- } from "../types/transactions";
10
- import {transactionsConfig} from "../config/transactions";
11
- import {sleep} from "../utils/async";
12
- import {GenLayerChain} from "@/types";
13
- import {Abi, PublicClient, Address} from "viem";
14
- import {localnet} from "@/chains/localnet";
15
- import {decodeLocalnetTransaction, decodeTransaction, simplifyTransactionReceipt} from "./decoders";
16
-
17
- export const receiptActions = (client: GenLayerClient<GenLayerChain>, publicClient: PublicClient) => ({
18
- waitForTransactionReceipt: async ({
19
- hash,
20
- status = TransactionStatus.ACCEPTED,
21
- interval = transactionsConfig.waitInterval,
22
- retries = transactionsConfig.retries,
23
- fullTransaction = false,
24
- }: {
25
- hash: TransactionHash;
26
- status: TransactionStatus;
27
- interval?: number;
28
- retries?: number;
29
- fullTransaction?: boolean;
30
- }): Promise<GenLayerTransaction> => {
31
- const transaction = await client.getTransaction({
32
- hash,
33
- });
34
-
35
- if (!transaction) {
36
- throw new Error("Transaction not found");
37
- }
38
- const transactionStatusString = String(transaction.status);
39
- const requestedStatus = transactionsStatusNameToNumber[status];
40
- if (
41
- transactionStatusString === requestedStatus ||
42
- (status === TransactionStatus.ACCEPTED && isDecidedState(transactionStatusString))
43
- ) {
44
- let finalTransaction = transaction;
45
- if (client.chain.id === localnet.id) {
46
- finalTransaction = decodeLocalnetTransaction(transaction as unknown as GenLayerTransaction);
47
- }
48
- if (!fullTransaction) {
49
- return simplifyTransactionReceipt(finalTransaction as GenLayerTransaction);
50
- }
51
- return finalTransaction;
52
- }
53
-
54
- if (retries === 0) {
55
- throw new Error("Transaction status is not " + status);
56
- }
57
-
58
- await sleep(interval);
59
- return receiptActions(client, publicClient).waitForTransactionReceipt({
60
- hash,
61
- status,
62
- interval,
63
- retries: retries - 1,
64
- fullTransaction,
65
- });
66
- },
67
- });
68
-
69
- export const transactionActions = (client: GenLayerClient<GenLayerChain>, publicClient: PublicClient) => ({
70
- getTransaction: async ({hash}: {hash: TransactionHash}): Promise<GenLayerTransaction> => {
71
- if (client.chain.isStudio) {
72
- const transaction = await client.getTransaction({hash});
73
- const localnetStatus =
74
- (transaction.status as string) === "ACTIVATED" ? TransactionStatus.PENDING : transaction.status;
75
-
76
- transaction.status = Number(transactionsStatusNameToNumber[localnetStatus as TransactionStatus]);
77
- transaction.statusName = localnetStatus as TransactionStatus;
78
- return decodeLocalnetTransaction(transaction as unknown as GenLayerTransaction);
79
- }
80
- const transaction = (await publicClient.readContract({
81
- address: client.chain.consensusDataContract?.address as Address,
82
- abi: client.chain.consensusDataContract?.abi as Abi,
83
- functionName: "getTransactionData",
84
- args: [
85
- hash,
86
- Math.round(new Date().getTime() / 1000), // unix seconds
87
- ],
88
- })) as unknown as GenLayerRawTransaction;
89
- return decodeTransaction(transaction);
90
- },
91
- estimateTransactionGas: async (transactionParams: {
92
- from?: Address;
93
- to: Address;
94
- data?: `0x${string}`;
95
- value?: bigint;
96
- }): Promise<bigint> => {
97
- const formattedParams = {
98
- from: transactionParams.from || client.account?.address,
99
- to: transactionParams.to,
100
- data: transactionParams.data || "0x",
101
- value: transactionParams.value
102
- ? (`0x${transactionParams.value.toString(16)}` as `0x${string}`)
103
- : ("0x0" as `0x${string}`),
104
- };
105
-
106
- const gasHex = (await client.request({
107
- method: "eth_estimateGas",
108
- params: [formattedParams],
109
- })) as string;
110
-
111
- return BigInt(gasHex);
112
- },
113
- });
@@ -1,275 +0,0 @@
1
- import {GenLayerTransaction, GenLayerRawTransaction, DecodedCallData, DecodedDeployData,transactionsStatusNumberToName, transactionResultNumberToName, voteTypeNumberToName, VoteType} from "../types/transactions";
2
- import {b64ToArray, calldataToUserFriendlyJson, resultToUserFriendlyJson} from "../utils/jsonifier";
3
- import {fromRlp, fromHex, Hex, Address} from "viem";
4
- import * as calldataAbi from "../abi/calldata";
5
-
6
- // Fields to remove from simplified transaction receipts
7
- const FIELDS_TO_REMOVE = [
8
- "raw", "contract_state", "base64", "consensus_history", "tx_data",
9
- "eq_blocks_outputs", "r", "s", "v", "created_timestamp",
10
- "current_timestamp", "tx_execution_hash", "random_seed", "states",
11
- "contract_code", "appeal_failed", "appeal_leader_timeout",
12
- "appeal_processing_time", "appeal_undetermined", "appealed",
13
- "timestamp_appeal", "config_rotation_rounds", "rotation_count",
14
- "queue_position", "queue_type", "leader_timeout_validators",
15
- "triggered_by", "num_of_initial_validators",
16
- "timestamp_awaiting_finalization", "last_vote_timestamp",
17
- "read_state_block_range", "tx_slot", "blockHash", "blockNumber",
18
- "to", "transactionIndex"
19
- ];
20
-
21
- // Field name mappings for cross-language compatibility with genlayer-py
22
- const FIELD_NAME_MAPPINGS: Record<string, string> = {
23
- statusName: "status_name",
24
- typeHex: "type"
25
- };
26
-
27
- export const decodeInputData = (
28
- rlpEncodedAppData: Hex | undefined | null,
29
- recipient: Address,
30
- ): DecodedDeployData | DecodedCallData | null => {
31
- if (!rlpEncodedAppData || rlpEncodedAppData === "0x" || rlpEncodedAppData.length <= 2) {
32
- return null;
33
- }
34
- try {
35
- const rlpDecodedArray = fromRlp(rlpEncodedAppData) as Hex[];
36
-
37
- if (rlpDecodedArray.length === 3) {
38
- return {
39
- code: fromHex(rlpDecodedArray[0], "string") as `0x${string}`,
40
- constructorArgs:
41
- rlpDecodedArray[1] && rlpDecodedArray[1] !== "0x"
42
- ? calldataAbi.decode(fromHex(rlpDecodedArray[1], "bytes"))
43
- : null,
44
- leaderOnly: rlpDecodedArray[2] === "0x01",
45
- type: "deploy",
46
- contractAddress: recipient,
47
- };
48
- } else if (rlpDecodedArray.length === 2) {
49
- return {
50
- callData:
51
- rlpDecodedArray[0] && rlpDecodedArray[0] !== "0x"
52
- ? calldataAbi.decode(fromHex(rlpDecodedArray[0], "bytes"))
53
- : null,
54
- leaderOnly: rlpDecodedArray[1] === "0x01",
55
- type: "call",
56
- };
57
- } else {
58
- console.warn(
59
- "[decodeInputData] WRITE: Unexpected RLP array length:",
60
- rlpDecodedArray.length,
61
- rlpDecodedArray,
62
- );
63
- return null;
64
- }
65
- } catch (e) {
66
- console.error(
67
- "[decodeInputData] Error during comprehensive decoding:",
68
- e,
69
- "Raw RLP App Data:",
70
- rlpEncodedAppData,
71
- );
72
- return null;
73
- }
74
- };
75
-
76
- export const decodeTransaction = (tx: GenLayerRawTransaction): GenLayerTransaction => {
77
- const txDataDecoded = decodeInputData(tx.txData, tx.recipient);
78
-
79
- const decodedTx = {
80
- ...tx,
81
- txData: tx.txData,
82
- txDataDecoded: txDataDecoded,
83
-
84
- currentTimestamp: tx.currentTimestamp.toString(),
85
- numOfInitialValidators: tx.numOfInitialValidators.toString(),
86
- txSlot: tx.txSlot.toString(),
87
- createdTimestamp: tx.createdTimestamp.toString(),
88
- lastVoteTimestamp: tx.lastVoteTimestamp.toString(),
89
- queuePosition: tx.queuePosition.toString(),
90
- numOfRounds: tx.numOfRounds.toString(),
91
-
92
- readStateBlockRange: {
93
- ...tx.readStateBlockRange,
94
- activationBlock: tx.readStateBlockRange.activationBlock.toString(),
95
- processingBlock: tx.readStateBlockRange.processingBlock.toString(),
96
- proposalBlock: tx.readStateBlockRange.proposalBlock.toString(),
97
- },
98
-
99
- statusName:
100
- transactionsStatusNumberToName[String(tx.status) as keyof typeof transactionsStatusNumberToName],
101
- resultName:
102
- transactionResultNumberToName[String(tx.result) as keyof typeof transactionResultNumberToName],
103
-
104
- lastRound: {
105
- ...tx.lastRound,
106
- round: tx.lastRound.round.toString(),
107
- leaderIndex: tx.lastRound.leaderIndex.toString(),
108
- votesCommitted: tx.lastRound.votesCommitted.toString(),
109
- votesRevealed: tx.lastRound.votesRevealed.toString(),
110
- appealBond: tx.lastRound.appealBond.toString(),
111
- rotationsLeft: tx.lastRound.rotationsLeft.toString(),
112
- validatorVotesName: tx.lastRound.validatorVotes.map(
113
- vote => voteTypeNumberToName[String(vote) as keyof typeof voteTypeNumberToName],
114
- ) as VoteType[],
115
- },
116
- };
117
- return decodedTx as GenLayerTransaction;
118
- };
119
-
120
- export const simplifyTransactionReceipt = (tx: GenLayerTransaction): GenLayerTransaction => {
121
- /**
122
- * Simplify transaction receipt by removing non-essential fields while preserving functionality.
123
- *
124
- * Removes: Binary data, internal timestamps, appeal fields, processing details, historical data
125
- * Preserves: Transaction IDs, status, execution results, node configs, readable data
126
- */
127
- const simplifyObject = (obj: any, path = ""): any => {
128
- if (obj === null || obj === undefined) return obj;
129
-
130
- if (Array.isArray(obj)) {
131
- return obj.map(item => simplifyObject(item, path)).filter(item => item !== undefined);
132
- }
133
-
134
- if (typeof obj === "object") {
135
- const result: any = {};
136
-
137
- for (const [key, value] of Object.entries(obj)) {
138
- const currentPath = path ? `${path}.${key}` : key;
139
-
140
- // Always remove these fields
141
- if (FIELDS_TO_REMOVE.includes(key)) {
142
- continue;
143
- }
144
-
145
- // Remove node_config only from top level (keep it in consensus_data)
146
- if (key === "node_config" && !path.includes("consensus_data")) {
147
- continue;
148
- }
149
-
150
- // Special handling for consensus_data - keep execution results and votes
151
- if (key === "consensus_data" && typeof value === "object" && value !== null) {
152
- const simplifiedConsensus: any = {};
153
-
154
- // Keep votes
155
- if ("votes" in value) {
156
- simplifiedConsensus.votes = value.votes;
157
- }
158
-
159
- // Process leader_receipt to keep only essential fields
160
- if ("leader_receipt" in value && Array.isArray(value.leader_receipt)) {
161
- simplifiedConsensus.leader_receipt = value.leader_receipt.map((receipt: any) => {
162
- const simplifiedReceipt: any = {};
163
-
164
- // Keep essential execution info
165
- ["execution_result", "genvm_result", "mode", "vote", "node_config"].forEach(field => {
166
- if (field in receipt) {
167
- simplifiedReceipt[field] = receipt[field];
168
- }
169
- });
170
-
171
- // Keep readable calldata
172
- if (receipt.calldata && typeof receipt.calldata === "object" && "readable" in receipt.calldata) {
173
- simplifiedReceipt.calldata = { readable: receipt.calldata.readable };
174
- }
175
-
176
- // Keep readable outputs
177
- if (receipt.eq_outputs) {
178
- simplifiedReceipt.eq_outputs = simplifyObject(receipt.eq_outputs, currentPath);
179
- }
180
- if (receipt.result) {
181
- simplifiedReceipt.result = simplifyObject(receipt.result, currentPath);
182
- }
183
-
184
- return simplifiedReceipt;
185
- });
186
- }
187
-
188
- // Process validators to keep execution results
189
- if ("validators" in value && Array.isArray(value.validators)) {
190
- const simplifiedValidators = value.validators.map((validator: any) => {
191
- const simplifiedValidator: any = {};
192
- ["execution_result", "genvm_result", "mode", "vote", "node_config"].forEach(field => {
193
- if (field in validator) {
194
- simplifiedValidator[field] = validator[field];
195
- }
196
- });
197
- return simplifiedValidator;
198
- }).filter((validator: any) => Object.keys(validator).length > 0);
199
-
200
- if (simplifiedValidators.length > 0) {
201
- simplifiedConsensus.validators = simplifiedValidators;
202
- }
203
- }
204
-
205
- result[key] = simplifiedConsensus;
206
- continue;
207
- }
208
-
209
- const simplifiedValue = simplifyObject(value, currentPath);
210
- // Include the value if it's not undefined and not an empty object
211
- // Special case: include numeric 0 values (like value: 0)
212
- const shouldInclude = simplifiedValue !== undefined &&
213
- !(typeof simplifiedValue === "object" && simplifiedValue !== null && Object.keys(simplifiedValue).length === 0);
214
-
215
- if (shouldInclude || simplifiedValue === 0) {
216
- // Map field names for cross-language compatibility
217
- const mappedKey = FIELD_NAME_MAPPINGS[key] || key;
218
- result[mappedKey] = simplifiedValue;
219
- }
220
- }
221
-
222
- return result;
223
- }
224
-
225
- return obj;
226
- };
227
-
228
- return simplifyObject({...tx});
229
- };
230
-
231
- export const decodeLocalnetTransaction = (tx: GenLayerTransaction): GenLayerTransaction => {
232
- if (!tx.data) return tx;
233
- try {
234
- const leaderReceipt = tx.consensus_data?.leader_receipt;
235
- if (leaderReceipt) {
236
- const receipts = Array.isArray(leaderReceipt) ? leaderReceipt : [leaderReceipt];
237
- receipts.forEach((receipt) => {
238
- if (receipt.result && typeof receipt.result === "string") {
239
- receipt.result = resultToUserFriendlyJson(receipt.result);
240
- }
241
- if (receipt.calldata && typeof receipt.calldata === "string") {
242
- receipt.calldata = {
243
- base64: receipt.calldata as string,
244
- ...calldataToUserFriendlyJson(b64ToArray(receipt.calldata as string)),
245
- };
246
- }
247
- if (receipt.eq_outputs) {
248
- const decodedOutputs: any = {};
249
- for (const [key, value] of Object.entries(receipt.eq_outputs)) {
250
- if (typeof value === "object" && value !== null) {
251
- decodedOutputs[key] = value;
252
- } else {
253
- try {
254
- decodedOutputs[key] = resultToUserFriendlyJson(value as string);
255
- } catch (e) {
256
- console.warn(`Error decoding eq_output ${key}: ${e}`);
257
- decodedOutputs[key] = value;
258
- }
259
- }
260
- }
261
- receipt.eq_outputs = decodedOutputs;
262
- }
263
- });
264
- }
265
- if (tx.data?.calldata && typeof tx.data.calldata === "string") {
266
- tx.data.calldata = {
267
- base64: tx.data.calldata as string,
268
- ...calldataToUserFriendlyJson(b64ToArray(tx.data.calldata as string)),
269
- };
270
- }
271
- } catch (e) {
272
- console.error("Error in decodeLocalnetTransaction:", e);
273
- }
274
- return tx;
275
- };
@@ -1 +0,0 @@
1
- export type {Account, Address} from "viem";
@@ -1,31 +0,0 @@
1
- export class CalldataAddress {
2
- bytes: Uint8Array;
3
-
4
- constructor(addr: Uint8Array) {
5
- if (addr.length != 20) {
6
- throw new Error(`invalid address length ${addr}`);
7
- }
8
-
9
- this.bytes = addr;
10
- }
11
- }
12
-
13
- export type CalldataEncodable =
14
- | null
15
- | boolean
16
- | CalldataAddress
17
- | number
18
- | bigint
19
- | string
20
- | Uint8Array /// bytes
21
- | Array<CalldataEncodable>
22
- | Map<string, CalldataEncodable>
23
- | {[key: string]: CalldataEncodable}; /// also a "map"
24
-
25
- export type MethodDescription = {
26
- method: string;
27
-
28
- args: Array<CalldataEncodable>;
29
- };
30
-
31
- export type TransactionDataElement = string | number | bigint | boolean | Uint8Array;
@@ -1,22 +0,0 @@
1
- import {Chain} from "viem";
2
- import {Address} from "./accounts";
3
-
4
- export type GenLayerChain = Chain & {
5
- isStudio: boolean;
6
- consensusMainContract: {
7
- address: Address;
8
- abi: readonly unknown[];
9
- bytecode: string;
10
- } | null;
11
- consensusDataContract: {
12
- address: Address;
13
- abi: readonly unknown[];
14
- bytecode: string;
15
- } | null;
16
- stakingContract: {
17
- address: Address;
18
- abi: readonly unknown[];
19
- } | null;
20
- defaultNumberOfInitialValidators: number;
21
- defaultConsensusMaxRotations: number;
22
- };
@@ -1,106 +0,0 @@
1
- import {Transport, Client, PublicActions, WalletActions} from "viem";
2
- import {GenLayerTransaction, TransactionHash, TransactionStatus, TransactionHashVariant} from "./transactions";
3
- import {GenLayerChain} from "./chains";
4
- import {Address, Account} from "./accounts";
5
- import {CalldataEncodable} from "./calldata";
6
- import {ContractSchema} from "./contracts";
7
- import {Network} from "./network";
8
- import {SnapSource} from "@/types/snapSource";
9
- import {MetaMaskClientResult} from "@/types/metamaskClientResult";
10
- import {StakingActions} from "./staking";
11
-
12
- export type GenLayerMethod =
13
- | {method: "sim_fundAccount"; params: [address: Address, amount: number]}
14
- | {method: "eth_getTransactionByHash"; params: [hash: TransactionHash]}
15
- | {method: "eth_call"; params: [requestParams: any, blockNumberOrHash: string]}
16
- | {method: "eth_sendRawTransaction"; params: [signedTransaction: string]}
17
- | {method: "gen_getContractSchema"; params: [address: Address]}
18
- | {method: "gen_getContractSchemaForCode"; params: [contractCode: string]}
19
- | {method: "gen_getContractCode"; params: [address: Address]}
20
- | {method: "sim_getTransactionsForAddress"; params: [address: Address, filter?: "all" | "from" | "to"]}
21
- | {method: "eth_getTransactionCount"; params: [address: Address, block: string]}
22
- | {method: "eth_estimateGas"; params: [transactionParams: any]}
23
- | {method: "gen_call"; params: [requestParams: any]};
24
-
25
- /*
26
- Take all the properties from Client<Transport, TGenLayerChain>
27
- Remove getTransaction and readContract because they are redefined with custom implementations.
28
- Keep transport as it's needed for viem contract interactions (e.g., staking).
29
- */
30
- export type GenLayerClient<TGenLayerChain extends GenLayerChain> = Omit<
31
- Client<Transport, TGenLayerChain>,
32
- "getTransaction" | "readContract"
33
- > &
34
- Omit<WalletActions<TGenLayerChain>, "deployContract" | "writeContract"> &
35
- Omit<
36
- PublicActions<Transport, TGenLayerChain>,
37
- "readContract" | "getTransaction" | "waitForTransactionReceipt"
38
- > & {
39
- request: Client<Transport, TGenLayerChain>["request"] & {
40
- <TMethod extends GenLayerMethod>(
41
- args: Extract<GenLayerMethod, {method: TMethod["method"]}>,
42
- ): Promise<unknown>;
43
- };
44
- readContract: <RawReturn extends boolean | undefined>(args: {
45
- account?: Account;
46
- address: Address;
47
- functionName: string;
48
- args?: CalldataEncodable[];
49
- kwargs?: Map<string, CalldataEncodable> | {[key: string]: CalldataEncodable};
50
- rawReturn?: RawReturn;
51
- jsonSafeReturn?: boolean;
52
- transactionHashVariant?: TransactionHashVariant;
53
- }) => Promise<RawReturn extends true ? `0x${string}` : CalldataEncodable>;
54
- writeContract: (args: {
55
- account?: Account;
56
- address: Address;
57
- functionName: string;
58
- args?: CalldataEncodable[];
59
- kwargs?: Map<string, CalldataEncodable> | {[key: string]: CalldataEncodable};
60
- value: bigint;
61
- leaderOnly?: boolean;
62
- consensusMaxRotations?: number;
63
- }) => Promise<any>;
64
- simulateWriteContract: <RawReturn extends boolean | undefined>(args: {
65
- account?: Account;
66
- address: Address;
67
- functionName: string;
68
- args?: CalldataEncodable[];
69
- kwargs?: Map<string, CalldataEncodable> | { [key: string]: CalldataEncodable };
70
- rawReturn?: RawReturn;
71
- leaderOnly?: boolean;
72
- transactionHashVariant?: TransactionHashVariant;
73
- }) => Promise<RawReturn extends true ? `0x${string}` : CalldataEncodable>;
74
- deployContract: (args: {
75
- account?: Account;
76
- code: string | Uint8Array;
77
- args?: CalldataEncodable[];
78
- kwargs?: Map<string, CalldataEncodable> | {[key: string]: CalldataEncodable};
79
- leaderOnly?: boolean;
80
- consensusMaxRotations?: number;
81
- }) => Promise<`0x${string}`>;
82
- getTransaction: (args: {hash: TransactionHash}) => Promise<GenLayerTransaction>;
83
- getCurrentNonce: (args: {address: Address}) => Promise<number>;
84
- estimateTransactionGas: (transactionParams: {
85
- from?: Address;
86
- to: Address;
87
- data?: `0x${string}`;
88
- value?: bigint;
89
- }) => Promise<bigint>;
90
- waitForTransactionReceipt: (args: {
91
- hash: TransactionHash;
92
- status?: TransactionStatus;
93
- interval?: number;
94
- retries?: number;
95
- }) => Promise<GenLayerTransaction>;
96
- getContractSchema: (address: Address) => Promise<ContractSchema>;
97
- getContractSchemaForCode: (contractCode: string | Uint8Array) => Promise<ContractSchema>;
98
- getContractCode: (address: Address) => Promise<string>;
99
- initializeConsensusSmartContract: (forceReset?: boolean) => Promise<void>;
100
- connect: (network?: Network, snapSource?: SnapSource) => Promise<void>;
101
- metamaskClient: (snapSource?: SnapSource) => Promise<MetaMaskClientResult>;
102
- appealTransaction: (args: {
103
- account?: Account;
104
- txId: `0x${string}`;
105
- }) => Promise<any>;
106
- } & StakingActions;
@@ -1,32 +0,0 @@
1
- export type ContractParamsArraySchemaElement = ContractParamsSchema | {$rep: ContractParamsSchema};
2
-
3
- export type ContractParamsSchema =
4
- | "null"
5
- | "bool"
6
- | "int"
7
- | "address"
8
- | "string"
9
- | "bytes"
10
- | "any"
11
- | "array"
12
- | "dict"
13
- | {$or: ContractParamsSchema[]}
14
- | {$dict: ContractParamsSchema}
15
- | {[key: string]: ContractParamsSchema}
16
- | ContractParamsArraySchemaElement[];
17
-
18
- export interface ContractMethodBase {
19
- params: [string, ContractParamsSchema][];
20
- kwparams: {[key: string]: ContractParamsSchema};
21
- }
22
-
23
- export interface ContractMethod extends ContractMethodBase {
24
- ret: ContractParamsSchema;
25
- readonly: boolean;
26
- payable?: boolean;
27
- }
28
-
29
- export type ContractSchema = {
30
- ctor: ContractMethodBase;
31
- methods: ContractMethod[];
32
- };
@@ -1,9 +0,0 @@
1
- export * from "./accounts";
2
- export {CalldataEncodable, MethodDescription, CalldataAddress} from "./calldata";
3
- export * from "./chains";
4
- export * from "./clients";
5
- export * from "./contracts";
6
- export * from "./transactions";
7
- export * from "./network";
8
- export * from "./snapSource";
9
- export * from "./staking";
@@ -1,5 +0,0 @@
1
- export type MetaMaskClientResult = {
2
- isFlask: boolean;
3
- installedSnaps: Record<string, any>;
4
- isGenLayerSnapInstalled: boolean;
5
- };
@@ -1 +0,0 @@
1
- export type Network = "localnet" | "studionet" | "testnetAsimov" | "mainnet";
@@ -1 +0,0 @@
1
- export type SnapSource = 'npm' | 'local';