diff --git a/api/spec/v1.yaml b/api/spec/v1.yaml index 7f84109a7..75097944d 100644 --- a/api/spec/v1.yaml +++ b/api/spec/v1.yaml @@ -1226,6 +1226,15 @@ components: success: type: boolean description: Whether this transaction successfully executed. + code: + type: integer + description: The status code of a failed call. + module: + type: string + description: The module of a failed call. + message: + type: string + description: The message of a failed call. description: | A consensus transaction. diff --git a/storage/client/client.go b/storage/client/client.go index 11b322b01..d1841d4b9 100644 --- a/storage/client/client.go +++ b/storage/client/client.go @@ -261,7 +261,8 @@ func (c *StorageClient) Transactions(ctx context.Context, p apiTypes.GetConsensu } for res.rows.Next() { var t Transaction - var code uint64 + var module string + var message string if err := res.rows.Scan( &t.Block, &t.Index, @@ -271,13 +272,18 @@ func (c *StorageClient) Transactions(ctx context.Context, p apiTypes.GetConsensu &t.Fee, &t.Method, &t.Body, - &code, + &t.Code, + &module, + &message, &t.Timestamp, ); err != nil { return nil, wrapError(err) } - if code == oasisErrors.CodeNoError { + if *t.Code == oasisErrors.CodeNoError { t.Success = true + } else { + t.Module = &module + t.Message = &message } ts.Transactions = append(ts.Transactions, t) @@ -295,7 +301,8 @@ func (c *StorageClient) Transaction(ctx context.Context, txHash string) (*Transa } var t Transaction - var code uint64 + var module string + var message string if err := c.db.QueryRow( ctx, queries.Transaction, @@ -309,13 +316,18 @@ func (c *StorageClient) Transaction(ctx context.Context, txHash string) (*Transa &t.Fee, &t.Method, &t.Body, - &code, + &t.Code, + &module, + &message, &t.Timestamp, ); err != nil { return nil, wrapError(err) } - if code == oasisErrors.CodeNoError { + if *t.Code == oasisErrors.CodeNoError { t.Success = true + } else { + t.Module = &module + t.Message = &message } c.cacheTx(&t) diff --git a/storage/client/queries/queries.go b/storage/client/queries/queries.go index d6e1f317b..78efd0dde 100644 --- a/storage/client/queries/queries.go +++ b/storage/client/queries/queries.go @@ -44,6 +44,8 @@ const ( chain.transactions.method as method, chain.transactions.body as body, chain.transactions.code as code, + chain.transactions.module as module, + chain.transactions.message as message, chain.blocks.time as time FROM chain.transactions JOIN chain.blocks ON chain.transactions.block = chain.blocks.height @@ -64,7 +66,7 @@ const ( OFFSET $9::bigint` Transaction = ` - SELECT block, tx_index, tx_hash, sender, nonce, fee_amount, method, body, code, chain.blocks.time + SELECT block, tx_index, tx_hash, sender, nonce, fee_amount, method, body, code, module, message, chain.blocks.time FROM chain.transactions JOIN chain.blocks ON chain.transactions.block = chain.blocks.height WHERE tx_hash = $1::text`