@optimex-xyz/market-maker-sdk 0.5.0-dev-81225fa → 0.5.0-dev-4237adc

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -11,10 +11,22 @@ interface EnvironmentConfig {
11
11
  interface AppConfig extends EnvironmentConfig {
12
12
  env: Environment;
13
13
  }
14
+ interface ConfigObserver {
15
+ onConfigUpdate(newConfig: AppConfig): void;
16
+ }
14
17
  declare class Config {
15
18
  private env;
16
19
  private config;
20
+ private observers;
17
21
  constructor(env?: Environment);
22
+ /**
23
+ * Register a service as an observer to be notified of config changes
24
+ */
25
+ registerObserver(observer: ConfigObserver): void;
26
+ /**
27
+ * Remove a service from observers
28
+ */
29
+ unregisterObserver(observer: ConfigObserver): void;
18
30
  /**
19
31
  * Set the environment for the SDK
20
32
  * @param env The environment to use ('dev' or 'production')
@@ -4704,9 +4716,14 @@ declare const TokenSchema: z.ZodObject<{
4704
4716
  }>;
4705
4717
  type Token = z.infer<typeof TokenSchema>;
4706
4718
 
4707
- declare class TokenService {
4708
- private readonly baseURL;
4719
+ declare class TokenService implements ConfigObserver {
4720
+ private baseURL;
4709
4721
  constructor();
4722
+ /**
4723
+ * Implementation of ConfigObserver interface
4724
+ * Updates service when config changes
4725
+ */
4726
+ onConfigUpdate(newConfig: AppConfig): void;
4710
4727
  /**
4711
4728
  * Fetches all available tokens from the API
4712
4729
  * @returns Promise<Token[]> Array of tokens
@@ -4803,4 +4820,4 @@ declare function camelToSnakeCase(str: string): string;
4803
4820
  declare const ensureHexPrefix: (value: string) => string;
4804
4821
  declare const removeHexPrefix: (value: string) => string;
4805
4822
 
4806
- export { type AppConfig, type ERC20, ERC20__factory, type Environment, type EnvironmentConfig, ITypes, type Payment, Payment__factory, type Router, RouterService, Router__factory, SDK, SignatureType, type Signer, SignerService, Signer__factory, SolverService, type Token, TokenSchema, TokenService, camelToSnakeCase, config, confirmDepositType, confirmPaymentType, confirmSettlementType, convertToCamelCase, convertToSnakeCase, ensureHexPrefix, index as factories, getCommitInfoHash, getMakePaymentHash, getSignature, getSigner, getTradeIdsHash, makePaymentType, presignType, removeHexPrefix, rfqAuthenticationTypes, routerService, sdk, selectionType, signerService, snakeToCamelCase, solverService, tokenService };
4823
+ export { type AppConfig, type ConfigObserver, type ERC20, ERC20__factory, type Environment, type EnvironmentConfig, ITypes, type Payment, Payment__factory, type Router, RouterService, Router__factory, SDK, SignatureType, type Signer, SignerService, Signer__factory, SolverService, type Token, TokenSchema, TokenService, camelToSnakeCase, config, confirmDepositType, confirmPaymentType, confirmSettlementType, convertToCamelCase, convertToSnakeCase, ensureHexPrefix, index as factories, getCommitInfoHash, getMakePaymentHash, getSignature, getSigner, getTradeIdsHash, makePaymentType, presignType, removeHexPrefix, rfqAuthenticationTypes, routerService, sdk, selectionType, signerService, snakeToCamelCase, solverService, tokenService };
package/dist/index.d.ts CHANGED
@@ -11,10 +11,22 @@ interface EnvironmentConfig {
11
11
  interface AppConfig extends EnvironmentConfig {
12
12
  env: Environment;
13
13
  }
14
+ interface ConfigObserver {
15
+ onConfigUpdate(newConfig: AppConfig): void;
16
+ }
14
17
  declare class Config {
15
18
  private env;
16
19
  private config;
20
+ private observers;
17
21
  constructor(env?: Environment);
22
+ /**
23
+ * Register a service as an observer to be notified of config changes
24
+ */
25
+ registerObserver(observer: ConfigObserver): void;
26
+ /**
27
+ * Remove a service from observers
28
+ */
29
+ unregisterObserver(observer: ConfigObserver): void;
18
30
  /**
19
31
  * Set the environment for the SDK
20
32
  * @param env The environment to use ('dev' or 'production')
@@ -4704,9 +4716,14 @@ declare const TokenSchema: z.ZodObject<{
4704
4716
  }>;
4705
4717
  type Token = z.infer<typeof TokenSchema>;
4706
4718
 
4707
- declare class TokenService {
4708
- private readonly baseURL;
4719
+ declare class TokenService implements ConfigObserver {
4720
+ private baseURL;
4709
4721
  constructor();
4722
+ /**
4723
+ * Implementation of ConfigObserver interface
4724
+ * Updates service when config changes
4725
+ */
4726
+ onConfigUpdate(newConfig: AppConfig): void;
4710
4727
  /**
4711
4728
  * Fetches all available tokens from the API
4712
4729
  * @returns Promise<Token[]> Array of tokens
@@ -4803,4 +4820,4 @@ declare function camelToSnakeCase(str: string): string;
4803
4820
  declare const ensureHexPrefix: (value: string) => string;
4804
4821
  declare const removeHexPrefix: (value: string) => string;
4805
4822
 
4806
- export { type AppConfig, type ERC20, ERC20__factory, type Environment, type EnvironmentConfig, ITypes, type Payment, Payment__factory, type Router, RouterService, Router__factory, SDK, SignatureType, type Signer, SignerService, Signer__factory, SolverService, type Token, TokenSchema, TokenService, camelToSnakeCase, config, confirmDepositType, confirmPaymentType, confirmSettlementType, convertToCamelCase, convertToSnakeCase, ensureHexPrefix, index as factories, getCommitInfoHash, getMakePaymentHash, getSignature, getSigner, getTradeIdsHash, makePaymentType, presignType, removeHexPrefix, rfqAuthenticationTypes, routerService, sdk, selectionType, signerService, snakeToCamelCase, solverService, tokenService };
4823
+ export { type AppConfig, type ConfigObserver, type ERC20, ERC20__factory, type Environment, type EnvironmentConfig, ITypes, type Payment, Payment__factory, type Router, RouterService, Router__factory, SDK, SignatureType, type Signer, SignerService, Signer__factory, SolverService, type Token, TokenSchema, TokenService, camelToSnakeCase, config, confirmDepositType, confirmPaymentType, confirmSettlementType, convertToCamelCase, convertToSnakeCase, ensureHexPrefix, index as factories, getCommitInfoHash, getMakePaymentHash, getSignature, getSigner, getTradeIdsHash, makePaymentType, presignType, removeHexPrefix, rfqAuthenticationTypes, routerService, sdk, selectionType, signerService, snakeToCamelCase, solverService, tokenService };
package/dist/index.js CHANGED
@@ -90,9 +90,22 @@ var environments = {
90
90
  };
91
91
  var Config = class {
92
92
  constructor(env = "production") {
93
+ this.observers = [];
93
94
  this.env = env;
94
95
  this.config = this.validateAndGetConfig(this.env);
95
96
  }
97
+ /**
98
+ * Register a service as an observer to be notified of config changes
99
+ */
100
+ registerObserver(observer) {
101
+ this.observers.push(observer);
102
+ }
103
+ /**
104
+ * Remove a service from observers
105
+ */
106
+ unregisterObserver(observer) {
107
+ this.observers = this.observers.filter((obs) => obs !== observer);
108
+ }
96
109
  /**
97
110
  * Set the environment for the SDK
98
111
  * @param env The environment to use ('dev' or 'production')
@@ -103,6 +116,8 @@ var Config = class {
103
116
  }
104
117
  this.env = env;
105
118
  this.config = environments[env];
119
+ const newConfig = this.get();
120
+ this.observers.forEach((observer) => observer.onConfigUpdate(newConfig));
106
121
  }
107
122
  validateAndGetConfig(env) {
108
123
  if (!environments[env]) {
@@ -3709,6 +3724,14 @@ var TokenResponseSchema = import_zod3.z.object({
3709
3724
  var TokenService = class {
3710
3725
  constructor() {
3711
3726
  this.baseURL = config.getBackendUrl();
3727
+ config.registerObserver(this);
3728
+ }
3729
+ /**
3730
+ * Implementation of ConfigObserver interface
3731
+ * Updates service when config changes
3732
+ */
3733
+ onConfigUpdate(newConfig) {
3734
+ this.baseURL = newConfig.backendUrl;
3712
3735
  }
3713
3736
  /**
3714
3737
  * Fetches all available tokens from the API
package/dist/index.mjs CHANGED
@@ -25,9 +25,22 @@ var environments = {
25
25
  };
26
26
  var Config = class {
27
27
  constructor(env = "production") {
28
+ this.observers = [];
28
29
  this.env = env;
29
30
  this.config = this.validateAndGetConfig(this.env);
30
31
  }
32
+ /**
33
+ * Register a service as an observer to be notified of config changes
34
+ */
35
+ registerObserver(observer) {
36
+ this.observers.push(observer);
37
+ }
38
+ /**
39
+ * Remove a service from observers
40
+ */
41
+ unregisterObserver(observer) {
42
+ this.observers = this.observers.filter((obs) => obs !== observer);
43
+ }
31
44
  /**
32
45
  * Set the environment for the SDK
33
46
  * @param env The environment to use ('dev' or 'production')
@@ -38,6 +51,8 @@ var Config = class {
38
51
  }
39
52
  this.env = env;
40
53
  this.config = environments[env];
54
+ const newConfig = this.get();
55
+ this.observers.forEach((observer) => observer.onConfigUpdate(newConfig));
41
56
  }
42
57
  validateAndGetConfig(env) {
43
58
  if (!environments[env]) {
@@ -3644,6 +3659,14 @@ var TokenResponseSchema = z3.object({
3644
3659
  var TokenService = class {
3645
3660
  constructor() {
3646
3661
  this.baseURL = config.getBackendUrl();
3662
+ config.registerObserver(this);
3663
+ }
3664
+ /**
3665
+ * Implementation of ConfigObserver interface
3666
+ * Updates service when config changes
3667
+ */
3668
+ onConfigUpdate(newConfig) {
3669
+ this.baseURL = newConfig.backendUrl;
3647
3670
  }
3648
3671
  /**
3649
3672
  * Fetches all available tokens from the API
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optimex-xyz/market-maker-sdk",
3
- "version": "0.5.0-dev-81225fa",
3
+ "version": "0.5.0-dev-4237adc",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"