-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: move migrations into dedicated module
Signed-off-by: Artur Troian <[email protected]>
- Loading branch information
Showing
15 changed files
with
1,070 additions
and
228 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package migrate | ||
|
||
import ( | ||
"github.com/akash-network/akash-api/go/node/audit/v1beta3" | ||
"github.com/cosmos/cosmos-sdk/codec" | ||
|
||
v1 "pkg.akt.dev/go/node/audit/v1" | ||
) | ||
|
||
func AuditedAttributesV1beta3Prefix() []byte { | ||
return v1beta3.PrefixProviderID() | ||
} | ||
|
||
func AuditedAttributesFromV1beta3(cdc codec.BinaryCodec, fromBz []byte) v1.Provider { | ||
var from v1beta3.AuditedAttributes | ||
cdc.MustUnmarshal(fromBz, &from) | ||
|
||
to := v1.Provider{ | ||
Owner: from.Owner, | ||
Auditor: from.Auditor, | ||
Attributes: AttributesFromV1Beta3(from.Attributes), | ||
} | ||
|
||
return to | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
package migrate | ||
|
||
import ( | ||
"github.com/cosmos/cosmos-sdk/codec" | ||
"github.com/cosmos/gogoproto/proto" | ||
|
||
"github.com/akash-network/akash-api/go/node/deployment/v1beta3" | ||
v1 "pkg.akt.dev/go/node/deployment/v1" | ||
"pkg.akt.dev/go/node/deployment/v1beta4" | ||
) | ||
|
||
func init() { | ||
proto.RegisterType((*v1beta3.DepositDeploymentAuthorization)(nil), "akash.deployment.v1beta3.DepositDeploymentAuthorization") | ||
} | ||
|
||
|
||
func DeploymentV1beta3Prefix() []byte { | ||
return v1beta3.DeploymentPrefix() | ||
} | ||
|
||
func GroupV1beta3Prefix() []byte { | ||
return v1beta3.GroupPrefix() | ||
} | ||
|
||
func DeploymentIDFromV1Beta3(from v1beta3.DeploymentID) v1.DeploymentID { | ||
return v1.DeploymentID{ | ||
Owner: from.Owner, | ||
DSeq: from.DSeq, | ||
} | ||
} | ||
|
||
func GroupIDFromV1Beta3(from v1beta3.GroupID) v1.GroupID { | ||
return v1.GroupID{ | ||
Owner: from.Owner, | ||
DSeq: from.DSeq, | ||
GSeq: from.GSeq, | ||
} | ||
} | ||
|
||
func DeploymentFromV1beta3(cdc codec.BinaryCodec, fromBz []byte) v1.Deployment { | ||
var from v1beta3.Deployment | ||
cdc.MustUnmarshal(fromBz, &from) | ||
|
||
return v1.Deployment{ | ||
ID: DeploymentIDFromV1Beta3(from.DeploymentID), | ||
State: v1.Deployment_State(from.State), | ||
Hash: from.Version, | ||
CreatedAt: from.CreatedAt, | ||
} | ||
} | ||
|
||
func DepositAuthorizationFromV1beta3(from v1beta3.DepositDeploymentAuthorization) v1.DepositAuthorization { | ||
return v1.DepositAuthorization{ | ||
SpendLimit: from.SpendLimit, | ||
} | ||
} | ||
|
||
func ResourceUnitFromV1Beta3(id uint32, from v1beta3.ResourceUnit) v1beta4.ResourceUnit { | ||
return v1beta4.ResourceUnit{ | ||
Resources: ResourcesFromV1Beta3(id, from.Resources), | ||
Count: from.Count, | ||
Price: from.Price, | ||
} | ||
} | ||
|
||
func ResourcesUnitsFromV1Beta3(from []v1beta3.ResourceUnit) v1beta4.ResourceUnits { | ||
res := make(v1beta4.ResourceUnits, 0, len(from)) | ||
|
||
for i, oval := range from { | ||
res = append(res, ResourceUnitFromV1Beta3(uint32(i+1), oval)) | ||
} | ||
|
||
return res | ||
} | ||
|
||
func GroupSpecFromV1Beta3(from v1beta3.GroupSpec) v1beta4.GroupSpec { | ||
return v1beta4.GroupSpec{ | ||
Name: from.Name, | ||
Requirements: PlacementRequirementsFromV1Beta3(from.Requirements), | ||
Resources: ResourcesUnitsFromV1Beta3(from.Resources), | ||
} | ||
} | ||
|
||
func GroupFromV1Beta3(cdc codec.BinaryCodec, fromBz []byte) v1beta4.Group { | ||
var from v1beta3.Group | ||
cdc.MustUnmarshal(fromBz, &from) | ||
|
||
return v1beta4.Group{ | ||
ID: GroupIDFromV1Beta3(from.GroupID), | ||
State: v1beta4.Group_State(from.State), | ||
GroupSpec: GroupSpecFromV1Beta3(from.GroupSpec), | ||
CreatedAt: from.CreatedAt, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.