diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 0360f436..039c1b31 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -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: | diff --git a/.gitignore b/.gitignore index d39871ee..fe5f5cad 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ docs .DS_Store # Local Netlify folder .netlify +lerna-debug.log diff --git a/examples/example-nodejs-bot/README.md b/examples/example-nodejs-bot/README.md index 7891e39e..f7ee1060 100644 --- a/examples/example-nodejs-bot/README.md +++ b/examples/example-nodejs-bot/README.md @@ -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. --- diff --git a/examples/example-vite-kitchen-sink/README.md b/examples/example-vite-kitchen-sink/README.md index 5c42e91e..ecb1afa2 100644 --- a/examples/example-vite-kitchen-sink/README.md +++ b/examples/example-vite-kitchen-sink/README.md @@ -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. diff --git a/examples/example-vite-react-sdk/README.md b/examples/example-vite-react-sdk/README.md index b6897e3f..44f2acc0 100644 --- a/examples/example-vite-react-sdk/README.md +++ b/examples/example-vite-react-sdk/README.md @@ -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({ @@ -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 diff --git a/examples/example-vite-svelte-recs/README.md b/examples/example-vite-svelte-recs/README.md index ae45eaee..a45e2a0b 100644 --- a/examples/example-vite-svelte-recs/README.md +++ b/examples/example-vite-svelte-recs/README.md @@ -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. diff --git a/package.json b/package.json index 15238768..c75d4278 100644 --- a/package.json +++ b/package.json @@ -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" diff --git a/packages/create-burner/readme.md b/packages/create-burner/readme.md index 7430a963..c3735a1a 100644 --- a/packages/create-burner/readme.md +++ b/packages/create-burner/readme.md @@ -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 @@ -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 @@ -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 diff --git a/packages/sdk/src/index.ts b/packages/sdk/src/index.ts index a41e6a0d..1bb2c3e1 100644 --- a/packages/sdk/src/index.ts +++ b/packages/sdk/src/index.ts @@ -198,5 +198,53 @@ export async function init( 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 + ); + }, + + /** + * 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} + */ + updateTokenBalanceSubscription: async ( + subscription: torii.Subscription, + contract_addresses: string[], + account_addresses: string[] + ): Promise => { + return await client.updateTokenBalanceSubscription( + subscription, + contract_addresses, + account_addresses + ); + }, }; } diff --git a/packages/sdk/src/types.ts b/packages/sdk/src/types.ts index 3ddda2b7..9c773025 100644 --- a/packages/sdk/src/types.ts +++ b/packages/sdk/src/types.ts @@ -321,6 +321,42 @@ export interface SDK { account_addresses: string[], contract_addresses: string[] ): Promise; + + /** + * 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; + + /** + * 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} + */ + updateTokenBalanceSubscription: ( + subscription: torii.Subscription, + contract_addresses: string[], + account_addresses: string[] + ) => Promise; } /** diff --git a/worlds/onchain-dash b/worlds/onchain-dash index a1fea339..0581aa9e 160000 --- a/worlds/onchain-dash +++ b/worlds/onchain-dash @@ -1 +1 @@ -Subproject commit a1fea339a3093050ce6a15f85e04540b7b698b09 +Subproject commit 0581aa9e01d81fc9cda36407e5a9ba85061b4d58