hivesigner 3.3.5 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -2
- package/lib/client.d.ts +19 -3
- package/lib/hivesigner.min.js +1 -10
- package/lib/index.d.ts +4 -0
- package/lib/index.js +194 -225
- package/lib/methods/send-operation.method.d.ts +1 -2
- package/lib/methods/send-operations.method.d.ts +1 -2
- package/lib/methods/send-transaction.method.d.ts +1 -2
- package/lib/pkce.d.ts +16 -0
- package/lib/types/callback-function.type.d.ts +1 -1
- package/lib/types/hive.types.d.ts +13 -0
- package/lib/types/index.d.ts +2 -0
- package/lib/types/login-options.interface.d.ts +2 -0
- package/lib/types/send-response.type.d.ts +1 -1
- package/lib/types/token-response.interface.d.ts +8 -0
- package/package.json +11 -18
- package/.babelrc +0 -8
- package/.claude/settings.local.json +0 -12
- package/.eslintignore +0 -3
- package/.eslintrc.js +0 -16
- package/CLAUDE.md +0 -142
- package/docs/CNAME +0 -1
- package/docs/index.html +0 -221
- package/jest.config.js +0 -10
- package/rollup.config.js +0 -12
- package/src/client.spec.ts +0 -455
- package/src/client.ts +0 -317
- package/src/consts/api-url.const.ts +0 -1
- package/src/consts/base-url.const.ts +0 -1
- package/src/consts/beta-url.const.ts +0 -1
- package/src/consts/index.ts +0 -3
- package/src/default-import.spec.ts +0 -10
- package/src/factories/index.ts +0 -1
- package/src/factories/initialize.factory.spec.ts +0 -9
- package/src/factories/initialize.factory.ts +0 -7
- package/src/index.ts +0 -16
- package/src/methods/index.ts +0 -4
- package/src/methods/send-operation.method.spec.ts +0 -47
- package/src/methods/send-operation.method.ts +0 -15
- package/src/methods/send-operations.method.spec.ts +0 -47
- package/src/methods/send-operations.method.ts +0 -15
- package/src/methods/send-transaction.method.spec.ts +0 -47
- package/src/methods/send-transaction.method.ts +0 -15
- package/src/methods/sign.method.spec.ts +0 -60
- package/src/methods/sign.method.ts +0 -22
- package/src/modules-import.spec.ts +0 -11
- package/src/require-import.spec.js +0 -11
- package/src/require-import.spec.ts +0 -10
- package/src/types/callback-function.type.ts +0 -1
- package/src/types/client-config.interface.ts +0 -8
- package/src/types/index.ts +0 -5
- package/src/types/login-options.interface.ts +0 -3
- package/src/types/send-response.type.ts +0 -1
- package/src/types/sign-errors.interface.ts +0 -4
- package/src/utilities/index.ts +0 -1
- package/src/utilities/is-browser.util.ts +0 -3
- package/tsconfig.json +0 -15
- package/webpack.config.js +0 -26
package/package.json
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hivesigner",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"description": "Hivesigner SDK",
|
|
5
5
|
"main": "./lib/index",
|
|
6
6
|
"types": "./lib/index",
|
|
7
|
+
"files": [
|
|
8
|
+
"lib"
|
|
9
|
+
],
|
|
7
10
|
"scripts": {
|
|
8
|
-
"build": "rimraf lib &&
|
|
11
|
+
"build": "rimraf lib && webpack && rollup -c rollup.config.js && tsc --emitDeclarationOnly",
|
|
9
12
|
"test": "npx jest",
|
|
10
13
|
"lint": "eslint ./src/**/*.ts"
|
|
11
14
|
},
|
|
@@ -15,41 +18,31 @@
|
|
|
15
18
|
},
|
|
16
19
|
"author": "Ecency <hello@ecency.com>",
|
|
17
20
|
"license": "MIT",
|
|
21
|
+
"engines": {
|
|
22
|
+
"node": ">=18.0.0"
|
|
23
|
+
},
|
|
18
24
|
"bugs": {
|
|
19
25
|
"url": "https://github.com/ecency/hivesigner-sdk/issues"
|
|
20
26
|
},
|
|
21
27
|
"homepage": "https://github.com/ecency/hivesigner-sdk#readme",
|
|
22
28
|
"devDependencies": {
|
|
23
|
-
"@
|
|
24
|
-
"@babel/plugin-proposal-class-properties": "^7.13.0",
|
|
25
|
-
"@babel/plugin-proposal-object-rest-spread": "^7.13.8",
|
|
26
|
-
"@babel/plugin-transform-modules-commonjs": "^7.13.8",
|
|
27
|
-
"@babel/plugin-transform-runtime": "^7.13.9",
|
|
28
|
-
"@babel/preset-env": "^7.13.9",
|
|
29
|
-
"@babel/preset-typescript": "^7.13.0",
|
|
30
|
-
"@hiveio/dhive": "^1.2.6",
|
|
31
|
-
"@types/bytebuffer": "^5.0.42",
|
|
29
|
+
"@rollup/plugin-typescript": "^12.3.0",
|
|
32
30
|
"@types/jest": "^26.0.20",
|
|
33
31
|
"@types/node": "^14.14.28",
|
|
34
32
|
"@typescript-eslint/eslint-plugin": "^4.15.1",
|
|
35
33
|
"@typescript-eslint/parser": "^4.15.1",
|
|
36
|
-
"babel-core": "^6.26.3",
|
|
37
|
-
"babel-loader": "^8.2.2",
|
|
38
34
|
"eslint": "^7.20.0",
|
|
39
35
|
"jest": "^26.6.3",
|
|
40
36
|
"rollup": "^2.40.0",
|
|
41
|
-
"rollup-plugin-typescript": "^1.0.1",
|
|
42
37
|
"ts-jest": "^26.5.1",
|
|
43
38
|
"ts-loader": "^8.0.17",
|
|
44
39
|
"ts-node": "^9.1.1",
|
|
45
40
|
"tslib": "^2.1.0",
|
|
46
41
|
"typescript": "^4.1.5",
|
|
47
|
-
"webpack": "^
|
|
48
|
-
"webpack-cli": "^
|
|
42
|
+
"webpack": "^5.105.4",
|
|
43
|
+
"webpack-cli": "^7.0.2"
|
|
49
44
|
},
|
|
50
45
|
"dependencies": {
|
|
51
|
-
"@babel/runtime": "^7.13.9",
|
|
52
|
-
"cross-fetch": "^3.0.6",
|
|
53
46
|
"hive-uri": "^0.2.4"
|
|
54
47
|
}
|
|
55
48
|
}
|
package/.babelrc
DELETED
package/.eslintignore
DELETED
package/.eslintrc.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
parser: '@typescript-eslint/parser', // Specifies the ESLint parser
|
|
3
|
-
extends: [
|
|
4
|
-
'plugin:@typescript-eslint/recommended' // Uses the recommended rules from @typescript-eslint/eslint-plugin
|
|
5
|
-
],
|
|
6
|
-
parserOptions: {
|
|
7
|
-
ecmaVersion: 2018, // Allows for the parsing of modern ECMAScript features
|
|
8
|
-
sourceType: 'module' // Allows for the use of imports
|
|
9
|
-
},
|
|
10
|
-
rules: {
|
|
11
|
-
// Place to specify ESLint rules. Can be used to overwrite rules specified from the extended configs
|
|
12
|
-
// e.g. '@typescript-eslint/explicit-function-return-type': 'off',
|
|
13
|
-
"@typescript-eslint/ban-ts-comment": "off",
|
|
14
|
-
"@typescript-eslint/no-empty-function": "off"
|
|
15
|
-
}
|
|
16
|
-
};
|
package/CLAUDE.md
DELETED
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
# CLAUDE.md
|
|
2
|
-
|
|
3
|
-
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
|
4
|
-
|
|
5
|
-
## Project Overview
|
|
6
|
-
|
|
7
|
-
HiveSigner SDK is a JavaScript/TypeScript SDK for the Hive blockchain's OAuth2 authentication service (HiveSigner). It enables applications to authenticate users and perform Hive blockchain operations on their behalf. The SDK works in both browser and Node.js environments.
|
|
8
|
-
|
|
9
|
-
## Build & Development Commands
|
|
10
|
-
|
|
11
|
-
### Building
|
|
12
|
-
```bash
|
|
13
|
-
npm run build
|
|
14
|
-
```
|
|
15
|
-
This command:
|
|
16
|
-
1. Cleans the `lib/` directory
|
|
17
|
-
2. Runs webpack to create browser bundle (`lib/hivesigner.min.js`)
|
|
18
|
-
3. Runs rollup to create CommonJS module (`lib/index.js`)
|
|
19
|
-
4. Runs TypeScript compiler to emit type declarations (`lib/**/*.d.ts`)
|
|
20
|
-
|
|
21
|
-
### Testing
|
|
22
|
-
```bash
|
|
23
|
-
npm test
|
|
24
|
-
```
|
|
25
|
-
Runs all tests using Jest with ts-jest preset.
|
|
26
|
-
|
|
27
|
-
To run a single test file:
|
|
28
|
-
```bash
|
|
29
|
-
npx jest src/path/to/file.spec.ts
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
### Linting
|
|
33
|
-
```bash
|
|
34
|
-
npm run lint
|
|
35
|
-
```
|
|
36
|
-
Runs ESLint on all TypeScript files in `src/`.
|
|
37
|
-
|
|
38
|
-
## Architecture
|
|
39
|
-
|
|
40
|
-
### Core Components
|
|
41
|
-
|
|
42
|
-
**Client Class (`src/client.ts`)**
|
|
43
|
-
- Main entry point for SDK functionality
|
|
44
|
-
- Handles OAuth2 authentication flow (login, token management)
|
|
45
|
-
- Provides convenience methods for common Hive operations (vote, comment, follow, etc.)
|
|
46
|
-
- Uses method overloading to support both callback and Promise-based APIs
|
|
47
|
-
- All operations ultimately call `broadcast()` or `send()` methods
|
|
48
|
-
|
|
49
|
-
**Dual API Pattern**
|
|
50
|
-
The SDK supports both callbacks and Promises throughout. Each public method has overloaded signatures:
|
|
51
|
-
```typescript
|
|
52
|
-
public vote(...args): Promise<SendResponse>
|
|
53
|
-
public vote(...args, cb: CallbackFunction): Promise<SendResponse>
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
### Directory Structure
|
|
57
|
-
|
|
58
|
-
- `src/client.ts` - Main Client class with all SDK methods
|
|
59
|
-
- `src/methods/` - Standalone utility methods for operations like `sendOperation`, `sendOperations`, `sign`
|
|
60
|
-
- `src/factories/` - Factory functions (mainly deprecated `Initialize` function)
|
|
61
|
-
- `src/types/` - TypeScript interfaces and types
|
|
62
|
-
- `src/consts/` - Constants for API URLs (API_URL, BASE_URL, BETA_URL)
|
|
63
|
-
- `src/utilities/` - Helper utilities like `isBrowser()`
|
|
64
|
-
|
|
65
|
-
### Key Concepts
|
|
66
|
-
|
|
67
|
-
**Operation Broadcasting**
|
|
68
|
-
- Most methods construct an operation array and call `this.broadcast(operations, cb)`
|
|
69
|
-
- `broadcast()` sends operations to HiveSigner API's `/api/broadcast` endpoint
|
|
70
|
-
- Operations follow Hive blockchain operation format (from `@hiveio/dhive`)
|
|
71
|
-
|
|
72
|
-
**Authentication Flow**
|
|
73
|
-
1. App creates Client instance with `app`, `callbackURL`, and `scope`
|
|
74
|
-
2. User redirects to URL from `getLoginURL()` or calls `login()`
|
|
75
|
-
3. HiveSigner redirects back with `access_token` in query params
|
|
76
|
-
4. App sets token via `setAccessToken(accessToken)`
|
|
77
|
-
5. Authenticated calls include token in Authorization header
|
|
78
|
-
|
|
79
|
-
**URI Encoding for Operations**
|
|
80
|
-
- `sendOperation()` and `sendOperations()` use `hive-uri` package to encode operations as hive:// URIs
|
|
81
|
-
- These URIs are converted to HiveSigner web URLs for browser-based signing
|
|
82
|
-
|
|
83
|
-
## Build Output
|
|
84
|
-
|
|
85
|
-
The build produces three main artifacts in `lib/`:
|
|
86
|
-
- `index.js` + `index.d.ts` - CommonJS module with TypeScript declarations
|
|
87
|
-
- `hivesigner.min.js` - Webpack-bundled browser build (UMD format)
|
|
88
|
-
- Directory structure mirrors `src/` for individual module imports
|
|
89
|
-
|
|
90
|
-
## TypeScript Configuration
|
|
91
|
-
|
|
92
|
-
- Target: ES5 for broad compatibility
|
|
93
|
-
- Module: CommonJS
|
|
94
|
-
- Declaration files are generated for all modules
|
|
95
|
-
- Test files (`*.spec.ts`) are excluded from compilation
|
|
96
|
-
|
|
97
|
-
## Dependencies
|
|
98
|
-
|
|
99
|
-
**Runtime:**
|
|
100
|
-
- `cross-fetch` - Isomorphic fetch for Node.js and browser
|
|
101
|
-
- `hive-uri` - Encoding/decoding Hive operation URIs
|
|
102
|
-
- `@hiveio/dhive` (devDep, used for types) - Hive blockchain library
|
|
103
|
-
|
|
104
|
-
**Build:**
|
|
105
|
-
- Webpack for browser bundle
|
|
106
|
-
- Rollup for CommonJS build
|
|
107
|
-
- TypeScript for compilation and type checking
|
|
108
|
-
- Jest + ts-jest for testing
|
|
109
|
-
|
|
110
|
-
## Known Issues & Fixes
|
|
111
|
-
|
|
112
|
-
### "Illegal invocation" Error with Fetch
|
|
113
|
-
When using the SDK in browser environments, you may encounter:
|
|
114
|
-
```
|
|
115
|
-
TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
**Cause**: The native browser `fetch` function loses its binding to the `window` object when imported and called through `cross-fetch`.
|
|
119
|
-
|
|
120
|
-
**Fix Applied**: The fetch function is now explicitly bound at module load time in `src/client.ts`:
|
|
121
|
-
```typescript
|
|
122
|
-
const fetch = crossFetch.bind(typeof globalThis !== 'undefined' ? globalThis : undefined)
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
This ensures the fetch function maintains proper context in both browser and Node.js environments.
|
|
126
|
-
|
|
127
|
-
### Webpack Build Error with Node.js 17+
|
|
128
|
-
When building with Node.js 17+, you may encounter:
|
|
129
|
-
```
|
|
130
|
-
Error: error:0308010C:digital envelope routines::unsupported
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
**Cause**: Webpack 4 uses the MD4 hash algorithm which was removed in OpenSSL 3.0 (used by Node.js 17+).
|
|
134
|
-
|
|
135
|
-
**Fix Applied**: The build script now uses the legacy OpenSSL provider:
|
|
136
|
-
```bash
|
|
137
|
-
NODE_OPTIONS=--openssl-legacy-provider webpack
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
**Alternative Solutions**:
|
|
141
|
-
- Use Node.js 16 or earlier
|
|
142
|
-
- Upgrade to Webpack 5 (requires dependency updates)
|
package/docs/CNAME
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
demo.hivesigner.com
|
package/docs/index.html
DELETED
|
@@ -1,221 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8">
|
|
5
|
-
<title>Hivesigner demo with Vue.js</title>
|
|
6
|
-
<link rel="stylesheet" href="https://unpkg.com/primer-css@9.6.0/build/build.css" />
|
|
7
|
-
<script src="https://unpkg.com/vue@latest/dist/vue.js"></script>
|
|
8
|
-
<script src="https://unpkg.com/hivesigner@latest/lib/hivesigner.min.js"></script>
|
|
9
|
-
<!-- <script src="https://cdn.jsdelivr.net/npm/hivesigner@3.2.2"></script> -->
|
|
10
|
-
<!-- <script src="../dist/hivesigner.min.js"></script> -->
|
|
11
|
-
</head>
|
|
12
|
-
<body>
|
|
13
|
-
|
|
14
|
-
<div id="main" class="Box p-4 my-4" v-cloak>
|
|
15
|
-
<div class="bg-gray text-center mb-4 p-4 rounded">
|
|
16
|
-
<h3>HiveSigner demo with Vue.js</h3>
|
|
17
|
-
<p>
|
|
18
|
-
<a target="_blank" href="https://github.com/ecency/hivesigner-sdk/blob/master/docs/index.html">
|
|
19
|
-
See the code on GitHub
|
|
20
|
-
</a>
|
|
21
|
-
</p>
|
|
22
|
-
</div>
|
|
23
|
-
|
|
24
|
-
<p v-if="!isInit">Loading...</p>
|
|
25
|
-
<div v-else>
|
|
26
|
-
<div v-if="!username" class="text-center">
|
|
27
|
-
|
|
28
|
-
<button @click="login" class="btn btn-primary" :disabled="isLoading">
|
|
29
|
-
Log in
|
|
30
|
-
</button>
|
|
31
|
-
</div>
|
|
32
|
-
|
|
33
|
-
<div v-if="username">
|
|
34
|
-
<p class="mb-4">
|
|
35
|
-
You are logged as <b>{{username}}</b>
|
|
36
|
-
<a href="#" @click="logout">logout</a>
|
|
37
|
-
</p>
|
|
38
|
-
|
|
39
|
-
<div class="mb-4">
|
|
40
|
-
<h4 class="mb-2">Comment and vote</h4>
|
|
41
|
-
<p class="mb-2">
|
|
42
|
-
You are commenting on the post:
|
|
43
|
-
<b>
|
|
44
|
-
<a :href="`https://ecency.com/@${parentAuthor}/${parentPermlink}`" target="_blank">
|
|
45
|
-
@{{ parentAuthor }}/{{ parentPermlink }}
|
|
46
|
-
</a>
|
|
47
|
-
</b>
|
|
48
|
-
</p>
|
|
49
|
-
|
|
50
|
-
<textarea
|
|
51
|
-
v-model="form.comment"
|
|
52
|
-
placeholder="Write a comment"
|
|
53
|
-
class="form-control mb-2 btn-block text-left"
|
|
54
|
-
:disabled="isLoading"
|
|
55
|
-
></textarea>
|
|
56
|
-
|
|
57
|
-
<button @click="comment" class="btn btn-primary mb-2 mr-1" :disabled="isLoading">
|
|
58
|
-
Comment
|
|
59
|
-
</button>
|
|
60
|
-
|
|
61
|
-
<button @click="vote" class="btn mb-2" :disabled="isLoading">
|
|
62
|
-
Upvote
|
|
63
|
-
</button>
|
|
64
|
-
</div>
|
|
65
|
-
|
|
66
|
-
<div class="mb-4">
|
|
67
|
-
<h4 class="mb-2">Request transfer</h4>
|
|
68
|
-
<button @click="transfer" class="btn mb-2" :disabled="isLoading">
|
|
69
|
-
Transfer
|
|
70
|
-
</button>
|
|
71
|
-
</div>
|
|
72
|
-
|
|
73
|
-
<div v-if="txId" class="flash flash-success mb-2">
|
|
74
|
-
<p>
|
|
75
|
-
The transaction has been broadcasted, here is the tx id:
|
|
76
|
-
<a :href="'https://hiveblocks.com/tx/' + txId" target="_blank">
|
|
77
|
-
<b>{{ txId }}</b>
|
|
78
|
-
</a>
|
|
79
|
-
</p>
|
|
80
|
-
</div>
|
|
81
|
-
|
|
82
|
-
<div v-if="error" class="flash flash-error mb-2">
|
|
83
|
-
<p>{{ error.error_description || error.error || error }}</p>
|
|
84
|
-
</div>
|
|
85
|
-
</div>
|
|
86
|
-
</div>
|
|
87
|
-
</div>
|
|
88
|
-
|
|
89
|
-
<script type="text/javascript">
|
|
90
|
-
const client = new hivesigner.Client({
|
|
91
|
-
app: 'demo',
|
|
92
|
-
callbackURL: 'https://demo.hivesigner.com'
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
window.onload = function() {
|
|
96
|
-
new Vue({
|
|
97
|
-
el: '#main',
|
|
98
|
-
data: {
|
|
99
|
-
username: null,
|
|
100
|
-
form: {
|
|
101
|
-
username: null,
|
|
102
|
-
comment: null,
|
|
103
|
-
},
|
|
104
|
-
isInit: false,
|
|
105
|
-
isLoading: false,
|
|
106
|
-
txId: null,
|
|
107
|
-
error: null,
|
|
108
|
-
parentAuthor: 'steemguest',
|
|
109
|
-
parentPermlink: '4lx1se-test-post',
|
|
110
|
-
|
|
111
|
-
},
|
|
112
|
-
mounted: function () {
|
|
113
|
-
let params = (new URL(location)).searchParams;
|
|
114
|
-
const token = params.get('access_token') || localStorage.getItem('sc_token');
|
|
115
|
-
if (token) {
|
|
116
|
-
const self = this;
|
|
117
|
-
this.isInit = false;
|
|
118
|
-
client.setAccessToken(token);
|
|
119
|
-
|
|
120
|
-
client.me(function(err, result) {
|
|
121
|
-
if (result) self.username = result.name;
|
|
122
|
-
if (err) self.error = err;
|
|
123
|
-
localStorage.setItem('sc_token', token);
|
|
124
|
-
self.isInit = true;
|
|
125
|
-
console.log(err, result);
|
|
126
|
-
});
|
|
127
|
-
} else {
|
|
128
|
-
this.isInit = true;
|
|
129
|
-
}
|
|
130
|
-
},
|
|
131
|
-
methods: {
|
|
132
|
-
login: function () {
|
|
133
|
-
const self = this;
|
|
134
|
-
this.isLoading = true;
|
|
135
|
-
|
|
136
|
-
const loginObj = {};
|
|
137
|
-
if (this.form.username) loginObj.username = this.form.username;
|
|
138
|
-
|
|
139
|
-
client.login(loginObj, function(err, token) {
|
|
140
|
-
console.log('Log in result', err, token);
|
|
141
|
-
if (err) return self.isLoading = false;
|
|
142
|
-
client.setAccessToken(token);
|
|
143
|
-
|
|
144
|
-
client.me(function(err, result) {
|
|
145
|
-
console.log('Verification result', err, result);
|
|
146
|
-
if (result) self.username = result.name;
|
|
147
|
-
if (err) self.error = err;
|
|
148
|
-
localStorage.setItem('sc_token', token);
|
|
149
|
-
self.isLoading = false;
|
|
150
|
-
});
|
|
151
|
-
});
|
|
152
|
-
},
|
|
153
|
-
comment: function () {
|
|
154
|
-
const self = this;
|
|
155
|
-
this.isLoading = true;
|
|
156
|
-
this.txId = null;
|
|
157
|
-
this.error = null;
|
|
158
|
-
|
|
159
|
-
const permlink = 'hivesigner-' + new Date().getTime();
|
|
160
|
-
const jsonMetadata = JSON.stringify({ tags: ['hivesigner'], app: 'hivesigner' });
|
|
161
|
-
|
|
162
|
-
client.comment(this.parentAuthor, this.parentPermlink, this.username, permlink, '', this.form.comment, jsonMetadata, function(err, result) {
|
|
163
|
-
console.log('Comment result', err, result);
|
|
164
|
-
self.isLoading = false;
|
|
165
|
-
if (result) self.txId = result.id || result.result.id;
|
|
166
|
-
if (err) self.error = err;
|
|
167
|
-
});
|
|
168
|
-
},
|
|
169
|
-
vote: function () {
|
|
170
|
-
const self = this;
|
|
171
|
-
this.isLoading = true;
|
|
172
|
-
this.txId = null;
|
|
173
|
-
this.error = null;
|
|
174
|
-
|
|
175
|
-
client.vote(this.username, this.parentAuthor, this.parentPermlink, 10000, function(err, result) {
|
|
176
|
-
console.log('Vote result', err, result);
|
|
177
|
-
self.isLoading = false;
|
|
178
|
-
if (result) self.txId = result.id || result.result.id;
|
|
179
|
-
if (err) self.error = err;
|
|
180
|
-
});
|
|
181
|
-
},
|
|
182
|
-
transfer: function () {
|
|
183
|
-
const self = this;
|
|
184
|
-
this.txId = null;
|
|
185
|
-
this.error = null;
|
|
186
|
-
|
|
187
|
-
const op = ['transfer', {
|
|
188
|
-
from: '__signer',
|
|
189
|
-
to: 'ecency',
|
|
190
|
-
amount: '0.001 HIVE',
|
|
191
|
-
memo: 'Transfer with HiveSigner demo'
|
|
192
|
-
}];
|
|
193
|
-
hivesigner.sendOperation(op, {}, function(err, result) {
|
|
194
|
-
console.log('Transfer result', err, result);
|
|
195
|
-
if (result) self.txId = result.id || result.result.id;
|
|
196
|
-
if (err) self.error = err;
|
|
197
|
-
});
|
|
198
|
-
},
|
|
199
|
-
logout: function () {
|
|
200
|
-
this.username = null;
|
|
201
|
-
localStorage.removeItem('sc_token');
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
});
|
|
205
|
-
};
|
|
206
|
-
</script>
|
|
207
|
-
|
|
208
|
-
<style type="text/css">
|
|
209
|
-
#main {
|
|
210
|
-
width: 100%;
|
|
211
|
-
max-width: 600px;
|
|
212
|
-
margin: 0 auto;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
[v-cloak] {
|
|
216
|
-
display: none;
|
|
217
|
-
}
|
|
218
|
-
</style>
|
|
219
|
-
|
|
220
|
-
</body>
|
|
221
|
-
</html>
|
package/jest.config.js
DELETED