@cityofzion/bs-neo3 1.14.0 → 1.14.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.
|
@@ -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,12 +8,18 @@ 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");
|
|
@@ -23,17 +29,18 @@ const neon_js_1 = require("@cityofzion/neon-js");
|
|
|
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.BSNumberHelper.formatNumber(total, { decimals: this.
|
|
69
|
+
return blockchain_service_1.BSNumberHelper.formatNumber(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
|
{
|