|
@@ -21,7 +21,7 @@
|
|
|
const debug = require('debug')('joystream:runtime:base')
|
|
|
const debugTx = require('debug')('joystream:runtime:base:tx')
|
|
|
|
|
|
-const { registerJoystreamTypes } = require('@joystream/types')
|
|
|
+const { types } = require('@joystream/types')
|
|
|
const { ApiPromise, WsProvider } = require('@polkadot/api')
|
|
|
const { IdentitiesApi } = require('@joystream/storage-runtime-api/identities')
|
|
|
const { BalancesApi } = require('@joystream/storage-runtime-api/balances')
|
|
@@ -54,13 +54,10 @@ class RuntimeApi {
|
|
|
|
|
|
options = options || {}
|
|
|
|
|
|
- // Register joystream types
|
|
|
- registerJoystreamTypes()
|
|
|
-
|
|
|
const provider = new WsProvider(options.provider_url || 'ws://localhost:9944')
|
|
|
|
|
|
// Create the API instrance
|
|
|
- this.api = await ApiPromise.create({ provider })
|
|
|
+ this.api = await ApiPromise.create({ provider, types: types })
|
|
|
|
|
|
this.asyncLock = new AsyncLock()
|
|
|
|
|
@@ -158,7 +155,9 @@ class RuntimeApi {
|
|
|
const cachedNonce = this.nonces[accountId]
|
|
|
// In future use this rpc method to take the pending tx pool into account when fetching the nonce
|
|
|
// const nonce = await this.api.rpc.system.accountNextIndex(accountId)
|
|
|
- const systemNonce = await this.api.query.system.accountNonce(accountId)
|
|
|
+ const { nonce } = await this.api.query.system.account(accountId)
|
|
|
+
|
|
|
+ const systemNonce = nonce
|
|
|
|
|
|
const bestNonce = cachedNonce && cachedNonce.gte(systemNonce) ? cachedNonce : systemNonce
|
|
|
|
|
@@ -209,7 +208,7 @@ class RuntimeApi {
|
|
|
|
|
|
// object used to communicate back information from the tx updates handler
|
|
|
const out = {
|
|
|
- lastResult: undefined,
|
|
|
+ lastResult: { status: {} },
|
|
|
}
|
|
|
|
|
|
// synchronize access to nonce
|
|
@@ -337,7 +336,7 @@ class RuntimeApi {
|
|
|
|
|
|
onFinalizedFailed &&
|
|
|
onFinalizedFailed({ err: status.type, result, tx: status.isUsurped ? status.asUsurped : undefined })
|
|
|
- } else if (result.isFinalized) {
|
|
|
+ } else if (result.isCompleted) {
|
|
|
unsubscribe()
|
|
|
|
|
|
debugTx('Finalized', txinfo())
|
|
@@ -357,7 +356,7 @@ class RuntimeApi {
|
|
|
err: 'ExtrinsicFailed',
|
|
|
mappedEvents,
|
|
|
result,
|
|
|
- block: status.asFinalized,
|
|
|
+ block: status.asCompleted,
|
|
|
dispatchError, // we get module number/id and index into the Error enum
|
|
|
})
|
|
|
} else if (success) {
|
|
@@ -365,20 +364,20 @@ class RuntimeApi {
|
|
|
// console, we cannot get it in the events
|
|
|
if (sudid) {
|
|
|
const dispatchSuccess = sudid.event.data[0]
|
|
|
- if (dispatchSuccess.isTrue) {
|
|
|
- onFinalizedSuccess({ mappedEvents, result, block: status.asFinalized })
|
|
|
+ if (dispatchSuccess.isOk) {
|
|
|
+ onFinalizedSuccess({ mappedEvents, result, block: status.asCompleted })
|
|
|
} else {
|
|
|
- onFinalizedFailed({ err: 'SudoFailed', mappedEvents, result, block: status.asFinalized })
|
|
|
+ onFinalizedFailed({ err: 'SudoFailed', mappedEvents, result, block: status.asCompleted })
|
|
|
}
|
|
|
} else if (sudoAsDone) {
|
|
|
const dispatchSuccess = sudoAsDone.event.data[0]
|
|
|
- if (dispatchSuccess.isTrue) {
|
|
|
- onFinalizedSuccess({ mappedEvents, result, block: status.asFinalized })
|
|
|
+ if (dispatchSuccess.isOk) {
|
|
|
+ onFinalizedSuccess({ mappedEvents, result, block: status.asCompleted })
|
|
|
} else {
|
|
|
- onFinalizedFailed({ err: 'SudoAsFailed', mappedEvents, result, block: status.asFinalized })
|
|
|
+ onFinalizedFailed({ err: 'SudoAsFailed', mappedEvents, result, block: status.asCompleted })
|
|
|
}
|
|
|
} else {
|
|
|
- onFinalizedSuccess({ mappedEvents, result, block: status.asFinalized })
|
|
|
+ onFinalizedSuccess({ mappedEvents, result, block: status.asCompleted })
|
|
|
}
|
|
|
}
|
|
|
}
|