-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2f4fb16
commit ab9ec26
Showing
37 changed files
with
270 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import Config from '../../../config'; | ||
import { ETHStateProvider } from '../../ethereum/api/csp'; | ||
|
||
export { EventLog } from '../../ethereum/api/csp'; | ||
export class RSKStateProvider extends ETHStateProvider { | ||
/* | ||
* Reusing ETHStateProvider class for RSK | ||
* Purpose is to avoid code duplication and reduce maintenance cost | ||
*/ | ||
constructor(public chain: string = 'RSK') { | ||
super(chain); | ||
this.config = Config.chains[this.chain]; | ||
} | ||
|
||
} | ||
|
||
export const RSK = new RSKStateProvider(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { Router } from 'express'; | ||
import logger from '../../../logger'; | ||
import { RSK } from './csp'; | ||
export const RskRoutes = Router(); | ||
|
||
RskRoutes.get('/api/RSK/:network/address/:address/txs/count', async (req, res) => { | ||
let { address, network } = req.params; | ||
try { | ||
const nonce = await RSK.getAccountNonce(network, address); | ||
res.json({ nonce }); | ||
} catch (err) { | ||
logger.error('Nonce Error::' + err); | ||
res.status(500).send(err); | ||
} | ||
}); | ||
|
||
RskRoutes.post('/api/RSK/:network/gas', async (req, res) => { | ||
const { from, to, value, data, gasPrice } = req.body; | ||
const { network } = req.params; | ||
try { | ||
const gasLimit = await RSK.estimateGas({ network, from, to, value, data, gasPrice }); | ||
res.json(gasLimit); | ||
} catch (err) { | ||
res.status(500).send(err); | ||
} | ||
}); | ||
|
||
RskRoutes.get('/api/RSK/:network/token/:tokenAddress', async (req, res) => { | ||
const { network, tokenAddress } = req.params; | ||
try { | ||
const tokenInfo = await RSK.getERC20TokenInfo(network, tokenAddress); | ||
res.json(tokenInfo); | ||
} catch (err) { | ||
res.status(500).send(err); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { BaseModule } from '..'; | ||
import { RSKStateProvider } from './api/csp'; | ||
import { RskRoutes } from './api/rsk-routes'; | ||
import { RskP2pWorker } from './p2p/p2p'; | ||
import { RskVerificationPeer } from './p2p/RskVerificationPeer'; | ||
|
||
export default class RSKModule extends BaseModule { | ||
constructor(services: BaseModule['bitcoreServices']) { | ||
super(services); | ||
services.P2P.register('RSK', RskP2pWorker); | ||
services.CSP.registerService('RSK', new RSKStateProvider('RSK')); | ||
services.Api.app.use(RskRoutes); | ||
services.Verification.register('RSK', RskVerificationPeer); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
packages/bitcore-node/src/modules/rsk/p2p/RskVerificationPeer.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { EthVerificationPeer } from '../../ethereum/p2p/EthVerificationPeer'; | ||
|
||
export class RskVerificationPeer extends EthVerificationPeer { | ||
/* | ||
* Reusing EthVerificationPeer class for RSK | ||
* Purpose is to avoid code duplication and reduce maintenance cost | ||
*/ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { EthP2pWorker } from '../../ethereum/p2p/p2p'; | ||
import { EthBlockStorage } from '../../ethereum/models/block'; | ||
export class RskP2pWorker extends EthP2pWorker { | ||
/* | ||
* Reusing EthP2pWorker class for RSK | ||
* Purpose is to avoid code duplication and reduce maintenance cost | ||
*/ | ||
constructor({ chain, network, chainConfig, blockModel = EthBlockStorage}) { | ||
super({ chain, network, chainConfig, blockModel }); | ||
this.chain = 'RSK'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,6 +51,7 @@ export class BlockchainMonitor { | |
btc: {}, | ||
bch: {}, | ||
eth: {}, | ||
rsk: {}, | ||
xrp: {}, | ||
doge: {}, | ||
ltc: {} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
packages/bitcore-wallet-service/src/lib/chain/rsk/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { EthChain } from '../eth'; | ||
|
||
export class RskChain extends EthChain { | ||
constructor() { | ||
super(); | ||
// Now RSK will inherit EthChain and override this.chain = 'RSK'; | ||
this.chain = 'RSK'; | ||
} | ||
|
||
// Rest of functions will be inherited from EthChain | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.