-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add retries for only the failed requests
- Loading branch information
1 parent
2d38d02
commit 5e71b3c
Showing
7 changed files
with
52 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,32 @@ | ||
import axios from "axios"; | ||
import { Network } from "../../types/Network"; | ||
import { RawTzktGetBigMapKeys, RawTzktGetSameMultisigs } from "../tzkt/types"; | ||
import { withRateLimit } from "../tezos"; | ||
const MULTISIG_FETCH_LIMIT = 10000; | ||
const TYPE_HASH = 1963879877; | ||
const CODE_HASH = -1890025422; | ||
|
||
export const getAllMultiSigContracts = async ( | ||
network: Network | ||
): Promise<RawTzktGetSameMultisigs> => { | ||
try { | ||
const url = `${network.tzktApiUrl}/v1/contracts?typeHash=${TYPE_HASH}&codeHash=${CODE_HASH}&includeStorage=true&limit=${MULTISIG_FETCH_LIMIT}`; | ||
const { data } = await axios.get<RawTzktGetSameMultisigs>(url); | ||
export const getAllMultiSigContracts = (network: Network): Promise<RawTzktGetSameMultisigs> => | ||
withRateLimit(async () => { | ||
try { | ||
const url = `${network.tzktApiUrl}/v1/contracts?typeHash=${TYPE_HASH}&codeHash=${CODE_HASH}&includeStorage=true&limit=${MULTISIG_FETCH_LIMIT}`; | ||
const { data } = await axios.get<RawTzktGetSameMultisigs>(url); | ||
|
||
return data; | ||
} catch (error: any) { | ||
throw new Error(`Error fetching same contracts from tzkt: ${error.message}`); | ||
} | ||
}; | ||
return data; | ||
} catch (error: any) { | ||
throw new Error(`Error fetching same contracts from tzkt: ${error.message}`); | ||
} | ||
}); | ||
|
||
// get all pending operations for a multisig contract address | ||
export const getPendingOperations = async ( | ||
export const getPendingOperations = ( | ||
bigMaps: number[], | ||
network: Network | ||
): Promise<RawTzktGetBigMapKeys> => { | ||
const url = `${network.tzktApiUrl}/v1/bigmaps/keys?active=true&bigmap.in=${bigMaps.join( | ||
"," | ||
)}&limit=${MULTISIG_FETCH_LIMIT}`; | ||
const { data } = await axios.get<RawTzktGetBigMapKeys>(url); | ||
return data; | ||
}; | ||
): Promise<RawTzktGetBigMapKeys> => | ||
withRateLimit(async () => { | ||
const url = `${network.tzktApiUrl}/v1/bigmaps/keys?active=true&bigmap.in=${bigMaps.join( | ||
"," | ||
)}&limit=${MULTISIG_FETCH_LIMIT}`; | ||
const { data } = await axios.get<RawTzktGetBigMapKeys>(url); | ||
return data; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters