@@ -41,12 +41,6 @@ export interface WebhookFilters {
4141 } ;
4242}
4343
44- interface CreateWebhookPayload {
45- name : string ;
46- webhook_url : string ;
47- filters : WebhookFilters ;
48- }
49-
5044interface WebhooksListResponse {
5145 data : WebhookResponse [ ] ;
5246 error ?: string ;
@@ -57,56 +51,10 @@ interface WebhookSingleResponse {
5751 error ?: string ;
5852}
5953
60- interface TestWebhookPayload {
61- webhook_url : string ;
62- type ?: "event" | "transaction" ;
63- }
64-
65- interface TestWebhookResponse {
66- success : boolean ;
67- error ?: string ;
68- }
69-
7054type SupportedWebhookChainsResponse =
7155 | { chains : Array < number > }
7256 | { error : string } ;
7357
74- export async function createWebhook (
75- payload : CreateWebhookPayload ,
76- clientId : string ,
77- ) : Promise < WebhookSingleResponse > {
78- try {
79- const authToken = await getAuthToken ( ) ;
80- const response = await fetch (
81- `https://${ THIRDWEB_INSIGHT_API_DOMAIN } /v1/webhooks` ,
82- {
83- body : JSON . stringify ( payload ) ,
84- headers : {
85- Authorization : `Bearer ${ authToken } ` ,
86- "Content-Type" : "application/json" ,
87- "x-client-id" : clientId ,
88- } ,
89- method : "POST" ,
90- } ,
91- ) ;
92-
93- if ( ! response . ok ) {
94- const errorText = await response . text ( ) ;
95- return {
96- data : null ,
97- error : `Failed to create webhook: ${ errorText } ` ,
98- } ;
99- }
100-
101- return ( await response . json ( ) ) as WebhookSingleResponse ;
102- } catch ( error ) {
103- return {
104- data : null ,
105- error : `Network or parsing error: ${ error instanceof Error ? error . message : "Unknown error" } ` ,
106- } ;
107- }
108- }
109-
11058export async function getWebhooks (
11159 clientId : string ,
11260) : Promise < WebhooksListResponse > {
@@ -174,42 +122,6 @@ export async function deleteWebhook(
174122 }
175123}
176124
177- export async function testWebhook (
178- payload : TestWebhookPayload ,
179- clientId : string ,
180- ) : Promise < TestWebhookResponse > {
181- try {
182- const authToken = await getAuthToken ( ) ;
183- const response = await fetch (
184- `https://${ THIRDWEB_INSIGHT_API_DOMAIN } /v1/webhooks/test` ,
185- {
186- body : JSON . stringify ( payload ) ,
187- headers : {
188- Authorization : `Bearer ${ authToken } ` ,
189- "Content-Type" : "application/json" ,
190- "x-client-id" : clientId ,
191- } ,
192- method : "POST" ,
193- } ,
194- ) ;
195-
196- if ( ! response . ok ) {
197- const errorText = await response . text ( ) ;
198- return {
199- error : `Failed to test webhook: ${ errorText } ` ,
200- success : false ,
201- } ;
202- }
203-
204- return ( await response . json ( ) ) as TestWebhookResponse ;
205- } catch ( error ) {
206- return {
207- error : `Network or parsing error: ${ error instanceof Error ? error . message : "Unknown error" } ` ,
208- success : false ,
209- } ;
210- }
211- }
212-
213125export async function getSupportedWebhookChains ( ) : Promise < SupportedWebhookChainsResponse > {
214126 try {
215127 const response = await fetch (
0 commit comments