@requestnetwork/thegraph-data-access 0.35.3-next.1937 → 0.35.3-next.1938
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/NoopDataWrite.d.ts +7 -0
- package/dist/NoopDataWrite.d.ts.map +1 -0
- package/dist/NoopDataWrite.js +21 -0
- package/dist/NoopDataWrite.js.map +1 -0
- package/dist/data-access.d.ts +13 -44
- package/dist/data-access.d.ts.map +1 -1
- package/dist/data-access.js +42 -245
- package/dist/data-access.js.map +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -5
- package/dist/index.js.map +1 -1
- package/dist/queries.js +1 -1
- package/dist/subgraph-client.d.ts +8 -6
- package/dist/subgraph-client.d.ts.map +1 -1
- package/dist/subgraph-client.js +37 -8
- package/dist/subgraph-client.js.map +1 -1
- package/dist/types.d.ts +10 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/package.json +7 -8
- package/dist/pending-store.d.ts +0 -18
- package/dist/pending-store.d.ts.map +0 -1
- package/dist/pending-store.js +0 -24
- package/dist/pending-store.js.map +0 -1
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { DataAccessTypes } from '@requestnetwork/types';
|
|
2
|
+
export declare class NoopDataWrite implements DataAccessTypes.IDataWrite {
|
|
3
|
+
initialize(): Promise<void>;
|
|
4
|
+
close(): Promise<void>;
|
|
5
|
+
persistTransaction(): Promise<DataAccessTypes.IReturnPersistTransaction>;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=NoopDataWrite.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NoopDataWrite.d.ts","sourceRoot":"","sources":["../src/NoopDataWrite.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,qBAAa,aAAc,YAAW,eAAe,CAAC,UAAU;IACxD,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAI3B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAI5B,kBAAkB,IAAI,OAAO,CAAC,eAAe,CAAC,yBAAyB,CAAC;CAKzE"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NoopDataWrite = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
class NoopDataWrite {
|
|
6
|
+
initialize() {
|
|
7
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
8
|
+
// no-op
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
close() {
|
|
12
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
13
|
+
// no-op
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
persistTransaction() {
|
|
17
|
+
throw new Error(`cannot call persistTranscation without storage. Specify storage on TheGraphDataAccess`);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.NoopDataWrite = NoopDataWrite;
|
|
21
|
+
//# sourceMappingURL=NoopDataWrite.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NoopDataWrite.js","sourceRoot":"","sources":["../src/NoopDataWrite.ts"],"names":[],"mappings":";;;;AAEA,MAAa,aAAa;IAClB,UAAU;;YACd,QAAQ;QACV,CAAC;KAAA;IAEK,KAAK;;YACT,QAAQ;QACV,CAAC;KAAA;IAED,kBAAkB;QAChB,MAAM,IAAI,KAAK,CACb,uFAAuF,CACxF,CAAC;IACJ,CAAC;CACF;AAdD,sCAcC"}
|
package/dist/data-access.d.ts
CHANGED
|
@@ -1,49 +1,18 @@
|
|
|
1
1
|
import { CombinedDataAccess } from '@requestnetwork/data-access';
|
|
2
|
-
import { DataAccessTypes
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
logger?: LogTypes.ILogger;
|
|
9
|
-
pendingStore?: PendingStore;
|
|
10
|
-
};
|
|
11
|
-
export type TheGraphDataAccessOptions = TheGraphDataAccessBaseOptions & {
|
|
12
|
-
graphql: {
|
|
13
|
-
url: string;
|
|
14
|
-
} & RequestInit;
|
|
15
|
-
storage?: StorageTypes.IStorageWrite;
|
|
16
|
-
};
|
|
17
|
-
export declare class TheGraphDataRead implements DataAccessTypes.IDataRead {
|
|
18
|
-
private readonly graphql;
|
|
19
|
-
private network;
|
|
20
|
-
private pendingStore?;
|
|
21
|
-
constructor(graphql: SubgraphClient, { network, pendingStore }: TheGraphDataAccessBaseOptions);
|
|
22
|
-
initialize(): Promise<void>;
|
|
23
|
-
close(): Promise<void>;
|
|
24
|
-
getTransactionsByChannelId(channelId: string, updatedBetween?: DataAccessTypes.ITimestampBoundaries): Promise<DataAccessTypes.IReturnGetTransactions>;
|
|
25
|
-
getChannelsByTopic(topic: string, updatedBetween?: DataAccessTypes.ITimestampBoundaries | undefined): Promise<DataAccessTypes.IReturnGetChannelsByTopic>;
|
|
26
|
-
getChannelsByMultipleTopics(topics: string[], updatedBetween?: DataAccessTypes.ITimestampBoundaries): Promise<DataAccessTypes.IReturnGetChannelsByTopic>;
|
|
27
|
-
private getPending;
|
|
28
|
-
private getTimestampedTransaction;
|
|
29
|
-
}
|
|
30
|
-
export declare class TheGraphDataWrite implements DataAccessTypes.IDataWrite {
|
|
31
|
-
protected readonly storage: StorageTypes.IStorageWrite;
|
|
32
|
-
private readonly graphql;
|
|
33
|
-
private logger;
|
|
34
|
-
private network;
|
|
35
|
-
private pendingStore?;
|
|
36
|
-
constructor(storage: StorageTypes.IStorageWrite, graphql: SubgraphClient, { network, logger, pendingStore }: TheGraphDataAccessBaseOptions);
|
|
37
|
-
initialize(): Promise<void>;
|
|
38
|
-
close(): Promise<void>;
|
|
39
|
-
persistTransaction(transaction: DataAccessTypes.ITransaction, channelId: string, topics?: string[] | undefined): Promise<DataAccessTypes.IReturnPersistTransaction>;
|
|
40
|
-
protected createPersistTransactionResult(channelId: string, transaction: DataAccessTypes.ITransaction, storageResult: StorageTypes.IAppendResult, topics: string[]): DataAccessTypes.IReturnPersistTransaction;
|
|
41
|
-
}
|
|
2
|
+
import { DataAccessTypes } from '@requestnetwork/types';
|
|
3
|
+
import { TheGraphDataAccessOptions } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* A custom DataAccess to retrieve Request data from a TheGraph subgraph.
|
|
6
|
+
* If no `storage` is passed, the data access is read-only.
|
|
7
|
+
*/
|
|
42
8
|
export declare class TheGraphDataAccess extends CombinedDataAccess {
|
|
43
|
-
private
|
|
44
|
-
private readonly storage;
|
|
9
|
+
private logger;
|
|
45
10
|
constructor({ graphql, storage, ...options }: TheGraphDataAccessOptions);
|
|
46
|
-
|
|
11
|
+
/** intercept events so that confirmation is emitted only once the transaction is indexed */
|
|
12
|
+
persistTransaction: (transactionData: DataAccessTypes.ITransaction, channelId: string, topics?: string[] | undefined) => Promise<DataAccessTypes.IReturnPersistTransaction>;
|
|
13
|
+
/**
|
|
14
|
+
* We wait until the data is indexed on TheGraph
|
|
15
|
+
**/
|
|
16
|
+
private fetchConfirmedTransaction;
|
|
47
17
|
}
|
|
48
|
-
export {};
|
|
49
18
|
//# sourceMappingURL=data-access.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-access.d.ts","sourceRoot":"","sources":["../src/data-access.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"data-access.d.ts","sourceRoot":"","sources":["../src/data-access.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAmC,MAAM,6BAA6B,CAAC;AAClG,OAAO,EAAE,eAAe,EAA0B,MAAM,uBAAuB,CAAC;AAEhF,OAAO,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAC;AAGpD;;;GAGG;AACH,qBAAa,kBAAmB,SAAQ,kBAAkB;IACxD,OAAO,CAAC,MAAM,CAAmB;gBACrB,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,OAAO,EAAE,EAAE,yBAAyB;IAoBvE,4FAA4F;IAC5F,kBAAkB,oBACC,gBAAgB,YAAY,aAClC,MAAM,WACR,MAAM,EAAE,GAAG,SAAS,KAC5B,QAAQ,gBAAgB,yBAAyB,CAAC,CAUnD;IAEF;;QAEI;YACU,yBAAyB;CA6BxC"}
|
package/dist/data-access.js
CHANGED
|
@@ -1,265 +1,62 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TheGraphDataAccess =
|
|
3
|
+
exports.TheGraphDataAccess = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const events_1 = require("events");
|
|
6
|
-
const
|
|
7
|
-
const utils_1 = require("@requestnetwork/utils");
|
|
6
|
+
const subgraph_client_1 = require("./subgraph-client");
|
|
8
7
|
const data_access_1 = require("@requestnetwork/data-access");
|
|
9
8
|
const types_1 = require("@requestnetwork/types");
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
blockNumber: result.blockNumber,
|
|
17
|
-
blockTimestamp: result.blockTimestamp,
|
|
18
|
-
networkName: network,
|
|
19
|
-
smartContractAddress: result.smartContractAddress,
|
|
20
|
-
transactionHash: result.transactionHash,
|
|
21
|
-
},
|
|
22
|
-
ipfs: {
|
|
23
|
-
size: ethers_1.BigNumber.from(result.size).toNumber(),
|
|
24
|
-
},
|
|
25
|
-
state: types_1.StorageTypes.ContentState.CONFIRMED,
|
|
26
|
-
storageType: types_1.StorageTypes.StorageSystemType.ETHEREUM_IPFS,
|
|
27
|
-
timestamp: result.blockTimestamp,
|
|
28
|
-
};
|
|
29
|
-
};
|
|
30
|
-
class TheGraphDataRead {
|
|
31
|
-
constructor(graphql, { network, pendingStore }) {
|
|
32
|
-
this.graphql = graphql;
|
|
33
|
-
this.network = network;
|
|
34
|
-
this.pendingStore = pendingStore;
|
|
35
|
-
}
|
|
36
|
-
initialize() {
|
|
37
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
38
|
-
yield this.graphql.getBlockNumber();
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
close() {
|
|
42
|
-
return Promise.resolve();
|
|
43
|
-
}
|
|
44
|
-
getTransactionsByChannelId(channelId, updatedBetween) {
|
|
45
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
46
|
-
const pending = yield this.getPending(channelId);
|
|
47
|
-
const result = yield this.graphql.getTransactionsByChannelId(channelId, updatedBetween);
|
|
48
|
-
return {
|
|
49
|
-
meta: {
|
|
50
|
-
transactionsStorageLocation: result.transactions
|
|
51
|
-
.map((x) => x.hash)
|
|
52
|
-
.concat(pending.meta.transactionsStorageLocation),
|
|
53
|
-
storageMeta: result.transactions.map((tx) => getStorageMeta(tx, result._meta.block.number, this.network)),
|
|
54
|
-
},
|
|
55
|
-
result: {
|
|
56
|
-
transactions: result.transactions
|
|
57
|
-
.map(this.getTimestampedTransaction)
|
|
58
|
-
.concat(pending.result.transactions),
|
|
59
|
-
},
|
|
60
|
-
};
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
getChannelsByTopic(topic, updatedBetween) {
|
|
64
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
65
|
-
return this.getChannelsByMultipleTopics([topic], updatedBetween);
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
getChannelsByMultipleTopics(topics, updatedBetween) {
|
|
69
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
70
|
-
const result = yield this.graphql.getChannelsByTopics(topics);
|
|
71
|
-
// list of channels having at least one tx updated during the updatedBetween boundaries
|
|
72
|
-
const channels = result.transactions
|
|
73
|
-
.filter((tx) => tx.blockTimestamp >= ((updatedBetween === null || updatedBetween === void 0 ? void 0 : updatedBetween.from) || 0) &&
|
|
74
|
-
tx.blockTimestamp <= ((updatedBetween === null || updatedBetween === void 0 ? void 0 : updatedBetween.to) || Number.MAX_SAFE_INTEGER))
|
|
75
|
-
.map((x) => x.channelId);
|
|
76
|
-
const filteredTxs = result.transactions.filter((tx) => channels.includes(tx.channelId));
|
|
77
|
-
return {
|
|
78
|
-
meta: {
|
|
79
|
-
storageMeta: filteredTxs.reduce((acc, tx) => {
|
|
80
|
-
acc[tx.channelId] = [getStorageMeta(tx, result._meta.block.number, this.network)];
|
|
81
|
-
return acc;
|
|
82
|
-
}, {}),
|
|
83
|
-
transactionsStorageLocation: filteredTxs.reduce((prev, curr) => {
|
|
84
|
-
if (!prev[curr.channelId]) {
|
|
85
|
-
prev[curr.channelId] = [];
|
|
86
|
-
}
|
|
87
|
-
prev[curr.channelId].push(curr.hash);
|
|
88
|
-
return prev;
|
|
89
|
-
}, {}),
|
|
90
|
-
},
|
|
91
|
-
result: {
|
|
92
|
-
transactions: filteredTxs.reduce((prev, curr) => {
|
|
93
|
-
if (!prev[curr.channelId]) {
|
|
94
|
-
prev[curr.channelId] = [];
|
|
95
|
-
}
|
|
96
|
-
prev[curr.channelId].push(this.getTimestampedTransaction(curr));
|
|
97
|
-
return prev;
|
|
98
|
-
}, {}),
|
|
99
|
-
},
|
|
100
|
-
};
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
getPending(channelId) {
|
|
104
|
-
var _a, _b;
|
|
105
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
106
|
-
const emptyResult = {
|
|
107
|
-
meta: {
|
|
108
|
-
transactionsStorageLocation: [],
|
|
109
|
-
storageMeta: [],
|
|
110
|
-
},
|
|
111
|
-
result: {
|
|
112
|
-
transactions: [],
|
|
113
|
-
},
|
|
114
|
-
};
|
|
115
|
-
const pending = (_a = this.pendingStore) === null || _a === void 0 ? void 0 : _a.get(channelId);
|
|
116
|
-
if (!pending) {
|
|
117
|
-
return emptyResult;
|
|
118
|
-
}
|
|
119
|
-
const { storageResult, transaction } = pending;
|
|
120
|
-
const { transactions } = yield this.graphql.getTransactionsByHash(storageResult.id);
|
|
121
|
-
// if the pending tx is found, remove its state and fetch the real data
|
|
122
|
-
if (transactions.length > 0) {
|
|
123
|
-
(_b = this.pendingStore) === null || _b === void 0 ? void 0 : _b.remove(channelId);
|
|
124
|
-
return emptyResult;
|
|
125
|
-
}
|
|
126
|
-
return {
|
|
127
|
-
meta: {
|
|
128
|
-
transactionsStorageLocation: [storageResult.id],
|
|
129
|
-
storageMeta: [storageResult.meta],
|
|
130
|
-
},
|
|
131
|
-
result: {
|
|
132
|
-
transactions: [
|
|
133
|
-
{
|
|
134
|
-
state: types_1.DataAccessTypes.TransactionState.PENDING,
|
|
135
|
-
timestamp: (0, utils_1.getCurrentTimestampInSecond)(),
|
|
136
|
-
transaction,
|
|
137
|
-
},
|
|
138
|
-
],
|
|
139
|
-
},
|
|
140
|
-
};
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
getTimestampedTransaction(transaction) {
|
|
144
|
-
var _a;
|
|
145
|
-
return {
|
|
146
|
-
state: types_1.DataAccessTypes.TransactionState.CONFIRMED,
|
|
147
|
-
timestamp: transaction.blockTimestamp,
|
|
148
|
-
transaction: {
|
|
149
|
-
data: transaction.data || undefined,
|
|
150
|
-
encryptedData: transaction.encryptedData || undefined,
|
|
151
|
-
encryptionMethod: transaction.encryptionMethod || undefined,
|
|
152
|
-
keys: (_a = transaction.publicKeys) === null || _a === void 0 ? void 0 : _a.reduce((prev, curr, i) => {
|
|
153
|
-
var _a;
|
|
154
|
-
return (Object.assign(Object.assign({}, prev), { [curr]: (_a = transaction.encryptedKeys) === null || _a === void 0 ? void 0 : _a[i] }));
|
|
155
|
-
}, {}),
|
|
156
|
-
},
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
exports.TheGraphDataRead = TheGraphDataRead;
|
|
161
|
-
class TheGraphDataWrite {
|
|
162
|
-
constructor(storage, graphql, { network, logger, pendingStore }) {
|
|
163
|
-
this.storage = storage;
|
|
164
|
-
this.graphql = graphql;
|
|
165
|
-
this.logger = logger || new utils_1.SimpleLogger();
|
|
166
|
-
this.network = network;
|
|
167
|
-
this.pendingStore = pendingStore;
|
|
168
|
-
}
|
|
169
|
-
initialize() {
|
|
170
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
171
|
-
yield this.graphql.getBlockNumber();
|
|
172
|
-
yield this.storage.initialize();
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
close() {
|
|
176
|
-
return Promise.resolve();
|
|
177
|
-
}
|
|
178
|
-
persistTransaction(transaction, channelId, topics) {
|
|
179
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
180
|
-
const updatedBlock = data_access_1.Block.pushTransaction(data_access_1.Block.createEmptyBlock(), transaction, channelId, topics);
|
|
181
|
-
const storageResult = yield this.storage.append(JSON.stringify(updatedBlock));
|
|
182
|
-
return this.createPersistTransactionResult(channelId, transaction, storageResult, topics || []);
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
createPersistTransactionResult(channelId, transaction, storageResult, topics) {
|
|
186
|
-
var _a;
|
|
187
|
-
const eventEmitter = new events_1.EventEmitter();
|
|
188
|
-
(_a = this.pendingStore) === null || _a === void 0 ? void 0 : _a.add(channelId, transaction, storageResult);
|
|
189
|
-
const result = {
|
|
190
|
-
meta: {
|
|
191
|
-
transactionStorageLocation: storageResult.id,
|
|
192
|
-
storageMeta: storageResult.meta,
|
|
193
|
-
topics,
|
|
194
|
-
},
|
|
195
|
-
result: {},
|
|
196
|
-
};
|
|
197
|
-
storageResult.on('confirmed', () => {
|
|
198
|
-
this.logger.debug(`Looking for ${storageResult.id} in subgraph`);
|
|
199
|
-
(0, utils_1.retry)(() => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
200
|
-
const response = yield this.graphql.getTransactionsByHash(storageResult.id);
|
|
201
|
-
if (response.transactions.length === 0) {
|
|
202
|
-
throw Error('no transactions');
|
|
203
|
-
}
|
|
204
|
-
this.logger.debug(`Hash ${storageResult.id} found in subgraph.`);
|
|
205
|
-
return response;
|
|
206
|
-
}), { maxRetries: 100, retryDelay: 1000 })()
|
|
207
|
-
.then((response) => {
|
|
208
|
-
var _a;
|
|
209
|
-
(_a = this.pendingStore) === null || _a === void 0 ? void 0 : _a.remove(channelId);
|
|
210
|
-
eventEmitter.emit('confirmed', Object.assign(Object.assign({}, result), { meta: Object.assign(Object.assign({}, result.meta), { storageMeta: getStorageMeta(response.transactions[0], response._meta.block.number, this.network) }) }));
|
|
211
|
-
})
|
|
212
|
-
.catch((error) => {
|
|
213
|
-
var _a;
|
|
214
|
-
(_a = this.pendingStore) === null || _a === void 0 ? void 0 : _a.remove(channelId);
|
|
215
|
-
eventEmitter.emit('error', error);
|
|
216
|
-
});
|
|
217
|
-
});
|
|
218
|
-
return Object.assign(eventEmitter, result);
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
exports.TheGraphDataWrite = TheGraphDataWrite;
|
|
222
|
-
class NoopDataWrite {
|
|
223
|
-
initialize() {
|
|
224
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
225
|
-
// no-op
|
|
226
|
-
});
|
|
227
|
-
}
|
|
228
|
-
close() {
|
|
229
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
230
|
-
// no-op
|
|
231
|
-
});
|
|
232
|
-
}
|
|
233
|
-
persistTransaction() {
|
|
234
|
-
throw new Error(`cannot call persistTranscation without storage. Specify storage on ${TheGraphDataAccess.name}`);
|
|
235
|
-
}
|
|
236
|
-
}
|
|
9
|
+
const utils_1 = require("@requestnetwork/utils");
|
|
10
|
+
const NoopDataWrite_1 = require("./NoopDataWrite");
|
|
11
|
+
/**
|
|
12
|
+
* A custom DataAccess to retrieve Request data from a TheGraph subgraph.
|
|
13
|
+
* If no `storage` is passed, the data access is read-only.
|
|
14
|
+
*/
|
|
237
15
|
class TheGraphDataAccess extends data_access_1.CombinedDataAccess {
|
|
238
16
|
constructor(_a) {
|
|
239
17
|
var { graphql, storage } = _a, options = tslib_1.__rest(_a, ["graphql", "storage"]);
|
|
240
18
|
const { url } = graphql, rest = tslib_1.__rest(graphql, ["url"]);
|
|
241
|
-
if (!options.pendingStore) {
|
|
242
|
-
options.pendingStore = new pending_store_1.PendingStore();
|
|
243
|
-
}
|
|
244
19
|
const graphqlClient = new subgraph_client_1.SubgraphClient(url, rest);
|
|
245
|
-
const reader = new
|
|
20
|
+
const reader = new data_access_1.DataAccessRead(graphqlClient, options);
|
|
246
21
|
const writer = storage
|
|
247
|
-
? new
|
|
248
|
-
: new NoopDataWrite();
|
|
22
|
+
? new data_access_1.DataAccessWrite(storage, options.pendingStore)
|
|
23
|
+
: new NoopDataWrite_1.NoopDataWrite();
|
|
249
24
|
super(reader, writer);
|
|
250
|
-
|
|
251
|
-
this.
|
|
25
|
+
/** intercept events so that confirmation is emitted only once the transaction is indexed */
|
|
26
|
+
this.persistTransaction = (transactionData, channelId, topics) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
const eventEmitter = new events_1.EventEmitter();
|
|
28
|
+
const result = yield this.writer.persistTransaction(transactionData, channelId, topics);
|
|
29
|
+
result.on('confirmed', (receipt) => {
|
|
30
|
+
this.fetchConfirmedTransaction(channelId, receipt)
|
|
31
|
+
.then((confirmedReceipt) => eventEmitter.emit('confirmed', confirmedReceipt))
|
|
32
|
+
.catch(() => this.logger.warn(`Could not confirm channel ${channelId}`));
|
|
33
|
+
});
|
|
34
|
+
result.on('error', (e) => eventEmitter.emit('error', e));
|
|
35
|
+
return Object.assign(eventEmitter, { meta: result.meta, result: result.result });
|
|
36
|
+
});
|
|
37
|
+
this.logger = options.logger || new utils_1.SimpleLogger();
|
|
38
|
+
this.fetchConfirmedTransaction = (0, utils_1.retry)(this.fetchConfirmedTransaction, {
|
|
39
|
+
context: this,
|
|
40
|
+
maxRetries: 30,
|
|
41
|
+
retryDelay: 1000,
|
|
42
|
+
});
|
|
252
43
|
}
|
|
253
|
-
|
|
44
|
+
/**
|
|
45
|
+
* We wait until the data is indexed on TheGraph
|
|
46
|
+
**/
|
|
47
|
+
fetchConfirmedTransaction(channelId, { meta, result }) {
|
|
254
48
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
255
|
-
|
|
256
|
-
if (
|
|
257
|
-
|
|
49
|
+
const transactions = yield this.reader.getTransactionsByChannelId(channelId);
|
|
50
|
+
if (transactions.result.transactions.some((tx) => tx.state === types_1.DataAccessTypes.TransactionState.PENDING &&
|
|
51
|
+
// ignore transactions that were not included in the receipt being confirmed
|
|
52
|
+
tx.transaction.hash &&
|
|
53
|
+
meta.transactionStorageLocation.includes(tx.transaction.hash))) {
|
|
54
|
+
throw new Error('not confirmed');
|
|
258
55
|
}
|
|
259
56
|
return {
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
57
|
+
meta: Object.assign(Object.assign({}, meta), { storageMeta: meta.storageMeta
|
|
58
|
+
? Object.assign(Object.assign({}, meta.storageMeta), { state: types_1.StorageTypes.ContentState.CONFIRMED }) : undefined }),
|
|
59
|
+
result,
|
|
263
60
|
};
|
|
264
61
|
});
|
|
265
62
|
}
|
package/dist/data-access.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-access.js","sourceRoot":"","sources":["../src/data-access.ts"],"names":[],"mappings":";;;;AAAA,mCAAsC;
|
|
1
|
+
{"version":3,"file":"data-access.js","sourceRoot":"","sources":["../src/data-access.ts"],"names":[],"mappings":";;;;AAAA,mCAAsC;AAEtC,uDAAmD;AACnD,6DAAkG;AAClG,iDAAgF;AAChF,iDAA4D;AAE5D,mDAAgD;AAEhD;;;GAGG;AACH,MAAa,kBAAmB,SAAQ,gCAAkB;IAExD,YAAY,EAA2D;YAA3D,EAAE,OAAO,EAAE,OAAO,OAAyC,EAApC,OAAO,sBAA9B,sBAAgC,CAAF;QACxC,MAAM,EAAE,GAAG,KAAc,OAA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GraphDataAccess } from './data-access';
|
|
3
2
|
export { SubgraphClient } from './subgraph-client';
|
|
4
3
|
export * as queries from './queries';
|
|
5
4
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.queries = exports.SubgraphClient = exports.
|
|
3
|
+
exports.queries = exports.SubgraphClient = exports.TheGraphDataAccess = void 0;
|
|
4
4
|
var data_access_1 = require("./data-access");
|
|
5
5
|
Object.defineProperty(exports, "TheGraphDataAccess", { enumerable: true, get: function () { return data_access_1.TheGraphDataAccess; } });
|
|
6
|
-
Object.defineProperty(exports, "TheGraphDataRead", { enumerable: true, get: function () { return data_access_1.TheGraphDataRead; } });
|
|
7
|
-
Object.defineProperty(exports, "TheGraphDataWrite", { enumerable: true, get: function () { return data_access_1.TheGraphDataWrite; } });
|
|
8
|
-
var pending_store_1 = require("./pending-store");
|
|
9
|
-
Object.defineProperty(exports, "PendingStore", { enumerable: true, get: function () { return pending_store_1.PendingStore; } });
|
|
10
6
|
var subgraph_client_1 = require("./subgraph-client");
|
|
11
7
|
Object.defineProperty(exports, "SubgraphClient", { enumerable: true, get: function () { return subgraph_client_1.SubgraphClient; } });
|
|
12
8
|
exports.queries = require("./queries");
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,6CAAmD;AAA1C,iHAAA,kBAAkB,OAAA;AAC3B,qDAAmD;AAA1C,iHAAA,cAAc,OAAA;AACvB,uCAAqC"}
|
package/dist/queries.js
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import { DataAccessTypes } from '@requestnetwork/types';
|
|
2
|
-
import { TransactionsBody } from './queries';
|
|
1
|
+
import { DataAccessTypes, StorageTypes } from '@requestnetwork/types';
|
|
3
2
|
import { RequestInit } from 'graphql-request/dist/types.dom';
|
|
4
|
-
export declare class SubgraphClient {
|
|
3
|
+
export declare class SubgraphClient implements StorageTypes.IIndexer {
|
|
5
4
|
private graphql;
|
|
6
5
|
readonly endpoint: string;
|
|
7
6
|
constructor(endpoint: string, options?: RequestInit);
|
|
7
|
+
initialize(): Promise<void>;
|
|
8
8
|
getBlockNumber(): Promise<number>;
|
|
9
|
-
|
|
10
|
-
getTransactionsByChannelId(channelId: string, updatedBetween?: DataAccessTypes.ITimestampBoundaries): Promise<
|
|
11
|
-
|
|
9
|
+
getTransactionsByStorageLocation(hash: string): Promise<StorageTypes.IGetTransactionsResponse>;
|
|
10
|
+
getTransactionsByChannelId(channelId: string, updatedBetween?: DataAccessTypes.ITimestampBoundaries): Promise<StorageTypes.IGetTransactionsResponse>;
|
|
11
|
+
getTransactionsByTopics(topics: string[]): Promise<StorageTypes.IGetTransactionsResponse>;
|
|
12
|
+
private fetchAndFormat;
|
|
13
|
+
private toIndexedTransaction;
|
|
12
14
|
private getTimeVariables;
|
|
13
15
|
}
|
|
14
16
|
//# sourceMappingURL=subgraph-client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subgraph-client.d.ts","sourceRoot":"","sources":["../src/subgraph-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,
|
|
1
|
+
{"version":3,"file":"subgraph-client.d.ts","sourceRoot":"","sources":["../src/subgraph-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAWtE,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAM7D,qBAAa,cAAe,YAAW,YAAY,CAAC,QAAQ;IAC1D,OAAO,CAAC,OAAO,CAAgB;IAC/B,SAAgB,QAAQ,EAAE,MAAM,CAAC;gBACrB,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW;IAKtC,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAI3B,cAAc,IAAI,OAAO,CAAC,MAAM,CAAC;IAKvC,gCAAgC,CACrC,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,YAAY,CAAC,wBAAwB,CAAC;IAI1C,0BAA0B,CAC/B,SAAS,EAAE,MAAM,EACjB,cAAc,CAAC,EAAE,eAAe,CAAC,oBAAoB,GACpD,OAAO,CAAC,YAAY,CAAC,wBAAwB,CAAC;IAUpC,uBAAuB,CAClC,MAAM,EAAE,MAAM,EAAE,GACf,OAAO,CAAC,YAAY,CAAC,wBAAwB,CAAC;YAyBnC,cAAc;IAW5B,OAAO,CAAC,oBAAoB;IAkB5B,OAAO,CAAC,gBAAgB;CASzB"}
|
package/dist/subgraph-client.js
CHANGED
|
@@ -11,25 +11,54 @@ class SubgraphClient {
|
|
|
11
11
|
this.endpoint = endpoint;
|
|
12
12
|
this.graphql = new graphql_request_1.GraphQLClient(endpoint, options);
|
|
13
13
|
}
|
|
14
|
+
initialize() {
|
|
15
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
16
|
+
yield this.getBlockNumber();
|
|
17
|
+
});
|
|
18
|
+
}
|
|
14
19
|
getBlockNumber() {
|
|
15
20
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
16
21
|
const { _meta } = yield this.graphql.request(queries_1.GetBlock);
|
|
17
22
|
return _meta.block.number;
|
|
18
23
|
});
|
|
19
24
|
}
|
|
20
|
-
|
|
21
|
-
return this.
|
|
22
|
-
hash,
|
|
23
|
-
});
|
|
25
|
+
getTransactionsByStorageLocation(hash) {
|
|
26
|
+
return this.fetchAndFormat(queries_1.GetTransactionsByHashQuery, { hash });
|
|
24
27
|
}
|
|
25
28
|
getTransactionsByChannelId(channelId, updatedBetween) {
|
|
26
|
-
return this.
|
|
29
|
+
return this.fetchAndFormat(queries_1.GetTransactionsByChannelIdQuery, Object.assign({ channelId }, this.getTimeVariables(updatedBetween)));
|
|
27
30
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
+
// FIXME: this should be possible to do in a single query to the subgraph,
|
|
32
|
+
// but currently one transaction doesn't contain topics from previous ones on the same channel.
|
|
33
|
+
// This could be fixed on the Subgraph indexer code for optimization.
|
|
34
|
+
getTransactionsByTopics(topics) {
|
|
35
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
36
|
+
const { _meta, transactions } = yield this.graphql.request(queries_1.GetChannelsByTopicsQuery, { topics });
|
|
37
|
+
const channelIds = transactions
|
|
38
|
+
.map((x) => x.channelId)
|
|
39
|
+
.filter((val, i, self) => self.indexOf(val) === i);
|
|
40
|
+
const transactionsByChannel = yield Promise.all(channelIds.map((channelId) => this.graphql
|
|
41
|
+
.request(queries_1.GetTransactionsByChannelIdQuery, Object.assign({ channelId }, this.getTimeVariables({})))
|
|
42
|
+
.then((x) => x.transactions))).then((x) => x.flat());
|
|
43
|
+
return {
|
|
44
|
+
transactions: transactionsByChannel.map(this.toIndexedTransaction),
|
|
45
|
+
blockNumber: _meta.block.number,
|
|
46
|
+
};
|
|
31
47
|
});
|
|
32
48
|
}
|
|
49
|
+
fetchAndFormat(query, parameters) {
|
|
50
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
51
|
+
const { _meta, transactions } = yield this.graphql.request(query, parameters);
|
|
52
|
+
return {
|
|
53
|
+
transactions: transactions.map(this.toIndexedTransaction),
|
|
54
|
+
blockNumber: _meta.block.number,
|
|
55
|
+
};
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
toIndexedTransaction(_a) {
|
|
59
|
+
var { publicKeys, encryptedKeys } = _a, transaction = tslib_1.__rest(_a, ["publicKeys", "encryptedKeys"]);
|
|
60
|
+
return Object.assign(Object.assign({}, transaction), { keys: (publicKeys === null || publicKeys === void 0 ? void 0 : publicKeys.reduce((prev, curr, i) => (Object.assign(Object.assign({}, prev), { [curr]: (encryptedKeys === null || encryptedKeys === void 0 ? void 0 : encryptedKeys[i]) || '' })), {})) || undefined });
|
|
61
|
+
}
|
|
33
62
|
getTimeVariables(updatedBetween) {
|
|
34
63
|
if (!updatedBetween) {
|
|
35
64
|
updatedBetween = {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subgraph-client.js","sourceRoot":"","sources":["../src/subgraph-client.ts"],"names":[],"mappings":";;;;AACA,qDAAgD;AAChD,
|
|
1
|
+
{"version":3,"file":"subgraph-client.js","sourceRoot":"","sources":["../src/subgraph-client.ts"],"names":[],"mappings":";;;;AACA,qDAAgD;AAChD,uCAQmB;AAInB,gDAAgD;AAChD,MAAM,aAAa,GAAG,UAAU,CAAC;AAEjC,MAAa,cAAc;IAGzB,YAAY,QAAgB,EAAE,OAAqB;QACjD,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,OAAO,GAAG,IAAI,+BAAa,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IACtD,CAAC;IAEY,UAAU;;YACrB,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;QAC9B,CAAC;KAAA;IAEY,cAAc;;YACzB,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,CAAO,kBAAQ,CAAC,CAAC;YAC7D,OAAO,KAAK,CAAC,KA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C,oBAAoB,CAAC;gBAClE,WAAW,EAAE,KAAK,CAAC,KAAK,CAAC,MAAM;aAChC,CAAC;QACJ,CAAC;KAAA;IAEa,cAAc,CAC1B,KAAa,EACb,UAAiC;;YAEjC,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,CAAmB,KAAK,EAAE,UAAU,CAAC,CAAC;YAChG,OAAO;gBACL,YAAY,EAAE,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,oBAAoB,CAAC;gBACzD,WAAW,EAAE,KAAK,CAAC,KAAK,CAAC,MAAM;aAChC,CAAC;QACJ,CAAC;KAAA;IAEO,oBAAoB,CAAC,EAIf;YAJe,EAC3B,UAAU,EACV,aAAa,OAED,EADT,WAAW,sBAHa,+BAI5B,CADe;QAEd,uCACK,WAAW,KACd,IAAI,EACF,CAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,MAAM,CAChB,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,iCACd,IAAI,KACP,CAAC,IAAI,CAAC,EAAE,CAAA,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAG,CAAC,CAAC,KAAI,EAAE,IAChC,EACF,EAA4B,CAC7B,KAAI,SAAS,IAChB;IACJ,CAAC;IAEO,gBAAgB,CAAC,cAAqD;QAC5E,IAAI,CAAC,cAAc,EAAE;YACnB,cAAc,GAAG,EAAE,CAAC;SACrB;QACD,OAAO;YACL,IAAI,EAAE,cAAc,CAAC,IAAI,IAAI,CAAC;YAC9B,EAAE,EAAE,cAAc,CAAC,EAAE,IAAI,aAAa;SACvC,CAAC;IACJ,CAAC;CACF;AArGD,wCAqGC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { StorageTypes } from '@requestnetwork/types';
|
|
2
|
+
import { DataAccessBaseOptions } from '@requestnetwork/data-access';
|
|
3
|
+
import { RequestInit } from 'graphql-request/dist/types.dom';
|
|
4
|
+
export type TheGraphDataAccessOptions = DataAccessBaseOptions & {
|
|
5
|
+
graphql: {
|
|
6
|
+
url: string;
|
|
7
|
+
} & RequestInit;
|
|
8
|
+
storage?: StorageTypes.IStorageWrite;
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAEpE,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAE7D,MAAM,MAAM,yBAAyB,GAAG,qBAAqB,GAAG;IAC9D,OAAO,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,GAAG,WAAW,CAAC;IACvC,OAAO,CAAC,EAAE,YAAY,CAAC,aAAa,CAAC;CACtC,CAAC"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@requestnetwork/thegraph-data-access",
|
|
3
|
-
"version": "0.35.3-next.
|
|
3
|
+
"version": "0.35.3-next.1938+9021cf2d",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -40,14 +40,13 @@
|
|
|
40
40
|
"test:watch": "yarn test --watch"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@requestnetwork/data-access": "0.28.1-next.
|
|
44
|
-
"@requestnetwork/smart-contracts": "0.30.1-next.
|
|
45
|
-
"@requestnetwork/types": "0.37.1-next.
|
|
46
|
-
"@requestnetwork/utils": "0.37.1-next.
|
|
43
|
+
"@requestnetwork/data-access": "0.28.1-next.1938+9021cf2d",
|
|
44
|
+
"@requestnetwork/smart-contracts": "0.30.1-next.1938+9021cf2d",
|
|
45
|
+
"@requestnetwork/types": "0.37.1-next.1938+9021cf2d",
|
|
46
|
+
"@requestnetwork/utils": "0.37.1-next.1938+9021cf2d",
|
|
47
47
|
"ethers": "5.5.1",
|
|
48
48
|
"graphql-request": "3.4.0",
|
|
49
|
-
"tslib": "2.5.0"
|
|
50
|
-
"typed-emitter": "1.4.0"
|
|
49
|
+
"tslib": "2.5.0"
|
|
51
50
|
},
|
|
52
51
|
"devDependencies": {
|
|
53
52
|
"@types/jest": "26.0.13",
|
|
@@ -58,5 +57,5 @@
|
|
|
58
57
|
"ts-node": "10.9.1",
|
|
59
58
|
"typescript": "4.9.5"
|
|
60
59
|
},
|
|
61
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "9021cf2d70f1908645d1a35113ed7936a98a31f7"
|
|
62
61
|
}
|
package/dist/pending-store.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { DataAccessTypes, StorageTypes } from '@requestnetwork/types';
|
|
2
|
-
type PendingItem = {
|
|
3
|
-
transaction: DataAccessTypes.ITransaction;
|
|
4
|
-
storageResult: StorageTypes.IAppendResult;
|
|
5
|
-
};
|
|
6
|
-
/**
|
|
7
|
-
* A simple in-memory store to share state between DataReader and DataWriter
|
|
8
|
-
* Useful to retrieve a transaction that was just emitted but is not confirmed yet
|
|
9
|
-
**/
|
|
10
|
-
export declare class PendingStore {
|
|
11
|
-
private pending;
|
|
12
|
-
/** Gets a pending tx */
|
|
13
|
-
get(channelId: string): PendingItem;
|
|
14
|
-
add(channelId: string, transaction: DataAccessTypes.ITransaction, storageResult: StorageTypes.IAppendResult): void;
|
|
15
|
-
remove(channelId: string): void;
|
|
16
|
-
}
|
|
17
|
-
export {};
|
|
18
|
-
//# sourceMappingURL=pending-store.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pending-store.d.ts","sourceRoot":"","sources":["../src/pending-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAEtE,KAAK,WAAW,GAAG;IACjB,WAAW,EAAE,eAAe,CAAC,YAAY,CAAC;IAC1C,aAAa,EAAE,YAAY,CAAC,aAAa,CAAC;CAC3C,CAAC;AACF;;;IAGI;AACJ,qBAAa,YAAY;IACvB,OAAO,CAAC,OAAO,CAAmC;IAElD,wBAAwB;IACjB,GAAG,CAAC,SAAS,EAAE,MAAM,GAAG,WAAW;IAInC,GAAG,CACR,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,eAAe,CAAC,YAAY,EACzC,aAAa,EAAE,YAAY,CAAC,aAAa,GACxC,IAAI;IAIA,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;CAGvC"}
|
package/dist/pending-store.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PendingStore = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* A simple in-memory store to share state between DataReader and DataWriter
|
|
6
|
-
* Useful to retrieve a transaction that was just emitted but is not confirmed yet
|
|
7
|
-
**/
|
|
8
|
-
class PendingStore {
|
|
9
|
-
constructor() {
|
|
10
|
-
this.pending = {};
|
|
11
|
-
}
|
|
12
|
-
/** Gets a pending tx */
|
|
13
|
-
get(channelId) {
|
|
14
|
-
return this.pending[channelId];
|
|
15
|
-
}
|
|
16
|
-
add(channelId, transaction, storageResult) {
|
|
17
|
-
this.pending[channelId] = { transaction, storageResult };
|
|
18
|
-
}
|
|
19
|
-
remove(channelId) {
|
|
20
|
-
delete this.pending[channelId];
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
exports.PendingStore = PendingStore;
|
|
24
|
-
//# sourceMappingURL=pending-store.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pending-store.js","sourceRoot":"","sources":["../src/pending-store.ts"],"names":[],"mappings":";;;AAMA;;;IAGI;AACJ,MAAa,YAAY;IAAzB;QACU,YAAO,GAAgC,EAAE,CAAC;IAkBpD,CAAC;IAhBC,wBAAwB;IACjB,GAAG,CAAC,SAAiB;QAC1B,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IACjC,CAAC;IAEM,GAAG,CACR,SAAiB,EACjB,WAAyC,EACzC,aAAyC;QAEzC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,GAAG,EAAE,WAAW,EAAE,aAAa,EAAE,CAAC;IAC3D,CAAC;IAEM,MAAM,CAAC,SAAiB;QAC7B,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IACjC,CAAC;CACF;AAnBD,oCAmBC"}
|