Skip to content

Commit a4aa94f

Browse files
committed
Update version to 0.1.42
1 parent 920e2d8 commit a4aa94f

21 files changed

+1509
-57
lines changed

README.md

Lines changed: 46 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,83 @@
1-
# Flare periphery package for smart contract development
1+
# Flare periphery package for Foundry
22

3-
This package contains a collection of smart contracts deployed on the **Flare**, Coston2 (test network for Flare), **Songbird** and Coston (test network for Songbird) networks.
3+
This package contains a collection of smart contract interfaces deployed on the **Flare**, Coston2 (test network for Flare), **Songbird** and Coston (test network for Songbird) networks.
44

55
The intention of this package is to provide a set of **interfaces** for easier integration and development of smart contracts on Flare based networks.
6-
Interfaces in the most recent version of this package are the same as the ones deployed on the networks. This package exposes all public and most of the internal interfaces but **does not** expose any of the implementations. If you want to access the implementations, you can use the official [flare smart contracts repo](https://gitlab.com/flarenetwork/flare-smart-contracts).
6+
Interfaces in the most recent version of this package are the same as the ones deployed on the networks. This package exposes all public and most of the internal interfaces but **does not** expose any of the implementations. If you want to access the implementations, you can use the official [Flare smart contracts repo](https://github.com/flare-foundation/flare-smart-contracts-v2).
77

8-
The package functions similar to openzeppelin library packages and can easily be imported in `nodejs` based projects as well as directly in remix IDE.
8+
Basic familiarity with the Flare network and EVM is assumed for use. For more information, please refer to the [Flare Developer Hub](https://dev.flare.network/). For a guided introduction to smart contract development on Flare, see [Getting Started with Flare](https://dev.flare.network/network/getting-started).
99

10-
Basic familiarity with the Flare network and EVM is assumed for use. For more information, please refer to the [Flare documentation](https://docs.flare.network/). If you want a guided tutorial on EVM development and Flare focused smart contract development with this package, please refer to the [Flare developer blogpost series](https://medium.com/@j0-0sko/setting-up-the-environment-3c9f20dcac7c).
10+
## Installation
11+
12+
Install the package using Forge Soldeer:
13+
14+
```sh
15+
forge soldeer install flare-periphery~<version>
16+
```
17+
18+
This will add the package to your `soldeer.lock` and make it available for import under the `flare-periphery/` prefix.
1119

1220
## Package structure
1321

14-
Each of the networks has its own folder and subfolders for interfaces of specific flare based technologies. The folder structure is as follows:
22+
Each network has its own folder inside `src/`. All interfaces are placed flat within the respective network folder.
1523

1624
```
25+
src/
1726
├── coston
18-
│ ├── distribution
19-
│ ├── ftso
20-
│ ├── governance
21-
│ ├── inflation
22-
│ ├── mockContracts
23-
│ ├── stateConnector
24-
│ └── util-contracts
2527
├── coston2
26-
│ ├── distribution
27-
│ ├── ftso
28-
│ ├── governance
29-
│ ├── mockContracts
30-
│ ├── stateConnector
31-
│ └── util-contracts
32-
├── examples
33-
│ ├── coston
34-
│ ├── coston2
35-
│ ├── flare
36-
│ └── songbird
3728
├── flare
38-
│ ├── distribution
39-
│ ├── ftso
40-
│ ├── governance
41-
│ ├── mockContracts
42-
│ ├── stateConnector
43-
│ └── util-contracts
4429
└── songbird
45-
├── distribution
46-
├── ftso
47-
├── governance
48-
├── inflation
49-
├── mockContracts
50-
├── stateConnector
51-
└── util-contracts
5230
```
5331

32+
> **Note:** The `coston2` folder also includes Smart Accounts interfaces.
33+
5434
## Example usages
5535

56-
### I want to use the FTSO prices in my contract
36+
### Using FTSO v2 feeds in your contract
37+
38+
To read FTSO v2 feed data on Flare, import `IFtsoV2` and the relay interfaces:
5739

58-
You should use `IFtsoRegistry` (or `IIFtsoRegistry`) for simple price queries or
59-
`IFtso` (or `IIFtso`) for more advanced queries.
60-
The `IFtsoRegistry` interface is available in
61-
`contracts/userInterfaces/IFtsoRegistry.sol` and the
62-
`IFtso` interface is available in `contracts/userInterfaces/IFtso.sol`.
40+
```solidity
41+
import { IFtsoV2 } from "flare-periphery/src/flare/IFtsoV2.sol";
42+
import { IRelay } from "flare-periphery/src/flare/IRelay.sol";
43+
```
6344

64-
To use the interfaces deployed on `Flare` network, just import them in your contract source:
45+
For Coston2 (testnet):
6546

6647
```solidity
67-
import { IPriceSubmitter } from "@flarenetwork/flare-periphery-contracts/flare/ftso/userInterfaces/IPriceSubmitter.sol";
68-
import { IFtsoRegistry } from "@flarenetwork/flare-periphery-contracts/flare/ftso/userInterfaces/IFtsoRegistry.sol";
48+
import { IFtsoV2 } from "flare-periphery/src/coston2/IFtsoV2.sol";
6949
```
7050

71-
If you are using Foundry, you can install the interfaces with Forge and import them in your contract source:
51+
### Using the Flare Data Connector (FDC)
52+
53+
To verify attestations using the FDC:
7254

7355
```solidity
74-
import { IPriceSubmitter } from "flare-periphery-contracts/flare/ftso/userInterfaces/IPriceSubmitter.sol";
75-
import { IFtsoRegistry } from "flare-periphery-contracts/flare/ftso/userInterfaces/IFtsoRegistry.sol";
56+
import { IFdcHub } from "flare-periphery/src/flare/IFdcHub.sol";
57+
import { IFdcVerification } from "flare-periphery/src/flare/IFdcVerification.sol";
7658
```
7759

78-
Very simple contract that can consume the FTSO prices is shown in `examples/networkName/SimpleFtsoExample.sol`.
60+
### Using FAssets interfaces
61+
62+
FAsset interfaces are available on all networks:
7963

80-
An example usage of the FTSO system to dynamically price token in a contract is showcased in
81-
`examples/network/DynamicToken.sol` with a more detailed explanation in the [blogpost](https://medium.com/@j0-0sko/taking-it-up-to-11-74dd91c39c2b).
64+
```solidity
65+
import { IAssetManager } from "flare-periphery/src/flare/IAssetManager.sol";
66+
import { IFAsset } from "flare-periphery/src/flare/IFAsset.sol";
67+
```
8268

83-
### I want to confirm something using the attestation client
69+
### Using the ContractRegistry
8470

85-
Coming soon.
71+
Each network folder includes a generated `ContractRegistry` Solidity library with on-chain addresses for all registered contracts:
72+
73+
```solidity
74+
import { ContractRegistry } from "flare-periphery/src/flare/ContractRegistry.sol";
75+
```
8676

8777
------
8878

89-
**You've got the tools, turn on your imagination and go, go and build something awesome**
79+
**You've got the tools, turn on your imagination and go build something awesome!**
9080

91-
If you find any mistake or have any suggestions, please open an issue or contact us are directly.
81+
If you find any mistakes or have suggestions, please open an issue or contact us directly.
9282

9383
**Package is provided as is, without any warranty.**

foundry.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "flare-periphery"
3-
version = "0.1.41"
3+
version = "0.1.42"
44

55
[profile.default]
66
src = "src"

src/coston2/ContractRegistry.sol

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import { IAssetManagerController } from "./IAssetManagerController.sol";
4343
import { IAssetManager } from "./IAssetManager.sol";
4444
import { IJsonApiVerification } from "./IJsonApiVerification.sol";
4545
import { IGenericRewardManager } from "./IGenericRewardManager.sol";
46+
import { IMasterAccountController } from "./IMasterAccountController.sol";
4647
// END AUTO GENERATED - DO NOT EDIT ABOVE THIS LINE
4748

4849
// Library is intended to be used inline, so the strings are all memory allocated (instead of calldata)
@@ -624,5 +625,18 @@ library ContractRegistry {
624625
);
625626
}
626627

628+
function getMasterAccountController()
629+
internal
630+
view
631+
returns (IMasterAccountController)
632+
{
633+
return
634+
IMasterAccountController(
635+
FLARE_CONTRACT_REGISTRY.getContractAddressByHash(
636+
keccak256(abi.encode("MasterAccountController"))
637+
)
638+
);
639+
}
640+
627641
// END AUTO GENERATED - DO NOT EDIT ABOVE THIS LINE
628642
}

src/flare/ContractRegistry.sol

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import { IFdcRequestFeeConfigurations } from "./IFdcRequestFeeConfigurations.sol
4242
import { IAssetManagerController } from "./IAssetManagerController.sol";
4343
import { IAssetManager } from "./IAssetManager.sol";
4444
import { IGenericRewardManager } from "./IGenericRewardManager.sol";
45+
import { IMasterAccountController } from "./IMasterAccountController.sol";
4546
// END AUTO GENERATED - DO NOT EDIT ABOVE THIS LINE
4647

4748
// Library is intended to be used inline, so the strings are all memory allocated (instead of calldata)
@@ -612,5 +613,18 @@ library ContractRegistry {
612613
);
613614
}
614615

616+
function getMasterAccountController()
617+
internal
618+
view
619+
returns (IMasterAccountController)
620+
{
621+
return
622+
IMasterAccountController(
623+
FLARE_CONTRACT_REGISTRY.getContractAddressByHash(
624+
keccak256(abi.encode("MasterAccountController"))
625+
)
626+
);
627+
}
628+
615629
// END AUTO GENERATED - DO NOT EDIT ABOVE THIS LINE
616630
}

src/flare/IAgentVaultsFacet.sol

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity >=0.8.4 <0.9;
3+
4+
/**
5+
* @title IAgentVaultsFacet
6+
* @notice Interface for the AgentVaultsFacet contract.
7+
*/
8+
interface IAgentVaultsFacet {
9+
10+
/**
11+
* @notice Emitted when an agent vault is added.
12+
* @param agentVaultId The agent vault ID.
13+
* @param agentVaultAddress The agent vault address.
14+
*/
15+
event AgentVaultAdded(
16+
uint256 indexed agentVaultId,
17+
address indexed agentVaultAddress
18+
);
19+
20+
/**
21+
* @notice Emitted when an agent vault is removed.
22+
* @param agentVaultId The agent vault ID.
23+
* @param agentVaultAddress The agent vault address.
24+
*/
25+
event AgentVaultRemoved(
26+
uint256 indexed agentVaultId,
27+
address indexed agentVaultAddress
28+
);
29+
30+
/**
31+
* @notice Reverts if array lengths do not match.
32+
*/
33+
error AgentsVaultsLengthsMismatch();
34+
35+
/**
36+
* @notice Reverts if the agent vault ID is zero.
37+
* @param index The index in the input array.
38+
*/
39+
error AgentVaultIdZero(
40+
uint256 index
41+
);
42+
43+
/**
44+
* @notice Reverts if the agent vault ID is already added.
45+
* @param agentVaultId The agent vault ID.
46+
*/
47+
error AgentVaultIdAlreadyAdded(
48+
uint256 agentVaultId
49+
);
50+
51+
/**
52+
* @notice Reverts if the agent vault address is zero.
53+
* @param index The index in the input array.
54+
*/
55+
error AgentVaultAddressZero(
56+
uint256 index
57+
);
58+
59+
/**
60+
* @notice Reverts if the agent vault address is already added.
61+
* @param agentVaultAddress The agent vault address.
62+
*/
63+
error AgentVaultAddressAlreadyAdded(
64+
address agentVaultAddress
65+
);
66+
67+
/**
68+
* @notice Reverts if the agent vault is invalid.
69+
* @param agentVaultId The agent vault ID.
70+
*/
71+
error InvalidAgentVault(
72+
uint256 agentVaultId
73+
);
74+
75+
/**
76+
* @notice Reverts if the agent is not available.
77+
* @param agentVault The agent vault address.
78+
*/
79+
error AgentNotAvailable(
80+
address agentVault
81+
);
82+
83+
/**
84+
* Returns the list of registered agent vault IDs and their corresponding addresses.
85+
* @return _agentVaultIds The list of registered agent vault IDs.
86+
* @return _agentVaultAddresses The list of registered agent vault addresses.
87+
*/
88+
function getAgentVaults()
89+
external view
90+
returns (uint256[] memory _agentVaultIds, address[] memory _agentVaultAddresses);
91+
}
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity >=0.8.4 <0.9;
3+
4+
/**
5+
* @title ICustomInstructionsFacet
6+
* @notice Interface for the CustomInstructionsFacet contract.
7+
*/
8+
interface ICustomInstructionsFacet {
9+
10+
/// @notice Struct containing custom call information
11+
struct CustomCall {
12+
/// @notice Target contract address
13+
address targetContract;
14+
/// @notice value (in wei) to send with the call
15+
uint256 value;
16+
/// @notice Call data
17+
bytes data;
18+
}
19+
20+
/**
21+
* @notice Emitted when a custom instruction is registered.
22+
* @param customInstructionHash The hash representing the registered instructions.
23+
*/
24+
event CustomInstructionRegistered(bytes32 indexed customInstructionHash);
25+
26+
/**
27+
* @notice Emitted when a custom instruction is already registered.
28+
* @param customInstructionHash The hash representing the already registered instructions.
29+
*/
30+
event CustomInstructionAlreadyRegistered(bytes32 indexed customInstructionHash);
31+
32+
/**
33+
* @notice Reverts if the custom instruction is empty (zero custom calls).
34+
*/
35+
error EmptyCustomInstruction();
36+
37+
/**
38+
* @notice Reverts if the target address of a custom call is zero.
39+
*/
40+
error TargetAddressZero();
41+
42+
/**
43+
* @notice Reverts if the target address of a custom call is not a contract.
44+
* @param target The target address.
45+
*/
46+
error TargetNotAContract(address target);
47+
48+
/**
49+
* @notice Register custom instruction and return the call hash.
50+
* @param _customInstruction Custom instruction (array of custom calls) to register.
51+
* @return _customInstructionHash The hash representing the registered custom instruction.
52+
*/
53+
function registerCustomInstruction(
54+
CustomCall[] memory _customInstruction
55+
) external returns (bytes32 _customInstructionHash);
56+
57+
/**
58+
* @notice Get a custom instruction for a given call hash.
59+
* @param _customInstructionHash The hash representing the custom instruction.
60+
* @return _customInstruction Custom instruction (array of custom calls) for the hash.
61+
*/
62+
function getCustomInstruction(
63+
bytes32 _customInstructionHash
64+
) external view returns (CustomCall[] memory _customInstruction);
65+
/**
66+
* @notice Get paginated custom instruction hashes.
67+
* @param _start The starting index.
68+
* @param _end The ending index.
69+
* @return _customInstructionHashes Array of custom instruction hashes for the requested page.
70+
* @return _totalLength The total number of custom instruction hashes.
71+
*/
72+
function getCustomInstructionHashes(
73+
uint256 _start,
74+
uint256 _end
75+
) external view returns (bytes32[] memory _customInstructionHashes, uint256 _totalLength);
76+
77+
/**
78+
* @notice Encode a custom instruction to get its call hash.
79+
* @param _customInstruction Custom instruction (array of custom calls) to encode.
80+
* @return _customInstructionHash The hash representing the custom instruction.
81+
*/
82+
function encodeCustomInstruction(
83+
CustomCall[] memory _customInstruction
84+
) external pure returns (bytes32 _customInstructionHash);
85+
}

0 commit comments

Comments
 (0)