diff --git a/components/dashboard/explorer_routes.go b/components/dashboard/explorer_routes.go index f5a73d25d..812c6c9f9 100644 --- a/components/dashboard/explorer_routes.go +++ b/components/dashboard/explorer_routes.go @@ -11,11 +11,10 @@ import ( "github.com/iotaledger/inx-app/pkg/httpserver" "github.com/iotaledger/iota-core/pkg/model" "github.com/iotaledger/iota-core/pkg/protocol/engine/blocks" - restapipkg "github.com/iotaledger/iota-core/pkg/restapi" "github.com/iotaledger/iota-core/pkg/retainer" iotago "github.com/iotaledger/iota.go/v4" + "github.com/iotaledger/iota.go/v4/api" "github.com/iotaledger/iota.go/v4/hexutil" - "github.com/iotaledger/iota.go/v4/nodeclient/apimodels" ) // SearchResult defines the struct of the SearchResult. @@ -27,8 +26,8 @@ type SearchResult struct { } func setupExplorerRoutes(routeGroup *echo.Group) { - routeGroup.GET("/block/:"+restapipkg.ParameterBlockID, func(c echo.Context) (err error) { - blockID, err := httpserver.ParseBlockIDParam(c, restapipkg.ParameterBlockID) + routeGroup.GET("/block/:"+api.ParameterBlockID, func(c echo.Context) (err error) { + blockID, err := httpserver.ParseBlockIDParam(c, api.ParameterBlockID) if err != nil { return ierrors.Errorf("parse block ID error: %w", err) } @@ -41,17 +40,17 @@ func setupExplorerRoutes(routeGroup *echo.Group) { return c.JSON(http.StatusOK, t) }) - routeGroup.GET("/transaction/:"+restapipkg.ParameterTransactionID, getTransaction) + routeGroup.GET("/transaction/:"+api.ParameterTransactionID, getTransaction) routeGroup.GET("/transaction/:transactionID/metadata", getTransactionMetadata) // routeGroup.GET("/transaction/:transactionID/attachments", ledgerstateAPI.GetTransactionAttachments) - routeGroup.GET("/output/:"+restapipkg.ParameterOutputID, getOutput) + routeGroup.GET("/output/:"+api.ParameterOutputID, getOutput) // routeGroup.GET("/output/:outputID/metadata", ledgerstateAPI.GetOutputMetadata) // routeGroup.GET("/output/:outputID/consumers", ledgerstateAPI.GetOutputConsumers) // routeGroup.GET("/conflict/:conflictID", ledgerstateAPI.GetConflict) // routeGroup.GET("/conflict/:conflictID/children", ledgerstateAPI.GetConflictChildren) // routeGroup.GET("/conflict/:conflictID/conflicts", ledgerstateAPI.GetConflictConflicts) // routeGroup.GET("/conflict/:conflictID/voters", ledgerstateAPI.GetConflictVoters) - routeGroup.GET("/slot/commitment/:"+restapipkg.ParameterCommitmentID, getSlotDetailsByID) + routeGroup.GET("/slot/commitment/:"+api.ParameterCommitmentID, getSlotDetailsByID) routeGroup.GET("/search/:search", func(c echo.Context) error { search := c.Param("search") @@ -177,13 +176,13 @@ func createExplorerBlock(block *model.Block, cachedBlock *blocks.Block, metadata }) } else { switch metadata.BlockState { - case apimodels.BlockStateConfirmed, apimodels.BlockStateFinalized: + case api.BlockStateConfirmed, api.BlockStateFinalized: t.Solid = true t.Booked = true t.Acceptance = true t.Scheduled = true t.Confirmation = true - case apimodels.BlockStateFailed, apimodels.BlockStateRejected: + case api.BlockStateFailed, api.BlockStateRejected: t.ObjectivelyInvalid = true } } @@ -192,7 +191,7 @@ func createExplorerBlock(block *model.Block, cachedBlock *blocks.Block, metadata } func getTransaction(c echo.Context) error { - txID, err := httpserver.ParseTransactionIDParam(c, restapipkg.ParameterTransactionID) + txID, err := httpserver.ParseTransactionIDParam(c, api.ParameterTransactionID) if err != nil { return err } @@ -220,7 +219,7 @@ func getTransaction(c echo.Context) error { } func getTransactionMetadata(c echo.Context) error { - txID, err := httpserver.ParseTransactionIDParam(c, restapipkg.ParameterTransactionID) + txID, err := httpserver.ParseTransactionIDParam(c, api.ParameterTransactionID) if err != nil { return err } @@ -239,7 +238,7 @@ func getTransactionMetadata(c echo.Context) error { } func getOutput(c echo.Context) error { - outputID, err := httpserver.ParseOutputIDParam(c, restapipkg.ParameterOutputID) + outputID, err := httpserver.ParseOutputIDParam(c, api.ParameterOutputID) if err != nil { return err } @@ -253,7 +252,7 @@ func getOutput(c echo.Context) error { } func getSlotDetailsByID(c echo.Context) error { - commitmentID, err := httpserver.ParseCommitmentIDParam(c, restapipkg.ParameterCommitmentID) + commitmentID, err := httpserver.ParseCommitmentIDParam(c, api.ParameterCommitmentID) if err != nil { return err } diff --git a/components/debugapi/component.go b/components/debugapi/component.go index 045a5e2dd..5d4457ff5 100644 --- a/components/debugapi/component.go +++ b/components/debugapi/component.go @@ -22,18 +22,19 @@ import ( "github.com/iotaledger/iota-core/pkg/storage/database" "github.com/iotaledger/iota-core/pkg/storage/prunable" iotago "github.com/iotaledger/iota.go/v4" + "github.com/iotaledger/iota.go/v4/api" ) const ( RouteValidators = "/validators" - RouteBlockMetadata = "/blocks/:" + restapipkg.ParameterBlockID + "/metadata" + RouteBlockMetadata = "/blocks/:" + api.ParameterBlockID + "/metadata" RouteChainManagerAllChainsDot = "/all-chains" RouteChainManagerAllChainsRendered = "/all-chains/rendered" - RouteCommitmentByIndexBlockIDs = "/commitments/by-index/:" + restapipkg.ParameterSlotIndex + "/blocks" + RouteCommitmentBySlotBlockIDs = "/commitments/by-slot/:" + api.ParameterSlot + "/blocks" - RouteCommitmentByIndexTransactionIDs = "/commitments/by-index/:" + restapipkg.ParameterSlotIndex + "/transactions" + RouteCommitmentBySlotTransactionIDs = "/commitments/by-slot/:" + api.ParameterSlot + "/transactions" ) const ( @@ -148,7 +149,7 @@ func configure() error { }) routeGroup.GET(RouteBlockMetadata, func(c echo.Context) error { - blockID, err := httpserver.ParseBlockIDParam(c, restapipkg.ParameterBlockID) + blockID, err := httpserver.ParseBlockIDParam(c, api.ParameterBlockID) if err != nil { return err } @@ -206,8 +207,8 @@ func configure() error { return c.Blob(http.StatusOK, "image/png", renderedBytes) }) - routeGroup.GET(RouteCommitmentByIndexBlockIDs, func(c echo.Context) error { - slot, err := httpserver.ParseSlotParam(c, restapipkg.ParameterSlotIndex) + routeGroup.GET(RouteCommitmentBySlotBlockIDs, func(c echo.Context) error { + slot, err := httpserver.ParseSlotParam(c, api.ParameterSlot) if err != nil { return err } @@ -220,8 +221,8 @@ func configure() error { return httpserver.JSONResponse(c, http.StatusOK, resp) }) - routeGroup.GET(RouteCommitmentByIndexTransactionIDs, func(c echo.Context) error { - slot, err := httpserver.ParseSlotParam(c, restapipkg.ParameterSlotIndex) + routeGroup.GET(RouteCommitmentBySlotTransactionIDs, func(c echo.Context) error { + slot, err := httpserver.ParseSlotParam(c, api.ParameterSlot) if err != nil { return err } diff --git a/components/restapi/core/accounts.go b/components/restapi/core/accounts.go index 0efcdbb59..ee721bd45 100644 --- a/components/restapi/core/accounts.go +++ b/components/restapi/core/accounts.go @@ -13,11 +13,11 @@ import ( "github.com/iotaledger/iota-core/pkg/core/account" restapipkg "github.com/iotaledger/iota-core/pkg/restapi" iotago "github.com/iotaledger/iota.go/v4" - "github.com/iotaledger/iota.go/v4/nodeclient/apimodels" + "github.com/iotaledger/iota.go/v4/api" ) -func congestionByAccountAddress(c echo.Context) (*apimodels.CongestionResponse, error) { - commitmentID, err := httpserver.ParseCommitmentIDQueryParam(c, restapipkg.ParameterCommitmentID) +func congestionByAccountAddress(c echo.Context) (*api.CongestionResponse, error) { + commitmentID, err := httpserver.ParseCommitmentIDQueryParam(c, api.ParameterCommitmentID) if err != nil { return nil, err } @@ -32,14 +32,14 @@ func congestionByAccountAddress(c echo.Context) (*apimodels.CongestionResponse, } hrp := deps.Protocol.CommittedAPI().ProtocolParameters().Bech32HRP() - address, err := httpserver.ParseBech32AddressParam(c, hrp, restapipkg.ParameterBech32Address) + address, err := httpserver.ParseBech32AddressParam(c, hrp, api.ParameterBech32Address) if err != nil { return nil, err } accountAddress, ok := address.(*iotago.AccountAddress) if !ok { - return nil, ierrors.Wrapf(httpserver.ErrInvalidParameter, "address %s is not an account address", c.Param(restapipkg.ParameterBech32Address)) + return nil, ierrors.Wrapf(httpserver.ErrInvalidParameter, "address %s is not an account address", c.Param(api.ParameterBech32Address)) } accountID := accountAddress.AccountID() @@ -51,7 +51,7 @@ func congestionByAccountAddress(c echo.Context) (*apimodels.CongestionResponse, return nil, ierrors.Wrapf(echo.ErrNotFound, "account not found: %s", accountID.ToHex()) } - return &apimodels.CongestionResponse{ + return &api.CongestionResponse{ Slot: commitment.Slot(), Ready: deps.Protocol.MainEngineInstance().Scheduler.IsBlockIssuerReady(accountID), ReferenceManaCost: commitment.ReferenceManaCost(), @@ -59,7 +59,7 @@ func congestionByAccountAddress(c echo.Context) (*apimodels.CongestionResponse, }, nil } -func validators(c echo.Context) (*apimodels.ValidatorsResponse, error) { +func validators(c echo.Context) (*api.ValidatorsResponse, error) { var err error pageSize := restapi.ParamsRestAPI.MaxPageSize if len(c.QueryParam(restapipkg.QueryParameterPageSize)) > 0 { @@ -100,7 +100,7 @@ func validators(c echo.Context) (*apimodels.ValidatorsResponse, error) { } page := registeredValidators[cursorIndex:lo.Min(cursorIndex+pageSize, uint32(len(registeredValidators)))] - resp := &apimodels.ValidatorsResponse{ + resp := &api.ValidatorsResponse{ Validators: page, PageSize: pageSize, } @@ -114,16 +114,16 @@ func validators(c echo.Context) (*apimodels.ValidatorsResponse, error) { return resp, nil } -func validatorByAccountAddress(c echo.Context) (*apimodels.ValidatorResponse, error) { +func validatorByAccountAddress(c echo.Context) (*api.ValidatorResponse, error) { hrp := deps.Protocol.CommittedAPI().ProtocolParameters().Bech32HRP() - address, err := httpserver.ParseBech32AddressParam(c, hrp, restapipkg.ParameterBech32Address) + address, err := httpserver.ParseBech32AddressParam(c, hrp, api.ParameterBech32Address) if err != nil { return nil, err } accountAddress, ok := address.(*iotago.AccountAddress) if !ok { - return nil, ierrors.Wrapf(httpserver.ErrInvalidParameter, "address %s is not an account address", c.Param(restapipkg.ParameterBech32Address)) + return nil, ierrors.Wrapf(httpserver.ErrInvalidParameter, "address %s is not an account address", c.Param(api.ParameterBech32Address)) } latestCommittedSlot := deps.Protocol.MainEngineInstance().SyncManager.LatestCommitment().Slot() @@ -144,7 +144,7 @@ func validatorByAccountAddress(c echo.Context) (*apimodels.ValidatorResponse, er return nil, ierrors.Wrapf(err, "failed to check if account %s is an active candidate", accountID.ToHex()) } - return &apimodels.ValidatorResponse{ + return &api.ValidatorResponse{ AddressBech32: accountID.ToAddress().Bech32(deps.Protocol.CommittedAPI().ProtocolParameters().Bech32HRP()), PoolStake: accountData.ValidatorStake + accountData.DelegationStake, ValidatorStake: accountData.ValidatorStake, @@ -156,18 +156,18 @@ func validatorByAccountAddress(c echo.Context) (*apimodels.ValidatorResponse, er }, nil } -func rewardsByOutputID(c echo.Context) (*apimodels.ManaRewardsResponse, error) { - outputID, err := httpserver.ParseOutputIDParam(c, restapipkg.ParameterOutputID) +func rewardsByOutputID(c echo.Context) (*api.ManaRewardsResponse, error) { + outputID, err := httpserver.ParseOutputIDParam(c, api.ParameterOutputID) if err != nil { - return nil, ierrors.Wrapf(err, "failed to parse output ID %s", c.Param(restapipkg.ParameterOutputID)) + return nil, ierrors.Wrapf(err, "failed to parse output ID %s", c.Param(api.ParameterOutputID)) } var slotIndex iotago.SlotIndex - if len(c.QueryParam(restapipkg.ParameterSlotIndex)) > 0 { + if len(c.QueryParam(api.ParameterSlot)) > 0 { var err error - slotIndex, err = httpserver.ParseSlotQueryParam(c, restapipkg.ParameterSlotIndex) + slotIndex, err = httpserver.ParseSlotQueryParam(c, api.ParameterSlot) if err != nil { - return nil, ierrors.Wrapf(err, "failed to parse slot index %s", c.Param(restapipkg.ParameterSlotIndex)) + return nil, ierrors.Wrapf(err, "failed to parse slot index %s", c.Param(api.ParameterSlot)) } genesisSlot := deps.Protocol.LatestAPI().ProtocolParameters().GenesisSlot() if slotIndex < genesisSlot { @@ -231,19 +231,19 @@ func rewardsByOutputID(c echo.Context) (*apimodels.ManaRewardsResponse, error) { return nil, ierrors.Wrapf(echo.ErrInternalServerError, "failed to calculate reward for output %s: %s", outputID.ToHex(), err) } - return &apimodels.ManaRewardsResponse{ + return &api.ManaRewardsResponse{ EpochStart: actualStart, EpochEnd: actualEnd, Rewards: reward, }, nil } -func selectedCommittee(c echo.Context) (*apimodels.CommitteeResponse, error) { +func selectedCommittee(c echo.Context) (*api.CommitteeResponse, error) { timeProvider := deps.Protocol.CommittedAPI().TimeProvider() var slot iotago.SlotIndex - epoch, err := httpserver.ParseEpochQueryParam(c, restapipkg.ParameterEpochIndex) + epoch, err := httpserver.ParseEpochQueryParam(c, api.ParameterEpoch) if err != nil { // by default we return current epoch slot = timeProvider.SlotFromTime(time.Now()) @@ -254,7 +254,7 @@ func selectedCommittee(c echo.Context) (*apimodels.CommitteeResponse, error) { seatedAccounts, exists := deps.Protocol.MainEngineInstance().SybilProtection.SeatManager().CommitteeInSlot(slot) if !exists { - return &apimodels.CommitteeResponse{ + return &api.CommitteeResponse{ Epoch: epoch, }, nil } @@ -264,9 +264,9 @@ func selectedCommittee(c echo.Context) (*apimodels.CommitteeResponse, error) { return nil, ierrors.Wrapf(err, "failed to get accounts from committee for slot %d", slot) } - committee := make([]*apimodels.CommitteeMemberResponse, 0, accounts.Size()) + committee := make([]*api.CommitteeMemberResponse, 0, accounts.Size()) accounts.ForEach(func(accountID iotago.AccountID, seat *account.Pool) bool { - committee = append(committee, &apimodels.CommitteeMemberResponse{ + committee = append(committee, &api.CommitteeMemberResponse{ AddressBech32: accountID.ToAddress().Bech32(deps.Protocol.CommittedAPI().ProtocolParameters().Bech32HRP()), PoolStake: seat.PoolStake, ValidatorStake: seat.ValidatorStake, @@ -276,7 +276,7 @@ func selectedCommittee(c echo.Context) (*apimodels.CommitteeResponse, error) { return true }) - return &apimodels.CommitteeResponse{ + return &api.CommitteeResponse{ Epoch: epoch, Committee: committee, TotalStake: accounts.TotalStake(), diff --git a/components/restapi/core/blocks.go b/components/restapi/core/blocks.go index b3baabf90..f9a3787ed 100644 --- a/components/restapi/core/blocks.go +++ b/components/restapi/core/blocks.go @@ -6,15 +6,14 @@ import ( "github.com/iotaledger/hive.go/ierrors" "github.com/iotaledger/inx-app/pkg/httpserver" "github.com/iotaledger/iota-core/pkg/blockhandler" - "github.com/iotaledger/iota-core/pkg/restapi" iotago "github.com/iotaledger/iota.go/v4" - "github.com/iotaledger/iota.go/v4/nodeclient/apimodels" + "github.com/iotaledger/iota.go/v4/api" ) func blockByID(c echo.Context) (*iotago.Block, error) { - blockID, err := httpserver.ParseBlockIDParam(c, restapi.ParameterBlockID) + blockID, err := httpserver.ParseBlockIDParam(c, api.ParameterBlockID) if err != nil { - return nil, ierrors.Wrapf(err, "failed to parse block ID %s", c.Param(restapi.ParameterBlockID)) + return nil, ierrors.Wrapf(err, "failed to parse block ID %s", c.Param(api.ParameterBlockID)) } block, exists := deps.Protocol.MainEngineInstance().Block(blockID) @@ -25,7 +24,7 @@ func blockByID(c echo.Context) (*iotago.Block, error) { return block.ProtocolBlock(), nil } -func blockMetadataByBlockID(blockID iotago.BlockID) (*apimodels.BlockMetadataResponse, error) { +func blockMetadataByBlockID(blockID iotago.BlockID) (*api.BlockMetadataResponse, error) { blockMetadata, err := deps.Protocol.MainEngineInstance().Retainer.BlockMetadata(blockID) if err != nil { return nil, ierrors.Wrapf(echo.ErrInternalServerError, "failed to get block metadata %s: %s", blockID.ToHex(), err) @@ -34,19 +33,19 @@ func blockMetadataByBlockID(blockID iotago.BlockID) (*apimodels.BlockMetadataRes return blockMetadata.BlockMetadataResponse(), nil } -func blockMetadataByID(c echo.Context) (*apimodels.BlockMetadataResponse, error) { - blockID, err := httpserver.ParseBlockIDParam(c, restapi.ParameterBlockID) +func blockMetadataByID(c echo.Context) (*api.BlockMetadataResponse, error) { + blockID, err := httpserver.ParseBlockIDParam(c, api.ParameterBlockID) if err != nil { - return nil, ierrors.Wrapf(err, "failed to parse block ID %s", c.Param(restapi.ParameterBlockID)) + return nil, ierrors.Wrapf(err, "failed to parse block ID %s", c.Param(api.ParameterBlockID)) } return blockMetadataByBlockID(blockID) } -func blockWithMetadataByID(c echo.Context) (*apimodels.BlockWithMetadataResponse, error) { - blockID, err := httpserver.ParseBlockIDParam(c, restapi.ParameterBlockID) +func blockWithMetadataByID(c echo.Context) (*api.BlockWithMetadataResponse, error) { + blockID, err := httpserver.ParseBlockIDParam(c, api.ParameterBlockID) if err != nil { - return nil, ierrors.Wrapf(err, "failed to parse block ID %s", c.Param(restapi.ParameterBlockID)) + return nil, ierrors.Wrapf(err, "failed to parse block ID %s", c.Param(api.ParameterBlockID)) } block, exists := deps.Protocol.MainEngineInstance().Block(blockID) @@ -59,19 +58,19 @@ func blockWithMetadataByID(c echo.Context) (*apimodels.BlockWithMetadataResponse return nil, err } - return &apimodels.BlockWithMetadataResponse{ + return &api.BlockWithMetadataResponse{ Block: block.ProtocolBlock(), Metadata: blockMetadata, }, nil } -func blockIssuance() (*apimodels.IssuanceBlockHeaderResponse, error) { +func blockIssuance() (*api.IssuanceBlockHeaderResponse, error) { references := deps.Protocol.MainEngineInstance().TipSelection.SelectTips(iotago.BasicBlockMaxParents) if len(references[iotago.StrongParentType]) == 0 { return nil, ierrors.Wrap(echo.ErrServiceUnavailable, "no strong parents available") } - resp := &apimodels.IssuanceBlockHeaderResponse{ + resp := &api.IssuanceBlockHeaderResponse{ StrongParents: references[iotago.StrongParentType], WeakParents: references[iotago.WeakParentType], ShallowLikeParents: references[iotago.ShallowLikeParentType], @@ -82,10 +81,10 @@ func blockIssuance() (*apimodels.IssuanceBlockHeaderResponse, error) { return resp, nil } -func sendBlock(c echo.Context) (*apimodels.BlockCreatedResponse, error) { +func sendBlock(c echo.Context) (*api.BlockCreatedResponse, error) { iotaBlock, err := httpserver.ParseRequestByHeader(c, deps.Protocol.CommittedAPI(), iotago.BlockFromBytes(deps.Protocol)) if err != nil { - return nil, ierrors.Wrapf(err, "failed to parse iotablock") + return nil, err } blockID, err := deps.BlockHandler.AttachBlock(c.Request().Context(), iotaBlock) @@ -102,7 +101,7 @@ func sendBlock(c echo.Context) (*apimodels.BlockCreatedResponse, error) { } } - return &apimodels.BlockCreatedResponse{ + return &api.BlockCreatedResponse{ BlockID: blockID, }, nil } diff --git a/components/restapi/core/commitment.go b/components/restapi/core/commitment.go index 2990f9b30..38f68cb84 100644 --- a/components/restapi/core/commitment.go +++ b/components/restapi/core/commitment.go @@ -6,7 +6,7 @@ import ( "github.com/iotaledger/hive.go/ierrors" "github.com/iotaledger/iota-core/pkg/model" iotago "github.com/iotaledger/iota.go/v4" - "github.com/iotaledger/iota.go/v4/nodeclient/apimodels" + "github.com/iotaledger/iota.go/v4/api" ) func getCommitmentBySlot(slot iotago.SlotIndex, latestCommitment ...*model.Commitment) (*model.Commitment, error) { @@ -53,7 +53,7 @@ func getCommitmentByID(commitmentID iotago.CommitmentID, latestCommitment ...*mo return commitment, nil } -func getUTXOChanges(commitmentID iotago.CommitmentID) (*apimodels.UTXOChangesResponse, error) { +func getUTXOChanges(commitmentID iotago.CommitmentID) (*api.UTXOChangesResponse, error) { diffs, err := deps.Protocol.MainEngineInstance().Ledger.SlotDiffs(commitmentID.Slot()) if err != nil { return nil, ierrors.Wrapf(echo.ErrInternalServerError, "failed to get slot diffs, commitmentID: %s, slot: %d, error: %w", commitmentID, commitmentID.Slot(), err) @@ -70,7 +70,7 @@ func getUTXOChanges(commitmentID iotago.CommitmentID) (*apimodels.UTXOChangesRes consumedOutputs[i] = output.OutputID() } - return &apimodels.UTXOChangesResponse{ + return &api.UTXOChangesResponse{ CommitmentID: commitmentID, CreatedOutputs: createdOutputs, ConsumedOutputs: consumedOutputs, diff --git a/components/restapi/core/component.go b/components/restapi/core/component.go index a36c8bd30..7fcfc5d8c 100644 --- a/components/restapi/core/component.go +++ b/components/restapi/core/component.go @@ -16,131 +16,7 @@ import ( "github.com/iotaledger/iota-core/pkg/blockhandler" protocolpkg "github.com/iotaledger/iota-core/pkg/protocol" restapipkg "github.com/iotaledger/iota-core/pkg/restapi" -) - -//nolint:goconst // don't care about the number of constants -const ( - // RouteInfo is the route for getting the node info. - // GET returns the node info. - // MIMEApplicationJSON => json. - // MIMEApplicationVendorIOTASerializerV2 => bytes. - RouteInfo = "/info" - - // RouteBlockIssuance is the route for getting all needed information for block creation. - // GET returns the data needed toa attach block. - // MIMEApplicationJSON => json. - // MIMEApplicationVendorIOTASerializerV2 => bytes. - RouteBlockIssuance = "/blocks/issuance" - - // RouteBlock is the route for getting a block by its blockID. - // GET returns the block based on the given type in the request "Accept" header. - // MIMEApplicationJSON => json. - // MIMEApplicationVendorIOTASerializerV2 => bytes. - RouteBlock = "/blocks/:" + restapipkg.ParameterBlockID - - // RouteBlockMetadata is the route for getting block metadata by its blockID. - // GET returns block metadata. - // MIMEApplicationJSON => json. - // MIMEApplicationVendorIOTASerializerV2 => bytes. - RouteBlockMetadata = "/blocks/:" + restapipkg.ParameterBlockID + "/metadata" - - // RouteBlockWithMetadata is the route for getting a block, together with its metadata by its blockID. - // GET returns the block and metadata. - // MIMEApplicationJSON => json. - // MIMEApplicationVendorIOTASerializerV2 => bytes. - RouteBlockWithMetadata = "/blocks/:" + restapipkg.ParameterBlockID + "/full" - - // RouteBlocks is the route for sending new blocks. - // POST creates a single new block and returns the new block ID. - // The block is parsed based on the given type in the request "Content-Type" header. - // MIMEApplicationJSON => json. - // MIMEApplicationVendorIOTASerializerV2 => bytes. - RouteBlocks = "/blocks" - - // RouteOutput is the route for getting an output by its outputID (transactionHash + outputIndex). This includes the proof, that the output corresponds to the requested outputID. - // GET returns the output based on the given type in the request "Accept" header. - // MIMEApplicationJSON => json. - // MIMEApplicationVendorIOTASerializerV2 => bytes. - RouteOutput = "/outputs/:" + restapipkg.ParameterOutputID - - // RouteOutputMetadata is the route for getting output metadata by its outputID (transactionHash + outputIndex) without getting the output itself again. - // GET returns the output metadata. - // MIMEApplicationJSON => json. - // MIMEApplicationVendorIOTASerializerV2 => bytes. - RouteOutputMetadata = "/outputs/:" + restapipkg.ParameterOutputID + "/metadata" - - // RouteOutputWithMetadata is the route for getting output, together with its metadata by its outputID (transactionHash + outputIndex). - // GET returns the output metadata. - // MIMEApplicationJSON => json. - // MIMEApplicationVendorIOTASerializerV2 => bytes. - RouteOutputWithMetadata = "/outputs/:" + restapipkg.ParameterOutputID + "/full" - - // RouteTransactionsIncludedBlock is the route for getting the block that was first confirmed for a given transaction ID. - // GET returns the block based on the given type in the request "Accept" header. - // MIMEApplicationJSON => json. - // MIMEApplicationVendorIOTASerializerV2 => bytes. - RouteTransactionsIncludedBlock = "/transactions/:" + restapipkg.ParameterTransactionID + "/included-block" - - // RouteTransactionsIncludedBlockMetadata is the route for getting the block metadata that was first confirmed in the ledger for a given transaction ID. - // GET returns block metadata (including info about "promotion/reattachment needed"). - // MIMEApplicationJSON => json. - // MIMEApplicationVendorIOTASerializerV2 => bytes. - RouteTransactionsIncludedBlockMetadata = "/transactions/:" + restapipkg.ParameterTransactionID + "/included-block/metadata" - - // RouteCommitmentByID is the route for getting a slot commitment by its ID. - // GET returns the commitment. - // MIMEApplicationJSON => json. - // MIMEApplicationVendorIOTASerializerV2 => bytes. - RouteCommitmentByID = "/commitments/:" + restapipkg.ParameterCommitmentID - - // RouteCommitmentByIDUTXOChanges is the route for getting all UTXO changes of a commitment by its ID. - // GET returns the output IDs of all UTXO changes. - // MIMEApplicationJSON => json. - // MIMEApplicationVendorIOTASerializerV2 => bytes. - RouteCommitmentByIDUTXOChanges = "/commitments/:" + restapipkg.ParameterCommitmentID + "/utxo-changes" - - // RouteCommitmentByIndex is the route for getting a commitment by its Slot. - // GET returns the commitment. - // MIMEApplicationJSON => json. - // MIMEApplicationVendorIOTASerializerV2 => bytes. - RouteCommitmentByIndex = "/commitments/by-index/:" + restapipkg.ParameterSlotIndex - - // RouteCommitmentByIndexUTXOChanges is the route for getting all UTXO changes of a commitment by its Slot. - // GET returns the output IDs of all UTXO changes. - // MIMEApplicationJSON => json. - // MIMEApplicationVendorIOTASerializerV2 => bytes. - RouteCommitmentByIndexUTXOChanges = "/commitments/by-index/:" + restapipkg.ParameterSlotIndex + "/utxo-changes" - - // RouteCongestion is the route for getting the current congestion state and all account related useful details as block issuance credits. - // GET returns the congestion state related to the specified account address. (optional query parameters: "commitmentID" to specify the used commitment) - // MIMEApplicationJSON => json. - // MIMEApplicationVendorIOTASerializerV2 => bytes. - RouteCongestion = "/accounts/:" + restapipkg.ParameterBech32Address + "/congestion" - - // RouteValidators is the route for getting informations about the current validators. - // GET returns the paginated response with the list of validators. - // MIMEApplicationJSON => json. - // MIMEApplicationVendorIOTASerializerV2 => bytes. - RouteValidators = "/validators" - - // RouteValidatorsAccount is the route for getting details about the validator by its account address. - // GET returns the validator details. - // MIMEApplicationJSON => json. - // MIMEApplicationVendorIOTASerializerV2 => bytes. - RouteValidatorsAccount = "/validators/:" + restapipkg.ParameterBech32Address - - // RouteRewards is the route for getting the rewards for staking or delegation based on staking account or delegation output. - // Rewards are decayed up to returned epochEnd index. - // GET returns the rewards. - // MIMEApplicationJSON => json. - // MIMEApplicationVendorIOTASerializerV2 => bytes. - RouteRewards = "/rewards/:" + restapipkg.ParameterOutputID - - // RouteCommittee is the route for getting the current committee. - // GET returns the committee. - // MIMEApplicationJSON => json. - // MIMEApplicationVendorIOTASerializerV2 => bytes. - RouteCommittee = "/committee" + "github.com/iotaledger/iota.go/v4/api" ) func init() { @@ -178,15 +54,15 @@ func configure() error { Component.LogPanicf("RestAPI plugin needs to be enabled to use the %s plugin", Component.Name) } - routeGroup := deps.RestRouteManager.AddRoute("core/v3") + routeGroup := deps.RestRouteManager.AddRoute(api.CorePluginName) - routeGroup.GET(RouteInfo, func(c echo.Context) error { + routeGroup.GET(api.CoreEndpointInfo, func(c echo.Context) error { resp := info() return responseByHeader(c, resp) }) - routeGroup.GET(RouteBlock, func(c echo.Context) error { + routeGroup.GET(api.EndpointWithEchoParameters(api.CoreEndpointBlock), func(c echo.Context) error { resp, err := blockByID(c) if err != nil { return err @@ -195,7 +71,7 @@ func configure() error { return responseByHeader(c, resp) }) - routeGroup.GET(RouteBlockMetadata, func(c echo.Context) error { + routeGroup.GET(api.EndpointWithEchoParameters(api.CoreEndpointBlockMetadata), func(c echo.Context) error { resp, err := blockMetadataByID(c) if err != nil { return err @@ -204,7 +80,7 @@ func configure() error { return responseByHeader(c, resp) }, checkNodeSynced()) - routeGroup.GET(RouteBlockWithMetadata, func(c echo.Context) error { + routeGroup.GET(api.EndpointWithEchoParameters(api.CoreEndpointBlockWithMetadata), func(c echo.Context) error { resp, err := blockWithMetadataByID(c) if err != nil { return err @@ -213,7 +89,7 @@ func configure() error { return responseByHeader(c, resp) }, checkNodeSynced()) - routeGroup.POST(RouteBlocks, func(c echo.Context) error { + routeGroup.POST(api.CoreEndpointBlocks, func(c echo.Context) error { resp, err := sendBlock(c) if err != nil { return err @@ -223,7 +99,7 @@ func configure() error { return httpserver.JSONResponse(c, http.StatusCreated, resp) }, checkNodeSynced()) - routeGroup.GET(RouteBlockIssuance, func(c echo.Context) error { + routeGroup.GET(api.CoreEndpointBlockIssuance, func(c echo.Context) error { resp, err := blockIssuance() if err != nil { return err @@ -232,8 +108,8 @@ func configure() error { return responseByHeader(c, resp) }, checkNodeSynced()) - routeGroup.GET(RouteCommitmentByID, func(c echo.Context) error { - commitmentID, err := httpserver.ParseCommitmentIDParam(c, restapipkg.ParameterCommitmentID) + routeGroup.GET(api.EndpointWithEchoParameters(api.CoreEndpointCommitmentByID), func(c echo.Context) error { + commitmentID, err := httpserver.ParseCommitmentIDParam(c, api.ParameterCommitmentID) if err != nil { return err } @@ -246,8 +122,8 @@ func configure() error { return responseByHeader(c, commitment.Commitment()) }) - routeGroup.GET(RouteCommitmentByIDUTXOChanges, func(c echo.Context) error { - commitmentID, err := httpserver.ParseCommitmentIDParam(c, restapipkg.ParameterCommitmentID) + routeGroup.GET(api.EndpointWithEchoParameters(api.CoreEndpointCommitmentByIDUTXOChanges), func(c echo.Context) error { + commitmentID, err := httpserver.ParseCommitmentIDParam(c, api.ParameterCommitmentID) if err != nil { return err } @@ -266,8 +142,8 @@ func configure() error { return responseByHeader(c, resp) }) - routeGroup.GET(RouteCommitmentByIndex, func(c echo.Context) error { - index, err := httpserver.ParseSlotParam(c, restapipkg.ParameterSlotIndex) + routeGroup.GET(api.EndpointWithEchoParameters(api.CoreEndpointCommitmentBySlot), func(c echo.Context) error { + index, err := httpserver.ParseSlotParam(c, api.ParameterSlot) if err != nil { return err } @@ -280,8 +156,8 @@ func configure() error { return responseByHeader(c, commitment.Commitment()) }) - routeGroup.GET(RouteCommitmentByIndexUTXOChanges, func(c echo.Context) error { - slot, err := httpserver.ParseSlotParam(c, restapipkg.ParameterSlotIndex) + routeGroup.GET(api.EndpointWithEchoParameters(api.CoreEndpointCommitmentBySlotUTXOChanges), func(c echo.Context) error { + slot, err := httpserver.ParseSlotParam(c, api.ParameterSlot) if err != nil { return err } @@ -299,7 +175,7 @@ func configure() error { return responseByHeader(c, resp) }) - routeGroup.GET(RouteOutput, func(c echo.Context) error { + routeGroup.GET(api.EndpointWithEchoParameters(api.CoreEndpointOutput), func(c echo.Context) error { resp, err := outputByID(c) if err != nil { return err @@ -308,7 +184,7 @@ func configure() error { return responseByHeader(c, resp) }) - routeGroup.GET(RouteOutputMetadata, func(c echo.Context) error { + routeGroup.GET(api.EndpointWithEchoParameters(api.CoreEndpointOutputMetadata), func(c echo.Context) error { resp, err := outputMetadataByID(c) if err != nil { return err @@ -317,7 +193,7 @@ func configure() error { return responseByHeader(c, resp) }) - routeGroup.GET(RouteOutputWithMetadata, func(c echo.Context) error { + routeGroup.GET(api.EndpointWithEchoParameters(api.CoreEndpointOutputWithMetadata), func(c echo.Context) error { resp, err := outputWithMetadataByID(c) if err != nil { return err @@ -326,7 +202,7 @@ func configure() error { return responseByHeader(c, resp) }) - routeGroup.GET(RouteTransactionsIncludedBlock, func(c echo.Context) error { + routeGroup.GET(api.EndpointWithEchoParameters(api.CoreEndpointTransactionsIncludedBlock), func(c echo.Context) error { block, err := blockByTransactionID(c) if err != nil { return err @@ -335,7 +211,7 @@ func configure() error { return responseByHeader(c, block.ProtocolBlock()) }) - routeGroup.GET(RouteTransactionsIncludedBlockMetadata, func(c echo.Context) error { + routeGroup.GET(api.EndpointWithEchoParameters(api.CoreEndpointTransactionsIncludedBlockMetadata), func(c echo.Context) error { resp, err := blockMetadataFromTransactionID(c) if err != nil { return err @@ -344,7 +220,7 @@ func configure() error { return responseByHeader(c, resp) }, checkNodeSynced()) - routeGroup.GET(RouteCongestion, func(c echo.Context) error { + routeGroup.GET(api.EndpointWithEchoParameters(api.CoreEndpointCongestion), func(c echo.Context) error { resp, err := congestionByAccountAddress(c) if err != nil { return err @@ -353,7 +229,7 @@ func configure() error { return responseByHeader(c, resp) }, checkNodeSynced()) - routeGroup.GET(RouteValidators, func(c echo.Context) error { + routeGroup.GET(api.CoreEndpointValidators, func(c echo.Context) error { resp, err := validators(c) if err != nil { return err @@ -362,7 +238,7 @@ func configure() error { return responseByHeader(c, resp) }, checkNodeSynced()) - routeGroup.GET(RouteValidatorsAccount, func(c echo.Context) error { + routeGroup.GET(api.EndpointWithEchoParameters(api.CoreEndpointValidatorsAccount), func(c echo.Context) error { resp, err := validatorByAccountAddress(c) if err != nil { return err @@ -371,7 +247,7 @@ func configure() error { return responseByHeader(c, resp) }, checkNodeSynced()) - routeGroup.GET(RouteRewards, func(c echo.Context) error { + routeGroup.GET(api.EndpointWithEchoParameters(api.CoreEndpointRewards), func(c echo.Context) error { resp, err := rewardsByOutputID(c) if err != nil { return err @@ -380,7 +256,7 @@ func configure() error { return responseByHeader(c, resp) }, checkNodeSynced()) - routeGroup.GET(RouteCommittee, func(c echo.Context) error { + routeGroup.GET(api.CoreEndpointCommittee, func(c echo.Context) error { resp, err := selectedCommittee(c) if err != nil { return err diff --git a/components/restapi/core/node.go b/components/restapi/core/node.go index c6b829c87..5ddc1fcfa 100644 --- a/components/restapi/core/node.go +++ b/components/restapi/core/node.go @@ -1,11 +1,9 @@ package core -import ( - "github.com/iotaledger/iota.go/v4/nodeclient/apimodels" -) +import "github.com/iotaledger/iota.go/v4/api" -func protocolParameters() []*apimodels.InfoResProtocolParameters { - protoParams := make([]*apimodels.InfoResProtocolParameters, 0) +func protocolParameters() []*api.InfoResProtocolParameters { + protoParams := make([]*api.InfoResProtocolParameters, 0) provider := deps.Protocol.MainEngineInstance().Storage.Settings().APIProvider() for _, version := range provider.ProtocolEpochVersions() { protocolParams := provider.ProtocolParameters(version.Version) @@ -13,7 +11,7 @@ func protocolParameters() []*apimodels.InfoResProtocolParameters { continue } - protoParams = append(protoParams, &apimodels.InfoResProtocolParameters{ + protoParams = append(protoParams, &api.InfoResProtocolParameters{ StartEpoch: version.StartEpoch, Parameters: protocolParams, }) @@ -22,15 +20,15 @@ func protocolParameters() []*apimodels.InfoResProtocolParameters { return protoParams } -func info() *apimodels.InfoResponse { +func info() *api.InfoResponse { clSnapshot := deps.Protocol.MainEngineInstance().Clock.Snapshot() syncStatus := deps.Protocol.MainEngineInstance().SyncManager.SyncStatus() metrics := deps.MetricsTracker.NodeMetrics() - return &apimodels.InfoResponse{ + return &api.InfoResponse{ Name: deps.AppInfo.Name, Version: deps.AppInfo.Version, - Status: &apimodels.InfoResNodeStatus{ + Status: &api.InfoResNodeStatus{ IsHealthy: syncStatus.NodeSynced, AcceptedTangleTime: clSnapshot.AcceptedTime, RelativeAcceptedTangleTime: clSnapshot.RelativeAcceptedTime, @@ -42,13 +40,13 @@ func info() *apimodels.InfoResponse { LatestConfirmedBlockSlot: syncStatus.LastConfirmedBlockSlot, PruningEpoch: syncStatus.LastPrunedEpoch, }, - Metrics: &apimodels.InfoResNodeMetrics{ + Metrics: &api.InfoResNodeMetrics{ BlocksPerSecond: metrics.BlocksPerSecond, ConfirmedBlocksPerSecond: metrics.ConfirmedBlocksPerSecond, ConfirmationRate: metrics.ConfirmedRate, }, ProtocolParameters: protocolParameters(), - BaseToken: &apimodels.InfoResBaseToken{ + BaseToken: &api.InfoResBaseToken{ Name: deps.BaseToken.Name, TickerSymbol: deps.BaseToken.TickerSymbol, Unit: deps.BaseToken.Unit, diff --git a/components/restapi/core/transaction.go b/components/restapi/core/transaction.go index 93f660134..a37be7aca 100644 --- a/components/restapi/core/transaction.go +++ b/components/restapi/core/transaction.go @@ -6,15 +6,14 @@ import ( "github.com/iotaledger/hive.go/ierrors" "github.com/iotaledger/inx-app/pkg/httpserver" "github.com/iotaledger/iota-core/pkg/model" - restapipkg "github.com/iotaledger/iota-core/pkg/restapi" iotago "github.com/iotaledger/iota.go/v4" - "github.com/iotaledger/iota.go/v4/nodeclient/apimodels" + "github.com/iotaledger/iota.go/v4/api" ) func blockIDByTransactionID(c echo.Context) (iotago.BlockID, error) { - txID, err := httpserver.ParseTransactionIDParam(c, restapipkg.ParameterTransactionID) + txID, err := httpserver.ParseTransactionIDParam(c, api.ParameterTransactionID) if err != nil { - return iotago.EmptyBlockID, ierrors.Wrapf(err, "failed to parse transaction ID %s", c.Param(restapipkg.ParameterTransactionID)) + return iotago.EmptyBlockID, ierrors.Wrapf(err, "failed to parse transaction ID %s", c.Param(api.ParameterTransactionID)) } return blockIDFromTransactionID(txID) @@ -50,7 +49,7 @@ func blockByTransactionID(c echo.Context) (*model.Block, error) { return block, nil } -func blockMetadataFromTransactionID(c echo.Context) (*apimodels.BlockMetadataResponse, error) { +func blockMetadataFromTransactionID(c echo.Context) (*api.BlockMetadataResponse, error) { blockID, err := blockIDByTransactionID(c) if err != nil { return nil, ierrors.Wrapf(echo.ErrBadRequest, "failed to get block ID by transaction ID: %s", err) diff --git a/components/restapi/core/utxo.go b/components/restapi/core/utxo.go index cec4f033e..a60b79450 100644 --- a/components/restapi/core/utxo.go +++ b/components/restapi/core/utxo.go @@ -6,14 +6,13 @@ import ( "github.com/iotaledger/hive.go/ierrors" "github.com/iotaledger/inx-app/pkg/httpserver" "github.com/iotaledger/iota-core/pkg/protocol/engine/utxoledger" - restapipkg "github.com/iotaledger/iota-core/pkg/restapi" - "github.com/iotaledger/iota.go/v4/nodeclient/apimodels" + "github.com/iotaledger/iota.go/v4/api" ) -func outputByID(c echo.Context) (*apimodels.OutputResponse, error) { - outputID, err := httpserver.ParseOutputIDParam(c, restapipkg.ParameterOutputID) +func outputByID(c echo.Context) (*api.OutputResponse, error) { + outputID, err := httpserver.ParseOutputIDParam(c, api.ParameterOutputID) if err != nil { - return nil, ierrors.Wrapf(err, "failed to parse output ID %s", c.Param(restapipkg.ParameterOutputID)) + return nil, ierrors.Wrapf(err, "failed to parse output ID %s", c.Param(api.ParameterOutputID)) } output, err := deps.Protocol.MainEngineInstance().Ledger.Output(outputID) @@ -21,16 +20,16 @@ func outputByID(c echo.Context) (*apimodels.OutputResponse, error) { return nil, ierrors.Wrapf(echo.ErrInternalServerError, "failed to get output %s from the Ledger: %s", outputID.ToHex(), err) } - return &apimodels.OutputResponse{ + return &api.OutputResponse{ Output: output.Output(), OutputIDProof: output.OutputIDProof(), }, nil } -func outputMetadataByID(c echo.Context) (*apimodels.OutputMetadata, error) { - outputID, err := httpserver.ParseOutputIDParam(c, restapipkg.ParameterOutputID) +func outputMetadataByID(c echo.Context) (*api.OutputMetadata, error) { + outputID, err := httpserver.ParseOutputIDParam(c, api.ParameterOutputID) if err != nil { - return nil, ierrors.Wrapf(err, "failed to parse output ID %s", c.Param(restapipkg.ParameterOutputID)) + return nil, ierrors.Wrapf(err, "failed to parse output ID %s", c.Param(api.ParameterOutputID)) } output, spent, err := deps.Protocol.MainEngineInstance().Ledger.OutputOrSpent(outputID) @@ -45,10 +44,10 @@ func outputMetadataByID(c echo.Context) (*apimodels.OutputMetadata, error) { return newOutputMetadataResponse(output) } -func outputWithMetadataByID(c echo.Context) (*apimodels.OutputWithMetadataResponse, error) { - outputID, err := httpserver.ParseOutputIDParam(c, restapipkg.ParameterOutputID) +func outputWithMetadataByID(c echo.Context) (*api.OutputWithMetadataResponse, error) { + outputID, err := httpserver.ParseOutputIDParam(c, api.ParameterOutputID) if err != nil { - return nil, ierrors.Wrapf(err, "failed to parse output ID %s", c.Param(restapipkg.ParameterOutputID)) + return nil, ierrors.Wrapf(err, "failed to parse output ID %s", c.Param(api.ParameterOutputID)) } output, spent, err := deps.Protocol.MainEngineInstance().Ledger.OutputOrSpent(outputID) @@ -62,7 +61,7 @@ func outputWithMetadataByID(c echo.Context) (*apimodels.OutputWithMetadataRespon return nil, ierrors.Wrapf(echo.ErrInternalServerError, "failed to load spent output metadata: %s", err) } - return &apimodels.OutputWithMetadataResponse{ + return &api.OutputWithMetadataResponse{ Output: spent.Output().Output(), OutputIDProof: spent.Output().OutputIDProof(), Metadata: metadata, @@ -74,17 +73,17 @@ func outputWithMetadataByID(c echo.Context) (*apimodels.OutputWithMetadataRespon return nil, err } - return &apimodels.OutputWithMetadataResponse{ + return &api.OutputWithMetadataResponse{ Output: output.Output(), OutputIDProof: output.OutputIDProof(), Metadata: metadata, }, nil } -func newOutputMetadataResponse(output *utxoledger.Output) (*apimodels.OutputMetadata, error) { +func newOutputMetadataResponse(output *utxoledger.Output) (*api.OutputMetadata, error) { latestCommitment := deps.Protocol.MainEngineInstance().SyncManager.LatestCommitment() - resp := &apimodels.OutputMetadata{ + resp := &api.OutputMetadata{ BlockID: output.BlockID(), TransactionID: output.OutputID().TransactionID(), OutputIndex: output.OutputID().Index(), @@ -105,10 +104,10 @@ func newOutputMetadataResponse(output *utxoledger.Output) (*apimodels.OutputMeta return resp, nil } -func newSpentMetadataResponse(spent *utxoledger.Spent) (*apimodels.OutputMetadata, error) { +func newSpentMetadataResponse(spent *utxoledger.Spent) (*api.OutputMetadata, error) { latestCommitment := deps.Protocol.MainEngineInstance().SyncManager.LatestCommitment() - resp := &apimodels.OutputMetadata{ + resp := &api.OutputMetadata{ BlockID: spent.BlockID(), TransactionID: spent.OutputID().TransactionID(), OutputIndex: spent.OutputID().Index(), diff --git a/components/restapi/management/component.go b/components/restapi/management/component.go index 2ba6507ed..24a3d91dd 100644 --- a/components/restapi/management/component.go +++ b/components/restapi/management/component.go @@ -11,26 +11,7 @@ import ( "github.com/iotaledger/iota-core/components/restapi" "github.com/iotaledger/iota-core/pkg/protocol" restapipkg "github.com/iotaledger/iota-core/pkg/restapi" -) - -const ( - // RoutePeer is the route for getting peers by their peerID. - // GET returns the peer - // DELETE deletes the peer. - RoutePeer = "/peers/:" + restapipkg.ParameterPeerID - - // RoutePeers is the route for getting all peers of the node. - // GET returns a list of all peers. - // POST adds a new peer. - RoutePeers = "/peers" - - // RouteDatabasePrune is the route to manually prune the database. - // POST prunes the database. - RouteDatabasePrune = "/database/prune" - - // RouteSnapshotsCreate is the route to manually create a snapshot files. - // POST creates a full snapshot. - RouteSnapshotsCreate = "/snapshots/create" + "github.com/iotaledger/iota.go/v4/api" ) func init() { @@ -62,9 +43,9 @@ func configure() error { Component.LogPanicf("RestAPI plugin needs to be enabled to use the %s plugin", Component.Name) } - routeGroup := deps.RestRouteManager.AddRoute("management/v1") + routeGroup := deps.RestRouteManager.AddRoute(api.ManagementPluginName) - routeGroup.GET(RoutePeer, func(c echo.Context) error { + routeGroup.GET(api.EndpointWithEchoParameters(api.ManagementEndpointPeer), func(c echo.Context) error { resp, err := getPeer(c) if err != nil { return err @@ -73,7 +54,7 @@ func configure() error { return httpserver.JSONResponse(c, http.StatusOK, resp) }) - routeGroup.DELETE(RoutePeer, func(c echo.Context) error { + routeGroup.DELETE(api.EndpointWithEchoParameters(api.ManagementEndpointPeer), func(c echo.Context) error { if err := removePeer(c); err != nil { return err } @@ -81,7 +62,7 @@ func configure() error { return c.NoContent(http.StatusNoContent) }) - routeGroup.GET(RoutePeers, func(c echo.Context) error { + routeGroup.GET(api.ManagementEndpointPeers, func(c echo.Context) error { resp, err := listPeers(c) if err != nil { return err @@ -90,7 +71,7 @@ func configure() error { return httpserver.JSONResponse(c, http.StatusOK, resp) }) - routeGroup.POST(RoutePeers, func(c echo.Context) error { + routeGroup.POST(api.ManagementEndpointPeers, func(c echo.Context) error { resp, err := addPeer(c, Component.Logger()) if err != nil { return err @@ -99,7 +80,7 @@ func configure() error { return httpserver.JSONResponse(c, http.StatusOK, resp) }) - routeGroup.POST(RouteDatabasePrune, func(c echo.Context) error { + routeGroup.POST(api.ManagementEndpointDatabasePrune, func(c echo.Context) error { resp, err := pruneDatabase(c) if err != nil { return err @@ -108,7 +89,7 @@ func configure() error { return httpserver.JSONResponse(c, http.StatusOK, resp) }) - routeGroup.POST(RouteSnapshotsCreate, func(c echo.Context) error { + routeGroup.POST(api.ManagementEndpointSnapshotsCreate, func(c echo.Context) error { resp, err := createSnapshots(c) if err != nil { return err diff --git a/components/restapi/management/peers.go b/components/restapi/management/peers.go index 254267e42..95af092a4 100644 --- a/components/restapi/management/peers.go +++ b/components/restapi/management/peers.go @@ -4,12 +4,12 @@ import ( "github.com/labstack/echo/v4" "github.com/iotaledger/hive.go/logger" - "github.com/iotaledger/iota.go/v4/nodeclient/apimodels" + "github.com/iotaledger/iota.go/v4/api" ) /* // WrapInfoSnapshot wraps the given peer info snapshot with additional metadata, such as gossip protocol information. -func WrapInfoSnapshot(info *p2p.PeerInfoSnapshot) *apimodels.PeerResponse { +func WrapInfoSnapshot(info *p2p.PeerInfoSnapshot) *api.PeerResponse { var alias *string if info.Alias != "" { @@ -39,7 +39,7 @@ func WrapInfoSnapshot(info *p2p.PeerInfoSnapshot) *apimodels.PeerResponse { } */ -func getPeer(_ echo.Context) (*apimodels.PeerInfo, error) { +func getPeer(_ echo.Context) (*api.PeerInfo, error) { /* peerID, err := restapipkg.ParsePeerIDParam(c) if err != nil { @@ -74,7 +74,7 @@ func removePeer(_ echo.Context) error { } //nolint:unparam // even if the error is never used, the structure of all routes should be the same -func listPeers(_ echo.Context) (*apimodels.PeersResponse, error) { +func listPeers(_ echo.Context) (*api.PeersResponse, error) { /* peerInfos := deps.PeeringManager.PeerInfoSnapshots() results := make([]*PeerResponse, len(peerInfos)) @@ -89,7 +89,7 @@ func listPeers(_ echo.Context) (*apimodels.PeersResponse, error) { return nil, nil } -func addPeer(_ echo.Context, _ *logger.Logger) (*apimodels.PeerInfo, error) { +func addPeer(_ echo.Context, _ *logger.Logger) (*api.PeerInfo, error) { /* request := &addPeerRequest{} diff --git a/components/restapi/management/pruning.go b/components/restapi/management/pruning.go index 972646757..8f9af7399 100644 --- a/components/restapi/management/pruning.go +++ b/components/restapi/management/pruning.go @@ -6,15 +6,15 @@ import ( "github.com/iotaledger/hive.go/ierrors" "github.com/iotaledger/inx-app/pkg/httpserver" - "github.com/iotaledger/iota.go/v4/nodeclient/apimodels" + "github.com/iotaledger/iota.go/v4/api" ) -func pruneDatabase(c echo.Context) (*apimodels.PruneDatabaseResponse, error) { +func pruneDatabase(c echo.Context) (*api.PruneDatabaseResponse, error) { if deps.Protocol.MainEngineInstance().Storage.IsPruning() { return nil, ierrors.Wrapf(echo.ErrServiceUnavailable, "node is already pruning") } - request := &apimodels.PruneDatabaseRequest{} + request := &api.PruneDatabaseRequest{} if err := c.Bind(request); err != nil { return nil, ierrors.Wrapf(httpserver.ErrInvalidParameter, "invalid request, error: %s", err) } @@ -60,7 +60,7 @@ func pruneDatabase(c echo.Context) (*apimodels.PruneDatabaseResponse, error) { targetEpoch++ } - return &apimodels.PruneDatabaseResponse{ + return &api.PruneDatabaseResponse{ Epoch: targetEpoch, }, nil } diff --git a/components/restapi/management/snapshots.go b/components/restapi/management/snapshots.go index 3f6f76317..bbcec37c6 100644 --- a/components/restapi/management/snapshots.go +++ b/components/restapi/management/snapshots.go @@ -3,10 +3,10 @@ package management import ( "github.com/labstack/echo/v4" - "github.com/iotaledger/iota.go/v4/nodeclient/apimodels" + "github.com/iotaledger/iota.go/v4/api" ) -func createSnapshots(_ echo.Context) (*apimodels.CreateSnapshotsResponse, error) { +func createSnapshots(_ echo.Context) (*api.CreateSnapshotsResponse, error) { /* if deps.SnapshotManager.IsSnapshotting() || deps.PruningManager.IsPruning() { return nil, errors.WithMessage(echo.ErrServiceUnavailable, "node is already creating a snapshot or pruning is running") diff --git a/components/restapi/routes.go b/components/restapi/routes.go index 262284b27..0ea71b46c 100644 --- a/components/restapi/routes.go +++ b/components/restapi/routes.go @@ -6,12 +6,7 @@ import ( "github.com/labstack/echo/v4" "github.com/iotaledger/inx-app/pkg/httpserver" -) - -const ( - nodeAPIHealthRoute = "/health" - - nodeAPIRoutesRoute = "/api/routes" + "github.com/iotaledger/iota.go/v4/api" ) type RoutesResponse struct { @@ -20,7 +15,7 @@ type RoutesResponse struct { func setupRoutes() { - deps.Echo.GET(nodeAPIHealthRoute, func(c echo.Context) error { + deps.Echo.GET(api.RouteHealth, func(c echo.Context) error { if deps.Protocol.MainEngineInstance().SyncManager.IsNodeSynced() { return c.NoContent(http.StatusOK) } @@ -28,7 +23,7 @@ func setupRoutes() { return c.NoContent(http.StatusServiceUnavailable) }) - deps.Echo.GET(nodeAPIRoutesRoute, func(c echo.Context) error { + deps.Echo.GET(api.RouteRoutes, func(c echo.Context) error { resp := &RoutesResponse{ Routes: deps.RestRouteManager.Routes(), } diff --git a/go.mod b/go.mod index 34f3301f7..a22ffce64 100644 --- a/go.mod +++ b/go.mod @@ -12,20 +12,20 @@ require ( github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 github.com/iotaledger/hive.go/ads v0.0.0-20231110191152-7135670285dc github.com/iotaledger/hive.go/app v0.0.0-20231113110812-4ca2b6cc9a42 - github.com/iotaledger/hive.go/constraints v0.0.0-20231113110812-4ca2b6cc9a42 + github.com/iotaledger/hive.go/constraints v0.0.0-20231122112629-bdf1cc39fba7 github.com/iotaledger/hive.go/core v1.0.0-rc.3.0.20231113110812-4ca2b6cc9a42 - github.com/iotaledger/hive.go/crypto v0.0.0-20231113110812-4ca2b6cc9a42 + github.com/iotaledger/hive.go/crypto v0.0.0-20231122112629-bdf1cc39fba7 github.com/iotaledger/hive.go/ds v0.0.0-20231113110812-4ca2b6cc9a42 - github.com/iotaledger/hive.go/ierrors v0.0.0-20231113110812-4ca2b6cc9a42 + github.com/iotaledger/hive.go/ierrors v0.0.0-20231122112629-bdf1cc39fba7 github.com/iotaledger/hive.go/kvstore v0.0.0-20231110191152-7135670285dc - github.com/iotaledger/hive.go/lo v0.0.0-20231113110812-4ca2b6cc9a42 + github.com/iotaledger/hive.go/lo v0.0.0-20231122112629-bdf1cc39fba7 github.com/iotaledger/hive.go/logger v0.0.0-20231113110812-4ca2b6cc9a42 - github.com/iotaledger/hive.go/runtime v0.0.0-20231113110812-4ca2b6cc9a42 + github.com/iotaledger/hive.go/runtime v0.0.0-20231122112629-bdf1cc39fba7 github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20231113110812-4ca2b6cc9a42 - github.com/iotaledger/hive.go/stringify v0.0.0-20231113110812-4ca2b6cc9a42 - github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231121121055-b13a176c5180 - github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231120082637-ccd5b8465251 - github.com/iotaledger/iota.go/v4 v4.0.0-20231123022049-52a0703d077f + github.com/iotaledger/hive.go/stringify v0.0.0-20231122112629-bdf1cc39fba7 + github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231123103852-bb039cbab83b + github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231123103318-f6ea945e2e98 + github.com/iotaledger/iota.go/v4 v4.0.0-20231123102955-eff367396512 github.com/labstack/echo/v4 v4.11.3 github.com/labstack/gommon v0.4.1 github.com/libp2p/go-libp2p v0.32.0 @@ -178,7 +178,7 @@ require ( golang.org/x/time v0.4.0 // indirect golang.org/x/tools v0.14.0 // indirect gonum.org/v1/gonum v0.14.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20231106174013-bbf56f31fb17 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20231120223509-83a465c0220f // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect lukechampine.com/blake3 v1.2.1 // indirect diff --git a/go.sum b/go.sum index 2d5b85f2b..4f00d72fe 100644 --- a/go.sum +++ b/go.sum @@ -279,36 +279,36 @@ github.com/iotaledger/hive.go/ads v0.0.0-20231110191152-7135670285dc h1:PsArE43U github.com/iotaledger/hive.go/ads v0.0.0-20231110191152-7135670285dc/go.mod h1:gbUvr01B5ha530GnNm8K2OsHXOd2BtzBYOMxyTX3iDg= github.com/iotaledger/hive.go/app v0.0.0-20231113110812-4ca2b6cc9a42 h1:K6VF23FOqHTRdk5OzsuBkYlGV008SZgKYqNwb0bp3rk= github.com/iotaledger/hive.go/app v0.0.0-20231113110812-4ca2b6cc9a42/go.mod h1:+riYmeLApkLlj4+EpuJpEJAsj/KGfD7cqLGy7oTsPOM= -github.com/iotaledger/hive.go/constraints v0.0.0-20231113110812-4ca2b6cc9a42 h1:+PyLPZhRHy+Negjpuj0CSLaObpErEH7yI6HB2z5N6b0= -github.com/iotaledger/hive.go/constraints v0.0.0-20231113110812-4ca2b6cc9a42/go.mod h1:dOBOM2s4se3HcWefPe8sQLUalGXJ8yVXw58oK8jke3s= +github.com/iotaledger/hive.go/constraints v0.0.0-20231122112629-bdf1cc39fba7 h1:ozpeM5nHHUjK3aKpTmwFEDG2bqxLJf0KBCTakjh+1FE= +github.com/iotaledger/hive.go/constraints v0.0.0-20231122112629-bdf1cc39fba7/go.mod h1:dOBOM2s4se3HcWefPe8sQLUalGXJ8yVXw58oK8jke3s= github.com/iotaledger/hive.go/core v1.0.0-rc.3.0.20231113110812-4ca2b6cc9a42 h1:3dW4gz0Vr9BogN826HRTp0OFlbngjhWcVPUfDhJ57Yw= github.com/iotaledger/hive.go/core v1.0.0-rc.3.0.20231113110812-4ca2b6cc9a42/go.mod h1:CdixkrB7VdQzEDlVuwsxPtsiJL/WXrQgz3PELIqlLko= -github.com/iotaledger/hive.go/crypto v0.0.0-20231113110812-4ca2b6cc9a42 h1:t6EKe+O7XAmbe07cVHuM/3aBLEbVIY4D6yefANB4PUA= -github.com/iotaledger/hive.go/crypto v0.0.0-20231113110812-4ca2b6cc9a42/go.mod h1:OQ9EVTTQT1mkO/16BgwSIyQlAhEg+Cptud/yutevWsI= +github.com/iotaledger/hive.go/crypto v0.0.0-20231122112629-bdf1cc39fba7 h1:vLLhxGhipU6AH/paexuRX3zsOvcl8bdYcwJRAchUP8g= +github.com/iotaledger/hive.go/crypto v0.0.0-20231122112629-bdf1cc39fba7/go.mod h1:OQ9EVTTQT1mkO/16BgwSIyQlAhEg+Cptud/yutevWsI= github.com/iotaledger/hive.go/ds v0.0.0-20231113110812-4ca2b6cc9a42 h1:QZiMlDxmikF64zimWQunTrsEGOK9ydRahUAz2I46JAk= github.com/iotaledger/hive.go/ds v0.0.0-20231113110812-4ca2b6cc9a42/go.mod h1:JE8cbZSvzbB5TrwXibg6M0B7ck35YxF30ItHBzQRlgc= -github.com/iotaledger/hive.go/ierrors v0.0.0-20231113110812-4ca2b6cc9a42 h1:gxlZ4zL6EfLyqT0+hIFV3WVE0FrPVgV5cQdyn36vPXQ= -github.com/iotaledger/hive.go/ierrors v0.0.0-20231113110812-4ca2b6cc9a42/go.mod h1:HcE8B5lP96enc/OALTb2/rIIi+yOLouRoHOKRclKmC8= +github.com/iotaledger/hive.go/ierrors v0.0.0-20231122112629-bdf1cc39fba7 h1:tf7x4U+ZXnmFXhUmqYtn0kcgpOcGPIhbxR/akpzAU4U= +github.com/iotaledger/hive.go/ierrors v0.0.0-20231122112629-bdf1cc39fba7/go.mod h1:HcE8B5lP96enc/OALTb2/rIIi+yOLouRoHOKRclKmC8= github.com/iotaledger/hive.go/kvstore v0.0.0-20231110191152-7135670285dc h1:3fsqfM2NqfhrewVdlKT3MHcXxVNvUCSP7P32il1ypa0= github.com/iotaledger/hive.go/kvstore v0.0.0-20231110191152-7135670285dc/go.mod h1:ytfKoHr/nF8u0y0G4mamfG0yjFtJiJVk0kgjnPOtsSY= -github.com/iotaledger/hive.go/lo v0.0.0-20231113110812-4ca2b6cc9a42 h1:kcHkWyURZDVqO80OmJo5Z+wTJB6H+s52WAnU575vX0o= -github.com/iotaledger/hive.go/lo v0.0.0-20231113110812-4ca2b6cc9a42/go.mod h1:6Ee7i6b4tuTHuRYnPP8VUb0wr9XFI5qlqtnttBd9jRg= +github.com/iotaledger/hive.go/lo v0.0.0-20231122112629-bdf1cc39fba7 h1:svFxB75LsjUOHt3crcn70GVk7ztdNv5CytC3GbGj9FQ= +github.com/iotaledger/hive.go/lo v0.0.0-20231122112629-bdf1cc39fba7/go.mod h1:6Ee7i6b4tuTHuRYnPP8VUb0wr9XFI5qlqtnttBd9jRg= github.com/iotaledger/hive.go/log v0.0.0-20231110191152-7135670285dc h1:joYrsSZuVG3DfAQR9iS3qjnMExJ0qNp2+369sxb1Y4g= github.com/iotaledger/hive.go/log v0.0.0-20231110191152-7135670285dc/go.mod h1:vzO4/wRkEJDEZb/9fD10oKU9k1bj4qLir2Uhl5U1FkM= github.com/iotaledger/hive.go/logger v0.0.0-20231113110812-4ca2b6cc9a42 h1:uD99UbTtBM5SIP9N3c/3BBLtb0frGYFsZ2lS8Zxtqr4= github.com/iotaledger/hive.go/logger v0.0.0-20231113110812-4ca2b6cc9a42/go.mod h1:w1psHM2MuKsen1WdsPKrpqElYH7ZOQ+YdQIgJZg4HTo= -github.com/iotaledger/hive.go/runtime v0.0.0-20231113110812-4ca2b6cc9a42 h1:hpR++ME3Y3CcxA431Zg0PgcCJUNkbBqjNXxR/bs+NdI= -github.com/iotaledger/hive.go/runtime v0.0.0-20231113110812-4ca2b6cc9a42/go.mod h1:DrZPvUvLarK8C2qb+3H2vdypp/MuhpQmB3iMJbDCr/Q= +github.com/iotaledger/hive.go/runtime v0.0.0-20231122112629-bdf1cc39fba7 h1:NtR3ZeY6Mop9JcHu62Z6JPMRcijIV1ZCZPpOev8HZRw= +github.com/iotaledger/hive.go/runtime v0.0.0-20231122112629-bdf1cc39fba7/go.mod h1:DrZPvUvLarK8C2qb+3H2vdypp/MuhpQmB3iMJbDCr/Q= github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20231113110812-4ca2b6cc9a42 h1:hepsnGvaS39azq80GV8DT9HlexoO/RqJbyiW5FXZ0HQ= github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20231113110812-4ca2b6cc9a42/go.mod h1:FoH3T6yKlZJp8xm8K+zsQiibSynp32v21CpWx8xkek8= -github.com/iotaledger/hive.go/stringify v0.0.0-20231113110812-4ca2b6cc9a42 h1:9c7NiX2cnNPHR9UNWINDqNkolupXiDF3543pR6KLwIg= -github.com/iotaledger/hive.go/stringify v0.0.0-20231113110812-4ca2b6cc9a42/go.mod h1:FTo/UWzNYgnQ082GI9QVM9HFDERqf9rw9RivNpqrnTs= -github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231121121055-b13a176c5180 h1:hAVWoyAF4FE+1gUd2IqvTBDTnQ4Z0GKE6qc8qw9QPqg= -github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231121121055-b13a176c5180/go.mod h1:iFiY6UukYeL8D3N1mtg4jh/9lxTBhzG0QgtD+w0gpps= -github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231120082637-ccd5b8465251 h1:bYGO8jXNXJNMGPG9etGW7WXfLbRU9ofx1xdd29/sS9M= -github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231120082637-ccd5b8465251/go.mod h1:chzj8FDIeXHIh3D52QTZ7imADlzdkhg7o7E2Qr85MJ8= -github.com/iotaledger/iota.go/v4 v4.0.0-20231123022049-52a0703d077f h1:CBSRHs4ysjR/NgrVb//4mm5SgzynIOOm0ZJ3IRIf3FY= -github.com/iotaledger/iota.go/v4 v4.0.0-20231123022049-52a0703d077f/go.mod h1:1CUJKGvkOUGXakxFZGAagEQDX9qYyhzIElmUHCHo9RM= +github.com/iotaledger/hive.go/stringify v0.0.0-20231122112629-bdf1cc39fba7 h1:h481Dn+giKO/1MamwuDZ8Mvzg4GbPx/asKD/X3Zs8wc= +github.com/iotaledger/hive.go/stringify v0.0.0-20231122112629-bdf1cc39fba7/go.mod h1:FTo/UWzNYgnQ082GI9QVM9HFDERqf9rw9RivNpqrnTs= +github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231123103852-bb039cbab83b h1:T/9f4eYcP/fxe0G0pYa6TRZxD9rI9uMdDW89hnsNByU= +github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231123103852-bb039cbab83b/go.mod h1:c7ktZxoH5Wp2ixzJn/8RmM5v2QOCIu/79tDFvfLbyPs= +github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231123103318-f6ea945e2e98 h1:PjGs+njONeFaxFgQ3lxxlRs3wTYw3233f/yDyTV8/F8= +github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231123103318-f6ea945e2e98/go.mod h1:jFRt2SZO3KE74/mk+zeCjlhVROriEg86K8CJTxvfdP8= +github.com/iotaledger/iota.go/v4 v4.0.0-20231123102955-eff367396512 h1:E1m9Ja6d47sVkl0k2a8eU9f5COWqpyNY9ET3TyYLHiI= +github.com/iotaledger/iota.go/v4 v4.0.0-20231123102955-eff367396512/go.mod h1:aO+5iL0vTNwNfE4QMGHVIufGziSI1wTvwJY1ipSMgCk= github.com/ipfs/boxo v0.13.1 h1:nQ5oQzcMZR3oL41REJDcTbrvDvuZh3J9ckc9+ILeRQI= github.com/ipfs/boxo v0.13.1/go.mod h1:btrtHy0lmO1ODMECbbEY1pxNtrLilvKSYLoGQt1yYCk= github.com/ipfs/go-cid v0.4.1 h1:A/T3qGvxi4kpKWWcPC/PgbvDA2bjVLO7n4UeVwnbs/s= @@ -877,8 +877,8 @@ google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98 google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= -google.golang.org/genproto/googleapis/rpc v0.0.0-20231106174013-bbf56f31fb17 h1:Jyp0Hsi0bmHXG6k9eATXoYtjd6e2UzZ1SCn/wIupY14= -google.golang.org/genproto/googleapis/rpc v0.0.0-20231106174013-bbf56f31fb17/go.mod h1:oQ5rr10WTTMvP4A36n8JpR1OrO1BEiV4f78CneXZxkA= +google.golang.org/genproto/googleapis/rpc v0.0.0-20231120223509-83a465c0220f h1:ultW7fxlIvee4HYrtnaRPon9HpEgFk5zYpmfMgtKB5I= +google.golang.org/genproto/googleapis/rpc v0.0.0-20231120223509-83a465c0220f/go.mod h1:L9KNLi232K1/xB6f7AlSX692koaRnKaWSR0stBki0Yc= google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.16.0/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9MZMio= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= diff --git a/pkg/protocol/chainmanager/testframework.go b/pkg/protocol/chainmanager/testframework.go index 8fdf41833..9d939b82b 100644 --- a/pkg/protocol/chainmanager/testframework.go +++ b/pkg/protocol/chainmanager/testframework.go @@ -12,7 +12,6 @@ import ( "github.com/iotaledger/hive.go/runtime/syncutils" "github.com/iotaledger/iota-core/pkg/model" iotago "github.com/iotaledger/iota.go/v4" - "github.com/iotaledger/iota.go/v4/api" ) type TestFramework struct { @@ -38,7 +37,7 @@ func NewTestFramework(test *testing.T, a iotago.API, opts ...options.Option[Test } return options.Apply(&TestFramework{ - Instance: NewManager(api.SingleVersionProvider(a), handleError), + Instance: NewManager(iotago.SingleVersionProvider(a), handleError), test: test, api: a, diff --git a/pkg/protocol/engine/accounts/accountsledger/testsuite_test.go b/pkg/protocol/engine/accounts/accountsledger/testsuite_test.go index 3decfe1cb..08cfe1e99 100644 --- a/pkg/protocol/engine/accounts/accountsledger/testsuite_test.go +++ b/pkg/protocol/engine/accounts/accountsledger/testsuite_test.go @@ -19,7 +19,6 @@ import ( "github.com/iotaledger/iota-core/pkg/storage/prunable/slotstore" "github.com/iotaledger/iota-core/pkg/utils" iotago "github.com/iotaledger/iota.go/v4" - "github.com/iotaledger/iota.go/v4/api" "github.com/iotaledger/iota.go/v4/tpkg" ) @@ -44,7 +43,7 @@ func NewTestSuite(test *testing.T) *TestSuite { t := &TestSuite{ T: test, - apiProvider: api.SingleVersionProvider(testAPI), + apiProvider: iotago.SingleVersionProvider(testAPI), accounts: make(map[string]iotago.AccountID), blockIssuerKeys: make(map[string]iotago.BlockIssuerKey), outputs: make(map[string]iotago.OutputID), diff --git a/pkg/protocol/engine/accounts/mana/manager_test.go b/pkg/protocol/engine/accounts/mana/manager_test.go index 767367087..62301750c 100644 --- a/pkg/protocol/engine/accounts/mana/manager_test.go +++ b/pkg/protocol/engine/accounts/mana/manager_test.go @@ -11,7 +11,6 @@ import ( "github.com/iotaledger/iota-core/pkg/protocol/engine/accounts" "github.com/iotaledger/iota-core/pkg/protocol/engine/utxoledger" iotago "github.com/iotaledger/iota.go/v4" - "github.com/iotaledger/iota.go/v4/api" "github.com/iotaledger/iota.go/v4/tpkg" ) @@ -25,7 +24,7 @@ func TestManager_GetManaOnAccountOverflow(t *testing.T) { switch id { case accountIDOverflow: return utxoledger.CreateOutput( - api.SingleVersionProvider(tpkg.TestAPI), + iotago.SingleVersionProvider(tpkg.TestAPI), iotago.OutputIDFromTransactionIDAndIndex(iotago.NewTransactionID(0, tpkg.Rand32ByteArray()), 0), tpkg.RandBlockID(), tpkg.RandSlot(), @@ -38,7 +37,7 @@ func TestManager_GetManaOnAccountOverflow(t *testing.T) { ), nil case accountIDRecentOutput: return utxoledger.CreateOutput( - api.SingleVersionProvider(tpkg.TestAPI), + iotago.SingleVersionProvider(tpkg.TestAPI), iotago.OutputIDFromTransactionIDAndIndex(iotago.NewTransactionID(1, tpkg.Rand32ByteArray()), 0), tpkg.RandBlockID(), tpkg.RandSlot(), @@ -51,7 +50,7 @@ func TestManager_GetManaOnAccountOverflow(t *testing.T) { ), nil default: return utxoledger.CreateOutput( - api.SingleVersionProvider(tpkg.TestAPI), + iotago.SingleVersionProvider(tpkg.TestAPI), iotago.OutputIDFromTransactionIDAndIndex(iotago.NewTransactionID(0, tpkg.Rand32ByteArray()), 0), tpkg.RandBlockID(), tpkg.RandSlot(), @@ -101,7 +100,7 @@ func TestManager_GetManaOnAccountOverflow(t *testing.T) { } } - manager := NewManager(api.SingleVersionProvider(tpkg.TestAPI), outputRetriever, accountRetriever) + manager := NewManager(iotago.SingleVersionProvider(tpkg.TestAPI), outputRetriever, accountRetriever) manaDecayProvider := manager.apiProvider.LatestAPI().ManaDecayProvider() // The value for this account will overflow because component values are too big. diff --git a/pkg/protocol/engine/attestation/slotattestation/testframework_test.go b/pkg/protocol/engine/attestation/slotattestation/testframework_test.go index 07fa7abe1..ed0cef175 100644 --- a/pkg/protocol/engine/attestation/slotattestation/testframework_test.go +++ b/pkg/protocol/engine/attestation/slotattestation/testframework_test.go @@ -19,7 +19,6 @@ import ( "github.com/iotaledger/iota-core/pkg/protocol/engine/attestation/slotattestation" "github.com/iotaledger/iota-core/pkg/protocol/engine/blocks" iotago "github.com/iotaledger/iota.go/v4" - "github.com/iotaledger/iota.go/v4/api" "github.com/iotaledger/iota.go/v4/builder" ) @@ -78,7 +77,7 @@ func NewTestFramework(test *testing.T) *TestFramework { ), ) - t.apiProvider = api.SingleVersionProvider(t.testAPI) + t.apiProvider = iotago.SingleVersionProvider(t.testAPI) t.Instance = slotattestation.NewManager( 0, diff --git a/pkg/protocol/engine/blockdag/inmemoryblockdag/blockdag.go b/pkg/protocol/engine/blockdag/inmemoryblockdag/blockdag.go index 9d9e3b16f..85125a616 100644 --- a/pkg/protocol/engine/blockdag/inmemoryblockdag/blockdag.go +++ b/pkg/protocol/engine/blockdag/inmemoryblockdag/blockdag.go @@ -15,7 +15,7 @@ import ( "github.com/iotaledger/iota-core/pkg/protocol/engine/blocks" "github.com/iotaledger/iota-core/pkg/protocol/engine/eviction" iotago "github.com/iotaledger/iota.go/v4" - "github.com/iotaledger/iota.go/v4/nodeclient/apimodels" + "github.com/iotaledger/iota.go/v4/api" ) // BlockDAG is a causally ordered DAG that forms the central data structure of the IOTA protocol. @@ -29,7 +29,7 @@ type BlockDAG struct { latestCommitmentFunc func() *model.Commitment uncommittedSlotBlocks *buffer.UnsolidCommitmentBuffer[*blocks.Block] - retainBlockFailure func(blockID iotago.BlockID, failureReason apimodels.BlockFailureReason) + retainBlockFailure func(blockID iotago.BlockID, failureReason api.BlockFailureReason) blockCache *blocks.Blocks @@ -159,7 +159,7 @@ func (b *BlockDAG) Shutdown() { b.workers.Shutdown() } -func (b *BlockDAG) setRetainBlockFailureFunc(retainBlockFailure func(blockID iotago.BlockID, failureReason apimodels.BlockFailureReason)) { +func (b *BlockDAG) setRetainBlockFailureFunc(retainBlockFailure func(blockID iotago.BlockID, failureReason api.BlockFailureReason)) { b.retainBlockFailure = retainBlockFailure } @@ -174,7 +174,7 @@ func (b *BlockDAG) attach(data *model.Block) (block *blocks.Block, wasAttached b block, evicted, updated := b.blockCache.StoreOrUpdate(data) if evicted { - b.retainBlockFailure(data.ID(), apimodels.BlockFailureIsTooOld) + b.retainBlockFailure(data.ID(), api.BlockFailureIsTooOld) return block, false, ierrors.New("cannot attach, block is too old, it was already evicted from the cache") } @@ -192,7 +192,7 @@ func (b *BlockDAG) attach(data *model.Block) (block *blocks.Block, wasAttached b // canAttach determines if the Block can be attached (does not exist and addresses a recent slot). func (b *BlockDAG) shouldAttach(data *model.Block) (shouldAttach bool, err error) { if b.evictionState.InRootBlockSlot(data.ID()) && !b.evictionState.IsRootBlock(data.ID()) { - b.retainBlockFailure(data.ID(), apimodels.BlockFailureIsTooOld) + b.retainBlockFailure(data.ID(), api.BlockFailureIsTooOld) return false, ierrors.Errorf("block data with %s is too old (issued at: %s)", data.ID(), data.ProtocolBlock().Header.IssuingTime) } @@ -216,7 +216,7 @@ func (b *BlockDAG) shouldAttach(data *model.Block) (shouldAttach bool, err error func (b *BlockDAG) canAttachToParents(modelBlock *model.Block) (parentsValid bool, err error) { for _, parentID := range modelBlock.ProtocolBlock().Parents() { if b.evictionState.InRootBlockSlot(parentID) && !b.evictionState.IsRootBlock(parentID) { - b.retainBlockFailure(modelBlock.ID(), apimodels.BlockFailureParentIsTooOld) + b.retainBlockFailure(modelBlock.ID(), api.BlockFailureParentIsTooOld) return false, ierrors.Errorf("parent %s of block %s is too old", parentID, modelBlock.ID()) } } diff --git a/pkg/protocol/engine/booker/inmemorybooker/booker.go b/pkg/protocol/engine/booker/inmemorybooker/booker.go index fb307866b..bae2873cf 100644 --- a/pkg/protocol/engine/booker/inmemorybooker/booker.go +++ b/pkg/protocol/engine/booker/inmemorybooker/booker.go @@ -15,7 +15,7 @@ import ( "github.com/iotaledger/iota-core/pkg/protocol/engine/mempool" "github.com/iotaledger/iota-core/pkg/protocol/engine/mempool/conflictdag" iotago "github.com/iotaledger/iota.go/v4" - "github.com/iotaledger/iota.go/v4/nodeclient/apimodels" + "github.com/iotaledger/iota.go/v4/api" ) type Booker struct { @@ -27,7 +27,7 @@ type Booker struct { ledger ledger.Ledger - retainBlockFailure func(id iotago.BlockID, reason apimodels.BlockFailureReason) + retainBlockFailure func(id iotago.BlockID, reason api.BlockFailureReason) errorHandler func(error) apiProvider iotago.APIProvider @@ -92,7 +92,7 @@ func (b *Booker) Queue(block *blocks.Block) error { } if signedTransactionMetadata == nil { - b.retainBlockFailure(block.ID(), apimodels.BlockFailurePayloadInvalid) + b.retainBlockFailure(block.ID(), api.BlockFailurePayloadInvalid) return ierrors.Errorf("transaction in %s was not attached", block.ID()) } @@ -153,7 +153,7 @@ func (b *Booker) setupBlock(block *blocks.Block) { }) } -func (b *Booker) setRetainBlockFailureFunc(retainBlockFailure func(iotago.BlockID, apimodels.BlockFailureReason)) { +func (b *Booker) setRetainBlockFailureFunc(retainBlockFailure func(iotago.BlockID, api.BlockFailureReason)) { b.retainBlockFailure = retainBlockFailure } @@ -192,7 +192,7 @@ func (b *Booker) inheritConflicts(block *blocks.Block) (conflictIDs ds.Set[iotag for _, parent := range block.ParentsWithType() { parentBlock, exists := b.blockCache.Block(parent.ID) if !exists { - b.retainBlockFailure(block.ID(), apimodels.BlockFailureParentNotFound) + b.retainBlockFailure(block.ID(), api.BlockFailureParentNotFound) return nil, ierrors.Errorf("parent %s does not exist", parent.ID) } diff --git a/pkg/protocol/engine/commitmentfilter/accountsfilter/commitmentfilter_test.go b/pkg/protocol/engine/commitmentfilter/accountsfilter/commitmentfilter_test.go index c7274801b..40e1cbfd8 100644 --- a/pkg/protocol/engine/commitmentfilter/accountsfilter/commitmentfilter_test.go +++ b/pkg/protocol/engine/commitmentfilter/accountsfilter/commitmentfilter_test.go @@ -13,7 +13,6 @@ import ( "github.com/iotaledger/iota-core/pkg/protocol/engine/blocks" "github.com/iotaledger/iota-core/pkg/protocol/engine/commitmentfilter" iotago "github.com/iotaledger/iota.go/v4" - "github.com/iotaledger/iota.go/v4/api" "github.com/iotaledger/iota.go/v4/builder" "github.com/iotaledger/iota.go/v4/tpkg" ) @@ -121,7 +120,7 @@ func TestCommitmentFilter_NoAccount(t *testing.T) { testAPI := tpkg.TestAPI tf := NewTestFramework(t, - api.SingleVersionProvider(testAPI), + iotago.SingleVersionProvider(testAPI), ) tf.CommitmentFilter.events.BlockAllowed.Hook(func(block *blocks.Block) { @@ -183,7 +182,7 @@ func TestCommitmentFilter_BurnedMana(t *testing.T) { testAPI := tpkg.TestAPI tf := NewTestFramework(t, - api.SingleVersionProvider(testAPI), + iotago.SingleVersionProvider(testAPI), ) tf.CommitmentFilter.events.BlockAllowed.Hook(func(block *blocks.Block) { @@ -231,7 +230,7 @@ func TestCommitmentFilter_Expiry(t *testing.T) { testAPI := tpkg.TestAPI tf := NewTestFramework(t, - api.SingleVersionProvider(testAPI), + iotago.SingleVersionProvider(testAPI), ) tf.CommitmentFilter.events.BlockAllowed.Hook(func(block *blocks.Block) { diff --git a/pkg/protocol/engine/consensus/blockgadget/testframework_test.go b/pkg/protocol/engine/consensus/blockgadget/testframework_test.go index aa7466f6c..aaea4179f 100644 --- a/pkg/protocol/engine/consensus/blockgadget/testframework_test.go +++ b/pkg/protocol/engine/consensus/blockgadget/testframework_test.go @@ -22,7 +22,6 @@ import ( "github.com/iotaledger/iota-core/pkg/storage/prunable/epochstore" "github.com/iotaledger/iota-core/pkg/storage/prunable/slotstore" iotago "github.com/iotaledger/iota.go/v4" - "github.com/iotaledger/iota.go/v4/api" "github.com/iotaledger/iota.go/v4/builder" "github.com/iotaledger/iota.go/v4/tpkg" ) @@ -43,7 +42,7 @@ func NewTestFramework(test *testing.T) *TestFramework { T: test, blocks: shrinkingmap.New[string, *blocks.Block](), - SeatManager: mock.NewManualPOA(api.SingleVersionProvider(tpkg.TestAPI), epochstore.NewStore(kvstore.Realm{}, mapdb.NewMapDB(), 0, (*account.Accounts).Bytes, account.AccountsFromBytes)), + SeatManager: mock.NewManualPOA(iotago.SingleVersionProvider(tpkg.TestAPI), epochstore.NewStore(kvstore.Realm{}, mapdb.NewMapDB(), 0, (*account.Accounts).Bytes, account.AccountsFromBytes)), } evictionState := eviction.NewState(mapdb.NewMapDB(), func(slot iotago.SlotIndex) (*slotstore.Store[iotago.BlockID, iotago.CommitmentID], error) { @@ -57,7 +56,7 @@ func NewTestFramework(test *testing.T) *TestFramework { return tpkg.TestAPI.ProtocolParameters().GenesisBlockID() }) - t.blockCache = blocks.New(evictionState, api.SingleVersionProvider(tpkg.TestAPI)) + t.blockCache = blocks.New(evictionState, iotago.SingleVersionProvider(tpkg.TestAPI)) instance := thresholdblockgadget.New(t.blockCache, t.SeatManager, func(err error) { fmt.Printf(">> Gadget.Error: %s\n", err) }) diff --git a/pkg/protocol/engine/eviction/state_test.go b/pkg/protocol/engine/eviction/state_test.go index 0bad76f27..5d77aa992 100644 --- a/pkg/protocol/engine/eviction/state_test.go +++ b/pkg/protocol/engine/eviction/state_test.go @@ -9,7 +9,6 @@ import ( "github.com/iotaledger/iota-core/pkg/storage/database" "github.com/iotaledger/iota-core/pkg/storage/prunable" iotago "github.com/iotaledger/iota.go/v4" - "github.com/iotaledger/iota.go/v4/api" "github.com/iotaledger/iota.go/v4/tpkg" ) @@ -20,7 +19,7 @@ func TestState_RootBlocks(t *testing.T) { prunableStorage := prunable.New(database.Config{ Engine: hivedb.EngineMapDB, Directory: t.TempDir(), - }, api.SingleVersionProvider(tpkg.TestAPI), errorHandler) + }, iotago.SingleVersionProvider(tpkg.TestAPI), errorHandler) ts := NewTestFramework(t, prunableStorage, eviction.NewState(mapdb.NewMapDB(), prunableStorage.RootBlocks, func() iotago.BlockID { return tpkg.TestAPI.ProtocolParameters().GenesisBlockID() diff --git a/pkg/protocol/engine/filter/blockfilter/filter_test.go b/pkg/protocol/engine/filter/blockfilter/filter_test.go index 2ab3aac3f..bde79f02e 100644 --- a/pkg/protocol/engine/filter/blockfilter/filter_test.go +++ b/pkg/protocol/engine/filter/blockfilter/filter_test.go @@ -14,7 +14,6 @@ import ( "github.com/iotaledger/iota-core/pkg/model" "github.com/iotaledger/iota-core/pkg/protocol/engine/filter" iotago "github.com/iotaledger/iota.go/v4" - "github.com/iotaledger/iota.go/v4/api" "github.com/iotaledger/iota.go/v4/builder" "github.com/iotaledger/iota.go/v4/tpkg" ) @@ -115,7 +114,7 @@ func TestFilter_WithMaxAllowedWallClockDrift(t *testing.T) { testAPI := tpkg.TestAPI tf := NewTestFramework(t, - api.SingleVersionProvider(testAPI), + iotago.SingleVersionProvider(testAPI), WithMaxAllowedWallClockDrift(allowedDrift), ) @@ -135,8 +134,8 @@ func TestFilter_WithMaxAllowedWallClockDrift(t *testing.T) { } func TestFilter_ProtocolVersion(t *testing.T) { - apiProvider := api.NewEpochBasedProvider( - api.WithAPIForMissingVersionCallback( + apiProvider := iotago.NewEpochBasedProvider( + iotago.WithAPIForMissingVersionCallback( func(params iotago.ProtocolParameters) (iotago.API, error) { return iotago.V3API(iotago.NewV3ProtocolParameters(iotago.WithVersion(params.Version()))), nil }, @@ -204,7 +203,7 @@ func TestFilter_ValidationBlocks(t *testing.T) { testAPI := tpkg.TestAPI tf := NewTestFramework(t, - api.SingleVersionProvider(testAPI), + iotago.SingleVersionProvider(testAPI), ) validatorAccountID := tpkg.RandAccountID() diff --git a/pkg/protocol/engine/mempool/v1/mempool_test.go b/pkg/protocol/engine/mempool/v1/mempool_test.go index 942a4cb09..db3c8ea89 100644 --- a/pkg/protocol/engine/mempool/v1/mempool_test.go +++ b/pkg/protocol/engine/mempool/v1/mempool_test.go @@ -21,7 +21,6 @@ import ( "github.com/iotaledger/iota-core/pkg/protocol/engine/mempool/conflictdag/conflictdagv1" mempooltests "github.com/iotaledger/iota-core/pkg/protocol/engine/mempool/tests" iotago "github.com/iotaledger/iota.go/v4" - "github.com/iotaledger/iota.go/v4/api" "github.com/iotaledger/iota.go/v4/tpkg" ) @@ -44,7 +43,7 @@ func TestMempoolV1_ResourceCleanup(t *testing.T) { conflictDAG := conflictdagv1.New[iotago.TransactionID, mempool.StateID, vote.MockedRank](func() int { return 0 }) memPoolInstance := New[vote.MockedRank](new(mempooltests.VM), func(reference mempool.StateReference) *promise.Promise[mempool.State] { return ledgerState.ResolveOutputState(reference) - }, mutationsFunc, workers, conflictDAG, api.SingleVersionProvider(tpkg.TestAPI), func(error) {}) + }, mutationsFunc, workers, conflictDAG, iotago.SingleVersionProvider(tpkg.TestAPI), func(error) {}) tf := mempooltests.NewTestFramework(t, memPoolInstance, conflictDAG, ledgerState, workers) @@ -153,7 +152,7 @@ func newTestFramework(t *testing.T) *mempooltests.TestFramework { return mempooltests.NewTestFramework(t, New[vote.MockedRank](new(mempooltests.VM), func(reference mempool.StateReference) *promise.Promise[mempool.State] { return ledgerState.ResolveOutputState(reference) - }, mutationsFunc, workers, conflictDAG, api.SingleVersionProvider(tpkg.TestAPI), func(error) {}), conflictDAG, ledgerState, workers) + }, mutationsFunc, workers, conflictDAG, iotago.SingleVersionProvider(tpkg.TestAPI), func(error) {}), conflictDAG, ledgerState, workers) } func newForkingTestFramework(t *testing.T) *mempooltests.TestFramework { @@ -168,5 +167,5 @@ func newForkingTestFramework(t *testing.T) *mempooltests.TestFramework { return mempooltests.NewTestFramework(t, New[vote.MockedRank](new(mempooltests.VM), func(reference mempool.StateReference) *promise.Promise[mempool.State] { return ledgerState.ResolveOutputState(reference) - }, mutationsFunc, workers, conflictDAG, api.SingleVersionProvider(tpkg.TestAPI), func(error) {}, WithForkAllTransactions[vote.MockedRank](true)), conflictDAG, ledgerState, workers) + }, mutationsFunc, workers, conflictDAG, iotago.SingleVersionProvider(tpkg.TestAPI), func(error) {}, WithForkAllTransactions[vote.MockedRank](true)), conflictDAG, ledgerState, workers) } diff --git a/pkg/protocol/engine/utxoledger/iteration_test.go b/pkg/protocol/engine/utxoledger/iteration_test.go index 968ed62b4..85fd8cf59 100644 --- a/pkg/protocol/engine/utxoledger/iteration_test.go +++ b/pkg/protocol/engine/utxoledger/iteration_test.go @@ -11,12 +11,11 @@ import ( "github.com/iotaledger/iota-core/pkg/protocol/engine/utxoledger/tpkg" "github.com/iotaledger/iota-core/pkg/utils" iotago "github.com/iotaledger/iota.go/v4" - "github.com/iotaledger/iota.go/v4/api" iotago_tpkg "github.com/iotaledger/iota.go/v4/tpkg" ) func TestUTXOComputeBalance(t *testing.T) { - manager := utxoledger.New(mapdb.NewMapDB(), api.SingleVersionProvider(iotago_tpkg.TestAPI)) + manager := utxoledger.New(mapdb.NewMapDB(), iotago.SingleVersionProvider(iotago_tpkg.TestAPI)) initialOutput := tpkg.RandLedgerStateOutputOnAddressWithAmount(iotago.OutputBasic, utils.RandAddress(iotago.AddressEd25519), 2_134_656_365) require.NoError(t, manager.AddGenesisUnspentOutput(initialOutput)) @@ -53,7 +52,7 @@ func TestUTXOComputeBalance(t *testing.T) { } func TestUTXOIteration(t *testing.T) { - manager := utxoledger.New(mapdb.NewMapDB(), api.SingleVersionProvider(iotago_tpkg.TestAPI)) + manager := utxoledger.New(mapdb.NewMapDB(), iotago.SingleVersionProvider(iotago_tpkg.TestAPI)) outputs := utxoledger.Outputs{ tpkg.RandLedgerStateOutputOnAddress(iotago.OutputBasic, utils.RandAddress(iotago.AddressEd25519)), diff --git a/pkg/protocol/engine/utxoledger/manager_test.go b/pkg/protocol/engine/utxoledger/manager_test.go index fe14c840e..1e046fc27 100644 --- a/pkg/protocol/engine/utxoledger/manager_test.go +++ b/pkg/protocol/engine/utxoledger/manager_test.go @@ -10,12 +10,11 @@ import ( "github.com/iotaledger/iota-core/pkg/protocol/engine/utxoledger" "github.com/iotaledger/iota-core/pkg/protocol/engine/utxoledger/tpkg" iotago "github.com/iotaledger/iota.go/v4" - "github.com/iotaledger/iota.go/v4/api" iotago_tpkg "github.com/iotaledger/iota.go/v4/tpkg" ) func TestConfirmationApplyAndRollbackToEmptyLedger(t *testing.T) { - manager := utxoledger.New(mapdb.NewMapDB(), api.SingleVersionProvider(iotago_tpkg.TestAPI)) + manager := utxoledger.New(mapdb.NewMapDB(), iotago.SingleVersionProvider(iotago_tpkg.TestAPI)) outputs := utxoledger.Outputs{ tpkg.RandLedgerStateOutputWithType(iotago.OutputBasic), @@ -89,7 +88,7 @@ func TestConfirmationApplyAndRollbackToEmptyLedger(t *testing.T) { } func TestConfirmationApplyAndRollbackToPreviousLedger(t *testing.T) { - manager := utxoledger.New(mapdb.NewMapDB(), api.SingleVersionProvider(iotago_tpkg.TestAPI)) + manager := utxoledger.New(mapdb.NewMapDB(), iotago.SingleVersionProvider(iotago_tpkg.TestAPI)) previousOutputs := utxoledger.Outputs{ tpkg.RandLedgerStateOutputWithType(iotago.OutputBasic), diff --git a/pkg/protocol/engine/utxoledger/output_test.go b/pkg/protocol/engine/utxoledger/output_test.go index d51af0013..0a90ad8ab 100644 --- a/pkg/protocol/engine/utxoledger/output_test.go +++ b/pkg/protocol/engine/utxoledger/output_test.go @@ -17,13 +17,12 @@ import ( "github.com/iotaledger/iota-core/pkg/protocol/engine/utxoledger/tpkg" "github.com/iotaledger/iota-core/pkg/utils" iotago "github.com/iotaledger/iota.go/v4" - "github.com/iotaledger/iota.go/v4/api" iotago_tpkg "github.com/iotaledger/iota.go/v4/tpkg" ) func AssertOutputUnspentAndSpentTransitions(t *testing.T, output *utxoledger.Output, spent *utxoledger.Spent) { outputID := output.OutputID() - manager := utxoledger.New(mapdb.NewMapDB(), api.SingleVersionProvider(iotago_tpkg.TestAPI)) + manager := utxoledger.New(mapdb.NewMapDB(), iotago.SingleVersionProvider(iotago_tpkg.TestAPI)) require.NoError(t, manager.AddGenesisUnspentOutput(output)) @@ -83,7 +82,7 @@ func CreateOutputAndAssertSerialization(t *testing.T, blockID iotago.BlockID, in require.NoError(t, err) iotagoAPI := iotago_tpkg.TestAPI - output := utxoledger.CreateOutput(api.SingleVersionProvider(iotagoAPI), outputID, blockID, indexBooked, iotaOutput, outputProof) + output := utxoledger.CreateOutput(iotago.SingleVersionProvider(iotagoAPI), outputID, blockID, indexBooked, iotaOutput, outputProof) outputBytes, err := iotagoAPI.Encode(output.Output()) require.NoError(t, err) proofBytes, err := outputProof.Bytes() diff --git a/pkg/protocol/engine/utxoledger/slot_diff_test.go b/pkg/protocol/engine/utxoledger/slot_diff_test.go index 095f05bda..f23feaa5d 100644 --- a/pkg/protocol/engine/utxoledger/slot_diff_test.go +++ b/pkg/protocol/engine/utxoledger/slot_diff_test.go @@ -15,7 +15,6 @@ import ( "github.com/iotaledger/iota-core/pkg/protocol/engine/utxoledger/tpkg" "github.com/iotaledger/iota-core/pkg/utils" iotago "github.com/iotaledger/iota.go/v4" - "github.com/iotaledger/iota.go/v4/api" iotago_tpkg "github.com/iotaledger/iota.go/v4/tpkg" ) @@ -40,7 +39,7 @@ func TestSimpleSlotDiffSerialization(t *testing.T) { outputProof, err := iotago.NewOutputIDProof(iotago_tpkg.TestAPI, txID.Identifier(), txID.Slot(), iotago.TxEssenceOutputs{iotaOutput}, 0) require.NoError(t, err) - output := utxoledger.CreateOutput(api.SingleVersionProvider(iotago_tpkg.TestAPI), outputID, blockID, indexBooked, iotaOutput, outputProof) + output := utxoledger.CreateOutput(iotago.SingleVersionProvider(iotago_tpkg.TestAPI), outputID, blockID, indexBooked, iotaOutput, outputProof) transactionIDSpent := utils.RandTransactionID() @@ -65,7 +64,7 @@ func TestSimpleSlotDiffSerialization(t *testing.T) { } func TestSlotDiffSerialization(t *testing.T) { - manager := utxoledger.New(mapdb.NewMapDB(), api.SingleVersionProvider(iotago_tpkg.TestAPI)) + manager := utxoledger.New(mapdb.NewMapDB(), iotago.SingleVersionProvider(iotago_tpkg.TestAPI)) outputs := utxoledger.Outputs{ tpkg.RandLedgerStateOutputWithType(iotago.OutputBasic), diff --git a/pkg/protocol/engine/utxoledger/snapshot_test.go b/pkg/protocol/engine/utxoledger/snapshot_test.go index 4f24112bc..5411094f6 100644 --- a/pkg/protocol/engine/utxoledger/snapshot_test.go +++ b/pkg/protocol/engine/utxoledger/snapshot_test.go @@ -15,7 +15,6 @@ import ( "github.com/iotaledger/iota-core/pkg/protocol/engine/utxoledger/tpkg" "github.com/iotaledger/iota-core/pkg/utils" iotago "github.com/iotaledger/iota.go/v4" - "github.com/iotaledger/iota.go/v4/api" iotago_tpkg "github.com/iotaledger/iota.go/v4/tpkg" ) @@ -34,7 +33,7 @@ func TestOutput_SnapshotBytes(t *testing.T) { proofBytes, err := proof.Bytes() require.NoError(t, err) - output := utxoledger.NewOutput(api.SingleVersionProvider(iotago_tpkg.TestAPI), outputID, blockID, slotBooked, iotaOutput, iotaOutputBytes, proof, proofBytes) + output := utxoledger.NewOutput(iotago.SingleVersionProvider(iotago_tpkg.TestAPI), outputID, blockID, slotBooked, iotaOutput, iotaOutputBytes, proof, proofBytes) snapshotBytes := output.SnapshotBytes() @@ -68,11 +67,11 @@ func TestOutputFromSnapshotReader(t *testing.T) { outputProofBytes, err := outputProof.Bytes() require.NoError(t, err) - output := utxoledger.NewOutput(api.SingleVersionProvider(iotago_tpkg.TestAPI), outputID, blockID, slotBooked, iotaOutput, iotaOutputBytes, outputProof, outputProofBytes) + output := utxoledger.NewOutput(iotago.SingleVersionProvider(iotago_tpkg.TestAPI), outputID, blockID, slotBooked, iotaOutput, iotaOutputBytes, outputProof, outputProofBytes) snapshotBytes := output.SnapshotBytes() buf := bytes.NewReader(snapshotBytes) - readOutput, err := utxoledger.OutputFromSnapshotReader(buf, api.SingleVersionProvider(iotago_tpkg.TestAPI)) + readOutput, err := utxoledger.OutputFromSnapshotReader(buf, iotago.SingleVersionProvider(iotago_tpkg.TestAPI)) require.NoError(t, err) require.Equal(t, output, readOutput) @@ -92,7 +91,7 @@ func TestSpent_SnapshotBytes(t *testing.T) { outputProofBytes, err := outputProof.Bytes() require.NoError(t, err) - output := utxoledger.NewOutput(api.SingleVersionProvider(iotago_tpkg.TestAPI), outputID, blockID, slotBooked, iotaOutput, iotaOutputBytes, outputProof, outputProofBytes) + output := utxoledger.NewOutput(iotago.SingleVersionProvider(iotago_tpkg.TestAPI), outputID, blockID, slotBooked, iotaOutput, iotaOutputBytes, outputProof, outputProofBytes) outputSnapshotBytes := output.SnapshotBytes() transactionID := utils.RandTransactionID() @@ -121,7 +120,7 @@ func TestSpentFromSnapshotReader(t *testing.T) { outputProofBytes, err := outputProof.Bytes() require.NoError(t, err) - output := utxoledger.NewOutput(api.SingleVersionProvider(iotago_tpkg.TestAPI), outputID, blockID, slotBooked, iotaOutput, iotaOutputBytes, outputProof, outputProofBytes) + output := utxoledger.NewOutput(iotago.SingleVersionProvider(iotago_tpkg.TestAPI), outputID, blockID, slotBooked, iotaOutput, iotaOutputBytes, outputProof, outputProofBytes) transactionID := utils.RandTransactionID() slotSpent := utils.RandSlotIndex() @@ -130,7 +129,7 @@ func TestSpentFromSnapshotReader(t *testing.T) { snapshotBytes := spent.SnapshotBytes() buf := bytes.NewReader(snapshotBytes) - readSpent, err := utxoledger.SpentFromSnapshotReader(buf, api.SingleVersionProvider(iotago_tpkg.TestAPI), slotSpent) + readSpent, err := utxoledger.SpentFromSnapshotReader(buf, iotago.SingleVersionProvider(iotago_tpkg.TestAPI), slotSpent) require.NoError(t, err) require.Equal(t, spent, readSpent) @@ -156,7 +155,7 @@ func TestReadSlotDiffToSnapshotReader(t *testing.T) { require.NoError(t, err) reader := writer.Reader() - readSlotDiff, err := utxoledger.ReadSlotDiffToSnapshotReader(reader, api.SingleVersionProvider(iotago_tpkg.TestAPI)) + readSlotDiff, err := utxoledger.ReadSlotDiffToSnapshotReader(reader, iotago.SingleVersionProvider(iotago_tpkg.TestAPI)) require.NoError(t, err) require.Equal(t, slotDiff.Slot, readSlotDiff.Slot) @@ -195,7 +194,7 @@ func TestWriteSlotDiffToSnapshotWriter(t *testing.T) { var snapshotOutputs utxoledger.Outputs for i := 0; i < len(slotDiff.Outputs); i++ { - readOutput, err := utxoledger.OutputFromSnapshotReader(reader, api.SingleVersionProvider(iotago_tpkg.TestAPI)) + readOutput, err := utxoledger.OutputFromSnapshotReader(reader, iotago.SingleVersionProvider(iotago_tpkg.TestAPI)) require.NoError(t, err) snapshotOutputs = append(snapshotOutputs, readOutput) } @@ -208,7 +207,7 @@ func TestWriteSlotDiffToSnapshotWriter(t *testing.T) { var snapshotSpents utxoledger.Spents for i := 0; i < len(slotDiff.Spents); i++ { - readSpent, err := utxoledger.SpentFromSnapshotReader(reader, api.SingleVersionProvider(iotago_tpkg.TestAPI), readSlot) + readSpent, err := utxoledger.SpentFromSnapshotReader(reader, iotago.SingleVersionProvider(iotago_tpkg.TestAPI), readSlot) require.NoError(t, err) snapshotSpents = append(snapshotSpents, readSpent) } @@ -218,7 +217,7 @@ func TestWriteSlotDiffToSnapshotWriter(t *testing.T) { func TestManager_Import(t *testing.T) { mapDB := mapdb.NewMapDB() - manager := utxoledger.New(mapDB, api.SingleVersionProvider(iotago_tpkg.TestAPI)) + manager := utxoledger.New(mapDB, iotago.SingleVersionProvider(iotago_tpkg.TestAPI)) output1 := tpkg.RandLedgerStateOutput() @@ -272,7 +271,7 @@ func TestManager_Import(t *testing.T) { reader := writer.Reader() - importedSlot2 := utxoledger.New(mapdb.NewMapDB(), api.SingleVersionProvider(iotago_tpkg.TestAPI)) + importedSlot2 := utxoledger.New(mapdb.NewMapDB(), iotago.SingleVersionProvider(iotago_tpkg.TestAPI)) require.NoError(t, importedSlot2.Import(reader)) require.Equal(t, iotago.SlotIndex(2), lo.PanicOnErr(importedSlot2.ReadLedgerSlot())) @@ -286,10 +285,10 @@ func TestManager_Import(t *testing.T) { reader := writer.Reader() - importedSlot1 := utxoledger.New(mapdb.NewMapDB(), api.SingleVersionProvider(iotago_tpkg.TestAPI)) + importedSlot1 := utxoledger.New(mapdb.NewMapDB(), iotago.SingleVersionProvider(iotago_tpkg.TestAPI)) require.NoError(t, importedSlot1.Import(reader)) - managerAtSlot1 := utxoledger.New(mapDBAtSlot1, api.SingleVersionProvider(iotago_tpkg.TestAPI)) + managerAtSlot1 := utxoledger.New(mapDBAtSlot1, iotago.SingleVersionProvider(iotago_tpkg.TestAPI)) require.Equal(t, iotago.SlotIndex(1), lo.PanicOnErr(importedSlot1.ReadLedgerSlot())) require.Equal(t, iotago.SlotIndex(1), lo.PanicOnErr(managerAtSlot1.ReadLedgerSlot())) @@ -303,10 +302,10 @@ func TestManager_Import(t *testing.T) { reader := writer.Reader() - importedSlot0 := utxoledger.New(mapdb.NewMapDB(), api.SingleVersionProvider(iotago_tpkg.TestAPI)) + importedSlot0 := utxoledger.New(mapdb.NewMapDB(), iotago.SingleVersionProvider(iotago_tpkg.TestAPI)) require.NoError(t, importedSlot0.Import(reader)) - managerAtSlot0 := utxoledger.New(mapDBAtSlot0, api.SingleVersionProvider(iotago_tpkg.TestAPI)) + managerAtSlot0 := utxoledger.New(mapDBAtSlot0, iotago.SingleVersionProvider(iotago_tpkg.TestAPI)) require.Equal(t, iotago.SlotIndex(0), lo.PanicOnErr(importedSlot0.ReadLedgerSlot())) require.Equal(t, iotago.SlotIndex(0), lo.PanicOnErr(managerAtSlot0.ReadLedgerSlot())) @@ -316,7 +315,7 @@ func TestManager_Import(t *testing.T) { func TestManager_Export(t *testing.T) { mapDB := mapdb.NewMapDB() - manager := utxoledger.New(mapDB, api.SingleVersionProvider(iotago_tpkg.TestAPI)) + manager := utxoledger.New(mapDB, iotago.SingleVersionProvider(iotago_tpkg.TestAPI)) output1 := tpkg.RandLedgerStateOutput() @@ -369,7 +368,7 @@ func TestManager_Export(t *testing.T) { var snapshotOutputs utxoledger.Outputs for i := uint64(0); i < outputCount; i++ { - output, err := utxoledger.OutputFromSnapshotReader(reader, api.SingleVersionProvider(iotago_tpkg.TestAPI)) + output, err := utxoledger.OutputFromSnapshotReader(reader, iotago.SingleVersionProvider(iotago_tpkg.TestAPI)) require.NoError(t, err) snapshotOutputs = append(snapshotOutputs, output) } @@ -402,7 +401,7 @@ func TestManager_Export(t *testing.T) { var snapshotOutputs utxoledger.Outputs for i := uint64(0); i < outputCount; i++ { - output, err := utxoledger.OutputFromSnapshotReader(reader, api.SingleVersionProvider(iotago_tpkg.TestAPI)) + output, err := utxoledger.OutputFromSnapshotReader(reader, iotago.SingleVersionProvider(iotago_tpkg.TestAPI)) require.NoError(t, err) snapshotOutputs = append(snapshotOutputs, output) } @@ -417,7 +416,7 @@ func TestManager_Export(t *testing.T) { require.Equal(t, uint32(1), slotDiffCount) for i := uint32(0); i < slotDiffCount; i++ { - diff, err := utxoledger.ReadSlotDiffToSnapshotReader(reader, api.SingleVersionProvider(iotago_tpkg.TestAPI)) + diff, err := utxoledger.ReadSlotDiffToSnapshotReader(reader, iotago.SingleVersionProvider(iotago_tpkg.TestAPI)) require.NoError(t, err) require.Equal(t, snapshotLedgerSlot-iotago.SlotIndex(i), diff.Slot) } @@ -440,7 +439,7 @@ func TestManager_Export(t *testing.T) { var snapshotOutputs utxoledger.Outputs for i := uint64(0); i < outputCount; i++ { - output, err := utxoledger.OutputFromSnapshotReader(reader, api.SingleVersionProvider(iotago_tpkg.TestAPI)) + output, err := utxoledger.OutputFromSnapshotReader(reader, iotago.SingleVersionProvider(iotago_tpkg.TestAPI)) require.NoError(t, err) snapshotOutputs = append(snapshotOutputs, output) } @@ -455,7 +454,7 @@ func TestManager_Export(t *testing.T) { require.Equal(t, uint32(2), slotDiffCount) for i := uint32(0); i < slotDiffCount; i++ { - diff, err := utxoledger.ReadSlotDiffToSnapshotReader(reader, api.SingleVersionProvider(iotago_tpkg.TestAPI)) + diff, err := utxoledger.ReadSlotDiffToSnapshotReader(reader, iotago.SingleVersionProvider(iotago_tpkg.TestAPI)) require.NoError(t, err) require.Equal(t, snapshotLedgerSlot-iotago.SlotIndex(i), diff.Slot) } diff --git a/pkg/protocol/engine/utxoledger/tpkg/random.go b/pkg/protocol/engine/utxoledger/tpkg/random.go index e8929f967..3df1f7e87 100644 --- a/pkg/protocol/engine/utxoledger/tpkg/random.go +++ b/pkg/protocol/engine/utxoledger/tpkg/random.go @@ -5,7 +5,6 @@ import ( "github.com/iotaledger/iota-core/pkg/protocol/engine/utxoledger" "github.com/iotaledger/iota-core/pkg/utils" iotago "github.com/iotaledger/iota.go/v4" - "github.com/iotaledger/iota.go/v4/api" "github.com/iotaledger/iota.go/v4/tpkg" ) @@ -18,7 +17,7 @@ func RandLedgerStateOutputWithOutput(output iotago.Output) *utxoledger.Output { txID := utils.RandTransactionID() proof := lo.PanicOnErr(iotago.NewOutputIDProof(tpkg.TestAPI, txID.Identifier(), txID.Slot(), outputs, 0)) - return utxoledger.CreateOutput(api.SingleVersionProvider(tpkg.TestAPI), utils.RandOutputID(), utils.RandBlockID(), utils.RandSlotIndex(), outputs[0], proof) + return utxoledger.CreateOutput(iotago.SingleVersionProvider(tpkg.TestAPI), utils.RandOutputID(), utils.RandBlockID(), utils.RandSlotIndex(), outputs[0], proof) } func RandLedgerStateOutputWithType(outputType iotago.OutputType) *utxoledger.Output { diff --git a/pkg/protocol/sybilprotection/seatmanager/topstakers/topstakers_test.go b/pkg/protocol/sybilprotection/seatmanager/topstakers/topstakers_test.go index 83141789c..53a49290a 100644 --- a/pkg/protocol/sybilprotection/seatmanager/topstakers/topstakers_test.go +++ b/pkg/protocol/sybilprotection/seatmanager/topstakers/topstakers_test.go @@ -17,7 +17,6 @@ import ( "github.com/iotaledger/iota-core/pkg/protocol/sybilprotection/seatmanager" "github.com/iotaledger/iota-core/pkg/storage/prunable/epochstore" iotago "github.com/iotaledger/iota.go/v4" - "github.com/iotaledger/iota.go/v4/api" "github.com/iotaledger/iota.go/v4/tpkg" ) @@ -34,7 +33,7 @@ func TestTopStakers_InitializeCommittee(t *testing.T) { committeeStore := epochstore.NewStore(kvstore.Realm{}, mapdb.NewMapDB(), 0, (*account.Accounts).Bytes, account.AccountsFromBytes) topStakersSeatManager := &SeatManager{ - apiProvider: api.SingleVersionProvider(testAPI), + apiProvider: iotago.SingleVersionProvider(testAPI), committeeStore: committeeStore, events: seatmanager.NewEvents(), activityTracker: activitytrackerv1.NewActivityTracker(time.Second * 30), @@ -88,7 +87,7 @@ func TestTopStakers_RotateCommittee(t *testing.T) { committeeStore := epochstore.NewStore(kvstore.Realm{}, mapdb.NewMapDB(), 0, (*account.Accounts).Bytes, account.AccountsFromBytes) s := &SeatManager{ - apiProvider: api.SingleVersionProvider(testAPI), + apiProvider: iotago.SingleVersionProvider(testAPI), committeeStore: committeeStore, events: seatmanager.NewEvents(), activityTracker: activitytrackerv1.NewActivityTracker(time.Second * 30), diff --git a/pkg/protocol/sybilprotection/sybilprotection.go b/pkg/protocol/sybilprotection/sybilprotection.go index 0968ec425..147e8580c 100644 --- a/pkg/protocol/sybilprotection/sybilprotection.go +++ b/pkg/protocol/sybilprotection/sybilprotection.go @@ -8,13 +8,13 @@ import ( "github.com/iotaledger/iota-core/pkg/protocol/engine/blocks" "github.com/iotaledger/iota-core/pkg/protocol/sybilprotection/seatmanager" iotago "github.com/iotaledger/iota.go/v4" - "github.com/iotaledger/iota.go/v4/nodeclient/apimodels" + "github.com/iotaledger/iota.go/v4/api" ) type SybilProtection interface { TrackBlock(block *blocks.Block) EligibleValidators(epoch iotago.EpochIndex) (accounts.AccountsData, error) - OrderedRegisteredCandidateValidatorsList(epoch iotago.EpochIndex) ([]*apimodels.ValidatorResponse, error) + OrderedRegisteredCandidateValidatorsList(epoch iotago.EpochIndex) ([]*api.ValidatorResponse, error) IsCandidateActive(validatorID iotago.AccountID, epoch iotago.EpochIndex) (bool, error) // ValidatorReward returns the amount of mana that a validator has earned in a given epoch range. // The actual used epoch range is returned, only until usedEnd the decay was applied. diff --git a/pkg/protocol/sybilprotection/sybilprotectionv1/performance/testsuite_test.go b/pkg/protocol/sybilprotection/sybilprotectionv1/performance/testsuite_test.go index 50734ac06..9d4d3211d 100644 --- a/pkg/protocol/sybilprotection/sybilprotectionv1/performance/testsuite_test.go +++ b/pkg/protocol/sybilprotection/sybilprotectionv1/performance/testsuite_test.go @@ -15,7 +15,6 @@ import ( "github.com/iotaledger/iota-core/pkg/storage/prunable/epochstore" "github.com/iotaledger/iota-core/pkg/storage/prunable/slotstore" iotago "github.com/iotaledger/iota.go/v4" - "github.com/iotaledger/iota.go/v4/api" "github.com/iotaledger/iota.go/v4/tpkg" ) @@ -80,7 +79,7 @@ func (t *TestSuite) InitPerformanceTracker() { committeeCandidatesStore.GetEpoch, performanceFactorFunc, t.latestCommittedEpoch, - api.SingleVersionProvider(t.api), + iotago.SingleVersionProvider(t.api), func(err error) {}, ) } diff --git a/pkg/protocol/sybilprotection/sybilprotectionv1/sybilprotection.go b/pkg/protocol/sybilprotection/sybilprotectionv1/sybilprotection.go index f99050243..649ff5663 100644 --- a/pkg/protocol/sybilprotection/sybilprotectionv1/sybilprotection.go +++ b/pkg/protocol/sybilprotection/sybilprotectionv1/sybilprotection.go @@ -21,7 +21,7 @@ import ( "github.com/iotaledger/iota-core/pkg/protocol/sybilprotection/seatmanager/topstakers" "github.com/iotaledger/iota-core/pkg/protocol/sybilprotection/sybilprotectionv1/performance" iotago "github.com/iotaledger/iota.go/v4" - "github.com/iotaledger/iota.go/v4/nodeclient/apimodels" + "github.com/iotaledger/iota.go/v4/api" ) type SybilProtection struct { @@ -327,7 +327,7 @@ func (o *SybilProtection) EligibleValidators(epoch iotago.EpochIndex) (accounts. } // OrderedRegisteredCandidateValidatorsList returns the currently known list of registered validator candidates for the given epoch. -func (o *SybilProtection) OrderedRegisteredCandidateValidatorsList(epoch iotago.EpochIndex) ([]*apimodels.ValidatorResponse, error) { +func (o *SybilProtection) OrderedRegisteredCandidateValidatorsList(epoch iotago.EpochIndex) ([]*api.ValidatorResponse, error) { candidates, err := o.performanceTracker.ValidatorCandidates(epoch) if err != nil { return nil, ierrors.Wrapf(err, "failed to retrieve candidates") @@ -338,7 +338,7 @@ func (o *SybilProtection) OrderedRegisteredCandidateValidatorsList(epoch iotago. return nil, ierrors.Wrapf(err, "failed to retrieve eligible candidates") } - validatorResp := make([]*apimodels.ValidatorResponse, 0, candidates.Size()) + validatorResp := make([]*api.ValidatorResponse, 0, candidates.Size()) if err := candidates.ForEach(func(candidate iotago.AccountID) error { accountData, exists, err := o.ledger.Account(candidate, o.lastCommittedSlot) if err != nil { @@ -352,7 +352,7 @@ func (o *SybilProtection) OrderedRegisteredCandidateValidatorsList(epoch iotago. return nil } active := activeCandidates.Has(candidate) - validatorResp = append(validatorResp, &apimodels.ValidatorResponse{ + validatorResp = append(validatorResp, &api.ValidatorResponse{ AddressBech32: accountData.ID.ToAddress().Bech32(o.apiProvider.CommittedAPI().ProtocolParameters().Bech32HRP()), StakingEpochEnd: accountData.StakeEndEpoch, PoolStake: accountData.ValidatorStake + accountData.DelegationStake, diff --git a/pkg/restapi/restapi.go b/pkg/restapi/restapi.go index 4c7f3de96..39afa8b29 100644 --- a/pkg/restapi/restapi.go +++ b/pkg/restapi/restapi.go @@ -6,33 +6,10 @@ import ( "github.com/iotaledger/hive.go/ierrors" "github.com/iotaledger/inx-app/pkg/httpserver" + "github.com/iotaledger/iota.go/v4/api" ) const ( - // ParameterBlockID is used to identify a block by its ID. - ParameterBlockID = "blockID" - - // ParameterTransactionID is used to identify a transaction by its ID. - ParameterTransactionID = "transactionID" - - // ParameterOutputID is used to identify an output by its ID. - ParameterOutputID = "outputID" - - // ParameterSlotIndex is used to identify a slot by index. - ParameterSlotIndex = "slotIndex" - - // ParameterEpochIndex is used to identify an epoch by index. - ParameterEpochIndex = "epochIndex" - - // ParameterCommitmentID is used to identify a slot commitment by its ID. - ParameterCommitmentID = "commitmentID" - - // ParameterBech32Address is used to to represent bech32 address. - ParameterBech32Address = "bech32Address" - - // ParameterPeerID is used to identify a peer. - ParameterPeerID = "peerID" - // QueryParameterPageSize is used to specify the page size. QueryParameterPageSize = "pageSize" @@ -41,7 +18,7 @@ const ( ) func ParsePeerIDParam(c echo.Context) (peer.ID, error) { - peerID, err := peer.Decode(c.Param(ParameterPeerID)) + peerID, err := peer.Decode(c.Param(api.ParameterPeerID)) if err != nil { return "", ierrors.Wrapf(httpserver.ErrInvalidParameter, "invalid peerID, error: %s", err) } diff --git a/pkg/retainer/block_metadata.go b/pkg/retainer/block_metadata.go index e829045fe..6d523f527 100644 --- a/pkg/retainer/block_metadata.go +++ b/pkg/retainer/block_metadata.go @@ -2,26 +2,26 @@ package retainer import ( iotago "github.com/iotaledger/iota.go/v4" - "github.com/iotaledger/iota.go/v4/nodeclient/apimodels" + "github.com/iotaledger/iota.go/v4/api" ) type BlockMetadata struct { BlockID iotago.BlockID - BlockState apimodels.BlockState - BlockFailureReason apimodels.BlockFailureReason - TransactionState apimodels.TransactionState - TransactionFailureReason apimodels.TransactionFailureReason + BlockState api.BlockState + BlockFailureReason api.BlockFailureReason + TransactionState api.TransactionState + TransactionFailureReason api.TransactionFailureReason } -func (b *BlockMetadata) BlockMetadataResponse() *apimodels.BlockMetadataResponse { - response := &apimodels.BlockMetadataResponse{ +func (b *BlockMetadata) BlockMetadataResponse() *api.BlockMetadataResponse { + response := &api.BlockMetadataResponse{ BlockID: b.BlockID, BlockState: b.BlockState.String(), BlockFailureReason: b.BlockFailureReason, TransactionFailureReason: b.TransactionFailureReason, } - if b.TransactionState != apimodels.TransactionStateNoTransaction { + if b.TransactionState != api.TransactionStateNoTransaction { response.TransactionState = b.TransactionState.String() } diff --git a/pkg/retainer/retainer.go b/pkg/retainer/retainer.go index ffcf24502..411e3c323 100644 --- a/pkg/retainer/retainer.go +++ b/pkg/retainer/retainer.go @@ -3,17 +3,17 @@ package retainer import ( "github.com/iotaledger/hive.go/runtime/module" iotago "github.com/iotaledger/iota.go/v4" - "github.com/iotaledger/iota.go/v4/nodeclient/apimodels" + "github.com/iotaledger/iota.go/v4/api" ) // Retainer keeps and resolves all the information needed in the API and INX. type Retainer interface { BlockMetadata(blockID iotago.BlockID) (*BlockMetadata, error) - RegisteredValidatorsCache(uint32) ([]*apimodels.ValidatorResponse, bool) - RetainRegisteredValidatorsCache(uint32, []*apimodels.ValidatorResponse) + RegisteredValidatorsCache(uint32) ([]*api.ValidatorResponse, bool) + RetainRegisteredValidatorsCache(uint32, []*api.ValidatorResponse) - RetainBlockFailure(iotago.BlockID, apimodels.BlockFailureReason) + RetainBlockFailure(iotago.BlockID, api.BlockFailureReason) RetainTransactionFailure(iotago.BlockID, error) // Reset resets the component to a clean state as if it was created at the last commitment. diff --git a/pkg/retainer/retainer/errors.go b/pkg/retainer/retainer/errors.go index 88d9594f6..ffb2fb7d0 100644 --- a/pkg/retainer/retainer/errors.go +++ b/pkg/retainer/retainer/errors.go @@ -3,81 +3,81 @@ package retainer import ( "github.com/iotaledger/hive.go/ierrors" iotago "github.com/iotaledger/iota.go/v4" - "github.com/iotaledger/iota.go/v4/nodeclient/apimodels" + "github.com/iotaledger/iota.go/v4/api" ) -var blocksErrorsFailureReasonMap = map[error]apimodels.BlockFailureReason{ - iotago.ErrIssuerAccountNotFound: apimodels.BlockFailureIssuerAccountNotFound, - iotago.ErrBurnedInsufficientMana: apimodels.BlockFailureBurnedInsufficientMana, - iotago.ErrBlockVersionInvalid: apimodels.BlockFailureVersionInvalid, - iotago.ErrRMCNotFound: apimodels.BlockFailureAccountInvalid, - iotago.ErrFailedToCalculateManaCost: apimodels.BlockFailureManaCostCalculationFailed, - iotago.ErrNegativeBIC: apimodels.BlockFailureAccountInvalid, - iotago.ErrAccountExpired: apimodels.BlockFailureAccountInvalid, - iotago.ErrInvalidSignature: apimodels.BlockFailureSignatureInvalid, +var blocksErrorsFailureReasonMap = map[error]api.BlockFailureReason{ + iotago.ErrIssuerAccountNotFound: api.BlockFailureIssuerAccountNotFound, + iotago.ErrBurnedInsufficientMana: api.BlockFailureBurnedInsufficientMana, + iotago.ErrBlockVersionInvalid: api.BlockFailureVersionInvalid, + iotago.ErrRMCNotFound: api.BlockFailureAccountInvalid, + iotago.ErrFailedToCalculateManaCost: api.BlockFailureManaCostCalculationFailed, + iotago.ErrNegativeBIC: api.BlockFailureAccountInvalid, + iotago.ErrAccountExpired: api.BlockFailureAccountInvalid, + iotago.ErrInvalidSignature: api.BlockFailureSignatureInvalid, } -func determineBlockFailureReason(err error) apimodels.BlockFailureReason { +func determineBlockFailureReason(err error) api.BlockFailureReason { for errKey, failureReason := range blocksErrorsFailureReasonMap { if ierrors.Is(err, errKey) { return failureReason } } // use most general failure reason - return apimodels.BlockFailureInvalid + return api.BlockFailureInvalid } -var txErrorsFailureReasonMap = map[error]apimodels.TransactionFailureReason{ +var txErrorsFailureReasonMap = map[error]api.TransactionFailureReason{ // unknown type / type casting errors - iotago.ErrTxTypeInvalid: apimodels.TxFailureTxTypeInvalid, - iotago.ErrUnknownInputType: apimodels.TxFailureUTXOInputInvalid, - iotago.ErrUTXOInputInvalid: apimodels.TxFailureUTXOInputInvalid, - iotago.ErrUnknownOutputType: apimodels.TxFailureUTXOInputInvalid, - iotago.ErrBICInputInvalid: apimodels.TxFailureBICInputInvalid, - iotago.ErrRewardInputInvalid: apimodels.TxFailureRewardInputInvalid, - iotago.ErrCommitmentInputMissing: apimodels.TxFailureCommitmentInputInvalid, - iotago.ErrCommitmentInputInvalid: apimodels.TxFailureCommitmentInputInvalid, - iotago.ErrUnlockBlockSignatureInvalid: apimodels.TxFailureUnlockBlockSignatureInvalid, + iotago.ErrTxTypeInvalid: api.TxFailureTxTypeInvalid, + iotago.ErrUnknownInputType: api.TxFailureUTXOInputInvalid, + iotago.ErrUTXOInputInvalid: api.TxFailureUTXOInputInvalid, + iotago.ErrUnknownOutputType: api.TxFailureUTXOInputInvalid, + iotago.ErrBICInputInvalid: api.TxFailureBICInputInvalid, + iotago.ErrRewardInputInvalid: api.TxFailureRewardInputInvalid, + iotago.ErrCommitmentInputMissing: api.TxFailureCommitmentInputInvalid, + iotago.ErrCommitmentInputInvalid: api.TxFailureCommitmentInputInvalid, + iotago.ErrUnlockBlockSignatureInvalid: api.TxFailureUnlockBlockSignatureInvalid, // context inputs errors - iotago.ErrNoStakingFeature: apimodels.TxFailureNoStakingFeature, - iotago.ErrFailedToClaimStakingReward: apimodels.TxFailureFailedToClaimStakingReward, - iotago.ErrFailedToClaimDelegationReward: apimodels.TxFailureFailedToClaimDelegationReward, + iotago.ErrNoStakingFeature: api.TxFailureNoStakingFeature, + iotago.ErrFailedToClaimStakingReward: api.TxFailureFailedToClaimStakingReward, + iotago.ErrFailedToClaimDelegationReward: api.TxFailureFailedToClaimDelegationReward, // UTXO errors - iotago.ErrTxConflicting: apimodels.TxFailureConflicting, - iotago.ErrInputAlreadySpent: apimodels.TxFailureUTXOInputAlreadySpent, + iotago.ErrTxConflicting: api.TxFailureConflicting, + iotago.ErrInputAlreadySpent: api.TxFailureUTXOInputAlreadySpent, // native token errors - iotago.ErrNativeTokenSetInvalid: apimodels.TxFailureGivenNativeTokensInvalid, - iotago.ErrNativeTokenSumUnbalanced: apimodels.TxFailureGivenNativeTokensInvalid, + iotago.ErrNativeTokenSetInvalid: api.TxFailureGivenNativeTokensInvalid, + iotago.ErrNativeTokenSumUnbalanced: api.TxFailureGivenNativeTokensInvalid, // vm errors - iotago.ErrInputOutputSumMismatch: apimodels.TxFailureSumOfInputAndOutputValuesDoesNotMatch, - iotago.ErrTimelockNotExpired: apimodels.TxFailureConfiguredTimelockNotYetExpired, - iotago.ErrReturnAmountNotFulFilled: apimodels.TxFailureReturnAmountNotFulfilled, - iotago.ErrInvalidInputUnlock: apimodels.TxFailureInputUnlockInvalid, - iotago.ErrSenderFeatureNotUnlocked: apimodels.TxFailureSenderNotUnlocked, - iotago.ErrChainTransitionInvalid: apimodels.TxFailureChainStateTransitionInvalid, - iotago.ErrInputOutputManaMismatch: apimodels.TxFailureManaAmountInvalid, - iotago.ErrManaAmountInvalid: apimodels.TxFailureManaAmountInvalid, - iotago.ErrInputCreationAfterTxCreation: apimodels.TxFailureInputCreationAfterTxCreation, + iotago.ErrInputOutputSumMismatch: api.TxFailureSumOfInputAndOutputValuesDoesNotMatch, + iotago.ErrTimelockNotExpired: api.TxFailureConfiguredTimelockNotYetExpired, + iotago.ErrReturnAmountNotFulFilled: api.TxFailureReturnAmountNotFulfilled, + iotago.ErrInvalidInputUnlock: api.TxFailureInputUnlockInvalid, + iotago.ErrSenderFeatureNotUnlocked: api.TxFailureSenderNotUnlocked, + iotago.ErrChainTransitionInvalid: api.TxFailureChainStateTransitionInvalid, + iotago.ErrInputOutputManaMismatch: api.TxFailureManaAmountInvalid, + iotago.ErrManaAmountInvalid: api.TxFailureManaAmountInvalid, + iotago.ErrInputCreationAfterTxCreation: api.TxFailureInputCreationAfterTxCreation, // tx capabilities errors - iotago.ErrTxCapabilitiesNativeTokenBurningNotAllowed: apimodels.TxFailureCapabilitiesNativeTokenBurningNotAllowed, - iotago.ErrTxCapabilitiesManaBurningNotAllowed: apimodels.TxFailureCapabilitiesManaBurningNotAllowed, - iotago.ErrTxCapabilitiesAccountDestructionNotAllowed: apimodels.TxFailureCapabilitiesAccountDestructionNotAllowed, - iotago.ErrTxCapabilitiesAnchorDestructionNotAllowed: apimodels.TxFailureCapabilitiesAnchorDestructionNotAllowed, - iotago.ErrTxCapabilitiesFoundryDestructionNotAllowed: apimodels.TxFailureCapabilitiesFoundryDestructionNotAllowed, - iotago.ErrTxCapabilitiesNFTDestructionNotAllowed: apimodels.TxFailureCapabilitiesNFTDestructionNotAllowed, + iotago.ErrTxCapabilitiesNativeTokenBurningNotAllowed: api.TxFailureCapabilitiesNativeTokenBurningNotAllowed, + iotago.ErrTxCapabilitiesManaBurningNotAllowed: api.TxFailureCapabilitiesManaBurningNotAllowed, + iotago.ErrTxCapabilitiesAccountDestructionNotAllowed: api.TxFailureCapabilitiesAccountDestructionNotAllowed, + iotago.ErrTxCapabilitiesAnchorDestructionNotAllowed: api.TxFailureCapabilitiesAnchorDestructionNotAllowed, + iotago.ErrTxCapabilitiesFoundryDestructionNotAllowed: api.TxFailureCapabilitiesFoundryDestructionNotAllowed, + iotago.ErrTxCapabilitiesNFTDestructionNotAllowed: api.TxFailureCapabilitiesNFTDestructionNotAllowed, } -func determineTxFailureReason(err error) apimodels.TransactionFailureReason { +func determineTxFailureReason(err error) api.TransactionFailureReason { for errKey, failureReason := range txErrorsFailureReasonMap { if ierrors.Is(err, errKey) { return failureReason } } // use most general failure reason - return apimodels.TxFailureSemanticValidationFailed + return api.TxFailureSemanticValidationFailed } diff --git a/pkg/retainer/retainer/retainer.go b/pkg/retainer/retainer/retainer.go index c61c1fdcd..3d8f06246 100644 --- a/pkg/retainer/retainer/retainer.go +++ b/pkg/retainer/retainer/retainer.go @@ -13,7 +13,7 @@ import ( "github.com/iotaledger/iota-core/pkg/retainer" "github.com/iotaledger/iota-core/pkg/storage/prunable/slotstore" iotago "github.com/iotaledger/iota.go/v4" - "github.com/iotaledger/iota.go/v4/nodeclient/apimodels" + "github.com/iotaledger/iota.go/v4/api" ) type ( @@ -32,7 +32,7 @@ type Retainer struct { finalizedSlotFunc FinalizedSlotFunc errorHandler func(error) - stakersResponses *shrinkingmap.ShrinkingMap[uint32, []*apimodels.ValidatorResponse] + stakersResponses *shrinkingmap.ShrinkingMap[uint32, []*api.ValidatorResponse] workerPool *workerpool.WorkerPool @@ -43,7 +43,7 @@ func New(workersGroup *workerpool.Group, retainerFunc RetainerFunc, latestCommit return &Retainer{ workerPool: workersGroup.CreatePool("Retainer", workerpool.WithWorkerCount(1)), store: retainerFunc, - stakersResponses: shrinkingmap.New[uint32, []*apimodels.ValidatorResponse](), + stakersResponses: shrinkingmap.New[uint32, []*api.ValidatorResponse](), latestCommittedSlotFunc: latestCommittedSlotFunc, finalizedSlotFunc: finalizedSlotFunc, errorHandler: errorHandler, @@ -84,7 +84,7 @@ func NewProvider() module.Provider[*engine.Engine, retainer.Retainer] { }, asyncOpt) e.Events.Scheduler.BlockDropped.Hook(func(b *blocks.Block, err error) { - r.RetainBlockFailure(b.ID(), apimodels.BlockFailureDroppedDueToCongestion) + r.RetainBlockFailure(b.ID(), api.BlockFailureDroppedDueToCongestion) }) e.HookInitialized(func() { @@ -153,13 +153,13 @@ func (r *Retainer) Shutdown() { func (r *Retainer) BlockMetadata(blockID iotago.BlockID) (*retainer.BlockMetadata, error) { blockStatus, blockFailureReason := r.blockStatus(blockID) - if blockStatus == apimodels.BlockStateUnknown { + if blockStatus == api.BlockStateUnknown { return nil, ierrors.Errorf("block %s not found", blockID.ToHex()) } // we do not expose accepted flag - if blockStatus == apimodels.BlockStateAccepted { - blockStatus = apimodels.BlockStatePending + if blockStatus == api.BlockStateAccepted { + blockStatus = api.BlockStatePending } txStatus, txFailureReason := r.transactionStatus(blockID) @@ -173,7 +173,7 @@ func (r *Retainer) BlockMetadata(blockID iotago.BlockID) (*retainer.BlockMetadat }, nil } -func (r *Retainer) RetainBlockFailure(blockID iotago.BlockID, failureCode apimodels.BlockFailureReason) { +func (r *Retainer) RetainBlockFailure(blockID iotago.BlockID, failureCode api.BlockFailureReason) { store, err := r.store(blockID.Slot()) if err != nil { r.errorHandler(ierrors.Wrapf(err, "could not get retainer store for slot %d", blockID.Slot())) @@ -197,11 +197,11 @@ func (r *Retainer) RetainTransactionFailure(blockID iotago.BlockID, err error) { } } -func (r *Retainer) RegisteredValidatorsCache(index uint32) ([]*apimodels.ValidatorResponse, bool) { +func (r *Retainer) RegisteredValidatorsCache(index uint32) ([]*api.ValidatorResponse, bool) { return r.stakersResponses.Get(index) } -func (r *Retainer) RetainRegisteredValidatorsCache(index uint32, resp []*apimodels.ValidatorResponse) { +func (r *Retainer) RetainRegisteredValidatorsCache(index uint32, resp []*api.ValidatorResponse) { r.stakersResponses.Set(index, resp) if r.stakersResponses.Size() > MaxStakersResponsesCacheNum { keys := r.stakersResponses.Keys() @@ -215,52 +215,52 @@ func (r *Retainer) RetainRegisteredValidatorsCache(index uint32, resp []*apimode } } -func (r *Retainer) blockStatus(blockID iotago.BlockID) (apimodels.BlockState, apimodels.BlockFailureReason) { +func (r *Retainer) blockStatus(blockID iotago.BlockID) (api.BlockState, api.BlockFailureReason) { store, err := r.store(blockID.Slot()) if err != nil { r.errorHandler(ierrors.Wrapf(err, "could not get retainer store for slot %d", blockID.Slot())) - return apimodels.BlockStateUnknown, apimodels.BlockFailureNone + return api.BlockStateUnknown, api.BlockFailureNone } blockData, exists := store.GetBlock(blockID) if !exists { - return apimodels.BlockStateUnknown, apimodels.BlockFailureNone + return api.BlockStateUnknown, api.BlockFailureNone } switch blockData.State { - case apimodels.BlockStatePending: + case api.BlockStatePending: if blockID.Slot() <= r.latestCommittedSlotFunc() { - return apimodels.BlockStateRejected, blockData.FailureReason + return api.BlockStateRejected, blockData.FailureReason } - case apimodels.BlockStateAccepted, apimodels.BlockStateConfirmed: + case api.BlockStateAccepted, api.BlockStateConfirmed: if blockID.Slot() <= r.finalizedSlotFunc() { - return apimodels.BlockStateFinalized, apimodels.BlockFailureNone + return api.BlockStateFinalized, api.BlockFailureNone } } return blockData.State, blockData.FailureReason } -func (r *Retainer) transactionStatus(blockID iotago.BlockID) (apimodels.TransactionState, apimodels.TransactionFailureReason) { +func (r *Retainer) transactionStatus(blockID iotago.BlockID) (api.TransactionState, api.TransactionFailureReason) { store, err := r.store(blockID.Slot()) if err != nil { r.errorHandler(ierrors.Wrapf(err, "could not get retainer store for slot %d", blockID.Slot())) - return apimodels.TransactionStateNoTransaction, apimodels.TxFailureNone + return api.TransactionStateNoTransaction, api.TxFailureNone } txData, exists := store.GetTransaction(blockID) if !exists { - return apimodels.TransactionStateNoTransaction, apimodels.TxFailureNone + return api.TransactionStateNoTransaction, api.TxFailureNone } // for confirmed and finalized we need to check for the block status - if txData.State == apimodels.TransactionStateAccepted { + if txData.State == api.TransactionStateAccepted { blockState, _ := r.blockStatus(blockID) switch blockState { - case apimodels.BlockStateConfirmed: - return apimodels.TransactionStateConfirmed, apimodels.TxFailureNone - case apimodels.BlockStateFinalized: - return apimodels.TransactionStateFinalized, apimodels.TxFailureNone + case api.BlockStateConfirmed: + return api.TransactionStateConfirmed, api.TxFailureNone + case api.BlockStateFinalized: + return api.TransactionStateFinalized, api.TxFailureNone } } @@ -300,7 +300,7 @@ func (r *Retainer) onTransactionAttached(blockID iotago.BlockID) error { return ierrors.Wrapf(err, "could not get retainer store for slot %d", blockID.Slot()) } - return store.StoreTransactionNoFailureStatus(blockID, apimodels.TransactionStatePending) + return store.StoreTransactionNoFailureStatus(blockID, api.TransactionStatePending) } func (r *Retainer) onTransactionAccepted(blockID iotago.BlockID) error { @@ -309,7 +309,7 @@ func (r *Retainer) onTransactionAccepted(blockID iotago.BlockID) error { return ierrors.Wrapf(err, "could not get retainer store for slot %d", blockID.Slot()) } - return store.StoreTransactionNoFailureStatus(blockID, apimodels.TransactionStateAccepted) + return store.StoreTransactionNoFailureStatus(blockID, api.TransactionStateAccepted) } func (r *Retainer) onAttachmentUpdated(prevID iotago.BlockID, newID iotago.BlockID, accepted bool) error { @@ -328,8 +328,8 @@ func (r *Retainer) onAttachmentUpdated(prevID iotago.BlockID, newID iotago.Block } if accepted { - return store.StoreTransactionNoFailureStatus(newID, apimodels.TransactionStateAccepted) + return store.StoreTransactionNoFailureStatus(newID, api.TransactionStateAccepted) } - return store.StoreTransactionNoFailureStatus(newID, apimodels.TransactionStatePending) + return store.StoreTransactionNoFailureStatus(newID, api.TransactionStatePending) } diff --git a/pkg/storage/permanent/options.go b/pkg/storage/permanent/options.go index 300615baa..2f05814c3 100644 --- a/pkg/storage/permanent/options.go +++ b/pkg/storage/permanent/options.go @@ -2,10 +2,10 @@ package permanent import ( "github.com/iotaledger/hive.go/runtime/options" - "github.com/iotaledger/iota.go/v4/api" + iotago "github.com/iotaledger/iota.go/v4" ) -func WithEpochBasedProviderOptions(opts ...options.Option[api.EpochBasedProvider]) options.Option[Permanent] { +func WithEpochBasedProviderOptions(opts ...options.Option[iotago.EpochBasedProvider]) options.Option[Permanent] { return func(p *Permanent) { p.optsEpochBasedProvider = append(p.optsEpochBasedProvider, opts...) } diff --git a/pkg/storage/permanent/permanent.go b/pkg/storage/permanent/permanent.go index fd576d9c6..c91ccca7e 100644 --- a/pkg/storage/permanent/permanent.go +++ b/pkg/storage/permanent/permanent.go @@ -11,7 +11,6 @@ import ( "github.com/iotaledger/iota-core/pkg/protocol/engine/utxoledger" "github.com/iotaledger/iota-core/pkg/storage/database" iotago "github.com/iotaledger/iota.go/v4" - "github.com/iotaledger/iota.go/v4/api" ) const ( @@ -34,7 +33,7 @@ type Permanent struct { accounts kvstore.KVStore latestNonEmptySlot kvstore.KVStore - optsEpochBasedProvider []options.Option[api.EpochBasedProvider] + optsEpochBasedProvider []options.Option[iotago.EpochBasedProvider] } // New returns a new permanent storage instance. diff --git a/pkg/storage/permanent/settings.go b/pkg/storage/permanent/settings.go index afa3aece9..a9bf979b2 100644 --- a/pkg/storage/permanent/settings.go +++ b/pkg/storage/permanent/settings.go @@ -16,7 +16,6 @@ import ( "github.com/iotaledger/hive.go/stringify" "github.com/iotaledger/iota-core/pkg/model" iotago "github.com/iotaledger/iota.go/v4" - "github.com/iotaledger/iota.go/v4/api" ) const ( @@ -42,11 +41,11 @@ type Settings struct { storeFutureProtocolParameters *kvstore.TypedStore[iotago.Version, *types.Tuple[iotago.EpochIndex, iotago.Identifier]] storeProtocolParameters *kvstore.TypedStore[iotago.Version, iotago.ProtocolParameters] - apiProvider *api.EpochBasedProvider + apiProvider *iotago.EpochBasedProvider } -func NewSettings(store kvstore.KVStore, opts ...options.Option[api.EpochBasedProvider]) (settings *Settings) { - apiProvider := api.NewEpochBasedProvider(opts...) +func NewSettings(store kvstore.KVStore, opts ...options.Option[iotago.EpochBasedProvider]) (settings *Settings) { + apiProvider := iotago.NewEpochBasedProvider(opts...) s := &Settings{ store: store, @@ -176,7 +175,7 @@ func (s *Settings) loadFutureProtocolParameters() { } } -func (s *Settings) APIProvider() *api.EpochBasedProvider { +func (s *Settings) APIProvider() *iotago.EpochBasedProvider { return s.apiProvider } diff --git a/pkg/storage/prunable/slotstore/retainer.go b/pkg/storage/prunable/slotstore/retainer.go index 646ed7913..44099e4b9 100644 --- a/pkg/storage/prunable/slotstore/retainer.go +++ b/pkg/storage/prunable/slotstore/retainer.go @@ -6,7 +6,7 @@ import ( "github.com/iotaledger/hive.go/lo" "github.com/iotaledger/hive.go/serializer/v2/stream" iotago "github.com/iotaledger/iota.go/v4" - "github.com/iotaledger/iota.go/v4/nodeclient/apimodels" + "github.com/iotaledger/iota.go/v4/api" ) const ( @@ -15,8 +15,8 @@ const ( ) type BlockRetainerData struct { - State apimodels.BlockState - FailureReason apimodels.BlockFailureReason + State api.BlockState + FailureReason api.BlockFailureReason } func (b *BlockRetainerData) Bytes() ([]byte, error) { @@ -38,10 +38,10 @@ func BlockRetainerDataFromBytes(bytes []byte) (*BlockRetainerData, int, error) { var err error b := new(BlockRetainerData) - if b.State, err = stream.Read[apimodels.BlockState](byteReader); err != nil { + if b.State, err = stream.Read[api.BlockState](byteReader); err != nil { return nil, 0, ierrors.Wrap(err, "failed to read block state") } - if b.FailureReason, err = stream.Read[apimodels.BlockFailureReason](byteReader); err != nil { + if b.FailureReason, err = stream.Read[api.BlockFailureReason](byteReader); err != nil { return nil, 0, ierrors.Wrap(err, "failed to read block failure reason") } @@ -49,8 +49,8 @@ func BlockRetainerDataFromBytes(bytes []byte) (*BlockRetainerData, int, error) { } type TransactionRetainerData struct { - State apimodels.TransactionState - FailureReason apimodels.TransactionFailureReason + State api.TransactionState + FailureReason api.TransactionFailureReason } func (t *TransactionRetainerData) Bytes() ([]byte, error) { @@ -72,10 +72,10 @@ func TransactionRetainerDataFromBytes(bytes []byte) (*TransactionRetainerData, i var err error t := new(TransactionRetainerData) - if t.State, err = stream.Read[apimodels.TransactionState](byteReader); err != nil { + if t.State, err = stream.Read[api.TransactionState](byteReader); err != nil { return nil, 0, ierrors.Wrap(err, "failed to read transaction state") } - if t.FailureReason, err = stream.Read[apimodels.TransactionFailureReason](byteReader); err != nil { + if t.FailureReason, err = stream.Read[api.TransactionFailureReason](byteReader); err != nil { return nil, 0, ierrors.Wrap(err, "failed to read transaction failure reason") } @@ -109,8 +109,8 @@ func NewRetainer(slot iotago.SlotIndex, store kvstore.KVStore) (newRetainer *Ret func (r *Retainer) StoreBlockAttached(blockID iotago.BlockID) error { return r.blockStore.Set(blockID, &BlockRetainerData{ - State: apimodels.BlockStatePending, - FailureReason: apimodels.BlockFailureNone, + State: api.BlockStatePending, + FailureReason: api.BlockFailureNone, }) } @@ -134,33 +134,33 @@ func (r *Retainer) GetTransaction(blockID iotago.BlockID) (*TransactionRetainerD func (r *Retainer) StoreBlockAccepted(blockID iotago.BlockID) error { return r.blockStore.Set(blockID, &BlockRetainerData{ - State: apimodels.BlockStateAccepted, - FailureReason: apimodels.BlockFailureNone, + State: api.BlockStateAccepted, + FailureReason: api.BlockFailureNone, }) } func (r *Retainer) StoreBlockConfirmed(blockID iotago.BlockID) error { return r.blockStore.Set(blockID, &BlockRetainerData{ - State: apimodels.BlockStateConfirmed, - FailureReason: apimodels.BlockFailureNone, + State: api.BlockStateConfirmed, + FailureReason: api.BlockFailureNone, }) } func (r *Retainer) StoreTransactionPending(blockID iotago.BlockID) error { return r.transactionStore.Set(blockID, &TransactionRetainerData{ - State: apimodels.TransactionStatePending, - FailureReason: apimodels.TxFailureNone, + State: api.TransactionStatePending, + FailureReason: api.TxFailureNone, }) } -func (r *Retainer) StoreTransactionNoFailureStatus(blockID iotago.BlockID, status apimodels.TransactionState) error { - if status == apimodels.TransactionStateFailed { +func (r *Retainer) StoreTransactionNoFailureStatus(blockID iotago.BlockID, status api.TransactionState) error { + if status == api.TransactionStateFailed { return ierrors.Errorf("failed to retain transaction status, status cannot be failed, blockID: %s", blockID.String()) } return r.transactionStore.Set(blockID, &TransactionRetainerData{ State: status, - FailureReason: apimodels.TxFailureNone, + FailureReason: api.TxFailureNone, }) } @@ -168,16 +168,16 @@ func (r *Retainer) DeleteTransactionData(prevID iotago.BlockID) error { return r.transactionStore.Delete(prevID) } -func (r *Retainer) StoreBlockFailure(blockID iotago.BlockID, failureType apimodels.BlockFailureReason) error { +func (r *Retainer) StoreBlockFailure(blockID iotago.BlockID, failureType api.BlockFailureReason) error { return r.blockStore.Set(blockID, &BlockRetainerData{ - State: apimodels.BlockStateFailed, + State: api.BlockStateFailed, FailureReason: failureType, }) } -func (r *Retainer) StoreTransactionFailure(blockID iotago.BlockID, failureType apimodels.TransactionFailureReason) error { +func (r *Retainer) StoreTransactionFailure(blockID iotago.BlockID, failureType api.TransactionFailureReason) error { return r.transactionStore.Set(blockID, &TransactionRetainerData{ - State: apimodels.TransactionStateFailed, + State: api.TransactionStateFailed, FailureReason: failureType, }) } diff --git a/pkg/tests/upgrade_signaling_test.go b/pkg/tests/upgrade_signaling_test.go index 76b63980f..1cef7088b 100644 --- a/pkg/tests/upgrade_signaling_test.go +++ b/pkg/tests/upgrade_signaling_test.go @@ -26,7 +26,6 @@ import ( "github.com/iotaledger/iota-core/pkg/testsuite" "github.com/iotaledger/iota-core/pkg/testsuite/mock" iotago "github.com/iotaledger/iota.go/v4" - "github.com/iotaledger/iota.go/v4/api" ) func Test_Upgrade_Signaling(t *testing.T) { @@ -75,7 +74,7 @@ func Test_Upgrade_Signaling(t *testing.T) { storage.WithPruningDelay(20), storage.WithPermanentOptions( permanent.WithEpochBasedProviderOptions( - api.WithAPIForMissingVersionCallback(func(protocolParameters iotago.ProtocolParameters) (iotago.API, error) { + iotago.WithAPIForMissingVersionCallback(func(protocolParameters iotago.ProtocolParameters) (iotago.API, error) { switch protocolParameters.Version() { case 3: return ts.API, nil @@ -106,7 +105,7 @@ func Test_Upgrade_Signaling(t *testing.T) { storage.WithPruningDelay(20), storage.WithPermanentOptions( permanent.WithEpochBasedProviderOptions( - api.WithAPIForMissingVersionCallback(func(protocolParameters iotago.ProtocolParameters) (iotago.API, error) { + iotago.WithAPIForMissingVersionCallback(func(protocolParameters iotago.ProtocolParameters) (iotago.API, error) { switch protocolParameters.Version() { case 3: return ts.API, nil diff --git a/tools/gendoc/go.mod b/tools/gendoc/go.mod index 86ec77966..4a8c51f46 100644 --- a/tools/gendoc/go.mod +++ b/tools/gendoc/go.mod @@ -58,21 +58,21 @@ require ( github.com/iancoleman/orderedmap v0.3.0 // indirect github.com/iotaledger/grocksdb v1.7.5-0.20230220105546-5162e18885c7 // indirect github.com/iotaledger/hive.go/ads v0.0.0-20231110191152-7135670285dc // indirect - github.com/iotaledger/hive.go/constraints v0.0.0-20231113110812-4ca2b6cc9a42 // indirect + github.com/iotaledger/hive.go/constraints v0.0.0-20231122112629-bdf1cc39fba7 // indirect github.com/iotaledger/hive.go/core v1.0.0-rc.3.0.20231113110812-4ca2b6cc9a42 // indirect - github.com/iotaledger/hive.go/crypto v0.0.0-20231113110812-4ca2b6cc9a42 // indirect + github.com/iotaledger/hive.go/crypto v0.0.0-20231122112629-bdf1cc39fba7 // indirect github.com/iotaledger/hive.go/ds v0.0.0-20231113110812-4ca2b6cc9a42 // indirect - github.com/iotaledger/hive.go/ierrors v0.0.0-20231113110812-4ca2b6cc9a42 // indirect + github.com/iotaledger/hive.go/ierrors v0.0.0-20231122112629-bdf1cc39fba7 // indirect github.com/iotaledger/hive.go/kvstore v0.0.0-20231110191152-7135670285dc // indirect - github.com/iotaledger/hive.go/lo v0.0.0-20231113110812-4ca2b6cc9a42 // indirect + github.com/iotaledger/hive.go/lo v0.0.0-20231122112629-bdf1cc39fba7 // indirect github.com/iotaledger/hive.go/log v0.0.0-20231110191152-7135670285dc // indirect github.com/iotaledger/hive.go/logger v0.0.0-20231113110812-4ca2b6cc9a42 // indirect - github.com/iotaledger/hive.go/runtime v0.0.0-20231113110812-4ca2b6cc9a42 // indirect + github.com/iotaledger/hive.go/runtime v0.0.0-20231122112629-bdf1cc39fba7 // indirect github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20231113110812-4ca2b6cc9a42 // indirect - github.com/iotaledger/hive.go/stringify v0.0.0-20231113110812-4ca2b6cc9a42 // indirect - github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231121121055-b13a176c5180 // indirect - github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231120082637-ccd5b8465251 // indirect - github.com/iotaledger/iota.go/v4 v4.0.0-20231123022049-52a0703d077f // indirect + github.com/iotaledger/hive.go/stringify v0.0.0-20231122112629-bdf1cc39fba7 // indirect + github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231123103852-bb039cbab83b // indirect + github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231123103318-f6ea945e2e98 // indirect + github.com/iotaledger/iota.go/v4 v4.0.0-20231123102955-eff367396512 // indirect github.com/ipfs/boxo v0.13.1 // indirect github.com/ipfs/go-cid v0.4.1 // indirect github.com/ipfs/go-datastore v0.6.0 // indirect @@ -178,7 +178,7 @@ require ( golang.org/x/time v0.4.0 // indirect golang.org/x/tools v0.14.0 // indirect gonum.org/v1/gonum v0.14.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20231106174013-bbf56f31fb17 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20231120223509-83a465c0220f // indirect google.golang.org/grpc v1.59.0 // indirect google.golang.org/protobuf v1.31.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect diff --git a/tools/gendoc/go.sum b/tools/gendoc/go.sum index 0607d081c..eee98d60b 100644 --- a/tools/gendoc/go.sum +++ b/tools/gendoc/go.sum @@ -283,36 +283,36 @@ github.com/iotaledger/hive.go/app v0.0.0-20231113110812-4ca2b6cc9a42 h1:K6VF23FO github.com/iotaledger/hive.go/app v0.0.0-20231113110812-4ca2b6cc9a42/go.mod h1:+riYmeLApkLlj4+EpuJpEJAsj/KGfD7cqLGy7oTsPOM= github.com/iotaledger/hive.go/apputils v0.0.0-20230829152614-7afc7a4d89b3 h1:4aVJTc0KS77uEw0Tny4r0n1ORwcbAQDECaCclgf/6lE= github.com/iotaledger/hive.go/apputils v0.0.0-20230829152614-7afc7a4d89b3/go.mod h1:TZeAqieDu+xDOZp2e9+S+8pZp1PrfgcwLUnxmd8IgLU= -github.com/iotaledger/hive.go/constraints v0.0.0-20231113110812-4ca2b6cc9a42 h1:+PyLPZhRHy+Negjpuj0CSLaObpErEH7yI6HB2z5N6b0= -github.com/iotaledger/hive.go/constraints v0.0.0-20231113110812-4ca2b6cc9a42/go.mod h1:dOBOM2s4se3HcWefPe8sQLUalGXJ8yVXw58oK8jke3s= +github.com/iotaledger/hive.go/constraints v0.0.0-20231122112629-bdf1cc39fba7 h1:ozpeM5nHHUjK3aKpTmwFEDG2bqxLJf0KBCTakjh+1FE= +github.com/iotaledger/hive.go/constraints v0.0.0-20231122112629-bdf1cc39fba7/go.mod h1:dOBOM2s4se3HcWefPe8sQLUalGXJ8yVXw58oK8jke3s= github.com/iotaledger/hive.go/core v1.0.0-rc.3.0.20231113110812-4ca2b6cc9a42 h1:3dW4gz0Vr9BogN826HRTp0OFlbngjhWcVPUfDhJ57Yw= github.com/iotaledger/hive.go/core v1.0.0-rc.3.0.20231113110812-4ca2b6cc9a42/go.mod h1:CdixkrB7VdQzEDlVuwsxPtsiJL/WXrQgz3PELIqlLko= -github.com/iotaledger/hive.go/crypto v0.0.0-20231113110812-4ca2b6cc9a42 h1:t6EKe+O7XAmbe07cVHuM/3aBLEbVIY4D6yefANB4PUA= -github.com/iotaledger/hive.go/crypto v0.0.0-20231113110812-4ca2b6cc9a42/go.mod h1:OQ9EVTTQT1mkO/16BgwSIyQlAhEg+Cptud/yutevWsI= +github.com/iotaledger/hive.go/crypto v0.0.0-20231122112629-bdf1cc39fba7 h1:vLLhxGhipU6AH/paexuRX3zsOvcl8bdYcwJRAchUP8g= +github.com/iotaledger/hive.go/crypto v0.0.0-20231122112629-bdf1cc39fba7/go.mod h1:OQ9EVTTQT1mkO/16BgwSIyQlAhEg+Cptud/yutevWsI= github.com/iotaledger/hive.go/ds v0.0.0-20231113110812-4ca2b6cc9a42 h1:QZiMlDxmikF64zimWQunTrsEGOK9ydRahUAz2I46JAk= github.com/iotaledger/hive.go/ds v0.0.0-20231113110812-4ca2b6cc9a42/go.mod h1:JE8cbZSvzbB5TrwXibg6M0B7ck35YxF30ItHBzQRlgc= -github.com/iotaledger/hive.go/ierrors v0.0.0-20231113110812-4ca2b6cc9a42 h1:gxlZ4zL6EfLyqT0+hIFV3WVE0FrPVgV5cQdyn36vPXQ= -github.com/iotaledger/hive.go/ierrors v0.0.0-20231113110812-4ca2b6cc9a42/go.mod h1:HcE8B5lP96enc/OALTb2/rIIi+yOLouRoHOKRclKmC8= +github.com/iotaledger/hive.go/ierrors v0.0.0-20231122112629-bdf1cc39fba7 h1:tf7x4U+ZXnmFXhUmqYtn0kcgpOcGPIhbxR/akpzAU4U= +github.com/iotaledger/hive.go/ierrors v0.0.0-20231122112629-bdf1cc39fba7/go.mod h1:HcE8B5lP96enc/OALTb2/rIIi+yOLouRoHOKRclKmC8= github.com/iotaledger/hive.go/kvstore v0.0.0-20231110191152-7135670285dc h1:3fsqfM2NqfhrewVdlKT3MHcXxVNvUCSP7P32il1ypa0= github.com/iotaledger/hive.go/kvstore v0.0.0-20231110191152-7135670285dc/go.mod h1:ytfKoHr/nF8u0y0G4mamfG0yjFtJiJVk0kgjnPOtsSY= -github.com/iotaledger/hive.go/lo v0.0.0-20231113110812-4ca2b6cc9a42 h1:kcHkWyURZDVqO80OmJo5Z+wTJB6H+s52WAnU575vX0o= -github.com/iotaledger/hive.go/lo v0.0.0-20231113110812-4ca2b6cc9a42/go.mod h1:6Ee7i6b4tuTHuRYnPP8VUb0wr9XFI5qlqtnttBd9jRg= +github.com/iotaledger/hive.go/lo v0.0.0-20231122112629-bdf1cc39fba7 h1:svFxB75LsjUOHt3crcn70GVk7ztdNv5CytC3GbGj9FQ= +github.com/iotaledger/hive.go/lo v0.0.0-20231122112629-bdf1cc39fba7/go.mod h1:6Ee7i6b4tuTHuRYnPP8VUb0wr9XFI5qlqtnttBd9jRg= github.com/iotaledger/hive.go/log v0.0.0-20231110191152-7135670285dc h1:joYrsSZuVG3DfAQR9iS3qjnMExJ0qNp2+369sxb1Y4g= github.com/iotaledger/hive.go/log v0.0.0-20231110191152-7135670285dc/go.mod h1:vzO4/wRkEJDEZb/9fD10oKU9k1bj4qLir2Uhl5U1FkM= github.com/iotaledger/hive.go/logger v0.0.0-20231113110812-4ca2b6cc9a42 h1:uD99UbTtBM5SIP9N3c/3BBLtb0frGYFsZ2lS8Zxtqr4= github.com/iotaledger/hive.go/logger v0.0.0-20231113110812-4ca2b6cc9a42/go.mod h1:w1psHM2MuKsen1WdsPKrpqElYH7ZOQ+YdQIgJZg4HTo= -github.com/iotaledger/hive.go/runtime v0.0.0-20231113110812-4ca2b6cc9a42 h1:hpR++ME3Y3CcxA431Zg0PgcCJUNkbBqjNXxR/bs+NdI= -github.com/iotaledger/hive.go/runtime v0.0.0-20231113110812-4ca2b6cc9a42/go.mod h1:DrZPvUvLarK8C2qb+3H2vdypp/MuhpQmB3iMJbDCr/Q= +github.com/iotaledger/hive.go/runtime v0.0.0-20231122112629-bdf1cc39fba7 h1:NtR3ZeY6Mop9JcHu62Z6JPMRcijIV1ZCZPpOev8HZRw= +github.com/iotaledger/hive.go/runtime v0.0.0-20231122112629-bdf1cc39fba7/go.mod h1:DrZPvUvLarK8C2qb+3H2vdypp/MuhpQmB3iMJbDCr/Q= github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20231113110812-4ca2b6cc9a42 h1:hepsnGvaS39azq80GV8DT9HlexoO/RqJbyiW5FXZ0HQ= github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20231113110812-4ca2b6cc9a42/go.mod h1:FoH3T6yKlZJp8xm8K+zsQiibSynp32v21CpWx8xkek8= -github.com/iotaledger/hive.go/stringify v0.0.0-20231113110812-4ca2b6cc9a42 h1:9c7NiX2cnNPHR9UNWINDqNkolupXiDF3543pR6KLwIg= -github.com/iotaledger/hive.go/stringify v0.0.0-20231113110812-4ca2b6cc9a42/go.mod h1:FTo/UWzNYgnQ082GI9QVM9HFDERqf9rw9RivNpqrnTs= -github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231121121055-b13a176c5180 h1:hAVWoyAF4FE+1gUd2IqvTBDTnQ4Z0GKE6qc8qw9QPqg= -github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231121121055-b13a176c5180/go.mod h1:iFiY6UukYeL8D3N1mtg4jh/9lxTBhzG0QgtD+w0gpps= -github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231120082637-ccd5b8465251 h1:bYGO8jXNXJNMGPG9etGW7WXfLbRU9ofx1xdd29/sS9M= -github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231120082637-ccd5b8465251/go.mod h1:chzj8FDIeXHIh3D52QTZ7imADlzdkhg7o7E2Qr85MJ8= -github.com/iotaledger/iota.go/v4 v4.0.0-20231123022049-52a0703d077f h1:CBSRHs4ysjR/NgrVb//4mm5SgzynIOOm0ZJ3IRIf3FY= -github.com/iotaledger/iota.go/v4 v4.0.0-20231123022049-52a0703d077f/go.mod h1:1CUJKGvkOUGXakxFZGAagEQDX9qYyhzIElmUHCHo9RM= +github.com/iotaledger/hive.go/stringify v0.0.0-20231122112629-bdf1cc39fba7 h1:h481Dn+giKO/1MamwuDZ8Mvzg4GbPx/asKD/X3Zs8wc= +github.com/iotaledger/hive.go/stringify v0.0.0-20231122112629-bdf1cc39fba7/go.mod h1:FTo/UWzNYgnQ082GI9QVM9HFDERqf9rw9RivNpqrnTs= +github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231123103852-bb039cbab83b h1:T/9f4eYcP/fxe0G0pYa6TRZxD9rI9uMdDW89hnsNByU= +github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231123103852-bb039cbab83b/go.mod h1:c7ktZxoH5Wp2ixzJn/8RmM5v2QOCIu/79tDFvfLbyPs= +github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231123103318-f6ea945e2e98 h1:PjGs+njONeFaxFgQ3lxxlRs3wTYw3233f/yDyTV8/F8= +github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231123103318-f6ea945e2e98/go.mod h1:jFRt2SZO3KE74/mk+zeCjlhVROriEg86K8CJTxvfdP8= +github.com/iotaledger/iota.go/v4 v4.0.0-20231123102955-eff367396512 h1:E1m9Ja6d47sVkl0k2a8eU9f5COWqpyNY9ET3TyYLHiI= +github.com/iotaledger/iota.go/v4 v4.0.0-20231123102955-eff367396512/go.mod h1:aO+5iL0vTNwNfE4QMGHVIufGziSI1wTvwJY1ipSMgCk= github.com/ipfs/boxo v0.13.1 h1:nQ5oQzcMZR3oL41REJDcTbrvDvuZh3J9ckc9+ILeRQI= github.com/ipfs/boxo v0.13.1/go.mod h1:btrtHy0lmO1ODMECbbEY1pxNtrLilvKSYLoGQt1yYCk= github.com/ipfs/go-cid v0.4.1 h1:A/T3qGvxi4kpKWWcPC/PgbvDA2bjVLO7n4UeVwnbs/s= @@ -881,8 +881,8 @@ google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98 google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= -google.golang.org/genproto/googleapis/rpc v0.0.0-20231106174013-bbf56f31fb17 h1:Jyp0Hsi0bmHXG6k9eATXoYtjd6e2UzZ1SCn/wIupY14= -google.golang.org/genproto/googleapis/rpc v0.0.0-20231106174013-bbf56f31fb17/go.mod h1:oQ5rr10WTTMvP4A36n8JpR1OrO1BEiV4f78CneXZxkA= +google.golang.org/genproto/googleapis/rpc v0.0.0-20231120223509-83a465c0220f h1:ultW7fxlIvee4HYrtnaRPon9HpEgFk5zYpmfMgtKB5I= +google.golang.org/genproto/googleapis/rpc v0.0.0-20231120223509-83a465c0220f/go.mod h1:L9KNLi232K1/xB6f7AlSX692koaRnKaWSR0stBki0Yc= google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.16.0/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9MZMio= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= diff --git a/tools/genesis-snapshot/go.mod b/tools/genesis-snapshot/go.mod index 936e0cc42..58cfbb210 100644 --- a/tools/genesis-snapshot/go.mod +++ b/tools/genesis-snapshot/go.mod @@ -5,12 +5,12 @@ go 1.21 replace github.com/iotaledger/iota-core => ../../ require ( - github.com/iotaledger/hive.go/crypto v0.0.0-20231113110812-4ca2b6cc9a42 - github.com/iotaledger/hive.go/ierrors v0.0.0-20231113110812-4ca2b6cc9a42 - github.com/iotaledger/hive.go/lo v0.0.0-20231113110812-4ca2b6cc9a42 - github.com/iotaledger/hive.go/runtime v0.0.0-20231113110812-4ca2b6cc9a42 + github.com/iotaledger/hive.go/crypto v0.0.0-20231122112629-bdf1cc39fba7 + github.com/iotaledger/hive.go/ierrors v0.0.0-20231122112629-bdf1cc39fba7 + github.com/iotaledger/hive.go/lo v0.0.0-20231122112629-bdf1cc39fba7 + github.com/iotaledger/hive.go/runtime v0.0.0-20231122112629-bdf1cc39fba7 github.com/iotaledger/iota-core v0.0.0-00010101000000-000000000000 - github.com/iotaledger/iota.go/v4 v4.0.0-20231123022049-52a0703d077f + github.com/iotaledger/iota.go/v4 v4.0.0-20231123102955-eff367396512 github.com/mr-tron/base58 v1.2.0 github.com/spf13/pflag v1.0.5 golang.org/x/crypto v0.15.0 @@ -27,13 +27,13 @@ require ( github.com/iancoleman/orderedmap v0.3.0 // indirect github.com/iotaledger/grocksdb v1.7.5-0.20230220105546-5162e18885c7 // indirect github.com/iotaledger/hive.go/ads v0.0.0-20231110191152-7135670285dc // indirect - github.com/iotaledger/hive.go/constraints v0.0.0-20231113110812-4ca2b6cc9a42 // indirect + github.com/iotaledger/hive.go/constraints v0.0.0-20231122112629-bdf1cc39fba7 // indirect github.com/iotaledger/hive.go/core v1.0.0-rc.3.0.20231113110812-4ca2b6cc9a42 // indirect github.com/iotaledger/hive.go/ds v0.0.0-20231113110812-4ca2b6cc9a42 // indirect github.com/iotaledger/hive.go/kvstore v0.0.0-20231110191152-7135670285dc // indirect github.com/iotaledger/hive.go/log v0.0.0-20231110191152-7135670285dc // indirect github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20231113110812-4ca2b6cc9a42 // indirect - github.com/iotaledger/hive.go/stringify v0.0.0-20231113110812-4ca2b6cc9a42 // indirect + github.com/iotaledger/hive.go/stringify v0.0.0-20231122112629-bdf1cc39fba7 // indirect github.com/ipfs/go-cid v0.4.1 // indirect github.com/klauspost/cpuid/v2 v2.2.5 // indirect github.com/kr/text v0.2.0 // indirect diff --git a/tools/genesis-snapshot/go.sum b/tools/genesis-snapshot/go.sum index f17261c00..f2962a3ca 100644 --- a/tools/genesis-snapshot/go.sum +++ b/tools/genesis-snapshot/go.sum @@ -30,30 +30,30 @@ github.com/iotaledger/grocksdb v1.7.5-0.20230220105546-5162e18885c7 h1:dTrD7X2PT github.com/iotaledger/grocksdb v1.7.5-0.20230220105546-5162e18885c7/go.mod h1:ZRdPu684P0fQ1z8sXz4dj9H5LWHhz4a9oCtvjunkSrw= github.com/iotaledger/hive.go/ads v0.0.0-20231110191152-7135670285dc h1:PsArE43UkLymmDy9r7n42Yd1pv1iq4FwSx3iv2Mo+vc= github.com/iotaledger/hive.go/ads v0.0.0-20231110191152-7135670285dc/go.mod h1:gbUvr01B5ha530GnNm8K2OsHXOd2BtzBYOMxyTX3iDg= -github.com/iotaledger/hive.go/constraints v0.0.0-20231113110812-4ca2b6cc9a42 h1:+PyLPZhRHy+Negjpuj0CSLaObpErEH7yI6HB2z5N6b0= -github.com/iotaledger/hive.go/constraints v0.0.0-20231113110812-4ca2b6cc9a42/go.mod h1:dOBOM2s4se3HcWefPe8sQLUalGXJ8yVXw58oK8jke3s= +github.com/iotaledger/hive.go/constraints v0.0.0-20231122112629-bdf1cc39fba7 h1:ozpeM5nHHUjK3aKpTmwFEDG2bqxLJf0KBCTakjh+1FE= +github.com/iotaledger/hive.go/constraints v0.0.0-20231122112629-bdf1cc39fba7/go.mod h1:dOBOM2s4se3HcWefPe8sQLUalGXJ8yVXw58oK8jke3s= github.com/iotaledger/hive.go/core v1.0.0-rc.3.0.20231113110812-4ca2b6cc9a42 h1:3dW4gz0Vr9BogN826HRTp0OFlbngjhWcVPUfDhJ57Yw= github.com/iotaledger/hive.go/core v1.0.0-rc.3.0.20231113110812-4ca2b6cc9a42/go.mod h1:CdixkrB7VdQzEDlVuwsxPtsiJL/WXrQgz3PELIqlLko= -github.com/iotaledger/hive.go/crypto v0.0.0-20231113110812-4ca2b6cc9a42 h1:t6EKe+O7XAmbe07cVHuM/3aBLEbVIY4D6yefANB4PUA= -github.com/iotaledger/hive.go/crypto v0.0.0-20231113110812-4ca2b6cc9a42/go.mod h1:OQ9EVTTQT1mkO/16BgwSIyQlAhEg+Cptud/yutevWsI= +github.com/iotaledger/hive.go/crypto v0.0.0-20231122112629-bdf1cc39fba7 h1:vLLhxGhipU6AH/paexuRX3zsOvcl8bdYcwJRAchUP8g= +github.com/iotaledger/hive.go/crypto v0.0.0-20231122112629-bdf1cc39fba7/go.mod h1:OQ9EVTTQT1mkO/16BgwSIyQlAhEg+Cptud/yutevWsI= github.com/iotaledger/hive.go/ds v0.0.0-20231113110812-4ca2b6cc9a42 h1:QZiMlDxmikF64zimWQunTrsEGOK9ydRahUAz2I46JAk= github.com/iotaledger/hive.go/ds v0.0.0-20231113110812-4ca2b6cc9a42/go.mod h1:JE8cbZSvzbB5TrwXibg6M0B7ck35YxF30ItHBzQRlgc= -github.com/iotaledger/hive.go/ierrors v0.0.0-20231113110812-4ca2b6cc9a42 h1:gxlZ4zL6EfLyqT0+hIFV3WVE0FrPVgV5cQdyn36vPXQ= -github.com/iotaledger/hive.go/ierrors v0.0.0-20231113110812-4ca2b6cc9a42/go.mod h1:HcE8B5lP96enc/OALTb2/rIIi+yOLouRoHOKRclKmC8= +github.com/iotaledger/hive.go/ierrors v0.0.0-20231122112629-bdf1cc39fba7 h1:tf7x4U+ZXnmFXhUmqYtn0kcgpOcGPIhbxR/akpzAU4U= +github.com/iotaledger/hive.go/ierrors v0.0.0-20231122112629-bdf1cc39fba7/go.mod h1:HcE8B5lP96enc/OALTb2/rIIi+yOLouRoHOKRclKmC8= github.com/iotaledger/hive.go/kvstore v0.0.0-20231110191152-7135670285dc h1:3fsqfM2NqfhrewVdlKT3MHcXxVNvUCSP7P32il1ypa0= github.com/iotaledger/hive.go/kvstore v0.0.0-20231110191152-7135670285dc/go.mod h1:ytfKoHr/nF8u0y0G4mamfG0yjFtJiJVk0kgjnPOtsSY= -github.com/iotaledger/hive.go/lo v0.0.0-20231113110812-4ca2b6cc9a42 h1:kcHkWyURZDVqO80OmJo5Z+wTJB6H+s52WAnU575vX0o= -github.com/iotaledger/hive.go/lo v0.0.0-20231113110812-4ca2b6cc9a42/go.mod h1:6Ee7i6b4tuTHuRYnPP8VUb0wr9XFI5qlqtnttBd9jRg= +github.com/iotaledger/hive.go/lo v0.0.0-20231122112629-bdf1cc39fba7 h1:svFxB75LsjUOHt3crcn70GVk7ztdNv5CytC3GbGj9FQ= +github.com/iotaledger/hive.go/lo v0.0.0-20231122112629-bdf1cc39fba7/go.mod h1:6Ee7i6b4tuTHuRYnPP8VUb0wr9XFI5qlqtnttBd9jRg= github.com/iotaledger/hive.go/log v0.0.0-20231110191152-7135670285dc h1:joYrsSZuVG3DfAQR9iS3qjnMExJ0qNp2+369sxb1Y4g= github.com/iotaledger/hive.go/log v0.0.0-20231110191152-7135670285dc/go.mod h1:vzO4/wRkEJDEZb/9fD10oKU9k1bj4qLir2Uhl5U1FkM= -github.com/iotaledger/hive.go/runtime v0.0.0-20231113110812-4ca2b6cc9a42 h1:hpR++ME3Y3CcxA431Zg0PgcCJUNkbBqjNXxR/bs+NdI= -github.com/iotaledger/hive.go/runtime v0.0.0-20231113110812-4ca2b6cc9a42/go.mod h1:DrZPvUvLarK8C2qb+3H2vdypp/MuhpQmB3iMJbDCr/Q= +github.com/iotaledger/hive.go/runtime v0.0.0-20231122112629-bdf1cc39fba7 h1:NtR3ZeY6Mop9JcHu62Z6JPMRcijIV1ZCZPpOev8HZRw= +github.com/iotaledger/hive.go/runtime v0.0.0-20231122112629-bdf1cc39fba7/go.mod h1:DrZPvUvLarK8C2qb+3H2vdypp/MuhpQmB3iMJbDCr/Q= github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20231113110812-4ca2b6cc9a42 h1:hepsnGvaS39azq80GV8DT9HlexoO/RqJbyiW5FXZ0HQ= github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20231113110812-4ca2b6cc9a42/go.mod h1:FoH3T6yKlZJp8xm8K+zsQiibSynp32v21CpWx8xkek8= -github.com/iotaledger/hive.go/stringify v0.0.0-20231113110812-4ca2b6cc9a42 h1:9c7NiX2cnNPHR9UNWINDqNkolupXiDF3543pR6KLwIg= -github.com/iotaledger/hive.go/stringify v0.0.0-20231113110812-4ca2b6cc9a42/go.mod h1:FTo/UWzNYgnQ082GI9QVM9HFDERqf9rw9RivNpqrnTs= -github.com/iotaledger/iota.go/v4 v4.0.0-20231123022049-52a0703d077f h1:CBSRHs4ysjR/NgrVb//4mm5SgzynIOOm0ZJ3IRIf3FY= -github.com/iotaledger/iota.go/v4 v4.0.0-20231123022049-52a0703d077f/go.mod h1:1CUJKGvkOUGXakxFZGAagEQDX9qYyhzIElmUHCHo9RM= +github.com/iotaledger/hive.go/stringify v0.0.0-20231122112629-bdf1cc39fba7 h1:h481Dn+giKO/1MamwuDZ8Mvzg4GbPx/asKD/X3Zs8wc= +github.com/iotaledger/hive.go/stringify v0.0.0-20231122112629-bdf1cc39fba7/go.mod h1:FTo/UWzNYgnQ082GI9QVM9HFDERqf9rw9RivNpqrnTs= +github.com/iotaledger/iota.go/v4 v4.0.0-20231123102955-eff367396512 h1:E1m9Ja6d47sVkl0k2a8eU9f5COWqpyNY9ET3TyYLHiI= +github.com/iotaledger/iota.go/v4 v4.0.0-20231123102955-eff367396512/go.mod h1:aO+5iL0vTNwNfE4QMGHVIufGziSI1wTvwJY1ipSMgCk= github.com/ipfs/go-cid v0.4.1 h1:A/T3qGvxi4kpKWWcPC/PgbvDA2bjVLO7n4UeVwnbs/s= github.com/ipfs/go-cid v0.4.1/go.mod h1:uQHwDeX4c6CtyrFwdqyhpNcxVewur1M7l7fNU7LKwZk= github.com/klauspost/cpuid/v2 v2.2.5 h1:0E5MSMDEoAulmXNFquVs//DdoomxaoTY1kUhbc/qbZg=