bridge: mint directly to recipient
Change-Id: Idfa06609c5b9982c885eaa14b402965514b2e143
This commit is contained in:
parent
45d22ce84f
commit
245409852f
|
@ -250,11 +250,6 @@ contract Bridge is BridgeGovernance {
|
|||
nativeFee *= multiplier;
|
||||
}
|
||||
|
||||
// mint wrapped asset
|
||||
if(transfer.tokenChain != chainId()) {
|
||||
TokenImplementation(address(transferToken)).mint(address(this), nativeAmount);
|
||||
}
|
||||
|
||||
// transfer fee to arbiter
|
||||
if(nativeFee > 0) {
|
||||
require(nativeFee <= nativeAmount, "fee higher than transferred amount");
|
||||
|
@ -264,7 +259,12 @@ contract Bridge is BridgeGovernance {
|
|||
|
||||
payable(msg.sender).transfer(nativeFee);
|
||||
} else {
|
||||
SafeERC20.safeTransfer(transferToken, msg.sender, nativeFee);
|
||||
if(transfer.tokenChain != chainId()) {
|
||||
// mint wrapped asset
|
||||
TokenImplementation(address(transferToken)).mint(msg.sender, nativeFee);
|
||||
}else{
|
||||
SafeERC20.safeTransfer(transferToken, msg.sender, nativeFee);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -277,7 +277,12 @@ contract Bridge is BridgeGovernance {
|
|||
|
||||
payable(transferRecipient).transfer(transferAmount);
|
||||
} else {
|
||||
SafeERC20.safeTransfer(transferToken, transferRecipient, transferAmount);
|
||||
if(transfer.tokenChain != chainId()) {
|
||||
// mint wrapped asset
|
||||
TokenImplementation(address(transferToken)).mint(transferRecipient, transferAmount);
|
||||
}else{
|
||||
SafeERC20.safeTransfer(transferToken, transferRecipient, transferAmount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -436,9 +436,10 @@ contract("Bridge", function () {
|
|||
assert.equal(bridgeBalanceAfter.toString(10), "0");
|
||||
})
|
||||
|
||||
it("should mint bridged assets wrappers on transfer from another chain", async function() {
|
||||
it("should mint bridged assets wrappers on transfer from another chain and handle fees correctly", async function() {
|
||||
const accounts = await web3.eth.getAccounts();
|
||||
const amount = "1000000000000000000";
|
||||
const fee = "1000000000000000";
|
||||
|
||||
const initialized = new web3.eth.Contract(BridgeImplementationFullABI, TokenBridge.address);
|
||||
|
||||
|
@ -462,7 +463,7 @@ contract("Bridge", function () {
|
|||
// receiving chain
|
||||
web3.eth.abi.encodeParameter("uint16", testChainId).substring(2 + (64 - 4)) +
|
||||
// fee
|
||||
"0000000000000000000000000000000000000000000000000000000000000000";
|
||||
web3.eth.abi.encodeParameter("uint256", new BigNumber(fee).div(1e10).toString()).substring(2);
|
||||
|
||||
const vm = await signAndEncodeVM(
|
||||
0,
|
||||
|
@ -480,15 +481,23 @@ contract("Bridge", function () {
|
|||
|
||||
await initialized.methods.completeTransfer("0x" + vm).send({
|
||||
value : 0,
|
||||
from : accounts[0],
|
||||
from : accounts[1],
|
||||
gasLimit : 2000000
|
||||
});
|
||||
|
||||
const accountBalanceAfter = await wrappedAsset.methods.balanceOf(accounts[0]).call();
|
||||
const senderBalanceAfter = await wrappedAsset.methods.balanceOf(accounts[1]).call();
|
||||
const totalSupplyAfter = await wrappedAsset.methods.totalSupply().call();
|
||||
|
||||
assert.equal(accountBalanceAfter.toString(10), amount);
|
||||
assert.equal(accountBalanceAfter.toString(10), new BigNumber(amount).minus(fee).toString(10));
|
||||
assert.equal(senderBalanceAfter.toString(10), fee);
|
||||
assert.equal(totalSupplyAfter.toString(10), amount);
|
||||
|
||||
await wrappedAsset.methods.transfer(accounts[0], fee).send({
|
||||
value : 0,
|
||||
from : accounts[1],
|
||||
gasLimit : 2000000
|
||||
});
|
||||
})
|
||||
|
||||
it("should burn bridged assets wrappers on transfer to another chain", async function() {
|
||||
|
|
Loading…
Reference in New Issue