@super-protocol/sdk-js 0.13.3 → 0.13.5
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/contracts/app.json +88 -0
- package/build/models/Order.d.ts +4 -0
- package/build/models/Order.js +16 -0
- package/build/models/TCB.d.ts +5 -5
- package/build/models/TCB.js +7 -7
- package/build/staticModels/ActiveOrders.d.ts +5 -0
- package/build/staticModels/ActiveOrders.js +41 -0
- package/build/staticModels/ProviderRegistry.d.ts +8 -0
- package/build/staticModels/ProviderRegistry.js +23 -0
- package/package.json +1 -1
package/build/contracts/app.json
CHANGED
|
@@ -2224,6 +2224,29 @@
|
|
|
2224
2224
|
"stateMutability": "nonpayable",
|
|
2225
2225
|
"type": "function"
|
|
2226
2226
|
},
|
|
2227
|
+
{
|
|
2228
|
+
"inputs": [
|
|
2229
|
+
{
|
|
2230
|
+
"internalType": "address",
|
|
2231
|
+
"name": "funder",
|
|
2232
|
+
"type": "address"
|
|
2233
|
+
},
|
|
2234
|
+
{
|
|
2235
|
+
"internalType": "address",
|
|
2236
|
+
"name": "beneficiary",
|
|
2237
|
+
"type": "address"
|
|
2238
|
+
},
|
|
2239
|
+
{
|
|
2240
|
+
"internalType": "uint256",
|
|
2241
|
+
"name": "amount",
|
|
2242
|
+
"type": "uint256"
|
|
2243
|
+
}
|
|
2244
|
+
],
|
|
2245
|
+
"name": "replenishForByApp",
|
|
2246
|
+
"outputs": [],
|
|
2247
|
+
"stateMutability": "nonpayable",
|
|
2248
|
+
"type": "function"
|
|
2249
|
+
},
|
|
2227
2250
|
{
|
|
2228
2251
|
"inputs": [
|
|
2229
2252
|
{
|
|
@@ -4730,6 +4753,30 @@
|
|
|
4730
4753
|
"name": "OrderProfitUnlocked",
|
|
4731
4754
|
"type": "event"
|
|
4732
4755
|
},
|
|
4756
|
+
{
|
|
4757
|
+
"inputs": [
|
|
4758
|
+
{
|
|
4759
|
+
"internalType": "uint256",
|
|
4760
|
+
"name": "orderId",
|
|
4761
|
+
"type": "uint256"
|
|
4762
|
+
}
|
|
4763
|
+
],
|
|
4764
|
+
"name": "isOrderProfitAvailable",
|
|
4765
|
+
"outputs": [
|
|
4766
|
+
{
|
|
4767
|
+
"internalType": "bool",
|
|
4768
|
+
"name": "available",
|
|
4769
|
+
"type": "bool"
|
|
4770
|
+
},
|
|
4771
|
+
{
|
|
4772
|
+
"internalType": "uint256",
|
|
4773
|
+
"name": "profit",
|
|
4774
|
+
"type": "uint256"
|
|
4775
|
+
}
|
|
4776
|
+
],
|
|
4777
|
+
"stateMutability": "view",
|
|
4778
|
+
"type": "function"
|
|
4779
|
+
},
|
|
4733
4780
|
{
|
|
4734
4781
|
"inputs": [
|
|
4735
4782
|
{
|
|
@@ -6047,6 +6094,24 @@
|
|
|
6047
6094
|
"stateMutability": "nonpayable",
|
|
6048
6095
|
"type": "function"
|
|
6049
6096
|
},
|
|
6097
|
+
{
|
|
6098
|
+
"inputs": [
|
|
6099
|
+
{
|
|
6100
|
+
"internalType": "address",
|
|
6101
|
+
"name": "providerAuth",
|
|
6102
|
+
"type": "address"
|
|
6103
|
+
},
|
|
6104
|
+
{
|
|
6105
|
+
"internalType": "uint256",
|
|
6106
|
+
"name": "amount",
|
|
6107
|
+
"type": "uint256"
|
|
6108
|
+
}
|
|
6109
|
+
],
|
|
6110
|
+
"name": "refillProviderSecurityDepoFor",
|
|
6111
|
+
"outputs": [],
|
|
6112
|
+
"stateMutability": "nonpayable",
|
|
6113
|
+
"type": "function"
|
|
6114
|
+
},
|
|
6050
6115
|
{
|
|
6051
6116
|
"inputs": [
|
|
6052
6117
|
{
|
|
@@ -9530,6 +9595,29 @@
|
|
|
9530
9595
|
"stateMutability": "nonpayable",
|
|
9531
9596
|
"type": "function"
|
|
9532
9597
|
},
|
|
9598
|
+
{
|
|
9599
|
+
"inputs": [
|
|
9600
|
+
{
|
|
9601
|
+
"internalType": "address",
|
|
9602
|
+
"name": "funder",
|
|
9603
|
+
"type": "address"
|
|
9604
|
+
},
|
|
9605
|
+
{
|
|
9606
|
+
"internalType": "address",
|
|
9607
|
+
"name": "depositOwner",
|
|
9608
|
+
"type": "address"
|
|
9609
|
+
},
|
|
9610
|
+
{
|
|
9611
|
+
"internalType": "uint256",
|
|
9612
|
+
"name": "amount",
|
|
9613
|
+
"type": "uint256"
|
|
9614
|
+
}
|
|
9615
|
+
],
|
|
9616
|
+
"name": "replenishForByApp",
|
|
9617
|
+
"outputs": [],
|
|
9618
|
+
"stateMutability": "nonpayable",
|
|
9619
|
+
"type": "function"
|
|
9620
|
+
},
|
|
9533
9621
|
{
|
|
9534
9622
|
"inputs": [
|
|
9535
9623
|
{
|
package/build/models/Order.d.ts
CHANGED
|
@@ -26,6 +26,10 @@ declare class Order {
|
|
|
26
26
|
* Check if order is in `processing` state
|
|
27
27
|
*/
|
|
28
28
|
isOrderProcessing(): Promise<boolean>;
|
|
29
|
+
/**
|
|
30
|
+
* Function for fetching avaliable for unlock order profit.
|
|
31
|
+
*/
|
|
32
|
+
isOrderProfitAvailable(): Promise<string>;
|
|
29
33
|
/**
|
|
30
34
|
* Function for fetching order price
|
|
31
35
|
*/
|
package/build/models/Order.js
CHANGED
|
@@ -110,6 +110,22 @@ var Order = /** @class */ (function () {
|
|
|
110
110
|
});
|
|
111
111
|
});
|
|
112
112
|
};
|
|
113
|
+
/**
|
|
114
|
+
* Function for fetching avaliable for unlock order profit.
|
|
115
|
+
*/
|
|
116
|
+
Order.prototype.isOrderProfitAvailable = function () {
|
|
117
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
118
|
+
var _a, profit;
|
|
119
|
+
return __generator(this, function (_b) {
|
|
120
|
+
switch (_b.label) {
|
|
121
|
+
case 0: return [4 /*yield*/, Order.contract.methods.isOrderProfitAvailable(this.id).call()];
|
|
122
|
+
case 1:
|
|
123
|
+
_a = _b.sent(), profit = _a[1];
|
|
124
|
+
return [2 /*return*/, profit];
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
};
|
|
113
129
|
/**
|
|
114
130
|
* Function for fetching order price
|
|
115
131
|
*/
|
package/build/models/TCB.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TransactionOptions } from "../types/Web3";
|
|
2
|
-
import { TcbData,
|
|
2
|
+
import { TcbData, TcbPublicData, TcbVerifiedStatus } from "../types/Consensus";
|
|
3
3
|
declare class TCB {
|
|
4
4
|
tcbId: string;
|
|
5
5
|
private contract;
|
|
@@ -30,14 +30,14 @@ declare class TCB {
|
|
|
30
30
|
* @param tcbId - TEE Offer's completed and valid TCB contract
|
|
31
31
|
* @param transactionOptions - object what contains alternative action account or gas limit (optional)
|
|
32
32
|
*/
|
|
33
|
-
claimRewards(
|
|
33
|
+
claimRewards(transactionOptions?: TransactionOptions): Promise<void>;
|
|
34
34
|
/**
|
|
35
35
|
* Function unlock previously locked TCB rewards (by claimRewards)
|
|
36
36
|
* @param tcbId - TCB contract address
|
|
37
37
|
* @param unlockAmount - amount of tokens to unlock, max available amount = TeeOffer.getLockInfo(tcbAddress)
|
|
38
38
|
* @param transactionOptions - object what contains alternative action account or gas limit (optional)
|
|
39
39
|
*/
|
|
40
|
-
unlockRewards(
|
|
40
|
+
unlockRewards(transactionOptions?: TransactionOptions): Promise<void>;
|
|
41
41
|
/**
|
|
42
42
|
* Function for fetching all TCB data
|
|
43
43
|
*/
|
|
@@ -50,8 +50,8 @@ declare class TCB {
|
|
|
50
50
|
marks: TcbVerifiedStatus[];
|
|
51
51
|
}>;
|
|
52
52
|
/**
|
|
53
|
-
* Function for fetching TCB
|
|
53
|
+
* Function for fetching TCB avaliable reward
|
|
54
54
|
*/
|
|
55
|
-
|
|
55
|
+
getRewardAmount(): Promise<string>;
|
|
56
56
|
}
|
|
57
57
|
export default TCB;
|
package/build/models/TCB.js
CHANGED
|
@@ -148,7 +148,7 @@ var TCB = /** @class */ (function () {
|
|
|
148
148
|
* @param tcbId - TEE Offer's completed and valid TCB contract
|
|
149
149
|
* @param transactionOptions - object what contains alternative action account or gas limit (optional)
|
|
150
150
|
*/
|
|
151
|
-
TCB.prototype.claimRewards = function (
|
|
151
|
+
TCB.prototype.claimRewards = function (transactionOptions) {
|
|
152
152
|
return __awaiter(this, void 0, void 0, function () {
|
|
153
153
|
var contract;
|
|
154
154
|
return __generator(this, function (_a) {
|
|
@@ -156,7 +156,7 @@ var TCB = /** @class */ (function () {
|
|
|
156
156
|
case 0:
|
|
157
157
|
contract = this.checkInitTcb(transactionOptions);
|
|
158
158
|
(0, utils_1.checkIfActionAccountInitialized)();
|
|
159
|
-
return [4 /*yield*/, TxManager_1.default.execute(contract.methods.claimRewards, [tcbId], transactionOptions)];
|
|
159
|
+
return [4 /*yield*/, TxManager_1.default.execute(contract.methods.claimRewards, [this.tcbId], transactionOptions)];
|
|
160
160
|
case 1:
|
|
161
161
|
_a.sent();
|
|
162
162
|
return [2 /*return*/];
|
|
@@ -170,7 +170,7 @@ var TCB = /** @class */ (function () {
|
|
|
170
170
|
* @param unlockAmount - amount of tokens to unlock, max available amount = TeeOffer.getLockInfo(tcbAddress)
|
|
171
171
|
* @param transactionOptions - object what contains alternative action account or gas limit (optional)
|
|
172
172
|
*/
|
|
173
|
-
TCB.prototype.unlockRewards = function (
|
|
173
|
+
TCB.prototype.unlockRewards = function (transactionOptions) {
|
|
174
174
|
return __awaiter(this, void 0, void 0, function () {
|
|
175
175
|
var contract;
|
|
176
176
|
return __generator(this, function (_a) {
|
|
@@ -178,7 +178,7 @@ var TCB = /** @class */ (function () {
|
|
|
178
178
|
case 0:
|
|
179
179
|
contract = this.checkInitTcb(transactionOptions);
|
|
180
180
|
(0, utils_1.checkIfActionAccountInitialized)();
|
|
181
|
-
return [4 /*yield*/, TxManager_1.default.execute(contract.methods.
|
|
181
|
+
return [4 /*yield*/, TxManager_1.default.execute(contract.methods.unlockTcbReward, [this.tcbId], transactionOptions)];
|
|
182
182
|
case 1:
|
|
183
183
|
_a.sent();
|
|
184
184
|
return [2 /*return*/];
|
|
@@ -224,12 +224,12 @@ var TCB = /** @class */ (function () {
|
|
|
224
224
|
});
|
|
225
225
|
};
|
|
226
226
|
/**
|
|
227
|
-
* Function for fetching TCB
|
|
227
|
+
* Function for fetching TCB avaliable reward
|
|
228
228
|
*/
|
|
229
|
-
TCB.prototype.
|
|
229
|
+
TCB.prototype.getRewardAmount = function () {
|
|
230
230
|
return __awaiter(this, void 0, void 0, function () {
|
|
231
231
|
return __generator(this, function (_a) {
|
|
232
|
-
return [2 /*return*/, this.contract.methods.
|
|
232
|
+
return [2 /*return*/, this.contract.methods.getTcbReward(this.tcbId).call()];
|
|
233
233
|
});
|
|
234
234
|
});
|
|
235
235
|
};
|
|
@@ -12,5 +12,10 @@ declare class ActiveOrders {
|
|
|
12
12
|
* @returns {Promise<string[]>}
|
|
13
13
|
*/
|
|
14
14
|
static getListOfActiveOrdersRange(begin?: BigNumber | number, end?: BigNumber | number): Promise<string[]>;
|
|
15
|
+
/**
|
|
16
|
+
* Function returns ids of active orders by offers
|
|
17
|
+
* @returns {Promise<string[]>}
|
|
18
|
+
*/
|
|
19
|
+
static getActiveOrdersRangeByOffers(offerIds: string[], begin?: BigNumber | number, end?: BigNumber | number): Promise<string[]>;
|
|
15
20
|
}
|
|
16
21
|
export default ActiveOrders;
|
|
@@ -104,6 +104,44 @@ var ActiveOrders = /** @class */ (function () {
|
|
|
104
104
|
});
|
|
105
105
|
});
|
|
106
106
|
};
|
|
107
|
+
/**
|
|
108
|
+
* Function returns ids of active orders by offers
|
|
109
|
+
* @returns {Promise<string[]>}
|
|
110
|
+
*/
|
|
111
|
+
ActiveOrders.getActiveOrdersRangeByOffers = function (offerIds, begin, end) {
|
|
112
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
113
|
+
var contract, response, _a, _b, _c, _i, offerId, _d, _e;
|
|
114
|
+
return __generator(this, function (_f) {
|
|
115
|
+
switch (_f.label) {
|
|
116
|
+
case 0:
|
|
117
|
+
contract = BlockchainConnector_1.default.getInstance().getContract();
|
|
118
|
+
response = [];
|
|
119
|
+
begin = begin !== null && begin !== void 0 ? begin : 0;
|
|
120
|
+
end = end !== null && end !== void 0 ? end : 999; // max active orders for one offer
|
|
121
|
+
_a = offerIds;
|
|
122
|
+
_b = [];
|
|
123
|
+
for (_c in _a)
|
|
124
|
+
_b.push(_c);
|
|
125
|
+
_i = 0;
|
|
126
|
+
_f.label = 1;
|
|
127
|
+
case 1:
|
|
128
|
+
if (!(_i < _b.length)) return [3 /*break*/, 4];
|
|
129
|
+
_c = _b[_i];
|
|
130
|
+
if (!(_c in _a)) return [3 /*break*/, 3];
|
|
131
|
+
offerId = _c;
|
|
132
|
+
_e = (_d = response).push;
|
|
133
|
+
return [4 /*yield*/, contract.methods.getOfferActiveOrdersRange(offerId, begin, end)];
|
|
134
|
+
case 2:
|
|
135
|
+
_e.apply(_d, [_f.sent()]);
|
|
136
|
+
_f.label = 3;
|
|
137
|
+
case 3:
|
|
138
|
+
_i++;
|
|
139
|
+
return [3 /*break*/, 1];
|
|
140
|
+
case 4: return [2 /*return*/, response];
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
};
|
|
107
145
|
ActiveOrders.logger = logger_1.default.child({ className: "ActiveOrders" });
|
|
108
146
|
__decorate([
|
|
109
147
|
(0, utils_1.incrementMethodCall)()
|
|
@@ -111,6 +149,9 @@ var ActiveOrders = /** @class */ (function () {
|
|
|
111
149
|
__decorate([
|
|
112
150
|
(0, utils_1.incrementMethodCall)()
|
|
113
151
|
], ActiveOrders, "getListOfActiveOrdersRange", null);
|
|
152
|
+
__decorate([
|
|
153
|
+
(0, utils_1.incrementMethodCall)()
|
|
154
|
+
], ActiveOrders, "getActiveOrdersRangeByOffers", null);
|
|
114
155
|
return ActiveOrders;
|
|
115
156
|
}());
|
|
116
157
|
exports.default = ActiveOrders;
|
|
@@ -17,6 +17,14 @@ declare class ProviderRegistry {
|
|
|
17
17
|
*/
|
|
18
18
|
static getSecurityDeposit(providerAuthority: string): Promise<string>;
|
|
19
19
|
static isProviderRegistered(providerAuthority: string): Promise<boolean>;
|
|
20
|
+
/**
|
|
21
|
+
* Refills security provider deposit
|
|
22
|
+
* Call this function with provider authority account (in transactionOptions)
|
|
23
|
+
* @param amount - amount of additional tokens
|
|
24
|
+
* @param recipient - target provider authority address
|
|
25
|
+
* @param transactionOptions - object what contains alternative action account or gas limit (optional)
|
|
26
|
+
*/
|
|
27
|
+
static refillSecurityDepositFor(amount: string, recipient: string, transactionOptions?: TransactionOptions): Promise<void>;
|
|
20
28
|
/**
|
|
21
29
|
* Reg new provider
|
|
22
30
|
* @param providerInfo - data of new provider
|
|
@@ -106,6 +106,29 @@ var ProviderRegistry = /** @class */ (function () {
|
|
|
106
106
|
});
|
|
107
107
|
});
|
|
108
108
|
};
|
|
109
|
+
/**
|
|
110
|
+
* Refills security provider deposit
|
|
111
|
+
* Call this function with provider authority account (in transactionOptions)
|
|
112
|
+
* @param amount - amount of additional tokens
|
|
113
|
+
* @param recipient - target provider authority address
|
|
114
|
+
* @param transactionOptions - object what contains alternative action account or gas limit (optional)
|
|
115
|
+
*/
|
|
116
|
+
ProviderRegistry.refillSecurityDepositFor = function (amount, recipient, transactionOptions) {
|
|
117
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
118
|
+
var contract;
|
|
119
|
+
return __generator(this, function (_a) {
|
|
120
|
+
switch (_a.label) {
|
|
121
|
+
case 0:
|
|
122
|
+
contract = BlockchainConnector_1.default.getInstance().getContract(transactionOptions);
|
|
123
|
+
(0, utils_1.checkIfActionAccountInitialized)(transactionOptions);
|
|
124
|
+
return [4 /*yield*/, TxManager_1.default.execute(contract.methods.refillProviderSecurityDepo, [amount, recipient], transactionOptions)];
|
|
125
|
+
case 1:
|
|
126
|
+
_a.sent();
|
|
127
|
+
return [2 /*return*/];
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
};
|
|
109
132
|
/**
|
|
110
133
|
* Reg new provider
|
|
111
134
|
* @param providerInfo - data of new provider
|