Skip to content

Commit

Permalink
fix(vats): don't give all of bankManager to 1 account (#9354)
Browse files Browse the repository at this point in the history
refs: #9342, #9193
stacked on

 - #9353

## Description

Provide localchain accounts only with the `bank` for the relevant
address, rather than giving them access to all accounts in the form of
the `bankManager`.

earlier discussion:
https://github.com/Agoric/agoric-sdk/pull/9342/files#r1594791187

### Security Considerations

bankManager was excess authority

### Scaling / Documentation / Testing Considerations

Nothing significant: no scaling changes; existing docs/tests suffice.

### Upgrade Considerations

code is not released / deployed
  • Loading branch information
mergify[bot] authored May 10, 2024
2 parents c11fecb + d1f1630 commit 4685ea9
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions packages/vats/src/localchain.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,19 @@ import { AmountShape } from '@agoric/ertp';
const { Fail } = assert;

/**
* @import {BankManager} from './vat-bank.js';
* @import {BankManager, Bank} from './vat-bank.js';
* @import {ScopedBridgeManager} from './types.js';
*/

/** @import {TypedJson, ResponseTo} from '@agoric/cosmic-proto'; */

/**
* @typedef {{
* system: ScopedBridgeManager;
* bank: Bank;
* }} AccountPowers
*/

/**
* @typedef {{
* system: ScopedBridgeManager;
Expand All @@ -34,7 +41,7 @@ const prepareLocalChainAccount = zone =>
LocalChainAccountI,
/**
* @param {string} address
* @param {LocalChainPowers} powers
* @param {AccountPowers} powers
*/
(address, powers) => ({ address, ...powers, reserved: undefined }),
{
Expand All @@ -50,12 +57,11 @@ const prepareLocalChainAccount = zone =>
* @param {Payment} payment
*/
async deposit(payment) {
const { address, bankManager } = this.state;
const { bank } = this.state;

const allegedBrand = await E(payment).getAllegedBrand();
const bankAcct = E(bankManager).getBankForAddress(address);
const allegedPurse = E(bankAcct).getPurse(allegedBrand);
return E(allegedPurse).deposit(payment);
const purse = E(bank).getPurse(allegedBrand);
return E(purse).deposit(payment);
},
/**
* Execute a batch of transactions and return the responses. Use
Expand Down Expand Up @@ -118,7 +124,8 @@ const prepareLocalChain = (zone, makeAccount) =>
const address = await E(system).toBridge({
type: 'VLOCALCHAIN_ALLOCATE_ADDRESS',
});
return makeAccount(address, { system, bankManager });
const bank = await E(bankManager).getBankForAddress(address);
return makeAccount(address, { system, bank });
},
/**
* Make a single query to the local chain. Will reject with an error if
Expand Down

0 comments on commit 4685ea9

Please sign in to comment.