How to use the @arkecosystem/crypto.Managers.configManager 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-state / src / stores / state.ts View on Github external
public setLastBlock(block: Interfaces.IBlock): void {
        // Only keep blocks which are below the new block height (i.e. rollback)
        if (this.lastBlocks.last() && this.lastBlocks.last().data.height !== block.data.height - 1) {
            assert(block.data.height - 1 <= this.lastBlocks.last().data.height);
            this.lastBlocks = this.lastBlocks.filter(b => b.data.height < block.data.height);
        }

        this.lastBlocks = this.lastBlocks.set(block.data.height, block);

        Managers.configManager.setHeight(block.data.height);

        if (Managers.configManager.isNewMilestone()) {
            app.resolvePlugin("event-emitter").emit("internal.milestone.changed");
        }

        Transactions.TransactionRegistry.updateStaticFees(block.data.height);

        // Delete oldest block if size exceeds the maximum
        if (this.lastBlocks.size > app.resolveOptions("state").storage.maxLastBlocks) {
            this.lastBlocks = this.lastBlocks.delete(this.lastBlocks.first().data.height);
        }
    }
github ArkEcosystem / core / __tests__ / functional / transaction-forging / __support__ / index.ts View on Github external
export const injectMilestone = (index: number, milestone: Record): void => {
    (Managers.configManager as any).milestones.splice(
        index,
        0,
        Object.assign(cloneDeep(Managers.configManager.getMilestone()), milestone),
    );
};
github ArkEcosystem / core / packages / core-tester-cli / src / commands / make / block.ts View on Github external
public async run(): Promise {
        const { flags } = this.makeOffline(BlockCommand);

        const genesisBlock = Managers.configManager.get("genesisBlock");
        const genesisWallets = genesisBlock.transactions.map(t => t.recipientId).filter(a => !!a);

        let previousBlock = flags.previousBlock ? JSON.parse(flags.previousBlock) : genesisBlock;

        const blocks: Interfaces.IBlockJson[] = [];

        for (let i = 0; i < flags.number; i++) {
            const milestone = Managers.configManager.getMilestone(previousBlock.height);
            const delegate = new Delegate(flags.passphrase, Managers.configManager.get("network.pubKeyHash"));

            const transactions = [];
            for (let i = 0; i < flags.transactions; i++) {
                transactions.push(
                    this.signer.makeTransfer({
                        ...flags,
                        ...{
github ArkEcosystem / desktop-wallet / __tests__ / unit / services / transaction.spec.js View on Github external
beforeEach(() => {
      Managers.configManager.getMilestone().aip11 = true
      transaction = Transactions.BuilderFactory
        .multiSignature()
        .multiSignatureAsset({
          min: 1,
          publicKeys: [
            Identities.PublicKey.fromPassphrase(passphrase)
          ]
        })
        .sign('passphrase')
        .fee(1)
    })
github ArkEcosystem / core / __tests__ / integration / core-api / utils.ts View on Github external
public async createTransaction() {
        Managers.configManager.setConfig(Managers.NetworkManager.findByName("testnet"));

        const transaction = TransactionFactory.transfer("AZFEPTWnn2Sn8wDZgCRF8ohwKkrmk2AZi1", 100000000, "test")
            .withPassphrase("clay harbor enemy utility margin pretty hub comic piece aerobic umbrella acquire")
            .createOne()

        await httpie.post("http://127.0.0.1:4003/api/transactions", {
            body: {
                transactions: [transaction],
            },
            headers: { "Content-Type": "application/json" },
        });

        return transaction;
    }
}
github ArkEcosystem / core / packages / core-transactions / src / handlers / transfer.ts View on Github external
public canEnterTransactionPool(
        data: Interfaces.ITransactionData,
        pool: TransactionPool.IConnection,
        processor: TransactionPool.IProcessor,
    ): boolean {
        if (!isRecipientOnActiveNetwork(data)) {
            processor.pushError(
                data,
                "ERR_INVALID_RECIPIENT",
                `Recipient ${data.recipientId} is not on the same network: ${Managers.configManager.get(
                    "network.pubKeyHash",
                )}`,
            );
            return false;
        }

        return true;
    }
github ArkEcosystem / core / packages / core-api / src / handlers / node / controller.ts View on Github external
public async configurationCrypto() {
        try {
            return {
                data: Managers.configManager.getPreset(this.config.get("network").name),
            };
        } catch (error) {
            return Boom.badImplementation(error);
        }
    }
github ArkEcosystem / core / packages / core-forger / src / manager.ts View on Github external
public async forgeNewBlock(
        delegate: Delegate,
        round: P2P.ICurrentRound,
        networkState: P2P.INetworkState,
    ): Promise {
        Managers.configManager.setHeight(networkState.nodeHeight);

        const transactions: Interfaces.ITransactionData[] = await this.getTransactionsForForging();

        const block: Interfaces.IBlock = delegate.forge(transactions, {
            previousBlock: {
                id: networkState.lastBlockId,
                idHex: Managers.configManager.getMilestone().block.idFullSha256
                    ? networkState.lastBlockId
                    : Blocks.Block.toBytesHex(networkState.lastBlockId),
                height: networkState.nodeHeight,
            },
            timestamp: round.timestamp,
            reward: round.reward,
        });

        const minimumMs: number = 2000;
github ArkEcosystem / core / packages / core-transaction-pool / src / utils.ts View on Github external
export function isRecipientOnActiveNetwork(transaction: Interfaces.ITransactionData): boolean {
    const recipientPrefix = bs58check.decode(transaction.recipientId).readUInt8(0);

    if (recipientPrefix === Managers.configManager.get("network.pubKeyHash")) {
        return true;
    }

    app.resolvePlugin("logger").error(
        `Recipient ${transaction.recipientId} is not on the same network: ${Managers.configManager.get(
            "network.pubKeyHash",
        )}`,
    );

    return false;
}
github ArkEcosystem / core / packages / core-container / src / config / index.ts View on Github external
private configureCrypto(value: any): void {
        Managers.configManager.setConfig(value);

        this.config.network = Managers.configManager.get("network");
        this.config.exceptions = Managers.configManager.get("exceptions");
        this.config.milestones = Managers.configManager.get("milestones");
        this.config.genesisBlock = Managers.configManager.get("genesisBlock");
    }