@cityofzion/bs-neo3 0.14.3 → 1.0.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 +6 -5
- package/dist/BSNeo3.js +9 -8
- package/dist/DoraBDSNeo3.d.ts +2 -1
- package/dist/DoraBDSNeo3.js +7 -7
- package/dist/DoraESNeo3.d.ts +3 -2
- package/dist/DoraESNeo3.js +8 -8
- package/dist/FlamingoEDSNeo3.d.ts +4 -2
- package/dist/FlamingoEDSNeo3.js +12 -7
- package/dist/GhostMarketNDSNeo3.d.ts +2 -1
- package/dist/GhostMarketNDSNeo3.js +6 -6
- package/dist/RpcBDSNeo3.d.ts +3 -2
- package/dist/RpcBDSNeo3.js +2 -2
- package/dist/assets/tokens/common.json +2 -2
- package/dist/constants.d.ts +8 -7
- package/dist/flamingo-swap/FlamingoSwapControllerService.d.ts +4 -3
- package/dist/flamingo-swap/FlamingoSwapControllerService.js +1 -1
- package/dist/flamingo-swap/FlamingoSwapHelper.d.ts +3 -2
- package/dist/flamingo-swap/FlamingoSwapHelper.js +2 -2
- package/dist/flamingo-swap/FlamingoSwapNeonDappKitInvocationBuilder.d.ts +3 -2
- package/dist/flamingo-swap/FlamingoSwapNeonDappKitInvocationBuilder.js +5 -5
- package/package.json +6 -6
package/dist/BSNeo3.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { BlockchainDataService, BlockchainService, BSClaimable, Account, ExchangeDataService, BDSClaimable, Token, BSWithNameService, Network,
|
|
1
|
+
import { BlockchainDataService, BlockchainService, BSClaimable, Account, ExchangeDataService, BDSClaimable, Token, BSWithNameService, Network, TransferParam, BSCalculableFee, NftDataService, BSWithNft, AccountWithDerivationPath, BSWithExplorerService, ExplorerService, BSWithLedger, PartialNetwork } from '@cityofzion/blockchain-service';
|
|
2
|
+
import { AvailableNetworkIds } from './constants';
|
|
2
3
|
import { LedgerServiceNeo3 } from './LedgerServiceNeo3';
|
|
3
4
|
import Transport from '@ledgerhq/hw-transport';
|
|
4
|
-
export declare class BSNeo3<BSCustomName extends string = string> implements BlockchainService, BSClaimable, BSWithNameService, BSCalculableFee, BSWithNft, BSWithExplorerService, BSWithLedger {
|
|
5
|
+
export declare class BSNeo3<BSCustomName extends string = string> implements BlockchainService<BSCustomName, AvailableNetworkIds>, BSClaimable, BSWithNameService, BSCalculableFee, BSWithNft, BSWithExplorerService, BSWithLedger {
|
|
5
6
|
readonly blockchainName: BSCustomName;
|
|
6
7
|
readonly feeToken: Token;
|
|
7
8
|
readonly claimToken: Token;
|
|
@@ -13,9 +14,9 @@ export declare class BSNeo3<BSCustomName extends string = string> implements Blo
|
|
|
13
14
|
exchangeDataService: ExchangeDataService;
|
|
14
15
|
explorerService: ExplorerService;
|
|
15
16
|
tokens: Token[];
|
|
16
|
-
network: Network
|
|
17
|
-
constructor(blockchainName: BSCustomName, network:
|
|
18
|
-
setNetwork(
|
|
17
|
+
network: Network<AvailableNetworkIds>;
|
|
18
|
+
constructor(blockchainName: BSCustomName, network: PartialNetwork<AvailableNetworkIds>, getLedgerTransport?: (account: Account) => Promise<Transport>);
|
|
19
|
+
setNetwork(partialNetwork: PartialNetwork<AvailableNetworkIds>): void;
|
|
19
20
|
validateAddress(address: string): boolean;
|
|
20
21
|
validateEncrypted(encryptedKey: string): boolean;
|
|
21
22
|
validateKey(key: string): boolean;
|
package/dist/BSNeo3.js
CHANGED
|
@@ -24,29 +24,30 @@ class BSNeo3 {
|
|
|
24
24
|
constructor(blockchainName, network, getLedgerTransport) {
|
|
25
25
|
this.blockchainName = blockchainName;
|
|
26
26
|
this.ledgerService = new LedgerServiceNeo3_1.LedgerServiceNeo3(getLedgerTransport);
|
|
27
|
-
this.tokens = constants_1.TOKENS[network.
|
|
27
|
+
this.tokens = constants_1.TOKENS[network.id];
|
|
28
28
|
this.derivationPath = constants_1.DERIVATION_PATH;
|
|
29
29
|
this.feeToken = this.tokens.find(token => token.symbol === 'GAS');
|
|
30
30
|
this.burnToken = this.tokens.find(token => token.symbol === 'NEO');
|
|
31
31
|
this.claimToken = this.tokens.find(token => token.symbol === 'GAS');
|
|
32
32
|
this.setNetwork(network);
|
|
33
33
|
}
|
|
34
|
-
setNetwork(
|
|
35
|
-
var _a;
|
|
34
|
+
setNetwork(partialNetwork) {
|
|
35
|
+
var _a, _b;
|
|
36
36
|
const network = {
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
id: partialNetwork.id,
|
|
38
|
+
name: (_a = partialNetwork.name) !== null && _a !== void 0 ? _a : partialNetwork.id,
|
|
39
|
+
url: (_b = partialNetwork.url) !== null && _b !== void 0 ? _b : constants_1.DEFAULT_URL_BY_NETWORK_TYPE[partialNetwork.id],
|
|
39
40
|
};
|
|
40
41
|
this.network = network;
|
|
41
|
-
if (network.
|
|
42
|
+
if (network.name === 'custom') {
|
|
42
43
|
this.blockchainDataService = new RpcBDSNeo3_1.RPCBDSNeo3(network, this.feeToken, this.claimToken);
|
|
43
44
|
}
|
|
44
45
|
else {
|
|
45
46
|
this.blockchainDataService = new DoraBDSNeo3_1.DoraBDSNeo3(network, this.feeToken, this.claimToken);
|
|
46
47
|
}
|
|
47
|
-
this.exchangeDataService = new FlamingoEDSNeo3_1.FlamingoEDSNeo3(network.
|
|
48
|
+
this.exchangeDataService = new FlamingoEDSNeo3_1.FlamingoEDSNeo3(network.id);
|
|
48
49
|
this.nftDataService = new GhostMarketNDSNeo3_1.GhostMarketNDSNeo3(network);
|
|
49
|
-
this.explorerService = new DoraESNeo3_1.DoraESNeo3(network.
|
|
50
|
+
this.explorerService = new DoraESNeo3_1.DoraESNeo3(network.id);
|
|
50
51
|
}
|
|
51
52
|
validateAddress(address) {
|
|
52
53
|
return neon_js_1.wallet.isAddress(address, 53);
|
package/dist/DoraBDSNeo3.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { BalanceResponse, ContractResponse, TransactionsByAddressParams, TransactionsByAddressResponse, TransactionResponse, Network, Token } from '@cityofzion/blockchain-service';
|
|
2
2
|
import { RPCBDSNeo3 } from './RpcBDSNeo3';
|
|
3
|
+
import { AvailableNetworkIds } from './constants';
|
|
3
4
|
export declare class DoraBDSNeo3 extends RPCBDSNeo3 {
|
|
4
|
-
constructor(network: Network
|
|
5
|
+
constructor(network: Network<AvailableNetworkIds>, feeToken: Token, claimToken: Token);
|
|
5
6
|
getTransaction(hash: string): Promise<TransactionResponse>;
|
|
6
7
|
getTransactionsByAddress({ address, page, }: TransactionsByAddressParams): Promise<TransactionsByAddressResponse>;
|
|
7
8
|
getContract(contractHash: string): Promise<ContractResponse>;
|
package/dist/DoraBDSNeo3.js
CHANGED
|
@@ -20,7 +20,7 @@ const NeoRest = new api_1.NeoRESTApi({
|
|
|
20
20
|
});
|
|
21
21
|
class DoraBDSNeo3 extends RpcBDSNeo3_1.RPCBDSNeo3 {
|
|
22
22
|
constructor(network, feeToken, claimToken) {
|
|
23
|
-
if (network.
|
|
23
|
+
if (network.id === 'custom') {
|
|
24
24
|
throw new Error('DoraBDSNeo3 does not support custom networks');
|
|
25
25
|
}
|
|
26
26
|
super(network, feeToken, claimToken);
|
|
@@ -29,7 +29,7 @@ class DoraBDSNeo3 extends RpcBDSNeo3_1.RPCBDSNeo3 {
|
|
|
29
29
|
var _a, _b;
|
|
30
30
|
return __awaiter(this, void 0, void 0, function* () {
|
|
31
31
|
try {
|
|
32
|
-
const data = yield NeoRest.transaction(hash, this._network.
|
|
32
|
+
const data = yield NeoRest.transaction(hash, this._network.id);
|
|
33
33
|
return {
|
|
34
34
|
block: data.block,
|
|
35
35
|
time: Number(data.time),
|
|
@@ -48,7 +48,7 @@ class DoraBDSNeo3 extends RpcBDSNeo3_1.RPCBDSNeo3 {
|
|
|
48
48
|
}
|
|
49
49
|
getTransactionsByAddress({ address, page = 1, }) {
|
|
50
50
|
return __awaiter(this, void 0, void 0, function* () {
|
|
51
|
-
const data = yield NeoRest.addressTXFull(address, page, this._network.
|
|
51
|
+
const data = yield NeoRest.addressTXFull(address, page, this._network.id);
|
|
52
52
|
const promises = data.items.map((item) => __awaiter(this, void 0, void 0, function* () {
|
|
53
53
|
var _a, _b;
|
|
54
54
|
const transferPromises = [];
|
|
@@ -113,7 +113,7 @@ class DoraBDSNeo3 extends RpcBDSNeo3_1.RPCBDSNeo3 {
|
|
|
113
113
|
var _a, _b;
|
|
114
114
|
return __awaiter(this, void 0, void 0, function* () {
|
|
115
115
|
try {
|
|
116
|
-
const data = yield NeoRest.contract(contractHash, this._network.
|
|
116
|
+
const data = yield NeoRest.contract(contractHash, this._network.id);
|
|
117
117
|
return {
|
|
118
118
|
hash: data.hash,
|
|
119
119
|
methods: (_b = (_a = data.manifest.abi) === null || _a === void 0 ? void 0 : _a.methods) !== null && _b !== void 0 ? _b : [],
|
|
@@ -127,14 +127,14 @@ class DoraBDSNeo3 extends RpcBDSNeo3_1.RPCBDSNeo3 {
|
|
|
127
127
|
}
|
|
128
128
|
getTokenInfo(tokenHash) {
|
|
129
129
|
return __awaiter(this, void 0, void 0, function* () {
|
|
130
|
-
const localToken = constants_1.TOKENS[this._network.
|
|
130
|
+
const localToken = constants_1.TOKENS[this._network.id].find(token => token.hash === tokenHash);
|
|
131
131
|
if (localToken)
|
|
132
132
|
return localToken;
|
|
133
133
|
if (this._tokenCache.has(tokenHash)) {
|
|
134
134
|
return this._tokenCache.get(tokenHash);
|
|
135
135
|
}
|
|
136
136
|
try {
|
|
137
|
-
const { decimals, symbol, name, scripthash } = yield NeoRest.asset(tokenHash, this._network.
|
|
137
|
+
const { decimals, symbol, name, scripthash } = yield NeoRest.asset(tokenHash, this._network.id);
|
|
138
138
|
const token = {
|
|
139
139
|
decimals: Number(decimals),
|
|
140
140
|
symbol,
|
|
@@ -151,7 +151,7 @@ class DoraBDSNeo3 extends RpcBDSNeo3_1.RPCBDSNeo3 {
|
|
|
151
151
|
}
|
|
152
152
|
getBalance(address) {
|
|
153
153
|
return __awaiter(this, void 0, void 0, function* () {
|
|
154
|
-
const response = yield NeoRest.balance(address, this._network.
|
|
154
|
+
const response = yield NeoRest.balance(address, this._network.id);
|
|
155
155
|
const promises = response.map((balance) => __awaiter(this, void 0, void 0, function* () {
|
|
156
156
|
try {
|
|
157
157
|
const token = yield this.getTokenInfo(balance.asset);
|
package/dist/DoraESNeo3.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { ExplorerService,
|
|
1
|
+
import { ExplorerService, BuildNftUrlParams } from '@cityofzion/blockchain-service';
|
|
2
|
+
import { AvailableNetworkIds } from './constants';
|
|
2
3
|
export declare class DoraESNeo3 implements ExplorerService {
|
|
3
4
|
#private;
|
|
4
|
-
constructor(networkType:
|
|
5
|
+
constructor(networkType: AvailableNetworkIds);
|
|
5
6
|
buildTransactionUrl(hash: string): string;
|
|
6
7
|
buildNftUrl({ contractHash, tokenId }: BuildNftUrlParams): string;
|
|
7
8
|
}
|
package/dist/DoraESNeo3.js
CHANGED
|
@@ -10,24 +10,24 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
10
10
|
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");
|
|
11
11
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
12
|
};
|
|
13
|
-
var
|
|
13
|
+
var _DoraESNeo3_networkId;
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.DoraESNeo3 = void 0;
|
|
16
16
|
class DoraESNeo3 {
|
|
17
17
|
constructor(networkType) {
|
|
18
|
-
|
|
19
|
-
__classPrivateFieldSet(this,
|
|
18
|
+
_DoraESNeo3_networkId.set(this, void 0);
|
|
19
|
+
__classPrivateFieldSet(this, _DoraESNeo3_networkId, networkType, "f");
|
|
20
20
|
}
|
|
21
21
|
buildTransactionUrl(hash) {
|
|
22
|
-
if (__classPrivateFieldGet(this,
|
|
22
|
+
if (__classPrivateFieldGet(this, _DoraESNeo3_networkId, "f") === 'custom')
|
|
23
23
|
throw new Error('DoraESNeo3 does not support custom network');
|
|
24
|
-
return `https://dora.coz.io/transaction/neo3/${__classPrivateFieldGet(this,
|
|
24
|
+
return `https://dora.coz.io/transaction/neo3/${__classPrivateFieldGet(this, _DoraESNeo3_networkId, "f")}/${hash}`;
|
|
25
25
|
}
|
|
26
26
|
buildNftUrl({ contractHash, tokenId }) {
|
|
27
|
-
if (__classPrivateFieldGet(this,
|
|
27
|
+
if (__classPrivateFieldGet(this, _DoraESNeo3_networkId, "f") === 'custom')
|
|
28
28
|
throw new Error('DoraESNeo3 does not support custom network');
|
|
29
|
-
return `https://dora.coz.io/nft/neo3/${__classPrivateFieldGet(this,
|
|
29
|
+
return `https://dora.coz.io/nft/neo3/${__classPrivateFieldGet(this, _DoraESNeo3_networkId, "f")}/${contractHash}/${tokenId}`;
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
exports.DoraESNeo3 = DoraESNeo3;
|
|
33
|
-
|
|
33
|
+
_DoraESNeo3_networkId = new WeakMap();
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { CryptoCompareEDS, Currency, ExchangeDataService,
|
|
1
|
+
import { CryptoCompareEDS, Currency, ExchangeDataService, GetTokenPriceHistory, TokenPricesHistoryResponse, TokenPricesResponse } from '@cityofzion/blockchain-service';
|
|
2
|
+
import { AvailableNetworkIds } from './constants';
|
|
2
3
|
export declare class FlamingoEDSNeo3 extends CryptoCompareEDS implements ExchangeDataService {
|
|
3
4
|
#private;
|
|
4
|
-
constructor(
|
|
5
|
+
constructor(networkId: AvailableNetworkIds);
|
|
5
6
|
getTokenPrices(currency: Currency): Promise<TokenPricesResponse[]>;
|
|
7
|
+
getTokenPriceHistory(params: GetTokenPriceHistory): Promise<TokenPricesHistoryResponse[]>;
|
|
6
8
|
private getCurrencyRatio;
|
|
7
9
|
}
|
package/dist/FlamingoEDSNeo3.js
CHANGED
|
@@ -22,23 +22,23 @@ 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
|
|
25
|
+
var _FlamingoEDSNeo3_networkId, _FlamingoEDSNeo3_axiosInstance;
|
|
26
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
27
|
exports.FlamingoEDSNeo3 = void 0;
|
|
28
28
|
const blockchain_service_1 = require("@cityofzion/blockchain-service");
|
|
29
29
|
const axios_1 = __importDefault(require("axios"));
|
|
30
30
|
const constants_1 = require("./constants");
|
|
31
31
|
class FlamingoEDSNeo3 extends blockchain_service_1.CryptoCompareEDS {
|
|
32
|
-
constructor(
|
|
33
|
-
super(
|
|
34
|
-
|
|
32
|
+
constructor(networkId) {
|
|
33
|
+
super(constants_1.TOKENS[networkId]);
|
|
34
|
+
_FlamingoEDSNeo3_networkId.set(this, void 0);
|
|
35
35
|
_FlamingoEDSNeo3_axiosInstance.set(this, void 0);
|
|
36
|
-
__classPrivateFieldSet(this,
|
|
36
|
+
__classPrivateFieldSet(this, _FlamingoEDSNeo3_networkId, networkId, "f");
|
|
37
37
|
__classPrivateFieldSet(this, _FlamingoEDSNeo3_axiosInstance, axios_1.default.create({ baseURL: 'https://api.flamingo.finance' }), "f");
|
|
38
38
|
}
|
|
39
39
|
getTokenPrices(currency) {
|
|
40
40
|
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
-
if (__classPrivateFieldGet(this,
|
|
41
|
+
if (__classPrivateFieldGet(this, _FlamingoEDSNeo3_networkId, "f") !== 'mainnet')
|
|
42
42
|
throw new Error('Exchange is only available on mainnet');
|
|
43
43
|
const { data: prices } = yield __classPrivateFieldGet(this, _FlamingoEDSNeo3_axiosInstance, "f").get('/token-info/prices');
|
|
44
44
|
let currencyRatio = 1;
|
|
@@ -52,6 +52,11 @@ class FlamingoEDSNeo3 extends blockchain_service_1.CryptoCompareEDS {
|
|
|
52
52
|
}));
|
|
53
53
|
});
|
|
54
54
|
}
|
|
55
|
+
getTokenPriceHistory(params) {
|
|
56
|
+
if (__classPrivateFieldGet(this, _FlamingoEDSNeo3_networkId, "f") !== 'mainnet')
|
|
57
|
+
throw new Error('Exchange is only available on mainnet');
|
|
58
|
+
return super.getTokenPriceHistory(params);
|
|
59
|
+
}
|
|
55
60
|
getCurrencyRatio(currency) {
|
|
56
61
|
return __awaiter(this, void 0, void 0, function* () {
|
|
57
62
|
const { data } = yield __classPrivateFieldGet(this, _FlamingoEDSNeo3_axiosInstance, "f").get(`/fiat/exchange-rate?pair=USD_${currency}`);
|
|
@@ -60,4 +65,4 @@ class FlamingoEDSNeo3 extends blockchain_service_1.CryptoCompareEDS {
|
|
|
60
65
|
}
|
|
61
66
|
}
|
|
62
67
|
exports.FlamingoEDSNeo3 = FlamingoEDSNeo3;
|
|
63
|
-
|
|
68
|
+
_FlamingoEDSNeo3_networkId = new WeakMap(), _FlamingoEDSNeo3_axiosInstance = new WeakMap();
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { NftResponse, NftsResponse, GetNftParam, GetNftsByAddressParams, Network } from '@cityofzion/blockchain-service';
|
|
2
|
+
import { AvailableNetworkIds } from './constants';
|
|
2
3
|
import { RpcNDSNeo3 } from './RpcNDSNeo3';
|
|
3
4
|
export declare class GhostMarketNDSNeo3 extends RpcNDSNeo3 {
|
|
4
5
|
#private;
|
|
5
|
-
constructor(network: Network);
|
|
6
|
+
constructor(network: Network<AvailableNetworkIds>);
|
|
6
7
|
getNftsByAddress({ address, size, cursor }: GetNftsByAddressParams): Promise<NftsResponse>;
|
|
7
8
|
getNft({ contractHash, tokenId }: GetNftParam): Promise<NftResponse>;
|
|
8
9
|
private treatGhostMarketImage;
|
|
@@ -22,7 +22,7 @@ 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
|
|
25
|
+
var _GhostMarketNDSNeo3_networkId;
|
|
26
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
27
|
exports.GhostMarketNDSNeo3 = void 0;
|
|
28
28
|
const query_string_1 = __importDefault(require("query-string"));
|
|
@@ -32,8 +32,8 @@ const RpcNDSNeo3_1 = require("./RpcNDSNeo3");
|
|
|
32
32
|
class GhostMarketNDSNeo3 extends RpcNDSNeo3_1.RpcNDSNeo3 {
|
|
33
33
|
constructor(network) {
|
|
34
34
|
super(network);
|
|
35
|
-
|
|
36
|
-
__classPrivateFieldSet(this,
|
|
35
|
+
_GhostMarketNDSNeo3_networkId.set(this, void 0);
|
|
36
|
+
__classPrivateFieldSet(this, _GhostMarketNDSNeo3_networkId, network.id, "f");
|
|
37
37
|
}
|
|
38
38
|
getNftsByAddress({ address, size = 18, cursor }) {
|
|
39
39
|
var _a;
|
|
@@ -69,8 +69,8 @@ class GhostMarketNDSNeo3 extends RpcNDSNeo3_1.RpcNDSNeo3 {
|
|
|
69
69
|
return srcImage;
|
|
70
70
|
}
|
|
71
71
|
getUrlWithParams(params) {
|
|
72
|
-
const parameters = query_string_1.default.stringify(Object.assign({ chain: constants_1.GHOSTMARKET_CHAIN_BY_NETWORK_TYPE[__classPrivateFieldGet(this,
|
|
73
|
-
return `${constants_1.GHOSTMARKET_URL_BY_NETWORK_TYPE[__classPrivateFieldGet(this,
|
|
72
|
+
const parameters = query_string_1.default.stringify(Object.assign({ chain: constants_1.GHOSTMARKET_CHAIN_BY_NETWORK_TYPE[__classPrivateFieldGet(this, _GhostMarketNDSNeo3_networkId, "f")] }, params), { arrayFormat: 'bracket' });
|
|
73
|
+
return `${constants_1.GHOSTMARKET_URL_BY_NETWORK_TYPE[__classPrivateFieldGet(this, _GhostMarketNDSNeo3_networkId, "f")]}/assets?${parameters}`;
|
|
74
74
|
}
|
|
75
75
|
parse(data) {
|
|
76
76
|
var _a, _b;
|
|
@@ -92,4 +92,4 @@ class GhostMarketNDSNeo3 extends RpcNDSNeo3_1.RpcNDSNeo3 {
|
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
exports.GhostMarketNDSNeo3 = GhostMarketNDSNeo3;
|
|
95
|
-
|
|
95
|
+
_GhostMarketNDSNeo3_networkId = new WeakMap();
|
package/dist/RpcBDSNeo3.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { BDSClaimable, BalanceResponse, BlockchainDataService, ContractResponse, Network, RpcResponse, Token, TransactionResponse, TransactionsByAddressParams, TransactionsByAddressResponse } from '@cityofzion/blockchain-service';
|
|
2
|
+
import { AvailableNetworkIds } from './constants';
|
|
2
3
|
export declare class RPCBDSNeo3 implements BlockchainDataService, BDSClaimable {
|
|
3
4
|
readonly _tokenCache: Map<string, Token>;
|
|
4
5
|
readonly _feeToken: Token;
|
|
5
6
|
readonly _claimToken: Token;
|
|
6
|
-
readonly _network: Network
|
|
7
|
+
readonly _network: Network<AvailableNetworkIds>;
|
|
7
8
|
maxTimeToConfirmTransactionInMs: number;
|
|
8
|
-
constructor(network: Network
|
|
9
|
+
constructor(network: Network<AvailableNetworkIds>, feeToken: Token, claimToken: Token);
|
|
9
10
|
getTransaction(hash: string): Promise<TransactionResponse>;
|
|
10
11
|
getTransactionsByAddress(_params: TransactionsByAddressParams): Promise<TransactionsByAddressResponse>;
|
|
11
12
|
getContract(contractHash: string): Promise<ContractResponse>;
|
package/dist/RpcBDSNeo3.js
CHANGED
|
@@ -73,7 +73,7 @@ class RPCBDSNeo3 {
|
|
|
73
73
|
}
|
|
74
74
|
getTokenInfo(tokenHash) {
|
|
75
75
|
return __awaiter(this, void 0, void 0, function* () {
|
|
76
|
-
const localToken = constants_1.TOKENS[this._network.
|
|
76
|
+
const localToken = constants_1.TOKENS[this._network.id].find(token => token.hash === tokenHash);
|
|
77
77
|
if (localToken)
|
|
78
78
|
return localToken;
|
|
79
79
|
if (this._tokenCache.has(tokenHash)) {
|
|
@@ -158,7 +158,7 @@ class RPCBDSNeo3 {
|
|
|
158
158
|
getRpcList() {
|
|
159
159
|
return __awaiter(this, void 0, void 0, function* () {
|
|
160
160
|
const list = [];
|
|
161
|
-
const promises = constants_1.RPC_LIST_BY_NETWORK_TYPE[this._network.
|
|
161
|
+
const promises = constants_1.RPC_LIST_BY_NETWORK_TYPE[this._network.id].map(url => {
|
|
162
162
|
// eslint-disable-next-line no-async-promise-executor
|
|
163
163
|
return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
|
|
164
164
|
const timeout = setTimeout(() => {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
[
|
|
2
2
|
{
|
|
3
3
|
"symbol": "GAS",
|
|
4
|
-
"name": "
|
|
4
|
+
"name": "GAS",
|
|
5
5
|
"hash": "d2a4cff31913016155e38e474a2c06d08be276cf",
|
|
6
6
|
"decimals": 8
|
|
7
7
|
},
|
|
8
8
|
{
|
|
9
9
|
"symbol": "NEO",
|
|
10
|
-
"name": "
|
|
10
|
+
"name": "NEO",
|
|
11
11
|
"hash": "ef4073a0f2b305a38ec4050e4d3d28bc40ea63f5",
|
|
12
12
|
"decimals": 0
|
|
13
13
|
}
|
package/dist/constants.d.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export
|
|
1
|
+
import { Token } from '@cityofzion/blockchain-service';
|
|
2
|
+
export type AvailableNetworkIds = 'mainnet' | 'testnet' | 'custom';
|
|
3
|
+
export declare const TOKENS: Record<AvailableNetworkIds, Token[]>;
|
|
3
4
|
export declare const BLOCKCHAIN_WSS_URL = "wss://rpc10.n3.nspcc.ru:10331/ws";
|
|
4
5
|
export declare const NEO_NS_HASH = "0x50ac1c37690cc2cfc594472833cf57505d5f46de";
|
|
5
6
|
export declare const GAS_PER_NEO = 0.001;
|
|
6
|
-
export declare const GHOSTMARKET_URL_BY_NETWORK_TYPE: Partial<Record<
|
|
7
|
-
export declare const GHOSTMARKET_CHAIN_BY_NETWORK_TYPE: Partial<Record<
|
|
7
|
+
export declare const GHOSTMARKET_URL_BY_NETWORK_TYPE: Partial<Record<AvailableNetworkIds, string>>;
|
|
8
|
+
export declare const GHOSTMARKET_CHAIN_BY_NETWORK_TYPE: Partial<Record<AvailableNetworkIds, string>>;
|
|
8
9
|
export declare const DERIVATION_PATH = "m/44'/888'/0'/0/?";
|
|
9
|
-
export declare const RPC_LIST_BY_NETWORK_TYPE: Record<
|
|
10
|
-
export declare const DEFAULT_URL_BY_NETWORK_TYPE: Record<
|
|
10
|
+
export declare const RPC_LIST_BY_NETWORK_TYPE: Record<AvailableNetworkIds, string[]>;
|
|
11
|
+
export declare const DEFAULT_URL_BY_NETWORK_TYPE: Record<AvailableNetworkIds, string>;
|
|
11
12
|
export type SwapScriptHashes = {
|
|
12
13
|
flamingoSwapRouter: string;
|
|
13
14
|
flamingoPairWhiteList: string;
|
|
@@ -17,4 +18,4 @@ export type SwapScriptHashes = {
|
|
|
17
18
|
bneo: string;
|
|
18
19
|
flpBneoGas: string;
|
|
19
20
|
};
|
|
20
|
-
export declare const SWAP_SCRIPT_HASHES_BY_NETWORK_TYPE: Partial<Record<
|
|
21
|
+
export declare const SWAP_SCRIPT_HASHES_BY_NETWORK_TYPE: Partial<Record<AvailableNetworkIds, SwapScriptHashes>>;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { Account, Network, SwapControllerService, SwapControllerServiceEvents, SwapControllerServiceSwapToReceiveArgs, SwapControllerServiceSwapToUseArgs, Token } from '@cityofzion/blockchain-service';
|
|
2
2
|
import TypedEmitter from 'typed-emitter';
|
|
3
3
|
import WebSocket from 'isomorphic-ws';
|
|
4
|
-
|
|
4
|
+
import { AvailableNetworkIds } from '../constants';
|
|
5
|
+
export declare class FlamingoSwapControllerService implements SwapControllerService<AvailableNetworkIds> {
|
|
5
6
|
#private;
|
|
6
7
|
eventEmitter: TypedEmitter<SwapControllerServiceEvents>;
|
|
7
8
|
ws: WebSocket;
|
|
8
|
-
constructor(network: Network);
|
|
9
|
-
buildSwapArgs(): SwapControllerServiceSwapToReceiveArgs | SwapControllerServiceSwapToUseArgs
|
|
9
|
+
constructor(network: Network<AvailableNetworkIds>);
|
|
10
|
+
buildSwapArgs(): SwapControllerServiceSwapToReceiveArgs<AvailableNetworkIds> | SwapControllerServiceSwapToUseArgs<AvailableNetworkIds>;
|
|
10
11
|
setAccountToUse(account: Account | null): void;
|
|
11
12
|
setAmountToUse(val: string | null): void;
|
|
12
13
|
setAmountToReceive(val: string | null): void;
|
|
@@ -52,7 +52,7 @@ class FlamingoSwapControllerService {
|
|
|
52
52
|
_FlamingoSwapControllerService_liquidityProviderFee.set(this, null);
|
|
53
53
|
_FlamingoSwapControllerService_routes.set(this, null);
|
|
54
54
|
_FlamingoSwapControllerService_lastAmountChange.set(this, null);
|
|
55
|
-
if (network.
|
|
55
|
+
if (network.id === 'custom')
|
|
56
56
|
throw new FlamingoSwapError_1.CustomNetworkNotSupportedError();
|
|
57
57
|
__classPrivateFieldSet(this, _FlamingoSwapControllerService_network, network, "f");
|
|
58
58
|
this.eventEmitter = new events_1.default();
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import BigNumber from 'bignumber.js';
|
|
2
2
|
import { Network, Token } from '@cityofzion/blockchain-service';
|
|
3
|
+
import { AvailableNetworkIds } from '../constants';
|
|
3
4
|
type TGetSwapArgs = {
|
|
4
5
|
amountToUse: string | null;
|
|
5
6
|
amountToReceive: string | null;
|
|
@@ -8,7 +9,7 @@ type TGetSwapArgs = {
|
|
|
8
9
|
reservesToUse: string;
|
|
9
10
|
reservesToReceive: string;
|
|
10
11
|
slippage: number;
|
|
11
|
-
network: Network
|
|
12
|
+
network: Network<AvailableNetworkIds>;
|
|
12
13
|
};
|
|
13
14
|
export declare class FlamingoSwapHelper {
|
|
14
15
|
static readonly BN_0: BigNumber;
|
|
@@ -25,7 +26,7 @@ export declare class FlamingoSwapHelper {
|
|
|
25
26
|
minimumReceived: string | null;
|
|
26
27
|
maximumSelling: string | null;
|
|
27
28
|
};
|
|
28
|
-
static overrideToken(network: Network
|
|
29
|
+
static overrideToken(network: Network<AvailableNetworkIds>, token: Token): Token;
|
|
29
30
|
private static createTradeData;
|
|
30
31
|
private static overrideAmountInput;
|
|
31
32
|
private static overrideAmountToDisplay;
|
|
@@ -78,12 +78,12 @@ class FlamingoSwapHelper {
|
|
|
78
78
|
};
|
|
79
79
|
}
|
|
80
80
|
static overrideToken(network, token) {
|
|
81
|
-
const neoScriptHash = constants_1.SWAP_SCRIPT_HASHES_BY_NETWORK_TYPE[network.
|
|
81
|
+
const neoScriptHash = constants_1.SWAP_SCRIPT_HASHES_BY_NETWORK_TYPE[network.id].neo;
|
|
82
82
|
const isNeoToken = this.normalizeHash(token.hash) === this.normalizeHash(neoScriptHash);
|
|
83
83
|
if (!isNeoToken) {
|
|
84
84
|
return token;
|
|
85
85
|
}
|
|
86
|
-
const bneoToken = constants_1.TOKENS[network.
|
|
86
|
+
const bneoToken = constants_1.TOKENS[network.id].find(token => token.hash === constants_1.SWAP_SCRIPT_HASHES_BY_NETWORK_TYPE[network.id].bneo);
|
|
87
87
|
if (!bneoToken)
|
|
88
88
|
throw new Error('Bneo token not found');
|
|
89
89
|
return bneoToken;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { ContractInvocationMulti } from '@cityofzion/neon-dappkit-types';
|
|
2
|
+
import { AvailableNetworkIds } from '../constants';
|
|
2
3
|
import { Network, SwapControllerServiceSwapToUseArgs, SwapControllerServiceSwapToReceiveArgs } from '@cityofzion/blockchain-service';
|
|
3
4
|
type GetReservesArgs = {
|
|
4
|
-
network: Network
|
|
5
|
+
network: Network<AvailableNetworkIds>;
|
|
5
6
|
tokenToReceiveScriptHash: string;
|
|
6
7
|
tokenToUseScriptHash: string;
|
|
7
8
|
};
|
|
8
9
|
export declare class FlamingoSwapNeonDappKitInvocationBuilder {
|
|
9
|
-
static swapInvocation(data: SwapControllerServiceSwapToReceiveArgs | SwapControllerServiceSwapToUseArgs): ContractInvocationMulti;
|
|
10
|
+
static swapInvocation(data: SwapControllerServiceSwapToReceiveArgs<AvailableNetworkIds> | SwapControllerServiceSwapToUseArgs<AvailableNetworkIds>): ContractInvocationMulti;
|
|
10
11
|
static getReservesInvocation({ network, tokenToReceiveScriptHash, tokenToUseScriptHash, }: GetReservesArgs): ContractInvocationMulti;
|
|
11
12
|
private static swapTokenToReceiveForTokenToUseInvocation;
|
|
12
13
|
private static swapTokenToUseForTokenToReceiveInvocation;
|
|
@@ -11,7 +11,7 @@ class FlamingoSwapNeonDappKitInvocationBuilder {
|
|
|
11
11
|
: this.swapTokenToUseForTokenToReceiveInvocation(data);
|
|
12
12
|
}
|
|
13
13
|
static getReservesInvocation({ network, tokenToReceiveScriptHash, tokenToUseScriptHash, }) {
|
|
14
|
-
const flamingoSwapRouter = constants_1.SWAP_SCRIPT_HASHES_BY_NETWORK_TYPE[network.
|
|
14
|
+
const flamingoSwapRouter = constants_1.SWAP_SCRIPT_HASHES_BY_NETWORK_TYPE[network.id].flamingoSwapRouter;
|
|
15
15
|
return {
|
|
16
16
|
invocations: [
|
|
17
17
|
{
|
|
@@ -39,7 +39,7 @@ class FlamingoSwapNeonDappKitInvocationBuilder {
|
|
|
39
39
|
static swapTokenToReceiveForTokenToUseInvocation({ address, amountToReceive, maximumSelling, tokenToReceive, tokenToUse, deadline, network, }) {
|
|
40
40
|
const invocations = [];
|
|
41
41
|
const allowedContracts = [];
|
|
42
|
-
const scriptHashes = constants_1.SWAP_SCRIPT_HASHES_BY_NETWORK_TYPE[network.
|
|
42
|
+
const scriptHashes = constants_1.SWAP_SCRIPT_HASHES_BY_NETWORK_TYPE[network.id];
|
|
43
43
|
const tokenToReceiveOverrode = FlamingoSwapHelper_1.FlamingoSwapHelper.overrideToken(network, tokenToReceive);
|
|
44
44
|
const amountToReceiveFormatted = neon_core_1.u.BigInteger.fromDecimal(Number(amountToReceive), tokenToReceiveOverrode.decimals).toString();
|
|
45
45
|
const maximumSellingFormatted = neon_core_1.u.BigInteger.fromDecimal(Number(maximumSelling), tokenToUse.decimals).toString();
|
|
@@ -104,7 +104,7 @@ class FlamingoSwapNeonDappKitInvocationBuilder {
|
|
|
104
104
|
static swapTokenToUseForTokenToReceiveInvocation({ address, amountToUse, deadline, tokenToReceive, tokenToUse, minimumReceived, network, }) {
|
|
105
105
|
const invocations = [];
|
|
106
106
|
const allowedContracts = [];
|
|
107
|
-
const scriptHashes = constants_1.SWAP_SCRIPT_HASHES_BY_NETWORK_TYPE[network.
|
|
107
|
+
const scriptHashes = constants_1.SWAP_SCRIPT_HASHES_BY_NETWORK_TYPE[network.id];
|
|
108
108
|
const isNeoSwapped = tokenToUse.hash === scriptHashes.neo;
|
|
109
109
|
if (isNeoSwapped) {
|
|
110
110
|
const transferContractInvocation = this.transferContractInvocation({
|
|
@@ -202,8 +202,8 @@ class FlamingoSwapNeonDappKitInvocationBuilder {
|
|
|
202
202
|
return [scriptHashes.gas, scriptHashes.flpBneoGas, scriptHashes.bneo];
|
|
203
203
|
}
|
|
204
204
|
static overrideScriptHash(network, scriptHash) {
|
|
205
|
-
return scriptHash === constants_1.SWAP_SCRIPT_HASHES_BY_NETWORK_TYPE[network.
|
|
206
|
-
? constants_1.SWAP_SCRIPT_HASHES_BY_NETWORK_TYPE[network.
|
|
205
|
+
return scriptHash === constants_1.SWAP_SCRIPT_HASHES_BY_NETWORK_TYPE[network.id].neo
|
|
206
|
+
? constants_1.SWAP_SCRIPT_HASHES_BY_NETWORK_TYPE[network.id].bneo
|
|
207
207
|
: scriptHash;
|
|
208
208
|
}
|
|
209
209
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cityofzion/bs-neo3",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"repository": "https://github.com/CityOfZion/blockchain-services",
|
|
@@ -17,24 +17,24 @@
|
|
|
17
17
|
"query-string": "7.1.3",
|
|
18
18
|
"@ledgerhq/hw-transport": "~6.30.5",
|
|
19
19
|
"@cityofzion/neon-dappkit": "0.4.1",
|
|
20
|
-
"@cityofzion/neon-dappkit-types": "~0.3.1",
|
|
21
20
|
"bignumber.js": "~9.1.2",
|
|
22
|
-
"typed-emitter": "~2.1.0",
|
|
23
21
|
"isomorphic-ws": "~5.0.0",
|
|
24
|
-
"@cityofzion/blockchain-service": "0.
|
|
22
|
+
"@cityofzion/blockchain-service": "1.0.0",
|
|
25
23
|
"@cityofzion/bs-asteroid-sdk": "0.9.0"
|
|
26
24
|
},
|
|
27
25
|
"devDependencies": {
|
|
26
|
+
"@cityofzion/neon-dappkit-types": "~0.3.1",
|
|
27
|
+
"@ledgerhq/hw-transport-node-hid": "~6.28.5",
|
|
28
28
|
"@types/jest": "29.5.3",
|
|
29
29
|
"@typescript-eslint/eslint-plugin": "^6.5.0",
|
|
30
30
|
"@typescript-eslint/parser": "^6.5.0",
|
|
31
|
-
"@ledgerhq/hw-transport-node-hid": "~6.28.5",
|
|
32
31
|
"dotenv": "16.3.1",
|
|
33
32
|
"eslint": "^8.48.0",
|
|
34
33
|
"jest": "29.6.2",
|
|
35
34
|
"ts-jest": "29.1.1",
|
|
36
35
|
"ts-node": "10.9.1",
|
|
37
|
-
"typescript": "4.9.5"
|
|
36
|
+
"typescript": "4.9.5",
|
|
37
|
+
"typed-emitter": "~2.1.0"
|
|
38
38
|
},
|
|
39
39
|
"scripts": {
|
|
40
40
|
"build": "tsc --project tsconfig.build.json",
|