Skip to content

Commit

Permalink
Merge branch 'feature/transfer' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
khawarizmus committed May 29, 2018
2 parents 22cbdee + fd6f480 commit efcc531
Showing 1 changed file with 64 additions and 0 deletions.
64 changes: 64 additions & 0 deletions src/Apostille.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { IReadyTransaction } from './ReadyTransaction';
import { SHA256 } from './hashFunctions';
import { HashFunction } from './hashFunctions/HashFunction';
import uniqBy = require('lodash/uniqBy');
import drop = require('lodash/drop');

const nem = nemSDK.default;
// TODO: add tx hash of creation
Expand Down Expand Up @@ -181,6 +182,69 @@ class Apostille {
this.transactions.push(readyModification);
}

public transfer(signers: Account[],
complete: boolean,
newOwners: PublicAccount[],
OwnersToRemove: PublicAccount[],
quorumDelta: number,
minRemovalDelta: number,
): void {
// the initiator must be a multisig account
const modifications: MultisigCosignatoryModification[] = [];
newOwners.forEach((cosignatory) => {
modifications.push(
new MultisigCosignatoryModification(
MultisigCosignatoryModificationType.Add,
cosignatory));
});
OwnersToRemove.forEach((cosignatory) => {
modifications.push(
new MultisigCosignatoryModification(
MultisigCosignatoryModificationType.Remove,
cosignatory));
});
const multisigCreation = ModifyMultisigAccountTransaction.create(
Deadline.create(),
quorumDelta,
minRemovalDelta,
modifications,
this.networkType,
);
let initiatorApostille: Initiator;
const cosignatories = drop(signers);
let readyModification: IReadyTransaction;
if (complete) {
// create an incomplete initiator
initiatorApostille = new Initiator(
signers[0],
this.networkType,
this.Apostille.publicAccount,
true,
cosignatories);
// we prepare the ready transaction
readyModification = {
initiator: initiatorApostille,
transaction: multisigCreation,
type: TransactionType.AGGREGATE_COMPLETE,
};
} else {
// create a compleet initiator
initiatorApostille = new Initiator(
signers[0],
this.networkType,
this.Apostille.publicAccount,
false,
cosignatories);
// we prepare the ready transaction
readyModification = {
initiator: initiatorApostille,
transaction: multisigCreation,
type: TransactionType.AGGREGATE_BONDED,
};
}
this.transactions.push(readyModification);
}

public async announce(urls?: string): Promise<void> {
await this.isAnnouced(this);
if (!this.created) {
Expand Down

0 comments on commit efcc531

Please sign in to comment.