@optimex-xyz/market-maker-sdk 0.5.0-dev-81225fa → 0.5.0-dev-4772ae2

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')
@@ -4578,10 +4590,15 @@ declare namespace index {
4578
4590
  export { index_ERC20__factory as ERC20__factory, index_Payment__factory as Payment__factory, index_Router__factory as Router__factory, index_Signer__factory as Signer__factory };
4579
4591
  }
4580
4592
 
4581
- declare class RouterService {
4582
- private readonly provider;
4583
- private readonly contract;
4593
+ declare class RouterService implements ConfigObserver {
4594
+ private provider;
4595
+ private contract;
4584
4596
  constructor();
4597
+ /**
4598
+ * Implementation of ConfigObserver interface
4599
+ * Updates service when config changes
4600
+ */
4601
+ onConfigUpdate(newConfig: AppConfig): void;
4585
4602
  getSigner(): Promise<string>;
4586
4603
  getCurrentPubkey(network: string): Promise<ITypes.MPCInfoStructOutput>;
4587
4604
  getCurrentStage(tradeId: BytesLike): Promise<bigint>;
@@ -4608,10 +4625,15 @@ declare class RouterService {
4608
4625
  }
4609
4626
  declare const routerService: RouterService;
4610
4627
 
4611
- declare class SignerService {
4612
- private readonly provider;
4628
+ declare class SignerService implements ConfigObserver {
4629
+ private provider;
4613
4630
  private readonly routerService;
4614
4631
  constructor();
4632
+ /**
4633
+ * Implementation of ConfigObserver interface
4634
+ * Updates service when config changes
4635
+ */
4636
+ onConfigUpdate(newConfig: AppConfig): void;
4615
4637
  getDomain(): Promise<{
4616
4638
  name: string;
4617
4639
  version: string;
@@ -4652,9 +4674,14 @@ declare const SubmitSettlementResponseSchema: z.ZodObject<{
4652
4674
  }>;
4653
4675
  type SubmitSettlementRequest = z.infer<typeof SubmitSettlementRequestSchema>;
4654
4676
  type SubmitSettlementResponse = z.infer<typeof SubmitSettlementResponseSchema>;
4655
- declare class SolverService {
4656
- private readonly baseURL;
4677
+ declare class SolverService implements ConfigObserver {
4678
+ private baseURL;
4657
4679
  constructor();
4680
+ /**
4681
+ * Implementation of ConfigObserver interface
4682
+ * Updates service when config changes
4683
+ */
4684
+ onConfigUpdate(newConfig: AppConfig): void;
4658
4685
  /**
4659
4686
  * Submits a settlement transaction to the solver backend
4660
4687
  * @param params Settlement transaction parameters
@@ -4704,9 +4731,14 @@ declare const TokenSchema: z.ZodObject<{
4704
4731
  }>;
4705
4732
  type Token = z.infer<typeof TokenSchema>;
4706
4733
 
4707
- declare class TokenService {
4708
- private readonly baseURL;
4734
+ declare class TokenService implements ConfigObserver {
4735
+ private baseURL;
4709
4736
  constructor();
4737
+ /**
4738
+ * Implementation of ConfigObserver interface
4739
+ * Updates service when config changes
4740
+ */
4741
+ onConfigUpdate(newConfig: AppConfig): void;
4710
4742
  /**
4711
4743
  * Fetches all available tokens from the API
4712
4744
  * @returns Promise<Token[]> Array of tokens
@@ -4803,4 +4835,4 @@ declare function camelToSnakeCase(str: string): string;
4803
4835
  declare const ensureHexPrefix: (value: string) => string;
4804
4836
  declare const removeHexPrefix: (value: string) => string;
4805
4837
 
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 };
4838
+ 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')
@@ -4578,10 +4590,15 @@ declare namespace index {
4578
4590
  export { index_ERC20__factory as ERC20__factory, index_Payment__factory as Payment__factory, index_Router__factory as Router__factory, index_Signer__factory as Signer__factory };
4579
4591
  }
4580
4592
 
4581
- declare class RouterService {
4582
- private readonly provider;
4583
- private readonly contract;
4593
+ declare class RouterService implements ConfigObserver {
4594
+ private provider;
4595
+ private contract;
4584
4596
  constructor();
4597
+ /**
4598
+ * Implementation of ConfigObserver interface
4599
+ * Updates service when config changes
4600
+ */
4601
+ onConfigUpdate(newConfig: AppConfig): void;
4585
4602
  getSigner(): Promise<string>;
4586
4603
  getCurrentPubkey(network: string): Promise<ITypes.MPCInfoStructOutput>;
4587
4604
  getCurrentStage(tradeId: BytesLike): Promise<bigint>;
@@ -4608,10 +4625,15 @@ declare class RouterService {
4608
4625
  }
4609
4626
  declare const routerService: RouterService;
4610
4627
 
4611
- declare class SignerService {
4612
- private readonly provider;
4628
+ declare class SignerService implements ConfigObserver {
4629
+ private provider;
4613
4630
  private readonly routerService;
4614
4631
  constructor();
4632
+ /**
4633
+ * Implementation of ConfigObserver interface
4634
+ * Updates service when config changes
4635
+ */
4636
+ onConfigUpdate(newConfig: AppConfig): void;
4615
4637
  getDomain(): Promise<{
4616
4638
  name: string;
4617
4639
  version: string;
@@ -4652,9 +4674,14 @@ declare const SubmitSettlementResponseSchema: z.ZodObject<{
4652
4674
  }>;
4653
4675
  type SubmitSettlementRequest = z.infer<typeof SubmitSettlementRequestSchema>;
4654
4676
  type SubmitSettlementResponse = z.infer<typeof SubmitSettlementResponseSchema>;
4655
- declare class SolverService {
4656
- private readonly baseURL;
4677
+ declare class SolverService implements ConfigObserver {
4678
+ private baseURL;
4657
4679
  constructor();
4680
+ /**
4681
+ * Implementation of ConfigObserver interface
4682
+ * Updates service when config changes
4683
+ */
4684
+ onConfigUpdate(newConfig: AppConfig): void;
4658
4685
  /**
4659
4686
  * Submits a settlement transaction to the solver backend
4660
4687
  * @param params Settlement transaction parameters
@@ -4704,9 +4731,14 @@ declare const TokenSchema: z.ZodObject<{
4704
4731
  }>;
4705
4732
  type Token = z.infer<typeof TokenSchema>;
4706
4733
 
4707
- declare class TokenService {
4708
- private readonly baseURL;
4734
+ declare class TokenService implements ConfigObserver {
4735
+ private baseURL;
4709
4736
  constructor();
4737
+ /**
4738
+ * Implementation of ConfigObserver interface
4739
+ * Updates service when config changes
4740
+ */
4741
+ onConfigUpdate(newConfig: AppConfig): void;
4710
4742
  /**
4711
4743
  * Fetches all available tokens from the API
4712
4744
  * @returns Promise<Token[]> Array of tokens
@@ -4803,4 +4835,4 @@ declare function camelToSnakeCase(str: string): string;
4803
4835
  declare const ensureHexPrefix: (value: string) => string;
4804
4836
  declare const removeHexPrefix: (value: string) => string;
4805
4837
 
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 };
4838
+ 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]) {
@@ -3487,6 +3502,15 @@ var RouterService = class {
3487
3502
  constructor() {
3488
3503
  this.provider = new import_ethers5.JsonRpcProvider(config.getRpcUrl());
3489
3504
  this.contract = Router__factory.connect(config.getRouterAddress(), this.provider);
3505
+ config.registerObserver(this);
3506
+ }
3507
+ /**
3508
+ * Implementation of ConfigObserver interface
3509
+ * Updates service when config changes
3510
+ */
3511
+ onConfigUpdate(newConfig) {
3512
+ this.provider = new import_ethers5.JsonRpcProvider(newConfig.rpcUrl);
3513
+ this.contract = Router__factory.connect(newConfig.routerAddress, this.provider);
3490
3514
  }
3491
3515
  async getSigner() {
3492
3516
  return await this.contract.SIGNER();
@@ -3566,6 +3590,14 @@ var SignerService = class {
3566
3590
  constructor() {
3567
3591
  this.routerService = routerService;
3568
3592
  this.provider = new import_ethers6.JsonRpcProvider(config.getRpcUrl());
3593
+ config.registerObserver(this);
3594
+ }
3595
+ /**
3596
+ * Implementation of ConfigObserver interface
3597
+ * Updates service when config changes
3598
+ */
3599
+ onConfigUpdate(newConfig) {
3600
+ this.provider = new import_ethers6.JsonRpcProvider(newConfig.rpcUrl);
3569
3601
  }
3570
3602
  async getDomain() {
3571
3603
  const signerAddress = await this.routerService.getSigner();
@@ -3644,6 +3676,14 @@ var SubmitSettlementResponseSchema = import_zod.z.object({
3644
3676
  var SolverService = class {
3645
3677
  constructor() {
3646
3678
  this.baseURL = config.getBackendUrl();
3679
+ config.registerObserver(this);
3680
+ }
3681
+ /**
3682
+ * Implementation of ConfigObserver interface
3683
+ * Updates service when config changes
3684
+ */
3685
+ onConfigUpdate(newConfig) {
3686
+ this.baseURL = newConfig.backendUrl;
3647
3687
  }
3648
3688
  /**
3649
3689
  * Submits a settlement transaction to the solver backend
@@ -3709,6 +3749,14 @@ var TokenResponseSchema = import_zod3.z.object({
3709
3749
  var TokenService = class {
3710
3750
  constructor() {
3711
3751
  this.baseURL = config.getBackendUrl();
3752
+ config.registerObserver(this);
3753
+ }
3754
+ /**
3755
+ * Implementation of ConfigObserver interface
3756
+ * Updates service when config changes
3757
+ */
3758
+ onConfigUpdate(newConfig) {
3759
+ this.baseURL = newConfig.backendUrl;
3712
3760
  }
3713
3761
  /**
3714
3762
  * 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]) {
@@ -3422,6 +3437,15 @@ var RouterService = class {
3422
3437
  constructor() {
3423
3438
  this.provider = new JsonRpcProvider(config.getRpcUrl());
3424
3439
  this.contract = Router__factory.connect(config.getRouterAddress(), this.provider);
3440
+ config.registerObserver(this);
3441
+ }
3442
+ /**
3443
+ * Implementation of ConfigObserver interface
3444
+ * Updates service when config changes
3445
+ */
3446
+ onConfigUpdate(newConfig) {
3447
+ this.provider = new JsonRpcProvider(newConfig.rpcUrl);
3448
+ this.contract = Router__factory.connect(newConfig.routerAddress, this.provider);
3425
3449
  }
3426
3450
  async getSigner() {
3427
3451
  return await this.contract.SIGNER();
@@ -3501,6 +3525,14 @@ var SignerService = class {
3501
3525
  constructor() {
3502
3526
  this.routerService = routerService;
3503
3527
  this.provider = new JsonRpcProvider2(config.getRpcUrl());
3528
+ config.registerObserver(this);
3529
+ }
3530
+ /**
3531
+ * Implementation of ConfigObserver interface
3532
+ * Updates service when config changes
3533
+ */
3534
+ onConfigUpdate(newConfig) {
3535
+ this.provider = new JsonRpcProvider2(newConfig.rpcUrl);
3504
3536
  }
3505
3537
  async getDomain() {
3506
3538
  const signerAddress = await this.routerService.getSigner();
@@ -3579,6 +3611,14 @@ var SubmitSettlementResponseSchema = z.object({
3579
3611
  var SolverService = class {
3580
3612
  constructor() {
3581
3613
  this.baseURL = config.getBackendUrl();
3614
+ config.registerObserver(this);
3615
+ }
3616
+ /**
3617
+ * Implementation of ConfigObserver interface
3618
+ * Updates service when config changes
3619
+ */
3620
+ onConfigUpdate(newConfig) {
3621
+ this.baseURL = newConfig.backendUrl;
3582
3622
  }
3583
3623
  /**
3584
3624
  * Submits a settlement transaction to the solver backend
@@ -3644,6 +3684,14 @@ var TokenResponseSchema = z3.object({
3644
3684
  var TokenService = class {
3645
3685
  constructor() {
3646
3686
  this.baseURL = config.getBackendUrl();
3687
+ config.registerObserver(this);
3688
+ }
3689
+ /**
3690
+ * Implementation of ConfigObserver interface
3691
+ * Updates service when config changes
3692
+ */
3693
+ onConfigUpdate(newConfig) {
3694
+ this.baseURL = newConfig.backendUrl;
3647
3695
  }
3648
3696
  /**
3649
3697
  * 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-4772ae2",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"