Skip to content

Commit

Permalink
fix: revive the ability of a zoe client to get access to the code.
Browse files Browse the repository at this point in the history
It's tested in an existing large test by checking for specific text in
the source code. We could check something less fragile (e.g. starts
with 'function getExport'), and still be pretty sure that if a string
is returned, it would continue to be the source of the contract.

fixes #877
  • Loading branch information
Chris-Hibbert committed Apr 9, 2020
1 parent d4d519c commit ea64ac1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
4 changes: 3 additions & 1 deletion packages/zoe/src/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import { makeTable, makeValidateProperties } from './table';
// Installation Table
// Columns: handle | installation
const makeInstallationTable = () => {
const validateSomewhat = makeValidateProperties(harden(['installation']));
const validateSomewhat = makeValidateProperties(
harden(['installation', 'code']),
);
return makeTable(validateSomewhat);
};

Expand Down
4 changes: 3 additions & 1 deletion packages/zoe/src/zoe.js
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ const makeZoe = (additionalEndowments = {}) => {
}
}
const installationHandle = installationTable.create(
harden({ installation }),
harden({ installation, code }),
);
return installationHandle;
},
Expand Down Expand Up @@ -500,6 +500,8 @@ const makeZoe = (additionalEndowments = {}) => {
isOfferActive: offerTable.isOfferActive,
getOffers: offerTable.getOffers,
getOffer: offerTable.get,
getInstallation: installationHandle =>
installationTable.get(installationHandle).code,
});
return zoeService;
};
Expand Down
11 changes: 11 additions & 0 deletions packages/zoe/test/swingsetTests/zoe/vat-dave.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,17 @@ const build = async (E, log, zoe, issuers, payments, installations, timer) => {
const { installationHandle, issuerKeywordRecord } = await E(
zoe,
).getInstance(instanceHandle);
const installationCode = await E(zoe).getInstallation(installationHandle);
// pick some arbitrary code points as a signature.
assert(
installationCode.indexOf("['Asset', 'Price']") === 58060,
details`source code didn't match`,
);
assert(
installationCode.indexOf('makeMatchingInvite') === 58091,
installationCode.indexOf('makeFirstOfferInvite') === 58498,
details`source code didn't match`,
);
assert(
installationHandle === installations.atomicSwap,
details`wrong installation`,
Expand Down

0 comments on commit ea64ac1

Please sign in to comment.