@streamflow/common 7.0.0-alpha.12 → 7.0.0-alpha.14
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/index.js +2 -1
- package/dist/cjs/lib/assertions.js +13 -0
- package/dist/cjs/{utils.js → lib/utils.js} +4 -2
- package/dist/cjs/solana/account-filters.js +19 -0
- package/dist/cjs/solana/index.js +2 -0
- package/dist/cjs/solana/public-key.js +8 -0
- package/dist/cjs/solana/utils.js +1 -1
- package/dist/esm/index.d.ts +2 -1
- package/dist/esm/index.js +2 -1
- package/dist/esm/lib/assertions.d.ts +1 -0
- package/dist/esm/lib/assertions.js +9 -0
- package/dist/esm/{utils.d.ts → lib/utils.d.ts} +1 -0
- package/dist/esm/{utils.js → lib/utils.js} +2 -1
- package/dist/esm/solana/account-filters.d.ts +2 -0
- package/dist/esm/solana/account-filters.js +15 -0
- package/dist/esm/solana/index.d.ts +2 -0
- package/dist/esm/solana/index.js +2 -0
- package/dist/esm/solana/public-key.d.ts +2 -0
- package/dist/esm/solana/public-key.js +4 -0
- package/dist/esm/solana/utils.js +1 -1
- package/package.json +3 -3
package/dist/cjs/index.js
CHANGED
|
@@ -15,4 +15,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./types.js"), exports);
|
|
18
|
-
__exportStar(require("./
|
|
18
|
+
__exportStar(require("./lib/assertions.js"), exports);
|
|
19
|
+
__exportStar(require("./lib/utils.js"), exports);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.invariant = void 0;
|
|
4
|
+
const prefix = "Assertion failed";
|
|
5
|
+
const invariant = (condition, message) => {
|
|
6
|
+
if (condition) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
const provided = typeof message === "function" ? message() : message;
|
|
10
|
+
const value = provided ? `${prefix}: ${provided}` : prefix;
|
|
11
|
+
throw new Error(value);
|
|
12
|
+
};
|
|
13
|
+
exports.invariant = invariant;
|
|
@@ -3,9 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.sleep = exports.handleContractError = exports.getNumberFromBN = exports.getBN = void 0;
|
|
6
|
+
exports.divCeilN = exports.sleep = exports.handleContractError = exports.getNumberFromBN = exports.getBN = void 0;
|
|
7
7
|
const bn_js_1 = __importDefault(require("bn.js"));
|
|
8
|
-
const types_js_1 = require("
|
|
8
|
+
const types_js_1 = require("../types.js");
|
|
9
9
|
/**
|
|
10
10
|
* Used for conversion of token amounts to their Big Number representation.
|
|
11
11
|
* Get Big Number representation in the smallest units from the same value in the highest units.
|
|
@@ -58,3 +58,5 @@ function sleep(ms) {
|
|
|
58
58
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
59
59
|
}
|
|
60
60
|
exports.sleep = sleep;
|
|
61
|
+
const divCeilN = (n, d) => n / d + (n % d ? BigInt(1) : BigInt(0));
|
|
62
|
+
exports.divCeilN = divCeilN;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getFilters = void 0;
|
|
4
|
+
const getFilters = (criteria, byteOffsets) => {
|
|
5
|
+
return Object.entries(criteria).reduce((acc, [key, value]) => {
|
|
6
|
+
const criteriaKey = key;
|
|
7
|
+
const effectiveByteOffset = byteOffsets[criteriaKey];
|
|
8
|
+
if (criteria[criteriaKey] && effectiveByteOffset) {
|
|
9
|
+
acc.push({
|
|
10
|
+
memcmp: {
|
|
11
|
+
offset: effectiveByteOffset,
|
|
12
|
+
bytes: value.toString(),
|
|
13
|
+
},
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return acc;
|
|
17
|
+
}, []);
|
|
18
|
+
};
|
|
19
|
+
exports.getFilters = getFilters;
|
package/dist/cjs/solana/index.js
CHANGED
|
@@ -14,6 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./account-filters.js"), exports);
|
|
17
18
|
__exportStar(require("./instructions.js"), exports);
|
|
19
|
+
__exportStar(require("./public-key.js"), exports);
|
|
18
20
|
__exportStar(require("./types.js"), exports);
|
|
19
21
|
__exportStar(require("./utils.js"), exports);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.pk = void 0;
|
|
4
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
5
|
+
const pk = (address) => {
|
|
6
|
+
return typeof address === "string" ? new web3_js_1.PublicKey(address) : address;
|
|
7
|
+
};
|
|
8
|
+
exports.pk = pk;
|
package/dist/cjs/solana/utils.js
CHANGED
|
@@ -9,7 +9,7 @@ const web3_js_1 = require("@solana/web3.js");
|
|
|
9
9
|
const bs58_1 = __importDefault(require("bs58"));
|
|
10
10
|
const p_queue_1 = __importDefault(require("p-queue"));
|
|
11
11
|
const types_js_1 = require("./types.js");
|
|
12
|
-
const utils_js_1 = require("../utils.js");
|
|
12
|
+
const utils_js_1 = require("../lib/utils.js");
|
|
13
13
|
const SIMULATE_TRIES = 3;
|
|
14
14
|
const buildSendThrottler = (sendRate) => {
|
|
15
15
|
return new p_queue_1.default({ concurrency: sendRate, intervalCap: 1, interval: 1000 });
|
package/dist/esm/index.d.ts
CHANGED
package/dist/esm/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const invariant: (condition: any, message?: string | (() => string)) => asserts condition;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const prefix = "Assertion failed";
|
|
2
|
+
export const invariant = (condition, message) => {
|
|
3
|
+
if (condition) {
|
|
4
|
+
return;
|
|
5
|
+
}
|
|
6
|
+
const provided = typeof message === "function" ? message() : message;
|
|
7
|
+
const value = provided ? `${prefix}: ${provided}` : prefix;
|
|
8
|
+
throw new Error(value);
|
|
9
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import BN from "bn.js";
|
|
2
|
-
import { ContractError } from "
|
|
2
|
+
import { ContractError } from "../types.js";
|
|
3
3
|
/**
|
|
4
4
|
* Used for conversion of token amounts to their Big Number representation.
|
|
5
5
|
* Get Big Number representation in the smallest units from the same value in the highest units.
|
|
@@ -48,3 +48,4 @@ export async function handleContractError(func, callback) {
|
|
|
48
48
|
export function sleep(ms) {
|
|
49
49
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
50
50
|
}
|
|
51
|
+
export const divCeilN = (n, d) => n / d + (n % d ? BigInt(1) : BigInt(0));
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export const getFilters = (criteria, byteOffsets) => {
|
|
2
|
+
return Object.entries(criteria).reduce((acc, [key, value]) => {
|
|
3
|
+
const criteriaKey = key;
|
|
4
|
+
const effectiveByteOffset = byteOffsets[criteriaKey];
|
|
5
|
+
if (criteria[criteriaKey] && effectiveByteOffset) {
|
|
6
|
+
acc.push({
|
|
7
|
+
memcmp: {
|
|
8
|
+
offset: effectiveByteOffset,
|
|
9
|
+
bytes: value.toString(),
|
|
10
|
+
},
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
return acc;
|
|
14
|
+
}, []);
|
|
15
|
+
};
|
package/dist/esm/solana/index.js
CHANGED
package/dist/esm/solana/utils.js
CHANGED
|
@@ -3,7 +3,7 @@ import { ComputeBudgetProgram, Keypair, TransactionMessage, VersionedTransaction
|
|
|
3
3
|
import bs58 from "bs58";
|
|
4
4
|
import PQueue from "p-queue";
|
|
5
5
|
import { TransactionFailedError, } from "./types.js";
|
|
6
|
-
import { sleep } from "../utils.js";
|
|
6
|
+
import { sleep } from "../lib/utils.js";
|
|
7
7
|
const SIMULATE_TRIES = 3;
|
|
8
8
|
export const buildSendThrottler = (sendRate) => {
|
|
9
9
|
return new PQueue({ concurrency: sendRate, intervalCap: 1, interval: 1000 });
|
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.14",
|
|
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,9 +27,9 @@
|
|
|
27
27
|
"lint-config": "eslint --print-config",
|
|
28
28
|
"prepublishOnly": "npm run lint && npm run build"
|
|
29
29
|
},
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "ce9df65df6f69ceac7a2ae4f3404060659ada89b",
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@streamflow/eslint-config": "7.0.0-alpha.
|
|
32
|
+
"@streamflow/eslint-config": "7.0.0-alpha.14",
|
|
33
33
|
"@types/bn.js": "5.1.1",
|
|
34
34
|
"date-fns": "2.28.0",
|
|
35
35
|
"typescript": "^4.9.5"
|