Skip to content

Commit

Permalink
Merge branch 'master' into gibson-7156-bootstrap-chainstorage-export
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Apr 25, 2023
2 parents 201d3e2 + bf2a9ff commit d375995
Show file tree
Hide file tree
Showing 79 changed files with 1,241 additions and 446 deletions.
2 changes: 2 additions & 0 deletions packages/ERTP/src/displayInfo.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// @jessie-check

import { Fail } from '@agoric/assert';
import { mustMatch } from '@agoric/store';

Expand Down
2 changes: 2 additions & 0 deletions packages/ERTP/src/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// @jessie-check

export * from './amountMath.js';
export * from './issuerKit.js';
export * from './typeGuards.js';
2 changes: 2 additions & 0 deletions packages/ERTP/src/legacy-payment-helpers.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// @jessie-check

import { mustMatch } from '@agoric/store';
import { E } from '@endo/far';
import { AmountMath } from './amountMath.js';
Expand Down
2 changes: 2 additions & 0 deletions packages/ERTP/src/mathHelpers/copyBagMathHelpers.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// @jessie-check

import {
keyEQ,
makeCopyBag,
Expand Down
2 changes: 2 additions & 0 deletions packages/ERTP/src/mathHelpers/copySetMathHelpers.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// @jessie-check

import {
keyEQ,
makeCopySet,
Expand Down
2 changes: 2 additions & 0 deletions packages/ERTP/src/mathHelpers/natMathHelpers.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// @jessie-check

import { Nat, isNat } from '@endo/nat';

import '../types-ambient.js';
Expand Down
2 changes: 2 additions & 0 deletions packages/ERTP/src/mathHelpers/setMathHelpers.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// @jessie-check

import { passStyleOf } from '@endo/marshal';
import {
assertKey,
Expand Down
2 changes: 2 additions & 0 deletions packages/ERTP/src/payment.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// @jessie-check

import { initEmpty } from '@agoric/store';
import { prepareExoClass } from '@agoric/vat-data';

Expand Down
2 changes: 2 additions & 0 deletions packages/ERTP/src/paymentLedger.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// @jessie-check

/* eslint-disable no-use-before-define */
import { isPromise } from '@endo/promise-kit';
import { mustMatch, M, keyEQ } from '@agoric/store';
Expand Down
2 changes: 2 additions & 0 deletions packages/ERTP/src/transientNotifier.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// @jessie-check

import { makeScalarBigWeakMapStore } from '@agoric/vat-data';
import { provideLazy } from '@agoric/store';
import { makeNotifierKit } from '@agoric/notifier';
Expand Down
2 changes: 2 additions & 0 deletions packages/ERTP/src/typeGuards.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// @jessie-check

import { M, matches } from '@agoric/store';

export const BrandShape = M.remotable('Brand');
Expand Down
2 changes: 2 additions & 0 deletions packages/ERTP/src/types-ambient.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// @jessie-check

/// <reference types="ses"/>

/**
Expand Down
10 changes: 5 additions & 5 deletions packages/SwingSet/src/kernel/kernel.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { assert, Fail } from '@agoric/assert';
import { isNat } from '@endo/nat';
import { importBundle } from '@endo/import-bundle';
import { makeUpgradeDisconnection } from '@agoric/internal/src/upgrade-api.js';
import { assertKnownOptions } from '../lib/assertOptions.js';
import { foreverPolicy } from '../lib/runPolicies.js';
import { kser, kslot, makeError } from '../lib/kmarshal.js';
Expand Down Expand Up @@ -815,12 +816,11 @@ export default function buildKernel(
const { meterID } = vatInfo;
let computrons;
const vatKeeper = kernelKeeper.provideVatKeeper(vatID);
const disconnectObject = {
name: 'vatUpgraded',
const disconnectionObject = makeUpgradeDisconnection(
upgradeMessage,
incarnationNumber: vatKeeper.getIncarnationNumber(),
};
const disconnectionCapData = kser(disconnectObject);
vatKeeper.getIncarnationNumber(),
);
const disconnectionCapData = kser(disconnectionObject);

/**
* Terminate the vat and translate internal-delivery results into
Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/src/types-external.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export {};
* @typedef { import('@agoric/swingset-liveslots').Message } Message
*
* @typedef { 'none' | 'ignore' | 'logAlways' | 'logFailure' | 'panic' } ResolutionPolicy
* @typedef {{ name: string, upgradeMessage: string, incarnationNumber: number }} DisconnectObject
* @typedef {import('@agoric/internal/src/upgrade-api.js').DisconnectionObject} DisconnectionObject
*
* @typedef { import('@agoric/swingset-liveslots').VatDeliveryObject } VatDeliveryObject
* @typedef { import('@agoric/swingset-liveslots').VatDeliveryResult } VatDeliveryResult
Expand Down
4 changes: 3 additions & 1 deletion packages/agoric-cli/src/commands/ec.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,9 @@ export const makeEconomicCommiteeCommand = (_logger, io = {}) => {

const info = await readLatestHead(
'published.committees.Economic_Committee.latestQuestion',
);
).catch(err => {
throw new CommanderError(1, 'VSTORAGE_FAILURE', err.message);
});
// XXX runtime shape-check
const questionDesc = /** @type {any} */ (info);

Expand Down
9 changes: 6 additions & 3 deletions packages/agoric-cli/src/commands/inter.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ const bidInvitationShape = harden({
* @param {AssetDescriptor[]} assets
*/
const makeFormatters = assets => {
const r4 = x => Math.round(x * 10_000) / 10_000;

const br = asBoardRemote;
const fmtAmtTuple = makeAmountFormatter(assets);

Expand All @@ -56,11 +58,11 @@ const makeFormatters = assets => {
const price = r => {
const [nl, nm] = fmtAmtTuple(br(r.numerator));
const [dl, dm] = fmtAmtTuple(br(r.denominator));
return `${Number(nm) / Number(dm)} ${nl}/${dl}`;
return `${r4(Number(nm) / Number(dm))} ${nl}/${dl}`;
};
/** @param {Ratio} r */
const discount = r =>
100 - (Number(r.numerator.value) / Number(r.denominator.value)) * 100;
r4(100 - (Number(r.numerator.value) / Number(r.denominator.value)) * 100);

/** @param {import('@agoric/time/src/types.js').TimestampRecord} tr */
const absTime = tr => new Date(Number(tr.absValue) * 1000).toISOString();
Expand Down Expand Up @@ -146,7 +148,7 @@ export const fmtBid = (bid, assets) => {

const {
id,
proposal: { give },
proposal: { give, want },
offerArgs: { maxBuy },
payouts,
result,
Expand All @@ -156,6 +158,7 @@ export const fmtBid = (bid, assets) => {
!error && result && result !== 'UNPUBLISHED' ? { result } : {};
const props = {
...(give ? { give: fmt.record(give) } : {}),
...(want ? { give: fmt.record(want) } : {}),
...(maxBuy ? { maxBuy: fmt.amount(maxBuy) } : {}),
...(payouts ? { payouts: fmt.record(payouts) } : resultProp),
...(error ? { error } : {}),
Expand Down
8 changes: 7 additions & 1 deletion packages/agoric-cli/src/lib/format.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,18 @@ export const asPercent = ratio => {
return (100 * Number(numerator.value)) / Number(denominator.value);
};

const { Fail, quote: q } = assert;

const isObject = x => typeof x === 'object' && x !== null;

/**
* @param {Amount} x
* @returns {Amount & { brand: BoardRemote }}
*/
export const asBoardRemote = x => {
assert('getBoardId' in x.brand);
isObject(x) || Fail`not object: ${q(x)}`;
isObject(x.brand) || Fail`not object: ${q(x.brand)}`;
'getBoardId' in x.brand || Fail`missing getBoardId: ${q(x.brand)}`;
// @ts-expect-error dynamic check
return x;
};
Expand Down
18 changes: 15 additions & 3 deletions packages/agoric-cli/src/lib/rpc.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,21 @@ export const makeVStorage = (powers, config = networkConfig) => {
`/abci_query?path=%22/custom/vstorage/${kind}/${path}%22&height=${height}`;

const readStorage = (path = 'published', { kind = 'children', height = 0 }) =>
getJSON(url(path, { kind, height })).catch(err => {
throw Error(`cannot read ${kind} of ${path}: ${err.message}`);
});
getJSON(url(path, { kind, height }))
.catch(err => {
throw Error(`cannot read ${kind} of ${path}: ${err.message}`);
})
.then(data => {
const {
result: { response },
} = data;
if (response?.code !== 0) {
throw Error(
`error code ${response?.code} reading ${kind} of ${path}: ${response.log}`,
);
}
return data;
});

return {
url,
Expand Down
4 changes: 2 additions & 2 deletions packages/agoric-cli/test/snapshots/test-inter-cli.js.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Generated by [AVA](https://avajs.dev).
--maxBuy <amount> max Collateral wanted (default: "1_000_000IbcATOM")␊
--wantMinimum <amount> only transact a bid that supplies this much␊
collateral␊
--offer-id <string> Offer id (default: "bid-978307200000")␊
--offer-id <string> Offer id (default: "bid-1680241587424")␊
--generate-only print wallet action only␊
--price <number> bid price (IST/Collateral)␊
-h, --help display help for command`
Expand All @@ -92,7 +92,7 @@ Generated by [AVA](https://avajs.dev).
--maxBuy <amount> max Collateral wanted (default: "1_000_000IbcATOM")␊
--wantMinimum <amount> only transact a bid that supplies this much␊
collateral␊
--offer-id <string> Offer id (default: "bid-978307200000")␊
--offer-id <string> Offer id (default: "bid-1680241587424")␊
--generate-only print wallet action only␊
--discount <percent> bid discount (0 to 100) or markup (0 to -100) %␊
-h, --help display help for command`
Expand Down
Binary file modified packages/agoric-cli/test/snapshots/test-inter-cli.js.snap
Binary file not shown.
Loading

0 comments on commit d375995

Please sign in to comment.