Skip to content

Commit

Permalink
fix: excise conventionalDecimalPlaces for now
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfig committed Nov 5, 2020
1 parent 39013c8 commit 0e7c896
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 18 deletions.
5 changes: 1 addition & 4 deletions packages/ERTP/src/displayInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,7 @@ export const assertDisplayInfo = allegedDisplayInfo => {
if (allegedDisplayInfo === undefined) {
return;
}
const displayInfoKeys = harden([
'decimalPlaces',
'conventionalDecimalPlaces',
]);
const displayInfoKeys = harden(['decimalPlaces']);
assertKeysAllowed(displayInfoKeys, allegedDisplayInfo);
};

Expand Down
7 changes: 0 additions & 7 deletions packages/ERTP/src/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,6 @@
* should not be specified.
* The decimalPlaces property should be used for *display purposes only*. Any
* other use is an anti-pattern.
* @property {number=} conventionalDecimalPlaces
* Tells the display software how many decimal places should be conventionally
* shown. So, if `conventionalDecimalPlaces` is 2, and the rendered value
* according to `decimalPlaces` is '1.2000000', then this says for the display
* software to prefer trimming it to '1.20'. This doesn't necessarily imply
* rounding, since somebody who has `1.199` may still need to be displayed
* accurately as `1.199`.
*/

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/ERTP/test/unitTests/test-issuerObj.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ test('bad display info', t => {
// @ts-ignore
t.throws(() => makeIssuerKit('fungible', MathKind.NAT, displayInfo), {
message:
'key "somethingUnexpected" was not one of the expected keys ["decimalPlaces","conventionalDecimalPlaces"]',
'key "somethingUnexpected" was not one of the expected keys ["decimalPlaces"]',
});
});

Expand Down
5 changes: 1 addition & 4 deletions packages/cosmic-swingset/lib/ag-solo/vats/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,7 @@ export function buildRootObject(vatPowers, vatParameters) {
[
'Testnet.$USD',
{
issuerArgs: [
undefined,
{ decimalPlaces: 3, conventionalDecimalPlaces: 2 },
],
issuerArgs: [undefined, { decimalPlaces: 3 }],
mintValue: 20000,
pursePetname: 'Local currency',
},
Expand Down
6 changes: 4 additions & 2 deletions packages/dapp-svelte-wallet/ui/src/Amount.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@
export let amount;
export let displayInfo;
const CONVENTIONAL_DECIMAL_PLACES = 2;
// The amount gets updated. Make this dynamic
$: ({ brand, value } = amount);
const decimate = v => {
if (Array.isArray(v)) {
return `${v.length}`;
}
const { decimalPlaces = 0, conventionalDecimalPlaces = 0 } = displayInfo || {};
const { decimalPlaces = 0 } = displayInfo || {};
const bScale = BigInt(10) ** BigInt(decimalPlaces);
const bValue = BigInt(value);
Expand All @@ -23,7 +25,7 @@
const dec0str0 = `${bDecimals}`.padStart(decimalPlaces, '0');
const dec0str = dec0str0.replace(/0+$/, '');
const decstr = dec0str.padEnd(conventionalDecimalPlaces, '0');
const decstr = dec0str.padEnd(CONVENTIONAL_DECIMAL_PLACES, '0');
const unitstr = `${bUnits}`;
if (!decstr) {
// No decimals to display.
Expand Down

0 comments on commit 0e7c896

Please sign in to comment.