Skip to content
This repository has been archived by the owner on Feb 13, 2024. It is now read-only.

Commit

Permalink
fix: add Far() where necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
warner committed Mar 10, 2021
1 parent d1be7df commit bf49b16
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
3 changes: 2 additions & 1 deletion api/src/handler.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
// @ts-check
import { E } from '@agoric/eventual-send';
import { Far } from '@agoric/marshal';
import { makeWebSocketHandler } from './lib-http';

const spawnHandler = (
{ creatorFacet, board, http, invitationIssuer },
_invitationMaker,
) =>
makeWebSocketHandler(http, (send, _meta) =>
harden({
Far('connectionHandler', {
async onMessage(obj) {
switch (obj.type) {
case 'fungibleFaucet/sendInvitation': {
Expand Down
9 changes: 5 additions & 4 deletions api/src/lib-http.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@

// @ts-check
import { E } from '@agoric/eventual-send';
import { Far } from '@agoric/marshal';

export const makeWebSocketHandler = (http, makeConnectionHandler) => {
return harden({
return Far('webSocketHandler', {
// This creates the commandHandler for the http service to handle inbound
// websocket requests.
getCommandHandler() {
const channelToConnHandler = new WeakMap();
const handler = {
const handler = Far('httpCommandHandler', {
// Executed upon an error in handling the websocket.
onError(obj, { channelHandle }) {
const connHandler = channelToConnHandler.get(channelHandle);
Expand Down Expand Up @@ -43,8 +44,8 @@ export const makeWebSocketHandler = (http, makeConnectionHandler) => {
const connHandler = channelToConnHandler.get(channelHandle);
return connHandler.onMessage(obj);
},
};
return harden(handler);
});
return handler;
},
});
};
9 changes: 5 additions & 4 deletions contract/src/contract.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// @ts-check
import '@agoric/zoe/exported';
import { Far } from '@agoric/marshal';

/**
* This is a very simple contract that creates a new issuer and mints payments
Expand Down Expand Up @@ -37,18 +38,18 @@ const start = async (zcf) => {
return 'Offer completed. You should receive a payment from Zoe';
};

const creatorFacet = {
const creatorFacet = Far('creatorFacet', {
// The creator of the instance can send invitations to anyone
// they wish to.
makeInvitation: () => zcf.makeInvitation(mintPayment, 'mint a payment'),
getTokenIssuer: () => issuer,
};
});

const publicFacet = {
const publicFacet = Far('publicFacet', {
// Make the token issuer public. Note that only the mint can
// make new digital assets. The issuer is ok to make public.
getTokenIssuer: () => issuer,
};
});

// Return the creatorFacet to the creator, so they can make
// invitations for others to get payments of tokens. Publish the
Expand Down

0 comments on commit bf49b16

Please sign in to comment.