Skip to content

Commit

Permalink
Merge pull request #50 from kaleido-io/contract-location
Browse files Browse the repository at this point in the history
Add contractLocation to receipts
  • Loading branch information
peterbroadhurst authored Feb 3, 2023
2 parents d8c74b1 + 149ef19 commit 36a74bd
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/hashicorp/golang-lru v0.5.4
github.com/hyperledger/firefly-common v1.2.1
github.com/hyperledger/firefly-signer v1.1.4
github.com/hyperledger/firefly-transaction-manager v1.2.2
github.com/hyperledger/firefly-transaction-manager v1.2.3
github.com/sirupsen/logrus v1.9.0
github.com/spf13/cobra v1.4.0
github.com/stretchr/testify v1.8.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -868,8 +868,8 @@ github.com/hyperledger/firefly-common v1.2.1 h1:h35T5Ask/ixlW70KZxHpPsO5QfdnKBFE
github.com/hyperledger/firefly-common v1.2.1/go.mod h1:aqaq2ZUzSlkwVC/TF+pwUkHxGDLYSE2DzdozZ1MIMeM=
github.com/hyperledger/firefly-signer v1.1.4 h1:Qpu1GLRWfsU3srtodGYqJ2LmZErYYJPstRLUlyh+zCg=
github.com/hyperledger/firefly-signer v1.1.4/go.mod h1:4h2MN910A2knrWGYCT+aWjBDlhptgQn/9WcT1N/Ct8s=
github.com/hyperledger/firefly-transaction-manager v1.2.2 h1:X0YhLUkDGiqLgti9EhvO7qAzOxvXfw7sWpGNOmfOJ1o=
github.com/hyperledger/firefly-transaction-manager v1.2.2/go.mod h1:6WC9uQKtucZcEFcCPlUdan5gwuas8FbVYQoGUlYhJ/A=
github.com/hyperledger/firefly-transaction-manager v1.2.3 h1:Ah/kRBzc93kfbaK7PA8P8He6H2WTfs1wtWqupW7kzhM=
github.com/hyperledger/firefly-transaction-manager v1.2.3/go.mod h1:6WC9uQKtucZcEFcCPlUdan5gwuas8FbVYQoGUlYhJ/A=
github.com/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho=
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
Expand Down
13 changes: 10 additions & 3 deletions internal/ethereum/get_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 @@ -117,13 +117,20 @@ func (c *ethConnector) TransactionReceipt(ctx context.Context, req *ffcapi.Trans
if ethReceipt.TransactionIndex != nil {
txIndex = ethReceipt.TransactionIndex.BigInt().Int64()
}
return &ffcapi.TransactionReceiptResponse{
receiptResponse := &ffcapi.TransactionReceiptResponse{
BlockNumber: (*fftypes.FFBigInt)(ethReceipt.BlockNumber),
TransactionIndex: fftypes.NewFFBigInt(txIndex),
BlockHash: ethReceipt.BlockHash.String(),
Success: isSuccess,
ProtocolID: ProtocolIDForReceipt((*fftypes.FFBigInt)(ethReceipt.BlockNumber), fftypes.NewFFBigInt(txIndex)),
ExtraInfo: fftypes.JSONAnyPtrBytes(fullReceipt),
}, "", nil
}
if ethReceipt.ContractAddress != nil {
location, _ := json.Marshal(map[string]string{
"address": ethReceipt.ContractAddress.String(),
})
receiptResponse.ContractLocation = fftypes.JSONAnyPtrBytes(location)
}
return receiptResponse, "", nil

}
2 changes: 1 addition & 1 deletion internal/ethereum/get_receipt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const sampleGetReceipt = `{
const sampleJSONRPCReceipt = `{
"blockHash": "0x6197ef1a58a2a592bb447efb651f0db7945de21aa8048801b250bd7b7431f9b6",
"blockNumber": "0x7b9",
"contractAddress": null,
"contractAddress": "0x87ae94ab290932c4e6269648bb47c86978af4436",
"cumulativeGasUsed": "0x8414",
"effectiveGasPrice": "0x0",
"from": "0x2b1c769ef5ad304a4889f2a07a6617cd935849ae",
Expand Down

0 comments on commit 36a74bd

Please sign in to comment.