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

bnc-sdk

Package Overview
Dependencies
Maintainers
3
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 4.3.0 to 4.4.0

dist/types/src/multichain/index.d.ts

6

dist/types/src/account.d.ts

@@ -1,4 +0,4 @@

import { Emitter } from './interfaces';
import Blocknative from '.';
declare function account(this: Blocknative, address: string): {
import { Emitter } from './types';
import SDK from '.';
declare function account(this: SDK, address: string): {
emitter: Emitter;

@@ -5,0 +5,0 @@ details: {

@@ -1,4 +0,4 @@

import Blocknative from '.';
import { Config, Emitter } from './interfaces';
declare function configuration(this: Blocknative, config: Config): Promise<string | {
import { Config, Emitter } from './types';
import SDK from '.';
declare function configuration(this: SDK, config: Config): Promise<string | {
details: {

@@ -5,0 +5,0 @@ config: Config;

@@ -1,3 +0,4 @@

import { EventObject } from './interfaces';
declare function event(this: any, eventObj: EventObject): void;
import SDK from '.';
import { EventObject } from './types';
declare function event(this: SDK, eventObj: EventObject): void;
export default event;

@@ -1,36 +0,4 @@

/// <reference types="node" />
import { InitializationOptions, Ac, TransactionHandler, EventObject, Tx, Transaction, Account, Event, Unsubscribe, Simulate, Destroy, Configuration, SDKError, LimitRules, EnhancedConfig } from './interfaces';
declare class Blocknative {
protected _storageKey: string;
protected _connectionId: string | undefined;
protected _dappId: string;
protected _system: string;
protected _networkId: number;
protected _appName: string;
protected _appVersion: string;
protected _transactionHandlers: TransactionHandler[];
protected _socket: any;
protected _connected: boolean;
protected _sendMessage: (msg: EventObject) => void;
protected _pingTimeout?: NodeJS.Timeout;
protected _heartbeat?: () => void;
protected _destroyed: boolean;
protected _onerror: ((error: SDKError) => void) | undefined;
protected _queuedMessages: EventObject[];
protected _limitRules: LimitRules;
protected _waitToRetry: null | Promise<void>;
protected _processingQueue: boolean;
protected _processQueue: () => Promise<void>;
transaction: Transaction;
account: Account;
event: Event;
simulate: Simulate;
unsubscribe: Unsubscribe;
destroy: Destroy;
configuration: Configuration;
watchedTransactions: Tx[];
watchedAccounts: Ac[];
configurations: Map<string, EnhancedConfig>;
constructor(options: InitializationOptions);
}
import Blocknative from './sdk';
export * from './types';
export { default as MultichainSDK } from './multichain';
export default Blocknative;

@@ -1,3 +0,4 @@

import { EventObject } from './interfaces';
export declare function sendMessage(this: any, msg: EventObject): void;
import { EventObject } from './types';
import SDK from '.';
export declare function sendMessage(this: SDK, msg: EventObject): void;
export declare function processQueue(this: any): Promise<void>;

@@ -4,0 +5,0 @@ export declare function handleMessage(this: any, msg: {

@@ -1,4 +0,4 @@

import { SimulationTransaction, SimulationTransactionOutput } from './interfaces';
import Blocknative from '.';
declare function simulate(this: Blocknative, system: string, network: string, transaction: SimulationTransaction): Promise<SimulationTransactionOutput>;
import { SimulationTransaction, SimulationTransactionOutput } from './types';
import SDK from '.';
declare function simulate(this: SDK, system: string, network: string, transaction: SimulationTransaction): Promise<SimulationTransactionOutput>;
export default simulate;
import { Subject } from 'rxjs';
import { SimulationTransactionOutput } from './interfaces';
import { SimulationTransactionOutput } from './types';
export declare const simulations$: Subject<SimulationTransactionOutput>;

@@ -1,4 +0,4 @@

import { Emitter } from './interfaces';
import Blocknative from '.';
declare function transaction(this: Blocknative, hash: string, id?: string): {
import { Emitter } from './types';
import SDK from '.';
declare function transaction(this: SDK, hash: string, id?: string): {
details: {

@@ -5,0 +5,0 @@ eventCode: string;

@@ -1,3 +0,3 @@

import Blocknative from '.';
declare function unsubscribe(this: Blocknative, addressOrHash: string): void;
import SDK from '.';
declare function unsubscribe(this: SDK, addressOrHash: string): void;
export default unsubscribe;

@@ -1,2 +0,2 @@

import { Emitter, NotificationObject } from './interfaces';
import { Emitter, NotificationObject } from './types';
export declare function createEmitter(): Emitter;

@@ -3,0 +3,0 @@ export declare function networkName(blockchain: string, id: number): string;

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

@@ -5,0 +5,0 @@ "keywords": [

@@ -135,2 +135,3 @@ # Blocknative sdk

})
```

@@ -168,1 +169,49 @@ #### Address Listener

For detailed documentation head to [docs.blocknative.com](https://docs.blocknative.com/notify-sdk)
## Multichain SDK (experimental new beta API that may break until it is finalized)
For apps that operate on multiple chains at once, you can use the Multichain SDK which provides a simple interface that abstracts away handling multiple WS connections at once and has a new API for subscribing to events.
## Subscribing to events
Currently a transaction hash or account address can be subscribed to for all events. The `subscribe` method requires an `id`, `chainId` and a `type` and returns an `Observable`. The `Observable` that is returned is specific for events on this subscription and on completion or unsubscribing from the observable will automatically unsubscribe within the SDK. Alternatively you can listen on the global transactions `Observable` at `sdk.transactions$`.
```javascript
import { MultichainSDK } from 'bnc-sdk'
const blocknative = new MultichainSDK({ apiKey: '<YOUR_API_KEY>' })
// subscribe to address events
const addressSubscription = blocknative.subscribe({
id: '0x32ee303b76B27A1cd1013DE2eA4513aceB937c72',
chainId: '0x1',
type: 'account'
})
// can listen to the address subscription directly
addressSubscription.subscribe(transaction => console.log(transaction))
// subscribe to transaction events
const transactionSubscription = blocknative.subscribe({
id: '0xbb1af436fd539a6282c6f45ed900abb5ac95ec435367f61fa8815a61bd2a7211',
chainId: '0x1',
type: 'transaction'
})
// can listen to the transaction subscription directly
transactionSubscription.subscribe(transaction => console.log(transaction))
// or can listen for all transaction events on the global transactions$ observable
blocknative.transaction$.subscribe(transaction => console.log(transaction))
```
## Unsubscribing
To stop listening to events on a transaction hash or account address, call the `unsubscribe` method. If called without a `chainId`, all networks will unsubscribe from the transaction or address. To only unsubscribe on a particular network, pass in the `chainId` of that network.
```javascript
blocknative.unsubscribe({
id: 'transactionHashOrAddress',
chainId: '0x1'
})
```

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

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