aboutsummaryrefslogblamecommitdiffstats
path: root/packages/testnet-faucets/src/ts/id_management.ts
blob: db9b610a3eb90c0f4ebb035e5681aba7548a445b (plain) (tree)
1
2
3
4
5
6
7
8
9
                                             
 
                                    
 
                                                           


                                     
                                                    




                                                            
                                          
                                                                                            




                                                            
import EthereumTx = require('ethereumjs-tx');

import { configs } from './configs';

type Callback = (err: Error | null, accounts: any) => void;

export const idManagement = {
    getAccounts(callback: Callback) {
        callback(null, [configs.DISPENSER_ADDRESS]);
    },
    approveTransaction(txData: object, callback: Callback) {
        callback(null, true);
    },
    signTransaction(txData: object, callback: Callback) {
        const tx = new EthereumTx(txData);
        const privateKeyBuffer = new Buffer(configs.DISPENSER_PRIVATE_KEY as string, 'hex');
        tx.sign(privateKeyBuffer);
        const rawTx = `0x${tx.serialize().toString('hex')}`;
        callback(null, rawTx);
    },
};