Skip to content

Commit

Permalink
docs and abis updated
Browse files Browse the repository at this point in the history
  • Loading branch information
erhant committed Dec 18, 2024
1 parent d795174 commit b2dafc8
Show file tree
Hide file tree
Showing 17 changed files with 702 additions and 53 deletions.
2 changes: 1 addition & 1 deletion abis/Swan.json
Original file line number Diff line number Diff line change
Expand Up @@ -1123,4 +1123,4 @@
}
]
}
]
]
2 changes: 1 addition & 1 deletion abis/SwanAgent.json
Original file line number Diff line number Diff line change
Expand Up @@ -621,4 +621,4 @@
}
]
}
]
]
2 changes: 1 addition & 1 deletion abis/SwanArtifact.json
Original file line number Diff line number Diff line change
Expand Up @@ -563,4 +563,4 @@
}
]
}
]
]
2 changes: 1 addition & 1 deletion abis/parseAbi.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ fs.readFile(filename, "utf8", (err, data) => {
process.exit(1);
}

console.log("ABI extracted and written to abi.json");
console.log("ABI extracted and written to", filename);
});
} catch (parseErr) {
console.error(`Error parsing JSON: ${parseErr}`);
Expand Down
49 changes: 40 additions & 9 deletions docs/src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,34 @@
</p>
</p>

<p align="center">
<a href="https://opensource.org/licenses/Apache-2-0" target="_blank">
<img alt="License: Apache 2.0" src="https://img.shields.io/badge/license-Apache_2.0-7CB9E8.svg">
</a>
<a href="./.github/workflows/test.yml" target="_blank">
<img alt="Workflow: Tests" src="https://github.com/firstbatchxyz/dria-oracle-contracts/actions/workflows/test.yml/badge.svg?branch=master">
</a>
<a href="https://discord.gg/dria" target="_blank">
<img alt="Discord" src="https://dcbadge.vercel.app/api/server/dria?style=flat">
</a>
</p>

Swan is a decentralized protocol where AI agents dynamically interact with users who create artifacts inlined with agent's narratives.

## Installation

Install everything with:
First, make sure you have the requirements:

- We are using [Foundry](https://book.getfoundry.sh/), so make sure you [install](https://book.getfoundry.sh/getting-started/installation) it first.
- Upgradable contracts make use of [NodeJS](https://nodejs.org/en), so you should [install](https://nodejs.org/en/download/package-manager) that as well.

Clone the repository:

```sh
git clone [email protected]:firstbatchxyz/swan-contracts.git
```

Install dependencies with:

```sh
forge install
Expand All @@ -27,12 +50,22 @@ Compile the contracts with:
forge clean && forge build
```

### Upgradability

We are using [openzeppelin-foundry-upgrades](https://github.com/OpenZeppelin/openzeppelin-foundry-upgrades) library. To make sure upgrades are **safe**, you must do one of the following before you run `forge script` or `forge test` (as per their [docs](https://github.com/OpenZeppelin/openzeppelin-foundry-upgrades?tab=readme-ov-file#before-running)):

- `forge clean` beforehand, e.g. `forge clean && forge test`
- include `--force` option when running, e.g. `forge test --force`

To update Swan in case any library is updated, you can do:
> Note that for some users this may fail (see [issue](https://github.com/firstbatchxyz/dria-oracle-contracts/issues/16)) due to a missing NPM package called `@openzeppelin/upgrades-core`. To fix it, do:
>
> ```sh
> npm install @openzeppelin/upgrades-core@latest -g
> ```
### Updates
To update contracts to the latest library versions, use:
```sh
forge update
Expand Down Expand Up @@ -150,20 +183,18 @@ forge clean && forge snapshot

You can see the snapshot `.gas-snapshot` file in the current directory.

## Format
## Documentation

Format code with:
We have auto-generated documentation under the [`docs`](./docs) folder, generated with the following command:

```sh
forge fmt
forge doc
```

## Documentation

We have auto-generated documentation under the [`docs`](./docs) folder, generated with the following command:
We provide an MDBook template over it, which you can open via:

```sh
forge doc
cd docs && mdbook serve --open
```

## License
Expand Down
10 changes: 4 additions & 6 deletions docs/src/SUMMARY.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
# Summary
- [Home](README.md)
# src
- [❱ mock](src/mock/README.md)
- [SwanV2](src/mock/SvanV2.sol/contract.SwanV2.md)
- [AIAgentFactory](src/AIAgent.sol/contract.AIAgentFactory.md)
- [AIAgent](src/AIAgent.sol/contract.AIAgent.md)
- [ArtifactFactory](src/Artifact.sol/contract.ArtifactFactory.md)
- [Artifact](src/Artifact.sol/contract.Artifact.md)
- [Swan](src/Swan.sol/contract.Swan.md)
- [Swan constants](src/Swan.sol/constants.Swan.md)
- [SwanAgentFactory](src/SwanAgent.sol/contract.SwanAgentFactory.md)
- [SwanAgent](src/SwanAgent.sol/contract.SwanAgent.md)
- [SwanArtifactFactory](src/SwanArtifact.sol/contract.SwanArtifactFactory.md)
- [SwanArtifact](src/SwanArtifact.sol/contract.SwanArtifact.md)
- [SwanMarketParameters](src/SwanManager.sol/struct.SwanMarketParameters.md)
- [SwanManager](src/SwanManager.sol/abstract.SwanManager.md)
9 changes: 4 additions & 5 deletions docs/src/src/README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@


# Contents
- [mock](/src/mock)
- [AIAgentFactory](AIAgent.sol/contract.AIAgentFactory.md)
- [AIAgent](AIAgent.sol/contract.AIAgent.md)
- [ArtifactFactory](Artifact.sol/contract.ArtifactFactory.md)
- [Artifact](Artifact.sol/contract.Artifact.md)
- [Swan](Swan.sol/contract.Swan.md)
- [Swan constants](Swan.sol/constants.Swan.md)
- [SwanAgentFactory](SwanAgent.sol/contract.SwanAgentFactory.md)
- [SwanAgent](SwanAgent.sol/contract.SwanAgent.md)
- [SwanArtifactFactory](SwanArtifact.sol/contract.SwanArtifactFactory.md)
- [SwanArtifact](SwanArtifact.sol/contract.SwanArtifact.md)
- [SwanMarketParameters](SwanManager.sol/struct.SwanMarketParameters.md)
- [SwanManager](SwanManager.sol/abstract.SwanManager.md)
16 changes: 10 additions & 6 deletions docs/src/src/Swan.sol/constants.Swan.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
# Constants
[Git Source](https://github.com/firstbatchxyz/swan-contracts/blob/c9444a397017d961972cbbff400b67d973ffe956/src/Swan.sol)
[Git Source](https://github.com/firstbatchxyz/swan-contracts/blob/d7951743b0ff97c2f6e978aeabb850c0310d76f3/src/Swan.sol)

### SwanAgentPurchaseOracleProtocol
*Protocol string for Swan Purchase CRONs, checked in the Oracle.*

### SwanAIAgentPurchaseOracleProtocol

```solidity
bytes32 constant SwanAIAgentPurchaseOracleProtocol = "swan-agent-purchase/0.1.0";
bytes32 constant SwanAgentPurchaseOracleProtocol = "swan-agent-purchase/0.1.0";
```

### SwanAIAgentStateOracleProtocol
### SwanAgentStateOracleProtocol
*Protocol string for Swan State CRONs, checked in the Oracle.*


```solidity
bytes32 constant SwanAIAgentStateOracleProtocol = "swan-agent-state/0.1.0";
bytes32 constant SwanAgentStateOracleProtocol = "swan-agent-state/0.1.0";
```

### BASIS_POINTS
*Used to calculate the fee for the AI agent to be able to compute correct amount.*
*Used to calculate the fee for the agent to be able to compute correct amount.*


```solidity
Expand Down
38 changes: 19 additions & 19 deletions docs/src/src/Swan.sol/contract.Swan.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# Swan
[Git Source](https://github.com/firstbatchxyz/swan-contracts/blob/c9444a397017d961972cbbff400b67d973ffe956/src/Swan.sol)
[Git Source](https://github.com/firstbatchxyz/swan-contracts/blob/d7951743b0ff97c2f6e978aeabb850c0310d76f3/src/Swan.sol)

**Inherits:**
[SwanManager](/src/SwanManager.sol/abstract.SwanManager.md), UUPSUpgradeable


## State Variables
### agentFactory
Factory contract to deploy AI Agents.
Factory contract to deploy Agents.


```solidity
AIAgentFactory public agentFactory;
SwanAgentFactory public agentFactory;
```


Expand All @@ -20,7 +20,7 @@ Factory contract to deploy Artifact tokens.


```solidity
ArtifactFactory public artifactFactory;
SwanArtifactFactory public artifactFactory;
```


Expand Down Expand Up @@ -109,21 +109,21 @@ function transferOwnership(address newOwner) public override onlyOwner;

### createAgent

Creates a new AI agent.
Creates a new agent.

*Emits a `AIAgentCreated` event.*
*Emits a `AgentCreated` event.*


```solidity
function createAgent(string calldata _name, string calldata _description, uint96 _feeRoyalty, uint256 _amountPerRound)
external
returns (AIAgent);
returns (SwanAgent);
```
**Returns**

|Name|Type|Description|
|----|----|-----------|
|`<none>`|`AIAgent`|address of the new AI agent.|
|`<none>`|`SwanAgent`|address of the new agent.|


### list
Expand Down Expand Up @@ -159,7 +159,7 @@ function relist(address _artifact, address _agent, uint256 _price) external;
|Name|Type|Description|
|----|----|-----------|
|`_artifact`|`address`|address of the artifact.|
|`_agent`|`address`|new AIAgent for the artifact.|
|`_agent`|`address`|new agent for the artifact.|
|`_price`|`uint256`|new price of the token.|


Expand All @@ -185,7 +185,7 @@ function purchase(address _artifact) external;

### setFactories

Set the factories for AI Agents and Artifacts.
Set the factories for Agents and Artifacts.

*Only callable by owner.*

Expand All @@ -197,8 +197,8 @@ function setFactories(address _agentFactory, address _artifactFactory) external

|Name|Type|Description|
|----|----|-----------|
|`_agentFactory`|`address`|new AIAgentFactory address|
|`_artifactFactory`|`address`|new ArtifactFactory address|
|`_agentFactory`|`address`|new SwanAgentFactory address|
|`_artifactFactory`|`address`|new SwanArtifactFactory address|


### getListingPrice
Expand Down Expand Up @@ -255,16 +255,16 @@ An `agent` purchased an artifact.
event ArtifactSold(address indexed owner, address indexed agent, address indexed artifact, uint256 price);
```

### AIAgentCreated
A new AI agent is created.
### AgentCreated
A new agent is created.

*`owner` is the owner of the AI agent.*
*`owner` is the owner of the agent.*

*`agent` is the address of the AI agent.*
*`agent` is the address of the agent.*


```solidity
event AIAgentCreated(address indexed owner, address indexed agent);
event AgentCreated(address indexed owner, address indexed agent);
```

## Errors
Expand Down Expand Up @@ -317,13 +317,13 @@ Holds the listing information.

*`createdAt` is the timestamp of the artifact creation.*

*`feeRoyalty` is the royalty fee of the AIAgent.*
*`feeRoyalty` is the royalty fee of the agent.*

*`price` is the price of the artifact.*

*`seller` is the address of the creator of the artifact.*

*`agent` is the address of the AIAgent.*
*`agent` is the address of the agent.*

*`round` is the round in which the artifact is created.*

Expand Down
Loading

0 comments on commit b2dafc8

Please sign in to comment.