-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathamount.ts
93 lines (80 loc) · 2.38 KB
/
amount.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import { AlgoAmount } from './types/amount'
declare global {
interface Number {
/**
* Returns an `AlgoAmount` using this number of microAlgo.
*/
microAlgos(this: number): AlgoAmount
/**
* Returns an `AlgoAmount` using this number of Algo.
*/
algos(this: number): AlgoAmount
/**
* Returns an `AlgoAmount` using this number of microAlgo.
*/
microAlgo(this: number): AlgoAmount
/**
* Returns an `AlgoAmount` using this number of Algo.
*/
algo(this: number): AlgoAmount
}
interface BigInt {
/**
* Returns an `AlgoAmount` using this number of microAlgo.
*/
microAlgo(this: bigint): AlgoAmount
/**
* Returns an `AlgoAmount` using this number of Algo.
*/
algo(this: bigint): AlgoAmount
}
}
Number.prototype.microAlgos = function () {
return AlgoAmount.MicroAlgo(this)
}
Number.prototype.algos = function () {
return AlgoAmount.Algo(this)
}
Number.prototype.microAlgo = function () {
return AlgoAmount.MicroAlgo(this)
}
Number.prototype.algo = function () {
return AlgoAmount.Algo(this)
}
BigInt.prototype.microAlgo = function () {
return AlgoAmount.MicroAlgo(this)
}
BigInt.prototype.algo = function () {
return AlgoAmount.Algo(this)
}
/** Returns an amount of Algo using AlgoAmount
* @param algos The amount of Algo
*/
export const algos = (algos: number | bigint) => {
return AlgoAmount.Algo(algos)
}
/** Returns an amount of Algo using AlgoAmount
* @param algos The amount of Algo
*/
export const algo = (algos: number | bigint) => {
return AlgoAmount.Algo(algos)
}
/** Returns an amount of µAlgo using AlgoAmount
* @param microAlgos The amount of µAlgo
*/
export const microAlgos = (microAlgos: number | bigint) => {
return AlgoAmount.MicroAlgo(microAlgos)
}
/** Returns an amount of µAlgo using AlgoAmount
* @param microAlgos The amount of µAlgo
*/
export const microAlgo = (microAlgos: number | bigint) => {
return AlgoAmount.MicroAlgo(microAlgos)
}
/** Returns an amount of µAlgo to cover standard fees for the given number of transactions using AlgoAmount
* @param numberOfTransactions The of standard transaction fees to return the amount of Algo
*/
export const transactionFees = (numberOfTransactions: number) => {
return AlgoAmount.MicroAlgo(BigInt(numberOfTransactions) * ALGORAND_MIN_TX_FEE.microAlgo)
}
export const ALGORAND_MIN_TX_FEE = AlgoAmount.MicroAlgo(1_000)