@airgap/icp 0.13.15-beta.6 → 0.13.15-beta.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +5 -5
- package/v1/protocol/ICPGovernance.d.ts +19 -19
- package/v1/protocol/ICPGovernance.js +150 -113
- package/v1/protocol/ICPGovernance.js.map +1 -1
- package/v1/protocol/ICPProtocol.d.ts +8 -4
- package/v1/protocol/ICPProtocol.js +129 -92
- package/v1/protocol/ICPProtocol.js.map +1 -1
- package/v1/serializer/v3/schemas/generated/transaction-sign-request-icp.json +2 -3
- package/v1/types/governance.d.ts +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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@airgap/icp",
|
|
3
|
-
"version": "0.13.15-beta.
|
|
3
|
+
"version": "0.13.15-beta.7",
|
|
4
4
|
"description": "The @airgap/icp is an ICP implementation of the ICoinProtocol interface from @airgap/coinlib-core.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"airgap",
|
|
@@ -30,10 +30,10 @@
|
|
|
30
30
|
},
|
|
31
31
|
"author": "Papers AG <contact@papers.ch> (https://papers.ch)",
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@airgap/coinlib-core": "^0.13.15-beta.
|
|
34
|
-
"@airgap/crypto": "^0.13.15-beta.
|
|
35
|
-
"@airgap/module-kit": "^0.13.15-beta.
|
|
36
|
-
"@airgap/serializer": "^0.13.15-beta.
|
|
33
|
+
"@airgap/coinlib-core": "^0.13.15-beta.7",
|
|
34
|
+
"@airgap/crypto": "^0.13.15-beta.7",
|
|
35
|
+
"@airgap/module-kit": "^0.13.15-beta.7",
|
|
36
|
+
"@airgap/serializer": "^0.13.15-beta.7",
|
|
37
37
|
"@dfinity/agent": "^0.15.4",
|
|
38
38
|
"@dfinity/identity-secp256k1": "^0.15.4",
|
|
39
39
|
"@dfinity/nns": "^0.14.0",
|
|
@@ -1,39 +1,39 @@
|
|
|
1
1
|
import { AirGapTransaction } from '@airgap/module-kit';
|
|
2
|
-
import { ICPProtocolNetwork, ICPUnits
|
|
2
|
+
import { ICPProtocolNetwork, ICPUnits } from '../module';
|
|
3
3
|
import { ICPTransaction } from '../types/transaction';
|
|
4
|
-
export declare function prepareGetNeuronInfo(): Promise<ICPTransaction>;
|
|
4
|
+
export declare function prepareGetNeuronInfo(): Promise<ICPTransaction[]>;
|
|
5
5
|
export declare function getDetailsFromUnsignedGetNeuronInfo(publicKey: string, network: ICPProtocolNetwork): AirGapTransaction<ICPUnits>[];
|
|
6
6
|
export declare function signGetNeuronInfo(unsignedTransaction: string, privateKey: string, canisterId: string): Promise<string>;
|
|
7
7
|
export declare function getDetailsFromSignedGetNeuronInfo(publicKey: string, network: ICPProtocolNetwork): AirGapTransaction<ICPUnits>[];
|
|
8
|
-
export declare function prepareTransferToSubaccount(publicKey: string, canisterId: string, amount: bigint, fee: bigint): Promise<ICPTransaction>;
|
|
8
|
+
export declare function prepareTransferToSubaccount(publicKey: string, canisterId: string, amount: bigint, fee: bigint): Promise<ICPTransaction[]>;
|
|
9
9
|
export declare function getDetailsFromUnsignedTransferToSubaccount(unsignedTransaction: string, publicKey: string, network: ICPProtocolNetwork): AirGapTransaction<ICPUnits>[];
|
|
10
10
|
export declare function signTransferToSubaccount(unsignedTransaction: string, privateKey: string, canisterId: string): Promise<string>;
|
|
11
11
|
export declare function getDetailsFromSignedTransferToSubaccount(signedTransaction: string, publicKey: string, network: ICPProtocolNetwork): AirGapTransaction<ICPUnits>[];
|
|
12
|
-
export declare function prepareClaimOrRefreshNeuron(publicKey: string): Promise<ICPTransaction>;
|
|
12
|
+
export declare function prepareClaimOrRefreshNeuron(publicKey: string): Promise<ICPTransaction[]>;
|
|
13
13
|
export declare function getDetailsFromUnsignedClaimGovernance(publicKey: string, network: ICPProtocolNetwork): AirGapTransaction<ICPUnits>[];
|
|
14
14
|
export declare function signClaimGovernance(unsignedTransaction: string, privateKey: string, canisterId: string): Promise<string>;
|
|
15
15
|
export declare function getDetailsFromTransactionClaimGovernance(publicKey: string, network: ICPProtocolNetwork): AirGapTransaction<ICPUnits>[];
|
|
16
|
-
export declare function
|
|
17
|
-
export declare function
|
|
18
|
-
export declare function
|
|
19
|
-
export declare function
|
|
20
|
-
export declare function prepareStartDissolving(publicKey: string): Promise<ICPTransaction>;
|
|
16
|
+
export declare function prepareIncreaseDissolveDelay(publicKey: string, additionalDissolveDelay: bigint): Promise<ICPTransaction[]>;
|
|
17
|
+
export declare function getDetailsFromUnsignedIncreaseDissolveDelay(publicKey: string, network: ICPProtocolNetwork): AirGapTransaction<ICPUnits>[];
|
|
18
|
+
export declare function signIncreaseDissolveDelay(unsignedTransaction: string, privateKey: string, canisterId: string): Promise<string>;
|
|
19
|
+
export declare function getDetailsFromSignedIncreaseDissolveDelay(publicKey: string, network: ICPProtocolNetwork): AirGapTransaction<ICPUnits>[];
|
|
20
|
+
export declare function prepareStartDissolving(publicKey: string): Promise<ICPTransaction[]>;
|
|
21
21
|
export declare function getDetailsFromUnsignedStartDissolving(publicKey: string, network: ICPProtocolNetwork): AirGapTransaction<ICPUnits>[];
|
|
22
22
|
export declare function signStartDissolving(unsignedTransaction: string, privateKey: string, canisterId: string): Promise<string>;
|
|
23
23
|
export declare function getDetailsFromSignedStartDissolving(publicKey: string, network: ICPProtocolNetwork): AirGapTransaction<ICPUnits>[];
|
|
24
|
-
export declare function
|
|
25
|
-
export declare function
|
|
26
|
-
export declare function
|
|
27
|
-
export declare function
|
|
28
|
-
export declare function
|
|
24
|
+
export declare function prepareStopDissolving(publicKey: string): Promise<ICPTransaction[]>;
|
|
25
|
+
export declare function getDetailsFromUnsignedStopDissolving(publicKey: string, network: ICPProtocolNetwork): AirGapTransaction<ICPUnits>[];
|
|
26
|
+
export declare function signStopDissolving(unsignedTransaction: string, privateKey: string, canisterId: string): Promise<string>;
|
|
27
|
+
export declare function getDetailsFromSignedStopDissolving(publicKey: string, network: ICPProtocolNetwork): AirGapTransaction<ICPUnits>[];
|
|
28
|
+
export declare function prepareAutoStakeMaturity(publicKey: string): Promise<ICPTransaction[]>;
|
|
29
|
+
export declare function getDetailsFromUnsignedAutoStakeMaturity(publicKey: string, network: ICPProtocolNetwork): AirGapTransaction<ICPUnits>[];
|
|
30
|
+
export declare function signAutoStakeMaturity(unsignedTransaction: string, privateKey: string, canisterId: string): Promise<string>;
|
|
31
|
+
export declare function getDetailsFromSignedAutoStakeMaturity(publicKey: string, network: ICPProtocolNetwork): AirGapTransaction<ICPUnits>[];
|
|
32
|
+
export declare function prepareFollowNeuron(publicKey: string, neuronId: bigint | undefined): Promise<ICPTransaction[]>;
|
|
29
33
|
export declare function getDetailsFromUnsignedFollowNeuron(publicKey: string, network: ICPProtocolNetwork): AirGapTransaction<ICPUnits>[];
|
|
30
34
|
export declare function signFollowNeuron(unsignedTransaction: string, privateKey: string, canisterId: string): Promise<string>;
|
|
31
35
|
export declare function getDetailsFromSignedFollowNeuron(publicKey: string, network: ICPProtocolNetwork): AirGapTransaction<ICPUnits>[];
|
|
32
|
-
export declare function
|
|
33
|
-
export declare function getDetailsFromUnsignedTransactionRestakeMaturity(publicKey: string, network: ICPProtocolNetwork): AirGapTransaction<ICPUnits>[];
|
|
34
|
-
export declare function signTransactionRestakeMaturity(unsignedTransaction: string, privateKey: string, canisterId: string): Promise<string>;
|
|
35
|
-
export declare function getDetailsFromSignedTransactionRestakeMaturity(publicKey: string, network: ICPProtocolNetwork): AirGapTransaction<ICPUnits>[];
|
|
36
|
-
export declare function prepareDisburse(publicKey: string): Promise<ICPTransaction>;
|
|
36
|
+
export declare function prepareDisburse(publicKey: string): Promise<ICPTransaction[]>;
|
|
37
37
|
export declare function getDetailsFromUnsignedDisburse(publicKey: string, network: ICPProtocolNetwork): AirGapTransaction<ICPUnits>[];
|
|
38
38
|
export declare function signDisburse(unsignedTransaction: string, privateKey: string, canisterId: string): Promise<string>;
|
|
39
39
|
export declare function getDetailsFromSignedDisburse(publicKey: string, network: ICPProtocolNetwork): AirGapTransaction<ICPUnits>[];
|
|
@@ -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.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.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");
|
|
@@ -91,10 +91,12 @@ const ICPImplementation_1 = require("./ICPImplementation");
|
|
|
91
91
|
function prepareGetNeuronInfo() {
|
|
92
92
|
return __awaiter(this, void 0, void 0, function* () {
|
|
93
93
|
// Does not need to create a transaction as it is only a call to the governance token
|
|
94
|
-
return
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
94
|
+
return [
|
|
95
|
+
{
|
|
96
|
+
actionType: transaction_1.ICPActionType.GET_NEURON_INFO,
|
|
97
|
+
encoded: ''
|
|
98
|
+
}
|
|
99
|
+
];
|
|
98
100
|
});
|
|
99
101
|
}
|
|
100
102
|
exports.prepareGetNeuronInfo = prepareGetNeuronInfo;
|
|
@@ -159,10 +161,12 @@ function prepareTransferToSubaccount(publicKey, canisterId, amount, fee) {
|
|
|
159
161
|
to: accountIdentifier.toHex(),
|
|
160
162
|
fee
|
|
161
163
|
});
|
|
162
|
-
return
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
164
|
+
return [
|
|
165
|
+
{
|
|
166
|
+
actionType: transaction_1.ICPActionType.TRANSFER_TO_SUBACCOUNT,
|
|
167
|
+
encoded: unsignedTransfer
|
|
168
|
+
}
|
|
169
|
+
];
|
|
166
170
|
});
|
|
167
171
|
}
|
|
168
172
|
exports.prepareTransferToSubaccount = prepareTransferToSubaccount;
|
|
@@ -243,10 +247,12 @@ function prepareClaimOrRefreshNeuron(publicKey) {
|
|
|
243
247
|
neuron_id_or_subaccount: []
|
|
244
248
|
}
|
|
245
249
|
]);
|
|
246
|
-
return
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
+
return [
|
|
251
|
+
{
|
|
252
|
+
actionType: transaction_1.ICPActionType.CLAIM_GOVERNANCE,
|
|
253
|
+
encoded: (0, convert_1.arrayBufferToHexString)(unsignedTransactionBuffer)
|
|
254
|
+
}
|
|
255
|
+
];
|
|
250
256
|
});
|
|
251
257
|
}
|
|
252
258
|
exports.prepareClaimOrRefreshNeuron = prepareClaimOrRefreshNeuron;
|
|
@@ -290,12 +296,12 @@ function getDetailsFromTransactionClaimGovernance(publicKey, network) {
|
|
|
290
296
|
];
|
|
291
297
|
}
|
|
292
298
|
exports.getDetailsFromTransactionClaimGovernance = getDetailsFromTransactionClaimGovernance;
|
|
293
|
-
//
|
|
299
|
+
// INCREASE_DISSOLVE_DELAY
|
|
294
300
|
// CANISTER : (name: NNS Governance, identifier: rrkah-fqaaa-aaaaa-aaaaq-cai)
|
|
295
301
|
// METHOD : (name: manage_neuron, type: update)
|
|
296
302
|
// PAYLOAD : (id : [{id : float}], command : [{Configure : {operation : [{IncreaseDissolveDelay : {additional_dissolve_delay_seconds : int}}]}}], neuron_id_or_subaccount : [])
|
|
297
303
|
// RESPONSE : (command : [{configure : {}}])
|
|
298
|
-
function
|
|
304
|
+
function prepareIncreaseDissolveDelay(publicKey, additionalDissolveDelay) {
|
|
299
305
|
return __awaiter(this, void 0, void 0, function* () {
|
|
300
306
|
// Create subaccount from publicKey
|
|
301
307
|
const { subAccount, nonce: _ } = (0, ICPImplementation_1.getFixedSubaccountFromPublicKey)(publicKey);
|
|
@@ -323,22 +329,31 @@ function createUnsignedTransactionIncreaseDelay(publicKey, delaySeconds) {
|
|
|
323
329
|
// Encode
|
|
324
330
|
const unsignedTransactionBuffer = IDL.encode([ManageNeuron], [
|
|
325
331
|
{
|
|
326
|
-
|
|
332
|
+
id: [],
|
|
333
|
+
command: [
|
|
334
|
+
{
|
|
335
|
+
Configure: {
|
|
336
|
+
operation: [
|
|
337
|
+
{
|
|
338
|
+
IncreaseDissolveDelay: { additional_dissolve_delay_seconds: additionalDissolveDelay }
|
|
339
|
+
}
|
|
340
|
+
]
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
],
|
|
327
344
|
neuron_id_or_subaccount: [{ Subaccount: subAccount.toUint8Array() }]
|
|
328
345
|
}
|
|
329
346
|
]);
|
|
330
|
-
return
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
]
|
|
337
|
-
});
|
|
347
|
+
return [
|
|
348
|
+
{
|
|
349
|
+
actionType: transaction_1.ICPActionType.INCREASE_DISSOLVE_DELAY,
|
|
350
|
+
encoded: (0, convert_1.arrayBufferToHexString)(unsignedTransactionBuffer)
|
|
351
|
+
}
|
|
352
|
+
];
|
|
338
353
|
});
|
|
339
354
|
}
|
|
340
|
-
exports.
|
|
341
|
-
function
|
|
355
|
+
exports.prepareIncreaseDissolveDelay = prepareIncreaseDissolveDelay;
|
|
356
|
+
function getDetailsFromUnsignedIncreaseDissolveDelay(publicKey, network) {
|
|
342
357
|
// Does not need info from transaction because it is only a call to the governance canister
|
|
343
358
|
return [
|
|
344
359
|
{
|
|
@@ -351,8 +366,8 @@ function getDetailsFromUnsignedTransactionIncreaseDelay(publicKey, network) {
|
|
|
351
366
|
}
|
|
352
367
|
];
|
|
353
368
|
}
|
|
354
|
-
exports.
|
|
355
|
-
function
|
|
369
|
+
exports.getDetailsFromUnsignedIncreaseDissolveDelay = getDetailsFromUnsignedIncreaseDissolveDelay;
|
|
370
|
+
function signIncreaseDissolveDelay(unsignedTransaction, privateKey, canisterId) {
|
|
356
371
|
return __awaiter(this, void 0, void 0, function* () {
|
|
357
372
|
// unsignedTransaction has already the arguments needed for signing, just need to be in a Buffer
|
|
358
373
|
const args = (0, convert_1.hexStringToArrayBuffer)(unsignedTransaction);
|
|
@@ -361,8 +376,8 @@ function signTransactionIncreaseDelay(unsignedTransaction, privateKey, canisterI
|
|
|
361
376
|
return signedTransaction;
|
|
362
377
|
});
|
|
363
378
|
}
|
|
364
|
-
exports.
|
|
365
|
-
function
|
|
379
|
+
exports.signIncreaseDissolveDelay = signIncreaseDissolveDelay;
|
|
380
|
+
function getDetailsFromSignedIncreaseDissolveDelay(publicKey, network) {
|
|
366
381
|
// Does not need info from transaction because it is only a call to the governance canister
|
|
367
382
|
return [
|
|
368
383
|
{
|
|
@@ -375,7 +390,7 @@ function getDetailsFromSignedTransactionIncreaseDelay(publicKey, network) {
|
|
|
375
390
|
}
|
|
376
391
|
];
|
|
377
392
|
}
|
|
378
|
-
exports.
|
|
393
|
+
exports.getDetailsFromSignedIncreaseDissolveDelay = getDetailsFromSignedIncreaseDissolveDelay;
|
|
379
394
|
// START_DISSOLVING
|
|
380
395
|
// CANISTER : (name: NNS Governance, identifier: rrkah-fqaaa-aaaaa-aaaaq-cai)
|
|
381
396
|
// METHOD : (name: manage_neuron, type: update)
|
|
@@ -412,10 +427,12 @@ function prepareStartDissolving(publicKey) {
|
|
|
412
427
|
neuron_id_or_subaccount: [{ Subaccount: subAccount.toUint8Array() }]
|
|
413
428
|
}
|
|
414
429
|
]);
|
|
415
|
-
return
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
430
|
+
return [
|
|
431
|
+
{
|
|
432
|
+
actionType: transaction_1.ICPActionType.START_DISSOLVING,
|
|
433
|
+
encoded: (0, convert_1.arrayBufferToHexString)(unsignedTransactionBuffer)
|
|
434
|
+
}
|
|
435
|
+
];
|
|
419
436
|
});
|
|
420
437
|
}
|
|
421
438
|
exports.prepareStartDissolving = prepareStartDissolving;
|
|
@@ -464,7 +481,7 @@ exports.getDetailsFromSignedStartDissolving = getDetailsFromSignedStartDissolvin
|
|
|
464
481
|
// METHOD : (name: manage_neuron, type: update)
|
|
465
482
|
// PAYLOAD : (id : [{id : float}], command : [{Configure : {operation : [{StopDissolving : {}}]}}], neuron_id_or_subaccount : [])
|
|
466
483
|
// RESPONSE : (command : [{configure : {}}])
|
|
467
|
-
function
|
|
484
|
+
function prepareStopDissolving(publicKey) {
|
|
468
485
|
return __awaiter(this, void 0, void 0, function* () {
|
|
469
486
|
// Create subaccount from publicKey
|
|
470
487
|
const { subAccount, nonce: _ } = (0, ICPImplementation_1.getFixedSubaccountFromPublicKey)(publicKey);
|
|
@@ -490,22 +507,21 @@ function createUnsignedTransactionStopDissolving(publicKey) {
|
|
|
490
507
|
// Encode
|
|
491
508
|
const unsignedTransactionBuffer = IDL.encode([ManageNeuron], [
|
|
492
509
|
{
|
|
510
|
+
id: [],
|
|
493
511
|
command: [{ Configure: { operation: [{ StopDissolving: {} }] } }],
|
|
494
512
|
neuron_id_or_subaccount: [{ Subaccount: subAccount.toUint8Array() }]
|
|
495
513
|
}
|
|
496
514
|
]);
|
|
497
|
-
return
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
]
|
|
504
|
-
});
|
|
515
|
+
return [
|
|
516
|
+
{
|
|
517
|
+
actionType: transaction_1.ICPActionType.STOP_DISSOLVING,
|
|
518
|
+
encoded: (0, convert_1.arrayBufferToHexString)(unsignedTransactionBuffer)
|
|
519
|
+
}
|
|
520
|
+
];
|
|
505
521
|
});
|
|
506
522
|
}
|
|
507
|
-
exports.
|
|
508
|
-
function
|
|
523
|
+
exports.prepareStopDissolving = prepareStopDissolving;
|
|
524
|
+
function getDetailsFromUnsignedStopDissolving(publicKey, network) {
|
|
509
525
|
// Does not need info from transaction because it is only a call to the governance canister
|
|
510
526
|
return [
|
|
511
527
|
{
|
|
@@ -514,12 +530,13 @@ function getDetailsFromUnsignedTransactionStopDissolving(publicKey, network) {
|
|
|
514
530
|
isInbound: false,
|
|
515
531
|
amount: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
516
532
|
fee: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
517
|
-
network
|
|
533
|
+
network,
|
|
534
|
+
type: transaction_1.ICPActionType.STOP_DISSOLVING
|
|
518
535
|
}
|
|
519
536
|
];
|
|
520
537
|
}
|
|
521
|
-
exports.
|
|
522
|
-
function
|
|
538
|
+
exports.getDetailsFromUnsignedStopDissolving = getDetailsFromUnsignedStopDissolving;
|
|
539
|
+
function signStopDissolving(unsignedTransaction, privateKey, canisterId) {
|
|
523
540
|
return __awaiter(this, void 0, void 0, function* () {
|
|
524
541
|
// unsignedTransaction has already the arguments needed for signing, just need to be in a Buffer
|
|
525
542
|
const args = (0, convert_1.hexStringToArrayBuffer)(unsignedTransaction);
|
|
@@ -528,8 +545,8 @@ function signTransactionStopDissolving(unsignedTransaction, privateKey, canister
|
|
|
528
545
|
return signedTransaction;
|
|
529
546
|
});
|
|
530
547
|
}
|
|
531
|
-
exports.
|
|
532
|
-
function
|
|
548
|
+
exports.signStopDissolving = signStopDissolving;
|
|
549
|
+
function getDetailsFromSignedStopDissolving(publicKey, network) {
|
|
533
550
|
// Does not need info from transaction because it is only a call to the governance canister
|
|
534
551
|
return [
|
|
535
552
|
{
|
|
@@ -538,28 +555,28 @@ function getDetailsFromSignedTransactionStopDissolving(publicKey, network) {
|
|
|
538
555
|
isInbound: false,
|
|
539
556
|
amount: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
540
557
|
fee: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
541
|
-
network
|
|
558
|
+
network,
|
|
559
|
+
type: transaction_1.ICPActionType.STOP_DISSOLVING
|
|
542
560
|
}
|
|
543
561
|
];
|
|
544
562
|
}
|
|
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) {
|
|
563
|
+
exports.getDetailsFromSignedStopDissolving = getDetailsFromSignedStopDissolving;
|
|
564
|
+
// AUTO_STAKE_MATURITY
|
|
565
|
+
function prepareAutoStakeMaturity(publicKey) {
|
|
552
566
|
return __awaiter(this, void 0, void 0, function* () {
|
|
553
567
|
// Create subaccount from publicKey
|
|
554
568
|
const { subAccount, nonce: _ } = (0, ICPImplementation_1.getFixedSubaccountFromPublicKey)(publicKey);
|
|
555
|
-
// IDL for
|
|
569
|
+
// IDL for StartDissolving
|
|
556
570
|
const NeuronId = IDL.Record({ id: IDL.Nat64 });
|
|
557
|
-
const
|
|
558
|
-
|
|
559
|
-
followees: IDL.Vec(NeuronId)
|
|
571
|
+
const ChangeAutoStakeMaturity = IDL.Record({
|
|
572
|
+
requested_setting_for_auto_stake_maturity: IDL.Bool
|
|
560
573
|
});
|
|
574
|
+
const Operation = IDL.Variant({
|
|
575
|
+
ChangeAutoStakeMaturity: ChangeAutoStakeMaturity
|
|
576
|
+
});
|
|
577
|
+
const Configure = IDL.Record({ operation: IDL.Opt(Operation) });
|
|
561
578
|
const Command = IDL.Variant({
|
|
562
|
-
|
|
579
|
+
Configure: Configure
|
|
563
580
|
});
|
|
564
581
|
const NeuronIdOrSubaccount = IDL.Variant({
|
|
565
582
|
Subaccount: IDL.Vec(IDL.Nat8),
|
|
@@ -570,23 +587,36 @@ function prepareFollowNeuron(publicKey, neuronId) {
|
|
|
570
587
|
command: IDL.Opt(Command),
|
|
571
588
|
neuron_id_or_subaccount: IDL.Opt(NeuronIdOrSubaccount)
|
|
572
589
|
});
|
|
573
|
-
// TODO : get the topic that corresponds to all topics
|
|
574
|
-
const topic = 0;
|
|
575
590
|
// Encode
|
|
576
591
|
const unsignedTransactionBuffer = IDL.encode([ManageNeuron], [
|
|
577
592
|
{
|
|
578
|
-
|
|
593
|
+
id: [],
|
|
594
|
+
command: [
|
|
595
|
+
{
|
|
596
|
+
Configure: {
|
|
597
|
+
operation: [
|
|
598
|
+
{
|
|
599
|
+
ChangeAutoStakeMaturity: {
|
|
600
|
+
requested_setting_for_auto_stake_maturity: true
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
]
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
],
|
|
579
607
|
neuron_id_or_subaccount: [{ Subaccount: subAccount.toUint8Array() }]
|
|
580
608
|
}
|
|
581
609
|
]);
|
|
582
|
-
return
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
610
|
+
return [
|
|
611
|
+
{
|
|
612
|
+
actionType: transaction_1.ICPActionType.AUTO_STAKE_MATURITY,
|
|
613
|
+
encoded: (0, convert_1.arrayBufferToHexString)(unsignedTransactionBuffer)
|
|
614
|
+
}
|
|
615
|
+
];
|
|
586
616
|
});
|
|
587
617
|
}
|
|
588
|
-
exports.
|
|
589
|
-
function
|
|
618
|
+
exports.prepareAutoStakeMaturity = prepareAutoStakeMaturity;
|
|
619
|
+
function getDetailsFromUnsignedAutoStakeMaturity(publicKey, network) {
|
|
590
620
|
// Does not need info from transaction because it is only a call to the governance canister
|
|
591
621
|
return [
|
|
592
622
|
{
|
|
@@ -595,12 +625,13 @@ function getDetailsFromUnsignedFollowNeuron(publicKey, network) {
|
|
|
595
625
|
isInbound: false,
|
|
596
626
|
amount: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
597
627
|
fee: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
598
|
-
network
|
|
628
|
+
network,
|
|
629
|
+
type: transaction_1.ICPActionType.AUTO_STAKE_MATURITY
|
|
599
630
|
}
|
|
600
631
|
];
|
|
601
632
|
}
|
|
602
|
-
exports.
|
|
603
|
-
function
|
|
633
|
+
exports.getDetailsFromUnsignedAutoStakeMaturity = getDetailsFromUnsignedAutoStakeMaturity;
|
|
634
|
+
function signAutoStakeMaturity(unsignedTransaction, privateKey, canisterId) {
|
|
604
635
|
return __awaiter(this, void 0, void 0, function* () {
|
|
605
636
|
// unsignedTransaction has already the arguments needed for signing, just need to be in a Buffer
|
|
606
637
|
const args = (0, convert_1.hexStringToArrayBuffer)(unsignedTransaction);
|
|
@@ -609,8 +640,8 @@ function signFollowNeuron(unsignedTransaction, privateKey, canisterId) {
|
|
|
609
640
|
return signedTransaction;
|
|
610
641
|
});
|
|
611
642
|
}
|
|
612
|
-
exports.
|
|
613
|
-
function
|
|
643
|
+
exports.signAutoStakeMaturity = signAutoStakeMaturity;
|
|
644
|
+
function getDetailsFromSignedAutoStakeMaturity(publicKey, network) {
|
|
614
645
|
// Does not need info from transaction because it is only a call to the governance canister
|
|
615
646
|
return [
|
|
616
647
|
{
|
|
@@ -619,27 +650,29 @@ function getDetailsFromSignedFollowNeuron(publicKey, network) {
|
|
|
619
650
|
isInbound: false,
|
|
620
651
|
amount: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
621
652
|
fee: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
622
|
-
network
|
|
653
|
+
network,
|
|
654
|
+
type: transaction_1.ICPActionType.AUTO_STAKE_MATURITY
|
|
623
655
|
}
|
|
624
656
|
];
|
|
625
657
|
}
|
|
626
|
-
exports.
|
|
627
|
-
//
|
|
658
|
+
exports.getDetailsFromSignedAutoStakeMaturity = getDetailsFromSignedAutoStakeMaturity;
|
|
659
|
+
// FOLLOW_NEURON
|
|
628
660
|
// CANISTER : (name: NNS Governance, identifier: rrkah-fqaaa-aaaaa-aaaaq-cai)
|
|
629
661
|
// METHOD : (name: manage_neuron, type: update)
|
|
630
|
-
// PAYLOAD : (id : [{id : float}], command : [{
|
|
631
|
-
// RESPONSE : (command : [{
|
|
632
|
-
function
|
|
662
|
+
// PAYLOAD : (id : [{id : float}], command : [{Follow : {topic : int, followees : [{id: int}]}}], neuron_id_or_subaccount : [])
|
|
663
|
+
// RESPONSE : (command : [{Follow : {}}])
|
|
664
|
+
function prepareFollowNeuron(publicKey, neuronId) {
|
|
633
665
|
return __awaiter(this, void 0, void 0, function* () {
|
|
634
666
|
// Create subaccount from publicKey
|
|
635
667
|
const { subAccount, nonce: _ } = (0, ICPImplementation_1.getFixedSubaccountFromPublicKey)(publicKey);
|
|
636
|
-
// IDL for
|
|
668
|
+
// IDL for FollowNeuron
|
|
637
669
|
const NeuronId = IDL.Record({ id: IDL.Nat64 });
|
|
638
|
-
const
|
|
639
|
-
|
|
670
|
+
const Follow = IDL.Record({
|
|
671
|
+
topic: IDL.Int32,
|
|
672
|
+
followees: IDL.Vec(NeuronId)
|
|
640
673
|
});
|
|
641
674
|
const Command = IDL.Variant({
|
|
642
|
-
|
|
675
|
+
Follow: Follow
|
|
643
676
|
});
|
|
644
677
|
const NeuronIdOrSubaccount = IDL.Variant({
|
|
645
678
|
Subaccount: IDL.Vec(IDL.Nat8),
|
|
@@ -650,25 +683,25 @@ function createUnsignedTransactionRestakeMaturity(publicKey, percentageStake) {
|
|
|
650
683
|
command: IDL.Opt(Command),
|
|
651
684
|
neuron_id_or_subaccount: IDL.Opt(NeuronIdOrSubaccount)
|
|
652
685
|
});
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
neuron_id_or_subaccount: [{ Subaccount: subAccount.toUint8Array() }]
|
|
658
|
-
}
|
|
659
|
-
]);
|
|
660
|
-
return (0, module_kit_1.newUnsignedTransaction)({
|
|
661
|
-
transactions: [
|
|
686
|
+
const topics = [0 /* All Except Governance, and SNS & Community Fund */, 4 /* Governance */, 14 /* SNS & Community Fund */];
|
|
687
|
+
return topics.map((topic) => {
|
|
688
|
+
// Encode
|
|
689
|
+
const unsignedTransactionBuffer = IDL.encode([ManageNeuron], [
|
|
662
690
|
{
|
|
663
|
-
|
|
664
|
-
|
|
691
|
+
id: [],
|
|
692
|
+
command: [{ Follow: { topic: topic, followees: neuronId !== undefined ? [{ id: neuronId }] : [] } }],
|
|
693
|
+
neuron_id_or_subaccount: [{ Subaccount: subAccount.toUint8Array() }]
|
|
665
694
|
}
|
|
666
|
-
]
|
|
695
|
+
]);
|
|
696
|
+
return {
|
|
697
|
+
actionType: transaction_1.ICPActionType.FOLLOW_NEURON,
|
|
698
|
+
encoded: (0, convert_1.arrayBufferToHexString)(unsignedTransactionBuffer)
|
|
699
|
+
};
|
|
667
700
|
});
|
|
668
701
|
});
|
|
669
702
|
}
|
|
670
|
-
exports.
|
|
671
|
-
function
|
|
703
|
+
exports.prepareFollowNeuron = prepareFollowNeuron;
|
|
704
|
+
function getDetailsFromUnsignedFollowNeuron(publicKey, network) {
|
|
672
705
|
// Does not need info from transaction because it is only a call to the governance canister
|
|
673
706
|
return [
|
|
674
707
|
{
|
|
@@ -677,12 +710,13 @@ function getDetailsFromUnsignedTransactionRestakeMaturity(publicKey, network) {
|
|
|
677
710
|
isInbound: false,
|
|
678
711
|
amount: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
679
712
|
fee: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
680
|
-
network
|
|
713
|
+
network,
|
|
714
|
+
type: transaction_1.ICPActionType.FOLLOW_NEURON
|
|
681
715
|
}
|
|
682
716
|
];
|
|
683
717
|
}
|
|
684
|
-
exports.
|
|
685
|
-
function
|
|
718
|
+
exports.getDetailsFromUnsignedFollowNeuron = getDetailsFromUnsignedFollowNeuron;
|
|
719
|
+
function signFollowNeuron(unsignedTransaction, privateKey, canisterId) {
|
|
686
720
|
return __awaiter(this, void 0, void 0, function* () {
|
|
687
721
|
// unsignedTransaction has already the arguments needed for signing, just need to be in a Buffer
|
|
688
722
|
const args = (0, convert_1.hexStringToArrayBuffer)(unsignedTransaction);
|
|
@@ -691,8 +725,8 @@ function signTransactionRestakeMaturity(unsignedTransaction, privateKey, caniste
|
|
|
691
725
|
return signedTransaction;
|
|
692
726
|
});
|
|
693
727
|
}
|
|
694
|
-
exports.
|
|
695
|
-
function
|
|
728
|
+
exports.signFollowNeuron = signFollowNeuron;
|
|
729
|
+
function getDetailsFromSignedFollowNeuron(publicKey, network) {
|
|
696
730
|
// Does not need info from transaction because it is only a call to the governance canister
|
|
697
731
|
return [
|
|
698
732
|
{
|
|
@@ -701,11 +735,12 @@ function getDetailsFromSignedTransactionRestakeMaturity(publicKey, network) {
|
|
|
701
735
|
isInbound: false,
|
|
702
736
|
amount: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
703
737
|
fee: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
704
|
-
network
|
|
738
|
+
network,
|
|
739
|
+
type: transaction_1.ICPActionType.FOLLOW_NEURON
|
|
705
740
|
}
|
|
706
741
|
];
|
|
707
742
|
}
|
|
708
|
-
exports.
|
|
743
|
+
exports.getDetailsFromSignedFollowNeuron = getDetailsFromSignedFollowNeuron;
|
|
709
744
|
// DISBURSE
|
|
710
745
|
// Cannot extrapolate method from call since we have to wait 6 months to do so
|
|
711
746
|
function prepareDisburse(publicKey) {
|
|
@@ -747,10 +782,12 @@ function prepareDisburse(publicKey) {
|
|
|
747
782
|
neuron_id_or_subaccount: [{ Subaccount: subAccount.toUint8Array() }]
|
|
748
783
|
}
|
|
749
784
|
]);
|
|
750
|
-
return
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
785
|
+
return [
|
|
786
|
+
{
|
|
787
|
+
actionType: transaction_1.ICPActionType.DISBURSE,
|
|
788
|
+
encoded: (0, convert_1.arrayBufferToHexString)(unsignedTransactionBuffer)
|
|
789
|
+
}
|
|
790
|
+
];
|
|
754
791
|
});
|
|
755
792
|
}
|
|
756
793
|
exports.prepareDisburse = prepareDisburse;
|