trustwallet-assets/script/blockchain/waves.ts
Adam R ec1fe7f6ee
[internal] Script restructuring/refactoring (#4070)
* Make non-mandatory action interface elements optional.

* Remove one unused import

* Scripts main renamed to entrypoint.

* Script common rename to generic

* Move generic scripts from action to generic.

* Move chain-specific scripts to blockchain.

Co-authored-by: Catenocrypt <catenocrypt@users.noreply.github.com>
2020-09-23 15:47:24 +02:00

34 lines
1.2 KiB
TypeScript

import { Waves } from "../generic/blockchains";
import { getChainValidatorsAssets } from "../generic/repo-structure";
import { ActionInterface, CheckStepInterface } from "../generic/interface";
import { isLowerCase, isUpperCase } from "../generic/types";
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"; }
getSanityChecks(): CheckStepInterface[] {
return [
{
getName: () => { return "Waves validator assets must have correct format"},
check: async () => {
const errors: string[] = [];
const assets = getChainValidatorsAssets(Waves);
assets.forEach(addr => {
if (!(isWavesAddress(addr))) {
errors.push(`Address ${addr} should be a Waves address'`);
}
});
return [errors, []];
}
},
];
}
}