Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: update SubAccount.formID to handle bigger numbers (#526)
# Motivation I am having a scenario where I need to handle more than 256 subaccounts. This is my workaround for now: ``` const principal = identity.getPrincipal() const generatedAccountId = AccountIdentifier.fromPrincipal({ principal, subAccount: SubAccount.fromBytes(numberToUint8Array32(newIndexNumber)), }) ``` where `numberToUint8Array32` is the updated `fromID` method. # Changes Updates the `SubAccount.fromID` method to handle up to nine quadrillion subaccounts (which is the max safe int). It creates a buffer of 32 bytes and uses `writeBigInt64BE` to write the `id` using a 24 offest. # Tests Added one more test for `fromID` method under `account_identifier.spec.ts`. All tests are passing. # Todos - Enjoy!
- Loading branch information