@cityofzion/bs-neo3 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/operation/build/state.json +1 -1
- package/.rush/temp/package-deps_build.json +25 -0
- package/.rush/temp/shrinkwrap-deps.json +2 -2
- package/bs-neo3.build.log +1 -86
- package/dist/BSNeo3.d.ts +24 -27
- package/dist/BSNeo3.js +124 -162
- package/dist/DoraBDSNeo3.d.ts +12 -0
- package/dist/DoraBDSNeo3.js +169 -0
- package/dist/FlamingoEDSNeo3.d.ts +8 -0
- package/dist/FlamingoEDSNeo3.js +44 -0
- package/dist/GhostMarketNDSNeo3.d.ts +10 -0
- package/dist/GhostMarketNDSNeo3.js +75 -0
- package/dist/RpcBDSNeo3.d.ts +15 -0
- package/dist/RpcBDSNeo3.js +152 -0
- package/dist/assets/tokens/common.json +14 -0
- package/dist/assets/tokens/mainnet.json +116 -0
- package/dist/constants.d.ts +7 -3
- package/dist/constants.js +24 -9
- package/dist/index.d.ts +4 -2
- package/dist/index.js +4 -2
- package/docs/assets/search.js +1 -1
- package/docs/classes/BDSNeo3.html +13 -13
- package/docs/classes/BSNeo3.html +80 -36
- package/docs/interfaces/DoraNeo3Abi.html +6 -6
- package/docs/interfaces/DoraNeo3Asset.html +9 -9
- package/docs/interfaces/DoraNeo3AssetState.html +6 -6
- package/docs/interfaces/DoraNeo3Balance.html +5 -5
- package/docs/interfaces/DoraNeo3ConsensusNode.html +3 -3
- package/docs/interfaces/DoraNeo3Contract.html +8 -8
- package/docs/interfaces/DoraNeo3Event.html +3 -3
- package/docs/interfaces/DoraNeo3Features.html +1 -1
- package/docs/interfaces/DoraNeo3HistoryState.html +3 -3
- package/docs/interfaces/DoraNeo3Invocation.html +3 -3
- package/docs/interfaces/DoraNeo3Item.html +11 -11
- package/docs/interfaces/DoraNeo3Manifest.html +9 -9
- package/docs/interfaces/DoraNeo3Metadata.html +12 -12
- package/docs/interfaces/DoraNeo3Method.html +12 -12
- package/docs/interfaces/DoraNeo3Nef.html +7 -7
- package/docs/interfaces/DoraNeo3Notification.html +4 -4
- package/docs/interfaces/DoraNeo3Parameter.html +3 -3
- package/docs/interfaces/DoraNeo3Permission.html +3 -3
- package/docs/interfaces/DoraNeo3Signer.html +3 -3
- package/docs/interfaces/DoraNeo3Token.html +6 -6
- package/docs/interfaces/DoraNeo3Transaction.html +16 -16
- package/docs/interfaces/DoraNeo3TransactionHistory.html +3 -3
- package/docs/interfaces/DoraNeo3Transfer.html +9 -9
- package/docs/interfaces/DoraNeo3Witness.html +3 -3
- package/docs/variables/DORA_ASSET.html +1 -1
- package/docs/variables/DORA_BALANCE.html +1 -1
- package/docs/variables/DORA_CONTRACT.html +1 -1
- package/docs/variables/DORA_NODES.html +1 -1
- package/docs/variables/DORA_TRANSACTION.html +1 -1
- package/docs/variables/DORA_TRANSACTIONS.html +1 -1
- package/docs/variables/explorerOptions.html +1 -1
- package/docs/variables/gasInfoNeo3.html +11 -2
- package/docs/variables/neoInfoNeo3.html +11 -2
- package/jest.config.ts +13 -0
- package/jest.setup.ts +1 -0
- package/package.json +14 -6
- package/src/BSNeo3.ts +221 -221
- package/src/DoraBDSNeo3.ts +180 -0
- package/src/FlamingoEDSNeo3.ts +45 -0
- package/src/GhostMarketNDSNeo3.ts +117 -0
- package/src/RpcBDSNeo3.ts +155 -0
- package/src/__tests__/BDSNeo3.spec.ts +126 -0
- package/src/__tests__/BSNeo3.spec.ts +142 -0
- package/src/__tests__/FlamingoEDSNeo3.spec.ts +45 -0
- package/src/__tests__/GhostMarketNDSNeo3.spec.ts +43 -0
- package/src/__tests__/utils/sleep.ts +1 -0
- package/src/assets/tokens/common.json +14 -0
- package/src/assets/tokens/mainnet.json +116 -0
- package/src/constants.ts +26 -10
- package/src/index.ts +4 -2
- package/tsconfig.build.json +4 -0
- package/tsconfig.json +3 -7
- package/bs-neo3.build.error.log +0 -84
- package/dist/excpetions.d.ts +0 -3
- package/dist/excpetions.js +0 -8
- package/src/BDSNeo3.ts +0 -168
- package/src/assets/blockchain_icon_neo.png +0 -0
- package/src/assets/blockchain_icon_neo_white.png +0 -0
- package/src/assets/tokens.json +0 -129
- package/src/exceptions.ts +0 -5
- package/src/explorer/dora/DoraNeo3Responses.ts +0 -207
- package/src/explorer/dora/DoraNeo3Routes.ts +0 -6
- package/src/explorer/index.ts +0 -8
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"files": {
|
|
3
|
+
"packages/bs-neo3/jest.config.ts": "d944475db93cbe41a9339187fd94b9962e411c43",
|
|
4
|
+
"packages/bs-neo3/jest.setup.ts": "9a1976a32050616d4d2ee95b1aa21041bc4daca3",
|
|
5
|
+
"packages/bs-neo3/package.json": "ac113a1a844452f1047cb59b169bfa1cdde2c680",
|
|
6
|
+
"packages/bs-neo3/src/BSNeo3.ts": "ac98a87cfd542ac1fdd1b2166ba2acb78a274126",
|
|
7
|
+
"packages/bs-neo3/src/DoraBDSNeo3.ts": "f94ef94afe666bc0991f5dd8e880d8fec8ade099",
|
|
8
|
+
"packages/bs-neo3/src/FlamingoEDSNeo3.ts": "f5fbb9ff405b02079c31493ae251aaea5defb77d",
|
|
9
|
+
"packages/bs-neo3/src/GhostMarketNDSNeo3.ts": "d7db2a624cf099fe550fa4a906f6127ca4815cac",
|
|
10
|
+
"packages/bs-neo3/src/RpcBDSNeo3.ts": "a548f689b39b42ce00452b1fb8f772b6ebbf7683",
|
|
11
|
+
"packages/bs-neo3/src/__tests__/BDSNeo3.spec.ts": "14bd204f3d4546c81b6ea37e16f3fe6e70102dd1",
|
|
12
|
+
"packages/bs-neo3/src/__tests__/BSNeo3.spec.ts": "edf56afc2efaa15d252eaaca0325cee364191699",
|
|
13
|
+
"packages/bs-neo3/src/__tests__/FlamingoEDSNeo3.spec.ts": "17e3b6f4dee4cb2222f3b4b1aed9d9a68ea037c0",
|
|
14
|
+
"packages/bs-neo3/src/__tests__/GhostMarketNDSNeo3.spec.ts": "1d583380b60112fb99426b4bf140c92898177b1e",
|
|
15
|
+
"packages/bs-neo3/src/__tests__/utils/sleep.ts": "c1eb515dad9f5c11eef5d5e77c85db4c3c8196a8",
|
|
16
|
+
"packages/bs-neo3/src/assets/tokens/common.json": "04691656019ba9234129b749553aa75828e77ef8",
|
|
17
|
+
"packages/bs-neo3/src/assets/tokens/mainnet.json": "f43f1a67f07c0b85977cf17dae825ae7fbb8eb21",
|
|
18
|
+
"packages/bs-neo3/src/constants.ts": "233a2c83f1829629865ace6fbf9c66cd39489c51",
|
|
19
|
+
"packages/bs-neo3/src/index.ts": "bad314a9ba14b57075684c9b823a934863bac6b2",
|
|
20
|
+
"packages/bs-neo3/tsconfig.build.json": "4dc23fb9c4c5e4d19a9bc3947a47c523f4bd967c",
|
|
21
|
+
"packages/bs-neo3/tsconfig.json": "77cf2b789e9c665b62792f9992cc81ae86296ef7",
|
|
22
|
+
"common/config/rush/npm-shrinkwrap.json": "4994dce94cedd11a678400d92e08741ac7bc9d3f"
|
|
23
|
+
},
|
|
24
|
+
"arguments": "tsc --project tsconfig.build.json "
|
|
25
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
|
-
"../../packages/bs-neo3": "../../packages/bs-neo3:
|
|
3
|
-
"/@cityofzion/blockchain-service/0.3.
|
|
2
|
+
"../../packages/bs-neo3": "../../packages/bs-neo3:5AjwK6LRNSM9TOZOCykvRPdKq8cRSeT4mf6AxYY5YFU=:",
|
|
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/neo3-invoker/1.4.0": "sha512-BOqJA2e6Kq3QPL/kaMYEjpPCeh9fdKTzRjEi9oIxi0MY5B7nj4rhAVl4l2A06jGNboi+VhToo/gJ/ZVzW/GaeQ==",
|
|
6
6
|
"/@cityofzion/neo3-parser/1.6.0": "sha512-K+j3qaZEuq1cxit+fFziwAAc0hMQTdACbtllU1HUKJZ89dw7z/FY3Bmg12cyZ8tXuiktCloXvUT0Mg/IzoYqdg==",
|
package/bs-neo3.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 BDSNeo3 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 BDSNeo3 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 BSNeo3 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 BSNeo3 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:41:0 - warning NeoNameService is referenced by BSNeo3 but not included in the documentation.
|
|
20
|
-
|
|
21
|
-
41 export interface NeoNameService {
|
|
22
|
-
|
|
23
|
-
C:/Workspace/blockchain-services/packages/blockchain-service/dist/interfaces.d.ts:11:0 - warning TokenInfo is referenced by gasInfoNeo3 but not included in the documentation.
|
|
24
|
-
|
|
25
|
-
11 export type TokenInfo = {
|
|
26
|
-
|
|
27
|
-
C:/Workspace/blockchain-services/packages/blockchain-service/dist/interfaces.d.ts:126:0 - warning BlockchainNetwork is referenced by BDSNeo3.network but not included in the documentation.
|
|
28
|
-
|
|
29
|
-
126 export type BlockchainNetwork = "mainnet" | "testnet" | "privatenet";
|
|
30
|
-
|
|
31
|
-
C:/Workspace/blockchain-services/packages/blockchain-service/dist/interfaces.d.ts:156:0 - warning Exchange is referenced by BSNeo3.exchange but not included in the documentation.
|
|
32
|
-
|
|
33
|
-
156 export interface Exchange {
|
|
34
|
-
|
|
35
|
-
C:/Workspace/blockchain-services/packages/blockchain-service/dist/interfaces.d.ts:46:0 - warning Token is referenced by BSNeo3.tokens but not included in the documentation.
|
|
36
|
-
|
|
37
|
-
46 export type Token = {
|
|
38
|
-
|
|
39
|
-
C:/Workspace/blockchain-services/packages/blockchain-service/dist/interfaces.d.ts:84:0 - warning TransactionResponse is referenced by BDSNeo3.findTransactionByTxid.findTransactionByTxid but not included in the documentation.
|
|
40
|
-
|
|
41
|
-
84 export type TransactionResponse = {
|
|
42
|
-
|
|
43
|
-
C:/Workspace/blockchain-services/packages/blockchain-service/dist/interfaces.d.ts:118:0 - warning ConsensusNodeResponse is referenced by BDSNeo3.getAllNodes.getAllNodes but not included in the documentation.
|
|
44
|
-
|
|
45
|
-
118 export type ConsensusNodeResponse = {
|
|
46
|
-
|
|
47
|
-
C:/Workspace/blockchain-services/packages/blockchain-service/dist/interfaces.d.ts:127:0 - warning BalanceResponse is referenced by BDSNeo3.getBalance.getBalance but not included in the documentation.
|
|
48
|
-
|
|
49
|
-
127 export type BalanceResponse = {
|
|
50
|
-
|
|
51
|
-
C:/Workspace/blockchain-services/packages/blockchain-service/dist/interfaces.d.ts:113:0 - warning ContractResponse is referenced by BDSNeo3.getContract.getContract but not included in the documentation.
|
|
52
|
-
|
|
53
|
-
113 export type ContractResponse = {
|
|
54
|
-
|
|
55
|
-
C:/Workspace/blockchain-services/packages/blockchain-service/dist/interfaces.d.ts:105:0 - warning TransactionHistoryResponse is referenced by BDSNeo3.getHistoryTransactions.getHistoryTransactions but not included in the documentation.
|
|
56
|
-
|
|
57
|
-
105 export type TransactionHistoryResponse = {
|
|
58
|
-
|
|
59
|
-
C:/Workspace/blockchain-services/packages/blockchain-service/dist/interfaces.d.ts:122:0 - warning TokenInfoResponse is referenced by BDSNeo3.getTokenInfo.getTokenInfo but not included in the documentation.
|
|
60
|
-
|
|
61
|
-
122 export type TokenInfoResponse = {
|
|
62
|
-
|
|
63
|
-
C:/Workspace/blockchain-services/packages/blockchain-service/dist/interfaces.d.ts:133:0 - warning UnclaimedResponse is referenced by BDSNeo3.getUnclaimed.getUnclaimed but not included in the documentation.
|
|
64
|
-
|
|
65
|
-
133 export type UnclaimedResponse = {
|
|
66
|
-
|
|
67
|
-
C:/Workspace/blockchain-services/packages/blockchain-service/dist/interfaces.d.ts:56:0 - warning CalculateTransferFeeResponse is referenced by BSNeo3.calculateTransferFee.calculateTransferFee but not included in the documentation.
|
|
68
|
-
|
|
69
|
-
56 export type CalculateTransferFeeResponse = {
|
|
70
|
-
|
|
71
|
-
C:/Workspace/blockchain-services/packages/blockchain-service/dist/interfaces.d.ts:52:0 - warning Account is referenced by BSNeo3.decryptKey.decryptKey but not included in the documentation.
|
|
72
|
-
|
|
73
|
-
52 export type Account = {
|
|
74
|
-
|
|
75
|
-
C:/Workspace/blockchain-services/packages/blockchain-service/dist/interfaces.d.ts:6:0 - warning IntentTransactionParam is referenced by BSNeo3.buildTransfer.buildTransfer.transactionIntents but not included in the documentation.
|
|
76
|
-
|
|
77
|
-
6 export type IntentTransactionParam = {
|
|
78
|
-
|
|
79
|
-
C:/Workspace/blockchain-services/packages/blockchain-service/dist/interfaces.d.ts:1:0 - warning SendTransactionParam is referenced by BSNeo3.calculateTransferFee.calculateTransferFee.param but not included in the documentation.
|
|
80
|
-
|
|
81
|
-
1 export type SendTransactionParam = {
|
|
82
|
-
|
|
83
|
-
C:/Workspace/blockchain-services/packages/blockchain-service/dist/interfaces.d.ts:35:0 - warning NNSRecordTypes is referenced by BSNeo3.getNNSRecord.getNNSRecord.type but not included in the documentation.
|
|
84
|
-
|
|
85
|
-
35 export declare enum NNSRecordTypes {
|
|
86
|
-
|
|
87
|
-
Documentation generated at ./docs
|
package/dist/BSNeo3.d.ts
CHANGED
|
@@ -1,30 +1,27 @@
|
|
|
1
|
-
import { BlockchainDataService, BlockchainService,
|
|
2
|
-
export declare class BSNeo3<BSCustomName extends string = string> implements BlockchainService,
|
|
3
|
-
blockchainName: BSCustomName;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { BlockchainDataService, BlockchainService, BSClaimable, Account, ExchangeDataService, BDSClaimable, Token, BSWithNameService, Network, PartialBy, TransferParam, BSCalculableFee, NftDataService, BSWithNft, AccountWithDerivationPath } from '@cityofzion/blockchain-service';
|
|
2
|
+
export declare class BSNeo3<BSCustomName extends string = string> implements BlockchainService, BSClaimable, BSWithNameService, BSCalculableFee, BSWithNft {
|
|
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
|
+
nftDataService: NftDataService;
|
|
10
|
+
exchangeDataService: ExchangeDataService;
|
|
8
11
|
tokens: Token[];
|
|
9
|
-
|
|
10
|
-
constructor(blockchainName: BSCustomName);
|
|
12
|
+
network: Network;
|
|
13
|
+
constructor(blockchainName: BSCustomName, network: PartialBy<Network, 'url'>);
|
|
14
|
+
setNetwork(param: PartialBy<Network, 'url'>): void;
|
|
11
15
|
validateAddress(address: string): boolean;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
symbol: string;
|
|
24
|
-
hash: string;
|
|
25
|
-
}>;
|
|
26
|
-
getNNSRecord(domainName: string, type: NNSRecordTypes): Promise<any>;
|
|
27
|
-
getOwnerOfNNS(domainName: string): Promise<any>;
|
|
28
|
-
private buildTransfer;
|
|
29
|
-
private signTransfer;
|
|
16
|
+
validateEncrypted(encryptedKey: string): boolean;
|
|
17
|
+
validateKey(key: string): boolean;
|
|
18
|
+
validateNameServiceDomainFormat(domainName: string): boolean;
|
|
19
|
+
generateAccountFromMnemonic(mnemonic: string[] | string, index: number): AccountWithDerivationPath;
|
|
20
|
+
generateAccountFromKey(key: string): Account;
|
|
21
|
+
decrypt(encryptedKey: string, password: string): Promise<Account>;
|
|
22
|
+
calculateTransferFee(param: TransferParam): Promise<string>;
|
|
23
|
+
transfer(param: TransferParam): Promise<string>;
|
|
24
|
+
claim(account: Account): Promise<string>;
|
|
25
|
+
resolveNameServiceDomain(domainName: string): Promise<any>;
|
|
26
|
+
private buildTransferInvocation;
|
|
30
27
|
}
|
package/dist/BSNeo3.js
CHANGED
|
@@ -8,213 +8,175 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
12
|
exports.BSNeo3 = void 0;
|
|
16
|
-
const blockchain_service_1 = require("@cityofzion/blockchain-service");
|
|
17
13
|
const neon_js_1 = require("@cityofzion/neon-js");
|
|
18
|
-
const constants_1 = require("./constants");
|
|
19
|
-
const exceptions_1 = require("./exceptions");
|
|
20
|
-
const explorer_1 = require("./explorer");
|
|
21
|
-
const tokens_json_1 = __importDefault(require("./assets/tokens.json"));
|
|
22
14
|
const neon_invoker_1 = require("@cityofzion/neon-invoker");
|
|
23
15
|
const neon_parser_1 = require("@cityofzion/neon-parser");
|
|
24
16
|
const neo3_parser_1 = require("@cityofzion/neo3-parser");
|
|
25
|
-
const
|
|
17
|
+
const RpcBDSNeo3_1 = require("./RpcBDSNeo3");
|
|
18
|
+
const DoraBDSNeo3_1 = require("./DoraBDSNeo3");
|
|
19
|
+
const constants_1 = require("./constants");
|
|
20
|
+
const FlamingoEDSNeo3_1 = require("./FlamingoEDSNeo3");
|
|
21
|
+
const GhostMarketNDSNeo3_1 = require("./GhostMarketNDSNeo3");
|
|
22
|
+
const bs_asteroid_sdk_1 = require("@cityofzion/bs-asteroid-sdk");
|
|
26
23
|
class BSNeo3 {
|
|
27
|
-
constructor(blockchainName) {
|
|
28
|
-
this.dataService = explorer_1.explorerOptions.dora;
|
|
29
|
-
this.feeToken = constants_1.gasInfoNeo3;
|
|
30
|
-
this.exchange = blockchain_service_1.exchangeOptions.flamingo;
|
|
31
|
-
this.tokenClaim = constants_1.neoInfoNeo3;
|
|
32
|
-
this.tokens = tokens_json_1.default;
|
|
33
|
-
this.derivationPath = "m/44'/888'/0'/0/?";
|
|
24
|
+
constructor(blockchainName, network) {
|
|
34
25
|
this.blockchainName = blockchainName;
|
|
26
|
+
this.tokens = constants_1.TOKENS[network.type];
|
|
27
|
+
this.derivationPath = constants_1.DERIVATION_PATH;
|
|
28
|
+
this.feeToken = this.tokens.find(token => token.symbol === 'GAS');
|
|
29
|
+
this.burnToken = this.tokens.find(token => token.symbol === 'NEO');
|
|
30
|
+
this.claimToken = this.tokens.find(token => token.symbol === 'GAS');
|
|
31
|
+
this.setNetwork(network);
|
|
32
|
+
}
|
|
33
|
+
setNetwork(param) {
|
|
34
|
+
var _a;
|
|
35
|
+
const network = {
|
|
36
|
+
type: param.type,
|
|
37
|
+
url: (_a = param.url) !== null && _a !== void 0 ? _a : constants_1.DEFAULT_URL_BY_NETWORK_TYPE[param.type],
|
|
38
|
+
};
|
|
39
|
+
this.network = network;
|
|
40
|
+
if (network.type === 'custom') {
|
|
41
|
+
this.blockchainDataService = new RpcBDSNeo3_1.RPCBDSNeo3(network, this.feeToken, this.claimToken);
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
this.blockchainDataService = new DoraBDSNeo3_1.DoraBDSNeo3(network, this.feeToken, this.claimToken);
|
|
45
|
+
}
|
|
46
|
+
this.exchangeDataService = new FlamingoEDSNeo3_1.FlamingoEDSNeo3(network.type);
|
|
47
|
+
this.nftDataService = new GhostMarketNDSNeo3_1.GhostMarketNDSNeo3(network.type);
|
|
35
48
|
}
|
|
36
49
|
validateAddress(address) {
|
|
37
50
|
return neon_js_1.wallet.isAddress(address, 53);
|
|
38
51
|
}
|
|
39
|
-
|
|
52
|
+
validateEncrypted(encryptedKey) {
|
|
40
53
|
return neon_js_1.wallet.isNEP2(encryptedKey);
|
|
41
54
|
}
|
|
42
|
-
|
|
43
|
-
return neon_js_1.wallet.isWIF(
|
|
55
|
+
validateKey(key) {
|
|
56
|
+
return neon_js_1.wallet.isWIF(key) || neon_js_1.wallet.isPrivateKey(key);
|
|
44
57
|
}
|
|
45
|
-
|
|
58
|
+
validateNameServiceDomainFormat(domainName) {
|
|
46
59
|
if (!domainName.endsWith('.neo'))
|
|
47
60
|
return false;
|
|
48
61
|
return true;
|
|
49
62
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
decryptKey(encryptedKey, password) {
|
|
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 };
|
|
70
|
+
}
|
|
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 };
|
|
77
|
+
}
|
|
78
|
+
decrypt(encryptedKey, password) {
|
|
68
79
|
return __awaiter(this, void 0, void 0, function* () {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
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.decryptNeo3(encryptedKey, password);
|
|
93
|
+
return this.generateAccountFromKey(privateKey);
|
|
72
94
|
});
|
|
73
95
|
}
|
|
74
96
|
calculateTransferFee(param) {
|
|
75
97
|
return __awaiter(this, void 0, void 0, function* () {
|
|
76
|
-
const
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
const txn = txBuilder.build();
|
|
89
|
-
const accountScriptHash = neon_js_1.wallet.getScriptHashFromAddress(param.senderAccount.address);
|
|
90
|
-
const invokeFunctionResponse = yield rpcClient.invokeScript(neon_js_1.u.HexString.fromHex(txn.script), [
|
|
91
|
-
{
|
|
92
|
-
account: accountScriptHash,
|
|
93
|
-
scopes: String(neon_js_1.tx.WitnessScope.CalledByEntry)
|
|
94
|
-
}
|
|
95
|
-
]);
|
|
96
|
-
const systemFee = neon_js_1.u.BigInteger.fromNumber(invokeFunctionResponse.gasconsumed).toDecimal(constants_1.gasInfoNeo3.decimals);
|
|
97
|
-
const networkFeeResponse = yield rpcClient.calculateNetworkFee(txn);
|
|
98
|
-
const networkFee = (Number(networkFeeResponse) / Math.pow(10, constants_1.gasInfoNeo3.decimals));
|
|
99
|
-
const sumFee = Number(systemFee) + networkFee;
|
|
100
|
-
const result = {
|
|
101
|
-
result: sumFee,
|
|
102
|
-
details: {
|
|
103
|
-
networkFee: networkFee.toString(),
|
|
104
|
-
systemFee
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
return result;
|
|
98
|
+
const account = new neon_js_1.wallet.Account(param.senderAccount.key);
|
|
99
|
+
const invoker = yield neon_invoker_1.NeonInvoker.init({
|
|
100
|
+
rpcAddress: this.network.url,
|
|
101
|
+
account,
|
|
102
|
+
});
|
|
103
|
+
const invocations = this.buildTransferInvocation(param, account);
|
|
104
|
+
const { networkFee, systemFee } = yield invoker.calculateFee({
|
|
105
|
+
invocations,
|
|
106
|
+
signers: [],
|
|
107
|
+
});
|
|
108
|
+
return networkFee.add(systemFee).toDecimal(this.feeToken.decimals);
|
|
108
109
|
});
|
|
109
110
|
}
|
|
110
|
-
|
|
111
|
+
transfer(param) {
|
|
111
112
|
return __awaiter(this, void 0, void 0, function* () {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}
|
|
113
|
+
const account = new neon_js_1.wallet.Account(param.senderAccount.key);
|
|
114
|
+
const invoker = yield neon_invoker_1.NeonInvoker.init({
|
|
115
|
+
rpcAddress: this.network.url,
|
|
116
|
+
account,
|
|
117
|
+
});
|
|
118
|
+
const invocations = this.buildTransferInvocation(param, account);
|
|
119
|
+
const transactionHash = yield invoker.invokeFunction({
|
|
120
|
+
invocations,
|
|
121
|
+
signers: [],
|
|
122
|
+
});
|
|
123
|
+
return transactionHash;
|
|
124
124
|
});
|
|
125
125
|
}
|
|
126
|
-
//Claimable interface implementation
|
|
127
126
|
claim(account) {
|
|
128
127
|
return __awaiter(this, void 0, void 0, function* () {
|
|
129
|
-
const
|
|
130
|
-
const
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
const neoAccount = new neon_js_1.wallet.Account(account.wif);
|
|
134
|
-
if (!neoBalance || !gasBalance)
|
|
135
|
-
throw new Error(`Problem to claim`);
|
|
136
|
-
const dataToClaim = {
|
|
137
|
-
transactionIntents: [{ amount: neoBalance.amount, receiverAddress: account.address, tokenHash: neoBalance.hash }],
|
|
138
|
-
senderAccount: account
|
|
139
|
-
};
|
|
140
|
-
const feeToClaim = yield this.calculateTransferFee(dataToClaim);
|
|
141
|
-
if (gasBalance.amount < feeToClaim.result) {
|
|
142
|
-
exceptions_1.claimGasExceptions.InsuficientGas(String(gasBalance.amount), String(feeToClaim.result));
|
|
143
|
-
}
|
|
144
|
-
const url = (yield this.dataService.getHigherNode()).url;
|
|
145
|
-
const facade = yield neon_js_1.api.NetworkFacade.fromConfig({ node: url });
|
|
146
|
-
const signing = this.signTransfer(account);
|
|
147
|
-
const txid = yield facade.claimGas(neoAccount, signing);
|
|
148
|
-
const result = {
|
|
149
|
-
hash: constants_1.gasInfoNeo3.hash,
|
|
150
|
-
symbol: constants_1.gasInfoNeo3.symbol,
|
|
151
|
-
txid
|
|
152
|
-
};
|
|
153
|
-
return result;
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
// Gets the record of a second-level domain or its subdomains with the specific type.
|
|
157
|
-
getNNSRecord(domainName, type) {
|
|
158
|
-
var _a;
|
|
159
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
160
|
-
const higherNode = yield this.dataService.getHigherNode();
|
|
161
|
-
const parser = neon_parser_1.NeonParser;
|
|
162
|
-
const invoker = yield neon_invoker_1.NeonInvoker.init(higherNode.url);
|
|
163
|
-
const response = yield invoker.testInvoke({
|
|
164
|
-
invocations: [{
|
|
165
|
-
scriptHash: NEO_NS_HASH,
|
|
166
|
-
operation: "getRecord",
|
|
167
|
-
args: [{ type: "String", value: domainName }, { type: "Integer", value: type }]
|
|
168
|
-
}]
|
|
128
|
+
const neoAccount = new neon_js_1.wallet.Account(account.key);
|
|
129
|
+
const facade = yield neon_js_1.api.NetworkFacade.fromConfig({ node: this.network.url });
|
|
130
|
+
const transactionHash = yield facade.claimGas(neoAccount, {
|
|
131
|
+
signingCallback: neon_js_1.api.signWithAccount(neoAccount),
|
|
169
132
|
});
|
|
170
|
-
|
|
171
|
-
throw new Error((_a = response.exception) !== null && _a !== void 0 ? _a : 'unrecognized response');
|
|
172
|
-
}
|
|
173
|
-
const parsed = parser.parseRpcResponse(response.stack[0]);
|
|
174
|
-
return parsed;
|
|
133
|
+
return transactionHash;
|
|
175
134
|
});
|
|
176
135
|
}
|
|
177
|
-
|
|
136
|
+
resolveNameServiceDomain(domainName) {
|
|
178
137
|
var _a;
|
|
179
138
|
return __awaiter(this, void 0, void 0, function* () {
|
|
180
|
-
const higherNode = yield this.dataService.getHigherNode();
|
|
181
139
|
const parser = neon_parser_1.NeonParser;
|
|
182
|
-
const invoker = yield neon_invoker_1.NeonInvoker.init(
|
|
140
|
+
const invoker = yield neon_invoker_1.NeonInvoker.init({ rpcAddress: this.network.url });
|
|
183
141
|
const response = yield invoker.testInvoke({
|
|
184
|
-
invocations: [
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
142
|
+
invocations: [
|
|
143
|
+
{
|
|
144
|
+
scriptHash: constants_1.NEO_NS_HASH,
|
|
145
|
+
operation: 'ownerOf',
|
|
146
|
+
args: [{ type: 'String', value: domainName }],
|
|
147
|
+
},
|
|
148
|
+
],
|
|
189
149
|
});
|
|
190
150
|
if (response.stack.length === 0) {
|
|
191
151
|
throw new Error((_a = response.exception) !== null && _a !== void 0 ? _a : 'unrecognized response');
|
|
192
152
|
}
|
|
193
|
-
const parsed = parser.parseRpcResponse(response.stack[0], {
|
|
194
|
-
|
|
153
|
+
const parsed = parser.parseRpcResponse(response.stack[0], {
|
|
154
|
+
type: neo3_parser_1.ABI_TYPES.HASH160.name,
|
|
155
|
+
});
|
|
156
|
+
const address = parser.accountInputToAddress(parsed.replace('0x', ''));
|
|
195
157
|
return address;
|
|
196
158
|
});
|
|
197
159
|
}
|
|
198
|
-
|
|
199
|
-
const intents = [];
|
|
200
|
-
const
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
};
|
|
217
|
-
return
|
|
160
|
+
buildTransferInvocation({ intent, tipIntent }, account) {
|
|
161
|
+
const intents = [intent, ...(tipIntent ? [tipIntent] : [])];
|
|
162
|
+
const invocations = intents.map(intent => {
|
|
163
|
+
return {
|
|
164
|
+
operation: 'transfer',
|
|
165
|
+
scriptHash: intent.tokenHash,
|
|
166
|
+
args: [
|
|
167
|
+
{ type: 'Hash160', value: account.address },
|
|
168
|
+
{ type: 'Hash160', value: intent.receiverAddress },
|
|
169
|
+
{
|
|
170
|
+
type: 'Integer',
|
|
171
|
+
value: intent.tokenDecimals
|
|
172
|
+
? neon_js_1.u.BigInteger.fromDecimal(intent.amount, intent.tokenDecimals).toString()
|
|
173
|
+
: intent.amount,
|
|
174
|
+
},
|
|
175
|
+
{ type: 'Any', value: '' },
|
|
176
|
+
],
|
|
177
|
+
};
|
|
178
|
+
});
|
|
179
|
+
return invocations;
|
|
218
180
|
}
|
|
219
181
|
}
|
|
220
182
|
exports.BSNeo3 = BSNeo3;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { BalanceResponse, ContractResponse, TransactionsByAddressParams, TransactionsByAddressResponse, TransactionResponse, Network, Token } from '@cityofzion/blockchain-service';
|
|
2
|
+
import { RPCBDSNeo3 } from './RpcBDSNeo3';
|
|
3
|
+
export declare class DoraBDSNeo3 extends RPCBDSNeo3 {
|
|
4
|
+
readonly network: Network;
|
|
5
|
+
constructor(network: Network, feeToken: Token, claimToken: Token);
|
|
6
|
+
getTransaction(hash: string): Promise<TransactionResponse>;
|
|
7
|
+
getTransactionsByAddress({ address, page, }: TransactionsByAddressParams): Promise<TransactionsByAddressResponse>;
|
|
8
|
+
getContract(contractHash: string): Promise<ContractResponse>;
|
|
9
|
+
getTokenInfo(tokenHash: string): Promise<Token>;
|
|
10
|
+
getBalance(address: string): Promise<BalanceResponse[]>;
|
|
11
|
+
private convertByteStringToAddress;
|
|
12
|
+
}
|