Skip to content

Commit

Permalink
fix: brc-20 pending transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
alter-eggo committed Feb 26, 2024
1 parent 3230c49 commit a5f6dac
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ export function useCheckOrderStatuses(ids: string[]) {
queryKey: ['check-order-status', id],
queryFn: async () => ordinalsbotClient.orderStatus(id),
async onSuccess({ data }: Awaited<ReturnType<typeof ordinalsbotClient.orderStatus>>) {
if (data.status === 'error') {
if (data.error.includes('no such order')) {
// TODO: error processing, remove tx from state?
}
return;
}
const entry = transferMap[data.charge.id];

if (!entry) return;
Expand Down
16 changes: 12 additions & 4 deletions src/app/query/bitcoin/ordinalsbot-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ interface InscriptionOrderArgs {
}

interface OrderStatusSuccessResponse {
status: string;
status: 'success';
paid: boolean;
underpaid: boolean;
expired: boolean;
Expand Down Expand Up @@ -115,6 +115,11 @@ interface OrderStatusSuccessResponse {
sent: string;
}

interface OrderStatusErrorResponse {
status: 'error';
error: string;
}

class OrdinalsbotClient {
constructor(readonly baseUrl: string) {}

Expand All @@ -132,9 +137,12 @@ class OrdinalsbotClient {
}

async orderStatus(id: string) {
return axios.get<OrderStatusSuccessResponse>(urlJoin(this.baseUrl, 'order'), {
params: { id },
});
return axios.get<OrderStatusSuccessResponse | OrderStatusErrorResponse>(
urlJoin(this.baseUrl, 'order'),
{
params: { id },
}
);
}
}

Expand Down

0 comments on commit a5f6dac

Please sign in to comment.