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

Linting dapp-agoric-basics #67

Merged
merged 13 commits into from
Oct 1, 2024
Merged

Conversation

mujahidkay
Copy link
Member

@mujahidkay mujahidkay commented Sep 20, 2024

Description

This PR enables tsc and fixes lint errors for this dapp. Majority of the code is typed now apart from a few instances where I either had to self-define some types or leave them as TO-DOs for future.

Have segregated the types of files by commits so can be reviewed commit by commit.

@mujahidkay mujahidkay force-pushed the type-enforcing-dapp-contracts branch 3 times, most recently from 3396f5e to 731c00a Compare September 25, 2024 17:24
@mujahidkay mujahidkay self-assigned this Sep 25, 2024
@mujahidkay mujahidkay force-pushed the type-enforcing-dapp-contracts branch 4 times, most recently from 7e7a9fd to 2ff18df Compare September 26, 2024 13:50
@mujahidkay mujahidkay marked this pull request as ready for review September 26, 2024 14:27
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.

Great progress!

contract/tsconfig.json Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

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

I was confused about the first commit being Update yarn.lock when I didn't see anything that would cause it to update.

Please squash that into this commit that makes the yarn.lock change

@@ -59,7 +59,7 @@ const makeTranslationTable = (makeSlot, makeVal) => {
return harden({ convertValToSlot, convertSlotToVal });
};

/** @type {(slot: string, iface: string | undefined) => any} */
/** @type {(slot: WildSlot, iface: string | undefined) => any} */
Copy link
Member

Choose a reason for hiding this comment

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

I appreciate the separated commits but the ordering is confusing. This type hasn't been defined yet.

Looking ahead I see its string | null. I think we should stick with that. I have no idea what a "wild slot" is. Sounds fun tho

contract/tools/ui-kit-goals/queryKit.js Outdated Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

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

fix causes a version bump an entry in the changelog that says 'Bug Fix".

Linting is never a bug. Use lint: or chore: for such changes

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll rebase and adjust all commits accordingly. Thanks!

contract/test/mintStable.js Outdated Show resolved Hide resolved
contract/test/test-postalSvc.js Outdated Show resolved Hide resolved
ui/src/components/DisplayAmount.tsx Outdated Show resolved Hide resolved
ui/src/components/PurseAmountInput.tsx Outdated Show resolved Hide resolved
ui/src/components/mint/MintTickets.tsx Outdated Show resolved Hide resolved
@mujahidkay
Copy link
Member Author

mujahidkay commented Sep 30, 2024

@turadg
I've addressed the comments except for #67 (comment) . It wouldn't allow me to type cast it to a Amount<'copyBag'>. I have kept this as is and specified the kind when defining the Brand in Inventory.
Comments addressed upto e192627

The last two commits are just cleanups. I will rebase and squash commits before merging the PR (as per your suggestion).

contract/src/swaparoo.contract.js Outdated Show resolved Hide resolved
contract/test/test-sell-concert-tickets-contract.js Outdated Show resolved Hide resolved
contract/test/test-vote-by-committee.js Outdated Show resolved Hide resolved
/**
* The null slot indicates that identity is not intended to be preserved.
*
* @typedef { string | null } WildSlot
Copy link
Member

Choose a reason for hiding this comment

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

oic, WildSlot predates this PR.

I think it's helpful to have this type named so we can keep the explanation about what null indicates.

To find a better name I went searching in agoric-sdk and it turns out that also has WildSlot.
https://github.com/Agoric/agoric-sdk/blob/2d48e143f54911897e8345e1094ae6d19599bef2/multichain-testing/tools/marshalTables.js#L15

@dckc what's the idea behind the name? WDYT of something like OptionalSlot or MaybeSlot or BoardSlot?

Copy link
Member Author

Choose a reason for hiding this comment

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

"is not intended to be preserved" maybe TempSlot as in, its temporary. I'm fine with whatever you agree on and decide.

Copy link
Member

Choose a reason for hiding this comment

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

I suppose WildSlot meant "either a slot or a wildcard". I like MaybeSlot. I'm a fan of haskell and the Typeclassopedia. But when in Rome... I just checked some typescript docs; there I see "optional". So OptionalSlot, please.

@mujahidkay mujahidkay force-pushed the type-enforcing-dapp-contracts branch from d6c3167 to 65b0ef7 Compare October 1, 2024 22:46
@mujahidkay mujahidkay force-pushed the type-enforcing-dapp-contracts branch from 65b0ef7 to 83d7b03 Compare October 1, 2024 22:46
@mujahidkay mujahidkay merged commit 005b339 into main Oct 1, 2024
2 checks passed
@mujahidkay mujahidkay deleted the type-enforcing-dapp-contracts branch October 1, 2024 22:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants