Skip to content

Commit f102085

Browse files
authored
Notification multisig (#752)
* - Subscribe multisig account from cosigner subscription - Fixed #751 * Lint fix
1 parent 1be3ac2 commit f102085

File tree

8 files changed

+243
-52
lines changed

8 files changed

+243
-52
lines changed

e2e/infrastructure/Listener.spec.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,24 @@ describe('Listener', () => {
376376
});
377377
});
378378

379+
describe('Aggregate Bonded Transactions - multisig other cosigner', () => {
380+
it('aggregateBondedTransactionsAdded', (done) => {
381+
const signedAggregatedTx = createSignedAggregatedBondTransaction(multisigAccount, account, account2.address);
382+
createHashLockTransactionAndAnnounce(signedAggregatedTx, account, helper.networkCurrency);
383+
helper.listener.aggregateBondedAdded(account2.address).subscribe(() => {
384+
done();
385+
});
386+
helper.listener.confirmed(unresolvedAddress).subscribe(() => {
387+
transactionRepository.announceAggregateBonded(signedAggregatedTx);
388+
});
389+
helper.listener.status(unresolvedAddress).subscribe((error) => {
390+
console.log('Error:', error);
391+
assert(false);
392+
done();
393+
});
394+
});
395+
});
396+
379397
describe('MultisigAccountModificationTransaction - Restore multisig Accounts', () => {
380398
it('Restore Multisig Account', () => {
381399
const removeCosigner1 = MultisigAccountModificationTransaction.create(

e2e/infrastructure/TransactionHttp.spec.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ describe('TransactionHttp', () => {
102102
let transactionRepository: TransactionRepository;
103103
let transactionStatusRepository: TransactionStatusRepository;
104104
let votingKey: string;
105-
let votingKeyV1: string;
106105

107106
const remoteAccount = Account.generateNewAccount(helper.networkType);
108107

@@ -117,7 +116,6 @@ describe('TransactionHttp', () => {
117116
generationHash = helper.generationHash;
118117
networkType = helper.networkType;
119118
votingKey = Convert.uint8ToHex(Crypto.randomBytes(32));
120-
votingKeyV1 = Convert.uint8ToHex(Crypto.randomBytes(48));
121119
namespaceRepository = helper.repositoryFactory.createNamespaceRepository();
122120
transactionRepository = helper.repositoryFactory.createTransactionRepository();
123121
transactionStatusRepository = helper.repositoryFactory.createTransactionStatusRepository();

src/infrastructure/IListener.ts

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,11 @@ export interface IListener {
7474
*
7575
* @param unresolvedAddress unresolved address we listen when a transaction is in confirmed state
7676
* @param transactionHash transactionHash for filtering multiple transactions
77+
* @param subscribeMultisig When `true` cosigner's multisig account will also be subscribed to the channel
7778
* @return an observable stream of Transaction with state confirmed
7879
*/
7980

80-
confirmed(unresolvedAddress: UnresolvedAddress, transactionHash?: string): Observable<Transaction>;
81+
confirmed(unresolvedAddress: UnresolvedAddress, transactionHash?: string, subscribeMultisig?: boolean): Observable<Transaction>;
8182

8283
/**
8384
* Returns an observable stream of Transaction for a specific address.
@@ -86,9 +87,10 @@ export interface IListener {
8687
*
8788
* @param unresolvedAddress unresolved address we listen when a transaction is in unconfirmed state
8889
* @param transactionHash transactionHash for filtering multiple transactions
90+
* @param subscribeMultisig When `true` cosigner's multisig account will also be subscribed to the channel
8991
* @return an observable stream of Transaction with state unconfirmed
9092
*/
91-
unconfirmedAdded(unresolvedAddress: UnresolvedAddress, transactionHash?: string): Observable<Transaction>;
93+
unconfirmedAdded(unresolvedAddress: UnresolvedAddress, transactionHash?: string, subscribeMultisig?: boolean): Observable<Transaction>;
9294

9395
/**
9496
* Returns an observable stream of Transaction Hashes for specific address.
@@ -97,9 +99,10 @@ export interface IListener {
9799
*
98100
* @param unresolvedAddress unresolved address we listen when a transaction is removed from unconfirmed state
99101
* @param transactionHash the transaction hash filter.
102+
* @param subscribeMultisig When `true` cosigner's multisig account will also be subscribed to the channel
100103
* @return an observable stream of Strings with the transaction hash
101104
*/
102-
unconfirmedRemoved(unresolvedAddress: UnresolvedAddress, transactionHash?: string): Observable<string>;
105+
unconfirmedRemoved(unresolvedAddress: UnresolvedAddress, transactionHash?: string, subscribeMultisig?: boolean): Observable<string>;
103106

104107
/**
105108
* Return an observable of {@link AggregateTransaction} for specific address.
@@ -108,9 +111,14 @@ export interface IListener {
108111
*
109112
* @param unresolvedAddress unresolved address we listen when a transaction with missing signatures state
110113
* @param transactionHash transactionHash for filtering multiple transactions
114+
* @param subscribeMultisig When `true` cosigner's multisig account will also be subscribed to the channel
111115
* @return an observable stream of AggregateTransaction with missing signatures state
112116
*/
113-
aggregateBondedAdded(unresolvedAddress: UnresolvedAddress, transactionHash?: string): Observable<AggregateTransaction>;
117+
aggregateBondedAdded(
118+
unresolvedAddress: UnresolvedAddress,
119+
transactionHash?: string,
120+
subscribeMultisig?: boolean,
121+
): Observable<AggregateTransaction>;
114122

115123
/**
116124
* Returns an observable stream of Transaction Hashes for specific address.
@@ -119,9 +127,10 @@ export interface IListener {
119127
*
120128
* @param unresolvedAddress unresolved address we listen when a transaction is confirmed or rejected
121129
* @param transactionHash the transaction hash filter.
130+
* @param subscribeMultisig When `true` cosigner's multisig account will also be subscribed to the channel
122131
* @return an observable stream of Strings with the transaction hash
123132
*/
124-
aggregateBondedRemoved(unresolvedAddress: UnresolvedAddress, transactionHash?: string): Observable<string>;
133+
aggregateBondedRemoved(unresolvedAddress: UnresolvedAddress, transactionHash?: string, subscribeMultisig?: boolean): Observable<string>;
125134

126135
/**
127136
* Returns an observable stream of {@link TransactionStatusError} for specific address.
@@ -140,7 +149,8 @@ export interface IListener {
140149
* it emits a new message with the cosignatory signed transaction in the even stream.
141150
*
142151
* @param unresolvedAddress unresolved address we listen when a cosignatory is added to some transaction address sent
152+
* @param subscribeMultisig When `true` cosigner's multisig account will also be subscribed to the channel
143153
* @return an observable stream of {@link CosignatureSignedTransaction}
144154
*/
145-
cosignatureAdded(unresolvedAddress: UnresolvedAddress): Observable<CosignatureSignedTransaction>;
155+
cosignatureAdded(unresolvedAddress: UnresolvedAddress, subscribeMultisig?: boolean): Observable<CosignatureSignedTransaction>;
146156
}

0 commit comments

Comments
 (0)