Skip to content

Commit

Permalink
build: use sdk instead of crypto repo
Browse files Browse the repository at this point in the history
  • Loading branch information
tammo committed Aug 19, 2020
1 parent 6aa4ff8 commit 3e50848
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 139 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"start": "ts-node src/index.ts"
},
"dependencies": {
"@tixl/tixl-crypto": "1.12.2",
"@tixl/tixl-sdk-js": "0.1.8",
"@tixl/tixl-types": "0.6.7",
"@types/node": "13.7.7",
"@types/promise-queue": "2.2.0",
Expand Down
3 changes: 3 additions & 0 deletions src/crypto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { createCrypto } from '@tixl/tixl-sdk-js/node-js';

export const crypto = createCrypto();
9 changes: 6 additions & 3 deletions src/sendFromGenesis.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import Queue from 'promise-queue';
import { AssetSymbol, Block, Signature } from '@tixl/tixl-types';
import { createSendBlock, decryptSender, decryptReceiver } from '@tixl/tixl-crypto';
import { decryptSender, decryptReceiver } from '@tixl/tixl-sdk-js/workflows/api/encryption';
import { createSendBlock } from '@tixl/tixl-sdk-js/workflows/api/send';

import { crypto } from './crypto';
import { sendTx, getBlockchain } from './gateway-helper';
import { networkResult } from './networkResult';
import { log } from './logger';
Expand All @@ -18,8 +20,8 @@ export const sendFromGenesis = async (address: string): Promise<{ sendAmount: bi

if (!genChain || !genLeaf) throw 'no genesis chain found';

await decryptSender(genLeaf, process.env.GEN_AES || '', { forceDecryptBF: true });
await decryptReceiver(genLeaf, process.env.GEN_NTRU_PRIV || '');
await decryptSender(crypto, genLeaf, process.env.GEN_AES || '', { forceDecryptBF: true });
await decryptReceiver(crypto, genLeaf, process.env.GEN_NTRU_PRIV || '');

const baseAmount = Math.floor(Math.random() * 5000000) + 1; // rng between 1..5,000,000
let rndTxl = baseAmount;
Expand All @@ -38,6 +40,7 @@ export const sendFromGenesis = async (address: string): Promise<{ sendAmount: bi
log.info('Current genesis balance', { balance: String(genLeaf.senderBalance) });

const send = await createSendBlock(
crypto,
genChain.leaf() as Block,
genChain.publicSig,
sendAmount,
Expand Down
Loading

0 comments on commit 3e50848

Please sign in to comment.