@initia/initia.js 1.0.9 → 1.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -21,15 +21,15 @@ The usage section of this document provides detailed explanations and code examp
21
21
 
22
22
  ### REST client 
23
23
 
24
- **REST**(previously LCD) class facilitates interaction with the Initia blockchain.
24
+ **RESTClient** class facilitates interaction with the Initia blockchain.
25
25
 
26
26
  ```typescript
27
27
  import { RESTClient } from '@initia/initia.js'
28
28
 
29
29
  const rest = new RESTClient('https://rest.testnet.initia.xyz', {
30
- chainId: 'initiation-2',
31
- gasPrices: '0.15uinit', // default gas prices
32
- gasAdjustment: '1.75', // default gas adjustment for fee estimation
30
+ chainId: 'initiation-2',
31
+ gasPrices: '0.15uinit', // default gas prices
32
+ gasAdjustment: '1.75', // default gas adjustment for fee estimation
33
33
  })
34
34
  ```
35
35
 
@@ -45,10 +45,10 @@ An abstract key interface that enables transaction signing and provides Bech32 a
45
45
  import { MnemonicKey } from '@initia/initia.js'
46
46
 
47
47
  const key = new MnemonicKey({
48
- mnemonic: 'bird upset ... evil cigar', // (optional) if null, generate a new Mnemonic key
49
- account: 0, // (optional) BIP44 account number. default = 0
50
- index: 0, // (optional) BIP44 index number. default = 0
51
- coinType: 60, // (optional) BIP44 coinType. default = 60
48
+ mnemonic: 'bird upset ... evil cigar', // (optional) if null, generate a new Mnemonic key
49
+ account: 0, // (optional) BIP44 account number. default = 0
50
+ index: 0, // (optional) BIP44 index number. default = 0
51
+ coinType: 60, // (optional) BIP44 coinType. default = 60
52
52
  })
53
53
  ```
54
54
 
@@ -61,20 +61,20 @@ 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
- .u64() // type
65
- .serialize(1234) // value
66
- .toBase64()
64
+ .u64() // type
65
+ .serialize(1234) // value
66
+ .toBase64()
67
67
 
68
68
  // deserialize
69
69
  const deserializedU64 = bcs
70
- .u64() // type
71
- .parse(Uint8Array.from(Buffer.from(serializedU64, 'base64')))
70
+ .u64() // type
71
+ .parse(Uint8Array.from(Buffer.from(serializedU64, 'base64')))
72
72
 
73
73
  // vector
74
74
  const serializedVector = bcs
75
- .vector(bcs.u64())
76
- .serialize([123, 456, 789])
77
- .toBase64()
75
+ .vector(bcs.u64())
76
+ .serialize([123, 456, 789])
77
+ .toBase64()
78
78
 
79
79
  // option
80
80
  const serializedSome = bcs.option(bcs.u64()).serialize(123)
@@ -96,9 +96,9 @@ Send coins to others.
96
96
  import { MsgSend } from '@initia/initia.js'
97
97
 
98
98
  const msg = new MsgSend(
99
- 'init1kdwzpz3wzvpdj90gtga4fw5zm9tk4cyrgnjauu', // sender address
100
- 'init18sj3x80fdjc6gzfvwl7lf8sxcvuvqjpvcmp6np', // recipient address
101
- '1000uinit', // send amount
99
+ 'init1kdwzpz3wzvpdj90gtga4fw5zm9tk4cyrgnjauu', // sender address
100
+ 'init18sj3x80fdjc6gzfvwl7lf8sxcvuvqjpvcmp6np', // recipient address
101
+ '1000uinit', // send amount
102
102
  )
103
103
  ```
104
104
 
@@ -110,9 +110,9 @@ Delegate governance coin to validators (staking).
110
110
  import { MsgDelegate } from '@initia/initia.js'
111
111
 
112
112
  const msg = new MsgDelegate(
113
- 'init1kdwzpz3wzvpdj90gtga4fw5zm9tk4cyrgnjauu', // delegator address
114
- 'initvaloper14qekdkj2nmmwea4ufg9n002a3pud23y8l3ep5z', // validator's operator (valoper) address
115
- '100000uinit', // delegate amount
113
+ 'init1kdwzpz3wzvpdj90gtga4fw5zm9tk4cyrgnjauu', // delegator address
114
+ 'initvaloper14qekdkj2nmmwea4ufg9n002a3pud23y8l3ep5z', // validator's operator (valoper) address
115
+ '100000uinit', // delegate amount
116
116
  )
117
117
  ```
118
118
 
@@ -124,9 +124,9 @@ Undelegate governance coin from validators (unstaking).
124
124
  import { MsgUndelegate } from '@initia/initia.js'
125
125
 
126
126
  const msg = new MsgUndelegate(
127
- 'init1kdwzpz3wzvpdj90gtga4fw5zm9tk4cyrgnjauu', // delegator address
128
- 'initvaloper14qekdkj2nmmwea4ufg9n002a3pud23y8l3ep5z', // validator's operator (valoper) address
129
- '100000uinit', // undelegate amount
127
+ 'init1kdwzpz3wzvpdj90gtga4fw5zm9tk4cyrgnjauu', // delegator address
128
+ 'initvaloper14qekdkj2nmmwea4ufg9n002a3pud23y8l3ep5z', // validator's operator (valoper) address
129
+ '100000uinit', // undelegate amount
130
130
  )
131
131
  ```
132
132
 
@@ -138,16 +138,16 @@ Execute move contract function.
138
138
  import { MsgExecute } from '@initia/initia.js'
139
139
 
140
140
  const msg = new MsgExecute(
141
- 'init1kdwzpz3wzvpdj90gtga4fw5zm9tk4cyrgnjauu', // sender address
142
- '0x1', // owner of the module
143
- 'dex', // name of the module
144
- 'swap_script', // function name
145
- [], // type arguments
146
- [
147
- bcs.address().serialize('0x2').toBase64(), // arguments, BCS-encoded
148
- bcs.address().serialize('0x3').toBase64(), // arguments, BCS-encoded
149
- bcs.u64().serialize(10000).toBase64() // arguments, BCS-encoded
150
- ]
141
+ 'init1kdwzpz3wzvpdj90gtga4fw5zm9tk4cyrgnjauu', // sender address
142
+ '0x1', // owner of the module
143
+ 'dex', // name of the module
144
+ 'swap_script', // function name
145
+ [], // type arguments
146
+ [
147
+ bcs.address().serialize('0x2').toBase64(), // arguments, BCS-encoded
148
+ bcs.address().serialize('0x3').toBase64(), // arguments, BCS-encoded
149
+ bcs.u64().serialize(10000).toBase64() // arguments, BCS-encoded
150
+ ]
151
151
  )
152
152
  ```
153
153
 
@@ -158,30 +158,30 @@ const msg = new MsgExecute(
158
158
  Create a wallet and sign transaction.  
159
159
 
160
160
  ```typescript
161
- import { Wallet, RESTClient, MnemonicKey } from '@initia/initia.js'
161
+ import { Wallet, RESTClient, MnemonicKey, MsgSend } from '@initia/initia.js'
162
162
 
163
163
  const key = new MnemonicKey({
164
- mnemonic:
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',
164
+ mnemonic:
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',
166
166
  })
167
167
 
168
168
  const rest = new RESTClient('https://rest.testnet.initia.xyz', {
169
- chainId: 'initiation-2',
170
- gasPrices: '0.15uinit', // default gas prices
171
- gasAdjustment: '1.75', // default gas adjustment for fee estimation
169
+ chainId: 'initiation-2',
170
+ gasPrices: '0.15uinit', // default gas prices
171
+ gasAdjustment: '1.75', // default gas adjustment for fee estimation
172
172
  })
173
173
 
174
174
  const wallet = new Wallet(rest, key)
175
175
 
176
176
  const sendMsg = new MsgSend(
177
- 'init14l3c2vxrdvu6y0sqykppey930s4kufsvt97aeu', // sender address
178
- 'init18sj3x80fdjc6gzfvwl7lf8sxcvuvqjpvcmp6np', // recipient address
179
- '1000uinit', // send amount
177
+ 'init14l3c2vxrdvu6y0sqykppey930s4kufsvt97aeu', // sender address
178
+ 'init18sj3x80fdjc6gzfvwl7lf8sxcvuvqjpvcmp6np', // recipient address
179
+ '1000uinit', // send amount
180
180
  )
181
181
 
182
182
  const signedTx = await wallet.createAndSignTx({
183
- msgs: [sendMsg],
184
- memo: 'sample memo',
183
+ msgs: [sendMsg],
184
+ memo: 'sample memo',
185
185
  })
186
186
  ```
187
187
 
@@ -211,14 +211,14 @@ Obtain the return values of a Move view function.
211
211
 
212
212
  ```typescript
213
213
  const res = await rest.move.viewFunction(
214
- '0x1', // owner of the module
215
- 'dex', // name of the module
216
- 'get_swap_simulation', // function name
217
- [], // type arguments
218
- [
219
- bcs.address().serialize('0x2').toBase64(), // arguments, BCS-encoded
220
- bcs.address().serialize('0x3').toBase64(), // arguments, BCS-encoded
221
- bcs.u64().serialize(10000).toBase64() // arguments, BCS-encoded
222
- ]
214
+ '0x1', // owner of the module
215
+ 'dex', // name of the module
216
+ 'get_swap_simulation', // function name
217
+ [], // type arguments
218
+ [
219
+ bcs.address().serialize('0x2').toBase64(), // arguments, BCS-encoded
220
+ bcs.address().serialize('0x3').toBase64(), // arguments, BCS-encoded
221
+ bcs.u64().serialize(10000).toBase64() // arguments, BCS-encoded
222
+ ]
223
223
  )
224
224
  ```
@@ -46,5 +46,3 @@ export declare class RESTClient {
46
46
  wallet(key: Key): Wallet;
47
47
  gasPrices(): Promise<Coins.Input | undefined>;
48
48
  }
49
- export declare class LCDClient extends RESTClient {
50
- }
@@ -7,7 +7,6 @@ export declare class Wallet {
7
7
  rest: RESTClient;
8
8
  key: Key;
9
9
  private accAddress;
10
- lcd: RESTClient;
11
10
  constructor(rest: RESTClient, key: Key);
12
11
  setAccountAddress(accAddress: string): void;
13
12
  accountNumberAndSequence(): Promise<{
@@ -1,4 +1,2 @@
1
- import { BigNumber } from 'bignumber.js';
2
1
  export declare function num(number: number | string): BigNumber;
3
2
  export declare function checkDecimal(amount: number | string): boolean;
4
- export * from 'bignumber.js';