Skip to content

Commit

Permalink
Implements Locked transfer
Browse files Browse the repository at this point in the history
  • Loading branch information
ajamaica committed Jul 20, 2023
1 parent 9b97e6a commit e40ea62
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions lib/src/main/java/com/metaplex/lib/modules/nfts/DelegateType.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,52 +3,64 @@ package com.metaplex.lib.modules.nfts
import com.metaplex.lib.experimental.jen.tokenmetadata.DelegateArgs
import com.metaplex.lib.experimental.jen.tokenmetadata.MetadataDelegateRole
import com.metaplex.lib.experimental.jen.tokenmetadata.TokenDelegateRole
import com.solana.core.PublicKey

enum class TokenDelegateType{
StandardV1,
TransferV1,
LockedTransferV1,
SaleV1,
UtilityV1,
StakingV1
}

enum class MetadataDelegateType {
CollectionV1,
UpdateV1
DataV1,
ProgrammableConfigV1
}

val tokenDelegateRoleMap = mapOf(
TokenDelegateType.StandardV1 to TokenDelegateRole.Standard,
TokenDelegateType.TransferV1 to TokenDelegateRole.Transfer,
TokenDelegateType.LockedTransferV1 to TokenDelegateRole.LockedTransfer,
TokenDelegateType.SaleV1 to TokenDelegateRole.Sale,
TokenDelegateType.UtilityV1 to TokenDelegateRole.Utility,
TokenDelegateType.StakingV1 to TokenDelegateRole.Staking,
)

val metadataDelegateRoleMap = mapOf(
MetadataDelegateType.CollectionV1 to MetadataDelegateRole.Collection,
MetadataDelegateType.UpdateV1 to MetadataDelegateRole.Update,
)
MetadataDelegateType.DataV1 to MetadataDelegateRole.Data,
MetadataDelegateType.ProgrammableConfigV1 to MetadataDelegateRole.ProgrammableConfig,
)

val metadataDelegateSeedMap = mapOf(
MetadataDelegateRole.Authority to "authority_delegate",
MetadataDelegateRole.AuthorityItem to "authority_item_delegate",
MetadataDelegateRole.Collection to "collection_delegate",
MetadataDelegateRole.Use to "use_delegate",
MetadataDelegateRole.Update to "update_delegate",
)
MetadataDelegateRole.Data to "data_delegate",
MetadataDelegateRole.ProgrammableConfig to "programmable_config_delegate",
MetadataDelegateRole.DataItem to "data_item_delegate",
MetadataDelegateRole.CollectionItem to "collection_item_delegate",
MetadataDelegateRole.ProgrammableConfigItem to "prog_config_item_delegate",
)

val metadataDelegateTypeCustomDataMap = mapOf(
MetadataDelegateType.CollectionV1 to false,
MetadataDelegateType.UpdateV1 to false,
)
MetadataDelegateType.DataV1 to false,
MetadataDelegateType.ProgrammableConfigV1 to false,
)

val tokenDelegateTypeCustomDataMap = mapOf(
TokenDelegateType.StandardV1 to true,
TokenDelegateType.TransferV1 to true,
TokenDelegateType.SaleV1 to true,
TokenDelegateType.UtilityV1 to true,
TokenDelegateType.StakingV1 to true,
)
TokenDelegateType.LockedTransferV1 to true,

)

fun getTokenDelegateRole(type: TokenDelegateType): TokenDelegateRole
= tokenDelegateRoleMap[type] ?: throw Exception("UnreachableCaseError")
Expand All @@ -68,6 +80,7 @@ fun getDefaultDelegateArgs(type: TokenDelegateType): DelegateArgs {
TokenDelegateType.SaleV1 -> DelegateArgs.SaleV1(1u, null)
TokenDelegateType.UtilityV1 -> DelegateArgs.UtilityV1(1u, null)
TokenDelegateType.StakingV1 -> DelegateArgs.StakingV1(1u, null)
TokenDelegateType.LockedTransferV1 -> throw Exception("Not implemented")
}
}

Expand Down

0 comments on commit e40ea62

Please sign in to comment.