Skip to content

Commit f5c2599

Browse files
authored
Various Fixes (#11)
* Updating Wharf * Update yarn.lock * Added required translations * Correctly pass the translation helper * Pass the ID, not name * Add JSON bundler
1 parent f724b6e commit f5c2599

File tree

10 files changed

+45
-12
lines changed

10 files changed

+45
-12
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@
4242
"@types/node": "^18.7.18",
4343
"@typescript-eslint/eslint-plugin": "^5.20.0",
4444
"@typescript-eslint/parser": "^5.20.0",
45-
"@wharfkit/mock-data": "^1.0.0",
46-
"@wharfkit/session": "next",
45+
"@wharfkit/mock-data": "^1.3.0",
46+
"@wharfkit/session": "^1.6.0",
4747
"chai": "^4.3.4",
4848
"eslint": "^8.13.0",
4949
"eslint-config-prettier": "^8.1.0",

rollup.config.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import dts from 'rollup-plugin-dts'
33
import typescript from '@rollup/plugin-typescript'
44

55
import pkg from './package.json'
6+
import json from '@rollup/plugin-json'
67

78
const name = pkg.name
89
const license = fs.readFileSync('LICENSE').toString('utf-8').trim()
@@ -29,7 +30,7 @@ export default [
2930
sourcemap: true,
3031
exports: 'named',
3132
},
32-
plugins: [typescript({target: 'es6'})],
33+
plugins: [typescript({target: 'es6'}), json()],
3334
external,
3435
},
3536
{
@@ -40,7 +41,7 @@ export default [
4041
format: 'esm',
4142
sourcemap: true,
4243
},
43-
plugins: [typescript({target: 'es2020'})],
44+
plugins: [typescript({target: 'es2020'}), json()],
4445
external,
4546
},
4647
{

src/index.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ import {PrivateKey, PublicKey, UInt64} from '@wharfkit/antelope'
2626
import {sealMessage} from '@wharfkit/sealed-messages'
2727
import WebSocket from 'isomorphic-ws'
2828

29+
import defaultTranslations from './translations'
30+
2931
interface WebAuthenticatorOptions {
3032
/** The URL of the web authenticator service */
3133
webAuthenticatorUrl?: string
@@ -79,6 +81,11 @@ export class WalletPluginWebAuthenticator extends AbstractWalletPlugin implement
7981
return 'web-authenticator'
8082
}
8183

84+
/**
85+
* The translations for this plugin
86+
*/
87+
translations = defaultTranslations
88+
8289
/**
8390
* Opens a popup window with the given URL and waits for it to complete
8491
*/
@@ -92,6 +99,8 @@ export class WalletPluginWebAuthenticator extends AbstractWalletPlugin implement
9299
// Show status message using WharfKit UI
93100
ui?.status('Opening authenticator popup...')
94101

102+
const t = ui?.getTranslate(this.id)
103+
95104
let popup: Window | null = null
96105

97106
popup = window.open(url, 'Web Authenticator', 'width=450,height=750')
@@ -115,7 +124,7 @@ export class WalletPluginWebAuthenticator extends AbstractWalletPlugin implement
115124
}
116125
}, 1000)
117126

118-
waitForCallback(receiveOptions, this.buoyWs, 30000)
127+
waitForCallback(receiveOptions, this.buoyWs, t)
119128
.then((response) => {
120129
clearInterval(checkClosed)
121130
popup?.close()
@@ -276,7 +285,7 @@ export class WalletPluginWebAuthenticator extends AbstractWalletPlugin implement
276285

277286
const signUrl = `${this.webAuthenticatorUrl}/sign?sealed=${sealedRequest.toString(
278287
'hex'
279-
)}&nonce=${nonce.toString()}&chain=${context.chain?.name}&accountName=${
288+
)}&nonce=${nonce.toString()}&chain=${context.chain?.id}&accountName=${
280289
context.accountName
281290
}&permissionName=${context.permissionName}&appName=${
282291
context.appName

src/translations/en.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"error": {
3+
"expired": "The request expired, please try again.",
4+
"invalid_response": "Invalid response from wallet, must contain link_ch, link_key, link_name and cid flags.",
5+
"not_completed": "The request was not completed.",
6+
"cancelled": "The request was cancelled."
7+
}
8+
}

src/translations/index.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import en from './en.json'
2+
import ko from './ko.json'
3+
import zh_hans from './zh-hans.json'
4+
import zh_hant from './zh-hant.json'
5+
6+
export default {
7+
en,
8+
ko,
9+
'zh-Hans': zh_hans,
10+
'zh-Hant': zh_hant,
11+
}

src/translations/ko.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

src/translations/zh-hans.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

src/translations/zh-hant.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"noImplicitAny": false,
1212
"sourceMap": true,
1313
"strict": true,
14-
"target": "es2020"
14+
"target": "es2020",
15+
"resolveJsonModule": true,
1516
},
1617
"include": ["src/**/*"]
1718
}

yarn.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,7 @@
662662
"@wharfkit/signing-request" "^3.1.0"
663663
tslib "^2.1.0"
664664

665-
"@wharfkit/mock-data@^1.0.0":
665+
"@wharfkit/mock-data@^1.3.0":
666666
version "1.3.0"
667667
resolved "https://registry.yarnpkg.com/@wharfkit/mock-data/-/mock-data-1.3.0.tgz#7a9caa7c7fb2ad839bc12593de1b7a546b673ae6"
668668
integrity sha512-LkhAkrUOvG6o+lPWb2Q6JCrs9++F2XowGK42PODh35Xu9an5H+THMGjpUhTC1sPiYkfjhkmBbAzMpZbHjkXj4w==
@@ -721,10 +721,10 @@
721721
pako "^2.0.4"
722722
tslib "^2.1.0"
723723

724-
"@wharfkit/session@next":
725-
version "1.6.0-rc1"
726-
resolved "https://registry.yarnpkg.com/@wharfkit/session/-/session-1.6.0-rc1.tgz#092e653c10e0cec91238e6c549baa13fbe17ede0"
727-
integrity sha512-PkXkm/Xd//sv6C0KfSEgve4zzaF/0hEcOKdDSC98wnylmtDYZjPenjQJE5g1I2b3Irteww9DACPcsSg1iqTYTg==
724+
"@wharfkit/session@^1.6.0":
725+
version "1.6.0"
726+
resolved "https://registry.yarnpkg.com/@wharfkit/session/-/session-1.6.0.tgz#8863feb83fc71f55e49a0729aceabf1c688e216a"
727+
integrity sha512-yrCDcW42Dqd387usVHa3qjnttc65OzHK3REKovzo6wLpQsPn709xzx4J6B9e9Xjb0WC/GQLghtr9EX+T+rRH6w==
728728
dependencies:
729729
"@wharfkit/abicache" "^1.2.1"
730730
"@wharfkit/antelope" "^1.0.11"

0 commit comments

Comments
 (0)