@1inch/fusion-sdk 0.1.9 → 0.1.11
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/README.md +3 -2
- package/api/fusion-api.d.ts +2 -0
- package/api/fusion-api.js +15 -4
- package/api/fusion-api.js.map +1 -1
- package/api/orders/orders.api.d.ts +2 -2
- package/api/orders/orders.api.js +1 -1
- package/api/orders/orders.api.js.map +1 -1
- package/api/orders/types.d.ts +1 -0
- package/api/orders/types.js.map +1 -1
- package/api/quoter/index.d.ts +1 -0
- package/api/quoter/index.js +1 -0
- package/api/quoter/index.js.map +1 -1
- package/api/quoter/quote/quote.d.ts +6 -1
- package/api/quoter/quote/quote.js +4 -1
- package/api/quoter/quote/quote.js.map +1 -1
- package/api/quoter/quoter-custom-preset.request.d.ts +10 -0
- package/api/quoter/quoter-custom-preset.request.js +66 -0
- package/api/quoter/quoter-custom-preset.request.js.map +1 -0
- package/api/quoter/quoter.api.d.ts +4 -2
- package/api/quoter/quoter.api.js +18 -1
- package/api/quoter/quoter.api.js.map +1 -1
- package/api/quoter/types.d.ts +17 -1
- package/api/quoter/types.js +1 -0
- package/api/quoter/types.js.map +1 -1
- package/api/relayer/relayer.api.d.ts +2 -2
- package/api/relayer/relayer.api.js +1 -1
- package/api/relayer/relayer.api.js.map +1 -1
- package/api/relayer/types.d.ts +1 -0
- package/api/types.d.ts +1 -0
- package/connector/http/axios-provider.connector.d.ts +2 -0
- package/connector/http/axios-provider.connector.js +39 -5
- package/connector/http/axios-provider.connector.js.map +1 -1
- package/connector/ws/types.d.ts +1 -0
- package/connector/ws/websocket-client.connector.d.ts +1 -0
- package/connector/ws/websocket-client.connector.js +15 -2
- package/connector/ws/websocket-client.connector.js.map +1 -1
- package/errors.d.ts +3 -0
- package/errors.js +10 -0
- package/errors.js.map +1 -0
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/index.js.map +1 -1
- package/package.json +2 -2
- package/sdk/sdk.d.ts +3 -1
- package/sdk/sdk.js +43 -9
- package/sdk/sdk.js.map +1 -1
- package/sdk/types.d.ts +6 -1
- package/api/orders/order-api.spec.d.ts +0 -1
- package/api/orders/order-api.spec.js +0 -431
- package/api/orders/order-api.spec.js.map +0 -1
- package/api/pagination.spec.d.ts +0 -1
- package/api/pagination.spec.js +0 -28
- package/api/pagination.spec.js.map +0 -1
- package/api/quoter/quoter.api.spec.d.ts +0 -1
- package/api/quoter/quoter.api.spec.js +0 -141
- package/api/quoter/quoter.api.spec.js.map +0 -1
- package/api/relayer/relayer.api.spec.d.ts +0 -1
- package/api/relayer/relayer.api.spec.js +0 -85
- package/api/relayer/relayer.api.spec.js.map +0 -1
- package/auction-calculator/auction-calculator.spec.d.ts +0 -1
- package/auction-calculator/auction-calculator.spec.js +0 -35
- package/auction-calculator/auction-calculator.spec.js.map +0 -1
- package/auction-salt/auction.salt.spec.d.ts +0 -1
- package/auction-salt/auction.salt.spec.js +0 -59
- package/auction-salt/auction.salt.spec.js.map +0 -1
- package/auction-suffix/auction-suffix.spec.d.ts +0 -1
- package/auction-suffix/auction-suffix.spec.js +0 -73
- package/auction-suffix/auction-suffix.spec.js.map +0 -1
- package/connector/blockchain/private-key-provider.connector.spec.d.ts +0 -1
- package/connector/blockchain/private-key-provider.connector.spec.js +0 -48
- package/connector/blockchain/private-key-provider.connector.spec.js.map +0 -1
- package/connector/blockchain/web3-provider.connector.spec.d.ts +0 -1
- package/connector/blockchain/web3-provider.connector.spec.js +0 -51
- package/connector/blockchain/web3-provider.connector.spec.js.map +0 -1
- package/connector/http/axios-provider.connector.spec.d.ts +0 -1
- package/connector/http/axios-provider.connector.spec.js +0 -33
- package/connector/http/axios-provider.connector.spec.js.map +0 -1
- package/fusion-order/fusion-order.spec.d.ts +0 -1
- package/fusion-order/fusion-order.spec.js +0 -54
- package/fusion-order/fusion-order.spec.js.map +0 -1
- package/limit-order/limit-order.spec.d.ts +0 -1
- package/limit-order/limit-order.spec.js +0 -196
- package/limit-order/limit-order.spec.js.map +0 -1
- package/limit-order/predicate-factory.spec.d.ts +0 -1
- package/limit-order/predicate-factory.spec.js +0 -35
- package/limit-order/predicate-factory.spec.js.map +0 -1
- package/nonce-manager/nonce-manager.spec.d.ts +0 -1
- package/nonce-manager/nonce-manager.spec.js +0 -20
- package/nonce-manager/nonce-manager.spec.js.map +0 -1
- package/sdk/sdk.spec.d.ts +0 -1
- package/sdk/sdk.spec.js +0 -85
- package/sdk/sdk.spec.js.map +0 -1
- package/settlement/settlement.spec.d.ts +0 -1
- package/settlement/settlement.spec.js +0 -67
- package/settlement/settlement.spec.js.map +0 -1
- package/ws-api/ws.spec.d.ts +0 -1
- package/ws-api/ws.spec.js +0 -583
- package/ws-api/ws.spec.js.map +0 -1
package/README.md
CHANGED
|
@@ -37,9 +37,10 @@ const blockchainProvider = new PrivateKeyProviderConnector(
|
|
|
37
37
|
)
|
|
38
38
|
|
|
39
39
|
const sdk = new FusionSDK({
|
|
40
|
-
url: 'https://
|
|
40
|
+
url: 'https://api.1inch.dev/fusion',
|
|
41
41
|
network: 1,
|
|
42
|
-
blockchainProvider
|
|
42
|
+
blockchainProvider,
|
|
43
|
+
authKey: 'your-auth-key'
|
|
43
44
|
})
|
|
44
45
|
|
|
45
46
|
sdk.placeOrder({
|
package/api/fusion-api.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { QuoterRequest } from './quoter';
|
|
|
3
3
|
import { RelayerRequest } from './relayer';
|
|
4
4
|
import { Quote } from './quoter/quote/quote';
|
|
5
5
|
import { ActiveOrdersRequest, ActiveOrdersResponse, OrdersByMakerRequest, OrderStatusRequest, OrderStatusResponse, OrdersByMakerResponse } from './orders';
|
|
6
|
+
import { QuoterCustomPresetRequest } from './quoter/quoter-custom-preset.request';
|
|
6
7
|
export declare class FusionApi {
|
|
7
8
|
private readonly quoterApi;
|
|
8
9
|
private readonly relayerApi;
|
|
@@ -10,6 +11,7 @@ export declare class FusionApi {
|
|
|
10
11
|
constructor(config: FusionApiConfig);
|
|
11
12
|
static new(config: FusionApiConfig): FusionApi;
|
|
12
13
|
getQuote(params: QuoterRequest): Promise<Quote>;
|
|
14
|
+
getQuoteWithCustomPreset(params: QuoterRequest, body: QuoterCustomPresetRequest): Promise<Quote>;
|
|
13
15
|
getActiveOrders(params?: ActiveOrdersRequest): Promise<ActiveOrdersResponse>;
|
|
14
16
|
getOrderStatus(params: OrderStatusRequest): Promise<OrderStatusResponse>;
|
|
15
17
|
getOrdersByMaker(params: OrdersByMakerRequest): Promise<OrdersByMakerResponse>;
|
package/api/fusion-api.js
CHANGED
|
@@ -9,24 +9,35 @@ class FusionApi {
|
|
|
9
9
|
constructor(config) {
|
|
10
10
|
this.quoterApi = quoter_1.QuoterApi.new({
|
|
11
11
|
url: `${config.url}/quoter`,
|
|
12
|
-
network: config.network
|
|
12
|
+
network: config.network,
|
|
13
|
+
authKey: config.authKey
|
|
13
14
|
}, config.httpProvider);
|
|
14
15
|
this.relayerApi = relayer_1.RelayerApi.new({
|
|
15
16
|
url: `${config.url}/relayer`,
|
|
16
|
-
network: config.network
|
|
17
|
+
network: config.network,
|
|
18
|
+
authKey: config.authKey
|
|
19
|
+
}, config.httpProvider);
|
|
20
|
+
this.ordersApi = orders_1.OrdersApi.new({
|
|
21
|
+
url: `${config.url}/orders`,
|
|
22
|
+
network: config.network,
|
|
23
|
+
authKey: config.authKey
|
|
17
24
|
}, config.httpProvider);
|
|
18
|
-
this.ordersApi = orders_1.OrdersApi.new({ url: `${config.url}/orders`, network: config.network }, config.httpProvider);
|
|
19
25
|
}
|
|
20
26
|
static new(config) {
|
|
21
27
|
return new FusionApi({
|
|
22
28
|
network: config.network,
|
|
23
29
|
url: config.url,
|
|
24
|
-
|
|
30
|
+
authKey: config.authKey,
|
|
31
|
+
httpProvider: config.httpProvider ||
|
|
32
|
+
new connector_1.AxiosProviderConnector(config.authKey)
|
|
25
33
|
});
|
|
26
34
|
}
|
|
27
35
|
getQuote(params) {
|
|
28
36
|
return this.quoterApi.getQuote(params);
|
|
29
37
|
}
|
|
38
|
+
getQuoteWithCustomPreset(params, body) {
|
|
39
|
+
return this.quoterApi.getQuoteWithCustomPreset(params, body);
|
|
40
|
+
}
|
|
30
41
|
getActiveOrders(params = orders_1.ActiveOrdersRequest.new()) {
|
|
31
42
|
return this.ordersApi.getActiveOrders(params);
|
|
32
43
|
}
|
package/api/fusion-api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fusion-api.js","sourceRoot":"","sources":["../../src/api/fusion-api.ts"],"names":[],"mappings":";;;AACA,qCAAiD;AACjD,uCAAoD;AACpD,4CAAmD;AAEnD,qCAQiB;
|
|
1
|
+
{"version":3,"file":"fusion-api.js","sourceRoot":"","sources":["../../src/api/fusion-api.ts"],"names":[],"mappings":";;;AACA,qCAAiD;AACjD,uCAAoD;AACpD,4CAAmD;AAEnD,qCAQiB;AAGjB,MAAa,SAAS;IAOlB,YAAY,MAAuB;QAC/B,IAAI,CAAC,SAAS,GAAG,kBAAS,CAAC,GAAG,CAC1B;YACI,GAAG,EAAE,GAAG,MAAM,CAAC,GAAG,SAAS;YAC3B,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,OAAO,EAAE,MAAM,CAAC,OAAO;SAC1B,EACD,MAAM,CAAC,YAAY,CACtB,CAAA;QAED,IAAI,CAAC,UAAU,GAAG,oBAAU,CAAC,GAAG,CAC5B;YACI,GAAG,EAAE,GAAG,MAAM,CAAC,GAAG,UAAU;YAC5B,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,OAAO,EAAE,MAAM,CAAC,OAAO;SAC1B,EACD,MAAM,CAAC,YAAY,CACtB,CAAA;QAED,IAAI,CAAC,SAAS,GAAG,kBAAS,CAAC,GAAG,CAC1B;YACI,GAAG,EAAE,GAAG,MAAM,CAAC,GAAG,SAAS;YAC3B,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,OAAO,EAAE,MAAM,CAAC,OAAO;SAC1B,EACD,MAAM,CAAC,YAAY,CACtB,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ByMakerRequest, OrderStatusRequest } from './orders.request';
|
|
3
3
|
import { ActiveOrdersResponse, OrdersApiConfig, OrdersByMakerResponse, OrderStatusResponse } from './types';
|
|
4
4
|
export declare class OrdersApi {
|
|
5
5
|
private readonly config;
|
|
6
6
|
private readonly httpClient;
|
|
7
7
|
constructor(config: OrdersApiConfig, httpClient: HttpProviderConnector);
|
|
8
|
-
static new(config: OrdersApiConfig, httpClient?:
|
|
8
|
+
static new(config: OrdersApiConfig, httpClient?: HttpProviderConnector): OrdersApi;
|
|
9
9
|
getActiveOrders(params: ActiveOrdersRequest): Promise<ActiveOrdersResponse>;
|
|
10
10
|
getOrderStatus(params: OrderStatusRequest): Promise<OrderStatusResponse>;
|
|
11
11
|
getOrdersByMaker(params: OrdersByMakerRequest): Promise<OrdersByMakerResponse>;
|
package/api/orders/orders.api.js
CHANGED
|
@@ -9,7 +9,7 @@ class OrdersApi {
|
|
|
9
9
|
this.config = config;
|
|
10
10
|
this.httpClient = httpClient;
|
|
11
11
|
}
|
|
12
|
-
static new(config, httpClient = new connector_1.AxiosProviderConnector()) {
|
|
12
|
+
static new(config, httpClient = new connector_1.AxiosProviderConnector(config.authKey)) {
|
|
13
13
|
return new OrdersApi(config, httpClient);
|
|
14
14
|
}
|
|
15
15
|
getActiveOrders(params) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orders.api.js","sourceRoot":"","sources":["../../../src/api/orders/orders.api.ts"],"names":[],"mappings":";;;;AAAA,+CAA6E;AAC7E,sCAA2C;AAa3C,MAAa,SAAS;IAClB,YACqB,MAAuB,EACvB,UAAiC;QADjC,WAAM,GAAN,MAAM,CAAiB;QACvB,eAAU,GAAV,UAAU,CAAuB;IACnD,CAAC;IAEJ,MAAM,CAAC,GAAG,CACN,MAAuB,EACvB,
|
|
1
|
+
{"version":3,"file":"orders.api.js","sourceRoot":"","sources":["../../../src/api/orders/orders.api.ts"],"names":[],"mappings":";;;;AAAA,+CAA6E;AAC7E,sCAA2C;A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AAE;gBACL,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,CAAA;aACvB;YAED,MAAM,WAAW,GAAG,IAAA,0BAAiB,EAAC,MAAM,CAAC,gBAAgB,EAAE,CAAC,CAAA;YAChE,MAAM,GAAG,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,SAAS,IAAI,CAAC,MAAM,CAAC,OAAO,gBAAgB,MAAM,CAAC,OAAO,IAAI,WAAW,EAAE,CAAA;YAEzG,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QACnC,CAAC;KAAA;CACJ;AA1DD,8BA0DC"}
|
package/api/orders/types.d.ts
CHANGED
package/api/orders/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/api/orders/types.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/api/orders/types.ts"],"names":[],"mappings":";;;AA8BA,IAAY,WAUX;AAVD,WAAY,WAAW;IACnB,kCAAmB,CAAA;IACnB,gCAAiB,CAAA;IACjB,iDAAkC,CAAA;IAClC,8EAA+D,CAAA;IAC/D,kCAAmB,CAAA;IACnB,mDAAoC,CAAA;IACpC,2CAA4B,CAAA;IAC5B,sCAAuB,CAAA;IACvB,qDAAsC,CAAA;AAC1C,CAAC,EAVW,WAAW,GAAX,mBAAW,KAAX,mBAAW,QAUtB"}
|
package/api/quoter/index.d.ts
CHANGED
package/api/quoter/index.js
CHANGED
|
@@ -6,4 +6,5 @@ tslib_1.__exportStar(require("./quoter.request"), exports);
|
|
|
6
6
|
tslib_1.__exportStar(require("./quoter.api"), exports);
|
|
7
7
|
tslib_1.__exportStar(require("./types"), exports);
|
|
8
8
|
tslib_1.__exportStar(require("./preset"), exports);
|
|
9
|
+
tslib_1.__exportStar(require("./quoter-custom-preset.request"), exports);
|
|
9
10
|
//# sourceMappingURL=index.js.map
|
package/api/quoter/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/quoter/index.ts"],"names":[],"mappings":";;;AAAA,wDAA6B;AAC7B,2DAAgC;AAChC,uDAA4B;AAC5B,kDAAuB;AACvB,mDAAwB"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/quoter/index.ts"],"names":[],"mappings":";;;AAAA,wDAA6B;AAC7B,2DAAgC;AAChC,uDAA4B;AAC5B,kDAAuB;AACvB,mDAAwB;AACxB,yEAA8C"}
|
|
@@ -9,7 +9,12 @@ export declare class Quote {
|
|
|
9
9
|
private readonly params;
|
|
10
10
|
readonly fromTokenAmount: string;
|
|
11
11
|
readonly feeToken: string;
|
|
12
|
-
readonly presets:
|
|
12
|
+
readonly presets: {
|
|
13
|
+
[PresetEnum.fast]: Preset;
|
|
14
|
+
[PresetEnum.slow]: Preset;
|
|
15
|
+
[PresetEnum.medium]: Preset;
|
|
16
|
+
[PresetEnum.custom]?: Preset;
|
|
17
|
+
};
|
|
13
18
|
readonly recommendedPreset: PresetEnum;
|
|
14
19
|
readonly toTokenAmount: string;
|
|
15
20
|
readonly prices: Cost;
|
|
@@ -20,7 +20,10 @@ class Quote {
|
|
|
20
20
|
this.presets = {
|
|
21
21
|
[types_1.PresetEnum.fast]: new preset_1.Preset(response.presets.fast),
|
|
22
22
|
[types_1.PresetEnum.medium]: new preset_1.Preset(response.presets.medium),
|
|
23
|
-
[types_1.PresetEnum.slow]: new preset_1.Preset(response.presets.slow)
|
|
23
|
+
[types_1.PresetEnum.slow]: new preset_1.Preset(response.presets.slow),
|
|
24
|
+
[types_1.PresetEnum.custom]: response.presets.custom
|
|
25
|
+
? new preset_1.Preset(response.presets.custom)
|
|
26
|
+
: undefined
|
|
24
27
|
};
|
|
25
28
|
this.toTokenAmount = response.toTokenAmount;
|
|
26
29
|
this.prices = response.prices;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quote.js","sourceRoot":"","sources":["../../../../src/api/quoter/quote/quote.ts"],"names":[],"mappings":";;;AAAA,oCAAyD;AACzD,sCAAgC;AAChC,4DAAqD;AACrD,wDAAiD;AACjD,0CAA+C;AAC/C,kDAM2B;AAC3B,oFAA6E;AAE7E,iDAAgD;AAEhD,8EAAuE;AACvE,8CAAmD;AAEnD,MAAa,KAAK;
|
|
1
|
+
{"version":3,"file":"quote.js","sourceRoot":"","sources":["../../../../src/api/quoter/quote/quote.ts"],"names":[],"mappings":";;;AAAA,oCAAyD;AACzD,sCAAgC;AAChC,4DAAqD;AACrD,wDAAiD;AACjD,0CAA+C;AAC/C,kDAM2B;AAC3B,oFAA6E;AAE7E,iDAAgD;AAEhD,8EAAuE;AACvE,8CAAmD;AAEnD,MAAa,KAAK;IA0Bd,YACqB,OAAoB,EACpB,MAAqB,EACtC,QAAwB;QAFP,YAAO,GAAP,OAAO,CAAa;QACpB,WAAM,GAAN,MAAM,CAAe;QAGtC,IAAI,CAAC,eAAe,GAAG,QAAQ,CAAC,eAAe,CAAA;QAC/C,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC,QAAQ,CAAA;QACjC,IAAI,CAAC,OAAO,GAAG;YACX,CAAC,kBAAU,CAAC,IAAI,CAAC,EAAE,IAAI,eAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC;YACpD,CAAC,kBAAU,CAAC,MAAM,CAAC,EAAE,IAAI,eAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC;YACxD,CAAC,kBAAU,CAAC,IAAI,CAAC,EAAE,IAAI,eAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC;YACpD,CAAC,kBAAU,CAAC,MAAM,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,MAAM;gBACxC,CAAC,CAAC,IAAI,eAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC;gBACrC,CAAC,CAAC,SAAS;SAClB,CAA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B,GAAG,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC;gBAC3D,CAAC,CAAC,SAAS;SAClB,CACJ,CAAA;IACL,CAAC;IAED,SAAS,CAAC,IAAI,GAAG,kBAAU,CAAC,IAAI;QAC5B,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAW,CAAA;IACvC,CAAC;IAEO,eAAe,CAAC,MAAuB;QAC3C,IAAI,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,KAAK,EAAE;YACf,OAAO,oCAAgB,CAAC,4BAA4B,CAChD,MAAM,CAAC,OAAO,EACd,MAAM,CAAC,KAAK,EACZ,MAAM,CAAC,QAAQ,CAClB,CAAA;SACJ;QAED,OAAO,oCAAgB,CAAC,cAAc,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;IAC3D,CAAC;IAEO,kCAAkC,CACtC,QAA4B;QAE5B,IAAI,CAAC,IAAA,wBAAgB,EAAC,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,EAAE;YAC/C,OAAO,SAAS,CAAA;SACnB;QAED,OAAO,0CAAmB,CAAC,MAAM,CAC7B,0CAA8B,CAAC,IAAI,CAAC,OAAO,CAAC,EAC5C,QAAQ,IAAI,IAAI,CAAC,MAAM,CAAC,aAAa,CACxC,CAAA;IACL,CAAC;CACJ;AA5ID,sBA4IC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CustomPreset, QuoterCustomPresetRequestParams } from './types';
|
|
2
|
+
export declare class QuoterCustomPresetRequest {
|
|
3
|
+
readonly customPreset: CustomPreset;
|
|
4
|
+
constructor(params: QuoterCustomPresetRequestParams);
|
|
5
|
+
static new(params: QuoterCustomPresetRequestParams): QuoterCustomPresetRequest;
|
|
6
|
+
build(): CustomPreset;
|
|
7
|
+
validate(): string | null;
|
|
8
|
+
private validateAuctionDuration;
|
|
9
|
+
private validatePoints;
|
|
10
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.QuoterCustomPresetRequest = void 0;
|
|
4
|
+
const bignumber_1 = require("@ethersproject/bignumber");
|
|
5
|
+
const validations_1 = require("../../validations");
|
|
6
|
+
class QuoterCustomPresetRequest {
|
|
7
|
+
constructor(params) {
|
|
8
|
+
this.customPreset = params.customPreset;
|
|
9
|
+
}
|
|
10
|
+
static new(params) {
|
|
11
|
+
return new QuoterCustomPresetRequest(params);
|
|
12
|
+
}
|
|
13
|
+
build() {
|
|
14
|
+
return {
|
|
15
|
+
auctionDuration: this.customPreset.auctionDuration,
|
|
16
|
+
auctionEndAmount: this.customPreset.auctionEndAmount,
|
|
17
|
+
auctionStartAmount: this.customPreset.auctionStartAmount,
|
|
18
|
+
points: this.customPreset.points
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
validate() {
|
|
22
|
+
if (!(0, validations_1.isValidAmount)(this.customPreset.auctionStartAmount)) {
|
|
23
|
+
return 'Invalid auctionStartAmount';
|
|
24
|
+
}
|
|
25
|
+
if (!(0, validations_1.isValidAmount)(this.customPreset.auctionEndAmount)) {
|
|
26
|
+
return 'Invalid auctionEndAmount';
|
|
27
|
+
}
|
|
28
|
+
const durationErr = this.validateAuctionDuration(this.customPreset.auctionDuration);
|
|
29
|
+
if (durationErr) {
|
|
30
|
+
return durationErr;
|
|
31
|
+
}
|
|
32
|
+
const pointsErr = this.validatePoints(this.customPreset.points, this.customPreset.auctionStartAmount, this.customPreset.auctionEndAmount);
|
|
33
|
+
if (pointsErr) {
|
|
34
|
+
return pointsErr;
|
|
35
|
+
}
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
validateAuctionDuration(duration) {
|
|
39
|
+
if (typeof duration !== 'number' || isNaN(duration)) {
|
|
40
|
+
return 'auctionDuration should be integer';
|
|
41
|
+
}
|
|
42
|
+
if (!Number.isInteger(duration)) {
|
|
43
|
+
return 'auctionDuration should be integer (not float)';
|
|
44
|
+
}
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
validatePoints(points, auctionStartAmount, auctionEndAmount) {
|
|
48
|
+
if (!points) {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
try {
|
|
52
|
+
const toTokenAmounts = points.map((p) => bignumber_1.BigNumber.from(p.toTokenAmount));
|
|
53
|
+
const isValid = toTokenAmounts.every((amount) => amount.lte(bignumber_1.BigNumber.from(auctionStartAmount)) &&
|
|
54
|
+
amount.gte(bignumber_1.BigNumber.from(auctionEndAmount)));
|
|
55
|
+
if (!isValid) {
|
|
56
|
+
return 'points should be in range of auction';
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
catch (e) {
|
|
60
|
+
return `points should be an array of valid amounts`;
|
|
61
|
+
}
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
exports.QuoterCustomPresetRequest = QuoterCustomPresetRequest;
|
|
66
|
+
//# sourceMappingURL=quoter-custom-preset.request.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quoter-custom-preset.request.js","sourceRoot":"","sources":["../../../src/api/quoter/quoter-custom-preset.request.ts"],"names":[],"mappings":";;;AAAA,wDAAkD;AAClD,mDAA+C;AAO/C,MAAa,yBAAyB;IAGlC,YAAY,MAAuC;QAC/C,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC,YAAY,CAAA;IAC3C,CAAC;IAED,MAAM,CAAC,GAAG,CACN,MAAuC;QAEvC,OAAO,IAAI,yBAAyB,CAAC,MAAM,CAAC,CAAA;IAChD,CAAC;IAED,KAAK;QACD,OAAO;YACH,eAAe,EAAE,IAAI,CAAC,YAAY,CAAC,eAAe;YAClD,gBAAgB,EAAE,IAAI,CAAC,YAAY,CAAC,gBAAgB;YACpD,kBAAkB,EAAE,IAAI,CAAC,YAAY,CAAC,kBAAkB;YACxD,MAAM,EAAE,IAAI,CAAC,YAAY,CAAC,MAAM;SACnC,CAAA;IACL,CA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E,EAAE,CACP,MAAM,CAAC,GAAG,CAAC,qBAAS,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;gBAC9C,MAAM,CAAC,GAAG,CAAC,qBAAS,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,CACnD,CAAA;YAED,IAAI,CAAC,OAAO,EAAE;gBACV,OAAO,sCAAsC,CAAA;aAChD;SACJ;QAAC,OAAO,CAAC,EAAE;YACR,OAAO,4CAA4C,CAAA;SACtD;QAED,OAAO,IAAI,CAAA;IACf,CAAC;CACJ;AA7FD,8DA6FC"}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HttpProviderConnector } from '../../connector';
|
|
2
2
|
import { QuoterRequest } from './quoter.request';
|
|
3
3
|
import { QuoterApiConfig } from './types';
|
|
4
4
|
import { Quote } from './quote';
|
|
5
|
+
import { QuoterCustomPresetRequest } from './quoter-custom-preset.request';
|
|
5
6
|
export declare class QuoterApi {
|
|
6
7
|
private readonly config;
|
|
7
8
|
private readonly httpClient;
|
|
8
9
|
constructor(config: QuoterApiConfig, httpClient: HttpProviderConnector);
|
|
9
|
-
static new(config: QuoterApiConfig, httpClient?:
|
|
10
|
+
static new(config: QuoterApiConfig, httpClient?: HttpProviderConnector): QuoterApi;
|
|
10
11
|
getQuote(params: QuoterRequest): Promise<Quote>;
|
|
12
|
+
getQuoteWithCustomPreset(params: QuoterRequest, body: QuoterCustomPresetRequest): Promise<Quote>;
|
|
11
13
|
}
|
package/api/quoter/quoter.api.js
CHANGED
|
@@ -10,7 +10,7 @@ class QuoterApi {
|
|
|
10
10
|
this.config = config;
|
|
11
11
|
this.httpClient = httpClient;
|
|
12
12
|
}
|
|
13
|
-
static new(config, httpClient = new connector_1.AxiosProviderConnector()) {
|
|
13
|
+
static new(config, httpClient = new connector_1.AxiosProviderConnector(config.authKey)) {
|
|
14
14
|
return new QuoterApi(config, httpClient);
|
|
15
15
|
}
|
|
16
16
|
getQuote(params) {
|
|
@@ -25,6 +25,23 @@ class QuoterApi {
|
|
|
25
25
|
return new quote_1.Quote(this.config.network, params, res);
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
|
+
getQuoteWithCustomPreset(params, body) {
|
|
29
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
30
|
+
const paramsErr = params.validate();
|
|
31
|
+
const bodyErr = body.validate();
|
|
32
|
+
if (paramsErr) {
|
|
33
|
+
throw new Error(paramsErr);
|
|
34
|
+
}
|
|
35
|
+
if (bodyErr) {
|
|
36
|
+
throw new Error(bodyErr);
|
|
37
|
+
}
|
|
38
|
+
const queryParams = (0, params_1.concatQueryParams)(params.build());
|
|
39
|
+
const bodyParams = body.build();
|
|
40
|
+
const url = `${this.config.url}/v1.0/${this.config.network}/quote/receive/${queryParams}`;
|
|
41
|
+
const res = yield this.httpClient.post(url, bodyParams);
|
|
42
|
+
return new quote_1.Quote(this.config.network, params, res);
|
|
43
|
+
});
|
|
44
|
+
}
|
|
28
45
|
}
|
|
29
46
|
exports.QuoterApi = QuoterApi;
|
|
30
47
|
//# sourceMappingURL=quoter.api.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quoter.api.js","sourceRoot":"","sources":["../../../src/api/quoter/quoter.api.ts"],"names":[],"mappings":";;;;AAAA,+CAA6E;AAG7E,sCAA2C;AAC3C,mCAA6B;
|
|
1
|
+
{"version":3,"file":"quoter.api.js","sourceRoot":"","sources":["../../../src/api/quoter/quoter.api.ts"],"names":[],"mappings":";;;;AAAA,+CAA6E;AAG7E,sCAA2C;AAC3C,mCAA6B;AAG7B,MAAa,SAAS;IAClB,YACqB,MAAuB,EACvB,UAAiC;QADjC,WAAM,GAAN,MAAM,CAAiB;QACvB,eAAU,GAAV,UAAU,CAAuB;IACnD,CAAC;IAEJ,MAAM,CAAC,GAAG,CACN,MAAuB,EACvB,aAAoC,IAAI,kCAAsB,CAC1D,MAAM,CAAC,OAAO,CACjB;QAED,OAAO,IAAI,SAAS,C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AU,CAAC,IAAI,CAAiB,GAAG,EAAE,UAAU,CAAC,CAAA;YAEvE,OAAO,IAAI,aAAK,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,CAAA;QACtD,CAAC;KAAA;CACJ;AArDD,8BAqDC"}
|
package/api/quoter/types.d.ts
CHANGED
|
@@ -9,9 +9,13 @@ export declare type QuoterRequestParams = {
|
|
|
9
9
|
fee?: number;
|
|
10
10
|
source?: string;
|
|
11
11
|
};
|
|
12
|
+
export declare type QuoterCustomPresetRequestParams = {
|
|
13
|
+
customPreset: CustomPreset;
|
|
14
|
+
};
|
|
12
15
|
export declare type QuoterApiConfig = {
|
|
13
16
|
network: NetworkEnum;
|
|
14
17
|
url: string;
|
|
18
|
+
authKey?: string;
|
|
15
19
|
};
|
|
16
20
|
export declare type QuoterResponse = {
|
|
17
21
|
fromTokenAmount: string;
|
|
@@ -29,6 +33,7 @@ export declare type QuoterPresets = {
|
|
|
29
33
|
fast: PresetData;
|
|
30
34
|
medium: PresetData;
|
|
31
35
|
slow: PresetData;
|
|
36
|
+
custom?: PresetData;
|
|
32
37
|
};
|
|
33
38
|
export declare type PresetData = {
|
|
34
39
|
auctionDuration: number;
|
|
@@ -53,5 +58,16 @@ export declare type Cost = {
|
|
|
53
58
|
export declare enum PresetEnum {
|
|
54
59
|
fast = "fast",
|
|
55
60
|
medium = "medium",
|
|
56
|
-
slow = "slow"
|
|
61
|
+
slow = "slow",
|
|
62
|
+
custom = "custom"
|
|
57
63
|
}
|
|
64
|
+
export declare type CustomPreset = {
|
|
65
|
+
auctionDuration: number;
|
|
66
|
+
auctionStartAmount: string;
|
|
67
|
+
auctionEndAmount: string;
|
|
68
|
+
points?: CustomPresetPoint[];
|
|
69
|
+
};
|
|
70
|
+
export declare type CustomPresetPoint = {
|
|
71
|
+
toTokenAmount: string;
|
|
72
|
+
delay: number;
|
|
73
|
+
};
|
package/api/quoter/types.js
CHANGED
package/api/quoter/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/api/quoter/types.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/api/quoter/types.ts"],"names":[],"mappings":";;;AAkEA,IAAY,UAKX;AALD,WAAY,UAAU;IAClB,2BAAa,CAAA;IACb,+BAAiB,CAAA;IACjB,2BAAa,CAAA;IACb,+BAAiB,CAAA;AACrB,CAAC,EALW,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAKrB"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HttpProviderConnector } from '../../connector';
|
|
2
2
|
import { RelayerRequest } from './relayer.request';
|
|
3
3
|
import { RelayerApiConfig } from './types';
|
|
4
4
|
export declare class RelayerApi {
|
|
5
5
|
private readonly config;
|
|
6
6
|
private readonly httpClient;
|
|
7
7
|
constructor(config: RelayerApiConfig, httpClient: HttpProviderConnector);
|
|
8
|
-
static new(config: RelayerApiConfig, httpClient?:
|
|
8
|
+
static new(config: RelayerApiConfig, httpClient?: HttpProviderConnector): RelayerApi;
|
|
9
9
|
submit(params: RelayerRequest): Promise<void>;
|
|
10
10
|
submitBatch(params: RelayerRequest[]): Promise<void>;
|
|
11
11
|
}
|
|
@@ -7,7 +7,7 @@ class RelayerApi {
|
|
|
7
7
|
this.config = config;
|
|
8
8
|
this.httpClient = httpClient;
|
|
9
9
|
}
|
|
10
|
-
static new(config, httpClient = new connector_1.AxiosProviderConnector()) {
|
|
10
|
+
static new(config, httpClient = new connector_1.AxiosProviderConnector(config.authKey)) {
|
|
11
11
|
return new RelayerApi(config, httpClient);
|
|
12
12
|
}
|
|
13
13
|
submit(params) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"relayer.api.js","sourceRoot":"","sources":["../../../src/api/relayer/relayer.api.ts"],"names":[],"mappings":";;;AAAA,+CAA6E;AAI7E,MAAa,UAAU;IACnB,YACqB,MAAwB,EACxB,UAAiC;QADjC,WAAM,GAAN,MAAM,CAAkB;QACxB,eAAU,GAAV,UAAU,CAAuB;IACnD,CAAC;IAEJ,MAAM,CAAC,GAAG,CACN,MAAwB,EACxB,
|
|
1
|
+
{"version":3,"file":"relayer.api.js","sourceRoot":"","sources":["../../../src/api/relayer/relayer.api.ts"],"names":[],"mappings":";;;AAAA,+CAA6E;AAI7E,MAAa,UAAU;IACnB,YACqB,MAAwB,EACxB,UAAiC;QADjC,WAAM,GAAN,MAAM,CAAkB;QACxB,eAAU,GAAV,UAAU,CAAuB;IACnD,CAAC;IAEJ,MAAM,CAAC,GAAG,CACN,MAAwB,EACxB,aAAoC,IAAI,kCAAsB,CAC1D,MAAM,CAAC,OAAO,CACjB;QAED,OAAO,IAAI,UAAU,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;IAC7C,CAAC;IAED,MAAM,CAAC,MAAsB;QACzB,MAAM,GAAG,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,SAAS,IAAI,CAAC,MAAM,CAAC,OAAO,eAAe,CAAA;QAEzE,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;IAC5C,CAAC;IAED,WAAW,CAAC,MAAwB;QAChC,MAAM,GAAG,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,SAAS,IAAI,CAAC,MAAM,CAAC,OAAO,oBAAoB,CAAA;QAE9E,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;IAC5C,CAAC;CACJ;AA1BD,gCA0BC"}
|
package/api/relayer/types.d.ts
CHANGED
package/api/types.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { HttpProviderConnector } from './http-provider.connector';
|
|
2
2
|
export declare class AxiosProviderConnector implements HttpProviderConnector {
|
|
3
|
+
private readonly authKey?;
|
|
4
|
+
constructor(authKey?: string | undefined);
|
|
3
5
|
get<T>(url: string): Promise<T>;
|
|
4
6
|
post<T>(url: string, data: unknown): Promise<T>;
|
|
5
7
|
}
|
|
@@ -2,18 +2,52 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AxiosProviderConnector = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const
|
|
5
|
+
const errors_1 = require("../../errors");
|
|
6
|
+
const axios_1 = tslib_1.__importStar(require("axios"));
|
|
6
7
|
class AxiosProviderConnector {
|
|
8
|
+
constructor(authKey) {
|
|
9
|
+
this.authKey = authKey;
|
|
10
|
+
}
|
|
7
11
|
get(url) {
|
|
12
|
+
var _a;
|
|
8
13
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
9
|
-
|
|
10
|
-
|
|
14
|
+
try {
|
|
15
|
+
const res = yield axios_1.default.get(url, this.authKey
|
|
16
|
+
? {
|
|
17
|
+
headers: {
|
|
18
|
+
Authorization: `Bearer ${this.authKey}`
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
: undefined);
|
|
22
|
+
return res.data;
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
if ((0, axios_1.isAxiosError)(error) && ((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === 401) {
|
|
26
|
+
throw new errors_1.AuthError();
|
|
27
|
+
}
|
|
28
|
+
throw error;
|
|
29
|
+
}
|
|
11
30
|
});
|
|
12
31
|
}
|
|
13
32
|
post(url, data) {
|
|
33
|
+
var _a;
|
|
14
34
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
15
|
-
|
|
16
|
-
|
|
35
|
+
try {
|
|
36
|
+
const res = yield axios_1.default.post(url, data, this.authKey
|
|
37
|
+
? {
|
|
38
|
+
headers: {
|
|
39
|
+
Authorization: `Bearer ${this.authKey}`
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
: undefined);
|
|
43
|
+
return res.data;
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
if ((0, axios_1.isAxiosError)(error) && ((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === 401) {
|
|
47
|
+
throw new errors_1.AuthError();
|
|
48
|
+
}
|
|
49
|
+
throw error;
|
|
50
|
+
}
|
|
17
51
|
});
|
|
18
52
|
}
|
|
19
53
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"axios-provider.connector.js","sourceRoot":"","sources":["../../../src/connector/http/axios-provider.connector.ts"],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"axios-provider.connector.js","sourceRoot":"","sources":["../../../src/connector/http/axios-provider.connector.ts"],"names":[],"mappings":";;;;AAAA,yCAAsC;AAEtC,uDAAyC;AAEzC,MAAa,sBAAsB;IAC/B,YAA6B,OAAgB;QAAhB,YAAO,GAAP,OAAO,CAAS;IAAG,CAAC;IAE3C,GAAG,CAAI,GAAW;;;YACpB,IAAI;gBACA,MAAM,GAAG,GAAG,MAAM,eAAK,CAAC,GAAG,CACvB,GAAG,EACH,IAAI,CAAC,OAAO;oBACR,CAAC,CAAC;wBACI,OAAO,EAAE;4BACL,aAAa,EAAE,UAAU,IAAI,CAAC,OAAO,EAAE;yBAC1C;qBACJ;oBACH,CAAC,CAAC,SAAS,CAClB,CAAA;gBAED,OAAO,GAAG,CAAC,IAAI,CAAA;aAClB;YAAC,OAAO,KAAK,EAAE;gBACZ,IAAI,IAAA,oBAAY,EAAC,KAAK,CAAC,IAAI,CAAA,MAAA,KAAK,CAAC,QAAQ,0CAAE,MAAM,MAAK,GAAG,EAAE;oBACvD,MAAM,IAAI,kBAAS,EAAE,CAAA;iBACxB;gBAED,MAAM,KAAK,CAAA;aACd;;KACJ;IAEK,IAAI,CAAI,GAAW,EAAE,IAAa;;;YACpC,IAAI;gBACA,MAAM,GAAG,GAAG,MAAM,eAAK,CAAC,IAAI,CACxB,GAAG,EACH,IAAI,EACJ,IAAI,CAAC,OAAO;oBACR,CAAC,CAAC;wBACI,OAAO,EAAE;4BACL,aAAa,EAAE,UAAU,IAAI,CAAC,OAAO,EAAE;yBAC1C;qBACJ;oBACH,CAAC,CAAC,SAAS,CAClB,CAAA;gBAED,OAAO,GAAG,CAAC,IAAI,CAAA;aAClB;YAAC,OAAO,KAAK,EAAE;gBACZ,IAAI,IAAA,oBAAY,EAAC,KAAK,CAAC,IAAI,CAAA,MAAA,KAAK,CAAC,QAAQ,0CAAE,MAAM,MAAK,GAAG,EAAE;oBACvD,MAAM,IAAI,kBAAS,EAAE,CAAA;iBACxB;gBAED,MAAM,KAAK,CAAA;aACd;;KACJ;CACJ;AAjDD,wDAiDC"}
|
package/connector/ws/types.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export declare class WebsocketClient implements WsProviderConnector {
|
|
|
5
5
|
readonly ws: WebSocket;
|
|
6
6
|
private readonly url;
|
|
7
7
|
private readonly initialized;
|
|
8
|
+
private readonly authKey?;
|
|
8
9
|
constructor(config: WsApiConfig);
|
|
9
10
|
init(): void;
|
|
10
11
|
on(event: string, cb: AnyFunctionWithThis): void;
|
|
@@ -6,10 +6,17 @@ const ws_1 = tslib_1.__importDefault(require("ws"));
|
|
|
6
6
|
class WebsocketClient {
|
|
7
7
|
constructor(config) {
|
|
8
8
|
this.url = config.url;
|
|
9
|
+
this.authKey = config.authKey;
|
|
9
10
|
const lazyInit = config.lazyInit || false;
|
|
10
11
|
if (!lazyInit) {
|
|
11
12
|
this.initialized = true;
|
|
12
|
-
this.ws = new ws_1.default(this.url
|
|
13
|
+
this.ws = new ws_1.default(this.url, this.authKey
|
|
14
|
+
? {
|
|
15
|
+
headers: {
|
|
16
|
+
Authorization: `Bearer ${this.authKey}`
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
: undefined);
|
|
13
20
|
return;
|
|
14
21
|
}
|
|
15
22
|
this.initialized = false;
|
|
@@ -21,7 +28,13 @@ class WebsocketClient {
|
|
|
21
28
|
// @ts-expect-error hack for readonly property
|
|
22
29
|
this.initialized = true;
|
|
23
30
|
// @ts-expect-error hack for readonly property
|
|
24
|
-
this.ws = new ws_1.default(this.url
|
|
31
|
+
this.ws = new ws_1.default(this.url, this.authKey
|
|
32
|
+
? {
|
|
33
|
+
headers: {
|
|
34
|
+
Authorization: `Bearer ${this.authKey}`
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
: undefined);
|
|
25
38
|
}
|
|
26
39
|
on(event, cb) {
|
|
27
40
|
this.checkInitialized();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"websocket-client.connector.js","sourceRoot":"","sources":["../../../src/connector/ws/websocket-client.connector.ts"],"names":[],"mappings":";;;;AAAA,oDAA0B;AAS1B,MAAa,eAAe;
|
|
1
|
+
{"version":3,"file":"websocket-client.connector.js","sourceRoot":"","sources":["../../../src/connector/ws/websocket-client.connector.ts"],"names":[],"mappings":";;;;AAAA,oDAA0B;AAS1B,MAAa,eAAe;IASxB,YAAY,MAAmB;QAC3B,IAAI,CAAC,GAAG,GAAG,MAAM,CAAC,GAAG,CAAA;QACrB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAA;QAE7B,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,IAAI,KAAK,CAAA;QAEzC,IAAI,CAAC,QAAQ,EAAE;YACX,IAAI,CAAC,WAAW,GAAG,IAAI,CAAA;YACvB,IAAI,CAAC,EAAE,GAAG,IAAI,YAAS,CACnB,IAAI,CAAC,GAAG,EACR,IAAI,CAAC,OAAO;gBACR,CAAC,CAAC;oBACI,OAAO,EAAE;wBACL,aAAa,EAAE,UAAU,IAAI,CAAC,OAAO,EAAE;qBAC1C;iBACJ;gBACH,CAAC,CAAC,SAAS,CAClB,CAAA;YAED,OAAM;SACT;QAED,IAAI,CAAC,WAAW,GAAG,KAAK,CAAA;IAC5B,CAAC;IAED,IAAI;QACA,IAAI,IAAI,CAAC,WAAW,EAAE;YAClB,MAAM,IAAI,KAAK,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AC,OAAO,EAAE,EAAE,CAAC,CAAA;IACxB,CAAC;IAED,OAAO,CAAC,EAAe;QACnB,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,CAAA;IACxB,CAAC;IAED,KAAK;QACD,IAAI,CAAC,gBAAgB,EAAE,CAAA;QACvB,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE,CAAA;IACnB,CAAC;IAEO,gBAAgB;QACpB,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;YACnB,cAAc,EAAE,CAAA;SACnB;IACL,CAAC;CACJ;AApGD,0CAoGC;AAED,SAAS,cAAc;IACnB,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAA;AACvE,CAAC"}
|
package/errors.d.ts
ADDED
package/errors.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AuthError = void 0;
|
|
4
|
+
class AuthError extends Error {
|
|
5
|
+
constructor() {
|
|
6
|
+
super('Auth error, please use token from https://portal.1inch.dev/');
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
exports.AuthError = AuthError;
|
|
10
|
+
//# sourceMappingURL=errors.js.map
|
package/errors.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";;;AAAA,MAAa,SAAU,SAAQ,KAAK;IAChC;QACI,KAAK,CAAC,6DAA6D,CAAC,CAAA;IACxE,CAAC;CACJ;AAJD,8BAIC"}
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -13,4 +13,5 @@ tslib_1.__exportStar(require("./utils"), exports);
|
|
|
13
13
|
tslib_1.__exportStar(require("./validations"), exports);
|
|
14
14
|
tslib_1.__exportStar(require("./settlement"), exports);
|
|
15
15
|
tslib_1.__exportStar(require("./ws-api"), exports);
|
|
16
|
+
tslib_1.__exportStar(require("./errors"), exports);
|
|
16
17
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,iEAAsC;AACtC,+DAAoC;AACpC,+DAAoC;AACpC,8DAAmC;AACnC,qEAA0C;AAC1C,4DAAiC;AACjC,sDAA2B;AAC3B,sDAA2B;AAC3B,kDAAuB;AACvB,wDAA6B;AAC7B,uDAA4B;AAC5B,mDAAwB"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,iEAAsC;AACtC,+DAAoC;AACpC,+DAAoC;AACpC,8DAAmC;AACnC,qEAA0C;AAC1C,4DAAiC;AACjC,sDAA2B;AAC3B,sDAA2B;AAC3B,kDAAuB;AACvB,wDAA6B;AAC7B,uDAA4B;AAC5B,mDAAwB;AACxB,mDAAwB"}
|