Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
*/
[
'amount',
'toAddr'
].forEach(key => {
if (!payload.hasOwnProperty(key)) {
throw new Error(
errorsCode.WrongRequiredparam + key
);
}
});
const storage = new BrowserStorage();
let forConfirm = await storage.get(fields.CONFIRM_TX);
if (validation.isBase58(payload.toAddr)) {
payload.toAddr = decodeBase58(payload.toAddr);
} else if (validation.isBech32(payload.toAddr)) {
payload.toAddr = fromBech32Address(payload.toAddr);
}
payload.toAddr = toChecksumAddress(payload.toAddr);
try {
forConfirm = forConfirm[fields.CONFIRM_TX];
forConfirm.push(payload);
} catch(err) {
forConfirm = [payload];
}
await storage.set(new BuildObject(fields.CONFIRM_TX, forConfirm));
this.notificationsCounter(forConfirm);
private getAddressType() {
const addrBool = validation.isAddress(this.raw);
const base58Bool = validation.isBase58(this.raw);
const bech32Bool = validation.isBech32(this.raw);
const bech32TestNetBool = validation.isBech32TestNet(this.raw);
const checksumBool = isValidChecksumAddress(this.raw);
if (addrBool === true && checksumBool === false) {
this.addressType = AddressType.bytes20;
this.bytes20 = this.raw.startsWith('0x')
? this.raw.substring(2)
: this.raw;
return;
}
if (addrBool === true && checksumBool === true) {
this.addressType = AddressType.checkSum;
this.bytes20 = this.raw.toLowerCase().substring(2);
return;