@dfinity/nns 0.4.1 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs.js +23 -23
- package/dist/cjs/index.cjs.js.map +3 -3
- package/dist/esm/chunk-DRE7O6A5.js +2 -0
- package/dist/esm/chunk-DRE7O6A5.js.map +7 -0
- package/dist/esm/genesis_token.js +1 -1
- package/dist/esm/genesis_token.js.map +3 -3
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{d as i,h as a,i as s}from"./chunk-E6UFXMWU.js";var u=({IDL:e})=>{let r=e.Record({id:e.Nat64}),t=e.Variant({Ok:e.Vec(r),Err:e.Text}),n=e.Variant({Ok:e.Null,Err:e.Text}),c=e.Record({error:e.Opt(e.Text),timestamp_seconds:e.Nat64,neuron_id:e.Opt(r)}),d=e.Record({authenticated_principal_id:e.Opt(e.Principal),successfully_transferred_neurons:e.Vec(c),is_whitelisted_for_forwarding:e.Bool,has_donated:e.Bool,failed_transferred_neurons:e.Vec(c),neuron_ids:e.Vec(r),has_claimed:e.Bool,has_forwarded:e.Bool,icpts:e.Nat32}),l=e.Variant({Ok:d,Err:e.Text});return e.Service({balance:e.Func([e.Text],[e.Nat32],["query"]),claim_neurons:e.Func([e.Text],[t],[]),donate_account:e.Func([e.Text],[n],[]),forward_whitelisted_unclaimed_accounts:e.Func([e.Null],[n],[]),get_account:e.Func([e.Text],[l],["query"]),len:e.Func([],[e.Nat16],["query"]),total:e.Func([],[e.Nat32],["query"])})};var o=class{constructor(r){this.service=r}static create(r={}){let t=r.agent??s(),n=r.canisterId??a,c=r.serviceOverride??i.createActor(u,{agent:t,canisterId:n});return new o(c)}claimNeurons=async({hexPubKey:r})=>{let t=await this.service.claim_neurons(r);if("Ok"in t)return t.Ok.map(n=>n.id);throw new Error(t.Err)}};export{o as a};
|
|
2
|
+
//# sourceMappingURL=chunk-DRE7O6A5.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../candid/genesis_token.idl.js", "../../src/genesis_token.ts"],
|
|
4
|
+
"sourcesContent": ["/* Do not edit. Compiled with ./scripts/compile-idl-js from candid/genesis_token.did */\nexport const idlFactory = ({ IDL }) => {\n const NeuronId = IDL.Record({ 'id' : IDL.Nat64 });\n const Result = IDL.Variant({ 'Ok' : IDL.Vec(NeuronId), 'Err' : IDL.Text });\n const Result_1 = IDL.Variant({ 'Ok' : IDL.Null, 'Err' : IDL.Text });\n const TransferredNeuron = IDL.Record({\n 'error' : IDL.Opt(IDL.Text),\n 'timestamp_seconds' : IDL.Nat64,\n 'neuron_id' : IDL.Opt(NeuronId),\n });\n const AccountState = IDL.Record({\n 'authenticated_principal_id' : IDL.Opt(IDL.Principal),\n 'successfully_transferred_neurons' : IDL.Vec(TransferredNeuron),\n 'is_whitelisted_for_forwarding' : IDL.Bool,\n 'has_donated' : IDL.Bool,\n 'failed_transferred_neurons' : IDL.Vec(TransferredNeuron),\n 'neuron_ids' : IDL.Vec(NeuronId),\n 'has_claimed' : IDL.Bool,\n 'has_forwarded' : IDL.Bool,\n 'icpts' : IDL.Nat32,\n });\n const Result_2 = IDL.Variant({ 'Ok' : AccountState, 'Err' : IDL.Text });\n return IDL.Service({\n 'balance' : IDL.Func([IDL.Text], [IDL.Nat32], ['query']),\n 'claim_neurons' : IDL.Func([IDL.Text], [Result], []),\n 'donate_account' : IDL.Func([IDL.Text], [Result_1], []),\n 'forward_whitelisted_unclaimed_accounts' : IDL.Func(\n [IDL.Null],\n [Result_1],\n [],\n ),\n 'get_account' : IDL.Func([IDL.Text], [Result_2], ['query']),\n 'len' : IDL.Func([], [IDL.Nat16], ['query']),\n 'total' : IDL.Func([], [IDL.Nat32], ['query']),\n });\n};\nexport const init = ({ IDL }) => { return []; };\n", "import { Actor, Agent } from \"@dfinity/agent\";\nimport { Principal } from \"@dfinity/principal\";\nimport { GenesisTokenService, idlFactory } from \"../candid/genesis_token.idl\";\nimport { MAINNET_GENESIS_TOKEN_CANISTER_ID } from \"./constants/canister_ids\";\nimport { NeuronId } from \"./types/common\";\nimport { defaultAgent } from \"./utils/agent.utils\";\n\n// HttpAgent options that can be used at construction.\nexport interface GenesisTokenCanisterOptions {\n // The agent to use when communicating with the canister.\n agent?: Agent;\n // The canister's ID.\n canisterId?: Principal;\n // The default service to use when calling into the IC. Primarily overridden\n // in test for mocking.\n serviceOverride?: GenesisTokenService;\n}\n\nexport class GenesisTokenCanister {\n private constructor(private readonly service: GenesisTokenService) {}\n\n public static create(options: GenesisTokenCanisterOptions = {}) {\n const agent = options.agent ?? defaultAgent();\n const canisterId = options.canisterId ?? MAINNET_GENESIS_TOKEN_CANISTER_ID;\n const service =\n options.serviceOverride ??\n Actor.createActor<GenesisTokenService>(idlFactory, {\n agent,\n canisterId,\n });\n\n return new GenesisTokenCanister(service);\n }\n\n public claimNeurons = async ({\n hexPubKey,\n }: {\n hexPubKey: string;\n }): Promise<NeuronId[]> => {\n const response = await this.service.claim_neurons(hexPubKey);\n if (\"Ok\" in response) {\n return response.Ok.map((neuronId) => neuronId.id);\n }\n\n throw new Error(response.Err);\n };\n}\n"],
|
|
5
|
+
"mappings": "sDACO,GAAM,GAAa,CAAC,CAAE,SAAU,CACrC,GAAM,GAAW,EAAI,OAAO,CAAE,GAAO,EAAI,KAAM,CAAC,EAC1C,EAAS,EAAI,QAAQ,CAAE,GAAO,EAAI,IAAI,CAAQ,EAAG,IAAQ,EAAI,IAAK,CAAC,EACnE,EAAW,EAAI,QAAQ,CAAE,GAAO,EAAI,KAAM,IAAQ,EAAI,IAAK,CAAC,EAC5D,EAAoB,EAAI,OAAO,CACnC,MAAU,EAAI,IAAI,EAAI,IAAI,EAC1B,kBAAsB,EAAI,MAC1B,UAAc,EAAI,IAAI,CAAQ,CAChC,CAAC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B,eAGyB,CACzB,GAAM,GAAW,KAAM,MAAK,QAAQ,cAAc,CAAS,EAC3D,GAAI,MAAQ,GACV,MAAO,GAAS,GAAG,IAAI,AAAC,GAAa,EAAS,EAAE,EAGlD,KAAM,IAAI,OAAM,EAAS,GAAG,CAC9B,CACF",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{a}from"./chunk-DRE7O6A5.js";import"./chunk-E6UFXMWU.js";import"./chunk-KXYKDST6.js";import"./chunk-ONAVPXOT.js";export{a as GenesisTokenCanister};
|
|
2
2
|
//# sourceMappingURL=genesis_token.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": [
|
|
4
|
-
"sourcesContent": [
|
|
5
|
-
"mappings": "
|
|
3
|
+
"sources": [],
|
|
4
|
+
"sourcesContent": [],
|
|
5
|
+
"mappings": "",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as
|
|
1
|
+
import{a as i}from"./chunk-DRE7O6A5.js";import{a as N,b as P,c as b,d as v,e as B,f as C,g as S,h as g,i as T,j as y,k as A,l as G,m as V,n as h,o as k,p as F,q as L,r as j,s as c}from"./chunk-NOBP3Q32.js";import{a,b as d}from"./chunk-XMQ7XZ3Q.js";import{a as q,b as w,c as z,d as D,e as E,f as H,g as J,h as m}from"./chunk-HPCMNLTU.js";import"./chunk-KUIJF2IJ.js";import"./chunk-QNJXXPDD.js";import"./chunk-E6UFXMWU.js";import"./chunk-KXYKDST6.js";import{c as _,d as I}from"./chunk-MTPVFXPH.js";import"./chunk-FL7E4DL3.js";import"./chunk-ONAVPXOT.js";var l=({recentBallots:e,proposalId:o})=>o?e.find(({proposalId:n})=>n===o)?.vote:void 0,x=({neurons:e,proposal:o})=>{let{ballots:r,proposalTimestampSeconds:n}=o;return e.filter(({createdTimestampSeconds:t,neuronId:f})=>{let p=t>n,s=r.find(({neuronId:u})=>u===f)===void 0;return p||s})},K=({neurons:e,proposal:o})=>{let{id:r}=o;return e.filter(({recentBallots:n,neuronId:t})=>l({recentBallots:n,proposalId:r})===void 0&&x({neurons:e,proposal:o}).find(({neuronId:f})=>f===t)===void 0)},M=({neurons:e,proposal:o})=>{let{id:r}=o;return e.filter(({recentBallots:n})=>l({recentBallots:n,proposalId:r})!==void 0)};export{a as AccountIdentifier,P as CouldNotClaimNeuronError,T as FeatureNotSupportedError,_ as FromICPStringError,i as GenesisTokenCanister,c as GovernanceCanister,B as GovernanceError,I as ICP,b as InsufficientAmountError,z as InsufficientFundsError,S as InvalidAccountIDError,C as InvalidPercentageError,w as InvalidSenderError,m as LedgerCanister,V as NeuronState,h as ProposalRewardStatus,k as ProposalStatus,N as StakeNeuronError,d as SubAccount,L as Topic,q as TransferError,E as TxCreatedInFutureError,H as TxDuplicateError,D as TxTooOldError,v as UnrecognizedTypeError,g as UnsupportedValueError,F as Vote,A as accountIdentifierFromBytes,y as accountIdentifierToBytes,j as checkAccountId,x as ineligibleNeurons,J as mapTransferError,G as principalToAccountIdentifier,K as votableNeurons,M as votedNeurons};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/utils/neurons.utils.ts"],
|
|
4
4
|
"sourcesContent": ["import type {\n Ballot,\n BallotInfo,\n NeuronInfo,\n ProposalId,\n ProposalInfo,\n Vote,\n} from \"../types/governance_converters\";\n\nconst voteForProposal = ({\n recentBallots,\n proposalId,\n}: {\n recentBallots: BallotInfo[];\n proposalId: ProposalId | undefined;\n}): Vote | undefined => {\n if (!proposalId) {\n return undefined;\n }\n\n const ballot: BallotInfo | undefined = recentBallots.find(\n ({ proposalId: id }: BallotInfo) => id === proposalId\n );\n return ballot?.vote;\n};\n\nexport const ineligibleNeurons = ({\n neurons,\n proposal,\n}: {\n neurons: NeuronInfo[];\n proposal: ProposalInfo;\n}): NeuronInfo[] => {\n const { ballots, proposalTimestampSeconds } = proposal;\n\n return neurons.filter(({ createdTimestampSeconds, neuronId }: NeuronInfo) => {\n const createdSinceProposal: boolean =\n createdTimestampSeconds > proposalTimestampSeconds;\n\n const dissolveTooShort: boolean =\n ballots.find(\n ({ neuronId: ballotNeuronId }: Ballot) => ballotNeuronId === neuronId\n ) === undefined;\n\n return createdSinceProposal || dissolveTooShort;\n });\n};\n\n/**\n * Neurons that can vote for the proposal (not voted, with voting power)\n */\nexport const votableNeurons = ({\n neurons,\n proposal,\n}: {\n neurons: NeuronInfo[];\n proposal: ProposalInfo;\n}): NeuronInfo[] => {\n const { id: proposalId } = proposal;\n\n return neurons.filter(\n ({ recentBallots, neuronId }: NeuronInfo) =>\n voteForProposal({ recentBallots, proposalId }) === undefined &&\n ineligibleNeurons({ neurons, proposal }).find(\n ({ neuronId: ineligibleNeuronId }: NeuronInfo) =>\n ineligibleNeuronId === neuronId\n ) === undefined\n );\n};\n\nexport const votedNeurons = ({\n neurons,\n proposal,\n}: {\n neurons: NeuronInfo[];\n proposal: ProposalInfo;\n}): NeuronInfo[] => {\n const { id: proposalId } = proposal;\n\n return neurons.filter(\n ({ recentBallots }: NeuronInfo) =>\n voteForProposal({ recentBallots, proposalId }) !== undefined\n );\n};\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": "wiBASA,GAAM,GAAkB,CAAC,CACvB,gBACA,gBAKK,EAOE,AAHgC,EAAc,KACnD,CAAC,CAAE,WAAY,KAAqB,IAAO,CAC7C,GACe,KANb,OASS,EAAoB,CAAC,CAChC,UACA,cAIkB,CAClB,GAAM,CAAE,UAAS,4BAA6B,EAE9C,MAAO,GAAQ,OAAO,CAAC,CAAE,0BAAyB,cAA2B,CAC3E,GAAM,GACJ,EAA0B,EAEtB,EACJ,EAAQ,KACN,CAAC,CAAE,SAAU,KAA6B,IAAmB,CAC/D,IAAM,OAER,MAAO,IAAwB,CACjC,CAAC,CACH,EAKa,EAAiB,CAAC,CAC7B,UACA,cAIkB,CAClB,GAAM,CAAE,GAAI,GAAe,EAE3B,MAAO,GAAQ,OACb,CAAC,CAAE,gBAAe,cAChB,EAAgB,CAAE,gBAAe,YAAW,CAAC,IAAM,QACnD,EAAkB,CAAE,UAAS,UAAS,CAAC,EAAE,KACvC,CAAC,CAAE,SAAU,KACX,IAAuB,CAC3B,IAAM,MACV,CACF,EAEa,EAAe,CAAC,CAC3B,UACA,cAIkB,CAClB,GAAM,CAAE,GAAI,GAAe,EAE3B,MAAO,GAAQ,OACb,CAAC,CAAE,mBACD,EAAgB,CAAE,gBAAe,YAAW,CAAC,IAAM,MACvD,CACF",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { AccountIdentifier, SubAccount } from "./account_identifier";
|
|
2
2
|
export * from "./errors/governance.errors";
|
|
3
3
|
export * from "./errors/ledger.errors";
|
|
4
|
+
export { GenesisTokenCanister } from "./genesis_token";
|
|
4
5
|
export { GovernanceCanister } from "./governance";
|
|
5
6
|
export { ICP } from "./icp";
|
|
6
7
|
export { LedgerCanister } from "./ledger";
|