Skip to content

Commit

Permalink
Merge pull request #8688 from Agoric/ta/fixup-endo-sync
Browse files Browse the repository at this point in the history
Endo sync types
  • Loading branch information
mergify[bot] authored Dec 21, 2023
2 parents 4f72580 + 990a79d commit bef63e5
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 37 deletions.
36 changes: 20 additions & 16 deletions packages/inter-protocol/src/price/roundsManager.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Fail, q } from '@agoric/assert';
import { AmountMath } from '@agoric/ertp';
import { makeTracer } from '@agoric/internal';
import { TimeMath } from '@agoric/time';
import { TimeMath, TimestampShape } from '@agoric/time';
import { M, makeScalarBigMapStore, prepareExoClassKit } from '@agoric/vat-data';
import {
calculateMedian,
Expand Down Expand Up @@ -98,21 +98,25 @@ export const prepareRoundsManagerKit = baggage =>
'RoundsManager',
{
helper: UnguardedHelperI,
contract: M.interface(
'contract',
{
authenticateQuote: M.call().rest(M.any()).returns(M.any()),
makeCreateQuote: M.call().rest(M.any()).returns(M.any()),
eligibleForSpecificRound: M.call().rest(M.any()).returns(M.boolean()),
getRoundData: M.call().rest(M.any()).returns(M.promise()),
getRoundStatus: M.call().rest(M.any()).returns(M.record()),
oracleRoundStateSuggestRound: M.call()
.rest(M.any())
.returns(M.record()),
},
// TODO(6571) stop sloppy
{ sloppy: true },
),
contract: M.interface('contract', {
authenticateQuote: M.call([M.record()]).returns(M.any()),
makeCreateQuote: M.call()
.optional({
overrideValueOut: M.number(),
timestamp: TimestampShape,
})
.returns(M.any()),
eligibleForSpecificRound: M.call(
M.any(),
M.bigint(),
TimestampShape,
).returns(M.boolean()),
getRoundData: M.call(M.any()).returns(M.promise()),
getRoundStatus: M.call(M.bigint()).returns(M.record()),
oracleRoundStateSuggestRound: M.call(M.any(), TimestampShape).returns(
M.record(),
),
}),
oracle: M.interface('oracle', {
handlePush: M.call(M.record(), M.record()).returns(M.promise()),
}),
Expand Down
6 changes: 2 additions & 4 deletions packages/internal/src/callback.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ const ownKeys =
);

/**
* @template T
* @typedef {(...args: Parameters<ReturnType<prepareAttenuator>>) => Farable<T>} MakeAttenuator
* @template {import('@endo/exo/src/exo-makers.js').Methods} T
* @typedef {(...args: Parameters<ReturnType<prepareAttenuator>>) => import('@endo/exo/src/exo-makers.js').Farable<T>} MakeAttenuator
*/

/**
Expand All @@ -28,8 +28,6 @@ const ownKeys =
* @typedef {import('./types.js').SyncCallback<I>} SyncCallback
*/

/** @template T @typedef {import('@endo/eventual-send').RemotableBrand<{}, T> & T} Farable */

/**
* @param {unknown} key
* @returns {key is PropertyKey} FIXME: should be just `PropertyKey` but TS
Expand Down
33 changes: 20 additions & 13 deletions packages/vat-data/src/exo-utils.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @jessie-check

/* eslint-disable @typescript-eslint/prefer-ts-expect-error -- for casting from deprecated types that aren't worth fixing */
import { initEmpty } from '@agoric/store';

import { provide, VatData as globalVatData } from './vat-data-bindings.js';
Expand Down Expand Up @@ -31,6 +31,7 @@ export const ignoreContext =
harden(ignoreContext);

// TODO: Find a good home for this function used by @agoric/vat-data and testing code
/** @param {import('@agoric/swingset-liveslots').VatData} VatData */
export const makeExoUtils = VatData => {
const {
defineKind,
Expand All @@ -41,6 +42,7 @@ export const makeExoUtils = VatData => {
} = VatData;

/**
* @deprecated Use Exos/ExoClasses instead of Kinds
* @param {Baggage} baggage
* @param {string} kindName
* @returns {DurableKindHandle}
Expand Down Expand Up @@ -101,9 +103,11 @@ export const makeExoUtils = VatData => {
* self: T,
* state: ReturnType<I>
* }>} [options]
* @returns {(...args: Parameters<I>) => (T & RemotableBrand<{}, T>)}
* @returns {(...args: Parameters<I>) => import('@endo/exo/src/exo-makers.js').Guarded<T>}
*/
const defineVirtualExoClass = (tag, interfaceGuard, init, methods, options) =>
// eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error
// @ts-ignore cast
defineKind(tag, init, methods, {
...options,
thisfulMethods: true,
Expand All @@ -118,14 +122,14 @@ export const makeExoUtils = VatData => {
* @param {InterfaceGuardKit | undefined} interfaceGuardKit
* @param {I} init
* @param {T & ThisType<{
* facets: T,
* facets: import('@endo/exo/src/exo-makers.js').GuardedKit<T>,
* state: ReturnType<I>
* }> } facets
* @param {DefineKindOptions<{
* facets: T,
* state: ReturnType<I>
* }>} [options]
* @returns {(...args: Parameters<I>) => (T & RemotableBrand<{}, T>)}
* @returns {(...args: Parameters<I>) => import('@endo/exo/src/exo-makers.js').GuardedKit<T>}
*/
const defineVirtualExoClassKit = (
tag,
Expand All @@ -134,6 +138,7 @@ export const makeExoUtils = VatData => {
facets,
options,
) =>
// @ts-ignore cast
defineKindMulti(tag, init, facets, {
...options,
thisfulMethods: true,
Expand All @@ -155,7 +160,7 @@ export const makeExoUtils = VatData => {
* self: T,
* state: ReturnType<I>
* }>} [options]
* @returns {(...args: Parameters<I>) => (T & RemotableBrand<{}, T>)}
* @returns {(...args: Parameters<I>) => import('@endo/exo/src/exo-makers.js').Guarded<T>}
*/
const defineDurableExoClass = (
kindHandle,
Expand All @@ -164,6 +169,7 @@ export const makeExoUtils = VatData => {
methods,
options,
) =>
// @ts-ignore cast
defineDurableKind(kindHandle, init, methods, {
...options,
thisfulMethods: true,
Expand All @@ -178,14 +184,14 @@ export const makeExoUtils = VatData => {
* @param {InterfaceGuardKit | undefined} interfaceGuardKit
* @param {I} init
* @param {T & ThisType<{
* facets: T,
* facets: import('@endo/exo/src/exo-makers.js').GuardedKit<T>,
* state: ReturnType<I>
* }> } facets
* @param {DefineKindOptions<{
* facets: T,
* state: ReturnType<I>
* }>} [options]
* @returns {(...args: Parameters<I>) => (T & RemotableBrand<{}, T>)}
* @returns {(...args: Parameters<I>) => import('@endo/exo/src/exo-makers.js').GuardedKit<T>}
*/
const defineDurableExoClassKit = (
kindHandle,
Expand All @@ -194,6 +200,7 @@ export const makeExoUtils = VatData => {
facets,
options,
) =>
// @ts-ignore cast
defineDurableKindMulti(kindHandle, init, facets, {
...options,
thisfulMethods: true,
Expand All @@ -216,7 +223,7 @@ export const makeExoUtils = VatData => {
* self: T,
* state: ReturnType<I>
* }>} [options]
* @returns {(...args: Parameters<I>) => (T & RemotableBrand<{}, T>)}
* @returns {(...args: Parameters<I>) => import('@endo/exo/src/exo-makers.js').Guarded<T>}
*/
const prepareExoClass = (
baggage,
Expand All @@ -243,14 +250,14 @@ export const makeExoUtils = VatData => {
* @param {InterfaceGuardKit | undefined} interfaceGuardKit
* @param {I} init
* @param {T & ThisType<{
* facets: T,
* facets: import('@endo/exo/src/exo-makers.js').GuardedKit<T>,
* state: ReturnType<I>
* }> } facets
* @param {DefineKindOptions<{
* facets: T,
* state: ReturnType<I>
* }>} [options]
* @returns {(...args: Parameters<I>) => (T & RemotableBrand<{}, T>)}
* @returns {(...args: Parameters<I>) => import('@endo/exo/src/exo-makers.js').GuardedKit<T>}
*/
const prepareExoClassKit = (
baggage,
Expand All @@ -276,7 +283,7 @@ export const makeExoUtils = VatData => {
* @param {InterfaceGuard | undefined} interfaceGuard
* @param {M} methods
* @param {DefineKindOptions<{ self: M }>} [options]
* @returns {M & RemotableBrand<{}, M>}
* @returns {import('@endo/exo/src/exo-makers.js').Guarded<M>}
*/
const prepareExo = (
baggage,
Expand Down Expand Up @@ -305,7 +312,7 @@ export const makeExoUtils = VatData => {
* @param {string} kindName
* @param {M} methods
* @param {DefineKindOptions<{ self: M }>} [options]
* @returns {M & RemotableBrand<{}, M>}
* @returns {import('@endo/exo/src/exo-makers.js').Guarded<M>}
*/
const prepareSingleton = (baggage, kindName, methods, options = undefined) =>
prepareExo(baggage, kindName, undefined, methods, options);
Expand All @@ -319,8 +326,8 @@ export const makeExoUtils = VatData => {
prepareExoClass,
prepareExoClassKit,
prepareExo,
prepareSingleton,

prepareSingleton,
provideKindHandle,
prepareKind,
prepareKindMulti,
Expand Down
4 changes: 0 additions & 4 deletions packages/zone/src/durable.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,6 @@ export const makeDurableZone = (baggage, baseLabel = 'durableZone') => {
/** @type {import('.').Zone['exoClass']} */
const exoClass = (...args) => prepareExoClass(baggage, ...args);
/** @type {import('.').Zone['exoClassKit']} */
// @ts-ignore This type check regressed inexplicably with the release
// following after @endo/[email protected].
// The lint error does not occur in local lint, but does in integration with
// @agoric/vats, so can not be suppressed with ts-expect-error.
const exoClassKit = (...args) => prepareExoClassKit(baggage, ...args);
/** @type {import('.').Zone['exo']} */
const exo = (...args) => prepareExo(baggage, ...args);
Expand Down

0 comments on commit bef63e5

Please sign in to comment.