From 3f88b62df2c7daee28327d994f5abc077a2eceef Mon Sep 17 00:00:00 2001 From: Frank Li Date: Mon, 15 Jan 2024 16:38:26 +1100 Subject: [PATCH 1/3] [TD-1115\ Update mainnet and testnet orderbook contract address references (#1337) Signed-off-by: Frank Li Co-authored-by: Sam Jeston --- packages/orderbook/src/config/config.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/orderbook/src/config/config.ts b/packages/orderbook/src/config/config.ts index c89b631962..cf12bdfda7 100644 --- a/packages/orderbook/src/config/config.ts +++ b/packages/orderbook/src/config/config.ts @@ -26,8 +26,8 @@ export function getOrderbookConfig( switch (environment) { case Environment.SANDBOX: return { - seaportContractAddress: '0x3A0C2Ba54D6CBd3121F01b96dFd20e99D1696C9D', - zoneContractAddress: '0x2EA937879beeF3393853A74Ad62F9ad7DA0B9E81', + seaportContractAddress: '0x7d117aA8BD6D31c4fa91722f246388f38ab1942c', + zoneContractAddress: '0x8831867E347AB87FA30199C5B695F0A31604Bb52', apiEndpoint: 'https://api.sandbox.immutable.com', chainName: TESTNET_CHAIN_NAME, provider: new providers.JsonRpcProvider( @@ -37,8 +37,8 @@ export function getOrderbookConfig( // not yet deployed case Environment.PRODUCTION: return { - seaportContractAddress: '', - zoneContractAddress: '', + seaportContractAddress: '0x6c12aD6F0bD274191075Eb2E78D7dA5ba6453424', + zoneContractAddress: '0x00338b92Bec262078B3e49BF12bbEA058916BF91', apiEndpoint: 'https://api.immutable.com', chainName: MAINNET_CHAIN_NAME, provider: new providers.JsonRpcProvider( From 03f56f5c33362cce0ab654fdabd12285ff2e3a55 Mon Sep 17 00:00:00 2001 From: Andrea Rampin Date: Mon, 15 Jan 2024 17:37:40 +1100 Subject: [PATCH 2/3] refactor: WT-2041 - better axios response handling (#1336) --- .../sdk/src/availability/availability.test.ts | 10 ++++----- .../sdk/src/availability/availability.ts | 21 ++++++++++--------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/packages/checkout/sdk/src/availability/availability.test.ts b/packages/checkout/sdk/src/availability/availability.test.ts index 602ca10e11..9f73cf7bc0 100644 --- a/packages/checkout/sdk/src/availability/availability.test.ts +++ b/packages/checkout/sdk/src/availability/availability.test.ts @@ -11,10 +11,8 @@ describe('availabilityService', () => { }); describe('checkDexAvailability', () => { - it('should return true when status is 204', async () => { - const mockResponse = { - status: 204, - }; + it('should return true when status is 2xx', async () => { + const mockResponse = {}; mockedAxios.post.mockResolvedValueOnce(mockResponse); const response = await availabilityService(true, false).checkDexAvailability(); @@ -26,7 +24,7 @@ describe('availabilityService', () => { const mockResponse = { status: 403, }; - mockedAxios.post.mockResolvedValueOnce(mockResponse); + mockedAxios.post.mockRejectedValueOnce({ response: mockResponse }); const response = await availabilityService(true, false).checkDexAvailability(); expect(mockedAxios.post).toHaveBeenCalledTimes(1); @@ -38,7 +36,7 @@ describe('availabilityService', () => { status: 500, statusText: 'error message', }; - mockedAxios.post.mockResolvedValueOnce(mockResponse); + mockedAxios.post.mockRejectedValueOnce({ response: mockResponse }); await expect(availabilityService(true, false).checkDexAvailability()) .rejects diff --git a/packages/checkout/sdk/src/availability/availability.ts b/packages/checkout/sdk/src/availability/availability.ts index 09f22a00c1..13cb8c376a 100644 --- a/packages/checkout/sdk/src/availability/availability.ts +++ b/packages/checkout/sdk/src/availability/availability.ts @@ -24,19 +24,20 @@ export const availabilityService = ( try { response = await axios.post(`${postEndpoint()}/v1/availability/checkout/swap`); } catch (error: any) { + // The request was made and the server responded with a status code + // that falls out of the range of 2xx response = error.response; - } - if (response.status === 403) { - return false; - } - if (response.status === 204) { - return true; + // If 403 then the service is geo-blocked + if (response.status === 403) return false; + + throw new CheckoutError( + `Error fetching from api: ${response.status} ${response.statusText}`, + CheckoutErrorType.API_ERROR, + ); } - throw new CheckoutError( - `Error fetching from api: ${response.status} ${response.statusText}`, - CheckoutErrorType.API_ERROR, - ); + + return true; }; return { From 451cd9d97e4de0263a2c407f3abd377ca8a6b98e Mon Sep 17 00:00:00 2001 From: Andrea Rampin Date: Mon, 15 Jan 2024 18:42:24 +1100 Subject: [PATCH 3/3] fix: WT-2047 - missing translations (#1342) --- packages/checkout/widgets-lib/src/locales/en.json | 6 ++++-- packages/checkout/widgets-lib/src/locales/ja.json | 2 ++ packages/checkout/widgets-lib/src/locales/ko.json | 6 ++++-- packages/checkout/widgets-lib/src/locales/zh.json | 6 ++++-- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/packages/checkout/widgets-lib/src/locales/en.json b/packages/checkout/widgets-lib/src/locales/en.json index 80dda425de..179c15acdf 100644 --- a/packages/checkout/widgets-lib/src/locales/en.json +++ b/packages/checkout/widgets-lib/src/locales/en.json @@ -406,8 +406,10 @@ "fiatPricePrefix": "~ USD $" }, "BRIDGE_FAILURE": { - "statusText": "Transaction failed", - "actionText": "Review & Try again" + "bridgeFailureText": { + "statusText": "Transaction failed", + "actionText": "Review & Try again" + } }, "APPROVE_TRANSACTION": { "content": { diff --git a/packages/checkout/widgets-lib/src/locales/ja.json b/packages/checkout/widgets-lib/src/locales/ja.json index fa3e34b8c2..171440c39e 100644 --- a/packages/checkout/widgets-lib/src/locales/ja.json +++ b/packages/checkout/widgets-lib/src/locales/ja.json @@ -409,8 +409,10 @@ "fiatPricePrefix": "~ USD $" }, "BRIDGE_FAILURE": { + "bridgeFailureText": { "statusText": "トランザクションが失敗しました", "actionText": "再確認してもう一度試す" + } }, "APPROVE_TRANSACTION": { "content": { diff --git a/packages/checkout/widgets-lib/src/locales/ko.json b/packages/checkout/widgets-lib/src/locales/ko.json index 587bca7f21..a4a1b4e971 100644 --- a/packages/checkout/widgets-lib/src/locales/ko.json +++ b/packages/checkout/widgets-lib/src/locales/ko.json @@ -406,8 +406,10 @@ "fiatPricePrefix": "~ USD $" }, "BRIDGE_FAILURE": { - "statusText": "거래 실패", - "actionText": "검토하고 다시 시도하세요" + "bridgeFailureText": { + "statusText": "거래 실패", + "actionText": "검토하고 다시 시도하세요" + } }, "APPROVE_TRANSACTION": { "content": { diff --git a/packages/checkout/widgets-lib/src/locales/zh.json b/packages/checkout/widgets-lib/src/locales/zh.json index f9bc721386..f142c0e764 100644 --- a/packages/checkout/widgets-lib/src/locales/zh.json +++ b/packages/checkout/widgets-lib/src/locales/zh.json @@ -406,8 +406,10 @@ "fiatPricePrefix": "~ 美元 $" }, "BRIDGE_FAILURE": { - "statusText": "交易失败", - "actionText": "审查并重试" + "bridgeFailureText": { + "statusText": "交易失败", + "actionText": "审查并重试" + } }, "APPROVE_TRANSACTION": { "content": {