@cityofzion/bs-neo3 0.10.0 → 0.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/BSNeo3.d.ts +3 -2
- package/dist/BSNeo3.js +23 -6
- package/dist/DoraBDSNeo3.d.ts +0 -1
- package/dist/DoraBDSNeo3.js +11 -12
- package/dist/DoraESNeo3.d.ts +1 -1
- package/dist/DoraESNeo3.js +19 -5
- package/dist/FlamingoEDSNeo3.d.ts +1 -2
- package/dist/FlamingoEDSNeo3.js +20 -5
- package/dist/GhostMarketNDSNeo3.d.ts +1 -1
- package/dist/GhostMarketNDSNeo3.js +17 -3
- package/dist/LedgerServiceNeo3.d.ts +3 -1
- package/dist/LedgerServiceNeo3.js +3 -0
- package/dist/RpcBDSNeo3.d.ts +4 -4
- package/dist/RpcBDSNeo3.js +17 -17
- package/package.json +6 -3
- package/.eslintignore +0 -13
- package/.eslintrc.cjs +0 -22
- package/.rush/temp/operation/build/all.log +0 -1
- package/.rush/temp/operation/build/state.json +0 -3
- package/.rush/temp/package-deps_build.json +0 -32
- package/.rush/temp/shrinkwrap-deps.json +0 -520
- package/CHANGELOG.json +0 -83
- package/CHANGELOG.md +0 -40
- package/bs-neo3.build.log +0 -1
- package/jest.config.ts +0 -13
- package/jest.setup.ts +0 -1
- package/src/BSNeo3.ts +0 -254
- package/src/DoraBDSNeo3.ts +0 -188
- package/src/DoraESNeo3.ts +0 -19
- package/src/FlamingoEDSNeo3.ts +0 -41
- package/src/GhostMarketNDSNeo3.ts +0 -121
- package/src/LedgerServiceNeo3.ts +0 -107
- package/src/RpcBDSNeo3.ts +0 -161
- package/src/__tests__/BDSNeo3.spec.ts +0 -124
- package/src/__tests__/BSNeo3.spec.ts +0 -175
- package/src/__tests__/DoraESNeo3.spec.ts +0 -23
- package/src/__tests__/FlamingoEDSNeo3.spec.ts +0 -48
- package/src/__tests__/GhostMarketNDSNeo3.spec.ts +0 -48
- package/src/__tests__/utils/sleep.ts +0 -1
- package/src/assets/tokens/common.json +0 -14
- package/src/assets/tokens/mainnet.json +0 -116
- package/src/constants.ts +0 -29
- package/src/index.ts +0 -6
- package/tsconfig.build.json +0 -4
- package/tsconfig.json +0 -14
package/dist/BSNeo3.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { BlockchainDataService, BlockchainService, BSClaimable, Account, ExchangeDataService, BDSClaimable, Token, BSWithNameService, Network, PartialBy, TransferParam, BSCalculableFee, NftDataService, BSWithNft, AccountWithDerivationPath, BSWithExplorerService, ExplorerService, BSWithLedger } from '@cityofzion/blockchain-service';
|
|
2
2
|
import { LedgerServiceNeo3 } from './LedgerServiceNeo3';
|
|
3
|
+
import Transport from '@ledgerhq/hw-transport';
|
|
3
4
|
export declare class BSNeo3<BSCustomName extends string = string> implements BlockchainService, BSClaimable, BSWithNameService, BSCalculableFee, BSWithNft, BSWithExplorerService, BSWithLedger {
|
|
4
5
|
readonly blockchainName: BSCustomName;
|
|
5
6
|
readonly feeToken: Token;
|
|
@@ -13,7 +14,7 @@ export declare class BSNeo3<BSCustomName extends string = string> implements Blo
|
|
|
13
14
|
explorerService: ExplorerService;
|
|
14
15
|
tokens: Token[];
|
|
15
16
|
network: Network;
|
|
16
|
-
constructor(blockchainName: BSCustomName, network: PartialBy<Network, 'url'>);
|
|
17
|
+
constructor(blockchainName: BSCustomName, network: PartialBy<Network, 'url'>, getLedgerTransport?: (account: Account) => Promise<Transport>);
|
|
17
18
|
setNetwork(param: PartialBy<Network, 'url'>): void;
|
|
18
19
|
validateAddress(address: string): boolean;
|
|
19
20
|
validateEncrypted(encryptedKey: string): boolean;
|
|
@@ -26,7 +27,7 @@ export declare class BSNeo3<BSCustomName extends string = string> implements Blo
|
|
|
26
27
|
encrypt(key: string, password: string): Promise<string>;
|
|
27
28
|
calculateTransferFee(param: TransferParam): Promise<string>;
|
|
28
29
|
transfer(param: TransferParam): Promise<string>;
|
|
29
|
-
claim(account: Account): Promise<string>;
|
|
30
|
+
claim(account: Account, isLedger?: boolean): Promise<string>;
|
|
30
31
|
resolveNameServiceDomain(domainName: string): Promise<any>;
|
|
31
32
|
private buildTransferInvocation;
|
|
32
33
|
}
|
package/dist/BSNeo3.js
CHANGED
|
@@ -21,9 +21,9 @@ const bs_asteroid_sdk_1 = require("@cityofzion/bs-asteroid-sdk");
|
|
|
21
21
|
const DoraESNeo3_1 = require("./DoraESNeo3");
|
|
22
22
|
const LedgerServiceNeo3_1 = require("./LedgerServiceNeo3");
|
|
23
23
|
class BSNeo3 {
|
|
24
|
-
constructor(blockchainName, network) {
|
|
25
|
-
this.ledgerService = new LedgerServiceNeo3_1.LedgerServiceNeo3();
|
|
24
|
+
constructor(blockchainName, network, getLedgerTransport) {
|
|
26
25
|
this.blockchainName = blockchainName;
|
|
26
|
+
this.ledgerService = new LedgerServiceNeo3_1.LedgerServiceNeo3(getLedgerTransport);
|
|
27
27
|
this.tokens = constants_1.TOKENS[network.type];
|
|
28
28
|
this.derivationPath = constants_1.DERIVATION_PATH;
|
|
29
29
|
this.feeToken = this.tokens.find(token => token.symbol === 'GAS');
|
|
@@ -106,7 +106,10 @@ class BSNeo3 {
|
|
|
106
106
|
});
|
|
107
107
|
}
|
|
108
108
|
encrypt(key, password) {
|
|
109
|
-
return
|
|
109
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
110
|
+
const encryptedKey = yield neon_js_1.wallet.encrypt(key, password);
|
|
111
|
+
return encryptedKey;
|
|
112
|
+
});
|
|
110
113
|
}
|
|
111
114
|
calculateTransferFee(param) {
|
|
112
115
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -125,11 +128,17 @@ class BSNeo3 {
|
|
|
125
128
|
}
|
|
126
129
|
transfer(param) {
|
|
127
130
|
return __awaiter(this, void 0, void 0, function* () {
|
|
131
|
+
let ledgerTransport;
|
|
132
|
+
if (param.isLedger) {
|
|
133
|
+
if (!this.ledgerService.getLedgerTransport)
|
|
134
|
+
throw new Error('You must provide a getLedgerTransport function to use Ledger');
|
|
135
|
+
ledgerTransport = yield this.ledgerService.getLedgerTransport(param.senderAccount);
|
|
136
|
+
}
|
|
128
137
|
const account = new neon_js_1.wallet.Account(param.senderAccount.key);
|
|
129
138
|
const invoker = yield neon_dappkit_1.NeonInvoker.init({
|
|
130
139
|
rpcAddress: this.network.url,
|
|
131
140
|
account,
|
|
132
|
-
signingCallback:
|
|
141
|
+
signingCallback: ledgerTransport ? this.ledgerService.getSigningCallback(ledgerTransport) : undefined,
|
|
133
142
|
});
|
|
134
143
|
const invocations = this.buildTransferInvocation(param, account);
|
|
135
144
|
const transactionHash = yield invoker.invokeFunction({
|
|
@@ -139,12 +148,20 @@ class BSNeo3 {
|
|
|
139
148
|
return transactionHash;
|
|
140
149
|
});
|
|
141
150
|
}
|
|
142
|
-
claim(account) {
|
|
151
|
+
claim(account, isLedger) {
|
|
143
152
|
return __awaiter(this, void 0, void 0, function* () {
|
|
153
|
+
let ledgerTransport;
|
|
154
|
+
if (isLedger) {
|
|
155
|
+
if (!this.ledgerService.getLedgerTransport)
|
|
156
|
+
throw new Error('You must provide a getLedgerTransport function to use Ledger');
|
|
157
|
+
ledgerTransport = yield this.ledgerService.getLedgerTransport(account);
|
|
158
|
+
}
|
|
144
159
|
const neoAccount = new neon_js_1.wallet.Account(account.key);
|
|
145
160
|
const facade = yield neon_js_1.api.NetworkFacade.fromConfig({ node: this.network.url });
|
|
146
161
|
const transactionHash = yield facade.claimGas(neoAccount, {
|
|
147
|
-
signingCallback:
|
|
162
|
+
signingCallback: ledgerTransport
|
|
163
|
+
? this.ledgerService.getSigningCallback(ledgerTransport)
|
|
164
|
+
: neon_js_1.api.signWithAccount(neoAccount),
|
|
148
165
|
});
|
|
149
166
|
return transactionHash;
|
|
150
167
|
});
|
package/dist/DoraBDSNeo3.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { BalanceResponse, ContractResponse, TransactionsByAddressParams, TransactionsByAddressResponse, TransactionResponse, Network, Token } from '@cityofzion/blockchain-service';
|
|
2
2
|
import { RPCBDSNeo3 } from './RpcBDSNeo3';
|
|
3
3
|
export declare class DoraBDSNeo3 extends RPCBDSNeo3 {
|
|
4
|
-
readonly network: Network;
|
|
5
4
|
constructor(network: Network, feeToken: Token, claimToken: Token);
|
|
6
5
|
getTransaction(hash: string): Promise<TransactionResponse>;
|
|
7
6
|
getTransactionsByAddress({ address, page, }: TransactionsByAddressParams): Promise<TransactionsByAddressResponse>;
|
package/dist/DoraBDSNeo3.js
CHANGED
|
@@ -24,20 +24,19 @@ class DoraBDSNeo3 extends RpcBDSNeo3_1.RPCBDSNeo3 {
|
|
|
24
24
|
throw new Error('DoraBDSNeo3 does not support custom networks');
|
|
25
25
|
}
|
|
26
26
|
super(network, feeToken, claimToken);
|
|
27
|
-
this.network = network;
|
|
28
27
|
}
|
|
29
28
|
getTransaction(hash) {
|
|
30
29
|
var _a, _b;
|
|
31
30
|
return __awaiter(this, void 0, void 0, function* () {
|
|
32
31
|
try {
|
|
33
|
-
const data = yield NeoRest.transaction(hash, this.
|
|
32
|
+
const data = yield NeoRest.transaction(hash, this._network.type);
|
|
34
33
|
return {
|
|
35
34
|
block: data.block,
|
|
36
35
|
time: Number(data.time),
|
|
37
36
|
hash: data.hash,
|
|
38
37
|
fee: neon_js_1.u.BigInteger.fromNumber((_a = data.netfee) !== null && _a !== void 0 ? _a : 0)
|
|
39
38
|
.add(neon_js_1.u.BigInteger.fromNumber((_b = data.sysfee) !== null && _b !== void 0 ? _b : 0))
|
|
40
|
-
.toDecimal(this.
|
|
39
|
+
.toDecimal(this._feeToken.decimals),
|
|
41
40
|
notifications: [],
|
|
42
41
|
transfers: [],
|
|
43
42
|
};
|
|
@@ -49,7 +48,7 @@ class DoraBDSNeo3 extends RpcBDSNeo3_1.RPCBDSNeo3 {
|
|
|
49
48
|
}
|
|
50
49
|
getTransactionsByAddress({ address, page = 1, }) {
|
|
51
50
|
return __awaiter(this, void 0, void 0, function* () {
|
|
52
|
-
const data = yield NeoRest.addressTXFull(address, page, this.
|
|
51
|
+
const data = yield NeoRest.addressTXFull(address, page, this._network.type);
|
|
53
52
|
const promises = data.items.map((item) => __awaiter(this, void 0, void 0, function* () {
|
|
54
53
|
var _a, _b;
|
|
55
54
|
const transferPromises = [];
|
|
@@ -97,7 +96,7 @@ class DoraBDSNeo3 extends RpcBDSNeo3_1.RPCBDSNeo3 {
|
|
|
97
96
|
hash: item.hash,
|
|
98
97
|
fee: neon_js_1.u.BigInteger.fromNumber((_a = item.netfee) !== null && _a !== void 0 ? _a : 0)
|
|
99
98
|
.add(neon_js_1.u.BigInteger.fromNumber((_b = item.sysfee) !== null && _b !== void 0 ? _b : 0))
|
|
100
|
-
.toDecimal(this.
|
|
99
|
+
.toDecimal(this._feeToken.decimals),
|
|
101
100
|
transfers,
|
|
102
101
|
notifications,
|
|
103
102
|
};
|
|
@@ -114,7 +113,7 @@ class DoraBDSNeo3 extends RpcBDSNeo3_1.RPCBDSNeo3 {
|
|
|
114
113
|
var _a, _b;
|
|
115
114
|
return __awaiter(this, void 0, void 0, function* () {
|
|
116
115
|
try {
|
|
117
|
-
const data = yield NeoRest.contract(contractHash, this.
|
|
116
|
+
const data = yield NeoRest.contract(contractHash, this._network.type);
|
|
118
117
|
return {
|
|
119
118
|
hash: data.hash,
|
|
120
119
|
methods: (_b = (_a = data.manifest.abi) === null || _a === void 0 ? void 0 : _a.methods) !== null && _b !== void 0 ? _b : [],
|
|
@@ -128,21 +127,21 @@ class DoraBDSNeo3 extends RpcBDSNeo3_1.RPCBDSNeo3 {
|
|
|
128
127
|
}
|
|
129
128
|
getTokenInfo(tokenHash) {
|
|
130
129
|
return __awaiter(this, void 0, void 0, function* () {
|
|
131
|
-
const localToken = constants_1.TOKENS[this.
|
|
130
|
+
const localToken = constants_1.TOKENS[this._network.type].find(token => token.hash === tokenHash);
|
|
132
131
|
if (localToken)
|
|
133
132
|
return localToken;
|
|
134
|
-
if (this.
|
|
135
|
-
return this.
|
|
133
|
+
if (this._tokenCache.has(tokenHash)) {
|
|
134
|
+
return this._tokenCache.get(tokenHash);
|
|
136
135
|
}
|
|
137
136
|
try {
|
|
138
|
-
const { decimals, symbol, name, scripthash } = yield NeoRest.asset(tokenHash, this.
|
|
137
|
+
const { decimals, symbol, name, scripthash } = yield NeoRest.asset(tokenHash, this._network.type);
|
|
139
138
|
const token = {
|
|
140
139
|
decimals: Number(decimals),
|
|
141
140
|
symbol,
|
|
142
141
|
name,
|
|
143
142
|
hash: scripthash,
|
|
144
143
|
};
|
|
145
|
-
this.
|
|
144
|
+
this._tokenCache.set(tokenHash, token);
|
|
146
145
|
return token;
|
|
147
146
|
}
|
|
148
147
|
catch (_a) {
|
|
@@ -152,7 +151,7 @@ class DoraBDSNeo3 extends RpcBDSNeo3_1.RPCBDSNeo3 {
|
|
|
152
151
|
}
|
|
153
152
|
getBalance(address) {
|
|
154
153
|
return __awaiter(this, void 0, void 0, function* () {
|
|
155
|
-
const response = yield NeoRest.balance(address, this.
|
|
154
|
+
const response = yield NeoRest.balance(address, this._network.type);
|
|
156
155
|
const promises = response.map((balance) => __awaiter(this, void 0, void 0, function* () {
|
|
157
156
|
try {
|
|
158
157
|
const token = yield this.getTokenInfo(balance.asset);
|
package/dist/DoraESNeo3.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ExplorerService, NetworkType, BuildNftUrlParams } from '@cityofzion/blockchain-service';
|
|
2
2
|
export declare class DoraESNeo3 implements ExplorerService {
|
|
3
|
-
private
|
|
3
|
+
#private;
|
|
4
4
|
constructor(networkType: NetworkType);
|
|
5
5
|
buildTransactionUrl(hash: string): string;
|
|
6
6
|
buildNftUrl({ contractHash, tokenId }: BuildNftUrlParams): string;
|
package/dist/DoraESNeo3.js
CHANGED
|
@@ -1,19 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
+
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");
|
|
6
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
+
};
|
|
8
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
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
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
+
};
|
|
13
|
+
var _DoraESNeo3_networkType;
|
|
2
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
15
|
exports.DoraESNeo3 = void 0;
|
|
4
16
|
class DoraESNeo3 {
|
|
5
17
|
constructor(networkType) {
|
|
6
|
-
this
|
|
18
|
+
_DoraESNeo3_networkType.set(this, void 0);
|
|
19
|
+
__classPrivateFieldSet(this, _DoraESNeo3_networkType, networkType, "f");
|
|
7
20
|
}
|
|
8
21
|
buildTransactionUrl(hash) {
|
|
9
|
-
if (this
|
|
22
|
+
if (__classPrivateFieldGet(this, _DoraESNeo3_networkType, "f") === 'custom')
|
|
10
23
|
throw new Error('DoraESNeo3 does not support custom network');
|
|
11
|
-
return `https://dora.coz.io/transaction/neo3/${this
|
|
24
|
+
return `https://dora.coz.io/transaction/neo3/${__classPrivateFieldGet(this, _DoraESNeo3_networkType, "f")}/${hash}`;
|
|
12
25
|
}
|
|
13
26
|
buildNftUrl({ contractHash, tokenId }) {
|
|
14
|
-
if (this
|
|
27
|
+
if (__classPrivateFieldGet(this, _DoraESNeo3_networkType, "f") === 'custom')
|
|
15
28
|
throw new Error('DoraESNeo3 does not support custom network');
|
|
16
|
-
return `https://dora.coz.io/nft/neo3/${this
|
|
29
|
+
return `https://dora.coz.io/nft/neo3/${__classPrivateFieldGet(this, _DoraESNeo3_networkType, "f")}/${contractHash}/${tokenId}`;
|
|
17
30
|
}
|
|
18
31
|
}
|
|
19
32
|
exports.DoraESNeo3 = DoraESNeo3;
|
|
33
|
+
_DoraESNeo3_networkType = new WeakMap();
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Currency, ExchangeDataService, NetworkType, TokenPricesResponse } from '@cityofzion/blockchain-service';
|
|
2
2
|
export declare class FlamingoEDSNeo3 implements ExchangeDataService {
|
|
3
|
-
|
|
4
|
-
private axiosInstance;
|
|
3
|
+
#private;
|
|
5
4
|
constructor(networkType: NetworkType);
|
|
6
5
|
getTokenPrices(currency: Currency): Promise<TokenPricesResponse[]>;
|
|
7
6
|
private getCurrencyRatio;
|
package/dist/FlamingoEDSNeo3.js
CHANGED
|
@@ -8,22 +8,36 @@ 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
|
+
};
|
|
17
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
18
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
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");
|
|
20
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
21
|
+
};
|
|
11
22
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
23
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
24
|
};
|
|
25
|
+
var _FlamingoEDSNeo3_networkType, _FlamingoEDSNeo3_axiosInstance;
|
|
14
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
27
|
exports.FlamingoEDSNeo3 = void 0;
|
|
16
28
|
const axios_1 = __importDefault(require("axios"));
|
|
17
29
|
class FlamingoEDSNeo3 {
|
|
18
30
|
constructor(networkType) {
|
|
19
|
-
this
|
|
20
|
-
|
|
31
|
+
_FlamingoEDSNeo3_networkType.set(this, void 0);
|
|
32
|
+
_FlamingoEDSNeo3_axiosInstance.set(this, void 0);
|
|
33
|
+
__classPrivateFieldSet(this, _FlamingoEDSNeo3_networkType, networkType, "f");
|
|
34
|
+
__classPrivateFieldSet(this, _FlamingoEDSNeo3_axiosInstance, axios_1.default.create({ baseURL: 'https://api.flamingo.finance' }), "f");
|
|
21
35
|
}
|
|
22
36
|
getTokenPrices(currency) {
|
|
23
37
|
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
-
if (this
|
|
38
|
+
if (__classPrivateFieldGet(this, _FlamingoEDSNeo3_networkType, "f") !== 'mainnet')
|
|
25
39
|
throw new Error('Exchange is only available on mainnet');
|
|
26
|
-
const { data: prices } = yield this.
|
|
40
|
+
const { data: prices } = yield __classPrivateFieldGet(this, _FlamingoEDSNeo3_axiosInstance, "f").get('/token-info/prices');
|
|
27
41
|
let currencyRatio = 1;
|
|
28
42
|
if (currency !== 'USD') {
|
|
29
43
|
currencyRatio = yield this.getCurrencyRatio(currency);
|
|
@@ -37,9 +51,10 @@ class FlamingoEDSNeo3 {
|
|
|
37
51
|
}
|
|
38
52
|
getCurrencyRatio(currency) {
|
|
39
53
|
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
-
const { data } = yield this.
|
|
54
|
+
const { data } = yield __classPrivateFieldGet(this, _FlamingoEDSNeo3_axiosInstance, "f").get(`/fiat/exchange-rate?pair=USD_${currency}`);
|
|
41
55
|
return data;
|
|
42
56
|
});
|
|
43
57
|
}
|
|
44
58
|
}
|
|
45
59
|
exports.FlamingoEDSNeo3 = FlamingoEDSNeo3;
|
|
60
|
+
_FlamingoEDSNeo3_networkType = new WeakMap(), _FlamingoEDSNeo3_axiosInstance = new WeakMap();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { NftResponse, NftsResponse, NetworkType, NftDataService, GetNftParam, GetNftsByAddressParams } from '@cityofzion/blockchain-service';
|
|
2
2
|
export declare class GhostMarketNDSNeo3 implements NftDataService {
|
|
3
|
-
private
|
|
3
|
+
#private;
|
|
4
4
|
constructor(networkType: NetworkType);
|
|
5
5
|
getNftsByAddress({ address, size, cursor }: GetNftsByAddressParams): Promise<NftsResponse>;
|
|
6
6
|
getNft({ contractHash, tokenId }: GetNftParam): Promise<NftResponse>;
|
|
@@ -8,9 +8,21 @@ 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
|
+
};
|
|
17
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
18
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
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");
|
|
20
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
21
|
+
};
|
|
11
22
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
23
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
24
|
};
|
|
25
|
+
var _GhostMarketNDSNeo3_networkType;
|
|
14
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
27
|
exports.GhostMarketNDSNeo3 = void 0;
|
|
16
28
|
const query_string_1 = __importDefault(require("query-string"));
|
|
@@ -18,7 +30,8 @@ const axios_1 = __importDefault(require("axios"));
|
|
|
18
30
|
const constants_1 = require("./constants");
|
|
19
31
|
class GhostMarketNDSNeo3 {
|
|
20
32
|
constructor(networkType) {
|
|
21
|
-
this
|
|
33
|
+
_GhostMarketNDSNeo3_networkType.set(this, void 0);
|
|
34
|
+
__classPrivateFieldSet(this, _GhostMarketNDSNeo3_networkType, networkType, "f");
|
|
22
35
|
}
|
|
23
36
|
getNftsByAddress({ address, size = 18, cursor }) {
|
|
24
37
|
var _a;
|
|
@@ -54,8 +67,8 @@ class GhostMarketNDSNeo3 {
|
|
|
54
67
|
return srcImage;
|
|
55
68
|
}
|
|
56
69
|
getUrlWithParams(params) {
|
|
57
|
-
const parameters = query_string_1.default.stringify(Object.assign({ chain: constants_1.GHOSTMARKET_CHAIN_BY_NETWORK_TYPE[this
|
|
58
|
-
return `${constants_1.GHOSTMARKET_URL_BY_NETWORK_TYPE[this
|
|
70
|
+
const parameters = query_string_1.default.stringify(Object.assign({ chain: constants_1.GHOSTMARKET_CHAIN_BY_NETWORK_TYPE[__classPrivateFieldGet(this, _GhostMarketNDSNeo3_networkType, "f")] }, params), { arrayFormat: 'bracket' });
|
|
71
|
+
return `${constants_1.GHOSTMARKET_URL_BY_NETWORK_TYPE[__classPrivateFieldGet(this, _GhostMarketNDSNeo3_networkType, "f")]}/assets?${parameters}`;
|
|
59
72
|
}
|
|
60
73
|
parse(data) {
|
|
61
74
|
var _a, _b;
|
|
@@ -77,3 +90,4 @@ class GhostMarketNDSNeo3 {
|
|
|
77
90
|
}
|
|
78
91
|
}
|
|
79
92
|
exports.GhostMarketNDSNeo3 = GhostMarketNDSNeo3;
|
|
93
|
+
_GhostMarketNDSNeo3_networkType = new WeakMap();
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { LedgerService } from '@cityofzion/blockchain-service';
|
|
1
|
+
import { Account, LedgerService } from '@cityofzion/blockchain-service';
|
|
2
2
|
import Transport from '@ledgerhq/hw-transport';
|
|
3
3
|
import { api } from '@cityofzion/neon-js';
|
|
4
4
|
export declare class LedgerServiceNeo3 implements LedgerService {
|
|
5
|
+
getLedgerTransport?: ((account: Account) => Promise<Transport>) | undefined;
|
|
6
|
+
constructor(getLedgerTransport?: ((account: Account) => Promise<Transport>) | undefined);
|
|
5
7
|
getAddress(transport: Transport): Promise<string>;
|
|
6
8
|
getSigningCallback(transport: Transport): api.SigningFunction;
|
|
7
9
|
getSignature(transport: Transport, serializedTransaction: string, networkMagic: number, addressIndex?: number): Promise<string>;
|
|
@@ -13,6 +13,9 @@ exports.LedgerServiceNeo3 = void 0;
|
|
|
13
13
|
const neon_js_1 = require("@cityofzion/neon-js");
|
|
14
14
|
const neon_dappkit_1 = require("@cityofzion/neon-dappkit");
|
|
15
15
|
class LedgerServiceNeo3 {
|
|
16
|
+
constructor(getLedgerTransport) {
|
|
17
|
+
this.getLedgerTransport = getLedgerTransport;
|
|
18
|
+
}
|
|
16
19
|
getAddress(transport) {
|
|
17
20
|
return __awaiter(this, void 0, void 0, function* () {
|
|
18
21
|
const publicKey = yield this.getPublicKey(transport);
|
package/dist/RpcBDSNeo3.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { BDSClaimable, BalanceResponse, BlockchainDataService, ContractResponse, Network, Token, TransactionResponse, TransactionsByAddressParams, TransactionsByAddressResponse } from '@cityofzion/blockchain-service';
|
|
2
2
|
export declare class RPCBDSNeo3 implements BlockchainDataService, BDSClaimable {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
readonly
|
|
3
|
+
readonly _tokenCache: Map<string, Token>;
|
|
4
|
+
readonly _feeToken: Token;
|
|
5
|
+
readonly _claimToken: Token;
|
|
6
|
+
readonly _network: Network;
|
|
7
7
|
maxTimeToConfirmTransactionInMs: number;
|
|
8
8
|
constructor(network: Network, feeToken: Token, claimToken: Token);
|
|
9
9
|
getTransaction(hash: string): Promise<TransactionResponse>;
|
package/dist/RpcBDSNeo3.js
CHANGED
|
@@ -15,24 +15,24 @@ const neon_dappkit_1 = require("@cityofzion/neon-dappkit");
|
|
|
15
15
|
const constants_1 = require("./constants");
|
|
16
16
|
class RPCBDSNeo3 {
|
|
17
17
|
constructor(network, feeToken, claimToken) {
|
|
18
|
-
this.
|
|
18
|
+
this._tokenCache = new Map();
|
|
19
19
|
this.maxTimeToConfirmTransactionInMs = 1000 * 60 * 2;
|
|
20
|
-
this.
|
|
21
|
-
this.
|
|
22
|
-
this.
|
|
20
|
+
this._network = network;
|
|
21
|
+
this._feeToken = feeToken;
|
|
22
|
+
this._claimToken = claimToken;
|
|
23
23
|
}
|
|
24
24
|
getTransaction(hash) {
|
|
25
25
|
var _a, _b;
|
|
26
26
|
return __awaiter(this, void 0, void 0, function* () {
|
|
27
27
|
try {
|
|
28
|
-
const rpcClient = new neon_core_1.rpc.RPCClient(this.
|
|
28
|
+
const rpcClient = new neon_core_1.rpc.RPCClient(this._network.url);
|
|
29
29
|
const response = yield rpcClient.getRawTransaction(hash, true);
|
|
30
30
|
return {
|
|
31
31
|
hash: response.hash,
|
|
32
32
|
block: response.validuntilblock,
|
|
33
33
|
fee: neon_core_1.u.BigInteger.fromNumber((_a = response.netfee) !== null && _a !== void 0 ? _a : 0)
|
|
34
34
|
.add(neon_core_1.u.BigInteger.fromNumber((_b = response.sysfee) !== null && _b !== void 0 ? _b : 0))
|
|
35
|
-
.toDecimal(this.
|
|
35
|
+
.toDecimal(this._feeToken.decimals),
|
|
36
36
|
notifications: [],
|
|
37
37
|
transfers: [],
|
|
38
38
|
time: response.blocktime,
|
|
@@ -51,7 +51,7 @@ class RPCBDSNeo3 {
|
|
|
51
51
|
getContract(contractHash) {
|
|
52
52
|
return __awaiter(this, void 0, void 0, function* () {
|
|
53
53
|
try {
|
|
54
|
-
const rpcClient = new neon_core_1.rpc.RPCClient(this.
|
|
54
|
+
const rpcClient = new neon_core_1.rpc.RPCClient(this._network.url);
|
|
55
55
|
const contractState = yield rpcClient.getContractState(contractHash);
|
|
56
56
|
const methods = contractState.manifest.abi.methods.map(method => ({
|
|
57
57
|
name: method.name,
|
|
@@ -73,17 +73,17 @@ 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.
|
|
76
|
+
const localToken = constants_1.TOKENS[this._network.type].find(token => token.hash === tokenHash);
|
|
77
77
|
if (localToken)
|
|
78
78
|
return localToken;
|
|
79
|
-
if (this.
|
|
80
|
-
return this.
|
|
79
|
+
if (this._tokenCache.has(tokenHash)) {
|
|
80
|
+
return this._tokenCache.get(tokenHash);
|
|
81
81
|
}
|
|
82
82
|
try {
|
|
83
|
-
const rpcClient = new neon_core_1.rpc.RPCClient(this.
|
|
83
|
+
const rpcClient = new neon_core_1.rpc.RPCClient(this._network.url);
|
|
84
84
|
const contractState = yield rpcClient.getContractState(tokenHash);
|
|
85
85
|
const invoker = yield neon_dappkit_1.NeonInvoker.init({
|
|
86
|
-
rpcAddress: this.
|
|
86
|
+
rpcAddress: this._network.url,
|
|
87
87
|
});
|
|
88
88
|
const response = yield invoker.testInvoke({
|
|
89
89
|
invocations: [
|
|
@@ -107,7 +107,7 @@ class RPCBDSNeo3 {
|
|
|
107
107
|
hash: contractState.hash,
|
|
108
108
|
decimals,
|
|
109
109
|
};
|
|
110
|
-
this.
|
|
110
|
+
this._tokenCache.set(tokenHash, token);
|
|
111
111
|
return token;
|
|
112
112
|
}
|
|
113
113
|
catch (_a) {
|
|
@@ -117,7 +117,7 @@ class RPCBDSNeo3 {
|
|
|
117
117
|
}
|
|
118
118
|
getBalance(address) {
|
|
119
119
|
return __awaiter(this, void 0, void 0, function* () {
|
|
120
|
-
const rpcClient = new neon_core_1.rpc.RPCClient(this.
|
|
120
|
+
const rpcClient = new neon_core_1.rpc.RPCClient(this._network.url);
|
|
121
121
|
const response = yield rpcClient.getNep17Balances(address);
|
|
122
122
|
const promises = response.balance.map((balance) => __awaiter(this, void 0, void 0, function* () {
|
|
123
123
|
var _a;
|
|
@@ -144,15 +144,15 @@ class RPCBDSNeo3 {
|
|
|
144
144
|
}
|
|
145
145
|
getBlockHeight() {
|
|
146
146
|
return __awaiter(this, void 0, void 0, function* () {
|
|
147
|
-
const rpcClient = new neon_core_1.rpc.RPCClient(this.
|
|
147
|
+
const rpcClient = new neon_core_1.rpc.RPCClient(this._network.url);
|
|
148
148
|
return yield rpcClient.getBlockCount();
|
|
149
149
|
});
|
|
150
150
|
}
|
|
151
151
|
getUnclaimed(address) {
|
|
152
152
|
return __awaiter(this, void 0, void 0, function* () {
|
|
153
|
-
const rpcClient = new neon_core_1.rpc.RPCClient(this.
|
|
153
|
+
const rpcClient = new neon_core_1.rpc.RPCClient(this._network.url);
|
|
154
154
|
const response = yield rpcClient.getUnclaimedGas(address);
|
|
155
|
-
return neon_core_1.u.BigInteger.fromNumber(response).toDecimal(this.
|
|
155
|
+
return neon_core_1.u.BigInteger.fromNumber(response).toDecimal(this._claimToken.decimals);
|
|
156
156
|
});
|
|
157
157
|
}
|
|
158
158
|
}
|
package/package.json
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cityofzion/bs-neo3",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.1",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"repository": "https://github.com/CityOfZion/blockchain-services",
|
|
7
7
|
"author": "Coz",
|
|
8
8
|
"license": "MIT",
|
|
9
|
+
"files": [
|
|
10
|
+
"/dist"
|
|
11
|
+
],
|
|
9
12
|
"dependencies": {
|
|
10
13
|
"@cityofzion/neon-js": "5.5.1",
|
|
11
14
|
"@cityofzion/neon-core": "5.5.1",
|
|
@@ -16,8 +19,8 @@
|
|
|
16
19
|
"@cityofzion/neon-dappkit": "0.4.1",
|
|
17
20
|
"@cityofzion/neon-dappkit-types": "~0.3.1",
|
|
18
21
|
"@ledgerhq/hw-transport-node-hid": "~6.28.5",
|
|
19
|
-
"@cityofzion/
|
|
20
|
-
"@cityofzion/
|
|
22
|
+
"@cityofzion/blockchain-service": "0.11.0",
|
|
23
|
+
"@cityofzion/bs-asteroid-sdk": "0.8.0"
|
|
21
24
|
},
|
|
22
25
|
"devDependencies": {
|
|
23
26
|
"@types/jest": "29.5.3",
|
package/.eslintignore
DELETED
package/.eslintrc.cjs
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended'],
|
|
3
|
-
parser: '@typescript-eslint/parser',
|
|
4
|
-
plugins: ['@typescript-eslint'],
|
|
5
|
-
parserOptions: {
|
|
6
|
-
parser: '@typescript-eslint/parser',
|
|
7
|
-
},
|
|
8
|
-
root: true,
|
|
9
|
-
rules: {
|
|
10
|
-
'@typescript-eslint/ban-ts-comment': 'off',
|
|
11
|
-
'@typescript-eslint/no-explicit-any': 'off',
|
|
12
|
-
'@typescript-eslint/no-unused-vars': [
|
|
13
|
-
'error',
|
|
14
|
-
{
|
|
15
|
-
varsIgnorePattern: '^_',
|
|
16
|
-
argsIgnorePattern: '^_',
|
|
17
|
-
},
|
|
18
|
-
],
|
|
19
|
-
'@typescript-eslint/no-var-requires': 'off',
|
|
20
|
-
'no-unused-vars': 'off',
|
|
21
|
-
},
|
|
22
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Invoking: tsc --project tsconfig.build.json
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"files": {
|
|
3
|
-
"packages/bs-neo3/.eslintignore": "3ee402c88b68258919e4f4b4eef4f25e5d078d90",
|
|
4
|
-
"packages/bs-neo3/.eslintrc.cjs": "5ec0bf6332ec01b3e02beb532bb47025c4c1bf7b",
|
|
5
|
-
"packages/bs-neo3/CHANGELOG.json": "0688f602e3434f9ed65b1ead92b26ee7e44fc684",
|
|
6
|
-
"packages/bs-neo3/CHANGELOG.md": "b6c76db44e9267156107719375c84649dd1bb5e1",
|
|
7
|
-
"packages/bs-neo3/jest.config.ts": "d944475db93cbe41a9339187fd94b9962e411c43",
|
|
8
|
-
"packages/bs-neo3/jest.setup.ts": "9a1976a32050616d4d2ee95b1aa21041bc4daca3",
|
|
9
|
-
"packages/bs-neo3/package.json": "bec4d27adae5e4f00064c6d66c75b41e09befa43",
|
|
10
|
-
"packages/bs-neo3/src/BSNeo3.ts": "aba770bbc30b53f63b5dc7eb57ecdde1e75c4c64",
|
|
11
|
-
"packages/bs-neo3/src/DoraBDSNeo3.ts": "35c2e26cc2c19e41c4dceb226e00238bdca45c87",
|
|
12
|
-
"packages/bs-neo3/src/DoraESNeo3.ts": "c3d36ee5c38cda45c08f517c49976af6d69c5711",
|
|
13
|
-
"packages/bs-neo3/src/FlamingoEDSNeo3.ts": "2a67c9716bc005210dbb9c0e5208a7576af44686",
|
|
14
|
-
"packages/bs-neo3/src/GhostMarketNDSNeo3.ts": "fb7109adfc16c652c56fa06ee14bbd58b9b61ceb",
|
|
15
|
-
"packages/bs-neo3/src/LedgerServiceNeo3.ts": "afd3b243d286c53c5a37d0949bf648f4ebb1b331",
|
|
16
|
-
"packages/bs-neo3/src/RpcBDSNeo3.ts": "402c3fdaa09992e6ebc8241db8633e12b285c8c9",
|
|
17
|
-
"packages/bs-neo3/src/__tests__/BDSNeo3.spec.ts": "5dc529cc41f64df6b603821c48fae282fed99220",
|
|
18
|
-
"packages/bs-neo3/src/__tests__/BSNeo3.spec.ts": "ecd2ad60cdb1123c5eb9b8001bfc5a088f4b014b",
|
|
19
|
-
"packages/bs-neo3/src/__tests__/DoraESNeo3.spec.ts": "450e087014c22b1a289e64dd80ff3e6ddfd8c932",
|
|
20
|
-
"packages/bs-neo3/src/__tests__/FlamingoEDSNeo3.spec.ts": "473b1aafe03031a28a8414dfa681b06f843acdf6",
|
|
21
|
-
"packages/bs-neo3/src/__tests__/GhostMarketNDSNeo3.spec.ts": "c1e835ab5016e8b8d7b3747cc0ed752093dbb967",
|
|
22
|
-
"packages/bs-neo3/src/__tests__/utils/sleep.ts": "c1eb515dad9f5c11eef5d5e77c85db4c3c8196a8",
|
|
23
|
-
"packages/bs-neo3/src/assets/tokens/common.json": "5fad5e8ad81723783ae4e594ff80614908081efd",
|
|
24
|
-
"packages/bs-neo3/src/assets/tokens/mainnet.json": "5aa5b375c4fe2537fec71389746cf906a4afebf5",
|
|
25
|
-
"packages/bs-neo3/src/constants.ts": "233a2c83f1829629865ace6fbf9c66cd39489c51",
|
|
26
|
-
"packages/bs-neo3/src/index.ts": "bad314a9ba14b57075684c9b823a934863bac6b2",
|
|
27
|
-
"packages/bs-neo3/tsconfig.build.json": "4dc23fb9c4c5e4d19a9bc3947a47c523f4bd967c",
|
|
28
|
-
"packages/bs-neo3/tsconfig.json": "77cf2b789e9c665b62792f9992cc81ae86296ef7",
|
|
29
|
-
"packages/bs-neo3/.rush/temp/shrinkwrap-deps.json": "d7141f31b9d802b7f2128a871ea0fe2b4b4f8c6b"
|
|
30
|
-
},
|
|
31
|
-
"arguments": "tsc --project tsconfig.build.json "
|
|
32
|
-
}
|