Skip to content

Commit

Permalink
chore: add Zoe invite issuer and purse to wallet (#1176)
Browse files Browse the repository at this point in the history
  • Loading branch information
katelynsills authored Jun 12, 2020
1 parent 6172b42 commit ef7bf84
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
18 changes: 17 additions & 1 deletion packages/cosmic-swingset/lib/ag-solo/vats/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export default function setup(syscall, state, helpers) {
),
);

// Register all of the starting issuers.
// Register the moola and simolean issuers
const issuerInfo = await Promise.all(
issuerNames.map(async (issuerName, i) =>
harden({
Expand All @@ -104,6 +104,21 @@ export default function setup(syscall, state, helpers) {
}),
),
);

// Add the Zoe invite issuer.
const zoeInviteIssuer = await E(zoe).getInviteIssuer();
const zoeInvitePetname = 'zoe invite';
issuerInfo.push(
harden({
issuer: zoeInviteIssuer,
petname: zoeInvitePetname,
brandRegKey: await E(registry).register(
zoeInvitePetname,
await E(zoeInviteIssuer).getBrand(),
),
}),
);

return harden({
async createUserBundle(_nickname) {
// Bind to some fresh ports (unspecified name) on the IBC implementation
Expand Down Expand Up @@ -246,6 +261,7 @@ export default function setup(syscall, state, helpers) {
const pursePetnames = {
moola: 'Fun budget',
simolean: 'Nest egg',
'zoe invite': 'Default Zoe invite purse',
};
await Promise.all(
issuerInfo.map(({ petname: issuerPetname }) => {
Expand Down
24 changes: 24 additions & 0 deletions packages/cosmic-swingset/test/test-home.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,30 @@ test('home.mailboxAdmin', async t => {
}
});

test('home.wallet', async t => {
try {
const { wallet, zoe } = E.G(home);

const zoeInviteIssuer = await E(zoe).getInviteIssuer();
const issuers = await E(wallet).getIssuers();
const issuersMap = new Map(issuers);
t.deepEquals(
issuersMap.get('zoe invite'),
zoeInviteIssuer,
`wallet knows about the Zoe invite issuer`,
);
const invitePurse = await E(wallet).getPurse('Default Zoe invite purse');
t.deepEquals(
await E(invitePurse).getAllegedBrand(),
await E(zoeInviteIssuer).getBrand(),
);
} catch (e) {
t.isNot(e, e, 'unexpected exception');
} finally {
t.end();
}
});

// =========================================
// This runs after all the tests.
test('teardown', async t => {
Expand Down

0 comments on commit ef7bf84

Please sign in to comment.