From 9d77f79036dff46ff4a46b712e3eab7eceb8fb1d Mon Sep 17 00:00:00 2001 From: Daniel N <2color@users.noreply.github.com> Date: Tue, 20 Feb 2024 15:00:54 +0100 Subject: [PATCH] fix: make the api backward compatible --- packages/block-brokers/src/trustless-gateway/broker.ts | 5 +++++ packages/block-brokers/src/trustless-gateway/index.ts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/block-brokers/src/trustless-gateway/broker.ts b/packages/block-brokers/src/trustless-gateway/broker.ts index 9b851bdfd..7e42075ef 100644 --- a/packages/block-brokers/src/trustless-gateway/broker.ts +++ b/packages/block-brokers/src/trustless-gateway/broker.ts @@ -20,6 +20,11 @@ ProgressOptions 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) + } + return new TrustlessGateway(gw.url, gw.isSubdomain) }) } diff --git a/packages/block-brokers/src/trustless-gateway/index.ts b/packages/block-brokers/src/trustless-gateway/index.ts index 80aa8b5d8..ec03b81cd 100644 --- a/packages/block-brokers/src/trustless-gateway/index.ts +++ b/packages/block-brokers/src/trustless-gateway/index.ts @@ -23,7 +23,7 @@ export type TrustlessGatewayGetBlockProgressEvents = ProgressEvent<'trustless-gateway:get-block:fetch', URL> export interface TrustlessGatewayBlockBrokerInit { - gateways?: Array + gateways?: Array } export interface TrustlessGatewayComponents {