genlayer-js 0.23.0 → 0.23.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/dist/index.cjs +38 -25
- package/dist/index.js +14 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -950,10 +950,23 @@ var _sendTransaction = async ({
|
|
|
950
950
|
chainId: `0x${client.chain.id.toString(16)}`,
|
|
951
951
|
...gasPriceHex ? { gasPrice: gasPriceHex } : {}
|
|
952
952
|
};
|
|
953
|
-
|
|
953
|
+
const evmTxHash = await client.request({
|
|
954
954
|
method: "eth_sendTransaction",
|
|
955
955
|
params: [formattedRequest]
|
|
956
956
|
});
|
|
957
|
+
const externalReceipt = await publicClient.waitForTransactionReceipt({ hash: evmTxHash });
|
|
958
|
+
if (externalReceipt.status === "reverted") {
|
|
959
|
+
throw new Error("Transaction reverted");
|
|
960
|
+
}
|
|
961
|
+
const externalNewTxEvents = _viem.parseEventLogs.call(void 0, {
|
|
962
|
+
abi: _optionalChain([client, 'access', _50 => _50.chain, 'access', _51 => _51.consensusMainContract, 'optionalAccess', _52 => _52.abi]),
|
|
963
|
+
eventName: "NewTransaction",
|
|
964
|
+
logs: externalReceipt.logs
|
|
965
|
+
});
|
|
966
|
+
if (externalNewTxEvents.length === 0) {
|
|
967
|
+
throw new Error("Transaction not processed by consensus");
|
|
968
|
+
}
|
|
969
|
+
return externalNewTxEvents[0].args["txId"];
|
|
957
970
|
};
|
|
958
971
|
try {
|
|
959
972
|
return await sendWithEncodedData(encodedData);
|
|
@@ -1070,7 +1083,7 @@ var decodeTransaction = (tx) => {
|
|
|
1070
1083
|
txData,
|
|
1071
1084
|
txDataDecoded,
|
|
1072
1085
|
currentTimestamp: tx.currentTimestamp.toString(),
|
|
1073
|
-
numOfInitialValidators: _nullishCoalesce(_optionalChain([numOfInitialValidators, 'optionalAccess',
|
|
1086
|
+
numOfInitialValidators: _nullishCoalesce(_optionalChain([numOfInitialValidators, 'optionalAccess', _53 => _53.toString, 'call', _54 => _54()]), () => ( "0")),
|
|
1074
1087
|
txSlot: tx.txSlot.toString(),
|
|
1075
1088
|
createdTimestamp: tx.createdTimestamp.toString(),
|
|
1076
1089
|
lastVoteTimestamp: tx.lastVoteTimestamp.toString(),
|
|
@@ -1078,21 +1091,21 @@ var decodeTransaction = (tx) => {
|
|
|
1078
1091
|
numOfRounds: tx.numOfRounds.toString(),
|
|
1079
1092
|
readStateBlockRange: {
|
|
1080
1093
|
...tx.readStateBlockRange,
|
|
1081
|
-
activationBlock: _nullishCoalesce(_optionalChain([tx, 'access',
|
|
1082
|
-
processingBlock: _nullishCoalesce(_optionalChain([tx, 'access',
|
|
1083
|
-
proposalBlock: _nullishCoalesce(_optionalChain([tx, 'access',
|
|
1094
|
+
activationBlock: _nullishCoalesce(_optionalChain([tx, 'access', _55 => _55.readStateBlockRange, 'optionalAccess', _56 => _56.activationBlock, 'optionalAccess', _57 => _57.toString, 'call', _58 => _58()]), () => ( "0")),
|
|
1095
|
+
processingBlock: _nullishCoalesce(_optionalChain([tx, 'access', _59 => _59.readStateBlockRange, 'optionalAccess', _60 => _60.processingBlock, 'optionalAccess', _61 => _61.toString, 'call', _62 => _62()]), () => ( "0")),
|
|
1096
|
+
proposalBlock: _nullishCoalesce(_optionalChain([tx, 'access', _63 => _63.readStateBlockRange, 'optionalAccess', _64 => _64.proposalBlock, 'optionalAccess', _65 => _65.toString, 'call', _66 => _66()]), () => ( "0"))
|
|
1084
1097
|
},
|
|
1085
1098
|
statusName: _chunkW4V73RPNcjs.transactionsStatusNumberToName[String(tx.status)],
|
|
1086
1099
|
resultName: _chunkW4V73RPNcjs.transactionResultNumberToName[String(tx.result)],
|
|
1087
1100
|
lastRound: {
|
|
1088
1101
|
...tx.lastRound,
|
|
1089
|
-
round: _nullishCoalesce(_optionalChain([tx, 'access',
|
|
1090
|
-
leaderIndex: _nullishCoalesce(_optionalChain([tx, 'access',
|
|
1091
|
-
votesCommitted: _nullishCoalesce(_optionalChain([tx, 'access',
|
|
1092
|
-
votesRevealed: _nullishCoalesce(_optionalChain([tx, 'access',
|
|
1093
|
-
appealBond: _nullishCoalesce(_optionalChain([tx, 'access',
|
|
1094
|
-
rotationsLeft: _nullishCoalesce(_optionalChain([tx, 'access',
|
|
1095
|
-
validatorVotesName: (_nullishCoalesce(_optionalChain([tx, 'access',
|
|
1102
|
+
round: _nullishCoalesce(_optionalChain([tx, 'access', _67 => _67.lastRound, 'optionalAccess', _68 => _68.round, 'optionalAccess', _69 => _69.toString, 'call', _70 => _70()]), () => ( "0")),
|
|
1103
|
+
leaderIndex: _nullishCoalesce(_optionalChain([tx, 'access', _71 => _71.lastRound, 'optionalAccess', _72 => _72.leaderIndex, 'optionalAccess', _73 => _73.toString, 'call', _74 => _74()]), () => ( "0")),
|
|
1104
|
+
votesCommitted: _nullishCoalesce(_optionalChain([tx, 'access', _75 => _75.lastRound, 'optionalAccess', _76 => _76.votesCommitted, 'optionalAccess', _77 => _77.toString, 'call', _78 => _78()]), () => ( "0")),
|
|
1105
|
+
votesRevealed: _nullishCoalesce(_optionalChain([tx, 'access', _79 => _79.lastRound, 'optionalAccess', _80 => _80.votesRevealed, 'optionalAccess', _81 => _81.toString, 'call', _82 => _82()]), () => ( "0")),
|
|
1106
|
+
appealBond: _nullishCoalesce(_optionalChain([tx, 'access', _83 => _83.lastRound, 'optionalAccess', _84 => _84.appealBond, 'optionalAccess', _85 => _85.toString, 'call', _86 => _86()]), () => ( "0")),
|
|
1107
|
+
rotationsLeft: _nullishCoalesce(_optionalChain([tx, 'access', _87 => _87.lastRound, 'optionalAccess', _88 => _88.rotationsLeft, 'optionalAccess', _89 => _89.toString, 'call', _90 => _90()]), () => ( "0")),
|
|
1108
|
+
validatorVotesName: (_nullishCoalesce(_optionalChain([tx, 'access', _91 => _91.lastRound, 'optionalAccess', _92 => _92.validatorVotes]), () => ( []))).map(
|
|
1096
1109
|
(vote) => _chunkW4V73RPNcjs.voteTypeNumberToName[String(vote)]
|
|
1097
1110
|
)
|
|
1098
1111
|
}
|
|
@@ -1174,7 +1187,7 @@ var simplifyTransactionReceipt = (tx) => {
|
|
|
1174
1187
|
var decodeLocalnetTransaction = (tx) => {
|
|
1175
1188
|
if (!tx.data) return tx;
|
|
1176
1189
|
try {
|
|
1177
|
-
const leaderReceipt = _optionalChain([tx, 'access',
|
|
1190
|
+
const leaderReceipt = _optionalChain([tx, 'access', _93 => _93.consensus_data, 'optionalAccess', _94 => _94.leader_receipt]);
|
|
1178
1191
|
if (leaderReceipt) {
|
|
1179
1192
|
const receipts = Array.isArray(leaderReceipt) ? leaderReceipt : [leaderReceipt];
|
|
1180
1193
|
receipts.forEach((receipt) => {
|
|
@@ -1205,7 +1218,7 @@ var decodeLocalnetTransaction = (tx) => {
|
|
|
1205
1218
|
}
|
|
1206
1219
|
});
|
|
1207
1220
|
}
|
|
1208
|
-
if (_optionalChain([tx, 'access',
|
|
1221
|
+
if (_optionalChain([tx, 'access', _95 => _95.data, 'optionalAccess', _96 => _96.calldata]) && typeof tx.data.calldata === "string") {
|
|
1209
1222
|
tx.data.calldata = {
|
|
1210
1223
|
base64: tx.data.calldata,
|
|
1211
1224
|
...calldataToUserFriendlyJson(b64ToArray(tx.data.calldata))
|
|
@@ -1267,8 +1280,8 @@ var transactionActions = (client, publicClient) => ({
|
|
|
1267
1280
|
return decodeLocalnetTransaction(transaction2);
|
|
1268
1281
|
}
|
|
1269
1282
|
const transaction = await publicClient.readContract({
|
|
1270
|
-
address: _optionalChain([client, 'access',
|
|
1271
|
-
abi: _optionalChain([client, 'access',
|
|
1283
|
+
address: _optionalChain([client, 'access', _97 => _97.chain, 'access', _98 => _98.consensusDataContract, 'optionalAccess', _99 => _99.address]),
|
|
1284
|
+
abi: _optionalChain([client, 'access', _100 => _100.chain, 'access', _101 => _101.consensusDataContract, 'optionalAccess', _102 => _102.abi]),
|
|
1272
1285
|
functionName: "getTransactionData",
|
|
1273
1286
|
args: [
|
|
1274
1287
|
hash,
|
|
@@ -1307,7 +1320,7 @@ var transactionActions = (client, publicClient) => ({
|
|
|
1307
1320
|
},
|
|
1308
1321
|
estimateTransactionGas: async (transactionParams) => {
|
|
1309
1322
|
const formattedParams = {
|
|
1310
|
-
from: transactionParams.from || _optionalChain([client, 'access',
|
|
1323
|
+
from: transactionParams.from || _optionalChain([client, 'access', _103 => _103.account, 'optionalAccess', _104 => _104.address]),
|
|
1311
1324
|
to: transactionParams.to,
|
|
1312
1325
|
data: transactionParams.data || "0x",
|
|
1313
1326
|
value: transactionParams.value ? `0x${transactionParams.value.toString(16)}` : "0x0"
|
|
@@ -1350,7 +1363,7 @@ var connect = async (client, network = "studionet", snapSource = "npm") => {
|
|
|
1350
1363
|
chainName: selectedNetwork.name,
|
|
1351
1364
|
rpcUrls: selectedNetwork.rpcUrls.default.http,
|
|
1352
1365
|
nativeCurrency: selectedNetwork.nativeCurrency,
|
|
1353
|
-
blockExplorerUrls: [_optionalChain([selectedNetwork, 'access',
|
|
1366
|
+
blockExplorerUrls: [_optionalChain([selectedNetwork, 'access', _105 => _105.blockExplorers, 'optionalAccess', _106 => _106.default, 'access', _107 => _107.url])]
|
|
1354
1367
|
};
|
|
1355
1368
|
const currentChainId = await window.ethereum.request({ method: "eth_chainId" });
|
|
1356
1369
|
if (currentChainId !== chainIdHex) {
|
|
@@ -1384,10 +1397,10 @@ var metamaskClient = async (snapSource = "npm") => {
|
|
|
1384
1397
|
}
|
|
1385
1398
|
const isFlask = async () => {
|
|
1386
1399
|
try {
|
|
1387
|
-
const clientVersion = await _optionalChain([window, 'access',
|
|
1400
|
+
const clientVersion = await _optionalChain([window, 'access', _108 => _108.ethereum, 'optionalAccess', _109 => _109.request, 'call', _110 => _110({
|
|
1388
1401
|
method: "web3_clientVersion"
|
|
1389
1402
|
})]);
|
|
1390
|
-
return _optionalChain([clientVersion, 'optionalAccess',
|
|
1403
|
+
return _optionalChain([clientVersion, 'optionalAccess', _111 => _111.includes, 'call', _112 => _112("flask")]);
|
|
1391
1404
|
} catch (error) {
|
|
1392
1405
|
console.error("Error detecting Flask:", error);
|
|
1393
1406
|
return false;
|
|
@@ -1395,7 +1408,7 @@ var metamaskClient = async (snapSource = "npm") => {
|
|
|
1395
1408
|
};
|
|
1396
1409
|
const installedSnaps = async () => {
|
|
1397
1410
|
try {
|
|
1398
|
-
return await _optionalChain([window, 'access',
|
|
1411
|
+
return await _optionalChain([window, 'access', _113 => _113.ethereum, 'optionalAccess', _114 => _114.request, 'call', _115 => _115({
|
|
1399
1412
|
method: "wallet_getSnaps"
|
|
1400
1413
|
})]);
|
|
1401
1414
|
} catch (error) {
|
|
@@ -1482,7 +1495,7 @@ function extractRevertReason(err) {
|
|
|
1482
1495
|
}
|
|
1483
1496
|
const revertError = err.walk((e) => e instanceof _viem.ContractFunctionRevertedError);
|
|
1484
1497
|
if (revertError instanceof _viem.ContractFunctionRevertedError) {
|
|
1485
|
-
if (_optionalChain([revertError, 'access',
|
|
1498
|
+
if (_optionalChain([revertError, 'access', _116 => _116.data, 'optionalAccess', _117 => _117.errorName])) {
|
|
1486
1499
|
return revertError.data.errorName;
|
|
1487
1500
|
}
|
|
1488
1501
|
return revertError.reason || "Unknown reason";
|
|
@@ -1570,7 +1583,7 @@ var stakingActions = (client, publicClient) => {
|
|
|
1570
1583
|
};
|
|
1571
1584
|
const getStakingAddress = () => {
|
|
1572
1585
|
const stakingConfig = client.chain.stakingContract;
|
|
1573
|
-
if (!_optionalChain([stakingConfig, 'optionalAccess',
|
|
1586
|
+
if (!_optionalChain([stakingConfig, 'optionalAccess', _118 => _118.address]) || stakingConfig.address === "0x0000000000000000000000000000000000000000") {
|
|
1574
1587
|
throw new Error("Staking is not supported on studio-based networks. Use testnet-asimov for staking operations.");
|
|
1575
1588
|
}
|
|
1576
1589
|
return stakingConfig.address;
|
|
@@ -1651,10 +1664,10 @@ var stakingActions = (client, publicClient) => {
|
|
|
1651
1664
|
return executeWrite({ to: getStakingAddress(), data });
|
|
1652
1665
|
},
|
|
1653
1666
|
validatorClaim: async (options) => {
|
|
1654
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
1667
|
+
if (!_optionalChain([options, 'optionalAccess', _119 => _119.validator]) && !client.account) {
|
|
1655
1668
|
throw new Error("Either provide validator address or initialize client with an account");
|
|
1656
1669
|
}
|
|
1657
|
-
const validatorAddress = _optionalChain([options, 'optionalAccess',
|
|
1670
|
+
const validatorAddress = _optionalChain([options, 'optionalAccess', _120 => _120.validator]) || client.account.address;
|
|
1658
1671
|
const data = _viem.encodeFunctionData.call(void 0, {
|
|
1659
1672
|
abi: _chunkNOMVZBCRcjs.STAKING_ABI,
|
|
1660
1673
|
functionName: "validatorClaim",
|
package/dist/index.js
CHANGED
|
@@ -950,10 +950,23 @@ var _sendTransaction = async ({
|
|
|
950
950
|
chainId: `0x${client.chain.id.toString(16)}`,
|
|
951
951
|
...gasPriceHex ? { gasPrice: gasPriceHex } : {}
|
|
952
952
|
};
|
|
953
|
-
|
|
953
|
+
const evmTxHash = await client.request({
|
|
954
954
|
method: "eth_sendTransaction",
|
|
955
955
|
params: [formattedRequest]
|
|
956
956
|
});
|
|
957
|
+
const externalReceipt = await publicClient.waitForTransactionReceipt({ hash: evmTxHash });
|
|
958
|
+
if (externalReceipt.status === "reverted") {
|
|
959
|
+
throw new Error("Transaction reverted");
|
|
960
|
+
}
|
|
961
|
+
const externalNewTxEvents = parseEventLogs({
|
|
962
|
+
abi: client.chain.consensusMainContract?.abi,
|
|
963
|
+
eventName: "NewTransaction",
|
|
964
|
+
logs: externalReceipt.logs
|
|
965
|
+
});
|
|
966
|
+
if (externalNewTxEvents.length === 0) {
|
|
967
|
+
throw new Error("Transaction not processed by consensus");
|
|
968
|
+
}
|
|
969
|
+
return externalNewTxEvents[0].args["txId"];
|
|
957
970
|
};
|
|
958
971
|
try {
|
|
959
972
|
return await sendWithEncodedData(encodedData);
|