Skip to content

Commit 9877176

Browse files
authored
[SDK] Fix: update bridge tests (#6785)
1 parent 67768ac commit 9877176

File tree

6 files changed

+31
-32
lines changed

6 files changed

+31
-32
lines changed

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

+8-12
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,12 @@ describe.runIf(process.env.TW_SECRET_KEY)("Bridge.Buy.quote", () => {
2424
Buy.quote({
2525
originChainId: 1,
2626
originTokenAddress: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
27-
destinationChainId: 10,
27+
destinationChainId: 444,
2828
destinationTokenAddress: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
2929
buyAmountWei: toWei("1000000000"),
3030
client: TEST_CLIENT,
3131
}),
32-
).rejects.toThrowErrorMatchingInlineSnapshot(
33-
`[Error: AMOUNT_TOO_HIGH | The provided amount is too high for the requested route.]`,
34-
);
32+
).rejects.toThrowError();
3533
});
3634
});
3735

@@ -43,8 +41,8 @@ describe.runIf(process.env.TW_SECRET_KEY)("Bridge.Buy.prepare", () => {
4341
destinationChainId: 10,
4442
destinationTokenAddress: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
4543
buyAmountWei: toWei("0.01"),
46-
sender: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
47-
receiver: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
44+
sender: "0x2a4f24F935Eb178e3e7BA9B53A5Ee6d8407C0709",
45+
receiver: "0x2a4f24F935Eb178e3e7BA9B53A5Ee6d8407C0709",
4846
client: TEST_CLIENT,
4947
});
5048

@@ -60,15 +58,13 @@ describe.runIf(process.env.TW_SECRET_KEY)("Bridge.Buy.prepare", () => {
6058
Buy.prepare({
6159
originChainId: 1,
6260
originTokenAddress: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
63-
destinationChainId: 10,
61+
destinationChainId: 444,
6462
destinationTokenAddress: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
6563
buyAmountWei: toWei("1000000000"),
66-
sender: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
67-
receiver: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
64+
sender: "0x2a4f24F935Eb178e3e7BA9B53A5Ee6d8407C0709",
65+
receiver: "0x2a4f24F935Eb178e3e7BA9B53A5Ee6d8407C0709",
6866
client: TEST_CLIENT,
6967
}),
70-
).rejects.toThrowErrorMatchingInlineSnapshot(
71-
`[Error: AMOUNT_TOO_HIGH | The provided amount is too high for the requested route.]`,
72-
);
68+
).rejects.toThrowError();
7369
});
7470
});

packages/thirdweb/src/bridge/Buy.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,9 @@ export async function quote(options: quote.Options): Promise<quote.Result> {
8080
const response = await clientFetch(url.toString());
8181
if (!response.ok) {
8282
const errorJson = await response.json();
83-
throw new Error(`${errorJson.code} | ${errorJson.message}`);
83+
throw new Error(
84+
`${errorJson.code} | ${errorJson.message} - ${errorJson.correlationId}`,
85+
);
8486
}
8587

8688
const { data }: { data: Quote } = await response.json();
@@ -228,7 +230,9 @@ export async function prepare(
228230
const response = await clientFetch(url.toString());
229231
if (!response.ok) {
230232
const errorJson = await response.json();
231-
throw new Error(`${errorJson.code} | ${errorJson.message}`);
233+
throw new Error(
234+
`${errorJson.code} | ${errorJson.message} - ${errorJson.correlationId}`,
235+
);
232236
}
233237

234238
const { data }: { data: PreparedQuote } = await response.json();

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

+8-12
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,12 @@ describe.runIf(process.env.TW_SECRET_KEY)("Bridge.Sell.quote", () => {
2424
Sell.quote({
2525
originChainId: 1,
2626
originTokenAddress: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
27-
destinationChainId: 10,
27+
destinationChainId: 444,
2828
destinationTokenAddress: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
2929
sellAmountWei: toWei("1000000000"),
3030
client: TEST_CLIENT,
3131
}),
32-
).rejects.toThrowErrorMatchingInlineSnapshot(
33-
`[Error: AMOUNT_TOO_HIGH | The provided amount is too high for the requested route.]`,
34-
);
32+
).rejects.toThrowError();
3533
});
3634
});
3735

@@ -43,8 +41,8 @@ describe.runIf(process.env.TW_SECRET_KEY)("Bridge.Sell.prepare", () => {
4341
destinationChainId: 10,
4442
destinationTokenAddress: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
4543
sellAmountWei: toWei("0.01"),
46-
sender: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
47-
receiver: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
44+
sender: "0x2a4f24F935Eb178e3e7BA9B53A5Ee6d8407C0709",
45+
receiver: "0x2a4f24F935Eb178e3e7BA9B53A5Ee6d8407C0709",
4846
client: TEST_CLIENT,
4947
});
5048

@@ -60,15 +58,13 @@ describe.runIf(process.env.TW_SECRET_KEY)("Bridge.Sell.prepare", () => {
6058
Sell.prepare({
6159
originChainId: 1,
6260
originTokenAddress: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
63-
destinationChainId: 10,
61+
destinationChainId: 444,
6462
destinationTokenAddress: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
6563
sellAmountWei: toWei("1000000000"),
66-
sender: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
67-
receiver: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
64+
sender: "0x2a4f24F935Eb178e3e7BA9B53A5Ee6d8407C0709",
65+
receiver: "0x2a4f24F935Eb178e3e7BA9B53A5Ee6d8407C0709",
6866
client: TEST_CLIENT,
6967
}),
70-
).rejects.toThrowErrorMatchingInlineSnapshot(
71-
`[Error: AMOUNT_TOO_HIGH | The provided amount is too high for the requested route.]`,
72-
);
68+
).rejects.toThrowError();
7369
});
7470
});

packages/thirdweb/src/bridge/Sell.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,9 @@ export async function quote(options: quote.Options): Promise<quote.Result> {
8080
const response = await clientFetch(url.toString());
8181
if (!response.ok) {
8282
const errorJson = await response.json();
83-
throw new Error(`${errorJson.code} | ${errorJson.message}`);
83+
throw new Error(
84+
`${errorJson.code} | ${errorJson.message} - ${errorJson.correlationId}`,
85+
);
8486
}
8587

8688
const { data }: { data: Quote } = await response.json();
@@ -229,7 +231,9 @@ export async function prepare(
229231
const response = await clientFetch(url.toString());
230232
if (!response.ok) {
231233
const errorJson = await response.json();
232-
throw new Error(`${errorJson.code} | ${errorJson.message}`);
234+
throw new Error(
235+
`${errorJson.code} | ${errorJson.message} - ${errorJson.correlationId}`,
236+
);
233237
}
234238

235239
const { data }: { data: PreparedQuote } = await response.json();

packages/thirdweb/src/bridge/Status.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,9 @@ export async function status(options: status.Options): Promise<status.Result> {
112112
const response = await clientFetch(url.toString());
113113
if (!response.ok) {
114114
const errorJson = await response.json();
115-
throw new Error(`${errorJson.code}: ${errorJson.message}`);
115+
throw new Error(
116+
`${errorJson.code} | ${errorJson.message} - ${errorJson.correlationId}`,
117+
);
116118
}
117119

118120
const { data }: { data: Status } = await response.json();

packages/thirdweb/src/utils/domains.ts

-3
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,6 @@ let domains: { [k in keyof DomainOverrides]-?: string } = {
6060
insight: DEFAULT_INSIGHT_URL,
6161
};
6262

63-
/**
64-
* @internal
65-
*/
6663
export const setThirdwebDomains = (DomainOverrides: DomainOverrides) => {
6764
domains = {
6865
rpc: DomainOverrides.rpc ?? DEFAULT_RPC_URL,

0 commit comments

Comments
 (0)