@airgap/polkadot 0.13.10 → 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.
Files changed (118) hide show
  1. package/package.json +14 -8
  2. package/airgap-coinlib-polkadot.min.js +0 -85359
  3. package/index.d.ts +0 -1
  4. package/index.js +0 -18
  5. package/index.js.map +0 -1
  6. package/v0/index.d.ts +0 -5
  7. package/v0/index.js +0 -31
  8. package/v0/index.js.map +0 -1
  9. package/v0/protocol/kusama/KusamaProtocol.d.ts +0 -22
  10. package/v0/protocol/kusama/KusamaProtocol.js +0 -71
  11. package/v0/protocol/kusama/KusamaProtocol.js.map +0 -1
  12. package/v0/protocol/kusama/KusamaProtocolOptions.d.ts +0 -23
  13. package/v0/protocol/kusama/KusamaProtocolOptions.js +0 -85
  14. package/v0/protocol/kusama/KusamaProtocolOptions.js.map +0 -1
  15. package/v0/protocol/polkadot/PolkadotProtocol.d.ts +0 -23
  16. package/v0/protocol/polkadot/PolkadotProtocol.js +0 -72
  17. package/v0/protocol/polkadot/PolkadotProtocol.js.map +0 -1
  18. package/v0/protocol/polkadot/PolkadotProtocolOptions.d.ts +0 -23
  19. package/v0/protocol/polkadot/PolkadotProtocolOptions.js +0 -85
  20. package/v0/protocol/polkadot/PolkadotProtocolOptions.js.map +0 -1
  21. package/v1/block-explorer/SubscanBlockExplorer.d.ts +0 -3
  22. package/v1/block-explorer/SubscanBlockExplorer.js +0 -16
  23. package/v1/block-explorer/SubscanBlockExplorer.js.map +0 -1
  24. package/v1/controller/PolkadotAccountController.d.ts +0 -28
  25. package/v1/controller/PolkadotAccountController.js +0 -656
  26. package/v1/controller/PolkadotAccountController.js.map +0 -1
  27. package/v1/controller/PolkadotTransactionController.d.ts +0 -5
  28. package/v1/controller/PolkadotTransactionController.js +0 -28
  29. package/v1/controller/PolkadotTransactionController.js.map +0 -1
  30. package/v1/data/staking/PolkadotActiveEraInfo.d.ts +0 -8
  31. package/v1/data/staking/PolkadotActiveEraInfo.js +0 -19
  32. package/v1/data/staking/PolkadotActiveEraInfo.js.map +0 -1
  33. package/v1/data/staking/PolkadotEraElectionStatus.d.ts +0 -12
  34. package/v1/data/staking/PolkadotEraElectionStatus.js +0 -27
  35. package/v1/data/staking/PolkadotEraElectionStatus.js.map +0 -1
  36. package/v1/data/staking/PolkadotEraRewardPoints.d.ts +0 -8
  37. package/v1/data/staking/PolkadotEraRewardPoints.js +0 -21
  38. package/v1/data/staking/PolkadotEraRewardPoints.js.map +0 -1
  39. package/v1/data/staking/PolkadotExposure.d.ts +0 -9
  40. package/v1/data/staking/PolkadotExposure.js +0 -23
  41. package/v1/data/staking/PolkadotExposure.js.map +0 -1
  42. package/v1/data/staking/PolkadotNominationStatus.d.ts +0 -5
  43. package/v1/data/staking/PolkadotNominationStatus.js +0 -10
  44. package/v1/data/staking/PolkadotNominationStatus.js.map +0 -1
  45. package/v1/data/staking/PolkadotNominations.d.ts +0 -9
  46. package/v1/data/staking/PolkadotNominations.js +0 -21
  47. package/v1/data/staking/PolkadotNominations.js.map +0 -1
  48. package/v1/data/staking/PolkadotNominatorDetails.d.ts +0 -24
  49. package/v1/data/staking/PolkadotNominatorDetails.js +0 -3
  50. package/v1/data/staking/PolkadotNominatorDetails.js.map +0 -1
  51. package/v1/data/staking/PolkadotPayee.d.ts +0 -5
  52. package/v1/data/staking/PolkadotPayee.js +0 -10
  53. package/v1/data/staking/PolkadotPayee.js.map +0 -1
  54. package/v1/data/staking/PolkadotSlashingSpans.d.ts +0 -10
  55. package/v1/data/staking/PolkadotSlashingSpans.js +0 -23
  56. package/v1/data/staking/PolkadotSlashingSpans.js.map +0 -1
  57. package/v1/data/staking/PolkadotStakingActionType.d.ts +0 -14
  58. package/v1/data/staking/PolkadotStakingActionType.js +0 -19
  59. package/v1/data/staking/PolkadotStakingActionType.js.map +0 -1
  60. package/v1/data/staking/PolkadotStakingLedger.d.ts +0 -11
  61. package/v1/data/staking/PolkadotStakingLedger.js +0 -27
  62. package/v1/data/staking/PolkadotStakingLedger.js.map +0 -1
  63. package/v1/data/staking/PolkadotValidatorDetails.d.ts +0 -16
  64. package/v1/data/staking/PolkadotValidatorDetails.js +0 -3
  65. package/v1/data/staking/PolkadotValidatorDetails.js.map +0 -1
  66. package/v1/data/staking/PolkadotValidatorPrefs.d.ts +0 -7
  67. package/v1/data/staking/PolkadotValidatorPrefs.js +0 -17
  68. package/v1/data/staking/PolkadotValidatorPrefs.js.map +0 -1
  69. package/v1/data/transaction/method/args.d.ts +0 -2
  70. package/v1/data/transaction/method/args.js +0 -439
  71. package/v1/data/transaction/method/args.js.map +0 -1
  72. package/v1/data/transaction/transaction.d.ts +0 -2
  73. package/v1/data/transaction/transaction.js +0 -28
  74. package/v1/data/transaction/transaction.js.map +0 -1
  75. package/v1/index.d.ts +0 -10
  76. package/v1/index.js +0 -13
  77. package/v1/index.js.map +0 -1
  78. package/v1/module/PolkadotModule.d.ts +0 -17
  79. package/v1/module/PolkadotModule.js +0 -121
  80. package/v1/module/PolkadotModule.js.map +0 -1
  81. package/v1/node/PolkadotNodeClient.d.ts +0 -46
  82. package/v1/node/PolkadotNodeClient.js +0 -323
  83. package/v1/node/PolkadotNodeClient.js.map +0 -1
  84. package/v1/protocol/KusamaProtocol.d.ts +0 -14
  85. package/v1/protocol/KusamaProtocol.js +0 -105
  86. package/v1/protocol/KusamaProtocol.js.map +0 -1
  87. package/v1/protocol/PolkadotBaseProtocol.d.ts +0 -24
  88. package/v1/protocol/PolkadotBaseProtocol.js +0 -478
  89. package/v1/protocol/PolkadotBaseProtocol.js.map +0 -1
  90. package/v1/protocol/PolkadotProtocol.d.ts +0 -14
  91. package/v1/protocol/PolkadotProtocol.js +0 -116
  92. package/v1/protocol/PolkadotProtocol.js.map +0 -1
  93. package/v1/serializer/v3/schemas/converter/transaction-converter.d.ts +0 -7
  94. package/v1/serializer/v3/schemas/converter/transaction-converter.js +0 -21
  95. package/v1/serializer/v3/schemas/converter/transaction-converter.js.map +0 -1
  96. package/v1/serializer/v3/schemas/definitions/transaction-sign-request-polkadot.d.ts +0 -3
  97. package/v1/serializer/v3/schemas/definitions/transaction-sign-request-polkadot.js +0 -3
  98. package/v1/serializer/v3/schemas/definitions/transaction-sign-request-polkadot.js.map +0 -1
  99. package/v1/serializer/v3/schemas/definitions/transaction-sign-response-polkadot.d.ts +0 -3
  100. package/v1/serializer/v3/schemas/definitions/transaction-sign-response-polkadot.js +0 -3
  101. package/v1/serializer/v3/schemas/definitions/transaction-sign-response-polkadot.js.map +0 -1
  102. package/v1/serializer/v3/schemas/generated/transaction-sign-request-polkadot.json +0 -36
  103. package/v1/serializer/v3/schemas/generated/transaction-sign-response-polkadot.json +0 -19
  104. package/v1/serializer/v3/serializer-companion.d.ts +0 -14
  105. package/v1/serializer/v3/serializer-companion.js +0 -189
  106. package/v1/serializer/v3/serializer-companion.js.map +0 -1
  107. package/v1/serializer/v3/validators/transaction-validator.d.ts +0 -4
  108. package/v1/serializer/v3/validators/transaction-validator.js +0 -28
  109. package/v1/serializer/v3/validators/transaction-validator.js.map +0 -1
  110. package/v1/serializer/v3/validators/validators.d.ts +0 -4
  111. package/v1/serializer/v3/validators/validators.js +0 -6
  112. package/v1/serializer/v3/validators/validators.js.map +0 -1
  113. package/v1/types/configuration.d.ts +0 -11
  114. package/v1/types/configuration.js +0 -3
  115. package/v1/types/configuration.js.map +0 -1
  116. package/v1/types/protocol.d.ts +0 -12
  117. package/v1/types/protocol.js +0 -3
  118. package/v1/types/protocol.js.map +0 -1
@@ -1,24 +0,0 @@
1
- import BigNumber from '@airgap/coinlib-core/dependencies/src/bignumber.js-9.0.0/bignumber';
2
- import { PublicKey } from '@airgap/module-kit';
3
- import { SubstrateAccountId, SubstrateProtocol, SubstrateProtocolImpl, SubstrateSS58Address, SubstrateTransactionType, SubstrateUnsignedTransaction } from '@airgap/substrate/v1';
4
- import { PolkadotAccountController } from '../controller/PolkadotAccountController';
5
- import { PolkadotTransactionController } from '../controller/PolkadotTransactionController';
6
- import { PolkadotPayee } from '../data/staking/PolkadotPayee';
7
- import { PolkadotNodeClient } from '../node/PolkadotNodeClient';
8
- import { PolkadotProtocolConfiguration } from '../types/configuration';
9
- import { PolkadotBaseProtocolOptions, PolkadotProtocolNetwork } from '../types/protocol';
10
- export interface PolkadotBaseProtocol<_Units extends string = string> extends SubstrateProtocol<_Units, PolkadotProtocolNetwork> {
11
- }
12
- export declare abstract class PolkadotBaseProtocolImpl<_Units extends string> extends SubstrateProtocolImpl<_Units, PolkadotProtocolConfiguration, PolkadotProtocolNetwork, PolkadotNodeClient, PolkadotAccountController, PolkadotTransactionController> implements PolkadotBaseProtocol<_Units> {
13
- constructor(options: PolkadotBaseProtocolOptions<_Units>);
14
- prepareNomination(publicKey: PublicKey, tip: string | number | BigNumber, targets: string[] | string, controller?: string, value?: string | number | BigNumber, payee?: string | PolkadotPayee): Promise<SubstrateUnsignedTransaction>;
15
- prepareRebondNominate(publicKey: PublicKey, tip: string | number | BigNumber, targets: string[] | string, value: string | number | BigNumber): Promise<SubstrateUnsignedTransaction>;
16
- prepareScheduleUndelegate(publicKey: PublicKey, tip: string | number | BigNumber, value?: string | number | BigNumber): Promise<SubstrateUnsignedTransaction>;
17
- prepareChangeValidator(publicKey: string, tip: string | number | BigNumber, targets: string[] | string): Promise<SubstrateUnsignedTransaction>;
18
- prepareUnbond(publicKey: PublicKey, tip: string | number | BigNumber, value: string | number | BigNumber): Promise<SubstrateUnsignedTransaction>;
19
- prepareRebond(publicKey: PublicKey, tip: string | number | BigNumber, value: string | number | BigNumber): Promise<SubstrateUnsignedTransaction>;
20
- prepareBondExtra(publicKey: PublicKey, tip: string | number | BigNumber, value: string | number | BigNumber): Promise<SubstrateUnsignedTransaction>;
21
- prepareRebondExtra(publicKey: PublicKey, tip: string | number | BigNumber, value: string | number | BigNumber): Promise<SubstrateUnsignedTransaction>;
22
- prepareWithdrawUnbonded(publicKey: string, tip: string | number | BigNumber): Promise<SubstrateUnsignedTransaction>;
23
- protected getFutureRequiredTransactions(accountId: SubstrateAccountId<SubstrateSS58Address>, intention: 'transfer' | 'check' | 'delegate'): Promise<[SubstrateTransactionType<PolkadotProtocolConfiguration>, any][]>;
24
- }
@@ -1,478 +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
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
54
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
55
- if (ar || !(i in from)) {
56
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
57
- ar[i] = from[i];
58
- }
59
- }
60
- return to.concat(ar || Array.prototype.slice.call(from));
61
- };
62
- var __importDefault = (this && this.__importDefault) || function (mod) {
63
- return (mod && mod.__esModule) ? mod : { "default": mod };
64
- };
65
- Object.defineProperty(exports, "__esModule", { value: true });
66
- exports.PolkadotBaseProtocolImpl = void 0;
67
- var bignumber_1 = __importDefault(require("@airgap/coinlib-core/dependencies/src/bignumber.js-9.0.0/bignumber"));
68
- var module_kit_1 = require("@airgap/module-kit");
69
- var v1_1 = require("@airgap/substrate/v1");
70
- var PolkadotAccountController_1 = require("../controller/PolkadotAccountController");
71
- var PolkadotTransactionController_1 = require("../controller/PolkadotTransactionController");
72
- var PolkadotPayee_1 = require("../data/staking/PolkadotPayee");
73
- var PolkadotNodeClient_1 = require("../node/PolkadotNodeClient");
74
- // Implementation
75
- var PolkadotBaseProtocolImpl = /** @class */ (function (_super) {
76
- __extends(PolkadotBaseProtocolImpl, _super);
77
- function PolkadotBaseProtocolImpl(options) {
78
- var nodeClient = new PolkadotNodeClient_1.PolkadotNodeClient(options.configuration, options.network.rpcUrl);
79
- var accountController = new PolkadotAccountController_1.PolkadotAccountController(options.configuration, nodeClient);
80
- var transactionController = new PolkadotTransactionController_1.PolkadotTransactionController(options.configuration, nodeClient);
81
- var blockExplorer = new v1_1.SubscanBlockExplorerClient(options.network.blockExplorerApi);
82
- return _super.call(this, options, nodeClient, accountController, transactionController, blockExplorer) || this;
83
- }
84
- PolkadotBaseProtocolImpl.prototype.prepareNomination = function (publicKey, tip, targets, controller, value, payee) {
85
- return __awaiter(this, void 0, void 0, function () {
86
- var balance, available, bondFirst, encoded;
87
- return __generator(this, function (_a) {
88
- switch (_a.label) {
89
- case 0: return [4 /*yield*/, this.accountController.getBalance(publicKey)];
90
- case 1:
91
- balance = _a.sent();
92
- available = new bignumber_1.default(balance.transferableCoveringFees).minus(value || 0);
93
- bondFirst = controller !== undefined && value !== undefined && payee !== undefined;
94
- return [4 /*yield*/, this.transactionController.prepareSubmittableTransactions(publicKey, available, __spreadArray(__spreadArray([], (bondFirst
95
- ? [
96
- // tslint:disable-next-line: no-object-literal-type-assertion
97
- {
98
- type: 'bond',
99
- tip: tip,
100
- args: {
101
- controller: controller,
102
- value: bignumber_1.default.isBigNumber(value) ? value : new bignumber_1.default(value),
103
- payee: typeof payee === 'string' ? PolkadotPayee_1.PolkadotPayee[payee] : payee
104
- }
105
- }
106
- ]
107
- : []), true), [
108
- {
109
- type: 'nominate',
110
- tip: tip,
111
- args: {
112
- targets: typeof targets === 'string' ? [targets] : targets
113
- }
114
- }
115
- ], false))];
116
- case 2:
117
- encoded = _a.sent();
118
- return [2 /*return*/, (0, module_kit_1.newUnsignedTransaction)({ encoded: encoded })];
119
- }
120
- });
121
- });
122
- };
123
- PolkadotBaseProtocolImpl.prototype.prepareRebondNominate = function (publicKey, tip, targets, value) {
124
- return __awaiter(this, void 0, void 0, function () {
125
- var _a, balance, lockedBalance, toDelegate, params, encoded;
126
- return __generator(this, function (_b) {
127
- switch (_b.label) {
128
- case 0: return [4 /*yield*/, Promise.all([
129
- this.accountController.getBalance(publicKey),
130
- this.accountController.getUnlockingBalance(publicKey)
131
- ])];
132
- case 1:
133
- _a = _b.sent(), balance = _a[0], lockedBalance = _a[1];
134
- toDelegate = bignumber_1.default.isBigNumber(value) ? value : new bignumber_1.default(value);
135
- params = [];
136
- if (toDelegate.gt(lockedBalance)) {
137
- params.push({
138
- type: 'rebond',
139
- tip: tip,
140
- args: {
141
- value: lockedBalance
142
- }
143
- }, {
144
- type: 'bond_extra',
145
- tip: tip,
146
- args: {
147
- value: toDelegate.minus(lockedBalance)
148
- }
149
- });
150
- }
151
- else {
152
- params.push({
153
- type: 'rebond',
154
- tip: tip,
155
- args: {
156
- value: toDelegate
157
- }
158
- });
159
- }
160
- params.push({
161
- type: 'nominate',
162
- tip: tip,
163
- args: {
164
- targets: typeof targets === 'string' ? [targets] : targets
165
- }
166
- });
167
- return [4 /*yield*/, this.transactionController.prepareSubmittableTransactions(publicKey, balance.transferableCoveringFees, params)];
168
- case 2:
169
- encoded = _b.sent();
170
- return [2 /*return*/, (0, module_kit_1.newUnsignedTransaction)({ encoded: encoded })];
171
- }
172
- });
173
- });
174
- };
175
- PolkadotBaseProtocolImpl.prototype.prepareScheduleUndelegate = function (publicKey, tip, value) {
176
- return __awaiter(this, void 0, void 0, function () {
177
- var balance, keepController, encoded;
178
- return __generator(this, function (_a) {
179
- switch (_a.label) {
180
- case 0: return [4 /*yield*/, this.accountController.getBalance(publicKey)];
181
- case 1:
182
- balance = _a.sent();
183
- keepController = value === undefined;
184
- return [4 /*yield*/, this.transactionController.prepareSubmittableTransactions(publicKey, balance.transferableCoveringFees, __spreadArray([
185
- {
186
- type: 'cancel_nomination',
187
- tip: tip,
188
- args: {}
189
- }
190
- ], (keepController
191
- ? []
192
- : [
193
- {
194
- type: 'unbond',
195
- tip: tip,
196
- args: {
197
- value: bignumber_1.default.isBigNumber(value) ? value : new bignumber_1.default(value)
198
- }
199
- }
200
- ]), true))];
201
- case 2:
202
- encoded = _a.sent();
203
- return [2 /*return*/, (0, module_kit_1.newUnsignedTransaction)({ encoded: encoded })];
204
- }
205
- });
206
- });
207
- };
208
- PolkadotBaseProtocolImpl.prototype.prepareChangeValidator = function (publicKey, tip, targets) {
209
- return __awaiter(this, void 0, void 0, function () {
210
- var balance, encoded;
211
- return __generator(this, function (_a) {
212
- switch (_a.label) {
213
- case 0: return [4 /*yield*/, this.accountController.getBalance(publicKey)];
214
- case 1:
215
- balance = _a.sent();
216
- return [4 /*yield*/, this.transactionController.prepareSubmittableTransactions(publicKey, balance.transferableCoveringFees, [
217
- {
218
- type: 'nominate',
219
- tip: tip,
220
- args: {
221
- targets: typeof targets === 'string' ? [targets] : targets
222
- }
223
- }
224
- ])];
225
- case 2:
226
- encoded = _a.sent();
227
- return [2 /*return*/, (0, module_kit_1.newUnsignedTransaction)({ encoded: encoded })];
228
- }
229
- });
230
- });
231
- };
232
- PolkadotBaseProtocolImpl.prototype.prepareUnbond = function (publicKey, tip, value) {
233
- return __awaiter(this, void 0, void 0, function () {
234
- var balance, encoded;
235
- return __generator(this, function (_a) {
236
- switch (_a.label) {
237
- case 0: return [4 /*yield*/, this.accountController.getBalance(publicKey)];
238
- case 1:
239
- balance = _a.sent();
240
- return [4 /*yield*/, this.transactionController.prepareSubmittableTransactions(publicKey, balance.transferableCoveringFees, [
241
- {
242
- type: 'unbond',
243
- tip: tip,
244
- args: {
245
- value: bignumber_1.default.isBigNumber(value) ? value : new bignumber_1.default(value)
246
- }
247
- }
248
- ])];
249
- case 2:
250
- encoded = _a.sent();
251
- return [2 /*return*/, (0, module_kit_1.newUnsignedTransaction)({ encoded: encoded })];
252
- }
253
- });
254
- });
255
- };
256
- PolkadotBaseProtocolImpl.prototype.prepareRebond = function (publicKey, tip, value) {
257
- return __awaiter(this, void 0, void 0, function () {
258
- var balance, encoded;
259
- return __generator(this, function (_a) {
260
- switch (_a.label) {
261
- case 0: return [4 /*yield*/, this.accountController.getBalance(publicKey)];
262
- case 1:
263
- balance = _a.sent();
264
- return [4 /*yield*/, this.transactionController.prepareSubmittableTransactions(publicKey, balance.transferableCoveringFees, [
265
- {
266
- type: 'rebond',
267
- tip: tip,
268
- args: {
269
- value: bignumber_1.default.isBigNumber(value) ? value : new bignumber_1.default(value)
270
- }
271
- }
272
- ])];
273
- case 2:
274
- encoded = _a.sent();
275
- return [2 /*return*/, (0, module_kit_1.newUnsignedTransaction)({ encoded: encoded })];
276
- }
277
- });
278
- });
279
- };
280
- PolkadotBaseProtocolImpl.prototype.prepareBondExtra = function (publicKey, tip, value) {
281
- return __awaiter(this, void 0, void 0, function () {
282
- var balance, encoded;
283
- return __generator(this, function (_a) {
284
- switch (_a.label) {
285
- case 0: return [4 /*yield*/, this.accountController.getBalance(publicKey)];
286
- case 1:
287
- balance = _a.sent();
288
- return [4 /*yield*/, this.transactionController.prepareSubmittableTransactions(publicKey, balance.transferableCoveringFees, [
289
- {
290
- type: 'bond_extra',
291
- tip: tip,
292
- args: {
293
- value: bignumber_1.default.isBigNumber(value) ? value : new bignumber_1.default(value)
294
- }
295
- }
296
- ])];
297
- case 2:
298
- encoded = _a.sent();
299
- return [2 /*return*/, (0, module_kit_1.newUnsignedTransaction)({ encoded: encoded })];
300
- }
301
- });
302
- });
303
- };
304
- PolkadotBaseProtocolImpl.prototype.prepareRebondExtra = function (publicKey, tip, value) {
305
- return __awaiter(this, void 0, void 0, function () {
306
- var _a, balance, lockedBalance, toDelegate, configs, encoded;
307
- return __generator(this, function (_b) {
308
- switch (_b.label) {
309
- case 0: return [4 /*yield*/, Promise.all([
310
- this.accountController.getBalance(publicKey),
311
- this.accountController.getUnlockingBalance(publicKey)
312
- ])];
313
- case 1:
314
- _a = _b.sent(), balance = _a[0], lockedBalance = _a[1];
315
- toDelegate = bignumber_1.default.isBigNumber(value) ? value : new bignumber_1.default(value);
316
- configs = toDelegate.gt(lockedBalance)
317
- ? [
318
- {
319
- type: 'rebond',
320
- tip: tip,
321
- args: {
322
- value: lockedBalance
323
- }
324
- },
325
- {
326
- type: 'bond_extra',
327
- tip: tip,
328
- args: {
329
- value: toDelegate.minus(lockedBalance)
330
- }
331
- }
332
- ]
333
- : [
334
- {
335
- type: 'rebond',
336
- tip: tip,
337
- args: {
338
- value: toDelegate
339
- }
340
- }
341
- ];
342
- return [4 /*yield*/, this.transactionController.prepareSubmittableTransactions(publicKey, balance.transferableCoveringFees, configs)];
343
- case 2:
344
- encoded = _b.sent();
345
- return [2 /*return*/, (0, module_kit_1.newUnsignedTransaction)({ encoded: encoded })];
346
- }
347
- });
348
- });
349
- };
350
- PolkadotBaseProtocolImpl.prototype.prepareWithdrawUnbonded = function (publicKey, tip) {
351
- return __awaiter(this, void 0, void 0, function () {
352
- var _a, balance, slashingSpansNumber, encoded;
353
- return __generator(this, function (_b) {
354
- switch (_b.label) {
355
- case 0: return [4 /*yield*/, Promise.all([
356
- this.accountController.getBalance(publicKey),
357
- this.accountController.getSlashingSpansNumber(publicKey)
358
- ])];
359
- case 1:
360
- _a = _b.sent(), balance = _a[0], slashingSpansNumber = _a[1];
361
- return [4 /*yield*/, this.transactionController.prepareSubmittableTransactions(publicKey, balance.transferableCoveringFees, [
362
- {
363
- type: 'withdraw_unbonded',
364
- tip: tip,
365
- args: { slashingSpansNumber: slashingSpansNumber }
366
- }
367
- ])];
368
- case 2:
369
- encoded = _b.sent();
370
- return [2 /*return*/, (0, module_kit_1.newUnsignedTransaction)({ encoded: encoded })];
371
- }
372
- });
373
- });
374
- };
375
- PolkadotBaseProtocolImpl.prototype.getFutureRequiredTransactions = function (accountId, intention) {
376
- return __awaiter(this, void 0, void 0, function () {
377
- var results, isBonded, isNominating, balance, unlockingBalance, transferableBalance, stakingBalance, isUnbonding, requiredTransactions;
378
- return __generator(this, function (_a) {
379
- switch (_a.label) {
380
- case 0: return [4 /*yield*/, Promise.all([
381
- this.accountController.isBonded(accountId),
382
- this.accountController.isDelegating(accountId),
383
- this.accountController.getBalance(accountId),
384
- this.accountController.getUnlockingBalance(accountId)
385
- ])];
386
- case 1:
387
- results = _a.sent();
388
- isBonded = results[0];
389
- isNominating = results[1];
390
- balance = results[2];
391
- unlockingBalance = results[3];
392
- transferableBalance = balance.transferable.minus(balance.existentialDeposit);
393
- stakingBalance = balance.transferableCoveringFees;
394
- isUnbonding = unlockingBalance.gt(0);
395
- requiredTransactions = [];
396
- if (intention === 'transfer') {
397
- requiredTransactions.push([
398
- 'transfer',
399
- {
400
- to: v1_1.SubstrateSS58Address.createPlaceholder(),
401
- value: transferableBalance
402
- }
403
- ]);
404
- }
405
- if (!isBonded && !isUnbonding && intention === 'delegate') {
406
- // not delegated & unbond
407
- requiredTransactions.push([
408
- 'bond',
409
- {
410
- controller: v1_1.SubstrateSS58Address.createPlaceholder(),
411
- value: stakingBalance,
412
- payee: 0
413
- }
414
- ], [
415
- 'nominate',
416
- {
417
- targets: [v1_1.SubstrateSS58Address.createPlaceholder()]
418
- }
419
- ], ['cancel_nomination', {}], [
420
- 'unbond',
421
- {
422
- value: stakingBalance
423
- }
424
- ], [
425
- 'withdraw_unbonded',
426
- {
427
- slashingSpansNumber: 0
428
- }
429
- ]);
430
- }
431
- else if (isUnbonding && intention === 'delegate') {
432
- requiredTransactions.push([
433
- 'rebond',
434
- {
435
- value: unlockingBalance
436
- }
437
- ], [
438
- 'nominate',
439
- {
440
- targets: [v1_1.SubstrateSS58Address.createPlaceholder()]
441
- }
442
- ], ['cancel_nomination', {}], [
443
- 'unbond',
444
- {
445
- value: stakingBalance.plus(unlockingBalance)
446
- }
447
- ], [
448
- 'withdraw_unbonded',
449
- {
450
- slashingSpansNumber: 0
451
- }
452
- ]);
453
- }
454
- else if (isBonded) {
455
- requiredTransactions.push([
456
- 'unbond',
457
- {
458
- value: stakingBalance
459
- }
460
- ], [
461
- 'withdraw_unbonded',
462
- {
463
- slashingSpansNumber: 0
464
- }
465
- ]);
466
- }
467
- if (isNominating) {
468
- requiredTransactions.push(['cancel_nomination', {}]);
469
- }
470
- return [2 /*return*/, requiredTransactions];
471
- }
472
- });
473
- });
474
- };
475
- return PolkadotBaseProtocolImpl;
476
- }(v1_1.SubstrateProtocolImpl));
477
- exports.PolkadotBaseProtocolImpl = PolkadotBaseProtocolImpl;
478
- //# sourceMappingURL=PolkadotBaseProtocol.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PolkadotBaseProtocol.js","sourceRoot":"","sources":["../../../src/v1/protocol/PolkadotBaseProtocol.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iHAA0F;AAC1F,iDAAsE;AACtE,2CAS6B;AAE7B,qFAAmF;AACnF,6FAA2F;AAC3F,+DAA6D;AAC7D,iEAA+D;AAQ/D,iBAAiB;AAEjB;IACU,4CAOP;IAED,kCAAmB,OAA4C;QAC7D,IAAM,UAAU,GAAuB,IAAI,uCAAkB,CAAC,OAAO,CAAC,aAAa,EAAE,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;QAE5G,IAAM,iBAAiB,GAA8B,IAAI,qDAAyB,CAAC,OAAO,CAAC,aAAa,EAAE,UAAU,CAAC,CAAA;QACrH,IAAM,qBAAqB,GAAkC,IAAI,6DAA6B,CAAC,OAAO,CAAC,aAAa,EAAE,UAAU,CAAC,CAAA;QAEjI,IAAM,aAAa,GAA+B,IAAI,+BAA0B,CAAC,OAAO,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAA;eAElH,kBAAM,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,aAAa,CAAC;IACrF,CAAC;IAEY,oDAAiB,GAA9B,UACE,SAAoB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AC5B;IACH,+BAAC;AAAD,CAAC,AA/YD,CACU,0BAAqB,GA8Y9B;AA/YqB,4DAAwB"}
@@ -1,14 +0,0 @@
1
- import { ProtocolMetadata, RecursivePartial } from '@airgap/module-kit';
2
- import { PolkadotProtocolConfiguration } from '../types/configuration';
3
- import { PolkadotProtocolNetwork, PolkadotProtocolOptions, PolkadotUnits } from '../types/protocol';
4
- import { PolkadotBaseProtocol, PolkadotBaseProtocolImpl } from './PolkadotBaseProtocol';
5
- export interface PolkadotProtocol extends PolkadotBaseProtocol<PolkadotUnits> {
6
- }
7
- export declare const POLKADOT_METADATA: ProtocolMetadata<PolkadotUnits>;
8
- export declare const POLKADOT_CONFIGURATION: PolkadotProtocolConfiguration;
9
- export declare class PolkadotProtocolImpl extends PolkadotBaseProtocolImpl<PolkadotUnits> implements PolkadotProtocol {
10
- constructor(options?: RecursivePartial<PolkadotProtocolOptions>);
11
- }
12
- export declare function createPolkadotProtocol(options?: RecursivePartial<PolkadotProtocolOptions>): PolkadotProtocol;
13
- export declare const POLKADOT_MAINNET_PROTOCOL_NETWORK: PolkadotProtocolNetwork;
14
- export declare function createPolkadotProtocolOptions(network?: Partial<PolkadotProtocolNetwork>): PolkadotProtocolOptions;
@@ -1,116 +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 __assign = (this && this.__assign) || function () {
18
- __assign = Object.assign || function(t) {
19
- for (var s, i = 1, n = arguments.length; i < n; i++) {
20
- s = arguments[i];
21
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
22
- t[p] = s[p];
23
- }
24
- return t;
25
- };
26
- return __assign.apply(this, arguments);
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.createPolkadotProtocolOptions = exports.POLKADOT_MAINNET_PROTOCOL_NETWORK = exports.createPolkadotProtocol = exports.PolkadotProtocolImpl = exports.POLKADOT_CONFIGURATION = exports.POLKADOT_METADATA = void 0;
30
- var coinlib_core_1 = require("@airgap/coinlib-core");
31
- var transaction_1 = require("../data/transaction/transaction");
32
- var PolkadotNodeClient_1 = require("../node/PolkadotNodeClient");
33
- var PolkadotBaseProtocol_1 = require("./PolkadotBaseProtocol");
34
- // Implementation
35
- exports.POLKADOT_METADATA = {
36
- identifier: coinlib_core_1.MainProtocolSymbols.POLKADOT,
37
- name: 'Polkadot',
38
- units: {
39
- DOT: {
40
- symbol: { value: 'DOT' },
41
- decimals: 10
42
- },
43
- mDOT: {
44
- symbol: { value: 'mDOT' },
45
- decimals: 7
46
- },
47
- uDOT: {
48
- symbol: { value: 'uDOT' },
49
- decimals: 4
50
- },
51
- Point: {
52
- symbol: { value: 'Point' },
53
- decimals: 1
54
- },
55
- Planck: {
56
- symbol: { value: 'Planck' },
57
- decimals: 0
58
- }
59
- },
60
- mainUnit: 'DOT',
61
- account: {
62
- standardDerivationPath: "m/44'/354'/0'/0/0",
63
- address: {
64
- isCaseSensitive: true,
65
- placeholder: "1ABC...",
66
- regex: '^1[a-km-zA-HJ-NP-Z1-9]+$'
67
- }
68
- }
69
- };
70
- exports.POLKADOT_CONFIGURATION = {
71
- account: {
72
- type: 'ss58',
73
- format: 0
74
- },
75
- transaction: {
76
- types: transaction_1.TRANSACTION_TYPES
77
- },
78
- rpc: {
79
- storageEntries: PolkadotNodeClient_1.STORAGE_ENTRIES,
80
- calls: PolkadotNodeClient_1.CALLS,
81
- constants: PolkadotNodeClient_1.CONSTANTS
82
- }
83
- };
84
- var PolkadotProtocolImpl = /** @class */ (function (_super) {
85
- __extends(PolkadotProtocolImpl, _super);
86
- function PolkadotProtocolImpl(options) {
87
- if (options === void 0) { options = {}; }
88
- var completeOptions = createPolkadotProtocolOptions(options.network);
89
- var metadata = exports.POLKADOT_METADATA;
90
- var configuration = exports.POLKADOT_CONFIGURATION;
91
- return _super.call(this, { metadata: metadata, configuration: configuration, network: completeOptions.network }) || this;
92
- }
93
- return PolkadotProtocolImpl;
94
- }(PolkadotBaseProtocol_1.PolkadotBaseProtocolImpl));
95
- exports.PolkadotProtocolImpl = PolkadotProtocolImpl;
96
- // Factory
97
- function createPolkadotProtocol(options) {
98
- if (options === void 0) { options = {}; }
99
- return new PolkadotProtocolImpl(options);
100
- }
101
- exports.createPolkadotProtocol = createPolkadotProtocol;
102
- exports.POLKADOT_MAINNET_PROTOCOL_NETWORK = {
103
- name: 'Mainnet',
104
- type: 'mainnet',
105
- rpcUrl: 'https://polkadot-node.prod.gke.papers.tech',
106
- blockExplorerApi: 'https://polkadot.subscan.prod.gke.papers.tech/api/scan'
107
- };
108
- var DEFAULT_POLKADOT_PROTOCOL_NETWORK = exports.POLKADOT_MAINNET_PROTOCOL_NETWORK;
109
- function createPolkadotProtocolOptions(network) {
110
- if (network === void 0) { network = {}; }
111
- return {
112
- network: __assign(__assign({}, DEFAULT_POLKADOT_PROTOCOL_NETWORK), network)
113
- };
114
- }
115
- exports.createPolkadotProtocolOptions = createPolkadotProtocolOptions;
116
- //# sourceMappingURL=PolkadotProtocol.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PolkadotProtocol.js","sourceRoot":"","sources":["../../../src/v1/protocol/PolkadotProtocol.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAA0D;AAG1D,+DAAmE;AACnE,iEAA8E;AAI9E,+DAAuF;AAMvF,iBAAiB;AAEJ,QAAA,iBAAiB,GAAoC;IAChE,UAAU,EA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