Balance Stays Zero - substrate

await api.query.system.account('5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY') returns { nonce: '0', consumers: '0', providers: '0', data: { free: '0', reserved: '0', miscFrozen: '0', feeFrozen: '0' } } and await api.query.system.account('5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY')
returns { free: '0', reserved: '0', miscFrozen: '0', feeFrozen: '0' } with the following genesis.json
"palletBalances": {
"balances": [
[
"5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY",
1152921504606846976
],
using the substrate node template 3.0.0
I've tried to use the balances pallet instead of the system pallet to store the balances but still

Related

#ibm-cloud/cloudant: includeDocs: true, still not able to get the entire details of the documents

service.postAllDocs({
db: 'orders',
includeDocs: true,
limit: 10
}).then(response => { console.log(response.result)});
result only returns:
id, key and value(only contains rev)
To fetch the first 10 docs from the database, including the doc bodies, this code works:
const { CloudantV1 } = require('#ibm-cloud/cloudant')
const client = CloudantV1.newInstance()
const DBNAME = 'orders'
const main = async function () {
const response = await client.postAllDocs({ db: DBNAME, includeDocs: true, limit: 10 })
console.log(response.result.rows)
}
main()
This produces the following output:
[
{
id: '1',
key: '1',
value: { rev: '1-0fdc08a2625917344e37eb91661a5568' },
doc: {
_id: '1',
_rev: '1-0fdc08a2625917344e37eb91661a5568',
fruit: 'banana'
}
},
{
id: '2',
key: '2',
value: { rev: '1-8c4d4385540143ea87f8663193105425' },
doc: {
_id: '2',
_rev: '1-8c4d4385540143ea87f8663193105425',
fruit: 'apple'
}
}
]
The document body is under the doc attribute in each object.

Why Am I getting an object with action observer property from selector using withLatestFrom operation in effect?

The "res" value is an object, that is not retrieving the data related to the selector, is working in other places, but in the effect is getting this object. Why is happening this?
constructor(
private serviceStore: Store<DataState>,
) {
searchForLatest$ = createEffect(() =>
this._actions.pipe(
ofType<GetLatestRequestService>(GetLatestData),
withLatestFrom(({ id }) =>
this.serviceStore.select(getlatestData(id)),
mergeMap(res => {
actionsObserver: {
closed: false,
hasError: false,
isStopped: false,
observers: [SkipSubscriber],
thrownError: null,
_isScalar: false,
}
operator: {
compare: undefined
keySelector: undefined
}
reducerManager: {
closed: false
dispatcher: DevtoolsDispatcher {_isScalar: false, observers: Array(1), closed: false,
isStopped: false, hasError: false, …}
hasError: false
initialState: undefined
isStopped: false
observers: [MapSubscriber]
reducerFactory: (reducers, initialState) => {…}
reducers: {uiContext: ƒ, parties: ƒ, user: ƒ, organizationsDetail: ƒ, activeRoute: ƒ, …}
thrownError: null
_isScalar: false
_value: (state, action) =>
}
Source: {
actionsObserver: ActionsSubject {_isScalar: false, observers: Array(1), closed: false,
isStopped: false, hasError: false, …}
operator: MapOperator {thisArg: undefined, project: ƒ}
reducerManager: ReducerManager {_isScalar: false, observers: Array(1), closed: false,
isStopped: false, hasError: false, …}
source: Store {_isScalar: false, actionsObserver: ActionsSubject, reducerManager:
ReducerManager, source: Observable}
_isScalar: false
}
_isScalar: false
The effects in v13 updated the approach to retrieve the latest data from a selector, I need to use the concatLatestFrom operator to get the data.
#Injectable()
export class CollectionEffects {
addBookToCollectionSuccess$ = createEffect(
() =>
this.actions$.pipe(
ofType(CollectionApiActions.addBookSuccess),
concatLatestFrom(action => this.store.select(fromBooks.getCollectionBookIds)),
tap(([action, bookCollection]) => {
if (bookCollection.length === 1) {
window.alert('Congrats on adding your first book!');
} else {
window.alert('You have added book number ' + bookCollection.length);
}
})
),
{ dispatch: false }
);
constructor(
private actions$: Actions,
private store: Store<fromBooks.State>
) {}
}
Note: For performance reasons, use a flattening operator like concatLatestFrom to prevent the selector from firing until the correct action is dispatched.

convert rxjs5 operators into rxjs6

i have following code written in rxjs5 and it broke with rxjs6
can some one help me with write in rxjs 6
its failing mergemap receiving groupedObserable which does not have count method and along also filter method does not exist.
list [
{id: '1', type: 't1', name: 'f1', des:'d1', selected: true},
{id: '2', type: 't1', name: 'f2', des:'d2', selected: false},
{id: '3', type: 't1', name: 'f11', des:'d11', selected: false},
{id: '4', type: 't1', name: 'f22', des:'d22', selected: true},
]
Observable.from(list)
.filter(a => a.name != null)
.groupBy(i => i.type)
.mergeMap(list => {
let count = list.count;
let selectedCount = 0;
list.filter( f => f.selected).count.subscribe(c => selectedCount = c)
return count.map(count => {
{
key: list.key,
totalCount: count,
selected: selectedCount
}
}
}).reduce((x, y) => {
x.isValid = x.selectedCount > 0
return x;
}).subscribe(r => {
console.log(r + 'any item selected')
}
)
when i tried to write in rxjs6 only progress i was able to made till here
thanks in advance.
from(list)
.pipe(
filter( s=> s.name != null) ,
groupBy(i => i.type),
mergeMap( (value, index) => {
value.count // that's where it starts to fail
}
))
The equivalent rxjs6 code should be like this:
from(list)
.pipe(
filter(a => a.name != null),
groupBy(i => i.type),
mergeMap((p) => {
return p.pipe(
filter(f => f.selected),
count(),
mergeMap(c => {
return p.pipe(
count(),
map(totalCount => {
return {
key: p.key,
totalCount: totalCount,
selected: c
};
})
);
})
);
}),
reduce((x, y) => {
//please adjust your code here as i could not see isValid on x
x.isValid = x.selectedCount > 0;
return x;
})
).subscribe(r => {
console.log(r + 'any item selected')
}
)
Hope it gives an idea of how to proceed.

How to increase performance of pouchdb-find queries?

I'm using pouchDB replication from couchDB in react native. This is my package.json:
"pouchdb": "^6.3.4",
"pouchdb-find": "^6.3.4",
"pouchdb-react-native": "^6.3.4",
I've a database named "databaseA" where one of the column is "col1". I've written a query using pouchdb-find to get all records of databaseA with matching
value in col1.
const localDB = new PouchDB('databaseA');
const remoteDB = new PouchDB('databaseA');
PouchDB.plugin(findPlugin);
localDB.replicate.from(
remoteDB,
(err, response) => {
if (err) {
return console.log(err);
}
},
);
localDB.createIndex({
index: {
fields: ['col1', 'col2'],
ddoc: 'col1-col2-index',
},
});
localDB.find({
selector: {
col1: {
$eq: '1',
},
col2: true,
},
fields: ['_id', 'col1', 'col2' ],
limit: 0,
// sort: [‘_id’],
use_index: 'col1-col2-index',
}).then((results) => {
alert(`Index called to increase speed: ${results.docs.length}`);
}).catch((ex) => {
// alert(`Index called to increase speed: Exception: ${JSON.stringify(ex)}`);
});
export function getItems(col1) {
const startTime = new Date();
return (dispatch, getState) => {
return localDB.find({
selector: {
col1: {
$eq: col1,
},
col2: true,
},
fields: ['_id', 'col2', 'col1' ],
// sort: [‘_id’],
use_index: 'col1-col2-index',
}).then((results) => {
const time = new Date().getTime() - startTime;
alert(`Total time ${time}`);
}).catch((ex) => {
console.log(ex);
});
};
}
I've around 900 records in the database. It takes nearly 2minutes which is quite high to query. How can the performance of this query be increased? Please help

SlickGrid: how to change column value from '1' to 'enabled'?

I have data column with value '1' or '0' and I need to show 'enabled' or 'disabled' in the grid.
How can I show different values in the grid based on input value?
Answer:
function formatterActive(row, cell, value, columnDef, dataContext) {
if( value == '1' ) {
return 'enabled';
} else { // '0'
return 'disabled';
}
}
columns : [
// ...
{ id: 'active', name: 'active', field: 'active', formatter: formatterActive }
],

Resources