Skip to content

Commit

Permalink
Merge pull request #414 from Peersyst/refactor/imporove-wallet-stability
Browse files Browse the repository at this point in the history
Refactor/imporove wallet stability
  • Loading branch information
AgustinMJ authored Feb 13, 2024
2 parents b8cdcd8 + 3dbddad commit 271a323
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 9 deletions.
39 changes: 31 additions & 8 deletions src/module/sdk/NearSdkService/NearSdkService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,14 @@ export class NearSDKService {

async getRecentActivity(): Promise<Action[]> {
this.getConnection();
return await this.apiService.getRecentActivity({ address: this.getAddress() });
let actions: Action[] = [];
try {
actions = await this.apiService.getRecentActivity({ address: this.getAddress() });
} catch (e: any) {
//eslint-disable-next-line no-console
console.warn("Error getting recent activity: ", e);
}
return actions;
}

// --------------------------------------------------------------
Expand Down Expand Up @@ -593,16 +600,32 @@ export class NearSDKService {
}

async getAllValidators(): Promise<Validator[]> {
const validators = await this.getAllValidatorIds();
const validatorsProms = validators.map((validator) => this.getValidatorDataFromId(validator, false, undefined, true));
const validatorsPromise = await Promise.all(validatorsProms);
return validatorsPromise.filter((validator: Validator) => (validator.fee ? validator.fee : 0 > 0));
let availableValidatorsList: Validator[] = [];
try {
const validators = await this.getAllValidatorIds();
const validatorsProms = validators.map((validator) => this.getValidatorDataFromId(validator, false, undefined, true));
const validatorsPromise = await Promise.all(validatorsProms);
availableValidatorsList = validatorsPromise.filter((validator: Validator) => (validator.fee ? validator.fee : 0 > 0));
} catch (e) {
//eslint-disable-next-line no-console
console.warn("Error in getAllValidators: ", e);
}
return availableValidatorsList;
}

async getCurrentValidators(): Promise<Validator[]> {
const stakingDeposits = await this.apiService.getStakingDeposits({ address: this.getAddress() });
const validatorsProms = stakingDeposits.map(({ validatorId, amount }) => this.getValidatorDataFromId(validatorId, true, amount));
return await Promise.all(validatorsProms);
let validators: Validator[] = [];
try {
const stakingDeposits = await this.apiService.getStakingDeposits({ address: this.getAddress() });
const validatorsProms = stakingDeposits.map(({ validatorId, amount }) =>
this.getValidatorDataFromId(validatorId, true, amount),
);
validators = await Promise.all(validatorsProms);
} catch (e) {
//eslint-disable-next-line no-console
console.warn("Error in getCurrentValidators: ", e);
}
return validators;
}

private addStakingBalancesFromValidators(validators: Validator[]): StakingBalance {
Expand Down
2 changes: 1 addition & 1 deletion src/module/token/component/display/TokenCard/TokenCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const TokenCard = ({ token }: TokenCardProps): JSX.Element => {
<MainListCard alignItems="center" justifyContent="space-between">
<Row alignItems="center" gap={16}>
<TokenIcon token={token} />
<Typography variant="body3Strong" numberOfLines={1} style={{ maxWidth: "70%" }}>
<Typography variant="body3Strong" numberOfLines={1} style={{ flex: 0.6 }}>
{name}
</Typography>
</Row>
Expand Down

0 comments on commit 271a323

Please sign in to comment.