Skip to content

Commit

Permalink
fix bug for klaster
Browse files Browse the repository at this point in the history
  • Loading branch information
nampc1 committed Sep 8, 2024
1 parent 948be5d commit fa25601
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,11 @@ export async function getERC20SpendingApprovalTx (spender: _Address, owner: _Add
maxPriorityFeePerGas: priority.maxPriorityFeePerGas?.toString()
} as TransactionConfig;
}

export function encodeSpendingApproval (spender: _Address, owner: _Address, contractAddress: _Address, evmApi: _EvmApi, amount = '115792089237316195423570985008687907853269984665640564039457584007913129639935'): string {
const tokenContract = getERC20Contract(contractAddress, evmApi);
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
const approveCall = tokenContract.methods.approve(spender, amount); // TODO: need test
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
return approveCall.encodeABI() as string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import {
rawTx
} from 'klaster-sdk';
import { encodeAcrossCallData, getAcrossSuggestedFee } from './helper/tx-encoder';
import { log } from "console";

export interface AcrossSuggestedFeeResp {
totalRelayFee: {
Expand Down Expand Up @@ -82,12 +81,10 @@ export class KlasterService {
this.bridgePlugin = async (data: BridgePluginParams) => {
const feeResponse = await getAcrossSuggestedFee(data);

console.log(feeResponse);

const outputAmount = data.amount - BigInt(feeResponse.totalRelayFee.total);
const acrossApproveTx = encodeApproveTx({
tokenAddress: data.sourceToken,
amount: outputAmount,
amount: outputAmount * 10n,
recipient: feeResponse.spokePoolAddress
});

Expand Down

0 comments on commit fa25601

Please sign in to comment.