@airgap/icp 0.13.15-beta.6 → 0.13.15-beta.8
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/protocol/ICPGovernance.d.ts +29 -29
- package/v1/protocol/ICPGovernance.js +530 -150
- package/v1/protocol/ICPGovernance.js.map +1 -1
- package/v1/protocol/ICPImplementation.d.ts +2 -1
- package/v1/protocol/ICPImplementation.js +11 -26
- package/v1/protocol/ICPImplementation.js.map +1 -1
- package/v1/protocol/ICPProtocol.d.ts +8 -4
- package/v1/protocol/ICPProtocol.js +139 -102
- package/v1/protocol/ICPProtocol.js.map +1 -1
- package/v1/serializer/v3/schemas/converter/transaction-converter.js +34 -4
- package/v1/serializer/v3/schemas/converter/transaction-converter.js.map +1 -1
- package/v1/serializer/v3/schemas/definitions/transaction-sign-request-icp.d.ts +8 -2
- package/v1/serializer/v3/schemas/generated/transaction-sign-request-icp.json +8 -4
- package/v1/serializer/v3/serializer-companion.js +0 -1
- package/v1/serializer/v3/serializer-companion.js.map +1 -1
- package/v1/types/governance.d.ts +6 -8
- package/v1/types/governance.js +4 -7
- package/v1/types/governance.js.map +1 -1
- package/v1/types/transaction.d.ts +2 -2
- package/v1/types/transaction.js +6 -6
- package/v1/types/transaction.js.map +1 -1
- package/v1/utils/json.d.ts +1 -0
- package/v1/utils/json.js +19 -0
- package/v1/utils/json.js.map +1 -0
|
@@ -32,12 +32,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
32
32
|
});
|
|
33
33
|
};
|
|
34
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
-
exports.getDetailsFromSignedDisburse = exports.signDisburse = exports.getDetailsFromUnsignedDisburse = exports.prepareDisburse = 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.getDetailsFromSignedClaimGovernance = 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");
|
|
39
|
+
const Cbor = __importStar(require("../utils/cbor"));
|
|
39
40
|
const convert_1 = require("../utils/convert");
|
|
40
41
|
const IDL = __importStar(require("../utils/idl"));
|
|
42
|
+
const json_1 = require("../utils/json");
|
|
41
43
|
const principal_1 = require("../utils/principal");
|
|
42
44
|
const ICPImplementation_1 = require("./ICPImplementation");
|
|
43
45
|
// GET_NEURON_INFO
|
|
@@ -91,10 +93,12 @@ const ICPImplementation_1 = require("./ICPImplementation");
|
|
|
91
93
|
function prepareGetNeuronInfo() {
|
|
92
94
|
return __awaiter(this, void 0, void 0, function* () {
|
|
93
95
|
// Does not need to create a transaction as it is only a call to the governance token
|
|
94
|
-
return
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
96
|
+
return [
|
|
97
|
+
{
|
|
98
|
+
actionType: transaction_1.ICPActionType.GET_NEURON_INFO,
|
|
99
|
+
encoded: ''
|
|
100
|
+
}
|
|
101
|
+
];
|
|
98
102
|
});
|
|
99
103
|
}
|
|
100
104
|
exports.prepareGetNeuronInfo = prepareGetNeuronInfo;
|
|
@@ -113,7 +117,7 @@ function getDetailsFromUnsignedGetNeuronInfo(publicKey, network) {
|
|
|
113
117
|
];
|
|
114
118
|
}
|
|
115
119
|
exports.getDetailsFromUnsignedGetNeuronInfo = getDetailsFromUnsignedGetNeuronInfo;
|
|
116
|
-
function signGetNeuronInfo(
|
|
120
|
+
function signGetNeuronInfo(_unsignedTransaction, privateKey, canisterId) {
|
|
117
121
|
return __awaiter(this, void 0, void 0, function* () {
|
|
118
122
|
const NeuronIdOrSubaccount = IDL.Variant({
|
|
119
123
|
Subaccount: IDL.Vec(IDL.Nat8)
|
|
@@ -125,8 +129,12 @@ function signGetNeuronInfo(unsignedTransaction, privateKey, canisterId) {
|
|
|
125
129
|
});
|
|
126
130
|
}
|
|
127
131
|
exports.signGetNeuronInfo = signGetNeuronInfo;
|
|
128
|
-
function getDetailsFromSignedGetNeuronInfo(publicKey, network) {
|
|
129
|
-
|
|
132
|
+
function getDetailsFromSignedGetNeuronInfo(encoded, publicKey, network) {
|
|
133
|
+
const NeuronIdOrSubaccount = IDL.Variant({
|
|
134
|
+
Subaccount: IDL.Vec(IDL.Nat8)
|
|
135
|
+
});
|
|
136
|
+
const cborDecoded = Cbor.decode((0, convert_1.hexStringToArrayBuffer)(encoded));
|
|
137
|
+
const neuronIdOrSubaccount = IDL.decode([NeuronIdOrSubaccount], cborDecoded.content.arg)[0];
|
|
130
138
|
return [
|
|
131
139
|
{
|
|
132
140
|
from: [(0, ICPImplementation_1.getAddressFromPublicKey)(publicKey)],
|
|
@@ -135,7 +143,8 @@ function getDetailsFromSignedGetNeuronInfo(publicKey, network) {
|
|
|
135
143
|
amount: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
136
144
|
fee: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
137
145
|
network,
|
|
138
|
-
type: transaction_1.ICPActionType.GET_NEURON_INFO
|
|
146
|
+
type: transaction_1.ICPActionType.GET_NEURON_INFO,
|
|
147
|
+
json: Object.assign(Object.assign({}, cborDecoded.content), { arg: (0, json_1.idlDecodedToJsonStringifiable)(neuronIdOrSubaccount) })
|
|
139
148
|
}
|
|
140
149
|
];
|
|
141
150
|
}
|
|
@@ -159,10 +168,12 @@ function prepareTransferToSubaccount(publicKey, canisterId, amount, fee) {
|
|
|
159
168
|
to: accountIdentifier.toHex(),
|
|
160
169
|
fee
|
|
161
170
|
});
|
|
162
|
-
return
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
171
|
+
return [
|
|
172
|
+
{
|
|
173
|
+
actionType: transaction_1.ICPActionType.TRANSFER_TO_SUBACCOUNT,
|
|
174
|
+
encoded: unsignedTransfer
|
|
175
|
+
}
|
|
176
|
+
];
|
|
166
177
|
});
|
|
167
178
|
}
|
|
168
179
|
exports.prepareTransferToSubaccount = prepareTransferToSubaccount;
|
|
@@ -176,7 +187,8 @@ function getDetailsFromUnsignedTransferToSubaccount(unsignedTransaction, publicK
|
|
|
176
187
|
amount: (0, module_kit_1.newAmount)(info.amount.toString(), 'blockchain'),
|
|
177
188
|
fee: (0, module_kit_1.newAmount)(info.fee.toString(), 'blockchain'),
|
|
178
189
|
network,
|
|
179
|
-
type: transaction_1.ICPActionType.TRANSFER_TO_SUBACCOUNT
|
|
190
|
+
type: transaction_1.ICPActionType.TRANSFER_TO_SUBACCOUNT,
|
|
191
|
+
json: (0, json_1.idlDecodedToJsonStringifiable)(info.json)
|
|
180
192
|
}
|
|
181
193
|
];
|
|
182
194
|
}
|
|
@@ -243,15 +255,41 @@ function prepareClaimOrRefreshNeuron(publicKey) {
|
|
|
243
255
|
neuron_id_or_subaccount: []
|
|
244
256
|
}
|
|
245
257
|
]);
|
|
246
|
-
return
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
258
|
+
return [
|
|
259
|
+
{
|
|
260
|
+
actionType: transaction_1.ICPActionType.CLAIM_GOVERNANCE,
|
|
261
|
+
encoded: (0, convert_1.arrayBufferToHexString)(unsignedTransactionBuffer)
|
|
262
|
+
}
|
|
263
|
+
];
|
|
250
264
|
});
|
|
251
265
|
}
|
|
252
266
|
exports.prepareClaimOrRefreshNeuron = prepareClaimOrRefreshNeuron;
|
|
253
|
-
function getDetailsFromUnsignedClaimGovernance(publicKey, network) {
|
|
254
|
-
//
|
|
267
|
+
function getDetailsFromUnsignedClaimGovernance(encoded, publicKey, network) {
|
|
268
|
+
// IDL for ManageNeuron
|
|
269
|
+
const NeuronId = IDL.Record({ id: IDL.Nat64 });
|
|
270
|
+
const ClaimOrRefreshNeuronFromAccount = IDL.Record({
|
|
271
|
+
controller: IDL.Opt(IDL.Principal),
|
|
272
|
+
memo: IDL.Nat64
|
|
273
|
+
});
|
|
274
|
+
const By = IDL.Variant({
|
|
275
|
+
NeuronIdOrSubaccount: IDL.Record({}),
|
|
276
|
+
MemoAndController: ClaimOrRefreshNeuronFromAccount,
|
|
277
|
+
Memo: IDL.Nat64
|
|
278
|
+
});
|
|
279
|
+
const ClaimOrRefresh = IDL.Record({ by: IDL.Opt(By) });
|
|
280
|
+
const Command = IDL.Variant({
|
|
281
|
+
ClaimOrRefresh: ClaimOrRefresh
|
|
282
|
+
});
|
|
283
|
+
const NeuronIdOrSubaccount = IDL.Variant({
|
|
284
|
+
Subaccount: IDL.Vec(IDL.Nat8),
|
|
285
|
+
NeuronId: NeuronId
|
|
286
|
+
});
|
|
287
|
+
const ManageNeuron = IDL.Record({
|
|
288
|
+
id: IDL.Opt(NeuronId),
|
|
289
|
+
command: IDL.Opt(Command),
|
|
290
|
+
neuron_id_or_subaccount: IDL.Opt(NeuronIdOrSubaccount)
|
|
291
|
+
});
|
|
292
|
+
const manageNeuron = IDL.decode([ManageNeuron], (0, convert_1.hexStringToArrayBuffer)(encoded))[0];
|
|
255
293
|
return [
|
|
256
294
|
{
|
|
257
295
|
from: [(0, ICPImplementation_1.getAddressFromPublicKey)(publicKey)],
|
|
@@ -260,7 +298,10 @@ function getDetailsFromUnsignedClaimGovernance(publicKey, network) {
|
|
|
260
298
|
amount: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
261
299
|
fee: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
262
300
|
network,
|
|
263
|
-
type: transaction_1.ICPActionType.CLAIM_GOVERNANCE
|
|
301
|
+
type: transaction_1.ICPActionType.CLAIM_GOVERNANCE,
|
|
302
|
+
json: {
|
|
303
|
+
ManageNeuron: (0, json_1.idlDecodedToJsonStringifiable)(manageNeuron)
|
|
304
|
+
}
|
|
264
305
|
}
|
|
265
306
|
];
|
|
266
307
|
}
|
|
@@ -275,8 +316,33 @@ function signClaimGovernance(unsignedTransaction, privateKey, canisterId) {
|
|
|
275
316
|
});
|
|
276
317
|
}
|
|
277
318
|
exports.signClaimGovernance = signClaimGovernance;
|
|
278
|
-
function
|
|
279
|
-
//
|
|
319
|
+
function getDetailsFromSignedClaimGovernance(encoded, publicKey, network) {
|
|
320
|
+
// IDL for ManageNeuron
|
|
321
|
+
const NeuronId = IDL.Record({ id: IDL.Nat64 });
|
|
322
|
+
const ClaimOrRefreshNeuronFromAccount = IDL.Record({
|
|
323
|
+
controller: IDL.Opt(IDL.Principal),
|
|
324
|
+
memo: IDL.Nat64
|
|
325
|
+
});
|
|
326
|
+
const By = IDL.Variant({
|
|
327
|
+
NeuronIdOrSubaccount: IDL.Record({}),
|
|
328
|
+
MemoAndController: ClaimOrRefreshNeuronFromAccount,
|
|
329
|
+
Memo: IDL.Nat64
|
|
330
|
+
});
|
|
331
|
+
const ClaimOrRefresh = IDL.Record({ by: IDL.Opt(By) });
|
|
332
|
+
const Command = IDL.Variant({
|
|
333
|
+
ClaimOrRefresh: ClaimOrRefresh
|
|
334
|
+
});
|
|
335
|
+
const NeuronIdOrSubaccount = IDL.Variant({
|
|
336
|
+
Subaccount: IDL.Vec(IDL.Nat8),
|
|
337
|
+
NeuronId: NeuronId
|
|
338
|
+
});
|
|
339
|
+
const ManageNeuron = IDL.Record({
|
|
340
|
+
id: IDL.Opt(NeuronId),
|
|
341
|
+
command: IDL.Opt(Command),
|
|
342
|
+
neuron_id_or_subaccount: IDL.Opt(NeuronIdOrSubaccount)
|
|
343
|
+
});
|
|
344
|
+
const cborDecoded = Cbor.decode((0, convert_1.hexStringToArrayBuffer)(encoded));
|
|
345
|
+
const manageNeuron = IDL.decode([ManageNeuron], cborDecoded.content.arg)[0];
|
|
280
346
|
return [
|
|
281
347
|
{
|
|
282
348
|
from: [(0, ICPImplementation_1.getAddressFromPublicKey)(publicKey)],
|
|
@@ -285,17 +351,18 @@ function getDetailsFromTransactionClaimGovernance(publicKey, network) {
|
|
|
285
351
|
amount: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
286
352
|
fee: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
287
353
|
network,
|
|
288
|
-
type: transaction_1.ICPActionType.CLAIM_GOVERNANCE
|
|
354
|
+
type: transaction_1.ICPActionType.CLAIM_GOVERNANCE,
|
|
355
|
+
json: Object.assign(Object.assign({}, cborDecoded.content), { arg: (0, json_1.idlDecodedToJsonStringifiable)(manageNeuron) })
|
|
289
356
|
}
|
|
290
357
|
];
|
|
291
358
|
}
|
|
292
|
-
exports.
|
|
293
|
-
//
|
|
359
|
+
exports.getDetailsFromSignedClaimGovernance = getDetailsFromSignedClaimGovernance;
|
|
360
|
+
// INCREASE_DISSOLVE_DELAY
|
|
294
361
|
// CANISTER : (name: NNS Governance, identifier: rrkah-fqaaa-aaaaa-aaaaq-cai)
|
|
295
362
|
// METHOD : (name: manage_neuron, type: update)
|
|
296
363
|
// PAYLOAD : (id : [{id : float}], command : [{Configure : {operation : [{IncreaseDissolveDelay : {additional_dissolve_delay_seconds : int}}]}}], neuron_id_or_subaccount : [])
|
|
297
364
|
// RESPONSE : (command : [{configure : {}}])
|
|
298
|
-
function
|
|
365
|
+
function prepareIncreaseDissolveDelay(publicKey, additionalDissolveDelay) {
|
|
299
366
|
return __awaiter(this, void 0, void 0, function* () {
|
|
300
367
|
// Create subaccount from publicKey
|
|
301
368
|
const { subAccount, nonce: _ } = (0, ICPImplementation_1.getFixedSubaccountFromPublicKey)(publicKey);
|
|
@@ -323,23 +390,53 @@ function createUnsignedTransactionIncreaseDelay(publicKey, delaySeconds) {
|
|
|
323
390
|
// Encode
|
|
324
391
|
const unsignedTransactionBuffer = IDL.encode([ManageNeuron], [
|
|
325
392
|
{
|
|
326
|
-
|
|
393
|
+
id: [],
|
|
394
|
+
command: [
|
|
395
|
+
{
|
|
396
|
+
Configure: {
|
|
397
|
+
operation: [
|
|
398
|
+
{
|
|
399
|
+
IncreaseDissolveDelay: { additional_dissolve_delay_seconds: additionalDissolveDelay }
|
|
400
|
+
}
|
|
401
|
+
]
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
],
|
|
327
405
|
neuron_id_or_subaccount: [{ Subaccount: subAccount.toUint8Array() }]
|
|
328
406
|
}
|
|
329
407
|
]);
|
|
330
|
-
return
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
]
|
|
337
|
-
});
|
|
408
|
+
return [
|
|
409
|
+
{
|
|
410
|
+
actionType: transaction_1.ICPActionType.INCREASE_DISSOLVE_DELAY,
|
|
411
|
+
encoded: (0, convert_1.arrayBufferToHexString)(unsignedTransactionBuffer)
|
|
412
|
+
}
|
|
413
|
+
];
|
|
338
414
|
});
|
|
339
415
|
}
|
|
340
|
-
exports.
|
|
341
|
-
function
|
|
342
|
-
//
|
|
416
|
+
exports.prepareIncreaseDissolveDelay = prepareIncreaseDissolveDelay;
|
|
417
|
+
function getDetailsFromUnsignedIncreaseDissolveDelay(encoded, publicKey, network) {
|
|
418
|
+
// IDL for IncreaseDissolveDelay
|
|
419
|
+
const NeuronId = IDL.Record({ id: IDL.Nat64 });
|
|
420
|
+
const IncreaseDissolveDelay = IDL.Record({
|
|
421
|
+
additional_dissolve_delay_seconds: IDL.Nat32
|
|
422
|
+
});
|
|
423
|
+
const Operation = IDL.Variant({
|
|
424
|
+
IncreaseDissolveDelay: IncreaseDissolveDelay
|
|
425
|
+
});
|
|
426
|
+
const Configure = IDL.Record({ operation: IDL.Opt(Operation) });
|
|
427
|
+
const Command = IDL.Variant({
|
|
428
|
+
Configure: Configure
|
|
429
|
+
});
|
|
430
|
+
const NeuronIdOrSubaccount = IDL.Variant({
|
|
431
|
+
Subaccount: IDL.Vec(IDL.Nat8),
|
|
432
|
+
NeuronId: NeuronId
|
|
433
|
+
});
|
|
434
|
+
const ManageNeuron = IDL.Record({
|
|
435
|
+
id: IDL.Opt(NeuronId),
|
|
436
|
+
command: IDL.Opt(Command),
|
|
437
|
+
neuron_id_or_subaccount: IDL.Opt(NeuronIdOrSubaccount)
|
|
438
|
+
});
|
|
439
|
+
const manageNeuron = IDL.decode([ManageNeuron], (0, convert_1.hexStringToArrayBuffer)(encoded))[0];
|
|
343
440
|
return [
|
|
344
441
|
{
|
|
345
442
|
from: [(0, ICPImplementation_1.getAddressFromPublicKey)(publicKey)],
|
|
@@ -347,12 +444,16 @@ function getDetailsFromUnsignedTransactionIncreaseDelay(publicKey, network) {
|
|
|
347
444
|
isInbound: false,
|
|
348
445
|
amount: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
349
446
|
fee: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
350
|
-
network
|
|
447
|
+
network,
|
|
448
|
+
type: transaction_1.ICPActionType.INCREASE_DISSOLVE_DELAY,
|
|
449
|
+
json: {
|
|
450
|
+
ManageNeuron: (0, json_1.idlDecodedToJsonStringifiable)(manageNeuron)
|
|
451
|
+
}
|
|
351
452
|
}
|
|
352
453
|
];
|
|
353
454
|
}
|
|
354
|
-
exports.
|
|
355
|
-
function
|
|
455
|
+
exports.getDetailsFromUnsignedIncreaseDissolveDelay = getDetailsFromUnsignedIncreaseDissolveDelay;
|
|
456
|
+
function signIncreaseDissolveDelay(unsignedTransaction, privateKey, canisterId) {
|
|
356
457
|
return __awaiter(this, void 0, void 0, function* () {
|
|
357
458
|
// unsignedTransaction has already the arguments needed for signing, just need to be in a Buffer
|
|
358
459
|
const args = (0, convert_1.hexStringToArrayBuffer)(unsignedTransaction);
|
|
@@ -361,9 +462,31 @@ function signTransactionIncreaseDelay(unsignedTransaction, privateKey, canisterI
|
|
|
361
462
|
return signedTransaction;
|
|
362
463
|
});
|
|
363
464
|
}
|
|
364
|
-
exports.
|
|
365
|
-
function
|
|
366
|
-
//
|
|
465
|
+
exports.signIncreaseDissolveDelay = signIncreaseDissolveDelay;
|
|
466
|
+
function getDetailsFromSignedIncreaseDissolveDelay(encoded, publicKey, network) {
|
|
467
|
+
// IDL for IncreaseDissolveDelay
|
|
468
|
+
const NeuronId = IDL.Record({ id: IDL.Nat64 });
|
|
469
|
+
const IncreaseDissolveDelay = IDL.Record({
|
|
470
|
+
additional_dissolve_delay_seconds: IDL.Nat32
|
|
471
|
+
});
|
|
472
|
+
const Operation = IDL.Variant({
|
|
473
|
+
IncreaseDissolveDelay: IncreaseDissolveDelay
|
|
474
|
+
});
|
|
475
|
+
const Configure = IDL.Record({ operation: IDL.Opt(Operation) });
|
|
476
|
+
const Command = IDL.Variant({
|
|
477
|
+
Configure: Configure
|
|
478
|
+
});
|
|
479
|
+
const NeuronIdOrSubaccount = IDL.Variant({
|
|
480
|
+
Subaccount: IDL.Vec(IDL.Nat8),
|
|
481
|
+
NeuronId: NeuronId
|
|
482
|
+
});
|
|
483
|
+
const ManageNeuron = IDL.Record({
|
|
484
|
+
id: IDL.Opt(NeuronId),
|
|
485
|
+
command: IDL.Opt(Command),
|
|
486
|
+
neuron_id_or_subaccount: IDL.Opt(NeuronIdOrSubaccount)
|
|
487
|
+
});
|
|
488
|
+
const cborDecoded = Cbor.decode((0, convert_1.hexStringToArrayBuffer)(encoded));
|
|
489
|
+
const manageNeuron = IDL.decode([ManageNeuron], cborDecoded.content.arg)[0];
|
|
367
490
|
return [
|
|
368
491
|
{
|
|
369
492
|
from: [(0, ICPImplementation_1.getAddressFromPublicKey)(publicKey)],
|
|
@@ -371,11 +494,13 @@ function getDetailsFromSignedTransactionIncreaseDelay(publicKey, network) {
|
|
|
371
494
|
isInbound: false,
|
|
372
495
|
amount: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
373
496
|
fee: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
374
|
-
network
|
|
497
|
+
network,
|
|
498
|
+
type: transaction_1.ICPActionType.INCREASE_DISSOLVE_DELAY,
|
|
499
|
+
json: Object.assign(Object.assign({}, cborDecoded.content), { arg: (0, json_1.idlDecodedToJsonStringifiable)(manageNeuron) })
|
|
375
500
|
}
|
|
376
501
|
];
|
|
377
502
|
}
|
|
378
|
-
exports.
|
|
503
|
+
exports.getDetailsFromSignedIncreaseDissolveDelay = getDetailsFromSignedIncreaseDissolveDelay;
|
|
379
504
|
// START_DISSOLVING
|
|
380
505
|
// CANISTER : (name: NNS Governance, identifier: rrkah-fqaaa-aaaaa-aaaaq-cai)
|
|
381
506
|
// METHOD : (name: manage_neuron, type: update)
|
|
@@ -412,15 +537,36 @@ function prepareStartDissolving(publicKey) {
|
|
|
412
537
|
neuron_id_or_subaccount: [{ Subaccount: subAccount.toUint8Array() }]
|
|
413
538
|
}
|
|
414
539
|
]);
|
|
415
|
-
return
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
540
|
+
return [
|
|
541
|
+
{
|
|
542
|
+
actionType: transaction_1.ICPActionType.START_DISSOLVING,
|
|
543
|
+
encoded: (0, convert_1.arrayBufferToHexString)(unsignedTransactionBuffer)
|
|
544
|
+
}
|
|
545
|
+
];
|
|
419
546
|
});
|
|
420
547
|
}
|
|
421
548
|
exports.prepareStartDissolving = prepareStartDissolving;
|
|
422
|
-
function getDetailsFromUnsignedStartDissolving(publicKey, network) {
|
|
423
|
-
//
|
|
549
|
+
function getDetailsFromUnsignedStartDissolving(encoded, publicKey, network) {
|
|
550
|
+
// IDL for StartDissolving
|
|
551
|
+
const NeuronId = IDL.Record({ id: IDL.Nat64 });
|
|
552
|
+
const StartDissolving = IDL.Record({});
|
|
553
|
+
const Operation = IDL.Variant({
|
|
554
|
+
StartDissolving: StartDissolving
|
|
555
|
+
});
|
|
556
|
+
const Configure = IDL.Record({ operation: IDL.Opt(Operation) });
|
|
557
|
+
const Command = IDL.Variant({
|
|
558
|
+
Configure: Configure
|
|
559
|
+
});
|
|
560
|
+
const NeuronIdOrSubaccount = IDL.Variant({
|
|
561
|
+
Subaccount: IDL.Vec(IDL.Nat8),
|
|
562
|
+
NeuronId: NeuronId
|
|
563
|
+
});
|
|
564
|
+
const ManageNeuron = IDL.Record({
|
|
565
|
+
id: IDL.Opt(NeuronId),
|
|
566
|
+
command: IDL.Opt(Command),
|
|
567
|
+
neuron_id_or_subaccount: IDL.Opt(NeuronIdOrSubaccount)
|
|
568
|
+
});
|
|
569
|
+
const manageNeuron = IDL.decode([ManageNeuron], (0, convert_1.hexStringToArrayBuffer)(encoded))[0];
|
|
424
570
|
return [
|
|
425
571
|
{
|
|
426
572
|
from: [(0, ICPImplementation_1.getAddressFromPublicKey)(publicKey)],
|
|
@@ -429,7 +575,10 @@ function getDetailsFromUnsignedStartDissolving(publicKey, network) {
|
|
|
429
575
|
amount: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
430
576
|
fee: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
431
577
|
network,
|
|
432
|
-
type: transaction_1.ICPActionType.START_DISSOLVING
|
|
578
|
+
type: transaction_1.ICPActionType.START_DISSOLVING,
|
|
579
|
+
json: {
|
|
580
|
+
ManageNeuron: (0, json_1.idlDecodedToJsonStringifiable)(manageNeuron)
|
|
581
|
+
}
|
|
433
582
|
}
|
|
434
583
|
];
|
|
435
584
|
}
|
|
@@ -444,8 +593,28 @@ function signStartDissolving(unsignedTransaction, privateKey, canisterId) {
|
|
|
444
593
|
});
|
|
445
594
|
}
|
|
446
595
|
exports.signStartDissolving = signStartDissolving;
|
|
447
|
-
function getDetailsFromSignedStartDissolving(publicKey, network) {
|
|
448
|
-
//
|
|
596
|
+
function getDetailsFromSignedStartDissolving(encoded, publicKey, network) {
|
|
597
|
+
// IDL for StartDissolving
|
|
598
|
+
const NeuronId = IDL.Record({ id: IDL.Nat64 });
|
|
599
|
+
const StartDissolving = IDL.Record({});
|
|
600
|
+
const Operation = IDL.Variant({
|
|
601
|
+
StartDissolving: StartDissolving
|
|
602
|
+
});
|
|
603
|
+
const Configure = IDL.Record({ operation: IDL.Opt(Operation) });
|
|
604
|
+
const Command = IDL.Variant({
|
|
605
|
+
Configure: Configure
|
|
606
|
+
});
|
|
607
|
+
const NeuronIdOrSubaccount = IDL.Variant({
|
|
608
|
+
Subaccount: IDL.Vec(IDL.Nat8),
|
|
609
|
+
NeuronId: NeuronId
|
|
610
|
+
});
|
|
611
|
+
const ManageNeuron = IDL.Record({
|
|
612
|
+
id: IDL.Opt(NeuronId),
|
|
613
|
+
command: IDL.Opt(Command),
|
|
614
|
+
neuron_id_or_subaccount: IDL.Opt(NeuronIdOrSubaccount)
|
|
615
|
+
});
|
|
616
|
+
const cborDecoded = Cbor.decode((0, convert_1.hexStringToArrayBuffer)(encoded));
|
|
617
|
+
const manageNeuron = IDL.decode([ManageNeuron], cborDecoded.content.arg)[0];
|
|
449
618
|
return [
|
|
450
619
|
{
|
|
451
620
|
from: [(0, ICPImplementation_1.getAddressFromPublicKey)(publicKey)],
|
|
@@ -453,8 +622,9 @@ function getDetailsFromSignedStartDissolving(publicKey, network) {
|
|
|
453
622
|
isInbound: false,
|
|
454
623
|
amount: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
455
624
|
fee: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
456
|
-
network
|
|
457
|
-
type: transaction_1.ICPActionType.START_DISSOLVING
|
|
625
|
+
network,
|
|
626
|
+
type: transaction_1.ICPActionType.START_DISSOLVING,
|
|
627
|
+
json: Object.assign(Object.assign({}, cborDecoded.content), { arg: (0, json_1.idlDecodedToJsonStringifiable)(manageNeuron) })
|
|
458
628
|
}
|
|
459
629
|
];
|
|
460
630
|
}
|
|
@@ -464,11 +634,11 @@ exports.getDetailsFromSignedStartDissolving = getDetailsFromSignedStartDissolvin
|
|
|
464
634
|
// METHOD : (name: manage_neuron, type: update)
|
|
465
635
|
// PAYLOAD : (id : [{id : float}], command : [{Configure : {operation : [{StopDissolving : {}}]}}], neuron_id_or_subaccount : [])
|
|
466
636
|
// RESPONSE : (command : [{configure : {}}])
|
|
467
|
-
function
|
|
637
|
+
function prepareStopDissolving(publicKey) {
|
|
468
638
|
return __awaiter(this, void 0, void 0, function* () {
|
|
469
639
|
// Create subaccount from publicKey
|
|
470
640
|
const { subAccount, nonce: _ } = (0, ICPImplementation_1.getFixedSubaccountFromPublicKey)(publicKey);
|
|
471
|
-
// IDL for
|
|
641
|
+
// IDL for StopDissolving
|
|
472
642
|
const NeuronId = IDL.Record({ id: IDL.Nat64 });
|
|
473
643
|
const StopDissolving = IDL.Record({});
|
|
474
644
|
const Operation = IDL.Variant({
|
|
@@ -490,23 +660,41 @@ function createUnsignedTransactionStopDissolving(publicKey) {
|
|
|
490
660
|
// Encode
|
|
491
661
|
const unsignedTransactionBuffer = IDL.encode([ManageNeuron], [
|
|
492
662
|
{
|
|
663
|
+
id: [],
|
|
493
664
|
command: [{ Configure: { operation: [{ StopDissolving: {} }] } }],
|
|
494
665
|
neuron_id_or_subaccount: [{ Subaccount: subAccount.toUint8Array() }]
|
|
495
666
|
}
|
|
496
667
|
]);
|
|
497
|
-
return
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
]
|
|
504
|
-
});
|
|
668
|
+
return [
|
|
669
|
+
{
|
|
670
|
+
actionType: transaction_1.ICPActionType.STOP_DISSOLVING,
|
|
671
|
+
encoded: (0, convert_1.arrayBufferToHexString)(unsignedTransactionBuffer)
|
|
672
|
+
}
|
|
673
|
+
];
|
|
505
674
|
});
|
|
506
675
|
}
|
|
507
|
-
exports.
|
|
508
|
-
function
|
|
509
|
-
//
|
|
676
|
+
exports.prepareStopDissolving = prepareStopDissolving;
|
|
677
|
+
function getDetailsFromUnsignedStopDissolving(encoded, publicKey, network) {
|
|
678
|
+
// IDL for StopDissolving
|
|
679
|
+
const NeuronId = IDL.Record({ id: IDL.Nat64 });
|
|
680
|
+
const StopDissolving = IDL.Record({});
|
|
681
|
+
const Operation = IDL.Variant({
|
|
682
|
+
StopDissolving: StopDissolving
|
|
683
|
+
});
|
|
684
|
+
const Configure = IDL.Record({ operation: IDL.Opt(Operation) });
|
|
685
|
+
const Command = IDL.Variant({
|
|
686
|
+
Configure: Configure
|
|
687
|
+
});
|
|
688
|
+
const NeuronIdOrSubaccount = IDL.Variant({
|
|
689
|
+
Subaccount: IDL.Vec(IDL.Nat8),
|
|
690
|
+
NeuronId: NeuronId
|
|
691
|
+
});
|
|
692
|
+
const ManageNeuron = IDL.Record({
|
|
693
|
+
id: IDL.Opt(NeuronId),
|
|
694
|
+
command: IDL.Opt(Command),
|
|
695
|
+
neuron_id_or_subaccount: IDL.Opt(NeuronIdOrSubaccount)
|
|
696
|
+
});
|
|
697
|
+
const manageNeuron = IDL.decode([ManageNeuron], (0, convert_1.hexStringToArrayBuffer)(encoded))[0];
|
|
510
698
|
return [
|
|
511
699
|
{
|
|
512
700
|
from: [(0, ICPImplementation_1.getAddressFromPublicKey)(publicKey)],
|
|
@@ -514,12 +702,16 @@ function getDetailsFromUnsignedTransactionStopDissolving(publicKey, network) {
|
|
|
514
702
|
isInbound: false,
|
|
515
703
|
amount: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
516
704
|
fee: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
517
|
-
network
|
|
705
|
+
network,
|
|
706
|
+
type: transaction_1.ICPActionType.STOP_DISSOLVING,
|
|
707
|
+
json: {
|
|
708
|
+
ManageNeuron: (0, json_1.idlDecodedToJsonStringifiable)(manageNeuron)
|
|
709
|
+
}
|
|
518
710
|
}
|
|
519
711
|
];
|
|
520
712
|
}
|
|
521
|
-
exports.
|
|
522
|
-
function
|
|
713
|
+
exports.getDetailsFromUnsignedStopDissolving = getDetailsFromUnsignedStopDissolving;
|
|
714
|
+
function signStopDissolving(unsignedTransaction, privateKey, canisterId) {
|
|
523
715
|
return __awaiter(this, void 0, void 0, function* () {
|
|
524
716
|
// unsignedTransaction has already the arguments needed for signing, just need to be in a Buffer
|
|
525
717
|
const args = (0, convert_1.hexStringToArrayBuffer)(unsignedTransaction);
|
|
@@ -528,9 +720,29 @@ function signTransactionStopDissolving(unsignedTransaction, privateKey, canister
|
|
|
528
720
|
return signedTransaction;
|
|
529
721
|
});
|
|
530
722
|
}
|
|
531
|
-
exports.
|
|
532
|
-
function
|
|
533
|
-
//
|
|
723
|
+
exports.signStopDissolving = signStopDissolving;
|
|
724
|
+
function getDetailsFromSignedStopDissolving(encoded, publicKey, network) {
|
|
725
|
+
// IDL for StopDissolving
|
|
726
|
+
const NeuronId = IDL.Record({ id: IDL.Nat64 });
|
|
727
|
+
const StopDissolving = IDL.Record({});
|
|
728
|
+
const Operation = IDL.Variant({
|
|
729
|
+
StopDissolving: StopDissolving
|
|
730
|
+
});
|
|
731
|
+
const Configure = IDL.Record({ operation: IDL.Opt(Operation) });
|
|
732
|
+
const Command = IDL.Variant({
|
|
733
|
+
Configure: Configure
|
|
734
|
+
});
|
|
735
|
+
const NeuronIdOrSubaccount = IDL.Variant({
|
|
736
|
+
Subaccount: IDL.Vec(IDL.Nat8),
|
|
737
|
+
NeuronId: NeuronId
|
|
738
|
+
});
|
|
739
|
+
const ManageNeuron = IDL.Record({
|
|
740
|
+
id: IDL.Opt(NeuronId),
|
|
741
|
+
command: IDL.Opt(Command),
|
|
742
|
+
neuron_id_or_subaccount: IDL.Opt(NeuronIdOrSubaccount)
|
|
743
|
+
});
|
|
744
|
+
const cborDecoded = Cbor.decode((0, convert_1.hexStringToArrayBuffer)(encoded));
|
|
745
|
+
const manageNeuron = IDL.decode([ManageNeuron], cborDecoded.content.arg)[0];
|
|
534
746
|
return [
|
|
535
747
|
{
|
|
536
748
|
from: [(0, ICPImplementation_1.getAddressFromPublicKey)(publicKey)],
|
|
@@ -538,28 +750,29 @@ function getDetailsFromSignedTransactionStopDissolving(publicKey, network) {
|
|
|
538
750
|
isInbound: false,
|
|
539
751
|
amount: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
540
752
|
fee: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
541
|
-
network
|
|
753
|
+
network,
|
|
754
|
+
type: transaction_1.ICPActionType.STOP_DISSOLVING,
|
|
755
|
+
json: Object.assign(Object.assign({}, cborDecoded.content), { arg: (0, json_1.idlDecodedToJsonStringifiable)(manageNeuron) })
|
|
542
756
|
}
|
|
543
757
|
];
|
|
544
758
|
}
|
|
545
|
-
exports.
|
|
546
|
-
//
|
|
547
|
-
|
|
548
|
-
// METHOD : (name: manage_neuron, type: update)
|
|
549
|
-
// PAYLOAD : (id : [{id : float}], command : [{Follow : {topic : int, followees : [{id: int}]}}], neuron_id_or_subaccount : [])
|
|
550
|
-
// RESPONSE : (command : [{Follow : {}}])
|
|
551
|
-
function prepareFollowNeuron(publicKey, neuronId) {
|
|
759
|
+
exports.getDetailsFromSignedStopDissolving = getDetailsFromSignedStopDissolving;
|
|
760
|
+
// AUTO_STAKE_MATURITY
|
|
761
|
+
function prepareAutoStakeMaturity(publicKey) {
|
|
552
762
|
return __awaiter(this, void 0, void 0, function* () {
|
|
553
763
|
// Create subaccount from publicKey
|
|
554
764
|
const { subAccount, nonce: _ } = (0, ICPImplementation_1.getFixedSubaccountFromPublicKey)(publicKey);
|
|
555
|
-
// IDL for
|
|
765
|
+
// IDL for ChangeAutoStakeMaturity
|
|
556
766
|
const NeuronId = IDL.Record({ id: IDL.Nat64 });
|
|
557
|
-
const
|
|
558
|
-
|
|
559
|
-
|
|
767
|
+
const ChangeAutoStakeMaturity = IDL.Record({
|
|
768
|
+
requested_setting_for_auto_stake_maturity: IDL.Bool
|
|
769
|
+
});
|
|
770
|
+
const Operation = IDL.Variant({
|
|
771
|
+
ChangeAutoStakeMaturity: ChangeAutoStakeMaturity
|
|
560
772
|
});
|
|
773
|
+
const Configure = IDL.Record({ operation: IDL.Opt(Operation) });
|
|
561
774
|
const Command = IDL.Variant({
|
|
562
|
-
|
|
775
|
+
Configure: Configure
|
|
563
776
|
});
|
|
564
777
|
const NeuronIdOrSubaccount = IDL.Variant({
|
|
565
778
|
Subaccount: IDL.Vec(IDL.Nat8),
|
|
@@ -570,24 +783,58 @@ function prepareFollowNeuron(publicKey, neuronId) {
|
|
|
570
783
|
command: IDL.Opt(Command),
|
|
571
784
|
neuron_id_or_subaccount: IDL.Opt(NeuronIdOrSubaccount)
|
|
572
785
|
});
|
|
573
|
-
// TODO : get the topic that corresponds to all topics
|
|
574
|
-
const topic = 0;
|
|
575
786
|
// Encode
|
|
576
787
|
const unsignedTransactionBuffer = IDL.encode([ManageNeuron], [
|
|
577
788
|
{
|
|
578
|
-
|
|
789
|
+
id: [],
|
|
790
|
+
command: [
|
|
791
|
+
{
|
|
792
|
+
Configure: {
|
|
793
|
+
operation: [
|
|
794
|
+
{
|
|
795
|
+
ChangeAutoStakeMaturity: {
|
|
796
|
+
requested_setting_for_auto_stake_maturity: true
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
]
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
],
|
|
579
803
|
neuron_id_or_subaccount: [{ Subaccount: subAccount.toUint8Array() }]
|
|
580
804
|
}
|
|
581
805
|
]);
|
|
582
|
-
return
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
806
|
+
return [
|
|
807
|
+
{
|
|
808
|
+
actionType: transaction_1.ICPActionType.AUTO_STAKE_MATURITY,
|
|
809
|
+
encoded: (0, convert_1.arrayBufferToHexString)(unsignedTransactionBuffer)
|
|
810
|
+
}
|
|
811
|
+
];
|
|
586
812
|
});
|
|
587
813
|
}
|
|
588
|
-
exports.
|
|
589
|
-
function
|
|
590
|
-
//
|
|
814
|
+
exports.prepareAutoStakeMaturity = prepareAutoStakeMaturity;
|
|
815
|
+
function getDetailsFromUnsignedAutoStakeMaturity(encoded, publicKey, network) {
|
|
816
|
+
// IDL for ChangeAutoStakeMaturity
|
|
817
|
+
const NeuronId = IDL.Record({ id: IDL.Nat64 });
|
|
818
|
+
const ChangeAutoStakeMaturity = IDL.Record({
|
|
819
|
+
requested_setting_for_auto_stake_maturity: IDL.Bool
|
|
820
|
+
});
|
|
821
|
+
const Operation = IDL.Variant({
|
|
822
|
+
ChangeAutoStakeMaturity: ChangeAutoStakeMaturity
|
|
823
|
+
});
|
|
824
|
+
const Configure = IDL.Record({ operation: IDL.Opt(Operation) });
|
|
825
|
+
const Command = IDL.Variant({
|
|
826
|
+
Configure: Configure
|
|
827
|
+
});
|
|
828
|
+
const NeuronIdOrSubaccount = IDL.Variant({
|
|
829
|
+
Subaccount: IDL.Vec(IDL.Nat8),
|
|
830
|
+
NeuronId: NeuronId
|
|
831
|
+
});
|
|
832
|
+
const ManageNeuron = IDL.Record({
|
|
833
|
+
id: IDL.Opt(NeuronId),
|
|
834
|
+
command: IDL.Opt(Command),
|
|
835
|
+
neuron_id_or_subaccount: IDL.Opt(NeuronIdOrSubaccount)
|
|
836
|
+
});
|
|
837
|
+
const manageNeuron = IDL.decode([ManageNeuron], (0, convert_1.hexStringToArrayBuffer)(encoded))[0];
|
|
591
838
|
return [
|
|
592
839
|
{
|
|
593
840
|
from: [(0, ICPImplementation_1.getAddressFromPublicKey)(publicKey)],
|
|
@@ -595,12 +842,16 @@ function getDetailsFromUnsignedFollowNeuron(publicKey, network) {
|
|
|
595
842
|
isInbound: false,
|
|
596
843
|
amount: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
597
844
|
fee: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
598
|
-
network
|
|
845
|
+
network,
|
|
846
|
+
type: transaction_1.ICPActionType.AUTO_STAKE_MATURITY,
|
|
847
|
+
json: {
|
|
848
|
+
ManageNeuron: (0, json_1.idlDecodedToJsonStringifiable)(manageNeuron)
|
|
849
|
+
}
|
|
599
850
|
}
|
|
600
851
|
];
|
|
601
852
|
}
|
|
602
|
-
exports.
|
|
603
|
-
function
|
|
853
|
+
exports.getDetailsFromUnsignedAutoStakeMaturity = getDetailsFromUnsignedAutoStakeMaturity;
|
|
854
|
+
function signAutoStakeMaturity(unsignedTransaction, privateKey, canisterId) {
|
|
604
855
|
return __awaiter(this, void 0, void 0, function* () {
|
|
605
856
|
// unsignedTransaction has already the arguments needed for signing, just need to be in a Buffer
|
|
606
857
|
const args = (0, convert_1.hexStringToArrayBuffer)(unsignedTransaction);
|
|
@@ -609,9 +860,31 @@ function signFollowNeuron(unsignedTransaction, privateKey, canisterId) {
|
|
|
609
860
|
return signedTransaction;
|
|
610
861
|
});
|
|
611
862
|
}
|
|
612
|
-
exports.
|
|
613
|
-
function
|
|
614
|
-
//
|
|
863
|
+
exports.signAutoStakeMaturity = signAutoStakeMaturity;
|
|
864
|
+
function getDetailsFromSignedAutoStakeMaturity(encoded, publicKey, network) {
|
|
865
|
+
// IDL for ChangeAutoStakeMaturity
|
|
866
|
+
const NeuronId = IDL.Record({ id: IDL.Nat64 });
|
|
867
|
+
const ChangeAutoStakeMaturity = IDL.Record({
|
|
868
|
+
requested_setting_for_auto_stake_maturity: IDL.Bool
|
|
869
|
+
});
|
|
870
|
+
const Operation = IDL.Variant({
|
|
871
|
+
ChangeAutoStakeMaturity: ChangeAutoStakeMaturity
|
|
872
|
+
});
|
|
873
|
+
const Configure = IDL.Record({ operation: IDL.Opt(Operation) });
|
|
874
|
+
const Command = IDL.Variant({
|
|
875
|
+
Configure: Configure
|
|
876
|
+
});
|
|
877
|
+
const NeuronIdOrSubaccount = IDL.Variant({
|
|
878
|
+
Subaccount: IDL.Vec(IDL.Nat8),
|
|
879
|
+
NeuronId: NeuronId
|
|
880
|
+
});
|
|
881
|
+
const ManageNeuron = IDL.Record({
|
|
882
|
+
id: IDL.Opt(NeuronId),
|
|
883
|
+
command: IDL.Opt(Command),
|
|
884
|
+
neuron_id_or_subaccount: IDL.Opt(NeuronIdOrSubaccount)
|
|
885
|
+
});
|
|
886
|
+
const cborDecoded = Cbor.decode((0, convert_1.hexStringToArrayBuffer)(encoded));
|
|
887
|
+
const manageNeuron = IDL.decode([ManageNeuron], cborDecoded.content.arg)[0];
|
|
615
888
|
return [
|
|
616
889
|
{
|
|
617
890
|
from: [(0, ICPImplementation_1.getAddressFromPublicKey)(publicKey)],
|
|
@@ -619,27 +892,35 @@ function getDetailsFromSignedFollowNeuron(publicKey, network) {
|
|
|
619
892
|
isInbound: false,
|
|
620
893
|
amount: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
621
894
|
fee: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
622
|
-
network
|
|
895
|
+
network,
|
|
896
|
+
type: transaction_1.ICPActionType.AUTO_STAKE_MATURITY,
|
|
897
|
+
json: Object.assign(Object.assign({}, cborDecoded.content), { arg: (0, json_1.idlDecodedToJsonStringifiable)(manageNeuron) })
|
|
623
898
|
}
|
|
624
899
|
];
|
|
625
900
|
}
|
|
626
|
-
exports.
|
|
627
|
-
//
|
|
901
|
+
exports.getDetailsFromSignedAutoStakeMaturity = getDetailsFromSignedAutoStakeMaturity;
|
|
902
|
+
// FOLLOW_NEURON
|
|
628
903
|
// CANISTER : (name: NNS Governance, identifier: rrkah-fqaaa-aaaaa-aaaaq-cai)
|
|
629
904
|
// METHOD : (name: manage_neuron, type: update)
|
|
630
|
-
// PAYLOAD : (id : [{id : float}], command : [{
|
|
631
|
-
// RESPONSE : (command : [{
|
|
632
|
-
|
|
905
|
+
// PAYLOAD : (id : [{id : float}], command : [{Follow : {topic : int, followees : [{id: int}]}}], neuron_id_or_subaccount : [])
|
|
906
|
+
// RESPONSE : (command : [{Follow : {}}])
|
|
907
|
+
const TOPICS = [
|
|
908
|
+
{ id: 0, name: 'All Except Governance, and SNS & Community Fund' },
|
|
909
|
+
{ id: 4, name: 'Governance' },
|
|
910
|
+
{ id: 14, name: 'SNS & Community Fund' }
|
|
911
|
+
];
|
|
912
|
+
function prepareFollowNeuron(publicKey, neuronId) {
|
|
633
913
|
return __awaiter(this, void 0, void 0, function* () {
|
|
634
914
|
// Create subaccount from publicKey
|
|
635
915
|
const { subAccount, nonce: _ } = (0, ICPImplementation_1.getFixedSubaccountFromPublicKey)(publicKey);
|
|
636
|
-
// IDL for
|
|
916
|
+
// IDL for FollowNeuron
|
|
637
917
|
const NeuronId = IDL.Record({ id: IDL.Nat64 });
|
|
638
|
-
const
|
|
639
|
-
|
|
918
|
+
const Follow = IDL.Record({
|
|
919
|
+
topic: IDL.Int32,
|
|
920
|
+
followees: IDL.Vec(NeuronId)
|
|
640
921
|
});
|
|
641
922
|
const Command = IDL.Variant({
|
|
642
|
-
|
|
923
|
+
Follow: Follow
|
|
643
924
|
});
|
|
644
925
|
const NeuronIdOrSubaccount = IDL.Variant({
|
|
645
926
|
Subaccount: IDL.Vec(IDL.Nat8),
|
|
@@ -650,26 +931,45 @@ function createUnsignedTransactionRestakeMaturity(publicKey, percentageStake) {
|
|
|
650
931
|
command: IDL.Opt(Command),
|
|
651
932
|
neuron_id_or_subaccount: IDL.Opt(NeuronIdOrSubaccount)
|
|
652
933
|
});
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
command: [{ StakeMaturity: { percentage_to_stake: percentageStake } }],
|
|
657
|
-
neuron_id_or_subaccount: [{ Subaccount: subAccount.toUint8Array() }]
|
|
658
|
-
}
|
|
659
|
-
]);
|
|
660
|
-
return (0, module_kit_1.newUnsignedTransaction)({
|
|
661
|
-
transactions: [
|
|
934
|
+
return TOPICS.map(({ id }) => {
|
|
935
|
+
// Encode
|
|
936
|
+
const unsignedTransactionBuffer = IDL.encode([ManageNeuron], [
|
|
662
937
|
{
|
|
663
|
-
|
|
664
|
-
|
|
938
|
+
id: [],
|
|
939
|
+
command: [{ Follow: { topic: id, followees: neuronId !== undefined ? [{ id: neuronId }] : [] } }],
|
|
940
|
+
neuron_id_or_subaccount: [{ Subaccount: subAccount.toUint8Array() }]
|
|
665
941
|
}
|
|
666
|
-
]
|
|
942
|
+
]);
|
|
943
|
+
return {
|
|
944
|
+
actionType: transaction_1.ICPActionType.FOLLOW_NEURON,
|
|
945
|
+
encoded: (0, convert_1.arrayBufferToHexString)(unsignedTransactionBuffer)
|
|
946
|
+
};
|
|
667
947
|
});
|
|
668
948
|
});
|
|
669
949
|
}
|
|
670
|
-
exports.
|
|
671
|
-
function
|
|
672
|
-
//
|
|
950
|
+
exports.prepareFollowNeuron = prepareFollowNeuron;
|
|
951
|
+
function getDetailsFromUnsignedFollowNeuron(encoded, publicKey, network) {
|
|
952
|
+
// IDL for FollowNeuron
|
|
953
|
+
const NeuronId = IDL.Record({ id: IDL.Nat64 });
|
|
954
|
+
const Follow = IDL.Record({
|
|
955
|
+
topic: IDL.Int32,
|
|
956
|
+
followees: IDL.Vec(NeuronId)
|
|
957
|
+
});
|
|
958
|
+
const Command = IDL.Variant({
|
|
959
|
+
Follow: Follow
|
|
960
|
+
});
|
|
961
|
+
const NeuronIdOrSubaccount = IDL.Variant({
|
|
962
|
+
Subaccount: IDL.Vec(IDL.Nat8),
|
|
963
|
+
NeuronId: NeuronId
|
|
964
|
+
});
|
|
965
|
+
const ManageNeuron = IDL.Record({
|
|
966
|
+
id: IDL.Opt(NeuronId),
|
|
967
|
+
command: IDL.Opt(Command),
|
|
968
|
+
neuron_id_or_subaccount: IDL.Opt(NeuronIdOrSubaccount)
|
|
969
|
+
});
|
|
970
|
+
const manageNeuron = IDL.decode([ManageNeuron], (0, convert_1.hexStringToArrayBuffer)(encoded))[0];
|
|
971
|
+
const topicId = manageNeuron.command[0].Follow.topic;
|
|
972
|
+
const topic = TOPICS.find(({ id }) => id.toString() === topicId.toString());
|
|
673
973
|
return [
|
|
674
974
|
{
|
|
675
975
|
from: [(0, ICPImplementation_1.getAddressFromPublicKey)(publicKey)],
|
|
@@ -677,12 +977,19 @@ function getDetailsFromUnsignedTransactionRestakeMaturity(publicKey, network) {
|
|
|
677
977
|
isInbound: false,
|
|
678
978
|
amount: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
679
979
|
fee: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
680
|
-
network
|
|
980
|
+
network,
|
|
981
|
+
type: transaction_1.ICPActionType.FOLLOW_NEURON,
|
|
982
|
+
json: {
|
|
983
|
+
ManageNeuron: (0, json_1.idlDecodedToJsonStringifiable)(manageNeuron)
|
|
984
|
+
},
|
|
985
|
+
extra: {
|
|
986
|
+
labeled: topic ? { topic: topic.name } : undefined
|
|
987
|
+
}
|
|
681
988
|
}
|
|
682
989
|
];
|
|
683
990
|
}
|
|
684
|
-
exports.
|
|
685
|
-
function
|
|
991
|
+
exports.getDetailsFromUnsignedFollowNeuron = getDetailsFromUnsignedFollowNeuron;
|
|
992
|
+
function signFollowNeuron(unsignedTransaction, privateKey, canisterId) {
|
|
686
993
|
return __awaiter(this, void 0, void 0, function* () {
|
|
687
994
|
// unsignedTransaction has already the arguments needed for signing, just need to be in a Buffer
|
|
688
995
|
const args = (0, convert_1.hexStringToArrayBuffer)(unsignedTransaction);
|
|
@@ -691,9 +998,30 @@ function signTransactionRestakeMaturity(unsignedTransaction, privateKey, caniste
|
|
|
691
998
|
return signedTransaction;
|
|
692
999
|
});
|
|
693
1000
|
}
|
|
694
|
-
exports.
|
|
695
|
-
function
|
|
696
|
-
//
|
|
1001
|
+
exports.signFollowNeuron = signFollowNeuron;
|
|
1002
|
+
function getDetailsFromSignedFollowNeuron(encoded, publicKey, network) {
|
|
1003
|
+
// IDL for FollowNeuron
|
|
1004
|
+
const NeuronId = IDL.Record({ id: IDL.Nat64 });
|
|
1005
|
+
const Follow = IDL.Record({
|
|
1006
|
+
topic: IDL.Int32,
|
|
1007
|
+
followees: IDL.Vec(NeuronId)
|
|
1008
|
+
});
|
|
1009
|
+
const Command = IDL.Variant({
|
|
1010
|
+
Follow: Follow
|
|
1011
|
+
});
|
|
1012
|
+
const NeuronIdOrSubaccount = IDL.Variant({
|
|
1013
|
+
Subaccount: IDL.Vec(IDL.Nat8),
|
|
1014
|
+
NeuronId: NeuronId
|
|
1015
|
+
});
|
|
1016
|
+
const ManageNeuron = IDL.Record({
|
|
1017
|
+
id: IDL.Opt(NeuronId),
|
|
1018
|
+
command: IDL.Opt(Command),
|
|
1019
|
+
neuron_id_or_subaccount: IDL.Opt(NeuronIdOrSubaccount)
|
|
1020
|
+
});
|
|
1021
|
+
const cborDecoded = Cbor.decode((0, convert_1.hexStringToArrayBuffer)(encoded));
|
|
1022
|
+
const manageNeuron = IDL.decode([ManageNeuron], cborDecoded.content.arg)[0];
|
|
1023
|
+
const topicId = manageNeuron.command[0].Follow.topic;
|
|
1024
|
+
const topic = TOPICS.find(({ id }) => id.toString() === topicId.toString());
|
|
697
1025
|
return [
|
|
698
1026
|
{
|
|
699
1027
|
from: [(0, ICPImplementation_1.getAddressFromPublicKey)(publicKey)],
|
|
@@ -701,11 +1029,16 @@ function getDetailsFromSignedTransactionRestakeMaturity(publicKey, network) {
|
|
|
701
1029
|
isInbound: false,
|
|
702
1030
|
amount: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
703
1031
|
fee: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
704
|
-
network
|
|
1032
|
+
network,
|
|
1033
|
+
type: transaction_1.ICPActionType.FOLLOW_NEURON,
|
|
1034
|
+
json: Object.assign(Object.assign({}, cborDecoded.content), { arg: (0, json_1.idlDecodedToJsonStringifiable)(manageNeuron) }),
|
|
1035
|
+
extra: {
|
|
1036
|
+
labeled: topic ? { topic: topic.name } : undefined
|
|
1037
|
+
}
|
|
705
1038
|
}
|
|
706
1039
|
];
|
|
707
1040
|
}
|
|
708
|
-
exports.
|
|
1041
|
+
exports.getDetailsFromSignedFollowNeuron = getDetailsFromSignedFollowNeuron;
|
|
709
1042
|
// DISBURSE
|
|
710
1043
|
// Cannot extrapolate method from call since we have to wait 6 months to do so
|
|
711
1044
|
function prepareDisburse(publicKey) {
|
|
@@ -747,15 +1080,37 @@ function prepareDisburse(publicKey) {
|
|
|
747
1080
|
neuron_id_or_subaccount: [{ Subaccount: subAccount.toUint8Array() }]
|
|
748
1081
|
}
|
|
749
1082
|
]);
|
|
750
|
-
return
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
1083
|
+
return [
|
|
1084
|
+
{
|
|
1085
|
+
actionType: transaction_1.ICPActionType.DISBURSE,
|
|
1086
|
+
encoded: (0, convert_1.arrayBufferToHexString)(unsignedTransactionBuffer)
|
|
1087
|
+
}
|
|
1088
|
+
];
|
|
754
1089
|
});
|
|
755
1090
|
}
|
|
756
1091
|
exports.prepareDisburse = prepareDisburse;
|
|
757
|
-
function getDetailsFromUnsignedDisburse(publicKey, network) {
|
|
758
|
-
//
|
|
1092
|
+
function getDetailsFromUnsignedDisburse(encoded, publicKey, network) {
|
|
1093
|
+
// IDL for Disburse
|
|
1094
|
+
const NeuronId = IDL.Record({ id: IDL.Nat64 });
|
|
1095
|
+
const AccountIdentifier = IDL.Record({ hash: IDL.Vec(IDL.Nat8) });
|
|
1096
|
+
const Amount = IDL.Record({ e8s: IDL.Nat64 });
|
|
1097
|
+
const Disburse = IDL.Record({
|
|
1098
|
+
to_account: IDL.Opt(AccountIdentifier),
|
|
1099
|
+
amount: IDL.Opt(Amount)
|
|
1100
|
+
});
|
|
1101
|
+
const Command = IDL.Variant({
|
|
1102
|
+
Disburse: Disburse
|
|
1103
|
+
});
|
|
1104
|
+
const NeuronIdOrSubaccount = IDL.Variant({
|
|
1105
|
+
Subaccount: IDL.Vec(IDL.Nat8),
|
|
1106
|
+
NeuronId: NeuronId
|
|
1107
|
+
});
|
|
1108
|
+
const ManageNeuron = IDL.Record({
|
|
1109
|
+
id: IDL.Opt(NeuronId),
|
|
1110
|
+
command: IDL.Opt(Command),
|
|
1111
|
+
neuron_id_or_subaccount: IDL.Opt(NeuronIdOrSubaccount)
|
|
1112
|
+
});
|
|
1113
|
+
const manageNeuron = IDL.decode([ManageNeuron], (0, convert_1.hexStringToArrayBuffer)(encoded))[0];
|
|
759
1114
|
return [
|
|
760
1115
|
{
|
|
761
1116
|
from: [network.governanceCanisterId],
|
|
@@ -763,8 +1118,11 @@ function getDetailsFromUnsignedDisburse(publicKey, network) {
|
|
|
763
1118
|
isInbound: false,
|
|
764
1119
|
amount: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
765
1120
|
fee: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
766
|
-
network
|
|
767
|
-
type: transaction_1.ICPActionType.DISBURSE
|
|
1121
|
+
network,
|
|
1122
|
+
type: transaction_1.ICPActionType.DISBURSE,
|
|
1123
|
+
json: {
|
|
1124
|
+
ManageNeuron: (0, json_1.idlDecodedToJsonStringifiable)(manageNeuron)
|
|
1125
|
+
}
|
|
768
1126
|
}
|
|
769
1127
|
];
|
|
770
1128
|
}
|
|
@@ -779,8 +1137,29 @@ function signDisburse(unsignedTransaction, privateKey, canisterId) {
|
|
|
779
1137
|
});
|
|
780
1138
|
}
|
|
781
1139
|
exports.signDisburse = signDisburse;
|
|
782
|
-
function getDetailsFromSignedDisburse(publicKey, network) {
|
|
783
|
-
//
|
|
1140
|
+
function getDetailsFromSignedDisburse(encoded, publicKey, network) {
|
|
1141
|
+
// IDL for Disburse
|
|
1142
|
+
const NeuronId = IDL.Record({ id: IDL.Nat64 });
|
|
1143
|
+
const AccountIdentifier = IDL.Record({ hash: IDL.Vec(IDL.Nat8) });
|
|
1144
|
+
const Amount = IDL.Record({ e8s: IDL.Nat64 });
|
|
1145
|
+
const Disburse = IDL.Record({
|
|
1146
|
+
to_account: IDL.Opt(AccountIdentifier),
|
|
1147
|
+
amount: IDL.Opt(Amount)
|
|
1148
|
+
});
|
|
1149
|
+
const Command = IDL.Variant({
|
|
1150
|
+
Disburse: Disburse
|
|
1151
|
+
});
|
|
1152
|
+
const NeuronIdOrSubaccount = IDL.Variant({
|
|
1153
|
+
Subaccount: IDL.Vec(IDL.Nat8),
|
|
1154
|
+
NeuronId: NeuronId
|
|
1155
|
+
});
|
|
1156
|
+
const ManageNeuron = IDL.Record({
|
|
1157
|
+
id: IDL.Opt(NeuronId),
|
|
1158
|
+
command: IDL.Opt(Command),
|
|
1159
|
+
neuron_id_or_subaccount: IDL.Opt(NeuronIdOrSubaccount)
|
|
1160
|
+
});
|
|
1161
|
+
const cborDecoded = Cbor.decode((0, convert_1.hexStringToArrayBuffer)(encoded));
|
|
1162
|
+
const manageNeuron = IDL.decode([ManageNeuron], cborDecoded.content.arg)[0];
|
|
784
1163
|
return [
|
|
785
1164
|
{
|
|
786
1165
|
from: [network.governanceCanisterId],
|
|
@@ -789,7 +1168,8 @@ function getDetailsFromSignedDisburse(publicKey, network) {
|
|
|
789
1168
|
amount: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
790
1169
|
fee: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
791
1170
|
network,
|
|
792
|
-
type: transaction_1.ICPActionType.DISBURSE
|
|
1171
|
+
type: transaction_1.ICPActionType.DISBURSE,
|
|
1172
|
+
json: Object.assign(Object.assign({}, cborDecoded.content), { arg: (0, json_1.idlDecodedToJsonStringifiable)(manageNeuron) })
|
|
793
1173
|
}
|
|
794
1174
|
];
|
|
795
1175
|
}
|