Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
b3hr4d committed Dec 5, 2023
0 parents commit 77b222e
Show file tree
Hide file tree
Showing 110 changed files with 18,372 additions and 0 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Node.js CI

on:
push:
branches: ["main"]
pull_request:
branches: ["main"]

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [18.x, 20.x]

steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "DIR=$(yarn cache dir)" >> $GITHUB_ENV
- uses: actions/cache@v3
id: yarn-cache
with:
path: |
node_modules
${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install Dependencies
if: matrix.node-version != '14.x'
run: yarn install

- run: yarn build
- run: yarn test
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# node
node_modules
.DS_Store

# build
lib
dist
.env
.dfx
.yarn
lerna-debug.log
yarn-error.log
8 changes: 8 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
The MIT License (MIT)
Copyright © 2023 B3Pay

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
78 changes: 78 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Re-Actor

## Introduction

Re-actor is a TypeScript library designed to simplify interactions between your frontend application and canisters on the Internet Computer. Leveraging the power of the `zustand` state management library and strong typing, Re-actor aims to make your development process smoother and more efficient.

## Installation

To install Re-actor, run the following command:

```bash
npm install @ic-reactor/core
```

## Features

- **Strong Typing**: Ensures type safety between your frontend and canister.
- **State Management**: Built-in state management using `zustand`.
- **Easy to Use**: Simplified API for quick integration into your projects.
- **Flexible**: Compatible with both React and non-React projects.

## Usage

Here's a simple example to get you started:

```jsx
import createReActor from "@ic-reactor/core"
import { canisterId, createActor } from "declaration/actor"

const { ReActorProvider, useActorMethod } = createReActor(() =>
createActor(canisterId)
)

const Balance = () => {
const { call, data, error, loading } = useActorMethod("get_balance")

return (
<div>
<button onClick={() => call()}>Fetch Balance</button>
{loading && <p>Loading...</p>}
{data && <p>Balance: {data}</p>}
{error && <p>Error: {error}</p>}
</div>
)
}

const App = () => (
<ReActorProvider>
<Balance />
</ReActorProvider>
)
```

For more detailed examples, check the [`examples`](./examples) directory.

## API Reference

### `useActorMethod`

This hook allows you to call a method from your canister and manage its state.

```typescript
const { call, data, error, loading } = useActorMethod("methodName")
```

- `call`: A function that calls the canister method.
- `data`: The data returned from the canister method.
- `error`: Any error that occurred while calling the canister method.
- `types`: The candid types of the canister method.
- `loading`: A boolean indicating whether the data is being fetched.

## Examples

For more complex examples, refer to the [`examples`](./examples) directory.

## License

This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details.
24 changes: 24 additions & 0 deletions e2e/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Various IDEs and Editors
.vscode/
.idea/
**/*~

# Mac OSX temporary files
.DS_Store
**/.DS_Store

# dfx temporary files
.dfx/

# generated files
declarations/

# rust
target/

# frontend code
node_modules/
dist/

# environment variables
.env
Loading

0 comments on commit 77b222e

Please sign in to comment.