vue-3-useeosiowallet
Advanced tools
Comparing version 0.0.2 to 0.0.3
import { useAnchor } from './anchor'; | ||
import { computed, ref } from 'vue'; | ||
import { useScatter } from './scatter'; | ||
const isSetup = ref(false); | ||
@@ -42,2 +43,6 @@ const applicationName = ref(''); | ||
break; | ||
case 'scatter': | ||
await useScatter().setup(applicationName.value, selectedChain.value); | ||
username.value = await useAnchor().login(); | ||
break; | ||
default: | ||
@@ -44,0 +49,0 @@ throw new Error('Login failed: Wallet ID not found.'); |
@@ -0,1 +1,6 @@ | ||
import { EosioChain } from './types'; | ||
export declare const useScatter: () => { | ||
setup: (appName: string, chain: EosioChain) => Promise<void>; | ||
login: () => Promise<any>; | ||
}; | ||
//# sourceMappingURL=scatter.d.ts.map |
@@ -1,2 +0,53 @@ | ||
"use strict"; | ||
// @ts-ignore | ||
import ScatterJS from '@scatterjs/core'; | ||
// @ts-ignore | ||
import ScatterEOS from '@scatterjs/eosjs2'; | ||
import { JsonRpc } from 'eosjs'; | ||
import { ref } from 'vue'; | ||
ScatterJS.plugins(new ScatterEOS()); | ||
const applicationName = ref(''); | ||
// @ts-ignore | ||
let rpc = null; | ||
let network = null; | ||
export const useScatter = () => { | ||
const setup = async (appName, chain) => { | ||
applicationName.value = appName; | ||
rpc = new JsonRpc(chain.nodeUrl); | ||
network = ScatterJS.Network.fromJson({ | ||
blockchain: 'eos', | ||
chainId: chain.chainId, | ||
host: chain.nodeUrl, | ||
port: 443, | ||
protocol: 'https', | ||
}); | ||
}; | ||
const connect = async () => { | ||
try { | ||
await ScatterJS.connect(applicationName.value, { network }); | ||
console.log('scatter connected'); | ||
} | ||
catch (e) { | ||
console.log('scatter connect error', e); | ||
throw e; | ||
} | ||
}; | ||
const login = async () => { | ||
try { | ||
await connect(); | ||
const id = ScatterJS.login({ accounts: [network] }); | ||
if (!id) | ||
throw new Error('Scatter login failed'); | ||
const account = id.accounts[0]; | ||
if (!account) | ||
throw new Error('Scatter failed to find account'); | ||
console.log('scatter logged in'); | ||
return account.name; | ||
} | ||
catch (e) { | ||
console.log('scatter login error', e); | ||
throw e; | ||
} | ||
}; | ||
return { setup, login }; | ||
}; | ||
//# sourceMappingURL=scatter.js.map |
{ | ||
"name": "vue-3-useeosiowallet", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "", | ||
@@ -13,4 +13,7 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"@scatterjs/core": "^2.7.54", | ||
"@scatterjs/eosjs2": "^1.5.36", | ||
"anchor-link": "^3.2.3", | ||
"anchor-link-browser-transport": "^3.1.3", | ||
"eosjs": "^21.0.4", | ||
"vue": "^3.0.11" | ||
@@ -17,0 +20,0 @@ }, |
import { useAnchor } from './anchor'; | ||
import { computed, ref } from 'vue'; | ||
import type { EosioChain } from './types'; | ||
import { useScatter } from './scatter'; | ||
@@ -49,2 +50,6 @@ const isSetup = ref<boolean>(false); | ||
break; | ||
case 'scatter': | ||
await useScatter().setup(applicationName.value, selectedChain.value); | ||
username.value = await useAnchor().login(); | ||
break; | ||
default: | ||
@@ -51,0 +56,0 @@ throw new Error('Login failed: Wallet ID not found.'); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
73649
471
6
+ Added@scatterjs/core@^2.7.54
+ Added@scatterjs/eosjs2@^1.5.36
+ Addedeosjs@^21.0.4
+ Added@scatterjs/core@2.7.54(transitive)
+ Added@scatterjs/eosjs2@1.5.36(transitive)
+ Addedasync-limiter@1.0.1(transitive)
+ Addedbn.js@5.2.0(transitive)
+ Addedcipher-base@1.0.6(transitive)
+ Addedcreate-hash@1.2.0(transitive)
+ Addeddevice-uuid@1.0.4(transitive)
+ Addeddom-walk@0.1.2(transitive)
+ Addedelliptic@6.5.4(transitive)
+ Addedeosjs@21.0.4(transitive)
+ Addedes6-promise@4.2.8(transitive)
+ Addedget-random-values@1.2.2(transitive)
+ Addedglobal@4.4.0(transitive)
+ Addedhash-base@3.1.0(transitive)
+ Addedmd5.js@1.3.5(transitive)
+ Addedmin-document@2.19.0(transitive)
+ Addedpako@2.0.3(transitive)
+ Addedprocess@0.11.10(transitive)
+ Addedreadable-stream@3.6.2(transitive)
+ Addedripemd160@2.0.2(transitive)
+ Addedsafe-buffer@5.2.1(transitive)
+ Addedsha.js@2.4.11(transitive)
+ Addedstring_decoder@1.3.0(transitive)
+ Addedutil-deprecate@1.0.2(transitive)
+ Addedws@6.2.3(transitive)