@airgap/icp 0.13.15-beta.7 → 0.13.15-beta.9

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.
@@ -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.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;
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
@@ -115,7 +117,7 @@ function getDetailsFromUnsignedGetNeuronInfo(publicKey, network) {
115
117
  ];
116
118
  }
117
119
  exports.getDetailsFromUnsignedGetNeuronInfo = getDetailsFromUnsignedGetNeuronInfo;
118
- function signGetNeuronInfo(unsignedTransaction, privateKey, canisterId) {
120
+ function signGetNeuronInfo(_unsignedTransaction, privateKey, canisterId) {
119
121
  return __awaiter(this, void 0, void 0, function* () {
120
122
  const NeuronIdOrSubaccount = IDL.Variant({
121
123
  Subaccount: IDL.Vec(IDL.Nat8)
@@ -127,8 +129,12 @@ function signGetNeuronInfo(unsignedTransaction, privateKey, canisterId) {
127
129
  });
128
130
  }
129
131
  exports.signGetNeuronInfo = signGetNeuronInfo;
130
- function getDetailsFromSignedGetNeuronInfo(publicKey, network) {
131
- // Does not need info from transaction because it is only a call to the governance canister
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];
132
138
  return [
133
139
  {
134
140
  from: [(0, ICPImplementation_1.getAddressFromPublicKey)(publicKey)],
@@ -137,7 +143,8 @@ function getDetailsFromSignedGetNeuronInfo(publicKey, network) {
137
143
  amount: (0, module_kit_1.newAmount)('0', 'blockchain'),
138
144
  fee: (0, module_kit_1.newAmount)('0', 'blockchain'),
139
145
  network,
140
- 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) })
141
148
  }
142
149
  ];
143
150
  }
@@ -180,7 +187,8 @@ function getDetailsFromUnsignedTransferToSubaccount(unsignedTransaction, publicK
180
187
  amount: (0, module_kit_1.newAmount)(info.amount.toString(), 'blockchain'),
181
188
  fee: (0, module_kit_1.newAmount)(info.fee.toString(), 'blockchain'),
182
189
  network,
183
- type: transaction_1.ICPActionType.TRANSFER_TO_SUBACCOUNT
190
+ type: transaction_1.ICPActionType.TRANSFER_TO_SUBACCOUNT,
191
+ json: (0, json_1.idlDecodedToJsonStringifiable)(info.json)
184
192
  }
185
193
  ];
186
194
  }
@@ -256,8 +264,32 @@ function prepareClaimOrRefreshNeuron(publicKey) {
256
264
  });
257
265
  }
258
266
  exports.prepareClaimOrRefreshNeuron = prepareClaimOrRefreshNeuron;
259
- function getDetailsFromUnsignedClaimGovernance(publicKey, network) {
260
- // Does not need info from transaction because it is only a call to the governance canister
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];
261
293
  return [
262
294
  {
263
295
  from: [(0, ICPImplementation_1.getAddressFromPublicKey)(publicKey)],
@@ -266,7 +298,10 @@ function getDetailsFromUnsignedClaimGovernance(publicKey, network) {
266
298
  amount: (0, module_kit_1.newAmount)('0', 'blockchain'),
267
299
  fee: (0, module_kit_1.newAmount)('0', 'blockchain'),
268
300
  network,
269
- type: transaction_1.ICPActionType.CLAIM_GOVERNANCE
301
+ type: transaction_1.ICPActionType.CLAIM_GOVERNANCE,
302
+ json: {
303
+ ManageNeuron: (0, json_1.idlDecodedToJsonStringifiable)(manageNeuron)
304
+ }
270
305
  }
271
306
  ];
272
307
  }
@@ -281,8 +316,33 @@ function signClaimGovernance(unsignedTransaction, privateKey, canisterId) {
281
316
  });
282
317
  }
283
318
  exports.signClaimGovernance = signClaimGovernance;
284
- function getDetailsFromTransactionClaimGovernance(publicKey, network) {
285
- // Does not need info from transaction because it is only a call to the governance canister
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];
286
346
  return [
287
347
  {
288
348
  from: [(0, ICPImplementation_1.getAddressFromPublicKey)(publicKey)],
@@ -291,11 +351,12 @@ function getDetailsFromTransactionClaimGovernance(publicKey, network) {
291
351
  amount: (0, module_kit_1.newAmount)('0', 'blockchain'),
292
352
  fee: (0, module_kit_1.newAmount)('0', 'blockchain'),
293
353
  network,
294
- 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) })
295
356
  }
296
357
  ];
297
358
  }
298
- exports.getDetailsFromTransactionClaimGovernance = getDetailsFromTransactionClaimGovernance;
359
+ exports.getDetailsFromSignedClaimGovernance = getDetailsFromSignedClaimGovernance;
299
360
  // INCREASE_DISSOLVE_DELAY
300
361
  // CANISTER : (name: NNS Governance, identifier: rrkah-fqaaa-aaaaa-aaaaq-cai)
301
362
  // METHOD : (name: manage_neuron, type: update)
@@ -353,8 +414,29 @@ function prepareIncreaseDissolveDelay(publicKey, additionalDissolveDelay) {
353
414
  });
354
415
  }
355
416
  exports.prepareIncreaseDissolveDelay = prepareIncreaseDissolveDelay;
356
- function getDetailsFromUnsignedIncreaseDissolveDelay(publicKey, network) {
357
- // Does not need info from transaction because it is only a call to the governance canister
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];
358
440
  return [
359
441
  {
360
442
  from: [(0, ICPImplementation_1.getAddressFromPublicKey)(publicKey)],
@@ -362,7 +444,11 @@ function getDetailsFromUnsignedIncreaseDissolveDelay(publicKey, network) {
362
444
  isInbound: false,
363
445
  amount: (0, module_kit_1.newAmount)('0', 'blockchain'),
364
446
  fee: (0, module_kit_1.newAmount)('0', 'blockchain'),
365
- network: network
447
+ network,
448
+ type: transaction_1.ICPActionType.INCREASE_DISSOLVE_DELAY,
449
+ json: {
450
+ ManageNeuron: (0, json_1.idlDecodedToJsonStringifiable)(manageNeuron)
451
+ }
366
452
  }
367
453
  ];
368
454
  }
@@ -377,8 +463,30 @@ function signIncreaseDissolveDelay(unsignedTransaction, privateKey, canisterId)
377
463
  });
378
464
  }
379
465
  exports.signIncreaseDissolveDelay = signIncreaseDissolveDelay;
380
- function getDetailsFromSignedIncreaseDissolveDelay(publicKey, network) {
381
- // Does not need info from transaction because it is only a call to the governance canister
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];
382
490
  return [
383
491
  {
384
492
  from: [(0, ICPImplementation_1.getAddressFromPublicKey)(publicKey)],
@@ -386,7 +494,9 @@ function getDetailsFromSignedIncreaseDissolveDelay(publicKey, network) {
386
494
  isInbound: false,
387
495
  amount: (0, module_kit_1.newAmount)('0', 'blockchain'),
388
496
  fee: (0, module_kit_1.newAmount)('0', 'blockchain'),
389
- 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) })
390
500
  }
391
501
  ];
392
502
  }
@@ -436,8 +546,27 @@ function prepareStartDissolving(publicKey) {
436
546
  });
437
547
  }
438
548
  exports.prepareStartDissolving = prepareStartDissolving;
439
- function getDetailsFromUnsignedStartDissolving(publicKey, network) {
440
- // Does not need info from transaction because it is only a call to the governance canister
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];
441
570
  return [
442
571
  {
443
572
  from: [(0, ICPImplementation_1.getAddressFromPublicKey)(publicKey)],
@@ -446,7 +575,10 @@ function getDetailsFromUnsignedStartDissolving(publicKey, network) {
446
575
  amount: (0, module_kit_1.newAmount)('0', 'blockchain'),
447
576
  fee: (0, module_kit_1.newAmount)('0', 'blockchain'),
448
577
  network,
449
- type: transaction_1.ICPActionType.START_DISSOLVING
578
+ type: transaction_1.ICPActionType.START_DISSOLVING,
579
+ json: {
580
+ ManageNeuron: (0, json_1.idlDecodedToJsonStringifiable)(manageNeuron)
581
+ }
450
582
  }
451
583
  ];
452
584
  }
@@ -461,8 +593,28 @@ function signStartDissolving(unsignedTransaction, privateKey, canisterId) {
461
593
  });
462
594
  }
463
595
  exports.signStartDissolving = signStartDissolving;
464
- function getDetailsFromSignedStartDissolving(publicKey, network) {
465
- // Does not need info from transaction because it is only a call to the governance canister
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];
466
618
  return [
467
619
  {
468
620
  from: [(0, ICPImplementation_1.getAddressFromPublicKey)(publicKey)],
@@ -470,8 +622,9 @@ function getDetailsFromSignedStartDissolving(publicKey, network) {
470
622
  isInbound: false,
471
623
  amount: (0, module_kit_1.newAmount)('0', 'blockchain'),
472
624
  fee: (0, module_kit_1.newAmount)('0', 'blockchain'),
473
- network: network,
474
- 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) })
475
628
  }
476
629
  ];
477
630
  }
@@ -485,7 +638,7 @@ function prepareStopDissolving(publicKey) {
485
638
  return __awaiter(this, void 0, void 0, function* () {
486
639
  // Create subaccount from publicKey
487
640
  const { subAccount, nonce: _ } = (0, ICPImplementation_1.getFixedSubaccountFromPublicKey)(publicKey);
488
- // IDL for StartDissolving
641
+ // IDL for StopDissolving
489
642
  const NeuronId = IDL.Record({ id: IDL.Nat64 });
490
643
  const StopDissolving = IDL.Record({});
491
644
  const Operation = IDL.Variant({
@@ -521,8 +674,27 @@ function prepareStopDissolving(publicKey) {
521
674
  });
522
675
  }
523
676
  exports.prepareStopDissolving = prepareStopDissolving;
524
- function getDetailsFromUnsignedStopDissolving(publicKey, network) {
525
- // Does not need info from transaction because it is only a call to the governance canister
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];
526
698
  return [
527
699
  {
528
700
  from: [(0, ICPImplementation_1.getAddressFromPublicKey)(publicKey)],
@@ -531,7 +703,10 @@ function getDetailsFromUnsignedStopDissolving(publicKey, network) {
531
703
  amount: (0, module_kit_1.newAmount)('0', 'blockchain'),
532
704
  fee: (0, module_kit_1.newAmount)('0', 'blockchain'),
533
705
  network,
534
- type: transaction_1.ICPActionType.STOP_DISSOLVING
706
+ type: transaction_1.ICPActionType.STOP_DISSOLVING,
707
+ json: {
708
+ ManageNeuron: (0, json_1.idlDecodedToJsonStringifiable)(manageNeuron)
709
+ }
535
710
  }
536
711
  ];
537
712
  }
@@ -546,8 +721,28 @@ function signStopDissolving(unsignedTransaction, privateKey, canisterId) {
546
721
  });
547
722
  }
548
723
  exports.signStopDissolving = signStopDissolving;
549
- function getDetailsFromSignedStopDissolving(publicKey, network) {
550
- // Does not need info from transaction because it is only a call to the governance canister
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];
551
746
  return [
552
747
  {
553
748
  from: [(0, ICPImplementation_1.getAddressFromPublicKey)(publicKey)],
@@ -556,7 +751,8 @@ function getDetailsFromSignedStopDissolving(publicKey, network) {
556
751
  amount: (0, module_kit_1.newAmount)('0', 'blockchain'),
557
752
  fee: (0, module_kit_1.newAmount)('0', 'blockchain'),
558
753
  network,
559
- type: transaction_1.ICPActionType.STOP_DISSOLVING
754
+ type: transaction_1.ICPActionType.STOP_DISSOLVING,
755
+ json: Object.assign(Object.assign({}, cborDecoded.content), { arg: (0, json_1.idlDecodedToJsonStringifiable)(manageNeuron) })
560
756
  }
561
757
  ];
562
758
  }
@@ -566,7 +762,7 @@ function prepareAutoStakeMaturity(publicKey) {
566
762
  return __awaiter(this, void 0, void 0, function* () {
567
763
  // Create subaccount from publicKey
568
764
  const { subAccount, nonce: _ } = (0, ICPImplementation_1.getFixedSubaccountFromPublicKey)(publicKey);
569
- // IDL for StartDissolving
765
+ // IDL for ChangeAutoStakeMaturity
570
766
  const NeuronId = IDL.Record({ id: IDL.Nat64 });
571
767
  const ChangeAutoStakeMaturity = IDL.Record({
572
768
  requested_setting_for_auto_stake_maturity: IDL.Bool
@@ -616,8 +812,29 @@ function prepareAutoStakeMaturity(publicKey) {
616
812
  });
617
813
  }
618
814
  exports.prepareAutoStakeMaturity = prepareAutoStakeMaturity;
619
- function getDetailsFromUnsignedAutoStakeMaturity(publicKey, network) {
620
- // Does not need info from transaction because it is only a call to the governance canister
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];
621
838
  return [
622
839
  {
623
840
  from: [(0, ICPImplementation_1.getAddressFromPublicKey)(publicKey)],
@@ -626,7 +843,10 @@ function getDetailsFromUnsignedAutoStakeMaturity(publicKey, network) {
626
843
  amount: (0, module_kit_1.newAmount)('0', 'blockchain'),
627
844
  fee: (0, module_kit_1.newAmount)('0', 'blockchain'),
628
845
  network,
629
- type: transaction_1.ICPActionType.AUTO_STAKE_MATURITY
846
+ type: transaction_1.ICPActionType.AUTO_STAKE_MATURITY,
847
+ json: {
848
+ ManageNeuron: (0, json_1.idlDecodedToJsonStringifiable)(manageNeuron)
849
+ }
630
850
  }
631
851
  ];
632
852
  }
@@ -641,8 +861,30 @@ function signAutoStakeMaturity(unsignedTransaction, privateKey, canisterId) {
641
861
  });
642
862
  }
643
863
  exports.signAutoStakeMaturity = signAutoStakeMaturity;
644
- function getDetailsFromSignedAutoStakeMaturity(publicKey, network) {
645
- // Does not need info from transaction because it is only a call to the governance canister
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];
646
888
  return [
647
889
  {
648
890
  from: [(0, ICPImplementation_1.getAddressFromPublicKey)(publicKey)],
@@ -651,7 +893,8 @@ function getDetailsFromSignedAutoStakeMaturity(publicKey, network) {
651
893
  amount: (0, module_kit_1.newAmount)('0', 'blockchain'),
652
894
  fee: (0, module_kit_1.newAmount)('0', 'blockchain'),
653
895
  network,
654
- type: transaction_1.ICPActionType.AUTO_STAKE_MATURITY
896
+ type: transaction_1.ICPActionType.AUTO_STAKE_MATURITY,
897
+ json: Object.assign(Object.assign({}, cborDecoded.content), { arg: (0, json_1.idlDecodedToJsonStringifiable)(manageNeuron) })
655
898
  }
656
899
  ];
657
900
  }
@@ -661,6 +904,11 @@ exports.getDetailsFromSignedAutoStakeMaturity = getDetailsFromSignedAutoStakeMat
661
904
  // METHOD : (name: manage_neuron, type: update)
662
905
  // PAYLOAD : (id : [{id : float}], command : [{Follow : {topic : int, followees : [{id: int}]}}], neuron_id_or_subaccount : [])
663
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
+ ];
664
912
  function prepareFollowNeuron(publicKey, neuronId) {
665
913
  return __awaiter(this, void 0, void 0, function* () {
666
914
  // Create subaccount from publicKey
@@ -683,13 +931,12 @@ function prepareFollowNeuron(publicKey, neuronId) {
683
931
  command: IDL.Opt(Command),
684
932
  neuron_id_or_subaccount: IDL.Opt(NeuronIdOrSubaccount)
685
933
  });
686
- const topics = [0 /* All Except Governance, and SNS & Community Fund */, 4 /* Governance */, 14 /* SNS & Community Fund */];
687
- return topics.map((topic) => {
934
+ return TOPICS.map(({ id }) => {
688
935
  // Encode
689
936
  const unsignedTransactionBuffer = IDL.encode([ManageNeuron], [
690
937
  {
691
938
  id: [],
692
- command: [{ Follow: { topic: topic, followees: neuronId !== undefined ? [{ id: neuronId }] : [] } }],
939
+ command: [{ Follow: { topic: id, followees: neuronId !== undefined ? [{ id: neuronId }] : [] } }],
693
940
  neuron_id_or_subaccount: [{ Subaccount: subAccount.toUint8Array() }]
694
941
  }
695
942
  ]);
@@ -701,8 +948,28 @@ function prepareFollowNeuron(publicKey, neuronId) {
701
948
  });
702
949
  }
703
950
  exports.prepareFollowNeuron = prepareFollowNeuron;
704
- function getDetailsFromUnsignedFollowNeuron(publicKey, network) {
705
- // Does not need info from transaction because it is only a call to the governance canister
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());
706
973
  return [
707
974
  {
708
975
  from: [(0, ICPImplementation_1.getAddressFromPublicKey)(publicKey)],
@@ -711,7 +978,13 @@ function getDetailsFromUnsignedFollowNeuron(publicKey, network) {
711
978
  amount: (0, module_kit_1.newAmount)('0', 'blockchain'),
712
979
  fee: (0, module_kit_1.newAmount)('0', 'blockchain'),
713
980
  network,
714
- type: transaction_1.ICPActionType.FOLLOW_NEURON
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
+ }
715
988
  }
716
989
  ];
717
990
  }
@@ -726,8 +999,29 @@ function signFollowNeuron(unsignedTransaction, privateKey, canisterId) {
726
999
  });
727
1000
  }
728
1001
  exports.signFollowNeuron = signFollowNeuron;
729
- function getDetailsFromSignedFollowNeuron(publicKey, network) {
730
- // Does not need info from transaction because it is only a call to the governance canister
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());
731
1025
  return [
732
1026
  {
733
1027
  from: [(0, ICPImplementation_1.getAddressFromPublicKey)(publicKey)],
@@ -736,7 +1030,11 @@ function getDetailsFromSignedFollowNeuron(publicKey, network) {
736
1030
  amount: (0, module_kit_1.newAmount)('0', 'blockchain'),
737
1031
  fee: (0, module_kit_1.newAmount)('0', 'blockchain'),
738
1032
  network,
739
- type: transaction_1.ICPActionType.FOLLOW_NEURON
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
+ }
740
1038
  }
741
1039
  ];
742
1040
  }
@@ -791,8 +1089,28 @@ function prepareDisburse(publicKey) {
791
1089
  });
792
1090
  }
793
1091
  exports.prepareDisburse = prepareDisburse;
794
- function getDetailsFromUnsignedDisburse(publicKey, network) {
795
- // Does not need info from transaction because it is only a call to the governance canister
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];
796
1114
  return [
797
1115
  {
798
1116
  from: [network.governanceCanisterId],
@@ -800,8 +1118,11 @@ function getDetailsFromUnsignedDisburse(publicKey, network) {
800
1118
  isInbound: false,
801
1119
  amount: (0, module_kit_1.newAmount)('0', 'blockchain'),
802
1120
  fee: (0, module_kit_1.newAmount)('0', 'blockchain'),
803
- network: network,
804
- type: transaction_1.ICPActionType.DISBURSE
1121
+ network,
1122
+ type: transaction_1.ICPActionType.DISBURSE,
1123
+ json: {
1124
+ ManageNeuron: (0, json_1.idlDecodedToJsonStringifiable)(manageNeuron)
1125
+ }
805
1126
  }
806
1127
  ];
807
1128
  }
@@ -816,8 +1137,29 @@ function signDisburse(unsignedTransaction, privateKey, canisterId) {
816
1137
  });
817
1138
  }
818
1139
  exports.signDisburse = signDisburse;
819
- function getDetailsFromSignedDisburse(publicKey, network) {
820
- // Does not need info from transaction because it is only a call to the governance canister
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];
821
1163
  return [
822
1164
  {
823
1165
  from: [network.governanceCanisterId],
@@ -826,7 +1168,8 @@ function getDetailsFromSignedDisburse(publicKey, network) {
826
1168
  amount: (0, module_kit_1.newAmount)('0', 'blockchain'),
827
1169
  fee: (0, module_kit_1.newAmount)('0', 'blockchain'),
828
1170
  network,
829
- 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) })
830
1173
  }
831
1174
  ];
832
1175
  }