@cityofzion/bs-ethereum 1.1.0 → 1.2.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/BSEthereum.d.ts +3 -2
- package/dist/BSEthereum.js +27 -7
- package/dist/BitqueryBDSEthereum.d.ts +1 -2
- package/dist/BitqueryBDSEthereum.js +27 -12
- package/dist/BitqueryEDSEthereum.d.ts +1 -2
- package/dist/BitqueryEDSEthereum.js +20 -5
- package/dist/GhostMarketNDSEthereum.d.ts +1 -1
- package/dist/GhostMarketNDSEthereum.js +17 -3
- package/dist/LedgerServiceEthereum.d.ts +4 -2
- package/dist/LedgerServiceEthereum.js +13 -5
- package/dist/RpcBDSEthereum.d.ts +1 -1
- package/dist/RpcBDSEthereum.js +21 -7
- package/package.json +5 -2
- 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 -30
- package/.rush/temp/shrinkwrap-deps.json +0 -531
- package/CHANGELOG.json +0 -126
- package/CHANGELOG.md +0 -68
- package/bs-ethereum.build.log +0 -1
- package/jest.config.ts +0 -13
- package/jest.setup.ts +0 -1
- package/src/BSEthereum.ts +0 -208
- package/src/BitqueryBDSEthereum.ts +0 -231
- package/src/BitqueryEDSEthereum.ts +0 -67
- package/src/GhostMarketNDSEthereum.ts +0 -125
- package/src/LedgerServiceEthereum.ts +0 -44
- package/src/RpcBDSEthereum.ts +0 -88
- package/src/__tests__/BSEthereum.spec.ts +0 -172
- package/src/__tests__/BitqueryBDSEthereum.spec.ts +0 -106
- package/src/__tests__/BitqueryEDSEthereum.spec.ts +0 -55
- package/src/__tests__/GhostMarketNDSEthereum.spec.ts +0 -49
- package/src/__tests__/RpcBDSEthereum.spec.ts +0 -62
- package/src/assets/tokens/common.json +0 -8
- package/src/constants.ts +0 -36
- package/src/graphql.ts +0 -288
- package/src/index.ts +0 -6
- package/tsconfig.build.json +0 -4
- package/tsconfig.json +0 -15
package/dist/BSEthereum.d.ts
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import { Account, AccountWithDerivationPath, BSCalculableFee, BSWithLedger, BSWithNameService, BSWithNft, BlockchainDataService, BlockchainService, ExchangeDataService, Network, NftDataService, PartialBy, Token, TransferParam } from '@cityofzion/blockchain-service';
|
|
2
2
|
import { LedgerServiceEthereum } from './LedgerServiceEthereum';
|
|
3
|
+
import Transport from '@ledgerhq/hw-transport';
|
|
3
4
|
export declare class BSEthereum<BSCustomName extends string = string> implements BlockchainService, BSWithNft, BSWithNameService, BSCalculableFee, BSWithLedger {
|
|
5
|
+
#private;
|
|
4
6
|
readonly blockchainName: BSCustomName;
|
|
5
7
|
readonly feeToken: Token;
|
|
6
8
|
readonly derivationPath: string;
|
|
7
|
-
private readonly bitqueryApiKey;
|
|
8
9
|
blockchainDataService: BlockchainDataService;
|
|
9
10
|
exchangeDataService: ExchangeDataService;
|
|
10
11
|
ledgerService: LedgerServiceEthereum;
|
|
11
12
|
tokens: Token[];
|
|
12
13
|
nftDataService: NftDataService;
|
|
13
14
|
network: Network;
|
|
14
|
-
constructor(blockchainName: BSCustomName, network: PartialBy<Network, 'url'>, bitqueryApiKey: string);
|
|
15
|
+
constructor(blockchainName: BSCustomName, network: PartialBy<Network, 'url'>, bitqueryApiKey: string, getLedgerTransport?: (account: Account) => Promise<Transport>);
|
|
15
16
|
setNetwork(param: PartialBy<Network, 'url'>): void;
|
|
16
17
|
validateAddress(address: string): boolean;
|
|
17
18
|
validateEncrypted(json: string): boolean;
|
package/dist/BSEthereum.js
CHANGED
|
@@ -31,6 +31,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
31
31
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
32
|
});
|
|
33
33
|
};
|
|
34
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
35
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
36
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
37
|
+
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");
|
|
38
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
39
|
+
};
|
|
40
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
41
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
42
|
+
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");
|
|
43
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
44
|
+
};
|
|
45
|
+
var _BSEthereum_bitqueryApiKey;
|
|
34
46
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
47
|
exports.BSEthereum = void 0;
|
|
36
48
|
const ethers_1 = require("ethers");
|
|
@@ -44,12 +56,13 @@ const RpcBDSEthereum_1 = require("./RpcBDSEthereum");
|
|
|
44
56
|
const BitqueryBDSEthereum_1 = require("./BitqueryBDSEthereum");
|
|
45
57
|
const LedgerServiceEthereum_1 = require("./LedgerServiceEthereum");
|
|
46
58
|
class BSEthereum {
|
|
47
|
-
constructor(blockchainName, network, bitqueryApiKey) {
|
|
48
|
-
this
|
|
59
|
+
constructor(blockchainName, network, bitqueryApiKey, getLedgerTransport) {
|
|
60
|
+
_BSEthereum_bitqueryApiKey.set(this, void 0);
|
|
49
61
|
this.blockchainName = blockchainName;
|
|
62
|
+
this.ledgerService = new LedgerServiceEthereum_1.LedgerServiceEthereum(getLedgerTransport);
|
|
50
63
|
this.derivationPath = constants_1.DERIVATION_PATH;
|
|
51
64
|
this.tokens = constants_1.TOKENS[network.type];
|
|
52
|
-
this
|
|
65
|
+
__classPrivateFieldSet(this, _BSEthereum_bitqueryApiKey, bitqueryApiKey, "f");
|
|
53
66
|
this.feeToken = this.tokens.find(token => token.symbol === 'ETH');
|
|
54
67
|
this.setNetwork(network);
|
|
55
68
|
}
|
|
@@ -64,9 +77,9 @@ class BSEthereum {
|
|
|
64
77
|
this.blockchainDataService = new RpcBDSEthereum_1.RpcBDSEthereum(network);
|
|
65
78
|
}
|
|
66
79
|
else {
|
|
67
|
-
this.blockchainDataService = new BitqueryBDSEthereum_1.BitqueryBDSEthereum(network, this
|
|
80
|
+
this.blockchainDataService = new BitqueryBDSEthereum_1.BitqueryBDSEthereum(network, __classPrivateFieldGet(this, _BSEthereum_bitqueryApiKey, "f"));
|
|
68
81
|
}
|
|
69
|
-
this.exchangeDataService = new BitqueryEDSEthereum_1.BitqueryEDSEthereum(network.type, this
|
|
82
|
+
this.exchangeDataService = new BitqueryEDSEthereum_1.BitqueryEDSEthereum(network.type, __classPrivateFieldGet(this, _BSEthereum_bitqueryApiKey, "f"));
|
|
70
83
|
this.nftDataService = new GhostMarketNDSEthereum_1.GhostMarketNDSEthereum(network.type);
|
|
71
84
|
}
|
|
72
85
|
validateAddress(address) {
|
|
@@ -139,8 +152,14 @@ class BSEthereum {
|
|
|
139
152
|
var _a;
|
|
140
153
|
return __awaiter(this, void 0, void 0, function* () {
|
|
141
154
|
const provider = new ethers_1.ethers.providers.JsonRpcProvider(this.network.url);
|
|
142
|
-
|
|
143
|
-
|
|
155
|
+
let ledgerTransport;
|
|
156
|
+
if (param.isLedger) {
|
|
157
|
+
if (!this.ledgerService.getLedgerTransport)
|
|
158
|
+
throw new Error('You must provide getLedgerTransport function to use Ledger');
|
|
159
|
+
ledgerTransport = yield this.ledgerService.getLedgerTransport(param.senderAccount);
|
|
160
|
+
}
|
|
161
|
+
const signTransactionFunction = ledgerTransport
|
|
162
|
+
? yield this.ledgerService.getSignTransactionFunction(ledgerTransport)
|
|
144
163
|
: new ethers_1.ethers.Wallet(param.senderAccount.key, provider).signTransaction;
|
|
145
164
|
const decimals = (_a = param.intent.tokenDecimals) !== null && _a !== void 0 ? _a : 18;
|
|
146
165
|
const amount = ethersBigNumber.parseFixed(param.intent.amount, decimals);
|
|
@@ -198,3 +217,4 @@ class BSEthereum {
|
|
|
198
217
|
}
|
|
199
218
|
}
|
|
200
219
|
exports.BSEthereum = BSEthereum;
|
|
220
|
+
_BSEthereum_bitqueryApiKey = new WeakMap();
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { BalanceResponse, ContractResponse, Token, TransactionsByAddressParams, TransactionsByAddressResponse, TransactionResponse, Network } from '@cityofzion/blockchain-service';
|
|
2
2
|
import { RpcBDSEthereum } from './RpcBDSEthereum';
|
|
3
3
|
export declare class BitqueryBDSEthereum extends RpcBDSEthereum {
|
|
4
|
-
private
|
|
5
|
-
private readonly networkType;
|
|
4
|
+
#private;
|
|
6
5
|
maxTimeToConfirmTransactionInMs: number;
|
|
7
6
|
constructor(network: Network, apiKey: string);
|
|
8
7
|
getTransaction(hash: string): Promise<TransactionResponse>;
|
|
@@ -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 _BitqueryBDSEthereum_client, _BitqueryBDSEthereum_networkType;
|
|
14
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
27
|
exports.BitqueryBDSEthereum = void 0;
|
|
16
28
|
const core_1 = require("@urql/core");
|
|
@@ -21,11 +33,13 @@ const RpcBDSEthereum_1 = require("./RpcBDSEthereum");
|
|
|
21
33
|
class BitqueryBDSEthereum extends RpcBDSEthereum_1.RpcBDSEthereum {
|
|
22
34
|
constructor(network, apiKey) {
|
|
23
35
|
super(network);
|
|
36
|
+
_BitqueryBDSEthereum_client.set(this, void 0);
|
|
37
|
+
_BitqueryBDSEthereum_networkType.set(this, void 0);
|
|
24
38
|
this.maxTimeToConfirmTransactionInMs = 1000 * 60 * 8;
|
|
25
39
|
if (network.type === 'custom')
|
|
26
40
|
throw new Error('Custom network not supported');
|
|
27
|
-
this
|
|
28
|
-
this
|
|
41
|
+
__classPrivateFieldSet(this, _BitqueryBDSEthereum_networkType, network.type, "f");
|
|
42
|
+
__classPrivateFieldSet(this, _BitqueryBDSEthereum_client, new core_1.Client({
|
|
29
43
|
url: constants_1.BITQUERY_URL,
|
|
30
44
|
exchanges: [core_1.fetchExchange],
|
|
31
45
|
fetch: node_fetch_1.default,
|
|
@@ -34,14 +48,14 @@ class BitqueryBDSEthereum extends RpcBDSEthereum_1.RpcBDSEthereum {
|
|
|
34
48
|
'X-API-KEY': apiKey,
|
|
35
49
|
},
|
|
36
50
|
},
|
|
37
|
-
});
|
|
51
|
+
}), "f");
|
|
38
52
|
}
|
|
39
53
|
getTransaction(hash) {
|
|
40
54
|
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
-
const result = yield this
|
|
55
|
+
const result = yield __classPrivateFieldGet(this, _BitqueryBDSEthereum_client, "f")
|
|
42
56
|
.query(graphql_1.bitqueryGetTransactionQuery, {
|
|
43
57
|
hash,
|
|
44
|
-
network: constants_1.BITQUERY_NETWORK_BY_NETWORK_TYPE[this
|
|
58
|
+
network: constants_1.BITQUERY_NETWORK_BY_NETWORK_TYPE[__classPrivateFieldGet(this, _BitqueryBDSEthereum_networkType, "f")],
|
|
45
59
|
})
|
|
46
60
|
.toPromise();
|
|
47
61
|
if (result.error)
|
|
@@ -65,12 +79,12 @@ class BitqueryBDSEthereum extends RpcBDSEthereum_1.RpcBDSEthereum {
|
|
|
65
79
|
return __awaiter(this, void 0, void 0, function* () {
|
|
66
80
|
const limit = 10;
|
|
67
81
|
const offset = limit * (page - 1);
|
|
68
|
-
const result = yield this
|
|
82
|
+
const result = yield __classPrivateFieldGet(this, _BitqueryBDSEthereum_client, "f")
|
|
69
83
|
.query(graphql_1.bitqueryGetTransactionsByAddressQuery, {
|
|
70
84
|
address,
|
|
71
85
|
limit,
|
|
72
86
|
offset,
|
|
73
|
-
network: constants_1.BITQUERY_NETWORK_BY_NETWORK_TYPE[this
|
|
87
|
+
network: constants_1.BITQUERY_NETWORK_BY_NETWORK_TYPE[__classPrivateFieldGet(this, _BitqueryBDSEthereum_networkType, "f")],
|
|
74
88
|
})
|
|
75
89
|
.toPromise();
|
|
76
90
|
if (result.error)
|
|
@@ -110,13 +124,13 @@ class BitqueryBDSEthereum extends RpcBDSEthereum_1.RpcBDSEthereum {
|
|
|
110
124
|
}
|
|
111
125
|
getTokenInfo(hash) {
|
|
112
126
|
return __awaiter(this, void 0, void 0, function* () {
|
|
113
|
-
const localToken = constants_1.TOKENS[this
|
|
127
|
+
const localToken = constants_1.TOKENS[__classPrivateFieldGet(this, _BitqueryBDSEthereum_networkType, "f")].find(token => token.hash === hash);
|
|
114
128
|
if (localToken)
|
|
115
129
|
return localToken;
|
|
116
|
-
const result = yield this
|
|
130
|
+
const result = yield __classPrivateFieldGet(this, _BitqueryBDSEthereum_client, "f")
|
|
117
131
|
.query(graphql_1.bitqueryGetTokenInfoQuery, {
|
|
118
132
|
hash,
|
|
119
|
-
network: constants_1.BITQUERY_NETWORK_BY_NETWORK_TYPE[this
|
|
133
|
+
network: constants_1.BITQUERY_NETWORK_BY_NETWORK_TYPE[__classPrivateFieldGet(this, _BitqueryBDSEthereum_networkType, "f")],
|
|
120
134
|
})
|
|
121
135
|
.toPromise();
|
|
122
136
|
if (result.error)
|
|
@@ -137,10 +151,10 @@ class BitqueryBDSEthereum extends RpcBDSEthereum_1.RpcBDSEthereum {
|
|
|
137
151
|
getBalance(address) {
|
|
138
152
|
var _a, _b, _c, _d;
|
|
139
153
|
return __awaiter(this, void 0, void 0, function* () {
|
|
140
|
-
const result = yield this
|
|
154
|
+
const result = yield __classPrivateFieldGet(this, _BitqueryBDSEthereum_client, "f")
|
|
141
155
|
.query(graphql_1.bitqueryGetBalanceQuery, {
|
|
142
156
|
address,
|
|
143
|
-
network: constants_1.BITQUERY_NETWORK_BY_NETWORK_TYPE[this
|
|
157
|
+
network: constants_1.BITQUERY_NETWORK_BY_NETWORK_TYPE[__classPrivateFieldGet(this, _BitqueryBDSEthereum_networkType, "f")],
|
|
144
158
|
})
|
|
145
159
|
.toPromise();
|
|
146
160
|
if (result.error)
|
|
@@ -196,3 +210,4 @@ class BitqueryBDSEthereum extends RpcBDSEthereum_1.RpcBDSEthereum {
|
|
|
196
210
|
}
|
|
197
211
|
}
|
|
198
212
|
exports.BitqueryBDSEthereum = BitqueryBDSEthereum;
|
|
213
|
+
_BitqueryBDSEthereum_client = new WeakMap(), _BitqueryBDSEthereum_networkType = new WeakMap();
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Currency, ExchangeDataService, NetworkType, TokenPricesResponse } from '@cityofzion/blockchain-service';
|
|
2
2
|
export declare class BitqueryEDSEthereum implements ExchangeDataService {
|
|
3
|
-
private
|
|
4
|
-
private readonly networkType;
|
|
3
|
+
#private;
|
|
5
4
|
constructor(networkType: NetworkType, apiKey: string);
|
|
6
5
|
getTokenPrices(currency: Currency): Promise<TokenPricesResponse[]>;
|
|
7
6
|
private getCurrencyRatio;
|
|
@@ -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 _BitqueryEDSEthereum_client, _BitqueryEDSEthereum_networkType;
|
|
14
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
27
|
exports.BitqueryEDSEthereum = void 0;
|
|
16
28
|
const core_1 = require("@urql/core");
|
|
@@ -22,8 +34,10 @@ const graphql_1 = require("./graphql");
|
|
|
22
34
|
dayjs_1.default.extend(utc_1.default);
|
|
23
35
|
class BitqueryEDSEthereum {
|
|
24
36
|
constructor(networkType, apiKey) {
|
|
25
|
-
this
|
|
26
|
-
this
|
|
37
|
+
_BitqueryEDSEthereum_client.set(this, void 0);
|
|
38
|
+
_BitqueryEDSEthereum_networkType.set(this, void 0);
|
|
39
|
+
__classPrivateFieldSet(this, _BitqueryEDSEthereum_networkType, networkType, "f");
|
|
40
|
+
__classPrivateFieldSet(this, _BitqueryEDSEthereum_client, new core_1.Client({
|
|
27
41
|
url: constants_1.BITQUERY_URL,
|
|
28
42
|
exchanges: [core_1.fetchExchange],
|
|
29
43
|
fetch: node_fetch_1.default,
|
|
@@ -32,14 +46,14 @@ class BitqueryEDSEthereum {
|
|
|
32
46
|
'X-API-KEY': apiKey,
|
|
33
47
|
},
|
|
34
48
|
},
|
|
35
|
-
});
|
|
49
|
+
}), "f");
|
|
36
50
|
}
|
|
37
51
|
getTokenPrices(currency) {
|
|
38
52
|
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
-
if (this
|
|
53
|
+
if (__classPrivateFieldGet(this, _BitqueryEDSEthereum_networkType, "f") !== 'mainnet')
|
|
40
54
|
throw new Error('Exchange is only available on mainnet');
|
|
41
55
|
const twoDaysAgo = dayjs_1.default.utc().subtract(2, 'day').startOf('date').toISOString();
|
|
42
|
-
const result = yield this
|
|
56
|
+
const result = yield __classPrivateFieldGet(this, _BitqueryEDSEthereum_client, "f")
|
|
43
57
|
.query(graphql_1.bitqueryGetPricesQuery, { after: twoDaysAgo, network: 'ethereum' })
|
|
44
58
|
.toPromise();
|
|
45
59
|
if (result.error) {
|
|
@@ -71,3 +85,4 @@ class BitqueryEDSEthereum {
|
|
|
71
85
|
}
|
|
72
86
|
}
|
|
73
87
|
exports.BitqueryEDSEthereum = BitqueryEDSEthereum;
|
|
88
|
+
_BitqueryEDSEthereum_client = new WeakMap(), _BitqueryEDSEthereum_networkType = new WeakMap();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { NftResponse, NftsResponse, NetworkType, NftDataService, GetNftParam, GetNftsByAddressParams } from '@cityofzion/blockchain-service';
|
|
2
2
|
export declare class GhostMarketNDSEthereum 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 _GhostMarketNDSEthereum_networkType;
|
|
14
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
27
|
exports.GhostMarketNDSEthereum = void 0;
|
|
16
28
|
const query_string_1 = __importDefault(require("query-string"));
|
|
@@ -18,7 +30,8 @@ const constants_1 = require("./constants");
|
|
|
18
30
|
const node_fetch_1 = __importDefault(require("node-fetch"));
|
|
19
31
|
class GhostMarketNDSEthereum {
|
|
20
32
|
constructor(networkType) {
|
|
21
|
-
this
|
|
33
|
+
_GhostMarketNDSEthereum_networkType.set(this, void 0);
|
|
34
|
+
__classPrivateFieldSet(this, _GhostMarketNDSEthereum_networkType, networkType, "f");
|
|
22
35
|
}
|
|
23
36
|
getNftsByAddress({ address, size = 18, cursor }) {
|
|
24
37
|
var _a;
|
|
@@ -56,8 +69,8 @@ class GhostMarketNDSEthereum {
|
|
|
56
69
|
return srcImage;
|
|
57
70
|
}
|
|
58
71
|
getUrlWithParams(params) {
|
|
59
|
-
const parameters = query_string_1.default.stringify(Object.assign({ chain: constants_1.GHOSTMARKET_CHAIN_BY_NETWORK_TYPE[this
|
|
60
|
-
return `${constants_1.GHOSTMARKET_URL_BY_NETWORK_TYPE[this
|
|
72
|
+
const parameters = query_string_1.default.stringify(Object.assign({ chain: constants_1.GHOSTMARKET_CHAIN_BY_NETWORK_TYPE[__classPrivateFieldGet(this, _GhostMarketNDSEthereum_networkType, "f")] }, params), { arrayFormat: 'bracket' });
|
|
73
|
+
return `${constants_1.GHOSTMARKET_URL_BY_NETWORK_TYPE[__classPrivateFieldGet(this, _GhostMarketNDSEthereum_networkType, "f")]}/assets?${parameters}`;
|
|
61
74
|
}
|
|
62
75
|
parse(data) {
|
|
63
76
|
var _a, _b;
|
|
@@ -79,3 +92,4 @@ class GhostMarketNDSEthereum {
|
|
|
79
92
|
}
|
|
80
93
|
}
|
|
81
94
|
exports.GhostMarketNDSEthereum = GhostMarketNDSEthereum;
|
|
95
|
+
_GhostMarketNDSEthereum_networkType = new WeakMap();
|
|
@@ -1,8 +1,10 @@
|
|
|
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 { ethers } from 'ethers';
|
|
4
4
|
export declare class LedgerServiceEthereum implements LedgerService {
|
|
5
|
-
private
|
|
5
|
+
#private;
|
|
6
|
+
getLedgerTransport?: ((account: Account) => Promise<Transport>) | undefined;
|
|
7
|
+
constructor(getLedgerTransport?: ((account: Account) => Promise<Transport>) | undefined);
|
|
6
8
|
getAddress(transport: Transport): Promise<string>;
|
|
7
9
|
getPublicKey(transport: Transport): Promise<string>;
|
|
8
10
|
getSignTransactionFunction(transport: Transport): Promise<(transaction: ethers.providers.TransactionRequest) => Promise<string>>;
|
|
@@ -31,25 +31,32 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
31
31
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
32
|
});
|
|
33
33
|
};
|
|
34
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
35
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
36
|
+
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");
|
|
37
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
38
|
+
};
|
|
39
|
+
var _LedgerServiceEthereum_defaultPath;
|
|
34
40
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
41
|
exports.LedgerServiceEthereum = void 0;
|
|
36
42
|
const hw_app_eth_1 = __importStar(require("@ledgerhq/hw-app-eth"));
|
|
37
43
|
const ethers_1 = require("ethers");
|
|
38
44
|
class LedgerServiceEthereum {
|
|
39
|
-
constructor() {
|
|
40
|
-
this.
|
|
45
|
+
constructor(getLedgerTransport) {
|
|
46
|
+
this.getLedgerTransport = getLedgerTransport;
|
|
47
|
+
_LedgerServiceEthereum_defaultPath.set(this, "44'/60'/0'/0/0");
|
|
41
48
|
}
|
|
42
49
|
getAddress(transport) {
|
|
43
50
|
return __awaiter(this, void 0, void 0, function* () {
|
|
44
51
|
const ledgerApp = new hw_app_eth_1.default(transport);
|
|
45
|
-
const { address } = yield ledgerApp.getAddress(this
|
|
52
|
+
const { address } = yield ledgerApp.getAddress(__classPrivateFieldGet(this, _LedgerServiceEthereum_defaultPath, "f"));
|
|
46
53
|
return address;
|
|
47
54
|
});
|
|
48
55
|
}
|
|
49
56
|
getPublicKey(transport) {
|
|
50
57
|
return __awaiter(this, void 0, void 0, function* () {
|
|
51
58
|
const ledgerApp = new hw_app_eth_1.default(transport);
|
|
52
|
-
const { publicKey } = yield ledgerApp.getAddress(this
|
|
59
|
+
const { publicKey } = yield ledgerApp.getAddress(__classPrivateFieldGet(this, _LedgerServiceEthereum_defaultPath, "f"));
|
|
53
60
|
return '0x' + publicKey;
|
|
54
61
|
});
|
|
55
62
|
}
|
|
@@ -60,7 +67,7 @@ class LedgerServiceEthereum {
|
|
|
60
67
|
const unsignedTransaction = Object.assign(Object.assign({}, transaction), { nonce: transaction.nonce ? ethers_1.ethers.BigNumber.from(transaction.nonce).toNumber() : undefined });
|
|
61
68
|
const serializedUnsignedTransaction = ethers_1.ethers.utils.serializeTransaction(unsignedTransaction).substring(2);
|
|
62
69
|
const resolution = yield hw_app_eth_1.ledgerService.resolveTransaction(serializedUnsignedTransaction, {}, {});
|
|
63
|
-
const signature = yield ledgerApp.signTransaction(this
|
|
70
|
+
const signature = yield ledgerApp.signTransaction(__classPrivateFieldGet(this, _LedgerServiceEthereum_defaultPath, "f"), serializedUnsignedTransaction, resolution);
|
|
64
71
|
return ethers_1.ethers.utils.serializeTransaction(unsignedTransaction, {
|
|
65
72
|
v: ethers_1.ethers.BigNumber.from('0x' + signature.v).toNumber(),
|
|
66
73
|
r: '0x' + signature.r,
|
|
@@ -71,3 +78,4 @@ class LedgerServiceEthereum {
|
|
|
71
78
|
}
|
|
72
79
|
}
|
|
73
80
|
exports.LedgerServiceEthereum = LedgerServiceEthereum;
|
|
81
|
+
_LedgerServiceEthereum_defaultPath = new WeakMap();
|
package/dist/RpcBDSEthereum.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BalanceResponse, BlockchainDataService, ContractResponse, Network, Token, TransactionResponse, TransactionsByAddressParams, TransactionsByAddressResponse } from '@cityofzion/blockchain-service';
|
|
2
2
|
export declare class RpcBDSEthereum implements BlockchainDataService {
|
|
3
|
-
private
|
|
3
|
+
#private;
|
|
4
4
|
maxTimeToConfirmTransactionInMs: number;
|
|
5
5
|
constructor(network: Network);
|
|
6
6
|
getTransaction(hash: string): Promise<TransactionResponse>;
|
package/dist/RpcBDSEthereum.js
CHANGED
|
@@ -8,25 +8,38 @@ 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
|
+
};
|
|
22
|
+
var _RpcBDSEthereum_network;
|
|
11
23
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
24
|
exports.RpcBDSEthereum = void 0;
|
|
13
25
|
const ethers_1 = require("ethers");
|
|
14
26
|
const constants_1 = require("./constants");
|
|
15
27
|
class RpcBDSEthereum {
|
|
16
28
|
constructor(network) {
|
|
29
|
+
_RpcBDSEthereum_network.set(this, void 0);
|
|
17
30
|
this.maxTimeToConfirmTransactionInMs = 1000 * 60 * 5;
|
|
18
|
-
this
|
|
31
|
+
__classPrivateFieldSet(this, _RpcBDSEthereum_network, network, "f");
|
|
19
32
|
}
|
|
20
33
|
getTransaction(hash) {
|
|
21
34
|
return __awaiter(this, void 0, void 0, function* () {
|
|
22
|
-
const provider = new ethers_1.ethers.providers.JsonRpcProvider(this.
|
|
35
|
+
const provider = new ethers_1.ethers.providers.JsonRpcProvider(__classPrivateFieldGet(this, _RpcBDSEthereum_network, "f").url);
|
|
23
36
|
const transaction = yield provider.getTransaction(hash);
|
|
24
37
|
if (!transaction || !transaction.blockHash || !transaction.to)
|
|
25
38
|
throw new Error('Transaction not found');
|
|
26
39
|
const block = yield provider.getBlock(transaction.blockHash);
|
|
27
40
|
if (!block)
|
|
28
41
|
throw new Error('Block not found');
|
|
29
|
-
const tokens = constants_1.TOKENS[this.
|
|
42
|
+
const tokens = constants_1.TOKENS[__classPrivateFieldGet(this, _RpcBDSEthereum_network, "f").type];
|
|
30
43
|
const token = tokens.find(token => token.symbol === 'ETH');
|
|
31
44
|
return {
|
|
32
45
|
block: block.number,
|
|
@@ -58,7 +71,7 @@ class RpcBDSEthereum {
|
|
|
58
71
|
}
|
|
59
72
|
getTokenInfo(hash) {
|
|
60
73
|
return __awaiter(this, void 0, void 0, function* () {
|
|
61
|
-
const tokens = constants_1.TOKENS[this.
|
|
74
|
+
const tokens = constants_1.TOKENS[__classPrivateFieldGet(this, _RpcBDSEthereum_network, "f").type];
|
|
62
75
|
const token = tokens.find(token => token.hash === hash);
|
|
63
76
|
if (!token)
|
|
64
77
|
throw new Error('Token not found');
|
|
@@ -67,9 +80,9 @@ class RpcBDSEthereum {
|
|
|
67
80
|
}
|
|
68
81
|
getBalance(address) {
|
|
69
82
|
return __awaiter(this, void 0, void 0, function* () {
|
|
70
|
-
const provider = new ethers_1.ethers.providers.JsonRpcProvider(this.
|
|
83
|
+
const provider = new ethers_1.ethers.providers.JsonRpcProvider(__classPrivateFieldGet(this, _RpcBDSEthereum_network, "f").url);
|
|
71
84
|
const balance = yield provider.getBalance(address);
|
|
72
|
-
const tokens = constants_1.TOKENS[this.
|
|
85
|
+
const tokens = constants_1.TOKENS[__classPrivateFieldGet(this, _RpcBDSEthereum_network, "f").type];
|
|
73
86
|
const token = tokens.find(token => token.symbol === 'ETH');
|
|
74
87
|
return [
|
|
75
88
|
{
|
|
@@ -81,9 +94,10 @@ class RpcBDSEthereum {
|
|
|
81
94
|
}
|
|
82
95
|
getBlockHeight() {
|
|
83
96
|
return __awaiter(this, void 0, void 0, function* () {
|
|
84
|
-
const provider = new ethers_1.ethers.providers.JsonRpcProvider(this.
|
|
97
|
+
const provider = new ethers_1.ethers.providers.JsonRpcProvider(__classPrivateFieldGet(this, _RpcBDSEthereum_network, "f").url);
|
|
85
98
|
return yield provider.getBlockNumber();
|
|
86
99
|
});
|
|
87
100
|
}
|
|
88
101
|
}
|
|
89
102
|
exports.RpcBDSEthereum = RpcBDSEthereum;
|
|
103
|
+
_RpcBDSEthereum_network = new WeakMap();
|
package/package.json
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cityofzion/bs-ethereum",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
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
|
"ethers": "5.7.2",
|
|
11
14
|
"@urql/core": "~4.1.1",
|
|
@@ -19,7 +22,7 @@
|
|
|
19
22
|
"@ledgerhq/hw-transport-node-hid": "~6.28.5",
|
|
20
23
|
"@ledgerhq/hw-transport": "~6.30.5",
|
|
21
24
|
"@ledgerhq/hw-app-eth": "~6.35.7",
|
|
22
|
-
"@cityofzion/blockchain-service": "0.
|
|
25
|
+
"@cityofzion/blockchain-service": "0.11.0"
|
|
23
26
|
},
|
|
24
27
|
"devDependencies": {
|
|
25
28
|
"@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,30 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"files": {
|
|
3
|
-
"packages/bs-ethereum/.eslintignore": "3ee402c88b68258919e4f4b4eef4f25e5d078d90",
|
|
4
|
-
"packages/bs-ethereum/.eslintrc.cjs": "5ec0bf6332ec01b3e02beb532bb47025c4c1bf7b",
|
|
5
|
-
"packages/bs-ethereum/CHANGELOG.json": "325dd368ceaddc016034aa87f89fd72ca69d24e7",
|
|
6
|
-
"packages/bs-ethereum/CHANGELOG.md": "3d678f8216c91d6607c00062fecae2068e8e8cac",
|
|
7
|
-
"packages/bs-ethereum/jest.config.ts": "d944475db93cbe41a9339187fd94b9962e411c43",
|
|
8
|
-
"packages/bs-ethereum/jest.setup.ts": "9a1976a32050616d4d2ee95b1aa21041bc4daca3",
|
|
9
|
-
"packages/bs-ethereum/package.json": "b28c67e06e88b76dabe2a59950a87fc702802784",
|
|
10
|
-
"packages/bs-ethereum/src/BSEthereum.ts": "851c8cb3d04e982b1f6084af3c0c6332e94dfb1b",
|
|
11
|
-
"packages/bs-ethereum/src/BitqueryBDSEthereum.ts": "47f24d0f3a94aa0eb761e1c2e96f6aeb9c51f82b",
|
|
12
|
-
"packages/bs-ethereum/src/BitqueryEDSEthereum.ts": "a1232bf1d1683d7fe0e752577f3eb489cfce734f",
|
|
13
|
-
"packages/bs-ethereum/src/GhostMarketNDSEthereum.ts": "c97f7fd9323b4089a8f2ed4178dbc14a0d17c61c",
|
|
14
|
-
"packages/bs-ethereum/src/LedgerServiceEthereum.ts": "4817179fe41406c77c24d7635c9fe01c8718ab51",
|
|
15
|
-
"packages/bs-ethereum/src/RpcBDSEthereum.ts": "6cbca256420b09cef7182cbc485eb4799ff9b614",
|
|
16
|
-
"packages/bs-ethereum/src/__tests__/BSEthereum.spec.ts": "755cb6c64843453d236c67b8e2837fe288fc8ecb",
|
|
17
|
-
"packages/bs-ethereum/src/__tests__/BitqueryBDSEthereum.spec.ts": "38f866d185089ff5a638dda6a7a7a82e6b75416c",
|
|
18
|
-
"packages/bs-ethereum/src/__tests__/BitqueryEDSEthereum.spec.ts": "a0994e0ad66408b281ec96a5f72b30b5e14a68ce",
|
|
19
|
-
"packages/bs-ethereum/src/__tests__/GhostMarketNDSEthereum.spec.ts": "4b10ef2b59437c9ea06695ab4844d5b131f65738",
|
|
20
|
-
"packages/bs-ethereum/src/__tests__/RpcBDSEthereum.spec.ts": "c76ab3af8b91ca9e1ae86face31933ca4f21ca1f",
|
|
21
|
-
"packages/bs-ethereum/src/assets/tokens/common.json": "96597dd06475ee6068b484510f27ffad27b52ebd",
|
|
22
|
-
"packages/bs-ethereum/src/constants.ts": "e216fc9b3e2f2333af4f42bca7cc2e6a461e2036",
|
|
23
|
-
"packages/bs-ethereum/src/graphql.ts": "2e759e198a9a37205ed115c41165eda18df66539",
|
|
24
|
-
"packages/bs-ethereum/src/index.ts": "69ca9c23acdd0afd70f7eaa0a840b07b62bdb07a",
|
|
25
|
-
"packages/bs-ethereum/tsconfig.build.json": "4dc23fb9c4c5e4d19a9bc3947a47c523f4bd967c",
|
|
26
|
-
"packages/bs-ethereum/tsconfig.json": "93e09769572b58e642d4990e9552c70a8b85e142",
|
|
27
|
-
"packages/bs-ethereum/.rush/temp/shrinkwrap-deps.json": "38753d194619dc40349a5bf0ecc2a3216d091fda"
|
|
28
|
-
},
|
|
29
|
-
"arguments": "tsc --project tsconfig.build.json "
|
|
30
|
-
}
|