@dfinity/nns 0.5.0 → 0.6.0-nightly-2022-07-21
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/README.md +1 -1
- package/dist/candid/genesis_token.certified.idl.d.ts +2 -0
- package/dist/candid/genesis_token.certified.idl.js +2 -1
- package/dist/candid/genesis_token.d.ts +33 -0
- package/dist/candid/genesis_token.did +23 -22
- package/dist/candid/genesis_token.idl.d.ts +0 -8
- package/dist/candid/genesis_token.idl.js +2 -1
- package/dist/candid/governance.certified.idl.js +86 -33
- package/dist/candid/{governanceTypes.d.ts → governance.d.ts} +28 -1
- package/dist/candid/governance.did +26 -5
- package/dist/candid/governance.idl.d.ts +0 -3
- package/dist/candid/governance.idl.js +86 -33
- package/dist/candid/ledger.certified.idl.js +1 -1
- package/dist/candid/{ledgerTypes.d.ts → ledger.d.ts} +0 -5
- package/dist/candid/ledger.did +2 -2
- package/dist/candid/ledger.idl.d.ts +0 -3
- package/dist/candid/ledger.idl.js +1 -1
- package/dist/candid/sns_wasm.certified.idl.d.ts +2 -0
- package/dist/candid/sns_wasm.certified.idl.js +117 -0
- package/dist/candid/sns_wasm.d.ts +106 -0
- package/dist/candid/sns_wasm.did +76 -0
- package/dist/candid/sns_wasm.idl.d.ts +2 -0
- package/dist/candid/sns_wasm.idl.js +117 -0
- package/dist/cjs/index.cjs.js +32 -32
- package/dist/cjs/index.cjs.js.map +3 -3
- package/dist/esm/account_identifier.js +1 -1
- package/dist/esm/chunk-CKIW7YKS.js +2 -0
- package/dist/esm/chunk-CKIW7YKS.js.map +7 -0
- package/dist/esm/{chunk-S37GZOMR.js → chunk-FZGMZSQZ.js} +3 -3
- package/dist/esm/chunk-FZGMZSQZ.js.map +7 -0
- package/dist/esm/chunk-H6I2Z4SN.js +7 -0
- package/dist/esm/chunk-H6I2Z4SN.js.map +7 -0
- package/dist/esm/{chunk-FL7E4DL3.js → chunk-IPUXUCZB.js} +2 -2
- package/dist/esm/chunk-IPUXUCZB.js.map +7 -0
- package/dist/esm/chunk-JUIC5FZJ.js +2 -0
- package/dist/esm/chunk-JUIC5FZJ.js.map +7 -0
- package/dist/esm/chunk-MGC7CRB4.js +11 -0
- package/dist/esm/chunk-MGC7CRB4.js.map +7 -0
- package/dist/esm/chunk-NN3MUNHF.js +2 -0
- package/dist/esm/chunk-NN3MUNHF.js.map +7 -0
- package/dist/esm/chunk-NNJFBVJ3.js +831 -0
- package/dist/esm/{chunk-EDMSX7GK.js.map → chunk-NNJFBVJ3.js.map} +3 -3
- package/dist/esm/{chunk-MTPVFXPH.js → chunk-RHCXRQFK.js} +2 -2
- package/dist/esm/{chunk-MTPVFXPH.js.map → chunk-RHCXRQFK.js.map} +1 -1
- package/dist/esm/chunk-TLWRX3CX.js +9 -0
- package/dist/esm/chunk-TLWRX3CX.js.map +7 -0
- package/dist/esm/genesis_token.canister.js +2 -0
- package/dist/esm/{genesis_token.js.map → genesis_token.canister.js.map} +0 -0
- package/dist/esm/governance.canister.js +2 -0
- package/dist/esm/{governance.js.map → governance.canister.js.map} +0 -0
- package/dist/esm/icp.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/ledger.canister.js +2 -0
- package/dist/esm/{ledger.js.map → ledger.canister.js.map} +0 -0
- package/dist/esm/sns_wasm.canister.js +2 -0
- package/dist/esm/sns_wasm.canister.js.map +7 -0
- package/dist/proto/governance.proto +2 -0
- package/dist/proto/governance_pb.d.ts +7 -0
- package/dist/proto/governance_pb.js +57 -2
- package/dist/types/account_identifier.d.ts +3 -1
- package/dist/types/canisters/governance/request.converters.d.ts +4 -3
- package/dist/types/canisters/governance/request.proto.converters.d.ts +2 -2
- package/dist/types/canisters/governance/response.converters.d.ts +12 -5
- package/dist/types/canisters/governance/services.d.ts +1 -2
- package/dist/types/canisters/ledger/ledger.request.converts.d.ts +2 -2
- package/dist/types/constants/canister_ids.d.ts +1 -0
- package/dist/types/errors/governance.errors.d.ts +2 -2
- package/dist/types/errors/ledger.errors.d.ts +2 -2
- package/dist/types/genesis_token.canister.d.ts +11 -0
- package/dist/types/{governance.d.ts → governance.canister.d.ts} +11 -5
- package/dist/types/index.d.ts +8 -5
- package/dist/types/{ledger.d.ts → ledger.canister.d.ts} +4 -4
- package/dist/types/sns_wasm.canister.d.ts +11 -0
- package/dist/types/types/canister.options.d.ts +8 -0
- package/dist/types/types/governance.options.d.ts +5 -0
- package/dist/types/types/governance_converters.d.ts +22 -5
- package/dist/types/types/ledger.options.d.ts +15 -0
- package/dist/types/types/ledger_converters.d.ts +3 -3
- package/dist/types/types/sns_wasm.options.d.ts +3 -0
- package/dist/types/utils/account_identifier.utils.d.ts +2 -2
- package/dist/types/utils/actor.utils.d.ts +14 -0
- package/dist/types/utils/agent.utils.d.ts +1 -1
- package/dist/types/utils/did.utils.d.ts +1 -0
- package/dist/types/utils/proto.utils.d.ts +2 -2
- package/package.json +10 -36
- package/dist/esm/chunk-BDJ6FQPO.js +0 -2
- package/dist/esm/chunk-BDJ6FQPO.js.map +0 -7
- package/dist/esm/chunk-C2ZTAHQL.js +0 -3
- package/dist/esm/chunk-C2ZTAHQL.js.map +0 -7
- package/dist/esm/chunk-CVYDMRZA.js +0 -7
- package/dist/esm/chunk-CVYDMRZA.js.map +0 -7
- package/dist/esm/chunk-EDMSX7GK.js +0 -831
- package/dist/esm/chunk-FL7E4DL3.js.map +0 -7
- package/dist/esm/chunk-KXYKDST6.js +0 -17
- package/dist/esm/chunk-KXYKDST6.js.map +0 -7
- package/dist/esm/chunk-S37GZOMR.js.map +0 -7
- package/dist/esm/chunk-SOPGOKKH.js +0 -2
- package/dist/esm/chunk-SOPGOKKH.js.map +0 -7
- package/dist/esm/genesis_token.js +0 -2
- package/dist/esm/governance.js +0 -2
- package/dist/esm/ledger.js +0 -2
- package/dist/types/genesis_token.d.ts +0 -17
- package/dist/types/types/governance.d.ts +0 -10
- package/dist/types/types/ledger.d.ts +0 -18
|
@@ -243,6 +243,7 @@ message Neuron {
|
|
|
243
243
|
uint64 neuron_fees_e8s = 6 [jstype = JS_STRING];
|
|
244
244
|
uint64 created_timestamp_seconds = 7 [jstype = JS_STRING];
|
|
245
245
|
uint64 aging_since_timestamp_seconds = 8 [jstype = JS_STRING];
|
|
246
|
+
optional uint64 spawn_at_timestamp_seconds = 19 [jstype = JS_STRING];
|
|
246
247
|
oneof dissolve_state {
|
|
247
248
|
uint64 when_dissolved_timestamp_seconds = 9 [jstype = JS_STRING];
|
|
248
249
|
uint64 dissolve_delay_seconds = 10 [jstype = JS_STRING];
|
|
@@ -284,4 +285,5 @@ enum Topic {
|
|
|
284
285
|
TOPIC_NETWORK_CANISTER_MANAGEMENT = 8;
|
|
285
286
|
TOPIC_KYC = 9;
|
|
286
287
|
TOPIC_NODE_PROVIDER_REWARDS = 10;
|
|
288
|
+
TOPIC_SNS_DECENTRALIZATION_SALE = 11;
|
|
287
289
|
}
|
|
@@ -888,6 +888,11 @@ export class Neuron extends jspb.Message {
|
|
|
888
888
|
getAgingSinceTimestampSeconds(): string;
|
|
889
889
|
setAgingSinceTimestampSeconds(value: string): void;
|
|
890
890
|
|
|
891
|
+
hasSpawnAtTimestampSeconds(): boolean;
|
|
892
|
+
clearSpawnAtTimestampSeconds(): void;
|
|
893
|
+
getSpawnAtTimestampSeconds(): string;
|
|
894
|
+
setSpawnAtTimestampSeconds(value: string): void;
|
|
895
|
+
|
|
891
896
|
hasWhenDissolvedTimestampSeconds(): boolean;
|
|
892
897
|
clearWhenDissolvedTimestampSeconds(): void;
|
|
893
898
|
getWhenDissolvedTimestampSeconds(): string;
|
|
@@ -940,6 +945,7 @@ export namespace Neuron {
|
|
|
940
945
|
neuronFeesE8s: string,
|
|
941
946
|
createdTimestampSeconds: string,
|
|
942
947
|
agingSinceTimestampSeconds: string,
|
|
948
|
+
spawnAtTimestampSeconds: string,
|
|
943
949
|
whenDissolvedTimestampSeconds: string,
|
|
944
950
|
dissolveDelaySeconds: string,
|
|
945
951
|
followeesMap: Array<[number, Neuron.Followees.AsObject]>,
|
|
@@ -1049,6 +1055,7 @@ export interface TopicMap {
|
|
|
1049
1055
|
TOPIC_NETWORK_CANISTER_MANAGEMENT: 8;
|
|
1050
1056
|
TOPIC_KYC: 9;
|
|
1051
1057
|
TOPIC_NODE_PROVIDER_REWARDS: 10;
|
|
1058
|
+
TOPIC_SNS_DECENTRALIZATION_SALE: 11;
|
|
1052
1059
|
}
|
|
1053
1060
|
|
|
1054
1061
|
export const Topic: TopicMap;
|
|
@@ -13,7 +13,13 @@
|
|
|
13
13
|
|
|
14
14
|
var jspb = require('google-protobuf');
|
|
15
15
|
var goog = jspb;
|
|
16
|
-
var global =
|
|
16
|
+
var global = (function() {
|
|
17
|
+
if (this) { return this; }
|
|
18
|
+
if (typeof window !== 'undefined') { return window; }
|
|
19
|
+
if (typeof global !== 'undefined') { return global; }
|
|
20
|
+
if (typeof self !== 'undefined') { return self; }
|
|
21
|
+
return Function('return this')();
|
|
22
|
+
}.call(null));
|
|
17
23
|
|
|
18
24
|
var base_types_pb = require('./base_types_pb.js');
|
|
19
25
|
goog.object.extend(proto, base_types_pb);
|
|
@@ -6527,6 +6533,7 @@ proto.ic_nns_governance.pb.v1.Neuron.toObject = function(includeInstance, msg) {
|
|
|
6527
6533
|
neuronFeesE8s: jspb.Message.getFieldWithDefault(msg, 6, "0"),
|
|
6528
6534
|
createdTimestampSeconds: jspb.Message.getFieldWithDefault(msg, 7, "0"),
|
|
6529
6535
|
agingSinceTimestampSeconds: jspb.Message.getFieldWithDefault(msg, 8, "0"),
|
|
6536
|
+
spawnAtTimestampSeconds: jspb.Message.getFieldWithDefault(msg, 19, "0"),
|
|
6530
6537
|
whenDissolvedTimestampSeconds: jspb.Message.getFieldWithDefault(msg, 9, "0"),
|
|
6531
6538
|
dissolveDelaySeconds: jspb.Message.getFieldWithDefault(msg, 10, "0"),
|
|
6532
6539
|
followeesMap: (f = msg.getFolloweesMap()) ? f.toObject(includeInstance, proto.ic_nns_governance.pb.v1.Neuron.Followees.toObject) : [],
|
|
@@ -6607,6 +6614,10 @@ proto.ic_nns_governance.pb.v1.Neuron.deserializeBinaryFromReader = function(msg,
|
|
|
6607
6614
|
var value = /** @type {string} */ (reader.readUint64String());
|
|
6608
6615
|
msg.setAgingSinceTimestampSeconds(value);
|
|
6609
6616
|
break;
|
|
6617
|
+
case 19:
|
|
6618
|
+
var value = /** @type {string} */ (reader.readUint64String());
|
|
6619
|
+
msg.setSpawnAtTimestampSeconds(value);
|
|
6620
|
+
break;
|
|
6610
6621
|
case 9:
|
|
6611
6622
|
var value = /** @type {string} */ (reader.readUint64String());
|
|
6612
6623
|
msg.setWhenDissolvedTimestampSeconds(value);
|
|
@@ -6731,6 +6742,13 @@ proto.ic_nns_governance.pb.v1.Neuron.serializeBinaryToWriter = function(message,
|
|
|
6731
6742
|
f
|
|
6732
6743
|
);
|
|
6733
6744
|
}
|
|
6745
|
+
f = /** @type {string} */ (jspb.Message.getField(message, 19));
|
|
6746
|
+
if (f != null) {
|
|
6747
|
+
writer.writeUint64String(
|
|
6748
|
+
19,
|
|
6749
|
+
f
|
|
6750
|
+
);
|
|
6751
|
+
}
|
|
6734
6752
|
f = /** @type {string} */ (jspb.Message.getField(message, 9));
|
|
6735
6753
|
if (f != null) {
|
|
6736
6754
|
writer.writeUint64String(
|
|
@@ -7175,6 +7193,42 @@ proto.ic_nns_governance.pb.v1.Neuron.prototype.setAgingSinceTimestampSeconds = f
|
|
|
7175
7193
|
};
|
|
7176
7194
|
|
|
7177
7195
|
|
|
7196
|
+
/**
|
|
7197
|
+
* optional uint64 spawn_at_timestamp_seconds = 19;
|
|
7198
|
+
* @return {string}
|
|
7199
|
+
*/
|
|
7200
|
+
proto.ic_nns_governance.pb.v1.Neuron.prototype.getSpawnAtTimestampSeconds = function() {
|
|
7201
|
+
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 19, "0"));
|
|
7202
|
+
};
|
|
7203
|
+
|
|
7204
|
+
|
|
7205
|
+
/**
|
|
7206
|
+
* @param {string} value
|
|
7207
|
+
* @return {!proto.ic_nns_governance.pb.v1.Neuron} returns this
|
|
7208
|
+
*/
|
|
7209
|
+
proto.ic_nns_governance.pb.v1.Neuron.prototype.setSpawnAtTimestampSeconds = function(value) {
|
|
7210
|
+
return jspb.Message.setField(this, 19, value);
|
|
7211
|
+
};
|
|
7212
|
+
|
|
7213
|
+
|
|
7214
|
+
/**
|
|
7215
|
+
* Clears the field making it undefined.
|
|
7216
|
+
* @return {!proto.ic_nns_governance.pb.v1.Neuron} returns this
|
|
7217
|
+
*/
|
|
7218
|
+
proto.ic_nns_governance.pb.v1.Neuron.prototype.clearSpawnAtTimestampSeconds = function() {
|
|
7219
|
+
return jspb.Message.setField(this, 19, undefined);
|
|
7220
|
+
};
|
|
7221
|
+
|
|
7222
|
+
|
|
7223
|
+
/**
|
|
7224
|
+
* Returns whether this field is set.
|
|
7225
|
+
* @return {boolean}
|
|
7226
|
+
*/
|
|
7227
|
+
proto.ic_nns_governance.pb.v1.Neuron.prototype.hasSpawnAtTimestampSeconds = function() {
|
|
7228
|
+
return jspb.Message.getField(this, 19) != null;
|
|
7229
|
+
};
|
|
7230
|
+
|
|
7231
|
+
|
|
7178
7232
|
/**
|
|
7179
7233
|
* optional uint64 when_dissolved_timestamp_seconds = 9;
|
|
7180
7234
|
* @return {string}
|
|
@@ -7800,7 +7854,8 @@ proto.ic_nns_governance.pb.v1.Topic = {
|
|
|
7800
7854
|
TOPIC_SUBNET_MANAGEMENT: 7,
|
|
7801
7855
|
TOPIC_NETWORK_CANISTER_MANAGEMENT: 8,
|
|
7802
7856
|
TOPIC_KYC: 9,
|
|
7803
|
-
TOPIC_NODE_PROVIDER_REWARDS: 10
|
|
7857
|
+
TOPIC_NODE_PROVIDER_REWARDS: 10,
|
|
7858
|
+
TOPIC_SNS_DECENTRALIZATION_SALE: 11
|
|
7804
7859
|
};
|
|
7805
7860
|
|
|
7806
7861
|
goog.object.extend(exports, proto.ic_nns_governance.pb.v1);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Principal } from "@dfinity/principal";
|
|
1
|
+
import type { Principal } from "@dfinity/principal";
|
|
2
2
|
import { AccountIdentifier as AccountIdentifierPb } from "../proto/ledger_pb";
|
|
3
3
|
export declare class AccountIdentifier {
|
|
4
4
|
private readonly bytes;
|
|
@@ -13,6 +13,7 @@ export declare class AccountIdentifier {
|
|
|
13
13
|
*/
|
|
14
14
|
toProto(): AccountIdentifierPb;
|
|
15
15
|
toHex(): string;
|
|
16
|
+
toUint8Array(): Uint8Array;
|
|
16
17
|
toNumbers(): number[];
|
|
17
18
|
}
|
|
18
19
|
export declare class SubAccount {
|
|
@@ -20,6 +21,7 @@ export declare class SubAccount {
|
|
|
20
21
|
private constructor();
|
|
21
22
|
static fromBytes(bytes: Uint8Array): SubAccount | Error;
|
|
22
23
|
static fromPrincipal(principal: Principal): SubAccount;
|
|
24
|
+
static fromID(id: number): SubAccount;
|
|
23
25
|
static ZERO: SubAccount;
|
|
24
26
|
toUint8Array(): Uint8Array;
|
|
25
27
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Principal } from "@dfinity/principal";
|
|
2
|
-
import { Command as RawCommand, ListNeurons as RawListNeurons, ListProposalInfo, ManageNeuron as RawManageNeuron, Operation as RawOperation } from "../../../candid/
|
|
3
|
-
import { E8s, NeuronId } from "../../types/common";
|
|
4
|
-
import { ClaimNeuronRequest, ClaimOrRefreshNeuronRequest, DisburseToNeuronRequest, FollowRequest, ListProposalsRequest, MakeProposalRequest, ManageNeuron, ProposalId, Vote } from "../../types/governance_converters";
|
|
2
|
+
import type { Command as RawCommand, ListNeurons as RawListNeurons, ListProposalInfo, ManageNeuron as RawManageNeuron, Operation as RawOperation } from "../../../candid/governance";
|
|
3
|
+
import type { E8s, NeuronId } from "../../types/common";
|
|
4
|
+
import type { ClaimNeuronRequest, ClaimOrRefreshNeuronRequest, DisburseToNeuronRequest, FollowRequest, ListProposalsRequest, MakeProposalRequest, ManageNeuron, ProposalId, Vote } from "../../types/governance_converters";
|
|
5
5
|
export declare const fromListNeurons: (neuronIds?: bigint[] | undefined) => RawListNeurons;
|
|
6
6
|
export declare const fromManageNeuron: ({ id, command, neuronIdOrSubaccount, }: ManageNeuron) => RawManageNeuron;
|
|
7
7
|
export declare const fromClaimNeuronRequest: ({ publicKey, nonce, dissolveDelayInSecs, }: ClaimNeuronRequest) => [Array<number>, bigint, bigint];
|
|
@@ -52,6 +52,7 @@ export declare const toIncreaseDissolveDelayRequest: ({ neuronId, additionalDiss
|
|
|
52
52
|
additionalDissolveDelaySeconds: number;
|
|
53
53
|
}) => RawManageNeuron;
|
|
54
54
|
export declare const toJoinCommunityFundRequest: (neuronId: NeuronId) => RawManageNeuron;
|
|
55
|
+
export declare const toLeaveCommunityFundRequest: (neuronId: NeuronId) => RawManageNeuron;
|
|
55
56
|
export declare const toMergeRequest: ({ sourceNeuronId, targetNeuronId, }: {
|
|
56
57
|
sourceNeuronId: NeuronId;
|
|
57
58
|
targetNeuronId: NeuronId;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ManageNeuron as PbManageNeuron } from "../../../proto/governance_pb";
|
|
2
|
-
import { NeuronId } from "../../types/common";
|
|
3
|
-
import { AddHotKeyRequest, DisburseRequest, FollowRequest, MergeMaturityRequest, MergeRequest, RemoveHotKeyRequest, SpawnRequest } from "../../types/governance_converters";
|
|
2
|
+
import type { NeuronId } from "../../types/common";
|
|
3
|
+
import type { AddHotKeyRequest, DisburseRequest, FollowRequest, MergeMaturityRequest, MergeRequest, RemoveHotKeyRequest, SpawnRequest } from "../../types/governance_converters";
|
|
4
4
|
export declare const fromAddHotKeyRequest: (request: AddHotKeyRequest) => PbManageNeuron;
|
|
5
5
|
export declare const fromRemoveHotKeyRequest: (request: RemoveHotKeyRequest) => PbManageNeuron;
|
|
6
6
|
export declare const fromIncreaseDissolveDelayRequest: ({ neuronId, additionalDissolveDelaySeconds, }: {
|
|
@@ -1,8 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ListNeuronsResponse,
|
|
3
|
-
import {
|
|
1
|
+
import { Principal } from "@dfinity/principal";
|
|
2
|
+
import type { KnownNeuron as RawKnownNeuron, ListNeuronsResponse as RawListNeuronsResponse, ListProposalInfoResponse as RawListProposalInfoResponse, ProposalInfo as RawProposalInfo } from "../../../candid/governance";
|
|
3
|
+
import type { ListNeuronsResponse, Neuron as PbNeuron } from "../../../proto/governance_pb";
|
|
4
|
+
import type { KnownNeuron, ListProposalsResponse, NeuronInfo, ProposalInfo } from "../../types/governance_converters";
|
|
4
5
|
export declare const toProposalInfo: (proposalInfo: RawProposalInfo) => ProposalInfo;
|
|
5
|
-
export declare const toArrayOfNeuronInfo: ({ neuron_infos, full_neurons, }:
|
|
6
|
+
export declare const toArrayOfNeuronInfo: ({ response: { neuron_infos, full_neurons }, canisterId, }: {
|
|
7
|
+
response: RawListNeuronsResponse;
|
|
8
|
+
canisterId: Principal;
|
|
9
|
+
}) => Array<NeuronInfo>;
|
|
6
10
|
export declare const toListProposalsResponse: ({ proposal_info, }: RawListProposalInfoResponse) => ListProposalsResponse;
|
|
7
11
|
export declare const toKnownNeuron: ({ id, known_neuron_data, }: RawKnownNeuron) => KnownNeuron;
|
|
8
|
-
export declare const convertPbNeuronToNeuronInfo: (pbNeurons
|
|
12
|
+
export declare const convertPbNeuronToNeuronInfo: ({ pbNeurons, canisterId, }: {
|
|
13
|
+
pbNeurons: PbNeuron[];
|
|
14
|
+
canisterId: Principal;
|
|
15
|
+
}) => (pbNeuronMapEntry: ListNeuronsResponse.NeuronMapEntry) => NeuronInfo;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { GovernanceService } from "../../../candid/governance
|
|
2
|
-
import { Command_1, ManageNeuron, ManageNeuronResponse } from "../../../candid/governanceTypes";
|
|
1
|
+
import type { Command_1, ManageNeuron, ManageNeuronResponse, _SERVICE as GovernanceService } from "../../../candid/governance";
|
|
3
2
|
/**
|
|
4
3
|
* Checks a Manage Neuron Response for error and returns successful response data.
|
|
5
4
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { TransferArgs as TransferRawRequest } from "../../../candid/
|
|
1
|
+
import type { TransferArgs as TransferRawRequest } from "../../../candid/ledger";
|
|
2
2
|
import { ICPTs, Subaccount } from "../../../proto/ledger_pb";
|
|
3
|
-
import { TransferRequest } from "../../types/ledger_converters";
|
|
3
|
+
import type { TransferRequest } from "../../types/ledger_converters";
|
|
4
4
|
export declare const subAccountNumbersToSubaccount: (subAccountNumbers: number[]) => Subaccount;
|
|
5
5
|
export declare const toICPTs: (amount: bigint) => ICPTs;
|
|
6
6
|
export declare const toTransferRawRequest: ({ to, amount, memo, fee, fromSubAccount, }: TransferRequest) => TransferRawRequest;
|
|
@@ -3,3 +3,4 @@ export declare const GOVERNANCE_CANISTER_ID: Principal;
|
|
|
3
3
|
export declare const MAINNET_GOVERNANCE_CANISTER_ID: Principal;
|
|
4
4
|
export declare const MAINNET_LEDGER_CANISTER_ID: Principal;
|
|
5
5
|
export declare const MAINNET_GENESIS_TOKEN_CANISTER_ID: Principal;
|
|
6
|
+
export declare const MAINNET_SNS_WASM_CANISTER_ID: Principal;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { GovernanceError as GovernanceErrorDetail } from "../../candid/
|
|
2
|
-
import { ICP } from "../icp";
|
|
1
|
+
import type { GovernanceError as GovernanceErrorDetail } from "../../candid/governance";
|
|
2
|
+
import type { ICP } from "../icp";
|
|
3
3
|
export declare abstract class StakeNeuronError extends Error {
|
|
4
4
|
}
|
|
5
5
|
export declare class CouldNotClaimNeuronError extends StakeNeuronError {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { TransferError as RawTransferError } from "../../candid/
|
|
1
|
+
import type { TransferError as RawTransferError } from "../../candid/ledger";
|
|
2
2
|
import { ICP } from "../icp";
|
|
3
|
-
import { BlockHeight } from "../types/common";
|
|
3
|
+
import type { BlockHeight } from "../types/common";
|
|
4
4
|
export declare class TransferError extends Error {
|
|
5
5
|
}
|
|
6
6
|
export declare class InvalidSenderError extends TransferError {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { _SERVICE as GenesisTokenService } from "../candid/genesis_token";
|
|
2
|
+
import type { CanisterOptions } from "./types/canister.options";
|
|
3
|
+
import type { NeuronId } from "./types/common";
|
|
4
|
+
export declare class GenesisTokenCanister {
|
|
5
|
+
private readonly service;
|
|
6
|
+
private constructor();
|
|
7
|
+
static create(options?: CanisterOptions<GenesisTokenService>): GenesisTokenCanister;
|
|
8
|
+
claimNeurons: ({ hexPubKey, }: {
|
|
9
|
+
hexPubKey: string;
|
|
10
|
+
}) => Promise<NeuronId[]>;
|
|
11
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Principal } from "@dfinity/principal";
|
|
1
|
+
import type { Principal } from "@dfinity/principal";
|
|
2
2
|
import { ICP } from "./icp";
|
|
3
|
-
import { LedgerCanister } from "./ledger";
|
|
4
|
-
import { E8s, NeuronId } from "./types/common";
|
|
5
|
-
import { GovernanceCanisterOptions } from "./types/governance";
|
|
6
|
-
import { ClaimOrRefreshNeuronRequest, FollowRequest, KnownNeuron, ListProposalsRequest, ListProposalsResponse, MakeProposalRequest, NeuronInfo, ProposalId, ProposalInfo, Vote } from "./types/governance_converters";
|
|
3
|
+
import type { LedgerCanister } from "./ledger.canister";
|
|
4
|
+
import type { E8s, NeuronId } from "./types/common";
|
|
5
|
+
import type { GovernanceCanisterOptions } from "./types/governance.options";
|
|
6
|
+
import type { ClaimOrRefreshNeuronRequest, FollowRequest, KnownNeuron, ListProposalsRequest, ListProposalsResponse, MakeProposalRequest, NeuronInfo, ProposalId, ProposalInfo, Vote } from "./types/governance_converters";
|
|
7
7
|
export declare class GovernanceCanister {
|
|
8
8
|
private readonly canisterId;
|
|
9
9
|
private readonly service;
|
|
@@ -83,6 +83,12 @@ export declare class GovernanceCanister {
|
|
|
83
83
|
* @throws {@link GovernanceError}
|
|
84
84
|
*/
|
|
85
85
|
joinCommunityFund: (neuronId: NeuronId) => Promise<void>;
|
|
86
|
+
/**
|
|
87
|
+
* Neuron leaves the community fund
|
|
88
|
+
*
|
|
89
|
+
* @throws {@link GovernanceError}
|
|
90
|
+
*/
|
|
91
|
+
leaveCommunityFund: (neuronId: NeuronId) => Promise<void>;
|
|
86
92
|
/**
|
|
87
93
|
* Merge two neurons
|
|
88
94
|
*
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
|
+
export type { DeployedSns } from "../candid/sns_wasm";
|
|
1
2
|
export { AccountIdentifier, SubAccount } from "./account_identifier";
|
|
2
3
|
export * from "./errors/governance.errors";
|
|
3
4
|
export * from "./errors/ledger.errors";
|
|
4
|
-
export { GenesisTokenCanister } from "./genesis_token";
|
|
5
|
-
export { GovernanceCanister } from "./governance";
|
|
5
|
+
export { GenesisTokenCanister } from "./genesis_token.canister";
|
|
6
|
+
export { GovernanceCanister } from "./governance.canister";
|
|
6
7
|
export { ICP } from "./icp";
|
|
7
|
-
export { LedgerCanister } from "./ledger";
|
|
8
|
+
export { LedgerCanister } from "./ledger.canister";
|
|
9
|
+
export { SnsWasmCanister } from "./sns_wasm.canister";
|
|
8
10
|
export * from "./types/common";
|
|
9
|
-
export * from "./types/governance";
|
|
11
|
+
export * from "./types/governance.options";
|
|
10
12
|
export * from "./types/governance_converters";
|
|
11
13
|
export * from "./types/icp";
|
|
12
|
-
export * from "./types/ledger";
|
|
14
|
+
export * from "./types/ledger.options";
|
|
15
|
+
export type { SnsWasmCanisterOptions } from "./types/sns_wasm.options";
|
|
13
16
|
export * from "./utils/accounts.utils";
|
|
14
17
|
export * from "./utils/account_identifier.utils";
|
|
15
18
|
export * from "./utils/neurons.utils";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { AccountIdentifier } from "./account_identifier";
|
|
1
|
+
import type { AccountIdentifier } from "./account_identifier";
|
|
2
2
|
import { ICP } from "./icp";
|
|
3
|
-
import { BlockHeight } from "./types/common";
|
|
4
|
-
import { LedgerCanisterOptions } from "./types/ledger";
|
|
5
|
-
import { TransferRequest } from "./types/ledger_converters";
|
|
3
|
+
import type { BlockHeight } from "./types/common";
|
|
4
|
+
import type { LedgerCanisterOptions } from "./types/ledger.options";
|
|
5
|
+
import type { TransferRequest } from "./types/ledger_converters";
|
|
6
6
|
export declare class LedgerCanister {
|
|
7
7
|
private readonly agent;
|
|
8
8
|
private readonly canisterId;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { DeployedSns, _SERVICE as SnsWasmService } from "../candid/sns_wasm";
|
|
2
|
+
import type { CanisterOptions } from "./types/canister.options";
|
|
3
|
+
export declare class SnsWasmCanister {
|
|
4
|
+
private readonly service;
|
|
5
|
+
private readonly certifiedService;
|
|
6
|
+
private constructor();
|
|
7
|
+
static create(options?: CanisterOptions<SnsWasmService>): SnsWasmCanister;
|
|
8
|
+
listSnses: ({ certified, }: {
|
|
9
|
+
certified?: boolean | undefined;
|
|
10
|
+
}) => Promise<DeployedSns[]>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ActorSubclass, Agent } from "@dfinity/agent";
|
|
2
|
+
import type { Principal } from "@dfinity/principal";
|
|
3
|
+
export interface CanisterOptions<T> {
|
|
4
|
+
agent?: Agent;
|
|
5
|
+
canisterId?: Principal;
|
|
6
|
+
serviceOverride?: ActorSubclass<T>;
|
|
7
|
+
certifiedServiceOverride?: ActorSubclass<T>;
|
|
8
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { DerEncodedPublicKey } from "@dfinity/agent";
|
|
2
|
-
import { Principal } from "@dfinity/principal";
|
|
3
|
-
import { AccountIdentifier, CanisterIdString, E8s, NeuronId, Option, PrincipalString } from "./common";
|
|
1
|
+
import type { DerEncodedPublicKey } from "@dfinity/agent";
|
|
2
|
+
import type { Principal } from "@dfinity/principal";
|
|
3
|
+
import type { AccountIdentifier, CanisterIdString, E8s, NeuronId, Option, PrincipalString } from "./common";
|
|
4
4
|
export declare type Action = {
|
|
5
5
|
RegisterKnownNeuron: KnownNeuron;
|
|
6
6
|
} | {
|
|
@@ -21,6 +21,8 @@ export declare type Action = {
|
|
|
21
21
|
SetDefaultFollowees: SetDefaultFollowees;
|
|
22
22
|
} | {
|
|
23
23
|
Motion: Motion;
|
|
24
|
+
} | {
|
|
25
|
+
SetSnsTokenSwapOpenTimeWindow: SetSnsTokenSwapOpenTimeWindow;
|
|
24
26
|
};
|
|
25
27
|
export interface AddHotKey {
|
|
26
28
|
newHotKey: Option<PrincipalString>;
|
|
@@ -190,6 +192,15 @@ export interface MethodAuthzInfo {
|
|
|
190
192
|
export interface Motion {
|
|
191
193
|
motionText: string;
|
|
192
194
|
}
|
|
195
|
+
export interface SetSnsTokenSwapOpenTimeWindow {
|
|
196
|
+
request?: {
|
|
197
|
+
openTimeWindow?: {
|
|
198
|
+
startTimestampSeconds: bigint;
|
|
199
|
+
endTimestampSeconds: bigint;
|
|
200
|
+
};
|
|
201
|
+
};
|
|
202
|
+
swapCanisterId?: string;
|
|
203
|
+
}
|
|
193
204
|
export interface NetworkEconomics {
|
|
194
205
|
neuronMinimumStake: E8s;
|
|
195
206
|
maxProposalsToKeepPerTopic: number;
|
|
@@ -210,6 +221,7 @@ export interface Neuron {
|
|
|
210
221
|
createdTimestampSeconds: bigint;
|
|
211
222
|
maturityE8sEquivalent: bigint;
|
|
212
223
|
agingSinceTimestampSeconds: bigint;
|
|
224
|
+
spawnAtTimesSeconds: Option<bigint>;
|
|
213
225
|
neuronFees: E8s;
|
|
214
226
|
hotKeys: Array<PrincipalString>;
|
|
215
227
|
accountIdentifier: AccountIdentifier;
|
|
@@ -226,7 +238,8 @@ export declare enum NeuronState {
|
|
|
226
238
|
UNSPECIFIED = 0,
|
|
227
239
|
LOCKED = 1,
|
|
228
240
|
DISSOLVING = 2,
|
|
229
|
-
DISSOLVED = 3
|
|
241
|
+
DISSOLVED = 3,
|
|
242
|
+
SPAWNING = 4
|
|
230
243
|
}
|
|
231
244
|
export interface NeuronInfo {
|
|
232
245
|
neuronId: NeuronId;
|
|
@@ -256,6 +269,8 @@ export declare type Operation = {
|
|
|
256
269
|
IncreaseDissolveDelay: IncreaseDissolveDelay;
|
|
257
270
|
} | {
|
|
258
271
|
JoinCommunityFund: Record<string, never>;
|
|
272
|
+
} | {
|
|
273
|
+
LeaveCommunityFund: Record<string, never>;
|
|
259
274
|
} | {
|
|
260
275
|
SetDissolveTimestamp: SetDissolveTimestamp;
|
|
261
276
|
};
|
|
@@ -274,6 +289,7 @@ export interface ProposalInfo {
|
|
|
274
289
|
rewardEventRound: bigint;
|
|
275
290
|
failedTimestampSeconds: bigint;
|
|
276
291
|
decidedTimestampSeconds: bigint;
|
|
292
|
+
deadlineTimestampSeconds: Option<bigint>;
|
|
277
293
|
latestTally: Option<Tally>;
|
|
278
294
|
proposal: Option<Proposal>;
|
|
279
295
|
proposer: Option<NeuronId>;
|
|
@@ -361,7 +377,8 @@ export declare enum Topic {
|
|
|
361
377
|
SubnetManagement = 7,
|
|
362
378
|
NetworkCanisterManagement = 8,
|
|
363
379
|
Kyc = 9,
|
|
364
|
-
NodeProviderRewards = 10
|
|
380
|
+
NodeProviderRewards = 10,
|
|
381
|
+
SnsDecentralizationSale = 11
|
|
365
382
|
}
|
|
366
383
|
export interface AddHotKeyRequest {
|
|
367
384
|
neuronId: NeuronId;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Agent } from "@dfinity/agent";
|
|
2
|
+
import type { Principal } from "@dfinity/principal";
|
|
3
|
+
import type { _SERVICE as LedgerService } from "../../candid/ledger";
|
|
4
|
+
import type { CanisterOptions } from "./canister.options";
|
|
5
|
+
export declare type LedgerCanisterCall = (params: {
|
|
6
|
+
agent: Agent;
|
|
7
|
+
canisterId: Principal;
|
|
8
|
+
methodName: string;
|
|
9
|
+
arg: ArrayBuffer;
|
|
10
|
+
}) => Promise<Uint8Array>;
|
|
11
|
+
export interface LedgerCanisterOptions extends CanisterOptions<LedgerService> {
|
|
12
|
+
updateCallOverride?: LedgerCanisterCall;
|
|
13
|
+
queryCallOverride?: LedgerCanisterCall;
|
|
14
|
+
hardwareWallet?: boolean;
|
|
15
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { AccountIdentifier } from "../account_identifier";
|
|
2
|
-
import { ICP } from "../icp";
|
|
3
|
-
import { E8s } from "./common";
|
|
1
|
+
import type { AccountIdentifier } from "../account_identifier";
|
|
2
|
+
import type { ICP } from "../icp";
|
|
3
|
+
import type { E8s } from "./common";
|
|
4
4
|
export declare type TransferRequest = {
|
|
5
5
|
to: AccountIdentifier;
|
|
6
6
|
amount: ICP;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Principal } from "@dfinity/principal";
|
|
2
|
-
import { AccountIdentifier } from "../types/common";
|
|
1
|
+
import type { Principal } from "@dfinity/principal";
|
|
2
|
+
import type { AccountIdentifier } from "../types/common";
|
|
3
3
|
export declare const accountIdentifierToBytes: (accountIdentifier: AccountIdentifier) => Uint8Array;
|
|
4
4
|
export declare const accountIdentifierFromBytes: (accountIdentifier: Uint8Array) => AccountIdentifier;
|
|
5
5
|
export declare const principalToAccountIdentifier: (principal: Principal, subAccount?: Uint8Array | undefined) => string;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ActorSubclass, Agent } from "@dfinity/agent";
|
|
2
|
+
import type { IDL } from "@dfinity/candid";
|
|
3
|
+
import type { CanisterOptions } from "../types/canister.options";
|
|
4
|
+
declare type RequiredCanisterOptions<T> = Required<Pick<CanisterOptions<T>, "canisterId">> & Omit<CanisterOptions<T>, "canisterId">;
|
|
5
|
+
export declare const createServices: <T>({ options: { canisterId, serviceOverride, certifiedServiceOverride, agent: agentOption, }, idlFactory, certifiedIdlFactory, }: {
|
|
6
|
+
options: RequiredCanisterOptions<T>;
|
|
7
|
+
idlFactory: IDL.InterfaceFactory;
|
|
8
|
+
certifiedIdlFactory: IDL.InterfaceFactory;
|
|
9
|
+
}) => {
|
|
10
|
+
service: ActorSubclass<T>;
|
|
11
|
+
certifiedService: ActorSubclass<T>;
|
|
12
|
+
agent: Agent;
|
|
13
|
+
};
|
|
14
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const fromNullable: <T>(value: [] | [T]) => T | undefined;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Agent } from "@dfinity/agent";
|
|
2
|
-
import { Principal } from "@dfinity/principal";
|
|
1
|
+
import type { Agent } from "@dfinity/agent";
|
|
2
|
+
import type { Principal } from "@dfinity/principal";
|
|
3
3
|
/**
|
|
4
4
|
* Submits an update call to the IC.
|
|
5
5
|
* @returns The (binary) response if the request succeeded, an error otherwise.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dfinity/nns",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0-nightly-2022-07-21",
|
|
4
4
|
"description": "A library for interfacing with the Internet Computer's Network Nervous System.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/cjs/index.cjs.js",
|
|
@@ -12,56 +12,30 @@
|
|
|
12
12
|
"LICENSE"
|
|
13
13
|
],
|
|
14
14
|
"scripts": {
|
|
15
|
-
"rmdir": "node
|
|
15
|
+
"rmdir": "node ../../scripts/rmdir.mjs",
|
|
16
16
|
"ts-declaration": "tsc --emitDeclarationOnly --outDir dist/types",
|
|
17
|
-
"did": "scripts/compile-idl-js",
|
|
18
17
|
"build": "npm run rmdir && mkdir -p dist && cp -R proto candid dist && node esbuild.mjs && npm run ts-declaration",
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"lint": "eslint --max-warnings 0 .",
|
|
22
|
-
"format": "prettier --write .",
|
|
23
|
-
"prepare": "npm run build",
|
|
24
|
-
"protoc": "bash ./scripts/update_proto.sh"
|
|
18
|
+
"prepack": "npm run build",
|
|
19
|
+
"test": "jest"
|
|
25
20
|
},
|
|
26
21
|
"dependencies": {
|
|
27
|
-
"@dfinity/agent": "^0.11.3",
|
|
28
|
-
"@dfinity/candid": "^0.11.3",
|
|
29
|
-
"@dfinity/principal": "^0.11.3",
|
|
30
22
|
"crc": "^4.1.1",
|
|
31
23
|
"crc-32": "^1.2.2",
|
|
32
|
-
"google-protobuf": "^3.
|
|
24
|
+
"google-protobuf": "^3.19.4",
|
|
33
25
|
"js-sha256": "^0.9.0",
|
|
34
26
|
"randombytes": "^2.1.0"
|
|
35
27
|
},
|
|
36
28
|
"devDependencies": {
|
|
37
29
|
"@types/google-protobuf": "^3.15.6",
|
|
38
|
-
"@types/
|
|
39
|
-
"@types/randombytes": "^2.0.0",
|
|
40
|
-
"@types/text-encoding": "^0.0.36",
|
|
41
|
-
"@typescript-eslint/eslint-plugin": "^5.23.0",
|
|
42
|
-
"esbuild": "^0.14.38",
|
|
43
|
-
"eslint": "^8.15.0",
|
|
44
|
-
"eslint-config-standard": "^17.0.0",
|
|
45
|
-
"eslint-plugin-import": "^2.26.0",
|
|
46
|
-
"eslint-plugin-node": "^11.1.0",
|
|
47
|
-
"eslint-plugin-promise": "^6.0.0",
|
|
48
|
-
"jest": "^28.1.0",
|
|
49
|
-
"jest-mock-extended": "^2.0.6",
|
|
50
|
-
"prettier": "^2.6.2",
|
|
51
|
-
"prettier-plugin-organize-imports": "^2.3.4",
|
|
52
|
-
"text-encoding": "^0.7.0",
|
|
53
|
-
"ts-jest": "^28.0.2",
|
|
54
|
-
"ts-protoc-gen": "^0.15.0",
|
|
55
|
-
"typedoc": "^0.22.15",
|
|
56
|
-
"typescript": "^4.5.5",
|
|
57
|
-
"whatwg-fetch": "^3.6.2"
|
|
30
|
+
"@types/randombytes": "^2.0.0"
|
|
58
31
|
},
|
|
59
32
|
"repository": {
|
|
60
33
|
"type": "git",
|
|
61
|
-
"url": "git+https://github.com/dfinity/
|
|
34
|
+
"url": "git+https://github.com/dfinity/ic-js.git",
|
|
35
|
+
"directory": "packages/nns"
|
|
62
36
|
},
|
|
63
37
|
"bugs": {
|
|
64
|
-
"url": "https://github.com/dfinity/
|
|
38
|
+
"url": "https://github.com/dfinity/ic-js"
|
|
65
39
|
},
|
|
66
40
|
"keywords": [
|
|
67
41
|
"internet computer",
|
|
@@ -80,4 +54,4 @@
|
|
|
80
54
|
"network nervous system",
|
|
81
55
|
"network-nervous-system"
|
|
82
56
|
]
|
|
83
|
-
}
|
|
57
|
+
}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as z,b as G}from"./chunk-S37GZOMR.js";import{c as V,f as W,h as Q}from"./chunk-EDMSX7GK.js";import{a as p,d as m}from"./chunk-MTPVFXPH.js";import{c as M}from"./chunk-FL7E4DL3.js";import{c as H}from"./chunk-ONAVPXOT.js";var U=({IDL:e})=>{let t=e.Nat64,r=e.Record({start:t,length:e.Nat64}),n=e.Nat64,c=e.Vec(e.Nat8),o=e.Record({e8s:e.Nat64}),a=e.Variant({Burn:e.Record({from:c,amount:o}),Mint:e.Record({to:c,amount:o}),Transfer:e.Record({to:c,fee:o,from:c,amount:o})}),i=e.Record({timestamp_nanos:e.Nat64}),l=e.Record({memo:n,operation:e.Opt(a),created_at_time:i}),d=e.Record({transaction:l,timestamp:i,parent_hash:e.Opt(e.Vec(e.Nat8))}),f=e.Record({blocks:e.Vec(d)}),x=e.Variant({BadFirstBlockIndex:e.Record({requested_index:t,first_valid_index:t}),Other:e.Record({error_message:e.Text,error_code:e.Nat64})}),R=e.Variant({Ok:f,Err:x}),w=e.Func([r],[R],[]),v=e.Record({certificate:e.Opt(e.Vec(e.Nat8)),blocks:e.Vec(d),chain_length:e.Nat64,first_block_index:t,archived_blocks:e.Vec(e.Record({callback:w,start:t,length:e.Nat64}))}),F=e.Record({account:c}),A=e.Record({canister_id:e.Principal}),N=e.Record({archives:e.Vec(A)}),k=e.Vec(e.Nat8),B=e.Record({to:c,fee:o,memo:n,from_subaccount:e.Opt(k),created_at_time:e.Opt(i),amount:o}),O=e.Variant({TxTooOld:e.Record({allowed_window_nanos:e.Nat64}),BadFee:e.Record({expected_fee:o}),TxDuplicate:e.Record({duplicate_of:t}),TxCreatedInFuture:e.Null,InsufficientFunds:e.Record({balance:o})}),S=e.Variant({Ok:t,Err:O}),q=e.Record({}),P=e.Record({transfer_fee:o});return e.Service({_blocks:e.Func([r],[v],[]),account_balance:e.Func([F],[o],[]),archives:e.Func([],[N],[]),decimals:e.Func([],[e.Record({decimals:e.Nat32})],[]),name:e.Func([],[e.Record({name:e.Text})],[]),symbol:e.Func([],[e.Record({symbol:e.Text})],[]),transfer:e.Func([B],[S],[]),transfer_fee:e.Func([q],[P],[])})};var j=({IDL:e})=>{let t=e.Vec(e.Nat8),r=e.Record({account:t}),n=e.Record({e8s:e.Nat64}),c=e.Record({canister_id:e.Principal}),o=e.Record({archives:e.Vec(c)}),a=e.Nat64,i=e.Record({start:a,length:e.Nat64}),l=e.Nat64,d=e.Variant({Burn:e.Record({from:t,amount:n}),Mint:e.Record({to:t,amount:n}),Transfer:e.Record({to:t,fee:n,from:t,amount:n})}),f=e.Record({timestamp_nanos:e.Nat64}),x=e.Record({memo:l,operation:e.Opt(d),created_at_time:f}),R=e.Record({transaction:x,timestamp:f,parent_hash:e.Opt(e.Vec(e.Nat8))}),w=e.Record({blocks:e.Vec(R)}),v=e.Variant({BadFirstBlockIndex:e.Record({requested_index:a,first_valid_index:a}),Other:e.Record({error_message:e.Text,error_code:e.Nat64})}),F=e.Variant({Ok:w,Err:v}),A=e.Func([i],[F],["query"]),N=e.Record({certificate:e.Opt(e.Vec(e.Nat8)),blocks:e.Vec(R),chain_length:e.Nat64,first_block_index:a,archived_blocks:e.Vec(e.Record({callback:A,start:a,length:e.Nat64}))}),k=e.Vec(e.Nat8),B=e.Record({to:t,fee:n,memo:l,from_subaccount:e.Opt(k),created_at_time:e.Opt(f),amount:n}),O=e.Variant({TxTooOld:e.Record({allowed_window_nanos:e.Nat64}),BadFee:e.Record({expected_fee:n}),TxDuplicate:e.Record({duplicate_of:a}),TxCreatedInFuture:e.Null,InsufficientFunds:e.Record({balance:n})}),S=e.Variant({Ok:a,Err:O}),q=e.Record({}),P=e.Record({transfer_fee:n});return e.Service({account_balance:e.Func([r],[n],["query"]),archives:e.Func([],[o],["query"]),decimals:e.Func([],[e.Record({decimals:e.Nat32})],["query"]),name:e.Func([],[e.Record({name:e.Text})],["query"]),query_blocks:e.Func([i],[N],["query"]),symbol:e.Func([],[e.Record({symbol:e.Text})],["query"]),transfer:e.Func([B],[S],[]),transfer_fee:e.Func([q],[P],["query"])})};var s=H(M());var h=H(M());var $=e=>{let t=new Uint8Array(e).buffer,r=new h.Subaccount;return r.setSubAccount(new Uint8Array(t)),r},K=e=>{let t=new h.ICPTs;return t.setE8s(e.toString(10)),t},J=e=>({e8s:e}),X=({to:e,amount:t,memo:r,fee:n,fromSubAccount:c})=>({to:e.toNumbers(),fee:J(n??p),amount:J(t.toE8s()),memo:r??BigInt(0),created_at_time:[],from_subaccount:c===void 0?[]:[c]});var u=class extends Error{},C=class extends u{},_=class extends u{constructor(r){super();this.balance=r}},b=class extends u{constructor(r){super();this.allowed_window_secs=r}},g=class extends u{},T=class extends u{constructor(r){super();this.duplicateOf=r}},E=class extends u{constructor(r){super();this.expectedFee=r}},Y=e=>{if("TxDuplicate"in e)return new T(e.TxDuplicate.duplicate_of);if("InsufficientFunds"in e){let t=m.fromE8s(e.InsufficientFunds.balance.e8s);return new _(t)}return"TxCreatedInFuture"in e?new g:"TxTooOld"in e?new b(Number(e.TxTooOld.allowed_window_nanos)):"BadFee"in e?new E(e.BadFee.expected_fee.e8s):new u(`Unknown error type ${JSON.stringify(e)}`)},Z=e=>{let{message:t}=e;if(t.includes("Reject code: 5")){if(t.match(/Sending from (.*) is not allowed/))return new C;{let r=t.match(/transaction.*duplicate.* in block (\d+)/);if(r&&r.length>1)return new T(BigInt(r[1]))}{let r=t.match(/debit account.*, current balance: (\d*(\.\d*)?)/);if(r&&r.length>1){let n=m.fromString(r[1]);if(n instanceof m)return new _(n)}}if(t.includes("is in future"))return new g;{let r=t.match(/older than (\d+)/);if(r&&r.length>1)return new b(Number.parseInt(r[1]))}}throw e};var y=class{constructor(t,r,n,c,o,a,i=!1){this.agent=t;this.canisterId=r;this.service=n;this.certifiedService=c;this.updateFetcher=o;this.queryFetcher=a;this.hardwareWallet=i}static create(t={}){let r=t.agent??Q(),n=t.canisterId??W,c=t.serviceOverride??V.createActor(j,{agent:r,canisterId:n}),o=t.certifiedServiceOverride??V.createActor(U,{agent:r,canisterId:n});return new y(r,n,c,o,t.updateCallOverride??z,t.queryCallOverride??G,t.hardwareWallet)}accountBalance=async({accountIdentifier:t,certified:r=!0})=>{if(this.hardwareWallet)return this.accountBalanceHardwareWallet({accountIdentifier:t,certified:r});let c=await(r?this.certifiedService:this.service).account_balance({account:t.toNumbers()});return m.fromE8s(c.e8s)};transactionFee=async()=>{let{transfer_fee:{e8s:t}}=await this.service.transfer_fee({});return t};transfer=async t=>{if(this.hardwareWallet)return this.transferHardwareWallet(t);t.fee===void 0&&(t.fee=this.hardwareWallet?p:await this.transactionFee());let r=X(t),n=await this.certifiedService.transfer(r);if("Err"in n)throw Y(n.Err);return n.Ok};accountBalanceHardwareWallet=async({accountIdentifier:t,certified:r=!0})=>{let n=r?this.updateFetcher:this.queryFetcher,c=new s.AccountBalanceRequest;c.setAccount(t.toProto());let o=await n({agent:this.agent,canisterId:this.canisterId,methodName:"account_balance_pb",arg:c.serializeBinary()});return m.fromE8s(BigInt(s.ICPTs.deserializeBinary(new Uint8Array(o)).getE8s()))};transferHardwareWallet=async({to:t,amount:r,memo:n,fee:c,fromSubAccount:o})=>{let a=new s.SendRequest;a.setTo(t.toProto());let i=new s.Payment;i.setReceiverGets(r.toProto()),a.setPayment(i),a.setMaxFee(K(c??p));let l=new s.Memo;l.setMemo((n??BigInt(0)).toString()),a.setMemo(l),o!==void 0&&a.setFromSubaccount($(o));try{let d=await this.updateFetcher({agent:this.agent,canisterId:this.canisterId,methodName:"send_pb",arg:a.serializeBinary()});return BigInt(s.BlockHeight.deserializeBinary(d).getHeight())}catch(d){throw d instanceof Error?Z(d):d}}};export{u as a,C as b,_ as c,b as d,g as e,T as f,E as g,Y as h,Z as i,y as j};
|
|
2
|
-
//# sourceMappingURL=chunk-BDJ6FQPO.js.map
|