Skip to content

Commit

Permalink
made lint happy
Browse files Browse the repository at this point in the history
  • Loading branch information
Foivos committed Nov 3, 2023
1 parent 6d7f609 commit 5203931
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 33 deletions.
10 changes: 2 additions & 8 deletions contracts/interfaces/ITokenRegistrar.sol
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,7 @@ interface ITokenRegistrar {
uint256 gasValue
) external payable;

function tokenTransferFrom(
bytes32 tokenId,
uint256 amount
) external payable;
function tokenTransferFrom(bytes32 tokenId, uint256 amount) external payable;

function tokenApprove(
bytes32 tokenId,
uint256 amount
) external payable;
function tokenApprove(bytes32 tokenId, uint256 amount) external payable;
}
10 changes: 2 additions & 8 deletions contracts/token-registrars/TokenRegistrar.sol
Original file line number Diff line number Diff line change
Expand Up @@ -214,20 +214,14 @@ contract TokenRegistrar is ITokenRegistrar, ITokenManagerType, Multicall, Upgrad
}
}

function tokenTransferFrom(
bytes32 tokenId,
uint256 amount
) external payable {
function tokenTransferFrom(bytes32 tokenId, uint256 amount) external payable {
address tokenAddress = service.tokenAddress(tokenId);
IStandardizedToken token = IStandardizedToken(tokenAddress);

token.safeTransferFrom(msg.sender, address(this), amount);
}

function tokenApprove(
bytes32 tokenId,
uint256 amount
) external payable {
function tokenApprove(bytes32 tokenId, uint256 amount) external payable {
address tokenAddress = service.tokenAddress(tokenId);
IStandardizedToken token = IStandardizedToken(tokenAddress);
address tokenManager = service.tokenManagerAddress(tokenId);
Expand Down
40 changes: 23 additions & 17 deletions test/TokenRegistrars.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,17 +109,14 @@ describe('Token Registrars', () => {

await token.approve(tokenRegistrar.address, amount).then((tx) => tx.wait());

await expect(
tokenRegistrar.tokenTransferFrom(tokenId, amount),
)
.to.emit(token, 'Transfer')
.withArgs(wallet.address, tokenRegistrar.address, amount);
await expect(tokenRegistrar.tokenTransferFrom(tokenId, amount))
.to.emit(token, 'Transfer')
.withArgs(wallet.address, tokenRegistrar.address, amount);
});


it('Should approve some tokens from the registrar to the token manager', async () => {
const amount = 123456;

await deployToken();

const params = defaultAbiCoder.encode(['bytes', 'address'], ['0x', token.address]);
Expand All @@ -130,18 +127,16 @@ describe('Token Registrars', () => {

tokenManagerAddress = await service.validTokenManagerAddress(tokenId);

await expect(
tokenRegistrar.tokenApprove(tokenId, amount),
)
.to.emit(token, 'Approval')
.withArgs(tokenRegistrar.address, tokenManagerAddress, amount)
await expect(tokenRegistrar.tokenApprove(tokenId, amount))
.to.emit(token, 'Approval')
.withArgs(tokenRegistrar.address, tokenManagerAddress, amount);
});

it('Should transfer some tokens through the registrar as the deployer', async () => {
const amount = 123456;
const destinationAddress = '0x57689403';
const gasValue = 45960;

await deployToken();

const params = defaultAbiCoder.encode(['bytes', 'address'], ['0x', token.address]);
Expand All @@ -158,19 +153,30 @@ describe('Token Registrars', () => {

txs.push(await tokenRegistrar.populateTransaction.tokenTransferFrom(tokenId, amount));
txs.push(await tokenRegistrar.populateTransaction.tokenApprove(tokenId, amount));
txs.push(await tokenRegistrar.populateTransaction.interchainTransfer(tokenId, destinationChain, destinationAddress, amount, gasValue));
txs.push(
await tokenRegistrar.populateTransaction.interchainTransfer(
tokenId,
destinationChain,
destinationAddress,
amount,
gasValue,
),
);

await expect(
tokenRegistrar.multicall(txs.map(tx => tx.data), {value: gasValue}),
)
tokenRegistrar.multicall(
txs.map((tx) => tx.data),
{ value: gasValue },
),
)
.to.emit(token, 'Transfer')
.withArgs(wallet.address, tokenRegistrar.address, amount)
.and.to.emit(token, 'Approval')
.withArgs(tokenRegistrar.address, tokenManagerAddress, amount)
.and.to.emit(token, 'Transfer')
.withArgs(tokenRegistrar.address, tokenManagerAddress, amount)
.and.to.emit(service, 'InterchainTransfer')
.withArgs(tokenId, destinationChain, destinationAddress, amount)
.withArgs(tokenId, destinationChain, destinationAddress, amount);
});
});

Expand Down

0 comments on commit 5203931

Please sign in to comment.