Skip to content

Commit

Permalink
Merge pull request #103 from blocknative/develop
Browse files Browse the repository at this point in the history
Release 3.1.0
  • Loading branch information
lnbc1QWFyb24 authored Jan 29, 2021
2 parents b9849a2 + ee8486f commit a9301e4
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ A lightweight JavaScript sdk to connect to the Blocknative backend Ethereum node
### Quick Start (client)

```javascript
import blocknativeSdk from 'bnc-sdk'
import BlocknativeSdk from 'bnc-sdk'
import Web3 from 'web3'

const web3 = new Web3(window.ethereum)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bnc-sdk",
"version": "3.0.0",
"version": "3.1.0",
"description": "SDK to connect to the blocknative backend via a websocket connection",
"keywords": [
"ethereum",
Expand Down
10 changes: 8 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ import {
EnhancedConfig
} from './interfaces'

const DEFAULT_NAME = 'unknown'
const DEFAULT_APP_NAME = 'unknown'
const DEFAULT_APP_VERSION = 'unknown'
const DEFAULT_SYSTEM = 'ethereum'

class Blocknative {
Expand All @@ -42,6 +43,8 @@ class Blocknative {
private _dappId: string
private _system: string
private _networkId: number
private _appName: string
private _appVersion: string
private _transactionHandlers: TransactionHandler[]
private _socket: any
private _connected: boolean
Expand Down Expand Up @@ -71,7 +74,8 @@ class Blocknative {
const {
dappId,
system = DEFAULT_SYSTEM,
name = DEFAULT_NAME,
name = DEFAULT_APP_NAME,
appVersion = DEFAULT_APP_VERSION,
networkId,
transactionHandlers = [],
apiUrl,
Expand Down Expand Up @@ -112,6 +116,8 @@ class Blocknative {
this._dappId = dappId
this._system = system
this._networkId = networkId
this._appName = name
this._appVersion = appVersion
this._transactionHandlers = transactionHandlers
this._socket = socket
this._connected = false
Expand Down
1 change: 1 addition & 0 deletions src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ export interface InitializationOptions {
dappId: string
system?: System
name?: string
appVersion?: string
transactionHandlers?: TransactionHandler[]
apiUrl?: string
ws?: any
Expand Down
2 changes: 2 additions & 0 deletions src/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,8 @@ export function createEventLog(this: any, msg: EventObject): string {
timeStamp: new Date().toISOString(),
dappId: this._dappId,
version,
appName: this._appName,
appVersion: this._appVersion,
blockchain: {
system: this._system,
network: networkName(this._system, this._networkId) || 'local'
Expand Down
8 changes: 8 additions & 0 deletions src/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export function validateOptions(options: any): never | void {
dappId,
system,
name,
appVersion,
networkId,
transactionHandlers,
apiUrl,
Expand All @@ -57,6 +58,7 @@ export function validateOptions(options: any): never | void {
'dappId',
'system',
'name',
'appVersion',
'networkId',
'transactionHandlers',
'apiUrl',
Expand All @@ -81,6 +83,12 @@ export function validateOptions(options: any): never | void {
})

validateType({ name: 'name', value: name, type: 'string', optional: true })
validateType({
name: 'appVersion',
value: appVersion,
type: 'string',
optional: true
})
validateType({ name: 'networkId', value: networkId, type: 'number' })

validateType({
Expand Down

0 comments on commit a9301e4

Please sign in to comment.