@dfinity/nns 0.4.2 → 0.4.3

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,2 +1,2 @@
1
- import{a as S,b as T}from"./chunk-KUIJF2IJ.js";import{e as B}from"./chunk-QNJXXPDD.js";import{g as P,i as A}from"./chunk-E6UFXMWU.js";import{a as x,d as u}from"./chunk-MTPVFXPH.js";import{c as C}from"./chunk-FL7E4DL3.js";import{c as w}from"./chunk-ONAVPXOT.js";var n=w(C());var l=w(C());var E=r=>{let e=B(r,32),t=new l.Subaccount;return t.setSubAccount(new Uint8Array(e)),t},_=r=>{let e=new l.ICPTs;return e.setE8s(r.toString(10)),e};var c=class extends Error{},p=class extends c{},f=class extends c{constructor(t){super();this.balance=t}},g=class extends c{constructor(t){super();this.allowed_window_secs=t}},b=class extends c{},h=class extends c{constructor(t){super();this.duplicateOf=t}},N=r=>{let{message:e}=r;if(e.includes("Reject code: 5")){if(e.match(/Sending from (.*) is not allowed/))return new p;{let t=e.match(/transaction.*duplicate.* in block (\d+)/);if(t&&t.length>1)return new h(BigInt(t[1]))}{let t=e.match(/debit account.*, current balance: (\d*(\.\d*)?)/);if(t&&t.length>1){let o=u.fromString(t[1]);if(o instanceof u)return new f(o)}}if(e.includes("is in future"))return new b;{let t=e.match(/older than (\d+)/);if(t&&t.length>1)return new g(Number.parseInt(t[1]))}}throw r};var d=class{constructor(e,t,o,s){this.agent=e;this.canisterId=t;this.updateFetcher=o;this.queryFetcher=s}static create(e={}){return new d(e.agent??A(),e.canisterId??P,e.updateCallOverride??S,e.queryCallOverride??T)}accountBalance=async({accountIdentifier:e,certified:t=!0})=>{let o=t?this.updateFetcher:this.queryFetcher,s=new n.AccountBalanceRequest;s.setAccount(e.toProto());let m=await o({agent:this.agent,canisterId:this.canisterId,methodName:"account_balance_pb",arg:s.serializeBinary()});return u.fromE8s(BigInt(n.ICPTs.deserializeBinary(new Uint8Array(m)).getE8s()))};transfer=async({to:e,amount:t,memo:o,fee:s,fromSubAccountId:m})=>{let a=new n.SendRequest;a.setTo(e.toProto());let I=new n.Payment;I.setReceiverGets(t.toProto()),a.setPayment(I),a.setMaxFee(_(s??x));let y=new n.Memo;y.setMemo((o??BigInt(0)).toString()),a.setMemo(y),m!==void 0&&a.setFromSubaccount(E(m));try{let i=await this.updateFetcher({agent:this.agent,canisterId:this.canisterId,methodName:"send_pb",arg:a.serializeBinary()});return BigInt(n.BlockHeight.deserializeBinary(i).getHeight())}catch(i){throw i instanceof Error?N(i):i}}};export{c as a,p as b,f as c,g as d,b as e,h as f,N as g,d as h};
2
- //# sourceMappingURL=chunk-HPCMNLTU.js.map
1
+ import{a as S,b as T}from"./chunk-BCUFAIRO.js";import{e as B}from"./chunk-QNJXXPDD.js";import{g as P,i as A}from"./chunk-BVNLDI2R.js";import{a as x,d as u}from"./chunk-MTPVFXPH.js";import{c as C}from"./chunk-FL7E4DL3.js";import{c as w}from"./chunk-ONAVPXOT.js";var n=w(C());var l=w(C());var E=r=>{let e=B(r,32),t=new l.Subaccount;return t.setSubAccount(new Uint8Array(e)),t},_=r=>{let e=new l.ICPTs;return e.setE8s(r.toString(10)),e};var c=class extends Error{},p=class extends c{},f=class extends c{constructor(t){super();this.balance=t}},g=class extends c{constructor(t){super();this.allowed_window_secs=t}},b=class extends c{},h=class extends c{constructor(t){super();this.duplicateOf=t}},N=r=>{let{message:e}=r;if(e.includes("Reject code: 5")){if(e.match(/Sending from (.*) is not allowed/))return new p;{let t=e.match(/transaction.*duplicate.* in block (\d+)/);if(t&&t.length>1)return new h(BigInt(t[1]))}{let t=e.match(/debit account.*, current balance: (\d*(\.\d*)?)/);if(t&&t.length>1){let o=u.fromString(t[1]);if(o instanceof u)return new f(o)}}if(e.includes("is in future"))return new b;{let t=e.match(/older than (\d+)/);if(t&&t.length>1)return new g(Number.parseInt(t[1]))}}throw r};var d=class{constructor(e,t,o,s){this.agent=e;this.canisterId=t;this.updateFetcher=o;this.queryFetcher=s}static create(e={}){return new d(e.agent??A(),e.canisterId??P,e.updateCallOverride??S,e.queryCallOverride??T)}accountBalance=async({accountIdentifier:e,certified:t=!0})=>{let o=t?this.updateFetcher:this.queryFetcher,s=new n.AccountBalanceRequest;s.setAccount(e.toProto());let m=await o({agent:this.agent,canisterId:this.canisterId,methodName:"account_balance_pb",arg:s.serializeBinary()});return u.fromE8s(BigInt(n.ICPTs.deserializeBinary(new Uint8Array(m)).getE8s()))};transfer=async({to:e,amount:t,memo:o,fee:s,fromSubAccountId:m})=>{let a=new n.SendRequest;a.setTo(e.toProto());let I=new n.Payment;I.setReceiverGets(t.toProto()),a.setPayment(I),a.setMaxFee(_(s??x));let y=new n.Memo;y.setMemo((o??BigInt(0)).toString()),a.setMemo(y),m!==void 0&&a.setFromSubaccount(E(m));try{let i=await this.updateFetcher({agent:this.agent,canisterId:this.canisterId,methodName:"send_pb",arg:a.serializeBinary()});return BigInt(n.BlockHeight.deserializeBinary(i).getHeight())}catch(i){throw i instanceof Error?N(i):i}}};export{c as a,p as b,f as c,g as d,b as e,h as f,N as g,d as h};
2
+ //# sourceMappingURL=chunk-PTMKC5FF.js.map
@@ -1,2 +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
1
+ import{d as i,h as a,i as s}from"./chunk-BVNLDI2R.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-Z667VRMY.js.map
@@ -1,2 +1,2 @@
1
- import{a}from"./chunk-DRE7O6A5.js";import"./chunk-E6UFXMWU.js";import"./chunk-KXYKDST6.js";import"./chunk-ONAVPXOT.js";export{a as GenesisTokenCanister};
1
+ import{a}from"./chunk-Z667VRMY.js";import"./chunk-BVNLDI2R.js";import"./chunk-KXYKDST6.js";import"./chunk-ONAVPXOT.js";export{a as GenesisTokenCanister};
2
2
  //# sourceMappingURL=genesis_token.js.map
@@ -1,2 +1,2 @@
1
- import{s as a}from"./chunk-NOBP3Q32.js";import"./chunk-XMQ7XZ3Q.js";import"./chunk-KUIJF2IJ.js";import"./chunk-QNJXXPDD.js";import"./chunk-E6UFXMWU.js";import"./chunk-KXYKDST6.js";import"./chunk-MTPVFXPH.js";import"./chunk-FL7E4DL3.js";import"./chunk-ONAVPXOT.js";export{a as GovernanceCanister};
1
+ import{s as a}from"./chunk-FZYDRSYR.js";import"./chunk-XMQ7XZ3Q.js";import"./chunk-BCUFAIRO.js";import"./chunk-QNJXXPDD.js";import"./chunk-BVNLDI2R.js";import"./chunk-KXYKDST6.js";import"./chunk-MTPVFXPH.js";import"./chunk-FL7E4DL3.js";import"./chunk-ONAVPXOT.js";export{a as GovernanceCanister};
2
2
  //# sourceMappingURL=governance.js.map
package/dist/esm/index.js CHANGED
@@ -1,2 +1,2 @@
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};
1
+ import{a as i}from"./chunk-Z667VRMY.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-FZYDRSYR.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-PTMKC5FF.js";import"./chunk-BCUFAIRO.js";import"./chunk-QNJXXPDD.js";import"./chunk-BVNLDI2R.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
@@ -1,2 +1,2 @@
1
- import{h as a}from"./chunk-HPCMNLTU.js";import"./chunk-KUIJF2IJ.js";import"./chunk-QNJXXPDD.js";import"./chunk-E6UFXMWU.js";import"./chunk-KXYKDST6.js";import"./chunk-MTPVFXPH.js";import"./chunk-FL7E4DL3.js";import"./chunk-ONAVPXOT.js";export{a as LedgerCanister};
1
+ import{h as a}from"./chunk-PTMKC5FF.js";import"./chunk-BCUFAIRO.js";import"./chunk-QNJXXPDD.js";import"./chunk-BVNLDI2R.js";import"./chunk-KXYKDST6.js";import"./chunk-MTPVFXPH.js";import"./chunk-FL7E4DL3.js";import"./chunk-ONAVPXOT.js";export{a as LedgerCanister};
2
2
  //# sourceMappingURL=ledger.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dfinity/nns",
3
- "version": "0.4.2",
3
+ "version": "0.4.3",
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",
@@ -24,9 +24,9 @@
24
24
  "protoc": "bash ./scripts/update_proto.sh"
25
25
  },
26
26
  "dependencies": {
27
- "@dfinity/agent": "^0.11.1",
28
- "@dfinity/candid": "^0.11.1",
29
- "@dfinity/principal": "^0.11.1",
27
+ "@dfinity/agent": "^0.11.3",
28
+ "@dfinity/candid": "^0.11.3",
29
+ "@dfinity/principal": "^0.11.3",
30
30
  "crc": "^4.1.1",
31
31
  "crc-32": "^1.2.2",
32
32
  "google-protobuf": "^3.20.1",