@@ -166,7 +166,6 @@ contract InterchainTokenFactory is IInterchainTokenFactory, ITokenManagerType, M
166
166
167
167
/**
168
168
* @notice Deploys a remote interchain token on a specified destination chain.
169
- * @param originalChainName The name of the chain where the token originally exists.
170
169
* @param salt The unique salt for deploying the token.
171
170
* @param minter The address to receive the minter and operator role of the token, in addition to ITS. If the address is `address(0)`,
172
171
* no additional minter is set on the token. Reverts if the minter does not have mint permission for the token.
@@ -175,46 +174,60 @@ contract InterchainTokenFactory is IInterchainTokenFactory, ITokenManagerType, M
175
174
* @return tokenId The tokenId corresponding to the deployed InterchainToken.
176
175
*/
177
176
function deployRemoteInterchainToken (
178
- string calldata originalChainName ,
179
177
bytes32 salt ,
180
178
address minter ,
181
179
string memory destinationChain ,
182
180
uint256 gasValue
183
- ) external payable returns (bytes32 tokenId ) {
181
+ ) public payable returns (bytes32 tokenId ) {
184
182
string memory tokenName;
185
183
string memory tokenSymbol;
186
184
uint8 tokenDecimals;
187
185
bytes memory minter_ = new bytes (0 );
188
186
189
- {
190
- bytes32 chainNameHash_;
191
- if (bytes (originalChainName).length == 0 ) {
192
- chainNameHash_ = chainNameHash;
193
- } else {
194
- chainNameHash_ = keccak256 (bytes (originalChainName));
195
- }
187
+ salt = interchainTokenSalt (chainNameHash, msg .sender , salt);
188
+ tokenId = interchainTokenService.interchainTokenId (TOKEN_FACTORY_DEPLOYER, salt);
196
189
197
- address sender = msg .sender ;
198
- salt = interchainTokenSalt (chainNameHash_, sender, salt);
199
- tokenId = interchainTokenService.interchainTokenId (TOKEN_FACTORY_DEPLOYER, salt);
190
+ IInterchainToken token = IInterchainToken (interchainTokenService.interchainTokenAddress (tokenId));
200
191
201
- IInterchainToken token = IInterchainToken (interchainTokenService.interchainTokenAddress (tokenId));
202
-
203
- tokenName = token.name ();
204
- tokenSymbol = token.symbol ();
205
- tokenDecimals = token.decimals ();
192
+ tokenName = token.name ();
193
+ tokenSymbol = token.symbol ();
194
+ tokenDecimals = token.decimals ();
206
195
207
- if (minter != address (0 )) {
208
- if (! token.isMinter (minter)) revert NotMinter (minter);
209
- if (minter == address (interchainTokenService)) revert InvalidMinter (minter);
196
+ if (minter != address (0 )) {
197
+ if (! token.isMinter (minter)) revert NotMinter (minter);
198
+ if (minter == address (interchainTokenService)) revert InvalidMinter (minter);
210
199
211
- minter_ = minter.toBytes ();
212
- }
200
+ minter_ = minter.toBytes ();
213
201
}
214
202
215
203
tokenId = _deployInterchainToken (salt, destinationChain, tokenName, tokenSymbol, tokenDecimals, minter_, gasValue);
216
204
}
217
205
206
+ /**
207
+ * @notice Deploys a remote interchain token on a specified destination chain.
208
+ * This method is deprecated and will be removed in the future. Please use the above method instead.
209
+ * @dev originalChainName is only allowed to be '', i.e the current chain.
210
+ * Other source chains are not supported anymore to simplify ITS token deployment behaviour.
211
+ * @param originalChainName The name of the chain where the token originally exists.
212
+ * @param salt The unique salt for deploying the token.
213
+ * @param minter The address to receive the minter and operator role of the token, in addition to ITS. If the address is `address(0)`,
214
+ * no additional minter is set on the token. Reverts if the minter does not have mint permission for the token.
215
+ * @param destinationChain The name of the destination chain.
216
+ * @param gasValue The amount of gas to send for the deployment.
217
+ * @return tokenId The tokenId corresponding to the deployed InterchainToken.
218
+ */
219
+ function deployRemoteInterchainToken (
220
+ string calldata originalChainName ,
221
+ bytes32 salt ,
222
+ address minter ,
223
+ string memory destinationChain ,
224
+ uint256 gasValue
225
+ ) external payable returns (bytes32 tokenId ) {
226
+ if (bytes (originalChainName).length != 0 ) revert NotSupported ();
227
+
228
+ tokenId = deployRemoteInterchainToken (salt, minter, destinationChain, gasValue);
229
+ }
230
+
218
231
/**
219
232
* @notice Deploys a new interchain token with specified parameters.
220
233
* @param salt The unique salt for deploying the token.
@@ -263,33 +276,23 @@ contract InterchainTokenFactory is IInterchainTokenFactory, ITokenManagerType, M
263
276
264
277
/**
265
278
* @notice Deploys a canonical interchain token on a remote chain.
266
- * @param originalChain The name of the chain where the token originally exists.
267
279
* @param originalTokenAddress The address of the original token on the original chain.
268
280
* @param destinationChain The name of the chain where the token will be deployed.
269
281
* @param gasValue The gas amount to be sent for deployment.
270
282
* @return tokenId The tokenId corresponding to the deployed InterchainToken.
271
283
*/
272
284
function deployRemoteCanonicalInterchainToken (
273
- string calldata originalChain ,
274
285
address originalTokenAddress ,
275
286
string calldata destinationChain ,
276
287
uint256 gasValue
277
- ) external payable returns (bytes32 tokenId ) {
288
+ ) public payable returns (bytes32 tokenId ) {
278
289
bytes32 salt;
279
290
IInterchainToken token;
280
291
281
- {
282
- bytes32 chainNameHash_;
283
- if (bytes (originalChain).length == 0 ) {
284
- chainNameHash_ = chainNameHash;
285
- } else {
286
- chainNameHash_ = keccak256 (bytes (originalChain));
287
- }
288
- // This ensures that the token manager has been deployed by this address, so it's safe to trust it.
289
- salt = canonicalInterchainTokenSalt (chainNameHash_, originalTokenAddress);
290
- tokenId = interchainTokenService.interchainTokenId (TOKEN_FACTORY_DEPLOYER, salt);
291
- token = IInterchainToken (interchainTokenService.validTokenAddress (tokenId));
292
- }
292
+ // This ensures that the token manager has been deployed by this address, so it's safe to trust it.
293
+ salt = canonicalInterchainTokenSalt (chainNameHash, originalTokenAddress);
294
+ tokenId = interchainTokenService.interchainTokenId (TOKEN_FACTORY_DEPLOYER, salt);
295
+ token = IInterchainToken (interchainTokenService.validTokenAddress (tokenId));
293
296
294
297
// The 3 lines below will revert if the token does not exist.
295
298
string memory tokenName = token.name ();
@@ -299,6 +302,28 @@ contract InterchainTokenFactory is IInterchainTokenFactory, ITokenManagerType, M
299
302
tokenId = _deployInterchainToken (salt, destinationChain, tokenName, tokenSymbol, tokenDecimals, '' , gasValue);
300
303
}
301
304
305
+ /**
306
+ * @notice Deploys a canonical interchain token on a remote chain.
307
+ * This method is deprecated and will be removed in the future. Please use the above method instead.
308
+ * @dev originalChain is only allowed to be '', i.e the current chain.
309
+ * Other source chains are not supported anymore to simplify ITS token deployment behaviour.
310
+ * @param originalChain The name of the chain where the token originally exists.
311
+ * @param originalTokenAddress The address of the original token on the original chain.
312
+ * @param destinationChain The name of the chain where the token will be deployed.
313
+ * @param gasValue The gas amount to be sent for deployment.
314
+ * @return tokenId The tokenId corresponding to the deployed InterchainToken.
315
+ */
316
+ function deployRemoteCanonicalInterchainToken (
317
+ string calldata originalChain ,
318
+ address originalTokenAddress ,
319
+ string calldata destinationChain ,
320
+ uint256 gasValue
321
+ ) external payable returns (bytes32 tokenId ) {
322
+ if (bytes (originalChain).length != 0 ) revert NotSupported ();
323
+
324
+ tokenId = deployRemoteCanonicalInterchainToken (originalTokenAddress, destinationChain, gasValue);
325
+ }
326
+
302
327
/**
303
328
* @notice Register 'canonical' gateway tokens. The same salt needs to be used for the same gateway token on every chain.
304
329
* @param tokenIdentifier A gateway token identifier to be used for the token registration. Should be the same for all chains.
0 commit comments