Skip to content

Commit

Permalink
Replace scatterjs with scatter-ts
Browse files Browse the repository at this point in the history
  • Loading branch information
apporc committed Sep 13, 2023
1 parent a5938a0 commit 1141529
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 64 deletions.
5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@
"prepare": "make"
},
"dependencies": {
"@scatterjs/core": "^2.7.48",
"@scatterjs/eosjs2": "^1.5.30",
"eosjs": "20.0.0",
"scatter-ts": "^0.1.9",
"tslib": "^2.1.0"
},
"peerDependencies": {
Expand All @@ -32,8 +31,6 @@
"@rollup/plugin-node-resolve": "^15.2.1",
"@rollup/plugin-replace": "^5.0.1",
"@rollup/plugin-typescript": "^11.1.3",
"@scatterjs/core": "^2.7.48",
"@scatterjs/eosjs2": "^1.5.30",
"@types/chai": "^4.3.1",
"@types/mocha": "^9.0.0",
"@types/node": "^18.7.18",
Expand Down
24 changes: 11 additions & 13 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@ import {
} from '@wharfkit/session'

import {Api, JsonRpc} from 'eosjs'
import ScatterJS from '@scatterjs/core'
import ScatterEOS from '@scatterjs/eosjs2'

import {ScatterAccount} from './types'
import {ScatterJS, ScatterEOS, ScatterAccount, ScatterIdentity} from 'scatter-ts'

export class WalletPluginWombat extends AbstractWalletPlugin implements WalletPlugin {
id = 'wombat'
Expand Down Expand Up @@ -100,24 +97,25 @@ export class WalletPluginWombat extends AbstractWalletPlugin implements WalletPl
}

async getScatter(context): Promise<{account: ScatterAccount; connector: any}> {
// Ensure connected
const connected: boolean = await ScatterJS.connect(context.appName)
if (!connected) {
throw new Error('Unable to connect with Wombat wallet')
}

// Setup network
const url = new URL(context.chain.url)
const protocol = url.protocol.replace(':', '') === 'https' ? 'https' : 'http'
const network = ScatterJS.Network.fromJson({
blockchain: context.chain.name,
chainId: String(context.chain.id),
host: url.hostname,
port: url.port,
protocol: url.protocol.replace(':', ''),
port: url.port ? Number(url.port) : protocol === 'https' ? 443 : 80,
protocol,
})

// Ensure connected
const connected: boolean = await ScatterJS.connect(context.appName, {network})
if (!connected) {
throw new Error('Unable to connect with Wombat wallet')
}

// Ensure connection and get identity
const scatterIdentity = await ScatterJS.login({accounts: [network]})
const scatterIdentity: ScatterIdentity = await ScatterJS.login()
if (!scatterIdentity || !scatterIdentity.accounts) {
throw new Error('Unable to retrieve account from Wombat')
}
Expand Down
18 changes: 0 additions & 18 deletions src/types.ts

This file was deleted.

58 changes: 29 additions & 29 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -422,25 +422,6 @@
estree-walker "^2.0.2"
picomatch "^2.3.1"

"@scatterjs/core@^2.7.48", "@scatterjs/core@^2.7.54":
version "2.7.54"
resolved "https://registry.yarnpkg.com/@scatterjs/core/-/core-2.7.54.tgz#c82f539b6f77f96be93817c3e1f6d0799cf53193"
integrity sha512-BtV44dvEPajDmDfn+jpGE9kHIlPyz70ttd96+LIokdRUR+lf5E33rMpJGH+OEFwxGDhY8tDS6SYlyIU8ohCFHw==
dependencies:
create-hash "^1.2.0"
device-uuid "^1.0.4"
es6-promise "^4.2.4"
get-random-values "^1.2.0"
isomorphic-ws "^4.0.1"
ws "^6.1.0"

"@scatterjs/eosjs2@^1.5.30":
version "1.5.36"
resolved "https://registry.yarnpkg.com/@scatterjs/eosjs2/-/eosjs2-1.5.36.tgz#457ed69f181a6a19eb053352662bfb25726d0f74"
integrity sha512-osx/shuwiB59ql0XTVCZ/D9T3AZf+RA0lRnUa0Gya9M21GGBt6YHdxO2jxkmJHjEpfxE7FIwV3dRDj9T1swd2g==
dependencies:
"@scatterjs/core" "^2.7.54"

"@tsconfig/node10@^1.0.7":
version "1.0.9"
resolved "https://registry.yarnpkg.com/@tsconfig/node10/-/node10-1.0.9.tgz#df4907fc07a886922637b15e02d4cebc4c0021b2"
Expand Down Expand Up @@ -786,6 +767,11 @@ base-x@^3.0.2:
dependencies:
safe-buffer "^5.0.1"

base64-js@^1.3.1:
version "1.5.1"
resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a"
integrity sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==

bigi@^1.1.0, bigi@^1.4.2:
version "1.4.2"
resolved "https://registry.yarnpkg.com/bigi/-/bigi-1.4.2.tgz#9c665a95f88b8b08fc05cfd731f561859d725825"
Expand Down Expand Up @@ -867,6 +853,14 @@ buffer-xor@^1.0.3:
resolved "https://registry.yarnpkg.com/buffer-xor/-/buffer-xor-1.0.3.tgz#26e61ed1422fb70dd42e6e36729ed51d855fe8d9"
integrity sha512-571s0T7nZWK6vB67HI5dyUF7wXiNcfaPPPTl6zYCNApANjIvYJTg7hlud/+cJpdAhS7dVzqMLmfhfHR3rAcOjQ==

buffer@^6.0.3:
version "6.0.3"
resolved "https://registry.yarnpkg.com/buffer/-/buffer-6.0.3.tgz#2ace578459cc8fbe2a70aaa8f52ee63b6a74c6c6"
integrity sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==
dependencies:
base64-js "^1.3.1"
ieee754 "^1.2.1"

builtin-modules@^3.3.0:
version "3.3.0"
resolved "https://registry.yarnpkg.com/builtin-modules/-/builtin-modules-3.3.0.tgz#cae62812b89801e9656336e46223e030386be7b6"
Expand Down Expand Up @@ -1127,11 +1121,6 @@ default-require-extensions@^3.0.0:
dependencies:
strip-bom "^4.0.0"

device-uuid@^1.0.4:
version "1.0.4"
resolved "https://registry.yarnpkg.com/device-uuid/-/device-uuid-1.0.4.tgz#f6973e58f19b92a237aeca7b16a395ae7195a883"
integrity sha512-nNbUKlCuXZ1BV4zKFr9z8VxypL1PCNExRoNtRx/mNKFcOEDWUdT3E1B4vw7LBWftBmixkrjQIjpdLov3EmEJjA==

[email protected]:
version "5.0.0"
resolved "https://registry.yarnpkg.com/diff/-/diff-5.0.0.tgz#7ed6ad76d859d030787ec35855f5b1daf31d852b"
Expand Down Expand Up @@ -1225,11 +1214,6 @@ es6-error@^4.0.1:
resolved "https://registry.yarnpkg.com/es6-error/-/es6-error-4.1.1.tgz#9e3af407459deed47e9a91f9b885a84eb05c561d"
integrity sha512-Um/+FxMr9CISWh0bi5Zv0iOD+4cFh5qLeks1qhAopKVAJw3drgKbKySikp7wGhDL0HPeaja0P5ULZrxLkniUVg==

es6-promise@^4.2.4:
version "4.2.8"
resolved "https://registry.yarnpkg.com/es6-promise/-/es6-promise-4.2.8.tgz#4eb21594c972bc40553d276e510539143db53e0a"
integrity sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w==

escalade@^3.1.1:
version "3.1.1"
resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.1.1.tgz#d8cfdc7000965c5a0174b4a82eaa5c0552742e40"
Expand Down Expand Up @@ -1714,6 +1698,11 @@ html-escaper@^2.0.0:
resolved "https://registry.yarnpkg.com/html-escaper/-/html-escaper-2.0.2.tgz#dfd60027da36a36dfcbe236262c00a5822681453"
integrity sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==

ieee754@^1.2.1:
version "1.2.1"
resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.2.1.tgz#8eb7a10a63fff25d15a57b001586d177d1b0d352"
integrity sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==

ignore@^5.2.0:
version "5.2.4"
resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.2.4.tgz#a291c0c6178ff1b960befe47fcdec301674a6324"
Expand Down Expand Up @@ -2565,6 +2554,17 @@ safe-buffer@^5.0.1, safe-buffer@^5.1.0, safe-buffer@^5.1.1, safe-buffer@^5.1.2,
resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6"
integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==

scatter-ts@^0.1.9:
version "0.1.9"
resolved "https://registry.yarnpkg.com/scatter-ts/-/scatter-ts-0.1.9.tgz#fad17404cd7e82a8e1542fd33ea2018740eef3b0"
integrity sha512-2ZbNvcVIZqXPSzZmJc0ssH9UH+ZH9kSIvmtLsRhlvRSOr9eMdmmGG9w8s+duKOUnIG5hLOBB5z4uXnkE6cvz7Q==
dependencies:
buffer "^6.0.3"
create-hash "^1.2.0"
get-random-values "^1.2.0"
isomorphic-ws "^4.0.1"
ws "^6.1.0"

semver@^6.0.0, semver@^6.3.0, semver@^6.3.1:
version "6.3.1"
resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.1.tgz#556d2ef8689146e46dcea4bfdd095f3434dffcb4"
Expand Down

0 comments on commit 1141529

Please sign in to comment.