Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syntax error in src/utils/tronWeb.js #26

Open
swansontec opened this issue Feb 1, 2023 · 0 comments
Open

Syntax error in src/utils/tronWeb.js #26

swansontec opened this issue Feb 1, 2023 · 0 comments

Comments

@swansontec
Copy link

When we try to require @tronscan/client/src/utils/tronWeb.js, we get syntax errors on Node.js. It turns out that the same file can't contain ES6 export statements and CommonJS require statements, or various build tools will break.

We are currently using patch-package to patch @tronscan/client@0.2.81. Here is the diff we are using:

diff --git a/node_modules/@tronscan/client/src/utils/tronWeb.js b/node_modules/@tronscan/client/src/utils/tronWeb.js
index 6b1bc38..3f48a11 100644
--- a/node_modules/@tronscan/client/src/utils/tronWeb.js
+++ b/node_modules/@tronscan/client/src/utils/tronWeb.js
@@ -25,7 +25,7 @@ const {
 const fromHexString = hexString =>
   new Uint8Array(hexString.match(/.{1,2}/g).map(byte => parseInt(byte, 16)));
 
-export function transactionJsonToProtoBuf(transaction) {
+function transactionJsonToProtoBuf(transaction) {
   const rawData = transaction["raw_data"];
   const contractJson = rawData.contract[0];
   const transactionObj = contractJsonToProtobuf(contractJson);
@@ -52,7 +52,7 @@ export function transactionJsonToProtoBuf(transaction) {
   return transactionObj;
 }
 
-export function contractJsonToProtobuf(contract) {
+function contractJsonToProtobuf(contract) {
   const value = contract.parameter.value;
   switch (contract.type) {
 
@@ -365,3 +365,8 @@ export function contractJsonToProtobuf(contract) {
 
   }
 }
+
+module.exports = {
+  transactionJsonToProtoBuf,
+  contractJsonToProtobuf
+};

Of course, we would love to get this fix upstream.

This issue body was partially generated by patch-package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant