@cityofzion/bs-neo-legacy 0.7.2 → 0.8.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/.rush/temp/operation/build/all.log +1 -0
- package/.rush/temp/operation/build/state.json +3 -0
- package/.rush/temp/package-deps_build.json +10 -6
- package/.rush/temp/shrinkwrap-deps.json +350 -101
- package/CHANGELOG.json +22 -0
- package/CHANGELOG.md +11 -0
- package/bs-neo-legacy.build.log +1 -2
- package/dist/BSNeoLegacy.d.ts +24 -23
- package/dist/BSNeoLegacy.js +173 -171
- package/dist/CryptoCompareEDSNeoLegacy.d.ts +7 -7
- package/dist/CryptoCompareEDSNeoLegacy.js +51 -41
- package/dist/DoraBDSNeoLegacy.d.ts +16 -15
- package/dist/DoraBDSNeoLegacy.js +163 -162
- package/dist/DoraESNeoLegacy.d.ts +7 -0
- package/dist/DoraESNeoLegacy.js +17 -0
- package/dist/assets/tokens/common.json +18 -18
- package/dist/assets/tokens/mainnet.json +620 -620
- package/dist/constants.d.ts +13 -13
- package/dist/constants.js +23 -23
- package/dist/index.d.ts +4 -4
- package/dist/index.js +20 -20
- package/jest.config.ts +13 -13
- package/jest.setup.ts +1 -1
- package/package.json +26 -25
- package/src/BSNeoLegacy.ts +198 -191
- package/src/CryptoCompareEDSNeoLegacy.ts +50 -40
- package/src/DoraBDSNeoLegacy.ts +173 -171
- package/src/DoraESNeoLegacy.ts +18 -0
- package/src/__tests__/BDSNeoLegacy.spec.ts +120 -120
- package/src/__tests__/BSNeoLegacy.spec.ts +127 -127
- package/src/__tests__/CryptoCompareExchange.spec.ts +48 -46
- package/src/__tests__/DoraESNeoLegacy.spec.ts +15 -0
- package/src/assets/tokens/common.json +17 -17
- package/src/assets/tokens/mainnet.json +619 -619
- package/src/constants.ts +23 -23
- package/src/index.ts +4 -4
- package/tsconfig.build.json +4 -4
- package/tsconfig.json +14 -14
- package/dist/BDSNeoLegacy.d.ts +0 -15
- package/dist/BDSNeoLegacy.js +0 -199
- package/dist/asset/tokens.json +0 -480
- package/dist/explorer/dora/DoraResponsesNeoLegacy.d.ts +0 -95
- package/dist/explorer/dora/DoraResponsesNeoLegacy.js +0 -2
- package/dist/explorer/dora/DoraRoutesNeoLegacy.d.ts +0 -7
- package/dist/explorer/dora/DoraRoutesNeoLegacy.js +0 -10
- package/dist/explorer/index.d.ts +0 -6
- package/dist/explorer/index.js +0 -23
- package/docs/.nojekyll +0 -1
- package/docs/assets/highlight.css +0 -22
- package/docs/assets/main.js +0 -58
- package/docs/assets/search.js +0 -1
- package/docs/assets/style.css +0 -1280
- package/docs/classes/BDSNeoLegacy.html +0 -243
- package/docs/classes/BSNeoLegacy.html +0 -423
- package/docs/index.html +0 -70
- package/docs/interfaces/DoraNeoLegacyAsset.html +0 -103
- package/docs/interfaces/DoraNeoLegacyAssetResponse.html +0 -117
- package/docs/interfaces/DoraNeoLegacyBalance.html +0 -89
- package/docs/interfaces/DoraNeoLegacyConsensusNode.html +0 -75
- package/docs/interfaces/DoraNeoLegacyDetails.html +0 -138
- package/docs/interfaces/DoraNeoLegacyEntriesEntity.html +0 -110
- package/docs/interfaces/DoraNeoLegacyNameEntity.html +0 -75
- package/docs/interfaces/DoraNeoLegacyScriptsEntity.html +0 -75
- package/docs/interfaces/DoraNeoLegacyTransaction.html +0 -152
- package/docs/interfaces/DoraNeoLegacyTransactionsHistory.html +0 -96
- package/docs/interfaces/DoraNeoLegacyUnclaimed.html +0 -82
- package/docs/interfaces/DoraNeoLegacyVinEntity.html +0 -75
- package/docs/interfaces/DoraNeoLegacyVoutEntity.html +0 -89
- package/docs/modules.html +0 -98
- package/docs/variables/DORA_NEO_LEGACY_ASSET.html +0 -69
- package/docs/variables/DORA_NEO_LEGACY_BALANCE.html +0 -69
- package/docs/variables/DORA_NEO_LEGACY_CONTRACT.html +0 -69
- package/docs/variables/DORA_NEO_LEGACY_HISTORY_TRANSACTIONS.html +0 -69
- package/docs/variables/DORA_NEO_LEGACY_NODES.html +0 -69
- package/docs/variables/DORA_NEO_LEGACY_TRANSACTION.html +0 -69
- package/docs/variables/DORA_NEO_LEGACY_UNCLAIMED.html +0 -69
- package/docs/variables/explorerNeoLegacyOption.html +0 -74
package/CHANGELOG.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@cityofzion/bs-neo-legacy",
|
|
3
|
+
"entries": [
|
|
4
|
+
{
|
|
5
|
+
"version": "0.8.0",
|
|
6
|
+
"tag": "@cityofzion/bs-neo-legacy_v0.8.0",
|
|
7
|
+
"date": "Mon, 27 Nov 2023 22:13:46 GMT",
|
|
8
|
+
"comments": {
|
|
9
|
+
"minor": [
|
|
10
|
+
{
|
|
11
|
+
"comment": "Inserted within the TokenPricesResponse type the token hash"
|
|
12
|
+
}
|
|
13
|
+
],
|
|
14
|
+
"dependency": [
|
|
15
|
+
{
|
|
16
|
+
"comment": "Updating dependency \"@cityofzion/blockchain-service\" to `0.8.0`"
|
|
17
|
+
}
|
|
18
|
+
]
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
}
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Change Log - @cityofzion/bs-neo-legacy
|
|
2
|
+
|
|
3
|
+
This log was last generated on Mon, 27 Nov 2023 22:13:46 GMT and should not be manually modified.
|
|
4
|
+
|
|
5
|
+
## 0.8.0
|
|
6
|
+
Mon, 27 Nov 2023 22:13:46 GMT
|
|
7
|
+
|
|
8
|
+
### Minor changes
|
|
9
|
+
|
|
10
|
+
- Inserted within the TokenPricesResponse type the token hash
|
|
11
|
+
|
package/bs-neo-legacy.build.log
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
Invoking: tsc --project tsconfig.build.json
|
|
2
|
-
|
|
1
|
+
Invoking: tsc --project tsconfig.build.json
|
package/dist/BSNeoLegacy.d.ts
CHANGED
|
@@ -1,23 +1,24 @@
|
|
|
1
|
-
import { Account, BDSClaimable, BlockchainDataService, BlockchainService, BSClaimable, ExchangeDataService, Token, Network, PartialBy, TransferParam, AccountWithDerivationPath } from '@cityofzion/blockchain-service';
|
|
2
|
-
export declare class BSNeoLegacy<BSCustomName extends string = string> implements BlockchainService, BSClaimable {
|
|
3
|
-
readonly blockchainName: BSCustomName;
|
|
4
|
-
readonly feeToken: Token;
|
|
5
|
-
readonly claimToken: Token;
|
|
6
|
-
readonly burnToken: Token;
|
|
7
|
-
readonly derivationPath: string;
|
|
8
|
-
blockchainDataService: BlockchainDataService & BDSClaimable;
|
|
9
|
-
exchangeDataService: ExchangeDataService;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
1
|
+
import { Account, BDSClaimable, BlockchainDataService, BlockchainService, BSClaimable, ExchangeDataService, Token, Network, PartialBy, TransferParam, AccountWithDerivationPath, BSWithExplorerService, ExplorerService } from '@cityofzion/blockchain-service';
|
|
2
|
+
export declare class BSNeoLegacy<BSCustomName extends string = string> implements BlockchainService, BSClaimable, BSWithExplorerService {
|
|
3
|
+
readonly blockchainName: BSCustomName;
|
|
4
|
+
readonly feeToken: Token;
|
|
5
|
+
readonly claimToken: Token;
|
|
6
|
+
readonly burnToken: Token;
|
|
7
|
+
readonly derivationPath: string;
|
|
8
|
+
blockchainDataService: BlockchainDataService & BDSClaimable;
|
|
9
|
+
exchangeDataService: ExchangeDataService;
|
|
10
|
+
explorerService: ExplorerService;
|
|
11
|
+
tokens: Token[];
|
|
12
|
+
network: Network;
|
|
13
|
+
legacyNetwork: string;
|
|
14
|
+
constructor(blockchainName: BSCustomName, network: PartialBy<Network, 'url'>);
|
|
15
|
+
setNetwork(param: PartialBy<Network, 'url'>): void;
|
|
16
|
+
validateAddress(address: string): boolean;
|
|
17
|
+
validateEncrypted(key: string): boolean;
|
|
18
|
+
validateKey(key: string): boolean;
|
|
19
|
+
generateAccountFromMnemonic(mnemonic: string[] | string, index: number): AccountWithDerivationPath;
|
|
20
|
+
generateAccountFromKey(key: string): Account;
|
|
21
|
+
decrypt(encryptedKey: string, password: string): Promise<Account>;
|
|
22
|
+
transfer({ intent: transferIntent, senderAccount, tipIntent, ...params }: TransferParam): Promise<string>;
|
|
23
|
+
claim(account: Account): Promise<string>;
|
|
24
|
+
}
|
package/dist/BSNeoLegacy.js
CHANGED
|
@@ -1,171 +1,173 @@
|
|
|
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 __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
-
var t = {};
|
|
13
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
-
t[p] = s[p];
|
|
15
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
-
t[p[i]] = s[p[i]];
|
|
19
|
-
}
|
|
20
|
-
return t;
|
|
21
|
-
};
|
|
22
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
-
exports.BSNeoLegacy = void 0;
|
|
24
|
-
const neon_js_1 = require("@cityofzion/neon-js");
|
|
25
|
-
const constants_1 = require("./constants");
|
|
26
|
-
const DoraBDSNeoLegacy_1 = require("./DoraBDSNeoLegacy");
|
|
27
|
-
const CryptoCompareEDSNeoLegacy_1 = require("./CryptoCompareEDSNeoLegacy");
|
|
28
|
-
const bs_asteroid_sdk_1 = require("@cityofzion/bs-asteroid-sdk");
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
this.
|
|
35
|
-
this.
|
|
36
|
-
this.
|
|
37
|
-
this.
|
|
38
|
-
this.
|
|
39
|
-
this.
|
|
40
|
-
this.
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
this.
|
|
52
|
-
this.
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
const
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
const
|
|
103
|
-
const
|
|
104
|
-
const
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
neon_js_1.
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
.
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
const
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
const
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
}
|
|
171
|
-
|
|
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 __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
+
var t = {};
|
|
13
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
+
t[p] = s[p];
|
|
15
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
+
t[p[i]] = s[p[i]];
|
|
19
|
+
}
|
|
20
|
+
return t;
|
|
21
|
+
};
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
exports.BSNeoLegacy = void 0;
|
|
24
|
+
const neon_js_1 = require("@cityofzion/neon-js");
|
|
25
|
+
const constants_1 = require("./constants");
|
|
26
|
+
const DoraBDSNeoLegacy_1 = require("./DoraBDSNeoLegacy");
|
|
27
|
+
const CryptoCompareEDSNeoLegacy_1 = require("./CryptoCompareEDSNeoLegacy");
|
|
28
|
+
const bs_asteroid_sdk_1 = require("@cityofzion/bs-asteroid-sdk");
|
|
29
|
+
const DoraESNeoLegacy_1 = require("./DoraESNeoLegacy");
|
|
30
|
+
class BSNeoLegacy {
|
|
31
|
+
constructor(blockchainName, network) {
|
|
32
|
+
if (network.type === 'custom')
|
|
33
|
+
throw new Error('Custom network is not supported for NEO Legacy');
|
|
34
|
+
this.blockchainName = blockchainName;
|
|
35
|
+
this.legacyNetwork = constants_1.LEGACY_NETWORK_BY_NETWORK_TYPE[network.type];
|
|
36
|
+
this.derivationPath = constants_1.DERIVATION_PATH;
|
|
37
|
+
this.tokens = constants_1.TOKENS[network.type];
|
|
38
|
+
this.claimToken = this.tokens.find(token => token.symbol === 'GAS');
|
|
39
|
+
this.burnToken = this.tokens.find(token => token.symbol === 'NEO');
|
|
40
|
+
this.feeToken = this.tokens.find(token => token.symbol === 'GAS');
|
|
41
|
+
this.setNetwork(network);
|
|
42
|
+
}
|
|
43
|
+
setNetwork(param) {
|
|
44
|
+
var _a;
|
|
45
|
+
if (param.type === 'custom')
|
|
46
|
+
throw new Error('Custom network is not supported for NEO Legacy');
|
|
47
|
+
const network = {
|
|
48
|
+
type: param.type,
|
|
49
|
+
url: (_a = param.url) !== null && _a !== void 0 ? _a : constants_1.DEFAULT_URL_BY_NETWORK_TYPE[param.type],
|
|
50
|
+
};
|
|
51
|
+
this.network = network;
|
|
52
|
+
this.blockchainDataService = new DoraBDSNeoLegacy_1.DoraBDSNeoLegacy(network, this.feeToken, this.claimToken);
|
|
53
|
+
this.exchangeDataService = new CryptoCompareEDSNeoLegacy_1.CryptoCompareEDSNeoLegacy(network.type);
|
|
54
|
+
this.explorerService = new DoraESNeoLegacy_1.DoraESNeoLegacy(network.type);
|
|
55
|
+
}
|
|
56
|
+
validateAddress(address) {
|
|
57
|
+
return neon_js_1.wallet.isAddress(address);
|
|
58
|
+
}
|
|
59
|
+
validateEncrypted(key) {
|
|
60
|
+
return neon_js_1.wallet.isNEP2(key);
|
|
61
|
+
}
|
|
62
|
+
validateKey(key) {
|
|
63
|
+
return neon_js_1.wallet.isWIF(key) || neon_js_1.wallet.isPrivateKey(key);
|
|
64
|
+
}
|
|
65
|
+
generateAccountFromMnemonic(mnemonic, index) {
|
|
66
|
+
bs_asteroid_sdk_1.keychain.importMnemonic(Array.isArray(mnemonic) ? mnemonic.join(' ') : mnemonic);
|
|
67
|
+
const path = this.derivationPath.replace('?', index.toString());
|
|
68
|
+
const childKey = bs_asteroid_sdk_1.keychain.generateChildKey('neo', path);
|
|
69
|
+
const key = childKey.getWIF();
|
|
70
|
+
const { address } = new neon_js_1.wallet.Account(key);
|
|
71
|
+
return { address, key, type: 'wif', derivationPath: path };
|
|
72
|
+
}
|
|
73
|
+
generateAccountFromKey(key) {
|
|
74
|
+
const type = neon_js_1.wallet.isWIF(key) ? 'wif' : neon_js_1.wallet.isPrivateKey(key) ? 'privateKey' : undefined;
|
|
75
|
+
if (!type)
|
|
76
|
+
throw new Error('Invalid key');
|
|
77
|
+
const { address } = new neon_js_1.wallet.Account(key);
|
|
78
|
+
return { address, key, type };
|
|
79
|
+
}
|
|
80
|
+
decrypt(encryptedKey, password) {
|
|
81
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
82
|
+
let BsReactNativeDecrypt;
|
|
83
|
+
try {
|
|
84
|
+
const { NativeModules } = require('react-native');
|
|
85
|
+
BsReactNativeDecrypt = NativeModules.BsReactNativeDecrypt;
|
|
86
|
+
}
|
|
87
|
+
catch (_a) {
|
|
88
|
+
const key = yield neon_js_1.wallet.decrypt(encryptedKey, password);
|
|
89
|
+
return this.generateAccountFromKey(key);
|
|
90
|
+
}
|
|
91
|
+
if (!BsReactNativeDecrypt) {
|
|
92
|
+
throw new Error('@CityOfZion/bs-react-native-decrypt is not installed');
|
|
93
|
+
}
|
|
94
|
+
const privateKey = yield BsReactNativeDecrypt.decryptNeoLegacy(encryptedKey, password);
|
|
95
|
+
return this.generateAccountFromKey(privateKey);
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
transfer(_a) {
|
|
99
|
+
var _b, _c;
|
|
100
|
+
var { intent: transferIntent, senderAccount, tipIntent } = _a, params = __rest(_a, ["intent", "senderAccount", "tipIntent"]);
|
|
101
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
102
|
+
const apiProvider = new neon_js_1.api.neoCli.instance(this.network.url);
|
|
103
|
+
const account = new neon_js_1.wallet.Account(senderAccount.key);
|
|
104
|
+
const priorityFee = Number((_b = params.priorityFee) !== null && _b !== void 0 ? _b : 0);
|
|
105
|
+
const nativeIntents = [];
|
|
106
|
+
const nep5ScriptBuilder = new neon_js_1.sc.ScriptBuilder();
|
|
107
|
+
const intents = [transferIntent, ...(tipIntent ? [tipIntent] : [])];
|
|
108
|
+
for (const intent of intents) {
|
|
109
|
+
const tokenHashFixed = intent.tokenHash.replace('0x', '');
|
|
110
|
+
const nativeAsset = constants_1.NATIVE_ASSETS.find(asset => asset.hash === tokenHashFixed);
|
|
111
|
+
if (nativeAsset) {
|
|
112
|
+
nativeIntents.push(...neon_js_1.api.makeIntent({ [nativeAsset.symbol]: Number(intent.amount) }, intent.receiverAddress));
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
nep5ScriptBuilder.emitAppCall(tokenHashFixed, 'transfer', [
|
|
116
|
+
neon_js_1.u.reverseHex(neon_js_1.wallet.getScriptHashFromAddress(account.address)),
|
|
117
|
+
neon_js_1.u.reverseHex(neon_js_1.wallet.getScriptHashFromAddress(intent.receiverAddress)),
|
|
118
|
+
neon_js_1.sc.ContractParam.integer(new neon_js_1.u.Fixed8(intent.amount)
|
|
119
|
+
.div(Math.pow(10, 8 - ((_c = intent.tokenDecimals) !== null && _c !== void 0 ? _c : 8)))
|
|
120
|
+
.toRawNumber()
|
|
121
|
+
.toString()),
|
|
122
|
+
]);
|
|
123
|
+
}
|
|
124
|
+
let response;
|
|
125
|
+
if (nep5ScriptBuilder.isEmpty()) {
|
|
126
|
+
response = yield neon_js_1.api.sendAsset({
|
|
127
|
+
account,
|
|
128
|
+
api: apiProvider,
|
|
129
|
+
url: this.network.url,
|
|
130
|
+
intents: nativeIntents,
|
|
131
|
+
fees: priorityFee,
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
response = yield neon_js_1.api.doInvoke({
|
|
136
|
+
intents: nativeIntents.length > 0 ? nativeIntents : undefined,
|
|
137
|
+
account,
|
|
138
|
+
api: apiProvider,
|
|
139
|
+
script: nep5ScriptBuilder.str,
|
|
140
|
+
url: this.network.url,
|
|
141
|
+
fees: priorityFee,
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
if (!response.tx)
|
|
145
|
+
throw new Error('Failed to send transaction');
|
|
146
|
+
return response.tx.hash;
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
claim(account) {
|
|
150
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
151
|
+
const neoAccount = new neon_js_1.wallet.Account(account.key);
|
|
152
|
+
const balances = yield this.blockchainDataService.getBalance(account.address);
|
|
153
|
+
const neoBalance = balances.find(balance => balance.token.symbol === 'NEO');
|
|
154
|
+
if (!neoBalance)
|
|
155
|
+
throw new Error('It is necessary to have NEO to claim');
|
|
156
|
+
const unclaimed = yield this.blockchainDataService.getUnclaimed(account.address);
|
|
157
|
+
if (Number(unclaimed) <= 0)
|
|
158
|
+
throw new Error(`Doesn't have gas to claim`);
|
|
159
|
+
const apiProvider = new neon_js_1.api.neoCli.instance(this.legacyNetwork);
|
|
160
|
+
const claims = yield apiProvider.getClaims(account.address);
|
|
161
|
+
const response = yield neon_js_1.api.claimGas({
|
|
162
|
+
claims,
|
|
163
|
+
api: apiProvider,
|
|
164
|
+
account: neoAccount,
|
|
165
|
+
url: this.network.url,
|
|
166
|
+
});
|
|
167
|
+
if (!response.tx)
|
|
168
|
+
throw new Error('Failed to claim');
|
|
169
|
+
return response.tx.hash;
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
exports.BSNeoLegacy = BSNeoLegacy;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Currency, ExchangeDataService, NetworkType, TokenPricesResponse } from '@cityofzion/blockchain-service';
|
|
2
|
-
export declare class CryptoCompareEDSNeoLegacy implements ExchangeDataService {
|
|
3
|
-
networkType: NetworkType;
|
|
4
|
-
private axiosInstance;
|
|
5
|
-
constructor(network: NetworkType);
|
|
6
|
-
getTokenPrices(currency: Currency): Promise<TokenPricesResponse[]>;
|
|
7
|
-
}
|
|
1
|
+
import { Currency, ExchangeDataService, NetworkType, TokenPricesResponse } from '@cityofzion/blockchain-service';
|
|
2
|
+
export declare class CryptoCompareEDSNeoLegacy implements ExchangeDataService {
|
|
3
|
+
networkType: NetworkType;
|
|
4
|
+
private axiosInstance;
|
|
5
|
+
constructor(network: NetworkType);
|
|
6
|
+
getTokenPrices(currency: Currency): Promise<TokenPricesResponse[]>;
|
|
7
|
+
}
|
|
@@ -1,41 +1,51 @@
|
|
|
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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.CryptoCompareEDSNeoLegacy = void 0;
|
|
16
|
-
const axios_1 = __importDefault(require("axios"));
|
|
17
|
-
const constants_1 = require("./constants");
|
|
18
|
-
class CryptoCompareEDSNeoLegacy {
|
|
19
|
-
constructor(network) {
|
|
20
|
-
this.networkType = network;
|
|
21
|
-
this.axiosInstance = axios_1.default.create({ baseURL: 'https://min-api.cryptocompare.com' });
|
|
22
|
-
}
|
|
23
|
-
getTokenPrices(currency) {
|
|
24
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
-
if (this.networkType !== 'mainnet')
|
|
26
|
-
throw new Error('Exchange is only available on mainnet');
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.CryptoCompareEDSNeoLegacy = void 0;
|
|
16
|
+
const axios_1 = __importDefault(require("axios"));
|
|
17
|
+
const constants_1 = require("./constants");
|
|
18
|
+
class CryptoCompareEDSNeoLegacy {
|
|
19
|
+
constructor(network) {
|
|
20
|
+
this.networkType = network;
|
|
21
|
+
this.axiosInstance = axios_1.default.create({ baseURL: 'https://min-api.cryptocompare.com' });
|
|
22
|
+
}
|
|
23
|
+
getTokenPrices(currency) {
|
|
24
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
+
if (this.networkType !== 'mainnet')
|
|
26
|
+
throw new Error('Exchange is only available on mainnet');
|
|
27
|
+
const tokens = constants_1.TOKENS[this.networkType];
|
|
28
|
+
const tokenSymbols = tokens.map(token => token.symbol);
|
|
29
|
+
const { data: prices } = yield this.axiosInstance.get('/data/pricemultifull', {
|
|
30
|
+
params: {
|
|
31
|
+
fsyms: tokenSymbols.join(','),
|
|
32
|
+
tsyms: currency,
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
return Object.entries(prices.RAW)
|
|
36
|
+
.map(([symbol, priceObject]) => {
|
|
37
|
+
const price = priceObject[currency].PRICE;
|
|
38
|
+
const token = tokens.find(token => token.symbol === symbol);
|
|
39
|
+
if (!token || !price)
|
|
40
|
+
return;
|
|
41
|
+
return {
|
|
42
|
+
symbol,
|
|
43
|
+
price,
|
|
44
|
+
hash: token === null || token === void 0 ? void 0 : token.hash,
|
|
45
|
+
};
|
|
46
|
+
})
|
|
47
|
+
.filter((price) => price !== undefined);
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
exports.CryptoCompareEDSNeoLegacy = CryptoCompareEDSNeoLegacy;
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import { BalanceResponse, BlockchainDataService, ContractResponse, TransactionsByAddressParams, TransactionsByAddressResponse, TransactionResponse, BDSClaimable, Token, Network } from '@cityofzion/blockchain-service';
|
|
2
|
-
export declare class DoraBDSNeoLegacy implements BlockchainDataService, BDSClaimable {
|
|
3
|
-
readonly network: Network;
|
|
4
|
-
private readonly claimToken;
|
|
5
|
-
private readonly feeToken;
|
|
6
|
-
private readonly tokenCache;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
import { BalanceResponse, BlockchainDataService, ContractResponse, TransactionsByAddressParams, TransactionsByAddressResponse, TransactionResponse, BDSClaimable, Token, Network } from '@cityofzion/blockchain-service';
|
|
2
|
+
export declare class DoraBDSNeoLegacy implements BlockchainDataService, BDSClaimable {
|
|
3
|
+
readonly network: Network;
|
|
4
|
+
private readonly claimToken;
|
|
5
|
+
private readonly feeToken;
|
|
6
|
+
private readonly tokenCache;
|
|
7
|
+
maxTimeToConfirmTransactionInMs: number;
|
|
8
|
+
constructor(network: Network, feeToken: Token, claimToken: Token);
|
|
9
|
+
getTransaction(hash: string): Promise<TransactionResponse>;
|
|
10
|
+
getTransactionsByAddress({ address, page, }: TransactionsByAddressParams): Promise<TransactionsByAddressResponse>;
|
|
11
|
+
getContract(contractHash: string): Promise<ContractResponse>;
|
|
12
|
+
getTokenInfo(tokenHash: string): Promise<Token>;
|
|
13
|
+
getBalance(address: string): Promise<BalanceResponse[]>;
|
|
14
|
+
getUnclaimed(address: string): Promise<string>;
|
|
15
|
+
getBlockHeight(): Promise<number>;
|
|
16
|
+
}
|