@cityofzion/bs-ethereum 0.7.1 → 0.7.3
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/.rush/temp/package-deps_build.json +7 -7
- package/dist/BitqueryBDSEthereum.d.ts +1 -0
- package/dist/BitqueryBDSEthereum.js +3 -2
- package/dist/BitqueryEDSEthereum.js +1 -1
- package/dist/RpcBDSEthereum.d.ts +1 -0
- package/dist/RpcBDSEthereum.js +1 -0
- package/dist/graphql.d.ts +2 -2
- package/dist/graphql.js +8 -2
- package/package.json +2 -2
- package/src/BitqueryBDSEthereum.ts +6 -3
- package/src/BitqueryEDSEthereum.ts +2 -2
- package/src/RpcBDSEthereum.ts +2 -0
- package/src/__tests__/BDSEthereum.spec.ts +1 -0
- package/src/graphql.ts +10 -4
|
@@ -2,23 +2,23 @@
|
|
|
2
2
|
"files": {
|
|
3
3
|
"packages/bs-ethereum/jest.config.ts": "d944475db93cbe41a9339187fd94b9962e411c43",
|
|
4
4
|
"packages/bs-ethereum/jest.setup.ts": "9a1976a32050616d4d2ee95b1aa21041bc4daca3",
|
|
5
|
-
"packages/bs-ethereum/package.json": "
|
|
5
|
+
"packages/bs-ethereum/package.json": "2388bfb836c6ba67fe7af26bcffb3668306b0a61",
|
|
6
6
|
"packages/bs-ethereum/src/BSEthereum.ts": "ea8070202977445b77ff67135f7fc7093f0ed2b9",
|
|
7
|
-
"packages/bs-ethereum/src/BitqueryBDSEthereum.ts": "
|
|
8
|
-
"packages/bs-ethereum/src/BitqueryEDSEthereum.ts": "
|
|
7
|
+
"packages/bs-ethereum/src/BitqueryBDSEthereum.ts": "aee408a61b1accc750723ce6addf8c99f365c8a4",
|
|
8
|
+
"packages/bs-ethereum/src/BitqueryEDSEthereum.ts": "c04aa2be223166140f3b98e01390a6f5f7ded8df",
|
|
9
9
|
"packages/bs-ethereum/src/GhostMarketNDSEthereum.ts": "145273284b3c27494eea0e80c0c1de8001b11c57",
|
|
10
|
-
"packages/bs-ethereum/src/RpcBDSEthereum.ts": "
|
|
11
|
-
"packages/bs-ethereum/src/__tests__/BDSEthereum.spec.ts": "
|
|
10
|
+
"packages/bs-ethereum/src/RpcBDSEthereum.ts": "6cbca256420b09cef7182cbc485eb4799ff9b614",
|
|
11
|
+
"packages/bs-ethereum/src/__tests__/BDSEthereum.spec.ts": "8b66ba80d8457601fac69819cc1fae4d7bc7b08a",
|
|
12
12
|
"packages/bs-ethereum/src/__tests__/BSEthereum.spec.ts": "0da33cb4c9f89a3b6c2c8445d800ff4ddb41d161",
|
|
13
13
|
"packages/bs-ethereum/src/__tests__/BitqueryEDSEthereum.spec.ts": "8e26084a00916be48eeeb65d3918e5eed6368f0c",
|
|
14
14
|
"packages/bs-ethereum/src/__tests__/GhostMarketNDSEthereum.spec.ts": "f5c9ba8f6c866b97bcf647d105bfa2d5f140180d",
|
|
15
15
|
"packages/bs-ethereum/src/assets/tokens/common.json": "4dbbf3a3b38422e743cf631ffb6c39231777b88d",
|
|
16
16
|
"packages/bs-ethereum/src/constants.ts": "40862a7cc04298a21e380ecdf02e09349897a6f5",
|
|
17
|
-
"packages/bs-ethereum/src/graphql.ts": "
|
|
17
|
+
"packages/bs-ethereum/src/graphql.ts": "aadff73a44a9d12cc65ebe1b0b161f1ecc4f6021",
|
|
18
18
|
"packages/bs-ethereum/src/index.ts": "69ca9c23acdd0afd70f7eaa0a840b07b62bdb07a",
|
|
19
19
|
"packages/bs-ethereum/tsconfig.build.json": "4dc23fb9c4c5e4d19a9bc3947a47c523f4bd967c",
|
|
20
20
|
"packages/bs-ethereum/tsconfig.json": "93e09769572b58e642d4990e9552c70a8b85e142",
|
|
21
|
-
"common/config/rush/npm-shrinkwrap.json": "
|
|
21
|
+
"common/config/rush/npm-shrinkwrap.json": "c7f58d681afa54f5c08d809a1ace9947b56fb633"
|
|
22
22
|
},
|
|
23
23
|
"arguments": "tsc --project tsconfig.build.json "
|
|
24
24
|
}
|
|
@@ -3,6 +3,7 @@ import { RpcBDSEthereum } from './RpcBDSEthereum';
|
|
|
3
3
|
export declare class BitqueryBDSEthereum extends RpcBDSEthereum {
|
|
4
4
|
private readonly client;
|
|
5
5
|
private readonly networkType;
|
|
6
|
+
maxTimeToConfirmTransactionInMs: number;
|
|
6
7
|
constructor(network: Network);
|
|
7
8
|
getTransaction(hash: string): Promise<TransactionResponse>;
|
|
8
9
|
getTransactionsByAddress({ address, page, }: TransactionsByAddressParams): Promise<TransactionsByAddressResponse>;
|
|
@@ -21,12 +21,13 @@ const RpcBDSEthereum_1 = require("./RpcBDSEthereum");
|
|
|
21
21
|
class BitqueryBDSEthereum extends RpcBDSEthereum_1.RpcBDSEthereum {
|
|
22
22
|
constructor(network) {
|
|
23
23
|
super(network);
|
|
24
|
+
this.maxTimeToConfirmTransactionInMs = 1000 * 60 * 8;
|
|
24
25
|
if (network.type === 'custom')
|
|
25
26
|
throw new Error('Custom network not supported');
|
|
26
27
|
this.networkType = network.type;
|
|
27
28
|
this.client = new core_1.Client({
|
|
28
29
|
url: constants_1.BITQUERY_URL,
|
|
29
|
-
exchanges: [core_1.
|
|
30
|
+
exchanges: [core_1.fetchExchange],
|
|
30
31
|
fetch: node_fetch_1.default,
|
|
31
32
|
fetchOptions: {
|
|
32
33
|
headers: {
|
|
@@ -76,7 +77,7 @@ class BitqueryBDSEthereum extends RpcBDSEthereum_1.RpcBDSEthereum {
|
|
|
76
77
|
throw new Error(result.error.message);
|
|
77
78
|
if (!result.data)
|
|
78
79
|
throw new Error('Address does not have transactions');
|
|
79
|
-
const totalCount = ((_a = result.data.ethereum.sentCount.count) !== null && _a !== void 0 ? _a : 0) + ((_b = result.data.ethereum.receiverCount.count) !== null && _b !== void 0 ? _b : 0);
|
|
80
|
+
const totalCount = ((_a = result.data.ethereum.sentCount[0].count) !== null && _a !== void 0 ? _a : 0) + ((_b = result.data.ethereum.receiverCount[0].count) !== null && _b !== void 0 ? _b : 0);
|
|
80
81
|
const mixedTransfers = [...((_e = (_d = (_c = result === null || result === void 0 ? void 0 : result.data) === null || _c === void 0 ? void 0 : _c.ethereum) === null || _d === void 0 ? void 0 : _d.sent) !== null && _e !== void 0 ? _e : []), ...((_h = (_g = (_f = result === null || result === void 0 ? void 0 : result.data) === null || _f === void 0 ? void 0 : _f.ethereum) === null || _g === void 0 ? void 0 : _g.received) !== null && _h !== void 0 ? _h : [])];
|
|
81
82
|
const transactions = new Map();
|
|
82
83
|
mixedTransfers.forEach(transfer => {
|
|
@@ -25,7 +25,7 @@ class BitqueryEDSEthereum {
|
|
|
25
25
|
this.networkType = networkType;
|
|
26
26
|
this.client = new core_1.Client({
|
|
27
27
|
url: constants_1.BITQUERY_URL,
|
|
28
|
-
exchanges: [core_1.
|
|
28
|
+
exchanges: [core_1.fetchExchange],
|
|
29
29
|
fetch: node_fetch_1.default,
|
|
30
30
|
fetchOptions: {
|
|
31
31
|
headers: {
|
package/dist/RpcBDSEthereum.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { BalanceResponse, BlockchainDataService, ContractResponse, Network, Token, TransactionResponse, TransactionsByAddressParams, TransactionsByAddressResponse } from '@cityofzion/blockchain-service';
|
|
2
2
|
export declare class RpcBDSEthereum implements BlockchainDataService {
|
|
3
3
|
private readonly network;
|
|
4
|
+
maxTimeToConfirmTransactionInMs: number;
|
|
4
5
|
constructor(network: Network);
|
|
5
6
|
getTransaction(hash: string): Promise<TransactionResponse>;
|
|
6
7
|
getTransactionsByAddress(_params: TransactionsByAddressParams): Promise<TransactionsByAddressResponse>;
|
package/dist/RpcBDSEthereum.js
CHANGED
package/dist/graphql.d.ts
CHANGED
|
@@ -32,10 +32,10 @@ type BitQueryGetTransactionsByAddressResponse = {
|
|
|
32
32
|
received: BitqueryTransaction[];
|
|
33
33
|
sentCount: {
|
|
34
34
|
count: number;
|
|
35
|
-
};
|
|
35
|
+
}[];
|
|
36
36
|
receiverCount: {
|
|
37
37
|
count: number;
|
|
38
|
-
};
|
|
38
|
+
}[];
|
|
39
39
|
};
|
|
40
40
|
};
|
|
41
41
|
type BitQueryGetTransactionsByAddressVariables = {
|
package/dist/graphql.js
CHANGED
|
@@ -5,7 +5,10 @@ const core_1 = require("@urql/core");
|
|
|
5
5
|
exports.bitqueryGetTransactionsByAddressQuery = (0, core_1.gql) `
|
|
6
6
|
query getTransactions($address: String!, $limit: Int!, $offset: Int!, $network: EthereumNetwork!) {
|
|
7
7
|
ethereum(network: $network) {
|
|
8
|
-
sent: transfers(
|
|
8
|
+
sent: transfers(
|
|
9
|
+
options: { limit: $limit, offset: $offset, desc: "block.timestamp.unixtime" }
|
|
10
|
+
sender: { is: $address }
|
|
11
|
+
) {
|
|
9
12
|
block {
|
|
10
13
|
timestamp {
|
|
11
14
|
unixtime
|
|
@@ -32,7 +35,10 @@ exports.bitqueryGetTransactionsByAddressQuery = (0, core_1.gql) `
|
|
|
32
35
|
}
|
|
33
36
|
entityId
|
|
34
37
|
}
|
|
35
|
-
received: transfers(
|
|
38
|
+
received: transfers(
|
|
39
|
+
options: { limit: $limit, offset: $offset, desc: "block.timestamp.unixtime" }
|
|
40
|
+
receiver: { is: $address }
|
|
41
|
+
) {
|
|
36
42
|
block {
|
|
37
43
|
timestamp {
|
|
38
44
|
unixtime
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cityofzion/bs-ethereum",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.3",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"repository": "https://github.com/CityOfZion/blockchain-services",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"test": "jest --config jest.config.ts"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@cityofzion/blockchain-service": "0.7.
|
|
14
|
+
"@cityofzion/blockchain-service": "0.7.3",
|
|
15
15
|
"ethers": "5.7.2",
|
|
16
16
|
"@urql/core": "~4.1.1",
|
|
17
17
|
"graphql": "~16.8.0",
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
TransactionTransferNft,
|
|
11
11
|
Network,
|
|
12
12
|
} from '@cityofzion/blockchain-service'
|
|
13
|
-
import { Client,
|
|
13
|
+
import { Client, fetchExchange } from '@urql/core'
|
|
14
14
|
import fetch from 'node-fetch'
|
|
15
15
|
import { BITQUERY_API_KEY, BITQUERY_NETWORK_BY_NETWORK_TYPE, BITQUERY_URL, TOKENS } from './constants'
|
|
16
16
|
import {
|
|
@@ -26,6 +26,8 @@ export class BitqueryBDSEthereum extends RpcBDSEthereum {
|
|
|
26
26
|
private readonly client: Client
|
|
27
27
|
private readonly networkType: Exclude<NetworkType, 'custom'>
|
|
28
28
|
|
|
29
|
+
maxTimeToConfirmTransactionInMs: number = 1000 * 60 * 8
|
|
30
|
+
|
|
29
31
|
constructor(network: Network) {
|
|
30
32
|
super(network)
|
|
31
33
|
|
|
@@ -34,7 +36,7 @@ export class BitqueryBDSEthereum extends RpcBDSEthereum {
|
|
|
34
36
|
|
|
35
37
|
this.client = new Client({
|
|
36
38
|
url: BITQUERY_URL,
|
|
37
|
-
exchanges: [
|
|
39
|
+
exchanges: [fetchExchange],
|
|
38
40
|
fetch,
|
|
39
41
|
fetchOptions: {
|
|
40
42
|
headers: {
|
|
@@ -93,7 +95,8 @@ export class BitqueryBDSEthereum extends RpcBDSEthereum {
|
|
|
93
95
|
if (result.error) throw new Error(result.error.message)
|
|
94
96
|
if (!result.data) throw new Error('Address does not have transactions')
|
|
95
97
|
|
|
96
|
-
const totalCount =
|
|
98
|
+
const totalCount =
|
|
99
|
+
(result.data.ethereum.sentCount[0].count ?? 0) + (result.data.ethereum.receiverCount[0].count ?? 0)
|
|
97
100
|
const mixedTransfers = [...(result?.data?.ethereum?.sent ?? []), ...(result?.data?.ethereum?.received ?? [])]
|
|
98
101
|
|
|
99
102
|
const transactions = new Map<string, TransactionResponse>()
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Currency, ExchangeDataService, NetworkType, TokenPricesResponse } from '@cityofzion/blockchain-service'
|
|
2
|
-
import { Client,
|
|
2
|
+
import { Client, fetchExchange } from '@urql/core'
|
|
3
3
|
import fetch from 'node-fetch'
|
|
4
4
|
import { BITQUERY_API_KEY, BITQUERY_URL } from './constants'
|
|
5
5
|
import dayjs from 'dayjs'
|
|
@@ -16,7 +16,7 @@ export class BitqueryEDSEthereum implements ExchangeDataService {
|
|
|
16
16
|
|
|
17
17
|
this.client = new Client({
|
|
18
18
|
url: BITQUERY_URL,
|
|
19
|
-
exchanges: [
|
|
19
|
+
exchanges: [fetchExchange],
|
|
20
20
|
fetch,
|
|
21
21
|
fetchOptions: {
|
|
22
22
|
headers: {
|
package/src/RpcBDSEthereum.ts
CHANGED
|
@@ -14,6 +14,8 @@ import { TOKENS } from './constants'
|
|
|
14
14
|
export class RpcBDSEthereum implements BlockchainDataService {
|
|
15
15
|
private readonly network: Network
|
|
16
16
|
|
|
17
|
+
maxTimeToConfirmTransactionInMs: number = 1000 * 60 * 5
|
|
18
|
+
|
|
17
19
|
constructor(network: Network) {
|
|
18
20
|
this.network = network
|
|
19
21
|
}
|
|
@@ -41,6 +41,7 @@ describe('BDSEthereum', () => {
|
|
|
41
41
|
async (BDSEthereum: BlockchainDataService) => {
|
|
42
42
|
const address = '0x82B5Cd984880C8A821429cFFf89f36D35BaeBE89'
|
|
43
43
|
const response = await BDSEthereum.getTransactionsByAddress({ address: address, page: 1 })
|
|
44
|
+
expect(response.totalCount).toBeGreaterThan(0)
|
|
44
45
|
response.transactions.forEach(transaction => {
|
|
45
46
|
expect(transaction).toEqual(
|
|
46
47
|
expect.objectContaining({
|
package/src/graphql.ts
CHANGED
|
@@ -36,10 +36,10 @@ type BitQueryGetTransactionsByAddressResponse = {
|
|
|
36
36
|
received: BitqueryTransaction[]
|
|
37
37
|
sentCount: {
|
|
38
38
|
count: number
|
|
39
|
-
}
|
|
39
|
+
}[]
|
|
40
40
|
receiverCount: {
|
|
41
41
|
count: number
|
|
42
|
-
}
|
|
42
|
+
}[]
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
|
|
@@ -56,7 +56,10 @@ export const bitqueryGetTransactionsByAddressQuery = gql<
|
|
|
56
56
|
>`
|
|
57
57
|
query getTransactions($address: String!, $limit: Int!, $offset: Int!, $network: EthereumNetwork!) {
|
|
58
58
|
ethereum(network: $network) {
|
|
59
|
-
sent: transfers(
|
|
59
|
+
sent: transfers(
|
|
60
|
+
options: { limit: $limit, offset: $offset, desc: "block.timestamp.unixtime" }
|
|
61
|
+
sender: { is: $address }
|
|
62
|
+
) {
|
|
60
63
|
block {
|
|
61
64
|
timestamp {
|
|
62
65
|
unixtime
|
|
@@ -83,7 +86,10 @@ export const bitqueryGetTransactionsByAddressQuery = gql<
|
|
|
83
86
|
}
|
|
84
87
|
entityId
|
|
85
88
|
}
|
|
86
|
-
received: transfers(
|
|
89
|
+
received: transfers(
|
|
90
|
+
options: { limit: $limit, offset: $offset, desc: "block.timestamp.unixtime" }
|
|
91
|
+
receiver: { is: $address }
|
|
92
|
+
) {
|
|
87
93
|
block {
|
|
88
94
|
timestamp {
|
|
89
95
|
unixtime
|