Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

pnpm: Use workspace-wide prettier configuration #7115

Merged
merged 3 commits into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = { // E: 'module' is not defined.
module.exports = {
extends: ['turbo', '@solana/eslint-config-solana', '@solana/eslint-config-solana/jest'],
root: true,
};
11 changes: 11 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
docs
lib
test-ledger
node_modules
dist
generated
.mypy_cache
*.yml
*.yaml
*.md
*.json
9 changes: 9 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"semi": true,
"singleQuote": true,
"trailingComma": "es5",
"useTabs": false,
"tabWidth": 4,
"arrowParens": "always",
"printWidth": 80
}
14 changes: 3 additions & 11 deletions account-compression/sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,8 @@
"scripts": {
"build": "rm -rf dist/ && tsc -p tsconfig.json",
"build:program": "cargo build-sbf --manifest-path=../programs/account-compression/Cargo.toml && cargo build-sbf --manifest-path=../programs/noop/Cargo.toml",
"fmt": "prettier --write '{*,**/*}.{ts,tsx,js,jsx,json}'",
"pretty": "prettier --check '{,{src,test}/**/}*.{j,t}s'",
"pretty:fix": "prettier --write '{,{src,test}/**/}*.{j,t}s'",
"lint": "set -ex; npm run pretty; eslint . --ext .js,.ts",
"lint:fix": "npm run pretty:fix && eslint . --fix --ext .js,.ts",
"lint": "set -ex; eslint . --ext .js,.ts",
"lint:fix": "eslint . --fix --ext .js,.ts",
"docs": "rm -rf docs/ && typedoc --out docs",
"deploy:docs": "npm run docs && gh-pages --dest account-compression/sdk --dist docs --dotfiles",
"start-validator": "solana-test-validator --reset --quiet --bpf-program cmtDvXumGCrqC1Age74AVPhSRVXJMd8PJS91L8KbNCK ../target/deploy/spl_account_compression.so --bpf-program noopb9bkMVfRPU8AsbpTUg8AQkHtKwMYZiFUjNRtMmV ../target/deploy/spl_noop.so",
Expand Down Expand Up @@ -68,32 +65,27 @@
"@metaplex-foundation/solita": "0.20.1",
"@coral-xyz/anchor": "^0.29.0",
"@solana/eslint-config-solana": "^3.0.3",
"@solana/prettier-config-solana": "^0.0.5",
"@types/bn.js": "^5.1.0",
"@types/jest": "^29.5.12",
"@types/node": "^22.1.0",
"@types/node-fetch": "^2.6.11",
"@typescript-eslint/eslint-plugin": "^7.17.0",
"@typescript-eslint/parser": "^7.18.0",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-config-turbo": "^2.0.11",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jest": "^28.7.0",
"eslint-plugin-mocha": "^10.5.0",
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-simple-import-sort": "^12.1.1",
"eslint-plugin-sort-keys-fix": "^1.1.2",
"gh-pages": "^6.1.1",
"jest": "^29.0.1",
"jest-config": "^29.0.1",
"prettier": "^3.3.3",
"start-server-and-test": "^2.0.5",
"ts-jest": "^29.2.4",
"ts-jest-resolver": "^2.0.1",
"ts-node": "^10.9.2",
"typedoc": "^0.26.5",
"typescript": "5.5.4"
},
"prettier": "@solana/prettier-config-solana"
}
}
2 changes: 0 additions & 2 deletions account-compression/sdk/src/.prettierignore

This file was deleted.

26 changes: 13 additions & 13 deletions account-compression/sdk/tests/accountCompression.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ describe('Account Compression', () => {

await provider.connection.confirmTransaction(
await provider.connection.requestAirdrop(payer, 1e10),
'confirmed'
'confirmed',
);
});

Expand All @@ -71,7 +71,7 @@ describe('Account Compression', () => {

assert(
Buffer.from(onChainRoot).equals(offChainTree.root),
'Updated on chain root matches root of updated off chain tree'
'Updated on chain root matches root of updated off chain tree',
);
});
it('Verify proof works for that leaf', async () => {
Expand All @@ -90,7 +90,7 @@ describe('Account Compression', () => {

assert(
Buffer.from(onChainRoot).equals(offChainTree.root),
'Updated on chain root matches root of updated off chain tree'
'Updated on chain root matches root of updated off chain tree',
);
});
it('Verify leaf fails when proof fails', async () => {
Expand Down Expand Up @@ -121,7 +121,7 @@ describe('Account Compression', () => {

assert(
Buffer.from(onChainRoot).equals(offChainTree.root),
'Updated on chain root matches root of updated off chain tree'
'Updated on chain root matches root of updated off chain tree',
);
});
it('Replace that leaf', async () => {
Expand All @@ -140,7 +140,7 @@ describe('Account Compression', () => {

assert(
Buffer.from(onChainRoot).equals(offChainTree.root),
'Updated on chain root matches root of updated off chain tree'
'Updated on chain root matches root of updated off chain tree',
);
});

Expand All @@ -159,7 +159,7 @@ describe('Account Compression', () => {

assert(
Buffer.from(onChainRoot).equals(offChainTree.root),
'Updated on chain root matches root of updated off chain tree'
'Updated on chain root matches root of updated off chain tree',
);
});
});
Expand All @@ -172,7 +172,7 @@ describe('Account Compression', () => {

beforeEach(async () => {
await provider.connection.confirmTransaction(
await (connection as Connection).requestAirdrop(authority, 1e10)
await (connection as Connection).requestAirdrop(authority, 1e10),
);
[cmtKeypair, offChainTree] = await createTreeOnChain(provider, authorityKeypair, 1, DEPTH_SIZE_PAIR);
cmt = cmtKeypair.publicKey;
Expand All @@ -196,7 +196,7 @@ describe('Account Compression', () => {

assert(
splCMT.getAuthority().equals(randomSigner),
`Upon transferring authority, authority should be ${randomSigner.toString()}, but was instead updated to ${splCMT.getAuthority()}`
`Upon transferring authority, authority should be ${randomSigner.toString()}, but was instead updated to ${splCMT.getAuthority()}`,
);

// Attempting to replace with new authority now works
Expand Down Expand Up @@ -245,7 +245,7 @@ describe('Account Compression', () => {

assert(
Buffer.from(onChainRoot).equals(offChainTree.root),
'Updated on chain root does not match root of updated off chain tree'
'Updated on chain root does not match root of updated off chain tree',
);
});
it('Empty all of the leaves and close the tree', async () => {
Expand Down Expand Up @@ -283,7 +283,7 @@ describe('Account Compression', () => {
const finalLamports = payerInfo!.lamports;
assert(
finalLamports === payerLamports + treeLamports - 5000,
'Expected payer to have received the lamports from the closed tree account'
'Expected payer to have received the lamports from the closed tree account',
);

treeInfo = await provider.connection.getAccountInfo(cmt, 'confirmed');
Expand Down Expand Up @@ -349,7 +349,7 @@ describe('Account Compression', () => {

assert(
splCMT.getCurrentBufferIndex() === 0,
"CMT updated its active index after attacker's transaction, when it shouldn't have done anything"
"CMT updated its active index after attacker's transaction, when it shouldn't have done anything",
);
});
});
Expand All @@ -361,7 +361,7 @@ describe('Account Compression', () => {
payerKeypair,
2 ** DEPTH,
{ maxBufferSize: 8, maxDepth: DEPTH },
DEPTH // Store full tree on chain
DEPTH, // Store full tree on chain
);
cmt = cmtKeypair.publicKey;

Expand Down Expand Up @@ -391,7 +391,7 @@ describe('Account Compression', () => {
payerKeypair,
0,
{ maxBufferSize: 8, maxDepth: DEPTH },
DEPTH // Store full tree on chain
DEPTH, // Store full tree on chain
);
cmt = cmtKeypair.publicKey;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,22 @@ function assertCMTProperties(
expectedMaxBufferSize: number,
expectedAuthority: PublicKey,
expectedRoot: Buffer,
expectedCanopyDepth?: number
expectedCanopyDepth?: number,
) {
assert(
onChainCMT.getMaxDepth() === expectedMaxDepth,
`Max depth does not match ${onChainCMT.getMaxDepth()}, expected ${expectedMaxDepth}`
`Max depth does not match ${onChainCMT.getMaxDepth()}, expected ${expectedMaxDepth}`,
);
assert(
onChainCMT.getMaxBufferSize() === expectedMaxBufferSize,
`Max buffer size does not match ${onChainCMT.getMaxBufferSize()}, expected ${expectedMaxBufferSize}`
`Max buffer size does not match ${onChainCMT.getMaxBufferSize()}, expected ${expectedMaxBufferSize}`,
);
assert(onChainCMT.getAuthority().equals(expectedAuthority), 'Failed to write auth pubkey');
assert(onChainCMT.getCurrentRoot().equals(expectedRoot), 'On chain root does not match root passed in instruction');
if (expectedCanopyDepth) {
assert(
onChainCMT.getCanopyDepth() === expectedCanopyDepth,
'On chain canopy depth does not match expected canopy depth'
'On chain canopy depth does not match expected canopy depth',
);
}
}
Expand Down Expand Up @@ -57,7 +57,7 @@ describe('ConcurrentMerkleTreeAccount tests', () => {

await provider.connection.confirmTransaction(
await provider.connection.requestAirdrop(payer, 1e10),
'confirmed'
'confirmed',
);
});

Expand All @@ -76,7 +76,7 @@ describe('ConcurrentMerkleTreeAccount tests', () => {
const cmt = await ConcurrentMerkleTreeAccount.fromAccountAddress(
connection,
cmtKeypair.publicKey,
'confirmed'
'confirmed',
);

await assertCMTProperties(cmt, MAX_DEPTH, MAX_SIZE, payer, offChainTree.root);
Expand All @@ -97,7 +97,7 @@ describe('ConcurrentMerkleTreeAccount tests', () => {
const cmt = await ConcurrentMerkleTreeAccount.fromAccountAddress(
connection,
cmtKeypair.publicKey,
'confirmed'
'confirmed',
);

// Verify it was initialized correctly
Expand All @@ -106,7 +106,7 @@ describe('ConcurrentMerkleTreeAccount tests', () => {
depthSizePair.maxDepth,
depthSizePair.maxBufferSize,
payer,
emptyNode(depthSizePair.maxDepth)
emptyNode(depthSizePair.maxDepth),
);
}
});
Expand All @@ -129,12 +129,12 @@ describe('ConcurrentMerkleTreeAccount tests', () => {
provider,
payerKeypair,
{ maxBufferSize, maxDepth },
canopyDepth
canopyDepth,
);
const cmt = await ConcurrentMerkleTreeAccount.fromAccountAddress(
connection,
cmtKeypair.publicKey,
'confirmed'
'confirmed',
);

// Verify it was initialized correctly
Expand Down
39 changes: 18 additions & 21 deletions account-compression/sdk/tests/events/applicationData.test.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,24 @@
import { strict as assert } from "node:assert";
import { strict as assert } from 'node:assert';

import { BN } from "bn.js";
import { BN } from 'bn.js';

import { deserializeApplicationDataEvent } from "../../src";
import { deserializeApplicationDataEvent } from '../../src';

describe("Serde tests", () => {
describe("ApplicationDataEvent tests", () => {
it("Can serialize and deserialize ApplicationDataEvent", () => {
const data = Buffer.from("Hello world");
const applicationDataEvent = Buffer.concat([
Buffer.from([0x1]), // ApplicationData Event tag
Buffer.from([0x0]), // version 0 tag
Buffer.from(new BN.BN(data.length).toArray("le", 4)), // Size of application data (for Vec)
data, // serialized application data (for Vec)
]);
describe('Serde tests', () => {
describe('ApplicationDataEvent tests', () => {
it('Can serialize and deserialize ApplicationDataEvent', () => {
const data = Buffer.from('Hello world');
const applicationDataEvent = Buffer.concat([
Buffer.from([0x1]), // ApplicationData Event tag
Buffer.from([0x0]), // version 0 tag
Buffer.from(new BN.BN(data.length).toArray('le', 4)), // Size of application data (for Vec)
data, // serialized application data (for Vec)
]);

const deserialized =
deserializeApplicationDataEvent(applicationDataEvent);
const decoder = new TextDecoder();
const deserializedData = decoder.decode(
deserialized.fields[0].applicationData
);
assert("Hello world" === deserializedData);
const deserialized = deserializeApplicationDataEvent(applicationDataEvent);
const decoder = new TextDecoder();
const deserializedData = decoder.decode(deserialized.fields[0].applicationData);
assert('Hello world' === deserializedData);
});
});
});
});
Loading