Skip to content

Commit

Permalink
fix: add missing files and dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfig committed Mar 22, 2020
1 parent 35e8729 commit 2dc3e07
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
49 changes: 49 additions & 0 deletions packages/cosmic-swingset/lib/ag-solo/vats/captp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// Avoid importing the full captp bundle, which would carry
// in its own makeHardener, etc.
import { makeCapTP } from '@agoric/captp/lib/captp';
import harden from '@agoric/harden';

export const getCapTPHandler = (E, sendMulticast, getBootstrapObject) => {
const conns = new Map();
const handler = harden({
onConnect(_obj, meta) {
const { connectionHandle, origin = 'unknown' } = meta || {};
console.info(`Starting CapTP`, meta);
const sendObj = o => {
sendMulticast(o, [connectionHandle]);
};
const { dispatch, abort } = makeCapTP(
origin,
sendObj,
getBootstrapObject,
);
conns.set(connectionHandle, [dispatch, abort]);
},
onDisconnect(_obj, meta) {
console.log(`Finishing CapTP`, meta);
const dispatchAbort = conns.get(meta.connectionHandle);
if (dispatchAbort) {
(1, dispatchAbort[1])();
}
conns.delete(meta.connectionHandle);
},
onError(obj, meta) {
console.log(`Error in CapTP`, meta, obj.error);
},
onMessage(obj, meta) {
console.error('processing inbound', obj);
const dispatchAbort = conns.get(meta.connectionHandle);
if (!dispatchAbort || !(1, dispatchAbort[0])(obj)) {
console.error(`Could not find CapTP handler ${obj.type}`, meta);
return false;
}
return true;
},
});

return harden({
getCommandHandler() {
return handler;
},
});
};
1 change: 1 addition & 0 deletions packages/cosmic-swingset/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"@agoric/registrar": "^0.0.1",
"@agoric/same-structure": "^0.0.1",
"@agoric/sharing-service": "^0.0.1",
"@agoric/spawner": "^0.0.3",
"@agoric/store": "^0.0.1",
"@agoric/swing-store-simple": "^0.1.0",
"@agoric/swingset-vat": "^0.3.0",
Expand Down

0 comments on commit 2dc3e07

Please sign in to comment.