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

blockchain-service-swap

Package Overview
Dependencies
Maintainers
0
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

blockchain-service-swap - npm Package Compare versions

Comparing version 2.0.0 to 3.0.0

4

dist/BSAggregator.d.ts

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

import { AccountWithDerivationPath, BlockchainService } from './interfaces';
import { Account, BlockchainService } from './interfaces';
export declare class BSAggregator<BSCustomName extends string = string, BSCustom extends BlockchainService<BSCustomName, string> = BlockchainService<BSCustomName, string>> {

@@ -14,3 +14,3 @@ #private;

getBlockchainNameByEncrypted(keyOrJson: string): BSCustomName[];
generateAccountFromMnemonicAllBlockchains(mnemonic: string, skippedAddresses?: string[]): Promise<Map<BSCustomName, AccountWithDerivationPath[]>>;
generateAccountsFromMnemonic(mnemonic: string): Promise<Map<BSCustomName, Account[]>>;
}

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

exports.BSAggregator = void 0;
const functions_1 = require("./functions");
class BSAggregator {

@@ -59,34 +60,7 @@ constructor(blockchainServices) {

}
generateAccountFromMnemonicAllBlockchains(mnemonic, skippedAddresses) {
generateAccountsFromMnemonic(mnemonic) {
return __awaiter(this, void 0, void 0, function* () {
const mnemonicAccounts = new Map();
const promises = __classPrivateFieldGet(this, _BSAggregator_blockchainServices, "f").map((service) => __awaiter(this, void 0, void 0, function* () {
let index = 0;
const accounts = [];
let hasError = false;
while (!hasError) {
const generatedAccount = service.generateAccountFromMnemonic(mnemonic, index);
if (skippedAddresses && skippedAddresses.find(address => address === generatedAccount.address)) {
index++;
continue;
}
if (index !== 0) {
try {
const { transactions } = yield service.blockchainDataService.getTransactionsByAddress({
address: generatedAccount.address,
});
if (!transactions || transactions.length <= 0)
hasError = true;
}
catch (_a) {
hasError = true;
}
}
accounts.push(generatedAccount);
index++;
}
mnemonicAccounts.set(service.blockchainName, accounts);
return (0, functions_1.fetchAccountsForBlockchainServices)(__classPrivateFieldGet(this, _BSAggregator_blockchainServices, "f"), (service, index) => __awaiter(this, void 0, void 0, function* () {
return service.generateAccountFromMnemonic(mnemonic, index);
}));
yield Promise.all(promises);
return mnemonicAccounts;
});

@@ -93,0 +67,0 @@ }

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

import { BlockchainService, BSCalculableFee, BSClaimable, BSWithExplorerService, BSWithLedger, BSWithNameService, BSWithNft } from './interfaces';
import { Account, BlockchainService, BSCalculableFee, BSClaimable, BSWithExplorerService, BSWithLedger, BSWithNameService, BSWithNft, BSWithSwap } from './interfaces';
export declare function hasNameService(service: BlockchainService): service is BlockchainService & BSWithNameService;

@@ -8,2 +8,4 @@ export declare function isClaimable(service: BlockchainService): service is BlockchainService & BSClaimable;

export declare function hasLedger(service: BlockchainService): service is BlockchainService & BSWithLedger;
export declare function hasSwap(service: BlockchainService): service is BlockchainService & BSWithSwap;
export declare function waitForTransaction(service: BlockchainService, txId: string): Promise<boolean>;
export declare function fetchAccountsForBlockchainServices<BSCustomName extends string = string>(blockchainServices: BlockchainService<BSCustomName>[], getAccountCallback: (service: BlockchainService<BSCustomName>, index: number) => Promise<Account>): Promise<Map<BSCustomName, Account[]>>;

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.waitForTransaction = exports.hasLedger = exports.hasExplorerService = exports.hasNft = exports.isCalculableFee = exports.isClaimable = exports.hasNameService = void 0;
exports.fetchAccountsForBlockchainServices = exports.waitForTransaction = exports.hasSwap = exports.hasLedger = exports.hasExplorerService = exports.hasNft = exports.isCalculableFee = exports.isClaimable = exports.hasNameService = void 0;
function hasNameService(service) {

@@ -38,2 +38,6 @@ return 'resolveNameServiceDomain' in service && 'validateNameServiceDomainFormat' in service;

exports.hasLedger = hasLedger;
function hasSwap(service) {
return 'createSwapService' in service;
}
exports.hasSwap = hasSwap;
function wait(ms) {

@@ -62,1 +66,32 @@ return new Promise(resolve => setTimeout(resolve, ms));

exports.waitForTransaction = waitForTransaction;
function fetchAccountsForBlockchainServices(blockchainServices, getAccountCallback) {
return __awaiter(this, void 0, void 0, function* () {
const accountsByBlockchainService = new Map();
const promises = blockchainServices.map((service) => __awaiter(this, void 0, void 0, function* () {
let index = 0;
const accounts = [];
let shouldBreak = false;
while (!shouldBreak) {
const generatedAccount = yield getAccountCallback(service, index);
if (index !== 0) {
try {
const { transactions } = yield service.blockchainDataService.getTransactionsByAddress({
address: generatedAccount.address,
});
if (!transactions || transactions.length <= 0)
shouldBreak = true;
}
catch (_a) {
shouldBreak = true;
}
}
accounts.push(generatedAccount);
index++;
}
accountsByBlockchainService.set(service.blockchainName, accounts);
}));
yield Promise.all(promises);
return accountsByBlockchainService;
});
}
exports.fetchAccountsForBlockchainServices = fetchAccountsForBlockchainServices;

@@ -7,6 +7,4 @@ import Transport from '@ledgerhq/hw-transport';

address: string;
bip44Path?: string;
};
export type AccountWithDerivationPath = Account & {
derivationPath: string;
};
export interface Token {

@@ -32,3 +30,3 @@ symbol: string;

senderAccount: Account;
intent: IntentTransferParam;
intents: IntentTransferParam[];
tipIntent?: IntentTransferParam;

@@ -40,3 +38,3 @@ priorityFee?: string;

readonly blockchainName: BSCustomName;
readonly derivationPath: string;
readonly bip44DerivationPath: string;
readonly feeToken: Token;

@@ -48,3 +46,3 @@ exchangeDataService: ExchangeDataService;

setNetwork: (partialNetwork: Network<BSAvailableNetworks>) => void;
generateAccountFromMnemonic(mnemonic: string | string, index: number): AccountWithDerivationPath;
generateAccountFromMnemonic(mnemonic: string | string, index: number): Account;
generateAccountFromKey(key: string): Account;

@@ -56,3 +54,3 @@ decrypt(keyOrJson: string, password: string): Promise<Account>;

validateKey(key: string): boolean;
transfer(param: TransferParam): Promise<string>;
transfer(param: TransferParam): Promise<string[]>;
}

@@ -82,2 +80,5 @@ export interface BSCalculableFee {

}
export interface BSWithSwap<BSAvailableNetworks extends string = string> {
createSwapService(): SwapService<BSAvailableNetworks>;
}
export type TransactionNotifications = {

@@ -232,4 +233,4 @@ eventName: string;

getLedgerTransport?: (account: Account) => Promise<Transport>;
getAddress(transport: Transport): Promise<string>;
getPublicKey(transport: Transport): Promise<string>;
getAccounts(transport: Transport): Promise<Account[]>;
getAccount(transport: Transport, index: number): Promise<Account>;
}

@@ -276,2 +277,3 @@ export type SwapRoute = {

} & SwapServiceSwapArgs<T>;
export type PoolGraph = Record<string, string[]>;
export interface SwapService<AvailableNetworkIds extends string> {

@@ -289,4 +291,3 @@ eventEmitter: TypedEmitter<SwapServiceEvents>;

stopListeningBlockGeneration(): void;
listSwappableTokens(network: Network<AvailableNetworkIds>): string[];
swap(isLedger?: boolean): void;
}
{
"name": "blockchain-service-swap",
"version": "2.0.0",
"version": "3.0.0",
"main": "dist/index.js",

@@ -5,0 +5,0 @@ "types": "dist/index.d.ts",

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