Skip to content

Commit 5c05873

Browse files
committed
Fix dynamodb fields
1 parent e45c994 commit 5c05873

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

cdk/functions/fetcher.ts

+10-3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import axios from "axios";
99
import { PublishedEvent } from "typebridge";
1010
import { FetchAccountTxsEvent } from "../lib/events";
1111
import { getFromEnv } from "../lib/cdk-stack";
12+
import { print } from "util";
1213

1314
const envs = ["mainnet", "goerli", "goerli-2"];
1415
const ddb = new DynamoDBClient({});
@@ -36,6 +37,9 @@ async function checkIfTxStatusChanged(env: string, event: Event) {
3637
continue;
3738
}
3839
const previousItem = await getPreviousItem(item.hash);
40+
console.log(`Previous item: ${JSON.stringify(previousItem, null, 2)}`);
41+
console.log(`Previous item status -${previousItem?.status}-`);
42+
console.log(`Item status -${item?.status}-`);
3943
if (previousItem === null || previousItem.status !== item.status) {
4044
console.log(`Transaction status changed to ${item.status}`);
4145
await setTransactionStatus(item);
@@ -47,8 +51,11 @@ async function checkIfTxStatusChanged(env: string, event: Event) {
4751
async function getPreviousItem(hash: string): Promise<Item | null> {
4852
const params = {
4953
TableName: process.env.TX_STATUSES_TABLE,
50-
Key: { transactionHash: { S: hash } },
54+
Key: { hash: { S: hash } },
5155
};
56+
console.log(
57+
`Calling previous items with command: ${JSON.stringify(params, null, 2)}`
58+
);
5259

5360
const res = await ddb.send(new GetItemCommand(params));
5461
if (res.Item == null) {
@@ -63,8 +70,8 @@ async function setTransactionStatus(item: Item) {
6370
const params = {
6471
TableName: process.env.TX_STATUSES_TABLE,
6572
Item: {
66-
transactionHash: { S: item.hash },
67-
transactionStatus: { S: item.status },
73+
hash: { S: item.hash },
74+
status: { S: item.status },
6875
},
6976
};
7077

0 commit comments

Comments
 (0)