Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

252 simplify parse account #11171

Merged
merged 2 commits into from
Mar 27, 2025
Merged

252 simplify parse account #11171

merged 2 commits into from
Mar 27, 2025

Conversation

Chris-Hibbert
Copy link
Contributor

refs: #11037
refs: #11146

Description

Since we widened our accountIds to AccountIdArg, (see #11007) this updates parseAccountId() to support it more cleanly (and renamed it to parseAccountIdArg()), added a separate parseAccountId() that parses CAIP-10 addresses to their constituent parts.

ChainHub.resolveAccountId() and ChainHub.makeChainAddreess(), which need to support bare bech32 addresses, no longer use parseAccountId.

This grew out of #11037. (It replaces #11146, which tried to go in a different direction.)

Security Considerations

No impact.

Scaling Considerations

No impact.

Documentation Considerations

Automatically generated docs will be updated.

Testing Considerations

Adds tests

Upgrade Considerations

Internal utilities only. Shouldn't impact upgrade.

@Chris-Hibbert Chris-Hibbert added the orchestration The Agoric Orchestration Platform label Mar 26, 2025
@Chris-Hibbert Chris-Hibbert self-assigned this Mar 26, 2025
@Chris-Hibbert Chris-Hibbert requested a review from a team as a code owner March 26, 2025 18:30
Copy link
Member

@turadg turadg left a comment

Choose a reason for hiding this comment

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

LGTM. Suggestions, no blockers

but please clean up commits or land as a squash like feat: parseAccountIdArg

@@ -670,7 +670,7 @@ export const makeChainHub = (
*
* XXX consider accepting AmountArg #10449
*
* @param {AccountIdArg} destination
* @param {AccountIdArg | string} destination
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* @param {AccountIdArg | string} destination
* @param {AccountIdArg | Bech32Address} destination

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Comment on lines 113 to 116
* namespace: string;
* reference: string;
* accountAddress: string;
* }}
Copy link
Member

Choose a reason for hiding this comment

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

consider a type like Caip10Obj

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I called it Caip10Record.

export const parseAccountId = partialId => {
if (typeof partialId !== 'string' || !partialId.length) {
Fail`Empty accountId: ${q(partialId)}`;
export const parseAccountIdArg = partialId => {
Copy link
Member

Choose a reason for hiding this comment

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

"partial" case is no longer supported.

Suggested change
export const parseAccountIdArg = partialId => {
export const parseAccountIdArg = idArg => {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

const parsed = parseAccountId(partialId);
if ('namespace' in parsed) {
// It is already fully qualified
if (partialId.split(':').length === 3) {
Copy link
Member

Choose a reason for hiding this comment

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

consider a comment "if it's already a CAIP-10, return it"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@Chris-Hibbert Chris-Hibbert force-pushed the 252-simplify-parseAccountId branch from d522d23 to 35b5e68 Compare March 26, 2025 21:23
Copy link

cloudflare-workers-and-pages bot commented Mar 26, 2025

Deploying agoric-sdk with  Cloudflare Pages  Cloudflare Pages

Latest commit: 36dee3c
Status: ✅  Deploy successful!
Preview URL: https://f25bb3a4.agoric-sdk.pages.dev
Branch Preview URL: https://252-simplify-parseaccountid.agoric-sdk.pages.dev

View logs

@Chris-Hibbert Chris-Hibbert force-pushed the 252-simplify-parseAccountId branch from 35b5e68 to 6b00e7a Compare March 26, 2025 21:25
@Chris-Hibbert Chris-Hibbert added the automerge:rebase Automatically rebase updates, then merge label Mar 26, 2025
@mergify mergify bot force-pushed the 252-simplify-parseAccountId branch from 6b00e7a to fbd361a Compare March 26, 2025 21:45
Copy link
Contributor

mergify bot commented Mar 26, 2025

This pull request has been removed from the queue for the following reason: checks failed.

The merge conditions cannot be satisfied due to failing checks:

You may have to fix your CI before adding the pull request to the queue again.

If you want to requeue this pull request, you can post a @mergifyio requeue comment.

@mergify mergify bot force-pushed the 252-simplify-parseAccountId branch from fbd361a to 36dee3c Compare March 27, 2025 16:22
@mergify mergify bot merged commit b2b8029 into master Mar 27, 2025
84 checks passed
@mergify mergify bot deleted the 252-simplify-parseAccountId branch March 27, 2025 17:15
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 orchestration The Agoric Orchestration Platform
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants