Skip to content

Commit

Permalink
chore: make cosmic-swingset lint clean (#1054)
Browse files Browse the repository at this point in the history
ensure linting errors in lib-wallet.js especially are caught by CI
  • Loading branch information
katelynsills authored May 4, 2020
1 parent e6e1736 commit cab6be8
Show file tree
Hide file tree
Showing 11 changed files with 40 additions and 29 deletions.
1 change: 1 addition & 0 deletions packages/cosmic-swingset/calc-rpcport.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const toml = require('@iarna/toml');
const configString = fs.readFileSync(process.argv[2]).toString();
const config = toml.parse(configString);
const { laddr } = config.rpc; // like tcp://0.0.0.0:26657
// eslint-disable-next-line no-useless-escape
const m = laddr.match(/^tcp:\/\/([\d\.]+):(\d+)$/);
if (!m) {
throw new Error(`error, unexpected laddr format ${laddr}`);
Expand Down
1 change: 1 addition & 0 deletions packages/cosmic-swingset/lib/ag-solo/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ export default async function bundle(insistIsBasedir, args) {
const main = mainNS.default;
if (typeof main !== 'function') {
console.error(`Bundle main does not have an export default function`);
// eslint-disable-next-line no-continue
continue;
}

Expand Down
8 changes: 8 additions & 0 deletions packages/cosmic-swingset/lib/ag-solo/chain-cosmos-sdk.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,21 @@ export async function connectToChain(
const queued = {};

async function retryRpcAddr(tryOnce) {
// eslint-disable-next-line no-constant-condition
while (true) {
const randomRpcAddr =
rpcAddresses[Math.floor(Math.random() * rpcAddresses.length)];

// tryOnce will either throw if cancelled (which rejects this promise),
// eslint-disable-next-line no-await-in-loop
const ret = await tryOnce(randomRpcAddr);
if (ret !== undefined) {
// Or returns non-undefined, which we should resolve.
return ret;
}

// It was undefined, so wait, then retry.
// eslint-disable-next-line no-await-in-loop
await new Promise(resolve => setTimeout(resolve, 5000));
}
}
Expand All @@ -96,6 +99,7 @@ export async function connectToChain(
throwIfCancelled = () => undefined,
defaultIfCancelled = WAS_CANCELLED_EXCEPTION,
) {
// eslint-disable-next-line consistent-return
return retryRpcAddr(async rpcAddr => {
await throwIfCancelled();

Expand Down Expand Up @@ -165,6 +169,7 @@ export async function connectToChain(
if (maxQueued !== undefined) {
while (queue.length > 0 && queue.length >= maxQueued) {
// Cancel the excesses from most recent down to the currently-running.
// eslint-disable-next-line no-unused-vars
const [proceed, cancel] = queue.pop();
log.debug(`cancelling ${queue.length}`);
cancel();
Expand All @@ -188,6 +193,7 @@ export async function connectToChain(
resolveWait = resolve;
if (queue[0] === qentry) {
// Wake us immediately, since we're first in queue.
// eslint-disable-next-line no-unused-vars
const [proceed, cancel] = qentry;
proceed();
}
Expand Down Expand Up @@ -216,6 +222,7 @@ export async function connectToChain(
}
if (queue[0] !== undefined) {
// Wake the next in queue.
// eslint-disable-next-line no-unused-vars
const [proceed, cancel] = queue[0];
proceed();
}
Expand All @@ -227,6 +234,7 @@ export async function connectToChain(
'getMailbox',
1, // Only one helper running at a time.
['query', 'swingset', 'mailbox', myAddr],
// eslint-disable-next-line consistent-return
ret => {
const { stdout, stderr } = ret;
log.error(stderr);
Expand Down
1 change: 1 addition & 0 deletions packages/cosmic-swingset/lib/ag-solo/set-gci-ingress.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export default function setGCIIngress(basedir, GCI, rpcAddresses, chainID) {
};
add(newconn);
const connections = [];
// eslint-disable-next-line no-unused-vars
Object.entries(connsByType).forEach(([type, conns]) =>
connections.push(...conns),
);
Expand Down
32 changes: 22 additions & 10 deletions packages/cosmic-swingset/lib/ag-solo/upload-contract.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
// This javascript source file uses the "tildot" syntax (foo~.bar()) for
// eventual sends.
// In the future, this javascript source file will use the "tildot"
// syntax (foo~.bar()) for eventual sends.
// https://agoric.com/documentation/ertp/guide/other-concepts.html
// Tildot is standards track with TC39, the JavaScript standards committee.
// https://github.com/tc39/proposal-wavy-dot
// Tildot is standards track with TC39, the JavaScript standards
// committee. https://github.com/tc39/proposal-wavy-dot

import { E } from '@agoric/eventual-send';

export default async function uploadContracts({ home, bundle }) {
console.error(`Installing targeted contracts...`);
await upload(home, bundle, Object.keys(bundle).filter(k => k !== 'main').sort(), true);
// eslint-disable-next-line no-use-before-define
await upload(
home,
bundle,
Object.keys(bundle)
.filter(k => k !== 'main')
.sort(),
true,
);
}

export async function upload(homeP, bundle, keys, verbose = false) {
Expand All @@ -22,7 +32,8 @@ export async function upload(homeP, bundle, keys, verbose = false) {
const { source, moduleFormat } = bundle[key];
// console.error(`Uploading ${source}`);

const targetObj = await homeP~.[target];
// eslint-disable-next-line no-await-in-loop
const targetObj = await E(homeP)[target];
if (!targetObj) {
console.error(
`Contract installation target object ${target} is not available for ${name}; skipping...`,
Expand All @@ -32,15 +43,16 @@ export async function upload(homeP, bundle, keys, verbose = false) {
if (verbose) {
console.debug(name);
}
contractsAP.push(targetObj~.install(source, moduleFormat));
contractsAP.push(E(targetObj).install(source, moduleFormat));
names.push(name);
}
}

const uploadsP = homeP~.uploads;
const uploadsP = E(homeP).uploads;
const contracts = await Promise.all(contractsAP);
for (let i = 0; i < contracts.length; i ++) {
await uploadsP~.set(names[i], contracts[i]);
for (let i = 0; i < contracts.length; i += 1) {
// eslint-disable-next-line no-await-in-loop
await E(uploadsP).set(names[i], contracts[i]);
}

console.error('See home.uploads~.list()');
Expand Down
1 change: 1 addition & 0 deletions packages/cosmic-swingset/lib/ag-solo/vats/ibc.js
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,7 @@ export function makeIBCProtocolHandler(

// TODO: Will need to change to dispatch (without sending)
// a ChanOpenInit to get a passive relayer flowing.
// eslint-disable-next-line no-constant-condition
if (false) {
const packet = {
source_channel: channelID,
Expand Down
2 changes: 1 addition & 1 deletion packages/cosmic-swingset/lib/ag-solo/vats/vat-registrar.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { makeRegistrar } from '@agoric/registrar';

// This vat contains the registrar for the demo.

function build(E, log) {
function build(_E, _log) {
const sharedRegistrar = makeRegistrar();

function getSharedRegistrar() {
Expand Down
2 changes: 1 addition & 1 deletion packages/cosmic-swingset/lib/ag-solo/vats/vat-sharing.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { makeSharingService } from '@agoric/sharing-service';

// This vat contains the sharing service for the demo.

function build(E, log) {
function build(_E, _log) {
const sharingService = makeSharingService();

function getSharingService() {
Expand Down
2 changes: 1 addition & 1 deletion packages/cosmic-swingset/lib/ag-solo/vats/vat-uploads.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import makeScratchPad from './scratch';

// This vat contains the private upload scratch pad.

function build(E, log) {
function build(_E, _log) {
const uploads = makeScratchPad();

function getUploads() {
Expand Down
5 changes: 3 additions & 2 deletions packages/cosmic-swingset/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"pretty-check": "prettier --check '**/*.js'",
"lint": "eslint '**/*.js'",
"lint-fix": "eslint --fix '**/*.js'",
"lint-check": "echo disabling lint in cosmic-swingset until files are lint compliant"
"lint-check": "eslint '**/*.js'"
},
"keywords": [],
"author": "Agoric",
Expand Down Expand Up @@ -66,5 +66,6 @@
},
"publishConfig": {
"access": "public"
}
},
"engines" : { "node" : ">=11.0" }
}
14 changes: 0 additions & 14 deletions packages/cosmic-swingset/test/test-node-version.js

This file was deleted.

0 comments on commit cab6be8

Please sign in to comment.