@ledgerhq/coin-polkadot 0.0.2
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/.eslintrc.js +57 -0
- package/.turbo/turbo-build.log +4 -0
- package/CHANGELOG.md +12 -0
- package/jest.config.js +10 -0
- package/lib/account.d.ts +15 -0
- package/lib/account.d.ts.map +1 -0
- package/lib/account.js +133 -0
- package/lib/account.js.map +1 -0
- package/lib/address.d.ts +7 -0
- package/lib/address.d.ts.map +1 -0
- package/lib/address.js +28 -0
- package/lib/address.js.map +1 -0
- package/lib/api/bisontrails.d.ts +11 -0
- package/lib/api/bisontrails.d.ts.map +1 -0
- package/lib/api/bisontrails.js +351 -0
- package/lib/api/bisontrails.js.map +1 -0
- package/lib/api/common.d.ts +12 -0
- package/lib/api/common.d.ts.map +1 -0
- package/lib/api/common.js +41 -0
- package/lib/api/common.js.map +1 -0
- package/lib/api/index.d.ts +3 -0
- package/lib/api/index.d.ts.map +1 -0
- package/lib/api/index.js +53 -0
- package/lib/api/index.js.map +1 -0
- package/lib/api/sidecar.d.ts +193 -0
- package/lib/api/sidecar.d.ts.map +1 -0
- package/lib/api/sidecar.js +844 -0
- package/lib/api/sidecar.js.map +1 -0
- package/lib/api/sidecar.types.d.ts +163 -0
- package/lib/api/sidecar.types.d.ts.map +1 -0
- package/lib/api/sidecar.types.js +3 -0
- package/lib/api/sidecar.types.js.map +1 -0
- package/lib/api/subscan.d.ts +6 -0
- package/lib/api/subscan.d.ts.map +1 -0
- package/lib/api/subscan.js +375 -0
- package/lib/api/subscan.js.map +1 -0
- package/lib/api/websocket.d.ts +92 -0
- package/lib/api/websocket.d.ts.map +1 -0
- package/lib/api/websocket.js +759 -0
- package/lib/api/websocket.js.map +1 -0
- package/lib/bridge/js.d.ts +6 -0
- package/lib/bridge/js.d.ts.map +1 -0
- package/lib/bridge/js.js +120 -0
- package/lib/bridge/js.js.map +1 -0
- package/lib/bridge.integration.test.d.ts +4 -0
- package/lib/bridge.integration.test.d.ts.map +1 -0
- package/lib/bridge.integration.test.js +795 -0
- package/lib/bridge.integration.test.js.map +1 -0
- package/lib/cache.d.ts +65 -0
- package/lib/cache.d.ts.map +1 -0
- package/lib/cache.js +182 -0
- package/lib/cache.js.map +1 -0
- package/lib/cli-transaction.d.ts +44 -0
- package/lib/cli-transaction.d.ts.map +1 -0
- package/lib/cli-transaction.js +148 -0
- package/lib/cli-transaction.js.map +1 -0
- package/lib/deviceTransactionConfig.d.ts +16 -0
- package/lib/deviceTransactionConfig.d.ts.map +1 -0
- package/lib/deviceTransactionConfig.js +171 -0
- package/lib/deviceTransactionConfig.js.map +1 -0
- package/lib/errors.d.ts +37 -0
- package/lib/errors.d.ts.map +1 -0
- package/lib/errors.js +17 -0
- package/lib/errors.js.map +1 -0
- package/lib/hw-getAddress.d.ts +4 -0
- package/lib/hw-getAddress.d.ts.map +1 -0
- package/lib/hw-getAddress.js +64 -0
- package/lib/hw-getAddress.js.map +1 -0
- package/lib/js-buildTransaction.d.ts +25 -0
- package/lib/js-buildTransaction.d.ts.map +1 -0
- package/lib/js-buildTransaction.js +265 -0
- package/lib/js-buildTransaction.js.map +1 -0
- package/lib/js-createTransaction.d.ts +9 -0
- package/lib/js-createTransaction.d.ts.map +1 -0
- package/lib/js-createTransaction.js +22 -0
- package/lib/js-createTransaction.js.map +1 -0
- package/lib/js-estimateMaxSpendable.d.ts +15 -0
- package/lib/js-estimateMaxSpendable.d.ts.map +1 -0
- package/lib/js-estimateMaxSpendable.js +89 -0
- package/lib/js-estimateMaxSpendable.js.map +1 -0
- package/lib/js-getFeesForTransaction.d.ts +14 -0
- package/lib/js-getFeesForTransaction.d.ts.map +1 -0
- package/lib/js-getFeesForTransaction.js +94 -0
- package/lib/js-getFeesForTransaction.js.map +1 -0
- package/lib/js-getTransactionStatus.d.ts +18 -0
- package/lib/js-getTransactionStatus.d.ts.map +1 -0
- package/lib/js-getTransactionStatus.js +316 -0
- package/lib/js-getTransactionStatus.js.map +1 -0
- package/lib/js-prepareTransaction.d.ts +9 -0
- package/lib/js-prepareTransaction.d.ts.map +1 -0
- package/lib/js-prepareTransaction.js +83 -0
- package/lib/js-prepareTransaction.js.map +1 -0
- package/lib/js-signOperation.d.ts +27 -0
- package/lib/js-signOperation.d.ts.map +1 -0
- package/lib/js-signOperation.js +235 -0
- package/lib/js-signOperation.js.map +1 -0
- package/lib/js-synchronisation.d.ts +3 -0
- package/lib/js-synchronisation.d.ts.map +1 -0
- package/lib/js-synchronisation.js +104 -0
- package/lib/js-synchronisation.js.map +1 -0
- package/lib/logic.d.ts +107 -0
- package/lib/logic.d.ts.map +1 -0
- package/lib/logic.js +242 -0
- package/lib/logic.js.map +1 -0
- package/lib/platformAdapter.d.ts +11 -0
- package/lib/platformAdapter.d.ts.map +1 -0
- package/lib/platformAdapter.js +25 -0
- package/lib/platformAdapter.js.map +1 -0
- package/lib/platformAdapter.test.d.ts +2 -0
- package/lib/platformAdapter.test.d.ts.map +1 -0
- package/lib/platformAdapter.test.js +51 -0
- package/lib/platformAdapter.test.js.map +1 -0
- package/lib/polkadot-crypto.d.ts +2 -0
- package/lib/polkadot-crypto.d.ts.map +1 -0
- package/lib/polkadot-crypto.js +14 -0
- package/lib/polkadot-crypto.js.map +1 -0
- package/lib/preload.d.ts +14 -0
- package/lib/preload.d.ts.map +1 -0
- package/lib/preload.js +173 -0
- package/lib/preload.js.map +1 -0
- package/lib/serialization.d.ts +4 -0
- package/lib/serialization.d.ts.map +1 -0
- package/lib/serialization.js +51 -0
- package/lib/serialization.js.map +1 -0
- package/lib/specs.d.ts +7 -0
- package/lib/specs.d.ts.map +1 -0
- package/lib/specs.js +274 -0
- package/lib/specs.js.map +1 -0
- package/lib/speculos-deviceActions.d.ts +4 -0
- package/lib/speculos-deviceActions.d.ts.map +1 -0
- package/lib/speculos-deviceActions.js +85 -0
- package/lib/speculos-deviceActions.js.map +1 -0
- package/lib/transaction.d.ts +15 -0
- package/lib/transaction.d.ts.map +1 -0
- package/lib/transaction.js +51 -0
- package/lib/transaction.js.map +1 -0
- package/lib/types.d.ts +96 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/types.js +3 -0
- package/lib/types.js.map +1 -0
- package/lib/validators.d.ts +3 -0
- package/lib/validators.d.ts.map +1 -0
- package/lib/validators.js +7 -0
- package/lib/validators.js.map +1 -0
- package/package.json +95 -0
- package/src/account.ts +170 -0
- package/src/address.ts +28 -0
- package/src/api/bisontrails.ts +343 -0
- package/src/api/common.ts +52 -0
- package/src/api/index.ts +38 -0
- package/src/api/sidecar.ts +735 -0
- package/src/api/sidecar.types.ts +162 -0
- package/src/api/subscan.ts +362 -0
- package/src/api/websocket.ts +535 -0
- package/src/bridge/js.ts +81 -0
- package/src/bridge.integration.test.ts +764 -0
- package/src/cache.ts +202 -0
- package/src/cli-transaction.ts +184 -0
- package/src/deviceTransactionConfig.ts +209 -0
- package/src/errors.ts +39 -0
- package/src/hw-getAddress.ts +14 -0
- package/src/js-buildTransaction.ts +206 -0
- package/src/js-createTransaction.ts +22 -0
- package/src/js-estimateMaxSpendable.ts +37 -0
- package/src/js-getFeesForTransaction.ts +41 -0
- package/src/js-getTransactionStatus.ts +350 -0
- package/src/js-prepareTransaction.ts +27 -0
- package/src/js-signOperation.ts +232 -0
- package/src/js-synchronisation.ts +57 -0
- package/src/logic.ts +266 -0
- package/src/platformAdapter.test.ts +61 -0
- package/src/platformAdapter.ts +29 -0
- package/src/polkadot-crypto.ts +10 -0
- package/src/preload.ts +148 -0
- package/src/serialization.ts +48 -0
- package/src/specs.ts +305 -0
- package/src/speculos-deviceActions.ts +84 -0
- package/src/transaction.ts +64 -0
- package/src/types.ts +118 -0
- package/src/validators.ts +2 -0
- package/tsconfig.json +21 -0
|
@@ -0,0 +1,795 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
+
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;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
50
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
51
|
+
if (!m) return o;
|
|
52
|
+
var i = m.call(o), r, ar = [], e;
|
|
53
|
+
try {
|
|
54
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
55
|
+
}
|
|
56
|
+
catch (error) { e = { error: error }; }
|
|
57
|
+
finally {
|
|
58
|
+
try {
|
|
59
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
60
|
+
}
|
|
61
|
+
finally { if (e) throw e.error; }
|
|
62
|
+
}
|
|
63
|
+
return ar;
|
|
64
|
+
};
|
|
65
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
66
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
67
|
+
if (ar || !(i in from)) {
|
|
68
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
69
|
+
ar[i] = from[i];
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
73
|
+
};
|
|
74
|
+
exports.__esModule = true;
|
|
75
|
+
exports.dataset = void 0;
|
|
76
|
+
var api_1 = require("./api");
|
|
77
|
+
var bignumber_js_1 = require("bignumber.js");
|
|
78
|
+
var logic_1 = require("./logic");
|
|
79
|
+
var errors_1 = require("@ledgerhq/errors");
|
|
80
|
+
var errors_2 = require("./errors");
|
|
81
|
+
var transaction_1 = require("./transaction");
|
|
82
|
+
var ACCOUNT_SAME_STASHCONTROLLER = "12YA86tRQhHgwU3SSj56aesUKB7GKvdnZTTTXRop4vd3YgDV";
|
|
83
|
+
var ACCOUNT_STASH = "13jAJfhpFkRZj1TSSdFopaiFeKnof2q7g4GNdcxcg8Lvx6QN";
|
|
84
|
+
var ACCOUNT_CONTROLLER = "15oodc5d8DWJodZhTD6qsxxSQRYWhdkWCrwqNHajDirXRrAD";
|
|
85
|
+
var ACCOUNT_EMPTY = "111111111111111111111111111111111HC1";
|
|
86
|
+
var ACCOUNT_WITH_NO_OPERATION = "12EsPA79dvhtjp1bYvCiEWPsQmmdKGss44GzE3CT9tTo9g4Q";
|
|
87
|
+
var polkadot = {
|
|
88
|
+
FIXME_ignoreAccountFields: [
|
|
89
|
+
"polkadotResources.unlockings",
|
|
90
|
+
"polkadotResources.nominations",
|
|
91
|
+
"polkadotResources.unlockedBalance", // It moved when an unbond is finished
|
|
92
|
+
],
|
|
93
|
+
scanAccounts: [
|
|
94
|
+
{
|
|
95
|
+
name: "polkadot seed 1",
|
|
96
|
+
apdus: "\n => 90010000142c00008062010080000000800000000000000000\n <= c71b1e00ca34fdd14ea065917a67168675828927e3adc3b68f444bf85b4d24be3135573461755239707652335a5765616f50516f4562616d54535557347571335072515369564a4e4e7953385868314e9000\n => 90010000142c00008062010080000000800000008000000080\n <= 845175a888f0ced372bd352d59cb51242dff8438c3dd12a703835c25bdfa3f9231337a565838337a74575939446d69757446525738374262676b627631517031666366706f4a6964626448776b3335649000\n => 90010000142c00008062010080010000800000008000000080\n <= 3a521fa830998568da9c205c987dcd157a78b2bd30ece3d1b6c32213986864ca31324b5542335272346163346469354a47707a545935474e516b44564e6b50556b636a324d4746546d7a617a4d5364739000\n => 90010000142c00008062010080020000800000008000000080\n <= 7e52138bf614dddff1116623b027ea92d6015d8fe741575b78ac7773545066bd31337264523573727657463533566b4e654a757a35576b476b4736465358515141375a423551424769673441544373399000\n => 90010000142c00008062010080030000800000008000000080\n <= dfd77108b64b8173805852f7550f1f2d6c166968d31d5c4984187c9cb1969d9331363456674b366f6f5a3466557555346946567770537558774658474c55356e5454577a4736347672447167697077689000\n "
|
|
97
|
+
},
|
|
98
|
+
],
|
|
99
|
+
accounts: [
|
|
100
|
+
{
|
|
101
|
+
// Account which is stash and controller
|
|
102
|
+
raw: {
|
|
103
|
+
id: "js:2:polkadot:".concat(ACCOUNT_SAME_STASHCONTROLLER, ":polkadotbip44"),
|
|
104
|
+
seedIdentifier: ACCOUNT_SAME_STASHCONTROLLER,
|
|
105
|
+
name: "Polkadot 1",
|
|
106
|
+
derivationMode: "polkadotbip44",
|
|
107
|
+
index: 0,
|
|
108
|
+
freshAddress: ACCOUNT_SAME_STASHCONTROLLER,
|
|
109
|
+
freshAddressPath: "44'/354'/0'/0'/0'",
|
|
110
|
+
freshAddresses: [],
|
|
111
|
+
blockHeight: 0,
|
|
112
|
+
operations: [],
|
|
113
|
+
pendingOperations: [],
|
|
114
|
+
currencyId: "polkadot",
|
|
115
|
+
unitMagnitude: 10,
|
|
116
|
+
lastSyncDate: "",
|
|
117
|
+
balance: "21000310"
|
|
118
|
+
},
|
|
119
|
+
transactions: [
|
|
120
|
+
{
|
|
121
|
+
name: "recipient and sender must not be the same",
|
|
122
|
+
transaction: (0, transaction_1.fromTransactionRaw)({
|
|
123
|
+
family: "polkadot",
|
|
124
|
+
recipient: ACCOUNT_SAME_STASHCONTROLLER,
|
|
125
|
+
amount: "100000000",
|
|
126
|
+
mode: "send",
|
|
127
|
+
era: null,
|
|
128
|
+
validators: [],
|
|
129
|
+
fees: null,
|
|
130
|
+
rewardDestination: null,
|
|
131
|
+
numSlashingSpans: 0
|
|
132
|
+
}),
|
|
133
|
+
expectedStatus: {
|
|
134
|
+
amount: new bignumber_js_1.BigNumber("100000000"),
|
|
135
|
+
errors: {
|
|
136
|
+
recipient: new errors_1.InvalidAddressBecauseDestinationIsAlsoSource()
|
|
137
|
+
},
|
|
138
|
+
warnings: {}
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
name: "Not a valid address",
|
|
143
|
+
transaction: (0, transaction_1.fromTransactionRaw)({
|
|
144
|
+
family: "polkadot",
|
|
145
|
+
recipient: "ewrererewrew",
|
|
146
|
+
amount: "100000000",
|
|
147
|
+
mode: "send",
|
|
148
|
+
era: null,
|
|
149
|
+
validators: [],
|
|
150
|
+
fees: null,
|
|
151
|
+
rewardDestination: null,
|
|
152
|
+
numSlashingSpans: 0
|
|
153
|
+
}),
|
|
154
|
+
expectedStatus: {
|
|
155
|
+
errors: {
|
|
156
|
+
recipient: new errors_1.InvalidAddress()
|
|
157
|
+
},
|
|
158
|
+
warnings: {}
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
name: "Amount Required",
|
|
163
|
+
transaction: (0, transaction_1.fromTransactionRaw)({
|
|
164
|
+
family: "polkadot",
|
|
165
|
+
recipient: ACCOUNT_CONTROLLER,
|
|
166
|
+
amount: "0",
|
|
167
|
+
mode: "send",
|
|
168
|
+
era: null,
|
|
169
|
+
validators: [],
|
|
170
|
+
fees: null,
|
|
171
|
+
rewardDestination: null,
|
|
172
|
+
numSlashingSpans: 0
|
|
173
|
+
}),
|
|
174
|
+
expectedStatus: {
|
|
175
|
+
errors: {
|
|
176
|
+
amount: new errors_1.AmountRequired()
|
|
177
|
+
},
|
|
178
|
+
warnings: {}
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
name: "Not enough balance",
|
|
183
|
+
transaction: (0, transaction_1.fromTransactionRaw)({
|
|
184
|
+
family: "polkadot",
|
|
185
|
+
recipient: ACCOUNT_CONTROLLER,
|
|
186
|
+
amount: "1000000000000000",
|
|
187
|
+
mode: "send",
|
|
188
|
+
era: null,
|
|
189
|
+
validators: [],
|
|
190
|
+
fees: null,
|
|
191
|
+
rewardDestination: null,
|
|
192
|
+
numSlashingSpans: 0
|
|
193
|
+
}),
|
|
194
|
+
expectedStatus: {
|
|
195
|
+
errors: {
|
|
196
|
+
amount: new errors_1.NotEnoughBalance()
|
|
197
|
+
},
|
|
198
|
+
warnings: {}
|
|
199
|
+
}
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
name: "Not created account and deposit not existing",
|
|
203
|
+
transaction: (0, transaction_1.fromTransactionRaw)({
|
|
204
|
+
family: "polkadot",
|
|
205
|
+
recipient: ACCOUNT_WITH_NO_OPERATION,
|
|
206
|
+
amount: "1000000",
|
|
207
|
+
mode: "send",
|
|
208
|
+
era: null,
|
|
209
|
+
validators: [],
|
|
210
|
+
fees: null,
|
|
211
|
+
rewardDestination: null,
|
|
212
|
+
numSlashingSpans: 0
|
|
213
|
+
}),
|
|
214
|
+
expectedStatus: {
|
|
215
|
+
errors: {
|
|
216
|
+
amount: new errors_1.NotEnoughBalanceBecauseDestinationNotCreated()
|
|
217
|
+
},
|
|
218
|
+
warnings: {}
|
|
219
|
+
}
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
name: "New account and suffisent deposit",
|
|
223
|
+
transaction: (0, transaction_1.fromTransactionRaw)({
|
|
224
|
+
family: "polkadot",
|
|
225
|
+
recipient: ACCOUNT_WITH_NO_OPERATION,
|
|
226
|
+
amount: "10000000000",
|
|
227
|
+
mode: "send",
|
|
228
|
+
era: null,
|
|
229
|
+
validators: [],
|
|
230
|
+
fees: null,
|
|
231
|
+
rewardDestination: null,
|
|
232
|
+
numSlashingSpans: 0
|
|
233
|
+
}),
|
|
234
|
+
expectedStatus: {
|
|
235
|
+
amount: new bignumber_js_1.BigNumber("10000000000"),
|
|
236
|
+
errors: {},
|
|
237
|
+
warnings: {}
|
|
238
|
+
}
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
name: "nominate without true validator",
|
|
242
|
+
transaction: (0, transaction_1.fromTransactionRaw)({
|
|
243
|
+
family: "polkadot",
|
|
244
|
+
recipient: ACCOUNT_SAME_STASHCONTROLLER,
|
|
245
|
+
amount: "0",
|
|
246
|
+
mode: "nominate",
|
|
247
|
+
era: null,
|
|
248
|
+
validators: [ACCOUNT_SAME_STASHCONTROLLER],
|
|
249
|
+
fees: null,
|
|
250
|
+
rewardDestination: null,
|
|
251
|
+
numSlashingSpans: 0
|
|
252
|
+
}),
|
|
253
|
+
expectedStatus: {
|
|
254
|
+
errors: {
|
|
255
|
+
staking: new errors_2.PolkadotNotValidator()
|
|
256
|
+
},
|
|
257
|
+
warnings: {}
|
|
258
|
+
}
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
name: "nominate is empty",
|
|
262
|
+
transaction: (0, transaction_1.fromTransactionRaw)({
|
|
263
|
+
family: "polkadot",
|
|
264
|
+
recipient: ACCOUNT_SAME_STASHCONTROLLER,
|
|
265
|
+
amount: "0",
|
|
266
|
+
mode: "nominate",
|
|
267
|
+
era: null,
|
|
268
|
+
validators: [],
|
|
269
|
+
fees: null,
|
|
270
|
+
rewardDestination: null,
|
|
271
|
+
numSlashingSpans: 0
|
|
272
|
+
}),
|
|
273
|
+
expectedStatus: {
|
|
274
|
+
errors: {
|
|
275
|
+
staking: new errors_2.PolkadotValidatorsRequired()
|
|
276
|
+
},
|
|
277
|
+
warnings: {}
|
|
278
|
+
}
|
|
279
|
+
},
|
|
280
|
+
{
|
|
281
|
+
name: "bond extra - not enough spendable",
|
|
282
|
+
transaction: (0, transaction_1.fromTransactionRaw)({
|
|
283
|
+
family: "polkadot",
|
|
284
|
+
recipient: ACCOUNT_SAME_STASHCONTROLLER,
|
|
285
|
+
amount: "2000000000000000000",
|
|
286
|
+
mode: "bond",
|
|
287
|
+
era: null,
|
|
288
|
+
validators: null,
|
|
289
|
+
fees: null,
|
|
290
|
+
rewardDestination: null,
|
|
291
|
+
numSlashingSpans: 0
|
|
292
|
+
}),
|
|
293
|
+
expectedStatus: {
|
|
294
|
+
errors: {
|
|
295
|
+
amount: new errors_1.NotEnoughBalance()
|
|
296
|
+
},
|
|
297
|
+
warnings: {}
|
|
298
|
+
}
|
|
299
|
+
},
|
|
300
|
+
{
|
|
301
|
+
name: "[Bond] New controller and suffisent deposit",
|
|
302
|
+
transaction: (0, transaction_1.fromTransactionRaw)({
|
|
303
|
+
family: "polkadot",
|
|
304
|
+
recipient: ACCOUNT_EMPTY,
|
|
305
|
+
amount: "10000000000",
|
|
306
|
+
mode: "bond",
|
|
307
|
+
era: null,
|
|
308
|
+
validators: [],
|
|
309
|
+
fees: null,
|
|
310
|
+
rewardDestination: null,
|
|
311
|
+
numSlashingSpans: 0
|
|
312
|
+
}),
|
|
313
|
+
expectedStatus: {
|
|
314
|
+
amount: new bignumber_js_1.BigNumber("10000000000"),
|
|
315
|
+
errors: {},
|
|
316
|
+
warnings: {}
|
|
317
|
+
}
|
|
318
|
+
},
|
|
319
|
+
{
|
|
320
|
+
name: "[unbond] no amount",
|
|
321
|
+
transaction: (0, transaction_1.fromTransactionRaw)({
|
|
322
|
+
family: "polkadot",
|
|
323
|
+
recipient: "",
|
|
324
|
+
amount: "0",
|
|
325
|
+
mode: "unbond",
|
|
326
|
+
era: null,
|
|
327
|
+
validators: [],
|
|
328
|
+
fees: null,
|
|
329
|
+
rewardDestination: null,
|
|
330
|
+
numSlashingSpans: 0
|
|
331
|
+
}),
|
|
332
|
+
expectedStatus: {
|
|
333
|
+
errors: {
|
|
334
|
+
amount: new errors_1.AmountRequired()
|
|
335
|
+
},
|
|
336
|
+
warnings: {}
|
|
337
|
+
}
|
|
338
|
+
},
|
|
339
|
+
{
|
|
340
|
+
name: "[unbond] not enough locked balance",
|
|
341
|
+
transaction: (0, transaction_1.fromTransactionRaw)({
|
|
342
|
+
family: "polkadot",
|
|
343
|
+
recipient: "",
|
|
344
|
+
amount: "2000000000000000",
|
|
345
|
+
mode: "unbond",
|
|
346
|
+
era: null,
|
|
347
|
+
validators: [],
|
|
348
|
+
fees: null,
|
|
349
|
+
rewardDestination: null,
|
|
350
|
+
numSlashingSpans: 0
|
|
351
|
+
}),
|
|
352
|
+
expectedStatus: {
|
|
353
|
+
errors: {
|
|
354
|
+
amount: new errors_1.NotEnoughBalance()
|
|
355
|
+
},
|
|
356
|
+
warnings: {}
|
|
357
|
+
}
|
|
358
|
+
},
|
|
359
|
+
{
|
|
360
|
+
name: "[rebond] no amount",
|
|
361
|
+
transaction: (0, transaction_1.fromTransactionRaw)({
|
|
362
|
+
family: "polkadot",
|
|
363
|
+
recipient: "",
|
|
364
|
+
amount: "0",
|
|
365
|
+
mode: "rebond",
|
|
366
|
+
era: null,
|
|
367
|
+
validators: [],
|
|
368
|
+
fees: null,
|
|
369
|
+
rewardDestination: null,
|
|
370
|
+
numSlashingSpans: 0
|
|
371
|
+
}),
|
|
372
|
+
expectedStatus: {
|
|
373
|
+
errors: {
|
|
374
|
+
amount: new errors_1.AmountRequired()
|
|
375
|
+
},
|
|
376
|
+
warnings: {}
|
|
377
|
+
}
|
|
378
|
+
},
|
|
379
|
+
{
|
|
380
|
+
name: "[unbond] use all amount",
|
|
381
|
+
transaction: function (t) { return (__assign(__assign({}, t), { useAllAmount: true, mode: "unbond" })); },
|
|
382
|
+
expectedStatus: function (a) {
|
|
383
|
+
var _a;
|
|
384
|
+
return ({
|
|
385
|
+
errors: {},
|
|
386
|
+
warnings: {},
|
|
387
|
+
amount: (_a = a.polkadotResources) === null || _a === void 0 ? void 0 : _a.lockedBalance.minus(a.polkadotResources.unlockingBalance)
|
|
388
|
+
});
|
|
389
|
+
}
|
|
390
|
+
},
|
|
391
|
+
{
|
|
392
|
+
name: "[rebond] use all amount",
|
|
393
|
+
transaction: function (t) { return (__assign(__assign({}, t), { useAllAmount: true, mode: "rebond" })); },
|
|
394
|
+
expectedStatus: function (a) {
|
|
395
|
+
var _a;
|
|
396
|
+
return ({
|
|
397
|
+
errors: {},
|
|
398
|
+
warnings: {},
|
|
399
|
+
amount: (_a = a.polkadotResources) === null || _a === void 0 ? void 0 : _a.unlockingBalance
|
|
400
|
+
});
|
|
401
|
+
}
|
|
402
|
+
},
|
|
403
|
+
]
|
|
404
|
+
},
|
|
405
|
+
{
|
|
406
|
+
raw: {
|
|
407
|
+
id: "js:2:polkadot:".concat(ACCOUNT_STASH, ":polkadotbip44"),
|
|
408
|
+
seedIdentifier: ACCOUNT_STASH,
|
|
409
|
+
name: "Polkadot 2",
|
|
410
|
+
derivationMode: "polkadotbip44",
|
|
411
|
+
index: 0,
|
|
412
|
+
freshAddress: ACCOUNT_STASH,
|
|
413
|
+
freshAddressPath: "44'/354'/2'/0'/0'",
|
|
414
|
+
freshAddresses: [],
|
|
415
|
+
blockHeight: 0,
|
|
416
|
+
operations: [],
|
|
417
|
+
pendingOperations: [],
|
|
418
|
+
currencyId: "polkadot",
|
|
419
|
+
unitMagnitude: 10,
|
|
420
|
+
lastSyncDate: "",
|
|
421
|
+
balance: "11000000000"
|
|
422
|
+
},
|
|
423
|
+
transactions: [
|
|
424
|
+
{
|
|
425
|
+
name: "[send] use all amount - should warn all funds",
|
|
426
|
+
transaction: function (t) { return (__assign(__assign({}, t), { useAllAmount: true, mode: "send", recipient: ACCOUNT_SAME_STASHCONTROLLER })); },
|
|
427
|
+
expectedStatus: function (account) { return ({
|
|
428
|
+
errors: {},
|
|
429
|
+
warnings: {
|
|
430
|
+
amount: new errors_2.PolkadotAllFundsWarning()
|
|
431
|
+
},
|
|
432
|
+
totalSpent: account.spendableBalance
|
|
433
|
+
}); }
|
|
434
|
+
},
|
|
435
|
+
{
|
|
436
|
+
name: "stash can't nominate",
|
|
437
|
+
transaction: (0, transaction_1.fromTransactionRaw)({
|
|
438
|
+
family: "polkadot",
|
|
439
|
+
recipient: ACCOUNT_SAME_STASHCONTROLLER,
|
|
440
|
+
amount: "0",
|
|
441
|
+
mode: "nominate",
|
|
442
|
+
era: null,
|
|
443
|
+
validators: [ACCOUNT_SAME_STASHCONTROLLER],
|
|
444
|
+
fees: null,
|
|
445
|
+
rewardDestination: null,
|
|
446
|
+
numSlashingSpans: 0
|
|
447
|
+
}),
|
|
448
|
+
expectedStatus: {
|
|
449
|
+
errors: {
|
|
450
|
+
staking: new errors_2.PolkadotUnauthorizedOperation()
|
|
451
|
+
},
|
|
452
|
+
warnings: {}
|
|
453
|
+
}
|
|
454
|
+
},
|
|
455
|
+
{
|
|
456
|
+
name: "[chill] unauthorized",
|
|
457
|
+
transaction: (0, transaction_1.fromTransactionRaw)({
|
|
458
|
+
family: "polkadot",
|
|
459
|
+
recipient: "",
|
|
460
|
+
amount: "1000",
|
|
461
|
+
mode: "chill",
|
|
462
|
+
era: null,
|
|
463
|
+
validators: [],
|
|
464
|
+
fees: null,
|
|
465
|
+
rewardDestination: null,
|
|
466
|
+
numSlashingSpans: 0
|
|
467
|
+
}),
|
|
468
|
+
expectedStatus: {
|
|
469
|
+
errors: {
|
|
470
|
+
staking: new errors_2.PolkadotUnauthorizedOperation()
|
|
471
|
+
},
|
|
472
|
+
warnings: {}
|
|
473
|
+
}
|
|
474
|
+
},
|
|
475
|
+
{
|
|
476
|
+
name: "[rebond] unauthorized",
|
|
477
|
+
transaction: (0, transaction_1.fromTransactionRaw)({
|
|
478
|
+
family: "polkadot",
|
|
479
|
+
recipient: "",
|
|
480
|
+
amount: "1000",
|
|
481
|
+
mode: "rebond",
|
|
482
|
+
era: null,
|
|
483
|
+
validators: [],
|
|
484
|
+
fees: null,
|
|
485
|
+
rewardDestination: null,
|
|
486
|
+
numSlashingSpans: 0
|
|
487
|
+
}),
|
|
488
|
+
expectedStatus: {
|
|
489
|
+
errors: {
|
|
490
|
+
staking: new errors_2.PolkadotUnauthorizedOperation()
|
|
491
|
+
},
|
|
492
|
+
warnings: {}
|
|
493
|
+
}
|
|
494
|
+
},
|
|
495
|
+
{
|
|
496
|
+
name: "[withdrawUnbonded] unauthorized",
|
|
497
|
+
transaction: (0, transaction_1.fromTransactionRaw)({
|
|
498
|
+
family: "polkadot",
|
|
499
|
+
recipient: "",
|
|
500
|
+
amount: "1000",
|
|
501
|
+
mode: "withdrawUnbonded",
|
|
502
|
+
era: null,
|
|
503
|
+
validators: [],
|
|
504
|
+
fees: null,
|
|
505
|
+
rewardDestination: null,
|
|
506
|
+
numSlashingSpans: 0
|
|
507
|
+
}),
|
|
508
|
+
expectedStatus: {
|
|
509
|
+
errors: {
|
|
510
|
+
staking: new errors_2.PolkadotUnauthorizedOperation()
|
|
511
|
+
},
|
|
512
|
+
warnings: {}
|
|
513
|
+
}
|
|
514
|
+
},
|
|
515
|
+
]
|
|
516
|
+
},
|
|
517
|
+
// TODO: Write a setController test
|
|
518
|
+
{
|
|
519
|
+
raw: {
|
|
520
|
+
id: "js:2:polkadot:".concat(ACCOUNT_CONTROLLER, ":polkadotbip44"),
|
|
521
|
+
seedIdentifier: ACCOUNT_CONTROLLER,
|
|
522
|
+
name: "Polkadot 3",
|
|
523
|
+
derivationMode: "polkadotbip44",
|
|
524
|
+
index: 0,
|
|
525
|
+
freshAddress: ACCOUNT_CONTROLLER,
|
|
526
|
+
freshAddressPath: "44'/354'/3'/0'/0'",
|
|
527
|
+
freshAddresses: [],
|
|
528
|
+
blockHeight: 0,
|
|
529
|
+
operations: [],
|
|
530
|
+
pendingOperations: [],
|
|
531
|
+
currencyId: "polkadot",
|
|
532
|
+
unitMagnitude: 10,
|
|
533
|
+
lastSyncDate: "",
|
|
534
|
+
balance: "11000000000"
|
|
535
|
+
},
|
|
536
|
+
transactions: [
|
|
537
|
+
{
|
|
538
|
+
name: "[send] Not enough balance",
|
|
539
|
+
transaction: (0, transaction_1.fromTransactionRaw)({
|
|
540
|
+
family: "polkadot",
|
|
541
|
+
recipient: ACCOUNT_SAME_STASHCONTROLLER,
|
|
542
|
+
amount: "12000000000",
|
|
543
|
+
mode: "send",
|
|
544
|
+
era: null,
|
|
545
|
+
validators: [],
|
|
546
|
+
fees: null,
|
|
547
|
+
rewardDestination: null,
|
|
548
|
+
numSlashingSpans: 0
|
|
549
|
+
}),
|
|
550
|
+
expectedStatus: {
|
|
551
|
+
errors: {
|
|
552
|
+
amount: new errors_1.NotEnoughBalance()
|
|
553
|
+
},
|
|
554
|
+
warnings: {}
|
|
555
|
+
}
|
|
556
|
+
},
|
|
557
|
+
{
|
|
558
|
+
name: "[send] Do Max Send Instead error",
|
|
559
|
+
transaction: (0, transaction_1.fromTransactionRaw)({
|
|
560
|
+
family: "polkadot",
|
|
561
|
+
recipient: ACCOUNT_SAME_STASHCONTROLLER,
|
|
562
|
+
amount: "5000000000",
|
|
563
|
+
mode: "send",
|
|
564
|
+
era: null,
|
|
565
|
+
validators: [],
|
|
566
|
+
fees: null,
|
|
567
|
+
rewardDestination: null,
|
|
568
|
+
numSlashingSpans: 0
|
|
569
|
+
}),
|
|
570
|
+
expectedStatus: {
|
|
571
|
+
errors: {
|
|
572
|
+
amount: new errors_2.PolkadotDoMaxSendInstead()
|
|
573
|
+
},
|
|
574
|
+
warnings: {}
|
|
575
|
+
}
|
|
576
|
+
},
|
|
577
|
+
{
|
|
578
|
+
name: "[send] use all amount no warn",
|
|
579
|
+
transaction: (0, transaction_1.fromTransactionRaw)({
|
|
580
|
+
family: "polkadot",
|
|
581
|
+
recipient: ACCOUNT_SAME_STASHCONTROLLER,
|
|
582
|
+
amount: "0",
|
|
583
|
+
useAllAmount: true,
|
|
584
|
+
mode: "send",
|
|
585
|
+
era: null,
|
|
586
|
+
validators: [],
|
|
587
|
+
fees: null,
|
|
588
|
+
rewardDestination: null,
|
|
589
|
+
numSlashingSpans: 0
|
|
590
|
+
}),
|
|
591
|
+
expectedStatus: {
|
|
592
|
+
errors: {},
|
|
593
|
+
warnings: {}
|
|
594
|
+
}
|
|
595
|
+
},
|
|
596
|
+
{
|
|
597
|
+
name: "[bond] no recipient",
|
|
598
|
+
transaction: (0, transaction_1.fromTransactionRaw)({
|
|
599
|
+
family: "polkadot",
|
|
600
|
+
recipient: "",
|
|
601
|
+
amount: "0",
|
|
602
|
+
mode: "bond",
|
|
603
|
+
era: null,
|
|
604
|
+
validators: [],
|
|
605
|
+
fees: null,
|
|
606
|
+
rewardDestination: null,
|
|
607
|
+
numSlashingSpans: 0
|
|
608
|
+
}),
|
|
609
|
+
expectedStatus: {
|
|
610
|
+
errors: {
|
|
611
|
+
recipient: new errors_1.RecipientRequired()
|
|
612
|
+
},
|
|
613
|
+
warnings: {}
|
|
614
|
+
}
|
|
615
|
+
},
|
|
616
|
+
{
|
|
617
|
+
name: "[bond] recipient with invalid address",
|
|
618
|
+
transaction: (0, transaction_1.fromTransactionRaw)({
|
|
619
|
+
family: "polkadot",
|
|
620
|
+
recipient: "not a valid address",
|
|
621
|
+
amount: "0",
|
|
622
|
+
mode: "bond",
|
|
623
|
+
era: null,
|
|
624
|
+
validators: [],
|
|
625
|
+
fees: null,
|
|
626
|
+
rewardDestination: null,
|
|
627
|
+
numSlashingSpans: 0
|
|
628
|
+
}),
|
|
629
|
+
expectedStatus: {
|
|
630
|
+
errors: {
|
|
631
|
+
recipient: new errors_1.InvalidAddress()
|
|
632
|
+
},
|
|
633
|
+
warnings: {}
|
|
634
|
+
}
|
|
635
|
+
},
|
|
636
|
+
{
|
|
637
|
+
name: "[bond] is already controller",
|
|
638
|
+
transaction: (0, transaction_1.fromTransactionRaw)({
|
|
639
|
+
family: "polkadot",
|
|
640
|
+
recipient: ACCOUNT_CONTROLLER,
|
|
641
|
+
amount: "100000000",
|
|
642
|
+
mode: "bond",
|
|
643
|
+
era: null,
|
|
644
|
+
validators: [],
|
|
645
|
+
fees: null,
|
|
646
|
+
rewardDestination: null,
|
|
647
|
+
numSlashingSpans: 0
|
|
648
|
+
}),
|
|
649
|
+
expectedStatus: {
|
|
650
|
+
errors: {
|
|
651
|
+
recipient: new errors_2.PolkadotUnauthorizedOperation("Recipient is already a controller")
|
|
652
|
+
},
|
|
653
|
+
warnings: {}
|
|
654
|
+
}
|
|
655
|
+
},
|
|
656
|
+
{
|
|
657
|
+
name: "[bond] not minimum amount",
|
|
658
|
+
transaction: (0, transaction_1.fromTransactionRaw)({
|
|
659
|
+
family: "polkadot",
|
|
660
|
+
recipient: ACCOUNT_CONTROLLER,
|
|
661
|
+
amount: "1000000",
|
|
662
|
+
mode: "bond",
|
|
663
|
+
era: null,
|
|
664
|
+
validators: [],
|
|
665
|
+
fees: null,
|
|
666
|
+
rewardDestination: null,
|
|
667
|
+
numSlashingSpans: 0
|
|
668
|
+
}),
|
|
669
|
+
expectedStatus: {
|
|
670
|
+
errors: {
|
|
671
|
+
amount: new errors_2.PolkadotBondMinimumAmount()
|
|
672
|
+
},
|
|
673
|
+
warnings: {}
|
|
674
|
+
}
|
|
675
|
+
},
|
|
676
|
+
{
|
|
677
|
+
name: "[bond] success",
|
|
678
|
+
transaction: (0, transaction_1.fromTransactionRaw)({
|
|
679
|
+
family: "polkadot",
|
|
680
|
+
recipient: ACCOUNT_CONTROLLER,
|
|
681
|
+
amount: "10000000000",
|
|
682
|
+
mode: "bond",
|
|
683
|
+
era: null,
|
|
684
|
+
validators: [],
|
|
685
|
+
fees: null,
|
|
686
|
+
rewardDestination: null,
|
|
687
|
+
numSlashingSpans: 0
|
|
688
|
+
}),
|
|
689
|
+
expectedStatus: {
|
|
690
|
+
errors: {},
|
|
691
|
+
warnings: {}
|
|
692
|
+
}
|
|
693
|
+
},
|
|
694
|
+
{
|
|
695
|
+
name: "[unbond] haveEnoughLockedBalance",
|
|
696
|
+
transaction: (0, transaction_1.fromTransactionRaw)({
|
|
697
|
+
family: "polkadot",
|
|
698
|
+
recipient: "",
|
|
699
|
+
amount: "100000",
|
|
700
|
+
mode: "unbond",
|
|
701
|
+
era: null,
|
|
702
|
+
validators: [],
|
|
703
|
+
fees: null,
|
|
704
|
+
rewardDestination: null,
|
|
705
|
+
numSlashingSpans: 0
|
|
706
|
+
}),
|
|
707
|
+
expectedStatus: {
|
|
708
|
+
errors: {
|
|
709
|
+
amount: new errors_1.NotEnoughBalance(),
|
|
710
|
+
staking: new errors_2.PolkadotUnauthorizedOperation()
|
|
711
|
+
},
|
|
712
|
+
warnings: {}
|
|
713
|
+
}
|
|
714
|
+
},
|
|
715
|
+
]
|
|
716
|
+
},
|
|
717
|
+
]
|
|
718
|
+
};
|
|
719
|
+
exports.dataset = {
|
|
720
|
+
implementations: ["js"],
|
|
721
|
+
currencies: {
|
|
722
|
+
polkadot: polkadot
|
|
723
|
+
}
|
|
724
|
+
};
|
|
725
|
+
// Disconnect all api clients that could be open.
|
|
726
|
+
afterAll(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
727
|
+
return __generator(this, function (_a) {
|
|
728
|
+
switch (_a.label) {
|
|
729
|
+
case 0: return [4 /*yield*/, (0, api_1.disconnect)()];
|
|
730
|
+
case 1:
|
|
731
|
+
_a.sent();
|
|
732
|
+
return [2 /*return*/];
|
|
733
|
+
}
|
|
734
|
+
});
|
|
735
|
+
}); });
|
|
736
|
+
describe("canUnbond", function () {
|
|
737
|
+
test("can unbond", function () {
|
|
738
|
+
var account = {
|
|
739
|
+
polkadotResources: {
|
|
740
|
+
controller: "",
|
|
741
|
+
stash: "",
|
|
742
|
+
nonce: 0,
|
|
743
|
+
numSlashingSpans: 0,
|
|
744
|
+
lockedBalance: new bignumber_js_1.BigNumber(10000),
|
|
745
|
+
unlockedBalance: new bignumber_js_1.BigNumber(0),
|
|
746
|
+
unlockingBalance: new bignumber_js_1.BigNumber(0),
|
|
747
|
+
nominations: [],
|
|
748
|
+
unlockings: __spreadArray([], __read(Array(logic_1.MAX_UNLOCKINGS - 1).map(function () { return ({
|
|
749
|
+
amount: new bignumber_js_1.BigNumber(100000),
|
|
750
|
+
completionDate: new Date()
|
|
751
|
+
}); })), false)
|
|
752
|
+
}
|
|
753
|
+
};
|
|
754
|
+
expect((0, logic_1.canUnbond)(account)).toBeTruthy();
|
|
755
|
+
});
|
|
756
|
+
test("can't unbond because unlockings is too much", function () {
|
|
757
|
+
var account = {
|
|
758
|
+
polkadotResources: {
|
|
759
|
+
controller: "",
|
|
760
|
+
stash: "",
|
|
761
|
+
nonce: 0,
|
|
762
|
+
numSlashingSpans: 0,
|
|
763
|
+
lockedBalance: new bignumber_js_1.BigNumber(1000000),
|
|
764
|
+
unlockedBalance: new bignumber_js_1.BigNumber(0),
|
|
765
|
+
unlockingBalance: new bignumber_js_1.BigNumber(0),
|
|
766
|
+
nominations: [],
|
|
767
|
+
unlockings: __spreadArray([], __read(Array(logic_1.MAX_UNLOCKINGS).map(function () { return ({
|
|
768
|
+
amount: new bignumber_js_1.BigNumber(100000),
|
|
769
|
+
completionDate: new Date()
|
|
770
|
+
}); })), false)
|
|
771
|
+
}
|
|
772
|
+
};
|
|
773
|
+
expect((0, logic_1.canUnbond)(account)).toBeFalsy();
|
|
774
|
+
});
|
|
775
|
+
test("can't unbond because not enough lockedBalance", function () {
|
|
776
|
+
var account = {
|
|
777
|
+
polkadotResources: {
|
|
778
|
+
controller: "",
|
|
779
|
+
stash: "",
|
|
780
|
+
nonce: 0,
|
|
781
|
+
numSlashingSpans: 0,
|
|
782
|
+
lockedBalance: new bignumber_js_1.BigNumber(100),
|
|
783
|
+
unlockedBalance: new bignumber_js_1.BigNumber(0),
|
|
784
|
+
unlockingBalance: new bignumber_js_1.BigNumber(100),
|
|
785
|
+
nominations: [],
|
|
786
|
+
unlockings: __spreadArray([], __read(Array(logic_1.MAX_UNLOCKINGS).map(function () { return ({
|
|
787
|
+
amount: new bignumber_js_1.BigNumber(100000),
|
|
788
|
+
completionDate: new Date()
|
|
789
|
+
}); })), false)
|
|
790
|
+
}
|
|
791
|
+
};
|
|
792
|
+
expect((0, logic_1.canUnbond)(account)).toBeFalsy();
|
|
793
|
+
});
|
|
794
|
+
});
|
|
795
|
+
//# sourceMappingURL=bridge.integration.test.js.map
|