New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@terminal-packages/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

@terminal-packages/sdk - npm Package Compare versions

Comparing version 1.0.14 to 1.0.15

dist/providers/metamask/models/imetamask-options.d.ts

4

CHANGELOG.md

@@ -5,2 +5,5 @@ ## Unreleased [Version 1.0.15]

- feat: pass in projectId
- feat: pass in custom provider headers
### Bug fixes

@@ -34,3 +37,2 @@

## [Version 1.0.10](2019-10-07)

@@ -37,0 +39,0 @@

export { SourceType } from './providers/enums/source-types';
export { Web3Versions } from './providers/enums/web3-versions';
export { ITerminalCustomHttpProviderOptions, } from './providers/http/models/iterminal-custom-http-provider-options';
export { ITerminalHttpProviderOptions, } from './providers/http/models/iterminal-http-provider-options';
export { ITerminalCustomHttpProviderOptions } from './providers/http/models/iterminal-custom-http-provider-options';
export { ITerminalHttpProviderOptions } from './providers/http/models/iterminal-http-provider-options';
export { TerminalHttpProvider } from './providers/http/terminal-http-provider';
export { TerminalWebsocketProvider, } from './providers/websockets/terminal-websockets-provider';
export { TerminalWebsocketProvider } from './providers/websockets/terminal-websockets-provider';
export { EnvironmentTypes } from './shared/enums/environment-types';

@@ -25,3 +25,3 @@ "use strict";

method,
params: params || [],
params: params || []
};

@@ -28,0 +28,0 @@ }

@@ -7,4 +7,5 @@ import { EnvironmentTypes } from '../../../shared/enums/environment-types';

source: SourceType | string;
environment?: EnvironmentTypes;
logLevel?: LogLevel;
projectId?: string | undefined;
environment?: EnvironmentTypes | undefined;
logLevel?: LogLevel | undefined;
}
import { AbstractWeb3Module } from 'web3-core';
import { AbstractMethod } from 'web3-core-method';
import { HttpProvider, WebsocketProvider } from 'web3-providers';
import { HttpProvider, WebsocketProvider, HttpProviderOptions } from 'web3-providers';
import { Web3Versions } from '../enums';

@@ -8,4 +8,6 @@ import { IBaseProviderOptions } from './models/ibase-provider-options';

import { ISendAsyncPayload } from './models/isend-async-payload';
import { IWebsocketProviderOptions } from '../websockets/models/iwebsocket-provider-options';
export declare class TerminalBaseProvider {
private _options;
private _baseOptions;
private _providerOptions?;
connected: boolean;

@@ -17,3 +19,3 @@ host: string;

private _baseProviderOptions;
constructor(_options: IBaseProviderOptions);
constructor(_baseOptions: IBaseProviderOptions, _providerOptions?: HttpProviderOptions | IWebsocketProviderOptions | undefined);
/**

@@ -54,3 +56,3 @@ * Send async jsonrpc method interceptor (backwards compatibility)

*/
protected saveToLogs(payload: ISendAsyncPayload, result: any, responseTimeMs: number | undefined, isError?: boolean, headers?: string): Promise<void>;
protected saveToLogs(payload: ISendAsyncPayload, result: any, responseTimeMs: number | undefined, isError?: boolean): Promise<void>;
/**

@@ -57,0 +59,0 @@ * Parse the jsonrpc result

@@ -19,22 +19,24 @@ "use strict";

class TerminalBaseProvider {
constructor(_options) {
this._options = _options;
constructor(_baseOptions, _providerOptions) {
this._baseOptions = _baseOptions;
this._providerOptions = _providerOptions;
this.connected = false;
if (!this._options.apiKey) {
if (!this._baseOptions.apiKey) {
throw new Error('You must supply an API key to the `Provider`');
}
if (!this._options.source) {
if (!this._baseOptions.source) {
throw new Error('You must supply a source to the `Provider`');
}
if (this._options.environment &&
!environment_types_1.EnvironmentTypes[this._options.environment]) {
if (this._baseOptions.environment &&
!environment_types_1.EnvironmentTypes[this._baseOptions.environment]) {
throw new Error('You must supply a valid environment type of `dev`, `staging` or `live`. Will default to live if no environment is passed in');
}
this._baseProviderOptions = {
source: this._options.source,
apiKey: this._options.apiKey,
logLevel: this._options.logLevel === undefined
source: this._baseOptions.source,
apiKey: this._baseOptions.apiKey,
projectId: this._baseOptions.projectId,
logLevel: this._baseOptions.logLevel === undefined
? log_level_1.LogLevel.Error
: this._options.logLevel,
environment: this._options.environment || environment_types_1.EnvironmentTypes.live,
: this._baseOptions.logLevel,
environment: this._baseOptions.environment || environment_types_1.EnvironmentTypes.live
};

@@ -187,5 +189,5 @@ this._apiService = new api_service_1.ApiService(this._baseProviderOptions.apiKey, this._baseProviderOptions.environment);

params: methods[i].parameters,
result: rpcMethodResponse.result || rpcMethodResponse.error,
result: rpcMethodResponse.result || rpcMethodResponse.error
},
isError: rpcMethodResponse.error !== undefined,
isError: rpcMethodResponse.error !== undefined
});

@@ -239,3 +241,3 @@ }

*/
saveToLogs(payload, result, responseTimeMs, isError = false, headers = '{}') {
saveToLogs(payload, result, responseTimeMs, isError = false) {
return __awaiter(this, void 0, void 0, function* () {

@@ -256,2 +258,6 @@ if (!Array.isArray(payload.params)) {

}
let headers = [];
if (this._providerOptions && this._providerOptions.headers) {
headers = this._providerOptions.headers;
}
const logRequest = {

@@ -268,3 +274,4 @@ id: payload.id,

chainId,
headers
headers: JSON.stringify(headers),
projectId: this._baseProviderOptions.projectId
};

@@ -271,0 +278,0 @@ yield this._apiService.saveToLogs(logRequest);

@@ -5,3 +5,4 @@ export declare enum SourceType {

Alchemy = "Alchemy",
MetaMask = "MetaMask"
MetaMask = "MetaMask",
Infura = "Infura"
}

@@ -9,2 +9,3 @@ "use strict";

SourceType["MetaMask"] = "MetaMask";
SourceType["Infura"] = "Infura";
})(SourceType = exports.SourceType || (exports.SourceType = {}));

@@ -5,3 +5,3 @@ "use strict";

rinkeby: 'https://rinkeby.infura.io/',
mainnet: 'https://mainnet.infura.io/',
mainnet: 'https://mainnet.infura.io/'
};

@@ -85,3 +85,3 @@ "use strict";

disconnect: () => false,
supportsSubscriptions: () => false,
supportsSubscriptions: () => false
};

@@ -88,0 +88,0 @@ }

@@ -6,3 +6,2 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
const environment_types_1 = require("../../shared/enums/environment-types");
const window_1 = __importDefault(require("../../shared/models/window"));

@@ -14,15 +13,19 @@ const source_types_1 = require("../enums/source-types");

metamask: {
startLogging: (apiKey, environmentType = environment_types_1.EnvironmentTypes.live) => {
startLogging: (options) => {
if (!window_1.default.ethereum || !window_1.default.ethereum.isMetaMask) {
throw new Error('MetaMask provider has not been injected, this normally means MetaMask is not installed on the extention');
}
if (!options || typeof options !== 'object') {
throw new Error('Please supply the options object into the MetaMask startLogging');
}
window_1.default.web3 = new window_1.default.Web3(new terminal_http_provider_1.TerminalHttpProvider({
apiKey,
apiKey: options.apiKey,
projectId: options.projectId,
source: source_types_1.SourceType.MetaMask,
environment: environmentType,
customHttpProvider: window_1.default.ethereum,
environment: options.environmentType,
customHttpProvider: window_1.default.ethereum
}));
},
},
},
}
}
}
};

@@ -5,3 +5,3 @@ "use strict";

rinkeby: 'wss://rinkeby.infura.io/ws',
mainnet: 'wss://mainnet.infura.io/ws',
mainnet: 'wss://mainnet.infura.io/ws'
};

@@ -20,4 +20,4 @@ "use strict";

parameters: ['newBlockHeader'],
subscribeMethod: 'eth_subscribe',
},
subscribeMethod: 'eth_subscribe'
}
};

@@ -24,0 +24,0 @@ // tslint:disable-next-line: no-console

@@ -7,3 +7,6 @@ import { HttpHeader } from 'web3-providers';

protocol?: string;
clientConfig?: string;
clientConfig?: {
maxReceivedFrameSize: number;
maxReceivedMessageSize: number;
} | undefined;
}

@@ -28,3 +28,3 @@ "use strict";

this.websocketProvider.connection.close();
},
}
};

@@ -109,3 +109,3 @@ this.web3Version = enums_1.Web3Versions.two;

const start = new Date().getTime();
const response = yield new Promise((resolve) => {
const response = yield new Promise(resolve => {
this.websocketProvider.send(

@@ -194,3 +194,3 @@ // @ts-ignore

nodeResult: this.parseJsonRPCResult(result.params.result),
firedAtTimestamp: new Date().getTime(),
firedAtTimestamp: new Date().getTime()
};

@@ -197,0 +197,0 @@ this.saveToLogs(json_rpc_mapper_1.default.toPayload(result.method, []), result.params.result, undefined, event === 'error');

@@ -35,6 +35,6 @@ "use strict";

// tslint:disable-next-line: quotemark
"ApiKey": this._apiKey,
'Content-Type': 'application/json',
ApiKey: this._apiKey,
'Content-Type': 'application/json'
},
body: JSON.stringify(saveLogRequest),
body: JSON.stringify(saveLogRequest)
});

@@ -41,0 +41,0 @@ });

@@ -10,5 +10,6 @@ export interface ISaveLogRequest {

isError: boolean;
responseTimeMs: number | undefined;
chainId: string | undefined;
headers: string | null;
responseTimeMs?: number | undefined;
chainId?: string | undefined;
headers: string;
projectId?: string | undefined;
}

@@ -18,3 +18,3 @@ "use strict";

[Networks.kovan, 'kovan'],
[Networks.unknown, 'unknown'],
[Networks.unknown, 'unknown']
]);
import Web3 from 'web3';
import { ITerminalHttpProvider } from '../../providers/http/iterminal-http-provider';
import { IMetaMaskOptions } from '../../providers/metamask/models/imetamask-options';
export interface ITerminalWindow extends Window {

@@ -17,3 +18,3 @@ web3: Web3;

metamask: {
startLogging: (apiKey: string) => void;
startLogging: (options: IMetaMaskOptions) => void;
};

@@ -20,0 +21,0 @@ };

@@ -12,7 +12,2 @@ import { ITerminalWindow } from './models/window';

static getWindow(): ITerminalWindow | undefined;
/**
* Convert rpc response to ether value if possible
* @param value The response value in hex
*/
static resultToEth(value: string): string;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const web3_utils_1 = require("web3-utils");
class Utils {

@@ -21,19 +20,3 @@ /**

}
/**
* Convert rpc response to ether value if possible
* @param value The response value in hex
*/
static resultToEth(value) {
if (web3_utils_1.isHex(value)) {
try {
const weiValue = web3_utils_1.hexToNumberString(value);
return web3_utils_1.fromWei(weiValue, 'ether');
}
catch (e) {
console.warn('Trying to convert a non hex value');
}
}
return value.toString();
}
}
exports.Utils = Utils;
{
"name": "@terminal-packages/sdk",
"version": "1.0.14",
"version": "1.0.15",
"description": "Ethereum developer tool kit for the Terminal platform",

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

@@ -23,3 +23,2 @@ [![npm version](https://badge.fury.io/js/%40terminal-packages%2Fsdk.svg)](https://badge.fury.io/js/%40terminal-packages%2Fsdk)

### Step 1

@@ -40,2 +39,3 @@

```
### Step 2

@@ -52,4 +52,4 @@

host: Any ethereum provider url of your choice
apiKey: An API key associated with your Terminal account
source: Any custom provider of your choice
apiKey: An API key associated with your Terminal account
source: Any custom provider of your choice

@@ -91,6 +91,7 @@ ## Changelog

export enum SourceType {
Terminal = 'Terminal',
Truffle = 'Truffle',
Alchemy = 'Alchemy',
MetaMask = 'MetaMask'
Terminal = "Terminal",
Truffle = "Truffle",
Alchemy = "Alchemy",
MetaMask = "MetaMask",
Infura = "Infura"
}

@@ -102,10 +103,14 @@ ```

```js
import { TerminalHttpProvider, SourceType } from '@terminal-packages/sdk';
import Web3 from 'web3';
import { TerminalHttpProvider, SourceType } from "@terminal-packages/sdk";
import Web3 from "web3";
const web3 = new Web3(
new TerminalHttpProvider({
host: 'https://yourethnodeurl.io',
apiKey: 'yourApiKey',
source: SourceType.Terminal // source can be a dynamic string as well
host: "https://yourethnodeurl.io",
apiKey: "yourApiKey",
// projectId is not required to log but we suggest
// using it for the best experience
projectId: "YOUR_TERMINAL_PROJECT_ID",
// source can be a dynamic string as well
source: SourceType.Terminal
})

@@ -118,10 +123,14 @@ );

```js
const sdk = require('@terminal-packages/sdk');
const Web3 = require('web3');
const sdk = require("@terminal-packages/sdk");
const Web3 = require("web3");
const web3 = new Web3(
new sdk.TerminalHttpProvider({
host: 'https://yourethnodeurl.io',
apiKey: 'yourApiKey',
source: sdk.SourceType.Terminal // source can be a dynamic string as well
host: "https://yourethnodeurl.io",
apiKey: "yourApiKey",
// projectId is not required to log but we suggest
// using it for the best experience
projectId: "YOUR_TERMINAL_PROJECT_ID",
// source can be a dynamic string as well
source: SourceType.Terminal
})

@@ -147,6 +156,16 @@ );

apiKey: 'yourApiKey',
source: SourceType.Terminal, // source can be a dynamic string as well
timeout: 10000,
headers: [{ name: 'x-custom-header' value: 'example' }],
withCredentials: true
// projectId is not required to log but we suggest
// using it for the best experience
projectId: "YOUR_TERMINAL_PROJECT_ID",
// source can be a dynamic string as well
source: SourceType.Terminal,
// options is not required
options: {
// timeout is not required
timeout: 10000,
// headers is not required
headers: [{ name: 'x-custom-header' value: 'example' }],
// with credentials is not required
withCredentials: true
}
})

@@ -166,6 +185,16 @@ );

apiKey: 'yourApiKey',
source: sdk.SourceType.Terminal, // source can be a dynamic string as well
timeout: 10000,
headers: [{ name: 'x-custom-header' value: 'example' }],
withCredentials: true
// projectId is not required to log but we suggest
// using it for the best experience
projectId: "YOUR_TERMINAL_PROJECT_ID",
// source can be a dynamic string as well
source: SourceType.Terminal,
// options is not required
options: {
// timeout is not required
timeout: 10000,
// headers is not required
headers: [{ name: 'x-custom-header' value: 'example' }],
// with credentials is not required
withCredentials: true
}
})

@@ -180,9 +209,13 @@ );

```js
import { TerminalHttpProvider, SourceType } from '@terminal-packages/sdk';
import Web3 from 'web3';
import { TerminalHttpProvider, SourceType } from "@terminal-packages/sdk";
import Web3 from "web3";
const web3 = new Web3(
new TerminalHttpProvider({
apiKey: 'yourApiKey',
source: SourceType.Terminal, // source can be a dynamic string as well
apiKey: "yourApiKey",
// projectId is not required to log but we suggest
// using it for the best experience
projectId: "YOUR_TERMINAL_PROJECT_ID",
// source can be a dynamic string as well
source: SourceType.Terminal,
customHttpProvider: new YourCustomHttpProvider()

@@ -196,9 +229,13 @@ })

```js
const sdk = require('@terminal-packages/sdk');
const Web3 = require('web3');
const sdk = require("@terminal-packages/sdk");
const Web3 = require("web3");
const web3 = new Web3(
new sdk.TerminalHttpProvider({
apiKey: 'yourApiKey',
source: sdk.SourceType.Terminal, // source can be a dynamic string as well
apiKey: "yourApiKey",
// projectId is not required to log but we suggest
// using it for the best experience
projectId: "YOUR_TERMINAL_PROJECT_ID",
// source can be a dynamic string as well
source: SourceType.Terminal,
customHttpProvider: new YourCustomHttpProvider()

@@ -217,5 +254,5 @@ })

export enum EnvironmentTypes {
dev = 'dev',
staging = 'staging',
live = 'live'
dev = "dev",
staging = "staging",
live = "live"
}

@@ -231,10 +268,14 @@ ```

SourceType
} from '@terminal-packages/sdk';
import Web3 from 'web3';
} from "@terminal-packages/sdk";
import Web3 from "web3";
const web3 = new Web3(
new TerminalHttpProvider({
host: 'https://yourethnodeurl.io',
apiKey: 'yourApiKey',
source: SourceType.Terminal, // source can be a dynamic string as well
host: "https://yourethnodeurl.io",
apiKey: "yourApiKey",
// projectId is not required to log but we suggest
// using it for the best experience
projectId: "YOUR_TERMINAL_PROJECT_ID",
// source can be a dynamic string as well
source: SourceType.Terminal,
environment: EnvironmentTypes.dev

@@ -248,10 +289,14 @@ })

```js
const sdk = require('@terminal-packages/sdk');
const Web3 = require('web3');
const sdk = require("@terminal-packages/sdk");
const Web3 = require("web3");
const web3 = new Web3(
new sdk.TerminalHttpProvider({
host: 'https://yourethnodeurl.io',
apiKey: 'yourApiKey',
source: sdk.SourceType.Terminal, // source can be a dynamic string as well
host: "https://yourethnodeurl.io",
apiKey: "yourApiKey",
// projectId is not required to log but we suggest
// using it for the best experience
projectId: "YOUR_TERMINAL_PROJECT_ID",
// source can be a dynamic string as well
source: SourceType.Terminal,
environment: sdk.EnvironmentTypes.dev

@@ -270,6 +315,7 @@ })

export enum SourceType {
Terminal = 'Terminal',
Truffle = 'Truffle',
Alchemy = 'Alchemy',
MetaMask = 'MetaMask'
Terminal = "Terminal",
Truffle = "Truffle",
Alchemy = "Alchemy",
MetaMask = "MetaMask",
Infura = "Infura"
}

@@ -281,10 +327,14 @@ ```

```js
import { TerminalHttpProvider, SourceType } from '@terminal-packages/sdk';
import { ethers } from 'ethers';
import { TerminalHttpProvider, SourceType } from "@terminal-packages/sdk";
import { ethers } from "ethers";
const provider = new ethers.providers.Web3Provider(
new TerminalHttpProvider({
host: 'https://yourethnodeurl.io',
apiKey: 'yourApiKey',
source: SourceType.Terminal // source can be a dynamic string as well
host: "https://yourethnodeurl.io",
apiKey: "yourApiKey",
// projectId is not required to log but we suggest
// using it for the best experience
projectId: "YOUR_TERMINAL_PROJECT_ID",
// source can be a dynamic string as well
source: SourceType.Terminal
})

@@ -297,10 +347,14 @@ );

```js
const sdk = require('@terminal-packages/sdk');
const ethers = require('ethers');
const sdk = require("@terminal-packages/sdk");
const ethers = require("ethers");
const provider = new ethers.providers.Web3Provider(
new sdk.TerminalHttpProvider({
host: 'https://yourethnodeurl.io',
apiKey: 'yourApiKey',
source: sdk.SourceType.Terminal // source can be a dynamic string as well
host: "https://yourethnodeurl.io",
apiKey: "yourApiKey",
// projectId is not required to log but we suggest
// using it for the best experience
projectId: "YOUR_TERMINAL_PROJECT_ID",
// source can be a dynamic string as well
source: SourceType.Terminal
})

@@ -326,6 +380,16 @@ );

apiKey: 'yourApiKey',
source: SourceType.Terminal, // source can be a dynamic string as well
timeout: 10000,
headers: [{ name: 'x-custom-header' value: 'example' }],
withCredentials: true
// projectId is not required to log but we suggest
// using it for the best experience
projectId: "YOUR_TERMINAL_PROJECT_ID",
// source can be a dynamic string as well
source: SourceType.Terminal,
// options is not required
options: {
// timeout is not required
timeout: 10000,
// headers is not required
headers: [{ name: 'x-custom-header' value: 'example' }],
// with credentials is not required
withCredentials: true
}
})

@@ -345,6 +409,16 @@ );

apiKey: 'yourApiKey',
source: sdk.SourceType.Terminal, // source can be a dynamic string as well
timeout: 10000,
headers: [{ name: 'x-custom-header' value: 'example' }],
withCredentials: true
// projectId is not required to log but we suggest
// using it for the best experience
projectId: "YOUR_TERMINAL_PROJECT_ID",
// source can be a dynamic string as well
source: SourceType.Terminal,
// options is not required
options: {
// timeout is not required
timeout: 10000,
// headers is not required
headers: [{ name: 'x-custom-header' value: 'example' }],
// with credentials is not required
withCredentials: true
}
})

@@ -359,9 +433,13 @@ );

```js
import { TerminalHttpProvider } from '@terminal-packages/sdk';
import { ethers } from 'ethers';
import { TerminalHttpProvider } from "@terminal-packages/sdk";
import { ethers } from "ethers";
const provider = new ethers.providers.Web3Provider(
new TerminalHttpProvider({
apiKey: 'yourApiKey',
source: SourceType.Terminal, // source can be a dynamic string as well
apiKey: "yourApiKey",
// projectId is not required to log but we suggest
// using it for the best experience
projectId: "YOUR_TERMINAL_PROJECT_ID",
// source can be a dynamic string as well
source: SourceType.Terminal,
customHttpProvider: new YourCustomHttpProvider()

@@ -375,9 +453,13 @@ })

```js
const sdk = require('@terminal-packages/sdk');
const ethers = require('ethers');
const sdk = require("@terminal-packages/sdk");
const ethers = require("ethers");
const provider = new ethers.providers.Web3Provider(
new sdk.TerminalHttpProvider({
apiKey: 'yourApiKey',
source: sdk.SourceType.Terminal, // source can be a dynamic string as well
apiKey: "yourApiKey",
// projectId is not required to log but we suggest
// using it for the best experience
projectId: "YOUR_TERMINAL_PROJECT_ID",
// source can be a dynamic string as well
source: SourceType.Terminal,
customHttpProvider: new YourCustomHttpProvider()

@@ -396,5 +478,5 @@ })

export enum EnvironmentTypes {
dev = 'dev',
staging = 'staging',
live = 'live'
dev = "dev",
staging = "staging",
live = "live"
}

@@ -410,10 +492,14 @@ ```

SourceType
} from '@terminal-packages/sdk';
import { ethers } from 'ethers';
} from "@terminal-packages/sdk";
import { ethers } from "ethers";
const provider = new ethers.providers.Web3Provider(
new TerminalHttpProvider({
host: 'https://yourethnodeurl.io',
apiKey: 'yourApiKey',
source: SourceType.Terminal, // source can be a dynamic string as well
host: "https://yourethnodeurl.io",
apiKey: "yourApiKey",
// projectId is not required to log but we suggest
// using it for the best experience
projectId: "YOUR_TERMINAL_PROJECT_ID",
// source can be a dynamic string as well
source: SourceType.Terminal,
environment: EnvironmentTypes.dev

@@ -427,10 +513,14 @@ })

```js
const sdk = require('@terminal-packages/sdk');
const ethers = require('ethers');
const sdk = require("@terminal-packages/sdk");
const ethers = require("ethers");
const provider = new ethers.providers.Web3Provider(
new sdk.TerminalHttpProvider({
host: 'https://yourethnodeurl.io',
apiKey: 'yourApiKey',
source: sdk.SourceType.Terminal, // source can be a dynamic string as well
host: "https://yourethnodeurl.io",
apiKey: "yourApiKey",
// projectId is not required to log but we suggest
// using it for the best experience
projectId: "YOUR_TERMINAL_PROJECT_ID",
// source can be a dynamic string as well
source: SourceType.Terminal,
environment: sdk.EnvironmentTypes.dev

@@ -450,9 +540,13 @@ })

```js
import { TerminalHttpProvider, SourceType } from '@terminal-packages/sdk';
import Web3 from 'web3';
import { TerminalHttpProvider, SourceType } from "@terminal-packages/sdk";
import Web3 from "web3";
const web3 = new Web3(
new TerminalHttpProvider({
apiKey: 'yourApiKey',
source: SourceType.Terminal, // source can be a dynamic string as well
apiKey: "yourApiKey",
// projectId is not required to log but we suggest
// using it for the best experience
projectId: "YOUR_TERMINAL_PROJECT_ID",
// source can be a dynamic string as well
source: SourceType.Terminal,
customHttpProvider: window.ethereum

@@ -466,9 +560,13 @@ })

```js
import { TerminalHttpProvider, SourceType } from '@terminal-packages/sdk';
import { ethers } from 'ethers';
import { TerminalHttpProvider, SourceType } from "@terminal-packages/sdk";
import { ethers } from "ethers";
const provider = new ethers.providers.Web3Provider(
new TerminalHttpProvider({
apiKey: 'yourApiKey',
source: SourceType.Terminal, // source can be a dynamic string as well
apiKey: "yourApiKey",
// projectId is not required to log but we suggest
// using it for the best experience
projectId: "YOUR_TERMINAL_PROJECT_ID",
// source can be a dynamic string as well
source: SourceType.Terminal,
customHttpProvider: window.ethereum

@@ -487,10 +585,9 @@ })

### Basic provider options
```ts
export enum SourceType {
Terminal = 'Terminal',
Truffle = 'Truffle',
Alchemy = 'Alchemy',
MetaMask = 'MetaMask'
Terminal = "Terminal",
Truffle = "Truffle",
Alchemy = "Alchemy",
MetaMask = "MetaMask",
Infura = "Infura"
}

@@ -503,7 +600,9 @@ ```

export enum Web3Versions {
one = '1',
two = '2'
one = "1",
two = "2"
}
```
### Basic provider options
#### JavaScript/TypeScript

@@ -516,11 +615,16 @@

Web3Versions
} from '@terminal-packages/sdk';
import Web3 from 'web3';
} from "@terminal-packages/sdk";
import Web3 from "web3";
const web3 = new Web3(
new TerminalWebsocketProvider({
host: 'wss://yourethnodeurl.io',
apiKey: 'yourApiKey',
source: SourceType.Terminal, // source can be a dynamic string as well
web3Version: Web3Versions.one // if your using web3 1 (NONE BETA) please tell us, if you're not please delete this property
host: "wss://yourethnodeurl.io",
apiKey: "yourApiKey",
// projectId is not required to log but we suggest
// using it for the best experience
projectId: "YOUR_TERMINAL_PROJECT_ID",
// source can be a dynamic string as well
source: SourceType.Terminal,
// if your using web3 1 (NONE BETA) please tell us, if you're not please delete this property
web3Version: sdk.Web3Versions.one
})

@@ -533,11 +637,16 @@ );

```js
const sdk = require('@terminal-packages/sdk');
const Web3 = require('web3');
const sdk = require("@terminal-packages/sdk");
const Web3 = require("web3");
const web3 = new Web3(
new sdk.TerminalWebsocketProvider({
host: 'wss://yourethnodeurl.io',
apiKey: 'yourApiKey',
source: sdk.SourceType.Terminal, // source can be a dynamic string as well
web3Version: sdk.Web3Versions.one // if your using web3 1 (NONE BETA) please tell us, if you're not please delete this property
host: "wss://yourethnodeurl.io",
apiKey: "yourApiKey",
// projectId is not required to log but we suggest
// using it for the best experience
projectId: "YOUR_TERMINAL_PROJECT_ID",
// source can be a dynamic string as well
source: SourceType.Terminal,
// if your using web3 1 (NONE BETA) please tell us, if you're not please delete this property
web3Version: sdk.Web3Versions.one
})

@@ -551,3 +660,4 @@ );

- headers - optional
- withCredentials - optional
- protocol - optional
- clientConfig - optional

@@ -564,7 +674,23 @@ #### JavaScript/TypeScript

apiKey: 'yourApiKey',
source: SourceType.Terminal, // source can be a dynamic string as well
web3Version: Web3Versions.one, // if your using web3 1 (NONE BETA) please tell us, if you're not please delete this property
timeout: 10000,
headers: [{ name: 'x-custom-header' value: 'example' }],
withCredentials: true
// projectId is not required to log but we suggest
// using it for the best experience
projectId: "YOUR_TERMINAL_PROJECT_ID",
// source can be a dynamic string as well
source: SourceType.Terminal,
// if your using web3 1 (NONE BETA) please tell us, if you're not please delete this property
web3Version: sdk.Web3Versions.one,
// options not required
options: {
// timeout not required
timeout: 10000,
// headers not required
headers: [{ name: 'x-custom-header' value: 'example' }],
// protocol not required
protocol: '63',
// client config not required
clientConfig: {
maxReceivedFrameSize: 100000000,
maxReceivedMessageSize: 100000000
},
}
})

@@ -584,7 +710,23 @@ );

apiKey: 'yourApiKey',
source: sdk.SourceType.Terminal, // source can be a dynamic string as well
web3Version: sdk.Web3Versions.one, // if your using web3 1 (NONE BETA) please tell us, if you're not please delete this property
timeout: 10000,
headers: [{ name: 'x-custom-header' value: 'example' }],
withCredentials: true
// projectId is not required to log but we suggest
// using it for the best experience
projectId: "YOUR_TERMINAL_PROJECT_ID",
// source can be a dynamic string as well
source: SourceType.Terminal,
// if your using web3 1 (NONE BETA) please tell us, if you're not please delete this property
web3Version: sdk.Web3Versions.one,
// options not required
options: {
// timeout not required
timeout: 10000,
// headers not required
headers: [{ name: 'x-custom-header' value: 'example' }],
// protocol not required
protocol: '63',
// client config not required
clientConfig: {
maxReceivedFrameSize: 100000000,
maxReceivedMessageSize: 100000000
},
}
})

@@ -603,10 +745,15 @@ );

Web3Versions
} from '@terminal-packages/sdk';
import Web3 from 'web3';
} from "@terminal-packages/sdk";
import Web3 from "web3";
const web3 = new Web3(
new TerminalWebsocketProvider({
apiKey: 'yourApiKey',
source: SourceType.Terminal, // source can be a dynamic string as well
web3Version: Web3Versions.one, // if your using web3 1 (NONE BETA) please tell us, if you're not please delete this property
apiKey: "yourApiKey",
// projectId is not required to log but we suggest
// using it for the best experience
projectId: "YOUR_TERMINAL_PROJECT_ID",
// source can be a dynamic string as well
source: SourceType.Terminal,
// if your using web3 1 (NONE BETA) please tell us, if you're not please delete this property
web3Version: sdk.Web3Versions.one,
customWebsocketProvider: new YourCustomWebsocketProvider()

@@ -620,10 +767,15 @@ })

```js
const sdk = require('@terminal-packages/sdk');
const Web3 = require('web3');
const sdk = require("@terminal-packages/sdk");
const Web3 = require("web3");
const web3 = new Web3(
new sdk.TerminalWebsocketProvider({
apiKey: 'yourApiKey',
source: sdk.SourceType.Terminal, // source can be a dynamic string as well
web3Version: sdk.Web3Versions.one, // if your using web3 1 (NONE BETA) please tell us, if you're not please delete this property
apiKey: "yourApiKey",
// projectId is not required to log but we suggest
// using it for the best experience
projectId: "YOUR_TERMINAL_PROJECT_ID",
// source can be a dynamic string as well
source: SourceType.Terminal,
// if your using web3 1 (NONE BETA) please tell us, if you're not please delete this property
web3Version: sdk.Web3Versions.one,
customWebsocketProvider: new YourCustomWebsocketProvider()

@@ -642,6 +794,7 @@ })

export enum SourceType {
Terminal = 'Terminal',
Truffle = 'Truffle',
Alchemy = 'Alchemy',
MetaMask = 'MetaMask'
Terminal = "Terminal",
Truffle = "Truffle",
Alchemy = "Alchemy",
MetaMask = "MetaMask",
Infura = "Infura"
}

@@ -654,4 +807,4 @@ ```

export enum Web3Versions {
one = '1',
two = '2'
one = "1",
two = "2"
}

@@ -667,11 +820,16 @@ ```

Web3Versions
} from '@terminal-packages/sdk';
import { ethers } from 'ethers';
} from "@terminal-packages/sdk";
import { ethers } from "ethers";
const provider = new ethers.providers.Web3Provider(
new TerminalWebsocketProvider({
host: 'wss://yourethnodeurl.io',
apiKey: 'yourApiKey',
source: SourceType.Terminal, // source can be a dynamic string as well
web3Version: Web3Versions.one // if your using web3 1 (NONE BETA) please tell us, if you're not please delete this property
host: "wss://yourethnodeurl.io",
apiKey: "yourApiKey",
// projectId is not required to log but we suggest
// using it for the best experience
projectId: "YOUR_TERMINAL_PROJECT_ID",
// source can be a dynamic string as well
source: SourceType.Terminal,
// if your using web3 1 (NONE BETA) please tell us, if you're not please delete this property
web3Version: sdk.Web3Versions.one
})

@@ -684,11 +842,16 @@ );

```js
const sdk = require('@terminal-packages/sdk');
const ethers = require('ethers');
const sdk = require("@terminal-packages/sdk");
const ethers = require("ethers");
const provider = new ethers.providers.Web3Provider(
new sdk.TerminalWebsocketProvider({
host: 'wss://yourethnodeurl.io',
apiKey: 'yourApiKey',
source: SourceType.Terminal, // source can be a dynamic string as well
web3Version: Web3Versions.one // if your using web3 1 (NONE BETA) please tell us, if you're not please delete this property
host: "wss://yourethnodeurl.io",
apiKey: "yourApiKey",
// projectId is not required to log but we suggest
// using it for the best experience
projectId: "YOUR_TERMINAL_PROJECT_ID",
// source can be a dynamic string as well
source: SourceType.Terminal,
// if your using web3 1 (NONE BETA) please tell us, if you're not please delete this property
web3Version: sdk.Web3Versions.one
})

@@ -714,7 +877,23 @@ );

apiKey: 'yourApiKey',
source: SourceType.Terminal, // source can be a dynamic string as well
web3Version: Web3Versions.one, // if your using web3 1 (NONE BETA) please tell us, if you're not please delete this property
timeout: 10000,
headers: [{ name: 'x-custom-header' value: 'example' }],
withCredentials: true
// projectId is not required to log but we suggest
// using it for the best experience
projectId: "YOUR_TERMINAL_PROJECT_ID",
// source can be a dynamic string as well
source: SourceType.Terminal,
// if your using web3 1 (NONE BETA) please tell us, if you're not please delete this property
web3Version: sdk.Web3Versions.one,
// options not required
options: {
// timeout not required
timeout: 10000,
// headers not required
headers: [{ name: 'x-custom-header' value: 'example' }],
// protocol not required
protocol: '63',
// client config not required
clientConfig: {
maxReceivedFrameSize: 100000000,
maxReceivedMessageSize: 100000000
},
}
})

@@ -734,7 +913,23 @@ );

apiKey: 'yourApiKey',
source: sdk.SourceType.Terminal, // source can be a dynamic string as well
web3Version: sdk.Web3Versions.one, // if your using web3 1 (NONE BETA) please tell us, if you're not please delete this property
timeout: 10000,
headers: [{ name: 'x-custom-header' value: 'example' }],
withCredentials: true
// projectId is not required to log but we suggest
// using it for the best experience
projectId: "YOUR_TERMINAL_PROJECT_ID",
// source can be a dynamic string as well
source: SourceType.Terminal,
// if your using web3 1 (NONE BETA) please tell us, if you're not please delete this property
web3Version: sdk.Web3Versions.one,
// options not required
options: {
// timeout not required
timeout: 10000,
// headers not required
headers: [{ name: 'x-custom-header' value: 'example' }],
// protocol not required
protocol: '63',
// client config not required
clientConfig: {
maxReceivedFrameSize: 100000000,
maxReceivedMessageSize: 100000000
},
}
})

@@ -753,10 +948,15 @@ );

Web3Versions
} from '@terminal-packages/sdk';
import { ethers } from 'ethers';
} from "@terminal-packages/sdk";
import { ethers } from "ethers";
const web3 = new ethers.providers.Web3Provider(
new TerminalWebsocketProvider({
apiKey: 'yourApiKey',
source: SourceType.Terminal, // source can be a dynamic string as well
web3Version: Web3Versions.one, // if your using web3 1 (NONE BETA) please tell us, if you're not please delete this property
apiKey: "yourApiKey",
// projectId is not required to log but we suggest
// using it for the best experience
projectId: "YOUR_TERMINAL_PROJECT_ID",
// source can be a dynamic string as well
source: SourceType.Terminal,
// if your using web3 1 (NONE BETA) please tell us, if you're not please delete this property
web3Version: sdk.Web3Versions.one,
customWebsocketProvider: new YourCustomWebsocketProvider()

@@ -770,10 +970,15 @@ })

```js
const sdk = require('@terminal-packages/sdk');
const ethers = require('ethers');
const sdk = require("@terminal-packages/sdk");
const ethers = require("ethers");
const web3 = new ethers.providers.Web3Provider(
new sdk.TerminalWebsocketProvider({
apiKey: 'yourApiKey',
source: sdk.SourceType.Terminal, // source can be a dynamic string as well
web3Version: sdk.Web3Versions.one, // if your using web3 1 (NONE BETA) please tell us, if you're not please delete this property
apiKey: "yourApiKey",
// projectId is not required to log but we suggest
// using it for the best experience
projectId: "YOUR_TERMINAL_PROJECT_ID",
// source can be a dynamic string as well
source: SourceType.Terminal,
// if your using web3 1 (NONE BETA) please tell us, if you're not please delete this property
web3Version: sdk.Web3Versions.one,
customWebsocketProvider: new YourCustomWebsocketProvider()

@@ -797,10 +1002,15 @@ })

Web3Versions
} from '@terminal-packages/sdk';
import Web3 from 'web3';
} from "@terminal-packages/sdk";
import Web3 from "web3";
const web3 = new Web3(
new TerminalWebsocketProvider({
apiKey: 'yourApiKey',
source: SourceType.Terminal, // source can be a dynamic string as well
web3Version: sdk.Web3Versions.one, // if your using web3 1 (NONE BETA) please tell us, if you're not please delete this property
apiKey: "yourApiKey",
// projectId is not required to log but we suggest
// using it for the best experience
projectId: "YOUR_TERMINAL_PROJECT_ID",
// source can be a dynamic string as well
source: SourceType.Terminal,
// if your using web3 1 (NONE BETA) please tell us, if you're not please delete this property
web3Version: sdk.Web3Versions.one,
customWebsocketProvider: window.ethereum

@@ -818,10 +1028,15 @@ })

Web3Versions
} from '@terminal-packages/sdk';
import { ethers } from 'ethers';
} from "@terminal-packages/sdk";
import { ethers } from "ethers";
const provider = new ethers.providers.Web3Provider(
new TerminalWebsocketProvider({
apiKey: 'yourApiKey',
source: SourceType.Terminal, // source can be a dynamic string as well
web3Version: sdk.Web3Versions.one, // if your using web3 1 (NONE BETA) please tell us, if you're not please delete this property
apiKey: "yourApiKey",
// projectId is not required to log but we suggest
// using it for the best experience
projectId: "YOUR_TERMINAL_PROJECT_ID",
// source can be a dynamic string as well
source: SourceType.Terminal,
// if your using web3 1 (NONE BETA) please tell us, if you're not please delete this property
web3Version: sdk.Web3Versions.one,
customWebsocketProvider: window.ethereum

@@ -858,3 +1073,3 @@ })

```js
window.terminal.sdk.metamask.startLogging('YOUR_API_KEY', 'dev');
window.terminal.sdk.metamask.startLogging("YOUR_API_KEY", "dev");
```

@@ -865,3 +1080,3 @@

```js
window.terminal.sdk.metamask.startLogging('YOUR_API_KEY', 'staging');
window.terminal.sdk.metamask.startLogging("YOUR_API_KEY", "staging");
```

@@ -868,0 +1083,0 @@

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