Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vue-3-useeosiowallet

Package Overview
Dependencies
Maintainers
1
Versions
66
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-3-useeosiowallet - npm Package Compare versions

Comparing version 0.2.1 to 0.2.2

dist/eosjs.js

14

dist/anchor.js

@@ -13,2 +13,15 @@ import { ref } from 'vue';

};
const transact = async (actions) => {
if (!globalSession)
throw new Error('Anchor Transaction Error: Link Session not found.');
const authorization = [globalSession.auth];
actions = actions.map((action) => ({
...action,
authorization,
}));
const { processed, transaction } = await globalSession.transact({ actions });
if (!processed)
throw new Error('Unkown Anchor Error: Transaction not broadcasted to network.');
return transaction.id.toString();
};
const login = async () => {

@@ -46,2 +59,3 @@ const user = await restoreSession();

setup,
transact,
login,

@@ -48,0 +62,0 @@ logout,

@@ -43,2 +43,18 @@ import { computed, ref } from 'vue';

};
export const transact = async (actions) => {
if (!isSetup.value)
throw new Error('Transaction Failed: Eosio wallet setup required. Please use setup() function first.');
if (!isAuthenticated.value)
throw new Error('Transaction canceled: No wallet connected.');
switch (selectedWallet.value) {
case Wallet.Anchor:
return await useAnchor().transact(actions);
case Wallet.Scatter:
return await useScatter().transact(actions);
case Wallet.WaxCloudWallet:
return await useWaxcloud().transact(actions);
default:
throw new Error('Transaction failed: Wallet ID not found.');
}
};
export const login = async (walletId) => {

@@ -45,0 +61,0 @@ if (!isSetup.value)

31

dist/scatter.js
import { ScatterJS, ScatterEOS } from 'scatter-ts';
import { ref } from 'vue';
import { Api, JsonRpc } from 'eosjs';
ScatterJS.plugins(new ScatterEOS());

@@ -12,3 +13,3 @@ const applicationName = ref('');

chainId: chain.chainId,
host: chain.nodeUrl,
host: chain.nodeUrl.split('//')[1],
port: 443,

@@ -18,2 +19,27 @@ protocol: 'https',

};
const transact = async (actions) => {
// TODO extract logic to eosjs.ts
if (!network)
throw new Error('Scatter Network not found.');
const rpc = new JsonRpc(network.fullhost());
const eos = ScatterJS.eos(network, Api, { rpc });
const account = ScatterJS.account('eos');
const authorization = [
{
actor: account.name,
permission: account.authority,
},
];
const options = {
blocksBehind: 3,
expireSeconds: 1200,
};
actions = actions.map((action) => ({
...action,
authorization,
}));
const result = await eos.transact({ actions }, options);
console.log('Scatter tx result', result);
return result.processed.id;
};
const connect = async () => {

@@ -37,6 +63,7 @@ if (!network)

const logout = async () => {
// TODO add scatter logout
// await ScatterJS.logout();
};
return { setup, login, logout };
return { setup, transact, login, logout };
};
//# sourceMappingURL=scatter.js.map

16

dist/types/index.d.ts

@@ -1,11 +0,12 @@

export declare type UseWalletProvider = {
logout: () => Promise<void>;
setup: (appName: string, chain: EosioChain) => Promise<void>;
login: () => Promise<string>;
};
export declare type EosioChain = {
export interface EosioChain {
id: string;
chainId: string;
nodeUrl: string;
};
}
export interface UseWalletProvider {
setup: (appName: string, chain: EosioChain) => Promise<void>;
transact: (actions: any[]) => Promise<string>;
login: () => Promise<string>;
logout: () => Promise<void>;
}
export declare enum Wallet {

@@ -31,2 +32,3 @@ Scatter = "scatter",

export declare const setup: (appName: string, chains: EosioChain[]) => Promise<void>;
export declare const transact: (actions: any[]) => Promise<string>;
export declare const login: (walletId: Wallet) => Promise<string>;

@@ -33,0 +35,0 @@ export declare const logout: () => Promise<void>;

@@ -9,2 +9,25 @@ import * as waxjs from '@waxio/waxjs/dist';

};
const transact = async (actions) => {
if (!wax)
throw new Error('Wax Cloud Transaction Error: Wax Cloud Wallet not found. Make sure to run setup() first.');
const authorization = [
{
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
actor: wax.userAccount,
permission: 'active',
},
];
const options = {
blocksBehind: 3,
expireSeconds: 1200,
};
actions = actions.map((action) => ({
...action,
authorization,
}));
const result = await wax.api.transact({ actions }, options);
console.log('Wax cloud tx result', result);
return result;
};
const login = async () => {

@@ -25,3 +48,3 @@ const user = await restoreSession();

return null;
// eslint-disable-next-line
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore

@@ -35,2 +58,3 @@ return wax.userAccount;

setup,
transact,
login,

@@ -37,0 +61,0 @@ logout,

{
"name": "vue-3-useeosiowallet",
"version": "0.2.1",
"version": "0.2.2",
"description": "",

@@ -17,3 +17,3 @@ "main": "dist/index.js",

"eosjs": "^21.0.4",
"scatter-ts": "^0.1.3",
"scatter-ts": "^0.1.7",
"vue": "^3.0.11"

@@ -20,0 +20,0 @@ },

@@ -20,2 +20,17 @@ import { ref } from 'vue';

const transact = async (actions: any[]): Promise<string> => {
if (!globalSession) throw new Error('Anchor Transaction Error: Link Session not found.');
const authorization = [globalSession.auth];
actions = actions.map((action) => ({
...action,
authorization,
}));
const { processed, transaction } = await globalSession.transact({ actions });
if (!processed) throw new Error('Unkown Anchor Error: Transaction not broadcasted to network.');
return transaction.id.toString();
};
const login = async (): Promise<string> => {

@@ -58,2 +73,3 @@ const user = await restoreSession();

setup,
transact,
login,

@@ -60,0 +76,0 @@ logout,

@@ -6,14 +6,15 @@ import { computed, ref } from 'vue';

export type UseWalletProvider = {
logout: () => Promise<void>;
setup: (appName: string, chain: EosioChain) => Promise<void>;
login: () => Promise<string>;
};
export type EosioChain = {
export interface EosioChain {
id: string;
chainId: string;
nodeUrl: string;
};
}
export interface UseWalletProvider {
setup: (appName: string, chain: EosioChain) => Promise<void>;
transact: (actions: any[]) => Promise<string>;
login: () => Promise<string>;
logout: () => Promise<void>;
}
export enum Wallet {

@@ -63,2 +64,19 @@ Scatter = 'scatter',

export const transact = async (actions: any[]): Promise<string> => {
if (!isSetup.value)
throw new Error('Transaction Failed: Eosio wallet setup required. Please use setup() function first.');
if (!isAuthenticated.value) throw new Error('Transaction canceled: No wallet connected.');
switch (selectedWallet.value) {
case Wallet.Anchor:
return await useAnchor().transact(actions);
case Wallet.Scatter:
return await useScatter().transact(actions);
case Wallet.WaxCloudWallet:
return await useWaxcloud().transact(actions);
default:
throw new Error('Transaction failed: Wallet ID not found.');
}
};
export const login = async (walletId: Wallet): Promise<string> => {

@@ -65,0 +83,0 @@ if (!isSetup.value)

import { ScatterJS, ScatterEOS, Network } from 'scatter-ts';
import { ref } from 'vue';
import { Api, JsonRpc } from 'eosjs';
import { EosioChain, UseWalletProvider } from './index';

@@ -17,3 +18,3 @@

chainId: chain.chainId,
host: chain.nodeUrl,
host: chain.nodeUrl.split('//')[1],
port: 443,

@@ -24,2 +25,31 @@ protocol: 'https',

const transact = async (actions: any[]): Promise<string> => {
// TODO extract logic to eosjs.ts
if (!network) throw new Error('Scatter Network not found.');
const rpc = new JsonRpc(network.fullhost());
const eos = ScatterJS.eos(network, Api, { rpc });
const account = ScatterJS.account('eos');
const authorization = [
{
actor: account.name,
permission: account.authority,
},
];
const options = {
blocksBehind: 3,
expireSeconds: 1200,
};
actions = actions.map((action) => ({
...action,
authorization,
}));
const result = await eos.transact({ actions }, options);
console.log('Scatter tx result', result);
return result.processed.id;
};
const connect = async (): Promise<void> => {

@@ -45,6 +75,7 @@ if (!network) throw new Error('Connection to Scatter failed. No network provided.');

const logout = async (): Promise<void> => {
// TODO add scatter logout
// await ScatterJS.logout();
};
return { setup, login, logout };
return { setup, transact, login, logout };
};
import * as waxjs from '@waxio/waxjs/dist';
import { EosioChain, UseWalletProvider } from './index';
let wax: waxjs.WaxJS | null = null;

@@ -12,2 +13,30 @@

const transact = async (actions: any[]): Promise<string> => {
if (!wax)
throw new Error('Wax Cloud Transaction Error: Wax Cloud Wallet not found. Make sure to run setup() first.');
const authorization = [
{
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
actor: wax.userAccount,
permission: 'active',
},
];
const options = {
blocksBehind: 3,
expireSeconds: 1200,
};
actions = actions.map((action) => ({
...action,
authorization,
}));
const result = await wax.api.transact({ actions }, options);
console.log('Wax cloud tx result', result);
return result;
};
const login = async (): Promise<string> => {

@@ -30,3 +59,3 @@ const user = await restoreSession();

// eslint-disable-next-line
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore

@@ -42,2 +71,3 @@ return wax.userAccount;

setup,
transact,
login,

@@ -44,0 +74,0 @@ logout,

@@ -14,7 +14,7 @@ {

"declaration": true,
"declarationDir": "./dist/types", /* Generates corresponding '.d.ts' file. */
"declarationDir": "dist/types", /* Generates corresponding '.d.ts' file. */
"declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
"sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
"outDir": "./dist", /* Redirect output structure to the directory. */
"outDir": "dist", /* Redirect output structure to the directory. */
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */

@@ -21,0 +21,0 @@ // "composite": true, /* Enable project compilation */

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

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc