@sonarwatch/portfolio-core 0.8.118 → 0.8.119
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/CHANGELOG.md +4 -0
- package/package.json +1 -1
- package/src/Address.d.ts +6 -0
- package/src/Address.js +3 -0
- package/src/Address.js.map +1 -1
- package/src/Network.d.ts +18 -0
- package/src/Network.js +3 -0
- package/src/Network.js.map +1 -1
- package/src/Platform.d.ts +3 -0
- package/src/Portfolio.d.ts +36 -0
- package/src/UsdValue.d.ts +6 -0
- package/src/Yield.d.ts +25 -0
- package/src/Yield.js +22 -0
- package/src/Yield.js.map +1 -1
- package/src/helpers.d.ts +7 -0
- package/src/helpers.js +7 -0
- package/src/helpers.js.map +1 -1
- package/src/utils/assertAddressSystem.d.ts +7 -0
- package/src/utils/assertAddressSystem.js +7 -0
- package/src/utils/assertAddressSystem.js.map +1 -1
- package/src/utils/assertNetworkId.d.ts +7 -0
- package/src/utils/assertNetworkId.js.map +1 -1
- package/src/utils/compareName.d.ts +6 -0
- package/src/utils/compareName.js +6 -0
- package/src/utils/compareName.js.map +1 -1
- package/src/utils/compareUsdValue.d.ts +6 -0
- package/src/utils/compareUsdValue.js.map +1 -1
- package/src/utils/formatTokenAddress.js +8 -6
- package/src/utils/formatTokenAddress.js.map +1 -1
- package/src/utils/isNativeAddressAlias.d.ts +1 -0
- package/src/utils/isNativeAddressAlias.js +9 -0
- package/src/utils/isNativeAddressAlias.js.map +1 -0
- package/src/Lock.d.ts +0 -17
- package/src/Lock.js +0 -20
- package/src/Lock.js.map +0 -1
- package/src/utils/isAnAlias.d.ts +0 -1
- package/src/utils/isAnAlias.js +0 -9
- package/src/utils/isAnAlias.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
## [0.8.119](https://github.com/sonarwatch/portfolio/compare/core-0.8.118...core-0.8.119) (2023-12-05)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
5
9
|
## [0.8.118](https://github.com/sonarwatch/portfolio/compare/core-0.8.117...core-0.8.118) (2023-12-05)
|
|
6
10
|
|
|
7
11
|
|
package/package.json
CHANGED
package/src/Address.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents the address systems.
|
|
3
|
+
*/
|
|
1
4
|
export declare const AddressSystem: {
|
|
2
5
|
readonly solana: "solana";
|
|
3
6
|
readonly bitcoin: "bitcoin";
|
|
@@ -5,4 +8,7 @@ export declare const AddressSystem: {
|
|
|
5
8
|
readonly move: "move";
|
|
6
9
|
readonly sei: "sei";
|
|
7
10
|
};
|
|
11
|
+
/**
|
|
12
|
+
* Represents the type of address system.
|
|
13
|
+
*/
|
|
8
14
|
export type AddressSystemType = (typeof AddressSystem)[keyof typeof AddressSystem];
|
package/src/Address.js
CHANGED
package/src/Address.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Address.js","sourceRoot":"","sources":["../../../../packages/core/src/Address.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"Address.js","sourceRoot":"","sources":["../../../../packages/core/src/Address.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACU,QAAA,aAAa,GAAG;IAC3B,MAAM,EAAE,QAAQ;IAChB,OAAO,EAAE,SAAS;IAClB,GAAG,EAAE,KAAK;IACV,IAAI,EAAE,MAAM;IACZ,GAAG,EAAE,KAAK;CACF,CAAC"}
|
package/src/Network.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { AddressSystemType } from './Address';
|
|
2
|
+
/**
|
|
3
|
+
* Network IDs.
|
|
4
|
+
*/
|
|
2
5
|
export declare const NetworkId: {
|
|
3
6
|
readonly bitcoin: "bitcoin";
|
|
4
7
|
readonly solana: "solana";
|
|
@@ -10,10 +13,25 @@ export declare const NetworkId: {
|
|
|
10
13
|
readonly sei: "sei";
|
|
11
14
|
readonly bnb: "bnb";
|
|
12
15
|
};
|
|
16
|
+
/**
|
|
17
|
+
* Represents the type of a network ID.
|
|
18
|
+
*/
|
|
13
19
|
export type NetworkIdType = (typeof NetworkId)[keyof typeof NetworkId];
|
|
20
|
+
/**
|
|
21
|
+
* Represents the type of a Move network ID.
|
|
22
|
+
*/
|
|
14
23
|
export type MoveNetworkIdType = typeof NetworkId.aptos | typeof NetworkId.sui;
|
|
24
|
+
/**
|
|
25
|
+
* Represents the type of an EVM network ID.
|
|
26
|
+
*/
|
|
15
27
|
export type EvmNetworkIdType = typeof NetworkId.ethereum | typeof NetworkId.avalanche | typeof NetworkId.polygon | typeof NetworkId.bnb;
|
|
28
|
+
/**
|
|
29
|
+
* Represents the type of a Cosmos network ID.
|
|
30
|
+
*/
|
|
16
31
|
export type CosmosNetworkIdType = typeof NetworkId.sei;
|
|
32
|
+
/**
|
|
33
|
+
* Represents a network.
|
|
34
|
+
*/
|
|
17
35
|
export type Network = {
|
|
18
36
|
id: NetworkIdType;
|
|
19
37
|
name: string;
|
package/src/Network.js
CHANGED
package/src/Network.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Network.js","sourceRoot":"","sources":["../../../../packages/core/src/Network.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"Network.js","sourceRoot":"","sources":["../../../../packages/core/src/Network.ts"],"names":[],"mappings":";;;AAEA;;GAEG;AACU,QAAA,SAAS,GAAG;IACvB,OAAO,EAAE,SAAS;IAClB,MAAM,EAAE,QAAQ;IAChB,QAAQ,EAAE,UAAU;IACpB,SAAS,EAAE,WAAW;IACtB,OAAO,EAAE,SAAS;IAClB,KAAK,EAAE,OAAO;IACd,GAAG,EAAE,KAAK;IACV,GAAG,EAAE,KAAK;IACV,GAAG,EAAE,KAAK;CACF,CAAC"}
|
package/src/Platform.d.ts
CHANGED
package/src/Portfolio.d.ts
CHANGED
|
@@ -165,15 +165,51 @@ export type PortfolioElementLiquidity = PortfolioElementCommon & {
|
|
|
165
165
|
* Represents the data of a borrow lend portfolio element.
|
|
166
166
|
*/
|
|
167
167
|
export type PortfolioElementBorrowLendData = {
|
|
168
|
+
/**
|
|
169
|
+
* The value of the portfolio element in USD.
|
|
170
|
+
*/
|
|
168
171
|
value: UsdValue;
|
|
172
|
+
/**
|
|
173
|
+
* The assets supplied in the portfolio element.
|
|
174
|
+
*/
|
|
169
175
|
suppliedAssets: PortfolioAsset[];
|
|
176
|
+
/**
|
|
177
|
+
* The assets borrowed in the portfolio element.
|
|
178
|
+
*/
|
|
170
179
|
borrowedAssets: PortfolioAsset[];
|
|
180
|
+
/**
|
|
181
|
+
* The assets rewarded in the portfolio element.
|
|
182
|
+
*/
|
|
171
183
|
rewardAssets: PortfolioAsset[];
|
|
184
|
+
/**
|
|
185
|
+
* The value of the assets supplied in USD.
|
|
186
|
+
*/
|
|
172
187
|
suppliedValue: UsdValue;
|
|
188
|
+
/**
|
|
189
|
+
* The value of the assets borrowed in USD.
|
|
190
|
+
*/
|
|
173
191
|
borrowedValue: UsdValue;
|
|
192
|
+
/**
|
|
193
|
+
* The yields generated by the supplied assets.
|
|
194
|
+
*/
|
|
174
195
|
suppliedYields: Yield[][];
|
|
196
|
+
/**
|
|
197
|
+
* The yields generated by the borrowed assets.
|
|
198
|
+
*/
|
|
175
199
|
borrowedYields: Yield[][];
|
|
200
|
+
/**
|
|
201
|
+
* The collateral ratio of the portfolio element.
|
|
202
|
+
* -1 means infinity/no borrow.
|
|
203
|
+
* null means unknown.
|
|
204
|
+
* 1.5 means 150%.
|
|
205
|
+
*/
|
|
176
206
|
collateralRatio: number | null;
|
|
207
|
+
/**
|
|
208
|
+
* The health ratio of the portfolio element.
|
|
209
|
+
* 1 means 100% / full health / no borrow.
|
|
210
|
+
* 0 and <0 means can be liquidated.
|
|
211
|
+
* null means unknown.
|
|
212
|
+
*/
|
|
177
213
|
healthRatio: number | null;
|
|
178
214
|
};
|
|
179
215
|
/**
|
package/src/UsdValue.d.ts
CHANGED
package/src/Yield.d.ts
CHANGED
|
@@ -1,8 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calculates the Annual Percentage Yield (APY) based on the Annual Percentage Rate (APR).
|
|
3
|
+
* @param apr The Annual Percentage Rate.
|
|
4
|
+
* @param compoundFrequency The number of times the interest is compounded in a year. Default is 365.
|
|
5
|
+
* @returns The Annual Percentage Yield (APY).
|
|
6
|
+
*/
|
|
1
7
|
export declare function aprToApy(apr: number, compoundFrequency?: number): number;
|
|
8
|
+
/**
|
|
9
|
+
* Calculates the Annual Percentage Rate (APR) based on the Annual Percentage Yield (APY).
|
|
10
|
+
* @param apy The Annual Percentage Yield.
|
|
11
|
+
* @param compoundFrequency The number of times the interest is compounded in a year. Default is 365.
|
|
12
|
+
* @returns The Annual Percentage Rate (APR).
|
|
13
|
+
*/
|
|
2
14
|
export declare function apyToApr(apy: number, compoundFrequency?: number): number;
|
|
15
|
+
/**
|
|
16
|
+
* Represents the yield information including APR and APY.
|
|
17
|
+
*/
|
|
3
18
|
export type Yield = {
|
|
4
19
|
apr: number;
|
|
5
20
|
apy: number;
|
|
6
21
|
};
|
|
22
|
+
/**
|
|
23
|
+
* Creates a Yield object from the given APR.
|
|
24
|
+
* @param apr The Annual Percentage Rate.
|
|
25
|
+
* @returns The Yield object with the calculated APY.
|
|
26
|
+
*/
|
|
7
27
|
export declare const createYieldFromApr: (apr: number) => Yield;
|
|
28
|
+
/**
|
|
29
|
+
* Creates a Yield object from the given APY.
|
|
30
|
+
* @param apy The Annual Percentage Yield.
|
|
31
|
+
* @returns The Yield object with the calculated APR.
|
|
32
|
+
*/
|
|
8
33
|
export declare const createYieldFromApy: (apy: number) => Yield;
|
package/src/Yield.js
CHANGED
|
@@ -1,19 +1,41 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createYieldFromApy = exports.createYieldFromApr = exports.apyToApr = exports.aprToApy = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Calculates the Annual Percentage Yield (APY) based on the Annual Percentage Rate (APR).
|
|
6
|
+
* @param apr The Annual Percentage Rate.
|
|
7
|
+
* @param compoundFrequency The number of times the interest is compounded in a year. Default is 365.
|
|
8
|
+
* @returns The Annual Percentage Yield (APY).
|
|
9
|
+
*/
|
|
4
10
|
function aprToApy(apr, compoundFrequency = 365) {
|
|
5
11
|
return Math.pow((1 + apr / compoundFrequency), compoundFrequency) - 1;
|
|
6
12
|
}
|
|
7
13
|
exports.aprToApy = aprToApy;
|
|
14
|
+
/**
|
|
15
|
+
* Calculates the Annual Percentage Rate (APR) based on the Annual Percentage Yield (APY).
|
|
16
|
+
* @param apy The Annual Percentage Yield.
|
|
17
|
+
* @param compoundFrequency The number of times the interest is compounded in a year. Default is 365.
|
|
18
|
+
* @returns The Annual Percentage Rate (APR).
|
|
19
|
+
*/
|
|
8
20
|
function apyToApr(apy, compoundFrequency = 365) {
|
|
9
21
|
return (Math.pow((1 + apy), (1 / compoundFrequency)) - 1) * compoundFrequency;
|
|
10
22
|
}
|
|
11
23
|
exports.apyToApr = apyToApr;
|
|
24
|
+
/**
|
|
25
|
+
* Creates a Yield object from the given APR.
|
|
26
|
+
* @param apr The Annual Percentage Rate.
|
|
27
|
+
* @returns The Yield object with the calculated APY.
|
|
28
|
+
*/
|
|
12
29
|
const createYieldFromApr = (apr) => ({
|
|
13
30
|
apr,
|
|
14
31
|
apy: aprToApy(apr),
|
|
15
32
|
});
|
|
16
33
|
exports.createYieldFromApr = createYieldFromApr;
|
|
34
|
+
/**
|
|
35
|
+
* Creates a Yield object from the given APY.
|
|
36
|
+
* @param apy The Annual Percentage Yield.
|
|
37
|
+
* @returns The Yield object with the calculated APR.
|
|
38
|
+
*/
|
|
17
39
|
const createYieldFromApy = (apy) => ({
|
|
18
40
|
apr: apyToApr(apy),
|
|
19
41
|
apy,
|
package/src/Yield.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Yield.js","sourceRoot":"","sources":["../../../../packages/core/src/Yield.ts"],"names":[],"mappings":";;;AAAA,SAAgB,QAAQ,CAAC,GAAW,EAAE,iBAAiB,GAAG,GAAG;IAC3D,OAAO,SAAA,CAAC,CAAC,GAAG,GAAG,GAAG,iBAAiB,CAAC,EAAI,iBAAiB,CAAA,GAAG,CAAC,CAAC;AAChE,CAAC;AAFD,4BAEC;AAED,SAAgB,QAAQ,CAAC,GAAW,EAAE,iBAAiB,GAAG,GAAG;IAC3D,OAAO,CAAC,SAAA,CAAC,CAAC,GAAG,GAAG,CAAC,EAAI,CAAC,CAAC,GAAG,iBAAiB,CAAC,CAAA,GAAG,CAAC,CAAC,GAAG,iBAAiB,CAAC;AACxE,CAAC;AAFD,4BAEC;
|
|
1
|
+
{"version":3,"file":"Yield.js","sourceRoot":"","sources":["../../../../packages/core/src/Yield.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,SAAgB,QAAQ,CAAC,GAAW,EAAE,iBAAiB,GAAG,GAAG;IAC3D,OAAO,SAAA,CAAC,CAAC,GAAG,GAAG,GAAG,iBAAiB,CAAC,EAAI,iBAAiB,CAAA,GAAG,CAAC,CAAC;AAChE,CAAC;AAFD,4BAEC;AAED;;;;;GAKG;AACH,SAAgB,QAAQ,CAAC,GAAW,EAAE,iBAAiB,GAAG,GAAG;IAC3D,OAAO,CAAC,SAAA,CAAC,CAAC,GAAG,GAAG,CAAC,EAAI,CAAC,CAAC,GAAG,iBAAiB,CAAC,CAAA,GAAG,CAAC,CAAC,GAAG,iBAAiB,CAAC;AACxE,CAAC;AAFD,4BAEC;AAUD;;;;GAIG;AACI,MAAM,kBAAkB,GAAG,CAAC,GAAW,EAAS,EAAE,CAAC,CAAC;IACzD,GAAG;IACH,GAAG,EAAE,QAAQ,CAAC,GAAG,CAAC;CACnB,CAAC,CAAC;AAHU,QAAA,kBAAkB,sBAG5B;AAEH;;;;GAIG;AACI,MAAM,kBAAkB,GAAG,CAAC,GAAW,EAAS,EAAE,CAAC,CAAC;IACzD,GAAG,EAAE,QAAQ,CAAC,GAAG,CAAC;IAClB,GAAG;CACJ,CAAC,CAAC;AAHU,QAAA,kBAAkB,sBAG5B"}
|
package/src/helpers.d.ts
CHANGED
package/src/helpers.js
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.deepClone = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Deep clones a value.
|
|
6
|
+
*
|
|
7
|
+
* @template T - The type of the value being cloned.
|
|
8
|
+
* @param value - The value to be cloned.
|
|
9
|
+
* @returns A deep clone of the value.
|
|
10
|
+
*/
|
|
4
11
|
function deepClone(value) {
|
|
5
12
|
return JSON.parse(JSON.stringify(value));
|
|
6
13
|
}
|
package/src/helpers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../../packages/core/src/helpers.ts"],"names":[],"mappings":";;;AAAA,SAAgB,SAAS,CAAI,KAAQ;IACnC,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAM,CAAC;AAChD,CAAC;AAFD,8BAEC"}
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../../packages/core/src/helpers.ts"],"names":[],"mappings":";;;AAAA;;;;;;GAMG;AACH,SAAgB,SAAS,CAAI,KAAQ;IACnC,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAM,CAAC;AAChD,CAAC;AAFD,8BAEC"}
|
|
@@ -1,2 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Asserts that the given address system is valid.
|
|
3
|
+
*
|
|
4
|
+
* @param addressSystem - The address system to be validated.
|
|
5
|
+
* @returns The validated address system.
|
|
6
|
+
* @throws Error if the address system is not valid.
|
|
7
|
+
*/
|
|
1
8
|
import { AddressSystemType } from '../Address';
|
|
2
9
|
export declare function assertAddressSystem(addressSystem: string): AddressSystemType;
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.assertAddressSystem = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Asserts that the given address system is valid.
|
|
6
|
+
*
|
|
7
|
+
* @param addressSystem - The address system to be validated.
|
|
8
|
+
* @returns The validated address system.
|
|
9
|
+
* @throws Error if the address system is not valid.
|
|
10
|
+
*/
|
|
4
11
|
const Address_1 = require("../Address");
|
|
5
12
|
function assertAddressSystem(addressSystem) {
|
|
6
13
|
if (addressSystem in Address_1.AddressSystem)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assertAddressSystem.js","sourceRoot":"","sources":["../../../../../packages/core/src/utils/assertAddressSystem.ts"],"names":[],"mappings":";;;AAAA,wCAA8D;AAE9D,SAAgB,mBAAmB,CAAC,aAAqB;IACvD,IAAI,aAAa,IAAI,uBAAa;QAAE,OAAO,aAAkC,CAAC;IAC9E,MAAM,IAAI,KAAK,CAAC,gCAAgC,aAAa,EAAE,CAAC,CAAC;AACnE,CAAC;AAHD,kDAGC"}
|
|
1
|
+
{"version":3,"file":"assertAddressSystem.js","sourceRoot":"","sources":["../../../../../packages/core/src/utils/assertAddressSystem.ts"],"names":[],"mappings":";;;AAAA;;;;;;GAMG;AACH,wCAA8D;AAE9D,SAAgB,mBAAmB,CAAC,aAAqB;IACvD,IAAI,aAAa,IAAI,uBAAa;QAAE,OAAO,aAAkC,CAAC;IAC9E,MAAM,IAAI,KAAK,CAAC,gCAAgC,aAAa,EAAE,CAAC,CAAC;AACnE,CAAC;AAHD,kDAGC"}
|
|
@@ -1,2 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Asserts the validity of a network ID.
|
|
3
|
+
*
|
|
4
|
+
* @param networkId - The network ID to be validated.
|
|
5
|
+
* @returns The validated network ID.
|
|
6
|
+
* @throws Error if the network ID is not valid.
|
|
7
|
+
*/
|
|
1
8
|
import { NetworkIdType } from '../Network';
|
|
2
9
|
export declare function assertNetworkId(networkId: string): NetworkIdType;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assertNetworkId.js","sourceRoot":"","sources":["../../../../../packages/core/src/utils/assertNetworkId.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"assertNetworkId.js","sourceRoot":"","sources":["../../../../../packages/core/src/utils/assertNetworkId.ts"],"names":[],"mappings":";;;AAQA,4CAAwC;AAExC,SAAgB,eAAe,CAAC,SAAiB;IAC/C,MAAM,OAAO,GAAG,oBAAQ,CAAC,SAA0B,CAAC,CAAC;IACrD,IAAI,CAAC,OAAO;QAAE,MAAM,IAAI,KAAK,CAAC,2BAA2B,SAAS,EAAE,CAAC,CAAC;IACtE,OAAO,SAA0B,CAAC;AACpC,CAAC;AAJD,0CAIC"}
|
|
@@ -1 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compares two names and returns a number indicating their order.
|
|
3
|
+
* @param a - The first name to compare.
|
|
4
|
+
* @param b - The second name to compare.
|
|
5
|
+
* @returns A negative number if `a` comes before `b`, a positive number if `a` comes after `b`, or 0 if they are equal.
|
|
6
|
+
*/
|
|
1
7
|
export declare function compareName(a: string | undefined, b: string | undefined): number;
|
package/src/utils/compareName.js
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.compareName = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Compares two names and returns a number indicating their order.
|
|
6
|
+
* @param a - The first name to compare.
|
|
7
|
+
* @param b - The second name to compare.
|
|
8
|
+
* @returns A negative number if `a` comes before `b`, a positive number if `a` comes after `b`, or 0 if they are equal.
|
|
9
|
+
*/
|
|
4
10
|
function compareName(a, b) {
|
|
5
11
|
if (a === b)
|
|
6
12
|
return 0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compareName.js","sourceRoot":"","sources":["../../../../../packages/core/src/utils/compareName.ts"],"names":[],"mappings":";;;AAAA,SAAgB,WAAW,CACzB,CAAqB,EACrB,CAAqB;IAErB,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,CAAC,CAAC;IACtB,IAAI,CAAC,KAAK,SAAS;QAAE,OAAO,CAAC,CAAC,CAAC;IAC/B,IAAI,CAAC,KAAK,SAAS;QAAE,OAAO,CAAC,CAAC;IAC9B,IAAI,CAAC,GAAG,CAAC;QAAE,OAAO,CAAC,CAAC,CAAC;IACrB,IAAI,CAAC,GAAG,CAAC;QAAE,OAAO,CAAC,CAAC;IACpB,OAAO,CAAC,CAAC;AACX,CAAC;AAVD,kCAUC"}
|
|
1
|
+
{"version":3,"file":"compareName.js","sourceRoot":"","sources":["../../../../../packages/core/src/utils/compareName.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,SAAgB,WAAW,CACzB,CAAqB,EACrB,CAAqB;IAErB,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,CAAC,CAAC;IACtB,IAAI,CAAC,KAAK,SAAS;QAAE,OAAO,CAAC,CAAC,CAAC;IAC/B,IAAI,CAAC,KAAK,SAAS;QAAE,OAAO,CAAC,CAAC;IAC9B,IAAI,CAAC,GAAG,CAAC;QAAE,OAAO,CAAC,CAAC,CAAC;IACrB,IAAI,CAAC,GAAG,CAAC;QAAE,OAAO,CAAC,CAAC;IACpB,OAAO,CAAC,CAAC;AACX,CAAC;AAVD,kCAUC"}
|
|
@@ -1,2 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compares two UsdValue objects and returns a number indicating their relative order.
|
|
3
|
+
* @param a - The first UsdValue object to compare.
|
|
4
|
+
* @param b - The second UsdValue object to compare.
|
|
5
|
+
* @returns A negative number if `a` is less than `b`, a positive number if `a` is greater than `b`, or 0 if they are equal.
|
|
6
|
+
*/
|
|
1
7
|
import { UsdValue } from '../UsdValue';
|
|
2
8
|
export declare function compareUsdValue(a: UsdValue, b: UsdValue): number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compareUsdValue.js","sourceRoot":"","sources":["../../../../../packages/core/src/utils/compareUsdValue.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"compareUsdValue.js","sourceRoot":"","sources":["../../../../../packages/core/src/utils/compareUsdValue.ts"],"names":[],"mappings":";;;AAQA,SAAgB,eAAe,CAAC,CAAW,EAAE,CAAW;IACtD,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,CAAC,CAAC;IACtB,IAAI,CAAC,KAAK,IAAI;QAAE,OAAO,CAAC,CAAC,CAAC;IAC1B,IAAI,CAAC,KAAK,IAAI;QAAE,OAAO,CAAC,CAAC;IACzB,OAAO,CAAC,GAAG,CAAC,CAAC;AACf,CAAC;AALD,0CAKC"}
|
|
@@ -5,7 +5,7 @@ const address_1 = require("@ethersproject/address");
|
|
|
5
5
|
const Address_1 = require("../Address");
|
|
6
6
|
const constants_1 = require("../constants");
|
|
7
7
|
const validTokenAddress_1 = require("./validTokenAddress");
|
|
8
|
-
const
|
|
8
|
+
const isNativeAddressAlias_1 = require("./isNativeAddressAlias");
|
|
9
9
|
function formatBitcoinTokenAddress(address) {
|
|
10
10
|
(0, validTokenAddress_1.assertBitcoinTokenAddress)(address);
|
|
11
11
|
return address;
|
|
@@ -13,13 +13,15 @@ function formatBitcoinTokenAddress(address) {
|
|
|
13
13
|
exports.formatBitcoinTokenAddress = formatBitcoinTokenAddress;
|
|
14
14
|
function formatMoveTokenAddress(address) {
|
|
15
15
|
(0, validTokenAddress_1.assertMoveTokenAddress)(address);
|
|
16
|
-
const tAddress = (0,
|
|
16
|
+
const tAddress = (0, isNativeAddressAlias_1.isNativeAddressAliasSui)(address)
|
|
17
|
+
? constants_1.networks.sui.native.address
|
|
18
|
+
: address;
|
|
17
19
|
return tAddress
|
|
18
20
|
.trim()
|
|
19
|
-
.
|
|
20
|
-
.
|
|
21
|
-
.
|
|
22
|
-
.
|
|
21
|
+
.replaceAll('::', '__')
|
|
22
|
+
.replaceAll(',', '-')
|
|
23
|
+
.replaceAll(/[^\w\s-]/g, '')
|
|
24
|
+
.replaceAll(/[\s_-]+/g, '-');
|
|
23
25
|
}
|
|
24
26
|
exports.formatMoveTokenAddress = formatMoveTokenAddress;
|
|
25
27
|
function formatEvmTokenAddress(address) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatTokenAddress.js","sourceRoot":"","sources":["../../../../../packages/core/src/utils/formatTokenAddress.ts"],"names":[],"mappings":";;;AAAA,oDAAoD;AAEpD,wCAA8D;AAC9D,4CAAwC;AACxC,2DAM6B;AAC7B,
|
|
1
|
+
{"version":3,"file":"formatTokenAddress.js","sourceRoot":"","sources":["../../../../../packages/core/src/utils/formatTokenAddress.ts"],"names":[],"mappings":";;;AAAA,oDAAoD;AAEpD,wCAA8D;AAC9D,4CAAwC;AACxC,2DAM6B;AAC7B,iEAAiE;AAEjE,SAAgB,yBAAyB,CAAC,OAAe;IACvD,IAAA,6CAAyB,EAAC,OAAO,CAAC,CAAC;IACnC,OAAO,OAAO,CAAC;AACjB,CAAC;AAHD,8DAGC;AAED,SAAgB,sBAAsB,CAAC,OAAe;IACpD,IAAA,0CAAsB,EAAC,OAAO,CAAC,CAAC;IAChC,MAAM,QAAQ,GAAG,IAAA,8CAAuB,EAAC,OAAO,CAAC;QAC/C,CAAC,CAAC,oBAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,OAAO;QAC7B,CAAC,CAAC,OAAO,CAAC;IACZ,OAAO,QAAQ;SACZ,IAAI,EAAE;SACN,UAAU,CAAC,IAAI,EAAE,IAAI,CAAC;SACtB,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC;SACpB,UAAU,CAAC,WAAW,EAAE,EAAE,CAAC;SAC3B,UAAU,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;AACjC,CAAC;AAXD,wDAWC;AAED,SAAgB,qBAAqB,CAAC,OAAe;IACnD,IAAA,yCAAqB,EAAC,OAAO,CAAC,CAAC;IAC/B,OAAO,IAAA,oBAAU,EAAC,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAAC;AACjD,CAAC;AAHD,sDAGC;AAED,SAAgB,wBAAwB,CAAC,OAAe;IACtD,IAAA,4CAAwB,EAAC,OAAO,CAAC,CAAC;IAClC,OAAO,OAAO,CAAC;AACjB,CAAC;AAHD,4DAGC;AAED,SAAgB,qBAAqB,CAAC,OAAe;IACnD,IAAA,yCAAqB,EAAC,OAAO,CAAC,CAAC;IAC/B,OAAO,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;AACrC,CAAC;AAHD,sDAGC;AAED,MAAM,UAAU,GAA2D;IACzE,CAAC,uBAAa,CAAC,MAAM,CAAC,EAAE,wBAAwB;IAChD,CAAC,uBAAa,CAAC,OAAO,CAAC,EAAE,yBAAyB;IAClD,CAAC,uBAAa,CAAC,GAAG,CAAC,EAAE,qBAAqB;IAC1C,CAAC,uBAAa,CAAC,IAAI,CAAC,EAAE,sBAAsB;IAC5C,CAAC,uBAAa,CAAC,GAAG,CAAC,EAAE,qBAAqB;CAC3C,CAAC;AAEF,SAAgB,kBAAkB,CAAC,OAAe,EAAE,SAAwB;IAC1E,MAAM,OAAO,GAAG,oBAAQ,CAAC,SAAS,CAAC,CAAC;IACpC,IAAI,CAAC,OAAO;QAAE,MAAM,IAAI,KAAK,CAAC,4BAA4B,SAAS,EAAE,CAAC,CAAC;IAEvE,MAAM,SAAS,GAAG,UAAU,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;IACpD,OAAO,SAAS,CAAC,OAAO,CAAC,CAAC;AAC5B,CAAC;AAND,gDAMC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isNativeAddressAliasSui(address: string): boolean;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isNativeAddressAliasSui = void 0;
|
|
4
|
+
const aliases = { sui: ['0x2::sui::SUI'] };
|
|
5
|
+
function isNativeAddressAliasSui(address) {
|
|
6
|
+
return aliases.sui.includes(address);
|
|
7
|
+
}
|
|
8
|
+
exports.isNativeAddressAliasSui = isNativeAddressAliasSui;
|
|
9
|
+
//# sourceMappingURL=isNativeAddressAlias.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isNativeAddressAlias.js","sourceRoot":"","sources":["../../../../../packages/core/src/utils/isNativeAddressAlias.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG,EAAE,GAAG,EAAE,CAAC,eAAe,CAAC,EAAE,CAAC;AAE3C,SAAgB,uBAAuB,CAAC,OAAe;IACrD,OAAO,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;AACvC,CAAC;AAFD,0DAEC"}
|
package/src/Lock.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export type Lock = StandardLock | UnbondingLock;
|
|
2
|
-
export type StandardLock = {
|
|
3
|
-
type: 'standard';
|
|
4
|
-
data: {
|
|
5
|
-
endTs: number;
|
|
6
|
-
};
|
|
7
|
-
};
|
|
8
|
-
export type UnbondingLock = {
|
|
9
|
-
type: 'unbonding';
|
|
10
|
-
data: {
|
|
11
|
-
periodMs: number;
|
|
12
|
-
startedTs?: number;
|
|
13
|
-
endTs?: number;
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
export declare const createUnbondingLock: (periodMs: number, startedTs?: number) => UnbondingLock;
|
|
17
|
-
export declare const createStandardLock: (endTs: number) => StandardLock;
|
package/src/Lock.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createStandardLock = exports.createUnbondingLock = void 0;
|
|
4
|
-
const createUnbondingLock = (periodMs, startedTs) => ({
|
|
5
|
-
type: 'unbonding',
|
|
6
|
-
data: {
|
|
7
|
-
periodMs,
|
|
8
|
-
startedTs: startedTs || undefined,
|
|
9
|
-
endTs: startedTs ? startedTs + periodMs : undefined,
|
|
10
|
-
},
|
|
11
|
-
});
|
|
12
|
-
exports.createUnbondingLock = createUnbondingLock;
|
|
13
|
-
const createStandardLock = (endTs) => ({
|
|
14
|
-
type: 'standard',
|
|
15
|
-
data: {
|
|
16
|
-
endTs,
|
|
17
|
-
},
|
|
18
|
-
});
|
|
19
|
-
exports.createStandardLock = createStandardLock;
|
|
20
|
-
//# sourceMappingURL=Lock.js.map
|
package/src/Lock.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Lock.js","sourceRoot":"","sources":["../../../../packages/core/src/Lock.ts"],"names":[],"mappings":";;;AAkBO,MAAM,mBAAmB,GAAG,CACjC,QAAgB,EAChB,SAAkB,EACH,EAAE,CAAC,CAAC;IACnB,IAAI,EAAE,WAAW;IACjB,IAAI,EAAE;QACJ,QAAQ;QACR,SAAS,EAAE,SAAS,IAAI,SAAS;QACjC,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,SAAS,GAAG,QAAQ,CAAC,CAAC,CAAC,SAAS;KACpD;CACF,CAAC,CAAC;AAVU,QAAA,mBAAmB,uBAU7B;AAEI,MAAM,kBAAkB,GAAG,CAAC,KAAa,EAAgB,EAAE,CAAC,CAAC;IAClE,IAAI,EAAE,UAAU;IAChB,IAAI,EAAE;QACJ,KAAK;KACN;CACF,CAAC,CAAC;AALU,QAAA,kBAAkB,sBAK5B"}
|
package/src/utils/isAnAlias.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function isASuiAlias(address: string): boolean;
|
package/src/utils/isAnAlias.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isASuiAlias = void 0;
|
|
4
|
-
const aliases = { sui: ['0x2::sui::SUI'] };
|
|
5
|
-
function isASuiAlias(address) {
|
|
6
|
-
return aliases.sui.includes(address);
|
|
7
|
-
}
|
|
8
|
-
exports.isASuiAlias = isASuiAlias;
|
|
9
|
-
//# sourceMappingURL=isAnAlias.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"isAnAlias.js","sourceRoot":"","sources":["../../../../../packages/core/src/utils/isAnAlias.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG,EAAE,GAAG,EAAE,CAAC,eAAe,CAAC,EAAE,CAAC;AAE3C,SAAgB,WAAW,CAAC,OAAe;IACzC,OAAO,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;AACvC,CAAC;AAFD,kCAEC"}
|