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

@blockfrost/blockfrost-js

Package Overview
Dependencies
Maintainers
3
Versions
105
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@blockfrost/blockfrost-js - npm Package Compare versions

Comparing version 3.0.2 to 3.0.3-beta.1

lib/utils/helpers.d.ts

4

lib/account/index.d.ts
import { BlockFrostAPI } from '..';
import * as Account from '../types/account';
export declare const deriveAddress: (publicKey: string, addressIndex: number, type: number, isTestnet: boolean) => {
address: string;
path: string;
};
export declare function getAccount(this: BlockFrostAPI, publicKey: string, type: Account.Type, isTestnet: boolean): Promise<Account.Result[]>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getAccount = exports.deriveAddress = void 0;
const cardano_serialization_lib_nodejs_1 = require("@emurgo/cardano-serialization-lib-nodejs");
exports.getAccount = void 0;
const config_1 = require("../config");
const deriveAddress = (publicKey, addressIndex, type, isTestnet) => {
const accountKey = cardano_serialization_lib_nodejs_1.Bip32PublicKey.from_bytes(Buffer.from(publicKey, 'hex'));
const utxoPubKey = accountKey.derive(type).derive(addressIndex);
const stakeKey = accountKey.derive(2).derive(0);
const networkId = isTestnet
? cardano_serialization_lib_nodejs_1.NetworkInfo.testnet().network_id()
: cardano_serialization_lib_nodejs_1.NetworkInfo.mainnet().network_id();
const baseAddr = cardano_serialization_lib_nodejs_1.BaseAddress.new(networkId, cardano_serialization_lib_nodejs_1.StakeCredential.from_keyhash(utxoPubKey.to_raw_key().hash()), cardano_serialization_lib_nodejs_1.StakeCredential.from_keyhash(stakeKey.to_raw_key().hash()));
return {
address: baseAddr.to_address().to_bech32(),
path: `m/1852'/1815'/0'/${type}/${addressIndex}`,
};
};
exports.deriveAddress = deriveAddress;
const helpers_1 = require("../utils/helpers");
async function getAccount(publicKey, type, isTestnet) {

@@ -27,3 +13,3 @@ let lastEmptyCount = 0;

for (let i = 0; i < config_1.ADDRESS_GAP_LIMIT; i++) {
const { address, path } = (0, exports.deriveAddress)(publicKey, addressCount, type, isTestnet);
const { address, path } = (0, helpers_1.deriveAddress)(publicKey, type, addressCount, isTestnet);
addressCount++;

@@ -30,0 +16,0 @@ const promise = this.addresses(address);

@@ -767,13 +767,2 @@ import { Got } from 'got';

/**
* deriveAddress
*
* @param hash
* @returns xxx
*
*/
deriveAddress: (publicKey: string, addressIndex: number, type: number, isTestnet: boolean) => {
address: string;
path: string;
};
/**
* txSubmit

@@ -780,0 +769,0 @@ *

@@ -770,10 +770,2 @@ "use strict";

/**
* deriveAddress
*
* @param hash
* @returns xxx
*
*/
this.deriveAddress = account_1.deriveAddress;
/**
* txSubmit

@@ -780,0 +772,0 @@ *

import { components } from './types/OpenApi';
import { BlockFrostAPI } from './BlockFrostAPI';
import { BlockFrostIPFS } from './BlockFrostIPFS';
import { parseAsset } from './utils/index';
import { deriveAddress, getFingerprint, parseAsset } from './utils/helpers';
import { BlockfrostClientError, BlockfrostServerError } from './utils/errors';
declare type Responses = components['schemas'];
export { BlockFrostAPI, BlockFrostIPFS, parseAsset, BlockfrostClientError, BlockfrostServerError, };
export { BlockFrostAPI, BlockFrostIPFS, BlockfrostClientError, BlockfrostServerError, parseAsset, getFingerprint, deriveAddress, };
export type { Responses };
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.BlockfrostServerError = exports.BlockfrostClientError = exports.parseAsset = exports.BlockFrostIPFS = exports.BlockFrostAPI = void 0;
exports.deriveAddress = exports.getFingerprint = exports.parseAsset = exports.BlockfrostServerError = exports.BlockfrostClientError = exports.BlockFrostIPFS = exports.BlockFrostAPI = void 0;
const BlockFrostAPI_1 = require("./BlockFrostAPI");

@@ -8,6 +8,8 @@ Object.defineProperty(exports, "BlockFrostAPI", { enumerable: true, get: function () { return BlockFrostAPI_1.BlockFrostAPI; } });

Object.defineProperty(exports, "BlockFrostIPFS", { enumerable: true, get: function () { return BlockFrostIPFS_1.BlockFrostIPFS; } });
const index_1 = require("./utils/index");
Object.defineProperty(exports, "parseAsset", { enumerable: true, get: function () { return index_1.parseAsset; } });
const helpers_1 = require("./utils/helpers");
Object.defineProperty(exports, "deriveAddress", { enumerable: true, get: function () { return helpers_1.deriveAddress; } });
Object.defineProperty(exports, "getFingerprint", { enumerable: true, get: function () { return helpers_1.getFingerprint; } });
Object.defineProperty(exports, "parseAsset", { enumerable: true, get: function () { return helpers_1.parseAsset; } });
const errors_1 = require("./utils/errors");
Object.defineProperty(exports, "BlockfrostClientError", { enumerable: true, get: function () { return errors_1.BlockfrostClientError; } });
Object.defineProperty(exports, "BlockfrostServerError", { enumerable: true, get: function () { return errors_1.BlockfrostServerError; } });

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

import { ParseAssetResult } from '../types/utils';
import { Options, ValidatedOptions, PaginationOptions, AdditionalEndpointOptions, AllMethodOptions } from '../types';

@@ -10,4 +9,2 @@ export declare const validateOptions: (options?: Options | undefined) => ValidatedOptions;

};
export declare const getFingerprint: (policyId: string, assetName?: string | undefined) => string;
export declare const parseAsset: (hex: string) => ParseAssetResult;
export declare const paginateMethod: <T extends (pagination: PaginationOptions, additionalOptions?: AdditionalEndpointOptions | undefined) => any>(fn: T, allMethodOptions: AllMethodOptions | undefined, additionalOptions?: AdditionalEndpointOptions | undefined) => Promise<ReturnType<T>>;
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.paginateMethod = exports.parseAsset = exports.getFingerprint = exports.getAllMethodOptions = exports.getPaginationOptions = exports.getAdditionalParams = exports.validateOptions = void 0;
const cip14_js_1 = __importDefault(require("@emurgo/cip14-js"));
exports.paginateMethod = exports.getAllMethodOptions = exports.getPaginationOptions = exports.getAdditionalParams = exports.validateOptions = void 0;
const config_1 = require("../config");

@@ -133,25 +129,2 @@ const validateOptions = (options) => {

exports.getAllMethodOptions = getAllMethodOptions;
const hexToString = (input) => {
const hex = input.toString();
let str = '';
for (let n = 0; n < hex.length; n += 2) {
str += String.fromCharCode(parseInt(hex.substr(n, 2), 16));
}
return str;
};
const getFingerprint = (policyId, assetName) => new cip14_js_1.default(Uint8Array.from(Buffer.from(policyId, 'hex')), Uint8Array.from(Buffer.from(assetName || '', 'hex'))).fingerprint();
exports.getFingerprint = getFingerprint;
const parseAsset = (hex) => {
const policyIdSize = 56;
const policyId = hex.slice(0, policyIdSize);
const assetNameInHex = hex.slice(policyIdSize);
const assetName = hexToString(assetNameInHex);
const fingerprint = (0, exports.getFingerprint)(policyId, assetNameInHex);
return {
policyId,
assetName,
fingerprint,
};
};
exports.parseAsset = parseAsset;
const paginateMethod = async (fn, allMethodOptions, additionalOptions) => {

@@ -158,0 +131,0 @@ const res = [];

{
"name": "@blockfrost/blockfrost-js",
"version": "3.0.2",
"version": "3.0.3-beta.1",
"description": "A JavaScript/TypeScript SDK for interacting with the https://blockfrost.io API",

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

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