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

Fix "to" field for contract creation #210

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jchen8tw
Copy link

@jchen8tw jchen8tw commented Dec 9, 2019

in case of contract creation, "to" should be null not empty string

in case of contract creation, to should be null not empty string
@fixanoid
Copy link
Contributor

fixanoid commented Dec 9, 2019

Hi @jchen8tw does having a defined but empty to field fail in some way for you? I see that it functions properly on my installation. Thanks.

@jchen8tw
Copy link
Author

jchen8tw commented Dec 9, 2019

Hi @fixanoid
My environment is
nodejs v12.13.1
quorum-js 0.3.4
web3 1.2.4
The problem is when to field is empty string it creates the following error message:

Error: Cannot convert string to buffer. toBuffer only supports 0x-prefixed hex strings and this string was given:
    at Object.exports.toBuffer (/home/ubuntu/quorum-examples/examples/7nodes/samples/send-private-txn-quorum.js/node_modules/ethereumjs-util/dist/bytes.js:79:23)
    at Transaction.setter [as to] (/home/ubuntu/quorum-examples/examples/7nodes/samples/send-private-txn-quorum.js/node_modules/ethereumjs-util/dist/object.js:42:25)
    at /home/ubuntu/quorum-examples/examples/7nodes/samples/send-private-txn-quorum.js/node_modules/ethereumjs-util/dist/object.js:95:38
    at Array.forEach (<anonymous>)
    at Object.exports.defineProperties (/home/ubuntu/quorum-examples/examples/7nodes/samples/send-private-txn-quorum.js/node_modules/ethereumjs-util/dist/object.js:93:20)
    at new Transaction (/home/ubuntu/quorum-examples/examples/7nodes/samples/send-private-txn-quorum.js/node_modules/ethereumjs-tx/dist/transaction.js:127:27)
    at serializeSignedTransaction (/home/ubuntu/quorum-examples/examples/7nodes/samples/send-private-txn-quorum.js/node_modules/quorum-js/lib/rawTransactionManager.js:62:16)
    at /home/ubuntu/quorum-examples/examples/7nodes/samples/send-private-txn-quorum.js/node_modules/quorum-js/lib/rawTransactionManager.js:177:28
    at processTicksAndRejections (internal/process/task_queues.js:93:5)

because in

quorum-examples/examples/7nodes/samples/send-private-txn-quorum.js/node_modules/ethereumjs-util/dist/bytes.js:79:23
if (Array.isArray(v)) {
    v = Buffer.from(v);
}
else if (typeof v === 'string') {
       if (ethjsUtil.isHexString(v)) {
            v = Buffer.from(ethjsUtil.padToEven(ethjsUtil.stripHexPrefix(v)), 'hex');
        }
        else {
                throw new Error("Cannot convert string to buffer. toBuffer only supports 0x-prefixed hex strings and this string was given: " + v);
         }
}

The type of v is checked first and empty string satisfy the condition of being string
and thus throws the error since it's not 0x-prefixed
The tricky part is that the error message will print out the error string but even the string is printed out, it's empty lol.
This tooks me a while to debug....
But by changing to field to null bypass the second if and could be parsed correctly

@fixanoid
Copy link
Contributor

fixanoid commented Dec 9, 2019

Ah well, the sample is locked to beta 36 and hasn't been updated to the newer web3 yet. Thanks for correction!

@jchen8tw
Copy link
Author

Ah well, the sample is locked to beta 36 and hasn't been updated to the newer web3 yet. Thanks for correction!

No problem :)

@CLAassistant
Copy link

CLAassistant commented Oct 13, 2020

CLA assistant check
All committers have signed the CLA.

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

Successfully merging this pull request may close these issues.

None yet

3 participants