Skip to content

Commit

Permalink
updated
Browse files Browse the repository at this point in the history
  • Loading branch information
ahramy committed Nov 5, 2024
1 parent c9224c5 commit 513f387
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 16 deletions.
2 changes: 1 addition & 1 deletion contracts/InterchainTokenFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ contract InterchainTokenFactory is IInterchainTokenFactory, ITokenManagerType, M
// This ensures that the token manager has been deployed by this address, so it's safe to trust it.
salt = canonicalInterchainTokenSalt(chainNameHash, originalTokenAddress);
tokenId = interchainTokenService.interchainTokenId(TOKEN_FACTORY_DEPLOYER, salt);
token = IInterchainToken(interchainTokenService.getManagedTokenAddress(tokenId));
token = IInterchainToken(interchainTokenService.registeredTokenAddress(tokenId));

// The 3 lines below will revert if the token does not exist.
string memory tokenName = token.name();
Expand Down
10 changes: 6 additions & 4 deletions contracts/InterchainTokenService.sol
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ contract InterchainTokenService is
* @notice Returns the instance of ITokenManager from a specific tokenId.
* @dev This function checks if a token manager contract exists at the address for the specified tokenId.
* If no token manager is deployed for the tokenId, the function will revert with `TokenManagerDoesNotExist`.
* @param tokenId The tokenId.
* @param tokenId The tokenId of the deployed token manager.
* @return tokenManager_ The instance of ITokenManager associated with the specified tokenId.
*/
function deployedTokenManager(bytes32 tokenId) public view returns (ITokenManager tokenManager_) {
Expand All @@ -209,10 +209,12 @@ contract InterchainTokenService is

/**
* @notice Returns the address of the token that an existing tokenManager points to.
* @param tokenId The tokenId.
* @dev This function requires that a token manager is already deployed for the specified tokenId.
* It will call `deployedTokenManager` to get the token manager and return the address of the associated token.
* @param tokenId The tokenId of the registered token.
* @return tokenAddress The address of the token.
*/
function getManagedTokenAddress(bytes32 tokenId) public view returns (address tokenAddress) {
function registeredTokenAddress(bytes32 tokenId) public view returns (address tokenAddress) {
tokenAddress = ITokenManager(deployedTokenManager(tokenId)).tokenAddress();
}

Expand Down Expand Up @@ -1089,7 +1091,7 @@ contract InterchainTokenService is
revert InvalidExpressMessageType(messageType);
}

return (getManagedTokenAddress(tokenId), amount);
return (registeredTokenAddress(tokenId), amount);
}

function _getExpressExecutorAndEmitEvent(
Expand Down
6 changes: 3 additions & 3 deletions contracts/interfaces/IInterchainTokenService.sol
Original file line number Diff line number Diff line change
Expand Up @@ -138,17 +138,17 @@ interface IInterchainTokenService is

/**
* @notice Returns the instance of ITokenManager from a specific tokenId.
* @param tokenId The tokenId.
* @param tokenId The tokenId of the deployed token manager.
* @return tokenManager_ The instance of ITokenManager associated with the specified tokenId.
*/
function deployedTokenManager(bytes32 tokenId) external view returns (ITokenManager tokenManager_);

/**
* @notice Returns the address of the token that an existing tokenManager points to.
* @param tokenId The tokenId of the token manager.
* @param tokenId The tokenId of the registered token.
* @return tokenAddress The address of the token.
*/
function getManagedTokenAddress(bytes32 tokenId) external view returns (address tokenAddress);
function registeredTokenAddress(bytes32 tokenId) external view returns (address tokenAddress);

/**
* @notice Returns the address of the interchain token associated with the given tokenId.
Expand Down
8 changes: 4 additions & 4 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -548,10 +548,10 @@ _The TokenManager needs to exist already._
| --------------------- | ------- | ------------------------------------------- |
| tokenManagerAddress\_ | address | The deployment address of the TokenManager. |

### getManagedTokenAddress
### registeredTokenAddress

```solidity
function getManagedTokenAddress(bytes32 tokenId) public view returns (address tokenAddress)
function registeredTokenAddress(bytes32 tokenId) public view returns (address tokenAddress)
```

Returns the address of the token that an existing tokenManager points to.
Expand Down Expand Up @@ -3034,10 +3034,10 @@ Returns the address of the valid token manager associated with the given tokenId
| --------------------- | ------- | --------------------------------------- |
| tokenManagerAddress\_ | address | The address of the valid token manager. |

### getManagedTokenAddress
### registeredTokenAddress

```solidity
function getManagedTokenAddress(bytes32 tokenId) external view returns (address tokenAddress)
function registeredTokenAddress(bytes32 tokenId) external view returns (address tokenAddress)
```

Returns the address of the token that an existing tokenManager points to.
Expand Down
8 changes: 4 additions & 4 deletions test/InterchainTokenService.js
Original file line number Diff line number Diff line change
Expand Up @@ -870,7 +870,7 @@ describe('Interchain Token Service', () => {
expect(await tokenManager.isFlowLimiter(wallet.address)).to.be.true;
expect(await tokenManager.isFlowLimiter(service.address)).to.be.true;

const tokenAddress = await service.getManagedTokenAddress(tokenId);
const tokenAddress = await service.registeredTokenAddress(tokenId);
expect(tokenAddress).to.eq(token.address);

tokenManagerProxy = await getContractAt('TokenManagerProxy', tokenManagerAddress, wallet);
Expand Down Expand Up @@ -932,7 +932,7 @@ describe('Interchain Token Service', () => {
expect(await tokenManager.isFlowLimiter(wallet.address)).to.be.true;
expect(await tokenManager.isFlowLimiter(service.address)).to.be.true;

const tokenAddress = await service.getManagedTokenAddress(tokenId);
const tokenAddress = await service.registeredTokenAddress(tokenId);
expect(tokenAddress).to.eq(token.address);

const tokenManagerProxy = await getContractAt('TokenManagerProxy', tokenManagerAddress, wallet);
Expand Down Expand Up @@ -969,7 +969,7 @@ describe('Interchain Token Service', () => {
expect(await tokenManager.isFlowLimiter(wallet.address)).to.be.true;
expect(await tokenManager.isFlowLimiter(service.address)).to.be.true;

const tokenAddress = await service.getManagedTokenAddress(tokenId);
const tokenAddress = await service.registeredTokenAddress(tokenId);
expect(tokenAddress).to.eq(token.address);

const tokenManagerProxy = await getContractAt('TokenManagerProxy', tokenManagerAddress, wallet);
Expand Down Expand Up @@ -1006,7 +1006,7 @@ describe('Interchain Token Service', () => {
expect(await tokenManager.isFlowLimiter(wallet.address)).to.be.true;
expect(await tokenManager.isFlowLimiter(service.address)).to.be.true;

const tokenAddress = await service.getManagedTokenAddress(tokenId);
const tokenAddress = await service.registeredTokenAddress(tokenId);
expect(tokenAddress).to.eq(token.address);

const tokenManagerProxy = await getContractAt('TokenManagerProxy', tokenManagerAddress, wallet);
Expand Down

0 comments on commit 513f387

Please sign in to comment.