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

all Uint8Array output in base64 #163

Merged
merged 11 commits into from
Jul 29, 2024
Merged

all Uint8Array output in base64 #163

merged 11 commits into from
Jul 29, 2024

Conversation

mixmix
Copy link
Contributor

@mixmix mixmix commented Jul 4, 2024

Addresses: #162 - all Uint8Array output should be in base64

  • all printing should convert UInt8Array => base64 so it doesn't spam feed
    • not the logger has already had this treatment in another PR
  • this PR also adds nicer output of the program config
    • unpacks the hex
    • converts the base64 addresses to hex

src/flows/sign/index.ts Outdated Show resolved Hide resolved
@mixmix mixmix changed the base branch from dev to mixmix/fix-deserialize July 18, 2024 02:26
Base automatically changed from mixmix/fix-deserialize to dev July 18, 2024 02:42
Comment on lines +14 to +30
if (typeof rawConfig !== 'string') return rawConfig
if (!rawConfig.startsWith('0x')) return rawConfig

const hex = rawConfig.slice(2)
const utf8 = Buffer.from(hex, 'hex').toString()
const output = JSON.parse(utf8)
Object.keys(output).forEach(key => {
output[key] = output[key].map(base64toHex)
})

return output
}

function base64toHex (base64: string): string {
return Buffer.from(base64, 'base64').toString('hex')
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a new feature.
NOTE: the program_config by default stores the addresses as base64, y'all asked for hex to make comparisons easier, so I've added that

@@ -14,7 +20,7 @@ export function replacer (key, value) {
}

export function print (...args) {
console.log(...args)
console.log(...args.map(arg => stringify(arg)))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is the core change
by default, print now converts UInt8Array => base64 so that output is not spammed with walls of Ints

@mixmix
Copy link
Contributor Author

mixmix commented Jul 23, 2024

@mixmix fix conflict then bump Frankie

@mixmix mixmix self-assigned this Jul 23, 2024
@mixmix mixmix requested a review from frankiebee July 24, 2024 04:03
@mixmix
Copy link
Contributor Author

mixmix commented Jul 24, 2024

@frankiebee ready for a review. This PR changed a little over time cos of other PRs 🤷

@mixmix
Copy link
Contributor Author

mixmix commented Jul 29, 2024

@rh0delta can you final review this

@mixmix mixmix requested a review from rh0delta July 29, 2024 23:44
@rh0delta rh0delta merged commit 130b4c1 into dev Jul 29, 2024
1 check passed
@rh0delta rh0delta deleted the mixmix/print_base64 branch July 29, 2024 23:52
@github-actions github-actions bot locked and limited conversation to collaborators Jul 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants