Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'use strict'
const { TRANSFER } = require('@arkecosystem/crypto').constants
const toBeTransferType = (received) => {
return {
message: () => 'Expected value to be a valid TRANSFER transaction.',
pass: received.type === TRANSFER
}
}
expect.extend({
toBeTransferType
})
'use strict'
const { MULTI_PAYMENT } = require('@arkecosystem/crypto').constants
const toBeMultiPaymentType = (received) => {
return {
message: () => 'Expected value to be a valid MULTI_PAYMENT transaction.',
pass: received.type === MULTI_PAYMENT
}
}
expect.extend({
toBeMultiPaymentType
})
'use strict'
const { VOTE } = require('@arkecosystem/crypto').constants
const toBeVoteType = (received) => {
return {
message: () => 'Expected value to be a valid VOTE transaction.',
pass: received.type === VOTE
}
}
expect.extend({
toBeVoteType
})
'use strict'
const { SECOND_SIGNATURE } = require('@arkecosystem/crypto').constants
const toBeSecondSignatureType = (received) => {
return {
message: () => 'Expected value to be a valid SECOND_SIGNATURE transaction.',
pass: received.type === SECOND_SIGNATURE
}
}
expect.extend({
toBeSecondSignatureType
})
'use strict'
const { TRANSACTION_TYPES } = require('@arkecosystem/crypto').constants
const toBeTimelockTransferType = (received) => {
return {
message: () => 'Expected value to be a valid TIMELOCK_TRANSFER transaction.',
pass: received.type === TRANSACTION_TYPES.TIMELOCK_TRANSFER
}
}
expect.extend({
toBeTimelockTransferType
})
const assert = require('assert')
const { client, crypto } = require('@arkecosystem/crypto')
const { TRANSACTION_TYPES } = require('@arkecosystem/crypto').constants
const config = require('../../config')
const superheroes = require('superheroes')
module.exports = (network, type, testWallet, testAddress, amount = 2, quantity = 10) => {
network = network || 'testnet'
type = type || TRANSACTION_TYPES.TRANSFER
amount = amount * Math.pow(10, 8)
assert.ok(['mainnet', 'devnet', 'testnet'].includes(network), 'Invalid network')
assert.ok([
TRANSACTION_TYPES.TRANSFER,
TRANSACTION_TYPES.SECOND_SIGNATURE,
TRANSACTION_TYPES.DELEGATE_REGISTRATION,
TRANSACTION_TYPES.VOTE
].includes(type), 'Invalid transaction type')
'use strict'
const Promise = require('bluebird')
const { crypto } = require('@arkecosystem/crypto')
const { Wallet } = require('@arkecosystem/crypto').models
const { TRANSACTION_TYPES } = require('@arkecosystem/crypto').constants
const container = require('@arkecosystem/core-container')
const config = container.resolvePlugin('config')
const logger = container.resolvePlugin('logger')
const emitter = container.resolvePlugin('event-emitter')
const map = require('lodash/map')
const genesisWallets = map(config.genesisBlock.transactions, 'senderId')
module.exports = class WalletManager {
/**
* Create a new wallet manager instance.
* @constructor
*/
constructor () {
this.reset()
const { Transaction } = require('@arkecosystem/crypto').models
const { TRANSACTION_TYPES } = require('@arkecosystem/crypto').constants
const container = require('@arkecosystem/core-container')
const logger = container.resolvePlugin('logger')
const config = container.resolvePlugin('config')
module.exports = class SPV {
/**
* Create a new wallet builder instance.
* @param {SequelizeConnection} database
* @return {void}
*/
constructor (database) {
this.connection = database.connection
this.models = database.models
this.walletManager = database.walletManager
this.query = database.query
}
const app = require('@arkecosystem/core-container')
const database = app.resolvePlugin('database')
const dayjs = require('dayjs-ext')
const { slots } = require('@arkecosystem/crypto')
const { TRANSACTION_TYPES } = require('@arkecosystem/crypto').constants
const buildFilterQuery = require('./utils/filter-query')
const Repository = require('./repository')
class TransactionsRepository extends Repository {
/**
* Get all transactions.
* @param {Object} params
* @return {Object}
*/
async findAll(parameters = {}) {
const selectQuery = this.query.select().from(this.query)
const countQuery = this._makeEstimateQuery()
if (parameters.senderId) {
const senderPublicKey = this.__publicKeyFromSenderId(parameters.senderId)
return observer.complete();
}
const epochTime = moment(this._network.epoch).utc().valueOf();
const now = moment().valueOf();
const keys = ArkCrypto.Keys.fromPassphrase(key);
transaction.timestamp = Math.floor((now - epochTime) / 1000);
transaction.senderPublicKey = keys.publicKey;
transaction.signature = null;
transaction.id = null;
const data: ArkCrypto.ITransactionData = {
network: this._network.version,
type: ArkCrypto.constants.TransactionTypes[ArkCrypto.constants.TransactionTypes[transaction.type]],
senderPublicKey: transaction.senderPublicKey,
timestamp: transaction.timestamp,
amount: transaction.amount,
fee: transaction.fee,
vendorField: transaction.vendorField,
recipientId: transaction.recipientId,
asset: transaction.asset
};
data.signature = ArkCrypto.crypto.sign(data, keys);
secondPassphrase = secondKey || secondPassphrase;
if (secondPassphrase) {
const secondKeys = ArkCrypto.Keys.fromPassphrase(secondPassphrase);
data.secondSignature = ArkCrypto.crypto.secondSign(data, secondKeys);