From c73e16165f67120443ea741e661f69c3e230ed43 Mon Sep 17 00:00:00 2001 From: Ferran Borreguero Date: Fri, 1 Mar 2024 16:52:36 +0000 Subject: [PATCH] Rename sendTransaction to sendConfidentialRequest (#44) --- examples/app-ofa-private/main.go | 6 +++--- examples/build-eth-block/main.go | 8 ++++---- examples/mevm-confidential-store/main.go | 3 ++- examples/mevm-context/main.go | 2 +- examples/mevm-is-confidential/main.go | 2 +- examples/offchain-logs/main.go | 4 ++-- examples/onchain-callback/main.go | 2 +- examples/onchain-state/main.go | 2 +- .../private-library-confidential-store/main.go | 4 ++-- examples/private-library/main.go | 2 +- examples/std-transaction-signing/main.go | 2 +- framework/framework.go | 14 +++++++------- 12 files changed, 26 insertions(+), 25 deletions(-) diff --git a/examples/app-ofa-private/main.go b/examples/app-ofa-private/main.go index c7338d8..76aa913 100644 --- a/examples/app-ofa-private/main.go +++ b/examples/app-ofa-private/main.go @@ -90,7 +90,7 @@ func main() { log.Printf("Latest goerli block: %d", target) // new dataRecord inputs - receipt := contract.SendTransaction("newOrder", []interface{}{target + 1}, bundleBytes) + receipt := contract.SendConfidentialRequest("newOrder", []interface{}{target + 1}, bundleBytes) hintEvent := &HintEvent{} if err := hintEvent.Unpack(receipt.Logs[0]); err != nil { @@ -115,7 +115,7 @@ func main() { log.Printf("Latest goerli block: %d", target) // backrun inputs - receipt = contract.SendTransaction("newMatch", []interface{}{hintEvent.DataRecordId, target + 1}, backRunBundleBytes) + receipt = contract.SendConfidentialRequest("newMatch", []interface{}{hintEvent.DataRecordId, target + 1}, backRunBundleBytes) matchEvent := &HintEvent{} if err := matchEvent.Unpack(receipt.Logs[0]); err != nil { @@ -127,7 +127,7 @@ func main() { // Step 4. Emit the batch to the relayer and parse the output fmt.Println("4. Emit batch") - receipt = contract.SendTransaction("emitMatchDataRecordAndHint", []interface{}{cfg.BuilderURL, matchEvent.DataRecordId}, backRunBundleBytes) + receipt = contract.SendConfidentialRequest("emitMatchDataRecordAndHint", []interface{}{cfg.BuilderURL, matchEvent.DataRecordId}, backRunBundleBytes) bundleHash, err := decodeBundleEmittedOutput(receipt) if err != nil { log.Fatal(err) diff --git a/examples/build-eth-block/main.go b/examples/build-eth-block/main.go index c9302f4..49bac6f 100644 --- a/examples/build-eth-block/main.go +++ b/examples/build-eth-block/main.go @@ -48,8 +48,8 @@ func main() { decryptionCondition := targetBlock + 1 allowedPeekers := []common.Address{ buildEthBlockAddress, - bundleContract.Address(), - ethBlockContract.Address()} + bundleContract.Raw().Address(), + ethBlockContract.Raw().Address()} allowedStores := []common.Address{} newBundleArgs := []any{ decryptionCondition, @@ -59,7 +59,7 @@ func main() { confidentialDataBytes, err := bundleContract.Abi.Methods["fetchConfidentialBundleData"].Outputs.Pack(bundleBytes) maybe(err) - _ = bundleContract.SendTransaction("newBundle", newBundleArgs, confidentialDataBytes) + _ = bundleContract.SendConfidentialRequest("newBundle", newBundleArgs, confidentialDataBytes) } { // Signal to the builder that it's time to build a new block @@ -69,7 +69,7 @@ func main() { FeeRecipient: common.Address{0x42}, } - _ = ethBlockContract.SendTransaction("buildFromPool", []any{payloadArgsTuple, targetBlock + 1}, nil) + _ = ethBlockContract.SendConfidentialRequest("buildFromPool", []any{payloadArgsTuple, targetBlock + 1}, nil) maybe(err) } } diff --git a/examples/mevm-confidential-store/main.go b/examples/mevm-confidential-store/main.go index 052d7c7..85cd669 100644 --- a/examples/mevm-confidential-store/main.go +++ b/examples/mevm-confidential-store/main.go @@ -6,5 +6,6 @@ import ( func main() { fr := framework.New() - fr.Suave.DeployContract("confidential-store.sol/ConfidentialStore.json").SendTransaction("example", []interface{}{}, nil) + fr.Suave.DeployContract("confidential-store.sol/ConfidentialStore.json"). + SendConfidentialRequest("example", []interface{}{}, nil) } diff --git a/examples/mevm-context/main.go b/examples/mevm-context/main.go index c8c010a..f50802d 100644 --- a/examples/mevm-context/main.go +++ b/examples/mevm-context/main.go @@ -7,5 +7,5 @@ import ( func main() { fr := framework.New() fr.Suave.DeployContract("context.sol/ContextExample.json"). - SendTransaction("example", nil, []byte{0x1}) + SendConfidentialRequest("example", nil, []byte{0x1}) } diff --git a/examples/mevm-is-confidential/main.go b/examples/mevm-is-confidential/main.go index 640a3f7..9369bd7 100644 --- a/examples/mevm-is-confidential/main.go +++ b/examples/mevm-is-confidential/main.go @@ -7,5 +7,5 @@ import ( func main() { fr := framework.New() fr.Suave.DeployContract("is-confidential.sol/IsConfidential.json"). - SendTransaction("example", nil, nil) + SendConfidentialRequest("example", nil, nil) } diff --git a/examples/offchain-logs/main.go b/examples/offchain-logs/main.go index a2c2d88..45a015b 100644 --- a/examples/offchain-logs/main.go +++ b/examples/offchain-logs/main.go @@ -10,13 +10,13 @@ func main() { fr := framework.New() contract := fr.Suave.DeployContract("offchain-logs.sol/OffchainLogs.json") - receipt := contract.SendTransaction("example", nil, nil) + receipt := contract.SendConfidentialRequest("example", nil, nil) if len(receipt.Logs) != 2 { log.Fatal("two logs expected") } // emit the CCR but DO NOT leak the logs - receipt = contract.SendTransaction("exampleNoLogs", nil, nil) + receipt = contract.SendConfidentialRequest("exampleNoLogs", nil, nil) if len(receipt.Logs) != 1 { log.Fatal("only one log expected") } diff --git a/examples/onchain-callback/main.go b/examples/onchain-callback/main.go index 58bc043..69d8ad3 100644 --- a/examples/onchain-callback/main.go +++ b/examples/onchain-callback/main.go @@ -7,5 +7,5 @@ import ( func main() { fr := framework.New() fr.Suave.DeployContract("onchain-callback.sol/OnChainCallback.json"). - SendTransaction("example", nil, nil) + SendConfidentialRequest("example", nil, nil) } diff --git a/examples/onchain-state/main.go b/examples/onchain-state/main.go index 63f6e56..82363a9 100644 --- a/examples/onchain-state/main.go +++ b/examples/onchain-state/main.go @@ -21,7 +21,7 @@ func main() { fmt.Println("2. Send a confidential request that modifies the state") - contract.SendTransaction("example", nil, nil) + contract.SendConfidentialRequest("example", nil, nil) val, ok := contract.Call("getState")[0].(uint64) if !ok { fmt.Printf("expected uint64") diff --git a/examples/private-library-confidential-store/main.go b/examples/private-library-confidential-store/main.go index 12a6a96..150c645 100644 --- a/examples/private-library-confidential-store/main.go +++ b/examples/private-library-confidential-store/main.go @@ -12,12 +12,12 @@ func main() { suapp := fr.Suave.DeployContract("lib-confidential-store.sol/PublicSuapp.json") // Deploy the contract and get the bid id - receipt := suapp.SendTransaction("registerContract", nil, privateLibrary.Code) + receipt := suapp.SendConfidentialRequest("registerContract", nil, privateLibrary.Code) event, _ := contractRegisteredABI.Inputs.Unpack(receipt.Logs[0].Data) privateContractBidId := event[0].([16]byte) // Use the private contract - suapp.SendTransaction("example", []interface{}{privateContractBidId}, nil) + suapp.SendConfidentialRequest("example", []interface{}{privateContractBidId}, nil) } var contractRegisteredABI abi.Event diff --git a/examples/private-library/main.go b/examples/private-library/main.go index f9331d5..31d09ab 100644 --- a/examples/private-library/main.go +++ b/examples/private-library/main.go @@ -7,5 +7,5 @@ func main() { fr := framework.New() fr.Suave.DeployContract("private-library.sol/PublicSuapp.json"). - SendTransaction("example", nil, privateLibrary.Code) + SendConfidentialRequest("example", nil, privateLibrary.Code) } diff --git a/examples/std-transaction-signing/main.go b/examples/std-transaction-signing/main.go index 31d9351..d99a3e6 100644 --- a/examples/std-transaction-signing/main.go +++ b/examples/std-transaction-signing/main.go @@ -12,7 +12,7 @@ func main() { priv := "b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291" contract := fr.Suave.DeployContract("transaction-signing.sol/TransactionSigning.json") - receipt := contract.SendTransaction("example", nil, []byte(priv)) + receipt := contract.SendConfidentialRequest("example", nil, []byte(priv)) // validate the signature txnSignatureEvent, err := contract.Abi.Events["TxnSignature"].ParseLog(receipt.Logs[0]) diff --git a/framework/framework.go b/framework/framework.go index f8da8d8..a276787 100644 --- a/framework/framework.go +++ b/framework/framework.go @@ -107,7 +107,7 @@ func GeneratePrivKey() *PrivKey { } type Contract struct { - *sdk.Contract + contract *sdk.Contract clt *sdk.Client kettleAddr common.Address @@ -139,14 +139,14 @@ func (c *Contract) Call(methodName string) []interface{} { } func (c *Contract) Raw() *sdk.Contract { - return c.Contract + return c.contract } var executionRevertedPrefix = "execution reverted: 0x" -// SendTransaction sends the transaction and panics if it fails -func (c *Contract) SendTransaction(method string, args []interface{}, confidentialBytes []byte) *types.Receipt { - txnResult, err := c.Contract.SendTransaction(method, args, confidentialBytes) +// SendConfidentialRequest sends the confidential request to the kettle +func (c *Contract) SendConfidentialRequest(method string, args []interface{}, confidentialBytes []byte) *types.Receipt { + txnResult, err := c.contract.SendTransaction(method, args, confidentialBytes) if err != nil { // decode the PeekerReverted error errMsg := err.Error() @@ -276,7 +276,7 @@ func (c *Chain) DeployContract(path string) *Contract { log.Printf("deployed contract at %s", receipt.ContractAddress.Hex()) contract := sdk.GetContract(receipt.ContractAddress, artifact.Abi, c.clt) - return &Contract{addr: receipt.ContractAddress, clt: c.clt, kettleAddr: c.kettleAddr, Abi: artifact.Abi, Contract: contract} + return &Contract{addr: receipt.ContractAddress, clt: c.clt, kettleAddr: c.kettleAddr, Abi: artifact.Abi, contract: contract} } func (c *Contract) Ref(acct *PrivKey) *Contract { @@ -285,7 +285,7 @@ func (c *Contract) Ref(acct *PrivKey) *Contract { cc := &Contract{ addr: c.addr, Abi: c.Abi, - Contract: sdk.GetContract(c.addr, c.Abi, clt), + contract: sdk.GetContract(c.addr, c.Abi, clt), } return cc }