@dfinity/nns 3.0.0 → 3.1.0

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.
@@ -1,6 +1,6 @@
1
1
  import type { DerEncodedPublicKey } from "@dfinity/agent";
2
2
  import type { Principal } from "@dfinity/principal";
3
- import type { NeuronState, ProposalRewardStatus, ProposalStatus, Topic, Vote } from "../enums/governance.enums";
3
+ import type { NeuronState, NeuronType, ProposalRewardStatus, ProposalStatus, Topic, Vote } from "../enums/governance.enums";
4
4
  import type { AccountIdentifier, CanisterIdString, E8s, NeuronId, Option, PrincipalString } from "./common";
5
5
  export type Action = {
6
6
  RegisterKnownNeuron: KnownNeuron;
@@ -181,7 +181,7 @@ export interface MergeRequest {
181
181
  targetNeuronId: NeuronId;
182
182
  }
183
183
  export interface StakeMaturity {
184
- percentageToStake?: number;
184
+ percentageToStake: Option<number>;
185
185
  }
186
186
  export interface MergeMaturity {
187
187
  percentageToMerge: number;
@@ -208,9 +208,9 @@ export interface Motion {
208
208
  motionText: string;
209
209
  }
210
210
  export interface OpenSnsTokenSwap {
211
- communityFundInvestmentE8s?: bigint;
212
- targetSwapCanisterId?: Principal;
213
- params?: {
211
+ communityFundInvestmentE8s: Option<bigint>;
212
+ targetSwapCanisterId: Option<Principal>;
213
+ params: Option<{
214
214
  minParticipantIcpE8s: bigint;
215
215
  maxIcpE8s: bigint;
216
216
  swapDueTimestampSeconds: bigint;
@@ -218,23 +218,23 @@ export interface OpenSnsTokenSwap {
218
218
  snsTokenE8s: bigint;
219
219
  maxParticipantIcpE8s: bigint;
220
220
  minIcpE8s: bigint;
221
- saleDelaySeconds?: bigint;
222
- neuronBasketConstructionParameters?: {
221
+ saleDelaySeconds: Option<bigint>;
222
+ neuronBasketConstructionParameters: Option<{
223
223
  dissolve_delay_interval_seconds: bigint;
224
224
  count: bigint;
225
- };
226
- maxDirectParticipationIcpE8s?: bigint;
227
- minDirectParticipationIcpE8s?: bigint;
228
- };
225
+ }>;
226
+ maxDirectParticipationIcpE8s: Option<bigint>;
227
+ minDirectParticipationIcpE8s: Option<bigint>;
228
+ }>;
229
229
  }
230
230
  export interface SetSnsTokenSwapOpenTimeWindow {
231
- request?: {
232
- openTimeWindow?: {
231
+ request: Option<{
232
+ openTimeWindow: Option<{
233
233
  startTimestampSeconds: bigint;
234
234
  endTimestampSeconds: bigint;
235
- };
236
- };
237
- swapCanisterId?: string;
235
+ }>;
236
+ }>;
237
+ swapCanisterId: Option<string>;
238
238
  }
239
239
  export interface NetworkEconomics {
240
240
  neuronMinimumStake: E8s;
@@ -248,6 +248,7 @@ export interface NetworkEconomics {
248
248
  }
249
249
  export interface Neuron {
250
250
  id: Option<NeuronId>;
251
+ neuronType: Option<NeuronType>;
251
252
  stakedMaturityE8sEquivalent: Option<bigint>;
252
253
  controller: Option<PrincipalString>;
253
254
  recentBallots: Array<BallotInfo>;
@@ -275,6 +276,7 @@ export interface NeuronInfo {
275
276
  neuronId: NeuronId;
276
277
  dissolveDelaySeconds: bigint;
277
278
  recentBallots: Array<BallotInfo>;
279
+ neuronType: Option<NeuronType>;
278
280
  createdTimestampSeconds: bigint;
279
281
  state: NeuronState;
280
282
  joinedCommunityFundTimestampSeconds: Option<bigint>;
@@ -480,49 +482,49 @@ export interface ListNodeProvidersResponse {
480
482
  nodeProviders: NodeProvider[];
481
483
  }
482
484
  export interface Percentage {
483
- basisPoints?: bigint;
485
+ basisPoints: Option<bigint>;
484
486
  }
485
487
  export interface Duration {
486
- seconds?: bigint;
488
+ seconds: Option<bigint>;
487
489
  }
488
490
  export interface GlobalTimeOfDay {
489
- secondsAfterUtcMidnight?: bigint;
491
+ secondsAfterUtcMidnight: Option<bigint>;
490
492
  }
491
493
  export interface Countries {
492
494
  isoCodes: Array<string>;
493
495
  }
494
496
  export interface Tokens {
495
- e8s?: bigint;
497
+ e8s: Option<bigint>;
496
498
  }
497
499
  export interface Image {
498
- base64Encoding?: string;
500
+ base64Encoding: Option<string>;
499
501
  }
500
502
  export interface LedgerParameters {
501
- transactionFee?: Tokens;
502
- tokenSymbol?: string;
503
- tokenLogo?: Image;
504
- tokenName?: string;
503
+ transactionFee: Option<Tokens>;
504
+ tokenSymbol: Option<string>;
505
+ tokenLogo: Option<Image>;
506
+ tokenName: Option<string>;
505
507
  }
506
508
  export interface VotingRewardParameters {
507
- rewardRateTransitionDuration?: Duration;
508
- initialRewardRate?: Percentage;
509
- finalRewardRate?: Percentage;
509
+ rewardRateTransitionDuration: Option<Duration>;
510
+ initialRewardRate: Option<Percentage>;
511
+ finalRewardRate: Option<Percentage>;
510
512
  }
511
513
  export interface GovernanceParameters {
512
- neuronMaximumDissolveDelayBonus?: Percentage;
513
- neuronMaximumAgeForAgeBonus?: Duration;
514
- neuronMaximumDissolveDelay?: Duration;
515
- neuronMinimumDissolveDelayToVote?: Duration;
516
- neuronMaximumAgeBonus?: Percentage;
517
- neuronMinimumStake?: Tokens;
518
- proposalWaitForQuietDeadlineIncrease?: Duration;
519
- proposalInitialVotingPeriod?: Duration;
520
- proposalRejectionFee?: Tokens;
521
- votingRewardParameters?: VotingRewardParameters;
514
+ neuronMaximumDissolveDelayBonus: Option<Percentage>;
515
+ neuronMaximumAgeForAgeBonus: Option<Duration>;
516
+ neuronMaximumDissolveDelay: Option<Duration>;
517
+ neuronMinimumDissolveDelayToVote: Option<Duration>;
518
+ neuronMaximumAgeBonus: Option<Percentage>;
519
+ neuronMinimumStake: Option<Tokens>;
520
+ proposalWaitForQuietDeadlineIncrease: Option<Duration>;
521
+ proposalInitialVotingPeriod: Option<Duration>;
522
+ proposalRejectionFee: Option<Tokens>;
523
+ votingRewardParameters: Option<VotingRewardParameters>;
522
524
  }
523
525
  export interface NeuronBasketConstructionParameters {
524
- dissolveDelayInterval?: Duration;
525
- count?: bigint;
526
+ dissolveDelayInterval: Option<Duration>;
527
+ count: Option<bigint>;
526
528
  }
527
529
  export interface SwapParameters {
528
530
  minimumParticipants: Option<bigint>;
@@ -541,32 +543,32 @@ export interface SwapParameters {
541
543
  neuronsFundParticipation: Option<boolean>;
542
544
  }
543
545
  export interface SwapDistribution {
544
- total?: Tokens;
546
+ total: Option<Tokens>;
545
547
  }
546
548
  export interface NeuronDistribution {
547
- controller?: PrincipalString;
548
- dissolveDelay?: Duration;
549
- memo?: bigint;
550
- vestingPeriod?: Duration;
551
- stake?: Tokens;
549
+ controller: Option<PrincipalString>;
550
+ dissolveDelay: Option<Duration>;
551
+ memo: Option<bigint>;
552
+ vestingPeriod: Option<Duration>;
553
+ stake: Option<Tokens>;
552
554
  }
553
555
  export interface DeveloperDistribution {
554
556
  developerNeurons: Array<NeuronDistribution>;
555
557
  }
556
558
  export interface InitialTokenDistribution {
557
- treasuryDistribution?: SwapDistribution;
558
- developerDistribution?: DeveloperDistribution;
559
- swapDistribution?: SwapDistribution;
559
+ treasuryDistribution: Option<SwapDistribution>;
560
+ developerDistribution: Option<DeveloperDistribution>;
561
+ swapDistribution: Option<SwapDistribution>;
560
562
  }
561
563
  export interface CreateServiceNervousSystem {
562
- url?: string;
563
- governanceParameters?: GovernanceParameters;
564
+ url: Option<string>;
565
+ governanceParameters: Option<GovernanceParameters>;
564
566
  fallbackControllerPrincipalIds: Array<PrincipalString>;
565
- logo?: Image;
566
- name?: string;
567
- ledgerParameters?: LedgerParameters;
568
- description?: string;
567
+ logo: Option<Image>;
568
+ name: Option<string>;
569
+ ledgerParameters: Option<LedgerParameters>;
570
+ description: Option<string>;
569
571
  dappCanisters: Array<CanisterIdString>;
570
- swapParameters?: SwapParameters;
571
- initialTokenDistribution?: InitialTokenDistribution;
572
+ swapParameters: Option<SwapParameters>;
573
+ initialTokenDistribution: Option<InitialTokenDistribution>;
572
574
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dfinity/nns",
3
- "version": "3.0.0",
3
+ "version": "3.1.0",
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",
@@ -51,11 +51,11 @@
51
51
  "network-nervous-system"
52
52
  ],
53
53
  "peerDependencies": {
54
- "@dfinity/agent": "^0.19.2",
55
- "@dfinity/candid": "^0.19.2",
54
+ "@dfinity/agent": "^0.20.2",
55
+ "@dfinity/candid": "^0.20.2",
56
56
  "@dfinity/ledger-icp": "^2.0.0",
57
57
  "@dfinity/nns-proto": "^1.0.0",
58
- "@dfinity/principal": "^0.19.2",
59
- "@dfinity/utils": "^1.0.0"
58
+ "@dfinity/principal": "^0.20.2",
59
+ "@dfinity/utils": "^2.0.0"
60
60
  }
61
61
  }
@@ -1,20 +0,0 @@
1
- import{a as Ee,b as Cr,c as eo}from"./chunk-KCY3PAEP.js";var ao=Ee(We=>{"use strict";We.byteLength=Hr;We.toByteArray=Gr;We.fromByteArray=$r;var q=[],C=[],Kr=typeof Uint8Array<"u"?Uint8Array:Array,Pn="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(se=0,ro=Pn.length;se<ro;++se)q[se]=Pn[se],C[Pn.charCodeAt(se)]=se;var se,ro;C["-".charCodeAt(0)]=62;C["_".charCodeAt(0)]=63;function io(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=e.indexOf("=");n===-1&&(n=t);var o=n===t?0:4-n%4;return[n,o]}function Hr(e){var t=io(e),n=t[0],o=t[1];return(n+o)*3/4-o}function Wr(e,t,n){return(t+n)*3/4-n}function Gr(e){var t,n=io(e),o=n[0],r=n[1],i=new Kr(Wr(e,o,r)),a=0,c=r>0?o-4:o,d;for(d=0;d<c;d+=4)t=C[e.charCodeAt(d)]<<18|C[e.charCodeAt(d+1)]<<12|C[e.charCodeAt(d+2)]<<6|C[e.charCodeAt(d+3)],i[a++]=t>>16&255,i[a++]=t>>8&255,i[a++]=t&255;return r===2&&(t=C[e.charCodeAt(d)]<<2|C[e.charCodeAt(d+1)]>>4,i[a++]=t&255),r===1&&(t=C[e.charCodeAt(d)]<<10|C[e.charCodeAt(d+1)]<<4|C[e.charCodeAt(d+2)]>>2,i[a++]=t>>8&255,i[a++]=t&255),i}function jr(e){return q[e>>18&63]+q[e>>12&63]+q[e>>6&63]+q[e&63]}function zr(e,t,n){for(var o,r=[],i=t;i<n;i+=3)o=(e[i]<<16&16711680)+(e[i+1]<<8&65280)+(e[i+2]&255),r.push(jr(o));return r.join("")}function $r(e){for(var t,n=e.length,o=n%3,r=[],i=16383,a=0,c=n-o;a<c;a+=i)r.push(zr(e,a,a+i>c?c:a+i));return o===1?(t=e[n-1],r.push(q[t>>2]+q[t<<4&63]+"==")):o===2&&(t=(e[n-2]<<8)+e[n-1],r.push(q[t>>10]+q[t>>4&63]+q[t<<2&63]+"=")),r.join("")}});var so=Ee(Cn=>{Cn.read=function(e,t,n,o,r){var i,a,c=r*8-o-1,d=(1<<c)-1,l=d>>1,m=-7,p=n?r-1:0,y=n?-1:1,N=e[t+p];for(p+=y,i=N&(1<<-m)-1,N>>=-m,m+=c;m>0;i=i*256+e[t+p],p+=y,m-=8);for(a=i&(1<<-m)-1,i>>=-m,m+=o;m>0;a=a*256+e[t+p],p+=y,m-=8);if(i===0)i=1-l;else{if(i===d)return a?NaN:(N?-1:1)*(1/0);a=a+Math.pow(2,o),i=i-l}return(N?-1:1)*a*Math.pow(2,i-o)};Cn.write=function(e,t,n,o,r,i){var a,c,d,l=i*8-r-1,m=(1<<l)-1,p=m>>1,y=r===23?Math.pow(2,-24)-Math.pow(2,-77):0,N=o?0:i-1,k=o?1:-1,f=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(c=isNaN(t)?1:0,a=m):(a=Math.floor(Math.log(t)/Math.LN2),t*(d=Math.pow(2,-a))<1&&(a--,d*=2),a+p>=1?t+=y/d:t+=y*Math.pow(2,1-p),t*d>=2&&(a++,d/=2),a+p>=m?(c=0,a=m):a+p>=1?(c=(t*d-1)*Math.pow(2,r),a=a+p):(c=t*Math.pow(2,p-1)*Math.pow(2,r),a=0));r>=8;e[n+N]=c&255,N+=k,c/=256,r-=8);for(a=a<<r|c,l+=r;l>0;e[n+N]=a&255,N+=k,a/=256,l-=8);e[n+N-k]|=f*128}});var vo=Ee(pe=>{"use strict";var Mn=ao(),de=so(),co=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;pe.Buffer=s;pe.SlowBuffer=Ir;pe.INSPECT_MAX_BYTES=50;var Ge=2147483647;pe.kMaxLength=Ge;s.TYPED_ARRAY_SUPPORT=Jr();!s.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function Jr(){try{var e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),e.foo()===42}catch{return!1}}Object.defineProperty(s.prototype,"parent",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.buffer}});Object.defineProperty(s.prototype,"offset",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.byteOffset}});function X(e){if(e>Ge)throw new RangeError('The value "'+e+'" is invalid for option "size"');var t=new Uint8Array(e);return Object.setPrototypeOf(t,s.prototype),t}function s(e,t,n){if(typeof e=="number"){if(typeof t=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return Fn(e)}return _o(e,t,n)}s.poolSize=8192;function _o(e,t,n){if(typeof e=="string")return Yr(e,t);if(ArrayBuffer.isView(e))return Qr(e);if(e==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(U(e,ArrayBuffer)||e&&U(e.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(U(e,SharedArrayBuffer)||e&&U(e.buffer,SharedArrayBuffer)))return Vn(e,t,n);if(typeof e=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');var o=e.valueOf&&e.valueOf();if(o!=null&&o!==e)return s.from(o,t,n);var r=Zr(e);if(r)return r;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof e[Symbol.toPrimitive]=="function")return s.from(e[Symbol.toPrimitive]("string"),t,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}s.from=function(e,t,n){return _o(e,t,n)};Object.setPrototypeOf(s.prototype,Uint8Array.prototype);Object.setPrototypeOf(s,Uint8Array);function lo(e){if(typeof e!="number")throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function Xr(e,t,n){return lo(e),e<=0?X(e):t!==void 0?typeof n=="string"?X(e).fill(t,n):X(e).fill(t):X(e)}s.alloc=function(e,t,n){return Xr(e,t,n)};function Fn(e){return lo(e),X(e<0?0:Bn(e)|0)}s.allocUnsafe=function(e){return Fn(e)};s.allocUnsafeSlow=function(e){return Fn(e)};function Yr(e,t){if((typeof t!="string"||t==="")&&(t="utf8"),!s.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var n=mo(e,t)|0,o=X(n),r=o.write(e,t);return r!==n&&(o=o.slice(0,r)),o}function An(e){for(var t=e.length<0?0:Bn(e.length)|0,n=X(t),o=0;o<t;o+=1)n[o]=e[o]&255;return n}function Qr(e){if(U(e,Uint8Array)){var t=new Uint8Array(e);return Vn(t.buffer,t.byteOffset,t.byteLength)}return An(e)}function Vn(e,t,n){if(t<0||e.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(n||0))throw new RangeError('"length" is outside of buffer bounds');var o;return t===void 0&&n===void 0?o=new Uint8Array(e):n===void 0?o=new Uint8Array(e,t):o=new Uint8Array(e,t,n),Object.setPrototypeOf(o,s.prototype),o}function Zr(e){if(s.isBuffer(e)){var t=Bn(e.length)|0,n=X(t);return n.length===0||e.copy(n,0,0,t),n}if(e.length!==void 0)return typeof e.length!="number"||qn(e.length)?X(0):An(e);if(e.type==="Buffer"&&Array.isArray(e.data))return An(e.data)}function Bn(e){if(e>=Ge)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Ge.toString(16)+" bytes");return e|0}function Ir(e){return+e!=e&&(e=0),s.alloc(+e)}s.isBuffer=function(t){return t!=null&&t._isBuffer===!0&&t!==s.prototype};s.compare=function(t,n){if(U(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),U(n,Uint8Array)&&(n=s.from(n,n.offset,n.byteLength)),!s.isBuffer(t)||!s.isBuffer(n))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===n)return 0;for(var o=t.length,r=n.length,i=0,a=Math.min(o,r);i<a;++i)if(t[i]!==n[i]){o=t[i],r=n[i];break}return o<r?-1:r<o?1:0};s.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};s.concat=function(t,n){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return s.alloc(0);var o;if(n===void 0)for(n=0,o=0;o<t.length;++o)n+=t[o].length;var r=s.allocUnsafe(n),i=0;for(o=0;o<t.length;++o){var a=t[o];if(U(a,Uint8Array))i+a.length>r.length?s.from(a).copy(r,i):Uint8Array.prototype.set.call(r,a,i);else if(s.isBuffer(a))a.copy(r,i);else throw new TypeError('"list" argument must be an Array of Buffers');i+=a.length}return r};function mo(e,t){if(s.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||U(e,ArrayBuffer))return e.byteLength;if(typeof e!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);var n=e.length,o=arguments.length>2&&arguments[2]===!0;if(!o&&n===0)return 0;for(var r=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return En(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return n*2;case"hex":return n>>>1;case"base64":return Ro(e).length;default:if(r)return o?-1:En(e).length;t=(""+t).toLowerCase(),r=!0}}s.byteLength=mo;function Dr(e,t,n){var o=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((n===void 0||n>this.length)&&(n=this.length),n<=0)||(n>>>=0,t>>>=0,n<=t))return"";for(e||(e="utf8");;)switch(e){case"hex":return ci(this,t,n);case"utf8":case"utf-8":return wo(this,t,n);case"ascii":return ai(this,t,n);case"latin1":case"binary":return si(this,t,n);case"base64":return ri(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ui(this,t,n);default:if(o)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),o=!0}}s.prototype._isBuffer=!0;function ce(e,t,n){var o=e[t];e[t]=e[n],e[n]=o}s.prototype.swap16=function(){var t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var n=0;n<t;n+=2)ce(this,n,n+1);return this};s.prototype.swap32=function(){var t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var n=0;n<t;n+=4)ce(this,n,n+3),ce(this,n+1,n+2);return this};s.prototype.swap64=function(){var t=this.length;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var n=0;n<t;n+=8)ce(this,n,n+7),ce(this,n+1,n+6),ce(this,n+2,n+5),ce(this,n+3,n+4);return this};s.prototype.toString=function(){var t=this.length;return t===0?"":arguments.length===0?wo(this,0,t):Dr.apply(this,arguments)};s.prototype.toLocaleString=s.prototype.toString;s.prototype.equals=function(t){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:s.compare(this,t)===0};s.prototype.inspect=function(){var t="",n=pe.INSPECT_MAX_BYTES;return t=this.toString("hex",0,n).replace(/(.{2})/g,"$1 ").trim(),this.length>n&&(t+=" ... "),"<Buffer "+t+">"};co&&(s.prototype[co]=s.prototype.inspect);s.prototype.compare=function(t,n,o,r,i){if(U(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(n===void 0&&(n=0),o===void 0&&(o=t?t.length:0),r===void 0&&(r=0),i===void 0&&(i=this.length),n<0||o>t.length||r<0||i>this.length)throw new RangeError("out of range index");if(r>=i&&n>=o)return 0;if(r>=i)return-1;if(n>=o)return 1;if(n>>>=0,o>>>=0,r>>>=0,i>>>=0,this===t)return 0;for(var a=i-r,c=o-n,d=Math.min(a,c),l=this.slice(r,i),m=t.slice(n,o),p=0;p<d;++p)if(l[p]!==m[p]){a=l[p],c=m[p];break}return a<c?-1:c<a?1:0};function fo(e,t,n,o,r){if(e.length===0)return-1;if(typeof n=="string"?(o=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,qn(n)&&(n=r?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(r)return-1;n=e.length-1}else if(n<0)if(r)n=0;else return-1;if(typeof t=="string"&&(t=s.from(t,o)),s.isBuffer(t))return t.length===0?-1:uo(e,t,n,o,r);if(typeof t=="number")return t=t&255,typeof Uint8Array.prototype.indexOf=="function"?r?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):uo(e,[t],n,o,r);throw new TypeError("val must be string, number or Buffer")}function uo(e,t,n,o,r){var i=1,a=e.length,c=t.length;if(o!==void 0&&(o=String(o).toLowerCase(),o==="ucs2"||o==="ucs-2"||o==="utf16le"||o==="utf-16le")){if(e.length<2||t.length<2)return-1;i=2,a/=2,c/=2,n/=2}function d(N,k){return i===1?N[k]:N.readUInt16BE(k*i)}var l;if(r){var m=-1;for(l=n;l<a;l++)if(d(e,l)===d(t,m===-1?0:l-m)){if(m===-1&&(m=l),l-m+1===c)return m*i}else m!==-1&&(l-=l-m),m=-1}else for(n+c>a&&(n=a-c),l=n;l>=0;l--){for(var p=!0,y=0;y<c;y++)if(d(e,l+y)!==d(t,y)){p=!1;break}if(p)return l}return-1}s.prototype.includes=function(t,n,o){return this.indexOf(t,n,o)!==-1};s.prototype.indexOf=function(t,n,o){return fo(this,t,n,o,!0)};s.prototype.lastIndexOf=function(t,n,o){return fo(this,t,n,o,!1)};function Lr(e,t,n,o){n=Number(n)||0;var r=e.length-n;o?(o=Number(o),o>r&&(o=r)):o=r;var i=t.length;o>i/2&&(o=i/2);for(var a=0;a<o;++a){var c=parseInt(t.substr(a*2,2),16);if(qn(c))return a;e[n+a]=c}return a}function ei(e,t,n,o){return je(En(t,e.length-n),e,n,o)}function ti(e,t,n,o){return je(_i(t),e,n,o)}function ni(e,t,n,o){return je(Ro(t),e,n,o)}function oi(e,t,n,o){return je(li(t,e.length-n),e,n,o)}s.prototype.write=function(t,n,o,r){if(n===void 0)r="utf8",o=this.length,n=0;else if(o===void 0&&typeof n=="string")r=n,o=this.length,n=0;else if(isFinite(n))n=n>>>0,isFinite(o)?(o=o>>>0,r===void 0&&(r="utf8")):(r=o,o=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var i=this.length-n;if((o===void 0||o>i)&&(o=i),t.length>0&&(o<0||n<0)||n>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var a=!1;;)switch(r){case"hex":return Lr(this,t,n,o);case"utf8":case"utf-8":return ei(this,t,n,o);case"ascii":case"latin1":case"binary":return ti(this,t,n,o);case"base64":return ni(this,t,n,o);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return oi(this,t,n,o);default:if(a)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),a=!0}};s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function ri(e,t,n){return t===0&&n===e.length?Mn.fromByteArray(e):Mn.fromByteArray(e.slice(t,n))}function wo(e,t,n){n=Math.min(e.length,n);for(var o=[],r=t;r<n;){var i=e[r],a=null,c=i>239?4:i>223?3:i>191?2:1;if(r+c<=n){var d,l,m,p;switch(c){case 1:i<128&&(a=i);break;case 2:d=e[r+1],(d&192)===128&&(p=(i&31)<<6|d&63,p>127&&(a=p));break;case 3:d=e[r+1],l=e[r+2],(d&192)===128&&(l&192)===128&&(p=(i&15)<<12|(d&63)<<6|l&63,p>2047&&(p<55296||p>57343)&&(a=p));break;case 4:d=e[r+1],l=e[r+2],m=e[r+3],(d&192)===128&&(l&192)===128&&(m&192)===128&&(p=(i&15)<<18|(d&63)<<12|(l&63)<<6|m&63,p>65535&&p<1114112&&(a=p))}}a===null?(a=65533,c=1):a>65535&&(a-=65536,o.push(a>>>10&1023|55296),a=56320|a&1023),o.push(a),r+=c}return ii(o)}var po=4096;function ii(e){var t=e.length;if(t<=po)return String.fromCharCode.apply(String,e);for(var n="",o=0;o<t;)n+=String.fromCharCode.apply(String,e.slice(o,o+=po));return n}function ai(e,t,n){var o="";n=Math.min(e.length,n);for(var r=t;r<n;++r)o+=String.fromCharCode(e[r]&127);return o}function si(e,t,n){var o="";n=Math.min(e.length,n);for(var r=t;r<n;++r)o+=String.fromCharCode(e[r]);return o}function ci(e,t,n){var o=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>o)&&(n=o);for(var r="",i=t;i<n;++i)r+=mi[e[i]];return r}function ui(e,t,n){for(var o=e.slice(t,n),r="",i=0;i<o.length-1;i+=2)r+=String.fromCharCode(o[i]+o[i+1]*256);return r}s.prototype.slice=function(t,n){var o=this.length;t=~~t,n=n===void 0?o:~~n,t<0?(t+=o,t<0&&(t=0)):t>o&&(t=o),n<0?(n+=o,n<0&&(n=0)):n>o&&(n=o),n<t&&(n=t);var r=this.subarray(t,n);return Object.setPrototypeOf(r,s.prototype),r};function v(e,t,n){if(e%1!==0||e<0)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}s.prototype.readUintLE=s.prototype.readUIntLE=function(t,n,o){t=t>>>0,n=n>>>0,o||v(t,n,this.length);for(var r=this[t],i=1,a=0;++a<n&&(i*=256);)r+=this[t+a]*i;return r};s.prototype.readUintBE=s.prototype.readUIntBE=function(t,n,o){t=t>>>0,n=n>>>0,o||v(t,n,this.length);for(var r=this[t+--n],i=1;n>0&&(i*=256);)r+=this[t+--n]*i;return r};s.prototype.readUint8=s.prototype.readUInt8=function(t,n){return t=t>>>0,n||v(t,1,this.length),this[t]};s.prototype.readUint16LE=s.prototype.readUInt16LE=function(t,n){return t=t>>>0,n||v(t,2,this.length),this[t]|this[t+1]<<8};s.prototype.readUint16BE=s.prototype.readUInt16BE=function(t,n){return t=t>>>0,n||v(t,2,this.length),this[t]<<8|this[t+1]};s.prototype.readUint32LE=s.prototype.readUInt32LE=function(t,n){return t=t>>>0,n||v(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216};s.prototype.readUint32BE=s.prototype.readUInt32BE=function(t,n){return t=t>>>0,n||v(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])};s.prototype.readIntLE=function(t,n,o){t=t>>>0,n=n>>>0,o||v(t,n,this.length);for(var r=this[t],i=1,a=0;++a<n&&(i*=256);)r+=this[t+a]*i;return i*=128,r>=i&&(r-=Math.pow(2,8*n)),r};s.prototype.readIntBE=function(t,n,o){t=t>>>0,n=n>>>0,o||v(t,n,this.length);for(var r=n,i=1,a=this[t+--r];r>0&&(i*=256);)a+=this[t+--r]*i;return i*=128,a>=i&&(a-=Math.pow(2,8*n)),a};s.prototype.readInt8=function(t,n){return t=t>>>0,n||v(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]};s.prototype.readInt16LE=function(t,n){t=t>>>0,n||v(t,2,this.length);var o=this[t]|this[t+1]<<8;return o&32768?o|4294901760:o};s.prototype.readInt16BE=function(t,n){t=t>>>0,n||v(t,2,this.length);var o=this[t+1]|this[t]<<8;return o&32768?o|4294901760:o};s.prototype.readInt32LE=function(t,n){return t=t>>>0,n||v(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24};s.prototype.readInt32BE=function(t,n){return t=t>>>0,n||v(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]};s.prototype.readFloatLE=function(t,n){return t=t>>>0,n||v(t,4,this.length),de.read(this,t,!0,23,4)};s.prototype.readFloatBE=function(t,n){return t=t>>>0,n||v(t,4,this.length),de.read(this,t,!1,23,4)};s.prototype.readDoubleLE=function(t,n){return t=t>>>0,n||v(t,8,this.length),de.read(this,t,!0,52,8)};s.prototype.readDoubleBE=function(t,n){return t=t>>>0,n||v(t,8,this.length),de.read(this,t,!1,52,8)};function S(e,t,n,o,r,i){if(!s.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>r||t<i)throw new RangeError('"value" argument is out of bounds');if(n+o>e.length)throw new RangeError("Index out of range")}s.prototype.writeUintLE=s.prototype.writeUIntLE=function(t,n,o,r){if(t=+t,n=n>>>0,o=o>>>0,!r){var i=Math.pow(2,8*o)-1;S(this,t,n,o,i,0)}var a=1,c=0;for(this[n]=t&255;++c<o&&(a*=256);)this[n+c]=t/a&255;return n+o};s.prototype.writeUintBE=s.prototype.writeUIntBE=function(t,n,o,r){if(t=+t,n=n>>>0,o=o>>>0,!r){var i=Math.pow(2,8*o)-1;S(this,t,n,o,i,0)}var a=o-1,c=1;for(this[n+a]=t&255;--a>=0&&(c*=256);)this[n+a]=t/c&255;return n+o};s.prototype.writeUint8=s.prototype.writeUInt8=function(t,n,o){return t=+t,n=n>>>0,o||S(this,t,n,1,255,0),this[n]=t&255,n+1};s.prototype.writeUint16LE=s.prototype.writeUInt16LE=function(t,n,o){return t=+t,n=n>>>0,o||S(this,t,n,2,65535,0),this[n]=t&255,this[n+1]=t>>>8,n+2};s.prototype.writeUint16BE=s.prototype.writeUInt16BE=function(t,n,o){return t=+t,n=n>>>0,o||S(this,t,n,2,65535,0),this[n]=t>>>8,this[n+1]=t&255,n+2};s.prototype.writeUint32LE=s.prototype.writeUInt32LE=function(t,n,o){return t=+t,n=n>>>0,o||S(this,t,n,4,4294967295,0),this[n+3]=t>>>24,this[n+2]=t>>>16,this[n+1]=t>>>8,this[n]=t&255,n+4};s.prototype.writeUint32BE=s.prototype.writeUInt32BE=function(t,n,o){return t=+t,n=n>>>0,o||S(this,t,n,4,4294967295,0),this[n]=t>>>24,this[n+1]=t>>>16,this[n+2]=t>>>8,this[n+3]=t&255,n+4};s.prototype.writeIntLE=function(t,n,o,r){if(t=+t,n=n>>>0,!r){var i=Math.pow(2,8*o-1);S(this,t,n,o,i-1,-i)}var a=0,c=1,d=0;for(this[n]=t&255;++a<o&&(c*=256);)t<0&&d===0&&this[n+a-1]!==0&&(d=1),this[n+a]=(t/c>>0)-d&255;return n+o};s.prototype.writeIntBE=function(t,n,o,r){if(t=+t,n=n>>>0,!r){var i=Math.pow(2,8*o-1);S(this,t,n,o,i-1,-i)}var a=o-1,c=1,d=0;for(this[n+a]=t&255;--a>=0&&(c*=256);)t<0&&d===0&&this[n+a+1]!==0&&(d=1),this[n+a]=(t/c>>0)-d&255;return n+o};s.prototype.writeInt8=function(t,n,o){return t=+t,n=n>>>0,o||S(this,t,n,1,127,-128),t<0&&(t=255+t+1),this[n]=t&255,n+1};s.prototype.writeInt16LE=function(t,n,o){return t=+t,n=n>>>0,o||S(this,t,n,2,32767,-32768),this[n]=t&255,this[n+1]=t>>>8,n+2};s.prototype.writeInt16BE=function(t,n,o){return t=+t,n=n>>>0,o||S(this,t,n,2,32767,-32768),this[n]=t>>>8,this[n+1]=t&255,n+2};s.prototype.writeInt32LE=function(t,n,o){return t=+t,n=n>>>0,o||S(this,t,n,4,2147483647,-2147483648),this[n]=t&255,this[n+1]=t>>>8,this[n+2]=t>>>16,this[n+3]=t>>>24,n+4};s.prototype.writeInt32BE=function(t,n,o){return t=+t,n=n>>>0,o||S(this,t,n,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[n]=t>>>24,this[n+1]=t>>>16,this[n+2]=t>>>8,this[n+3]=t&255,n+4};function No(e,t,n,o,r,i){if(n+o>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function go(e,t,n,o,r){return t=+t,n=n>>>0,r||No(e,t,n,4,34028234663852886e22,-34028234663852886e22),de.write(e,t,n,o,23,4),n+4}s.prototype.writeFloatLE=function(t,n,o){return go(this,t,n,!0,o)};s.prototype.writeFloatBE=function(t,n,o){return go(this,t,n,!1,o)};function yo(e,t,n,o,r){return t=+t,n=n>>>0,r||No(e,t,n,8,17976931348623157e292,-17976931348623157e292),de.write(e,t,n,o,52,8),n+8}s.prototype.writeDoubleLE=function(t,n,o){return yo(this,t,n,!0,o)};s.prototype.writeDoubleBE=function(t,n,o){return yo(this,t,n,!1,o)};s.prototype.copy=function(t,n,o,r){if(!s.isBuffer(t))throw new TypeError("argument should be a Buffer");if(o||(o=0),!r&&r!==0&&(r=this.length),n>=t.length&&(n=t.length),n||(n=0),r>0&&r<o&&(r=o),r===o||t.length===0||this.length===0)return 0;if(n<0)throw new RangeError("targetStart out of bounds");if(o<0||o>=this.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),t.length-n<r-o&&(r=t.length-n+o);var i=r-o;return this===t&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(n,o,r):Uint8Array.prototype.set.call(t,this.subarray(o,r),n),i};s.prototype.fill=function(t,n,o,r){if(typeof t=="string"){if(typeof n=="string"?(r=n,n=0,o=this.length):typeof o=="string"&&(r=o,o=this.length),r!==void 0&&typeof r!="string")throw new TypeError("encoding must be a string");if(typeof r=="string"&&!s.isEncoding(r))throw new TypeError("Unknown encoding: "+r);if(t.length===1){var i=t.charCodeAt(0);(r==="utf8"&&i<128||r==="latin1")&&(t=i)}}else typeof t=="number"?t=t&255:typeof t=="boolean"&&(t=Number(t));if(n<0||this.length<n||this.length<o)throw new RangeError("Out of range index");if(o<=n)return this;n=n>>>0,o=o===void 0?this.length:o>>>0,t||(t=0);var a;if(typeof t=="number")for(a=n;a<o;++a)this[a]=t;else{var c=s.isBuffer(t)?t:s.from(t,r),d=c.length;if(d===0)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(a=0;a<o-n;++a)this[a+n]=c[a%d]}return this};var di=/[^+/0-9A-Za-z-_]/g;function pi(e){if(e=e.split("=")[0],e=e.trim().replace(di,""),e.length<2)return"";for(;e.length%4!==0;)e=e+"=";return e}function En(e,t){t=t||1/0;for(var n,o=e.length,r=null,i=[],a=0;a<o;++a){if(n=e.charCodeAt(a),n>55295&&n<57344){if(!r){if(n>56319){(t-=3)>-1&&i.push(239,191,189);continue}else if(a+1===o){(t-=3)>-1&&i.push(239,191,189);continue}r=n;continue}if(n<56320){(t-=3)>-1&&i.push(239,191,189),r=n;continue}n=(r-55296<<10|n-56320)+65536}else r&&(t-=3)>-1&&i.push(239,191,189);if(r=null,n<128){if((t-=1)<0)break;i.push(n)}else if(n<2048){if((t-=2)<0)break;i.push(n>>6|192,n&63|128)}else if(n<65536){if((t-=3)<0)break;i.push(n>>12|224,n>>6&63|128,n&63|128)}else if(n<1114112){if((t-=4)<0)break;i.push(n>>18|240,n>>12&63|128,n>>6&63|128,n&63|128)}else throw new Error("Invalid code point")}return i}function _i(e){for(var t=[],n=0;n<e.length;++n)t.push(e.charCodeAt(n)&255);return t}function li(e,t){for(var n,o,r,i=[],a=0;a<e.length&&!((t-=2)<0);++a)n=e.charCodeAt(a),o=n>>8,r=n%256,i.push(r),i.push(o);return i}function Ro(e){return Mn.toByteArray(pi(e))}function je(e,t,n,o){for(var r=0;r<o&&!(r+n>=t.length||r>=e.length);++r)t[r+n]=e[r];return r}function U(e,t){return e instanceof t||e!=null&&e.constructor!=null&&e.constructor.name!=null&&e.constructor.name===t.name}function qn(e){return e!==e}var mi=function(){for(var e="0123456789abcdef",t=new Array(256),n=0;n<16;++n)for(var o=n*16,r=0;r<16;++r)t[o+r]=e[n]+e[r];return t}()});var xo=Ee((Un,Oo)=>{var ze=vo(),Y=ze.Buffer;function ho(e,t){for(var n in e)t[n]=e[n]}Y.from&&Y.alloc&&Y.allocUnsafe&&Y.allocUnsafeSlow?Oo.exports=ze:(ho(ze,Un),Un.Buffer=_e);function _e(e,t,n){return Y(e,t,n)}ho(Y,_e);_e.from=function(e,t,n){if(typeof e=="number")throw new TypeError("Argument must not be a number");return Y(e,t,n)};_e.alloc=function(e,t,n){if(typeof e!="number")throw new TypeError("Argument must be a number");var o=Y(e);return t!==void 0?typeof n=="string"?o.fill(t,n):o.fill(t):o.fill(0),o};_e.allocUnsafe=function(e){if(typeof e!="number")throw new TypeError("Argument must be a number");return Y(e)};_e.allocUnsafeSlow=function(e){if(typeof e!="number")throw new TypeError("Argument must be a number");return ze.SlowBuffer(e)}});var bo=Ee((Ua,Hn)=>{"use strict";var Kn=65536,fi=4294967295;function wi(){throw new Error(`Secure random number generation is not supported by this browser.
2
- Use Chrome, Firefox or Internet Explorer 11`)}var Ni=xo().Buffer,$e=window.crypto||window.msCrypto;$e&&$e.getRandomValues?Hn.exports=gi:Hn.exports=wi;function gi(e,t){if(e>fi)throw new RangeError("requested too many random bytes");var n=Ni.allocUnsafe(e);if(e>0)if(e>Kn)for(var o=0;o<e;o+=Kn)$e.getRandomValues(n.slice(o,o+Kn));else $e.getRandomValues(n);return typeof t=="function"?process.nextTick(function(){t(null,n)}):n}});import{AccountIdentifier as Zn,SubAccount as ha,checkAccountId as Sr}from"@dfinity/ledger-icp";import{arrayOfNumberToUint8Array as Oa,asciiStringToByteArray as xa,assertPercentageNumber as In,createServices as ba,fromNullable as P,isNullish as Dn,nonNullish as B,uint8ArrayToBigInt as kr}from"@dfinity/utils";function Mr(e,...t){if(!(e instanceof Uint8Array))throw new Error("Expected Uint8Array");if(t.length>0&&!t.includes(e.length))throw new Error(`Expected Uint8Array of length ${t}, not of length=${e.length}`)}function Sn(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function to(e,t){Mr(e);let n=t.outputLen;if(e.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}var Ar=e=>e instanceof Uint8Array;var Ke=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),E=(e,t)=>e<<32-t|e>>>t,Vr=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!Vr)throw new Error("Non little-endian hardware is not supported");function Er(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function kn(e){if(typeof e=="string"&&(e=Er(e)),!Ar(e))throw new Error(`expected Uint8Array, got ${typeof e}`);return e}var Ue=class{clone(){return this._cloneInto()}},ka={}.toString;function no(e){let t=o=>e().update(kn(o)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function Fr(e,t,n,o){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,n,o);let r=BigInt(32),i=BigInt(4294967295),a=Number(n>>r&i),c=Number(n&i),d=o?4:0,l=o?0:4;e.setUint32(t+d,a,o),e.setUint32(t+l,c,o)}var He=class extends Ue{constructor(t,n,o,r){super(),this.blockLen=t,this.outputLen=n,this.padOffset=o,this.isLE=r,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=Ke(this.buffer)}update(t){Sn(this);let{view:n,buffer:o,blockLen:r}=this;t=kn(t);let i=t.length;for(let a=0;a<i;){let c=Math.min(r-this.pos,i-a);if(c===r){let d=Ke(t);for(;r<=i-a;a+=r)this.process(d,a);continue}o.set(t.subarray(a,a+c),this.pos),this.pos+=c,a+=c,this.pos===r&&(this.process(n,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){Sn(this),to(t,this),this.finished=!0;let{buffer:n,view:o,blockLen:r,isLE:i}=this,{pos:a}=this;n[a++]=128,this.buffer.subarray(a).fill(0),this.padOffset>r-a&&(this.process(o,0),a=0);for(let p=a;p<r;p++)n[p]=0;Fr(o,r-8,BigInt(this.length*8),i),this.process(o,0);let c=Ke(t),d=this.outputLen;if(d%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let l=d/4,m=this.get();if(l>m.length)throw new Error("_sha2: outputLen bigger than state");for(let p=0;p<l;p++)c.setUint32(4*p,m[p],i)}digest(){let{buffer:t,outputLen:n}=this;this.digestInto(t);let o=t.slice(0,n);return this.destroy(),o}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:n,buffer:o,length:r,finished:i,destroyed:a,pos:c}=this;return t.length=r,t.pos=c,t.finished=i,t.destroyed=a,r%n&&t.buffer.set(o),t}};var Br=(e,t,n)=>e&t^~e&n,qr=(e,t,n)=>e&t^e&n^t&n,Ur=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),I=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),D=new Uint32Array(64),Tn=class extends He{constructor(){super(64,32,8,!1),this.A=I[0]|0,this.B=I[1]|0,this.C=I[2]|0,this.D=I[3]|0,this.E=I[4]|0,this.F=I[5]|0,this.G=I[6]|0,this.H=I[7]|0}get(){let{A:t,B:n,C:o,D:r,E:i,F:a,G:c,H:d}=this;return[t,n,o,r,i,a,c,d]}set(t,n,o,r,i,a,c,d){this.A=t|0,this.B=n|0,this.C=o|0,this.D=r|0,this.E=i|0,this.F=a|0,this.G=c|0,this.H=d|0}process(t,n){for(let p=0;p<16;p++,n+=4)D[p]=t.getUint32(n,!1);for(let p=16;p<64;p++){let y=D[p-15],N=D[p-2],k=E(y,7)^E(y,18)^y>>>3,f=E(N,17)^E(N,19)^N>>>10;D[p]=f+D[p-7]+k+D[p-16]|0}let{A:o,B:r,C:i,D:a,E:c,F:d,G:l,H:m}=this;for(let p=0;p<64;p++){let y=E(c,6)^E(c,11)^E(c,25),N=m+y+Br(c,d,l)+Ur[p]+D[p]|0,f=(E(o,2)^E(o,13)^E(o,22))+qr(o,r,i)|0;m=l,l=d,d=c,c=a+N|0,a=i,i=r,r=o,o=N+f|0}o=o+this.A|0,r=r+this.B|0,i=i+this.C|0,a=a+this.D|0,c=c+this.E|0,d=d+this.F|0,l=l+this.G|0,m=m+this.H|0,this.set(o,r,i,a,c,d,l,m)}roundClean(){D.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var oo=no(()=>new Tn);var Ln=Cr(bo());var So=({IDL:e})=>{let t=e.Rec(),n=e.Record({id:e.Nat64}),o=e.Record({followees:e.Vec(n)}),r=e.Record({name:e.Text,description:e.Opt(e.Text)}),i=e.Record({id:e.Opt(n),known_neuron_data:e.Opt(r)}),a=e.Record({percentage_to_spawn:e.Opt(e.Nat32),new_controller:e.Opt(e.Principal),nonce:e.Opt(e.Nat64)}),c=e.Record({amount_e8s:e.Nat64}),d=e.Record({topic:e.Int32,followees:e.Vec(n)}),l=e.Record({controller:e.Opt(e.Principal),memo:e.Nat64}),m=e.Variant({NeuronIdOrSubaccount:e.Record({}),MemoAndController:l,Memo:e.Nat64}),p=e.Record({by:e.Opt(m)}),y=e.Record({hot_key_to_remove:e.Opt(e.Principal)}),N=e.Record({new_hot_key:e.Opt(e.Principal)}),k=e.Record({requested_setting_for_auto_stake_maturity:e.Bool}),f=e.Record({additional_dissolve_delay_seconds:e.Nat32}),et=e.Record({dissolve_timestamp_seconds:e.Nat64}),tt=e.Variant({RemoveHotKey:y,AddHotKey:N,ChangeAutoStakeMaturity:k,StopDissolving:e.Record({}),StartDissolving:e.Record({}),IncreaseDissolveDelay:f,JoinCommunityFund:e.Record({}),LeaveCommunityFund:e.Record({}),SetDissolveTimestamp:et}),le=e.Record({operation:e.Opt(tt)}),nt=e.Record({vote:e.Int32,proposal:e.Opt(n)}),me=e.Record({source_neuron_id:e.Opt(n)}),fe=e.Record({dissolve_delay_seconds:e.Nat64,kyc_verified:e.Bool,amount_e8s:e.Nat64,new_controller:e.Opt(e.Principal),nonce:e.Nat64}),ot=e.Record({percentage_to_stake:e.Opt(e.Nat32)}),we=e.Record({percentage_to_merge:e.Nat32}),j=e.Record({hash:e.Vec(e.Nat8)}),rt=e.Record({e8s:e.Nat64}),Ne=e.Record({to_account:e.Opt(j),amount:e.Opt(rt)}),it=e.Variant({Spawn:a,Split:c,Follow:d,ClaimOrRefresh:p,Configure:le,RegisterVote:nt,Merge:me,DisburseToNeuron:fe,MakeProposal:t,StakeMaturity:ot,MergeMaturity:we,Disburse:Ne}),te=e.Variant({Subaccount:e.Vec(e.Nat8),NeuronId:n}),ne=e.Record({id:e.Opt(n),command:e.Opt(it),neuron_id_or_subaccount:e.Opt(te)}),z=e.Record({basis_points:e.Opt(e.Nat64)}),R=e.Record({seconds:e.Opt(e.Nat64)}),w=e.Record({e8s:e.Opt(e.Nat64)}),at=e.Record({reward_rate_transition_duration:e.Opt(R),initial_reward_rate:e.Opt(z),final_reward_rate:e.Opt(z)}),st=e.Record({neuron_maximum_dissolve_delay_bonus:e.Opt(z),neuron_maximum_age_for_age_bonus:e.Opt(R),neuron_maximum_dissolve_delay:e.Opt(R),neuron_minimum_dissolve_delay_to_vote:e.Opt(R),neuron_maximum_age_bonus:e.Opt(z),neuron_minimum_stake:e.Opt(w),proposal_wait_for_quiet_deadline_increase:e.Opt(R),proposal_initial_voting_period:e.Opt(R),proposal_rejection_fee:e.Opt(w),voting_reward_parameters:e.Opt(at)}),ge=e.Record({base64_encoding:e.Opt(e.Text)}),ct=e.Record({transaction_fee:e.Opt(w),token_symbol:e.Opt(e.Text),token_logo:e.Opt(ge),token_name:e.Opt(e.Text)}),ut=e.Record({id:e.Opt(e.Principal)}),dt=e.Record({dissolve_delay_interval:e.Opt(R),count:e.Opt(e.Nat64)}),pt=e.Record({seconds_after_utc_midnight:e.Opt(e.Nat64)}),_t=e.Record({iso_codes:e.Vec(e.Text)}),lt=e.Record({minimum_participants:e.Opt(e.Nat64),neurons_fund_participation:e.Opt(e.Bool),duration:e.Opt(R),neuron_basket_construction_parameters:e.Opt(dt),confirmation_text:e.Opt(e.Text),maximum_participant_icp:e.Opt(w),minimum_icp:e.Opt(w),minimum_direct_participation_icp:e.Opt(w),minimum_participant_icp:e.Opt(w),start_time:e.Opt(pt),maximum_direct_participation_icp:e.Opt(w),maximum_icp:e.Opt(w),neurons_fund_investment_icp:e.Opt(w),restricted_countries:e.Opt(_t)}),u=e.Record({total:e.Opt(w)}),mt=e.Record({controller:e.Opt(e.Principal),dissolve_delay:e.Opt(R),memo:e.Opt(e.Nat64),vesting_period:e.Opt(R),stake:e.Opt(w)}),ft=e.Record({developer_neurons:e.Vec(mt)}),wt=e.Record({treasury_distribution:e.Opt(u),developer_distribution:e.Opt(ft),swap_distribution:e.Opt(u)}),Nt=e.Record({url:e.Opt(e.Text),governance_parameters:e.Opt(st),fallback_controller_principal_ids:e.Vec(e.Principal),logo:e.Opt(ge),name:e.Opt(e.Text),ledger_parameters:e.Opt(ct),description:e.Opt(e.Text),dapp_canisters:e.Vec(ut),swap_parameters:e.Opt(lt),initial_token_distribution:e.Opt(wt)}),gt=e.Record({nns_function:e.Int32,payload:e.Vec(e.Nat8)}),T=e.Record({id:e.Opt(e.Principal),reward_account:e.Opt(j)}),yt=e.Record({dissolve_delay_seconds:e.Nat64}),Rt=e.Record({to_account:e.Opt(j)}),vt=e.Variant({RewardToNeuron:yt,RewardToAccount:Rt}),oe=e.Record({node_provider:e.Opt(T),reward_mode:e.Opt(vt),amount_e8s:e.Nat64}),ht=e.Record({dissolve_delay_interval_seconds:e.Nat64,count:e.Nat64}),Ot=e.Record({min_participant_icp_e8s:e.Nat64,neuron_basket_construction_parameters:e.Opt(ht),max_icp_e8s:e.Nat64,swap_due_timestamp_seconds:e.Nat64,min_participants:e.Nat32,sns_token_e8s:e.Nat64,sale_delay_seconds:e.Opt(e.Nat64),max_participant_icp_e8s:e.Nat64,min_direct_participation_icp_e8s:e.Opt(e.Nat64),min_icp_e8s:e.Nat64,max_direct_participation_icp_e8s:e.Opt(e.Nat64)}),xt=e.Record({community_fund_investment_e8s:e.Opt(e.Nat64),target_swap_canister_id:e.Opt(e.Principal),params:e.Opt(Ot)}),bt=e.Record({start_timestamp_seconds:e.Nat64,end_timestamp_seconds:e.Nat64}),St=e.Record({open_time_window:e.Opt(bt)}),kt=e.Record({request:e.Opt(St),swap_canister_id:e.Opt(e.Principal)}),Tt=e.Record({default_followees:e.Vec(e.Tuple(e.Int32,o))}),ye=e.Record({use_registry_derived_rewards:e.Opt(e.Bool),rewards:e.Vec(oe)}),re=e.Record({neuron_minimum_stake_e8s:e.Nat64,max_proposals_to_keep_per_topic:e.Nat32,neuron_management_fee_per_proposal_e8s:e.Nat64,reject_cost_e8s:e.Nat64,transaction_fee_e8s:e.Nat64,neuron_spawn_dissolve_delay_seconds:e.Nat64,minimum_icp_xdr_rate:e.Nat64,maximum_node_provider_rewards_e8s:e.Nat64}),Pt=e.Record({principals:e.Vec(e.Principal)}),Ct=e.Variant({ToRemove:T,ToAdd:T}),Mt=e.Record({change:e.Opt(Ct)}),At=e.Record({motion_text:e.Text}),Vt=e.Variant({RegisterKnownNeuron:i,ManageNeuron:ne,CreateServiceNervousSystem:Nt,ExecuteNnsFunction:gt,RewardNodeProvider:oe,OpenSnsTokenSwap:xt,SetSnsTokenSwapOpenTimeWindow:kt,SetDefaultFollowees:Tt,RewardNodeProviders:ye,ManageNetworkEconomics:re,ApproveGenesisKyc:Pt,AddOrRemoveNodeProvider:Mt,Motion:At});t.fill(e.Record({url:e.Text,title:e.Opt(e.Text),action:e.Opt(Vt),summary:e.Text}));let Et=e.Record({proposal:e.Opt(t),caller:e.Opt(e.Principal),proposer_id:e.Opt(n)}),Re=e.Record({timestamp:e.Nat64,rewards:e.Vec(oe)}),ve=e.Record({total_maturity_e8s_equivalent:e.Nat64,not_dissolving_neurons_e8s_buckets:e.Vec(e.Tuple(e.Nat64,e.Float64)),dissolving_neurons_staked_maturity_e8s_equivalent_sum:e.Nat64,garbage_collectable_neurons_count:e.Nat64,dissolving_neurons_staked_maturity_e8s_equivalent_buckets:e.Vec(e.Tuple(e.Nat64,e.Float64)),neurons_with_invalid_stake_count:e.Nat64,not_dissolving_neurons_count_buckets:e.Vec(e.Tuple(e.Nat64,e.Nat64)),total_supply_icp:e.Nat64,neurons_with_less_than_6_months_dissolve_delay_count:e.Nat64,dissolved_neurons_count:e.Nat64,community_fund_total_maturity_e8s_equivalent:e.Nat64,total_staked_e8s:e.Nat64,not_dissolving_neurons_count:e.Nat64,total_locked_e8s:e.Nat64,neurons_fund_total_active_neurons:e.Nat64,total_staked_maturity_e8s_equivalent:e.Nat64,not_dissolving_neurons_staked_maturity_e8s_equivalent_sum:e.Nat64,dissolved_neurons_e8s:e.Nat64,neurons_with_less_than_6_months_dissolve_delay_e8s:e.Nat64,not_dissolving_neurons_staked_maturity_e8s_equivalent_buckets:e.Vec(e.Tuple(e.Nat64,e.Float64)),dissolving_neurons_count_buckets:e.Vec(e.Tuple(e.Nat64,e.Nat64)),dissolving_neurons_count:e.Nat64,dissolving_neurons_e8s_buckets:e.Vec(e.Tuple(e.Nat64,e.Float64)),community_fund_total_staked_e8s:e.Nat64,timestamp_seconds:e.Nat64}),he=e.Record({rounds_since_last_distribution:e.Opt(e.Nat64),day_after_genesis:e.Nat64,actual_timestamp_seconds:e.Nat64,total_available_e8s_equivalent:e.Nat64,latest_round_available_e8s_equivalent:e.Opt(e.Nat64),distributed_e8s_equivalent:e.Nat64,settled_proposals:e.Vec(n)}),Oe=e.Record({to_subaccount:e.Vec(e.Nat8),neuron_stake_e8s:e.Nat64,from:e.Opt(e.Principal),memo:e.Nat64,from_subaccount:e.Vec(e.Nat8),transfer_timestamp:e.Nat64,block_height:e.Nat64}),Ft=e.Variant({LastNeuronId:n}),xe=e.Record({status:e.Opt(e.Int32),failure_reason:e.Opt(e.Text),progress:e.Opt(Ft)}),Bt=e.Record({neuron_indexes_migration:e.Opt(xe),copy_inactive_neurons_to_stable_memory_migration:e.Opt(xe)}),g=e.Record({error_message:e.Text,error_type:e.Int32}),qt=e.Record({has_created_neuron_recipes:e.Opt(e.Bool),nns_neuron_id:e.Nat64,amount_icp_e8s:e.Nat64}),Ut=e.Record({hotkey_principal:e.Text,cf_neurons:e.Vec(qt)}),be=e.Record({vote:e.Int32,voting_power:e.Nat64}),Kt=e.Record({min_participant_icp_e8s:e.Opt(e.Nat64),max_participant_icp_e8s:e.Opt(e.Nat64),min_direct_participation_icp_e8s:e.Opt(e.Nat64),max_direct_participation_icp_e8s:e.Opt(e.Nat64)}),Ht=e.Record({hotkey_principal:e.Opt(e.Principal),is_capped:e.Opt(e.Bool),maturity_equivalent_icp_e8s:e.Opt(e.Nat64),nns_neuron_id:e.Opt(n),amount_icp_e8s:e.Opt(e.Nat64)}),Se=e.Record({neurons_fund_neuron_portions:e.Vec(Ht)}),Wt=e.Record({serialized_representation:e.Opt(e.Text)}),ke=e.Record({total_maturity_equivalent_icp_e8s:e.Opt(e.Nat64),intended_neurons_fund_participation_icp_e8s:e.Opt(e.Nat64),direct_participation_icp_e8s:e.Opt(e.Nat64),swap_participation_limits:e.Opt(Kt),max_neurons_fund_swap_participation_icp_e8s:e.Opt(e.Nat64),neurons_fund_reserves:e.Opt(Se),ideal_matched_participation_function:e.Opt(Wt)}),Gt=e.Record({final_neurons_fund_participation:e.Opt(ke),initial_neurons_fund_participation:e.Opt(ke),neurons_fund_refunds:e.Opt(Se)}),jt=e.Record({status:e.Opt(e.Int32),freezing_threshold:e.Opt(e.Nat64),controllers:e.Vec(e.Principal),memory_size:e.Opt(e.Nat64),cycles:e.Opt(e.Nat64),idle_cycles_burned_per_day:e.Opt(e.Nat64),module_hash:e.Vec(e.Nat8)}),x=e.Record({status:e.Opt(jt),canister_id:e.Opt(e.Principal)}),zt=e.Record({ledger_index_canister_summary:e.Opt(x),fallback_controller_principal_ids:e.Vec(e.Principal),ledger_archive_canister_summaries:e.Vec(x),ledger_canister_summary:e.Opt(x),swap_canister_summary:e.Opt(x),governance_canister_summary:e.Opt(x),root_canister_summary:e.Opt(x),dapp_canister_summaries:e.Vec(x)}),Te=e.Record({swap_background_information:e.Opt(zt)}),Pe=e.Record({no:e.Nat64,yes:e.Nat64,total:e.Nat64,timestamp_seconds:e.Nat64}),$t=e.Record({current_deadline_timestamp_seconds:e.Nat64}),Jt=e.Record({id:e.Opt(n),failure_reason:e.Opt(g),cf_participants:e.Vec(Ut),ballots:e.Vec(e.Tuple(e.Nat64,be)),proposal_timestamp_seconds:e.Nat64,reward_event_round:e.Nat64,failed_timestamp_seconds:e.Nat64,neurons_fund_data:e.Opt(Gt),reject_cost_e8s:e.Nat64,derived_proposal_information:e.Opt(Te),latest_tally:e.Opt(Pe),sns_token_swap_lifecycle:e.Opt(e.Int32),decided_timestamp_seconds:e.Nat64,proposal:e.Opt(t),proposer:e.Opt(n),wait_for_quiet_state:e.Opt($t),executed_timestamp_seconds:e.Nat64,original_total_community_fund_maturity_e8s_equivalent:e.Opt(e.Nat64)}),Xt=e.Variant({Spawn:n,Split:c,Configure:le,Merge:me,DisburseToNeuron:fe,SyncCommand:e.Record({}),ClaimOrRefreshNeuron:p,MergeMaturity:we,Disburse:Ne}),Yt=e.Record({command:e.Opt(Xt),timestamp:e.Nat64}),Ce=e.Record({vote:e.Int32,proposal_id:e.Opt(n)}),Qt=e.Variant({DissolveDelaySeconds:e.Nat64,WhenDissolvedTimestampSeconds:e.Nat64}),V=e.Record({id:e.Opt(n),staked_maturity_e8s_equivalent:e.Opt(e.Nat64),controller:e.Opt(e.Principal),recent_ballots:e.Vec(Ce),kyc_verified:e.Bool,not_for_profit:e.Bool,maturity_e8s_equivalent:e.Nat64,cached_neuron_stake_e8s:e.Nat64,created_timestamp_seconds:e.Nat64,auto_stake_maturity:e.Opt(e.Bool),aging_since_timestamp_seconds:e.Nat64,hot_keys:e.Vec(e.Principal),account:e.Vec(e.Nat8),joined_community_fund_timestamp_seconds:e.Opt(e.Nat64),dissolve_state:e.Opt(Qt),followees:e.Vec(e.Tuple(e.Int32,o)),neuron_fees_e8s:e.Nat64,transfer:e.Opt(Oe),known_neuron_data:e.Opt(r),spawn_at_timestamp_seconds:e.Opt(e.Nat64)}),Pr=e.Record({default_followees:e.Vec(e.Tuple(e.Int32,o)),making_sns_proposal:e.Opt(Et),most_recent_monthly_node_provider_rewards:e.Opt(Re),maturity_modulation_last_updated_at_timestamp_seconds:e.Opt(e.Nat64),wait_for_quiet_threshold_seconds:e.Nat64,metrics:e.Opt(ve),neuron_management_voting_period_seconds:e.Opt(e.Nat64),node_providers:e.Vec(T),cached_daily_maturity_modulation_basis_points:e.Opt(e.Int32),economics:e.Opt(re),spawning_neurons:e.Opt(e.Bool),latest_reward_event:e.Opt(he),to_claim_transfers:e.Vec(Oe),short_voting_period_seconds:e.Nat64,migrations:e.Opt(Bt),proposals:e.Vec(e.Tuple(e.Nat64,Jt)),in_flight_commands:e.Vec(e.Tuple(e.Nat64,Yt)),neurons:e.Vec(e.Tuple(e.Nat64,V)),genesis_timestamp_seconds:e.Nat64}),$=e.Variant({Ok:e.Null,Err:g}),Zt=e.Variant({Error:g,NeuronId:n}),It=e.Record({result:e.Opt(Zt)}),Me=e.Variant({Ok:V,Err:g}),Dt=e.Variant({Ok:ve,Err:g}),Lt=e.Variant({Ok:ye,Err:g}),J=e.Record({dissolve_delay_seconds:e.Nat64,recent_ballots:e.Vec(Ce),created_timestamp_seconds:e.Nat64,state:e.Int32,stake_e8s:e.Nat64,joined_community_fund_timestamp_seconds:e.Opt(e.Nat64),retrieved_at_timestamp_seconds:e.Nat64,known_neuron_data:e.Opt(r),voting_power:e.Nat64,age_seconds:e.Nat64}),Ae=e.Variant({Ok:J,Err:g}),en=e.Variant({Ok:T,Err:g}),ie=e.Record({id:e.Opt(n),status:e.Int32,topic:e.Int32,failure_reason:e.Opt(g),ballots:e.Vec(e.Tuple(e.Nat64,be)),proposal_timestamp_seconds:e.Nat64,reward_event_round:e.Nat64,deadline_timestamp_seconds:e.Opt(e.Nat64),failed_timestamp_seconds:e.Nat64,reject_cost_e8s:e.Nat64,derived_proposal_information:e.Opt(Te),latest_tally:e.Opt(Pe),reward_status:e.Int32,decided_timestamp_seconds:e.Nat64,proposal:e.Opt(t),proposer:e.Opt(n),executed_timestamp_seconds:e.Nat64}),tn=e.Record({known_neurons:e.Vec(i)}),nn=e.Record({neuron_ids:e.Vec(e.Nat64),include_neurons_readable_by_caller:e.Bool}),on=e.Record({neuron_infos:e.Vec(e.Tuple(e.Nat64,J)),full_neurons:e.Vec(V)}),rn=e.Record({node_providers:e.Vec(T)}),an=e.Record({include_reward_status:e.Vec(e.Int32),omit_large_fields:e.Opt(e.Bool),before_proposal:e.Opt(n),limit:e.Nat32,exclude_topic:e.Vec(e.Int32),include_all_manage_neuron_proposals:e.Opt(e.Bool),include_status:e.Vec(e.Int32)}),sn=e.Record({proposal_info:e.Vec(ie)}),ae=e.Record({created_neuron_id:e.Opt(n)}),cn=e.Record({refreshed_neuron_id:e.Opt(n)}),un=e.Record({target_neuron:e.Opt(V),source_neuron:e.Opt(V),target_neuron_info:e.Opt(J),source_neuron_info:e.Opt(J)}),dn=e.Record({proposal_id:e.Opt(n)}),pn=e.Record({maturity_e8s:e.Nat64,staked_maturity_e8s:e.Nat64}),_n=e.Record({merged_maturity_e8s:e.Nat64,new_stake_e8s:e.Nat64}),ln=e.Record({transfer_block_height:e.Nat64}),mn=e.Variant({Error:g,Spawn:ae,Split:ae,Follow:e.Record({}),ClaimOrRefresh:cn,Configure:e.Record({}),RegisterVote:e.Record({}),Merge:un,DisburseToNeuron:ae,MakeProposal:dn,StakeMaturity:pn,MergeMaturity:_n,Disburse:ln}),Ve=e.Record({command:e.Opt(mn)}),fn=e.Record({total_direct_contribution_icp_e8s:e.Opt(e.Nat64),total_neurons_fund_contribution_icp_e8s:e.Opt(e.Nat64),sns_governance_canister_id:e.Opt(e.Principal)}),wn=e.Variant({Committed:fn,Aborted:e.Record({})}),Nn=e.Record({result:e.Opt(wn),open_sns_token_swap_proposal_id:e.Opt(e.Nat64)}),gn=e.Record({total_direct_participation_icp_e8s:e.Opt(e.Nat64),total_neurons_fund_participation_icp_e8s:e.Opt(e.Nat64),sns_governance_canister_id:e.Opt(e.Principal)}),yn=e.Variant({Committed:gn,Aborted:e.Record({})}),Rn=e.Record({result:e.Opt(yn),nns_proposal_id:e.Opt(e.Nat64)}),vn=e.Record({hotkey_principal:e.Opt(e.Text),is_capped:e.Opt(e.Bool),nns_neuron_id:e.Opt(e.Nat64),amount_icp_e8s:e.Opt(e.Nat64)}),hn=e.Record({neurons_fund_neuron_portions:e.Vec(vn)}),On=e.Variant({Ok:hn,Err:g}),xn=e.Record({result:e.Opt(On)}),bn=e.Record({reward_account:e.Opt(j)});return e.Service({claim_gtc_neurons:e.Func([e.Principal,e.Vec(n)],[$],[]),claim_or_refresh_neuron_from_account:e.Func([l],[It],[]),get_build_metadata:e.Func([],[e.Text],[]),get_full_neuron:e.Func([e.Nat64],[Me],[]),get_full_neuron_by_id_or_subaccount:e.Func([te],[Me],[]),get_latest_reward_event:e.Func([],[he],[]),get_metrics:e.Func([],[Dt],[]),get_monthly_node_provider_rewards:e.Func([],[Lt],[]),get_most_recent_monthly_node_provider_rewards:e.Func([],[e.Opt(Re)],[]),get_network_economics_parameters:e.Func([],[re],[]),get_neuron_ids:e.Func([],[e.Vec(e.Nat64)],[]),get_neuron_info:e.Func([e.Nat64],[Ae],[]),get_neuron_info_by_id_or_subaccount:e.Func([te],[Ae],[]),get_node_provider_by_caller:e.Func([e.Null],[en],[]),get_pending_proposals:e.Func([],[e.Vec(ie)],[]),get_proposal_info:e.Func([e.Nat64],[e.Opt(ie)],[]),list_known_neurons:e.Func([],[tn],[]),list_neurons:e.Func([nn],[on],[]),list_node_providers:e.Func([],[rn],[]),list_proposals:e.Func([an],[sn],[]),manage_neuron:e.Func([ne],[Ve],[]),settle_community_fund_participation:e.Func([Nn],[$],[]),settle_neurons_fund_participation:e.Func([Rn],[xn],[]),simulate_manage_neuron:e.Func([ne],[Ve],[]),transfer_gtc_neuron:e.Func([n,n],[$],[]),update_node_provider:e.Func([bn],[$],[])})};var ko=({IDL:e})=>{let t=e.Rec(),n=e.Record({id:e.Nat64}),o=e.Record({followees:e.Vec(n)}),r=e.Record({name:e.Text,description:e.Opt(e.Text)}),i=e.Record({id:e.Opt(n),known_neuron_data:e.Opt(r)}),a=e.Record({percentage_to_spawn:e.Opt(e.Nat32),new_controller:e.Opt(e.Principal),nonce:e.Opt(e.Nat64)}),c=e.Record({amount_e8s:e.Nat64}),d=e.Record({topic:e.Int32,followees:e.Vec(n)}),l=e.Record({controller:e.Opt(e.Principal),memo:e.Nat64}),m=e.Variant({NeuronIdOrSubaccount:e.Record({}),MemoAndController:l,Memo:e.Nat64}),p=e.Record({by:e.Opt(m)}),y=e.Record({hot_key_to_remove:e.Opt(e.Principal)}),N=e.Record({new_hot_key:e.Opt(e.Principal)}),k=e.Record({requested_setting_for_auto_stake_maturity:e.Bool}),f=e.Record({additional_dissolve_delay_seconds:e.Nat32}),et=e.Record({dissolve_timestamp_seconds:e.Nat64}),tt=e.Variant({RemoveHotKey:y,AddHotKey:N,ChangeAutoStakeMaturity:k,StopDissolving:e.Record({}),StartDissolving:e.Record({}),IncreaseDissolveDelay:f,JoinCommunityFund:e.Record({}),LeaveCommunityFund:e.Record({}),SetDissolveTimestamp:et}),le=e.Record({operation:e.Opt(tt)}),nt=e.Record({vote:e.Int32,proposal:e.Opt(n)}),me=e.Record({source_neuron_id:e.Opt(n)}),fe=e.Record({dissolve_delay_seconds:e.Nat64,kyc_verified:e.Bool,amount_e8s:e.Nat64,new_controller:e.Opt(e.Principal),nonce:e.Nat64}),ot=e.Record({percentage_to_stake:e.Opt(e.Nat32)}),we=e.Record({percentage_to_merge:e.Nat32}),j=e.Record({hash:e.Vec(e.Nat8)}),rt=e.Record({e8s:e.Nat64}),Ne=e.Record({to_account:e.Opt(j),amount:e.Opt(rt)}),it=e.Variant({Spawn:a,Split:c,Follow:d,ClaimOrRefresh:p,Configure:le,RegisterVote:nt,Merge:me,DisburseToNeuron:fe,MakeProposal:t,StakeMaturity:ot,MergeMaturity:we,Disburse:Ne}),te=e.Variant({Subaccount:e.Vec(e.Nat8),NeuronId:n}),ne=e.Record({id:e.Opt(n),command:e.Opt(it),neuron_id_or_subaccount:e.Opt(te)}),z=e.Record({basis_points:e.Opt(e.Nat64)}),R=e.Record({seconds:e.Opt(e.Nat64)}),w=e.Record({e8s:e.Opt(e.Nat64)}),at=e.Record({reward_rate_transition_duration:e.Opt(R),initial_reward_rate:e.Opt(z),final_reward_rate:e.Opt(z)}),st=e.Record({neuron_maximum_dissolve_delay_bonus:e.Opt(z),neuron_maximum_age_for_age_bonus:e.Opt(R),neuron_maximum_dissolve_delay:e.Opt(R),neuron_minimum_dissolve_delay_to_vote:e.Opt(R),neuron_maximum_age_bonus:e.Opt(z),neuron_minimum_stake:e.Opt(w),proposal_wait_for_quiet_deadline_increase:e.Opt(R),proposal_initial_voting_period:e.Opt(R),proposal_rejection_fee:e.Opt(w),voting_reward_parameters:e.Opt(at)}),ge=e.Record({base64_encoding:e.Opt(e.Text)}),ct=e.Record({transaction_fee:e.Opt(w),token_symbol:e.Opt(e.Text),token_logo:e.Opt(ge),token_name:e.Opt(e.Text)}),ut=e.Record({id:e.Opt(e.Principal)}),dt=e.Record({dissolve_delay_interval:e.Opt(R),count:e.Opt(e.Nat64)}),pt=e.Record({seconds_after_utc_midnight:e.Opt(e.Nat64)}),_t=e.Record({iso_codes:e.Vec(e.Text)}),lt=e.Record({minimum_participants:e.Opt(e.Nat64),neurons_fund_participation:e.Opt(e.Bool),duration:e.Opt(R),neuron_basket_construction_parameters:e.Opt(dt),confirmation_text:e.Opt(e.Text),maximum_participant_icp:e.Opt(w),minimum_icp:e.Opt(w),minimum_direct_participation_icp:e.Opt(w),minimum_participant_icp:e.Opt(w),start_time:e.Opt(pt),maximum_direct_participation_icp:e.Opt(w),maximum_icp:e.Opt(w),neurons_fund_investment_icp:e.Opt(w),restricted_countries:e.Opt(_t)}),u=e.Record({total:e.Opt(w)}),mt=e.Record({controller:e.Opt(e.Principal),dissolve_delay:e.Opt(R),memo:e.Opt(e.Nat64),vesting_period:e.Opt(R),stake:e.Opt(w)}),ft=e.Record({developer_neurons:e.Vec(mt)}),wt=e.Record({treasury_distribution:e.Opt(u),developer_distribution:e.Opt(ft),swap_distribution:e.Opt(u)}),Nt=e.Record({url:e.Opt(e.Text),governance_parameters:e.Opt(st),fallback_controller_principal_ids:e.Vec(e.Principal),logo:e.Opt(ge),name:e.Opt(e.Text),ledger_parameters:e.Opt(ct),description:e.Opt(e.Text),dapp_canisters:e.Vec(ut),swap_parameters:e.Opt(lt),initial_token_distribution:e.Opt(wt)}),gt=e.Record({nns_function:e.Int32,payload:e.Vec(e.Nat8)}),T=e.Record({id:e.Opt(e.Principal),reward_account:e.Opt(j)}),yt=e.Record({dissolve_delay_seconds:e.Nat64}),Rt=e.Record({to_account:e.Opt(j)}),vt=e.Variant({RewardToNeuron:yt,RewardToAccount:Rt}),oe=e.Record({node_provider:e.Opt(T),reward_mode:e.Opt(vt),amount_e8s:e.Nat64}),ht=e.Record({dissolve_delay_interval_seconds:e.Nat64,count:e.Nat64}),Ot=e.Record({min_participant_icp_e8s:e.Nat64,neuron_basket_construction_parameters:e.Opt(ht),max_icp_e8s:e.Nat64,swap_due_timestamp_seconds:e.Nat64,min_participants:e.Nat32,sns_token_e8s:e.Nat64,sale_delay_seconds:e.Opt(e.Nat64),max_participant_icp_e8s:e.Nat64,min_direct_participation_icp_e8s:e.Opt(e.Nat64),min_icp_e8s:e.Nat64,max_direct_participation_icp_e8s:e.Opt(e.Nat64)}),xt=e.Record({community_fund_investment_e8s:e.Opt(e.Nat64),target_swap_canister_id:e.Opt(e.Principal),params:e.Opt(Ot)}),bt=e.Record({start_timestamp_seconds:e.Nat64,end_timestamp_seconds:e.Nat64}),St=e.Record({open_time_window:e.Opt(bt)}),kt=e.Record({request:e.Opt(St),swap_canister_id:e.Opt(e.Principal)}),Tt=e.Record({default_followees:e.Vec(e.Tuple(e.Int32,o))}),ye=e.Record({use_registry_derived_rewards:e.Opt(e.Bool),rewards:e.Vec(oe)}),re=e.Record({neuron_minimum_stake_e8s:e.Nat64,max_proposals_to_keep_per_topic:e.Nat32,neuron_management_fee_per_proposal_e8s:e.Nat64,reject_cost_e8s:e.Nat64,transaction_fee_e8s:e.Nat64,neuron_spawn_dissolve_delay_seconds:e.Nat64,minimum_icp_xdr_rate:e.Nat64,maximum_node_provider_rewards_e8s:e.Nat64}),Pt=e.Record({principals:e.Vec(e.Principal)}),Ct=e.Variant({ToRemove:T,ToAdd:T}),Mt=e.Record({change:e.Opt(Ct)}),At=e.Record({motion_text:e.Text}),Vt=e.Variant({RegisterKnownNeuron:i,ManageNeuron:ne,CreateServiceNervousSystem:Nt,ExecuteNnsFunction:gt,RewardNodeProvider:oe,OpenSnsTokenSwap:xt,SetSnsTokenSwapOpenTimeWindow:kt,SetDefaultFollowees:Tt,RewardNodeProviders:ye,ManageNetworkEconomics:re,ApproveGenesisKyc:Pt,AddOrRemoveNodeProvider:Mt,Motion:At});t.fill(e.Record({url:e.Text,title:e.Opt(e.Text),action:e.Opt(Vt),summary:e.Text}));let Et=e.Record({proposal:e.Opt(t),caller:e.Opt(e.Principal),proposer_id:e.Opt(n)}),Re=e.Record({timestamp:e.Nat64,rewards:e.Vec(oe)}),ve=e.Record({total_maturity_e8s_equivalent:e.Nat64,not_dissolving_neurons_e8s_buckets:e.Vec(e.Tuple(e.Nat64,e.Float64)),dissolving_neurons_staked_maturity_e8s_equivalent_sum:e.Nat64,garbage_collectable_neurons_count:e.Nat64,dissolving_neurons_staked_maturity_e8s_equivalent_buckets:e.Vec(e.Tuple(e.Nat64,e.Float64)),neurons_with_invalid_stake_count:e.Nat64,not_dissolving_neurons_count_buckets:e.Vec(e.Tuple(e.Nat64,e.Nat64)),total_supply_icp:e.Nat64,neurons_with_less_than_6_months_dissolve_delay_count:e.Nat64,dissolved_neurons_count:e.Nat64,community_fund_total_maturity_e8s_equivalent:e.Nat64,total_staked_e8s:e.Nat64,not_dissolving_neurons_count:e.Nat64,total_locked_e8s:e.Nat64,neurons_fund_total_active_neurons:e.Nat64,total_staked_maturity_e8s_equivalent:e.Nat64,not_dissolving_neurons_staked_maturity_e8s_equivalent_sum:e.Nat64,dissolved_neurons_e8s:e.Nat64,neurons_with_less_than_6_months_dissolve_delay_e8s:e.Nat64,not_dissolving_neurons_staked_maturity_e8s_equivalent_buckets:e.Vec(e.Tuple(e.Nat64,e.Float64)),dissolving_neurons_count_buckets:e.Vec(e.Tuple(e.Nat64,e.Nat64)),dissolving_neurons_count:e.Nat64,dissolving_neurons_e8s_buckets:e.Vec(e.Tuple(e.Nat64,e.Float64)),community_fund_total_staked_e8s:e.Nat64,timestamp_seconds:e.Nat64}),he=e.Record({rounds_since_last_distribution:e.Opt(e.Nat64),day_after_genesis:e.Nat64,actual_timestamp_seconds:e.Nat64,total_available_e8s_equivalent:e.Nat64,latest_round_available_e8s_equivalent:e.Opt(e.Nat64),distributed_e8s_equivalent:e.Nat64,settled_proposals:e.Vec(n)}),Oe=e.Record({to_subaccount:e.Vec(e.Nat8),neuron_stake_e8s:e.Nat64,from:e.Opt(e.Principal),memo:e.Nat64,from_subaccount:e.Vec(e.Nat8),transfer_timestamp:e.Nat64,block_height:e.Nat64}),Ft=e.Variant({LastNeuronId:n}),xe=e.Record({status:e.Opt(e.Int32),failure_reason:e.Opt(e.Text),progress:e.Opt(Ft)}),Bt=e.Record({neuron_indexes_migration:e.Opt(xe),copy_inactive_neurons_to_stable_memory_migration:e.Opt(xe)}),g=e.Record({error_message:e.Text,error_type:e.Int32}),qt=e.Record({has_created_neuron_recipes:e.Opt(e.Bool),nns_neuron_id:e.Nat64,amount_icp_e8s:e.Nat64}),Ut=e.Record({hotkey_principal:e.Text,cf_neurons:e.Vec(qt)}),be=e.Record({vote:e.Int32,voting_power:e.Nat64}),Kt=e.Record({min_participant_icp_e8s:e.Opt(e.Nat64),max_participant_icp_e8s:e.Opt(e.Nat64),min_direct_participation_icp_e8s:e.Opt(e.Nat64),max_direct_participation_icp_e8s:e.Opt(e.Nat64)}),Ht=e.Record({hotkey_principal:e.Opt(e.Principal),is_capped:e.Opt(e.Bool),maturity_equivalent_icp_e8s:e.Opt(e.Nat64),nns_neuron_id:e.Opt(n),amount_icp_e8s:e.Opt(e.Nat64)}),Se=e.Record({neurons_fund_neuron_portions:e.Vec(Ht)}),Wt=e.Record({serialized_representation:e.Opt(e.Text)}),ke=e.Record({total_maturity_equivalent_icp_e8s:e.Opt(e.Nat64),intended_neurons_fund_participation_icp_e8s:e.Opt(e.Nat64),direct_participation_icp_e8s:e.Opt(e.Nat64),swap_participation_limits:e.Opt(Kt),max_neurons_fund_swap_participation_icp_e8s:e.Opt(e.Nat64),neurons_fund_reserves:e.Opt(Se),ideal_matched_participation_function:e.Opt(Wt)}),Gt=e.Record({final_neurons_fund_participation:e.Opt(ke),initial_neurons_fund_participation:e.Opt(ke),neurons_fund_refunds:e.Opt(Se)}),jt=e.Record({status:e.Opt(e.Int32),freezing_threshold:e.Opt(e.Nat64),controllers:e.Vec(e.Principal),memory_size:e.Opt(e.Nat64),cycles:e.Opt(e.Nat64),idle_cycles_burned_per_day:e.Opt(e.Nat64),module_hash:e.Vec(e.Nat8)}),x=e.Record({status:e.Opt(jt),canister_id:e.Opt(e.Principal)}),zt=e.Record({ledger_index_canister_summary:e.Opt(x),fallback_controller_principal_ids:e.Vec(e.Principal),ledger_archive_canister_summaries:e.Vec(x),ledger_canister_summary:e.Opt(x),swap_canister_summary:e.Opt(x),governance_canister_summary:e.Opt(x),root_canister_summary:e.Opt(x),dapp_canister_summaries:e.Vec(x)}),Te=e.Record({swap_background_information:e.Opt(zt)}),Pe=e.Record({no:e.Nat64,yes:e.Nat64,total:e.Nat64,timestamp_seconds:e.Nat64}),$t=e.Record({current_deadline_timestamp_seconds:e.Nat64}),Jt=e.Record({id:e.Opt(n),failure_reason:e.Opt(g),cf_participants:e.Vec(Ut),ballots:e.Vec(e.Tuple(e.Nat64,be)),proposal_timestamp_seconds:e.Nat64,reward_event_round:e.Nat64,failed_timestamp_seconds:e.Nat64,neurons_fund_data:e.Opt(Gt),reject_cost_e8s:e.Nat64,derived_proposal_information:e.Opt(Te),latest_tally:e.Opt(Pe),sns_token_swap_lifecycle:e.Opt(e.Int32),decided_timestamp_seconds:e.Nat64,proposal:e.Opt(t),proposer:e.Opt(n),wait_for_quiet_state:e.Opt($t),executed_timestamp_seconds:e.Nat64,original_total_community_fund_maturity_e8s_equivalent:e.Opt(e.Nat64)}),Xt=e.Variant({Spawn:n,Split:c,Configure:le,Merge:me,DisburseToNeuron:fe,SyncCommand:e.Record({}),ClaimOrRefreshNeuron:p,MergeMaturity:we,Disburse:Ne}),Yt=e.Record({command:e.Opt(Xt),timestamp:e.Nat64}),Ce=e.Record({vote:e.Int32,proposal_id:e.Opt(n)}),Qt=e.Variant({DissolveDelaySeconds:e.Nat64,WhenDissolvedTimestampSeconds:e.Nat64}),V=e.Record({id:e.Opt(n),staked_maturity_e8s_equivalent:e.Opt(e.Nat64),controller:e.Opt(e.Principal),recent_ballots:e.Vec(Ce),kyc_verified:e.Bool,not_for_profit:e.Bool,maturity_e8s_equivalent:e.Nat64,cached_neuron_stake_e8s:e.Nat64,created_timestamp_seconds:e.Nat64,auto_stake_maturity:e.Opt(e.Bool),aging_since_timestamp_seconds:e.Nat64,hot_keys:e.Vec(e.Principal),account:e.Vec(e.Nat8),joined_community_fund_timestamp_seconds:e.Opt(e.Nat64),dissolve_state:e.Opt(Qt),followees:e.Vec(e.Tuple(e.Int32,o)),neuron_fees_e8s:e.Nat64,transfer:e.Opt(Oe),known_neuron_data:e.Opt(r),spawn_at_timestamp_seconds:e.Opt(e.Nat64)}),Pr=e.Record({default_followees:e.Vec(e.Tuple(e.Int32,o)),making_sns_proposal:e.Opt(Et),most_recent_monthly_node_provider_rewards:e.Opt(Re),maturity_modulation_last_updated_at_timestamp_seconds:e.Opt(e.Nat64),wait_for_quiet_threshold_seconds:e.Nat64,metrics:e.Opt(ve),neuron_management_voting_period_seconds:e.Opt(e.Nat64),node_providers:e.Vec(T),cached_daily_maturity_modulation_basis_points:e.Opt(e.Int32),economics:e.Opt(re),spawning_neurons:e.Opt(e.Bool),latest_reward_event:e.Opt(he),to_claim_transfers:e.Vec(Oe),short_voting_period_seconds:e.Nat64,migrations:e.Opt(Bt),proposals:e.Vec(e.Tuple(e.Nat64,Jt)),in_flight_commands:e.Vec(e.Tuple(e.Nat64,Yt)),neurons:e.Vec(e.Tuple(e.Nat64,V)),genesis_timestamp_seconds:e.Nat64}),$=e.Variant({Ok:e.Null,Err:g}),Zt=e.Variant({Error:g,NeuronId:n}),It=e.Record({result:e.Opt(Zt)}),Me=e.Variant({Ok:V,Err:g}),Dt=e.Variant({Ok:ve,Err:g}),Lt=e.Variant({Ok:ye,Err:g}),J=e.Record({dissolve_delay_seconds:e.Nat64,recent_ballots:e.Vec(Ce),created_timestamp_seconds:e.Nat64,state:e.Int32,stake_e8s:e.Nat64,joined_community_fund_timestamp_seconds:e.Opt(e.Nat64),retrieved_at_timestamp_seconds:e.Nat64,known_neuron_data:e.Opt(r),voting_power:e.Nat64,age_seconds:e.Nat64}),Ae=e.Variant({Ok:J,Err:g}),en=e.Variant({Ok:T,Err:g}),ie=e.Record({id:e.Opt(n),status:e.Int32,topic:e.Int32,failure_reason:e.Opt(g),ballots:e.Vec(e.Tuple(e.Nat64,be)),proposal_timestamp_seconds:e.Nat64,reward_event_round:e.Nat64,deadline_timestamp_seconds:e.Opt(e.Nat64),failed_timestamp_seconds:e.Nat64,reject_cost_e8s:e.Nat64,derived_proposal_information:e.Opt(Te),latest_tally:e.Opt(Pe),reward_status:e.Int32,decided_timestamp_seconds:e.Nat64,proposal:e.Opt(t),proposer:e.Opt(n),executed_timestamp_seconds:e.Nat64}),tn=e.Record({known_neurons:e.Vec(i)}),nn=e.Record({neuron_ids:e.Vec(e.Nat64),include_neurons_readable_by_caller:e.Bool}),on=e.Record({neuron_infos:e.Vec(e.Tuple(e.Nat64,J)),full_neurons:e.Vec(V)}),rn=e.Record({node_providers:e.Vec(T)}),an=e.Record({include_reward_status:e.Vec(e.Int32),omit_large_fields:e.Opt(e.Bool),before_proposal:e.Opt(n),limit:e.Nat32,exclude_topic:e.Vec(e.Int32),include_all_manage_neuron_proposals:e.Opt(e.Bool),include_status:e.Vec(e.Int32)}),sn=e.Record({proposal_info:e.Vec(ie)}),ae=e.Record({created_neuron_id:e.Opt(n)}),cn=e.Record({refreshed_neuron_id:e.Opt(n)}),un=e.Record({target_neuron:e.Opt(V),source_neuron:e.Opt(V),target_neuron_info:e.Opt(J),source_neuron_info:e.Opt(J)}),dn=e.Record({proposal_id:e.Opt(n)}),pn=e.Record({maturity_e8s:e.Nat64,staked_maturity_e8s:e.Nat64}),_n=e.Record({merged_maturity_e8s:e.Nat64,new_stake_e8s:e.Nat64}),ln=e.Record({transfer_block_height:e.Nat64}),mn=e.Variant({Error:g,Spawn:ae,Split:ae,Follow:e.Record({}),ClaimOrRefresh:cn,Configure:e.Record({}),RegisterVote:e.Record({}),Merge:un,DisburseToNeuron:ae,MakeProposal:dn,StakeMaturity:pn,MergeMaturity:_n,Disburse:ln}),Ve=e.Record({command:e.Opt(mn)}),fn=e.Record({total_direct_contribution_icp_e8s:e.Opt(e.Nat64),total_neurons_fund_contribution_icp_e8s:e.Opt(e.Nat64),sns_governance_canister_id:e.Opt(e.Principal)}),wn=e.Variant({Committed:fn,Aborted:e.Record({})}),Nn=e.Record({result:e.Opt(wn),open_sns_token_swap_proposal_id:e.Opt(e.Nat64)}),gn=e.Record({total_direct_participation_icp_e8s:e.Opt(e.Nat64),total_neurons_fund_participation_icp_e8s:e.Opt(e.Nat64),sns_governance_canister_id:e.Opt(e.Principal)}),yn=e.Variant({Committed:gn,Aborted:e.Record({})}),Rn=e.Record({result:e.Opt(yn),nns_proposal_id:e.Opt(e.Nat64)}),vn=e.Record({hotkey_principal:e.Opt(e.Text),is_capped:e.Opt(e.Bool),nns_neuron_id:e.Opt(e.Nat64),amount_icp_e8s:e.Opt(e.Nat64)}),hn=e.Record({neurons_fund_neuron_portions:e.Vec(vn)}),On=e.Variant({Ok:hn,Err:g}),xn=e.Record({result:e.Opt(On)}),bn=e.Record({reward_account:e.Opt(j)});return e.Service({claim_gtc_neurons:e.Func([e.Principal,e.Vec(n)],[$],[]),claim_or_refresh_neuron_from_account:e.Func([l],[It],[]),get_build_metadata:e.Func([],[e.Text],["query"]),get_full_neuron:e.Func([e.Nat64],[Me],["query"]),get_full_neuron_by_id_or_subaccount:e.Func([te],[Me],["query"]),get_latest_reward_event:e.Func([],[he],["query"]),get_metrics:e.Func([],[Dt],["query"]),get_monthly_node_provider_rewards:e.Func([],[Lt],[]),get_most_recent_monthly_node_provider_rewards:e.Func([],[e.Opt(Re)],["query"]),get_network_economics_parameters:e.Func([],[re],["query"]),get_neuron_ids:e.Func([],[e.Vec(e.Nat64)],["query"]),get_neuron_info:e.Func([e.Nat64],[Ae],["query"]),get_neuron_info_by_id_or_subaccount:e.Func([te],[Ae],["query"]),get_node_provider_by_caller:e.Func([e.Null],[en],["query"]),get_pending_proposals:e.Func([],[e.Vec(ie)],["query"]),get_proposal_info:e.Func([e.Nat64],[e.Opt(ie)],["query"]),list_known_neurons:e.Func([],[tn],["query"]),list_neurons:e.Func([nn],[on],["query"]),list_node_providers:e.Func([],[rn],["query"]),list_proposals:e.Func([an],[sn],["query"]),manage_neuron:e.Func([ne],[Ve],[]),settle_community_fund_participation:e.Func([Nn],[$],[]),settle_neurons_fund_participation:e.Func([Rn],[xn],[]),simulate_manage_neuron:e.Func([ne],[Ve],[]),transfer_gtc_neuron:e.Func([n,n],[$],[]),update_node_provider:e.Func([bn],[$],[])})};import{accountIdentifierToBytes as yi}from"@dfinity/ledger-icp";import{Principal as W}from"@dfinity/principal";import{arrayBufferToUint8Array as Ri,toNullable as K}from"@dfinity/utils";var Je=class extends Error{},Fe=class extends Je{},Be=class extends Je{constructor(n){super();this.minimumAmount=n}},Q=class extends Error{},F=class extends Error{constructor(n){super();this.detail=n}},h=class extends Error{constructor(t){super("Unsupported value: "+t)}},Xe=class extends Error{};var Co=e=>({id:e}),Wn=e=>({id:e}),vi=e=>({followees:e.map(Wn)}),hi=e=>{if("NeuronId"in e)return{NeuronId:{id:e.NeuronId}};if("Subaccount"in e)return{Subaccount:Uint8Array.from(e.Subaccount)};throw new h(e)},Ye=e=>e.basisPoints!==void 0?{basis_points:[e.basisPoints]}:{basis_points:[]},H=e=>e.seconds!==void 0?{seconds:[e.seconds]}:{seconds:[]},Oi=e=>e.secondsAfterUtcMidnight!==void 0?{seconds_after_utc_midnight:[e.secondsAfterUtcMidnight]}:{seconds_after_utc_midnight:[]},xi=e=>({iso_codes:e.isoCodes}),M=e=>e.e8s!==void 0?{e8s:[e.e8s]}:{e8s:[]},Mo=e=>e.base64Encoding!==void 0?{base64_encoding:[e.base64Encoding]}:{base64_encoding:[]},bi=e=>({reward_rate_transition_duration:e.rewardRateTransitionDuration!==void 0?[H(e.rewardRateTransitionDuration)]:[],initial_reward_rate:e.initialRewardRate!==void 0?[Ye(e.initialRewardRate)]:[],final_reward_rate:e.finalRewardRate!==void 0?[Ye(e.finalRewardRate)]:[]}),Si=e=>({transaction_fee:e.transactionFee!==void 0?[M(e.transactionFee)]:[],token_symbol:e.tokenSymbol!==void 0?[e.tokenSymbol]:[],token_logo:e.tokenLogo!==void 0?[Mo(e.tokenLogo)]:[],token_name:e.tokenName!==void 0?[e.tokenName]:[]}),ki=e=>({minimum_participants:e.minimumParticipants!==void 0?[e.minimumParticipants]:[],duration:e.duration!==void 0?[H(e.duration)]:[],neuron_basket_construction_parameters:e.neuronBasketConstructionParameters!==void 0?[Ti(e.neuronBasketConstructionParameters)]:[],confirmation_text:e.confirmationText!==void 0?[e.confirmationText]:[],maximum_participant_icp:e.maximumParticipantIcp!==void 0?[M(e.maximumParticipantIcp)]:[],neurons_fund_investment_icp:e.neuronsFundInvestmentIcp!==void 0?[M(e.neuronsFundInvestmentIcp)]:[],minimum_icp:e.minimumIcp!==void 0?[M(e.minimumIcp)]:[],minimum_participant_icp:e.minimumParticipantIcp!==void 0?[M(e.minimumParticipantIcp)]:[],start_time:e.startTime!==void 0?[Oi(e.startTime)]:[],maximum_icp:e.maximumIcp!==void 0?[M(e.maximumIcp)]:[],restricted_countries:e.restrictedCountries!==void 0?[xi(e.restrictedCountries)]:[],maximum_direct_participation_icp:e.maxDirectParticipationIcp!==void 0?[M(e.maxDirectParticipationIcp)]:[],minimum_direct_participation_icp:e.minDirectParticipationIcp!==void 0?[M(e.minDirectParticipationIcp)]:[],neurons_fund_participation:K(e.neuronsFundParticipation)}),Ti=e=>({dissolve_delay_interval:e.dissolveDelayInterval!==void 0?[H(e.dissolveDelayInterval)]:[],count:e.count!==void 0?[e.count]:[]}),Pi=e=>({neuron_maximum_dissolve_delay_bonus:e.neuronMaximumDissolveDelayBonus!==void 0?[Ye(e.neuronMaximumDissolveDelayBonus)]:[],neuron_maximum_age_for_age_bonus:e.neuronMaximumAgeForAgeBonus!==void 0?[H(e.neuronMaximumAgeForAgeBonus)]:[],neuron_maximum_dissolve_delay:e.neuronMaximumDissolveDelay!==void 0?[H(e.neuronMaximumDissolveDelay)]:[],neuron_minimum_dissolve_delay_to_vote:e.neuronMinimumDissolveDelayToVote!==void 0?[H(e.neuronMinimumDissolveDelayToVote)]:[],neuron_maximum_age_bonus:e.neuronMaximumAgeBonus!==void 0?[Ye(e.neuronMaximumAgeBonus)]:[],neuron_minimum_stake:e.neuronMinimumStake!==void 0?[M(e.neuronMinimumStake)]:[],proposal_wait_for_quiet_deadline_increase:e.proposalWaitForQuietDeadlineIncrease!==void 0?[H(e.proposalWaitForQuietDeadlineIncrease)]:[],proposal_initial_voting_period:e.proposalInitialVotingPeriod!==void 0?[H(e.proposalInitialVotingPeriod)]:[],proposal_rejection_fee:e.proposalRejectionFee!==void 0?[M(e.proposalRejectionFee)]:[],voting_reward_parameters:e.votingRewardParameters!==void 0?[bi(e.votingRewardParameters)]:[]}),To=e=>({total:e.total!==void 0?[M(e.total)]:[]}),Ci=e=>({treasury_distribution:e.treasuryDistribution!==void 0?[To(e.treasuryDistribution)]:[],developer_distribution:e.developerDistribution!==void 0?[Ai(e.developerDistribution)]:[],swap_distribution:e.swapDistribution!==void 0?[To(e.swapDistribution)]:[]}),Mi=e=>({controller:e.controller!==void 0?[W.fromText(e.controller)]:[],dissolve_delay:e.dissolveDelay!==void 0?[H(e.dissolveDelay)]:[],memo:e.memo!==void 0?[e.memo]:[],vesting_period:e.vestingPeriod!==void 0?[H(e.vestingPeriod)]:[],stake:e.stake!==void 0?[M(e.stake)]:[]}),Ai=e=>({developer_neurons:e.developerNeurons.map(Mi)}),Vi=e=>({url:e.url!==void 0?[e.url]:[],governance_parameters:e.governanceParameters!==void 0?[Pi(e.governanceParameters)]:[],fallback_controller_principal_ids:e.fallbackControllerPrincipalIds.map(W.fromText),logo:e.logo!==void 0?[Mo(e.logo)]:[],name:e.name!==void 0?[e.name]:[],ledger_parameters:e.ledgerParameters!==void 0?[Si(e.ledgerParameters)]:[],description:e.description!==void 0?[e.description]:[],dapp_canisters:e.dappCanisters.map(t=>({id:[W.fromText(t)]})),swap_parameters:e.swapParameters!==void 0?[ki(e.swapParameters)]:[],initial_token_distribution:e.initialTokenDistribution!==void 0?[Ci(e.initialTokenDistribution)]:[]}),Ao=e=>{if("ExecuteNnsFunction"in e){let t=e.ExecuteNnsFunction;if(t.payloadBytes===void 0)throw new Error("payloadBytes not found");return{ExecuteNnsFunction:{nns_function:t.nnsFunctionId,payload:Ri(t.payloadBytes)}}}if("ManageNeuron"in e){let t=e.ManageNeuron;return{ManageNeuron:Ui(t)}}if("ApproveGenesisKyc"in e)return{ApproveGenesisKyc:{principals:e.ApproveGenesisKyc.principals.map(W.fromText)}};if("ManageNetworkEconomics"in e){let t=e.ManageNetworkEconomics;return{ManageNetworkEconomics:{neuron_minimum_stake_e8s:t.neuronMinimumStake,max_proposals_to_keep_per_topic:t.maxProposalsToKeepPerTopic,neuron_management_fee_per_proposal_e8s:t.neuronManagementFeePerProposal,reject_cost_e8s:t.rejectCost,transaction_fee_e8s:t.transactionFee,neuron_spawn_dissolve_delay_seconds:t.neuronSpawnDissolveDelaySeconds,minimum_icp_xdr_rate:t.minimumIcpXdrRate,maximum_node_provider_rewards_e8s:t.maximumNodeProviderRewards}}}if("RewardNodeProvider"in e){let t=e.RewardNodeProvider;return{RewardNodeProvider:{node_provider:t.nodeProvider?[Qe(t.nodeProvider)]:[],amount_e8s:t.amountE8s,reward_mode:t.rewardMode!=null?[Po(t.rewardMode)]:[]}}}if("RewardNodeProviders"in e){let t=e.RewardNodeProviders;return{RewardNodeProviders:{use_registry_derived_rewards:t.useRegistryDerivedRewards===void 0?[]:[t.useRegistryDerivedRewards],rewards:t.rewards.map(n=>({node_provider:n.nodeProvider?[Qe(n.nodeProvider)]:[],amount_e8s:n.amountE8s,reward_mode:n.rewardMode!=null?[Po(n.rewardMode)]:[]}))}}}if("AddOrRemoveNodeProvider"in e){let t=e.AddOrRemoveNodeProvider;return{AddOrRemoveNodeProvider:{change:t.change?[Bi(t.change)]:[]}}}if("Motion"in e)return{Motion:{motion_text:e.Motion.motionText}};if("SetDefaultFollowees"in e)return{SetDefaultFollowees:{default_followees:e.SetDefaultFollowees.defaultFollowees.map(n=>[n.topic,vi(n.followees)])}};if("RegisterKnownNeuron"in e){let t=e.RegisterKnownNeuron;return{RegisterKnownNeuron:{id:[{id:t.id}],known_neuron_data:[{name:t.name,description:t.description!==void 0?[t.description]:[]}]}}}if("SetSnsTokenSwapOpenTimeWindow"in e){let{request:t,swapCanisterId:n}=e.SetSnsTokenSwapOpenTimeWindow;return{SetSnsTokenSwapOpenTimeWindow:{request:t===void 0?[]:[{open_time_window:t.openTimeWindow===void 0?[]:[{start_timestamp_seconds:t.openTimeWindow.startTimestampSeconds,end_timestamp_seconds:t.openTimeWindow.endTimestampSeconds}]}],swap_canister_id:n===void 0?[]:[W.fromText(n)]}}}if("OpenSnsTokenSwap"in e){let{communityFundInvestmentE8s:t,targetSwapCanisterId:n,params:o}=e.OpenSnsTokenSwap;return{OpenSnsTokenSwap:{community_fund_investment_e8s:K(t),target_swap_canister_id:K(n),params:o===void 0?[]:[{min_participant_icp_e8s:o.minParticipantIcpE8s,max_icp_e8s:o.maxIcpE8s,swap_due_timestamp_seconds:o.swapDueTimestampSeconds,min_participants:o.minParticipants,sns_token_e8s:o.snsTokenE8s,max_participant_icp_e8s:o.maxParticipantIcpE8s,min_icp_e8s:o.minIcpE8s,sale_delay_seconds:K(o.saleDelaySeconds),neuron_basket_construction_parameters:K(o.neuronBasketConstructionParameters),max_direct_participation_icp_e8s:K(o.maxDirectParticipationIcpE8s),min_direct_participation_icp_e8s:K(o.minDirectParticipationIcpE8s)}]}}}if("CreateServiceNervousSystem"in e)return{CreateServiceNervousSystem:Vi(e.CreateServiceNervousSystem)};throw new h(e)},Ei=e=>{if("Split"in e)return{Split:{amount_e8s:e.Split.amount}};if("Follow"in e){let t=e.Follow;return{Follow:{topic:t.topic,followees:t.followees.map(Wn)}}}if("ClaimOrRefresh"in e){let t=e.ClaimOrRefresh;return{ClaimOrRefresh:{by:t.by?[qi(t.by)]:[]}}}if("Configure"in e){let t=e.Configure;return{Configure:{operation:t.operation?[Fi(t.operation)]:[]}}}if("RegisterVote"in e){let t=e.RegisterVote;return{RegisterVote:{vote:t.vote,proposal:t.proposal?[Co(t.proposal)]:[]}}}if("DisburseToNeuron"in e){let t=e.DisburseToNeuron;return{DisburseToNeuron:{dissolve_delay_seconds:t.dissolveDelaySeconds,kyc_verified:t.kycVerified,amount_e8s:t.amount,new_controller:t.newController?[W.fromText(t.newController)]:[],nonce:t.nonce}}}if("MergeMaturity"in e)return{MergeMaturity:{percentage_to_merge:e.MergeMaturity.percentageToMerge}};if("StakeMaturity"in e){let{percentageToStake:t}=e.StakeMaturity;return{StakeMaturity:{percentage_to_stake:K(t)}}}if("MakeProposal"in e){let t=e.MakeProposal;return{MakeProposal:{url:t.url,title:[],action:t.action?[Ao(t.action)]:[],summary:t.summary}}}if("Disburse"in e){let t=e.Disburse;return{Disburse:{to_account:t.toAccountId?[Gn(t.toAccountId)]:[],amount:t.amount?[Vo(t.amount)]:[]}}}if("Spawn"in e){let t=e.Spawn;return{Spawn:{percentage_to_spawn:t.percentageToSpawn===void 0?[]:[t.percentageToSpawn],new_controller:t.newController?[W.fromText(t.newController)]:[],nonce:[]}}}if("Merge"in e){let t=e.Merge;return{Merge:{source_neuron_id:t.sourceNeuronId?[{id:t.sourceNeuronId}]:[]}}}throw new h(e)},Fi=e=>{if("RemoveHotKey"in e){let t=e.RemoveHotKey;return{RemoveHotKey:{hot_key_to_remove:t.hotKeyToRemove!=null?[W.fromText(t.hotKeyToRemove)]:[]}}}if("AddHotKey"in e){let t=e.AddHotKey;return{AddHotKey:{new_hot_key:t.newHotKey?[W.fromText(t.newHotKey)]:[]}}}if("StopDissolving"in e)return{StopDissolving:{}};if("StartDissolving"in e)return{StartDissolving:{}};if("IncreaseDissolveDelay"in e)return{IncreaseDissolveDelay:{additional_dissolve_delay_seconds:e.IncreaseDissolveDelay.additionalDissolveDelaySeconds}};if("JoinCommunityFund"in e||"LeaveCommunityFund"in e)return e;if("SetDissolveTimestamp"in e)return{SetDissolveTimestamp:{dissolve_timestamp_seconds:e.SetDissolveTimestamp.dissolveTimestampSeconds}};if("ChangeAutoStakeMaturity"in e){let{requestedSettingForAutoStakeMaturity:t}=e.ChangeAutoStakeMaturity;return{ChangeAutoStakeMaturity:{requested_setting_for_auto_stake_maturity:t}}}throw new h(e)},Bi=e=>{if("ToRemove"in e)return{ToRemove:Qe(e.ToRemove)};if("ToAdd"in e)return{ToAdd:Qe(e.ToAdd)};throw new h(e)},Qe=e=>({id:e.id!=null?[W.fromText(e.id)]:[],reward_account:e.rewardAccount!=null?[Gn(e.rewardAccount)]:[]}),Vo=e=>({e8s:e}),Gn=e=>({hash:yi(e)}),Po=e=>{if("RewardToNeuron"in e)return{RewardToNeuron:{dissolve_delay_seconds:e.RewardToNeuron.dissolveDelaySeconds}};if("RewardToAccount"in e)return{RewardToAccount:{to_account:e.RewardToAccount.toAccount!=null?[Gn(e.RewardToAccount.toAccount)]:[]}};throw new h(e)},qi=e=>{if("NeuronIdOrSubaccount"in e)return{NeuronIdOrSubaccount:{}};if("Memo"in e)return{Memo:e.Memo};if("MemoAndController"in e)return{MemoAndController:{memo:e.MemoAndController.memo,controller:e.MemoAndController.controller?[e.MemoAndController.controller]:[]}};throw new h(e)},Eo=e=>({neuron_ids:BigUint64Array.from(e??[]),include_neurons_readable_by_caller:!e}),Ui=({id:e,command:t,neuronIdOrSubaccount:n})=>({id:e?[Wn(e)]:[],command:t?[Ei(t)]:[],neuron_id_or_subaccount:n?[hi(n)]:[]}),Fo=({includeRewardStatus:e,beforeProposal:t,excludeTopic:n,includeStatus:o,limit:r,includeAllManageNeuronProposals:i,omitLargeFields:a})=>({include_reward_status:Int32Array.from(e),before_proposal:t?[Co(t)]:[],limit:r,exclude_topic:Int32Array.from(n),include_all_manage_neuron_proposals:i!==void 0?[i]:[],include_status:Int32Array.from(o),omit_large_fields:K(a)}),Bo=e=>({id:[],command:[{ClaimOrRefresh:{by:[{NeuronIdOrSubaccount:{}}]}}],neuron_id_or_subaccount:[{NeuronId:{id:e.neuronId}}]}),qo=({memo:e,controller:t})=>{let n={ClaimOrRefresh:{by:[{MemoAndController:{controller:t==null?[]:[t],memo:e}}]}};return{id:[],command:[n],neuron_id_or_subaccount:[]}},Uo=({neuronId:e,amount:t})=>({id:[],command:[{Split:{amount_e8s:t}}],neuron_id_or_subaccount:[{NeuronId:{id:e}}]});var Ko=({neuronId:e,vote:t,proposalId:n})=>L({neuronId:e,command:{RegisterVote:{vote:t,proposal:[{id:n}]}}}),Ho=e=>{let t={MakeProposal:{url:e.url,title:e.title!=null?[e.title]:[],summary:e.summary,action:[Ao(e.action)]}};return{id:[],command:[t],neuron_id_or_subaccount:[{NeuronId:{id:e.neuronId}}]}},Wo=({neuronId:e,topic:t,followees:n})=>L({neuronId:e,command:{Follow:{topic:t,followees:n.map(o=>({id:o}))}}}),Go=({neuronId:e,toAccountIdentifier:t,amount:n})=>L({neuronId:e,command:{Disburse:{to_account:t!==void 0?[t.toAccountIdentifierHash()]:[],amount:n!==void 0?[Vo(n)]:[]}}}),jo=({neuronId:e,percentageToMerge:t})=>L({neuronId:e,command:{MergeMaturity:{percentage_to_merge:t}}}),zo=({neuronId:e,percentageToStake:t})=>L({neuronId:e,command:{StakeMaturity:{percentage_to_stake:K(t)}}}),$o=({neuronId:e,percentageToSpawn:t,newController:n,nonce:o})=>L({neuronId:e,command:{Spawn:{percentage_to_spawn:t===void 0?[]:[t],new_controller:n===void 0?[]:[n],nonce:o===void 0?[]:[o]}}}),Jo=({neuronId:e,principal:t})=>Z({neuronId:e,operation:{AddHotKey:{new_hot_key:[t]}}}),Xo=({neuronId:e,principal:t})=>Z({neuronId:e,operation:{RemoveHotKey:{hot_key_to_remove:[t]}}}),Yo=({neuronId:e,additionalDissolveDelaySeconds:t})=>Z({neuronId:e,operation:{IncreaseDissolveDelay:{additional_dissolve_delay_seconds:t}}}),Qo=({neuronId:e,dissolveDelaySeconds:t})=>Z({neuronId:e,operation:{SetDissolveTimestamp:{dissolve_timestamp_seconds:BigInt(t)}}}),Zo=e=>Z({neuronId:e,operation:{JoinCommunityFund:{}}}),Io=({neuronId:e,autoStake:t})=>Z({neuronId:e,operation:{ChangeAutoStakeMaturity:{requested_setting_for_auto_stake_maturity:t}}}),Do=e=>Z({neuronId:e,operation:{LeaveCommunityFund:{}}}),jn=({sourceNeuronId:e,targetNeuronId:t})=>L({neuronId:t,command:{Merge:{source_neuron_id:[{id:e}]}}}),Lo=e=>Z({neuronId:e,operation:{StartDissolving:{}}}),er=e=>Z({neuronId:e,operation:{StopDissolving:{}}}),L=({neuronId:e,command:t})=>({id:[{id:e}],command:[t],neuron_id_or_subaccount:[]}),Z=({neuronId:e,operation:t})=>L({neuronId:e,command:{Configure:{operation:[t]}}});import{Principal as zn}from"@dfinity/principal";import{polling as tr}from"@dfinity/agent";var b=()=>import("@dfinity/nns-proto"),Ze=async({agent:e,canisterId:t,methodName:n,arg:o})=>{let r=await e.call(t,{methodName:n,arg:o,effectiveCanisterId:t});if(!r.response.ok)throw new Error(["Call failed:",` Method: ${n}`,` Canister ID: ${t}`,` Request ID: ${r.requestId}`,` HTTP status code: ${r.response.status}`,` HTTP status text: ${r.response.statusText}`].join(`
3
- `));let i=await tr.pollForResponse(e,t,r.requestId,tr.defaultStrategy());return new Uint8Array(i)};var nr=async e=>{let{PrincipalId:t,ManageNeuron:n,NeuronId:o}=await b(),r=new t;r.setSerializedId(zn.fromText(e.principal).toUint8Array());let i=new n.AddHotKey;i.setNewHotKey(r);let a=new n.Configure;a.setAddHotKey(i);let c=new n;c.setConfigure(a);let d=new o;return d.setId(e.neuronId.toString()),c.setNeuronId(d),c},or=async e=>{let{PrincipalId:t,ManageNeuron:n,NeuronId:o}=await b(),r=new t;r.setSerializedId(zn.fromText(e.principal).toUint8Array());let i=new n.RemoveHotKey;i.setHotKeyToRemove(r);let a=new n.Configure;a.setRemoveHotKey(i);let c=new n;c.setConfigure(a);let d=new o;return d.setId(e.neuronId.toString()),c.setNeuronId(d),c},rr=async({neuronId:e,additionalDissolveDelaySeconds:t})=>{let{ManageNeuron:n,NeuronId:o}=await b(),r=new n.IncreaseDissolveDelay;r.setAdditionalDissolveDelaySeconds(t);let i=new n.Configure;i.setIncreaseDissolveDelay(r);let a=new n;a.setConfigure(i);let c=new o;return c.setId(e.toString()),a.setNeuronId(c),a},ir=async e=>{let{ManageNeuron:t,NeuronId:n}=await b(),o=new t.Configure;o.setStartDissolving(new t.StartDissolving);let r=new t;r.setConfigure(o);let i=new n;return i.setId(e.toString()),r.setNeuronId(i),r},ar=async e=>{let{ManageNeuron:t,NeuronId:n}=await b(),o=new t.Configure;o.setStopDissolving(new t.StopDissolving);let r=new t;r.setConfigure(o);let i=new n;return i.setId(e.toString()),r.setNeuronId(i),r},sr=async e=>{let{ManageNeuron:t,NeuronId:n}=await b(),o=new t.Configure;o.setJoinCommunityFund(new t.JoinCommunityFund);let r=new t;r.setConfigure(o);let i=new n;return i.setId(e.toString()),r.setNeuronId(i),r},cr=async e=>{let{ManageNeuron:t,NeuronId:n,AccountIdentifier:o}=await b(),r=new t.Disburse;if(e.toAccountId){let c=new o;c.setHash(Uint8Array.from(Buffer.from(e.toAccountId,"hex"))),r.setToAccount(c)}if(e.amount!=null){let c=new t.Disburse.Amount;c.setE8s(e.amount.toString()),r.setAmount(c)}let i=new t;i.setDisburse(r);let a=new n;return a.setId(e.neuronId.toString()),i.setNeuronId(a),i},ur=async e=>{let{ManageNeuron:t,NeuronId:n}=await b(),o=new t.MergeMaturity;o.setPercentageToMerge(e.percentageToMerge);let r=new t,i=new n;return i.setId(e.neuronId.toString()),r.setNeuronId(i),r.setMergeMaturity(o),r},dr=async e=>{let{ManageNeuron:t,NeuronId:n,PrincipalId:o}=await b(),r=new t.Spawn;if(e.newController){let c=new o;c.setSerializedId(zn.fromText(e.newController).toUint8Array().slice(4)),r.setNewController(c)}e.percentageToSpawn!==void 0&&r.setPercentageToSpawn(e.percentageToSpawn);let i=new t;i.setSpawn(r);let a=new n;return a.setId(e.neuronId.toString()),i.setNeuronId(a),i};import{AccountIdentifier as fr,accountIdentifierFromBytes as zi,principalToAccountIdentifier as $i,SubAccount as Ji}from"@dfinity/ledger-icp";import{Principal as $n}from"@dfinity/principal";import{fromDefinedNullable as Xi,fromNullable as _,nonNullish as Ie,toNullable as ue,uint8ArrayToArrayOfNumber as Yi}from"@dfinity/utils";var pr=(i=>(i[i.Unspecified=0]="Unspecified",i[i.Locked=1]="Locked",i[i.Dissolving=2]="Dissolving",i[i.Dissolved=3]="Dissolved",i[i.Spawning=4]="Spawning",i))(pr||{}),Ki=(f=>(f[f.Unspecified=0]="Unspecified",f[f.ManageNeuron=1]="ManageNeuron",f[f.ExchangeRate=2]="ExchangeRate",f[f.NetworkEconomics=3]="NetworkEconomics",f[f.Governance=4]="Governance",f[f.NodeAdmin=5]="NodeAdmin",f[f.ParticipantManagement=6]="ParticipantManagement",f[f.SubnetManagement=7]="SubnetManagement",f[f.NetworkCanisterManagement=8]="NetworkCanisterManagement",f[f.Kyc=9]="Kyc",f[f.NodeProviderRewards=10]="NodeProviderRewards",f[f.SnsDecentralizationSale=11]="SnsDecentralizationSale",f[f.SubnetReplicaVersionManagement=12]="SubnetReplicaVersionManagement",f[f.ReplicaVersionManagement=13]="ReplicaVersionManagement",f[f.SnsAndCommunityFund=14]="SnsAndCommunityFund",f))(Ki||{}),Hi=(i=>(i[i.Unknown=0]="Unknown",i[i.AcceptVotes=1]="AcceptVotes",i[i.ReadyToSettle=2]="ReadyToSettle",i[i.Settled=3]="Settled",i[i.Ineligible=4]="Ineligible",i))(Hi||{}),Wi=(a=>(a[a.Unknown=0]="Unknown",a[a.Open=1]="Open",a[a.Rejected=2]="Rejected",a[a.Accepted=3]="Accepted",a[a.Executed=4]="Executed",a[a.Failed=5]="Failed",a))(Wi||{}),Gi=(o=>(o[o.Unspecified=0]="Unspecified",o[o.Yes=1]="Yes",o[o.No=2]="No",o))(Gi||{}),ji=(u=>(u[u.Unspecified=0]="Unspecified",u[u.CreateSubnet=1]="CreateSubnet",u[u.AddNodeToSubnet=2]="AddNodeToSubnet",u[u.NnsCanisterInstall=3]="NnsCanisterInstall",u[u.NnsCanisterUpgrade=4]="NnsCanisterUpgrade",u[u.BlessReplicaVersion=5]="BlessReplicaVersion",u[u.RecoverSubnet=6]="RecoverSubnet",u[u.UpdateConfigOfSubnet=7]="UpdateConfigOfSubnet",u[u.AssignNoid=8]="AssignNoid",u[u.NnsRootUpgrade=9]="NnsRootUpgrade",u[u.IcpXdrConversionRate=10]="IcpXdrConversionRate",u[u.UpdateSubnetReplicaVersion=11]="UpdateSubnetReplicaVersion",u[u.ClearProvisionalWhitelist=12]="ClearProvisionalWhitelist",u[u.RemoveNodesFromSubnet=13]="RemoveNodesFromSubnet",u[u.SetAuthorizedSubnetworks=14]="SetAuthorizedSubnetworks",u[u.SetFirewallConfig=15]="SetFirewallConfig",u[u.UpdateNodeOperatorConfig=16]="UpdateNodeOperatorConfig",u[u.StopOrStartNnsCanister=17]="StopOrStartNnsCanister",u[u.RemoveNodes=18]="RemoveNodes",u[u.UninstallCode=19]="UninstallCode",u[u.UpdateNodeRewardsTable=20]="UpdateNodeRewardsTable",u[u.AddOrRemoveDataCenters=21]="AddOrRemoveDataCenters",u[u.UpdateUnassignedNodesConfig=22]="UpdateUnassignedNodesConfig",u[u.RemoveNodeOperators=23]="RemoveNodeOperators",u[u.RerouteCanisterRanges=24]="RerouteCanisterRanges",u[u.AddFirewallRules=25]="AddFirewallRules",u[u.RemoveFirewallRules=26]="RemoveFirewallRules",u[u.UpdateFirewallRules=27]="UpdateFirewallRules",u[u.PrepareCanisterMigration=28]="PrepareCanisterMigration",u[u.CompleteCanisterMigration=29]="CompleteCanisterMigration",u[u.AddSnsWasm=30]="AddSnsWasm",u[u.ChangeSubnetMembership=31]="ChangeSubnetMembership",u[u.UpdateSubnetType=32]="UpdateSubnetType",u[u.ChangeSubnetTypeAssignment=33]="ChangeSubnetTypeAssignment",u[u.UpdateSnsWasmSnsSubnetIds=34]="UpdateSnsWasmSnsSubnetIds",u[u.UpdateAllowedPrincipals=35]="UpdateAllowedPrincipals",u[u.RetireReplicaVersion=36]="RetireReplicaVersion",u[u.InsertSnsWasmUpgradePathEntries=37]="InsertSnsWasmUpgradePathEntries",u[u.UpdateElectedReplicaVersions=38]="UpdateElectedReplicaVersions",u[u.BitcoinSetConfig=39]="BitcoinSetConfig",u[u.UpdateElectedHostosVersions=40]="UpdateElectedHostosVersions",u[u.UpdateNodesHostosVersion=41]="UpdateNodesHostosVersion",u))(ji||{});var Jn=({neuronId:e,neuronInfo:t,rawNeuron:n,canisterId:o})=>{let r=n?Qi({neuron:n,canisterId:o}):void 0;return{neuronId:e,dissolveDelaySeconds:t.dissolve_delay_seconds,recentBallots:t.recent_ballots.map(wr),createdTimestampSeconds:t.created_timestamp_seconds,state:t.state,joinedCommunityFundTimestampSeconds:t.joined_community_fund_timestamp_seconds.length?t.joined_community_fund_timestamp_seconds[0]:void 0,retrievedAtTimestampSeconds:t.retrieved_at_timestamp_seconds,votingPower:t.voting_power,ageSeconds:t.age_seconds,fullNeuron:r}},Qi=({neuron:e,canisterId:t})=>({id:e.id.length?ee(e.id[0]):void 0,stakedMaturityE8sEquivalent:_(e.staked_maturity_e8s_equivalent),controller:e.controller.length?e.controller[0].toString():void 0,recentBallots:e.recent_ballots.map(wr),kycVerified:e.kyc_verified,notForProfit:e.not_for_profit,cachedNeuronStake:e.cached_neuron_stake_e8s,createdTimestampSeconds:e.created_timestamp_seconds,autoStakeMaturity:_(e.auto_stake_maturity),maturityE8sEquivalent:e.maturity_e8s_equivalent,agingSinceTimestampSeconds:e.aging_since_timestamp_seconds,neuronFees:e.neuron_fees_e8s,hotKeys:e.hot_keys.map(n=>n.toString()),accountIdentifier:$i(t,Uint8Array.from(e.account)),joinedCommunityFundTimestampSeconds:e.joined_community_fund_timestamp_seconds.length?e.joined_community_fund_timestamp_seconds[0]:void 0,dissolveState:e.dissolve_state.length?Zi(e.dissolve_state[0]):void 0,spawnAtTimesSeconds:e.spawn_at_timestamp_seconds[0],followees:e.followees.map(([n,o])=>Nr({topic:n,followees:o}))}),rs=e=>({id:Ie(e.id)?ue({id:e.id}):[],staked_maturity_e8s_equivalent:ue(e.stakedMaturityE8sEquivalent),controller:Ie(e.controller)?ue($n.from(e.controller)):[],recent_ballots:e.recentBallots.map(t=>({vote:t.vote,proposal_id:Ie(t.proposalId)?ue({id:t.proposalId}):[]})),kyc_verified:e.kycVerified,not_for_profit:e.notForProfit,cached_neuron_stake_e8s:e.cachedNeuronStake,created_timestamp_seconds:e.createdTimestampSeconds,auto_stake_maturity:ue(e.autoStakeMaturity),maturity_e8s_equivalent:e.maturityE8sEquivalent,aging_since_timestamp_seconds:e.agingSinceTimestampSeconds,neuron_fees_e8s:e.neuronFees,hot_keys:e.hotKeys.map(t=>$n.from(t)),account:fr.fromHex(e.accountIdentifier).toUint8Array(),joined_community_fund_timestamp_seconds:ue(e.joinedCommunityFundTimestampSeconds),dissolve_state:Ie(e.dissolveState)?[e.dissolveState]:[],spawn_at_timestamp_seconds:ue(e.spawnAtTimesSeconds),followees:e.followees.map(t=>[t.topic,{followees:t.followees.map(n=>({id:n}))}]),transfer:[],known_neuron_data:[]}),wr=({vote:e,proposal_id:t})=>({vote:e,proposalId:t.length?ee(t[0]):void 0}),Zi=e=>"DissolveDelaySeconds"in e?{DissolveDelaySeconds:e.DissolveDelaySeconds}:{WhenDissolvedTimestampSeconds:e.WhenDissolvedTimestampSeconds},Nr=({topic:e,followees:t})=>({topic:e,followees:t.followees.map(ee)}),ee=({id:e})=>e,Ii=e=>{if("NeuronId"in e)return{NeuronId:e.NeuronId.id};if("Subaccount"in e)return{Subaccount:Yi(Uint8Array.from(e.Subaccount))};throw new h(e)},Di=({neuronId:e,ballot:t})=>{let{vote:n,voting_power:o}=t;return{neuronId:e,vote:n,votingPower:o}},Li=({title:e,url:t,action:n,summary:o})=>({title:e.length?e[0]:void 0,url:t,action:n.length?gr(n[0]):void 0,summary:o}),gr=e=>{if("ExecuteNnsFunction"in e)return{ExecuteNnsFunction:{nnsFunctionId:e.ExecuteNnsFunction.nns_function}};if("ManageNeuron"in e){let t=e.ManageNeuron;return{ManageNeuron:{id:t.id.length?ee(t.id[0]):void 0,command:t.command.length?ta(t.command[0]):void 0,neuronIdOrSubaccount:t.neuron_id_or_subaccount.length?Ii(t.neuron_id_or_subaccount[0]):void 0}}}if("ApproveGenesisKyc"in e)return{ApproveGenesisKyc:{principals:e.ApproveGenesisKyc.principals.map(n=>n.toString())}};if("ManageNetworkEconomics"in e){let t=e.ManageNetworkEconomics;return{ManageNetworkEconomics:{neuronMinimumStake:t.neuron_minimum_stake_e8s,maxProposalsToKeepPerTopic:t.max_proposals_to_keep_per_topic,neuronManagementFeePerProposal:t.neuron_management_fee_per_proposal_e8s,rejectCost:t.reject_cost_e8s,transactionFee:t.transaction_fee_e8s,neuronSpawnDissolveDelaySeconds:t.neuron_spawn_dissolve_delay_seconds,minimumIcpXdrRate:t.minimum_icp_xdr_rate,maximumNodeProviderRewards:t.maximum_node_provider_rewards_e8s}}}if("RewardNodeProvider"in e){let t=e.RewardNodeProvider;return{RewardNodeProvider:{nodeProvider:t.node_provider.length?De(t.node_provider[0]):void 0,amountE8s:t.amount_e8s,rewardMode:t.reward_mode.length?_r(t.reward_mode[0]):void 0}}}if("RewardNodeProviders"in e){let t=e.RewardNodeProviders;return{RewardNodeProviders:{useRegistryDerivedRewards:t.use_registry_derived_rewards.length?t.use_registry_derived_rewards[0]:void 0,rewards:t.rewards.map(n=>({nodeProvider:n.node_provider.length?De(n.node_provider[0]):void 0,amountE8s:n.amount_e8s,rewardMode:n.reward_mode.length?_r(n.reward_mode[0]):void 0}))}}}if("AddOrRemoveNodeProvider"in e){let t=e.AddOrRemoveNodeProvider;return{AddOrRemoveNodeProvider:{change:t.change.length?oa(t.change[0]):void 0}}}if("Motion"in e)return{Motion:{motionText:e.Motion.motion_text}};if("SetDefaultFollowees"in e)return{SetDefaultFollowees:{defaultFollowees:e.SetDefaultFollowees.default_followees.map(([n,o])=>Nr({topic:n,followees:o}))}};if("RegisterKnownNeuron"in e){let t=e.RegisterKnownNeuron;return{RegisterKnownNeuron:aa(t)}}if("SetSnsTokenSwapOpenTimeWindow"in e){let t=e.SetSnsTokenSwapOpenTimeWindow,n=t.request?.length?{openTimeWindow:t.request[0].open_time_window.length?{startTimestampSeconds:t.request[0].open_time_window[0].start_timestamp_seconds,endTimestampSeconds:t.request[0].open_time_window[0].end_timestamp_seconds}:void 0}:void 0,o=t?.swap_canister_id.length?t.swap_canister_id[0].toString():void 0;return{SetSnsTokenSwapOpenTimeWindow:{request:n,swapCanisterId:o}}}if("OpenSnsTokenSwap"in e){let t=e.OpenSnsTokenSwap,n=_(t.params);return{OpenSnsTokenSwap:{communityFundInvestmentE8s:_(t.community_fund_investment_e8s),targetSwapCanisterId:_(t.target_swap_canister_id),...n!==void 0&&{params:{minParticipantIcpE8s:n.min_participant_icp_e8s,maxIcpE8s:n.max_icp_e8s,swapDueTimestampSeconds:n.swap_due_timestamp_seconds,minParticipants:n.min_participants,snsTokenE8s:n.sns_token_e8s,maxParticipantIcpE8s:n.max_participant_icp_e8s,minIcpE8s:n.min_icp_e8s,saleDelaySeconds:_(n.sale_delay_seconds),neuronBasketConstructionParameters:_(n.neuron_basket_construction_parameters)}}}}}if("CreateServiceNervousSystem"in e){let t=e.CreateServiceNervousSystem;return{CreateServiceNervousSystem:{url:_(t.url),governanceParameters:wa(_(t.governance_parameters)),fallbackControllerPrincipalIds:t.fallback_controller_principal_ids.map(n=>n.toString()),logo:Or(_(t.logo)),name:_(t.name),ledgerParameters:ma(_(t.ledger_parameters)),description:_(t.description),dappCanisters:t.dapp_canisters.map(la)??[],swapParameters:ga(_(t.swap_parameters)),initialTokenDistribution:va(_(t.initial_token_distribution))}}}throw new h(e)},ea=e=>({no:e.no,yes:e.yes,total:e.total,timestampSeconds:e.timestamp_seconds}),ta=e=>{if("Spawn"in e){let t=e.Spawn;return{Spawn:{newController:t.new_controller.length?t.new_controller[0].toString():void 0,percentageToSpawn:t.percentage_to_spawn.length?t.percentage_to_spawn[0]:0}}}if("Split"in e)return{Split:{amount:e.Split.amount_e8s}};if("Follow"in e){let t=e.Follow;return{Follow:{topic:t.topic,followees:t.followees.map(ee)}}}if("ClaimOrRefresh"in e){let t=e.ClaimOrRefresh;return{ClaimOrRefresh:{by:t.by.length?ia(t.by[0]):void 0}}}if("Configure"in e){let t=e.Configure;return{Configure:{operation:t.operation.length?na(t.operation[0]):void 0}}}if("RegisterVote"in e){let t=e.RegisterVote;return{RegisterVote:{vote:t.vote,proposal:t.proposal.length?ee(t.proposal[0]):void 0}}}if("DisburseToNeuron"in e){let t=e.DisburseToNeuron;return{DisburseToNeuron:{dissolveDelaySeconds:t.dissolve_delay_seconds,kycVerified:t.kyc_verified,amount:t.amount_e8s,newController:t.new_controller.length?t.new_controller[0].toString():void 0,nonce:t.nonce}}}if("MergeMaturity"in e)return{MergeMaturity:{percentageToMerge:e.MergeMaturity.percentage_to_merge}};if("StakeMaturity"in e){let{percentage_to_stake:t}=e.StakeMaturity;return{StakeMaturity:{percentageToStake:_(t)}}}if("MakeProposal"in e){let t=e.MakeProposal;return{MakeProposal:{title:t.title.length?t.title[0]:void 0,url:t.url,action:t.action.length?gr(t.action[0]):void 0,summary:t.summary}}}if("Disburse"in e){let t=e.Disburse;return{Disburse:{toAccountId:t.to_account.length?Xn(t.to_account[0]):void 0,amount:t.amount.length?ra(t.amount[0]):void 0}}}if("Merge"in e){let t=e.Merge;return{Merge:{sourceNeuronId:t.source_neuron_id.length?t.source_neuron_id[0].id:void 0}}}throw new h(e)},na=e=>{if("RemoveHotKey"in e){let t=e.RemoveHotKey;return{RemoveHotKey:{hotKeyToRemove:t.hot_key_to_remove.length?t.hot_key_to_remove[0].toString():void 0}}}if("AddHotKey"in e){let t=e.AddHotKey;return{AddHotKey:{newHotKey:t.new_hot_key.length?t.new_hot_key[0].toString():void 0}}}if("StopDissolving"in e)return{StopDissolving:{}};if("StartDissolving"in e)return{StartDissolving:{}};if("IncreaseDissolveDelay"in e)return{IncreaseDissolveDelay:{additionalDissolveDelaySeconds:e.IncreaseDissolveDelay.additional_dissolve_delay_seconds}};if("JoinCommunityFund"in e||"LeaveCommunityFund"in e)return e;if("SetDissolveTimestamp"in e)return{SetDissolveTimestamp:{dissolveTimestampSeconds:e.SetDissolveTimestamp.dissolve_timestamp_seconds}};if("ChangeAutoStakeMaturity"in e){let{requested_setting_for_auto_stake_maturity:t}=e.ChangeAutoStakeMaturity;return{ChangeAutoStakeMaturity:{requestedSettingForAutoStakeMaturity:t}}}throw new h(e)},oa=e=>{if("ToRemove"in e)return{ToRemove:De(e.ToRemove)};if("ToAdd"in e)return{ToAdd:De(e.ToAdd)};throw new h(e)},De=e=>({id:e.id.length?e.id[0].toString():void 0,rewardAccount:e.reward_account.length?Xn(e.reward_account[0]):void 0}),ra=e=>e.e8s,Xn=e=>zi(new Uint8Array(e.hash)),_r=e=>{if("RewardToNeuron"in e)return{RewardToNeuron:{dissolveDelaySeconds:e.RewardToNeuron.dissolve_delay_seconds}};if("RewardToAccount"in e)return{RewardToAccount:{toAccount:e.RewardToAccount.to_account!=null&&e.RewardToAccount.to_account.length?Xn(e.RewardToAccount.to_account[0]):void 0}};throw new h(e)},ia=e=>{if("NeuronIdOrSubaccount"in e)return{NeuronIdOrSubaccount:{}};if("Memo"in e)return{Memo:e.Memo};if("MemoAndController"in e)return{MemoAndController:{memo:e.MemoAndController.memo,controller:e.MemoAndController.controller.length?e.MemoAndController.controller[0]:void 0}};throw new h(e)},Yn=e=>({id:e.id.length?ee(e.id[0]):void 0,ballots:e.ballots.map(t=>Di({neuronId:t[0],ballot:t[1]})),rejectCost:e.reject_cost_e8s,proposalTimestampSeconds:e.proposal_timestamp_seconds,rewardEventRound:e.reward_event_round,failedTimestampSeconds:e.failed_timestamp_seconds,deadlineTimestampSeconds:_(e.deadline_timestamp_seconds),decidedTimestampSeconds:e.decided_timestamp_seconds,proposal:e.proposal.length?Li(e.proposal[0]):void 0,proposer:e.proposer.length?ee(e.proposer[0]):void 0,latestTally:e.latest_tally.length?ea(e.latest_tally[0]):void 0,executedTimestampSeconds:e.executed_timestamp_seconds,topic:e.topic,status:e.status,rewardStatus:e.reward_status}),yr=({response:{neuron_infos:e,full_neurons:t},canisterId:n})=>e.map(([o,r])=>Jn({neuronId:o,neuronInfo:r,rawNeuron:t.find(i=>i.id.length&&i.id[0].id===o),canisterId:n})),Rr=({proposal_info:e})=>({proposals:e.map(Yn)}),aa=({id:e,known_neuron_data:t})=>({id:e[0]?.id??BigInt(0),name:t[0]?.name??"",description:t[0]?.description[0]??""}),vr=e=>{let t=e.getProposalId();return{vote:e.getVote(),proposalId:t!==void 0?BigInt(t.getId()):void 0}},sa=e=>e?.hasWhenDissolvedTimestampSeconds()?2:e?.hasDissolveDelaySeconds()?e.getDissolveDelaySeconds()==="0"?3:1:0,ca=e=>e.toArray().map(([t,n])=>({topic:Number(t),followees:n.getFolloweesList?.().map(o=>BigInt(o.getId()))??[]})),lr=e=>$n.fromUint8Array(e.getSerializedId_asU8()).toText(),ua=({neuron:e,canisterId:t})=>{let n=Ji.fromBytes(e.getAccount_asU8());return fr.fromPrincipal({principal:t,subAccount:n})},da=({pbNeuron:e,pbNeuronInfo:t,canisterId:n})=>{let o=e.getId(),r=e.getController(),i=r===void 0?r:lr(r),a;return e.hasWhenDissolvedTimestampSeconds()?a={WhenDissolvedTimestampSeconds:BigInt(e.getWhenDissolvedTimestampSeconds())}:e.hasDissolveDelaySeconds()&&(a={DissolveDelaySeconds:BigInt(e.getDissolveDelaySeconds())}),{id:o===void 0?void 0:BigInt(o.getId()),stakedMaturityE8sEquivalent:void 0,controller:i,recentBallots:t.getRecentBallotsList().map(vr),kycVerified:e.getKycVerified(),notForProfit:e.getNotForProfit(),cachedNeuronStake:BigInt(e.getCachedNeuronStakeE8s()),createdTimestampSeconds:BigInt(e.getCreatedTimestampSeconds()),autoStakeMaturity:void 0,maturityE8sEquivalent:BigInt(e.getMaturityE8sEquivalent()),agingSinceTimestampSeconds:BigInt(e.getAgingSinceTimestampSeconds()),spawnAtTimesSeconds:e.hasSpawnAtTimestampSeconds()?BigInt(e.getSpawnAtTimestampSeconds()):void 0,neuronFees:BigInt(e.getNeuronFeesE8s()),hotKeys:e.getHotKeysList().map(lr),accountIdentifier:ua({neuron:e,canisterId:n}).toHex(),joinedCommunityFundTimestampSeconds:void 0,dissolveState:a,followees:ca(e.getFolloweesMap())}},hr=({pbNeurons:e,canisterId:t})=>n=>{let o=e.find(i=>i.getId()?.getId()===n.getKey()),r=n.getValue();if(r===void 0)throw new Error(`NeuronInfo not present for neuron ${n.getKey()}`);return{neuronId:BigInt(n.getKey()),dissolveDelaySeconds:BigInt(r.getDissolveDelaySeconds()),recentBallots:r.getRecentBallotsList().map(vr),createdTimestampSeconds:BigInt(r.getCreatedTimestampSeconds()),state:sa(o),joinedCommunityFundTimestampSeconds:void 0,retrievedAtTimestampSeconds:BigInt(r.getRetrievedAtTimestampSeconds()),votingPower:BigInt(r.getVotingPower()),ageSeconds:BigInt(r.getAgeSeconds()),fullNeuron:o===void 0?void 0:da({pbNeuron:o,pbNeuronInfo:r,canisterId:t})}},Le=e=>e===void 0?void 0:{basisPoints:_(e.basis_points)},G=e=>e===void 0?void 0:{seconds:_(e.seconds)},pa=e=>e===void 0?void 0:{secondsAfterUtcMidnight:_(e.seconds_after_utc_midnight)},_a=e=>e===void 0?void 0:{isoCodes:e.iso_codes},A=e=>e===void 0?void 0:{e8s:_(e.e8s)},la=e=>e===void 0||e.id.length===0?void 0:Xi(e.id).toString(),Or=e=>e===void 0?void 0:{base64Encoding:_(e.base64_encoding)},ma=e=>e===void 0?void 0:{transactionFee:A(_(e.transaction_fee)),tokenSymbol:_(e.token_symbol),tokenLogo:Or(_(e.token_logo)),tokenName:_(e.token_name)},fa=e=>e===void 0?void 0:{rewardRateTransitionDuration:G(_(e.reward_rate_transition_duration)),initialRewardRate:Le(_(e.initial_reward_rate)),finalRewardRate:Le(_(e.final_reward_rate))},wa=e=>e===void 0?void 0:{neuronMaximumDissolveDelayBonus:Le(_(e.neuron_maximum_dissolve_delay_bonus)),neuronMaximumAgeForAgeBonus:G(_(e.neuron_maximum_age_for_age_bonus)),neuronMaximumDissolveDelay:G(_(e.neuron_maximum_dissolve_delay)),neuronMinimumDissolveDelayToVote:G(_(e.neuron_minimum_dissolve_delay_to_vote)),neuronMaximumAgeBonus:Le(_(e.neuron_maximum_age_bonus)),neuronMinimumStake:A(_(e.neuron_minimum_stake)),proposalWaitForQuietDeadlineIncrease:G(_(e.proposal_wait_for_quiet_deadline_increase)),proposalInitialVotingPeriod:G(_(e.proposal_initial_voting_period)),proposalRejectionFee:A(_(e.proposal_rejection_fee)),votingRewardParameters:fa(_(e.voting_reward_parameters))},Na=e=>e===void 0?void 0:{dissolveDelayInterval:G(_(e.dissolve_delay_interval)),count:_(e.count)},ga=e=>e===void 0?void 0:{minimumParticipants:_(e.minimum_participants),duration:G(_(e.duration)),neuronBasketConstructionParameters:Na(_(e.neuron_basket_construction_parameters)),confirmationText:_(e.confirmation_text),maximumParticipantIcp:A(_(e.maximum_participant_icp)),neuronsFundInvestmentIcp:A(_(e.neurons_fund_investment_icp)),minimumIcp:A(_(e.minimum_icp)),minimumParticipantIcp:A(_(e.minimum_participant_icp)),startTime:pa(_(e.start_time)),maximumIcp:A(_(e.maximum_icp)),restrictedCountries:_a(_(e.restricted_countries)),maxDirectParticipationIcp:A(_(e.maximum_direct_participation_icp)),minDirectParticipationIcp:A(_(e.minimum_direct_participation_icp)),neuronsFundParticipation:_(e.neurons_fund_participation)},mr=e=>e===void 0?void 0:{total:A(_(e.total))},ya=e=>e===void 0?void 0:{controller:e.controller.length===0?void 0:e.controller[0].toString(),dissolveDelay:G(_(e.dissolve_delay)),memo:_(e.memo),vestingPeriod:G(_(e.vesting_period)),stake:A(_(e.stake))},Ra=e=>e===void 0?void 0:{developerNeurons:e.developer_neurons.map(ya)},va=e=>e===void 0?void 0:{treasuryDistribution:mr(_(e.treasury_distribution)),developerDistribution:Ra(_(e.developer_distribution)),swapDistribution:mr(_(e.swap_distribution))};var xr=async e=>{let{ManageNeuronResponse:t}=await b(),o=t.deserializeBinary(e).getError();if(o)throw new F({error_message:o.getErrorMessage(),error_type:o.getErrorType()})};var qe=e=>{let{command:t}=e,n=t[0];if(!n)throw new F({error_message:"Error updating neuron",error_type:0});if("Error"in n)throw new F(n.Error);return n},O=async({request:e,service:t})=>{let n=await t.manage_neuron(e);qe(n)},br=async({request:e,service:t})=>{let n=await t.simulate_manage_neuron(e);return qe(n)};var Qn=BigInt(1e8);var Tr=class e{constructor(t,n,o,r,i=!1){this.canisterId=t;this.service=n;this.certifiedService=o;this.agent=r;this.hardwareWallet=i;this.listNeurons=async({certified:t=!0,neuronIds:n})=>{if(this.hardwareWallet&&!t)throw new Xe;if(this.hardwareWallet)return this.listNeuronsHardwareWallet();let o=Eo(n),r=await this.getGovernanceService(t).list_neurons(o);return yr({response:r,canisterId:this.canisterId})};this.listKnownNeurons=async(t=!0)=>(await this.getGovernanceService(t).list_known_neurons()).known_neurons.map(o=>({id:P(o.id)?.id??BigInt(0),name:P(o.known_neuron_data)?.name??"",description:P(P(o.known_neuron_data)?.description??[])}));this.getLastestRewardEvent=async(t=!0)=>this.getGovernanceService(t).get_latest_reward_event();this.listProposals=async({request:t,certified:n=!0})=>{let o=Fo(t),r=await this.getGovernanceService(n).list_proposals(o);return Rr(r)};this.stakeNeuron=async({stake:t,principal:n,fromSubAccount:o,ledgerCanister:r,createdAt:i,fee:a})=>{if(t<Qn)throw new Be(t);let c=new Uint8Array((0,Ln.default)(8)),d=kr(c),l=this.buildNeuronStakeSubAccount(c,n),m=Zn.fromPrincipal({principal:this.canisterId,subAccount:l});await r.transfer({memo:d,amount:t,fromSubAccount:o,to:m,createdAt:i,fee:a});let p=await this.claimOrRefreshNeuronFromAccount({controller:n,memo:d});if(Dn(p))throw new Fe;return p};this.stakeNeuronIcrc1=async({stake:t,principal:n,fromSubAccount:o,ledgerCanister:r,createdAt:i,fee:a})=>{if(t<Qn)throw new Be(t);let c=new Uint8Array((0,Ln.default)(8)),d=kr(c),l=this.getNeuronStakeSubAccountBytes(c,n);await r.icrc1Transfer({icrc1Memo:c,amount:t,fromSubAccount:o,to:{owner:this.canisterId,subaccount:[l]},createdAt:i,fee:a});let m=await this.claimOrRefreshNeuronFromAccount({controller:n,memo:d});if(Dn(m))throw new Fe;return m};this.increaseDissolveDelay=async({neuronId:t,additionalDissolveDelaySeconds:n})=>{if(this.hardwareWallet)return this.increaseDissolveDelayHardwareWallet({neuronId:t,additionalDissolveDelaySeconds:n});let o=Yo({neuronId:t,additionalDissolveDelaySeconds:n});return O({request:o,service:this.certifiedService})};this.setDissolveDelay=async({neuronId:t,dissolveDelaySeconds:n})=>{let o=Qo({neuronId:t,dissolveDelaySeconds:n});return O({request:o,service:this.certifiedService})};this.startDissolving=async t=>{if(this.hardwareWallet)return this.startDissolvingHardwareWallet(t);let n=Lo(t);return O({request:n,service:this.certifiedService})};this.stopDissolving=async t=>{if(this.hardwareWallet)return this.stopDissolvingHardwareWallet(t);let n=er(t);return O({request:n,service:this.certifiedService})};this.joinCommunityFund=async t=>{if(this.hardwareWallet)return this.joinCommunityFundHardwareWallet(t);let n=Zo(t);return O({request:n,service:this.certifiedService})};this.autoStakeMaturity=t=>O({request:Io(t),service:this.certifiedService});this.leaveCommunityFund=async t=>{let n=Do(t);return O({request:n,service:this.certifiedService})};this.setNodeProviderAccount=async t=>{Sr(t);let n=Zn.fromHex(t),o=await this.certifiedService.update_node_provider({reward_account:[n.toAccountIdentifierHash()]});if("Err"in o)throw new F(o.Err)};this.mergeNeurons=async t=>{let n=jn(t);return O({request:n,service:this.certifiedService})};this.simulateMergeNeurons=async t=>{let n=jn(t),o=await br({request:n,service:this.certifiedService}),r,i,a,c;if("Merge"in o&&B(r=o.Merge)&&B(i=P(r.target_neuron_info))&&B(a=P(r.target_neuron))&&B(c=P(a.id)?.id))return Jn({neuronId:c,neuronInfo:i,rawNeuron:a,canisterId:this.canisterId});throw new Q(`simulateMergeNeurons: Unrecognized Merge error in ${JSON.stringify(o)}`)};this.splitNeuron=async({neuronId:t,amount:n})=>{let o=Uo({neuronId:t,amount:n}),r=await this.certifiedService.manage_neuron(o),i=qe(r);if("Split"in i){let a=P(i.Split.created_neuron_id);if(Dn(a))throw new F({error_message:"Unexpected error splitting neuron. No neuronId in Split response.",error_type:0});return a.id}throw new Q(`Unrecognized Split error in ${JSON.stringify(r)}`)};this.getProposal=async({proposalId:t,certified:n=!0})=>{let[o]=await this.getGovernanceService(n).get_proposal_info(t);return o?Yn(o):void 0};this.makeProposal=async t=>{let n=Ho(t);return O({request:n,service:this.certifiedService})};this.registerVote=async({neuronId:t,vote:n,proposalId:o})=>{let r=Ko({neuronId:t,vote:n,proposalId:o});return O({request:r,service:this.certifiedService})};this.setFollowees=async t=>{let n=Wo(t);return O({request:n,service:this.certifiedService})};this.disburse=async({neuronId:t,toAccountId:n,amount:o})=>{if(B(n)&&Sr(n),this.hardwareWallet)return this.disburseHardwareWallet({neuronId:t,toAccountId:n,amount:o});let r=B(n)?Zn.fromHex(n):void 0,i=Go({neuronId:t,toAccountIdentifier:r,amount:o});return O({request:i,service:this.certifiedService})};this.mergeMaturity=async({neuronId:t,percentageToMerge:n})=>{if(In(n),this.hardwareWallet)return this.mergeMaturityHardwareWallet({neuronId:t,percentageToMerge:n});let o=jo({neuronId:t,percentageToMerge:n});return O({request:o,service:this.certifiedService})};this.stakeMaturity=async({neuronId:t,percentageToStake:n})=>{In(n??100),await O({request:zo({neuronId:t,percentageToStake:n}),service:this.certifiedService})};this.spawnNeuron=async({neuronId:t,percentageToSpawn:n,newController:o,nonce:r})=>{if(B(n)&&In(n),this.hardwareWallet)return this.spawnHardwareWallet({neuronId:t,percentageToSpawn:n,newController:o?.toText()});let i=$o({neuronId:t,percentageToSpawn:n,newController:o,nonce:r}),a=await this.certifiedService.manage_neuron(i),c=qe(a),d;if("Spawn"in c&&B(d=P(c.Spawn.created_neuron_id)?.id))return d;throw new Q(`Unrecognized Spawn error in ${JSON.stringify(a)}`)};this.addHotkey=async({neuronId:t,principal:n})=>{if(this.hardwareWallet)return this.addHotkeyHardwareWallet({neuronId:t,principal:n});let o=Jo({neuronId:t,principal:n});return O({request:o,service:this.certifiedService})};this.removeHotkey=async({neuronId:t,principal:n})=>{if(this.hardwareWallet)return this.removeHotkeyHardwareWallet({neuronId:t,principal:n});let o=Xo({neuronId:t,principal:n});return O({request:o,service:this.certifiedService})};this.claimOrRefreshNeuronFromAccount=async({memo:t,controller:n})=>{let o=qo({memo:t,controller:n}),r=await this.certifiedService.manage_neuron(o),i;if(B(i=P(r.command))&&"ClaimOrRefresh"in i)return P(i.ClaimOrRefresh.refreshed_neuron_id)?.id;throw new Q(`Unrecognized ClaimOrRefresh error in ${JSON.stringify(r)}`)};this.claimOrRefreshNeuron=async t=>{let n=Bo(t),o=await this.service.manage_neuron(n),r;if(B(r=P(o.command))&&"ClaimOrRefresh"in r)return P(r.ClaimOrRefresh.refreshed_neuron_id)?.id;throw new Q(`Unrecognized ClaimOrRefresh error in ${JSON.stringify(o)}`)};this.buildNeuronStakeSubAccount=(t,n)=>ha.fromBytes(this.getNeuronStakeSubAccountBytes(t,n));this.getNeuronStakeSubAccountBytes=(t,n)=>{let o=xa("neuron-stake"),r=oo.create();return r.update(Oa([12,...o,...n.toUint8Array(),...t])),r.digest()};this.getNeuron=async({certified:t=!0,neuronId:n})=>{let[o]=await this.listNeurons({certified:t,neuronIds:[n]});return o};this.listNeuronsHardwareWallet=async()=>{let{ListNeurons:t,ListNeuronsResponse:n}=await b(),o=new t;o.setIncludeNeuronsReadableByCaller(!0);let r=await Ze({agent:this.agent,canisterId:this.canisterId,methodName:"list_neurons_pb",arg:o.serializeBinary()}),i=n.deserializeBinary(r),a=i.getFullNeuronsList();return i.getNeuronIdsList().map(hr({pbNeurons:a,canisterId:this.canisterId}))};this.manageNeuronUpdateCall=async t=>{let n=await Ze({agent:this.agent,canisterId:this.canisterId,methodName:"manage_neuron_pb",arg:t.serializeBinary()});await xr(n)};this.addHotkeyHardwareWallet=async({neuronId:t,principal:n})=>{let o=await nr({neuronId:t,principal:n.toText()});await this.manageNeuronUpdateCall(o)};this.removeHotkeyHardwareWallet=async({neuronId:t,principal:n})=>{let o=await or({neuronId:t,principal:n.toText()});await this.manageNeuronUpdateCall(o)};this.increaseDissolveDelayHardwareWallet=async({neuronId:t,additionalDissolveDelaySeconds:n})=>{let o=await rr({neuronId:t,additionalDissolveDelaySeconds:n});await this.manageNeuronUpdateCall(o)};this.startDissolvingHardwareWallet=async t=>{let n=await ir(t);await this.manageNeuronUpdateCall(n)};this.stopDissolvingHardwareWallet=async t=>{let n=await ar(t);await this.manageNeuronUpdateCall(n)};this.joinCommunityFundHardwareWallet=async t=>{let n=await sr(t);await this.manageNeuronUpdateCall(n)};this.disburseHardwareWallet=async t=>{let n=await cr(t);await this.manageNeuronUpdateCall(n)};this.mergeMaturityHardwareWallet=async t=>{let n=await ur(t);await this.manageNeuronUpdateCall(n)};this.spawnHardwareWallet=async t=>{let n=await dr(t),o=await Ze({agent:this.agent,canisterId:this.canisterId,methodName:"manage_neuron_pb",arg:n.serializeBinary()}),{ManageNeuronResponse:r}=await b(),i=r.deserializeBinary(o),a=i.getError();if(a)throw new F({error_message:a.getErrorMessage(),error_type:a.getErrorType()});let c=i.getSpawn()?.getCreatedNeuronId();if(B(c))return BigInt(c.getId());throw new Q(`Unrecognized Spawn error in ${JSON.stringify(i)}`)};this.canisterId=t,this.service=n,this.certifiedService=o,this.agent=r,this.hardwareWallet=i}static create(t={}){let n=t.canisterId??eo,{service:o,certifiedService:r,agent:i}=ba({options:{...t,canisterId:n},idlFactory:ko,certifiedIdlFactory:So});return new e(n,o,r,i,t.hardwareWallet)}getGovernanceService(t){return t?this.certifiedService:this.service}};export{ko as a,Je as b,Fe as c,Be as d,Q as e,F as f,h as g,Xe as h,pr as i,Ki as j,Hi as k,Wi as l,Gi as m,ji as n,rs as o,Tr as p};
4
- /*! Bundled license information:
5
-
6
- ieee754/index.js:
7
- (*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> *)
8
-
9
- buffer/index.js:
10
- (*!
11
- * The buffer module from node.js, for the browser.
12
- *
13
- * @author Feross Aboukhadijeh <https://feross.org>
14
- * @license MIT
15
- *)
16
-
17
- @noble/hashes/esm/utils.js:
18
- (*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
19
- */
20
- //# sourceMappingURL=chunk-DEWIE3XB.js.map