Skip to content

Commit

Permalink
Merge pull request #55 from pnetwork-association/fix/37
Browse files Browse the repository at this point in the history
Fix #37 (4/4)
  • Loading branch information
gitmp01 authored Nov 6, 2024
2 parents 5999374 + dbaa2e1 commit bee3383
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 3 deletions.
9 changes: 7 additions & 2 deletions solidity/src/contracts/Adapter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,19 @@ contract Adapter is IAdapter, Ownable, ReentrancyGuard {
address public pam;
uint256 public minFee;
mapping(bytes32 => bool) public pastEvents;
bool public isNative;

constructor(
address xerc20_,
address erc20_,
bool isNative_,
address feesManager_,
address pam_
) Ownable(msg.sender) {
erc20 = erc20_;
isNative = isNative_;
if (!isNative) {
erc20 = erc20_;
}
xerc20 = xerc20_;
feesManager = feesManager_;
pam = pam_;
Expand Down Expand Up @@ -124,7 +129,7 @@ contract Adapter is IAdapter, Ownable, ReentrancyGuard {
string memory recipient,
bytes memory data
) external payable {
if (erc20 == address(0)) {
if (erc20 == address(0) && isNative) {
_swapNative(destinationChainId, recipient, data);
} else {
_swapToken(token, amount, destinationChainId, recipient, data);
Expand Down
1 change: 1 addition & 0 deletions solidity/test/forge/Adapter.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ contract AdapterTest is Test, Helper {
adapter = new Adapter(
address(xerc20),
address(erc20),
notNative,
address(feesManager),
address(pam)
);
Expand Down
1 change: 1 addition & 0 deletions solidity/test/forge/Helper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ abstract contract Helper is Test, DeployHelper {
adapter = new Adapter(
address(xerc20),
address(erc20),
notNative,
address(feesManager),
address(pam)
);
Expand Down
1 change: 1 addition & 0 deletions solidity/test/hardhat/Adapter.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ const deployERC1820 = () => setCode(ERC1820, ERC1820BYTES)
const adapter = await deploy(hre, 'Adapter', [
pTokenV2.target,
erc20.target,
_isNative,
feesManager,
PAM,
])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ conditionalDescribe(
const burningLimit = hre.ethers.parseEther('500000')
const swapAmount = hre.ethers.parseEther('10000')
const userdata = '0x'
const isNative = false

let erc20,
adapterEth,
Expand Down Expand Up @@ -93,6 +94,7 @@ conditionalDescribe(
adapterBsc = await deploy(hre, 'Adapter', [
ptoken.target,
ADDRESS_ERC20_TOKEN,
isNative,
feesManagerBsc,
pamBsc,
])
Expand Down Expand Up @@ -179,7 +181,6 @@ conditionalDescribe(

const name = `p${await erc20.name()}`
const symbol = `p${await erc20.symbol()}`
const isNative = false

const factory = await deploy(hre, 'XERC20Factory', [])
xerc20 = await deployXERC20(hre, factory, name, symbol)
Expand All @@ -204,6 +205,7 @@ conditionalDescribe(
adapterEth = await deploy(hre, 'Adapter', [
xerc20.target,
ADDRESS_ERC20_TOKEN,
isNative,
feesManagerEth,
pamEth,
])
Expand Down

0 comments on commit bee3383

Please sign in to comment.