@airgap/icp 0.13.15-beta.0 → 0.13.15-beta.2
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 +8 -6
- package/v1/block-explorer/ICPBlockExplorer.js +16 -51
- package/v1/block-explorer/ICPBlockExplorer.js.map +1 -1
- package/v1/index.d.ts +2 -2
- package/v1/index.js +7 -5
- package/v1/index.js.map +1 -1
- package/v1/module/ICPModule.js +53 -94
- package/v1/module/ICPModule.js.map +1 -1
- package/v1/module.js +1 -1
- package/v1/module.js.map +1 -1
- package/v1/protocol/ICPGovernance.d.ts +38 -0
- package/v1/protocol/ICPGovernance.js +748 -0
- package/v1/protocol/ICPGovernance.js.map +1 -0
- package/v1/protocol/ICPImplementation.d.ts +27 -5
- package/v1/protocol/ICPImplementation.js +368 -250
- package/v1/protocol/ICPImplementation.js.map +1 -1
- package/v1/protocol/ICPProtocol.d.ts +29 -4
- package/v1/protocol/ICPProtocol.js +507 -320
- package/v1/protocol/ICPProtocol.js.map +1 -1
- package/v1/protocol/icrc/CkBTCProtocol.js +137 -223
- package/v1/protocol/icrc/CkBTCProtocol.js.map +1 -1
- package/v1/protocol/icrc/ICRC1Protocol.js +338 -553
- package/v1/protocol/icrc/ICRC1Protocol.js.map +1 -1
- package/v1/serializer/v3/schemas/converter/transaction-converter.js +17 -4
- package/v1/serializer/v3/schemas/converter/transaction-converter.js.map +1 -1
- package/v1/serializer/v3/schemas/generated/transaction-sign-request-icp.json +35 -6
- package/v1/serializer/v3/serializer-companion.js +86 -144
- package/v1/serializer/v3/serializer-companion.js.map +1 -1
- package/v1/serializer/v3/validators/transaction-validator.js +22 -60
- package/v1/serializer/v3/validators/transaction-validator.js.map +1 -1
- package/v1/serializer/v3/validators/validators.js +19 -58
- package/v1/serializer/v3/validators/validators.js.map +1 -1
- package/v1/types/governance.d.ts +2 -0
- package/v1/types/governance.js +268 -210
- package/v1/types/governance.js.map +1 -1
- package/v1/types/icrc/ledger.js +22 -23
- package/v1/types/icrc/ledger.js.map +1 -1
- package/v1/types/ledger.d.ts +1 -0
- package/v1/types/ledger.js +37 -38
- package/v1/types/ledger.js.map +1 -1
- package/v1/types/management_idl.js +6 -7
- package/v1/types/management_idl.js.map +1 -1
- package/v1/types/protocol.d.ts +1 -0
- package/v1/types/transaction.d.ts +21 -3
- package/v1/types/transaction.js +28 -0
- package/v1/types/transaction.js.map +1 -1
- package/v1/utils/account.js +42 -70
- package/v1/utils/account.js.map +1 -1
- package/v1/utils/actor.js +139 -322
- package/v1/utils/actor.js.map +1 -1
- package/v1/utils/auth.js +44 -134
- package/v1/utils/auth.js.map +1 -1
- package/v1/utils/bls.js +41 -109
- package/v1/utils/bls.js.map +1 -1
- package/v1/utils/buffer.js +47 -111
- package/v1/utils/buffer.js.map +1 -1
- package/v1/utils/cbor.js +50 -85
- package/v1/utils/cbor.js.map +1 -1
- package/v1/utils/certificate.js +116 -238
- package/v1/utils/certificate.js.map +1 -1
- package/v1/utils/convert.d.ts +1 -1
- package/v1/utils/convert.js +29 -49
- package/v1/utils/convert.js.map +1 -1
- package/v1/utils/der.js +37 -35
- package/v1/utils/der.js.map +1 -1
- package/v1/utils/errors.js +10 -30
- package/v1/utils/errors.js.map +1 -1
- package/v1/utils/hdkey.js +33 -33
- package/v1/utils/hdkey.js.map +1 -1
- package/v1/utils/http.d.ts +1 -1
- package/v1/utils/http.js +202 -426
- package/v1/utils/http.js.map +1 -1
- package/v1/utils/icrc1.js +24 -41
- package/v1/utils/icrc1.js.map +1 -1
- package/v1/utils/idl.js +780 -1159
- package/v1/utils/idl.js.map +1 -1
- package/v1/utils/leb128.js +29 -30
- package/v1/utils/leb128.js.map +1 -1
- package/v1/utils/polling.js +84 -234
- package/v1/utils/polling.js.map +1 -1
- package/v1/utils/principal.js +78 -126
- package/v1/utils/principal.js.map +1 -1
- package/v1/utils/secp256k1.js +68 -134
- package/v1/utils/secp256k1.js.map +1 -1
- package/v1/utils/transaction.js +7 -7
- package/v1/utils/transaction.js.map +1 -1
|
@@ -0,0 +1,748 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
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;
|
|
36
|
+
const module_kit_1 = require("@airgap/module-kit");
|
|
37
|
+
const transaction_1 = require("../types/transaction");
|
|
38
|
+
const account_1 = require("../utils/account");
|
|
39
|
+
const convert_1 = require("../utils/convert");
|
|
40
|
+
const IDL = __importStar(require("../utils/idl"));
|
|
41
|
+
const principal_1 = require("../utils/principal");
|
|
42
|
+
const ICPImplementation_1 = require("./ICPImplementation");
|
|
43
|
+
// GET_NEURON_INFO
|
|
44
|
+
// CANISTER : (name: NNS Governance, identifier: rrkah-fqaaa-aaaaa-aaaaq-cai)
|
|
45
|
+
// METHOD : (name: list_neurons, type: query)
|
|
46
|
+
// PAYLOAD : (neuron_ids : {}, include_neurons_readable_by_caller : true)
|
|
47
|
+
// RESPONSE :
|
|
48
|
+
// root : {
|
|
49
|
+
// neuron_infos : [
|
|
50
|
+
// [
|
|
51
|
+
// neuronId : float,
|
|
52
|
+
// {
|
|
53
|
+
// dissolve_delay_seconds: int,
|
|
54
|
+
// recent_ballots: [],
|
|
55
|
+
// created_timestamp_seconds: int,
|
|
56
|
+
// state: int,
|
|
57
|
+
// stake_e8s: int,
|
|
58
|
+
// joined_community_fund_timestamp_seconds: [],
|
|
59
|
+
// retrieved_at_timestamp_seconds: int,
|
|
60
|
+
// known_neuron_data:[],
|
|
61
|
+
// voting_power: int,
|
|
62
|
+
// age_seconds: int
|
|
63
|
+
// }
|
|
64
|
+
// ]
|
|
65
|
+
// ],
|
|
66
|
+
// full_neurons : [
|
|
67
|
+
// {
|
|
68
|
+
// id: [],
|
|
69
|
+
// staked_maturity_e8s_equivalent: [],
|
|
70
|
+
// controller: [],
|
|
71
|
+
// recent_ballots: [],
|
|
72
|
+
// kyc_verified: bool,
|
|
73
|
+
// not_for_profit: bool,
|
|
74
|
+
// maturity_e8s_equivalent: int,
|
|
75
|
+
// cached_neuron_stake_e8s: int,
|
|
76
|
+
// created_timestamp_seconds: int,
|
|
77
|
+
// auto_stake_maturity: [],
|
|
78
|
+
// aging_since_timestamp_seconds: float,
|
|
79
|
+
// hot_keys: [],
|
|
80
|
+
// account: {},
|
|
81
|
+
// joined_community_fund_timestamp_seconds: [],
|
|
82
|
+
// dissolve_state: [],
|
|
83
|
+
// followees: [],
|
|
84
|
+
// neuron_fees_e8s: int,
|
|
85
|
+
// transfer: [],
|
|
86
|
+
// known_neuron_data: [],
|
|
87
|
+
// spawn_at_timestamp_seconds: []
|
|
88
|
+
// }
|
|
89
|
+
// ]
|
|
90
|
+
// }
|
|
91
|
+
function createUnsignedTransactionGetNeuronInfo() {
|
|
92
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
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
|
+
});
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
exports.createUnsignedTransactionGetNeuronInfo = createUnsignedTransactionGetNeuronInfo;
|
|
105
|
+
function getDetailsFromUnsignedTransactionGetNeuronInfo(publicKey, network) {
|
|
106
|
+
// Does not need info from transaction because it is only a call to the governance canister
|
|
107
|
+
return [
|
|
108
|
+
{
|
|
109
|
+
from: [(0, ICPImplementation_1.getAddressFromPublicKey)(publicKey)],
|
|
110
|
+
to: [network.governanceCanisterId],
|
|
111
|
+
isInbound: false,
|
|
112
|
+
amount: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
113
|
+
fee: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
114
|
+
network
|
|
115
|
+
}
|
|
116
|
+
];
|
|
117
|
+
}
|
|
118
|
+
exports.getDetailsFromUnsignedTransactionGetNeuronInfo = getDetailsFromUnsignedTransactionGetNeuronInfo;
|
|
119
|
+
function signTransactionGetNeuronInfo(unsignedTransaction, privateKey, canisterId) {
|
|
120
|
+
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
|
|
124
|
+
});
|
|
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');
|
|
127
|
+
return signedTransaction;
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
exports.signTransactionGetNeuronInfo = signTransactionGetNeuronInfo;
|
|
131
|
+
function getDetailsFromSignedTransactionGetNeuronInfo(publicKey, network) {
|
|
132
|
+
// Does not need info from transaction because it is only a call to the governance canister
|
|
133
|
+
return [
|
|
134
|
+
{
|
|
135
|
+
from: [(0, ICPImplementation_1.getAddressFromPublicKey)(publicKey)],
|
|
136
|
+
to: [network.governanceCanisterId],
|
|
137
|
+
isInbound: false,
|
|
138
|
+
amount: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
139
|
+
fee: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
140
|
+
network
|
|
141
|
+
}
|
|
142
|
+
];
|
|
143
|
+
}
|
|
144
|
+
exports.getDetailsFromSignedTransactionGetNeuronInfo = getDetailsFromSignedTransactionGetNeuronInfo;
|
|
145
|
+
// TRANSFER_TO_SUBACCOUNT
|
|
146
|
+
// CANISTER : (name: NNS Ledger, identifier: ryjl3-tyaaa-aaaaa-aaaba-cai)
|
|
147
|
+
// METHOD : (name: transfer, type: update)
|
|
148
|
+
// PAYLOAD : (to : {}, fee : {e8s: int}, memo: int, from_subaccount: [], created_at_time: [{timestamp_nanos : float}], amount: {e8s: int})
|
|
149
|
+
// RESPONSE : (Ok : int)
|
|
150
|
+
function createUnsignedTransactionTransferToSubaccount(publicKey, canisterId, amount, fee) {
|
|
151
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
152
|
+
// Create subaccount from publicKey
|
|
153
|
+
const { subAccount, nonce } = (0, ICPImplementation_1.getFixedSubaccountFromPublicKey)(publicKey);
|
|
154
|
+
const accountIdentifier = account_1.AccountIdentifier.fromPrincipal({
|
|
155
|
+
principal: principal_1.Principal.from(canisterId),
|
|
156
|
+
subAccount: subAccount
|
|
157
|
+
});
|
|
158
|
+
const unsignedTransfer = (0, ICPImplementation_1.createUnsignedTransaction)({
|
|
159
|
+
memo: nonce,
|
|
160
|
+
amount: amount,
|
|
161
|
+
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
|
+
]
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
exports.createUnsignedTransactionTransferToSubaccount = createUnsignedTransactionTransferToSubaccount;
|
|
175
|
+
function getDetailsFromUnsignedTransactionTransferToSubaccount(unsignedTransaction, publicKey, network) {
|
|
176
|
+
const info = (0, ICPImplementation_1.getInfoFromUnsignedTransaction)(unsignedTransaction);
|
|
177
|
+
return [
|
|
178
|
+
{
|
|
179
|
+
from: [(0, ICPImplementation_1.getAddressFromPublicKey)(publicKey)],
|
|
180
|
+
to: [info.to],
|
|
181
|
+
isInbound: false,
|
|
182
|
+
amount: (0, module_kit_1.newAmount)(info.amount.toString(), 'blockchain'),
|
|
183
|
+
fee: (0, module_kit_1.newAmount)(info.fee.toString(), 'blockchain'),
|
|
184
|
+
network
|
|
185
|
+
}
|
|
186
|
+
];
|
|
187
|
+
}
|
|
188
|
+
exports.getDetailsFromUnsignedTransactionTransferToSubaccount = getDetailsFromUnsignedTransactionTransferToSubaccount;
|
|
189
|
+
function signTransactionTransferToSubaccount(unsignedTransaction, privateKey, canisterId) {
|
|
190
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
191
|
+
return (0, ICPImplementation_1.signTransactionTransfer)(unsignedTransaction, privateKey, canisterId);
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
exports.signTransactionTransferToSubaccount = signTransactionTransferToSubaccount;
|
|
195
|
+
function getDetailsFromSignedTransactionTransferToSubaccount(signedTransaction, publicKey, network) {
|
|
196
|
+
return (0, ICPImplementation_1.getDetailsFromSignedTransactionTransfer)(signedTransaction, publicKey, network);
|
|
197
|
+
}
|
|
198
|
+
exports.getDetailsFromSignedTransactionTransferToSubaccount = getDetailsFromSignedTransactionTransferToSubaccount;
|
|
199
|
+
// CLAIM_GOVERNANCE ?
|
|
200
|
+
// CANISTER : (name: NNS Governance, identifier: rrkah-fqaaa-aaaaa-aaaaq-cai)
|
|
201
|
+
// METHOD : (name: claim_or_refresh_neuron_from_account, type: call)
|
|
202
|
+
function createUnsignedTransactionClaimGovernance(publicKey) {
|
|
203
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
204
|
+
// Create subaccount from publicKey
|
|
205
|
+
const { subAccount: _, nonce } = (0, ICPImplementation_1.getFixedSubaccountFromPublicKey)(publicKey);
|
|
206
|
+
// Get Principal from public key
|
|
207
|
+
const principal = (0, ICPImplementation_1.getPrincipalFromPublicKey)(publicKey);
|
|
208
|
+
// IDL for ClaimOrRefresh
|
|
209
|
+
const ClaimOrRefreshNeuronFromAccount = IDL.Record({
|
|
210
|
+
controller: IDL.Opt(IDL.Principal),
|
|
211
|
+
memo: IDL.Nat64
|
|
212
|
+
});
|
|
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
|
+
]
|
|
222
|
+
});
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
exports.createUnsignedTransactionClaimGovernance = createUnsignedTransactionClaimGovernance;
|
|
226
|
+
function getDetailsFromUnsignedTransactionClaimGovernance(publicKey, network) {
|
|
227
|
+
// Does not need info from transaction because it is only a call to the governance canister
|
|
228
|
+
return [
|
|
229
|
+
{
|
|
230
|
+
from: [(0, ICPImplementation_1.getAddressFromPublicKey)(publicKey)],
|
|
231
|
+
to: [network.governanceCanisterId],
|
|
232
|
+
isInbound: false,
|
|
233
|
+
amount: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
234
|
+
fee: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
235
|
+
network
|
|
236
|
+
}
|
|
237
|
+
];
|
|
238
|
+
}
|
|
239
|
+
exports.getDetailsFromUnsignedTransactionClaimGovernance = getDetailsFromUnsignedTransactionClaimGovernance;
|
|
240
|
+
function signTransactionClaimGovernance(unsignedTransaction, privateKey, canisterId) {
|
|
241
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
242
|
+
// unsignedTransaction has already the arguments needed for signing, just need to be in a Buffer
|
|
243
|
+
const args = (0, convert_1.hexStringToArrayBuffer)(unsignedTransaction);
|
|
244
|
+
// Sign transaction
|
|
245
|
+
const signedTransaction = (0, ICPImplementation_1.signTransaction)(privateKey, canisterId, args, 'claim_or_refresh_neuron_from_account', 'call');
|
|
246
|
+
return signedTransaction;
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
exports.signTransactionClaimGovernance = signTransactionClaimGovernance;
|
|
250
|
+
function getDetailsFromSignedTransactionClaimGovernance(publicKey, network) {
|
|
251
|
+
// Does not need info from transaction because it is only a call to the governance canister
|
|
252
|
+
return [
|
|
253
|
+
{
|
|
254
|
+
from: [(0, ICPImplementation_1.getAddressFromPublicKey)(publicKey)],
|
|
255
|
+
to: [network.governanceCanisterId],
|
|
256
|
+
isInbound: false,
|
|
257
|
+
amount: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
258
|
+
fee: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
259
|
+
network
|
|
260
|
+
}
|
|
261
|
+
];
|
|
262
|
+
}
|
|
263
|
+
exports.getDetailsFromSignedTransactionClaimGovernance = getDetailsFromSignedTransactionClaimGovernance;
|
|
264
|
+
// INCREASE_DELAY
|
|
265
|
+
// CANISTER : (name: NNS Governance, identifier: rrkah-fqaaa-aaaaa-aaaaq-cai)
|
|
266
|
+
// METHOD : (name: manage_neuron, type: update)
|
|
267
|
+
// PAYLOAD : (id : [{id : float}], command : [{Configure : {operation : [{IncreaseDissolveDelay : {additional_dissolve_delay_seconds : int}}]}}], neuron_id_or_subaccount : [])
|
|
268
|
+
// RESPONSE : (command : [{configure : {}}])
|
|
269
|
+
function createUnsignedTransactionIncreaseDelay(publicKey, delaySeconds) {
|
|
270
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
271
|
+
// Create subaccount from publicKey
|
|
272
|
+
const { subAccount, nonce: _ } = (0, ICPImplementation_1.getFixedSubaccountFromPublicKey)(publicKey);
|
|
273
|
+
// IDL for IncreaseDissolveDelay
|
|
274
|
+
const NeuronId = IDL.Record({ id: IDL.Nat64 });
|
|
275
|
+
const IncreaseDissolveDelay = IDL.Record({
|
|
276
|
+
additional_dissolve_delay_seconds: IDL.Nat32
|
|
277
|
+
});
|
|
278
|
+
const Operation = IDL.Variant({
|
|
279
|
+
IncreaseDissolveDelay: IncreaseDissolveDelay
|
|
280
|
+
});
|
|
281
|
+
const Configure = IDL.Record({ operation: IDL.Opt(Operation) });
|
|
282
|
+
const Command = IDL.Variant({
|
|
283
|
+
Configure: Configure
|
|
284
|
+
});
|
|
285
|
+
const NeuronIdOrSubaccount = IDL.Variant({
|
|
286
|
+
Subaccount: IDL.Vec(IDL.Nat8),
|
|
287
|
+
NeuronId: NeuronId
|
|
288
|
+
});
|
|
289
|
+
const ManageNeuron = IDL.Record({
|
|
290
|
+
id: IDL.Opt(NeuronId),
|
|
291
|
+
command: IDL.Opt(Command),
|
|
292
|
+
neuron_id_or_subaccount: IDL.Opt(NeuronIdOrSubaccount)
|
|
293
|
+
});
|
|
294
|
+
// Encode
|
|
295
|
+
const unsignedTransactionBuffer = IDL.encode([ManageNeuron], [
|
|
296
|
+
{
|
|
297
|
+
command: [{ Configure: { operation: [{ IncreaseDissolveDelay: { additional_dissolve_delay_seconds: delaySeconds } }] } }],
|
|
298
|
+
neuron_id_or_subaccount: [{ Subaccount: subAccount }]
|
|
299
|
+
}
|
|
300
|
+
]);
|
|
301
|
+
return (0, module_kit_1.newUnsignedTransaction)({
|
|
302
|
+
transactions: [
|
|
303
|
+
{
|
|
304
|
+
actionType: transaction_1.ICPActionType.INCREASE_DELAY,
|
|
305
|
+
encoded: (0, convert_1.arrayBufferToHexString)(unsignedTransactionBuffer)
|
|
306
|
+
}
|
|
307
|
+
]
|
|
308
|
+
});
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
exports.createUnsignedTransactionIncreaseDelay = createUnsignedTransactionIncreaseDelay;
|
|
312
|
+
function getDetailsFromUnsignedTransactionIncreaseDelay(publicKey, network) {
|
|
313
|
+
// Does not need info from transaction because it is only a call to the governance canister
|
|
314
|
+
return [
|
|
315
|
+
{
|
|
316
|
+
from: [(0, ICPImplementation_1.getAddressFromPublicKey)(publicKey)],
|
|
317
|
+
to: [network.governanceCanisterId],
|
|
318
|
+
isInbound: false,
|
|
319
|
+
amount: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
320
|
+
fee: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
321
|
+
network: network
|
|
322
|
+
}
|
|
323
|
+
];
|
|
324
|
+
}
|
|
325
|
+
exports.getDetailsFromUnsignedTransactionIncreaseDelay = getDetailsFromUnsignedTransactionIncreaseDelay;
|
|
326
|
+
function signTransactionIncreaseDelay(unsignedTransaction, privateKey, canisterId) {
|
|
327
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
328
|
+
// unsignedTransaction has already the arguments needed for signing, just need to be in a Buffer
|
|
329
|
+
const args = (0, convert_1.hexStringToArrayBuffer)(unsignedTransaction);
|
|
330
|
+
// Sign transaction
|
|
331
|
+
const signedTransaction = (0, ICPImplementation_1.signTransaction)(privateKey, canisterId, args, 'manage_neuron', 'call');
|
|
332
|
+
return signedTransaction;
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
exports.signTransactionIncreaseDelay = signTransactionIncreaseDelay;
|
|
336
|
+
function getDetailsFromSignedTransactionIncreaseDelay(publicKey, network) {
|
|
337
|
+
// Does not need info from transaction because it is only a call to the governance canister
|
|
338
|
+
return [
|
|
339
|
+
{
|
|
340
|
+
from: [(0, ICPImplementation_1.getAddressFromPublicKey)(publicKey)],
|
|
341
|
+
to: [network.governanceCanisterId],
|
|
342
|
+
isInbound: false,
|
|
343
|
+
amount: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
344
|
+
fee: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
345
|
+
network
|
|
346
|
+
}
|
|
347
|
+
];
|
|
348
|
+
}
|
|
349
|
+
exports.getDetailsFromSignedTransactionIncreaseDelay = getDetailsFromSignedTransactionIncreaseDelay;
|
|
350
|
+
// START_DISSOLVING
|
|
351
|
+
// CANISTER : (name: NNS Governance, identifier: rrkah-fqaaa-aaaaa-aaaaq-cai)
|
|
352
|
+
// METHOD : (name: manage_neuron, type: update)
|
|
353
|
+
// PAYLOAD : (id : [{id : float}], command : [{Configure : {operation : [{StartDissolving : {}}]}}], neuron_id_or_subaccount : [])
|
|
354
|
+
// RESPONSE : (command : [{configure : {}}])
|
|
355
|
+
function createUnsignedTransactionStartDissolving(publicKey) {
|
|
356
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
357
|
+
// Create subaccount from publicKey
|
|
358
|
+
const { subAccount, nonce: _ } = (0, ICPImplementation_1.getFixedSubaccountFromPublicKey)(publicKey);
|
|
359
|
+
// IDL for StartDissolving
|
|
360
|
+
const NeuronId = IDL.Record({ id: IDL.Nat64 });
|
|
361
|
+
const StartDissolving = IDL.Record({});
|
|
362
|
+
const Operation = IDL.Variant({
|
|
363
|
+
StartDissolving: StartDissolving
|
|
364
|
+
});
|
|
365
|
+
const Configure = IDL.Record({ operation: IDL.Opt(Operation) });
|
|
366
|
+
const Command = IDL.Variant({
|
|
367
|
+
Configure: Configure
|
|
368
|
+
});
|
|
369
|
+
const NeuronIdOrSubaccount = IDL.Variant({
|
|
370
|
+
Subaccount: IDL.Vec(IDL.Nat8),
|
|
371
|
+
NeuronId: NeuronId
|
|
372
|
+
});
|
|
373
|
+
const ManageNeuron = IDL.Record({
|
|
374
|
+
id: IDL.Opt(NeuronId),
|
|
375
|
+
command: IDL.Opt(Command),
|
|
376
|
+
neuron_id_or_subaccount: IDL.Opt(NeuronIdOrSubaccount)
|
|
377
|
+
});
|
|
378
|
+
// Encode
|
|
379
|
+
const unsignedTransactionBuffer = IDL.encode([ManageNeuron], [
|
|
380
|
+
{
|
|
381
|
+
command: [{ Configure: { operation: [{ StartDissolving: {} }] } }],
|
|
382
|
+
neuron_id_or_subaccount: [{ Subaccount: subAccount }]
|
|
383
|
+
}
|
|
384
|
+
]);
|
|
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
|
+
});
|
|
393
|
+
});
|
|
394
|
+
}
|
|
395
|
+
exports.createUnsignedTransactionStartDissolving = createUnsignedTransactionStartDissolving;
|
|
396
|
+
function getDetailsFromUnsignedTransactionStartDissolving(publicKey, network) {
|
|
397
|
+
// Does not need info from transaction because it is only a call to the governance canister
|
|
398
|
+
return [
|
|
399
|
+
{
|
|
400
|
+
from: [(0, ICPImplementation_1.getAddressFromPublicKey)(publicKey)],
|
|
401
|
+
to: [network.governanceCanisterId],
|
|
402
|
+
isInbound: false,
|
|
403
|
+
amount: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
404
|
+
fee: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
405
|
+
network
|
|
406
|
+
}
|
|
407
|
+
];
|
|
408
|
+
}
|
|
409
|
+
exports.getDetailsFromUnsignedTransactionStartDissolving = getDetailsFromUnsignedTransactionStartDissolving;
|
|
410
|
+
function signTransactionStartDissolving(unsignedTransaction, privateKey, canisterId) {
|
|
411
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
412
|
+
// unsignedTransaction has already the arguments needed for signing, just need to be in a Buffer
|
|
413
|
+
const args = (0, convert_1.hexStringToArrayBuffer)(unsignedTransaction);
|
|
414
|
+
// Sign transaction
|
|
415
|
+
const signedTransaction = (0, ICPImplementation_1.signTransaction)(privateKey, canisterId, args, 'manage_neuron', 'call');
|
|
416
|
+
return signedTransaction;
|
|
417
|
+
});
|
|
418
|
+
}
|
|
419
|
+
exports.signTransactionStartDissolving = signTransactionStartDissolving;
|
|
420
|
+
function getDetailsFromSignedTransactionStartDissolving(publicKey, network) {
|
|
421
|
+
// Does not need info from transaction because it is only a call to the governance canister
|
|
422
|
+
return [
|
|
423
|
+
{
|
|
424
|
+
from: [(0, ICPImplementation_1.getAddressFromPublicKey)(publicKey)],
|
|
425
|
+
to: [network.governanceCanisterId],
|
|
426
|
+
isInbound: false,
|
|
427
|
+
amount: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
428
|
+
fee: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
429
|
+
network: network
|
|
430
|
+
}
|
|
431
|
+
];
|
|
432
|
+
}
|
|
433
|
+
exports.getDetailsFromSignedTransactionStartDissolving = getDetailsFromSignedTransactionStartDissolving;
|
|
434
|
+
// STOP_DISSOLVING
|
|
435
|
+
// CANISTER : (name: NNS Governance, identifier: rrkah-fqaaa-aaaaa-aaaaq-cai)
|
|
436
|
+
// METHOD : (name: manage_neuron, type: update)
|
|
437
|
+
// PAYLOAD : (id : [{id : float}], command : [{Configure : {operation : [{StopDissolving : {}}]}}], neuron_id_or_subaccount : [])
|
|
438
|
+
// RESPONSE : (command : [{configure : {}}])
|
|
439
|
+
function createUnsignedTransactionStopDissolving(publicKey) {
|
|
440
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
441
|
+
// Create subaccount from publicKey
|
|
442
|
+
const { subAccount, nonce: _ } = (0, ICPImplementation_1.getFixedSubaccountFromPublicKey)(publicKey);
|
|
443
|
+
// IDL for StartDissolving
|
|
444
|
+
const NeuronId = IDL.Record({ id: IDL.Nat64 });
|
|
445
|
+
const StopDissolving = IDL.Record({});
|
|
446
|
+
const Operation = IDL.Variant({
|
|
447
|
+
StopDissolving: StopDissolving
|
|
448
|
+
});
|
|
449
|
+
const Configure = IDL.Record({ operation: IDL.Opt(Operation) });
|
|
450
|
+
const Command = IDL.Variant({
|
|
451
|
+
Configure: Configure
|
|
452
|
+
});
|
|
453
|
+
const NeuronIdOrSubaccount = IDL.Variant({
|
|
454
|
+
Subaccount: IDL.Vec(IDL.Nat8),
|
|
455
|
+
NeuronId: NeuronId
|
|
456
|
+
});
|
|
457
|
+
const ManageNeuron = IDL.Record({
|
|
458
|
+
id: IDL.Opt(NeuronId),
|
|
459
|
+
command: IDL.Opt(Command),
|
|
460
|
+
neuron_id_or_subaccount: IDL.Opt(NeuronIdOrSubaccount)
|
|
461
|
+
});
|
|
462
|
+
// Encode
|
|
463
|
+
const unsignedTransactionBuffer = IDL.encode([ManageNeuron], [
|
|
464
|
+
{
|
|
465
|
+
command: [{ Configure: { operation: [{ StopDissolving: {} }] } }],
|
|
466
|
+
neuron_id_or_subaccount: [{ Subaccount: subAccount }]
|
|
467
|
+
}
|
|
468
|
+
]);
|
|
469
|
+
return (0, module_kit_1.newUnsignedTransaction)({
|
|
470
|
+
transactions: [
|
|
471
|
+
{
|
|
472
|
+
actionType: transaction_1.ICPActionType.STOP_DISSOLVING,
|
|
473
|
+
encoded: (0, convert_1.arrayBufferToHexString)(unsignedTransactionBuffer)
|
|
474
|
+
}
|
|
475
|
+
]
|
|
476
|
+
});
|
|
477
|
+
});
|
|
478
|
+
}
|
|
479
|
+
exports.createUnsignedTransactionStopDissolving = createUnsignedTransactionStopDissolving;
|
|
480
|
+
function getDetailsFromUnsignedTransactionStopDissolving(publicKey, network) {
|
|
481
|
+
// Does not need info from transaction because it is only a call to the governance canister
|
|
482
|
+
return [
|
|
483
|
+
{
|
|
484
|
+
from: [(0, ICPImplementation_1.getAddressFromPublicKey)(publicKey)],
|
|
485
|
+
to: [network.governanceCanisterId],
|
|
486
|
+
isInbound: false,
|
|
487
|
+
amount: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
488
|
+
fee: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
489
|
+
network: network
|
|
490
|
+
}
|
|
491
|
+
];
|
|
492
|
+
}
|
|
493
|
+
exports.getDetailsFromUnsignedTransactionStopDissolving = getDetailsFromUnsignedTransactionStopDissolving;
|
|
494
|
+
function signTransactionStopDissolving(unsignedTransaction, privateKey, canisterId) {
|
|
495
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
496
|
+
// unsignedTransaction has already the arguments needed for signing, just need to be in a Buffer
|
|
497
|
+
const args = (0, convert_1.hexStringToArrayBuffer)(unsignedTransaction);
|
|
498
|
+
// Sign transaction
|
|
499
|
+
const signedTransaction = (0, ICPImplementation_1.signTransaction)(privateKey, canisterId, args, 'manage_neuron', 'call');
|
|
500
|
+
return signedTransaction;
|
|
501
|
+
});
|
|
502
|
+
}
|
|
503
|
+
exports.signTransactionStopDissolving = signTransactionStopDissolving;
|
|
504
|
+
function getDetailsFromSignedTransactionStopDissolving(publicKey, network) {
|
|
505
|
+
// Does not need info from transaction because it is only a call to the governance canister
|
|
506
|
+
return [
|
|
507
|
+
{
|
|
508
|
+
from: [(0, ICPImplementation_1.getAddressFromPublicKey)(publicKey)],
|
|
509
|
+
to: [network.governanceCanisterId],
|
|
510
|
+
isInbound: false,
|
|
511
|
+
amount: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
512
|
+
fee: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
513
|
+
network
|
|
514
|
+
}
|
|
515
|
+
];
|
|
516
|
+
}
|
|
517
|
+
exports.getDetailsFromSignedTransactionStopDissolving = getDetailsFromSignedTransactionStopDissolving;
|
|
518
|
+
// FOLLOW_NEURON
|
|
519
|
+
// CANISTER : (name: NNS Governance, identifier: rrkah-fqaaa-aaaaa-aaaaq-cai)
|
|
520
|
+
// METHOD : (name: manage_neuron, type: update)
|
|
521
|
+
// PAYLOAD : (id : [{id : float}], command : [{Follow : {topic : int, followees : [{id: int}]}}], neuron_id_or_subaccount : [])
|
|
522
|
+
// RESPONSE : (command : [{Follow : {}}])
|
|
523
|
+
function createUnsignedTransactionFollowNeuron(publicKey, neuronId) {
|
|
524
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
525
|
+
// Create subaccount from publicKey
|
|
526
|
+
const { subAccount, nonce: _ } = (0, ICPImplementation_1.getFixedSubaccountFromPublicKey)(publicKey);
|
|
527
|
+
// IDL for FollowNeuron
|
|
528
|
+
const NeuronId = IDL.Record({ id: IDL.Nat64 });
|
|
529
|
+
const Follow = IDL.Record({
|
|
530
|
+
topic: IDL.Int32,
|
|
531
|
+
followees: IDL.Vec(NeuronId)
|
|
532
|
+
});
|
|
533
|
+
const Command = IDL.Variant({
|
|
534
|
+
Follow: Follow
|
|
535
|
+
});
|
|
536
|
+
const NeuronIdOrSubaccount = IDL.Variant({
|
|
537
|
+
Subaccount: IDL.Vec(IDL.Nat8),
|
|
538
|
+
NeuronId: NeuronId
|
|
539
|
+
});
|
|
540
|
+
const ManageNeuron = IDL.Record({
|
|
541
|
+
id: IDL.Opt(NeuronId),
|
|
542
|
+
command: IDL.Opt(Command),
|
|
543
|
+
neuron_id_or_subaccount: IDL.Opt(NeuronIdOrSubaccount)
|
|
544
|
+
});
|
|
545
|
+
// TODO : get the topic that corresponds to all topics
|
|
546
|
+
const topic = 0;
|
|
547
|
+
// Encode
|
|
548
|
+
const unsignedTransactionBuffer = IDL.encode([ManageNeuron], [
|
|
549
|
+
{
|
|
550
|
+
command: [{ Follow: { topic: topic, followees: [neuronId] } }],
|
|
551
|
+
neuron_id_or_subaccount: [{ Subaccount: subAccount }]
|
|
552
|
+
}
|
|
553
|
+
]);
|
|
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
|
+
});
|
|
562
|
+
});
|
|
563
|
+
}
|
|
564
|
+
exports.createUnsignedTransactionFollowNeuron = createUnsignedTransactionFollowNeuron;
|
|
565
|
+
function getDetailsFromUnsignedTransactionFollowNeuron(publicKey, network) {
|
|
566
|
+
// Does not need info from transaction because it is only a call to the governance canister
|
|
567
|
+
return [
|
|
568
|
+
{
|
|
569
|
+
from: [(0, ICPImplementation_1.getAddressFromPublicKey)(publicKey)],
|
|
570
|
+
to: [network.governanceCanisterId],
|
|
571
|
+
isInbound: false,
|
|
572
|
+
amount: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
573
|
+
fee: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
574
|
+
network
|
|
575
|
+
}
|
|
576
|
+
];
|
|
577
|
+
}
|
|
578
|
+
exports.getDetailsFromUnsignedTransactionFollowNeuron = getDetailsFromUnsignedTransactionFollowNeuron;
|
|
579
|
+
function signTransactionFollowNeuron(unsignedTransaction, privateKey, canisterId) {
|
|
580
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
581
|
+
// unsignedTransaction has already the arguments needed for signing, just need to be in a Buffer
|
|
582
|
+
const args = (0, convert_1.hexStringToArrayBuffer)(unsignedTransaction);
|
|
583
|
+
// Sign transaction
|
|
584
|
+
const signedTransaction = (0, ICPImplementation_1.signTransaction)(privateKey, canisterId, args, 'manage_neuron', 'call');
|
|
585
|
+
return signedTransaction;
|
|
586
|
+
});
|
|
587
|
+
}
|
|
588
|
+
exports.signTransactionFollowNeuron = signTransactionFollowNeuron;
|
|
589
|
+
function getDetailsFromSignedTransactionFollowNeuron(publicKey, network) {
|
|
590
|
+
// Does not need info from transaction because it is only a call to the governance canister
|
|
591
|
+
return [
|
|
592
|
+
{
|
|
593
|
+
from: [(0, ICPImplementation_1.getAddressFromPublicKey)(publicKey)],
|
|
594
|
+
to: [network.governanceCanisterId],
|
|
595
|
+
isInbound: false,
|
|
596
|
+
amount: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
597
|
+
fee: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
598
|
+
network
|
|
599
|
+
}
|
|
600
|
+
];
|
|
601
|
+
}
|
|
602
|
+
exports.getDetailsFromSignedTransactionFollowNeuron = getDetailsFromSignedTransactionFollowNeuron;
|
|
603
|
+
// RESTAKE_MATURITY
|
|
604
|
+
// CANISTER : (name: NNS Governance, identifier: rrkah-fqaaa-aaaaa-aaaaq-cai)
|
|
605
|
+
// METHOD : (name: manage_neuron, type: update)
|
|
606
|
+
// PAYLOAD : (id : [{id : float}], command : [{StakeMaturity : {percentage_to_stake : [int]}}], neuron_id_or_subaccount : [])
|
|
607
|
+
// RESPONSE : (command : [{StakeMaturity : {maturity_e8s : int, staked_maturity_e8s : int}}])
|
|
608
|
+
function createUnsignedTransactionRestakeMaturity(publicKey, percentageStake) {
|
|
609
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
610
|
+
// Create subaccount from publicKey
|
|
611
|
+
const { subAccount, nonce: _ } = (0, ICPImplementation_1.getFixedSubaccountFromPublicKey)(publicKey);
|
|
612
|
+
// IDL for StakeMaturity
|
|
613
|
+
const NeuronId = IDL.Record({ id: IDL.Nat64 });
|
|
614
|
+
const StakeMaturity = IDL.Record({
|
|
615
|
+
percentage_to_stake: IDL.Opt(IDL.Nat32)
|
|
616
|
+
});
|
|
617
|
+
const Command = IDL.Variant({
|
|
618
|
+
StakeMaturity: StakeMaturity
|
|
619
|
+
});
|
|
620
|
+
const NeuronIdOrSubaccount = IDL.Variant({
|
|
621
|
+
Subaccount: IDL.Vec(IDL.Nat8),
|
|
622
|
+
NeuronId: NeuronId
|
|
623
|
+
});
|
|
624
|
+
const ManageNeuron = IDL.Record({
|
|
625
|
+
id: IDL.Opt(NeuronId),
|
|
626
|
+
command: IDL.Opt(Command),
|
|
627
|
+
neuron_id_or_subaccount: IDL.Opt(NeuronIdOrSubaccount)
|
|
628
|
+
});
|
|
629
|
+
// Encode
|
|
630
|
+
const unsignedTransactionBuffer = IDL.encode([ManageNeuron], [
|
|
631
|
+
{
|
|
632
|
+
command: [{ StakeMaturity: { percentage_to_stake: percentageStake } }],
|
|
633
|
+
neuron_id_or_subaccount: [{ Subaccount: subAccount }]
|
|
634
|
+
}
|
|
635
|
+
]);
|
|
636
|
+
return (0, module_kit_1.newUnsignedTransaction)({
|
|
637
|
+
transactions: [
|
|
638
|
+
{
|
|
639
|
+
actionType: transaction_1.ICPActionType.FOLLOW_NEURON,
|
|
640
|
+
encoded: (0, convert_1.arrayBufferToHexString)(unsignedTransactionBuffer)
|
|
641
|
+
}
|
|
642
|
+
]
|
|
643
|
+
});
|
|
644
|
+
});
|
|
645
|
+
}
|
|
646
|
+
exports.createUnsignedTransactionRestakeMaturity = createUnsignedTransactionRestakeMaturity;
|
|
647
|
+
function getDetailsFromUnsignedTransactionRestakeMaturity(publicKey, network) {
|
|
648
|
+
// Does not need info from transaction because it is only a call to the governance canister
|
|
649
|
+
return [
|
|
650
|
+
{
|
|
651
|
+
from: [(0, ICPImplementation_1.getAddressFromPublicKey)(publicKey)],
|
|
652
|
+
to: [network.governanceCanisterId],
|
|
653
|
+
isInbound: false,
|
|
654
|
+
amount: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
655
|
+
fee: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
656
|
+
network: network
|
|
657
|
+
}
|
|
658
|
+
];
|
|
659
|
+
}
|
|
660
|
+
exports.getDetailsFromUnsignedTransactionRestakeMaturity = getDetailsFromUnsignedTransactionRestakeMaturity;
|
|
661
|
+
function signTransactionRestakeMaturity(unsignedTransaction, privateKey, canisterId) {
|
|
662
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
663
|
+
// unsignedTransaction has already the arguments needed for signing, just need to be in a Buffer
|
|
664
|
+
const args = (0, convert_1.hexStringToArrayBuffer)(unsignedTransaction);
|
|
665
|
+
// Sign transaction
|
|
666
|
+
const signedTransaction = (0, ICPImplementation_1.signTransaction)(privateKey, canisterId, args, 'manage_neuron', 'call');
|
|
667
|
+
return signedTransaction;
|
|
668
|
+
});
|
|
669
|
+
}
|
|
670
|
+
exports.signTransactionRestakeMaturity = signTransactionRestakeMaturity;
|
|
671
|
+
function getDetailsFromSignedTransactionRestakeMaturity(publicKey, network) {
|
|
672
|
+
// Does not need info from transaction because it is only a call to the governance canister
|
|
673
|
+
return [
|
|
674
|
+
{
|
|
675
|
+
from: [(0, ICPImplementation_1.getAddressFromPublicKey)(publicKey)],
|
|
676
|
+
to: [network.governanceCanisterId],
|
|
677
|
+
isInbound: false,
|
|
678
|
+
amount: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
679
|
+
fee: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
680
|
+
network
|
|
681
|
+
}
|
|
682
|
+
];
|
|
683
|
+
}
|
|
684
|
+
exports.getDetailsFromSignedTransactionRestakeMaturity = getDetailsFromSignedTransactionRestakeMaturity;
|
|
685
|
+
// REMOVE_STAKE
|
|
686
|
+
// Cannot extrapolate method from call since we have to wait 6 months to do so
|
|
687
|
+
function createUnsignedTransactionRemoveStake(publicKey) {
|
|
688
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
689
|
+
// Create subaccount from publicKey
|
|
690
|
+
const { subAccount, nonce: _ } = (0, ICPImplementation_1.getFixedSubaccountFromPublicKey)(publicKey);
|
|
691
|
+
// IDL for RemoveStake
|
|
692
|
+
// Encode
|
|
693
|
+
const unsignedTransactionBuffer = IDL.encode([], [
|
|
694
|
+
{
|
|
695
|
+
command: [],
|
|
696
|
+
neuron_id_or_subaccount: [{ Subaccount: subAccount }]
|
|
697
|
+
}
|
|
698
|
+
]);
|
|
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
|
+
});
|
|
707
|
+
});
|
|
708
|
+
}
|
|
709
|
+
exports.createUnsignedTransactionRemoveStake = createUnsignedTransactionRemoveStake;
|
|
710
|
+
function getDetailsFromUnsignedTransactionRemoveStake(publicKey, network) {
|
|
711
|
+
// Does not need info from transaction because it is only a call to the governance canister
|
|
712
|
+
return [
|
|
713
|
+
{
|
|
714
|
+
from: [(0, ICPImplementation_1.getAddressFromPublicKey)(publicKey)],
|
|
715
|
+
to: [network.governanceCanisterId],
|
|
716
|
+
isInbound: false,
|
|
717
|
+
amount: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
718
|
+
fee: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
719
|
+
network: network
|
|
720
|
+
}
|
|
721
|
+
];
|
|
722
|
+
}
|
|
723
|
+
exports.getDetailsFromUnsignedTransactionRemoveStake = getDetailsFromUnsignedTransactionRemoveStake;
|
|
724
|
+
function signTransactionRemoveStake(unsignedTransaction, privateKey, canisterId) {
|
|
725
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
726
|
+
// unsignedTransaction has already the arguments needed for signing, just need to be in a Buffer
|
|
727
|
+
const args = (0, convert_1.hexStringToArrayBuffer)(unsignedTransaction);
|
|
728
|
+
// Sign transaction
|
|
729
|
+
const signedTransaction = (0, ICPImplementation_1.signTransaction)(privateKey, canisterId, args, 'manage_neuron', 'call');
|
|
730
|
+
return signedTransaction;
|
|
731
|
+
});
|
|
732
|
+
}
|
|
733
|
+
exports.signTransactionRemoveStake = signTransactionRemoveStake;
|
|
734
|
+
function getDetailsFromSignedTransactionRemoveStake(publicKey, network) {
|
|
735
|
+
// Does not need info from transaction because it is only a call to the governance canister
|
|
736
|
+
return [
|
|
737
|
+
{
|
|
738
|
+
from: [(0, ICPImplementation_1.getAddressFromPublicKey)(publicKey)],
|
|
739
|
+
to: [network.governanceCanisterId],
|
|
740
|
+
isInbound: false,
|
|
741
|
+
amount: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
742
|
+
fee: (0, module_kit_1.newAmount)('0', 'blockchain'),
|
|
743
|
+
network
|
|
744
|
+
}
|
|
745
|
+
];
|
|
746
|
+
}
|
|
747
|
+
exports.getDetailsFromSignedTransactionRemoveStake = getDetailsFromSignedTransactionRemoveStake;
|
|
748
|
+
//# sourceMappingURL=ICPGovernance.js.map
|