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

Add support for signed payloads to the setOptions operation. #534

Closed
wants to merge 4 commits into from

Conversation

Shaptic
Copy link
Contributor

@Shaptic Shaptic commented Jun 8, 2022

While many parts of the SDK have been updated to enable the new signer type from CAP-40, the SetOptions operation has not.

As part of this, new helpers exist:

  function composeSignedPayload(address: string, payload: Buffer): string;
  function decomposeSignedPayload(address: string): { signer: string; payload: Buffer };

which should make it easy to create a P-address from a G-address and a payload and vice-versa.

@Shaptic Shaptic added the bug label Jun 8, 2022
@Shaptic Shaptic requested review from leighmcculloch, kalepail and a team June 8, 2022 19:43
Copy link
Contributor

@kalepail kalepail left a comment

Choose a reason for hiding this comment

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

The ergonomics on this feel way better and a massive +1 for adding the setOptions support. I can't speak to if this should actually get merged as is as I'm not a core SDK contributor but it lgtm from an ergonomics improvement pov.

👏

src/signerkey.js Outdated
*
* @returns {string} the StrKey-encoded signed payload address (P...)
*/
static encodeSignedPayloadFromAddress(address, payload) {
Copy link
Member

Choose a reason for hiding this comment

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

Any reason this can't have a shorter name?

Suggested change
static encodeSignedPayloadFromAddress(address, payload) {
static encodeSignedPayload(address, payload) {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

probably not 🤷 that clashes with StrKey.encodeSignedPayload, but separate namespaces should be enough of a hint that they're different

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ooh how about composeSignedPayload 🎶

Copy link
Member

Choose a reason for hiding this comment

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

What is StrKey.encodeSignedPayload for? It seems like a very low-level thing to expose to developers. We don't expose it in other SDKs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

All of the StrKey functions in the SDK convert between raw buffers and strkeys. I'm not a fan and it deserves a refactor to line up more w/ the other SDK implementations, but that's historical.

Copy link
Member

Choose a reason for hiding this comment

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

I think the historic reason was fine because once-upon-a-time all strkeys were just a single 32byte buffer.

It's unintuitive to me that a user must use a SignerKey object to generate a strkey. Maybe we should do soemthing like what we did with MuxedAccounts, where you create a SignedPayloadSigner which is an object that sits apart, and then you can generate a SignerKey from it.

*
* @returns {string} the StrKey-encoded signed payload address (P...)
*/
static composeSignedPayload(address, payload) {
Copy link
Member

Choose a reason for hiding this comment

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

Can we name this function encodeSignedPayload? It fits existing terms used in the SignerKey type and doesn't clash with any existing function. Using a new term compose seems unnecessary.

src/signerkey.js Outdated
*
* @returns {string} the StrKey-encoded signed payload address (P...)
*/
static encodeSignedPayloadFromAddress(address, payload) {
Copy link
Member

Choose a reason for hiding this comment

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

I think the historic reason was fine because once-upon-a-time all strkeys were just a single 32byte buffer.

It's unintuitive to me that a user must use a SignerKey object to generate a strkey. Maybe we should do soemthing like what we did with MuxedAccounts, where you create a SignedPayloadSigner which is an object that sits apart, and then you can generate a SignerKey from it.

@orbitlens
Copy link
Contributor

orbitlens commented Sep 2, 2022

Just realized that my PR #542 was intended to solve the same problem. Wish I'd done more comprehensive search before writing the code. There were no mentions of this PR in the issue tracker.

Is there any ETA? Quite a high-priority issue for us. Can we go at least with a simple MVP that allows to build a transaction plus correctly parse tx XDRs, and implement additional tooling later given that there's no consensus on methods naming?

@leighmcculloch
Copy link
Member

Looks like this PR fell through the cracks, it was intended to go out when protocol 19 was released. cc @Shaptic

@Shaptic
Copy link
Contributor Author

Shaptic commented Oct 4, 2022

I think we can close this in lieu of the merged-and-released #542. If usability and ergonomics become a concern, we can revisit this design.

@Shaptic Shaptic closed this Oct 4, 2022
@Shaptic Shaptic deleted the cap40-set-options branch June 13, 2023 22:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants