@agoric/wallet-backend 0.13.5 → 0.13.6-dev-d32a66a.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/bundles/bundle-wallet-js-meta.json +582 -0
- package/bundles/bundle-wallet.js +1 -1
- package/deploy.js +2 -2
- package/jsconfig.json +1 -15
- package/package.json +22 -22
- package/scripts/build-bundles.js +1 -1
- package/src/findOrMakeInvitation.js +10 -13
- package/src/internal-types.js +6 -4
- package/src/issuerTable.js +5 -5
- package/src/lib-dehydrate.js +24 -31
- package/src/lib-wallet.js +85 -210
- package/src/types.js +2 -2
- package/src/wallet.js +4 -8
- package/test/test-getPursesNotifier.js +15 -16
- package/test/test-lib-dehydrate.js +10 -10
- package/test/test-lib-wallet.js +38 -247
- package/test/test-middleware.js +7 -15
- package/bundles/bundle-wallet-meta.js +0 -490
- package/src/marshal-contexts.js +0 -387
- package/test/attestationExample.js +0 -65
- package/test/test-wallet-marshal.js +0 -184
|
@@ -2,30 +2,29 @@
|
|
|
2
2
|
import { test } from '@agoric/zoe/tools/prepare-test-env-ava.js';
|
|
3
3
|
|
|
4
4
|
import { makeIssuerKit } from '@agoric/ertp';
|
|
5
|
-
import {
|
|
6
|
-
import fakeVatAdmin from '@agoric/zoe/tools/fakeVatAdmin.js';
|
|
5
|
+
import { makeZoeForTest } from '@agoric/zoe/tools/setup-zoe.js';
|
|
7
6
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
8
|
-
import {
|
|
7
|
+
import { makeFakeBoard } from '@agoric/vats/tools/board-utils.js';
|
|
9
8
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
9
|
+
import { heapZone } from '@agoric/zone';
|
|
10
|
+
import {
|
|
11
|
+
makeNameHubKit,
|
|
12
|
+
prepareMixinMyAddress,
|
|
13
|
+
} from '@agoric/vats/src/nameHub.js';
|
|
12
14
|
import { makeWalletRoot } from '../src/lib-wallet.js';
|
|
13
15
|
|
|
14
16
|
import '../src/types.js';
|
|
15
17
|
|
|
18
|
+
const mixinMyAddress = prepareMixinMyAddress(heapZone);
|
|
19
|
+
|
|
16
20
|
function makeFakeMyAddressNameAdmin() {
|
|
17
|
-
const { nameAdmin
|
|
18
|
-
return
|
|
19
|
-
...rawMyAddressNameAdmin,
|
|
20
|
-
getMyAddress() {
|
|
21
|
-
return 'agoric1test1';
|
|
22
|
-
},
|
|
23
|
-
});
|
|
21
|
+
const { nameAdmin } = makeNameHubKit();
|
|
22
|
+
return mixinMyAddress(nameAdmin, 'agoric1test1');
|
|
24
23
|
}
|
|
25
24
|
|
|
26
25
|
const setup = async () => {
|
|
27
|
-
const
|
|
28
|
-
const board =
|
|
26
|
+
const zoe = makeZoeForTest();
|
|
27
|
+
const board = makeFakeBoard();
|
|
29
28
|
|
|
30
29
|
const pursesStateChangeHandler = _data => {};
|
|
31
30
|
const inboxStateChangeHandler = _data => {};
|
|
@@ -66,7 +65,7 @@ test('getPursesNotifier', async t => {
|
|
|
66
65
|
value: 0n,
|
|
67
66
|
});
|
|
68
67
|
t.deepEqual(moolaPurseInfo.currentAmountSlots, {
|
|
69
|
-
body: '{"brand":
|
|
68
|
+
body: '#{"brand":"$0.Alleged: moola brand","value":"+0"}',
|
|
70
69
|
slots: [
|
|
71
70
|
{
|
|
72
71
|
kind: 'brand',
|
|
@@ -100,7 +99,7 @@ test('getAttenuatedPursesNotifier', async t => {
|
|
|
100
99
|
value: 0n,
|
|
101
100
|
});
|
|
102
101
|
t.deepEqual(moolaPurseInfo.currentAmountSlots, {
|
|
103
|
-
body: '{"brand":
|
|
102
|
+
body: '#{"brand":"$0.Alleged: moola brand","value":"+0"}',
|
|
104
103
|
slots: [
|
|
105
104
|
{
|
|
106
105
|
kind: 'brand',
|
|
@@ -111,7 +111,7 @@ test('makeDehydrator', async t => {
|
|
|
111
111
|
t.deepEqual(
|
|
112
112
|
dehydrate(harden({ handle: handle1 })),
|
|
113
113
|
{
|
|
114
|
-
body: '{"handle":
|
|
114
|
+
body: '#{"handle":"$0.Alleged: handle1"}',
|
|
115
115
|
slots: [{ kind: 'instanceHandle', petname: 'simpleExchange' }],
|
|
116
116
|
},
|
|
117
117
|
`serialize val with petname`,
|
|
@@ -119,7 +119,7 @@ test('makeDehydrator', async t => {
|
|
|
119
119
|
t.deepEqual(
|
|
120
120
|
hydrate(
|
|
121
121
|
harden({
|
|
122
|
-
body: '{"handle":
|
|
122
|
+
body: '#{"handle":"$0"}',
|
|
123
123
|
slots: [
|
|
124
124
|
{
|
|
125
125
|
kind: 'instanceHandle',
|
|
@@ -134,7 +134,7 @@ test('makeDehydrator', async t => {
|
|
|
134
134
|
t.deepEqual(
|
|
135
135
|
dehydrate(harden({ brand: brand1, value: 40 })),
|
|
136
136
|
harden({
|
|
137
|
-
body: '{"brand":
|
|
137
|
+
body: '#{"brand":"$0.Alleged: mock brand","value":40}',
|
|
138
138
|
slots: [{ kind: 'brand', petname: 'moola' }],
|
|
139
139
|
}),
|
|
140
140
|
`serialize brand with petname`,
|
|
@@ -142,7 +142,7 @@ test('makeDehydrator', async t => {
|
|
|
142
142
|
t.deepEqual(
|
|
143
143
|
hydrate(
|
|
144
144
|
harden({
|
|
145
|
-
body: '{"brand":
|
|
145
|
+
body: '#{"brand":"$0","value":40}',
|
|
146
146
|
slots: [{ kind: 'brand', petname: 'moola' }],
|
|
147
147
|
}),
|
|
148
148
|
),
|
|
@@ -167,7 +167,7 @@ test('makeDehydrator', async t => {
|
|
|
167
167
|
t.deepEqual(
|
|
168
168
|
dehydrate(proposal),
|
|
169
169
|
{
|
|
170
|
-
body: '{"exit":{"afterDeadline":{"deadline":55,"timer":
|
|
170
|
+
body: '#{"exit":{"afterDeadline":{"deadline":55,"timer":"$0.Alleged: timer"}},"give":{"Price":{"brand":"$1.Alleged: mock brand","value":3}},"want":{"Asset1":{"brand":"$2.Alleged: mock brand","value":60},"Asset2":{"brand":"$3.Alleged: mock brand","value":{"instanceHandle":"$4.Alleged: handle3"}}}}',
|
|
171
171
|
slots: [
|
|
172
172
|
{ kind: 'unnamed', petname: 'unnamed-1' },
|
|
173
173
|
{ kind: 'brand', petname: 'simolean' },
|
|
@@ -181,7 +181,7 @@ test('makeDehydrator', async t => {
|
|
|
181
181
|
t.deepEqual(
|
|
182
182
|
hydrate(
|
|
183
183
|
harden({
|
|
184
|
-
body: '{"want":{"Asset1":{"brand":
|
|
184
|
+
body: '#{"want":{"Asset1":{"brand":"$0","value":60},"Asset2":{"brand":"$1","value":{"instanceHandle":"$2"}}},"give":{"Price":{"brand":"$3","value":3}},"exit":{"afterDeadline":{"timer":"$4","deadline":55}}}',
|
|
185
185
|
slots: [
|
|
186
186
|
{ kind: 'brand', petname: 'moola' },
|
|
187
187
|
{ kind: 'brand', petname: 'zoeInvite' },
|
|
@@ -198,7 +198,7 @@ test('makeDehydrator', async t => {
|
|
|
198
198
|
t.deepEqual(
|
|
199
199
|
dehydrate(harden({ handle: handle4 })),
|
|
200
200
|
{
|
|
201
|
-
body: '{"handle":
|
|
201
|
+
body: '#{"handle":"$0.Alleged: handle4"}',
|
|
202
202
|
slots: [{ kind: 'unnamed', petname: 'unnamed-2' }],
|
|
203
203
|
},
|
|
204
204
|
`serialize val with no petname`,
|
|
@@ -206,7 +206,7 @@ test('makeDehydrator', async t => {
|
|
|
206
206
|
t.deepEqual(
|
|
207
207
|
hydrate(
|
|
208
208
|
harden({
|
|
209
|
-
body: '{"handle":
|
|
209
|
+
body: '#{"handle":"$0"}',
|
|
210
210
|
slots: [{ kind: 'unnamed', petname: 'unnamed-2' }],
|
|
211
211
|
}),
|
|
212
212
|
),
|
|
@@ -218,7 +218,7 @@ test('makeDehydrator', async t => {
|
|
|
218
218
|
t.deepEqual(
|
|
219
219
|
dehydrate(harden({ handle: handle4 })),
|
|
220
220
|
{
|
|
221
|
-
body: '{"handle":
|
|
221
|
+
body: '#{"handle":"$0.Alleged: handle4"}',
|
|
222
222
|
slots: [{ kind: 'instanceHandle', petname: 'autoswap' }],
|
|
223
223
|
},
|
|
224
224
|
`serialize val with new petname`,
|
|
@@ -226,7 +226,7 @@ test('makeDehydrator', async t => {
|
|
|
226
226
|
t.deepEqual(
|
|
227
227
|
hydrate(
|
|
228
228
|
harden({
|
|
229
|
-
body: '{"handle":
|
|
229
|
+
body: '#{"handle":"$0"}',
|
|
230
230
|
slots: [{ kind: 'instanceHandle', petname: 'autoswap' }],
|
|
231
231
|
}),
|
|
232
232
|
),
|
package/test/test-lib-wallet.js
CHANGED
|
@@ -8,31 +8,31 @@ import { makeIssuerKit, AmountMath, AssetKind } from '@agoric/ertp';
|
|
|
8
8
|
|
|
9
9
|
import { M } from '@agoric/store';
|
|
10
10
|
|
|
11
|
-
import {
|
|
12
|
-
import fakeVatAdmin from '@agoric/zoe/tools/fakeVatAdmin.js';
|
|
11
|
+
import { makeZoeForTest } from '@agoric/zoe/tools/setup-zoe.js';
|
|
13
12
|
import { E } from '@endo/eventual-send';
|
|
14
13
|
|
|
15
14
|
import { assert } from '@agoric/assert';
|
|
16
15
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
17
|
-
import {
|
|
16
|
+
import { makeFakeBoard } from '@agoric/vats/tools/board-utils.js';
|
|
18
17
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
19
|
-
import {
|
|
20
|
-
|
|
18
|
+
import {
|
|
19
|
+
makeNameHubKit,
|
|
20
|
+
prepareMixinMyAddress,
|
|
21
|
+
} from '@agoric/vats/src/nameHub.js';
|
|
21
22
|
import { resolve as importMetaResolve } from 'import-meta-resolve';
|
|
23
|
+
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
24
|
+
import { heapZone } from '@agoric/zone';
|
|
22
25
|
import { makeWalletRoot } from '../src/lib-wallet.js';
|
|
23
26
|
|
|
24
27
|
import '../src/types.js';
|
|
25
28
|
|
|
26
29
|
const ZOE_INVITE_PURSE_PETNAME = 'Default Zoe invite purse';
|
|
27
30
|
|
|
31
|
+
const mixinMyAddress = prepareMixinMyAddress(heapZone);
|
|
32
|
+
|
|
28
33
|
function makeFakeMyAddressNameAdmin() {
|
|
29
|
-
const { nameAdmin
|
|
30
|
-
return
|
|
31
|
-
...rawMyAddressNameAdmin,
|
|
32
|
-
getMyAddress() {
|
|
33
|
-
return 'agoric1test1';
|
|
34
|
-
},
|
|
35
|
-
});
|
|
34
|
+
const { nameAdmin } = makeNameHubKit();
|
|
35
|
+
return mixinMyAddress(nameAdmin, 'agoric1test1');
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
/** @type {import('ava').TestFn<Awaited<LibWalletTestContext>>} */
|
|
@@ -43,13 +43,12 @@ const test = anyTest;
|
|
|
43
43
|
* zoe: ZoeService,
|
|
44
44
|
* automaticRefundInstallation: Installation,
|
|
45
45
|
* autoswapInstallation: Installation,
|
|
46
|
-
* attestationInstallation: Installation,
|
|
47
46
|
* }} LibWalletTestContext
|
|
48
47
|
*/
|
|
49
48
|
|
|
50
49
|
async function setupTest(
|
|
51
50
|
/** @type {import('ava').ExecutionContext<LibWalletTestContext>} */ t,
|
|
52
|
-
{ autoswap = false, automaticRefund = false
|
|
51
|
+
{ autoswap = false, automaticRefund = false } = {},
|
|
53
52
|
) {
|
|
54
53
|
const pursesStateChangeLog = [];
|
|
55
54
|
const inboxStateChangeLog = [];
|
|
@@ -63,7 +62,7 @@ async function setupTest(
|
|
|
63
62
|
const moolaBundle = makeIssuerKit('moola');
|
|
64
63
|
const simoleanBundle = makeIssuerKit('simolean');
|
|
65
64
|
const rpgBundle = makeIssuerKit('rpg', AssetKind.SET);
|
|
66
|
-
const board =
|
|
65
|
+
const board = makeFakeBoard();
|
|
67
66
|
|
|
68
67
|
const automaticRefundP = (automaticRefund &&
|
|
69
68
|
(async () => {
|
|
@@ -97,71 +96,24 @@ async function setupTest(
|
|
|
97
96
|
instance: null,
|
|
98
97
|
};
|
|
99
98
|
|
|
100
|
-
const attestationP = (attestation &&
|
|
101
|
-
(async () => {
|
|
102
|
-
const { publicFacet, instance } = await E(t.context.zoe).startInstance(
|
|
103
|
-
t.context.attestationInstallation,
|
|
104
|
-
);
|
|
105
|
-
const {
|
|
106
|
-
issuers: { Attestation: issuer },
|
|
107
|
-
brands: { Attestation: brand },
|
|
108
|
-
} = await E(t.context.zoe).getTerms(instance);
|
|
109
|
-
|
|
110
|
-
const names = {
|
|
111
|
-
lookup: (/** @type {string[]} */ ...namePath) => {
|
|
112
|
-
if (namePath[0] === 'issuer' && namePath[1] === 'Attestation') {
|
|
113
|
-
return issuer;
|
|
114
|
-
}
|
|
115
|
-
return null;
|
|
116
|
-
},
|
|
117
|
-
};
|
|
118
|
-
return { names, issuer, brand, publicFacet };
|
|
119
|
-
})()) || {
|
|
120
|
-
names: null,
|
|
121
|
-
issuer: null,
|
|
122
|
-
brand: null,
|
|
123
|
-
publicFacet: null,
|
|
124
|
-
};
|
|
125
|
-
|
|
126
99
|
const [
|
|
127
100
|
{
|
|
128
101
|
creatorInvitation: automaticRefundInvitation,
|
|
129
102
|
instance: automaticRefundInstance,
|
|
130
103
|
},
|
|
131
104
|
{ invite: addLiquidityInvite, instance: autoswapInstanceHandle },
|
|
132
|
-
|
|
133
|
-
names: fakeAgoricNames,
|
|
134
|
-
issuer: attestationIssuer,
|
|
135
|
-
brand: attestationBrand,
|
|
136
|
-
publicFacet: attestationPublicFacet,
|
|
137
|
-
},
|
|
138
|
-
] = await Promise.all([automaticRefundP, autoswapP, attestationP]);
|
|
105
|
+
] = await Promise.all([automaticRefundP, autoswapP]);
|
|
139
106
|
|
|
140
107
|
const { admin: wallet, initialized } = makeWalletRoot({
|
|
141
108
|
zoe: t.context.zoe,
|
|
142
109
|
board,
|
|
143
110
|
myAddressNameAdmin: makeFakeMyAddressNameAdmin(),
|
|
144
|
-
// @ts-expect-error
|
|
145
|
-
agoricNames: fakeAgoricNames,
|
|
146
111
|
pursesStateChangeHandler,
|
|
147
112
|
inboxStateChangeHandler,
|
|
148
113
|
});
|
|
149
114
|
await initialized;
|
|
150
115
|
|
|
151
|
-
if (attestation) {
|
|
152
|
-
assert(attestationBrand);
|
|
153
|
-
wallet.resolveAttMaker({
|
|
154
|
-
makeReturnAttInvitation: attestationPublicFacet.makeReturnAttInvitation,
|
|
155
|
-
makeAttestation: (/** @type {any} */ value) =>
|
|
156
|
-
attestationPublicFacet.mintAttestation(value),
|
|
157
|
-
wrapLienedAmount: ({ value }) => AmountMath.make(attestationBrand, value),
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
|
|
161
116
|
return {
|
|
162
|
-
attestationIssuer,
|
|
163
|
-
attestationPublicFacet,
|
|
164
|
-
attestationBrand,
|
|
165
117
|
moolaBundle,
|
|
166
118
|
simoleanBundle,
|
|
167
119
|
rpgBundle,
|
|
@@ -179,7 +131,7 @@ async function setupTest(
|
|
|
179
131
|
/**
|
|
180
132
|
* Run a thunk and wait for the notifier to fire.
|
|
181
133
|
*
|
|
182
|
-
* @param {ERef<
|
|
134
|
+
* @param {ERef<LatestTopic<any>>} notifier
|
|
183
135
|
* @param {() => Promise<any>} thunk
|
|
184
136
|
*/
|
|
185
137
|
const waitForUpdate = async (notifier, thunk) => {
|
|
@@ -189,7 +141,7 @@ const waitForUpdate = async (notifier, thunk) => {
|
|
|
189
141
|
};
|
|
190
142
|
|
|
191
143
|
test.before(async t => {
|
|
192
|
-
const zoe =
|
|
144
|
+
const zoe = makeZoeForTest();
|
|
193
145
|
|
|
194
146
|
// Create AutomaticRefund instance
|
|
195
147
|
const automaticRefundContractUrl = await importMetaResolve(
|
|
@@ -212,20 +164,10 @@ test.before(async t => {
|
|
|
212
164
|
const autoswapBundle = await bundleSource(autoswapContractRoot);
|
|
213
165
|
const autoswapInstallation = await E(zoe).install(autoswapBundle);
|
|
214
166
|
|
|
215
|
-
// Create attestationExample instance
|
|
216
|
-
const url = await importMetaResolve(
|
|
217
|
-
'./attestationExample.js',
|
|
218
|
-
import.meta.url,
|
|
219
|
-
);
|
|
220
|
-
const path = new URL(url).pathname;
|
|
221
|
-
const attestationBundle = await bundleSource(path);
|
|
222
|
-
const attestationInstallation = await E(zoe).install(attestationBundle);
|
|
223
|
-
|
|
224
167
|
t.context = {
|
|
225
168
|
zoe,
|
|
226
169
|
automaticRefundInstallation,
|
|
227
170
|
autoswapInstallation,
|
|
228
|
-
attestationInstallation,
|
|
229
171
|
};
|
|
230
172
|
});
|
|
231
173
|
|
|
@@ -320,7 +262,7 @@ test('lib-wallet issuer and purse methods', async t => {
|
|
|
320
262
|
pursePetname: 'Default Zoe invite purse',
|
|
321
263
|
value: [],
|
|
322
264
|
currentAmountSlots: {
|
|
323
|
-
body: '{"brand":
|
|
265
|
+
body: '#{"brand":"$0.Alleged: Zoe Invitation brand","value":[]}',
|
|
324
266
|
slots: [{ kind: 'brand', petname: 'zoe invite' }],
|
|
325
267
|
},
|
|
326
268
|
currentAmount: {
|
|
@@ -342,7 +284,7 @@ test('lib-wallet issuer and purse methods', async t => {
|
|
|
342
284
|
pursePetname: 'fun money',
|
|
343
285
|
value: 100,
|
|
344
286
|
currentAmountSlots: {
|
|
345
|
-
body: '{"brand":
|
|
287
|
+
body: '#{"brand":"$0.Alleged: moola brand","value":"+100"}',
|
|
346
288
|
slots: [{ kind: 'brand', petname: 'moola' }],
|
|
347
289
|
},
|
|
348
290
|
currentAmount: {
|
|
@@ -428,7 +370,7 @@ test('lib-wallet dapp suggests issuer, instance, installation petnames', async t
|
|
|
428
370
|
assert(Array.isArray(invitationAmountValue2));
|
|
429
371
|
const [{ handle: inviteHandle2 }] = invitationAmountValue2;
|
|
430
372
|
|
|
431
|
-
await waitForUpdate(
|
|
373
|
+
await waitForUpdate(wallet.getPursesNotifier(), () =>
|
|
432
374
|
wallet.deposit('Default Zoe invite purse', invite2),
|
|
433
375
|
);
|
|
434
376
|
|
|
@@ -472,12 +414,12 @@ test('lib-wallet dapp suggests issuer, instance, installation petnames', async t
|
|
|
472
414
|
},
|
|
473
415
|
],
|
|
474
416
|
currentAmountSlots: {
|
|
475
|
-
body: '{"brand":
|
|
417
|
+
body: '#{"brand":"$0.Alleged: Zoe Invitation brand","value":[{"description":"getRefund","handle":"$1.Alleged: InvitationHandle","installation":"$2.Alleged: BundleInstallation","instance":"$3.Alleged: InstanceHandle"}]}',
|
|
476
418
|
slots: [
|
|
477
419
|
{ kind: 'brand', petname: 'zoe invite' },
|
|
478
420
|
{ kind: 'unnamed', petname: 'unnamed-4' },
|
|
479
421
|
{ kind: 'unnamed', petname: 'unnamed-2' },
|
|
480
|
-
{ kind: 'unnamed', petname: 'unnamed-
|
|
422
|
+
{ kind: 'unnamed', petname: 'unnamed-1' },
|
|
481
423
|
],
|
|
482
424
|
},
|
|
483
425
|
currentAmount: {
|
|
@@ -487,7 +429,7 @@ test('lib-wallet dapp suggests issuer, instance, installation petnames', async t
|
|
|
487
429
|
description: 'getRefund',
|
|
488
430
|
handle: { kind: 'unnamed', petname: 'unnamed-4' },
|
|
489
431
|
installation: { kind: 'unnamed', petname: 'unnamed-2' },
|
|
490
|
-
instance: { kind: 'unnamed', petname: 'unnamed-
|
|
432
|
+
instance: { kind: 'unnamed', petname: 'unnamed-1' },
|
|
491
433
|
},
|
|
492
434
|
],
|
|
493
435
|
},
|
|
@@ -559,7 +501,7 @@ test('lib-wallet dapp suggests issuer, instance, installation petnames', async t
|
|
|
559
501
|
},
|
|
560
502
|
],
|
|
561
503
|
currentAmountSlots: {
|
|
562
|
-
body: '{"brand":
|
|
504
|
+
body: '#{"brand":"$0.Alleged: Zoe Invitation brand","value":[{"description":"getRefund","handle":"$1.Alleged: InvitationHandle","installation":"$2.Alleged: BundleInstallation","instance":"$3.Alleged: InstanceHandle"}]}',
|
|
563
505
|
slots: [
|
|
564
506
|
{ kind: 'brand', petname: 'zoe invite' },
|
|
565
507
|
{ kind: 'unnamed', petname: 'unnamed-4' },
|
|
@@ -597,7 +539,7 @@ test('lib-wallet dapp suggests issuer, instance, installation petnames', async t
|
|
|
597
539
|
description: 'getRefund',
|
|
598
540
|
handle: {
|
|
599
541
|
kind: 'unnamed',
|
|
600
|
-
petname: 'unnamed-
|
|
542
|
+
petname: 'unnamed-3',
|
|
601
543
|
},
|
|
602
544
|
installation: {
|
|
603
545
|
kind: 'installation',
|
|
@@ -698,7 +640,7 @@ test('lib-wallet dapp suggests issuer, instance, installation petnames', async t
|
|
|
698
640
|
},
|
|
699
641
|
],
|
|
700
642
|
currentAmountSlots: {
|
|
701
|
-
body: '{"brand":
|
|
643
|
+
body: '#{"brand":"$0.Alleged: Zoe Invitation brand","value":[{"description":"getRefund","handle":"$1.Alleged: InvitationHandle","installation":"$2.Alleged: BundleInstallation","instance":"$3.Alleged: InstanceHandle"}]}',
|
|
702
644
|
slots: [
|
|
703
645
|
{ kind: 'brand', petname: 'zoe invite' },
|
|
704
646
|
{ kind: 'unnamed', petname: 'unnamed-4' },
|
|
@@ -735,7 +677,7 @@ test('lib-wallet dapp suggests issuer, instance, installation petnames', async t
|
|
|
735
677
|
description: 'getRefund',
|
|
736
678
|
handle: {
|
|
737
679
|
kind: 'unnamed',
|
|
738
|
-
petname: 'unnamed-
|
|
680
|
+
petname: 'unnamed-3',
|
|
739
681
|
},
|
|
740
682
|
installation: {
|
|
741
683
|
kind: 'installation',
|
|
@@ -905,7 +847,7 @@ test('lib-wallet offer methods', async t => {
|
|
|
905
847
|
pursePetname: 'Default Zoe invite purse',
|
|
906
848
|
value: [],
|
|
907
849
|
currentAmountSlots: {
|
|
908
|
-
body: '{"brand":
|
|
850
|
+
body: '#{"brand":"$0.Alleged: Zoe Invitation brand","value":[]}',
|
|
909
851
|
slots: [{ kind: 'brand', petname: 'zoe invite' }],
|
|
910
852
|
},
|
|
911
853
|
currentAmount: {
|
|
@@ -928,7 +870,7 @@ test('lib-wallet offer methods', async t => {
|
|
|
928
870
|
depositBoardId: 'board0371',
|
|
929
871
|
value: 100,
|
|
930
872
|
currentAmountSlots: {
|
|
931
|
-
body: '{"brand":
|
|
873
|
+
body: '#{"brand":"$0.Alleged: moola brand","value":"+100"}',
|
|
932
874
|
slots: [{ kind: 'brand', petname: 'moola' }],
|
|
933
875
|
},
|
|
934
876
|
meta: {
|
|
@@ -970,7 +912,7 @@ test('lib-wallet offer methods', async t => {
|
|
|
970
912
|
},
|
|
971
913
|
instance: {
|
|
972
914
|
kind: 'unnamed',
|
|
973
|
-
petname: 'unnamed-
|
|
915
|
+
petname: 'unnamed-1',
|
|
974
916
|
},
|
|
975
917
|
},
|
|
976
918
|
inviteHandleBoardId: 'board0257',
|
|
@@ -984,7 +926,7 @@ test('lib-wallet offer methods', async t => {
|
|
|
984
926
|
},
|
|
985
927
|
requestContext: { dappOrigin: 'unknown' },
|
|
986
928
|
status: 'decline',
|
|
987
|
-
instancePetname: 'unnamed-
|
|
929
|
+
instancePetname: 'unnamed-1',
|
|
988
930
|
installationPetname: 'unnamed-2',
|
|
989
931
|
proposalForDisplay: {
|
|
990
932
|
give: {
|
|
@@ -1039,7 +981,7 @@ test('lib-wallet addOffer for autoswap swap', async t => {
|
|
|
1039
981
|
),
|
|
1040
982
|
);
|
|
1041
983
|
|
|
1042
|
-
/** @type {{ getLiquidityIssuer: () => Issuer
|
|
984
|
+
/** @type {{ getLiquidityIssuer: () => Issuer<'nat'>, makeSwapInvitation: () => Invitation }} */
|
|
1043
985
|
const publicAPI = await E(t.context.zoe).getPublicFacet(
|
|
1044
986
|
autoswapInstanceHandle,
|
|
1045
987
|
);
|
|
@@ -1190,7 +1132,7 @@ test('lib-wallet performAction acceptOffer', async t => {
|
|
|
1190
1132
|
),
|
|
1191
1133
|
);
|
|
1192
1134
|
|
|
1193
|
-
/** @type {{ getLiquidityIssuer: () => Issuer
|
|
1135
|
+
/** @type {{ getLiquidityIssuer: () => Issuer<'nat'>, makeSwapInvitation: () => Invitation }} */
|
|
1194
1136
|
const publicAPI = await E(t.context.zoe).getPublicFacet(
|
|
1195
1137
|
autoswapInstanceHandle,
|
|
1196
1138
|
);
|
|
@@ -1303,157 +1245,6 @@ test('lib-wallet performAction acceptOffer', async t => {
|
|
|
1303
1245
|
);
|
|
1304
1246
|
});
|
|
1305
1247
|
|
|
1306
|
-
test('lib-wallet can give attestations in offers', async t => {
|
|
1307
|
-
const {
|
|
1308
|
-
wallet,
|
|
1309
|
-
attestationPublicFacet,
|
|
1310
|
-
attestationBrand,
|
|
1311
|
-
attestationIssuer,
|
|
1312
|
-
} = await setupTest(t, { attestation: true });
|
|
1313
|
-
|
|
1314
|
-
assert(attestationIssuer);
|
|
1315
|
-
assert(attestationBrand);
|
|
1316
|
-
const issuerManager = wallet.getIssuerManager();
|
|
1317
|
-
await issuerManager.add('Attestation', attestationIssuer);
|
|
1318
|
-
await wallet.makeEmptyPurse('Attestation', 'staking purse');
|
|
1319
|
-
|
|
1320
|
-
const invitation = await attestationPublicFacet.makeReturnAttInvitation();
|
|
1321
|
-
|
|
1322
|
-
const rawId = '123-arbitrary';
|
|
1323
|
-
const id = `unknown#${rawId}`;
|
|
1324
|
-
const offer = {
|
|
1325
|
-
id: rawId,
|
|
1326
|
-
invitation,
|
|
1327
|
-
proposalTemplate: {
|
|
1328
|
-
give: {
|
|
1329
|
-
Attestation: {
|
|
1330
|
-
pursePetname: 'staking purse',
|
|
1331
|
-
value: 30n,
|
|
1332
|
-
type: 'Attestation',
|
|
1333
|
-
},
|
|
1334
|
-
},
|
|
1335
|
-
exit: {
|
|
1336
|
-
onDemand: null,
|
|
1337
|
-
},
|
|
1338
|
-
},
|
|
1339
|
-
};
|
|
1340
|
-
|
|
1341
|
-
await wallet.addOffer(offer);
|
|
1342
|
-
const accepted = await wallet.acceptOffer(id);
|
|
1343
|
-
assert(accepted);
|
|
1344
|
-
const { depositedP } = accepted;
|
|
1345
|
-
await depositedP;
|
|
1346
|
-
|
|
1347
|
-
// There should be two calls. The first is call to give the attestation
|
|
1348
|
-
// as proposed. The second call is to return the unallocated attestation
|
|
1349
|
-
// back to the attMaker (which in this test uses the same method).
|
|
1350
|
-
const callHistory = await attestationPublicFacet.getCallHistory();
|
|
1351
|
-
t.deepEqual(callHistory.returnProposals, [
|
|
1352
|
-
{
|
|
1353
|
-
exit: {
|
|
1354
|
-
onDemand: null,
|
|
1355
|
-
},
|
|
1356
|
-
give: {
|
|
1357
|
-
Attestation: AmountMath.make(attestationBrand, 30n),
|
|
1358
|
-
},
|
|
1359
|
-
want: {},
|
|
1360
|
-
},
|
|
1361
|
-
{
|
|
1362
|
-
exit: {
|
|
1363
|
-
onDemand: null,
|
|
1364
|
-
},
|
|
1365
|
-
give: {
|
|
1366
|
-
Attestation: AmountMath.make(attestationBrand, 30n),
|
|
1367
|
-
},
|
|
1368
|
-
want: {},
|
|
1369
|
-
},
|
|
1370
|
-
]);
|
|
1371
|
-
t.deepEqual(callHistory.returnAllocations, [
|
|
1372
|
-
{
|
|
1373
|
-
Attestation: AmountMath.make(attestationBrand, 30n),
|
|
1374
|
-
},
|
|
1375
|
-
{
|
|
1376
|
-
Attestation: AmountMath.make(attestationBrand, 30n),
|
|
1377
|
-
},
|
|
1378
|
-
]);
|
|
1379
|
-
});
|
|
1380
|
-
|
|
1381
|
-
test('lib-wallet can want attestations in offers', async t => {
|
|
1382
|
-
const {
|
|
1383
|
-
wallet,
|
|
1384
|
-
attestationPublicFacet,
|
|
1385
|
-
attestationBrand,
|
|
1386
|
-
attestationIssuer,
|
|
1387
|
-
} = await setupTest(t, { attestation: true });
|
|
1388
|
-
|
|
1389
|
-
assert(attestationIssuer);
|
|
1390
|
-
assert(attestationBrand);
|
|
1391
|
-
const issuerManager = wallet.getIssuerManager();
|
|
1392
|
-
await issuerManager.add('Attestation', attestationIssuer);
|
|
1393
|
-
await wallet.makeEmptyPurse('Attestation', 'staking purse');
|
|
1394
|
-
|
|
1395
|
-
const invitation = await attestationPublicFacet.makeWantAttInvitation();
|
|
1396
|
-
|
|
1397
|
-
const rawId = '123-arbitrary';
|
|
1398
|
-
const id = `unknown#${rawId}`;
|
|
1399
|
-
const offer = {
|
|
1400
|
-
id: rawId,
|
|
1401
|
-
invitation,
|
|
1402
|
-
proposalTemplate: {
|
|
1403
|
-
want: {
|
|
1404
|
-
Attestation: {
|
|
1405
|
-
pursePetname: 'staking purse',
|
|
1406
|
-
value: 65n,
|
|
1407
|
-
type: 'Attestation',
|
|
1408
|
-
},
|
|
1409
|
-
},
|
|
1410
|
-
exit: {
|
|
1411
|
-
onDemand: null,
|
|
1412
|
-
},
|
|
1413
|
-
},
|
|
1414
|
-
};
|
|
1415
|
-
|
|
1416
|
-
await wallet.addOffer(offer);
|
|
1417
|
-
const accepted = await wallet.acceptOffer(id);
|
|
1418
|
-
assert(accepted);
|
|
1419
|
-
const { depositedP } = accepted;
|
|
1420
|
-
await depositedP;
|
|
1421
|
-
|
|
1422
|
-
const callHistory = await attestationPublicFacet.getCallHistory();
|
|
1423
|
-
t.deepEqual(callHistory.wantProposals, [
|
|
1424
|
-
{
|
|
1425
|
-
exit: {
|
|
1426
|
-
onDemand: null,
|
|
1427
|
-
},
|
|
1428
|
-
want: {
|
|
1429
|
-
Attestation: AmountMath.make(attestationBrand, 65n),
|
|
1430
|
-
},
|
|
1431
|
-
give: {},
|
|
1432
|
-
},
|
|
1433
|
-
]);
|
|
1434
|
-
t.deepEqual(callHistory.wantAllocations, [
|
|
1435
|
-
{ Attestation: AmountMath.make(attestationBrand, 0n) },
|
|
1436
|
-
]);
|
|
1437
|
-
// When an attestation payout is recieved, the wallet should return it to the
|
|
1438
|
-
// attMaker:
|
|
1439
|
-
t.deepEqual(callHistory.returnProposals, [
|
|
1440
|
-
{
|
|
1441
|
-
exit: {
|
|
1442
|
-
onDemand: null,
|
|
1443
|
-
},
|
|
1444
|
-
give: {
|
|
1445
|
-
Attestation: AmountMath.make(attestationBrand, 65n),
|
|
1446
|
-
},
|
|
1447
|
-
want: {},
|
|
1448
|
-
},
|
|
1449
|
-
]);
|
|
1450
|
-
t.deepEqual(callHistory.returnAllocations, [
|
|
1451
|
-
{
|
|
1452
|
-
Attestation: AmountMath.make(attestationBrand, 65n),
|
|
1453
|
-
},
|
|
1454
|
-
]);
|
|
1455
|
-
});
|
|
1456
|
-
|
|
1457
1248
|
test('addOffer invitationQuery', async t => {
|
|
1458
1249
|
const {
|
|
1459
1250
|
moolaBundle,
|
|
@@ -1480,7 +1271,7 @@ test('addOffer invitationQuery', async t => {
|
|
|
1480
1271
|
),
|
|
1481
1272
|
);
|
|
1482
1273
|
|
|
1483
|
-
/** @type {{ getLiquidityIssuer: () => Issuer
|
|
1274
|
+
/** @type {{ getLiquidityIssuer: () => Issuer<'nat'>, makeSwapInvitation: () => Invitation }} */
|
|
1484
1275
|
const publicAPI = await E(t.context.zoe).getPublicFacet(
|
|
1485
1276
|
autoswapInstanceHandle,
|
|
1486
1277
|
);
|
|
@@ -1608,7 +1399,7 @@ test('addOffer offer.invitation', async t => {
|
|
|
1608
1399
|
),
|
|
1609
1400
|
);
|
|
1610
1401
|
|
|
1611
|
-
/** @type {{ getLiquidityIssuer: () => Issuer
|
|
1402
|
+
/** @type {{ getLiquidityIssuer: () => Issuer<'nat'>, makeSwapInvitation: () => Invitation }} */
|
|
1612
1403
|
const publicAPI = await E(t.context.zoe).getPublicFacet(
|
|
1613
1404
|
autoswapInstanceHandle,
|
|
1614
1405
|
);
|
|
@@ -1704,7 +1495,7 @@ test('addOffer offer.invitation', async t => {
|
|
|
1704
1495
|
});
|
|
1705
1496
|
|
|
1706
1497
|
test('addOffer makeContinuingInvitation', async t => {
|
|
1707
|
-
const board =
|
|
1498
|
+
const board = makeFakeBoard();
|
|
1708
1499
|
|
|
1709
1500
|
// Create ContinuingInvitationExample instance
|
|
1710
1501
|
const url = await importMetaResolve(
|
|
@@ -1794,7 +1585,7 @@ test('addOffer makeContinuingInvitation', async t => {
|
|
|
1794
1585
|
});
|
|
1795
1586
|
|
|
1796
1587
|
test('getZoe, getBoard', async t => {
|
|
1797
|
-
const board =
|
|
1588
|
+
const board = makeFakeBoard();
|
|
1798
1589
|
|
|
1799
1590
|
const pursesStateChangeHandler = (/** @type {any} */ _data) => {};
|
|
1800
1591
|
const inboxStateChangeHandler = (/** @type {any} */ _data) => {};
|
|
@@ -1813,7 +1604,7 @@ test('getZoe, getBoard', async t => {
|
|
|
1813
1604
|
});
|
|
1814
1605
|
|
|
1815
1606
|
test('stamps from dateNow', async t => {
|
|
1816
|
-
const board =
|
|
1607
|
+
const board = makeFakeBoard();
|
|
1817
1608
|
|
|
1818
1609
|
const startDateMS = new Date(2020, 0, 1).valueOf();
|
|
1819
1610
|
let currentDateMS = startDateMS;
|