fix: provide FromAccountIndex and ApiKeyIndex for Lighter nonce auto-fetch

Root cause: SDK requires these fields to fetch nonce from API, otherwise nonce gets cached/stuck
This commit is contained in:
tinkle-community
2026-01-13 13:42:14 +08:00
parent aa7aa94275
commit 68e8a6e4b0
2 changed files with 10 additions and 2 deletions

View File

@@ -284,9 +284,13 @@ func (t *LighterTraderV2) CancelOrder(symbol, orderID string) error {
}
// Sign transaction using SDK
// Must provide FromAccountIndex and ApiKeyIndex for nonce auto-fetch to work
nonce := int64(-1) // -1 means auto-fetch
apiKeyIdx := t.apiKeyIndex
tx, err := t.txClient.GetCancelOrderTransaction(txReq, &types.TransactOpts{
Nonce: &nonce,
FromAccountIndex: &t.accountIndex,
ApiKeyIndex: &apiKeyIdx,
Nonce: &nonce,
})
if err != nil {
return fmt.Errorf("failed to sign cancel order: %w", err)