Skip to content

Commit acaba32

Browse files
committed
fixup! remove some * imports
1 parent dd18b3b commit acaba32

File tree

3 files changed

+67
-67
lines changed

3 files changed

+67
-67
lines changed

packages/internal/src/lib-chainStorage.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Fail } from '@endo/errors';
44
import { E, Far } from '@endo/far';
55
import { M } from '@endo/patterns';
66
import { makeHeapZone } from '@agoric/base-zone/heap.js';
7-
import * as cb from './callback.js';
7+
import { callE, makeFunctionCallback } from './callback.js';
88

99
/**
1010
* @import {ERef} from '@endo/far';
@@ -188,7 +188,7 @@ export const prepareChainStorageNode = zone => {
188188
*/
189189
async getStoreKey() {
190190
const { path, messenger } = this.state;
191-
return cb.callE(messenger, {
191+
return callE(messenger, {
192192
method: 'getStoreKey',
193193
args: [path],
194194
});
@@ -220,7 +220,7 @@ export const prepareChainStorageNode = zone => {
220220
} else {
221221
entry = [path, value];
222222
}
223-
await cb.callE(messenger, {
223+
await callE(messenger, {
224224
method: sequence ? 'append' : 'set',
225225
args: [entry],
226226
});
@@ -257,7 +257,7 @@ export function makeChainStorageRoot(
257257
rootPath,
258258
rootOptions = {},
259259
) {
260-
const messenger = cb.makeFunctionCallback(handleStorageMessage);
260+
const messenger = makeFunctionCallback(handleStorageMessage);
261261

262262
// Use the heapZone directly.
263263
const rootNode = makeHeapChainStorageNode(messenger, rootPath, rootOptions);

packages/internal/test/callback.test.js

Lines changed: 61 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,16 @@ import test from 'ava';
33

44
import { Far } from '@endo/far';
55
import { makeHeapZone } from '@agoric/base-zone/heap.js';
6-
import * as cb from '../src/callback.js';
6+
import {
7+
makeSyncFunctionCallback,
8+
makeSyncMethodCallback,
9+
callSync,
10+
makeMethodCallback,
11+
callE,
12+
makeFunctionCallback,
13+
isCallback,
14+
prepareAttenuator,
15+
} from '../src/callback.js';
716
import {
817
passableSymbolForName,
918
unpassableSymbolForName,
@@ -21,36 +30,36 @@ test('near function callbacks', t => {
2130
const f = (a, b, c) => `${a + b}${c}`;
2231

2332
/** @type {SyncCallback<typeof f>} */
24-
const cb0 = cb.makeSyncFunctionCallback(f);
33+
const cb0 = makeSyncFunctionCallback(f);
2534
t.deepEqual(cb0, { target: f, bound: [], isSync: true });
2635

2736
/** @type {SyncCallback<(b: number, c: string) => string>} */
28-
const cb1 = cb.makeSyncFunctionCallback(f, 9);
37+
const cb1 = makeSyncFunctionCallback(f, 9);
2938
t.deepEqual(cb1, { target: f, bound: [9], isSync: true });
3039

3140
/** @type {SyncCallback<(c: string) => string>} */
32-
const cb2 = cb.makeSyncFunctionCallback(f, 9, 10);
41+
const cb2 = makeSyncFunctionCallback(f, 9, 10);
3342
t.deepEqual(cb2, { target: f, bound: [9, 10], isSync: true });
3443

3544
// @ts-expect-error deliberate: boolean is not assignable to string
36-
const cb3 = cb.makeSyncFunctionCallback(f, 9, 10, true);
45+
const cb3 = makeSyncFunctionCallback(f, 9, 10, true);
3746
t.deepEqual(cb3, { target: f, bound: [9, 10, true], isSync: true });
3847

3948
// @ts-expect-error deliberate: Expected 4 arguments but got 5
40-
t.is(cb.callSync(cb0, 2, 3, 'go', 'bad'), '5go');
49+
t.is(callSync(cb0, 2, 3, 'go', 'bad'), '5go');
4150

4251
// @ts-expect-error deliberate: number is not assignable to string
43-
t.is(cb.callSync(cb0, 2, 3, 2), '52');
52+
t.is(callSync(cb0, 2, 3, 2), '52');
4453

45-
t.is(cb.callSync(cb1, 10, 'go'), '19go');
46-
t.is(cb.callSync(cb2, 'go'), '19go');
54+
t.is(callSync(cb1, 10, 'go'), '19go');
55+
t.is(callSync(cb2, 'go'), '19go');
4756

4857
const cbp2 = /** @type {SyncCallback<(...args: unknown[]) => any>} */ ({
4958
target: Promise.resolve(f),
5059
methodName: undefined,
5160
bound: [9, 10],
5261
});
53-
t.throws(() => cb.callSync(cbp2, 'go'), { message: /not a function/ });
62+
t.throws(() => callSync(cbp2, 'go'), { message: /not a function/ });
5463
});
5564

5665
test('near method callbacks', t => {
@@ -78,15 +87,15 @@ test('near method callbacks', t => {
7887
};
7988

8089
/** @type {SyncCallback<typeof o.m1>} */
81-
const cb0 = cb.makeSyncMethodCallback(o, 'm1');
90+
const cb0 = makeSyncMethodCallback(o, 'm1');
8291
t.deepEqual(cb0, { target: o, methodName: 'm1', bound: [], isSync: true });
8392

8493
/** @type {SyncCallback<(b: number, c: string) => string>} */
85-
const cb1 = cb.makeSyncMethodCallback(o, 'm1', 9);
94+
const cb1 = makeSyncMethodCallback(o, 'm1', 9);
8695
t.deepEqual(cb1, { target: o, methodName: 'm1', bound: [9], isSync: true });
8796

8897
/** @type {SyncCallback<(c: string) => string>} */
89-
const cb2 = cb.makeSyncMethodCallback(o, 'm1', 9, 10);
98+
const cb2 = makeSyncMethodCallback(o, 'm1', 9, 10);
9099
t.deepEqual(cb2, {
91100
target: o,
92101
methodName: 'm1',
@@ -95,7 +104,7 @@ test('near method callbacks', t => {
95104
});
96105

97106
// @ts-expect-error deliberate: boolean is not assignable to string
98-
const cb3 = cb.makeSyncMethodCallback(o, 'm1', 9, 10, true);
107+
const cb3 = makeSyncMethodCallback(o, 'm1', 9, 10, true);
99108
t.deepEqual(cb3, {
100109
target: o,
101110
methodName: 'm1',
@@ -104,24 +113,24 @@ test('near method callbacks', t => {
104113
});
105114

106115
/** @type {SyncCallback<(c: string) => string>} */
107-
const cb4 = cb.makeSyncMethodCallback(o, m2, 9, 10);
116+
const cb4 = makeSyncMethodCallback(o, m2, 9, 10);
108117
t.deepEqual(cb4, { target: o, methodName: m2, bound: [9, 10], isSync: true });
109118

110119
// @ts-expect-error deliberate: Expected 4 arguments but got 5
111-
t.is(cb.callSync(cb0, 2, 3, 'go', 'bad'), '5go');
120+
t.is(callSync(cb0, 2, 3, 'go', 'bad'), '5go');
112121

113122
// @ts-expect-error deliberate: number is not assignable to string
114-
t.is(cb.callSync(cb0, 2, 3, 2), '52');
123+
t.is(callSync(cb0, 2, 3, 2), '52');
115124

116-
t.is(cb.callSync(cb1, 10, 'go'), '19go');
117-
t.is(cb.callSync(cb2, 'go'), '19go');
118-
t.is(cb.callSync(cb4, 'go'), '19go');
125+
t.is(callSync(cb1, 10, 'go'), '19go');
126+
t.is(callSync(cb2, 'go'), '19go');
127+
t.is(callSync(cb4, 'go'), '19go');
119128

120129
// @ts-expect-error deliberate: Promise provides no match for the signature
121-
const cbp2 = cb.makeSyncMethodCallback(Promise.resolve(o), 'm1', 9, 10);
130+
const cbp2 = makeSyncMethodCallback(Promise.resolve(o), 'm1', 9, 10);
122131
t.like(cbp2, { methodName: 'm1', bound: [9, 10], isSync: true });
123132
t.assert(cbp2.target instanceof Promise);
124-
t.throws(() => cb.callSync(cbp2, 'go'), { message: /not a function/ });
133+
t.throws(() => callSync(cbp2, 'go'), { message: /not a function/ });
125134
});
126135

127136
test('far method callbacks', async t => {
@@ -148,23 +157,23 @@ test('far method callbacks', async t => {
148157
});
149158

150159
/** @type {Callback<(c: string) => Promise<string>>} */
151-
const cbp2 = cb.makeMethodCallback(Promise.resolve(o), 'm1', 9, 10);
160+
const cbp2 = makeMethodCallback(Promise.resolve(o), 'm1', 9, 10);
152161
t.like(cbp2, { methodName: 'm1', bound: [9, 10] });
153162
t.assert(cbp2.target instanceof Promise);
154-
const p2r = cb.callE(cbp2, 'go');
163+
const p2r = callE(cbp2, 'go');
155164
t.assert(p2r instanceof Promise);
156165
t.is(await p2r, '19go');
157166

158167
/** @type {Callback<(c: string) => Promise<string>>} */
159-
const cbp3 = cb.makeMethodCallback(Promise.resolve(o), 'm2', 9, 10);
168+
const cbp3 = makeMethodCallback(Promise.resolve(o), 'm2', 9, 10);
160169
t.like(cbp3, { methodName: 'm2', bound: [9, 10] });
161170
t.assert(cbp3.target instanceof Promise);
162-
const p3r = cb.callE(cbp3, 'go');
171+
const p3r = callE(cbp3, 'go');
163172
t.assert(p3r instanceof Promise);
164173
t.is(await p3r, '19go');
165174

166175
// @ts-expect-error deliberate: is not assignable to SyncCallback
167-
const thunk = () => cb.callSync(cbp2, 'go');
176+
const thunk = () => callSync(cbp2, 'go');
168177
t.throws(thunk, { message: /not a function/ });
169178
});
170179

@@ -178,105 +187,96 @@ test('far function callbacks', async t => {
178187
const f = async (a, b, c) => `${a + b}${c}`;
179188

180189
/** @type {Callback<(c: string) => Promise<string>>} */
181-
const cbp2 = cb.makeFunctionCallback(Promise.resolve(f), 9, 10);
190+
const cbp2 = makeFunctionCallback(Promise.resolve(f), 9, 10);
182191
t.like(cbp2, { bound: [9, 10] });
183192
t.assert(cbp2.target instanceof Promise);
184193
// @ts-expect-error deliberate: is not assignable to SyncCallback
185-
const thunk = () => cb.callSync(cbp2, 'go');
194+
const thunk = () => callSync(cbp2, 'go');
186195
t.throws(thunk, { message: /not a function/ });
187-
const p2r = cb.callE(cbp2, 'go');
196+
const p2r = callE(cbp2, 'go');
188197
t.assert(p2r instanceof Promise);
189198
t.is(await p2r, '19go');
190199
});
191200

192201
test('bad callbacks', t => {
193202
t.throws(
194203
// @ts-expect-error deliberate: number is not assignable to function
195-
() => cb.makeFunctionCallback(42),
204+
() => makeFunctionCallback(42),
196205
undefined,
197206
'number as function presence',
198207
);
199208
t.throws(
200-
() => cb.makeMethodCallback('string', 'slice'),
209+
() => makeMethodCallback('string', 'slice'),
201210
undefined,
202211
'string as presence',
203212
);
204213
t.throws(
205214
// @ts-expect-error deliberate: object is not assignable to function
206-
() => cb.makeSyncFunctionCallback({}),
215+
() => makeSyncFunctionCallback({}),
207216
undefined,
208217
'plain object as function',
209218
);
210219
t.throws(
211-
() => cb.makeSyncMethodCallback(false, 'valueOf'),
220+
() => makeSyncMethodCallback(false, 'valueOf'),
212221
undefined,
213222
'boolean as object',
214223
);
215224
});
216225

217226
test('isCallback', t => {
218227
t.true(
219-
cb.isCallback(cb.makeFunctionCallback(async () => {})),
228+
isCallback(makeFunctionCallback(async () => {})),
220229
'makeFunctionCallback',
221230
);
222231
const sym = Symbol.asyncIterator;
223232
t.true(
224-
cb.isCallback(cb.makeMethodCallback({ [sym]: async () => {} }, sym)),
233+
isCallback(makeMethodCallback({ [sym]: async () => {} }, sym)),
225234
'makeMethodCallback',
226235
);
227236
t.true(
228-
cb.isCallback(cb.makeSyncFunctionCallback(() => {})),
237+
isCallback(makeSyncFunctionCallback(() => {})),
229238
'makeSyncFunctionCallback',
230239
);
231240
t.true(
232-
cb.isCallback(cb.makeSyncMethodCallback({ m: () => {} }, 'm')),
241+
isCallback(makeSyncMethodCallback({ m: () => {} }, 'm')),
233242
'makeSyncMethodCallback',
234243
);
235244
// manually-implemented original-format callback objects must always work
236-
t.true(cb.isCallback({ target: () => {}, bound: [] }), 'manual function');
245+
t.true(isCallback({ target: () => {}, bound: [] }), 'manual function');
237246
t.true(
238-
cb.isCallback({ target: {}, methodName: 'foo', bound: [] }),
247+
isCallback({ target: {}, methodName: 'foo', bound: [] }),
239248
'manual method',
240249
);
241250
t.true(
242-
cb.isCallback({
251+
isCallback({
243252
target: {},
244253
methodName: passableSymbolForName('foo'),
245254
bound: [],
246255
}),
247256
'manual symbol-keyed method',
248257
);
249258

250-
t.false(cb.isCallback(undefined), 'undefined');
251-
t.false(cb.isCallback(null), 'null');
252-
t.false(cb.isCallback('string'), 'string');
253-
t.false(cb.isCallback({}), 'empty object');
254-
t.false(
255-
cb.isCallback({ target: 'non-object', bound: [] }),
256-
'non-object target',
257-
);
259+
t.false(isCallback(undefined), 'undefined');
260+
t.false(isCallback(null), 'null');
261+
t.false(isCallback('string'), 'string');
262+
t.false(isCallback({}), 'empty object');
263+
t.false(isCallback({ target: 'non-object', bound: [] }), 'non-object target');
258264
t.false(
259-
cb.isCallback({
265+
isCallback({
260266
target: {},
261267
methodName: unpassableSymbolForName('foo'),
262268
bound: [],
263269
}),
264270
'unique symbol method name',
265271
);
266-
t.false(cb.isCallback({ target: {}, bound: {} }), 'non-array bound args');
267-
t.false(
268-
cb.isCallback({ target: {}, bound: undefined }),
269-
'undefined bound args',
270-
);
271-
t.false(
272-
cb.isCallback({ target: {}, methodName: 'foo' }),
273-
'missing bound args',
274-
);
272+
t.false(isCallback({ target: {}, bound: {} }), 'non-array bound args');
273+
t.false(isCallback({ target: {}, bound: undefined }), 'undefined bound args');
274+
t.false(isCallback({ target: {}, methodName: 'foo' }), 'missing bound args');
275275
});
276276

277277
test('makeAttenuator', async t => {
278278
const zone = makeHeapZone();
279-
const makeAttenuator = cb.prepareAttenuator(zone, ['m0', 'm1', 'm2', 'm4']);
279+
const makeAttenuator = prepareAttenuator(zone, ['m0', 'm1', 'm2', 'm4']);
280280
const target = Far('original', {
281281
m0() {
282282
return 'return original.m0';
@@ -314,7 +314,7 @@ test('makeAttenuator', async t => {
314314
isSync: true,
315315
overrides: {
316316
m1: null,
317-
m2: cb.makeMethodCallback(
317+
m2: makeMethodCallback(
318318
Far('Abc', {
319319
abc() {
320320
return 'return abc';

packages/vats/src/vat-bridge.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Fail } from '@endo/errors';
22
import { Far } from '@endo/far';
33
import { makeDurableZone } from '@agoric/zone/durable.js';
4-
import * as cb from '@agoric/internal/src/callback.js';
4+
import { makeMethodCallback } from '@agoric/internal/src/callback.js';
55
import { prepareChainStorageNode } from '@agoric/internal/src/lib-chainStorage.js';
66
import { prepareBridgeManager } from './bridge.js';
77

@@ -34,7 +34,7 @@ export function buildRootObject(vatPowers, _args, baggage) {
3434

3535
const storageBridgeManager = await storageBridgeManagerP;
3636
const rootNode = makeChainStorageNode(
37-
cb.makeMethodCallback(storageBridgeManager, 'toBridge'),
37+
makeMethodCallback(storageBridgeManager, 'toBridge'),
3838
rootPath,
3939
options,
4040
);

0 commit comments

Comments
 (0)