genlayer-js 0.4.3 → 0.4.5
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 +9 -0
- package/dist/index.cjs +4 -4
- package/dist/index.js +4 -4
- package/dist/types/index.d.cts +23 -14
- package/dist/types/index.d.ts +23 -14
- package/package.json +1 -1
- package/src/contracts/actions.ts +6 -6
- package/src/types/contracts.ts +29 -13
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
+
## 0.4.5 (2024-12-02)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* set leaderOnly parameter camelCase ([#35](https://github.com/yeagerai/genlayer-js/issues/35)) ([a6a4cae](https://github.com/yeagerai/genlayer-js/commit/a6a4caed8ab2784c2de202e34429c68eeeb0482d))
|
|
9
|
+
|
|
10
|
+
## 0.4.4 (2024-11-28)
|
|
11
|
+
|
|
3
12
|
## 0.4.3 (2024-11-26)
|
|
4
13
|
|
|
5
14
|
|
package/dist/index.cjs
CHANGED
|
@@ -222,8 +222,8 @@ var overrideContractActions = (client) => {
|
|
|
222
222
|
return result;
|
|
223
223
|
};
|
|
224
224
|
client.writeContract = async (args) => {
|
|
225
|
-
const { account, address, functionName, args: params, value = 0n,
|
|
226
|
-
const data = [encode({ method: functionName, args: params }),
|
|
225
|
+
const { account, address, functionName, args: params, value = 0n, leaderOnly = false } = args;
|
|
226
|
+
const data = [encode({ method: functionName, args: params }), leaderOnly];
|
|
227
227
|
const serializedData = serialize(data);
|
|
228
228
|
const senderAccount = account || client.account;
|
|
229
229
|
if (!senderAccount) {
|
|
@@ -249,8 +249,8 @@ var overrideContractActions = (client) => {
|
|
|
249
249
|
return result;
|
|
250
250
|
};
|
|
251
251
|
client.deployContract = async (args) => {
|
|
252
|
-
const { account, code, args: constructorArgs,
|
|
253
|
-
const data = [code, encode({ args: constructorArgs }),
|
|
252
|
+
const { account, code, args: constructorArgs, leaderOnly = false } = args;
|
|
253
|
+
const data = [code, encode({ args: constructorArgs }), leaderOnly];
|
|
254
254
|
const serializedData = serialize(data);
|
|
255
255
|
const senderAccount = account || client.account;
|
|
256
256
|
if (!senderAccount) {
|
package/dist/index.js
CHANGED
|
@@ -222,8 +222,8 @@ var overrideContractActions = (client) => {
|
|
|
222
222
|
return result;
|
|
223
223
|
};
|
|
224
224
|
client.writeContract = async (args) => {
|
|
225
|
-
const { account, address, functionName, args: params, value = 0n,
|
|
226
|
-
const data = [encode({ method: functionName, args: params }),
|
|
225
|
+
const { account, address, functionName, args: params, value = 0n, leaderOnly = false } = args;
|
|
226
|
+
const data = [encode({ method: functionName, args: params }), leaderOnly];
|
|
227
227
|
const serializedData = serialize(data);
|
|
228
228
|
const senderAccount = account || client.account;
|
|
229
229
|
if (!senderAccount) {
|
|
@@ -249,8 +249,8 @@ var overrideContractActions = (client) => {
|
|
|
249
249
|
return result;
|
|
250
250
|
};
|
|
251
251
|
client.deployContract = async (args) => {
|
|
252
|
-
const { account, code, args: constructorArgs,
|
|
253
|
-
const data = [code, encode({ args: constructorArgs }),
|
|
252
|
+
const { account, code, args: constructorArgs, leaderOnly = false } = args;
|
|
253
|
+
const data = [code, encode({ args: constructorArgs }), leaderOnly];
|
|
254
254
|
const serializedData = serialize(data);
|
|
255
255
|
const senderAccount = account || client.account;
|
|
256
256
|
if (!senderAccount) {
|
package/dist/types/index.d.cts
CHANGED
|
@@ -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
|
-
|
|
75
|
-
|
|
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 = {
|
|
@@ -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/dist/types/index.d.ts
CHANGED
|
@@ -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
|
-
|
|
75
|
-
|
|
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 = {
|
|
@@ -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
package/src/contracts/actions.ts
CHANGED
|
@@ -48,10 +48,10 @@ export const overrideContractActions = (client: GenLayerClient<SimulatorChain>)
|
|
|
48
48
|
functionName: string;
|
|
49
49
|
args: CalldataEncodable[];
|
|
50
50
|
value: bigint;
|
|
51
|
-
|
|
51
|
+
leaderOnly?: boolean;
|
|
52
52
|
}): Promise<`0x${string}`> => {
|
|
53
|
-
const {account, address, functionName, args: params, value = 0n,
|
|
54
|
-
const data = [encode({method: functionName, args: params}),
|
|
53
|
+
const {account, address, functionName, args: params, value = 0n, leaderOnly = false} = args;
|
|
54
|
+
const data = [encode({method: functionName, args: params}), leaderOnly];
|
|
55
55
|
const serializedData = serialize(data);
|
|
56
56
|
|
|
57
57
|
const senderAccount = account || client.account;
|
|
@@ -85,10 +85,10 @@ export const overrideContractActions = (client: GenLayerClient<SimulatorChain>)
|
|
|
85
85
|
account?: Account;
|
|
86
86
|
code: string;
|
|
87
87
|
args: CalldataEncodable[];
|
|
88
|
-
|
|
88
|
+
leaderOnly?: boolean;
|
|
89
89
|
}) => {
|
|
90
|
-
const {account, code, args: constructorArgs,
|
|
91
|
-
const data = [code, encode({args: constructorArgs}),
|
|
90
|
+
const {account, code, args: constructorArgs, leaderOnly = false} = args;
|
|
91
|
+
const data = [code, encode({args: constructorArgs}), leaderOnly];
|
|
92
92
|
const serializedData = serialize(data);
|
|
93
93
|
|
|
94
94
|
const senderAccount = account || client.account;
|
package/src/types/contracts.ts
CHANGED
|
@@ -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
|
-
|
|
3
|
-
|
|
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
|
};
|