Skip to content

Commit

Permalink
Merge pull request #837 from symbol/dev
Browse files Browse the repository at this point in the history
Release v2.0.0
  • Loading branch information
yilmazbahadir committed Mar 2, 2022
2 parents 2e47366 + 03d8e99 commit c63226d
Show file tree
Hide file tree
Showing 81 changed files with 3,050 additions and 2,328 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module.exports = {
parser: '@typescript-eslint/parser', // Specifies the ESLint parser
plugins: ['@typescript-eslint/eslint-plugin'],
extends: [
'plugin:@typescript-eslint/recommended', // Uses the recommended rules from the @typescript-eslint/eslint-plugin
'prettier/@typescript-eslint', // Uses eslint-config-prettier to disable ESLint rules from @typescript-eslint/eslint-plugin that would conflict with prettier
'plugin:prettier/recommended', // Enables eslint-plugin-prettier and eslint-config-prettier. This will display prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array.
],
parserOptions: {
Expand Down
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
dist: bionic
language: node_js
node_js:
- 10
- 12
- lts/*
- node
services:
- docker
env:
Expand Down
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,21 @@ All notable changes to this project will be documented in this file.

The changelog format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [2.0.0] - 01-Mar-2022

**Milestone**: Symbol Mainnet
Package | Version | Link
---|---|---
SDK Core| v2.0.0 | [symbol-sdk](https://www.npmjs.com/package/symbol-sdk)
Catbuffer | v1.0.1 | [catbuffer-typescript](https://www.npmjs.com/package/catbuffer-typescript)
Client Library | v1.0.3 | [symbol-openapi-typescript-fetch-client](https://www.npmjs.com/package/symbol-openapi-typescript-fetch-client)

- **[BREAKING CHANGE]** The type of `value` field in `AccountMetadataTransaction`, `MosaicMetadataTransaction`, `NamespaceMetadataTransaction` classes is changed from `string` to `Uint8Array`.
- fix: Fixed metadata value non-ascii utf8 encoding issue [#834](https://github.com/symbol/symbol-sdk-typescript-javascript/issues/834)
- fix: Upgraded Node to 12.22.1.
- fix: Upgraded typescript to 4.5.4.
- fix: Upgraded RXJS to 7.4.0.

## [1.0.3] - 16-Nov-2021

**Milestone**: Symbol Mainnet
Expand Down
55 changes: 27 additions & 28 deletions e2e/infrastructure/AccountHttp.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import { deepEqual } from 'assert';
import { expect } from 'chai';
import { firstValueFrom } from 'rxjs';
import { take, toArray } from 'rxjs/operators';
import { AccountRepository, MultisigRepository, NamespaceRepository, Order, RepositoryCallError } from '../../src/infrastructure';
import { AccountPaginationStreamer } from '../../src/infrastructure/paginationStreamer';
Expand Down Expand Up @@ -164,79 +165,77 @@ describe('AccountHttp', () => {

describe('getAccountInfo', () => {
it('should return account data given a NEM Address', async () => {
const accountInfo = await accountRepository.getAccountInfo(accountAddress).toPromise();
const accountInfo = await firstValueFrom(accountRepository.getAccountInfo(accountAddress));
expect(accountInfo.publicKey).to.be.equal(accountPublicKey);

const merkleInfo = await accountRepository.getAccountInfoMerkle(accountInfo.address).toPromise();
const merkleInfo = await firstValueFrom(accountRepository.getAccountInfoMerkle(accountInfo.address));
expect(merkleInfo.raw).to.not.be.undefined;
});
});

describe('getAccountsInfo', () => {
it('should return account data given a NEM Address', async () => {
const accountsInfo = await accountRepository.getAccountsInfo([accountAddress]).toPromise();
const accountsInfo = await firstValueFrom(accountRepository.getAccountsInfo([accountAddress]));
expect(accountsInfo[0].publicKey).to.be.equal(accountPublicKey);
});
});

describe('searchAccount', () => {
it('should return account info', async () => {
const info = await accountRepository.search({}).toPromise();
const info = await firstValueFrom(accountRepository.search({}));
expect(info.data.length).to.be.greaterThan(0);
});
});

describe('searchAccount with streamer', () => {
it('should return account info', async () => {
const streamer = new AccountPaginationStreamer(accountRepository);
const infoStreamer = await streamer
.search({ pageSize: 20, order: Order.Asc, orderBy: AccountOrderBy.Id })
.pipe(take(20), toArray())
.toPromise();
const info = await accountRepository.search({ pageSize: 20, order: Order.Asc, orderBy: AccountOrderBy.Id }).toPromise();
const infoStreamer = await firstValueFrom(
streamer.search({ pageSize: 20, order: Order.Asc, orderBy: AccountOrderBy.Id }).pipe(take(20), toArray()),
);
const info = await firstValueFrom(accountRepository.search({ pageSize: 20, order: Order.Asc, orderBy: AccountOrderBy.Id }));
expect(infoStreamer.length).to.be.greaterThan(0);
deepEqual(infoStreamer[0], info.data[0]);
});
});

describe('transactions', () => {
it('should not return accounts when account does not exist', () => {
return accountRepository
.getAccountInfo(Account.generateNewAccount(networkType).address)
.toPromise()
.then(
() => {
return Promise.reject('should fail!');
},
(err) => {
const error: RepositoryCallError = JSON.parse(err.message);
expect(error.statusCode).to.be.eq(404);
expect(error.statusMessage).to.be.eq('Not Found');
return Promise.resolve();
},
);
return firstValueFrom(accountRepository.getAccountInfo(Account.generateNewAccount(networkType).address)).then(
() => {
return Promise.reject('should fail!');
},
(err) => {
const error: RepositoryCallError = JSON.parse(err.message);
expect(error.statusCode).to.be.eq(404);
expect(error.statusMessage).to.be.eq('Not Found');
return Promise.resolve();
},
);
});
});

describe('getAddressNames', () => {
it('should call getAddressNames successfully', async () => {
const addressNames = await namespaceRepository.getAccountsNames([accountAddress]).toPromise();
const addressNames = await firstValueFrom(namespaceRepository.getAccountsNames([accountAddress]));
expect(addressNames.length).to.be.greaterThan(0);
});
});

describe('getMultisigAccountGraphInfo', () => {
it('should call getMultisigAccountGraphInfo successfully', async () => {
await new Promise((resolve) => setTimeout(resolve, 3000));
const multisigAccountGraphInfo = await multisigRepository
.getMultisigAccountGraphInfo(multisigAccount.publicAccount.address)
.toPromise();
const multisigAccountGraphInfo = await firstValueFrom(
multisigRepository.getMultisigAccountGraphInfo(multisigAccount.publicAccount.address),
);
expect(multisigAccountGraphInfo.multisigEntries.get(0)![0].accountAddress.plain()).to.be.equal(multisigAccount.address.plain());
});
});
describe('getMultisigAccountInfo', () => {
it('should call getMultisigAccountInfo successfully', async () => {
const multisigAccountInfo = await multisigRepository.getMultisigAccountInfo(multisigAccount.publicAccount.address).toPromise();
const multisigAccountInfo = await firstValueFrom(
multisigRepository.getMultisigAccountInfo(multisigAccount.publicAccount.address),
);
expect(multisigAccountInfo.accountAddress.plain()).to.be.equal(multisigAccount.address.plain());
});
});
Expand Down
31 changes: 15 additions & 16 deletions e2e/infrastructure/BlockHttp.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import { deepEqual } from 'assert';
import { expect } from 'chai';
import { firstValueFrom } from 'rxjs';
import { mergeMap, take, toArray } from 'rxjs/operators';
import { Order } from '../../src/infrastructure';
import { BlockRepository } from '../../src/infrastructure/BlockRepository';
Expand Down Expand Up @@ -84,7 +85,7 @@ describe('BlockHttp', () => {

describe('getBlockByHeight', () => {
it('should return block info given height', async () => {
const blockInfo = await blockRepository.getBlockByHeight(UInt64.fromUint(1)).toPromise();
const blockInfo = await firstValueFrom(blockRepository.getBlockByHeight(UInt64.fromUint(1)));
expect(blockInfo.height.lower).to.be.equal(1);
expect(blockInfo.height.higher).to.be.equal(0);
expect(blockInfo.timestamp.lower).to.be.equal(0);
Expand All @@ -96,56 +97,54 @@ describe('BlockHttp', () => {

describe('searchBlock', () => {
it('should return block info given height and limit', async () => {
const blocksInfo = await blockRepository.search({}).toPromise();
const blocksInfo = await firstValueFrom(blockRepository.search({}));
expect(blocksInfo.data.length).to.be.greaterThan(0);
});
});

describe('searchBlock with streamer', () => {
it('should return block info given height and limit', async () => {
const streamer = new BlockPaginationStreamer(blockRepository);
const blockInfoStreamer = await streamer.search({ pageSize: 20 }).pipe(take(20), toArray()).toPromise();
const blocksInfo = await blockRepository.search({ pageSize: 20 }).toPromise();
const blockInfoStreamer = await firstValueFrom(streamer.search({ pageSize: 20 }).pipe(take(20), toArray()));
const blocksInfo = await firstValueFrom(blockRepository.search({ pageSize: 20 }));
expect(blockInfoStreamer.length).to.be.greaterThan(0);
deepEqual(blockInfoStreamer, blocksInfo.data);
});
});

describe('getMerkleReceipts', () => {
it('should return Merkle Receipts', async () => {
const merkleReceipts = await receiptRepository
.searchReceipts({ height: chainHeight })
.pipe(
const merkleReceipts = await firstValueFrom(
receiptRepository.searchReceipts({ height: chainHeight }).pipe(
mergeMap((_) => {
return blockRepository.getMerkleReceipts(chainHeight, (_.data[0] as TransactionStatement).generateHash());
}),
)
.toPromise();
),
);
expect(merkleReceipts.merklePath).not.to.be.null;
});
});
describe('getMerkleTransaction', () => {
it('should return Merkle Transaction', async () => {
const merkleTransactionss = await blockRepository.getMerkleTransaction(chainHeight, transactionHash).toPromise();
const merkleTransactionss = await firstValueFrom(blockRepository.getMerkleTransaction(chainHeight, transactionHash));
expect(merkleTransactionss.merklePath).not.to.be.null;
});
});

describe('getBlockReceipts', () => {
it('should return block receipts', async () => {
const statement = await receiptRepository.searchReceipts({ height: chainHeight }).toPromise();
const statement = await firstValueFrom(receiptRepository.searchReceipts({ height: chainHeight }));
expect(statement.data.length).to.be.greaterThan(0);
});
});

describe('searchReceipt with streamer', () => {
it('should return receipt info', async () => {
const streamer = ReceiptPaginationStreamer.transactionStatements(receiptRepository);
const infoStreamer = await streamer
.search({ pageSize: 20, height: chainHeight, order: Order.Asc })
.pipe(take(20), toArray())
.toPromise();
const info = await receiptRepository.searchReceipts({ pageSize: 20, height: chainHeight, order: Order.Asc }).toPromise();
const infoStreamer = await firstValueFrom(
streamer.search({ pageSize: 20, height: chainHeight, order: Order.Asc }).pipe(take(20), toArray()),
);
const info = await firstValueFrom(receiptRepository.searchReceipts({ pageSize: 20, height: chainHeight, order: Order.Asc }));
expect(infoStreamer.length).to.be.greaterThan(0);
deepEqual(infoStreamer[0], info.data[0]);
});
Expand Down
3 changes: 2 additions & 1 deletion e2e/infrastructure/ChainHttp.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

import { expect } from 'chai';
import { firstValueFrom } from 'rxjs';
import { ChainRepository } from '../../src/infrastructure/ChainRepository';
import { IntegrationTestHelper } from './IntegrationTestHelper';

Expand All @@ -34,7 +35,7 @@ describe('ChainHttp', () => {

describe('getChainInfo', () => {
it('should return blockchain score', async () => {
const info = await chainRepository.getChainInfo().toPromise();
const info = await firstValueFrom(chainRepository.getChainInfo());
expect(info.scoreLow).to.not.be.equal(undefined);
expect(info.scoreHigh.lower).to.be.equal(0);
expect(info.scoreHigh.higher).to.be.equal(0);
Expand Down
5 changes: 3 additions & 2 deletions e2e/infrastructure/FinalizationHttp.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* limitations under the License.
*/
import { expect } from 'chai';
import { firstValueFrom } from 'rxjs';
import { FinalizationRepository } from '../../src/infrastructure/FinalizationRepository';
import { UInt64 } from '../../src/model/UInt64';
import { IntegrationTestHelper } from './IntegrationTestHelper';
Expand All @@ -34,7 +35,7 @@ describe('FinalizationHttp', () => {

describe('getFinalizationProofAtEpoch', () => {
it('should return finalization proof at epoch', async () => {
const dto = await finalizationRepository.getFinalizationProofAtEpoch(1).toPromise();
const dto = await firstValueFrom(finalizationRepository.getFinalizationProofAtEpoch(1));
expect(dto).not.to.be.null;
expect(dto.height).to.deep.eq(UInt64.fromUint(1));
expect(dto.version).to.eq(1);
Expand All @@ -46,7 +47,7 @@ describe('FinalizationHttp', () => {

describe('getNetworkName', () => {
it('should return finalization proof at height', async () => {
const dto = await finalizationRepository.getFinalizationProofAtHeight(UInt64.fromUint(1)).toPromise();
const dto = await firstValueFrom(finalizationRepository.getFinalizationProofAtHeight(UInt64.fromUint(1)));
expect(dto).not.to.be.null;
expect(dto.height).to.deep.eq(UInt64.fromUint(1));
expect(dto.version).to.eq(1);
Expand Down
18 changes: 9 additions & 9 deletions e2e/infrastructure/HashLockHttp.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import { ChronoUnit } from '@js-joda/core';
import { deepEqual } from 'assert';
import { expect } from 'chai';
import { firstValueFrom } from 'rxjs';
import { take, toArray } from 'rxjs/operators';
import { HashLockPaginationStreamer, Order } from '../../src/infrastructure';
import { HashLockRepository } from '../../src/infrastructure/HashLockRepository';
Expand Down Expand Up @@ -154,34 +155,33 @@ describe('HashLockHttp', () => {
describe('searchHashLock', () => {
it('should return hash lock page info', async () => {
await new Promise((resolve) => setTimeout(resolve, 3000));
const page = await hashLockRepo.search({ address: account.address }).toPromise();
const page = await firstValueFrom(hashLockRepo.search({ address: account.address }));
const info = page.data[0];
hash = info.hash;
expect(page.data.length).to.be.greaterThan(0);

const infoFromId = await hashLockRepo.getHashLock(hash).toPromise();
const infoFromId = await firstValueFrom(hashLockRepo.getHashLock(hash));
expect(infoFromId).deep.eq(info);
const merkleInfo = await hashLockRepo.getHashLockMerkle(hash).toPromise();
const merkleInfo = await firstValueFrom(hashLockRepo.getHashLockMerkle(hash));
expect(merkleInfo.raw).to.not.be.undefined;
});
});

describe('searchHashLock with streamer', () => {
it('should return hash lock page info', async () => {
const streamer = new HashLockPaginationStreamer(hashLockRepo);
const infoStreamer = await streamer
.search({ address: account.address, pageSize: 20, order: Order.Asc })
.pipe(take(20), toArray())
.toPromise();
const info = await hashLockRepo.search({ address: account.address, pageSize: 20, order: Order.Asc }).toPromise();
const infoStreamer = await firstValueFrom(
streamer.search({ address: account.address, pageSize: 20, order: Order.Asc }).pipe(take(20), toArray()),
);
const info = await firstValueFrom(hashLockRepo.search({ address: account.address, pageSize: 20, order: Order.Asc }));
expect(infoStreamer.length).to.be.greaterThan(0);
deepEqual(infoStreamer[0], info.data[0]);
});
});

describe('getHashLock', () => {
it('should return hash lock info given hash', async () => {
const info = await hashLockRepo.getHashLock(hash).toPromise();
const info = await firstValueFrom(hashLockRepo.getHashLock(hash));
expect(info.ownerAddress.plain()).to.be.equal(account.address.plain());
expect(info.amount.toString()).to.be.equal('10000000');
});
Expand Down
22 changes: 11 additions & 11 deletions e2e/infrastructure/IntegrationTestHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { firstValueFrom } from 'rxjs';
import { map } from 'rxjs/operators';
import { Addresses, BootstrapService, BootstrapUtils, ConfigLoader, StartParams } from 'symbol-bootstrap';
import { IListener, RepositoryFactory, RepositoryFactoryHttp } from '../../src/infrastructure';
Expand Down Expand Up @@ -84,9 +85,9 @@ export class IntegrationTestHelper {
this.repositoryFactory.createReceiptRepository(),
);

this.networkType = await this.repositoryFactory.getNetworkType().toPromise();
this.generationHash = await this.repositoryFactory.getGenerationHash().toPromise();
this.epochAdjustment = await this.repositoryFactory.getEpochAdjustment().toPromise();
this.networkType = await firstValueFrom(this.repositoryFactory.getNetworkType());
this.generationHash = await firstValueFrom(this.repositoryFactory.getGenerationHash());
this.epochAdjustment = await firstValueFrom(this.repositoryFactory.getEpochAdjustment());

let index = 0;
this.accounts = accounts.map((account) => Account.createFromPrivateKey(account, this.networkType));
Expand All @@ -104,7 +105,7 @@ export class IntegrationTestHelper {

// What would be the best maxFee? In the future we will load the fee multiplier from rest.
this.maxFee = UInt64.fromUint(1000000);
this.networkCurrency = (await this.repositoryFactory.getCurrencies().toPromise()).currency;
this.networkCurrency = (await firstValueFrom(this.repositoryFactory.getCurrencies())).currency;

if (openListener) {
await this.listener.open();
Expand All @@ -118,22 +119,21 @@ export class IntegrationTestHelper {

announce(signedTransaction: SignedTransaction): Promise<Transaction> {
console.log(`Announcing transaction: ${signedTransaction.type}`);
return this.transactionService
.announce(signedTransaction, this.listener)
.pipe(
return firstValueFrom(
this.transactionService.announce(signedTransaction, this.listener).pipe(
map((t) => {
console.log(`Transaction ${signedTransaction.type} confirmed`);
return t;
}),
)
.toPromise();
),
);
}

public static sleep(ms: number): Promise<any> {
public static sleep(ms: number): Promise<void> {
// Create a promise that rejects in <ms> milliseconds
return new Promise((resolve) => {
setTimeout(() => {
resolve();
resolve(undefined);
}, ms);
});
}
Expand Down
Loading

0 comments on commit c63226d

Please sign in to comment.