@airgap/moonbeam 0.13.11-beta.0 → 0.13.11-beta.1
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/package.json +12 -9
- package/airgap-coinlib-moonbeam.min.js +0 -115369
- package/index.d.ts +0 -1
- package/index.js +0 -18
- package/index.js.map +0 -1
- package/v0/index.d.ts +0 -6
- package/v0/index.js +0 -37
- package/v0/index.js.map +0 -1
- package/v0/protocol/moonbase/MoonbaseProtocol.d.ts +0 -17
- package/v0/protocol/moonbase/MoonbaseProtocol.js +0 -75
- package/v0/protocol/moonbase/MoonbaseProtocol.js.map +0 -1
- package/v0/protocol/moonbase/MoonbaseProtocolOptions.d.ts +0 -21
- package/v0/protocol/moonbase/MoonbaseProtocolOptions.js +0 -80
- package/v0/protocol/moonbase/MoonbaseProtocolOptions.js.map +0 -1
- package/v0/protocol/moonbeam/MoonbeamProtocol.d.ts +0 -55
- package/v0/protocol/moonbeam/MoonbeamProtocol.js +0 -641
- package/v0/protocol/moonbeam/MoonbeamProtocol.js.map +0 -1
- package/v0/protocol/moonbeam/MoonbeamProtocolOptions.d.ts +0 -32
- package/v0/protocol/moonbeam/MoonbeamProtocolOptions.js +0 -104
- package/v0/protocol/moonbeam/MoonbeamProtocolOptions.js.map +0 -1
- package/v0/protocol/moonbeam/controllers/MoonbeamAccountController.d.ts +0 -28
- package/v0/protocol/moonbeam/controllers/MoonbeamAccountController.js +0 -551
- package/v0/protocol/moonbeam/controllers/MoonbeamAccountController.js.map +0 -1
- package/v0/protocol/moonbeam/controllers/MoonbeamTransactionController.d.ts +0 -9
- package/v0/protocol/moonbeam/controllers/MoonbeamTransactionController.js +0 -75
- package/v0/protocol/moonbeam/controllers/MoonbeamTransactionController.js.map +0 -1
- package/v0/protocol/moonbeam/data/staking/MoonbeamBond.d.ts +0 -13
- package/v0/protocol/moonbeam/data/staking/MoonbeamBond.js +0 -43
- package/v0/protocol/moonbeam/data/staking/MoonbeamBond.js.map +0 -1
- package/v0/protocol/moonbeam/data/staking/MoonbeamCandidateBondLessRequest.d.ts +0 -11
- package/v0/protocol/moonbeam/data/staking/MoonbeamCandidateBondLessRequest.js +0 -43
- package/v0/protocol/moonbeam/data/staking/MoonbeamCandidateBondLessRequest.js.map +0 -1
- package/v0/protocol/moonbeam/data/staking/MoonbeamCandidateMetadata.d.ts +0 -28
- package/v0/protocol/moonbeam/data/staking/MoonbeamCandidateMetadata.js +0 -49
- package/v0/protocol/moonbeam/data/staking/MoonbeamCandidateMetadata.js.map +0 -1
- package/v0/protocol/moonbeam/data/staking/MoonbeamCollatorDetails.d.ts +0 -9
- package/v0/protocol/moonbeam/data/staking/MoonbeamCollatorDetails.js +0 -3
- package/v0/protocol/moonbeam/data/staking/MoonbeamCollatorDetails.js.map +0 -1
- package/v0/protocol/moonbeam/data/staking/MoonbeamDelegationDetails.d.ts +0 -13
- package/v0/protocol/moonbeam/data/staking/MoonbeamDelegationDetails.js +0 -3
- package/v0/protocol/moonbeam/data/staking/MoonbeamDelegationDetails.js.map +0 -1
- package/v0/protocol/moonbeam/data/staking/MoonbeamDelegationScheduledRequests.d.ts +0 -46
- package/v0/protocol/moonbeam/data/staking/MoonbeamDelegationScheduledRequests.js +0 -148
- package/v0/protocol/moonbeam/data/staking/MoonbeamDelegationScheduledRequests.js.map +0 -1
- package/v0/protocol/moonbeam/data/staking/MoonbeamDelegator.d.ts +0 -40
- package/v0/protocol/moonbeam/data/staking/MoonbeamDelegator.js +0 -132
- package/v0/protocol/moonbeam/data/staking/MoonbeamDelegator.js.map +0 -1
- package/v0/protocol/moonbeam/data/staking/MoonbeamDelegatorDetails.d.ts +0 -5
- package/v0/protocol/moonbeam/data/staking/MoonbeamDelegatorDetails.js +0 -3
- package/v0/protocol/moonbeam/data/staking/MoonbeamDelegatorDetails.js.map +0 -1
- package/v0/protocol/moonbeam/data/staking/MoonbeamRoundInfo.d.ts +0 -8
- package/v0/protocol/moonbeam/data/staking/MoonbeamRoundInfo.js +0 -22
- package/v0/protocol/moonbeam/data/staking/MoonbeamRoundInfo.js.map +0 -1
- package/v0/protocol/moonbeam/data/staking/MoonbeamStakingActionType.d.ts +0 -13
- package/v0/protocol/moonbeam/data/staking/MoonbeamStakingActionType.js +0 -18
- package/v0/protocol/moonbeam/data/staking/MoonbeamStakingActionType.js.map +0 -1
- package/v0/protocol/moonbeam/node/MoonbeamNodeClient.d.ts +0 -26
- package/v0/protocol/moonbeam/node/MoonbeamNodeClient.js +0 -220
- package/v0/protocol/moonbeam/node/MoonbeamNodeClient.js.map +0 -1
- package/v0/protocol/moonriver/MoonriverProtocol.d.ts +0 -17
- package/v0/protocol/moonriver/MoonriverProtocol.js +0 -75
- package/v0/protocol/moonriver/MoonriverProtocol.js.map +0 -1
- package/v0/protocol/moonriver/MoonriverProtocolOptions.d.ts +0 -21
- package/v0/protocol/moonriver/MoonriverProtocolOptions.js +0 -80
- package/v0/protocol/moonriver/MoonriverProtocolOptions.js.map +0 -1
- package/v1/block-explorer/SubscanBlockExplorer.d.ts +0 -4
- package/v1/block-explorer/SubscanBlockExplorer.js +0 -21
- package/v1/block-explorer/SubscanBlockExplorer.js.map +0 -1
- package/v1/controller/MoonbeamAccountController.d.ts +0 -22
- package/v1/controller/MoonbeamAccountController.js +0 -494
- package/v1/controller/MoonbeamAccountController.js.map +0 -1
- package/v1/controller/MoonbeamTransactionController.d.ts +0 -5
- package/v1/controller/MoonbeamTransactionController.js +0 -28
- package/v1/controller/MoonbeamTransactionController.js.map +0 -1
- package/v1/data/staking/MoonbeamBond.d.ts +0 -9
- package/v1/data/staking/MoonbeamBond.js +0 -41
- package/v1/data/staking/MoonbeamBond.js.map +0 -1
- package/v1/data/staking/MoonbeamCandidateBondLessRequest.d.ts +0 -9
- package/v1/data/staking/MoonbeamCandidateBondLessRequest.js +0 -41
- package/v1/data/staking/MoonbeamCandidateBondLessRequest.js.map +0 -1
- package/v1/data/staking/MoonbeamCandidateMetadata.d.ts +0 -27
- package/v1/data/staking/MoonbeamCandidateMetadata.js +0 -50
- package/v1/data/staking/MoonbeamCandidateMetadata.js.map +0 -1
- package/v1/data/staking/MoonbeamCollatorDetails.d.ts +0 -9
- package/v1/data/staking/MoonbeamCollatorDetails.js +0 -3
- package/v1/data/staking/MoonbeamCollatorDetails.js.map +0 -1
- package/v1/data/staking/MoonbeamDelegationDetails.d.ts +0 -13
- package/v1/data/staking/MoonbeamDelegationDetails.js +0 -3
- package/v1/data/staking/MoonbeamDelegationDetails.js.map +0 -1
- package/v1/data/staking/MoonbeamDelegationScheduledRequests.d.ts +0 -40
- package/v1/data/staking/MoonbeamDelegationScheduledRequests.js +0 -148
- package/v1/data/staking/MoonbeamDelegationScheduledRequests.js.map +0 -1
- package/v1/data/staking/MoonbeamDelegator.d.ts +0 -35
- package/v1/data/staking/MoonbeamDelegator.js +0 -132
- package/v1/data/staking/MoonbeamDelegator.js.map +0 -1
- package/v1/data/staking/MoonbeamDelegatorDetails.d.ts +0 -5
- package/v1/data/staking/MoonbeamDelegatorDetails.js +0 -3
- package/v1/data/staking/MoonbeamDelegatorDetails.js.map +0 -1
- package/v1/data/staking/MoonbeamRoundInfo.d.ts +0 -9
- package/v1/data/staking/MoonbeamRoundInfo.js +0 -21
- package/v1/data/staking/MoonbeamRoundInfo.js.map +0 -1
- package/v1/data/staking/MoonbeamStakingActionType.d.ts +0 -13
- package/v1/data/staking/MoonbeamStakingActionType.js +0 -18
- package/v1/data/staking/MoonbeamStakingActionType.js.map +0 -1
- package/v1/data/transaction/method/args.d.ts +0 -2
- package/v1/data/transaction/method/args.js +0 -475
- package/v1/data/transaction/method/args.js.map +0 -1
- package/v1/data/transaction/transaction.d.ts +0 -2
- package/v1/data/transaction/transaction.js +0 -29
- package/v1/data/transaction/transaction.js.map +0 -1
- package/v1/index.d.ts +0 -11
- package/v1/index.js +0 -16
- package/v1/index.js.map +0 -1
- package/v1/module/MoonbeamModule.d.ts +0 -17
- package/v1/module/MoonbeamModule.js +0 -121
- package/v1/module/MoonbeamModule.js.map +0 -1
- package/v1/module.d.ts +0 -3
- package/v1/module.js +0 -24
- package/v1/module.js.map +0 -1
- package/v1/node/MoonbeamNodeClient.d.ts +0 -35
- package/v1/node/MoonbeamNodeClient.js +0 -269
- package/v1/node/MoonbeamNodeClient.js.map +0 -1
- package/v1/protocol/MoonbaseProtocol.d.ts +0 -14
- package/v1/protocol/MoonbaseProtocol.js +0 -110
- package/v1/protocol/MoonbaseProtocol.js.map +0 -1
- package/v1/protocol/MoonbeamBaseProtocol.d.ts +0 -27
- package/v1/protocol/MoonbeamBaseProtocol.js +0 -432
- package/v1/protocol/MoonbeamBaseProtocol.js.map +0 -1
- package/v1/protocol/MoonbeamProtocol.d.ts +0 -14
- package/v1/protocol/MoonbeamProtocol.js +0 -125
- package/v1/protocol/MoonbeamProtocol.js.map +0 -1
- package/v1/protocol/MoonriverProtocol.d.ts +0 -14
- package/v1/protocol/MoonriverProtocol.js +0 -110
- package/v1/protocol/MoonriverProtocol.js.map +0 -1
- package/v1/serializer/v3/schemas/converter/transaction-converter.d.ts +0 -7
- package/v1/serializer/v3/schemas/converter/transaction-converter.js +0 -21
- package/v1/serializer/v3/schemas/converter/transaction-converter.js.map +0 -1
- package/v1/serializer/v3/schemas/definitions/transaction-sign-request-moonbeam.d.ts +0 -3
- package/v1/serializer/v3/schemas/definitions/transaction-sign-request-moonbeam.js +0 -3
- package/v1/serializer/v3/schemas/definitions/transaction-sign-request-moonbeam.js.map +0 -1
- package/v1/serializer/v3/schemas/definitions/transaction-sign-response-moonbeam.d.ts +0 -3
- package/v1/serializer/v3/schemas/definitions/transaction-sign-response-moonbeam.js +0 -3
- package/v1/serializer/v3/schemas/definitions/transaction-sign-response-moonbeam.js.map +0 -1
- package/v1/serializer/v3/schemas/generated/transaction-sign-request-moonbeam.json +0 -36
- package/v1/serializer/v3/schemas/generated/transaction-sign-response-moonbeam.json +0 -19
- package/v1/serializer/v3/serializer-companion.d.ts +0 -14
- package/v1/serializer/v3/serializer-companion.js +0 -189
- package/v1/serializer/v3/serializer-companion.js.map +0 -1
- package/v1/serializer/v3/validators/transaction-validator.d.ts +0 -4
- package/v1/serializer/v3/validators/transaction-validator.js +0 -28
- package/v1/serializer/v3/validators/transaction-validator.js.map +0 -1
- package/v1/serializer/v3/validators/validators.d.ts +0 -4
- package/v1/serializer/v3/validators/validators.js +0 -6
- package/v1/serializer/v3/validators/validators.js.map +0 -1
- package/v1/types/configuration.d.ts +0 -11
- package/v1/types/configuration.js +0 -3
- package/v1/types/configuration.js.map +0 -1
- package/v1/types/protocol.d.ts +0 -13
- package/v1/types/protocol.js +0 -3
- package/v1/types/protocol.js.map +0 -1
|
@@ -1,641 +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
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
-
});
|
|
25
|
-
};
|
|
26
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
27
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
28
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
29
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
30
|
-
function step(op) {
|
|
31
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
32
|
-
while (_) try {
|
|
33
|
-
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;
|
|
34
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
35
|
-
switch (op[0]) {
|
|
36
|
-
case 0: case 1: t = op; break;
|
|
37
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
38
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
39
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
40
|
-
default:
|
|
41
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
42
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
43
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
44
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
45
|
-
if (t[2]) _.ops.pop();
|
|
46
|
-
_.trys.pop(); continue;
|
|
47
|
-
}
|
|
48
|
-
op = body.call(thisArg, _);
|
|
49
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
50
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
|
-
exports.MoonbeamProtocol = void 0;
|
|
55
|
-
var bignumber_1 = require("@airgap/coinlib-core/dependencies/src/bignumber.js-9.0.0/bignumber");
|
|
56
|
-
var errors_1 = require("@airgap/coinlib-core/errors");
|
|
57
|
-
var coinlib_error_1 = require("@airgap/coinlib-core/errors/coinlib-error");
|
|
58
|
-
var assert_1 = require("@airgap/coinlib-core/utils/assert");
|
|
59
|
-
var ProtocolSymbols_1 = require("@airgap/coinlib-core/utils/ProtocolSymbols");
|
|
60
|
-
var SubstrateTransaction_1 = require("@airgap/substrate/v0/protocol/common/data/transaction/SubstrateTransaction");
|
|
61
|
-
var MoonbeamAddress_1 = require("@airgap/substrate/v0/protocol/moonbeam/MoonbeamAddress");
|
|
62
|
-
var SubstrateDelegateProtocol_1 = require("@airgap/substrate/v0/protocol/SubstrateDelegateProtocol");
|
|
63
|
-
var MoonbeamStakingActionType_1 = require("./data/staking/MoonbeamStakingActionType");
|
|
64
|
-
var MoonbeamProtocolOptions_1 = require("./MoonbeamProtocolOptions");
|
|
65
|
-
var MoonbeamProtocol = /** @class */ (function (_super) {
|
|
66
|
-
__extends(MoonbeamProtocol, _super);
|
|
67
|
-
function MoonbeamProtocol(options) {
|
|
68
|
-
if (options === void 0) { options = new MoonbeamProtocolOptions_1.MoonbeamProtocolOptions(new MoonbeamProtocolOptions_1.MoonbeamProtocolNetwork()); }
|
|
69
|
-
var _this = _super.call(this, options) || this;
|
|
70
|
-
_this.options = options;
|
|
71
|
-
_this.symbol = 'GLMR';
|
|
72
|
-
_this.name = 'Moonbeam';
|
|
73
|
-
_this.marketSymbol = 'GLMR';
|
|
74
|
-
_this.feeSymbol = 'GLMR';
|
|
75
|
-
_this.decimals = 18;
|
|
76
|
-
_this.feeDecimals = 18;
|
|
77
|
-
_this.identifier = ProtocolSymbols_1.MainProtocolSymbols.MOONBEAM;
|
|
78
|
-
_this.feeDefaults = {
|
|
79
|
-
low: '0.000000000125',
|
|
80
|
-
medium: '0.000000000125',
|
|
81
|
-
high: '0.000000000125'
|
|
82
|
-
};
|
|
83
|
-
_this.units = [
|
|
84
|
-
{
|
|
85
|
-
unitSymbol: 'GLMR',
|
|
86
|
-
factor: '1'
|
|
87
|
-
},
|
|
88
|
-
{
|
|
89
|
-
unitSymbol: 'mGLMR',
|
|
90
|
-
factor: '0.001'
|
|
91
|
-
},
|
|
92
|
-
{
|
|
93
|
-
unitSymbol: 'uGLMR',
|
|
94
|
-
factor: '0.000001'
|
|
95
|
-
},
|
|
96
|
-
{
|
|
97
|
-
unitSymbol: 'GWEI',
|
|
98
|
-
factor: '0.000000001'
|
|
99
|
-
},
|
|
100
|
-
{
|
|
101
|
-
unitSymbol: 'MWEI',
|
|
102
|
-
factor: '0.000000000001'
|
|
103
|
-
},
|
|
104
|
-
{
|
|
105
|
-
unitSymbol: 'kWEI',
|
|
106
|
-
factor: '0.000000000000001'
|
|
107
|
-
},
|
|
108
|
-
{
|
|
109
|
-
unitSymbol: 'WEI',
|
|
110
|
-
factor: '0.000000000000000001'
|
|
111
|
-
}
|
|
112
|
-
];
|
|
113
|
-
_this.standardDerivationPath = "m/44'/60'/0'/0/0";
|
|
114
|
-
_this.addressIsCaseSensitive = false;
|
|
115
|
-
_this.addressValidationPattern = '^0x[a-fA-F0-9]{40}$';
|
|
116
|
-
_this.addressPlaceholder = "0xabc...";
|
|
117
|
-
return _this;
|
|
118
|
-
}
|
|
119
|
-
MoonbeamProtocol.prototype.getDefaultDelegatee = function () {
|
|
120
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
121
|
-
var collators;
|
|
122
|
-
return __generator(this, function (_a) {
|
|
123
|
-
switch (_a.label) {
|
|
124
|
-
case 0:
|
|
125
|
-
if (this.defaultValidator) {
|
|
126
|
-
return [2 /*return*/, this.defaultValidator];
|
|
127
|
-
}
|
|
128
|
-
return [4 /*yield*/, this.options.nodeClient.getCollators()];
|
|
129
|
-
case 1:
|
|
130
|
-
collators = _a.sent();
|
|
131
|
-
return [2 /*return*/, collators ? collators[0].asString() : ''];
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
});
|
|
135
|
-
};
|
|
136
|
-
MoonbeamProtocol.prototype.getCurrentDelegateesForPublicKey = function (publicKey) {
|
|
137
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
138
|
-
return __generator(this, function (_a) {
|
|
139
|
-
return [2 /*return*/, this.options.accountController.getCurrentCollators(publicKey)];
|
|
140
|
-
});
|
|
141
|
-
});
|
|
142
|
-
};
|
|
143
|
-
MoonbeamProtocol.prototype.getCurrentDelegateesForAddress = function (address) {
|
|
144
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
145
|
-
return __generator(this, function (_a) {
|
|
146
|
-
return [2 /*return*/, this.options.accountController.getCurrentCollators(address)];
|
|
147
|
-
});
|
|
148
|
-
});
|
|
149
|
-
};
|
|
150
|
-
MoonbeamProtocol.prototype.getDelegateeDetails = function (address) {
|
|
151
|
-
var _a, _b;
|
|
152
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
153
|
-
var collatorDetails;
|
|
154
|
-
return __generator(this, function (_c) {
|
|
155
|
-
switch (_c.label) {
|
|
156
|
-
case 0: return [4 /*yield*/, this.options.accountController.getCollatorDetails(address)];
|
|
157
|
-
case 1:
|
|
158
|
-
collatorDetails = _c.sent();
|
|
159
|
-
return [2 /*return*/, {
|
|
160
|
-
name: (_a = collatorDetails.name) !== null && _a !== void 0 ? _a : '',
|
|
161
|
-
status: (_b = collatorDetails.status) !== null && _b !== void 0 ? _b : '',
|
|
162
|
-
address: collatorDetails.address
|
|
163
|
-
}];
|
|
164
|
-
}
|
|
165
|
-
});
|
|
166
|
-
});
|
|
167
|
-
};
|
|
168
|
-
MoonbeamProtocol.prototype.isPublicKeyDelegating = function (publicKey) {
|
|
169
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
170
|
-
return __generator(this, function (_a) {
|
|
171
|
-
return [2 /*return*/, this.options.accountController.isDelegating(publicKey)];
|
|
172
|
-
});
|
|
173
|
-
});
|
|
174
|
-
};
|
|
175
|
-
MoonbeamProtocol.prototype.isAddressDelegating = function (address) {
|
|
176
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
177
|
-
return __generator(this, function (_a) {
|
|
178
|
-
return [2 /*return*/, this.options.accountController.isDelegating(address)];
|
|
179
|
-
});
|
|
180
|
-
});
|
|
181
|
-
};
|
|
182
|
-
MoonbeamProtocol.prototype.getDelegatorDetailsFromPublicKey = function (publicKey) {
|
|
183
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
184
|
-
return __generator(this, function (_a) {
|
|
185
|
-
return [2 /*return*/, this.options.accountController.getDelegatorDetails(publicKey)];
|
|
186
|
-
});
|
|
187
|
-
});
|
|
188
|
-
};
|
|
189
|
-
MoonbeamProtocol.prototype.getDelegatorDetailsFromAddress = function (address) {
|
|
190
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
191
|
-
return __generator(this, function (_a) {
|
|
192
|
-
return [2 /*return*/, this.options.accountController.getDelegatorDetails(address)];
|
|
193
|
-
});
|
|
194
|
-
});
|
|
195
|
-
};
|
|
196
|
-
MoonbeamProtocol.prototype.getDelegationDetailsFromPublicKey = function (publicKey, delegatees) {
|
|
197
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
198
|
-
var address;
|
|
199
|
-
return __generator(this, function (_a) {
|
|
200
|
-
switch (_a.label) {
|
|
201
|
-
case 0: return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)];
|
|
202
|
-
case 1:
|
|
203
|
-
address = _a.sent();
|
|
204
|
-
return [2 /*return*/, this.getDelegationDetailsFromAddress(address.address, delegatees)];
|
|
205
|
-
}
|
|
206
|
-
});
|
|
207
|
-
});
|
|
208
|
-
};
|
|
209
|
-
MoonbeamProtocol.prototype.getDelegationDetailsFromAddress = function (address, delegatees) {
|
|
210
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
211
|
-
var collator, delegationDetails;
|
|
212
|
-
return __generator(this, function (_a) {
|
|
213
|
-
switch (_a.label) {
|
|
214
|
-
case 0:
|
|
215
|
-
if (delegatees.length > 1) {
|
|
216
|
-
throw new errors_1.UnsupportedError(coinlib_error_1.Domain.SUBSTRATE, 'Multiple validators for a single delegation are not supported');
|
|
217
|
-
}
|
|
218
|
-
collator = delegatees[0];
|
|
219
|
-
return [4 /*yield*/, this.options.accountController.getDelegationDetails(address, collator)];
|
|
220
|
-
case 1:
|
|
221
|
-
delegationDetails = _a.sent();
|
|
222
|
-
return [2 /*return*/, {
|
|
223
|
-
delegator: delegationDetails.delegatorDetails,
|
|
224
|
-
delegatees: [delegationDetails.collatorDetails]
|
|
225
|
-
}];
|
|
226
|
-
}
|
|
227
|
-
});
|
|
228
|
-
});
|
|
229
|
-
};
|
|
230
|
-
MoonbeamProtocol.prototype.prepareDelegatorActionFromPublicKey = function (publicKey, type, data) {
|
|
231
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
232
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
233
|
-
return __generator(this, function (_m) {
|
|
234
|
-
if (!data) {
|
|
235
|
-
data = {};
|
|
236
|
-
}
|
|
237
|
-
switch (type) {
|
|
238
|
-
case MoonbeamStakingActionType_1.MoonbeamStakingActionType.DELEGATE:
|
|
239
|
-
(0, assert_1.assertFields)("".concat(type, " action"), data, 'candidate', 'amount');
|
|
240
|
-
return [2 /*return*/, this.prepareDelegation(publicKey, (_a = data.tip) !== null && _a !== void 0 ? _a : 0, data.candidate, data.amount)];
|
|
241
|
-
case MoonbeamStakingActionType_1.MoonbeamStakingActionType.BOND_MORE:
|
|
242
|
-
(0, assert_1.assertFields)("".concat(type, " action"), data, 'candidate', 'more');
|
|
243
|
-
return [2 /*return*/, this.prepareDelegatorBondMore(publicKey, (_b = data.tip) !== null && _b !== void 0 ? _b : 0, data.candidate, data.more)];
|
|
244
|
-
case MoonbeamStakingActionType_1.MoonbeamStakingActionType.SCHEDULE_BOND_LESS:
|
|
245
|
-
(0, assert_1.assertFields)("".concat(type, " action"), data, 'candidate', 'less');
|
|
246
|
-
return [2 /*return*/, this.prepareScheduleDelegatorBondLess(publicKey, (_c = data.tip) !== null && _c !== void 0 ? _c : 0, data.candidate, data.less)];
|
|
247
|
-
case MoonbeamStakingActionType_1.MoonbeamStakingActionType.EXECUTE_BOND_LESS:
|
|
248
|
-
(0, assert_1.assertFields)("".concat(type, " action"), data, 'candidate');
|
|
249
|
-
return [2 /*return*/, this.prepareExecuteDelegatorBondLess(publicKey, (_d = data.tip) !== null && _d !== void 0 ? _d : 0, data.candidate)];
|
|
250
|
-
case MoonbeamStakingActionType_1.MoonbeamStakingActionType.CANCEL_BOND_LESS:
|
|
251
|
-
(0, assert_1.assertFields)("".concat(type, " action"), data, 'candidate');
|
|
252
|
-
return [2 /*return*/, this.prepareCancelDelegatorBondLess(publicKey, (_e = data.tip) !== null && _e !== void 0 ? _e : 0, data.candidate)];
|
|
253
|
-
case MoonbeamStakingActionType_1.MoonbeamStakingActionType.SCHEDULE_UNDELEGATE:
|
|
254
|
-
(0, assert_1.assertFields)("".concat(type, " action"), data, 'collator');
|
|
255
|
-
return [2 /*return*/, this.prepareScheduleUndelegate(publicKey, (_f = data.tip) !== null && _f !== void 0 ? _f : 0, data.collator)];
|
|
256
|
-
case MoonbeamStakingActionType_1.MoonbeamStakingActionType.EXECUTE_UNDELEGATE:
|
|
257
|
-
(0, assert_1.assertFields)("".concat(type, " action"), data, 'candidate');
|
|
258
|
-
return [2 /*return*/, this.prepareExecuteUndelegate(publicKey, (_g = data.tip) !== null && _g !== void 0 ? _g : 0, data.candidate)];
|
|
259
|
-
case MoonbeamStakingActionType_1.MoonbeamStakingActionType.CANCEL_UNDELEGATE:
|
|
260
|
-
(0, assert_1.assertFields)("".concat(type, " action"), data, 'candidate');
|
|
261
|
-
return [2 /*return*/, this.prepareCancelUndelegate(publicKey, (_h = data.tip) !== null && _h !== void 0 ? _h : 0, data.candidate)];
|
|
262
|
-
case MoonbeamStakingActionType_1.MoonbeamStakingActionType.SCHEDULE_UNDELEGATE_ALL:
|
|
263
|
-
return [2 /*return*/, this.prepareScheduleUndelegateAll(publicKey, (_j = data.tip) !== null && _j !== void 0 ? _j : 0)];
|
|
264
|
-
case MoonbeamStakingActionType_1.MoonbeamStakingActionType.EXECUTE_UNDELEGATE_ALL:
|
|
265
|
-
return [2 /*return*/, this.prepareExecuteUndelegateAll(publicKey, (_k = data.tip) !== null && _k !== void 0 ? _k : 0)];
|
|
266
|
-
case MoonbeamStakingActionType_1.MoonbeamStakingActionType.CANCEL_UNDELEGATE_ALL:
|
|
267
|
-
return [2 /*return*/, this.prepareCancelUndelegateAll(publicKey, (_l = data.tip) !== null && _l !== void 0 ? _l : 0)];
|
|
268
|
-
default:
|
|
269
|
-
throw new errors_1.UnsupportedError(coinlib_error_1.Domain.SUBSTRATE, 'Unsupported delegator action.');
|
|
270
|
-
}
|
|
271
|
-
return [2 /*return*/];
|
|
272
|
-
});
|
|
273
|
-
});
|
|
274
|
-
};
|
|
275
|
-
MoonbeamProtocol.prototype.prepareDelegation = function (publicKey, tip, candidate, amount) {
|
|
276
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
277
|
-
var requestedAmount, minAmount, results, delegatorDetails, collatorDetails, maxDelegations, balance, available, encoded;
|
|
278
|
-
return __generator(this, function (_a) {
|
|
279
|
-
switch (_a.label) {
|
|
280
|
-
case 0:
|
|
281
|
-
requestedAmount = new bignumber_1.BigNumber(amount);
|
|
282
|
-
return [4 /*yield*/, this.getMinDelegationAmount(publicKey)];
|
|
283
|
-
case 1:
|
|
284
|
-
minAmount = _a.sent();
|
|
285
|
-
if (requestedAmount.lt(minAmount)) {
|
|
286
|
-
throw new errors_1.ConditionViolationError(coinlib_error_1.Domain.SUBSTRATE, "The amount is too low, it has to be at least ".concat(minAmount.toString()));
|
|
287
|
-
}
|
|
288
|
-
return [4 /*yield*/, Promise.all([
|
|
289
|
-
this.options.accountController.getDelegatorDetails(publicKey),
|
|
290
|
-
this.options.accountController.getCollatorDetails(candidate),
|
|
291
|
-
this.options.nodeClient.getMaxDelegationsPerDelegator(),
|
|
292
|
-
this.getBalanceOfPublicKey(publicKey)
|
|
293
|
-
])];
|
|
294
|
-
case 2:
|
|
295
|
-
results = _a.sent();
|
|
296
|
-
delegatorDetails = results[0];
|
|
297
|
-
collatorDetails = results[1];
|
|
298
|
-
maxDelegations = results[2];
|
|
299
|
-
balance = results[3];
|
|
300
|
-
if (maxDelegations === null || maxDelegations === void 0 ? void 0 : maxDelegations.lte(delegatorDetails.delegatees.length)) {
|
|
301
|
-
throw new errors_1.ConditionViolationError(coinlib_error_1.Domain.SUBSTRATE, 'This delegator cannot nominate more collators.');
|
|
302
|
-
}
|
|
303
|
-
available = new bignumber_1.BigNumber(balance).minus(amount);
|
|
304
|
-
return [4 /*yield*/, this.options.transactionController.prepareSubmittableTransactions(publicKey, available, [
|
|
305
|
-
{
|
|
306
|
-
type: SubstrateTransaction_1.SubstrateTransactionType.M_DELEGATE,
|
|
307
|
-
tip: tip,
|
|
308
|
-
args: {
|
|
309
|
-
candidate: candidate,
|
|
310
|
-
amount: new bignumber_1.BigNumber(amount),
|
|
311
|
-
candidateDelegationCount: collatorDetails.delegators,
|
|
312
|
-
delegationCount: delegatorDetails.delegatees.length
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
])];
|
|
316
|
-
case 3:
|
|
317
|
-
encoded = _a.sent();
|
|
318
|
-
return [2 /*return*/, [{ encoded: encoded }]];
|
|
319
|
-
}
|
|
320
|
-
});
|
|
321
|
-
});
|
|
322
|
-
};
|
|
323
|
-
MoonbeamProtocol.prototype.prepareScheduleUndelegate = function (publicKey, tip, collator) {
|
|
324
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
325
|
-
var balance, encoded;
|
|
326
|
-
return __generator(this, function (_a) {
|
|
327
|
-
switch (_a.label) {
|
|
328
|
-
case 0: return [4 /*yield*/, this.getBalanceOfPublicKey(publicKey)];
|
|
329
|
-
case 1:
|
|
330
|
-
balance = _a.sent();
|
|
331
|
-
return [4 /*yield*/, this.options.transactionController.prepareSubmittableTransactions(publicKey, balance, [
|
|
332
|
-
{
|
|
333
|
-
type: SubstrateTransaction_1.SubstrateTransactionType.M_SCHEDULE_REVOKE_DELGATION,
|
|
334
|
-
tip: tip,
|
|
335
|
-
args: {
|
|
336
|
-
collator: collator
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
])];
|
|
340
|
-
case 2:
|
|
341
|
-
encoded = _a.sent();
|
|
342
|
-
return [2 /*return*/, [{ encoded: encoded }]];
|
|
343
|
-
}
|
|
344
|
-
});
|
|
345
|
-
});
|
|
346
|
-
};
|
|
347
|
-
MoonbeamProtocol.prototype.prepareExecuteUndelegate = function (publicKey, tip, candidate) {
|
|
348
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
349
|
-
return __generator(this, function (_a) {
|
|
350
|
-
return [2 /*return*/, this.prepareExecuteDelegationRequest(publicKey, tip, candidate)];
|
|
351
|
-
});
|
|
352
|
-
});
|
|
353
|
-
};
|
|
354
|
-
MoonbeamProtocol.prototype.prepareCancelUndelegate = function (publicKey, tip, candidate) {
|
|
355
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
356
|
-
return __generator(this, function (_a) {
|
|
357
|
-
return [2 /*return*/, this.prepareCancelDelegationRequest(publicKey, tip, candidate)];
|
|
358
|
-
});
|
|
359
|
-
});
|
|
360
|
-
};
|
|
361
|
-
MoonbeamProtocol.prototype.prepareScheduleUndelegateAll = function (publicKey, tip) {
|
|
362
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
363
|
-
var balance, encoded;
|
|
364
|
-
return __generator(this, function (_a) {
|
|
365
|
-
switch (_a.label) {
|
|
366
|
-
case 0: return [4 /*yield*/, this.getBalanceOfPublicKey(publicKey)];
|
|
367
|
-
case 1:
|
|
368
|
-
balance = _a.sent();
|
|
369
|
-
return [4 /*yield*/, this.options.transactionController.prepareSubmittableTransactions(publicKey, balance, [
|
|
370
|
-
{
|
|
371
|
-
type: SubstrateTransaction_1.SubstrateTransactionType.M_SCHEDULE_LEAVE_DELEGATORS,
|
|
372
|
-
tip: tip,
|
|
373
|
-
args: {}
|
|
374
|
-
}
|
|
375
|
-
])];
|
|
376
|
-
case 2:
|
|
377
|
-
encoded = _a.sent();
|
|
378
|
-
return [2 /*return*/, [{ encoded: encoded }]];
|
|
379
|
-
}
|
|
380
|
-
});
|
|
381
|
-
});
|
|
382
|
-
};
|
|
383
|
-
MoonbeamProtocol.prototype.prepareExecuteUndelegateAll = function (publicKey, tip) {
|
|
384
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
385
|
-
var results, delegatorDetails, balance, delegator, encoded;
|
|
386
|
-
return __generator(this, function (_a) {
|
|
387
|
-
switch (_a.label) {
|
|
388
|
-
case 0: return [4 /*yield*/, Promise.all([
|
|
389
|
-
this.options.accountController.getDelegatorDetails(publicKey),
|
|
390
|
-
this.getBalanceOfPublicKey(publicKey),
|
|
391
|
-
this.getAddressFromPublicKey(publicKey)
|
|
392
|
-
])];
|
|
393
|
-
case 1:
|
|
394
|
-
results = _a.sent();
|
|
395
|
-
delegatorDetails = results[0];
|
|
396
|
-
balance = results[1];
|
|
397
|
-
delegator = results[2].address;
|
|
398
|
-
return [4 /*yield*/, this.options.transactionController.prepareSubmittableTransactions(publicKey, balance, [
|
|
399
|
-
{
|
|
400
|
-
type: SubstrateTransaction_1.SubstrateTransactionType.M_EXECUTE_LEAVE_DELEGATORS,
|
|
401
|
-
tip: tip,
|
|
402
|
-
args: {
|
|
403
|
-
delegator: delegator,
|
|
404
|
-
delegationCount: delegatorDetails.delegatees.length
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
])];
|
|
408
|
-
case 2:
|
|
409
|
-
encoded = _a.sent();
|
|
410
|
-
return [2 /*return*/, [{ encoded: encoded }]];
|
|
411
|
-
}
|
|
412
|
-
});
|
|
413
|
-
});
|
|
414
|
-
};
|
|
415
|
-
MoonbeamProtocol.prototype.prepareCancelUndelegateAll = function (publicKey, tip) {
|
|
416
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
417
|
-
var balance, encoded;
|
|
418
|
-
return __generator(this, function (_a) {
|
|
419
|
-
switch (_a.label) {
|
|
420
|
-
case 0: return [4 /*yield*/, this.getBalanceOfPublicKey(publicKey)];
|
|
421
|
-
case 1:
|
|
422
|
-
balance = _a.sent();
|
|
423
|
-
return [4 /*yield*/, this.options.transactionController.prepareSubmittableTransactions(publicKey, balance, [
|
|
424
|
-
{
|
|
425
|
-
type: SubstrateTransaction_1.SubstrateTransactionType.M_CANCEL_LEAVE_DELEGATORS,
|
|
426
|
-
tip: tip,
|
|
427
|
-
args: {}
|
|
428
|
-
}
|
|
429
|
-
])];
|
|
430
|
-
case 2:
|
|
431
|
-
encoded = _a.sent();
|
|
432
|
-
return [2 /*return*/, [{ encoded: encoded }]];
|
|
433
|
-
}
|
|
434
|
-
});
|
|
435
|
-
});
|
|
436
|
-
};
|
|
437
|
-
MoonbeamProtocol.prototype.prepareDelegatorBondMore = function (publicKey, tip, candidate, more) {
|
|
438
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
439
|
-
var balance, available, encoded;
|
|
440
|
-
return __generator(this, function (_a) {
|
|
441
|
-
switch (_a.label) {
|
|
442
|
-
case 0: return [4 /*yield*/, this.getBalanceOfPublicKey(publicKey)];
|
|
443
|
-
case 1:
|
|
444
|
-
balance = _a.sent();
|
|
445
|
-
available = new bignumber_1.BigNumber(balance).minus(more);
|
|
446
|
-
return [4 /*yield*/, this.options.transactionController.prepareSubmittableTransactions(publicKey, available, [
|
|
447
|
-
{
|
|
448
|
-
type: SubstrateTransaction_1.SubstrateTransactionType.M_DELEGATOR_BOND_MORE,
|
|
449
|
-
tip: tip,
|
|
450
|
-
args: {
|
|
451
|
-
candidate: candidate,
|
|
452
|
-
more: new bignumber_1.BigNumber(more)
|
|
453
|
-
}
|
|
454
|
-
}
|
|
455
|
-
])];
|
|
456
|
-
case 2:
|
|
457
|
-
encoded = _a.sent();
|
|
458
|
-
return [2 /*return*/, [{ encoded: encoded }]];
|
|
459
|
-
}
|
|
460
|
-
});
|
|
461
|
-
});
|
|
462
|
-
};
|
|
463
|
-
MoonbeamProtocol.prototype.prepareScheduleDelegatorBondLess = function (publicKey, tip, candidate, less) {
|
|
464
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
465
|
-
var _a, balance, delegationDetails, bondAmount, requestedAmount, encoded;
|
|
466
|
-
return __generator(this, function (_b) {
|
|
467
|
-
switch (_b.label) {
|
|
468
|
-
case 0: return [4 /*yield*/, Promise.all([
|
|
469
|
-
this.getBalanceOfPublicKey(publicKey),
|
|
470
|
-
this.options.accountController.getDelegationDetails(publicKey, candidate)
|
|
471
|
-
])];
|
|
472
|
-
case 1:
|
|
473
|
-
_a = _b.sent(), balance = _a[0], delegationDetails = _a[1];
|
|
474
|
-
bondAmount = new bignumber_1.BigNumber(delegationDetails.bond);
|
|
475
|
-
requestedAmount = new bignumber_1.BigNumber(less);
|
|
476
|
-
if (requestedAmount.gt(bondAmount)) {
|
|
477
|
-
throw new errors_1.ConditionViolationError(coinlib_error_1.Domain.SUBSTRATE, 'Bond less amount too high');
|
|
478
|
-
}
|
|
479
|
-
else if (requestedAmount.eq(bondAmount)) {
|
|
480
|
-
return [2 /*return*/, this.prepareScheduleUndelegate(publicKey, tip, candidate)];
|
|
481
|
-
}
|
|
482
|
-
return [4 /*yield*/, this.options.transactionController.prepareSubmittableTransactions(publicKey, balance, [
|
|
483
|
-
{
|
|
484
|
-
type: SubstrateTransaction_1.SubstrateTransactionType.M_SCHEDULE_DELEGATOR_BOND_LESS,
|
|
485
|
-
tip: tip,
|
|
486
|
-
args: {
|
|
487
|
-
candidate: candidate,
|
|
488
|
-
less: requestedAmount
|
|
489
|
-
}
|
|
490
|
-
}
|
|
491
|
-
])];
|
|
492
|
-
case 2:
|
|
493
|
-
encoded = _b.sent();
|
|
494
|
-
return [2 /*return*/, [{ encoded: encoded }]];
|
|
495
|
-
}
|
|
496
|
-
});
|
|
497
|
-
});
|
|
498
|
-
};
|
|
499
|
-
MoonbeamProtocol.prototype.prepareExecuteDelegatorBondLess = function (publicKey, tip, candidate) {
|
|
500
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
501
|
-
return __generator(this, function (_a) {
|
|
502
|
-
return [2 /*return*/, this.prepareExecuteDelegationRequest(publicKey, tip, candidate)];
|
|
503
|
-
});
|
|
504
|
-
});
|
|
505
|
-
};
|
|
506
|
-
MoonbeamProtocol.prototype.prepareCancelDelegatorBondLess = function (publicKey, tip, candidate) {
|
|
507
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
508
|
-
return __generator(this, function (_a) {
|
|
509
|
-
return [2 /*return*/, this.prepareCancelDelegationRequest(publicKey, tip, candidate)];
|
|
510
|
-
});
|
|
511
|
-
});
|
|
512
|
-
};
|
|
513
|
-
MoonbeamProtocol.prototype.prepareExecuteDelegationRequest = function (publicKey, tip, candidate) {
|
|
514
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
515
|
-
var results, balance, delegator, encoded;
|
|
516
|
-
return __generator(this, function (_a) {
|
|
517
|
-
switch (_a.label) {
|
|
518
|
-
case 0: return [4 /*yield*/, Promise.all([this.getBalanceOfPublicKey(publicKey), this.getAddressFromPublicKey(publicKey)])];
|
|
519
|
-
case 1:
|
|
520
|
-
results = _a.sent();
|
|
521
|
-
balance = results[0];
|
|
522
|
-
delegator = results[1].address;
|
|
523
|
-
return [4 /*yield*/, this.options.transactionController.prepareSubmittableTransactions(publicKey, balance, [
|
|
524
|
-
{
|
|
525
|
-
type: SubstrateTransaction_1.SubstrateTransactionType.M_EXECUTE_DELGATION_REQUEST,
|
|
526
|
-
tip: tip,
|
|
527
|
-
args: {
|
|
528
|
-
delegator: delegator,
|
|
529
|
-
candidate: candidate
|
|
530
|
-
}
|
|
531
|
-
}
|
|
532
|
-
])];
|
|
533
|
-
case 2:
|
|
534
|
-
encoded = _a.sent();
|
|
535
|
-
return [2 /*return*/, [{ encoded: encoded }]];
|
|
536
|
-
}
|
|
537
|
-
});
|
|
538
|
-
});
|
|
539
|
-
};
|
|
540
|
-
MoonbeamProtocol.prototype.prepareCancelDelegationRequest = function (publicKey, tip, candidate) {
|
|
541
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
542
|
-
var balance, encoded;
|
|
543
|
-
return __generator(this, function (_a) {
|
|
544
|
-
switch (_a.label) {
|
|
545
|
-
case 0: return [4 /*yield*/, this.getBalanceOfPublicKey(publicKey)];
|
|
546
|
-
case 1:
|
|
547
|
-
balance = _a.sent();
|
|
548
|
-
return [4 /*yield*/, this.options.transactionController.prepareSubmittableTransactions(publicKey, balance, [
|
|
549
|
-
{
|
|
550
|
-
type: SubstrateTransaction_1.SubstrateTransactionType.M_CANCEL_DELEGATION_REQUEST,
|
|
551
|
-
tip: tip,
|
|
552
|
-
args: {
|
|
553
|
-
candidate: candidate
|
|
554
|
-
}
|
|
555
|
-
}
|
|
556
|
-
])];
|
|
557
|
-
case 2:
|
|
558
|
-
encoded = _a.sent();
|
|
559
|
-
return [2 /*return*/, [{ encoded: encoded }]];
|
|
560
|
-
}
|
|
561
|
-
});
|
|
562
|
-
});
|
|
563
|
-
};
|
|
564
|
-
MoonbeamProtocol.prototype.getMinDelegationAmount = function (accountId) {
|
|
565
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
566
|
-
return __generator(this, function (_a) {
|
|
567
|
-
return [2 /*return*/, this.options.accountController.getMinDelegationAmount(accountId)];
|
|
568
|
-
});
|
|
569
|
-
});
|
|
570
|
-
};
|
|
571
|
-
MoonbeamProtocol.prototype.getFutureRequiredTransactions = function (accountId, intention) {
|
|
572
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
573
|
-
var results, isDelegating, transferableBalance, stakingBalance, requiredTransactions;
|
|
574
|
-
return __generator(this, function (_a) {
|
|
575
|
-
switch (_a.label) {
|
|
576
|
-
case 0: return [4 /*yield*/, Promise.all([
|
|
577
|
-
this.options.accountController.isDelegating(accountId),
|
|
578
|
-
this.options.accountController.getTransferableBalance(accountId),
|
|
579
|
-
this.options.accountController.getTransferableBalance(accountId, false, false)
|
|
580
|
-
])];
|
|
581
|
-
case 1:
|
|
582
|
-
results = _a.sent();
|
|
583
|
-
isDelegating = results[0];
|
|
584
|
-
transferableBalance = results[1];
|
|
585
|
-
stakingBalance = results[2];
|
|
586
|
-
requiredTransactions = [];
|
|
587
|
-
if (intention === 'transfer') {
|
|
588
|
-
requiredTransactions.push([
|
|
589
|
-
SubstrateTransaction_1.SubstrateTransactionType.TRANSFER,
|
|
590
|
-
{
|
|
591
|
-
to: MoonbeamAddress_1.MoonbeamAddress.getPlaceholder(),
|
|
592
|
-
value: transferableBalance
|
|
593
|
-
}
|
|
594
|
-
]);
|
|
595
|
-
}
|
|
596
|
-
if (!isDelegating && intention === 'delegate') {
|
|
597
|
-
// not delegated
|
|
598
|
-
requiredTransactions.push([
|
|
599
|
-
SubstrateTransaction_1.SubstrateTransactionType.M_DELEGATE,
|
|
600
|
-
{
|
|
601
|
-
candidate: MoonbeamAddress_1.MoonbeamAddress.getPlaceholder(),
|
|
602
|
-
amount: stakingBalance,
|
|
603
|
-
candidateDelegationCount: 0,
|
|
604
|
-
delegationCount: 0
|
|
605
|
-
}
|
|
606
|
-
], [
|
|
607
|
-
SubstrateTransaction_1.SubstrateTransactionType.M_SCHEDULE_REVOKE_DELGATION,
|
|
608
|
-
{
|
|
609
|
-
collator: MoonbeamAddress_1.MoonbeamAddress.getPlaceholder()
|
|
610
|
-
}
|
|
611
|
-
], [
|
|
612
|
-
SubstrateTransaction_1.SubstrateTransactionType.M_EXECUTE_DELGATION_REQUEST,
|
|
613
|
-
{
|
|
614
|
-
delegator: MoonbeamAddress_1.MoonbeamAddress.getPlaceholder(),
|
|
615
|
-
candidate: MoonbeamAddress_1.MoonbeamAddress.getPlaceholder()
|
|
616
|
-
}
|
|
617
|
-
]);
|
|
618
|
-
}
|
|
619
|
-
if (isDelegating && intention === 'delegate') {
|
|
620
|
-
requiredTransactions.push([
|
|
621
|
-
SubstrateTransaction_1.SubstrateTransactionType.M_SCHEDULE_REVOKE_DELGATION,
|
|
622
|
-
{
|
|
623
|
-
collator: MoonbeamAddress_1.MoonbeamAddress.getPlaceholder()
|
|
624
|
-
}
|
|
625
|
-
], [
|
|
626
|
-
SubstrateTransaction_1.SubstrateTransactionType.M_EXECUTE_DELGATION_REQUEST,
|
|
627
|
-
{
|
|
628
|
-
delegator: MoonbeamAddress_1.MoonbeamAddress.getPlaceholder(),
|
|
629
|
-
candidate: MoonbeamAddress_1.MoonbeamAddress.getPlaceholder()
|
|
630
|
-
}
|
|
631
|
-
]);
|
|
632
|
-
}
|
|
633
|
-
return [2 /*return*/, requiredTransactions];
|
|
634
|
-
}
|
|
635
|
-
});
|
|
636
|
-
});
|
|
637
|
-
};
|
|
638
|
-
return MoonbeamProtocol;
|
|
639
|
-
}(SubstrateDelegateProtocol_1.SubstrateDelegateProtocol));
|
|
640
|
-
exports.MoonbeamProtocol = MoonbeamProtocol;
|
|
641
|
-
//# sourceMappingURL=MoonbeamProtocol.js.map
|