@adland/data 0.11.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/index.cjs +99 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +457 -3
- package/dist/index.d.ts +457 -3
- package/dist/index.js +98 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -165,6 +165,110 @@ type MiniAppAd = {
|
|
|
165
165
|
metadata: MiniAppAdMetadata;
|
|
166
166
|
};
|
|
167
167
|
|
|
168
|
+
declare const tokenAd: AdDefinition<z.ZodObject<{
|
|
169
|
+
address: z.ZodString;
|
|
170
|
+
chainId: z.ZodNumber;
|
|
171
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
172
|
+
name: z.ZodOptional<z.ZodString>;
|
|
173
|
+
symbol: z.ZodOptional<z.ZodString>;
|
|
174
|
+
decimals: z.ZodOptional<z.ZodNumber>;
|
|
175
|
+
logoURI: z.ZodOptional<z.ZodString>;
|
|
176
|
+
}, z.core.$strip>> & {
|
|
177
|
+
process: (input: {
|
|
178
|
+
address: string;
|
|
179
|
+
chainId: number;
|
|
180
|
+
}) => Promise<{
|
|
181
|
+
data: {
|
|
182
|
+
address: string;
|
|
183
|
+
chainId: number;
|
|
184
|
+
};
|
|
185
|
+
metadata: {
|
|
186
|
+
name?: string | undefined;
|
|
187
|
+
symbol?: string | undefined;
|
|
188
|
+
decimals?: number | undefined;
|
|
189
|
+
logoURI?: string | undefined;
|
|
190
|
+
} | undefined;
|
|
191
|
+
}>;
|
|
192
|
+
safeProcess: (input: {
|
|
193
|
+
address: string;
|
|
194
|
+
chainId: number;
|
|
195
|
+
}) => Promise<{
|
|
196
|
+
success: boolean;
|
|
197
|
+
data?: {
|
|
198
|
+
address: string;
|
|
199
|
+
chainId: number;
|
|
200
|
+
} | undefined;
|
|
201
|
+
metadata?: {
|
|
202
|
+
name?: string | undefined;
|
|
203
|
+
symbol?: string | undefined;
|
|
204
|
+
decimals?: number | undefined;
|
|
205
|
+
logoURI?: string | undefined;
|
|
206
|
+
} | undefined;
|
|
207
|
+
error?: z.ZodError | string;
|
|
208
|
+
}>;
|
|
209
|
+
};
|
|
210
|
+
type TokenAdData = z.infer<typeof tokenAd.data>;
|
|
211
|
+
type TokenAdMetadata = z.infer<NonNullable<typeof tokenAd.metadata>>;
|
|
212
|
+
type TokenAd = {
|
|
213
|
+
type: "token";
|
|
214
|
+
data: TokenAdData;
|
|
215
|
+
metadata: TokenAdMetadata;
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
declare const farcasterProfileAd: AdDefinition<z.ZodObject<{
|
|
219
|
+
fid: z.ZodString;
|
|
220
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
221
|
+
pfpUrl: z.ZodOptional<z.ZodString>;
|
|
222
|
+
bio: z.ZodOptional<z.ZodString>;
|
|
223
|
+
username: z.ZodOptional<z.ZodString>;
|
|
224
|
+
displayName: z.ZodOptional<z.ZodString>;
|
|
225
|
+
followers: z.ZodOptional<z.ZodNumber>;
|
|
226
|
+
following: z.ZodOptional<z.ZodNumber>;
|
|
227
|
+
pro: z.ZodOptional<z.ZodBoolean>;
|
|
228
|
+
}, z.core.$strip>> & {
|
|
229
|
+
process: (input: {
|
|
230
|
+
fid: string;
|
|
231
|
+
}) => Promise<{
|
|
232
|
+
data: {
|
|
233
|
+
fid: string;
|
|
234
|
+
};
|
|
235
|
+
metadata: {
|
|
236
|
+
pfpUrl?: string | undefined;
|
|
237
|
+
bio?: string | undefined;
|
|
238
|
+
username?: string | undefined;
|
|
239
|
+
displayName?: string | undefined;
|
|
240
|
+
followers?: number | undefined;
|
|
241
|
+
following?: number | undefined;
|
|
242
|
+
pro?: boolean | undefined;
|
|
243
|
+
} | undefined;
|
|
244
|
+
}>;
|
|
245
|
+
safeProcess: (input: {
|
|
246
|
+
fid: string;
|
|
247
|
+
}) => Promise<{
|
|
248
|
+
success: boolean;
|
|
249
|
+
data?: {
|
|
250
|
+
fid: string;
|
|
251
|
+
} | undefined;
|
|
252
|
+
metadata?: {
|
|
253
|
+
pfpUrl?: string | undefined;
|
|
254
|
+
bio?: string | undefined;
|
|
255
|
+
username?: string | undefined;
|
|
256
|
+
displayName?: string | undefined;
|
|
257
|
+
followers?: number | undefined;
|
|
258
|
+
following?: number | undefined;
|
|
259
|
+
pro?: boolean | undefined;
|
|
260
|
+
} | undefined;
|
|
261
|
+
error?: z.ZodError | string;
|
|
262
|
+
}>;
|
|
263
|
+
};
|
|
264
|
+
type FarcasterProfileAdData = z.infer<typeof farcasterProfileAd.data>;
|
|
265
|
+
type FarcasterProfileAdMetadata = z.infer<NonNullable<typeof farcasterProfileAd.metadata>>;
|
|
266
|
+
type FarcasterProfileAd = {
|
|
267
|
+
type: "farcasterProfile";
|
|
268
|
+
data: FarcasterProfileAdData;
|
|
269
|
+
metadata: FarcasterProfileAdMetadata;
|
|
270
|
+
};
|
|
271
|
+
|
|
168
272
|
/**
|
|
169
273
|
* Ad Definition type
|
|
170
274
|
* Represents a data contract + behavior for an ad type
|
|
@@ -248,7 +352,7 @@ declare function safeProcessAd<TData extends z.ZodTypeAny, TMetadata extends z.Z
|
|
|
248
352
|
/**
|
|
249
353
|
* Union type for all complete ad structures with type, data, and optional metadata
|
|
250
354
|
*/
|
|
251
|
-
type AdData = CastAd | LinkAd | MiniAppAd;
|
|
355
|
+
type AdData = CastAd | LinkAd | MiniAppAd | TokenAd | FarcasterProfileAd;
|
|
252
356
|
/**
|
|
253
357
|
* Registry of all ad definitions
|
|
254
358
|
* Each entry is an AdDefinition object
|
|
@@ -365,8 +469,96 @@ declare const ads: {
|
|
|
365
469
|
error?: z.ZodError | string;
|
|
366
470
|
}>;
|
|
367
471
|
};
|
|
472
|
+
readonly token: AdDefinition<z.ZodObject<{
|
|
473
|
+
address: z.ZodString;
|
|
474
|
+
chainId: z.ZodNumber;
|
|
475
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
476
|
+
name: z.ZodOptional<z.ZodString>;
|
|
477
|
+
symbol: z.ZodOptional<z.ZodString>;
|
|
478
|
+
decimals: z.ZodOptional<z.ZodNumber>;
|
|
479
|
+
logoURI: z.ZodOptional<z.ZodString>;
|
|
480
|
+
}, z.core.$strip>> & {
|
|
481
|
+
process: (input: {
|
|
482
|
+
address: string;
|
|
483
|
+
chainId: number;
|
|
484
|
+
}) => Promise<{
|
|
485
|
+
data: {
|
|
486
|
+
address: string;
|
|
487
|
+
chainId: number;
|
|
488
|
+
};
|
|
489
|
+
metadata: {
|
|
490
|
+
name?: string | undefined;
|
|
491
|
+
symbol?: string | undefined;
|
|
492
|
+
decimals?: number | undefined;
|
|
493
|
+
logoURI?: string | undefined;
|
|
494
|
+
} | undefined;
|
|
495
|
+
}>;
|
|
496
|
+
safeProcess: (input: {
|
|
497
|
+
address: string;
|
|
498
|
+
chainId: number;
|
|
499
|
+
}) => Promise<{
|
|
500
|
+
success: boolean;
|
|
501
|
+
data?: {
|
|
502
|
+
address: string;
|
|
503
|
+
chainId: number;
|
|
504
|
+
} | undefined;
|
|
505
|
+
metadata?: {
|
|
506
|
+
name?: string | undefined;
|
|
507
|
+
symbol?: string | undefined;
|
|
508
|
+
decimals?: number | undefined;
|
|
509
|
+
logoURI?: string | undefined;
|
|
510
|
+
} | undefined;
|
|
511
|
+
error?: z.ZodError | string;
|
|
512
|
+
}>;
|
|
513
|
+
};
|
|
514
|
+
readonly farcasterProfile: AdDefinition<z.ZodObject<{
|
|
515
|
+
fid: z.ZodString;
|
|
516
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
517
|
+
pfpUrl: z.ZodOptional<z.ZodString>;
|
|
518
|
+
bio: z.ZodOptional<z.ZodString>;
|
|
519
|
+
username: z.ZodOptional<z.ZodString>;
|
|
520
|
+
displayName: z.ZodOptional<z.ZodString>;
|
|
521
|
+
followers: z.ZodOptional<z.ZodNumber>;
|
|
522
|
+
following: z.ZodOptional<z.ZodNumber>;
|
|
523
|
+
pro: z.ZodOptional<z.ZodBoolean>;
|
|
524
|
+
}, z.core.$strip>> & {
|
|
525
|
+
process: (input: {
|
|
526
|
+
fid: string;
|
|
527
|
+
}) => Promise<{
|
|
528
|
+
data: {
|
|
529
|
+
fid: string;
|
|
530
|
+
};
|
|
531
|
+
metadata: {
|
|
532
|
+
pfpUrl?: string | undefined;
|
|
533
|
+
bio?: string | undefined;
|
|
534
|
+
username?: string | undefined;
|
|
535
|
+
displayName?: string | undefined;
|
|
536
|
+
followers?: number | undefined;
|
|
537
|
+
following?: number | undefined;
|
|
538
|
+
pro?: boolean | undefined;
|
|
539
|
+
} | undefined;
|
|
540
|
+
}>;
|
|
541
|
+
safeProcess: (input: {
|
|
542
|
+
fid: string;
|
|
543
|
+
}) => Promise<{
|
|
544
|
+
success: boolean;
|
|
545
|
+
data?: {
|
|
546
|
+
fid: string;
|
|
547
|
+
} | undefined;
|
|
548
|
+
metadata?: {
|
|
549
|
+
pfpUrl?: string | undefined;
|
|
550
|
+
bio?: string | undefined;
|
|
551
|
+
username?: string | undefined;
|
|
552
|
+
displayName?: string | undefined;
|
|
553
|
+
followers?: number | undefined;
|
|
554
|
+
following?: number | undefined;
|
|
555
|
+
pro?: boolean | undefined;
|
|
556
|
+
} | undefined;
|
|
557
|
+
error?: z.ZodError | string;
|
|
558
|
+
}>;
|
|
559
|
+
};
|
|
368
560
|
};
|
|
369
|
-
declare const adTypes: readonly ["link", "cast", "miniapp"];
|
|
561
|
+
declare const adTypes: readonly ["link", "cast", "miniapp", "token", "farcasterProfile"];
|
|
370
562
|
/**
|
|
371
563
|
* Type for ad definition keys
|
|
372
564
|
*/
|
|
@@ -482,6 +674,92 @@ declare function getAd(type: AdType): (AdDefinition<z.ZodObject<{
|
|
|
482
674
|
} | undefined;
|
|
483
675
|
error?: z.ZodError | string;
|
|
484
676
|
}>;
|
|
677
|
+
}) | (AdDefinition<z.ZodObject<{
|
|
678
|
+
address: z.ZodString;
|
|
679
|
+
chainId: z.ZodNumber;
|
|
680
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
681
|
+
name: z.ZodOptional<z.ZodString>;
|
|
682
|
+
symbol: z.ZodOptional<z.ZodString>;
|
|
683
|
+
decimals: z.ZodOptional<z.ZodNumber>;
|
|
684
|
+
logoURI: z.ZodOptional<z.ZodString>;
|
|
685
|
+
}, z.core.$strip>> & {
|
|
686
|
+
process: (input: {
|
|
687
|
+
address: string;
|
|
688
|
+
chainId: number;
|
|
689
|
+
}) => Promise<{
|
|
690
|
+
data: {
|
|
691
|
+
address: string;
|
|
692
|
+
chainId: number;
|
|
693
|
+
};
|
|
694
|
+
metadata: {
|
|
695
|
+
name?: string | undefined;
|
|
696
|
+
symbol?: string | undefined;
|
|
697
|
+
decimals?: number | undefined;
|
|
698
|
+
logoURI?: string | undefined;
|
|
699
|
+
} | undefined;
|
|
700
|
+
}>;
|
|
701
|
+
safeProcess: (input: {
|
|
702
|
+
address: string;
|
|
703
|
+
chainId: number;
|
|
704
|
+
}) => Promise<{
|
|
705
|
+
success: boolean;
|
|
706
|
+
data?: {
|
|
707
|
+
address: string;
|
|
708
|
+
chainId: number;
|
|
709
|
+
} | undefined;
|
|
710
|
+
metadata?: {
|
|
711
|
+
name?: string | undefined;
|
|
712
|
+
symbol?: string | undefined;
|
|
713
|
+
decimals?: number | undefined;
|
|
714
|
+
logoURI?: string | undefined;
|
|
715
|
+
} | undefined;
|
|
716
|
+
error?: z.ZodError | string;
|
|
717
|
+
}>;
|
|
718
|
+
}) | (AdDefinition<z.ZodObject<{
|
|
719
|
+
fid: z.ZodString;
|
|
720
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
721
|
+
pfpUrl: z.ZodOptional<z.ZodString>;
|
|
722
|
+
bio: z.ZodOptional<z.ZodString>;
|
|
723
|
+
username: z.ZodOptional<z.ZodString>;
|
|
724
|
+
displayName: z.ZodOptional<z.ZodString>;
|
|
725
|
+
followers: z.ZodOptional<z.ZodNumber>;
|
|
726
|
+
following: z.ZodOptional<z.ZodNumber>;
|
|
727
|
+
pro: z.ZodOptional<z.ZodBoolean>;
|
|
728
|
+
}, z.core.$strip>> & {
|
|
729
|
+
process: (input: {
|
|
730
|
+
fid: string;
|
|
731
|
+
}) => Promise<{
|
|
732
|
+
data: {
|
|
733
|
+
fid: string;
|
|
734
|
+
};
|
|
735
|
+
metadata: {
|
|
736
|
+
pfpUrl?: string | undefined;
|
|
737
|
+
bio?: string | undefined;
|
|
738
|
+
username?: string | undefined;
|
|
739
|
+
displayName?: string | undefined;
|
|
740
|
+
followers?: number | undefined;
|
|
741
|
+
following?: number | undefined;
|
|
742
|
+
pro?: boolean | undefined;
|
|
743
|
+
} | undefined;
|
|
744
|
+
}>;
|
|
745
|
+
safeProcess: (input: {
|
|
746
|
+
fid: string;
|
|
747
|
+
}) => Promise<{
|
|
748
|
+
success: boolean;
|
|
749
|
+
data?: {
|
|
750
|
+
fid: string;
|
|
751
|
+
} | undefined;
|
|
752
|
+
metadata?: {
|
|
753
|
+
pfpUrl?: string | undefined;
|
|
754
|
+
bio?: string | undefined;
|
|
755
|
+
username?: string | undefined;
|
|
756
|
+
displayName?: string | undefined;
|
|
757
|
+
followers?: number | undefined;
|
|
758
|
+
following?: number | undefined;
|
|
759
|
+
pro?: boolean | undefined;
|
|
760
|
+
} | undefined;
|
|
761
|
+
error?: z.ZodError | string;
|
|
762
|
+
}>;
|
|
485
763
|
});
|
|
486
764
|
/**
|
|
487
765
|
* Validate ad data against any ad definition
|
|
@@ -607,6 +885,94 @@ declare const adDefinitions: {
|
|
|
607
885
|
error?: z.ZodError | string;
|
|
608
886
|
}>;
|
|
609
887
|
};
|
|
888
|
+
readonly token: AdDefinition<z.ZodObject<{
|
|
889
|
+
address: z.ZodString;
|
|
890
|
+
chainId: z.ZodNumber;
|
|
891
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
892
|
+
name: z.ZodOptional<z.ZodString>;
|
|
893
|
+
symbol: z.ZodOptional<z.ZodString>;
|
|
894
|
+
decimals: z.ZodOptional<z.ZodNumber>;
|
|
895
|
+
logoURI: z.ZodOptional<z.ZodString>;
|
|
896
|
+
}, z.core.$strip>> & {
|
|
897
|
+
process: (input: {
|
|
898
|
+
address: string;
|
|
899
|
+
chainId: number;
|
|
900
|
+
}) => Promise<{
|
|
901
|
+
data: {
|
|
902
|
+
address: string;
|
|
903
|
+
chainId: number;
|
|
904
|
+
};
|
|
905
|
+
metadata: {
|
|
906
|
+
name?: string | undefined;
|
|
907
|
+
symbol?: string | undefined;
|
|
908
|
+
decimals?: number | undefined;
|
|
909
|
+
logoURI?: string | undefined;
|
|
910
|
+
} | undefined;
|
|
911
|
+
}>;
|
|
912
|
+
safeProcess: (input: {
|
|
913
|
+
address: string;
|
|
914
|
+
chainId: number;
|
|
915
|
+
}) => Promise<{
|
|
916
|
+
success: boolean;
|
|
917
|
+
data?: {
|
|
918
|
+
address: string;
|
|
919
|
+
chainId: number;
|
|
920
|
+
} | undefined;
|
|
921
|
+
metadata?: {
|
|
922
|
+
name?: string | undefined;
|
|
923
|
+
symbol?: string | undefined;
|
|
924
|
+
decimals?: number | undefined;
|
|
925
|
+
logoURI?: string | undefined;
|
|
926
|
+
} | undefined;
|
|
927
|
+
error?: z.ZodError | string;
|
|
928
|
+
}>;
|
|
929
|
+
};
|
|
930
|
+
readonly farcasterProfile: AdDefinition<z.ZodObject<{
|
|
931
|
+
fid: z.ZodString;
|
|
932
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
933
|
+
pfpUrl: z.ZodOptional<z.ZodString>;
|
|
934
|
+
bio: z.ZodOptional<z.ZodString>;
|
|
935
|
+
username: z.ZodOptional<z.ZodString>;
|
|
936
|
+
displayName: z.ZodOptional<z.ZodString>;
|
|
937
|
+
followers: z.ZodOptional<z.ZodNumber>;
|
|
938
|
+
following: z.ZodOptional<z.ZodNumber>;
|
|
939
|
+
pro: z.ZodOptional<z.ZodBoolean>;
|
|
940
|
+
}, z.core.$strip>> & {
|
|
941
|
+
process: (input: {
|
|
942
|
+
fid: string;
|
|
943
|
+
}) => Promise<{
|
|
944
|
+
data: {
|
|
945
|
+
fid: string;
|
|
946
|
+
};
|
|
947
|
+
metadata: {
|
|
948
|
+
pfpUrl?: string | undefined;
|
|
949
|
+
bio?: string | undefined;
|
|
950
|
+
username?: string | undefined;
|
|
951
|
+
displayName?: string | undefined;
|
|
952
|
+
followers?: number | undefined;
|
|
953
|
+
following?: number | undefined;
|
|
954
|
+
pro?: boolean | undefined;
|
|
955
|
+
} | undefined;
|
|
956
|
+
}>;
|
|
957
|
+
safeProcess: (input: {
|
|
958
|
+
fid: string;
|
|
959
|
+
}) => Promise<{
|
|
960
|
+
success: boolean;
|
|
961
|
+
data?: {
|
|
962
|
+
fid: string;
|
|
963
|
+
} | undefined;
|
|
964
|
+
metadata?: {
|
|
965
|
+
pfpUrl?: string | undefined;
|
|
966
|
+
bio?: string | undefined;
|
|
967
|
+
username?: string | undefined;
|
|
968
|
+
displayName?: string | undefined;
|
|
969
|
+
followers?: number | undefined;
|
|
970
|
+
following?: number | undefined;
|
|
971
|
+
pro?: boolean | undefined;
|
|
972
|
+
} | undefined;
|
|
973
|
+
error?: z.ZodError | string;
|
|
974
|
+
}>;
|
|
975
|
+
};
|
|
610
976
|
};
|
|
611
977
|
declare const adModels: {
|
|
612
978
|
readonly link: AdDefinition<z.ZodObject<{
|
|
@@ -720,6 +1086,94 @@ declare const adModels: {
|
|
|
720
1086
|
error?: z.ZodError | string;
|
|
721
1087
|
}>;
|
|
722
1088
|
};
|
|
1089
|
+
readonly token: AdDefinition<z.ZodObject<{
|
|
1090
|
+
address: z.ZodString;
|
|
1091
|
+
chainId: z.ZodNumber;
|
|
1092
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
1093
|
+
name: z.ZodOptional<z.ZodString>;
|
|
1094
|
+
symbol: z.ZodOptional<z.ZodString>;
|
|
1095
|
+
decimals: z.ZodOptional<z.ZodNumber>;
|
|
1096
|
+
logoURI: z.ZodOptional<z.ZodString>;
|
|
1097
|
+
}, z.core.$strip>> & {
|
|
1098
|
+
process: (input: {
|
|
1099
|
+
address: string;
|
|
1100
|
+
chainId: number;
|
|
1101
|
+
}) => Promise<{
|
|
1102
|
+
data: {
|
|
1103
|
+
address: string;
|
|
1104
|
+
chainId: number;
|
|
1105
|
+
};
|
|
1106
|
+
metadata: {
|
|
1107
|
+
name?: string | undefined;
|
|
1108
|
+
symbol?: string | undefined;
|
|
1109
|
+
decimals?: number | undefined;
|
|
1110
|
+
logoURI?: string | undefined;
|
|
1111
|
+
} | undefined;
|
|
1112
|
+
}>;
|
|
1113
|
+
safeProcess: (input: {
|
|
1114
|
+
address: string;
|
|
1115
|
+
chainId: number;
|
|
1116
|
+
}) => Promise<{
|
|
1117
|
+
success: boolean;
|
|
1118
|
+
data?: {
|
|
1119
|
+
address: string;
|
|
1120
|
+
chainId: number;
|
|
1121
|
+
} | undefined;
|
|
1122
|
+
metadata?: {
|
|
1123
|
+
name?: string | undefined;
|
|
1124
|
+
symbol?: string | undefined;
|
|
1125
|
+
decimals?: number | undefined;
|
|
1126
|
+
logoURI?: string | undefined;
|
|
1127
|
+
} | undefined;
|
|
1128
|
+
error?: z.ZodError | string;
|
|
1129
|
+
}>;
|
|
1130
|
+
};
|
|
1131
|
+
readonly farcasterProfile: AdDefinition<z.ZodObject<{
|
|
1132
|
+
fid: z.ZodString;
|
|
1133
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
1134
|
+
pfpUrl: z.ZodOptional<z.ZodString>;
|
|
1135
|
+
bio: z.ZodOptional<z.ZodString>;
|
|
1136
|
+
username: z.ZodOptional<z.ZodString>;
|
|
1137
|
+
displayName: z.ZodOptional<z.ZodString>;
|
|
1138
|
+
followers: z.ZodOptional<z.ZodNumber>;
|
|
1139
|
+
following: z.ZodOptional<z.ZodNumber>;
|
|
1140
|
+
pro: z.ZodOptional<z.ZodBoolean>;
|
|
1141
|
+
}, z.core.$strip>> & {
|
|
1142
|
+
process: (input: {
|
|
1143
|
+
fid: string;
|
|
1144
|
+
}) => Promise<{
|
|
1145
|
+
data: {
|
|
1146
|
+
fid: string;
|
|
1147
|
+
};
|
|
1148
|
+
metadata: {
|
|
1149
|
+
pfpUrl?: string | undefined;
|
|
1150
|
+
bio?: string | undefined;
|
|
1151
|
+
username?: string | undefined;
|
|
1152
|
+
displayName?: string | undefined;
|
|
1153
|
+
followers?: number | undefined;
|
|
1154
|
+
following?: number | undefined;
|
|
1155
|
+
pro?: boolean | undefined;
|
|
1156
|
+
} | undefined;
|
|
1157
|
+
}>;
|
|
1158
|
+
safeProcess: (input: {
|
|
1159
|
+
fid: string;
|
|
1160
|
+
}) => Promise<{
|
|
1161
|
+
success: boolean;
|
|
1162
|
+
data?: {
|
|
1163
|
+
fid: string;
|
|
1164
|
+
} | undefined;
|
|
1165
|
+
metadata?: {
|
|
1166
|
+
pfpUrl?: string | undefined;
|
|
1167
|
+
bio?: string | undefined;
|
|
1168
|
+
username?: string | undefined;
|
|
1169
|
+
displayName?: string | undefined;
|
|
1170
|
+
followers?: number | undefined;
|
|
1171
|
+
following?: number | undefined;
|
|
1172
|
+
pro?: boolean | undefined;
|
|
1173
|
+
} | undefined;
|
|
1174
|
+
error?: z.ZodError | string;
|
|
1175
|
+
}>;
|
|
1176
|
+
};
|
|
723
1177
|
};
|
|
724
1178
|
|
|
725
|
-
export { type AdData, type AdDefinition, type AdType, type CastAd, type CastAdData, type CastAdMetadata, type LinkAd, type LinkAdData, type LinkAdMetadata, type MiniAppAd, type MiniAppAdData, type MiniAppAdMetadata, adDefinitions, adModels, adTypes, ads, castAd, defineAd, getAd, linkAd, miniappAd, processAd, safeProcessAd, validateAdData };
|
|
1179
|
+
export { type AdData, type AdDefinition, type AdType, type CastAd, type CastAdData, type CastAdMetadata, type FarcasterProfileAd, type FarcasterProfileAdData, type FarcasterProfileAdMetadata, type LinkAd, type LinkAdData, type LinkAdMetadata, type MiniAppAd, type MiniAppAdData, type MiniAppAdMetadata, type TokenAd, type TokenAdData, type TokenAdMetadata, adDefinitions, adModels, adTypes, ads, castAd, defineAd, farcasterProfileAd, getAd, linkAd, miniappAd, processAd, safeProcessAd, tokenAd, validateAdData };
|
package/dist/index.js
CHANGED
|
@@ -71,14 +71,37 @@ var AdlandAPI = class {
|
|
|
71
71
|
async getMiniappMetadata({ url }) {
|
|
72
72
|
return this.get(`${adlandApiUrl}/metadata/miniapp?url=${encodeURIComponent(url)}`);
|
|
73
73
|
}
|
|
74
|
-
async getLinkMetadata({
|
|
75
|
-
url
|
|
76
|
-
}) {
|
|
74
|
+
async getLinkMetadata({ url }) {
|
|
77
75
|
return this.get(`${adlandApiUrl}/metadata/link?url=${encodeURIComponent(url)}`);
|
|
78
76
|
}
|
|
79
77
|
async getCastMetadata({ hash }) {
|
|
80
78
|
return this.get(`${adlandApiUrl}/metadata/cast?hash=${encodeURIComponent(hash)}`);
|
|
81
79
|
}
|
|
80
|
+
async verifyFarcasterProfile({ fid }) {
|
|
81
|
+
return this.post(`${adlandApiUrl}/verify/profile`, {
|
|
82
|
+
fid
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
async getFarcasterProfile({ fid }) {
|
|
86
|
+
return this.get(`${adlandApiUrl}/metadata/profile?fid=${encodeURIComponent(fid)}`);
|
|
87
|
+
}
|
|
88
|
+
async verifyToken({
|
|
89
|
+
address,
|
|
90
|
+
chainId
|
|
91
|
+
}) {
|
|
92
|
+
return this.post(`${adlandApiUrl}/verify/token`, {
|
|
93
|
+
address,
|
|
94
|
+
chainId
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
async getTokenMetadata({
|
|
98
|
+
address,
|
|
99
|
+
chainId
|
|
100
|
+
}) {
|
|
101
|
+
return this.get(
|
|
102
|
+
`${adlandApiUrl}/metadata/token?address=${encodeURIComponent(address)}&chainId=${chainId}`
|
|
103
|
+
);
|
|
104
|
+
}
|
|
82
105
|
async post(url, body) {
|
|
83
106
|
return fetch(url, {
|
|
84
107
|
method: "POST",
|
|
@@ -183,14 +206,83 @@ var miniappAd = defineAd({
|
|
|
183
206
|
};
|
|
184
207
|
}
|
|
185
208
|
});
|
|
209
|
+
var tokenAd = defineAd({
|
|
210
|
+
type: "token",
|
|
211
|
+
data: z.object({
|
|
212
|
+
address: z.string().nonempty("Address is required"),
|
|
213
|
+
chainId: z.number().int().positive("Chain ID is required").refine((chainId) => [8453].includes(chainId), "Invalid chain ID")
|
|
214
|
+
}),
|
|
215
|
+
metadata: z.object({
|
|
216
|
+
name: z.string().optional(),
|
|
217
|
+
symbol: z.string().optional(),
|
|
218
|
+
decimals: z.number().optional(),
|
|
219
|
+
logoURI: z.string().optional()
|
|
220
|
+
}),
|
|
221
|
+
async verify({ address, chainId }) {
|
|
222
|
+
const res = await adlandAPI.verifyToken({ address, chainId });
|
|
223
|
+
if (!res.verified) {
|
|
224
|
+
throw new Error("Token verification failed");
|
|
225
|
+
}
|
|
226
|
+
},
|
|
227
|
+
async getMetadata({ address, chainId }) {
|
|
228
|
+
const token = await adlandAPI.getTokenMetadata({ address, chainId });
|
|
229
|
+
return {
|
|
230
|
+
name: token.name,
|
|
231
|
+
symbol: token.symbol,
|
|
232
|
+
decimals: token.decimals,
|
|
233
|
+
logoURI: token.logoURI
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
var farcasterProfileAd = defineAd({
|
|
238
|
+
type: "farcasterProfile",
|
|
239
|
+
data: z.object({
|
|
240
|
+
fid: z.string().nonempty("Fid is required")
|
|
241
|
+
}),
|
|
242
|
+
metadata: z.object({
|
|
243
|
+
pfpUrl: z.string().optional(),
|
|
244
|
+
bio: z.string().optional(),
|
|
245
|
+
username: z.string().optional(),
|
|
246
|
+
displayName: z.string().optional(),
|
|
247
|
+
followers: z.number().optional(),
|
|
248
|
+
following: z.number().optional(),
|
|
249
|
+
pro: z.boolean().optional()
|
|
250
|
+
}),
|
|
251
|
+
async verify({ fid }) {
|
|
252
|
+
const res = await adlandAPI.verifyFarcasterProfile({ fid });
|
|
253
|
+
if (!res.verified) {
|
|
254
|
+
throw new Error("Farcaster profile verification failed");
|
|
255
|
+
}
|
|
256
|
+
},
|
|
257
|
+
async getMetadata({ fid }) {
|
|
258
|
+
const res = await adlandAPI.getFarcasterProfile({ fid });
|
|
259
|
+
return {
|
|
260
|
+
pfpUrl: res.pfpUrl,
|
|
261
|
+
bio: res.bio,
|
|
262
|
+
username: res.username,
|
|
263
|
+
displayName: res.displayName,
|
|
264
|
+
followers: res.followers,
|
|
265
|
+
following: res.following,
|
|
266
|
+
pro: res.pro
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
});
|
|
186
270
|
|
|
187
271
|
// src/index.ts
|
|
188
272
|
var ads = {
|
|
189
273
|
link: linkAd,
|
|
190
274
|
cast: castAd,
|
|
191
|
-
miniapp: miniappAd
|
|
275
|
+
miniapp: miniappAd,
|
|
276
|
+
token: tokenAd,
|
|
277
|
+
farcasterProfile: farcasterProfileAd
|
|
192
278
|
};
|
|
193
|
-
var adTypes = [
|
|
279
|
+
var adTypes = [
|
|
280
|
+
"link",
|
|
281
|
+
"cast",
|
|
282
|
+
"miniapp",
|
|
283
|
+
"token",
|
|
284
|
+
"farcasterProfile"
|
|
285
|
+
];
|
|
194
286
|
function getAd(type) {
|
|
195
287
|
return ads[type];
|
|
196
288
|
}
|
|
@@ -221,6 +313,6 @@ function validateAdData(data) {
|
|
|
221
313
|
var adDefinitions = ads;
|
|
222
314
|
var adModels = ads;
|
|
223
315
|
|
|
224
|
-
export { adDefinitions, adModels, adTypes, ads, castAd, defineAd, getAd, linkAd, miniappAd, processAd, safeProcessAd, validateAdData };
|
|
316
|
+
export { adDefinitions, adModels, adTypes, ads, castAd, defineAd, farcasterProfileAd, getAd, linkAd, miniappAd, processAd, safeProcessAd, tokenAd, validateAdData };
|
|
225
317
|
//# sourceMappingURL=index.js.map
|
|
226
318
|
//# sourceMappingURL=index.js.map
|