Skip to content

chore: increase timeout in github action #403

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 9 commits into from
5 changes: 5 additions & 0 deletions .changeset/eleven-dryers-turn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rabbitholegg/questdk-plugin-zora": minor
---

add `create` action to zora plugin
2 changes: 1 addition & 1 deletion .github/workflows/on-push-to-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
name: Release
needs: verify
runs-on: ubuntu-latest
timeout-minutes: 15
timeout-minutes: 20

steps:
- name: Clone repository
Expand Down
68 changes: 63 additions & 5 deletions packages/zora/src/Zora.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
import { getDynamicNameParams, getMintIntent, mint, simulateMint } from './Zora'
import { failingTestCases, passingTestCases } from './test-setup'
import {
create,
getDynamicNameParams,
getMintIntent,
mint,
simulateMint,
} from './Zora'
import {
failingTestCasesCreate,
failingTestCasesMint,
passingTestCasesCreate,
passingTestCasesMint,
} from './test-setup'
import {
EXPECTED_ENCODED_DATA_721,
EXPECTED_ENCODED_DATA_1155,
Expand All @@ -16,7 +27,7 @@ import { type Address, parseEther } from 'viem'
import { describe, expect, test, vi } from 'vitest'

describe('Given the zora plugin', () => {
describe('When handling the mint', () => {
describe('When handling the mint action', () => {
describe('should return a valid action filter', () => {
test('when making a valid mint action', async () => {
const filter = await mint({
Expand Down Expand Up @@ -44,7 +55,7 @@ describe('Given the zora plugin', () => {
})

describe('should pass filter with valid transactions', () => {
passingTestCases.forEach((testCase) => {
passingTestCasesMint.forEach((testCase) => {
const { transaction, params, description } = testCase
test(description, async () => {
const filter = await mint(params)
Expand All @@ -54,7 +65,7 @@ describe('Given the zora plugin', () => {
})

describe('should not pass filter with invalid transactions', () => {
failingTestCases.forEach((testCase) => {
failingTestCasesMint.forEach((testCase) => {
const { transaction, params, description } = testCase
test(description, async () => {
const filter = await mint(params)
Expand All @@ -63,6 +74,53 @@ describe('Given the zora plugin', () => {
})
})
})

describe('When handling the create action', () => {
describe('should return a valid action filter', () => {
test('when making a valid create action', async () => {
const filter = await create({
chainId: 1,
})
expect(filter).toBeTypeOf('object')
expect(Number(filter.chainId)).toBe(1)
if (typeof filter.to === 'string') {
expect(filter.to).toMatch(/^0x[a-fA-F0-9]{40}$/)
} else {
// if to is an object, it should have a logical operator as the only key
expect(filter.to).toBeTypeOf('object')
expect(Object.keys(filter.to)).toHaveLength(1)
expect(
['$or', '$and'].some((prop) =>
Object.hasOwnProperty.call(filter.to, prop),
),
).to.be.true
expect(Object.values(filter.to)[0]).to.satisfy((arr: string[]) =>
arr.every((val) => val.match(/^0x[a-fA-F0-9]{40}$/)),
)
}
})
})

describe('should pass filter with valid transactions', () => {
passingTestCasesCreate.forEach((testCase) => {
const { transaction, params, description } = testCase
test(description, async () => {
const filter = await create(params)
expect(apply(transaction, filter)).to.be.true
})
})
})

describe('should not pass filter with invalid transactions', () => {
failingTestCasesCreate.forEach((testCase) => {
const { transaction, params, description } = testCase
test(description, async () => {
const filter = await create(params)
expect(apply(transaction, filter)).to.be.false
})
})
})
})
})

describe('Given the getMintIntent function', () => {
Expand Down
17 changes: 17 additions & 0 deletions packages/zora/src/Zora.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
CREATE_CONTRACT_ABI,
FUNCTION_SELECTORS,
UNIVERSAL_MINTER_ABI,
ZORA_MINTER_ABI_721,
Expand All @@ -8,10 +9,12 @@ import {
import { CHAIN_ID_ARRAY } from './chain-ids'
import {
FIXED_PRICE_SALE_STRATS,
ZORA_1155_FACTORY,
ZORA_DEPLOYER_ADDRESS,
} from './contract-addresses'
import {
type MintActionParams,
type CreateActionParams,
type TransactionFilter,
compressJson,
} from '@rabbitholegg/questdk'
Expand Down Expand Up @@ -42,6 +45,20 @@ import {
toHex,
} from 'viem'

export const create = async (
create: CreateActionParams,
): Promise<TransactionFilter> => {
const { chainId, contractAddress } = create

return compressJson({
chainId,
to: contractAddress ?? ZORA_1155_FACTORY,
input: {
$abi: CREATE_CONTRACT_ABI,
},
})
}

export const mint = async (
mint: MintActionParams,
): Promise<TransactionFilter> => {
Expand Down
37 changes: 37 additions & 0 deletions packages/zora/src/abi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,43 @@ export const UNIVERSAL_MINTER_ABI = [
},
] // universal batch mint

export const CREATE_CONTRACT_ABI = [
{
inputs: [
{ internalType: 'string', name: 'newContractURI', type: 'string' },
{ internalType: 'string', name: 'name', type: 'string' },
{
components: [
{
internalType: 'uint32',
name: 'royaltyMintSchedule',
type: 'uint32',
},
{ internalType: 'uint32', name: 'royaltyBPS', type: 'uint32' },
{
internalType: 'address',
name: 'royaltyRecipient',
type: 'address',
},
],
internalType: 'struct ICreatorRoyaltiesControl.RoyaltyConfiguration',
name: 'defaultRoyaltyConfiguration',
type: 'tuple',
},
{
internalType: 'address payable',
name: 'defaultAdmin',
type: 'address',
},
{ internalType: 'bytes[]', name: 'setupActions', type: 'bytes[]' },
],
name: 'createContract',
outputs: [{ internalType: 'address', name: '', type: 'address' }],
stateMutability: 'nonpayable',
type: 'function',
},
]

export const FUNCTION_SELECTORS = [
'359f1302', // mint (1155)
'731133e9', // mint (Legacy 1155)
Expand Down
2 changes: 2 additions & 0 deletions packages/zora/src/contract-addresses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ export const FIXED_PRICE_SALE_STRATS: { [chainId: number]: Address } = {
[Chains.ARBITRUM_ONE]: '0x1Cd1C1f3b8B779B50Db23155F2Cb244FCcA06B21',
}

export const ZORA_1155_FACTORY = '0x777777c338d93e2c7adf08d102d45ca7cc4ed021'

// for referrals
export const ZORA_DEPLOYER_ADDRESS =
'0xe3bBA2A4F8E0F5C32EF5097F988a4d88075C8B48'
2 changes: 2 additions & 0 deletions packages/zora/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
} from '@rabbitholegg/questdk-plugin-utils'

import {
create,
getDynamicNameParams,
getFees,
getMintIntent,
Expand All @@ -21,6 +22,7 @@ export const Zora: IActionPlugin = {
getSupportedTokenAddresses,
getSupportedChainIds,
bridge: async () => new PluginActionNotImplementedError(),
create,
swap: async () => new PluginActionNotImplementedError(),
mint,
getDynamicNameParams,
Expand Down
20 changes: 18 additions & 2 deletions packages/zora/src/test-setup.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import {
BASIC_PURCHASE,
BATCH_MINT_ARB,
CREATE_COLLECTION_BASE,
CREATE_COLLECTION_ZORA,
LAYER_ZERO_MINT,
MINT_BATCH_WITHOUT_FEES,
MINT_WITH_REWARDS,
Expand All @@ -9,7 +11,7 @@ import {
import { createTestCase } from '@rabbitholegg/questdk-plugin-utils'
import { getAddress } from 'viem'

export const passingTestCases = [
export const passingTestCasesMint = [
createTestCase(BASIC_PURCHASE, 'when doing a basic purchase'),
createTestCase(MINT_WITH_REWARDS, 'Minting with rewards'),
createTestCase(MINT_WITH_REWARDS_1155, 'Minting with rewards 1155'),
Expand All @@ -29,7 +31,7 @@ export const passingTestCases = [
createTestCase(LAYER_ZERO_MINT, 'using layer zero mint'),
]

export const failingTestCases = [
export const failingTestCasesMint = [
createTestCase(BASIC_PURCHASE, 'when chainId is incorrect', {
chainId: 1,
}),
Expand Down Expand Up @@ -60,3 +62,17 @@ export const failingTestCases = [
},
),
]

export const passingTestCasesCreate = [
createTestCase(CREATE_COLLECTION_BASE, 'when creating a collection on BASE'),
createTestCase(CREATE_COLLECTION_ZORA, 'when creating a collection on Zora'),
]

export const failingTestCasesCreate = [
createTestCase(CREATE_COLLECTION_BASE, 'when chainId is incorrect', {
chainId: 1,
}),
createTestCase(CREATE_COLLECTION_ZORA, 'when contractAddress is incorrect', {
contractAddress: '0x4f330940159fB3368F5b06b34212C0cDB4e2C032',
}),
]
35 changes: 34 additions & 1 deletion packages/zora/src/test-transactions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { type MintActionParams } from '@rabbitholegg/questdk'
import type {
MintActionParams,
CreateActionParams,
} from '@rabbitholegg/questdk'
import { Chains, type TestParams } from '@rabbitholegg/questdk-plugin-utils'

export const BASIC_PURCHASE: TestParams<MintActionParams> = {
Expand Down Expand Up @@ -107,3 +110,33 @@ export const LAYER_ZERO_MINT: TestParams<MintActionParams> = {
contractAddress: '0x323c74b3dae9844c113d41e9c3db2743c500a26d',
},
}

export const CREATE_COLLECTION_BASE: TestParams<CreateActionParams> = {
transaction: {
chainId: 8453, // BASE
from: '0xec8287faef6cd7fc9887be6e40d6abc0ccb29d2f',
to: '0x777777c338d93e2c7adf08d102d45ca7cc4ed021',
hash: '0x3ae17f5201c98cdcff8721f4fbf641d19356b00332f605e9d19d915b1e6a1be3',
input:
'0x0582823a00000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000160000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001f4000000000000000000000000ec8287faef6cd7fc9887be6e40d6abc0ccb29d2f000000000000000000000000ec8287faef6cd7fc9887be6e40d6abc0ccb29d2f00000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000042697066733a2f2f6261666b726569656435716f7a686578736678376e326a33366b72337573776d69766d7a6b326b686c7263366d796f61726f7a787861787662636d000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c42617365f09f94b5f09fa5ba0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000240000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000003a000000000000000000000000000000000000000000000000000000000000005400000000000000000000000000000000000000000000000000000000000000024e72878b400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e4674cbae60000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000ffffffffffffffff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000042697066733a2f2f6261666b726569677070737336623676346536346c61787165666c6e6e6c74346c6f6a6b3773676377767237347578707a6f686d627769756a3371000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000084afed7e9e0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001f4000000000000000000000000ec8287faef6cd7fc9887be6e40d6abc0ccb29d2f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000648ec998a0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000004e2516a2c207e84a1839755675dfd8ef6302f0a0000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000164d904b94a000000000000000000000000000000000000000000000000000000000000000100000000000000000000000004e2516a2c207e84a1839755675dfd8ef6302f0a000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000c434db7eee0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000006644013400000000000000000000000000000000000000000000000000000000666b8e3400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ec8287faef6cd7fc9887be6e40d6abc0ccb29d2f000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c4c238d1ee000000000000000000000000ec8287faef6cd7fc9887be6e40d6abc0ccb29d2f0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
value: '0',
},
params: {
chainId: Chains.BASE,
},
}

export const CREATE_COLLECTION_ZORA: TestParams<CreateActionParams> = {
transaction: {
chainId: 7777777, // Zora
from: '0x561db962f06B295cE2A95f31e81Ca5839b7CAfdB',
to: '0x777777C338d93e2C7adf08D102d45CA7CC4Ed021',
hash: '0x391c204dbc67500ef79d460e7ad9870c955c691bef9c5dce76fe6731d3bf5327',
input:
'0x0582823a00000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000160000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001f4000000000000000000000000561db962f06b295ce2a95f31e81ca5839b7cafdb000000000000000000000000561db962f06b295ce2a95f31e81ca5839b7cafdb00000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000042697066733a2f2f6261666b72656966366636736e786c7770767a6f36377376707a676c6d716b7335686b77353268706973626f736d646a746977616c366771633571000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000367686b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000240000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000003a000000000000000000000000000000000000000000000000000000000000005400000000000000000000000000000000000000000000000000000000000000024e72878b400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e4674cbae60000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000ffffffffffffffff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000042697066733a2f2f6261666b726569676f7472736c37756c65626c373776356a336c7575756c7678356e356879737a626f74657874666b6d6f637836636f7a36746671000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000084afed7e9e0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001f4000000000000000000000000561db962f06b295ce2a95f31e81ca5839b7cafdb0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000648ec998a0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000004e2516a2c207e84a1839755675dfd8ef6302f0a0000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000164d904b94a000000000000000000000000000000000000000000000000000000000000000100000000000000000000000004e2516a2c207e84a1839755675dfd8ef6302f0a000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000c434db7eee0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000006644203100000000000000000000000000000000000000000000000000000000666bad3100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002cd9760ba5000000000000000000000000000561db962f06b295ce2a95f31e81ca5839b7cafdb000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c4c238d1ee000000000000000000000000561db962f06b295ce2a95f31e81ca5839b7cafdb0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
value: '0',
},
params: {
chainId: Chains.ZORA,
},
}
Loading