@cityofzion/bs-neo3 1.3.2 → 1.4.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 +11 -5
- package/dist/BSNeo3.js +43 -36
- package/dist/builder/invocation/FlamingoSwapInvocationBuilderNeo3.d.ts +1 -1
- package/dist/builder/invocation/FlamingoSwapInvocationBuilderNeo3.js +21 -13
- package/dist/constants/BSNeo3Constants.d.ts +15 -0
- package/dist/constants/BSNeo3Constants.js +59 -0
- package/dist/constants/FlamingoSwapConstants.d.ts +1 -1
- package/dist/constants/FlamingoSwapConstants.js +0 -12
- package/dist/helpers/BSNeo3Helper.d.ts +3 -18
- package/dist/helpers/BSNeo3Helper.js +7 -61
- package/dist/helpers/FlamingoSwapHelper.d.ts +2 -1
- package/dist/helpers/FlamingoSwapHelper.js +4 -0
- package/dist/services/blockchain-data/DoraBDSNeo3.d.ts +1 -1
- package/dist/services/blockchain-data/RpcBDSNeo3.d.ts +1 -1
- package/dist/services/exchange-data/FlamingoEDSNeo3.d.ts +1 -1
- package/dist/services/explorer/DoraESNeo3.d.ts +1 -1
- package/dist/services/ledger/NeonDappKitLedgerServiceNeo3.d.ts +6 -6
- package/dist/services/ledger/NeonDappKitLedgerServiceNeo3.js +64 -40
- package/dist/services/nft-data/GhostMarketNDSNeo3.d.ts +1 -1
- package/dist/services/nft-data/RpcNDSNeo3.d.ts +1 -1
- package/dist/services/swap/FlamingoSwapServiceNeo3.d.ts +3 -3
- package/dist/services/swap/FlamingoSwapServiceNeo3.js +9 -20
- package/dist/services/swap/handlers/FlamingoSwapDetailsHandler.d.ts +1 -1
- package/dist/services/swap/handlers/FlamingoSwapRouteHandler.d.ts +1 -1
- package/package.json +2 -2
package/dist/BSNeo3.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import { Account,
|
|
1
|
+
import { Account, BDSClaimable, BlockchainDataService, BlockchainService, BSCalculableFee, BSClaimable, BSWithExplorerService, BSWithLedger, BSWithNameService, BSWithNft, BSWithSwap, ExchangeDataService, ExplorerService, Network, NftDataService, SwapService, Token, TransferParam } from '@cityofzion/blockchain-service';
|
|
2
|
+
import Neon from '@cityofzion/neon-core';
|
|
3
|
+
import { api } from '@cityofzion/neon-js';
|
|
2
4
|
import Transport from '@ledgerhq/hw-transport';
|
|
3
|
-
import { BSNeo3NetworkId } from './helpers/BSNeo3Helper';
|
|
4
5
|
import { NeonDappKitLedgerServiceNeo3 } from './services/ledger/NeonDappKitLedgerServiceNeo3';
|
|
6
|
+
import { BSNeo3NetworkId } from './constants/BSNeo3Constants';
|
|
5
7
|
export declare class BSNeo3<BSCustomName extends string = string> implements BlockchainService<BSCustomName, BSNeo3NetworkId>, BSClaimable, BSWithNameService, BSCalculableFee, BSWithNft, BSWithExplorerService, BSWithLedger, BSWithSwap<BSNeo3NetworkId> {
|
|
6
8
|
#private;
|
|
7
9
|
blockchainName: BSCustomName;
|
|
8
|
-
|
|
10
|
+
bip44DerivationPath: string;
|
|
9
11
|
tokens: Token[];
|
|
10
12
|
feeToken: Token;
|
|
11
13
|
claimToken: Token;
|
|
@@ -17,19 +19,23 @@ export declare class BSNeo3<BSCustomName extends string = string> implements Blo
|
|
|
17
19
|
explorerService: ExplorerService;
|
|
18
20
|
network: Network<BSNeo3NetworkId>;
|
|
19
21
|
constructor(blockchainName: BSCustomName, network?: Network<BSNeo3NetworkId>, getLedgerTransport?: (account: Account) => Promise<Transport>);
|
|
22
|
+
generateSigningCallback(account: Account, isLedger?: boolean): Promise<{
|
|
23
|
+
neonJsAccount: Neon.wallet.Account;
|
|
24
|
+
signingCallback: api.SigningFunction;
|
|
25
|
+
}>;
|
|
20
26
|
createSwapService(): SwapService<BSNeo3NetworkId>;
|
|
21
27
|
setNetwork(network: Network<BSNeo3NetworkId>): void;
|
|
22
28
|
validateAddress(address: string): boolean;
|
|
23
29
|
validateEncrypted(encryptedKey: string): boolean;
|
|
24
30
|
validateKey(key: string): boolean;
|
|
25
31
|
validateNameServiceDomainFormat(domainName: string): boolean;
|
|
26
|
-
generateAccountFromMnemonic(mnemonic: string[] | string, index: number):
|
|
32
|
+
generateAccountFromMnemonic(mnemonic: string[] | string, index: number): Account;
|
|
27
33
|
generateAccountFromPublicKey(publicKey: string): Account;
|
|
28
34
|
generateAccountFromKey(key: string): Account;
|
|
29
35
|
decrypt(encryptedKey: string, password: string): Promise<Account>;
|
|
30
36
|
encrypt(key: string, password: string): Promise<string>;
|
|
31
37
|
calculateTransferFee(param: TransferParam): Promise<string>;
|
|
32
|
-
transfer(param: TransferParam): Promise<string>;
|
|
38
|
+
transfer(param: TransferParam): Promise<string[]>;
|
|
33
39
|
claim(account: Account, isLedger?: boolean): Promise<string>;
|
|
34
40
|
resolveNameServiceDomain(domainName: string): Promise<any>;
|
|
35
41
|
}
|
package/dist/BSNeo3.js
CHANGED
|
@@ -26,17 +26,38 @@ const DoraESNeo3_1 = require("./services/explorer/DoraESNeo3");
|
|
|
26
26
|
const NeonDappKitLedgerServiceNeo3_1 = require("./services/ledger/NeonDappKitLedgerServiceNeo3");
|
|
27
27
|
const GhostMarketNDSNeo3_1 = require("./services/nft-data/GhostMarketNDSNeo3");
|
|
28
28
|
const FlamingoSwapServiceNeo3_1 = require("./services/swap/FlamingoSwapServiceNeo3");
|
|
29
|
+
const BSNeo3Constants_1 = require("./constants/BSNeo3Constants");
|
|
29
30
|
class BSNeo3 {
|
|
30
31
|
constructor(blockchainName, network, getLedgerTransport) {
|
|
31
32
|
_BSNeo3_instances.add(this);
|
|
32
|
-
network = network !== null && network !== void 0 ? network :
|
|
33
|
+
network = network !== null && network !== void 0 ? network : BSNeo3Constants_1.BSNeo3Constants.DEFAULT_NETWORK;
|
|
33
34
|
this.blockchainName = blockchainName;
|
|
34
|
-
this.ledgerService = new NeonDappKitLedgerServiceNeo3_1.NeonDappKitLedgerServiceNeo3(getLedgerTransport);
|
|
35
|
-
this.
|
|
35
|
+
this.ledgerService = new NeonDappKitLedgerServiceNeo3_1.NeonDappKitLedgerServiceNeo3(this, getLedgerTransport);
|
|
36
|
+
this.bip44DerivationPath = BSNeo3Constants_1.BSNeo3Constants.DEFAULT_BIP44_DERIVATION_PATH;
|
|
36
37
|
this.setNetwork(network);
|
|
37
38
|
}
|
|
39
|
+
generateSigningCallback(account, isLedger) {
|
|
40
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
const neonJsAccount = new neon_js_1.wallet.Account(account.key);
|
|
42
|
+
if (isLedger) {
|
|
43
|
+
if (!this.ledgerService.getLedgerTransport)
|
|
44
|
+
throw new Error('You must provide a getLedgerTransport function to use Ledger');
|
|
45
|
+
if (typeof account.bip44Path !== 'string')
|
|
46
|
+
throw new Error('Your account must have bip44 path to use Ledger');
|
|
47
|
+
const ledgerTransport = yield this.ledgerService.getLedgerTransport(account);
|
|
48
|
+
return {
|
|
49
|
+
neonJsAccount,
|
|
50
|
+
signingCallback: this.ledgerService.getSigningCallback(ledgerTransport, account),
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
neonJsAccount,
|
|
55
|
+
signingCallback: neon_js_1.api.signWithAccount(neonJsAccount),
|
|
56
|
+
};
|
|
57
|
+
});
|
|
58
|
+
}
|
|
38
59
|
createSwapService() {
|
|
39
|
-
return new FlamingoSwapServiceNeo3_1.FlamingoSwapServiceNeo3(this.network, this
|
|
60
|
+
return new FlamingoSwapServiceNeo3_1.FlamingoSwapServiceNeo3(this.network, this);
|
|
40
61
|
}
|
|
41
62
|
setNetwork(network) {
|
|
42
63
|
__classPrivateFieldGet(this, _BSNeo3_instances, "m", _BSNeo3_setTokens).call(this, network);
|
|
@@ -62,11 +83,11 @@ class BSNeo3 {
|
|
|
62
83
|
}
|
|
63
84
|
generateAccountFromMnemonic(mnemonic, index) {
|
|
64
85
|
bs_asteroid_sdk_1.keychain.importMnemonic(Array.isArray(mnemonic) ? mnemonic.join(' ') : mnemonic);
|
|
65
|
-
const
|
|
66
|
-
const childKey = bs_asteroid_sdk_1.keychain.generateChildKey('neo',
|
|
86
|
+
const bip44Path = this.bip44DerivationPath.replace('?', index.toString());
|
|
87
|
+
const childKey = bs_asteroid_sdk_1.keychain.generateChildKey('neo', bip44Path);
|
|
67
88
|
const key = childKey.getWIF();
|
|
68
89
|
const { address } = new neon_js_1.wallet.Account(key);
|
|
69
|
-
return { address, key, type: 'wif',
|
|
90
|
+
return { address, key, type: 'wif', bip44Path };
|
|
70
91
|
}
|
|
71
92
|
generateAccountFromPublicKey(publicKey) {
|
|
72
93
|
if (!neon_js_1.wallet.isPublicKey(publicKey))
|
|
@@ -99,12 +120,12 @@ class BSNeo3 {
|
|
|
99
120
|
}
|
|
100
121
|
calculateTransferFee(param) {
|
|
101
122
|
return __awaiter(this, void 0, void 0, function* () {
|
|
102
|
-
const
|
|
123
|
+
const { neonJsAccount } = yield this.generateSigningCallback(param.senderAccount, param.isLedger);
|
|
103
124
|
const invoker = yield neon_dappkit_1.NeonInvoker.init({
|
|
104
125
|
rpcAddress: this.network.url,
|
|
105
|
-
account,
|
|
126
|
+
account: neonJsAccount,
|
|
106
127
|
});
|
|
107
|
-
const invocations = __classPrivateFieldGet(this, _BSNeo3_instances, "m", _BSNeo3_buildTransferInvocation).call(this, param,
|
|
128
|
+
const invocations = __classPrivateFieldGet(this, _BSNeo3_instances, "m", _BSNeo3_buildTransferInvocation).call(this, param, neonJsAccount);
|
|
108
129
|
const { total } = yield invoker.calculateFee({
|
|
109
130
|
invocations,
|
|
110
131
|
signers: [],
|
|
@@ -114,40 +135,26 @@ class BSNeo3 {
|
|
|
114
135
|
}
|
|
115
136
|
transfer(param) {
|
|
116
137
|
return __awaiter(this, void 0, void 0, function* () {
|
|
117
|
-
|
|
118
|
-
if (param.isLedger) {
|
|
119
|
-
if (!this.ledgerService.getLedgerTransport)
|
|
120
|
-
throw new Error('You must provide a getLedgerTransport function to use Ledger');
|
|
121
|
-
ledgerTransport = yield this.ledgerService.getLedgerTransport(param.senderAccount);
|
|
122
|
-
}
|
|
123
|
-
const account = new neon_js_1.wallet.Account(param.senderAccount.key);
|
|
138
|
+
const { neonJsAccount, signingCallback } = yield this.generateSigningCallback(param.senderAccount, param.isLedger);
|
|
124
139
|
const invoker = yield neon_dappkit_1.NeonInvoker.init({
|
|
125
140
|
rpcAddress: this.network.url,
|
|
126
|
-
account,
|
|
127
|
-
signingCallback:
|
|
141
|
+
account: neonJsAccount,
|
|
142
|
+
signingCallback: signingCallback,
|
|
128
143
|
});
|
|
129
|
-
const invocations = __classPrivateFieldGet(this, _BSNeo3_instances, "m", _BSNeo3_buildTransferInvocation).call(this, param,
|
|
144
|
+
const invocations = __classPrivateFieldGet(this, _BSNeo3_instances, "m", _BSNeo3_buildTransferInvocation).call(this, param, neonJsAccount);
|
|
130
145
|
const transactionHash = yield invoker.invokeFunction({
|
|
131
146
|
invocations,
|
|
132
147
|
signers: [],
|
|
133
148
|
});
|
|
134
|
-
return transactionHash;
|
|
149
|
+
return [transactionHash];
|
|
135
150
|
});
|
|
136
151
|
}
|
|
137
152
|
claim(account, isLedger) {
|
|
138
153
|
return __awaiter(this, void 0, void 0, function* () {
|
|
139
|
-
|
|
140
|
-
if (isLedger) {
|
|
141
|
-
if (!this.ledgerService.getLedgerTransport)
|
|
142
|
-
throw new Error('You must provide a getLedgerTransport function to use Ledger');
|
|
143
|
-
ledgerTransport = yield this.ledgerService.getLedgerTransport(account);
|
|
144
|
-
}
|
|
145
|
-
const neoAccount = new neon_js_1.wallet.Account(account.key);
|
|
154
|
+
const { neonJsAccount, signingCallback } = yield this.generateSigningCallback(account, isLedger);
|
|
146
155
|
const facade = yield neon_js_1.api.NetworkFacade.fromConfig({ node: this.network.url });
|
|
147
|
-
const transactionHash = yield facade.claimGas(
|
|
148
|
-
signingCallback:
|
|
149
|
-
? this.ledgerService.getSigningCallback(ledgerTransport)
|
|
150
|
-
: neon_js_1.api.signWithAccount(neoAccount),
|
|
156
|
+
const transactionHash = yield facade.claimGas(neonJsAccount, {
|
|
157
|
+
signingCallback: signingCallback,
|
|
151
158
|
});
|
|
152
159
|
return transactionHash;
|
|
153
160
|
});
|
|
@@ -160,7 +167,7 @@ class BSNeo3 {
|
|
|
160
167
|
const response = yield invoker.testInvoke({
|
|
161
168
|
invocations: [
|
|
162
169
|
{
|
|
163
|
-
scriptHash:
|
|
170
|
+
scriptHash: BSNeo3Constants_1.BSNeo3Constants.NEO_NS_HASH,
|
|
164
171
|
operation: 'ownerOf',
|
|
165
172
|
args: [{ type: 'String', value: domainName }],
|
|
166
173
|
},
|
|
@@ -184,9 +191,9 @@ _BSNeo3_instances = new WeakSet(), _BSNeo3_setTokens = function _BSNeo3_setToken
|
|
|
184
191
|
this.feeToken = tokens.find(token => token.symbol === 'GAS');
|
|
185
192
|
this.burnToken = tokens.find(token => token.symbol === 'NEO');
|
|
186
193
|
this.claimToken = tokens.find(token => token.symbol === 'GAS');
|
|
187
|
-
}, _BSNeo3_buildTransferInvocation = function _BSNeo3_buildTransferInvocation({
|
|
188
|
-
const
|
|
189
|
-
const invocations =
|
|
194
|
+
}, _BSNeo3_buildTransferInvocation = function _BSNeo3_buildTransferInvocation({ intents, tipIntent }, account) {
|
|
195
|
+
const concatIntents = [...intents, ...(tipIntent ? [tipIntent] : [])];
|
|
196
|
+
const invocations = concatIntents.map(intent => {
|
|
190
197
|
return {
|
|
191
198
|
operation: 'transfer',
|
|
192
199
|
scriptHash: intent.tokenHash,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SwapServiceSwapToReceiveArgs, SwapServiceSwapToUseArgs } from '@cityofzion/blockchain-service';
|
|
2
2
|
import { ContractInvocationMulti } from '@cityofzion/neon-dappkit-types';
|
|
3
|
-
import { BSNeo3NetworkId } from '../../
|
|
3
|
+
import { BSNeo3NetworkId } from '../../constants/BSNeo3Constants';
|
|
4
4
|
export declare class FlamingoSwapInvocationBuilderNeo3 {
|
|
5
5
|
#private;
|
|
6
6
|
static swapInvocation(data: SwapServiceSwapToReceiveArgs<BSNeo3NetworkId> | SwapServiceSwapToUseArgs<BSNeo3NetworkId>): ContractInvocationMulti;
|
|
@@ -23,9 +23,10 @@ _a = FlamingoSwapInvocationBuilderNeo3, _FlamingoSwapInvocationBuilderNeo3_build
|
|
|
23
23
|
const [tokenToUse] = routePath;
|
|
24
24
|
const tokenToReceive = routePath[routePath.length - 1];
|
|
25
25
|
const scriptHashes = FlamingoSwapHelper_1.FlamingoSwapHelper.getFlamingoSwapScriptHashes(network);
|
|
26
|
-
const tokenToReceiveOverrode = FlamingoSwapHelper_1.FlamingoSwapHelper.overrideToken(network, tokenToReceive);
|
|
27
26
|
const invocations = [];
|
|
28
|
-
const allowedContracts =
|
|
27
|
+
const allowedContracts = [];
|
|
28
|
+
const tokenToReceiveOverrode = FlamingoSwapHelper_1.FlamingoSwapHelper.overrideToken(network, tokenToReceive);
|
|
29
|
+
const routePathOverrode = FlamingoSwapHelper_1.FlamingoSwapHelper.overrideRoutePath(network, routePath);
|
|
29
30
|
const amountToReceiveFormatted = FlamingoSwapHelper_1.FlamingoSwapHelper.formatAmount(amountToReceive, tokenToReceiveOverrode.decimals);
|
|
30
31
|
const maximumSellingFormatted = FlamingoSwapHelper_1.FlamingoSwapHelper.formatAmount(maximumSelling, tokenToUse.decimals);
|
|
31
32
|
const swapInvocation = NeonDappKitInvocationBuilderNeo3_1.NeonDappKitInvocationBuilderNeo3.swapTokenOutForTokenInContractInvocation({
|
|
@@ -34,13 +35,16 @@ _a = FlamingoSwapInvocationBuilderNeo3, _FlamingoSwapInvocationBuilderNeo3_build
|
|
|
34
35
|
amountToReceive: amountToReceiveFormatted,
|
|
35
36
|
maximumSelling: maximumSellingFormatted,
|
|
36
37
|
deadline,
|
|
37
|
-
args: __classPrivateFieldGet(this, _a, "m", _FlamingoSwapInvocationBuilderNeo3_mapRoutePathToArgs).call(this,
|
|
38
|
+
args: __classPrivateFieldGet(this, _a, "m", _FlamingoSwapInvocationBuilderNeo3_mapRoutePathToArgs).call(this, routePathOverrode),
|
|
38
39
|
});
|
|
39
40
|
invocations.push(swapInvocation);
|
|
41
|
+
allowedContracts.push(...__classPrivateFieldGet(this, _a, "m", _FlamingoSwapInvocationBuilderNeo3_getAllowedContracts).call(this, scriptHashes, routePath));
|
|
40
42
|
if (FlamingoSwapHelper_1.FlamingoSwapHelper.isNeoToken(network, tokenToReceive)) {
|
|
41
43
|
const amountToReceiveTransfer = neon_core_1.u.BigInteger.fromNumber(Number(amountToReceiveFormatted) * FlamingoSwapConstants_1.FlamingoSwapConstants.GAS_PER_NEO).toString();
|
|
42
|
-
const
|
|
44
|
+
const gasHash = FlamingoSwapHelper_1.FlamingoSwapHelper.getFlamingoSwapToken(network, 'GAS').hash;
|
|
45
|
+
const neoTransferInvocation = __classPrivateFieldGet(this, _a, "m", _FlamingoSwapInvocationBuilderNeo3_buildNEOTransferInvocation).call(this, address, gasHash, amountToReceiveTransfer, network);
|
|
43
46
|
invocations.push(neoTransferInvocation);
|
|
47
|
+
allowedContracts.push(FlamingoSwapHelper_1.FlamingoSwapHelper.getFlamingoSwapPool(network, 'FLP-bNEO-GAS').hash);
|
|
44
48
|
}
|
|
45
49
|
return {
|
|
46
50
|
invocations,
|
|
@@ -51,12 +55,16 @@ _a = FlamingoSwapInvocationBuilderNeo3, _FlamingoSwapInvocationBuilderNeo3_build
|
|
|
51
55
|
const tokenToReceive = routePath[routePath.length - 1];
|
|
52
56
|
const scriptHashes = FlamingoSwapHelper_1.FlamingoSwapHelper.getFlamingoSwapScriptHashes(network);
|
|
53
57
|
const invocations = [];
|
|
54
|
-
const allowedContracts =
|
|
58
|
+
const allowedContracts = [];
|
|
55
59
|
if (FlamingoSwapHelper_1.FlamingoSwapHelper.isNeoToken(network, tokenToUse)) {
|
|
56
|
-
const
|
|
60
|
+
const neoHash = FlamingoSwapHelper_1.FlamingoSwapHelper.getFlamingoSwapToken(network, 'NEO').hash;
|
|
61
|
+
const neoTransferInvocation = __classPrivateFieldGet(this, _a, "m", _FlamingoSwapInvocationBuilderNeo3_buildNEOTransferInvocation).call(this, address, neoHash, amountToUse, network);
|
|
57
62
|
invocations.push(neoTransferInvocation);
|
|
63
|
+
allowedContracts.push(FlamingoSwapHelper_1.FlamingoSwapHelper.getFlamingoSwapPool(network, 'FLP-bNEO-GAS').hash);
|
|
58
64
|
}
|
|
59
|
-
const
|
|
65
|
+
const tokenToUseOverrode = FlamingoSwapHelper_1.FlamingoSwapHelper.overrideToken(network, tokenToUse);
|
|
66
|
+
const routePathOverrode = FlamingoSwapHelper_1.FlamingoSwapHelper.overrideRoutePath(network, routePath);
|
|
67
|
+
const amountToUseFormatted = FlamingoSwapHelper_1.FlamingoSwapHelper.formatAmount(amountToUse, tokenToUseOverrode.decimals);
|
|
60
68
|
const minimumReceivedFormatted = FlamingoSwapHelper_1.FlamingoSwapHelper.formatAmount(minimumReceived, tokenToReceive.decimals);
|
|
61
69
|
const swapInvocation = NeonDappKitInvocationBuilderNeo3_1.NeonDappKitInvocationBuilderNeo3.swapTokenInForTokenOutContractInvocation({
|
|
62
70
|
routerScriptHash: scriptHashes.flamingoSwapRouter,
|
|
@@ -64,9 +72,10 @@ _a = FlamingoSwapInvocationBuilderNeo3, _FlamingoSwapInvocationBuilderNeo3_build
|
|
|
64
72
|
minimumReceived: minimumReceivedFormatted,
|
|
65
73
|
senderAddress: address,
|
|
66
74
|
deadline,
|
|
67
|
-
args: __classPrivateFieldGet(this, _a, "m", _FlamingoSwapInvocationBuilderNeo3_mapRoutePathToArgs).call(this,
|
|
75
|
+
args: __classPrivateFieldGet(this, _a, "m", _FlamingoSwapInvocationBuilderNeo3_mapRoutePathToArgs).call(this, routePathOverrode),
|
|
68
76
|
});
|
|
69
77
|
invocations.push(swapInvocation);
|
|
78
|
+
allowedContracts.push(...__classPrivateFieldGet(this, _a, "m", _FlamingoSwapInvocationBuilderNeo3_getAllowedContracts).call(this, scriptHashes, routePath));
|
|
70
79
|
return {
|
|
71
80
|
invocations,
|
|
72
81
|
signers: [{ scopes: neon_core_1.tx.WitnessScope.CustomContracts, allowedContracts }],
|
|
@@ -83,13 +92,12 @@ _a = FlamingoSwapInvocationBuilderNeo3, _FlamingoSwapInvocationBuilderNeo3_build
|
|
|
83
92
|
scriptHashes.flamingoPairWhiteList,
|
|
84
93
|
...routePath.map(token => token.hash),
|
|
85
94
|
];
|
|
86
|
-
}, _FlamingoSwapInvocationBuilderNeo3_buildNEOTransferInvocation = function _FlamingoSwapInvocationBuilderNeo3_buildNEOTransferInvocation(
|
|
95
|
+
}, _FlamingoSwapInvocationBuilderNeo3_buildNEOTransferInvocation = function _FlamingoSwapInvocationBuilderNeo3_buildNEOTransferInvocation(senderAddress, contractHash, amount, network) {
|
|
87
96
|
const bNEO = FlamingoSwapHelper_1.FlamingoSwapHelper.getFlamingoSwapToken(network, 'bNEO');
|
|
88
|
-
const GAS = FlamingoSwapHelper_1.FlamingoSwapHelper.getFlamingoSwapToken(network, 'GAS');
|
|
89
97
|
return NeonDappKitInvocationBuilderNeo3_1.NeonDappKitInvocationBuilderNeo3.transferContractInvocation({
|
|
90
|
-
|
|
91
|
-
amount,
|
|
98
|
+
contractHash,
|
|
92
99
|
tokenHash: bNEO.hash,
|
|
93
|
-
|
|
100
|
+
senderAddress,
|
|
101
|
+
amount,
|
|
94
102
|
});
|
|
95
103
|
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Network, NetworkId, Token } from '@cityofzion/blockchain-service';
|
|
2
|
+
export type BSNeo3NetworkId = NetworkId<'mainnet' | 'testnet'>;
|
|
3
|
+
export declare class BSNeo3Constants {
|
|
4
|
+
static EXTRA_TOKENS_BY_NETWORK_ID: Partial<Record<BSNeo3NetworkId, Token[]>>;
|
|
5
|
+
static RPC_LIST_BY_NETWORK_ID: Partial<Record<BSNeo3NetworkId, string[]>>;
|
|
6
|
+
static MAINNET_NETWORK_IDS: BSNeo3NetworkId[];
|
|
7
|
+
static TESTNET_NETWORK_IDS: BSNeo3NetworkId[];
|
|
8
|
+
static ALL_NETWORK_IDS: BSNeo3NetworkId[];
|
|
9
|
+
static MAINNET_NETWORKS: Network<BSNeo3NetworkId>[];
|
|
10
|
+
static TESTNET_NETWORKS: Network<BSNeo3NetworkId>[];
|
|
11
|
+
static ALL_NETWORKS: Network<BSNeo3NetworkId>[];
|
|
12
|
+
static DEFAULT_NETWORK: Network<BSNeo3NetworkId>;
|
|
13
|
+
static NEO_NS_HASH: string;
|
|
14
|
+
static DEFAULT_BIP44_DERIVATION_PATH: string;
|
|
15
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
var _a;
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.BSNeo3Constants = void 0;
|
|
8
|
+
const mainnet_json_1 = __importDefault(require("../assets/tokens/mainnet.json"));
|
|
9
|
+
class BSNeo3Constants {
|
|
10
|
+
}
|
|
11
|
+
exports.BSNeo3Constants = BSNeo3Constants;
|
|
12
|
+
_a = BSNeo3Constants;
|
|
13
|
+
BSNeo3Constants.EXTRA_TOKENS_BY_NETWORK_ID = {
|
|
14
|
+
mainnet: mainnet_json_1.default,
|
|
15
|
+
};
|
|
16
|
+
BSNeo3Constants.RPC_LIST_BY_NETWORK_ID = {
|
|
17
|
+
mainnet: [
|
|
18
|
+
'https://mainnet1.neo.coz.io:443',
|
|
19
|
+
'https://mainnet4.neo.coz.io:443',
|
|
20
|
+
'http://seed1.neo.org:10332',
|
|
21
|
+
'http://seed2.neo.org:10332',
|
|
22
|
+
'https://mainnet2.neo.coz.io:443',
|
|
23
|
+
'https://mainnet5.neo.coz.io:443',
|
|
24
|
+
'https://mainnet3.neo.coz.io:443',
|
|
25
|
+
'https://rpc10.n3.nspcc.ru:10331',
|
|
26
|
+
'https://neo1-nodes.ghostmarket.io:443',
|
|
27
|
+
],
|
|
28
|
+
testnet: [
|
|
29
|
+
'https://testnet1.neo.coz.io:443',
|
|
30
|
+
'https://testnet2.neo.coz.io:443',
|
|
31
|
+
'https://rpc.t5.n3.nspcc.ru:20331',
|
|
32
|
+
'http://seed1t5.neo.org:20332',
|
|
33
|
+
'http://seed2t5.neo.org:20332',
|
|
34
|
+
'http://seed3t5.neo.org:20332',
|
|
35
|
+
'http://seed4t5.neo.org:20332',
|
|
36
|
+
'http://seed5t5.neo.org:20332',
|
|
37
|
+
],
|
|
38
|
+
};
|
|
39
|
+
BSNeo3Constants.MAINNET_NETWORK_IDS = ['mainnet'];
|
|
40
|
+
BSNeo3Constants.TESTNET_NETWORK_IDS = ['testnet'];
|
|
41
|
+
BSNeo3Constants.ALL_NETWORK_IDS = [..._a.MAINNET_NETWORK_IDS, ..._a.TESTNET_NETWORK_IDS];
|
|
42
|
+
BSNeo3Constants.MAINNET_NETWORKS = [
|
|
43
|
+
{
|
|
44
|
+
id: 'mainnet',
|
|
45
|
+
name: 'Mainnet',
|
|
46
|
+
url: _a.RPC_LIST_BY_NETWORK_ID['mainnet'][0],
|
|
47
|
+
},
|
|
48
|
+
];
|
|
49
|
+
BSNeo3Constants.TESTNET_NETWORKS = [
|
|
50
|
+
{
|
|
51
|
+
id: 'testnet',
|
|
52
|
+
name: 'Testnet',
|
|
53
|
+
url: _a.RPC_LIST_BY_NETWORK_ID['testnet'][0],
|
|
54
|
+
},
|
|
55
|
+
];
|
|
56
|
+
BSNeo3Constants.ALL_NETWORKS = [..._a.MAINNET_NETWORKS, ..._a.TESTNET_NETWORKS];
|
|
57
|
+
BSNeo3Constants.DEFAULT_NETWORK = _a.MAINNET_NETWORKS[0];
|
|
58
|
+
BSNeo3Constants.NEO_NS_HASH = '0x50ac1c37690cc2cfc594472833cf57505d5f46de';
|
|
59
|
+
BSNeo3Constants.DEFAULT_BIP44_DERIVATION_PATH = "m/44'/888'/0'/0/?";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Token } from '@cityofzion/blockchain-service';
|
|
2
2
|
import BigNumber from 'bignumber.js';
|
|
3
|
-
import { BSNeo3NetworkId } from '
|
|
3
|
+
import { BSNeo3NetworkId } from './BSNeo3Constants';
|
|
4
4
|
export type FlamingoSwapScriptHashes = {
|
|
5
5
|
flamingoSwapRouter: string;
|
|
6
6
|
flamingoPairWhiteList: string;
|
|
@@ -178,12 +178,6 @@ FlamingoSwapConstants.MAINNET_FLAMINGO_SWAP_TOKENS = {
|
|
|
178
178
|
hash: '0x8c07b4c9f5bc170a3922eac4f5bb7ef17b0acc8b',
|
|
179
179
|
name: 'LRB',
|
|
180
180
|
},
|
|
181
|
-
USDL: {
|
|
182
|
-
symbol: 'USDL',
|
|
183
|
-
decimals: 8,
|
|
184
|
-
hash: '0xa8c51aa0c177187aeed3db88bdfa908ccbc9b1a5',
|
|
185
|
-
name: 'USDL',
|
|
186
|
-
},
|
|
187
181
|
SOM: {
|
|
188
182
|
symbol: 'SOM',
|
|
189
183
|
decimals: 8,
|
|
@@ -666,12 +660,6 @@ FlamingoSwapConstants.MAINNET_FLAMINGO_SWAP_POOLS = {
|
|
|
666
660
|
hash: '0x1f86bab6d548a3bd4e9292be0937c074da78ab77',
|
|
667
661
|
tokens: [_a.FLAMINGO_SWAP_TOKENS.mainnet.LRB, _a.FLAMINGO_SWAP_TOKENS.mainnet.FLM],
|
|
668
662
|
},
|
|
669
|
-
'FRP-FLM-USDL': {
|
|
670
|
-
symbol: 'FRP-FLM-USDL',
|
|
671
|
-
decimals: 8,
|
|
672
|
-
hash: '0x33a1e91d8187d6f62b5b2c9847b450c90d770b32',
|
|
673
|
-
tokens: [_a.FLAMINGO_SWAP_TOKENS.mainnet.USDL, _a.FLAMINGO_SWAP_TOKENS.mainnet.FLM],
|
|
674
|
-
},
|
|
675
663
|
'FLP-FLM-FUSD': {
|
|
676
664
|
symbol: 'FLP-FLM-FUSD',
|
|
677
665
|
decimals: 8,
|
|
@@ -1,22 +1,7 @@
|
|
|
1
|
-
import { Network
|
|
2
|
-
|
|
1
|
+
import { Network } from '@cityofzion/blockchain-service';
|
|
2
|
+
import { BSNeo3NetworkId } from '../constants/BSNeo3Constants';
|
|
3
3
|
export declare class BSNeo3Helper {
|
|
4
|
-
|
|
5
|
-
static MAINNET_NETWORK_IDS: BSNeo3NetworkId[];
|
|
6
|
-
static TESTNET_NETWORK_IDS: BSNeo3NetworkId[];
|
|
7
|
-
static ALL_NETWORK_IDS: BSNeo3NetworkId[];
|
|
8
|
-
static MAINNET_NETWORKS: Network<BSNeo3NetworkId>[];
|
|
9
|
-
static TESTNET_NETWORKS: Network<BSNeo3NetworkId>[];
|
|
10
|
-
static ALL_NETWORKS: Network<BSNeo3NetworkId>[];
|
|
11
|
-
static DEFAULT_NETWORK: Network<BSNeo3NetworkId>;
|
|
12
|
-
static NEO_NS_HASH: string;
|
|
13
|
-
static DERIVATION_PATH: string;
|
|
14
|
-
static getTokens(network: Network<BSNeo3NetworkId>): {
|
|
15
|
-
symbol: string;
|
|
16
|
-
name: string;
|
|
17
|
-
hash: string;
|
|
18
|
-
decimals: number;
|
|
19
|
-
}[];
|
|
4
|
+
static getTokens(network: Network<BSNeo3NetworkId>): import("@cityofzion/blockchain-service").Token[];
|
|
20
5
|
static getRpcList(network: Network<BSNeo3NetworkId>): string[];
|
|
21
6
|
static isMainnet(network: Network<BSNeo3NetworkId>): boolean;
|
|
22
7
|
static isCustomNet(network: Network<BSNeo3NetworkId>): boolean;
|
|
@@ -1,83 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
3
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
4
|
-
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");
|
|
5
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
6
|
-
};
|
|
7
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
8
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
9
4
|
};
|
|
10
|
-
var _a, _BSNeo3Helper_EXTRA_TOKENS_BY_NETWORK_ID, _BSNeo3Helper_RPC_LIST_BY_NETWORK_ID;
|
|
11
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
6
|
exports.BSNeo3Helper = void 0;
|
|
13
7
|
const common_json_1 = __importDefault(require("../assets/tokens/common.json"));
|
|
14
|
-
const
|
|
8
|
+
const BSNeo3Constants_1 = require("../constants/BSNeo3Constants");
|
|
15
9
|
class BSNeo3Helper {
|
|
16
10
|
static getTokens(network) {
|
|
17
|
-
var
|
|
18
|
-
const extraTokens = (
|
|
11
|
+
var _a;
|
|
12
|
+
const extraTokens = (_a = BSNeo3Constants_1.BSNeo3Constants.EXTRA_TOKENS_BY_NETWORK_ID[network.id]) !== null && _a !== void 0 ? _a : [];
|
|
19
13
|
return [...extraTokens, ...common_json_1.default];
|
|
20
14
|
}
|
|
21
15
|
static getRpcList(network) {
|
|
22
|
-
var
|
|
23
|
-
return (
|
|
16
|
+
var _a;
|
|
17
|
+
return (_a = BSNeo3Constants_1.BSNeo3Constants.RPC_LIST_BY_NETWORK_ID[network.id]) !== null && _a !== void 0 ? _a : [];
|
|
24
18
|
}
|
|
25
19
|
static isMainnet(network) {
|
|
26
|
-
return
|
|
20
|
+
return BSNeo3Constants_1.BSNeo3Constants.MAINNET_NETWORK_IDS.includes(network.id);
|
|
27
21
|
}
|
|
28
22
|
static isCustomNet(network) {
|
|
29
|
-
return !
|
|
23
|
+
return !BSNeo3Constants_1.BSNeo3Constants.ALL_NETWORK_IDS.includes(network.id);
|
|
30
24
|
}
|
|
31
25
|
static normalizeHash(hash) {
|
|
32
26
|
return hash.startsWith('0x') ? hash.slice(2) : hash;
|
|
33
27
|
}
|
|
34
28
|
}
|
|
35
29
|
exports.BSNeo3Helper = BSNeo3Helper;
|
|
36
|
-
_a = BSNeo3Helper;
|
|
37
|
-
_BSNeo3Helper_EXTRA_TOKENS_BY_NETWORK_ID = { value: {
|
|
38
|
-
mainnet: mainnet_json_1.default,
|
|
39
|
-
} };
|
|
40
|
-
_BSNeo3Helper_RPC_LIST_BY_NETWORK_ID = { value: {
|
|
41
|
-
mainnet: [
|
|
42
|
-
'https://mainnet1.neo.coz.io:443',
|
|
43
|
-
'https://mainnet4.neo.coz.io:443',
|
|
44
|
-
'http://seed1.neo.org:10332',
|
|
45
|
-
'http://seed2.neo.org:10332',
|
|
46
|
-
'https://mainnet2.neo.coz.io:443',
|
|
47
|
-
'https://mainnet5.neo.coz.io:443',
|
|
48
|
-
'https://mainnet3.neo.coz.io:443',
|
|
49
|
-
'https://rpc10.n3.nspcc.ru:10331',
|
|
50
|
-
'https://neo1-nodes.ghostmarket.io:443',
|
|
51
|
-
],
|
|
52
|
-
testnet: [
|
|
53
|
-
'https://testnet1.neo.coz.io:443',
|
|
54
|
-
'https://testnet2.neo.coz.io:443',
|
|
55
|
-
'https://rpc.t5.n3.nspcc.ru:20331',
|
|
56
|
-
'http://seed1t5.neo.org:20332',
|
|
57
|
-
'http://seed2t5.neo.org:20332',
|
|
58
|
-
'http://seed3t5.neo.org:20332',
|
|
59
|
-
'http://seed4t5.neo.org:20332',
|
|
60
|
-
'http://seed5t5.neo.org:20332',
|
|
61
|
-
],
|
|
62
|
-
} };
|
|
63
|
-
BSNeo3Helper.MAINNET_NETWORK_IDS = ['mainnet'];
|
|
64
|
-
BSNeo3Helper.TESTNET_NETWORK_IDS = ['testnet'];
|
|
65
|
-
BSNeo3Helper.ALL_NETWORK_IDS = [..._a.MAINNET_NETWORK_IDS, ..._a.TESTNET_NETWORK_IDS];
|
|
66
|
-
BSNeo3Helper.MAINNET_NETWORKS = [
|
|
67
|
-
{
|
|
68
|
-
id: 'mainnet',
|
|
69
|
-
name: 'Mainnet',
|
|
70
|
-
url: __classPrivateFieldGet(_a, _a, "f", _BSNeo3Helper_RPC_LIST_BY_NETWORK_ID)['mainnet'][0],
|
|
71
|
-
},
|
|
72
|
-
];
|
|
73
|
-
BSNeo3Helper.TESTNET_NETWORKS = [
|
|
74
|
-
{
|
|
75
|
-
id: 'testnet',
|
|
76
|
-
name: 'Testnet',
|
|
77
|
-
url: __classPrivateFieldGet(_a, _a, "f", _BSNeo3Helper_RPC_LIST_BY_NETWORK_ID)['testnet'][0],
|
|
78
|
-
},
|
|
79
|
-
];
|
|
80
|
-
BSNeo3Helper.ALL_NETWORKS = [..._a.MAINNET_NETWORKS, ..._a.TESTNET_NETWORKS];
|
|
81
|
-
BSNeo3Helper.DEFAULT_NETWORK = _a.MAINNET_NETWORKS[0];
|
|
82
|
-
BSNeo3Helper.NEO_NS_HASH = '0x50ac1c37690cc2cfc594472833cf57505d5f46de';
|
|
83
|
-
BSNeo3Helper.DERIVATION_PATH = "m/44'/888'/0'/0/?";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Network, SwapRoute, Token } from '@cityofzion/blockchain-service';
|
|
2
2
|
import BigNumber from 'bignumber.js';
|
|
3
3
|
import { FlamingoSwapPoolInfo, FlamingoSwapPools, FlamingoSwapScriptHashes, FlamingoSwapTokens } from '../constants/FlamingoSwapConstants';
|
|
4
|
-
import { BSNeo3NetworkId } from '
|
|
4
|
+
import { BSNeo3NetworkId } from '../constants/BSNeo3Constants';
|
|
5
5
|
export declare class FlamingoSwapHelper {
|
|
6
6
|
static listSwappableTokensSymbol(network: Network<BSNeo3NetworkId>): string[];
|
|
7
7
|
static getFlamingoSwapPools(network: Network<BSNeo3NetworkId>): FlamingoSwapPools;
|
|
@@ -14,6 +14,7 @@ export declare class FlamingoSwapHelper {
|
|
|
14
14
|
static overrideAmountInput(network: Network<BSNeo3NetworkId>, amount: string, token: Token): BigNumber;
|
|
15
15
|
static overrideAmountToDisplay(network: Network<BSNeo3NetworkId>, amount: string, token: Token): string;
|
|
16
16
|
static overrideRoute(network: Network<BSNeo3NetworkId>, route: SwapRoute[]): SwapRoute[];
|
|
17
|
+
static overrideRoutePath(network: Network<BSNeo3NetworkId>, routePath: Token[]): Token[];
|
|
17
18
|
static normalizeHash(hash: string): string;
|
|
18
19
|
static isNeoToken(network: Network<BSNeo3NetworkId>, token: Token): boolean;
|
|
19
20
|
static formatAmount(amount: string, decimals: number): string;
|
|
@@ -74,6 +74,10 @@ class FlamingoSwapHelper {
|
|
|
74
74
|
}
|
|
75
75
|
return overrodeRoute;
|
|
76
76
|
}
|
|
77
|
+
static overrideRoutePath(network, routePath) {
|
|
78
|
+
const overrodeRoutePath = routePath.map(token => this.overrideToken(network, token));
|
|
79
|
+
return overrodeRoutePath.filter((item, index, arr) => arr.indexOf(item) === index);
|
|
80
|
+
}
|
|
77
81
|
static normalizeHash(hash) {
|
|
78
82
|
return hash.startsWith('0x') ? hash.slice(2) : hash;
|
|
79
83
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BalanceResponse, ContractResponse, Network, Token, TransactionResponse, TransactionsByAddressParams, TransactionsByAddressResponse } from '@cityofzion/blockchain-service';
|
|
2
|
-
import { BSNeo3NetworkId } from '../../helpers/BSNeo3Helper';
|
|
3
2
|
import { RpcBDSNeo3 } from './RpcBDSNeo3';
|
|
3
|
+
import { BSNeo3NetworkId } from '../../constants/BSNeo3Constants';
|
|
4
4
|
export declare class DoraBDSNeo3 extends RpcBDSNeo3 {
|
|
5
5
|
constructor(network: Network<BSNeo3NetworkId>, feeToken: Token, claimToken: Token, tokens: Token[]);
|
|
6
6
|
getTransaction(hash: string): Promise<TransactionResponse>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BDSClaimable, BalanceResponse, BlockchainDataService, ContractResponse, Network, RpcResponse, Token, TransactionResponse, TransactionsByAddressParams, TransactionsByAddressResponse } from '@cityofzion/blockchain-service';
|
|
2
|
-
import { BSNeo3NetworkId } from '../../
|
|
2
|
+
import { BSNeo3NetworkId } from '../../constants/BSNeo3Constants';
|
|
3
3
|
export declare class RpcBDSNeo3 implements BlockchainDataService, BDSClaimable {
|
|
4
4
|
readonly _tokenCache: Map<string, Token>;
|
|
5
5
|
readonly _feeToken: Token;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CryptoCompareEDS, ExchangeDataService, GetTokenPriceHistoryParams, GetTokenPricesParams, Network, TokenPricesHistoryResponse, TokenPricesResponse } from '@cityofzion/blockchain-service';
|
|
2
|
-
import { BSNeo3NetworkId } from '../../
|
|
2
|
+
import { BSNeo3NetworkId } from '../../constants/BSNeo3Constants';
|
|
3
3
|
export declare class FlamingoEDSNeo3 extends CryptoCompareEDS implements ExchangeDataService {
|
|
4
4
|
#private;
|
|
5
5
|
constructor(network: Network<BSNeo3NetworkId>);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BuildNftUrlParams, ExplorerService, Network } from '@cityofzion/blockchain-service';
|
|
2
|
-
import { BSNeo3NetworkId } from '../../
|
|
2
|
+
import { BSNeo3NetworkId } from '../../constants/BSNeo3Constants';
|
|
3
3
|
export declare class DoraESNeo3 implements ExplorerService {
|
|
4
4
|
#private;
|
|
5
5
|
constructor(network: Network<BSNeo3NetworkId>);
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { Account, LedgerService, LedgerServiceEmitter } from '@cityofzion/blockchain-service';
|
|
2
2
|
import { api } from '@cityofzion/neon-js';
|
|
3
3
|
import Transport from '@ledgerhq/hw-transport';
|
|
4
|
+
import { BSNeo3 } from '../../BSNeo3';
|
|
4
5
|
export declare class NeonDappKitLedgerServiceNeo3 implements LedgerService {
|
|
5
6
|
#private;
|
|
6
|
-
getLedgerTransport?: ((account: Account) => Promise<Transport>) | undefined;
|
|
7
7
|
emitter: LedgerServiceEmitter;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
getLedgerTransport?: (account: Account) => Promise<Transport>;
|
|
9
|
+
constructor(blockchainService: BSNeo3, getLedgerTransport?: (account: Account) => Promise<Transport>);
|
|
10
|
+
getAccount(transport: Transport, index: number): Promise<Account>;
|
|
11
|
+
getAccounts(transport: Transport): Promise<Account[]>;
|
|
12
|
+
getSigningCallback(transport: Transport, account: Account): api.SigningFunction;
|
|
13
13
|
}
|
|
@@ -8,6 +8,12 @@ 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 __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
12
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
13
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
14
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
15
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
16
|
+
};
|
|
11
17
|
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
12
18
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
13
19
|
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");
|
|
@@ -16,9 +22,10 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
16
22
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
23
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
24
|
};
|
|
19
|
-
var _NeonDappKitLedgerServiceNeo3_instances,
|
|
25
|
+
var _NeonDappKitLedgerServiceNeo3_instances, _NeonDappKitLedgerServiceNeo3_blockchainService, _NeonDappKitLedgerServiceNeo3_sendChunk, _NeonDappKitLedgerServiceNeo3_bip44PathToHex, _NeonDappKitLedgerServiceNeo3_derSignatureToHex;
|
|
20
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
27
|
exports.NeonDappKitLedgerServiceNeo3 = void 0;
|
|
28
|
+
const blockchain_service_1 = require("@cityofzion/blockchain-service");
|
|
22
29
|
const neon_dappkit_1 = require("@cityofzion/neon-dappkit");
|
|
23
30
|
const neon_js_1 = require("@cityofzion/neon-js");
|
|
24
31
|
const events_1 = __importDefault(require("events"));
|
|
@@ -37,50 +44,69 @@ var LedgerSecondParameter;
|
|
|
37
44
|
LedgerSecondParameter[LedgerSecondParameter["LAST_DATA"] = 0] = "LAST_DATA";
|
|
38
45
|
})(LedgerSecondParameter || (LedgerSecondParameter = {}));
|
|
39
46
|
class NeonDappKitLedgerServiceNeo3 {
|
|
40
|
-
constructor(getLedgerTransport) {
|
|
41
|
-
this.getLedgerTransport = getLedgerTransport;
|
|
47
|
+
constructor(blockchainService, getLedgerTransport) {
|
|
42
48
|
_NeonDappKitLedgerServiceNeo3_instances.add(this);
|
|
49
|
+
_NeonDappKitLedgerServiceNeo3_blockchainService.set(this, void 0);
|
|
43
50
|
this.emitter = new events_1.default();
|
|
51
|
+
__classPrivateFieldSet(this, _NeonDappKitLedgerServiceNeo3_blockchainService, blockchainService, "f");
|
|
52
|
+
this.getLedgerTransport = getLedgerTransport;
|
|
44
53
|
}
|
|
45
|
-
|
|
54
|
+
getAccount(transport, index) {
|
|
46
55
|
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
-
const
|
|
56
|
+
const bip44Path = __classPrivateFieldGet(this, _NeonDappKitLedgerServiceNeo3_blockchainService, "f").bip44DerivationPath.replace('?', index.toString());
|
|
57
|
+
const bip44PathHex = __classPrivateFieldGet(this, _NeonDappKitLedgerServiceNeo3_instances, "m", _NeonDappKitLedgerServiceNeo3_bip44PathToHex).call(this, bip44Path);
|
|
58
|
+
const result = yield __classPrivateFieldGet(this, _NeonDappKitLedgerServiceNeo3_instances, "m", _NeonDappKitLedgerServiceNeo3_sendChunk).call(this, transport, LedgerCommand.GET_PUBLIC_KEY, 0x00, LedgerSecondParameter.LAST_DATA, bip44PathHex);
|
|
59
|
+
const publicKey = result.toString('hex').substring(0, 130);
|
|
48
60
|
const { address } = new neon_js_1.wallet.Account(publicKey);
|
|
49
|
-
return
|
|
61
|
+
return {
|
|
62
|
+
address,
|
|
63
|
+
key: publicKey,
|
|
64
|
+
type: 'publicKey',
|
|
65
|
+
bip44Path,
|
|
66
|
+
};
|
|
50
67
|
});
|
|
51
68
|
}
|
|
52
|
-
|
|
53
|
-
return
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
const signature = yield this.getSignature(transport, transaction.serialize(false), network, witnessIndex);
|
|
61
|
-
return signature;
|
|
69
|
+
getAccounts(transport) {
|
|
70
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
71
|
+
const accountsByBlockchainService = yield (0, blockchain_service_1.fetchAccountsForBlockchainServices)([__classPrivateFieldGet(this, _NeonDappKitLedgerServiceNeo3_blockchainService, "f")], (_service, index) => __awaiter(this, void 0, void 0, function* () {
|
|
72
|
+
return this.getAccount(transport, index);
|
|
73
|
+
}));
|
|
74
|
+
const accounts = accountsByBlockchainService.get(__classPrivateFieldGet(this, _NeonDappKitLedgerServiceNeo3_blockchainService, "f").blockchainName);
|
|
75
|
+
return accounts !== null && accounts !== void 0 ? accounts : [];
|
|
62
76
|
});
|
|
63
77
|
}
|
|
64
|
-
|
|
65
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
78
|
+
getSigningCallback(transport, account) {
|
|
79
|
+
return (transaction, { witnessIndex, network }) => __awaiter(this, void 0, void 0, function* () {
|
|
66
80
|
try {
|
|
67
81
|
this.emitter.emit('getSignatureStart');
|
|
68
|
-
|
|
82
|
+
if (!account.bip44Path) {
|
|
83
|
+
throw new Error('Account must have a bip 44 path to sign with Ledger');
|
|
84
|
+
}
|
|
85
|
+
const neonJsAccount = new neon_js_1.wallet.Account(account.key);
|
|
86
|
+
const witnessScriptHash = neon_js_1.wallet.getScriptHashFromVerificationScript(transaction.witnesses[witnessIndex].verificationScript.toString());
|
|
87
|
+
if (neonJsAccount.scriptHash !== witnessScriptHash) {
|
|
88
|
+
throw new Error('Invalid witness script hash');
|
|
89
|
+
}
|
|
90
|
+
const bip44PathHex = __classPrivateFieldGet(this, _NeonDappKitLedgerServiceNeo3_instances, "m", _NeonDappKitLedgerServiceNeo3_bip44PathToHex).call(this, account.bip44Path);
|
|
69
91
|
// Send the BIP44 account as first chunk
|
|
70
|
-
yield __classPrivateFieldGet(this, _NeonDappKitLedgerServiceNeo3_instances, "m", _NeonDappKitLedgerServiceNeo3_sendChunk).call(this, transport, LedgerCommand.SIGN, 0, LedgerSecondParameter.MORE_DATA,
|
|
92
|
+
yield __classPrivateFieldGet(this, _NeonDappKitLedgerServiceNeo3_instances, "m", _NeonDappKitLedgerServiceNeo3_sendChunk).call(this, transport, LedgerCommand.SIGN, 0, LedgerSecondParameter.MORE_DATA, bip44PathHex);
|
|
71
93
|
// Send the network magic as second chunk
|
|
72
|
-
yield __classPrivateFieldGet(this, _NeonDappKitLedgerServiceNeo3_instances, "m", _NeonDappKitLedgerServiceNeo3_sendChunk).call(this, transport, LedgerCommand.SIGN, 1, LedgerSecondParameter.MORE_DATA, neon_dappkit_1.NeonParser.numToHex(
|
|
94
|
+
yield __classPrivateFieldGet(this, _NeonDappKitLedgerServiceNeo3_instances, "m", _NeonDappKitLedgerServiceNeo3_sendChunk).call(this, transport, LedgerCommand.SIGN, 1, LedgerSecondParameter.MORE_DATA, neon_dappkit_1.NeonParser.numToHex(network, 4, true));
|
|
95
|
+
const serializedTransaction = transaction.serialize(false);
|
|
96
|
+
// Split the serialized transaction into chunks of 510 bytes
|
|
73
97
|
const chunks = serializedTransaction.match(/.{1,510}/g) || [];
|
|
98
|
+
// Send all chunks except the last one
|
|
74
99
|
for (let i = 0; i < chunks.length - 1; i++) {
|
|
75
100
|
// We plus 2 because we already sent 2 chunks before
|
|
76
101
|
const commandIndex = 2 + i;
|
|
77
102
|
yield __classPrivateFieldGet(this, _NeonDappKitLedgerServiceNeo3_instances, "m", _NeonDappKitLedgerServiceNeo3_sendChunk).call(this, transport, LedgerCommand.SIGN, commandIndex, LedgerSecondParameter.MORE_DATA, chunks[i]);
|
|
78
103
|
}
|
|
79
|
-
// Again we plus 2 because we already sent 2 chunks before getting the chunks
|
|
104
|
+
// Again, we plus 2 because we already sent 2 chunks before getting the chunks
|
|
80
105
|
const lastChunkIndex = 2 + chunks.length;
|
|
106
|
+
// Send the last chunk signaling that it is the last one and get the signature
|
|
81
107
|
const response = yield __classPrivateFieldGet(this, _NeonDappKitLedgerServiceNeo3_instances, "m", _NeonDappKitLedgerServiceNeo3_sendChunk).call(this, transport, LedgerCommand.SIGN, lastChunkIndex, LedgerSecondParameter.LAST_DATA, chunks[chunks.length - 1]);
|
|
82
108
|
if (response.length <= 2) {
|
|
83
|
-
throw new Error(
|
|
109
|
+
throw new Error('Invalid signature returned from Ledger');
|
|
84
110
|
}
|
|
85
111
|
const signature = __classPrivateFieldGet(this, _NeonDappKitLedgerServiceNeo3_instances, "m", _NeonDappKitLedgerServiceNeo3_derSignatureToHex).call(this, response.toString('hex'));
|
|
86
112
|
return signature;
|
|
@@ -90,26 +116,24 @@ class NeonDappKitLedgerServiceNeo3 {
|
|
|
90
116
|
}
|
|
91
117
|
});
|
|
92
118
|
}
|
|
93
|
-
getPublicKey(transport, addressIndex = 0) {
|
|
94
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
95
|
-
const bip44 = __classPrivateFieldGet(this, _NeonDappKitLedgerServiceNeo3_instances, "m", _NeonDappKitLedgerServiceNeo3_toBip44).call(this, addressIndex);
|
|
96
|
-
const result = yield __classPrivateFieldGet(this, _NeonDappKitLedgerServiceNeo3_instances, "m", _NeonDappKitLedgerServiceNeo3_sendChunk).call(this, transport, LedgerCommand.GET_PUBLIC_KEY, 0x00, LedgerSecondParameter.LAST_DATA, bip44);
|
|
97
|
-
const publicKey = result.toString('hex').substring(0, 130);
|
|
98
|
-
return publicKey;
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
119
|
}
|
|
102
120
|
exports.NeonDappKitLedgerServiceNeo3 = NeonDappKitLedgerServiceNeo3;
|
|
103
|
-
_NeonDappKitLedgerServiceNeo3_instances = new WeakSet(), _NeonDappKitLedgerServiceNeo3_sendChunk = function _NeonDappKitLedgerServiceNeo3_sendChunk(transport, command, commandIndex, secondParameter, chunk) {
|
|
121
|
+
_NeonDappKitLedgerServiceNeo3_blockchainService = new WeakMap(), _NeonDappKitLedgerServiceNeo3_instances = new WeakSet(), _NeonDappKitLedgerServiceNeo3_sendChunk = function _NeonDappKitLedgerServiceNeo3_sendChunk(transport, command, commandIndex, secondParameter, chunk) {
|
|
104
122
|
return transport.send(0x80, command, commandIndex, secondParameter, Buffer.from(chunk, 'hex'), [LedgerStatus.OK]);
|
|
105
|
-
},
|
|
106
|
-
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
123
|
+
}, _NeonDappKitLedgerServiceNeo3_bip44PathToHex = function _NeonDappKitLedgerServiceNeo3_bip44PathToHex(path) {
|
|
124
|
+
let result = '';
|
|
125
|
+
const components = path.split('/');
|
|
126
|
+
components.forEach(element => {
|
|
127
|
+
let number = parseInt(element, 10);
|
|
128
|
+
if (isNaN(number)) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
if (element.length > 1 && element[element.length - 1] === "'") {
|
|
132
|
+
number += 0x80000000;
|
|
133
|
+
}
|
|
134
|
+
result += number.toString(16).padStart(8, '0');
|
|
135
|
+
});
|
|
136
|
+
return result;
|
|
113
137
|
}, _NeonDappKitLedgerServiceNeo3_derSignatureToHex = function _NeonDappKitLedgerServiceNeo3_derSignatureToHex(response) {
|
|
114
138
|
const ss = new neon_js_1.u.StringStream(response);
|
|
115
139
|
// The first byte is format. It is usually 0x30 (SEQ) or 0x31 (SET)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { GetNftParam, GetNftsByAddressParams, Network, NftResponse, NftsResponse } from '@cityofzion/blockchain-service';
|
|
2
|
-
import { BSNeo3NetworkId } from '../../helpers/BSNeo3Helper';
|
|
3
2
|
import { RpcNDSNeo3 } from './RpcNDSNeo3';
|
|
3
|
+
import { BSNeo3NetworkId } from '../../constants/BSNeo3Constants';
|
|
4
4
|
export declare class GhostMarketNDSNeo3 extends RpcNDSNeo3 {
|
|
5
5
|
#private;
|
|
6
6
|
static CONFIG_BY_NETWORK_ID: Partial<Record<BSNeo3NetworkId, {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { GetNftParam, GetNftsByAddressParams, HasTokenParam, Network, NftDataService, NftResponse, NftsResponse } from '@cityofzion/blockchain-service';
|
|
2
|
-
import { BSNeo3NetworkId } from '../../
|
|
2
|
+
import { BSNeo3NetworkId } from '../../constants/BSNeo3Constants';
|
|
3
3
|
export declare abstract class RpcNDSNeo3 implements NftDataService {
|
|
4
4
|
#private;
|
|
5
5
|
protected constructor(network: Network<BSNeo3NetworkId>);
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Account, Network, SwapService, SwapServiceEvents, SwapServiceSwapToReceiveArgs, SwapServiceSwapToUseArgs, Token } from '@cityofzion/blockchain-service';
|
|
2
2
|
import TypedEmitter from 'typed-emitter';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { BSNeo3 } from '../../BSNeo3';
|
|
4
|
+
import { BSNeo3NetworkId } from '../../constants/BSNeo3Constants';
|
|
5
5
|
type BuildSwapInvocationArgs = SwapServiceSwapToUseArgs<BSNeo3NetworkId> | SwapServiceSwapToReceiveArgs<BSNeo3NetworkId>;
|
|
6
6
|
export declare class FlamingoSwapServiceNeo3 implements SwapService<BSNeo3NetworkId> {
|
|
7
7
|
#private;
|
|
8
8
|
eventEmitter: TypedEmitter<SwapServiceEvents>;
|
|
9
|
-
constructor(network: Network<BSNeo3NetworkId>,
|
|
9
|
+
constructor(network: Network<BSNeo3NetworkId>, blockchainService: BSNeo3);
|
|
10
10
|
buildSwapInvocationArgs(): BuildSwapInvocationArgs;
|
|
11
11
|
swap(isLedger?: boolean): Promise<void>;
|
|
12
12
|
startListeningBlockGeneration(): void;
|
|
@@ -22,10 +22,9 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
22
22
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
23
23
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
24
|
};
|
|
25
|
-
var _FlamingoSwapServiceNeo3_instances,
|
|
25
|
+
var _FlamingoSwapServiceNeo3_instances, _FlamingoSwapServiceNeo3_blockchainService, _FlamingoSwapServiceNeo3_network, _FlamingoSwapServiceNeo3_privateAccountToUse, _FlamingoSwapServiceNeo3_privateTokenToReceive, _FlamingoSwapServiceNeo3_privateTokenToUse, _FlamingoSwapServiceNeo3_privateAmountToReceive, _FlamingoSwapServiceNeo3_privateAmountToUse, _FlamingoSwapServiceNeo3_privateMinimumReceived, _FlamingoSwapServiceNeo3_privateMaximumSelling, _FlamingoSwapServiceNeo3_privateSlippage, _FlamingoSwapServiceNeo3_privateDeadline, _FlamingoSwapServiceNeo3_privatePriceInverse, _FlamingoSwapServiceNeo3_privatePriceImpact, _FlamingoSwapServiceNeo3_privateLiquidityProviderFee, _FlamingoSwapServiceNeo3_privateRoute, _FlamingoSwapServiceNeo3_privateLastAmountChanged, _FlamingoSwapServiceNeo3_socket, _FlamingoSwapServiceNeo3_setReserves, _FlamingoSwapServiceNeo3_clearFields, _FlamingoSwapServiceNeo3_recalculateSwapArguments, _FlamingoSwapServiceNeo3_recalculateRoute, _FlamingoSwapServiceNeo3_lastAmountChanged_get, _FlamingoSwapServiceNeo3_lastAmountChanged_set, _FlamingoSwapServiceNeo3_accountToUse_get, _FlamingoSwapServiceNeo3_accountToUse_set, _FlamingoSwapServiceNeo3_amountToUse_get, _FlamingoSwapServiceNeo3_amountToUse_set, _FlamingoSwapServiceNeo3_minimumReceived_get, _FlamingoSwapServiceNeo3_minimumReceived_set, _FlamingoSwapServiceNeo3_maximumSelling_get, _FlamingoSwapServiceNeo3_maximumSelling_set, _FlamingoSwapServiceNeo3_amountToReceive_get, _FlamingoSwapServiceNeo3_amountToReceive_set, _FlamingoSwapServiceNeo3_deadline_get, _FlamingoSwapServiceNeo3_deadline_set, _FlamingoSwapServiceNeo3_liquidityProviderFee_get, _FlamingoSwapServiceNeo3_liquidityProviderFee_set, _FlamingoSwapServiceNeo3_priceImpact_get, _FlamingoSwapServiceNeo3_priceImpact_set, _FlamingoSwapServiceNeo3_priceInverse_get, _FlamingoSwapServiceNeo3_priceInverse_set, _FlamingoSwapServiceNeo3_route_get, _FlamingoSwapServiceNeo3_route_set, _FlamingoSwapServiceNeo3_slippage_get, _FlamingoSwapServiceNeo3_slippage_set, _FlamingoSwapServiceNeo3_tokenToReceive_get, _FlamingoSwapServiceNeo3_tokenToReceive_set, _FlamingoSwapServiceNeo3_tokenToUse_get, _FlamingoSwapServiceNeo3_tokenToUse_set;
|
|
26
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
27
|
exports.FlamingoSwapServiceNeo3 = void 0;
|
|
28
|
-
const neon_core_1 = require("@cityofzion/neon-core");
|
|
29
28
|
const neon_dappkit_1 = require("@cityofzion/neon-dappkit");
|
|
30
29
|
const events_1 = __importDefault(require("events"));
|
|
31
30
|
const lodash_clonedeep_1 = __importDefault(require("lodash.clonedeep"));
|
|
@@ -33,9 +32,9 @@ const FlamingoSwapInvocationBuilderNeo3_1 = require("../../builder/invocation/Fl
|
|
|
33
32
|
const FlamingoSwapHelper_1 = require("../../helpers/FlamingoSwapHelper");
|
|
34
33
|
const handlers_1 = require("./handlers");
|
|
35
34
|
class FlamingoSwapServiceNeo3 {
|
|
36
|
-
constructor(network,
|
|
35
|
+
constructor(network, blockchainService) {
|
|
37
36
|
_FlamingoSwapServiceNeo3_instances.add(this);
|
|
38
|
-
|
|
37
|
+
_FlamingoSwapServiceNeo3_blockchainService.set(this, void 0);
|
|
39
38
|
_FlamingoSwapServiceNeo3_network.set(this, void 0);
|
|
40
39
|
_FlamingoSwapServiceNeo3_privateAccountToUse.set(this, null);
|
|
41
40
|
_FlamingoSwapServiceNeo3_privateTokenToReceive.set(this, null);
|
|
@@ -54,7 +53,7 @@ class FlamingoSwapServiceNeo3 {
|
|
|
54
53
|
_FlamingoSwapServiceNeo3_socket.set(this, new handlers_1.FlamingoSwapSocketService());
|
|
55
54
|
this.eventEmitter = new events_1.default();
|
|
56
55
|
__classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_network, network, "f");
|
|
57
|
-
__classPrivateFieldSet(this,
|
|
56
|
+
__classPrivateFieldSet(this, _FlamingoSwapServiceNeo3_blockchainService, blockchainService, "f");
|
|
58
57
|
}
|
|
59
58
|
buildSwapInvocationArgs() {
|
|
60
59
|
if (!__classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "a", _FlamingoSwapServiceNeo3_accountToUse_get) ||
|
|
@@ -84,22 +83,12 @@ class FlamingoSwapServiceNeo3 {
|
|
|
84
83
|
swap(isLedger) {
|
|
85
84
|
return __awaiter(this, void 0, void 0, function* () {
|
|
86
85
|
const swapInvocationArgs = this.buildSwapInvocationArgs();
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
if (!__classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_ledgerService, "f")) {
|
|
91
|
-
throw new Error('You must provide a ledger service to use Ledger');
|
|
92
|
-
}
|
|
93
|
-
if (!__classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_ledgerService, "f").getLedgerTransport) {
|
|
94
|
-
throw new Error('You must provide a getLedgerTransport function to use Ledger');
|
|
95
|
-
}
|
|
96
|
-
ledgerTransport = yield __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_ledgerService, "f").getLedgerTransport(__classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "a", _FlamingoSwapServiceNeo3_accountToUse_get));
|
|
97
|
-
signingCallback = __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_ledgerService, "f").getSigningCallback(ledgerTransport);
|
|
98
|
-
}
|
|
99
|
-
const account = new neon_core_1.wallet.Account(__classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "a", _FlamingoSwapServiceNeo3_accountToUse_get).key);
|
|
86
|
+
if (!__classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "a", _FlamingoSwapServiceNeo3_accountToUse_get))
|
|
87
|
+
throw new Error('Account to use is not set');
|
|
88
|
+
const { neonJsAccount, signingCallback } = yield __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_blockchainService, "f").generateSigningCallback(__classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "a", _FlamingoSwapServiceNeo3_accountToUse_get), isLedger);
|
|
100
89
|
const invoker = yield neon_dappkit_1.NeonInvoker.init({
|
|
101
90
|
rpcAddress: __classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_network, "f").url,
|
|
102
|
-
account,
|
|
91
|
+
account: neonJsAccount,
|
|
103
92
|
signingCallback,
|
|
104
93
|
});
|
|
105
94
|
yield invoker.invokeFunction(FlamingoSwapInvocationBuilderNeo3_1.FlamingoSwapInvocationBuilderNeo3.swapInvocation(swapInvocationArgs));
|
|
@@ -149,7 +138,7 @@ class FlamingoSwapServiceNeo3 {
|
|
|
149
138
|
}
|
|
150
139
|
}
|
|
151
140
|
exports.FlamingoSwapServiceNeo3 = FlamingoSwapServiceNeo3;
|
|
152
|
-
|
|
141
|
+
_FlamingoSwapServiceNeo3_blockchainService = new WeakMap(), _FlamingoSwapServiceNeo3_network = new WeakMap(), _FlamingoSwapServiceNeo3_privateAccountToUse = new WeakMap(), _FlamingoSwapServiceNeo3_privateTokenToReceive = new WeakMap(), _FlamingoSwapServiceNeo3_privateTokenToUse = new WeakMap(), _FlamingoSwapServiceNeo3_privateAmountToReceive = new WeakMap(), _FlamingoSwapServiceNeo3_privateAmountToUse = new WeakMap(), _FlamingoSwapServiceNeo3_privateMinimumReceived = new WeakMap(), _FlamingoSwapServiceNeo3_privateMaximumSelling = new WeakMap(), _FlamingoSwapServiceNeo3_privateSlippage = new WeakMap(), _FlamingoSwapServiceNeo3_privateDeadline = new WeakMap(), _FlamingoSwapServiceNeo3_privatePriceInverse = new WeakMap(), _FlamingoSwapServiceNeo3_privatePriceImpact = new WeakMap(), _FlamingoSwapServiceNeo3_privateLiquidityProviderFee = new WeakMap(), _FlamingoSwapServiceNeo3_privateRoute = new WeakMap(), _FlamingoSwapServiceNeo3_privateLastAmountChanged = new WeakMap(), _FlamingoSwapServiceNeo3_socket = new WeakMap(), _FlamingoSwapServiceNeo3_instances = new WeakSet(), _FlamingoSwapServiceNeo3_setReserves = function _FlamingoSwapServiceNeo3_setReserves() {
|
|
153
142
|
return __awaiter(this, void 0, void 0, function* () {
|
|
154
143
|
if (!__classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "a", _FlamingoSwapServiceNeo3_tokenToReceive_get) || !__classPrivateFieldGet(this, _FlamingoSwapServiceNeo3_instances, "a", _FlamingoSwapServiceNeo3_tokenToUse_get))
|
|
155
144
|
return;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Network, SwapRoute, Token } from '@cityofzion/blockchain-service';
|
|
2
|
-
import { BSNeo3NetworkId } from '../../../
|
|
2
|
+
import { BSNeo3NetworkId } from '../../../constants/BSNeo3Constants';
|
|
3
3
|
type CalculateSwapDetailsArgs = {
|
|
4
4
|
amountToUse: string | null;
|
|
5
5
|
amountToReceive: string | null;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Network, PoolGraph, SwapRoute, Token } from '@cityofzion/blockchain-service';
|
|
2
|
-
import { BSNeo3NetworkId } from '../../../
|
|
2
|
+
import { BSNeo3NetworkId } from '../../../constants/BSNeo3Constants';
|
|
3
3
|
type CalculateBestRouteForSwapArgs = {
|
|
4
4
|
tokenToUse: Token;
|
|
5
5
|
tokenToReceive: Token;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cityofzion/bs-neo3",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"repository": "https://github.com/CityOfZion/blockchain-services",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"bignumber.js": "^9.1.2",
|
|
21
21
|
"isomorphic-ws": "^5.0.0",
|
|
22
22
|
"lodash.clonedeep": "^4.5.0",
|
|
23
|
-
"@cityofzion/blockchain-service": "1.
|
|
23
|
+
"@cityofzion/blockchain-service": "1.4.0",
|
|
24
24
|
"@cityofzion/bs-asteroid-sdk": "0.9.0"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|