Skip to content

Commit 9315980

Browse files
authored
Merge pull request #275 from hypercerts-org/feature/index-burning-of-fractions
bugfix(storeValueTransfer): perform sql request even if to_token_id i…
2 parents f5dea4d + 215d52f commit 9315980

File tree

1 file changed

+41
-41
lines changed

1 file changed

+41
-41
lines changed

src/storage/storeValueTransfer.ts

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -121,50 +121,50 @@ export const storeValueTransfer: StorageMethod<ParsedValueTransfer> = async ({
121121
creation_block_number: block.blockNumber,
122122
creation_block_timestamp: block.timestamp.toString(),
123123
};
124+
}
124125

125-
const filteredTokens = [fromToken, toToken].filter(
126-
(token) => token !== undefined,
127-
);
126+
const filteredTokens = [fromToken, toToken].filter(
127+
(token) => token !== undefined,
128+
);
128129

129-
const parsedTokens = filteredTokens.map((token) => {
130-
return {
131-
...token,
132-
claims_id,
133-
token_id: token.token_id.toString(),
134-
units: token.units.toString(),
135-
creation_block_number: block.blockNumber.toString(),
136-
creation_block_timestamp: block.timestamp.toString(),
137-
last_update_block_number: block.blockNumber.toString(),
138-
last_update_block_timestamp: block.timestamp.toString(),
139-
};
140-
});
130+
const parsedTokens = filteredTokens.map((token) => {
131+
return {
132+
...token,
133+
claims_id,
134+
token_id: token.token_id.toString(),
135+
units: token.units.toString(),
136+
creation_block_number: block.blockNumber.toString(),
137+
creation_block_timestamp: block.timestamp.toString(),
138+
last_update_block_number: block.blockNumber.toString(),
139+
last_update_block_timestamp: block.timestamp.toString(),
140+
};
141+
});
141142

142-
requests.push(
143-
dbClient
144-
.insertInto("fractions")
145-
.values(parsedTokens)
146-
.onConflict((oc) =>
147-
oc.columns(["claims_id", "token_id"]).doUpdateSet((eb) => ({
148-
units: eb.ref("excluded.units"),
149-
fraction_id: eb.ref("excluded.fraction_id"),
150-
last_update_block_number: eb.ref(
151-
"excluded.last_update_block_number",
152-
),
153-
last_update_block_timestamp: eb.ref(
154-
"excluded.last_update_block_timestamp",
155-
),
156-
burned: eb.ref("excluded.burned"),
157-
})),
158-
)
159-
.compile(),
160-
dbClient
161-
.updateTable("contract_events")
162-
.set({ last_block_indexed: block.blockNumber })
163-
.where("contracts_id", "=", contracts_id)
164-
.where("events_id", "=", events_id)
165-
.compile(),
166-
);
167-
}
143+
requests.push(
144+
dbClient
145+
.insertInto("fractions")
146+
.values(parsedTokens)
147+
.onConflict((oc) =>
148+
oc.columns(["claims_id", "token_id"]).doUpdateSet((eb) => ({
149+
units: eb.ref("excluded.units"),
150+
fraction_id: eb.ref("excluded.fraction_id"),
151+
last_update_block_number: eb.ref(
152+
"excluded.last_update_block_number",
153+
),
154+
last_update_block_timestamp: eb.ref(
155+
"excluded.last_update_block_timestamp",
156+
),
157+
burned: eb.ref("excluded.burned"),
158+
})),
159+
)
160+
.compile(),
161+
dbClient
162+
.updateTable("contract_events")
163+
.set({ last_block_indexed: block.blockNumber })
164+
.where("contracts_id", "=", contracts_id)
165+
.where("events_id", "=", events_id)
166+
.compile(),
167+
);
168168
}
169169

170170
return requests;

0 commit comments

Comments
 (0)