From 6ef492ce34eba476c8cb677da5819db9ab42f025 Mon Sep 17 00:00:00 2001 From: Alistair Singh Date: Mon, 18 Nov 2024 22:44:46 +0200 Subject: [PATCH] Fix rate limit check (#1332) * fixes * fix rate limit and up version numbers --- web/packages/api/package.json | 2 +- web/packages/api/src/subscan.ts | 6 +++--- web/packages/api/src/toEthereum.ts | 11 ++--------- web/packages/contract-types/package.json | 2 +- web/packages/contracts/package.json | 2 +- 5 files changed, 8 insertions(+), 15 deletions(-) diff --git a/web/packages/api/package.json b/web/packages/api/package.json index 1cb031dab1..dd84fc536a 100644 --- a/web/packages/api/package.json +++ b/web/packages/api/package.json @@ -1,6 +1,6 @@ { "name": "@snowbridge/api", - "version": "0.1.24", + "version": "0.1.25", "description": "Snowbridge API client", "license": "Apache-2.0", "repository": { diff --git a/web/packages/api/src/subscan.ts b/web/packages/api/src/subscan.ts index 30a708a551..3e65f34d00 100644 --- a/web/packages/api/src/subscan.ts +++ b/web/packages/api/src/subscan.ts @@ -50,12 +50,12 @@ export const createApi = (baseUrl: string, apiKey: string, options = { limit: 1 redirect: "follow", } - if (rateLimit.retryAfter !== null && rateLimit.retryAfter > 0) { - console.log("Being rate limited", rateLimit) + if (rateLimit.remaining === 0 && rateLimit.retryAfter !== null && rateLimit.retryAfter > 0) { + console.log("Being rate limited: retryAfter", rateLimit) await sleepMs(rateLimit.retryAfter * 1000) } if (rateLimit.remaining === 0 && rateLimit.reset !== null && rateLimit.reset > 0) { - console.log("Being rate limited", rateLimit) + console.log("Being rate limited: reset", rateLimit) await sleepMs(rateLimit.reset * 1000) } diff --git a/web/packages/api/src/toEthereum.ts b/web/packages/api/src/toEthereum.ts index 981f918d13..a4ff051030 100644 --- a/web/packages/api/src/toEthereum.ts +++ b/web/packages/api/src/toEthereum.ts @@ -111,10 +111,6 @@ export const validateSend = async ( ): Promise => { const options = { ...ValidateOptionDefaults, ...validateOptions } const { - ethereum, - ethereum: { - contracts: { gateway }, - }, polkadot: { api: { assetHub, bridgeHub, relaychain, parachains }, }, @@ -218,11 +214,8 @@ export const validateSend = async ( message: "Asset balance insufficient for transfer.", }) - const [bridgeStatus] = await Promise.all([ - bridgeStatusInfo(context), - ethereum.api.getNetwork(), - gateway.isTokenRegistered(tokenAddress), - ]) + const bridgeStatus = await bridgeStatusInfo(context); + const bridgeOperational = bridgeStatus.toEthereum.operatingMode.outbound === "Normal" const lightClientLatencyIsAcceptable = bridgeStatus.toEthereum.latencySeconds < options.acceptableLatencyInSeconds diff --git a/web/packages/contract-types/package.json b/web/packages/contract-types/package.json index 015d03222f..7697660737 100644 --- a/web/packages/contract-types/package.json +++ b/web/packages/contract-types/package.json @@ -1,6 +1,6 @@ { "name": "@snowbridge/contract-types", - "version": "0.1.24", + "version": "0.1.25", "description": "Snowbridge contract type bindings", "license": "Apache-2.0", "repository": { diff --git a/web/packages/contracts/package.json b/web/packages/contracts/package.json index 599807af18..3212d41225 100644 --- a/web/packages/contracts/package.json +++ b/web/packages/contracts/package.json @@ -1,6 +1,6 @@ { "name": "@snowbridge/contracts", - "version": "0.1.24", + "version": "0.1.25", "description": "Snowbridge contract source and abi.", "license": "Apache-2.0", "repository": {