Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update ogmigo v6 #18

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/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
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
51 changes: 34 additions & 17 deletions txBuilding/Backend/OgmiosChainContext/OgmiosChainContext.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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),
}
Expand Down Expand Up @@ -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]{}
Expand All @@ -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}
}
Expand Down Expand Up @@ -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")
}
Expand All @@ -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),
}
Expand Down
Loading