@cityofzion/bs-neo3 1.16.2 → 1.16.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/dist/BSNeo3.d.ts +39 -30
  2. package/dist/BSNeo3.js +102 -54
  3. package/dist/constants/BSNeo3Constants.d.ts +12 -17
  4. package/dist/constants/BSNeo3Constants.js +221 -37
  5. package/dist/helpers/BSNeo3Helper.d.ts +5 -6
  6. package/dist/helpers/BSNeo3Helper.js +9 -8
  7. package/dist/helpers/BSNeo3NeonDappKitSingletonHelper.d.ts +6 -0
  8. package/dist/helpers/BSNeo3NeonDappKitSingletonHelper.js +26 -0
  9. package/dist/helpers/BSNeo3NeonJsSingletonHelper.d.ts +7 -0
  10. package/dist/helpers/BSNeo3NeonJsSingletonHelper.js +26 -0
  11. package/dist/index.d.ts +3 -2
  12. package/dist/index.js +3 -2
  13. package/dist/services/blockchain-data/DoraBDSNeo3.d.ts +13 -12
  14. package/dist/services/blockchain-data/DoraBDSNeo3.js +130 -140
  15. package/dist/services/blockchain-data/RpcBDSNeo3.d.ts +13 -19
  16. package/dist/services/blockchain-data/RpcBDSNeo3.js +28 -62
  17. package/dist/services/chaim-data/RpcCDSNeo3.d.ts +7 -0
  18. package/dist/services/chaim-data/RpcCDSNeo3.js +27 -0
  19. package/dist/services/exchange-data/FlamingoForthewinEDSNeo3.d.ts +6 -7
  20. package/dist/services/exchange-data/FlamingoForthewinEDSNeo3.js +4 -19
  21. package/dist/services/explorer/DoraESNeo3.d.ts +5 -5
  22. package/dist/services/explorer/DoraESNeo3.js +19 -22
  23. package/dist/services/ledger/NeonDappKitLedgerServiceNeo3.d.ts +10 -10
  24. package/dist/services/ledger/NeonDappKitLedgerServiceNeo3.js +28 -38
  25. package/dist/services/neo3neoXBridge/Neo3NeoXBridgeService.d.ts +10 -9
  26. package/dist/services/neo3neoXBridge/Neo3NeoXBridgeService.js +26 -25
  27. package/dist/services/nft-data/GhostMarketNDSNeo3.d.ts +7 -11
  28. package/dist/services/nft-data/GhostMarketNDSNeo3.js +41 -79
  29. package/dist/services/vote/DoraVoteServiceNeo3.d.ts +8 -29
  30. package/dist/services/vote/DoraVoteServiceNeo3.js +81 -21
  31. package/dist/types.d.ts +84 -0
  32. package/dist/types.js +18 -0
  33. package/package.json +25 -25
  34. package/dist/assets/tokens/mainnet.json +0 -194
  35. package/dist/assets/tokens/native.json +0 -14
  36. package/dist/builder/invocation/NeonDappKitInvocationBuilderNeo3.d.ts +0 -34
  37. package/dist/builder/invocation/NeonDappKitInvocationBuilderNeo3.js +0 -102
  38. package/dist/interfaces.d.ts +0 -41
  39. package/dist/interfaces.js +0 -2
  40. package/dist/services/nft-data/RpcNDSNeo3.d.ts +0 -9
  41. package/dist/services/nft-data/RpcNDSNeo3.js +0 -59
  42. package/dist/services/vote/RpcVoteServiceNeo3.d.ts +0 -10
  43. package/dist/services/vote/RpcVoteServiceNeo3.js +0 -88
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cityofzion/bs-neo3",
3
- "version": "1.16.2",
3
+ "version": "1.16.4",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "repository": "https://github.com/CityOfZion/blockchain-services",
@@ -10,39 +10,39 @@
10
10
  "/dist"
11
11
  ],
12
12
  "dependencies": {
13
+ "@cityofzion/dora-ts": "~0.5.1",
13
14
  "@cityofzion/neon-js": "~5.7.0",
14
15
  "@cityofzion/neon-core": "~5.7.0",
15
- "@cityofzion/dora-ts": "0.5.1",
16
- "axios": "1.8.2",
17
- "query-string": "7.1.3",
18
- "@ledgerhq/hw-transport": "~6.31.8",
19
16
  "@cityofzion/neon-dappkit": "~0.6.0",
20
- "bignumber.js": "^9.1.2",
21
- "isomorphic-ws": "^5.0.0",
22
- "lodash.clonedeep": "^4.5.0",
23
- "date-fns": "~4.1.0",
24
- "@cityofzion/blockchain-service": "1.21.1",
25
- "@cityofzion/bs-asteroid-sdk": "0.9.1"
17
+ "axios": "~1.12.2",
18
+ "@cityofzion/blockchain-service": "1.21.3"
26
19
  },
27
20
  "devDependencies": {
28
21
  "@cityofzion/neon-dappkit-types": "~0.5.0",
29
- "@ledgerhq/hw-transport-node-hid": "~6.28.5",
30
- "@types/lodash.clonedeep": "^4.5.9",
31
- "@types/jest": "29.5.3",
32
- "@typescript-eslint/eslint-plugin": "^6.5.0",
33
- "@typescript-eslint/parser": "^6.5.0",
34
- "dotenv": "16.3.1",
35
- "eslint": "^8.48.0",
36
- "jest": "29.6.2",
37
- "ts-jest": "29.1.1",
22
+ "@ledgerhq/hw-transport": "~6.31.11",
23
+ "@ledgerhq/hw-transport-node-hid": "~6.29.12",
24
+ "@types/jest": "~30.0.0",
25
+ "date-fns": "~4.1.0",
26
+ "dotenv": "~17.2.2",
27
+ "eslint": "~9.36.0",
28
+ "jest": "~30.1.3",
29
+ "ts-jest": "~29.4.4",
38
30
  "ts-node": "~10.9.2",
39
- "typescript": "4.9.5",
40
- "typed-emitter": "^2.1.0"
31
+ "typescript": "~5.9.2"
32
+ },
33
+ "overrides": {
34
+ "@cityofzion/neon-js": "~5.7.0",
35
+ "@cityofzion/neon-core": "~5.7.0"
36
+ },
37
+ "resolutions": {
38
+ "@cityofzion/neon-js": "~5.7.0",
39
+ "@cityofzion/neon-core": "~5.7.0"
41
40
  },
42
41
  "scripts": {
43
- "build": "tsc --project tsconfig.build.json",
44
- "test": "jest --config jest.config.ts",
42
+ "build": "rm -rf ./dist && tsc --project tsconfig.build.json",
43
+ "test": "jest -i --config jest.config.ts",
45
44
  "lint": "eslint .",
46
- "format": "eslint --fix"
45
+ "format": "eslint --fix",
46
+ "package": "npm run build && npm pack"
47
47
  }
48
48
  }
@@ -1,194 +0,0 @@
1
- [
2
- {
3
- "symbol": "LRB",
4
- "name": "LyrebirdToken",
5
- "hash": "0x8c07b4c9f5bc170a3922eac4f5bb7ef17b0acc8b",
6
- "decimals": 8
7
- },
8
- {
9
- "symbol": "USDL",
10
- "name": "LyrebirdUSDToken",
11
- "hash": "0xa8c51aa0c177187aeed3db88bdfa908ccbc9b1a5",
12
- "decimals": 8
13
- },
14
- {
15
- "symbol": "FLM",
16
- "name": "FLM",
17
- "hash": "0xf0151f528127558851b39c2cd8aa47da7418ab28",
18
- "decimals": 8
19
- },
20
- {
21
- "symbol": "CAKE",
22
- "hash": "0x570c27653683788177f05740257d88fed76bf74b",
23
- "decimals": 18,
24
- "name": "CAKE"
25
- },
26
- {
27
- "symbol": "fCAKE",
28
- "name": "fCAKE",
29
- "hash": "0xe65b462b90516012826f8a9c4c285d8c750e3a77",
30
- "decimals": 18
31
- },
32
- {
33
- "symbol": "WING",
34
- "name": "WING",
35
- "hash": "0x948a60635d1f7921063d04be8f6cb35c741df566",
36
- "decimals": 9
37
- },
38
- {
39
- "symbol": "pWING",
40
- "hash": "0xeeccd60ed722111f8400434dac3ba42c14d8beb1",
41
- "decimals": 9,
42
- "name": "pWING"
43
- },
44
- {
45
- "symbol": "WETH",
46
- "hash": "0xd3a41b53888a733b549f5d4146e7a98d3285fa21",
47
- "decimals": 18,
48
- "name": "WETH"
49
- },
50
- {
51
- "symbol": "fWETH",
52
- "name": "fWETH",
53
- "hash": "0xc14b601252aa5dfa6166cf35fe5ccd2e35f3fdf5",
54
- "decimals": 18
55
- },
56
- {
57
- "symbol": "WBTC",
58
- "hash": "0x4548a3bcb3c2b5ce42bf0559b1cf2f1ec97a51d0",
59
- "decimals": 8,
60
- "name": "WBTC"
61
- },
62
- {
63
- "symbol": "fWBTC",
64
- "name": "fWBTC",
65
- "hash": "0xd6abe115ecb75e1fa0b42f5e85934ce8c1ae2893",
66
- "decimals": 8
67
- },
68
- {
69
- "symbol": "SWTH",
70
- "name": "SWTHToken",
71
- "hash": "0x78e1330db47634afdb5ea455302ba2d12b8d549f",
72
- "decimals": 8
73
- },
74
- {
75
- "symbol": "ONT",
76
- "hash": "0x0a1328bffb804ad7bb342673da82a972cc7af86c",
77
- "decimals": 9,
78
- "name": "ONT"
79
- },
80
- {
81
- "symbol": "pONT",
82
- "name": "pONT",
83
- "hash": "0x8122bc2212ec971690a044b37a6f52a9349b702b",
84
- "decimals": 9
85
- },
86
- {
87
- "symbol": "USDT",
88
- "name": "USDT",
89
- "hash": "0x68b938cc42b6a2d54fb9040f5facf4290ebb8c5f",
90
- "decimals": 6
91
- },
92
- {
93
- "symbol": "fUSDT",
94
- "name": "fUSDT",
95
- "hash": "0xcd48b160c1bbc9d74997b803b9a7ad50a4bef020",
96
- "decimals": 6
97
- },
98
- {
99
- "symbol": "FLUND",
100
- "name": "FLUND",
101
- "hash": "0xa9603a59e21d29e37ac39cf1b5f5abf5006b22a3",
102
- "decimals": 8
103
- },
104
- {
105
- "symbol": "GM",
106
- "name": "GhostMarketToken",
107
- "hash": "0x9b049f1283515eef1d3f6ac610e1595ed25ca3e9",
108
- "decimals": 8
109
- },
110
- {
111
- "symbol": "TIPS",
112
- "name": "TIPS",
113
- "hash": "0x340720c7107ef5721e44ed2ea8e314cce5c130fa",
114
- "decimals": 8
115
- },
116
- {
117
- "symbol": "CANDY",
118
- "name": "NeoCandy",
119
- "hash": "0x88da18a5bca86ec8206d9b4960a7d0c4355a432f",
120
- "decimals": 9
121
- },
122
- {
123
- "symbol": "DOGER",
124
- "name": "DogeRift",
125
- "hash": "0x322b5a366ca724801a1aa01e669b5f3d7f8c7f6f",
126
- "decimals": 8
127
- },
128
- {
129
- "symbol": "DOGEF",
130
- "name": "DogeFood",
131
- "hash": "0xa3291b66f70d4687fc0e41977d8acb0699f235ae",
132
- "decimals": 8
133
- },
134
- {
135
- "symbol": "SOM",
136
- "name": "Som",
137
- "hash": "0x2d4c6cf0417209a7eb410160344e224e74f87195",
138
- "decimals": 8
139
- },
140
- {
141
- "symbol": "LAMBO",
142
- "name": "BoomerFund",
143
- "hash": "0xafdd6abedf066ff8c5fbc868cc89f80eac467142",
144
- "decimals": 8
145
- },
146
- {
147
- "symbol": "bNEO",
148
- "hash": "0x48c40d4666f93408be1bef038b6722404d9a4c2a",
149
- "decimals": 8,
150
- "name": "BurgerNEO"
151
- },
152
- {
153
- "symbol": "BNB",
154
- "hash": "0x00fb9575f220727f71a1537f75e83af9387628ff",
155
- "decimals": 18,
156
- "name": "BNB"
157
- },
158
- {
159
- "symbol": "fBNB",
160
- "hash": "0xb56f0fba45cc57a948b342186274dfd863996bb3",
161
- "decimals": 18,
162
- "name": "fBNB"
163
- },
164
- {
165
- "symbol": "FUSD",
166
- "hash": "0x1005d400bcc2a56b7352f09e273be3f9933a5fb1",
167
- "decimals": 8,
168
- "name": "FUSD"
169
- },
170
- {
171
- "symbol": "FDE",
172
- "hash": "0x9770f4d78a19d1a6fa94b472bcedffcc06b56c49",
173
- "decimals": 8,
174
- "name": "FDE"
175
- },
176
- {
177
- "symbol": "Hood",
178
- "hash": "0xc8d56cac2dd82e2da605ccae6865a99da491b97e",
179
- "decimals": 8,
180
- "name": "RobinHood"
181
- },
182
- {
183
- "symbol": "HD",
184
- "hash": "0x4b027a8320d5705802e5efbb51f6231ebf412cf6",
185
- "decimals": 8,
186
- "name": "The Hongfei"
187
- },
188
- {
189
- "symbol": "NRP",
190
- "hash": "0x789518aa302b571e3e825f2c85a01ad731014a45",
191
- "decimals": 8,
192
- "name": "NeoRedPill"
193
- }
194
- ]
@@ -1,14 +0,0 @@
1
- [
2
- {
3
- "symbol": "GAS",
4
- "name": "GAS",
5
- "hash": "0xd2a4cff31913016155e38e474a2c06d08be276cf",
6
- "decimals": 8
7
- },
8
- {
9
- "symbol": "NEO",
10
- "name": "NEO",
11
- "hash": "0xef4073a0f2b305a38ec4050e4d3d28bc40ea63f5",
12
- "decimals": 0
13
- }
14
- ]
@@ -1,34 +0,0 @@
1
- import { Arg, ContractInvocation } from '@cityofzion/neon-dappkit-types';
2
- export type GetReservesParams = {
3
- routerScriptHash: string;
4
- tokenToReceiveHash: string;
5
- tokenToUseHash: string;
6
- };
7
- export type TokenOutForTokenInParams = {
8
- routerScriptHash: string;
9
- senderAddress: string;
10
- amountToReceive: string;
11
- maximumSelling: string;
12
- deadline: string;
13
- args: Arg[];
14
- };
15
- export type TokenInForTokenOutParams = {
16
- routerScriptHash: string;
17
- senderAddress: string;
18
- amountToUse: string;
19
- minimumReceived: string;
20
- deadline: string;
21
- args: Arg[];
22
- };
23
- export type TransferArgs = {
24
- contractHash: string;
25
- senderAddress: string;
26
- tokenHash: string;
27
- amount: string;
28
- };
29
- export declare class NeonDappKitInvocationBuilderNeo3 {
30
- static getReservesContractInvocation({ routerScriptHash, tokenToReceiveHash, tokenToUseHash, }: GetReservesParams): ContractInvocation;
31
- static swapTokenOutForTokenInContractInvocation({ routerScriptHash, senderAddress, amountToReceive, maximumSelling, deadline, args, }: TokenOutForTokenInParams): ContractInvocation;
32
- static swapTokenInForTokenOutContractInvocation({ routerScriptHash, senderAddress, amountToUse, minimumReceived, deadline, args, }: TokenInForTokenOutParams): ContractInvocation;
33
- static transferContractInvocation({ contractHash, senderAddress, tokenHash, amount, }: TransferArgs): ContractInvocation;
34
- }
@@ -1,102 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NeonDappKitInvocationBuilderNeo3 = void 0;
4
- class NeonDappKitInvocationBuilderNeo3 {
5
- static getReservesContractInvocation({ routerScriptHash, tokenToReceiveHash, tokenToUseHash, }) {
6
- return {
7
- scriptHash: routerScriptHash,
8
- operation: 'getReserves',
9
- args: [
10
- {
11
- type: 'Hash160',
12
- value: tokenToReceiveHash,
13
- },
14
- {
15
- type: 'Hash160',
16
- value: tokenToUseHash,
17
- },
18
- ],
19
- };
20
- }
21
- static swapTokenOutForTokenInContractInvocation({ routerScriptHash, senderAddress, amountToReceive, maximumSelling, deadline, args, }) {
22
- return {
23
- scriptHash: routerScriptHash,
24
- operation: 'swapTokenOutForTokenIn',
25
- args: [
26
- {
27
- type: 'Hash160',
28
- value: senderAddress,
29
- },
30
- {
31
- type: 'Integer',
32
- value: amountToReceive,
33
- },
34
- {
35
- type: 'Integer',
36
- value: maximumSelling,
37
- },
38
- {
39
- type: 'Array',
40
- value: args,
41
- },
42
- {
43
- type: 'Integer',
44
- value: deadline,
45
- },
46
- ],
47
- };
48
- }
49
- static swapTokenInForTokenOutContractInvocation({ routerScriptHash, senderAddress, amountToUse, minimumReceived, deadline, args, }) {
50
- return {
51
- scriptHash: routerScriptHash,
52
- operation: 'swapTokenInForTokenOut',
53
- args: [
54
- {
55
- type: 'Hash160',
56
- value: senderAddress,
57
- },
58
- {
59
- type: 'Integer',
60
- value: amountToUse,
61
- },
62
- {
63
- type: 'Integer',
64
- value: minimumReceived,
65
- },
66
- {
67
- type: 'Array',
68
- value: args,
69
- },
70
- {
71
- type: 'Integer',
72
- value: deadline,
73
- },
74
- ],
75
- };
76
- }
77
- static transferContractInvocation({ contractHash, senderAddress, tokenHash, amount, }) {
78
- return {
79
- scriptHash: contractHash,
80
- operation: 'transfer',
81
- args: [
82
- {
83
- type: 'Hash160',
84
- value: senderAddress,
85
- },
86
- {
87
- type: 'Hash160',
88
- value: tokenHash,
89
- },
90
- {
91
- type: 'Integer',
92
- value: amount,
93
- },
94
- {
95
- type: 'Any',
96
- value: null,
97
- },
98
- ],
99
- };
100
- }
101
- }
102
- exports.NeonDappKitInvocationBuilderNeo3 = NeonDappKitInvocationBuilderNeo3;
@@ -1,41 +0,0 @@
1
- import { Account } from '@cityofzion/blockchain-service';
2
- import Neon from '@cityofzion/neon-core';
3
- import { api } from '@cityofzion/neon-js';
4
- export type GenerateSigningCallbackResponse = {
5
- neonJsAccount: Neon.wallet.Account;
6
- signingCallback: api.SigningFunction;
7
- };
8
- export type Candidate = {
9
- position: number;
10
- name: string;
11
- description: string;
12
- location: string;
13
- email: string;
14
- website: string;
15
- hash: string;
16
- pubKey: string;
17
- votes: number;
18
- logoUrl?: string;
19
- type: 'consensus' | 'council';
20
- };
21
- export type GetCandidatesToVoteResponse = Candidate[];
22
- export type GetVoteDetailsByAddressResponse = {
23
- candidateName?: string;
24
- candidatePubKey?: string;
25
- neoBalance: number;
26
- address: string;
27
- };
28
- export type VoteParams<BSName extends string> = {
29
- account: Account<BSName>;
30
- candidatePubKey: string;
31
- };
32
- export type VoteResponse = {
33
- transactionHash: string;
34
- };
35
- export type CalculateVoteFeeParams<BSName extends string> = VoteParams<BSName>;
36
- export interface VoteService<BSName extends string> {
37
- getCandidatesToVote(): Promise<GetCandidatesToVoteResponse>;
38
- getVoteDetailsByAddress(address: string): Promise<GetVoteDetailsByAddressResponse>;
39
- vote(params: VoteParams<BSName>): Promise<VoteResponse>;
40
- calculateVoteFee(params: CalculateVoteFeeParams<BSName>): Promise<string>;
41
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,9 +0,0 @@
1
- import { GetNftParam, GetNftsByAddressParams, HasTokenParam, Network, NftDataService, NftResponse, NftsResponse } from '@cityofzion/blockchain-service';
2
- import { BSNeo3NetworkId } from '../../constants/BSNeo3Constants';
3
- export declare abstract class RpcNDSNeo3 implements NftDataService {
4
- #private;
5
- protected constructor(network: Network<BSNeo3NetworkId>);
6
- abstract getNftsByAddress(params: GetNftsByAddressParams): Promise<NftsResponse>;
7
- abstract getNft(params: GetNftParam): Promise<NftResponse>;
8
- hasToken({ collectionHash, address }: HasTokenParam): Promise<boolean>;
9
- }
@@ -1,59 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
12
- if (kind === "m") throw new TypeError("Private method is not writable");
13
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
14
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
15
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
16
- };
17
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
18
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
19
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
20
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
21
- };
22
- var _RpcNDSNeo3_network;
23
- Object.defineProperty(exports, "__esModule", { value: true });
24
- exports.RpcNDSNeo3 = void 0;
25
- const neon_dappkit_1 = require("@cityofzion/neon-dappkit");
26
- class RpcNDSNeo3 {
27
- constructor(network) {
28
- _RpcNDSNeo3_network.set(this, void 0);
29
- __classPrivateFieldSet(this, _RpcNDSNeo3_network, network, "f");
30
- }
31
- hasToken({ collectionHash, address }) {
32
- return __awaiter(this, void 0, void 0, function* () {
33
- const parser = neon_dappkit_1.NeonParser;
34
- const invoker = yield neon_dappkit_1.NeonInvoker.init({ rpcAddress: __classPrivateFieldGet(this, _RpcNDSNeo3_network, "f").url });
35
- try {
36
- const result = yield invoker.testInvoke({
37
- invocations: [
38
- {
39
- scriptHash: collectionHash,
40
- operation: 'balanceOf',
41
- args: [
42
- {
43
- type: 'Hash160',
44
- value: address,
45
- },
46
- ],
47
- },
48
- ],
49
- });
50
- return parser.parseRpcResponse(result.stack[0], { type: 'Integer' }) > 0;
51
- }
52
- catch (_a) {
53
- throw new Error(`Token not found: ${collectionHash}`);
54
- }
55
- });
56
- }
57
- }
58
- exports.RpcNDSNeo3 = RpcNDSNeo3;
59
- _RpcNDSNeo3_network = new WeakMap();
@@ -1,10 +0,0 @@
1
- import { CalculateVoteFeeParams, GetCandidatesToVoteResponse, GetVoteDetailsByAddressResponse, VoteParams, VoteResponse, VoteService } from '../../interfaces';
2
- import { BSNeo3 } from '../../BSNeo3';
3
- export declare abstract class RpcVoteServiceNeo3<BSName extends string> implements VoteService<BSName> {
4
- #private;
5
- protected constructor(service: BSNeo3<BSName>);
6
- abstract getCandidatesToVote(): Promise<GetCandidatesToVoteResponse>;
7
- abstract getVoteDetailsByAddress(_address: string): Promise<GetVoteDetailsByAddressResponse>;
8
- vote({ account, candidatePubKey }: VoteParams<BSName>): Promise<VoteResponse>;
9
- calculateVoteFee({ account, candidatePubKey }: CalculateVoteFeeParams<BSName>): Promise<string>;
10
- }
@@ -1,88 +0,0 @@
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 _RpcVoteServiceNeo3_instances, _RpcVoteServiceNeo3_service, _RpcVoteServiceNeo3_getVoteCIM;
23
- Object.defineProperty(exports, "__esModule", { value: true });
24
- exports.RpcVoteServiceNeo3 = void 0;
25
- const BSNeo3Helper_1 = require("../../helpers/BSNeo3Helper");
26
- const neon_dappkit_1 = require("@cityofzion/neon-dappkit");
27
- const neon_js_1 = require("@cityofzion/neon-js");
28
- const blockchain_service_1 = require("@cityofzion/blockchain-service");
29
- class RpcVoteServiceNeo3 {
30
- constructor(service) {
31
- _RpcVoteServiceNeo3_instances.add(this);
32
- _RpcVoteServiceNeo3_service.set(this, void 0);
33
- __classPrivateFieldSet(this, _RpcVoteServiceNeo3_service, service, "f");
34
- }
35
- vote({ account, candidatePubKey }) {
36
- return __awaiter(this, void 0, void 0, function* () {
37
- if (!BSNeo3Helper_1.BSNeo3Helper.isMainnet(__classPrivateFieldGet(this, _RpcVoteServiceNeo3_service, "f").network))
38
- throw new Error('Only Mainnet is supported');
39
- if (!candidatePubKey)
40
- throw new Error('Missing candidatePubKey param');
41
- const { neonJsAccount, signingCallback } = yield __classPrivateFieldGet(this, _RpcVoteServiceNeo3_service, "f").generateSigningCallback(account);
42
- const invoker = yield neon_dappkit_1.NeonInvoker.init({
43
- rpcAddress: __classPrivateFieldGet(this, _RpcVoteServiceNeo3_service, "f").network.url,
44
- account: neonJsAccount,
45
- signingCallback,
46
- });
47
- const transactionHash = yield invoker.invokeFunction(__classPrivateFieldGet(this, _RpcVoteServiceNeo3_instances, "m", _RpcVoteServiceNeo3_getVoteCIM).call(this, {
48
- address: account.address,
49
- candidatePubKey,
50
- }));
51
- return { transactionHash };
52
- });
53
- }
54
- calculateVoteFee({ account, candidatePubKey }) {
55
- return __awaiter(this, void 0, void 0, function* () {
56
- if (!BSNeo3Helper_1.BSNeo3Helper.isMainnet(__classPrivateFieldGet(this, _RpcVoteServiceNeo3_service, "f").network))
57
- throw new Error('Only Mainnet is supported');
58
- if (!candidatePubKey)
59
- throw new Error('Missing candidatePubKey param');
60
- const { neonJsAccount } = yield __classPrivateFieldGet(this, _RpcVoteServiceNeo3_service, "f").generateSigningCallback(account);
61
- const invoker = yield neon_dappkit_1.NeonInvoker.init({
62
- rpcAddress: __classPrivateFieldGet(this, _RpcVoteServiceNeo3_service, "f").network.url,
63
- account: neonJsAccount,
64
- });
65
- const { total } = yield invoker.calculateFee(__classPrivateFieldGet(this, _RpcVoteServiceNeo3_instances, "m", _RpcVoteServiceNeo3_getVoteCIM).call(this, {
66
- address: account.address,
67
- candidatePubKey,
68
- }));
69
- return blockchain_service_1.BSBigNumberHelper.format(total, { decimals: __classPrivateFieldGet(this, _RpcVoteServiceNeo3_service, "f").feeToken.decimals });
70
- });
71
- }
72
- }
73
- exports.RpcVoteServiceNeo3 = RpcVoteServiceNeo3;
74
- _RpcVoteServiceNeo3_service = new WeakMap(), _RpcVoteServiceNeo3_instances = new WeakSet(), _RpcVoteServiceNeo3_getVoteCIM = function _RpcVoteServiceNeo3_getVoteCIM({ address, candidatePubKey }) {
75
- return {
76
- invocations: [
77
- {
78
- scriptHash: 'ef4073a0f2b305a38ec4050e4d3d28bc40ea63f5',
79
- operation: 'vote',
80
- args: [
81
- { type: 'Hash160', value: address },
82
- { type: 'PublicKey', value: candidatePubKey },
83
- ],
84
- },
85
- ],
86
- signers: [{ scopes: neon_js_1.tx.WitnessScope.CalledByEntry }],
87
- };
88
- };