Skip to content

Commit

Permalink
fix: experiments on #3448 for suggesting
Browse files Browse the repository at this point in the history
  • Loading branch information
erights authored and Chris-Hibbert committed Aug 24, 2021
1 parent 370077f commit 58d4361
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
27 changes: 16 additions & 11 deletions packages/governance/src/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,25 @@
*/

/**
* @typedef { 'amount' | 'brand' | 'installation' | 'instance' | 'nat' |
* 'ratio' | 'string' | 'unknown' } ParamType
* @typedef { Amount | Brand | Installation | Instance | bigint |
* Ratio | string | unknown } ParamValue
*/

/**
* @typedef { Amount | Brand | Installation | Instance | bigint | Ratio |
* string | unknown } ParamValue
* @template T
* @typedef {{ type: T, name: string }} ParamRecord
*/

/**
* @typedef {ParamRecord<'amount'> & { value: Amount } |
* ParamRecord<'brand'> & { value: Brand } |
* ParamRecord<'installation'> & { value: Installation } |
* ParamRecord<'instance'> & { value: Instance } |
* ParamRecord<'nat'> & { value: bigint } |
* ParamRecord<'ratio'> & { value: Ratio } |
* ParamRecord<'string'> & { value: string } |
* ParamRecord<'unknown'> & { value: unknown }
* } ParamDescription
*/

/**
Expand Down Expand Up @@ -312,13 +324,6 @@
* @property {Handle<'Ballot'>} handle
*/

/**
* @typedef {Object} ParamDescription
* @property {string} name
* @property {ParamValue} value
* @property {ParamType} type
*/

/**
* @typedef {Object} ParamManagerBase
* @property {() => Record<Keyword,ParamDescription>} getParams
Expand Down
2 changes: 2 additions & 0 deletions packages/zoe/src/contractSupport/ratio.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { assert, details as X, q } from '@agoric/assert';
import { Nat } from '@agoric/nat';
import { AmountMath } from '@agoric/ertp';
import { natSafeMath } from './safeMath.js';
import { passStyleOf } from '@agoric/marshal';

const { multiply, floorDivide, ceilDivide, add, subtract } = natSafeMath;

Expand Down Expand Up @@ -38,6 +39,7 @@ const PERCENT = 100n;
const ratioPropertyNames = ['numerator', 'denominator'];

export const assertIsRatio = ratio => {
assert.equal(passStyleOf(ratio), 'copyRecord');
const propertyNames = Object.getOwnPropertyNames(ratio);
assert(
propertyNames.length === 2,
Expand Down

0 comments on commit 58d4361

Please sign in to comment.