diff --git a/packages/pegasus/src/courier.js b/packages/pegasus/src/courier.js index b4606ac9529..5f4b28a136f 100644 --- a/packages/pegasus/src/courier.js +++ b/packages/pegasus/src/courier.js @@ -157,12 +157,14 @@ export const makeCourierMaker = } // Contract Call Forward via PFM if (forward && forward.call) { - const { address, contractKey, functionName, args } = forward.call; - if (!address || !contractKey || !functionName || !args) { + const { address, contractKey, functionName, args: argString } = forward.call; + if (!address || !contractKey || !functionName || !argString) { throw Error(`Invalid PFM Call Forward: ${JSON.stringify(forward.call)}`); } + let args = JSON.parse(argString) const instance = await E(namesByAddress).lookup(address, contractKey); - const result = await E(instance.publicFacet)[functionName](...args); + args['funds'] = payout; + const result = await E(instance.publicFacet)[functionName](args); console.log("Completed PFM Call Forward: ", forward.call); console.log("PFM Call Result: ", result); return E(transferProtocol).makeTransferPacketAck(true); diff --git a/packages/pegasus/src/types.js b/packages/pegasus/src/types.js index 1abf690c1e3..a35b3101749 100644 --- a/packages/pegasus/src/types.js +++ b/packages/pegasus/src/types.js @@ -128,7 +128,7 @@ * @property {string} address the agoric address of the namesByAddress * @property {string} contractKey the key of the instance saved in namesByAddress * @property {string} functionName the function name of the method to call in the public facet - * @property {any[]} args json encoded string of the args to pass into the method to call from the public facet + * @property {string} args json encoded string of the args to pass into the method to call from the public facet */ /** diff --git a/packages/pegasus/test/test-contract-pfm.js b/packages/pegasus/test/test-contract-pfm.js index 088143c5892..6a28890c8b4 100644 --- a/packages/pegasus/test/test-contract-pfm.js +++ b/packages/pegasus/test/test-contract-pfm.js @@ -3,9 +3,8 @@ import { Far } from '@endo/far'; const start = zcf => { return harden({ publicFacet: Far('publicFacet', { - helloWorld(name) { - console.log(`Hello world from ${name}!`); - return `Hello world from ${name}!` + helloWorld(args) { + return `Hello world from ${args.name} with funds ${args.funds}!` }, }), }); diff --git a/packages/pegasus/test/test-peg.js b/packages/pegasus/test/test-peg.js index 8dfeea1049c..64e0fd4ff3a 100644 --- a/packages/pegasus/test/test-peg.js +++ b/packages/pegasus/test/test-peg.js @@ -338,7 +338,7 @@ async function testRemotePeg(t) { address: "agoric1234567", contractKey: "pfmTest", functionName: "helloWorld", - args: ["PFM Land"] + args: JSON.stringify({"name": "PFM Land"}) } } const sendPacketPFMCall = {