-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TxBuilder: TransactionBuilder.nodeStake takes rewardDelegators
- Loading branch information
Showing
10 changed files
with
227 additions
and
14 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
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from './addr-from-pubkey' | ||
export * from './public-key-from-private' | ||
export * from './hrtime' | ||
export * from './sort' |
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,36 @@ | ||
|
||
/** | ||
* Internal function to sort an object with keys resursively | ||
* @param {any} obj - The hex string to convert. | ||
* @returns {Uint8Array} - A byte array with the converted hex string. | ||
* | ||
* */ | ||
function sortKeysRecursively(obj: any): any { | ||
if (typeof obj !== 'object' || obj === null) { | ||
return obj; | ||
} | ||
|
||
if (Array.isArray(obj)) { | ||
return obj.map(sortKeysRecursively); | ||
} | ||
|
||
const sortedKeys = Object.keys(obj).sort(); | ||
const sortedObj: Record<string, any> = {}; | ||
|
||
sortedKeys.forEach(key => { | ||
sortedObj[key] = sortKeysRecursively(obj[key]); | ||
}); | ||
|
||
return sortedObj; | ||
} | ||
|
||
/** | ||
* Stringify an object with its keys sorted alphabetically | ||
* @param {Buffer} obj - Object to stringify | ||
* @returns {string} - Stringified result | ||
*/ | ||
export function stringifyObjectWithSort(obj: Record<string, any>): string { | ||
const sortedObj = sortKeysRecursively(obj); | ||
const jsonString = JSON.stringify(sortedObj); | ||
return jsonString; | ||
} |
Oops, something went wrong.