@cityofzion/bs-neo3 1.14.0 → 1.15.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/BSNeo3.d.ts +3 -2
- package/dist/BSNeo3.js +4 -3
- package/dist/assets/tokens/native.json +2 -2
- package/dist/constants/BSNeo3Constants.d.ts +3 -1
- package/dist/constants/BSNeo3Constants.js +6 -2
- package/dist/helpers/BSNeo3Helper.d.ts +1 -7
- package/dist/helpers/BSNeo3Helper.js +1 -9
- package/dist/services/blockchain-data/DoraBDSNeo3.d.ts +2 -0
- package/dist/services/blockchain-data/DoraBDSNeo3.js +34 -32
- package/dist/services/blockchain-data/RpcBDSNeo3.js +35 -33
- package/dist/services/explorer/DoraESNeo3.js +3 -3
- package/dist/services/neo3neoXBridge/Neo3NeoXBridgeService.d.ts +16 -0
- package/dist/services/neo3neoXBridge/Neo3NeoXBridgeService.js +302 -0
- package/dist/services/nft-data/GhostMarketNDSNeo3.js +3 -2
- package/dist/services/vote/DoraVoteServiceNeo3.js +7 -5
- package/dist/services/vote/RpcVoteServiceNeo3.d.ts +0 -1
- package/dist/services/vote/RpcVoteServiceNeo3.js +18 -11
- package/package.json +2 -2
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, Network, NftDataService, Token, TransferParam } from '@cityofzion/blockchain-service';
|
|
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';
|
|
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> {
|
|
5
|
+
export declare class BSNeo3<BSName extends string = string> implements BlockchainService<BSName, BSNeo3NetworkId>, BSClaimable<BSName>, BSWithNameService, BSCalculableFee<BSName>, BSWithNft, BSWithExplorerService, BSWithLedger<BSName>, IBSWithNeo3NeoXBridge<BSName> {
|
|
6
6
|
#private;
|
|
7
7
|
name: BSName;
|
|
8
8
|
bip44DerivationPath: string;
|
|
@@ -17,6 +17,7 @@ export declare class BSNeo3<BSName extends string = string> implements Blockchai
|
|
|
17
17
|
exchangeDataService: ExchangeDataService;
|
|
18
18
|
explorerService: ExplorerService;
|
|
19
19
|
voteService: VoteService<BSName>;
|
|
20
|
+
neo3NeoXBridgeService: INeo3NeoXBridgeService<BSName>;
|
|
20
21
|
network: Network<BSNeo3NetworkId>;
|
|
21
22
|
constructor(name: BSName, network?: Network<BSNeo3NetworkId>, getLedgerTransport?: GetLedgerTransport<BSName>);
|
|
22
23
|
generateSigningCallback(account: Account<BSName>): Promise<GenerateSigningCallbackResponse>;
|
package/dist/BSNeo3.js
CHANGED
|
@@ -16,6 +16,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
16
16
|
var _BSNeo3_instances, _BSNeo3_setTokens, _BSNeo3_buildTransferInvocation;
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.BSNeo3 = void 0;
|
|
19
|
+
const blockchain_service_1 = require("@cityofzion/blockchain-service");
|
|
19
20
|
const bs_asteroid_sdk_1 = require("@cityofzion/bs-asteroid-sdk");
|
|
20
21
|
const neon_dappkit_1 = require("@cityofzion/neon-dappkit");
|
|
21
22
|
const neon_js_1 = require("@cityofzion/neon-js");
|
|
@@ -27,6 +28,7 @@ const NeonDappKitLedgerServiceNeo3_1 = require("./services/ledger/NeonDappKitLed
|
|
|
27
28
|
const GhostMarketNDSNeo3_1 = require("./services/nft-data/GhostMarketNDSNeo3");
|
|
28
29
|
const BSNeo3Constants_1 = require("./constants/BSNeo3Constants");
|
|
29
30
|
const RpcBDSNeo3_1 = require("./services/blockchain-data/RpcBDSNeo3");
|
|
31
|
+
const Neo3NeoXBridgeService_1 = require("./services/neo3neoXBridge/Neo3NeoXBridgeService");
|
|
30
32
|
const DoraVoteServiceNeo3_1 = require("./services/vote/DoraVoteServiceNeo3");
|
|
31
33
|
class BSNeo3 {
|
|
32
34
|
constructor(name, network, getLedgerTransport) {
|
|
@@ -69,6 +71,7 @@ class BSNeo3 {
|
|
|
69
71
|
this.nftDataService = new GhostMarketNDSNeo3_1.GhostMarketNDSNeo3(network);
|
|
70
72
|
this.explorerService = new DoraESNeo3_1.DoraESNeo3(network);
|
|
71
73
|
this.voteService = new DoraVoteServiceNeo3_1.DoraVoteServiceNeo3(this);
|
|
74
|
+
this.neo3NeoXBridgeService = new Neo3NeoXBridgeService_1.Neo3NeoXBridgeService(this);
|
|
72
75
|
this.blockchainDataService = new DoraBDSNeo3_1.DoraBDSNeo3(network, this.feeToken, this.claimToken, this.tokens, this.nftDataService, this.explorerService);
|
|
73
76
|
this.exchangeDataService = new FlamingoForthewinEDSNeo3_1.FlamingoForthewinEDSNeo3(network);
|
|
74
77
|
}
|
|
@@ -216,9 +219,7 @@ _BSNeo3_instances = new WeakSet(), _BSNeo3_setTokens = function _BSNeo3_setToken
|
|
|
216
219
|
{ type: 'Hash160', value: intent.receiverAddress },
|
|
217
220
|
{
|
|
218
221
|
type: 'Integer',
|
|
219
|
-
value: intent.
|
|
220
|
-
? neon_js_1.u.BigInteger.fromDecimal(Number(intent.amount).toFixed(intent.tokenDecimals), intent.tokenDecimals).toString()
|
|
221
|
-
: intent.amount,
|
|
222
|
+
value: blockchain_service_1.BSBigNumberHelper.toDecimals(blockchain_service_1.BSBigNumberHelper.fromNumber(intent.amount), decimals),
|
|
222
223
|
},
|
|
223
224
|
{ type: 'Any', value: null },
|
|
224
225
|
],
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
{
|
|
3
3
|
"symbol": "GAS",
|
|
4
4
|
"name": "GAS",
|
|
5
|
-
"hash": "
|
|
5
|
+
"hash": "0xd2a4cff31913016155e38e474a2c06d08be276cf",
|
|
6
6
|
"decimals": 8
|
|
7
7
|
},
|
|
8
8
|
{
|
|
9
9
|
"symbol": "NEO",
|
|
10
10
|
"name": "NEO",
|
|
11
|
-
"hash": "
|
|
11
|
+
"hash": "0xef4073a0f2b305a38ec4050e4d3d28bc40ea63f5",
|
|
12
12
|
"decimals": 0
|
|
13
13
|
}
|
|
14
14
|
]
|
|
@@ -2,6 +2,9 @@ import { Network, NetworkId, Token } from '@cityofzion/blockchain-service';
|
|
|
2
2
|
export type BSNeo3NetworkId = NetworkId<'mainnet' | 'testnet'>;
|
|
3
3
|
export declare class BSNeo3Constants {
|
|
4
4
|
static EXTRA_TOKENS_BY_NETWORK_ID: Partial<Record<BSNeo3NetworkId, Token[]>>;
|
|
5
|
+
static NATIVE_ASSETS: Token[];
|
|
6
|
+
static GAS_TOKEN: Token;
|
|
7
|
+
static NEO_TOKEN: Token;
|
|
5
8
|
static RPC_LIST_BY_NETWORK_ID: Partial<Record<BSNeo3NetworkId, string[]>>;
|
|
6
9
|
static MAINNET_NETWORK_IDS: BSNeo3NetworkId[];
|
|
7
10
|
static TESTNET_NETWORK_IDS: BSNeo3NetworkId[];
|
|
@@ -12,5 +15,4 @@ export declare class BSNeo3Constants {
|
|
|
12
15
|
static DEFAULT_NETWORK: Network<BSNeo3NetworkId>;
|
|
13
16
|
static NEO_NS_HASH: string;
|
|
14
17
|
static DEFAULT_BIP44_DERIVATION_PATH: string;
|
|
15
|
-
static NATIVE_ASSETS: Token[];
|
|
16
18
|
}
|
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
var _a;
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.BSNeo3Constants = void 0;
|
|
8
|
+
const blockchain_service_1 = require("@cityofzion/blockchain-service");
|
|
8
9
|
const mainnet_json_1 = __importDefault(require("../assets/tokens/mainnet.json"));
|
|
9
10
|
const native_json_1 = __importDefault(require("../assets/tokens/native.json"));
|
|
10
11
|
class BSNeo3Constants {
|
|
@@ -12,8 +13,11 @@ class BSNeo3Constants {
|
|
|
12
13
|
exports.BSNeo3Constants = BSNeo3Constants;
|
|
13
14
|
_a = BSNeo3Constants;
|
|
14
15
|
BSNeo3Constants.EXTRA_TOKENS_BY_NETWORK_ID = {
|
|
15
|
-
mainnet: mainnet_json_1.default,
|
|
16
|
+
mainnet: blockchain_service_1.BSTokenHelper.normalizeToken(mainnet_json_1.default),
|
|
16
17
|
};
|
|
18
|
+
BSNeo3Constants.NATIVE_ASSETS = blockchain_service_1.BSTokenHelper.normalizeToken(native_json_1.default);
|
|
19
|
+
BSNeo3Constants.GAS_TOKEN = _a.NATIVE_ASSETS.find(token => token.name === 'GAS');
|
|
20
|
+
BSNeo3Constants.NEO_TOKEN = _a.NATIVE_ASSETS.find(token => token.name === 'NEO');
|
|
17
21
|
BSNeo3Constants.RPC_LIST_BY_NETWORK_ID = {
|
|
18
22
|
mainnet: [
|
|
19
23
|
'https://mainnet1.neo.coz.io:443',
|
|
@@ -55,7 +59,7 @@ BSNeo3Constants.TESTNET_NETWORKS = [
|
|
|
55
59
|
},
|
|
56
60
|
];
|
|
57
61
|
BSNeo3Constants.ALL_NETWORKS = [..._a.MAINNET_NETWORKS, ..._a.TESTNET_NETWORKS];
|
|
62
|
+
// If tou change this, make sure to update the tests accordingly
|
|
58
63
|
BSNeo3Constants.DEFAULT_NETWORK = _a.MAINNET_NETWORKS[0];
|
|
59
64
|
BSNeo3Constants.NEO_NS_HASH = '0x50ac1c37690cc2cfc594472833cf57505d5f46de';
|
|
60
65
|
BSNeo3Constants.DEFAULT_BIP44_DERIVATION_PATH = "m/44'/888'/0'/0/?";
|
|
61
|
-
BSNeo3Constants.NATIVE_ASSETS = native_json_1.default;
|
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
import { Network } from '@cityofzion/blockchain-service';
|
|
2
2
|
import { BSNeo3NetworkId } from '../constants/BSNeo3Constants';
|
|
3
3
|
export declare class BSNeo3Helper {
|
|
4
|
-
static getTokens(network: Network<BSNeo3NetworkId>):
|
|
5
|
-
symbol: string;
|
|
6
|
-
name: string;
|
|
7
|
-
hash: string;
|
|
8
|
-
decimals: number;
|
|
9
|
-
}[];
|
|
4
|
+
static getTokens(network: Network<BSNeo3NetworkId>): import("@cityofzion/blockchain-service").Token[];
|
|
10
5
|
static getRpcList(network: Network<BSNeo3NetworkId>): string[];
|
|
11
6
|
static isMainnet(network: Network<BSNeo3NetworkId>): boolean;
|
|
12
7
|
static isCustomNet(network: Network<BSNeo3NetworkId>): boolean;
|
|
13
|
-
static normalizeHash(hash: string): string;
|
|
14
8
|
}
|
|
@@ -1,17 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.BSNeo3Helper = void 0;
|
|
7
|
-
const blockchain_service_1 = require("@cityofzion/blockchain-service");
|
|
8
|
-
const native_json_1 = __importDefault(require("../assets/tokens/native.json"));
|
|
9
4
|
const BSNeo3Constants_1 = require("../constants/BSNeo3Constants");
|
|
10
5
|
class BSNeo3Helper {
|
|
11
6
|
static getTokens(network) {
|
|
12
7
|
var _a;
|
|
13
8
|
const extraTokens = (_a = BSNeo3Constants_1.BSNeo3Constants.EXTRA_TOKENS_BY_NETWORK_ID[network.id]) !== null && _a !== void 0 ? _a : [];
|
|
14
|
-
return [...extraTokens, ...
|
|
9
|
+
return [...extraTokens, ...BSNeo3Constants_1.BSNeo3Constants.NATIVE_ASSETS];
|
|
15
10
|
}
|
|
16
11
|
static getRpcList(network) {
|
|
17
12
|
var _a;
|
|
@@ -23,8 +18,5 @@ class BSNeo3Helper {
|
|
|
23
18
|
static isCustomNet(network) {
|
|
24
19
|
return !BSNeo3Constants_1.BSNeo3Constants.ALL_NETWORK_IDS.includes(network.id);
|
|
25
20
|
}
|
|
26
|
-
static normalizeHash(hash) {
|
|
27
|
-
return (0, blockchain_service_1.normalizeHash)(hash, { lowercase: false });
|
|
28
|
-
}
|
|
29
21
|
}
|
|
30
22
|
exports.BSNeo3Helper = BSNeo3Helper;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { BalanceResponse, ContractResponse, FullTransactionsByAddressParams, FullTransactionsByAddressResponse, Network, NftDataService, Token, TransactionResponse, TransactionsByAddressParams, TransactionsByAddressResponse, ExplorerService, ExportTransactionsByAddressParams } from '@cityofzion/blockchain-service';
|
|
2
|
+
import { api } from '@cityofzion/dora-ts';
|
|
2
3
|
import { BSNeo3NetworkId } from '../../constants/BSNeo3Constants';
|
|
3
4
|
import { RpcBDSNeo3 } from './RpcBDSNeo3';
|
|
5
|
+
export declare const DoraNeoRest: api.NeoRESTApi;
|
|
4
6
|
export declare class DoraBDSNeo3 extends RpcBDSNeo3 {
|
|
5
7
|
#private;
|
|
6
8
|
constructor(network: Network<BSNeo3NetworkId>, feeToken: Token, claimToken: Token, tokens: Token[], nftDataService: NftDataService, explorerService: ExplorerService);
|
|
@@ -32,13 +32,13 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
32
32
|
};
|
|
33
33
|
var _DoraBDSNeo3_instances, _DoraBDSNeo3_supportedNep11Standards, _DoraBDSNeo3_nftDataService, _DoraBDSNeo3_explorerService, _DoraBDSNeo3_validateAddress, _DoraBDSNeo3_validateFullTransactionsByAddressParams, _DoraBDSNeo3_validateGetFullTransactionsByAddressParams;
|
|
34
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
-
exports.DoraBDSNeo3 = void 0;
|
|
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
39
|
const BSNeo3Helper_1 = require("../../helpers/BSNeo3Helper");
|
|
40
40
|
const RpcBDSNeo3_1 = require("./RpcBDSNeo3");
|
|
41
|
-
|
|
41
|
+
exports.DoraNeoRest = new dora_ts_1.api.NeoRESTApi({
|
|
42
42
|
doraUrl: blockchain_service_1.BSCommonConstants.DORA_URL,
|
|
43
43
|
endpoint: '/api/v2/neo3',
|
|
44
44
|
});
|
|
@@ -62,14 +62,15 @@ class DoraBDSNeo3 extends RpcBDSNeo3_1.RpcBDSNeo3 {
|
|
|
62
62
|
return yield _super.getTransaction.call(this, hash);
|
|
63
63
|
}
|
|
64
64
|
try {
|
|
65
|
-
const data = yield
|
|
65
|
+
const data = yield exports.DoraNeoRest.transaction(hash, this._network.id);
|
|
66
|
+
const systemFeeNumber = blockchain_service_1.BSBigNumberHelper.fromNumber((_a = data.sysfee) !== null && _a !== void 0 ? _a : 0);
|
|
67
|
+
const networkFeeNumber = blockchain_service_1.BSBigNumberHelper.fromNumber((_b = data.netfee) !== null && _b !== void 0 ? _b : 0);
|
|
68
|
+
const totalFee = systemFeeNumber.plus(networkFeeNumber);
|
|
66
69
|
return {
|
|
67
70
|
block: data.block,
|
|
68
71
|
time: Number(data.time),
|
|
69
72
|
hash: data.hash,
|
|
70
|
-
fee:
|
|
71
|
-
.add(neon_js_1.u.BigInteger.fromNumber((_b = data.sysfee) !== null && _b !== void 0 ? _b : 0))
|
|
72
|
-
.toDecimal(this._feeToken.decimals),
|
|
73
|
+
fee: blockchain_service_1.BSBigNumberHelper.format(totalFee, { decimals: this._feeToken.decimals }),
|
|
73
74
|
notifications: [],
|
|
74
75
|
transfers: [],
|
|
75
76
|
};
|
|
@@ -87,7 +88,7 @@ class DoraBDSNeo3 extends RpcBDSNeo3_1.RpcBDSNeo3 {
|
|
|
87
88
|
if (BSNeo3Helper_1.BSNeo3Helper.isCustomNet(this._network)) {
|
|
88
89
|
return yield _super.getTransactionsByAddress.call(this, { address, nextPageParams });
|
|
89
90
|
}
|
|
90
|
-
const data = yield
|
|
91
|
+
const data = yield exports.DoraNeoRest.addressTXFull(address, nextPageParams, this._network.id);
|
|
91
92
|
const promises = data.items.map((item) => __awaiter(this, void 0, void 0, function* () {
|
|
92
93
|
var _a, _b;
|
|
93
94
|
const transferPromises = [];
|
|
@@ -130,13 +131,14 @@ class DoraBDSNeo3 extends RpcBDSNeo3_1.RpcBDSNeo3 {
|
|
|
130
131
|
eventName: notification.event_name,
|
|
131
132
|
state: notification.state,
|
|
132
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);
|
|
136
|
+
const totalFee = systemFeeNumber.plus(networkFeeNumber);
|
|
133
137
|
return {
|
|
134
138
|
block: item.block,
|
|
135
139
|
time: Number(item.time),
|
|
136
140
|
hash: item.hash,
|
|
137
|
-
fee:
|
|
138
|
-
.add(neon_js_1.u.BigInteger.fromNumber((_b = item.sysfee) !== null && _b !== void 0 ? _b : 0))
|
|
139
|
-
.toDecimal(this._feeToken.decimals),
|
|
141
|
+
fee: blockchain_service_1.BSBigNumberHelper.format(totalFee, { decimals: this._feeToken.decimals }),
|
|
140
142
|
transfers,
|
|
141
143
|
notifications,
|
|
142
144
|
};
|
|
@@ -156,7 +158,7 @@ class DoraBDSNeo3 extends RpcBDSNeo3_1.RpcBDSNeo3 {
|
|
|
156
158
|
return __awaiter(this, void 0, void 0, function* () {
|
|
157
159
|
__classPrivateFieldGet(this, _DoraBDSNeo3_instances, "m", _DoraBDSNeo3_validateGetFullTransactionsByAddressParams).call(this, params);
|
|
158
160
|
const data = [];
|
|
159
|
-
const response = yield
|
|
161
|
+
const response = yield exports.DoraNeoRest.getFullTransactionsByAddress({
|
|
160
162
|
address: params.address,
|
|
161
163
|
timestampFrom: params.dateFrom,
|
|
162
164
|
timestampTo: params.dateTo,
|
|
@@ -180,10 +182,10 @@ class DoraBDSNeo3 extends RpcBDSNeo3_1.RpcBDSNeo3 {
|
|
|
180
182
|
invocationCount: item.invocationCount,
|
|
181
183
|
notificationCount: item.notificationCount,
|
|
182
184
|
networkFeeAmount: networkFeeAmount
|
|
183
|
-
? blockchain_service_1.
|
|
185
|
+
? blockchain_service_1.BSBigNumberHelper.format(networkFeeAmount, { decimals: this._feeToken.decimals })
|
|
184
186
|
: undefined,
|
|
185
187
|
systemFeeAmount: systemFeeAmount
|
|
186
|
-
? blockchain_service_1.
|
|
188
|
+
? blockchain_service_1.BSBigNumberHelper.format(systemFeeAmount, { decimals: this._feeToken.decimals })
|
|
187
189
|
: undefined,
|
|
188
190
|
events: [],
|
|
189
191
|
};
|
|
@@ -222,11 +224,10 @@ class DoraBDSNeo3 extends RpcBDSNeo3_1.RpcBDSNeo3 {
|
|
|
222
224
|
}
|
|
223
225
|
else {
|
|
224
226
|
const [token] = yield blockchain_service_1.BSPromisesHelper.tryCatch(() => this.getTokenInfo(hash));
|
|
225
|
-
const { amount } = event;
|
|
226
227
|
assetEvent = {
|
|
227
228
|
eventType: 'token',
|
|
228
|
-
amount: amount
|
|
229
|
-
? blockchain_service_1.
|
|
229
|
+
amount: event.amount
|
|
230
|
+
? blockchain_service_1.BSBigNumberHelper.format(event.amount, { decimals: (_k = token === null || token === void 0 ? void 0 : token.decimals) !== null && _k !== void 0 ? _k : event.tokenDecimals })
|
|
230
231
|
: undefined,
|
|
231
232
|
methodName,
|
|
232
233
|
from,
|
|
@@ -251,7 +252,7 @@ class DoraBDSNeo3 extends RpcBDSNeo3_1.RpcBDSNeo3 {
|
|
|
251
252
|
exportFullTransactionsByAddress(params) {
|
|
252
253
|
return __awaiter(this, void 0, void 0, function* () {
|
|
253
254
|
__classPrivateFieldGet(this, _DoraBDSNeo3_instances, "m", _DoraBDSNeo3_validateFullTransactionsByAddressParams).call(this, params);
|
|
254
|
-
return yield
|
|
255
|
+
return yield exports.DoraNeoRest.exportFullTransactionsByAddress({
|
|
255
256
|
address: params.address,
|
|
256
257
|
timestampFrom: params.dateFrom,
|
|
257
258
|
timestampTo: params.dateTo,
|
|
@@ -269,7 +270,7 @@ class DoraBDSNeo3 extends RpcBDSNeo3_1.RpcBDSNeo3 {
|
|
|
269
270
|
return yield _super.getContract.call(this, contractHash);
|
|
270
271
|
}
|
|
271
272
|
try {
|
|
272
|
-
const data = yield
|
|
273
|
+
const data = yield exports.DoraNeoRest.contract(contractHash, this._network.id);
|
|
273
274
|
return {
|
|
274
275
|
hash: data.hash,
|
|
275
276
|
methods: (_b = (_a = data.manifest.abi) === null || _a === void 0 ? void 0 : _a.methods) !== null && _b !== void 0 ? _b : [],
|
|
@@ -289,20 +290,21 @@ class DoraBDSNeo3 extends RpcBDSNeo3_1.RpcBDSNeo3 {
|
|
|
289
290
|
if (BSNeo3Helper_1.BSNeo3Helper.isCustomNet(this._network)) {
|
|
290
291
|
return yield _super.getTokenInfo.call(this, tokenHash);
|
|
291
292
|
}
|
|
292
|
-
const localToken = this._tokens.find(token => token.hash === tokenHash);
|
|
293
|
-
if (localToken)
|
|
294
|
-
return localToken;
|
|
295
|
-
if (this._tokenCache.has(tokenHash)) {
|
|
296
|
-
return this._tokenCache.get(tokenHash);
|
|
297
|
-
}
|
|
298
293
|
try {
|
|
299
|
-
const
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
294
|
+
const cachedToken = this._tokenCache.get(tokenHash);
|
|
295
|
+
if (cachedToken) {
|
|
296
|
+
return cachedToken;
|
|
297
|
+
}
|
|
298
|
+
let token = this._tokens.find(blockchain_service_1.BSTokenHelper.predicateByHash(tokenHash));
|
|
299
|
+
if (!token) {
|
|
300
|
+
const { decimals, symbol, name, scripthash } = yield exports.DoraNeoRest.asset(tokenHash, this._network.id);
|
|
301
|
+
token = blockchain_service_1.BSTokenHelper.normalizeToken({
|
|
302
|
+
decimals: Number(decimals),
|
|
303
|
+
symbol,
|
|
304
|
+
name,
|
|
305
|
+
hash: scripthash,
|
|
306
|
+
});
|
|
307
|
+
}
|
|
306
308
|
this._tokenCache.set(tokenHash, token);
|
|
307
309
|
return token;
|
|
308
310
|
}
|
|
@@ -319,7 +321,7 @@ class DoraBDSNeo3 extends RpcBDSNeo3_1.RpcBDSNeo3 {
|
|
|
319
321
|
if (BSNeo3Helper_1.BSNeo3Helper.isCustomNet(this._network)) {
|
|
320
322
|
return yield _super.getBalance.call(this, address);
|
|
321
323
|
}
|
|
322
|
-
const response = yield
|
|
324
|
+
const response = yield exports.DoraNeoRest.balance(address, this._network.id);
|
|
323
325
|
const promises = response.map((balance) => __awaiter(this, void 0, void 0, function* () {
|
|
324
326
|
try {
|
|
325
327
|
const token = yield this.getTokenInfo(balance.asset);
|
|
@@ -10,6 +10,7 @@ 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");
|
|
13
14
|
const neon_core_1 = require("@cityofzion/neon-core");
|
|
14
15
|
const neon_dappkit_1 = require("@cityofzion/neon-dappkit");
|
|
15
16
|
const BSNeo3Helper_1 = require("../../helpers/BSNeo3Helper");
|
|
@@ -85,40 +86,41 @@ class RpcBDSNeo3 {
|
|
|
85
86
|
}
|
|
86
87
|
getTokenInfo(tokenHash) {
|
|
87
88
|
return __awaiter(this, void 0, void 0, function* () {
|
|
88
|
-
const localToken = this._tokens.find(token => BSNeo3Helper_1.BSNeo3Helper.normalizeHash(token.hash) === BSNeo3Helper_1.BSNeo3Helper.normalizeHash(tokenHash));
|
|
89
|
-
if (localToken)
|
|
90
|
-
return localToken;
|
|
91
|
-
if (this._tokenCache.has(tokenHash)) {
|
|
92
|
-
return this._tokenCache.get(tokenHash);
|
|
93
|
-
}
|
|
94
89
|
try {
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
decimals
|
|
121
|
-
|
|
90
|
+
const cachedToken = this._tokenCache.get(tokenHash);
|
|
91
|
+
if (cachedToken) {
|
|
92
|
+
return cachedToken;
|
|
93
|
+
}
|
|
94
|
+
let token = this._tokens.find(blockchain_service_1.BSTokenHelper.predicateByHash(tokenHash));
|
|
95
|
+
if (!token) {
|
|
96
|
+
const rpcClient = new neon_core_1.rpc.RPCClient(this._network.url);
|
|
97
|
+
const contractState = yield rpcClient.getContractState(tokenHash);
|
|
98
|
+
const invoker = yield neon_dappkit_1.NeonInvoker.init({
|
|
99
|
+
rpcAddress: this._network.url,
|
|
100
|
+
});
|
|
101
|
+
const response = yield invoker.testInvoke({
|
|
102
|
+
invocations: [
|
|
103
|
+
{
|
|
104
|
+
scriptHash: tokenHash,
|
|
105
|
+
operation: 'decimals',
|
|
106
|
+
args: [],
|
|
107
|
+
},
|
|
108
|
+
{ scriptHash: tokenHash, operation: 'symbol', args: [] },
|
|
109
|
+
],
|
|
110
|
+
});
|
|
111
|
+
if (!neon_dappkit_1.TypeChecker.isStackTypeInteger(response.stack[0]))
|
|
112
|
+
throw new Error('Invalid decimals');
|
|
113
|
+
if (!neon_dappkit_1.TypeChecker.isStackTypeByteString(response.stack[1]))
|
|
114
|
+
throw new Error('Invalid symbol');
|
|
115
|
+
const decimals = Number(response.stack[0].value);
|
|
116
|
+
const symbol = neon_core_1.u.base642utf8(response.stack[1].value);
|
|
117
|
+
token = blockchain_service_1.BSTokenHelper.normalizeToken({
|
|
118
|
+
name: contractState.manifest.name,
|
|
119
|
+
symbol,
|
|
120
|
+
hash: contractState.hash,
|
|
121
|
+
decimals,
|
|
122
|
+
});
|
|
123
|
+
}
|
|
122
124
|
this._tokenCache.set(tokenHash, token);
|
|
123
125
|
return token;
|
|
124
126
|
}
|
|
@@ -24,17 +24,17 @@ class DoraESNeo3 {
|
|
|
24
24
|
buildTransactionUrl(hash) {
|
|
25
25
|
if (BSNeo3Helper_1.BSNeo3Helper.isCustomNet(__classPrivateFieldGet(this, _DoraESNeo3_network, "f")))
|
|
26
26
|
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}/${hash}`;
|
|
27
|
+
return `${__classPrivateFieldGet(this, _DoraESNeo3_BASE_URL, "f")}/transaction/neo3/${__classPrivateFieldGet(this, _DoraESNeo3_network, "f").id}/${blockchain_service_1.BSTokenHelper.normalizeHash(hash)}`;
|
|
28
28
|
}
|
|
29
29
|
buildContractUrl(contractHash) {
|
|
30
30
|
if (BSNeo3Helper_1.BSNeo3Helper.isCustomNet(__classPrivateFieldGet(this, _DoraESNeo3_network, "f")))
|
|
31
31
|
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}/${contractHash}`;
|
|
32
|
+
return `${__classPrivateFieldGet(this, _DoraESNeo3_BASE_URL, "f")}/contract/neo3/${__classPrivateFieldGet(this, _DoraESNeo3_network, "f").id}/${blockchain_service_1.BSTokenHelper.normalizeHash(contractHash)}`;
|
|
33
33
|
}
|
|
34
34
|
buildNftUrl({ contractHash, tokenId }) {
|
|
35
35
|
if (BSNeo3Helper_1.BSNeo3Helper.isCustomNet(__classPrivateFieldGet(this, _DoraESNeo3_network, "f")))
|
|
36
36
|
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}/${contractHash}/${tokenId}`;
|
|
37
|
+
return `${__classPrivateFieldGet(this, _DoraESNeo3_BASE_URL, "f")}/nft/neo3/${__classPrivateFieldGet(this, _DoraESNeo3_network, "f").id}/${blockchain_service_1.BSTokenHelper.normalizeHash(contractHash)}/${tokenId}`;
|
|
38
38
|
}
|
|
39
39
|
getAddressTemplateUrl() {
|
|
40
40
|
if (BSNeo3Helper_1.BSNeo3Helper.isCustomNet(__classPrivateFieldGet(this, _DoraESNeo3_network, "f")))
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { INeo3NeoXBridgeService, TNeo3NeoXBridgeServiceBridgeParam, TNeo3NeoXBridgeServiceCalculateMaxAmountParams, TNeo3NeoXBridgeServiceValidatedInputs, TNeo3NeoXBridgeServiceValidateInputParams, TNeo3NeoXBridgeServiceWaitParams } from '@cityofzion/blockchain-service';
|
|
2
|
+
import { BSNeo3 } from '../../BSNeo3';
|
|
3
|
+
export declare class Neo3NeoXBridgeService<BSName extends string = string> implements INeo3NeoXBridgeService<BSName> {
|
|
4
|
+
#private;
|
|
5
|
+
readonly BRIDGE_SCRIPT_HASH = "0xbb19cfc864b73159277e1fd39694b3fd5fc613d2";
|
|
6
|
+
readonly BRIDGE_GAS_FEE = 0.1;
|
|
7
|
+
readonly BRIDGE_MIN_AMOUNT = 1;
|
|
8
|
+
readonly BRIDGE_NEOX_BASE_CONFIRMATION_URL = "https://xexplorer.neo.org:8877/api/v1/transactions/deposits";
|
|
9
|
+
readonly BRIDGE_NEOX_NEO_TOKEN_HASH = "0xc28736dc83f4fd43d6fb832Fd93c3eE7bB26828f";
|
|
10
|
+
constructor(service: BSNeo3<BSName>);
|
|
11
|
+
calculateMaxAmount({ account, balances, receiverAddress, token, }: TNeo3NeoXBridgeServiceCalculateMaxAmountParams<BSName>): Promise<string>;
|
|
12
|
+
calculateFee(params: TNeo3NeoXBridgeServiceBridgeParam<BSName>): Promise<string>;
|
|
13
|
+
bridge(params: TNeo3NeoXBridgeServiceBridgeParam<BSName>): Promise<string>;
|
|
14
|
+
validateInputs(params: TNeo3NeoXBridgeServiceValidateInputParams<BSName>): Promise<TNeo3NeoXBridgeServiceValidatedInputs>;
|
|
15
|
+
wait(params: TNeo3NeoXBridgeServiceWaitParams): Promise<boolean>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
12
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
13
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
14
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
15
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
16
|
+
};
|
|
17
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
18
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
19
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
20
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
21
|
+
};
|
|
22
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
23
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
|
+
};
|
|
25
|
+
var _Neo3NeoXBridgeService_instances, _Neo3NeoXBridgeService_service, _Neo3NeoXBridgeService_buildGasCIM, _Neo3NeoXBridgeService_buildNeoCIM, _Neo3NeoXBridgeService_buildCIM, _Neo3NeoXBridgeService_validateGas, _Neo3NeoXBridgeService_validateNeo;
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
+
exports.Neo3NeoXBridgeService = void 0;
|
|
28
|
+
const blockchain_service_1 = require("@cityofzion/blockchain-service");
|
|
29
|
+
const BSNeo3Constants_1 = require("../../constants/BSNeo3Constants");
|
|
30
|
+
const neon_dappkit_1 = require("@cityofzion/neon-dappkit");
|
|
31
|
+
const BSNeo3Helper_1 = require("../../helpers/BSNeo3Helper");
|
|
32
|
+
const DoraBDSNeo3_1 = require("../blockchain-data/DoraBDSNeo3");
|
|
33
|
+
const axios_1 = __importDefault(require("axios"));
|
|
34
|
+
class Neo3NeoXBridgeService {
|
|
35
|
+
constructor(service) {
|
|
36
|
+
_Neo3NeoXBridgeService_instances.add(this);
|
|
37
|
+
this.BRIDGE_SCRIPT_HASH = '0xbb19cfc864b73159277e1fd39694b3fd5fc613d2';
|
|
38
|
+
this.BRIDGE_GAS_FEE = 0.1;
|
|
39
|
+
this.BRIDGE_MIN_AMOUNT = 1;
|
|
40
|
+
this.BRIDGE_NEOX_BASE_CONFIRMATION_URL = 'https://xexplorer.neo.org:8877/api/v1/transactions/deposits';
|
|
41
|
+
this.BRIDGE_NEOX_NEO_TOKEN_HASH = '0xc28736dc83f4fd43d6fb832Fd93c3eE7bB26828f';
|
|
42
|
+
_Neo3NeoXBridgeService_service.set(this, void 0);
|
|
43
|
+
__classPrivateFieldSet(this, _Neo3NeoXBridgeService_service, service, "f");
|
|
44
|
+
}
|
|
45
|
+
calculateMaxAmount({ account, balances, receiverAddress, token, }) {
|
|
46
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
+
if (!BSNeo3Helper_1.BSNeo3Helper.isMainnet(__classPrivateFieldGet(this, _Neo3NeoXBridgeService_service, "f").network))
|
|
48
|
+
throw new blockchain_service_1.BSError('Bridging to NeoX is only supported on mainnet', 'UNSUPPORTED_NETWORK');
|
|
49
|
+
const normalizedSelectedToken = blockchain_service_1.BSTokenHelper.normalizeToken(token);
|
|
50
|
+
const selectedTokenBalance = balances.find(balance => blockchain_service_1.BSTokenHelper.normalizeHash(balance.token.hash) === normalizedSelectedToken.hash);
|
|
51
|
+
if (!selectedTokenBalance) {
|
|
52
|
+
throw new blockchain_service_1.BSError('Token balance not found', 'TOKEN_BALANCE_NOT_FOUND');
|
|
53
|
+
}
|
|
54
|
+
const amountNumber = blockchain_service_1.BSBigNumberHelper.fromNumber(selectedTokenBalance.amount);
|
|
55
|
+
const validatedInputs = {
|
|
56
|
+
receiveAmount: amountNumber.minus(this.BRIDGE_MIN_AMOUNT).toString(),
|
|
57
|
+
token,
|
|
58
|
+
amount: amountNumber.toString(),
|
|
59
|
+
};
|
|
60
|
+
const fee = yield this.calculateFee({
|
|
61
|
+
account,
|
|
62
|
+
receiverAddress,
|
|
63
|
+
validatedInputs,
|
|
64
|
+
});
|
|
65
|
+
const maxAmount = amountNumber.minus(fee).toString();
|
|
66
|
+
return maxAmount;
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
calculateFee(params) {
|
|
70
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
71
|
+
if (!BSNeo3Helper_1.BSNeo3Helper.isMainnet(__classPrivateFieldGet(this, _Neo3NeoXBridgeService_service, "f").network))
|
|
72
|
+
throw new blockchain_service_1.BSError('Bridging to NeoX is only supported on mainnet', 'UNSUPPORTED_NETWORK');
|
|
73
|
+
try {
|
|
74
|
+
const { account } = params;
|
|
75
|
+
const { neonJsAccount } = yield __classPrivateFieldGet(this, _Neo3NeoXBridgeService_service, "f").generateSigningCallback(account);
|
|
76
|
+
const invoker = yield neon_dappkit_1.NeonInvoker.init({
|
|
77
|
+
rpcAddress: __classPrivateFieldGet(this, _Neo3NeoXBridgeService_service, "f").network.url,
|
|
78
|
+
account: neonJsAccount,
|
|
79
|
+
});
|
|
80
|
+
const contractInvocationMulti = __classPrivateFieldGet(this, _Neo3NeoXBridgeService_instances, "m", _Neo3NeoXBridgeService_buildCIM).call(this, params, neonJsAccount);
|
|
81
|
+
const { total } = yield invoker.calculateFee(contractInvocationMulti);
|
|
82
|
+
return total.toString();
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
throw new blockchain_service_1.BSError(error.message, 'FEE_CALCULATION_ERROR');
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
bridge(params) {
|
|
90
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
91
|
+
if (!BSNeo3Helper_1.BSNeo3Helper.isMainnet(__classPrivateFieldGet(this, _Neo3NeoXBridgeService_service, "f").network))
|
|
92
|
+
throw new blockchain_service_1.BSError('Bridging to NeoX is only supported on mainnet', 'UNSUPPORTED_NETWORK');
|
|
93
|
+
const { account } = params;
|
|
94
|
+
const { neonJsAccount, signingCallback } = yield __classPrivateFieldGet(this, _Neo3NeoXBridgeService_service, "f").generateSigningCallback(account);
|
|
95
|
+
const invoker = yield neon_dappkit_1.NeonInvoker.init({
|
|
96
|
+
rpcAddress: __classPrivateFieldGet(this, _Neo3NeoXBridgeService_service, "f").network.url,
|
|
97
|
+
account: neonJsAccount,
|
|
98
|
+
signingCallback: signingCallback,
|
|
99
|
+
});
|
|
100
|
+
const contractInvocationMulti = __classPrivateFieldGet(this, _Neo3NeoXBridgeService_instances, "m", _Neo3NeoXBridgeService_buildCIM).call(this, params, neonJsAccount);
|
|
101
|
+
const transactionHash = yield invoker.invokeFunction(contractInvocationMulti);
|
|
102
|
+
return transactionHash;
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
validateInputs(params) {
|
|
106
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
107
|
+
if (!BSNeo3Helper_1.BSNeo3Helper.isMainnet(__classPrivateFieldGet(this, _Neo3NeoXBridgeService_service, "f").network))
|
|
108
|
+
throw new blockchain_service_1.BSError('Bridging to NeoX is only supported on mainnet', 'UNSUPPORTED_NETWORK');
|
|
109
|
+
const normalizedSelectedToken = blockchain_service_1.BSTokenHelper.normalizeToken(params.token);
|
|
110
|
+
const isGasToken = normalizedSelectedToken.hash === BSNeo3Constants_1.BSNeo3Constants.GAS_TOKEN.hash;
|
|
111
|
+
const isNeoToken = normalizedSelectedToken.hash === BSNeo3Constants_1.BSNeo3Constants.NEO_TOKEN.hash;
|
|
112
|
+
if (isGasToken) {
|
|
113
|
+
return __classPrivateFieldGet(this, _Neo3NeoXBridgeService_instances, "m", _Neo3NeoXBridgeService_validateGas).call(this, params);
|
|
114
|
+
}
|
|
115
|
+
else if (isNeoToken) {
|
|
116
|
+
return __classPrivateFieldGet(this, _Neo3NeoXBridgeService_instances, "m", _Neo3NeoXBridgeService_validateNeo).call(this, params);
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
throw new blockchain_service_1.BSError('Only GAS and NEO tokens are supported for bridging', 'UNSUPPORTED_TOKEN');
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
wait(params) {
|
|
124
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
125
|
+
if (!BSNeo3Helper_1.BSNeo3Helper.isMainnet(__classPrivateFieldGet(this, _Neo3NeoXBridgeService_service, "f").network))
|
|
126
|
+
throw new blockchain_service_1.BSError('Bridging to NeoX is only supported on mainnet', 'UNSUPPORTED_NETWORK');
|
|
127
|
+
try {
|
|
128
|
+
const { transactionHash, validatedInputs } = params;
|
|
129
|
+
let nonce;
|
|
130
|
+
const log = yield blockchain_service_1.BSUtilsHelper.retry(() => DoraBDSNeo3_1.DoraNeoRest.log(transactionHash, __classPrivateFieldGet(this, _Neo3NeoXBridgeService_service, "f").network.id), {
|
|
131
|
+
retries: 10,
|
|
132
|
+
delay: 30000,
|
|
133
|
+
});
|
|
134
|
+
if (log.vmstate !== 'HALT') {
|
|
135
|
+
throw new Error();
|
|
136
|
+
}
|
|
137
|
+
const isGasToken = blockchain_service_1.BSTokenHelper.predicateByHash(validatedInputs.token)(BSNeo3Constants_1.BSNeo3Constants.GAS_TOKEN);
|
|
138
|
+
if (isGasToken) {
|
|
139
|
+
const notification = log.notifications.find(item => item.event_name === 'NativeDeposit');
|
|
140
|
+
nonce = notification === null || notification === void 0 ? void 0 : notification.state.value[0].value;
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
const notification = log.notifications.find(item => item.event_name === 'TokenDeposit');
|
|
144
|
+
nonce = notification === null || notification === void 0 ? void 0 : notification.state.value[2].value;
|
|
145
|
+
}
|
|
146
|
+
if (!nonce) {
|
|
147
|
+
throw new Error();
|
|
148
|
+
}
|
|
149
|
+
yield blockchain_service_1.BSUtilsHelper.retry(() => __awaiter(this, void 0, void 0, function* () {
|
|
150
|
+
var _a;
|
|
151
|
+
let url;
|
|
152
|
+
if (isGasToken) {
|
|
153
|
+
url = `${this.BRIDGE_NEOX_BASE_CONFIRMATION_URL}/${nonce}`;
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
url = `${this.BRIDGE_NEOX_BASE_CONFIRMATION_URL}/${this.BRIDGE_NEOX_NEO_TOKEN_HASH}/${nonce}`;
|
|
157
|
+
}
|
|
158
|
+
const response = yield axios_1.default.get(url);
|
|
159
|
+
if (!((_a = response.data) === null || _a === void 0 ? void 0 : _a.txid)) {
|
|
160
|
+
throw new blockchain_service_1.BSError('Transaction not found', 'TRANSACTION_NOT_FOUND');
|
|
161
|
+
}
|
|
162
|
+
}), {
|
|
163
|
+
retries: 10,
|
|
164
|
+
delay: 30000,
|
|
165
|
+
});
|
|
166
|
+
return true;
|
|
167
|
+
}
|
|
168
|
+
catch (error) {
|
|
169
|
+
return false;
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
exports.Neo3NeoXBridgeService = Neo3NeoXBridgeService;
|
|
175
|
+
_Neo3NeoXBridgeService_service = new WeakMap(), _Neo3NeoXBridgeService_instances = new WeakSet(), _Neo3NeoXBridgeService_buildGasCIM = function _Neo3NeoXBridgeService_buildGasCIM({ receiverAddress, validatedInputs }, neonJsAccount) {
|
|
176
|
+
return {
|
|
177
|
+
invocations: [
|
|
178
|
+
{
|
|
179
|
+
scriptHash: this.BRIDGE_SCRIPT_HASH,
|
|
180
|
+
operation: 'depositNative',
|
|
181
|
+
args: [
|
|
182
|
+
{ type: 'Hash160', value: neonJsAccount.address },
|
|
183
|
+
{ type: 'Hash160', value: receiverAddress },
|
|
184
|
+
{
|
|
185
|
+
type: 'Integer',
|
|
186
|
+
value: blockchain_service_1.BSBigNumberHelper.toDecimals(blockchain_service_1.BSBigNumberHelper.fromNumber(validatedInputs.receiveAmount), validatedInputs.token.decimals),
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
type: 'Integer',
|
|
190
|
+
value: blockchain_service_1.BSBigNumberHelper.toDecimals(blockchain_service_1.BSBigNumberHelper.fromNumber(this.BRIDGE_GAS_FEE), BSNeo3Constants_1.BSNeo3Constants.GAS_TOKEN.decimals),
|
|
191
|
+
},
|
|
192
|
+
],
|
|
193
|
+
},
|
|
194
|
+
],
|
|
195
|
+
signers: [
|
|
196
|
+
{
|
|
197
|
+
scopes: 16,
|
|
198
|
+
allowedContracts: [this.BRIDGE_SCRIPT_HASH, BSNeo3Constants_1.BSNeo3Constants.GAS_TOKEN.hash],
|
|
199
|
+
},
|
|
200
|
+
],
|
|
201
|
+
};
|
|
202
|
+
}, _Neo3NeoXBridgeService_buildNeoCIM = function _Neo3NeoXBridgeService_buildNeoCIM({ receiverAddress, validatedInputs }, neonJsAccount) {
|
|
203
|
+
return {
|
|
204
|
+
invocations: [
|
|
205
|
+
{
|
|
206
|
+
scriptHash: this.BRIDGE_SCRIPT_HASH,
|
|
207
|
+
operation: 'depositToken',
|
|
208
|
+
args: [
|
|
209
|
+
{ type: 'Hash160', value: BSNeo3Constants_1.BSNeo3Constants.NEO_TOKEN.hash },
|
|
210
|
+
{ type: 'Hash160', value: neonJsAccount.scriptHash },
|
|
211
|
+
{ type: 'Hash160', value: receiverAddress },
|
|
212
|
+
{
|
|
213
|
+
type: 'Integer',
|
|
214
|
+
value: blockchain_service_1.BSBigNumberHelper.toDecimals(blockchain_service_1.BSBigNumberHelper.fromNumber(validatedInputs.receiveAmount), validatedInputs.token.decimals),
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
type: 'Integer',
|
|
218
|
+
value: blockchain_service_1.BSBigNumberHelper.toDecimals(blockchain_service_1.BSBigNumberHelper.fromNumber(this.BRIDGE_GAS_FEE), BSNeo3Constants_1.BSNeo3Constants.GAS_TOKEN.decimals),
|
|
219
|
+
},
|
|
220
|
+
],
|
|
221
|
+
},
|
|
222
|
+
],
|
|
223
|
+
signers: [
|
|
224
|
+
{
|
|
225
|
+
scopes: 16,
|
|
226
|
+
allowedContracts: [this.BRIDGE_SCRIPT_HASH, BSNeo3Constants_1.BSNeo3Constants.GAS_TOKEN.hash, BSNeo3Constants_1.BSNeo3Constants.NEO_TOKEN.hash],
|
|
227
|
+
},
|
|
228
|
+
],
|
|
229
|
+
};
|
|
230
|
+
}, _Neo3NeoXBridgeService_buildCIM = function _Neo3NeoXBridgeService_buildCIM(params, neonJsAccount) {
|
|
231
|
+
const isGasToken = blockchain_service_1.BSTokenHelper.predicateByHash(params.validatedInputs.token)(BSNeo3Constants_1.BSNeo3Constants.GAS_TOKEN);
|
|
232
|
+
if (isGasToken) {
|
|
233
|
+
return __classPrivateFieldGet(this, _Neo3NeoXBridgeService_instances, "m", _Neo3NeoXBridgeService_buildGasCIM).call(this, params, neonJsAccount);
|
|
234
|
+
}
|
|
235
|
+
return __classPrivateFieldGet(this, _Neo3NeoXBridgeService_instances, "m", _Neo3NeoXBridgeService_buildNeoCIM).call(this, params, neonJsAccount);
|
|
236
|
+
}, _Neo3NeoXBridgeService_validateGas = function _Neo3NeoXBridgeService_validateGas({ amount, balances, token, account, receiverAddress, }) {
|
|
237
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
238
|
+
const gasBalance = balances.find(balance => blockchain_service_1.BSTokenHelper.predicateByHash(balance.token)(BSNeo3Constants_1.BSNeo3Constants.GAS_TOKEN));
|
|
239
|
+
if (!gasBalance) {
|
|
240
|
+
throw new blockchain_service_1.BSError('GAS is necessary to bridge', 'GAS_BALANCE_NOT_FOUND');
|
|
241
|
+
}
|
|
242
|
+
const amountNumber = blockchain_service_1.BSBigNumberHelper.fromNumber(amount);
|
|
243
|
+
const gasBalanceNumber = blockchain_service_1.BSBigNumberHelper.fromNumber(gasBalance.amount);
|
|
244
|
+
const validatedInputs = {
|
|
245
|
+
receiveAmount: amountNumber.minus(this.BRIDGE_GAS_FEE).toString(),
|
|
246
|
+
token,
|
|
247
|
+
amount,
|
|
248
|
+
};
|
|
249
|
+
if (amountNumber.isLessThan(this.BRIDGE_MIN_AMOUNT + this.BRIDGE_GAS_FEE)) {
|
|
250
|
+
throw new blockchain_service_1.BSError('Amount is less than the minimum amount plus bridge fee', 'AMOUNT_TOO_LOW');
|
|
251
|
+
}
|
|
252
|
+
if (amountNumber.isGreaterThan(gasBalanceNumber)) {
|
|
253
|
+
throw new blockchain_service_1.BSError('Amount is greater than your balance', 'INSUFFICIENT_GAS_BALANCE');
|
|
254
|
+
}
|
|
255
|
+
const fee = yield this.calculateFee({
|
|
256
|
+
account,
|
|
257
|
+
receiverAddress,
|
|
258
|
+
validatedInputs,
|
|
259
|
+
});
|
|
260
|
+
if (amountNumber.plus(fee).isGreaterThan(gasBalanceNumber)) {
|
|
261
|
+
throw new blockchain_service_1.BSError('Amount is greater than your balance plus fee', 'INSUFFICIENT_GAS_BALANCE_FEE');
|
|
262
|
+
}
|
|
263
|
+
return validatedInputs;
|
|
264
|
+
});
|
|
265
|
+
}, _Neo3NeoXBridgeService_validateNeo = function _Neo3NeoXBridgeService_validateNeo({ amount, balances, token, account, receiverAddress, }) {
|
|
266
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
267
|
+
const gasBalance = balances.find(balance => blockchain_service_1.BSTokenHelper.predicateByHash(balance.token)(BSNeo3Constants_1.BSNeo3Constants.GAS_TOKEN));
|
|
268
|
+
if (!gasBalance) {
|
|
269
|
+
throw new blockchain_service_1.BSError('GAS is necessary to bridge', 'GAS_BALANCE_NOT_FOUND');
|
|
270
|
+
}
|
|
271
|
+
const neoBalance = balances.find(balance => blockchain_service_1.BSTokenHelper.predicateByHash(balance.token)(BSNeo3Constants_1.BSNeo3Constants.NEO_TOKEN));
|
|
272
|
+
if (!neoBalance) {
|
|
273
|
+
throw new blockchain_service_1.BSError('NEO balance not found', 'NEO_BALANCE_NOT_FOUND');
|
|
274
|
+
}
|
|
275
|
+
const amountNumber = blockchain_service_1.BSBigNumberHelper.fromNumber(amount);
|
|
276
|
+
const gasBalanceNumber = blockchain_service_1.BSBigNumberHelper.fromNumber(gasBalance.amount);
|
|
277
|
+
const minGasBalanceNumber = blockchain_service_1.BSBigNumberHelper.fromNumber(this.BRIDGE_GAS_FEE);
|
|
278
|
+
const validatedInputs = {
|
|
279
|
+
receiveAmount: amount,
|
|
280
|
+
token,
|
|
281
|
+
amount,
|
|
282
|
+
};
|
|
283
|
+
if (amountNumber.isLessThan(this.BRIDGE_MIN_AMOUNT)) {
|
|
284
|
+
throw new blockchain_service_1.BSError('Amount is less than the minimum amount', 'AMOUNT_TOO_LOW');
|
|
285
|
+
}
|
|
286
|
+
if (amountNumber.isGreaterThan(neoBalance.amount)) {
|
|
287
|
+
throw new blockchain_service_1.BSError('Amount is greater than your balance', 'INSUFFICIENT_NEO_BALANCE');
|
|
288
|
+
}
|
|
289
|
+
if (gasBalanceNumber.isLessThan(minGasBalanceNumber)) {
|
|
290
|
+
throw new blockchain_service_1.BSError('GAS balance is less than bridge fee', 'INSUFFICIENT_GAS_BALANCE_BRIDGE_FEE');
|
|
291
|
+
}
|
|
292
|
+
const fee = yield this.calculateFee({
|
|
293
|
+
account,
|
|
294
|
+
receiverAddress,
|
|
295
|
+
validatedInputs,
|
|
296
|
+
});
|
|
297
|
+
if (minGasBalanceNumber.plus(fee).isGreaterThan(gasBalanceNumber)) {
|
|
298
|
+
throw new blockchain_service_1.BSError('GAS balance is less than fees', 'INSUFFICIENT_GAS_BALANCE_FEES');
|
|
299
|
+
}
|
|
300
|
+
return validatedInputs;
|
|
301
|
+
});
|
|
302
|
+
};
|
|
@@ -25,6 +25,7 @@ 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");
|
|
28
29
|
const axios_1 = __importDefault(require("axios"));
|
|
29
30
|
const query_string_1 = __importDefault(require("query-string"));
|
|
30
31
|
const RpcNDSNeo3_1 = require("./RpcNDSNeo3");
|
|
@@ -51,7 +52,7 @@ class GhostMarketNDSNeo3 extends RpcNDSNeo3_1.RpcNDSNeo3 {
|
|
|
51
52
|
getNft({ contractHash, tokenId }) {
|
|
52
53
|
return __awaiter(this, void 0, void 0, function* () {
|
|
53
54
|
const url = __classPrivateFieldGet(this, _GhostMarketNDSNeo3_instances, "m", _GhostMarketNDSNeo3_getUrlWithParams).call(this, {
|
|
54
|
-
contract: contractHash,
|
|
55
|
+
contract: blockchain_service_1.BSTokenHelper.normalizeHash(contractHash),
|
|
55
56
|
tokenIds: [tokenId],
|
|
56
57
|
});
|
|
57
58
|
const { data } = yield axios_1.default.get(url);
|
|
@@ -82,7 +83,7 @@ _GhostMarketNDSNeo3_network = new WeakMap(), _GhostMarketNDSNeo3_instances = new
|
|
|
82
83
|
const nftResponse = {
|
|
83
84
|
collectionImage: __classPrivateFieldGet(this, _GhostMarketNDSNeo3_instances, "m", _GhostMarketNDSNeo3_treatGhostMarketImage).call(this, (_a = data.collection) === null || _a === void 0 ? void 0 : _a.logoUrl),
|
|
84
85
|
id: data.tokenId,
|
|
85
|
-
contractHash: data.contract.hash,
|
|
86
|
+
contractHash: blockchain_service_1.BSTokenHelper.normalizeHash(data.contract.hash),
|
|
86
87
|
symbol: data.contract.symbol,
|
|
87
88
|
collectionName: (_b = data.collection) === null || _b === void 0 ? void 0 : _b.name,
|
|
88
89
|
image: __classPrivateFieldGet(this, _GhostMarketNDSNeo3_instances, "m", _GhostMarketNDSNeo3_treatGhostMarketImage).call(this, data.metadata.mediaUri),
|
|
@@ -33,7 +33,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
33
33
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
34
34
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
35
35
|
};
|
|
36
|
-
var _DoraVoteServiceNeo3_doraAxiosInstance;
|
|
36
|
+
var _DoraVoteServiceNeo3_service, _DoraVoteServiceNeo3_doraAxiosInstance;
|
|
37
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
38
|
exports.DoraVoteServiceNeo3 = void 0;
|
|
39
39
|
const BSNeo3Helper_1 = require("../../helpers/BSNeo3Helper");
|
|
@@ -43,12 +43,14 @@ const RpcVoteServiceNeo3_1 = require("./RpcVoteServiceNeo3");
|
|
|
43
43
|
class DoraVoteServiceNeo3 extends RpcVoteServiceNeo3_1.RpcVoteServiceNeo3 {
|
|
44
44
|
constructor(service) {
|
|
45
45
|
super(service);
|
|
46
|
+
_DoraVoteServiceNeo3_service.set(this, void 0);
|
|
46
47
|
_DoraVoteServiceNeo3_doraAxiosInstance.set(this, void 0);
|
|
48
|
+
__classPrivateFieldSet(this, _DoraVoteServiceNeo3_service, service, "f");
|
|
47
49
|
__classPrivateFieldSet(this, _DoraVoteServiceNeo3_doraAxiosInstance, axios_1.default.create({ baseURL: `${blockchain_service_1.BSCommonConstants.DORA_URL}/api/v2/neo3` }), "f");
|
|
48
50
|
}
|
|
49
51
|
getCandidatesToVote() {
|
|
50
52
|
return __awaiter(this, void 0, void 0, function* () {
|
|
51
|
-
if (!BSNeo3Helper_1.BSNeo3Helper.isMainnet(this.
|
|
53
|
+
if (!BSNeo3Helper_1.BSNeo3Helper.isMainnet(__classPrivateFieldGet(this, _DoraVoteServiceNeo3_service, "f").network))
|
|
52
54
|
throw new Error('Only Mainnet is supported');
|
|
53
55
|
const { data } = yield __classPrivateFieldGet(this, _DoraVoteServiceNeo3_doraAxiosInstance, "f").get('/mainnet/committee');
|
|
54
56
|
return data.map((_a, index) => {
|
|
@@ -72,11 +74,11 @@ class DoraVoteServiceNeo3 extends RpcVoteServiceNeo3_1.RpcVoteServiceNeo3 {
|
|
|
72
74
|
}
|
|
73
75
|
getVoteDetailsByAddress(address) {
|
|
74
76
|
return __awaiter(this, void 0, void 0, function* () {
|
|
75
|
-
if (!BSNeo3Helper_1.BSNeo3Helper.isMainnet(this.
|
|
77
|
+
if (!BSNeo3Helper_1.BSNeo3Helper.isMainnet(__classPrivateFieldGet(this, _DoraVoteServiceNeo3_service, "f").network))
|
|
76
78
|
throw new Error('Only Mainnet is supported');
|
|
77
79
|
if (!address)
|
|
78
80
|
throw new Error('Missing address');
|
|
79
|
-
if (!this.
|
|
81
|
+
if (!__classPrivateFieldGet(this, _DoraVoteServiceNeo3_service, "f").validateAddress(address))
|
|
80
82
|
throw new Error('Invalid address');
|
|
81
83
|
const _a = (yield __classPrivateFieldGet(this, _DoraVoteServiceNeo3_doraAxiosInstance, "f").get(`/mainnet/voter/${address}`)).data, { candidatePubkey } = _a, data = __rest(_a, ["candidatePubkey"]);
|
|
82
84
|
if (!candidatePubkey)
|
|
@@ -90,4 +92,4 @@ class DoraVoteServiceNeo3 extends RpcVoteServiceNeo3_1.RpcVoteServiceNeo3 {
|
|
|
90
92
|
}
|
|
91
93
|
}
|
|
92
94
|
exports.DoraVoteServiceNeo3 = DoraVoteServiceNeo3;
|
|
93
|
-
_DoraVoteServiceNeo3_doraAxiosInstance = new WeakMap();
|
|
95
|
+
_DoraVoteServiceNeo3_service = new WeakMap(), _DoraVoteServiceNeo3_doraAxiosInstance = new WeakMap();
|
|
@@ -2,7 +2,6 @@ import { CalculateVoteFeeParams, GetCandidatesToVoteResponse, GetVoteDetailsByAd
|
|
|
2
2
|
import { BSNeo3 } from '../../BSNeo3';
|
|
3
3
|
export declare abstract class RpcVoteServiceNeo3<BSName extends string> implements VoteService<BSName> {
|
|
4
4
|
#private;
|
|
5
|
-
readonly _service: BSNeo3<BSName>;
|
|
6
5
|
protected constructor(service: BSNeo3<BSName>);
|
|
7
6
|
abstract getCandidatesToVote(): Promise<GetCandidatesToVoteResponse>;
|
|
8
7
|
abstract getVoteDetailsByAddress(_address: string): Promise<GetVoteDetailsByAddressResponse>;
|
|
@@ -8,32 +8,39 @@ 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
|
+
};
|
|
11
17
|
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
12
18
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
13
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");
|
|
14
20
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
15
21
|
};
|
|
16
|
-
var _RpcVoteServiceNeo3_instances, _RpcVoteServiceNeo3_getVoteCIM;
|
|
22
|
+
var _RpcVoteServiceNeo3_instances, _RpcVoteServiceNeo3_service, _RpcVoteServiceNeo3_getVoteCIM;
|
|
17
23
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
24
|
exports.RpcVoteServiceNeo3 = void 0;
|
|
19
25
|
const BSNeo3Helper_1 = require("../../helpers/BSNeo3Helper");
|
|
20
26
|
const neon_dappkit_1 = require("@cityofzion/neon-dappkit");
|
|
21
|
-
const blockchain_service_1 = require("@cityofzion/blockchain-service");
|
|
22
27
|
const neon_js_1 = require("@cityofzion/neon-js");
|
|
28
|
+
const blockchain_service_1 = require("@cityofzion/blockchain-service");
|
|
23
29
|
class RpcVoteServiceNeo3 {
|
|
24
30
|
constructor(service) {
|
|
25
31
|
_RpcVoteServiceNeo3_instances.add(this);
|
|
26
|
-
this
|
|
32
|
+
_RpcVoteServiceNeo3_service.set(this, void 0);
|
|
33
|
+
__classPrivateFieldSet(this, _RpcVoteServiceNeo3_service, service, "f");
|
|
27
34
|
}
|
|
28
35
|
vote({ account, candidatePubKey }) {
|
|
29
36
|
return __awaiter(this, void 0, void 0, function* () {
|
|
30
|
-
if (!BSNeo3Helper_1.BSNeo3Helper.isMainnet(this.
|
|
37
|
+
if (!BSNeo3Helper_1.BSNeo3Helper.isMainnet(__classPrivateFieldGet(this, _RpcVoteServiceNeo3_service, "f").network))
|
|
31
38
|
throw new Error('Only Mainnet is supported');
|
|
32
39
|
if (!candidatePubKey)
|
|
33
40
|
throw new Error('Missing candidatePubKey param');
|
|
34
|
-
const { neonJsAccount, signingCallback } = yield this.
|
|
41
|
+
const { neonJsAccount, signingCallback } = yield __classPrivateFieldGet(this, _RpcVoteServiceNeo3_service, "f").generateSigningCallback(account);
|
|
35
42
|
const invoker = yield neon_dappkit_1.NeonInvoker.init({
|
|
36
|
-
rpcAddress: this.
|
|
43
|
+
rpcAddress: __classPrivateFieldGet(this, _RpcVoteServiceNeo3_service, "f").network.url,
|
|
37
44
|
account: neonJsAccount,
|
|
38
45
|
signingCallback,
|
|
39
46
|
});
|
|
@@ -46,25 +53,25 @@ class RpcVoteServiceNeo3 {
|
|
|
46
53
|
}
|
|
47
54
|
calculateVoteFee({ account, candidatePubKey }) {
|
|
48
55
|
return __awaiter(this, void 0, void 0, function* () {
|
|
49
|
-
if (!BSNeo3Helper_1.BSNeo3Helper.isMainnet(this.
|
|
56
|
+
if (!BSNeo3Helper_1.BSNeo3Helper.isMainnet(__classPrivateFieldGet(this, _RpcVoteServiceNeo3_service, "f").network))
|
|
50
57
|
throw new Error('Only Mainnet is supported');
|
|
51
58
|
if (!candidatePubKey)
|
|
52
59
|
throw new Error('Missing candidatePubKey param');
|
|
53
|
-
const { neonJsAccount } = yield this.
|
|
60
|
+
const { neonJsAccount } = yield __classPrivateFieldGet(this, _RpcVoteServiceNeo3_service, "f").generateSigningCallback(account);
|
|
54
61
|
const invoker = yield neon_dappkit_1.NeonInvoker.init({
|
|
55
|
-
rpcAddress: this.
|
|
62
|
+
rpcAddress: __classPrivateFieldGet(this, _RpcVoteServiceNeo3_service, "f").network.url,
|
|
56
63
|
account: neonJsAccount,
|
|
57
64
|
});
|
|
58
65
|
const { total } = yield invoker.calculateFee(__classPrivateFieldGet(this, _RpcVoteServiceNeo3_instances, "m", _RpcVoteServiceNeo3_getVoteCIM).call(this, {
|
|
59
66
|
address: account.address,
|
|
60
67
|
candidatePubKey,
|
|
61
68
|
}));
|
|
62
|
-
return blockchain_service_1.
|
|
69
|
+
return blockchain_service_1.BSBigNumberHelper.format(total, { decimals: __classPrivateFieldGet(this, _RpcVoteServiceNeo3_service, "f").feeToken.decimals });
|
|
63
70
|
});
|
|
64
71
|
}
|
|
65
72
|
}
|
|
66
73
|
exports.RpcVoteServiceNeo3 = RpcVoteServiceNeo3;
|
|
67
|
-
_RpcVoteServiceNeo3_instances = new WeakSet(), _RpcVoteServiceNeo3_getVoteCIM = function _RpcVoteServiceNeo3_getVoteCIM({ address, candidatePubKey }) {
|
|
74
|
+
_RpcVoteServiceNeo3_service = new WeakMap(), _RpcVoteServiceNeo3_instances = new WeakSet(), _RpcVoteServiceNeo3_getVoteCIM = function _RpcVoteServiceNeo3_getVoteCIM({ address, candidatePubKey }) {
|
|
68
75
|
return {
|
|
69
76
|
invocations: [
|
|
70
77
|
{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cityofzion/bs-neo3",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.15.0",
|
|
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.19.0",
|
|
25
25
|
"@cityofzion/bs-asteroid-sdk": "0.9.1"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|