Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@omisego/omg-js-childchain

Package Overview
Dependencies
Maintainers
6
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@omisego/omg-js-childchain - npm Package Compare versions

Comparing version 4.0.1-1.0.0 to 4.1.0-1.0.4

test/createTransactionTest.js

6

package.json
{
"name": "@omisego/omg-js-childchain",
"version": "4.0.1-1.0.0",
"version": "4.1.0-1.0.4",
"description": "Module to interact with OMG ChildChain",

@@ -31,3 +31,3 @@ "keywords": [

"@hapi/joi": "^16.1.8",
"@omisego/omg-js-util": "4.0.1-1.0.0",
"@omisego/omg-js-util": "4.1.0-1.0.4",
"axios": "^0.19.2",

@@ -48,3 +48,3 @@ "bn.js": "^5.0.0",

},
"gitHead": "90ef46c17bad7b696e3a376010b04831449db06a"
"gitHead": "870385f5fddda54417824339abe3ee6deebbd77f"
}

@@ -22,2 +22,3 @@ /*

getTransactionSchema,
getDepositsSchema,
getExitDataSchema,

@@ -40,2 +41,3 @@ getChallengeDataSchema,

const { transaction, sign, hexPrefix, utxo } = require('@omisego/omg-js-util')
const BN = require('bn.js')
global.Buffer = global.Buffer || require('buffer').Buffer

@@ -48,3 +50,4 @@

* @param {Object} config the childchain configuration object
* @param {string} config.watcherUrl the url of the watcher server (running in security-critical and informational mode)
* @param {string} config.watcherUrl the url of the watcher-info server (running in both security-critical and informational mode)
* @param {string} config.watcherSecurityUrl *optional* the url of the watcher security server. If this is set, all security related endpoints would be using from this url instead.
* @param {string} [config.watcherProxyUrl] *optional* the proxy url for requests made to the watcher server

@@ -55,5 +58,6 @@ * @param {string} config.plasmaContractAddress the address of the PlasmaFramework contract

*/
constructor ({ watcherUrl, watcherProxyUrl, plasmaContractAddress }) {
Joi.assert({ watcherUrl, watcherProxyUrl, plasmaContractAddress }, childchainConstructorSchema)
constructor ({ watcherUrl, watcherProxyUrl, watcherSecurityUrl, plasmaContractAddress }) {
Joi.assert({ watcherUrl, watcherProxyUrl, watcherSecurityUrl, plasmaContractAddress }, childchainConstructorSchema)
this.watcherUrl = watcherUrl
this.watcherSecurityUrl = watcherSecurityUrl || watcherUrl
this.watcherProxyUrl = watcherProxyUrl

@@ -148,2 +152,21 @@ this.plasmaContractAddress = plasmaContractAddress

/**
* Get deposits
*
* @method getDeposits
* @param {Object} filters filter object
* @param {string} [filters.address] address to filter by
* @param {number} [filters.limit] max number of transactions to return
* @param {number} [filters.page] page of paginated request
* @return {Promise<DepositInfo>} promise that resolves with an array of confirmed deposits
*/
async getDeposits (filters) {
Joi.assert(filters, getDepositsSchema)
return rpcApi.post({
url: `${this.watcherUrl}/deposit.all`,
body: filters,
proxyUrl: this.watcherProxyUrl
})
}
/**
* Get the exit data for a UTXO

@@ -159,3 +182,3 @@ *

return rpcApi.post({
url: `${this.watcherUrl}/utxo.get_exit_data`,
url: `${this.watcherSecurityUrl}/utxo.get_exit_data`,
body: { utxo_pos: utxoPos },

@@ -176,3 +199,3 @@ proxyUrl: this.watcherProxyUrl

return rpcApi.post({
url: `${this.watcherUrl}/utxo.get_challenge_data`,
url: `${this.watcherSecurityUrl}/utxo.get_challenge_data`,
body: { utxo_pos: utxoPos },

@@ -201,2 +224,7 @@ proxyUrl: this.watcherProxyUrl

const _payments = payments.map((payment) => ({
...payment,
amount: new BN(payment.amount)
}))
return rpcApi.post({

@@ -206,3 +234,3 @@ url: `${this.watcherUrl}/transaction.create`,

owner,
payments,
payments: _payments,
fee,

@@ -285,3 +313,3 @@ metadata: _metadata

return rpcApi.post({
url: `${this.watcherUrl}/transaction.submit`,
url: `${this.watcherSecurityUrl}/transaction.submit`,
body: { transaction: transaction.startsWith('0x') ? transaction : `0x${transaction}` },

@@ -398,3 +426,3 @@ proxyUrl: this.watcherProxyUrl

return rpcApi.post({
url: `${this.watcherUrl}/in_flight_exit.get_input_challenge_data`,
url: `${this.watcherSecurityUrl}/in_flight_exit.get_input_challenge_data`,
body: {

@@ -419,3 +447,3 @@ txbytes: hexPrefix(txbytes),

return rpcApi.post({
url: `${this.watcherUrl}/in_flight_exit.get_output_challenge_data`,
url: `${this.watcherSecurityUrl}/in_flight_exit.get_output_challenge_data`,
body: {

@@ -439,3 +467,3 @@ txbytes: hexPrefix(txbytes),

return rpcApi.post({
url: `${this.watcherUrl}/in_flight_exit.get_data`,
url: `${this.watcherSecurityUrl}/in_flight_exit.get_data`,
body: { txbytes: hexPrefix(txbytes) },

@@ -452,7 +480,7 @@ proxyUrl: this.watcherProxyUrl

* @return {Promise<Object>} promise that resolves with a competitor to the in-flight transaction
*/
*/
async inFlightExitGetCompetitor (txbytes) {
Joi.assert(txbytes, Joi.string().required())
return rpcApi.post({
url: `${this.watcherUrl}/in_flight_exit.get_competitor`,
url: `${this.watcherSecurityUrl}/in_flight_exit.get_competitor`,
body: { txbytes: hexPrefix(txbytes) },

@@ -473,3 +501,3 @@ proxyUrl: this.watcherProxyUrl

return rpcApi.post({
url: `${this.watcherUrl}/in_flight_exit.prove_canonical`,
url: `${this.watcherSecurityUrl}/in_flight_exit.prove_canonical`,
body: { txbytes: hexPrefix(txbytes) },

@@ -476,0 +504,0 @@ proxyUrl: this.watcherProxyUrl

@@ -14,2 +14,3 @@ const Joi = require('@hapi/joi')

watcherProxyUrl: Joi.string().allow(''),
watcherSecurityUrl: Joi.string().allow(''),
plasmaContractAddress: validateAddress.required()

@@ -34,2 +35,8 @@ })

const getDepositsSchema = Joi.object({
address: validateAddress,
limit: Joi.number().integer(),
page: Joi.number().integer()
})
const getExitDataSchema = Joi.object({

@@ -104,2 +111,3 @@ blknum: validateAmount,

getTransactionSchema,
getDepositsSchema,
getExitDataSchema,

@@ -106,0 +114,0 @@ getChallengeDataSchema,

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc