@@ -10,14 +10,21 @@ import {
1010 PremintConfigWithVersion ,
1111} from "@zoralabs/protocol-deployments" ;
1212import { PremintSignatureGetResponse } from "./premint-api-client" ;
13+ import { ContractCreationConfigOrAddress } from "./contract-types" ;
1314
1415export const convertCollectionFromApi = (
1516 collection : PremintSignatureGetResponse [ "collection" ] ,
16- ) : ContractCreationConfig => ( {
17- ...collection ,
18- contractAdmin : collection . contractAdmin as Address ,
19- additionalAdmins : [ ] ,
20- } ) ;
17+ ) : ContractCreationConfig | undefined => {
18+ if ( ! collection ) return undefined ;
19+
20+ return {
21+ additionalAdmins :
22+ ( collection . additionalAdmins as Address [ ] | undefined ) || [ ] ,
23+ contractAdmin : collection . contractAdmin as Address ,
24+ contractName : collection . contractName ,
25+ contractURI : collection . contractURI ,
26+ } ;
27+ } ;
2128
2229/**
2330 * Convert server to on-chain types for a premint
@@ -82,6 +89,7 @@ export const convertGetPremintApiResponse = (
8289) => ( {
8390 ...convertPremintFromApi ( response . premint ) ,
8491 collection : convertCollectionFromApi ( response . collection ) ,
92+ collectionAddress : response . collection_address as Address ,
8593 signature : response . signature as Hex ,
8694} ) ;
8795
@@ -143,20 +151,24 @@ export type PremintSignatureResponse =
143151 */
144152export const encodePostSignatureInput = < T extends PremintConfigVersion > ( {
145153 collection,
154+ collectionAddress,
146155 premintConfigVersion,
147156 premintConfig,
148157 signature,
149158 chainId,
150159} : {
151- collection : ContractCreationConfig ;
152160 signature : Hex ;
153161 chainId : number ;
154- } & PremintConfigWithVersion < T > ) : PremintSignatureRequestBody => ( {
162+ } & PremintConfigWithVersion < T > &
163+ ContractCreationConfigOrAddress ) : PremintSignatureRequestBody => ( {
155164 premint : encodePremintForAPI ( {
156165 premintConfig,
157166 premintConfigVersion,
158167 } ) ,
159168 signature,
160- collection,
169+ collection : collection as
170+ | PremintSignatureRequestBody [ "collection" ]
171+ | undefined ,
172+ collection_address : collectionAddress ,
161173 chain_name : networkConfigByChain [ chainId ] ! . zoraBackendChainName ,
162174} ) ;
0 commit comments