@@ -172,12 +172,6 @@ export function buildRootObject(_vatPowers) {
172
172
/** @type {Store<string, Bank> } */
173
173
const addressToBank = makeStore ( 'address' ) ;
174
174
175
- /** @type {NotifierRecord<string[]> } */
176
- const {
177
- notifier : accountsNotifier ,
178
- updater : accountsUpdater ,
179
- } = makeNotifierKit ( [ ...addressToBank . keys ( ) ] ) ;
180
-
181
175
/**
182
176
* Create a new personal bank interface for a given address.
183
177
*
@@ -257,22 +251,9 @@ export function buildRootObject(_vatPowers) {
257
251
} ,
258
252
} ) ;
259
253
addressToBank . init ( address , bank ) ;
260
- accountsUpdater . updateState ( [ ...addressToBank . keys ( ) ] ) ;
261
254
return bank ;
262
255
} ;
263
256
264
- const bankDepositFacet = Far ( 'bankDepositFacet' , {
265
- getAccountsNotifier ( ) {
266
- return accountsNotifier ;
267
- } ,
268
- deposit ( brand , account , payment ) {
269
- // The purse will do the proper verification as part of deposit.
270
- const bank = getBankForAddress ( account ) ;
271
- const purse = bank . getPurse ( brand ) ;
272
- return E ( purse ) . deposit ( payment ) ;
273
- } ,
274
- } ) ;
275
-
276
257
return Far ( 'bankManager' , {
277
258
/**
278
259
* Returns assets as they are added to the bank.
@@ -282,9 +263,38 @@ export function buildRootObject(_vatPowers) {
282
263
getAssetSubscription ( ) {
283
264
return harden ( assetSubscription ) ;
284
265
} ,
285
- getDepositFacet ( ) {
286
- return bankDepositFacet ;
266
+ /**
267
+ * @param {string } denom
268
+ * @param {AssetIssuerKit } feeKit
269
+ * @returns {import('@agoric/eventual-send').EOnly<DepositFacet> }
270
+ */
271
+ getFeeCollectorDepositFacet ( denom , feeKit ) {
272
+ if ( ! bankCall ) {
273
+ throw Error ( `Bank doesn't implement fee collectors` ) ;
274
+ }
275
+
276
+ /** @type {VirtualPurseController } */
277
+ const feeVpc = harden ( {
278
+ async * getBalances ( _brand ) {
279
+ // Never resolve!
280
+ yield new Promise ( _ => { } ) ;
281
+ } ,
282
+ async pullAmount ( _amount ) {
283
+ throw Error ( `Cannot pull from fee collector` ) ;
284
+ } ,
285
+ async pushAmount ( amount ) {
286
+ const value = AmountMath . getValue ( feeKit . brand , amount ) ;
287
+ await bankCall ( {
288
+ type : 'VPURSE_GIVE_TO_FEE_COLLECTOR' ,
289
+ denom,
290
+ amount : `${ value } ` ,
291
+ } ) ;
292
+ } ,
293
+ } ) ;
294
+ const vp = makeVirtualPurse ( feeVpc , feeKit ) ;
295
+ return E ( vp ) . getDepositFacet ( ) ;
287
296
} ,
297
+
288
298
/**
289
299
* Add an asset to the bank, and publish it to the subscriptions.
290
300
*
0 commit comments