@chainflip/utils 0.6.0 → 0.7.1

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;
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/types.d.cts CHANGED
@@ -1,4 +1,38 @@
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: {
12
+ account: string | null;
13
+ commissionBps: number;
14
+ };
15
+ affiliateFees: {
16
+ accountIndex: number;
17
+ commissionBps: number;
18
+ }[];
19
+ maxBoostFee: number;
20
+ dcaParams: {
21
+ chunkInterval: number;
22
+ numberOfChunks: number;
23
+ } | null;
24
+ refundParams: {
25
+ refundAddress: string;
26
+ minPrice: bigint;
27
+ retryDuration: number;
28
+ };
29
+ ccmDepositMetadata: {
30
+ channelMetadata: {
31
+ message: HexString;
32
+ gasBudget: HexString;
33
+ };
34
+ ccmAdditionalData: T;
35
+ } | null;
36
+ };
3
37
 
4
- export type { Bytelike, HexString };
38
+ export type { Bytelike, HexString, VaultSwapData };
package/dist/types.d.ts CHANGED
@@ -1,4 +1,38 @@
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: {
12
+ account: string | null;
13
+ commissionBps: number;
14
+ };
15
+ affiliateFees: {
16
+ accountIndex: number;
17
+ commissionBps: number;
18
+ }[];
19
+ maxBoostFee: number;
20
+ dcaParams: {
21
+ chunkInterval: number;
22
+ numberOfChunks: number;
23
+ } | null;
24
+ refundParams: {
25
+ refundAddress: string;
26
+ minPrice: bigint;
27
+ retryDuration: number;
28
+ };
29
+ ccmDepositMetadata: {
30
+ channelMetadata: {
31
+ message: HexString;
32
+ gasBudget: HexString;
33
+ };
34
+ ccmAdditionalData: T;
35
+ } | null;
36
+ };
3
37
 
4
- export type { Bytelike, HexString };
38
+ 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.6.0",
3
+ "version": "0.7.1",
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",