@airgap/icp 0.13.15-beta.5 → 0.13.15-beta.7
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 +5 -5
- package/v1/index.d.ts +2 -2
- package/v1/index.js +2 -2
- package/v1/index.js.map +1 -1
- package/v1/protocol/ICPGovernance.d.ts +28 -28
- package/v1/protocol/ICPGovernance.js +272 -178
- package/v1/protocol/ICPGovernance.js.map +1 -1
- package/v1/protocol/ICPImplementation.d.ts +6 -4
- package/v1/protocol/ICPImplementation.js +14 -52
- package/v1/protocol/ICPImplementation.js.map +1 -1
- package/v1/protocol/ICPProtocol.d.ts +35 -16
- package/v1/protocol/ICPProtocol.js +351 -110
- package/v1/protocol/ICPProtocol.js.map +1 -1
- package/v1/serializer/v3/schemas/generated/transaction-sign-request-icp.json +2 -3
- package/v1/types/governance.d.ts +27 -0
- package/v1/types/governance.js +12 -1
- package/v1/types/governance.js.map +1 -1
- package/v1/types/transaction.d.ts +5 -4
- package/v1/types/transaction.js +24 -14
- package/v1/types/transaction.js.map +1 -1
- package/v1/types/staking.d.ts +0 -12
- package/v1/types/staking.js +0 -17
- package/v1/types/staking.js.map +0 -1
|
@@ -32,7 +32,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
32
32
|
});
|
|
33
33
|
};
|
|
34
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
-
exports.
|
|
35
|
+
exports.getDetailsFromSignedDisburse = exports.signDisburse = exports.getDetailsFromUnsignedDisburse = exports.prepareDisburse = exports.getDetailsFromSignedFollowNeuron = exports.signFollowNeuron = exports.getDetailsFromUnsignedFollowNeuron = exports.prepareFollowNeuron = exports.getDetailsFromSignedAutoStakeMaturity = exports.signAutoStakeMaturity = exports.getDetailsFromUnsignedAutoStakeMaturity = exports.prepareAutoStakeMaturity = exports.getDetailsFromSignedStopDissolving = exports.signStopDissolving = exports.getDetailsFromUnsignedStopDissolving = exports.prepareStopDissolving = exports.getDetailsFromSignedStartDissolving = exports.signStartDissolving = exports.getDetailsFromUnsignedStartDissolving = exports.prepareStartDissolving = exports.getDetailsFromSignedIncreaseDissolveDelay = exports.signIncreaseDissolveDelay = exports.getDetailsFromUnsignedIncreaseDissolveDelay = exports.prepareIncreaseDissolveDelay = exports.getDetailsFromTransactionClaimGovernance = exports.signClaimGovernance = exports.getDetailsFromUnsignedClaimGovernance = exports.prepareClaimOrRefreshNeuron = exports.getDetailsFromSignedTransferToSubaccount = exports.signTransferToSubaccount = exports.getDetailsFromUnsignedTransferToSubaccount = exports.prepareTransferToSubaccount = exports.getDetailsFromSignedGetNeuronInfo = exports.signGetNeuronInfo = exports.getDetailsFromUnsignedGetNeuronInfo = exports.prepareGetNeuronInfo = void 0;
|
|
36
36
|
const module_kit_1 = require("@airgap/module-kit");
|
|
37
37
|
const transaction_1 = require("../types/transaction");
|
|
38
38
|
const account_1 = require("../utils/account");
|
|
@@ -88,21 +88,19 @@ const ICPImplementation_1 = require("./ICPImplementation");
|
|
|
88
88
|
// }
|
|
89
89
|
// ]
|
|
90
90
|
// }
|
|
91
|
-
function
|
|
91
|
+
function prepareGetNeuronInfo() {
|
|
92
92
|
return __awaiter(this, void 0, void 0, function* () {
|
|
93
93
|
// Does not need to create a transaction as it is only a call to the governance token
|
|
94
|
-
return
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
]
|
|
101
|
-
});
|
|
94
|
+
return [
|
|
95
|
+
{
|
|
96
|
+
actionType: transaction_1.ICPActionType.GET_NEURON_INFO,
|
|
97
|
+
encoded: ''
|
|
98
|
+
}
|
|
99
|
+
];
|
|
102
100
|
});
|
|
103
101
|
}
|
|
104
|
-
exports.
|
|
105
|
-
function
|
|
102
|
+
exports.prepareGetNeuronInfo = prepareGetNeuronInfo;
|
|
103
|
+
function getDetailsFromUnsignedGetNeuronInfo(publicKey, network) {
|
|
106
104
|
// Does not need info from transaction because it is only a call to the governance canister
|
|
107
105
|
return [
|
|
108
106
|
{
|
|
@@ -111,24 +109,25 @@ function getDetailsFromUnsignedTransactionGetNeuronInfo(publicKey, network) {
|
|
|
111
109
|
isInbound: false,
|
|
112
110
|
amount: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
113
111
|
fee: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
114
|
-
network
|
|
112
|
+
network,
|
|
113
|
+
type: transaction_1.ICPActionType.GET_NEURON_INFO
|
|
115
114
|
}
|
|
116
115
|
];
|
|
117
116
|
}
|
|
118
|
-
exports.
|
|
119
|
-
function
|
|
117
|
+
exports.getDetailsFromUnsignedGetNeuronInfo = getDetailsFromUnsignedGetNeuronInfo;
|
|
118
|
+
function signGetNeuronInfo(unsignedTransaction, privateKey, canisterId) {
|
|
120
119
|
return __awaiter(this, void 0, void 0, function* () {
|
|
121
|
-
const
|
|
122
|
-
|
|
123
|
-
include_neurons_readable_by_caller: IDL.Bool
|
|
120
|
+
const NeuronIdOrSubaccount = IDL.Variant({
|
|
121
|
+
Subaccount: IDL.Vec(IDL.Nat8)
|
|
124
122
|
});
|
|
125
|
-
const
|
|
126
|
-
const
|
|
123
|
+
const { subAccount } = (0, ICPImplementation_1.getFixedSubaccountFromPrivateKey)(privateKey);
|
|
124
|
+
const args = IDL.encode([NeuronIdOrSubaccount], [{ Subaccount: subAccount.toUint8Array() }]);
|
|
125
|
+
const signedTransaction = (0, ICPImplementation_1.signTransaction)(privateKey, canisterId, args, 'get_full_neuron_by_id_or_subaccount', 'query');
|
|
127
126
|
return signedTransaction;
|
|
128
127
|
});
|
|
129
128
|
}
|
|
130
|
-
exports.
|
|
131
|
-
function
|
|
129
|
+
exports.signGetNeuronInfo = signGetNeuronInfo;
|
|
130
|
+
function getDetailsFromSignedGetNeuronInfo(publicKey, network) {
|
|
132
131
|
// Does not need info from transaction because it is only a call to the governance canister
|
|
133
132
|
return [
|
|
134
133
|
{
|
|
@@ -137,11 +136,12 @@ function getDetailsFromSignedTransactionGetNeuronInfo(publicKey, network) {
|
|
|
137
136
|
isInbound: false,
|
|
138
137
|
amount: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
139
138
|
fee: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
140
|
-
network
|
|
139
|
+
network,
|
|
140
|
+
type: transaction_1.ICPActionType.GET_NEURON_INFO
|
|
141
141
|
}
|
|
142
142
|
];
|
|
143
143
|
}
|
|
144
|
-
exports.
|
|
144
|
+
exports.getDetailsFromSignedGetNeuronInfo = getDetailsFromSignedGetNeuronInfo;
|
|
145
145
|
// TRANSFER_TO_SUBACCOUNT
|
|
146
146
|
// CANISTER : (name: NNS Ledger, identifier: ryjl3-tyaaa-aaaaa-aaaba-cai)
|
|
147
147
|
// METHOD : (name: transfer, type: update)
|
|
@@ -161,10 +161,12 @@ function prepareTransferToSubaccount(publicKey, canisterId, amount, fee) {
|
|
|
161
161
|
to: accountIdentifier.toHex(),
|
|
162
162
|
fee
|
|
163
163
|
});
|
|
164
|
-
return
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
164
|
+
return [
|
|
165
|
+
{
|
|
166
|
+
actionType: transaction_1.ICPActionType.TRANSFER_TO_SUBACCOUNT,
|
|
167
|
+
encoded: unsignedTransfer
|
|
168
|
+
}
|
|
169
|
+
];
|
|
168
170
|
});
|
|
169
171
|
}
|
|
170
172
|
exports.prepareTransferToSubaccount = prepareTransferToSubaccount;
|
|
@@ -197,26 +199,63 @@ exports.getDetailsFromSignedTransferToSubaccount = getDetailsFromSignedTransferT
|
|
|
197
199
|
// CLAIM_GOVERNANCE ?
|
|
198
200
|
// CANISTER : (name: NNS Governance, identifier: rrkah-fqaaa-aaaaa-aaaaq-cai)
|
|
199
201
|
// METHOD : (name: claim_or_refresh_neuron_from_account, type: call)
|
|
200
|
-
function
|
|
202
|
+
function prepareClaimOrRefreshNeuron(publicKey) {
|
|
201
203
|
return __awaiter(this, void 0, void 0, function* () {
|
|
202
204
|
// Create subaccount from publicKey
|
|
203
|
-
const {
|
|
205
|
+
const { nonce } = (0, ICPImplementation_1.getFixedSubaccountFromPublicKey)(publicKey);
|
|
204
206
|
// Get Principal from public key
|
|
205
207
|
const principal = (0, ICPImplementation_1.getPrincipalFromPublicKey)(publicKey);
|
|
206
|
-
// IDL for
|
|
208
|
+
// IDL for ManageNeuron
|
|
209
|
+
const NeuronId = IDL.Record({ id: IDL.Nat64 });
|
|
207
210
|
const ClaimOrRefreshNeuronFromAccount = IDL.Record({
|
|
208
211
|
controller: IDL.Opt(IDL.Principal),
|
|
209
212
|
memo: IDL.Nat64
|
|
210
213
|
});
|
|
214
|
+
const By = IDL.Variant({
|
|
215
|
+
NeuronIdOrSubaccount: IDL.Record({}),
|
|
216
|
+
MemoAndController: ClaimOrRefreshNeuronFromAccount,
|
|
217
|
+
Memo: IDL.Nat64
|
|
218
|
+
});
|
|
219
|
+
const ClaimOrRefresh = IDL.Record({ by: IDL.Opt(By) });
|
|
220
|
+
const Command = IDL.Variant({
|
|
221
|
+
ClaimOrRefresh: ClaimOrRefresh
|
|
222
|
+
});
|
|
223
|
+
const NeuronIdOrSubaccount = IDL.Variant({
|
|
224
|
+
Subaccount: IDL.Vec(IDL.Nat8),
|
|
225
|
+
NeuronId: NeuronId
|
|
226
|
+
});
|
|
227
|
+
const ManageNeuron = IDL.Record({
|
|
228
|
+
id: IDL.Opt(NeuronId),
|
|
229
|
+
command: IDL.Opt(Command),
|
|
230
|
+
neuron_id_or_subaccount: IDL.Opt(NeuronIdOrSubaccount)
|
|
231
|
+
});
|
|
211
232
|
// Encode
|
|
212
|
-
const unsignedTransactionBuffer = IDL.encode([
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
233
|
+
const unsignedTransactionBuffer = IDL.encode([ManageNeuron], [
|
|
234
|
+
{
|
|
235
|
+
id: [],
|
|
236
|
+
command: [
|
|
237
|
+
{
|
|
238
|
+
ClaimOrRefresh: {
|
|
239
|
+
by: [
|
|
240
|
+
{
|
|
241
|
+
MemoAndController: { controller: [principal], memo: nonce }
|
|
242
|
+
}
|
|
243
|
+
]
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
],
|
|
247
|
+
neuron_id_or_subaccount: []
|
|
248
|
+
}
|
|
249
|
+
]);
|
|
250
|
+
return [
|
|
251
|
+
{
|
|
252
|
+
actionType: transaction_1.ICPActionType.CLAIM_GOVERNANCE,
|
|
253
|
+
encoded: (0, convert_1.arrayBufferToHexString)(unsignedTransactionBuffer)
|
|
254
|
+
}
|
|
255
|
+
];
|
|
217
256
|
});
|
|
218
257
|
}
|
|
219
|
-
exports.
|
|
258
|
+
exports.prepareClaimOrRefreshNeuron = prepareClaimOrRefreshNeuron;
|
|
220
259
|
function getDetailsFromUnsignedClaimGovernance(publicKey, network) {
|
|
221
260
|
// Does not need info from transaction because it is only a call to the governance canister
|
|
222
261
|
return [
|
|
@@ -237,7 +276,7 @@ function signClaimGovernance(unsignedTransaction, privateKey, canisterId) {
|
|
|
237
276
|
// unsignedTransaction has already the arguments needed for signing, just need to be in a Buffer
|
|
238
277
|
const args = (0, convert_1.hexStringToArrayBuffer)(unsignedTransaction);
|
|
239
278
|
// Sign transaction
|
|
240
|
-
const signedTransaction = (0, ICPImplementation_1.signTransaction)(privateKey, canisterId, args, '
|
|
279
|
+
const signedTransaction = (0, ICPImplementation_1.signTransaction)(privateKey, canisterId, args, 'manage_neuron', 'call');
|
|
241
280
|
return signedTransaction;
|
|
242
281
|
});
|
|
243
282
|
}
|
|
@@ -257,12 +296,12 @@ function getDetailsFromTransactionClaimGovernance(publicKey, network) {
|
|
|
257
296
|
];
|
|
258
297
|
}
|
|
259
298
|
exports.getDetailsFromTransactionClaimGovernance = getDetailsFromTransactionClaimGovernance;
|
|
260
|
-
//
|
|
299
|
+
// INCREASE_DISSOLVE_DELAY
|
|
261
300
|
// CANISTER : (name: NNS Governance, identifier: rrkah-fqaaa-aaaaa-aaaaq-cai)
|
|
262
301
|
// METHOD : (name: manage_neuron, type: update)
|
|
263
302
|
// PAYLOAD : (id : [{id : float}], command : [{Configure : {operation : [{IncreaseDissolveDelay : {additional_dissolve_delay_seconds : int}}]}}], neuron_id_or_subaccount : [])
|
|
264
303
|
// RESPONSE : (command : [{configure : {}}])
|
|
265
|
-
function
|
|
304
|
+
function prepareIncreaseDissolveDelay(publicKey, additionalDissolveDelay) {
|
|
266
305
|
return __awaiter(this, void 0, void 0, function* () {
|
|
267
306
|
// Create subaccount from publicKey
|
|
268
307
|
const { subAccount, nonce: _ } = (0, ICPImplementation_1.getFixedSubaccountFromPublicKey)(publicKey);
|
|
@@ -290,22 +329,31 @@ function createUnsignedTransactionIncreaseDelay(publicKey, delaySeconds) {
|
|
|
290
329
|
// Encode
|
|
291
330
|
const unsignedTransactionBuffer = IDL.encode([ManageNeuron], [
|
|
292
331
|
{
|
|
293
|
-
|
|
294
|
-
|
|
332
|
+
id: [],
|
|
333
|
+
command: [
|
|
334
|
+
{
|
|
335
|
+
Configure: {
|
|
336
|
+
operation: [
|
|
337
|
+
{
|
|
338
|
+
IncreaseDissolveDelay: { additional_dissolve_delay_seconds: additionalDissolveDelay }
|
|
339
|
+
}
|
|
340
|
+
]
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
],
|
|
344
|
+
neuron_id_or_subaccount: [{ Subaccount: subAccount.toUint8Array() }]
|
|
295
345
|
}
|
|
296
346
|
]);
|
|
297
|
-
return
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
]
|
|
304
|
-
});
|
|
347
|
+
return [
|
|
348
|
+
{
|
|
349
|
+
actionType: transaction_1.ICPActionType.INCREASE_DISSOLVE_DELAY,
|
|
350
|
+
encoded: (0, convert_1.arrayBufferToHexString)(unsignedTransactionBuffer)
|
|
351
|
+
}
|
|
352
|
+
];
|
|
305
353
|
});
|
|
306
354
|
}
|
|
307
|
-
exports.
|
|
308
|
-
function
|
|
355
|
+
exports.prepareIncreaseDissolveDelay = prepareIncreaseDissolveDelay;
|
|
356
|
+
function getDetailsFromUnsignedIncreaseDissolveDelay(publicKey, network) {
|
|
309
357
|
// Does not need info from transaction because it is only a call to the governance canister
|
|
310
358
|
return [
|
|
311
359
|
{
|
|
@@ -318,8 +366,8 @@ function getDetailsFromUnsignedTransactionIncreaseDelay(publicKey, network) {
|
|
|
318
366
|
}
|
|
319
367
|
];
|
|
320
368
|
}
|
|
321
|
-
exports.
|
|
322
|
-
function
|
|
369
|
+
exports.getDetailsFromUnsignedIncreaseDissolveDelay = getDetailsFromUnsignedIncreaseDissolveDelay;
|
|
370
|
+
function signIncreaseDissolveDelay(unsignedTransaction, privateKey, canisterId) {
|
|
323
371
|
return __awaiter(this, void 0, void 0, function* () {
|
|
324
372
|
// unsignedTransaction has already the arguments needed for signing, just need to be in a Buffer
|
|
325
373
|
const args = (0, convert_1.hexStringToArrayBuffer)(unsignedTransaction);
|
|
@@ -328,8 +376,8 @@ function signTransactionIncreaseDelay(unsignedTransaction, privateKey, canisterI
|
|
|
328
376
|
return signedTransaction;
|
|
329
377
|
});
|
|
330
378
|
}
|
|
331
|
-
exports.
|
|
332
|
-
function
|
|
379
|
+
exports.signIncreaseDissolveDelay = signIncreaseDissolveDelay;
|
|
380
|
+
function getDetailsFromSignedIncreaseDissolveDelay(publicKey, network) {
|
|
333
381
|
// Does not need info from transaction because it is only a call to the governance canister
|
|
334
382
|
return [
|
|
335
383
|
{
|
|
@@ -342,13 +390,13 @@ function getDetailsFromSignedTransactionIncreaseDelay(publicKey, network) {
|
|
|
342
390
|
}
|
|
343
391
|
];
|
|
344
392
|
}
|
|
345
|
-
exports.
|
|
393
|
+
exports.getDetailsFromSignedIncreaseDissolveDelay = getDetailsFromSignedIncreaseDissolveDelay;
|
|
346
394
|
// START_DISSOLVING
|
|
347
395
|
// CANISTER : (name: NNS Governance, identifier: rrkah-fqaaa-aaaaa-aaaaq-cai)
|
|
348
396
|
// METHOD : (name: manage_neuron, type: update)
|
|
349
397
|
// PAYLOAD : (id : [{id : float}], command : [{Configure : {operation : [{StartDissolving : {}}]}}], neuron_id_or_subaccount : [])
|
|
350
398
|
// RESPONSE : (command : [{configure : {}}])
|
|
351
|
-
function
|
|
399
|
+
function prepareStartDissolving(publicKey) {
|
|
352
400
|
return __awaiter(this, void 0, void 0, function* () {
|
|
353
401
|
// Create subaccount from publicKey
|
|
354
402
|
const { subAccount, nonce: _ } = (0, ICPImplementation_1.getFixedSubaccountFromPublicKey)(publicKey);
|
|
@@ -374,22 +422,21 @@ function createUnsignedTransactionStartDissolving(publicKey) {
|
|
|
374
422
|
// Encode
|
|
375
423
|
const unsignedTransactionBuffer = IDL.encode([ManageNeuron], [
|
|
376
424
|
{
|
|
425
|
+
id: [],
|
|
377
426
|
command: [{ Configure: { operation: [{ StartDissolving: {} }] } }],
|
|
378
|
-
neuron_id_or_subaccount: [{ Subaccount: subAccount }]
|
|
427
|
+
neuron_id_or_subaccount: [{ Subaccount: subAccount.toUint8Array() }]
|
|
379
428
|
}
|
|
380
429
|
]);
|
|
381
|
-
return
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
]
|
|
388
|
-
});
|
|
430
|
+
return [
|
|
431
|
+
{
|
|
432
|
+
actionType: transaction_1.ICPActionType.START_DISSOLVING,
|
|
433
|
+
encoded: (0, convert_1.arrayBufferToHexString)(unsignedTransactionBuffer)
|
|
434
|
+
}
|
|
435
|
+
];
|
|
389
436
|
});
|
|
390
437
|
}
|
|
391
|
-
exports.
|
|
392
|
-
function
|
|
438
|
+
exports.prepareStartDissolving = prepareStartDissolving;
|
|
439
|
+
function getDetailsFromUnsignedStartDissolving(publicKey, network) {
|
|
393
440
|
// Does not need info from transaction because it is only a call to the governance canister
|
|
394
441
|
return [
|
|
395
442
|
{
|
|
@@ -398,12 +445,13 @@ function getDetailsFromUnsignedTransactionStartDissolving(publicKey, network) {
|
|
|
398
445
|
isInbound: false,
|
|
399
446
|
amount: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
400
447
|
fee: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
401
|
-
network
|
|
448
|
+
network,
|
|
449
|
+
type: transaction_1.ICPActionType.START_DISSOLVING
|
|
402
450
|
}
|
|
403
451
|
];
|
|
404
452
|
}
|
|
405
|
-
exports.
|
|
406
|
-
function
|
|
453
|
+
exports.getDetailsFromUnsignedStartDissolving = getDetailsFromUnsignedStartDissolving;
|
|
454
|
+
function signStartDissolving(unsignedTransaction, privateKey, canisterId) {
|
|
407
455
|
return __awaiter(this, void 0, void 0, function* () {
|
|
408
456
|
// unsignedTransaction has already the arguments needed for signing, just need to be in a Buffer
|
|
409
457
|
const args = (0, convert_1.hexStringToArrayBuffer)(unsignedTransaction);
|
|
@@ -412,8 +460,8 @@ function signTransactionStartDissolving(unsignedTransaction, privateKey, caniste
|
|
|
412
460
|
return signedTransaction;
|
|
413
461
|
});
|
|
414
462
|
}
|
|
415
|
-
exports.
|
|
416
|
-
function
|
|
463
|
+
exports.signStartDissolving = signStartDissolving;
|
|
464
|
+
function getDetailsFromSignedStartDissolving(publicKey, network) {
|
|
417
465
|
// Does not need info from transaction because it is only a call to the governance canister
|
|
418
466
|
return [
|
|
419
467
|
{
|
|
@@ -422,17 +470,18 @@ function getDetailsFromSignedTransactionStartDissolving(publicKey, network) {
|
|
|
422
470
|
isInbound: false,
|
|
423
471
|
amount: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
424
472
|
fee: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
425
|
-
network: network
|
|
473
|
+
network: network,
|
|
474
|
+
type: transaction_1.ICPActionType.START_DISSOLVING
|
|
426
475
|
}
|
|
427
476
|
];
|
|
428
477
|
}
|
|
429
|
-
exports.
|
|
478
|
+
exports.getDetailsFromSignedStartDissolving = getDetailsFromSignedStartDissolving;
|
|
430
479
|
// STOP_DISSOLVING
|
|
431
480
|
// CANISTER : (name: NNS Governance, identifier: rrkah-fqaaa-aaaaa-aaaaq-cai)
|
|
432
481
|
// METHOD : (name: manage_neuron, type: update)
|
|
433
482
|
// PAYLOAD : (id : [{id : float}], command : [{Configure : {operation : [{StopDissolving : {}}]}}], neuron_id_or_subaccount : [])
|
|
434
483
|
// RESPONSE : (command : [{configure : {}}])
|
|
435
|
-
function
|
|
484
|
+
function prepareStopDissolving(publicKey) {
|
|
436
485
|
return __awaiter(this, void 0, void 0, function* () {
|
|
437
486
|
// Create subaccount from publicKey
|
|
438
487
|
const { subAccount, nonce: _ } = (0, ICPImplementation_1.getFixedSubaccountFromPublicKey)(publicKey);
|
|
@@ -458,22 +507,21 @@ function createUnsignedTransactionStopDissolving(publicKey) {
|
|
|
458
507
|
// Encode
|
|
459
508
|
const unsignedTransactionBuffer = IDL.encode([ManageNeuron], [
|
|
460
509
|
{
|
|
510
|
+
id: [],
|
|
461
511
|
command: [{ Configure: { operation: [{ StopDissolving: {} }] } }],
|
|
462
|
-
neuron_id_or_subaccount: [{ Subaccount: subAccount }]
|
|
512
|
+
neuron_id_or_subaccount: [{ Subaccount: subAccount.toUint8Array() }]
|
|
463
513
|
}
|
|
464
514
|
]);
|
|
465
|
-
return
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
]
|
|
472
|
-
});
|
|
515
|
+
return [
|
|
516
|
+
{
|
|
517
|
+
actionType: transaction_1.ICPActionType.STOP_DISSOLVING,
|
|
518
|
+
encoded: (0, convert_1.arrayBufferToHexString)(unsignedTransactionBuffer)
|
|
519
|
+
}
|
|
520
|
+
];
|
|
473
521
|
});
|
|
474
522
|
}
|
|
475
|
-
exports.
|
|
476
|
-
function
|
|
523
|
+
exports.prepareStopDissolving = prepareStopDissolving;
|
|
524
|
+
function getDetailsFromUnsignedStopDissolving(publicKey, network) {
|
|
477
525
|
// Does not need info from transaction because it is only a call to the governance canister
|
|
478
526
|
return [
|
|
479
527
|
{
|
|
@@ -482,12 +530,13 @@ function getDetailsFromUnsignedTransactionStopDissolving(publicKey, network) {
|
|
|
482
530
|
isInbound: false,
|
|
483
531
|
amount: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
484
532
|
fee: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
485
|
-
network
|
|
533
|
+
network,
|
|
534
|
+
type: transaction_1.ICPActionType.STOP_DISSOLVING
|
|
486
535
|
}
|
|
487
536
|
];
|
|
488
537
|
}
|
|
489
|
-
exports.
|
|
490
|
-
function
|
|
538
|
+
exports.getDetailsFromUnsignedStopDissolving = getDetailsFromUnsignedStopDissolving;
|
|
539
|
+
function signStopDissolving(unsignedTransaction, privateKey, canisterId) {
|
|
491
540
|
return __awaiter(this, void 0, void 0, function* () {
|
|
492
541
|
// unsignedTransaction has already the arguments needed for signing, just need to be in a Buffer
|
|
493
542
|
const args = (0, convert_1.hexStringToArrayBuffer)(unsignedTransaction);
|
|
@@ -496,8 +545,8 @@ function signTransactionStopDissolving(unsignedTransaction, privateKey, canister
|
|
|
496
545
|
return signedTransaction;
|
|
497
546
|
});
|
|
498
547
|
}
|
|
499
|
-
exports.
|
|
500
|
-
function
|
|
548
|
+
exports.signStopDissolving = signStopDissolving;
|
|
549
|
+
function getDetailsFromSignedStopDissolving(publicKey, network) {
|
|
501
550
|
// Does not need info from transaction because it is only a call to the governance canister
|
|
502
551
|
return [
|
|
503
552
|
{
|
|
@@ -506,28 +555,28 @@ function getDetailsFromSignedTransactionStopDissolving(publicKey, network) {
|
|
|
506
555
|
isInbound: false,
|
|
507
556
|
amount: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
508
557
|
fee: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
509
|
-
network
|
|
558
|
+
network,
|
|
559
|
+
type: transaction_1.ICPActionType.STOP_DISSOLVING
|
|
510
560
|
}
|
|
511
561
|
];
|
|
512
562
|
}
|
|
513
|
-
exports.
|
|
514
|
-
//
|
|
515
|
-
|
|
516
|
-
// METHOD : (name: manage_neuron, type: update)
|
|
517
|
-
// PAYLOAD : (id : [{id : float}], command : [{Follow : {topic : int, followees : [{id: int}]}}], neuron_id_or_subaccount : [])
|
|
518
|
-
// RESPONSE : (command : [{Follow : {}}])
|
|
519
|
-
function prepareFollowNeuron(publicKey, neuronId) {
|
|
563
|
+
exports.getDetailsFromSignedStopDissolving = getDetailsFromSignedStopDissolving;
|
|
564
|
+
// AUTO_STAKE_MATURITY
|
|
565
|
+
function prepareAutoStakeMaturity(publicKey) {
|
|
520
566
|
return __awaiter(this, void 0, void 0, function* () {
|
|
521
567
|
// Create subaccount from publicKey
|
|
522
568
|
const { subAccount, nonce: _ } = (0, ICPImplementation_1.getFixedSubaccountFromPublicKey)(publicKey);
|
|
523
|
-
// IDL for
|
|
569
|
+
// IDL for StartDissolving
|
|
524
570
|
const NeuronId = IDL.Record({ id: IDL.Nat64 });
|
|
525
|
-
const
|
|
526
|
-
|
|
527
|
-
|
|
571
|
+
const ChangeAutoStakeMaturity = IDL.Record({
|
|
572
|
+
requested_setting_for_auto_stake_maturity: IDL.Bool
|
|
573
|
+
});
|
|
574
|
+
const Operation = IDL.Variant({
|
|
575
|
+
ChangeAutoStakeMaturity: ChangeAutoStakeMaturity
|
|
528
576
|
});
|
|
577
|
+
const Configure = IDL.Record({ operation: IDL.Opt(Operation) });
|
|
529
578
|
const Command = IDL.Variant({
|
|
530
|
-
|
|
579
|
+
Configure: Configure
|
|
531
580
|
});
|
|
532
581
|
const NeuronIdOrSubaccount = IDL.Variant({
|
|
533
582
|
Subaccount: IDL.Vec(IDL.Nat8),
|
|
@@ -538,23 +587,36 @@ function prepareFollowNeuron(publicKey, neuronId) {
|
|
|
538
587
|
command: IDL.Opt(Command),
|
|
539
588
|
neuron_id_or_subaccount: IDL.Opt(NeuronIdOrSubaccount)
|
|
540
589
|
});
|
|
541
|
-
// TODO : get the topic that corresponds to all topics
|
|
542
|
-
const topic = 0;
|
|
543
590
|
// Encode
|
|
544
591
|
const unsignedTransactionBuffer = IDL.encode([ManageNeuron], [
|
|
545
592
|
{
|
|
546
|
-
|
|
547
|
-
|
|
593
|
+
id: [],
|
|
594
|
+
command: [
|
|
595
|
+
{
|
|
596
|
+
Configure: {
|
|
597
|
+
operation: [
|
|
598
|
+
{
|
|
599
|
+
ChangeAutoStakeMaturity: {
|
|
600
|
+
requested_setting_for_auto_stake_maturity: true
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
]
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
],
|
|
607
|
+
neuron_id_or_subaccount: [{ Subaccount: subAccount.toUint8Array() }]
|
|
548
608
|
}
|
|
549
609
|
]);
|
|
550
|
-
return
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
610
|
+
return [
|
|
611
|
+
{
|
|
612
|
+
actionType: transaction_1.ICPActionType.AUTO_STAKE_MATURITY,
|
|
613
|
+
encoded: (0, convert_1.arrayBufferToHexString)(unsignedTransactionBuffer)
|
|
614
|
+
}
|
|
615
|
+
];
|
|
554
616
|
});
|
|
555
617
|
}
|
|
556
|
-
exports.
|
|
557
|
-
function
|
|
618
|
+
exports.prepareAutoStakeMaturity = prepareAutoStakeMaturity;
|
|
619
|
+
function getDetailsFromUnsignedAutoStakeMaturity(publicKey, network) {
|
|
558
620
|
// Does not need info from transaction because it is only a call to the governance canister
|
|
559
621
|
return [
|
|
560
622
|
{
|
|
@@ -563,12 +625,13 @@ function getDetailsFromUnsignedFollowNeuron(publicKey, network) {
|
|
|
563
625
|
isInbound: false,
|
|
564
626
|
amount: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
565
627
|
fee: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
566
|
-
network
|
|
628
|
+
network,
|
|
629
|
+
type: transaction_1.ICPActionType.AUTO_STAKE_MATURITY
|
|
567
630
|
}
|
|
568
631
|
];
|
|
569
632
|
}
|
|
570
|
-
exports.
|
|
571
|
-
function
|
|
633
|
+
exports.getDetailsFromUnsignedAutoStakeMaturity = getDetailsFromUnsignedAutoStakeMaturity;
|
|
634
|
+
function signAutoStakeMaturity(unsignedTransaction, privateKey, canisterId) {
|
|
572
635
|
return __awaiter(this, void 0, void 0, function* () {
|
|
573
636
|
// unsignedTransaction has already the arguments needed for signing, just need to be in a Buffer
|
|
574
637
|
const args = (0, convert_1.hexStringToArrayBuffer)(unsignedTransaction);
|
|
@@ -577,8 +640,8 @@ function signFollowNeuron(unsignedTransaction, privateKey, canisterId) {
|
|
|
577
640
|
return signedTransaction;
|
|
578
641
|
});
|
|
579
642
|
}
|
|
580
|
-
exports.
|
|
581
|
-
function
|
|
643
|
+
exports.signAutoStakeMaturity = signAutoStakeMaturity;
|
|
644
|
+
function getDetailsFromSignedAutoStakeMaturity(publicKey, network) {
|
|
582
645
|
// Does not need info from transaction because it is only a call to the governance canister
|
|
583
646
|
return [
|
|
584
647
|
{
|
|
@@ -587,27 +650,29 @@ function getDetailsFromSignedFollowNeuron(publicKey, network) {
|
|
|
587
650
|
isInbound: false,
|
|
588
651
|
amount: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
589
652
|
fee: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
590
|
-
network
|
|
653
|
+
network,
|
|
654
|
+
type: transaction_1.ICPActionType.AUTO_STAKE_MATURITY
|
|
591
655
|
}
|
|
592
656
|
];
|
|
593
657
|
}
|
|
594
|
-
exports.
|
|
595
|
-
//
|
|
658
|
+
exports.getDetailsFromSignedAutoStakeMaturity = getDetailsFromSignedAutoStakeMaturity;
|
|
659
|
+
// FOLLOW_NEURON
|
|
596
660
|
// CANISTER : (name: NNS Governance, identifier: rrkah-fqaaa-aaaaa-aaaaq-cai)
|
|
597
661
|
// METHOD : (name: manage_neuron, type: update)
|
|
598
|
-
// PAYLOAD : (id : [{id : float}], command : [{
|
|
599
|
-
// RESPONSE : (command : [{
|
|
600
|
-
function
|
|
662
|
+
// PAYLOAD : (id : [{id : float}], command : [{Follow : {topic : int, followees : [{id: int}]}}], neuron_id_or_subaccount : [])
|
|
663
|
+
// RESPONSE : (command : [{Follow : {}}])
|
|
664
|
+
function prepareFollowNeuron(publicKey, neuronId) {
|
|
601
665
|
return __awaiter(this, void 0, void 0, function* () {
|
|
602
666
|
// Create subaccount from publicKey
|
|
603
667
|
const { subAccount, nonce: _ } = (0, ICPImplementation_1.getFixedSubaccountFromPublicKey)(publicKey);
|
|
604
|
-
// IDL for
|
|
668
|
+
// IDL for FollowNeuron
|
|
605
669
|
const NeuronId = IDL.Record({ id: IDL.Nat64 });
|
|
606
|
-
const
|
|
607
|
-
|
|
670
|
+
const Follow = IDL.Record({
|
|
671
|
+
topic: IDL.Int32,
|
|
672
|
+
followees: IDL.Vec(NeuronId)
|
|
608
673
|
});
|
|
609
674
|
const Command = IDL.Variant({
|
|
610
|
-
|
|
675
|
+
Follow: Follow
|
|
611
676
|
});
|
|
612
677
|
const NeuronIdOrSubaccount = IDL.Variant({
|
|
613
678
|
Subaccount: IDL.Vec(IDL.Nat8),
|
|
@@ -618,25 +683,25 @@ function createUnsignedTransactionRestakeMaturity(publicKey, percentageStake) {
|
|
|
618
683
|
command: IDL.Opt(Command),
|
|
619
684
|
neuron_id_or_subaccount: IDL.Opt(NeuronIdOrSubaccount)
|
|
620
685
|
});
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
neuron_id_or_subaccount: [{ Subaccount: subAccount }]
|
|
626
|
-
}
|
|
627
|
-
]);
|
|
628
|
-
return (0, module_kit_1.newUnsignedTransaction)({
|
|
629
|
-
transactions: [
|
|
686
|
+
const topics = [0 /* All Except Governance, and SNS & Community Fund */, 4 /* Governance */, 14 /* SNS & Community Fund */];
|
|
687
|
+
return topics.map((topic) => {
|
|
688
|
+
// Encode
|
|
689
|
+
const unsignedTransactionBuffer = IDL.encode([ManageNeuron], [
|
|
630
690
|
{
|
|
631
|
-
|
|
632
|
-
|
|
691
|
+
id: [],
|
|
692
|
+
command: [{ Follow: { topic: topic, followees: neuronId !== undefined ? [{ id: neuronId }] : [] } }],
|
|
693
|
+
neuron_id_or_subaccount: [{ Subaccount: subAccount.toUint8Array() }]
|
|
633
694
|
}
|
|
634
|
-
]
|
|
695
|
+
]);
|
|
696
|
+
return {
|
|
697
|
+
actionType: transaction_1.ICPActionType.FOLLOW_NEURON,
|
|
698
|
+
encoded: (0, convert_1.arrayBufferToHexString)(unsignedTransactionBuffer)
|
|
699
|
+
};
|
|
635
700
|
});
|
|
636
701
|
});
|
|
637
702
|
}
|
|
638
|
-
exports.
|
|
639
|
-
function
|
|
703
|
+
exports.prepareFollowNeuron = prepareFollowNeuron;
|
|
704
|
+
function getDetailsFromUnsignedFollowNeuron(publicKey, network) {
|
|
640
705
|
// Does not need info from transaction because it is only a call to the governance canister
|
|
641
706
|
return [
|
|
642
707
|
{
|
|
@@ -645,12 +710,13 @@ function getDetailsFromUnsignedTransactionRestakeMaturity(publicKey, network) {
|
|
|
645
710
|
isInbound: false,
|
|
646
711
|
amount: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
647
712
|
fee: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
648
|
-
network
|
|
713
|
+
network,
|
|
714
|
+
type: transaction_1.ICPActionType.FOLLOW_NEURON
|
|
649
715
|
}
|
|
650
716
|
];
|
|
651
717
|
}
|
|
652
|
-
exports.
|
|
653
|
-
function
|
|
718
|
+
exports.getDetailsFromUnsignedFollowNeuron = getDetailsFromUnsignedFollowNeuron;
|
|
719
|
+
function signFollowNeuron(unsignedTransaction, privateKey, canisterId) {
|
|
654
720
|
return __awaiter(this, void 0, void 0, function* () {
|
|
655
721
|
// unsignedTransaction has already the arguments needed for signing, just need to be in a Buffer
|
|
656
722
|
const args = (0, convert_1.hexStringToArrayBuffer)(unsignedTransaction);
|
|
@@ -659,8 +725,8 @@ function signTransactionRestakeMaturity(unsignedTransaction, privateKey, caniste
|
|
|
659
725
|
return signedTransaction;
|
|
660
726
|
});
|
|
661
727
|
}
|
|
662
|
-
exports.
|
|
663
|
-
function
|
|
728
|
+
exports.signFollowNeuron = signFollowNeuron;
|
|
729
|
+
function getDetailsFromSignedFollowNeuron(publicKey, network) {
|
|
664
730
|
// Does not need info from transaction because it is only a call to the governance canister
|
|
665
731
|
return [
|
|
666
732
|
{
|
|
@@ -669,51 +735,78 @@ function getDetailsFromSignedTransactionRestakeMaturity(publicKey, network) {
|
|
|
669
735
|
isInbound: false,
|
|
670
736
|
amount: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
671
737
|
fee: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
672
|
-
network
|
|
738
|
+
network,
|
|
739
|
+
type: transaction_1.ICPActionType.FOLLOW_NEURON
|
|
673
740
|
}
|
|
674
741
|
];
|
|
675
742
|
}
|
|
676
|
-
exports.
|
|
743
|
+
exports.getDetailsFromSignedFollowNeuron = getDetailsFromSignedFollowNeuron;
|
|
677
744
|
// DISBURSE
|
|
678
745
|
// Cannot extrapolate method from call since we have to wait 6 months to do so
|
|
679
|
-
function
|
|
746
|
+
function prepareDisburse(publicKey) {
|
|
680
747
|
return __awaiter(this, void 0, void 0, function* () {
|
|
681
748
|
// Create subaccount from publicKey
|
|
682
749
|
const { subAccount, nonce: _ } = (0, ICPImplementation_1.getFixedSubaccountFromPublicKey)(publicKey);
|
|
683
|
-
// IDL for
|
|
750
|
+
// IDL for Disburse
|
|
751
|
+
const NeuronId = IDL.Record({ id: IDL.Nat64 });
|
|
752
|
+
const AccountIdentifier = IDL.Record({ hash: IDL.Vec(IDL.Nat8) });
|
|
753
|
+
const Amount = IDL.Record({ e8s: IDL.Nat64 });
|
|
754
|
+
const Disburse = IDL.Record({
|
|
755
|
+
to_account: IDL.Opt(AccountIdentifier),
|
|
756
|
+
amount: IDL.Opt(Amount)
|
|
757
|
+
});
|
|
758
|
+
const Command = IDL.Variant({
|
|
759
|
+
Disburse: Disburse
|
|
760
|
+
});
|
|
761
|
+
const NeuronIdOrSubaccount = IDL.Variant({
|
|
762
|
+
Subaccount: IDL.Vec(IDL.Nat8),
|
|
763
|
+
NeuronId: NeuronId
|
|
764
|
+
});
|
|
765
|
+
const ManageNeuron = IDL.Record({
|
|
766
|
+
id: IDL.Opt(NeuronId),
|
|
767
|
+
command: IDL.Opt(Command),
|
|
768
|
+
neuron_id_or_subaccount: IDL.Opt(NeuronIdOrSubaccount)
|
|
769
|
+
});
|
|
684
770
|
// Encode
|
|
685
|
-
const unsignedTransactionBuffer = IDL.encode([], [
|
|
771
|
+
const unsignedTransactionBuffer = IDL.encode([ManageNeuron], [
|
|
686
772
|
{
|
|
687
|
-
|
|
688
|
-
|
|
773
|
+
id: [],
|
|
774
|
+
command: [
|
|
775
|
+
{
|
|
776
|
+
Disburse: {
|
|
777
|
+
to_account: [],
|
|
778
|
+
amount: []
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
],
|
|
782
|
+
neuron_id_or_subaccount: [{ Subaccount: subAccount.toUint8Array() }]
|
|
689
783
|
}
|
|
690
784
|
]);
|
|
691
|
-
return
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
]
|
|
698
|
-
});
|
|
785
|
+
return [
|
|
786
|
+
{
|
|
787
|
+
actionType: transaction_1.ICPActionType.DISBURSE,
|
|
788
|
+
encoded: (0, convert_1.arrayBufferToHexString)(unsignedTransactionBuffer)
|
|
789
|
+
}
|
|
790
|
+
];
|
|
699
791
|
});
|
|
700
792
|
}
|
|
701
|
-
exports.
|
|
702
|
-
function
|
|
793
|
+
exports.prepareDisburse = prepareDisburse;
|
|
794
|
+
function getDetailsFromUnsignedDisburse(publicKey, network) {
|
|
703
795
|
// Does not need info from transaction because it is only a call to the governance canister
|
|
704
796
|
return [
|
|
705
797
|
{
|
|
706
|
-
from: [
|
|
707
|
-
to: [
|
|
798
|
+
from: [network.governanceCanisterId],
|
|
799
|
+
to: [(0, ICPImplementation_1.getAddressFromPublicKey)(publicKey)],
|
|
708
800
|
isInbound: false,
|
|
709
801
|
amount: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
710
802
|
fee: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
711
|
-
network: network
|
|
803
|
+
network: network,
|
|
804
|
+
type: transaction_1.ICPActionType.DISBURSE
|
|
712
805
|
}
|
|
713
806
|
];
|
|
714
807
|
}
|
|
715
|
-
exports.
|
|
716
|
-
function
|
|
808
|
+
exports.getDetailsFromUnsignedDisburse = getDetailsFromUnsignedDisburse;
|
|
809
|
+
function signDisburse(unsignedTransaction, privateKey, canisterId) {
|
|
717
810
|
return __awaiter(this, void 0, void 0, function* () {
|
|
718
811
|
// unsignedTransaction has already the arguments needed for signing, just need to be in a Buffer
|
|
719
812
|
const args = (0, convert_1.hexStringToArrayBuffer)(unsignedTransaction);
|
|
@@ -722,19 +815,20 @@ function signTransactionRemoveStake(unsignedTransaction, privateKey, canisterId)
|
|
|
722
815
|
return signedTransaction;
|
|
723
816
|
});
|
|
724
817
|
}
|
|
725
|
-
exports.
|
|
726
|
-
function
|
|
818
|
+
exports.signDisburse = signDisburse;
|
|
819
|
+
function getDetailsFromSignedDisburse(publicKey, network) {
|
|
727
820
|
// Does not need info from transaction because it is only a call to the governance canister
|
|
728
821
|
return [
|
|
729
822
|
{
|
|
730
|
-
from: [
|
|
731
|
-
to: [
|
|
823
|
+
from: [network.governanceCanisterId],
|
|
824
|
+
to: [(0, ICPImplementation_1.getAddressFromPublicKey)(publicKey)],
|
|
732
825
|
isInbound: false,
|
|
733
826
|
amount: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
734
827
|
fee: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
735
|
-
network
|
|
828
|
+
network,
|
|
829
|
+
type: transaction_1.ICPActionType.DISBURSE
|
|
736
830
|
}
|
|
737
831
|
];
|
|
738
832
|
}
|
|
739
|
-
exports.
|
|
833
|
+
exports.getDetailsFromSignedDisburse = getDetailsFromSignedDisburse;
|
|
740
834
|
//# sourceMappingURL=ICPGovernance.js.map
|