-
Notifications
You must be signed in to change notification settings - Fork 214
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
closes: #9692, #9693 ## Description Sets up a convention for `flows` modules and document in the orchestration README. Also makes lint config to test them. The lint config is exported as a shared config that developers can use. I've included it in the same PR to make sure it works with the new convention. ### Security Considerations none ### Scaling Considerations none ### Documentation Considerations Documented the convention in the README. I expect it'll make its way to docs.agoric.com as needed. ### Testing Considerations nothing special ### Upgrade Considerations not yet deployed
- Loading branch information
Showing
16 changed files
with
149 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,6 +61,6 @@ | |
"workerThreads": false | ||
}, | ||
"typeCoverage": { | ||
"atLeast": 76.94 | ||
"atLeast": 77.01 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -92,6 +92,6 @@ | |
"access": "public" | ||
}, | ||
"typeCoverage": { | ||
"atLeast": 98.09 | ||
"atLeast": 98.05 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { M, mustMatch } from '@endo/patterns'; | ||
|
||
/** | ||
* @import {GuestOf} from '@agoric/async-flow'; | ||
* @import {VBankAssetDetail} from '@agoric/vats/tools/board-utils.js'; | ||
* @import {ZoeTools} from '../utils/zoe-tools.js'; | ||
* @import {Orchestrator, LocalAccountMethods, OrchestrationAccountI, OrchestrationFlow} from '../types.js'; | ||
*/ | ||
|
||
const { entries } = Object; | ||
|
||
// in guest file (the orchestration functions) | ||
// the second argument is all the endowments provided | ||
|
||
/** | ||
* @satisfies {OrchestrationFlow} | ||
* @param {Orchestrator} orch | ||
* @param {object} ctx | ||
* @param {{ account?: OrchestrationAccountI & LocalAccountMethods }} ctx.contractState | ||
* @param {GuestOf<ZoeTools['localTransfer']>} ctx.localTransfer | ||
* @param {(brand: Brand) => Promise<VBankAssetDetail>} ctx.findBrandInVBank | ||
* @param {ZCFSeat} seat | ||
* @param {{ chainName: string; destAddr: string }} offerArgs | ||
*/ | ||
export async function sendIt( | ||
orch, | ||
{ contractState, localTransfer, findBrandInVBank }, | ||
seat, | ||
offerArgs, | ||
) { | ||
mustMatch(offerArgs, harden({ chainName: M.scalar(), destAddr: M.string() })); | ||
const { chainName, destAddr } = offerArgs; | ||
// NOTE the proposal shape ensures that the `give` is a single asset | ||
const { give } = seat.getProposal(); | ||
const [[_kw, amt]] = entries(give); | ||
const { denom } = await findBrandInVBank(amt.brand); | ||
const chain = await orch.getChain(chainName); | ||
|
||
if (!contractState.account) { | ||
const agoricChain = await orch.getChain('agoric'); | ||
contractState.account = await agoricChain.makeAccount(); | ||
} | ||
|
||
const info = await chain.getChainInfo(); | ||
const { chainId } = info; | ||
assert(typeof chainId === 'string', 'bad chainId'); | ||
|
||
await localTransfer(seat, contractState.account, give); | ||
|
||
await contractState.account.transfer( | ||
{ denom, value: amt.value }, | ||
{ | ||
value: destAddr, | ||
encoding: 'bech32', | ||
chainId, | ||
}, | ||
); | ||
} | ||
harden(sendIt); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/** | ||
* @file Module with linting errors, to verify the linting config detects them. | ||
* This assumes `reportUnusedDisableDirectives` is enabled in the local | ||
* config. | ||
*/ | ||
|
||
// TODO error on exports that: | ||
// - aren't hardened (probably a new rule in @endo/eslint-plugin ) | ||
// - don't satisfy orchestration flow type | ||
|
||
// eslint-disable-next-line no-restricted-syntax -- intentional for test | ||
import { E } from '@endo/far'; | ||
|
||
export function notFlow() { | ||
console.log('This function is not a flow'); | ||
} | ||
|
||
export async function notHardened() { | ||
console.log('This function is the most minimal flow, but it’s not hardened'); | ||
} | ||
|
||
export async function usesE(orch, { someEref }) { | ||
// eslint-disable-next-line no-restricted-syntax -- intentional for test | ||
await E(someEref).foo(); | ||
} |
Oops, something went wrong.