@chainflip/utils 0.5.1 → 0.7.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/base58.d.cts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { Bytelike } from './types.cjs';
2
+ import './chainflip.cjs';
2
3
 
3
4
  declare const CHARSET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
4
5
  declare const encode: (bytes: Bytelike) => string;
package/dist/base58.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { Bytelike } from './types.js';
2
+ import './chainflip.js';
2
3
 
3
4
  declare const CHARSET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
4
5
  declare const encode: (bytes: Bytelike) => string;
package/dist/bytes.d.cts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { HexString, Bytelike } from './types.cjs';
2
+ import './chainflip.cjs';
2
3
 
3
4
  declare const bytesToHex: (input: Uint8Array | number[]) => `0x${string}`;
4
5
  declare const hexToBytes: (input: HexString) => Uint8Array;
package/dist/bytes.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { HexString, Bytelike } from './types.js';
2
+ import './chainflip.js';
2
3
 
3
4
  declare const bytesToHex: (input: Uint8Array | number[]) => `0x${string}`;
4
5
  declare const hexToBytes: (input: HexString) => Uint8Array;
@@ -22,8 +22,10 @@ var chainflip_exports = {};
22
22
  __export(chainflip_exports, {
23
23
  addressTypes: () => addressTypes,
24
24
  assetConstants: () => assetConstants,
25
+ assetContractId: () => assetContractId,
25
26
  baseChainflipAssets: () => baseChainflipAssets,
26
27
  chainConstants: () => chainConstants,
28
+ chainContractId: () => chainContractId,
27
29
  chainflipAssets: () => chainflipAssets,
28
30
  chainflipChains: () => chainflipChains,
29
31
  chainflipEvmChains: () => chainflipEvmChains,
@@ -153,12 +155,33 @@ var internalAssetToRpcAsset = {
153
155
  Sol: { chain: "Solana", asset: "SOL" },
154
156
  SolUsdc: { chain: "Solana", asset: "USDC" }
155
157
  };
158
+ var chainContractId = {
159
+ Ethereum: 1,
160
+ Polkadot: 2,
161
+ Bitcoin: 3,
162
+ Arbitrum: 4,
163
+ Solana: 5
164
+ };
165
+ var assetContractId = {
166
+ Eth: 1,
167
+ Flip: 2,
168
+ Usdc: 3,
169
+ Usdt: 8,
170
+ Dot: 4,
171
+ Btc: 5,
172
+ ArbEth: 6,
173
+ ArbUsdc: 7,
174
+ Sol: 9,
175
+ SolUsdc: 10
176
+ };
156
177
  // Annotate the CommonJS export names for ESM import in node:
157
178
  0 && (module.exports = {
158
179
  addressTypes,
159
180
  assetConstants,
181
+ assetContractId,
160
182
  baseChainflipAssets,
161
183
  chainConstants,
184
+ chainContractId,
162
185
  chainflipAssets,
163
186
  chainflipChains,
164
187
  chainflipEvmChains,
@@ -116,5 +116,7 @@ declare const chainConstants: {
116
116
  };
117
117
  };
118
118
  declare const internalAssetToRpcAsset: Record<ChainflipAsset, AssetAndChain>;
119
+ declare const chainContractId: Record<ChainflipChain, number>;
120
+ declare const assetContractId: Record<ChainflipAsset, number>;
119
121
 
120
- export { type AddressType, type AssetOfChain, type BaseChainAssetMap, type BaseChainflipAsset, type ChainAssetMap, type ChainflipAsset, type ChainflipChain, type ChainflipEvmChain, type ChainflipNetwork, addressTypes, assetConstants, baseChainflipAssets, chainConstants, chainflipAssets, chainflipChains, chainflipEvmChains, chainflipNetworks, internalAssetToRpcAsset, readAssetValue, rpcAssets };
122
+ export { type AddressType, type AssetOfChain, type BaseChainAssetMap, type BaseChainflipAsset, type ChainAssetMap, type ChainflipAsset, type ChainflipChain, type ChainflipEvmChain, type ChainflipNetwork, addressTypes, assetConstants, assetContractId, baseChainflipAssets, chainConstants, chainContractId, chainflipAssets, chainflipChains, chainflipEvmChains, chainflipNetworks, internalAssetToRpcAsset, readAssetValue, rpcAssets };
@@ -116,5 +116,7 @@ declare const chainConstants: {
116
116
  };
117
117
  };
118
118
  declare const internalAssetToRpcAsset: Record<ChainflipAsset, AssetAndChain>;
119
+ declare const chainContractId: Record<ChainflipChain, number>;
120
+ declare const assetContractId: Record<ChainflipAsset, number>;
119
121
 
120
- export { type AddressType, type AssetOfChain, type BaseChainAssetMap, type BaseChainflipAsset, type ChainAssetMap, type ChainflipAsset, type ChainflipChain, type ChainflipEvmChain, type ChainflipNetwork, addressTypes, assetConstants, baseChainflipAssets, chainConstants, chainflipAssets, chainflipChains, chainflipEvmChains, chainflipNetworks, internalAssetToRpcAsset, readAssetValue, rpcAssets };
122
+ export { type AddressType, type AssetOfChain, type BaseChainAssetMap, type BaseChainflipAsset, type ChainAssetMap, type ChainflipAsset, type ChainflipChain, type ChainflipEvmChain, type ChainflipNetwork, addressTypes, assetConstants, assetContractId, baseChainflipAssets, chainConstants, chainContractId, chainflipAssets, chainflipChains, chainflipEvmChains, chainflipNetworks, internalAssetToRpcAsset, readAssetValue, rpcAssets };
package/dist/chainflip.js CHANGED
@@ -1,8 +1,10 @@
1
1
  import {
2
2
  addressTypes,
3
3
  assetConstants,
4
+ assetContractId,
4
5
  baseChainflipAssets,
5
6
  chainConstants,
7
+ chainContractId,
6
8
  chainflipAssets,
7
9
  chainflipChains,
8
10
  chainflipEvmChains,
@@ -10,12 +12,14 @@ import {
10
12
  internalAssetToRpcAsset,
11
13
  readAssetValue,
12
14
  rpcAssets
13
- } from "./chunk-FKSZD3R5.js";
15
+ } from "./chunk-YOAHWTE7.js";
14
16
  export {
15
17
  addressTypes,
16
18
  assetConstants,
19
+ assetContractId,
17
20
  baseChainflipAssets,
18
21
  chainConstants,
22
+ chainContractId,
19
23
  chainflipAssets,
20
24
  chainflipChains,
21
25
  chainflipEvmChains,
@@ -119,6 +119,25 @@ var internalAssetToRpcAsset = {
119
119
  Sol: { chain: "Solana", asset: "SOL" },
120
120
  SolUsdc: { chain: "Solana", asset: "USDC" }
121
121
  };
122
+ var chainContractId = {
123
+ Ethereum: 1,
124
+ Polkadot: 2,
125
+ Bitcoin: 3,
126
+ Arbitrum: 4,
127
+ Solana: 5
128
+ };
129
+ var assetContractId = {
130
+ Eth: 1,
131
+ Flip: 2,
132
+ Usdc: 3,
133
+ Usdt: 8,
134
+ Dot: 4,
135
+ Btc: 5,
136
+ ArbEth: 6,
137
+ ArbUsdc: 7,
138
+ Sol: 9,
139
+ SolUsdc: 10
140
+ };
122
141
 
123
142
  export {
124
143
  chainflipAssets,
@@ -131,5 +150,7 @@ export {
131
150
  readAssetValue,
132
151
  assetConstants,
133
152
  chainConstants,
134
- internalAssetToRpcAsset
153
+ internalAssetToRpcAsset,
154
+ chainContractId,
155
+ assetContractId
135
156
  };
package/dist/consts.cjs CHANGED
@@ -38,12 +38,12 @@ var POLKADOT_SS58_PREFIX = 0;
38
38
  var CHAINFLIP_BLOCK_TIME_SECONDS = 6;
39
39
  var CHAINFLIP_BLOCKS_PER_YEAR = 5256e3;
40
40
  var chainflipLinks = {
41
- website: "https://chainflip.io/",
41
+ website: "https://chainflip.io",
42
42
  discord: "https://discord.gg/chainflip-community",
43
43
  twitter: "https://twitter.com/chainflip",
44
44
  telegram: "https://t.me/chainflip_io_chat",
45
- blog: "https://blog.chainflip.io/",
46
- docs: "https://docs.chainflip.io/"
45
+ blog: "https://blog.chainflip.io",
46
+ docs: "https://docs.chainflip.io"
47
47
  };
48
48
  var chainflipCommunityLinks = {
49
49
  discord: "https://discord.gg/chainflip-community",
@@ -136,6 +136,14 @@ var brokerAliasMap = {
136
136
  cFLre1qinRDSoxnQ4sFEXRde58jkmkVMX7B2NFGkgZJ9pQLqF: {
137
137
  name: "Trust Wallet",
138
138
  twitter: "@TrustWallet"
139
+ },
140
+ cFKCm1mNBmVH2Lwyp2NTzPa1JNs4KYt19pX3yjbTy7GdCr3aB: {
141
+ name: "Dexifier",
142
+ twitter: "@DexifierX"
143
+ },
144
+ cFP82c86HiP35H7TwYziqnmUjSym3YdT3U2HwgrqN7krTyyih: {
145
+ name: "Moca",
146
+ twitter: "@moca_app"
139
147
  }
140
148
  };
141
149
  var lpAliasMap = {
package/dist/consts.js CHANGED
@@ -5,12 +5,12 @@ var POLKADOT_SS58_PREFIX = 0;
5
5
  var CHAINFLIP_BLOCK_TIME_SECONDS = 6;
6
6
  var CHAINFLIP_BLOCKS_PER_YEAR = 5256e3;
7
7
  var chainflipLinks = {
8
- website: "https://chainflip.io/",
8
+ website: "https://chainflip.io",
9
9
  discord: "https://discord.gg/chainflip-community",
10
10
  twitter: "https://twitter.com/chainflip",
11
11
  telegram: "https://t.me/chainflip_io_chat",
12
- blog: "https://blog.chainflip.io/",
13
- docs: "https://docs.chainflip.io/"
12
+ blog: "https://blog.chainflip.io",
13
+ docs: "https://docs.chainflip.io"
14
14
  };
15
15
  var chainflipCommunityLinks = {
16
16
  discord: "https://discord.gg/chainflip-community",
@@ -103,6 +103,14 @@ var brokerAliasMap = {
103
103
  cFLre1qinRDSoxnQ4sFEXRde58jkmkVMX7B2NFGkgZJ9pQLqF: {
104
104
  name: "Trust Wallet",
105
105
  twitter: "@TrustWallet"
106
+ },
107
+ cFKCm1mNBmVH2Lwyp2NTzPa1JNs4KYt19pX3yjbTy7GdCr3aB: {
108
+ name: "Dexifier",
109
+ twitter: "@DexifierX"
110
+ },
111
+ cFP82c86HiP35H7TwYziqnmUjSym3YdT3U2HwgrqN7krTyyih: {
112
+ name: "Moca",
113
+ twitter: "@moca_app"
106
114
  }
107
115
  };
108
116
  var lpAliasMap = {
package/dist/number.d.cts CHANGED
@@ -1,5 +1,6 @@
1
1
  import BigNumber from 'bignumber.js';
2
2
  import { HexString } from './types.cjs';
3
+ import './chainflip.cjs';
3
4
 
4
5
  declare const hexEncodeNumber: (num: number | bigint) => HexString;
5
6
  declare function formatUsdValue(value: BigNumber.Value, precise?: boolean): string;
package/dist/number.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import BigNumber from 'bignumber.js';
2
2
  import { HexString } from './types.js';
3
+ import './chainflip.js';
3
4
 
4
5
  declare const hexEncodeNumber: (num: number | bigint) => HexString;
5
6
  declare function formatUsdValue(value: BigNumber.Value, precise?: boolean): string;
package/dist/ss58.d.cts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { Bytelike, HexString } from './types.cjs';
2
+ import './chainflip.cjs';
2
3
 
3
4
  declare const decode: (input: string) => {
4
5
  data: Uint8Array;
package/dist/ss58.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { Bytelike, HexString } from './types.js';
2
+ import './chainflip.js';
2
3
 
3
4
  declare const decode: (input: string) => {
4
5
  data: Uint8Array;
package/dist/string.d.cts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { HexString } from './types.cjs';
2
+ import './chainflip.cjs';
2
3
 
3
4
  declare const toUpperCase: <const T extends string>(str: T) => Uppercase<T>;
4
5
  declare const toLowerCase: <const T extends string>(str: T) => Lowercase<T>;
package/dist/string.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { HexString } from './types.js';
2
+ import './chainflip.js';
2
3
 
3
4
  declare const toUpperCase: <const T extends string>(str: T) => Uppercase<T>;
4
5
  declare const toLowerCase: <const T extends string>(str: T) => Lowercase<T>;
package/dist/tickMath.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  assetConstants
3
- } from "./chunk-FKSZD3R5.js";
3
+ } from "./chunk-YOAHWTE7.js";
4
4
 
5
5
  // src/tickMath.ts
6
6
  import { BigNumber } from "bignumber.js";
package/dist/types.d.cts CHANGED
@@ -1,4 +1,35 @@
1
+ import { ChainflipAsset } from './chainflip.cjs';
2
+
1
3
  type HexString = `0x${string}`;
2
4
  type Bytelike = Uint8Array | number[] | HexString;
5
+ type VaultSwapData<T = never> = {
6
+ amount: bigint;
7
+ destinationAddress: string;
8
+ inputAsset: ChainflipAsset;
9
+ outputAsset: ChainflipAsset;
10
+ depositChainBlockHeight: number;
11
+ brokerFee: number;
12
+ affiliateFees: {
13
+ accountIndex: number;
14
+ commissionBps: number;
15
+ }[];
16
+ maxBoostFee: number;
17
+ dcaParams: {
18
+ chunkInterval: number;
19
+ numberOfChunks: number;
20
+ } | null;
21
+ refundParams: {
22
+ refundAddress: string;
23
+ minPrice: bigint;
24
+ retryDuration: number;
25
+ };
26
+ ccmDepositMetadata: {
27
+ channelMetadata: {
28
+ message: HexString;
29
+ gasBudget: HexString;
30
+ };
31
+ ccmAdditionalData: T;
32
+ } | null;
33
+ };
3
34
 
4
- export type { Bytelike, HexString };
35
+ export type { Bytelike, HexString, VaultSwapData };
package/dist/types.d.ts CHANGED
@@ -1,4 +1,35 @@
1
+ import { ChainflipAsset } from './chainflip.js';
2
+
1
3
  type HexString = `0x${string}`;
2
4
  type Bytelike = Uint8Array | number[] | HexString;
5
+ type VaultSwapData<T = never> = {
6
+ amount: bigint;
7
+ destinationAddress: string;
8
+ inputAsset: ChainflipAsset;
9
+ outputAsset: ChainflipAsset;
10
+ depositChainBlockHeight: number;
11
+ brokerFee: number;
12
+ affiliateFees: {
13
+ accountIndex: number;
14
+ commissionBps: number;
15
+ }[];
16
+ maxBoostFee: number;
17
+ dcaParams: {
18
+ chunkInterval: number;
19
+ numberOfChunks: number;
20
+ } | null;
21
+ refundParams: {
22
+ refundAddress: string;
23
+ minPrice: bigint;
24
+ retryDuration: number;
25
+ };
26
+ ccmDepositMetadata: {
27
+ channelMetadata: {
28
+ message: HexString;
29
+ gasBudget: HexString;
30
+ };
31
+ ccmAdditionalData: T;
32
+ } | null;
33
+ };
3
34
 
4
- export type { Bytelike, HexString };
35
+ export type { Bytelike, HexString, VaultSwapData };
package/dist/url.cjs ADDED
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/url.ts
21
+ var url_exports = {};
22
+ __export(url_exports, {
23
+ parseUrlWithBasicAuth: () => parseUrlWithBasicAuth
24
+ });
25
+ module.exports = __toCommonJS(url_exports);
26
+ var parseUrlWithBasicAuth = (url) => {
27
+ const rpcUrl = new URL(url);
28
+ let headers = {};
29
+ if (rpcUrl.username || rpcUrl.password) {
30
+ headers = { Authorization: `Basic ${btoa(`${rpcUrl.username}:${rpcUrl.password}`)}` };
31
+ rpcUrl.username = "";
32
+ rpcUrl.password = "";
33
+ }
34
+ return { url: rpcUrl.toString(), headers };
35
+ };
36
+ // Annotate the CommonJS export names for ESM import in node:
37
+ 0 && (module.exports = {
38
+ parseUrlWithBasicAuth
39
+ });
package/dist/url.d.cts ADDED
@@ -0,0 +1,6 @@
1
+ declare const parseUrlWithBasicAuth: (url: string) => {
2
+ url: string;
3
+ headers: {};
4
+ };
5
+
6
+ export { parseUrlWithBasicAuth };
package/dist/url.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ declare const parseUrlWithBasicAuth: (url: string) => {
2
+ url: string;
3
+ headers: {};
4
+ };
5
+
6
+ export { parseUrlWithBasicAuth };
package/dist/url.js ADDED
@@ -0,0 +1,14 @@
1
+ // src/url.ts
2
+ var parseUrlWithBasicAuth = (url) => {
3
+ const rpcUrl = new URL(url);
4
+ let headers = {};
5
+ if (rpcUrl.username || rpcUrl.password) {
6
+ headers = { Authorization: `Basic ${btoa(`${rpcUrl.username}:${rpcUrl.password}`)}` };
7
+ rpcUrl.username = "";
8
+ rpcUrl.password = "";
9
+ }
10
+ return { url: rpcUrl.toString(), headers };
11
+ };
12
+ export {
13
+ parseUrlWithBasicAuth
14
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chainflip/utils",
3
- "version": "0.5.1",
3
+ "version": "0.7.0",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",
@@ -20,7 +20,7 @@
20
20
  },
21
21
  "devDependencies": {
22
22
  "@noble/hashes": "^1.7.1",
23
- "@vitest/ui": "3.0.7"
23
+ "@vitest/ui": "3.0.8"
24
24
  },
25
25
  "dependencies": {
26
26
  "@date-fns/utc": "^2.1.0",