Skip to content

Commit

Permalink
Fixed Aptos address normalization (#123)
Browse files Browse the repository at this point in the history
* Fix

* 1 more fix

* version bump
  • Loading branch information
LukaStreamflow authored Jan 4, 2024
1 parent 46440fa commit f651b32
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"packages": [
"packages/*"
],
"version": "5.9.5",
"version": "5.9.6",
"$schema": "node_modules/lerna/schemas/lerna-schema.json"
}
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions packages/stream/aptos/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function isAddressSpecial(address: string): boolean {

/**
* Aptos has inconsistencies in how it returns addresses.
* This method normalizes them to be 64 characters long, or leaves it as SPECIAL ADDRESS (0x0 - 0xf inclusive)
* This method normalizes them to be 64+2(0x...) characters long, or leaves it as SPECIAL ADDRESS (0x0 - 0xf inclusive)
* Per this: https://github.com/aptos-labs/aptos-ts-sdk/blob/main/src/core/accountAddress.ts#L115
* */
export function normalizeAptosAddress(address: string): string {
Expand All @@ -28,10 +28,10 @@ export function normalizeAptosAddress(address: string): string {
}

const length = address.length;
if (length === 64) {
if (length === 66 || length < 3) {
return address;
}

const missingZeros = 64 - length;
const missingZeros = 66 - length;
return address.slice(0, 2) + "0".repeat(missingZeros) + address.slice(2);
}
2 changes: 1 addition & 1 deletion packages/stream/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@streamflow/stream",
"version": "5.9.5",
"version": "5.9.6",
"description": "JavaScript SDK to interact with Streamflow protocol.",
"main": "dist/index.js",
"homepage": "https://github.com/streamflow-finance/js-sdk/",
Expand Down

0 comments on commit f651b32

Please sign in to comment.