Skip to content

Commit

Permalink
fix(aepp)!: use the same name for all nodes provided by wallet
Browse files Browse the repository at this point in the history
BREAKING CHANGE: All wallet provided nodes have the same name
Specified in `name` option of `connectToWallet`.
  • Loading branch information
davidyuk committed Mar 28, 2023
1 parent adf9c3e commit 0ece313
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions .mocharc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ module.exports = {
recursive: true,
extension: '.js,.ts',
timeout: '40s',
ignore: 'test/environment/**',
exit: true // TODO: fix in state channel tests
}
3 changes: 2 additions & 1 deletion src/AeSdkAepp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ export default class AeSdkAepp extends AeSdkBase {
},
[METHODS.updateNetwork]: (params) => {
const { node } = params;
if (node != null) this.addNode(node.name, new Node(node.url), true);
this.pool.delete(name);
if (node != null) this.addNode(name, new Node(node.url), true);
this.onNetworkChange(params);
},
[METHODS.closeConnection]: (params) => {
Expand Down
1 change: 1 addition & 0 deletions src/aepp-wallet-communication/rpc/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export interface Accounts {
}

export interface Node {
// TODO: name is not used, can be removed
name: string;
url: string;
}
Expand Down
9 changes: 6 additions & 3 deletions test/integration/rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,20 @@ describe('Aepp<->Wallet', function aeppWallet() {
target: connections.walletWindow,
});
const handlerReject = (): void => { throw new Error('test reject'); };
let aeSdk: AeSdk;
let account: AccountBase;

before(async () => {
aeSdk = await getSdk();
[account] = Object.values(aeSdk.accounts);
});

describe('New RPC Wallet-AEPP: AEPP node', () => {
const keypair = generateKeyPair();
let aeSdk: AeSdk;
let aepp: AeSdkAepp;
let wallet: AeSdkWallet;

before(async () => {
aeSdk = await getSdk();
[account] = Object.values(aeSdk.accounts);
wallet = new AeSdkWallet({
nodes: [{ name: 'local', instance: node }],
accounts: [account, MemoryAccount.generate()],
Expand Down

0 comments on commit 0ece313

Please sign in to comment.