Skip to main content

WalletConnectHelper

public class WalletConnectHelper extends Object

package com.onekosmos.blockid.sdk.walletconnect


A singleton class that provides the following application features:

  • Connect BlockID SDK wallet to DApps
  • Transaction signing
  • Personal signing

Prerequisites

  • WalletConnect Project ID
    1. Register a project into the WalletConnect Cloud application (https://cloud.walletconnect.com/app) to get the Project ID for your project
    2. The Project ID allows you to start using the relay network immediately, and is needed during SDK initialization

Method Summary

TypeNameDescription
voidapproveConnection(@NonNull Sign.Model.SessionProposal sessionProposal)Approves the requested session. A session is created between the proposer and responder.
voidapproveSession(@NonNull Sign.Model.SessionRequest sessionRequest)Signs the transaction for a given session. Allowed methods are eth_signTransaction and personal_sign in the SessionRequest object.
voidconnect(@NonNull String uri)Connect a client with a URI generated by the proposer.
voiddisconnect(@NonNull Sign.Model.Session session)Disconnect the given active session.
List<Sign.Model.Session>getActiveSessions()Returns list of active sessions.
WalletConnectHelpergetInstance()Creates and returns a singleton instance of the WalletConnectHelper class.
voidinitialize(@NonNull Application application, @NonNull String projectID, @NonNull Sign.Model.AppMetaData metadata, @NonNull WalletConnectCallback callback)Initializes the object based on given project id and application metadata.
voidrejectConnection(@NonNull Sign.Model.SessionProposal sessionProposal)Rejects the requested proposal session.
voidrejectSession(@NonNull Sign.Model.SessionRequest sessionRequest)Rejects the transaction for a given session.

Method Detail

approveConnection

public void approveConnection(@NonNull Sign.Model.SessionProposal sessionProposal)

  • Approves the requested session. A session is created between the proposer and responder.
Parameters
sessionProposalSign.Model.SessionProposal: Session proposal

approveSession

public void approveSession(@NonNull Sign.Model.SessionRequest sessionRequest)

  • Signs the transaction for a given session. Allowed methods are eth_signTransaction and personal_sign in the SessionRequest object.
Parameters
sessionRequestSign.Model.SessionRequest : Session request

connect

public void connect(@NonNull String uri)

  • Connect a client with a URI generated by the proposer.
Parameters
uriString: Connection uri

disconnect

public void disconnect(@NonNull Sign.Model.Session session)

  • Disconnect the given active session.
Parameters
sessionSign.Model.Session: Session to be disconnect

getActiveSessions

public List<Sign.Model.Session> getActiveSessions()

  • Returns list of active sessions.

approveConnection

public static WalletConnectHelper getInstance()

  • Creates and returns a singleton instance of the WalletConnectHelper class.

initialize

public void initialize(@NonNull Application application, @NonNull String projectID, @NonNull Sign.Model.AppMetaData metadata, @NonNull WalletConnectCallback callback)

  • Initializes the object based on given project id and application metadata.
Parameters
applicationApplication: Application object
projectIDString: Project ID
metadataSign.Model.AppMetaData : App meta data information
callbackWalletConnectCallback: The block to execute when events related to wallet connect/ disconnect, transaction and personal signing requests.

rejectConnection

public void rejectConnection(@NonNull Sign.Model.SessionProposal sessionProposal)

  • Rejects the requested proposal session.
Parameters
sessionProposalSign.Model.SessionProposal: Session proposal

rejectSession

public void rejectSession(@NonNull Sign.Model.SessionRequest sessionRequest)

  • Rejects the transaction for a given session.
Parameters
sessionRequestSign.Model.SessionRequest : Session request