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
13 changes: 11 additions & 2 deletions src/model/transaction/AccountAddressRestrictionTransaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ export class AccountAddressRestrictionTransaction extends Transaction {
* @param restrictionDeletions - Account restriction deletions.
* @param networkType - The network type.
* @param maxFee - (Optional) Max fee defined by the sender
* @param signature - (Optional) Transaction signature
* @param signer - (Optional) Signer public account
* @returns {AccountAddressRestrictionTransaction}
*/
public static create(
Expand All @@ -59,6 +61,8 @@ export class AccountAddressRestrictionTransaction extends Transaction {
restrictionDeletions: (Address | NamespaceId)[],
networkType: NetworkType,
maxFee: UInt64 = new UInt64([0, 0]),
signature?: string,
signer?: PublicAccount,
): AccountAddressRestrictionTransaction {
return new AccountAddressRestrictionTransaction(
networkType,
Expand All @@ -68,6 +72,8 @@ export class AccountAddressRestrictionTransaction extends Transaction {
restrictionFlags,
restrictionAdditions,
restrictionDeletions,
signature,
signer,
);
}

Expand Down Expand Up @@ -110,6 +116,7 @@ export class AccountAddressRestrictionTransaction extends Transaction {
: AccountAddressRestrictionTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload));
const signerPublicKey = Convert.uint8ToHex(builder.getSignerPublicKey().key);
const networkType = builder.getNetwork().valueOf();
const signature = payload.substring(16, 144);
const transaction = AccountAddressRestrictionTransaction.create(
isEmbedded
? Deadline.create()
Expand All @@ -123,6 +130,8 @@ export class AccountAddressRestrictionTransaction extends Transaction {
}),
networkType,
isEmbedded ? new UInt64([0, 0]) : new UInt64((builder as AccountAddressRestrictionTransactionBuilder).fee.amount),
isEmbedded || signature.match(`^[0]+$`) ? undefined : signature,
signerPublicKey.match(`^[0]+$`) ? undefined : PublicAccount.createFromPublicKey(signerPublicKey, networkType),
);
return isEmbedded ? transaction.toAggregate(PublicAccount.createFromPublicKey(signerPublicKey, networkType)) : transaction;
}
Expand Down Expand Up @@ -160,8 +169,8 @@ export class AccountAddressRestrictionTransaction extends Transaction {
* @returns {Uint8Array}
*/
protected generateBytes(): Uint8Array {
const signerBuffer = new Uint8Array(32);
const signatureBuffer = new Uint8Array(64);
const signerBuffer = this.signer !== undefined ? Convert.hexToUint8(this.signer.publicKey) : new Uint8Array(32);
const signatureBuffer = this.signature !== undefined ? Convert.hexToUint8(this.signature) : new Uint8Array(64);

const transactionBuilder = new AccountAddressRestrictionTransactionBuilder(
new SignatureDto(signatureBuffer),
Expand Down
13 changes: 11 additions & 2 deletions src/model/transaction/AccountKeyLinkTransaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ export class AccountKeyLinkTransaction extends Transaction {
* @param remotePublicKey - The public key of the remote account.
* @param linkAction - The account link action.
* @param maxFee - (Optional) Max fee defined by the sender
* @param signature - (Optional) Transaction signature
* @param signer - (Optional) Signer public account
* @returns {AccountLinkTransaction}
*/
public static create(
Expand All @@ -54,6 +56,8 @@ export class AccountKeyLinkTransaction extends Transaction {
linkAction: LinkAction,
networkType: NetworkType,
maxFee: UInt64 = new UInt64([0, 0]),
signature?: string,
signer?: PublicAccount,
): AccountKeyLinkTransaction {
return new AccountKeyLinkTransaction(
networkType,
Expand All @@ -62,6 +66,8 @@ export class AccountKeyLinkTransaction extends Transaction {
maxFee,
remotePublicKey,
linkAction,
signature,
signer,
);
}

Expand Down Expand Up @@ -108,12 +114,15 @@ export class AccountKeyLinkTransaction extends Transaction {
: AccountKeyLinkTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload));
const signerPublicKey = Convert.uint8ToHex(builder.getSignerPublicKey().key);
const networkType = builder.getNetwork().valueOf();
const signature = payload.substring(16, 144);
const transaction = AccountKeyLinkTransaction.create(
isEmbedded ? Deadline.create() : Deadline.createFromDTO((builder as AccountKeyLinkTransactionBuilder).getDeadline().timestamp),
Convert.uint8ToHex(builder.getRemotePublicKey().key),
builder.getLinkAction().valueOf(),
networkType,
isEmbedded ? new UInt64([0, 0]) : new UInt64((builder as AccountKeyLinkTransactionBuilder).fee.amount),
isEmbedded || signature.match(`^[0]+$`) ? undefined : signature,
signerPublicKey.match(`^[0]+$`) ? undefined : PublicAccount.createFromPublicKey(signerPublicKey, networkType),
);
return isEmbedded ? transaction.toAggregate(PublicAccount.createFromPublicKey(signerPublicKey, networkType)) : transaction;
}
Expand All @@ -139,8 +148,8 @@ export class AccountKeyLinkTransaction extends Transaction {
* @returns {Uint8Array}
*/
protected generateBytes(): Uint8Array {
const signerBuffer = new Uint8Array(32);
const signatureBuffer = new Uint8Array(64);
const signerBuffer = this.signer !== undefined ? Convert.hexToUint8(this.signer.publicKey) : new Uint8Array(32);
const signatureBuffer = this.signature !== undefined ? Convert.hexToUint8(this.signature) : new Uint8Array(64);

const transactionBuilder = new AccountKeyLinkTransactionBuilder(
new SignatureDto(signatureBuffer),
Expand Down
13 changes: 11 additions & 2 deletions src/model/transaction/AccountMetadataTransaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ export class AccountMetadataTransaction extends Transaction {
* You can calculate value as xor(previous-value, new-value).
* If there is no previous value, use directly the new value.
* @param maxFee - (Optional) Max fee defined by the sender
* @param signature - (Optional) Transaction signature
* @param signer - (Optional) Signer public account
* @returns {AccountMetadataTransaction}
*/
public static create(
Expand All @@ -59,6 +61,8 @@ export class AccountMetadataTransaction extends Transaction {
value: string,
networkType: NetworkType,
maxFee: UInt64 = new UInt64([0, 0]),
signature?: string,
signer?: PublicAccount,
): AccountMetadataTransaction {
return new AccountMetadataTransaction(
networkType,
Expand All @@ -69,6 +73,8 @@ export class AccountMetadataTransaction extends Transaction {
scopedMetadataKey,
valueSizeDelta,
value,
signature,
signer,
);
}

Expand Down Expand Up @@ -126,6 +132,7 @@ export class AccountMetadataTransaction extends Transaction {
: AccountMetadataTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload));
const signerPublicKey = Convert.uint8ToHex(builder.getSignerPublicKey().key);
const networkType = builder.getNetwork().valueOf();
const signature = payload.substring(16, 144);
const transaction = AccountMetadataTransaction.create(
isEmbedded ? Deadline.create() : Deadline.createFromDTO((builder as AccountMetadataTransactionBuilder).getDeadline().timestamp),
Convert.uint8ToHex(builder.getTargetPublicKey().key),
Expand All @@ -134,6 +141,8 @@ export class AccountMetadataTransaction extends Transaction {
Convert.uint8ToUtf8(builder.getValue()),
networkType,
isEmbedded ? new UInt64([0, 0]) : new UInt64((builder as AccountMetadataTransactionBuilder).fee.amount),
isEmbedded || signature.match(`^[0]+$`) ? undefined : signature,
signerPublicKey.match(`^[0]+$`) ? undefined : PublicAccount.createFromPublicKey(signerPublicKey, networkType),
);
return isEmbedded ? transaction.toAggregate(PublicAccount.createFromPublicKey(signerPublicKey, networkType)) : transaction;
}
Expand Down Expand Up @@ -161,8 +170,8 @@ export class AccountMetadataTransaction extends Transaction {
* @returns {Uint8Array}
*/
protected generateBytes(): Uint8Array {
const signerBuffer = new Uint8Array(32);
const signatureBuffer = new Uint8Array(64);
const signerBuffer = this.signer !== undefined ? Convert.hexToUint8(this.signer.publicKey) : new Uint8Array(32);
const signatureBuffer = this.signature !== undefined ? Convert.hexToUint8(this.signature) : new Uint8Array(64);

const transactionBuilder = new AccountMetadataTransactionBuilder(
new SignatureDto(signatureBuffer),
Expand Down
13 changes: 11 additions & 2 deletions src/model/transaction/AccountMosaicRestrictionTransaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ export class AccountMosaicRestrictionTransaction extends Transaction {
* @param restrictionDeletions - Account restriction deletions.
* @param networkType - The network type.
* @param maxFee - (Optional) Max fee defined by the sender
* @param signature - (Optional) Transaction signature
* @param signer - (Optional) Signer public account
* @returns {AccountAddressRestrictionTransaction}
*/
public static create(
Expand All @@ -59,6 +61,8 @@ export class AccountMosaicRestrictionTransaction extends Transaction {
restrictionDeletions: (MosaicId | NamespaceId)[],
networkType: NetworkType,
maxFee: UInt64 = new UInt64([0, 0]),
signature?: string,
signer?: PublicAccount,
): AccountMosaicRestrictionTransaction {
return new AccountMosaicRestrictionTransaction(
networkType,
Expand All @@ -68,6 +72,8 @@ export class AccountMosaicRestrictionTransaction extends Transaction {
restrictionFlags,
restrictionAdditions,
restrictionDeletions,
signature,
signer,
);
}

Expand Down Expand Up @@ -110,6 +116,7 @@ export class AccountMosaicRestrictionTransaction extends Transaction {
: AccountMosaicRestrictionTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload));
const signerPublicKey = Convert.uint8ToHex(builder.getSignerPublicKey().key);
const networkType = builder.getNetwork().valueOf();
const signature = payload.substring(16, 144);
const transaction = AccountMosaicRestrictionTransaction.create(
isEmbedded
? Deadline.create()
Expand All @@ -123,6 +130,8 @@ export class AccountMosaicRestrictionTransaction extends Transaction {
}),
networkType,
isEmbedded ? new UInt64([0, 0]) : new UInt64((builder as AccountMosaicRestrictionTransactionBuilder).fee.amount),
isEmbedded || signature.match(`^[0]+$`) ? undefined : signature,
signerPublicKey.match(`^[0]+$`) ? undefined : PublicAccount.createFromPublicKey(signerPublicKey, networkType),
);
return isEmbedded ? transaction.toAggregate(PublicAccount.createFromPublicKey(signerPublicKey, networkType)) : transaction;
}
Expand Down Expand Up @@ -160,8 +169,8 @@ export class AccountMosaicRestrictionTransaction extends Transaction {
* @returns {Uint8Array}
*/
protected generateBytes(): Uint8Array {
const signerBuffer = new Uint8Array(32);
const signatureBuffer = new Uint8Array(64);
const signerBuffer = this.signer !== undefined ? Convert.hexToUint8(this.signer.publicKey) : new Uint8Array(32);
const signatureBuffer = this.signature !== undefined ? Convert.hexToUint8(this.signature) : new Uint8Array(64);

const transactionBuilder = new AccountMosaicRestrictionTransactionBuilder(
new SignatureDto(signatureBuffer),
Expand Down
13 changes: 11 additions & 2 deletions src/model/transaction/AccountOperationRestrictionTransaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ export class AccountOperationRestrictionTransaction extends Transaction {
* @param restrictionDeletions - Account restriction deletions.
* @param networkType - The network type.
* @param maxFee - (Optional) Max fee defined by the sender
* @param signature - (Optional) Transaction signature
* @param signer - (Optional) Signer public account
* @returns {AccountOperationRestrictionTransaction}
*/
public static create(
Expand All @@ -53,6 +55,8 @@ export class AccountOperationRestrictionTransaction extends Transaction {
restrictionDeletions: TransactionType[],
networkType: NetworkType,
maxFee: UInt64 = new UInt64([0, 0]),
signature?: string,
signer?: PublicAccount,
): AccountOperationRestrictionTransaction {
return new AccountOperationRestrictionTransaction(
networkType,
Expand All @@ -62,6 +66,8 @@ export class AccountOperationRestrictionTransaction extends Transaction {
restrictionFlags,
restrictionAdditions,
restrictionDeletions,
signature,
signer,
);
}

Expand Down Expand Up @@ -104,6 +110,7 @@ export class AccountOperationRestrictionTransaction extends Transaction {
: AccountOperationRestrictionTransactionBuilder.loadFromBinary(Convert.hexToUint8(payload));
const signer = Convert.uint8ToHex(builder.getSignerPublicKey().key);
const networkType = builder.getNetwork().valueOf();
const signature = payload.substring(16, 144);
const transaction = AccountOperationRestrictionTransaction.create(
isEmbedded
? Deadline.create()
Expand All @@ -113,6 +120,8 @@ export class AccountOperationRestrictionTransaction extends Transaction {
builder.getRestrictionDeletions(),
networkType,
isEmbedded ? new UInt64([0, 0]) : new UInt64((builder as AccountOperationRestrictionTransactionBuilder).fee.amount),
isEmbedded || signature.match(`^[0]+$`) ? undefined : signature,
signer.match(`^[0]+$`) ? undefined : PublicAccount.createFromPublicKey(signer, networkType),
);
return isEmbedded ? transaction.toAggregate(PublicAccount.createFromPublicKey(signer, networkType)) : transaction;
}
Expand Down Expand Up @@ -150,8 +159,8 @@ export class AccountOperationRestrictionTransaction extends Transaction {
* @returns {Uint8Array}
*/
protected generateBytes(): Uint8Array {
const signerBuffer = new Uint8Array(32);
const signatureBuffer = new Uint8Array(64);
const signerBuffer = this.signer !== undefined ? Convert.hexToUint8(this.signer.publicKey) : new Uint8Array(32);
const signatureBuffer = this.signature !== undefined ? Convert.hexToUint8(this.signature) : new Uint8Array(64);

const transactionBuilder = new AccountOperationRestrictionTransactionBuilder(
new SignatureDto(signatureBuffer),
Expand Down
19 changes: 19 additions & 0 deletions src/model/transaction/AccountRestrictionTransaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { AccountMosaicRestrictionTransaction } from './AccountMosaicRestrictionT
import { AccountOperationRestrictionTransaction } from './AccountOperationRestrictionTransaction';
import { Deadline } from './Deadline';
import { TransactionType } from './TransactionType';
import { PublicAccount } from '../account/PublicAccount';

export class AccountRestrictionTransaction {
/**
Expand All @@ -35,6 +36,8 @@ export class AccountRestrictionTransaction {
* @param restrictionDeletions - Account restriction deletions.
* @param networkType - The network type.
* @param maxFee - (Optional) Max fee defined by the sender
* @param signature - (Optional) Transaction signature
* @param signer - (Optional) Signer public account
* @returns {AccountAddressRestrictionTransaction}
*/
public static createAddressRestrictionModificationTransaction(
Expand All @@ -44,6 +47,8 @@ export class AccountRestrictionTransaction {
restrictionDeletions: (Address | NamespaceId)[],
networkType: NetworkType,
maxFee: UInt64 = new UInt64([0, 0]),
signature?: string,
signer?: PublicAccount,
): AccountAddressRestrictionTransaction {
if (
![
Expand All @@ -62,6 +67,8 @@ export class AccountRestrictionTransaction {
restrictionDeletions,
networkType,
maxFee,
signature,
signer,
);
}

Expand All @@ -73,6 +80,8 @@ export class AccountRestrictionTransaction {
* @param restrictionDeletions - Account restriction deletions.
* @param networkType - The network type.
* @param maxFee - (Optional) Max fee defined by the sender
* @param signature - (Optional) Transaction signature
* @param signer - (Optional) Signer public account
* @returns {AccountMosaicRestrictionTransaction}
*/
public static createMosaicRestrictionModificationTransaction(
Expand All @@ -82,6 +91,8 @@ export class AccountRestrictionTransaction {
restrictionDeletions: (MosaicId | NamespaceId)[],
networkType: NetworkType,
maxFee: UInt64 = new UInt64([0, 0]),
signature?: string,
signer?: PublicAccount,
): AccountMosaicRestrictionTransaction {
if (![AccountRestrictionFlags.AllowMosaic, AccountRestrictionFlags.BlockMosaic].includes(restrictionFlags)) {
throw new Error('Restriction type is not allowed.');
Expand All @@ -93,6 +104,8 @@ export class AccountRestrictionTransaction {
restrictionDeletions,
networkType,
maxFee,
signature,
signer,
);
}

Expand All @@ -104,6 +117,8 @@ export class AccountRestrictionTransaction {
* @param restrictionDeletions - Account restriction deletions.
* @param networkType - The network type.
* @param maxFee - (Optional) Max fee defined by the sender
* @param signature - (Optional) Transaction signature
* @param signer - (Optional) Signer public account
* @returns {AccountOperationRestrictionTransaction}
*/
public static createOperationRestrictionModificationTransaction(
Expand All @@ -113,6 +128,8 @@ export class AccountRestrictionTransaction {
restrictionDeletions: TransactionType[],
networkType: NetworkType,
maxFee: UInt64 = new UInt64([0, 0]),
signature?: string,
signer?: PublicAccount,
): AccountOperationRestrictionTransaction {
if (
![AccountRestrictionFlags.AllowOutgoingTransactionType, AccountRestrictionFlags.BlockOutgoingTransactionType].includes(
Expand All @@ -128,6 +145,8 @@ export class AccountRestrictionTransaction {
restrictionDeletions,
networkType,
maxFee,
signature,
signer,
);
}
}
Loading