Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const getPairHistory = (ticker, fiat) => date =>
!date
? 1 // for the test, we make countervalue value 1 at current price
: date > new Date()
? 0 // let's assume we return 0 for future
: 0.0000001 * (Date.now() - date) +
new Prando(`${ticker}-${fiat}`).next(0, 99);
const calculateCounterValue = makeCalculateCounterValue(getPairHistory);
rngSeed?: string | number,
time?: number
) {
ctx.resetTransform()
this.aspectRatio = width / height
// i.e. size 1 = entire width
this.originalScale = width
// i.e. size 1/100 of width
ctx.scale(width, width)
ctx.lineWidth = 0.01
ctx.lineJoin = "round"
ctx.strokeStyle = "black"
ctx.fillStyle = "gray"
this.lineStyle = { cap: "round" }
this.rng = new Prando(rngSeed)
// RNG is pretty poor with similar integer seeds, iterates it 100 times which seems to improve
// will probably replace with better RNG?
this.rng.skip(100)
this.t = time || 0
}
Observable.create(o => {
const rng = new Prando()
const op = genOperation(account, account.operations, account.currency, rng)
op.type = 'OUT'
op.value = t.amount
op.blockHash = null
op.blockHeight = null
op.senders = [account.freshAddress]
op.recipients = [t.recipient]
op.blockHeight = account.blockHeight
op.date = new Date()
broadcasted[account.id] = (broadcasted[account.id] || []).concat(op)
o.next({ type: 'signed' })
o.next({ type: 'broadcasted', operation: { ...op } })
}),
}
function genTokenAccount(
index: number,
account: Account
): $Exact {
const rng = new Prando(account.id + "|" + index);
const tokens = listTokensForCryptoCurrency(account.currency).filter(t =>
hardcodedMarketcap.includes(t.id)
);
const token = rng.nextArrayItem(tokens);
const tokenAccount = {
type: "TokenAccount",
id: account.id + "|" + index,
parentId: account.id,
token,
operationsCount: 0,
operations: [],
pendingOperations: [],
balance: BigNumber(0)
};
const operationsSize = rng.nextInt(1, 200);
export function genAddingOperationsInAccount(
account: Account,
count: number,
seed: number | string
): Account {
const rng = new Prando(seed);
const copy: Account = { ...account };
copy.operations = Array(count)
.fill(null)
.reduce(ops => {
const op = genOperation(copy, copy, ops, rng);
return ops.concat(op);
}, copy.operations);
copy.balance = ensureNoNegative(copy.operations);
return copy;
}
await delay(1000);
if (cancelled) return;
for (let i = 0; i <= 1; i += 0.1) {
o.next({ type: "device-streaming", progress: i });
await delay(300);
}
o.next({ type: "device-signature-requested" });
await delay(2000);
if (cancelled) return;
o.next({ type: "device-signature-granted" });
const rng = new Prando();
const op = genOperation(account, account, account.operations, rng);
op.type = "OUT";
op.value = transaction.amount;
op.blockHash = null;
op.blockHeight = null;
op.senders = [account.freshAddress];
op.recipients = [transaction.recipient];
op.blockHeight = account.blockHeight;
op.date = new Date();
await delay(1000);
if (cancelled) return;
broadcasted[account.id] = (broadcasted[account.id] || []).concat(op);
o.next({
type: "signed",
signedOperation: {
timeout = setTimeout(() => {
const rng = new Prando();
const op = genOperation(account, account, account.operations, rng);
op.type = "OUT";
op.value = t.amount;
op.blockHash = null;
op.blockHeight = null;
op.senders = [account.freshAddress];
op.recipients = [t.recipient];
op.blockHeight = account.blockHeight;
op.date = new Date();
broadcasted[account.id] = (broadcasted[account.id] || []).concat(op);
o.next({ type: "broadcasted", operation: { ...op } });
o.complete();
}, 3000);
}, 3000);
resetRandomNumberGenerator(seed?: number | string) {
this.rng = new Prando(seed)
}
onClick={() => {
this.rng = new Prando(selectedMessage.id);
this.setState(
{
decodedMessage: "",
message: selectedMessage.message,
ra: selectedMessage.ra,
rf: selectedMessage.rf
},
this.decode.bind(this)
);
}}
>
export function genAccount(
id: number | string,
opts: GenAccountOptions = {}
): $Exact {
const rng = new Prando(id);
const currency = opts.currency || rng.nextArrayItem(currencies);
const operationsSize = opts.operationsSize || rng.nextInt(1, 200);
const address = genAddress(currency, rng);
const derivationPath = runDerivationScheme(
getDerivationScheme({ currency, derivationMode: "" }),
currency
);
const freshAddress = { address, derivationPath };
const account: $Exact = {
type: "Account",
id: `mock:1:${currency.id}:${id}:`,
seedIdentifier: "mock",
derivationMode: "",
xpub: genHex(64, rng),
index: 1,