@cityofzion/bs-neox 1.3.5 → 1.4.0
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/BSNeoX.d.ts +8 -6
- package/dist/BSNeoX.js +17 -7
- package/dist/constants/BSNeoXConstants.d.ts +8 -13
- package/dist/constants/BSNeoXConstants.js +18 -32
- package/dist/helpers/BSNeoXHelper.d.ts +3 -3
- package/dist/helpers/BSNeoXHelper.js +2 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/services/blockchain-data/BlockscoutBDSNeoX.d.ts +19 -14
- package/dist/services/blockchain-data/BlockscoutBDSNeoX.js +118 -133
- package/dist/services/exchange-data/FlamingoForthewinEDSNeoX.d.ts +6 -7
- package/dist/services/exchange-data/FlamingoForthewinEDSNeoX.js +9 -28
- package/dist/services/explorer/BlockscoutESNeoX.d.ts +5 -4
- package/dist/services/explorer/BlockscoutESNeoX.js +13 -5
- package/dist/services/neo3neoXBridge/Neo3NeoXBridgeService.d.ts +3 -2
- package/dist/services/neo3neoXBridge/Neo3NeoXBridgeService.js +35 -49
- package/dist/services/nft-data/GhostMarketNDSNeoX.d.ts +5 -4
- package/dist/services/nft-data/GhostMarketNDSNeoX.js +11 -4
- package/dist/types.d.ts +88 -0
- package/dist/types.js +2 -0
- package/package.json +20 -22
package/dist/BSNeoX.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { BSEthereum } from '@cityofzion/bs-ethereum';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
export declare class BSNeoX<
|
|
5
|
-
neo3NeoXBridgeService: INeo3NeoXBridgeService<
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
import { TGetLedgerTransport, INeo3NeoXBridgeService, TBSNetwork } from '@cityofzion/blockchain-service';
|
|
3
|
+
import { IBSNeoX, TBSNeoXNetworkId } from './types';
|
|
4
|
+
export declare class BSNeoX<N extends string = string> extends BSEthereum<N, TBSNeoXNetworkId> implements IBSNeoX<N> {
|
|
5
|
+
neo3NeoXBridgeService: INeo3NeoXBridgeService<N>;
|
|
6
|
+
readonly defaultNetwork: TBSNetwork<TBSNeoXNetworkId>;
|
|
7
|
+
readonly availableNetworks: TBSNetwork<TBSNeoXNetworkId>[];
|
|
8
|
+
constructor(name: N, network?: TBSNetwork<TBSNeoXNetworkId>, getLedgerTransport?: TGetLedgerTransport<N>);
|
|
9
|
+
setNetwork(network: TBSNetwork<TBSNeoXNetworkId>): void;
|
|
8
10
|
}
|
package/dist/BSNeoX.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.BSNeoX = void 0;
|
|
4
4
|
const bs_ethereum_1 = require("@cityofzion/bs-ethereum");
|
|
5
5
|
const BSNeoXConstants_1 = require("./constants/BSNeoXConstants");
|
|
6
|
+
const blockchain_service_1 = require("@cityofzion/blockchain-service");
|
|
6
7
|
const BlockscoutBDSNeoX_1 = require("./services/blockchain-data/BlockscoutBDSNeoX");
|
|
7
8
|
const FlamingoForthewinEDSNeoX_1 = require("./services/exchange-data/FlamingoForthewinEDSNeoX");
|
|
8
9
|
const BlockscoutESNeoX_1 = require("./services/explorer/BlockscoutESNeoX");
|
|
@@ -10,20 +11,29 @@ const GhostMarketNDSNeoX_1 = require("./services/nft-data/GhostMarketNDSNeoX");
|
|
|
10
11
|
const Neo3NeoXBridgeService_1 = require("./services/neo3neoXBridge/Neo3NeoXBridgeService");
|
|
11
12
|
class BSNeoX extends bs_ethereum_1.BSEthereum {
|
|
12
13
|
constructor(name, network, getLedgerTransport) {
|
|
13
|
-
|
|
14
|
-
super(name, network, getLedgerTransport);
|
|
14
|
+
super(name, undefined, undefined, getLedgerTransport);
|
|
15
15
|
this.tokens = [BSNeoXConstants_1.BSNeoXConstants.NATIVE_ASSET];
|
|
16
16
|
this.nativeTokens = [BSNeoXConstants_1.BSNeoXConstants.NATIVE_ASSET];
|
|
17
17
|
this.feeToken = BSNeoXConstants_1.BSNeoXConstants.NATIVE_ASSET;
|
|
18
|
+
this.availableNetworks = BSNeoXConstants_1.BSNeoXConstants.ALL_NETWORKS;
|
|
19
|
+
this.defaultNetwork = BSNeoXConstants_1.BSNeoXConstants.MAINNET_NETWORK;
|
|
20
|
+
this.setNetwork(network !== null && network !== void 0 ? network : this.defaultNetwork);
|
|
18
21
|
}
|
|
19
22
|
setNetwork(network) {
|
|
23
|
+
const availableURLs = BSNeoXConstants_1.BSNeoXConstants.RPC_LIST_BY_NETWORK_ID[network.id] || [];
|
|
24
|
+
const isValidNetwork = blockchain_service_1.BSUtilsHelper.validateNetwork(network, this.availableNetworks, availableURLs);
|
|
25
|
+
if (!isValidNetwork) {
|
|
26
|
+
throw new Error(`Network with id ${network.id} is not available for ${this.name}`);
|
|
27
|
+
}
|
|
20
28
|
this.network = network;
|
|
21
|
-
this.
|
|
22
|
-
this.nftDataService = new GhostMarketNDSNeoX_1.GhostMarketNDSNeoX(
|
|
23
|
-
this.explorerService = new BlockscoutESNeoX_1.BlockscoutESNeoX(
|
|
24
|
-
this.exchangeDataService = new FlamingoForthewinEDSNeoX_1.FlamingoForthewinEDSNeoX(
|
|
29
|
+
this.availableNetworkURLs = availableURLs;
|
|
30
|
+
this.nftDataService = new GhostMarketNDSNeoX_1.GhostMarketNDSNeoX(this);
|
|
31
|
+
this.explorerService = new BlockscoutESNeoX_1.BlockscoutESNeoX(this);
|
|
32
|
+
this.exchangeDataService = new FlamingoForthewinEDSNeoX_1.FlamingoForthewinEDSNeoX(this);
|
|
25
33
|
this.neo3NeoXBridgeService = new Neo3NeoXBridgeService_1.Neo3NeoXBridgeService(this);
|
|
26
|
-
this.blockchainDataService = new BlockscoutBDSNeoX_1.BlockscoutBDSNeoX(
|
|
34
|
+
this.blockchainDataService = new BlockscoutBDSNeoX_1.BlockscoutBDSNeoX(this);
|
|
35
|
+
this.tokenService = new bs_ethereum_1.TokenServiceEthereum();
|
|
36
|
+
this.walletConnectService = new bs_ethereum_1.WalletConnectServiceEthereum(this);
|
|
27
37
|
}
|
|
28
38
|
}
|
|
29
39
|
exports.BSNeoX = BSNeoX;
|
|
@@ -1,15 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { TBSNetwork, TBSToken } from '@cityofzion/blockchain-service';
|
|
2
|
+
import { TBSNeoXNetworkId } from '../types';
|
|
3
3
|
export declare class BSNeoXConstants {
|
|
4
|
-
|
|
5
|
-
static
|
|
6
|
-
static
|
|
7
|
-
static
|
|
8
|
-
static
|
|
9
|
-
static
|
|
10
|
-
static ALL_NETWORK_IDS: BSNeoXNetworkId[];
|
|
11
|
-
static MAINNET_NETWORKS: Network<BSNeoXNetworkId>[];
|
|
12
|
-
static TESTNET_NETWORKS: Network<BSNeoXNetworkId>[];
|
|
13
|
-
static ALL_NETWORK: Network<BSNeoXNetworkId>[];
|
|
14
|
-
static DEFAULT_NETWORK: Network<BSNeoXNetworkId>;
|
|
4
|
+
static readonly NATIVE_ASSET: TBSToken;
|
|
5
|
+
static readonly NEO_TOKEN: TBSToken;
|
|
6
|
+
static readonly RPC_LIST_BY_NETWORK_ID: Record<TBSNeoXNetworkId, string[]>;
|
|
7
|
+
static readonly MAINNET_NETWORK: TBSNetwork<TBSNeoXNetworkId>;
|
|
8
|
+
static readonly TESTNET_NETWORK: TBSNetwork<TBSNeoXNetworkId>;
|
|
9
|
+
static readonly ALL_NETWORKS: TBSNetwork<TBSNeoXNetworkId>[];
|
|
15
10
|
}
|
|
@@ -1,51 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
4
|
-
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");
|
|
5
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
6
|
-
};
|
|
7
|
-
var _a, _BSNeoXConstants_tokenService;
|
|
2
|
+
var _a;
|
|
8
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
4
|
exports.BSNeoXConstants = void 0;
|
|
10
|
-
const bs_ethereum_1 = require("@cityofzion/bs-ethereum");
|
|
11
5
|
class BSNeoXConstants {
|
|
12
6
|
}
|
|
13
7
|
exports.BSNeoXConstants = BSNeoXConstants;
|
|
14
8
|
_a = BSNeoXConstants;
|
|
15
|
-
|
|
16
|
-
BSNeoXConstants.NATIVE_ASSET = __classPrivateFieldGet(_a, _a, "f", _BSNeoXConstants_tokenService).normalizeToken({
|
|
9
|
+
BSNeoXConstants.NATIVE_ASSET = {
|
|
17
10
|
symbol: 'GAS',
|
|
18
11
|
name: 'GAS',
|
|
19
12
|
decimals: 18,
|
|
20
13
|
hash: '0x',
|
|
21
|
-
}
|
|
22
|
-
BSNeoXConstants.NEO_TOKEN =
|
|
14
|
+
};
|
|
15
|
+
BSNeoXConstants.NEO_TOKEN = {
|
|
23
16
|
name: 'NEO',
|
|
24
17
|
symbol: 'NEO',
|
|
25
18
|
decimals: 18,
|
|
26
19
|
hash: '0xc28736dc83f4fd43d6fb832Fd93c3eE7bB26828f',
|
|
27
|
-
}
|
|
20
|
+
};
|
|
28
21
|
BSNeoXConstants.RPC_LIST_BY_NETWORK_ID = {
|
|
29
22
|
'47763': ['https://mainnet-1.rpc.banelabs.org', 'https://mainnet-2.rpc.banelabs.org'],
|
|
30
23
|
'12227332': ['https://testnet.rpc.banelabs.org', 'https://neoxt4seed1.ngd.network'],
|
|
31
24
|
};
|
|
32
|
-
BSNeoXConstants.
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
]
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
name: 'NeoX Testnet',
|
|
46
|
-
url: _a.RPC_LIST_BY_NETWORK_ID['12227332'][0],
|
|
47
|
-
},
|
|
48
|
-
];
|
|
49
|
-
BSNeoXConstants.ALL_NETWORK = [..._a.MAINNET_NETWORKS, ..._a.TESTNET_NETWORKS];
|
|
50
|
-
// If tou change this, make sure to update the tests accordingly
|
|
51
|
-
BSNeoXConstants.DEFAULT_NETWORK = _a.MAINNET_NETWORKS[0];
|
|
25
|
+
BSNeoXConstants.MAINNET_NETWORK = {
|
|
26
|
+
id: '47763',
|
|
27
|
+
name: 'NeoX Mainnet',
|
|
28
|
+
url: _a.RPC_LIST_BY_NETWORK_ID['47763'][0],
|
|
29
|
+
type: 'mainnet',
|
|
30
|
+
};
|
|
31
|
+
BSNeoXConstants.TESTNET_NETWORK = {
|
|
32
|
+
id: '12227332',
|
|
33
|
+
name: 'NeoX Testnet',
|
|
34
|
+
url: _a.RPC_LIST_BY_NETWORK_ID['12227332'][0],
|
|
35
|
+
type: 'testnet',
|
|
36
|
+
};
|
|
37
|
+
BSNeoXConstants.ALL_NETWORKS = [_a.MAINNET_NETWORK, _a.TESTNET_NETWORK];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { TBSNetwork } from '@cityofzion/blockchain-service';
|
|
2
|
+
import { TBSNeoXNetworkId } from '../types';
|
|
3
3
|
export declare class BSNeoXHelper {
|
|
4
|
-
static
|
|
4
|
+
static isMainnetNetwork(network: TBSNetwork<TBSNeoXNetworkId>): boolean;
|
|
5
5
|
}
|
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.BSNeoXHelper = void 0;
|
|
4
4
|
const BSNeoXConstants_1 = require("../constants/BSNeoXConstants");
|
|
5
5
|
class BSNeoXHelper {
|
|
6
|
-
static
|
|
7
|
-
return BSNeoXConstants_1.BSNeoXConstants.
|
|
6
|
+
static isMainnetNetwork(network) {
|
|
7
|
+
return network.id === BSNeoXConstants_1.BSNeoXConstants.MAINNET_NETWORK.id && network.type === 'mainnet';
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
10
|
exports.BSNeoXHelper = BSNeoXHelper;
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -20,3 +20,4 @@ __exportStar(require("./services/blockchain-data/BlockscoutBDSNeoX"), exports);
|
|
|
20
20
|
__exportStar(require("./services/exchange-data/FlamingoForthewinEDSNeoX"), exports);
|
|
21
21
|
__exportStar(require("./services/explorer/BlockscoutESNeoX"), exports);
|
|
22
22
|
__exportStar(require("./services/nft-data/GhostMarketNDSNeoX"), exports);
|
|
23
|
+
__exportStar(require("./types"), exports);
|
|
@@ -1,18 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
1
|
+
import { TBalanceResponse, ContractResponse, TExportTransactionsByAddressParams, TFullTransactionsByAddressParams, TFullTransactionsByAddressResponse, TBSNetwork, TBSToken, TTransactionResponse, TTransactionsByAddressParams, TTransactionsByAddressResponse } from '@cityofzion/blockchain-service';
|
|
2
|
+
import { AxiosInstance } from 'axios';
|
|
3
|
+
import { RpcBDSEthereum } from '@cityofzion/bs-ethereum';
|
|
4
|
+
import { IBSNeoX, TBSNeoXNetworkId } from '../../types';
|
|
5
|
+
export declare class BlockscoutBDSNeoX<N extends string> extends RpcBDSEthereum<N, TBSNeoXNetworkId, IBSNeoX<N>> {
|
|
5
6
|
#private;
|
|
6
|
-
static BASE_URL_BY_CHAIN_ID: Partial<Record<
|
|
7
|
-
static
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
static readonly BASE_URL_BY_CHAIN_ID: Partial<Record<TBSNeoXNetworkId, string>>;
|
|
8
|
+
static readonly FULL_TRANSACTIONS_SUPPORTED_NETWORKS_IDS: TBSNeoXNetworkId[];
|
|
9
|
+
static readonly FULL_TRANSACTIONS_ERC721_STANDARDS: string[];
|
|
10
|
+
static readonly FULL_TRANSACTIONS_ERC1155_STANDARDS: string[];
|
|
11
|
+
static readonly FULL_TRANSACTIONS_ERC20_STANDARDS: string[];
|
|
12
|
+
static getClient(network: TBSNetwork<TBSNeoXNetworkId>): AxiosInstance;
|
|
13
|
+
readonly maxTimeToConfirmTransactionInMs: number;
|
|
14
|
+
constructor(service: IBSNeoX<N>);
|
|
15
|
+
getTransaction(txid: string): Promise<TTransactionResponse>;
|
|
16
|
+
getTransactionsByAddress(params: TTransactionsByAddressParams): Promise<TTransactionsByAddressResponse>;
|
|
17
|
+
getFullTransactionsByAddress({ nextCursor, ...params }: TFullTransactionsByAddressParams): Promise<TFullTransactionsByAddressResponse>;
|
|
18
|
+
exportFullTransactionsByAddress(params: TExportTransactionsByAddressParams): Promise<string>;
|
|
14
19
|
getContract(contractHash: string): Promise<ContractResponse>;
|
|
15
|
-
getTokenInfo(tokenHash: string): Promise<
|
|
16
|
-
getBalance(address: string): Promise<
|
|
20
|
+
getTokenInfo(tokenHash: string): Promise<TBSToken>;
|
|
21
|
+
getBalance(address: string): Promise<TBalanceResponse[]>;
|
|
17
22
|
getBlockHeight(): Promise<number>;
|
|
18
23
|
}
|
|
@@ -8,12 +8,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
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
11
|
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
18
12
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
19
13
|
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");
|
|
@@ -33,7 +27,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
33
27
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
34
28
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
35
29
|
};
|
|
36
|
-
var _BlockscoutBDSNeoX_instances,
|
|
30
|
+
var _BlockscoutBDSNeoX_instances, _a, _BlockscoutBDSNeoX_apiInstance, _BlockscoutBDSNeoX_api_get, _BlockscoutBDSNeoX_getBridgeNeo3NeoXDataByBlockscoutTransaction;
|
|
37
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
32
|
exports.BlockscoutBDSNeoX = void 0;
|
|
39
33
|
const blockchain_service_1 = require("@cityofzion/blockchain-service");
|
|
@@ -44,38 +38,29 @@ const bs_ethereum_1 = require("@cityofzion/bs-ethereum");
|
|
|
44
38
|
const BSNeoXConstants_1 = require("../../constants/BSNeoXConstants");
|
|
45
39
|
const bridge_1 = require("../../assets/abis/bridge");
|
|
46
40
|
const Neo3NeoXBridgeService_1 = require("../neo3neoXBridge/Neo3NeoXBridgeService");
|
|
47
|
-
const
|
|
48
|
-
class BlockscoutBDSNeoX extends bs_ethereum_1.
|
|
41
|
+
const bs_neo3_1 = require("@cityofzion/bs-neo3");
|
|
42
|
+
class BlockscoutBDSNeoX extends bs_ethereum_1.RpcBDSEthereum {
|
|
49
43
|
static getClient(network) {
|
|
50
|
-
const baseURL =
|
|
51
|
-
if (!baseURL)
|
|
44
|
+
const baseURL = _a.BASE_URL_BY_CHAIN_ID[network.id];
|
|
45
|
+
if (!baseURL)
|
|
52
46
|
throw new Error('Unsupported network');
|
|
53
|
-
}
|
|
54
|
-
return axios_1.default.create({
|
|
55
|
-
baseURL,
|
|
56
|
-
});
|
|
47
|
+
return axios_1.default.create({ baseURL });
|
|
57
48
|
}
|
|
58
|
-
constructor(
|
|
59
|
-
super(
|
|
49
|
+
constructor(service) {
|
|
50
|
+
super(service);
|
|
60
51
|
_BlockscoutBDSNeoX_instances.add(this);
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
_BlockscoutBDSNeoX_neo3NeoXBridgeService.set(this, void 0);
|
|
64
|
-
this.maxTimeToConfirmTransactionInMs = 1000 * 60 * 5;
|
|
65
|
-
__classPrivateFieldSet(this, _BlockscoutBDSNeoX_nftDataService, nftDataService, "f");
|
|
66
|
-
__classPrivateFieldSet(this, _BlockscoutBDSNeoX_explorerService, explorerService, "f");
|
|
67
|
-
__classPrivateFieldSet(this, _BlockscoutBDSNeoX_neo3NeoXBridgeService, neo3NeoXBridgeService, "f");
|
|
52
|
+
this.maxTimeToConfirmTransactionInMs = 1000 * 60 * 5; // 5 minutes
|
|
53
|
+
_BlockscoutBDSNeoX_apiInstance.set(this, void 0);
|
|
68
54
|
}
|
|
69
55
|
getTransaction(txid) {
|
|
70
|
-
var _a;
|
|
71
56
|
return __awaiter(this, void 0, void 0, function* () {
|
|
72
|
-
|
|
73
|
-
const { data } = yield
|
|
57
|
+
var _b;
|
|
58
|
+
const { data } = yield __classPrivateFieldGet(this, _BlockscoutBDSNeoX_instances, "a", _BlockscoutBDSNeoX_api_get).get(`/transactions/${txid}`);
|
|
74
59
|
if (!data || 'message' in data) {
|
|
75
60
|
throw new Error('Transaction not found');
|
|
76
61
|
}
|
|
77
62
|
const nativeToken = BSNeoXConstants_1.BSNeoXConstants.NATIVE_ASSET;
|
|
78
|
-
const to = (
|
|
63
|
+
const to = (_b = data.to) === null || _b === void 0 ? void 0 : _b.hash;
|
|
79
64
|
const transfers = [];
|
|
80
65
|
const hasNativeTokenBeingTransferred = data.value !== '0';
|
|
81
66
|
if (hasNativeTokenBeingTransferred) {
|
|
@@ -98,7 +83,7 @@ class BlockscoutBDSNeoX extends bs_ethereum_1.DoraBDSEthereum {
|
|
|
98
83
|
to: tokenTransfer.to.hash,
|
|
99
84
|
type: 'token',
|
|
100
85
|
contractHash: tokenTransfer.token.address,
|
|
101
|
-
token: this.
|
|
86
|
+
token: this._service.tokenService.normalizeToken({
|
|
102
87
|
symbol: tokenTransfer.token.symbol,
|
|
103
88
|
name: tokenTransfer.token.name,
|
|
104
89
|
hash: tokenTransfer.token.address,
|
|
@@ -128,17 +113,18 @@ class BlockscoutBDSNeoX extends bs_ethereum_1.DoraBDSEthereum {
|
|
|
128
113
|
type: 'default',
|
|
129
114
|
};
|
|
130
115
|
if (to === Neo3NeoXBridgeService_1.Neo3NeoXBridgeService.BRIDGE_SCRIPT_HASH) {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
116
|
+
yield blockchain_service_1.BSPromisesHelper.tryCatch(() => {
|
|
117
|
+
const bridgeNeo3NeoXData = __classPrivateFieldGet(this, _BlockscoutBDSNeoX_instances, "m", _BlockscoutBDSNeoX_getBridgeNeo3NeoXDataByBlockscoutTransaction).call(this, data);
|
|
118
|
+
if (bridgeNeo3NeoXData)
|
|
119
|
+
transaction = Object.assign(Object.assign({}, transaction), { type: 'bridgeNeo3NeoX', data: bridgeNeo3NeoXData });
|
|
120
|
+
});
|
|
134
121
|
}
|
|
135
122
|
return transaction;
|
|
136
123
|
});
|
|
137
124
|
}
|
|
138
125
|
getTransactionsByAddress(params) {
|
|
139
126
|
return __awaiter(this, void 0, void 0, function* () {
|
|
140
|
-
const
|
|
141
|
-
const { data } = yield client.get(`/addresses/${params.address}/transactions`, {
|
|
127
|
+
const { data } = yield __classPrivateFieldGet(this, _BlockscoutBDSNeoX_instances, "a", _BlockscoutBDSNeoX_api_get).get(`/addresses/${params.address}/transactions`, {
|
|
142
128
|
params: {
|
|
143
129
|
next_page_params: params.nextPageParams,
|
|
144
130
|
},
|
|
@@ -149,9 +135,9 @@ class BlockscoutBDSNeoX extends bs_ethereum_1.DoraBDSEthereum {
|
|
|
149
135
|
const nativeToken = BSNeoXConstants_1.BSNeoXConstants.NATIVE_ASSET;
|
|
150
136
|
const transactions = [];
|
|
151
137
|
const promises = data.items.map((item) => __awaiter(this, void 0, void 0, function* () {
|
|
152
|
-
var
|
|
138
|
+
var _b;
|
|
153
139
|
const transfers = [];
|
|
154
|
-
const to = (
|
|
140
|
+
const to = (_b = item.to) === null || _b === void 0 ? void 0 : _b.hash;
|
|
155
141
|
const hasNativeTokenBeingTransferred = item.value !== '0';
|
|
156
142
|
if (hasNativeTokenBeingTransferred) {
|
|
157
143
|
transfers.push({
|
|
@@ -182,7 +168,7 @@ class BlockscoutBDSNeoX extends bs_ethereum_1.DoraBDSEthereum {
|
|
|
182
168
|
token,
|
|
183
169
|
});
|
|
184
170
|
}
|
|
185
|
-
catch (
|
|
171
|
+
catch (_c) {
|
|
186
172
|
/* empty */
|
|
187
173
|
}
|
|
188
174
|
}
|
|
@@ -209,29 +195,27 @@ class BlockscoutBDSNeoX extends bs_ethereum_1.DoraBDSEthereum {
|
|
|
209
195
|
};
|
|
210
196
|
});
|
|
211
197
|
}
|
|
212
|
-
getFullTransactionsByAddress(
|
|
213
|
-
var _b, _c;
|
|
214
|
-
var { nextCursor } = _a, params = __rest(_a, ["nextCursor"]);
|
|
198
|
+
getFullTransactionsByAddress(_b) {
|
|
215
199
|
return __awaiter(this, void 0, void 0, function* () {
|
|
216
|
-
|
|
200
|
+
var _c, _d;
|
|
201
|
+
var { nextCursor } = _b, params = __rest(_b, ["nextCursor"]);
|
|
202
|
+
blockchain_service_1.BSFullTransactionsByAddressHelper.validateFullTransactionsByAddressParams(Object.assign({ service: this._service, supportedNetworksIds: _a.FULL_TRANSACTIONS_SUPPORTED_NETWORKS_IDS }, params));
|
|
217
203
|
const data = [];
|
|
218
204
|
const response = yield dora_ts_1.api.NeoXREST.getFullTransactionsByAddress({
|
|
219
205
|
address: params.address,
|
|
220
206
|
timestampFrom: params.dateFrom,
|
|
221
207
|
timestampTo: params.dateTo,
|
|
222
|
-
network:
|
|
208
|
+
network: this._service.network.type,
|
|
223
209
|
cursor: nextCursor,
|
|
224
|
-
pageLimit: (
|
|
210
|
+
pageLimit: (_c = params.pageSize) !== null && _c !== void 0 ? _c : 50,
|
|
225
211
|
});
|
|
226
|
-
const items = (
|
|
227
|
-
const
|
|
228
|
-
const
|
|
229
|
-
const
|
|
230
|
-
const
|
|
231
|
-
const
|
|
232
|
-
|
|
233
|
-
const itemPromises = items.map((_d, index) => __awaiter(this, void 0, void 0, function* () {
|
|
234
|
-
var { networkFeeAmount, systemFeeAmount } = _d, item = __rest(_d, ["networkFeeAmount", "systemFeeAmount"]);
|
|
212
|
+
const items = (_d = response.data) !== null && _d !== void 0 ? _d : [];
|
|
213
|
+
const addressTemplateUrl = this._service.explorerService.getAddressTemplateUrl();
|
|
214
|
+
const txTemplateUrl = this._service.explorerService.getTxTemplateUrl();
|
|
215
|
+
const nftTemplateUrl = this._service.explorerService.getNftTemplateUrl();
|
|
216
|
+
const contractTemplateUrl = this._service.explorerService.getContractTemplateUrl();
|
|
217
|
+
const itemPromises = items.map((_b, index) => __awaiter(this, void 0, void 0, function* () {
|
|
218
|
+
var { networkFeeAmount, systemFeeAmount } = _b, item = __rest(_b, ["networkFeeAmount", "systemFeeAmount"]);
|
|
235
219
|
const txId = item.transactionID;
|
|
236
220
|
let newItem = {
|
|
237
221
|
txId,
|
|
@@ -241,35 +225,33 @@ class BlockscoutBDSNeoX extends bs_ethereum_1.DoraBDSEthereum {
|
|
|
241
225
|
invocationCount: item.invocationCount,
|
|
242
226
|
notificationCount: item.notificationCount,
|
|
243
227
|
networkFeeAmount: networkFeeAmount
|
|
244
|
-
? blockchain_service_1.BSBigNumberHelper.format(networkFeeAmount, { decimals:
|
|
228
|
+
? blockchain_service_1.BSBigNumberHelper.format(networkFeeAmount, { decimals: BSNeoXConstants_1.BSNeoXConstants.NATIVE_ASSET.decimals })
|
|
245
229
|
: undefined,
|
|
246
230
|
systemFeeAmount: systemFeeAmount
|
|
247
|
-
? blockchain_service_1.BSBigNumberHelper.format(systemFeeAmount, { decimals:
|
|
231
|
+
? blockchain_service_1.BSBigNumberHelper.format(systemFeeAmount, { decimals: BSNeoXConstants_1.BSNeoXConstants.NATIVE_ASSET.decimals })
|
|
248
232
|
: undefined,
|
|
249
233
|
events: [],
|
|
250
234
|
type: 'default',
|
|
251
235
|
};
|
|
252
236
|
const eventPromises = item.events.map((event, eventIndex) => __awaiter(this, void 0, void 0, function* () {
|
|
253
|
-
var
|
|
254
|
-
let nftEvent;
|
|
255
|
-
let assetEvent;
|
|
237
|
+
var _b, _c, _d, _e, _f, _g, _h;
|
|
256
238
|
const { methodName, tokenID: tokenHash, contractHash } = event;
|
|
257
|
-
const
|
|
258
|
-
const
|
|
259
|
-
const
|
|
260
|
-
const
|
|
261
|
-
const isErc721 = this._supportedErc721Standards.includes(standard);
|
|
262
|
-
const isErc20 = this._supportedErc20Standards.includes(standard);
|
|
239
|
+
const standard = (_d = (_c = (_b = event.supportedStandards) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.toLowerCase()) !== null && _d !== void 0 ? _d : '';
|
|
240
|
+
const isErc1155 = _a.FULL_TRANSACTIONS_ERC1155_STANDARDS.includes(standard);
|
|
241
|
+
const isErc721 = _a.FULL_TRANSACTIONS_ERC721_STANDARDS.includes(standard);
|
|
242
|
+
const isErc20 = _a.FULL_TRANSACTIONS_ERC20_STANDARDS.includes(standard);
|
|
263
243
|
const isNft = (isErc1155 || isErc721) && !!tokenHash;
|
|
244
|
+
const from = (_e = event.from) !== null && _e !== void 0 ? _e : undefined;
|
|
264
245
|
const fromUrl = from ? addressTemplateUrl === null || addressTemplateUrl === void 0 ? void 0 : addressTemplateUrl.replace('{address}', from) : undefined;
|
|
246
|
+
const to = (_f = event.to) !== null && _f !== void 0 ? _f : undefined;
|
|
265
247
|
const toUrl = to ? addressTemplateUrl === null || addressTemplateUrl === void 0 ? void 0 : addressTemplateUrl.replace('{address}', to) : undefined;
|
|
266
248
|
const contractHashUrl = contractHash ? contractTemplateUrl === null || contractTemplateUrl === void 0 ? void 0 : contractTemplateUrl.replace('{hash}', contractHash) : undefined;
|
|
267
249
|
if (isNft) {
|
|
268
|
-
const [nft] = yield blockchain_service_1.BSPromisesHelper.tryCatch(() =>
|
|
250
|
+
const [nft] = yield blockchain_service_1.BSPromisesHelper.tryCatch(() => this._service.nftDataService.getNft({ collectionHash: contractHash, tokenHash }));
|
|
269
251
|
const nftUrl = contractHash
|
|
270
252
|
? nftTemplateUrl === null || nftTemplateUrl === void 0 ? void 0 : nftTemplateUrl.replace('{collectionHash}', contractHash).replace('{tokenHash}', tokenHash)
|
|
271
253
|
: undefined;
|
|
272
|
-
|
|
254
|
+
newItem.events.splice(eventIndex, 0, {
|
|
273
255
|
eventType: 'nft',
|
|
274
256
|
amount: undefined,
|
|
275
257
|
methodName,
|
|
@@ -284,36 +266,35 @@ class BlockscoutBDSNeoX extends bs_ethereum_1.DoraBDSEthereum {
|
|
|
284
266
|
nftImageUrl: nft === null || nft === void 0 ? void 0 : nft.image,
|
|
285
267
|
nftUrl,
|
|
286
268
|
name: nft === null || nft === void 0 ? void 0 : nft.name,
|
|
287
|
-
collectionName: (
|
|
288
|
-
};
|
|
289
|
-
|
|
290
|
-
else {
|
|
291
|
-
const [token] = yield blockchain_service_1.BSPromisesHelper.tryCatch(() => this.getTokenInfo(contractHash));
|
|
292
|
-
assetEvent = {
|
|
293
|
-
eventType: 'token',
|
|
294
|
-
amount: event.amount
|
|
295
|
-
? blockchain_service_1.BSBigNumberHelper.format(event.amount, { decimals: (_l = token === null || token === void 0 ? void 0 : token.decimals) !== null && _l !== void 0 ? _l : event.tokenDecimals })
|
|
296
|
-
: undefined,
|
|
297
|
-
methodName,
|
|
298
|
-
from,
|
|
299
|
-
fromUrl,
|
|
300
|
-
to,
|
|
301
|
-
toUrl,
|
|
302
|
-
contractHash,
|
|
303
|
-
contractHashUrl,
|
|
304
|
-
token: token !== null && token !== void 0 ? token : undefined,
|
|
305
|
-
tokenType: isErc20 ? 'erc-20' : 'generic',
|
|
306
|
-
};
|
|
269
|
+
collectionName: (_g = nft === null || nft === void 0 ? void 0 : nft.collection) === null || _g === void 0 ? void 0 : _g.name,
|
|
270
|
+
});
|
|
271
|
+
return;
|
|
307
272
|
}
|
|
273
|
+
const [token] = yield blockchain_service_1.BSPromisesHelper.tryCatch(() => this.getTokenInfo(contractHash));
|
|
274
|
+
newItem.events.splice(eventIndex, 0, {
|
|
275
|
+
eventType: 'token',
|
|
276
|
+
amount: event.amount
|
|
277
|
+
? blockchain_service_1.BSBigNumberHelper.format(event.amount, { decimals: (_h = token === null || token === void 0 ? void 0 : token.decimals) !== null && _h !== void 0 ? _h : event.tokenDecimals })
|
|
278
|
+
: undefined,
|
|
279
|
+
methodName,
|
|
280
|
+
from,
|
|
281
|
+
fromUrl,
|
|
282
|
+
to,
|
|
283
|
+
toUrl,
|
|
284
|
+
contractHash,
|
|
285
|
+
contractHashUrl,
|
|
286
|
+
token: token !== null && token !== void 0 ? token : undefined,
|
|
287
|
+
tokenType: isErc20 ? 'erc-20' : 'generic',
|
|
288
|
+
});
|
|
289
|
+
// Verify if the event is a bridgeNeo3NeoX event
|
|
308
290
|
if (newItem.type === 'default' && to === Neo3NeoXBridgeService_1.Neo3NeoXBridgeService.BRIDGE_SCRIPT_HASH) {
|
|
309
|
-
|
|
310
|
-
const response = yield
|
|
311
|
-
|
|
291
|
+
yield blockchain_service_1.BSPromisesHelper.tryCatch(() => __awaiter(this, void 0, void 0, function* () {
|
|
292
|
+
const response = yield __classPrivateFieldGet(this, _BlockscoutBDSNeoX_instances, "a", _BlockscoutBDSNeoX_api_get).get(`/transactions/${txId}`);
|
|
293
|
+
const bridgeNeo3NeoXData = __classPrivateFieldGet(this, _BlockscoutBDSNeoX_instances, "m", _BlockscoutBDSNeoX_getBridgeNeo3NeoXDataByBlockscoutTransaction).call(this, response.data);
|
|
294
|
+
if (bridgeNeo3NeoXData)
|
|
295
|
+
newItem = Object.assign(Object.assign({}, newItem), { type: 'bridgeNeo3NeoX', data: bridgeNeo3NeoXData });
|
|
312
296
|
}));
|
|
313
|
-
if (data)
|
|
314
|
-
newItem = Object.assign(Object.assign({}, newItem), { type: 'bridgeNeo3NeoX', data });
|
|
315
297
|
}
|
|
316
|
-
newItem.events.splice(eventIndex, 0, isNft ? nftEvent : assetEvent);
|
|
317
298
|
}));
|
|
318
299
|
yield Promise.allSettled(eventPromises);
|
|
319
300
|
data.splice(index, 0, newItem);
|
|
@@ -324,34 +305,33 @@ class BlockscoutBDSNeoX extends bs_ethereum_1.DoraBDSEthereum {
|
|
|
324
305
|
}
|
|
325
306
|
exportFullTransactionsByAddress(params) {
|
|
326
307
|
return __awaiter(this, void 0, void 0, function* () {
|
|
327
|
-
this.
|
|
308
|
+
blockchain_service_1.BSFullTransactionsByAddressHelper.validateFullTransactionsByAddressParams(Object.assign({ service: this._service, supportedNetworksIds: _a.FULL_TRANSACTIONS_SUPPORTED_NETWORKS_IDS }, params));
|
|
328
309
|
return yield dora_ts_1.api.NeoXREST.exportFullTransactionsByAddress({
|
|
329
310
|
address: params.address,
|
|
330
311
|
timestampFrom: params.dateFrom,
|
|
331
312
|
timestampTo: params.dateTo,
|
|
332
|
-
network:
|
|
313
|
+
network: this._service.network.type,
|
|
333
314
|
});
|
|
334
315
|
});
|
|
335
316
|
}
|
|
336
317
|
getContract(contractHash) {
|
|
337
318
|
return __awaiter(this, void 0, void 0, function* () {
|
|
338
319
|
try {
|
|
339
|
-
const
|
|
340
|
-
const { data } = yield client.get(`/smart-contracts/${contractHash}`);
|
|
320
|
+
const { data } = yield __classPrivateFieldGet(this, _BlockscoutBDSNeoX_instances, "a", _BlockscoutBDSNeoX_api_get).get(`/smart-contracts/${contractHash}`);
|
|
341
321
|
if (!data || 'message' in data) {
|
|
342
322
|
throw new Error('Contract not found');
|
|
343
323
|
}
|
|
344
324
|
const methods = [];
|
|
345
325
|
data.abi.forEach(abi => {
|
|
346
|
-
var
|
|
326
|
+
var _b, _c;
|
|
347
327
|
if (abi.type !== 'function')
|
|
348
328
|
return;
|
|
349
|
-
const parameters = (
|
|
329
|
+
const parameters = (_b = abi.inputs) === null || _b === void 0 ? void 0 : _b.map(param => ({
|
|
350
330
|
name: param.name,
|
|
351
331
|
type: param.type,
|
|
352
332
|
}));
|
|
353
333
|
methods.push({
|
|
354
|
-
name: (
|
|
334
|
+
name: (_c = abi.name) !== null && _c !== void 0 ? _c : '',
|
|
355
335
|
parameters: parameters !== null && parameters !== void 0 ? parameters : [],
|
|
356
336
|
});
|
|
357
337
|
});
|
|
@@ -361,14 +341,14 @@ class BlockscoutBDSNeoX extends bs_ethereum_1.DoraBDSEthereum {
|
|
|
361
341
|
methods,
|
|
362
342
|
};
|
|
363
343
|
}
|
|
364
|
-
catch (
|
|
344
|
+
catch (_b) {
|
|
365
345
|
throw new Error('Contract not found or not supported');
|
|
366
346
|
}
|
|
367
347
|
});
|
|
368
348
|
}
|
|
369
349
|
getTokenInfo(tokenHash) {
|
|
370
350
|
return __awaiter(this, void 0, void 0, function* () {
|
|
371
|
-
const normalizedHash = this.
|
|
351
|
+
const normalizedHash = this._service.tokenService.normalizeHash(tokenHash);
|
|
372
352
|
const nativeAsset = BSNeoXConstants_1.BSNeoXConstants.NATIVE_ASSET;
|
|
373
353
|
if (nativeAsset.hash === normalizedHash) {
|
|
374
354
|
return nativeAsset;
|
|
@@ -377,15 +357,14 @@ class BlockscoutBDSNeoX extends bs_ethereum_1.DoraBDSEthereum {
|
|
|
377
357
|
if (cachedToken) {
|
|
378
358
|
return cachedToken;
|
|
379
359
|
}
|
|
380
|
-
const
|
|
381
|
-
const { data } = yield client.get(`/tokens/${tokenHash}`);
|
|
360
|
+
const { data } = yield __classPrivateFieldGet(this, _BlockscoutBDSNeoX_instances, "a", _BlockscoutBDSNeoX_api_get).get(`/tokens/${tokenHash}`);
|
|
382
361
|
if (!data || 'message' in data) {
|
|
383
362
|
throw new Error('Token not found');
|
|
384
363
|
}
|
|
385
364
|
if (data.type !== 'ERC-20') {
|
|
386
365
|
throw new Error('Token is not an ERC-20 token');
|
|
387
366
|
}
|
|
388
|
-
const token = this.
|
|
367
|
+
const token = this._service.tokenService.normalizeToken({
|
|
389
368
|
decimals: data.decimals ? parseInt(data.decimals) : bs_ethereum_1.BSEthereumConstants.DEFAULT_DECIMALS,
|
|
390
369
|
hash: tokenHash,
|
|
391
370
|
name: data.name,
|
|
@@ -397,8 +376,7 @@ class BlockscoutBDSNeoX extends bs_ethereum_1.DoraBDSEthereum {
|
|
|
397
376
|
}
|
|
398
377
|
getBalance(address) {
|
|
399
378
|
return __awaiter(this, void 0, void 0, function* () {
|
|
400
|
-
const
|
|
401
|
-
const { data: nativeBalance } = yield client.get(`/addresses/${address}`);
|
|
379
|
+
const { data: nativeBalance } = yield __classPrivateFieldGet(this, _BlockscoutBDSNeoX_instances, "a", _BlockscoutBDSNeoX_api_get).get(`/addresses/${address}`);
|
|
402
380
|
if (!nativeBalance || 'message' in nativeBalance) {
|
|
403
381
|
throw new Error('Native balance not found');
|
|
404
382
|
}
|
|
@@ -409,7 +387,7 @@ class BlockscoutBDSNeoX extends bs_ethereum_1.DoraBDSEthereum {
|
|
|
409
387
|
token: nativeToken,
|
|
410
388
|
},
|
|
411
389
|
];
|
|
412
|
-
const { data: erc20Balances } = yield
|
|
390
|
+
const { data: erc20Balances } = yield __classPrivateFieldGet(this, _BlockscoutBDSNeoX_instances, "a", _BlockscoutBDSNeoX_api_get).get(`/addresses/${address}/token-balances`);
|
|
413
391
|
if (!erc20Balances || 'message' in erc20Balances) {
|
|
414
392
|
throw new Error('ERC20 balance not found');
|
|
415
393
|
}
|
|
@@ -418,7 +396,7 @@ class BlockscoutBDSNeoX extends bs_ethereum_1.DoraBDSEthereum {
|
|
|
418
396
|
if (balance.token.type !== 'ERC-20') {
|
|
419
397
|
return;
|
|
420
398
|
}
|
|
421
|
-
const token = this.
|
|
399
|
+
const token = this._service.tokenService.normalizeToken({
|
|
422
400
|
decimals: balance.token.decimals ? parseInt(balance.token.decimals) : bs_ethereum_1.BSEthereumConstants.DEFAULT_DECIMALS,
|
|
423
401
|
hash: balance.token.address,
|
|
424
402
|
name: balance.token.symbol,
|
|
@@ -429,7 +407,7 @@ class BlockscoutBDSNeoX extends bs_ethereum_1.DoraBDSEthereum {
|
|
|
429
407
|
token,
|
|
430
408
|
});
|
|
431
409
|
}
|
|
432
|
-
catch (
|
|
410
|
+
catch (_b) {
|
|
433
411
|
/* empty */
|
|
434
412
|
}
|
|
435
413
|
});
|
|
@@ -438,8 +416,7 @@ class BlockscoutBDSNeoX extends bs_ethereum_1.DoraBDSEthereum {
|
|
|
438
416
|
}
|
|
439
417
|
getBlockHeight() {
|
|
440
418
|
return __awaiter(this, void 0, void 0, function* () {
|
|
441
|
-
const
|
|
442
|
-
const { data } = yield client.get('/blocks');
|
|
419
|
+
const { data } = yield __classPrivateFieldGet(this, _BlockscoutBDSNeoX_instances, "a", _BlockscoutBDSNeoX_api_get).get('/blocks');
|
|
443
420
|
if (!data || 'message' in data) {
|
|
444
421
|
throw new Error('Block not found');
|
|
445
422
|
}
|
|
@@ -448,32 +425,40 @@ class BlockscoutBDSNeoX extends bs_ethereum_1.DoraBDSEthereum {
|
|
|
448
425
|
}
|
|
449
426
|
}
|
|
450
427
|
exports.BlockscoutBDSNeoX = BlockscoutBDSNeoX;
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
428
|
+
_a = BlockscoutBDSNeoX, _BlockscoutBDSNeoX_apiInstance = new WeakMap(), _BlockscoutBDSNeoX_instances = new WeakSet(), _BlockscoutBDSNeoX_api_get = function _BlockscoutBDSNeoX_api_get() {
|
|
429
|
+
if (!__classPrivateFieldGet(this, _BlockscoutBDSNeoX_apiInstance, "f")) {
|
|
430
|
+
return _a.getClient(this._service.network);
|
|
431
|
+
}
|
|
432
|
+
return __classPrivateFieldGet(this, _BlockscoutBDSNeoX_apiInstance, "f");
|
|
433
|
+
}, _BlockscoutBDSNeoX_getBridgeNeo3NeoXDataByBlockscoutTransaction = function _BlockscoutBDSNeoX_getBridgeNeo3NeoXDataByBlockscoutTransaction(transactionResponse) {
|
|
434
|
+
const BridgeInterface = new ethers_1.ethers.utils.Interface(bridge_1.BRIDGE_ABI);
|
|
435
|
+
const input = BridgeInterface.parseTransaction({ data: transactionResponse.raw_input });
|
|
436
|
+
const { wallet } = bs_neo3_1.BSNeo3NeonJsSingletonHelper.getInstance();
|
|
437
|
+
const to = input.args._to;
|
|
438
|
+
const receiverAddress = wallet.getAddressFromScriptHash(to.startsWith('0x') ? to.slice(2) : to);
|
|
439
|
+
let token;
|
|
440
|
+
let amountBn;
|
|
441
|
+
if (input.name === 'withdrawNative') {
|
|
442
|
+
token = this._service.neo3NeoXBridgeService.gasToken;
|
|
443
|
+
amountBn = blockchain_service_1.BSBigNumberHelper.fromDecimals(transactionResponse.value, token.decimals).minus(Neo3NeoXBridgeService_1.Neo3NeoXBridgeService.BRIDGE_FEE);
|
|
444
|
+
}
|
|
445
|
+
else if (input.name === 'withdrawToken') {
|
|
446
|
+
token = this._service.neo3NeoXBridgeService.neoToken;
|
|
447
|
+
amountBn = blockchain_service_1.BSBigNumberHelper.fromDecimals(input.args._amount.toString(), token.decimals);
|
|
448
|
+
}
|
|
449
|
+
if (!token || !amountBn)
|
|
473
450
|
return undefined;
|
|
474
|
-
|
|
451
|
+
return {
|
|
452
|
+
token,
|
|
453
|
+
receiverAddress,
|
|
454
|
+
amount: blockchain_service_1.BSBigNumberHelper.toNumber(amountBn),
|
|
455
|
+
};
|
|
475
456
|
};
|
|
476
457
|
BlockscoutBDSNeoX.BASE_URL_BY_CHAIN_ID = {
|
|
477
458
|
'47763': `${blockchain_service_1.BSCommonConstants.DORA_URL}/api/neox/mainnet`,
|
|
478
459
|
'12227332': 'https://dora-stage.coz.io/api/neox/testnet',
|
|
479
460
|
};
|
|
461
|
+
BlockscoutBDSNeoX.FULL_TRANSACTIONS_SUPPORTED_NETWORKS_IDS = ['12227332', '47763'];
|
|
462
|
+
BlockscoutBDSNeoX.FULL_TRANSACTIONS_ERC721_STANDARDS = ['erc721', 'erc-721'];
|
|
463
|
+
BlockscoutBDSNeoX.FULL_TRANSACTIONS_ERC1155_STANDARDS = ['erc1155', 'erc-1155'];
|
|
464
|
+
BlockscoutBDSNeoX.FULL_TRANSACTIONS_ERC20_STANDARDS = ['erc20', 'erc-20'];
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
export declare class FlamingoForthewinEDSNeoX extends
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
getTokenPriceHistory(params: GetTokenPriceHistoryParams): Promise<import("@cityofzion/blockchain-service").TokenPricesHistoryResponse[]>;
|
|
1
|
+
import { FlamingoForthewinEDS, TGetTokenPriceHistoryParams, TGetTokenPricesParams, TTokenPricesResponse } from '@cityofzion/blockchain-service';
|
|
2
|
+
import { IBSNeoX } from '../../types';
|
|
3
|
+
export declare class FlamingoForthewinEDSNeoX<N extends string> extends FlamingoForthewinEDS<N> {
|
|
4
|
+
constructor(service: IBSNeoX<N>);
|
|
5
|
+
getTokenPrices({ tokens }: TGetTokenPricesParams): Promise<TTokenPricesResponse[]>;
|
|
6
|
+
getTokenPriceHistory(params: TGetTokenPriceHistoryParams): Promise<import("@cityofzion/blockchain-service").TTokenPricesHistoryResponse[]>;
|
|
8
7
|
}
|
|
@@ -8,35 +8,21 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
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 _FlamingoForthewinEDSNeoX_instances, _FlamingoForthewinEDSNeoX_network, _FlamingoForthewinEDSNeoX_validate;
|
|
23
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
12
|
exports.FlamingoForthewinEDSNeoX = void 0;
|
|
25
13
|
const blockchain_service_1 = require("@cityofzion/blockchain-service");
|
|
26
|
-
const
|
|
14
|
+
const BSNeoXHelper_1 = require("../../helpers/BSNeoXHelper");
|
|
27
15
|
class FlamingoForthewinEDSNeoX extends blockchain_service_1.FlamingoForthewinEDS {
|
|
28
|
-
constructor(
|
|
29
|
-
super(
|
|
30
|
-
_FlamingoForthewinEDSNeoX_instances.add(this);
|
|
31
|
-
_FlamingoForthewinEDSNeoX_network.set(this, void 0);
|
|
32
|
-
__classPrivateFieldSet(this, _FlamingoForthewinEDSNeoX_network, network, "f");
|
|
16
|
+
constructor(service) {
|
|
17
|
+
super(service);
|
|
33
18
|
}
|
|
34
|
-
getTokenPrices(
|
|
19
|
+
getTokenPrices(_a) {
|
|
35
20
|
const _super = Object.create(null, {
|
|
36
21
|
getTokenPrices: { get: () => super.getTokenPrices }
|
|
37
22
|
});
|
|
38
|
-
return __awaiter(this,
|
|
39
|
-
|
|
23
|
+
return __awaiter(this, arguments, void 0, function* ({ tokens }) {
|
|
24
|
+
if (!BSNeoXHelper_1.BSNeoXHelper.isMainnetNetwork(this._service.network))
|
|
25
|
+
throw new Error('Exchange is only available on Neo X Mainnet');
|
|
40
26
|
const gasToken = tokens.find(({ symbol }) => symbol === 'GAS');
|
|
41
27
|
const neoToken = tokens.find(({ symbol }) => symbol === 'NEO');
|
|
42
28
|
if (!gasToken && !neoToken)
|
|
@@ -51,7 +37,8 @@ class FlamingoForthewinEDSNeoX extends blockchain_service_1.FlamingoForthewinEDS
|
|
|
51
37
|
getTokenPriceHistory: { get: () => super.getTokenPriceHistory }
|
|
52
38
|
});
|
|
53
39
|
return __awaiter(this, void 0, void 0, function* () {
|
|
54
|
-
|
|
40
|
+
if (!BSNeoXHelper_1.BSNeoXHelper.isMainnetNetwork(this._service.network))
|
|
41
|
+
throw new Error('Exchange is only available on Neo X Mainnet');
|
|
55
42
|
const { symbol } = params.token;
|
|
56
43
|
if (symbol !== 'GAS' && symbol !== 'NEO')
|
|
57
44
|
throw new Error('Invalid token, it should be GAS or NEO');
|
|
@@ -60,9 +47,3 @@ class FlamingoForthewinEDSNeoX extends blockchain_service_1.FlamingoForthewinEDS
|
|
|
60
47
|
}
|
|
61
48
|
}
|
|
62
49
|
exports.FlamingoForthewinEDSNeoX = FlamingoForthewinEDSNeoX;
|
|
63
|
-
_FlamingoForthewinEDSNeoX_network = new WeakMap(), _FlamingoForthewinEDSNeoX_instances = new WeakSet(), _FlamingoForthewinEDSNeoX_validate = function _FlamingoForthewinEDSNeoX_validate() {
|
|
64
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
65
|
-
if (!BSNeoXConstants_1.BSNeoXConstants.MAINNET_NETWORK_IDS.includes(__classPrivateFieldGet(this, _FlamingoForthewinEDSNeoX_network, "f").id))
|
|
66
|
-
throw new Error('Exchange is only available on Neo X Mainnet');
|
|
67
|
-
});
|
|
68
|
-
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { Network, TokenService } from '@cityofzion/blockchain-service';
|
|
2
1
|
import { BlockscoutESEthereum } from '@cityofzion/bs-ethereum';
|
|
3
|
-
import {
|
|
4
|
-
export declare class BlockscoutESNeoX extends BlockscoutESEthereum<
|
|
5
|
-
|
|
2
|
+
import { IBSNeoX, TBSNeoXNetworkId } from '../../types';
|
|
3
|
+
export declare class BlockscoutESNeoX<N extends string> extends BlockscoutESEthereum<N, TBSNeoXNetworkId> {
|
|
4
|
+
static readonly DEFAULT_BASE_URL_BY_NETWORK_ID: Record<TBSNeoXNetworkId, string>;
|
|
5
|
+
constructor(service: IBSNeoX<N>);
|
|
6
|
+
getBaseUrl(): string;
|
|
6
7
|
}
|
|
@@ -3,11 +3,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.BlockscoutESNeoX = void 0;
|
|
4
4
|
const bs_ethereum_1 = require("@cityofzion/bs-ethereum");
|
|
5
5
|
class BlockscoutESNeoX extends bs_ethereum_1.BlockscoutESEthereum {
|
|
6
|
-
constructor(
|
|
7
|
-
super(
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
constructor(service) {
|
|
7
|
+
super(service);
|
|
8
|
+
}
|
|
9
|
+
getBaseUrl() {
|
|
10
|
+
const baseUrl = BlockscoutESNeoX.DEFAULT_BASE_URL_BY_NETWORK_ID[this._service.network.id];
|
|
11
|
+
if (!baseUrl) {
|
|
12
|
+
throw new Error('Network not supported');
|
|
13
|
+
}
|
|
14
|
+
return baseUrl;
|
|
11
15
|
}
|
|
12
16
|
}
|
|
13
17
|
exports.BlockscoutESNeoX = BlockscoutESNeoX;
|
|
18
|
+
BlockscoutESNeoX.DEFAULT_BASE_URL_BY_NETWORK_ID = {
|
|
19
|
+
'47763': 'https://xexplorer.neo.org',
|
|
20
|
+
'12227332': 'https://xt4scan.ngd.network',
|
|
21
|
+
};
|
|
@@ -4,8 +4,9 @@ export declare class Neo3NeoXBridgeService<BSName extends string> implements INe
|
|
|
4
4
|
#private;
|
|
5
5
|
static readonly BRIDGE_SCRIPT_HASH = "0x1212000000000000000000000000000000000004";
|
|
6
6
|
static readonly BRIDGE_FEE = 0.1;
|
|
7
|
-
readonly BRIDGE_BASE_CONFIRMATION_URL = "https://xexplorer.neo.org:8877/api/v1/transactions/deposits";
|
|
8
|
-
|
|
7
|
+
static readonly BRIDGE_BASE_CONFIRMATION_URL = "https://xexplorer.neo.org:8877/api/v1/transactions/deposits";
|
|
8
|
+
readonly gasToken: TBridgeToken<BSName>;
|
|
9
|
+
readonly neoToken: TBridgeToken<BSName>;
|
|
9
10
|
constructor(service: BSNeoX<BSName>);
|
|
10
11
|
getBridgeConstants(token: TBridgeToken<BSName>): Promise<TNeo3NeoXBridgeServiceConstants>;
|
|
11
12
|
getApprovalFee(params: TNeo3NeoXBridgeServiceGetApprovalParam<BSName>): Promise<string>;
|
|
@@ -22,34 +22,31 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
22
22
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
23
23
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
24
|
};
|
|
25
|
-
var _Neo3NeoXBridgeService_instances, _Neo3NeoXBridgeService_service, _Neo3NeoXBridgeService_buildApproveTransactionParam;
|
|
25
|
+
var _Neo3NeoXBridgeService_instances, _a, _Neo3NeoXBridgeService_service, _Neo3NeoXBridgeService_buildApproveTransactionParam;
|
|
26
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
27
|
exports.Neo3NeoXBridgeService = void 0;
|
|
28
28
|
const blockchain_service_1 = require("@cityofzion/blockchain-service");
|
|
29
29
|
const BSNeoXConstants_1 = require("../../constants/BSNeoXConstants");
|
|
30
30
|
const ethers_1 = require("ethers");
|
|
31
|
-
const neon_js_1 = require("@cityofzion/neon-js");
|
|
32
31
|
const bridge_1 = require("../../assets/abis/bridge");
|
|
33
32
|
const bs_ethereum_1 = require("@cityofzion/bs-ethereum");
|
|
34
33
|
const axios_1 = __importDefault(require("axios"));
|
|
35
34
|
const BlockscoutBDSNeoX_1 = require("../blockchain-data/BlockscoutBDSNeoX");
|
|
36
35
|
const BSNeoXHelper_1 = require("../../helpers/BSNeoXHelper");
|
|
36
|
+
const bs_neo3_1 = require("@cityofzion/bs-neo3");
|
|
37
37
|
class Neo3NeoXBridgeService {
|
|
38
38
|
constructor(service) {
|
|
39
39
|
_Neo3NeoXBridgeService_instances.add(this);
|
|
40
|
-
this.BRIDGE_BASE_CONFIRMATION_URL = 'https://xexplorer.neo.org:8877/api/v1/transactions/deposits';
|
|
41
40
|
_Neo3NeoXBridgeService_service.set(this, void 0);
|
|
42
41
|
__classPrivateFieldSet(this, _Neo3NeoXBridgeService_service, service, "f");
|
|
43
|
-
this.
|
|
44
|
-
|
|
45
|
-
Object.assign(Object.assign({}, BSNeoXConstants_1.BSNeoXConstants.NEO_TOKEN), { multichainId: 'neo', blockchain: service.name }),
|
|
46
|
-
];
|
|
42
|
+
this.gasToken = Object.assign(Object.assign({}, BSNeoXConstants_1.BSNeoXConstants.NATIVE_ASSET), { blockchain: service.name, multichainId: 'gas' });
|
|
43
|
+
this.neoToken = Object.assign(Object.assign({}, BSNeoXConstants_1.BSNeoXConstants.NEO_TOKEN), { blockchain: service.name, multichainId: 'neo' });
|
|
47
44
|
}
|
|
48
45
|
getBridgeConstants(token) {
|
|
49
46
|
return __awaiter(this, void 0, void 0, function* () {
|
|
50
47
|
try {
|
|
51
48
|
const provider = new ethers_1.ethers.providers.JsonRpcProvider(__classPrivateFieldGet(this, _Neo3NeoXBridgeService_service, "f").network.url);
|
|
52
|
-
const bridgeContract = new ethers_1.ethers.Contract(
|
|
49
|
+
const bridgeContract = new ethers_1.ethers.Contract(_a.BRIDGE_SCRIPT_HASH, bridge_1.BRIDGE_ABI, provider);
|
|
53
50
|
const isNativeToken = __classPrivateFieldGet(this, _Neo3NeoXBridgeService_service, "f").tokenService.predicateByHash(token, BSNeoXConstants_1.BSNeoXConstants.NATIVE_ASSET);
|
|
54
51
|
const response = isNativeToken
|
|
55
52
|
? yield bridgeContract.nativeBridge()
|
|
@@ -98,12 +95,13 @@ class Neo3NeoXBridgeService {
|
|
|
98
95
|
}
|
|
99
96
|
bridge(params) {
|
|
100
97
|
return __awaiter(this, void 0, void 0, function* () {
|
|
101
|
-
if (!BSNeoXHelper_1.BSNeoXHelper.
|
|
98
|
+
if (!BSNeoXHelper_1.BSNeoXHelper.isMainnetNetwork(__classPrivateFieldGet(this, _Neo3NeoXBridgeService_service, "f").network))
|
|
102
99
|
throw new blockchain_service_1.BSError('Bridging to Neo3 is only supported on mainnet', 'UNSUPPORTED_NETWORK');
|
|
103
100
|
const { account } = params;
|
|
104
101
|
const signer = yield __classPrivateFieldGet(this, _Neo3NeoXBridgeService_service, "f").generateSigner(account);
|
|
105
|
-
const bridgeContract = new ethers_1.ethers.Contract(
|
|
106
|
-
const
|
|
102
|
+
const bridgeContract = new ethers_1.ethers.Contract(_a.BRIDGE_SCRIPT_HASH, bridge_1.BRIDGE_ABI);
|
|
103
|
+
const { wallet } = bs_neo3_1.BSNeo3NeonJsSingletonHelper.getInstance();
|
|
104
|
+
const to = '0x' + wallet.getScriptHashFromAddress(params.receiverAddress);
|
|
107
105
|
const bridgeFee = ethers_1.ethers.utils.parseUnits(params.bridgeFee, BSNeoXConstants_1.BSNeoXConstants.NATIVE_ASSET.decimals);
|
|
108
106
|
const isNativeToken = __classPrivateFieldGet(this, _Neo3NeoXBridgeService_service, "f").tokenService.predicateByHash(params.token, BSNeoXConstants_1.BSNeoXConstants.NATIVE_ASSET);
|
|
109
107
|
let bridgeTransactionParam = {
|
|
@@ -128,7 +126,7 @@ class Neo3NeoXBridgeService {
|
|
|
128
126
|
try {
|
|
129
127
|
gasLimit = yield signer.estimateGas(bridgeTransactionParam);
|
|
130
128
|
}
|
|
131
|
-
catch (
|
|
129
|
+
catch (_b) {
|
|
132
130
|
gasLimit = bs_ethereum_1.BSEthereumConstants.DEFAULT_GAS_LIMIT;
|
|
133
131
|
}
|
|
134
132
|
const gasPrice = yield signer.getGasPrice();
|
|
@@ -138,56 +136,43 @@ class Neo3NeoXBridgeService {
|
|
|
138
136
|
}
|
|
139
137
|
getNonce(params) {
|
|
140
138
|
return __awaiter(this, void 0, void 0, function* () {
|
|
141
|
-
|
|
142
|
-
try {
|
|
139
|
+
const [transactionLogsResponse, transactionLogsResponseError] = yield blockchain_service_1.BSPromisesHelper.tryCatch(() => __awaiter(this, void 0, void 0, function* () {
|
|
143
140
|
const client = BlockscoutBDSNeoX_1.BlockscoutBDSNeoX.getClient(__classPrivateFieldGet(this, _Neo3NeoXBridgeService_service, "f").network);
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
}
|
|
150
|
-
if (!data.items || data.items.length === 0) {
|
|
151
|
-
throw new blockchain_service_1.BSError('Transaction invalid', 'INVALID_TRANSACTION');
|
|
152
|
-
}
|
|
153
|
-
try {
|
|
141
|
+
return yield client.get(`/transactions/${params.transactionHash}/logs`);
|
|
142
|
+
}));
|
|
143
|
+
if (!transactionLogsResponse)
|
|
144
|
+
throw new blockchain_service_1.BSError('Failed to get nonce from transaction log', 'FAILED_TO_GET_NONCE', transactionLogsResponseError);
|
|
145
|
+
const [nonce, nonceError] = yield blockchain_service_1.BSPromisesHelper.tryCatch(() => {
|
|
154
146
|
const BridgeInterface = new ethers_1.ethers.utils.Interface(bridge_1.BRIDGE_ABI);
|
|
155
147
|
const isNativeToken = __classPrivateFieldGet(this, _Neo3NeoXBridgeService_service, "f").tokenService.predicateByHash(params.token, BSNeoXConstants_1.BSNeoXConstants.NATIVE_ASSET);
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
}
|
|
167
|
-
if (!nonce) {
|
|
168
|
-
throw new blockchain_service_1.BSError('Nonce not found in transaction log', 'NONCE_NOT_FOUND');
|
|
169
|
-
}
|
|
170
|
-
return nonce;
|
|
171
|
-
}
|
|
172
|
-
catch (error) {
|
|
173
|
-
throw new blockchain_service_1.BSError('Failed to get nonce from transaction log', 'FAILED_TO_GET_NONCE', error);
|
|
148
|
+
const dataIndex = isNativeToken ? 0 : 1;
|
|
149
|
+
const log = transactionLogsResponse.data.items[dataIndex];
|
|
150
|
+
const parsedLog = BridgeInterface.parseLog({
|
|
151
|
+
data: log.data,
|
|
152
|
+
topics: log.topics.filter(Boolean),
|
|
153
|
+
});
|
|
154
|
+
return parsedLog.args.nonce ? parsedLog.args.nonce.toString() : undefined;
|
|
155
|
+
});
|
|
156
|
+
if (!nonce) {
|
|
157
|
+
throw new blockchain_service_1.BSError('Failed to get nonce from transaction log', 'FAILED_TO_GET_NONCE', nonceError);
|
|
174
158
|
}
|
|
159
|
+
return nonce;
|
|
175
160
|
});
|
|
176
161
|
}
|
|
177
162
|
getTransactionHashByNonce(params) {
|
|
178
|
-
var _a;
|
|
179
163
|
return __awaiter(this, void 0, void 0, function* () {
|
|
164
|
+
var _b;
|
|
180
165
|
try {
|
|
181
166
|
let url;
|
|
182
167
|
const isNativeToken = __classPrivateFieldGet(this, _Neo3NeoXBridgeService_service, "f").tokenService.predicateByHash(params.token, BSNeoXConstants_1.BSNeoXConstants.NATIVE_ASSET);
|
|
183
168
|
if (isNativeToken) {
|
|
184
|
-
url = `${
|
|
169
|
+
url = `${_a.BRIDGE_BASE_CONFIRMATION_URL}/${params.nonce}`;
|
|
185
170
|
}
|
|
186
171
|
else {
|
|
187
|
-
url = `${
|
|
172
|
+
url = `${_a.BRIDGE_BASE_CONFIRMATION_URL}/${BSNeoXConstants_1.BSNeoXConstants.NEO_TOKEN.hash}/${params.nonce}`;
|
|
188
173
|
}
|
|
189
174
|
const response = yield axios_1.default.get(url);
|
|
190
|
-
if (!((
|
|
175
|
+
if (!((_b = response.data) === null || _b === void 0 ? void 0 : _b.txid)) {
|
|
191
176
|
throw new blockchain_service_1.BSError('Transaction ID not found in response', 'TXID_NOT_FOUND');
|
|
192
177
|
}
|
|
193
178
|
return response.data.txid;
|
|
@@ -199,11 +184,11 @@ class Neo3NeoXBridgeService {
|
|
|
199
184
|
}
|
|
200
185
|
}
|
|
201
186
|
exports.Neo3NeoXBridgeService = Neo3NeoXBridgeService;
|
|
202
|
-
_Neo3NeoXBridgeService_service = new WeakMap(), _Neo3NeoXBridgeService_instances = new WeakSet(), _Neo3NeoXBridgeService_buildApproveTransactionParam = function _Neo3NeoXBridgeService_buildApproveTransactionParam(params) {
|
|
187
|
+
_a = Neo3NeoXBridgeService, _Neo3NeoXBridgeService_service = new WeakMap(), _Neo3NeoXBridgeService_instances = new WeakSet(), _Neo3NeoXBridgeService_buildApproveTransactionParam = function _Neo3NeoXBridgeService_buildApproveTransactionParam(params) {
|
|
203
188
|
return __awaiter(this, void 0, void 0, function* () {
|
|
204
189
|
const provider = new ethers_1.ethers.providers.JsonRpcProvider(__classPrivateFieldGet(this, _Neo3NeoXBridgeService_service, "f").network.url);
|
|
205
190
|
const erc20Contract = new ethers_1.ethers.Contract(params.token.hash, bs_ethereum_1.ERC20_ABI, provider);
|
|
206
|
-
const allowance = yield erc20Contract.allowance(params.account.address,
|
|
191
|
+
const allowance = yield erc20Contract.allowance(params.account.address, _a.BRIDGE_SCRIPT_HASH);
|
|
207
192
|
const allowanceNumber = blockchain_service_1.BSBigNumberHelper.fromDecimals(allowance.toString(), BSNeoXConstants_1.BSNeoXConstants.NEO_TOKEN.decimals);
|
|
208
193
|
// We are using 0 as the decimals because the NEO token in Neo3 has 0 decimals
|
|
209
194
|
const fixedAmount = blockchain_service_1.BSBigNumberHelper.format(params.amount, { decimals: 0 });
|
|
@@ -211,8 +196,9 @@ _Neo3NeoXBridgeService_service = new WeakMap(), _Neo3NeoXBridgeService_instances
|
|
|
211
196
|
return null;
|
|
212
197
|
}
|
|
213
198
|
const amount = ethers_1.ethers.utils.parseUnits(fixedAmount, params.token.decimals);
|
|
214
|
-
return yield erc20Contract.populateTransaction.approve(
|
|
199
|
+
return yield erc20Contract.populateTransaction.approve(_a.BRIDGE_SCRIPT_HASH, amount);
|
|
215
200
|
});
|
|
216
201
|
};
|
|
217
202
|
Neo3NeoXBridgeService.BRIDGE_SCRIPT_HASH = '0x1212000000000000000000000000000000000004';
|
|
218
203
|
Neo3NeoXBridgeService.BRIDGE_FEE = 0.1;
|
|
204
|
+
Neo3NeoXBridgeService.BRIDGE_BASE_CONFIRMATION_URL = 'https://xexplorer.neo.org:8877/api/v1/transactions/deposits';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { GhostMarketNDSEthereum } from '@cityofzion/bs-ethereum';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
constructor(
|
|
2
|
+
import { IBSNeoX, TBSNeoXNetworkId } from '../../types';
|
|
3
|
+
export declare class GhostMarketNDSNeoX<N extends string> extends GhostMarketNDSEthereum<N, TBSNeoXNetworkId> {
|
|
4
|
+
static readonly CHAIN_BY_NETWORK_ID: Partial<Record<TBSNeoXNetworkId, string>>;
|
|
5
|
+
constructor(service: IBSNeoX<N>);
|
|
6
|
+
getChain(): string;
|
|
6
7
|
}
|
|
@@ -3,10 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.GhostMarketNDSNeoX = void 0;
|
|
4
4
|
const bs_ethereum_1 = require("@cityofzion/bs-ethereum");
|
|
5
5
|
class GhostMarketNDSNeoX extends bs_ethereum_1.GhostMarketNDSEthereum {
|
|
6
|
-
constructor(
|
|
7
|
-
super(
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
constructor(service) {
|
|
7
|
+
super(service);
|
|
8
|
+
}
|
|
9
|
+
getChain() {
|
|
10
|
+
const chain = GhostMarketNDSNeoX.CHAIN_BY_NETWORK_ID[this._service.network.id];
|
|
11
|
+
if (!chain)
|
|
12
|
+
throw new Error('Network not supported');
|
|
13
|
+
return chain;
|
|
10
14
|
}
|
|
11
15
|
}
|
|
12
16
|
exports.GhostMarketNDSNeoX = GhostMarketNDSNeoX;
|
|
17
|
+
GhostMarketNDSNeoX.CHAIN_BY_NETWORK_ID = {
|
|
18
|
+
'47763': 'neox',
|
|
19
|
+
};
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { IBSWithNeo3NeoXBridge, TBSNetworkId } from '@cityofzion/blockchain-service';
|
|
2
|
+
import { ERC20_ABI, IBSEthereum } from '@cityofzion/bs-ethereum';
|
|
3
|
+
export type TBSNeoXNetworkId = TBSNetworkId<'47763' | '12227332'>;
|
|
4
|
+
export interface IBSNeoX<N extends string = string> extends IBSEthereum<N, TBSNeoXNetworkId>, IBSWithNeo3NeoXBridge<N> {
|
|
5
|
+
}
|
|
6
|
+
export type TBlockscoutBDSNeoXTransactionApiResponse = {
|
|
7
|
+
fee: {
|
|
8
|
+
value: string;
|
|
9
|
+
};
|
|
10
|
+
hash: string;
|
|
11
|
+
block: number;
|
|
12
|
+
timestamp: string;
|
|
13
|
+
value: string;
|
|
14
|
+
from: {
|
|
15
|
+
hash: string;
|
|
16
|
+
};
|
|
17
|
+
to: {
|
|
18
|
+
hash: string;
|
|
19
|
+
};
|
|
20
|
+
token_transfers: {
|
|
21
|
+
token: {
|
|
22
|
+
type: string;
|
|
23
|
+
address: string;
|
|
24
|
+
symbol: string;
|
|
25
|
+
name: string;
|
|
26
|
+
};
|
|
27
|
+
from: {
|
|
28
|
+
hash: string;
|
|
29
|
+
};
|
|
30
|
+
to: {
|
|
31
|
+
hash: string;
|
|
32
|
+
};
|
|
33
|
+
total: {
|
|
34
|
+
value: string;
|
|
35
|
+
decimals: number;
|
|
36
|
+
token_id: string;
|
|
37
|
+
};
|
|
38
|
+
}[];
|
|
39
|
+
raw_input: string;
|
|
40
|
+
};
|
|
41
|
+
export type TBlockscoutBDSNeoXTransactionByAddressApiResponse = {
|
|
42
|
+
items: TBlockscoutBDSNeoXTransactionApiResponse[];
|
|
43
|
+
next_page_params?: {
|
|
44
|
+
block_number: number;
|
|
45
|
+
fee: string;
|
|
46
|
+
hash: string;
|
|
47
|
+
index: number;
|
|
48
|
+
inserted_at: string;
|
|
49
|
+
items_count: number;
|
|
50
|
+
value: string;
|
|
51
|
+
} | null;
|
|
52
|
+
};
|
|
53
|
+
export type TBlockscoutBDSNeoXBlocksApiResponse = {
|
|
54
|
+
items: {
|
|
55
|
+
height: number;
|
|
56
|
+
}[];
|
|
57
|
+
};
|
|
58
|
+
export type TBlockscoutBDSNeoXBalanceApiResponse = {
|
|
59
|
+
token: {
|
|
60
|
+
name: string;
|
|
61
|
+
decimals: string | null;
|
|
62
|
+
address: string;
|
|
63
|
+
symbol: string;
|
|
64
|
+
type: string;
|
|
65
|
+
};
|
|
66
|
+
token_id: string | null;
|
|
67
|
+
value: string;
|
|
68
|
+
};
|
|
69
|
+
export type TBlockscoutBDSNeoXSmartContractApiResponse = {
|
|
70
|
+
name: string;
|
|
71
|
+
abi: typeof ERC20_ABI;
|
|
72
|
+
};
|
|
73
|
+
export type TBlockscoutBDSNeoXTokensApiResponse = {
|
|
74
|
+
name: string;
|
|
75
|
+
decimals: string | null;
|
|
76
|
+
address: string;
|
|
77
|
+
symbol: string;
|
|
78
|
+
type: string;
|
|
79
|
+
};
|
|
80
|
+
export type TNeo3NeoXBridgeServiceTransactionLogApiResponse = {
|
|
81
|
+
items: {
|
|
82
|
+
data: string;
|
|
83
|
+
topics: any[];
|
|
84
|
+
}[];
|
|
85
|
+
};
|
|
86
|
+
export type TNeo3NeoXBridgeServiceGetTransactionByNonceApiReponse = {
|
|
87
|
+
txid: string | null;
|
|
88
|
+
};
|
package/dist/types.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cityofzion/bs-neox",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"repository": "https://github.com/CityOfZion/blockchain-services",
|
|
@@ -10,32 +10,30 @@
|
|
|
10
10
|
"/dist"
|
|
11
11
|
],
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@cityofzion/dora-ts": "0.5.1",
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"@cityofzion/blockchain-service": "1.21.2",
|
|
20
|
-
"@cityofzion/bs-ethereum": "2.13.4"
|
|
13
|
+
"@cityofzion/dora-ts": "~0.5.1",
|
|
14
|
+
"axios": "~1.12.2",
|
|
15
|
+
"ethers": "~5.7.2",
|
|
16
|
+
"@cityofzion/bs-neo3": "1.17.0",
|
|
17
|
+
"@cityofzion/bs-ethereum": "2.14.0",
|
|
18
|
+
"@cityofzion/blockchain-service": "1.22.0"
|
|
21
19
|
},
|
|
22
20
|
"devDependencies": {
|
|
23
|
-
"@ledgerhq/hw-transport
|
|
24
|
-
"@
|
|
25
|
-
"@
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"jest": "29.
|
|
31
|
-
"ts-jest": "29.1.1",
|
|
21
|
+
"@ledgerhq/hw-transport": "~6.31.11",
|
|
22
|
+
"@ledgerhq/hw-transport-node-hid": "~6.29.12",
|
|
23
|
+
"@types/jest": "~30.0.0",
|
|
24
|
+
"date-fns": "~4.1.0",
|
|
25
|
+
"dotenv": "~17.2.2",
|
|
26
|
+
"eslint": "~9.36.0",
|
|
27
|
+
"jest": "~30.1.3",
|
|
28
|
+
"ts-jest": "~29.4.4",
|
|
32
29
|
"ts-node": "~10.9.2",
|
|
33
|
-
"typescript": "
|
|
30
|
+
"typescript": "~5.9.2"
|
|
34
31
|
},
|
|
35
32
|
"scripts": {
|
|
36
|
-
"build": "tsc --project tsconfig.build.json",
|
|
37
|
-
"test": "jest --config jest.config.ts",
|
|
33
|
+
"build": "rm -rf ./dist && tsc --project tsconfig.build.json",
|
|
34
|
+
"test": "jest -i --config jest.config.ts",
|
|
38
35
|
"lint": "eslint .",
|
|
39
|
-
"format": "eslint --fix"
|
|
36
|
+
"format": "eslint --fix",
|
|
37
|
+
"package": "npm run build && npm pack"
|
|
40
38
|
}
|
|
41
39
|
}
|