diff --git a/packages/thirdweb/src/bridge/Buy.test.ts b/packages/thirdweb/src/bridge/Buy.test.ts index 446f836631e..5b01db9610e 100644 --- a/packages/thirdweb/src/bridge/Buy.test.ts +++ b/packages/thirdweb/src/bridge/Buy.test.ts @@ -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(); }); }); @@ -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, }); @@ -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(); }); }); diff --git a/packages/thirdweb/src/bridge/Buy.ts b/packages/thirdweb/src/bridge/Buy.ts index b026dd7b2f9..0c145e45c70 100644 --- a/packages/thirdweb/src/bridge/Buy.ts +++ b/packages/thirdweb/src/bridge/Buy.ts @@ -80,7 +80,9 @@ export async function quote(options: quote.Options): Promise { 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(); @@ -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(); diff --git a/packages/thirdweb/src/bridge/Sell.test.ts b/packages/thirdweb/src/bridge/Sell.test.ts index d4dbe5e6fb8..f2c6809b171 100644 --- a/packages/thirdweb/src/bridge/Sell.test.ts +++ b/packages/thirdweb/src/bridge/Sell.test.ts @@ -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(); }); }); @@ -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, }); @@ -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(); }); }); diff --git a/packages/thirdweb/src/bridge/Sell.ts b/packages/thirdweb/src/bridge/Sell.ts index cf19197e119..288df5db033 100644 --- a/packages/thirdweb/src/bridge/Sell.ts +++ b/packages/thirdweb/src/bridge/Sell.ts @@ -80,7 +80,9 @@ export async function quote(options: quote.Options): Promise { 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(); @@ -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(); diff --git a/packages/thirdweb/src/bridge/Status.ts b/packages/thirdweb/src/bridge/Status.ts index c58abeb4088..dd75ddc689f 100644 --- a/packages/thirdweb/src/bridge/Status.ts +++ b/packages/thirdweb/src/bridge/Status.ts @@ -112,7 +112,9 @@ export async function status(options: status.Options): Promise { 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: Status } = await response.json(); diff --git a/packages/thirdweb/src/utils/domains.ts b/packages/thirdweb/src/utils/domains.ts index 273ef7d5389..374b7ebb783 100644 --- a/packages/thirdweb/src/utils/domains.ts +++ b/packages/thirdweb/src/utils/domains.ts @@ -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,