init339398989
This commit is contained in:
@@ -28,7 +28,7 @@ import {
|
||||
signAndBroadcastEvmFeeTx,
|
||||
signAndBroadcastSolanaTx,
|
||||
} from './wallet-signer.service';
|
||||
import { computeAppFee, getAppFeeWallet, APP_FEE_WALLET_SOL, APP_FEE_WALLET_TRX } from '../lib/app-fee';
|
||||
import { computeAppFee, APP_FEE_WALLET_SOL, APP_FEE_WALLET_TRX } from '../lib/app-fee';
|
||||
import { SOL_TOKENS, TRX_TOKENS } from '../lib/token-registry';
|
||||
|
||||
/**
|
||||
@@ -448,8 +448,6 @@ async function executeSol(
|
||||
// ── App fee 0.7% (atomic — fee tx ПЕРЕД main bridge) ──
|
||||
// Native SOL bridge → fee in native SOL. SPL bridge → fee in same SPL token.
|
||||
// Если fee = 0 (amount слишком мал) → throw (anti-bypass).
|
||||
let feeTxid: string | undefined;
|
||||
let feeAmount: string | undefined;
|
||||
const feeAmountBig = computeAppFee(p.fromAmount);
|
||||
if (feeAmountBig <= 0n) {
|
||||
throw new Error('SOL bridge: fromAmount too small — fee = 0');
|
||||
@@ -466,8 +464,8 @@ async function executeSol(
|
||||
amount: feeAmountBig.toString(),
|
||||
token: feeSymbol,
|
||||
});
|
||||
feeTxid = feeRes.txid;
|
||||
feeAmount = feeAmountBig.toString();
|
||||
const feeTxid = feeRes.txid;
|
||||
const feeAmount = feeAmountBig.toString();
|
||||
logger.info(`SOL bridge fee broadcast: ${feeAmount} ${feeSymbol || 'lamports'} → ${APP_FEE_WALLET_SOL} (txid ${feeTxid})`);
|
||||
|
||||
// Для SOL LiFi возвращает в `transactionRequest.data` = base64-encoded VersionedTransaction.
|
||||
|
||||
@@ -260,7 +260,7 @@ export async function signAndBroadcastRawTron(p: SignRawTronParams): Promise<{ t
|
||||
// Если у нас неизвестный selector (LiFi bridge calls, custom routers) — мы НЕ можем
|
||||
// передать "0x..." как function_selector (TronGrid keccak'нёт строку и получит
|
||||
// полностью другие 4 байта → contract revert). Используем `data` напрямую.
|
||||
let data = p.callData.startsWith('0x') ? p.callData.slice(2) : p.callData;
|
||||
const data = p.callData.startsWith('0x') ? p.callData.slice(2) : p.callData;
|
||||
if (data.length < 8) throw new Error('TRX call data too short (need >= 4-byte selector)');
|
||||
const selector8 = data.slice(0, 8);
|
||||
const knownCanonical = lookupKnownSelector(selector8);
|
||||
@@ -294,7 +294,12 @@ export async function signAndBroadcastRawTron(p: SignRawTronParams): Promise<{ t
|
||||
if (!simOk) {
|
||||
const rawMsg = simRes?.result?.message;
|
||||
const msgDecoded = rawMsg
|
||||
? Buffer.from(rawMsg, 'hex').toString().replace(/[ | ||||