Add check for trusted declarator address.
This commit is contained in:
parent
665b28a8ba
commit
bb6426c252
@ -129,7 +129,7 @@ const defaultAccount: AccountDetails = {
|
|||||||
meta: {
|
meta: {
|
||||||
TYP: [],
|
TYP: [],
|
||||||
},
|
},
|
||||||
value: '',
|
value: '+254700000000',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
version: [
|
version: [
|
||||||
|
@ -62,6 +62,10 @@ export class TransactionService {
|
|||||||
transaction.value = Number(transaction.value);
|
transaction.value = Number(transaction.value);
|
||||||
transaction.type = 'transaction';
|
transaction.type = 'transaction';
|
||||||
try {
|
try {
|
||||||
|
if (transaction.from === environment.trustedDeclaratorAddress) {
|
||||||
|
transaction.sender = defaultAccount;
|
||||||
|
this.userService.addAccount(defaultAccount, cacheSize);
|
||||||
|
} else {
|
||||||
this.userService
|
this.userService
|
||||||
.getAccountDetailsFromMeta(await User.toKey(transaction.from))
|
.getAccountDetailsFromMeta(await User.toKey(transaction.from))
|
||||||
.pipe(first())
|
.pipe(first())
|
||||||
@ -70,10 +74,18 @@ export class TransactionService {
|
|||||||
transaction.sender = this.getAccountInfo(res, cacheSize);
|
transaction.sender = this.getAccountInfo(res, cacheSize);
|
||||||
},
|
},
|
||||||
(error) => {
|
(error) => {
|
||||||
transaction.sender = defaultAccount;
|
this.loggingService.sendErrorLevelMessage(
|
||||||
this.userService.addAccount(defaultAccount, cacheSize);
|
`Account with address ${transaction.from} not found`,
|
||||||
|
this,
|
||||||
|
{ error }
|
||||||
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
if (transaction.to === environment.trustedDeclaratorAddress) {
|
||||||
|
transaction.recipient = defaultAccount;
|
||||||
|
this.userService.addAccount(defaultAccount, cacheSize);
|
||||||
|
} else {
|
||||||
this.userService
|
this.userService
|
||||||
.getAccountDetailsFromMeta(await User.toKey(transaction.to))
|
.getAccountDetailsFromMeta(await User.toKey(transaction.to))
|
||||||
.pipe(first())
|
.pipe(first())
|
||||||
@ -82,10 +94,14 @@ export class TransactionService {
|
|||||||
transaction.recipient = this.getAccountInfo(res, cacheSize);
|
transaction.recipient = this.getAccountInfo(res, cacheSize);
|
||||||
},
|
},
|
||||||
(error) => {
|
(error) => {
|
||||||
transaction.recipient = defaultAccount;
|
this.loggingService.sendErrorLevelMessage(
|
||||||
this.userService.addAccount(defaultAccount, cacheSize);
|
`Account with address ${transaction.to} not found`,
|
||||||
|
this,
|
||||||
|
{ error }
|
||||||
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
this.addTransaction(transaction, cacheSize);
|
this.addTransaction(transaction, cacheSize);
|
||||||
}
|
}
|
||||||
@ -99,6 +115,10 @@ export class TransactionService {
|
|||||||
conversion.fromValue = Number(conversion.fromValue);
|
conversion.fromValue = Number(conversion.fromValue);
|
||||||
conversion.toValue = Number(conversion.toValue);
|
conversion.toValue = Number(conversion.toValue);
|
||||||
try {
|
try {
|
||||||
|
if (conversion.trader === environment.trustedDeclaratorAddress) {
|
||||||
|
conversion.sender = conversion.recipient = defaultAccount;
|
||||||
|
this.userService.addAccount(defaultAccount, cacheSize);
|
||||||
|
} else {
|
||||||
this.userService
|
this.userService
|
||||||
.getAccountDetailsFromMeta(await User.toKey(conversion.trader))
|
.getAccountDetailsFromMeta(await User.toKey(conversion.trader))
|
||||||
.pipe(first())
|
.pipe(first())
|
||||||
@ -107,10 +127,14 @@ export class TransactionService {
|
|||||||
conversion.sender = conversion.recipient = this.getAccountInfo(res);
|
conversion.sender = conversion.recipient = this.getAccountInfo(res);
|
||||||
},
|
},
|
||||||
(error) => {
|
(error) => {
|
||||||
conversion.sender = conversion.recipient = defaultAccount;
|
this.loggingService.sendErrorLevelMessage(
|
||||||
this.userService.addAccount(defaultAccount, cacheSize);
|
`Account with address ${conversion.trader} not found`,
|
||||||
|
this,
|
||||||
|
{ error }
|
||||||
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
this.addTransaction(conversion, cacheSize);
|
this.addTransaction(conversion, cacheSize);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user