Skip to content

Commit eff3062

Browse files
authored
add token bridge TransferRedeemed event and unify formatting (#61)
* add token bridge TransferRedeemed event and unify formatting * more formatting
1 parent f0dec22 commit eff3062

File tree

4 files changed

+878
-848
lines changed

4 files changed

+878
-848
lines changed

src/interfaces/ITokenBridge.sol

Lines changed: 146 additions & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -6,172 +6,192 @@ pragma solidity ^0.8.0;
66
import "./IWormhole.sol";
77

88
interface ITokenBridge {
9-
struct Transfer {
10-
uint8 payloadID;
11-
uint256 amount;
12-
bytes32 tokenAddress;
13-
uint16 tokenChain;
14-
bytes32 to;
15-
uint16 toChain;
16-
uint256 fee;
17-
}
18-
19-
struct TransferWithPayload {
20-
uint8 payloadID;
21-
uint256 amount;
22-
bytes32 tokenAddress;
23-
uint16 tokenChain;
24-
bytes32 to;
25-
uint16 toChain;
26-
bytes32 fromAddress;
27-
bytes payload;
28-
}
29-
30-
struct AssetMeta {
31-
uint8 payloadID;
32-
bytes32 tokenAddress;
33-
uint16 tokenChain;
34-
uint8 decimals;
35-
bytes32 symbol;
36-
bytes32 name;
37-
}
9+
struct Transfer {
10+
uint8 payloadID;
11+
uint256 amount;
12+
bytes32 tokenAddress;
13+
uint16 tokenChain;
14+
bytes32 to;
15+
uint16 toChain;
16+
uint256 fee;
17+
}
18+
19+
struct TransferWithPayload {
20+
uint8 payloadID;
21+
uint256 amount;
22+
bytes32 tokenAddress;
23+
uint16 tokenChain;
24+
bytes32 to;
25+
uint16 toChain;
26+
bytes32 fromAddress;
27+
bytes payload;
28+
}
29+
30+
struct AssetMeta {
31+
uint8 payloadID;
32+
bytes32 tokenAddress;
33+
uint16 tokenChain;
34+
uint8 decimals;
35+
bytes32 symbol;
36+
bytes32 name;
37+
}
38+
39+
struct RegisterChain {
40+
bytes32 module;
41+
uint8 action;
42+
uint16 chainId;
43+
uint16 emitterChainID;
44+
bytes32 emitterAddress;
45+
}
46+
47+
struct UpgradeContract {
48+
bytes32 module;
49+
uint8 action;
50+
uint16 chainId;
51+
bytes32 newContract;
52+
}
53+
54+
struct RecoverChainId {
55+
bytes32 module;
56+
uint8 action;
57+
uint256 evmChainId;
58+
uint16 newChainId;
59+
}
60+
61+
event ContractUpgraded(address indexed oldContract, address indexed newContract);
62+
63+
event TransferRedeemed(
64+
uint16 indexed emitterChainId,
65+
bytes32 indexed emitterAddress,
66+
uint64 indexed sequence
67+
);
68+
69+
function _parseTransferCommon(
70+
bytes memory encoded
71+
) external pure returns (Transfer memory transfer);
3872

39-
struct RegisterChain {
40-
bytes32 module;
41-
uint8 action;
42-
uint16 chainId;
43-
uint16 emitterChainID;
44-
bytes32 emitterAddress;
45-
}
73+
function attestToken(
74+
address tokenAddress,
75+
uint32 nonce
76+
) external payable returns (uint64 sequence);
4677

47-
struct UpgradeContract {
48-
bytes32 module;
49-
uint8 action;
50-
uint16 chainId;
51-
bytes32 newContract;
52-
}
78+
function wrapAndTransferETH(
79+
uint16 recipientChain,
80+
bytes32 recipient,
81+
uint256 arbiterFee,
82+
uint32 nonce
83+
) external payable returns (uint64 sequence);
5384

54-
struct RecoverChainId {
55-
bytes32 module;
56-
uint8 action;
57-
uint256 evmChainId;
58-
uint16 newChainId;
59-
}
85+
function wrapAndTransferETHWithPayload(
86+
uint16 recipientChain,
87+
bytes32 recipient,
88+
uint32 nonce,
89+
bytes memory payload
90+
) external payable returns (uint64 sequence);
6091

61-
event ContractUpgraded(address indexed oldContract, address indexed newContract);
92+
function transferTokens(
93+
address token,
94+
uint256 amount,
95+
uint16 recipientChain,
96+
bytes32 recipient,
97+
uint256 arbiterFee,
98+
uint32 nonce
99+
) external payable returns (uint64 sequence);
62100

63-
function _parseTransferCommon(bytes memory encoded) external pure returns (Transfer memory transfer);
101+
function transferTokensWithPayload(
102+
address token,
103+
uint256 amount,
104+
uint16 recipientChain,
105+
bytes32 recipient,
106+
uint32 nonce,
107+
bytes memory payload
108+
) external payable returns (uint64 sequence);
64109

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

67-
function wrapAndTransferETH(uint16 recipientChain, bytes32 recipient, uint256 arbiterFee, uint32 nonce)
68-
external
69-
payable
70-
returns (uint64 sequence);
112+
function createWrapped(bytes memory encodedVm) external returns (address token);
71113

72-
function wrapAndTransferETHWithPayload(uint16 recipientChain, bytes32 recipient, uint32 nonce, bytes memory payload)
73-
external
74-
payable
75-
returns (uint64 sequence);
114+
function completeTransferWithPayload(bytes memory encodedVm) external returns (bytes memory);
76115

77-
function transferTokens(
78-
address token,
79-
uint256 amount,
80-
uint16 recipientChain,
81-
bytes32 recipient,
82-
uint256 arbiterFee,
83-
uint32 nonce
84-
) external payable returns (uint64 sequence);
116+
function completeTransferAndUnwrapETHWithPayload(
117+
bytes memory encodedVm
118+
) external returns (bytes memory);
85119

86-
function transferTokensWithPayload(
87-
address token,
88-
uint256 amount,
89-
uint16 recipientChain,
90-
bytes32 recipient,
91-
uint32 nonce,
92-
bytes memory payload
93-
) external payable returns (uint64 sequence);
120+
function completeTransfer(bytes memory encodedVm) external;
94121

95-
function updateWrapped(bytes memory encodedVm) external returns (address token);
122+
function completeTransferAndUnwrapETH(bytes memory encodedVm) external;
96123

97-
function createWrapped(bytes memory encodedVm) external returns (address token);
124+
function encodeAssetMeta(AssetMeta memory meta) external pure returns (bytes memory encoded);
98125

99-
function completeTransferWithPayload(bytes memory encodedVm) external returns (bytes memory);
126+
function encodeTransfer(Transfer memory transfer) external pure returns (bytes memory encoded);
100127

101-
function completeTransferAndUnwrapETHWithPayload(bytes memory encodedVm) external returns (bytes memory);
128+
function encodeTransferWithPayload(TransferWithPayload memory transfer)
129+
external
130+
pure
131+
returns (bytes memory encoded);
102132

103-
function completeTransfer(bytes memory encodedVm) external;
133+
function parsePayloadID(bytes memory encoded) external pure returns (uint8 payloadID);
104134

105-
function completeTransferAndUnwrapETH(bytes memory encodedVm) external;
135+
function parseAssetMeta(bytes memory encoded) external pure returns (AssetMeta memory meta);
106136

107-
function encodeAssetMeta(AssetMeta memory meta) external pure returns (bytes memory encoded);
137+
function parseTransfer(bytes memory encoded) external pure returns (Transfer memory transfer);
108138

109-
function encodeTransfer(Transfer memory transfer) external pure returns (bytes memory encoded);
139+
function parseTransferWithPayload(bytes memory encoded)
140+
external
141+
pure
142+
returns (TransferWithPayload memory transfer);
110143

111-
function encodeTransferWithPayload(TransferWithPayload memory transfer)
112-
external
113-
pure
114-
returns (bytes memory encoded);
144+
function governanceActionIsConsumed(bytes32 hash) external view returns (bool);
115145

116-
function parsePayloadID(bytes memory encoded) external pure returns (uint8 payloadID);
146+
function isInitialized(address impl) external view returns (bool);
117147

118-
function parseAssetMeta(bytes memory encoded) external pure returns (AssetMeta memory meta);
148+
function isTransferCompleted(bytes32 hash) external view returns (bool);
119149

120-
function parseTransfer(bytes memory encoded) external pure returns (Transfer memory transfer);
150+
function wormhole() external view returns (IWormhole);
121151

122-
function parseTransferWithPayload(bytes memory encoded)
123-
external
124-
pure
125-
returns (TransferWithPayload memory transfer);
152+
function chainId() external view returns (uint16);
126153

127-
function governanceActionIsConsumed(bytes32 hash) external view returns (bool);
154+
function evmChainId() external view returns (uint256);
128155

129-
function isInitialized(address impl) external view returns (bool);
156+
function isFork() external view returns (bool);
130157

131-
function isTransferCompleted(bytes32 hash) external view returns (bool);
158+
function governanceChainId() external view returns (uint16);
132159

133-
function wormhole() external view returns (IWormhole);
160+
function governanceContract() external view returns (bytes32);
134161

135-
function chainId() external view returns (uint16);
162+
function wrappedAsset(uint16 tokenChainId, bytes32 tokenAddress) external view returns (address);
136163

137-
function evmChainId() external view returns (uint256);
164+
function bridgeContracts(uint16 chainId_) external view returns (bytes32);
138165

139-
function isFork() external view returns (bool);
166+
function tokenImplementation() external view returns (address);
140167

141-
function governanceChainId() external view returns (uint16);
168+
function WETH() external view returns (address);
142169

143-
function governanceContract() external view returns (bytes32);
170+
function outstandingBridged(address token) external view returns (uint256);
144171

145-
function wrappedAsset(uint16 tokenChainId, bytes32 tokenAddress) external view returns (address);
172+
function isWrappedAsset(address token) external view returns (bool);
146173

147-
function bridgeContracts(uint16 chainId_) external view returns (bytes32);
174+
function finality() external view returns (uint8);
148175

149-
function tokenImplementation() external view returns (address);
176+
function implementation() external view returns (address);
150177

151-
function WETH() external view returns (address);
178+
function initialize() external;
152179

153-
function outstandingBridged(address token) external view returns (uint256);
180+
function registerChain(bytes memory encodedVM) external;
154181

155-
function isWrappedAsset(address token) external view returns (bool);
182+
function upgrade(bytes memory encodedVM) external;
156183

157-
function finality() external view returns (uint8);
184+
function submitRecoverChainId(bytes memory encodedVM) external;
158185

159-
function implementation() external view returns (address);
186+
function parseRegisterChain(
187+
bytes memory encoded
188+
) external pure returns (RegisterChain memory chain);
160189

161-
function initialize() external;
190+
function parseUpgrade(
191+
bytes memory encoded
192+
) external pure returns (UpgradeContract memory chain);
162193

163-
function registerChain(bytes memory encodedVM) external;
164-
165-
function upgrade(bytes memory encodedVM) external;
166-
167-
function submitRecoverChainId(bytes memory encodedVM) external;
168-
169-
function parseRegisterChain(bytes memory encoded) external pure returns (RegisterChain memory chain);
170-
171-
function parseUpgrade(bytes memory encoded) external pure returns (UpgradeContract memory chain);
172-
173-
function parseRecoverChainId(bytes memory encodedRecoverChainId)
174-
external
175-
pure
176-
returns (RecoverChainId memory rci);
194+
function parseRecoverChainId(
195+
bytes memory encodedRecoverChainId
196+
) external pure returns (RecoverChainId memory rci);
177197
}

0 commit comments

Comments
 (0)