@super-protocol/sdk-js 0.12.8-beta.2 → 0.13.0-beta.0
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/build/TIIGenerator.js +16 -14
- package/build/connectors/BlockchainConnector.d.ts +1 -1
- package/build/connectors/BlockchainConnector.js +6 -4
- package/build/contracts/app.json +3581 -1393
- package/build/crypto/Crypto.d.ts +3 -3
- package/build/crypto/Crypto.js +3 -3
- package/build/crypto/nodejs/AES.d.ts +1 -1
- package/build/crypto/nodejs/AES.js +1 -1
- package/build/crypto/nodejs/ARIA.d.ts +1 -1
- package/build/crypto/nodejs/ARIA.js +1 -1
- package/build/index.d.ts +15 -15
- package/build/index.js +20 -22
- package/build/models/Offer.d.ts +47 -4
- package/build/models/Offer.js +159 -21
- package/build/models/Order.d.ts +29 -17
- package/build/models/Order.js +103 -74
- package/build/models/Provider.js +4 -2
- package/build/models/TeeOffer.d.ts +92 -11
- package/build/models/TeeOffer.js +305 -53
- package/build/providers/storage/ChunksDownloadDecorator.d.ts +0 -2
- package/build/providers/storage/ChunksDownloadDecorator.js +0 -3
- package/build/providers/storage/IStorageProvider.d.ts +0 -2
- package/build/providers/storage/StorjStorageProvider.d.ts +0 -2
- package/build/providers/storage/StorjStorageProvider.js +0 -15
- package/build/staticModels/Deposits.d.ts +71 -0
- package/build/staticModels/Deposits.js +303 -0
- package/build/staticModels/Offers.d.ts +58 -0
- package/build/staticModels/{OffersFactory.js → Offers.js} +115 -14
- package/build/staticModels/{OrdersFactory.d.ts → Orders.d.ts} +36 -43
- package/build/staticModels/{OrdersFactory.js → Orders.js} +103 -125
- package/build/staticModels/ProviderRegistry.d.ts +1 -1
- package/build/staticModels/ProviderRegistry.js +1 -1
- package/build/staticModels/Superpro.d.ts +2 -2
- package/build/staticModels/Superpro.js +1 -1
- package/build/staticModels/TeeOffers.d.ts +101 -0
- package/build/staticModels/TeeOffers.js +455 -0
- package/build/types/DepositInfo.d.ts +10 -0
- package/build/types/DepositInfo.js +9 -0
- package/build/types/Events.d.ts +0 -12
- package/build/types/HardwareInfo.d.ts +19 -0
- package/build/types/HardwareInfo.js +10 -0
- package/build/types/Offer.d.ts +0 -7
- package/build/types/Offer.js +0 -3
- package/build/types/OptionInfo.d.ts +10 -0
- package/build/types/OptionInfo.js +9 -0
- package/build/types/Order.d.ts +5 -1
- package/build/types/SlotInfo.d.ts +12 -0
- package/build/types/SlotInfo.js +10 -0
- package/build/types/SlotUsage.d.ts +16 -0
- package/build/types/SlotUsage.js +15 -0
- package/build/types/Superpro.d.ts +0 -14
- package/build/types/Superpro.js +1 -16
- package/build/types/TeeOfferInfo.d.ts +31 -0
- package/build/types/{TeeOffer.js → TeeOfferInfo.js} +2 -4
- package/build/types/TeeOfferOption.d.ts +21 -0
- package/build/types/TeeOfferOption.js +11 -0
- package/build/types/TeeOfferSlot.d.ts +22 -0
- package/build/types/TeeOfferSlot.js +11 -0
- package/build/types/ValueOfferSlot.d.ts +29 -0
- package/build/types/ValueOfferSlot.js +13 -0
- package/build/utils.d.ts +1 -0
- package/build/utils.js +5 -1
- package/package.json +1 -1
- package/build/models/Ballot.d.ts +0 -13
- package/build/models/Ballot.js +0 -70
- package/build/staticModels/OffersFactory.d.ts +0 -32
- package/build/staticModels/Staking.d.ts +0 -20
- package/build/staticModels/Staking.js +0 -116
- package/build/staticModels/TeeOffersFactory.d.ts +0 -36
- package/build/staticModels/TeeOffersFactory.js +0 -211
- package/build/staticModels/Voting.d.ts +0 -29
- package/build/staticModels/Voting.js +0 -91
- package/build/types/Ballot.d.ts +0 -75
- package/build/types/Ballot.js +0 -49
- package/build/types/Staking.d.ts +0 -27
- package/build/types/Staking.js +0 -22
- package/build/types/TeeOffer.d.ts +0 -25
package/build/crypto/Crypto.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ declare class Crypto {
|
|
|
8
8
|
* @param content - string data to encrypt
|
|
9
9
|
* @param key - key in string format (default encoding base64)
|
|
10
10
|
* @param encoding - encoding of key and output data
|
|
11
|
-
* @
|
|
11
|
+
* @returns {Promise<Encryption>} - object what contains encrypted data, key and spec to decryption
|
|
12
12
|
*/
|
|
13
13
|
static encrypt(content: string, encryption: Encryption): Promise<Encryption>;
|
|
14
14
|
/**
|
|
@@ -17,13 +17,13 @@ declare class Crypto {
|
|
|
17
17
|
* @param outputStream - place where it will be saved
|
|
18
18
|
* @param algorithm - file encryption algorithm
|
|
19
19
|
* @param key – key that will be used to encrypt data
|
|
20
|
-
* @
|
|
20
|
+
* @returns {Promise<Encryption>} - encryption info
|
|
21
21
|
*/
|
|
22
22
|
static encryptStream(inputStream: fs.ReadStream, outputStream: fs.WriteStream, encryption: Encryption): Promise<Encryption>;
|
|
23
23
|
/**
|
|
24
24
|
* Used to decrypt data from blockchain
|
|
25
25
|
* @param encryption - object what contains encrypted data, key and spec to decryption
|
|
26
|
-
* @
|
|
26
|
+
* @returns {Promise<string>} - decrypted string
|
|
27
27
|
*/
|
|
28
28
|
static decrypt(encryption: Encryption): Promise<string>;
|
|
29
29
|
/**
|
package/build/crypto/Crypto.js
CHANGED
|
@@ -53,7 +53,7 @@ var Crypto = /** @class */ (function () {
|
|
|
53
53
|
* @param content - string data to encrypt
|
|
54
54
|
* @param key - key in string format (default encoding base64)
|
|
55
55
|
* @param encoding - encoding of key and output data
|
|
56
|
-
* @
|
|
56
|
+
* @returns {Promise<Encryption>} - object what contains encrypted data, key and spec to decryption
|
|
57
57
|
*/
|
|
58
58
|
Crypto.encrypt = function (content, encryption) {
|
|
59
59
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -88,7 +88,7 @@ var Crypto = /** @class */ (function () {
|
|
|
88
88
|
* @param outputStream - place where it will be saved
|
|
89
89
|
* @param algorithm - file encryption algorithm
|
|
90
90
|
* @param key – key that will be used to encrypt data
|
|
91
|
-
* @
|
|
91
|
+
* @returns {Promise<Encryption>} - encryption info
|
|
92
92
|
*/
|
|
93
93
|
Crypto.encryptStream = function (inputStream, outputStream, encryption) {
|
|
94
94
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -117,7 +117,7 @@ var Crypto = /** @class */ (function () {
|
|
|
117
117
|
/**
|
|
118
118
|
* Used to decrypt data from blockchain
|
|
119
119
|
* @param encryption - object what contains encrypted data, key and spec to decryption
|
|
120
|
-
* @
|
|
120
|
+
* @returns {Promise<string>} - decrypted string
|
|
121
121
|
*/
|
|
122
122
|
Crypto.decrypt = function (encryption) {
|
|
123
123
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -9,7 +9,7 @@ declare class AES {
|
|
|
9
9
|
* @param outputStream - place where it will be saved
|
|
10
10
|
* @param algorithm - file encryption algorithm
|
|
11
11
|
* @param key – key that will be used to encrypt data
|
|
12
|
-
* @
|
|
12
|
+
* @returns {Promise<Encryption>} - encryption info
|
|
13
13
|
*/
|
|
14
14
|
static encryptStream(inputStream: ReadStream, outputStream: WriteStream, encryption: Encryption): Promise<AESEncryption>;
|
|
15
15
|
static decrypt(encryption: AESEncryption): Promise<string>;
|
|
@@ -70,7 +70,7 @@ var AES = /** @class */ (function () {
|
|
|
70
70
|
* @param outputStream - place where it will be saved
|
|
71
71
|
* @param algorithm - file encryption algorithm
|
|
72
72
|
* @param key – key that will be used to encrypt data
|
|
73
|
-
* @
|
|
73
|
+
* @returns {Promise<Encryption>} - encryption info
|
|
74
74
|
*/
|
|
75
75
|
AES.encryptStream = function (inputStream, outputStream, encryption) {
|
|
76
76
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -9,7 +9,7 @@ declare class ARIA {
|
|
|
9
9
|
* @param outputStream - place where it will be saved
|
|
10
10
|
* @param algorithm - file encryption algorithm
|
|
11
11
|
* @param key – key that will be used to encrypt data
|
|
12
|
-
* @
|
|
12
|
+
* @returns {Promise<Encryption>} - encryption info
|
|
13
13
|
*/
|
|
14
14
|
static encryptStream(inputStream: ReadStream, outputStream: WriteStream, encryption: Encryption): Promise<ARIAEncryption>;
|
|
15
15
|
static decrypt(encryption: ARIAEncryption): Promise<string>;
|
|
@@ -70,7 +70,7 @@ var ARIA = /** @class */ (function () {
|
|
|
70
70
|
* @param outputStream - place where it will be saved
|
|
71
71
|
* @param algorithm - file encryption algorithm
|
|
72
72
|
* @param key – key that will be used to encrypt data
|
|
73
|
-
* @
|
|
73
|
+
* @returns {Promise<Encryption>} - encryption info
|
|
74
74
|
*/
|
|
75
75
|
ARIA.encryptStream = function (inputStream, outputStream, encryption) {
|
|
76
76
|
return __awaiter(this, void 0, void 0, function () {
|
package/build/index.d.ts
CHANGED
|
@@ -8,28 +8,26 @@ export { default as TIIGenerator } from "./TIIGenerator";
|
|
|
8
8
|
export * from "./TIIGenerator";
|
|
9
9
|
export { default as Consensus } from "./staticModels/Consensus";
|
|
10
10
|
export * from "./staticModels/Consensus";
|
|
11
|
-
export { default as
|
|
12
|
-
export * from "./staticModels/
|
|
11
|
+
export { default as Orders } from "./staticModels/Orders";
|
|
12
|
+
export * from "./staticModels/Orders";
|
|
13
13
|
export { default as ActiveOrders } from "./staticModels/ActiveOrders";
|
|
14
14
|
export * from "./staticModels/ActiveOrders";
|
|
15
15
|
export { default as ActiveOffers } from "./staticModels/ActiveOffers";
|
|
16
16
|
export * from "./staticModels/ActiveOffers";
|
|
17
|
-
export { default as
|
|
18
|
-
export * from "./staticModels/
|
|
19
|
-
export { default as
|
|
20
|
-
export * from "./staticModels/
|
|
17
|
+
export { default as Offers } from "./staticModels/Offers";
|
|
18
|
+
export * from "./staticModels/Offers";
|
|
19
|
+
export { default as TeeOffers } from "./staticModels/TeeOffers";
|
|
20
|
+
export * from "./staticModels/TeeOffers";
|
|
21
21
|
export { default as ProviderRegistry } from "./staticModels/ProviderRegistry";
|
|
22
22
|
export * from "./staticModels/ProviderRegistry";
|
|
23
|
-
export { default as Staking } from "./staticModels/Staking";
|
|
24
|
-
export * from "./staticModels/Staking";
|
|
25
|
-
export { default as Voting } from "./staticModels/Voting";
|
|
26
|
-
export * from "./staticModels/Voting";
|
|
27
23
|
export { default as SuperproToken } from "./staticModels/SuperproToken";
|
|
28
24
|
export * from "./staticModels/SuperproToken";
|
|
29
25
|
export { default as Superpro } from "./staticModels/Superpro";
|
|
30
26
|
export * from "./staticModels/Superpro";
|
|
31
27
|
export { default as Marks } from "./staticModels/Marks";
|
|
32
28
|
export * from "./staticModels/Marks";
|
|
29
|
+
export { default as Deposits } from "./staticModels/Deposits";
|
|
30
|
+
export * from "./staticModels/Deposits";
|
|
33
31
|
export { default as Order } from "./models/Order";
|
|
34
32
|
export * from "./models/Order";
|
|
35
33
|
export { default as Provider } from "./models/Provider";
|
|
@@ -38,17 +36,19 @@ export { default as TeeOffer } from "./models/TeeOffer";
|
|
|
38
36
|
export * from "./models/TeeOffer";
|
|
39
37
|
export { default as Offer } from "./models/Offer";
|
|
40
38
|
export * from "./models/Offer";
|
|
41
|
-
export { default as Ballot } from "./models/Ballot";
|
|
42
|
-
export * from "./models/Ballot";
|
|
43
39
|
export { default as TCB } from "./models/TCB";
|
|
44
40
|
export * from "./models/TCB";
|
|
45
41
|
export * from "./types/Offer";
|
|
46
42
|
export * from "./types/Marks";
|
|
47
43
|
export * from "./types/Order";
|
|
48
|
-
export * from "./types/
|
|
44
|
+
export * from "./types/TeeOfferInfo";
|
|
45
|
+
export * from "./types/HardwareInfo";
|
|
46
|
+
export * from "./types/SlotInfo";
|
|
47
|
+
export * from "./types/SlotUsage";
|
|
48
|
+
export * from "./types/OptionInfo";
|
|
49
|
+
export * from "./types/TeeOfferOption";
|
|
50
|
+
export * from "./types/TeeOfferSlot";
|
|
49
51
|
export * from "./types/Provider";
|
|
50
|
-
export * from "./types/Staking";
|
|
51
|
-
export * from "./types/Ballot";
|
|
52
52
|
export * from "./types/Superpro";
|
|
53
53
|
export * from "./types/Consensus";
|
|
54
54
|
export * from "./types/Origins";
|
package/build/index.js
CHANGED
|
@@ -29,7 +29,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
29
29
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
30
30
|
};
|
|
31
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
-
exports.getStorageProvider = exports.ChunkedStorageProvider = exports.TCB = exports.
|
|
32
|
+
exports.getStorageProvider = exports.ChunkedStorageProvider = exports.TCB = exports.Offer = exports.TeeOffer = exports.Provider = exports.Order = exports.Deposits = exports.Marks = exports.Superpro = exports.SuperproToken = exports.ProviderRegistry = exports.TeeOffers = exports.Offers = exports.ActiveOffers = exports.ActiveOrders = exports.Orders = exports.Consensus = exports.TIIGenerator = exports.Crypto = exports.BlockchainEventsListener = void 0;
|
|
33
33
|
var BlockchainConnector_1 = __importDefault(require("./connectors/BlockchainConnector"));
|
|
34
34
|
exports.default = BlockchainConnector_1.default;
|
|
35
35
|
__exportStar(require("./connectors/BlockchainConnector"), exports);
|
|
@@ -43,30 +43,24 @@ __exportStar(require("./TIIGenerator"), exports);
|
|
|
43
43
|
var Consensus_1 = require("./staticModels/Consensus");
|
|
44
44
|
Object.defineProperty(exports, "Consensus", { enumerable: true, get: function () { return __importDefault(Consensus_1).default; } });
|
|
45
45
|
__exportStar(require("./staticModels/Consensus"), exports);
|
|
46
|
-
var
|
|
47
|
-
Object.defineProperty(exports, "
|
|
48
|
-
__exportStar(require("./staticModels/
|
|
46
|
+
var Orders_1 = require("./staticModels/Orders");
|
|
47
|
+
Object.defineProperty(exports, "Orders", { enumerable: true, get: function () { return __importDefault(Orders_1).default; } });
|
|
48
|
+
__exportStar(require("./staticModels/Orders"), exports);
|
|
49
49
|
var ActiveOrders_1 = require("./staticModels/ActiveOrders");
|
|
50
50
|
Object.defineProperty(exports, "ActiveOrders", { enumerable: true, get: function () { return __importDefault(ActiveOrders_1).default; } });
|
|
51
51
|
__exportStar(require("./staticModels/ActiveOrders"), exports);
|
|
52
52
|
var ActiveOffers_1 = require("./staticModels/ActiveOffers");
|
|
53
53
|
Object.defineProperty(exports, "ActiveOffers", { enumerable: true, get: function () { return __importDefault(ActiveOffers_1).default; } });
|
|
54
54
|
__exportStar(require("./staticModels/ActiveOffers"), exports);
|
|
55
|
-
var
|
|
56
|
-
Object.defineProperty(exports, "
|
|
57
|
-
__exportStar(require("./staticModels/
|
|
58
|
-
var
|
|
59
|
-
Object.defineProperty(exports, "
|
|
60
|
-
__exportStar(require("./staticModels/
|
|
55
|
+
var Offers_1 = require("./staticModels/Offers");
|
|
56
|
+
Object.defineProperty(exports, "Offers", { enumerable: true, get: function () { return __importDefault(Offers_1).default; } });
|
|
57
|
+
__exportStar(require("./staticModels/Offers"), exports);
|
|
58
|
+
var TeeOffers_1 = require("./staticModels/TeeOffers");
|
|
59
|
+
Object.defineProperty(exports, "TeeOffers", { enumerable: true, get: function () { return __importDefault(TeeOffers_1).default; } });
|
|
60
|
+
__exportStar(require("./staticModels/TeeOffers"), exports);
|
|
61
61
|
var ProviderRegistry_1 = require("./staticModels/ProviderRegistry");
|
|
62
62
|
Object.defineProperty(exports, "ProviderRegistry", { enumerable: true, get: function () { return __importDefault(ProviderRegistry_1).default; } });
|
|
63
63
|
__exportStar(require("./staticModels/ProviderRegistry"), exports);
|
|
64
|
-
var Staking_1 = require("./staticModels/Staking");
|
|
65
|
-
Object.defineProperty(exports, "Staking", { enumerable: true, get: function () { return __importDefault(Staking_1).default; } });
|
|
66
|
-
__exportStar(require("./staticModels/Staking"), exports);
|
|
67
|
-
var Voting_1 = require("./staticModels/Voting");
|
|
68
|
-
Object.defineProperty(exports, "Voting", { enumerable: true, get: function () { return __importDefault(Voting_1).default; } });
|
|
69
|
-
__exportStar(require("./staticModels/Voting"), exports);
|
|
70
64
|
var SuperproToken_1 = require("./staticModels/SuperproToken");
|
|
71
65
|
Object.defineProperty(exports, "SuperproToken", { enumerable: true, get: function () { return __importDefault(SuperproToken_1).default; } });
|
|
72
66
|
__exportStar(require("./staticModels/SuperproToken"), exports);
|
|
@@ -76,6 +70,9 @@ __exportStar(require("./staticModels/Superpro"), exports);
|
|
|
76
70
|
var Marks_1 = require("./staticModels/Marks");
|
|
77
71
|
Object.defineProperty(exports, "Marks", { enumerable: true, get: function () { return __importDefault(Marks_1).default; } });
|
|
78
72
|
__exportStar(require("./staticModels/Marks"), exports);
|
|
73
|
+
var Deposits_1 = require("./staticModels/Deposits");
|
|
74
|
+
Object.defineProperty(exports, "Deposits", { enumerable: true, get: function () { return __importDefault(Deposits_1).default; } });
|
|
75
|
+
__exportStar(require("./staticModels/Deposits"), exports);
|
|
79
76
|
var Order_1 = require("./models/Order");
|
|
80
77
|
Object.defineProperty(exports, "Order", { enumerable: true, get: function () { return __importDefault(Order_1).default; } });
|
|
81
78
|
__exportStar(require("./models/Order"), exports);
|
|
@@ -88,19 +85,20 @@ __exportStar(require("./models/TeeOffer"), exports);
|
|
|
88
85
|
var Offer_1 = require("./models/Offer");
|
|
89
86
|
Object.defineProperty(exports, "Offer", { enumerable: true, get: function () { return __importDefault(Offer_1).default; } });
|
|
90
87
|
__exportStar(require("./models/Offer"), exports);
|
|
91
|
-
var Ballot_1 = require("./models/Ballot");
|
|
92
|
-
Object.defineProperty(exports, "Ballot", { enumerable: true, get: function () { return __importDefault(Ballot_1).default; } });
|
|
93
|
-
__exportStar(require("./models/Ballot"), exports);
|
|
94
88
|
var TCB_1 = require("./models/TCB");
|
|
95
89
|
Object.defineProperty(exports, "TCB", { enumerable: true, get: function () { return __importDefault(TCB_1).default; } });
|
|
96
90
|
__exportStar(require("./models/TCB"), exports);
|
|
97
91
|
__exportStar(require("./types/Offer"), exports);
|
|
98
92
|
__exportStar(require("./types/Marks"), exports);
|
|
99
93
|
__exportStar(require("./types/Order"), exports);
|
|
100
|
-
__exportStar(require("./types/
|
|
94
|
+
__exportStar(require("./types/TeeOfferInfo"), exports);
|
|
95
|
+
__exportStar(require("./types/HardwareInfo"), exports);
|
|
96
|
+
__exportStar(require("./types/SlotInfo"), exports);
|
|
97
|
+
__exportStar(require("./types/SlotUsage"), exports);
|
|
98
|
+
__exportStar(require("./types/OptionInfo"), exports);
|
|
99
|
+
__exportStar(require("./types/TeeOfferOption"), exports);
|
|
100
|
+
__exportStar(require("./types/TeeOfferSlot"), exports);
|
|
101
101
|
__exportStar(require("./types/Provider"), exports);
|
|
102
|
-
__exportStar(require("./types/Staking"), exports);
|
|
103
|
-
__exportStar(require("./types/Ballot"), exports);
|
|
104
102
|
__exportStar(require("./types/Superpro"), exports);
|
|
105
103
|
__exportStar(require("./types/Consensus"), exports);
|
|
106
104
|
__exportStar(require("./types/Origins"), exports);
|
package/build/models/Offer.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { OfferInfo, OfferType } from "../types/Offer";
|
|
2
2
|
import { TransactionOptions } from "../types/Web3";
|
|
3
3
|
import { Origins } from "../types/Origins";
|
|
4
|
+
import { ValueOfferSlot } from "../types/ValueOfferSlot";
|
|
5
|
+
import { SlotInfo } from "../types/SlotInfo";
|
|
6
|
+
import { OptionInfo } from "../types/OptionInfo";
|
|
7
|
+
import { SlotUsage } from "../types/SlotUsage";
|
|
4
8
|
declare class Offer {
|
|
5
9
|
private static contract;
|
|
6
10
|
private logger;
|
|
@@ -12,7 +16,7 @@ declare class Offer {
|
|
|
12
16
|
id: string;
|
|
13
17
|
enabled?: boolean;
|
|
14
18
|
closingPrice?: string;
|
|
15
|
-
|
|
19
|
+
minDeposit?: string;
|
|
16
20
|
constructor(offerId: string);
|
|
17
21
|
/**
|
|
18
22
|
* Checks if contract has been initialized, if not - initialize contract
|
|
@@ -63,12 +67,51 @@ declare class Offer {
|
|
|
63
67
|
/**
|
|
64
68
|
* Function for fetching offer hold deposit
|
|
65
69
|
*/
|
|
66
|
-
|
|
70
|
+
getMinDeposit(slotId: number, slotCount: number, optionsIds: number[], optionsCount: number[]): Promise<string>;
|
|
67
71
|
/**
|
|
68
|
-
* Function for offer
|
|
72
|
+
* Function for fetching cheapest value offer from blockchain
|
|
69
73
|
*/
|
|
70
|
-
|
|
74
|
+
getCheapestPrice(): Promise<string>;
|
|
71
75
|
isOfferExists(): Promise<boolean>;
|
|
76
|
+
/**
|
|
77
|
+
* Function for fetching whether offer slot exists or not
|
|
78
|
+
* @param slotId - Slot ID
|
|
79
|
+
*/
|
|
80
|
+
isSlotExists(slotId: string): Promise<boolean>;
|
|
81
|
+
/**
|
|
82
|
+
* Function for fetching offer slot by id
|
|
83
|
+
* @param slotId - Slot ID
|
|
84
|
+
*/
|
|
85
|
+
getSlotById(slotId: string): Promise<ValueOfferSlot>;
|
|
86
|
+
/**
|
|
87
|
+
* Function for fetching offer slots info from blockchain
|
|
88
|
+
* @param begin - The first element of range.
|
|
89
|
+
* @param end - One past the final element in the range.
|
|
90
|
+
* @returns {Promise<ValueOfferSlot[]>}
|
|
91
|
+
*/
|
|
92
|
+
getSlots(begin: number, end: number): Promise<ValueOfferSlot[]>;
|
|
93
|
+
/**
|
|
94
|
+
* Function for add slot usage to the value offer
|
|
95
|
+
* @param slotInfo - slot info
|
|
96
|
+
* @param optionInfo - option info
|
|
97
|
+
* @param slotUsage - slot usage info
|
|
98
|
+
* @param transactionOptions - object what contains alternative action account or gas limit (optional)
|
|
99
|
+
*/
|
|
100
|
+
addSlot(slotInfo: SlotInfo, optionInfo: OptionInfo, slotUsage: SlotUsage, externalId?: string, transactionOptions?: TransactionOptions): Promise<void>;
|
|
101
|
+
/**
|
|
102
|
+
* Function for update slot usage of value offer
|
|
103
|
+
* @param slotInfo - new slot info
|
|
104
|
+
* @param optionInfo - new option info
|
|
105
|
+
* @param slotUsage - new slot usage info
|
|
106
|
+
* @param transactionOptions - object what contains alternative action account or gas limit (optional)
|
|
107
|
+
*/
|
|
108
|
+
updateSlot(slotId: string, newSlotInfo: SlotInfo, newOptionInfo: OptionInfo, newUsage: SlotUsage, transactionOptions?: TransactionOptions): Promise<void>;
|
|
109
|
+
/**
|
|
110
|
+
* Function for delete slot usage from offer
|
|
111
|
+
* @param slotId - Slot ID
|
|
112
|
+
* @param transactionOptions - object what contains alternative action account or gas limit (optional)
|
|
113
|
+
*/
|
|
114
|
+
deleteSlot(slotId: string, transactionOptions?: TransactionOptions): Promise<void>;
|
|
72
115
|
/**
|
|
73
116
|
* Function for disabling offer
|
|
74
117
|
* @param transactionOptions - object what contains alternative action account or gas limit (optional)
|
package/build/models/Offer.js
CHANGED
|
@@ -53,13 +53,21 @@ var Origins_1 = require("../types/Origins");
|
|
|
53
53
|
var BlockchainConnector_1 = __importDefault(require("../connectors/BlockchainConnector"));
|
|
54
54
|
var Superpro_1 = __importDefault(require("../staticModels/Superpro"));
|
|
55
55
|
var TxManager_1 = __importDefault(require("../utils/TxManager"));
|
|
56
|
+
var ValueOfferSlot_1 = require("../types/ValueOfferSlot");
|
|
57
|
+
var SlotInfo_1 = require("../types/SlotInfo");
|
|
58
|
+
var OptionInfo_1 = require("../types/OptionInfo");
|
|
59
|
+
var SlotUsage_1 = require("../types/SlotUsage");
|
|
60
|
+
var utils_2 = require("ethers/lib/utils");
|
|
56
61
|
var Offer = /** @class */ (function () {
|
|
57
62
|
function Offer(offerId) {
|
|
58
63
|
this.id = offerId;
|
|
59
64
|
if (!Offer.contract) {
|
|
60
65
|
Offer.contract = BlockchainConnector_1.default.getInstance().getContract();
|
|
61
66
|
}
|
|
62
|
-
this.logger = logger_1.default.child({
|
|
67
|
+
this.logger = logger_1.default.child({
|
|
68
|
+
className: "Offer",
|
|
69
|
+
offerId: this.id,
|
|
70
|
+
});
|
|
63
71
|
}
|
|
64
72
|
/**
|
|
65
73
|
* Checks if contract has been initialized, if not - initialize contract
|
|
@@ -155,14 +163,13 @@ var Offer = /** @class */ (function () {
|
|
|
155
163
|
*/
|
|
156
164
|
Offer.prototype.getInfo = function () {
|
|
157
165
|
return __awaiter(this, void 0, void 0, function () {
|
|
158
|
-
var _a, offerInfoParams
|
|
166
|
+
var _a, offerInfoParams;
|
|
159
167
|
return __generator(this, function (_b) {
|
|
160
168
|
switch (_b.label) {
|
|
161
169
|
case 0: return [4 /*yield*/, Offer.contract.methods.getValueOffer(this.id).call()];
|
|
162
170
|
case 1:
|
|
163
|
-
_a = _b.sent(), offerInfoParams = _a[2]
|
|
171
|
+
_a = _b.sent(), offerInfoParams = _a[2];
|
|
164
172
|
this.offerInfo = (0, utils_1.tupleToObject)(offerInfoParams, Offer_1.OfferInfoStructure);
|
|
165
|
-
this.offerInfo.enabled = enabled;
|
|
166
173
|
return [2 /*return*/, this.offerInfo];
|
|
167
174
|
}
|
|
168
175
|
});
|
|
@@ -246,35 +253,32 @@ var Offer = /** @class */ (function () {
|
|
|
246
253
|
/**
|
|
247
254
|
* Function for fetching offer hold deposit
|
|
248
255
|
*/
|
|
249
|
-
Offer.prototype.
|
|
256
|
+
Offer.prototype.getMinDeposit = function (slotId, slotCount, optionsIds, optionsCount) {
|
|
250
257
|
return __awaiter(this, void 0, void 0, function () {
|
|
251
258
|
var _a;
|
|
252
259
|
return __generator(this, function (_b) {
|
|
253
260
|
switch (_b.label) {
|
|
254
261
|
case 0:
|
|
255
262
|
_a = this;
|
|
256
|
-
return [4 /*yield*/, Offer.contract.methods
|
|
263
|
+
return [4 /*yield*/, Offer.contract.methods
|
|
264
|
+
.getOfferMinDeposit(this.id, slotId, slotCount, optionsIds, optionsCount)
|
|
265
|
+
.call()];
|
|
257
266
|
case 1:
|
|
258
|
-
_a.
|
|
259
|
-
return [2 /*return*/, this.
|
|
267
|
+
_a.minDeposit = _b.sent();
|
|
268
|
+
return [2 /*return*/, this.minDeposit];
|
|
260
269
|
}
|
|
261
270
|
});
|
|
262
271
|
});
|
|
263
272
|
};
|
|
264
273
|
/**
|
|
265
|
-
* Function for offer
|
|
274
|
+
* Function for fetching cheapest value offer from blockchain
|
|
266
275
|
*/
|
|
267
|
-
Offer.prototype.
|
|
276
|
+
Offer.prototype.getCheapestPrice = function () {
|
|
268
277
|
return __awaiter(this, void 0, void 0, function () {
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
case
|
|
273
|
-
_a = this;
|
|
274
|
-
return [4 /*yield*/, Offer.contract.methods.getOfferClosingPrice(this.id, startDate, orderPrice).call()];
|
|
275
|
-
case 1:
|
|
276
|
-
_a.closingPrice = _b.sent();
|
|
277
|
-
return [2 /*return*/, this.closingPrice];
|
|
278
|
+
return __generator(this, function (_a) {
|
|
279
|
+
switch (_a.label) {
|
|
280
|
+
case 0: return [4 /*yield*/, Offer.contract.methods.getCheapestValueOffersPrice(this.id).call()];
|
|
281
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
278
282
|
}
|
|
279
283
|
});
|
|
280
284
|
});
|
|
@@ -289,6 +293,131 @@ var Offer = /** @class */ (function () {
|
|
|
289
293
|
});
|
|
290
294
|
});
|
|
291
295
|
};
|
|
296
|
+
/**
|
|
297
|
+
* Function for fetching whether offer slot exists or not
|
|
298
|
+
* @param slotId - Slot ID
|
|
299
|
+
*/
|
|
300
|
+
Offer.prototype.isSlotExists = function (slotId) {
|
|
301
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
302
|
+
return __generator(this, function (_a) {
|
|
303
|
+
switch (_a.label) {
|
|
304
|
+
case 0: return [4 /*yield*/, Offer.contract.methods.isValueOfferSlotExists(this.id, slotId).call()];
|
|
305
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
306
|
+
}
|
|
307
|
+
});
|
|
308
|
+
});
|
|
309
|
+
};
|
|
310
|
+
/**
|
|
311
|
+
* Function for fetching offer slot by id
|
|
312
|
+
* @param slotId - Slot ID
|
|
313
|
+
*/
|
|
314
|
+
Offer.prototype.getSlotById = function (slotId) {
|
|
315
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
316
|
+
var slot;
|
|
317
|
+
return __generator(this, function (_a) {
|
|
318
|
+
switch (_a.label) {
|
|
319
|
+
case 0: return [4 /*yield*/, Offer.contract.methods.getValueOfferSlotById(this.id, slotId).call()];
|
|
320
|
+
case 1:
|
|
321
|
+
slot = _a.sent();
|
|
322
|
+
return [2 /*return*/, (0, utils_1.tupleToObject)(slot, ValueOfferSlot_1.ValueOfferSlotStructure)];
|
|
323
|
+
}
|
|
324
|
+
});
|
|
325
|
+
});
|
|
326
|
+
};
|
|
327
|
+
/**
|
|
328
|
+
* Function for fetching offer slots info from blockchain
|
|
329
|
+
* @param begin - The first element of range.
|
|
330
|
+
* @param end - One past the final element in the range.
|
|
331
|
+
* @returns {Promise<ValueOfferSlot[]>}
|
|
332
|
+
*/
|
|
333
|
+
Offer.prototype.getSlots = function (begin, end) {
|
|
334
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
335
|
+
var slot;
|
|
336
|
+
return __generator(this, function (_a) {
|
|
337
|
+
switch (_a.label) {
|
|
338
|
+
case 0: return [4 /*yield*/, Offer.contract.methods.getValueOfferSlots(this.id, begin, end).call()];
|
|
339
|
+
case 1:
|
|
340
|
+
slot = _a.sent();
|
|
341
|
+
return [2 /*return*/, (0, utils_1.tupleToObjectsArray)(slot, ValueOfferSlot_1.ValueOfferSlotStructure)];
|
|
342
|
+
}
|
|
343
|
+
});
|
|
344
|
+
});
|
|
345
|
+
};
|
|
346
|
+
/**
|
|
347
|
+
* Function for add slot usage to the value offer
|
|
348
|
+
* @param slotInfo - slot info
|
|
349
|
+
* @param optionInfo - option info
|
|
350
|
+
* @param slotUsage - slot usage info
|
|
351
|
+
* @param transactionOptions - object what contains alternative action account or gas limit (optional)
|
|
352
|
+
*/
|
|
353
|
+
Offer.prototype.addSlot = function (slotInfo, optionInfo, slotUsage, externalId, transactionOptions) {
|
|
354
|
+
if (externalId === void 0) { externalId = "default"; }
|
|
355
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
356
|
+
var contract, slotInfoTuple, optionInfoTuple, slotUsageTuple, formattedExternalId;
|
|
357
|
+
return __generator(this, function (_a) {
|
|
358
|
+
switch (_a.label) {
|
|
359
|
+
case 0:
|
|
360
|
+
contract = BlockchainConnector_1.default.getInstance().getContract(transactionOptions);
|
|
361
|
+
(0, utils_1.checkIfActionAccountInitialized)(transactionOptions);
|
|
362
|
+
slotInfoTuple = (0, utils_1.objectToTuple)(slotInfo, SlotInfo_1.SlotInfoStructure);
|
|
363
|
+
optionInfoTuple = (0, utils_1.objectToTuple)(optionInfo, OptionInfo_1.OptionInfoStructure);
|
|
364
|
+
slotUsageTuple = (0, utils_1.objectToTuple)(slotUsage, SlotUsage_1.SlotUsageStructure);
|
|
365
|
+
formattedExternalId = (0, utils_2.formatBytes32String)(externalId);
|
|
366
|
+
return [4 /*yield*/, TxManager_1.default.execute(contract.methods.addValueOfferSlot, [this.id, formattedExternalId, slotInfoTuple, optionInfoTuple, slotUsageTuple], transactionOptions)];
|
|
367
|
+
case 1:
|
|
368
|
+
_a.sent();
|
|
369
|
+
return [2 /*return*/];
|
|
370
|
+
}
|
|
371
|
+
});
|
|
372
|
+
});
|
|
373
|
+
};
|
|
374
|
+
/**
|
|
375
|
+
* Function for update slot usage of value offer
|
|
376
|
+
* @param slotInfo - new slot info
|
|
377
|
+
* @param optionInfo - new option info
|
|
378
|
+
* @param slotUsage - new slot usage info
|
|
379
|
+
* @param transactionOptions - object what contains alternative action account or gas limit (optional)
|
|
380
|
+
*/
|
|
381
|
+
Offer.prototype.updateSlot = function (slotId, newSlotInfo, newOptionInfo, newUsage, transactionOptions) {
|
|
382
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
383
|
+
var contract, newSlotInfoTuple, newOptionInfoTuple, newSlotUsageTuple;
|
|
384
|
+
return __generator(this, function (_a) {
|
|
385
|
+
switch (_a.label) {
|
|
386
|
+
case 0:
|
|
387
|
+
contract = BlockchainConnector_1.default.getInstance().getContract(transactionOptions);
|
|
388
|
+
(0, utils_1.checkIfActionAccountInitialized)(transactionOptions);
|
|
389
|
+
newSlotInfoTuple = (0, utils_1.objectToTuple)(newSlotInfo, SlotInfo_1.SlotInfoStructure);
|
|
390
|
+
newOptionInfoTuple = (0, utils_1.objectToTuple)(newOptionInfo, OptionInfo_1.OptionInfoStructure);
|
|
391
|
+
newSlotUsageTuple = (0, utils_1.objectToTuple)(newUsage, SlotUsage_1.SlotUsageStructure);
|
|
392
|
+
return [4 /*yield*/, TxManager_1.default.execute(contract.methods.updateValueOfferSlot, [this.id, slotId, newSlotInfoTuple, newOptionInfoTuple, newSlotUsageTuple], transactionOptions)];
|
|
393
|
+
case 1:
|
|
394
|
+
_a.sent();
|
|
395
|
+
return [2 /*return*/];
|
|
396
|
+
}
|
|
397
|
+
});
|
|
398
|
+
});
|
|
399
|
+
};
|
|
400
|
+
/**
|
|
401
|
+
* Function for delete slot usage from offer
|
|
402
|
+
* @param slotId - Slot ID
|
|
403
|
+
* @param transactionOptions - object what contains alternative action account or gas limit (optional)
|
|
404
|
+
*/
|
|
405
|
+
Offer.prototype.deleteSlot = function (slotId, transactionOptions) {
|
|
406
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
407
|
+
var contract;
|
|
408
|
+
return __generator(this, function (_a) {
|
|
409
|
+
switch (_a.label) {
|
|
410
|
+
case 0:
|
|
411
|
+
contract = BlockchainConnector_1.default.getInstance().getContract(transactionOptions);
|
|
412
|
+
(0, utils_1.checkIfActionAccountInitialized)(transactionOptions);
|
|
413
|
+
return [4 /*yield*/, TxManager_1.default.execute(contract.methods.deleteValueOfferSlot, [this.id, slotId], transactionOptions)];
|
|
414
|
+
case 1:
|
|
415
|
+
_a.sent();
|
|
416
|
+
return [2 /*return*/];
|
|
417
|
+
}
|
|
418
|
+
});
|
|
419
|
+
});
|
|
420
|
+
};
|
|
292
421
|
/**
|
|
293
422
|
* Function for disabling offer
|
|
294
423
|
* @param transactionOptions - object what contains alternative action account or gas limit (optional)
|
|
@@ -375,13 +504,22 @@ var Offer = /** @class */ (function () {
|
|
|
375
504
|
], Offer.prototype, "getOrigins", null);
|
|
376
505
|
__decorate([
|
|
377
506
|
(0, utils_1.incrementMethodCall)()
|
|
378
|
-
], Offer.prototype, "
|
|
507
|
+
], Offer.prototype, "getMinDeposit", null);
|
|
379
508
|
__decorate([
|
|
380
509
|
(0, utils_1.incrementMethodCall)()
|
|
381
|
-
], Offer.prototype, "
|
|
510
|
+
], Offer.prototype, "getCheapestPrice", null);
|
|
382
511
|
__decorate([
|
|
383
512
|
(0, utils_1.incrementMethodCall)()
|
|
384
513
|
], Offer.prototype, "isOfferExists", null);
|
|
514
|
+
__decorate([
|
|
515
|
+
(0, utils_1.incrementMethodCall)()
|
|
516
|
+
], Offer.prototype, "addSlot", null);
|
|
517
|
+
__decorate([
|
|
518
|
+
(0, utils_1.incrementMethodCall)()
|
|
519
|
+
], Offer.prototype, "updateSlot", null);
|
|
520
|
+
__decorate([
|
|
521
|
+
(0, utils_1.incrementMethodCall)()
|
|
522
|
+
], Offer.prototype, "deleteSlot", null);
|
|
385
523
|
__decorate([
|
|
386
524
|
(0, utils_1.incrementMethodCall)()
|
|
387
525
|
], Offer.prototype, "isRestrictionsPermitThatOffer", null);
|