From 1d70859e445eebe5a28ed2dbb530d499c385b1af Mon Sep 17 00:00:00 2001 From: Richard Gibson Date: Fri, 1 Dec 2023 16:40:02 -0500 Subject: [PATCH] style: Improve the consistency of code samples --- main/glossary/README.md | 2 +- main/guides/js-programming/notifiers.md | 4 +- main/guides/zoe/actual-contracts/PSM.md | 4 +- main/guides/zoe/contracts/barter-exchange.md | 2 +- main/guides/zoe/contracts/covered-call.md | 4 +- main/reference/ertp-api/amount-math.md | 18 ++--- main/reference/ertp-api/issuer.md | 31 +++++---- main/reference/ertp-api/mint.md | 6 +- main/reference/ertp-api/payment.md | 2 +- main/reference/ertp-api/purse.md | 7 +- main/reference/repl/board.md | 2 +- main/reference/repl/networking.md | 2 +- main/reference/zoe-api/ratio-math.md | 16 ++--- main/reference/zoe-api/zoe-helpers.md | 71 +++++++++----------- main/reference/zoe-api/zoe.md | 16 ++--- 15 files changed, 92 insertions(+), 95 deletions(-) diff --git a/main/glossary/README.md b/main/glossary/README.md index d3b4e55953..e229ed93b9 100644 --- a/main/glossary/README.md +++ b/main/glossary/README.md @@ -124,7 +124,7 @@ Before a contract can be installed on Zoe, its source code must be bundled. This ```js import bundleSource from '@endo/bundle-source'; const atomicSwapBundle = await bundleSource( - require.resolve('@agoric/zoe/src/contracts/atomicSwap'), + require.resolve('@agoric/zoe/src/contracts/atomicSwap'), ); ``` The installation operation returns an `installation`, which is an object with a single diff --git a/main/guides/js-programming/notifiers.md b/main/guides/js-programming/notifiers.md index 19af093a26..fd2c1a658e 100644 --- a/main/guides/js-programming/notifiers.md +++ b/main/guides/js-programming/notifiers.md @@ -208,7 +208,7 @@ const consume = async subscription => { } }; consume(subscription); -// eventually prints +// Eventually prints: // non-final-value a // non-final-value b // the iteration finished @@ -221,7 +221,7 @@ const observer = harden({ fail: reason => console.log('failed', reason), }); observeIteration(subscription, observer); -// eventually prints +// Eventually prints: // non-final-value a // non-final-value b // finished done diff --git a/main/guides/zoe/actual-contracts/PSM.md b/main/guides/zoe/actual-contracts/PSM.md index 2c6a44ed3d..1b4b3bfbcc 100644 --- a/main/guides/zoe/actual-contracts/PSM.md +++ b/main/guides/zoe/actual-contracts/PSM.md @@ -51,8 +51,8 @@ this proposal doesn’t have (or need) an exit condition. ```js const myProposal = { - give: {In: giveAnchorAmount }, - want: {Out: wantMintedAmount } + give: { In: giveAnchorAmount }, + want: { Out: wantMintedAmount } }; ``` 4. Create a payment record containing the external stable tokens you’re trading to the PSM. diff --git a/main/guides/zoe/contracts/barter-exchange.md b/main/guides/zoe/contracts/barter-exchange.md index 56563cb0df..e3d4383a66 100644 --- a/main/guides/zoe/contracts/barter-exchange.md +++ b/main/guides/zoe/contracts/barter-exchange.md @@ -19,7 +19,7 @@ keeps an order book, and each time it receives a new offer, it looks for matches throughout the order book. The Barter Exchange only accepts offers that look like -`{ give: { In: amount }, want: { Out: amount}` } +`{ give: { In: amount }, want: { Out: amount }` } The want amount will be matched, while the give amount is a maximum. Each successful trader gets their `want` and may trade with counter-parties who diff --git a/main/guides/zoe/contracts/covered-call.md b/main/guides/zoe/contracts/covered-call.md index 6da3e4fd78..523bfed541 100644 --- a/main/guides/zoe/contracts/covered-call.md +++ b/main/guides/zoe/contracts/covered-call.md @@ -50,7 +50,9 @@ with the key "afterDeadline": { give: { ... }, want: { ... }, - exit: {afterDeadline: { deadline: time, timer: chainTimer } }, + exit: { + afterDeadline: { deadline: time, timer: chainTimer }, + }, } ``` diff --git a/main/reference/ertp-api/amount-math.md b/main/reference/ertp-api/amount-math.md index e1c0d0ec12..1815ec62ff 100644 --- a/main/reference/ertp-api/amount-math.md +++ b/main/reference/ertp-api/amount-math.md @@ -25,7 +25,7 @@ not equal, an error is thrown and no changes are made. Creates an **Amount** from a given **Value** and a **Brand**. ```js -//amount837 = { value: 837n, brand: quatloos } +// amount837 = { brand: quatloosBrand, value: 837n } const amount837 = AmountMath.make(quatloosBrand, 837n); ``` @@ -53,7 +53,7 @@ Returns the **Value** from the given **Amount**. ```js const quatloos123 = AmountMath.make(quatloosBrand, 123n); -// returns 123n +// Returns 123n const myValue = AmountMath.getValue(quatloosBrand, quatloos123); ``` ## AmountMath.makeEmpty(brand, assetKind) @@ -64,7 +64,7 @@ const myValue = AmountMath.getValue(quatloosBrand, quatloos123); Returns the **Amount** representing an empty **Amount** for the *brand* parameter's **Brand**. This is the identity element for **AmountMath.add()** and **AmountMath.subtract()**. The empty **Value** depends -on whether the *assetKind* is **AssetKind.NAT** (*0n*), **AssetKind.COPY_SET** (*[]*), or **AssetKind.COPY_BAG** (*[]*). +on whether the *assetKind* is **AssetKind.NAT** (`0n`), **AssetKind.COPY_SET** (`[]`), or **AssetKind.COPY_BAG** (`[]`). ```js // Returns an empty amount. @@ -81,9 +81,9 @@ Returns the **Amount** representing an empty **Amount**, using another **Amount** as the template for the **[Brand](./brand.md)** and **[Value](./ertp-data-types.md#value)**. ```js -// quatloosAmount837 = { value: 837n, brand: quatloos } +// quatloosAmount837 = { brand: quatloos, value: 837n } const quatloosAmount837 = AmountMath.make(quatloosBrand, 837n); -// Returns an amount = { value: 0n, brand: quatloos } +// Returns an amount = { brand: quatloos, value: 0n } const quatloosAmount0 = AmountMath.makeEmptyFromAmount(quatloosAmount837); ``` @@ -100,10 +100,10 @@ If the optional *brand* argument doesn't match the **Amount**'s **Brand**, an er const empty = AmountMath.makeEmpty(quatloosBrand, AssetKind.NAT); const quatloos1 = AmountMath.make(quatloosBrand, 1n); -// returns true +// Returns true const result = AmountMath.isEmpty(empty); -// returns false +// Returns false const result = AmountMath.isEmpty(quatloos1); ``` @@ -254,7 +254,7 @@ If the optional *brand* argument doesn't match the **Brand** of *x* and *y*, an const smallerAmount = AmountMath.make(quatloosBrand, 5n); const largerAmount = AmountMath.make(quatloosBrand, 10n); -//returns smallerAmount +// Returns smallerAmount const comparisonResult = AmountMath.min(smallerAmount, largerAmount); ``` @@ -274,7 +274,7 @@ If the optional *brand* argument doesn't match the **Brand** of *x* and *y*, an const smallerAmount = AmountMath.make(quatloosBrand, 5n); const largerAmount = AmountMath.make(quatloosBrand, 10n); -//returns largerAmount +// Returns largerAmount const comparisonResult = AmountMath.max(smallerAmount, largerAmount); ``` diff --git a/main/reference/ertp-api/issuer.md b/main/reference/ertp-api/issuer.md index 66ad8b1261..89d1f96bad 100644 --- a/main/reference/ertp-api/issuer.md +++ b/main/reference/ertp-api/issuer.md @@ -59,13 +59,13 @@ makeIssuerKit('title', AssetKind.COPY_SET); ``` ```js -const { issuer: quatloosIssuer, mint: quatloosMint, brand: quatloosBrand } = - makeIssuerKit('quatloos'); +const { issuer: quatloosIssuer, mint: quatloosMint, brand: quatloosBrand } = + makeIssuerKit('quatloos'); // This is merely an amount, describing assets, not minting assets const quatloos2 = AmountMath.make(quatloosBrand, 2n); -const { issuer: titleIssuer, mint: titleMint, brand: titleBrand } = - makeIssuerKit('propertyTitle'); +const { issuer: titleIssuer, mint: titleMint, brand: titleBrand } = + makeIssuerKit('propertyTitle'); // These are merely amounts describing digital assets, not minting assets. const cornerProperty = AmountMath.make(propertyTitleBrand, ['1292826']); const adjacentProperty = AmountMath.make(propertyTitleBrand, ['1028393']); @@ -119,7 +119,8 @@ source cannot be trusted to provide its own true value, the **Issuer** must be u validate its **[Brand](./brand.md)** and report how much the returned **Amount** contains. ```js -const { issuer: quatloosIssuer, mint: quatloosMint, brand: quatloosBrand} = makeIssuerKit('quatloos'); +const { issuer: quatloosIssuer, mint: quatloosMint, brand: quatloosBrand } = + makeIssuerKit('quatloos'); const quatloosPayment = quatloosMint.mintPayment(AmountMath.make(quatloosBrand, 100n)); quatloosIssuer.getAmountOf(quatloosPayment); // returns an amount of 100 Quatloos ``` @@ -167,8 +168,8 @@ and the original **Payment** is unmodified. If *payment* is a promise, the operation proceeds after it resolves to a **Payment**. ```js -const { issuer: quatloosIssuer, mint: quatloosMint, brand: quatloosBrand } = - makeIssuerKit('quatloos'); +const { issuer: quatloosIssuer, mint: quatloosMint, brand: quatloosBrand } = + makeIssuerKit('quatloos'); const amountToBurn = AmountMath.make(quatloosBrand, 10n); const paymentToBurn = quatloosMint.mintPayment(amountToBurn); @@ -192,7 +193,8 @@ and the original **Payment** is unmodified. If *payment* is a promise, the operation proceeds after it resolves to a **Payment**. ```js -const { mint: quatloosMint, issuer: quatloosIssuer, brand: quatloosBrand } = makeIssuerKit('quatloos'); +const { issuer: quatloosIssuer, mint: quatloosMint, brand: quatloosBrand } = + makeIssuerKit('quatloos'); const amountExpectedToTransfer = AmountMath.make(quatloosBrand, 2n); const originalPayment = quatloosMint.mintPayment(amountExpectedToTransfer); @@ -216,14 +218,15 @@ and the original **Payment** is unmodified. Each **Payment** in *paymentsArray* must be associated with the same **[Brand](./brand.md)** as the **Issuer**. ```js -const { mint: quatloosMint, issuer: quatloosIssuer, brand: quatloosBrand } = makeIssuerKit('quatloos'); -// create an array of 100 payments of 1 quatloo each +const { issuer: quatloosIssuer, mint: quatloosMint, brand: quatloosBrand } = + makeIssuerKit('quatloos'); +// Create an array of 100 payments of 1 quatloo each const payments = []; for (let i = 0; i < 100; i += 1) { payments.push(quatloosMint.mintPayment(AmountMath.make(quatloosBrand, 1n))); } -// combinedpayment equals 100 +// combinedPayment equals 100 const combinedPayment = quatloosIssuer.combine(payments); ``` @@ -243,7 +246,8 @@ If *payment* is a promise, the operation proceeds after it resolves to a **Payme *payment* and *paymentAmountA* must both be associated with the same **[Brand](./brand.md)** as the **Issuer**. ```js -const { mint: quatloosMint, issuer: quatloosIssuer, brand: quatloosBrand } = makeIssuerKit('quatloos'); +const { issuer: quatloosIssuer, mint: quatloosMint, brand: quatloosBrand } = + makeIssuerKit('quatloos'); const oldPayment = quatloosMint.mintPayment(AmountMath.make(quatloosBrand, 20n)); // After the split, paymentA has 5 quatloos and paymentB has 15. const [paymentA, paymentB] = quatloosIssuer.split(oldPayment, AmountMath.make(quatloosBrand, 5n)); @@ -265,7 +269,8 @@ If the **Amounts** in *amountArray* don't add up to the value of *payment*, the *payment* and each **Amount** in *amountArray* must be associated with the same **[Brand](./brand.md)** as **Issuer**. ```js -const { mint: quatloosMint, issuer: quatloosIssuer, brand: quatloosBrand} = makeIssuerKit('quatloos'); +const { issuer: quatloosIssuer, mint: quatloosMint, brand: quatloosBrand } = + makeIssuerKit('quatloos'); const oldPayment = quatloosMint.mintPayment(AmountMath.make(quatloosBrand, 100n)); const goodAmounts = Array(10).fill(AmountMath.make(quatloosBrand, 10n)); diff --git a/main/reference/ertp-api/mint.md b/main/reference/ertp-api/mint.md index 0ad9ce6584..679d66092d 100644 --- a/main/reference/ertp-api/mint.md +++ b/main/reference/ertp-api/mint.md @@ -18,7 +18,7 @@ in an unchangeable one-to-one relationship with a particular **Issuer**. const { issuer: quatloosIssuer, mint: quatloosMint } = makeIssuerKit('quatloos'); const quatloosMintIssuer = quatloosMint.getIssuer(); -// returns true +// Returns true issuer === quatloosMintIssuer; ``` @@ -31,8 +31,8 @@ From its creation, a **Mint** is always in an unchangeable one-to-one relationship with a **Brand**. ```js -const { issuer: quatloosIssuer, mint: quatloosMint - brand: quatloosBrand } = makeIssuerKit('quatloos'); +const { issuer: quatloosIssuer, mint: quatloosMint, brand: quatloosBrand } = + makeIssuerKit('quatloos'); const quatloos1000 = amountMath.make(quatloosBrand, 1000n); // newPayment will have a balance of 1000 Quatloos diff --git a/main/reference/ertp-api/payment.md b/main/reference/ertp-api/payment.md index cd29e953fa..54bf0085cd 100644 --- a/main/reference/ertp-api/payment.md +++ b/main/reference/ertp-api/payment.md @@ -40,7 +40,7 @@ Any successful operation by an **Issuer** on a **Payment** verifies it. ```js const payment = quatloosMint.mintPayment(AmountMath.make(quatloosBrand, 10n)); -//Should return 'quatloos' +// Should return 'quatloos' const allegedBrand = payment.getAllegedBrand(); ``` diff --git a/main/reference/ertp-api/purse.md b/main/reference/ertp-api/purse.md index 0ef4265f6d..d15fe0301f 100644 --- a/main/reference/ertp-api/purse.md +++ b/main/reference/ertp-api/purse.md @@ -18,7 +18,7 @@ method on the **[Issuer](./issuer.md)** associated with the **Brand** of assets new **Purse** to hold. ```js -const {issuer: quatloosIssuer} = makeIssuerKit{'quatloos'}; +const { issuer: quatloosIssuer } = makeIssuerKit('quatloos'); const quatloosPurse = quatloosIssuer.makeEmptyPurse(); ``` @@ -86,8 +86,8 @@ may pass them by. This is safe, as even if all the assets are withdrawn, the deposit still works on an empty **Purse**. ```js -const { issuer: quatloosIssuer, mint: quatloosMint, brand: quatloosBrand } = - makeIssuerKit('quatloos'); +const { issuer: quatloosIssuer, mint: quatloosMint, brand: quatloosBrand } = + makeIssuerKit('quatloos'); const quatloosPurse = quatloosIssuer.makeEmptyPurse(); const payment = quatloosMint.mintPayment(AmountMath.make(quatloosBrand, 123n)); const quatloos123 = AmountMath.make(quatloosBrand, 123n); @@ -158,6 +158,7 @@ const depositOnlyFacet = purse.getDepositFacet(); // a payment, thus depositing the payment assets in the Purse associated with the deposit facet. depositOnlyFacet.receive(payment); ``` + Once you have created a **DepositFacet**, there is one method you can call on it, **[aDepositFacet.receive()](#adepositfacet-receive-payment-optamount)**. The **DepositFacet** takes a **Payment** and adds it to the balance of the **DepositFacet**'s associated **Purse**. The **Payment** diff --git a/main/reference/repl/board.md b/main/reference/repl/board.md index e2c62d9206..a7445b869b 100644 --- a/main/reference/repl/board.md +++ b/main/reference/repl/board.md @@ -61,7 +61,7 @@ Errors: ```js // Continuing from the example above in getValue(), the id returns its associated value command[3] E(home.board).getValue("1403739213") -// returns the "abc" value +// Returns the "abc" value history[3] [Alleged: presence o-102]{} ``` diff --git a/main/reference/repl/networking.md b/main/reference/repl/networking.md index def8252c88..7dbb99e037 100644 --- a/main/reference/repl/networking.md +++ b/main/reference/repl/networking.md @@ -60,7 +60,7 @@ The other side of `connect()` is a "listening port". These ports are waiting for To get a listening port, you need a `NetworkInterface` object (such as the one on your `ag-solo` under `home.network`) and ask it to `bind()` to an endpoint. You can either provide a specific port name, or allow the API to allocate a random one for you. The endpoint specifies the type of connection that this port will be able to accept (IBC, TCP, etc), and some properties of that connection. `bind()` uses a "multiaddress" to encode this information. ```js -// ask for a random allocation - ends with a slash +// Ask for a random allocation - ends with a slash E(home.network).bind('/ibc-port/') .then(port => usePort(port)); diff --git a/main/reference/zoe-api/ratio-math.md b/main/reference/zoe-api/ratio-math.md index 2b0ef16dc9..852f909a64 100644 --- a/main/reference/zoe-api/ratio-math.md +++ b/main/reference/zoe-api/ratio-math.md @@ -273,11 +273,11 @@ denominator, and then the **Ratios** are added. For example: -1. Let's assume *left* = {numerator: 44n kilometers, denominator: 3n hours} and -*right* = {numerator: 25n kilometers, denominator: 2n hours}. +1. Let's assume *left* = { numerator: 44n kilometers, denominator: 3n hours } and +*right* = { numerator: 25n kilometers, denominator: 2n hours }. 2. *left* would be multiplied by 2/2, and *right* would be multiplied by 3/3, resulting in -*left* = {numerator: 88n kilometers, denominator: 6n hours} and *right* = {numerator: 75n kilometers, denominator: 6n hours} -3. *left* and *right* would then be added together, resulting in {numerator: 163n kilometers, denominator: 6n hours}. +*left* = { numerator: 88n kilometers, denominator: 6n hours } and *right* = { numerator: 75n kilometers, denominator: 6n hours } +3. *left* and *right* would then be added together, resulting in { numerator: 163n kilometers, denominator: 6n hours }. This **Ratio** would then be returned. @@ -298,11 +298,11 @@ denominator, and then *right* is subtracted from *left*. For example: -1. Let's assume *left* = {numerator: 44n kilometers, denominator: 3n hours} and -*right* = {numerator: 25n kilometers, denominator: 2n hours}. +1. Let's assume *left* = { numerator: 44n kilometers, denominator: 3n hours } and +*right* = { numerator: 25n kilometers, denominator: 2n hours }. 2. *left* would be multiplied by 2/2, and *right* would be multiplied by 3/3, resulting in -*left* = {numerator: 88n kilometers, denominator: 6n hours} and *right* = {numerator: 75n kilometers, denominator: 6n hours} -3. *right* would then be subtracted from *left* would then be added together, resulting in {numerator: 13n kilometers, denominator: 6n hours}. +*left* = { numerator: 88n kilometers, denominator: 6n hours } and *right* = { numerator: 75n kilometers, denominator: 6n hours } +3. *right* would then be subtracted from *left* would then be added together, resulting in { numerator: 13n kilometers, denominator: 6n hours }. This **Ratio** would then be returned. ## multiplyRatios(left, right) diff --git a/main/reference/zoe-api/zoe-helpers.md b/main/reference/zoe-api/zoe-helpers.md index 1e7797cc11..ce77a40de9 100644 --- a/main/reference/zoe-api/zoe-helpers.md +++ b/main/reference/zoe-api/zoe-helpers.md @@ -106,7 +106,7 @@ import { assertIssuerKeywords } from '@agoric/zoe/src/contractSupport/index.js'; -// proposals for this contract instance use keywords 'Asset' and 'Price' +// Proposals for this contract instance use keywords 'Asset' and 'Price' assertIssuerKeywords(zcf, harden(['Asset', 'Price'])); ``` @@ -131,14 +131,14 @@ It then calls **satisfiedBy()** on both orders of the two **seats**. If both sat it does a swap on them. ```js -import { - satisfies, -} from '@agoric/zoe/src/contractSupport/index.js'; +import { satisfies } from '@agoric/zoe/src/contractSupport/index.js'; const satisfiedBy = (xSeat, ySeat) => - satisfies(zcf, xSeat, ySeat.getCurrentAllocation()); + satisfies(zcf, xSeat, ySeat.getCurrentAllocation()); + if (satisfiedBy(offer, seat) && satisfiedBy(seat, offer)) { - swap(zcf, seat, offer); + swap(zcf, seat, offer); +} ``` ## swap(zcf, leftSeat, rightSeat) @@ -165,9 +165,7 @@ wants 3 Quatloos, **seat** A retains 2 Quatloos. If the swap fails, no assets transfer, and both *leftSeat* and *rightSeat* are exited. ```js -import { - swap -} from '@agoric/zoe/src/contractSupport.js'; +import { swap } from '@agoric/zoe/src/contractSupport.js'; swap(zcf, firstSeat, secondSeat); ``` @@ -199,9 +197,7 @@ Once the contract has been completed, please check your payout**. If the swap fails, no assets transfer, and both *leftSeat* and *rightSeat* are exited. ```js -import { - swapExact -} from '@agoric/zoe/src/contractSupport/index.js'; +import { swapExact } from '@agoric/zoe/src/contractSupport/index.js'; const swapMsg = swapExact(zcf, zcfSeatA, zcfSeatB); ``` @@ -231,14 +227,12 @@ and **give** should be **null**; the **exit** clause should specify a rule with these expectations, that **proposal** is rejected (and refunded). ```js -import { - assertProposalShape -} from '@agoric/zoe/src/contractSupport/index.js'; +import { assertProposalShape } from '@agoric/zoe/src/contractSupport/index.js'; const sellAssetForPrice = harden({ - give: { Asset: null }, - want: { Price: null }, - }); + give: { Asset: null }, + want: { Price: null }, +}); const sell = seat => { assertProposalShape(seat, sellAssetForPrice); buySeats = swapIfCanTradeAndUpdateBook(buySeats, sellSeats, seat); @@ -257,9 +251,7 @@ This means the corresponding **[Mint](/reference/ertp-api/mint.md)** creates fun If **false** throws with message **brand must be AssetKind.NAT**. ```js -import { - assertNatAssetKind -} from '@agoric/zoe/src/contractSupport/index.js'; +import { assertNatAssetKind } from '@agoric/zoe/src/contractSupport/index.js'; assertNatAssetKind(zcf, quatloosBrand); ``` @@ -280,9 +272,8 @@ If the seat has exited, aborts with the message **The recipientSeat cannot have On success, returns the exported and settable **depositToSeatSuccessMsg** which defaults to **Deposit and reallocation successful.** ```js -import { - depositToSeat, -} from '@agoric/zoe/src/contractSupport/index.js'; +import { depositToSeat } from '@agoric/zoe/src/contractSupport/index.js'; + await depositToSeat(zcf, zcfSeat, { Dep: quatloos(2n) }, { Dep: quatloosPayment }); ``` @@ -300,9 +291,8 @@ If the seat has exited, aborts with the message **The seat cannot have exited.** Unlike **depositToSeat()**, a **PaymentPKeywordRecord** is returned, not a success message. ```js -import { - withdrawFromSeat -} from '@agoric/zoe/src/contractSupport/index.js'; +import { withdrawFromSeat } from '@agoric/zoe/src/contractSupport/index.js'; + const paymentKeywordRecord = await withdrawFromSeat(zcf, zcfSeat, { With: quatloos(2n) }); ``` @@ -318,9 +308,8 @@ This does **not** error if any of the **[Keywords](./zoe-data-types.md#keyword)* already present, it is ignored. ```js -import { - saveAllIssuers, -} from '@agoric/zoe/src/contractSupport/index.js'; +import { saveAllIssuers } from '@agoric/zoe/src/contractSupport/index.js'; + await saveAllIssuers(zcf, { G: gIssuer, D: dIssuer, P: pIssuer }); ``` @@ -355,10 +344,10 @@ contractA reverses this mapping. It looks like this, where the **Keywords** are from the contracts indicated by using "A" or "B" in the **Keyword** name. ```js // Map the keywords in contractA to the keywords in contractB - const keywordMapping = harden({ - TokenA1: 'TokenB1', - TokenA2: 'TokenB2' - }); +const keywordMapping = harden({ + TokenA1: 'TokenB1', + TokenA2: 'TokenB2', +}); ``` *offerArgs* is an object that can be used to pass @@ -381,11 +370,11 @@ Its two properties are: - **deposited**: **Promise<AmountKeywordRecord>** ```js - const { userSeatPromise: AMMUserSeat, deposited } = zcf.offerTo( - swapInvitation, - keywordMapping, // {} - proposal, - fromSeat, - lenderSeat - ); +const { userSeatPromise: AMMUserSeat, deposited } = zcf.offerTo( + swapInvitation, + keywordMapping, // {} + proposal, + fromSeat, + lenderSeat, +); ``` diff --git a/main/reference/zoe-api/zoe.md b/main/reference/zoe-api/zoe.md index 2ebf2b70df..f0c8fa22bf 100644 --- a/main/reference/zoe-api/zoe.md +++ b/main/reference/zoe-api/zoe.md @@ -34,7 +34,7 @@ and the values are the **Brands** for particular **[Issuers](/reference/ertp-api const brandKeywordRecord = { FirstCurrency: quatloosBrand, SecondCurrency: moolaBrand, - //etc. + // etc. }; ``` @@ -74,12 +74,12 @@ custom terms. The returned values look like: ```js { - //brands and issuers are keywordRecords + // Brands and issuers are keywordRecords brands: { A: moolaKit.brand, B: simoleanKit.brand }, issuers: { A: moolaKit.issuer, B: simoleanKit.issuer }, customTermA: 'something', customTermB: 'something else', - //All other customTerms + // All other customTerms }; ``` @@ -114,7 +114,7 @@ const invitationIssuer = await E(Zoe).getInvitationIssuer(); // transform the untrusted invitation to a trusted one const trustedInvitation = await invitationIssuer.claim(untrustedInvitation); const { value: invitationValue } = - await E(invitationIssuer).getAmountOf(trustedInvitation); + await E(invitationIssuer).getAmountOf(trustedInvitation); ``` ## E(Zoe).getInvitationDetails(invitation) @@ -242,7 +242,7 @@ not be in the public terms. For example, to share minting authority among multiple contracts, pass in the following as **privateArgs**: ```js -{ externalMint: myExternalMint } +const privateArgs = { externalMint: myExternalMint }; ``` It returns a **Promise** for a **StartInstanceResult** object. The object consists of: @@ -278,11 +278,11 @@ represented as a **Payment**. ```js const issuerKeywordRecord = { Asset: moolaIssuer, - Price: quatlooIssuer + Price: quatlooIssuer, }; const terms = { numBids: 3 }; -const { creatorFacet, publicFacet, creatorInvitation } = await E(Zoe).startInstance( - installation, issuerKeywordRecord, terms); +const { creatorFacet, publicFacet, creatorInvitation } = + await E(Zoe).startInstance(installation, issuerKeywordRecord, terms); ```