Skip to content

Commit

Permalink
Change arg format and push funds in
Browse files Browse the repository at this point in the history
  • Loading branch information
schnetzlerjoe committed Oct 23, 2023
1 parent 1b79e2f commit d247175
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
8 changes: 5 additions & 3 deletions packages/pegasus/src/courier.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Check failure on line 164 in packages/pegasus/src/courier.js

View workflow job for this annotation

GitHub Actions / lint-rest

'args' is never reassigned. Use 'const' instead
const instance = await E(namesByAddress).lookup(address, contractKey);
const result = await E(instance.publicFacet)[functionName](...args);
args['funds'] = payout;

Check failure on line 166 in packages/pegasus/src/courier.js

View workflow job for this annotation

GitHub Actions / lint-rest

["funds"] is better written in dot notation
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);
Expand Down
2 changes: 1 addition & 1 deletion packages/pegasus/src/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/

/**
Expand Down
5 changes: 2 additions & 3 deletions packages/pegasus/test/test-contract-pfm.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ import { Far } from '@endo/far';
const start = zcf => {

Check failure on line 3 in packages/pegasus/test/test-contract-pfm.js

View workflow job for this annotation

GitHub Actions / lint-rest

'zcf' is defined but never used. Allowed unused args must match /^_/u
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}!`
},
}),
});
Expand Down
2 changes: 1 addition & 1 deletion packages/pegasus/test/test-peg.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down

0 comments on commit d247175

Please sign in to comment.