2020-09-23 13:47:24 +00:00
|
|
|
import { Waves } from "../generic/blockchains";
|
|
|
|
import { getChainValidatorsAssets } from "../generic/repo-structure";
|
|
|
|
import { ActionInterface, CheckStepInterface } from "../generic/interface";
|
|
|
|
import { isLowerCase, isUpperCase } from "../generic/types";
|
2020-08-06 19:17:38 +00:00
|
|
|
|
|
|
|
export function isWavesAddress(address: string): boolean {
|
|
|
|
return address.length == 35 &&
|
|
|
|
address.startsWith("3P") &&
|
|
|
|
isLowerCase(address) == false &&
|
|
|
|
isUpperCase(address) == false;
|
|
|
|
}
|
|
|
|
|
|
|
|
export class WavesAction implements ActionInterface {
|
|
|
|
getName(): string { return "Waves chain"; }
|
|
|
|
|
2020-08-10 08:56:41 +00:00
|
|
|
getSanityChecks(): CheckStepInterface[] {
|
2020-08-06 19:17:38 +00:00
|
|
|
return [
|
|
|
|
{
|
|
|
|
getName: () => { return "Waves validator assets must have correct format"},
|
|
|
|
check: async () => {
|
2020-09-18 14:39:31 +00:00
|
|
|
const errors: string[] = [];
|
2020-08-06 19:17:38 +00:00
|
|
|
const assets = getChainValidatorsAssets(Waves);
|
|
|
|
assets.forEach(addr => {
|
|
|
|
if (!(isWavesAddress(addr))) {
|
2020-09-16 12:52:10 +00:00
|
|
|
errors.push(`Address ${addr} should be a Waves address'`);
|
2020-08-06 19:17:38 +00:00
|
|
|
}
|
|
|
|
});
|
2020-09-16 12:52:10 +00:00
|
|
|
return [errors, []];
|
2020-08-06 19:17:38 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|