Skip to content

Commit

Permalink
Fix cn non native calcs (5.31.10)
Browse files Browse the repository at this point in the history
  • Loading branch information
axtezy authored Jul 18, 2024
2 parents 376a62f + 6cf9159 commit d3674e5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rubic-sdk",
"version": "5.31.9",
"version": "5.31.10",
"description": "Simplify dApp creation",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { FailedToCheckForTransactionReceiptError, RubicSdkError } from 'src/comm
import { PriceTokenAmount } from 'src/common/tokens';
import { getGasOptions } from 'src/common/utils/options';
import { EvmBlockchainName } from 'src/core/blockchain/models/blockchain-name';
import { CHAIN_TYPE } from 'src/core/blockchain/models/chain-type';
import { BlockchainsInfo } from 'src/core/blockchain/utils/blockchains-info/blockchains-info';
import { EvmWeb3Private } from 'src/core/blockchain/web3-private-service/web3-private/evm-web3-private/evm-web3-private';
import { ERC20_TOKEN_ABI } from 'src/core/blockchain/web3-public-service/web3-public/evm-web3-public/constants/erc-20-token-abi';
Expand Down Expand Up @@ -288,16 +289,24 @@ export class ChangenowCrossChainTrade extends EvmCrossChainTrade {
config.data = '0x';
config.to = this.paymentInfo.payinAddress;
} else {
const encodedConfig = EvmWeb3Pure.encodeMethodCall(
this.from.address,
ERC20_TOKEN_ABI,
'transfer',
[this.paymentInfo.payinAddress, this.from.stringWeiAmount],
'0'
);
config.value = '0';
config.to = this.from.address;
config.data = encodedConfig.data;
const blockchainType = BlockchainsInfo.getChainType(this.from.blockchain);

if (blockchainType === CHAIN_TYPE.EVM) {
const encodedConfig = EvmWeb3Pure.encodeMethodCall(
this.from.address,
ERC20_TOKEN_ABI,
'transfer',
[this.paymentInfo.payinAddress, this.from.stringWeiAmount],
'0'
);
config.value = '0';
config.to = this.from.address;
config.data = encodedConfig.data;
} else {
config.value = '0';
config.data = '0x';
config.to = this.paymentInfo.payinAddress;
}
}

return { config, amount: toAmountWei };
Expand Down

0 comments on commit d3674e5

Please sign in to comment.