Skip to content

Commit dc627bd

Browse files
authored
feat: destroy stream in CRE flow (#167)
1 parent 853c26d commit dc627bd

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

core/tnclient/client.go

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,21 @@ func (c *Client) DeployStream(ctx context.Context, streamId util.StreamId, strea
143143
}
144144

145145
func (c *Client) DestroyStream(ctx context.Context, streamId util.StreamId) (types.Hash, error) {
146-
return tn_api.DestroyStream(ctx, tn_api.DestroyStreamInput{
147-
StreamId: streamId,
148-
KwilClient: c.GetKwilClient(),
149-
})
146+
// For HTTP transport, use the existing implementation (backwards compatible)
147+
// For custom transports (CRE, etc.), use transport.Execute directly
148+
if httpTransport, ok := c.transport.(*HTTPTransport); ok {
149+
return tn_api.DestroyStream(ctx, tn_api.DestroyStreamInput{
150+
StreamId: streamId,
151+
KwilClient: httpTransport.gatewayClient,
152+
})
153+
}
154+
// Use transport.Execute directly for custom transports
155+
// Derive address from signer for delete_stream call
156+
addr, _ := auth.EthSecp256k1Authenticator{}.Identifier(c.signer.CompactID())
157+
return c.transport.Execute(ctx, "", "delete_stream", [][]any{{
158+
addr,
159+
streamId.String(),
160+
}})
150161
}
151162

152163
func (c *Client) LoadActions() (clientType.IAction, error) {

0 commit comments

Comments
 (0)