-
Notifications
You must be signed in to change notification settings - Fork 352
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix Int hashcode method * update * Update packages/utils/src/types/u8aUtils.ts Co-authored-by: Scott Twiname <[email protected]> * update2 * update2 * Update packages/utils/src/types/u8aUtils.ts Co-authored-by: Scott Twiname <[email protected]> * Update packages/utils/src/types/supported/Int.ts Co-authored-by: Scott Twiname <[email protected]> --------- Co-authored-by: Scott Twiname <[email protected]>
- Loading branch information
Showing
5 changed files
with
65 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Copyright 2020-2024 SubQuery Pte Ltd authors & contributors | ||
// SPDX-License-Identifier: GPL-3.0 | ||
|
||
import {numberToU8a, u8aConcat} from '@polkadot/util'; | ||
|
||
/** | ||
* Due to current polkadotjs `numberToU8a` not support negative number, | ||
* The helper method used to convert negative to a uint8Array | ||
* | ||
* @param byteArray | ||
*/ | ||
|
||
export function wrappedNumToU8a(num: number) { | ||
if (num >= 0) { | ||
return numberToU8a(num); | ||
} | ||
return u8aConcat(new Uint8Array([0]), numberToU8a(Math.abs(num))); | ||
} |