Skip to content

Commit

Permalink
fix transfer calldata validation
Browse files Browse the repository at this point in the history
  • Loading branch information
nohaapav committed Oct 9, 2024
1 parent 0ab726e commit e906541
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/xcm-sdk/src/adapters/transfer/ContractTransfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ export class ContractTransfer implements TransferProvider<ContractConfig> {
config: ContractConfig
): Promise<XCall> {
const { abi, asset, data } = EvmTransferFactory.get(this.#client, config);
const erc20 = new Erc20Client(this.#client, asset);

const transferCall = {
abi: JSON.stringify(abi),
Expand All @@ -38,6 +37,7 @@ export class ContractTransfer implements TransferProvider<ContractConfig> {
return transferCall;
}

const erc20 = new Erc20Client(this.#client, asset);
const allowance = await erc20.allowance(account, config.address);
if (allowance >= amount) {
return transferCall;
Expand Down
4 changes: 3 additions & 1 deletion packages/xcm-sdk/src/evm/Erc20Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ export class Erc20Client {

private validateContractAddress(address: string) {
if (!addr.isH160(address)) {
throw new Error('Contract address is not valid h160 address');
throw new Error(
'Contract address ' + address + ' is not valid h160 address'
);
}
}

Expand Down

0 comments on commit e906541

Please sign in to comment.