@aigne/afs-ocap 1.12.0-beta.5
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/LICENSE.md +26 -0
- package/README.md +144 -0
- package/aup/accounts/default.json +64 -0
- package/aup/accounts/item.json +510 -0
- package/aup/assets/default.json +70 -0
- package/aup/assets/item.json +360 -0
- package/aup/bridges/_addr/blocks/item.json +168 -0
- package/aup/bridges/default.json +79 -0
- package/aup/bridges/item.json +868 -0
- package/aup/config/default.json +806 -0
- package/aup/default.json +387 -0
- package/aup/delegates/default.json +71 -0
- package/aup/delegates/item.json +241 -0
- package/aup/factories/default.json +78 -0
- package/aup/factories/item.json +310 -0
- package/aup/stakes/default.json +76 -0
- package/aup/stakes/item.json +374 -0
- package/aup/tokens/default.json +76 -0
- package/aup/tokens/item.json +384 -0
- package/aup/transactions/default.json +102 -0
- package/aup/transactions/item.json +286 -0
- package/aup/validators/default.json +57 -0
- package/aup/validators/item.json +99 -0
- package/dist/_virtual/_@oxc-project_runtime@0.108.0/helpers/decorate.cjs +11 -0
- package/dist/_virtual/_@oxc-project_runtime@0.108.0/helpers/decorate.mjs +10 -0
- package/dist/index.cjs +7 -0
- package/dist/index.d.cts +5 -0
- package/dist/index.d.mts +5 -0
- package/dist/index.mjs +4 -0
- package/dist/method-colors.cjs +137 -0
- package/dist/method-colors.mjs +136 -0
- package/dist/method-colors.mjs.map +1 -0
- package/dist/provider.cjs +2490 -0
- package/dist/provider.d.cts +453 -0
- package/dist/provider.d.cts.map +1 -0
- package/dist/provider.d.mts +453 -0
- package/dist/provider.d.mts.map +1 -0
- package/dist/provider.mjs +2490 -0
- package/dist/provider.mjs.map +1 -0
- package/dist/remote-source.cjs +338 -0
- package/dist/remote-source.d.cts +62 -0
- package/dist/remote-source.d.cts.map +1 -0
- package/dist/remote-source.d.mts +62 -0
- package/dist/remote-source.d.mts.map +1 -0
- package/dist/remote-source.mjs +339 -0
- package/dist/remote-source.mjs.map +1 -0
- package/dist/source.d.cts +77 -0
- package/dist/source.d.cts.map +1 -0
- package/dist/source.d.mts +77 -0
- package/dist/source.d.mts.map +1 -0
- package/dist/types.d.cts +572 -0
- package/dist/types.d.cts.map +1 -0
- package/dist/types.d.mts +572 -0
- package/dist/types.d.mts.map +1 -0
- package/dist/utils.cjs +581 -0
- package/dist/utils.mjs +557 -0
- package/dist/utils.mjs.map +1 -0
- package/package.json +61 -0
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
let _aigne_afs = require("@aigne/afs");
|
|
2
|
+
|
|
3
|
+
//#region src/remote-source.ts
|
|
4
|
+
const log = (0, _aigne_afs.makeNsLog)("provider:ocap");
|
|
5
|
+
let _clientCtorPromise = null;
|
|
6
|
+
function loadGraphQLClientCtor() {
|
|
7
|
+
if (!_clientCtorPromise) _clientCtorPromise = import("@ocap/client").then((mod) => {
|
|
8
|
+
return mod.default ?? mod;
|
|
9
|
+
});
|
|
10
|
+
return _clientCtorPromise;
|
|
11
|
+
}
|
|
12
|
+
function toGraphQLPaging(paging) {
|
|
13
|
+
return {
|
|
14
|
+
size: paging.size,
|
|
15
|
+
cursor: String(paging.offset)
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function fromPageInfo(page, items) {
|
|
19
|
+
return {
|
|
20
|
+
total: page?.total ?? items.length,
|
|
21
|
+
hasNext: page?.next ?? false
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
var OcapRemoteSource = class {
|
|
25
|
+
/**
|
|
26
|
+
* Lazily-instantiated GraphQL client. Initialized on the first method call,
|
|
27
|
+
* not at construction time, because `@ocap/client` is loaded via dynamic
|
|
28
|
+
* `import()` so bundlers can keep it out of the cold-start path.
|
|
29
|
+
*/
|
|
30
|
+
clientPromise = null;
|
|
31
|
+
url;
|
|
32
|
+
constructor(endpoint) {
|
|
33
|
+
this.url = /^https?:\/\//i.test(endpoint) ? endpoint : `https://${endpoint}`;
|
|
34
|
+
}
|
|
35
|
+
getClient() {
|
|
36
|
+
if (!this.clientPromise) this.clientPromise = loadGraphQLClientCtor().then((Ctor) => new Ctor(this.url));
|
|
37
|
+
return this.clientPromise;
|
|
38
|
+
}
|
|
39
|
+
async getChainInfo() {
|
|
40
|
+
return (await (await this.getClient()).getChainInfo()).info;
|
|
41
|
+
}
|
|
42
|
+
async getConfig() {
|
|
43
|
+
const res = await (await this.getClient()).getConfig({ parsed: true });
|
|
44
|
+
try {
|
|
45
|
+
return JSON.parse(res.config);
|
|
46
|
+
} catch {
|
|
47
|
+
return { raw: res.config };
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
async getValidatorsInfo() {
|
|
51
|
+
return (await (await this.getClient()).getValidatorsInfo()).validatorsInfo?.validators || [];
|
|
52
|
+
}
|
|
53
|
+
async getForgeStats() {
|
|
54
|
+
const f = (await (await this.getClient()).getForgeStats()).forgeStats || {};
|
|
55
|
+
return { forgeStats: {
|
|
56
|
+
numTxs: f.numTxs ?? [],
|
|
57
|
+
numStakes: f.numStakes ?? [],
|
|
58
|
+
numValidators: f.numValidators ?? [],
|
|
59
|
+
numDeclareTxs: f.numDeclareTxs ?? []
|
|
60
|
+
} };
|
|
61
|
+
}
|
|
62
|
+
async getTx(hash) {
|
|
63
|
+
return (await (await this.getClient()).getTx({ hash })).info ?? null;
|
|
64
|
+
}
|
|
65
|
+
async listTransactions(paging, filters) {
|
|
66
|
+
const params = { paging: toGraphQLPaging(paging) };
|
|
67
|
+
if (filters?.addressFilter) params.addressFilter = filters.addressFilter;
|
|
68
|
+
if (filters?.typeFilter) params.typeFilter = filters.typeFilter;
|
|
69
|
+
if (filters?.tokenFilter) params.tokenFilter = filters.tokenFilter;
|
|
70
|
+
if (filters?.assetFilter) params.assetFilter = filters.assetFilter;
|
|
71
|
+
if (filters?.factoryFilter) params.factoryFilter = filters.factoryFilter;
|
|
72
|
+
if (filters?.accountFilter) params.accountFilter = filters.accountFilter;
|
|
73
|
+
if (filters?.rollupFilter) params.rollupFilter = filters.rollupFilter;
|
|
74
|
+
if (filters?.stakeFilter) params.stakeFilter = filters.stakeFilter;
|
|
75
|
+
if (filters?.delegationFilter) params.delegationFilter = filters.delegationFilter;
|
|
76
|
+
if (filters?.validityFilter) params.validityFilter = filters.validityFilter;
|
|
77
|
+
if (filters?.timeFilter) params.timeFilter = filters.timeFilter;
|
|
78
|
+
const res = await (await this.getClient()).listTransactions(params);
|
|
79
|
+
const items = res.transactions || [];
|
|
80
|
+
return {
|
|
81
|
+
items,
|
|
82
|
+
...fromPageInfo(res.page, items)
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
async getAccountState(address) {
|
|
86
|
+
const res = await (await this.getClient()).getAccountState({ address });
|
|
87
|
+
if (!res.state) return null;
|
|
88
|
+
const { context, ...rest } = res.state;
|
|
89
|
+
return {
|
|
90
|
+
...rest,
|
|
91
|
+
genesisTime: context?.genesisTime ?? void 0,
|
|
92
|
+
renaissanceTime: context?.renaissanceTime ?? void 0
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
async getAccountTokens(address) {
|
|
96
|
+
return (await (await this.getClient()).getAccountTokens({ address })).tokens || [];
|
|
97
|
+
}
|
|
98
|
+
async listTopAccounts(paging, filters) {
|
|
99
|
+
const res = await (await this.getClient()).listTopAccounts({
|
|
100
|
+
paging: toGraphQLPaging(paging),
|
|
101
|
+
...filters?.tokenAddress && { tokenAddress: filters.tokenAddress },
|
|
102
|
+
...filters?.timeFilter && { timeFilter: filters.timeFilter }
|
|
103
|
+
});
|
|
104
|
+
const items = res.accounts || [];
|
|
105
|
+
return {
|
|
106
|
+
items,
|
|
107
|
+
...fromPageInfo(res.page, items)
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
async getTokenState(address) {
|
|
111
|
+
return (await (await this.getClient()).getTokenState({ address })).state ?? null;
|
|
112
|
+
}
|
|
113
|
+
async listTokens(paging, filters) {
|
|
114
|
+
const res = await (await this.getClient()).listTokens({
|
|
115
|
+
paging: toGraphQLPaging(paging),
|
|
116
|
+
...filters?.issuerAddress && { issuerAddress: filters.issuerAddress },
|
|
117
|
+
...filters?.timeFilter && { timeFilter: filters.timeFilter }
|
|
118
|
+
});
|
|
119
|
+
const items = res.tokens || [];
|
|
120
|
+
return {
|
|
121
|
+
items,
|
|
122
|
+
...fromPageInfo(res.page, items)
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
async getAssetState(address) {
|
|
126
|
+
const res = await (await this.getClient()).getAssetState({ address });
|
|
127
|
+
if (!res.state) return null;
|
|
128
|
+
const { context, ...rest } = res.state;
|
|
129
|
+
return {
|
|
130
|
+
...rest,
|
|
131
|
+
genesisTime: context?.genesisTime ?? void 0,
|
|
132
|
+
renaissanceTime: context?.renaissanceTime ?? void 0
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
async listAssets(paging, filters) {
|
|
136
|
+
const res = await (await this.getClient()).listAssets({
|
|
137
|
+
paging: toGraphQLPaging(paging),
|
|
138
|
+
...filters?.ownerAddress && { ownerAddress: filters.ownerAddress },
|
|
139
|
+
...filters?.factoryAddress && { factoryAddress: filters.factoryAddress },
|
|
140
|
+
...filters?.timeFilter && { timeFilter: filters.timeFilter }
|
|
141
|
+
});
|
|
142
|
+
const items = res.assets || [];
|
|
143
|
+
return {
|
|
144
|
+
items,
|
|
145
|
+
...fromPageInfo(res.page, items)
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
async getFactoryState(address) {
|
|
149
|
+
const res = await (await this.getClient()).getFactoryState({ address });
|
|
150
|
+
if (!res.state) return null;
|
|
151
|
+
const { context, ...rest } = res.state;
|
|
152
|
+
return {
|
|
153
|
+
...rest,
|
|
154
|
+
genesisTime: context?.genesisTime ?? void 0,
|
|
155
|
+
renaissanceTime: context?.renaissanceTime ?? void 0
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
async listFactories(paging, filters) {
|
|
159
|
+
const res = await (await this.getClient()).listFactories({
|
|
160
|
+
paging: toGraphQLPaging(paging),
|
|
161
|
+
...filters?.ownerAddress && { ownerAddress: filters.ownerAddress },
|
|
162
|
+
...filters?.addressList && { addressList: filters.addressList },
|
|
163
|
+
...filters?.timeFilter && { timeFilter: filters.timeFilter }
|
|
164
|
+
});
|
|
165
|
+
const items = res.factories || [];
|
|
166
|
+
return {
|
|
167
|
+
items,
|
|
168
|
+
...fromPageInfo(res.page, items)
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
async getStakeState(address) {
|
|
172
|
+
return (await (await this.getClient()).getStakeState({ address })).state ?? null;
|
|
173
|
+
}
|
|
174
|
+
async listStakes(paging, filters) {
|
|
175
|
+
const params = { paging: toGraphQLPaging(paging) };
|
|
176
|
+
if (filters?.addressFilter) params.addressFilter = filters.addressFilter;
|
|
177
|
+
if (filters?.timeFilter) params.timeFilter = filters.timeFilter;
|
|
178
|
+
const res = await (await this.getClient()).listStakes(params);
|
|
179
|
+
const items = res.stakes || [];
|
|
180
|
+
return {
|
|
181
|
+
items,
|
|
182
|
+
...fromPageInfo(res.page, items)
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
async getRollupState(address) {
|
|
186
|
+
return (await (await this.getClient()).getRollupState({ address })).state ?? null;
|
|
187
|
+
}
|
|
188
|
+
async listRollups(paging, filters) {
|
|
189
|
+
const res = await (await this.getClient()).listRollups({
|
|
190
|
+
paging: toGraphQLPaging(paging),
|
|
191
|
+
...filters?.tokenAddress && { tokenAddress: filters.tokenAddress },
|
|
192
|
+
...filters?.timeFilter && { timeFilter: filters.timeFilter }
|
|
193
|
+
});
|
|
194
|
+
const items = res.rollups || [];
|
|
195
|
+
return {
|
|
196
|
+
items,
|
|
197
|
+
...fromPageInfo(res.page, items)
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
async getRollupBlock(hash, rollupAddress) {
|
|
201
|
+
return (await (await this.getClient()).getRollupBlock({
|
|
202
|
+
hash,
|
|
203
|
+
rollupAddress
|
|
204
|
+
})).block ?? null;
|
|
205
|
+
}
|
|
206
|
+
async listRollupBlocks(rollupAddress, paging, filters) {
|
|
207
|
+
const res = await (await this.getClient()).listRollupBlocks({
|
|
208
|
+
rollupAddress,
|
|
209
|
+
paging: toGraphQLPaging(paging),
|
|
210
|
+
...filters?.validatorFilter && { validatorFilter: filters.validatorFilter }
|
|
211
|
+
});
|
|
212
|
+
const items = res.blocks || [];
|
|
213
|
+
return {
|
|
214
|
+
items,
|
|
215
|
+
...fromPageInfo(res.page, items)
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
async listRollupValidators(rollupAddress, paging) {
|
|
219
|
+
const res = await (await this.getClient()).listRollupValidators({
|
|
220
|
+
rollupAddress,
|
|
221
|
+
paging: toGraphQLPaging(paging)
|
|
222
|
+
});
|
|
223
|
+
const items = res.validators || [];
|
|
224
|
+
return {
|
|
225
|
+
items,
|
|
226
|
+
...fromPageInfo(res.page, items)
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
async getDelegateState(address) {
|
|
230
|
+
const res = await (await this.getClient()).getDelegateState({ address });
|
|
231
|
+
if (!res.state) return null;
|
|
232
|
+
const { ops, ...rest } = res.state;
|
|
233
|
+
const opsArray = ops ? Object.entries(ops).map(([key, value]) => ({
|
|
234
|
+
key,
|
|
235
|
+
value
|
|
236
|
+
})) : void 0;
|
|
237
|
+
return {
|
|
238
|
+
...rest,
|
|
239
|
+
ops: opsArray
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
async listDelegations(paging, filters) {
|
|
243
|
+
const res = await (await this.getClient()).listDelegations({
|
|
244
|
+
paging: toGraphQLPaging(paging),
|
|
245
|
+
...filters?.from && { from: filters.from },
|
|
246
|
+
...filters?.to && { to: filters.to },
|
|
247
|
+
...filters?.timeFilter && { timeFilter: filters.timeFilter }
|
|
248
|
+
});
|
|
249
|
+
const items = res.delegations || [];
|
|
250
|
+
return {
|
|
251
|
+
items,
|
|
252
|
+
...fromPageInfo(res.page, items)
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
async search(keyword, paging) {
|
|
256
|
+
const res = await (await this.getClient()).search({
|
|
257
|
+
keyword,
|
|
258
|
+
paging: toGraphQLPaging(paging)
|
|
259
|
+
});
|
|
260
|
+
const items = (res.results || []).map((r) => ({
|
|
261
|
+
type: r.type,
|
|
262
|
+
id: r.id,
|
|
263
|
+
title: r.title || "",
|
|
264
|
+
subtitle: r.subtitle || "",
|
|
265
|
+
description: r.description || "",
|
|
266
|
+
tags: r.tags || [],
|
|
267
|
+
timestamp: r.timestamp || ""
|
|
268
|
+
}));
|
|
269
|
+
return {
|
|
270
|
+
items,
|
|
271
|
+
...fromPageInfo(res.page, items)
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
async listTokenFlows(accountAddress, paging, options) {
|
|
275
|
+
const res = await (await this.getClient()).listTokenFlows({
|
|
276
|
+
accountAddress,
|
|
277
|
+
paging: toGraphQLPaging(paging),
|
|
278
|
+
...options?.tokenAddress && { tokenAddress: options.tokenAddress },
|
|
279
|
+
...options?.depth != null && { depth: options.depth },
|
|
280
|
+
...options?.direction && { direction: options.direction }
|
|
281
|
+
});
|
|
282
|
+
const items = (res.data ?? []).map((d) => ({
|
|
283
|
+
hash: d.hash,
|
|
284
|
+
from: d.from,
|
|
285
|
+
to: d.to,
|
|
286
|
+
value: d.value
|
|
287
|
+
}));
|
|
288
|
+
return {
|
|
289
|
+
items,
|
|
290
|
+
...fromPageInfo(res.page, items)
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Install `@ocap/client/subscribe` on the GraphQL client and forward
|
|
295
|
+
* topic events to the supplied callback. The install is lazy — it
|
|
296
|
+
* waits for the client to be constructed via `getClient()` so we
|
|
297
|
+
* don't pay the import cost on instances that never subscribe.
|
|
298
|
+
*
|
|
299
|
+
* Returns an unsub fn. Failures during install (e.g. the bundled
|
|
300
|
+
* runtime can't resolve `@arcblock/ws`) bubble up so
|
|
301
|
+
* `AFSOCAP.onMount` can fall back to `live: false` without
|
|
302
|
+
* misreporting capability.
|
|
303
|
+
*/
|
|
304
|
+
subscribe(topic, callback) {
|
|
305
|
+
let cancelled = false;
|
|
306
|
+
let installedUnsub = null;
|
|
307
|
+
const installAsync = async () => {
|
|
308
|
+
const client = await this.getClient();
|
|
309
|
+
if (!Object.hasOwn(client, "_ensureSocketClient")) {
|
|
310
|
+
const mod = await import("@ocap/client/subscribe");
|
|
311
|
+
const install = mod.install ?? mod.default?.install;
|
|
312
|
+
if (typeof install !== "function") throw new Error("@ocap/client/subscribe: install() not found on imported module");
|
|
313
|
+
install(client);
|
|
314
|
+
}
|
|
315
|
+
if (cancelled) return;
|
|
316
|
+
const handler = (payload) => {
|
|
317
|
+
try {
|
|
318
|
+
callback(payload);
|
|
319
|
+
} catch {}
|
|
320
|
+
};
|
|
321
|
+
client.subscribe?.(topic, handler);
|
|
322
|
+
installedUnsub = () => client.unsubscribe?.(topic, handler);
|
|
323
|
+
};
|
|
324
|
+
installAsync().catch((err) => {
|
|
325
|
+
if (typeof console !== "undefined") log.warn("[OcapRemoteSource] subscribe install failed", err);
|
|
326
|
+
});
|
|
327
|
+
return () => {
|
|
328
|
+
if (cancelled) return;
|
|
329
|
+
cancelled = true;
|
|
330
|
+
try {
|
|
331
|
+
installedUnsub?.();
|
|
332
|
+
} catch {}
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
};
|
|
336
|
+
|
|
337
|
+
//#endregion
|
|
338
|
+
exports.OcapRemoteSource = OcapRemoteSource;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { ForgeStatsSlice, OcapDataSource } from "./source.cjs";
|
|
2
|
+
import { AccountFilters, AccountState, AccountToken, AssetFactoryState, AssetFilters, AssetState, BridgeFilters, ChainConfig, ChainInfo, DelegateState, DelegationFilters, FactoryFilters, IndexedAccountState, IndexedAssetState, IndexedDelegationState, IndexedFactoryState, IndexedRollupBlock, IndexedRollupState, IndexedRollupValidator, IndexedStakeState, IndexedTokenFlow, IndexedTokenState, IndexedTransaction, PagedResult, Paging, RollupBlock, RollupBlockFilters, RollupState, SearchResult, StakeFilters, StakeState, TokenFilters, TokenFlowDirection, TokenState, TransactionInfo, TxFilters, ValidatorInfo } from "./types.cjs";
|
|
3
|
+
|
|
4
|
+
//#region src/remote-source.d.ts
|
|
5
|
+
declare class OcapRemoteSource implements OcapDataSource {
|
|
6
|
+
/**
|
|
7
|
+
* Lazily-instantiated GraphQL client. Initialized on the first method call,
|
|
8
|
+
* not at construction time, because `@ocap/client` is loaded via dynamic
|
|
9
|
+
* `import()` so bundlers can keep it out of the cold-start path.
|
|
10
|
+
*/
|
|
11
|
+
private clientPromise;
|
|
12
|
+
private readonly url;
|
|
13
|
+
constructor(endpoint: string);
|
|
14
|
+
private getClient;
|
|
15
|
+
getChainInfo(): Promise<ChainInfo>;
|
|
16
|
+
getConfig(): Promise<ChainConfig>;
|
|
17
|
+
getValidatorsInfo(): Promise<ValidatorInfo[]>;
|
|
18
|
+
getForgeStats(): Promise<{
|
|
19
|
+
forgeStats: ForgeStatsSlice;
|
|
20
|
+
}>;
|
|
21
|
+
getTx(hash: string): Promise<TransactionInfo | null>;
|
|
22
|
+
listTransactions(paging: Paging, filters?: TxFilters): Promise<PagedResult<IndexedTransaction>>;
|
|
23
|
+
getAccountState(address: string): Promise<AccountState | null>;
|
|
24
|
+
getAccountTokens(address: string): Promise<AccountToken[]>;
|
|
25
|
+
listTopAccounts(paging: Paging, filters?: AccountFilters): Promise<PagedResult<IndexedAccountState>>;
|
|
26
|
+
getTokenState(address: string): Promise<TokenState | null>;
|
|
27
|
+
listTokens(paging: Paging, filters?: TokenFilters): Promise<PagedResult<IndexedTokenState>>;
|
|
28
|
+
getAssetState(address: string): Promise<AssetState | null>;
|
|
29
|
+
listAssets(paging: Paging, filters?: AssetFilters): Promise<PagedResult<IndexedAssetState>>;
|
|
30
|
+
getFactoryState(address: string): Promise<AssetFactoryState | null>;
|
|
31
|
+
listFactories(paging: Paging, filters?: FactoryFilters): Promise<PagedResult<IndexedFactoryState>>;
|
|
32
|
+
getStakeState(address: string): Promise<StakeState | null>;
|
|
33
|
+
listStakes(paging: Paging, filters?: StakeFilters): Promise<PagedResult<IndexedStakeState>>;
|
|
34
|
+
getRollupState(address: string): Promise<RollupState | null>;
|
|
35
|
+
listRollups(paging: Paging, filters?: BridgeFilters): Promise<PagedResult<IndexedRollupState>>;
|
|
36
|
+
getRollupBlock(hash: string, rollupAddress: string): Promise<RollupBlock | null>;
|
|
37
|
+
listRollupBlocks(rollupAddress: string, paging: Paging, filters?: RollupBlockFilters): Promise<PagedResult<IndexedRollupBlock>>;
|
|
38
|
+
listRollupValidators(rollupAddress: string, paging: Paging): Promise<PagedResult<IndexedRollupValidator>>;
|
|
39
|
+
getDelegateState(address: string): Promise<DelegateState | null>;
|
|
40
|
+
listDelegations(paging: Paging, filters?: DelegationFilters): Promise<PagedResult<IndexedDelegationState>>;
|
|
41
|
+
search(keyword: string, paging: Paging): Promise<PagedResult<SearchResult>>;
|
|
42
|
+
listTokenFlows(accountAddress: string, paging: Paging, options?: {
|
|
43
|
+
tokenAddress?: string;
|
|
44
|
+
depth?: number;
|
|
45
|
+
direction?: TokenFlowDirection;
|
|
46
|
+
}): Promise<PagedResult<IndexedTokenFlow>>;
|
|
47
|
+
/**
|
|
48
|
+
* Install `@ocap/client/subscribe` on the GraphQL client and forward
|
|
49
|
+
* topic events to the supplied callback. The install is lazy — it
|
|
50
|
+
* waits for the client to be constructed via `getClient()` so we
|
|
51
|
+
* don't pay the import cost on instances that never subscribe.
|
|
52
|
+
*
|
|
53
|
+
* Returns an unsub fn. Failures during install (e.g. the bundled
|
|
54
|
+
* runtime can't resolve `@arcblock/ws`) bubble up so
|
|
55
|
+
* `AFSOCAP.onMount` can fall back to `live: false` without
|
|
56
|
+
* misreporting capability.
|
|
57
|
+
*/
|
|
58
|
+
subscribe(topic: string, callback: (payload: unknown) => void): () => void;
|
|
59
|
+
}
|
|
60
|
+
//#endregion
|
|
61
|
+
export { OcapRemoteSource };
|
|
62
|
+
//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AY,mBAAA;EAWjB,aAAA,CAAc,OAAA,WAAkB,OAAA,CAAQ,UAAA;EAKxC,UAAA,CACJ,MAAA,EAAQ,MAAA,EACR,OAAA,GAAU,YAAA,GACT,OAAA,CAAQ,WAAA,CAAY,iBAAA;EAWjB,cAAA,CAAe,OAAA,WAAkB,OAAA,CAAQ,WAAA;EAKzC,WAAA,CACJ,MAAA,EAAQ,MAAA,EACR,OAAA,GAAU,aAAA,GACT,OAAA,CAAQ,WAAA,CAAY,kBAAA;EAUjB,cAAA,CAAe,IAAA,UAAc,aAAA,WAAwB,OAAA,CAAQ,WAAA;EAK7D,gBAAA,CACJ,aAAA,UACA,MAAA,EAAQ,MAAA,EACR,OAAA,GAAU,kBAAA,GACT,OAAA,CAAQ,WAAA,CAAY,kBAAA;EAUjB,oBAAA,CACJ,aAAA,UACA,MAAA,EAAQ,MAAA,GACP,OAAA,CAAQ,WAAA,CAAY,sBAAA;EASjB,gBAAA,CAAiB,OAAA,WAAkB,OAAA,CAAQ,aAAA;EAS3C,eAAA,CACJ,MAAA,EAAQ,MAAA,EACR,OAAA,GAAU,iBAAA,GACT,OAAA,CAAQ,WAAA,CAAY,sBAAA;EAWjB,MAAA,CAAO,OAAA,UAAiB,MAAA,EAAQ,MAAA,GAAS,OAAA,CAAQ,WAAA,CAAY,YAAA;EAiB7D,cAAA,CACJ,cAAA,UACA,MAAA,EAAQ,MAAA,EACR,OAAA;IACE,YAAA;IACA,KAAA;IACA,SAAA,GAJY,kBAAA;EAAA,IAMb,OAAA,CAAQ,WAAA,CAF4C,gBAAA;EAlHT;;;;;;;;;;;EAiJ9C,SAAA,CAAU,KAAA,UAAe,QAAA,GAAW,OAAA;AAAA"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { ForgeStatsSlice, OcapDataSource } from "./source.mjs";
|
|
2
|
+
import { AccountFilters, AccountState, AccountToken, AssetFactoryState, AssetFilters, AssetState, BridgeFilters, ChainConfig, ChainInfo, DelegateState, DelegationFilters, FactoryFilters, IndexedAccountState, IndexedAssetState, IndexedDelegationState, IndexedFactoryState, IndexedRollupBlock, IndexedRollupState, IndexedRollupValidator, IndexedStakeState, IndexedTokenFlow, IndexedTokenState, IndexedTransaction, PagedResult, Paging, RollupBlock, RollupBlockFilters, RollupState, SearchResult, StakeFilters, StakeState, TokenFilters, TokenFlowDirection, TokenState, TransactionInfo, TxFilters, ValidatorInfo } from "./types.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/remote-source.d.ts
|
|
5
|
+
declare class OcapRemoteSource implements OcapDataSource {
|
|
6
|
+
/**
|
|
7
|
+
* Lazily-instantiated GraphQL client. Initialized on the first method call,
|
|
8
|
+
* not at construction time, because `@ocap/client` is loaded via dynamic
|
|
9
|
+
* `import()` so bundlers can keep it out of the cold-start path.
|
|
10
|
+
*/
|
|
11
|
+
private clientPromise;
|
|
12
|
+
private readonly url;
|
|
13
|
+
constructor(endpoint: string);
|
|
14
|
+
private getClient;
|
|
15
|
+
getChainInfo(): Promise<ChainInfo>;
|
|
16
|
+
getConfig(): Promise<ChainConfig>;
|
|
17
|
+
getValidatorsInfo(): Promise<ValidatorInfo[]>;
|
|
18
|
+
getForgeStats(): Promise<{
|
|
19
|
+
forgeStats: ForgeStatsSlice;
|
|
20
|
+
}>;
|
|
21
|
+
getTx(hash: string): Promise<TransactionInfo | null>;
|
|
22
|
+
listTransactions(paging: Paging, filters?: TxFilters): Promise<PagedResult<IndexedTransaction>>;
|
|
23
|
+
getAccountState(address: string): Promise<AccountState | null>;
|
|
24
|
+
getAccountTokens(address: string): Promise<AccountToken[]>;
|
|
25
|
+
listTopAccounts(paging: Paging, filters?: AccountFilters): Promise<PagedResult<IndexedAccountState>>;
|
|
26
|
+
getTokenState(address: string): Promise<TokenState | null>;
|
|
27
|
+
listTokens(paging: Paging, filters?: TokenFilters): Promise<PagedResult<IndexedTokenState>>;
|
|
28
|
+
getAssetState(address: string): Promise<AssetState | null>;
|
|
29
|
+
listAssets(paging: Paging, filters?: AssetFilters): Promise<PagedResult<IndexedAssetState>>;
|
|
30
|
+
getFactoryState(address: string): Promise<AssetFactoryState | null>;
|
|
31
|
+
listFactories(paging: Paging, filters?: FactoryFilters): Promise<PagedResult<IndexedFactoryState>>;
|
|
32
|
+
getStakeState(address: string): Promise<StakeState | null>;
|
|
33
|
+
listStakes(paging: Paging, filters?: StakeFilters): Promise<PagedResult<IndexedStakeState>>;
|
|
34
|
+
getRollupState(address: string): Promise<RollupState | null>;
|
|
35
|
+
listRollups(paging: Paging, filters?: BridgeFilters): Promise<PagedResult<IndexedRollupState>>;
|
|
36
|
+
getRollupBlock(hash: string, rollupAddress: string): Promise<RollupBlock | null>;
|
|
37
|
+
listRollupBlocks(rollupAddress: string, paging: Paging, filters?: RollupBlockFilters): Promise<PagedResult<IndexedRollupBlock>>;
|
|
38
|
+
listRollupValidators(rollupAddress: string, paging: Paging): Promise<PagedResult<IndexedRollupValidator>>;
|
|
39
|
+
getDelegateState(address: string): Promise<DelegateState | null>;
|
|
40
|
+
listDelegations(paging: Paging, filters?: DelegationFilters): Promise<PagedResult<IndexedDelegationState>>;
|
|
41
|
+
search(keyword: string, paging: Paging): Promise<PagedResult<SearchResult>>;
|
|
42
|
+
listTokenFlows(accountAddress: string, paging: Paging, options?: {
|
|
43
|
+
tokenAddress?: string;
|
|
44
|
+
depth?: number;
|
|
45
|
+
direction?: TokenFlowDirection;
|
|
46
|
+
}): Promise<PagedResult<IndexedTokenFlow>>;
|
|
47
|
+
/**
|
|
48
|
+
* Install `@ocap/client/subscribe` on the GraphQL client and forward
|
|
49
|
+
* topic events to the supplied callback. The install is lazy — it
|
|
50
|
+
* waits for the client to be constructed via `getClient()` so we
|
|
51
|
+
* don't pay the import cost on instances that never subscribe.
|
|
52
|
+
*
|
|
53
|
+
* Returns an unsub fn. Failures during install (e.g. the bundled
|
|
54
|
+
* runtime can't resolve `@arcblock/ws`) bubble up so
|
|
55
|
+
* `AFSOCAP.onMount` can fall back to `live: false` without
|
|
56
|
+
* misreporting capability.
|
|
57
|
+
*/
|
|
58
|
+
subscribe(topic: string, callback: (payload: unknown) => void): () => void;
|
|
59
|
+
}
|
|
60
|
+
//#endregion
|
|
61
|
+
export { OcapRemoteSource };
|
|
62
|
+
//# sourceMappingURL=remote-source.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remote-source.d.mts","names":[],"sources":["../src/remote-source.ts"],"mappings":";;;;cA+Fa,gBAAA,YAA4B,cAAA;EAmCJ;;;;;EAAA,QA7B3B,aAAA;EAAA,iBACS,GAAA;cAEL,QAAA;EAAA,QAKJ,SAAA;EAOF,YAAA,CAAA,GAAgB,OAAA,CAAQ,SAAA;EAKxB,SAAA,CAAA,GAAa,OAAA,CAAQ,WAAA;EASrB,iBAAA,CAAA,GAAqB,OAAA,CAAQ,aAAA;EAK7B,aAAA,CAAA,GAAiB,OAAA;IAAU,UAAA,EALC,eAAA;EAAA;EAkB5B,KAAA,CAAM,IAAA,WAAe,OAAA,CAAQ,eAAA;EAK7B,gBAAA,CACJ,MAAA,EAAQ,MAAA,EACR,OAAA,GAAU,SAAA,GACT,OAAA,CAAQ,WAAA,CAAY,kBAAA;EAoBjB,eAAA,CAAgB,OAAA,WAAkB,OAAA,CAAQ,YAAA;EAW1C,gBAAA,CAAiB,OAAA,WAAkB,OAAA,CAAQ,YAAA;EAK3C,eAAA,CACJ,MAAA,EAAQ,MAAA,EACR,OAAA,GAAU,cAAA,GACT,OAAA,CAAQ,WAAA,CAAY,mBAAA;EAUjB,aAAA,CAAc,OAAA,WAAkB,OAAA,CAAQ,UAAA;EAKxC,UAAA,CACJ,MAAA,EAAQ,MAAA,EACR,OAAA,GAAU,YAAA,GACT,OAAA,CAAQ,WAAA,CAAY,iBAAA;EAUjB,aAAA,CAAc,OAAA,WAAkB,OAAA,CAAQ,UAAA;EAWxC,UAAA,CACJ,MAAA,EAAQ,MAAA,EACR,OAAA,GAAU,YAAA,GACT,OAAA,CAAQ,WAAA,CAAY,iB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