Skip to content

Commit db4d487

Browse files
authored
Merge pull request #279 from hypercerts-org/develop
Deploy to PROD
2 parents 7535e8f + 7087c90 commit db4d487

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

scripts/update_sales_values.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import "dotenv/config";
22

3-
import { HypercertExchangeAbi, getHypercertTokenId, parseClaimOrFractionId } from "@hypercerts-org/sdk";
3+
import {
4+
HypercertExchangeAbi,
5+
getHypercertTokenId,
6+
parseClaimOrFractionId,
7+
} from "@hypercerts-org/sdk";
48
import { createClient } from "@supabase/supabase-js";
59
import { Chain, erc20Abi, getAddress, parseEventLogs, zeroAddress } from "viem";
610
import {
@@ -37,6 +41,10 @@ const getChain = (chainId: number) => {
3741
};
3842

3943
const main = async () => {
44+
// This scripts has been deprecated as the transaction_hash is no longer unique for each sale
45+
// since we introduced batching of sales
46+
throw new Error("This script is deprecated");
47+
4048
console.log("update_sales_values");
4149
// Get all sales rows
4250
// Create supabase client
@@ -167,7 +175,6 @@ const main = async () => {
167175
};
168176
});
169177

170-
171178
// Upsert rows
172179
console.log("Upserting rows");
173180
console.log(JSON.stringify(rowsToUpsert, null, 2));

src/storage/storeTakerBid.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ export const TakerBid = z.object({
2727
transaction_hash: z.string(),
2828
currency_amount: z.bigint(),
2929
fee_amounts: z.array(z.bigint()),
30-
fee_recipients: z.array(z.string().refine(isAddress, { message: "Invalid fee recipient address" })),
30+
fee_recipients: z.array(
31+
z.string().refine(isAddress, { message: "Invalid fee recipient address" }),
32+
),
3133
});
3234

3335
export type TakerBid = z.infer<typeof TakerBid>;
@@ -145,8 +147,10 @@ export const storeTakerBid: StorageMethod<TakerBid> = async ({
145147
})
146148
.filter((x) => x !== null);
147149

148-
console.log("[IndexTakerBid] Deleting invalid orders", ordersToUpdate);
149-
await supabaseData.from("marketplace_orders").upsert(ordersToUpdate);
150+
if (ordersToUpdate.length > 0) {
151+
console.log("[IndexTakerBid] Deleting invalid orders", ordersToUpdate);
152+
await supabaseData.from("marketplace_orders").upsert(ordersToUpdate);
153+
}
150154
}
151155

152156
return [
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
-- Drop the unique constraint first
2+
alter table "public"."sales"
3+
drop constraint "sales_transactionHash_key";

0 commit comments

Comments
 (0)