@cityofzion/bs-neo3 1.2.0 → 1.3.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.
Files changed (46) hide show
  1. package/dist/BSNeo3.d.ts +3 -3
  2. package/dist/BSNeo3.js +9 -9
  3. package/dist/builder/invocation/FlamingoSwapInvocationBuilderNeo3.d.ts +7 -0
  4. package/dist/builder/invocation/FlamingoSwapInvocationBuilderNeo3.js +95 -0
  5. package/dist/builder/invocation/NeonDappKitInvocationBuilderNeo3.d.ts +34 -0
  6. package/dist/builder/invocation/NeonDappKitInvocationBuilderNeo3.js +102 -0
  7. package/dist/constants/FlamingoSwapConstants.d.ts +36 -0
  8. package/dist/constants/FlamingoSwapConstants.js +853 -0
  9. package/dist/{BSNeo3Helper.js → helpers/BSNeo3Helper.js} +2 -2
  10. package/dist/helpers/FlamingoSwapHelper.d.ts +19 -0
  11. package/dist/helpers/FlamingoSwapHelper.js +84 -0
  12. package/dist/index.d.ts +13 -11
  13. package/dist/index.js +13 -11
  14. package/dist/{DoraBDSNeo3.d.ts → services/blockchain-data/DoraBDSNeo3.d.ts} +4 -4
  15. package/dist/{DoraBDSNeo3.js → services/blockchain-data/DoraBDSNeo3.js} +3 -3
  16. package/dist/{RpcBDSNeo3.d.ts → services/blockchain-data/RpcBDSNeo3.d.ts} +2 -2
  17. package/dist/{RpcBDSNeo3.js → services/blockchain-data/RpcBDSNeo3.js} +4 -4
  18. package/dist/{FlamingoEDSNeo3.d.ts → services/exchange-data/FlamingoEDSNeo3.d.ts} +1 -1
  19. package/dist/{FlamingoEDSNeo3.js → services/exchange-data/FlamingoEDSNeo3.js} +1 -1
  20. package/dist/{DoraESNeo3.d.ts → services/explorer/DoraESNeo3.d.ts} +2 -2
  21. package/dist/{DoraESNeo3.js → services/explorer/DoraESNeo3.js} +1 -1
  22. package/dist/{NeonDappKitLedgerServiceNeo3.d.ts → services/ledger/NeonDappKitLedgerServiceNeo3.d.ts} +2 -4
  23. package/dist/services/ledger/NeonDappKitLedgerServiceNeo3.js +135 -0
  24. package/dist/{GhostMarketNDSNeo3.d.ts → services/nft-data/GhostMarketNDSNeo3.d.ts} +2 -2
  25. package/dist/{RpcNDSNeo3.d.ts → services/nft-data/RpcNDSNeo3.d.ts} +1 -1
  26. package/dist/services/swap/FlamingoSwapServiceNeo3.d.ts +23 -0
  27. package/dist/services/swap/FlamingoSwapServiceNeo3.js +271 -0
  28. package/dist/services/swap/handlers/FlamingoSwapDetailsHandler.d.ts +24 -0
  29. package/dist/services/swap/handlers/FlamingoSwapDetailsHandler.js +178 -0
  30. package/dist/services/swap/handlers/FlamingoSwapRouteHandler.d.ts +13 -0
  31. package/dist/services/swap/handlers/FlamingoSwapRouteHandler.js +181 -0
  32. package/dist/services/swap/handlers/FlamingoSwapSocketHandler.d.ts +9 -0
  33. package/dist/services/swap/handlers/FlamingoSwapSocketHandler.js +57 -0
  34. package/dist/services/swap/handlers/index.d.ts +3 -0
  35. package/dist/services/swap/handlers/index.js +19 -0
  36. package/package.json +7 -5
  37. package/dist/NeonDappKitLedgerServiceNeo3.js +0 -110
  38. package/dist/flamingo-swap/FlamingoSwapControllerService.d.ts +0 -20
  39. package/dist/flamingo-swap/FlamingoSwapControllerService.js +0 -290
  40. package/dist/flamingo-swap/FlamingoSwapHelper.d.ts +0 -48
  41. package/dist/flamingo-swap/FlamingoSwapHelper.js +0 -171
  42. package/dist/flamingo-swap/FlamingoSwapNeonDappKitInvocationBuilder.d.ts +0 -19
  43. package/dist/flamingo-swap/FlamingoSwapNeonDappKitInvocationBuilder.js +0 -208
  44. package/dist/{BSNeo3Helper.d.ts → helpers/BSNeo3Helper.d.ts} +0 -0
  45. package/dist/{GhostMarketNDSNeo3.js → services/nft-data/GhostMarketNDSNeo3.js} +1 -1
  46. /package/dist/{RpcNDSNeo3.js → services/nft-data/RpcNDSNeo3.js} +0 -0
@@ -1,208 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FlamingoSwapNeonDappKitInvocationBuilder = void 0;
4
- const neon_core_1 = require("@cityofzion/neon-core");
5
- const FlamingoSwapHelper_1 = require("./FlamingoSwapHelper");
6
- class FlamingoSwapNeonDappKitInvocationBuilder {
7
- static swapInvocation(data) {
8
- return data.type === 'swapTokenToReceive'
9
- ? this.swapTokenToReceiveForTokenToUseInvocation(data)
10
- : this.swapTokenToUseForTokenToReceiveInvocation(data);
11
- }
12
- static getReservesInvocation({ network, tokenToReceiveScriptHash, tokenToUseScriptHash, }) {
13
- const scriptHashes = FlamingoSwapHelper_1.FlamingoSwapHelper.getSwapScriptHashes(network);
14
- return {
15
- invocations: [
16
- {
17
- scriptHash: scriptHashes.flamingoSwapRouter,
18
- operation: 'getReserves',
19
- args: [
20
- {
21
- type: 'Hash160',
22
- value: this.overrideScriptHash(network, tokenToReceiveScriptHash),
23
- },
24
- {
25
- type: 'Hash160',
26
- value: this.overrideScriptHash(network, tokenToUseScriptHash),
27
- },
28
- ],
29
- },
30
- ],
31
- signers: [
32
- {
33
- scopes: 1,
34
- },
35
- ],
36
- };
37
- }
38
- static swapTokenToReceiveForTokenToUseInvocation({ address, amountToReceive, maximumSelling, tokenToReceive, tokenToUse, deadline, network, }) {
39
- const invocations = [];
40
- const allowedContracts = [];
41
- const scriptHashes = FlamingoSwapHelper_1.FlamingoSwapHelper.getSwapScriptHashes(network);
42
- const tokenToReceiveOverrode = FlamingoSwapHelper_1.FlamingoSwapHelper.overrideToken(network, tokenToReceive);
43
- const amountToReceiveFormatted = neon_core_1.u.BigInteger.fromDecimal(Number(amountToReceive), tokenToReceiveOverrode.decimals).toString();
44
- const maximumSellingFormatted = neon_core_1.u.BigInteger.fromDecimal(Number(maximumSelling), tokenToUse.decimals).toString();
45
- invocations.push({
46
- scriptHash: scriptHashes.flamingoSwapRouter,
47
- operation: 'swapTokenOutForTokenIn',
48
- args: [
49
- {
50
- type: 'Hash160',
51
- value: address,
52
- },
53
- {
54
- type: 'Integer',
55
- value: amountToReceiveFormatted,
56
- },
57
- {
58
- type: 'Integer',
59
- value: maximumSellingFormatted,
60
- },
61
- {
62
- type: 'Array',
63
- value: [
64
- {
65
- type: 'Hash160',
66
- value: tokenToUse.hash,
67
- },
68
- {
69
- type: 'Hash160',
70
- value: tokenToReceiveOverrode.hash,
71
- },
72
- ],
73
- },
74
- {
75
- type: 'Integer',
76
- value: deadline,
77
- },
78
- ],
79
- });
80
- const isNeoSwapped = tokenToReceive.hash === scriptHashes.neo;
81
- if (isNeoSwapped) {
82
- const amountToUseInTransferFormatted = neon_core_1.u.BigInteger.fromNumber(Number(amountToReceiveFormatted) * FlamingoSwapHelper_1.FlamingoSwapHelper.GAS_PER_NEO).toString();
83
- const transferContractInvocation = this.transferContractInvocation({
84
- address,
85
- amountToUse: amountToUseInTransferFormatted,
86
- tokenToUseScriptHash: scriptHashes.bneo,
87
- contractScriptHash: scriptHashes.gas,
88
- });
89
- invocations.push(transferContractInvocation);
90
- allowedContracts.push(...this.allowedContractsTransfer(scriptHashes));
91
- }
92
- allowedContracts.push(...this.allowedContractsSwap(scriptHashes, tokenToReceive.hash, tokenToUse.hash));
93
- return {
94
- invocations,
95
- signers: [
96
- {
97
- scopes: neon_core_1.tx.WitnessScope.CustomContracts,
98
- allowedContracts,
99
- },
100
- ],
101
- };
102
- }
103
- static swapTokenToUseForTokenToReceiveInvocation({ address, amountToUse, deadline, tokenToReceive, tokenToUse, minimumReceived, network, }) {
104
- const invocations = [];
105
- const allowedContracts = [];
106
- const scriptHashes = FlamingoSwapHelper_1.FlamingoSwapHelper.getSwapScriptHashes(network);
107
- const isNeoSwapped = tokenToUse.hash === scriptHashes.neo;
108
- if (isNeoSwapped) {
109
- const transferContractInvocation = this.transferContractInvocation({
110
- address,
111
- amountToUse,
112
- tokenToUseScriptHash: scriptHashes.bneo,
113
- contractScriptHash: scriptHashes.neo,
114
- });
115
- invocations.push(transferContractInvocation);
116
- allowedContracts.push(...this.allowedContractsTransfer(scriptHashes));
117
- }
118
- const tokenToUseOverrode = FlamingoSwapHelper_1.FlamingoSwapHelper.overrideToken(network, tokenToUse);
119
- const amountToUseFormatted = neon_core_1.u.BigInteger.fromDecimal(Number(amountToUse), tokenToUseOverrode.decimals).toString();
120
- const minimumReceivedFormatted = neon_core_1.u.BigInteger.fromDecimal(Number(minimumReceived), tokenToReceive.decimals).toString();
121
- invocations.push({
122
- scriptHash: scriptHashes.flamingoSwapRouter,
123
- operation: 'swapTokenInForTokenOut',
124
- args: [
125
- {
126
- type: 'Hash160',
127
- value: address,
128
- },
129
- {
130
- type: 'Integer',
131
- value: amountToUseFormatted,
132
- },
133
- {
134
- type: 'Integer',
135
- value: minimumReceivedFormatted,
136
- },
137
- {
138
- type: 'Array',
139
- value: [
140
- {
141
- type: 'Hash160',
142
- value: tokenToUseOverrode.hash,
143
- },
144
- {
145
- type: 'Hash160',
146
- value: tokenToReceive.hash,
147
- },
148
- ],
149
- },
150
- {
151
- type: 'Integer',
152
- value: deadline,
153
- },
154
- ],
155
- });
156
- allowedContracts.push(...this.allowedContractsSwap(scriptHashes, tokenToReceive.hash, tokenToUse.hash));
157
- return {
158
- invocations,
159
- signers: [
160
- {
161
- scopes: neon_core_1.tx.WitnessScope.CustomContracts,
162
- allowedContracts,
163
- },
164
- ],
165
- };
166
- }
167
- static transferContractInvocation({ address, amountToUse, contractScriptHash, tokenToUseScriptHash, }) {
168
- return {
169
- scriptHash: contractScriptHash,
170
- operation: 'transfer',
171
- args: [
172
- {
173
- type: 'Hash160',
174
- value: address,
175
- },
176
- {
177
- type: 'Hash160',
178
- value: tokenToUseScriptHash,
179
- },
180
- {
181
- type: 'Integer',
182
- value: amountToUse,
183
- },
184
- {
185
- type: 'Any',
186
- value: null,
187
- },
188
- ],
189
- };
190
- }
191
- static allowedContractsSwap(scriptHashes, tokenInScriptHash, tokenOutScriptHash) {
192
- return [
193
- scriptHashes.flamingoSwapRouter,
194
- scriptHashes.flamingoFactory,
195
- scriptHashes.flamingoPairWhiteList,
196
- tokenInScriptHash,
197
- tokenOutScriptHash,
198
- ];
199
- }
200
- static allowedContractsTransfer(scriptHashes) {
201
- return [scriptHashes.gas, scriptHashes.flpBneoGas, scriptHashes.bneo];
202
- }
203
- static overrideScriptHash(network, scriptHash) {
204
- const swapScriptHashes = FlamingoSwapHelper_1.FlamingoSwapHelper.getSwapScriptHashes(network);
205
- return scriptHash === swapScriptHashes.neo ? swapScriptHashes.bneo : scriptHash;
206
- }
207
- }
208
- exports.FlamingoSwapNeonDappKitInvocationBuilder = FlamingoSwapNeonDappKitInvocationBuilder;
@@ -25,8 +25,8 @@ 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 query_string_1 = __importDefault(require("query-string"));
29
28
  const axios_1 = __importDefault(require("axios"));
29
+ const query_string_1 = __importDefault(require("query-string"));
30
30
  const RpcNDSNeo3_1 = require("./RpcNDSNeo3");
31
31
  class GhostMarketNDSNeo3 extends RpcNDSNeo3_1.RpcNDSNeo3 {
32
32
  constructor(network) {