Skip to content

Commit

Permalink
rename ai agent
Browse files Browse the repository at this point in the history
  • Loading branch information
erhant committed Dec 18, 2024
1 parent c9444a3 commit abe44a9
Show file tree
Hide file tree
Showing 27 changed files with 349 additions and 265 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@ storage/

# Dotenv file
.env

# appleeeee
.DS_Store
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ APPENDIX: How to apply the Apache License to your work.
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright 2023 FirstBatch
Copyright 2024 FirstBatch

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
121 changes: 86 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,74 @@
# Swan Protocol
Swan is a **Decentralized Protocol** where AI agents (buyers) dynamically interact with asset creators. Agents operate with budgets to purchase assets that match their objectives. Asset creators design assets to align with buyers’ needs to convince the LLM to buy their asset/assets.
<p align="center">
<img src="https://raw.githubusercontent.com/firstbatchxyz/.github/refs/heads/master/branding/swan-logo-square.svg" alt="logo" width="168">
</p>

<p align="center">
<h1 align="center">
Swan Protocol
</h1>
<p align="center">
<i>Simulated Worlds with AI Narratives.</i>
</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

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:

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

Install dependencies with:

```sh
forge install
```

Compile the contracts with:

```sh
forge clean && forge build
```

> [!NOTE]
>
> Openzeppelin' foundry modules expect that running `forge clean` before running Foundry script or test or include `--force` option when running `forge script` or `forge test`.
### Upgradability

## Test
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)):

Run tests on local:
- `forge clean` beforehand, e.g. `forge clean && forge test`
- include `--force` option when running, e.g. `forge test --force`

```sh
forge clean && forge test
```
> 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
or on any other evm chain:
To update contracts to the latest library versions, use:
```sh
forge clean && forge test --rpc-url <RPC_URL>
forge update
```
## Deployment
Expand All @@ -42,6 +86,7 @@ Create keystores for deployment. [See more for keystores](https://eips.ethereum.
```sh
cast wallet import <FILE_NAME_OF_YOUR_KEYSTORE> --interactive
```

You can see your wallets with:

```sh
Expand All @@ -66,18 +111,17 @@ Deploy the contract with:
```sh
forge clean && forge script ./script/Deploy.s.sol:Deploy<CONTRACT_NAME> --rpc-url <RPC_URL> --account <FILE_NAME_OF_YOUR_KEYSTORE> --sender <DEPLOYER_ADDRESS> --broadcast
```

or for instant verification use:

```sh
forge clean && forge script ./script/Deploy.s.sol:Deploy<CONTRACT_NAME> --rpc-url <RPC_URL> --account <FILE_NAME_OF_YOUR_KEYSTORE> --sender <DEPLOYER_ADDRESS> --broadcast --verify --verifier <etherscan|blockscout|sourcify> --verifier-url <VERIFIER_URL>
```

> [!NOTE]
> `<VERIFIER_URL>` should be expolorer's homepage url. Forge reads your `<ETHERSCAN_API_KEY>` from .env file so you don't need to add this at the end of `<VERIFIER_URL>`.
> [!NOTE] > `<VERIFIER_URL>` should be expolorer's homepage url. Forge reads your `<ETHERSCAN_API_KEY>` from .env file so you don't need to add this at the end of `<VERIFIER_URL>`.
>
> e.g.
> e.g.
> `https://base-sepolia.blockscout.com/api/` for `Base Sepolia Network`
>
You can see deployed contract addresses under the `deployment/<chainid>.json`

Expand All @@ -89,13 +133,28 @@ Verify contract manually with:
forge verify-contract <CONTRACT_ADDRESS> src/$<CONTRACT_NAME>.sol:<CONTRACT_NAME> --verifier <etherscan|blockscout|sourcify> --verifier-url <VERIFIER_URL>
```

## Coverage
## Testing & Diagnostics

Run tests on local network:

```sh
forge clean && forge test
```

or fork an existing chain and run the tests on it:

```sh
forge clean && forge test --rpc-url <RPC_URL>
```

### Coverage

Check coverages with:

```sh
forge clean && bash coverage.sh
```

or to see summarized coverages on terminal:

```sh
Expand All @@ -104,7 +163,7 @@ forge clean && forge coverage --no-match-coverage "(test|mock|script)"

You can see coverages under the coverage directory.

## Storage Layout
### Storage Layout

Get storage layout with:

Expand All @@ -114,7 +173,7 @@ forge clean && bash storage.sh

You can see storage layouts under the storage directory.

## Gas Snapshot
### Gas Snapshot

Take the gas snapshot with:

Expand All @@ -124,28 +183,20 @@ forge clean && forge snapshot

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

## Format
## Documentation

Format code with:

```sh
forge fmt
```

## Generate documentation

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

```sh
forge doc
```

## Update

Update modules with:
We provide an MDBook template over it, which you can open via:

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

You can see the documentation under the `docs/` directory.
## License

We are using Apache-2.0 license.
6 changes: 6 additions & 0 deletions deployment/31337.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,11 @@
"Swan": {
"proxyAddr": "0xdeb1e9a6be7baf84208bb6e10ac9f9bbe1d70809",
"implAddr": "0x62c20aa1e0272312bc100b4e23b4dc1ed96dd7d1"
},
"SwanAgentFactory": {
"addr": "0x34a1d3fff3958843c43ad80f30b94c510645c316"
},
"SwanArtifactFactory": {
"addr": "0x90193c961a926261b756d1e5bb255e67ff9498a1"
}
}
86 changes: 53 additions & 33 deletions docs/src/README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,41 @@
# Swan Protocol
Swan is a **Decentralized Protocol** where AI agents (buyers) dynamically interact with asset creators. Agents operate with budgets to purchase assets that match their objectives. Asset creators design assets to align with buyers’ needs to convince the LLM to buy their asset/assets.
<p align="center">
<img src="https://raw.githubusercontent.com/firstbatchxyz/.github/refs/heads/master/branding/swan-logo-square.svg" alt="logo" width="168">
</p>

## Compile
<p align="center">
<h1 align="center">
Swan Protocol
</h1>
<p align="center">
<i>Simulated Worlds with AI Narratives.</i>
</p>
</p>

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

```sh
forge clean && forge build
```
## Installation

> [!NOTE]
>
> Openzeppelin' foundry modules expect that running `forge clean` before running Foundry script or test or include `--force` option when running `forge script` or `forge test`.
Install everything with:

## Test
```sh
forge install
```

Run tests on local:
Compile the contracts with:

```sh
forge clean && forge test
forge clean && forge build
```

or on any other evm chain:
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:

```sh
forge clean && forge test --rpc-url <RPC_URL>
forge update
```

## Deployment
Expand All @@ -42,6 +53,7 @@ Create keystores for deployment. [See more for keystores](https://eips.ethereum.
```sh
cast wallet import <FILE_NAME_OF_YOUR_KEYSTORE> --interactive
```

You can see your wallets with:

```sh
Expand All @@ -66,18 +78,17 @@ Deploy the contract with:
```sh
forge clean && forge script ./script/Deploy.s.sol:Deploy<CONTRACT_NAME> --rpc-url <RPC_URL> --account <FILE_NAME_OF_YOUR_KEYSTORE> --sender <DEPLOYER_ADDRESS> --broadcast
```

or for instant verification use:

```sh
forge clean && forge script ./script/Deploy.s.sol:Deploy --rpc-url <RPC_URL> --account <FILE_NAME_OF_YOUR_KEYSTORE> --sender <DEPLOYER_ADDRESS> --broadcast --verify --verifier <etherscan|blockscout|sourcify> --verifier-url <VERIFIER_URL>
forge clean && forge script ./script/Deploy.s.sol:Deploy<CONTRACT_NAME> --rpc-url <RPC_URL> --account <FILE_NAME_OF_YOUR_KEYSTORE> --sender <DEPLOYER_ADDRESS> --broadcast --verify --verifier <etherscan|blockscout|sourcify> --verifier-url <VERIFIER_URL>
```

> [!NOTE]
> `<VERIFIER_URL>` should be expolorer's homepage url. Forge reads your `<ETHERSCAN_API_KEY>` from .env file so you don't need to add this at the end of `<VERIFIER_URL>`.
> [!NOTE] > `<VERIFIER_URL>` should be expolorer's homepage url. Forge reads your `<ETHERSCAN_API_KEY>` from .env file so you don't need to add this at the end of `<VERIFIER_URL>`.
>
> e.g.
> e.g.
> `https://base-sepolia.blockscout.com/api/` for `Base Sepolia Network`
>
You can see deployed contract addresses under the `deployment/<chainid>.json`

Expand All @@ -89,13 +100,28 @@ Verify contract manually with:
forge verify-contract <CONTRACT_ADDRESS> src/$<CONTRACT_NAME>.sol:<CONTRACT_NAME> --verifier <etherscan|blockscout|sourcify> --verifier-url <VERIFIER_URL>
```

## Coverage
## Testing & Diagnostics

Run tests on local network:

```sh
forge clean && forge test
```

or fork an existing chain and run the tests on it:

```sh
forge clean && forge test --rpc-url <RPC_URL>
```

### Coverage

Check coverages with:

```sh
forge clean && bash coverage.sh
```

or to see summarized coverages on terminal:

```sh
Expand All @@ -104,7 +130,7 @@ forge clean && forge coverage --no-match-coverage "(test|mock|script)"

You can see coverages under the coverage directory.

## Storage Layout
### Storage Layout

Get storage layout with:

Expand All @@ -114,7 +140,7 @@ forge clean && bash storage.sh

You can see storage layouts under the storage directory.

## Gas Snapshot
### Gas Snapshot

Take the gas snapshot with:

Expand All @@ -132,20 +158,14 @@ Format code with:
forge fmt
```

## Generate documentation
## Documentation

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

```sh
forge doc
```

## Update

Update modules with:

```sh
forge update
```
## License

You can see the documentation under the `docs/` directory.
We are using Apache-2.0 license.
2 changes: 1 addition & 1 deletion docs/src/src/AIAgent.sol/contract.AIAgent.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# AIAgent
[Git Source](https://github.com/firstbatchxyz/swan-contracts/blob/feb8dd64d672a341a29a0a52b12cc56adf09c996/src/AIAgent.sol)
[Git Source](https://github.com/firstbatchxyz/swan-contracts/blob/c9444a397017d961972cbbff400b67d973ffe956/src/AIAgent.sol)

**Inherits:**
Ownable
Expand Down
Loading

0 comments on commit abe44a9

Please sign in to comment.