Skip to content

Commit adab8dc

Browse files
authored
Merge branch 'main' into docs/readme
2 parents c35a4ed + fd2bd8e commit adab8dc

9 files changed

+299
-477
lines changed

scripts/deploy.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,25 @@ async function deployAll(
112112
deploymentKey,
113113
);
114114

115-
const factory = await deployInterchainTokenFactory(
115+
const tokenFactory = await deployInterchainTokenFactory(
116116
wallet,
117117
create3Deployer.address,
118118
interchainTokenServiceAddress,
119119
factoryDeploymentKey,
120120
);
121-
return [service, gateway, gasService, factory, create3Deployer];
121+
122+
return {
123+
service,
124+
gateway,
125+
gasService,
126+
tokenFactory,
127+
create3Deployer,
128+
tokenManagerDeployer,
129+
interchainToken,
130+
interchainTokenDeployer,
131+
tokenManager,
132+
tokenHandler,
133+
};
122134
}
123135

124136
module.exports = {

test/AddressDerivation.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ const {
99
} = ethers;
1010
const { deployAll } = require('../scripts/deploy');
1111
const { approveContractCall } = require('../scripts/utils');
12-
const { getRandomBytes32, getSaltFromKey, isHardhat } = require('./utils');
12+
const { getRandomBytes32, getSaltFromKey, isHardhat, getContractJSON } = require('./utils');
1313
const { create3DeployContract } = require('@axelar-network/axelar-gmp-sdk-solidity');
14-
const Token = require('../artifacts/contracts/test/TestInterchainTokenStandard.sol/TestInterchainTokenStandard.json');
14+
const Token = getContractJSON('TestInterchainTokenStandard');
1515
const MINT_BURN = 0;
1616
const MESSAGE_TYPE_DEPLOY_INTERCHAIN_TOKEN = 1;
1717

@@ -21,7 +21,7 @@ if (isHardhat) {
2121
let service;
2222
let gateway;
2323
let create3Deployer;
24-
let factory;
24+
let tokenFactory;
2525
let token;
2626
let sourceAddress;
2727

@@ -35,7 +35,7 @@ if (isHardhat) {
3535
const wallets = await ethers.getSigners();
3636
wallet = wallets[0];
3737

38-
[service, gateway, , factory, create3Deployer] = await deployAll(wallet, 'Test', [sourceChain, destinationChain]);
38+
({ service, gateway, tokenFactory, create3Deployer } = await deployAll(wallet, 'Test', [sourceChain, destinationChain]));
3939
token = await create3DeployContract(create3Deployer.address, wallet, Token, 'Test', [
4040
tokenName,
4141
tokenSymbol,
@@ -116,23 +116,23 @@ if (isHardhat) {
116116

117117
it('Should derive the correct token address for interchain token deployment on source chain', async () => {
118118
const salt = getSaltFromKey('deployInterchainToken');
119-
const tokenId = await factory.interchainTokenId(wallet.address, salt);
119+
const tokenId = await tokenFactory.interchainTokenId(wallet.address, salt);
120120

121121
const expectedTokenAddress = '0xD48F12c4b65135575495C476977B893D8e817B4b';
122122
const expectedTokenManagerAddress = '0xcb7DEA0Aeb34A992451717C0537b5C4eA1635A54';
123123

124-
const params = defaultAbiCoder.encode(['bytes', 'address'], [factory.address, expectedTokenAddress]);
124+
const params = defaultAbiCoder.encode(['bytes', 'address'], [tokenFactory.address, expectedTokenAddress]);
125125

126-
await expect(factory.deployInterchainToken(salt, tokenName, tokenSymbol, tokenDecimals, initialSupply, wallet.address))
126+
await expect(tokenFactory.deployInterchainToken(salt, tokenName, tokenSymbol, tokenDecimals, initialSupply, wallet.address))
127127
.to.emit(service, 'InterchainTokenDeployed')
128-
.withArgs(tokenId, expectedTokenAddress, factory.address, tokenName, tokenSymbol, tokenDecimals)
128+
.withArgs(tokenId, expectedTokenAddress, tokenFactory.address, tokenName, tokenSymbol, tokenDecimals)
129129
.to.emit(service, 'TokenManagerDeployed')
130130
.withArgs(tokenId, expectedTokenManagerAddress, MINT_BURN, params);
131131
});
132132

133133
it('Should derive the correct token address for remote interchain token deployment', async () => {
134134
const salt = getSaltFromKey('deployRemoteInterchainToken');
135-
const tokenId = await factory.interchainTokenId(wallet.address, salt);
135+
const tokenId = await tokenFactory.interchainTokenId(wallet.address, salt);
136136
const minter = wallet.address;
137137
const operator = wallet.address;
138138

@@ -156,7 +156,7 @@ if (isHardhat) {
156156

157157
it('Should derive the correct token address for remote interchain token deployment with empty minter and operator', async () => {
158158
const salt = getSaltFromKey('deployRemoteInterchainTokenEmpty');
159-
const tokenId = await factory.interchainTokenId(wallet.address, salt);
159+
const tokenId = await tokenFactory.interchainTokenId(wallet.address, salt);
160160
const minter = AddressZero;
161161
const operator = '0x';
162162

@@ -179,7 +179,7 @@ if (isHardhat) {
179179
});
180180

181181
it('Should derive the correct token address for remote canonical token deployment', async () => {
182-
const tokenId = await factory.canonicalInterchainTokenId(token.address);
182+
const tokenId = await tokenFactory.canonicalInterchainTokenId(token.address);
183183
const minter = wallet.address;
184184
const operator = wallet.address;
185185

test/ERC20Permit.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ describe('ERC20 Permit', () => {
2626
const wallets = await ethers.getSigners();
2727
owner = wallets[0];
2828
user = wallets[1];
29-
});
3029

31-
beforeEach(async () => {
3230
interchainToken = await deployContract(owner, 'InterchainToken', [owner.address]);
3331
interchainTokenDeployer = await deployContract(owner, 'InterchainTokenDeployer', [interchainToken.address]);
3432

test/InterchainTokenFactory.js

Lines changed: 4 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,10 @@ const {
99
constants: { AddressZero },
1010
utils: { defaultAbiCoder, keccak256, toUtf8Bytes },
1111
} = ethers;
12-
1312
const { deployAll, deployContract } = require('../scripts/deploy');
1413
const { getRandomBytes32, expectRevert } = require('./utils');
1514

16-
// const MESSAGE_TYPE_INTERCHAIN_TRANSFER = 0;
1715
const MESSAGE_TYPE_DEPLOY_INTERCHAIN_TOKEN = 1;
18-
// const MESSAGE_TYPE_DEPLOY_TOKEN_MANAGER = 2;
1916

2017
const LOCK_UNLOCK = 2;
2118
const MINT_BURN = 0;
@@ -35,7 +32,7 @@ describe('InterchainTokenFactory', () => {
3532

3633
before(async () => {
3734
[wallet, otherWallet] = await ethers.getSigners();
38-
[service, gateway, gasService, tokenFactory] = await deployAll(wallet, chainName, [destinationChain]);
35+
({ service, gateway, gasService, tokenFactory } = await deployAll(wallet, chainName, [destinationChain]));
3936
});
4037

4138
describe('Token Factory Deployment', async () => {
@@ -72,9 +69,11 @@ describe('InterchainTokenFactory', () => {
7269
await (await token.setTokenId(tokenId)).wait();
7370
}
7471

75-
it('Should register a token', async () => {
72+
before(async () => {
7673
await deployToken();
74+
});
7775

76+
it('Should register a token', async () => {
7877
const params = defaultAbiCoder.encode(['bytes', 'address'], ['0x', token.address]);
7978

8079
await expect(tokenFactory.registerCanonicalInterchainToken(token.address))
@@ -84,19 +83,11 @@ describe('InterchainTokenFactory', () => {
8483

8584
it('Should initiate a remote interchain token deployment with no original chain name provided', async () => {
8685
const gasValue = 1234;
87-
88-
await deployToken();
89-
90-
const params = defaultAbiCoder.encode(['bytes', 'address'], ['0x', token.address]);
9186
const payload = defaultAbiCoder.encode(
9287
['uint256', 'bytes32', 'string', 'string', 'uint8', 'bytes'],
9388
[MESSAGE_TYPE_DEPLOY_INTERCHAIN_TOKEN, tokenId, name, symbol, decimals, '0x'],
9489
);
9590

96-
await expect(tokenFactory.registerCanonicalInterchainToken(token.address))
97-
.to.emit(service, 'TokenManagerDeployed')
98-
.withArgs(tokenId, tokenManagerAddress, LOCK_UNLOCK, params);
99-
10091
await expect(
10192
tokenFactory.deployRemoteCanonicalInterchainToken('', token.address, destinationChain, gasValue, {
10293
value: gasValue,
@@ -112,19 +103,11 @@ describe('InterchainTokenFactory', () => {
112103

113104
it('Should initiate a remote interchain token deployment', async () => {
114105
const gasValue = 1234;
115-
116-
await deployToken();
117-
118-
const params = defaultAbiCoder.encode(['bytes', 'address'], ['0x', token.address]);
119106
const payload = defaultAbiCoder.encode(
120107
['uint256', 'bytes32', 'string', 'string', 'uint8', 'bytes'],
121108
[MESSAGE_TYPE_DEPLOY_INTERCHAIN_TOKEN, tokenId, name, symbol, decimals, '0x'],
122109
);
123110

124-
await expect(tokenFactory.registerCanonicalInterchainToken(token.address))
125-
.to.emit(service, 'TokenManagerDeployed')
126-
.withArgs(tokenId, tokenManagerAddress, LOCK_UNLOCK, params);
127-
128111
await expect(
129112
tokenFactory.deployRemoteCanonicalInterchainToken(chainName, token.address, destinationChain, gasValue, {
130113
value: gasValue,
@@ -138,19 +121,7 @@ describe('InterchainTokenFactory', () => {
138121
.withArgs(service.address, destinationChain, service.address, keccak256(payload), payload);
139122
});
140123

141-
it('Should transfer some tokens to the factory', async () => {
142-
await deployToken();
143-
144-
const params = defaultAbiCoder.encode(['bytes', 'address'], ['0x', token.address]);
145-
146-
await expect(tokenFactory.registerCanonicalInterchainToken(token.address))
147-
.to.emit(service, 'TokenManagerDeployed')
148-
.withArgs(tokenId, tokenManagerAddress, LOCK_UNLOCK, params);
149-
});
150-
151124
it('Should revert when trying to register a canonical lock/unlock gateway token', async () => {
152-
await deployToken();
153-
154125
const tokenCap = 0;
155126
const mintLimit = 0;
156127
const tokenAddress = token.address;

0 commit comments

Comments
 (0)