Skip to content

Commit

Permalink
refactor: tokenId() -> interchainTokenId()
Browse files Browse the repository at this point in the history
  • Loading branch information
milapsheth committed Nov 3, 2023
1 parent 3ac2eed commit 93e6c76
Show file tree
Hide file tree
Showing 12 changed files with 54 additions and 54 deletions.
6 changes: 3 additions & 3 deletions contracts/interchain-token-service/InterchainTokenService.sol
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ contract InterchainTokenService is
* @param salt the salt that the deployer uses for the deployment.
* @return tokenId_ the tokenId_ that the custom TokenManager would get (or has gotten).
*/
function tokenId(address sender, bytes32 salt) public pure returns (bytes32 tokenId_) {
function interchainTokenId(address sender, bytes32 salt) public pure returns (bytes32 tokenId_) {
tokenId_ = keccak256(abi.encode(PREFIX_TOKEN_ID, sender, salt));
}

Expand Down Expand Up @@ -267,7 +267,7 @@ contract InterchainTokenService is
uint256 gasValue
) external payable whenNotPaused returns (bytes32 tokenId_) {
address deployer_ = msg.sender;
tokenId_ = tokenId(deployer_, salt);
tokenId_ = interchainTokenId(deployer_, salt);

emit CustomTokenIdClaimed(tokenId_, deployer_, salt);
if (bytes(destinationChain).length == 0) {
Expand Down Expand Up @@ -300,7 +300,7 @@ contract InterchainTokenService is
bytes memory operator,
uint256 gasValue
) external payable whenNotPaused {
bytes32 tokenId_ = tokenId(msg.sender, salt);
bytes32 tokenId_ = interchainTokenId(msg.sender, salt);

if (bytes(destinationChain).length == 0) {
address tokenAddress_;
Expand Down
2 changes: 1 addition & 1 deletion contracts/interfaces/IInterchainTokenService.sol
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ interface IInterchainTokenService is ITokenManagerType, IAxelarValuedExpressExec
* @param salt The salt used for token id calculation.
* @return tokenId_ The custom tokenId_ associated with the operator and salt.
*/
function tokenId(address operator_, bytes32 salt) external view returns (bytes32 tokenId_);
function interchainTokenId(address operator_, bytes32 salt) external view returns (bytes32 tokenId_);

/**
* @notice Deploys a custom token manager contract on a remote chain.
Expand Down
2 changes: 1 addition & 1 deletion contracts/interfaces/ITokenManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ interface ITokenManager is ITokenManagerType, IOperatable, IFlowLimit, IImplemen
/**
* @notice A function that returns the token id.
*/
function tokenId() external view returns (bytes32);
function interchainTokenId() external view returns (bytes32);

/**
* @notice A function that should return the address of the token.
Expand Down
2 changes: 1 addition & 1 deletion contracts/interfaces/ITokenManagerProxy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ interface ITokenManagerProxy {
/**
* @notice Returns token ID of the token manager.
*/
function tokenId() external view returns (bytes32);
function interchainTokenId() external view returns (bytes32);
}
4 changes: 2 additions & 2 deletions contracts/interfaces/ITokenRegistrar.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ interface ITokenRegistrar {

function standardizedTokenSalt(bytes32 chainAddressHash_, address deployer, bytes32 salt) external view returns (bytes32);

function standardizedTokenId(address deployer, bytes32 salt) external view returns (bytes32 tokenId);
function standardizedinterchainTokenId(address deployer, bytes32 salt) external view returns (bytes32 tokenId);

function interchainTokenAddress(address deployer, bytes32 salt) external view returns (address tokenAddress);

Expand All @@ -38,7 +38,7 @@ interface ITokenRegistrar {

function canonicalTokenSalt(bytes32 chainAddressHash_, address tokenAddress) external view returns (bytes32 salt);

function canonicalTokenId(address tokenAddress) external view returns (bytes32 tokenId);
function canonicalinterchainTokenId(address tokenAddress) external view returns (bytes32 tokenId);

function registerCanonicalToken(address tokenAddress) external payable returns (bytes32 tokenId);

Expand Down
4 changes: 2 additions & 2 deletions contracts/proxies/TokenManagerProxy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { ITokenManagerProxy } from '../interfaces/ITokenManagerProxy.sol';
contract TokenManagerProxy is ITokenManagerProxy {
IInterchainTokenService public immutable interchainTokenService;
uint256 public immutable implementationType;
bytes32 public immutable tokenId;
bytes32 public immutable interchainTokenId;

/**
* @dev Constructs the TokenManagerProxy contract.
Expand All @@ -25,7 +25,7 @@ contract TokenManagerProxy is ITokenManagerProxy {
constructor(address interchainTokenServiceAddress_, uint256 implementationType_, bytes32 tokenId_, bytes memory params) {
interchainTokenService = IInterchainTokenService(interchainTokenServiceAddress_);
implementationType = implementationType_;
tokenId = tokenId_;
interchainTokenId = tokenId_;
address impl = _tokenManagerImplementation(IInterchainTokenService(interchainTokenServiceAddress_), implementationType_);

(bool success, bytes memory returnData) = impl.delegatecall(abi.encodeWithSelector(TokenManagerProxy.setup.selector, params));
Expand Down
12 changes: 6 additions & 6 deletions contracts/token-manager/TokenManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ abstract contract TokenManager is ITokenManager, Operatable, FlowLimit, Implemen
* @notice A function that returns the token id.
* @dev This will only work when implementation is called by a proxy, which stores the tokenId as an immutable.
*/
function tokenId() public view returns (bytes32) {
function interchainTokenId() public view returns (bytes32) {
// slither-disable-next-line var-read-using-this
return this.tokenId();
return this.interchainTokenId();
}

/**
Expand Down Expand Up @@ -109,7 +109,7 @@ abstract contract TokenManager is ITokenManager, Operatable, FlowLimit, Implemen
_addFlowOut(amount);

interchainTokenService.transmitSendToken{ value: msg.value }(
tokenId(),
interchainTokenId(),
sender,
destinationChain,
destinationAddress,
Expand All @@ -136,7 +136,7 @@ abstract contract TokenManager is ITokenManager, Operatable, FlowLimit, Implemen
_addFlowOut(amount);
uint32 version = 0;
interchainTokenService.transmitSendToken{ value: msg.value }(
tokenId(),
interchainTokenId(),
sender,
destinationChain,
destinationAddress,
Expand All @@ -163,7 +163,7 @@ abstract contract TokenManager is ITokenManager, Operatable, FlowLimit, Implemen
amount = _takeToken(sender, amount);
_addFlowOut(amount);
interchainTokenService.transmitSendToken{ value: msg.value }(
tokenId(),
interchainTokenId(),
sender,
destinationChain,
destinationAddress,
Expand Down Expand Up @@ -225,7 +225,7 @@ abstract contract TokenManager is ITokenManager, Operatable, FlowLimit, Implemen
* @param flowLimit_ the maximum difference between the tokens flowing in and/or out at any given interval of time (6h)
*/
function setFlowLimit(uint256 flowLimit_) external onlyRole(uint8(Roles.FLOW_LIMITER)) {
_setFlowLimit(flowLimit_, tokenId());
_setFlowLimit(flowLimit_, interchainTokenId());
}

/**
Expand Down
16 changes: 8 additions & 8 deletions contracts/token-registrars/TokenRegistrar.sol
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ contract TokenRegistrar is ITokenRegistrar, ITokenManagerType, Multicall, Upgrad
return keccak256(abi.encode(PREFIX_STANDARDIZED_TOKEN_SALT, chainNameHash_, deployer, salt));
}

function standardizedTokenId(address deployer, bytes32 salt) public view returns (bytes32 tokenId) {
tokenId = service.tokenId(address(this), standardizedTokenSalt(chainNameHash, deployer, salt));
function standardizedinterchainTokenId(address deployer, bytes32 salt) public view returns (bytes32 tokenId) {
tokenId = service.interchainTokenId(address(this), standardizedTokenSalt(chainNameHash, deployer, salt));
}

function interchainTokenAddress(address deployer, bytes32 salt) public view returns (address tokenAddress) {
tokenAddress = service.interchainTokenAddress(standardizedTokenId(deployer, salt));
tokenAddress = service.interchainTokenAddress(standardizedinterchainTokenId(deployer, salt));
}

function deployInterchainToken(
Expand All @@ -77,7 +77,7 @@ contract TokenRegistrar is ITokenRegistrar, ITokenManagerType, Multicall, Upgrad
_deployInterchainToken(salt, '', name, symbol, decimals, distributorBytes, operator.toBytes(), 0);

if (mintAmount > 0) {
bytes32 tokenId = service.tokenId(address(this), salt);
bytes32 tokenId = service.interchainTokenId(address(this), salt);
IStandardizedToken token = IStandardizedToken(service.interchainTokenAddress(tokenId));
token.mint(address(this), mintAmount);
token.transferDistributorship(distributor);
Expand Down Expand Up @@ -107,7 +107,7 @@ contract TokenRegistrar is ITokenRegistrar, ITokenManagerType, Multicall, Upgrad
}
address sender = msg.sender;
salt = standardizedTokenSalt(chainNameHash_, sender, salt);
bytes32 tokenId = service.tokenId(address(this), salt);
bytes32 tokenId = service.interchainTokenId(address(this), salt);

IStandardizedToken token = IStandardizedToken(service.interchainTokenAddress(tokenId));
ITokenManager tokenManager = ITokenManager(service.tokenManagerAddress(tokenId));
Expand Down Expand Up @@ -156,8 +156,8 @@ contract TokenRegistrar is ITokenRegistrar, ITokenManagerType, Multicall, Upgrad
salt = keccak256(abi.encode(PREFIX_CANONICAL_TOKEN_SALT, chainNameHash_, tokenAddress));
}

function canonicalTokenId(address tokenAddress) public view returns (bytes32 tokenId) {
tokenId = service.tokenId(address(this), canonicalTokenSalt(chainNameHash, tokenAddress));
function canonicalinterchainTokenId(address tokenAddress) public view returns (bytes32 tokenId) {
tokenId = service.interchainTokenId(address(this), canonicalTokenSalt(chainNameHash, tokenAddress));
}

function registerCanonicalToken(address tokenAddress) external payable returns (bytes32 tokenId) {
Expand All @@ -184,7 +184,7 @@ contract TokenRegistrar is ITokenRegistrar, ITokenManagerType, Multicall, Upgrad
}
// This ensures that the token manager has been deployed by this address, so it's safe to trust it.
salt = canonicalTokenSalt(chainNameHash_, originalTokenAddress);
bytes32 tokenId = service.tokenId(address(this), salt);
bytes32 tokenId = service.interchainTokenId(address(this), salt);
token = IStandardizedToken(service.tokenAddress(tokenId));
}

Expand Down
12 changes: 6 additions & 6 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ The token does not need to exist.
### canonicalTokenId

```solidity
function canonicalTokenId(address tokenAddress) public view returns (bytes32 tokenId)
function canonicalinterchainTokenId(address tokenAddress) public view returns (bytes32 tokenId)
```

Calculates the tokenId that would correspond to a canonical link for a given token.
Expand All @@ -275,7 +275,7 @@ This will depend on what chain it is called from, unlike custom tokenIds.
### tokenId

```solidity
function tokenId(address sender, bytes32 salt) public pure returns (bytes32 tokenId)
function interchainTokenId(address sender, bytes32 salt) public pure returns (bytes32 tokenId)
```

Calculates the tokenId that would correspond to a custom link for a given deployer with a specified salt.
Expand Down Expand Up @@ -1348,7 +1348,7 @@ Returns the address of the standardized token associated with the given tokenId.
### canonicalTokenId

```solidity
function canonicalTokenId(address tokenAddress) external view returns (bytes32 tokenId)
function canonicalinterchainTokenId(address tokenAddress) external view returns (bytes32 tokenId)
```

Returns the canonical tokenId associated with the given tokenAddress.
Expand All @@ -1368,7 +1368,7 @@ Returns the canonical tokenId associated with the given tokenAddress.
### tokenId

```solidity
function tokenId(address operator, bytes32 salt) external view returns (bytes32 tokenId)
function interchainTokenId(address operator, bytes32 salt) external view returns (bytes32 tokenId)
```

Returns the custom tokenId associated with the given operator and salt.
Expand Down Expand Up @@ -2275,7 +2275,7 @@ Returns the address of the current implementation.
### tokenId

```solidity
function tokenId() external view returns (bytes32)
function interchainTokenId() external view returns (bytes32)
```

Returns token ID of the token manager.
Expand Down Expand Up @@ -4303,7 +4303,7 @@ Must be overridden in the inheriting contract._
### \_getTokenId

```solidity
function _getTokenId() internal view returns (bytes32 tokenId)
function _getinterchainTokenId() internal view returns (bytes32 tokenId)
```

Gets the token ID from the token manager proxy.
Expand Down
8 changes: 4 additions & 4 deletions test/TokenRegistrars.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ describe('Token Registrars', () => {

async function deployToken() {
token = await deployContract(wallet, 'InterchainTokenTest', [name, symbol, decimals, wallet.address]);
tokenId = await tokenRegistrar.canonicalTokenId(token.address);
tokenId = await tokenRegistrar.canonicalinterchainTokenId(token.address);
tokenManagerAddress = await service.tokenManagerAddress(tokenId);
await (await token.mint(wallet.address, tokenCap)).wait();
await (await token.setTokenManager(tokenManagerAddress)).wait();
Expand Down Expand Up @@ -130,7 +130,7 @@ describe('Token Registrars', () => {

it('Should register a token', async () => {
const salt = keccak256('0x');
tokenId = await tokenRegistrar.standardizedTokenId(wallet.address, salt);
tokenId = await tokenRegistrar.standardizedinterchainTokenId(wallet.address, salt);
const tokenAddress = await tokenRegistrar.interchainTokenAddress(wallet.address, salt);
const params = defaultAbiCoder.encode(['bytes', 'address'], [operator, tokenAddress]);
const tokenManager = new Contract(await service.tokenManagerAddress(tokenId), ITokenManager.abi, wallet);
Expand Down Expand Up @@ -163,7 +163,7 @@ describe('Token Registrars', () => {
const mintAmount = 5678;

const salt = keccak256('0x12');
tokenId = await tokenRegistrar.standardizedTokenId(wallet.address, salt);
tokenId = await tokenRegistrar.standardizedinterchainTokenId(wallet.address, salt);
const tokenAddress = await tokenRegistrar.interchainTokenAddress(wallet.address, salt);
let params = defaultAbiCoder.encode(['bytes', 'address'], [wallet.address, tokenAddress]);
const tokenManager = new Contract(await service.tokenManagerAddress(tokenId), ITokenManager.abi, wallet);
Expand Down Expand Up @@ -221,7 +221,7 @@ describe('Token Registrars', () => {
const gasValue = 1234;

const salt = keccak256('0x1245');
tokenId = await tokenRegistrar.standardizedTokenId(wallet.address, salt);
tokenId = await tokenRegistrar.standardizedinterchainTokenId(wallet.address, salt);
const tokenAddress = await tokenRegistrar.interchainTokenAddress(wallet.address, salt);
let params = defaultAbiCoder.encode(['bytes', 'address'], [wallet.address, tokenAddress]);
const tokenManager = new Contract(await service.tokenManagerAddress(tokenId), ITokenManager.abi, wallet);
Expand Down
Loading

0 comments on commit 93e6c76

Please sign in to comment.