Skip to content

Commit fcb738e

Browse files
committed
lint: inline snippets
1 parent e8cb88e commit fcb738e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+852
-842
lines changed

CONTRIBUTING.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ module.exports = {
107107
themeConfig: {
108108
sidebar: 'auto'
109109
}
110-
}
110+
};
111111
```
112112

113113
Or, add a config entry, either as part of a group or as an individual page.
@@ -133,7 +133,7 @@ module.exports = {
133133
}
134134
]
135135
}
136-
}
136+
};
137137
```
138138

139139
## Writing Links
@@ -564,8 +564,8 @@ export default ({ router }) => {
564564
path: '/getting-started/agoric-cli-guide.html',
565565
redirect: '/guides/agoric-cli/'
566566
}
567-
])
568-
}
567+
]);
568+
};
569569
```
570570

571571
The general format should be self-explanatory. However, there are two things you need to know that aren't apparent

main/e2e-testing.md

+15-15
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,16 @@ Before you start writing your E2E tests, you'll need to create a configuration f
4040
Inside `synpress.config.js`, you'll set the `baseUrl` property within the e2e configuration. This tells Cypress where to find your DApp during testing. Here's an example configuration:
4141

4242
```js
43-
const baseConfig = require('@agoric/synpress/synpress.config')
44-
const { defineConfig } = require('cypress')
43+
const baseConfig = require('@agoric/synpress/synpress.config');
44+
const { defineConfig } = require('cypress');
4545

4646
module.exports = defineConfig({
4747
...baseConfig,
4848
e2e: {
4949
...baseConfig.e2e,
5050
baseUrl: 'http://localhost:5173'
5151
}
52-
})
52+
});
5353
```
5454

5555
In this example, `baseUrl` is set to `http://localhost:5173`. Make sure to replace this with the actual URL where your DApp is running.
@@ -69,7 +69,7 @@ Navigate to your project's `tests/e2e` directory and create a new file named `su
6969
After creating your `support.js` file, make sure to include the following import statement:
7070

7171
```js
72-
import '@agoric/synpress/support/index'
72+
import '@agoric/synpress/support/index';
7373
```
7474

7575
This import is essential because it brings in the necessary functionalities from `@agoric/synpress` to interact with the Keplr wallet within your e2e tests. Without it, your tests won't be able to leverage the features provided by `@agoric/synpress` for Keplr integration.
@@ -86,8 +86,8 @@ You use `describe` blocks to group related tests together, and `it` blocks to de
8686
describe('User Login', () => {
8787
it('should login with valid credentials', () => {
8888
// Test steps for login functionality
89-
})
90-
})
89+
});
90+
});
9191
```
9292

9393
### Test 1: Setting Up Keplr Wallet
@@ -96,9 +96,9 @@ describe('User Login', () => {
9696
it('should setup a Keplr wallet', () => {
9797
cy.setupWallet({
9898
secretWords: 'KEPLR_MNEMONIC'
99-
})
100-
cy.visit('/')
101-
})
99+
});
100+
cy.visit('/');
101+
});
102102
```
103103

104104
This test case simulates setting up a Keplr wallet for your tests, using the `cy.setupWallet` method. Make sure to replace `KEPLR_MNEMONIC` with a 24-word mnemonic phrase. The `setupWallet` method creates a wallet based on the provided mnemonic phrase, which can then be used throughout your test suite.
@@ -109,9 +109,9 @@ After setting up the wallet, we visit the root path (`/`) of the DApp using `cy.
109109

110110
```js
111111
it('should accept connection with wallet', () => {
112-
cy.contains('Connect Wallet').click()
113-
cy.acceptAccess()
114-
})
112+
cy.contains('Connect Wallet').click();
113+
cy.acceptAccess();
114+
});
115115
```
116116

117117
This test simulates a user connecting their Keplr wallet to your DApp. `cy.contains('Connect Wallet')` searches for an element containing the text `Connect Wallet` on the webpage and triggers a click event. `cy.acceptAccess` simulates accepting Keplr wallet access for your DApp.
@@ -120,9 +120,9 @@ This test simulates a user connecting their Keplr wallet to your DApp. `cy.conta
120120

121121
```js
122122
it('should confirm make an offer transaction', () => {
123-
cy.contains('Make an Offer').click()
124-
cy.confirmTransaction()
125-
})
123+
cy.contains('Make an Offer').click();
124+
cy.confirmTransaction();
125+
});
126126
```
127127

128128
This test simulates transaction Signing on your DApp. `cy.contains('Make an Offer')` searches for an element containing the text `Make an Offer` and triggers a click event. `cy.confirmTransaction` simulates confirming a transaction.

main/glossary/index.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,10 @@ and the [ERTP API's Brand section](/reference/ertp-api/brand).
141141
Before a contract can be installed on Zoe, its source code must be bundled. This is done by:
142142

143143
```js
144-
import bundleSource from '@endo/bundle-source'
144+
import bundleSource from '@endo/bundle-source';
145145
const atomicSwapBundle = await bundleSource(
146146
require.resolve('@agoric/zoe/src/contracts/atomicSwap')
147-
)
147+
);
148148
```
149149

150150
The installation operation returns an `installation`, which is an object with a single
@@ -153,7 +153,7 @@ In most cases, the bundle contains a base64-encoded zip file that you can
153153
extract for review.
154154

155155
```js
156-
const { endoZipBase64 } = await E(installation).getBundle()
156+
const { endoZipBase64 } = await E(installation).getBundle();
157157
```
158158

159159
```sh
@@ -296,10 +296,10 @@ A _facet_ is an object that exposes an API or particular view of some larger ent
296296
You can make any number of facets of an entity. In JavaScript, you often make a facet that forwards method calls:
297297

298298
```js
299-
import { Far } from '@endo/far'
299+
import { Far } from '@endo/far';
300300
const facet = Far('FacetName', {
301301
myMethod: (...args) => oldObject.method(...args)
302-
})
302+
});
303303
```
304304

305305
Two Agoric uses are:
@@ -550,7 +550,7 @@ const myProposal = harden({
550550
give: { Asset: AmountMath.make(quatloosBrand, 4n) },
551551
want: { Price: AmountMath.make(moolaBrand, 15n) },
552552
exit: { onDemand: null }
553-
})
553+
});
554554
```
555555

556556
`give` and `want` each associate [Keywords](#keyword) defined by the contract with corresponding [Amounts](#amount) describing respectively what will be given and what is being requested in exchange.

main/guides/coreeval/permissions.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ export const permit = harden({
2525
instance: { produce: { [contractName]: true } },
2626
issuer: { consume: { IST: true }, produce: { Ticket: true } },
2727
brand: { consume: { IST: true }, produce: { Ticket: true } }
28-
})
28+
});
2929

30-
export const main = startSellConcertTicketsContract
30+
export const main = startSellConcertTicketsContract;
3131
```
3232

3333
## Selected BootstrapPowers

main/guides/coreeval/proposal.md

+23-23
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ After some preliminaries, ...
1919

2020
```js
2121
// @ts-check
22-
import { allValues } from './objectTools.js'
22+
import { allValues } from './objectTools.js';
2323
import {
2424
AmountMath,
2525
installContract,
2626
startContract
27-
} from './platform-goals/start-contract.js'
27+
} from './platform-goals/start-contract.js';
2828

29-
const { Fail } = assert
30-
const IST_UNIT = 1_000_000n
29+
const { Fail } = assert;
30+
const IST_UNIT = 1_000_000n;
3131

3232
export const makeInventory = (brand, baseUnit) => {
3333
return {
@@ -43,14 +43,14 @@ export const makeInventory = (brand, baseUnit) => {
4343
tradePrice: AmountMath.make(brand, baseUnit * 1n),
4444
maxTickets: 3n
4545
}
46-
}
47-
}
46+
};
47+
};
4848

4949
export const makeTerms = (brand, baseUnit) => {
5050
return {
5151
inventory: makeInventory(brand, baseUnit)
52-
}
53-
}
52+
};
53+
};
5454

5555
/**
5656
* @typedef {{
@@ -66,7 +66,7 @@ export const makeTerms = (brand, baseUnit) => {
6666
... the function for deploying the contract is `startSellConcertTicketsContract`:
6767

6868
```js
69-
const contractName = 'sellConcertTickets'
69+
const contractName = 'sellConcertTickets';
7070

7171
/**
7272
* Core eval script to start contract
@@ -75,23 +75,23 @@ const contractName = 'sellConcertTickets'
7575
* @param {*} config
7676
*/
7777
export const startSellConcertTicketsContract = async (powers, config) => {
78-
console.log('core eval for', contractName)
78+
console.log('core eval for', contractName);
7979
const {
8080
// must be supplied by caller or template-replaced
8181
bundleID = Fail`no bundleID`
82-
} = config?.options?.[contractName] ?? {}
82+
} = config?.options?.[contractName] ?? {};
8383

8484
const installation = await installContract(powers, {
8585
name: contractName,
8686
bundleID
87-
})
87+
});
8888

8989
const ist = await allValues({
9090
brand: powers.brand.consume.IST,
9191
issuer: powers.issuer.consume.IST
92-
})
92+
});
9393

94-
const terms = makeTerms(ist.brand, 1n * IST_UNIT)
94+
const terms = makeTerms(ist.brand, 1n * IST_UNIT);
9595

9696
await startContract(powers, {
9797
name: contractName,
@@ -101,10 +101,10 @@ export const startSellConcertTicketsContract = async (powers, config) => {
101101
terms
102102
},
103103
issuerNames: ['Ticket']
104-
})
104+
});
105105

106-
console.log(contractName, '(re)started')
107-
}
106+
console.log(contractName, '(re)started');
107+
};
108108
```
109109
110110
A `BootstrapPowers` object is composed of several _promise spaces_.
@@ -137,12 +137,12 @@ export const installContract = async (
137137
{ consume: { zoe }, installation: { produce: produceInstallation } },
138138
{ name, bundleID }
139139
) => {
140-
const installation = await E(zoe).installBundleID(bundleID)
141-
produceInstallation[name].reset()
142-
produceInstallation[name].resolve(installation)
143-
console.log(name, 'installed as', bundleID.slice(0, 8))
144-
return installation
145-
}
140+
const installation = await E(zoe).installBundleID(bundleID);
141+
produceInstallation[name].reset();
142+
produceInstallation[name].resolve(installation);
143+
console.log(name, 'installed as', bundleID.slice(0, 8));
144+
return installation;
145+
};
146146
```
147147
148148
This `installation` promise space is linked to the `E(agoricNames).lookup('installation')` NameHub: when you call `produce[name].resolve(value)` on the installation promise space, it triggers an update in the NameHub. The update associates the provided name with the provided value so that `E(agoricNames).lookup('installation', name)` is a promise for `value`.

main/guides/getting-started/deploying.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ file `ui/public/conf/installationConstants.js` with contents like:
5858
export default {
5959
CONTRACT_NAME: 'fungibleFaucet',
6060
INSTALLATION_BOARD_ID: '1456154132'
61-
}
61+
};
6262
```
6363

6464
The board provides a unique ID per object, in this case

main/guides/getting-started/sell-concert-tickets-contract-explainer.md

+14-14
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const inventory = {
3333
tradePrice: AmountMath.make(istBrand, n),
3434
maxTickets: n
3535
}
36-
}
36+
};
3737
```
3838

3939
Our contract takes the provided `inventory` object as a parameter to initiate the process.
@@ -49,8 +49,8 @@ In our example, tickets are non-fungible and can have duplicates, meaning there
4949
</details>
5050

5151
```js
52-
const ticketMint = await zcf.makeZCFMint('Ticket', AssetKind.COPY_BAG)
53-
const { brand: ticketBrand } = ticketMint.getIssuerRecord()
52+
const ticketMint = await zcf.makeZCFMint('Ticket', AssetKind.COPY_BAG);
53+
const { brand: ticketBrand } = ticketMint.getIssuerRecord();
5454
```
5555

5656
Once our asset is defined, we will mint our inventory at the start of our the smart contract and allocate it to our `inventorySeat` object.
@@ -69,14 +69,14 @@ const inventoryBag = makeCopyBag(
6969
ticket,
7070
maxTickets
7171
])
72-
)
72+
);
7373
const toMint = {
7474
Tickets: {
7575
brand: ticketBrand,
7676
value: inventoryBag
7777
}
78-
}
79-
const inventorySeat = ticketMint.mintGains(toMint)
78+
};
79+
const inventorySeat = ticketMint.mintGains(toMint);
8080
```
8181

8282
## Trading Tickets
@@ -85,7 +85,7 @@ Customers who wish to purchase event tickets first [make an invitation](https://
8585

8686
```js
8787
const makeTradeInvitation = () =>
88-
zcf.makeInvitation(tradeHandler, 'buy tickets', undefined, proposalShape)
88+
zcf.makeInvitation(tradeHandler, 'buy tickets', undefined, proposalShape);
8989
```
9090

9191
Here you can see two important parameters:
@@ -94,9 +94,9 @@ Here you can see two important parameters:
9494

9595
```js
9696
const tradeHandler = buyerSeat => {
97-
const { give, want } = buyerSeat.getProposal()
97+
const { give, want } = buyerSeat.getProposal();
9898
// ... checks and transfers
99-
}
99+
};
100100
```
101101

102102
- **proposalShape** (Optional): This object outlines the necessary and permissible elements of each [proposal](https://docs.agoric.com/reference/zoe-api/zoe-contract-facet.html#proposal-shapes). Here is the proposal shape for this contract.
@@ -106,7 +106,7 @@ const proposalShape = harden({
106106
give: { Price: AmountShape },
107107
want: { Tickets: { brand: ticketBrand, value: M.bag() } },
108108
exit: M.any()
109-
})
109+
});
110110
```
111111

112112
## Trade Handler
@@ -115,20 +115,20 @@ The `tradeHandler` function begins by checking to see if there are enough ticket
115115

116116
```js
117117
AmountMath.isGTE(inventorySeat.getCurrentAllocation().Tickets, want.Tickets) ||
118-
Fail`Not enough inventory, ${q(want.Tickets)} wanted`
118+
Fail`Not enough inventory, ${q(want.Tickets)} wanted`;
119119
```
120120

121121
Next, the total price is calcualted using `bagPrice`:
122122

123123
```js
124-
const totalPrice = bagPrice(want.Tickets.value, inventory)
124+
const totalPrice = bagPrice(want.Tickets.value, inventory);
125125
```
126126

127127
After that, a check is made to ensure the offered price is sufficient:
128128

129129
```js
130130
AmountMath.isGTE(give.Price, totalPrice) ||
131-
Fail`Total price is ${q(totalPrice)}, but ${q(give.Price)} was given`
131+
Fail`Total price is ${q(totalPrice)}, but ${q(give.Price)} was given`;
132132
```
133133

134134
Finally, `atomicRearrange` can be called to exchange the requested tickets for the required payment:
@@ -142,7 +142,7 @@ atomicRearrange(
142142
// tickets from inventory to buyer
143143
[inventorySeat, buyerSeat, want]
144144
])
145-
)
145+
);
146146
```
147147

148148
Take a complete look at this example code in our [Github repository](https://github.com/Agoric/dapp-agoric-basics/blob/main/contract/src/sell-concert-tickets.contract.js).

0 commit comments

Comments
 (0)