Skip to content

feat: bump dojo v1.0.9 #363

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,15 @@ jobs:
run: git submodule update --init --recursive

- run: curl -L https://install.dojoengine.org | bash
- run: /home/runner/.config/.dojo/bin/dojoup -v v1.0.8
- run: /home/runner/.config/.dojo/bin/dojoup -v v1.0.9
- run: |
cd worlds/dojo-starter
/home/runner/.config/.dojo/bin/sozo build
/home/runner/.config/.dojo/bin/sozo test
- run: |
cd worlds/onchain-dash
/home/runner/.config/.dojo/bin/sozo build
/home/runner/.config/.dojo/bin/sozo test

- name: "Setup npm"
run: |
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ docs
.DS_Store
# Local Netlify folder
.netlify
lerna-debug.log
8 changes: 4 additions & 4 deletions examples/example-nodejs-bot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ A Discord bot for interacting with your Dojo world via Torii.

Features:

- Poll a Torii for information.
- Expose a slash command for reading Torii state.
- Easy to extend with new commands.
- GraphQL codegen for Torii models.
- Poll a Torii for information.
- Expose a slash command for reading Torii state.
- Easy to extend with new commands.
- GraphQL codegen for Torii models.

---

Expand Down
4 changes: 2 additions & 2 deletions examples/example-vite-kitchen-sink/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,5 @@ sozo migrate apply

### Notes

- you main want to update `actions` contract address in `src/components/caller-counter.tsx` & `src/components/global-counter.tsx` which is hardcoded in those files.
- if you want to have braavos & argent wallet working, you need to deploy classes and deploy your wallet manually.
- you main want to update `actions` contract address in `src/components/caller-counter.tsx` & `src/components/global-counter.tsx` which is hardcoded in those files.
- if you want to have braavos & argent wallet working, you need to deploy classes and deploy your wallet manually.
12 changes: 6 additions & 6 deletions examples/example-vite-react-sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ This template provides a minimal setup to get React working in Vite with HMR and

Currently, two official plugins are available:

- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh

## Expanding the ESLint configuration

If you are developing a production application, we recommend updating the configuration to enable type aware lint rules:

- Configure the top-level `parserOptions` property like this:
- Configure the top-level `parserOptions` property like this:

```js
export default tseslint.config({
Expand All @@ -25,9 +25,9 @@ export default tseslint.config({
});
```

- Replace `tseslint.configs.recommended` to `tseslint.configs.recommendedTypeChecked` or `tseslint.configs.strictTypeChecked`
- Optionally add `...tseslint.configs.stylisticTypeChecked`
- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and update the config:
- Replace `tseslint.configs.recommended` to `tseslint.configs.recommendedTypeChecked` or `tseslint.configs.strictTypeChecked`
- Optionally add `...tseslint.configs.stylisticTypeChecked`
- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and update the config:

```js
// eslint.config.js
Expand Down
4 changes: 2 additions & 2 deletions examples/example-vite-svelte-recs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ Check out [SvelteKit](https://github.com/sveltejs/kit#readme), which is also pow

**Why use this over SvelteKit?**

- It brings its own routing solution which might not be preferable for some users.
- It is first and foremost a framework that just happens to use Vite under the hood, not a Vite app.
- It brings its own routing solution which might not be preferable for some users.
- It is first and foremost a framework that just happens to use Vite under the hood, not a Vite app.

This template contains as little as possible to get started with Vite + TypeScript + Svelte, while taking into account the developer experience with regards to HMR and intellisense. It demonstrates capabilities on par with the other `create-vite` templates and is a good starting point for beginners dipping their toes into a Vite + Svelte project.

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"build": "bash ./scripts/build-packages.sh",
"build-examples": "bash ./scripts/build-examples.sh",
"clean": "bash ./scripts/clean.sh",
"prettier-check": "npx prettier --check {packages,examples}",
"prettier": "npx prettier --write {packages,examples}",
"prettier-check": "pnpx prettier --check {packages,examples}",
"prettier": "pnpx prettier --write {packages,examples}",
"release": "pnpm build && pnpm prettier && npx lerna publish --no-private --force-publish",
"docs": "npx typedoc --out docs",
"prepare": "husky install"
Expand Down
62 changes: 31 additions & 31 deletions packages/create-burner/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,20 @@ Easily manage, create, and interact with burner accounts on Starknets using this

## Features:

- Initialize and manage burner accounts.
- Abstracts away intricacies related to creating, fetching, and setting active burner accounts.
- Easily integrate with React apps using the provided hook.
- Vanilla JS support.
- Initialize and manage burner accounts.
- Abstracts away intricacies related to creating, fetching, and setting active burner accounts.
- Easily integrate with React apps using the provided hook.
- Vanilla JS support.

## Table of Contents

- [Installation](#installation)
- [Usage](#usage)
- [With React](#with-react)
- [Vanilla JavaScript](#vanilla-javascript)
- [API](#api)
- [Contribute](#contribute)
- [License](#license)
- [Installation](#installation)
- [Usage](#usage)
- [With React](#with-react)
- [Vanilla JavaScript](#vanilla-javascript)
- [API](#api)
- [Contribute](#contribute)
- [License](#license)

## Installation

Expand All @@ -58,7 +58,7 @@ yarn add @dojoengine/create-burner starknet

### In the wild:

- [dojo-starter-react-app](https://github.com/dojoengine/dojo-starter-react-app)
- [dojo-starter-react-app](https://github.com/dojoengine/dojo-starter-react-app)

## Usage

Expand Down Expand Up @@ -90,25 +90,25 @@ const activeAccount = manager.getActiveAccount();

## API

- **useBurner**: A React hook that provides functionalities like creating burners, selecting them, and more.

- `get(address: string)`: Get a burner account based on its address.
- `list()`: List all burners.
- `select(address: string)`: Set a burner as the active account.
- `create()`: Create a new burner.
- `account`: The active burner account.
- `isDeploying`: A boolean that indicates whether a burner is being deployed.
- `listConnectors()`: List all available connectors that can be used with Starknet React.

- **BurnerManager**: A class for vanilla JS that offers methods to manage burner accounts.
- `init()`: Initializes the manager.
- `getActiveAccount()`: Retrieves the active burner account.
- `get(address: string)`: Get a burner account based on its address.
- `list()`: List all burners.
- `select(address: string)`: Set a burner as the active account.
- `create()`: Create a new burner.
- `account`: The active burner account.
- `isDeploying`: A boolean that indicates whether a burner is being deployed.
- **useBurner**: A React hook that provides functionalities like creating burners, selecting them, and more.

- `get(address: string)`: Get a burner account based on its address.
- `list()`: List all burners.
- `select(address: string)`: Set a burner as the active account.
- `create()`: Create a new burner.
- `account`: The active burner account.
- `isDeploying`: A boolean that indicates whether a burner is being deployed.
- `listConnectors()`: List all available connectors that can be used with Starknet React.

- **BurnerManager**: A class for vanilla JS that offers methods to manage burner accounts.
- `init()`: Initializes the manager.
- `getActiveAccount()`: Retrieves the active burner account.
- `get(address: string)`: Get a burner account based on its address.
- `list()`: List all burners.
- `select(address: string)`: Set a burner as the active account.
- `create()`: Create a new burner.
- `account`: The active burner account.
- `isDeploying`: A boolean that indicates whether a burner is being deployed.

## Contribute

Expand Down
48 changes: 48 additions & 0 deletions packages/sdk/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,5 +198,53 @@ export async function init<T extends SchemaType>(
contract_addresses
);
},

/**
* Subscribes to token balance updates
*
* # Parameters
* @param {string[]} contract_addresses - Array of contract addresses to filter (empty for all)
* @param {string[]} account_addresses - Array of account addresses to filter (empty for all)
* @param {Funtion} callback - JavaScript function to call on updates
*
* # Returns
* Result containing subscription handle or error
* @returns torii.Subscription
*/
onTokenBalanceUpdated: (
contract_addresses: string[],
account_addresses: string[],
callback: Function
): torii.Subscription => {
return client.onTokenBalanceUpdated(
contract_addresses,
account_addresses,
callback
);
},
Comment on lines +214 to +224
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Improve type safety of the callback parameter

The Function type is too broad and can lead to runtime errors. Define a specific callback signature for better type safety.

Apply this diff:

-callback: Function
+callback: (balance: torii.TokenBalance) => void
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
onTokenBalanceUpdated: (
contract_addresses: string[],
account_addresses: string[],
callback: Function
): torii.Subscription => {
return client.onTokenBalanceUpdated(
contract_addresses,
account_addresses,
callback
);
},
onTokenBalanceUpdated: (
contract_addresses: string[],
account_addresses: string[],
callback: (balance: torii.TokenBalance) => void
): torii.Subscription => {
return client.onTokenBalanceUpdated(
contract_addresses,
account_addresses,
callback
);
},
🧰 Tools
🪛 Biome (1.9.4)

[error] 217-217: Don't use 'Function' as a type.

Prefer explicitly define the function shape. This type accepts any function-like value, which can be a common source of bugs.

(lint/complexity/noBannedTypes)


/**
* Updates an existing token balance subscription
*
* # Parameters
* @param {torii.Subscription} subscription - Existing subscription to update
* @param {string[]} contract_addresses - New array of contract addresses to filter
* @param {string[]} account_addresses - New array of account addresses to filter
*
* # Returns
* Result containing unit or error
* @returns {Promise<void>}
*/
updateTokenBalanceSubscription: async (
subscription: torii.Subscription,
contract_addresses: string[],
account_addresses: string[]
): Promise<void> => {
return await client.updateTokenBalanceSubscription(
subscription,
contract_addresses,
account_addresses
);
},
};
}
36 changes: 36 additions & 0 deletions packages/sdk/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,42 @@ export interface SDK<T extends SchemaType> {
account_addresses: string[],
contract_addresses: string[]
): Promise<torii.TokenBalances>;

/**
* Subscribes to token balance updates
*
* # Parameters
* @param {string[]} contract_addresses - Array of contract addresses to filter (empty for all)
* @param {string[]} account_addresses - Array of account addresses to filter (empty for all)
* @param {Funtion} callback - JavaScript function to call on updates
*
* # Returns
* Result containing subscription handle or error
* @returns torii.Subscription
*/
onTokenBalanceUpdated: (
contract_addresses: string[],
account_addresses: string[],
callback: Function
) => torii.Subscription;
Comment on lines +337 to +341
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Improve type safety of the callback parameter in interface

The Function type should be replaced with a specific callback signature for better type safety, matching the implementation.

Apply this diff:

-callback: Function
+callback: (balance: torii.TokenBalance) => void
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
onTokenBalanceUpdated: (
contract_addresses: string[],
account_addresses: string[],
callback: Function
) => torii.Subscription;
onTokenBalanceUpdated: (
contract_addresses: string[],
account_addresses: string[],
callback: (balance: torii.TokenBalance) => void
) => torii.Subscription;
🧰 Tools
🪛 Biome (1.9.4)

[error] 340-340: Don't use 'Function' as a type.

Prefer explicitly define the function shape. This type accepts any function-like value, which can be a common source of bugs.

(lint/complexity/noBannedTypes)


/**
* Updates an existing token balance subscription
*
* # Parameters
* @param {torii.Subscription} subscription - Existing subscription to update
* @param {string[]} contract_addresses - New array of contract addresses to filter
* @param {string[]} account_addresses - New array of account addresses to filter
*
* # Returns
* Result containing unit or error
* @returns {Promise<void>}
*/
updateTokenBalanceSubscription: (
subscription: torii.Subscription,
contract_addresses: string[],
account_addresses: string[]
) => Promise<void>;
}

/**
Expand Down
Loading