The window.leap.enable(chainIds) method redirects to the extension login page if it is locked. If the user hasn't permitted the webpage, it will ask the user to enable the webpage to access Leap.
window.leap.enable(chainId: string | Array<string>)// you can pass a list of chainIds to get approval for multiple chains in one requestwindow.leap.enable(['chainId1','chainId2'])
Note: In a case where multiple wallets are imported, users can select the wallet/wallets that are supposed to be enabled.
Get Key:
If the webpage has permission and Leap wallet is unlocked, this function will return the address and public key in the following format:
Like signAmino method of CosmJS OfflineDirectSigner, however, Leap's signAmino function takes the chain-id as a required parameter. Signs Amino-encoded StdSignDoc.
interfaceSignOptions {// If set to true the wallet will not override fees specified in the signDoc. preferNoSetFee:boolean} signAmino(chainId: string, signer: string, signDoc: StdSignDoc, signOptions?: SignOptions): Promise<AminoSignResponse>
Sign Direct / Protobuf:
Like signDirect method of CosmJS OfflineDirectSigner, however, Leap's signDirect function takes the chain-id as a required parameter. Signs Proto-encoded StdSignDoc.
interfaceSignDoc { bodyBytes?:Uint8Array|null; authInfoBytes?:Uint8Array|null; chainId?:string|null; accountNumber?:Long|null;}interfaceSignOptions {// If set to true the wallet will not override fees specified in the signDoc. preferNoSetFee:boolean} signDirect(chainId:string, signer:string, signDoc: SignDoc, signOptions?: SignOptions): Promise<DirectSignResponse>
Webpages can use this function to delegate the broadcasting of the transaction to LCD endpoints configured in the leap wallet. If the broadcast is successful, this method will return the transaction hash. Otherwise, it will throw an error.
Leap’s API is similar to Keplr's to keep the integration of leap for the dApp as easy as possible.
import { GasPrice, SigningStargateClient } from'@cosmjs/stargate'awaitwindow.leap.enable(chainId);constsignOptions= {// set this to true to prevent leap from overriding the fees. preferNoFeeSet:false}constofflineSigner=window.leap.getOfflineSigner(chainId, signOptions);constaccounts=awaitofflineSigner.getAccounts();constrpcUrl=""// Replace with a RPC URL for the given chainIdconstsigningStargateClient=awaitSigningStargateClient.connectWithSigner( rptycUrl, offlineSigner, { gasPrice:GasPrice.fromString("0.0025ujuno"), })