Skip to content

Commit

Permalink
chore: simplify ertp service
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris-Hibbert committed Jun 27, 2022
1 parent 850aec0 commit 7cff145
Showing 1 changed file with 6 additions and 18 deletions.
24 changes: 6 additions & 18 deletions packages/ERTP/test/swingsetTests/ertpService/vat-ertp-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,18 @@
import { Far } from '@endo/marshal';
import {
makeScalarBigMapStore,
makeScalarBigSetStore,
provideDurableSetStore,
provideDurableSingleton,
} from '@agoric/vat-data/src';
import { provide } from '@agoric/store';

import {
AssetKind,
makeDurableIssuerKit,
provideDurableIssuerKit,
} from '../../../src';

function makeErtpService(baggage, exitVatWithFailure) {
const didStart = baggage.has('didStart'); // false for v1, true for v2

const issuerBaggageSet = provide(baggage, 'BaggageSet', () => {
baggage.init('didStart', true);
return makeScalarBigSetStore('BaggageSet', {
durable: true,
});
});

function provideErtpService(baggage, exitVatWithFailure) {
const issuerBaggageSet = provideDurableSetStore(baggage, 'BaggageSet');
const ertpService = provideDurableSingleton(baggage, 'ERTPService', {
makeIssuerKit: (
_context,
Expand All @@ -47,18 +38,15 @@ function makeErtpService(baggage, exitVatWithFailure) {
},
});

if (didStart) {
console.log(`DID START`);
for (const issuerBaggage of issuerBaggageSet.values()) {
provideDurableIssuerKit(issuerBaggage);
}
for (const issuerBaggage of issuerBaggageSet.values()) {
provideDurableIssuerKit(issuerBaggage);
}

return ertpService;
}

export const buildRootObject = async (vatPowers, _vatParams, baggage) => {
const ertpService = makeErtpService(baggage, vatPowers.exitVatWithFailure);
const ertpService = provideErtpService(baggage, vatPowers.exitVatWithFailure);
return Far('root', {
getErtpService: () => ertpService,
});
Expand Down

0 comments on commit 7cff145

Please sign in to comment.