Skip to content

Commit

Permalink
Fix rate limit check (#1332)
Browse files Browse the repository at this point in the history
* fixes

* fix rate limit and up version numbers
  • Loading branch information
alistair-singh authored Nov 18, 2024
1 parent 26fd3ac commit 6ef492c
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 15 deletions.
2 changes: 1 addition & 1 deletion web/packages/api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@snowbridge/api",
"version": "0.1.24",
"version": "0.1.25",
"description": "Snowbridge API client",
"license": "Apache-2.0",
"repository": {
Expand Down
6 changes: 3 additions & 3 deletions web/packages/api/src/subscan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
11 changes: 2 additions & 9 deletions web/packages/api/src/toEthereum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,6 @@ export const validateSend = async (
): Promise<SendValidationResult> => {
const options = { ...ValidateOptionDefaults, ...validateOptions }
const {
ethereum,
ethereum: {
contracts: { gateway },
},
polkadot: {
api: { assetHub, bridgeHub, relaychain, parachains },
},
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion web/packages/contract-types/package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion web/packages/contracts/package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down

0 comments on commit 6ef492c

Please sign in to comment.