Merge pull request #180 from lbryio/account_balance_039_fix

feat: 0.39 account balance basic API support
This commit is contained in:
Sean Yesmunt 2019-08-19 01:19:23 -04:00 committed by GitHub
commit f4413a8ab4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 32 additions and 5 deletions

7
dist/bundle.es.js vendored
View file

@ -741,7 +741,7 @@ const Lbry = {
blob_list: (params = {}) => daemonCallWithResult('blob_list', params),
// Wallet utilities
account_balance: (params = {}) => daemonCallWithResult('account_balance', params),
account_balance: () => daemonCallWithResult('account_balance'),
account_decrypt: () => daemonCallWithResult('account_decrypt', {}),
account_encrypt: (params = {}) => daemonCallWithResult('account_encrypt', params),
account_unlock: (params = {}) => daemonCallWithResult('account_unlock', params),
@ -1777,12 +1777,15 @@ function creditsToString(amount) {
return creditString;
}
//
function doUpdateBalance() {
return (dispatch, getState) => {
const {
wallet: { balance: balanceInStore }
} = getState();
lbryProxy.account_balance().then(({ available }) => {
lbryProxy.account_balance().then(response => {
const { available } = response;
const balance = parseFloat(available);
if (balanceInStore !== balance) {
dispatch({

View file

@ -63,6 +63,17 @@ declare type VersionResponse = {
python_version: string,
};
declare type BalanceResponse = {
available: string,
reserved: string,
reserved_subtotals: ? {
claims: string,
supports: string,
tips: string,
},
total: string,
};
declare type ResolveResponse = {
// Keys are the url(s) passed to resolve
[string]: Claim | { error?: {} },

13
flow-typed/Lbry.js vendored
View file

@ -63,6 +63,17 @@ declare type VersionResponse = {
python_version: string,
};
declare type BalanceResponse = {
available: string,
reserved: string,
reserved_subtotals: ?{
claims: string,
supports: string,
tips: string,
},
total: string,
};
declare type ResolveResponse = {
// Keys are the url(s) passed to resolve
[string]: Claim | { error?: {} },
@ -194,7 +205,7 @@ declare type LbryTypes = {
comment_list: (params: {}) => Promise<CommentListResponse>,
comment_create: (params: {}) => Promise<CommentCreateResponse>,
// Wallet utilities
account_balance: (params: {}) => Promise<string>,
account_balance: (params: {}) => Promise<BalanceResponse>,
account_decrypt: (prams: {}) => Promise<boolean>,
account_encrypt: (params: {}) => Promise<boolean>,
account_unlock: (params: {}) => Promise<boolean>,

View file

@ -90,7 +90,7 @@ const Lbry: LbryTypes = {
blob_list: (params = {}) => daemonCallWithResult('blob_list', params),
// Wallet utilities
account_balance: (params = {}) => daemonCallWithResult('account_balance', params),
account_balance: () => daemonCallWithResult('account_balance'),
account_decrypt: () => daemonCallWithResult('account_decrypt', {}),
account_encrypt: (params = {}) => daemonCallWithResult('account_encrypt', params),
account_unlock: (params = {}) => daemonCallWithResult('account_unlock', params),

View file

@ -1,3 +1,4 @@
// @flow
import * as ACTIONS from 'constants/action_types';
import Lbry from 'lbry';
import { doToast } from 'redux/actions/notifications';
@ -10,7 +11,8 @@ export function doUpdateBalance() {
const {
wallet: { balance: balanceInStore },
} = getState();
Lbry.account_balance().then(({ available }) => {
Lbry.account_balance().then((response: BalanceResponse) => {
const { available } = response;
const balance = parseFloat(available);
if (balanceInStore !== balance) {
dispatch({