Skip to content

Commit

Permalink
api: better swap logging
Browse files Browse the repository at this point in the history
  • Loading branch information
dcposch committed Sep 3, 2024
1 parent b567885 commit db3a422
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 15 deletions.
15 changes: 6 additions & 9 deletions packages/daimo-api/src/contract/foreignCoinIndexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ export class ForeignCoinIndexer extends Indexer {
])
.where("chain_id", "=", "" + chainConfig.chainL2.id)
.where((eb) => eb.between("block_num", "" + from, "" + to))
.orderBy("block_num", "asc")
.orderBy("sort_idx", "asc")
.orderBy("block_num")
.orderBy("sort_idx")
.execute()
);

Expand Down Expand Up @@ -200,15 +200,12 @@ export class ForeignCoinIndexer extends Indexer {
this.pendingSwapsByAddr.set(addr, newPendingSwaps);
} else {
// inbound transfer, add as a pending swap
const pending = this.pendingSwapsByAddr.get(addr) || [];
pending.push(log);
this.pendingSwapsByAddr.set(addr, pending);
console.log(
`[FOREIGN-COIN] inbound token transfer to ${addrName} ${addr}, ${log.value} ${log.foreignToken.symbol} ${log.foreignToken.token}`
`[FOREIGN-COIN] inbound token transfer to ${addrName} ${addr}, ${log.value} ${log.foreignToken.symbol} ${log.foreignToken.token}, new bal ${newBal}, # swaps pending: ${pending.length}`
);
const pending = this.pendingSwapsByAddr.get(addr);
if (pending != null) {
pending.push(log);
} else {
this.pendingSwapsByAddr.set(addr, [log]);
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions packages/daimo-api/src/contract/homeCoinIndexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ export class HomeCoinIndexer extends Indexer {
.where("chain_id", "=", "" + chainConfig.chainL2.id)
.where((e) => e.between("block_num", "" + from, "" + to))
.where("token", "=", hexToBuffer(chainConfig.tokenAddress))
.orderBy("block_num", "asc")
.orderBy("sort_idx", "asc")
.orderBy("block_num")
.orderBy("sort_idx")
.execute()
);

Expand Down
1 change: 0 additions & 1 deletion packages/daimo-api/src/contract/keyRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ export class KeyRegistry extends Indexer {
.where("chain_id", "=", "" + chainConfig.chainL2.id)
.where((eb) => eb.between("block_num", "" + from, "" + to))
.orderBy("block_num")
.orderBy("tx_idx")
.orderBy("log_idx")
.execute()
);
Expand Down
1 change: 0 additions & 1 deletion packages/daimo-api/src/contract/nameRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ export class NameRegistry extends Indexer {
.where("chain_id", "=", "" + chainConfig.chainL2.id)
.where((eb) => eb.between("block_num", "" + from, "" + to))
.orderBy("block_num")
.orderBy("tx_idx")
.orderBy("log_idx")
.execute()
);
Expand Down
1 change: 0 additions & 1 deletion packages/daimo-api/src/contract/noteIndexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ export class NoteIndexer extends Indexer {
.where("chain_id", "=", "" + chainConfig.chainL2.id)
.where((eb) => eb.between("block_num", "" + from, "" + to))
.orderBy("block_num")
.orderBy("tx_idx")
.orderBy("log_idx")
.execute()
);
Expand Down
1 change: 0 additions & 1 deletion packages/daimo-api/src/contract/requestIndexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ export class RequestIndexer extends Indexer {
.where("chain_id", "=", "" + chainConfig.chainL2.id)
.where((eb) => eb.between("block_num", "" + from, "" + to))
.orderBy("block_num")
.orderBy("tx_idx")
.orderBy("log_idx")
.execute()
);
Expand Down

0 comments on commit db3a422

Please sign in to comment.