|
@@ -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 || {}
|
|
|
|
|
|
-
|
|
|
- registerJoystreamTypes()
|
|
|
-
|
|
|
const provider = new WsProvider(options.provider_url || 'ws://localhost:9944')
|
|
|
|
|
|
|
|
|
- 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]
|
|
|
|
|
|
|
|
|
- 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
|
|
|
|
|
@@ -233,11 +232,11 @@ class RuntimeApi {
|
|
|
|
|
|
|
|
|
|
|
|
- if (out.lastResult.status.isFuture) {
|
|
|
- debugTx(`Warning: Submitted Tx with future nonce: ${serialized}`)
|
|
|
- } else {
|
|
|
- debugTx(`Submitted: ${serialized}`)
|
|
|
- }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
this.incrementAndSaveNonce(accountId)
|
|
@@ -251,9 +250,9 @@ class RuntimeApi {
|
|
|
|
|
|
|
|
|
|
|
|
- if (out.lastResult.status.isFuture) {
|
|
|
- return {}
|
|
|
- }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -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,
|
|
|
})
|
|
|
} else if (success) {
|
|
@@ -365,20 +364,20 @@ class RuntimeApi {
|
|
|
|
|
|
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 })
|
|
|
}
|
|
|
}
|
|
|
}
|