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

@stacks/network

Package Overview
Dependencies
Maintainers
8
Versions
632
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stacks/network - npm Package Compare versions

Comparing version 3.0.0 to 3.2.0

11

CHANGELOG.md

@@ -6,2 +6,13 @@ # Change Log

# [3.2.0](https://github.com/blockstack/blockstack.js/compare/v3.1.1...v3.2.0) (2022-02-02)
### Features
* reduce reliance on network package ([422fda3](https://github.com/blockstack/blockstack.js/commit/422fda3cd43e16ae24ea9d97297b423a90823672))
## [2.0.1](https://github.com/blockstack/blockstack.js/compare/v2.0.1-beta.2...v2.0.1) (2021-08-09)

@@ -8,0 +19,0 @@

44

dist/esm/index.d.ts

@@ -8,7 +8,8 @@ import { TransactionVersion, ChainID } from '@stacks/common';

}
export interface StacksNetwork {
export declare const StacksNetworks: readonly ["mainnet", "testnet"];
export declare type StacksNetworkName = typeof StacksNetworks[number];
export declare class StacksNetwork {
version: TransactionVersion;
chainId: ChainID;
bnsLookupUrl: string;
readonly coreApiUrl: string;
broadcastEndpoint: string;

@@ -20,30 +21,6 @@ transferFeeEstimateEndpoint: string;

readOnlyFunctionCallEndpoint: string;
isMainnet(): boolean;
getBroadcastApiUrl: () => string;
getTransferFeeEstimateApiUrl: () => string;
getTransactionFeeEstimateApiUrl: () => string;
getAccountApiUrl: (address: string) => string;
getAbiApiUrl: (address: string, contract: string) => string;
getReadOnlyFunctionCallApiUrl: (contractAddress: string, contractName: string, functionName: string) => string;
getInfoUrl: () => string;
getBlockTimeInfoUrl: () => string;
getPoxInfoUrl: () => string;
getRewardsUrl: (address: string, options?: any) => string;
getRewardHoldersUrl: (address: string, options?: any) => string;
getRewardsTotalUrl: (address: string) => string;
getStackerInfoUrl: (contractAddress: string, contractName: string) => string;
getNameInfo: (fullyQualifiedName: string) => any;
}
export declare class StacksMainnet implements StacksNetwork {
version: TransactionVersion;
chainId: ChainID;
bnsLookupUrl: string;
broadcastEndpoint: string;
transferFeeEstimateEndpoint: string;
transactionFeeEstimateEndpoint: string;
accountEndpoint: string;
contractAbiEndpoint: string;
readOnlyFunctionCallEndpoint: string;
readonly coreApiUrl: string;
constructor(networkUrl?: NetworkConfig);
constructor(networkConfig: NetworkConfig);
static fromName: (networkName: StacksNetworkName) => StacksNetwork;
static fromNameOrNetwork: (network: StacksNetworkName | StacksNetwork) => StacksNetwork;
isMainnet: () => boolean;

@@ -65,3 +42,3 @@ getBroadcastApiUrl: () => string;

}
export declare class StacksTestnet extends StacksMainnet implements StacksNetwork {
export declare class StacksMainnet extends StacksNetwork {
version: TransactionVersion;

@@ -71,3 +48,3 @@ chainId: ChainID;

}
export declare class StacksMocknet extends StacksMainnet implements StacksNetwork {
export declare class StacksTestnet extends StacksNetwork {
version: TransactionVersion;

@@ -77,1 +54,6 @@ chainId: ChainID;

}
export declare class StacksMocknet extends StacksNetwork {
version: TransactionVersion;
chainId: ChainID;
constructor(networkUrl?: NetworkConfig);
}

@@ -5,4 +5,5 @@ import { TransactionVersion, ChainID, fetchPrivate } from '@stacks/common';

export const HIRO_MOCKNET_DEFAULT = 'http://localhost:3999';
export class StacksMainnet {
constructor(networkUrl = { url: HIRO_MAINNET_DEFAULT }) {
export const StacksNetworks = ['mainnet', 'testnet'];
export class StacksNetwork {
constructor(networkConfig) {
this.version = TransactionVersion.Mainnet;

@@ -44,3 +45,3 @@ this.chainId = ChainID.Mainnet;

${contractAddress}/${contractName}/get-stacker-info`;
this.coreApiUrl = networkUrl.url;
this.coreApiUrl = networkConfig.url;
}

@@ -71,3 +72,26 @@ getNameInfo(fullyQualifiedName) {

}
export class StacksTestnet extends StacksMainnet {
StacksNetwork.fromName = (networkName) => {
switch (networkName) {
case 'mainnet':
return new StacksMainnet();
case 'testnet':
return new StacksTestnet();
default:
throw new Error(`Invalid network name provided. Must be one of the following: ${StacksNetworks.join(', ')}`);
}
};
StacksNetwork.fromNameOrNetwork = (network) => {
if (typeof network !== 'string' && 'version' in network) {
return network;
}
return StacksNetwork.fromName(network);
};
export class StacksMainnet extends StacksNetwork {
constructor(networkUrl = { url: HIRO_MAINNET_DEFAULT }) {
super(networkUrl);
this.version = TransactionVersion.Mainnet;
this.chainId = ChainID.Mainnet;
}
}
export class StacksTestnet extends StacksNetwork {
constructor(networkUrl = { url: HIRO_TESTNET_DEFAULT }) {

@@ -79,3 +103,3 @@ super(networkUrl);

}
export class StacksMocknet extends StacksMainnet {
export class StacksMocknet extends StacksNetwork {
constructor(networkUrl = { url: HIRO_MOCKNET_DEFAULT }) {

@@ -82,0 +106,0 @@ super(networkUrl);

@@ -8,7 +8,8 @@ import { TransactionVersion, ChainID } from '@stacks/common';

}
export interface StacksNetwork {
export declare const StacksNetworks: readonly ["mainnet", "testnet"];
export declare type StacksNetworkName = typeof StacksNetworks[number];
export declare class StacksNetwork {
version: TransactionVersion;
chainId: ChainID;
bnsLookupUrl: string;
readonly coreApiUrl: string;
broadcastEndpoint: string;

@@ -20,30 +21,6 @@ transferFeeEstimateEndpoint: string;

readOnlyFunctionCallEndpoint: string;
isMainnet(): boolean;
getBroadcastApiUrl: () => string;
getTransferFeeEstimateApiUrl: () => string;
getTransactionFeeEstimateApiUrl: () => string;
getAccountApiUrl: (address: string) => string;
getAbiApiUrl: (address: string, contract: string) => string;
getReadOnlyFunctionCallApiUrl: (contractAddress: string, contractName: string, functionName: string) => string;
getInfoUrl: () => string;
getBlockTimeInfoUrl: () => string;
getPoxInfoUrl: () => string;
getRewardsUrl: (address: string, options?: any) => string;
getRewardHoldersUrl: (address: string, options?: any) => string;
getRewardsTotalUrl: (address: string) => string;
getStackerInfoUrl: (contractAddress: string, contractName: string) => string;
getNameInfo: (fullyQualifiedName: string) => any;
}
export declare class StacksMainnet implements StacksNetwork {
version: TransactionVersion;
chainId: ChainID;
bnsLookupUrl: string;
broadcastEndpoint: string;
transferFeeEstimateEndpoint: string;
transactionFeeEstimateEndpoint: string;
accountEndpoint: string;
contractAbiEndpoint: string;
readOnlyFunctionCallEndpoint: string;
readonly coreApiUrl: string;
constructor(networkUrl?: NetworkConfig);
constructor(networkConfig: NetworkConfig);
static fromName: (networkName: StacksNetworkName) => StacksNetwork;
static fromNameOrNetwork: (network: StacksNetworkName | StacksNetwork) => StacksNetwork;
isMainnet: () => boolean;

@@ -65,3 +42,3 @@ getBroadcastApiUrl: () => string;

}
export declare class StacksTestnet extends StacksMainnet implements StacksNetwork {
export declare class StacksMainnet extends StacksNetwork {
version: TransactionVersion;

@@ -71,3 +48,3 @@ chainId: ChainID;

}
export declare class StacksMocknet extends StacksMainnet implements StacksNetwork {
export declare class StacksTestnet extends StacksNetwork {
version: TransactionVersion;

@@ -77,1 +54,6 @@ chainId: ChainID;

}
export declare class StacksMocknet extends StacksNetwork {
version: TransactionVersion;
chainId: ChainID;
constructor(networkUrl?: NetworkConfig);
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.StacksMocknet = exports.StacksTestnet = exports.StacksMainnet = exports.HIRO_MOCKNET_DEFAULT = exports.HIRO_TESTNET_DEFAULT = exports.HIRO_MAINNET_DEFAULT = void 0;
exports.StacksMocknet = exports.StacksTestnet = exports.StacksMainnet = exports.StacksNetwork = exports.StacksNetworks = exports.HIRO_MOCKNET_DEFAULT = exports.HIRO_TESTNET_DEFAULT = exports.HIRO_MAINNET_DEFAULT = void 0;
const common_1 = require("@stacks/common");

@@ -8,4 +8,5 @@ exports.HIRO_MAINNET_DEFAULT = 'https://stacks-node-api.mainnet.stacks.co';

exports.HIRO_MOCKNET_DEFAULT = 'http://localhost:3999';
class StacksMainnet {
constructor(networkUrl = { url: exports.HIRO_MAINNET_DEFAULT }) {
exports.StacksNetworks = ['mainnet', 'testnet'];
class StacksNetwork {
constructor(networkConfig) {
this.version = common_1.TransactionVersion.Mainnet;

@@ -47,3 +48,3 @@ this.chainId = common_1.ChainID.Mainnet;

${contractAddress}/${contractName}/get-stacker-info`;
this.coreApiUrl = networkUrl.url;
this.coreApiUrl = networkConfig.url;
}

@@ -74,4 +75,28 @@ getNameInfo(fullyQualifiedName) {

}
exports.StacksNetwork = StacksNetwork;
StacksNetwork.fromName = (networkName) => {
switch (networkName) {
case 'mainnet':
return new StacksMainnet();
case 'testnet':
return new StacksTestnet();
default:
throw new Error(`Invalid network name provided. Must be one of the following: ${exports.StacksNetworks.join(', ')}`);
}
};
StacksNetwork.fromNameOrNetwork = (network) => {
if (typeof network !== 'string' && 'version' in network) {
return network;
}
return StacksNetwork.fromName(network);
};
class StacksMainnet extends StacksNetwork {
constructor(networkUrl = { url: exports.HIRO_MAINNET_DEFAULT }) {
super(networkUrl);
this.version = common_1.TransactionVersion.Mainnet;
this.chainId = common_1.ChainID.Mainnet;
}
}
exports.StacksMainnet = StacksMainnet;
class StacksTestnet extends StacksMainnet {
class StacksTestnet extends StacksNetwork {
constructor(networkUrl = { url: exports.HIRO_TESTNET_DEFAULT }) {

@@ -84,3 +109,3 @@ super(networkUrl);

exports.StacksTestnet = StacksTestnet;
class StacksMocknet extends StacksMainnet {
class StacksMocknet extends StacksNetwork {
constructor(networkUrl = { url: exports.HIRO_MOCKNET_DEFAULT }) {

@@ -87,0 +112,0 @@ super(networkUrl);

{
"name": "@stacks/network",
"version": "3.0.0",
"version": "3.2.0",
"description": "Library for Stacks network operations",

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

"unpkg": "dist/index.umd.js",
"gitHead": "728b58358f2876d282f511ba1fc6c4fa9a1ac2f3"
"gitHead": "cfabdf8a48269e35e72f5e558fc722a55da02a5e"
}

@@ -11,44 +11,6 @@ import { TransactionVersion, ChainID, fetchPrivate } from '@stacks/common';

export interface StacksNetwork {
version: TransactionVersion;
chainId: ChainID;
bnsLookupUrl: string;
readonly coreApiUrl: string;
broadcastEndpoint: string;
transferFeeEstimateEndpoint: string;
transactionFeeEstimateEndpoint: string;
accountEndpoint: string;
contractAbiEndpoint: string;
readOnlyFunctionCallEndpoint: string;
isMainnet(): boolean;
getBroadcastApiUrl: () => string;
getTransferFeeEstimateApiUrl: () => string;
getTransactionFeeEstimateApiUrl: () => string;
getAccountApiUrl: (address: string) => string;
getAbiApiUrl: (address: string, contract: string) => string;
getReadOnlyFunctionCallApiUrl: (
contractAddress: string,
contractName: string,
functionName: string
) => string;
getInfoUrl: () => string;
getBlockTimeInfoUrl: () => string;
getPoxInfoUrl: () => string;
getRewardsUrl: (address: string, options?: any) => string;
getRewardHoldersUrl: (address: string, options?: any) => string;
getRewardsTotalUrl: (address: string) => string;
getStackerInfoUrl: (contractAddress: string, contractName: string) => string;
export const StacksNetworks = ['mainnet', 'testnet'] as const;
export type StacksNetworkName = typeof StacksNetworks[number];
/**
* Get WHOIS-like information for a name, including the address that owns it,
* the block at which it expires, and the zone file anchored to it (if available).
*
* This is intended for use in third-party wallets or in DApps that register names.
* @param fullyQualifiedName the name to query. Can be on-chain of off-chain.
* @return a promise that resolves to the WHOIS-like information
*/
getNameInfo: (fullyQualifiedName: string) => any;
}
export class StacksMainnet implements StacksNetwork {
export class StacksNetwork {
version = TransactionVersion.Mainnet;

@@ -66,6 +28,29 @@ chainId = ChainID.Mainnet;

constructor(networkUrl: NetworkConfig = { url: HIRO_MAINNET_DEFAULT }) {
this.coreApiUrl = networkUrl.url;
constructor(networkConfig: NetworkConfig) {
this.coreApiUrl = networkConfig.url;
}
static fromName = (networkName: StacksNetworkName): StacksNetwork => {
switch (networkName) {
case 'mainnet':
return new StacksMainnet();
case 'testnet':
return new StacksTestnet();
default:
throw new Error(
`Invalid network name provided. Must be one of the following: ${StacksNetworks.join(
', '
)}`
);
}
};
static fromNameOrNetwork = (network: StacksNetworkName | StacksNetwork) => {
if (typeof network !== 'string' && 'version' in network) {
return network;
}
return StacksNetwork.fromName(network);
};
isMainnet = () => this.version === TransactionVersion.Mainnet;

@@ -138,3 +123,12 @@ getBroadcastApiUrl = () => `${this.coreApiUrl}${this.broadcastEndpoint}`;

export class StacksTestnet extends StacksMainnet implements StacksNetwork {
export class StacksMainnet extends StacksNetwork {
version = TransactionVersion.Mainnet;
chainId = ChainID.Mainnet;
constructor(networkUrl: NetworkConfig = { url: HIRO_MAINNET_DEFAULT }) {
super(networkUrl);
}
}
export class StacksTestnet extends StacksNetwork {
version = TransactionVersion.Testnet;

@@ -148,3 +142,3 @@ chainId = ChainID.Testnet;

export class StacksMocknet extends StacksMainnet implements StacksNetwork {
export class StacksMocknet extends StacksNetwork {
version = TransactionVersion.Testnet;

@@ -151,0 +145,0 @@ chainId = ChainID.Testnet;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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