Skip to content

Commit

Permalink
fix(aepp): don't require subscription to request addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
davidyuk committed May 29, 2024
1 parent 10a97f1 commit 2b247ff
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/AeSdkAepp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export default class AeSdkAepp extends AeSdkBase {
* @returns Addresses from wallet
*/
async askAddresses(): Promise<Encoded.AccountAddress[]> {
this._ensureAccountAccess();
this._ensureConnected();
return this.rpcClient.request(METHODS.address, undefined);
}

Expand Down
9 changes: 6 additions & 3 deletions test/integration/rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
UnAuthorizedAccountError,
UnknownRpcClientError,
UnsubscribedAccountError,
RpcInternalError,
AccountBase,
verifyMessage,
buildTx,
Expand Down Expand Up @@ -182,7 +183,9 @@ describe('Aepp<->Wallet', () => {
});

it('Try to ask for address', async () => {
await expect(aepp.askAddresses()).to.be.rejectedWith(UnsubscribedAccountError, 'You are not subscribed for an account.');
await expect(aepp.askAddresses()).to.be.rejectedWith(RpcInternalError, 'The peer failed to execute your request due to unknown error');
wallet.onAskAccounts = () => {};
expect(await aepp.askAddresses()).to.be.eql(wallet.addresses());
});

it('Try to sign and send transaction to wallet without subscription', async () => {
Expand Down Expand Up @@ -235,15 +238,15 @@ describe('Aepp<->Wallet', () => {
expect(aepp.address).to.be.equal(account.address);
});

it('Ask for address: subscribed for accounts -> wallet deny', async () => {
it('Ask for address: exception in onAskAccounts -> wallet deny', async () => {
wallet.onAskAccounts = () => {
throw new RpcRejectedByUserError();
};
await expect(aepp.askAddresses()).to.be.eventually
.rejectedWith('Operation rejected by user').with.property('code', 4);
});

it('Ask for address: subscribed for accounts -> wallet accept', async () => {
it('Ask for address: no exception in onAskAccounts -> wallet accept', async () => {
let checkPromise;
wallet.onAskAccounts = (id, params, origin) => {
checkPromise = Promise.resolve().then(() => {
Expand Down

0 comments on commit 2b247ff

Please sign in to comment.