From 8efaf8178b0f91e5ceaec59996835de31a7f51d1 Mon Sep 17 00:00:00 2001 From: dafuga Date: Wed, 25 Sep 2024 16:19:22 -0700 Subject: [PATCH] chore: updated session kit cleanup: code cleanup --- package.json | 4 ++-- rollup.config.mjs | 3 +-- src/index.ts | 18 +++++++----------- yarn.lock | 22 +++++++++++++++++----- 4 files changed, 27 insertions(+), 20 deletions(-) diff --git a/package.json b/package.json index ebfdd7e..9fa2102 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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", diff --git a/rollup.config.mjs b/rollup.config.mjs index 12796dd..86a4c32 100644 --- a/rollup.config.mjs +++ b/rollup.config.mjs @@ -34,7 +34,6 @@ export default [ format: 'cjs', sourcemap: true, exports: 'named', - inlineDynamicImports: true, }, plugins: [ typescript({target: 'es6'}), @@ -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()], }, ] diff --git a/src/index.ts b/src/index.ts index 667d25f..5aeac2a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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 } /** @@ -57,9 +62,6 @@ export class WalletPluginWombat extends AbstractWalletPlugin implements WalletPl */ async login(context: LoginContext): Promise { const scatterProtocol = await this.loadScatterProtocol() - if (!scatterProtocol) { - throw new Error('Scatter protocol is not available in this environment') - } return scatterProtocol.handleLogin(context) } @@ -71,9 +73,6 @@ export class WalletPluginWombat extends AbstractWalletPlugin implements WalletPl */ async logout(context: LogoutContext): Promise { const scatterProtocol = await this.loadScatterProtocol() - if (!scatterProtocol) { - throw new Error('Scatter protocol is not available in this environment') - } return scatterProtocol.handleLogout(context) } @@ -89,9 +88,6 @@ export class WalletPluginWombat extends AbstractWalletPlugin implements WalletPl context: TransactContext ): Promise { const scatterProtocol = await this.loadScatterProtocol() - if (!scatterProtocol) { - throw new Error('Scatter protocol is not available in this environment') - } return scatterProtocol.handleSignatureRequest(resolved, context) } } diff --git a/yarn.lock b/yarn.lock index dab827d..5b63394 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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" @@ -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"