-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #409 from telosnetwork/develop
v1.0.1-rc
- Loading branch information
Showing
29 changed files
with
268 additions
and
141 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/usr/bin/env sh | ||
. "$(dirname -- "$0")/_/husky.sh" | ||
|
||
yarn test |
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
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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import axios from 'axios'; | ||
import { Chain } from 'src/types/Chain'; | ||
import { getChain } from 'src/config/ConfigManager'; | ||
|
||
const MAX_REQUESTS_COUNT = 5; | ||
const INTERVAL_MS = 10; | ||
let PENDING_REQUESTS = 0; | ||
|
||
const chain: Chain = getChain(); | ||
|
||
const telosApi = axios.create({ baseURL: chain.getApiEndpoint() }); | ||
|
||
telosApi.interceptors.request.use(function (config) { | ||
return new Promise((resolve) => { | ||
const interval = setInterval(() => { | ||
if (PENDING_REQUESTS < MAX_REQUESTS_COUNT) { | ||
PENDING_REQUESTS++; | ||
clearInterval(interval); | ||
resolve(config); | ||
} | ||
}, INTERVAL_MS); | ||
}); | ||
}); | ||
|
||
/** | ||
* Axios Response Interceptor | ||
*/ | ||
telosApi.interceptors.response.use( | ||
function (response) { | ||
PENDING_REQUESTS = Math.max(0, PENDING_REQUESTS - 1); | ||
return Promise.resolve(response); | ||
}, | ||
function (error) { | ||
PENDING_REQUESTS = Math.max(0, PENDING_REQUESTS - 1); | ||
return Promise.reject(error); | ||
} | ||
); | ||
|
||
export const getApy = async function (): Promise<string> { | ||
const response = await telosApi.get('apy/native'); | ||
return response.data as string; | ||
}; |
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
Oops, something went wrong.