Files
pezkuwi-telegram-miniapp/supabase/functions/check-deposits/ton_test.ts
T
SatoshiQaziMuhammed e0d56a5fb5 fix(check-deposits): count only TON transfers sent to the deposit address (#38)
The TON check walked every jetton transfer in the deposit address's event
feed, including the ones it sends. An outgoing transfer whose comment
matched a user's deposit code would have been credited to that user; the
2026-02-13 sweep of 41.9 USDT was reported as an unknown-memo deposit on
every run.

Resolve the configured address to its raw form and skip any transfer
whose recipient is not the deposit address.
2026-10-18 19:48:14 +04:00

22 lines
847 B
TypeScript

import { assert, assertFalse } from 'jsr:@std/assert@1';
import { isIncomingTonTransfer } from './ton.ts';
const DEPOSIT = '0:c35f028ad76a7003bcb164decaec61230a77ad05c724856409e9445014b0b7be';
Deno.test('a transfer to the deposit address is a deposit', () => {
assert(isIncomingTonTransfer({ recipient: { address: DEPOSIT } }, DEPOSIT));
});
Deno.test('a sweep out of the deposit address is not a deposit', () => {
// 2026-02-13: 41.9 USDT sent from the deposit address, no memo.
const sweep = {
recipient: { address: '0:ef28248f185d0000000000000000000000000000000000000000000000000000' },
};
assertFalse(isIncomingTonTransfer(sweep, DEPOSIT));
});
Deno.test('a transfer with no recipient is not a deposit', () => {
assertFalse(isIncomingTonTransfer({}, DEPOSIT));
assertFalse(isIncomingTonTransfer(undefined, DEPOSIT));
});