Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
aff8179
Added #93
rg911 Jun 11, 2019
6a24240
Added #94
rg911 Jun 11, 2019
f3840c9
Added unit test
rg911 Jun 12, 2019
f82c312
Added #170
rg911 Jun 12, 2019
6c41ef5
Added #95
rg911 Jun 12, 2019
db91428
Applied transaction builders to transaction models
rg911 Jun 12, 2019
ad538ef
Updated licenses
rg911 Jun 12, 2019
fa2a7c7
Added #96
rg911 Jun 12, 2019
7d15023
Fixed accountProperty transaction modification type field name mismat…
rg911 Jun 12, 2019
a5f888b
Updated account decrypt message parameter name.
rg911 Jun 13, 2019
97a7c69
Fixed doc
rg911 Jun 13, 2019
c15999a
Merge pull request #168 from rg911/task/g93_merge_encoders
evias Jun 14, 2019
4262dab
Added #94
rg911 Jun 11, 2019
7daa764
Added unit test
rg911 Jun 12, 2019
08e4bea
Merge branch 'task/g94_merge_crypto_implementation' of github.com:rg9…
rg911 Jun 14, 2019
1007912
Merge pull request #169 from rg911/task/g94_merge_crypto_implementation
evias Jun 14, 2019
ae4224a
Added #170
rg911 Jun 12, 2019
78ee613
Merge branch 'task/g170_merge_existing_buffer_schema' of github.com:r…
rg911 Jun 14, 2019
8c580c1
Merge pull request #171 from rg911/task/g170_merge_existing_buffer_sc…
evias Jun 14, 2019
833b59d
Added #95
rg911 Jun 12, 2019
5333811
Applied transaction builders to transaction models
rg911 Jun 12, 2019
0cab0c4
Updated licenses
rg911 Jun 12, 2019
227b8f5
Fixed accountProperty transaction modification type field name mismat…
rg911 Jun 12, 2019
ec97c84
Merge branch 'task/g95_merge_library_transaction_builder' of github.c…
rg911 Jun 14, 2019
e189f6a
Removed lib namespaceMosaic id generator nem2-lib reference
rg911 Jun 14, 2019
e037fb6
Merge pull request #172 from rg911/task/g95_merge_library_transaction…
evias Jun 14, 2019
cc974df
Added #96
rg911 Jun 12, 2019
52b15a5
Updated account decrypt message parameter name.
rg911 Jun 13, 2019
7f00e07
Fixed doc
rg911 Jun 13, 2019
83030ec
Removed Nem2-Lib from package.json
rg911 Jun 14, 2019
c1108e0
Merge branch 'task/g96_merge_swagger_generated_classes' of github.com…
rg911 Jun 14, 2019
0932831
Fixed e2e test in AccountHttp
rg911 Jun 14, 2019
07c50f3
removed unused imports
rg911 Jun 14, 2019
2383706
Applied new swagger code gen template
rg911 Jun 15, 2019
5e50cde
Updated doc
rg911 Jun 15, 2019
bdd47ec
Updated readme for DTO code generation
rg911 Jun 15, 2019
0e83ff2
updated readme
rg911 Jun 15, 2019
b6edf2d
Updated readme
rg911 Jun 15, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 95 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,101 @@ Important versions listed below. Refer to the [Changelog](CHANGELOG.md) for a fu
- [0.10.1-beta](CHANGELOG.md#v0101-beta) - **Alpaca compatible** 07.2018
- [0.9.5](CHANGELOG.md#095-27-Jun-2018) - **Alpaca compatible** 07.2018

## Notes on generation of catapult-rest DTO and API client

Following command can be used to generate DTOs and Api clients for the [nem2-sdk-typescript-javascript](https://github.com/nemtech/nem2-sdk-typescript-javascript) :

1. Download latest NEM2 swagger definition
```bash
$ git clone git@github.com:nemtech/nem2-docs
$ cd nem2-docs && mkdir sdks && cd sdks
$ cp ../source/resources/collections/swagger.yaml .
```
2. Copy OpenAPI generator template

Copy the `templates` folder from {nem2-sdk-typescript-javascript}/infrastructure/ into `sdk` folder

3. Download OpenAPI generator and generate codes
```bash
$ brew install openapi-generator
$ openapi-generator generate -i ./swagger2.yaml -g typescript-node -t templates/ -o ./nem2-ts-sdk/ && rm -R nem2-ts-sdk/test
```
** Note openapi-generator is also available on docker. (`https://hub.docker.com/r/openapitools/openapi-generator`)
4. Fix enum type definitions

As the generator doesn't recognize `enum` type alias, we need to manually move enum classes in to the `enumsMap` list.
- Open generated file `./nem2-ts-sdk/model/models.ts` in editor
- Search for line contains `let enumsMap: {[index: string]: any}`.
- Move all `xxxTypeEnum` entries from below `typeMap` into `enumsMap`.

example below:
```js
let enumsMap: {[index: string]: any} = {
"AccountPropertyTypeEnum": AccountPropertyTypeEnum,
"AliasTypeEnum": AliasTypeEnum,
"ResolutionStatementDTO": ResolutionStatementDTO,
"MosaicPropertyIdEnum": MosaicPropertyIdEnum,
"MultisigModificationTypeEnum": MultisigModificationTypeEnum,
"NamespaceTypeEnum": NamespaceTypeEnum,
"ReceiptTypeEnum": ReceiptTypeEnum,
"RolesTypeEnum": RolesTypeEnum,
}

let typeMap: {[index: string]: any} = {
"AccountDTO": AccountDTO,
"AccountIds": AccountIds,
"AccountInfoDTO": AccountInfoDTO,
"AccountMetaDTO": AccountMetaDTO,
"AccountNamesDTO": AccountNamesDTO,
"AccountPropertiesDTO": AccountPropertiesDTO,
"AccountPropertiesInfoDTO": AccountPropertiesInfoDTO,
"AccountPropertyDTO": AccountPropertyDTO,
"AliasDTO": AliasDTO,
"AnnounceTransactionInfoDTO": AnnounceTransactionInfoDTO,
"BlockDTO": BlockDTO,
"BlockInfoDTO": BlockInfoDTO,
"BlockMetaDTO": BlockMetaDTO,
"BlockchainScoreDTO": BlockchainScoreDTO,
"CommunicationTimestamps": CommunicationTimestamps,
"Cosignature": Cosignature,
"HeightInfoDTO": HeightInfoDTO,
"MerklePathItem": MerklePathItem,
"MerkleProofInfo": MerkleProofInfo,
"MerkleProofInfoDTO": MerkleProofInfoDTO,
"MosaicDTO": MosaicDTO,
"MosaicDefinitionDTO": MosaicDefinitionDTO,
"MosaicIds": MosaicIds,
"MosaicInfoDTO": MosaicInfoDTO,
"MosaicMetaDTO": MosaicMetaDTO,
"MosaicNamesDTO": MosaicNamesDTO,
"MosaicPropertyDTO": MosaicPropertyDTO,
"MultisigAccountGraphInfoDTO": MultisigAccountGraphInfoDTO,
"MultisigAccountInfoDTO": MultisigAccountInfoDTO,
"MultisigDTO": MultisigDTO,
"NamespaceDTO": NamespaceDTO,
"NamespaceIds": NamespaceIds,
"NamespaceInfoDTO": NamespaceInfoDTO,
"NamespaceMetaDTO": NamespaceMetaDTO,
"NamespaceNameDTO": NamespaceNameDTO,
"NetworkTypeDTO": NetworkTypeDTO,
"NodeInfoDTO": NodeInfoDTO,
"NodeTimeDTO": NodeTimeDTO,
"ResolutionEntryDTO": ResolutionEntryDTO,
"ServerDTO": ServerDTO,
"ServerInfoDTO": ServerInfoDTO,
"SourceDTO": SourceDTO,
"StatementsDTO": StatementsDTO,
"StorageInfoDTO": StorageInfoDTO,
"TransactionHashes": TransactionHashes,
"TransactionIds": TransactionIds,
"TransactionInfoDTO": TransactionInfoDTO,
"TransactionMetaDTO": TransactionMetaDTO,
"TransactionPayload": TransactionPayload,
"TransactionStatementDTO": TransactionStatementDTO,
"TransactionStatusDTO": TransactionStatusDTO,
}
```

## License

Copyright (c) 2018-2019 NEM
Expand Down
31 changes: 0 additions & 31 deletions e2e/infrastructure/AccountHttp.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -444,37 +444,6 @@ describe('AccountHttp', () => {
});
});

describe('Remove test AddressAlias', () => {
let listener: Listener;
before (() => {
listener = new Listener(config.apiUrl);
return listener.open();
});
after(() => {
return listener.close();
});

it('Announce addressAliasTransaction', (done) => {
const addressAliasTransaction = AddressAliasTransaction.create(
Deadline.create(),
AliasActionType.Unlink,
namespaceId,
account.address,
NetworkType.MIJIN_TEST,
);
const signedTransaction = addressAliasTransaction.signWith(account, generationHash);

listener.confirmed(account.address).subscribe(() => {
done();
});
listener.status(account.address).subscribe((error) => {
console.log('Error:', error);
assert(false);
done();
});
transactionHttp.announce(signedTransaction);
});
});
describe('Restore test multisig Accounts', () => {
let listener: Listener;
before (() => {
Expand Down
1 change: 0 additions & 1 deletion e2e/infrastructure/MosaicHttp.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ describe('MosaicHttp', () => {
it('Announce MosaicDefinitionTransaction', (done) => {
const nonce = MosaicNonce.createRandom();
mosaicId = MosaicId.createFromNonce(nonce, account.publicAccount);
console.log(mosaicId.toHex());
const mosaicDefinitionTransaction = MosaicDefinitionTransaction.create(
Deadline.create(),
nonce,
Expand Down
36 changes: 18 additions & 18 deletions e2e/infrastructure/TransactionHttp.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ import {assert, expect} from 'chai';
import * as CryptoJS from 'crypto-js';
import {ChronoUnit} from 'js-joda';
import {keccak_256, sha3_256} from 'js-sha3';
import {convert, nacl_catapult} from 'nem2-library';
import {Crypto} from '../../src/core/crypto';
import { Convert as convert } from '../../src/core/format';
import {AccountHttp} from '../../src/infrastructure/AccountHttp';
import { NamespaceHttp } from '../../src/infrastructure/infrastructure';
import {Listener} from '../../src/infrastructure/Listener';
Expand Down Expand Up @@ -66,7 +67,6 @@ import {Transaction} from '../../src/model/transaction/Transaction';
import {TransactionType} from '../../src/model/transaction/TransactionType';
import {TransferTransaction} from '../../src/model/transaction/TransferTransaction';
import {UInt64} from '../../src/model/UInt64';

describe('TransactionHttp', () => {
let transactionHash;
let transactionId;
Expand Down Expand Up @@ -992,7 +992,7 @@ describe('TransactionHttp', () => {
NetworkCurrencyMosaic.createAbsolute(10),
UInt64.fromUint(100),
HashType.Op_Sha3_256,
sha3_256.create().update(nacl_catapult.randomBytes(20)).hex(),
sha3_256.create().update(Crypto.randomBytes(20)).hex(),
account2.address,
NetworkType.MIJIN_TEST,
);
Expand Down Expand Up @@ -1028,7 +1028,7 @@ describe('TransactionHttp', () => {
NetworkCurrencyMosaic.createAbsolute(10),
UInt64.fromUint(100),
HashType.Op_Sha3_256,
sha3_256.create().update(nacl_catapult.randomBytes(20)).hex(),
sha3_256.create().update(Crypto.randomBytes(20)).hex(),
account2.address,
NetworkType.MIJIN_TEST,
);
Expand Down Expand Up @@ -1062,7 +1062,7 @@ describe('TransactionHttp', () => {
NetworkCurrencyMosaic.createAbsolute(10),
UInt64.fromUint(100),
HashType.Op_Keccak_256,
sha3_256.create().update(nacl_catapult.randomBytes(20)).hex(),
sha3_256.create().update(Crypto.randomBytes(20)).hex(),
account2.address,
NetworkType.MIJIN_TEST,
);
Expand Down Expand Up @@ -1092,7 +1092,7 @@ describe('TransactionHttp', () => {
NetworkCurrencyMosaic.createAbsolute(10),
UInt64.fromUint(100),
HashType.Op_Keccak_256,
sha3_256.create().update(nacl_catapult.randomBytes(20)).hex(),
sha3_256.create().update(Crypto.randomBytes(20)).hex(),
account2.address,
NetworkType.MIJIN_TEST,
);
Expand Down Expand Up @@ -1121,7 +1121,7 @@ describe('TransactionHttp', () => {
return listener.close();
});
it('standalone', (done) => {
const secretSeed = String.fromCharCode.apply(null, nacl_catapult.randomBytes(20));
const secretSeed = String.fromCharCode.apply(null, Crypto.randomBytes(20));
const secret = CryptoJS.RIPEMD160(CryptoJS.SHA256(secretSeed).toString(CryptoJS.enc.Hex)).toString(CryptoJS.enc.Hex);
const secretLockTransaction = SecretLockTransaction.create(
Deadline.create(),
Expand Down Expand Up @@ -1153,7 +1153,7 @@ describe('TransactionHttp', () => {
return listener.close();
});
it('aggregate', (done) => {
const secretSeed = String.fromCharCode.apply(null, nacl_catapult.randomBytes(20));
const secretSeed = String.fromCharCode.apply(null, Crypto.randomBytes(20));
const secret = CryptoJS.RIPEMD160(CryptoJS.SHA256(secretSeed).toString(CryptoJS.enc.Hex)).toString(CryptoJS.enc.Hex);
const secretLockTransaction = SecretLockTransaction.create(
Deadline.create(),
Expand Down Expand Up @@ -1194,7 +1194,7 @@ describe('TransactionHttp', () => {
NetworkCurrencyMosaic.createAbsolute(10),
UInt64.fromUint(100),
HashType.Op_Hash_256,
sha3_256.create().update(nacl_catapult.randomBytes(20)).hex(),
sha3_256.create().update(Crypto.randomBytes(20)).hex(),
account2.address,
NetworkType.MIJIN_TEST,
);
Expand Down Expand Up @@ -1224,7 +1224,7 @@ describe('TransactionHttp', () => {
NetworkCurrencyMosaic.createAbsolute(10),
UInt64.fromUint(100),
HashType.Op_Hash_256,
sha3_256.create().update(nacl_catapult.randomBytes(20)).hex(),
sha3_256.create().update(Crypto.randomBytes(20)).hex(),
account2.address,
NetworkType.MIJIN_TEST,
);
Expand Down Expand Up @@ -1253,7 +1253,7 @@ describe('TransactionHttp', () => {
return listener.close();
});
it('standalone', (done) => {
const secretSeed = nacl_catapult.randomBytes(20);
const secretSeed = Crypto.randomBytes(20);
const secret = sha3_256.create().update(secretSeed).hex();
const proof = convert.uint8ToHex(secretSeed);

Expand Down Expand Up @@ -1304,7 +1304,7 @@ describe('TransactionHttp', () => {
return listener.close();
});
it('aggregate', (done) => {
const secretSeed = nacl_catapult.randomBytes(20);
const secretSeed = Crypto.randomBytes(20);
const secret = sha3_256.create().update(secretSeed).hex();
const proof = convert.uint8ToHex(secretSeed);
const secretLockTransaction = SecretLockTransaction.create(
Expand Down Expand Up @@ -1352,7 +1352,7 @@ describe('TransactionHttp', () => {
return listener.close();
});
it('standalone', (done) => {
const secretSeed = nacl_catapult.randomBytes(20);
const secretSeed = Crypto.randomBytes(20);
const secret = keccak_256.create().update(secretSeed).hex();
const proof = convert.uint8ToHex(secretSeed);
const secretLockTransaction = SecretLockTransaction.create(
Expand Down Expand Up @@ -1396,7 +1396,7 @@ describe('TransactionHttp', () => {
return listener.close();
});
it('aggregate', (done) => {
const secretSeed = nacl_catapult.randomBytes(20);
const secretSeed = Crypto.randomBytes(20);
const secret = keccak_256.create().update(secretSeed).hex();
const proof = convert.uint8ToHex(secretSeed);
const secretLockTransaction = SecretLockTransaction.create(
Expand Down Expand Up @@ -1704,8 +1704,8 @@ describe('TransactionHttp', () => {
transactionHttp.getTransactionStatus(transactionHash)
.subscribe((transactionStatus) => {
expect(transactionStatus.group).to.be.equal('confirmed');
expect(transactionStatus.height.lower).to.be.greaterThan(0);
expect(transactionStatus.height.higher).to.be.equal(0);
expect(transactionStatus.height!.lower).to.be.greaterThan(0);
expect(transactionStatus.height!.higher).to.be.equal(0);
done();
});
});
Expand All @@ -1716,8 +1716,8 @@ describe('TransactionHttp', () => {
transactionHttp.getTransactionsStatuses([transactionHash])
.subscribe((transactionStatuses) => {
expect(transactionStatuses[0].group).to.be.equal('confirmed');
expect(transactionStatuses[0].height.lower).to.be.greaterThan(0);
expect(transactionStatuses[0].height.higher).to.be.equal(0);
expect(transactionStatuses[0].height!.lower).to.be.greaterThan(0);
expect(transactionStatuses[0].height!.higher).to.be.equal(0);
done();
});
});
Expand Down
2 changes: 2 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ export * from './src/infrastructure/infrastructure';
export * from './src/model/model';
export * from './src/service/service';
export * from './src/core/utils/utility';
export * from './src/core/format';
export * from './src/core/crypto';
Loading