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

CAIP-222/ReCaps #1272

Merged
merged 28 commits into from
Feb 2, 2024
Merged

CAIP-222/ReCaps #1272

merged 28 commits into from
Feb 2, 2024

Conversation

jakubuid
Copy link
Contributor

@jakubuid jakubuid commented Jan 5, 2024

@jakubuid jakubuid changed the title ReCaps CAIP-222/ReCaps Jan 5, 2024
Copy link

github-actions bot commented Jan 5, 2024

Qodana Community for Android

42 new problems were found

Inspection name Severity Problems
Constant conditions 🔶 Warning 26
Serializable object must implement 'readResolve' 🔶 Warning 10
Control flow with empty body 🔶 Warning 1
JUnit malformed declaration 🔶 Warning 1
Constant conditions ◽️ Notice 3
Argument could be converted to 'Set' to improve performance ◽️ Notice 1
View the detailed Qodana report

To be able to view the detailed Qodana report, you can either:

  1. Register at Qodana Cloud and configure the action
  2. Use GitHub Code Scanning with Qodana
  3. Host Qodana report at GitHub Pages
  4. Inspect and use qodana.sarif.json (see the Qodana SARIF format for details)

To get *.log files or any other Qodana artifacts, run the action with upload-result option set to true,
so that the action will upload the files as the job artifacts:

      - name: 'Qodana Scan'
        uses: JetBrains/[email protected]
        with:
          upload-result: true
Contact Qodana team

Contact us at [email protected]

@jakubuid jakubuid marked this pull request as ready for review January 5, 2024 15:44
@jakubuid jakubuid requested review from kacperoak, Elyniss, Talhaali00 and a team as code owners January 5, 2024 15:44
Comment on lines 88 to 90
if (resources?.find { r -> r.startsWith(RECAPS_PREFIX) } != null) message += "\nI further authorize the stated URI to perform the following actions on my behalf: (1) $actionsString for '${
Issuer(iss).namespace
}'\n"
Copy link
Contributor

@Elyniss Elyniss Jan 5, 2024

Choose a reason for hiding this comment

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

I think the part where you only specify (1) resource might be wrong. It only works if there is one resource.

Could there be multiple namespaces defined for one cacao? If yes then this will generate invalid statement

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We support for now only a single namespace that's why (1) is hardcoded

// multi-namespace should error 
const { uri, response } = await dapp.sessionAuthenticate({
      chains: ["eip155:1", "cosmos:1"],
      domain: "localhost",
      nonce: "1",
      aud: "aud",
      methods: ["personal_sign", "eth_signTypedData_v4"],
    });

// this is fine
    const { uri, response } = await dapp.sessionAuthenticate({
      chains: ["eip155:1", "eip155:137"],
      domain: "localhost",
      nonce: "1",
      aud: "aud",
      methods: ["personal_sign", "eth_signTypedData_v4"],
    });
// this is fine
    const { uri, response } = await dapp.sessionAuthenticate({
      chains: ["cosmos:1", "cosmos:2"],
      domain: "localhost",
      nonce: "1",
      aud: "aud",
      methods: ["personal_sign", "eth_signTypedData_v4"],
    });

Comment on lines 87 to 90
if (statement != null) message += "$statement\n"
if (resources?.find { r -> r.startsWith(RECAPS_PREFIX) } != null) message += "\nI further authorize the stated URI to perform the following actions on my behalf: (1) $actionsString for '${
Issuer(iss).namespace
}'\n"
Copy link
Contributor

@Elyniss Elyniss Jan 5, 2024

Choose a reason for hiding this comment

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

As per specs statement part of the SIWE MUST NOT contain \n source. Current code results too many new lines.

Cacao.Payload statement is not the same as SIWE statement

Copy link
Contributor

Choose a reason for hiding this comment

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

Currenlty it generates:

service.invalid wants you to sign in with your Ethereum account:
0x15bca56b6e2728aec2532df9d436bd1600e86688

I accept the ServiceOrg Terms of Service: https://service.invalid/tos

I further authorize the stated URI to perform the following actions on my behalf: (1) 'request': 'eth_signTypedData_v4', 'personal_sign' for 'eip155'

URI: https://service.invalid/login
Version: 1
Chain ID: 1
Nonce: 32891756

Wheras it should be:

service.invalid wants you to sign in with your Ethereum account:
0x15bca56b6e2728aec2532df9d436bd1600e86688

I accept the ServiceOrg Terms of Service: https://service.invalid/tos I further authorize the stated URI to perform the following actions on my behalf: (1) 'request': 'eth_signTypedData_v4', 'personal_sign' for 'eip155'

URI: https://service.invalid/login
Version: 1
Chain ID: 1
Nonce: 32891756

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, ty

Copy link
Contributor

@kacperoak kacperoak left a comment

Choose a reason for hiding this comment

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

There is a lot new todos, make sure you really want to leave them all

Copy link
Contributor

@Talhaali00 Talhaali00 left a comment

Choose a reason for hiding this comment

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

Verify that all public methods are backwards compatible. Instead of changing the function names, create new functions and deprecate old.

Comment on lines -24 to -25
@Json(name = "caip222Response")
val caip222Response: List<Cacao>,
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we still keep this for backwards compatibility?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, it's a new method that has changed during development

val actions: MutableMap<String, MutableList<String>> = mutableMapOf()

for (i in 0 until requests.length()) {
val actionString = requests.getJSONObject(i).keys().next() as String
Copy link
Contributor

Choose a reason for hiding this comment

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

regarding the Qodana warning, can we just do next().toString() instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup

Copy link
Contributor

Choose a reason for hiding this comment

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

please address lint warnings on this file

val payloadParams: PayloadAuthRequestParams,
) : Model()

data class Participant(
Copy link
Contributor

Choose a reason for hiding this comment

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

can this be a child class of SessionAuthenticated?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup

)

data class Participant(
Copy link
Contributor

Choose a reason for hiding this comment

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

same question, can this be moved to SessionAuthenticate?

Copy link
Contributor

Choose a reason for hiding this comment

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

instead of just renaming the functions, we should deprecate the old functions and then create the new ones. Otherwise current implementers will see crashes in their apps

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These are not on production

Copy link
Contributor

Choose a reason for hiding this comment

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

make internal

@Talhaali00
Copy link
Contributor

Also, try to address as many of the linter wanrings

…nV2 into sign_2.5_recaps

# Conflicts:
#	core/android/src/main/kotlin/com/walletconnect/android/internal/utils/Expiration.kt
#	product/walletconnectmodal/src/main/kotlin/com/walletconnect/wcmodal/client/ClientMapper.kt
#	product/walletconnectmodal/src/main/kotlin/com/walletconnect/wcmodal/client/Modal.kt
#	product/walletconnectmodal/src/main/kotlin/com/walletconnect/wcmodal/client/WalletConnectModal.kt
#	product/walletconnectmodal/src/main/kotlin/com/walletconnect/wcmodal/domain/WalletConnectModalDelegate.kt
#	product/web3modal/src/main/kotlin/com/walletconnect/web3/modal/client/ClientMapper.kt
#	product/web3modal/src/main/kotlin/com/walletconnect/web3/modal/client/Web3Modal.kt
#	product/web3modal/src/main/kotlin/com/walletconnect/web3/modal/domain/delegate/Web3ModalDelegate.kt
#	protocol/sign/src/androidTest/kotlin/com/walletconnect/sign/test/utils/dapp/DappDelegate.kt
#	protocol/sign/src/androidTest/kotlin/com/walletconnect/sign/test/utils/hybrid/HybridDelegate.kt
#	protocol/sign/src/main/kotlin/com/walletconnect/sign/client/SignInterface.kt
#	protocol/sign/src/main/kotlin/com/walletconnect/sign/client/SignProtocol.kt
#	protocol/sign/src/main/kotlin/com/walletconnect/sign/common/exceptions/SignExceptions.kt
#	protocol/sign/src/main/kotlin/com/walletconnect/sign/common/model/vo/clientsync/session/params/SignParams.kt
#	protocol/sign/src/main/kotlin/com/walletconnect/sign/di/CallsModule.kt
#	protocol/sign/src/main/kotlin/com/walletconnect/sign/di/EngineModule.kt
#	protocol/sign/src/main/kotlin/com/walletconnect/sign/engine/domain/SignEngine.kt
#	protocol/sign/src/main/kotlin/com/walletconnect/sign/engine/model/mapper/EngineMapper.kt
#	protocol/sign/src/main/kotlin/com/walletconnect/sign/engine/use_case/calls/ApproveSessionUseCase.kt
#	protocol/sign/src/main/sqldelight/databases/8.db
#	sample/dapp/src/main/kotlin/com/walletconnect/sample/dapp/domain/DappDelegate.kt
#	sample/modal/src/main/kotlin/com/walletconnect/sample/modal/ModalSampleDelegate.kt
Copy link

github-actions bot commented Jan 25, 2024

Qodana Community for Android

56 new problems were found

Inspection name Severity Problems
Constant conditions 🔶 Warning 41
Serializable object must implement 'readResolve' 🔶 Warning 10
Control flow with empty body 🔶 Warning 1
JUnit malformed declaration 🔶 Warning 1
Constant conditions ◽️ Notice 2
Argument could be converted to 'Set' to improve performance ◽️ Notice 1
View the detailed Qodana report

To be able to view the detailed Qodana report, you can either:

  1. Register at Qodana Cloud and configure the action
  2. Use GitHub Code Scanning with Qodana
  3. Host Qodana report at GitHub Pages
  4. Inspect and use qodana.sarif.json (see the Qodana SARIF format for details)

To get *.log files or any other Qodana artifacts, run the action with upload-result option set to true,
so that the action will upload the files as the job artifacts:

      - name: 'Qodana Scan'
        uses: JetBrains/[email protected]
        with:
          upload-result: true
Contact Qodana team

Contact us at [email protected]

…nV2 into sign_2.5_recaps

# Conflicts:
#	product/web3modal/src/main/kotlin/com/walletconnect/web3/modal/client/Modal.kt
#	product/web3modal/src/main/kotlin/com/walletconnect/web3/modal/client/Web3Modal.kt
…inV2 into sign_2.5_recaps

# Conflicts:
#	product/walletconnectmodal/src/main/kotlin/com/walletconnect/wcmodal/client/ClientMapper.kt
#	product/walletconnectmodal/src/main/kotlin/com/walletconnect/wcmodal/client/WalletConnectModal.kt
#	product/walletconnectmodal/src/main/kotlin/com/walletconnect/wcmodal/domain/WalletConnectModalDelegate.kt
#	product/web3modal/src/main/kotlin/com/walletconnect/web3/modal/client/ClientMapper.kt
#	product/web3modal/src/main/kotlin/com/walletconnect/web3/modal/domain/delegate/Web3ModalDelegate.kt
#	product/web3modal/src/main/kotlin/com/walletconnect/web3/modal/engine/Web3ModalEngine.kt
#	protocol/sign/src/androidTest/kotlin/com/walletconnect/sign/test/utils/hybrid/HybridDelegate.kt
#	protocol/sign/src/main/kotlin/com/walletconnect/sign/client/SignInterface.kt
#	protocol/sign/src/main/kotlin/com/walletconnect/sign/client/SignProtocol.kt
#	protocol/sign/src/main/kotlin/com/walletconnect/sign/common/exceptions/SignExceptions.kt
#	protocol/sign/src/main/kotlin/com/walletconnect/sign/common/model/vo/clientsync/session/params/SignParams.kt
#	protocol/sign/src/main/kotlin/com/walletconnect/sign/engine/model/mapper/EngineMapper.kt
#	protocol/sign/src/main/kotlin/com/walletconnect/sign/engine/use_case/calls/ApproveSessionAuthenticateUseCase.kt
#	protocol/sign/src/main/kotlin/com/walletconnect/sign/engine/use_case/calls/SessionAuthenticateUseCase.kt
#	protocol/sign/src/main/kotlin/com/walletconnect/sign/engine/use_case/responses/OnSessionAuthenticateResponseUseCase.kt
#	sample/dapp/src/main/kotlin/com/walletconnect/sample/dapp/domain/DappDelegate.kt
@jakubuid
Copy link
Contributor Author

There is a lot new todos, make sure you really want to leave them all

Yeah I do, we're merging to a feature branch so before merging this feature branch to develop, all the TODOs will be resolved

@jakubuid jakubuid merged commit 92b3c1b into sign_2.5 Feb 2, 2024
2 checks passed
@jakubuid jakubuid deleted the sign_2.5_recaps branch February 2, 2024 06: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.

4 participants