starkware-libs / starkex-js

JavaScript SDK for StarkEx
https://starkware.co/starkex/api/
28 stars 18 forks source link

feat(3127791831): dynamic versioning #27

Closed danielgluskin-starkware closed 2 years ago

danielgluskin-starkware commented 2 years ago

Description of the Changes

Add dynamic versioning for gateways: Pass a default version inside the c'tor.

class FeederGateway extends GatewayBase {
  constructor(config: StarkExClientConfig) {
    super(config, {
      gatewayRoute: 'feeder_gateway',
      defaultVersion: ApiVersion.V2
    });
  }

Override it as:

public getBatchEnclosingIds(batchId: number): Promise<number[]> {
    return this.makeRequest(
      `${FeederGatewayServiceType.GET_BATCH_ENCLOSING_IDS}?batch_id=${batchId}`,
      'GET',
      undefined,
      ApiVersion.V1
    );
  }

(we can use an object here, so we don't need to provide 'GET' & undefined). This will make a call to v1 with an empty prefix.

Solves #3127791831


Checklist

dan-ziv commented 2 years ago

:tada: This PR is included in version 0.1.0-dev.6 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket:

dan-ziv commented 2 years ago

:tada: This PR is included in version 0.1.0 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket: