Skip to content

Commit

Permalink
✨ Bolt Typescript SDK (magicblock-labs#1)
Browse files Browse the repository at this point in the history
* ✨ Bolt Typescript SDK

* ♻️ Code Refactoring

* ✨ Add Pdas derivation

* ♻️ Code Refactoring

* ♻️ Code Refactoring
  • Loading branch information
GabrielePicco authored Dec 15, 2023
1 parent 8a39a53 commit 873d5ba
Show file tree
Hide file tree
Showing 88 changed files with 13,938 additions and 28 deletions.
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
clients/bolt-sdk/idl/world.ts
.anchor
target
24 changes: 24 additions & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
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"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
target
**/*.rs.bk
node_modules
clients/sdk/node_modules
test-ledger
.yarn
**/test-ledger
Expand Down
2 changes: 2 additions & 0 deletions clients/bolt-sdk/.crates/.crates.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[v1]
"anchor-cli 0.29.0 (registry+https://github.com/rust-lang/crates.io-index)" = ["anchor"]
1 change: 1 addition & 0 deletions clients/bolt-sdk/.crates/.crates2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"installs":{"anchor-cli 0.29.0 (registry+https://github.com/rust-lang/crates.io-index)":{"version_req":"0.29.0","bins":["anchor"],"features":[],"all_features":false,"no_default_features":false,"profile":"release","target":"aarch64-apple-darwin","rustc":"rustc 1.73.0 (cc66ad468 2023-10-03)\nbinary: rustc\ncommit-hash: cc66ad468955717ab92600c770da8c1601a4ff33\ncommit-date: 2023-10-03\nhost: aarch64-apple-darwin\nrelease: 1.73.0\nLLVM version: 17.0.2\n"}}}
Binary file added clients/bolt-sdk/.crates/bin/anchor
Binary file not shown.
15 changes: 15 additions & 0 deletions clients/bolt-sdk/.solitarc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
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",
idlDir,
sdkDir,
binaryInstallDir,
programDir,
};
21 changes: 21 additions & 0 deletions clients/bolt-sdk/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# BOLT SDK

This Typescript sdk provides a convenient interface and methods for interacting with bolt.

## Installation

To install the bolt sdk, run the following command:

```bash
npm install bolt-sdk
```

## Contributing

The community is encouraged to contribute to the Soar SDK.

Fixes and features are always welcome! Please feel free to submit a PR for review.

### Tests.

Test files are located in `client/tests/*`. To run the tests, enter `anchor test` from the root directory of the repository.
273 changes: 273 additions & 0 deletions clients/bolt-sdk/idl/world.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,273 @@
{
"version": "0.0.1",
"name": "world",
"instructions": [
{
"name": "initializeRegistry",
"accounts": [
{
"name": "registry",
"isMut": true,
"isSigner": false
},
{
"name": "payer",
"isMut": true,
"isSigner": true
},
{
"name": "systemProgram",
"isMut": false,
"isSigner": false
}
],
"args": []
},
{
"name": "initializeNewWorld",
"accounts": [
{
"name": "payer",
"isMut": true,
"isSigner": true
},
{
"name": "world",
"isMut": true,
"isSigner": false
},
{
"name": "registry",
"isMut": true,
"isSigner": false
},
{
"name": "systemProgram",
"isMut": false,
"isSigner": false
}
],
"args": []
},
{
"name": "addEntity",
"accounts": [
{
"name": "payer",
"isMut": true,
"isSigner": true
},
{
"name": "entity",
"isMut": true,
"isSigner": false
},
{
"name": "world",
"isMut": true,
"isSigner": false
},
{
"name": "systemProgram",
"isMut": false,
"isSigner": false
}
],
"args": [
{
"name": "extraSeed",
"type": {
"option": "string"
}
}
]
},
{
"name": "initializeComponent",
"accounts": [
{
"name": "payer",
"isMut": true,
"isSigner": true
},
{
"name": "data",
"isMut": true,
"isSigner": false
},
{
"name": "entity",
"isMut": false,
"isSigner": false
},
{
"name": "componentProgram",
"isMut": false,
"isSigner": false
},
{
"name": "systemProgram",
"isMut": false,
"isSigner": false
}
],
"args": []
},
{
"name": "apply",
"accounts": [
{
"name": "componentProgram",
"isMut": false,
"isSigner": false
},
{
"name": "boltSystem",
"isMut": false,
"isSigner": false
},
{
"name": "boltComponent",
"isMut": true,
"isSigner": false
}
],
"args": [
{
"name": "args",
"type": "bytes"
}
]
},
{
"name": "apply2",
"accounts": [
{
"name": "boltSystem",
"isMut": false,
"isSigner": false
},
{
"name": "componentProgram1",
"isMut": false,
"isSigner": false
},
{
"name": "boltComponent1",
"isMut": true,
"isSigner": false
},
{
"name": "componentProgram2",
"isMut": false,
"isSigner": false
},
{
"name": "boltComponent2",
"isMut": true,
"isSigner": false
}
],
"args": [
{
"name": "args",
"type": "bytes"
}
]
},
{
"name": "apply3",
"accounts": [
{
"name": "boltSystem",
"isMut": false,
"isSigner": false
},
{
"name": "componentProgram1",
"isMut": false,
"isSigner": false
},
{
"name": "boltComponent1",
"isMut": true,
"isSigner": false
},
{
"name": "componentProgram2",
"isMut": false,
"isSigner": false
},
{
"name": "boltComponent2",
"isMut": true,
"isSigner": false
},
{
"name": "componentProgram3",
"isMut": false,
"isSigner": false
},
{
"name": "boltComponent3",
"isMut": true,
"isSigner": false
}
],
"args": [
{
"name": "args",
"type": "bytes"
}
]
}
],
"accounts": [
{
"name": "Registry",
"type": {
"kind": "struct",
"fields": [
{
"name": "worlds",
"type": "u64"
}
]
}
},
{
"name": "World",
"type": {
"kind": "struct",
"fields": [
{
"name": "id",
"type": "u64"
},
{
"name": "entities",
"type": "u64"
}
]
}
},
{
"name": "Entity",
"type": {
"kind": "struct",
"fields": [
{
"name": "id",
"type": "u64"
}
]
}
}
],
"metadata": {
"address": "WorLD15A7CrDwLcLy4fRqtaTb9fbd8o8iqiEMUDse2n",
"origin": "anchor",
"binaryVersion": "0.29.0",
"libVersion": "0.29.0"
}
}
Loading

0 comments on commit 873d5ba

Please sign in to comment.