Skip to content

Get Block Should Accept Hash#77

Merged
joepetrowski merged 4 commits intomasterfrom
feat/block/take-hex
Jun 14, 2020
Merged

Get Block Should Accept Hash#77
joepetrowski merged 4 commits intomasterfrom
feat/block/take-hex

Conversation

@danforbes
Copy link
Contributor

Closes #76

Copy link
Contributor

@emostov emostov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@danforbes danforbes force-pushed the feat/block/take-hex branch from bd151b7 to afd13b9 Compare June 12, 2020 15:26
Copy link
Contributor

@amaury1093 amaury1093 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, would just add the 32-byte check

@danforbes danforbes marked this pull request as draft June 12, 2020 18:33
@danforbes danforbes force-pushed the feat/block/take-hex branch 3 times, most recently from 5b6ed12 to ffb2e96 Compare June 12, 2020 18:39
@danforbes danforbes marked this pull request as ready for review June 12, 2020 18:43
@danforbes danforbes marked this pull request as draft June 12, 2020 19:00
@danforbes
Copy link
Contributor Author

Converting this to draft so I can rebase on top of the ESLint changes 🚀

@danforbes danforbes force-pushed the feat/block/take-hex branch from ffb2e96 to 3bdebdf Compare June 12, 2020 19:53
@danforbes danforbes marked this pull request as ready for review June 12, 2020 19:55
@danforbes
Copy link
Contributor Author

Okay rebased and linted 👍

src/main.ts Outdated
return api.createType('BlockHash', blockId);
} else if (isHexStr) {
throw {
error: `Cannot get block hash for ${blockId}. Hex string block IDs must be 66-characters (32-bytes) in length.`,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it'd be good to convert this to a number if some people's systems use hex. There's no way block number collides with a hash that's 32 bytes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I totally understand, but would the conversion be surfacing an additional point of failure/ misdirection that could obscure the original error? i.e if someone accidentally sends the string "Hello", but we convert it to a number before interpolating into the error message, it could throw off debugging.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think I'm with Zeke on this one but I'm still not completely sure this is what Joe was suggesting so I'll just hold off.

@danforbes danforbes force-pushed the feat/block/take-hex branch from 835aad8 to f1b656a Compare June 13, 2020 14:10
@danforbes danforbes force-pushed the feat/block/take-hex branch from f1b656a to 75934cc Compare June 13, 2020 14:14
Copy link
Collaborator

@joepetrowski joepetrowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This I can get behind, much clearer about what is an acceptable input and much more useful than before. 🎉

@joepetrowski joepetrowski merged commit 29a50b5 into master Jun 14, 2020
@joepetrowski joepetrowski deleted the feat/block/take-hex branch June 14, 2020 09:20
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.

Get Block Should Accept Hash

4 participants