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

Cleanup and updated session kit #19

Merged
merged 1 commit into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"tslib": "^2.1.0"
},
"peerDependencies": {
"@wharfkit/session": "^1.2.2"
"@wharfkit/session": "^1.4.0"
},
"devDependencies": {
"@babel/runtime": "^7.22.6",
Expand All @@ -34,7 +34,7 @@
"@types/node": "^18.7.18",
"@typescript-eslint/eslint-plugin": "^5.20.0",
"@typescript-eslint/parser": "^5.20.0",
"@wharfkit/session": "^1.3.1",
"@wharfkit/session": "^1.4.0",
"chai": "^4.3.4",
"crypto-js": "^4.1.1",
"eslint": "^8.13.0",
Expand Down
3 changes: 1 addition & 2 deletions rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ export default [
format: 'cjs',
sourcemap: true,
exports: 'named',
inlineDynamicImports: true,
},
plugins: [
typescript({target: 'es6'}),
Expand Down Expand Up @@ -68,7 +67,7 @@ export default [
},
{
input: 'src/index.ts',
output: {banner, dir: pkg.types, format: 'esm'},
output: {banner, dir: pkg.types.split('/').slice(0, -1).join('/'), format: 'esm'},
plugins: [dts()],
},
]
18 changes: 7 additions & 11 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,15 @@ export class WalletPluginWombat extends AbstractWalletPlugin implements WalletPl
})

private async loadScatterProtocol() {
let scatterProtocol
if (typeof window !== 'undefined') {
return import('@wharfkit/protocol-scatter')
scatterProtocol = await import('@wharfkit/protocol-scatter')
}
return null

if (!scatterProtocol) {
throw new Error('Scatter protocol is not available in this environment')
}
return scatterProtocol
}

/**
Expand All @@ -57,9 +62,6 @@ export class WalletPluginWombat extends AbstractWalletPlugin implements WalletPl
*/
async login(context: LoginContext): Promise<WalletPluginLoginResponse> {
const scatterProtocol = await this.loadScatterProtocol()
if (!scatterProtocol) {
throw new Error('Scatter protocol is not available in this environment')
}
return scatterProtocol.handleLogin(context)
}

Expand All @@ -71,9 +73,6 @@ export class WalletPluginWombat extends AbstractWalletPlugin implements WalletPl
*/
async logout(context: LogoutContext): Promise<void> {
const scatterProtocol = await this.loadScatterProtocol()
if (!scatterProtocol) {
throw new Error('Scatter protocol is not available in this environment')
}
return scatterProtocol.handleLogout(context)
}

Expand All @@ -89,9 +88,6 @@ export class WalletPluginWombat extends AbstractWalletPlugin implements WalletPl
context: TransactContext
): Promise<WalletPluginSignResponse> {
const scatterProtocol = await this.loadScatterProtocol()
if (!scatterProtocol) {
throw new Error('Scatter protocol is not available in this environment')
}
return scatterProtocol.handleSignatureRequest(resolved, context)
}
}
22 changes: 17 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,18 @@
pako "^2.1.0"
tslib "^2.0.3"

"@wharfkit/antelope@^1.0.11":
version "1.0.12"
resolved "https://registry.yarnpkg.com/@wharfkit/antelope/-/antelope-1.0.12.tgz#e7b8e0e0805a7194fa62cacd3dfb662b18aa9962"
integrity sha512-Iuqog3rgnW+o8S+Etw5mMto14e1RILIDnRfZAvRS1DOVFgAma6Vv+rT9rJpJq7ldvTBdZu35BImkfwl0iDJCVw==
dependencies:
bn.js "^4.11.9"
brorand "^1.1.0"
elliptic "^6.5.4"
hash.js "^1.0.0"
pako "^2.1.0"
tslib "^2.0.3"

"@wharfkit/antelope@^1.0.4":
version "1.0.7"
resolved "https://registry.yarnpkg.com/@wharfkit/antelope/-/antelope-1.0.7.tgz#5ca010db963e061b2e8c47c14e55f86817718c2e"
Expand Down Expand Up @@ -622,14 +634,14 @@
js-big-decimal "^2.0.7"
tslib "^2.1.0"

"@wharfkit/session@^1.3.1":
version "1.3.1"
resolved "https://registry.yarnpkg.com/@wharfkit/session/-/session-1.3.1.tgz#2cbfa14aafc21abba060e97dab24e9263c78ad6e"
integrity sha512-x+SV14arfhvuiDGyWAH2WIKW7v2WKQ1njc3EzU5ZzE6xVWRfKZ23mqtz83YemQ2h0562+QR712CzX5ZhAcdcpg==
"@wharfkit/session@^1.4.0":
version "1.4.0"
resolved "https://registry.yarnpkg.com/@wharfkit/session/-/session-1.4.0.tgz#13a44a0d23d5ee689755985580f943f869352987"
integrity sha512-U+K9eWbYzFeDshYwgrhyNoF47kYToKFpTe6xFAwaJO+2w0kIkP0vtJFl7ygd06muh7Hu3K1BqrZ3j6+FyyuIyA==
dependencies:
"@wharfkit/abicache" "^1.2.1"
"@wharfkit/account" "^1.0.0"
"@wharfkit/antelope" "^1.0.2"
"@wharfkit/antelope" "^1.0.11"
"@wharfkit/common" "^1.2.0"
"@wharfkit/signing-request" "^3.1.0"
pako "^2.0.4"
Expand Down