diff --git a/go.mod b/go.mod index 9d2b959..32ddd32 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/Salvionied/cbor/v2 v2.6.0 github.com/SundaeSwap-finance/kugo v0.1.5 github.com/SundaeSwap-finance/ogmigo v0.8.0 - github.com/SundaeSwap-finance/ogmigo/v6 v6.0.0-20231101192200-2e052daaeb54 + github.com/SundaeSwap-finance/ogmigo/v6 v6.0.0-20240117201106-ce491d0b031e github.com/tyler-smith/go-bip39 v1.1.0 golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 golang.org/x/text v0.9.0 diff --git a/go.sum b/go.sum index b43d324..cd83ad1 100644 --- a/go.sum +++ b/go.sum @@ -6,8 +6,8 @@ github.com/SundaeSwap-finance/kugo v0.1.5 h1:udigs4BdhFKNQqV2NW5oAma4Qhhenmh+3/j github.com/SundaeSwap-finance/kugo v0.1.5/go.mod h1:P3Hn7eqby5AdRmZkclFLLc3EQIIexEaVvfDZD6lcKQ8= github.com/SundaeSwap-finance/ogmigo v0.8.0 h1:cnta2oCuSwbFe/Wnc93lI+llz77GUrWCUpm+Vfj4HQc= github.com/SundaeSwap-finance/ogmigo v0.8.0/go.mod h1:Zuywifig7DQb5sEBrXsE44tv7fIm3fa9izKihtaez1I= -github.com/SundaeSwap-finance/ogmigo/v6 v6.0.0-20231101192200-2e052daaeb54 h1:td92+pUFNDK4RwJASl0pLjs2hzqWYPPEMTqAHpBMGRQ= -github.com/SundaeSwap-finance/ogmigo/v6 v6.0.0-20231101192200-2e052daaeb54/go.mod h1:CsDGcgbkKoz6S4h0RJ30go7oXG+KhGE2KLhBpRFnEqA= +github.com/SundaeSwap-finance/ogmigo/v6 v6.0.0-20240117201106-ce491d0b031e h1:wYmyTXTnrYNMZqe3qFs9dJiUYy+yhZrNJFbN49tSjbY= +github.com/SundaeSwap-finance/ogmigo/v6 v6.0.0-20240117201106-ce491d0b031e/go.mod h1:CsDGcgbkKoz6S4h0RJ30go7oXG+KhGE2KLhBpRFnEqA= github.com/aws/aws-sdk-go v1.44.197 h1:pkg/NZsov9v/CawQWy+qWVzJMIZRQypCtYjUBXFomF8= github.com/aws/aws-sdk-go v1.44.197/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUs= diff --git a/txBuilding/Backend/OgmiosChainContext/OgmiosChainContext.go b/txBuilding/Backend/OgmiosChainContext/OgmiosChainContext.go index 8f8c189..6f2e2fb 100644 --- a/txBuilding/Backend/OgmiosChainContext/OgmiosChainContext.go +++ b/txBuilding/Backend/OgmiosChainContext/OgmiosChainContext.go @@ -140,7 +140,7 @@ func scriptRef_OgmigoToApollo(script json.RawMessage) (*PlutusData.ScriptRef, er return &ref, nil } -func Utxo_OgmigoToApollo(u statequery.Utxo) UTxO.UTxO { +func Utxo_OgmigoToApollo(u statequery.TxOut) UTxO.UTxO { txHashRaw, err := hex.DecodeString(u.Transaction.ID) if err != nil { log.Fatal(err, "Failed to decode ogmigo transaction ID") @@ -176,7 +176,7 @@ func Utxo_OgmigoToApollo(u statequery.Utxo) UTxO.UTxO { func (occ *OgmiosChainContext) GetUtxoFromRef(txHash string, index int) *UTxO.UTxO { ctx := context.Background() utxos, err := occ.ogmigo.UtxosByTxIn(ctx, chainsync.TxInQuery{ - Transaction: chainsync.UtxoTxID{ + Transaction: shared.UtxoTxID{ ID: txHash, }, Index: uint32(index), @@ -238,7 +238,7 @@ func (occ *OgmiosChainContext) TxOuts(txHash string) []Base.Output { queries := make([]chainsync.TxInQuery, chunk_size) for ix, _ := range queries { queries[ix] = chainsync.TxInQuery{ - Transaction: chainsync.UtxoTxID{ + Transaction: shared.UtxoTxID{ ID: txHash, }, Index: uint32(ix), @@ -457,14 +457,23 @@ func (occ *OgmiosChainContext) LatestEpochParams() Base.ProtocolParameters { MinPoolCost: strconv.FormatUint(ogmiosParams.MinStakePoolCost.Lovelace, 10), PriceMem: float32(ogmiosParams.ScriptExecutionPrices.Memory), PriceStep: float32(ogmiosParams.ScriptExecutionPrices.Cpu), - MaxTxExMem: strconv.FormatUint(ogmiosParams.MaxExecutionUnitsPerTransaction.Memory, 10), - MaxTxExSteps: strconv.FormatUint(ogmiosParams.MaxExecutionUnitsPerTransaction.Cpu, 10), - MaxBlockExMem: strconv.FormatUint(ogmiosParams.MaxExecutionUnitsPerBlock.Memory, 10), - MaxBlockExSteps: strconv.FormatUint(ogmiosParams.MaxExecutionUnitsPerBlock.Cpu, 10), - MaxValSize: strconv.FormatUint(ogmiosParams.MaxValSize.Bytes, 10), - CollateralPercent: int(ogmiosParams.CollateralPercentage), - MaxCollateralInuts: int(ogmiosParams.MaxCollateralInputs), - CoinsPerUtxoByte: strconv.FormatUint(ogmiosParams.MinUtxoDepositCoefficient, 10), + MaxTxExMem: strconv.FormatUint( + ogmiosParams.MaxExecutionUnitsPerTransaction.Memory, + 10, + ), + MaxTxExSteps: strconv.FormatUint( + ogmiosParams.MaxExecutionUnitsPerTransaction.Cpu, + 10, + ), + MaxBlockExMem: strconv.FormatUint( + ogmiosParams.MaxExecutionUnitsPerBlock.Memory, + 10, + ), + MaxBlockExSteps: strconv.FormatUint(ogmiosParams.MaxExecutionUnitsPerBlock.Cpu, 10), + MaxValSize: strconv.FormatUint(ogmiosParams.MaxValSize.Bytes, 10), + CollateralPercent: int(ogmiosParams.CollateralPercentage), + MaxCollateralInuts: int(ogmiosParams.MaxCollateralInputs), + CoinsPerUtxoByte: strconv.FormatUint(ogmiosParams.MinUtxoDepositCoefficient, 10), // PerUtxoWord is deprecated https://cips.cardano.org/cips/cip55/ CoinsPerUtxoWord: strconv.FormatUint(ogmiosParams.MinUtxoDepositCoefficient, 10), } @@ -532,7 +541,10 @@ func (occ *OgmiosChainContext) Utxos(address Address.Address) []UTxO.UTxO { utxos := make([]UTxO.UTxO, 0) for _, result := range results { decodedTxId, _ := hex.DecodeString(result.TxHash) - tx_in := TransactionInput.TransactionInput{TransactionId: decodedTxId, Index: result.OutputIndex} + tx_in := TransactionInput.TransactionInput{ + TransactionId: decodedTxId, + Index: result.OutputIndex, + } amount := result.Amount lovelace_amount := 0 multi_assets := MultiAsset.MultiAsset[int64]{} @@ -559,7 +571,10 @@ func (occ *OgmiosChainContext) Utxos(address Address.Address) []UTxO.UTxO { } final_amount := Value.Value{} if len(multi_assets) > 0 { - final_amount = Value.Value{Am: Amount.Amount{Coin: int64(lovelace_amount), Value: multi_assets}, HasAssets: true} + final_amount = Value.Value{ + Am: Amount.Amount{Coin: int64(lovelace_amount), Value: multi_assets}, + HasAssets: true, + } } else { final_amount = Value.Value{Coin: int64(lovelace_amount), HasAssets: false} } @@ -599,10 +614,12 @@ func (occ *OgmiosChainContext) Utxos(address Address.Address) []UTxO.UTxO { return utxos } -func (occ *OgmiosChainContext) SubmitTx(tx Transaction.Transaction) (serialization.TransactionId, error) { +func (occ *OgmiosChainContext) SubmitTx( + tx Transaction.Transaction, +) (serialization.TransactionId, error) { ctx := context.Background() bytes, err := tx.Bytes() - err = occ.ogmigo.SubmitTx(ctx, hex.EncodeToString(bytes)) + _, err = occ.ogmigo.SubmitTx(ctx, hex.EncodeToString(bytes)) if err != nil { log.Fatal(err, "OgmiosChainContext: SubmitTx: Error submitting tx") } @@ -618,8 +635,8 @@ func (occ *OgmiosChainContext) EvaluateTx(tx []byte) map[string]Redeemer.Executi if err != nil { log.Fatal(err, "OgmiosChainContext: EvaluateTx: Error evaluating tx") } - for _, e := range eval { - final_result[e.Validator] = Redeemer.ExecutionUnits{ + for _, e := range eval.ExUnits { + final_result[e.Validator.Purpose] = Redeemer.ExecutionUnits{ Mem: int64(e.Budget.Memory), Steps: int64(e.Budget.Cpu), }