Skip to content

Commit

Permalink
Merge pull request #61 from hyperledger/contract-location
Browse files Browse the repository at this point in the history
Add contractLocation field to transaction output
  • Loading branch information
nguyer authored Feb 3, 2023
2 parents 8f3be12 + 1f0341c commit b3f786f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
9 changes: 5 additions & 4 deletions pkg/apitypes/managed_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,9 @@ type ReplyHeaders struct {
// latest status change. Full status for a transaction must be retrieved with
// /transactions/{txid}
type TransactionUpdateReply struct {
Headers ReplyHeaders `json:"headers"`
Status TxStatus `json:"status"`
ProtocolID string `json:"protocolId"`
TransactionHash string `json:"transactionHash,omitempty"`
Headers ReplyHeaders `json:"headers"`
Status TxStatus `json:"status"`
ProtocolID string `json:"protocolId"`
TransactionHash string `json:"transactionHash,omitempty"`
ContractLocation *fftypes.JSONAny `json:"contractLocation,omitempty"`
}
3 changes: 2 additions & 1 deletion pkg/ffcapi/transaction_receipt.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2022 Kaleido, Inc.
// Copyright © 2023 Kaleido, Inc.
//
// SPDX-License-Identifier: Apache-2.0
//
Expand Down Expand Up @@ -31,4 +31,5 @@ type TransactionReceiptResponse struct {
Success bool `json:"success"`
ProtocolID string `json:"protocolId"`
ExtraInfo *fftypes.JSONAny `json:"extraInfo"`
ContractLocation *fftypes.JSONAny `json:"contractLocation"`
}
4 changes: 4 additions & 0 deletions pkg/fftm/policyloop.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,10 @@ func (m *manager) sendWSReply(mtx *apitypes.ManagedTX) {
TransactionHash: mtx.TransactionHash,
}

if mtx.Receipt != nil && mtx.Receipt.ContractLocation != nil {
wsr.ContractLocation = mtx.Receipt.ContractLocation
}

if mtx.Receipt != nil {
wsr.ProtocolID = mtx.Receipt.ProtocolID
} else {
Expand Down
1 change: 1 addition & 0 deletions pkg/fftm/policyloop_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ func TestPolicyLoopE2EOk(t *testing.T) {
BlockHash: fftypes.NewRandB32().String(),
ProtocolID: fmt.Sprintf("%.12d/%.6d", fftypes.NewFFBigInt(12345).Int64(), fftypes.NewFFBigInt(10).Int64()),
Success: true,
ContractLocation: fftypes.JSONAnyPtr(`{"address": "0x24746b95d118b2b4e8d07b06b1bad988fbf9415d"}`),
})
n.Transaction.Confirmed(context.Background(), []confirmations.BlockInfo{})
}).Return(nil)
Expand Down

0 comments on commit b3f786f

Please sign in to comment.