@streamflow/common 7.0.0-alpha.1 → 7.0.0-alpha.3
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/cjs/utils.js +14 -19
- package/dist/esm/solana/instructions.d.ts +2 -2
- package/dist/esm/utils.d.ts +9 -9
- package/dist/esm/utils.js +12 -15
- package/package.json +4 -5
package/dist/cjs/utils.js
CHANGED
|
@@ -39,34 +39,29 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
39
39
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
40
|
};
|
|
41
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
-
exports.sleep = exports.handleContractError = exports.
|
|
43
|
-
var
|
|
42
|
+
exports.sleep = exports.handleContractError = exports.getScaledBigNumber = exports.getNumberFromBigNumber = void 0;
|
|
43
|
+
var bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
44
44
|
var types_js_1 = require("./types.js");
|
|
45
45
|
/**
|
|
46
|
-
* Used for
|
|
47
|
-
* Get
|
|
48
|
-
* @param {
|
|
46
|
+
* Used for token amounts conversion from their Big Number representation to number.
|
|
47
|
+
* Get value in the highest units from BigNumber representation of the same value in the smallest units.
|
|
48
|
+
* @param {BigNumber} value - Big Number representation of value in the smallest units.
|
|
49
49
|
* @param {number} decimals - Number of decimals the token has.
|
|
50
50
|
*/
|
|
51
|
-
var
|
|
52
|
-
|
|
53
|
-
var integerPart = new bn_js_1.default(Math.trunc(value));
|
|
54
|
-
var decimalE = new bn_js_1.default(decimalPart * 1e9);
|
|
55
|
-
var sum = integerPart.mul(new bn_js_1.default(1e9)).add(decimalE);
|
|
56
|
-
var resultE = sum.mul(new bn_js_1.default(10).pow(new bn_js_1.default(decimals)));
|
|
57
|
-
return resultE.div(new bn_js_1.default(1e9));
|
|
51
|
+
var getNumberFromBigNumber = function (bigNum, decimals) {
|
|
52
|
+
return bigNum.div((0, bignumber_js_1.default)(10).pow(decimals)).toNumber();
|
|
58
53
|
};
|
|
59
|
-
exports.
|
|
54
|
+
exports.getNumberFromBigNumber = getNumberFromBigNumber;
|
|
60
55
|
/**
|
|
61
|
-
* Used for token amounts
|
|
62
|
-
* Get
|
|
63
|
-
* @param {
|
|
56
|
+
* Used for conversion of token amounts to their Big Number representation.
|
|
57
|
+
* Get Big Number representation in the smallest units from the same value in the highest units.
|
|
58
|
+
* @param {number} value - Number of tokens you want to convert to its BigNumber representation.
|
|
64
59
|
* @param {number} decimals - Number of decimals the token has.
|
|
65
60
|
*/
|
|
66
|
-
var
|
|
67
|
-
return
|
|
61
|
+
var getScaledBigNumber = function (value, decimals) {
|
|
62
|
+
return new bignumber_js_1.default(value).times(new bignumber_js_1.default(10).pow(decimals));
|
|
68
63
|
};
|
|
69
|
-
exports.
|
|
64
|
+
exports.getScaledBigNumber = getScaledBigNumber;
|
|
70
65
|
/**
|
|
71
66
|
* Used to make on chain calls to the contract and wrap raised errors if any
|
|
72
67
|
* @param func function that interacts with the contract
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { Connection, PublicKey, TransactionInstruction } from "@solana/web3.js";
|
|
2
|
-
import
|
|
3
|
-
export declare const prepareWrappedAccount: (connection: Connection, senderAddress: PublicKey, amount:
|
|
2
|
+
import BigNumber from "bignumber.js";
|
|
3
|
+
export declare const prepareWrappedAccount: (connection: Connection, senderAddress: PublicKey, amount: BigNumber) => Promise<TransactionInstruction[]>;
|
package/dist/esm/utils.d.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import
|
|
1
|
+
import BigNumber from "bignumber.js";
|
|
2
2
|
/**
|
|
3
|
-
* Used for
|
|
4
|
-
* Get
|
|
5
|
-
* @param {
|
|
3
|
+
* Used for token amounts conversion from their Big Number representation to number.
|
|
4
|
+
* Get value in the highest units from BigNumber representation of the same value in the smallest units.
|
|
5
|
+
* @param {BigNumber} value - Big Number representation of value in the smallest units.
|
|
6
6
|
* @param {number} decimals - Number of decimals the token has.
|
|
7
7
|
*/
|
|
8
|
-
export declare const
|
|
8
|
+
export declare const getNumberFromBigNumber: (bigNum: BigNumber, decimals: number) => number;
|
|
9
9
|
/**
|
|
10
|
-
* Used for token amounts
|
|
11
|
-
* Get
|
|
12
|
-
* @param {
|
|
10
|
+
* Used for conversion of token amounts to their Big Number representation.
|
|
11
|
+
* Get Big Number representation in the smallest units from the same value in the highest units.
|
|
12
|
+
* @param {number} value - Number of tokens you want to convert to its BigNumber representation.
|
|
13
13
|
* @param {number} decimals - Number of decimals the token has.
|
|
14
14
|
*/
|
|
15
|
-
export declare const
|
|
15
|
+
export declare const getScaledBigNumber: (value: number | string | BigNumber, decimals: number) => BigNumber;
|
|
16
16
|
/**
|
|
17
17
|
* Used to make on chain calls to the contract and wrap raised errors if any
|
|
18
18
|
* @param func function that interacts with the contract
|
package/dist/esm/utils.js
CHANGED
|
@@ -1,26 +1,23 @@
|
|
|
1
|
-
import
|
|
1
|
+
import BigNumber from "bignumber.js";
|
|
2
2
|
import { ContractError } from "./types.js";
|
|
3
3
|
/**
|
|
4
|
-
* Used for
|
|
5
|
-
* Get
|
|
6
|
-
* @param {
|
|
4
|
+
* Used for token amounts conversion from their Big Number representation to number.
|
|
5
|
+
* Get value in the highest units from BigNumber representation of the same value in the smallest units.
|
|
6
|
+
* @param {BigNumber} value - Big Number representation of value in the smallest units.
|
|
7
7
|
* @param {number} decimals - Number of decimals the token has.
|
|
8
8
|
*/
|
|
9
|
-
export const
|
|
10
|
-
|
|
11
|
-
const integerPart = new BN(Math.trunc(value));
|
|
12
|
-
const decimalE = new BN(decimalPart * 1e9);
|
|
13
|
-
const sum = integerPart.mul(new BN(1e9)).add(decimalE);
|
|
14
|
-
const resultE = sum.mul(new BN(10).pow(new BN(decimals)));
|
|
15
|
-
return resultE.div(new BN(1e9));
|
|
9
|
+
export const getNumberFromBigNumber = (bigNum, decimals) => {
|
|
10
|
+
return bigNum.div(BigNumber(10).pow(decimals)).toNumber();
|
|
16
11
|
};
|
|
17
12
|
/**
|
|
18
|
-
* Used for token amounts
|
|
19
|
-
* Get
|
|
20
|
-
* @param {
|
|
13
|
+
* Used for conversion of token amounts to their Big Number representation.
|
|
14
|
+
* Get Big Number representation in the smallest units from the same value in the highest units.
|
|
15
|
+
* @param {number} value - Number of tokens you want to convert to its BigNumber representation.
|
|
21
16
|
* @param {number} decimals - Number of decimals the token has.
|
|
22
17
|
*/
|
|
23
|
-
export const
|
|
18
|
+
export const getScaledBigNumber = (value, decimals) => {
|
|
19
|
+
return new BigNumber(value).times(new BigNumber(10).pow(decimals));
|
|
20
|
+
};
|
|
24
21
|
/**
|
|
25
22
|
* Used to make on chain calls to the contract and wrap raised errors if any
|
|
26
23
|
* @param func function that interacts with the contract
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@streamflow/common",
|
|
3
|
-
"version": "7.0.0-alpha.
|
|
3
|
+
"version": "7.0.0-alpha.3",
|
|
4
4
|
"description": "Common utilities and types used by streamflow packages.",
|
|
5
5
|
"homepage": "https://github.com/streamflow-finance/js-sdk/",
|
|
6
6
|
"main": "./dist/esm/index.js",
|
|
@@ -27,10 +27,9 @@
|
|
|
27
27
|
"lint-config": "eslint --print-config",
|
|
28
28
|
"prepublishOnly": "npm run lint && npm run build"
|
|
29
29
|
},
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "1f0ce4ebcbbf9ac79f744a7ef232543b9e6d2a5b",
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@streamflow/eslint-config": "7.0.0-alpha.
|
|
33
|
-
"@types/bn.js": "5.1.1",
|
|
32
|
+
"@streamflow/eslint-config": "7.0.0-alpha.3",
|
|
34
33
|
"date-fns": "2.28.0",
|
|
35
34
|
"typescript": "^4.9.5"
|
|
36
35
|
},
|
|
@@ -41,7 +40,7 @@
|
|
|
41
40
|
"@solana/wallet-adapter-base": "0.9.19",
|
|
42
41
|
"@solana/web3.js": "1.70.1",
|
|
43
42
|
"aptos": "1.4.0",
|
|
44
|
-
"
|
|
43
|
+
"bignumber.js": "^9.1.2",
|
|
45
44
|
"borsh": "^2.0.0",
|
|
46
45
|
"bs58": "5.0.0",
|
|
47
46
|
"p-queue": "^8.0.1"
|