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

@cityofzion/bs-neo-legacy

Package Overview
Dependencies
Maintainers
0
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cityofzion/bs-neo-legacy - npm Package Compare versions

Comparing version 0.10.6 to 1.0.0

11

dist/BSNeoLegacy.d.ts

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

import { Account, BDSClaimable, BlockchainDataService, BlockchainService, BSClaimable, ExchangeDataService, Token, Network, PartialBy, TransferParam, AccountWithDerivationPath, BSWithExplorerService, ExplorerService } from '@cityofzion/blockchain-service';
export declare class BSNeoLegacy<BSCustomName extends string = string> implements BlockchainService, BSClaimable, BSWithExplorerService {
import { Account, BDSClaimable, BlockchainDataService, BlockchainService, BSClaimable, ExchangeDataService, Token, Network, TransferParam, AccountWithDerivationPath, BSWithExplorerService, ExplorerService, PartialNetwork } from '@cityofzion/blockchain-service';
import { AvailableNetworkIds } from './constants';
export declare class BSNeoLegacy<BSCustomName extends string = string> implements BlockchainService<BSCustomName, AvailableNetworkIds>, BSClaimable, BSWithExplorerService {
readonly blockchainName: BSCustomName;

@@ -12,6 +13,6 @@ readonly feeToken: Token;

tokens: Token[];
network: Network;
network: Network<AvailableNetworkIds>;
legacyNetwork: string;
constructor(blockchainName: BSCustomName, network: PartialBy<Network, 'url'>);
setNetwork(param: PartialBy<Network, 'url'>): void;
constructor(blockchainName: BSCustomName, network: PartialNetwork<AvailableNetworkIds>);
setNetwork(param: PartialNetwork<AvailableNetworkIds>): void;
validateAddress(address: string): boolean;

@@ -18,0 +19,0 @@ validateEncrypted(key: string): boolean;

@@ -32,8 +32,6 @@ "use strict";

constructor(blockchainName, network) {
if (network.type === 'custom')
throw new Error('Custom network is not supported for NEO Legacy');
this.blockchainName = blockchainName;
this.legacyNetwork = constants_1.LEGACY_NETWORK_BY_NETWORK_TYPE[network.type];
this.legacyNetwork = constants_1.LEGACY_NETWORK_BY_NETWORK_TYPE[network.id];
this.derivationPath = constants_1.DERIVATION_PATH;
this.tokens = constants_1.TOKENS[network.type];
this.tokens = constants_1.TOKENS[network.id];
this.claimToken = this.tokens.find(token => token.symbol === 'GAS');

@@ -45,13 +43,12 @@ this.burnToken = this.tokens.find(token => token.symbol === 'NEO');

setNetwork(param) {
var _a;
if (param.type === 'custom')
throw new Error('Custom network is not supported for NEO Legacy');
var _a, _b;
const network = {
type: param.type,
url: (_a = param.url) !== null && _a !== void 0 ? _a : constants_1.DEFAULT_URL_BY_NETWORK_TYPE[param.type],
id: param.id,
name: (_a = param.name) !== null && _a !== void 0 ? _a : param.id,
url: (_b = param.url) !== null && _b !== void 0 ? _b : constants_1.DEFAULT_URL_BY_NETWORK_TYPE[param.id],
};
this.network = network;
this.blockchainDataService = new DoraBDSNeoLegacy_1.DoraBDSNeoLegacy(network, this.feeToken, this.claimToken);
this.exchangeDataService = new CryptoCompareEDSNeoLegacy_1.CryptoCompareEDSNeoLegacy(network.type);
this.explorerService = new DoraESNeoLegacy_1.DoraESNeoLegacy(network.type);
this.exchangeDataService = new CryptoCompareEDSNeoLegacy_1.CryptoCompareEDSNeoLegacy(network.id);
this.explorerService = new DoraESNeoLegacy_1.DoraESNeoLegacy(network.id);
}

@@ -58,0 +55,0 @@ validateAddress(address) {

@@ -1,4 +0,5 @@

import { NetworkType, Token } from '@cityofzion/blockchain-service';
export declare const TOKENS: Record<NetworkType, Token[]>;
export declare const LEGACY_NETWORK_BY_NETWORK_TYPE: Record<Exclude<NetworkType, 'custom'>, string>;
import { Token } from '@cityofzion/blockchain-service';
export type AvailableNetworkIds = 'mainnet' | 'testnet';
export declare const TOKENS: Record<AvailableNetworkIds, Token[]>;
export declare const LEGACY_NETWORK_BY_NETWORK_TYPE: Record<Exclude<AvailableNetworkIds, 'custom'>, string>;
export declare const NATIVE_ASSETS: {

@@ -11,3 +12,3 @@ symbol: string;

export declare const DERIVATION_PATH = "m/44'/888'/0'/0/?";
export declare const RPC_LIST_BY_NETWORK_TYPE: Record<Exclude<NetworkType, 'custom'>, string[]>;
export declare const DEFAULT_URL_BY_NETWORK_TYPE: Record<Exclude<NetworkType, 'custom'>, string>;
export declare const RPC_LIST_BY_NETWORK_TYPE: Record<Exclude<AvailableNetworkIds, 'custom'>, string[]>;
export declare const DEFAULT_URL_BY_NETWORK_TYPE: Record<Exclude<AvailableNetworkIds, 'custom'>, string>;

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

testnet: common_json_1.default,
custom: common_json_1.default,
};

@@ -15,0 +14,0 @@ exports.LEGACY_NETWORK_BY_NETWORK_TYPE = {

@@ -1,4 +0,8 @@

import { CryptoCompareEDS, ExchangeDataService, NetworkType } from '@cityofzion/blockchain-service';
import { CryptoCompareEDS, Currency, ExchangeDataService, GetTokenPriceHistory, TokenPricesHistoryResponse, TokenPricesResponse } from '@cityofzion/blockchain-service';
import { AvailableNetworkIds } from './constants';
export declare class CryptoCompareEDSNeoLegacy extends CryptoCompareEDS implements ExchangeDataService {
constructor(networkType: NetworkType);
#private;
constructor(networkId: AvailableNetworkIds);
getTokenPriceHistory(params: GetTokenPriceHistory): Promise<TokenPricesHistoryResponse[]>;
getTokenPrices(currency: Currency): Promise<TokenPricesResponse[]>;
}
"use strict";
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
if (kind === "m") throw new TypeError("Private method is not writable");
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _CryptoCompareEDSNeoLegacy_networkId;
Object.defineProperty(exports, "__esModule", { value: true });

@@ -7,6 +19,19 @@ exports.CryptoCompareEDSNeoLegacy = void 0;

class CryptoCompareEDSNeoLegacy extends blockchain_service_1.CryptoCompareEDS {
constructor(networkType) {
super(networkType, constants_1.TOKENS[networkType]);
constructor(networkId) {
super(constants_1.TOKENS[networkId]);
_CryptoCompareEDSNeoLegacy_networkId.set(this, void 0);
__classPrivateFieldSet(this, _CryptoCompareEDSNeoLegacy_networkId, networkId, "f");
}
getTokenPriceHistory(params) {
if (__classPrivateFieldGet(this, _CryptoCompareEDSNeoLegacy_networkId, "f") !== 'mainnet')
throw new Error('Exchange is only available on mainnet');
return super.getTokenPriceHistory(params);
}
getTokenPrices(currency) {
if (__classPrivateFieldGet(this, _CryptoCompareEDSNeoLegacy_networkId, "f") !== 'mainnet')
throw new Error('Exchange is only available on mainnet');
return super.getTokenPrices(currency);
}
}
exports.CryptoCompareEDSNeoLegacy = CryptoCompareEDSNeoLegacy;
_CryptoCompareEDSNeoLegacy_networkId = new WeakMap();
import { BalanceResponse, BlockchainDataService, ContractResponse, TransactionsByAddressParams, TransactionsByAddressResponse, TransactionResponse, BDSClaimable, Token, Network, RpcResponse } from '@cityofzion/blockchain-service';
import { AvailableNetworkIds } from './constants';
export declare class DoraBDSNeoLegacy implements BlockchainDataService, BDSClaimable {
#private;
maxTimeToConfirmTransactionInMs: number;
constructor(network: Network, feeToken: Token, claimToken: Token);
constructor(network: Network<AvailableNetworkIds>, feeToken: Token, claimToken: Token);
getTransaction(hash: string): Promise<TransactionResponse>;

@@ -7,0 +8,0 @@ getTransactionsByAddress({ address, page, }: TransactionsByAddressParams): Promise<TransactionsByAddressResponse>;

@@ -35,4 +35,2 @@ "use strict";

this.maxTimeToConfirmTransactionInMs = 1000 * 60 * 2;
if (network.type === 'custom')
throw new Error('Custom network is not supported for NEO Legacy');
__classPrivateFieldSet(this, _DoraBDSNeoLegacy_network, network, "f");

@@ -45,3 +43,3 @@ __classPrivateFieldSet(this, _DoraBDSNeoLegacy_claimToken, claimToken, "f");

return __awaiter(this, void 0, void 0, function* () {
const data = yield dora_ts_1.api.NeoLegacyREST.transaction(hash, __classPrivateFieldGet(this, _DoraBDSNeoLegacy_network, "f").type);
const data = yield dora_ts_1.api.NeoLegacyREST.transaction(hash, __classPrivateFieldGet(this, _DoraBDSNeoLegacy_network, "f").id);
if (!data || 'error' in data)

@@ -75,3 +73,3 @@ throw new Error(`Transaction ${hash} not found`);

return __awaiter(this, void 0, void 0, function* () {
const data = yield dora_ts_1.api.NeoLegacyREST.getAddressAbstracts(address, page, __classPrivateFieldGet(this, _DoraBDSNeoLegacy_network, "f").type);
const data = yield dora_ts_1.api.NeoLegacyREST.getAddressAbstracts(address, page, __classPrivateFieldGet(this, _DoraBDSNeoLegacy_network, "f").id);
const transactions = new Map();

@@ -114,3 +112,3 @@ const promises = data.entries.map((entry) => __awaiter(this, void 0, void 0, function* () {

return __awaiter(this, void 0, void 0, function* () {
const response = yield dora_ts_1.api.NeoLegacyREST.contract(contractHash, __classPrivateFieldGet(this, _DoraBDSNeoLegacy_network, "f").type);
const response = yield dora_ts_1.api.NeoLegacyREST.contract(contractHash, __classPrivateFieldGet(this, _DoraBDSNeoLegacy_network, "f").id);
if (!response || 'error' in response)

@@ -127,3 +125,3 @@ throw new Error(`Contract ${contractHash} not found`);

return __awaiter(this, void 0, void 0, function* () {
const localToken = constants_1.TOKENS[__classPrivateFieldGet(this, _DoraBDSNeoLegacy_network, "f").type].find(token => token.hash === tokenHash);
const localToken = constants_1.TOKENS[__classPrivateFieldGet(this, _DoraBDSNeoLegacy_network, "f").id].find(token => token.hash === tokenHash);
if (localToken)

@@ -134,3 +132,3 @@ return localToken;

}
const data = yield dora_ts_1.api.NeoLegacyREST.asset(tokenHash, __classPrivateFieldGet(this, _DoraBDSNeoLegacy_network, "f").type);
const data = yield dora_ts_1.api.NeoLegacyREST.asset(tokenHash, __classPrivateFieldGet(this, _DoraBDSNeoLegacy_network, "f").id);
if (!data || 'error' in data)

@@ -150,3 +148,3 @@ throw new Error(`Token ${tokenHash} not found`);

return __awaiter(this, void 0, void 0, function* () {
const data = yield dora_ts_1.api.NeoLegacyREST.balance(address, __classPrivateFieldGet(this, _DoraBDSNeoLegacy_network, "f").type);
const data = yield dora_ts_1.api.NeoLegacyREST.balance(address, __classPrivateFieldGet(this, _DoraBDSNeoLegacy_network, "f").id);
const promises = data.map((balance) => __awaiter(this, void 0, void 0, function* () {

@@ -177,3 +175,3 @@ const hash = balance.asset.replace('0x', '');

return __awaiter(this, void 0, void 0, function* () {
const { unclaimed } = yield dora_ts_1.api.NeoLegacyREST.getUnclaimed(address, __classPrivateFieldGet(this, _DoraBDSNeoLegacy_network, "f").type);
const { unclaimed } = yield dora_ts_1.api.NeoLegacyREST.getUnclaimed(address, __classPrivateFieldGet(this, _DoraBDSNeoLegacy_network, "f").id);
return (unclaimed / Math.pow(10, __classPrivateFieldGet(this, _DoraBDSNeoLegacy_claimToken, "f").decimals)).toFixed(__classPrivateFieldGet(this, _DoraBDSNeoLegacy_claimToken, "f").decimals);

@@ -191,3 +189,3 @@ });

const list = [];
const networkType = __classPrivateFieldGet(this, _DoraBDSNeoLegacy_network, "f").type;
const networkType = __classPrivateFieldGet(this, _DoraBDSNeoLegacy_network, "f").id;
const promises = constants_1.RPC_LIST_BY_NETWORK_TYPE[networkType].map(url => {

@@ -194,0 +192,0 @@ // eslint-disable-next-line no-async-promise-executor

@@ -1,7 +0,8 @@

import { BuildNftUrlParams, ExplorerService, NetworkType } from '@cityofzion/blockchain-service';
import { BuildNftUrlParams, ExplorerService } from '@cityofzion/blockchain-service';
import { AvailableNetworkIds } from './constants';
export declare class DoraESNeoLegacy implements ExplorerService {
#private;
constructor(networkType: NetworkType);
constructor(networkId: AvailableNetworkIds);
buildTransactionUrl(hash: string): string;
buildNftUrl(_params: BuildNftUrlParams): string;
}

@@ -13,14 +13,12 @@ "use strict";

};
var _DoraESNeoLegacy_networkType;
var _DoraESNeoLegacy_networkId;
Object.defineProperty(exports, "__esModule", { value: true });
exports.DoraESNeoLegacy = void 0;
class DoraESNeoLegacy {
constructor(networkType) {
_DoraESNeoLegacy_networkType.set(this, void 0);
__classPrivateFieldSet(this, _DoraESNeoLegacy_networkType, networkType, "f");
constructor(networkId) {
_DoraESNeoLegacy_networkId.set(this, void 0);
__classPrivateFieldSet(this, _DoraESNeoLegacy_networkId, networkId, "f");
}
buildTransactionUrl(hash) {
if (__classPrivateFieldGet(this, _DoraESNeoLegacy_networkType, "f") === 'custom')
throw new Error('DoraESNeoLegacy does not support custom network');
return `https://dora.coz.io/transaction/neo2/${__classPrivateFieldGet(this, _DoraESNeoLegacy_networkType, "f")}/${hash}`;
return `https://dora.coz.io/transaction/neo2/${__classPrivateFieldGet(this, _DoraESNeoLegacy_networkId, "f")}/${hash}`;
}

@@ -32,2 +30,2 @@ buildNftUrl(_params) {

exports.DoraESNeoLegacy = DoraESNeoLegacy;
_DoraESNeoLegacy_networkType = new WeakMap();
_DoraESNeoLegacy_networkId = new WeakMap();
{
"name": "@cityofzion/bs-neo-legacy",
"version": "0.10.6",
"version": "1.0.0",
"main": "dist/index.js",

@@ -14,4 +14,4 @@ "types": "dist/index.d.ts",

"@cityofzion/neon-js": "4.8.3",
"@cityofzion/bs-asteroid-sdk": "0.9.0",
"@cityofzion/blockchain-service": "0.13.0"
"@cityofzion/blockchain-service": "1.0.0",
"@cityofzion/bs-asteroid-sdk": "0.9.0"
},

@@ -18,0 +18,0 @@ "devDependencies": {

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