Skip to content

Commit 7617c77

Browse files
committed
Merge dev: fix accountKeys property name for solana/kit
2 parents 9ce8fe8 + fab7482 commit 7617c77

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

src/services/deposit.ts

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ interface SolanaRpc {
1111
getTransaction(signature: any, opts: any): {
1212
send(): Promise<{
1313
meta: { preBalances: number[]; postBalances: number[] } | null;
14-
transaction: { message: { staticAccountKeys: string[] } };
14+
transaction: { message: { accountKeys?: string[]; staticAccountKeys?: string[] } };
1515
} | null>;
1616
};
1717
}
@@ -49,24 +49,26 @@ export class DepositDetector {
4949
try {
5050
const txDetail = await this.cfg.rpc.getTransaction(sig, {
5151
maxSupportedTransactionVersion: 0,
52-
}).send();
52+
}).send() as any;
5353
if (!txDetail?.meta) {
5454
log.warn({ sig }, 'verifyDeposit: no meta');
5555
return false;
5656
}
5757
const { preBalances, postBalances } = txDetail.meta;
58-
const accountKeys = txDetail.transaction.message.staticAccountKeys;
59-
const treasuryIdx = accountKeys.findIndex(k => String(k) === String(this.cfg.treasuryAddress));
58+
// @solana/kit returns accountKeys (not staticAccountKeys)
59+
const msg = txDetail.transaction.message;
60+
const accountKeys: string[] = (msg.accountKeys ?? msg.staticAccountKeys ?? []).map(String);
61+
if (accountKeys.length === 0) {
62+
log.warn({ sig, messageKeys: Object.keys(msg) }, 'verifyDeposit: no account keys found');
63+
return false;
64+
}
65+
const treasuryIdx = accountKeys.findIndex(k => k === String(this.cfg.treasuryAddress));
6066
if (treasuryIdx === -1) {
61-
log.warn({ sig, accountKeys: accountKeys.map(String), treasury: this.cfg.treasuryAddress }, 'verifyDeposit: treasury not in accountKeys');
67+
log.warn({ sig, accountKeys, treasury: this.cfg.treasuryAddress }, 'verifyDeposit: treasury not in accountKeys');
6268
return false;
6369
}
6470
const received = (postBalances[treasuryIdx] - preBalances[treasuryIdx]) / 1_000_000_000;
65-
const ok = received >= expectedSol * 0.999;
66-
if (!ok) {
67-
log.warn({ sig, received, expectedSol, threshold: expectedSol * 0.999 }, 'verifyDeposit: amount below threshold');
68-
}
69-
return ok;
71+
return received >= expectedSol * 0.999;
7072
} catch (err) {
7173
log.warn({ sig, err }, 'verifyDeposit: exception');
7274
return false;
@@ -117,13 +119,14 @@ export class DepositDetector {
117119
}).send();
118120
if (!txDetail?.meta) return;
119121

120-
const accountKeys = txDetail.transaction.message.staticAccountKeys;
121-
const treasuryIdx = accountKeys.findIndex(k => String(k) === String(this.cfg.treasuryAddress));
122+
const msg = (txDetail as any).transaction.message;
123+
const accountKeys: string[] = (msg.accountKeys ?? msg.staticAccountKeys ?? []).map(String);
124+
const treasuryIdx = accountKeys.findIndex(k => k === String(this.cfg.treasuryAddress));
122125
if (treasuryIdx === -1) return;
123126

124127
const received = (txDetail.meta.postBalances[treasuryIdx] - txDetail.meta.preBalances[treasuryIdx]) / 1_000_000_000;
125128
// Sender is the first account (fee payer)
126-
const sender = String(accountKeys[0]);
129+
const sender = accountKeys[0];
127130

128131
const matching = pendingSells.find(
129132
(tx) => tx.wallet === sender && received >= tx.sol_amount * 0.999,

0 commit comments

Comments
 (0)