Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added support for gateway tokens #246

Merged
merged 18 commits into from
Jan 22, 2024
11 changes: 11 additions & 0 deletions contracts/interfaces/ITokenHandler.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ interface ITokenHandler {
error UnsupportedTokenManagerType(uint256 tokenManagerType);
error AddressZero();

/**
* @notice Returns the address of the axelar gateway on this chain.
* @return gateway_ The address of the axelar gateway contract.
*/
function gateway() external view returns (address gateway_);

/**
* @notice This function gives token to a specified address from the token manager.
milapsheth marked this conversation as resolved.
Show resolved Hide resolved
* @param tokenManagerType The token manager type.
Expand Down Expand Up @@ -61,5 +67,10 @@ interface ITokenHandler {
uint256 amount
) external payable returns (uint256);

/**
* @notice This function prepares a token manager after it is deployed
* @param tokenManagerType The token manager type.
* @param tokenManager The address of the token manager.
*/
function postTokenManagerDeploy(uint256 tokenManagerType, address tokenManager) external payable;
milapsheth marked this conversation as resolved.
Show resolved Hide resolved
}
6 changes: 3 additions & 3 deletions scripts/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ async function approveContractCall(
['string', 'string', 'address', 'bytes32', 'bytes32', 'uint256'],
[sourceChain, sourceAddress, contractAddress, keccak256(payload), sourceTxHash, sourceEventIndex],
);
await (await gateway.approveContractCall(params, commandId)).wait();
await gateway.approveContractCall(params, commandId).then((tx) => tx.wait);
milapsheth marked this conversation as resolved.
Show resolved Hide resolved

return commandId;
}
Expand All @@ -42,7 +42,7 @@ async function approveContractCallWithMint(
['string', 'string', 'address', 'bytes32', 'string', 'uint256', 'bytes32', 'uint256'],
[sourceChain, sourceAddress, contractAddress, keccak256(payload), symbol, amount, sourceTxHash, sourceEventIndex],
);
await (await gateway.approveContractCallWithMint(params, commandId)).wait();
await gateway.approveContractCallWithMint(params, commandId).then((tx) => tx.wait);

return commandId;
}
Expand All @@ -60,7 +60,7 @@ async function deployGatewayToken(gateway, tokenName, tokenSymbol, tokenDecimals
[tokenName, tokenSymbol, tokenDecimals, 0, tokenAddress, 0],
);
const commandId = getRandomBytes32();
await (await gateway.deployToken(params, commandId)).wait();
await gateway.deployToken(params, commandId).then((tx) => tx.wait);
}

module.exports = {
Expand Down
2 changes: 1 addition & 1 deletion test/ERC20.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('ERC20', () => {

await interchainTokenDeployer.deployInterchainToken(salt, tokenId, owner.address, name, symbol, decimals).then((tx) => tx.wait());

await (await token.mint(owner.address, mintAmount)).wait();
await token.mint(owner.address, mintAmount).then((tx) => tx.wait);
expect(await token.interchainTokenId()).to.equal(tokenId);
});

Expand Down
2 changes: 1 addition & 1 deletion test/ERC20Permit.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe('ERC20 Permit', () => {

await interchainTokenDeployer.deployInterchainToken(salt, tokenId, owner.address, name, symbol, decimals).then((tx) => tx.wait());

await (await token.mint(owner.address, mintAmount)).wait();
await token.mint(owner.address, mintAmount).then((tx) => tx.wait);
expect(await token.interchainTokenId()).to.equal(tokenId);
});

Expand Down
2 changes: 1 addition & 1 deletion test/InterchainToken.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe('InterchainToken', () => {

await interchainTokenDeployer.deployInterchainToken(salt, tokenId, owner.address, name, symbol, decimals).then((tx) => tx.wait());

await (await token.mint(owner.address, mintAmount)).wait();
await token.mint(owner.address, mintAmount).then((tx) => tx.wait);
expect(await token.interchainTokenId()).to.equal(tokenId);
});

Expand Down
24 changes: 13 additions & 11 deletions test/InterchainTokenFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ describe('InterchainTokenFactory', () => {
]);
tokenId = await tokenFactory.canonicalInterchainTokenId(token.address);
tokenManagerAddress = await service.tokenManagerAddress(tokenId);
await (await token.mint(wallet.address, tokenCap)).wait();
await (await token.setTokenId(tokenId)).wait();
await token.mint(wallet.address, tokenCap).then((tx) => tx.wait);
await token.setTokenId(tokenId).then((tx) => tx.wait);
}

before(async () => {
Expand Down Expand Up @@ -131,7 +131,7 @@ describe('InterchainTokenFactory', () => {
['string', 'string', 'uint8', 'uint256', 'address', 'uint256'],
[name, symbol, decimals, tokenCap, tokenAddress, mintLimit],
);
await (await gateway.deployToken(params, getRandomBytes32())).wait();
await gateway.deployToken(params, getRandomBytes32()).then((tx) => tx.wait);

await expectRevert(
(gasOptions) => tokenFactory.registerCanonicalInterchainToken(tokenAddress, gasOptions),
Expand All @@ -150,7 +150,7 @@ describe('InterchainTokenFactory', () => {
['string', 'string', 'uint8', 'uint256', 'address', 'uint256'],
[name, newSymbol, decimals, tokenCap, tokenAddress, mintLimit],
);
await (await gateway.deployToken(params, getRandomBytes32())).wait();
await gateway.deployToken(params, getRandomBytes32()).then((tx) => tx.wait);

tokenAddress = await gateway.tokenAddresses(newSymbol);

Expand Down Expand Up @@ -186,21 +186,23 @@ describe('InterchainTokenFactory', () => {
[name, symbol, decimals, 0, tokenAddress, 0],
);

await (await gateway.deployToken(params, getRandomBytes32())).wait();
await gateway.deployToken(params, getRandomBytes32()).then((tx) => tx.wait());

tokenId = await service.interchainTokenId(AddressZero, salt);
tokenManagerAddress = await service.tokenManagerAddress(tokenId);

if (lockUnlock) {
await (await token.mint(wallet.address, tokenCap)).wait();
await (await token.setTokenId(tokenId)).wait();
await token.mint(wallet.address, tokenCap).then((tx) => tx.wait());
await token.setTokenId(tokenId).then((tx) => tx.wait());
} else {
tokenAddress = await gateway.tokenAddresses(symbol);
token = await getContractAt('IERC20', tokenAddress);
await await gateway.mintToken(
defaultAbiCoder.encode(['string', 'address', 'uint256'], [symbol, wallet.address, tokenCap]),
getRandomBytes32(),
);
await gateway
.mintToken(
defaultAbiCoder.encode(['string', 'address', 'uint256'], [symbol, wallet.address, tokenCap]),
getRandomBytes32(),
)
.then((tx) => tx.wait());
}
}

Expand Down
Loading
Loading