Skip to content

Commit

Permalink
feat: Update bolt ApplySystem snippet (#6)
Browse files Browse the repository at this point in the history
# 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:
magicblock-labs/bolt#51
  • Loading branch information
crypto-vincent authored Jun 17, 2024
1 parent a368391 commit d2d063b
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 15 deletions.
18 changes: 18 additions & 0 deletions .markdownlint.json
Original file line number Diff line number Diff line change
@@ -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"
]
}
}
3 changes: 2 additions & 1 deletion BOLT/Introduction/introduction.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
12 changes: 7 additions & 5 deletions BOLT/getting_started/installation.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: "Setup/installation"
title: "Setup / Installation"
description: "Setup your environment and install BOLT"
---

Expand Down Expand Up @@ -34,16 +34,18 @@ We recommend reading chapters 1-4 of the [Anchor book](https://book.anchor-lang.

Install BOLT

```bash
<CodeGroup>

```bash NPM
npm install -g @magicblock-labs/bolt-cli
```

or

```bash
```bash Yarn
yarn global add @magicblock-labs/bolt-cli
```

</CodeGroup>

Verify the installation

```bash
Expand Down
15 changes: 8 additions & 7 deletions BOLT/getting_started/world_program.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
```
2 changes: 1 addition & 1 deletion EphemeralRollups/ephemeral_rollups.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ The ephemeral rollup operates as a specialized SVM runtime to facilitate transac

## White Paper

<img height="200" src="/images/ER_diagram.png" />
<img height="200" alt="Ephemeral rollups diagram" src="/images/ER_diagram.png" />

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).

Expand Down
2 changes: 1 addition & 1 deletion Onboarding/Session Keys/how-do-session-keys-work.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Session Keys work in tandem with our on chain program to validate the token and

## **How do they work?**

<img height="200" src="/images/how_session_keys_work.png" />
<img height="200" alt="Session keys lifecycle" src="/images/how_session_keys_work.png" />

- 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.
Expand Down

0 comments on commit d2d063b

Please sign in to comment.