@cityofzion/bs-neo-legacy 0.4.2 → 0.7.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.
- package/.rush/temp/package-deps_build.json +21 -0
- package/.rush/temp/shrinkwrap-deps.json +2 -2
- package/bs-neo-legacy.build.log +1 -86
- package/dist/BSNeoLegacy.d.ts +20 -23
- package/dist/BSNeoLegacy.js +118 -135
- package/dist/CryptoCompareEDSNeoLegacy.d.ts +7 -0
- package/dist/CryptoCompareEDSNeoLegacy.js +41 -0
- package/dist/DoraBDSNeoLegacy.d.ts +15 -0
- package/dist/DoraBDSNeoLegacy.js +162 -0
- package/dist/assets/tokens/common.json +18 -0
- package/dist/assets/tokens/mainnet.json +620 -0
- package/dist/constants.d.ts +10 -4
- package/dist/constants.js +20 -17
- package/dist/index.d.ts +3 -2
- package/dist/index.js +3 -2
- package/docs/assets/search.js +1 -1
- package/docs/classes/BDSNeoLegacy.html +13 -13
- package/docs/classes/BSNeoLegacy.html +81 -37
- package/docs/interfaces/DoraNeoLegacyAsset.html +7 -7
- package/docs/interfaces/DoraNeoLegacyAssetResponse.html +9 -9
- package/docs/interfaces/DoraNeoLegacyBalance.html +5 -5
- package/docs/interfaces/DoraNeoLegacyConsensusNode.html +3 -3
- package/docs/interfaces/DoraNeoLegacyDetails.html +12 -12
- package/docs/interfaces/DoraNeoLegacyEntriesEntity.html +8 -8
- package/docs/interfaces/DoraNeoLegacyNameEntity.html +3 -3
- package/docs/interfaces/DoraNeoLegacyScriptsEntity.html +3 -3
- package/docs/interfaces/DoraNeoLegacyTransaction.html +14 -14
- package/docs/interfaces/DoraNeoLegacyTransactionsHistory.html +6 -6
- package/docs/interfaces/DoraNeoLegacyUnclaimed.html +4 -4
- package/docs/interfaces/DoraNeoLegacyVinEntity.html +3 -3
- package/docs/interfaces/DoraNeoLegacyVoutEntity.html +5 -5
- package/docs/variables/DORA_NEO_LEGACY_ASSET.html +1 -1
- package/docs/variables/DORA_NEO_LEGACY_BALANCE.html +1 -1
- package/docs/variables/DORA_NEO_LEGACY_CONTRACT.html +1 -1
- package/docs/variables/DORA_NEO_LEGACY_HISTORY_TRANSACTIONS.html +1 -1
- package/docs/variables/DORA_NEO_LEGACY_NODES.html +1 -1
- package/docs/variables/DORA_NEO_LEGACY_TRANSACTION.html +1 -1
- package/docs/variables/DORA_NEO_LEGACY_UNCLAIMED.html +1 -1
- package/docs/variables/explorerNeoLegacyOption.html +1 -1
- package/jest.config.ts +13 -0
- package/jest.setup.ts +1 -0
- package/package.json +10 -6
- package/src/BSNeoLegacy.ts +184 -152
- package/src/CryptoCompareEDSNeoLegacy.ts +40 -0
- package/src/DoraBDSNeoLegacy.ts +171 -0
- package/src/__tests__/BDSNeoLegacy.spec.ts +120 -0
- package/src/__tests__/BSNeoLegacy.spec.ts +127 -0
- package/src/__tests__/CryptoCompareExchange.spec.ts +46 -0
- package/src/assets/tokens/common.json +18 -0
- package/src/assets/tokens/mainnet.json +620 -0
- package/src/constants.ts +20 -17
- package/src/index.ts +3 -2
- package/tsconfig.build.json +4 -0
- package/tsconfig.json +3 -7
- package/bs-neo-legacy.build.error.log +0 -84
- package/src/BDSNeoLegacy.ts +0 -163
- package/src/asset/blockchain_icon_neo_legacy.png +0 -0
- package/src/asset/blockchain_icon_neo_legacy_white.png +0 -0
- package/src/asset/tokens.json +0 -481
- package/src/explorer/dora/DoraResponsesNeoLegacy.ts +0 -107
- package/src/explorer/dora/DoraRoutesNeoLegacy.ts +0 -7
- package/src/explorer/index.ts +0 -8
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"files": {
|
|
3
|
+
"packages/bs-neo-legacy/jest.config.ts": "d944475db93cbe41a9339187fd94b9962e411c43",
|
|
4
|
+
"packages/bs-neo-legacy/jest.setup.ts": "9a1976a32050616d4d2ee95b1aa21041bc4daca3",
|
|
5
|
+
"packages/bs-neo-legacy/package.json": "c0b7d3d28174c6ce4652a442ad6b9485ee49f45c",
|
|
6
|
+
"packages/bs-neo-legacy/src/BSNeoLegacy.ts": "ce59dc999823497ba0f79ec31afb81aec1d29351",
|
|
7
|
+
"packages/bs-neo-legacy/src/CryptoCompareEDSNeoLegacy.ts": "7cbe7bf0e39f100edd329a9211006c3c1994a1c2",
|
|
8
|
+
"packages/bs-neo-legacy/src/DoraBDSNeoLegacy.ts": "3ac617c879987ae8106cb212c36523909fffe79d",
|
|
9
|
+
"packages/bs-neo-legacy/src/__tests__/BDSNeoLegacy.spec.ts": "04210ed3cc8b8afbc824417be87eac06d1f875fd",
|
|
10
|
+
"packages/bs-neo-legacy/src/__tests__/BSNeoLegacy.spec.ts": "b2cff48a43db986fc02fdefbfd66a5cd4d70a5d9",
|
|
11
|
+
"packages/bs-neo-legacy/src/__tests__/CryptoCompareExchange.spec.ts": "0aeb2e77cf1d3eabc7534d2b9cbc26e93240852d",
|
|
12
|
+
"packages/bs-neo-legacy/src/assets/tokens/common.json": "81b0a9bb3e6c1b5bb41f57e6b1fc403ce1ac1489",
|
|
13
|
+
"packages/bs-neo-legacy/src/assets/tokens/mainnet.json": "e1194b98d7a91a8494760d597a90c02e00880972",
|
|
14
|
+
"packages/bs-neo-legacy/src/constants.ts": "82e36146cf6cf3c16bc7b7ec4fd3e4089c745bd5",
|
|
15
|
+
"packages/bs-neo-legacy/src/index.ts": "247e7d072502350e685e11497aeedc89b7c921d5",
|
|
16
|
+
"packages/bs-neo-legacy/tsconfig.build.json": "4dc23fb9c4c5e4d19a9bc3947a47c523f4bd967c",
|
|
17
|
+
"packages/bs-neo-legacy/tsconfig.json": "77cf2b789e9c665b62792f9992cc81ae86296ef7",
|
|
18
|
+
"common/config/rush/npm-shrinkwrap.json": "4994dce94cedd11a678400d92e08741ac7bc9d3f"
|
|
19
|
+
},
|
|
20
|
+
"arguments": "tsc --project tsconfig.build.json "
|
|
21
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
|
-
"../../packages/bs-neo-legacy": "../../packages/bs-neo-legacy:
|
|
3
|
-
"/@cityofzion/blockchain-service/0.3.
|
|
2
|
+
"../../packages/bs-neo-legacy": "../../packages/bs-neo-legacy:IOE6x0Jg1o1QcNEwF2rtSNHgOZi7/+bAniT1hAF6CJI=:",
|
|
3
|
+
"/@cityofzion/blockchain-service/0.3.0": "sha512-Qe/lVI8tCAAVZZNeBglZEFrqS9khjihc5jkiiEobi6CY4l1z6uFj/xSGQ7Nnz2QlTNQ8DjUqN05iDjKuy+4LLA==",
|
|
4
4
|
"/@cityofzion/dora-ts/0.0.11": "sha512-LJWGU29BHPTHkt0i/OwhNdMfUGM/rgAa4rqlDwBy95spxSoUHGSoAtOD5k4aSVKmLFwq77ghNna0Lpc7lEuHBA==",
|
|
5
5
|
"/@cityofzion/neon-api/4.9.0_@cityofzion+neon-core@4.9.0": "sha512-8eN3N3sGgd4L7qFaFATKr94kA/65626eo6hB7fHL+S8OGCVCrrl3tfh8GAOv50vLxd2YyoDu9pBY/0NPKY8tsQ==",
|
|
6
6
|
"/@cityofzion/neon-core/4.9.0": "sha512-z4UgEIjAS9E2QP6HSTzri02DFY++nYmfzbspi1818mvnTst6Lf8bDNYYxG/686wdYN2dEF3RuccMXraw2Bm31g==",
|
package/bs-neo-legacy.build.log
CHANGED
|
@@ -1,87 +1,2 @@
|
|
|
1
|
-
Invoking: tsc
|
|
1
|
+
Invoking: tsc --project tsconfig.build.json
|
|
2
2
|
|
|
3
|
-
C:/Workspace/blockchain-services/packages/blockchain-service/dist/interfaces.d.ts:140:0 - warning BlockchainDataService is referenced by BDSNeoLegacy but not included in the documentation.
|
|
4
|
-
|
|
5
|
-
140 export interface BlockchainDataService {
|
|
6
|
-
|
|
7
|
-
C:/Workspace/blockchain-services/packages/blockchain-service/dist/interfaces.d.ts:137:0 - warning BDSClaimable is referenced by BDSNeoLegacy but not included in the documentation.
|
|
8
|
-
|
|
9
|
-
137 export interface BDSClaimable {
|
|
10
|
-
|
|
11
|
-
C:/Workspace/blockchain-services/packages/blockchain-service/dist/interfaces.d.ts:60:0 - warning BlockchainService is referenced by BSNeoLegacy but not included in the documentation.
|
|
12
|
-
|
|
13
|
-
60 export interface BlockchainService<BSCustomName extends string = string> {
|
|
14
|
-
|
|
15
|
-
C:/Workspace/blockchain-services/packages/blockchain-service/dist/interfaces.d.ts:30:0 - warning Claimable is referenced by BSNeoLegacy but not included in the documentation.
|
|
16
|
-
|
|
17
|
-
30 export interface Claimable {
|
|
18
|
-
|
|
19
|
-
C:/Workspace/blockchain-services/packages/blockchain-service/dist/interfaces.d.ts:126:0 - warning BlockchainNetwork is referenced by BDSNeoLegacy.network but not included in the documentation.
|
|
20
|
-
|
|
21
|
-
126 export type BlockchainNetwork = "mainnet" | "testnet" | "privatenet";
|
|
22
|
-
|
|
23
|
-
C:/Workspace/blockchain-services/packages/blockchain-service/dist/interfaces.d.ts:156:0 - warning Exchange is referenced by BSNeoLegacy.exchange but not included in the documentation.
|
|
24
|
-
|
|
25
|
-
156 export interface Exchange {
|
|
26
|
-
|
|
27
|
-
C:/Workspace/blockchain-services/packages/blockchain-service/dist/interfaces.d.ts:11:0 - warning TokenInfo is referenced by BSNeoLegacy.feeToken but not included in the documentation.
|
|
28
|
-
|
|
29
|
-
11 export type TokenInfo = {
|
|
30
|
-
|
|
31
|
-
C:/Workspace/blockchain-services/packages/blockchain-service/dist/interfaces.d.ts:46:0 - warning Token is referenced by BSNeoLegacy.tokens but not included in the documentation.
|
|
32
|
-
|
|
33
|
-
46 export type Token = {
|
|
34
|
-
|
|
35
|
-
C:/Workspace/blockchain-services/packages/blockchain-service/dist/interfaces.d.ts:118:0 - warning ConsensusNodeResponse is referenced by BDSNeoLegacy.getAllNodes.getAllNodes but not included in the documentation.
|
|
36
|
-
|
|
37
|
-
118 export type ConsensusNodeResponse = {
|
|
38
|
-
|
|
39
|
-
C:/Workspace/blockchain-services/packages/blockchain-service/dist/interfaces.d.ts:127:0 - warning BalanceResponse is referenced by BDSNeoLegacy.getBalance.getBalance but not included in the documentation.
|
|
40
|
-
|
|
41
|
-
127 export type BalanceResponse = {
|
|
42
|
-
|
|
43
|
-
C:/Workspace/blockchain-services/packages/blockchain-service/dist/interfaces.d.ts:113:0 - warning ContractResponse is referenced by BDSNeoLegacy.getContract.getContract but not included in the documentation.
|
|
44
|
-
|
|
45
|
-
113 export type ContractResponse = {
|
|
46
|
-
|
|
47
|
-
C:/Workspace/blockchain-services/packages/blockchain-service/dist/interfaces.d.ts:105:0 - warning TransactionHistoryResponse is referenced by BDSNeoLegacy.getHistoryTransactions.getHistoryTransactions but not included in the documentation.
|
|
48
|
-
|
|
49
|
-
105 export type TransactionHistoryResponse = {
|
|
50
|
-
|
|
51
|
-
C:/Workspace/blockchain-services/packages/blockchain-service/dist/interfaces.d.ts:122:0 - warning TokenInfoResponse is referenced by BDSNeoLegacy.getTokenInfo.getTokenInfo but not included in the documentation.
|
|
52
|
-
|
|
53
|
-
122 export type TokenInfoResponse = {
|
|
54
|
-
|
|
55
|
-
C:/Workspace/blockchain-services/packages/blockchain-service/dist/interfaces.d.ts:84:0 - warning TransactionResponse is referenced by BDSNeoLegacy.getTransaction.getTransaction but not included in the documentation.
|
|
56
|
-
|
|
57
|
-
84 export type TransactionResponse = {
|
|
58
|
-
|
|
59
|
-
C:/Workspace/blockchain-services/packages/blockchain-service/dist/interfaces.d.ts:133:0 - warning UnclaimedResponse is referenced by BDSNeoLegacy.getUnclaimed.getUnclaimed but not included in the documentation.
|
|
60
|
-
|
|
61
|
-
133 export type UnclaimedResponse = {
|
|
62
|
-
|
|
63
|
-
C:/Workspace/blockchain-services/packages/blockchain-service/dist/interfaces.d.ts:56:0 - warning CalculateTransferFeeResponse is referenced by BSNeoLegacy.calculateTransferFee.calculateTransferFee but not included in the documentation.
|
|
64
|
-
|
|
65
|
-
56 export type CalculateTransferFeeResponse = {
|
|
66
|
-
|
|
67
|
-
C:/Workspace/blockchain-services/packages/blockchain-service/dist/interfaces.d.ts:25:0 - warning ClaimResponse is referenced by BSNeoLegacy.claim.claim but not included in the documentation.
|
|
68
|
-
|
|
69
|
-
25 export type ClaimResponse = {
|
|
70
|
-
|
|
71
|
-
C:/Workspace/blockchain-services/packages/blockchain-service/dist/interfaces.d.ts:52:0 - warning Account is referenced by BSNeoLegacy.decryptKey.decryptKey but not included in the documentation.
|
|
72
|
-
|
|
73
|
-
52 export type Account = {
|
|
74
|
-
|
|
75
|
-
./src/BSNeoLegacy.ts:149:8 - warning TransactionIntentResponse is referenced by BSNeoLegacy.setTypeIntents.setTypeIntents but not included in the documentation.
|
|
76
|
-
|
|
77
|
-
149 type TransactionIntentResponse = IntentTransactionParam & { type: 'native' | 'nep5' }
|
|
78
|
-
|
|
79
|
-
C:/Workspace/blockchain-services/packages/blockchain-service/dist/interfaces.d.ts:6:0 - warning IntentTransactionParam is referenced by BSNeoLegacy.buildNativeTransaction.buildNativeTransaction.transactionIntents but not included in the documentation.
|
|
80
|
-
|
|
81
|
-
6 export type IntentTransactionParam = {
|
|
82
|
-
|
|
83
|
-
C:/Workspace/blockchain-services/packages/blockchain-service/dist/interfaces.d.ts:1:0 - warning SendTransactionParam is referenced by BSNeoLegacy.sendTransaction.sendTransaction.param but not included in the documentation.
|
|
84
|
-
|
|
85
|
-
1 export type SendTransactionParam = {
|
|
86
|
-
|
|
87
|
-
Documentation generated at ./docs
|
package/dist/BSNeoLegacy.d.ts
CHANGED
|
@@ -1,26 +1,23 @@
|
|
|
1
|
-
import { Account, BDSClaimable, BlockchainDataService, BlockchainService,
|
|
2
|
-
export declare class BSNeoLegacy<BSCustomName extends string = string> implements BlockchainService,
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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;
|
|
8
10
|
tokens: Token[];
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
constructor(blockchainName: BSCustomName);
|
|
11
|
+
network: Network;
|
|
12
|
+
legacyNetwork: string;
|
|
13
|
+
constructor(blockchainName: BSCustomName, network: PartialBy<Network, 'url'>);
|
|
14
|
+
setNetwork(param: PartialBy<Network, 'url'>): void;
|
|
12
15
|
validateAddress(address: string): boolean;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
sendTransaction(param: SendTransactionParam): Promise<string>;
|
|
21
|
-
claim(account: Account): Promise<ClaimResponse>;
|
|
22
|
-
private buildNativeTransaction;
|
|
23
|
-
private buildNep5Transaction;
|
|
24
|
-
private setTypeIntents;
|
|
25
|
-
private isNativeTransaction;
|
|
16
|
+
validateEncrypted(key: string): boolean;
|
|
17
|
+
validateKey(key: string): boolean;
|
|
18
|
+
generateAccountFromMnemonic(mnemonic: string[] | string, index: number): AccountWithDerivationPath;
|
|
19
|
+
generateAccountFromKey(key: string): Account;
|
|
20
|
+
decrypt(encryptedKey: string, password: string): Promise<Account>;
|
|
21
|
+
transfer({ intent: transferIntent, senderAccount, tipIntent, ...params }: TransferParam): Promise<string>;
|
|
22
|
+
claim(account: Account): Promise<string>;
|
|
26
23
|
}
|
package/dist/BSNeoLegacy.js
CHANGED
|
@@ -19,170 +19,153 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
19
19
|
}
|
|
20
20
|
return t;
|
|
21
21
|
};
|
|
22
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
23
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
|
-
};
|
|
25
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
23
|
exports.BSNeoLegacy = void 0;
|
|
27
|
-
const blockchain_service_1 = require("@cityofzion/blockchain-service");
|
|
28
24
|
const neon_js_1 = require("@cityofzion/neon-js");
|
|
29
|
-
const explorer_1 = require("./explorer");
|
|
30
25
|
const constants_1 = require("./constants");
|
|
31
|
-
const
|
|
32
|
-
const
|
|
26
|
+
const DoraBDSNeoLegacy_1 = require("./DoraBDSNeoLegacy");
|
|
27
|
+
const CryptoCompareEDSNeoLegacy_1 = require("./CryptoCompareEDSNeoLegacy");
|
|
28
|
+
const bs_asteroid_sdk_1 = require("@cityofzion/bs-asteroid-sdk");
|
|
33
29
|
class BSNeoLegacy {
|
|
34
|
-
constructor(blockchainName) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
this.tokens = tokens_json_1.default;
|
|
38
|
-
this.nativeAssets = constants_1.nativeAssetsNeoLegacy;
|
|
39
|
-
this.derivationPath = "m/44'/888'/0'/0/?";
|
|
30
|
+
constructor(blockchainName, network) {
|
|
31
|
+
if (network.type === 'custom')
|
|
32
|
+
throw new Error('Custom network is not supported for NEO Legacy');
|
|
40
33
|
this.blockchainName = blockchainName;
|
|
34
|
+
this.legacyNetwork = constants_1.LEGACY_NETWORK_BY_NETWORK_TYPE[network.type];
|
|
35
|
+
this.derivationPath = constants_1.DERIVATION_PATH;
|
|
36
|
+
this.tokens = constants_1.TOKENS[network.type];
|
|
37
|
+
this.claimToken = this.tokens.find(token => token.symbol === 'GAS');
|
|
38
|
+
this.burnToken = this.tokens.find(token => token.symbol === 'NEO');
|
|
39
|
+
this.feeToken = this.tokens.find(token => token.symbol === 'GAS');
|
|
40
|
+
this.setNetwork(network);
|
|
41
|
+
}
|
|
42
|
+
setNetwork(param) {
|
|
43
|
+
var _a;
|
|
44
|
+
if (param.type === 'custom')
|
|
45
|
+
throw new Error('Custom network is not supported for NEO Legacy');
|
|
46
|
+
const network = {
|
|
47
|
+
type: param.type,
|
|
48
|
+
url: (_a = param.url) !== null && _a !== void 0 ? _a : constants_1.DEFAULT_URL_BY_NETWORK_TYPE[param.type],
|
|
49
|
+
};
|
|
50
|
+
this.network = network;
|
|
51
|
+
this.blockchainDataService = new DoraBDSNeoLegacy_1.DoraBDSNeoLegacy(network, this.feeToken, this.claimToken);
|
|
52
|
+
this.exchangeDataService = new CryptoCompareEDSNeoLegacy_1.CryptoCompareEDSNeoLegacy(network.type);
|
|
41
53
|
}
|
|
42
54
|
validateAddress(address) {
|
|
43
55
|
return neon_js_1.wallet.isAddress(address);
|
|
44
56
|
}
|
|
45
|
-
|
|
46
|
-
return neon_js_1.wallet.isNEP2(
|
|
57
|
+
validateEncrypted(key) {
|
|
58
|
+
return neon_js_1.wallet.isNEP2(key);
|
|
47
59
|
}
|
|
48
|
-
|
|
49
|
-
return neon_js_1.wallet.isWIF(
|
|
60
|
+
validateKey(key) {
|
|
61
|
+
return neon_js_1.wallet.isWIF(key) || neon_js_1.wallet.isPrivateKey(key);
|
|
50
62
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
63
|
+
generateAccountFromMnemonic(mnemonic, index) {
|
|
64
|
+
bs_asteroid_sdk_1.keychain.importMnemonic(Array.isArray(mnemonic) ? mnemonic.join(' ') : mnemonic);
|
|
65
|
+
const path = this.derivationPath.replace('?', index.toString());
|
|
66
|
+
const childKey = bs_asteroid_sdk_1.keychain.generateChildKey('neo', path);
|
|
67
|
+
const key = childKey.getWIF();
|
|
68
|
+
const { address } = new neon_js_1.wallet.Account(key);
|
|
69
|
+
return { address, key, type: 'wif', derivationPath: path };
|
|
56
70
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
const { address } = new neon_js_1.wallet.Account(
|
|
62
|
-
return { address,
|
|
71
|
+
generateAccountFromKey(key) {
|
|
72
|
+
const type = neon_js_1.wallet.isWIF(key) ? 'wif' : neon_js_1.wallet.isPrivateKey(key) ? 'privateKey' : undefined;
|
|
73
|
+
if (!type)
|
|
74
|
+
throw new Error('Invalid key');
|
|
75
|
+
const { address } = new neon_js_1.wallet.Account(key);
|
|
76
|
+
return { address, key, type };
|
|
63
77
|
}
|
|
64
|
-
|
|
65
|
-
const { address } = new neon_js_1.wallet.Account(wif);
|
|
66
|
-
return { address, wif };
|
|
67
|
-
}
|
|
68
|
-
decryptKey(encryptedKey, password) {
|
|
78
|
+
decrypt(encryptedKey, password) {
|
|
69
79
|
return __awaiter(this, void 0, void 0, function* () {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
80
|
+
let BsReactNativeDecrypt;
|
|
81
|
+
try {
|
|
82
|
+
const { NativeModules } = require('react-native');
|
|
83
|
+
BsReactNativeDecrypt = NativeModules.BsReactNativeDecrypt;
|
|
84
|
+
}
|
|
85
|
+
catch (_a) {
|
|
86
|
+
const key = yield neon_js_1.wallet.decrypt(encryptedKey, password);
|
|
87
|
+
return this.generateAccountFromKey(key);
|
|
88
|
+
}
|
|
89
|
+
if (!BsReactNativeDecrypt) {
|
|
90
|
+
throw new Error('@CityOfZion/bs-react-native-decrypt is not installed');
|
|
91
|
+
}
|
|
92
|
+
const privateKey = yield BsReactNativeDecrypt.decryptNeoLegacy(encryptedKey, password);
|
|
93
|
+
return this.generateAccountFromKey(privateKey);
|
|
74
94
|
});
|
|
75
95
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
sendTransaction(param) {
|
|
80
|
-
var _a;
|
|
96
|
+
transfer(_a) {
|
|
97
|
+
var _b, _c;
|
|
98
|
+
var { intent: transferIntent, senderAccount, tipIntent } = _a, params = __rest(_a, ["intent", "senderAccount", "tipIntent"]);
|
|
81
99
|
return __awaiter(this, void 0, void 0, function* () {
|
|
82
|
-
const
|
|
83
|
-
const
|
|
84
|
-
const
|
|
85
|
-
const
|
|
86
|
-
const
|
|
87
|
-
const
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
return neon_js_1.api.sendAsset({
|
|
95
|
-
account,
|
|
96
|
-
api: apiProvider,
|
|
97
|
-
url,
|
|
98
|
-
intents: this.buildNativeTransaction(param.transactionIntents),
|
|
99
|
-
fees: priorityFee
|
|
100
|
-
});
|
|
101
|
-
},
|
|
102
|
-
nep5: () => {
|
|
103
|
-
const extraIntentsNep5 = intentsWithTye.filter(it => it.type === 'native').map(it => {
|
|
104
|
-
const { type } = it, rest = __rest(it, ["type"]);
|
|
105
|
-
return rest;
|
|
106
|
-
});
|
|
107
|
-
return neon_js_1.api.doInvoke({
|
|
108
|
-
intents: extraIntentsNep5.length > 0 ? this.buildNativeTransaction(extraIntentsNep5) : undefined,
|
|
109
|
-
account,
|
|
110
|
-
api: apiProvider,
|
|
111
|
-
script: this.buildNep5Transaction(param.transactionIntents, param.senderAccount).str,
|
|
112
|
-
url,
|
|
113
|
-
fees: priorityFee
|
|
114
|
-
});
|
|
100
|
+
const apiProvider = new neon_js_1.api.neoCli.instance(this.network.url);
|
|
101
|
+
const account = new neon_js_1.wallet.Account(senderAccount.key);
|
|
102
|
+
const priorityFee = Number((_b = params.priorityFee) !== null && _b !== void 0 ? _b : 0);
|
|
103
|
+
const nativeIntents = [];
|
|
104
|
+
const nep5ScriptBuilder = new neon_js_1.sc.ScriptBuilder();
|
|
105
|
+
const intents = [transferIntent, ...(tipIntent ? [tipIntent] : [])];
|
|
106
|
+
for (const intent of intents) {
|
|
107
|
+
const tokenHashFixed = intent.tokenHash.replace('0x', '');
|
|
108
|
+
const nativeAsset = constants_1.NATIVE_ASSETS.find(asset => asset.hash === tokenHashFixed);
|
|
109
|
+
if (nativeAsset) {
|
|
110
|
+
nativeIntents.push(...neon_js_1.api.makeIntent({ [nativeAsset.symbol]: Number(intent.amount) }, intent.receiverAddress));
|
|
111
|
+
continue;
|
|
115
112
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
113
|
+
nep5ScriptBuilder.emitAppCall(tokenHashFixed, 'transfer', [
|
|
114
|
+
neon_js_1.u.reverseHex(neon_js_1.wallet.getScriptHashFromAddress(account.address)),
|
|
115
|
+
neon_js_1.u.reverseHex(neon_js_1.wallet.getScriptHashFromAddress(intent.receiverAddress)),
|
|
116
|
+
neon_js_1.sc.ContractParam.integer(new neon_js_1.u.Fixed8(intent.amount)
|
|
117
|
+
.div(Math.pow(10, 8 - ((_c = intent.tokenDecimals) !== null && _c !== void 0 ? _c : 8)))
|
|
118
|
+
.toRawNumber()
|
|
119
|
+
.toString()),
|
|
120
|
+
]);
|
|
121
|
+
}
|
|
122
|
+
let response;
|
|
123
|
+
if (nep5ScriptBuilder.isEmpty()) {
|
|
124
|
+
response = yield neon_js_1.api.sendAsset({
|
|
125
|
+
account,
|
|
126
|
+
api: apiProvider,
|
|
127
|
+
url: this.network.url,
|
|
128
|
+
intents: nativeIntents,
|
|
129
|
+
fees: priorityFee,
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
response = yield neon_js_1.api.doInvoke({
|
|
134
|
+
intents: nativeIntents.length > 0 ? nativeIntents : undefined,
|
|
135
|
+
account,
|
|
136
|
+
api: apiProvider,
|
|
137
|
+
script: nep5ScriptBuilder.str,
|
|
138
|
+
url: this.network.url,
|
|
139
|
+
fees: priorityFee,
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
if (!response.tx)
|
|
143
|
+
throw new Error('Failed to send transaction');
|
|
144
|
+
return response.tx.hash;
|
|
121
145
|
});
|
|
122
146
|
}
|
|
123
|
-
//Implementation Claim interface
|
|
124
147
|
claim(account) {
|
|
125
148
|
return __awaiter(this, void 0, void 0, function* () {
|
|
126
|
-
const neoAccount = new neon_js_1.wallet.Account(account.
|
|
127
|
-
const balances = yield this.
|
|
128
|
-
const neoBalance = balances.find(balance => balance.symbol === 'NEO');
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
const hasClaim = yield this.dataService.getUnclaimed(account.address);
|
|
134
|
-
if (hasClaim.unclaimed <= 0)
|
|
149
|
+
const neoAccount = new neon_js_1.wallet.Account(account.key);
|
|
150
|
+
const balances = yield this.blockchainDataService.getBalance(account.address);
|
|
151
|
+
const neoBalance = balances.find(balance => balance.token.symbol === 'NEO');
|
|
152
|
+
if (!neoBalance)
|
|
153
|
+
throw new Error('It is necessary to have NEO to claim');
|
|
154
|
+
const unclaimed = yield this.blockchainDataService.getUnclaimed(account.address);
|
|
155
|
+
if (Number(unclaimed) <= 0)
|
|
135
156
|
throw new Error(`Doesn't have gas to claim`);
|
|
136
|
-
const
|
|
137
|
-
const claims = yield
|
|
138
|
-
const
|
|
157
|
+
const apiProvider = new neon_js_1.api.neoCli.instance(this.legacyNetwork);
|
|
158
|
+
const claims = yield apiProvider.getClaims(account.address);
|
|
159
|
+
const response = yield neon_js_1.api.claimGas({
|
|
139
160
|
claims,
|
|
140
161
|
api: apiProvider,
|
|
141
162
|
account: neoAccount,
|
|
142
|
-
url
|
|
163
|
+
url: this.network.url,
|
|
143
164
|
});
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
symbol: constants_1.unclaimedTokenNeoLegacy.symbol
|
|
148
|
-
};
|
|
149
|
-
return result;
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
buildNativeTransaction(transactionIntents) {
|
|
153
|
-
let intents = [];
|
|
154
|
-
transactionIntents.forEach(transaction => {
|
|
155
|
-
const nativeAsset = this.nativeAssets.find(asset => asset.hash === transaction.tokenHash);
|
|
156
|
-
if (nativeAsset) {
|
|
157
|
-
intents = [...intents, ...neon_js_1.api.makeIntent({ [nativeAsset.symbol]: transaction.amount }, transaction.receiverAddress)];
|
|
158
|
-
}
|
|
165
|
+
if (!response.tx)
|
|
166
|
+
throw new Error('Failed to claim');
|
|
167
|
+
return response.tx.hash;
|
|
159
168
|
});
|
|
160
|
-
return intents;
|
|
161
|
-
}
|
|
162
|
-
buildNep5Transaction(transactionIntents, senderAccount) {
|
|
163
|
-
const sb = new neon_js_1.sc.ScriptBuilder();
|
|
164
|
-
transactionIntents.forEach(transaction => {
|
|
165
|
-
if (!this.isNativeTransaction(transaction)) {
|
|
166
|
-
const senderHash = neon_js_1.u.reverseHex(neon_js_1.wallet.getScriptHashFromAddress(senderAccount.address));
|
|
167
|
-
const receiveHash = neon_js_1.u.reverseHex(neon_js_1.wallet.getScriptHashFromAddress(transaction.receiverAddress));
|
|
168
|
-
const adjustedAmount = new neon_js_1.u.Fixed8(transaction.amount).toRawNumber();
|
|
169
|
-
sb.emitAppCall(transaction.tokenHash.replace('0x', ''), "transfer", [
|
|
170
|
-
senderHash,
|
|
171
|
-
receiveHash,
|
|
172
|
-
neon_js_1.sc.ContractParam.integer(adjustedAmount.toString())
|
|
173
|
-
]);
|
|
174
|
-
}
|
|
175
|
-
});
|
|
176
|
-
return sb;
|
|
177
|
-
}
|
|
178
|
-
setTypeIntents(transactionIntents) {
|
|
179
|
-
const intents = transactionIntents.map(transaction => {
|
|
180
|
-
return Object.assign(Object.assign({}, transaction), { type: this.isNativeTransaction(transaction) ? 'native' : 'nep5' });
|
|
181
|
-
});
|
|
182
|
-
return intents;
|
|
183
|
-
}
|
|
184
|
-
isNativeTransaction(transactionParam) {
|
|
185
|
-
return this.nativeAssets.some(asset => asset.hash === transactionParam.tokenHash);
|
|
186
169
|
}
|
|
187
170
|
}
|
|
188
171
|
exports.BSNeoLegacy = BSNeoLegacy;
|
|
@@ -0,0 +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
|
+
}
|
|
@@ -0,0 +1,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 tokenSymbols = constants_1.TOKENS[this.networkType].map(token => token.symbol);
|
|
28
|
+
const { data: prices } = yield this.axiosInstance.get('/data/pricemultifull', {
|
|
29
|
+
params: {
|
|
30
|
+
fsyms: tokenSymbols.join(','),
|
|
31
|
+
tsyms: currency,
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
return Object.entries(prices.RAW).map(([symbol, price]) => ({
|
|
35
|
+
symbol,
|
|
36
|
+
price: price[currency].PRICE,
|
|
37
|
+
}));
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.CryptoCompareEDSNeoLegacy = CryptoCompareEDSNeoLegacy;
|
|
@@ -0,0 +1,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
|
+
constructor(network: Network, feeToken: Token, claimToken: Token);
|
|
8
|
+
getTransaction(hash: string): Promise<TransactionResponse>;
|
|
9
|
+
getTransactionsByAddress({ address, page, }: TransactionsByAddressParams): Promise<TransactionsByAddressResponse>;
|
|
10
|
+
getContract(contractHash: string): Promise<ContractResponse>;
|
|
11
|
+
getTokenInfo(tokenHash: string): Promise<Token>;
|
|
12
|
+
getBalance(address: string): Promise<BalanceResponse[]>;
|
|
13
|
+
getUnclaimed(address: string): Promise<string>;
|
|
14
|
+
getBlockHeight(): Promise<number>;
|
|
15
|
+
}
|