-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #476 from casper-ecosystem/clValue-enhancement
Fixed Tuple3 constructor inconsistency, aligned Numerics CLValue by value type
- Loading branch information
Showing
33 changed files
with
458 additions
and
628 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
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,56 @@ | ||
import { BigNumber, BigNumberish } from '@ethersproject/bignumber'; | ||
|
||
/** | ||
* Abstract class representing a numeric value in the Casper type system. | ||
* Provides common methods and properties for numeric types. | ||
*/ | ||
export abstract class CLValueNumeric { | ||
protected value: BigNumberish; | ||
|
||
/** | ||
* The constructor is protected to ensure this class cannot be instantiated directly. | ||
* Subclasses can call this constructor using `super`. | ||
*/ | ||
protected constructor(value: BigNumberish) { | ||
this.value = value; | ||
} | ||
|
||
/** | ||
* Converts the numeric value to its byte representation. | ||
* Must be implemented by subclasses. | ||
*/ | ||
public abstract bytes(): Uint8Array; | ||
|
||
/** | ||
* Provides a string representation of the numeric value. | ||
* @returns The string representation of the value. | ||
*/ | ||
public toString(): string { | ||
return this.value.toString(); | ||
} | ||
|
||
/** | ||
* Converts the numeric value to a JavaScript number. | ||
* @returns The numeric value as a JavaScript number. | ||
*/ | ||
public toNumber(): number { | ||
const bigNumber = BigNumber.from(this.value); | ||
return bigNumber.toNumber(); | ||
} | ||
|
||
/** | ||
* Converts the instance to a JSON-compatible string. | ||
* @returns {string} The string representation of the instance. | ||
*/ | ||
public toJSON(): string { | ||
return this.toString(); | ||
} | ||
|
||
/** | ||
* Retrieves the numeric value. | ||
* @returns The numeric representation of the value. | ||
*/ | ||
public getValue(): BigNumberish { | ||
return this.value; | ||
} | ||
} |
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
Oops, something went wrong.