Skip to content

Commit

Permalink
refactor: update folder structure (#146)
Browse files Browse the repository at this point in the history
  • Loading branch information
milapsheth authored Nov 4, 2023
1 parent 6da1bf4 commit 722a67b
Show file tree
Hide file tree
Showing 21 changed files with 77 additions and 94 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pragma solidity ^0.8.0;
import { Ownable } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/utils/Ownable.sol';
import { InterchainAddressTracker } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/utils/InterchainAddressTracker.sol';

import { IAddressTracker } from '../interfaces/IAddressTracker.sol';
import { IAddressTracker } from './interfaces/IAddressTracker.sol';

contract AddressTracker is IAddressTracker, Ownable, InterchainAddressTracker {
constructor(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import { SafeTokenTransfer, SafeTokenTransferFrom, SafeTokenCall } from '@axelar
import { Multicall } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/utils/Multicall.sol';
import { Upgradable } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/upgradable/Upgradable.sol';

import { IInterchainTokenService } from '../interfaces/IInterchainTokenService.sol';
import { IInterchainTokenFactory } from '../interfaces/IInterchainTokenFactory.sol';
import { ITokenManagerType } from '../interfaces/ITokenManagerType.sol';
import { ITokenManager } from '../interfaces/ITokenManager.sol';
import { IInterchainToken } from '../interfaces/IInterchainToken.sol';
import { IInterchainTokenService } from './interfaces/IInterchainTokenService.sol';
import { IInterchainTokenFactory } from './interfaces/IInterchainTokenFactory.sol';
import { ITokenManagerType } from './interfaces/ITokenManagerType.sol';
import { ITokenManager } from './interfaces/ITokenManager.sol';
import { IInterchainToken } from './interfaces/IInterchainToken.sol';

contract InterchainTokenFactory is IInterchainTokenFactory, ITokenManagerType, Multicall, Upgradable {
using AddressBytes for bytes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ import { Multicall } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/uti
import { IInterchainAddressTracker } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/interfaces/IInterchainAddressTracker.sol';
import { Pausable } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/utils/Pausable.sol';

import { IInterchainTokenService } from '../interfaces/IInterchainTokenService.sol';
import { ITokenManagerDeployer } from '../interfaces/ITokenManagerDeployer.sol';
import { IInterchainTokenDeployer } from '../interfaces/IInterchainTokenDeployer.sol';
import { IInterchainTokenExecutable } from '../interfaces/IInterchainTokenExecutable.sol';
import { IInterchainTokenExpressExecutable } from '../interfaces/IInterchainTokenExpressExecutable.sol';
import { ITokenManager } from '../interfaces/ITokenManager.sol';
import { IERC20Named } from '../interfaces/IERC20Named.sol';

import { Operatable } from '../utils/Operatable.sol';
import { IInterchainTokenService } from './interfaces/IInterchainTokenService.sol';
import { ITokenManagerDeployer } from './interfaces/ITokenManagerDeployer.sol';
import { IInterchainTokenDeployer } from './interfaces/IInterchainTokenDeployer.sol';
import { IInterchainTokenExecutable } from './interfaces/IInterchainTokenExecutable.sol';
import { IInterchainTokenExpressExecutable } from './interfaces/IInterchainTokenExpressExecutable.sol';
import { ITokenManager } from './interfaces/ITokenManager.sol';
import { IERC20Named } from './interfaces/IERC20Named.sol';

import { Operatable } from './utils/Operatable.sol';

/**
* @title The Interchain Token Service
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import { IImplementation } from '../interfaces/IImplementation.sol';
import { IInterchainToken } from '../interfaces/IInterchainToken.sol';
import { ITokenManager } from '../interfaces/ITokenManager.sol';

import { InterchainTokenBase } from '../interchain-token/InterchainTokenBase.sol';
import { ERC20Permit } from '../token-implementations/ERC20Permit.sol';
import { InterchainTokenBase } from './InterchainTokenBase.sol';
import { ERC20Permit } from './ERC20Permit.sol';
import { Implementation } from '../utils/Implementation.sol';
import { Distributable } from '../utils/Distributable.sol';

Expand Down
3 changes: 2 additions & 1 deletion contracts/interchain-token/InterchainTokenBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ pragma solidity ^0.8.0;

import { IInterchainTokenBase } from '../interfaces/IInterchainTokenBase.sol';
import { ITokenManager } from '../interfaces/ITokenManager.sol';
import { ERC20 } from '../token-implementations/ERC20.sol';

import { ERC20 } from './ERC20.sol';

/**
* @title An example implementation of the IInterchainToken.
Expand Down
2 changes: 1 addition & 1 deletion contracts/test/HardCodedConstantsTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// solhint-disable-next-line one-contract-per-file
pragma solidity ^0.8.0;

import { TokenManagerLiquidityPool } from '../token-manager/implementations/TokenManagerLiquidityPool.sol';
import { TokenManagerLiquidityPool } from '../token-manager/TokenManagerLiquidityPool.sol';
import { Distributable } from '../utils/Distributable.sol';
import { FlowLimit } from '../utils/FlowLimit.sol';
import { Operatable } from '../utils/Operatable.sol';
Expand Down
2 changes: 1 addition & 1 deletion contracts/test/InvalidInterchainToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { IERC20MintableBurnable } from '../interfaces/IERC20MintableBurnable.sol
import { ITokenManager } from '../interfaces/ITokenManager.sol';

import { InterchainTokenBase } from '../interchain-token/InterchainTokenBase.sol';
import { ERC20Permit } from '../token-implementations/ERC20Permit.sol';
import { ERC20Permit } from '../interchain-token/ERC20Permit.sol';
import { Implementation } from '../utils/Implementation.sol';
import { Distributable } from '../utils/Distributable.sol';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { IERC20 } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/interf
import { SafeTokenTransferFrom } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/libs/SafeTransfer.sol';
import { ReentrancyGuard } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/utils/ReentrancyGuard.sol';

import { ITokenManagerLiquidityPool } from '../../interfaces/ITokenManagerLiquidityPool.sol';
import { TokenManager } from '../TokenManager.sol';
import { ITokenManagerLiquidityPool } from '../interfaces/ITokenManagerLiquidityPool.sol';
import { TokenManager } from './TokenManager.sol';

/**
* @title TokenManagerLiquidityPool
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ pragma solidity ^0.8.0;
import { IERC20 } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/interfaces/IERC20.sol';
import { SafeTokenTransfer, SafeTokenTransferFrom } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/libs/SafeTransfer.sol';

import { ITokenManagerLockUnlock } from '../../interfaces/ITokenManagerLockUnlock.sol';
import { TokenManager } from '../TokenManager.sol';
import { ITokenManagerLockUnlock } from '..//interfaces/ITokenManagerLockUnlock.sol';
import { TokenManager } from './TokenManager.sol';

/**
* @title TokenManagerLockUnlock
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { IERC20 } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/interf
import { SafeTokenTransferFrom, SafeTokenTransfer } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/libs/SafeTransfer.sol';
import { ReentrancyGuard } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/utils/ReentrancyGuard.sol';

import { ITokenManagerLockUnlock } from '../../interfaces/ITokenManagerLockUnlock.sol';
import { TokenManager } from '../TokenManager.sol';
import { ITokenManagerLockUnlock } from '../interfaces/ITokenManagerLockUnlock.sol';
import { TokenManager } from './TokenManager.sol';

/**
* @title TokenManagerLockUnlock
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ pragma solidity ^0.8.0;
import { IERC20 } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/interfaces/IERC20.sol';
import { SafeTokenCall } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/libs/SafeTransfer.sol';

import { TokenManager } from '../TokenManager.sol';
import { IERC20MintableBurnable } from '../../interfaces/IERC20MintableBurnable.sol';
import { ITokenManagerMintBurn } from '../../interfaces/ITokenManagerMintBurn.sol';
import { TokenManager } from './TokenManager.sol';
import { IERC20MintableBurnable } from '../interfaces/IERC20MintableBurnable.sol';
import { ITokenManagerMintBurn } from '../interfaces/ITokenManagerMintBurn.sol';

/**
* @title TokenManagerMintBurn
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pragma solidity ^0.8.0;
import { IERC20 } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/interfaces/IERC20.sol';
import { SafeTokenCall } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/libs/SafeTransfer.sol';

import { IERC20BurnableFrom } from '../../interfaces/IERC20BurnableFrom.sol';
import { IERC20BurnableFrom } from '../interfaces/IERC20BurnableFrom.sol';
import { TokenManagerMintBurn } from './TokenManagerMintBurn.sol';

/**
Expand Down
7 changes: 2 additions & 5 deletions test/ERC20.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@
const chai = require('chai');
const { ethers } = require('hardhat');
const {
Contract,
constants: { MaxUint256, AddressZero },
getContractAt,
} = ethers;
const { expect } = chai;
const { getRandomBytes32, expectRevert } = require('./utils');
const { deployContract } = require('../scripts/deploy');

const InterchainToken = require('../artifacts/contracts/token-implementations/InterchainToken.sol/InterchainToken.json');

describe('ERC20', () => {
let interchainToken, interchainTokenDeployer;

Expand All @@ -35,8 +33,7 @@ describe('ERC20', () => {
const salt = getRandomBytes32();

const tokenAddress = await interchainTokenDeployer.deployedAddress(salt);

token = new Contract(tokenAddress, InterchainToken.abi, owner);
token = await getContractAt('InterchainToken', tokenAddress, owner);

await interchainTokenDeployer
.deployInterchainToken(salt, owner.address, owner.address, name, symbol, decimals)
Expand Down
6 changes: 2 additions & 4 deletions test/ERC20Permit.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@
const chai = require('chai');
const { ethers } = require('hardhat');
const {
Contract,
getContractAt,
utils: { splitSignature },
constants: { MaxUint256 },
} = ethers;
const { expect } = chai;
const { getRandomBytes32, expectRevert, getChainId } = require('./utils');
const { deployContract } = require('../scripts/deploy');

const InterchainToken = require('../artifacts/contracts/token-implementations/InterchainToken.sol/InterchainToken.json');

describe('ERC20 Permit', () => {
let interchainToken, interchainTokenDeployer;

Expand All @@ -39,7 +37,7 @@ describe('ERC20 Permit', () => {

const tokenAddress = await interchainTokenDeployer.deployedAddress(salt);

token = new Contract(tokenAddress, InterchainToken.abi, owner);
token = await getContractAt('InterchainToken', tokenAddress, owner);

await interchainTokenDeployer
.deployInterchainToken(salt, owner.address, owner.address, name, symbol, decimals)
Expand Down
11 changes: 4 additions & 7 deletions test/InterchainToken.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,13 @@
const chai = require('chai');
const { ethers } = require('hardhat');
const {
Contract,
getContractAt,
utils: { keccak256, toUtf8Bytes },
} = ethers;
const { expect } = chai;
const { getRandomBytes32, expectRevert, getGasOptions } = require('./utils');
const { deployContract } = require('../scripts/deploy');

const InterchainToken = require('../artifacts/contracts/token-implementations/InterchainToken.sol/InterchainToken.json');
const InterchainTokenProxy = require('../artifacts/contracts/proxies/InterchainTokenProxy.sol/InterchainTokenProxy.json');

describe('InterchainToken', () => {
let interchainToken, interchainTokenDeployer;

Expand All @@ -37,8 +34,8 @@ describe('InterchainToken', () => {

const tokenAddress = await interchainTokenDeployer.deployedAddress(salt);

token = new Contract(tokenAddress, InterchainToken.abi, owner);
tokenProxy = new Contract(tokenAddress, InterchainTokenProxy.abi, owner);
token = await getContractAt('InterchainToken', tokenAddress, owner);
tokenProxy = await getContractAt('InterchainTokenProxy', tokenAddress, owner);

await interchainTokenDeployer
.deployInterchainToken(salt, owner.address, owner.address, name, symbol, decimals)
Expand Down Expand Up @@ -78,7 +75,7 @@ describe('InterchainToken', () => {
describe('Interchain Token', () => {
it('revert on setup if not called by the proxy', async () => {
const implementationAddress = await tokenProxy.implementation();
const implementation = new Contract(implementationAddress, InterchainToken.abi, owner);
const implementation = await getContractAt('InterchainToken', implementationAddress, owner);

const params = '0x';
await expectRevert((gasOptions) => implementation.setup(params, gasOptions), token, 'NotProxy');
Expand Down
17 changes: 7 additions & 10 deletions test/InterchainTokenFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,11 @@ require('dotenv').config();
const { ethers } = require('hardhat');
const { defaultAbiCoder, keccak256 } = ethers.utils;
const {
Contract,
getContractAt,
Wallet,
constants: { AddressZero },
} = ethers;

const ITokenManager = require('../artifacts/contracts/interfaces/ITokenManager.sol/ITokenManager.json');
const IInterchainToken = require('../artifacts/contracts/interfaces/IInterchainToken.sol/IInterchainToken.json');

const { deployAll, deployContract } = require('../scripts/deploy');
const { getRandomBytes32 } = require('./utils');

Expand Down Expand Up @@ -187,8 +184,8 @@ describe('InterchainTokenFactory', () => {
tokenId = await tokenFactory.interchainTokenId(wallet.address, salt);
const tokenAddress = await tokenFactory.interchainTokenAddress(wallet.address, salt);
const params = defaultAbiCoder.encode(['bytes', 'address'], [operator, tokenAddress]);
const tokenManager = new Contract(await service.tokenManagerAddress(tokenId), ITokenManager.abi, wallet);
const token = new Contract(tokenAddress, IInterchainToken.abi, wallet);
const tokenManager = await getContractAt('TokenManager', await service.tokenManagerAddress(tokenId), wallet);
const token = await getContractAt('InterchainToken', tokenAddress, wallet);

await expect(tokenFactory.deployInterchainToken(salt, name, symbol, decimals, mintAmount, distributor, operator))
.to.emit(service, 'InterchainTokenDeployed')
Expand Down Expand Up @@ -220,8 +217,8 @@ describe('InterchainTokenFactory', () => {
tokenId = await tokenFactory.interchainTokenId(wallet.address, salt);
const tokenAddress = await tokenFactory.interchainTokenAddress(wallet.address, salt);
let params = defaultAbiCoder.encode(['bytes', 'address'], [wallet.address, tokenAddress]);
const tokenManager = new Contract(await service.tokenManagerAddress(tokenId), ITokenManager.abi, wallet);
const token = new Contract(tokenAddress, IInterchainToken.abi, wallet);
const tokenManager = await getContractAt('TokenManager', await service.tokenManagerAddress(tokenId), wallet);
const token = await getContractAt('InterchainToken', tokenAddress, wallet);

await expect(tokenFactory.deployInterchainToken(salt, name, symbol, decimals, mintAmount, wallet.address, wallet.address))
.to.emit(service, 'InterchainTokenDeployed')
Expand Down Expand Up @@ -269,8 +266,8 @@ describe('InterchainTokenFactory', () => {
tokenId = await tokenFactory.interchainTokenId(wallet.address, salt);
const tokenAddress = await tokenFactory.interchainTokenAddress(wallet.address, salt);
let params = defaultAbiCoder.encode(['bytes', 'address'], [wallet.address, tokenAddress]);
const tokenManager = new Contract(await service.tokenManagerAddress(tokenId), ITokenManager.abi, wallet);
const token = new Contract(tokenAddress, IInterchainToken.abi, wallet);
const tokenManager = await getContractAt('TokenManager', await service.tokenManagerAddress(tokenId), wallet);
const token = await getContractAt('InterchainToken', tokenAddress, wallet);

await expect(tokenFactory.deployInterchainToken(salt, name, symbol, decimals, mintAmount, wallet.address, wallet.address))
.to.emit(service, 'InterchainTokenDeployed')
Expand Down
Loading

0 comments on commit 722a67b

Please sign in to comment.