@optimex-xyz/market-maker-sdk 0.4.1 → 0.4.3
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 +47 -10
- package/dist/index.d.ts +47 -10
- package/dist/index.js +56 -1
- package/dist/index.mjs +56 -1
- package/package.json +2 -2
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')
|
|
@@ -35,6 +47,11 @@ declare class SDK {
|
|
|
35
47
|
* @param env The environment to use ('dev' or 'production')
|
|
36
48
|
*/
|
|
37
49
|
setEnvironment(env: Environment): void;
|
|
50
|
+
/**
|
|
51
|
+
* Get the current environment configuration
|
|
52
|
+
* @returns The current environment configuration
|
|
53
|
+
*/
|
|
54
|
+
getConfig(): AppConfig;
|
|
38
55
|
}
|
|
39
56
|
declare const sdk: SDK;
|
|
40
57
|
|
|
@@ -4573,10 +4590,15 @@ declare namespace index {
|
|
|
4573
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 };
|
|
4574
4591
|
}
|
|
4575
4592
|
|
|
4576
|
-
declare class RouterService {
|
|
4577
|
-
private
|
|
4578
|
-
private
|
|
4593
|
+
declare class RouterService implements ConfigObserver {
|
|
4594
|
+
private provider;
|
|
4595
|
+
private contract;
|
|
4579
4596
|
constructor();
|
|
4597
|
+
/**
|
|
4598
|
+
* Implementation of ConfigObserver interface
|
|
4599
|
+
* Updates service when config changes
|
|
4600
|
+
*/
|
|
4601
|
+
onConfigUpdate(newConfig: AppConfig): void;
|
|
4580
4602
|
getSigner(): Promise<string>;
|
|
4581
4603
|
getCurrentPubkey(network: string): Promise<ITypes.MPCInfoStructOutput>;
|
|
4582
4604
|
getCurrentStage(tradeId: BytesLike): Promise<bigint>;
|
|
@@ -4603,10 +4625,15 @@ declare class RouterService {
|
|
|
4603
4625
|
}
|
|
4604
4626
|
declare const routerService: RouterService;
|
|
4605
4627
|
|
|
4606
|
-
declare class SignerService {
|
|
4607
|
-
private
|
|
4628
|
+
declare class SignerService implements ConfigObserver {
|
|
4629
|
+
private provider;
|
|
4608
4630
|
private readonly routerService;
|
|
4609
4631
|
constructor();
|
|
4632
|
+
/**
|
|
4633
|
+
* Implementation of ConfigObserver interface
|
|
4634
|
+
* Updates service when config changes
|
|
4635
|
+
*/
|
|
4636
|
+
onConfigUpdate(newConfig: AppConfig): void;
|
|
4610
4637
|
getDomain(): Promise<{
|
|
4611
4638
|
name: string;
|
|
4612
4639
|
version: string;
|
|
@@ -4647,9 +4674,14 @@ declare const SubmitSettlementResponseSchema: z.ZodObject<{
|
|
|
4647
4674
|
}>;
|
|
4648
4675
|
type SubmitSettlementRequest = z.infer<typeof SubmitSettlementRequestSchema>;
|
|
4649
4676
|
type SubmitSettlementResponse = z.infer<typeof SubmitSettlementResponseSchema>;
|
|
4650
|
-
declare class SolverService {
|
|
4651
|
-
private
|
|
4677
|
+
declare class SolverService implements ConfigObserver {
|
|
4678
|
+
private baseURL;
|
|
4652
4679
|
constructor();
|
|
4680
|
+
/**
|
|
4681
|
+
* Implementation of ConfigObserver interface
|
|
4682
|
+
* Updates service when config changes
|
|
4683
|
+
*/
|
|
4684
|
+
onConfigUpdate(newConfig: AppConfig): void;
|
|
4653
4685
|
/**
|
|
4654
4686
|
* Submits a settlement transaction to the solver backend
|
|
4655
4687
|
* @param params Settlement transaction parameters
|
|
@@ -4699,9 +4731,14 @@ declare const TokenSchema: z.ZodObject<{
|
|
|
4699
4731
|
}>;
|
|
4700
4732
|
type Token = z.infer<typeof TokenSchema>;
|
|
4701
4733
|
|
|
4702
|
-
declare class TokenService {
|
|
4703
|
-
private
|
|
4734
|
+
declare class TokenService implements ConfigObserver {
|
|
4735
|
+
private baseURL;
|
|
4704
4736
|
constructor();
|
|
4737
|
+
/**
|
|
4738
|
+
* Implementation of ConfigObserver interface
|
|
4739
|
+
* Updates service when config changes
|
|
4740
|
+
*/
|
|
4741
|
+
onConfigUpdate(newConfig: AppConfig): void;
|
|
4705
4742
|
/**
|
|
4706
4743
|
* Fetches all available tokens from the API
|
|
4707
4744
|
* @returns Promise<Token[]> Array of tokens
|
|
@@ -4798,4 +4835,4 @@ declare function camelToSnakeCase(str: string): string;
|
|
|
4798
4835
|
declare const ensureHexPrefix: (value: string) => string;
|
|
4799
4836
|
declare const removeHexPrefix: (value: string) => string;
|
|
4800
4837
|
|
|
4801
|
-
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')
|
|
@@ -35,6 +47,11 @@ declare class SDK {
|
|
|
35
47
|
* @param env The environment to use ('dev' or 'production')
|
|
36
48
|
*/
|
|
37
49
|
setEnvironment(env: Environment): void;
|
|
50
|
+
/**
|
|
51
|
+
* Get the current environment configuration
|
|
52
|
+
* @returns The current environment configuration
|
|
53
|
+
*/
|
|
54
|
+
getConfig(): AppConfig;
|
|
38
55
|
}
|
|
39
56
|
declare const sdk: SDK;
|
|
40
57
|
|
|
@@ -4573,10 +4590,15 @@ declare namespace index {
|
|
|
4573
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 };
|
|
4574
4591
|
}
|
|
4575
4592
|
|
|
4576
|
-
declare class RouterService {
|
|
4577
|
-
private
|
|
4578
|
-
private
|
|
4593
|
+
declare class RouterService implements ConfigObserver {
|
|
4594
|
+
private provider;
|
|
4595
|
+
private contract;
|
|
4579
4596
|
constructor();
|
|
4597
|
+
/**
|
|
4598
|
+
* Implementation of ConfigObserver interface
|
|
4599
|
+
* Updates service when config changes
|
|
4600
|
+
*/
|
|
4601
|
+
onConfigUpdate(newConfig: AppConfig): void;
|
|
4580
4602
|
getSigner(): Promise<string>;
|
|
4581
4603
|
getCurrentPubkey(network: string): Promise<ITypes.MPCInfoStructOutput>;
|
|
4582
4604
|
getCurrentStage(tradeId: BytesLike): Promise<bigint>;
|
|
@@ -4603,10 +4625,15 @@ declare class RouterService {
|
|
|
4603
4625
|
}
|
|
4604
4626
|
declare const routerService: RouterService;
|
|
4605
4627
|
|
|
4606
|
-
declare class SignerService {
|
|
4607
|
-
private
|
|
4628
|
+
declare class SignerService implements ConfigObserver {
|
|
4629
|
+
private provider;
|
|
4608
4630
|
private readonly routerService;
|
|
4609
4631
|
constructor();
|
|
4632
|
+
/**
|
|
4633
|
+
* Implementation of ConfigObserver interface
|
|
4634
|
+
* Updates service when config changes
|
|
4635
|
+
*/
|
|
4636
|
+
onConfigUpdate(newConfig: AppConfig): void;
|
|
4610
4637
|
getDomain(): Promise<{
|
|
4611
4638
|
name: string;
|
|
4612
4639
|
version: string;
|
|
@@ -4647,9 +4674,14 @@ declare const SubmitSettlementResponseSchema: z.ZodObject<{
|
|
|
4647
4674
|
}>;
|
|
4648
4675
|
type SubmitSettlementRequest = z.infer<typeof SubmitSettlementRequestSchema>;
|
|
4649
4676
|
type SubmitSettlementResponse = z.infer<typeof SubmitSettlementResponseSchema>;
|
|
4650
|
-
declare class SolverService {
|
|
4651
|
-
private
|
|
4677
|
+
declare class SolverService implements ConfigObserver {
|
|
4678
|
+
private baseURL;
|
|
4652
4679
|
constructor();
|
|
4680
|
+
/**
|
|
4681
|
+
* Implementation of ConfigObserver interface
|
|
4682
|
+
* Updates service when config changes
|
|
4683
|
+
*/
|
|
4684
|
+
onConfigUpdate(newConfig: AppConfig): void;
|
|
4653
4685
|
/**
|
|
4654
4686
|
* Submits a settlement transaction to the solver backend
|
|
4655
4687
|
* @param params Settlement transaction parameters
|
|
@@ -4699,9 +4731,14 @@ declare const TokenSchema: z.ZodObject<{
|
|
|
4699
4731
|
}>;
|
|
4700
4732
|
type Token = z.infer<typeof TokenSchema>;
|
|
4701
4733
|
|
|
4702
|
-
declare class TokenService {
|
|
4703
|
-
private
|
|
4734
|
+
declare class TokenService implements ConfigObserver {
|
|
4735
|
+
private baseURL;
|
|
4704
4736
|
constructor();
|
|
4737
|
+
/**
|
|
4738
|
+
* Implementation of ConfigObserver interface
|
|
4739
|
+
* Updates service when config changes
|
|
4740
|
+
*/
|
|
4741
|
+
onConfigUpdate(newConfig: AppConfig): void;
|
|
4705
4742
|
/**
|
|
4706
4743
|
* Fetches all available tokens from the API
|
|
4707
4744
|
* @returns Promise<Token[]> Array of tokens
|
|
@@ -4798,4 +4835,4 @@ declare function camelToSnakeCase(str: string): string;
|
|
|
4798
4835
|
declare const ensureHexPrefix: (value: string) => string;
|
|
4799
4836
|
declare const removeHexPrefix: (value: string) => string;
|
|
4800
4837
|
|
|
4801
|
-
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]) {
|
|
@@ -140,6 +155,13 @@ var SDK = class {
|
|
|
140
155
|
setEnvironment(env) {
|
|
141
156
|
config.setEnvironment(env);
|
|
142
157
|
}
|
|
158
|
+
/**
|
|
159
|
+
* Get the current environment configuration
|
|
160
|
+
* @returns The current environment configuration
|
|
161
|
+
*/
|
|
162
|
+
getConfig() {
|
|
163
|
+
return config.get();
|
|
164
|
+
}
|
|
143
165
|
};
|
|
144
166
|
var sdk = new SDK();
|
|
145
167
|
|
|
@@ -3480,6 +3502,15 @@ var RouterService = class {
|
|
|
3480
3502
|
constructor() {
|
|
3481
3503
|
this.provider = new import_ethers5.JsonRpcProvider(config.getRpcUrl());
|
|
3482
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);
|
|
3483
3514
|
}
|
|
3484
3515
|
async getSigner() {
|
|
3485
3516
|
return await this.contract.SIGNER();
|
|
@@ -3559,6 +3590,14 @@ var SignerService = class {
|
|
|
3559
3590
|
constructor() {
|
|
3560
3591
|
this.routerService = routerService;
|
|
3561
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);
|
|
3562
3601
|
}
|
|
3563
3602
|
async getDomain() {
|
|
3564
3603
|
const signerAddress = await this.routerService.getSigner();
|
|
@@ -3637,6 +3676,14 @@ var SubmitSettlementResponseSchema = import_zod.z.object({
|
|
|
3637
3676
|
var SolverService = class {
|
|
3638
3677
|
constructor() {
|
|
3639
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;
|
|
3640
3687
|
}
|
|
3641
3688
|
/**
|
|
3642
3689
|
* Submits a settlement transaction to the solver backend
|
|
@@ -3649,7 +3696,7 @@ var SolverService = class {
|
|
|
3649
3696
|
SubmitSettlementRequestSchema.parse(params);
|
|
3650
3697
|
const snakeCaseParams = convertToSnakeCase(params);
|
|
3651
3698
|
const response = await import_axios.default.post(
|
|
3652
|
-
`${this.baseURL}/solver/submit-settlement-tx`,
|
|
3699
|
+
`${this.baseURL}/v1/solver/submit-settlement-tx`,
|
|
3653
3700
|
snakeCaseParams,
|
|
3654
3701
|
{
|
|
3655
3702
|
headers: {
|
|
@@ -3702,6 +3749,14 @@ var TokenResponseSchema = import_zod3.z.object({
|
|
|
3702
3749
|
var TokenService = class {
|
|
3703
3750
|
constructor() {
|
|
3704
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;
|
|
3705
3760
|
}
|
|
3706
3761
|
/**
|
|
3707
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]) {
|
|
@@ -75,6 +90,13 @@ var SDK = class {
|
|
|
75
90
|
setEnvironment(env) {
|
|
76
91
|
config.setEnvironment(env);
|
|
77
92
|
}
|
|
93
|
+
/**
|
|
94
|
+
* Get the current environment configuration
|
|
95
|
+
* @returns The current environment configuration
|
|
96
|
+
*/
|
|
97
|
+
getConfig() {
|
|
98
|
+
return config.get();
|
|
99
|
+
}
|
|
78
100
|
};
|
|
79
101
|
var sdk = new SDK();
|
|
80
102
|
|
|
@@ -3415,6 +3437,15 @@ var RouterService = class {
|
|
|
3415
3437
|
constructor() {
|
|
3416
3438
|
this.provider = new JsonRpcProvider(config.getRpcUrl());
|
|
3417
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);
|
|
3418
3449
|
}
|
|
3419
3450
|
async getSigner() {
|
|
3420
3451
|
return await this.contract.SIGNER();
|
|
@@ -3494,6 +3525,14 @@ var SignerService = class {
|
|
|
3494
3525
|
constructor() {
|
|
3495
3526
|
this.routerService = routerService;
|
|
3496
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);
|
|
3497
3536
|
}
|
|
3498
3537
|
async getDomain() {
|
|
3499
3538
|
const signerAddress = await this.routerService.getSigner();
|
|
@@ -3572,6 +3611,14 @@ var SubmitSettlementResponseSchema = z.object({
|
|
|
3572
3611
|
var SolverService = class {
|
|
3573
3612
|
constructor() {
|
|
3574
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;
|
|
3575
3622
|
}
|
|
3576
3623
|
/**
|
|
3577
3624
|
* Submits a settlement transaction to the solver backend
|
|
@@ -3584,7 +3631,7 @@ var SolverService = class {
|
|
|
3584
3631
|
SubmitSettlementRequestSchema.parse(params);
|
|
3585
3632
|
const snakeCaseParams = convertToSnakeCase(params);
|
|
3586
3633
|
const response = await axios.post(
|
|
3587
|
-
`${this.baseURL}/solver/submit-settlement-tx`,
|
|
3634
|
+
`${this.baseURL}/v1/solver/submit-settlement-tx`,
|
|
3588
3635
|
snakeCaseParams,
|
|
3589
3636
|
{
|
|
3590
3637
|
headers: {
|
|
@@ -3637,6 +3684,14 @@ var TokenResponseSchema = z3.object({
|
|
|
3637
3684
|
var TokenService = class {
|
|
3638
3685
|
constructor() {
|
|
3639
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;
|
|
3640
3695
|
}
|
|
3641
3696
|
/**
|
|
3642
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.4.
|
|
3
|
+
"version": "0.4.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"commit": "cz"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"axios": "^1.
|
|
45
|
+
"axios": "^1.8.2",
|
|
46
46
|
"bip174": "^3.0.0-rc.1",
|
|
47
47
|
"bitcoinjs-lib": "^7.0.0-rc.0",
|
|
48
48
|
"ecpair": "^3.0.0-rc.0",
|