Skip to content

Commit

Permalink
♻️ Code Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
GabrielePicco committed Oct 4, 2024
1 parent 7947a95 commit 21fe460
Show file tree
Hide file tree
Showing 29 changed files with 165 additions and 1,698 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/publish-bolt-crates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:

- uses: actions/setup-node@v4
with:
node-version: 20
node-version: 21

- name: install essentials
run: |
Expand Down Expand Up @@ -82,7 +82,7 @@ jobs:
- name: Use Node ${{ matrix.node }}
uses: actions/setup-node@v4
with:
node-version: 20
node-version: 21

- name: Cache node dependencies
uses: actions/cache@v4
Expand Down Expand Up @@ -115,7 +115,7 @@ jobs:
- name: Use Node ${{ matrix.node }}
uses: actions/setup-node@v4
with:
node-version: 20
node-version: 21

- name: Cache node dependencies
uses: actions/cache@v3
Expand Down
7 changes: 3 additions & 4 deletions .github/workflows/publish-bolt-sdk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:

- uses: actions/setup-node@v4
with:
node-version: 20
node-version: 21

- name: install essentials
run: |
Expand Down Expand Up @@ -82,7 +82,7 @@ jobs:
- name: Use Node ${{ matrix.node }}
uses: actions/setup-node@v4
with:
node-version: 20
node-version: 21

- name: Cache node dependencies
uses: actions/cache@v4
Expand Down Expand Up @@ -115,7 +115,7 @@ jobs:
- name: Use Node ${{ matrix.node }}
uses: actions/setup-node@v4
with:
node-version: 20
node-version: 21

- name: Cache node dependencies
uses: actions/cache@v3
Expand Down Expand Up @@ -180,7 +180,6 @@ jobs:
- name: npm publish
run: |
npm install --global eslint@^8.33.0
npm install
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
npm set //registry.npmjs.org/:_authToken ${{ secrets.NPM_TOKEN }}
Expand Down
14 changes: 6 additions & 8 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/cache@v4
name: cache solana cli
id: cache-solana
Expand All @@ -26,7 +27,7 @@ jobs:

- uses: actions/setup-node@v4
with:
node-version: 20
node-version: 21

- name: install essentials
run: |
Expand All @@ -37,7 +38,7 @@ jobs:
- name: Cache node dependencies
uses: actions/cache@v3
with:
path: "**/node_modules"
path: '**/node_modules'
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}

- name: install node_modules
Expand All @@ -49,7 +50,6 @@ jobs:
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
components: rustfmt

- name: Cache rust
uses: Swatinem/rust-cache@v2
Expand All @@ -69,8 +69,6 @@ jobs:
- uses: actions/checkout@v4
- name: Cache rust
uses: Swatinem/rust-cache@v2
- name: Check Rust version
run: rustc --version
- name: Run fmt
run: cargo fmt -- --check --verbose
- name: Run clippy
Expand All @@ -84,12 +82,12 @@ jobs:
- name: Use Node ${{ matrix.node }}
uses: actions/setup-node@v4
with:
node-version: 20
node-version: 21

- name: Cache node dependencies
uses: actions/cache@v4
with:
path: "**/node_modules"
path: '**/node_modules'
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}

- name: Run lint
Expand All @@ -113,7 +111,7 @@ jobs:
- name: Use Node ${{ matrix.node }}
uses: actions/setup-node@v4
with:
node-version: 20
node-version: 21

- name: Cache node dependencies
uses: actions/cache@v3
Expand Down
15 changes: 0 additions & 15 deletions cli/npm-package/.eslintrc

This file was deleted.

8 changes: 4 additions & 4 deletions cli/npm-package/bolt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function getExePath(): string {
return require.resolve(binaryName);
} catch (e) {
throw new Error(
`Couldn't find application binary inside node_modules for ${os}-${arch()}`
`Couldn't find application binary inside node_modules for ${os}-${arch()}`,
);
}
}
Expand Down Expand Up @@ -60,7 +60,7 @@ function tryPackageBolt(): boolean {
} catch (e) {
console.error(
"Failed to run bolt from package:",
e instanceof Error ? e.message : e
e instanceof Error ? e.message : e,
);
return false;
}
Expand All @@ -80,7 +80,7 @@ function trySystemBolt(): void {

if (!absolutePath) {
console.error(
`Could not find globally installed bolt, please install with cargo.`
`Could not find globally installed bolt, please install with cargo.`,
);
process.exit(1);
}
Expand All @@ -94,7 +94,7 @@ function trySystemBolt(): void {
}
if (binaryVersion !== PACKAGE_VERSION) {
console.error(
`Globally installed bolt version is not correct. Expected "${PACKAGE_VERSION}", found "${binaryVersion}".`
`Globally installed bolt version is not correct. Expected "${PACKAGE_VERSION}", found "${binaryVersion}".`,
);
return;
}
Expand Down
10 changes: 4 additions & 6 deletions cli/npm-package/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,15 @@
},
"scripts": {
"typecheck": "tsc --noEmit",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"lint": "prettier */*.js \"*/**/*{.js,.ts}\" --check ",
"lint:fix": "prettier */*.js \"*/**/*{.js,.ts}\" -w",
"build": "tsc",
"dev": "yarn build && node lib/index.js"
},
"devDependencies": {
"@types/node": "^20.8.8",
"@typescript-eslint/eslint-plugin": "^5.48.0",
"@typescript-eslint/parser": "^5.48.0",
"eslint": "^8.31.0",
"typescript": "^4.9.4"
"typescript": "^4.9.4",
"prettier": "^3.1.1"
},
"optionalDependencies": {
"@magicblock-labs/bolt-cli-darwin-x64": "0.1.10",
Expand Down
11 changes: 2 additions & 9 deletions clients/bolt-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,6 @@
},
"devDependencies": {
"@metaplex-foundation/solita": "^0.20.1",
"@typescript-eslint/eslint-plugin": "^6.14.0",
"@typescript-eslint/parser": "^6.14.0",
"eslint": "^8.55.0",
"eslint-config-prettier": "^9.1.0",
"eslint-config-standard-with-typescript": "^42.0.0",
"eslint-plugin-import": "^2.29.0",
"eslint-plugin-react": "^7.33.2",
"prettier": "^3.1.1",
"rimraf": "^5.0.5",
"typedoc": "^0.25.4",
Expand All @@ -41,8 +34,8 @@
"build:docs": "typedoc && typedoc --plugin typedoc-plugin-markdown --out docs-mk",
"dev": "tsc --watch",
"start": "tsc",
"lint": "eslint -c ../../.eslintrc.yml --ext .ts,.tsx src",
"lint:fix": "eslint -c ../../.eslintrc.yml --ext .ts,.tsx src --fix"
"lint": "prettier */*.js \"*/**/*{.js,.ts}\" --check",
"lint:fix": "prettier */*.js \"*/**/*{.js,.ts}\" -w"
},
"files": [
"lib"
Expand Down
6 changes: 3 additions & 3 deletions clients/bolt-sdk/src/delegation/allow_undelegation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const allowUndelegationStruct = new beet.BeetArgsStruct<{
instructionDiscriminator: number[] /* size: 8 */;
}>(
[["instructionDiscriminator", beet.uniformFixedSizeArray(beet.u8, 8)]],
"allowUndelegationInstructionArgs"
"allowUndelegationInstructionArgs",
);

export interface AllowUndelegationInstructionAccounts {
Expand All @@ -27,15 +27,15 @@ export const allowUndelegateInstructionDiscriminator = [
*/

export function createAllowUndelegationInstruction(
accounts: AllowUndelegationInstructionAccounts
accounts: AllowUndelegationInstructionAccounts,
) {
const [data] = allowUndelegationStruct.serialize({
instructionDiscriminator: allowUndelegateInstructionDiscriminator,
});

const { delegationPda, delegationMetadata, bufferPda } = DelegateAccounts(
accounts.delegatedAccount,
accounts.ownerProgram
accounts.ownerProgram,
);

const keys: web3.AccountMeta[] = [
Expand Down
6 changes: 3 additions & 3 deletions clients/bolt-sdk/src/delegation/delegate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const delegateStruct = new beet.FixableBeetArgsStruct<
["validUntil", beet.i64],
["commitFrequencyMs", beet.u32],
],
"DelegateInstructionArgs"
"DelegateInstructionArgs",
);

/**
Expand Down Expand Up @@ -58,7 +58,7 @@ export function createDelegateInstruction(
accounts: DelegateInstructionAccounts,
validUntil: beet.bignum = 0,
commitFrequencyMs: number = 30000,
programId = accounts.ownerProgram
programId = accounts.ownerProgram,
) {
const [data] = delegateStruct.serialize({
instructionDiscriminator: delegateInstructionDiscriminator,
Expand All @@ -68,7 +68,7 @@ export function createDelegateInstruction(

const { delegationPda, delegationMetadata, bufferPda } = DelegateAccounts(
accounts.account,
accounts.ownerProgram
accounts.ownerProgram,
);

const keys: web3.AccountMeta[] = [
Expand Down
4 changes: 2 additions & 2 deletions clients/bolt-sdk/src/delegation/undelegate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const undelegateStruct = new beet.BeetArgsStruct<{
instructionDiscriminator: number[] /* size: 8 */;
}>(
[["instructionDiscriminator", beet.uniformFixedSizeArray(beet.u8, 8)]],
"undelegateInstructionArgs"
"undelegateInstructionArgs",
);

export interface UndelegateInstructionAccounts {
Expand All @@ -26,7 +26,7 @@ export const undelegateInstructionDiscriminator = [
* Creates an Undelegate instruction.
*/
export function createUndelegateInstruction(
accounts: UndelegateInstructionAccounts
accounts: UndelegateInstructionAccounts,
) {
const [data] = undelegateStruct.serialize({
instructionDiscriminator: undelegateInstructionDiscriminator,
Expand Down
16 changes: 8 additions & 8 deletions clients/bolt-sdk/src/generated/accounts/Entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class Entity implements EntityArgs {
*/
static fromAccountInfo(
accountInfo: web3.AccountInfo<Buffer>,
offset = 0
offset = 0,
): [Entity, number] {
return Entity.deserialize(accountInfo.data, offset);
}
Expand All @@ -56,11 +56,11 @@ export class Entity implements EntityArgs {
static async fromAccountAddress(
connection: web3.Connection,
address: web3.PublicKey,
commitmentOrConfig?: web3.Commitment | web3.GetAccountInfoConfig
commitmentOrConfig?: web3.Commitment | web3.GetAccountInfoConfig,
): Promise<Entity> {
const accountInfo = await connection.getAccountInfo(
address,
commitmentOrConfig
commitmentOrConfig,
);
if (accountInfo == null) {
throw new Error(`Unable to find Entity account at ${address}`);
Expand All @@ -76,8 +76,8 @@ export class Entity implements EntityArgs {
*/
static gpaBuilder(
programId: web3.PublicKey = new web3.PublicKey(
"WorLD15A7CrDwLcLy4fRqtaTb9fbd8o8iqiEMUDse2n"
)
"WorLD15A7CrDwLcLy4fRqtaTb9fbd8o8iqiEMUDse2n",
),
) {
return beetSolana.GpaBuilder.fromStruct(programId, entityBeet);
}
Expand Down Expand Up @@ -117,11 +117,11 @@ export class Entity implements EntityArgs {
*/
static async getMinimumBalanceForRentExemption(
connection: web3.Connection,
commitment?: web3.Commitment
commitment?: web3.Commitment,
): Promise<number> {
return connection.getMinimumBalanceForRentExemption(
Entity.byteSize,
commitment
commitment,
);
}

Expand Down Expand Up @@ -169,5 +169,5 @@ export const entityBeet = new beet.BeetStruct<
["id", beet.u64],
],
Entity.fromArgs,
"Entity"
"Entity",
);
Loading

0 comments on commit 21fe460

Please sign in to comment.