Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 8 additions & 12 deletions packages/thirdweb/src/bridge/Buy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,12 @@ describe.runIf(process.env.TW_SECRET_KEY)("Bridge.Buy.quote", () => {
Buy.quote({
originChainId: 1,
originTokenAddress: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
destinationChainId: 10,
destinationChainId: 444,
destinationTokenAddress: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
buyAmountWei: toWei("1000000000"),
client: TEST_CLIENT,
}),
).rejects.toThrowErrorMatchingInlineSnapshot(
`[Error: AMOUNT_TOO_HIGH | The provided amount is too high for the requested route.]`,
);
).rejects.toThrowError();
});
});

Expand All @@ -43,8 +41,8 @@ describe.runIf(process.env.TW_SECRET_KEY)("Bridge.Buy.prepare", () => {
destinationChainId: 10,
destinationTokenAddress: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
buyAmountWei: toWei("0.01"),
sender: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
receiver: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
sender: "0x2a4f24F935Eb178e3e7BA9B53A5Ee6d8407C0709",
receiver: "0x2a4f24F935Eb178e3e7BA9B53A5Ee6d8407C0709",
client: TEST_CLIENT,
});

Expand All @@ -60,15 +58,13 @@ describe.runIf(process.env.TW_SECRET_KEY)("Bridge.Buy.prepare", () => {
Buy.prepare({
originChainId: 1,
originTokenAddress: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
destinationChainId: 10,
destinationChainId: 444,
destinationTokenAddress: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
buyAmountWei: toWei("1000000000"),
sender: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
receiver: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
sender: "0x2a4f24F935Eb178e3e7BA9B53A5Ee6d8407C0709",
receiver: "0x2a4f24F935Eb178e3e7BA9B53A5Ee6d8407C0709",
client: TEST_CLIENT,
}),
).rejects.toThrowErrorMatchingInlineSnapshot(
`[Error: AMOUNT_TOO_HIGH | The provided amount is too high for the requested route.]`,
);
).rejects.toThrowError();
});
});
8 changes: 6 additions & 2 deletions packages/thirdweb/src/bridge/Buy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ export async function quote(options: quote.Options): Promise<quote.Result> {
const response = await clientFetch(url.toString());
if (!response.ok) {
const errorJson = await response.json();
throw new Error(`${errorJson.code} | ${errorJson.message}`);
throw new Error(
`${errorJson.code} | ${errorJson.message} - ${errorJson.correlationId}`,
);
}

const { data }: { data: Quote } = await response.json();
Expand Down Expand Up @@ -228,7 +230,9 @@ export async function prepare(
const response = await clientFetch(url.toString());
if (!response.ok) {
const errorJson = await response.json();
throw new Error(`${errorJson.code} | ${errorJson.message}`);
throw new Error(
`${errorJson.code} | ${errorJson.message} - ${errorJson.correlationId}`,
);
}

const { data }: { data: PreparedQuote } = await response.json();
Expand Down
20 changes: 8 additions & 12 deletions packages/thirdweb/src/bridge/Sell.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,12 @@ describe.runIf(process.env.TW_SECRET_KEY)("Bridge.Sell.quote", () => {
Sell.quote({
originChainId: 1,
originTokenAddress: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
destinationChainId: 10,
destinationChainId: 444,
destinationTokenAddress: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
sellAmountWei: toWei("1000000000"),
client: TEST_CLIENT,
}),
).rejects.toThrowErrorMatchingInlineSnapshot(
`[Error: AMOUNT_TOO_HIGH | The provided amount is too high for the requested route.]`,
);
).rejects.toThrowError();
});
});

Expand All @@ -43,8 +41,8 @@ describe.runIf(process.env.TW_SECRET_KEY)("Bridge.Sell.prepare", () => {
destinationChainId: 10,
destinationTokenAddress: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
sellAmountWei: toWei("0.01"),
sender: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
receiver: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
sender: "0x2a4f24F935Eb178e3e7BA9B53A5Ee6d8407C0709",
receiver: "0x2a4f24F935Eb178e3e7BA9B53A5Ee6d8407C0709",
client: TEST_CLIENT,
});

Expand All @@ -60,15 +58,13 @@ describe.runIf(process.env.TW_SECRET_KEY)("Bridge.Sell.prepare", () => {
Sell.prepare({
originChainId: 1,
originTokenAddress: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
destinationChainId: 10,
destinationChainId: 444,
destinationTokenAddress: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
sellAmountWei: toWei("1000000000"),
sender: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
receiver: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
sender: "0x2a4f24F935Eb178e3e7BA9B53A5Ee6d8407C0709",
receiver: "0x2a4f24F935Eb178e3e7BA9B53A5Ee6d8407C0709",
client: TEST_CLIENT,
}),
).rejects.toThrowErrorMatchingInlineSnapshot(
`[Error: AMOUNT_TOO_HIGH | The provided amount is too high for the requested route.]`,
);
).rejects.toThrowError();
});
});
8 changes: 6 additions & 2 deletions packages/thirdweb/src/bridge/Sell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ export async function quote(options: quote.Options): Promise<quote.Result> {
const response = await clientFetch(url.toString());
if (!response.ok) {
const errorJson = await response.json();
throw new Error(`${errorJson.code} | ${errorJson.message}`);
throw new Error(
`${errorJson.code} | ${errorJson.message} - ${errorJson.correlationId}`,
);
}

const { data }: { data: Quote } = await response.json();
Expand Down Expand Up @@ -229,7 +231,9 @@ export async function prepare(
const response = await clientFetch(url.toString());
if (!response.ok) {
const errorJson = await response.json();
throw new Error(`${errorJson.code} | ${errorJson.message}`);
throw new Error(
`${errorJson.code} | ${errorJson.message} - ${errorJson.correlationId}`,
);
}

const { data }: { data: PreparedQuote } = await response.json();
Expand Down
4 changes: 3 additions & 1 deletion packages/thirdweb/src/bridge/Status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@
const response = await clientFetch(url.toString());
if (!response.ok) {
const errorJson = await response.json();
throw new Error(`${errorJson.code}: ${errorJson.message}`);
throw new Error(
`${errorJson.code} | ${errorJson.message} - ${errorJson.correlationId}`,
);

Check warning on line 117 in packages/thirdweb/src/bridge/Status.ts

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/bridge/Status.ts#L115-L117

Added lines #L115 - L117 were not covered by tests
}

const { data }: { data: Status } = await response.json();
Expand Down
3 changes: 0 additions & 3 deletions packages/thirdweb/src/utils/domains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@ let domains: { [k in keyof DomainOverrides]-?: string } = {
insight: DEFAULT_INSIGHT_URL,
};

/**
* @internal
*/
export const setThirdwebDomains = (DomainOverrides: DomainOverrides) => {
domains = {
rpc: DomainOverrides.rpc ?? DEFAULT_RPC_URL,
Expand Down
Loading