@initia/initia.js 0.2.21 → 0.2.23

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.
Files changed (62) hide show
  1. package/README.md +30 -31
  2. package/dist/TransportWebHID-BJGOHoD4.js +1 -0
  3. package/dist/TransportWebHID-BpNQALzF.mjs +154 -0
  4. package/dist/TransportWebUSB-Bog8kAV9.js +1 -0
  5. package/dist/TransportWebUSB-Bs9AHNsu.mjs +196 -0
  6. package/dist/client/index.d.ts +0 -1
  7. package/dist/client/rest/APIRequester.d.ts +1 -0
  8. package/dist/client/rest/Wallet.d.ts +1 -0
  9. package/dist/client/rest/api/AuthzAPI.d.ts +1 -1
  10. package/dist/client/rest/api/EvmAPI.d.ts +4 -4
  11. package/dist/client/rest/api/ForwardingAPI.d.ts +2 -1
  12. package/dist/client/rest/api/GovAPI.d.ts +4 -4
  13. package/dist/client/rest/api/GroupAPI.d.ts +7 -7
  14. package/dist/client/rest/api/IbcAPI.d.ts +2 -2
  15. package/dist/client/rest/api/IbcNftAPI.d.ts +1 -1
  16. package/dist/client/rest/api/IbcPermAPI.d.ts +1 -1
  17. package/dist/client/rest/api/IbcTransferAPI.d.ts +1 -11
  18. package/dist/client/rest/api/MoveAPI.d.ts +12 -20
  19. package/dist/client/rest/api/MstakingAPI.d.ts +1 -1
  20. package/dist/client/rest/api/OpchildAPI.d.ts +1 -1
  21. package/dist/client/rest/api/OphostAPI.d.ts +10 -10
  22. package/dist/client/rest/api/SlashingAPI.d.ts +4 -22
  23. package/dist/client/rest/api/TxAPI.d.ts +3 -3
  24. package/dist/client/rest/api/WasmAPI.d.ts +4 -4
  25. package/dist/core/Duration.d.ts +1 -2
  26. package/dist/core/auth/BaseAccount.d.ts +2 -2
  27. package/dist/core/bank/msgs/MsgMultiSend.d.ts +8 -8
  28. package/dist/core/crisis/msgs/MsgVerifyInvariant.d.ts +7 -7
  29. package/dist/core/gov/Vote.d.ts +2 -2
  30. package/dist/core/ibc/applications/transfer/index.d.ts +1 -0
  31. package/dist/core/ibc/core/client/msgs/tendermint/crypto.d.ts +2 -2
  32. package/dist/core/ibc/core/client/msgs/tendermint/types.d.ts +27 -28
  33. package/dist/core/ibc/lightclient/tendermint/Header.d.ts +5 -5
  34. package/dist/core/move/Module.d.ts +36 -0
  35. package/dist/core/move/index.d.ts +1 -0
  36. package/dist/core/move/msgs/MsgExecute.d.ts +2 -2
  37. package/dist/core/move/msgs/MsgPublish.d.ts +2 -2
  38. package/dist/core/move/msgs/MsgScript.d.ts +2 -2
  39. package/dist/core/mstaking/Redelegation.d.ts +3 -3
  40. package/dist/core/mstaking/UnbondingDelegation.d.ts +3 -3
  41. package/dist/core/mstaking/Validator.d.ts +9 -9
  42. package/dist/core/mstaking/msgs/MsgDelegate.d.ts +2 -2
  43. package/dist/core/mstaking/msgs/MsgEditValidator.d.ts +2 -2
  44. package/dist/core/mstaking/msgs/MsgUndelegate.d.ts +2 -2
  45. package/dist/core/slashing/SlashingParams.d.ts +4 -4
  46. package/dist/core/slashing/ValidatorSigningInfo.d.ts +37 -0
  47. package/dist/core/slashing/index.d.ts +1 -0
  48. package/dist/core/tx/SignatureV2.d.ts +1 -1
  49. package/dist/index-BNBWMUWc.mjs +456 -0
  50. package/dist/index-BY4R60_E.js +2 -0
  51. package/dist/index.cjs.js +2 -2
  52. package/dist/index.es.js +10682 -8540
  53. package/dist/key/RawKey.d.ts +1 -1
  54. package/dist/util/bcs.d.ts +12 -10
  55. package/package.json +14 -18
  56. package/dist/TransportWebHID-BwOWyIog.mjs +0 -313
  57. package/dist/TransportWebHID-CVJmgfzo.js +0 -1
  58. package/dist/TransportWebUSB-BjylRdFj.mjs +0 -413
  59. package/dist/TransportWebUSB-V4VV5RPc.js +0 -1
  60. package/dist/client/LocalInitia.d.ts +0 -18
  61. package/dist/index-CGO7OOZz.js +0 -2
  62. package/dist/index-LYdmc_QU.mjs +0 -449
package/README.md CHANGED
@@ -24,13 +24,13 @@ The usage section of this document provides detailed explanations and code examp
24
24
  **REST**(previously LCD) class facilitates interaction with the Initia blockchain.
25
25
 
26
26
  ```typescript
27
- import { RESTClient } from '@initia/initia.js';
27
+ import { RESTClient } from '@initia/initia.js'
28
28
 
29
29
  const rest = new RESTClient('https://rest.testnet.initia.xyz', {
30
30
  chainId: 'initiation-2',
31
31
  gasPrices: '0.15uinit', // default gas prices
32
32
  gasAdjustment: '1.75', // default gas adjustment for fee estimation
33
- });
33
+ })
34
34
  ```
35
35
 
36
36
 
@@ -42,14 +42,14 @@ const rest = new RESTClient('https://rest.testnet.initia.xyz', {
42
42
  An abstract key interface that enables transaction signing and provides Bech32 address and public key derivation from a public key. 
43
43
 
44
44
  ```typescript
45
- import { MnemonicKey } from '@initia/initia.js';
45
+ import { MnemonicKey } from '@initia/initia.js'
46
46
 
47
47
  const key = new MnemonicKey({
48
48
  mnemonic: 'bird upset ... evil cigar', // (optional) if null, generate a new Mnemonic key
49
49
  account: 0, // (optional) BIP44 account number. default = 0
50
- index: 0, // (optional) BIP44 index number. defualt = 0
50
+ index: 0, // (optional) BIP44 index number. default = 0
51
51
  coinType: 118, // (optional) BIP44 coinType. default = 118
52
- });
52
+ })
53
53
  ```
54
54
 
55
55
  ### BCS
@@ -57,34 +57,33 @@ const key = new MnemonicKey({
57
57
  **BCS**(Binary Canonical Serialization) is the binary encoding for Move resources and other non-module values published on-chain.  
58
58
 
59
59
  ```typescript
60
- import { bcs } from '@initia/initia.js';
60
+ import { bcs } from '@initia/initia.js'
61
61
 
62
62
  // serialize, serialize value to BCS and encode it to base64
63
63
  const serializedU64 = bcs
64
64
  .u64() // type
65
65
  .serialize(1234) // value
66
- .toBase64();
66
+ .toBase64()
67
67
 
68
68
  // deserialize
69
69
  const deserializedU64 = bcs
70
70
  .u64() // type
71
- .parse(Uint8Array.from(Buffer.from(serializedU64, 'base64')));
71
+ .parse(Uint8Array.from(Buffer.from(serializedU64, 'base64')))
72
72
 
73
73
  // vector
74
74
  const serializedVector = bcs
75
75
  .vector(bcs.u64())
76
76
  .serialize([123, 456, 789])
77
- .toBase64();
77
+ .toBase64()
78
78
 
79
79
  // option
80
- const serializedSome = bcs.option(bcs.u64()).serialize(123);
81
- const serializedNone = bcs.option(bcs.u64()).serialize(null);
80
+ const serializedSome = bcs.option(bcs.u64()).serialize(123)
81
+ const serializedNone = bcs.option(bcs.u64()).serialize(null)
82
82
  ```
83
83
 
84
84
  **Support types for BCS**
85
85
  > \`u8\`, \`u16\`, \`u32\`, \`u64\`, \`u128\`, \`u256\`, \`bool\`, \`vector\`, \`address\`, \`string\`, \`option\`, \`fixed_point32\`, \`fixed_point64\`, \`decimal128\`, \`decimal256\`
86
86
 
87
-
88
87
  ### Msg 
89
88
 
90
89
  Msgs are object whose end-goal is to trigger state-transitions. They are wrapped in transactions, which may contain one or more of them.
@@ -94,13 +93,13 @@ Msgs are object whose end-goal is to trigger state-transitions. They are wrapped
94
93
  Send coins to others.
95
94
 
96
95
  ```typescript
97
- import { MsgSend } from '@initia/initia.js';
96
+ import { MsgSend } from '@initia/initia.js'
98
97
 
99
98
  const msg = new MsgSend(
100
99
  'init1kdwzpz3wzvpdj90gtga4fw5zm9tk4cyrgnjauu', // sender address
101
100
  'init18sj3x80fdjc6gzfvwl7lf8sxcvuvqjpvcmp6np', // recipient address
102
101
  '1000uinit', // send amount
103
- );
102
+ )
104
103
  ```
105
104
 
106
105
  * `MsgDelegate()`
@@ -108,13 +107,13 @@ const msg = new MsgSend(
108
107
  Delegate governance coin to validators (staking).
109
108
 
110
109
  ```typescript
111
- import { MsgDelegate } from '@initia/initia.js';
110
+ import { MsgDelegate } from '@initia/initia.js'
112
111
 
113
112
  const msg = new MsgDelegate(
114
113
  'init1kdwzpz3wzvpdj90gtga4fw5zm9tk4cyrgnjauu', // delegator address
115
- 'init18sj3x80fdjc6gzfvwl7lf8sxcvuvqjpvcmp6np', // validator's operator addres
114
+ 'init18sj3x80fdjc6gzfvwl7lf8sxcvuvqjpvcmp6np', // validator's operator address
116
115
  '100000uinit', // delegate amount
117
- );
116
+ )
118
117
  ```
119
118
 
120
119
  * `MsgUndelegate()`
@@ -122,13 +121,13 @@ const msg = new MsgDelegate(
122
121
  Undelegate governance coin from validators (unstaking).
123
122
 
124
123
  ```typescript
125
- import { MsgUndelegate } from '@initia/initia.js';
124
+ import { MsgUndelegate } from '@initia/initia.js'
126
125
 
127
126
  const msg = new MsgUndelegate(
128
127
  'init1kdwzpz3wzvpdj90gtga4fw5zm9tk4cyrgnjauu', // delegator address
129
- 'init18sj3x80fdjc6gzfvwl7lf8sxcvuvqjpvcmp6np', // validator's operator addres
128
+ 'init18sj3x80fdjc6gzfvwl7lf8sxcvuvqjpvcmp6np', // validator's operator address
130
129
  '100000uinit', // undelegate amount
131
- );
130
+ )
132
131
  ```
133
132
 
134
133
  * `MsgExecute()`
@@ -136,7 +135,7 @@ const msg = new MsgUndelegate(
136
135
  Execute move contract function.
137
136
 
138
137
  ```typescript
139
- import { MsgExecute } from '@initia/initia.js';
138
+ import { MsgExecute } from '@initia/initia.js'
140
139
 
141
140
  const msg = new MsgExecute(
142
141
  'init1kdwzpz3wzvpdj90gtga4fw5zm9tk4cyrgnjauu', // sender address
@@ -149,7 +148,7 @@ const msg = new MsgExecute(
149
148
  bcs.address().serialize('0x3').toBase64(), // arguments, BCS-encoded
150
149
  bcs.u64().serialize(10000).toBase64() // arguments, BCS-encoded
151
150
  ]
152
- );
151
+ )
153
152
  ```
154
153
 
155
154
  ### Tx broadcasting 
@@ -159,31 +158,31 @@ const msg = new MsgExecute(
159
158
  Create a wallet and sign transaction.  
160
159
 
161
160
  ```typescript
162
- import { Wallet, RESTClient, MnemonicKey } from '@initia/initia.js';
161
+ import { Wallet, RESTClient, MnemonicKey } from '@initia/initia.js'
163
162
 
164
163
  const key = new MnemonicKey({
165
164
  mnemonic:
166
165
  'moral wise tape glance grit gentle movie doll omit you pet soon enter year funny gauge digital supply cereal city ring egg repair coyote',
167
- });
166
+ })
168
167
 
169
168
  const rest = new RESTClient('https://rest.testnet.initia.xyz', {
170
169
  chainId: 'initiation-2',
171
170
  gasPrices: '0.15uinit', // default gas prices
172
171
  gasAdjustment: '1.75', // default gas adjustment for fee estimation
173
- });
172
+ })
174
173
 
175
- const wallet = new Wallet(rest, key);
174
+ const wallet = new Wallet(rest, key)
176
175
 
177
176
  const sendMsg = new MsgSend(
178
177
  'init14l3c2vxrdvu6y0sqykppey930s4kufsvt97aeu', // sender address
179
178
  'init18sj3x80fdjc6gzfvwl7lf8sxcvuvqjpvcmp6np', // recipient address
180
179
  '1000uinit', // send amount
181
- );
180
+ )
182
181
 
183
182
  const signedTx = await wallet.createAndSignTx({
184
183
  msgs: [sendMsg],
185
184
  memo: 'sample memo',
186
- });
185
+ })
187
186
  ```
188
187
 
189
188
  When sending coins with `MsgSend`, sender address should be same with wallet address.
@@ -193,7 +192,7 @@ When sending coins with `MsgSend`, sender address should be same with wallet add
193
192
  `broadcast()` is the action that sends your transaction to the blockchain code.
194
193
 
195
194
  ```typescript
196
- const broadcastResult = await rest.tx.broadcast(signedTx);
195
+ const broadcastResult = await rest.tx.broadcast(signedTx)
197
196
  ```
198
197
 
199
198
  ### Queries 
@@ -203,7 +202,7 @@ const broadcastResult = await rest.tx.broadcast(signedTx);
203
202
  Query the balance of the account.
204
203
 
205
204
  ```typescript
206
- const balances = await rest.bank.balance('init14l3c2vxrdvu6y0sqykppey930s4kufsvt97aeu');
205
+ const balances = await rest.bank.balance('init14l3c2vxrdvu6y0sqykppey930s4kufsvt97aeu')
207
206
  ```
208
207
 
209
208
  * `viewfunction()`
@@ -221,5 +220,5 @@ const res = await rest.move.viewFunction(
221
220
  bcs.address().serialize('0x3').toBase64(), // arguments, BCS-encoded
222
221
  bcs.u64().serialize(10000).toBase64() // arguments, BCS-encoded
223
222
  ]
224
- );
223
+ )
225
224
  ```
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("@ledgerhq/hw-transport"),o=require("./index-BY4R60_E.js");var c=function(i,e,t,n){function r(l){return l instanceof t?l:new t(function(d){d(l)})}return new(t||(t=Promise))(function(l,d){function f(s){try{a(n.next(s))}catch(v){d(v)}}function h(s){try{a(n.throw(s))}catch(v){d(v)}}function a(s){s.done?l(s.value):r(s.value).then(f,h)}a((n=n.apply(i,e||[])).next())})};const w=[{vendorId:o.ledgerUSBVendorId}],D=()=>Promise.resolve(!!(window.navigator&&window.navigator.hid)),p=()=>{const{hid:i}=navigator;if(!i)throw new o.TransportError("navigator.hid is not supported","HIDNotSupported");return i};function m(){return c(this,void 0,void 0,function*(){const i=yield p().requestDevice({filters:w});return Array.isArray(i)?i:[i]})}function g(){return c(this,void 0,void 0,function*(){return(yield p().getDevices()).filter(e=>e.vendorId===o.ledgerUSBVendorId)})}function I(){return c(this,void 0,void 0,function*(){const i=yield g();return i.length>0?i[0]:(yield m())[0]})}class u extends y{constructor(e){super(),this.channel=Math.floor(Math.random()*65535),this.packetSize=64,this.inputs=[],this.read=()=>this.inputs.length?Promise.resolve(this.inputs.shift()):new Promise(t=>{this.inputCallback=t}),this.onInputReport=t=>{const n=Buffer.from(t.data.buffer);this.inputCallback?(this.inputCallback(n),this.inputCallback=null):this.inputs.push(n)},this._disconnectEmitted=!1,this._emitDisconnect=t=>{this._disconnectEmitted||(this._disconnectEmitted=!0,this.emit("disconnect",t))},this.exchange=t=>c(this,void 0,void 0,function*(){return yield this.exchangeAtomicImpl(()=>c(this,void 0,void 0,function*(){const{channel:r,packetSize:l}=this;o.log("apdu","=> "+t.toString("hex"));const d=o.createHIDframing(r,l),f=d.makeBlocks(t);for(let s=0;s<f.length;s++)yield this.device.sendReport(0,f[s]);let h,a;for(;!(h=d.getReducedResult(a));){const s=yield this.read();a=d.reduceResponse(a,s)}return o.log("apdu","<= "+h.toString("hex")),h})).catch(r=>{throw r&&r.message&&r.message.includes("write")?(this._emitDisconnect(r),new o.DisconnectedDeviceDuringOperation(r.message)):r})}),this.device=e,this.deviceModel=typeof e.productId=="number"?o.identifyUSBProductId(e.productId):void 0,e.addEventListener("inputreport",this.onInputReport)}static request(){return c(this,void 0,void 0,function*(){const[e]=yield m();return u.open(e)})}static openConnected(){return c(this,void 0,void 0,function*(){const e=yield g();return e.length===0?null:u.open(e[0])})}static open(e){return c(this,void 0,void 0,function*(){yield e.open();const t=new u(e),n=r=>{e===r.device&&(p().removeEventListener("disconnect",n),t._emitDisconnect(new o.DisconnectedDevice))};return p().addEventListener("disconnect",n),t})}close(){return c(this,void 0,void 0,function*(){yield this.exchangeBusyPromise,this.device.removeEventListener("inputreport",this.onInputReport),yield this.device.close()})}setScrambleKey(){}}u.isSupported=D;u.list=g;u.listen=i=>{let e=!1;I().then(n=>{if(!n)i.error(new o.TransportOpenUserCancelled("Access denied to use Ledger device"));else if(!e){const r=typeof n.productId=="number"?o.identifyUSBProductId(n.productId):void 0;i.next({type:"add",descriptor:n,deviceModel:r}),i.complete()}},n=>{i.error(new o.TransportOpenUserCancelled(n.message))});function t(){e=!0}return{unsubscribe:t}};exports.default=u;
@@ -0,0 +1,154 @@
1
+ import b from "@ledgerhq/hw-transport";
2
+ import { l as m, D as I, i as y, T as g, a as x, b as w, c as S, d as k } from "./index-BNBWMUWc.mjs";
3
+ var r = function(i, e, t, n) {
4
+ function s(d) {
5
+ return d instanceof t ? d : new t(function(c) {
6
+ c(d);
7
+ });
8
+ }
9
+ return new (t || (t = Promise))(function(d, c) {
10
+ function h(o) {
11
+ try {
12
+ u(n.next(o));
13
+ } catch (p) {
14
+ c(p);
15
+ }
16
+ }
17
+ function l(o) {
18
+ try {
19
+ u(n.throw(o));
20
+ } catch (p) {
21
+ c(p);
22
+ }
23
+ }
24
+ function u(o) {
25
+ o.done ? d(o.value) : s(o.value).then(h, l);
26
+ }
27
+ u((n = n.apply(i, e || [])).next());
28
+ });
29
+ };
30
+ const E = [
31
+ {
32
+ vendorId: w
33
+ }
34
+ ], L = () => Promise.resolve(!!(window.navigator && window.navigator.hid)), f = () => {
35
+ const { hid: i } = navigator;
36
+ if (!i)
37
+ throw new x("navigator.hid is not supported", "HIDNotSupported");
38
+ return i;
39
+ };
40
+ function D() {
41
+ return r(this, void 0, void 0, function* () {
42
+ const i = yield f().requestDevice({
43
+ filters: E
44
+ });
45
+ return Array.isArray(i) ? i : [i];
46
+ });
47
+ }
48
+ function v() {
49
+ return r(this, void 0, void 0, function* () {
50
+ return (yield f().getDevices()).filter((e) => e.vendorId === w);
51
+ });
52
+ }
53
+ function R() {
54
+ return r(this, void 0, void 0, function* () {
55
+ const i = yield v();
56
+ return i.length > 0 ? i[0] : (yield D())[0];
57
+ });
58
+ }
59
+ class a extends b {
60
+ constructor(e) {
61
+ super(), this.channel = Math.floor(Math.random() * 65535), this.packetSize = 64, this.inputs = [], this.read = () => this.inputs.length ? Promise.resolve(this.inputs.shift()) : new Promise((t) => {
62
+ this.inputCallback = t;
63
+ }), this.onInputReport = (t) => {
64
+ const n = Buffer.from(t.data.buffer);
65
+ this.inputCallback ? (this.inputCallback(n), this.inputCallback = null) : this.inputs.push(n);
66
+ }, this._disconnectEmitted = !1, this._emitDisconnect = (t) => {
67
+ this._disconnectEmitted || (this._disconnectEmitted = !0, this.emit("disconnect", t));
68
+ }, this.exchange = (t) => r(this, void 0, void 0, function* () {
69
+ return yield this.exchangeAtomicImpl(() => r(this, void 0, void 0, function* () {
70
+ const { channel: s, packetSize: d } = this;
71
+ m("apdu", "=> " + t.toString("hex"));
72
+ const c = S(s, d), h = c.makeBlocks(t);
73
+ for (let o = 0; o < h.length; o++)
74
+ yield this.device.sendReport(0, h[o]);
75
+ let l, u;
76
+ for (; !(l = c.getReducedResult(u)); ) {
77
+ const o = yield this.read();
78
+ u = c.reduceResponse(u, o);
79
+ }
80
+ return m("apdu", "<= " + l.toString("hex")), l;
81
+ })).catch((s) => {
82
+ throw s && s.message && s.message.includes("write") ? (this._emitDisconnect(s), new I(s.message)) : s;
83
+ });
84
+ }), this.device = e, this.deviceModel = typeof e.productId == "number" ? y(e.productId) : void 0, e.addEventListener("inputreport", this.onInputReport);
85
+ }
86
+ /**
87
+ * Similar to create() except it will always display the device permission (even if some devices are already accepted).
88
+ */
89
+ static request() {
90
+ return r(this, void 0, void 0, function* () {
91
+ const [e] = yield D();
92
+ return a.open(e);
93
+ });
94
+ }
95
+ /**
96
+ * Similar to create() except it will never display the device permission (it returns a Promise<?Transport>, null if it fails to find a device).
97
+ */
98
+ static openConnected() {
99
+ return r(this, void 0, void 0, function* () {
100
+ const e = yield v();
101
+ return e.length === 0 ? null : a.open(e[0]);
102
+ });
103
+ }
104
+ /**
105
+ * Create a Ledger transport with a HIDDevice
106
+ */
107
+ static open(e) {
108
+ return r(this, void 0, void 0, function* () {
109
+ yield e.open();
110
+ const t = new a(e), n = (s) => {
111
+ e === s.device && (f().removeEventListener("disconnect", n), t._emitDisconnect(new k()));
112
+ };
113
+ return f().addEventListener("disconnect", n), t;
114
+ });
115
+ }
116
+ /**
117
+ * Release the transport device
118
+ */
119
+ close() {
120
+ return r(this, void 0, void 0, function* () {
121
+ yield this.exchangeBusyPromise, this.device.removeEventListener("inputreport", this.onInputReport), yield this.device.close();
122
+ });
123
+ }
124
+ setScrambleKey() {
125
+ }
126
+ }
127
+ a.isSupported = L;
128
+ a.list = v;
129
+ a.listen = (i) => {
130
+ let e = !1;
131
+ R().then((n) => {
132
+ if (!n)
133
+ i.error(new g("Access denied to use Ledger device"));
134
+ else if (!e) {
135
+ const s = typeof n.productId == "number" ? y(n.productId) : void 0;
136
+ i.next({
137
+ type: "add",
138
+ descriptor: n,
139
+ deviceModel: s
140
+ }), i.complete();
141
+ }
142
+ }, (n) => {
143
+ i.error(new g(n.message));
144
+ });
145
+ function t() {
146
+ e = !0;
147
+ }
148
+ return {
149
+ unsubscribe: t
150
+ };
151
+ };
152
+ export {
153
+ a as default
154
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("@ledgerhq/hw-transport"),d=require("./index-BY4R60_E.js");var p=function(r,e,o,t){function u(n){return n instanceof o?n:new o(function(i){i(n)})}return new(o||(o=Promise))(function(n,i){function a(c){try{s(t.next(c))}catch(h){i(h)}}function l(c){try{s(t.throw(c))}catch(h){i(h)}}function s(c){c.done?n(c.value):u(c.value).then(a,l)}s((t=t.apply(r,e||[])).next())})};const D=[{vendorId:d.ledgerUSBVendorId}];function w(){return p(this,void 0,void 0,function*(){return yield navigator.usb.requestDevice({filters:D})})}function g(){return p(this,void 0,void 0,function*(){return(yield navigator.usb.getDevices()).filter(e=>e.vendorId===d.ledgerUSBVendorId)})}function x(){return p(this,void 0,void 0,function*(){const r=yield g();return r.length>0?r[0]:w()})}const I=()=>Promise.resolve(!!navigator&&!!navigator.usb&&typeof navigator.usb.getDevices=="function");var v=function(r,e,o,t){function u(n){return n instanceof o?n:new o(function(i){i(n)})}return new(o||(o=Promise))(function(n,i){function a(c){try{s(t.next(c))}catch(h){i(h)}}function l(c){try{s(t.throw(c))}catch(h){i(h)}}function s(c){c.done?n(c.value):u(c.value).then(a,l)}s((t=t.apply(r,e||[])).next())})};const S=1,m=3;class f extends b{constructor(e,o){super(),this.channel=Math.floor(Math.random()*65535),this.packetSize=64,this._disconnectEmitted=!1,this._emitDisconnect=t=>{this._disconnectEmitted||(this._disconnectEmitted=!0,this.emit("disconnect",t))},this.device=e,this.interfaceNumber=o,this.deviceModel=d.identifyUSBProductId(e.productId)}static request(){return v(this,void 0,void 0,function*(){const e=yield w();return f.open(e)})}static openConnected(){return v(this,void 0,void 0,function*(){const e=yield g();return e.length===0?null:f.open(e[0])})}static open(e){return v(this,void 0,void 0,function*(){yield e.open(),e.configuration===null&&(yield e.selectConfiguration(S)),yield y(e);const o=e.configurations[0].interfaces.find(({alternates:i})=>i.some(a=>a.interfaceClass===255));if(!o)throw new d.TransportInterfaceNotAvailable("No WebUSB interface found for your Ledger device. Please upgrade firmware or contact techsupport.");const t=o.interfaceNumber;try{yield e.claimInterface(t)}catch(i){throw yield e.close(),new d.TransportInterfaceNotAvailable(i.message)}const u=new f(e,t),n=i=>{e===i.device&&(navigator.usb.removeEventListener("disconnect",n),u._emitDisconnect(new d.DisconnectedDevice))};return navigator.usb.addEventListener("disconnect",n),u})}close(){return v(this,void 0,void 0,function*(){yield this.exchangeBusyPromise,yield this.device.releaseInterface(this.interfaceNumber),yield y(this.device),yield this.device.close()})}exchange(e){return v(this,void 0,void 0,function*(){return yield this.exchangeAtomicImpl(()=>v(this,void 0,void 0,function*(){const{channel:t,packetSize:u}=this;d.log("apdu","=> "+e.toString("hex"));const n=d.createHIDframing(t,u),i=n.makeBlocks(e);for(let s=0;s<i.length;s++)yield this.device.transferOut(m,i[s]);let a,l;for(;!(a=n.getReducedResult(l));){const s=yield this.device.transferIn(m,u),c=Buffer.from(s.data.buffer);l=n.reduceResponse(l,c)}return d.log("apdu","<= "+a.toString("hex")),a})).catch(t=>{throw t&&t.message&&t.message.includes("disconnected")?(this._emitDisconnect(t),new d.DisconnectedDeviceDuringOperation(t.message)):t})})}setScrambleKey(){}}f.isSupported=I;f.list=g;f.listen=r=>{let e=!1;x().then(t=>{if(!e){const u=d.identifyUSBProductId(t.productId);r.next({type:"add",descriptor:t,deviceModel:u}),r.complete()}},t=>{window.DOMException&&t instanceof window.DOMException&&t.code===18?r.error(new d.TransportWebUSBGestureRequired(t.message)):r.error(new d.TransportOpenUserCancelled(t.message))});function o(){e=!0}return{unsubscribe:o}};function y(r){return v(this,void 0,void 0,function*(){try{yield r.reset()}catch(e){console.warn(e)}})}exports.default=f;
@@ -0,0 +1,196 @@
1
+ import I from "@ledgerhq/hw-transport";
2
+ import { b as D, i as b, e as m, l as g, D as _, f as S, T as E, d as N, c as L } from "./index-BNBWMUWc.mjs";
3
+ var v = function(s, e, c, t) {
4
+ function d(n) {
5
+ return n instanceof c ? n : new c(function(i) {
6
+ i(n);
7
+ });
8
+ }
9
+ return new (c || (c = Promise))(function(n, i) {
10
+ function u(o) {
11
+ try {
12
+ r(t.next(o));
13
+ } catch (f) {
14
+ i(f);
15
+ }
16
+ }
17
+ function a(o) {
18
+ try {
19
+ r(t.throw(o));
20
+ } catch (f) {
21
+ i(f);
22
+ }
23
+ }
24
+ function r(o) {
25
+ o.done ? n(o.value) : d(o.value).then(u, a);
26
+ }
27
+ r((t = t.apply(s, e || [])).next());
28
+ });
29
+ };
30
+ const M = [
31
+ {
32
+ vendorId: D
33
+ }
34
+ ];
35
+ function x() {
36
+ return v(this, void 0, void 0, function* () {
37
+ return yield navigator.usb.requestDevice({
38
+ filters: M
39
+ });
40
+ });
41
+ }
42
+ function p() {
43
+ return v(this, void 0, void 0, function* () {
44
+ return (yield navigator.usb.getDevices()).filter((e) => e.vendorId === D);
45
+ });
46
+ }
47
+ function k() {
48
+ return v(this, void 0, void 0, function* () {
49
+ const s = yield p();
50
+ return s.length > 0 ? s[0] : x();
51
+ });
52
+ }
53
+ const B = () => Promise.resolve(!!navigator && !!navigator.usb && typeof navigator.usb.getDevices == "function");
54
+ var l = function(s, e, c, t) {
55
+ function d(n) {
56
+ return n instanceof c ? n : new c(function(i) {
57
+ i(n);
58
+ });
59
+ }
60
+ return new (c || (c = Promise))(function(n, i) {
61
+ function u(o) {
62
+ try {
63
+ r(t.next(o));
64
+ } catch (f) {
65
+ i(f);
66
+ }
67
+ }
68
+ function a(o) {
69
+ try {
70
+ r(t.throw(o));
71
+ } catch (f) {
72
+ i(f);
73
+ }
74
+ }
75
+ function r(o) {
76
+ o.done ? n(o.value) : d(o.value).then(u, a);
77
+ }
78
+ r((t = t.apply(s, e || [])).next());
79
+ });
80
+ };
81
+ const O = 1, y = 3;
82
+ class h extends I {
83
+ constructor(e, c) {
84
+ super(), this.channel = Math.floor(Math.random() * 65535), this.packetSize = 64, this._disconnectEmitted = !1, this._emitDisconnect = (t) => {
85
+ this._disconnectEmitted || (this._disconnectEmitted = !0, this.emit("disconnect", t));
86
+ }, this.device = e, this.interfaceNumber = c, this.deviceModel = b(e.productId);
87
+ }
88
+ /**
89
+ * Similar to create() except it will always display the device permission (even if some devices are already accepted).
90
+ */
91
+ static request() {
92
+ return l(this, void 0, void 0, function* () {
93
+ const e = yield x();
94
+ return h.open(e);
95
+ });
96
+ }
97
+ /**
98
+ * Similar to create() except it will never display the device permission (it returns a Promise<?Transport>, null if it fails to find a device).
99
+ */
100
+ static openConnected() {
101
+ return l(this, void 0, void 0, function* () {
102
+ const e = yield p();
103
+ return e.length === 0 ? null : h.open(e[0]);
104
+ });
105
+ }
106
+ /**
107
+ * Create a Ledger transport with a USBDevice
108
+ */
109
+ static open(e) {
110
+ return l(this, void 0, void 0, function* () {
111
+ yield e.open(), e.configuration === null && (yield e.selectConfiguration(O)), yield w(e);
112
+ const c = e.configurations[0].interfaces.find(({ alternates: i }) => i.some((u) => u.interfaceClass === 255));
113
+ if (!c)
114
+ throw new m("No WebUSB interface found for your Ledger device. Please upgrade firmware or contact techsupport.");
115
+ const t = c.interfaceNumber;
116
+ try {
117
+ yield e.claimInterface(t);
118
+ } catch (i) {
119
+ throw yield e.close(), new m(i.message);
120
+ }
121
+ const d = new h(e, t), n = (i) => {
122
+ e === i.device && (navigator.usb.removeEventListener("disconnect", n), d._emitDisconnect(new N()));
123
+ };
124
+ return navigator.usb.addEventListener("disconnect", n), d;
125
+ });
126
+ }
127
+ /**
128
+ * Release the transport device
129
+ */
130
+ close() {
131
+ return l(this, void 0, void 0, function* () {
132
+ yield this.exchangeBusyPromise, yield this.device.releaseInterface(this.interfaceNumber), yield w(this.device), yield this.device.close();
133
+ });
134
+ }
135
+ /**
136
+ * Exchange with the device using APDU protocol.
137
+ * @param apdu
138
+ * @returns a promise of apdu response
139
+ */
140
+ exchange(e) {
141
+ return l(this, void 0, void 0, function* () {
142
+ return yield this.exchangeAtomicImpl(() => l(this, void 0, void 0, function* () {
143
+ const { channel: t, packetSize: d } = this;
144
+ g("apdu", "=> " + e.toString("hex"));
145
+ const n = L(t, d), i = n.makeBlocks(e);
146
+ for (let r = 0; r < i.length; r++)
147
+ yield this.device.transferOut(y, i[r]);
148
+ let u, a;
149
+ for (; !(u = n.getReducedResult(a)); ) {
150
+ const r = yield this.device.transferIn(y, d), o = Buffer.from(r.data.buffer);
151
+ a = n.reduceResponse(a, o);
152
+ }
153
+ return g("apdu", "<= " + u.toString("hex")), u;
154
+ })).catch((t) => {
155
+ throw t && t.message && t.message.includes("disconnected") ? (this._emitDisconnect(t), new _(t.message)) : t;
156
+ });
157
+ });
158
+ }
159
+ setScrambleKey() {
160
+ }
161
+ }
162
+ h.isSupported = B;
163
+ h.list = p;
164
+ h.listen = (s) => {
165
+ let e = !1;
166
+ k().then((t) => {
167
+ if (!e) {
168
+ const d = b(t.productId);
169
+ s.next({
170
+ type: "add",
171
+ descriptor: t,
172
+ deviceModel: d
173
+ }), s.complete();
174
+ }
175
+ }, (t) => {
176
+ window.DOMException && t instanceof window.DOMException && t.code === 18 ? s.error(new S(t.message)) : s.error(new E(t.message));
177
+ });
178
+ function c() {
179
+ e = !0;
180
+ }
181
+ return {
182
+ unsubscribe: c
183
+ };
184
+ };
185
+ function w(s) {
186
+ return l(this, void 0, void 0, function* () {
187
+ try {
188
+ yield s.reset();
189
+ } catch (e) {
190
+ console.warn(e);
191
+ }
192
+ });
193
+ }
194
+ export {
195
+ h as default
196
+ };
@@ -2,5 +2,4 @@ export * from './rest/APIRequester';
2
2
  export * from './rest/RESTClient';
3
3
  export * from './rest/Wallet';
4
4
  export * from './rest/api';
5
- export * from './LocalInitia';
6
5
  export * from './WebSocketClient';
@@ -19,6 +19,7 @@ export declare class APIRequester {
19
19
  private axios;
20
20
  private readonly baseURL;
21
21
  constructor(baseURL: string, config?: CreateAxiosDefaults<any> | undefined);
22
+ private validateEndpoint;
22
23
  private computeEndpoint;
23
24
  getRaw<T>(endpoint: string, params?: URLSearchParams | APIParams): Promise<T>;
24
25
  get<T>(endpoint: string, params?: URLSearchParams | APIParams, headers?: AxiosHeaders): Promise<T>;
@@ -7,6 +7,7 @@ export declare class Wallet {
7
7
  rest: RESTClient;
8
8
  key: Key;
9
9
  private accAddress;
10
+ lcd: RESTClient;
10
11
  constructor(rest: RESTClient, key: Key);
11
12
  setAccountAddress(accAddress: string): void;
12
13
  accountNumberAndSequence(): Promise<{
@@ -2,7 +2,7 @@ import { AccAddress, AuthorizationGrant } from '../../../core';
2
2
  import { BaseAPI } from './BaseAPI';
3
3
  import { APIParams, Pagination } from '../APIRequester';
4
4
  export declare class AuthzAPI extends BaseAPI {
5
- grants(granter: AccAddress, grantee: AccAddress, msgTypeUrl?: string, params?: APIParams): Promise<[AuthorizationGrant[], Pagination]>;
5
+ grants(granter: AccAddress, grantee: AccAddress, msg_type_url?: string, params?: APIParams): Promise<[AuthorizationGrant[], Pagination]>;
6
6
  granter(granter: AccAddress, params?: APIParams): Promise<[AuthorizationGrant[], Pagination]>;
7
7
  grantee(grantee: AccAddress, params?: APIParams): Promise<[AuthorizationGrant[], Pagination]>;
8
8
  }
@@ -12,11 +12,11 @@ export interface CallResponse {
12
12
  trace_output: string;
13
13
  }
14
14
  export declare class EvmAPI extends BaseAPI {
15
- code(contractAddr: AccAddress, params?: APIParams): Promise<string>;
16
- state(contractAddr: AccAddress, key: string, params?: APIParams): Promise<string>;
15
+ code(contract_addr: AccAddress, params?: APIParams): Promise<string>;
16
+ state(contract_addr: AccAddress, key: string, params?: APIParams): Promise<string>;
17
17
  erc20Factory(params?: APIParams): Promise<string>;
18
18
  contractAddrByDenom(denom: string, params?: APIParams): Promise<AccAddress>;
19
- denom(contractAddr: AccAddress, params?: APIParams): Promise<string>;
20
- call(sender: AccAddress, contractAddr: AccAddress, input: string, withTrace: boolean): Promise<CallResponse>;
19
+ denom(contract_addr: AccAddress, params?: APIParams): Promise<string>;
20
+ call(sender: AccAddress, contract_addr: AccAddress, input: string, with_trace: boolean): Promise<CallResponse>;
21
21
  parameters(params?: APIParams): Promise<EvmParams>;
22
22
  }
@@ -14,6 +14,7 @@ export declare namespace ForwardingStats {
14
14
  }
15
15
  }
16
16
  export declare class ForwardingAPI extends BaseAPI {
17
- address(channel: string, recipient: string, params?: APIParams): Promise<AccAddress>;
17
+ denoms(params?: APIParams): Promise<string[]>;
18
+ address(channel: string, recipient: string, fallback: string, params?: APIParams): Promise<AccAddress>;
18
19
  stats(channel: string, params?: APIParams): Promise<ForwardingStats>;
19
20
  }
@@ -3,10 +3,10 @@ import { Proposal, Deposit, Vote, GovParams, TallyResult } from '../../../core';
3
3
  import { APIParams, Pagination, PaginationOptions } from '../APIRequester';
4
4
  export declare class GovAPI extends BaseAPI {
5
5
  proposals(params?: Partial<PaginationOptions & APIParams>): Promise<[Proposal[], Pagination]>;
6
- proposal(proposalId: number, params?: APIParams): Promise<Proposal>;
7
- deposits(proposalId: number, _params?: Partial<PaginationOptions & APIParams>): Promise<[Deposit[], Pagination]>;
8
- votes(proposalId: number, _params?: Partial<PaginationOptions & APIParams>): Promise<[Vote[], Pagination]>;
9
- tally(proposalId: number, params?: APIParams): Promise<TallyResult>;
6
+ proposal(proposal_id: number, params?: APIParams): Promise<Proposal>;
7
+ deposits(proposal_id: number, params?: Partial<PaginationOptions & APIParams>): Promise<[Deposit[], Pagination]>;
8
+ votes(proposal_id: number, params?: Partial<PaginationOptions & APIParams>): Promise<[Vote[], Pagination]>;
9
+ tally(proposal_id: number, params?: APIParams): Promise<TallyResult>;
10
10
  parameters(params?: APIParams): Promise<GovParams>;
11
11
  emergencyProposals(params?: Partial<PaginationOptions & APIParams>): Promise<[Proposal[], Pagination]>;
12
12
  }