@cityofzion/bs-neo3 1.16.3 → 1.17.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/dist/BSNeo3.d.ts +40 -30
- package/dist/BSNeo3.js +104 -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 +4 -2
- package/dist/index.js +4 -2
- package/dist/services/blockchain-data/DoraBDSNeo3.d.ts +13 -12
- package/dist/services/blockchain-data/DoraBDSNeo3.js +131 -141
- 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/services/wallet-connect/WalletConnectServiceNeo3.d.ts +45 -0
- package/dist/services/wallet-connect/WalletConnectServiceNeo3.js +163 -0
- 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,50 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TBSAccount, TGetLedgerTransport, IBlockchainDataService, IClaimDataService, IExchangeDataService, IExplorerService, INeo3NeoXBridgeService, INftDataService, ITokenService, TBSNetwork, TBSToken, TTransferParam, TPingNetworkResponse, IWalletConnectService } 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
|
-
|
|
24
|
-
|
|
25
|
-
setNetwork(network:
|
|
26
|
-
|
|
28
|
+
claimDataService: IClaimDataService;
|
|
29
|
+
walletConnectService: IWalletConnectService;
|
|
30
|
+
constructor(name: N, network?: TBSNetwork<TBSNeo3NetworkId>, getLedgerTransport?: TGetLedgerTransport<N>);
|
|
31
|
+
setNetwork(network: TBSNetwork<TBSNeo3NetworkId>): void;
|
|
32
|
+
pingNetwork(network: TBSNetwork<TBSNeo3NetworkId>): Promise<TPingNetworkResponse>;
|
|
33
|
+
generateSigningCallback(account: TBSAccount<N>): Promise<{
|
|
34
|
+
neonJsAccount: wallet.Account;
|
|
35
|
+
signingCallback: api.SigningFunction;
|
|
36
|
+
}>;
|
|
27
37
|
validateAddress(address: string): boolean;
|
|
28
38
|
validateEncrypted(encryptedKey: string): boolean;
|
|
29
39
|
validateKey(key: string): boolean;
|
|
30
40
|
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<
|
|
41
|
+
generateAccountFromMnemonic(mnemonic: string[] | string, index: number): TBSAccount<N>;
|
|
42
|
+
generateAccountFromPublicKey(publicKey: string): TBSAccount<N>;
|
|
43
|
+
generateAccountFromKey(key: string): TBSAccount<N>;
|
|
44
|
+
decrypt(encryptedKey: string, password: string): Promise<TBSAccount<N>>;
|
|
35
45
|
encrypt(key: string, password: string): Promise<string>;
|
|
36
|
-
calculateTransferFee(param:
|
|
37
|
-
transfer(param:
|
|
38
|
-
claim(account:
|
|
46
|
+
calculateTransferFee(param: TTransferParam<N>): Promise<string>;
|
|
47
|
+
transfer(param: TTransferParam<N>): Promise<string[]>;
|
|
48
|
+
claim(account: TBSAccount<N>): Promise<string>;
|
|
39
49
|
resolveNameServiceDomain(domainName: string): Promise<string>;
|
|
40
50
|
}
|
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,83 @@ 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"));
|
|
37
|
+
const WalletConnectServiceNeo3_1 = require("./services/wallet-connect/WalletConnectServiceNeo3");
|
|
34
38
|
class BSNeo3 {
|
|
35
39
|
constructor(name, network, getLedgerTransport) {
|
|
36
40
|
_BSNeo3_instances.add(this);
|
|
37
|
-
|
|
41
|
+
this.isMultiTransferSupported = true;
|
|
42
|
+
this.isCustomNetworkSupported = true;
|
|
38
43
|
this.name = name;
|
|
39
44
|
this.ledgerService = new NeonDappKitLedgerServiceNeo3_1.NeonDappKitLedgerServiceNeo3(this, getLedgerTransport);
|
|
40
45
|
this.bip44DerivationPath = BSNeo3Constants_1.BSNeo3Constants.DEFAULT_BIP44_DERIVATION_PATH;
|
|
41
|
-
this.
|
|
46
|
+
this.nativeTokens = BSNeo3Constants_1.BSNeo3Constants.NATIVE_ASSETS;
|
|
47
|
+
this.feeToken = BSNeo3Constants_1.BSNeo3Constants.GAS_TOKEN;
|
|
48
|
+
this.burnToken = BSNeo3Constants_1.BSNeo3Constants.NEO_TOKEN;
|
|
49
|
+
this.claimToken = BSNeo3Constants_1.BSNeo3Constants.GAS_TOKEN;
|
|
50
|
+
this.availableNetworks = BSNeo3Constants_1.BSNeo3Constants.ALL_NETWORKS;
|
|
51
|
+
this.defaultNetwork = BSNeo3Constants_1.BSNeo3Constants.MAINNET_NETWORK;
|
|
52
|
+
this.setNetwork(network !== null && network !== void 0 ? network : this.defaultNetwork);
|
|
53
|
+
}
|
|
54
|
+
setNetwork(network) {
|
|
55
|
+
const availableURLs = BSNeo3Constants_1.BSNeo3Constants.RPC_LIST_BY_NETWORK_ID[network.id] || [];
|
|
56
|
+
if (network.type === 'custom') {
|
|
57
|
+
if (typeof network.url !== 'string' || network.url.length === 0) {
|
|
58
|
+
throw new Error('You must provide a valid url to use a custom network');
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
const isValidNetwork = blockchain_service_1.BSUtilsHelper.validateNetwork(network, this.availableNetworks, availableURLs);
|
|
63
|
+
if (!isValidNetwork) {
|
|
64
|
+
throw new Error(`Network with id ${network.id} is not available for ${this.name}`);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
__classPrivateFieldGet(this, _BSNeo3_instances, "m", _BSNeo3_setTokens).call(this, network);
|
|
68
|
+
this.network = network;
|
|
69
|
+
this.availableNetworkURLs = availableURLs;
|
|
70
|
+
this.tokenService = new TokenServiceNeo3_1.TokenServiceNeo3();
|
|
71
|
+
this.nftDataService = new GhostMarketNDSNeo3_1.GhostMarketNDSNeo3(this);
|
|
72
|
+
this.explorerService = new DoraESNeo3_1.DoraESNeo3(this);
|
|
73
|
+
this.voteService = new DoraVoteServiceNeo3_1.DoraVoteServiceNeo3(this);
|
|
74
|
+
this.neo3NeoXBridgeService = new Neo3NeoXBridgeService_1.Neo3NeoXBridgeService(this);
|
|
75
|
+
this.blockchainDataService = new DoraBDSNeo3_1.DoraBDSNeo3(this);
|
|
76
|
+
this.exchangeDataService = new FlamingoForthewinEDSNeo3_1.FlamingoForthewinEDSNeo3(this);
|
|
77
|
+
this.claimDataService = new RpcCDSNeo3_1.RpcCDSNeo3(this);
|
|
78
|
+
this.walletConnectService = new WalletConnectServiceNeo3_1.WalletConnectServiceNeo3(this);
|
|
79
|
+
}
|
|
80
|
+
// This method is done manually because we need to ensure that the request is aborted after timeout
|
|
81
|
+
pingNetwork(network) {
|
|
82
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
83
|
+
const abortController = new AbortController();
|
|
84
|
+
const timeout = setTimeout(() => {
|
|
85
|
+
abortController.abort();
|
|
86
|
+
}, 5000);
|
|
87
|
+
const timeStart = Date.now();
|
|
88
|
+
const response = yield axios_1.default.post(network.url, {
|
|
89
|
+
jsonrpc: '2.0',
|
|
90
|
+
method: 'getblockcount',
|
|
91
|
+
params: [],
|
|
92
|
+
id: 1234,
|
|
93
|
+
}, { timeout: 5000, signal: abortController.signal });
|
|
94
|
+
clearTimeout(timeout);
|
|
95
|
+
const latency = Date.now() - timeStart;
|
|
96
|
+
return {
|
|
97
|
+
latency,
|
|
98
|
+
url: network.url,
|
|
99
|
+
height: response.data.result,
|
|
100
|
+
};
|
|
101
|
+
});
|
|
42
102
|
}
|
|
43
103
|
generateSigningCallback(account) {
|
|
44
104
|
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
-
const
|
|
105
|
+
const { wallet, api } = BSNeo3NeonJsSingletonHelper_1.BSNeo3NeonJsSingletonHelper.getInstance();
|
|
106
|
+
const neonJsAccount = new wallet.Account(account.key);
|
|
46
107
|
if (account.isHardware) {
|
|
47
108
|
if (!this.ledgerService.getLedgerTransport)
|
|
48
109
|
throw new Error('You must provide a getLedgerTransport function to use Ledger');
|
|
@@ -56,51 +117,38 @@ class BSNeo3 {
|
|
|
56
117
|
}
|
|
57
118
|
return {
|
|
58
119
|
neonJsAccount,
|
|
59
|
-
signingCallback:
|
|
120
|
+
signingCallback: api.signWithAccount(neonJsAccount),
|
|
60
121
|
};
|
|
61
122
|
});
|
|
62
123
|
}
|
|
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
124
|
validateAddress(address) {
|
|
81
|
-
|
|
125
|
+
const { wallet } = BSNeo3NeonJsSingletonHelper_1.BSNeo3NeonJsSingletonHelper.getInstance();
|
|
126
|
+
return wallet.isAddress(address, 53);
|
|
82
127
|
}
|
|
83
128
|
validateEncrypted(encryptedKey) {
|
|
84
|
-
|
|
129
|
+
const { wallet } = BSNeo3NeonJsSingletonHelper_1.BSNeo3NeonJsSingletonHelper.getInstance();
|
|
130
|
+
return wallet.isNEP2(encryptedKey);
|
|
85
131
|
}
|
|
86
132
|
validateKey(key) {
|
|
87
|
-
|
|
133
|
+
const { wallet } = BSNeo3NeonJsSingletonHelper_1.BSNeo3NeonJsSingletonHelper.getInstance();
|
|
134
|
+
return wallet.isWIF(key) || wallet.isPrivateKey(key);
|
|
88
135
|
}
|
|
89
136
|
validateNameServiceDomainFormat(domainName) {
|
|
90
137
|
return domainName.endsWith('.neo');
|
|
91
138
|
}
|
|
92
139
|
generateAccountFromMnemonic(mnemonic, index) {
|
|
93
|
-
|
|
140
|
+
const mnemonicStr = Array.isArray(mnemonic) ? mnemonic.join(' ') : mnemonic;
|
|
94
141
|
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 };
|
|
142
|
+
const key = blockchain_service_1.BSKeychainHelper.generateNeoPrivateKeyFromMnemonic(mnemonicStr, bip44Path);
|
|
143
|
+
const { wallet } = BSNeo3NeonJsSingletonHelper_1.BSNeo3NeonJsSingletonHelper.getInstance();
|
|
144
|
+
const { address, WIF } = new wallet.Account(key);
|
|
145
|
+
return { address, key: WIF, type: 'wif', bip44Path, blockchain: this.name };
|
|
99
146
|
}
|
|
100
147
|
generateAccountFromPublicKey(publicKey) {
|
|
101
|
-
|
|
148
|
+
const { wallet } = BSNeo3NeonJsSingletonHelper_1.BSNeo3NeonJsSingletonHelper.getInstance();
|
|
149
|
+
if (!wallet.isPublicKey(publicKey))
|
|
102
150
|
throw new Error('Invalid public key');
|
|
103
|
-
const account = new
|
|
151
|
+
const account = new wallet.Account(publicKey);
|
|
104
152
|
return {
|
|
105
153
|
address: account.address,
|
|
106
154
|
key: account.publicKey,
|
|
@@ -109,27 +157,31 @@ class BSNeo3 {
|
|
|
109
157
|
};
|
|
110
158
|
}
|
|
111
159
|
generateAccountFromKey(key) {
|
|
112
|
-
const
|
|
160
|
+
const { wallet } = BSNeo3NeonJsSingletonHelper_1.BSNeo3NeonJsSingletonHelper.getInstance();
|
|
161
|
+
const type = wallet.isWIF(key) ? 'wif' : wallet.isPrivateKey(key) ? 'privateKey' : undefined;
|
|
113
162
|
if (!type)
|
|
114
163
|
throw new Error('Invalid key');
|
|
115
|
-
const { address } = new
|
|
164
|
+
const { address } = new wallet.Account(key);
|
|
116
165
|
return { address, key, type, blockchain: this.name };
|
|
117
166
|
}
|
|
118
167
|
decrypt(encryptedKey, password) {
|
|
119
168
|
return __awaiter(this, void 0, void 0, function* () {
|
|
120
|
-
const
|
|
169
|
+
const { wallet } = BSNeo3NeonJsSingletonHelper_1.BSNeo3NeonJsSingletonHelper.getInstance();
|
|
170
|
+
const key = yield wallet.decrypt(encryptedKey, password);
|
|
121
171
|
return this.generateAccountFromKey(key);
|
|
122
172
|
});
|
|
123
173
|
}
|
|
124
174
|
encrypt(key, password) {
|
|
125
175
|
return __awaiter(this, void 0, void 0, function* () {
|
|
126
|
-
|
|
176
|
+
const { wallet } = BSNeo3NeonJsSingletonHelper_1.BSNeo3NeonJsSingletonHelper.getInstance();
|
|
177
|
+
return yield wallet.encrypt(key, password);
|
|
127
178
|
});
|
|
128
179
|
}
|
|
129
180
|
calculateTransferFee(param) {
|
|
130
181
|
return __awaiter(this, void 0, void 0, function* () {
|
|
131
182
|
const { neonJsAccount } = yield this.generateSigningCallback(param.senderAccount);
|
|
132
|
-
const
|
|
183
|
+
const { NeonInvoker } = BSNeo3NeonDappKitSingletonHelper_1.BSNeo3NeonDappKitSingletonHelper.getInstance();
|
|
184
|
+
const invoker = yield NeonInvoker.init({
|
|
133
185
|
rpcAddress: this.network.url,
|
|
134
186
|
account: neonJsAccount,
|
|
135
187
|
});
|
|
@@ -144,7 +196,8 @@ class BSNeo3 {
|
|
|
144
196
|
transfer(param) {
|
|
145
197
|
return __awaiter(this, void 0, void 0, function* () {
|
|
146
198
|
const { neonJsAccount, signingCallback } = yield this.generateSigningCallback(param.senderAccount);
|
|
147
|
-
const
|
|
199
|
+
const { NeonInvoker } = BSNeo3NeonDappKitSingletonHelper_1.BSNeo3NeonDappKitSingletonHelper.getInstance();
|
|
200
|
+
const invoker = yield NeonInvoker.init({
|
|
148
201
|
rpcAddress: this.network.url,
|
|
149
202
|
account: neonJsAccount,
|
|
150
203
|
signingCallback: signingCallback,
|
|
@@ -160,17 +213,18 @@ class BSNeo3 {
|
|
|
160
213
|
claim(account) {
|
|
161
214
|
return __awaiter(this, void 0, void 0, function* () {
|
|
162
215
|
const { neonJsAccount, signingCallback } = yield this.generateSigningCallback(account);
|
|
163
|
-
const
|
|
216
|
+
const { api } = BSNeo3NeonJsSingletonHelper_1.BSNeo3NeonJsSingletonHelper.getInstance();
|
|
217
|
+
const facade = yield api.NetworkFacade.fromConfig({ node: this.network.url });
|
|
164
218
|
return yield facade.claimGas(neonJsAccount, {
|
|
165
219
|
signingCallback: signingCallback,
|
|
166
220
|
});
|
|
167
221
|
});
|
|
168
222
|
}
|
|
169
223
|
resolveNameServiceDomain(domainName) {
|
|
170
|
-
var _a;
|
|
171
224
|
return __awaiter(this, void 0, void 0, function* () {
|
|
172
|
-
|
|
173
|
-
const
|
|
225
|
+
var _a;
|
|
226
|
+
const { NeonParser, NeonInvoker } = BSNeo3NeonDappKitSingletonHelper_1.BSNeo3NeonDappKitSingletonHelper.getInstance();
|
|
227
|
+
const invoker = yield NeonInvoker.init({ rpcAddress: this.network.url });
|
|
174
228
|
const response = yield invoker.testInvoke({
|
|
175
229
|
invocations: [
|
|
176
230
|
{
|
|
@@ -183,23 +237,19 @@ class BSNeo3 {
|
|
|
183
237
|
if (response.stack.length === 0) {
|
|
184
238
|
throw new Error((_a = response.exception) !== null && _a !== void 0 ? _a : 'unrecognized response');
|
|
185
239
|
}
|
|
186
|
-
const parsed =
|
|
240
|
+
const parsed = NeonParser.parseRpcResponse(response.stack[0], {
|
|
187
241
|
type: 'Hash160',
|
|
188
242
|
});
|
|
189
|
-
return
|
|
243
|
+
return NeonParser.accountInputToAddress(parsed.replace('0x', ''));
|
|
190
244
|
});
|
|
191
245
|
}
|
|
192
246
|
}
|
|
193
247
|
exports.BSNeo3 = BSNeo3;
|
|
194
248
|
_BSNeo3_instances = new WeakSet(), _BSNeo3_setTokens = function _BSNeo3_setTokens(network) {
|
|
195
249
|
const tokens = BSNeo3Helper_1.BSNeo3Helper.getTokens(network);
|
|
196
|
-
this.nativeTokens = BSNeo3Constants_1.BSNeo3Constants.NATIVE_ASSETS;
|
|
197
250
|
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* () {
|
|
251
|
+
}, _BSNeo3_buildTransferInvocation = function _BSNeo3_buildTransferInvocation(_a, account_1) {
|
|
252
|
+
return __awaiter(this, arguments, void 0, function* ({ intents, tipIntent }, account) {
|
|
203
253
|
const concatIntents = [...intents, ...(tipIntent ? [tipIntent] : [])];
|
|
204
254
|
const invocations = [];
|
|
205
255
|
for (const intent of concatIntents) {
|
|
@@ -209,7 +259,7 @@ _BSNeo3_instances = new WeakSet(), _BSNeo3_setTokens = function _BSNeo3_setToken
|
|
|
209
259
|
const token = yield this.blockchainDataService.getTokenInfo(intent.tokenHash);
|
|
210
260
|
decimals = token.decimals;
|
|
211
261
|
}
|
|
212
|
-
catch (
|
|
262
|
+
catch (_b) {
|
|
213
263
|
decimals = 8;
|
|
214
264
|
}
|
|
215
265
|
}
|
|
@@ -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
|
}
|