import bigInteger from "big-integer" ; import { Amino , Type } from "@chainapsis/ts-amino" ; const { Method , DefineStruct } = Amino ; @ DefineStruct ( ) export class Int { private int : bigInteger . BigInteger ; param int param base param alphabet param caseSensitive constructor ( int , base ? , alphabet ? , caseSensitive ? ) { if ( typeof int === "string" ) { this . int = bigInteger ( int , base , alphabet , caseSensitive ) ; } else if ( typeof int === "number" ) { this . int = bigInteger ( int ) ; } else { this . int = bigInteger ( int ) ; } } @ Method . AminoMarshaler ( { type : Type . String } ) public marshalAmino ( ) { return this . int . toString ( 10 ) ; } public toString ( ) { return this . int . toString ( 10 ) ; } public equals ( i ) { return this . int . equals ( i . int ) ; } public gt ( i ) { return this . int . gt ( i . int ) ; } public gte ( i ) { return this . int . greaterOrEquals ( i . int ) ; } public lt ( i ) { return this . int . lt ( i . int ) ; } public lte ( i ) { return this . int . lesserOrEquals ( i . int ) ; } public add ( i ) { return new Int ( this . int . add ( i . int ) ) ; } public sub ( i ) { return new Int ( this . int . subtract ( i . int ) ) ; } public mul ( i ) { return new Int ( this . int . multiply ( i . int ) ) ; } public div ( i ) { return new Int ( this . int . divide ( i . int ) ) ; } public mod ( i ) { return new Int ( this . int . mod ( i . int ) ) ; } public neg ( ) { return new Int ( this . int . negate ( ) ) ; } } @ DefineStruct ( ) export class Uint { private uint : bigInteger . BigInteger ; param uint param base param alphabet param caseSensitive constructor ( uint , base ? , alphabet ? , caseSensitive ? ) { if ( typeof uint === "string" ) { this . uint = bigInteger ( uint , base , alphabet , caseSensitive ) ; } else if ( typeof uint === "number" ) { this . uint = bigInteger ( uint ) ; } else { this . uint = bigInteger ( uint ) ; } if ( this . uint . isNegative ( ) ) { throw new TypeError ( "Uint should not be negative" ) ; } } @ Method . AminoMarshaler ( { type : Type . String } ) public marshalAmino ( ) { return this . uint . toString ( 10 ) ; } public toString ( ) { return this . uint . toString ( 10 ) ; } public equals ( i ) { return this . uint . equals ( i . uint ) ; } public gt ( i ) { return this . uint . gt ( i . uint ) ; } public gte ( i ) { return this . uint . greaterOrEquals ( i . uint ) ; } public lt ( i ) { return this . uint . lt ( i . uint ) ; } public lte ( i ) { return this . uint . lesserOrEquals ( i . uint ) ; } public add ( i ) { return new Uint ( this . uint . add ( i . uint ) ) ; } public sub ( i ) { return new Uint ( this . uint . subtract ( i . uint ) ) ; } public mul ( i ) { return new Uint ( this . uint . multiply ( i . uint ) ) ; } public div ( i ) { return new Uint ( this . uint . divide ( i . uint ) ) ; } public mod ( i ) { return new Uint ( this . uint . mod ( i . uint ) ) ; } }