From 7947a955949e8e9b2bf9560c3140c57a89998046 Mon Sep 17 00:00:00 2001 From: Gabriele Picco Date: Fri, 4 Oct 2024 17:52:15 +0700 Subject: [PATCH] :recycle: Code Refactor --- .eslintignore | 3 - .eslintrc.yml | 24 -- .prettierignore | 14 +- .prettierrc | 7 - cli/npm-package/bolt.ts | 42 +- clients/bolt-sdk/.solitarc.js | 16 +- .../src/delegation/allow_undelegation.ts | 14 +- clients/bolt-sdk/src/delegation/delegate.ts | 24 +- clients/bolt-sdk/src/delegation/undelegate.ts | 12 +- .../bolt-sdk/src/generated/accounts/Entity.ts | 28 +- .../src/generated/accounts/Registry.ts | 28 +- .../bolt-sdk/src/generated/accounts/World.ts | 34 +- .../bolt-sdk/src/generated/accounts/index.ts | 12 +- .../bolt-sdk/src/generated/errors/index.ts | 10 +- clients/bolt-sdk/src/generated/index.ts | 14 +- .../src/generated/instructions/addEntity.ts | 12 +- .../src/generated/instructions/apply.ts | 12 +- .../src/generated/instructions/apply2.ts | 12 +- .../src/generated/instructions/apply3.ts | 12 +- .../src/generated/instructions/apply4.ts | 12 +- .../src/generated/instructions/apply5.ts | 12 +- .../src/generated/instructions/index.ts | 18 +- .../instructions/initializeComponent.ts | 10 +- .../instructions/initializeNewWorld.ts | 10 +- .../instructions/initializeRegistry.ts | 10 +- clients/bolt-sdk/src/generated/types/world.ts | 388 +++++++++--------- clients/bolt-sdk/src/index.ts | 46 +-- clients/bolt-sdk/src/world/transactions.ts | 40 +- migrations/deploy.js | 4 +- migrations/deploy.ts | 2 +- tests/bolt.ts | 220 +++++----- tsconfig.json | 1 + 32 files changed, 535 insertions(+), 568 deletions(-) delete mode 100644 .eslintignore delete mode 100644 .eslintrc.yml delete mode 100644 .prettierrc diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index 6b1600b..0000000 --- a/.eslintignore +++ /dev/null @@ -1,3 +0,0 @@ -clients/bolt-sdk/idl/world.ts -.anchor -target \ No newline at end of file diff --git a/.eslintrc.yml b/.eslintrc.yml deleted file mode 100644 index bc373f0..0000000 --- a/.eslintrc.yml +++ /dev/null @@ -1,24 +0,0 @@ -env: - browser: true - es2021: true -extends: - - standard-with-typescript - - plugin:prettier/recommended -plugins: - - prettier -ignorePatterns: - - "**/idl/world.ts" -parser: "@typescript-eslint/parser" -parserOptions: - ecmaVersion: latest - sourceType: module - project: [./tsconfig.json] -rules: - "@typescript-eslint/strict-boolean-expressions": - - error - - allowNullableObject: true - "@typescript-eslint/return-await": - - error - - in-try-catch - "@typescript-eslint/explicit-function-return-type": "off" - "@typescript-eslint/restrict-template-expressions": "off" diff --git a/.prettierignore b/.prettierignore index 58ead4a..82f6a35 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,10 +1,10 @@ -# Ignore all files in the generated types directory -clients/bolt-sdk/src/generated/types/world.ts - -# You can add more patterns here +.anchor +.bolt +.DS_Store +target node_modules dist - -clients/bolt-sdk/idl/world.ts -.anchor +build +test-ledger target +clients/bolt-sdk/lib \ No newline at end of file diff --git a/.prettierrc b/.prettierrc deleted file mode 100644 index c9ae50d..0000000 --- a/.prettierrc +++ /dev/null @@ -1,7 +0,0 @@ -{ - "semi": true, - "singleQuote": true, - "trailingComma": "all", - "printWidth": 80, - "tabWidth": 2 -} diff --git a/cli/npm-package/bolt.ts b/cli/npm-package/bolt.ts index 001fb68..66cfb2a 100755 --- a/cli/npm-package/bolt.ts +++ b/cli/npm-package/bolt.ts @@ -1,14 +1,14 @@ #!/usr/bin/env node -import fs from 'fs'; -import { spawn, spawnSync } from 'child_process'; -import path from 'path'; -import { arch, platform } from 'os'; -import { version } from './package.json'; +import fs from "fs"; +import { spawn, spawnSync } from "child_process"; +import path from "path"; +import { arch, platform } from "os"; +import { version } from "./package.json"; const PACKAGE_VERSION = `bolt-cli ${version}`; function getBinaryVersion(location: string): [string | null, string | null] { - const result = spawnSync(location, ['--version']); + const result = spawnSync(location, ["--version"]); const error: string | null = (result.error && result.error.toString()) || (result.stderr.length > 0 && result.stderr.toString().trim()) || @@ -18,26 +18,26 @@ function getBinaryVersion(location: string): [string | null, string | null] { function getExePath(): string { let os: string = platform(); - let extension = ''; - if (['win32', 'cygwin'].includes(os)) { - os = 'windows'; - extension = '.exe'; + let extension = ""; + if (["win32", "cygwin"].includes(os)) { + os = "windows"; + extension = ".exe"; } const binaryName = `@magicblock-labs/bolt-cli-${os}-${arch()}/bin/bolt${extension}`; try { 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()}` ); } } function runBolt(location: string): void { const args = process.argv.slice(2); - const bolt = spawn(location, args, { stdio: 'inherit' }); - bolt.on('exit', (code: number | null, signal: NodeJS.Signals | null) => { - process.on('exit', () => { + const bolt = spawn(location, args, { stdio: "inherit" }); + bolt.on("exit", (code: number | null, signal: NodeJS.Signals | null) => { + process.on("exit", () => { if (signal) { process.kill(process.pid, signal); } else if (code !== null) { @@ -46,9 +46,9 @@ function runBolt(location: string): void { }); }); - process.on('SIGINT', () => { - bolt.kill('SIGINT'); - bolt.kill('SIGTERM'); + process.on("SIGINT", () => { + bolt.kill("SIGINT"); + bolt.kill("SIGTERM"); }); } @@ -59,8 +59,8 @@ function tryPackageBolt(): boolean { return true; } catch (e) { console.error( - 'Failed to run bolt from package:', - e instanceof Error ? e.message : e, + "Failed to run bolt from package:", + e instanceof Error ? e.message : e ); return false; } @@ -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); } @@ -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; } diff --git a/clients/bolt-sdk/.solitarc.js b/clients/bolt-sdk/.solitarc.js index dc3af35..1cdd790 100644 --- a/clients/bolt-sdk/.solitarc.js +++ b/clients/bolt-sdk/.solitarc.js @@ -1,13 +1,13 @@ -const path = require('path'); -const programDir = path.join(__dirname, '../../', 'programs', 'world'); -const idlDir = path.join(__dirname, 'idl'); -const sdkDir = path.join(__dirname, 'src', 'generated'); -const binaryInstallDir = path.join(__dirname, '.crates'); +const path = require("path"); +const programDir = path.join(__dirname, "../../", "programs", "world"); +const idlDir = path.join(__dirname, "idl"); +const sdkDir = path.join(__dirname, "src", "generated"); +const binaryInstallDir = path.join(__dirname, ".crates"); module.exports = { - idlGenerator: 'anchor', - programName: 'world', - programId: 'WorLD15A7CrDwLcLy4fRqtaTb9fbd8o8iqiEMUDse2n', + idlGenerator: "anchor", + programName: "world", + programId: "WorLD15A7CrDwLcLy4fRqtaTb9fbd8o8iqiEMUDse2n", removeExistingIdl: false, idlDir, sdkDir, diff --git a/clients/bolt-sdk/src/delegation/allow_undelegation.ts b/clients/bolt-sdk/src/delegation/allow_undelegation.ts index a44ba2f..5b3354c 100644 --- a/clients/bolt-sdk/src/delegation/allow_undelegation.ts +++ b/clients/bolt-sdk/src/delegation/allow_undelegation.ts @@ -1,15 +1,15 @@ -import * as beet from '@metaplex-foundation/beet'; -import * as web3 from '@solana/web3.js'; +import * as beet from "@metaplex-foundation/beet"; +import * as web3 from "@solana/web3.js"; import { DelegateAccounts, DELEGATION_PROGRAM_ID, -} from '@magicblock-labs/ephemeral-rollups-sdk'; +} from "@magicblock-labs/ephemeral-rollups-sdk"; export const allowUndelegationStruct = new beet.BeetArgsStruct<{ instructionDiscriminator: number[] /* size: 8 */; }>( - [['instructionDiscriminator', beet.uniformFixedSizeArray(beet.u8, 8)]], - 'allowUndelegationInstructionArgs', + [["instructionDiscriminator", beet.uniformFixedSizeArray(beet.u8, 8)]], + "allowUndelegationInstructionArgs" ); export interface AllowUndelegationInstructionAccounts { @@ -27,7 +27,7 @@ export const allowUndelegateInstructionDiscriminator = [ */ export function createAllowUndelegationInstruction( - accounts: AllowUndelegationInstructionAccounts, + accounts: AllowUndelegationInstructionAccounts ) { const [data] = allowUndelegationStruct.serialize({ instructionDiscriminator: allowUndelegateInstructionDiscriminator, @@ -35,7 +35,7 @@ export function createAllowUndelegationInstruction( const { delegationPda, delegationMetadata, bufferPda } = DelegateAccounts( accounts.delegatedAccount, - accounts.ownerProgram, + accounts.ownerProgram ); const keys: web3.AccountMeta[] = [ diff --git a/clients/bolt-sdk/src/delegation/delegate.ts b/clients/bolt-sdk/src/delegation/delegate.ts index ab9be08..a81fe71 100644 --- a/clients/bolt-sdk/src/delegation/delegate.ts +++ b/clients/bolt-sdk/src/delegation/delegate.ts @@ -1,15 +1,15 @@ -import * as beet from '@metaplex-foundation/beet'; -import * as web3 from '@solana/web3.js'; +import * as beet from "@metaplex-foundation/beet"; +import * as web3 from "@solana/web3.js"; import { DelegateAccounts, DELEGATION_PROGRAM_ID, -} from '@magicblock-labs/ephemeral-rollups-sdk'; -import { FindComponentPda } from '../index'; +} from "@magicblock-labs/ephemeral-rollups-sdk"; +import { FindComponentPda } from "../index"; import { type PublicKey, Transaction, type TransactionInstruction, -} from '@solana/web3.js'; +} from "@solana/web3.js"; export interface DelegateInstructionArgs { validUntil: beet.bignum; @@ -22,11 +22,11 @@ export const delegateStruct = new beet.FixableBeetArgsStruct< } >( [ - ['instructionDiscriminator', beet.uniformFixedSizeArray(beet.u8, 8)], - ['validUntil', beet.i64], - ['commitFrequencyMs', beet.u32], + ["instructionDiscriminator", beet.uniformFixedSizeArray(beet.u8, 8)], + ["validUntil", beet.i64], + ["commitFrequencyMs", beet.u32], ], - 'DelegateInstructionArgs', + "DelegateInstructionArgs" ); /** @@ -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, @@ -68,7 +68,7 @@ export function createDelegateInstruction( const { delegationPda, delegationMetadata, bufferPda } = DelegateAccounts( accounts.account, - accounts.ownerProgram, + accounts.ownerProgram ); const keys: web3.AccountMeta[] = [ @@ -144,7 +144,7 @@ export async function DelegateComponent({ payer, entity, componentId, - seed = '', + seed = "", buffer, delegationRecord, delegationMetadata, diff --git a/clients/bolt-sdk/src/delegation/undelegate.ts b/clients/bolt-sdk/src/delegation/undelegate.ts index ea265b1..5954d72 100644 --- a/clients/bolt-sdk/src/delegation/undelegate.ts +++ b/clients/bolt-sdk/src/delegation/undelegate.ts @@ -1,15 +1,15 @@ -import * as beet from '@metaplex-foundation/beet'; -import * as web3 from '@solana/web3.js'; +import * as beet from "@metaplex-foundation/beet"; +import * as web3 from "@solana/web3.js"; import { MAGIC_CONTEXT_ID, MAGIC_PROGRAM_ID, -} from '@magicblock-labs/ephemeral-rollups-sdk'; +} from "@magicblock-labs/ephemeral-rollups-sdk"; export const undelegateStruct = new beet.BeetArgsStruct<{ instructionDiscriminator: number[] /* size: 8 */; }>( - [['instructionDiscriminator', beet.uniformFixedSizeArray(beet.u8, 8)]], - 'undelegateInstructionArgs', + [["instructionDiscriminator", beet.uniformFixedSizeArray(beet.u8, 8)]], + "undelegateInstructionArgs" ); export interface UndelegateInstructionAccounts { @@ -26,7 +26,7 @@ export const undelegateInstructionDiscriminator = [ * Creates an Undelegate instruction. */ export function createUndelegateInstruction( - accounts: UndelegateInstructionAccounts, + accounts: UndelegateInstructionAccounts ) { const [data] = undelegateStruct.serialize({ instructionDiscriminator: undelegateInstructionDiscriminator, diff --git a/clients/bolt-sdk/src/generated/accounts/Entity.ts b/clients/bolt-sdk/src/generated/accounts/Entity.ts index 5f70291..1e54b2d 100644 --- a/clients/bolt-sdk/src/generated/accounts/Entity.ts +++ b/clients/bolt-sdk/src/generated/accounts/Entity.ts @@ -5,9 +5,9 @@ * See: https://github.com/metaplex-foundation/solita */ -import * as beet from '@metaplex-foundation/beet'; -import * as web3 from '@solana/web3.js'; -import * as beetSolana from '@metaplex-foundation/beet-solana'; +import * as beet from "@metaplex-foundation/beet"; +import * as web3 from "@solana/web3.js"; +import * as beetSolana from "@metaplex-foundation/beet-solana"; /** * Arguments used to create {@link Entity} @@ -42,7 +42,7 @@ export class Entity implements EntityArgs { */ static fromAccountInfo( accountInfo: web3.AccountInfo, - offset = 0, + offset = 0 ): [Entity, number] { return Entity.deserialize(accountInfo.data, offset); } @@ -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 { const accountInfo = await connection.getAccountInfo( address, - commitmentOrConfig, + commitmentOrConfig ); if (accountInfo == null) { throw new Error(`Unable to find Entity account at ${address}`); @@ -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); } @@ -117,11 +117,11 @@ export class Entity implements EntityArgs { */ static async getMinimumBalanceForRentExemption( connection: web3.Connection, - commitment?: web3.Commitment, + commitment?: web3.Commitment ): Promise { return connection.getMinimumBalanceForRentExemption( Entity.byteSize, - commitment, + commitment ); } @@ -141,7 +141,7 @@ export class Entity implements EntityArgs { return { id: (() => { const x = this.id as { toNumber: () => number }; - if (typeof x.toNumber === 'function') { + if (typeof x.toNumber === "function") { try { return x.toNumber(); } catch (_) { @@ -165,9 +165,9 @@ export const entityBeet = new beet.BeetStruct< } >( [ - ['accountDiscriminator', beet.uniformFixedSizeArray(beet.u8, 8)], - ['id', beet.u64], + ["accountDiscriminator", beet.uniformFixedSizeArray(beet.u8, 8)], + ["id", beet.u64], ], Entity.fromArgs, - 'Entity', + "Entity" ); diff --git a/clients/bolt-sdk/src/generated/accounts/Registry.ts b/clients/bolt-sdk/src/generated/accounts/Registry.ts index c020516..6ae12c4 100644 --- a/clients/bolt-sdk/src/generated/accounts/Registry.ts +++ b/clients/bolt-sdk/src/generated/accounts/Registry.ts @@ -5,9 +5,9 @@ * See: https://github.com/metaplex-foundation/solita */ -import * as beet from '@metaplex-foundation/beet'; -import * as web3 from '@solana/web3.js'; -import * as beetSolana from '@metaplex-foundation/beet-solana'; +import * as beet from "@metaplex-foundation/beet"; +import * as web3 from "@solana/web3.js"; +import * as beetSolana from "@metaplex-foundation/beet-solana"; /** * Arguments used to create {@link Registry} @@ -42,7 +42,7 @@ export class Registry implements RegistryArgs { */ static fromAccountInfo( accountInfo: web3.AccountInfo, - offset = 0, + offset = 0 ): [Registry, number] { return Registry.deserialize(accountInfo.data, offset); } @@ -56,11 +56,11 @@ export class Registry implements RegistryArgs { static async fromAccountAddress( connection: web3.Connection, address: web3.PublicKey, - commitmentOrConfig?: web3.Commitment | web3.GetAccountInfoConfig, + commitmentOrConfig?: web3.Commitment | web3.GetAccountInfoConfig ): Promise { const accountInfo = await connection.getAccountInfo( address, - commitmentOrConfig, + commitmentOrConfig ); if (accountInfo == null) { throw new Error(`Unable to find Registry account at ${address}`); @@ -76,8 +76,8 @@ export class Registry implements RegistryArgs { */ static gpaBuilder( programId: web3.PublicKey = new web3.PublicKey( - 'WorLD15A7CrDwLcLy4fRqtaTb9fbd8o8iqiEMUDse2n', - ), + "WorLD15A7CrDwLcLy4fRqtaTb9fbd8o8iqiEMUDse2n" + ) ) { return beetSolana.GpaBuilder.fromStruct(programId, registryBeet); } @@ -117,11 +117,11 @@ export class Registry implements RegistryArgs { */ static async getMinimumBalanceForRentExemption( connection: web3.Connection, - commitment?: web3.Commitment, + commitment?: web3.Commitment ): Promise { return connection.getMinimumBalanceForRentExemption( Registry.byteSize, - commitment, + commitment ); } @@ -141,7 +141,7 @@ export class Registry implements RegistryArgs { return { worlds: (() => { const x = this.worlds as { toNumber: () => number }; - if (typeof x.toNumber === 'function') { + if (typeof x.toNumber === "function") { try { return x.toNumber(); } catch (_) { @@ -165,9 +165,9 @@ export const registryBeet = new beet.BeetStruct< } >( [ - ['accountDiscriminator', beet.uniformFixedSizeArray(beet.u8, 8)], - ['worlds', beet.u64], + ["accountDiscriminator", beet.uniformFixedSizeArray(beet.u8, 8)], + ["worlds", beet.u64], ], Registry.fromArgs, - 'Registry', + "Registry" ); diff --git a/clients/bolt-sdk/src/generated/accounts/World.ts b/clients/bolt-sdk/src/generated/accounts/World.ts index 38e9f24..9e76e97 100644 --- a/clients/bolt-sdk/src/generated/accounts/World.ts +++ b/clients/bolt-sdk/src/generated/accounts/World.ts @@ -5,9 +5,9 @@ * See: https://github.com/metaplex-foundation/solita */ -import * as beet from '@metaplex-foundation/beet'; -import * as web3 from '@solana/web3.js'; -import * as beetSolana from '@metaplex-foundation/beet-solana'; +import * as beet from "@metaplex-foundation/beet"; +import * as web3 from "@solana/web3.js"; +import * as beetSolana from "@metaplex-foundation/beet-solana"; /** * Arguments used to create {@link World} @@ -30,7 +30,7 @@ export const worldDiscriminator = [145, 45, 170, 174, 122, 32, 155, 124]; export class World implements WorldArgs { private constructor( readonly id: beet.bignum, - readonly entities: beet.bignum, + readonly entities: beet.bignum ) {} /** @@ -46,7 +46,7 @@ export class World implements WorldArgs { */ static fromAccountInfo( accountInfo: web3.AccountInfo, - offset = 0, + offset = 0 ): [World, number] { return World.deserialize(accountInfo.data, offset); } @@ -60,11 +60,11 @@ export class World implements WorldArgs { static async fromAccountAddress( connection: web3.Connection, address: web3.PublicKey, - commitmentOrConfig?: web3.Commitment | web3.GetAccountInfoConfig, + commitmentOrConfig?: web3.Commitment | web3.GetAccountInfoConfig ): Promise { const accountInfo = await connection.getAccountInfo( address, - commitmentOrConfig, + commitmentOrConfig ); if (accountInfo == null) { throw new Error(`Unable to find World account at ${address}`); @@ -80,8 +80,8 @@ export class World implements WorldArgs { */ static gpaBuilder( programId: web3.PublicKey = new web3.PublicKey( - 'WorLD15A7CrDwLcLy4fRqtaTb9fbd8o8iqiEMUDse2n', - ), + "WorLD15A7CrDwLcLy4fRqtaTb9fbd8o8iqiEMUDse2n" + ) ) { return beetSolana.GpaBuilder.fromStruct(programId, worldBeet); } @@ -121,11 +121,11 @@ export class World implements WorldArgs { */ static async getMinimumBalanceForRentExemption( connection: web3.Connection, - commitment?: web3.Commitment, + commitment?: web3.Commitment ): Promise { return connection.getMinimumBalanceForRentExemption( World.byteSize, - commitment, + commitment ); } @@ -145,7 +145,7 @@ export class World implements WorldArgs { return { id: (() => { const x = this.id as { toNumber: () => number }; - if (typeof x.toNumber === 'function') { + if (typeof x.toNumber === "function") { try { return x.toNumber(); } catch (_) { @@ -156,7 +156,7 @@ export class World implements WorldArgs { })(), entities: (() => { const x = this.entities as { toNumber: () => number }; - if (typeof x.toNumber === 'function') { + if (typeof x.toNumber === "function") { try { return x.toNumber(); } catch (_) { @@ -180,10 +180,10 @@ export const worldBeet = new beet.BeetStruct< } >( [ - ['accountDiscriminator', beet.uniformFixedSizeArray(beet.u8, 8)], - ['id', beet.u64], - ['entities', beet.u64], + ["accountDiscriminator", beet.uniformFixedSizeArray(beet.u8, 8)], + ["id", beet.u64], + ["entities", beet.u64], ], World.fromArgs, - 'World', + "World" ); diff --git a/clients/bolt-sdk/src/generated/accounts/index.ts b/clients/bolt-sdk/src/generated/accounts/index.ts index 6dd69e1..a616381 100644 --- a/clients/bolt-sdk/src/generated/accounts/index.ts +++ b/clients/bolt-sdk/src/generated/accounts/index.ts @@ -5,12 +5,12 @@ * See: https://github.com/metaplex-foundation/solita */ -import { Entity } from './Entity'; -import { Registry } from './Registry'; -import { World } from './World'; +import { Entity } from "./Entity"; +import { Registry } from "./Registry"; +import { World } from "./World"; -export * from './Entity'; -export * from './Registry'; -export * from './World'; +export * from "./Entity"; +export * from "./Registry"; +export * from "./World"; export const accountProviders = { Entity, Registry, World }; diff --git a/clients/bolt-sdk/src/generated/errors/index.ts b/clients/bolt-sdk/src/generated/errors/index.ts index cbfef80..4ff4e04 100644 --- a/clients/bolt-sdk/src/generated/errors/index.ts +++ b/clients/bolt-sdk/src/generated/errors/index.ts @@ -19,10 +19,10 @@ const createErrorFromNameLookup = new Map ErrorWithCode>(); */ export class InvalidAuthorityError extends Error { readonly code: number = 0x1770; - readonly name: string = 'InvalidAuthority'; + readonly name: string = "InvalidAuthority"; constructor() { - super('Invalid authority for instruction'); - if (typeof Error.captureStackTrace === 'function') { + super("Invalid authority for instruction"); + if (typeof Error.captureStackTrace === "function") { Error.captureStackTrace(this, InvalidAuthorityError); } } @@ -30,8 +30,8 @@ export class InvalidAuthorityError extends Error { createErrorFromCodeLookup.set(0x1770, () => new InvalidAuthorityError()); createErrorFromNameLookup.set( - 'InvalidAuthority', - () => new InvalidAuthorityError(), + "InvalidAuthority", + () => new InvalidAuthorityError() ); /** diff --git a/clients/bolt-sdk/src/generated/index.ts b/clients/bolt-sdk/src/generated/index.ts index 41e2b55..50e75dd 100644 --- a/clients/bolt-sdk/src/generated/index.ts +++ b/clients/bolt-sdk/src/generated/index.ts @@ -5,12 +5,12 @@ * See: https://github.com/metaplex-foundation/solita */ -import { PublicKey } from '@solana/web3.js'; -import { type World as WorldProgram } from './types/world'; -import idl from './idl/world.json'; -export * from './accounts'; -export * from './errors'; -export * from './instructions'; +import { PublicKey } from "@solana/web3.js"; +import { type World as WorldProgram } from "./types/world"; +import idl from "./idl/world.json"; +export * from "./accounts"; +export * from "./errors"; +export * from "./instructions"; /** * Program address @@ -18,7 +18,7 @@ export * from './instructions'; * @category constants * @category generated */ -export const PROGRAM_ADDRESS = 'WorLD15A7CrDwLcLy4fRqtaTb9fbd8o8iqiEMUDse2n'; +export const PROGRAM_ADDRESS = "WorLD15A7CrDwLcLy4fRqtaTb9fbd8o8iqiEMUDse2n"; /** * Program public key diff --git a/clients/bolt-sdk/src/generated/instructions/addEntity.ts b/clients/bolt-sdk/src/generated/instructions/addEntity.ts index 7cb6c06..e785b4a 100644 --- a/clients/bolt-sdk/src/generated/instructions/addEntity.ts +++ b/clients/bolt-sdk/src/generated/instructions/addEntity.ts @@ -5,8 +5,8 @@ * See: https://github.com/metaplex-foundation/solita */ -import * as beet from '@metaplex-foundation/beet'; -import * as web3 from '@solana/web3.js'; +import * as beet from "@metaplex-foundation/beet"; +import * as web3 from "@solana/web3.js"; /** * @category Instructions @@ -27,10 +27,10 @@ export const addEntityStruct = new beet.FixableBeetArgsStruct< } >( [ - ['instructionDiscriminator', beet.uniformFixedSizeArray(beet.u8, 8)], - ['extraSeed', beet.coption(beet.utf8String)], + ["instructionDiscriminator", beet.uniformFixedSizeArray(beet.u8, 8)], + ["extraSeed", beet.coption(beet.utf8String)], ], - 'AddEntityInstructionArgs', + "AddEntityInstructionArgs" ); /** * Accounts required by the _addEntity_ instruction @@ -67,7 +67,7 @@ export const addEntityInstructionDiscriminator = [ export function createAddEntityInstruction( accounts: AddEntityInstructionAccounts, args: AddEntityInstructionArgs, - programId = new web3.PublicKey('WorLD15A7CrDwLcLy4fRqtaTb9fbd8o8iqiEMUDse2n'), + programId = new web3.PublicKey("WorLD15A7CrDwLcLy4fRqtaTb9fbd8o8iqiEMUDse2n") ) { const [data] = addEntityStruct.serialize({ instructionDiscriminator: addEntityInstructionDiscriminator, diff --git a/clients/bolt-sdk/src/generated/instructions/apply.ts b/clients/bolt-sdk/src/generated/instructions/apply.ts index fe1901d..1cfa7d8 100644 --- a/clients/bolt-sdk/src/generated/instructions/apply.ts +++ b/clients/bolt-sdk/src/generated/instructions/apply.ts @@ -5,8 +5,8 @@ * See: https://github.com/metaplex-foundation/solita */ -import * as beet from '@metaplex-foundation/beet'; -import * as web3 from '@solana/web3.js'; +import * as beet from "@metaplex-foundation/beet"; +import * as web3 from "@solana/web3.js"; /** * @category Instructions @@ -27,10 +27,10 @@ export const applyStruct = new beet.FixableBeetArgsStruct< } >( [ - ['instructionDiscriminator', beet.uniformFixedSizeArray(beet.u8, 8)], - ['args', beet.bytes], + ["instructionDiscriminator", beet.uniformFixedSizeArray(beet.u8, 8)], + ["args", beet.bytes], ], - 'ApplyInstructionArgs', + "ApplyInstructionArgs" ); /** * Accounts required by the _apply_ instruction @@ -70,7 +70,7 @@ export const applyInstructionDiscriminator = [ export function createApplyInstruction( accounts: ApplyInstructionAccounts, args: ApplyInstructionArgs, - programId = new web3.PublicKey('WorLD15A7CrDwLcLy4fRqtaTb9fbd8o8iqiEMUDse2n'), + programId = new web3.PublicKey("WorLD15A7CrDwLcLy4fRqtaTb9fbd8o8iqiEMUDse2n") ) { const [data] = applyStruct.serialize({ instructionDiscriminator: applyInstructionDiscriminator, diff --git a/clients/bolt-sdk/src/generated/instructions/apply2.ts b/clients/bolt-sdk/src/generated/instructions/apply2.ts index 13c4061..dc999dc 100644 --- a/clients/bolt-sdk/src/generated/instructions/apply2.ts +++ b/clients/bolt-sdk/src/generated/instructions/apply2.ts @@ -5,8 +5,8 @@ * See: https://github.com/metaplex-foundation/solita */ -import * as beet from '@metaplex-foundation/beet'; -import * as web3 from '@solana/web3.js'; +import * as beet from "@metaplex-foundation/beet"; +import * as web3 from "@solana/web3.js"; /** * @category Instructions @@ -27,10 +27,10 @@ export const apply2Struct = new beet.FixableBeetArgsStruct< } >( [ - ['instructionDiscriminator', beet.uniformFixedSizeArray(beet.u8, 8)], - ['args', beet.bytes], + ["instructionDiscriminator", beet.uniformFixedSizeArray(beet.u8, 8)], + ["args", beet.bytes], ], - 'Apply2InstructionArgs', + "Apply2InstructionArgs" ); /** * Accounts required by the _apply2_ instruction @@ -74,7 +74,7 @@ export const apply2InstructionDiscriminator = [ export function createApply2Instruction( accounts: Apply2InstructionAccounts, args: Apply2InstructionArgs, - programId = new web3.PublicKey('WorLD15A7CrDwLcLy4fRqtaTb9fbd8o8iqiEMUDse2n'), + programId = new web3.PublicKey("WorLD15A7CrDwLcLy4fRqtaTb9fbd8o8iqiEMUDse2n") ) { const [data] = apply2Struct.serialize({ instructionDiscriminator: apply2InstructionDiscriminator, diff --git a/clients/bolt-sdk/src/generated/instructions/apply3.ts b/clients/bolt-sdk/src/generated/instructions/apply3.ts index 562dd54..fc2334c 100644 --- a/clients/bolt-sdk/src/generated/instructions/apply3.ts +++ b/clients/bolt-sdk/src/generated/instructions/apply3.ts @@ -5,8 +5,8 @@ * See: https://github.com/metaplex-foundation/solita */ -import * as beet from '@metaplex-foundation/beet'; -import * as web3 from '@solana/web3.js'; +import * as beet from "@metaplex-foundation/beet"; +import * as web3 from "@solana/web3.js"; /** * @category Instructions @@ -27,10 +27,10 @@ export const apply3Struct = new beet.FixableBeetArgsStruct< } >( [ - ['instructionDiscriminator', beet.uniformFixedSizeArray(beet.u8, 8)], - ['args', beet.bytes], + ["instructionDiscriminator", beet.uniformFixedSizeArray(beet.u8, 8)], + ["args", beet.bytes], ], - 'Apply3InstructionArgs', + "Apply3InstructionArgs" ); /** * Accounts required by the _apply3_ instruction @@ -78,7 +78,7 @@ export const apply3InstructionDiscriminator = [ export function createApply3Instruction( accounts: Apply3InstructionAccounts, args: Apply3InstructionArgs, - programId = new web3.PublicKey('WorLD15A7CrDwLcLy4fRqtaTb9fbd8o8iqiEMUDse2n'), + programId = new web3.PublicKey("WorLD15A7CrDwLcLy4fRqtaTb9fbd8o8iqiEMUDse2n") ) { const [data] = apply3Struct.serialize({ instructionDiscriminator: apply3InstructionDiscriminator, diff --git a/clients/bolt-sdk/src/generated/instructions/apply4.ts b/clients/bolt-sdk/src/generated/instructions/apply4.ts index 2409048..8c03c3c 100644 --- a/clients/bolt-sdk/src/generated/instructions/apply4.ts +++ b/clients/bolt-sdk/src/generated/instructions/apply4.ts @@ -5,8 +5,8 @@ * See: https://github.com/metaplex-foundation/solita */ -import * as beet from '@metaplex-foundation/beet'; -import * as web3 from '@solana/web3.js'; +import * as beet from "@metaplex-foundation/beet"; +import * as web3 from "@solana/web3.js"; /** * @category Instructions @@ -27,10 +27,10 @@ export const apply4Struct = new beet.FixableBeetArgsStruct< } >( [ - ['instructionDiscriminator', beet.uniformFixedSizeArray(beet.u8, 8)], - ['args', beet.bytes], + ["instructionDiscriminator", beet.uniformFixedSizeArray(beet.u8, 8)], + ["args", beet.bytes], ], - 'Apply4InstructionArgs', + "Apply4InstructionArgs" ); /** * Accounts required by the _apply4_ instruction @@ -82,7 +82,7 @@ export const apply4InstructionDiscriminator = [ export function createApply4Instruction( accounts: Apply4InstructionAccounts, args: Apply4InstructionArgs, - programId = new web3.PublicKey('WorLD15A7CrDwLcLy4fRqtaTb9fbd8o8iqiEMUDse2n'), + programId = new web3.PublicKey("WorLD15A7CrDwLcLy4fRqtaTb9fbd8o8iqiEMUDse2n") ) { const [data] = apply4Struct.serialize({ instructionDiscriminator: apply4InstructionDiscriminator, diff --git a/clients/bolt-sdk/src/generated/instructions/apply5.ts b/clients/bolt-sdk/src/generated/instructions/apply5.ts index 24384f1..53b0ed3 100644 --- a/clients/bolt-sdk/src/generated/instructions/apply5.ts +++ b/clients/bolt-sdk/src/generated/instructions/apply5.ts @@ -5,8 +5,8 @@ * See: https://github.com/metaplex-foundation/solita */ -import * as beet from '@metaplex-foundation/beet'; -import * as web3 from '@solana/web3.js'; +import * as beet from "@metaplex-foundation/beet"; +import * as web3 from "@solana/web3.js"; /** * @category Instructions @@ -27,10 +27,10 @@ export const apply5Struct = new beet.FixableBeetArgsStruct< } >( [ - ['instructionDiscriminator', beet.uniformFixedSizeArray(beet.u8, 8)], - ['args', beet.bytes], + ["instructionDiscriminator", beet.uniformFixedSizeArray(beet.u8, 8)], + ["args", beet.bytes], ], - 'Apply5InstructionArgs', + "Apply5InstructionArgs" ); /** * Accounts required by the _apply5_ instruction @@ -86,7 +86,7 @@ export const apply5InstructionDiscriminator = [ export function createApply5Instruction( accounts: Apply5InstructionAccounts, args: Apply5InstructionArgs, - programId = new web3.PublicKey('WorLD15A7CrDwLcLy4fRqtaTb9fbd8o8iqiEMUDse2n'), + programId = new web3.PublicKey("WorLD15A7CrDwLcLy4fRqtaTb9fbd8o8iqiEMUDse2n") ) { const [data] = apply5Struct.serialize({ instructionDiscriminator: apply5InstructionDiscriminator, diff --git a/clients/bolt-sdk/src/generated/instructions/index.ts b/clients/bolt-sdk/src/generated/instructions/index.ts index 604aadf..abde1fd 100644 --- a/clients/bolt-sdk/src/generated/instructions/index.ts +++ b/clients/bolt-sdk/src/generated/instructions/index.ts @@ -5,12 +5,12 @@ * See: https://github.com/metaplex-foundation/solita */ -export * from './addEntity'; -export * from './apply'; -export * from './apply2'; -export * from './apply3'; -export * from './apply4'; -export * from './apply5'; -export * from './initializeComponent'; -export * from './initializeNewWorld'; -export * from './initializeRegistry'; +export * from "./addEntity"; +export * from "./apply"; +export * from "./apply2"; +export * from "./apply3"; +export * from "./apply4"; +export * from "./apply5"; +export * from "./initializeComponent"; +export * from "./initializeNewWorld"; +export * from "./initializeRegistry"; diff --git a/clients/bolt-sdk/src/generated/instructions/initializeComponent.ts b/clients/bolt-sdk/src/generated/instructions/initializeComponent.ts index 538ae0f..7b1099a 100644 --- a/clients/bolt-sdk/src/generated/instructions/initializeComponent.ts +++ b/clients/bolt-sdk/src/generated/instructions/initializeComponent.ts @@ -5,8 +5,8 @@ * See: https://github.com/metaplex-foundation/solita */ -import * as beet from '@metaplex-foundation/beet'; -import * as web3 from '@solana/web3.js'; +import * as beet from "@metaplex-foundation/beet"; +import * as web3 from "@solana/web3.js"; /** * @category Instructions @@ -16,8 +16,8 @@ import * as web3 from '@solana/web3.js'; export const initializeComponentStruct = new beet.BeetArgsStruct<{ instructionDiscriminator: number[] /* size: 8 */; }>( - [['instructionDiscriminator', beet.uniformFixedSizeArray(beet.u8, 8)]], - 'InitializeComponentInstructionArgs', + [["instructionDiscriminator", beet.uniformFixedSizeArray(beet.u8, 8)]], + "InitializeComponentInstructionArgs" ); /** * Accounts required by the _initializeComponent_ instruction @@ -57,7 +57,7 @@ export const initializeComponentInstructionDiscriminator = [ */ export function createInitializeComponentInstruction( accounts: InitializeComponentInstructionAccounts, - programId = new web3.PublicKey('WorLD15A7CrDwLcLy4fRqtaTb9fbd8o8iqiEMUDse2n'), + programId = new web3.PublicKey("WorLD15A7CrDwLcLy4fRqtaTb9fbd8o8iqiEMUDse2n") ) { const [data] = initializeComponentStruct.serialize({ instructionDiscriminator: initializeComponentInstructionDiscriminator, diff --git a/clients/bolt-sdk/src/generated/instructions/initializeNewWorld.ts b/clients/bolt-sdk/src/generated/instructions/initializeNewWorld.ts index fd2d3a0..ce9e2b9 100644 --- a/clients/bolt-sdk/src/generated/instructions/initializeNewWorld.ts +++ b/clients/bolt-sdk/src/generated/instructions/initializeNewWorld.ts @@ -5,8 +5,8 @@ * See: https://github.com/metaplex-foundation/solita */ -import * as beet from '@metaplex-foundation/beet'; -import * as web3 from '@solana/web3.js'; +import * as beet from "@metaplex-foundation/beet"; +import * as web3 from "@solana/web3.js"; /** * @category Instructions @@ -16,8 +16,8 @@ import * as web3 from '@solana/web3.js'; export const initializeNewWorldStruct = new beet.BeetArgsStruct<{ instructionDiscriminator: number[] /* size: 8 */; }>( - [['instructionDiscriminator', beet.uniformFixedSizeArray(beet.u8, 8)]], - 'InitializeNewWorldInstructionArgs', + [["instructionDiscriminator", beet.uniformFixedSizeArray(beet.u8, 8)]], + "InitializeNewWorldInstructionArgs" ); /** * Accounts required by the _initializeNewWorld_ instruction @@ -51,7 +51,7 @@ export const initializeNewWorldInstructionDiscriminator = [ */ export function createInitializeNewWorldInstruction( accounts: InitializeNewWorldInstructionAccounts, - programId = new web3.PublicKey('WorLD15A7CrDwLcLy4fRqtaTb9fbd8o8iqiEMUDse2n'), + programId = new web3.PublicKey("WorLD15A7CrDwLcLy4fRqtaTb9fbd8o8iqiEMUDse2n") ) { const [data] = initializeNewWorldStruct.serialize({ instructionDiscriminator: initializeNewWorldInstructionDiscriminator, diff --git a/clients/bolt-sdk/src/generated/instructions/initializeRegistry.ts b/clients/bolt-sdk/src/generated/instructions/initializeRegistry.ts index 2db26f5..8eb5cfa 100644 --- a/clients/bolt-sdk/src/generated/instructions/initializeRegistry.ts +++ b/clients/bolt-sdk/src/generated/instructions/initializeRegistry.ts @@ -5,8 +5,8 @@ * See: https://github.com/metaplex-foundation/solita */ -import * as beet from '@metaplex-foundation/beet'; -import * as web3 from '@solana/web3.js'; +import * as beet from "@metaplex-foundation/beet"; +import * as web3 from "@solana/web3.js"; /** * @category Instructions @@ -16,8 +16,8 @@ import * as web3 from '@solana/web3.js'; export const initializeRegistryStruct = new beet.BeetArgsStruct<{ instructionDiscriminator: number[] /* size: 8 */; }>( - [['instructionDiscriminator', beet.uniformFixedSizeArray(beet.u8, 8)]], - 'InitializeRegistryInstructionArgs', + [["instructionDiscriminator", beet.uniformFixedSizeArray(beet.u8, 8)]], + "InitializeRegistryInstructionArgs" ); /** * Accounts required by the _initializeRegistry_ instruction @@ -49,7 +49,7 @@ export const initializeRegistryInstructionDiscriminator = [ */ export function createInitializeRegistryInstruction( accounts: InitializeRegistryInstructionAccounts, - programId = new web3.PublicKey('WorLD15A7CrDwLcLy4fRqtaTb9fbd8o8iqiEMUDse2n'), + programId = new web3.PublicKey("WorLD15A7CrDwLcLy4fRqtaTb9fbd8o8iqiEMUDse2n") ) { const [data] = initializeRegistryStruct.serialize({ instructionDiscriminator: initializeRegistryInstructionDiscriminator, diff --git a/clients/bolt-sdk/src/generated/types/world.ts b/clients/bolt-sdk/src/generated/types/world.ts index 74ec5d3..bc8a086 100644 --- a/clients/bolt-sdk/src/generated/types/world.ts +++ b/clients/bolt-sdk/src/generated/types/world.ts @@ -5,556 +5,556 @@ * IDL can be found at `target/idl/world.json`. */ export interface World { - address: 'WorLD15A7CrDwLcLy4fRqtaTb9fbd8o8iqiEMUDse2n'; + address: "WorLD15A7CrDwLcLy4fRqtaTb9fbd8o8iqiEMUDse2n"; metadata: { - name: 'world'; - version: '0.1.9'; - spec: '0.1.0'; - description: 'Bolt World program'; - repository: 'https://github.com/magicblock-labs/bolt'; + name: "world"; + version: "0.1.9"; + spec: "0.1.0"; + description: "Bolt World program"; + repository: "https://github.com/magicblock-labs/bolt"; }; instructions: [ { - name: 'addAuthority'; + name: "addAuthority"; discriminator: [229, 9, 106, 73, 91, 213, 109, 183]; accounts: [ { - name: 'authority'; + name: "authority"; writable: true; signer: true; }, { - name: 'newAuthority'; + name: "newAuthority"; }, { - name: 'world'; + name: "world"; writable: true; }, { - name: 'systemProgram'; - address: '11111111111111111111111111111111'; - }, + name: "systemProgram"; + address: "11111111111111111111111111111111"; + } ]; args: [ { - name: 'worldId'; - type: 'u64'; - }, + name: "worldId"; + type: "u64"; + } ]; }, { - name: 'addEntity'; + name: "addEntity"; discriminator: [163, 241, 57, 35, 244, 244, 48, 57]; accounts: [ { - name: 'payer'; + name: "payer"; writable: true; signer: true; }, { - name: 'entity'; + name: "entity"; writable: true; }, { - name: 'world'; + name: "world"; writable: true; }, { - name: 'systemProgram'; - address: '11111111111111111111111111111111'; - }, + name: "systemProgram"; + address: "11111111111111111111111111111111"; + } ]; args: [ { - name: 'extraSeed'; + name: "extraSeed"; type: { - option: 'string'; + option: "string"; }; - }, + } ]; }, { - name: 'apply'; + name: "apply"; discriminator: [248, 243, 145, 24, 105, 50, 162, 225]; accounts: [ { - name: 'componentProgram'; + name: "componentProgram"; }, { - name: 'boltSystem'; + name: "boltSystem"; }, { - name: 'boltComponent'; + name: "boltComponent"; writable: true; }, { - name: 'authority'; + name: "authority"; signer: true; }, { - name: 'instructionSysvarAccount'; - address: 'Sysvar1nstructions1111111111111111111111111'; + name: "instructionSysvarAccount"; + address: "Sysvar1nstructions1111111111111111111111111"; }, { - name: 'world'; - }, + name: "world"; + } ]; args: [ { - name: 'args'; - type: 'bytes'; - }, + name: "args"; + type: "bytes"; + } ]; }, { - name: 'apply2'; + name: "apply2"; discriminator: [120, 32, 116, 154, 158, 159, 208, 73]; accounts: [ { - name: 'boltSystem'; + name: "boltSystem"; }, { - name: 'componentProgram1'; + name: "componentProgram1"; }, { - name: 'boltComponent1'; + name: "boltComponent1"; writable: true; }, { - name: 'componentProgram2'; + name: "componentProgram2"; }, { - name: 'boltComponent2'; + name: "boltComponent2"; writable: true; }, { - name: 'authority'; + name: "authority"; signer: true; }, { - name: 'instructionSysvarAccount'; - address: 'Sysvar1nstructions1111111111111111111111111'; + name: "instructionSysvarAccount"; + address: "Sysvar1nstructions1111111111111111111111111"; }, { - name: 'world'; - }, + name: "world"; + } ]; args: [ { - name: 'args'; - type: 'bytes'; - }, + name: "args"; + type: "bytes"; + } ]; }, { - name: 'apply3'; + name: "apply3"; discriminator: [254, 146, 49, 7, 236, 131, 105, 221]; accounts: [ { - name: 'boltSystem'; + name: "boltSystem"; }, { - name: 'componentProgram1'; + name: "componentProgram1"; }, { - name: 'boltComponent1'; + name: "boltComponent1"; writable: true; }, { - name: 'componentProgram2'; + name: "componentProgram2"; }, { - name: 'boltComponent2'; + name: "boltComponent2"; writable: true; }, { - name: 'componentProgram3'; + name: "componentProgram3"; }, { - name: 'boltComponent3'; + name: "boltComponent3"; writable: true; }, { - name: 'authority'; + name: "authority"; signer: true; }, { - name: 'instructionSysvarAccount'; - address: 'Sysvar1nstructions1111111111111111111111111'; + name: "instructionSysvarAccount"; + address: "Sysvar1nstructions1111111111111111111111111"; }, { - name: 'world'; - }, + name: "world"; + } ]; args: [ { - name: 'args'; - type: 'bytes'; - }, + name: "args"; + type: "bytes"; + } ]; }, { - name: 'apply4'; + name: "apply4"; discriminator: [223, 104, 24, 79, 252, 196, 14, 109]; accounts: [ { - name: 'boltSystem'; + name: "boltSystem"; }, { - name: 'componentProgram1'; + name: "componentProgram1"; }, { - name: 'boltComponent1'; + name: "boltComponent1"; writable: true; }, { - name: 'componentProgram2'; + name: "componentProgram2"; }, { - name: 'boltComponent2'; + name: "boltComponent2"; writable: true; }, { - name: 'componentProgram3'; + name: "componentProgram3"; }, { - name: 'boltComponent3'; + name: "boltComponent3"; writable: true; }, { - name: 'componentProgram4'; + name: "componentProgram4"; }, { - name: 'boltComponent4'; + name: "boltComponent4"; writable: true; }, { - name: 'authority'; + name: "authority"; signer: true; }, { - name: 'instructionSysvarAccount'; - address: 'Sysvar1nstructions1111111111111111111111111'; + name: "instructionSysvarAccount"; + address: "Sysvar1nstructions1111111111111111111111111"; }, { - name: 'world'; - }, + name: "world"; + } ]; args: [ { - name: 'args'; - type: 'bytes'; - }, + name: "args"; + type: "bytes"; + } ]; }, { - name: 'apply5'; + name: "apply5"; discriminator: [70, 164, 214, 28, 136, 116, 84, 153]; accounts: [ { - name: 'boltSystem'; + name: "boltSystem"; }, { - name: 'componentProgram1'; + name: "componentProgram1"; }, { - name: 'boltComponent1'; + name: "boltComponent1"; writable: true; }, { - name: 'componentProgram2'; + name: "componentProgram2"; }, { - name: 'boltComponent2'; + name: "boltComponent2"; writable: true; }, { - name: 'componentProgram3'; + name: "componentProgram3"; }, { - name: 'boltComponent3'; + name: "boltComponent3"; writable: true; }, { - name: 'componentProgram4'; + name: "componentProgram4"; }, { - name: 'boltComponent4'; + name: "boltComponent4"; writable: true; }, { - name: 'componentProgram5'; + name: "componentProgram5"; }, { - name: 'boltComponent5'; + name: "boltComponent5"; writable: true; }, { - name: 'authority'; + name: "authority"; signer: true; }, { - name: 'instructionSysvarAccount'; - address: 'Sysvar1nstructions1111111111111111111111111'; + name: "instructionSysvarAccount"; + address: "Sysvar1nstructions1111111111111111111111111"; }, { - name: 'world'; - }, + name: "world"; + } ]; args: [ { - name: 'args'; - type: 'bytes'; - }, + name: "args"; + type: "bytes"; + } ]; }, { - name: 'approveSystem'; + name: "approveSystem"; discriminator: [114, 165, 105, 68, 52, 67, 207, 121]; accounts: [ { - name: 'authority'; + name: "authority"; writable: true; signer: true; }, { - name: 'world'; + name: "world"; writable: true; }, { - name: 'system'; + name: "system"; }, { - name: 'systemProgram'; - address: '11111111111111111111111111111111'; - }, + name: "systemProgram"; + address: "11111111111111111111111111111111"; + } ]; args: []; }, { - name: 'initializeComponent'; + name: "initializeComponent"; discriminator: [36, 143, 233, 113, 12, 234, 61, 30]; accounts: [ { - name: 'payer'; + name: "payer"; writable: true; signer: true; }, { - name: 'data'; + name: "data"; writable: true; }, { - name: 'entity'; + name: "entity"; }, { - name: 'componentProgram'; + name: "componentProgram"; }, { - name: 'authority'; + name: "authority"; }, { - name: 'instructionSysvarAccount'; - address: 'Sysvar1nstructions1111111111111111111111111'; + name: "instructionSysvarAccount"; + address: "Sysvar1nstructions1111111111111111111111111"; }, { - name: 'systemProgram'; - address: '11111111111111111111111111111111'; - }, + name: "systemProgram"; + address: "11111111111111111111111111111111"; + } ]; args: []; }, { - name: 'initializeNewWorld'; + name: "initializeNewWorld"; discriminator: [23, 96, 88, 194, 200, 203, 200, 98]; accounts: [ { - name: 'payer'; + name: "payer"; writable: true; signer: true; }, { - name: 'world'; + name: "world"; writable: true; }, { - name: 'registry'; + name: "registry"; writable: true; }, { - name: 'systemProgram'; - address: '11111111111111111111111111111111'; - }, + name: "systemProgram"; + address: "11111111111111111111111111111111"; + } ]; args: []; }, { - name: 'initializeRegistry'; + name: "initializeRegistry"; discriminator: [189, 181, 20, 17, 174, 57, 249, 59]; accounts: [ { - name: 'registry'; + name: "registry"; writable: true; }, { - name: 'payer'; + name: "payer"; writable: true; signer: true; }, { - name: 'systemProgram'; - address: '11111111111111111111111111111111'; - }, + name: "systemProgram"; + address: "11111111111111111111111111111111"; + } ]; args: []; }, { - name: 'removeAuthority'; + name: "removeAuthority"; discriminator: [242, 104, 208, 132, 190, 250, 74, 216]; accounts: [ { - name: 'authority'; + name: "authority"; writable: true; signer: true; }, { - name: 'authorityToDelete'; + name: "authorityToDelete"; }, { - name: 'world'; + name: "world"; writable: true; }, { - name: 'systemProgram'; - address: '11111111111111111111111111111111'; - }, + name: "systemProgram"; + address: "11111111111111111111111111111111"; + } ]; args: [ { - name: 'worldId'; - type: 'u64'; - }, + name: "worldId"; + type: "u64"; + } ]; }, { - name: 'removeSystem'; + name: "removeSystem"; discriminator: [218, 80, 71, 80, 161, 130, 149, 120]; accounts: [ { - name: 'authority'; + name: "authority"; writable: true; signer: true; }, { - name: 'world'; + name: "world"; writable: true; }, { - name: 'system'; + name: "system"; }, { - name: 'systemProgram'; - address: '11111111111111111111111111111111'; - }, + name: "systemProgram"; + address: "11111111111111111111111111111111"; + } ]; args: []; - }, + } ]; accounts: [ { - name: 'entity'; + name: "entity"; discriminator: [46, 157, 161, 161, 254, 46, 79, 24]; }, { - name: 'registry'; + name: "registry"; discriminator: [47, 174, 110, 246, 184, 182, 252, 218]; }, { - name: 'world'; + name: "world"; discriminator: [145, 45, 170, 174, 122, 32, 155, 124]; - }, + } ]; errors: [ { code: 6000; - name: 'invalidAuthority'; - msg: 'Invalid authority for instruction'; + name: "invalidAuthority"; + msg: "Invalid authority for instruction"; }, { code: 6001; - name: 'worldAccountMismatch'; - msg: 'The provided world account does not match the expected PDA.'; + name: "worldAccountMismatch"; + msg: "The provided world account does not match the expected PDA."; }, { code: 6002; - name: 'tooManyAuthorities'; - msg: 'Exceed the maximum number of authorities.'; + name: "tooManyAuthorities"; + msg: "Exceed the maximum number of authorities."; }, { code: 6003; - name: 'authorityNotFound'; - msg: 'The provided authority not found'; + name: "authorityNotFound"; + msg: "The provided authority not found"; }, { code: 6004; - name: 'systemNotApproved'; - msg: 'The system is not approved in this world instance'; - }, + name: "systemNotApproved"; + msg: "The system is not approved in this world instance"; + } ]; types: [ { - name: 'entity'; + name: "entity"; type: { - kind: 'struct'; + kind: "struct"; fields: [ { - name: 'id'; - type: 'u64'; - }, + name: "id"; + type: "u64"; + } ]; }; }, { - name: 'registry'; + name: "registry"; type: { - kind: 'struct'; + kind: "struct"; fields: [ { - name: 'worlds'; - type: 'u64'; - }, + name: "worlds"; + type: "u64"; + } ]; }; }, { - name: 'world'; + name: "world"; type: { - kind: 'struct'; + kind: "struct"; fields: [ { - name: 'id'; - type: 'u64'; + name: "id"; + type: "u64"; }, { - name: 'entities'; - type: 'u64'; + name: "entities"; + type: "u64"; }, { - name: 'authorities'; + name: "authorities"; type: { - vec: 'pubkey'; + vec: "pubkey"; }; }, { - name: 'permissionless'; - type: 'bool'; + name: "permissionless"; + type: "bool"; }, { - name: 'systems'; - type: 'bytes'; - }, + name: "systems"; + type: "bytes"; + } ]; }; - }, + } ]; } diff --git a/clients/bolt-sdk/src/index.ts b/clients/bolt-sdk/src/index.ts index 03537fd..b787c1d 100644 --- a/clients/bolt-sdk/src/index.ts +++ b/clients/bolt-sdk/src/index.ts @@ -1,22 +1,22 @@ -import { PublicKey } from '@solana/web3.js'; -import type BN from 'bn.js'; -import { PROGRAM_ID } from './generated'; -export * from './generated/accounts'; -export * from './generated/instructions'; -export * from './world/transactions'; -export * from './delegation/delegate'; -export * from './delegation/undelegate'; -export * from './delegation/allow_undelegation'; -export { DELEGATION_PROGRAM_ID } from '@magicblock-labs/ephemeral-rollups-sdk'; +import { PublicKey } from "@solana/web3.js"; +import type BN from "bn.js"; +import { PROGRAM_ID } from "./generated"; +export * from "./generated/accounts"; +export * from "./generated/instructions"; +export * from "./world/transactions"; +export * from "./delegation/delegate"; +export * from "./delegation/undelegate"; +export * from "./delegation/allow_undelegation"; +export { DELEGATION_PROGRAM_ID } from "@magicblock-labs/ephemeral-rollups-sdk"; export const SYSVAR_INSTRUCTIONS_PUBKEY = new PublicKey( - 'Sysvar1nstructions1111111111111111111111111', + "Sysvar1nstructions1111111111111111111111111" ); export function FindRegistryPda({ programId }: { programId?: PublicKey }) { return PublicKey.findProgramAddressSync( - [Buffer.from('registry')], - programId ?? PROGRAM_ID, + [Buffer.from("registry")], + programId ?? PROGRAM_ID )[0]; } @@ -27,10 +27,10 @@ export function FindWorldPda({ worldId: BN; programId?: PublicKey; }) { - const idBuffer = Buffer.from(worldId.toArrayLike(Buffer, 'be', 8)); + const idBuffer = Buffer.from(worldId.toArrayLike(Buffer, "be", 8)); return PublicKey.findProgramAddressSync( - [Buffer.from('world'), idBuffer], - programId ?? PROGRAM_ID, + [Buffer.from("world"), idBuffer], + programId ?? PROGRAM_ID )[0]; } @@ -45,16 +45,16 @@ export function FindEntityPda({ seed?: string; programId?: PublicKey; }) { - const worldIdBuffer = Buffer.from(worldId.toArrayLike(Buffer, 'be', 8)); - const seeds = [Buffer.from('entity'), worldIdBuffer]; + const worldIdBuffer = Buffer.from(worldId.toArrayLike(Buffer, "be", 8)); + const seeds = [Buffer.from("entity"), worldIdBuffer]; if (seed !== undefined) { seeds.push(Buffer.from(new Uint8Array(8))); seeds.push(Buffer.from(seed)); } else if (entityId !== undefined) { - const entityIdBuffer = Buffer.from(entityId.toArrayLike(Buffer, 'be', 8)); + const entityIdBuffer = Buffer.from(entityId.toArrayLike(Buffer, "be", 8)); seeds.push(entityIdBuffer); } else { - throw new Error('An entity must have either an Id or a Seed'); + throw new Error("An entity must have either an Id or a Seed"); } return PublicKey.findProgramAddressSync(seeds, programId ?? PROGRAM_ID)[0]; } @@ -69,8 +69,8 @@ export function FindComponentPda({ seed?: string; }) { return PublicKey.findProgramAddressSync( - [Buffer.from(seed ?? ''), entity.toBytes()], - componentId, + [Buffer.from(seed ?? ""), entity.toBytes()], + componentId )[0]; } @@ -86,6 +86,6 @@ export function SerializeArgs(args: any = {}) { return Buffer.from( binaryData.buffer, binaryData.byteOffset, - binaryData.byteLength, + binaryData.byteLength ); } diff --git a/clients/bolt-sdk/src/world/transactions.ts b/clients/bolt-sdk/src/world/transactions.ts index a2f3dc0..b9d9beb 100644 --- a/clients/bolt-sdk/src/world/transactions.ts +++ b/clients/bolt-sdk/src/world/transactions.ts @@ -10,18 +10,18 @@ import { SerializeArgs, SYSVAR_INSTRUCTIONS_PUBKEY, World, -} from '../index'; -import BN from 'bn.js'; -import type web3 from '@solana/web3.js'; +} from "../index"; +import BN from "bn.js"; +import type web3 from "@solana/web3.js"; import { type Connection, type PublicKey, Transaction, type TransactionInstruction, -} from '@solana/web3.js'; -import type WorldProgram from '../generated'; -import { PROGRAM_ID, worldIdl } from '../generated'; -import { type Idl, Program } from '@coral-xyz/anchor'; +} from "@solana/web3.js"; +import type WorldProgram from "../generated"; +import { PROGRAM_ID, worldIdl } from "../generated"; +import { type Idl, Program } from "@coral-xyz/anchor"; const MAX_COMPONENTS = 5; @@ -83,7 +83,7 @@ export async function AddAuthority({ transaction: Transaction; }> { const program = new Program( - worldIdl as Idl, + worldIdl as Idl ) as unknown as Program; const worldInstance = await World.fromAccountAddress(connection, world); const worldId = new BN(worldInstance.id); @@ -124,7 +124,7 @@ export async function RemoveAuthority({ transaction: Transaction; }> { const program = new Program( - worldIdl as Idl, + worldIdl as Idl ) as unknown as Program; const worldInstance = await World.fromAccountAddress(connection, world); const worldId = new BN(worldInstance.id); @@ -162,7 +162,7 @@ export async function ApproveSystem({ transaction: Transaction; }> { const program = new Program( - worldIdl as Idl, + worldIdl as Idl ) as unknown as Program; const approveSystemIx = await program.methods .approveSystem() @@ -198,7 +198,7 @@ export async function RemoveSystem({ transaction: Transaction; }> { const program = new Program( - worldIdl as Idl, + worldIdl as Idl ) as unknown as Program; const removeSystemIx = await program.methods .removeSystem() @@ -248,7 +248,7 @@ export async function AddEntity({ payer, entity: entityPda, }, - { extraSeed: seed ?? null }, + { extraSeed: seed ?? null } ); return { instruction: addEntityIx, @@ -271,7 +271,7 @@ export async function InitializeComponent({ payer, entity, componentId, - seed = '', + seed = "", authority, anchorRemainingAccounts, }: { @@ -312,14 +312,14 @@ interface ApplySystemInstruction { args?: object; } function getApplyInstructionFunctionName(componentsCount: number) { - return `apply${componentsCount > 1 ? componentsCount : ''}`; + return `apply${componentsCount > 1 ? componentsCount : ""}`; } function getBoltComponentName(index: number, componentsCount: number) { - if (componentsCount === 1) return 'boltComponent'; + if (componentsCount === 1) return "boltComponent"; return `boltComponent${index + 1}`; } function getBoltComponentProgramName(index: number, componentsCount: number) { - if (componentsCount === 1) return 'componentProgram'; + if (componentsCount === 1) return "componentProgram"; return `componentProgram${index + 1}`; } async function createApplySystemInstruction({ @@ -331,18 +331,18 @@ async function createApplySystemInstruction({ args, }: ApplySystemInstruction): Promise { const program = new Program( - worldIdl as Idl, + worldIdl as Idl ) as unknown as Program; let componentCount = 0; entities.forEach(function (entity) { componentCount += entity.components.length; }); if (componentCount <= 0) { - throw new Error('No components provided'); + throw new Error("No components provided"); } if (componentCount > MAX_COMPONENTS) { throw new Error( - `Not implemented for component counts outside 1-${MAX_COMPONENTS}`, + `Not implemented for component counts outside 1-${MAX_COMPONENTS}` ); } @@ -370,7 +370,7 @@ async function createApplySystemInstruction({ }); }); return program.methods[getApplyInstructionFunctionName(componentCount)]( - SerializeArgs(args), + SerializeArgs(args) ) .accounts(applyAccounts) .remainingAccounts(extraAccounts ?? []) diff --git a/migrations/deploy.js b/migrations/deploy.js index f092848..933d4a0 100644 --- a/migrations/deploy.js +++ b/migrations/deploy.js @@ -21,7 +21,7 @@ var __awaiter = } function rejected(value) { try { - step(generator['throw'](value)); + step(generator["throw"](value)); } catch (e) { reject(e); } @@ -34,7 +34,7 @@ var __awaiter = step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; -const anchor = require('@coral-xyz/anchor'); +const anchor = require("@coral-xyz/anchor"); module.exports = function (provider) { return __awaiter(this, void 0, void 0, function* () { // Configure client to use the provider. diff --git a/migrations/deploy.ts b/migrations/deploy.ts index b8551f5..82fb175 100644 --- a/migrations/deploy.ts +++ b/migrations/deploy.ts @@ -2,7 +2,7 @@ // single deploy script that's invoked from the CLI, injecting a provider // configured from the workspace's Anchor.toml. -const anchor = require('@coral-xyz/anchor'); +const anchor = require("@coral-xyz/anchor"); module.exports = async function (provider) { // Configure client to use the provider. diff --git a/tests/bolt.ts b/tests/bolt.ts index 7814f77..f58601d 100644 --- a/tests/bolt.ts +++ b/tests/bolt.ts @@ -1,15 +1,15 @@ -import * as anchor from '@coral-xyz/anchor'; -import { type Program, web3 } from '@coral-xyz/anchor'; -import { Keypair, type PublicKey } from '@solana/web3.js'; -import { type Position } from '../target/types/position'; -import { type Velocity } from '../target/types/velocity'; -import { type BoltComponent } from '../target/types/bolt_component'; -import { type SystemSimpleMovement } from '../target/types/system_simple_movement'; -import { type World } from '../target/types/world'; -import { type SystemFly } from '../target/types/system_fly'; -import { type SystemApplyVelocity } from '../target/types/system_apply_velocity'; -import { expect } from 'chai'; -import type BN from 'bn.js'; +import * as anchor from "@coral-xyz/anchor"; +import { type Program, web3 } from "@coral-xyz/anchor"; +import { Keypair, type PublicKey } from "@solana/web3.js"; +import { type Position } from "../target/types/position"; +import { type Velocity } from "../target/types/velocity"; +import { type BoltComponent } from "../target/types/bolt_component"; +import { type SystemSimpleMovement } from "../target/types/system_simple_movement"; +import { type World } from "../target/types/world"; +import { type SystemFly } from "../target/types/system_fly"; +import { type SystemApplyVelocity } from "../target/types/system_apply_velocity"; +import { expect } from "chai"; +import type BN from "bn.js"; import { AddEntity, createInitializeRegistryInstruction, @@ -23,13 +23,13 @@ import { RemoveAuthority, ApproveSystem, RemoveSystem, -} from '../clients/bolt-sdk'; +} from "../clients/bolt-sdk"; enum Direction { - Left = 'Left', - Right = 'Right', - Up = 'Up', - Down = 'Down', + Left = "Left", + Right = "Right", + Up = "Up", + Down = "Down", } function padCenter(value: string, width: number) { @@ -39,34 +39,34 @@ function padCenter(value: string, width: number) { } const padding = (width - length) / 2; const align = width - padding; - return value.padStart(align, ' ').padEnd(width, ' '); + return value.padStart(align, " ").padEnd(width, " "); } function logPosition(title: string, { x, y, z }: { x: BN; y: BN; z: BN }) { - console.log(' +----------------------------------+'); + console.log(" +----------------------------------+"); console.log(` | ${padCenter(title, 32)} |`); - console.log(' +-----------------+----------------+'); - console.log(` | X Position | ${String(x).padEnd(14, ' ')} |`); - console.log(` | Y Position | ${String(y).padEnd(14, ' ')} |`); - console.log(` | Z Position | ${String(z).padEnd(14, ' ')} |`); - console.log(' +-----------------+----------------+'); + console.log(" +-----------------+----------------+"); + console.log(` | X Position | ${String(x).padEnd(14, " ")} |`); + console.log(` | Y Position | ${String(y).padEnd(14, " ")} |`); + console.log(` | Z Position | ${String(z).padEnd(14, " ")} |`); + console.log(" +-----------------+----------------+"); } function logVelocity( title: string, - { x, y, z, lastApplied }: { x: BN; y: BN; z: BN; lastApplied: BN }, + { x, y, z, lastApplied }: { x: BN; y: BN; z: BN; lastApplied: BN } ) { - console.log(' +----------------------------------+'); + console.log(" +----------------------------------+"); console.log(` | ${padCenter(title, 32)} |`); - console.log(' +-----------------+----------------+'); - console.log(` | X Velocity | ${String(x).padEnd(14, ' ')} |`); - console.log(` | Y Velocity | ${String(y).padEnd(14, ' ')} |`); - console.log(` | Z Velocity | ${String(z).padEnd(14, ' ')} |`); - console.log(` | Last Applied | ${String(lastApplied).padEnd(14, ' ')} |`); - console.log(' +-----------------+----------------+'); + console.log(" +-----------------+----------------+"); + console.log(` | X Velocity | ${String(x).padEnd(14, " ")} |`); + console.log(` | Y Velocity | ${String(y).padEnd(14, " ")} |`); + console.log(` | Z Velocity | ${String(z).padEnd(14, " ")} |`); + console.log(` | Last Applied | ${String(lastApplied).padEnd(14, " ")} |`); + console.log(" +-----------------+----------------+"); } -describe('bolt', () => { +describe("bolt", () => { const provider = anchor.AnchorProvider.env(); anchor.setProvider(provider); @@ -104,7 +104,7 @@ describe('bolt', () => { const secondAuthority = Keypair.generate().publicKey; - it.only('InitializeRegistry', async () => { + it.only("InitializeRegistry", async () => { const registryPda = FindRegistryPda({}); const initializeRegistryIx = createInitializeRegistryInstruction({ registry: registryPda, @@ -114,19 +114,19 @@ describe('bolt', () => { await provider.sendAndConfirm(tx); }); - it.only('InitializeNewWorld', async () => { + it.only("InitializeNewWorld", async () => { const initializeNewWorld = await InitializeNewWorld({ payer: provider.wallet.publicKey, connection: provider.connection, }); const signature = await provider.sendAndConfirm( - initializeNewWorld.transaction, + initializeNewWorld.transaction ); - console.log('InitializeNewWorld signature: ', signature); + console.log("InitializeNewWorld signature: ", signature); worldPda = initializeNewWorld.worldPda; // Saved for later }); - it('Add authority', async () => { + it("Add authority", async () => { const addAuthority = await AddAuthority({ authority: provider.wallet.publicKey, newAuthority: provider.wallet.publicKey, @@ -139,12 +139,12 @@ describe('bolt', () => { const worldAccount = await worldProgram.account.world.fetch(worldPda); expect( worldAccount.authorities.some((auth) => - auth.equals(provider.wallet.publicKey), - ), + auth.equals(provider.wallet.publicKey) + ) ); }); - it('Add a second authority', async () => { + it("Add a second authority", async () => { const addAuthority = await AddAuthority({ authority: provider.wallet.publicKey, newAuthority: secondAuthority, @@ -155,11 +155,11 @@ describe('bolt', () => { console.log(`Add Authority signature: ${signature}`); const worldAccount = await worldProgram.account.world.fetch(worldPda); expect( - worldAccount.authorities.some((auth) => auth.equals(secondAuthority)), + worldAccount.authorities.some((auth) => auth.equals(secondAuthority)) ); }); - it('Remove an authority', async () => { + it("Remove an authority", async () => { const addAuthority = await RemoveAuthority({ authority: provider.wallet.publicKey, authorityToDelete: secondAuthority, @@ -170,11 +170,11 @@ describe('bolt', () => { console.log(`Add Authority signature: ${signature}`); const worldAccount = await worldProgram.account.world.fetch(worldPda); expect( - !worldAccount.authorities.some((auth) => auth.equals(secondAuthority)), + !worldAccount.authorities.some((auth) => auth.equals(secondAuthority)) ); }); - it('InitializeNewWorld 2', async () => { + it("InitializeNewWorld 2", async () => { const initializeNewWorld = await InitializeNewWorld({ payer: provider.wallet.publicKey, connection: provider.connection, @@ -182,7 +182,7 @@ describe('bolt', () => { await provider.sendAndConfirm(initializeNewWorld.transaction); }); - it('Add entity 1', async () => { + it("Add entity 1", async () => { const addEntity = await AddEntity({ payer: provider.wallet.publicKey, world: worldPda, @@ -192,7 +192,7 @@ describe('bolt', () => { entity1Pda = addEntity.entityPda; // Saved for later }); - it('Add entity 2', async () => { + it("Add entity 2", async () => { const addEntity = await AddEntity({ payer: provider.wallet.publicKey, world: worldPda, @@ -202,7 +202,7 @@ describe('bolt', () => { entity2Pda = addEntity.entityPda; // Saved for later }); - it('Add entity 3', async () => { + it("Add entity 3", async () => { const addEntity = await AddEntity({ payer: provider.wallet.publicKey, world: worldPda, @@ -211,18 +211,18 @@ describe('bolt', () => { await provider.sendAndConfirm(addEntity.transaction); }); - it('Add entity 4 (with seed)', async () => { + it("Add entity 4 (with seed)", async () => { const addEntity = await AddEntity({ payer: provider.wallet.publicKey, world: worldPda, - seed: 'extra-seed', + seed: "extra-seed", connection: provider.connection, }); await provider.sendAndConfirm(addEntity.transaction); entity4Pda = addEntity.entityPda; }); - it('Add entity 5', async () => { + it("Add entity 5", async () => { const addEntity = await AddEntity({ payer: provider.wallet.publicKey, world: worldPda, @@ -232,27 +232,27 @@ describe('bolt', () => { entity5Pda = addEntity.entityPda; // Saved for later }); - it('Initialize Original Component on Entity 1, trough the world instance', async () => { + it("Initialize Original Component on Entity 1, trough the world instance", async () => { const initializeComponent = await InitializeComponent({ payer: provider.wallet.publicKey, entity: entity1Pda, - seed: 'origin-component', + seed: "origin-component", componentId: boltComponentProgram.programId, }); await provider.sendAndConfirm(initializeComponent.transaction); }); - it('Initialize Original Component on Entity 2, trough the world instance', async () => { + it("Initialize Original Component on Entity 2, trough the world instance", async () => { const initializeComponent = await InitializeComponent({ payer: provider.wallet.publicKey, entity: entity2Pda, - seed: 'origin-component', + seed: "origin-component", componentId: boltComponentProgram.programId, }); await provider.sendAndConfirm(initializeComponent.transaction); }); - it('Initialize Position Component on Entity 1', async () => { + it("Initialize Position Component on Entity 1", async () => { const initializeComponent = await InitializeComponent({ payer: provider.wallet.publicKey, entity: entity1Pda, @@ -262,18 +262,18 @@ describe('bolt', () => { componentPositionEntity1Pda = initializeComponent.componentPda; // Saved for later }); - it('Initialize Velocity Component on Entity 1 (with seed)', async () => { + it("Initialize Velocity Component on Entity 1 (with seed)", async () => { const initializeComponent = await InitializeComponent({ payer: provider.wallet.publicKey, entity: entity1Pda, componentId: exampleComponentVelocity.programId, - seed: 'component-velocity', + seed: "component-velocity", }); await provider.sendAndConfirm(initializeComponent.transaction); componentVelocityEntity1Pda = initializeComponent.componentPda; // Saved for later }); - it('Initialize Position Component on Entity 2', async () => { + it("Initialize Position Component on Entity 2", async () => { const initializeComponent = await InitializeComponent({ payer: provider.wallet.publicKey, entity: entity2Pda, @@ -282,7 +282,7 @@ describe('bolt', () => { await provider.sendAndConfirm(initializeComponent.transaction); }); - it('Initialize Position Component on Entity 4', async () => { + it("Initialize Position Component on Entity 4", async () => { const initializeComponent = await InitializeComponent({ payer: provider.wallet.publicKey, entity: entity4Pda, @@ -292,7 +292,7 @@ describe('bolt', () => { componentPositionEntity4Pda = initializeComponent.componentPda; // Saved for later }); - it('Initialize Position Component on Entity 5 (with authority)', async () => { + it("Initialize Position Component on Entity 5 (with authority)", async () => { const initializeComponent = await InitializeComponent({ payer: provider.wallet.publicKey, entity: entity5Pda, @@ -303,17 +303,17 @@ describe('bolt', () => { componentPositionEntity5Pda = initializeComponent.componentPda; // Saved for later }); - it('Check Position on Entity 1 is default', async () => { + it("Check Position on Entity 1 is default", async () => { const position = await exampleComponentPosition.account.position.fetch( - componentPositionEntity1Pda, + componentPositionEntity1Pda ); - logPosition('Default State: Entity 1', position); + logPosition("Default State: Entity 1", position); expect(position.x.toNumber()).to.equal(0); expect(position.y.toNumber()).to.equal(0); expect(position.z.toNumber()).to.equal(0); }); - it('Apply Simple Movement System (Up) on Entity 1', async () => { + it("Apply Simple Movement System (Up) on Entity 1", async () => { const applySystem = await ApplySystem({ authority: provider.wallet.publicKey, systemId: exampleSystemSimpleMovement, @@ -331,20 +331,20 @@ describe('bolt', () => { const signature = await provider.sendAndConfirm( applySystem.transaction, [], - { skipPreflight: true }, + { skipPreflight: true } ); console.log(`Signature: ${signature}`); const position = await exampleComponentPosition.account.position.fetch( - componentPositionEntity1Pda, + componentPositionEntity1Pda ); - logPosition('Movement System: Entity 1', position); + logPosition("Movement System: Entity 1", position); expect(position.x.toNumber()).to.equal(0); expect(position.y.toNumber()).to.equal(1); expect(position.z.toNumber()).to.equal(0); }); - it('Apply Simple Movement System (Right) on Entity 1', async () => { + it("Apply Simple Movement System (Right) on Entity 1", async () => { const applySystem = await ApplySystem({ authority: provider.wallet.publicKey, systemId: exampleSystemSimpleMovement, @@ -362,15 +362,15 @@ describe('bolt', () => { await provider.sendAndConfirm(applySystem.transaction); const position = await exampleComponentPosition.account.position.fetch( - componentPositionEntity1Pda, + componentPositionEntity1Pda ); - logPosition('Movement System: Entity 1', position); + logPosition("Movement System: Entity 1", position); expect(position.x.toNumber()).to.equal(1); expect(position.y.toNumber()).to.equal(1); expect(position.z.toNumber()).to.equal(0); }); - it('Apply Fly System on Entity 1', async () => { + it("Apply Fly System on Entity 1", async () => { const applySystem = await ApplySystem({ authority: provider.wallet.publicKey, systemId: exampleSystemFly, @@ -385,15 +385,15 @@ describe('bolt', () => { await provider.sendAndConfirm(applySystem.transaction); const position = await exampleComponentPosition.account.position.fetch( - componentPositionEntity1Pda, + componentPositionEntity1Pda ); - logPosition('Fly System: Entity 1', position); + logPosition("Fly System: Entity 1", position); expect(position.x.toNumber()).to.equal(1); expect(position.y.toNumber()).to.equal(1); expect(position.z.toNumber()).to.equal(1); }); - it('Apply System Velocity on Entity 1', async () => { + it("Apply System Velocity on Entity 1", async () => { const applySystem = await ApplySystem({ authority: provider.wallet.publicKey, systemId: exampleSystemApplyVelocity, @@ -404,7 +404,7 @@ describe('bolt', () => { components: [ { componentId: exampleComponentVelocity.programId, - seed: 'component-velocity', + seed: "component-velocity", }, { componentId: exampleComponentPosition.programId }, ], @@ -414,24 +414,24 @@ describe('bolt', () => { await provider.sendAndConfirm(applySystem.transaction); const velocity = await exampleComponentVelocity.account.velocity.fetch( - componentVelocityEntity1Pda, + componentVelocityEntity1Pda ); - logVelocity('Apply System Velocity: Entity 1', velocity); + logVelocity("Apply System Velocity: Entity 1", velocity); expect(velocity.x.toNumber()).to.equal(10); expect(velocity.y.toNumber()).to.equal(0); expect(velocity.z.toNumber()).to.equal(0); expect(velocity.lastApplied.toNumber()).to.not.equal(0); const position = await exampleComponentPosition.account.position.fetch( - componentPositionEntity1Pda, + componentPositionEntity1Pda ); - logPosition('Apply System Velocity: Entity 1', position); + logPosition("Apply System Velocity: Entity 1", position); expect(position.x.toNumber()).to.greaterThan(1); expect(position.y.toNumber()).to.equal(1); expect(position.z.toNumber()).to.equal(1); }); - it('Apply System Velocity on Entity 1, with Clock external account', async () => { + it("Apply System Velocity on Entity 1, with Clock external account", async () => { const applySystem = await ApplySystem({ authority: provider.wallet.publicKey, systemId: exampleSystemApplyVelocity, @@ -442,7 +442,7 @@ describe('bolt', () => { components: [ { componentId: exampleComponentVelocity.programId, - seed: 'component-velocity', + seed: "component-velocity", }, { componentId: exampleComponentPosition.programId }, ], @@ -451,7 +451,7 @@ describe('bolt', () => { extraAccounts: [ { pubkey: new web3.PublicKey( - 'SysvarC1ock11111111111111111111111111111111', + "SysvarC1ock11111111111111111111111111111111" ), isWritable: false, isSigner: false, @@ -461,15 +461,15 @@ describe('bolt', () => { await provider.sendAndConfirm(applySystem.transaction); const position = await exampleComponentPosition.account.position.fetch( - componentPositionEntity1Pda, + componentPositionEntity1Pda ); - logPosition('Apply System Velocity: Entity 1', position); + logPosition("Apply System Velocity: Entity 1", position); expect(position.x.toNumber()).to.greaterThan(1); expect(position.y.toNumber()).to.equal(1); expect(position.z.toNumber()).to.equal(300); }); - it('Apply Fly System on Entity 4', async () => { + it("Apply Fly System on Entity 4", async () => { const applySystem = await ApplySystem({ authority: provider.wallet.publicKey, systemId: exampleSystemFly, @@ -484,18 +484,18 @@ describe('bolt', () => { await provider.sendAndConfirm(applySystem.transaction); const position = await exampleComponentPosition.account.position.fetch( - componentPositionEntity4Pda, + componentPositionEntity4Pda ); - logPosition('Fly System: Entity 4', position); + logPosition("Fly System: Entity 4", position); expect(position.x.toNumber()).to.equal(0); expect(position.y.toNumber()).to.equal(0); expect(position.z.toNumber()).to.equal(1); }); - it('Apply Fly System on Entity 5 (should fail with wrong authority)', async () => { + it("Apply Fly System on Entity 5 (should fail with wrong authority)", async () => { const positionBefore = await exampleComponentPosition.account.position.fetch( - componentPositionEntity5Pda, + componentPositionEntity5Pda ); const applySystem = await ApplySystem({ @@ -516,12 +516,12 @@ describe('bolt', () => { } catch (error) { failed = true; // console.log("error", error); - expect(error.logs.join('\n')).to.contain('Error Code: InvalidAuthority'); + expect(error.logs.join("\n")).to.contain("Error Code: InvalidAuthority"); } expect(failed).to.equal(true); const positionAfter = await exampleComponentPosition.account.position.fetch( - componentPositionEntity5Pda, + componentPositionEntity5Pda ); expect(positionBefore.x.toNumber()).to.equal(positionAfter.x.toNumber()); @@ -529,7 +529,7 @@ describe('bolt', () => { expect(positionBefore.z.toNumber()).to.equal(positionAfter.z.toNumber()); }); - it('Whitelist System', async () => { + it("Whitelist System", async () => { const approveSystem = await ApproveSystem({ authority: provider.wallet.publicKey, systemToApprove: exampleSystemFly, @@ -539,7 +539,7 @@ describe('bolt', () => { const signature = await provider.sendAndConfirm( approveSystem.transaction, [], - { skipPreflight: true }, + { skipPreflight: true } ); console.log(`Whitelist 2 system approval signature: ${signature}`); @@ -549,7 +549,7 @@ describe('bolt', () => { expect(worldAccount.systems.length).to.be.greaterThan(0); }); - it('Whitelist System 2', async () => { + it("Whitelist System 2", async () => { const approveSystem = await ApproveSystem({ authority: provider.wallet.publicKey, systemToApprove: exampleSystemApplyVelocity, @@ -559,7 +559,7 @@ describe('bolt', () => { const signature = await provider.sendAndConfirm( approveSystem.transaction, [], - { skipPreflight: true }, + { skipPreflight: true } ); console.log(`Whitelist 2 system approval signature: ${signature}`); @@ -569,7 +569,7 @@ describe('bolt', () => { expect(worldAccount.systems.length).to.be.greaterThan(0); }); - it('Apply Fly System on Entity 1', async () => { + it("Apply Fly System on Entity 1", async () => { const applySystem = await ApplySystem({ authority: provider.wallet.publicKey, systemId: exampleSystemFly, @@ -584,7 +584,7 @@ describe('bolt', () => { await provider.sendAndConfirm(applySystem.transaction); }); - it('Remove System 1', async () => { + it("Remove System 1", async () => { const approveSystem = await RemoveSystem({ authority: provider.wallet.publicKey, systemToRemove: exampleSystemFly, @@ -594,7 +594,7 @@ describe('bolt', () => { const signature = await provider.sendAndConfirm( approveSystem.transaction, [], - { skipPreflight: true }, + { skipPreflight: true } ); console.log(`Whitelist 2 system approval signature: ${signature}`); @@ -604,7 +604,7 @@ describe('bolt', () => { expect(worldAccount.systems.length).to.be.greaterThan(0); }); - it('Apply Invalid Fly System on Entity 1', async () => { + it("Apply Invalid Fly System on Entity 1", async () => { const applySystem = await ApplySystem({ authority: provider.wallet.publicKey, systemId: exampleSystemFly, @@ -620,13 +620,13 @@ describe('bolt', () => { try { await provider.sendAndConfirm(applySystem.transaction); } catch (error) { - expect(error.logs.join(' ')).to.contain('Error Code: SystemNotApproved'); + expect(error.logs.join(" ")).to.contain("Error Code: SystemNotApproved"); invalid = true; } expect(invalid).to.equal(true); }); - it('Check invalid component init without CPI', async () => { + it("Check invalid component init without CPI", async () => { let invalid = false; try { await exampleComponentPosition.methods @@ -640,17 +640,17 @@ describe('bolt', () => { .rpc(); } catch (error) { // console.log("error", error); - expect(error.message).to.contain('Error Code: InvalidCaller'); + expect(error.message).to.contain("Error Code: InvalidCaller"); invalid = true; } expect(invalid).to.equal(true); }); - it('Check invalid component update without CPI', async () => { + it("Check invalid component update without CPI", async () => { let invalid = false; try { await boltComponentProgram.methods - .update(Buffer.from('')) + .update(Buffer.from("")) .accounts({ boltComponent: componentPositionEntity4Pda, authority: provider.wallet.publicKey, @@ -659,14 +659,14 @@ describe('bolt', () => { } catch (error) { // console.log("error", error); expect(error.message).to.contain( - 'bolt_component. Error Code: AccountOwnedByWrongProgram', + "bolt_component. Error Code: AccountOwnedByWrongProgram" ); invalid = true; } expect(invalid).to.equal(true); }); - it('Check component delegation', async () => { + it("Check component delegation", async () => { const delegateComponent = await DelegateComponent({ payer: provider.wallet.publicKey, entity: entity1Pda, @@ -676,12 +676,12 @@ describe('bolt', () => { const txSign = await provider.sendAndConfirm( delegateComponent.transaction, [], - { skipPreflight: true, commitment: 'confirmed' }, + { skipPreflight: true, commitment: "confirmed" } ); console.log(`Delegation signature: ${txSign}`); const acc = await provider.connection.getAccountInfo( - delegateComponent.componentPda, + delegateComponent.componentPda ); - expect(acc.owner.toString()).to.equal(DELEGATION_PROGRAM_ID); + expect(acc?.owner.toString()).to.equal(DELEGATION_PROGRAM_ID); }); }); diff --git a/tsconfig.json b/tsconfig.json index 5faac89..a894721 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -11,6 +11,7 @@ "es2015" ], "module": "commonjs", + "strictNullChecks": true, "target": "es6", "esModuleInterop": true }