Skip to content

Commit

Permalink
Merge pull request #50 from maestro-org/chore/update-deprecated-endpo…
Browse files Browse the repository at this point in the history
…ints

feat: chang compatibility
  • Loading branch information
Vardominator authored Aug 30, 2024
2 parents 2d6624c + 86fc3b1 commit 194b0f7
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 57 deletions.
12 changes: 6 additions & 6 deletions client/general.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ func (c *Client) ChainTip() (*models.ChainTip, error) {
return &chainTip, nil
}

func (c *Client) EraHistory() (*models.EraHistory, error) {
url := "/era-history"
func (c *Client) EraSummaries() (*models.EraSummaries, error) {
url := "/era-summaries"
resp, err := c.get(url)
if err != nil {
return nil, err
Expand All @@ -42,16 +42,16 @@ func (c *Client) EraHistory() (*models.EraHistory, error) {
return nil, fmt.Errorf("unexpected error: %d", resp.Body)
}
defer resp.Body.Close()
var eraHistory models.EraHistory
err = json.NewDecoder(resp.Body).Decode(&eraHistory)
var eraSummaries models.EraSummaries
err = json.NewDecoder(resp.Body).Decode(&eraSummaries)
if err != nil {
return nil, err
}
return &eraHistory, nil
return &eraSummaries, nil
}

func (c *Client) ProtocolParameters() (*models.ProtocolParameters, error) {
url := "/protocol-params"
url := "/protocol-parameters"
resp, err := c.get(url)
if err != nil {
return nil, err
Expand Down
93 changes: 57 additions & 36 deletions models/general.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,19 @@ package models

import "github.com/maestro-org/go-sdk/utils"

type ChainTipData struct {
BlockHash string `json:"block_hash"`
Height int64 `json:"height"`
Slot int64 `json:"slot"`
type BytesSize struct {
Bytes int64 `json:"bytes"`
}

type ChainTip struct {
Data ChainTipData `json:"data"`
LastUpdated utils.LastUpdated `json:"last_updated"`
}

type EraTimeStamp struct {
Epoch int64 `json:"epoch"`
Slot int64 `json:"slot"`
Time int64 `json:"time"`
}

type EraParams struct {
EpochLength int64 `json:"epoch_length"`
SafeZone int64 `json:"safe_zone"`
SlotLength int64 `json:"slot_length"`
type ChainTipData struct {
BlockHash string `json:"block_hash"`
Height int64 `json:"height"`
Slot int64 `json:"slot"`
}

type Era struct {
Expand All @@ -31,52 +23,81 @@ type Era struct {
Start EraTimeStamp `json:"start"`
}

type EraHistory struct {
type EraParams struct {
EpochLength int64 `json:"epoch_length"`
SafeZone int64 `json:"safe_zone"`
SlotLength EraSlotLength `json:"slot_length"`
}

type EraSummaries struct {
Data []Era `json:"data"`
LastUpdated utils.LastUpdated `json:"last_updated"`
}

type ProtocolParameters struct {
Data ProtocolParams `json:"data"`
LastUpdated utils.LastUpdated `json:"last_updated"`
type EraSlotLength struct {
Milliseconds int64 `json:"milliseconds"`
}

type EraTime struct {
Seconds int64 `json:"seconds"`
}

type EraTimeStamp struct {
Epoch int64 `json:"epoch"`
Slot int64 `json:"slot"`
Time EraTime `json:"time"`
}

type ExUnits struct {
Memory int64 `json:"memory"`
Steps int64 `json:"steps"`
}

type StringExUnits struct {
Memory string `json:"memory"`
Steps string `json:"steps"`
type LovelaceAmount struct {
Lovelace int64 `json:"lovelace"`
}

type ProtocolParameters struct {
Data ProtocolParams `json:"data"`
LastUpdated utils.LastUpdated `json:"last_updated"`
}

type ProtocolVersion struct {
Major int64 `json:"major"`
Minor int64 `json:"minor"`
}

type StringExUnits struct {
Memory string `json:"memory"`
Steps string `json:"steps"`
}

type AdaAmount struct {
LovelaceAmount LovelaceAmount `json:"ada"`
}

type ProtocolParams struct {
CoinsPerUtxoByte int64 `json:"coins_per_utxo_byte"`
CollateralPercentage int64 `json:"collateral_percentage"`
CostModels any `json:"cost_models"`
DesiredNumberOfPools int64 `json:"desired_number_of_pools"`
MaxBlockBodySize int64 `json:"max_block_body_size"`
MaxBlockHeaderSize int64 `json:"max_block_header_size"`
DesiredNumberOfStakePools int64 `json:"desired_number_of_stake_pools"`
MaxBlockBodySize BytesSize `json:"max_block_body_size"`
MaxBlockHeaderSize BytesSize `json:"max_block_header_size"`
MaxCollateralInputs int64 `json:"max_collateral_inputs"`
MaxExecutionUnitsPerBlock ExUnits `json:"max_execution_units_per_block"`
MaxExecutionUnitsPerTransaction ExUnits `json:"max_execution_units_per_transaction"`
MaxTxSize int64 `json:"max_tx_size"`
MaxValueSize int64 `json:"max_value_size"`
MaxTransactionSize BytesSize `json:"max_transaction_size"`
MaxValueSize BytesSize `json:"max_value_size"`
MinFeeCoefficient int64 `json:"min_fee_coefficient"`
MinFeeConstant int64 `json:"min_fee_constant"`
MinPoolCost int64 `json:"min_pool_cost"`
MinFeeConstant AdaAmount `json:"min_fee_constant"`
MinStakePoolCost AdaAmount `json:"min_stake_pool_cost"`
MinUtxoDepositCoefficient int64 `json:"min_utxo_deposit_coefficient"`
MinUtxoDepositConstant AdaAmount `json:"min_utxo_deposit_constant"`
MonetaryExpansion string `json:"monetary_expansion"`
PoolDeposit int64 `json:"pool_deposit"`
PoolInfluence string `json:"pool_influence"`
PoolRetirementEpochBound int64 `json:"pool_retirement_epoch_bound"`
Prices StringExUnits `json:"prices"`
ProtocolVersion ProtocolVersion `json:"protocol_version"`
StakeKeyDeposit int64 `json:"stake_key_deposit"`
PlutusCostModels any `json:"plutus_cost_models"`
ProtocolVersion ProtocolVersion `json:"version"`
ScriptExecutionPrices StringExUnits `json:"script_execution_prices"`
StakeCredentialDeposit AdaAmount `json:"stake_credential_deposit"`
StakePoolDeposit AdaAmount `json:"stake_pool_deposit"`
StakePoolPledgeInfluence string `json:"stake_pool_pledge_influence"`
StakePoolRetirementEpochBound int64 `json:"stake_pool_retirement_epoch_bound"`
TreasuryExpansion string `json:"treasury_expansion"`
}
2 changes: 0 additions & 2 deletions models/pools.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ type PoolMintedBlocks struct {
}

type StakePoolDelegator struct {
ActiveEpochNo int64 `json:"active_epoch_no"`
Amount string `json:"amount"`
LatestDelegationTxHash string `json:"latest_delegation_tx_hash"`
StakeAddress string `json:"stake_address"`
Expand Down Expand Up @@ -69,7 +68,6 @@ type Relay struct {
}

type StakePoolDetails struct {
ActiveEpochNo int64 `json:"active_epoch_no"`
ActiveStake int64 `json:"active_stake"`
BlockCount int64 `json:"block_count"`
FixedCost int64 `json:"fixed_cost"`
Expand Down
1 change: 1 addition & 0 deletions models/scripts.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ type ScriptVersion string
const (
PlutusV1 ScriptVersion = "plutusv1"
PlutusV2 ScriptVersion = "plutusv2"
PlutusV3 ScriptVersion = "plutusv3"
)

type Script struct {
Expand Down
46 changes: 33 additions & 13 deletions models/transactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,61 @@ package models
import "github.com/maestro-org/go-sdk/utils"

type Certificates struct {
MirTransfers []any `json:"mir_transfers"`
PoolRegistrations []any `json:"pool_registrations"`
PoolRetirements []any `json:"pool_retirements"`
StakeDelegations []any `json:"stake_delegations"`
StakeDeregistrations []any `json:"stake_deregistrations"`
StakeRegistrationsReserves []any `json:"stake_registrations_reserves"`
AuthCommitteeHotCerts []any `json:"auth_committee_hot_certs"`
MirTransfers []any `json:"mir_transfers"`
PoolRegistrations []any `json:"pool_registrations"`
PoolRetirements []any `json:"pool_retirements"`
RegCerts []any `json:"reg_certs"`
RegDRepCerts []any `json:"reg_drep_certs"`
ResignCommitteeColdCerts []any `json:"resign_committee_cold_certs"`
StakeDelegations []any `json:"stake_delegations"`
StakeDeregistrations []any `json:"stake_deregistrations"`
StakeRegDelegations []any `json:"stake_reg_delegations"`
StakeRegistrations []any `json:"stake_registrations"`
StakeVoteDelegations []any `json:"stake_vote_delegations"`
StakeVoteRegDelegations []any `json:"stake_vote_reg_delegations"`
UnRegCerts []any `json:"unreg_certs"`
UnRegDRepCerts []any `json:"unreg_drep_certs"`
UpdateDRepCerts []any `json:"update_drep_certs"`
VoteDelegations []any `json:"vote_delegations"`
VoteRegDelegations []any `json:"vote_reg_delegations"`
}

type Redeemers struct {
Certificates []any `json:"certificates"`
Mints []any `json:"mints"`
Spends []any `json:"spends"`
Withdrawals []any `json:"withdrawals"`
Votes []any `json:"votes"`
Proposals []any `json:"proposals"`
}

type MintAsset struct {
Unit string `json:"unit"`
Amount any `json:"amount"`
}

type TransactionDetail struct {
AdditionalSigners []string `json:"additional_signers"`
BlockAbsoluteSlot int64 `json:"block_absolute_slot"`
BlockEpoch int64 `json:"block_epoch"`
BlockHash string `json:"block_hash"`
BlockHeight int64 `json:"block_height"`
BlockTimestamp int64 `json:"block_timestamp"`
BlockTxIndex int64 `json:"block_tx_index"`
BlockTxIndex int32 `json:"block_tx_index"`
Certificates Certificates `json:"certificates"`
CollateralInputs []Utxo `json:"collateral_inputs"`
CollateralReturn any `json:"collateral_return"`
CollateralReturn *Utxo `json:"collateral_return,omitempty"`
Deposit int64 `json:"deposit"`
Fee int64 `json:"fee"`
Inputs []Utxo `json:"inputs"`
InvalidBefore int64 `json:"invalid_before"`
InvalidHereafter int64 `json:"invalid_hereafter"`
Metadata any `json:"metadata"`
Mint []any `json:"mint"`
InvalidBefore *int64 `json:"invalid_before,omitempty"`
InvalidHereafter *int64 `json:"invalid_hereafter,omitempty"`
Metadata interface{} `json:"metadata,omitempty"`
Mint []MintAsset `json:"mint"`
Outputs []Utxo `json:"outputs"`
Redeemers Redeemers `json:"redeemers"`
ReferenceInputs []any `json:"reference_inputs"`
ReferenceInputs []Utxo `json:"reference_inputs"`
ScriptsExecuted []Script `json:"scripts_executed"`
ScriptsSuccessful bool `json:"scripts_successful"`
Size int64 `json:"size"`
Expand Down

0 comments on commit 194b0f7

Please sign in to comment.