-
Notifications
You must be signed in to change notification settings - Fork 222
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
7 changed files
with
20 additions
and
39 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,7 @@ profiles: | |
attributes: | ||
region: us-west | ||
pricing: | ||
web: 100m | ||
web: .101 | ||
|
||
deployment: | ||
web: | ||
|
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 |
---|---|---|
|
@@ -22,7 +22,7 @@ profiles: | |
attributes: | ||
region: us-west | ||
pricing: | ||
web: 100m | ||
web: .1 | ||
|
||
deployment: | ||
web: | ||
|
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,38 +1,19 @@ | ||
package denom | ||
|
||
import ( | ||
"fmt" | ||
"strconv" | ||
"strings" | ||
) | ||
|
||
const ( | ||
miliAkash = 1 | ||
Akash = 1000 * miliAkash | ||
miliAkashPerAkash = 1000 | ||
) | ||
|
||
var unitSuffixes = []struct { | ||
symbol string | ||
unit uint64 | ||
}{ | ||
{"A", Akash}, | ||
{"m", miliAkash}, | ||
} | ||
|
||
// ToBase converts a unit of currency to its equivalent value in base denomination | ||
func ToBase(sval string) (uint64, error) { | ||
for _, suffix := range unitSuffixes { | ||
if !strings.HasSuffix(sval, suffix.symbol) { | ||
continue | ||
} | ||
sval := strings.TrimSuffix(sval, suffix.symbol) | ||
val, err := strconv.ParseUint(sval, 10, 64) | ||
if err != nil { | ||
return 0, err | ||
} | ||
amount := val * suffix.unit | ||
return amount, nil | ||
akash, err := strconv.ParseFloat(sval, 64) | ||
if err != nil { | ||
return 0, err | ||
} | ||
|
||
return 0, fmt.Errorf("unrecognized denomination %s", sval) | ||
amount := akash * miliAkashPerAkash | ||
return uint64(amount), nil | ||
} |
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 |
---|---|---|
|
@@ -20,7 +20,7 @@ profiles: | |
attributes: | ||
region: us-west | ||
pricing: | ||
web: 8m | ||
web: .8 | ||
|
||
deployment: | ||
web: | ||
|
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