@ownables/adapter-viem 0.8.1 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapter-viem/src/index.d.ts.map +1 -0
- package/dist/adapter-viem/src/index.js.map +1 -0
- package/dist/{services → adapter-viem/src/services}/EQTY.service.d.ts +9 -8
- package/dist/adapter-viem/src/services/EQTY.service.d.ts.map +1 -0
- package/dist/adapter-viem/src/services/EQTY.service.js +515 -0
- package/dist/adapter-viem/src/services/EQTY.service.js.map +1 -0
- package/dist/{services → adapter-viem/src/services}/MockEQTY.service.d.ts +5 -3
- package/dist/adapter-viem/src/services/MockEQTY.service.d.ts.map +1 -0
- package/dist/{services → adapter-viem/src/services}/MockEQTY.service.js +14 -10
- package/dist/adapter-viem/src/services/MockEQTY.service.js.map +1 -0
- package/dist/{types → adapter-viem/src/types}/EQTY.d.ts +9 -0
- package/dist/adapter-viem/src/types/EQTY.d.ts.map +1 -0
- package/dist/{types → adapter-viem/src/types}/EQTY.js.map +1 -1
- package/dist/core/src/index.d.ts +24 -0
- package/dist/core/src/index.d.ts.map +1 -0
- package/dist/core/src/index.js +23 -0
- package/dist/core/src/index.js.map +1 -0
- package/dist/core/src/interfaces/core.d.ts +59 -0
- package/dist/core/src/interfaces/core.d.ts.map +1 -0
- package/dist/core/src/interfaces/core.js +2 -0
- package/dist/core/src/interfaces/core.js.map +1 -0
- package/dist/core/src/logger.d.ts +3 -0
- package/dist/core/src/logger.d.ts.map +1 -0
- package/dist/core/src/logger.js +2 -0
- package/dist/core/src/logger.js.map +1 -0
- package/dist/core/src/services/AnchorValidation.service.d.ts +10 -0
- package/dist/core/src/services/AnchorValidation.service.d.ts.map +1 -0
- package/dist/core/src/services/AnchorValidation.service.js +115 -0
- package/dist/core/src/services/AnchorValidation.service.js.map +1 -0
- package/dist/core/src/services/EventChain.service.d.ts +46 -0
- package/dist/core/src/services/EventChain.service.d.ts.map +1 -0
- package/dist/core/src/services/EventChain.service.js +118 -0
- package/dist/core/src/services/EventChain.service.js.map +1 -0
- package/dist/core/src/services/Ownable.service.d.ts +97 -0
- package/dist/core/src/services/Ownable.service.d.ts.map +1 -0
- package/dist/core/src/services/Ownable.service.js +688 -0
- package/dist/core/src/services/Ownable.service.js.map +1 -0
- package/dist/core/src/services/Polling.service.d.ts +31 -0
- package/dist/core/src/services/Polling.service.d.ts.map +1 -0
- package/dist/core/src/services/Polling.service.js +109 -0
- package/dist/core/src/services/Polling.service.js.map +1 -0
- package/dist/core/src/services/Progress.service.d.ts +7 -0
- package/dist/core/src/services/Progress.service.d.ts.map +1 -0
- package/dist/core/src/services/Progress.service.js +12 -0
- package/dist/core/src/services/Progress.service.js.map +1 -0
- package/dist/core/src/services/ReplayAuthority.service.d.ts +23 -0
- package/dist/core/src/services/ReplayAuthority.service.d.ts.map +1 -0
- package/dist/core/src/services/ReplayAuthority.service.js +191 -0
- package/dist/core/src/services/ReplayAuthority.service.js.map +1 -0
- package/dist/core/src/services/SIWE.service.d.ts +16 -0
- package/dist/core/src/services/SIWE.service.d.ts.map +1 -0
- package/dist/core/src/services/SIWE.service.js +122 -0
- package/dist/core/src/services/SIWE.service.js.map +1 -0
- package/dist/core/src/services/StateStoreRecordStore.service.d.ts +13 -0
- package/dist/core/src/services/StateStoreRecordStore.service.d.ts.map +1 -0
- package/dist/core/src/services/StateStoreRecordStore.service.js +76 -0
- package/dist/core/src/services/StateStoreRecordStore.service.js.map +1 -0
- package/dist/core/src/services/WorkerRPC.service.d.ts +45 -0
- package/dist/core/src/services/WorkerRPC.service.d.ts.map +1 -0
- package/dist/core/src/services/WorkerRPC.service.js +292 -0
- package/dist/core/src/services/WorkerRPC.service.js.map +1 -0
- package/dist/core/src/types/AnchorValidation.d.ts +55 -0
- package/dist/core/src/types/AnchorValidation.d.ts.map +1 -0
- package/dist/core/src/types/AnchorValidation.js +2 -0
- package/dist/core/src/types/AnchorValidation.js.map +1 -0
- package/dist/core/src/types/Authority.d.ts +40 -0
- package/dist/core/src/types/Authority.d.ts.map +1 -0
- package/dist/core/src/types/Authority.js +2 -0
- package/dist/core/src/types/Authority.js.map +1 -0
- package/dist/core/src/types/EventChainStore.d.ts +12 -0
- package/dist/core/src/types/EventChainStore.d.ts.map +1 -0
- package/dist/core/src/types/EventChainStore.js +2 -0
- package/dist/core/src/types/EventChainStore.js.map +1 -0
- package/dist/core/src/types/MessageInfo.d.ts +19 -0
- package/dist/core/src/types/MessageInfo.d.ts.map +1 -0
- package/dist/core/src/types/MessageInfo.js +2 -0
- package/dist/core/src/types/MessageInfo.js.map +1 -0
- package/dist/core/src/types/OwnableRuntime.d.ts +79 -0
- package/dist/core/src/types/OwnableRuntime.d.ts.map +1 -0
- package/dist/core/src/types/OwnableRuntime.js +2 -0
- package/dist/core/src/types/OwnableRuntime.js.map +1 -0
- package/dist/core/src/types/Polling.d.ts +14 -0
- package/dist/core/src/types/Polling.d.ts.map +1 -0
- package/dist/core/src/types/Polling.js +2 -0
- package/dist/core/src/types/Polling.js.map +1 -0
- package/dist/core/src/types/Replay.d.ts +100 -0
- package/dist/core/src/types/Replay.d.ts.map +1 -0
- package/dist/core/src/types/Replay.js +2 -0
- package/dist/core/src/types/Replay.js.map +1 -0
- package/dist/core/src/types/SIWE.d.ts +30 -0
- package/dist/core/src/types/SIWE.d.ts.map +1 -0
- package/dist/core/src/types/SIWE.js +2 -0
- package/dist/core/src/types/SIWE.js.map +1 -0
- package/dist/core/src/types/TypedCosmWasmMsg.d.ts +12 -0
- package/dist/core/src/types/TypedCosmWasmMsg.d.ts.map +1 -0
- package/dist/core/src/types/TypedCosmWasmMsg.js +2 -0
- package/dist/core/src/types/TypedCosmWasmMsg.js.map +1 -0
- package/dist/core/src/types/TypedDict.d.ts +4 -0
- package/dist/core/src/types/TypedDict.d.ts.map +1 -0
- package/dist/core/src/types/TypedDict.js +2 -0
- package/dist/core/src/types/TypedDict.js.map +1 -0
- package/dist/core/src/types/TypedOwnableInfo.d.ts +34 -0
- package/dist/core/src/types/TypedOwnableInfo.d.ts.map +1 -0
- package/dist/core/src/types/TypedOwnableInfo.js +2 -0
- package/dist/core/src/types/TypedOwnableInfo.js.map +1 -0
- package/dist/core/src/types/TypedPackage.d.ts +39 -0
- package/dist/core/src/types/TypedPackage.d.ts.map +1 -0
- package/dist/core/src/types/TypedPackage.js +2 -0
- package/dist/core/src/types/TypedPackage.js.map +1 -0
- package/package.json +7 -5
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/services/EQTY.service.d.ts.map +0 -1
- package/dist/services/EQTY.service.js +0 -359
- package/dist/services/EQTY.service.js.map +0 -1
- package/dist/services/MockEQTY.service.d.ts.map +0 -1
- package/dist/services/MockEQTY.service.js.map +0 -1
- package/dist/types/EQTY.d.ts.map +0 -1
- /package/dist/{index.d.ts → adapter-viem/src/index.d.ts} +0 -0
- /package/dist/{index.js → adapter-viem/src/index.js} +0 -0
- /package/dist/{types → adapter-viem/src/types}/EQTY.js +0 -0
|
@@ -0,0 +1,688 @@
|
|
|
1
|
+
import { EventChain, Event, Binary } from 'eqty-core';
|
|
2
|
+
import { encode } from 'cbor-x';
|
|
3
|
+
import { ProgressService } from './Progress.service.js';
|
|
4
|
+
export default class OwnableService {
|
|
5
|
+
SNAPSHOT_INTERVAL = 50;
|
|
6
|
+
PUBLIC_EVENT_REPLAY_STORE_SUFFIX = '.public-event-replays';
|
|
7
|
+
stateStore;
|
|
8
|
+
eventChains;
|
|
9
|
+
eqty;
|
|
10
|
+
packages;
|
|
11
|
+
runtimeSource;
|
|
12
|
+
runtimeRpc;
|
|
13
|
+
replay;
|
|
14
|
+
logger;
|
|
15
|
+
constructor(deps) {
|
|
16
|
+
this.stateStore = deps.stateStore;
|
|
17
|
+
this.eventChains = deps.eventChains;
|
|
18
|
+
this.eqty = deps.anchorProvider;
|
|
19
|
+
this.packages = deps.packages;
|
|
20
|
+
this.runtimeSource = deps.runtimeSource;
|
|
21
|
+
this.runtimeRpc = deps.runtimeRpc;
|
|
22
|
+
this.replay = deps.replay;
|
|
23
|
+
this.logger = deps.logger ?? console;
|
|
24
|
+
}
|
|
25
|
+
_rpc = new Map();
|
|
26
|
+
get anchoring() {
|
|
27
|
+
return this.eventChains.anchoring;
|
|
28
|
+
}
|
|
29
|
+
async loadAll() {
|
|
30
|
+
return this.eventChains.loadAll();
|
|
31
|
+
}
|
|
32
|
+
isReady(id) {
|
|
33
|
+
return this._rpc.has(id);
|
|
34
|
+
}
|
|
35
|
+
rpc(id) {
|
|
36
|
+
const rpc = this._rpc.get(id);
|
|
37
|
+
if (!rpc)
|
|
38
|
+
throw new Error(`No RPC for ownable ${id}`);
|
|
39
|
+
return rpc;
|
|
40
|
+
}
|
|
41
|
+
clearRpc(id) {
|
|
42
|
+
const rpc = this._rpc.get(id);
|
|
43
|
+
if (!rpc)
|
|
44
|
+
return;
|
|
45
|
+
rpc.terminate();
|
|
46
|
+
this._rpc.delete(id);
|
|
47
|
+
}
|
|
48
|
+
setWidgetWindow(id, win) {
|
|
49
|
+
const rpc = this._rpc.get(id);
|
|
50
|
+
if (rpc)
|
|
51
|
+
rpc.setWidgetWindow(win);
|
|
52
|
+
}
|
|
53
|
+
async initWorker(id, cid) {
|
|
54
|
+
if (this._rpc.has(id))
|
|
55
|
+
return;
|
|
56
|
+
const js = this.runtimeSource.getWorkerSource();
|
|
57
|
+
const wasm = (await this.packages.getAsset(cid, 'ownable_bg.wasm', (fr, file) => fr.readAsArrayBuffer(file)));
|
|
58
|
+
const rpc = this.runtimeRpc.create(id);
|
|
59
|
+
await rpc.initialize(js, new Uint8Array(wasm));
|
|
60
|
+
this._rpc.set(id, rpc);
|
|
61
|
+
}
|
|
62
|
+
async create(pkg, onProgress) {
|
|
63
|
+
const progress = new ProgressService(onProgress);
|
|
64
|
+
const address = this.eqty.address;
|
|
65
|
+
const networkId = this.eqty.chainId;
|
|
66
|
+
const chain = EventChain.create(address, networkId);
|
|
67
|
+
const anchors = [];
|
|
68
|
+
if (pkg.isDynamic || this.anchoring) {
|
|
69
|
+
const msg = {
|
|
70
|
+
'@context': 'instantiate_msg.json',
|
|
71
|
+
ownable_id: chain.id,
|
|
72
|
+
package: pkg.cid,
|
|
73
|
+
network_id: networkId,
|
|
74
|
+
keywords: pkg.keywords ?? [],
|
|
75
|
+
...(pkg.title ? { name: pkg.title } : {}),
|
|
76
|
+
...(pkg.description ? { description: pkg.description } : {}),
|
|
77
|
+
};
|
|
78
|
+
await progress.step('signEvent', () => this.eqty.sign(new Event(msg).addTo(chain)));
|
|
79
|
+
}
|
|
80
|
+
if (this.anchoring) {
|
|
81
|
+
const hash = chain.latestHash.hex;
|
|
82
|
+
anchors.push(...chain.startingWith(Binary.fromHex(hash)).anchorMap);
|
|
83
|
+
}
|
|
84
|
+
if (anchors.length > 0) {
|
|
85
|
+
// Queue anchors and submit as single tx
|
|
86
|
+
await this.eqty.anchor(...anchors);
|
|
87
|
+
const txHash = await progress.step('anchorEvent', () => this.eqty.submitAnchors());
|
|
88
|
+
return txHash ? { chain, txHash } : { chain };
|
|
89
|
+
}
|
|
90
|
+
return { chain };
|
|
91
|
+
}
|
|
92
|
+
async init(chain, cid, uniqueMessageHash) {
|
|
93
|
+
if (!this._rpc.has(chain.id)) {
|
|
94
|
+
await this.initWorker(chain.id, cid);
|
|
95
|
+
}
|
|
96
|
+
const stateDump = await this.apply(chain, []);
|
|
97
|
+
await this.initStore(chain, cid, uniqueMessageHash, stateDump);
|
|
98
|
+
}
|
|
99
|
+
async createSnapshot(chain, stateDump, eventIndex) {
|
|
100
|
+
const chainId = chain.id;
|
|
101
|
+
const storeId = `ownable:${chainId}`;
|
|
102
|
+
const snapshotStoreId = `${storeId}.snapshots`;
|
|
103
|
+
try {
|
|
104
|
+
const snapshot = {
|
|
105
|
+
eventIndex,
|
|
106
|
+
blockHash: chain.latestHash.hex,
|
|
107
|
+
stateDump,
|
|
108
|
+
timestamp: new Date(),
|
|
109
|
+
};
|
|
110
|
+
if (!(await this.stateStore.hasStore(snapshotStoreId))) {
|
|
111
|
+
await this.stateStore.createStore(snapshotStoreId);
|
|
112
|
+
}
|
|
113
|
+
await this.stateStore.set(snapshotStoreId, `snapshot_${eventIndex}`, snapshot);
|
|
114
|
+
// Cleanup old snapshots (keep only last 3)
|
|
115
|
+
const keys = await this.stateStore.keys(snapshotStoreId);
|
|
116
|
+
if (keys.length > 3) {
|
|
117
|
+
const sortedKeys = keys
|
|
118
|
+
.map((key) => parseInt(key.replace('snapshot_', '')))
|
|
119
|
+
.sort((a, b) => b - a);
|
|
120
|
+
// Delete oldest snapshots, keep the 3 most recent
|
|
121
|
+
const keysToDelete = sortedKeys.slice(3).map((index) => `snapshot_${index}`);
|
|
122
|
+
for (const key of keysToDelete) {
|
|
123
|
+
await this.stateStore.delete(snapshotStoreId, key);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
catch (error) {
|
|
128
|
+
this.logger.error('Error creating snapshot:', error);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
async getLatestSnapshot(chainId) {
|
|
132
|
+
const storeId = `ownable:${chainId}`;
|
|
133
|
+
const snapshotStoreId = `${storeId}.snapshots`;
|
|
134
|
+
const exist = await this.stateStore.hasStore(snapshotStoreId);
|
|
135
|
+
if (!exist) {
|
|
136
|
+
return null;
|
|
137
|
+
}
|
|
138
|
+
const snapshots = await this.stateStore.keys(snapshotStoreId);
|
|
139
|
+
if (snapshots.length === 0)
|
|
140
|
+
return null;
|
|
141
|
+
const latestKey = snapshots
|
|
142
|
+
.map((key) => parseInt(key.replace('snapshot_', '')))
|
|
143
|
+
.sort((a, b) => b - a)[0];
|
|
144
|
+
return await this.stateStore.get(snapshotStoreId, `snapshot_${latestKey}`);
|
|
145
|
+
}
|
|
146
|
+
async listSnapshots(chainId) {
|
|
147
|
+
const storeId = `ownable:${chainId}`;
|
|
148
|
+
const snapshotStoreId = `${storeId}.snapshots`;
|
|
149
|
+
if (!(await this.stateStore.hasStore(snapshotStoreId))) {
|
|
150
|
+
return [];
|
|
151
|
+
}
|
|
152
|
+
const snapshots = await this.stateStore.keys(snapshotStoreId);
|
|
153
|
+
const sortedKeys = snapshots
|
|
154
|
+
.map((key) => parseInt(key.replace('snapshot_', '')))
|
|
155
|
+
.sort((a, b) => a - b);
|
|
156
|
+
return Promise.all(sortedKeys.map((index) => this.stateStore.get(snapshotStoreId, `snapshot_${index}`)));
|
|
157
|
+
}
|
|
158
|
+
async deleteSnapshots(chainId) {
|
|
159
|
+
const storeId = `ownable:${chainId}`;
|
|
160
|
+
const snapshotStoreId = `${storeId}.snapshots`;
|
|
161
|
+
if (await this.stateStore.hasStore(snapshotStoreId)) {
|
|
162
|
+
await this.stateStore.deleteStore(snapshotStoreId);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
publicEventReplayStoreId(chainId) {
|
|
166
|
+
return `ownable:${chainId}${this.PUBLIC_EVENT_REPLAY_STORE_SUFFIX}`;
|
|
167
|
+
}
|
|
168
|
+
replayRecord(event, status, sources) {
|
|
169
|
+
return {
|
|
170
|
+
replayKey: this.replay.key(event),
|
|
171
|
+
event,
|
|
172
|
+
status,
|
|
173
|
+
sources: [...new Set(sources)],
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
mergeReplayRecordSources(current, next) {
|
|
177
|
+
return current.includes(next) ? current : [...current, next];
|
|
178
|
+
}
|
|
179
|
+
async ensureReplayStore(chainId) {
|
|
180
|
+
const replayStoreId = this.publicEventReplayStoreId(chainId);
|
|
181
|
+
if (!(await this.stateStore.hasStore(replayStoreId))) {
|
|
182
|
+
await this.stateStore.createStore(replayStoreId);
|
|
183
|
+
}
|
|
184
|
+
return replayStoreId;
|
|
185
|
+
}
|
|
186
|
+
async listReplayRecords(chainId) {
|
|
187
|
+
const replayStoreId = this.publicEventReplayStoreId(chainId);
|
|
188
|
+
if (!(await this.stateStore.hasStore(replayStoreId))) {
|
|
189
|
+
return [];
|
|
190
|
+
}
|
|
191
|
+
const records = (await this.stateStore.getAll(replayStoreId));
|
|
192
|
+
return [...records].sort((left, right) => {
|
|
193
|
+
if (left.event.blockNumber !== right.event.blockNumber) {
|
|
194
|
+
return left.event.blockNumber - right.event.blockNumber;
|
|
195
|
+
}
|
|
196
|
+
if (left.event.transactionIndex !== right.event.transactionIndex) {
|
|
197
|
+
return left.event.transactionIndex - right.event.transactionIndex;
|
|
198
|
+
}
|
|
199
|
+
return left.event.logIndex - right.event.logIndex;
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
async listTrackedPublicEvents(chainId) {
|
|
203
|
+
return this.listReplayRecords(chainId);
|
|
204
|
+
}
|
|
205
|
+
emptyReplayAttemptResult(stateDump) {
|
|
206
|
+
return {
|
|
207
|
+
complete: true,
|
|
208
|
+
stateDump,
|
|
209
|
+
appliedEvents: [],
|
|
210
|
+
appliedReplayKeys: [],
|
|
211
|
+
duplicateReplayKeys: [],
|
|
212
|
+
appliedPublicEvents: [],
|
|
213
|
+
duplicatePublicEvents: [],
|
|
214
|
+
ignoredPublicEvents: [],
|
|
215
|
+
pendingPublicEvents: [],
|
|
216
|
+
confirmedPendingPublicEvents: [],
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
publicEventSubjectId(chain) {
|
|
220
|
+
return Binary.fromHex(chain.id).hash().hex;
|
|
221
|
+
}
|
|
222
|
+
provisionalPublicEventReplayKey(chain, eventType, data) {
|
|
223
|
+
return `pending:${this.publicEventSubjectId(chain)}:${eventType}:${new Binary(data).hash().hex}`;
|
|
224
|
+
}
|
|
225
|
+
provisionalPublicEventRecord(chain, eventType, data) {
|
|
226
|
+
const replayKey = this.provisionalPublicEventReplayKey(chain, eventType, data);
|
|
227
|
+
const payloadHex = new Binary(data).hex;
|
|
228
|
+
return {
|
|
229
|
+
replayKey,
|
|
230
|
+
event: {
|
|
231
|
+
source: this.eqty.address,
|
|
232
|
+
eventType,
|
|
233
|
+
data: payloadHex,
|
|
234
|
+
blockNumber: 0,
|
|
235
|
+
transactionHash: payloadHex,
|
|
236
|
+
transactionIndex: 0,
|
|
237
|
+
logIndex: 0,
|
|
238
|
+
},
|
|
239
|
+
status: 'pending',
|
|
240
|
+
sources: ['local'],
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
toRegisterRuntimeEvent(event) {
|
|
244
|
+
const { subjectId: _subjectId, timestamp: _timestamp, ...publicEvent } = event;
|
|
245
|
+
return {
|
|
246
|
+
...publicEvent,
|
|
247
|
+
data: typeof publicEvent.data === 'string' ? publicEvent.data : new Binary(event.data).hex,
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
publicEventSubjectMatches(chain, event) {
|
|
251
|
+
return event.subjectId.toLowerCase() === this.publicEventSubjectId(chain).toLowerCase();
|
|
252
|
+
}
|
|
253
|
+
toRegisterRpcPayload(event) {
|
|
254
|
+
return {
|
|
255
|
+
...event,
|
|
256
|
+
data: Binary.fromHex(event.data),
|
|
257
|
+
transactionHash: Binary.fromHex(event.transactionHash),
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
async applyEvent(rpc, event, stateDump, chain, eventIndex) {
|
|
261
|
+
const info = {
|
|
262
|
+
sender: event.signerAddress || this.eqty.address,
|
|
263
|
+
funds: [],
|
|
264
|
+
};
|
|
265
|
+
const { '@context': context, ...msg } = event.parsedData;
|
|
266
|
+
let result;
|
|
267
|
+
switch (context) {
|
|
268
|
+
case 'instantiate_msg.json':
|
|
269
|
+
result = await rpc.instantiate(msg, info);
|
|
270
|
+
break;
|
|
271
|
+
case 'execute_msg.json':
|
|
272
|
+
result = await rpc.execute(msg, info, stateDump);
|
|
273
|
+
break;
|
|
274
|
+
case 'register_msg.json':
|
|
275
|
+
result = await rpc.register(this.toRegisterRpcPayload(msg), info, stateDump);
|
|
276
|
+
break;
|
|
277
|
+
case 'ingest_msg.json':
|
|
278
|
+
result = await rpc.ingest(msg, info, stateDump);
|
|
279
|
+
break;
|
|
280
|
+
default:
|
|
281
|
+
throw new Error(`Unknown event type`);
|
|
282
|
+
}
|
|
283
|
+
if ((eventIndex + 1) % this.SNAPSHOT_INTERVAL === 0) {
|
|
284
|
+
await this.createSnapshot(chain, result.state, eventIndex);
|
|
285
|
+
}
|
|
286
|
+
return result;
|
|
287
|
+
}
|
|
288
|
+
async apply(partialChain, stateDump) {
|
|
289
|
+
const rpc = this.rpc(partialChain.id);
|
|
290
|
+
const snapshot = await this.getLatestSnapshot(partialChain.id);
|
|
291
|
+
let startIndex = 0;
|
|
292
|
+
if (snapshot) {
|
|
293
|
+
const snapshotEventIndex = partialChain.events.findIndex((e) => e.hash?.hex === snapshot.blockHash);
|
|
294
|
+
if (snapshotEventIndex !== -1) {
|
|
295
|
+
stateDump = snapshot.stateDump;
|
|
296
|
+
startIndex = snapshotEventIndex + 1;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
const BATCH_SIZE = 10;
|
|
300
|
+
const totalEvents = partialChain.events.length;
|
|
301
|
+
for (let batchStart = startIndex; batchStart < totalEvents; batchStart += BATCH_SIZE) {
|
|
302
|
+
const batchEnd = Math.min(batchStart + BATCH_SIZE, totalEvents);
|
|
303
|
+
const batch = partialChain.events.slice(batchStart, batchEnd);
|
|
304
|
+
for (let i = 0; i < batch.length; i++) {
|
|
305
|
+
const globalIndex = batchStart + i;
|
|
306
|
+
const event = batch[i];
|
|
307
|
+
if (!event)
|
|
308
|
+
continue;
|
|
309
|
+
try {
|
|
310
|
+
const result = await this.applyEvent(rpc, event, stateDump, partialChain, globalIndex);
|
|
311
|
+
stateDump = result.state;
|
|
312
|
+
}
|
|
313
|
+
catch (error) {
|
|
314
|
+
this.logger.error(`Error applying event at index ${globalIndex}:`, error);
|
|
315
|
+
if (globalIndex > startIndex) {
|
|
316
|
+
await this.createSnapshot(partialChain, stateDump, globalIndex - 1);
|
|
317
|
+
}
|
|
318
|
+
throw error;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
if (batchEnd < totalEvents) {
|
|
322
|
+
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
return stateDump;
|
|
326
|
+
}
|
|
327
|
+
async replayIndexedPublicEvents(chainId, stateDump, indexedPublicEvents, options) {
|
|
328
|
+
return this.attemptReplayIndexedPublicEvents(chainId, stateDump, indexedPublicEvents, options);
|
|
329
|
+
}
|
|
330
|
+
async attemptReplayIndexedPublicEvents(chainId, stateDump, indexedPublicEvents, options) {
|
|
331
|
+
const info = {
|
|
332
|
+
sender: this.eqty.address,
|
|
333
|
+
funds: [],
|
|
334
|
+
};
|
|
335
|
+
const deduped = this.replay.dedupe(indexedPublicEvents);
|
|
336
|
+
const selected = options
|
|
337
|
+
? this.replay.selectReplayable(indexedPublicEvents, options)
|
|
338
|
+
: { events: deduped.events, ignoredPublicEvents: [] };
|
|
339
|
+
const events = selected.events;
|
|
340
|
+
const duplicateReplayKeys = deduped.duplicateReplayKeys;
|
|
341
|
+
const appliedEvents = [];
|
|
342
|
+
const appliedReplayKeys = [];
|
|
343
|
+
const appliedPublicEvents = [];
|
|
344
|
+
const duplicatePublicEvents = deduped.duplicateEvents.map((event) => ({
|
|
345
|
+
replayKey: this.replay.key(event),
|
|
346
|
+
event,
|
|
347
|
+
}));
|
|
348
|
+
const ignoredPublicEvents = [...selected.ignoredPublicEvents];
|
|
349
|
+
let nextState = stateDump;
|
|
350
|
+
for (const indexedEvent of events) {
|
|
351
|
+
const runtimeEvent = this.toRegisterRuntimeEvent(indexedEvent);
|
|
352
|
+
const replayKey = this.replay.key(indexedEvent);
|
|
353
|
+
try {
|
|
354
|
+
const { state } = await this.rpc(chainId).register(this.toRegisterRpcPayload(runtimeEvent), info, nextState);
|
|
355
|
+
nextState = state;
|
|
356
|
+
appliedEvents.push(indexedEvent);
|
|
357
|
+
appliedReplayKeys.push(replayKey);
|
|
358
|
+
appliedPublicEvents.push({
|
|
359
|
+
replayKey,
|
|
360
|
+
event: indexedEvent,
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
catch (cause) {
|
|
364
|
+
ignoredPublicEvents.push({
|
|
365
|
+
replayKey,
|
|
366
|
+
event: indexedEvent,
|
|
367
|
+
reason: 'register_failed',
|
|
368
|
+
cause,
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
return {
|
|
373
|
+
complete: ignoredPublicEvents.length === 0,
|
|
374
|
+
stateDump: nextState,
|
|
375
|
+
appliedEvents,
|
|
376
|
+
appliedReplayKeys,
|
|
377
|
+
duplicateReplayKeys,
|
|
378
|
+
appliedPublicEvents,
|
|
379
|
+
duplicatePublicEvents,
|
|
380
|
+
ignoredPublicEvents,
|
|
381
|
+
pendingPublicEvents: [],
|
|
382
|
+
confirmedPendingPublicEvents: [],
|
|
383
|
+
};
|
|
384
|
+
}
|
|
385
|
+
async applyIndexedPublicEventSnapshot(chain, indexedPublicEvents, onProgress) {
|
|
386
|
+
return this.reconcileIndexedPublicEvents(chain, indexedPublicEvents, 'snapshot', onProgress);
|
|
387
|
+
}
|
|
388
|
+
async applyIndexedPublicEventStream(chain, indexedPublicEvents, onProgress) {
|
|
389
|
+
return this.reconcileIndexedPublicEvents(chain, indexedPublicEvents, 'stream', onProgress);
|
|
390
|
+
}
|
|
391
|
+
async reconcileIndexedPublicEvents(chain, indexedPublicEvents, source, onProgress) {
|
|
392
|
+
const progress = new ProgressService(onProgress);
|
|
393
|
+
const stateDump = await this.eventChains.getStateDump(chain.id, chain.state.hex);
|
|
394
|
+
if (!stateDump)
|
|
395
|
+
throw Error('State mismatch for register public event');
|
|
396
|
+
const replayStoreId = await this.ensureReplayStore(chain.id);
|
|
397
|
+
const base = this.emptyReplayAttemptResult(stateDump);
|
|
398
|
+
const deduped = this.replay.dedupe(indexedPublicEvents);
|
|
399
|
+
const info = {
|
|
400
|
+
sender: this.eqty.address,
|
|
401
|
+
funds: [],
|
|
402
|
+
};
|
|
403
|
+
base.duplicateReplayKeys.push(...deduped.duplicateReplayKeys);
|
|
404
|
+
base.duplicatePublicEvents.push(...deduped.duplicateEvents.map((event) => this.replayRecord(event, 'confirmed', [source])));
|
|
405
|
+
let nextState = stateDump;
|
|
406
|
+
for (const indexedEvent of deduped.events) {
|
|
407
|
+
const replayKey = this.replay.key(indexedEvent);
|
|
408
|
+
const existing = (await this.stateStore
|
|
409
|
+
.get(replayStoreId, replayKey)
|
|
410
|
+
.catch(() => undefined));
|
|
411
|
+
if (existing?.status === 'confirmed') {
|
|
412
|
+
const updated = this.replayRecord(existing.event, 'confirmed', this.mergeReplayRecordSources(existing.sources, source));
|
|
413
|
+
await this.stateStore.set(replayStoreId, replayKey, updated);
|
|
414
|
+
base.duplicateReplayKeys.push(replayKey);
|
|
415
|
+
base.duplicatePublicEvents.push(updated);
|
|
416
|
+
continue;
|
|
417
|
+
}
|
|
418
|
+
const runtimeEvent = this.toRegisterRuntimeEvent(indexedEvent);
|
|
419
|
+
try {
|
|
420
|
+
const { state } = await this.rpc(chain.id).register(this.toRegisterRpcPayload(runtimeEvent), info, nextState);
|
|
421
|
+
nextState = state;
|
|
422
|
+
await progress.step('signPublicEvent', () => this.eqty.sign(new Event({
|
|
423
|
+
'@context': 'register_msg.json',
|
|
424
|
+
...runtimeEvent,
|
|
425
|
+
}).addTo(chain)));
|
|
426
|
+
await this.store(chain, nextState);
|
|
427
|
+
const confirmedRecord = this.replayRecord(indexedEvent, 'confirmed', existing?.status === 'pending'
|
|
428
|
+
? this.mergeReplayRecordSources(existing.sources, source)
|
|
429
|
+
: [source]);
|
|
430
|
+
await this.stateStore.set(replayStoreId, replayKey, confirmedRecord);
|
|
431
|
+
base.appliedEvents.push(indexedEvent);
|
|
432
|
+
base.appliedReplayKeys.push(replayKey);
|
|
433
|
+
base.appliedPublicEvents.push({ replayKey, event: indexedEvent });
|
|
434
|
+
if (existing?.status === 'pending') {
|
|
435
|
+
base.confirmedPendingPublicEvents.push(confirmedRecord);
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
catch (cause) {
|
|
439
|
+
base.ignoredPublicEvents.push({
|
|
440
|
+
replayKey,
|
|
441
|
+
event: indexedEvent,
|
|
442
|
+
reason: 'register_failed',
|
|
443
|
+
cause,
|
|
444
|
+
});
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
return {
|
|
448
|
+
...base,
|
|
449
|
+
complete: base.ignoredPublicEvents.length === 0,
|
|
450
|
+
stateDump: nextState,
|
|
451
|
+
};
|
|
452
|
+
}
|
|
453
|
+
async execute(chain, msg, stateDump, onProgress, attachments = []) {
|
|
454
|
+
const progress = new ProgressService(onProgress);
|
|
455
|
+
const info = { sender: this.eqty.address, funds: [] };
|
|
456
|
+
const { state: newStateDump } = await this.rpc(chain.id).execute(msg, info, stateDump);
|
|
457
|
+
delete msg['@context']; // Shouldn't be set
|
|
458
|
+
const event = new Event({ '@context': 'execute_msg.json', ...msg }).addTo(chain);
|
|
459
|
+
for (const attachment of attachments) {
|
|
460
|
+
event.addAttachment(attachment.name, new Uint8Array(await attachment.file.arrayBuffer()), attachment.file.type || 'application/octet-stream');
|
|
461
|
+
}
|
|
462
|
+
await progress.step('signEvent', () => this.eqty.sign(event));
|
|
463
|
+
// Store without submitting anchors yet; submission is controlled by caller
|
|
464
|
+
await this.store(chain, newStateDump);
|
|
465
|
+
return newStateDump;
|
|
466
|
+
}
|
|
467
|
+
async registerPublicEvent(chain, event, onProgress) {
|
|
468
|
+
const publicEvent = this.toRegisterRuntimeEvent(event);
|
|
469
|
+
return this.applyIndexedPublicEventStream(chain, [publicEvent], onProgress);
|
|
470
|
+
}
|
|
471
|
+
async emitPublicEvent(chain, eventType, payload, onProgress) {
|
|
472
|
+
const progress = new ProgressService(onProgress);
|
|
473
|
+
const stateDump = await this.eventChains.getStateDump(chain.id, chain.state.hex);
|
|
474
|
+
if (!stateDump)
|
|
475
|
+
throw Error('State mismatch for emit public event');
|
|
476
|
+
const encodedPayload = await progress.step('encodePublicEvent', () => this.rpc(chain.id).encodePublicEvent(eventType, encode(payload)));
|
|
477
|
+
const subjectId = this.publicEventSubjectId(chain);
|
|
478
|
+
const replayStoreId = await this.ensureReplayStore(chain.id);
|
|
479
|
+
const provisionalPendingRecord = this.provisionalPublicEventRecord(chain, eventType, encodedPayload);
|
|
480
|
+
await this.stateStore.set(replayStoreId, provisionalPendingRecord.replayKey, provisionalPendingRecord);
|
|
481
|
+
let publicEvent;
|
|
482
|
+
try {
|
|
483
|
+
publicEvent = await progress.step('emitPublicEvent', () => this.eqty.emitPublicEvent(subjectId, eventType, encodedPayload));
|
|
484
|
+
}
|
|
485
|
+
catch (cause) {
|
|
486
|
+
await this.stateStore.delete(replayStoreId, provisionalPendingRecord.replayKey);
|
|
487
|
+
throw cause;
|
|
488
|
+
}
|
|
489
|
+
if (!this.publicEventSubjectMatches(chain, publicEvent)) {
|
|
490
|
+
await this.stateStore.delete(replayStoreId, provisionalPendingRecord.replayKey);
|
|
491
|
+
const result = this.emptyReplayAttemptResult(stateDump);
|
|
492
|
+
result.complete = false;
|
|
493
|
+
result.ignoredPublicEvents.push({
|
|
494
|
+
replayKey: this.replay.key(this.toRegisterRuntimeEvent(publicEvent)),
|
|
495
|
+
event: this.toRegisterRuntimeEvent(publicEvent),
|
|
496
|
+
reason: 'invalid_subject_id',
|
|
497
|
+
cause: {
|
|
498
|
+
expectedSubjectId: subjectId,
|
|
499
|
+
receivedSubjectId: publicEvent.subjectId,
|
|
500
|
+
},
|
|
501
|
+
});
|
|
502
|
+
return result;
|
|
503
|
+
}
|
|
504
|
+
const runtimeEvent = this.toRegisterRuntimeEvent(publicEvent);
|
|
505
|
+
const pendingRecord = this.replayRecord(runtimeEvent, 'pending', ['local']);
|
|
506
|
+
await this.stateStore.delete(replayStoreId, provisionalPendingRecord.replayKey);
|
|
507
|
+
await this.stateStore.set(replayStoreId, pendingRecord.replayKey, pendingRecord);
|
|
508
|
+
const result = this.emptyReplayAttemptResult(stateDump);
|
|
509
|
+
result.pendingPublicEvents.push(pendingRecord);
|
|
510
|
+
return result;
|
|
511
|
+
}
|
|
512
|
+
async submitAnchors(onProgress) {
|
|
513
|
+
if (!this.anchoring)
|
|
514
|
+
return undefined;
|
|
515
|
+
return await new ProgressService(onProgress).step('anchor', () => this.eqty.submitAnchors());
|
|
516
|
+
}
|
|
517
|
+
async canConsume(consumer, info) {
|
|
518
|
+
if (!this.packages.info(consumer.package).isConsumer)
|
|
519
|
+
return false;
|
|
520
|
+
try {
|
|
521
|
+
const state = await this.eventChains.getStateDump(consumer.chain.id, consumer.chain.state.hex);
|
|
522
|
+
if (!state)
|
|
523
|
+
return false;
|
|
524
|
+
const result = await this.rpc(consumer.chain.id).query({
|
|
525
|
+
is_consumer_of: {
|
|
526
|
+
consumable_type: info.ownable_type,
|
|
527
|
+
issuer: info.issuer,
|
|
528
|
+
},
|
|
529
|
+
}, state);
|
|
530
|
+
return result === true;
|
|
531
|
+
}
|
|
532
|
+
catch (error) {
|
|
533
|
+
this.logger.warn('Error checking canConsume:', error);
|
|
534
|
+
return false;
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
async consume(consumer, consumable, onProgress) {
|
|
538
|
+
const progress = new ProgressService(onProgress);
|
|
539
|
+
const info = {
|
|
540
|
+
sender: this.eqty.address,
|
|
541
|
+
funds: [],
|
|
542
|
+
};
|
|
543
|
+
const consumeMessage = { consume: {} };
|
|
544
|
+
const consumerState = await this.eventChains.getStateDump(consumer.id, consumer.state.hex);
|
|
545
|
+
const consumableState = await this.eventChains.getStateDump(consumable.id, consumable.state.hex);
|
|
546
|
+
if (!consumerState || !consumableState)
|
|
547
|
+
throw Error('State mismatch for consume');
|
|
548
|
+
const { events, state: consumableStateDump } = await this.rpc(consumable.id).execute(consumeMessage, info, consumableState);
|
|
549
|
+
const consumeEvent = events.find((event) => event.type === 'consume');
|
|
550
|
+
if (!consumeEvent)
|
|
551
|
+
throw Error('No consume event emitted');
|
|
552
|
+
const consumableInfo = (await this.rpc(consumable.id).query({ get_info: {} }, consumableStateDump));
|
|
553
|
+
const ingestEvent = {
|
|
554
|
+
source: {
|
|
555
|
+
id: consumable.id,
|
|
556
|
+
owner: consumableInfo.owner,
|
|
557
|
+
issuer: consumableInfo.issuer,
|
|
558
|
+
},
|
|
559
|
+
attributes: consumeEvent.attributes,
|
|
560
|
+
eventType: consumeEvent.type,
|
|
561
|
+
};
|
|
562
|
+
const { state: consumerStateDump } = await this.rpc(consumer.id).ingest(ingestEvent, info, consumerState);
|
|
563
|
+
await progress.step('signConsumableEvent', () => this.eqty.sign(new Event({ '@context': 'execute_msg.json', ...consumeMessage }).addTo(consumable)));
|
|
564
|
+
await progress.step('signConsumerEvent', () => this.eqty.sign(new Event({
|
|
565
|
+
'@context': 'ingest_msg.json',
|
|
566
|
+
...ingestEvent,
|
|
567
|
+
}).addTo(consumer)));
|
|
568
|
+
// Store both chains; emit anchor progress only once to represent anchoring both
|
|
569
|
+
// Queue anchors for both chains without submitting yet
|
|
570
|
+
await this.store(consumable, consumableStateDump);
|
|
571
|
+
await this.stateStore.set(`ownable:${consumable.id}`, 'isConsumed', true);
|
|
572
|
+
await this.store(consumer, consumerStateDump);
|
|
573
|
+
// Submit a single anchor tx for both
|
|
574
|
+
await this.submitAnchors(onProgress);
|
|
575
|
+
}
|
|
576
|
+
async retryOperation(operation, maxRetries = 3, delay = 1000) {
|
|
577
|
+
for (let attempt = 1; attempt <= maxRetries; attempt++) {
|
|
578
|
+
try {
|
|
579
|
+
return await operation();
|
|
580
|
+
}
|
|
581
|
+
catch (error) {
|
|
582
|
+
this.logger.warn(`Attempt ${attempt} failed:`, error);
|
|
583
|
+
if (attempt < maxRetries) {
|
|
584
|
+
await new Promise((resolve) => setTimeout(resolve, delay * attempt));
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
throw new Error(`Operation failed after ${maxRetries} attempts. Last error: `);
|
|
589
|
+
}
|
|
590
|
+
async initStore(chain, pkg, uniqueMessageHash, stateDump) {
|
|
591
|
+
const storeId = `ownable:${chain.id}`;
|
|
592
|
+
const stateStoreId = `${storeId}.state`;
|
|
593
|
+
const chainData = {
|
|
594
|
+
chain: chain.toJSON(),
|
|
595
|
+
state: chain.state.hex,
|
|
596
|
+
package: pkg,
|
|
597
|
+
isConsumed: false,
|
|
598
|
+
created: new Date(),
|
|
599
|
+
latestHash: chain.latestHash.hex,
|
|
600
|
+
keywords: this.packages.info(pkg).keywords,
|
|
601
|
+
uniqueMessageHash: this.packages.info(pkg, uniqueMessageHash).uniqueMessageHash,
|
|
602
|
+
};
|
|
603
|
+
const stores = [storeId];
|
|
604
|
+
if (stateDump)
|
|
605
|
+
stores.push(stateStoreId);
|
|
606
|
+
await this.retryOperation(async () => {
|
|
607
|
+
const hasStore = await this.stateStore.hasStore(storeId);
|
|
608
|
+
if (hasStore) {
|
|
609
|
+
return;
|
|
610
|
+
}
|
|
611
|
+
await this.stateStore.createStore(...stores);
|
|
612
|
+
const data = {
|
|
613
|
+
[storeId]: chainData,
|
|
614
|
+
};
|
|
615
|
+
if (stateDump) {
|
|
616
|
+
data[stateStoreId] = new Map(stateDump);
|
|
617
|
+
}
|
|
618
|
+
try {
|
|
619
|
+
await this.stateStore.setAll(data);
|
|
620
|
+
}
|
|
621
|
+
catch (error) {
|
|
622
|
+
// If setAll fails, attempt to clean up
|
|
623
|
+
this.logger.error('Failed to set data, cleaning up stores...');
|
|
624
|
+
await Promise.all(stores.map((store) => this.stateStore.deleteStore(store).catch(() => { })));
|
|
625
|
+
throw error;
|
|
626
|
+
}
|
|
627
|
+
const verifyData = await Promise.all([
|
|
628
|
+
this.stateStore.get(storeId, 'state'),
|
|
629
|
+
stateDump ? this.stateStore.getAll(stateStoreId) : Promise.resolve(null),
|
|
630
|
+
]);
|
|
631
|
+
if (verifyData[0] !== chainData.state || (stateDump && !verifyData[1]?.length)) {
|
|
632
|
+
throw new Error('Data verification failed after write');
|
|
633
|
+
}
|
|
634
|
+
});
|
|
635
|
+
}
|
|
636
|
+
async store(chain, stateDump) {
|
|
637
|
+
const anchors = [];
|
|
638
|
+
const storeId = `ownable:${chain.id}`;
|
|
639
|
+
const stateStoreId = `${storeId}.state`;
|
|
640
|
+
await this.retryOperation(async () => {
|
|
641
|
+
const storedState = await this.stateStore.get(storeId, 'state');
|
|
642
|
+
if (storedState === chain.state)
|
|
643
|
+
return;
|
|
644
|
+
const data = {
|
|
645
|
+
[storeId]: {
|
|
646
|
+
chain: chain.toJSON(),
|
|
647
|
+
state: chain.state.hex,
|
|
648
|
+
latestHash: chain.latestHash.hex,
|
|
649
|
+
},
|
|
650
|
+
[stateStoreId]: new Map(stateDump),
|
|
651
|
+
};
|
|
652
|
+
if (this.anchoring) {
|
|
653
|
+
const previousHash = await this.stateStore.get(`ownable:${chain.id}`, 'latestHash');
|
|
654
|
+
anchors.push(...chain.startingAfter(Binary.fromHex(previousHash)).anchorMap);
|
|
655
|
+
}
|
|
656
|
+
if (anchors.length > 0) {
|
|
657
|
+
// Queue anchors only; submission handled separately to allow batching
|
|
658
|
+
await this.eqty.anchor(...anchors);
|
|
659
|
+
}
|
|
660
|
+
await this.stateStore.setAll(data);
|
|
661
|
+
const eventCount = chain.events.length;
|
|
662
|
+
if (eventCount % this.SNAPSHOT_INTERVAL === 0) {
|
|
663
|
+
await this.createSnapshot(chain, stateDump, eventCount - 1);
|
|
664
|
+
}
|
|
665
|
+
// Verify write
|
|
666
|
+
const verifyState = await this.stateStore.get(storeId, 'state');
|
|
667
|
+
if (verifyState !== chain.state.hex) {
|
|
668
|
+
throw new Error('State verification failed after write');
|
|
669
|
+
}
|
|
670
|
+
});
|
|
671
|
+
}
|
|
672
|
+
async delete(id) {
|
|
673
|
+
await this.eventChains.delete(id);
|
|
674
|
+
}
|
|
675
|
+
async deleteAll() {
|
|
676
|
+
await this.eventChains.deleteAll();
|
|
677
|
+
}
|
|
678
|
+
async zip(chain) {
|
|
679
|
+
const firstEvent = chain.events[0];
|
|
680
|
+
if (!firstEvent)
|
|
681
|
+
throw new Error('Cannot zip an empty ownable chain');
|
|
682
|
+
const packageCid = firstEvent.parsedData.package;
|
|
683
|
+
const zip = await this.packages.zip(packageCid);
|
|
684
|
+
zip.file('chain.json', JSON.stringify(chain.toJSON()));
|
|
685
|
+
return zip;
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
//# sourceMappingURL=Ownable.service.js.map
|