Skip to content

Commit

Permalink
add token bridge TransferRedeemed event and unify formatting (#61)
Browse files Browse the repository at this point in the history
* add token bridge TransferRedeemed event and unify formatting

* more formatting
  • Loading branch information
nonergodic authored Sep 24, 2024
1 parent f0dec22 commit eff3062
Show file tree
Hide file tree
Showing 4 changed files with 878 additions and 848 deletions.
272 changes: 146 additions & 126 deletions src/interfaces/ITokenBridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,172 +6,192 @@ pragma solidity ^0.8.0;
import "./IWormhole.sol";

interface ITokenBridge {
struct Transfer {
uint8 payloadID;
uint256 amount;
bytes32 tokenAddress;
uint16 tokenChain;
bytes32 to;
uint16 toChain;
uint256 fee;
}

struct TransferWithPayload {
uint8 payloadID;
uint256 amount;
bytes32 tokenAddress;
uint16 tokenChain;
bytes32 to;
uint16 toChain;
bytes32 fromAddress;
bytes payload;
}

struct AssetMeta {
uint8 payloadID;
bytes32 tokenAddress;
uint16 tokenChain;
uint8 decimals;
bytes32 symbol;
bytes32 name;
}
struct Transfer {
uint8 payloadID;
uint256 amount;
bytes32 tokenAddress;
uint16 tokenChain;
bytes32 to;
uint16 toChain;
uint256 fee;
}

struct TransferWithPayload {
uint8 payloadID;
uint256 amount;
bytes32 tokenAddress;
uint16 tokenChain;
bytes32 to;
uint16 toChain;
bytes32 fromAddress;
bytes payload;
}

struct AssetMeta {
uint8 payloadID;
bytes32 tokenAddress;
uint16 tokenChain;
uint8 decimals;
bytes32 symbol;
bytes32 name;
}

struct RegisterChain {
bytes32 module;
uint8 action;
uint16 chainId;
uint16 emitterChainID;
bytes32 emitterAddress;
}

struct UpgradeContract {
bytes32 module;
uint8 action;
uint16 chainId;
bytes32 newContract;
}

struct RecoverChainId {
bytes32 module;
uint8 action;
uint256 evmChainId;
uint16 newChainId;
}

event ContractUpgraded(address indexed oldContract, address indexed newContract);

event TransferRedeemed(
uint16 indexed emitterChainId,
bytes32 indexed emitterAddress,
uint64 indexed sequence
);

function _parseTransferCommon(
bytes memory encoded
) external pure returns (Transfer memory transfer);

struct RegisterChain {
bytes32 module;
uint8 action;
uint16 chainId;
uint16 emitterChainID;
bytes32 emitterAddress;
}
function attestToken(
address tokenAddress,
uint32 nonce
) external payable returns (uint64 sequence);

struct UpgradeContract {
bytes32 module;
uint8 action;
uint16 chainId;
bytes32 newContract;
}
function wrapAndTransferETH(
uint16 recipientChain,
bytes32 recipient,
uint256 arbiterFee,
uint32 nonce
) external payable returns (uint64 sequence);

struct RecoverChainId {
bytes32 module;
uint8 action;
uint256 evmChainId;
uint16 newChainId;
}
function wrapAndTransferETHWithPayload(
uint16 recipientChain,
bytes32 recipient,
uint32 nonce,
bytes memory payload
) external payable returns (uint64 sequence);

event ContractUpgraded(address indexed oldContract, address indexed newContract);
function transferTokens(
address token,
uint256 amount,
uint16 recipientChain,
bytes32 recipient,
uint256 arbiterFee,
uint32 nonce
) external payable returns (uint64 sequence);

function _parseTransferCommon(bytes memory encoded) external pure returns (Transfer memory transfer);
function transferTokensWithPayload(
address token,
uint256 amount,
uint16 recipientChain,
bytes32 recipient,
uint32 nonce,
bytes memory payload
) external payable returns (uint64 sequence);

function attestToken(address tokenAddress, uint32 nonce) external payable returns (uint64 sequence);
function updateWrapped(bytes memory encodedVm) external returns (address token);

function wrapAndTransferETH(uint16 recipientChain, bytes32 recipient, uint256 arbiterFee, uint32 nonce)
external
payable
returns (uint64 sequence);
function createWrapped(bytes memory encodedVm) external returns (address token);

function wrapAndTransferETHWithPayload(uint16 recipientChain, bytes32 recipient, uint32 nonce, bytes memory payload)
external
payable
returns (uint64 sequence);
function completeTransferWithPayload(bytes memory encodedVm) external returns (bytes memory);

function transferTokens(
address token,
uint256 amount,
uint16 recipientChain,
bytes32 recipient,
uint256 arbiterFee,
uint32 nonce
) external payable returns (uint64 sequence);
function completeTransferAndUnwrapETHWithPayload(
bytes memory encodedVm
) external returns (bytes memory);

function transferTokensWithPayload(
address token,
uint256 amount,
uint16 recipientChain,
bytes32 recipient,
uint32 nonce,
bytes memory payload
) external payable returns (uint64 sequence);
function completeTransfer(bytes memory encodedVm) external;

function updateWrapped(bytes memory encodedVm) external returns (address token);
function completeTransferAndUnwrapETH(bytes memory encodedVm) external;

function createWrapped(bytes memory encodedVm) external returns (address token);
function encodeAssetMeta(AssetMeta memory meta) external pure returns (bytes memory encoded);

function completeTransferWithPayload(bytes memory encodedVm) external returns (bytes memory);
function encodeTransfer(Transfer memory transfer) external pure returns (bytes memory encoded);

function completeTransferAndUnwrapETHWithPayload(bytes memory encodedVm) external returns (bytes memory);
function encodeTransferWithPayload(TransferWithPayload memory transfer)
external
pure
returns (bytes memory encoded);

function completeTransfer(bytes memory encodedVm) external;
function parsePayloadID(bytes memory encoded) external pure returns (uint8 payloadID);

function completeTransferAndUnwrapETH(bytes memory encodedVm) external;
function parseAssetMeta(bytes memory encoded) external pure returns (AssetMeta memory meta);

function encodeAssetMeta(AssetMeta memory meta) external pure returns (bytes memory encoded);
function parseTransfer(bytes memory encoded) external pure returns (Transfer memory transfer);

function encodeTransfer(Transfer memory transfer) external pure returns (bytes memory encoded);
function parseTransferWithPayload(bytes memory encoded)
external
pure
returns (TransferWithPayload memory transfer);

function encodeTransferWithPayload(TransferWithPayload memory transfer)
external
pure
returns (bytes memory encoded);
function governanceActionIsConsumed(bytes32 hash) external view returns (bool);

function parsePayloadID(bytes memory encoded) external pure returns (uint8 payloadID);
function isInitialized(address impl) external view returns (bool);

function parseAssetMeta(bytes memory encoded) external pure returns (AssetMeta memory meta);
function isTransferCompleted(bytes32 hash) external view returns (bool);

function parseTransfer(bytes memory encoded) external pure returns (Transfer memory transfer);
function wormhole() external view returns (IWormhole);

function parseTransferWithPayload(bytes memory encoded)
external
pure
returns (TransferWithPayload memory transfer);
function chainId() external view returns (uint16);

function governanceActionIsConsumed(bytes32 hash) external view returns (bool);
function evmChainId() external view returns (uint256);

function isInitialized(address impl) external view returns (bool);
function isFork() external view returns (bool);

function isTransferCompleted(bytes32 hash) external view returns (bool);
function governanceChainId() external view returns (uint16);

function wormhole() external view returns (IWormhole);
function governanceContract() external view returns (bytes32);

function chainId() external view returns (uint16);
function wrappedAsset(uint16 tokenChainId, bytes32 tokenAddress) external view returns (address);

function evmChainId() external view returns (uint256);
function bridgeContracts(uint16 chainId_) external view returns (bytes32);

function isFork() external view returns (bool);
function tokenImplementation() external view returns (address);

function governanceChainId() external view returns (uint16);
function WETH() external view returns (address);

function governanceContract() external view returns (bytes32);
function outstandingBridged(address token) external view returns (uint256);

function wrappedAsset(uint16 tokenChainId, bytes32 tokenAddress) external view returns (address);
function isWrappedAsset(address token) external view returns (bool);

function bridgeContracts(uint16 chainId_) external view returns (bytes32);
function finality() external view returns (uint8);

function tokenImplementation() external view returns (address);
function implementation() external view returns (address);

function WETH() external view returns (address);
function initialize() external;

function outstandingBridged(address token) external view returns (uint256);
function registerChain(bytes memory encodedVM) external;

function isWrappedAsset(address token) external view returns (bool);
function upgrade(bytes memory encodedVM) external;

function finality() external view returns (uint8);
function submitRecoverChainId(bytes memory encodedVM) external;

function implementation() external view returns (address);
function parseRegisterChain(
bytes memory encoded
) external pure returns (RegisterChain memory chain);

function initialize() external;
function parseUpgrade(
bytes memory encoded
) external pure returns (UpgradeContract memory chain);

function registerChain(bytes memory encodedVM) external;

function upgrade(bytes memory encodedVM) external;

function submitRecoverChainId(bytes memory encodedVM) external;

function parseRegisterChain(bytes memory encoded) external pure returns (RegisterChain memory chain);

function parseUpgrade(bytes memory encoded) external pure returns (UpgradeContract memory chain);

function parseRecoverChainId(bytes memory encodedRecoverChainId)
external
pure
returns (RecoverChainId memory rci);
function parseRecoverChainId(
bytes memory encodedRecoverChainId
) external pure returns (RecoverChainId memory rci);
}
Loading

0 comments on commit eff3062

Please sign in to comment.