vue-3-useeosiowallet
Advanced tools
Comparing version 0.0.33 to 0.0.34
@@ -1,18 +0,12 @@ | ||
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.useAnchor = void 0; | ||
const vue_1 = require("vue"); | ||
const anchor_link_1 = __importDefault(require("anchor-link")); | ||
const anchor_link_browser_transport_1 = __importDefault(require("anchor-link-browser-transport")); | ||
const applicationName = vue_1.ref(''); | ||
const transport = new anchor_link_browser_transport_1.default(); | ||
import { ref } from 'vue'; | ||
import AnchorLink from 'anchor-link'; | ||
import AnchorLinkBrowserTransport from 'anchor-link-browser-transport'; | ||
const applicationName = ref(''); | ||
const transport = new AnchorLinkBrowserTransport(); | ||
let link = null; | ||
let globalSession = null; | ||
const useAnchor = () => { | ||
export const useAnchor = () => { | ||
const setup = async (appName, chain) => { | ||
applicationName.value = appName; | ||
link = new anchor_link_1.default({ transport, chains: [chain] }); | ||
link = new AnchorLink({ transport, chains: [chain] }); | ||
}; | ||
@@ -55,3 +49,2 @@ const login = async () => { | ||
}; | ||
exports.useAnchor = useAnchor; | ||
//# sourceMappingURL=anchor.js.map |
@@ -1,12 +0,9 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.changeChain = exports.logout = exports.login = exports.setup = exports.isAuthenticated = exports.username = exports.selectedWallet = exports.availableWallets = exports.selectedChain = exports.availableChains = void 0; | ||
const anchor_1 = require("./anchor"); | ||
const vue_1 = require("vue"); | ||
const waxcloud_1 = require("./waxcloud"); | ||
const scatter_1 = require("./scatter"); | ||
const isSetup = vue_1.ref(false); | ||
const applicationName = vue_1.ref(''); | ||
exports.availableChains = vue_1.ref([]); | ||
exports.selectedChain = vue_1.ref({ | ||
import { useAnchor } from './anchor'; | ||
import { computed, ref } from 'vue'; | ||
import { useWaxcloud } from './waxcloud'; | ||
import { useScatter } from './scatter'; | ||
const isSetup = ref(false); | ||
const applicationName = ref(''); | ||
export const availableChains = ref([]); | ||
export const selectedChain = ref({ | ||
id: 'eos', | ||
@@ -16,4 +13,4 @@ chainId: 'aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906', | ||
}); | ||
exports.availableWallets = vue_1.computed(() => { | ||
switch (exports.selectedChain.value.id) { | ||
export const availableWallets = computed(() => { | ||
switch (selectedChain.value.id) { | ||
case 'wax': | ||
@@ -25,6 +22,6 @@ return ['anchor', 'scatter', 'waxcloud']; | ||
}); | ||
exports.selectedWallet = vue_1.ref(null); | ||
exports.username = vue_1.ref(null); | ||
exports.isAuthenticated = vue_1.ref(false); | ||
const setup = async (appName, chains) => { | ||
export const selectedWallet = ref(null); | ||
export const username = ref(null); | ||
export const isAuthenticated = ref(false); | ||
export const setup = async (appName, chains) => { | ||
if (!appName) | ||
@@ -35,24 +32,23 @@ throw new Error('App Name not set.'); | ||
applicationName.value = appName; | ||
exports.availableChains.value = chains; | ||
await exports.changeChain(chains[0].id); | ||
availableChains.value = chains; | ||
await changeChain(chains[0].id); | ||
isSetup.value = true; | ||
}; | ||
exports.setup = setup; | ||
const login = async (walletId) => { | ||
export const login = async (walletId) => { | ||
if (!isSetup.value) | ||
throw new Error('Login Failed: Eosio wallet setup required. Please use setup() function first.'); | ||
if (exports.isAuthenticated.value) | ||
if (isAuthenticated.value) | ||
throw new Error('Login failed: A user is already logged in - please logout first.'); | ||
switch (walletId) { | ||
case 'anchor': | ||
await anchor_1.useAnchor().setup(applicationName.value, exports.selectedChain.value); | ||
exports.username.value = await anchor_1.useAnchor().login(); | ||
await useAnchor().setup(applicationName.value, selectedChain.value); | ||
username.value = await useAnchor().login(); | ||
break; | ||
case 'waxcloud': | ||
await waxcloud_1.useWaxcloud().setup(applicationName.value, exports.selectedChain.value); | ||
exports.username.value = await waxcloud_1.useWaxcloud().login(); | ||
await useWaxcloud().setup(applicationName.value, selectedChain.value); | ||
username.value = await useWaxcloud().login(); | ||
break; | ||
case 'scatter': | ||
await scatter_1.useScatter().setup(applicationName.value, exports.selectedChain.value); | ||
exports.username.value = await scatter_1.useScatter().login(); | ||
await useScatter().setup(applicationName.value, selectedChain.value); | ||
username.value = await useScatter().login(); | ||
break; | ||
@@ -62,15 +58,14 @@ default: | ||
} | ||
exports.isAuthenticated.value = true; | ||
exports.selectedWallet.value = walletId; | ||
return exports.username.value; | ||
isAuthenticated.value = true; | ||
selectedWallet.value = walletId; | ||
return username.value; | ||
}; | ||
exports.login = login; | ||
const logout = async () => { | ||
export const logout = async () => { | ||
if (!isSetup.value) | ||
throw new Error('Logout Failed: Eosio wallet setup required. Please use setup() function first.'); | ||
if (!exports.isAuthenticated.value) | ||
if (!isAuthenticated.value) | ||
throw new Error('Logout failed: No wallet connected.'); | ||
switch (exports.selectedWallet.value) { | ||
switch (selectedWallet.value) { | ||
case 'anchor': | ||
await anchor_1.useAnchor().logout(); | ||
await useAnchor().logout(); | ||
break; | ||
@@ -80,16 +75,14 @@ default: | ||
} | ||
exports.username.value = null; | ||
exports.isAuthenticated.value = false; | ||
exports.selectedWallet.value = null; | ||
username.value = null; | ||
isAuthenticated.value = false; | ||
selectedWallet.value = null; | ||
}; | ||
exports.logout = logout; | ||
const changeChain = async (chainId) => { | ||
const chain = exports.availableChains.value.find((x) => x.id === chainId); | ||
export const changeChain = async (chainId) => { | ||
const chain = availableChains.value.find((x) => x.id === chainId); | ||
if (!chain) | ||
throw new Error('Chain ID not found'); | ||
if (exports.isAuthenticated.value) | ||
await exports.logout(); | ||
exports.selectedChain.value = chain; | ||
if (isAuthenticated.value) | ||
await logout(); | ||
selectedChain.value = chain; | ||
}; | ||
exports.changeChain = changeChain; | ||
//# sourceMappingURL=index.js.map |
@@ -1,23 +0,17 @@ | ||
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.useScatter = void 0; | ||
// @ts-ignore | ||
const core_1 = __importDefault(require("@scatterjs/core")); | ||
import ScatterJS from '@scatterjs/core'; | ||
// @ts-ignore | ||
const eosjs2_1 = __importDefault(require("@scatterjs/eosjs2")); | ||
const eosjs_1 = require("eosjs"); | ||
const vue_1 = require("vue"); | ||
core_1.default.plugins(new eosjs2_1.default()); | ||
const applicationName = vue_1.ref(''); | ||
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; | ||
const useScatter = () => { | ||
export const useScatter = () => { | ||
const setup = async (appName, chain) => { | ||
applicationName.value = appName; | ||
rpc = new eosjs_1.JsonRpc(chain.nodeUrl); | ||
network = core_1.default.Network.fromJson({ | ||
rpc = new JsonRpc(chain.nodeUrl); | ||
network = ScatterJS.Network.fromJson({ | ||
blockchain: 'eos', | ||
@@ -32,3 +26,3 @@ chainId: chain.chainId, | ||
try { | ||
const connected = await core_1.default.connect(applicationName.value, { network }); | ||
const connected = await ScatterJS.connect(applicationName.value, { network }); | ||
if (!connected) | ||
@@ -46,3 +40,3 @@ throw new Error('Scatter could not connect to app.'); | ||
await connect(); | ||
const id = await core_1.default.login({ accounts: [network] }); | ||
const id = await ScatterJS.login({ accounts: [network] }); | ||
if (!id) | ||
@@ -65,3 +59,2 @@ throw new Error('Scatter login failed'); | ||
}; | ||
exports.useScatter = useScatter; | ||
//# sourceMappingURL=scatter.js.map |
@@ -1,26 +0,4 @@ | ||
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.useWaxcloud = void 0; | ||
const waxjs = __importStar(require("@waxio/waxjs/dist")); | ||
import * as waxjs from "@waxio/waxjs/dist"; | ||
let wax = null; | ||
const useWaxcloud = () => { | ||
export const useWaxcloud = () => { | ||
const setup = async (appName, chain) => { | ||
@@ -58,3 +36,2 @@ if (chain.id !== 'wax') | ||
}; | ||
exports.useWaxcloud = useWaxcloud; | ||
//# sourceMappingURL=waxcloud.js.map |
{ | ||
"name": "vue-3-useeosiowallet", | ||
"version": "0.0.33", | ||
"version": "0.0.34", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -8,3 +8,3 @@ { | ||
"target": "ESNEXT", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */ | ||
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */ | ||
"module": "es2015", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */ | ||
// "lib": [], /* Specify library files to be included in the compilation. */ | ||
@@ -11,0 +11,0 @@ // "allowJs": true, /* Allow javascript files to be compiled. */ |
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
35472
559