@cityofzion/bs-neo3 0.11.2 → 0.11.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/BSNeo3.js +1 -1
- package/dist/FlamingoEDSNeo3.d.ts +2 -2
- package/dist/FlamingoEDSNeo3.js +4 -1
- package/dist/GhostMarketNDSNeo3.d.ts +4 -3
- package/dist/GhostMarketNDSNeo3.js +5 -3
- package/dist/RpcBDSNeo3.d.ts +2 -1
- package/dist/RpcBDSNeo3.js +26 -0
- package/dist/RpcNDSNeo3.d.ts +8 -0
- package/dist/RpcNDSNeo3.js +59 -0
- package/dist/constants.d.ts +2 -1
- package/dist/constants.js +30 -6
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +2 -2
package/dist/BSNeo3.js
CHANGED
|
@@ -45,7 +45,7 @@ class BSNeo3 {
|
|
|
45
45
|
this.blockchainDataService = new DoraBDSNeo3_1.DoraBDSNeo3(network, this.feeToken, this.claimToken);
|
|
46
46
|
}
|
|
47
47
|
this.exchangeDataService = new FlamingoEDSNeo3_1.FlamingoEDSNeo3(network.type);
|
|
48
|
-
this.nftDataService = new GhostMarketNDSNeo3_1.GhostMarketNDSNeo3(network
|
|
48
|
+
this.nftDataService = new GhostMarketNDSNeo3_1.GhostMarketNDSNeo3(network);
|
|
49
49
|
this.explorerService = new DoraESNeo3_1.DoraESNeo3(network.type);
|
|
50
50
|
}
|
|
51
51
|
validateAddress(address) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Currency, ExchangeDataService, NetworkType, TokenPricesResponse } from '@cityofzion/blockchain-service';
|
|
2
|
-
export declare class FlamingoEDSNeo3 implements ExchangeDataService {
|
|
1
|
+
import { CryptoCompareEDS, Currency, ExchangeDataService, NetworkType, TokenPricesResponse } from '@cityofzion/blockchain-service';
|
|
2
|
+
export declare class FlamingoEDSNeo3 extends CryptoCompareEDS implements ExchangeDataService {
|
|
3
3
|
#private;
|
|
4
4
|
constructor(networkType: NetworkType);
|
|
5
5
|
getTokenPrices(currency: Currency): Promise<TokenPricesResponse[]>;
|
package/dist/FlamingoEDSNeo3.js
CHANGED
|
@@ -25,9 +25,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
25
25
|
var _FlamingoEDSNeo3_networkType, _FlamingoEDSNeo3_axiosInstance;
|
|
26
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
27
|
exports.FlamingoEDSNeo3 = void 0;
|
|
28
|
+
const blockchain_service_1 = require("@cityofzion/blockchain-service");
|
|
28
29
|
const axios_1 = __importDefault(require("axios"));
|
|
29
|
-
|
|
30
|
+
const constants_1 = require("./constants");
|
|
31
|
+
class FlamingoEDSNeo3 extends blockchain_service_1.CryptoCompareEDS {
|
|
30
32
|
constructor(networkType) {
|
|
33
|
+
super(networkType, constants_1.TOKENS[networkType]);
|
|
31
34
|
_FlamingoEDSNeo3_networkType.set(this, void 0);
|
|
32
35
|
_FlamingoEDSNeo3_axiosInstance.set(this, void 0);
|
|
33
36
|
__classPrivateFieldSet(this, _FlamingoEDSNeo3_networkType, networkType, "f");
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { NftResponse, NftsResponse,
|
|
2
|
-
|
|
1
|
+
import { NftResponse, NftsResponse, GetNftParam, GetNftsByAddressParams, Network } from '@cityofzion/blockchain-service';
|
|
2
|
+
import { RpcNDSNeo3 } from './RpcNDSNeo3';
|
|
3
|
+
export declare class GhostMarketNDSNeo3 extends RpcNDSNeo3 {
|
|
3
4
|
#private;
|
|
4
|
-
constructor(
|
|
5
|
+
constructor(network: Network);
|
|
5
6
|
getNftsByAddress({ address, size, cursor }: GetNftsByAddressParams): Promise<NftsResponse>;
|
|
6
7
|
getNft({ contractHash, tokenId }: GetNftParam): Promise<NftResponse>;
|
|
7
8
|
private treatGhostMarketImage;
|
|
@@ -28,10 +28,12 @@ exports.GhostMarketNDSNeo3 = void 0;
|
|
|
28
28
|
const query_string_1 = __importDefault(require("query-string"));
|
|
29
29
|
const axios_1 = __importDefault(require("axios"));
|
|
30
30
|
const constants_1 = require("./constants");
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
const RpcNDSNeo3_1 = require("./RpcNDSNeo3");
|
|
32
|
+
class GhostMarketNDSNeo3 extends RpcNDSNeo3_1.RpcNDSNeo3 {
|
|
33
|
+
constructor(network) {
|
|
34
|
+
super(network);
|
|
33
35
|
_GhostMarketNDSNeo3_networkType.set(this, void 0);
|
|
34
|
-
__classPrivateFieldSet(this, _GhostMarketNDSNeo3_networkType,
|
|
36
|
+
__classPrivateFieldSet(this, _GhostMarketNDSNeo3_networkType, network.type, "f");
|
|
35
37
|
}
|
|
36
38
|
getNftsByAddress({ address, size = 18, cursor }) {
|
|
37
39
|
var _a;
|
package/dist/RpcBDSNeo3.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BDSClaimable, BalanceResponse, BlockchainDataService, ContractResponse, Network, Token, TransactionResponse, TransactionsByAddressParams, TransactionsByAddressResponse } from '@cityofzion/blockchain-service';
|
|
1
|
+
import { BDSClaimable, BalanceResponse, BlockchainDataService, ContractResponse, Network, RpcResponse, Token, TransactionResponse, TransactionsByAddressParams, TransactionsByAddressResponse } from '@cityofzion/blockchain-service';
|
|
2
2
|
export declare class RPCBDSNeo3 implements BlockchainDataService, BDSClaimable {
|
|
3
3
|
readonly _tokenCache: Map<string, Token>;
|
|
4
4
|
readonly _feeToken: Token;
|
|
@@ -13,4 +13,5 @@ export declare class RPCBDSNeo3 implements BlockchainDataService, BDSClaimable {
|
|
|
13
13
|
getBalance(address: string): Promise<BalanceResponse[]>;
|
|
14
14
|
getBlockHeight(): Promise<number>;
|
|
15
15
|
getUnclaimed(address: string): Promise<string>;
|
|
16
|
+
getRpcList(): Promise<RpcResponse[]>;
|
|
16
17
|
}
|
package/dist/RpcBDSNeo3.js
CHANGED
|
@@ -155,5 +155,31 @@ class RPCBDSNeo3 {
|
|
|
155
155
|
return neon_core_1.u.BigInteger.fromNumber(response).toDecimal(this._claimToken.decimals);
|
|
156
156
|
});
|
|
157
157
|
}
|
|
158
|
+
getRpcList() {
|
|
159
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
160
|
+
const list = [];
|
|
161
|
+
const promises = constants_1.RPC_LIST_BY_NETWORK_TYPE[this._network.type].map(url => {
|
|
162
|
+
// eslint-disable-next-line no-async-promise-executor
|
|
163
|
+
return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
|
|
164
|
+
const timeout = setTimeout(() => {
|
|
165
|
+
resolve();
|
|
166
|
+
}, 5000);
|
|
167
|
+
try {
|
|
168
|
+
const rpcClient = new neon_core_1.rpc.RPCClient(url);
|
|
169
|
+
const timeStart = Date.now();
|
|
170
|
+
const height = yield rpcClient.getBlockCount();
|
|
171
|
+
const latency = Date.now() - timeStart;
|
|
172
|
+
list.push({ url, latency, height });
|
|
173
|
+
}
|
|
174
|
+
finally {
|
|
175
|
+
resolve();
|
|
176
|
+
clearTimeout(timeout);
|
|
177
|
+
}
|
|
178
|
+
}));
|
|
179
|
+
});
|
|
180
|
+
yield Promise.allSettled(promises);
|
|
181
|
+
return list;
|
|
182
|
+
});
|
|
183
|
+
}
|
|
158
184
|
}
|
|
159
185
|
exports.RPCBDSNeo3 = RPCBDSNeo3;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { GetNftParam, GetNftsByAddressParams, HasTokenParam, Network, NftDataService, NftResponse, NftsResponse } from '@cityofzion/blockchain-service';
|
|
2
|
+
export declare abstract class RpcNDSNeo3 implements NftDataService {
|
|
3
|
+
#private;
|
|
4
|
+
protected constructor(network: Network);
|
|
5
|
+
abstract getNftsByAddress(params: GetNftsByAddressParams): Promise<NftsResponse>;
|
|
6
|
+
abstract getNft(params: GetNftParam): Promise<NftResponse>;
|
|
7
|
+
hasToken({ contractHash, address }: HasTokenParam): Promise<boolean>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
12
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
13
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
14
|
+
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");
|
|
15
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
16
|
+
};
|
|
17
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
18
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
19
|
+
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");
|
|
20
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
21
|
+
};
|
|
22
|
+
var _RpcNDSNeo3_network;
|
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
exports.RpcNDSNeo3 = void 0;
|
|
25
|
+
const neon_dappkit_1 = require("@cityofzion/neon-dappkit");
|
|
26
|
+
class RpcNDSNeo3 {
|
|
27
|
+
constructor(network) {
|
|
28
|
+
_RpcNDSNeo3_network.set(this, void 0);
|
|
29
|
+
__classPrivateFieldSet(this, _RpcNDSNeo3_network, network, "f");
|
|
30
|
+
}
|
|
31
|
+
hasToken({ contractHash, address }) {
|
|
32
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
+
const parser = neon_dappkit_1.NeonParser;
|
|
34
|
+
const invoker = yield neon_dappkit_1.NeonInvoker.init({ rpcAddress: __classPrivateFieldGet(this, _RpcNDSNeo3_network, "f").url });
|
|
35
|
+
try {
|
|
36
|
+
const result = yield invoker.testInvoke({
|
|
37
|
+
invocations: [
|
|
38
|
+
{
|
|
39
|
+
scriptHash: contractHash,
|
|
40
|
+
operation: 'balanceOf',
|
|
41
|
+
args: [
|
|
42
|
+
{
|
|
43
|
+
type: 'Hash160',
|
|
44
|
+
value: address,
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
});
|
|
50
|
+
return parser.parseRpcResponse(result.stack[0], { type: 'Integer' }) > 0;
|
|
51
|
+
}
|
|
52
|
+
catch (_a) {
|
|
53
|
+
throw new Error(`Token not found: ${contractHash}`);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.RpcNDSNeo3 = RpcNDSNeo3;
|
|
59
|
+
_RpcNDSNeo3_network = new WeakMap();
|
package/dist/constants.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { NetworkType, Token } from '@cityofzion/blockchain-service';
|
|
2
2
|
export declare const TOKENS: Record<NetworkType, Token[]>;
|
|
3
3
|
export declare const NEO_NS_HASH = "0x50ac1c37690cc2cfc594472833cf57505d5f46de";
|
|
4
|
-
export declare const DEFAULT_URL_BY_NETWORK_TYPE: Record<NetworkType, string>;
|
|
5
4
|
export declare const GHOSTMARKET_URL_BY_NETWORK_TYPE: Partial<Record<NetworkType, string>>;
|
|
6
5
|
export declare const GHOSTMARKET_CHAIN_BY_NETWORK_TYPE: Partial<Record<NetworkType, string>>;
|
|
7
6
|
export declare const DERIVATION_PATH = "m/44'/888'/0'/0/?";
|
|
7
|
+
export declare const RPC_LIST_BY_NETWORK_TYPE: Record<NetworkType, string[]>;
|
|
8
|
+
export declare const DEFAULT_URL_BY_NETWORK_TYPE: Record<NetworkType, string>;
|
package/dist/constants.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.DEFAULT_URL_BY_NETWORK_TYPE = exports.RPC_LIST_BY_NETWORK_TYPE = exports.DERIVATION_PATH = exports.GHOSTMARKET_CHAIN_BY_NETWORK_TYPE = exports.GHOSTMARKET_URL_BY_NETWORK_TYPE = exports.NEO_NS_HASH = exports.TOKENS = void 0;
|
|
7
7
|
const common_json_1 = __importDefault(require("./assets/tokens/common.json"));
|
|
8
8
|
const mainnet_json_1 = __importDefault(require("./assets/tokens/mainnet.json"));
|
|
9
9
|
exports.TOKENS = {
|
|
@@ -12,11 +12,6 @@ exports.TOKENS = {
|
|
|
12
12
|
custom: common_json_1.default,
|
|
13
13
|
};
|
|
14
14
|
exports.NEO_NS_HASH = '0x50ac1c37690cc2cfc594472833cf57505d5f46de';
|
|
15
|
-
exports.DEFAULT_URL_BY_NETWORK_TYPE = {
|
|
16
|
-
mainnet: 'https://mainnet1.neo.coz.io:443',
|
|
17
|
-
testnet: 'https://testnet1.neo.coz.io:443',
|
|
18
|
-
custom: 'http://127.0.0.1:50012',
|
|
19
|
-
};
|
|
20
15
|
exports.GHOSTMARKET_URL_BY_NETWORK_TYPE = {
|
|
21
16
|
mainnet: 'https://api.ghostmarket.io/api/v2',
|
|
22
17
|
testnet: 'https://api-testnet.ghostmarket.io/api/v2',
|
|
@@ -26,3 +21,32 @@ exports.GHOSTMARKET_CHAIN_BY_NETWORK_TYPE = {
|
|
|
26
21
|
testnet: 'n3t',
|
|
27
22
|
};
|
|
28
23
|
exports.DERIVATION_PATH = "m/44'/888'/0'/0/?";
|
|
24
|
+
exports.RPC_LIST_BY_NETWORK_TYPE = {
|
|
25
|
+
mainnet: [
|
|
26
|
+
'https://mainnet1.neo.coz.io:443',
|
|
27
|
+
'https://mainnet4.neo.coz.io:443',
|
|
28
|
+
'http://seed1.neo.org:10332',
|
|
29
|
+
'http://seed2.neo.org:10332',
|
|
30
|
+
'https://mainnet2.neo.coz.io:443',
|
|
31
|
+
'https://mainnet5.neo.coz.io:443',
|
|
32
|
+
'https://mainnet3.neo.coz.io:443',
|
|
33
|
+
'https://rpc10.n3.nspcc.ru:10331',
|
|
34
|
+
'https://neo1-nodes.ghostmarket.io:443',
|
|
35
|
+
],
|
|
36
|
+
testnet: [
|
|
37
|
+
'https://testnet1.neo.coz.io:443',
|
|
38
|
+
'https://testnet2.neo.coz.io:443',
|
|
39
|
+
'https://rpc.t5.n3.nspcc.ru:20331',
|
|
40
|
+
'http://seed1t5.neo.org:20332',
|
|
41
|
+
'http://seed2t5.neo.org:20332',
|
|
42
|
+
'http://seed3t5.neo.org:20332',
|
|
43
|
+
'http://seed4t5.neo.org:20332',
|
|
44
|
+
'http://seed5t5.neo.org:20332',
|
|
45
|
+
],
|
|
46
|
+
custom: ['http://127.0.0.1:50012'],
|
|
47
|
+
};
|
|
48
|
+
exports.DEFAULT_URL_BY_NETWORK_TYPE = {
|
|
49
|
+
mainnet: exports.RPC_LIST_BY_NETWORK_TYPE.mainnet[0],
|
|
50
|
+
testnet: exports.RPC_LIST_BY_NETWORK_TYPE.testnet[0],
|
|
51
|
+
custom: exports.RPC_LIST_BY_NETWORK_TYPE.custom[0],
|
|
52
|
+
};
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cityofzion/bs-neo3",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.4",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"repository": "https://github.com/CityOfZion/blockchain-services",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"@cityofzion/neon-dappkit": "0.4.1",
|
|
20
20
|
"@cityofzion/neon-dappkit-types": "~0.3.1",
|
|
21
21
|
"@ledgerhq/hw-transport-node-hid": "~6.28.5",
|
|
22
|
-
"@cityofzion/blockchain-service": "0.11.
|
|
22
|
+
"@cityofzion/blockchain-service": "0.11.2",
|
|
23
23
|
"@cityofzion/bs-asteroid-sdk": "0.8.1"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|