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

@mijoco/stx_helpers

Package Overview
Dependencies
Maintainers
1
Versions
100
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mijoco/stx_helpers - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

dist/stacks-node/custom-node.d.ts

1

dist/account/account.d.ts

@@ -16,1 +16,2 @@ import { UserSession } from '@stacks/connect';

export declare function logUserOut(): void;
export declare function checkAddressForNetwork(net: string, address: string | undefined): void;

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.logUserOut = exports.loginStacksFromHeader = exports.loginStacks = exports.getStacksAddress = exports.isLoggedIn = exports.appDetails = exports.isLeather = exports.isAsigna = exports.isHiro = exports.isXverse = exports.userSession = void 0;
exports.checkAddressForNetwork = exports.logUserOut = exports.loginStacksFromHeader = exports.loginStacks = exports.getStacksAddress = exports.isLoggedIn = exports.appDetails = exports.isLeather = exports.isAsigna = exports.isHiro = exports.isXverse = exports.userSession = void 0;
const connect_1 = require("@stacks/connect");

@@ -113,1 +113,32 @@ const appConfig = new connect_1.AppConfig(['store_write', 'publish_data']);

exports.logUserOut = logUserOut;
function checkAddressForNetwork(net, address) {
if (!address || typeof address !== 'string')
throw new Error('No address passed');
if (address.length < 10)
throw new Error('Address is undefined');
if (net === 'devnet')
return;
else if (net === 'testnet') {
if (address.startsWith('bc'))
throw new Error('Mainnet address passed to testnet app: ' + address);
else if (address.startsWith('3'))
throw new Error('Mainnet address passed to testnet app: ' + address);
else if (address.startsWith('1'))
throw new Error('Mainnet address passed to testnet app: ' + address);
else if (address.startsWith('SP') || address.startsWith('sp'))
throw new Error('Mainnet stacks address passed to testnet app: ' + address);
}
else {
if (address.startsWith('tb'))
throw new Error('Testnet address passed to testnet app: ' + address);
else if (address.startsWith('2'))
throw new Error('Testnet address passed to testnet app: ' + address);
else if (address.startsWith('m'))
throw new Error('Testnet address passed to testnet app: ' + address);
else if (address.startsWith('n'))
throw new Error('Testnet address passed to testnet app: ' + address);
else if (address.startsWith('ST') || address.startsWith('st'))
throw new Error('Testnet stacks address passed to testnet app: ' + address);
}
}
exports.checkAddressForNetwork = checkAddressForNetwork;

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

import { StacksMainnet, StacksTestnet } from "@stacks/network";
export declare function fetchDataVar(stacksApi: string, contractAddress: string, contractName: string, dataVarName: string): Promise<any>;
export declare function getStacksNetwork(network: string): StacksMainnet | StacksTestnet;
export declare function lookupContract(stacksApi: string, contract_id: string): Promise<any>;

@@ -3,0 +5,0 @@ export declare function isConstructed(stacksApi: string, contract_id: string): Promise<any>;

@@ -12,3 +12,4 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.fetchExchangeRates = exports.getPoxInfo = exports.getStacksBalances = exports.fetchStacksInfo = exports.isConstructed = exports.lookupContract = exports.fetchDataVar = void 0;
exports.fetchExchangeRates = exports.getPoxInfo = exports.getStacksBalances = exports.fetchStacksInfo = exports.isConstructed = exports.lookupContract = exports.getStacksNetwork = exports.fetchDataVar = void 0;
const network_1 = require("@stacks/network");
function fetchDataVar(stacksApi, contractAddress, contractName, dataVarName) {

@@ -29,2 +30,23 @@ return __awaiter(this, void 0, void 0, function* () {

exports.fetchDataVar = fetchDataVar;
function getStacksNetwork(network) {
let stxNetwork;
/**
if (CONFIG.VITE_ENVIRONMENT === 'nakamoto') {
stxNetwork = new StacksTestnet({
url: 'https://api.nakamoto.testnet.hiro.so',
});
return stxNetwork
}
*/
if (network === 'devnet')
stxNetwork = new network_1.StacksMocknet();
else if (network === 'testnet')
stxNetwork = new network_1.StacksTestnet();
else if (network === 'mainnet')
stxNetwork = new network_1.StacksMainnet();
else
stxNetwork = new network_1.StacksMocknet();
return stxNetwork;
}
exports.getStacksNetwork = getStacksNetwork;
function lookupContract(stacksApi, contract_id) {

@@ -31,0 +53,0 @@ return __awaiter(this, void 0, void 0, function* () {

5

package.json
{
"name": "@mijoco/stx_helpers",
"version": "0.0.1",
"version": "0.0.2",
"main": "index.js",

@@ -9,3 +9,3 @@ "scripts": {

"clean": "rm -rf dist",
"pub": "npm publish --access public"
"pub": "npm publish --access public"
},

@@ -23,4 +23,5 @@ "keywords": [],

"@stacks/connect": "^7.7.1",
"@stacks/network": "^6.13.0",
"tslib": "^2.6.3"
}
}

@@ -93,1 +93,21 @@ import { AppConfig, UserSession, showConnect, getStacksProvider, type StacksProvider } from '@stacks/connect';

}
export function checkAddressForNetwork(net:string, address:string|undefined) {
if (!address || typeof address !== 'string') throw new Error('No address passed')
if (address.length < 10) throw new Error('Address is undefined')
if (net === 'devnet') return
else if (net === 'testnet') {
if (address.startsWith('bc')) throw new Error('Mainnet address passed to testnet app: ' + address)
else if (address.startsWith('3')) throw new Error('Mainnet address passed to testnet app: ' + address)
else if (address.startsWith('1')) throw new Error('Mainnet address passed to testnet app: ' + address)
else if (address.startsWith('SP') || address.startsWith('sp')) throw new Error('Mainnet stacks address passed to testnet app: ' + address)
} else {
if (address.startsWith('tb')) throw new Error('Testnet address passed to testnet app: ' + address)
else if (address.startsWith('2')) throw new Error('Testnet address passed to testnet app: ' + address)
else if (address.startsWith('m')) throw new Error('Testnet address passed to testnet app: ' + address)
else if (address.startsWith('n')) throw new Error('Testnet address passed to testnet app: ' + address)
else if (address.startsWith('ST') || address.startsWith('st')) throw new Error('Testnet stacks address passed to testnet app: ' + address)
}
}

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

import { StacksMainnet, StacksMocknet, StacksTestnet } from "@stacks/network";
export async function fetchDataVar(stacksApi:string, contractAddress:string, contractName:string, dataVarName:string) {

@@ -13,2 +15,20 @@ try {

export function getStacksNetwork(network:string) {
let stxNetwork:StacksMainnet|StacksTestnet;
/**
if (CONFIG.VITE_ENVIRONMENT === 'nakamoto') {
stxNetwork = new StacksTestnet({
url: 'https://api.nakamoto.testnet.hiro.so',
});
return stxNetwork
}
*/
if (network === 'devnet') stxNetwork = new StacksMocknet();
else if (network === 'testnet') stxNetwork = new StacksTestnet();
else if (network === 'mainnet') stxNetwork = new StacksMainnet();
else stxNetwork = new StacksMocknet();
return stxNetwork;
}
export async function lookupContract(stacksApi:string, contract_id:string) {

@@ -15,0 +35,0 @@ const path = `${stacksApi}/extended/v1/contract/${contract_id}`;

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