@cityofzion/bs-neo3 1.15.4 → 1.16.1
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.d.ts +4 -3
- package/dist/BSNeo3.js +11 -9
- package/dist/constants/BSNeo3Constants.d.ts +1 -0
- package/dist/constants/BSNeo3Constants.js +10 -4
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/services/blockchain-data/DoraBDSNeo3.d.ts +2 -2
- package/dist/services/blockchain-data/DoraBDSNeo3.js +87 -41
- package/dist/services/blockchain-data/RpcBDSNeo3.d.ts +3 -2
- package/dist/services/blockchain-data/RpcBDSNeo3.js +5 -4
- package/dist/services/exchange-data/FlamingoForthewinEDSNeo3.d.ts +2 -2
- package/dist/services/exchange-data/FlamingoForthewinEDSNeo3.js +2 -2
- package/dist/services/explorer/DoraESNeo3.d.ts +3 -3
- package/dist/services/explorer/DoraESNeo3.js +10 -8
- package/dist/services/neo3neoXBridge/Neo3NeoXBridgeService.js +4 -4
- package/dist/services/nft-data/GhostMarketNDSNeo3.d.ts +1 -1
- package/dist/services/nft-data/GhostMarketNDSNeo3.js +9 -8
- package/dist/services/nft-data/RpcNDSNeo3.d.ts +1 -1
- package/dist/services/nft-data/RpcNDSNeo3.js +3 -3
- package/dist/services/token/TokenServiceNeo3.d.ts +4 -0
- package/dist/services/token/TokenServiceNeo3.js +11 -0
- package/package.json +3 -3
package/dist/BSNeo3.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Account, BDSClaimable, BlockchainDataService, BlockchainService, BSCalculableFee, BSClaimable, BSWithExplorerService, BSWithLedger, BSWithNameService, BSWithNft, ExchangeDataService, ExplorerService, GetLedgerTransport, IBSWithNeo3NeoXBridge, INeo3NeoXBridgeService, Network, NftDataService, Token, TransferParam } from '@cityofzion/blockchain-service';
|
|
1
|
+
import { Account, BDSClaimable, BlockchainDataService, BlockchainService, BSCalculableFee, BSClaimable, BSWithEncryption, BSWithExplorerService, BSWithLedger, BSWithNameService, BSWithNft, ExchangeDataService, ExplorerService, GetLedgerTransport, IBSWithNeo3NeoXBridge, INeo3NeoXBridgeService, ITokenService, Network, NftDataService, Token, TransferParam } from '@cityofzion/blockchain-service';
|
|
2
2
|
import { NeonDappKitLedgerServiceNeo3 } from './services/ledger/NeonDappKitLedgerServiceNeo3';
|
|
3
3
|
import { BSNeo3NetworkId } from './constants/BSNeo3Constants';
|
|
4
4
|
import { GenerateSigningCallbackResponse, VoteService } from './interfaces';
|
|
5
|
-
export declare class BSNeo3<BSName extends string = string> implements BlockchainService<BSName, BSNeo3NetworkId>, BSClaimable<BSName>, BSWithNameService, BSCalculableFee<BSName>, BSWithNft, BSWithExplorerService, BSWithLedger<BSName>, IBSWithNeo3NeoXBridge<BSName> {
|
|
5
|
+
export declare class BSNeo3<BSName extends string = string> implements BlockchainService<BSName, BSNeo3NetworkId>, BSClaimable<BSName>, BSWithNameService, BSCalculableFee<BSName>, BSWithNft, BSWithExplorerService, BSWithLedger<BSName>, IBSWithNeo3NeoXBridge<BSName>, BSWithEncryption<BSName> {
|
|
6
6
|
#private;
|
|
7
7
|
name: BSName;
|
|
8
8
|
bip44DerivationPath: string;
|
|
@@ -18,11 +18,12 @@ export declare class BSNeo3<BSName extends string = string> implements Blockchai
|
|
|
18
18
|
explorerService: ExplorerService;
|
|
19
19
|
voteService: VoteService<BSName>;
|
|
20
20
|
neo3NeoXBridgeService: INeo3NeoXBridgeService<BSName>;
|
|
21
|
+
tokenService: ITokenService;
|
|
21
22
|
network: Network<BSNeo3NetworkId>;
|
|
22
23
|
constructor(name: BSName, network?: Network<BSNeo3NetworkId>, getLedgerTransport?: GetLedgerTransport<BSName>);
|
|
23
24
|
generateSigningCallback(account: Account<BSName>): Promise<GenerateSigningCallbackResponse>;
|
|
24
|
-
testNetwork(network: Network<BSNeo3NetworkId>): Promise<void>;
|
|
25
25
|
setNetwork(network: Network<BSNeo3NetworkId>): void;
|
|
26
|
+
testNetwork(network: Network<BSNeo3NetworkId>): Promise<void>;
|
|
26
27
|
validateAddress(address: string): boolean;
|
|
27
28
|
validateEncrypted(encryptedKey: string): boolean;
|
|
28
29
|
validateKey(key: string): boolean;
|
package/dist/BSNeo3.js
CHANGED
|
@@ -30,6 +30,7 @@ const BSNeo3Constants_1 = require("./constants/BSNeo3Constants");
|
|
|
30
30
|
const RpcBDSNeo3_1 = require("./services/blockchain-data/RpcBDSNeo3");
|
|
31
31
|
const Neo3NeoXBridgeService_1 = require("./services/neo3neoXBridge/Neo3NeoXBridgeService");
|
|
32
32
|
const DoraVoteServiceNeo3_1 = require("./services/vote/DoraVoteServiceNeo3");
|
|
33
|
+
const TokenServiceNeo3_1 = require("./services/token/TokenServiceNeo3");
|
|
33
34
|
class BSNeo3 {
|
|
34
35
|
constructor(name, network, getLedgerTransport) {
|
|
35
36
|
_BSNeo3_instances.add(this);
|
|
@@ -59,21 +60,22 @@ class BSNeo3 {
|
|
|
59
60
|
};
|
|
60
61
|
});
|
|
61
62
|
}
|
|
62
|
-
testNetwork(network) {
|
|
63
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
64
|
-
const blockchainDataServiceClone = new RpcBDSNeo3_1.RpcBDSNeo3(network, this.feeToken, this.claimToken, this.tokens);
|
|
65
|
-
yield blockchainDataServiceClone.getBlockHeight();
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
63
|
setNetwork(network) {
|
|
69
64
|
__classPrivateFieldGet(this, _BSNeo3_instances, "m", _BSNeo3_setTokens).call(this, network);
|
|
70
65
|
this.network = network;
|
|
66
|
+
this.tokenService = new TokenServiceNeo3_1.TokenServiceNeo3();
|
|
71
67
|
this.nftDataService = new GhostMarketNDSNeo3_1.GhostMarketNDSNeo3(network);
|
|
72
|
-
this.explorerService = new DoraESNeo3_1.DoraESNeo3(network);
|
|
68
|
+
this.explorerService = new DoraESNeo3_1.DoraESNeo3(network, this.tokenService);
|
|
73
69
|
this.voteService = new DoraVoteServiceNeo3_1.DoraVoteServiceNeo3(this);
|
|
74
70
|
this.neo3NeoXBridgeService = new Neo3NeoXBridgeService_1.Neo3NeoXBridgeService(this);
|
|
75
|
-
this.blockchainDataService = new DoraBDSNeo3_1.DoraBDSNeo3(network, this.feeToken, this.claimToken, this.tokens, this.nftDataService, this.explorerService);
|
|
76
|
-
this.exchangeDataService = new FlamingoForthewinEDSNeo3_1.FlamingoForthewinEDSNeo3(network);
|
|
71
|
+
this.blockchainDataService = new DoraBDSNeo3_1.DoraBDSNeo3(network, this.feeToken, this.claimToken, this.tokens, this.nftDataService, this.explorerService, this.tokenService, this.neo3NeoXBridgeService);
|
|
72
|
+
this.exchangeDataService = new FlamingoForthewinEDSNeo3_1.FlamingoForthewinEDSNeo3(network, this.tokenService);
|
|
73
|
+
}
|
|
74
|
+
testNetwork(network) {
|
|
75
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
76
|
+
const blockchainDataServiceClone = new RpcBDSNeo3_1.RpcBDSNeo3(network, this.feeToken, this.claimToken, this.tokens, this.tokenService);
|
|
77
|
+
yield blockchainDataServiceClone.getBlockHeight();
|
|
78
|
+
});
|
|
77
79
|
}
|
|
78
80
|
validateAddress(address) {
|
|
79
81
|
return neon_js_1.wallet.isAddress(address, 53);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Network, NetworkId, Token } from '@cityofzion/blockchain-service';
|
|
2
2
|
export type BSNeo3NetworkId = NetworkId<'mainnet' | 'testnet'>;
|
|
3
3
|
export declare class BSNeo3Constants {
|
|
4
|
+
#private;
|
|
4
5
|
static EXTRA_TOKENS_BY_NETWORK_ID: Partial<Record<BSNeo3NetworkId, Token[]>>;
|
|
5
6
|
static NATIVE_ASSETS: Token[];
|
|
6
7
|
static GAS_TOKEN: Token;
|
|
@@ -1,21 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
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
|
+
};
|
|
2
7
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
8
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
9
|
};
|
|
5
|
-
var _a;
|
|
10
|
+
var _a, _BSNeo3Constants_tokenService;
|
|
6
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
12
|
exports.BSNeo3Constants = void 0;
|
|
8
|
-
const blockchain_service_1 = require("@cityofzion/blockchain-service");
|
|
9
13
|
const mainnet_json_1 = __importDefault(require("../assets/tokens/mainnet.json"));
|
|
10
14
|
const native_json_1 = __importDefault(require("../assets/tokens/native.json"));
|
|
15
|
+
const TokenServiceNeo3_1 = require("../services/token/TokenServiceNeo3");
|
|
11
16
|
class BSNeo3Constants {
|
|
12
17
|
}
|
|
13
18
|
exports.BSNeo3Constants = BSNeo3Constants;
|
|
14
19
|
_a = BSNeo3Constants;
|
|
20
|
+
_BSNeo3Constants_tokenService = { value: new TokenServiceNeo3_1.TokenServiceNeo3() };
|
|
15
21
|
BSNeo3Constants.EXTRA_TOKENS_BY_NETWORK_ID = {
|
|
16
|
-
mainnet:
|
|
22
|
+
mainnet: __classPrivateFieldGet(_a, _a, "f", _BSNeo3Constants_tokenService).normalizeToken(mainnet_json_1.default),
|
|
17
23
|
};
|
|
18
|
-
BSNeo3Constants.NATIVE_ASSETS =
|
|
24
|
+
BSNeo3Constants.NATIVE_ASSETS = __classPrivateFieldGet(_a, _a, "f", _BSNeo3Constants_tokenService).normalizeToken(native_json_1.default);
|
|
19
25
|
BSNeo3Constants.GAS_TOKEN = _a.NATIVE_ASSETS.find(token => token.name === 'GAS');
|
|
20
26
|
BSNeo3Constants.NEO_TOKEN = _a.NATIVE_ASSETS.find(token => token.name === 'NEO');
|
|
21
27
|
BSNeo3Constants.RPC_LIST_BY_NETWORK_ID = {
|
package/dist/index.d.ts
CHANGED
|
@@ -8,4 +8,7 @@ export * from './services/explorer/DoraESNeo3';
|
|
|
8
8
|
export * from './services/ledger/NeonDappKitLedgerServiceNeo3';
|
|
9
9
|
export * from './services/nft-data/GhostMarketNDSNeo3';
|
|
10
10
|
export * from './services/nft-data/RpcNDSNeo3';
|
|
11
|
+
export * from './services/vote/DoraVoteServiceNeo3';
|
|
12
|
+
export * from './services/neo3neoXBridge/Neo3NeoXBridgeService';
|
|
13
|
+
export * from './services/token/TokenServiceNeo3';
|
|
11
14
|
export * from './interfaces';
|
package/dist/index.js
CHANGED
|
@@ -24,4 +24,7 @@ __exportStar(require("./services/explorer/DoraESNeo3"), exports);
|
|
|
24
24
|
__exportStar(require("./services/ledger/NeonDappKitLedgerServiceNeo3"), exports);
|
|
25
25
|
__exportStar(require("./services/nft-data/GhostMarketNDSNeo3"), exports);
|
|
26
26
|
__exportStar(require("./services/nft-data/RpcNDSNeo3"), exports);
|
|
27
|
+
__exportStar(require("./services/vote/DoraVoteServiceNeo3"), exports);
|
|
28
|
+
__exportStar(require("./services/neo3neoXBridge/Neo3NeoXBridgeService"), exports);
|
|
29
|
+
__exportStar(require("./services/token/TokenServiceNeo3"), exports);
|
|
27
30
|
__exportStar(require("./interfaces"), exports);
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { BalanceResponse, ContractResponse, FullTransactionsByAddressParams, FullTransactionsByAddressResponse, Network, NftDataService, Token, TransactionResponse, TransactionsByAddressParams, TransactionsByAddressResponse, ExplorerService, ExportTransactionsByAddressParams } from '@cityofzion/blockchain-service';
|
|
1
|
+
import { BalanceResponse, ContractResponse, FullTransactionsByAddressParams, FullTransactionsByAddressResponse, Network, NftDataService, Token, TransactionResponse, TransactionsByAddressParams, TransactionsByAddressResponse, ExplorerService, ExportTransactionsByAddressParams, TokenService, INeo3NeoXBridgeService } from '@cityofzion/blockchain-service';
|
|
2
2
|
import { api } from '@cityofzion/dora-ts';
|
|
3
3
|
import { BSNeo3NetworkId } from '../../constants/BSNeo3Constants';
|
|
4
4
|
import { RpcBDSNeo3 } from './RpcBDSNeo3';
|
|
5
5
|
export declare const DoraNeoRest: api.NeoRESTApi;
|
|
6
6
|
export declare class DoraBDSNeo3 extends RpcBDSNeo3 {
|
|
7
7
|
#private;
|
|
8
|
-
constructor(network: Network<BSNeo3NetworkId>, feeToken: Token, claimToken: Token, tokens: Token[], nftDataService: NftDataService, explorerService: ExplorerService);
|
|
8
|
+
constructor(network: Network<BSNeo3NetworkId>, feeToken: Token, claimToken: Token, tokens: Token[], nftDataService: NftDataService, explorerService: ExplorerService, tokenService: TokenService, neo3NeoXBridgeService: INeo3NeoXBridgeService);
|
|
9
9
|
getTransaction(hash: string): Promise<TransactionResponse>;
|
|
10
10
|
getTransactionsByAddress({ address, nextPageParams, }: TransactionsByAddressParams): Promise<TransactionsByAddressResponse>;
|
|
11
11
|
getFullTransactionsByAddress({ nextCursor, ...params }: FullTransactionsByAddressParams): Promise<FullTransactionsByAddressResponse>;
|
|
@@ -30,12 +30,13 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
30
30
|
}
|
|
31
31
|
return t;
|
|
32
32
|
};
|
|
33
|
-
var _DoraBDSNeo3_instances, _DoraBDSNeo3_supportedNep11Standards, _DoraBDSNeo3_nftDataService, _DoraBDSNeo3_explorerService, _DoraBDSNeo3_validateAddress, _DoraBDSNeo3_validateFullTransactionsByAddressParams, _DoraBDSNeo3_validateGetFullTransactionsByAddressParams;
|
|
33
|
+
var _DoraBDSNeo3_instances, _DoraBDSNeo3_supportedNep11Standards, _DoraBDSNeo3_nftDataService, _DoraBDSNeo3_explorerService, _DoraBDSNeo3_neo3NeoXBridgeService, _DoraBDSNeo3_validateAddress, _DoraBDSNeo3_validateFullTransactionsByAddressParams, _DoraBDSNeo3_validateGetFullTransactionsByAddressParams, _DoraBDSNeo3_getBridgeNeo3NeoXDataByNotifications;
|
|
34
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
35
|
exports.DoraBDSNeo3 = exports.DoraNeoRest = void 0;
|
|
36
36
|
const blockchain_service_1 = require("@cityofzion/blockchain-service");
|
|
37
37
|
const dora_ts_1 = require("@cityofzion/dora-ts");
|
|
38
38
|
const neon_js_1 = require("@cityofzion/neon-js");
|
|
39
|
+
const BSNeo3Constants_1 = require("../../constants/BSNeo3Constants");
|
|
39
40
|
const BSNeo3Helper_1 = require("../../helpers/BSNeo3Helper");
|
|
40
41
|
const RpcBDSNeo3_1 = require("./RpcBDSNeo3");
|
|
41
42
|
exports.DoraNeoRest = new dora_ts_1.api.NeoRESTApi({
|
|
@@ -43,14 +44,16 @@ exports.DoraNeoRest = new dora_ts_1.api.NeoRESTApi({
|
|
|
43
44
|
endpoint: '/api/v2/neo3',
|
|
44
45
|
});
|
|
45
46
|
class DoraBDSNeo3 extends RpcBDSNeo3_1.RpcBDSNeo3 {
|
|
46
|
-
constructor(network, feeToken, claimToken, tokens, nftDataService, explorerService) {
|
|
47
|
-
super(network, feeToken, claimToken, tokens);
|
|
47
|
+
constructor(network, feeToken, claimToken, tokens, nftDataService, explorerService, tokenService, neo3NeoXBridgeService) {
|
|
48
|
+
super(network, feeToken, claimToken, tokens, tokenService);
|
|
48
49
|
_DoraBDSNeo3_instances.add(this);
|
|
49
50
|
_DoraBDSNeo3_supportedNep11Standards.set(this, ['nep11', 'nep-11']);
|
|
50
51
|
_DoraBDSNeo3_nftDataService.set(this, void 0);
|
|
51
52
|
_DoraBDSNeo3_explorerService.set(this, void 0);
|
|
53
|
+
_DoraBDSNeo3_neo3NeoXBridgeService.set(this, void 0);
|
|
52
54
|
__classPrivateFieldSet(this, _DoraBDSNeo3_nftDataService, nftDataService, "f");
|
|
53
55
|
__classPrivateFieldSet(this, _DoraBDSNeo3_explorerService, explorerService, "f");
|
|
56
|
+
__classPrivateFieldSet(this, _DoraBDSNeo3_neo3NeoXBridgeService, neo3NeoXBridgeService, "f");
|
|
54
57
|
}
|
|
55
58
|
getTransaction(hash) {
|
|
56
59
|
const _super = Object.create(null, {
|
|
@@ -73,6 +76,7 @@ class DoraBDSNeo3 extends RpcBDSNeo3_1.RpcBDSNeo3 {
|
|
|
73
76
|
fee: blockchain_service_1.BSBigNumberHelper.format(totalFee, { decimals: this._feeToken.decimals }),
|
|
74
77
|
notifications: [],
|
|
75
78
|
transfers: [],
|
|
79
|
+
type: 'default', // It's not possible to set the correct type because we don't have notifications here
|
|
76
80
|
};
|
|
77
81
|
}
|
|
78
82
|
catch (_c) {
|
|
@@ -90,11 +94,12 @@ class DoraBDSNeo3 extends RpcBDSNeo3_1.RpcBDSNeo3 {
|
|
|
90
94
|
}
|
|
91
95
|
const data = yield exports.DoraNeoRest.addressTXFull(address, nextPageParams, this._network.id);
|
|
92
96
|
const promises = data.items.map((item) => __awaiter(this, void 0, void 0, function* () {
|
|
93
|
-
var _a, _b;
|
|
97
|
+
var _a, _b, _c;
|
|
94
98
|
const transferPromises = [];
|
|
99
|
+
const notifications = (_a = item.notifications) !== null && _a !== void 0 ? _a : [];
|
|
95
100
|
item.notifications.forEach(({ contract: contractHash, state, event_name: eventName }) => {
|
|
96
101
|
var _a;
|
|
97
|
-
const properties = Array.isArray(state) ? state : (_a = state === null || state === void 0 ? void 0 : state.value) !== null && _a !== void 0 ? _a : [];
|
|
102
|
+
const properties = (Array.isArray(state) ? state : (_a = state === null || state === void 0 ? void 0 : state.value) !== null && _a !== void 0 ? _a : []);
|
|
98
103
|
if (eventName !== 'Transfer' || (properties.length !== 3 && properties.length !== 4))
|
|
99
104
|
return;
|
|
100
105
|
const promise = () => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -119,29 +124,33 @@ class DoraBDSNeo3 extends RpcBDSNeo3_1.RpcBDSNeo3 {
|
|
|
119
124
|
return {
|
|
120
125
|
from: convertedFrom,
|
|
121
126
|
to: convertedTo,
|
|
122
|
-
|
|
123
|
-
contractHash,
|
|
127
|
+
tokenHash: properties[3].value,
|
|
128
|
+
collectionHash: contractHash,
|
|
124
129
|
type: 'nft',
|
|
125
130
|
};
|
|
126
131
|
});
|
|
127
132
|
transferPromises.push(promise());
|
|
128
133
|
});
|
|
129
134
|
const transfers = yield Promise.all(transferPromises);
|
|
130
|
-
const
|
|
131
|
-
|
|
132
|
-
state: notification.state,
|
|
133
|
-
}));
|
|
134
|
-
const systemFeeNumber = blockchain_service_1.BSBigNumberHelper.fromNumber((_a = item.sysfee) !== null && _a !== void 0 ? _a : 0);
|
|
135
|
-
const networkFeeNumber = blockchain_service_1.BSBigNumberHelper.fromNumber((_b = item.netfee) !== null && _b !== void 0 ? _b : 0);
|
|
135
|
+
const systemFeeNumber = blockchain_service_1.BSBigNumberHelper.fromNumber((_b = item.sysfee) !== null && _b !== void 0 ? _b : 0);
|
|
136
|
+
const networkFeeNumber = blockchain_service_1.BSBigNumberHelper.fromNumber((_c = item.netfee) !== null && _c !== void 0 ? _c : 0);
|
|
136
137
|
const totalFee = systemFeeNumber.plus(networkFeeNumber);
|
|
137
|
-
|
|
138
|
+
let transaction = {
|
|
138
139
|
block: item.block,
|
|
139
140
|
time: Number(item.time),
|
|
140
141
|
hash: item.hash,
|
|
141
142
|
fee: blockchain_service_1.BSBigNumberHelper.format(totalFee, { decimals: this._feeToken.decimals }),
|
|
142
143
|
transfers,
|
|
143
|
-
notifications
|
|
144
|
+
notifications: notifications.map(notification => ({
|
|
145
|
+
eventName: notification.event_name,
|
|
146
|
+
state: notification.state,
|
|
147
|
+
})),
|
|
148
|
+
type: 'default',
|
|
144
149
|
};
|
|
150
|
+
const bridgeNeo3NeoXData = __classPrivateFieldGet(this, _DoraBDSNeo3_instances, "m", _DoraBDSNeo3_getBridgeNeo3NeoXDataByNotifications).call(this, notifications);
|
|
151
|
+
if (bridgeNeo3NeoXData)
|
|
152
|
+
transaction = Object.assign(Object.assign({}, transaction), { type: 'bridgeNeo3NeoX', data: bridgeNeo3NeoXData });
|
|
153
|
+
return transaction;
|
|
145
154
|
}));
|
|
146
155
|
const transactions = yield Promise.all(promises);
|
|
147
156
|
const limit = 15;
|
|
@@ -171,10 +180,10 @@ class DoraBDSNeo3 extends RpcBDSNeo3_1.RpcBDSNeo3 {
|
|
|
171
180
|
const txTemplateUrl = __classPrivateFieldGet(this, _DoraBDSNeo3_explorerService, "f").getTxTemplateUrl();
|
|
172
181
|
const nftTemplateUrl = __classPrivateFieldGet(this, _DoraBDSNeo3_explorerService, "f").getNftTemplateUrl();
|
|
173
182
|
const contractTemplateUrl = __classPrivateFieldGet(this, _DoraBDSNeo3_explorerService, "f").getContractTemplateUrl();
|
|
174
|
-
const itemPromises = items.map((_d) => __awaiter(this, void 0, void 0, function* () {
|
|
183
|
+
const itemPromises = items.map((_d, index) => __awaiter(this, void 0, void 0, function* () {
|
|
175
184
|
var { networkFeeAmount, systemFeeAmount } = _d, item = __rest(_d, ["networkFeeAmount", "systemFeeAmount"]);
|
|
176
185
|
const txId = item.transactionID;
|
|
177
|
-
|
|
186
|
+
let newItem = {
|
|
178
187
|
txId,
|
|
179
188
|
txIdUrl: txId ? txTemplateUrl === null || txTemplateUrl === void 0 ? void 0 : txTemplateUrl.replace('{txId}', txId) : undefined,
|
|
180
189
|
block: item.block,
|
|
@@ -188,23 +197,24 @@ class DoraBDSNeo3 extends RpcBDSNeo3_1.RpcBDSNeo3 {
|
|
|
188
197
|
? blockchain_service_1.BSBigNumberHelper.format(systemFeeAmount, { decimals: this._feeToken.decimals })
|
|
189
198
|
: undefined,
|
|
190
199
|
events: [],
|
|
200
|
+
type: 'default',
|
|
191
201
|
};
|
|
192
|
-
const eventPromises = item.events.map((event) => __awaiter(this, void 0, void 0, function* () {
|
|
193
|
-
var _e, _f, _g, _h, _j, _k;
|
|
194
|
-
|
|
195
|
-
let assetEvent;
|
|
196
|
-
const { methodName, tokenID: tokenId, contractHash: hash } = event;
|
|
202
|
+
const eventPromises = item.events.map((event, eventIndex) => __awaiter(this, void 0, void 0, function* () {
|
|
203
|
+
var _e, _f, _g, _h, _j, _k, _l;
|
|
204
|
+
const { methodName, tokenID: tokenHash, contractHash, contractName } = event;
|
|
197
205
|
const from = (_e = event.from) !== null && _e !== void 0 ? _e : undefined;
|
|
198
206
|
const to = (_f = event.to) !== null && _f !== void 0 ? _f : undefined;
|
|
199
207
|
const fromUrl = from ? addressTemplateUrl === null || addressTemplateUrl === void 0 ? void 0 : addressTemplateUrl.replace('{address}', from) : undefined;
|
|
200
208
|
const toUrl = to ? addressTemplateUrl === null || addressTemplateUrl === void 0 ? void 0 : addressTemplateUrl.replace('{address}', to) : undefined;
|
|
201
|
-
const
|
|
209
|
+
const contractHashUrl = contractHash ? contractTemplateUrl === null || contractTemplateUrl === void 0 ? void 0 : contractTemplateUrl.replace('{hash}', contractHash) : undefined;
|
|
202
210
|
const standard = (_j = (_h = (_g = event.supportedStandards) === null || _g === void 0 ? void 0 : _g[0]) === null || _h === void 0 ? void 0 : _h.toLowerCase()) !== null && _j !== void 0 ? _j : '';
|
|
203
|
-
const isNft = __classPrivateFieldGet(this, _DoraBDSNeo3_supportedNep11Standards, "f").includes(standard) && !!
|
|
211
|
+
const isNft = __classPrivateFieldGet(this, _DoraBDSNeo3_supportedNep11Standards, "f").includes(standard) && !!tokenHash;
|
|
204
212
|
if (isNft) {
|
|
205
|
-
const [nft] = yield blockchain_service_1.BSPromisesHelper.tryCatch(() => __classPrivateFieldGet(this, _DoraBDSNeo3_nftDataService, "f").getNft({
|
|
206
|
-
const nftUrl =
|
|
207
|
-
|
|
213
|
+
const [nft] = yield blockchain_service_1.BSPromisesHelper.tryCatch(() => __classPrivateFieldGet(this, _DoraBDSNeo3_nftDataService, "f").getNft({ collectionHash: contractHash, tokenHash }));
|
|
214
|
+
const nftUrl = contractHash
|
|
215
|
+
? nftTemplateUrl === null || nftTemplateUrl === void 0 ? void 0 : nftTemplateUrl.replace('{collectionHash}', contractHash).replace('{tokenHash}', tokenHash)
|
|
216
|
+
: undefined;
|
|
217
|
+
const nftEvent = {
|
|
208
218
|
eventType: 'nft',
|
|
209
219
|
amount: undefined,
|
|
210
220
|
methodName,
|
|
@@ -212,38 +222,48 @@ class DoraBDSNeo3 extends RpcBDSNeo3_1.RpcBDSNeo3 {
|
|
|
212
222
|
fromUrl,
|
|
213
223
|
to,
|
|
214
224
|
toUrl,
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
225
|
+
collectionHash: contractHash,
|
|
226
|
+
collectionHashUrl: contractHashUrl,
|
|
227
|
+
tokenHash,
|
|
218
228
|
tokenType: 'nep-11',
|
|
219
229
|
nftImageUrl: nft === null || nft === void 0 ? void 0 : nft.image,
|
|
220
230
|
nftUrl,
|
|
221
231
|
name: nft === null || nft === void 0 ? void 0 : nft.name,
|
|
222
|
-
collectionName: nft === null || nft === void 0 ? void 0 : nft.
|
|
232
|
+
collectionName: (_k = nft === null || nft === void 0 ? void 0 : nft.collection) === null || _k === void 0 ? void 0 : _k.name,
|
|
223
233
|
};
|
|
234
|
+
newItem.events.splice(eventIndex, 0, nftEvent);
|
|
235
|
+
return;
|
|
224
236
|
}
|
|
225
237
|
else {
|
|
226
|
-
const [token] = yield blockchain_service_1.BSPromisesHelper.tryCatch(() => this.getTokenInfo(
|
|
227
|
-
assetEvent = {
|
|
238
|
+
const [token] = yield blockchain_service_1.BSPromisesHelper.tryCatch(() => this.getTokenInfo(contractHash));
|
|
239
|
+
const assetEvent = {
|
|
228
240
|
eventType: 'token',
|
|
229
241
|
amount: event.amount
|
|
230
|
-
? blockchain_service_1.BSBigNumberHelper.format(event.amount, { decimals: (
|
|
242
|
+
? 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 })
|
|
231
243
|
: undefined,
|
|
232
244
|
methodName,
|
|
233
245
|
from,
|
|
234
246
|
fromUrl,
|
|
235
247
|
to,
|
|
236
248
|
toUrl,
|
|
237
|
-
|
|
238
|
-
|
|
249
|
+
contractHash,
|
|
250
|
+
contractHashUrl,
|
|
239
251
|
token: token !== null && token !== void 0 ? token : undefined,
|
|
240
252
|
tokenType: 'nep-17',
|
|
241
253
|
};
|
|
254
|
+
newItem.events.splice(eventIndex, 0, assetEvent);
|
|
255
|
+
}
|
|
256
|
+
if (newItem.type === 'default' && contractName === 'NeoXBridge') {
|
|
257
|
+
const [log] = yield blockchain_service_1.BSPromisesHelper.tryCatch(() => exports.DoraNeoRest.log(txId, this._network.id));
|
|
258
|
+
if (!!log && log.vmstate === 'HALT') {
|
|
259
|
+
const data = __classPrivateFieldGet(this, _DoraBDSNeo3_instances, "m", _DoraBDSNeo3_getBridgeNeo3NeoXDataByNotifications).call(this, log.notifications || []);
|
|
260
|
+
if (data)
|
|
261
|
+
newItem = Object.assign(Object.assign({}, newItem), { type: 'bridgeNeo3NeoX', data });
|
|
262
|
+
}
|
|
242
263
|
}
|
|
243
|
-
newItem.events.push(isNft ? nftEvent : assetEvent);
|
|
244
264
|
}));
|
|
245
265
|
yield Promise.allSettled(eventPromises);
|
|
246
|
-
data.
|
|
266
|
+
data.splice(index, 0, newItem);
|
|
247
267
|
}));
|
|
248
268
|
yield Promise.allSettled(itemPromises);
|
|
249
269
|
return { nextCursor: response.nextCursor, data };
|
|
@@ -295,10 +315,10 @@ class DoraBDSNeo3 extends RpcBDSNeo3_1.RpcBDSNeo3 {
|
|
|
295
315
|
if (cachedToken) {
|
|
296
316
|
return cachedToken;
|
|
297
317
|
}
|
|
298
|
-
let token = this._tokens.find(
|
|
318
|
+
let token = this._tokens.find(this._tokenService.predicateByHash(tokenHash));
|
|
299
319
|
if (!token) {
|
|
300
320
|
const { decimals, symbol, name, scripthash } = yield exports.DoraNeoRest.asset(tokenHash, this._network.id);
|
|
301
|
-
token =
|
|
321
|
+
token = this._tokenService.normalizeToken({
|
|
302
322
|
decimals: Number(decimals),
|
|
303
323
|
symbol,
|
|
304
324
|
name,
|
|
@@ -344,7 +364,7 @@ class DoraBDSNeo3 extends RpcBDSNeo3_1.RpcBDSNeo3 {
|
|
|
344
364
|
}
|
|
345
365
|
}
|
|
346
366
|
exports.DoraBDSNeo3 = DoraBDSNeo3;
|
|
347
|
-
_DoraBDSNeo3_supportedNep11Standards = new WeakMap(), _DoraBDSNeo3_nftDataService = new WeakMap(), _DoraBDSNeo3_explorerService = new WeakMap(), _DoraBDSNeo3_instances = new WeakSet(), _DoraBDSNeo3_validateAddress = function _DoraBDSNeo3_validateAddress(address) {
|
|
367
|
+
_DoraBDSNeo3_supportedNep11Standards = new WeakMap(), _DoraBDSNeo3_nftDataService = new WeakMap(), _DoraBDSNeo3_explorerService = new WeakMap(), _DoraBDSNeo3_neo3NeoXBridgeService = new WeakMap(), _DoraBDSNeo3_instances = new WeakSet(), _DoraBDSNeo3_validateAddress = function _DoraBDSNeo3_validateAddress(address) {
|
|
348
368
|
return neon_js_1.wallet.isAddress(address, 53);
|
|
349
369
|
}, _DoraBDSNeo3_validateFullTransactionsByAddressParams = function _DoraBDSNeo3_validateFullTransactionsByAddressParams(params) {
|
|
350
370
|
if (BSNeo3Helper_1.BSNeo3Helper.isCustomNet(this._network))
|
|
@@ -357,4 +377,30 @@ _DoraBDSNeo3_supportedNep11Standards = new WeakMap(), _DoraBDSNeo3_nftDataServic
|
|
|
357
377
|
if (typeof pageSize === 'number' && (isNaN(pageSize) || pageSize < 1 || pageSize > 500))
|
|
358
378
|
throw new Error('Page size should be between 1 and 500');
|
|
359
379
|
__classPrivateFieldGet(this, _DoraBDSNeo3_instances, "m", _DoraBDSNeo3_validateFullTransactionsByAddressParams).call(this, params);
|
|
380
|
+
}, _DoraBDSNeo3_getBridgeNeo3NeoXDataByNotifications = function _DoraBDSNeo3_getBridgeNeo3NeoXDataByNotifications(notifications) {
|
|
381
|
+
var _a, _b, _c;
|
|
382
|
+
const gasNotification = notifications.find(({ event_name }) => event_name === 'NativeDeposit');
|
|
383
|
+
const isNativeToken = !!gasNotification;
|
|
384
|
+
const neoNotification = !isNativeToken
|
|
385
|
+
? notifications.find(({ event_name }) => event_name === 'TokenDeposit')
|
|
386
|
+
: undefined;
|
|
387
|
+
const notification = isNativeToken ? gasNotification : neoNotification;
|
|
388
|
+
const notificationStateValue = (_a = notification === null || notification === void 0 ? void 0 : notification.state) === null || _a === void 0 ? void 0 : _a.value;
|
|
389
|
+
if (!notificationStateValue)
|
|
390
|
+
return undefined;
|
|
391
|
+
const decimals = isNativeToken ? BSNeo3Constants_1.BSNeo3Constants.GAS_TOKEN.decimals : BSNeo3Constants_1.BSNeo3Constants.NEO_TOKEN.decimals;
|
|
392
|
+
const amountIndex = isNativeToken ? 2 : 4;
|
|
393
|
+
const amountWithDecimals = ((_b = notificationStateValue === null || notificationStateValue === void 0 ? void 0 : notificationStateValue[amountIndex]) === null || _b === void 0 ? void 0 : _b.value) || 0;
|
|
394
|
+
const amount = blockchain_service_1.BSBigNumberHelper.format(neon_js_1.u.BigInteger.fromNumber(amountWithDecimals).toDecimal(decimals), {
|
|
395
|
+
decimals,
|
|
396
|
+
});
|
|
397
|
+
const receiverAddressIndex = isNativeToken ? 1 : 3;
|
|
398
|
+
const byteStringReceiverAddress = ((_c = notificationStateValue === null || notificationStateValue === void 0 ? void 0 : notificationStateValue[receiverAddressIndex]) === null || _c === void 0 ? void 0 : _c.value) || '';
|
|
399
|
+
if (!byteStringReceiverAddress)
|
|
400
|
+
return undefined;
|
|
401
|
+
const receiverAddress = `0x${neon_js_1.u.HexString.fromBase64(byteStringReceiverAddress).toLittleEndian()}`;
|
|
402
|
+
const token = __classPrivateFieldGet(this, _DoraBDSNeo3_neo3NeoXBridgeService, "f").tokens.find(this._tokenService.predicateByHash(isNativeToken ? BSNeo3Constants_1.BSNeo3Constants.GAS_TOKEN : BSNeo3Constants_1.BSNeo3Constants.NEO_TOKEN));
|
|
403
|
+
if (!token)
|
|
404
|
+
return undefined;
|
|
405
|
+
return { amount, token, receiverAddress };
|
|
360
406
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BalanceResponse, BDSClaimable, BlockchainDataService, ContractResponse, ExportTransactionsByAddressParams, FullTransactionsByAddressParams, FullTransactionsByAddressResponse, Network, RpcResponse, Token, TransactionResponse, TransactionsByAddressParams, TransactionsByAddressResponse } from '@cityofzion/blockchain-service';
|
|
1
|
+
import { BalanceResponse, BDSClaimable, BlockchainDataService, ContractResponse, ExportTransactionsByAddressParams, FullTransactionsByAddressParams, FullTransactionsByAddressResponse, Network, RpcResponse, Token, TokenService, TransactionResponse, TransactionsByAddressParams, TransactionsByAddressResponse } from '@cityofzion/blockchain-service';
|
|
2
2
|
import { BSNeo3NetworkId } from '../../constants/BSNeo3Constants';
|
|
3
3
|
export declare class RpcBDSNeo3 implements BlockchainDataService, BDSClaimable {
|
|
4
4
|
readonly _tokenCache: Map<string, Token>;
|
|
@@ -6,8 +6,9 @@ export declare class RpcBDSNeo3 implements BlockchainDataService, BDSClaimable {
|
|
|
6
6
|
readonly _claimToken: Token;
|
|
7
7
|
readonly _network: Network<BSNeo3NetworkId>;
|
|
8
8
|
readonly _tokens: Token[];
|
|
9
|
+
readonly _tokenService: TokenService;
|
|
9
10
|
maxTimeToConfirmTransactionInMs: number;
|
|
10
|
-
constructor(network: Network<BSNeo3NetworkId>, feeToken: Token, claimToken: Token, tokens: Token[]);
|
|
11
|
+
constructor(network: Network<BSNeo3NetworkId>, feeToken: Token, claimToken: Token, tokens: Token[], tokenService: TokenService);
|
|
11
12
|
getTransaction(hash: string): Promise<TransactionResponse>;
|
|
12
13
|
getTransactionsByAddress(_params: TransactionsByAddressParams): Promise<TransactionsByAddressResponse>;
|
|
13
14
|
getFullTransactionsByAddress(_params: FullTransactionsByAddressParams): Promise<FullTransactionsByAddressResponse>;
|
|
@@ -10,12 +10,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.RpcBDSNeo3 = void 0;
|
|
13
|
-
const blockchain_service_1 = require("@cityofzion/blockchain-service");
|
|
14
13
|
const neon_core_1 = require("@cityofzion/neon-core");
|
|
15
14
|
const neon_dappkit_1 = require("@cityofzion/neon-dappkit");
|
|
16
15
|
const BSNeo3Helper_1 = require("../../helpers/BSNeo3Helper");
|
|
17
16
|
class RpcBDSNeo3 {
|
|
18
|
-
constructor(network, feeToken, claimToken, tokens) {
|
|
17
|
+
constructor(network, feeToken, claimToken, tokens, tokenService) {
|
|
19
18
|
this._tokenCache = new Map();
|
|
20
19
|
this._tokens = [];
|
|
21
20
|
this.maxTimeToConfirmTransactionInMs = 1000 * 60 * 2;
|
|
@@ -23,6 +22,7 @@ class RpcBDSNeo3 {
|
|
|
23
22
|
this._feeToken = feeToken;
|
|
24
23
|
this._claimToken = claimToken;
|
|
25
24
|
this._tokens = tokens;
|
|
25
|
+
this._tokenService = tokenService;
|
|
26
26
|
}
|
|
27
27
|
getTransaction(hash) {
|
|
28
28
|
var _a, _b;
|
|
@@ -39,6 +39,7 @@ class RpcBDSNeo3 {
|
|
|
39
39
|
notifications: [],
|
|
40
40
|
transfers: [],
|
|
41
41
|
time: response.blocktime,
|
|
42
|
+
type: 'default', // It's not possible to set the correct type because we don't have notifications here
|
|
42
43
|
};
|
|
43
44
|
}
|
|
44
45
|
catch (_c) {
|
|
@@ -91,7 +92,7 @@ class RpcBDSNeo3 {
|
|
|
91
92
|
if (cachedToken) {
|
|
92
93
|
return cachedToken;
|
|
93
94
|
}
|
|
94
|
-
let token = this._tokens.find(
|
|
95
|
+
let token = this._tokens.find(this._tokenService.predicateByHash(tokenHash));
|
|
95
96
|
if (!token) {
|
|
96
97
|
const rpcClient = new neon_core_1.rpc.RPCClient(this._network.url);
|
|
97
98
|
const contractState = yield rpcClient.getContractState(tokenHash);
|
|
@@ -114,7 +115,7 @@ class RpcBDSNeo3 {
|
|
|
114
115
|
throw new Error('Invalid symbol');
|
|
115
116
|
const decimals = Number(response.stack[0].value);
|
|
116
117
|
const symbol = neon_core_1.u.base642utf8(response.stack[1].value);
|
|
117
|
-
token =
|
|
118
|
+
token = this._tokenService.normalizeToken({
|
|
118
119
|
name: contractState.manifest.name,
|
|
119
120
|
symbol,
|
|
120
121
|
hash: contractState.hash,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { ExchangeDataService, FlamingoForthewinEDS, GetTokenPriceHistoryParams, GetTokenPricesParams, Network, TokenPricesHistoryResponse, TokenPricesResponse } from '@cityofzion/blockchain-service';
|
|
1
|
+
import { ExchangeDataService, FlamingoForthewinEDS, GetTokenPriceHistoryParams, GetTokenPricesParams, Network, TokenPricesHistoryResponse, TokenPricesResponse, TokenService } from '@cityofzion/blockchain-service';
|
|
2
2
|
import { BSNeo3NetworkId } from '../../constants/BSNeo3Constants';
|
|
3
3
|
export declare class FlamingoForthewinEDSNeo3 extends FlamingoForthewinEDS implements ExchangeDataService {
|
|
4
4
|
#private;
|
|
5
|
-
constructor(network: Network<BSNeo3NetworkId
|
|
5
|
+
constructor(network: Network<BSNeo3NetworkId>, tokenService: TokenService);
|
|
6
6
|
getTokenPrices(params: GetTokenPricesParams): Promise<TokenPricesResponse[]>;
|
|
7
7
|
getTokenPriceHistory(params: GetTokenPriceHistoryParams): Promise<TokenPricesHistoryResponse[]>;
|
|
8
8
|
}
|
|
@@ -25,8 +25,8 @@ exports.FlamingoForthewinEDSNeo3 = void 0;
|
|
|
25
25
|
const blockchain_service_1 = require("@cityofzion/blockchain-service");
|
|
26
26
|
const BSNeo3Helper_1 = require("../../helpers/BSNeo3Helper");
|
|
27
27
|
class FlamingoForthewinEDSNeo3 extends blockchain_service_1.FlamingoForthewinEDS {
|
|
28
|
-
constructor(network) {
|
|
29
|
-
super();
|
|
28
|
+
constructor(network, tokenService) {
|
|
29
|
+
super(tokenService);
|
|
30
30
|
_FlamingoForthewinEDSNeo3_network.set(this, void 0);
|
|
31
31
|
__classPrivateFieldSet(this, _FlamingoForthewinEDSNeo3_network, network, "f");
|
|
32
32
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { BuildNftUrlParams, ExplorerService, Network } from '@cityofzion/blockchain-service';
|
|
1
|
+
import { BuildNftUrlParams, ExplorerService, Network, TokenService } from '@cityofzion/blockchain-service';
|
|
2
2
|
import { BSNeo3NetworkId } from '../../constants/BSNeo3Constants';
|
|
3
3
|
export declare class DoraESNeo3 implements ExplorerService {
|
|
4
4
|
#private;
|
|
5
|
-
constructor(network: Network<BSNeo3NetworkId
|
|
5
|
+
constructor(network: Network<BSNeo3NetworkId>, tokenService: TokenService);
|
|
6
6
|
buildTransactionUrl(hash: string): string;
|
|
7
7
|
buildContractUrl(contractHash: string): string;
|
|
8
|
-
buildNftUrl({
|
|
8
|
+
buildNftUrl({ collectionHash, tokenHash }: BuildNftUrlParams): string;
|
|
9
9
|
getAddressTemplateUrl(): string | undefined;
|
|
10
10
|
getTxTemplateUrl(): string | undefined;
|
|
11
11
|
getNftTemplateUrl(): string | undefined;
|
|
@@ -10,31 +10,33 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
10
10
|
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");
|
|
11
11
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
12
|
};
|
|
13
|
-
var _DoraESNeo3_BASE_URL, _DoraESNeo3_network;
|
|
13
|
+
var _DoraESNeo3_BASE_URL, _DoraESNeo3_network, _DoraESNeo3_tokenService;
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.DoraESNeo3 = void 0;
|
|
16
16
|
const blockchain_service_1 = require("@cityofzion/blockchain-service");
|
|
17
17
|
const BSNeo3Helper_1 = require("../../helpers/BSNeo3Helper");
|
|
18
18
|
class DoraESNeo3 {
|
|
19
|
-
constructor(network) {
|
|
19
|
+
constructor(network, tokenService) {
|
|
20
20
|
_DoraESNeo3_BASE_URL.set(this, blockchain_service_1.BSCommonConstants.DORA_URL);
|
|
21
21
|
_DoraESNeo3_network.set(this, void 0);
|
|
22
|
+
_DoraESNeo3_tokenService.set(this, void 0);
|
|
22
23
|
__classPrivateFieldSet(this, _DoraESNeo3_network, network, "f");
|
|
24
|
+
__classPrivateFieldSet(this, _DoraESNeo3_tokenService, tokenService, "f");
|
|
23
25
|
}
|
|
24
26
|
buildTransactionUrl(hash) {
|
|
25
27
|
if (BSNeo3Helper_1.BSNeo3Helper.isCustomNet(__classPrivateFieldGet(this, _DoraESNeo3_network, "f")))
|
|
26
28
|
throw new Error('DoraESNeo3 is only available on mainnet and testnet');
|
|
27
|
-
return `${__classPrivateFieldGet(this, _DoraESNeo3_BASE_URL, "f")}/transaction/neo3/${__classPrivateFieldGet(this, _DoraESNeo3_network, "f").id}/${
|
|
29
|
+
return `${__classPrivateFieldGet(this, _DoraESNeo3_BASE_URL, "f")}/transaction/neo3/${__classPrivateFieldGet(this, _DoraESNeo3_network, "f").id}/${__classPrivateFieldGet(this, _DoraESNeo3_tokenService, "f").normalizeHash(hash)}`;
|
|
28
30
|
}
|
|
29
31
|
buildContractUrl(contractHash) {
|
|
30
32
|
if (BSNeo3Helper_1.BSNeo3Helper.isCustomNet(__classPrivateFieldGet(this, _DoraESNeo3_network, "f")))
|
|
31
33
|
throw new Error('DoraESNeo3 is only available on mainnet and testnet');
|
|
32
|
-
return `${__classPrivateFieldGet(this, _DoraESNeo3_BASE_URL, "f")}/contract/neo3/${__classPrivateFieldGet(this, _DoraESNeo3_network, "f").id}/${
|
|
34
|
+
return `${__classPrivateFieldGet(this, _DoraESNeo3_BASE_URL, "f")}/contract/neo3/${__classPrivateFieldGet(this, _DoraESNeo3_network, "f").id}/${__classPrivateFieldGet(this, _DoraESNeo3_tokenService, "f").normalizeHash(contractHash)}`;
|
|
33
35
|
}
|
|
34
|
-
buildNftUrl({
|
|
36
|
+
buildNftUrl({ collectionHash, tokenHash }) {
|
|
35
37
|
if (BSNeo3Helper_1.BSNeo3Helper.isCustomNet(__classPrivateFieldGet(this, _DoraESNeo3_network, "f")))
|
|
36
38
|
throw new Error('DoraESNeo3 is only available on mainnet and testnet');
|
|
37
|
-
return `${__classPrivateFieldGet(this, _DoraESNeo3_BASE_URL, "f")}/nft/neo3/${__classPrivateFieldGet(this, _DoraESNeo3_network, "f").id}/${
|
|
39
|
+
return `${__classPrivateFieldGet(this, _DoraESNeo3_BASE_URL, "f")}/nft/neo3/${__classPrivateFieldGet(this, _DoraESNeo3_network, "f").id}/${collectionHash}/${tokenHash}`;
|
|
38
40
|
}
|
|
39
41
|
getAddressTemplateUrl() {
|
|
40
42
|
if (BSNeo3Helper_1.BSNeo3Helper.isCustomNet(__classPrivateFieldGet(this, _DoraESNeo3_network, "f")))
|
|
@@ -49,7 +51,7 @@ class DoraESNeo3 {
|
|
|
49
51
|
getNftTemplateUrl() {
|
|
50
52
|
if (BSNeo3Helper_1.BSNeo3Helper.isCustomNet(__classPrivateFieldGet(this, _DoraESNeo3_network, "f")))
|
|
51
53
|
return undefined;
|
|
52
|
-
return `${__classPrivateFieldGet(this, _DoraESNeo3_BASE_URL, "f")}/nft/neo3/${__classPrivateFieldGet(this, _DoraESNeo3_network, "f").id}/{
|
|
54
|
+
return `${__classPrivateFieldGet(this, _DoraESNeo3_BASE_URL, "f")}/nft/neo3/${__classPrivateFieldGet(this, _DoraESNeo3_network, "f").id}/{collectionHash}/{tokenHash}`;
|
|
53
55
|
}
|
|
54
56
|
getContractTemplateUrl() {
|
|
55
57
|
if (BSNeo3Helper_1.BSNeo3Helper.isCustomNet(__classPrivateFieldGet(this, _DoraESNeo3_network, "f")))
|
|
@@ -58,4 +60,4 @@ class DoraESNeo3 {
|
|
|
58
60
|
}
|
|
59
61
|
}
|
|
60
62
|
exports.DoraESNeo3 = DoraESNeo3;
|
|
61
|
-
_DoraESNeo3_BASE_URL = new WeakMap(), _DoraESNeo3_network = new WeakMap();
|
|
63
|
+
_DoraESNeo3_BASE_URL = new WeakMap(), _DoraESNeo3_network = new WeakMap(), _DoraESNeo3_tokenService = new WeakMap();
|
|
@@ -51,7 +51,7 @@ class Neo3NeoXBridgeService {
|
|
|
51
51
|
const invoker = yield neon_dappkit_1.NeonInvoker.init({
|
|
52
52
|
rpcAddress: __classPrivateFieldGet(this, _Neo3NeoXBridgeService_service, "f").network.url,
|
|
53
53
|
});
|
|
54
|
-
const isNativeToken =
|
|
54
|
+
const isNativeToken = __classPrivateFieldGet(this, _Neo3NeoXBridgeService_service, "f").tokenService.predicateByHash(token)(BSNeo3Constants_1.BSNeo3Constants.GAS_TOKEN);
|
|
55
55
|
let invocations;
|
|
56
56
|
if (isNativeToken) {
|
|
57
57
|
invocations = [
|
|
@@ -132,7 +132,7 @@ class Neo3NeoXBridgeService {
|
|
|
132
132
|
scopes: 16,
|
|
133
133
|
allowedContracts: [this.BRIDGE_SCRIPT_HASH, BSNeo3Constants_1.BSNeo3Constants.GAS_TOKEN.hash],
|
|
134
134
|
};
|
|
135
|
-
const isNativeToken =
|
|
135
|
+
const isNativeToken = __classPrivateFieldGet(this, _Neo3NeoXBridgeService_service, "f").tokenService.predicateByHash(params.token)(BSNeo3Constants_1.BSNeo3Constants.GAS_TOKEN);
|
|
136
136
|
if (!isNativeToken) {
|
|
137
137
|
(_a = contractInvocation.args) === null || _a === void 0 ? void 0 : _a.unshift({ type: 'Hash160', value: BSNeo3Constants_1.BSNeo3Constants.NEO_TOKEN.hash });
|
|
138
138
|
(_b = signer.allowedContracts) === null || _b === void 0 ? void 0 : _b.push(BSNeo3Constants_1.BSNeo3Constants.NEO_TOKEN.hash);
|
|
@@ -157,7 +157,7 @@ class Neo3NeoXBridgeService {
|
|
|
157
157
|
if ((log === null || log === void 0 ? void 0 : log.vmstate) !== 'HALT') {
|
|
158
158
|
throw new blockchain_service_1.BSError('Transaction invalid', 'INVALID_TRANSACTION');
|
|
159
159
|
}
|
|
160
|
-
const isNativeToken =
|
|
160
|
+
const isNativeToken = __classPrivateFieldGet(this, _Neo3NeoXBridgeService_service, "f").tokenService.predicateByHash(params.token)(BSNeo3Constants_1.BSNeo3Constants.GAS_TOKEN);
|
|
161
161
|
let nonce = null;
|
|
162
162
|
if (isNativeToken) {
|
|
163
163
|
const notification = log.notifications.find(item => item.event_name === 'NativeDeposit');
|
|
@@ -177,7 +177,7 @@ class Neo3NeoXBridgeService {
|
|
|
177
177
|
return __awaiter(this, void 0, void 0, function* () {
|
|
178
178
|
let data;
|
|
179
179
|
try {
|
|
180
|
-
const isNativeToken =
|
|
180
|
+
const isNativeToken = __classPrivateFieldGet(this, _Neo3NeoXBridgeService_service, "f").tokenService.predicateByHash(params.token)(BSNeo3Constants_1.BSNeo3Constants.GAS_TOKEN);
|
|
181
181
|
const response = yield axios_1.default.post('https://neofura.ngd.network', {
|
|
182
182
|
jsonrpc: '2.0',
|
|
183
183
|
method: 'GetBridgeTxByNonce',
|
|
@@ -9,5 +9,5 @@ export declare class GhostMarketNDSNeo3 extends RpcNDSNeo3 {
|
|
|
9
9
|
}>>;
|
|
10
10
|
constructor(network: Network<BSNeo3NetworkId>);
|
|
11
11
|
getNftsByAddress({ address, size, cursor }: GetNftsByAddressParams): Promise<NftsResponse>;
|
|
12
|
-
getNft({
|
|
12
|
+
getNft({ collectionHash, tokenHash }: GetNftParam): Promise<NftResponse>;
|
|
13
13
|
}
|
|
@@ -25,7 +25,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
25
25
|
var _GhostMarketNDSNeo3_instances, _GhostMarketNDSNeo3_network, _GhostMarketNDSNeo3_treatGhostMarketImage, _GhostMarketNDSNeo3_getUrlWithParams, _GhostMarketNDSNeo3_parse;
|
|
26
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
27
|
exports.GhostMarketNDSNeo3 = void 0;
|
|
28
|
-
const blockchain_service_1 = require("@cityofzion/blockchain-service");
|
|
29
28
|
const axios_1 = __importDefault(require("axios"));
|
|
30
29
|
const query_string_1 = __importDefault(require("query-string"));
|
|
31
30
|
const RpcNDSNeo3_1 = require("./RpcNDSNeo3");
|
|
@@ -49,11 +48,11 @@ class GhostMarketNDSNeo3 extends RpcNDSNeo3_1.RpcNDSNeo3 {
|
|
|
49
48
|
return { nextCursor: data.next, items: nfts.map(__classPrivateFieldGet(this, _GhostMarketNDSNeo3_instances, "m", _GhostMarketNDSNeo3_parse).bind(this)) };
|
|
50
49
|
});
|
|
51
50
|
}
|
|
52
|
-
getNft({
|
|
51
|
+
getNft({ collectionHash, tokenHash }) {
|
|
53
52
|
return __awaiter(this, void 0, void 0, function* () {
|
|
54
53
|
const url = __classPrivateFieldGet(this, _GhostMarketNDSNeo3_instances, "m", _GhostMarketNDSNeo3_getUrlWithParams).call(this, {
|
|
55
|
-
contract:
|
|
56
|
-
tokenIds: [
|
|
54
|
+
contract: collectionHash,
|
|
55
|
+
tokenIds: [tokenHash],
|
|
57
56
|
});
|
|
58
57
|
const { data } = yield axios_1.default.get(url);
|
|
59
58
|
return __classPrivateFieldGet(this, _GhostMarketNDSNeo3_instances, "m", _GhostMarketNDSNeo3_parse).call(this, data.assets[0]);
|
|
@@ -81,11 +80,13 @@ _GhostMarketNDSNeo3_network = new WeakMap(), _GhostMarketNDSNeo3_instances = new
|
|
|
81
80
|
}, _GhostMarketNDSNeo3_parse = function _GhostMarketNDSNeo3_parse(data) {
|
|
82
81
|
var _a, _b;
|
|
83
82
|
const nftResponse = {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
83
|
+
hash: data.tokenId,
|
|
84
|
+
collection: {
|
|
85
|
+
hash: data.contract.hash,
|
|
86
|
+
name: (_a = data.collection) === null || _a === void 0 ? void 0 : _a.name,
|
|
87
|
+
image: __classPrivateFieldGet(this, _GhostMarketNDSNeo3_instances, "m", _GhostMarketNDSNeo3_treatGhostMarketImage).call(this, (_b = data.collection) === null || _b === void 0 ? void 0 : _b.logoUrl),
|
|
88
|
+
},
|
|
87
89
|
symbol: data.contract.symbol,
|
|
88
|
-
collectionName: (_b = data.collection) === null || _b === void 0 ? void 0 : _b.name,
|
|
89
90
|
image: __classPrivateFieldGet(this, _GhostMarketNDSNeo3_instances, "m", _GhostMarketNDSNeo3_treatGhostMarketImage).call(this, data.metadata.mediaUri),
|
|
90
91
|
isSVG: String(data.metadata.mediaType).includes('svg+xml'),
|
|
91
92
|
name: data.metadata.name,
|
|
@@ -5,5 +5,5 @@ export declare abstract class RpcNDSNeo3 implements NftDataService {
|
|
|
5
5
|
protected constructor(network: Network<BSNeo3NetworkId>);
|
|
6
6
|
abstract getNftsByAddress(params: GetNftsByAddressParams): Promise<NftsResponse>;
|
|
7
7
|
abstract getNft(params: GetNftParam): Promise<NftResponse>;
|
|
8
|
-
hasToken({
|
|
8
|
+
hasToken({ collectionHash, address }: HasTokenParam): Promise<boolean>;
|
|
9
9
|
}
|
|
@@ -28,7 +28,7 @@ class RpcNDSNeo3 {
|
|
|
28
28
|
_RpcNDSNeo3_network.set(this, void 0);
|
|
29
29
|
__classPrivateFieldSet(this, _RpcNDSNeo3_network, network, "f");
|
|
30
30
|
}
|
|
31
|
-
hasToken({
|
|
31
|
+
hasToken({ collectionHash, address }) {
|
|
32
32
|
return __awaiter(this, void 0, void 0, function* () {
|
|
33
33
|
const parser = neon_dappkit_1.NeonParser;
|
|
34
34
|
const invoker = yield neon_dappkit_1.NeonInvoker.init({ rpcAddress: __classPrivateFieldGet(this, _RpcNDSNeo3_network, "f").url });
|
|
@@ -36,7 +36,7 @@ class RpcNDSNeo3 {
|
|
|
36
36
|
const result = yield invoker.testInvoke({
|
|
37
37
|
invocations: [
|
|
38
38
|
{
|
|
39
|
-
scriptHash:
|
|
39
|
+
scriptHash: collectionHash,
|
|
40
40
|
operation: 'balanceOf',
|
|
41
41
|
args: [
|
|
42
42
|
{
|
|
@@ -50,7 +50,7 @@ class RpcNDSNeo3 {
|
|
|
50
50
|
return parser.parseRpcResponse(result.stack[0], { type: 'Integer' }) > 0;
|
|
51
51
|
}
|
|
52
52
|
catch (_a) {
|
|
53
|
-
throw new Error(`Token not found: ${
|
|
53
|
+
throw new Error(`Token not found: ${collectionHash}`);
|
|
54
54
|
}
|
|
55
55
|
});
|
|
56
56
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TokenServiceNeo3 = void 0;
|
|
4
|
+
const blockchain_service_1 = require("@cityofzion/blockchain-service");
|
|
5
|
+
class TokenServiceNeo3 extends blockchain_service_1.TokenService {
|
|
6
|
+
normalizeHash(hash) {
|
|
7
|
+
const fixed = hash.startsWith('0x') ? hash : `0x${hash}`;
|
|
8
|
+
return fixed.toLowerCase();
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.TokenServiceNeo3 = TokenServiceNeo3;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cityofzion/bs-neo3",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.16.1",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"repository": "https://github.com/CityOfZion/blockchain-services",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"isomorphic-ws": "^5.0.0",
|
|
22
22
|
"lodash.clonedeep": "^4.5.0",
|
|
23
23
|
"date-fns": "~4.1.0",
|
|
24
|
-
"@cityofzion/blockchain-service": "1.
|
|
24
|
+
"@cityofzion/blockchain-service": "1.21.0",
|
|
25
25
|
"@cityofzion/bs-asteroid-sdk": "0.9.1"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"eslint": "^8.48.0",
|
|
36
36
|
"jest": "29.6.2",
|
|
37
37
|
"ts-jest": "29.1.1",
|
|
38
|
-
"ts-node": "10.9.
|
|
38
|
+
"ts-node": "~10.9.2",
|
|
39
39
|
"typescript": "4.9.5",
|
|
40
40
|
"typed-emitter": "^2.1.0"
|
|
41
41
|
},
|