Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ with the NEM2 (a.k.a Catapult)

## Important Notes

### _Elephant Network Compatibility (catapult-server@0.5.0.1)
### _Elephant_ Network Compatibility (catapult-server@0.5.0.1)

Due to a network upgrade with [catapult-server@elephant](https://github.com/nemtech/catapult-server/releases/tag/v0.5.0.1) version, **it is recommended to use this package's 0.13.0 version and upwards to use this package with Dragon versioned networks**.
Due to a network upgrade with [catapult-server@elephant](https://github.com/nemtech/catapult-server/releases/tag/v0.5.0.1) version, **it is recommended to use this package's 0.13.0 version and upwards to use this package with Elephant versioned networks**.

The upgrade to this package's [version v0.13.0](https://github.com/nemtech/nem2-sdk-typescript-javascript/releases/tag/v0.13.0) is mandatory for **dragon compatibility**.
The upgrade to this package's [version v0.13.0](https://github.com/nemtech/nem2-sdk-typescript-javascript/releases/tag/v0.13.0) is mandatory for **elephant compatibility**.

### _Dragon_ Network Compatibility (catapult-server@0.4.0.1)

Expand Down
63 changes: 63 additions & 0 deletions e2e/infrastructure/TransactionHttp.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {ChronoUnit} from 'js-joda';
import {keccak_256, sha3_256} from 'js-sha3';
import {Crypto} from '../../src/core/crypto';
import { Convert as convert } from '../../src/core/format';
import { TransactionMapping } from '../../src/core/utils/TransactionMapping';
import {AccountHttp} from '../../src/infrastructure/AccountHttp';
import { NamespaceHttp } from '../../src/infrastructure/infrastructure';
import {Listener} from '../../src/infrastructure/Listener';
Expand All @@ -45,6 +46,7 @@ import { AccountRestrictionTransaction } from '../../src/model/transaction/Accou
import { AddressAliasTransaction } from '../../src/model/transaction/AddressAliasTransaction';
import {AggregateTransaction} from '../../src/model/transaction/AggregateTransaction';
import {CosignatureSignedTransaction} from '../../src/model/transaction/CosignatureSignedTransaction';
import { CosignatureTransaction } from '../../src/model/transaction/CosignatureTransaction';
import {Deadline} from '../../src/model/transaction/Deadline';
import { HashLockTransaction } from '../../src/model/transaction/HashLockTransaction';
import {HashType} from '../../src/model/transaction/HashType';
Expand Down Expand Up @@ -1761,6 +1763,67 @@ describe('TransactionHttp', () => {
});
});

describe('SignTransactionGivenSignatures', () => {
let listener: Listener;
before (() => {
listener = new Listener(config.apiUrl);
return listener.open();
});
after(() => {
return listener.close();
});
it('Announce cosign signatures given', (done) => {

/**
* @see https://github.com/nemtech/nem2-sdk-typescript-javascript/issues/112
*/
// AliceAccount: account
// BobAccount: account

const sendAmount = NetworkCurrencyMosaic.createRelative(1000);
const backAmount = NetworkCurrencyMosaic.createRelative(1);

const aliceTransferTransaction = TransferTransaction.create(Deadline.create(), account2.address, [sendAmount],
PlainMessage.create('payout'), NetworkType.MIJIN_TEST);
const bobTransferTransaction = TransferTransaction.create(Deadline.create(), account.address, [backAmount],
PlainMessage.create('payout'), NetworkType.MIJIN_TEST);

// 01. Alice creates the aggregated tx and sign it. Then payload send to Bob
const aggregateTransaction = AggregateTransaction.createComplete(
Deadline.create(),
[
aliceTransferTransaction.toAggregate(account.publicAccount),
bobTransferTransaction.toAggregate(account2.publicAccount),
],
NetworkType.MIJIN_TEST,
[],
);

const aliceSignedTransaction = aggregateTransaction.signWith(account, generationHash);

// 02 Bob cosigns the tx and sends it back to Alice
const signedTxBob = CosignatureTransaction.signTransactionPayload(account2, aliceSignedTransaction.payload, generationHash);

// 03. Alice collects the cosignatures, recreate, sign, and announces the transaction
const cosignatureSignedTransactions = [
new CosignatureSignedTransaction(signedTxBob.parentHash, signedTxBob.signature, signedTxBob.signer),
];
const recreatedTx = TransactionMapping.createFromPayload(aliceSignedTransaction.payload) as AggregateTransaction;

const signedTransaction = recreatedTx.signTransactionGivenSignatures(account, cosignatureSignedTransactions, generationHash);

listener.confirmed(account.address).subscribe(() => {
done();
});
listener.status(account.address).subscribe((error) => {
console.log('Error:', error);
assert(false);
done();
});
transactionHttp.announce(signedTransaction);
});
});

describe('transactions', () => {
it('should call transactions successfully', (done) => {
accountHttp.transactions(account.publicAccount).subscribe((transactions) => {
Expand Down
Loading