@chainflip/rpc 1.4.0

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/common.js ADDED
@@ -0,0 +1,33 @@
1
+ import {
2
+ brokerRequestSwapDepositAddress,
3
+ cfBoostPoolsDepth,
4
+ cfEnvironment,
5
+ cfFundingEnvironment,
6
+ cfIngressEgressEnvironment,
7
+ cfSupportedAsssets,
8
+ cfSwapRate,
9
+ cfSwapRateV2,
10
+ cfSwappingEnvironment,
11
+ chainGetBlockHash,
12
+ stateGetMetadata,
13
+ stateGetRuntimeVersion
14
+ } from "./parsers";
15
+ const rpcResult = {
16
+ broker_requestSwapDepositAddress: brokerRequestSwapDepositAddress,
17
+ cf_boost_pools_depth: cfBoostPoolsDepth,
18
+ cf_environment: cfEnvironment,
19
+ cf_funding_environment: cfFundingEnvironment,
20
+ cf_ingress_egress_environment: cfIngressEgressEnvironment,
21
+ cf_supported_assets: cfSupportedAsssets,
22
+ cf_swap_rate: cfSwapRate,
23
+ cf_swap_rate_v2: cfSwapRateV2,
24
+ cf_swapping_environment: cfSwappingEnvironment,
25
+ chain_getBlockHash: chainGetBlockHash,
26
+ state_getMetadata: stateGetMetadata,
27
+ state_getRuntimeVersion: stateGetRuntimeVersion
28
+ };
29
+ import { rpcResponse as rpcResponse2 } from "./parsers";
30
+ export {
31
+ rpcResponse2 as rpcResponse,
32
+ rpcResult
33
+ };
@@ -0,0 +1,13 @@
1
+ declare const PUBLIC_RPC_ENDPOINTS: {
2
+ mainnet: string;
3
+ perseverance: string;
4
+ sisyphos: string;
5
+ backspin: string;
6
+ };
7
+
8
+ declare const constants_PUBLIC_RPC_ENDPOINTS: typeof PUBLIC_RPC_ENDPOINTS;
9
+ declare namespace constants {
10
+ export { constants_PUBLIC_RPC_ENDPOINTS as PUBLIC_RPC_ENDPOINTS };
11
+ }
12
+
13
+ export { PUBLIC_RPC_ENDPOINTS as P, constants as c };
@@ -0,0 +1,13 @@
1
+ declare const PUBLIC_RPC_ENDPOINTS: {
2
+ mainnet: string;
3
+ perseverance: string;
4
+ sisyphos: string;
5
+ backspin: string;
6
+ };
7
+
8
+ declare const constants_PUBLIC_RPC_ENDPOINTS: typeof PUBLIC_RPC_ENDPOINTS;
9
+ declare namespace constants {
10
+ export { constants_PUBLIC_RPC_ENDPOINTS as PUBLIC_RPC_ENDPOINTS };
11
+ }
12
+
13
+ export { PUBLIC_RPC_ENDPOINTS as P, constants as c };
@@ -0,0 +1,9 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});const PUBLIC_RPC_ENDPOINTS = {
2
+ mainnet: "https://mainnet-archive.chainflip.io",
3
+ perseverance: "https://archive.perseverance.chainflip.io",
4
+ sisyphos: "https://archive.sisyphos.chainflip.io",
5
+ backspin: "https://backspin-rpc.staging"
6
+ };
7
+
8
+
9
+ exports.PUBLIC_RPC_ENDPOINTS = PUBLIC_RPC_ENDPOINTS;
@@ -0,0 +1 @@
1
+ export { P as PUBLIC_RPC_ENDPOINTS } from './constants-jLrn-AnI.cjs';
@@ -0,0 +1 @@
1
+ export { P as PUBLIC_RPC_ENDPOINTS } from './constants-jLrn-AnI.js';
@@ -0,0 +1,9 @@
1
+ const PUBLIC_RPC_ENDPOINTS = {
2
+ mainnet: "https://mainnet-archive.chainflip.io",
3
+ perseverance: "https://archive.perseverance.chainflip.io",
4
+ sisyphos: "https://archive.sisyphos.chainflip.io",
5
+ backspin: "https://backspin-rpc.staging"
6
+ };
7
+ export {
8
+ PUBLIC_RPC_ENDPOINTS
9
+ };
package/dist/index.cjs ADDED
@@ -0,0 +1,9 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _createStarExport(obj) { Object.keys(obj) .filter((key) => key !== "default" && key !== "__esModule") .forEach((key) => { if (exports.hasOwnProperty(key)) { return; } Object.defineProperty(exports, key, {enumerable: true, configurable: true, get: () => obj[key]}); }); }var _HttpClient = require('./HttpClient'); var _HttpClient2 = _interopRequireDefault(_HttpClient);
2
+ var _WsClient = require('./WsClient'); var _WsClient2 = _interopRequireDefault(_WsClient);
3
+ var _types = require('./types'); _createStarExport(_types);
4
+ var _constants = require('./constants'); var constants = _interopRequireWildcard(_constants);
5
+
6
+
7
+
8
+
9
+ exports.HttpClient = _HttpClient2.default; exports.WsClient = _WsClient2.default; exports.constants = constants;
@@ -0,0 +1,9 @@
1
+ export { default as HttpClient } from './HttpClient.cjs';
2
+ export { default as WsClient } from './WsClient.cjs';
3
+ export { CfBoostPoolsDepth, CfBoostPoolsDepthResponse, CfEnvironment, CfEnvironmentResponse, CfFundingEnvironment, CfFundingEnvironmentResponse, CfIngressEgressEnvironment, CfIngressEgressEnvironmentResponse, CfSupportedAssets, CfSupportedAssetsResponse, CfSwapRate, CfSwapRateResponse, CfSwapRateV2, CfSwapRateV2Response, CfSwappingEnvironment, CfSwappingEnvironmentResponse } from './types.cjs';
4
+ export { c as constants } from './constants-jLrn-AnI.cjs';
5
+ export { RpcMethod, RpcRequest as RpcParams, RpcResult } from './common.cjs';
6
+ import './Client.cjs';
7
+ import 'zod';
8
+ import './parsers.cjs';
9
+ import '@chainflip/utils/types';
@@ -0,0 +1,9 @@
1
+ export { default as HttpClient } from './HttpClient.js';
2
+ export { default as WsClient } from './WsClient.js';
3
+ export { CfBoostPoolsDepth, CfBoostPoolsDepthResponse, CfEnvironment, CfEnvironmentResponse, CfFundingEnvironment, CfFundingEnvironmentResponse, CfIngressEgressEnvironment, CfIngressEgressEnvironmentResponse, CfSupportedAssets, CfSupportedAssetsResponse, CfSwapRate, CfSwapRateResponse, CfSwapRateV2, CfSwapRateV2Response, CfSwappingEnvironment, CfSwappingEnvironmentResponse } from './types.js';
4
+ export { c as constants } from './constants-jLrn-AnI.js';
5
+ export { RpcMethod, RpcRequest as RpcParams, RpcResult } from './common.js';
6
+ import './Client.js';
7
+ import 'zod';
8
+ import './parsers.js';
9
+ import '@chainflip/utils/types';
package/dist/index.js ADDED
@@ -0,0 +1,9 @@
1
+ import { default as default2 } from "./HttpClient";
2
+ import { default as default3 } from "./WsClient";
3
+ export * from "./types";
4
+ import * as constants from "./constants";
5
+ export {
6
+ default2 as HttpClient,
7
+ default3 as WsClient,
8
+ constants
9
+ };
@@ -0,0 +1,113 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _guard = require('@chainflip/utils/guard');
2
+ var _string = require('@chainflip/utils/string');
3
+ var _zod = require('zod');
4
+ const hexString = _zod.z.string().refine(_string.isHex, { message: "Invalid hex string" });
5
+ const u256 = hexString.transform((value) => BigInt(value));
6
+ const numberOrHex = _zod.z.union([_zod.z.number().transform((n) => BigInt(n)), u256]);
7
+ const chainAssetMapFactory = (parser) => _zod.z.object({
8
+ Bitcoin: _zod.z.object({ BTC: parser }),
9
+ Ethereum: _zod.z.object({ ETH: parser, USDC: parser, FLIP: parser, USDT: parser }),
10
+ Polkadot: _zod.z.object({ DOT: parser }),
11
+ Arbitrum: _zod.z.object({ ETH: parser, USDC: parser })
12
+ });
13
+ const chainMapFactory = (parser) => _zod.z.object({ Bitcoin: parser, Ethereum: parser, Polkadot: parser, Arbitrum: parser });
14
+ const rpcAssetSchema = _zod.z.union([
15
+ _zod.z.object({ chain: _zod.z.literal("Bitcoin"), asset: _zod.z.literal("BTC") }),
16
+ _zod.z.object({ chain: _zod.z.literal("Polkadot"), asset: _zod.z.literal("DOT") }),
17
+ _zod.z.object({ chain: _zod.z.literal("Ethereum"), asset: _zod.z.literal("FLIP") }),
18
+ _zod.z.object({ chain: _zod.z.literal("Ethereum"), asset: _zod.z.literal("ETH") }),
19
+ _zod.z.object({ chain: _zod.z.literal("Ethereum"), asset: _zod.z.literal("USDC") }),
20
+ _zod.z.object({ chain: _zod.z.literal("Ethereum"), asset: _zod.z.literal("USDT") }),
21
+ _zod.z.object({ chain: _zod.z.literal("Arbitrum"), asset: _zod.z.literal("ETH") }),
22
+ _zod.z.object({ chain: _zod.z.literal("Arbitrum"), asset: _zod.z.literal("USDC") })
23
+ ]);
24
+ const rename = (mapping) => (obj) => Object.fromEntries(
25
+ Object.entries(obj).map(([key, value]) => [
26
+ key in mapping ? mapping[key] : key,
27
+ value
28
+ ])
29
+ );
30
+ const rpcBaseResponse = _zod.z.object({
31
+ id: _zod.z.union([_zod.z.string(), _zod.z.number()]),
32
+ jsonrpc: _zod.z.literal("2.0")
33
+ });
34
+ const nonNullish = _zod.z.any().refine(_guard.isNotNullish, { message: "Value must not be null or undefined" });
35
+ const rpcSuccessResponse = rpcBaseResponse.extend({ result: nonNullish });
36
+ const rpcErrorResponse = rpcBaseResponse.extend({
37
+ error: _zod.z.object({ code: _zod.z.number(), message: _zod.z.string() })
38
+ });
39
+ const rpcResponse = _zod.z.union([rpcSuccessResponse, rpcErrorResponse]);
40
+ const cfSwapRate = _zod.z.object({
41
+ intermediary: numberOrHex.nullable(),
42
+ output: numberOrHex
43
+ });
44
+ const fee = _zod.z.intersection(rpcAssetSchema, _zod.z.object({ amount: numberOrHex }));
45
+ const cfSwapRateV2 = _zod.z.object({
46
+ egress_fee: fee,
47
+ ingress_fee: fee,
48
+ intermediary: u256.nullable(),
49
+ network_fee: fee,
50
+ output: u256
51
+ });
52
+ const chainGetBlockHash = hexString;
53
+ const stateGetMetadata = hexString;
54
+ const stateGetRuntimeVersion = _zod.z.object({
55
+ specName: _zod.z.string(),
56
+ implName: _zod.z.string(),
57
+ authoringVersion: _zod.z.number(),
58
+ specVersion: _zod.z.number(),
59
+ implVersion: _zod.z.number(),
60
+ apis: _zod.z.array(_zod.z.tuple([hexString, _zod.z.number()])),
61
+ transactionVersion: _zod.z.number(),
62
+ stateVersion: _zod.z.number()
63
+ });
64
+ const cfIngressEgressEnvironment = _zod.z.object({
65
+ minimum_deposit_amounts: chainAssetMapFactory(numberOrHex),
66
+ ingress_fees: chainAssetMapFactory(numberOrHex.nullable()),
67
+ egress_fees: chainAssetMapFactory(numberOrHex.nullable()),
68
+ witness_safety_margins: chainMapFactory(_zod.z.number().nullable()),
69
+ egress_dust_limits: chainAssetMapFactory(numberOrHex),
70
+ channel_opening_fees: chainMapFactory(numberOrHex)
71
+ }).transform(rename({ egress_dust_limits: "minimum_egress_amounts" }));
72
+ const cfSwappingEnvironment = _zod.z.object({
73
+ maximum_swap_amounts: chainAssetMapFactory(numberOrHex.nullable()),
74
+ network_fee_hundredth_pips: _zod.z.number()
75
+ });
76
+ const cfFundingEnvironment = _zod.z.object({
77
+ redemption_tax: numberOrHex,
78
+ minimum_funding_amount: numberOrHex
79
+ });
80
+ const cfEnvironment = _zod.z.object({
81
+ ingress_egress: cfIngressEgressEnvironment,
82
+ swapping: cfSwappingEnvironment,
83
+ funding: cfFundingEnvironment
84
+ });
85
+ const cfBoostPoolsDepth = _zod.z.array(
86
+ _zod.z.intersection(rpcAssetSchema, _zod.z.object({ tier: _zod.z.number(), available_amount: u256 }))
87
+ );
88
+ const cfSupportedAsssets = _zod.z.array(rpcAssetSchema);
89
+ const brokerRequestSwapDepositAddress = _zod.z.object({
90
+ address: _zod.z.string(),
91
+ issued_block: _zod.z.number(),
92
+ channel_id: _zod.z.number(),
93
+ source_chain_expiry_block: numberOrHex,
94
+ channel_opening_fee: u256
95
+ });
96
+
97
+
98
+
99
+
100
+
101
+
102
+
103
+
104
+
105
+
106
+
107
+
108
+
109
+
110
+
111
+
112
+
113
+ exports.brokerRequestSwapDepositAddress = brokerRequestSwapDepositAddress; exports.cfBoostPoolsDepth = cfBoostPoolsDepth; exports.cfEnvironment = cfEnvironment; exports.cfFundingEnvironment = cfFundingEnvironment; exports.cfIngressEgressEnvironment = cfIngressEgressEnvironment; exports.cfSupportedAsssets = cfSupportedAsssets; exports.cfSwapRate = cfSwapRate; exports.cfSwapRateV2 = cfSwapRateV2; exports.cfSwappingEnvironment = cfSwappingEnvironment; exports.chainGetBlockHash = chainGetBlockHash; exports.hexString = hexString; exports.numberOrHex = numberOrHex; exports.rpcResponse = rpcResponse; exports.stateGetMetadata = stateGetMetadata; exports.stateGetRuntimeVersion = stateGetRuntimeVersion; exports.u256 = u256;