Merged main into contracts-merge

This commit is contained in:
2024-10-26 12:38:51 +01:00
parent 9e0276378c
commit 74c851f286
4 changed files with 8553 additions and 267 deletions

View File

@@ -1,66 +0,0 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.8.2 <0.9.0;
contract Escrow {
struct EscrowContract {
address buyer;
address seller;
uint256 amount;
bool buyerApproved;
bool sellerApproved;
bool isComplete;
}
mapping(uint256 => EscrowContract) public escrows;
uint256 public escrowCounter;
function createEscrow(address _seller) public payable {
escrows[escrowCounter] = EscrowContract(msg.sender, _seller, msg.value, false, false, false);
escrowCounter++;
}
function approveEscrow(uint256 escrowId) public {
require(escrowId < escrowCounter, "Invalid escrow ID");
require(msg.sender == escrows[escrowId].buyer || msg.sender == escrows[escrowId].seller, "Unauthorized");
if (msg.sender == escrows[escrowId].buyer) {
escrows[escrowId].buyerApproved = true;
} else {
escrows[escrowId].sellerApproved = true;
}
if (escrows[escrowId].buyerApproved && escrows[escrowId].sellerApproved) {
escrows[escrowId].isComplete = true;
(bool sent, ) = escrows[escrowId].seller.call{value: escrows[escrowId].amount}("");
require(sent, "Failed to send FLR to seller");
}
}
function getEscrowAmount(uint256 escrowId) public view returns (uint256) {
return escrows[escrowId].amount;
}
function getEscrowBuyer(uint256 escrowId) public view returns (address) {
return escrows[escrowId].buyer;
}
function getEscrowSeller(uint256 escrowId) public view returns (address) {
return escrows[escrowId].seller;
}
function getEscrowBuyerApproved(uint256 escrowId) public view returns (bool) {
return escrows[escrowId].buyerApproved;
}
function getEscrowSellerApproved(uint256 escrowId) public view returns (bool) {
return escrows[escrowId].sellerApproved;
}
function getEscrowIsComplete(uint256 escrowId) public view returns (bool) {
return escrows[escrowId].isComplete;
}
}

View File

@@ -1,44 +0,0 @@
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0 <0.9.0;
import {ContractRegistry} from "@flarenetwork/flare-periphery-contracts/coston2/ContractRegistry.sol";
/* THIS IS A TEST IMPORT, in production use: import {FtsoV2Interface} from "@flarenetwork/flare-periphery-contracts/coston2/FtsoV2Interface.sol"; */
import {TestFtsoV2Interface} from "@flarenetwork/flare-periphery-contracts/coston2/TestFtsoV2Interface.sol";
/**
* THIS IS AN EXAMPLE CONTRACT.
* DO NOT USE THIS CODE IN PRODUCTION.
*/
contract FtsoV2FeedConsumer {
TestFtsoV2Interface internal ftsoV2;
// Feed IDs, see https://dev.flare.network/ftso/feeds for full list
bytes21[] public feedIds = [
bytes21(0x01464c522f55534400000000000000000000000000) // FLR/USD
// bytes21(0x014254432f55534400000000000000000000000000), // BTC/USD
// bytes21(0x014554482f55534400000000000000000000000000) // ETH/USD
];
/**
* Constructor initializes the FTSOv2 contract.
* The contract registry is used to fetch the FtsoV2 contract address.
*/
constructor() {
/* THIS IS A TEST METHOD, in production use: ftsoV2 = ContractRegistry.getFtsoV2(); */
ftsoV2 = ContractRegistry.getTestFtsoV2();
}
/**
* Get the current value of the feeds.
*/
function getFtsoV2CurrentFeedValues()
external
view
returns (
uint256[] memory _feedValues,
int8[] memory _decimals,
uint64 _timestamp
)
{
return ftsoV2.getFeedsById(feedIds);
}
}