Skip to content

Commit

Permalink
fix(types):Zoe AdminFacet is far
Browse files Browse the repository at this point in the history
  • Loading branch information
turadg committed Jul 16, 2024
1 parent 294c67b commit 3ecde25
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
5 changes: 3 additions & 2 deletions packages/zoe/src/zoeService/utils.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import type { TagContainer } from '@agoric/internal/src/tagged.js';
import type { Baggage } from '@agoric/swingset-liveslots';
import type { VatUpgradeResults } from '@agoric/swingset-vat';
import type { RemotableObject } from '@endo/marshal';
import type { FarRef } from '@endo/far';

// XXX https://github.com/Agoric/agoric-sdk/issues/4565
type SourceBundle = Record<string, any>;
Expand All @@ -33,7 +34,7 @@ export type ContractStartFunction = (
baggage?: Baggage,
) => ERef<{ creatorFacet?: {}; publicFacet?: {} }>;

export type AdminFacet<SF extends ContractStartFunction> = RemotableObject & {
export type AdminFacet<SF extends ContractStartFunction> = FarRef<{
// Completion, which is currently any
getVatShutdownPromise: () => Promise<any>;
upgradeContract: Parameters<SF>[1] extends undefined
Expand All @@ -45,7 +46,7 @@ export type AdminFacet<SF extends ContractStartFunction> = RemotableObject & {
restartContract: Parameters<SF>[1] extends undefined
? () => Promise<VatUpgradeResults>
: (newPrivateArgs: Parameters<SF>[1]) => Promise<VatUpgradeResults>;
};
}>;

export type StartParams<SF> = SF extends ContractStartFunction
? Parameters<SF>[1] extends undefined
Expand Down
11 changes: 6 additions & 5 deletions packages/zoe/src/zoeService/utils.test-d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { E } from '@endo/far';
import type { StartedInstanceKit } from './utils';

const someContractStartFn = (
Expand All @@ -10,24 +11,24 @@ type PsmInstanceKit = StartedInstanceKit<typeof someContractStartFn>;
const psmInstanceKit: PsmInstanceKit = null as any;

// @ts-expect-error missing privateArgs argument
void psmInstanceKit.adminFacet.restartContract();
void E(psmInstanceKit.adminFacet).restartContract();

const partial = {
someNumber: 1,
};
// @ts-expect-error missing member of privateArgs argument
void psmInstanceKit.adminFacet.restartContract(partial);
void E(psmInstanceKit.adminFacet).restartContract(partial);

// valid privateArgs now with 'marshaller'
void psmInstanceKit.adminFacet.restartContract({
void E(psmInstanceKit.adminFacet).restartContract({
...partial,
someString: 'str',
});

// @ts-expect-error missing member of privateArgs argument
void psmInstanceKit.adminFacet.upgradeContract('whatever', partial);
void E(psmInstanceKit.adminFacet).upgradeContract('whatever', partial);
// valid privateArgs now with 'marshaller'
void psmInstanceKit.adminFacet.upgradeContract('whatever', {
void E(psmInstanceKit.adminFacet).upgradeContract('whatever', {
...partial,
someString: 'str',
});

0 comments on commit 3ecde25

Please sign in to comment.