Skip to content

Commit

Permalink
Add support for Platform Airdrop schedule mode
Browse files Browse the repository at this point in the history
  • Loading branch information
PabloSzx committed Dec 21, 2023
1 parent def1710 commit 4f9cfe2
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .changeset/loud-lies-juggle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@soundxyz/sdk': major
---

Add support for Platform Airdrop schedule mode
20 changes: 18 additions & 2 deletions packages/sdk/src/contract/edition-v2/read/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,23 @@ export function createTieredEditionArgs({
})
}

const mode: number = (() => {
switch (mintConfig.mode) {
case 'DEFAULT': {
return 0
}
case 'VERIFY_MERKLE': {
return 1
}
case 'VERIFY_SIGNATURE': {
return 2
}
case 'PLATFORM_AIRDROP': {
return 3
}
}
})()

contractCalls.push({
contractAddress: SUPER_MINTER_V2_ADDRESS,
calldata: encodeFunctionData({
Expand All @@ -115,8 +132,7 @@ export function createTieredEditionArgs({
affiliateMerkleRoot: mintConfig.affiliateMerkleRoot,
tier: mintConfig.tier,
platform: mintConfig.platform,
// TODO: add better typesafety here
mode: mintConfig.mode === 'DEFAULT' ? 0 : mintConfig.mode === 'VERIFY_MERKLE' ? 1 : 2,
mode,
merkleRoot: mintConfig.mode === 'VERIFY_MERKLE' ? mintConfig.merkleRoot : EMPTY_MERKLE_ROOT,
},
],
Expand Down
56 changes: 49 additions & 7 deletions packages/sdk/src/contract/edition-v2/read/info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,16 @@ export type MerkleScheduleConfig = ScheduleConfigBase & {
export type SignatureScheduleConfig = ScheduleConfigBase & {
mode: 'VERIFY_SIGNATURE'
}
export type MinterScheduleConfig = DefaultScheduleConfig | MerkleScheduleConfig | SignatureScheduleConfig

export type PlatformAirdropScheduleConfig = ScheduleConfigBase & {
mode: 'PLATFORM_AIRDROP'
}

export type MinterScheduleConfig =
| DefaultScheduleConfig
| MerkleScheduleConfig
| SignatureScheduleConfig
| PlatformAirdropScheduleConfig

export type ScheduleBase = ScheduleConfigBase & {
minterAddress: Address
Expand All @@ -119,8 +128,11 @@ export type MerkleSchedule = ScheduleBase & {
export type SignatureSchedule = ScheduleBase & {
mode: 'VERIFY_SIGNATURE'
}
export type PlatformAirdropSchedule = ScheduleBase & {
mode: 'PLATFORM_AIRDROP'
}

export type SuperMinterSchedule = DefaultSchedule | MerkleSchedule | SignatureSchedule
export type SuperMinterSchedule = DefaultSchedule | MerkleSchedule | SignatureSchedule | PlatformAirdropSchedule

export type GetMintingSchedulesParams = {
editionAddress: Address
Expand All @@ -146,11 +158,41 @@ export async function mintingSchedules<Client extends Pick<PublicClient, 'readCo
args: [editionAddress],
})
.then((schedules) =>
schedules.map((schedule) => ({
...schedule,
mode: schedule.mode === 0 ? 'DEFAULT' : schedule.mode === 1 ? 'VERIFY_MERKLE' : 'VERIFY_SIGNATURE',
minterAddress: address,
})),
schedules.map((schedule): SuperMinterSchedule => {
const scheduleData = {
...schedule,
minterAddress: address,
} satisfies Omit<SuperMinterSchedule, 'mode'>
switch (schedule.mode) {
case 0: {
return {
...scheduleData,
mode: 'DEFAULT',
}
}
case 1: {
return {
...scheduleData,
mode: 'VERIFY_MERKLE',
}
}
case 2: {
return {
...scheduleData,
mode: 'VERIFY_SIGNATURE',
}
}
case 3: {
return {
...scheduleData,
mode: 'PLATFORM_AIRDROP',
}
}
default: {
throw Error(`Unsupported schedule mode ${schedule.mode}`)
}
}
}),
)

const activeSchedules = schedules.filter((mintSchedule) => {
Expand Down

0 comments on commit 4f9cfe2

Please sign in to comment.