Skip to content

Commit

Permalink
Add logout support
Browse files Browse the repository at this point in the history
  • Loading branch information
apporc committed May 1, 2024
1 parent 9184151 commit 8e9a7d5
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
AbstractWalletPlugin,
LoginContext,
LogoutContext,

Check failure on line 4 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js v14

'"@wharfkit/session"' has no exported member named 'LogoutContext'. Did you mean 'LoginContext'?

Check failure on line 4 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js v16

'"@wharfkit/session"' has no exported member named 'LogoutContext'. Did you mean 'LoginContext'?

Check failure on line 4 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js v18

'"@wharfkit/session"' has no exported member named 'LogoutContext'. Did you mean 'LoginContext'?
ResolvedSigningRequest,
TransactContext,
WalletPlugin,
Expand All @@ -9,7 +10,7 @@ import {
WalletPluginMetadata,
WalletPluginSignResponse,
} from '@wharfkit/session'
import {handleLogin, handleSignatureRequest} from '@wharfkit/protocol-scatter'
import {handleLogin, handleLogout, handleSignatureRequest} from '@wharfkit/protocol-scatter'

Check failure on line 13 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js v14

Module '"@wharfkit/protocol-scatter"' has no exported member 'handleLogout'.

Check failure on line 13 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js v16

Module '"@wharfkit/protocol-scatter"' has no exported member 'handleLogout'.

Check failure on line 13 in src/index.ts

View workflow job for this annotation

GitHub Actions / Node.js v18

Module '"@wharfkit/protocol-scatter"' has no exported member 'handleLogout'.

export class WalletPluginScatter extends AbstractWalletPlugin implements WalletPlugin {
id = 'scatter'
Expand Down Expand Up @@ -45,7 +46,7 @@ export class WalletPluginScatter extends AbstractWalletPlugin implements WalletP
/**
* Performs the wallet logic required to login and return the chain and permission level to use.
*
* @param options WalletPluginLoginOptions
* @param context LoginContext
* @returns Promise<WalletPluginLoginResponse>
*/
login(context: LoginContext): Promise<WalletPluginLoginResponse> {
Expand All @@ -60,6 +61,25 @@ export class WalletPluginScatter extends AbstractWalletPlugin implements WalletP
})
}

/**
* Performs the wallet logic required to logout.
*
* @param context: LogoutContext
* @returns Promise<void>
*/

logout(context: LogoutContext): Promise<void> {
return new Promise((resolve, reject) => {
handleLogout(context)
.then(() => {
resolve()
})
.catch((error) => {
reject(error)
})
})
}

/**
* Performs the wallet logic required to sign a transaction and return the signature.
*
Expand Down

0 comments on commit 8e9a7d5

Please sign in to comment.