@agoric/internal 0.3.3-dev-681b352.0 → 0.3.3-dev-7d1dfc0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/internal",
|
|
3
|
-
"version": "0.3.3-dev-
|
|
3
|
+
"version": "0.3.3-dev-7d1dfc0.0+7d1dfc0",
|
|
4
4
|
"description": "Externally unsupported utilities internal to agoric-sdk",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"lint:types": "tsc"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@agoric/base-zone": "0.1.1-dev-
|
|
23
|
+
"@agoric/base-zone": "0.1.1-dev-7d1dfc0.0+7d1dfc0",
|
|
24
24
|
"@endo/common": "^1.2.5",
|
|
25
25
|
"@endo/errors": "^1.2.5",
|
|
26
26
|
"@endo/far": "^1.1.5",
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"typeCoverage": {
|
|
60
60
|
"atLeast": 93.42
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "7d1dfc0b517194bf93cc015a94eaa4fa6da4636e"
|
|
63
63
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lib-chainStorage.d.ts","sourceRoot":"","sources":["lib-chainStorage.js"],"names":[],"mappings":"AAyPA;;;;;;;;;;;;GAYG;AACH,2DATW,CAAC,OAAO,EAAE,cAAc,KAAK,GAAG,YAGhC,MAAM;;;;IAhEX;;;OAGG;mBADa,OAAO,CAAC,WAAW,CAAC;IASpC;;;;;OAKG;wBAHQ,MAAM,qBACO;QAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,GACtC,WAAW;IAYnB,+CAA+C;oBAA5B,MAAM,GAAK,OAAO,CAA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AAM;iBACN,MAAM;qBACN,MAAM;;;uBAKN,CAAC;;;;iBAED,MAAM;YACN,CAAC,EAAE;;;;;;;;;;;;;;;;cAcH,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC;;;;;aAC/B,MAAM,MAAM;;;;iBAEZ,MAAM,OAAO,CAAC,WAAW,CAAC;mBAC1B,CACT,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,KAC7B,WAAW;;;;;;;aA6CL,MAAM,OAAO,CAAC,MAAM,CAAC;;;;iBAErB,WAAW,CAAC,aAAa,CAAC;;;;;qBAC1B,MAAM,YAAY;;;;;4CAqBnB,KAAK,GACX,aAAa,GACb,KAAK,GACL,UAAU,GACV,SAAS,GACT,QAAQ,GACR,MAAM;;;;gDAGA,KAAK,GAAG,kBAAkB,GAAG,QAAQ;;;;mCAGrC,6BAA6B,GACnC,iCAAiC;;;;0CAG3B,CAAC,IAAI,EAAE,MAAM,CAAC;;;;2BAEd,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;;;;8CAErC,YAAY,EAAE;;;;6BAEd;IACJ,MAAM,EAAE,6BAA6B,CAAC;IACtC,IAAI,EAAE,2BAA2B,CAAC;CACnC,GACD;IACE,MAAM,EAAE,iCAAiC,CAAC;IAC1C,IAAI,EAAE,+BAA+B,CAAC;CACvC;0BA5Ie,WAAW;iCACJ,eAAe"}
|
package/src/lib-chainStorage.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
|
|
3
3
|
import { Fail } from '@endo/errors';
|
|
4
|
-
import { E } from '@endo/far';
|
|
4
|
+
import { E, Far } from '@endo/far';
|
|
5
5
|
import { M } from '@endo/patterns';
|
|
6
6
|
import { makeHeapZone } from '@agoric/base-zone/heap.js';
|
|
7
7
|
import * as cb from './callback.js';
|
|
@@ -278,7 +278,10 @@ export function makeChainStorageRoot(
|
|
|
278
278
|
*/
|
|
279
279
|
const makeNullStorageNode = () => {
|
|
280
280
|
// XXX re-use "ChainStorage" methods above which don't actually depend on chains
|
|
281
|
-
return makeChainStorageRoot(
|
|
281
|
+
return makeChainStorageRoot(
|
|
282
|
+
Far('NullMessenger', () => null),
|
|
283
|
+
'null',
|
|
284
|
+
);
|
|
282
285
|
};
|
|
283
286
|
|
|
284
287
|
/**
|
|
@@ -21,10 +21,13 @@ export function makeFakeStorageKit(rootPath: string, rootOptions?: Parameters<ty
|
|
|
21
21
|
}>;
|
|
22
22
|
data: Map<string, string>;
|
|
23
23
|
messages: StorageMessage[];
|
|
24
|
-
toStorage: (message: StorageMessage) => string | number | any[] | {
|
|
24
|
+
toStorage: ((message: StorageMessage) => string | number | any[] | {
|
|
25
25
|
storeName: string;
|
|
26
26
|
storeSubkey: string;
|
|
27
|
-
} | null | undefined
|
|
27
|
+
} | null | undefined) & import("@endo/pass-style").RemotableObject<`Alleged: ${string}`> & import("@endo/eventual-send").RemotableBrand<{}, (message: StorageMessage) => string | number | any[] | {
|
|
28
|
+
storeName: string;
|
|
29
|
+
storeSubkey: string;
|
|
30
|
+
} | null | undefined>;
|
|
28
31
|
};
|
|
29
32
|
export function makeMockChainStorageRoot(): MockChainStorageRoot;
|
|
30
33
|
export function documentStorageSchema(t: import("ava").ExecutionContext<unknown>, storage: MockChainStorageRoot | FakeStorageKit, opts: ({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage-test-utils.d.ts","sourceRoot":"","sources":["storage-test-utils.js"],"names":[],"mappings":"AAwBO,yCAHI,MAAM,UACN,MAAM,6GAGC;AAElB;;;GAGG;AACH;;;;;EAEG;AA4CH,8CAtBuB,GAAG,KAAK,GAAG,CAsB+B;AAU1D,6CAHI,MAAM,gBACN,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC,CAAC,CAAC;;;;;
|
|
1
|
+
{"version":3,"file":"storage-test-utils.d.ts","sourceRoot":"","sources":["storage-test-utils.js"],"names":[],"mappings":"AAwBO,yCAHI,MAAM,UACN,MAAM,6GAGC;AAElB;;;GAGG;AACH;;;;;EAEG;AA4CH,8CAtBuB,GAAG,KAAK,GAAG,CAsB+B;AAU1D,6CAHI,MAAM,gBACN,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC,CAAC,CAAC;;;;;oBA2GjD,CAAA;;;;UAEiB,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;;0BAjFxB,cAAc;;;0JAAd,cAAc;;;;EAqF7B;AAoBM,4CADO,oBAAoB,CA6BjC;AAQM,yCALI,OAAO,KAAK,EAAE,gBAAgB,CAAC,OAAO,CAAC,WACvC,oBAAoB,GAAG,cAAc,QACrC,CAAC;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,GAC9D,CAAK;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,GAAG,EAAE,CAAC,iBAkCnD;6BAtFa,UAAU,CAAC,OAAO,kBAAkB,CAAC;;;;;;;;aAIrC,CACT,IAAI,EAAE,MAAM,EACZ,UAAU,CAAC,EAAE,UAAU,EACvB,KAAK,CAAC,EAAE,MAAM,KACX,OAAO;UAKD,MAAM,MAAM,EAAE;;mCAEd,WAAW,GAAG,2BAA2B;qCAjNJ,uBAAuB;iCAMF,uBAAuB;oCAAvB,uBAAuB;gCAAvB,uBAAuB"}
|
|
@@ -108,82 +108,86 @@ export const makeFakeStorageKit = (rootPath, rootOptions) => {
|
|
|
108
108
|
};
|
|
109
109
|
/** @type {StorageMessage[]} */
|
|
110
110
|
const messages = [];
|
|
111
|
-
/** @param {StorageMessage} message */
|
|
112
111
|
|
|
113
|
-
const toStorage =
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
return data.has(key) ? data.get(key) : null;
|
|
123
|
-
}
|
|
124
|
-
case 'children': {
|
|
125
|
-
const [key] = message.args;
|
|
126
|
-
const childEntries = getChildEntries(`${key}.`);
|
|
127
|
-
return [...childEntries.keys()];
|
|
128
|
-
}
|
|
129
|
-
case 'entries': {
|
|
130
|
-
const [key] = message.args;
|
|
131
|
-
const childEntries = getChildEntries(`${key}.`);
|
|
132
|
-
return [...childEntries.entries()].map(entry =>
|
|
133
|
-
entry[1] != null ? entry : [entry[0]],
|
|
134
|
-
);
|
|
135
|
-
}
|
|
136
|
-
case 'set':
|
|
137
|
-
case 'setWithoutNotify': {
|
|
138
|
-
trace('toStorage set', message);
|
|
139
|
-
/** @type {StorageEntry[]} */
|
|
140
|
-
const newEntries = message.args;
|
|
141
|
-
for (const [key, value] of newEntries) {
|
|
142
|
-
if (value != null) {
|
|
143
|
-
data.set(key, value);
|
|
144
|
-
} else {
|
|
145
|
-
data.delete(key);
|
|
146
|
-
}
|
|
112
|
+
const toStorage = Far(
|
|
113
|
+
'ToStorage',
|
|
114
|
+
/** @param {StorageMessage} message */
|
|
115
|
+
message => {
|
|
116
|
+
messages.push(message);
|
|
117
|
+
switch (message.method) {
|
|
118
|
+
case 'getStoreKey': {
|
|
119
|
+
const [key] = message.args;
|
|
120
|
+
return { storeName: 'swingset', storeSubkey: `fake:${key}` };
|
|
147
121
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
122
|
+
case 'get': {
|
|
123
|
+
const [key] = message.args;
|
|
124
|
+
return data.has(key) ? data.get(key) : null;
|
|
125
|
+
}
|
|
126
|
+
case 'children': {
|
|
127
|
+
const [key] = message.args;
|
|
128
|
+
const childEntries = getChildEntries(`${key}.`);
|
|
129
|
+
return [...childEntries.keys()];
|
|
130
|
+
}
|
|
131
|
+
case 'entries': {
|
|
132
|
+
const [key] = message.args;
|
|
133
|
+
const childEntries = getChildEntries(`${key}.`);
|
|
134
|
+
return [...childEntries.entries()].map(entry =>
|
|
135
|
+
entry[1] != null ? entry : [entry[0]],
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
case 'set':
|
|
139
|
+
case 'setWithoutNotify': {
|
|
140
|
+
trace('toStorage set', message);
|
|
141
|
+
/** @type {StorageEntry[]} */
|
|
142
|
+
const newEntries = message.args;
|
|
143
|
+
for (const [key, value] of newEntries) {
|
|
144
|
+
if (value != null) {
|
|
145
|
+
data.set(key, value);
|
|
146
|
+
} else {
|
|
147
|
+
data.delete(key);
|
|
165
148
|
}
|
|
166
149
|
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
150
|
+
break;
|
|
151
|
+
}
|
|
152
|
+
case 'append': {
|
|
153
|
+
trace('toStorage append', message);
|
|
154
|
+
/** @type {StorageEntry[]} */
|
|
155
|
+
const newEntries = message.args;
|
|
156
|
+
for (const [key, value] of newEntries) {
|
|
157
|
+
value != null || Fail`attempt to append with no value`;
|
|
158
|
+
// In the absence of block boundaries, everything goes in a single StreamCell.
|
|
159
|
+
const oldVal = data.get(key);
|
|
160
|
+
let streamCell;
|
|
161
|
+
if (oldVal != null) {
|
|
162
|
+
try {
|
|
163
|
+
streamCell = JSON.parse(oldVal);
|
|
164
|
+
assert(isStreamCell(streamCell));
|
|
165
|
+
} catch (_err) {
|
|
166
|
+
streamCell = undefined;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
if (streamCell === undefined) {
|
|
170
|
+
streamCell = {
|
|
171
|
+
blockHeight: '0',
|
|
172
|
+
values: oldVal != null ? [oldVal] : [],
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
streamCell.values.push(value);
|
|
176
|
+
data.set(key, JSON.stringify(streamCell));
|
|
172
177
|
}
|
|
173
|
-
|
|
174
|
-
data.set(key, JSON.stringify(streamCell));
|
|
178
|
+
break;
|
|
175
179
|
}
|
|
176
|
-
|
|
180
|
+
case 'size':
|
|
181
|
+
// Intentionally incorrect because it counts non-child descendants,
|
|
182
|
+
// but nevertheless supports a "has children" test.
|
|
183
|
+
return [...data.keys()].filter(k =>
|
|
184
|
+
k.startsWith(`${message.args[0]}.`),
|
|
185
|
+
).length;
|
|
186
|
+
default:
|
|
187
|
+
throw Error(`unsupported method: ${message.method}`);
|
|
177
188
|
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
// but nevertheless supports a "has children" test.
|
|
181
|
-
return [...data.keys()].filter(k => k.startsWith(`${message.args[0]}.`))
|
|
182
|
-
.length;
|
|
183
|
-
default:
|
|
184
|
-
throw Error(`unsupported method: ${message.method}`);
|
|
185
|
-
}
|
|
186
|
-
};
|
|
189
|
+
},
|
|
190
|
+
);
|
|
187
191
|
const rootNode = makeChainStorageRoot(toStorage, rootPath, resolvedOptions);
|
|
188
192
|
return {
|
|
189
193
|
rootNode,
|