Skip to content

Commit 806ec90

Browse files
committed
test: update to new status casing
1 parent fe13706 commit 806ec90

File tree

5 files changed

+51
-48
lines changed

5 files changed

+51
-48
lines changed

packages/thirdweb/src/bridge/Buy.test.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@ describe("Bridge.Buy.quote", () => {
2929
buyAmountWei: toWei("1000000000"),
3030
client: TEST_CLIENT,
3131
}),
32-
).rejects.toThrowErrorMatchingInlineSnapshot(
33-
`[Error: AmountTooHigh | The provided amount is too high for the requested route.]`,
34-
);
32+
).rejects.toThrowErrorMatchingInlineSnapshot(`[Error: AMOUNT_TOO_HIGH | The provided amount is too high for the requested route.]`);
3533
});
3634
});
3735

@@ -67,8 +65,6 @@ describe("Bridge.Buy.prepare", () => {
6765
receiver: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
6866
client: TEST_CLIENT,
6967
}),
70-
).rejects.toThrowErrorMatchingInlineSnapshot(
71-
`[Error: AmountTooHigh | The provided amount is too high for the requested route.]`,
72-
);
68+
).rejects.toThrowErrorMatchingInlineSnapshot(`[Error: AMOUNT_TOO_HIGH | The provided amount is too high for the requested route.]`);
7369
});
7470
});

packages/thirdweb/src/bridge/Sell.test.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@ describe("Bridge.Sell.quote", () => {
2929
sellAmountWei: toWei("1000000000"),
3030
client: TEST_CLIENT,
3131
}),
32-
).rejects.toThrowErrorMatchingInlineSnapshot(
33-
`[Error: AmountTooHigh | The provided amount is too high for the requested route.]`,
34-
);
32+
).rejects.toThrowErrorMatchingInlineSnapshot(`[Error: AMOUNT_TOO_HIGH | The provided amount is too high for the requested route.]`);
3533
});
3634
});
3735

@@ -67,8 +65,6 @@ describe("Bridge.Sell.prepare", () => {
6765
receiver: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
6866
client: TEST_CLIENT,
6967
}),
70-
).rejects.toThrowErrorMatchingInlineSnapshot(
71-
`[Error: AmountTooHigh | The provided amount is too high for the requested route.]`,
72-
);
68+
).rejects.toThrowErrorMatchingInlineSnapshot(`[Error: AMOUNT_TOO_HIGH | The provided amount is too high for the requested route.]`);
7369
});
7470
});

packages/thirdweb/src/bridge/Status.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ describe("Bridge.status", () => {
1212
});
1313

1414
expect(result).toBeDefined();
15-
expect(result.status).toBe("completed");
15+
expect(result.status).toBe("COMPLETED");
1616
expect(result).toMatchInlineSnapshot(`
1717
{
1818
"destinationAmount": 188625148000000n,
@@ -21,7 +21,7 @@ describe("Bridge.status", () => {
2121
"originAmount": 200000000000000n,
2222
"originChainId": 8453,
2323
"originTokenAddress": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
24-
"status": "completed",
24+
"status": "COMPLETED",
2525
"transactions": [
2626
{
2727
"chainId": 8453,

packages/thirdweb/src/bridge/Status.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,16 +114,16 @@ export async function status(options: status.Options): Promise<status.Result> {
114114
}
115115

116116
const { data }: { data: Status } = await response.json();
117-
if (data.status === "failed") {
117+
if (data.status === "FAILED") {
118118
return {
119-
status: "failed",
119+
status: "FAILED",
120120
transactions: data.transactions,
121121
};
122122
}
123123

124-
if (data.status === "pending") {
124+
if (data.status === "PENDING") {
125125
return {
126-
status: "pending",
126+
status: "PENDING",
127127
originAmount: BigInt(data.originAmount),
128128
originChainId: data.originChainId,
129129
destinationChainId: data.destinationChainId,
@@ -133,8 +133,15 @@ export async function status(options: status.Options): Promise<status.Result> {
133133
};
134134
}
135135

136+
if (data.status === "NOT_FOUND") {
137+
return {
138+
status: "NOT_FOUND",
139+
transactions: [],
140+
};
141+
}
142+
136143
return {
137-
status: "completed",
144+
status: "COMPLETED",
138145
originAmount: BigInt(data.originAmount),
139146
destinationAmount: BigInt(data.destinationAmount),
140147
originChainId: data.originChainId,

packages/thirdweb/src/bridge/types/Status.ts

Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,38 @@ import type { Address as ox__Address, Hex as ox__Hex } from "ox";
22

33
export type Status =
44
| {
5-
status: "completed";
6-
originAmount: bigint;
7-
destinationAmount: bigint;
8-
originChainId: number;
9-
destinationChainId: number;
10-
originTokenAddress: ox__Address.Address;
11-
destinationTokenAddress: ox__Address.Address;
12-
transactions: Array<{
13-
chainId: number;
14-
transactionHash: ox__Hex.Hex;
15-
}>;
16-
}
5+
status: "COMPLETED";
6+
originAmount: bigint;
7+
destinationAmount: bigint;
8+
originChainId: number;
9+
destinationChainId: number;
10+
originTokenAddress: ox__Address.Address;
11+
destinationTokenAddress: ox__Address.Address;
12+
transactions: Array<{
13+
chainId: number;
14+
transactionHash: ox__Hex.Hex;
15+
}>;
16+
}
1717
| {
18-
status: "pending";
19-
originAmount: bigint;
20-
originChainId: number;
21-
destinationChainId: number;
22-
originTokenAddress: ox__Address.Address;
23-
destinationTokenAddress: ox__Address.Address;
24-
transactions: Array<{
25-
chainId: number;
26-
transactionHash: ox__Hex.Hex;
27-
}>;
28-
}
18+
status: "PENDING";
19+
originAmount: bigint;
20+
originChainId: number;
21+
destinationChainId: number;
22+
originTokenAddress: ox__Address.Address;
23+
destinationTokenAddress: ox__Address.Address;
24+
transactions: Array<{
25+
chainId: number;
26+
transactionHash: ox__Hex.Hex;
27+
}>;
28+
}
2929
| {
30-
status: "failed";
31-
transactions: Array<{
32-
chainId: number;
33-
transactionHash: ox__Hex.Hex;
34-
}>;
35-
};
30+
status: "FAILED";
31+
transactions: Array<{
32+
chainId: number;
33+
transactionHash: ox__Hex.Hex;
34+
}>;
35+
}
36+
| {
37+
status: "NOT_FOUND";
38+
transactions: [];
39+
};

0 commit comments

Comments
 (0)