Skip to content

Commit f99779a

Browse files
committed
fix: resolve inactive account login failure due to empty address field
1 parent 85b7dfa commit f99779a

File tree

1 file changed

+31
-24
lines changed

1 file changed

+31
-24
lines changed

packages/adena-extension/src/common/provider/gno/gno-provider.ts

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -91,39 +91,46 @@ export class GnoProvider extends GnoJSONRPCProvider {
9191
address: string,
9292
height?: number | undefined,
9393
): Promise<AccountInfo | null> {
94+
const inActiveAccount: AccountInfo = {
95+
address,
96+
coins: '',
97+
chainId: '',
98+
status: 'IN_ACTIVE',
99+
publicKey: null,
100+
accountNumber: '0',
101+
sequence: '0',
102+
};
103+
94104
const abciAccount = await this.getAccount(address, height).catch((e) => {
95105
console.info(e);
96106
return null;
97107
});
98108

99109
if (!abciAccount || !abciAccount.BaseAccount) {
100-
return {
101-
address: '',
102-
coins: '',
103-
chainId: '',
104-
status: 'IN_ACTIVE',
105-
publicKey: null,
106-
accountNumber: '0',
107-
sequence: '0',
108-
};
110+
return inActiveAccount;
109111
}
110112

111-
const {
112-
coins,
113-
public_key: publicKey,
114-
account_number: accountNumber,
115-
sequence,
116-
} = abciAccount.BaseAccount;
113+
try {
114+
const {
115+
coins,
116+
public_key: publicKey,
117+
account_number: accountNumber,
118+
sequence,
119+
} = abciAccount.BaseAccount;
117120

118-
return {
119-
address,
120-
coins,
121-
chainId: this.chainId ?? '',
122-
status: 'ACTIVE',
123-
publicKey,
124-
accountNumber,
125-
sequence,
126-
};
121+
return {
122+
address,
123+
coins,
124+
chainId: this.chainId ?? '',
125+
status: 'ACTIVE',
126+
publicKey,
127+
accountNumber,
128+
sequence,
129+
};
130+
} catch (e) {
131+
console.info(e);
132+
return inActiveAccount;
133+
}
127134
}
128135

129136
public getValueByEvaluateExpression(

0 commit comments

Comments
 (0)