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

walletlib + fakewallet updates #574

Merged
merged 15 commits into from
Oct 23, 2023
Merged

Conversation

Funkatronics
Copy link
Contributor

@Funkatronics Funkatronics commented Oct 17, 2023

This PR has been used to cut alpha builds quickly. This PR only touches walletlib (and fakewallet)

summary of changes:

  • updated authorize request and response with all the latest spec changes ([TBD] Align with upcoming wallet-standard connect feature #562 & Align with wallet-standard WalletAccount interface #563)
  • updated fakewallet to use the new 2.0 spec params, and adds app flavors for V1 and Legacy protocol versions
  • we now hide the protocol version from consumers: consumption of the 2.x SDK enforces the new protocol version and internally handles backwards compat so there is no need to expose this.
  • separate reauthorize stuff has now been removed from MobileWalletAdapterServer completely. The scenario still exposes reauthorize and handles authorize/reauthorize internally so things remain the same for consumers.

Most relevant files:

@Funkatronics
Copy link
Contributor Author

ran automated tests locally and passed.

@@ -353,14 +368,25 @@ class MobileWalletAdapterViewModel(application: Application) : AndroidViewModel(
}
}

private fun clusterToRpcUri(cluster: String?): Uri {
return when (cluster) {
private fun buildAccount(publicKey: ByteArray, label: String, icon: Uri? = null,
Copy link
Contributor

Choose a reason for hiding this comment

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

Whats the need for this method if it just returns an AuthorizedAccount constructor?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

convenience

protected final String[] mFeatures;

@Nullable
protected final String[] mAddresses;
Copy link
Contributor

Choose a reason for hiding this comment

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

addresses is how the way for dApp to request authorization for certain bs58 pubkeys/addresses correct?

Does this act as a signal for the wallet to attempt to reauthorize the dapp for these addresses?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, tho its not the same as MWA spec reauthorize. its a clue to the wallet as to what addresses the dapp is looking to use for the session.

this.features = features;
}

public AuthorizedAccount(@NonNull byte[] publicKey,
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the usecase for the two different constructors?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

displayAddress/Format are more a a multichain relevancy thing, so today no one will be using them. so adding the extra constructor is just a convenience

@@ -333,75 +325,6 @@ private void doReauthorize(@NonNull MobileWalletAdapterServer.AuthorizeRequest r
authRecord.chain, authRecord.scope)));
}

@Override
Copy link
Contributor

Choose a reason for hiding this comment

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

I thought reauthorize was still used internally? But here we're deleting it?

Can you outline the new flow for reauthorize from the consumer dapp -> wallet?

Copy link
Contributor

Choose a reason for hiding this comment

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

Nevermind, answered my own question. authorize now calls doReauthorize under the hood, and this public reauthorize method isn't needed.

// =============================================================================================

// NOTE: future may be either AuthorizeRequest or ReauthorizeRequest
private void handleAuthorize(@Nullable Object id, @Nullable Object params) throws IOException {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is the entrypoint for where the authorize request enters the wallet.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah this is where we handle the RPC request

@NonNull String chain) {
@NonNull String chain,
@Nullable String[] features,
@Nullable String[] addresses) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is the authToken parameter gone from this AuthorizeRequest?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it was always null, so it made no sense to pass it to the client. If the authToken is present, the reauthorize callback is triggered instead.

@Nullable String chain,
@Nullable String[] features,
@Nullable String[] addresses,
@Nullable String authToken) {
Copy link
Contributor

Choose a reason for hiding this comment

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

authToken is present in this AuthorizeRequest

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 authorize method now takes an optional authToken param in the 2.0 spec, so that needs to be added here so that we can pass it to the scenario

@Funkatronics Funkatronics merged commit 7f3126e into main Oct 23, 2023
8 checks passed
@Funkatronics Funkatronics deleted the walletlib-expose-authv2-params branch October 23, 2023 21:44
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.

2 participants