From 37c843ad4a236573dbcfb166fe4bec1843e6606f Mon Sep 17 00:00:00 2001 From: Bernardo Ramos Date: Wed, 2 Oct 2024 17:20:19 -0300 Subject: [PATCH 1/7] correct typos and grammar issues --- indexer/cache.go | 2 +- indexer/miner.go | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/indexer/cache.go b/indexer/cache.go index c34f748..812f507 100644 --- a/indexer/cache.go +++ b/indexer/cache.go @@ -93,7 +93,7 @@ func (ns *Cache) refreshVariables(info BlockInfo, blockDoc *doc.EsBlock, minerGR mapBalance := make(map[string]string) ns.addrsBalance.Range(func(k, v interface{}) bool { if addr, ok := k.(string); ok { - if isExiststake := ns.idxer.MinerBalance(blockDoc, addr, minerGRPC); isExiststake == false { + if stakeExists := ns.idxer.MinerBalance(blockDoc, addr, minerGRPC); stakeExists == false { mapBalance[addr] = "" } } diff --git a/indexer/miner.go b/indexer/miner.go index f05210b..e1ac2f9 100644 --- a/indexer/miner.go +++ b/indexer/miner.go @@ -301,7 +301,7 @@ func (ns *Indexer) MinerTokenVerified(tokenAddr, contractAddr, metadata string, if contractAddr != "" && updateContractAddr != contractAddr { tokenDoc, err := ns.getToken(contractAddr) if err != nil || tokenDoc == nil { - ns.log.Error().Err(err).Str("addr", contractAddr).Msg("tokenDoc is not exist. wait until tokenDoc added") + ns.log.Error().Err(err).Str("addr", contractAddr).Msg("tokenDoc does not exist. wait until tokenDoc added") return contractAddr } @@ -318,7 +318,7 @@ func (ns *Indexer) MinerTokenVerified(tokenAddr, contractAddr, metadata string, if updateContractAddr != "" { tokenDoc, err := ns.getToken(updateContractAddr) if err != nil || tokenDoc == nil { - ns.log.Error().Err(err).Str("addr", updateContractAddr).Msg("tokenDoc is not exist. wait until tokenDoc added") + ns.log.Error().Err(err).Str("addr", updateContractAddr).Msg("tokenDoc does not exist. wait until tokenDoc added") return contractAddr // 기존 contract address 반환 } @@ -340,7 +340,7 @@ func (ns *Indexer) MinerContractVerified(tokenAddr, contractAddr, metadata strin if contractAddr != "" && contractAddr != updateContractAddr { contractDoc, err := ns.getContract(contractAddr) if err != nil || contractDoc == nil { - ns.log.Error().Err(err).Str("addr", contractAddr).Msg("contractDoc is not exist. wait until contractDoc added") + ns.log.Error().Err(err).Str("addr", contractAddr).Msg("contractDoc does not exist. wait until contractDoc is added") return contractAddr } contractUpDoc := doc.ConvContractUp(contractDoc.Id, string(NotVerified), "", "", "") @@ -352,7 +352,7 @@ func (ns *Indexer) MinerContractVerified(tokenAddr, contractAddr, metadata strin if updateContractAddr != "" { contractDoc, err := ns.getContract(updateContractAddr) if err != nil || contractDoc == nil { - ns.log.Error().Err(err).Msg("contractDoc is not exist. wait until contractDoc added") + ns.log.Error().Err(err).Msg("contractDoc does not exist. wait until contractDoc is added") return contractAddr // 기존 contract address 반환 } From e72d3cdb85b9bea1492c9c27aaf7384ebfd76cfd Mon Sep 17 00:00:00 2001 From: Bernardo Ramos Date: Wed, 9 Oct 2024 20:03:19 +0000 Subject: [PATCH 2/7] remove CodeUrl field --- indexer/documents/conv.go | 3 +-- indexer/documents/documents.go | 2 -- indexer/miner.go | 6 ++++-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/indexer/documents/conv.go b/indexer/documents/conv.go index 7ec06d3..bf2965a 100644 --- a/indexer/documents/conv.go +++ b/indexer/documents/conv.go @@ -116,12 +116,11 @@ func ConvInternalContract(txDoc *EsTx, contractAddress []byte) *EsContract { } } -func ConvContractUp(contractAddress string, status, token, codeUrl, code string) *EsContractUp { +func ConvContractUp(contractAddress string, status, token, code string) *EsContractUp { return &EsContractUp{ BaseEsType: &BaseEsType{Id: contractAddress}, VerifiedToken: token, VerifiedStatus: status, - CodeUrl: codeUrl, SourceCode: code, } } diff --git a/indexer/documents/documents.go b/indexer/documents/documents.go index 7768598..e5ce1fc 100755 --- a/indexer/documents/documents.go +++ b/indexer/documents/documents.go @@ -92,14 +92,12 @@ type EsContract struct { VerifiedStatus string `json:"verified_status" db:"verified_status"` VerifiedToken string `json:"verified_token" db:"verified_token"` - CodeUrl string `json:"code_url" db:"code_url"` } type EsContractUp struct { *BaseEsType VerifiedStatus string `json:"verified_status" db:"verified_status"` VerifiedToken string `json:"verified_token" db:"verified_token"` - CodeUrl string `json:"code_url" db:"code_url"` SourceCode string `json:"source_code" db:"source_code"` } diff --git a/indexer/miner.go b/indexer/miner.go index e1ac2f9..523df83 100644 --- a/indexer/miner.go +++ b/indexer/miner.go @@ -334,7 +334,7 @@ func (ns *Indexer) MinerTokenVerified(tokenAddr, contractAddr, metadata string, } func (ns *Indexer) MinerContractVerified(tokenAddr, contractAddr, metadata string, MinerGRPC *client.AergoClientController) (updateContractAddr string) { - updateContractAddr, _, codeUrl := transaction.UnmarshalMetadataVerifyContract(metadata) + updateContractAddr, _, _ := transaction.UnmarshalMetadataVerifyContract(metadata) // remove exist contract info if contractAddr != "" && contractAddr != updateContractAddr { @@ -356,6 +356,7 @@ func (ns *Indexer) MinerContractVerified(tokenAddr, contractAddr, metadata strin return contractAddr // 기존 contract address 반환 } + /* // skip if codeUrl not changed var code string var status string = string(NotVerified) @@ -369,6 +370,7 @@ func (ns *Indexer) MinerContractVerified(tokenAddr, contractAddr, metadata strin } else if len(code) > 0 { status = string(Verified) } + */ // TODO : valid bytecode /* @@ -392,7 +394,7 @@ func (ns *Indexer) MinerContractVerified(tokenAddr, contractAddr, metadata strin } */ - contractUpDoc := doc.ConvContractUp(updateContractAddr, status, tokenAddr, codeUrl, code) + contractUpDoc := doc.ConvContractUp(updateContractAddr, status, tokenAddr, code) ns.updateContract(contractUpDoc) ns.log.Info().Str("contract", updateContractAddr).Str("token", tokenAddr).Msg("verified contract updated") } From 811414e998959d523aded3b4c01973671dadae72 Mon Sep 17 00:00:00 2001 From: Bernardo Ramos Date: Wed, 9 Oct 2024 20:13:50 +0000 Subject: [PATCH 3/7] separate update of source-code and token info --- indexer/documents/conv.go | 12 +++++++++--- indexer/documents/documents.go | 8 ++++++-- indexer/dto.go | 11 +++++++++-- indexer/miner.go | 10 +++++----- 4 files changed, 29 insertions(+), 12 deletions(-) diff --git a/indexer/documents/conv.go b/indexer/documents/conv.go index bf2965a..a7bfc6f 100644 --- a/indexer/documents/conv.go +++ b/indexer/documents/conv.go @@ -116,12 +116,18 @@ func ConvInternalContract(txDoc *EsTx, contractAddress []byte) *EsContract { } } -func ConvContractUp(contractAddress string, status, token, code string) *EsContractUp { - return &EsContractUp{ +func ConvContractSource(contractAddress string, sourceCode string) *EsContractSource { + return &EsContractSource{ + BaseEsType: &BaseEsType{Id: contractAddress}, + SourceCode: sourceCode, + } +} + +func ConvContractToken(contractAddress string, status, token string) *EsContractToken { + return &EsContractToken{ BaseEsType: &BaseEsType{Id: contractAddress}, VerifiedToken: token, VerifiedStatus: status, - SourceCode: code, } } diff --git a/indexer/documents/documents.go b/indexer/documents/documents.go index e5ce1fc..740f1ef 100755 --- a/indexer/documents/documents.go +++ b/indexer/documents/documents.go @@ -94,11 +94,15 @@ type EsContract struct { VerifiedToken string `json:"verified_token" db:"verified_token"` } -type EsContractUp struct { +type EsContractSource struct { + *BaseEsType + SourceCode string `json:"source_code" db:"source_code"` +} + +type EsContractToken struct { *BaseEsType VerifiedStatus string `json:"verified_status" db:"verified_status"` VerifiedToken string `json:"verified_token" db:"verified_token"` - SourceCode string `json:"source_code" db:"source_code"` } // EsEvent is a contract-event mapping stored in the database diff --git a/indexer/dto.go b/indexer/dto.go index d6c5741..e64de95 100644 --- a/indexer/dto.go +++ b/indexer/dto.go @@ -147,10 +147,17 @@ func (ns *Indexer) updateTokenVerified(tokenDoc *doc.EsTokenUpVerified) { } } -func (ns *Indexer) updateContract(contractDoc *doc.EsContractUp) { +func (ns *Indexer) updateContractSource(contractDoc *doc.EsContractSource) { err := ns.db.Update(contractDoc, ns.indexNamePrefix+"contract", contractDoc.Id) if err != nil { - ns.log.Error().Str("Id", contractDoc.Id).Err(err).Str("method", "updateContract").Msg("error while update") + ns.log.Error().Str("Id", contractDoc.Id).Err(err).Str("method", "updateContractSource").Msg("error while update") + } +} + +func (ns *Indexer) updateContractToken(contractDoc *doc.EsContractToken) { + err := ns.db.Update(contractDoc, ns.indexNamePrefix+"contract", contractDoc.Id) + if err != nil { + ns.log.Error().Str("Id", contractDoc.Id).Err(err).Str("method", "updateContractToken").Msg("error while update") } } diff --git a/indexer/miner.go b/indexer/miner.go index 523df83..312e1f0 100644 --- a/indexer/miner.go +++ b/indexer/miner.go @@ -336,15 +336,15 @@ func (ns *Indexer) MinerTokenVerified(tokenAddr, contractAddr, metadata string, func (ns *Indexer) MinerContractVerified(tokenAddr, contractAddr, metadata string, MinerGRPC *client.AergoClientController) (updateContractAddr string) { updateContractAddr, _, _ := transaction.UnmarshalMetadataVerifyContract(metadata) - // remove exist contract info + // remove existing contract info (verified token) if contractAddr != "" && contractAddr != updateContractAddr { contractDoc, err := ns.getContract(contractAddr) if err != nil || contractDoc == nil { ns.log.Error().Err(err).Str("addr", contractAddr).Msg("contractDoc does not exist. wait until contractDoc is added") return contractAddr } - contractUpDoc := doc.ConvContractUp(contractDoc.Id, string(NotVerified), "", "", "") - ns.updateContract(contractUpDoc) + contractUpDoc := doc.ConvContractToken(contractDoc.Id, string(NotVerified), "") + ns.updateContractToken(contractUpDoc) ns.log.Info().Str("contract", contractAddr).Str("token", tokenAddr).Msg("verified contract removed") } @@ -394,8 +394,8 @@ func (ns *Indexer) MinerContractVerified(tokenAddr, contractAddr, metadata strin } */ - contractUpDoc := doc.ConvContractUp(updateContractAddr, status, tokenAddr, code) - ns.updateContract(contractUpDoc) + contractUpDoc := doc.ConvContractToken(updateContractAddr, status, tokenAddr) + ns.updateContractToken(contractUpDoc) ns.log.Info().Str("contract", updateContractAddr).Str("token", tokenAddr).Msg("verified contract updated") } return updateContractAddr From e32d44280b9ca848db1ce6dad2d8688cf86a8c77 Mon Sep 17 00:00:00 2001 From: Bernardo Ramos Date: Wed, 9 Oct 2024 20:22:17 +0000 Subject: [PATCH 4/7] rename variable --- indexer/miner.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/indexer/miner.go b/indexer/miner.go index 312e1f0..fea1456 100644 --- a/indexer/miner.go +++ b/indexer/miner.go @@ -333,7 +333,7 @@ func (ns *Indexer) MinerTokenVerified(tokenAddr, contractAddr, metadata string, return updateContractAddr } -func (ns *Indexer) MinerContractVerified(tokenAddr, contractAddr, metadata string, MinerGRPC *client.AergoClientController) (updateContractAddr string) { +func (ns *Indexer) MinerContractVerified(tokenSymbol, contractAddr, metadata string, MinerGRPC *client.AergoClientController) (updateContractAddr string) { updateContractAddr, _, _ := transaction.UnmarshalMetadataVerifyContract(metadata) // remove existing contract info (verified token) @@ -345,7 +345,7 @@ func (ns *Indexer) MinerContractVerified(tokenAddr, contractAddr, metadata strin } contractUpDoc := doc.ConvContractToken(contractDoc.Id, string(NotVerified), "") ns.updateContractToken(contractUpDoc) - ns.log.Info().Str("contract", contractAddr).Str("token", tokenAddr).Msg("verified contract removed") + ns.log.Info().Str("contract", contractAddr).Str("token", tokenSymbol).Msg("verified contract removed") } // update contract info @@ -361,7 +361,7 @@ func (ns *Indexer) MinerContractVerified(tokenAddr, contractAddr, metadata strin var code string var status string = string(NotVerified) if codeUrl != "" && contractDoc.CodeUrl == codeUrl { - ns.log.Debug().Str("method", "verifyContract").Str("tokenAddr", tokenAddr).Msg("codeUrl is not changed, skip") + ns.log.Debug().Str("method", "verifyContract").Str("token", tokenSymbol).Msg("codeUrl is not changed, skip") return updateContractAddr } code, err = lua_compiler.GetCode(codeUrl) @@ -384,7 +384,7 @@ func (ns *Indexer) MinerContractVerified(tokenAddr, contractAddr, metadata strin if bytes.Contains([]byte(contractDoc.Payload), bytecode) == true { status = string(Verified) } else { - ns.log.Error().Str("method", "verifyContract").Str("tokenAddr", tokenAddr).Msg("Failed to verify contract") + ns.log.Error().Str("method", "verifyContract").Str("token", tokenSymbol).Msg("Failed to verify contract") fmt.Println([]byte(contractDoc.Payload)) var i interface{} json.Unmarshal([]byte(contractDoc.Payload), i) @@ -394,9 +394,9 @@ func (ns *Indexer) MinerContractVerified(tokenAddr, contractAddr, metadata strin } */ - contractUpDoc := doc.ConvContractToken(updateContractAddr, status, tokenAddr) + contractUpDoc := doc.ConvContractToken(updateContractAddr, status, tokenSymbol) ns.updateContractToken(contractUpDoc) - ns.log.Info().Str("contract", updateContractAddr).Str("token", tokenAddr).Msg("verified contract updated") + ns.log.Info().Str("contract", updateContractAddr).Str("token", tokenSymbol).Msg("verified contract updated") } return updateContractAddr } From b9bd017e4a78e30a3d75802ba237418d634dcde5 Mon Sep 17 00:00:00 2001 From: Bernardo Ramos Date: Wed, 9 Oct 2024 20:22:26 +0000 Subject: [PATCH 5/7] update readme --- README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 36d9e84..dcf5414 100755 --- a/README.md +++ b/README.md @@ -83,10 +83,12 @@ tx_id string tx hash creator string creators address blockno uint64 block number ts timestamp last updated timestamp (unixnano) -payload string compiled bytecode +abi string contract abi +byte_code string compiled bytecode +source_code string contract source code +deploy_args string constructor function arguments verified_status string verified status -verified_token string verified token address -code string verified contract code +verified_token string verified token symbol ``` event From 3ee39cebf5031112916ac99e97798347bc0bcc9a Mon Sep 17 00:00:00 2001 From: Bernardo Ramos Date: Wed, 9 Oct 2024 21:28:23 +0000 Subject: [PATCH 6/7] add function checkContractSourceCode --- indexer/documents/conv.go | 12 ++++++---- indexer/miner.go | 48 +++++++++++++++++++++++++++++++-------- 2 files changed, 47 insertions(+), 13 deletions(-) diff --git a/indexer/documents/conv.go b/indexer/documents/conv.go index a7bfc6f..b598006 100644 --- a/indexer/documents/conv.go +++ b/indexer/documents/conv.go @@ -144,7 +144,10 @@ func extractContractCode(payload []byte) ([]byte, string, string, string) { } // on hardfork 4, the deploy contains the contract source code and deploy args sourceCode, deployArgs := extractSourceCode(payload) - bytecode, abi := compileSourceCode(sourceCode) + bytecode, abi, err := CompileSourceCode(sourceCode) + if err != nil { + panic(err) + } return bytecode, sourceCode, abi, deployArgs } @@ -175,17 +178,18 @@ func extractSourceCode(payload []byte) (string, string) { return string(sourceCode), string(deployArgs) } -func compileSourceCode(sourceCode string) ([]byte, string) { +// CompileSourceCode compiles the source code and returns the bytecode and abi +func CompileSourceCode(sourceCode string) ([]byte, string, error) { bytecodeABI, err := lua_compiler.CompileCode(sourceCode) if err != nil { - panic(err) + return nil, "", err } // read the bytecode length bytecodeLength := binary.BigEndian.Uint32(bytecodeABI[:4]) // extract the bytecode and abi bytecode := bytecodeABI[4:bytecodeLength] abi := bytecodeABI[4+bytecodeLength:] - return bytecode, string(abi) + return bytecode, string(abi), nil } // ConvEvent converts Event from RPC into Elasticsearch type diff --git a/indexer/miner.go b/indexer/miner.go index fea1456..9566669 100644 --- a/indexer/miner.go +++ b/indexer/miner.go @@ -8,7 +8,6 @@ import ( "github.com/aergoio/aergo-indexer-2.0/indexer/client" doc "github.com/aergoio/aergo-indexer-2.0/indexer/documents" "github.com/aergoio/aergo-indexer-2.0/indexer/transaction" - "github.com/aergoio/aergo-indexer-2.0/lua_compiler" "github.com/aergoio/aergo-indexer-2.0/types" ) @@ -333,8 +332,12 @@ func (ns *Indexer) MinerTokenVerified(tokenAddr, contractAddr, metadata string, return updateContractAddr } +// it appears that this function is used for 2 different cases: +// 1. verifying and updating the contract source code +// 2. updating the verified token status +// TODO: separate the logic into two different functions func (ns *Indexer) MinerContractVerified(tokenSymbol, contractAddr, metadata string, MinerGRPC *client.AergoClientController) (updateContractAddr string) { - updateContractAddr, _, _ := transaction.UnmarshalMetadataVerifyContract(metadata) + updateContractAddr, _, _ = transaction.UnmarshalMetadataVerifyContract(metadata) // remove existing contract info (verified token) if contractAddr != "" && contractAddr != updateContractAddr { @@ -359,7 +362,6 @@ func (ns *Indexer) MinerContractVerified(tokenSymbol, contractAddr, metadata str /* // skip if codeUrl not changed var code string - var status string = string(NotVerified) if codeUrl != "" && contractDoc.CodeUrl == codeUrl { ns.log.Debug().Str("method", "verifyContract").Str("token", tokenSymbol).Msg("codeUrl is not changed, skip") return updateContractAddr @@ -368,7 +370,7 @@ func (ns *Indexer) MinerContractVerified(tokenSymbol, contractAddr, metadata str if err != nil { ns.log.Error().Err(err).Str("method", "verifyContract").Msg("Failed to get code") } else if len(code) > 0 { - status = string(Verified) + ... } */ @@ -380,9 +382,8 @@ func (ns *Indexer) MinerContractVerified(tokenSymbol, contractAddr, metadata str } // compare bytecode and payload - var status string - if bytes.Contains([]byte(contractDoc.Payload), bytecode) == true { - status = string(Verified) + if bytes.Equal([]byte(contractDoc.ByteCode), bytecode) == true { + ... } else { ns.log.Error().Str("method", "verifyContract").Str("token", tokenSymbol).Msg("Failed to verify contract") fmt.Println([]byte(contractDoc.Payload)) @@ -390,13 +391,42 @@ func (ns *Indexer) MinerContractVerified(tokenSymbol, contractAddr, metadata str json.Unmarshal([]byte(contractDoc.Payload), i) fmt.Println(i) fmt.Println(bytecode) - status = string(NotVerified) } */ - contractUpDoc := doc.ConvContractToken(updateContractAddr, status, tokenSymbol) + contractUpDoc := doc.ConvContractToken(updateContractAddr, string(Verified), tokenSymbol) ns.updateContractToken(contractUpDoc) ns.log.Info().Str("contract", updateContractAddr).Str("token", tokenSymbol).Msg("verified contract updated") } return updateContractAddr } + +// TODO: use this function in the backend +func (ns *Indexer) checkContractSourceCode(contractAddress, sourceCode string) (status string) { + contractDoc, err := ns.getContract(contractAddress) + if err != nil || contractDoc == nil { + ns.log.Error().Err(err).Str("addr", contractAddress).Msg("not found") + return "this contract is not yet added to the index. wait until it is indexed or check the contract address" + } + + // compile the source code + bytecode, _, err := doc.CompileSourceCode(sourceCode) + if err != nil { + ns.log.Error().Err(err).Str("addr", contractAddress).Msg("failed to compile source code") + return "compile error" + } + + // compare the generated bytecode with the contract bytecode + isCorrect := bytes.Equal(bytecode, []byte(contractDoc.ByteCode)) + + if isCorrect { + // store the source code in the contract doc + contractUpDoc := doc.ConvContractSource(contractDoc.Id, sourceCode) + ns.updateContractSource(contractUpDoc) + ns.log.Info().Str("contract", contractAddress).Msg("contract source code updated") + return "OK" + } else { + ns.log.Error().Str("contract", contractAddress).Msg("invalid source code") + return "invalid source code" + } +} From 6296654934404fb5e39a35bff03b73e3c29c8d41 Mon Sep 17 00:00:00 2001 From: Bernardo Ramos Date: Wed, 9 Oct 2024 23:37:11 +0000 Subject: [PATCH 7/7] add function ConvContractFromCall --- indexer/documents/conv.go | 20 +++++++++++++++----- indexer/documents/conv_test.go | 2 +- indexer/miner.go | 2 +- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/indexer/documents/conv.go b/indexer/documents/conv.go index b598006..0d9cbb9 100644 --- a/indexer/documents/conv.go +++ b/indexer/documents/conv.go @@ -88,17 +88,27 @@ func ConvTx(txIdx uint64, tx *types.Tx, receipt *types.Receipt, blockDoc *EsBloc } } -// ConvContractCreateTx creates document for token creation -func ConvContract(txDoc *EsTx, contractAddress []byte) *EsContract { - +// ConvContractFromTx creates document for contract creation +func ConvContractFromTx(txDoc *EsTx, contractAddress []byte) *EsContract { byteCode, sourceCode, abi, deployArgs := extractContractCode(txDoc.Payload) + return ConvContract(txDoc, contractAddress, txDoc.Account, byteCode, abi, sourceCode, deployArgs) +} + +func ConvContractFromCall(txDoc *EsTx, contractAddress []byte, creator, sourceCode, deployArgs string) *EsContract { + byteCode, abi, err := CompileSourceCode(sourceCode) + if err != nil { + panic(err) + } + return ConvContract(txDoc, contractAddress, creator, byteCode, abi, sourceCode, deployArgs) +} +func ConvContract(txDoc *EsTx, contractAddress []byte, creator string, byteCode []byte, abi, sourceCode, deployArgs string) *EsContract { return &EsContract{ BaseEsType: &BaseEsType{Id: transaction.EncodeAndResolveAccount(contractAddress, txDoc.BlockNo)}, - Creator: txDoc.Account, - TxId: txDoc.GetID(), BlockNo: txDoc.BlockNo, Timestamp: txDoc.Timestamp, + TxId: txDoc.GetID(), + Creator: creator, ABI: abi, ByteCode: byteCode, SourceCode: sourceCode, diff --git a/indexer/documents/conv_test.go b/indexer/documents/conv_test.go index 9a8bc77..8c4ebc4 100644 --- a/indexer/documents/conv_test.go +++ b/indexer/documents/conv_test.go @@ -95,7 +95,7 @@ func TestConvTx(t *testing.T) { func TestConvContract(t *testing.T) { fn_test := func(esTx *EsTx, contractAddress []byte, esContractExpect *EsContract) { - esContractConv := ConvContract(esTx, contractAddress) + esContractConv := ConvContractFromTx(esTx, contractAddress) require.Equal(t, esContractExpect, esContractConv) } diff --git a/indexer/miner.go b/indexer/miner.go index 9566669..5e9a5b9 100644 --- a/indexer/miner.go +++ b/indexer/miner.go @@ -89,7 +89,7 @@ func (ns *Indexer) MinerTx(txIdx uint64, info BlockInfo, blockDoc *doc.EsBlock, // Process Contract Deploy if txDoc.Category == transaction.TxDeploy { - contractDoc := doc.ConvContract(txDoc, receipt.ContractAddress) + contractDoc := doc.ConvContractFromTx(txDoc, receipt.ContractAddress) ns.addContract(info.Type, contractDoc) }