Skip to content

Conversation

dckc
Copy link
Member

@dckc dckc commented Sep 25, 2025

Description

creator can withdraw fees; for example when terminating / replacing the contract

Security / Documentation Considerations

straightforward usage of creatorFacet, compatible with ymaxControl

Scaling Considerations

n/a

Testing Considerations

straightforward unit test using mock bridge

Upgrade Considerations

upgrade compatible

@dckc dckc requested a review from a team as a code owner September 25, 2025 17:41
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a new withdrawFees method to the portfolio contract's creator facet, allowing the creator to withdraw accumulated fees from the contract account. This functionality is particularly useful when terminating or replacing the contract.

Key changes:

  • Added withdrawFees method to the creator facet with optional amount parameter
  • Enhanced the contract interface to include proper method signature validation
  • Added comprehensive test coverage for both partial and full fee withdrawal scenarios

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
packages/portfolio-contract/src/portfolio.contract.ts Implements the withdrawFees method on the creator facet with optional amount parameter and proper interface validation
packages/portfolio-contract/test/portfolio.contract.test.ts Adds comprehensive test coverage for the new withdrawal functionality, testing both partial and complete fee withdrawal scenarios

// LCA operations are prompt
const { when } = vowTools;
const acct = await when(contractAccountV);
const amount = await (optAmount || when(acct.getBalance('ubld')));
Copy link
Preview

Copilot AI Sep 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parentheses are incorrectly placed. This will always await optAmount if it exists (which could be a synchronous value), or await the balance if not. It should be const amount = optAmount || await when(acct.getBalance('ubld')); to properly handle the optional parameter.

Suggested change
const amount = await (optAmount || when(acct.getBalance('ubld')));
const amount = optAmount || await when(acct.getBalance('ubld'));

Copilot uses AI. Check for mistakes.

Copy link
Member Author

@dckc dckc Sep 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot, This is intentional. We prefer to not have code paths that sometimes await and sometimes don't. cf. Zalgo and all that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case, there's an await on the prior line. Does that allow the nested await?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The await above means our lint rule is satisfied. But my impression is that in any case, it's best not to have code paths that are sometimes a turn boundary and sometimes not.

Copy link

cloudflare-workers-and-pages bot commented Sep 25, 2025

Deploying agoric-sdk with  Cloudflare Pages  Cloudflare Pages

Latest commit: 530289b
Status: ✅  Deploy successful!
Preview URL: https://f71ca61b.agoric-sdk.pages.dev
Branch Preview URL: https://dc-withdraw-fees.agoric-sdk.pages.dev

View logs

Copy link
Member

@dtribble dtribble left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dckc dckc added automerge:rebase Automatically rebase updates, then merge bypass:integration Prevent integration tests from running on PR labels Sep 29, 2025
@mergify mergify bot added the queued label Sep 29, 2025
@mergify mergify bot merged commit 1627f18 into master Sep 29, 2025
98 checks passed
@mergify mergify bot removed the queued label Sep 29, 2025
@mergify mergify bot deleted the dc-withdraw-fees branch September 29, 2025 05:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge:rebase Automatically rebase updates, then merge bypass:integration Prevent integration tests from running on PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants