Skip to content
This repository was archived by the owner on Jan 15, 2025. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
52e6e8a
* made "prettier"
Jul 13, 2022
72aa449
Revert "* made "prettier""
Sep 24, 2022
5ab971f
Merge branch 'development' of /home/leprechaun/Source/ecency-vision i…
Sep 26, 2022
b66ec20
Merge branch 'development' of ssh://github.com/ecency/ecency-vision i…
Sep 26, 2022
f333972
* added runtime validation checks
Oct 1, 2022
8571752
Merge remote-tracking branch 'upstream/development' into development
Oct 1, 2022
9ad86b8
* migrated changes for Hive Engine token management to transfer-he/in…
Oct 7, 2022
5a5b6ec
* regression fixes
Oct 7, 2022
af267cb
* show those who have been delegated to in the drop down list when un…
Oct 12, 2022
36e2b86
Merge commit 'cad8ec13254811ea783b3f80d4ef4dbb66129f28' into development
Oct 12, 2022
ef104c0
* added a detailed wallet for Engine tokens
Oct 26, 2022
3aea4ff
* now shows recent transactions in the Hive Engine detail
Oct 28, 2022
f357a3b
* merge
Nov 2, 2022
b3cce33
* removed testnet code as there are no testnet RPC nodes that really …
Nov 3, 2022
214aabd
* updated README file
Nov 4, 2022
4685444
* undid unintentional change to defaults.json
Nov 4, 2022
d9dc79b
* removed need for client_config file
Nov 4, 2022
6fc4a49
* redirect to the site being used rather than the site of the backend…
Nov 6, 2022
86cf5f1
Merge remote-tracking branch 'upstream/development' into development
shawnpringle Nov 20, 2022
2bc6229
* test correction
Nov 20, 2022
b46df07
* migrated constants from client_config.ts to constants/defaults.json
Nov 21, 2022
9d6b936
* added card-link style to the listed Hive Engine tokens
Nov 21, 2022
c30bb22
Merge branch 'development' of ssh://github.com/ecency/ecency-vision i…
shawnpringle Nov 21, 2022
d0dd470
Merge branch 'development' of ssh://github.com/ecency/ecency-vision i…
shawnpringle Nov 21, 2022
3230e33
Merge branch 'development' of ssh://github.com/ecency/ecency-vision i…
Nov 21, 2022
36a6c56
Merge branch 'development' of /home/leprechaun/Source/ecency-vision i…
Nov 21, 2022
2e2a960
Merge branch 'ecency:development' into detailed-hive-engine-wallet
shawnpringle Nov 21, 2022
902a16d
* additional fixes for merge
shawnpringle Nov 22, 2022
8bf81c9
* removed duplicate symbol, made formated-number round rather than tr…
Nov 22, 2022
bcdb48d
Merge branch 'development' into detailed-hive-engine-wallet
Nov 22, 2022
326abeb
* merge
Nov 22, 2022
1bd1912
* merge
shawnpringle Nov 25, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ npm-debug.log*
.DS_Store
.idea
cache

coverage
node_modules
build
Expand All @@ -13,8 +12,7 @@ public/static
.env.development.local
.env.test.local
.env.production.local

src/config.ts
.vscode

dev.sh
*~
*.marks
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,21 @@ Feel free to test it out and submit improvements and pull requests.

When setting up another service like Ecency with Ecency-vision software:

- `HIVESIGNER_ID` - iff USE_PRIVATE is 0, set this to what account will handle the permissions for posting level operations.
- `HIVESIGNER_SECRET` - iff USE_PRIVATE is 0, set this to the "secret" field value in the [Hive Signer profile](https://hivesigner.com/profile) for the user named as your `HIVESIGNER_ID`. This should be a lengthy lowercase hex string.

1. You may leave `HIVESIGNER_ID` and `HIVESIGNER_SECRET` environment variables unset and optionally set USE_PRIVATE=1 and leave "base" in the constants/defaults.json set to "https://ecency.com". Your new site will contain more features as it will use Ecency's private API. This is by far the easiest option.
2. You may change `base` to the URL of your own site, but you will have to set environment variables `HIVESIGNER_ID` and `HIVESIGNER_SECRET`; set USE_PRIVATE=0 as well as configure your the `HIVESIGNER_ID` account at the [Hivesigner website.](https://hivesigner.com/profile). Hivesigner will need a `secret`, in the form of a long lowercase hexadecimal number. The HIVESIGNER_SECRET should be set to this value.

###### Hivesigner Login Process

In order to validate a login, and do posting level operations, this software relies on Hivesigner. A user @alice will use login credentials to login to the site via one of several methods, but the site will communicate with Hivesigner and ask it to do all posting operations on behalf of @alice. Hivesigner can and will do this because both @alice will have given posting authority to the `HIVESIGNER_ID` user and the `HIVESIGNER_ID` user will have given its posting authority to Hivesigner.

##### Edit "default" values
Also for URLs other than https://ecency.com\_...

If you are setting up your own website other than Ecency.com, you can still leave the value `base` as "https://ecency.com". However, you should change `name`, `title` and `twitterHandle`. There are also a lot of static pages that are Ecency specific.
The 'appURL' member should be the URL of the front end you are running. If you are running this testing, it should be "http://localhost" so hiveSigner redirects you back to localhost. The default is 'https://ecency.com'.
The testnet member should be set to false, unless you want to use a Hive testnet

##### Start website in dev

Expand Down
42 changes: 21 additions & 21 deletions public/firebase-messaging-sw.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
// Scripts for firebase and firebase messaging
importScripts('https://www.gstatic.com/firebasejs/8.2.0/firebase-app.js');
importScripts('https://www.gstatic.com/firebasejs/8.2.0/firebase-messaging.js');
importScripts("https://www.gstatic.com/firebasejs/8.2.0/firebase-app.js");
importScripts("https://www.gstatic.com/firebasejs/8.2.0/firebase-messaging.js");

// Initialize the Firebase app in the service worker by passing the generated config
var firebaseConfig = {
apiKey: 'AIzaSyDKF-JWDMmUs5ozjK7ZdgG4beHRsAMd2Yw',
authDomain: 'esteem-ded08.firebaseapp.com',
databaseURL: 'https://esteem-ded08.firebaseio.com',
projectId: 'esteem-ded08',
storageBucket: 'esteem-ded08.appspot.com',
messagingSenderId: '211285790917',
appId: '1:211285790917:web:c259d25ed1834c683760ac',
measurementId: 'G-TYQD1N3NR3'
apiKey: "AIzaSyDKF-JWDMmUs5ozjK7ZdgG4beHRsAMd2Yw",
authDomain: "esteem-ded08.firebaseapp.com",
databaseURL: "https://esteem-ded08.firebaseio.com",
projectId: "esteem-ded08",
storageBucket: "esteem-ded08.appspot.com",
messagingSenderId: "211285790917",
appId: "1:211285790917:web:c259d25ed1834c683760ac",
measurementId: "G-TYQD1N3NR3"
};

firebase.initializeApp(firebaseConfig);
Expand All @@ -21,28 +21,28 @@ const messaging = firebase.messaging();

messaging.onBackgroundMessage(function (payload) {
//console.log('Received bg notification', payload);
const notificationTitle = payload.notification?.title || 'Ecency';
const notificationTitle = payload.notification?.title || "Ecency";

self.registration.showNotification(notificationTitle, {
body: payload.notification?.body,
icon: payload.notification?.image || 'https://ecency.com/static/media/logo-circle.2df6f251.svg',
data: payload.data,
icon: payload.notification?.image || "https://ecency.com/static/media/logo-circle.2df6f251.svg",
data: payload.data
});
});

self.addEventListener('notificationclick', function (event) {
self.addEventListener("notificationclick", function (event) {
const data = event.notification.data;
let url = 'https://ecency.com';
let url = "https://ecency.com";
const fullPermlink = data.permlink1 + data.permlink2 + data.permlink3;
if (['vote', 'unvote', 'spin', 'inactive'].includes(data.type)) {
url += '/@' + data.target;
if (["vote", "unvote", "spin", "inactive"].includes(data.type)) {
url += "/@" + data.target;
} else {
// delegation, mention, transfer, follow, unfollow, ignore, blacklist, reblog
url += '/@' + data.source;
url += "/@" + data.source;
}
if (fullPermlink) {
url += '/' + fullPermlink;
url += "/" + fullPermlink;
}

clients.openWindow(url, '_blank');
});
clients.openWindow(url, "_blank");
});
26 changes: 14 additions & 12 deletions razzle.config.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
'use strict';
const LoadableWebpackPlugin = require('@loadable/webpack-plugin');
const { loadableTransformer } = require('loadable-ts-transformer');
const path = require('path');
"use strict";
const LoadableWebpackPlugin = require("@loadable/webpack-plugin");
const { loadableTransformer } = require("loadable-ts-transformer");
const path = require("path");

module.exports = {
plugins: ['typescript', 'scss'],
plugins: ["typescript", "scss"],
options: {
buildType: 'iso'
buildType: "iso"
},
modifyWebpackConfig({
env: {
target, // the target 'node' or 'web'
dev, // is this a development build? true or false
dev // is this a development build? true or false
},
webpackConfig, // the created webpack config
webpackObject, // the imported webpack node module
options: {
pluginOptions, // the options passed to the plugin ({ name:'pluginname', options: { key: 'value'}})
razzleOptions, // the modified options passed to Razzle in the `options` key in `razzle.config.js` (options: { key: 'value'})
webpackOptions, // the modified options that was used to configure webpack/ webpack loaders and plugins
webpackOptions // the modified options that was used to configure webpack/ webpack loaders and plugins
},
paths, // the modified paths that will be used by Razzle.
paths // the modified paths that will be used by Razzle.
}) {
// Do some stuff to webpackConfig
if (target === "web") {
Expand All @@ -31,16 +31,18 @@ module.exports = {
webpackConfig.plugins.push(
new LoadableWebpackPlugin({
outputAsset: true,
writeToDisk: { filename },
writeToDisk: { filename }
})
);
}

// Enable SSR lazy-loading
const tsLoader = webpackConfig.module.rules.find(rule => !(rule.test instanceof Array) && rule.test && rule.test.test('.tsx'));
const tsLoader = webpackConfig.module.rules.find(
(rule) => !(rule.test instanceof Array) && rule.test && rule.test.test(".tsx")
);
tsLoader.use[0].options.getCustomTransformers = () => ({ before: [loadableTransformer] });

webpackConfig.devtool = dev ? 'source-map' : false;
webpackConfig.devtool = dev ? "source-map" : false;
return webpackConfig;
}
};
137 changes: 132 additions & 5 deletions src/common/api/hive-engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,47 @@ export interface TokenStatus {
precision: number;
}

export interface Unstake {
_id: number;
account: string;
symbol: string;
quantity: string;
quantityLeft: string;
nextTransactionTimestamp: number;
numberTransactionsLeft: string;
millisecPerPeriod: string;
txID: string;
}

import { HECoarseTransaction, HEFineTransaction } from "../store/transactions/types";

const HIVE_ENGINE_RPC_URL = engine.engineRpcUrl;

export const getPendingUnstakes = (account: string, tokenName: string): Promise<Array<Unstake>> => {
const data = {
jsonrpc: "2.0",
method: "find",
params: {
contract: "tokens",
table: "pendingUnstakes",
query: {
account: account,
token: tokenName
}
},
id: 1
};

return axios
.post(HIVE_ENGINE_RPC_URL, data, {
headers: { "Content-type": "application/json" }
})
.then((r) => r.data.result)
.catch((e) => {
return [];
});
};

export const getTokenBalances = (account: string): Promise<TokenBalance[]> => {
const data = {
jsonrpc: "2.0",
Expand Down Expand Up @@ -93,6 +132,22 @@ const getTokens = (tokens: string[]): Promise<Token[]> => {
});
};

export const getHiveEngineTokenBalance = async (
account: string,
tokenName: string
): Promise<HiveEngineToken> => {
// commented just to try removing the non-existing unknowing HiveEngineTokenBalance type
// ): Promise<HiveEngineTokenBalance[]> => {
let balances = await getTokenBalances(account);
const tokens = await getTokens([tokenName]);

const balance = balances.find((balance) => balance.symbol == tokenName);
const token = tokens[0];
const tokenMetadata = token && (JSON.parse(token!.metadata) as TokenMetadata);

return new HiveEngineToken({ ...balance, ...token, ...tokenMetadata } as any);
};

export const getHiveEngineTokenBalances = async (account: string): Promise<HiveEngineToken[]> => {
// commented just to try removing the non-existing unknowing HiveEngineTokenBalance type
// ): Promise<HiveEngineTokenBalance[]> => {
Expand Down Expand Up @@ -151,6 +206,83 @@ export const stakeTokens = async (
return broadcastPostingJSON(account, "ssc-mainnet-hive", json);
};

export interface DelegationEntry {
_id: number;
from: string;
to: string;
symbol: string;
quantity: string;
}

export async function getTokenDelegations(account: string): Promise<Array<DelegationEntry>> {
const data = {
jsonrpc: "2.0",
method: "find",
params: {
contract: "tokens",
table: "delegations",
query: {
$or: [{ from: account }, { to: account }]
}
},
id: 3
};
return axios
.post(HIVE_ENGINE_RPC_URL, data, {
headers: { "Content-type": "application/json" }
})
.then((r) => {
const list: Array<DelegationEntry> = r.data.result;
return list;
})
.catch((e) => {
console.log(e.message);
return [];
});
}

// Exclude author and curation reward details
export async function getCoarseTransactions(
account: string,
limit: number,
symbol: string,
offset: number = 0
) {
const response = await axios({
url: "https://accounts.hive-engine.com/accountHistory",
method: "GET",
params: {
account,
limit,
offset,
type: "user",
symbol
}
});
return response.data;
}

// Include virtual transactions like curation and author reward details.
export async function getFineTransactions(
symbol: string,
account: string,
limit: number,
offset: number
): Promise<Array<HEFineTransaction>> {
return axios({
url: `https://scot-api.hive-engine.com/get_account_history`,
method: "GET",
params: {
account,
token: symbol,
limit,
offset
}
}).then((response) => {
return response.data;
});
}

export const getMetrics: any = async (symbol?: any, account?: any) => {
const data = {
jsonrpc: "2.0",
Expand All @@ -166,11 +298,6 @@ export const getMetrics: any = async (symbol?: any, account?: any) => {
id: 1
};

// const result = await axios
// .post(HIVE_ENGINE_RPC_URL, data, {
// headers: { "Content-type": "application/json" }
// })
// return result;
return axios
.post(HIVE_ENGINE_RPC_URL, data, {
headers: { "Content-type": "application/json" }
Expand Down
Loading