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

bnc-sdk

Package Overview
Dependencies
Maintainers
1
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bnc-sdk - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

195

dist/cjs/index.js

@@ -9,2 +9,51 @@ 'use strict';

function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
function ownKeys(object, enumerableOnly) {
var keys = Object.keys(object);
if (Object.getOwnPropertySymbols) {
var symbols = Object.getOwnPropertySymbols(object);
if (enumerableOnly) symbols = symbols.filter(function (sym) {
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
});
keys.push.apply(keys, symbols);
}
return keys;
}
function _objectSpread2(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i] != null ? arguments[i] : {};
if (i % 2) {
ownKeys(source, true).forEach(function (key) {
_defineProperty(target, key, source[key]);
});
} else if (Object.getOwnPropertyDescriptors) {
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
} else {
ownKeys(source).forEach(function (key) {
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
});
}
}
return target;
}
function validateOptions(options) {

@@ -60,53 +109,4 @@ ow(options, "options", ow.object.exactShape({

function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
var version = "0.1.1";
return obj;
}
function ownKeys(object, enumerableOnly) {
var keys = Object.keys(object);
if (Object.getOwnPropertySymbols) {
var symbols = Object.getOwnPropertySymbols(object);
if (enumerableOnly) symbols = symbols.filter(function (sym) {
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
});
keys.push.apply(keys, symbols);
}
return keys;
}
function _objectSpread2(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i] != null ? arguments[i] : {};
if (i % 2) {
ownKeys(source, true).forEach(function (key) {
_defineProperty(target, key, source[key]);
});
} else if (Object.getOwnPropertyDescriptors) {
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
} else {
ownKeys(source).forEach(function (key) {
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
});
}
}
return target;
}
var version = "0.1.0";
var session = {

@@ -154,2 +154,12 @@ socket: null,

this.listeners[eventCode] = listener;
},
emit: function emit(state) {
if (this.listeners[state.eventCode]) {
this.listeners[state.eventCode](state);
return;
}
if (this.listeners.all) {
this.listeners.all(state);
}
}

@@ -195,3 +205,20 @@ };

}
function serverEcho(eventCode) {
switch (eventCode) {
case "txRequest":
case "nsfFail":
case "txRepeat":
case "txAwaitingApproval":
case "txConfirmReminder":
case "txSendFail":
case "txError":
case "txUnderPriced":
case "txSent":
return true;
default:
return false;
}
}
function sendMessage(msg) {

@@ -206,5 +233,13 @@ session.socket.send(createEventLog(msg));

nodeSyncStatus = _JSON$parse.nodeSyncStatus,
connectionId = _JSON$parse.connectionId; // handle node sync status change
connectionId = _JSON$parse.connectionId;
if (connectionId) {
if (typeof window !== "undefined") {
window.localStorage.setItem("connectionId", connectionId);
} else {
session.connectionId = connectionId;
}
} // handle node sync status change
if (nodeSyncStatus !== undefined && nodeSyncStatus.blockchain === "ethereum" && nodeSyncStatus.network === networkName(session.networkId)) {

@@ -245,4 +280,10 @@ session.status.nodeSynced = nodeSyncStatus.synced;

contractCall: contractCall
});
}); // ignore server echo messages
if (serverEcho(eventCode)) {
return;
} //handle change of hash in speedup and cancel events
if (eventCode === "txSpeedUp" || eventCode === "txCancel") {

@@ -261,9 +302,7 @@ session.transactions = session.transactions.map(function (tx) {

});
var addressListener = addressNotifier && addressNotifier.emitter && (addressNotifier.emitter.listeners[eventCode] || addressNotifier.emitter.listeners.all);
addressListener && addressListener(newState);
addressNotifier && addressNotifier.emitter.emit(newState);
var hashNotifier = session.transactions.find(function (t) {
return t.id === transaction.id || t.hash === transaction.hash;
});
var hashListener = hashNotifier && hashNotifier.emitter && (hashNotifier.emitter.listeners[eventCode] || hashNotifier.emitter.listeners.all);
var emitterResult = hashNotifier ? hashListener && hashListener(newState) : false;
var emitterResult = hashNotifier ? hashNotifier.emitter.emit(newState) : false;
session.transactionListeners && session.transactionListeners.forEach(function (listener) {

@@ -276,10 +315,2 @@ return listener({

}
if (connectionId) {
if (typeof window !== "undefined") {
window.localStorage.setItem("connectionId", connectionId);
} else {
session.connectionId = connectionId;
}
}
}

@@ -304,22 +335,34 @@

emitter: emitter
});
var transaction = {
hash: hash,
id: id || hash,
startTime: startTime,
status: "sent"
};
var newState = _objectSpread2({}, transaction, {
eventCode: eventCode
}); // logEvent to server
sendMessage({
eventCode: eventCode,
categoryCode: "activeTransaction",
transaction: {
hash: hash,
id: id || hash,
startTime: startTime,
status: "sent"
}
transaction: transaction
});
var transactionObj = {
details: {
hash: hash,
startTime: startTime,
eventCode: eventCode
},
details: newState,
emitter: emitter
};
}; // emit after delay to allow for listener to be registered
setTimeout(function () {
var emitterResult = emitter.emit(newState);
session.transactionListeners && session.transactionListeners.forEach(function (listener) {
return listener({
transaction: newState,
emitterResult: emitterResult
});
});
}, 5);
return transactionObj;

@@ -326,0 +369,0 @@ }

@@ -5,2 +5,51 @@ import SturdyWebSocket from 'sturdy-websocket';

function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
function ownKeys(object, enumerableOnly) {
var keys = Object.keys(object);
if (Object.getOwnPropertySymbols) {
var symbols = Object.getOwnPropertySymbols(object);
if (enumerableOnly) symbols = symbols.filter(function (sym) {
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
});
keys.push.apply(keys, symbols);
}
return keys;
}
function _objectSpread2(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i] != null ? arguments[i] : {};
if (i % 2) {
ownKeys(source, true).forEach(function (key) {
_defineProperty(target, key, source[key]);
});
} else if (Object.getOwnPropertyDescriptors) {
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
} else {
ownKeys(source).forEach(function (key) {
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
});
}
}
return target;
}
function validateOptions(options) {

@@ -56,53 +105,4 @@ ow(options, "options", ow.object.exactShape({

function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
var version = "0.1.1";
return obj;
}
function ownKeys(object, enumerableOnly) {
var keys = Object.keys(object);
if (Object.getOwnPropertySymbols) {
var symbols = Object.getOwnPropertySymbols(object);
if (enumerableOnly) symbols = symbols.filter(function (sym) {
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
});
keys.push.apply(keys, symbols);
}
return keys;
}
function _objectSpread2(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i] != null ? arguments[i] : {};
if (i % 2) {
ownKeys(source, true).forEach(function (key) {
_defineProperty(target, key, source[key]);
});
} else if (Object.getOwnPropertyDescriptors) {
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
} else {
ownKeys(source).forEach(function (key) {
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
});
}
}
return target;
}
var version = "0.1.0";
var session = {

@@ -150,2 +150,12 @@ socket: null,

this.listeners[eventCode] = listener;
},
emit: function emit(state) {
if (this.listeners[state.eventCode]) {
this.listeners[state.eventCode](state);
return;
}
if (this.listeners.all) {
this.listeners.all(state);
}
}

@@ -191,3 +201,20 @@ };

}
function serverEcho(eventCode) {
switch (eventCode) {
case "txRequest":
case "nsfFail":
case "txRepeat":
case "txAwaitingApproval":
case "txConfirmReminder":
case "txSendFail":
case "txError":
case "txUnderPriced":
case "txSent":
return true;
default:
return false;
}
}
function sendMessage(msg) {

@@ -202,5 +229,13 @@ session.socket.send(createEventLog(msg));

nodeSyncStatus = _JSON$parse.nodeSyncStatus,
connectionId = _JSON$parse.connectionId; // handle node sync status change
connectionId = _JSON$parse.connectionId;
if (connectionId) {
if (typeof window !== "undefined") {
window.localStorage.setItem("connectionId", connectionId);
} else {
session.connectionId = connectionId;
}
} // handle node sync status change
if (nodeSyncStatus !== undefined && nodeSyncStatus.blockchain === "ethereum" && nodeSyncStatus.network === networkName(session.networkId)) {

@@ -241,4 +276,10 @@ session.status.nodeSynced = nodeSyncStatus.synced;

contractCall: contractCall
});
}); // ignore server echo messages
if (serverEcho(eventCode)) {
return;
} //handle change of hash in speedup and cancel events
if (eventCode === "txSpeedUp" || eventCode === "txCancel") {

@@ -257,9 +298,7 @@ session.transactions = session.transactions.map(function (tx) {

});
var addressListener = addressNotifier && addressNotifier.emitter && (addressNotifier.emitter.listeners[eventCode] || addressNotifier.emitter.listeners.all);
addressListener && addressListener(newState);
addressNotifier && addressNotifier.emitter.emit(newState);
var hashNotifier = session.transactions.find(function (t) {
return t.id === transaction.id || t.hash === transaction.hash;
});
var hashListener = hashNotifier && hashNotifier.emitter && (hashNotifier.emitter.listeners[eventCode] || hashNotifier.emitter.listeners.all);
var emitterResult = hashNotifier ? hashListener && hashListener(newState) : false;
var emitterResult = hashNotifier ? hashNotifier.emitter.emit(newState) : false;
session.transactionListeners && session.transactionListeners.forEach(function (listener) {

@@ -272,10 +311,2 @@ return listener({

}
if (connectionId) {
if (typeof window !== "undefined") {
window.localStorage.setItem("connectionId", connectionId);
} else {
session.connectionId = connectionId;
}
}
}

@@ -300,22 +331,34 @@

emitter: emitter
});
var transaction = {
hash: hash,
id: id || hash,
startTime: startTime,
status: "sent"
};
var newState = _objectSpread2({}, transaction, {
eventCode: eventCode
}); // logEvent to server
sendMessage({
eventCode: eventCode,
categoryCode: "activeTransaction",
transaction: {
hash: hash,
id: id || hash,
startTime: startTime,
status: "sent"
}
transaction: transaction
});
var transactionObj = {
details: {
hash: hash,
startTime: startTime,
eventCode: eventCode
},
details: newState,
emitter: emitter
};
}; // emit after delay to allow for listener to be registered
setTimeout(function () {
var emitterResult = emitter.emit(newState);
session.transactionListeners && session.transactionListeners.forEach(function (listener) {
return listener({
transaction: newState,
emitterResult: emitterResult
});
});
}, 5);
return transactionObj;

@@ -322,0 +365,0 @@ }

{
"name": "bnc-sdk",
"version": "0.1.0",
"version": "0.1.1",
"description": "SDK to connect to the blocknative backend via a websocket connection",

@@ -5,0 +5,0 @@ "main": "dist/cjs/index.js",

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