Skip to content

Commit c63226d

Browse files
Merge pull request #837 from symbol/dev
Release v2.0.0
2 parents 2e47366 + 03d8e99 commit c63226d

File tree

81 files changed

+3050
-2328
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+3050
-2328
lines changed

.eslintrc.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
module.exports = {
22
parser: '@typescript-eslint/parser', // Specifies the ESLint parser
3+
plugins: ['@typescript-eslint/eslint-plugin'],
34
extends: [
45
'plugin:@typescript-eslint/recommended', // Uses the recommended rules from the @typescript-eslint/eslint-plugin
5-
'prettier/@typescript-eslint', // Uses eslint-config-prettier to disable ESLint rules from @typescript-eslint/eslint-plugin that would conflict with prettier
66
'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.
77
],
88
parserOptions: {

.travis.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
dist: bionic
22
language: node_js
33
node_js:
4-
- 10
54
- 12
5+
- lts/*
6+
- node
67
services:
78
- docker
89
env:

CHANGELOG.md

+15
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,21 @@ All notable changes to this project will be documented in this file.
44

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

7+
## [2.0.0] - 01-Mar-2022
8+
9+
**Milestone**: Symbol Mainnet
10+
Package | Version | Link
11+
---|---|---
12+
SDK Core| v2.0.0 | [symbol-sdk](https://www.npmjs.com/package/symbol-sdk)
13+
Catbuffer | v1.0.1 | [catbuffer-typescript](https://www.npmjs.com/package/catbuffer-typescript)
14+
Client Library | v1.0.3 | [symbol-openapi-typescript-fetch-client](https://www.npmjs.com/package/symbol-openapi-typescript-fetch-client)
15+
16+
- **[BREAKING CHANGE]** The type of `value` field in `AccountMetadataTransaction`, `MosaicMetadataTransaction`, `NamespaceMetadataTransaction` classes is changed from `string` to `Uint8Array`.
17+
- fix: Fixed metadata value non-ascii utf8 encoding issue [#834](https://github.com/symbol/symbol-sdk-typescript-javascript/issues/834)
18+
- fix: Upgraded Node to 12.22.1.
19+
- fix: Upgraded typescript to 4.5.4.
20+
- fix: Upgraded RXJS to 7.4.0.
21+
722
## [1.0.3] - 16-Nov-2021
823

924
**Milestone**: Symbol Mainnet

e2e/infrastructure/AccountHttp.spec.ts

+27-28
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

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

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

170-
const merkleInfo = await accountRepository.getAccountInfoMerkle(accountInfo.address).toPromise();
171+
const merkleInfo = await firstValueFrom(accountRepository.getAccountInfoMerkle(accountInfo.address));
171172
expect(merkleInfo.raw).to.not.be.undefined;
172173
});
173174
});
174175

175176
describe('getAccountsInfo', () => {
176177
it('should return account data given a NEM Address', async () => {
177-
const accountsInfo = await accountRepository.getAccountsInfo([accountAddress]).toPromise();
178+
const accountsInfo = await firstValueFrom(accountRepository.getAccountsInfo([accountAddress]));
178179
expect(accountsInfo[0].publicKey).to.be.equal(accountPublicKey);
179180
});
180181
});
181182

182183
describe('searchAccount', () => {
183184
it('should return account info', async () => {
184-
const info = await accountRepository.search({}).toPromise();
185+
const info = await firstValueFrom(accountRepository.search({}));
185186
expect(info.data.length).to.be.greaterThan(0);
186187
});
187188
});
188189

189190
describe('searchAccount with streamer', () => {
190191
it('should return account info', async () => {
191192
const streamer = new AccountPaginationStreamer(accountRepository);
192-
const infoStreamer = await streamer
193-
.search({ pageSize: 20, order: Order.Asc, orderBy: AccountOrderBy.Id })
194-
.pipe(take(20), toArray())
195-
.toPromise();
196-
const info = await accountRepository.search({ pageSize: 20, order: Order.Asc, orderBy: AccountOrderBy.Id }).toPromise();
193+
const infoStreamer = await firstValueFrom(
194+
streamer.search({ pageSize: 20, order: Order.Asc, orderBy: AccountOrderBy.Id }).pipe(take(20), toArray()),
195+
);
196+
const info = await firstValueFrom(accountRepository.search({ pageSize: 20, order: Order.Asc, orderBy: AccountOrderBy.Id }));
197197
expect(infoStreamer.length).to.be.greaterThan(0);
198198
deepEqual(infoStreamer[0], info.data[0]);
199199
});
200200
});
201201

202202
describe('transactions', () => {
203203
it('should not return accounts when account does not exist', () => {
204-
return accountRepository
205-
.getAccountInfo(Account.generateNewAccount(networkType).address)
206-
.toPromise()
207-
.then(
208-
() => {
209-
return Promise.reject('should fail!');
210-
},
211-
(err) => {
212-
const error: RepositoryCallError = JSON.parse(err.message);
213-
expect(error.statusCode).to.be.eq(404);
214-
expect(error.statusMessage).to.be.eq('Not Found');
215-
return Promise.resolve();
216-
},
217-
);
204+
return firstValueFrom(accountRepository.getAccountInfo(Account.generateNewAccount(networkType).address)).then(
205+
() => {
206+
return Promise.reject('should fail!');
207+
},
208+
(err) => {
209+
const error: RepositoryCallError = JSON.parse(err.message);
210+
expect(error.statusCode).to.be.eq(404);
211+
expect(error.statusMessage).to.be.eq('Not Found');
212+
return Promise.resolve();
213+
},
214+
);
218215
});
219216
});
220217

221218
describe('getAddressNames', () => {
222219
it('should call getAddressNames successfully', async () => {
223-
const addressNames = await namespaceRepository.getAccountsNames([accountAddress]).toPromise();
220+
const addressNames = await firstValueFrom(namespaceRepository.getAccountsNames([accountAddress]));
224221
expect(addressNames.length).to.be.greaterThan(0);
225222
});
226223
});
227224

228225
describe('getMultisigAccountGraphInfo', () => {
229226
it('should call getMultisigAccountGraphInfo successfully', async () => {
230227
await new Promise((resolve) => setTimeout(resolve, 3000));
231-
const multisigAccountGraphInfo = await multisigRepository
232-
.getMultisigAccountGraphInfo(multisigAccount.publicAccount.address)
233-
.toPromise();
228+
const multisigAccountGraphInfo = await firstValueFrom(
229+
multisigRepository.getMultisigAccountGraphInfo(multisigAccount.publicAccount.address),
230+
);
234231
expect(multisigAccountGraphInfo.multisigEntries.get(0)![0].accountAddress.plain()).to.be.equal(multisigAccount.address.plain());
235232
});
236233
});
237234
describe('getMultisigAccountInfo', () => {
238235
it('should call getMultisigAccountInfo successfully', async () => {
239-
const multisigAccountInfo = await multisigRepository.getMultisigAccountInfo(multisigAccount.publicAccount.address).toPromise();
236+
const multisigAccountInfo = await firstValueFrom(
237+
multisigRepository.getMultisigAccountInfo(multisigAccount.publicAccount.address),
238+
);
240239
expect(multisigAccountInfo.accountAddress.plain()).to.be.equal(multisigAccount.address.plain());
241240
});
242241
});

e2e/infrastructure/BlockHttp.spec.ts

+15-16
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
import { deepEqual } from 'assert';
1818
import { expect } from 'chai';
19+
import { firstValueFrom } from 'rxjs';
1920
import { mergeMap, take, toArray } from 'rxjs/operators';
2021
import { Order } from '../../src/infrastructure';
2122
import { BlockRepository } from '../../src/infrastructure/BlockRepository';
@@ -84,7 +85,7 @@ describe('BlockHttp', () => {
8485

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

9798
describe('searchBlock', () => {
9899
it('should return block info given height and limit', async () => {
99-
const blocksInfo = await blockRepository.search({}).toPromise();
100+
const blocksInfo = await firstValueFrom(blockRepository.search({}));
100101
expect(blocksInfo.data.length).to.be.greaterThan(0);
101102
});
102103
});
103104

104105
describe('searchBlock with streamer', () => {
105106
it('should return block info given height and limit', async () => {
106107
const streamer = new BlockPaginationStreamer(blockRepository);
107-
const blockInfoStreamer = await streamer.search({ pageSize: 20 }).pipe(take(20), toArray()).toPromise();
108-
const blocksInfo = await blockRepository.search({ pageSize: 20 }).toPromise();
108+
const blockInfoStreamer = await firstValueFrom(streamer.search({ pageSize: 20 }).pipe(take(20), toArray()));
109+
const blocksInfo = await firstValueFrom(blockRepository.search({ pageSize: 20 }));
109110
expect(blockInfoStreamer.length).to.be.greaterThan(0);
110111
deepEqual(blockInfoStreamer, blocksInfo.data);
111112
});
112113
});
113114

114115
describe('getMerkleReceipts', () => {
115116
it('should return Merkle Receipts', async () => {
116-
const merkleReceipts = await receiptRepository
117-
.searchReceipts({ height: chainHeight })
118-
.pipe(
117+
const merkleReceipts = await firstValueFrom(
118+
receiptRepository.searchReceipts({ height: chainHeight }).pipe(
119119
mergeMap((_) => {
120120
return blockRepository.getMerkleReceipts(chainHeight, (_.data[0] as TransactionStatement).generateHash());
121121
}),
122-
)
123-
.toPromise();
122+
),
123+
);
124124
expect(merkleReceipts.merklePath).not.to.be.null;
125125
});
126126
});
127127
describe('getMerkleTransaction', () => {
128128
it('should return Merkle Transaction', async () => {
129-
const merkleTransactionss = await blockRepository.getMerkleTransaction(chainHeight, transactionHash).toPromise();
129+
const merkleTransactionss = await firstValueFrom(blockRepository.getMerkleTransaction(chainHeight, transactionHash));
130130
expect(merkleTransactionss.merklePath).not.to.be.null;
131131
});
132132
});
133133

134134
describe('getBlockReceipts', () => {
135135
it('should return block receipts', async () => {
136-
const statement = await receiptRepository.searchReceipts({ height: chainHeight }).toPromise();
136+
const statement = await firstValueFrom(receiptRepository.searchReceipts({ height: chainHeight }));
137137
expect(statement.data.length).to.be.greaterThan(0);
138138
});
139139
});
140140

141141
describe('searchReceipt with streamer', () => {
142142
it('should return receipt info', async () => {
143143
const streamer = ReceiptPaginationStreamer.transactionStatements(receiptRepository);
144-
const infoStreamer = await streamer
145-
.search({ pageSize: 20, height: chainHeight, order: Order.Asc })
146-
.pipe(take(20), toArray())
147-
.toPromise();
148-
const info = await receiptRepository.searchReceipts({ pageSize: 20, height: chainHeight, order: Order.Asc }).toPromise();
144+
const infoStreamer = await firstValueFrom(
145+
streamer.search({ pageSize: 20, height: chainHeight, order: Order.Asc }).pipe(take(20), toArray()),
146+
);
147+
const info = await firstValueFrom(receiptRepository.searchReceipts({ pageSize: 20, height: chainHeight, order: Order.Asc }));
149148
expect(infoStreamer.length).to.be.greaterThan(0);
150149
deepEqual(infoStreamer[0], info.data[0]);
151150
});

e2e/infrastructure/ChainHttp.spec.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616

1717
import { expect } from 'chai';
18+
import { firstValueFrom } from 'rxjs';
1819
import { ChainRepository } from '../../src/infrastructure/ChainRepository';
1920
import { IntegrationTestHelper } from './IntegrationTestHelper';
2021

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

3536
describe('getChainInfo', () => {
3637
it('should return blockchain score', async () => {
37-
const info = await chainRepository.getChainInfo().toPromise();
38+
const info = await firstValueFrom(chainRepository.getChainInfo());
3839
expect(info.scoreLow).to.not.be.equal(undefined);
3940
expect(info.scoreHigh.lower).to.be.equal(0);
4041
expect(info.scoreHigh.higher).to.be.equal(0);

e2e/infrastructure/FinalizationHttp.spec.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* limitations under the License.
1515
*/
1616
import { expect } from 'chai';
17+
import { firstValueFrom } from 'rxjs';
1718
import { FinalizationRepository } from '../../src/infrastructure/FinalizationRepository';
1819
import { UInt64 } from '../../src/model/UInt64';
1920
import { IntegrationTestHelper } from './IntegrationTestHelper';
@@ -34,7 +35,7 @@ describe('FinalizationHttp', () => {
3435

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

4748
describe('getNetworkName', () => {
4849
it('should return finalization proof at height', async () => {
49-
const dto = await finalizationRepository.getFinalizationProofAtHeight(UInt64.fromUint(1)).toPromise();
50+
const dto = await firstValueFrom(finalizationRepository.getFinalizationProofAtHeight(UInt64.fromUint(1)));
5051
expect(dto).not.to.be.null;
5152
expect(dto.height).to.deep.eq(UInt64.fromUint(1));
5253
expect(dto.version).to.eq(1);

e2e/infrastructure/HashLockHttp.spec.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import { ChronoUnit } from '@js-joda/core';
1818
import { deepEqual } from 'assert';
1919
import { expect } from 'chai';
20+
import { firstValueFrom } from 'rxjs';
2021
import { take, toArray } from 'rxjs/operators';
2122
import { HashLockPaginationStreamer, Order } from '../../src/infrastructure';
2223
import { HashLockRepository } from '../../src/infrastructure/HashLockRepository';
@@ -154,34 +155,33 @@ describe('HashLockHttp', () => {
154155
describe('searchHashLock', () => {
155156
it('should return hash lock page info', async () => {
156157
await new Promise((resolve) => setTimeout(resolve, 3000));
157-
const page = await hashLockRepo.search({ address: account.address }).toPromise();
158+
const page = await firstValueFrom(hashLockRepo.search({ address: account.address }));
158159
const info = page.data[0];
159160
hash = info.hash;
160161
expect(page.data.length).to.be.greaterThan(0);
161162

162-
const infoFromId = await hashLockRepo.getHashLock(hash).toPromise();
163+
const infoFromId = await firstValueFrom(hashLockRepo.getHashLock(hash));
163164
expect(infoFromId).deep.eq(info);
164-
const merkleInfo = await hashLockRepo.getHashLockMerkle(hash).toPromise();
165+
const merkleInfo = await firstValueFrom(hashLockRepo.getHashLockMerkle(hash));
165166
expect(merkleInfo.raw).to.not.be.undefined;
166167
});
167168
});
168169

169170
describe('searchHashLock with streamer', () => {
170171
it('should return hash lock page info', async () => {
171172
const streamer = new HashLockPaginationStreamer(hashLockRepo);
172-
const infoStreamer = await streamer
173-
.search({ address: account.address, pageSize: 20, order: Order.Asc })
174-
.pipe(take(20), toArray())
175-
.toPromise();
176-
const info = await hashLockRepo.search({ address: account.address, pageSize: 20, order: Order.Asc }).toPromise();
173+
const infoStreamer = await firstValueFrom(
174+
streamer.search({ address: account.address, pageSize: 20, order: Order.Asc }).pipe(take(20), toArray()),
175+
);
176+
const info = await firstValueFrom(hashLockRepo.search({ address: account.address, pageSize: 20, order: Order.Asc }));
177177
expect(infoStreamer.length).to.be.greaterThan(0);
178178
deepEqual(infoStreamer[0], info.data[0]);
179179
});
180180
});
181181

182182
describe('getHashLock', () => {
183183
it('should return hash lock info given hash', async () => {
184-
const info = await hashLockRepo.getHashLock(hash).toPromise();
184+
const info = await firstValueFrom(hashLockRepo.getHashLock(hash));
185185
expect(info.ownerAddress.plain()).to.be.equal(account.address.plain());
186186
expect(info.amount.toString()).to.be.equal('10000000');
187187
});

e2e/infrastructure/IntegrationTestHelper.ts

+11-11
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
import { firstValueFrom } from 'rxjs';
1617
import { map } from 'rxjs/operators';
1718
import { Addresses, BootstrapService, BootstrapUtils, ConfigLoader, StartParams } from 'symbol-bootstrap';
1819
import { IListener, RepositoryFactory, RepositoryFactoryHttp } from '../../src/infrastructure';
@@ -84,9 +85,9 @@ export class IntegrationTestHelper {
8485
this.repositoryFactory.createReceiptRepository(),
8586
);
8687

87-
this.networkType = await this.repositoryFactory.getNetworkType().toPromise();
88-
this.generationHash = await this.repositoryFactory.getGenerationHash().toPromise();
89-
this.epochAdjustment = await this.repositoryFactory.getEpochAdjustment().toPromise();
88+
this.networkType = await firstValueFrom(this.repositoryFactory.getNetworkType());
89+
this.generationHash = await firstValueFrom(this.repositoryFactory.getGenerationHash());
90+
this.epochAdjustment = await firstValueFrom(this.repositoryFactory.getEpochAdjustment());
9091

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

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

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

119120
announce(signedTransaction: SignedTransaction): Promise<Transaction> {
120121
console.log(`Announcing transaction: ${signedTransaction.type}`);
121-
return this.transactionService
122-
.announce(signedTransaction, this.listener)
123-
.pipe(
122+
return firstValueFrom(
123+
this.transactionService.announce(signedTransaction, this.listener).pipe(
124124
map((t) => {
125125
console.log(`Transaction ${signedTransaction.type} confirmed`);
126126
return t;
127127
}),
128-
)
129-
.toPromise();
128+
),
129+
);
130130
}
131131

132-
public static sleep(ms: number): Promise<any> {
132+
public static sleep(ms: number): Promise<void> {
133133
// Create a promise that rejects in <ms> milliseconds
134134
return new Promise((resolve) => {
135135
setTimeout(() => {
136-
resolve();
136+
resolve(undefined);
137137
}, ms);
138138
});
139139
}

0 commit comments

Comments
 (0)