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

Hide exposed utility functions in collections #113

Closed
austinabell opened this issue Jun 20, 2022 · 2 comments
Closed

Hide exposed utility functions in collections #113

austinabell opened this issue Jun 20, 2022 · 2 comments
Labels
invalid This doesn't seem right

Comments

@austinabell
Copy link
Contributor

austinabell commented Jun 20, 2022

Some utility functions, which should not be exposed publicly, should just be converted into internal functions to avoid confusion and make this change less breaking in the future.

Offending functions:

serializeIndex(index) {
let data = new Uint32Array([index])
let array = new Uint8Array(data.buffer)
return u8ArrayToBytes(array)
}
deserializeIndex(rawIndex) {
let array = bytesToU8Array(rawIndex)
let data = new Uint32Array(array.buffer)
return data[0]
}
getIndexRaw(key) {
let indexLookup = this.keyIndexPrefix + key
let indexRaw = near.jsvmStorageRead(indexLookup)
return indexRaw
}

serializeIndex(index) {
let data = new Uint32Array([index])
let array = new Uint8Array(data.buffer)
return u8ArrayToBytes(array)
}
deserializeIndex(rawIndex) {
let array = bytesToU8Array(rawIndex)
let data = new Uint32Array(array.buffer)
return data[0]
}

https://github.com/near/near-sdk-js/blob/master/src/collections/vector.js#L23-L28

@austinabell austinabell added the invalid This doesn't seem right label Jun 20, 2022
@ailisp
Copy link
Member

ailisp commented Jun 30, 2022

Duplicated with #83

@ailisp ailisp closed this as completed Jun 30, 2022
@austinabell
Copy link
Contributor Author

Duplicated with #83

oops, I really do have a bad memory 😂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

2 participants