-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
66 additions
and
53 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,32 +1,32 @@ | ||
import { expect, it, describe } from '@jest/globals'; | ||
import BigNumber from 'bignumber.js'; | ||
import * as converters from '../../src/utils/converters'; | ||
import { fromMAS, toMAS } from '@massalabs/web3-utils'; | ||
|
||
describe('conversion tests', () => { | ||
it('test conversions to and from (all ranges and formats)', () => { | ||
const nanoMassa1 = converters.fromMAS('1.5234'); | ||
const nanoMassa1 = fromMAS('1.5234'); | ||
expect(nanoMassa1.toString()).toStrictEqual('1523400000'); | ||
const massa1 = converters.toMAS(nanoMassa1); | ||
const massa1 = toMAS(nanoMassa1); | ||
expect(massa1.toString()).toStrictEqual('1.5234'); | ||
|
||
const nanoMassa2 = converters.fromMAS(1.5234); | ||
const nanoMassa2 = fromMAS(1.5234); | ||
expect(nanoMassa2.toString()).toStrictEqual('1523400000'); | ||
const massa2 = converters.toMAS(nanoMassa2); | ||
const massa2 = toMAS(nanoMassa2); | ||
expect(massa2.toString()).toStrictEqual('1.5234'); | ||
|
||
const nanoMassa3 = converters.fromMAS(new BigNumber('1.5234')); | ||
const nanoMassa3 = fromMAS(new BigNumber('1.5234')); | ||
expect(nanoMassa3.toString()).toStrictEqual('1523400000'); | ||
const massa3 = converters.toMAS(nanoMassa3); | ||
const massa3 = toMAS(nanoMassa3); | ||
expect(massa3.toString()).toStrictEqual('1.5234'); | ||
|
||
const nanoMassa4 = converters.fromMAS(BigInt(2)); | ||
const nanoMassa4 = fromMAS(BigInt(2)); | ||
expect(nanoMassa4.toString()).toStrictEqual('2000000000'); | ||
const massa4 = converters.toMAS(nanoMassa4); | ||
const massa4 = toMAS(nanoMassa4); | ||
expect(massa4.toString()).toStrictEqual('2'); | ||
|
||
const nanoMassa5 = converters.fromMAS('1.1234567899'); | ||
const nanoMassa5 = fromMAS('1.1234567899'); | ||
expect(nanoMassa5.toString()).toStrictEqual('1123456790'); | ||
const massa5 = converters.toMAS(nanoMassa5); | ||
const massa5 = toMAS(nanoMassa5); | ||
expect(massa5.toString()).toStrictEqual('1.12345679'); | ||
}); | ||
}); |
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 |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
"outDir": "./dist" | ||
}, | ||
"include": [ | ||
"./src/**/*.ts" | ||
"./src/**/*.ts", | ||
], | ||
"exclude": [ | ||
"node_modules", | ||
|
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,25 @@ | ||
import { fromMAS } from './converters'; | ||
|
||
/* -------------------------------------------------------------------------- */ | ||
/* KEYS */ | ||
/* -------------------------------------------------------------------------- */ | ||
export const SECRET_KEY_PREFIX = 'S'; | ||
export const PUBLIC_KEY_PREFIX = 'P'; | ||
export const ADDRESS_USER_PREFIX = 'AU'; | ||
export const ADDRESS_CONTRACT_PREFIX = 'AS'; | ||
export const ADDRESS_PREFIX_LENGTH = 2; | ||
export const KEYS_VERSION_NUMBER = 0; | ||
|
||
/* -------------------------------------------------------------------------- */ | ||
/* STORAGE COST */ | ||
/* -------------------------------------------------------------------------- */ | ||
export const STORAGE_BYTE_COST = fromMAS(0.0001); | ||
export const NEW_LEDGER_ENTRY_COST = STORAGE_BYTE_COST * 4n; | ||
export const BASE_ACCOUNT_CREATION_COST = fromMAS(0.001); | ||
|
||
/* -------------------------------------------------------------------------- */ | ||
/* GAS LIMIT */ | ||
/* -------------------------------------------------------------------------- */ | ||
export const MAX_GAS_EXECUTE_SC = 3_980_167_295n; | ||
export const MAX_GAS_DEPLOYMENT = MAX_GAS_EXECUTE_SC; | ||
export const MAX_GAS_CALL = 4_294_967_295n; |
File renamed without changes.
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,5 @@ | ||
export * from './arguments'; | ||
export * from './serializers'; | ||
export * from './interfaces'; | ||
export * from './constants'; | ||
export * from './converters'; |