genlayer-js 0.4.0 → 0.4.1

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,7 @@
1
1
 
2
2
 
3
+ ## 0.4.1 (2024-11-20)
4
+
3
5
  ## 0.4.0 (2024-11-14)
4
6
 
5
7
 
package/dist/index.cjs CHANGED
@@ -222,8 +222,9 @@ var overrideContractActions = (client) => {
222
222
  return result;
223
223
  };
224
224
  client.writeContract = async (args) => {
225
- const { account, address, functionName, args: params, value = 0n } = args;
226
- const encodedData = encodeAndSerialize({ method: functionName, args: params });
225
+ const { account, address, functionName, args: params, value = 0n, leader_only = false } = args;
226
+ const data = [encode({ method: functionName, args: params }), leader_only];
227
+ const serializedData = serialize(data);
227
228
  const senderAccount = account || client.account;
228
229
  if (!senderAccount) {
229
230
  throw new Error(
@@ -235,7 +236,7 @@ var overrideContractActions = (client) => {
235
236
  }
236
237
  const nonce = await client.getCurrentNonce({ address: senderAccount.address });
237
238
  const signedTransaction = await senderAccount.signTransaction({
238
- data: encodedData,
239
+ data: serializedData,
239
240
  to: address,
240
241
  value,
241
242
  type: "legacy",
@@ -248,8 +249,8 @@ var overrideContractActions = (client) => {
248
249
  return result;
249
250
  };
250
251
  client.deployContract = async (args) => {
251
- const { account, code, args: constructorArgs } = args;
252
- const data = [code, encode({ args: constructorArgs })];
252
+ const { account, code, args: constructorArgs, leader_only = false } = args;
253
+ const data = [code, encode({ args: constructorArgs }), leader_only];
253
254
  const serializedData = serialize(data);
254
255
  const senderAccount = account || client.account;
255
256
  if (!senderAccount) {
package/dist/index.js CHANGED
@@ -222,8 +222,9 @@ var overrideContractActions = (client) => {
222
222
  return result;
223
223
  };
224
224
  client.writeContract = async (args) => {
225
- const { account, address, functionName, args: params, value = 0n } = args;
226
- const encodedData = encodeAndSerialize({ method: functionName, args: params });
225
+ const { account, address, functionName, args: params, value = 0n, leader_only = false } = args;
226
+ const data = [encode({ method: functionName, args: params }), leader_only];
227
+ const serializedData = serialize(data);
227
228
  const senderAccount = account || client.account;
228
229
  if (!senderAccount) {
229
230
  throw new Error(
@@ -235,7 +236,7 @@ var overrideContractActions = (client) => {
235
236
  }
236
237
  const nonce = await client.getCurrentNonce({ address: senderAccount.address });
237
238
  const signedTransaction = await senderAccount.signTransaction({
238
- data: encodedData,
239
+ data: serializedData,
239
240
  to: address,
240
241
  value,
241
242
  type: "legacy",
@@ -248,8 +249,8 @@ var overrideContractActions = (client) => {
248
249
  return result;
249
250
  };
250
251
  client.deployContract = async (args) => {
251
- const { account, code, args: constructorArgs } = args;
252
- const data = [code, encode({ args: constructorArgs })];
252
+ const { account, code, args: constructorArgs, leader_only = false } = args;
253
+ const data = [code, encode({ args: constructorArgs }), leader_only];
253
254
  const serializedData = serialize(data);
254
255
  const senderAccount = account || client.account;
255
256
  if (!senderAccount) {
@@ -112,11 +112,13 @@ type GenLayerClient<TSimulatorChain extends SimulatorChain> = Omit<Client<Transp
112
112
  functionName: string;
113
113
  args: CalldataEncodable[];
114
114
  value: bigint;
115
+ leader_only?: boolean;
115
116
  }) => Promise<any>;
116
117
  deployContract: (args: {
117
118
  account?: Account;
118
119
  code: string;
119
120
  args: CalldataEncodable[];
121
+ leader_only?: boolean;
120
122
  }) => Promise<any>;
121
123
  getTransaction: (args: {
122
124
  hash: TransactionHash;
@@ -112,11 +112,13 @@ type GenLayerClient<TSimulatorChain extends SimulatorChain> = Omit<Client<Transp
112
112
  functionName: string;
113
113
  args: CalldataEncodable[];
114
114
  value: bigint;
115
+ leader_only?: boolean;
115
116
  }) => Promise<any>;
116
117
  deployContract: (args: {
117
118
  account?: Account;
118
119
  code: string;
119
120
  args: CalldataEncodable[];
121
+ leader_only?: boolean;
120
122
  }) => Promise<any>;
121
123
  getTransaction: (args: {
122
124
  hash: TransactionHash;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "genlayer-js",
3
3
  "type": "module",
4
- "version": "0.4.0",
4
+ "version": "0.4.1",
5
5
  "description": "GenLayer JavaScript SDK",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -48,9 +48,11 @@ export const overrideContractActions = (client: GenLayerClient<SimulatorChain>)
48
48
  functionName: string;
49
49
  args: CalldataEncodable[];
50
50
  value: bigint;
51
+ leader_only?: boolean;
51
52
  }): Promise<any> => {
52
- const {account, address, functionName, args: params, value = 0n} = args;
53
- const encodedData = encodeAndSerialize({method: functionName, args: params});
53
+ const {account, address, functionName, args: params, value = 0n, leader_only = false} = args;
54
+ const data = [encode({method: functionName, args: params}), leader_only];
55
+ const serializedData = serialize(data);
54
56
 
55
57
  const senderAccount = account || client.account;
56
58
  if (!senderAccount) {
@@ -66,7 +68,7 @@ export const overrideContractActions = (client: GenLayerClient<SimulatorChain>)
66
68
  const nonce = await client.getCurrentNonce({address: senderAccount.address});
67
69
 
68
70
  const signedTransaction = await senderAccount.signTransaction({
69
- data: encodedData,
71
+ data: serializedData,
70
72
  to: address,
71
73
  value,
72
74
  type: "legacy",
@@ -79,9 +81,14 @@ export const overrideContractActions = (client: GenLayerClient<SimulatorChain>)
79
81
  return result;
80
82
  };
81
83
 
82
- client.deployContract = async (args: {account?: Account; code: string; args: CalldataEncodable[]}) => {
83
- const {account, code, args: constructorArgs} = args;
84
- const data = [code, encode({args: constructorArgs})];
84
+ client.deployContract = async (args: {
85
+ account?: Account;
86
+ code: string;
87
+ args: CalldataEncodable[];
88
+ leader_only?: boolean;
89
+ }) => {
90
+ const {account, code, args: constructorArgs, leader_only = false} = args;
91
+ const data = [code, encode({args: constructorArgs}), leader_only];
85
92
  const serializedData = serialize(data);
86
93
 
87
94
  const senderAccount = account || client.account;
@@ -43,8 +43,14 @@ export type GenLayerClient<TSimulatorChain extends SimulatorChain> = Omit<
43
43
  functionName: string;
44
44
  args: CalldataEncodable[];
45
45
  value: bigint;
46
+ leader_only?: boolean;
47
+ }) => Promise<any>;
48
+ deployContract: (args: {
49
+ account?: Account;
50
+ code: string;
51
+ args: CalldataEncodable[];
52
+ leader_only?: boolean;
46
53
  }) => Promise<any>;
47
- deployContract: (args: {account?: Account; code: string; args: CalldataEncodable[]}) => Promise<any>;
48
54
  getTransaction: (args: {hash: TransactionHash}) => Promise<GenLayerTransaction>;
49
55
  getCurrentNonce: (args: {address: string}) => Promise<number>;
50
56
  waitForTransactionReceipt: (args: {