@airgap/icp 0.13.15-beta.4 → 0.13.15-beta.6

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,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.getDetailsFromSignedTransactionRemoveStake = exports.signTransactionRemoveStake = exports.getDetailsFromUnsignedTransactionRemoveStake = exports.createUnsignedTransactionRemoveStake = exports.getDetailsFromSignedTransactionRestakeMaturity = exports.signTransactionRestakeMaturity = exports.getDetailsFromUnsignedTransactionRestakeMaturity = exports.createUnsignedTransactionRestakeMaturity = exports.getDetailsFromSignedTransactionFollowNeuron = exports.signTransactionFollowNeuron = exports.getDetailsFromUnsignedTransactionFollowNeuron = exports.createUnsignedTransactionFollowNeuron = exports.getDetailsFromSignedTransactionStopDissolving = exports.signTransactionStopDissolving = exports.getDetailsFromUnsignedTransactionStopDissolving = exports.createUnsignedTransactionStopDissolving = exports.getDetailsFromSignedTransactionStartDissolving = exports.signTransactionStartDissolving = exports.getDetailsFromUnsignedTransactionStartDissolving = exports.createUnsignedTransactionStartDissolving = exports.getDetailsFromSignedTransactionIncreaseDelay = exports.signTransactionIncreaseDelay = exports.getDetailsFromUnsignedTransactionIncreaseDelay = exports.createUnsignedTransactionIncreaseDelay = exports.getDetailsFromSignedTransactionClaimGovernance = exports.signTransactionClaimGovernance = exports.getDetailsFromUnsignedTransactionClaimGovernance = exports.createUnsignedTransactionClaimGovernance = exports.getDetailsFromSignedTransactionTransferToSubaccount = exports.signTransactionTransferToSubaccount = exports.getDetailsFromUnsignedTransactionTransferToSubaccount = exports.createUnsignedTransactionTransferToSubaccount = exports.getDetailsFromSignedTransactionGetNeuronInfo = exports.signTransactionGetNeuronInfo = exports.getDetailsFromUnsignedTransactionGetNeuronInfo = exports.createUnsignedTransactionGetNeuronInfo = void 0;
35
+ exports.getDetailsFromSignedDisburse = exports.signDisburse = exports.getDetailsFromUnsignedDisburse = exports.prepareDisburse = exports.getDetailsFromSignedTransactionRestakeMaturity = exports.signTransactionRestakeMaturity = exports.getDetailsFromUnsignedTransactionRestakeMaturity = exports.createUnsignedTransactionRestakeMaturity = exports.getDetailsFromSignedFollowNeuron = exports.signFollowNeuron = exports.getDetailsFromUnsignedFollowNeuron = exports.prepareFollowNeuron = exports.getDetailsFromSignedTransactionStopDissolving = exports.signTransactionStopDissolving = exports.getDetailsFromUnsignedTransactionStopDissolving = exports.createUnsignedTransactionStopDissolving = exports.getDetailsFromSignedStartDissolving = exports.signStartDissolving = exports.getDetailsFromUnsignedStartDissolving = exports.prepareStartDissolving = exports.getDetailsFromSignedTransactionIncreaseDelay = exports.signTransactionIncreaseDelay = exports.getDetailsFromUnsignedTransactionIncreaseDelay = exports.createUnsignedTransactionIncreaseDelay = 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,17 @@ const ICPImplementation_1 = require("./ICPImplementation");
88
88
  // }
89
89
  // ]
90
90
  // }
91
- function createUnsignedTransactionGetNeuronInfo() {
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 (0, module_kit_1.newUnsignedTransaction)({
95
- transactions: [
96
- {
97
- actionType: transaction_1.ICPActionType.GET_NEURON_INFO,
98
- encoded: ''
99
- }
100
- ]
101
- });
94
+ return {
95
+ actionType: transaction_1.ICPActionType.GET_NEURON_INFO,
96
+ encoded: ''
97
+ };
102
98
  });
103
99
  }
104
- exports.createUnsignedTransactionGetNeuronInfo = createUnsignedTransactionGetNeuronInfo;
105
- function getDetailsFromUnsignedTransactionGetNeuronInfo(publicKey, network) {
100
+ exports.prepareGetNeuronInfo = prepareGetNeuronInfo;
101
+ function getDetailsFromUnsignedGetNeuronInfo(publicKey, network) {
106
102
  // Does not need info from transaction because it is only a call to the governance canister
107
103
  return [
108
104
  {
@@ -111,24 +107,25 @@ function getDetailsFromUnsignedTransactionGetNeuronInfo(publicKey, network) {
111
107
  isInbound: false,
112
108
  amount: (0, module_kit_1.newAmount)('0', 'blockchain'),
113
109
  fee: (0, module_kit_1.newAmount)('0', 'blockchain'),
114
- network
110
+ network,
111
+ type: transaction_1.ICPActionType.GET_NEURON_INFO
115
112
  }
116
113
  ];
117
114
  }
118
- exports.getDetailsFromUnsignedTransactionGetNeuronInfo = getDetailsFromUnsignedTransactionGetNeuronInfo;
119
- function signTransactionGetNeuronInfo(unsignedTransaction, privateKey, canisterId) {
115
+ exports.getDetailsFromUnsignedGetNeuronInfo = getDetailsFromUnsignedGetNeuronInfo;
116
+ function signGetNeuronInfo(unsignedTransaction, privateKey, canisterId) {
120
117
  return __awaiter(this, void 0, void 0, function* () {
121
- const ListNeurons = IDL.Record({
122
- neuron_ids: IDL.Vec(IDL.Nat64),
123
- include_neurons_readable_by_caller: IDL.Bool
118
+ const NeuronIdOrSubaccount = IDL.Variant({
119
+ Subaccount: IDL.Vec(IDL.Nat8)
124
120
  });
125
- const args = IDL.encode([ListNeurons], [{ neuron_ids: [], include_neurons_readable_by_caller: true }]);
126
- const signedTransaction = (0, ICPImplementation_1.signTransaction)(privateKey, canisterId, args, 'list_neurons', 'query');
121
+ const { subAccount } = (0, ICPImplementation_1.getFixedSubaccountFromPrivateKey)(privateKey);
122
+ const args = IDL.encode([NeuronIdOrSubaccount], [{ Subaccount: subAccount.toUint8Array() }]);
123
+ const signedTransaction = (0, ICPImplementation_1.signTransaction)(privateKey, canisterId, args, 'get_full_neuron_by_id_or_subaccount', 'query');
127
124
  return signedTransaction;
128
125
  });
129
126
  }
130
- exports.signTransactionGetNeuronInfo = signTransactionGetNeuronInfo;
131
- function getDetailsFromSignedTransactionGetNeuronInfo(publicKey, network) {
127
+ exports.signGetNeuronInfo = signGetNeuronInfo;
128
+ function getDetailsFromSignedGetNeuronInfo(publicKey, network) {
132
129
  // Does not need info from transaction because it is only a call to the governance canister
133
130
  return [
134
131
  {
@@ -137,17 +134,18 @@ function getDetailsFromSignedTransactionGetNeuronInfo(publicKey, network) {
137
134
  isInbound: false,
138
135
  amount: (0, module_kit_1.newAmount)('0', 'blockchain'),
139
136
  fee: (0, module_kit_1.newAmount)('0', 'blockchain'),
140
- network
137
+ network,
138
+ type: transaction_1.ICPActionType.GET_NEURON_INFO
141
139
  }
142
140
  ];
143
141
  }
144
- exports.getDetailsFromSignedTransactionGetNeuronInfo = getDetailsFromSignedTransactionGetNeuronInfo;
142
+ exports.getDetailsFromSignedGetNeuronInfo = getDetailsFromSignedGetNeuronInfo;
145
143
  // TRANSFER_TO_SUBACCOUNT
146
144
  // CANISTER : (name: NNS Ledger, identifier: ryjl3-tyaaa-aaaaa-aaaba-cai)
147
145
  // METHOD : (name: transfer, type: update)
148
146
  // PAYLOAD : (to : {}, fee : {e8s: int}, memo: int, from_subaccount: [], created_at_time: [{timestamp_nanos : float}], amount: {e8s: int})
149
147
  // RESPONSE : (Ok : int)
150
- function createUnsignedTransactionTransferToSubaccount(publicKey, canisterId, amount, fee) {
148
+ function prepareTransferToSubaccount(publicKey, canisterId, amount, fee) {
151
149
  return __awaiter(this, void 0, void 0, function* () {
152
150
  // Create subaccount from publicKey
153
151
  const { subAccount, nonce } = (0, ICPImplementation_1.getFixedSubaccountFromPublicKey)(publicKey);
@@ -157,22 +155,18 @@ function createUnsignedTransactionTransferToSubaccount(publicKey, canisterId, am
157
155
  });
158
156
  const unsignedTransfer = (0, ICPImplementation_1.createUnsignedTransaction)({
159
157
  memo: nonce,
160
- amount: amount,
158
+ amount,
161
159
  to: accountIdentifier.toHex(),
162
- fee: fee
163
- });
164
- return (0, module_kit_1.newUnsignedTransaction)({
165
- transactions: [
166
- {
167
- actionType: transaction_1.ICPActionType.TRANSFER_TO_SUBACCOUNT,
168
- encoded: unsignedTransfer
169
- }
170
- ]
160
+ fee
171
161
  });
162
+ return {
163
+ actionType: transaction_1.ICPActionType.TRANSFER_TO_SUBACCOUNT,
164
+ encoded: unsignedTransfer
165
+ };
172
166
  });
173
167
  }
174
- exports.createUnsignedTransactionTransferToSubaccount = createUnsignedTransactionTransferToSubaccount;
175
- function getDetailsFromUnsignedTransactionTransferToSubaccount(unsignedTransaction, publicKey, network) {
168
+ exports.prepareTransferToSubaccount = prepareTransferToSubaccount;
169
+ function getDetailsFromUnsignedTransferToSubaccount(unsignedTransaction, publicKey, network) {
176
170
  const info = (0, ICPImplementation_1.getInfoFromUnsignedTransaction)(unsignedTransaction);
177
171
  return [
178
172
  {
@@ -181,49 +175,82 @@ function getDetailsFromUnsignedTransactionTransferToSubaccount(unsignedTransacti
181
175
  isInbound: false,
182
176
  amount: (0, module_kit_1.newAmount)(info.amount.toString(), 'blockchain'),
183
177
  fee: (0, module_kit_1.newAmount)(info.fee.toString(), 'blockchain'),
184
- network
178
+ network,
179
+ type: transaction_1.ICPActionType.TRANSFER_TO_SUBACCOUNT
185
180
  }
186
181
  ];
187
182
  }
188
- exports.getDetailsFromUnsignedTransactionTransferToSubaccount = getDetailsFromUnsignedTransactionTransferToSubaccount;
189
- function signTransactionTransferToSubaccount(unsignedTransaction, privateKey, canisterId) {
183
+ exports.getDetailsFromUnsignedTransferToSubaccount = getDetailsFromUnsignedTransferToSubaccount;
184
+ function signTransferToSubaccount(unsignedTransaction, privateKey, canisterId) {
190
185
  return __awaiter(this, void 0, void 0, function* () {
191
186
  return (0, ICPImplementation_1.signTransactionTransfer)(unsignedTransaction, privateKey, canisterId);
192
187
  });
193
188
  }
194
- exports.signTransactionTransferToSubaccount = signTransactionTransferToSubaccount;
195
- function getDetailsFromSignedTransactionTransferToSubaccount(signedTransaction, publicKey, network) {
196
- return (0, ICPImplementation_1.getDetailsFromSignedTransactionTransfer)(signedTransaction, publicKey, network);
189
+ exports.signTransferToSubaccount = signTransferToSubaccount;
190
+ function getDetailsFromSignedTransferToSubaccount(signedTransaction, publicKey, network) {
191
+ const info = (0, ICPImplementation_1.getDetailsFromSignedTransactionTransfer)(signedTransaction, publicKey, network);
192
+ return info.map((tx) => (Object.assign(Object.assign({}, tx), { type: transaction_1.ICPActionType.TRANSFER_TO_SUBACCOUNT })));
197
193
  }
198
- exports.getDetailsFromSignedTransactionTransferToSubaccount = getDetailsFromSignedTransactionTransferToSubaccount;
194
+ exports.getDetailsFromSignedTransferToSubaccount = getDetailsFromSignedTransferToSubaccount;
199
195
  // CLAIM_GOVERNANCE ?
200
196
  // CANISTER : (name: NNS Governance, identifier: rrkah-fqaaa-aaaaa-aaaaq-cai)
201
197
  // METHOD : (name: claim_or_refresh_neuron_from_account, type: call)
202
- function createUnsignedTransactionClaimGovernance(publicKey) {
198
+ function prepareClaimOrRefreshNeuron(publicKey) {
203
199
  return __awaiter(this, void 0, void 0, function* () {
204
200
  // Create subaccount from publicKey
205
- const { subAccount: _, nonce } = (0, ICPImplementation_1.getFixedSubaccountFromPublicKey)(publicKey);
201
+ const { nonce } = (0, ICPImplementation_1.getFixedSubaccountFromPublicKey)(publicKey);
206
202
  // Get Principal from public key
207
203
  const principal = (0, ICPImplementation_1.getPrincipalFromPublicKey)(publicKey);
208
- // IDL for ClaimOrRefresh
204
+ // IDL for ManageNeuron
205
+ const NeuronId = IDL.Record({ id: IDL.Nat64 });
209
206
  const ClaimOrRefreshNeuronFromAccount = IDL.Record({
210
207
  controller: IDL.Opt(IDL.Principal),
211
208
  memo: IDL.Nat64
212
209
  });
213
- // Encode
214
- const unsignedTransactionBuffer = IDL.encode([ClaimOrRefreshNeuronFromAccount], [{ controller: [principal], memo: nonce }]);
215
- return (0, module_kit_1.newUnsignedTransaction)({
216
- transactions: [
217
- {
218
- actionType: transaction_1.ICPActionType.CLAIM_GOVERNANCE,
219
- encoded: (0, convert_1.arrayBufferToHexString)(unsignedTransactionBuffer)
220
- }
221
- ]
210
+ const By = IDL.Variant({
211
+ NeuronIdOrSubaccount: IDL.Record({}),
212
+ MemoAndController: ClaimOrRefreshNeuronFromAccount,
213
+ Memo: IDL.Nat64
214
+ });
215
+ const ClaimOrRefresh = IDL.Record({ by: IDL.Opt(By) });
216
+ const Command = IDL.Variant({
217
+ ClaimOrRefresh: ClaimOrRefresh
222
218
  });
219
+ const NeuronIdOrSubaccount = IDL.Variant({
220
+ Subaccount: IDL.Vec(IDL.Nat8),
221
+ NeuronId: NeuronId
222
+ });
223
+ const ManageNeuron = IDL.Record({
224
+ id: IDL.Opt(NeuronId),
225
+ command: IDL.Opt(Command),
226
+ neuron_id_or_subaccount: IDL.Opt(NeuronIdOrSubaccount)
227
+ });
228
+ // Encode
229
+ const unsignedTransactionBuffer = IDL.encode([ManageNeuron], [
230
+ {
231
+ id: [],
232
+ command: [
233
+ {
234
+ ClaimOrRefresh: {
235
+ by: [
236
+ {
237
+ MemoAndController: { controller: [principal], memo: nonce }
238
+ }
239
+ ]
240
+ }
241
+ }
242
+ ],
243
+ neuron_id_or_subaccount: []
244
+ }
245
+ ]);
246
+ return {
247
+ actionType: transaction_1.ICPActionType.CLAIM_GOVERNANCE,
248
+ encoded: (0, convert_1.arrayBufferToHexString)(unsignedTransactionBuffer)
249
+ };
223
250
  });
224
251
  }
225
- exports.createUnsignedTransactionClaimGovernance = createUnsignedTransactionClaimGovernance;
226
- function getDetailsFromUnsignedTransactionClaimGovernance(publicKey, network) {
252
+ exports.prepareClaimOrRefreshNeuron = prepareClaimOrRefreshNeuron;
253
+ function getDetailsFromUnsignedClaimGovernance(publicKey, network) {
227
254
  // Does not need info from transaction because it is only a call to the governance canister
228
255
  return [
229
256
  {
@@ -232,22 +259,23 @@ function getDetailsFromUnsignedTransactionClaimGovernance(publicKey, network) {
232
259
  isInbound: false,
233
260
  amount: (0, module_kit_1.newAmount)('0', 'blockchain'),
234
261
  fee: (0, module_kit_1.newAmount)('0', 'blockchain'),
235
- network
262
+ network,
263
+ type: transaction_1.ICPActionType.CLAIM_GOVERNANCE
236
264
  }
237
265
  ];
238
266
  }
239
- exports.getDetailsFromUnsignedTransactionClaimGovernance = getDetailsFromUnsignedTransactionClaimGovernance;
240
- function signTransactionClaimGovernance(unsignedTransaction, privateKey, canisterId) {
267
+ exports.getDetailsFromUnsignedClaimGovernance = getDetailsFromUnsignedClaimGovernance;
268
+ function signClaimGovernance(unsignedTransaction, privateKey, canisterId) {
241
269
  return __awaiter(this, void 0, void 0, function* () {
242
270
  // unsignedTransaction has already the arguments needed for signing, just need to be in a Buffer
243
271
  const args = (0, convert_1.hexStringToArrayBuffer)(unsignedTransaction);
244
272
  // Sign transaction
245
- const signedTransaction = (0, ICPImplementation_1.signTransaction)(privateKey, canisterId, args, 'claim_or_refresh_neuron_from_account', 'call');
273
+ const signedTransaction = (0, ICPImplementation_1.signTransaction)(privateKey, canisterId, args, 'manage_neuron', 'call');
246
274
  return signedTransaction;
247
275
  });
248
276
  }
249
- exports.signTransactionClaimGovernance = signTransactionClaimGovernance;
250
- function getDetailsFromSignedTransactionClaimGovernance(publicKey, network) {
277
+ exports.signClaimGovernance = signClaimGovernance;
278
+ function getDetailsFromTransactionClaimGovernance(publicKey, network) {
251
279
  // Does not need info from transaction because it is only a call to the governance canister
252
280
  return [
253
281
  {
@@ -256,11 +284,12 @@ function getDetailsFromSignedTransactionClaimGovernance(publicKey, network) {
256
284
  isInbound: false,
257
285
  amount: (0, module_kit_1.newAmount)('0', 'blockchain'),
258
286
  fee: (0, module_kit_1.newAmount)('0', 'blockchain'),
259
- network
287
+ network,
288
+ type: transaction_1.ICPActionType.CLAIM_GOVERNANCE
260
289
  }
261
290
  ];
262
291
  }
263
- exports.getDetailsFromSignedTransactionClaimGovernance = getDetailsFromSignedTransactionClaimGovernance;
292
+ exports.getDetailsFromTransactionClaimGovernance = getDetailsFromTransactionClaimGovernance;
264
293
  // INCREASE_DELAY
265
294
  // CANISTER : (name: NNS Governance, identifier: rrkah-fqaaa-aaaaa-aaaaq-cai)
266
295
  // METHOD : (name: manage_neuron, type: update)
@@ -295,13 +324,13 @@ function createUnsignedTransactionIncreaseDelay(publicKey, delaySeconds) {
295
324
  const unsignedTransactionBuffer = IDL.encode([ManageNeuron], [
296
325
  {
297
326
  command: [{ Configure: { operation: [{ IncreaseDissolveDelay: { additional_dissolve_delay_seconds: delaySeconds } }] } }],
298
- neuron_id_or_subaccount: [{ Subaccount: subAccount }]
327
+ neuron_id_or_subaccount: [{ Subaccount: subAccount.toUint8Array() }]
299
328
  }
300
329
  ]);
301
330
  return (0, module_kit_1.newUnsignedTransaction)({
302
331
  transactions: [
303
332
  {
304
- actionType: transaction_1.ICPActionType.INCREASE_DELAY,
333
+ actionType: transaction_1.ICPActionType.INCREASE_DISSOLVING_DELAY,
305
334
  encoded: (0, convert_1.arrayBufferToHexString)(unsignedTransactionBuffer)
306
335
  }
307
336
  ]
@@ -352,7 +381,7 @@ exports.getDetailsFromSignedTransactionIncreaseDelay = getDetailsFromSignedTrans
352
381
  // METHOD : (name: manage_neuron, type: update)
353
382
  // PAYLOAD : (id : [{id : float}], command : [{Configure : {operation : [{StartDissolving : {}}]}}], neuron_id_or_subaccount : [])
354
383
  // RESPONSE : (command : [{configure : {}}])
355
- function createUnsignedTransactionStartDissolving(publicKey) {
384
+ function prepareStartDissolving(publicKey) {
356
385
  return __awaiter(this, void 0, void 0, function* () {
357
386
  // Create subaccount from publicKey
358
387
  const { subAccount, nonce: _ } = (0, ICPImplementation_1.getFixedSubaccountFromPublicKey)(publicKey);
@@ -378,22 +407,19 @@ function createUnsignedTransactionStartDissolving(publicKey) {
378
407
  // Encode
379
408
  const unsignedTransactionBuffer = IDL.encode([ManageNeuron], [
380
409
  {
410
+ id: [],
381
411
  command: [{ Configure: { operation: [{ StartDissolving: {} }] } }],
382
- neuron_id_or_subaccount: [{ Subaccount: subAccount }]
412
+ neuron_id_or_subaccount: [{ Subaccount: subAccount.toUint8Array() }]
383
413
  }
384
414
  ]);
385
- return (0, module_kit_1.newUnsignedTransaction)({
386
- transactions: [
387
- {
388
- actionType: transaction_1.ICPActionType.START_DISSOLVING,
389
- encoded: (0, convert_1.arrayBufferToHexString)(unsignedTransactionBuffer)
390
- }
391
- ]
392
- });
415
+ return {
416
+ actionType: transaction_1.ICPActionType.START_DISSOLVING,
417
+ encoded: (0, convert_1.arrayBufferToHexString)(unsignedTransactionBuffer)
418
+ };
393
419
  });
394
420
  }
395
- exports.createUnsignedTransactionStartDissolving = createUnsignedTransactionStartDissolving;
396
- function getDetailsFromUnsignedTransactionStartDissolving(publicKey, network) {
421
+ exports.prepareStartDissolving = prepareStartDissolving;
422
+ function getDetailsFromUnsignedStartDissolving(publicKey, network) {
397
423
  // Does not need info from transaction because it is only a call to the governance canister
398
424
  return [
399
425
  {
@@ -402,12 +428,13 @@ function getDetailsFromUnsignedTransactionStartDissolving(publicKey, network) {
402
428
  isInbound: false,
403
429
  amount: (0, module_kit_1.newAmount)('0', 'blockchain'),
404
430
  fee: (0, module_kit_1.newAmount)('0', 'blockchain'),
405
- network
431
+ network,
432
+ type: transaction_1.ICPActionType.START_DISSOLVING
406
433
  }
407
434
  ];
408
435
  }
409
- exports.getDetailsFromUnsignedTransactionStartDissolving = getDetailsFromUnsignedTransactionStartDissolving;
410
- function signTransactionStartDissolving(unsignedTransaction, privateKey, canisterId) {
436
+ exports.getDetailsFromUnsignedStartDissolving = getDetailsFromUnsignedStartDissolving;
437
+ function signStartDissolving(unsignedTransaction, privateKey, canisterId) {
411
438
  return __awaiter(this, void 0, void 0, function* () {
412
439
  // unsignedTransaction has already the arguments needed for signing, just need to be in a Buffer
413
440
  const args = (0, convert_1.hexStringToArrayBuffer)(unsignedTransaction);
@@ -416,8 +443,8 @@ function signTransactionStartDissolving(unsignedTransaction, privateKey, caniste
416
443
  return signedTransaction;
417
444
  });
418
445
  }
419
- exports.signTransactionStartDissolving = signTransactionStartDissolving;
420
- function getDetailsFromSignedTransactionStartDissolving(publicKey, network) {
446
+ exports.signStartDissolving = signStartDissolving;
447
+ function getDetailsFromSignedStartDissolving(publicKey, network) {
421
448
  // Does not need info from transaction because it is only a call to the governance canister
422
449
  return [
423
450
  {
@@ -426,11 +453,12 @@ function getDetailsFromSignedTransactionStartDissolving(publicKey, network) {
426
453
  isInbound: false,
427
454
  amount: (0, module_kit_1.newAmount)('0', 'blockchain'),
428
455
  fee: (0, module_kit_1.newAmount)('0', 'blockchain'),
429
- network: network
456
+ network: network,
457
+ type: transaction_1.ICPActionType.START_DISSOLVING
430
458
  }
431
459
  ];
432
460
  }
433
- exports.getDetailsFromSignedTransactionStartDissolving = getDetailsFromSignedTransactionStartDissolving;
461
+ exports.getDetailsFromSignedStartDissolving = getDetailsFromSignedStartDissolving;
434
462
  // STOP_DISSOLVING
435
463
  // CANISTER : (name: NNS Governance, identifier: rrkah-fqaaa-aaaaa-aaaaq-cai)
436
464
  // METHOD : (name: manage_neuron, type: update)
@@ -463,7 +491,7 @@ function createUnsignedTransactionStopDissolving(publicKey) {
463
491
  const unsignedTransactionBuffer = IDL.encode([ManageNeuron], [
464
492
  {
465
493
  command: [{ Configure: { operation: [{ StopDissolving: {} }] } }],
466
- neuron_id_or_subaccount: [{ Subaccount: subAccount }]
494
+ neuron_id_or_subaccount: [{ Subaccount: subAccount.toUint8Array() }]
467
495
  }
468
496
  ]);
469
497
  return (0, module_kit_1.newUnsignedTransaction)({
@@ -520,7 +548,7 @@ exports.getDetailsFromSignedTransactionStopDissolving = getDetailsFromSignedTran
520
548
  // METHOD : (name: manage_neuron, type: update)
521
549
  // PAYLOAD : (id : [{id : float}], command : [{Follow : {topic : int, followees : [{id: int}]}}], neuron_id_or_subaccount : [])
522
550
  // RESPONSE : (command : [{Follow : {}}])
523
- function createUnsignedTransactionFollowNeuron(publicKey, neuronId) {
551
+ function prepareFollowNeuron(publicKey, neuronId) {
524
552
  return __awaiter(this, void 0, void 0, function* () {
525
553
  // Create subaccount from publicKey
526
554
  const { subAccount, nonce: _ } = (0, ICPImplementation_1.getFixedSubaccountFromPublicKey)(publicKey);
@@ -548,21 +576,17 @@ function createUnsignedTransactionFollowNeuron(publicKey, neuronId) {
548
576
  const unsignedTransactionBuffer = IDL.encode([ManageNeuron], [
549
577
  {
550
578
  command: [{ Follow: { topic: topic, followees: [neuronId] } }],
551
- neuron_id_or_subaccount: [{ Subaccount: subAccount }]
579
+ neuron_id_or_subaccount: [{ Subaccount: subAccount.toUint8Array() }]
552
580
  }
553
581
  ]);
554
- return (0, module_kit_1.newUnsignedTransaction)({
555
- transactions: [
556
- {
557
- actionType: transaction_1.ICPActionType.FOLLOW_NEURON,
558
- encoded: (0, convert_1.arrayBufferToHexString)(unsignedTransactionBuffer)
559
- }
560
- ]
561
- });
582
+ return {
583
+ actionType: transaction_1.ICPActionType.FOLLOW_NEURON,
584
+ encoded: (0, convert_1.arrayBufferToHexString)(unsignedTransactionBuffer)
585
+ };
562
586
  });
563
587
  }
564
- exports.createUnsignedTransactionFollowNeuron = createUnsignedTransactionFollowNeuron;
565
- function getDetailsFromUnsignedTransactionFollowNeuron(publicKey, network) {
588
+ exports.prepareFollowNeuron = prepareFollowNeuron;
589
+ function getDetailsFromUnsignedFollowNeuron(publicKey, network) {
566
590
  // Does not need info from transaction because it is only a call to the governance canister
567
591
  return [
568
592
  {
@@ -575,8 +599,8 @@ function getDetailsFromUnsignedTransactionFollowNeuron(publicKey, network) {
575
599
  }
576
600
  ];
577
601
  }
578
- exports.getDetailsFromUnsignedTransactionFollowNeuron = getDetailsFromUnsignedTransactionFollowNeuron;
579
- function signTransactionFollowNeuron(unsignedTransaction, privateKey, canisterId) {
602
+ exports.getDetailsFromUnsignedFollowNeuron = getDetailsFromUnsignedFollowNeuron;
603
+ function signFollowNeuron(unsignedTransaction, privateKey, canisterId) {
580
604
  return __awaiter(this, void 0, void 0, function* () {
581
605
  // unsignedTransaction has already the arguments needed for signing, just need to be in a Buffer
582
606
  const args = (0, convert_1.hexStringToArrayBuffer)(unsignedTransaction);
@@ -585,8 +609,8 @@ function signTransactionFollowNeuron(unsignedTransaction, privateKey, canisterId
585
609
  return signedTransaction;
586
610
  });
587
611
  }
588
- exports.signTransactionFollowNeuron = signTransactionFollowNeuron;
589
- function getDetailsFromSignedTransactionFollowNeuron(publicKey, network) {
612
+ exports.signFollowNeuron = signFollowNeuron;
613
+ function getDetailsFromSignedFollowNeuron(publicKey, network) {
590
614
  // Does not need info from transaction because it is only a call to the governance canister
591
615
  return [
592
616
  {
@@ -599,7 +623,7 @@ function getDetailsFromSignedTransactionFollowNeuron(publicKey, network) {
599
623
  }
600
624
  ];
601
625
  }
602
- exports.getDetailsFromSignedTransactionFollowNeuron = getDetailsFromSignedTransactionFollowNeuron;
626
+ exports.getDetailsFromSignedFollowNeuron = getDetailsFromSignedFollowNeuron;
603
627
  // RESTAKE_MATURITY
604
628
  // CANISTER : (name: NNS Governance, identifier: rrkah-fqaaa-aaaaa-aaaaq-cai)
605
629
  // METHOD : (name: manage_neuron, type: update)
@@ -630,13 +654,13 @@ function createUnsignedTransactionRestakeMaturity(publicKey, percentageStake) {
630
654
  const unsignedTransactionBuffer = IDL.encode([ManageNeuron], [
631
655
  {
632
656
  command: [{ StakeMaturity: { percentage_to_stake: percentageStake } }],
633
- neuron_id_or_subaccount: [{ Subaccount: subAccount }]
657
+ neuron_id_or_subaccount: [{ Subaccount: subAccount.toUint8Array() }]
634
658
  }
635
659
  ]);
636
660
  return (0, module_kit_1.newUnsignedTransaction)({
637
661
  transactions: [
638
662
  {
639
- actionType: transaction_1.ICPActionType.FOLLOW_NEURON,
663
+ actionType: transaction_1.ICPActionType.RESTAKE_MATURITY,
640
664
  encoded: (0, convert_1.arrayBufferToHexString)(unsignedTransactionBuffer)
641
665
  }
642
666
  ]
@@ -682,46 +706,70 @@ function getDetailsFromSignedTransactionRestakeMaturity(publicKey, network) {
682
706
  ];
683
707
  }
684
708
  exports.getDetailsFromSignedTransactionRestakeMaturity = getDetailsFromSignedTransactionRestakeMaturity;
685
- // REMOVE_STAKE
709
+ // DISBURSE
686
710
  // Cannot extrapolate method from call since we have to wait 6 months to do so
687
- function createUnsignedTransactionRemoveStake(publicKey) {
711
+ function prepareDisburse(publicKey) {
688
712
  return __awaiter(this, void 0, void 0, function* () {
689
713
  // Create subaccount from publicKey
690
714
  const { subAccount, nonce: _ } = (0, ICPImplementation_1.getFixedSubaccountFromPublicKey)(publicKey);
691
- // IDL for RemoveStake
715
+ // IDL for Disburse
716
+ const NeuronId = IDL.Record({ id: IDL.Nat64 });
717
+ const AccountIdentifier = IDL.Record({ hash: IDL.Vec(IDL.Nat8) });
718
+ const Amount = IDL.Record({ e8s: IDL.Nat64 });
719
+ const Disburse = IDL.Record({
720
+ to_account: IDL.Opt(AccountIdentifier),
721
+ amount: IDL.Opt(Amount)
722
+ });
723
+ const Command = IDL.Variant({
724
+ Disburse: Disburse
725
+ });
726
+ const NeuronIdOrSubaccount = IDL.Variant({
727
+ Subaccount: IDL.Vec(IDL.Nat8),
728
+ NeuronId: NeuronId
729
+ });
730
+ const ManageNeuron = IDL.Record({
731
+ id: IDL.Opt(NeuronId),
732
+ command: IDL.Opt(Command),
733
+ neuron_id_or_subaccount: IDL.Opt(NeuronIdOrSubaccount)
734
+ });
692
735
  // Encode
693
- const unsignedTransactionBuffer = IDL.encode([], [
736
+ const unsignedTransactionBuffer = IDL.encode([ManageNeuron], [
694
737
  {
695
- command: [],
696
- neuron_id_or_subaccount: [{ Subaccount: subAccount }]
738
+ id: [],
739
+ command: [
740
+ {
741
+ Disburse: {
742
+ to_account: [],
743
+ amount: []
744
+ }
745
+ }
746
+ ],
747
+ neuron_id_or_subaccount: [{ Subaccount: subAccount.toUint8Array() }]
697
748
  }
698
749
  ]);
699
- return (0, module_kit_1.newUnsignedTransaction)({
700
- transactions: [
701
- {
702
- actionType: transaction_1.ICPActionType.REMOVE_STAKE,
703
- encoded: (0, convert_1.arrayBufferToHexString)(unsignedTransactionBuffer)
704
- }
705
- ]
706
- });
750
+ return {
751
+ actionType: transaction_1.ICPActionType.DISBURSE,
752
+ encoded: (0, convert_1.arrayBufferToHexString)(unsignedTransactionBuffer)
753
+ };
707
754
  });
708
755
  }
709
- exports.createUnsignedTransactionRemoveStake = createUnsignedTransactionRemoveStake;
710
- function getDetailsFromUnsignedTransactionRemoveStake(publicKey, network) {
756
+ exports.prepareDisburse = prepareDisburse;
757
+ function getDetailsFromUnsignedDisburse(publicKey, network) {
711
758
  // Does not need info from transaction because it is only a call to the governance canister
712
759
  return [
713
760
  {
714
- from: [(0, ICPImplementation_1.getAddressFromPublicKey)(publicKey)],
715
- to: [network.governanceCanisterId],
761
+ from: [network.governanceCanisterId],
762
+ to: [(0, ICPImplementation_1.getAddressFromPublicKey)(publicKey)],
716
763
  isInbound: false,
717
764
  amount: (0, module_kit_1.newAmount)('0', 'blockchain'),
718
765
  fee: (0, module_kit_1.newAmount)('0', 'blockchain'),
719
- network: network
766
+ network: network,
767
+ type: transaction_1.ICPActionType.DISBURSE
720
768
  }
721
769
  ];
722
770
  }
723
- exports.getDetailsFromUnsignedTransactionRemoveStake = getDetailsFromUnsignedTransactionRemoveStake;
724
- function signTransactionRemoveStake(unsignedTransaction, privateKey, canisterId) {
771
+ exports.getDetailsFromUnsignedDisburse = getDetailsFromUnsignedDisburse;
772
+ function signDisburse(unsignedTransaction, privateKey, canisterId) {
725
773
  return __awaiter(this, void 0, void 0, function* () {
726
774
  // unsignedTransaction has already the arguments needed for signing, just need to be in a Buffer
727
775
  const args = (0, convert_1.hexStringToArrayBuffer)(unsignedTransaction);
@@ -730,19 +778,20 @@ function signTransactionRemoveStake(unsignedTransaction, privateKey, canisterId)
730
778
  return signedTransaction;
731
779
  });
732
780
  }
733
- exports.signTransactionRemoveStake = signTransactionRemoveStake;
734
- function getDetailsFromSignedTransactionRemoveStake(publicKey, network) {
781
+ exports.signDisburse = signDisburse;
782
+ function getDetailsFromSignedDisburse(publicKey, network) {
735
783
  // Does not need info from transaction because it is only a call to the governance canister
736
784
  return [
737
785
  {
738
- from: [(0, ICPImplementation_1.getAddressFromPublicKey)(publicKey)],
739
- to: [network.governanceCanisterId],
786
+ from: [network.governanceCanisterId],
787
+ to: [(0, ICPImplementation_1.getAddressFromPublicKey)(publicKey)],
740
788
  isInbound: false,
741
789
  amount: (0, module_kit_1.newAmount)('0', 'blockchain'),
742
790
  fee: (0, module_kit_1.newAmount)('0', 'blockchain'),
743
- network
791
+ network,
792
+ type: transaction_1.ICPActionType.DISBURSE
744
793
  }
745
794
  ];
746
795
  }
747
- exports.getDetailsFromSignedTransactionRemoveStake = getDetailsFromSignedTransactionRemoveStake;
796
+ exports.getDetailsFromSignedDisburse = getDetailsFromSignedDisburse;
748
797
  //# sourceMappingURL=ICPGovernance.js.map