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