Skip to content

Commit

Permalink
docs: add abis docs
Browse files Browse the repository at this point in the history
  • Loading branch information
wfnuser committed Jun 26, 2024
1 parent 1dadc26 commit bd8b622
Show file tree
Hide file tree
Showing 3 changed files with 159 additions and 2 deletions.
12 changes: 11 additions & 1 deletion docs/.vitepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,17 @@ module.exports = {
{
text: "Vision",
link: "/introduction/vision",
}
},
],
},
{
text: "Contract",
items: [
// TODO: Add explain for GST rules.
{
text: "GST Contract ABI",
link: "/contract/abi",
},
],
},
{
Expand Down
146 changes: 146 additions & 0 deletions docs/contract/abi.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@

# GST Contract ABI

This document provides detailed information about the ABI of the Bet smart contract. The contract facilitates goal-driven staking, offering two types of goals: Solo and Gambling. Users can create goals, stake tokens, confirm task completions, claim rewards, and settle goals.


## Read Functions

### 1. `getAllGoals()`

- **Description**: Returns information about all goals.
- **Returns**: `GoalInfo[]` - An array of goal information objects.

```solidity
function getAllGoals() public view returns (GoalInfo[] memory)
```

### 2. `getUserGoals(address _user)`

- **Description**: Returns the IDs of goals that a user is participating in.
- **Parameters**:
- `_user` (address): The address of the user.
- **Returns**: `uint[]` - An array of goal IDs.

```solidity
function getUserGoals(address _user) public view returns (uint[] memory)
```

### 3. `getGoalDetails(uint _goalId)`

- **Description**: Returns detailed information about a specific goal.
- **Parameters**:
- `_goalId` (uint): The ID of the goal.
- **Returns**: `GoalInfo` - An object containing the goal's details.

```solidity
function getGoalDetails(uint _goalId) public view returns (GoalInfo memory)
```

## Write Functions

### 1. `createGoalSolo(string memory _name, string memory _description, uint _requiredStake, uint _taskCount)`

- **Description**: Creates a new solo goal.
- **Parameters**:
- `_name` (string): The name of the goal.
- `_description` (string): A description of the goal.
- `_requiredStake` (uint): The required stake amount.
- `_taskCount` (uint): The number of tasks in the goal.

```solidity
function createGoalSolo(string memory _name, string memory _description, uint _requiredStake, uint _taskCount) public
```

### 2. `createGoal(string memory _name, string memory _description, uint _requiredStake, uint _taskCount)`

- **Description**: Creates a new gambling goal.
- **Parameters**:
- `_name` (string): The name of the goal.
- `_description` (string): A description of the goal.
- `_requiredStake` (uint): The required stake amount.
- `_taskCount` (uint): The number of tasks in the goal.

```solidity
function createGoal(string memory _name, string memory _description, uint _requiredStake, uint _taskCount) public
```

### 3. `stakeAndUnlockGoal(uint _goalId)`

- **Description**: Stakes tokens and unlocks a goal for participation.
- **Parameters**:
- `_goalId` (uint): The ID of the goal.

```solidity
function stakeAndUnlockGoal(uint _goalId) public payable
```

### 4. `confirmTaskCompletion(uint _goalId, address _user)`

- **Description**: Confirms the completion of a task for a user in a specific goal.
- **Parameters**:
- `_goalId` (uint): The ID of the goal.
- `_user` (address): The address of the user.

```solidity
function confirmTaskCompletion(uint _goalId, address _user) public
```

### 5. `claimStake(uint _goalId)`

- **Description**: Claims the reward for a specific goal.
- **Parameters**:
- `_goalId` (uint): The ID of the goal.

```solidity
function claimStake(uint _goalId) public
```

### 6. `settleGoal(uint _goalId)`

- **Description**: Settles a gambling goal by distributing rewards based on task completion.
- **Parameters**:
- `_goalId` (uint): The ID of the goal.

```solidity
function settleGoal(uint _goalId) public
```

## Events

### 1. `GoalCreated`

- **Parameters**:
- `id` (uint): The ID of the goal.
- `name` (string): The name of the goal.
- `description` (string): A description of the goal.
- `requiredStake` (uint): The required stake amount.
- `taskCount` (uint): The number of tasks in the goal.
- `goalType` (GoalType): The type of the goal (Solo or Gambling).
- `creator` (address): The address of the goal creator.

### 2. `GoalUnlocked`

- **Parameters**:
- `id` (uint): The ID of the goal.
- `user` (address): The address of the user.
- `stakeAmount` (uint): The amount staked by the user.

### 3. `TaskConfirmed`

- **Parameters**:
- `id` (uint): The ID of the goal.
- `user` (address): The address of the user.
- `taskIndex` (uint): The index of the confirmed task.

### 4. `StakeClaimed`

- **Parameters**:
- `id` (uint): The ID of the goal.
- `user` (address): The address of the user.
- `stakeAmount` (uint): The amount of the reward claimed by the user.

### 5. `GoalSettled`

- **Parameters**:
- `id` (uint): The ID of the goal.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"docs:build": "vitepress build docs"
"docs:build": "vitepress build docs",
"docs:dev": "vitepress dev docs"
},
"keywords": [],
"author": "",
Expand Down

0 comments on commit bd8b622

Please sign in to comment.