Skip to content

Commit

Permalink
chore: facade reconciliation
Browse files Browse the repository at this point in the history
  • Loading branch information
turadg committed Jun 5, 2024
1 parent 8adec2a commit fd70556
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
31 changes: 19 additions & 12 deletions packages/orchestration/src/facade.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ import { CosmosChainInfoShape } from './typeGuards.js';
/** @type {any} */
const anyVal = null;

// FIXME should be configurable
// FIXME look up real values
// UNTIL https://github.com/Agoric/agoric-sdk/issues/9063
const mockLocalChainInfo = {
allegedName: 'agoric',
allowedMessages: [],
Expand All @@ -43,36 +44,41 @@ const makeLocalChainFacade = localchain => {
return mockLocalChainInfo;
},

// @ts-expect-error FIXME promise resolution through membrane
async makeAccount() {
const account = await E(localchain).makeAccount();

return {
deposit(payment) {
async deposit(payment) {
console.log('deposit got', payment);
return E(account).deposit(payment);
await E(account).deposit(payment);
},
async getAddress() {
const addressStr = await E(account).getAddress();
getAddress() {
const addressStr = account.getAddress();
return {
address: addressStr,
chainId: mockLocalChainInfo.chainId,
addressEncoding: 'bech32',
};
},
getBalance(_denom) {
// FIXME map denom to Brand
const brand = /** @type {any} */ (null);
return E(account).getBalance(brand);
async getBalance(denomArg) {
// FIXME look up real values
// UNTIL https://github.com/Agoric/agoric-sdk/issues/9211
const [brand, denom] =
typeof denomArg === 'string'
? [/** @type {any} */ (null), denomArg]
: [denomArg, 'FIXME'];

const natAmount = await account.getBalance(brand);
return harden({ denom, value: natAmount.value });
},
getBalances() {
throw new Error('not yet implemented');
},
send(toAccount, amount) {
async send(toAccount, amount) {
// FIXME implement
console.log('send got', toAccount, amount);
},
transfer(amount, destination, opts) {
async transfer(amount, destination, opts) {
// FIXME implement
console.log('transfer got', amount, destination, opts);
},
Expand Down Expand Up @@ -113,6 +119,7 @@ const makeRemoteChainFacade = (
/** @returns {Promise<OrchestrationAccount<CCI>>} */
makeAccount: async () => {
// FIXME look up real values
// UNTIL https://github.com/Agoric/agoric-sdk/issues/9063
const hostConnectionId = 'connection-1';
const controllerConnectionId = 'connection-2';

Expand Down
2 changes: 1 addition & 1 deletion packages/vats/src/localchain.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const prepareLocalChainAccount = zone =>
(address, powers) => ({ address, ...powers, reserved: undefined }),
{
// Information that the account creator needs.
async getAddress() {
getAddress() {
return this.state.address;
},
/** @param {Brand<'nat'>} brand */
Expand Down

0 comments on commit fd70556

Please sign in to comment.