genlayer-js 0.28.1 → 0.28.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/dist/index.cjs CHANGED
@@ -530,10 +530,10 @@ function extractGenCallResult(result) {
530
530
  }
531
531
  var contractActions = (client, publicClient) => {
532
532
  return {
533
- /** Retrieves the source code of a deployed contract. Localnet only. */
533
+ /** Retrieves the source code of a deployed contract. Studio only. */
534
534
  getContractCode: async (address) => {
535
- if (client.chain.id !== _chunkPZEHAYIUcjs.localnet.id) {
536
- throw new Error(`getContractCode is only available on localnet (current chain: ${client.chain.name})`);
535
+ if (!client.chain.isStudio) {
536
+ throw new Error(`getContractCode is only available on Studio networks (current chain: ${client.chain.name})`);
537
537
  }
538
538
  const result = await client.request({
539
539
  method: "gen_getContractCode",
@@ -542,10 +542,10 @@ var contractActions = (client, publicClient) => {
542
542
  const codeBytes = b64ToArray(result);
543
543
  return new TextDecoder().decode(codeBytes);
544
544
  },
545
- /** Gets the schema (methods and constructor) of a deployed contract. Localnet only. */
545
+ /** Gets the schema (methods and constructor) of a deployed contract. Studio only. */
546
546
  getContractSchema: async (address) => {
547
- if (client.chain.id !== _chunkPZEHAYIUcjs.localnet.id) {
548
- throw new Error(`getContractSchema is only available on localnet (current chain: ${client.chain.name})`);
547
+ if (!client.chain.isStudio) {
548
+ throw new Error(`getContractSchema is only available on Studio networks (current chain: ${client.chain.name})`);
549
549
  }
550
550
  const schema = await client.request({
551
551
  method: "gen_getContractSchema",
@@ -553,10 +553,10 @@ var contractActions = (client, publicClient) => {
553
553
  });
554
554
  return schema;
555
555
  },
556
- /** Generates a schema for contract code without deploying it. Localnet only. */
556
+ /** Generates a schema for contract code without deploying it. Studio only. */
557
557
  getContractSchemaForCode: async (contractCode) => {
558
- if (client.chain.id !== _chunkPZEHAYIUcjs.localnet.id) {
559
- throw new Error(`getContractSchema is only available on localnet (current chain: ${client.chain.name})`);
558
+ if (!client.chain.isStudio) {
559
+ throw new Error(`getContractSchemaForCode is only available on Studio networks (current chain: ${client.chain.name})`);
560
560
  }
561
561
  const schema = await client.request({
562
562
  method: "gen_getContractSchemaForCode",
@@ -802,8 +802,7 @@ var contractActions = (client, publicClient) => {
802
802
  estimatedGas = await client.estimateTransactionGas({
803
803
  to: client.chain.consensusMainContract.address,
804
804
  data: encodedData,
805
- value,
806
- nonce
805
+ value
807
806
  });
808
807
  } catch (err) {
809
808
  console.error("Gas estimation failed, using default 200_000:", err);
@@ -1088,6 +1087,9 @@ var _sendTransaction = async ({
1088
1087
  method: "eth_sendTransaction",
1089
1088
  params: [formattedRequest]
1090
1089
  });
1090
+ if (client.chain.isStudio) {
1091
+ return evmTxHash;
1092
+ }
1091
1093
  const externalReceipt = await publicClient.waitForTransactionReceipt({ hash: evmTxHash });
1092
1094
  if (externalReceipt.status === "reverted") {
1093
1095
  throw new Error(`Transaction reverted: EVM tx ${evmTxHash} to consensus contract ${_optionalChain([client, 'access', _68 => _68.chain, 'access', _69 => _69.consensusMainContract, 'optionalAccess', _70 => _70.address])} was reverted.`);
@@ -1384,7 +1386,7 @@ var receiptActions = (client, publicClient) => ({
1384
1386
  const requestedStatus = _chunkGJXSECNHcjs.transactionsStatusNameToNumber[status];
1385
1387
  if (transactionStatusString === requestedStatus || status === "ACCEPTED" /* ACCEPTED */ && _chunkGJXSECNHcjs.isDecidedState.call(void 0, transactionStatusString)) {
1386
1388
  let finalTransaction = transaction;
1387
- if (client.chain.id === _chunkPZEHAYIUcjs.localnet.id) {
1389
+ if (client.chain.isStudio) {
1388
1390
  finalTransaction = decodeLocalnetTransaction(transaction);
1389
1391
  }
1390
1392
  if (!fullTransaction) {
@@ -2264,6 +2266,7 @@ var PROVIDER_METHODS = /* @__PURE__ */ new Set([
2264
2266
  "eth_signTypedData_v4"
2265
2267
  ]);
2266
2268
  var assertChainMatch = async (provider, chainConfig) => {
2269
+ if (chainConfig.isStudio) return;
2267
2270
  const expectedChainIdHex = `0x${chainConfig.id.toString(16)}`;
2268
2271
  try {
2269
2272
  const currentChainId = await provider.request({ method: "eth_chainId" });
package/dist/index.js CHANGED
@@ -530,10 +530,10 @@ function extractGenCallResult(result) {
530
530
  }
531
531
  var contractActions = (client, publicClient) => {
532
532
  return {
533
- /** Retrieves the source code of a deployed contract. Localnet only. */
533
+ /** Retrieves the source code of a deployed contract. Studio only. */
534
534
  getContractCode: async (address) => {
535
- if (client.chain.id !== localnet.id) {
536
- throw new Error(`getContractCode is only available on localnet (current chain: ${client.chain.name})`);
535
+ if (!client.chain.isStudio) {
536
+ throw new Error(`getContractCode is only available on Studio networks (current chain: ${client.chain.name})`);
537
537
  }
538
538
  const result = await client.request({
539
539
  method: "gen_getContractCode",
@@ -542,10 +542,10 @@ var contractActions = (client, publicClient) => {
542
542
  const codeBytes = b64ToArray(result);
543
543
  return new TextDecoder().decode(codeBytes);
544
544
  },
545
- /** Gets the schema (methods and constructor) of a deployed contract. Localnet only. */
545
+ /** Gets the schema (methods and constructor) of a deployed contract. Studio only. */
546
546
  getContractSchema: async (address) => {
547
- if (client.chain.id !== localnet.id) {
548
- throw new Error(`getContractSchema is only available on localnet (current chain: ${client.chain.name})`);
547
+ if (!client.chain.isStudio) {
548
+ throw new Error(`getContractSchema is only available on Studio networks (current chain: ${client.chain.name})`);
549
549
  }
550
550
  const schema = await client.request({
551
551
  method: "gen_getContractSchema",
@@ -553,10 +553,10 @@ var contractActions = (client, publicClient) => {
553
553
  });
554
554
  return schema;
555
555
  },
556
- /** Generates a schema for contract code without deploying it. Localnet only. */
556
+ /** Generates a schema for contract code without deploying it. Studio only. */
557
557
  getContractSchemaForCode: async (contractCode) => {
558
- if (client.chain.id !== localnet.id) {
559
- throw new Error(`getContractSchema is only available on localnet (current chain: ${client.chain.name})`);
558
+ if (!client.chain.isStudio) {
559
+ throw new Error(`getContractSchemaForCode is only available on Studio networks (current chain: ${client.chain.name})`);
560
560
  }
561
561
  const schema = await client.request({
562
562
  method: "gen_getContractSchemaForCode",
@@ -802,8 +802,7 @@ var contractActions = (client, publicClient) => {
802
802
  estimatedGas = await client.estimateTransactionGas({
803
803
  to: client.chain.consensusMainContract.address,
804
804
  data: encodedData,
805
- value,
806
- nonce
805
+ value
807
806
  });
808
807
  } catch (err) {
809
808
  console.error("Gas estimation failed, using default 200_000:", err);
@@ -1088,6 +1087,9 @@ var _sendTransaction = async ({
1088
1087
  method: "eth_sendTransaction",
1089
1088
  params: [formattedRequest]
1090
1089
  });
1090
+ if (client.chain.isStudio) {
1091
+ return evmTxHash;
1092
+ }
1091
1093
  const externalReceipt = await publicClient.waitForTransactionReceipt({ hash: evmTxHash });
1092
1094
  if (externalReceipt.status === "reverted") {
1093
1095
  throw new Error(`Transaction reverted: EVM tx ${evmTxHash} to consensus contract ${client.chain.consensusMainContract?.address} was reverted.`);
@@ -1384,7 +1386,7 @@ var receiptActions = (client, publicClient) => ({
1384
1386
  const requestedStatus = transactionsStatusNameToNumber[status];
1385
1387
  if (transactionStatusString === requestedStatus || status === "ACCEPTED" /* ACCEPTED */ && isDecidedState(transactionStatusString)) {
1386
1388
  let finalTransaction = transaction;
1387
- if (client.chain.id === localnet.id) {
1389
+ if (client.chain.isStudio) {
1388
1390
  finalTransaction = decodeLocalnetTransaction(transaction);
1389
1391
  }
1390
1392
  if (!fullTransaction) {
@@ -2264,6 +2266,7 @@ var PROVIDER_METHODS = /* @__PURE__ */ new Set([
2264
2266
  "eth_signTypedData_v4"
2265
2267
  ]);
2266
2268
  var assertChainMatch = async (provider, chainConfig) => {
2269
+ if (chainConfig.isStudio) return;
2267
2270
  const expectedChainIdHex = `0x${chainConfig.id.toString(16)}`;
2268
2271
  try {
2269
2272
  const currentChainId = await provider.request({ method: "eth_chainId" });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "genlayer-js",
3
3
  "type": "module",
4
- "version": "0.28.1",
4
+ "version": "0.28.4",
5
5
  "description": "GenLayer JavaScript SDK",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",