How to use the @arkecosystem/crypto.Enums.TransactionTypes function in @arkecosystem/crypto

To help you get started, we’ve selected a few @arkecosystem/crypto examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ArkEcosystem / core / packages / core-jest-matchers / src / transactions / types / multi-payment.ts View on Github external
import { Enums } from "@arkecosystem/crypto";

const { MultiPayment } = Enums.TransactionTypes;

export {};

declare global {
    namespace jest {
        // tslint:disable-next-line:interface-name
        interface Matchers {
            toBeMultiPaymentType(): R;
        }
    }
}

expect.extend({
    toBeMultiPaymentType: received => {
        return {
            message: () => "Expected value to be a valid MultiPayment transaction.",
github ArkEcosystem / core / packages / core-transaction-pool / src / memory.ts View on Github external
private calculateTransactionExpiration(
        transaction: Interfaces.ITransaction,
        context: {
            blockTime: number,
            currentHeight: number,
            now: number,
        }
    ): number {
        if (transaction.type === Enums.TransactionTypes.TimelockTransfer) {
            // tslint:disable-next-line:no-null-keyword
            return null;
        }

        // We ignore data.expiration in v1 transactions because it is not signed
        // by the transaction creator.
        if (transaction.data.version >= 2 && transaction.data.expiration > 0) {
            return transaction.data.expiration;
        }

        // Since the user did not specify an expiration we set one by calculating
        // approximately the height of the chain as of the time the transaction was
        // created and adding maxTransactionAge to that.

        // Both now and transaction.data.timestamp use [number of seconds since the genesis block].
        const createdSecondsAgo: number = context.now - transaction.data.timestamp;
github ArkEcosystem / core / packages / core-jest-matchers / src / transactions / types / second-signature.ts View on Github external
import { Enums } from "@arkecosystem/crypto";

const { SecondSignature } = Enums.TransactionTypes;

export {};

declare global {
    namespace jest {
        // tslint:disable-next-line:interface-name
        interface Matchers {
            toBeSecondSignatureType(): R;
        }
    }
}

expect.extend({
    toBeSecondSignatureType: received => {
        return {
            message: () => "Expected value to be a valid SecondSignature transaction.",
github ArkEcosystem / core / packages / core-jest-matchers / src / transactions / types / multi-signature.ts View on Github external
import { Enums } from "@arkecosystem/crypto";

const { MultiSignature } = Enums.TransactionTypes;

export {};

declare global {
    namespace jest {
        // tslint:disable-next-line:interface-name
        interface Matchers {
            toBeMultiSignatureType(): R;
        }
    }
}

expect.extend({
    toBeMultiSignatureType: received => {
        return {
            message: () => "Expected value to be a valid MultiSignature transaction.",
github ArkEcosystem / core / packages / core-jest-matchers / src / transactions / types / vote.ts View on Github external
import { Enums } from "@arkecosystem/crypto";

const { Vote } = Enums.TransactionTypes;

export {};

declare global {
    namespace jest {
        // tslint:disable-next-line:interface-name
        interface Matchers {
            toBeVoteType(): R;
        }
    }
}

expect.extend({
    toBeVoteType: received => {
        return {
            message: () => "Expected value to be a valid VOTE transaction.",
github ArkEcosystem / core / packages / core-jest-matchers / src / transactions / types / transfer.ts View on Github external
import { Enums } from "@arkecosystem/crypto";

const { Transfer } = Enums.TransactionTypes;

export {};

declare global {
    namespace jest {
        // tslint:disable-next-line:interface-name
        interface Matchers {
            toBeTransferType(): R;
        }
    }
}

expect.extend({
    toBeTransferType: received => {
        return {
            message: () => "Expected value to be a valid Transfer transaction.",
github ArkEcosystem / core / packages / core-state / src / wallets / wallet.ts View on Github external
if (transaction.type === Enums.TransactionTypes.SecondSignature) {
            audit.push({ "Second public key": this.secondPublicKey });
        }

        if (transaction.type === Enums.TransactionTypes.DelegateRegistration) {
            const username = transaction.asset.delegate.username;
            audit.push({ "Current username": this.username });
            audit.push({ "New username": username });
        }

        if (transaction.type === Enums.TransactionTypes.Vote) {
            audit.push({ "Current vote": this.vote });
            audit.push({ "New vote": transaction.asset.votes[0] });
        }

        if (transaction.type === Enums.TransactionTypes.MultiSignature) {
            const keysgroup = transaction.asset.multisignature.keysgroup;
            audit.push({ "Multisignature not yet registered": !this.multisignature });
            audit.push({
                "Multisignature enough keys": keysgroup.length >= transaction.asset.multiSignature.min,
            });
            audit.push({
                "Multisignature all keys signed": keysgroup.length === transaction.signatures.length,
            });
            audit.push({
                "Multisignature verification": this.verifySignatures(transaction, transaction.asset.multiSignature),
            });
        }

        if (transaction.type === Enums.TransactionTypes.Ipfs) {
            audit.push({ IPFS: true });
        }
github ArkEcosystem / core / packages / core-transaction-pool / src / dynamic-fee.ts View on Github external
export const calculateMinimumFee = (satoshiPerByte: number, transaction: Interfaces.ITransaction): Utils.BigNumber => {
    if (satoshiPerByte <= 0) {
        satoshiPerByte = 1;
    }

    const key: string = camelCase(
        transaction.type in Enums.TransactionTypes
            ? Enums.TransactionTypes[transaction.type]
            : transaction.constructor.name.replace("Transaction", ""),
    );

    const addonBytes: number = app.resolveOptions("transaction-pool").dynamicFees.addonBytes[key];
    const transactionSizeInBytes: number = transaction.serialized.length / 2;

    return Utils.BigNumber.make(addonBytes + transactionSizeInBytes).times(satoshiPerByte);
};
github ArkEcosystem / core / packages / core-blockchain / src / replay / replay-blockchain.ts View on Github external
private async processGenesisBlock(): Promise {
        const genesisBlock: Interfaces.IBlock = Blocks.BlockFactory.fromJson(
            Managers.configManager.get("genesisBlock"),
        );

        const { transactions }: Interfaces.IBlock = genesisBlock;
        for (const transaction of transactions) {
            if (transaction.type === Enums.TransactionTypes.Transfer) {
                const recipient: State.IWallet = this.walletManager.findByAddress(transaction.data.recipientId);
                recipient.balance = new Utils.BigNumber(transaction.data.amount);
            }
        }

        for (const transaction of transactions) {
            const sender: State.IWallet = this.walletManager.findByPublicKey(transaction.data.senderPublicKey);
            sender.balance = sender.balance.minus(transaction.data.amount).minus(transaction.data.fee);

            if (transaction.type === Enums.TransactionTypes.DelegateRegistration) {
                sender.username = transaction.data.asset.delegate.username;
                this.walletManager.reindex(sender);
            } else if (transaction.type === Enums.TransactionTypes.Vote) {
                const vote = transaction.data.asset.votes[0];
                sender.vote = vote.slice(1);
            }
github ArkEcosystem / core / packages / core-blockchain / src / replay / replay-blockchain.ts View on Github external
Managers.configManager.get("genesisBlock"),
        );

        const { transactions }: Interfaces.IBlock = genesisBlock;
        for (const transaction of transactions) {
            if (transaction.type === Enums.TransactionTypes.Transfer) {
                const recipient: State.IWallet = this.walletManager.findByAddress(transaction.data.recipientId);
                recipient.balance = new Utils.BigNumber(transaction.data.amount);
            }
        }

        for (const transaction of transactions) {
            const sender: State.IWallet = this.walletManager.findByPublicKey(transaction.data.senderPublicKey);
            sender.balance = sender.balance.minus(transaction.data.amount).minus(transaction.data.fee);

            if (transaction.type === Enums.TransactionTypes.DelegateRegistration) {
                sender.username = transaction.data.asset.delegate.username;
                this.walletManager.reindex(sender);
            } else if (transaction.type === Enums.TransactionTypes.Vote) {
                const vote = transaction.data.asset.votes[0];
                sender.vote = vote.slice(1);
            }
        }

        this.walletManager.buildVoteBalances();

        this.state.setLastBlock(genesisBlock);

        const roundInfo: Shared.IRoundInfo = roundCalculator.calculateRound(1);
        const delegates: State.IDelegateWallet[] = this.walletManager.loadActiveDelegateList(roundInfo);

        (this.localDatabase as any).forgingDelegates = await this.localDatabase.getActiveDelegates(