Skip to content

Commit

Permalink
Merge pull request #4330 from Agoric/ta/prettier-2.5.1
Browse files Browse the repository at this point in the history
style: upgrade prettier to 2.5.1 and reformat
  • Loading branch information
mergify[bot] authored Feb 4, 2022
2 parents 50e8523 + b7c2a9b commit 1daf09d
Show file tree
Hide file tree
Showing 170 changed files with 1,502 additions and 2,137 deletions.
6 changes: 4 additions & 2 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
## Uses .gitignore syntax and should mostly match that file
## so that we don't format what never ends up in SCM.

# artifacts
build
bundles
bundle-*.js
compiled
dist
lcov-report
Expand All @@ -18,5 +22,3 @@ public
# copied from upstream
/packages/xsnap/lib/object-inspect.js

# XXX unsupported syntax; will be addressed in https://github.com/Agoric/agoric-sdk/issues/4329
/packages/captp/src/ts-types.d.ts
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"eslint-plugin-prettier": "^3.2.0",
"lerna": "^3.20.2",
"npm-run-all": "^4.1.5",
"prettier": "^1.19.1",
"prettier": "^2.5.1",
"typescript": "~4.5.5"
},
"engines": {
Expand All @@ -72,6 +72,7 @@
"root": true
},
"prettier": {
"arrowParens": "avoid",
"trailingComma": "all",
"singleQuote": true
},
Expand All @@ -81,8 +82,8 @@
"lerna": "lerna",
"link-cli": "yarn run create-agoric-cli",
"create-agoric-cli": "node ./scripts/create-agoric-cli.cjs",
"format": "yarn prettier --write '{.github,golang,packages}/**/*.{js,jsx,ts,tsx,yml,yaml}'",
"lint:format": "yarn prettier --check '{.github,golang,packages}/**/*.{js,jsx,ts,tsx,yml,yaml}'",
"format": "yarn prettier --write .github golang packages",
"lint:format": "yarn prettier --check .github golang packages",
"lint-fix": "yarn workspaces run lint-fix",
"lint": "run-s --continue-on-error lint:*",
"lint:packages": "yarn workspaces run lint",
Expand Down
6 changes: 2 additions & 4 deletions packages/ERTP/src/purse.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ export const makePurse = (allegedName, assetKind, brand, purseMethods) => {
let currentBalance = AmountMath.makeEmpty(brand, assetKind);

/** @type {NotifierRecord<Amount>} */
const {
notifier: balanceNotifier,
updater: balanceUpdater,
} = makeNotifierKit(currentBalance);
const { notifier: balanceNotifier, updater: balanceUpdater } =
makeNotifierKit(currentBalance);

const updatePurseBalance = newPurseBalance => {
currentBalance = newPurseBalance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,12 @@ test('copyBag with strings getValue', t => {
);
t.deepEqual(
getCopyBagEntries(
/** @type {CopyBag<Key>} */ (m.getValue(
mockBrand,
harden({ brand: mockBrand, value: makeBag(['1']) }),
)),
/** @type {CopyBag<Key>} */ (
m.getValue(
mockBrand,
harden({ brand: mockBrand, value: makeBag(['1']) }),
)
),
),
[['1', 1n]],
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,12 @@ test('copySet with strings getValue', t => {
);
t.deepEqual(
getCopySetKeys(
/** @type {CopySet<Key>} */ (m.getValue(
mockBrand,
harden({ brand: mockBrand, value: makeCopySet(['1']) }),
)),
/** @type {CopySet<Key>} */ (
m.getValue(
mockBrand,
harden({ brand: mockBrand, value: makeCopySet(['1']) }),
)
),
),
['1'],
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ test('natMathHelpers coerce', t => {
}),
),
{
message: /The brand in the allegedAmount .* in 'coerce' didn't match the specified brand/,
message:
/The brand in the allegedAmount .* in 'coerce' didn't match the specified brand/,
},
`coerce can't take the wrong brand`,
);
Expand Down
3 changes: 2 additions & 1 deletion packages/ERTP/test/unitTests/test-inputValidation.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ test('makeIssuerKit bad allegedName', async t => {
test('makeIssuerKit bad assetKind', async t => {
// @ts-ignore Intentional wrong type for testing
t.throws(() => makeIssuerKit('myTokens', 'somethingWrong'), {
message: /The assetKind "somethingWrong" must be one of \["copyBag","copySet","nat","set"\]/,
message:
/The assetKind "somethingWrong" must be one of \["copyBag","copySet","nat","set"\]/,
});
});

Expand Down
47 changes: 21 additions & 26 deletions packages/ERTP/test/unitTests/test-issuerObj.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ test('bad display info', t => {
const displayInfo = harden({ somethingUnexpected: 3 });
// @ts-ignore deliberate invalid arguments for testing
t.throws(() => makeIssuerKit('fungible', AssetKind.NAT, displayInfo), {
message: /key "somethingUnexpected" was not one of the expected keys \["decimalPlaces","assetKind"\]/,
message:
/key "somethingUnexpected" was not one of the expected keys \["decimalPlaces","assetKind"\]/,
});
});

Expand Down Expand Up @@ -163,21 +164,19 @@ test('purse.deposit', async t => {
nextUpdate = notifier.getUpdateSince(updateCount);
};

const checkDeposit = (
expectedOldBalance,
expectedNewBalance,
) => async depositResult => {
const delta = AmountMath.subtract(expectedNewBalance, expectedOldBalance);
t.assert(
AmountMath.isEqual(depositResult, delta),
`the balance changes by the deposited amount: ${delta.value}`,
);
t.assert(
AmountMath.isEqual(purse.getCurrentAmount(), expectedNewBalance),
`the new purse balance ${depositResult.value} is the expected amount: ${expectedNewBalance.value}`,
);
await checkNotifier();
};
const checkDeposit =
(expectedOldBalance, expectedNewBalance) => async depositResult => {
const delta = AmountMath.subtract(expectedNewBalance, expectedOldBalance);
t.assert(
AmountMath.isEqual(depositResult, delta),
`the balance changes by the deposited amount: ${delta.value}`,
);
t.assert(
AmountMath.isEqual(purse.getCurrentAmount(), expectedNewBalance),
`the new purse balance ${depositResult.value} is the expected amount: ${expectedNewBalance.value}`,
);
await checkNotifier();
};

await checkNotifier();
await E(purse)
Expand Down Expand Up @@ -333,7 +332,8 @@ test('issuer.split bad amount', async t => {
await t.throwsAsync(
_ => E(issuer).split(payment, AmountMath.make(otherBrand, 10n)),
{
message: /The brand in the allegedAmount .* in 'coerce' didn't match the specified brand/,
message:
/The brand in the allegedAmount .* in 'coerce' didn't match the specified brand/,
},
'throws for bad amount',
);
Expand Down Expand Up @@ -396,9 +396,7 @@ test('issuer.combine good payments', async t => {
),
);
};
await E(issuer)
.combine(payments)
.then(checkCombinedPayment);
await E(issuer).combine(payments).then(checkCombinedPayment);
});

test('issuer.combine array of promises', async t => {
Expand All @@ -418,16 +416,13 @@ test('issuer.combine array of promises', async t => {
});
};

await E(issuer)
.combine(paymentsP)
.then(checkCombinedResult);
await E(issuer).combine(paymentsP).then(checkCombinedResult);
});

test('issuer.combine bad payments', async t => {
const { mint, issuer, brand } = makeIssuerKit('fungible');
const { mint: otherMint, brand: otherBrand } = makeIssuerKit(
'other fungible',
);
const { mint: otherMint, brand: otherBrand } =
makeIssuerKit('other fungible');
const payments = [];
for (let i = 0; i < 100; i += 1) {
payments.push(mint.mintPayment(AmountMath.make(brand, 1n)));
Expand Down
12 changes: 4 additions & 8 deletions packages/SwingSet/demo/encouragementBotComms/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@ export function buildRootObject(vatPowers) {
D(devices.loopbox).registerInboundHandler(USER, vats.uservattp);
const usersender = D(devices.loopbox).getSender(USER);
await E(vats.uservattp).registerMailboxDevice(usersender);
const {
transmitter: txToBotForUser,
setReceiver: setRxFromBotForUser,
} = await E(vats.uservattp).addRemote(BOT);
const { transmitter: txToBotForUser, setReceiver: setRxFromBotForUser } =
await E(vats.uservattp).addRemote(BOT);
await E(vats.usercomms).addRemote(
BOT,
txToBotForUser,
Expand All @@ -29,10 +27,8 @@ export function buildRootObject(vatPowers) {
D(devices.loopbox).registerInboundHandler(BOT, vats.botvattp);
const botsender = D(devices.loopbox).getSender(BOT);
await E(vats.botvattp).registerMailboxDevice(botsender);
const {
transmitter: txToUserForBot,
setReceiver: setRxFromUserForBot,
} = await E(vats.botvattp).addRemote(USER);
const { transmitter: txToUserForBot, setReceiver: setRxFromUserForBot } =
await E(vats.botvattp).addRemote(USER);
await E(vats.botcomms).addRemote(
USER,
txToUserForBot,
Expand Down
7 changes: 2 additions & 5 deletions packages/SwingSet/src/devices/command-src.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@ import { assert, details as X } from '@agoric/assert';

export function buildRootDeviceNode(tools) {
const { SO, getDeviceState, setDeviceState, endowments } = tools;
const {
registerInboundCallback,
deliverResponse,
sendBroadcast,
} = endowments;
const { registerInboundCallback, deliverResponse, sendBroadcast } =
endowments;
let { inboundHandler } = getDeviceState() || {};

registerInboundCallback((count, bodyString) => {
Expand Down
9 changes: 2 additions & 7 deletions packages/SwingSet/src/devices/loopbox-src.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,8 @@ import { assert, details as X } from '@agoric/assert';
import { Far } from '@endo/marshal';

export function buildRootDeviceNode(tools) {
const {
SO,
endowments,
deviceParameters,
getDeviceState,
setDeviceState,
} = tools;
const { SO, endowments, deviceParameters, getDeviceState, setDeviceState } =
tools;
const { registerPassOneMessage, deliverMode } = endowments;

function makeSender(sender) {
Expand Down
11 changes: 2 additions & 9 deletions packages/SwingSet/src/kernel/collectionManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -646,15 +646,8 @@ export function makeCollectionManager(
if (hasWeakKeys) {
collection = weakMethods;
} else {
const {
keys,
values,
entries,
sizeInternal,
getSize,
snapshot,
clear,
} = raw;
const { keys, values, entries, sizeInternal, getSize, snapshot, clear } =
raw;
collection = {
...weakMethods,
keys,
Expand Down
10 changes: 5 additions & 5 deletions packages/SwingSet/src/kernel/json-stable-stringify.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ const isArray =

const objectKeys =
Object.keys ||
function(obj) {
function (obj) {
const has =
Object.prototype.hasOwnProperty ||
function() {
function () {
return true;
};
const keys = [];
Expand All @@ -36,9 +36,9 @@ export default function stableStringify(obj, opts) {

const cmp =
opts.cmp &&
(function(f) {
return function(node) {
return function(a, b) {
(function (f) {
return function (node) {
return function (a, b) {
const aobj = { key: a, value: node[a] };
const bobj = { key: b, value: node[b] };
return f(aobj, bobj);
Expand Down
5 changes: 2 additions & 3 deletions packages/SwingSet/src/kernel/kernel.js
Original file line number Diff line number Diff line change
Expand Up @@ -1066,9 +1066,8 @@ export default function buildKernel(
if (deviceEndowments[name] || unendowed) {
const translators = makeDeviceTranslators(deviceID, name, kernelKeeper);
function deviceSyscallHandler(deviceSyscallObject) {
const ksc = translators.deviceSyscallToKernelSyscall(
deviceSyscallObject,
);
const ksc =
translators.deviceSyscallToKernelSyscall(deviceSyscallObject);
const kres = kernelSyscallHandler.doKernelSyscall(ksc);
const dres = translators.kernelResultToDeviceResult(ksc[0], kres);
assert.equal(dres[0], 'ok');
Expand Down
9 changes: 2 additions & 7 deletions packages/SwingSet/src/kernel/kernelSyscall.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,8 @@ export function doSend(kernelKeeper, target, msg) {
}

export function makeKernelSyscallHandler(tools) {
const {
kernelKeeper,
ephemeral,
notify,
doResolve,
setTerminationTrigger,
} = tools;
const { kernelKeeper, ephemeral, notify, doResolve, setTerminationTrigger } =
tools;

const { kvStore } = kernelKeeper;

Expand Down
18 changes: 5 additions & 13 deletions packages/SwingSet/src/kernel/slogger.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,7 @@ function makeCallbackRegistry(callbacks) {
if (!cbNames.length) {
return;
}
console.warn(
errorUnusedMsg,
cbNames
.map(quote)
.sort()
.join(', '),
);
console.warn(errorUnusedMsg, cbNames.map(quote).sort().join(', '));
},
});
}
Expand All @@ -84,9 +78,8 @@ function makeCallbackRegistry(callbacks) {
* @returns { KernelSlog }
*/
export function makeDummySlogger(slogCallbacks, makeConsole) {
const { registerCallback: reg, doneRegistering } = makeCallbackRegistry(
slogCallbacks,
);
const { registerCallback: reg, doneRegistering } =
makeCallbackRegistry(slogCallbacks);
const dummySlogger = harden({
provideVatSlogger: reg('provideVatSlogger', () =>
harden({
Expand Down Expand Up @@ -249,9 +242,8 @@ export function makeSlogger(slogCallbacks, writeObj) {
// write({ type: 'annotate-vat', vatID, data });
// }

const { registerCallback: reg, doneRegistering } = makeCallbackRegistry(
slogCallbacks,
);
const { registerCallback: reg, doneRegistering } =
makeCallbackRegistry(slogCallbacks);
const slogger = harden({
provideVatSlogger: reg('provideVatSlogger', provideVatSlogger),
vatConsole: reg('vatConsole', (vatID, ...args) =>
Expand Down
14 changes: 6 additions & 8 deletions packages/SwingSet/src/kernel/state/kernelKeeper.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,11 @@ export default function makeKernelKeeper(
return true;
}

const { abortCrank, commitCrank, enhancedCrankBuffer: kvStore } = wrapStorage(
rawKVStore,
createSHA256,
isConsensusKey,
);
const {
abortCrank,
commitCrank,
enhancedCrankBuffer: kvStore,
} = wrapStorage(rawKVStore, createSHA256, isConsensusKey);
insistEnhancedStorageAPI(kvStore);
const { streamStore, snapStore } = hostStorage;

Expand Down Expand Up @@ -770,9 +770,7 @@ export default function makeKernelKeeper(
const p = getKernelPromise(kernelSlot);
const s = new Set(p.subscribers);
s.add(vatID);
const v = Array.from(s)
.sort()
.join(',');
const v = Array.from(s).sort().join(',');
kvStore.set(`${kernelSlot}.subscribers`, v);
}

Expand Down
Loading

0 comments on commit 1daf09d

Please sign in to comment.