From 02ff5b49783fb307eda2ce73f80b1fca4daef9b0 Mon Sep 17 00:00:00 2001 From: Michael FIG Date: Thu, 18 Jul 2024 12:57:25 -0600 Subject: [PATCH 1/3] refactor: change `.then` and `.catch` to `await` in `try-catch` --- .../src/examples/swapExample.contract.js | 16 ++++---- packages/vow/src/when.js | 38 ++++++++++--------- 2 files changed, 28 insertions(+), 26 deletions(-) diff --git a/packages/orchestration/src/examples/swapExample.contract.js b/packages/orchestration/src/examples/swapExample.contract.js index 187a210b194c..8d75dd41087f 100644 --- a/packages/orchestration/src/examples/swapExample.contract.js +++ b/packages/orchestration/src/examples/swapExample.contract.js @@ -26,7 +26,7 @@ import { withOrchestration } from '../utils/start-helper.js'; * @param {Amount<'nat'>} offerArgs.staked * @param {CosmosValidatorAddress} offerArgs.validator */ -const stackAndSwapFn = async (orch, { localTransfer }, seat, offerArgs) => { +const stakeAndSwapFn = async (orch, { localTransfer }, seat, offerArgs) => { const { give } = seat.getProposal(); const omni = await orch.getChain('omniflixhub'); @@ -52,12 +52,12 @@ const stackAndSwapFn = async (orch, { localTransfer }, seat, offerArgs) => { slippage: 0.03, }); - await localAccount - .transferSteps(give.Stable, transferMsg) - .then(_txResult => - omniAccount.delegate(offerArgs.validator, offerArgs.staked), - ) - .catch(e => console.error(e)); + try { + await localAccount.transferSteps(give.Stable, transferMsg); + await omniAccount.delegate(offerArgs.validator, offerArgs.staked); + } catch (e) { + console.error(e); + } }; /** @type {ContractMeta} */ @@ -105,7 +105,7 @@ const contract = async (zcf, privateArgs, zone, { orchestrate, zoeTools }) => { const swapAndStakeHandler = orchestrate( 'LSTTia', { zcf, localTransfer: zoeTools.localTransfer }, - stackAndSwapFn, + stakeAndSwapFn, ); const publicFacet = zone.exo('publicFacet', undefined, { diff --git a/packages/vow/src/when.js b/packages/vow/src/when.js index 0bd2aa8e5572..c9befef854b4 100644 --- a/packages/vow/src/when.js +++ b/packages/vow/src/when.js @@ -36,24 +36,26 @@ export const makeWhen = ( if (seenPayloads.has(vowV0)) { throw Error('Vow resolution cycle detected'); } - result = await basicE(vowV0) - .shorten() - .then( - res => { - seenPayloads.add(vowV0); - priorRetryValue = undefined; - return res; - }, - e => { - const nextValue = isRetryableReason(e, priorRetryValue); - if (nextValue) { - // Shorten the same specimen to try again. - priorRetryValue = nextValue; - return result; - } - throw e; - }, - ); + + try { + // Shorten the vow to the "next step", whether another vow or a final + // result. + const res = await basicE(vowV0).shorten(); + + // Prevent cycles in the resolution graph. + seenPayloads.add(vowV0); + priorRetryValue = undefined; + result = res; + } catch (e) { + const nextRetryValue = isRetryableReason(e, priorRetryValue); + if (!nextRetryValue) { + // Not a retry, so just reject with the reason. + throw e; + } + + // Shorten the same specimen to try again. + priorRetryValue = nextRetryValue; + } // Advance to the next vow. payload = getVowPayload(result); } From ea82b9a10e11d4a799cbd3c6bbb80f26831a5e75 Mon Sep 17 00:00:00 2001 From: Michael FIG Date: Sat, 20 Jul 2024 11:17:40 -0600 Subject: [PATCH 2/3] ci(getting-started): prevent failures of all retries --- scripts/registry.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/registry.sh b/scripts/registry.sh index 4824ac1c3b48..6cc7f4423253 100755 --- a/scripts/registry.sh +++ b/scripts/registry.sh @@ -104,6 +104,8 @@ integrationTest() { # Install the Agoric CLI on this machine's $PATH. case $1 in link-cli | link-cli/*) + # Prevent retries from failing with "must not already exist" + rm -f "$HOME/bin/agoric" yarn link-cli "$HOME/bin/agoric" persistVar AGORIC_CMD "[\"$HOME/bin/agoric\"]" ;; From c4f6a0312a6523c2faf47dd0453d480243e0f186 Mon Sep 17 00:00:00 2001 From: omahs <73983677+omahs@users.noreply.github.com> Date: Mon, 22 Jul 2024 00:24:07 +0200 Subject: [PATCH 3/3] docs: fix typos (#9749) docs: fix typos --- MAINTAINERS.md | 2 +- docs/architecture/0001-record-architecture-decisions.md | 2 +- docs/typescript.md | 2 +- packages/swingset-runner/src/main.js | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/MAINTAINERS.md b/MAINTAINERS.md index c6c610454ad1..7ef3fcbf8567 100644 --- a/MAINTAINERS.md +++ b/MAINTAINERS.md @@ -117,7 +117,7 @@ For each set of changes to include: These are the steps for a Release Manager to create and publish a new release of the Agoric SDK. This combines the process of -GitHub-based release managment and publication together with NPM-based +GitHub-based release management and publication together with NPM-based publication of the SDK and its individual packages. ### Prerequisites diff --git a/docs/architecture/0001-record-architecture-decisions.md b/docs/architecture/0001-record-architecture-decisions.md index cba0f81572ce..54b3207ef459 100644 --- a/docs/architecture/0001-record-architecture-decisions.md +++ b/docs/architecture/0001-record-architecture-decisions.md @@ -11,7 +11,7 @@ subject](http://thinkrelevance.com/blog/2011/11/15/documenting-architecture-deci Architecture for agile projects has to be described and defined differently. Not all decisions will be made at once, nor will all of them be done when the project begins. -Agile methods are not opposed to documentation, only to valueless documentation. Documents that assist the team itself can have value, but only if they are kept up to date. Large documents are never kept up to date. Small, modular documents have at least a chance at being updated. +Agile methods are not opposed to documentation, only to valueless documentation. Documents that assist the team itself can have value, but only if they are kept up to date. Large documents are never kept up to date. Small, modular documents have at least a chance of being updated. Nobody ever reads large documents, either. Most developers have been on at least one project where the specification document was larger (in bytes) than the total source code size. Those documents are too large to open, read, or update. Bite sized pieces are easier for for all stakeholders to consume. diff --git a/docs/typescript.md b/docs/typescript.md index 39926e740b54..8e612623e159 100644 --- a/docs/typescript.md +++ b/docs/typescript.md @@ -1,6 +1,6 @@ # usage of TypeScript -Our use of TypeScript has to accomodate both .js development in agoric-sdk (which could not import types until TS 5.5) and .ts development of consumers of agoric-sdk packages (which could always import types). For .js development, we have many ambient (global) types so that we don't have to precede each type reference by an import. For .ts development, we want exports from modules so we don't pollute a global namespace. We are slowly transitioning away from ambient types. +Our use of TypeScript has to accommodate both .js development in agoric-sdk (which could not import types until TS 5.5) and .ts development of consumers of agoric-sdk packages (which could always import types). For .js development, we have many ambient (global) types so that we don't have to precede each type reference by an import. For .ts development, we want exports from modules so we don't pollute a global namespace. We are slowly transitioning away from ambient types. ## Best practices diff --git a/packages/swingset-runner/src/main.js b/packages/swingset-runner/src/main.js index e6a20d196a36..6003a30227dc 100644 --- a/packages/swingset-runner/src/main.js +++ b/packages/swingset-runner/src/main.js @@ -49,7 +49,7 @@ FLAGS may be: --initonly - initialize the swingset but exit without running it --sqlite - runs using Sqlite3 as the data store (default) --memdb - runs using the non-persistent in-memory data store - --usexs - run vats using the the XS engine + --usexs - run vats using the XS engine --usebundlecache - cache bundles created by swingset loader --dbdir DIR - specify where the data store should go (default BASEDIR) --blockmode - run in block mode (checkpoint every BLOCKSIZE blocks)