Skip to content

Commit

Permalink
Merge branch 'master' into fe/airdrop-decimals
Browse files Browse the repository at this point in the history
  • Loading branch information
abtestingalpha committed Sep 26, 2024
2 parents 58b872e + ebf102c commit d96f06d
Show file tree
Hide file tree
Showing 41 changed files with 2,217 additions and 48 deletions.
16 changes: 16 additions & 0 deletions packages/contracts-rfq/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,22 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [0.5.6](https://github.com/synapsecns/sanguine/compare/@synapsecns/[email protected]...@synapsecns/[email protected]) (2024-09-26)

**Note:** Version bump only for package @synapsecns/contracts-rfq





## [0.5.5](https://github.com/synapsecns/sanguine/compare/@synapsecns/[email protected]...@synapsecns/[email protected]) (2024-09-26)

**Note:** Version bump only for package @synapsecns/contracts-rfq





## [0.5.4](https://github.com/synapsecns/sanguine/compare/@synapsecns/[email protected]...@synapsecns/[email protected]) (2024-09-26)

**Note:** Version bump only for package @synapsecns/contracts-rfq
Expand Down
18 changes: 14 additions & 4 deletions packages/contracts-rfq/contracts/FastBridgeV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ contract FastBridgeV2 is Admin, IFastBridgeV2, IFastBridgeV2Errors {
mapping(bytes32 => BridgeStatus) public bridgeStatuses;
/// @notice Proof of relayed bridge tx on origin chain
mapping(bytes32 => BridgeProof) public bridgeProofs;
/// @notice Whether bridge has been relayed on destination chain
mapping(bytes32 => bool) public bridgeRelays;
/// @notice Relay details on destination chain
mapping(bytes32 => BridgeRelay) public bridgeRelayDetails;

/// @dev to prevent replays
uint256 public nonce;
Expand Down Expand Up @@ -80,6 +80,7 @@ contract FastBridgeV2 is Admin, IFastBridgeV2, IFastBridgeV2Errors {
// check bridge params
if (params.dstChainId == block.chainid) revert ChainIncorrect();
if (params.originAmount == 0 || params.destAmount == 0) revert AmountIncorrect();
if (params.sender == address(0) || params.to == address(0)) revert ZeroAddress();
if (params.originToken == address(0) || params.destToken == address(0)) revert ZeroAddress();
if (params.deadline < block.timestamp + MIN_DEADLINE_PERIOD) revert DeadlineTooShort();

Expand Down Expand Up @@ -132,16 +133,19 @@ contract FastBridgeV2 is Admin, IFastBridgeV2, IFastBridgeV2Errors {

/// @inheritdoc IFastBridgeV2
function relay(bytes memory request, address relayer) public payable {
if (relayer == address(0)) revert ZeroAddress();
bytes32 transactionId = keccak256(request);
BridgeTransaction memory transaction = getBridgeTransaction(request);
if (transaction.destChainId != uint32(block.chainid)) revert ChainIncorrect();

// check haven't exceeded deadline for relay to happen
if (block.timestamp > transaction.deadline) revert DeadlineExceeded();

if (bridgeRelayDetails[transactionId].relayer != address(0)) revert TransactionRelayed();

// mark bridge transaction as relayed
if (bridgeRelays[transactionId]) revert TransactionRelayed();
bridgeRelays[transactionId] = true;
bridgeRelayDetails[transactionId] =
BridgeRelay({blockNumber: uint48(block.number), blockTimestamp: uint48(block.timestamp), relayer: relayer});

// transfer tokens to recipient on destination chain and gas rebate if requested
address to = transaction.destRecipient;
Expand Down Expand Up @@ -175,6 +179,12 @@ contract FastBridgeV2 is Admin, IFastBridgeV2, IFastBridgeV2Errors {
);
}

/// @inheritdoc IFastBridgeV2
function bridgeRelays(bytes32 transactionId) public view returns (bool) {
// has this transactionId been relayed?
return bridgeRelayDetails[transactionId].relayer != address(0);
}

/// @inheritdoc IFastBridge
function prove(bytes memory request, bytes32 destTxHash) external {
bytes32 transactionId = keccak256(request);
Expand Down
10 changes: 10 additions & 0 deletions packages/contracts-rfq/contracts/interfaces/IFastBridgeV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ pragma solidity ^0.8.20;
import {IFastBridge} from "./IFastBridge.sol";

interface IFastBridgeV2 is IFastBridge {
struct BridgeRelay {
uint48 blockNumber;
uint48 blockTimestamp;
address relayer;
}

/// @notice Relays destination side of bridge transaction by off-chain relayer
/// @param request The encoded bridge transaction to relay on destination chain
/// @param relayer The address of the relaying entity which should have control of the origin funds when claimed
Expand All @@ -19,4 +25,8 @@ interface IFastBridgeV2 is IFastBridge {
/// @notice Can only send funds to the relayer address on the proof.
/// @param request The encoded bridge transaction to claim on origin chain
function claim(bytes memory request) external;
/// @notice Checks if a transaction has been relayed
/// @param transactionId The ID of the transaction to check
/// @return True if the transaction has been relayed, false otherwise
function bridgeRelays(bytes32 transactionId) external view returns (bool);
}
2 changes: 1 addition & 1 deletion packages/contracts-rfq/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@synapsecns/contracts-rfq",
"license": "MIT",
"version": "0.5.4",
"version": "0.5.6",
"description": "FastBridge contracts.",
"private": true,
"files": [
Expand Down
22 changes: 22 additions & 0 deletions packages/contracts-rfq/test/FastBridgeV2.Dst.t.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import {ChainIncorrect, DeadlineExceeded, TransactionRelayed, ZeroAddress} from "../contracts/libs/Errors.sol";

import {FastBridgeV2, FastBridgeV2Test, IFastBridge} from "./FastBridgeV2.t.sol";

// solhint-disable func-name-mixedcase, ordering
Expand Down Expand Up @@ -113,6 +115,21 @@ contract FastBridgeV2DstTest is FastBridgeV2Test {
assertEq(address(fastBridge).balance, 0);
}

/// @notice RelayerB completes the ETH bridge request, using relayerA's address
function test_relay_eth_withRelayerAddress_checkBlockData() public {
vm.roll(987_654_321);
vm.warp(123_456_789);
bytes32 txId = getTxId(ethTx);
expectBridgeRelayed(ethTx, txId, address(relayerA));
relayWithAddress({caller: relayerB, relayer: relayerA, msgValue: ethParams.destAmount, bridgeTx: ethTx});
assertTrue(fastBridge.bridgeRelays(txId));
(uint48 recordedBlockNumber, uint48 recordedblockTimestamp,) = fastBridge.bridgeRelayDetails(txId);
assertEq(recordedBlockNumber, 987_654_321);
assertEq(recordedblockTimestamp, 123_456_789);
assertEq(address(userB).balance, ethParams.destAmount);
assertEq(address(relayerB).balance, LEFTOVER_BALANCE);
assertEq(address(fastBridge).balance, 0);
}
// ══════════════════════════════════════════════════ REVERTS ══════════════════════════════════════════════════════

function test_relay_revert_chainIncorrect() public {
Expand Down Expand Up @@ -150,4 +167,9 @@ contract FastBridgeV2DstTest is FastBridgeV2Test {
vm.expectRevert(DeadlineExceeded.selector);
relayWithAddress({caller: relayerA, relayer: relayerB, msgValue: 0, bridgeTx: tokenTx});
}

function test_relay_withRelayerAddress_revert_zeroAddr() public {
vm.expectRevert(ZeroAddress.selector);
relayWithAddress({caller: relayerA, relayer: address(0), msgValue: 0, bridgeTx: tokenTx});
}
}
2 changes: 0 additions & 2 deletions packages/contracts-rfq/test/FastBridgeV2.Src.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -275,14 +275,12 @@ contract FastBridgeV2SrcTest is FastBridgeV2Test {
}

function test_bridge_revert_zeroSender() public {
vm.skip(true); // TODO: unskip when fixed
tokenParams.sender = address(0);
vm.expectRevert(ZeroAddress.selector);
bridge({caller: userA, msgValue: 0, params: tokenParams});
}

function test_bridge_revert_zeroRecipient() public {
vm.skip(true); // TODO: unskip when fixed
tokenParams.to = address(0);
vm.expectRevert(ZeroAddress.selector);
bridge({caller: userA, msgValue: 0, params: tokenParams});
Expand Down
8 changes: 8 additions & 0 deletions packages/explorer-ui/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [0.3.3](https://github.com/synapsecns/sanguine/compare/@synapsecns/[email protected]...@synapsecns/[email protected]) (2024-09-26)

**Note:** Version bump only for package @synapsecns/explorer-ui





## [0.3.2](https://github.com/synapsecns/sanguine/compare/@synapsecns/[email protected]...@synapsecns/[email protected]) (2024-09-10)

**Note:** Version bump only for package @synapsecns/explorer-ui
Expand Down
2 changes: 1 addition & 1 deletion packages/explorer-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@synapsecns/explorer-ui",
"version": "0.3.2",
"version": "0.3.3",
"private": true,
"engines": {
"node": ">=18.17.0"
Expand Down
12 changes: 9 additions & 3 deletions packages/explorer-ui/pages/tx/[kappa].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { API_URL } from '@graphql'
import { HorizontalDivider } from '@components/misc/HorizontalDivider'
import { formatDateTimestamp } from '@utils/formatDate'
import { IconAndAmount } from '@components/misc/IconAndAmount'

import { addressToSymbol } from '@utils/addressToSymbol'
const CHAINS_BY_ID = CHAINS.CHAINS_BY_ID

const link = new HttpLink({
Expand Down Expand Up @@ -157,7 +157,10 @@ export const BridgeTransaction = ({ queryResult }) => {
value={fromInfo.value}
tokenAddress={fromInfo.tokenAddress}
chainId={fromInfo.chainID}
tokenSymbol={fromInfo.tokenSymbol}
tokenSymbol={addressToSymbol({
tokenAddress: fromInfo.tokenAddress,
chainId: fromInfo.chainID,
})}
iconSize="w-4 h-4"
// textSize="text-sm"
// styledCoin={true}
Expand All @@ -183,7 +186,10 @@ export const BridgeTransaction = ({ queryResult }) => {
value={toInfo.value}
tokenAddress={toInfo.tokenAddress}
chainId={toInfo.chainID}
tokenSymbol={toInfo.tokenSymbol}
tokenSymbol={addressToSymbol({
tokenAddress: toInfo.tokenAddress,
chainId: toInfo.chainID,
})}
iconSize="w-4 h-4"
// textSize="text-sm"
// styledCoin={true}
Expand Down
16 changes: 16 additions & 0 deletions packages/rest-api/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,22 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [1.3.2](https://github.com/synapsecns/sanguine/compare/@synapsecns/[email protected]...@synapsecns/[email protected]) (2024-09-26)

**Note:** Version bump only for package @synapsecns/rest-api





## [1.3.1](https://github.com/synapsecns/sanguine/compare/@synapsecns/[email protected]...@synapsecns/[email protected]) (2024-09-26)

**Note:** Version bump only for package @synapsecns/rest-api





# [1.3.0](https://github.com/synapsecns/sanguine/compare/@synapsecns/[email protected]...@synapsecns/[email protected]) (2024-09-25)


Expand Down
4 changes: 2 additions & 2 deletions packages/rest-api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@synapsecns/rest-api",
"version": "1.3.0",
"version": "1.3.2",
"private": "true",
"engines": {
"node": ">=18.17.0"
Expand All @@ -22,7 +22,7 @@
"@ethersproject/bignumber": "^5.7.0",
"@ethersproject/providers": "^5.7.2",
"@ethersproject/units": "5.7.0",
"@synapsecns/sdk-router": "^0.11.1",
"@synapsecns/sdk-router": "^0.11.2",
"bignumber": "^1.1.0",
"ethers": "5.7.2",
"express": "^4.18.2",
Expand Down
8 changes: 6 additions & 2 deletions packages/rest-api/src/controllers/destinationTxController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { validationResult } from 'express-validator'
import { ethers } from 'ethers'

import { getTokenDecimals } from '../utils/getTokenDecimals'
import { tokenAddressToToken } from '../utils/tokenAddressToToken'

export const destinationTxController = async (req, res) => {
const errors = validationResult(req)
Expand Down Expand Up @@ -47,15 +48,18 @@ export const destinationTxController = async (req, res) => {
const toInfo = graphqlData.data.bridgeTransactions[0]?.toInfo || null

if (toInfo) {
const { tokenAddress, value, ...restToInfo } = toInfo
const { tokenAddress, value, chainID, ...restToInfo } = toInfo

const tokenDecimals = getTokenDecimals(toInfo.chainID, tokenAddress)
const tokenInfo = tokenAddressToToken(chainID.toString(), tokenAddress)
const tokenDecimals = getTokenDecimals(chainID, tokenAddress)
const formattedValue = ethers.utils.formatUnits(value, tokenDecimals)

res.json({
status: 'completed',
toInfo: {
chainID,
...restToInfo,
tokenSymbol: tokenInfo ? tokenInfo?.symbol : null,
formattedValue: `${formattedValue}`,
},
})
Expand Down
11 changes: 11 additions & 0 deletions packages/sdk-router/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [0.11.2](https://github.com/synapsecns/sanguine/compare/@synapsecns/[email protected]...@synapsecns/[email protected]) (2024-09-26)


### Bug Fixes

* **sdk-router:** disable ARB airdrop tests ([#3195](https://github.com/synapsecns/sanguine/issues/3195)) ([fc6ddae](https://github.com/synapsecns/sanguine/commit/fc6ddaedf03f7769dab362f0bcdf81a3dd010516))





## [0.11.1](https://github.com/synapsecns/sanguine/compare/@synapsecns/[email protected]...@synapsecns/[email protected]) (2024-09-04)

**Note:** Version bump only for package @synapsecns/sdk-router
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk-router/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@synapsecns/sdk-router",
"description": "An SDK for interacting with the Synapse Protocol",
"version": "0.11.1",
"version": "0.11.2",
"license": "MIT",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
Expand Down
27 changes: 27 additions & 0 deletions packages/synapse-interface/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,33 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [0.40.0](https://github.com/synapsecns/sanguine/compare/@synapsecns/[email protected]...@synapsecns/[email protected]) (2024-09-26)


### Features

* **synapse-interface:** refund RFQ transaction [SLT-272] ([#3197](https://github.com/synapsecns/sanguine/issues/3197)) ([f0b13bc](https://github.com/synapsecns/sanguine/commit/f0b13bc456620004a1787f62e87f404d95272356))





## [0.39.2](https://github.com/synapsecns/sanguine/compare/@synapsecns/[email protected]...@synapsecns/[email protected]) (2024-09-26)

**Note:** Version bump only for package @synapsecns/synapse-interface





## [0.39.1](https://github.com/synapsecns/sanguine/compare/@synapsecns/[email protected]...@synapsecns/[email protected]) (2024-09-26)

**Note:** Version bump only for package @synapsecns/synapse-interface





# [0.39.0](https://github.com/synapsecns/sanguine/compare/@synapsecns/[email protected]...@synapsecns/[email protected]) (2024-09-23)


Expand Down
2 changes: 1 addition & 1 deletion packages/synapse-interface/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next

## Getting Started

First, run the development server:
First, run development server:

```bash
yarn dev
Expand Down
Loading

0 comments on commit d96f06d

Please sign in to comment.