Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean console logs #2

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@jmgayosso/nbv-client-api",
"version": "0.0.2",
"version": "0.0.4",
"description": "Client API that handles calls and queries to interact with NBV pallet",
"main": "src/index.js",
"scripts": {
Expand Down
14 changes: 7 additions & 7 deletions src/model/basePolkadot.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class BasePolkadot {
* @returns Query response or unsubscribe function from polkadot api
*/
async exEntriesQuery (queryName, params, pagination, subTrigger) {
console.log('exEntriesQuery params', { queryName, params, pagination, subTrigger })
// console.log('exEntriesQuery params', { queryName, params, pagination, subTrigger })
if (!params) {
return this.polkadot._api.query[this.palletName][queryName].entries()
}
Expand Down Expand Up @@ -95,14 +95,14 @@ class BasePolkadot {
type: 'listening'
})
const { events = [], status } = e
console.log('events', events)
console.log('status', status)
// console.log('events', events)
// console.log('status', status)
if (status.isFinalized || status.isInBlock) {
// console.log(`Transaction included at blockHash ${status.asFinalized}`)

// Loop through Vec<EventRecord> to display all events
events.forEach(({ phase, event: { data, method, section } }) => {
console.log(`\t' ${phase}: ${section}.${method}:: ${data}`)
// console.log(`\t' ${phase}: ${section}.${method}:: ${data}`)
})

events.filter(({ event: { section } }) => section === 'system').forEach(({ event: { method, data } }) => {
Expand All @@ -123,13 +123,13 @@ class BasePolkadot {
}

// console.error('errorInfo', errorInfo)
console.log('unsub', unsub)
// console.log('unsub', unsub)
unsub()
reject(`Extrinsic failed: ${errorInfo}`)
// const mod = data[0].asModule
} else if (method === 'ExtrinsicSuccess') {
console.log('ExtrinsicSuccess', data)
console.log('unsub', unsub)
// console.log('ExtrinsicSuccess', data)
// console.log('unsub', unsub)
unsub()
resolve(data)
// txSuccessCb(result);
Expand Down
56 changes: 56 additions & 0 deletions src/model/polkadot-pallets/nbvStorageApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,62 @@ class NbvStorageApi extends BasePolkadot {
params: [proposalId]
})
}

/**
* @description Create proof of reserves
* @param {String} vaultId Vault Id
* @param {String} message message
* @param {String} psbt psbt
* @returns
*/
createProofOfReserves ({ vaultId, message, psbt }) {
return this.callTx({
extrinsicName: 'createProof',
signer: this._signer,
params: [vaultId, message, psbt]
})
}

/**
* @description Save Proof Of Reserves PSBTs
* @param {String} vaultId Vault Id
* @param {String} psbt psbt
* @param {Boolean} isFinalized falg
* @returns
*/
saveProofOfReservesPSBT ({ vaultId, psbt }) {
return this.callTx({
extrinsicName: 'saveProofPsbt',
signer: this._signer,
params: [vaultId, psbt]
})
}

/**
* @description Finalize proof of reserves
* @param {String} vaultId Vault Id
* @param {String} psbt psbt
* @returns
*/
finalizeProofOfReserves ({ vaultId, psbt }) {
return this.callTx({
extrinsicName: 'finalizeProof',
signer: this._signer,
params: [vaultId, psbt]
})
}

/**
* @name getProofOfReservesByVault
* @description Get all proof of reserves for a vault
* @param {String} vaultId Vault Id
* @param {Function} subTrigger Function to trigger when subscription detect changes
* @returns {Array} array of vaults Id
* [{ id }]
*/
getProofOfReservesByVault ({ vaultId, subTrigger }) {
return this.exQuery('proofOfReserves', [vaultId], subTrigger)
}
}

// export default NbvStorageApi
Expand Down