Skip to content

Commit

Permalink
refactor: provideAccount -> createAccount. address -> accountAddress
Browse files Browse the repository at this point in the history
  • Loading branch information
0xpatrickdev committed Apr 2, 2024
1 parent 745697a commit 752d603
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
13 changes: 7 additions & 6 deletions packages/orchestration/src/contracts/stakeAtom.contract.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
*
*/

import { makeTracer } from '@agoric/internal';
import { makeDurableZone } from '@agoric/zone/durable.js';
import { V as E } from '@agoric/vat-data/vow.js';

const trace = makeTracer('StakeAtom');

/** @typedef {{ hostConnectionId: string, controllerConnectionId: string }} StakeAtomTerms */
/**
* @typedef {{
* hostConnectionId: import('../types').ConnectionId;
* controllerConnectionId: import('../types').ConnectionId;
* }} StakeAtomTerms
*/

/**
*
Expand All @@ -31,8 +33,7 @@ export const start = async (zcf, privateArgs, baggage) => {
* @param {Port} [port] if the user has a bound port and wants to reuse it
*/
async provideAccount(port) {
trace(`provideAccount. ${port ? 'Reusing port' : 'Binding new port'}`);
return E(orchestration).provideAccount(
return E(orchestration).createAccount(
hostConnectionId,
controllerConnectionId,
port,
Expand Down
20 changes: 10 additions & 10 deletions packages/vats/src/orchestration.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const getPower = (powers, name) => {
};

export const ChainAccountI = M.interface('ChainAccount', {
getAddress: M.call().returns(M.string()),
getAccountAddress: M.call().returns(M.string()),
getLocalAddress: M.call().returns(M.string()),
getRemoteAddress: M.call().returns(M.string()),
getPort: M.call().returns(M.remotable('Port')),
Expand Down Expand Up @@ -73,24 +73,24 @@ const prepareChainAccount = zone =>
* localAddress: string | undefined;
* requestedRemoteAddress: string;
* remoteAddress: string | undefined;
* chainAddress: ChainAddress | undefined;
* accountAddress: ChainAddress | undefined;
* }}
*/ (
harden({
port,
connection: undefined,
requestedRemoteAddress,
remoteAddress: undefined,
chainAddress: undefined,
accountAddress: undefined,
localAddress: undefined,
})
),
{
account: {
getAddress() {
const { chainAddress } = this.state;
chainAddress || Fail`chain address not available`;
return chainAddress;
getAccountAddress() {
const { accountAddress } = this.state;
accountAddress || Fail`account address not available`;
return accountAddress;
},
getLocalAddress() {
const { localAddress } = this.state;
Expand Down Expand Up @@ -146,7 +146,7 @@ const prepareChainAccount = zone =>
this.state.remoteAddress = remoteAddr;
this.state.localAddress = localAddr;
// XXX parseAddress currently throws, should it return '' instead?
this.state.chainAddress = parseAddress(remoteAddr);
this.state.accountAddress = parseAddress(remoteAddr);
},
async onClose(connection, reason) {
trace(`ICA Channel closed. Reason: ${reason}`);
Expand All @@ -161,7 +161,7 @@ const prepareChainAccount = zone =>
);

export const OrchestrationI = M.interface('Orchestration', {
provideAccount: M.callWhen(M.string(), M.string())
createAccount: M.callWhen(M.string(), M.string())
.optional(M.remotable('Port'))
.returns(M.remotable('ChainAccount')),
getChain: M.callWhen(M.string()).returns(M.remotable('Chain')),
Expand Down Expand Up @@ -206,7 +206,7 @@ const prepareOrchestration = (zone, createChainAccount) =>
* @param {Port} [currentPort] if a port is provided, it will be reused
* to create the account
*/
async provideAccount(
async createAccount(
hostConnectionId,
controllerConnectionId,
currentPort,
Expand Down

0 comments on commit 752d603

Please sign in to comment.