genlayer-js 0.4.2 → 0.4.4

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 CHANGED
@@ -1,5 +1,14 @@
1
1
 
2
2
 
3
+ ## 0.4.4 (2024-11-28)
4
+
5
+ ## 0.4.3 (2024-11-26)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * readContract return type ([#32](https://github.com/yeagerai/genlayer-js/issues/32)) ([8222453](https://github.com/yeagerai/genlayer-js/commit/82224530cf5c28b17b43943fad92cd5782ecf1be))
11
+
3
12
  ## 0.4.2 (2024-11-22)
4
13
 
5
14
 
@@ -70,20 +70,29 @@ type GenLayerTransaction = {
70
70
  };
71
71
  type TransactionDataElement = string | number | bigint | boolean | Uint8Array;
72
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
+ }
73
93
  type ContractSchema = {
74
- abi: Array<{
75
- inputs?: Array<{
76
- name: string;
77
- type: string;
78
- }>;
79
- name?: string;
80
- outputs?: Array<{
81
- name: string;
82
- type: string;
83
- }>;
84
- type: "constructor" | "function";
85
- }>;
86
- class: string;
94
+ ctor: ContractMethodBase;
95
+ methods: ContractMethod[];
87
96
  };
88
97
 
89
98
  type GenLayerMethod = {
@@ -122,7 +131,7 @@ type GenLayerClient<TSimulatorChain extends SimulatorChain> = Omit<Client<Transp
122
131
  address: Address$1;
123
132
  functionName: string;
124
133
  args: CalldataEncodable[];
125
- }) => Promise<`0x${string}`>;
134
+ }) => Promise<unknown>;
126
135
  writeContract: (args: {
127
136
  account?: Account;
128
137
  address: Address$1;
@@ -153,4 +162,4 @@ type GenLayerClient<TSimulatorChain extends SimulatorChain> = Omit<Client<Transp
153
162
  getContractSchemaForCode: (contractCode: string) => Promise<ContractSchema>;
154
163
  };
155
164
 
156
- export { type Address$1 as Address, type CalldataEncodable, type ContractSchema, type GenLayerClient, type GenLayerMethod, type GenLayerTransaction, type MethodDescription, SimulatorChain, type TransactionData, type TransactionDataElement, type TransactionHash, TransactionStatus };
165
+ 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 };
@@ -70,20 +70,29 @@ type GenLayerTransaction = {
70
70
  };
71
71
  type TransactionDataElement = string | number | bigint | boolean | Uint8Array;
72
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
+ }
73
93
  type ContractSchema = {
74
- abi: Array<{
75
- inputs?: Array<{
76
- name: string;
77
- type: string;
78
- }>;
79
- name?: string;
80
- outputs?: Array<{
81
- name: string;
82
- type: string;
83
- }>;
84
- type: "constructor" | "function";
85
- }>;
86
- class: string;
94
+ ctor: ContractMethodBase;
95
+ methods: ContractMethod[];
87
96
  };
88
97
 
89
98
  type GenLayerMethod = {
@@ -122,7 +131,7 @@ type GenLayerClient<TSimulatorChain extends SimulatorChain> = Omit<Client<Transp
122
131
  address: Address$1;
123
132
  functionName: string;
124
133
  args: CalldataEncodable[];
125
- }) => Promise<`0x${string}`>;
134
+ }) => Promise<unknown>;
126
135
  writeContract: (args: {
127
136
  account?: Account;
128
137
  address: Address$1;
@@ -153,4 +162,4 @@ type GenLayerClient<TSimulatorChain extends SimulatorChain> = Omit<Client<Transp
153
162
  getContractSchemaForCode: (contractCode: string) => Promise<ContractSchema>;
154
163
  };
155
164
 
156
- export { type Address$1 as Address, type CalldataEncodable, type ContractSchema, type GenLayerClient, type GenLayerMethod, type GenLayerTransaction, type MethodDescription, SimulatorChain, type TransactionData, type TransactionDataElement, type TransactionHash, TransactionStatus };
165
+ 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 };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "genlayer-js",
3
3
  "type": "module",
4
- "version": "0.4.2",
4
+ "version": "0.4.4",
5
5
  "description": "GenLayer JavaScript SDK",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -26,7 +26,7 @@ export const overrideContractActions = (client: GenLayerClient<SimulatorChain>)
26
26
  address: Address;
27
27
  functionName: string;
28
28
  args: CalldataEncodable[];
29
- }): Promise<any> => {
29
+ }): Promise<unknown> => {
30
30
  const {account, address, functionName, args: params} = args;
31
31
  const encodedData = encodeAndSerialize({method: functionName, args: params});
32
32
 
@@ -39,7 +39,7 @@ export type GenLayerClient<TSimulatorChain extends SimulatorChain> = Omit<
39
39
  address: Address;
40
40
  functionName: string;
41
41
  args: CalldataEncodable[];
42
- }) => Promise<`0x${string}`>;
42
+ }) => Promise<unknown>;
43
43
  writeContract: (args: {
44
44
  account?: Account;
45
45
  address: Address;
@@ -1,15 +1,31 @@
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
+ }
27
+
1
28
  export type ContractSchema = {
2
- abi: Array<{
3
- inputs?: Array<{
4
- name: string;
5
- type: string;
6
- }>;
7
- name?: string;
8
- outputs?: Array<{
9
- name: string;
10
- type: string;
11
- }>;
12
- type: "constructor" | "function";
13
- }>;
14
- class: string;
29
+ ctor: ContractMethodBase;
30
+ methods: ContractMethod[];
15
31
  };