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

Blob #71

Merged
merged 10 commits into from
Jul 28, 2023
Merged

Blob #71

merged 10 commits into from
Jul 28, 2023

Conversation

aaroncox
Copy link
Member

No description provided.

src/serializer/builtins.ts Outdated Show resolved Hide resolved
src/chain/blob.ts Outdated Show resolved Hide resolved
throw new Error('Invalid blob')
}

static fromString(value: string) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This needs to handle the invalid base64 padding nodeos outputs

Copy link
Member Author

Choose a reason for hiding this comment

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

I think I have tests ensuring the invalid stuff works here: 1cd6b9b

}

static fromString(value: string) {
return new this(new Uint8Array(Buffer.from(value, 'base64')))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Didn't catch this first time around but you cannot use Buffer in core, it's not available outside of node.js. You'll have to use atob and btoa (see https://developer.mozilla.org/en-US/docs/Glossary/Base64)

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch. I originally swapped to a buffer because VSCode was complaining atob was deprecated 😅

New snag... atob and btoa aren't available in nodejs 14, so our tests against that version are failing. I added back some checks to see if Buffer exists, and if so, use it.

a8526b7

}

get base64String(): string {
return Buffer.from(this.array).toString('base64')
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same here, no Buffer

@aaroncox aaroncox self-assigned this Jul 27, 2023
@aaroncox aaroncox requested a review from jnordberg July 27, 2023 23:45
Copy link
Collaborator

@jnordberg jnordberg left a comment

Choose a reason for hiding this comment

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

LGTM, just a nitpick


/**
* Create a new Bytes instance.
* @note Make sure to take a [[copy]] before mutating the bytes as the underlying source is not copied here.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Docstring says Bytes and references non existent method

Copy link
Member Author

Choose a reason for hiding this comment

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

Bytes is where I copied the class structure from instead of writing it from scratch... my sloppy copy/pasta. Whoops 😅

@aaroncox aaroncox merged commit fb8e512 into get_raw_abi Jul 28, 2023
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants