Skip to content

Commit fb1a040

Browse files
committed
WIP: fusd upgrade w/smartWallet + Justin
1 parent 3dc72bf commit fb1a040

File tree

1 file changed

+42
-1
lines changed

1 file changed

+42
-1
lines changed

packages/boot/test/bootstrapTests/wallet-fun.test.ts

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type { CurrentWalletRecord } from '@agoric/smart-wallet/src/smartWallet.j
66
import type { NameHub } from '@agoric/vats';
77
import type { AmountKeywordRecord, IssuerKeywordRecord } from '@agoric/zoe';
88
import { start as startSwap } from '@agoric/zoe/src/contracts/atomicSwap.js';
9-
import type { Installation } from '@agoric/zoe/src/zoeService/utils';
9+
import type { AdminFacet, Installation } from '@agoric/zoe/src/zoeService/utils';
1010
import bundleSource from '@endo/bundle-source';
1111
import type { ExecutionContext, TestFn } from 'ava';
1212
import { createRequire } from 'node:module';
@@ -15,6 +15,8 @@ import {
1515
makeWalletFactoryContext,
1616
type WalletFactoryTestContext as TC,
1717
} from './walletFactory.ts';
18+
import type { EProxy } from '@endo/eventual-send';
19+
import type { FastUsdcSF } from '@aglocal/fast-usdc-contract/src/fast-usdc.contract.ts';
1820

1921
const nodeRequire = createRequire(import.meta.url);
2022

@@ -243,3 +245,42 @@ test('use Invitation offer result in atomicSwap', async t => {
243245
await party.B.buy(t);
244246
await party.A.completeSale(t);
245247
});
248+
249+
// cf packages/fast-usdc-deploy/src/update-settler-reference.core.js
250+
test('upgrade a deployed contract', async t=>{
251+
const upgradeFn =
252+
(
253+
nameHub = null as unknown as NameHub,
254+
E =null as unknown as EProxy,
255+
) =>
256+
E(E.get(nameHub.lookup('fuKit')).adminFacet as Promise<AdminFacet<FastUsdcSF>>).upgradeContract(
257+
BUNDLE_ID,
258+
fuKit.privateArgs,
259+
).then(
260+
trace('fastUsdc upgraded', upgraded);
261+
262+
await E(creatorFacet).connectToNoble();
263+
})
264+
/**
265+
* @param {BootstrapPowers & FastUSDCCorePowers} powers
266+
* @param {object} [config]
267+
* @param {UpdateOpts} [config.options]
268+
*/
269+
export const updateSettlerReference = async (
270+
{ consume: { fastUsdcKit } },
271+
{ options = {} } = {},
272+
) => {
273+
trace('options', options);
274+
const { fastUsdcCode = assert.fail('missing bundleID') } = options;
275+
const fuKit = await fastUsdcKit;
276+
trace('fastUsdcKit.privateArgs keys:', keys(fuKit.privateArgs));
277+
const { adminFacet, creatorFacet } = fuKit;
278+
const upgraded = await E(adminFacet).upgradeContract(
279+
fastUsdcCode.bundleID,
280+
fuKit.privateArgs,
281+
);
282+
trace('fastUsdc upgraded', upgraded);
283+
284+
await E(creatorFacet).connectToNoble();
285+
trace('updateSettlerReference done');
286+
};

0 commit comments

Comments
 (0)