Skip to content

Commit

Permalink
UnlockedAccount endpoint and latest openAPI changes (#706)
Browse files Browse the repository at this point in the history
* Fixed #705
- Added unlocked account endpoint
- Applied latest changes from openAPI

* Updated open api to latest alpha (Requires New Rest) (#698)

* Fixed #672
- Added finalization http

* Security alert fix

* Updated libs

* Updated open api to latest alpha
Added secret filter in secret lock search
Updated transaction search

* Improved e2e tests

* Increased timeout

* Fixed build error

Co-authored-by: Steven Liu <xian.f.liu@gmail.com>

* Fixed #705
- Added unlocked account endpoint
- Applied latest changes from openAPI

* Updated change log

Co-authored-by: fboucquez <fboucquez@gmail.com>
  • Loading branch information
rg911 and fboucquez committed Nov 6, 2020
1 parent b19de0e commit 9b67cd0
Show file tree
Hide file tree
Showing 8 changed files with 105 additions and 257 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -19,6 +19,7 @@ Client Library | v0.10.1 | [symbol-openapi-typescript-fetch-client](https://www
- Added `FinalizationRepository`.
- Added `transferMosaicId`, `fromTransferAmount`, `toTransferAmount` to transaction searches.
- Added `CurrencyService` to allow loading Network and custom `Currency` objects from the rest service.
- Added `UnlockedAccount` endpoint in `NodeRepository` for checking delegated harvesting status.

## [0.21.0] - 25-Sep-2020

Expand Down
8 changes: 8 additions & 0 deletions e2e/infrastructure/NodeHttp.spec.ts
Expand Up @@ -90,4 +90,12 @@ describe('NodeHttp', () => {
expect(health.db).not.to.be.null;
});
});

describe('getUnlockedAccount', () => {
it('should return unlocked account', async () => {
const unlockedAccount = await nodeRepository.getUnlockedAccount().toPromise();
expect(unlockedAccount).not.to.be.null;
expect(unlockedAccount.length).greaterThan(0);
});
});
});
7 changes: 6 additions & 1 deletion e2e/infrastructure/SecretLockHttp.spec.ts
Expand Up @@ -111,7 +111,12 @@ describe('SecretLockHttp', () => {
.search({ address: account.address, pageSize: 20, order: Order.Asc })
.pipe(take(20), toArray())
.toPromise();
const info = await SecretLockRepo.search({ address: account.address, pageSize: 20, order: Order.Asc }).toPromise();
const info = await SecretLockRepo.search({
address: account.address,
secret: undefined,
pageSize: 20,
order: Order.Asc,
}).toPromise();
expect(infoStreamer.length).to.be.greaterThan(0);
deepEqual(infoStreamer[0], info.data[0]);
});
Expand Down
319 changes: 64 additions & 255 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -111,7 +111,7 @@
"ripemd160": "^2.0.2",
"rxjs": "^6.6.3",
"rxjs-compat": "^6.6.3",
"symbol-openapi-typescript-fetch-client": "^0.10.1-SNAPSHOT.202010252303",
"symbol-openapi-typescript-fetch-client": "0.10.1-SNAPSHOT.202011061706",
"tweetnacl": "^1.0.3",
"ws": "^7.3.1"
},
Expand Down
8 changes: 8 additions & 0 deletions src/infrastructure/NodeHttp.ts
Expand Up @@ -111,6 +111,14 @@ export class NodeHttp extends Http implements NodeRepository {
return this.call(this.nodeRoutesApi.getNodeHealth(), (body) => new NodeHealth(body.status.apiNode, body.status.db));
}

/**
* Return unlocked harvesting account from node.
* @returns Observable<string[]>
*/
getUnlockedAccount(): Observable<string[]> {
return this.call(this.nodeRoutesApi.getUnlockedAccount(), (body) => body);
}

/**
* It maps NodeInfoDTO to NodeInfo
*
Expand Down
6 changes: 6 additions & 0 deletions src/infrastructure/NodeRepository.ts
Expand Up @@ -63,4 +63,10 @@ export interface NodeRepository {
* @returns Observable<Server>
*/
getServerInfo(): Observable<ServerInfo>;

/**
* Return unlocked harvesting account from node.
* @returns Observable<string[]>
*/
getUnlockedAccount(): Observable<string[]>;
}
11 changes: 11 additions & 0 deletions test/infrastructure/NodeHttp.spec.ts
Expand Up @@ -200,6 +200,17 @@ describe('NodeHttp', () => {
}
});

it('getUnlockedAccount', async () => {
const body = ['key1', 'key2'];

when(nodeRoutesApi.getUnlockedAccount()).thenReturn(Promise.resolve(body));

const unlockedAccount = await nodeRepository.getUnlockedAccount().toPromise();
expect(unlockedAccount).to.be.not.null;
expect(unlockedAccount[0]).to.be.equal('key1');
expect(unlockedAccount[1]).to.be.equal('key2');
});

it('getStorageInfo', async () => {
const body = {} as StorageInfoDTO;
body.numAccounts = 1;
Expand Down

0 comments on commit 9b67cd0

Please sign in to comment.