@streamflow/common 6.5.0 → 7.0.0-alpha.10
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/{index.js → cjs/index.js} +2 -2
- package/dist/{solana → cjs/solana}/index.js +3 -3
- package/dist/cjs/solana/instructions.js +22 -0
- package/dist/cjs/solana/types.js +11 -0
- package/dist/cjs/solana/utils.js +443 -0
- package/dist/cjs/types.js +40 -0
- package/dist/cjs/utils.js +57 -0
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/solana/index.d.ts +3 -0
- package/dist/esm/solana/index.js +3 -0
- package/dist/{solana → esm/solana}/instructions.d.ts +2 -2
- package/dist/esm/solana/instructions.js +18 -0
- package/dist/esm/solana/types.js +7 -0
- package/dist/{solana → esm/solana}/utils.d.ts +1 -1
- package/dist/esm/solana/utils.js +416 -0
- package/dist/{types.d.ts → esm/types.d.ts} +1 -2
- package/dist/esm/types.js +38 -0
- package/dist/{utils.d.ts → esm/utils.d.ts} +9 -9
- package/dist/esm/utils.js +47 -0
- package/package.json +20 -20
- package/dist/index.d.ts +0 -2
- package/dist/solana/index.d.ts +0 -3
- package/dist/solana/instructions.js +0 -92
- package/dist/solana/types.js +0 -29
- package/dist/solana/utils.js +0 -754
- package/dist/types.js +0 -58
- package/dist/utils.js +0 -107
- /package/dist/{solana → esm/solana}/types.d.ts +0 -0
package/dist/types.js
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.ContractError = exports.IChain = exports.ICluster = void 0;
|
|
19
|
-
// Utility types
|
|
20
|
-
var ICluster;
|
|
21
|
-
(function (ICluster) {
|
|
22
|
-
ICluster["Mainnet"] = "mainnet";
|
|
23
|
-
ICluster["Devnet"] = "devnet";
|
|
24
|
-
ICluster["Testnet"] = "testnet";
|
|
25
|
-
ICluster["Local"] = "local";
|
|
26
|
-
})(ICluster = exports.ICluster || (exports.ICluster = {}));
|
|
27
|
-
var IChain;
|
|
28
|
-
(function (IChain) {
|
|
29
|
-
IChain["Solana"] = "Solana";
|
|
30
|
-
IChain["Aptos"] = "Aptos";
|
|
31
|
-
IChain["Ethereum"] = "Ethereum";
|
|
32
|
-
IChain["BNB"] = "BNB";
|
|
33
|
-
IChain["Polygon"] = "Polygon";
|
|
34
|
-
IChain["Sui"] = "Sui";
|
|
35
|
-
})(IChain = exports.IChain || (exports.IChain = {}));
|
|
36
|
-
/**
|
|
37
|
-
* Error wrapper for calls made to the contract on chain
|
|
38
|
-
*/
|
|
39
|
-
var ContractError = /** @class */ (function (_super) {
|
|
40
|
-
__extends(ContractError, _super);
|
|
41
|
-
/**
|
|
42
|
-
* Constructs the Error Wrapper
|
|
43
|
-
* @param error Original error raised probably by the chain SDK
|
|
44
|
-
* @param code extracted code from the error if managed to parse it
|
|
45
|
-
*/
|
|
46
|
-
function ContractError(error, code, description) {
|
|
47
|
-
var _this = _super.call(this, error.message) || this;
|
|
48
|
-
_this.contractErrorCode = code !== null && code !== void 0 ? code : null;
|
|
49
|
-
_this.description = description !== null && description !== void 0 ? description : null;
|
|
50
|
-
// Copy properties from the original error
|
|
51
|
-
Object.setPrototypeOf(_this, ContractError.prototype);
|
|
52
|
-
_this.name = "ContractError"; // Set the name property
|
|
53
|
-
_this.stack = error.stack;
|
|
54
|
-
return _this;
|
|
55
|
-
}
|
|
56
|
-
return ContractError;
|
|
57
|
-
}(Error));
|
|
58
|
-
exports.ContractError = ContractError;
|
package/dist/utils.js
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
-
};
|
|
41
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
-
exports.sleep = exports.handleContractError = exports.getNumberFromBN = exports.getBN = void 0;
|
|
43
|
-
var bn_js_1 = __importDefault(require("bn.js"));
|
|
44
|
-
var types_1 = require("./types");
|
|
45
|
-
/**
|
|
46
|
-
* Used for conversion of token amounts to their Big Number representation.
|
|
47
|
-
* Get Big Number representation in the smallest units from the same value in the highest units.
|
|
48
|
-
* @param {number} value - Number of tokens you want to convert to its BN representation.
|
|
49
|
-
* @param {number} decimals - Number of decimals the token has.
|
|
50
|
-
*/
|
|
51
|
-
var getBN = function (value, decimals) {
|
|
52
|
-
var decimalPart = value - Math.trunc(value);
|
|
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));
|
|
58
|
-
};
|
|
59
|
-
exports.getBN = getBN;
|
|
60
|
-
/**
|
|
61
|
-
* Used for token amounts conversion from their Big Number representation to number.
|
|
62
|
-
* Get value in the highest units from BN representation of the same value in the smallest units.
|
|
63
|
-
* @param {BN} value - Big Number representation of value in the smallest units.
|
|
64
|
-
* @param {number} decimals - Number of decimals the token has.
|
|
65
|
-
*/
|
|
66
|
-
var getNumberFromBN = function (value, decimals) {
|
|
67
|
-
return value.gt(new bn_js_1.default(Math.pow(2, 53) - 1)) ? value.div(new bn_js_1.default(Math.pow(10, decimals))).toNumber() : value.toNumber() / Math.pow(10, decimals);
|
|
68
|
-
};
|
|
69
|
-
exports.getNumberFromBN = getNumberFromBN;
|
|
70
|
-
/**
|
|
71
|
-
* Used to make on chain calls to the contract and wrap raised errors if any
|
|
72
|
-
* @param func function that interacts with the contract
|
|
73
|
-
* @param callback callback that may be used to extract error code
|
|
74
|
-
* @returns {T}
|
|
75
|
-
*/
|
|
76
|
-
function handleContractError(func, callback) {
|
|
77
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
78
|
-
var err_1;
|
|
79
|
-
return __generator(this, function (_a) {
|
|
80
|
-
switch (_a.label) {
|
|
81
|
-
case 0:
|
|
82
|
-
_a.trys.push([0, 2, , 3]);
|
|
83
|
-
return [4 /*yield*/, func()];
|
|
84
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
85
|
-
case 2:
|
|
86
|
-
err_1 = _a.sent();
|
|
87
|
-
if (err_1 instanceof Error) {
|
|
88
|
-
if (callback) {
|
|
89
|
-
throw new types_1.ContractError(err_1, callback(err_1));
|
|
90
|
-
}
|
|
91
|
-
throw new types_1.ContractError(err_1);
|
|
92
|
-
}
|
|
93
|
-
throw err_1;
|
|
94
|
-
case 3: return [2 /*return*/];
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
exports.handleContractError = handleContractError;
|
|
100
|
-
/**
|
|
101
|
-
* Pause async function execution for given amount of milliseconds
|
|
102
|
-
* @param ms millisecond to sleep for
|
|
103
|
-
*/
|
|
104
|
-
function sleep(ms) {
|
|
105
|
-
return new Promise(function (resolve) { return setTimeout(resolve, ms); });
|
|
106
|
-
}
|
|
107
|
-
exports.sleep = sleep;
|
|
File without changes
|