Skip to content

Commit

Permalink
fix: handling ssr
Browse files Browse the repository at this point in the history
  • Loading branch information
dafuga committed Jan 23, 2024
1 parent ec8ad88 commit 33f2da6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
2 changes: 2 additions & 0 deletions rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export default [
sourcemap: true,
exports: 'named',
},
inlineDynamicImports: true,
plugins: [
typescript({target: 'es6'}),
commonjs({
Expand All @@ -54,6 +55,7 @@ export default [
format: 'esm',
sourcemap: true,
},
inlineDynamicImports: true,
plugins: [
typescript({target: 'es2020'}),
commonjs({
Expand Down
20 changes: 18 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ import {
WalletPluginMetadata,
WalletPluginSignResponse,
} from '@wharfkit/session'
import {handleLogin, handleSignatureRequest} from '@wharfkit/protocol-scatter'
import {ScatterEOS, ScatterJS} from 'scatter-ts'

let handleLogin: any
let handleSignatureRequest: any

export class WalletPluginScatter extends AbstractWalletPlugin implements WalletPlugin {
id = 'scatter'
Expand All @@ -30,6 +31,21 @@ export class WalletPluginScatter extends AbstractWalletPlugin implements WalletP

constructor() {
super()
this.loadScatterProtocol()

this.intializeScatter()
}

async loadScatterProtocol() {
const scatterProtocol = await import('@wharfkit/protocol-scatter');

handleLogin = scatterProtocol.handleLogin
handleSignatureRequest = scatterProtocol.handleSignatureRequest
}

async intializeScatter() {
const { ScatterEOS, ScatterJS } = await import('scatter-ts');

ScatterJS.plugins(new ScatterEOS())
}

Expand Down

0 comments on commit 33f2da6

Please sign in to comment.