genlayer-js 0.6.0 → 0.6.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.
@@ -1,166 +1,3 @@
1
- import { S as SimulatorChain } from '../chains-BV4Glo-M.js';
2
- import { Client, Transport, PublicActions, Account } from 'viem';
1
+ export { A as Address, a as CalldataAddress, C as CalldataEncodable, f as ContractMethod, e as ContractMethodBase, c as ContractParamsArraySchemaElement, d as ContractParamsSchema, g as ContractSchema, G as GenLayerClient, b as GenLayerMethod, j as GenLayerTransaction, M as MethodDescription, k as TransactionDataElement, h as TransactionHash, i as TransactionStatus } from '../index-B1ZR98OZ.js';
2
+ export { S as SimulatorChain } from '../chains-BV4Glo-M.js';
3
3
  export { Account } from 'viem';
4
-
5
- type Address$1 = `0x${string}` & {
6
- length: 42;
7
- };
8
-
9
- declare class Address {
10
- bytes: Uint8Array;
11
- constructor(addr: Uint8Array);
12
- }
13
- type CalldataEncodable = null | boolean | Address | number | bigint | string | Uint8Array | Array<CalldataEncodable> | Map<string, CalldataEncodable> | {
14
- [key: string]: CalldataEncodable;
15
- };
16
- type MethodDescription = {
17
- method: string;
18
- args: Array<CalldataEncodable>;
19
- };
20
- type TransactionData = {
21
- method: string;
22
- args: CalldataEncodable[];
23
- };
24
-
25
- type TransactionHash = `0x${string}` & {
26
- length: 66;
27
- };
28
- declare enum TransactionStatus {
29
- PENDING = "PENDING",
30
- CANCELED = "CANCELED",
31
- PROPOSING = "PROPOSING",
32
- COMMITTING = "COMMITTING",
33
- REVEALING = "REVEALING",
34
- ACCEPTED = "ACCEPTED",
35
- FINALIZED = "FINALIZED",
36
- UNDETERMINED = "UNDETERMINED"
37
- }
38
- type GenLayerTransaction = {
39
- hash: TransactionHash;
40
- status: TransactionStatus;
41
- from_address?: string;
42
- to_address?: string;
43
- data?: Record<string, unknown>;
44
- consensus_data?: {
45
- final: boolean;
46
- leader_receipt?: {
47
- calldata: string;
48
- class_name: string;
49
- contract_state: string;
50
- eq_outputs: Record<string, unknown>;
51
- error: string | null;
52
- execution_result: string;
53
- gas_used: number;
54
- mode: string;
55
- node_config: Record<string, unknown>;
56
- pending_transactions: unknown[];
57
- vote: string;
58
- };
59
- validators?: Record<string, unknown>[];
60
- votes?: Record<string, string>;
61
- };
62
- nonce?: number;
63
- value?: number;
64
- type?: number;
65
- gaslimit?: bigint;
66
- created_at?: Date;
67
- r?: number;
68
- s?: number;
69
- v?: number;
70
- };
71
- type TransactionDataElement = string | number | bigint | boolean | Uint8Array;
72
-
73
- type ContractParamsArraySchemaElement = ContractParamsSchema | {
74
- $rep: ContractParamsSchema;
75
- };
76
- type ContractParamsSchema = "null" | "bool" | "int" | "address" | "string" | "bytes" | "any" | "array" | "dict" | {
77
- $or: ContractParamsSchema[];
78
- } | {
79
- $dict: ContractParamsSchema;
80
- } | {
81
- [key: string]: ContractParamsSchema;
82
- } | ContractParamsArraySchemaElement[];
83
- interface ContractMethodBase {
84
- params: [string, ContractParamsSchema][];
85
- kwparams: {
86
- [key: string]: ContractParamsSchema;
87
- };
88
- }
89
- interface ContractMethod extends ContractMethodBase {
90
- ret: ContractParamsSchema;
91
- readonly: boolean;
92
- }
93
- type ContractSchema = {
94
- ctor: ContractMethodBase;
95
- methods: ContractMethod[];
96
- };
97
-
98
- type GenLayerMethod = {
99
- method: "sim_fundAccount";
100
- params: [address: string, amount: number];
101
- } | {
102
- method: "eth_getTransactionByHash";
103
- params: [hash: TransactionHash];
104
- } | {
105
- method: "eth_call";
106
- params: [requestParams: any, blockNumberOrHash: string];
107
- } | {
108
- method: "eth_sedRawTransaction";
109
- params: [signedTransaction: string];
110
- } | {
111
- method: "gen_getContractSchema";
112
- params: [address: string];
113
- } | {
114
- method: "gen_getContractSchemaForCode";
115
- params: [contractCode: string];
116
- } | {
117
- method: "sim_getTransactionsForAddress";
118
- params: [address: string, filter?: "all" | "from" | "to"];
119
- } | {
120
- method: "eth_getTransactionCount";
121
- params: [address: string, block: string];
122
- };
123
- type GenLayerClient<TSimulatorChain extends SimulatorChain> = Omit<Client<Transport, TSimulatorChain>, "transport" | "getTransaction" | "readContract"> & Omit<PublicActions<Transport, TSimulatorChain>, "readContract" | "getTransaction" | "waitForTransactionReceipt"> & {
124
- request: Client<Transport, TSimulatorChain>["request"] & {
125
- <TMethod extends GenLayerMethod>(args: Extract<GenLayerMethod, {
126
- method: TMethod["method"];
127
- }>): Promise<unknown>;
128
- };
129
- readContract: (args: {
130
- account?: Account;
131
- address: Address$1;
132
- functionName: string;
133
- args: CalldataEncodable[];
134
- stateStatus?: TransactionStatus;
135
- }) => Promise<unknown>;
136
- writeContract: (args: {
137
- account?: Account;
138
- address: Address$1;
139
- functionName: string;
140
- args: CalldataEncodable[];
141
- value: bigint;
142
- leaderOnly?: boolean;
143
- }) => Promise<any>;
144
- deployContract: (args: {
145
- account?: Account;
146
- code: string;
147
- args: CalldataEncodable[];
148
- leaderOnly?: boolean;
149
- }) => Promise<`0x${string}`>;
150
- getTransaction: (args: {
151
- hash: TransactionHash;
152
- }) => Promise<GenLayerTransaction>;
153
- getCurrentNonce: (args: {
154
- address: string;
155
- }) => Promise<number>;
156
- waitForTransactionReceipt: (args: {
157
- hash: TransactionHash;
158
- status?: TransactionStatus;
159
- interval?: number;
160
- retries?: number;
161
- }) => Promise<GenLayerTransaction>;
162
- getContractSchema: (address: string) => Promise<ContractSchema>;
163
- getContractSchemaForCode: (contractCode: string) => Promise<ContractSchema>;
164
- };
165
-
166
- export { type Address$1 as Address, type CalldataEncodable, type ContractMethod, type ContractMethodBase, type ContractParamsArraySchemaElement, type ContractParamsSchema, type ContractSchema, type GenLayerClient, type GenLayerMethod, type GenLayerTransaction, type MethodDescription, SimulatorChain, type TransactionData, type TransactionDataElement, type TransactionHash, TransactionStatus };
@@ -1,7 +1,9 @@
1
1
  import {
2
+ CalldataAddress,
2
3
  TransactionStatus
3
- } from "../chunk-G7EQ6KPE.js";
4
+ } from "../chunk-2EJVFGKU.js";
4
5
  import "../chunk-MLKGABMK.js";
5
6
  export {
7
+ CalldataAddress,
6
8
  TransactionStatus
7
9
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "genlayer-js",
3
3
  "type": "module",
4
- "version": "0.6.0",
4
+ "version": "0.6.2",
5
5
  "description": "GenLayer JavaScript SDK",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
package/renovate.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "$schema": "https://docs.renovatebot.com/renovate-schema.json",
3
+ "extends": ["config:recommended", "group:recommended", "group:allNonMajor", "group:githubArtifactActions"],
4
+ "packageRules": [
5
+ {
6
+ "matchUpdateTypes": ["minor", "patch", "pin", "digest"],
7
+ "automerge": true
8
+ }
9
+ ],
10
+ "vulnerabilityAlerts": {
11
+ "enabled": true
12
+ },
13
+ "osvVulnerabilityAlerts": true,
14
+ "dependencyDashboard": true,
15
+ "npm": {
16
+ "minimumReleaseAge": "3 days"
17
+ },
18
+ "reviewers": ["denishacquin", "epsjunior", "cristiam86"],
19
+ "baseBranches": ["staging"]
20
+ }
@@ -1,5 +1,5 @@
1
1
  import type {CalldataEncodable} from "../../types/calldata";
2
- import {Address} from "../../types/calldata";
2
+ import {CalldataAddress} from "../../types/calldata";
3
3
  import * as consts from "./consts";
4
4
 
5
5
  function readULeb128(data: Uint8Array, index: {i: number}): bigint {
@@ -29,7 +29,7 @@ function decodeImpl(data: Uint8Array, index: {i: number}): CalldataEncodable {
29
29
  case BigInt(consts.SPECIAL_ADDR): {
30
30
  const res = data.slice(index.i, index.i + 20);
31
31
  index.i += 20;
32
- return new Address(res);
32
+ return new CalldataAddress(res);
33
33
  }
34
34
  }
35
35
  const type = Number(cur & 0xffn) & ((1 << consts.BITS_IN_TYPE) - 1);
@@ -1,7 +1,5 @@
1
- import {toHex} from "viem";
2
- import {toRlp} from "viem";
3
- import type {CalldataEncodable, TransactionDataElement} from "../../types/calldata";
4
- import {Address} from "../../types/calldata";
1
+ import type {CalldataEncodable} from "../../types/calldata";
2
+ import {CalldataAddress} from "../../types/calldata";
5
3
  import * as consts from "./consts";
6
4
 
7
5
  function reportError(msg: string, data: CalldataEncodable): never {
@@ -119,7 +117,7 @@ function encodeImpl(to: number[], data: CalldataEncodable) {
119
117
  }
120
118
  } else if (data instanceof Map) {
121
119
  encodeMap(to, data);
122
- } else if (data instanceof Address) {
120
+ } else if (data instanceof CalldataAddress) {
123
121
  to.push(consts.SPECIAL_ADDR);
124
122
  for (const c of data.bytes) {
125
123
  to.push(c);
@@ -142,88 +140,3 @@ export function encode(data: CalldataEncodable): Uint8Array {
142
140
  encodeImpl(arr, data);
143
141
  return new Uint8Array(arr);
144
142
  }
145
-
146
- function toStringImplMap(data: Iterable<[string, CalldataEncodable]>, to: string[]) {
147
- to.push("{");
148
- for (const [k, v] of data) {
149
- to.push(JSON.stringify(k));
150
- to.push(":");
151
- toStringImpl(v, to);
152
- }
153
- to.push("}");
154
- }
155
-
156
- function toStringImpl(data: CalldataEncodable, to: string[]) {
157
- if (data === null || data === undefined) {
158
- to.push("null");
159
- return;
160
- }
161
- if (data === true) {
162
- to.push("true");
163
- return;
164
- }
165
- if (data === false) {
166
- to.push("false");
167
- return;
168
- }
169
- switch (typeof data) {
170
- case "number": {
171
- if (!Number.isInteger(data)) {
172
- reportError("floats are not supported", data);
173
- }
174
- to.push(data.toString());
175
- return;
176
- }
177
- case "bigint": {
178
- to.push(data.toString());
179
- return;
180
- }
181
- case "string": {
182
- to.push(JSON.stringify(data));
183
- return;
184
- }
185
- case "object": {
186
- if (data instanceof Uint8Array) {
187
- to.push("b#");
188
- for (const b of data) {
189
- to.push(b.toString(16));
190
- }
191
- } else if (data instanceof Array) {
192
- to.push("[");
193
- for (const c of data) {
194
- toStringImpl(c, to);
195
- to.push(",");
196
- }
197
- to.push("]");
198
- } else if (data instanceof Map) {
199
- toStringImplMap(data.entries(), to);
200
- } else if (data instanceof Address) {
201
- to.push("addr#");
202
- for (const c of data.bytes) {
203
- to.push(c.toString(16));
204
- }
205
- } else if (Object.getPrototypeOf(data) === Object.prototype) {
206
- toStringImplMap(Object.entries(data), to);
207
- } else {
208
- reportError("unknown object type", data);
209
- }
210
- return;
211
- }
212
- default:
213
- reportError("unknown base type", data);
214
- }
215
- }
216
-
217
- export function toString(data: CalldataEncodable): string {
218
- const to: string[] = [];
219
- toStringImpl(data, to);
220
- return to.join("");
221
- }
222
-
223
- export function serialize(data: TransactionDataElement[]): `0x${string}` {
224
- return toRlp(data.map(param => toHex(param)));
225
- }
226
-
227
- export function encodeAndSerialize(data: CalldataEncodable): `0x${string}` {
228
- return serialize([encode(data)]);
229
- }
@@ -0,0 +1,3 @@
1
+ export * from "./encoder";
2
+ export * from "./decoder";
3
+ export * from "./string";
@@ -0,0 +1,83 @@
1
+ import type {CalldataEncodable} from "../../types/calldata";
2
+ import {CalldataAddress} from "../../types/calldata";
3
+
4
+ function reportError(msg: string, data: CalldataEncodable): never {
5
+ throw new Error(`invalid calldata input '${data}'`);
6
+ }
7
+
8
+ function toStringImplMap(data: Iterable<[string, CalldataEncodable]>, to: string[]) {
9
+ to.push("{");
10
+ for (const [k, v] of data) {
11
+ to.push(JSON.stringify(k));
12
+ to.push(":");
13
+ toStringImpl(v, to);
14
+ }
15
+ to.push("}");
16
+ }
17
+
18
+ function toStringImpl(data: CalldataEncodable, to: string[]) {
19
+ if (data === null || data === undefined) {
20
+ to.push("null");
21
+ return;
22
+ }
23
+ if (data === true) {
24
+ to.push("true");
25
+ return;
26
+ }
27
+ if (data === false) {
28
+ to.push("false");
29
+ return;
30
+ }
31
+ switch (typeof data) {
32
+ case "number": {
33
+ if (!Number.isInteger(data)) {
34
+ reportError("floats are not supported", data);
35
+ }
36
+ to.push(data.toString());
37
+ return;
38
+ }
39
+ case "bigint": {
40
+ to.push(data.toString());
41
+ return;
42
+ }
43
+ case "string": {
44
+ to.push(JSON.stringify(data));
45
+ return;
46
+ }
47
+ case "object": {
48
+ if (data instanceof Uint8Array) {
49
+ to.push("b#");
50
+ for (const b of data) {
51
+ to.push(b.toString(16));
52
+ }
53
+ } else if (data instanceof Array) {
54
+ to.push("[");
55
+ for (const c of data) {
56
+ toStringImpl(c, to);
57
+ to.push(",");
58
+ }
59
+ to.push("]");
60
+ } else if (data instanceof Map) {
61
+ toStringImplMap(data.entries(), to);
62
+ } else if (data instanceof CalldataAddress) {
63
+ to.push("addr#");
64
+ for (const c of data.bytes) {
65
+ to.push(c.toString(16));
66
+ }
67
+ } else if (Object.getPrototypeOf(data) === Object.prototype) {
68
+ toStringImplMap(Object.entries(data), to);
69
+ } else {
70
+ reportError("unknown object type", data);
71
+ }
72
+ return;
73
+ }
74
+ default:
75
+ reportError("unknown base type", data);
76
+ }
77
+ }
78
+
79
+ export function toString(data: CalldataEncodable): string {
80
+ const to: string[] = [];
81
+ toStringImpl(data, to);
82
+ return to.join("");
83
+ }
package/src/abi/index.ts CHANGED
@@ -1 +1,5 @@
1
- export * from "./calldata/encoder";
1
+ import * as cd from "./calldata"
2
+ import * as tx from "./transactions"
3
+
4
+ export const calldata = cd;
5
+ export const transactions = tx;
@@ -0,0 +1,11 @@
1
+ import {toHex, toRlp} from "viem";
2
+
3
+ import type {TransactionDataElement} from "../types/calldata";
4
+
5
+ export function serializeOne(data: TransactionDataElement): `0x${string}` {
6
+ return toHex(data)
7
+ }
8
+
9
+ export function serialize(data: TransactionDataElement[]): `0x${string}` {
10
+ return toRlp(data.map(serializeOne));
11
+ }
@@ -1,5 +1,5 @@
1
- import {decode} from "@/abi/calldata/decoder";
2
- import {encode, serialize} from "@/abi/calldata/encoder";
1
+ import * as calldata from "@/abi/calldata";
2
+ import {serialize, serializeOne} from "@/abi/transactions";
3
3
  import {
4
4
  Account,
5
5
  ContractSchema,
@@ -9,6 +9,40 @@ import {
9
9
  Address,
10
10
  TransactionStatus,
11
11
  } from "@/types";
12
+ import { fromHex, toHex } from "viem";
13
+
14
+ function makeCalldataObject(method: string | undefined, args: CalldataEncodable[] | undefined, kwargs: {[key: string]: CalldataEncodable} | Map<string, CalldataEncodable> | undefined): CalldataEncodable {
15
+ // this method omits args or kwargs if they are empty
16
+ // it reduces transaction size
17
+ let ret: {[key: string]: CalldataEncodable} = {}
18
+
19
+ if (method) {
20
+ ret['method'] = method
21
+ }
22
+
23
+ if (args && args.length > 0) {
24
+ ret['args'] = args
25
+ }
26
+
27
+ if (kwargs) {
28
+ if (kwargs instanceof Map) {
29
+ if (kwargs.size > 0) {
30
+ ret['kwargs'] = kwargs
31
+ }
32
+ } else {
33
+ let hasVal = false
34
+ for (const _k in kwargs) {
35
+ hasVal = true;
36
+ break
37
+ }
38
+ if (hasVal) {
39
+ ret['kwargs'] = kwargs
40
+ }
41
+ }
42
+ }
43
+
44
+ return ret
45
+ }
12
46
 
13
47
  export const contractActions = (client: GenLayerClient<SimulatorChain>) => {
14
48
  return {
@@ -19,10 +53,10 @@ export const contractActions = (client: GenLayerClient<SimulatorChain>) => {
19
53
  })) as string;
20
54
  return schema as unknown as ContractSchema;
21
55
  },
22
- getContractSchemaForCode: async (contractCode: string): Promise<ContractSchema> => {
56
+ getContractSchemaForCode: async (contractCode: string | Uint8Array): Promise<ContractSchema> => {
23
57
  const schema = (await client.request({
24
58
  method: "gen_getContractSchemaForCode",
25
- params: [contractCode],
59
+ params: [toHex(contractCode)],
26
60
  })) as string;
27
61
  return schema as unknown as ContractSchema;
28
62
  },
@@ -30,16 +64,18 @@ export const contractActions = (client: GenLayerClient<SimulatorChain>) => {
30
64
  };
31
65
 
32
66
  export const overrideContractActions = (client: GenLayerClient<SimulatorChain>) => {
33
- client.readContract = async (args: {
67
+ client.readContract = async <RawReturn extends boolean | undefined>(args: {
34
68
  account?: Account;
35
69
  address: Address;
36
70
  functionName: string;
37
- args: CalldataEncodable[];
71
+ args?: CalldataEncodable[];
72
+ kwargs?: Map<string, CalldataEncodable> | { [key: string]: CalldataEncodable }
38
73
  stateStatus?: TransactionStatus;
39
- }): Promise<unknown> => {
40
- const {account, address, functionName, args: params, stateStatus = TransactionStatus.ACCEPTED} = args;
41
- const encodedData = [encode({method: functionName, args: params}), stateStatus];
42
- const serializedData = serialize(encodedData);
74
+ rawReturn?: RawReturn;
75
+ }): Promise<RawReturn extends true ? `0x${string}` : CalldataEncodable> => {
76
+ const {account, address, functionName, args: callArgs, kwargs, stateStatus = TransactionStatus.ACCEPTED} = args;
77
+ const encodedData = calldata.encode(makeCalldataObject(functionName, callArgs, kwargs));
78
+ const serializedData = serializeOne(encodedData);
43
79
 
44
80
  const senderAddress = account?.address ?? client.account?.address;
45
81
 
@@ -50,27 +86,27 @@ export const overrideContractActions = (client: GenLayerClient<SimulatorChain>)
50
86
  };
51
87
  const result = await client.request({
52
88
  method: "eth_call",
53
- params: [requestParams, "latest"],
89
+ params: [requestParams, stateStatus == TransactionStatus.FINALIZED ? "finalized" : "latest"],
54
90
  });
55
91
 
56
- if (typeof result === "string") {
57
- const val = Uint8Array.from(atob(result), c => c.charCodeAt(0));
58
- return decode(val);
59
- } else {
60
- return "<unknown>";
92
+ if (args.rawReturn) {
93
+ return result
61
94
  }
95
+ const resultBinary = fromHex(result, "bytes")
96
+ return calldata.decode(resultBinary) as any;
62
97
  };
63
98
 
64
99
  client.writeContract = async (args: {
65
100
  account?: Account;
66
101
  address: Address;
67
102
  functionName: string;
68
- args: CalldataEncodable[];
103
+ args?: CalldataEncodable[];
104
+ kwargs?: Map<string, CalldataEncodable> | { [key: string]: CalldataEncodable }
69
105
  value: bigint;
70
106
  leaderOnly?: boolean;
71
107
  }): Promise<`0x${string}`> => {
72
- const {account, address, functionName, args: params, value = 0n, leaderOnly = false} = args;
73
- const data = [encode({method: functionName, args: params}), leaderOnly];
108
+ const {account, address, functionName, args: callArgs, kwargs, value = 0n, leaderOnly = false} = args;
109
+ const data = [calldata.encode(makeCalldataObject(functionName, callArgs, kwargs)), leaderOnly];
74
110
  const serializedData = serialize(data);
75
111
  const senderAccount = account || client.account;
76
112
 
@@ -116,12 +152,13 @@ export const overrideContractActions = (client: GenLayerClient<SimulatorChain>)
116
152
 
117
153
  client.deployContract = async (args: {
118
154
  account?: Account;
119
- code: string;
120
- args: CalldataEncodable[];
155
+ code: string | Uint8Array;
156
+ args?: CalldataEncodable[];
157
+ kwargs?: Map<string, CalldataEncodable> | { [key: string]: CalldataEncodable }
121
158
  leaderOnly?: boolean;
122
159
  }) => {
123
- const {account, code, args: constructorArgs, leaderOnly = false} = args;
124
- const data = [code, encode({args: constructorArgs}), leaderOnly];
160
+ const {account, code, args: constructorArgs, kwargs, leaderOnly = false} = args;
161
+ const data = [code, calldata.encode(makeCalldataObject(undefined, constructorArgs, kwargs)), leaderOnly];
125
162
  const serializedData = serialize(data);
126
163
  const senderAccount = account || client.account;
127
164
 
package/src/index.ts CHANGED
@@ -2,3 +2,4 @@
2
2
  export {createClient} from "./client/client";
3
3
  export {createAccount, generatePrivateKey} from "./accounts/account";
4
4
  export * as chains from "./chains";
5
+ export * as abi from "./abi";
@@ -1,8 +1,8 @@
1
- export class Address {
1
+ export class CalldataAddress {
2
2
  bytes: Uint8Array;
3
3
 
4
4
  constructor(addr: Uint8Array) {
5
- if (addr.length != 32) {
5
+ if (addr.length != 20) {
6
6
  throw new Error(`invalid address length ${addr}`);
7
7
  }
8
8
 
@@ -13,7 +13,7 @@ export class Address {
13
13
  export type CalldataEncodable =
14
14
  | null
15
15
  | boolean
16
- | Address
16
+ | CalldataAddress
17
17
  | number
18
18
  | bigint
19
19
  | string
@@ -28,10 +28,4 @@ export type MethodDescription = {
28
28
  args: Array<CalldataEncodable>;
29
29
  };
30
30
 
31
- export type TransactionData = {
32
- method: string;
33
-
34
- args: CalldataEncodable[];
35
- };
36
-
37
31
  export type TransactionDataElement = string | number | bigint | boolean | Uint8Array;
@@ -9,7 +9,7 @@ export type GenLayerMethod =
9
9
  | {method: "sim_fundAccount"; params: [address: string, amount: number]}
10
10
  | {method: "eth_getTransactionByHash"; params: [hash: TransactionHash]}
11
11
  | {method: "eth_call"; params: [requestParams: any, blockNumberOrHash: string]}
12
- | {method: "eth_sedRawTransaction"; params: [signedTransaction: string]}
12
+ | {method: "eth_sendRawTransaction"; params: [signedTransaction: string]}
13
13
  | {method: "gen_getContractSchema"; params: [address: string]}
14
14
  | {method: "gen_getContractSchemaForCode"; params: [contractCode: string]}
15
15
  | {method: "sim_getTransactionsForAddress"; params: [address: string, filter?: "all" | "from" | "to"]}
@@ -34,25 +34,29 @@ export type GenLayerClient<TSimulatorChain extends SimulatorChain> = Omit<
34
34
  args: Extract<GenLayerMethod, {method: TMethod["method"]}>,
35
35
  ): Promise<unknown>;
36
36
  };
37
- readContract: (args: {
37
+ readContract: <RawReturn extends boolean | undefined>(args: {
38
38
  account?: Account;
39
39
  address: Address;
40
40
  functionName: string;
41
- args: CalldataEncodable[];
42
41
  stateStatus?: TransactionStatus;
43
- }) => Promise<unknown>;
42
+ args?: CalldataEncodable[];
43
+ kwargs?: Map<string, CalldataEncodable> | { [key: string]: CalldataEncodable };
44
+ rawReturn?: RawReturn;
45
+ }) => Promise<RawReturn extends true ? `0x${string}` : CalldataEncodable>;
44
46
  writeContract: (args: {
45
47
  account?: Account;
46
48
  address: Address;
47
49
  functionName: string;
48
- args: CalldataEncodable[];
50
+ args?: CalldataEncodable[];
51
+ kwargs?: Map<string, CalldataEncodable> | { [key: string]: CalldataEncodable };
49
52
  value: bigint;
50
53
  leaderOnly?: boolean;
51
54
  }) => Promise<any>;
52
55
  deployContract: (args: {
53
56
  account?: Account;
54
- code: string;
55
- args: CalldataEncodable[];
57
+ code: string | Uint8Array;
58
+ args?: CalldataEncodable[];
59
+ kwargs?: Map<string, CalldataEncodable> | { [key: string]: CalldataEncodable };
56
60
  leaderOnly?: boolean;
57
61
  }) => Promise<`0x${string}`>;
58
62
  getTransaction: (args: {hash: TransactionHash}) => Promise<GenLayerTransaction>;
@@ -64,5 +68,5 @@ export type GenLayerClient<TSimulatorChain extends SimulatorChain> = Omit<
64
68
  retries?: number;
65
69
  }) => Promise<GenLayerTransaction>;
66
70
  getContractSchema: (address: string) => Promise<ContractSchema>;
67
- getContractSchemaForCode: (contractCode: string) => Promise<ContractSchema>;
71
+ getContractSchemaForCode: (contractCode: string | Uint8Array) => Promise<ContractSchema>;
68
72
  };
@@ -1,5 +1,5 @@
1
1
  export * from "./accounts";
2
- export {CalldataEncodable, MethodDescription, TransactionData} from "./calldata";
2
+ export {CalldataEncodable, MethodDescription, CalldataAddress} from "./calldata";
3
3
  export * from "./chains";
4
4
  export * from "./clients";
5
5
  export * from "./contracts";