Skip to content

Commit

Permalink
Add spare ABI urls
Browse files Browse the repository at this point in the history
  • Loading branch information
DimaStebaev committed Feb 20, 2024
1 parent bd56733 commit 5d6e819
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 20 deletions.
50 changes: 35 additions & 15 deletions typescript/base/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,20 +1,40 @@
/* eslint-env node */
module.exports = {
extends: [
'eslint:all',
'eslint:recommended',
'plugin:@typescript-eslint/recommended'
"extends": [
"eslint:all",
"eslint:recommended",
"plugin:@typescript-eslint/recommended"
],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
root: true,
rules: {
"object-curly-spacing": [ "error", "always" ],
"padded-blocks": [ "error", "never" ],
"one-var": ["error", "never"]
},
ignorePatterns: [
"ignorePatterns": [
"lib/**",
"debug.ts"
]
};
],
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"],
"root": true,
"rules": {
"capitalized-comments": [
"error",
"always",
{
"ignoreConsecutiveComments": true
}
],
"multiline-comment-style": [
"error",
"separate-lines"
],
"object-curly-spacing": [
"error",
"always"
],
"one-var": [
"error",
"never"
],
"padded-blocks": [
"error",
"never"
]
}
};
27 changes: 22 additions & 5 deletions typescript/base/src/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,30 @@ export abstract class Project<ContractType> {
}

async downloadAbiFile (version: string) {
const response = await axios.get(this.getAbiUrl(version));
return response.data as SkaleABIFile;
const exceptions = [];
for (const abiUrl of this.getAbiUrls(version)) {
try {
// Await expression should be executed only
// when it failed on the previous iteration
// eslint-disable-next-line no-await-in-loop
const response = await axios.get(abiUrl);
return response.data as SkaleABIFile;
} catch (exception) {
exceptions.push(exception);
}
}
throw new Error(exceptions.toString());
}

getAbiUrl (version: string) {
return `${this.githubRepo}releases/download/` +
`${version}/${this.getAbiFilename(version)}`;
getAbiUrls (version: string) {
return [
`${this.githubRepo}releases/download/` +
`${version}/${this.getAbiFilename(version)}`,
`${this.githubRepo.replace(
"github.com",
"raw.githubusercontent.com"
)}abi/${version}/${this.getAbiFilename(version)}`
];
}

abstract getAbiFilename(version: string): string;
Expand Down

0 comments on commit 5d6e819

Please sign in to comment.