From d2d063bbb52ad0c573fe2ee20a0c19cc54705dad Mon Sep 17 00:00:00 2001 From: crypto-vincent Date: Mon, 17 Jun 2024 14:24:44 +0100 Subject: [PATCH] feat: Update bolt ApplySystem snippet (#6) # Summary `ApplySystem` typescript API has changed, we update the docs to match that. # Details `ApplySystem` can now take an array of entities instead of a single entity as parameter. Also removed the use of `entityId`. Also mention we can read the state from the `componentPda`. # Notes Matching PR for `bolt-sdk` change: https://github.com/magicblock-labs/bolt/pull/51 --- .markdownlint.json | 18 ++++++++++++++++++ BOLT/Introduction/introduction.mdx | 3 ++- BOLT/getting_started/installation.mdx | 12 +++++++----- BOLT/getting_started/world_program.mdx | 15 ++++++++------- EphemeralRollups/ephemeral_rollups.mdx | 2 +- .../Session Keys/how-do-session-keys-work.mdx | 2 +- 6 files changed, 37 insertions(+), 15 deletions(-) create mode 100644 .markdownlint.json diff --git a/.markdownlint.json b/.markdownlint.json new file mode 100644 index 0000000..b403d92 --- /dev/null +++ b/.markdownlint.json @@ -0,0 +1,18 @@ +{ + "heading-style": { + "style": "atx" + }, + "ul-indent": { + "indent": 2 + }, + "line-length": { + "line_length": 200, + "strict": true + }, + "no-inline-html": { + "allowed_elements": [ + "CodeGroup", + "img" + ] + } +} \ No newline at end of file diff --git a/BOLT/Introduction/introduction.mdx b/BOLT/Introduction/introduction.mdx index f2d8c91..654f51f 100644 --- a/BOLT/Introduction/introduction.mdx +++ b/BOLT/Introduction/introduction.mdx @@ -24,7 +24,8 @@ description: "Building your game logic onchain" ## Game state & logic -To build a game onchain, you'll need to familiarize with Solana programs (smart contracts). You might be already familiar with [Anchor](https://www.anchor-lang.com/), one of the most used toolkit for writing smart contract on Solana. +To build a game onchain, you'll need to familiarize with Solana programs (smart contracts). +You might be already familiar with [Anchor](https://www.anchor-lang.com/), one of the most used toolkit for writing smart contract on Solana. BOLT is a framework that **extends Anchor functionalities** to include a standardized way to model your game's logic using an Entity Components Systems (ECS) pattern. diff --git a/BOLT/getting_started/installation.mdx b/BOLT/getting_started/installation.mdx index 6005b86..348b511 100644 --- a/BOLT/getting_started/installation.mdx +++ b/BOLT/getting_started/installation.mdx @@ -1,5 +1,5 @@ --- -title: "Setup/installation" +title: "Setup / Installation" description: "Setup your environment and install BOLT" --- @@ -34,16 +34,18 @@ We recommend reading chapters 1-4 of the [Anchor book](https://book.anchor-lang. Install BOLT -```bash + + +```bash NPM npm install -g @magicblock-labs/bolt-cli ``` -or - -```bash +```bash Yarn yarn global add @magicblock-labs/bolt-cli ``` + + Verify the installation ```bash diff --git a/BOLT/getting_started/world_program.mdx b/BOLT/getting_started/world_program.mdx index bebad37..fcad07a 100644 --- a/BOLT/getting_started/world_program.mdx +++ b/BOLT/getting_started/world_program.mdx @@ -53,14 +53,13 @@ const entityPda = addEntity.entityPda; // we can use this later For attaching components: ```typescript -const inititializeComponent = await InitializeComponent({ +const initializeComponent = await InitializeComponent({ payer: provider.wallet.publicKey, entity: entityPda, componentId: positionComponent.programId, }); -const signature = await provider.sendAndConfirm( - inititializeComponent.transaction -); +const signature = await provider.sendAndConfirm(initializeComponent.transaction); +const componentPda = initializeComponent.componentPda; // We can use this to fetch the state ``` ## Applying Systems @@ -70,9 +69,11 @@ To apply a system: ```typescript const applySystem = await ApplySystem({ authority: provider.wallet.publicKey, - system: systemMovement.programId, - entity: entityPda, - components: [positionComponent.programId], + systemId: systemMovement.programId, + entities: [{ + entity: entityPda, + components: [{ componentId: positionComponent.programId }], + }] }); const signature = await provider.sendAndConfirm(applySystem.transaction); ``` diff --git a/EphemeralRollups/ephemeral_rollups.mdx b/EphemeralRollups/ephemeral_rollups.mdx index 2086372..72823f5 100644 --- a/EphemeralRollups/ephemeral_rollups.mdx +++ b/EphemeralRollups/ephemeral_rollups.mdx @@ -11,7 +11,7 @@ The ephemeral rollup operates as a specialized SVM runtime to facilitate transac ## White Paper - +Ephemeral rollups diagram Bolt white paper describes in details the architecture and the scalability solution. We recommend reading the basic concepts of ephemeral rollups in section 2.2 of the Bolt [Whitepaper](https://arxiv.org/abs/2311.02650). diff --git a/Onboarding/Session Keys/how-do-session-keys-work.mdx b/Onboarding/Session Keys/how-do-session-keys-work.mdx index b82663d..ddff916 100644 --- a/Onboarding/Session Keys/how-do-session-keys-work.mdx +++ b/Onboarding/Session Keys/how-do-session-keys-work.mdx @@ -14,7 +14,7 @@ Session Keys work in tandem with our on chain program to validate the token and ## **How do they work?** - +Session keys lifecycle - Ephemeral Keys are stored on the client side, to invoke transactions. - The transactions invoked by these ephemeral keys are validated in the target program for their validity, expiry and scope.