Skip to content

Commit

Permalink
fix: make the api backward compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
2color committed Feb 20, 2024
1 parent dde050c commit 9d77f79
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions packages/block-brokers/src/trustless-gateway/broker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ ProgressOptions<TrustlessGatewayGetBlockProgressEvents>
this.log = components.logger.forComponent('helia:trustless-gateway-block-broker')
this.gateways = (init.gateways ?? DEFAULT_TRUSTLESS_GATEWAYS)
.map((gw) => {
if(typeof gw === 'string' || gw instanceof URL) {
// backward compatibility defaults to path gateway
return new TrustlessGateway(gw, false)
}

Check warning on line 26 in packages/block-brokers/src/trustless-gateway/broker.ts

View check run for this annotation

Codecov / codecov/patch

packages/block-brokers/src/trustless-gateway/broker.ts#L24-L26

Added lines #L24 - L26 were not covered by tests

return new TrustlessGateway(gw.url, gw.isSubdomain)
})
}
Expand Down
2 changes: 1 addition & 1 deletion packages/block-brokers/src/trustless-gateway/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export type TrustlessGatewayGetBlockProgressEvents =
ProgressEvent<'trustless-gateway:get-block:fetch', URL>

export interface TrustlessGatewayBlockBrokerInit {
gateways?: Array<TrustlessGatewayUrl>
gateways?: Array<string | URL | TrustlessGatewayUrl>
}

export interface TrustlessGatewayComponents {
Expand Down

0 comments on commit 9d77f79

Please sign in to comment.