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

[NayNay] File Restructure: Signing Restructure #218

Merged
merged 17 commits into from
Aug 29, 2024

Conversation

rh0delta
Copy link
Contributor

@rh0delta rh0delta commented Aug 7, 2024

Related Issue(s)

Proposed Changes

  • created new file structure for signing flow
  • updated tui/cli with new changes

Testing

  • Unit tests added/updated
  • Integration tests added/updated
  • Manual testing performed

Screenshots (if applicable)

Additional Context

Checklist

  • I have performed a self-review of my code.
  • I have added tests.
  • I have commented my code.
  • I have included a CHANGELOG.md entry.
  • I have updated documentation in github.com:entropyxyz/entropy-docs, where necessary.

@rh0delta rh0delta marked this pull request as ready for review August 20, 2024 00:11
Copy link
Contributor

@mixmix mixmix left a comment

Choose a reason for hiding this comment

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

I love the direction and how you've split out commands + types + utils really clearly.

I've listed quite a few smallish things. Sorry it was 2 weeks and now a bunch of change requests, appreciate that might land a bit annoying.
Happy to have a call if you wanna connect + discuss anything (nicer way to resolve opinions sometimes, and can be faster)

src/cli.ts Outdated Show resolved Hide resolved
@@ -0,0 +1,37 @@
export const FLOW_CONTEXT = 'ENTROPY_SIGNING'
Copy link
Contributor

@mixmix mixmix Aug 21, 2024

Choose a reason for hiding this comment

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

🔥 in our design work #94 / https://hackmd.io/g4Tpy6R_Tym-hLUWhlF-ng?view we agreed to call our folders like entropy-sign (and the man-page style name for the command is then entropy-sign)

Request/ Proposal:

  • rename folder entropy-sign sign
  • rename the FLOW_CONTEXT to ENTROPY_SIGN
  • rename the class from SignCommand to EntropySign

Copy link
Contributor

@mixmix mixmix Aug 27, 2024

Choose a reason for hiding this comment

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

Still relevant.
Want the folder to reflect the command name (sign, not signing)

src/signing/constants.ts Outdated Show resolved Hide resolved
src/signing/types.ts Outdated Show resolved Hide resolved
src/signing/command.ts Outdated Show resolved Hide resolved
src/signing/command.ts Outdated Show resolved Hide resolved
src/signing/command.ts Outdated Show resolved Hide resolved
src/signing/command.ts Outdated Show resolved Hide resolved
src/signing/command.ts Outdated Show resolved Hide resolved
src/signing/utils.ts Outdated Show resolved Hide resolved
@rh0delta rh0delta linked an issue Aug 23, 2024 that may be closed by this pull request
@rh0delta rh0delta requested a review from mixmix August 23, 2024 18:05
Copy link
Contributor

@mixmix mixmix left a comment

Choose a reason for hiding this comment

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

Review 2.

Looking good. There are a few things that are style things (like I want the core functionality all in the main.ts file, not hidden elsewhere, and variable renames), and there are also so gotchas which will cause problems 🔥

The scope creep with new features is starting to burn a bit much.

  • I don't want to say again that msg/msgPath doesn't work needs more design
  • rawSign is also new (I think)

please revert these. We need this mega branch merged and I don't want to stop to discuss those things 🙏 ❤️
I am real happy to revisit those as simple little side quests after this is merged


NOTE: this PR currently doesn't work with fresh installs! (no accounts = no default selected nor selectable account = throws)

src/balance/command.ts Outdated Show resolved Hide resolved
src/balance/command.ts Outdated Show resolved Hide resolved
src/balance/main.ts Outdated Show resolved Hide resolved
// .default(process.env.ENTROPY_SESSION)
}

export async function loadEntropy (entropy: Entropy | undefined, address: string, endpoint: string, password?: string): Promise<Entropy> {
Copy link
Contributor

Choose a reason for hiding this comment

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

🔥 why does this take entropy as an argument - we don't use it internally for anything... other than reassigning it which ... I don't even know if that does anything outside the scope of this function, ... and if it does ... then maybe don't (mutating inputs is a pattern that will get you burnt)

Strong request to remove entropy as an argument

src/common/utils-cli.ts Outdated Show resolved Hide resolved
src/signing/main.ts Outdated Show resolved Hide resolved
src/signing/utils.ts Outdated Show resolved Hide resolved
src/transfer/main.ts Outdated Show resolved Hide resolved
.addOption(passwordOption('Password for the source account (if required)'))
.addOption(endpointOption())
.addOption(currentAccountAddressOption())
.action(async (_source, destination, amount, opts) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

🔥🔥🔥🔥🔥 why do you drop the source here ... if I put in that I wanted to move funds from A => B and instead it moved from selectedAccount => B I would be wild mad.

so this might need more design... as the options I can see are:

  • A. remove source
  • B. require source but then ... have that override the selectedAccount (error if --account is provided too?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the source in this case must be a funded entropy account, since we require the signer pair, not just an address. The source in this case must be provided by the selected account from the config which can be overrided by the current account address option, so i dont see the need for a specific source argument here

src/transfer/utils.ts Outdated Show resolved Hide resolved
@mixmix
Copy link
Contributor

mixmix commented Aug 27, 2024

TODO:

  • fix loadEntropy
  • final review

mixmix and others added 2 commits August 28, 2024 13:12
* tweeeeks

* more tweeks

* fix tests

* rename test

* fix maskPayload

* test fix

* change sign command to just return sig
src/sign/command.ts Outdated Show resolved Hide resolved
src/sign/command.ts Outdated Show resolved Hide resolved
})
}

public async sendTransfer (toAddress: string, amount: string, startProgress?: ()=>void, stopProgress?: ()=>void) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This feels like interaction to me... I don't understand why it exists - if the progress things are optional then this wrapper only does

  • formatting amount
  • logging

I think logging should be in the base transfer anyway ...

Copy link
Contributor

@mixmix mixmix left a comment

Choose a reason for hiding this comment

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

YUSSS. I'm gonna make minor changes then merge

Comment on lines 27 to 30
if (transferStatus.isFinalized) {
if (progress) return progress.stop()
return
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Dropped this check as rawTransfer only ever resolves if isFinalized === true already

Comment on lines 62 to 65
const inputAmount = "1.5"
await run(
'transfer',
TransferService.transfer({
from: charlieEntropy.keyring.accounts.registration.pair,
to: recipientAddress,
amount: BigInt(1000 * 10e10)
})
TransferService.transfer(naynayAddress, inputAmount)
Copy link
Contributor

Choose a reason for hiding this comment

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

Testing the actual "main" function we're using with the input it will be receiving (e.g. "1.5" as a string)

@@ -15,19 +15,17 @@ export class EntropyTransfer extends EntropyBase {
// - progress callbacks (optional)

async transfer (toAddress: string, amount: string, progress?: { start: ()=>void, stop: ()=>void }) {
const formattedAmount = BigInt(parseInt(amount) * 1e10)
const formattedAmount = BigInt(Number(amount) * 1e10)
Copy link
Contributor

Choose a reason for hiding this comment

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

YO! the parseInt here was rounding our inputs.
Also what is our name for this 1e10 ... is that that number of decimal places we support?

@mixmix mixmix merged commit 67045d4 into naynay/file-restructure Aug 29, 2024
2 checks passed
@mixmix mixmix deleted the naynay/signing-restructure branch August 29, 2024 00:44
@github-actions github-actions bot locked and limited conversation to collaborators Aug 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

signing restructure
2 participants