@chainflip/rpc 1.6.2 → 1.6.4
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/Client.cjs +6 -7
- package/dist/Client.d.cts +1 -1
- package/dist/Client.d.ts +1 -1
- package/dist/{Client.mjs → Client.js} +3 -4
- package/dist/HttpClient.cjs +3 -4
- package/dist/HttpClient.d.cts +1 -1
- package/dist/HttpClient.d.ts +1 -1
- package/dist/{HttpClient.mjs → HttpClient.js} +3 -4
- package/dist/WsClient.cjs +9 -10
- package/dist/WsClient.d.cts +1 -1
- package/dist/WsClient.d.ts +1 -1
- package/dist/{WsClient.mjs → WsClient.js} +6 -7
- package/dist/common.cjs +17 -30
- package/dist/common.d.cts +570 -5755
- package/dist/common.d.ts +570 -5755
- package/dist/{common.mjs → common.js} +3 -16
- package/dist/constants.cjs +1 -2
- package/dist/{constants.mjs → constants.js} +1 -2
- package/dist/index.cjs +5 -6
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +9 -0
- package/dist/parsers.cjs +36 -197
- package/dist/parsers.d.cts +267 -6032
- package/dist/parsers.d.ts +267 -6032
- package/dist/parsers.js +113 -0
- package/dist/types.d.cts +3 -20
- package/dist/types.d.ts +3 -20
- package/package.json +1 -1
- package/dist/index.mjs +0 -10
- package/dist/parsers.mjs +0 -274
- /package/dist/{types.mjs → types.js} +0 -0
package/dist/Client.cjs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true})
|
|
2
|
-
var _commoncjs = require('./common.cjs');
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _common = require('./common');
|
|
3
2
|
var _assertion = require('@chainflip/utils/assertion');
|
|
4
|
-
|
|
3
|
+
class Client {
|
|
5
4
|
constructor(url) {
|
|
6
5
|
this.url = url;
|
|
7
6
|
}
|
|
@@ -15,19 +14,19 @@ var Client = class {
|
|
|
15
14
|
const response = await this.send(this.formatRequest(method, params));
|
|
16
15
|
if (!response.success)
|
|
17
16
|
throw response.error;
|
|
18
|
-
const parseResult =
|
|
17
|
+
const parseResult = _common.rpcResponse.safeParse(response.result);
|
|
19
18
|
_assertion.assert.call(void 0, parseResult.success, "Malformed RPC response received");
|
|
20
19
|
if ("error" in parseResult.data) {
|
|
21
20
|
throw new Error(
|
|
22
21
|
`RPC error [${parseResult.data.error.code}]: ${parseResult.data.error.message}`
|
|
23
22
|
);
|
|
24
23
|
}
|
|
25
|
-
return
|
|
24
|
+
return _common.rpcResult[method].parse(parseResult.data.result);
|
|
26
25
|
}
|
|
27
26
|
methods() {
|
|
28
|
-
return Object.keys(
|
|
27
|
+
return Object.keys(_common.rpcResult).sort();
|
|
29
28
|
}
|
|
30
|
-
}
|
|
29
|
+
}
|
|
31
30
|
|
|
32
31
|
|
|
33
32
|
exports.default = Client;
|
package/dist/Client.d.cts
CHANGED
package/dist/Client.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
import { rpcResult, rpcResponse } from "./common.mjs";
|
|
1
|
+
import { rpcResult, rpcResponse } from "./common";
|
|
3
2
|
import { assert } from "@chainflip/utils/assertion";
|
|
4
|
-
|
|
3
|
+
class Client {
|
|
5
4
|
constructor(url) {
|
|
6
5
|
this.url = url;
|
|
7
6
|
}
|
|
@@ -27,7 +26,7 @@ var Client = class {
|
|
|
27
26
|
methods() {
|
|
28
27
|
return Object.keys(rpcResult).sort();
|
|
29
28
|
}
|
|
30
|
-
}
|
|
29
|
+
}
|
|
31
30
|
export {
|
|
32
31
|
Client as default
|
|
33
32
|
};
|
package/dist/HttpClient.cjs
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
2
|
-
|
|
3
|
-
var HttpClient = class extends _Clientcjs2.default {
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _Client = require('./Client'); var _Client2 = _interopRequireDefault(_Client);
|
|
2
|
+
class HttpClient extends _Client2.default {
|
|
4
3
|
async send(request) {
|
|
5
4
|
const res = await fetch(this.url, {
|
|
6
5
|
body: JSON.stringify(request),
|
|
@@ -19,7 +18,7 @@ var HttpClient = class extends _Clientcjs2.default {
|
|
|
19
18
|
return { success: false, error: new Error("Invalid JSON response") };
|
|
20
19
|
}
|
|
21
20
|
}
|
|
22
|
-
}
|
|
21
|
+
}
|
|
23
22
|
|
|
24
23
|
|
|
25
24
|
exports.default = HttpClient;
|
package/dist/HttpClient.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import Client from './Client.cjs';
|
|
2
2
|
import { RpcMethod, JsonRpcRequest } from './common.cjs';
|
|
3
|
-
import '@chainflip/utils/types';
|
|
4
3
|
import 'zod';
|
|
5
4
|
import './parsers.cjs';
|
|
5
|
+
import '@chainflip/utils/types';
|
|
6
6
|
|
|
7
7
|
declare class HttpClient extends Client {
|
|
8
8
|
protected send<const T extends RpcMethod>(request: JsonRpcRequest<T>): Promise<{
|
package/dist/HttpClient.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import Client from './Client.js';
|
|
2
2
|
import { RpcMethod, JsonRpcRequest } from './common.js';
|
|
3
|
-
import '@chainflip/utils/types';
|
|
4
3
|
import 'zod';
|
|
5
4
|
import './parsers.js';
|
|
5
|
+
import '@chainflip/utils/types';
|
|
6
6
|
|
|
7
7
|
declare class HttpClient extends Client {
|
|
8
8
|
protected send<const T extends RpcMethod>(request: JsonRpcRequest<T>): Promise<{
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var HttpClient = class extends Client {
|
|
1
|
+
import Client from "./Client";
|
|
2
|
+
class HttpClient extends Client {
|
|
4
3
|
async send(request) {
|
|
5
4
|
const res = await fetch(this.url, {
|
|
6
5
|
body: JSON.stringify(request),
|
|
@@ -19,7 +18,7 @@ var HttpClient = class extends Client {
|
|
|
19
18
|
return { success: false, error: new Error("Invalid JSON response") };
|
|
20
19
|
}
|
|
21
20
|
}
|
|
22
|
-
}
|
|
21
|
+
}
|
|
23
22
|
export {
|
|
24
23
|
HttpClient as default
|
|
25
24
|
};
|
package/dist/WsClient.cjs
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
|
-
var _async = require('@chainflip/utils/async');
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _async = require('@chainflip/utils/async');
|
|
3
2
|
var _crypto = require('crypto');
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
var _Client = require('./Client'); var _Client2 = _interopRequireDefault(_Client);
|
|
4
|
+
var _common = require('./common');
|
|
5
|
+
const READY = "READY";
|
|
6
|
+
const DISCONNECT = "DISCONNECT";
|
|
7
|
+
class WsClient extends _Client2.default {
|
|
9
8
|
constructor(url, WebSocket = globalThis.WebSocket) {
|
|
10
|
-
super(url);
|
|
9
|
+
super(url);WsClient.prototype.__init.call(this);WsClient.prototype.__init2.call(this);WsClient.prototype.__init3.call(this);WsClient.prototype.__init4.call(this);WsClient.prototype.__init5.call(this);;
|
|
11
10
|
this.WebSocket = WebSocket;
|
|
12
11
|
}
|
|
13
12
|
|
|
@@ -52,7 +51,7 @@ var WsClient = (_class = class extends _Clientcjs2.default {
|
|
|
52
51
|
}}
|
|
53
52
|
__init5() {this.handleMessage = (data) => {
|
|
54
53
|
const parsedData = JSON.parse(data.data);
|
|
55
|
-
const response =
|
|
54
|
+
const response = _common.rpcResponse.safeParse(parsedData);
|
|
56
55
|
if (!response.success)
|
|
57
56
|
return;
|
|
58
57
|
const { id } = response.data;
|
|
@@ -102,7 +101,7 @@ var WsClient = (_class = class extends _Clientcjs2.default {
|
|
|
102
101
|
}
|
|
103
102
|
return { success: false, error: new Error("max retries exceeded") };
|
|
104
103
|
}
|
|
105
|
-
}
|
|
104
|
+
}
|
|
106
105
|
|
|
107
106
|
|
|
108
107
|
exports.default = WsClient;
|
package/dist/WsClient.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import Client from './Client.cjs';
|
|
2
2
|
import { RpcMethod, JsonRpcRequest } from './common.cjs';
|
|
3
|
-
import '@chainflip/utils/types';
|
|
4
3
|
import 'zod';
|
|
5
4
|
import './parsers.cjs';
|
|
5
|
+
import '@chainflip/utils/types';
|
|
6
6
|
|
|
7
7
|
declare class WsClient extends Client {
|
|
8
8
|
private readonly WebSocket;
|
package/dist/WsClient.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import Client from './Client.js';
|
|
2
2
|
import { RpcMethod, JsonRpcRequest } from './common.js';
|
|
3
|
-
import '@chainflip/utils/types';
|
|
4
3
|
import 'zod';
|
|
5
4
|
import './parsers.js';
|
|
5
|
+
import '@chainflip/utils/types';
|
|
6
6
|
|
|
7
7
|
declare class WsClient extends Client {
|
|
8
8
|
private readonly WebSocket;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
// src/WsClient.ts
|
|
2
1
|
import { deferredPromise, once, sleep } from "@chainflip/utils/async";
|
|
3
2
|
import { randomUUID } from "crypto";
|
|
4
|
-
import Client from "./Client
|
|
5
|
-
import { rpcResponse } from "./common
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
import Client from "./Client";
|
|
4
|
+
import { rpcResponse } from "./common";
|
|
5
|
+
const READY = "READY";
|
|
6
|
+
const DISCONNECT = "DISCONNECT";
|
|
7
|
+
class WsClient extends Client {
|
|
9
8
|
constructor(url, WebSocket = globalThis.WebSocket) {
|
|
10
9
|
super(url);
|
|
11
10
|
this.WebSocket = WebSocket;
|
|
@@ -102,7 +101,7 @@ var WsClient = class extends Client {
|
|
|
102
101
|
}
|
|
103
102
|
return { success: false, error: new Error("max retries exceeded") };
|
|
104
103
|
}
|
|
105
|
-
}
|
|
104
|
+
}
|
|
106
105
|
export {
|
|
107
106
|
WsClient as default
|
|
108
107
|
};
|
package/dist/common.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true})
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
@@ -11,36 +11,23 @@
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
cf_funding_environment: _parserscjs.cfFundingEnvironment,
|
|
29
|
-
cf_ingress_egress_environment: _parserscjs.cfIngressEgressEnvironment,
|
|
30
|
-
cf_pool_orders: _parserscjs.cfPoolOrders,
|
|
31
|
-
cf_pool_price_v2: _parserscjs.cfPoolPriceV2,
|
|
32
|
-
cf_pools_environment: _parserscjs.cfPoolsEnvironment,
|
|
33
|
-
cf_supported_assets: _parserscjs.cfSupportedAsssets,
|
|
34
|
-
cf_swap_rate: _parserscjs.cfSwapRate,
|
|
35
|
-
cf_swap_rate_v2: _parserscjs.cfSwapRateV2,
|
|
36
|
-
cf_swapping_environment: _parserscjs.cfSwappingEnvironment,
|
|
37
|
-
chain_getBlockHash: _parserscjs.chainGetBlockHash,
|
|
38
|
-
cf_boost_pool_details: _parserscjs.cfBoostPoolDetails,
|
|
39
|
-
cf_boost_pool_pending_fees: _parserscjs.cfBoostPoolPendingFees,
|
|
40
|
-
state_getMetadata: _parserscjs.stateGetMetadata,
|
|
41
|
-
state_getRuntimeVersion: _parserscjs.stateGetRuntimeVersion
|
|
14
|
+
var _parsers = require('./parsers');
|
|
15
|
+
const rpcResult = {
|
|
16
|
+
broker_requestSwapDepositAddress: _parsers.brokerRequestSwapDepositAddress,
|
|
17
|
+
cf_boost_pools_depth: _parsers.cfBoostPoolsDepth,
|
|
18
|
+
cf_environment: _parsers.cfEnvironment,
|
|
19
|
+
cf_funding_environment: _parsers.cfFundingEnvironment,
|
|
20
|
+
cf_ingress_egress_environment: _parsers.cfIngressEgressEnvironment,
|
|
21
|
+
cf_supported_assets: _parsers.cfSupportedAsssets,
|
|
22
|
+
cf_swap_rate: _parsers.cfSwapRate,
|
|
23
|
+
cf_swap_rate_v2: _parsers.cfSwapRateV2,
|
|
24
|
+
cf_swapping_environment: _parsers.cfSwappingEnvironment,
|
|
25
|
+
chain_getBlockHash: _parsers.chainGetBlockHash,
|
|
26
|
+
state_getMetadata: _parsers.stateGetMetadata,
|
|
27
|
+
state_getRuntimeVersion: _parsers.stateGetRuntimeVersion
|
|
42
28
|
};
|
|
43
29
|
|
|
44
30
|
|
|
45
31
|
|
|
46
|
-
|
|
32
|
+
|
|
33
|
+
exports.rpcResponse = _parsers.rpcResponse; exports.rpcResult = rpcResult;
|