Skip to content

Commit 2f7f516

Browse files
committed
Merge remote-tracking branch 'origin/master' into catbuffer-library
# Conflicts: # package.json # src/model/transaction/TransactionStatus.ts
2 parents 127d9da + c3797e0 commit 2f7f516

File tree

233 files changed

+998
-19325
lines changed

Some content is hidden

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

233 files changed

+998
-19325
lines changed

CHANGELOG.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,32 @@ All notable changes to this project will be documented in this file.
33

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

6+
## 09-Jan-2020
7+
8+
**Milestone**: Fushicho.3
9+
Versions | |
10+
---|---|---
11+
SDK Core| v0.16.3 | https://www.npmjs.com/package/nem2-sdk
12+
Catbuffer Library| v0.0.7 | https://www.npmjs.com/package/catbuffer
13+
Client Library | v0.7.20-beta.6 | https://www.npmjs.com/package/nem2-sdk-openapi-typescript-node-client
14+
15+
- Fixed http client (OpenAPI client package) does not support ES6 issue.
16+
17+
## 06-Jan-2020
18+
19+
**Milestone**: Fushicho.3
20+
Versions | |
21+
---|---|---
22+
SDK Core| v0.16.2 | https://www.npmjs.com/package/nem2-sdk
23+
Catbuffer Library| v0.0.7 | https://www.npmjs.com/package/catbuffer
24+
Client Library | v0.7.20-alpha.6 | https://www.npmjs.com/package/nem2-sdk-openapi-typescript-node-client
25+
26+
- Refactored to replace generated codes by public library package for both `Catbuffer` and `OpenAPI Http Client`.
27+
- Added unresolved (mosaicId, address) support in `MosaicRestrictionTransaction`.
28+
- Added `toHex()` in `MosaicNonce` class.
29+
- Exposed `MultisigAccountGraphInfo` class constructor to public.
30+
- Fixed `transaction status` issue in both `Http` and `Websocket` due to schema update.
31+
632
## [0.16.1] - 23-Dec-2019
733

834
**Milestone**: Fushicho.3
@@ -302,6 +328,8 @@ The changelog format is based on [Keep a Changelog](https://keepachangelog.com/e
302328
**Milestone**: Alpaca
303329

304330
- Initial code release.
331+
[0.16.3]: https://github.com/nemtech/nem2-sdk-typescript-javascript/compare/v0.16.2...v0.16.3
332+
[0.16.2]: https://github.com/nemtech/nem2-sdk-typescript-javascript/compare/v0.16.1...v0.16.2
305333
[0.16.1]: https://github.com/nemtech/nem2-sdk-typescript-javascript/compare/v0.16.0...v0.16.1
306334
[0.16.0]: https://github.com/nemtech/nem2-sdk-typescript-javascript/compare/v0.15.1...v0.16.0
307335
[0.15.1]: https://github.com/nemtech/nem2-sdk-typescript-javascript/compare/v0.15.0...v0.15.1

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ with the NEM2 (a.k.a Catapult)
1212

1313
### _Fushicho_ Network Compatibility (catapult-server@0.9.1.1)
1414

15-
Due to a network upgrade with [catapult-server@Fushicho](https://github.com/nemtech/catapult-server/releases/tag/v0.9.1.1) version, **it is recommended to use this package's 0.16.1 version and upwards to use this package with Fushicho versioned networks**.
15+
Due to a network upgrade with [catapult-server@Fushicho](https://github.com/nemtech/catapult-server/releases/tag/v0.9.1.1) version, **it is recommended to use this package's 0.16.3 version and upwards to use this package with Fushicho versioned networks**.
1616

17-
The upgrade to this package's [version v0.16.0](https://github.com/nemtech/nem2-sdk-typescript-javascript/releases/tag/v0.16.0) is mandatory for **fushicho compatibility**.
17+
The upgrade to this package's [version v0.16.3](https://github.com/nemtech/nem2-sdk-typescript-javascript/releases/tag/v0.16.3) is mandatory for **fushicho compatibility**.
1818

1919
### _Elephant_ Network Compatibility (catapult-server@0.7.0.1)
2020

e2e/infrastructure/AccountHttp.spec.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { assert, expect } from 'chai';
1818
import { AccountRepository } from '../../src/infrastructure/AccountRepository';
1919
import { MultisigRepository } from '../../src/infrastructure/MultisigRepository';
2020
import { NamespaceRepository } from '../../src/infrastructure/NamespaceRepository';
21+
import { QueryParams } from '../../src/infrastructure/QueryParams';
2122
import { Account } from '../../src/model/account/Account';
2223
import { Address } from '../../src/model/account/Address';
2324
import { PublicAccount } from '../../src/model/account/PublicAccount';
@@ -31,6 +32,7 @@ import { AggregateTransaction } from '../../src/model/transaction/AggregateTrans
3132
import { Deadline } from '../../src/model/transaction/Deadline';
3233
import { MultisigAccountModificationTransaction } from '../../src/model/transaction/MultisigAccountModificationTransaction';
3334
import { NamespaceRegistrationTransaction } from '../../src/model/transaction/NamespaceRegistrationTransaction';
35+
import { TransactionType } from '../../src/model/transaction/TransactionType';
3436
import { TransferTransaction } from '../../src/model/transaction/TransferTransaction';
3537
import { UInt64 } from '../../src/model/UInt64';
3638
import { IntegrationTestHelper } from './IntegrationTestHelper';
@@ -225,6 +227,30 @@ describe('AccountHttp', () => {
225227
});
226228
});
227229

230+
describe('transactions', () => {
231+
it('should not return accounts when account does not exist', () => {
232+
return accountRepository.getAccountInfo(Account.generateNewAccount(networkType).address).toPromise().then(r => {
233+
return Promise.reject('should fail!');
234+
}, err => {
235+
const error = JSON.parse(err.message);
236+
expect(error.statusCode).to.be.eq(404);
237+
expect(error.errorDetails.statusMessage).to.be.eq('Not Found');
238+
return Promise.resolve();
239+
});
240+
});
241+
});
242+
243+
describe('transactions', () => {
244+
it('should call transactions successfully by type', async () => {
245+
const transactions = await accountRepository.getAccountTransactions(publicAccount.address, {transactionType: TransactionType.TRANSFER} as QueryParams).toPromise();
246+
247+
expect(transactions.length).to.be.greaterThan(0);
248+
transactions.forEach(t => {
249+
expect(t.type).to.be.eq(TransactionType.TRANSFER);
250+
});
251+
});
252+
});
253+
228254
describe('transactions', () => {
229255
it('should call transactions successfully', (done) => {
230256
accountRepository.getAccountTransactions(publicAccount.address).subscribe((transactions) => {

e2e/infrastructure/BlockHttp.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ describe('BlockHttp', () => {
8080
const signedTransaction = transferTransaction.signWith(account, generationHash);
8181
helper.announce(signedTransaction).then((transaction) => {
8282
chainHeight = transaction.transactionInfo!.height.toString();
83-
return transaction;
83+
done();
8484
});
8585
});
8686
});

e2e/infrastructure/IntegrationTestHelper.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,7 @@ export class IntegrationTestHelper {
7777
'../../../catapult-service-bootstrap/build/generated-addresses/addresses.yaml'),
7878
(error: any, yamlData: any) => {
7979
if (error) {
80-
console.log(`catapult-service-bootstrap generated address could not be loaded.
81-
Ignoring and using accounts from network.conf. Error: ${error}`);
80+
console.log(`catapult-service-bootstrap generated address could not be loaded. Ignoring and using accounts from network.conf.`);
8281
return resolve(this);
8382
} else {
8483
const parsedYaml = this.yaml.safeLoad(yamlData);

e2e/infrastructure/Listener.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ describe('Listener', () => {
369369
return helper.announce(transferTransaction.signWith(account, generationHash)).then(() => {
370370
throw new Error('Transaction should have failed!!');
371371
}, (error) => {
372-
expect(error.status).to.be.equal('Failure_Core_Insufficient_Balance');
372+
expect(error.code).to.be.equal('Failure_Core_Insufficient_Balance');
373373
});
374374
});
375375
});

e2e/service/MosaicRestrictionTransactionService.spec.ts

Lines changed: 131 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
11
import { expect } from 'chai';
22
import { KeyGenerator } from '../../src/core/format/KeyGenerator';
3+
import { NamespaceRepository } from '../../src/infrastructure/NamespaceRepository';
34
import { RestrictionMosaicRepository } from '../../src/infrastructure/RestrictionMosaicRepository';
45
import { Account } from '../../src/model/account/Account';
56
import { NetworkType } from '../../src/model/blockchain/NetworkType';
67
import { MosaicFlags } from '../../src/model/mosaic/MosaicFlags';
78
import { MosaicId } from '../../src/model/mosaic/MosaicId';
89
import { MosaicNonce } from '../../src/model/mosaic/MosaicNonce';
10+
import { AliasAction } from '../../src/model/namespace/AliasAction';
11+
import { NamespaceId } from '../../src/model/namespace/NamespaceId';
912
import { MosaicRestrictionType } from '../../src/model/restriction/MosaicRestrictionType';
13+
import { AddressAliasTransaction } from '../../src/model/transaction/AddressAliasTransaction';
1014
import { AggregateTransaction } from '../../src/model/transaction/AggregateTransaction';
1115
import { Deadline } from '../../src/model/transaction/Deadline';
1216
import { MosaicAddressRestrictionTransaction } from '../../src/model/transaction/MosaicAddressRestrictionTransaction';
17+
import { MosaicAliasTransaction } from '../../src/model/transaction/MosaicAliasTransaction';
1318
import { MosaicDefinitionTransaction } from '../../src/model/transaction/MosaicDefinitionTransaction';
1419
import { MosaicGlobalRestrictionTransaction } from '../../src/model/transaction/MosaicGlobalRestrictionTransaction';
20+
import { NamespaceRegistrationTransaction } from '../../src/model/transaction/NamespaceRegistrationTransaction';
1521
import { TransactionType } from '../../src/model/transaction/TransactionType';
1622
import { UInt64 } from '../../src/model/UInt64';
1723
import { MosaicRestrictionTransactionService } from '../../src/service/MosaicRestrictionTransactionService';
@@ -22,17 +28,21 @@ describe('MosaicRestrictionTransactionService', () => {
2228
const key = KeyGenerator.generateUInt64Key('TestKey');
2329
let account: Account;
2430
let restrictionRepository: RestrictionMosaicRepository;
31+
let namespaceRepository: NamespaceRepository;
2532
let mosaicId: MosaicId;
2633
let generationHash: string;
2734
const helper = new IntegrationTestHelper();
2835
let networkType: NetworkType;
36+
let namespaceIdAddress: NamespaceId;
37+
let namespaceIdMosaic: NamespaceId;
2938

3039
before(() => {
3140
return helper.start().then(() => {
3241
account = helper.account;
3342
generationHash = helper.generationHash;
3443
networkType = helper.networkType;
3544
restrictionRepository = helper.repositoryFactory.createRestrictionMosaicRepository();
45+
namespaceRepository = helper.repositoryFactory.createNamespaceRepository();
3646
});
3747
});
3848

@@ -64,6 +74,7 @@ describe('MosaicRestrictionTransactionService', () => {
6474
UInt64.fromUint(1000),
6575
networkType, helper.maxFee,
6676
);
77+
console.log(mosaicId.toHex());
6778
const signedTransaction = mosaicDefinitionTransaction.signWith(account, generationHash);
6879
return helper.announce(signedTransaction);
6980
});
@@ -99,6 +110,7 @@ describe('MosaicRestrictionTransactionService', () => {
99110
account.address,
100111
UInt64.fromUint(2),
101112
networkType,
113+
undefined,
102114
helper.maxFee,
103115
);
104116
const aggregateTransaction = AggregateTransaction.createComplete(Deadline.create(),
@@ -111,14 +123,80 @@ describe('MosaicRestrictionTransactionService', () => {
111123
});
112124
});
113125

126+
describe('NamespaceRegistrationTransaction', () => {
127+
128+
it('standalone', () => {
129+
const namespaceName = 'root-test-namespace-' + Math.floor(Math.random() * 10000);
130+
const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace(
131+
Deadline.create(),
132+
namespaceName,
133+
UInt64.fromUint(50),
134+
networkType, helper.maxFee,
135+
);
136+
namespaceIdMosaic = new NamespaceId(namespaceName);
137+
const signedTransaction = registerNamespaceTransaction.signWith(account, generationHash);
138+
139+
return helper.announce(signedTransaction);
140+
});
141+
});
142+
143+
describe('NamespaceRegistrationTransaction', () => {
144+
145+
it('standalone', () => {
146+
const namespaceName = 'root-test-namespace-' + Math.floor(Math.random() * 10000);
147+
const registerNamespaceTransaction = NamespaceRegistrationTransaction.createRootNamespace(
148+
Deadline.create(),
149+
namespaceName,
150+
UInt64.fromUint(50),
151+
networkType, helper.maxFee,
152+
);
153+
namespaceIdAddress = new NamespaceId(namespaceName);
154+
const signedTransaction = registerNamespaceTransaction.signWith(account, generationHash);
155+
156+
return helper.announce(signedTransaction);
157+
});
158+
});
159+
160+
describe('AddressAliasTransaction', () => {
161+
162+
it('standalone', () => {
163+
const addressAliasTransaction = AddressAliasTransaction.create(
164+
Deadline.create(),
165+
AliasAction.Link,
166+
namespaceIdAddress,
167+
account.address,
168+
networkType, helper.maxFee,
169+
);
170+
const signedTransaction = addressAliasTransaction.signWith(account, generationHash);
171+
172+
return helper.announce(signedTransaction);
173+
});
174+
});
175+
176+
describe('MosaicAliasTransaction', () => {
177+
178+
it('standalone', () => {
179+
const mosaicAliasTransaction = MosaicAliasTransaction.create(
180+
Deadline.create(),
181+
AliasAction.Link,
182+
namespaceIdMosaic,
183+
mosaicId,
184+
networkType, helper.maxFee,
185+
);
186+
const signedTransaction = mosaicAliasTransaction.signWith(account, generationHash);
187+
188+
return helper.announce(signedTransaction);
189+
});
190+
});
191+
114192
/**
115193
* =========================
116194
* Test
117195
* =========================
118196
*/
119-
describe('Test new services', () => {
197+
describe('Test new services - MosaicGlobalRestriction', () => {
120198
it('should create MosaicGlobalRestrictionTransaction', (done) => {
121-
const service = new MosaicRestrictionTransactionService(restrictionRepository);
199+
const service = new MosaicRestrictionTransactionService(restrictionRepository, namespaceRepository);
122200

123201
return service.createMosaicGlobalRestrictionTransaction(
124202
deadline,
@@ -137,9 +215,33 @@ describe('MosaicRestrictionTransactionService', () => {
137215
done();
138216
});
139217
});
140-
it('should create MosaicAddressRestrictionTransaction', (done) => {
141-
const service = new MosaicRestrictionTransactionService(restrictionRepository);
218+
});
219+
220+
describe('Test new services - MosaicGlobalRestriction', () => {
221+
it('should create MosaicGlobalRestrictionTransaction using alias', (done) => {
222+
const service = new MosaicRestrictionTransactionService(restrictionRepository, namespaceRepository);
223+
return service.createMosaicGlobalRestrictionTransaction(
224+
deadline,
225+
networkType,
226+
namespaceIdMosaic,
227+
key,
228+
'2',
229+
MosaicRestrictionType.GE, undefined, helper.maxFee,
230+
).subscribe((transaction: MosaicGlobalRestrictionTransaction) => {
231+
expect(transaction.type).to.be.equal(TransactionType.MOSAIC_GLOBAL_RESTRICTION);
232+
expect(transaction.previousRestrictionValue.toString()).to.be.equal('1');
233+
expect(transaction.previousRestrictionType).to.be.equal(MosaicRestrictionType.GE);
234+
expect(transaction.newRestrictionValue.toString()).to.be.equal('2');
235+
expect(transaction.newRestrictionType).to.be.equal(MosaicRestrictionType.GE);
236+
expect(transaction.restrictionKey.toHex()).to.be.equal(key.toHex());
237+
done();
238+
});
239+
});
240+
});
142241

242+
describe('Test new services - MosaicAddressRestriction', () => {
243+
it('should create MosaicAddressRestrictionTransaction', (done) => {
244+
const service = new MosaicRestrictionTransactionService(restrictionRepository, namespaceRepository);
143245
return service.createMosaicAddressRestrictionTransaction(
144246
deadline,
145247
networkType,
@@ -159,10 +261,33 @@ describe('MosaicRestrictionTransactionService', () => {
159261
});
160262
});
161263

264+
describe('Test new services - MosaicAddressRestriction', () => {
265+
it('should create MosaicAddressRestrictionTransaction with address alias', (done) => {
266+
const service = new MosaicRestrictionTransactionService(restrictionRepository, namespaceRepository);
267+
268+
return service.createMosaicAddressRestrictionTransaction(
269+
deadline,
270+
networkType,
271+
mosaicId,
272+
key,
273+
namespaceIdAddress,
274+
'4',
275+
helper.maxFee,
276+
).subscribe((transaction: MosaicAddressRestrictionTransaction) => {
277+
expect(transaction.type).to.be.equal(TransactionType.MOSAIC_ADDRESS_RESTRICTION);
278+
expect(transaction.previousRestrictionValue.toString()).to.be.equal('3');
279+
expect(transaction.newRestrictionValue.toString()).to.be.equal('4');
280+
expect(transaction.targetAddressToString()).to.be.equal(account.address.plain());
281+
expect(transaction.restrictionKey.toHex()).to.be.equal(key.toHex());
282+
done();
283+
});
284+
});
285+
});
286+
162287
describe('Announce MosaicGlobalRestriction through service', () => {
163288

164289
it('should create MosaicGlobalRestriction and announce', (done) => {
165-
const service = new MosaicRestrictionTransactionService(restrictionRepository);
290+
const service = new MosaicRestrictionTransactionService(restrictionRepository, namespaceRepository);
166291
service.createMosaicGlobalRestrictionTransaction(
167292
deadline,
168293
networkType,
@@ -188,7 +313,7 @@ describe('MosaicRestrictionTransactionService', () => {
188313
describe('Announce MosaicAddressRestriction through service', () => {
189314

190315
it('should create MosaicAddressRestriction and announce', (done) => {
191-
const service = new MosaicRestrictionTransactionService(restrictionRepository);
316+
const service = new MosaicRestrictionTransactionService(restrictionRepository, namespaceRepository);
192317

193318
return service.createMosaicAddressRestrictionTransaction(
194319
deadline,

0 commit comments

Comments
 (0)