commonMain.io.eqoty.secret.std.contract.msg.EqotyReleaseMsgs.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of contract-msgs-jvm Show documentation
Show all versions of contract-msgs-jvm Show documentation
Eqoty Secret dapp utils library
The newest version!
package io.eqoty.secret.std.contract.msg
import io.eqoty.cosmwasm.std.types.ContractInfo
import io.eqoty.secret.std.types.Permit
import kotlinx.serialization.*
import kotlinx.serialization.builtins.ListSerializer
import kotlinx.serialization.builtins.serializer
import kotlinx.serialization.descriptors.PrimitiveKind
import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor
import kotlinx.serialization.descriptors.SerialDescriptor
import kotlinx.serialization.descriptors.listSerialDescriptor
import kotlinx.serialization.encoding.Decoder
import kotlinx.serialization.encoding.Encoder
object EqotyReleaseMsgs {
@Serializable
data class Instantiate(
@SerialName("instance_id") val instanceId: UShort,
val admin: String,
@SerialName("royalty_dealer_code_info") val royaltyDealerCodeInfo: CodeInfo,
@SerialName("product_dealer_code_info") val productDealerCodeInfo: CodeInfo,
@SerialName("migratable_snip721_code_info") val migratableSnip721CodeInfo: CodeInfo,
@SerialName("aws_config") val awsConfig: AwsConfig
)
@Serializable
data class Execute(
@SerialName("approve_organizations_pending_info") val approveOrganizationsPendingInfo: IdList? = null,
@SerialName("approve_releasers_pending_info") val approveReleasersPendingInfo: IdList? = null,
@SerialName("delete_pending_organizations") val deletePendingOrganizations: IdList? = null,
@SerialName("delete_pending_releasers") val deletePendingReleasers: IdList? = null,
@SerialName("register_organization") val registerOrganization: RegisterOrganization? = null,
@SerialName("register_releasers") val registerReleasers: RegisterReleasers? = null,
@SerialName("mint_release") val mintRelease: MintRelease? = null,
@SerialName("set_aws_config") val setAwsConfig: AwsConfig? = null,
@SerialName("set_organization_info") val setOrganizationInfo: SetOrganizationInfo? = null,
@SerialName("set_organizations_status") val setOrganizationsStatus: SetOrganizationsStatus? = null,
@SerialName("set_release_name") val setReleaseName: SetReleaseName? = null,
@SerialName("set_releaser_address") val setReleaserAddress: SetReleaserAddress? = null,
@SerialName("set_releaser_info") val setReleaserInfo: SetReleaserInfo? = null,
@SerialName("set_releasers_status") val setReleasersStatus: SetReleasersStatus? = null,
@SerialName("set_release_listed") val setReleaseListed: SetReleaseListed? = null,
) {
@Serializable
data class MintRelease(
@SerialName("eq_royalty_dealer_init_config") val eqRoyaltyDealerInitConfig: EqotyRoyaltyDealerMsgs.InstantiateConfig,
@SerialName("eq_product_dealer_init_config") val eqProductDealerInitConfig: EqotyProductDealerMsgs.InstantiateConfig,
@SerialName("mint_release_config") val mintReleaseConfig: MintReleaseConfig,
) {
@Serializable
data class MintReleaseConfig(
val name: String,
@SerialName("organization_id") val organizationId: ULong,
@SerialName("label_extra") val labelExtra: String? = null
)
}
@Serializable
data class RegisterOrganization(
val organization: OrganizationInfo,
val releasers: List,
)
@Serializable
data class RegisterReleasers(
@SerialName("registration_forms") val registrationForms: List,
)
@Serializable
data class SetOrganizationInfo(
val id: ULong,
val info: OrganizationInfo,
)
@Serializable
data class SetOrganizationsStatus(
val ids: List,
@Serializable(with = StatusSerializer::class) val status: Status
)
@Serializable
data class SetReleaseName(
val id: UInt,
val name: String,
)
@Serializable
data class SetReleaserAddress(
val releaser: ReleaserBy,
val info: ReleaserInfo,
)
@Serializable
data class SetReleaserInfo(
val releaser: ReleaserBy,
val info: ReleaserInfo,
)
@Serializable
data class SetReleasersStatus(
val releasers: List,
@Serializable(with = StatusSerializer::class) val status: Status
)
@Serializable
data class SetReleaseListed(
val id: UInt,
val listed: Boolean,
)
}
@Serializable
data class ExecuteAnswer(
@SerialName("mint_release") val mintRelease: MintRelease? = null,
@SerialName("register_organization") val registerOrganization: RegisterOrganization? = null,
@SerialName("register_releasers") val registerReleasers: List? = null,
) {
@Serializable
data class MintRelease(
@SerialName("release_id") val releaseId: UInt,
@SerialName("eq_royalty_dealer_addr") val eqRoyaltyDealerAddr: String,
@SerialName("eq_product_dealer_addr") val eqProductDealerAddr: String,
)
@Serializable
data class RegisterOrganization(
val id: ULong,
)
}
@Serializable
data class Query(
@SerialName("generate_presigned_organization_put_url") val generatePresignedOrganizationPutUrl: GeneratePresignedOrganizationPutUrl? = null,
@SerialName("generate_presigned_release_put_url") val generatePresignedReleasePutUrl: GeneratePresignedReleasePutUrl? = null,
@SerialName("instance_id") val instanceId: InstanceId? = null,
val organizations: Organizations? = null,
@SerialName("organizations_batch") val organizationsBatch: OrganizationsBatch? = null,
@SerialName("organization_memberships") val organizationMemberships: OrganizationMemberships? = null,
@SerialName("organization_names") val organizationNames: OrganizationNames? = null,
@SerialName("organization_profile_uri") val organizationProfileUri: OrganizationProfileUri? = null,
@SerialName("organization_releases") val organizationReleases: OrganizationReleases? = null,
@SerialName("product_dealer_code_info") val productDealerCodeInfo: ProductDealerCodeInfo? = null,
@SerialName("product_dealer_contract_by_release_id") val productDealerContractByReleaseId: ContractByReleaseId? = null,
@SerialName("royalty_dealer_contract_by_release_id") val royaltyDealerContractByReleaseId: ContractByReleaseId? = null,
@SerialName("releaser_id") val releaserId: ReleaserId? = null,
@SerialName("releasers_batch") val releasersBatch: ReleasersBatch? = null,
val releasers: Releasers? = null,
val releases: Releases? = null,
@SerialName("releases_batch") val releasesBatch: ReleasesBatch? = null,
) {
@Serializable
data class ContractByReleaseId(@SerialName("release_id") val releaseId: UInt)
@Serializable
data class GeneratePresignedOrganizationPutUrl(
/// must be an admin or a releaser's permit
val permit: Permit,
/// The Organization id
val id: ULong,
/// The file name to generate a presigned url for inside the organization's directory
@SerialName("file_name") val fileName: String,
)
@Serializable
data class GeneratePresignedReleasePutUrl(
/// must be an admin or a releaser's permit
val permit: Permit,
/// The release id
val id: UInt,
/// The file name to generate a presigned url for inside the organization's directory
@SerialName("file_name") val fileName: String,
)
@Serializable
data class OrganizationMemberships(
val permit: Permit, val releaser: ReleaserBy
)
@Serializable
class InstanceId
@Serializable
class ProductDealerCodeInfo
@Serializable
data class ReleaserId(
val permit: Permit, val address: String
)
@Serializable
data class ReleasersBatch(
val permit: Permit, val ids: List
)
@Serializable
data class OrganizationsBatch(
val permit: Permit, val ids: List
)
@Serializable
data class Organizations(
val permit: Permit,
@Serializable(with = StatusSerializer::class) val status: Status? = null,
@SerialName("start_index") val startIndex: UInt? = null,
@SerialName("max_count") val maxCount: UInt? = null,
)
@Serializable
data class OrganizationNames(
val ids: List
)
@Serializable
data class OrganizationProfileUri(
val id: ULong,
)
@Serializable
data class OrganizationReleases(
val id: ULong,
@SerialName("start_index") val startIndex: UInt? = null,
@SerialName("max_count") val maxCount: UInt? = null,
)
@Serializable
data class Releasers(
val permit: Permit,
@Serializable(with = StatusSerializer::class) val status: Status? = null,
@SerialName("start_index") val startIndex: UInt? = null,
@SerialName("max_count") val maxCount: UInt? = null,
)
@Serializable
data class ReleasesBatch(
val permit: Permit,
val ids: List,
@SerialName("request_next_private_data_key") val requestNextPrivateDataKey: Boolean? = null,
)
@Serializable
data class Releases(
val permit: Permit,
@SerialName("start_index") val startIndex: UInt? = null,
@SerialName("max_count") val maxCount: UInt? = null,
@SerialName("request_next_private_data_key") val requestNextPrivateDataKey: Boolean? = null,
)
}
@Serializable
data class QueryAnswer(
@SerialName("instance_id") val instanceId: UShort? = null,
@SerialName("num_tokens") val numTokens: Snip721Msgs.QueryAnswer.NumTokens? = null,
@SerialName("code_info") val codeInfo: CodeInfo? = null,
@SerialName("contract_by_release_id") val contractByReleaseId: ContractByReleaseId? = null,
@SerialName("organization_memberships") val organizationMemberships: List? = null,
@SerialName("organization_releases") val organizationReleases: List? = null,
val organizations: List? = null,
@SerialName("presigned_aws_url") val presignedAwsUrl: PresignedAwsUrl? = null,
@SerialName("releaser_id") val releaserId: ULong? = null,
val releasers: List? = null,
val releases: List? = null,
) {
@Serializable
data class ContractByReleaseId(val contract: ContractInfo?)
}
@Serializable
data class ReleaserBy(
val address: String? = null,
val id: ULong? = null,
)
@Serializable
data class CodeInfo(
@SerialName("code_id") val codeId: ULong,
@SerialName("code_hash") val codeHash: String,
)
@Serializable
data class OrganizationInfo(
val name: String,
val email: String,
@SerialName("mailing_address") val mailingAddress: String? = null,
val phone: String? = null,
)
@Serializable
data class ReleaserRegistrationForm(
val info: ReleaserInfo,
val address: String? = null,
)
@Serializable
data class ReleaserInfo(
@SerialName("first_name") val firstName: String,
@SerialName("last_name") val lastName: String,
val email: String,
val phone: String? = null,
@SerialName("mailing_address") val mailingAddress: String? = null,
)
@Serializable
data class Organization(
val id: ULong,
val info: OrganizationInfo?,
@SerialName("pending_info") val pendingInfo: OrganizationInfo?,
@Serializable(with = StatusSerializer::class) val status: Status,
@SerialName("profile_uri") val profileUri: PresignedAwsUrl?,
@SerialName("releaser_ids") val releaserIds: List,
)
@Serializable
data class BasicReleaserInfo(
val id: ULong,
@SerialName("first_name") val firstName: String,
@SerialName("last_name") val lastName: String,
val address: String,
@Serializable(with = StatusSerializer::class) val status: Status,
)
@Serializable
data class Releaser(
val id: ULong,
val address: String,
val info: ReleaserInfo?,
@SerialName("pending_info") val pendingInfo: ReleaserInfo?,
@Serializable(with = StatusSerializer::class) val status: Status,
)
@Serializable
data class Release(
val id: UInt,
val name: String,
val listed: Boolean,
@SerialName("organization_id") val organizationId: ULong,
@SerialName("organization_name") val organizationName: String,
@SerialName("product_dealer") val productDealer: ContractInfo,
@SerialName("royalty_dealer") val royaltyDealer: ContractInfo,
@SerialName("metadata_url") val metadataUrl: PresignedAwsUrl,
@SerialName("private_data_key") val privateDataKey: String?,
)
@Serializable
data class IdList(
val ids: List,
)
@Serializable
data class AwsConfig(
val domain: String,
val bucket: String,
val credentials: AwsCredentials,
)
@Serializable
data class AwsCredentials(
@SerialName("access_key") val accessKey: String,
val secret: String,
)
@Serializable
data class PresignedAwsUrl(
@SerialName("file_name") val fileName: String,
val domain: String,
val bucket: String,
@Serializable(with = StringPairListSerializer::class) @SerialName("canonical_query_params")
val canonicalQueryParams: List>,
val signature: String,
)
}
// Custom serializer for Pair
object StringPairSerializer : KSerializer> {
@OptIn(ExperimentalSerializationApi::class)
override val descriptor: SerialDescriptor = SerialDescriptor("Pair", listSerialDescriptor())
override fun serialize(encoder: Encoder, value: Pair) {
val (first, second) = value
encoder.encodeSerializableValue(
ListSerializer(String.serializer()), listOf(first, second)
)
}
override fun deserialize(decoder: Decoder): Pair {
val list = decoder.decodeSerializableValue(
ListSerializer(String.serializer())
)
return list[0] to list[1]
}
}
// Custom serializer for List>
object StringPairListSerializer : KSerializer>> {
override val descriptor: SerialDescriptor = ListSerializer(StringPairSerializer).descriptor
override fun serialize(encoder: Encoder, value: List>) {
encoder.encodeSerializableValue(ListSerializer(StringPairSerializer), value)
}
override fun deserialize(decoder: Decoder): List> {
return decoder.decodeSerializableValue(ListSerializer(StringPairSerializer))
}
}
@Serializable
enum class Status(val value: UByte) {
PENDING(0u), ENABLED(1u), DISABLED(2u),
}
object StatusSerializer : KSerializer {
override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor("Status", PrimitiveKind.BYTE)
override fun serialize(encoder: Encoder, value: Status) {
encoder.encodeByte(value.value.toByte())
}
override fun deserialize(decoder: Decoder): Status {
val value = decoder.decodeByte()
return Status.entries.firstOrNull { it.value.toByte() == value }
?: throw SerializationException("Unknown value for Status: $value")
}
}