Skip to content

Commit

Permalink
Merge pull request #243 from rsksmart/flyover-2.1
Browse files Browse the repository at this point in the history
Flyover 2.1 -> QA-Test
  • Loading branch information
Luisfc68 authored Aug 13, 2024
2 parents 4646443 + 9a98c60 commit cd7fb89
Show file tree
Hide file tree
Showing 9 changed files with 332 additions and 146 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ jobs:
- name: Install truffle
run: npm install -g truffle

- name: NPM Login
run: npm config set //npm.pkg.github.com/:_authToken ${{ secrets.GITHUB_TOKEN }}

- name: Install dependencies
run: npm ci
# - name: Lint source and tests
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/slither.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ jobs:
with:
node-version: '19.6.0'

- name: NPM Login
run: npm config set //npm.pkg.github.com/:_authToken ${{ secrets.GITHUB_TOKEN }}

- name: Install dependencies
run: npm ci

Expand Down
4 changes: 2 additions & 2 deletions contracts/Bridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ interface Bridge {

function getFederatorPublicKey(int256 index) external view returns (bytes memory);

function getFederatorPublicKeyOfType(int256 index, string calldata atype) external returns (bytes memory);
function getFederatorPublicKeyOfType(int256 index, string calldata atype) external view returns (bytes memory);

function getFederationCreationTime() external view returns (int256);

Expand Down Expand Up @@ -111,7 +111,7 @@ interface Bridge {
function registerBtcCoinbaseTransaction(bytes calldata btcTxSerialized, bytes32 blockHash,
bytes calldata pmtSerialized, bytes32 witnessMerkleRoot, bytes32 witnessReservedValue) external;

function hasBtcBlockCoinbaseTransactionInformation(bytes32 blockHash) external returns (bool);
function hasBtcBlockCoinbaseTransactionInformation(bytes32 blockHash) external view returns (bool);

function registerFastBridgeBtcTransaction(bytes calldata btcTxSerialized, uint256 height,
bytes calldata pmtSerialized, bytes32 derivationArgumentsHash,
Expand Down
45 changes: 30 additions & 15 deletions contracts/LiquidityBridgeContractV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ contract LiquidityBridgeContractV2 is Initializable, OwnableUpgradeable, Reentra
require(msg.sender == address(bridge), "LBC007");
}

function version() external pure returns (string memory) {
return "1.3.0";
}

function getProviderIds() external view returns (uint) {
return providerId;
}
Expand Down Expand Up @@ -255,28 +259,39 @@ contract LiquidityBridgeContractV2 is Initializable, OwnableUpgradeable, Reentra
return (providerId);
}

function getProviders(
uint[] memory providerIds
) external view returns (LiquidityProvider[] memory) {
LiquidityProvider[] memory providersToReturn = new LiquidityProvider[](
providerIds.length
);
function getProviders() external view returns (LiquidityProvider[] memory) {
uint count = 0;

for (uint i = 0; i < providerIds.length; i++) {
uint id = providerIds[i];
if (
(isRegistered(liquidityProviders[id].provider) ||
isRegisteredForPegout(liquidityProviders[id].provider)) &&
liquidityProviders[id].status
) {
providersToReturn[count] = liquidityProviders[id];
LiquidityProvider storage lp;
for (uint i = 1; i <= providerId; i++) {
if (shouldBeListed(liquidityProviders[i])) {
count++;
}
}
LiquidityProvider[] memory providersToReturn = new LiquidityProvider[](count);
count = 0;
for (uint i = 1; i <= providerId; i++) {
lp = liquidityProviders[i];
if (shouldBeListed(lp)) {
providersToReturn[count] = lp;
count++;
}
}
return providersToReturn;
}

function getProvider(address providerAddress) public view returns (LiquidityProvider memory) {
for (uint i = 1; i <= providerId; i++) {
if (liquidityProviders[i].provider == providerAddress) {
return liquidityProviders[i];
}
}
revert("LBC001");
}

function shouldBeListed(LiquidityProvider storage lp) private view returns(bool){
return (isRegistered(lp.provider) || isRegisteredForPegout(lp.provider)) && lp.status;
}

/**
@dev Increases the amount of collateral of the sender
*/
Expand Down
59 changes: 40 additions & 19 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "liquidity-bridge-contract",
"version": "1.2.0",
"version": "1.3.0",
"description": "## registerFastBridgeBtcTransaction",
"main": "index.js",
"scripts": {
Expand Down Expand Up @@ -44,8 +44,9 @@
"dependencies": {
"@openzeppelin/contracts": "^4.8.0",
"@openzeppelin/contracts-upgradeable": "^4.8.2",
"@rsksmart/btc-transaction-solidity-helper": "^0.1.1",
"@rsksmart/btc-transaction-solidity-helper": "^0.2.1",
"@truffle/hdwallet-provider": "^2.1.3",
"bech32": "^2.0.0",
"chai": "^4.3.4",
"chai-bn": "^0.3.0",
"truffle-assertions": "^0.9.2",
Expand Down
14 changes: 9 additions & 5 deletions readme.MD
Original file line number Diff line number Diff line change
Expand Up @@ -140,15 +140,19 @@ Registers msg.sender as a liquidity provider with msg.value as collateral
The registered provider ID

### **getProviders**
function getProviders(
uint[] memory providerIds
) external view returns (LiquidityProvider[] memory)
function getProviders() external view returns (LiquidityProvider[] memory)
Retrieves the information of a group of liquidity providers
#### Parametets
* providerIds: IDs of the providers to fetch
#### Return value
Array with the information of the requested LPs

### **getProvider**
function getProvider(address providerAddress) external view returns (LiquidityProvider memory)
Retrieves the information of a specific liquidity provider, regardless if it has resigned or has been disabled
#### Parameters
* providerAddress: address of the provider to fetch
#### Return value
Information of the requested LP

### **withdrawCollateral**
function withdrawCollateral() external
Used to withdraw the locked collateral. It is only for LPs who have resigned
Expand Down
Loading

0 comments on commit cd7fb89

Please sign in to comment.