genlayer 0.36.1 → 0.37.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/README.md +24 -3
- package/dist/index.js +94 -19
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -174,15 +174,15 @@ USAGE:
|
|
|
174
174
|
OPTIONS (deploy):
|
|
175
175
|
--contract <contractPath> (Optional) Path to the intelligent contract to deploy
|
|
176
176
|
--rpc <rpcUrl> RPC URL for the network
|
|
177
|
-
--args <args...>
|
|
177
|
+
--args <args...> Contract arguments (see Argument Types below)
|
|
178
178
|
|
|
179
179
|
OPTIONS (call):
|
|
180
180
|
--rpc <rpcUrl> RPC URL for the network
|
|
181
|
-
--args <args...>
|
|
181
|
+
--args <args...> Method arguments (see Argument Types below)
|
|
182
182
|
|
|
183
183
|
OPTIONS (write):
|
|
184
184
|
--rpc <rpcUrl> RPC URL for the network
|
|
185
|
-
--args <args...>
|
|
185
|
+
--args <args...> Method arguments (see Argument Types below)
|
|
186
186
|
|
|
187
187
|
OPTIONS (schema):
|
|
188
188
|
--rpc <rpcUrl> RPC URL for the network
|
|
@@ -193,9 +193,30 @@ EXAMPLES:
|
|
|
193
193
|
genlayer deploy --contract ./my_contract.gpy --args "arg1" "arg2" 123
|
|
194
194
|
genlayer call 0x123456789abcdef greet --args "Hello World!"
|
|
195
195
|
genlayer write 0x123456789abcdef updateValue --args 42
|
|
196
|
+
genlayer write 0x123456789abcdef sendReward --args 0x6857Ed54CbafaA74Fc0357145eC0ee1536ca45A0
|
|
197
|
+
genlayer write 0x123456789abcdef setScores --args '[1, 2, 3]'
|
|
198
|
+
genlayer write 0x123456789abcdef setConfig --args '{"timeout": 30, "retries": 5}'
|
|
196
199
|
genlayer schema 0x123456789abcdef
|
|
197
200
|
```
|
|
198
201
|
|
|
202
|
+
##### Argument Types
|
|
203
|
+
|
|
204
|
+
The `--args` option automatically detects and converts values to the correct type:
|
|
205
|
+
|
|
206
|
+
| Type | Syntax | Example |
|
|
207
|
+
|------|--------|---------|
|
|
208
|
+
| Boolean | `true`, `false` | `--args true false` |
|
|
209
|
+
| Null | `null` | `--args null` |
|
|
210
|
+
| Integer | numeric value | `--args 42 -1` |
|
|
211
|
+
| Hex integer | `0x` prefix | `--args 0x1a` |
|
|
212
|
+
| String | any other value | `--args hello "multi word"` |
|
|
213
|
+
| Address | 40 hex chars with `0x` or `addr#` prefix | `--args 0x6857...a0` or `--args addr#6857...a0` |
|
|
214
|
+
| Bytes | `b#` prefix + hex | `--args b#deadbeef` |
|
|
215
|
+
| Array | JSON array in quotes | `--args '[1, 2, "three"]'` |
|
|
216
|
+
| Dict | JSON object in quotes | `--args '{"key": "value"}'` |
|
|
217
|
+
|
|
218
|
+
Large numbers that exceed JavaScript's safe integer range are automatically handled as BigInt to preserve precision.
|
|
219
|
+
|
|
199
220
|
##### Deploy Behavior
|
|
200
221
|
- If `--contract` is specified, the command will **deploy the given contract**.
|
|
201
222
|
- If `--contract` is omitted, the CLI will **search for scripts inside the `deploy` folder**, sort them, and execute them sequentially.
|
package/dist/index.js
CHANGED
|
@@ -20078,7 +20078,7 @@ var require_cli_table3 = __commonJS({
|
|
|
20078
20078
|
import { program } from "commander";
|
|
20079
20079
|
|
|
20080
20080
|
// package.json
|
|
20081
|
-
var version = "0.
|
|
20081
|
+
var version = "0.37.1";
|
|
20082
20082
|
var package_default = {
|
|
20083
20083
|
name: "genlayer",
|
|
20084
20084
|
version,
|
|
@@ -20156,7 +20156,7 @@ var package_default = {
|
|
|
20156
20156
|
dotenv: "^17.0.0",
|
|
20157
20157
|
ethers: "^6.13.4",
|
|
20158
20158
|
"fs-extra": "^11.3.0",
|
|
20159
|
-
"genlayer-js": "^0.
|
|
20159
|
+
"genlayer-js": "^0.23.0",
|
|
20160
20160
|
inquirer: "^12.0.0",
|
|
20161
20161
|
keytar: "^7.9.0",
|
|
20162
20162
|
"node-fetch": "^3.0.0",
|
|
@@ -33746,7 +33746,7 @@ init_toHex();
|
|
|
33746
33746
|
init_keccak256();
|
|
33747
33747
|
init_formatEther();
|
|
33748
33748
|
|
|
33749
|
-
// node_modules/genlayer-js/dist/chunk-
|
|
33749
|
+
// node_modules/genlayer-js/dist/chunk-C4Z24PT6.js
|
|
33750
33750
|
var chains_exports = {};
|
|
33751
33751
|
__export2(chains_exports, {
|
|
33752
33752
|
localnet: () => localnet,
|
|
@@ -43231,6 +43231,20 @@ var STAKING_ABI = [
|
|
|
43231
43231
|
inputs: [{ name: "_validator", type: "address" }],
|
|
43232
43232
|
outputs: [{ name: "", type: "uint256" }]
|
|
43233
43233
|
},
|
|
43234
|
+
{
|
|
43235
|
+
name: "validatorMinStake",
|
|
43236
|
+
type: "function",
|
|
43237
|
+
stateMutability: "view",
|
|
43238
|
+
inputs: [],
|
|
43239
|
+
outputs: [{ name: "", type: "uint256" }]
|
|
43240
|
+
},
|
|
43241
|
+
{
|
|
43242
|
+
name: "delegatorMinStake",
|
|
43243
|
+
type: "function",
|
|
43244
|
+
stateMutability: "view",
|
|
43245
|
+
inputs: [],
|
|
43246
|
+
outputs: [{ name: "", type: "uint256" }]
|
|
43247
|
+
},
|
|
43234
43248
|
{
|
|
43235
43249
|
name: "validatorsCount",
|
|
43236
43250
|
type: "function",
|
|
@@ -52730,7 +52744,9 @@ var stakingActions = (client, publicClient) => {
|
|
|
52730
52744
|
epochMinDuration,
|
|
52731
52745
|
epochZeroMinDuration,
|
|
52732
52746
|
epochOdd,
|
|
52733
|
-
epochEven
|
|
52747
|
+
epochEven,
|
|
52748
|
+
valMinStake,
|
|
52749
|
+
delMinStake
|
|
52734
52750
|
] = await Promise.all([
|
|
52735
52751
|
contract.read.epoch(),
|
|
52736
52752
|
contract.read.finalized(),
|
|
@@ -52738,7 +52754,9 @@ var stakingActions = (client, publicClient) => {
|
|
|
52738
52754
|
contract.read.epochMinDuration(),
|
|
52739
52755
|
contract.read.epochZeroMinDuration(),
|
|
52740
52756
|
contract.read.epochOdd(),
|
|
52741
|
-
contract.read.epochEven()
|
|
52757
|
+
contract.read.epochEven(),
|
|
52758
|
+
contract.read.validatorMinStake(),
|
|
52759
|
+
contract.read.delegatorMinStake()
|
|
52742
52760
|
]);
|
|
52743
52761
|
const raw = epoch % 2n === 0n ? epochEven : epochOdd;
|
|
52744
52762
|
const currentEpochData = {
|
|
@@ -52766,7 +52784,11 @@ var stakingActions = (client, publicClient) => {
|
|
|
52766
52784
|
lastFinalizedEpoch: finalized,
|
|
52767
52785
|
activeValidatorsCount: activeCount,
|
|
52768
52786
|
epochMinDuration,
|
|
52769
|
-
nextEpochEstimate
|
|
52787
|
+
nextEpochEstimate,
|
|
52788
|
+
validatorMinStake: formatStakingAmount(valMinStake),
|
|
52789
|
+
validatorMinStakeRaw: valMinStake,
|
|
52790
|
+
delegatorMinStake: formatStakingAmount(delMinStake),
|
|
52791
|
+
delegatorMinStakeRaw: delMinStake
|
|
52770
52792
|
};
|
|
52771
52793
|
},
|
|
52772
52794
|
getEpochData: async (epochNumber) => {
|
|
@@ -55120,19 +55142,72 @@ var CodeAction = class extends BaseAction {
|
|
|
55120
55142
|
};
|
|
55121
55143
|
|
|
55122
55144
|
// src/commands/contracts/index.ts
|
|
55123
|
-
|
|
55124
|
-
|
|
55125
|
-
|
|
55126
|
-
|
|
55127
|
-
|
|
55145
|
+
var ADDRESS_RE = /^0x[0-9a-fA-F]{40}$/;
|
|
55146
|
+
var ADDR_PREFIX_RE = /^addr#([0-9a-fA-F]{40})$/;
|
|
55147
|
+
var BYTES_PREFIX_RE = /^b#([0-9a-fA-F]*)$/;
|
|
55148
|
+
var HEX_RE = /^0x[0-9a-fA-F]+$/;
|
|
55149
|
+
function hexToBytes4(hex) {
|
|
55150
|
+
const bytes = new Uint8Array(hex.length / 2);
|
|
55151
|
+
for (let i2 = 0; i2 < bytes.length; i2++) {
|
|
55152
|
+
bytes[i2] = parseInt(hex.slice(i2 * 2, i2 * 2 + 2), 16);
|
|
55153
|
+
}
|
|
55154
|
+
return bytes;
|
|
55128
55155
|
}
|
|
55156
|
+
function coerceValue(value) {
|
|
55157
|
+
if (value === null) return null;
|
|
55158
|
+
if (typeof value === "boolean") return value;
|
|
55159
|
+
if (typeof value === "number") {
|
|
55160
|
+
if (Number.isSafeInteger(value)) return value;
|
|
55161
|
+
return BigInt(value);
|
|
55162
|
+
}
|
|
55163
|
+
if (Array.isArray(value)) return value.map(coerceValue);
|
|
55164
|
+
if (typeof value === "object" && value !== null) {
|
|
55165
|
+
const result = {};
|
|
55166
|
+
for (const [k, v] of Object.entries(value)) {
|
|
55167
|
+
result[k] = coerceValue(v);
|
|
55168
|
+
}
|
|
55169
|
+
return result;
|
|
55170
|
+
}
|
|
55171
|
+
if (typeof value === "string") return parseScalar(value);
|
|
55172
|
+
return value;
|
|
55173
|
+
}
|
|
55174
|
+
function parseScalar(value) {
|
|
55175
|
+
if (value === "null") return null;
|
|
55176
|
+
if (value === "true") return true;
|
|
55177
|
+
if (value === "false") return false;
|
|
55178
|
+
const addrMatch = value.match(ADDR_PREFIX_RE);
|
|
55179
|
+
if (addrMatch) return new CalldataAddress(hexToBytes4(addrMatch[1]));
|
|
55180
|
+
if (ADDRESS_RE.test(value)) return new CalldataAddress(hexToBytes4(value.slice(2)));
|
|
55181
|
+
const bytesMatch = value.match(BYTES_PREFIX_RE);
|
|
55182
|
+
if (bytesMatch) return hexToBytes4(bytesMatch[1]);
|
|
55183
|
+
if (HEX_RE.test(value)) return BigInt(value);
|
|
55184
|
+
if (!isNaN(Number(value)) && Number.isSafeInteger(Number(value))) return Number(value);
|
|
55185
|
+
if (!isNaN(Number(value))) return BigInt(value);
|
|
55186
|
+
return value;
|
|
55187
|
+
}
|
|
55188
|
+
function parseArg(value, previous = []) {
|
|
55189
|
+
try {
|
|
55190
|
+
const parsed = JSON.parse(value);
|
|
55191
|
+
if (typeof parsed === "object" || Array.isArray(parsed)) {
|
|
55192
|
+
return [...previous, coerceValue(parsed)];
|
|
55193
|
+
}
|
|
55194
|
+
} catch {
|
|
55195
|
+
}
|
|
55196
|
+
return [...previous, parseScalar(value)];
|
|
55197
|
+
}
|
|
55198
|
+
var ARGS_HELP = [
|
|
55199
|
+
"Contract arguments. Supported types:",
|
|
55200
|
+
" bool: true, false",
|
|
55201
|
+
" null: null",
|
|
55202
|
+
" int: 42, -1, 0x1a (large values auto-use BigInt)",
|
|
55203
|
+
' str: hello, "multi word"',
|
|
55204
|
+
" address: 0x6857...a0 (40 hex chars) or addr#6857...a0",
|
|
55205
|
+
" bytes: b#deadbeef",
|
|
55206
|
+
` array: '[1, 2, "three"]'`,
|
|
55207
|
+
` dict: '{"key": "value"}'`
|
|
55208
|
+
].join("\n");
|
|
55129
55209
|
function initializeContractsCommands(program2) {
|
|
55130
|
-
program2.command("deploy").description("Deploy intelligent contracts").option("--contract <contractPath>", "Path to the smart contract to deploy").option("--rpc <rpcUrl>", "RPC URL for the network").option(
|
|
55131
|
-
"--args <args...>",
|
|
55132
|
-
"Positional arguments for the contract (space-separated, use quotes for multi-word arguments)",
|
|
55133
|
-
parseArg,
|
|
55134
|
-
[]
|
|
55135
|
-
).action(async (options) => {
|
|
55210
|
+
program2.command("deploy").description("Deploy intelligent contracts").option("--contract <contractPath>", "Path to the smart contract to deploy").option("--rpc <rpcUrl>", "RPC URL for the network").option("--args <args...>", ARGS_HELP, parseArg, []).action(async (options) => {
|
|
55136
55211
|
const deployer = new DeployAction();
|
|
55137
55212
|
if (options.contract) {
|
|
55138
55213
|
await deployer.deploy(options);
|
|
@@ -55143,7 +55218,7 @@ function initializeContractsCommands(program2) {
|
|
|
55143
55218
|
});
|
|
55144
55219
|
program2.command("call <contractAddress> <method>").description("Call a contract method without sending a transaction or changing the state").option("--rpc <rpcUrl>", "RPC URL for the network").option(
|
|
55145
55220
|
"--args <args...>",
|
|
55146
|
-
|
|
55221
|
+
ARGS_HELP,
|
|
55147
55222
|
parseArg,
|
|
55148
55223
|
[]
|
|
55149
55224
|
).action(async (contractAddress, method, options) => {
|
|
@@ -55152,7 +55227,7 @@ function initializeContractsCommands(program2) {
|
|
|
55152
55227
|
});
|
|
55153
55228
|
program2.command("write <contractAddress> <method>").description("Sends a transaction to a contract method that modifies the state").option("--rpc <rpcUrl>", "RPC URL for the network").option(
|
|
55154
55229
|
"--args <args...>",
|
|
55155
|
-
|
|
55230
|
+
ARGS_HELP,
|
|
55156
55231
|
parseArg,
|
|
55157
55232
|
[]
|
|
55158
55233
|
).action(async (contractAddress, method, options) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "genlayer",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.37.1",
|
|
4
4
|
"description": "GenLayer Command Line Tool",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"dotenv": "^17.0.0",
|
|
76
76
|
"ethers": "^6.13.4",
|
|
77
77
|
"fs-extra": "^11.3.0",
|
|
78
|
-
"genlayer-js": "^0.
|
|
78
|
+
"genlayer-js": "^0.23.0",
|
|
79
79
|
"inquirer": "^12.0.0",
|
|
80
80
|
"keytar": "^7.9.0",
|
|
81
81
|
"node-fetch": "^3.0.0",
|