@cityofzion/bs-neo3 1.16.2 → 1.16.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/BSNeo3.d.ts +39 -30
- package/dist/BSNeo3.js +102 -54
- package/dist/constants/BSNeo3Constants.d.ts +12 -17
- package/dist/constants/BSNeo3Constants.js +221 -37
- package/dist/helpers/BSNeo3Helper.d.ts +5 -6
- package/dist/helpers/BSNeo3Helper.js +9 -8
- package/dist/helpers/BSNeo3NeonDappKitSingletonHelper.d.ts +6 -0
- package/dist/helpers/BSNeo3NeonDappKitSingletonHelper.js +26 -0
- package/dist/helpers/BSNeo3NeonJsSingletonHelper.d.ts +7 -0
- package/dist/helpers/BSNeo3NeonJsSingletonHelper.js +26 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.js +3 -2
- package/dist/services/blockchain-data/DoraBDSNeo3.d.ts +13 -12
- package/dist/services/blockchain-data/DoraBDSNeo3.js +130 -140
- package/dist/services/blockchain-data/RpcBDSNeo3.d.ts +13 -19
- package/dist/services/blockchain-data/RpcBDSNeo3.js +28 -62
- package/dist/services/chaim-data/RpcCDSNeo3.d.ts +7 -0
- package/dist/services/chaim-data/RpcCDSNeo3.js +27 -0
- package/dist/services/exchange-data/FlamingoForthewinEDSNeo3.d.ts +6 -7
- package/dist/services/exchange-data/FlamingoForthewinEDSNeo3.js +4 -19
- package/dist/services/explorer/DoraESNeo3.d.ts +5 -5
- package/dist/services/explorer/DoraESNeo3.js +19 -22
- package/dist/services/ledger/NeonDappKitLedgerServiceNeo3.d.ts +10 -10
- package/dist/services/ledger/NeonDappKitLedgerServiceNeo3.js +28 -38
- package/dist/services/neo3neoXBridge/Neo3NeoXBridgeService.d.ts +10 -9
- package/dist/services/neo3neoXBridge/Neo3NeoXBridgeService.js +26 -25
- package/dist/services/nft-data/GhostMarketNDSNeo3.d.ts +7 -11
- package/dist/services/nft-data/GhostMarketNDSNeo3.js +41 -79
- package/dist/services/vote/DoraVoteServiceNeo3.d.ts +8 -29
- package/dist/services/vote/DoraVoteServiceNeo3.js +81 -21
- package/dist/types.d.ts +84 -0
- package/dist/types.js +18 -0
- package/package.json +25 -25
- package/dist/assets/tokens/mainnet.json +0 -194
- package/dist/assets/tokens/native.json +0 -14
- package/dist/builder/invocation/NeonDappKitInvocationBuilderNeo3.d.ts +0 -34
- package/dist/builder/invocation/NeonDappKitInvocationBuilderNeo3.js +0 -102
- package/dist/interfaces.d.ts +0 -41
- package/dist/interfaces.js +0 -2
- package/dist/services/nft-data/RpcNDSNeo3.d.ts +0 -9
- package/dist/services/nft-data/RpcNDSNeo3.js +0 -59
- package/dist/services/vote/RpcVoteServiceNeo3.d.ts +0 -10
- package/dist/services/vote/RpcVoteServiceNeo3.js +0 -88
package/dist/BSNeo3.d.ts
CHANGED
|
@@ -1,40 +1,49 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TBSAccount, TGetLedgerTransport, IBlockchainDataService, IClaimDataService, IExchangeDataService, IExplorerService, INeo3NeoXBridgeService, INftDataService, ITokenService, TBSNetwork, TBSToken, TTransferParam, TPingNetworkResponse } from '@cityofzion/blockchain-service';
|
|
2
2
|
import { NeonDappKitLedgerServiceNeo3 } from './services/ledger/NeonDappKitLedgerServiceNeo3';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
export declare class BSNeo3<
|
|
3
|
+
import { IBSNeo3, IVoteService, TBSNeo3NetworkId } from './types';
|
|
4
|
+
import { api, wallet } from './helpers/BSNeo3NeonJsSingletonHelper';
|
|
5
|
+
export declare class BSNeo3<N extends string = string> implements IBSNeo3<N> {
|
|
6
6
|
#private;
|
|
7
|
-
name:
|
|
8
|
-
bip44DerivationPath: string;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
7
|
+
readonly name: N;
|
|
8
|
+
readonly bip44DerivationPath: string;
|
|
9
|
+
readonly isMultiTransferSupported = true;
|
|
10
|
+
readonly isCustomNetworkSupported = true;
|
|
11
|
+
tokens: TBSToken[];
|
|
12
|
+
readonly nativeTokens: TBSToken[];
|
|
13
|
+
readonly feeToken: TBSToken;
|
|
14
|
+
readonly claimToken: TBSToken;
|
|
15
|
+
readonly burnToken: TBSToken;
|
|
16
|
+
network: TBSNetwork<TBSNeo3NetworkId>;
|
|
17
|
+
availableNetworkURLs: string[];
|
|
18
|
+
readonly defaultNetwork: TBSNetwork<TBSNeo3NetworkId>;
|
|
19
|
+
readonly availableNetworks: TBSNetwork<TBSNeo3NetworkId>[];
|
|
20
|
+
blockchainDataService: IBlockchainDataService;
|
|
21
|
+
nftDataService: INftDataService;
|
|
22
|
+
ledgerService: NeonDappKitLedgerServiceNeo3<N>;
|
|
23
|
+
exchangeDataService: IExchangeDataService;
|
|
24
|
+
explorerService: IExplorerService;
|
|
25
|
+
voteService: IVoteService<N>;
|
|
26
|
+
neo3NeoXBridgeService: INeo3NeoXBridgeService<N>;
|
|
21
27
|
tokenService: ITokenService;
|
|
22
|
-
|
|
23
|
-
constructor(name:
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
28
|
+
claimDataService: IClaimDataService;
|
|
29
|
+
constructor(name: N, network?: TBSNetwork<TBSNeo3NetworkId>, getLedgerTransport?: TGetLedgerTransport<N>);
|
|
30
|
+
setNetwork(network: TBSNetwork<TBSNeo3NetworkId>): void;
|
|
31
|
+
pingNetwork(network: TBSNetwork<TBSNeo3NetworkId>): Promise<TPingNetworkResponse>;
|
|
32
|
+
generateSigningCallback(account: TBSAccount<N>): Promise<{
|
|
33
|
+
neonJsAccount: wallet.Account;
|
|
34
|
+
signingCallback: api.SigningFunction;
|
|
35
|
+
}>;
|
|
27
36
|
validateAddress(address: string): boolean;
|
|
28
37
|
validateEncrypted(encryptedKey: string): boolean;
|
|
29
38
|
validateKey(key: string): boolean;
|
|
30
39
|
validateNameServiceDomainFormat(domainName: string): boolean;
|
|
31
|
-
generateAccountFromMnemonic(mnemonic: string[] | string, index: number):
|
|
32
|
-
generateAccountFromPublicKey(publicKey: string):
|
|
33
|
-
generateAccountFromKey(key: string):
|
|
34
|
-
decrypt(encryptedKey: string, password: string): Promise<
|
|
40
|
+
generateAccountFromMnemonic(mnemonic: string[] | string, index: number): TBSAccount<N>;
|
|
41
|
+
generateAccountFromPublicKey(publicKey: string): TBSAccount<N>;
|
|
42
|
+
generateAccountFromKey(key: string): TBSAccount<N>;
|
|
43
|
+
decrypt(encryptedKey: string, password: string): Promise<TBSAccount<N>>;
|
|
35
44
|
encrypt(key: string, password: string): Promise<string>;
|
|
36
|
-
calculateTransferFee(param:
|
|
37
|
-
transfer(param:
|
|
38
|
-
claim(account:
|
|
45
|
+
calculateTransferFee(param: TTransferParam<N>): Promise<string>;
|
|
46
|
+
transfer(param: TTransferParam<N>): Promise<string[]>;
|
|
47
|
+
claim(account: TBSAccount<N>): Promise<string>;
|
|
39
48
|
resolveNameServiceDomain(domainName: string): Promise<string>;
|
|
40
49
|
}
|
package/dist/BSNeo3.js
CHANGED
|
@@ -13,13 +13,13 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
13
13
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
14
14
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
15
15
|
};
|
|
16
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
+
};
|
|
16
19
|
var _BSNeo3_instances, _BSNeo3_setTokens, _BSNeo3_buildTransferInvocation;
|
|
17
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
21
|
exports.BSNeo3 = void 0;
|
|
19
22
|
const blockchain_service_1 = require("@cityofzion/blockchain-service");
|
|
20
|
-
const bs_asteroid_sdk_1 = require("@cityofzion/bs-asteroid-sdk");
|
|
21
|
-
const neon_dappkit_1 = require("@cityofzion/neon-dappkit");
|
|
22
|
-
const neon_js_1 = require("@cityofzion/neon-js");
|
|
23
23
|
const BSNeo3Helper_1 = require("./helpers/BSNeo3Helper");
|
|
24
24
|
const DoraBDSNeo3_1 = require("./services/blockchain-data/DoraBDSNeo3");
|
|
25
25
|
const FlamingoForthewinEDSNeo3_1 = require("./services/exchange-data/FlamingoForthewinEDSNeo3");
|
|
@@ -27,22 +27,81 @@ const DoraESNeo3_1 = require("./services/explorer/DoraESNeo3");
|
|
|
27
27
|
const NeonDappKitLedgerServiceNeo3_1 = require("./services/ledger/NeonDappKitLedgerServiceNeo3");
|
|
28
28
|
const GhostMarketNDSNeo3_1 = require("./services/nft-data/GhostMarketNDSNeo3");
|
|
29
29
|
const BSNeo3Constants_1 = require("./constants/BSNeo3Constants");
|
|
30
|
-
const RpcBDSNeo3_1 = require("./services/blockchain-data/RpcBDSNeo3");
|
|
31
30
|
const Neo3NeoXBridgeService_1 = require("./services/neo3neoXBridge/Neo3NeoXBridgeService");
|
|
32
31
|
const DoraVoteServiceNeo3_1 = require("./services/vote/DoraVoteServiceNeo3");
|
|
33
32
|
const TokenServiceNeo3_1 = require("./services/token/TokenServiceNeo3");
|
|
33
|
+
const RpcCDSNeo3_1 = require("./services/chaim-data/RpcCDSNeo3");
|
|
34
|
+
const BSNeo3NeonJsSingletonHelper_1 = require("./helpers/BSNeo3NeonJsSingletonHelper");
|
|
35
|
+
const BSNeo3NeonDappKitSingletonHelper_1 = require("./helpers/BSNeo3NeonDappKitSingletonHelper");
|
|
36
|
+
const axios_1 = __importDefault(require("axios"));
|
|
34
37
|
class BSNeo3 {
|
|
35
38
|
constructor(name, network, getLedgerTransport) {
|
|
36
39
|
_BSNeo3_instances.add(this);
|
|
37
|
-
|
|
40
|
+
this.isMultiTransferSupported = true;
|
|
41
|
+
this.isCustomNetworkSupported = true;
|
|
38
42
|
this.name = name;
|
|
39
43
|
this.ledgerService = new NeonDappKitLedgerServiceNeo3_1.NeonDappKitLedgerServiceNeo3(this, getLedgerTransport);
|
|
40
44
|
this.bip44DerivationPath = BSNeo3Constants_1.BSNeo3Constants.DEFAULT_BIP44_DERIVATION_PATH;
|
|
41
|
-
this.
|
|
45
|
+
this.nativeTokens = BSNeo3Constants_1.BSNeo3Constants.NATIVE_ASSETS;
|
|
46
|
+
this.feeToken = BSNeo3Constants_1.BSNeo3Constants.GAS_TOKEN;
|
|
47
|
+
this.burnToken = BSNeo3Constants_1.BSNeo3Constants.NEO_TOKEN;
|
|
48
|
+
this.claimToken = BSNeo3Constants_1.BSNeo3Constants.GAS_TOKEN;
|
|
49
|
+
this.availableNetworks = BSNeo3Constants_1.BSNeo3Constants.ALL_NETWORKS;
|
|
50
|
+
this.defaultNetwork = BSNeo3Constants_1.BSNeo3Constants.MAINNET_NETWORK;
|
|
51
|
+
this.setNetwork(network !== null && network !== void 0 ? network : this.defaultNetwork);
|
|
52
|
+
}
|
|
53
|
+
setNetwork(network) {
|
|
54
|
+
const availableURLs = BSNeo3Constants_1.BSNeo3Constants.RPC_LIST_BY_NETWORK_ID[network.id] || [];
|
|
55
|
+
if (network.type === 'custom') {
|
|
56
|
+
if (typeof network.url !== 'string' || network.url.length === 0) {
|
|
57
|
+
throw new Error('You must provide a valid url to use a custom network');
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
const isValidNetwork = blockchain_service_1.BSUtilsHelper.validateNetwork(network, this.availableNetworks, availableURLs);
|
|
62
|
+
if (!isValidNetwork) {
|
|
63
|
+
throw new Error(`Network with id ${network.id} is not available for ${this.name}`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
__classPrivateFieldGet(this, _BSNeo3_instances, "m", _BSNeo3_setTokens).call(this, network);
|
|
67
|
+
this.network = network;
|
|
68
|
+
this.availableNetworkURLs = availableURLs;
|
|
69
|
+
this.tokenService = new TokenServiceNeo3_1.TokenServiceNeo3();
|
|
70
|
+
this.nftDataService = new GhostMarketNDSNeo3_1.GhostMarketNDSNeo3(this);
|
|
71
|
+
this.explorerService = new DoraESNeo3_1.DoraESNeo3(this);
|
|
72
|
+
this.voteService = new DoraVoteServiceNeo3_1.DoraVoteServiceNeo3(this);
|
|
73
|
+
this.neo3NeoXBridgeService = new Neo3NeoXBridgeService_1.Neo3NeoXBridgeService(this);
|
|
74
|
+
this.blockchainDataService = new DoraBDSNeo3_1.DoraBDSNeo3(this);
|
|
75
|
+
this.exchangeDataService = new FlamingoForthewinEDSNeo3_1.FlamingoForthewinEDSNeo3(this);
|
|
76
|
+
this.claimDataService = new RpcCDSNeo3_1.RpcCDSNeo3(this);
|
|
77
|
+
}
|
|
78
|
+
// This method is done manually because we need to ensure that the request is aborted after timeout
|
|
79
|
+
pingNetwork(network) {
|
|
80
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
81
|
+
const abortController = new AbortController();
|
|
82
|
+
const timeout = setTimeout(() => {
|
|
83
|
+
abortController.abort();
|
|
84
|
+
}, 5000);
|
|
85
|
+
const timeStart = Date.now();
|
|
86
|
+
const response = yield axios_1.default.post(network.url, {
|
|
87
|
+
jsonrpc: '2.0',
|
|
88
|
+
method: 'getblockcount',
|
|
89
|
+
params: [],
|
|
90
|
+
id: 1234,
|
|
91
|
+
}, { timeout: 5000, signal: abortController.signal });
|
|
92
|
+
clearTimeout(timeout);
|
|
93
|
+
const latency = Date.now() - timeStart;
|
|
94
|
+
return {
|
|
95
|
+
latency,
|
|
96
|
+
url: network.url,
|
|
97
|
+
height: response.data.result,
|
|
98
|
+
};
|
|
99
|
+
});
|
|
42
100
|
}
|
|
43
101
|
generateSigningCallback(account) {
|
|
44
102
|
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
-
const
|
|
103
|
+
const { wallet, api } = BSNeo3NeonJsSingletonHelper_1.BSNeo3NeonJsSingletonHelper.getInstance();
|
|
104
|
+
const neonJsAccount = new wallet.Account(account.key);
|
|
46
105
|
if (account.isHardware) {
|
|
47
106
|
if (!this.ledgerService.getLedgerTransport)
|
|
48
107
|
throw new Error('You must provide a getLedgerTransport function to use Ledger');
|
|
@@ -56,51 +115,38 @@ class BSNeo3 {
|
|
|
56
115
|
}
|
|
57
116
|
return {
|
|
58
117
|
neonJsAccount,
|
|
59
|
-
signingCallback:
|
|
118
|
+
signingCallback: api.signWithAccount(neonJsAccount),
|
|
60
119
|
};
|
|
61
120
|
});
|
|
62
121
|
}
|
|
63
|
-
setNetwork(network) {
|
|
64
|
-
__classPrivateFieldGet(this, _BSNeo3_instances, "m", _BSNeo3_setTokens).call(this, network);
|
|
65
|
-
this.network = network;
|
|
66
|
-
this.tokenService = new TokenServiceNeo3_1.TokenServiceNeo3();
|
|
67
|
-
this.nftDataService = new GhostMarketNDSNeo3_1.GhostMarketNDSNeo3(network);
|
|
68
|
-
this.explorerService = new DoraESNeo3_1.DoraESNeo3(network, this.tokenService);
|
|
69
|
-
this.voteService = new DoraVoteServiceNeo3_1.DoraVoteServiceNeo3(this);
|
|
70
|
-
this.neo3NeoXBridgeService = new Neo3NeoXBridgeService_1.Neo3NeoXBridgeService(this);
|
|
71
|
-
this.blockchainDataService = new DoraBDSNeo3_1.DoraBDSNeo3(network, this.feeToken, this.claimToken, this.tokens, this.nftDataService, this.explorerService, this.tokenService, this.neo3NeoXBridgeService);
|
|
72
|
-
this.exchangeDataService = new FlamingoForthewinEDSNeo3_1.FlamingoForthewinEDSNeo3(network, this.tokenService);
|
|
73
|
-
}
|
|
74
|
-
testNetwork(network) {
|
|
75
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
76
|
-
const blockchainDataServiceClone = new RpcBDSNeo3_1.RpcBDSNeo3(network, this.feeToken, this.claimToken, this.tokens, this.tokenService);
|
|
77
|
-
yield blockchainDataServiceClone.getBlockHeight();
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
122
|
validateAddress(address) {
|
|
81
|
-
|
|
123
|
+
const { wallet } = BSNeo3NeonJsSingletonHelper_1.BSNeo3NeonJsSingletonHelper.getInstance();
|
|
124
|
+
return wallet.isAddress(address, 53);
|
|
82
125
|
}
|
|
83
126
|
validateEncrypted(encryptedKey) {
|
|
84
|
-
|
|
127
|
+
const { wallet } = BSNeo3NeonJsSingletonHelper_1.BSNeo3NeonJsSingletonHelper.getInstance();
|
|
128
|
+
return wallet.isNEP2(encryptedKey);
|
|
85
129
|
}
|
|
86
130
|
validateKey(key) {
|
|
87
|
-
|
|
131
|
+
const { wallet } = BSNeo3NeonJsSingletonHelper_1.BSNeo3NeonJsSingletonHelper.getInstance();
|
|
132
|
+
return wallet.isWIF(key) || wallet.isPrivateKey(key);
|
|
88
133
|
}
|
|
89
134
|
validateNameServiceDomainFormat(domainName) {
|
|
90
135
|
return domainName.endsWith('.neo');
|
|
91
136
|
}
|
|
92
137
|
generateAccountFromMnemonic(mnemonic, index) {
|
|
93
|
-
|
|
138
|
+
const mnemonicStr = Array.isArray(mnemonic) ? mnemonic.join(' ') : mnemonic;
|
|
94
139
|
const bip44Path = this.bip44DerivationPath.replace('?', index.toString());
|
|
95
|
-
const
|
|
96
|
-
const
|
|
97
|
-
const { address } = new
|
|
98
|
-
return { address, key, type: 'wif', bip44Path, blockchain: this.name };
|
|
140
|
+
const key = blockchain_service_1.BSKeychainHelper.generateNeoPrivateKeyFromMnemonic(mnemonicStr, bip44Path);
|
|
141
|
+
const { wallet } = BSNeo3NeonJsSingletonHelper_1.BSNeo3NeonJsSingletonHelper.getInstance();
|
|
142
|
+
const { address, WIF } = new wallet.Account(key);
|
|
143
|
+
return { address, key: WIF, type: 'wif', bip44Path, blockchain: this.name };
|
|
99
144
|
}
|
|
100
145
|
generateAccountFromPublicKey(publicKey) {
|
|
101
|
-
|
|
146
|
+
const { wallet } = BSNeo3NeonJsSingletonHelper_1.BSNeo3NeonJsSingletonHelper.getInstance();
|
|
147
|
+
if (!wallet.isPublicKey(publicKey))
|
|
102
148
|
throw new Error('Invalid public key');
|
|
103
|
-
const account = new
|
|
149
|
+
const account = new wallet.Account(publicKey);
|
|
104
150
|
return {
|
|
105
151
|
address: account.address,
|
|
106
152
|
key: account.publicKey,
|
|
@@ -109,27 +155,31 @@ class BSNeo3 {
|
|
|
109
155
|
};
|
|
110
156
|
}
|
|
111
157
|
generateAccountFromKey(key) {
|
|
112
|
-
const
|
|
158
|
+
const { wallet } = BSNeo3NeonJsSingletonHelper_1.BSNeo3NeonJsSingletonHelper.getInstance();
|
|
159
|
+
const type = wallet.isWIF(key) ? 'wif' : wallet.isPrivateKey(key) ? 'privateKey' : undefined;
|
|
113
160
|
if (!type)
|
|
114
161
|
throw new Error('Invalid key');
|
|
115
|
-
const { address } = new
|
|
162
|
+
const { address } = new wallet.Account(key);
|
|
116
163
|
return { address, key, type, blockchain: this.name };
|
|
117
164
|
}
|
|
118
165
|
decrypt(encryptedKey, password) {
|
|
119
166
|
return __awaiter(this, void 0, void 0, function* () {
|
|
120
|
-
const
|
|
167
|
+
const { wallet } = BSNeo3NeonJsSingletonHelper_1.BSNeo3NeonJsSingletonHelper.getInstance();
|
|
168
|
+
const key = yield wallet.decrypt(encryptedKey, password);
|
|
121
169
|
return this.generateAccountFromKey(key);
|
|
122
170
|
});
|
|
123
171
|
}
|
|
124
172
|
encrypt(key, password) {
|
|
125
173
|
return __awaiter(this, void 0, void 0, function* () {
|
|
126
|
-
|
|
174
|
+
const { wallet } = BSNeo3NeonJsSingletonHelper_1.BSNeo3NeonJsSingletonHelper.getInstance();
|
|
175
|
+
return yield wallet.encrypt(key, password);
|
|
127
176
|
});
|
|
128
177
|
}
|
|
129
178
|
calculateTransferFee(param) {
|
|
130
179
|
return __awaiter(this, void 0, void 0, function* () {
|
|
131
180
|
const { neonJsAccount } = yield this.generateSigningCallback(param.senderAccount);
|
|
132
|
-
const
|
|
181
|
+
const { NeonInvoker } = BSNeo3NeonDappKitSingletonHelper_1.BSNeo3NeonDappKitSingletonHelper.getInstance();
|
|
182
|
+
const invoker = yield NeonInvoker.init({
|
|
133
183
|
rpcAddress: this.network.url,
|
|
134
184
|
account: neonJsAccount,
|
|
135
185
|
});
|
|
@@ -144,7 +194,8 @@ class BSNeo3 {
|
|
|
144
194
|
transfer(param) {
|
|
145
195
|
return __awaiter(this, void 0, void 0, function* () {
|
|
146
196
|
const { neonJsAccount, signingCallback } = yield this.generateSigningCallback(param.senderAccount);
|
|
147
|
-
const
|
|
197
|
+
const { NeonInvoker } = BSNeo3NeonDappKitSingletonHelper_1.BSNeo3NeonDappKitSingletonHelper.getInstance();
|
|
198
|
+
const invoker = yield NeonInvoker.init({
|
|
148
199
|
rpcAddress: this.network.url,
|
|
149
200
|
account: neonJsAccount,
|
|
150
201
|
signingCallback: signingCallback,
|
|
@@ -160,17 +211,18 @@ class BSNeo3 {
|
|
|
160
211
|
claim(account) {
|
|
161
212
|
return __awaiter(this, void 0, void 0, function* () {
|
|
162
213
|
const { neonJsAccount, signingCallback } = yield this.generateSigningCallback(account);
|
|
163
|
-
const
|
|
214
|
+
const { api } = BSNeo3NeonJsSingletonHelper_1.BSNeo3NeonJsSingletonHelper.getInstance();
|
|
215
|
+
const facade = yield api.NetworkFacade.fromConfig({ node: this.network.url });
|
|
164
216
|
return yield facade.claimGas(neonJsAccount, {
|
|
165
217
|
signingCallback: signingCallback,
|
|
166
218
|
});
|
|
167
219
|
});
|
|
168
220
|
}
|
|
169
221
|
resolveNameServiceDomain(domainName) {
|
|
170
|
-
var _a;
|
|
171
222
|
return __awaiter(this, void 0, void 0, function* () {
|
|
172
|
-
|
|
173
|
-
const
|
|
223
|
+
var _a;
|
|
224
|
+
const { NeonParser, NeonInvoker } = BSNeo3NeonDappKitSingletonHelper_1.BSNeo3NeonDappKitSingletonHelper.getInstance();
|
|
225
|
+
const invoker = yield NeonInvoker.init({ rpcAddress: this.network.url });
|
|
174
226
|
const response = yield invoker.testInvoke({
|
|
175
227
|
invocations: [
|
|
176
228
|
{
|
|
@@ -183,23 +235,19 @@ class BSNeo3 {
|
|
|
183
235
|
if (response.stack.length === 0) {
|
|
184
236
|
throw new Error((_a = response.exception) !== null && _a !== void 0 ? _a : 'unrecognized response');
|
|
185
237
|
}
|
|
186
|
-
const parsed =
|
|
238
|
+
const parsed = NeonParser.parseRpcResponse(response.stack[0], {
|
|
187
239
|
type: 'Hash160',
|
|
188
240
|
});
|
|
189
|
-
return
|
|
241
|
+
return NeonParser.accountInputToAddress(parsed.replace('0x', ''));
|
|
190
242
|
});
|
|
191
243
|
}
|
|
192
244
|
}
|
|
193
245
|
exports.BSNeo3 = BSNeo3;
|
|
194
246
|
_BSNeo3_instances = new WeakSet(), _BSNeo3_setTokens = function _BSNeo3_setTokens(network) {
|
|
195
247
|
const tokens = BSNeo3Helper_1.BSNeo3Helper.getTokens(network);
|
|
196
|
-
this.nativeTokens = BSNeo3Constants_1.BSNeo3Constants.NATIVE_ASSETS;
|
|
197
248
|
this.tokens = tokens;
|
|
198
|
-
|
|
199
|
-
this
|
|
200
|
-
this.claimToken = tokens.find(token => token.symbol === 'GAS');
|
|
201
|
-
}, _BSNeo3_buildTransferInvocation = function _BSNeo3_buildTransferInvocation({ intents, tipIntent }, account) {
|
|
202
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
249
|
+
}, _BSNeo3_buildTransferInvocation = function _BSNeo3_buildTransferInvocation(_a, account_1) {
|
|
250
|
+
return __awaiter(this, arguments, void 0, function* ({ intents, tipIntent }, account) {
|
|
203
251
|
const concatIntents = [...intents, ...(tipIntent ? [tipIntent] : [])];
|
|
204
252
|
const invocations = [];
|
|
205
253
|
for (const intent of concatIntents) {
|
|
@@ -209,7 +257,7 @@ _BSNeo3_instances = new WeakSet(), _BSNeo3_setTokens = function _BSNeo3_setToken
|
|
|
209
257
|
const token = yield this.blockchainDataService.getTokenInfo(intent.tokenHash);
|
|
210
258
|
decimals = token.decimals;
|
|
211
259
|
}
|
|
212
|
-
catch (
|
|
260
|
+
catch (_b) {
|
|
213
261
|
decimals = 8;
|
|
214
262
|
}
|
|
215
263
|
}
|
|
@@ -1,19 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { TBSNetwork, TBSToken } from '@cityofzion/blockchain-service';
|
|
2
|
+
import { TBSNeo3NetworkId } from '../types';
|
|
3
3
|
export declare class BSNeo3Constants {
|
|
4
|
-
|
|
5
|
-
static
|
|
6
|
-
static
|
|
7
|
-
static
|
|
8
|
-
static
|
|
9
|
-
static
|
|
10
|
-
static
|
|
11
|
-
static
|
|
12
|
-
static
|
|
13
|
-
static
|
|
14
|
-
static TESTNET_NETWORKS: Network<BSNeo3NetworkId>[];
|
|
15
|
-
static ALL_NETWORKS: Network<BSNeo3NetworkId>[];
|
|
16
|
-
static DEFAULT_NETWORK: Network<BSNeo3NetworkId>;
|
|
17
|
-
static NEO_NS_HASH: string;
|
|
18
|
-
static DEFAULT_BIP44_DERIVATION_PATH: string;
|
|
4
|
+
static readonly EXTRA_TOKENS_BY_NETWORK_ID: Partial<Record<TBSNeo3NetworkId, TBSToken[]>>;
|
|
5
|
+
static readonly GAS_TOKEN: TBSToken;
|
|
6
|
+
static readonly NEO_TOKEN: TBSToken;
|
|
7
|
+
static readonly NATIVE_ASSETS: TBSToken[];
|
|
8
|
+
static readonly RPC_LIST_BY_NETWORK_ID: Partial<Record<TBSNeo3NetworkId, string[]>>;
|
|
9
|
+
static readonly MAINNET_NETWORK: TBSNetwork<TBSNeo3NetworkId>;
|
|
10
|
+
static readonly TESTNET_NETWORK: TBSNetwork<TBSNeo3NetworkId>;
|
|
11
|
+
static readonly ALL_NETWORKS: TBSNetwork<TBSNeo3NetworkId>[];
|
|
12
|
+
static readonly NEO_NS_HASH = "0x50ac1c37690cc2cfc594472833cf57505d5f46de";
|
|
13
|
+
static readonly DEFAULT_BIP44_DERIVATION_PATH = "m/44'/888'/0'/0/?";
|
|
19
14
|
}
|