@initia/initia.js 0.2.17 → 0.2.19
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 +13 -13
- package/dist/client/LocalInitia.d.ts +3 -3
- package/dist/client/index.d.ts +4 -4
- package/dist/client/{lcd/LCDClient.d.ts → rest/RESTClient.d.ts} +6 -4
- package/dist/client/{lcd → rest}/Wallet.d.ts +4 -4
- package/dist/client/{lcd → rest}/api/TxAPI.d.ts +3 -3
- package/dist/core/PublicKey.d.ts +29 -7
- package/dist/core/tx/Tx.d.ts +1 -1
- package/dist/index.cjs.js +2 -2
- package/dist/index.es.js +3276 -3234
- package/package.json +1 -1
- /package/dist/client/{lcd → rest}/APIRequester.d.ts +0 -0
- /package/dist/client/{lcd → rest}/api/AuctionAPI.d.ts +0 -0
- /package/dist/client/{lcd → rest}/api/AuthAPI.d.ts +0 -0
- /package/dist/client/{lcd → rest}/api/AuthzAPI.d.ts +0 -0
- /package/dist/client/{lcd → rest}/api/BankAPI.d.ts +0 -0
- /package/dist/client/{lcd → rest}/api/BaseAPI.d.ts +0 -0
- /package/dist/client/{lcd → rest}/api/DistributionAPI.d.ts +0 -0
- /package/dist/client/{lcd → rest}/api/EvidenceAPI.d.ts +0 -0
- /package/dist/client/{lcd → rest}/api/EvmAPI.d.ts +0 -0
- /package/dist/client/{lcd → rest}/api/FeeGrantAPI.d.ts +0 -0
- /package/dist/client/{lcd → rest}/api/ForwardingAPI.d.ts +0 -0
- /package/dist/client/{lcd → rest}/api/GovAPI.d.ts +0 -0
- /package/dist/client/{lcd → rest}/api/GroupAPI.d.ts +0 -0
- /package/dist/client/{lcd → rest}/api/IbcAPI.d.ts +0 -0
- /package/dist/client/{lcd → rest}/api/IbcHooksAPI.d.ts +0 -0
- /package/dist/client/{lcd → rest}/api/IbcNftAPI.d.ts +0 -0
- /package/dist/client/{lcd → rest}/api/IbcPermAPI.d.ts +0 -0
- /package/dist/client/{lcd → rest}/api/IbcTransferAPI.d.ts +0 -0
- /package/dist/client/{lcd → rest}/api/InterTxAPI.d.ts +0 -0
- /package/dist/client/{lcd → rest}/api/MarketmapAPI.d.ts +0 -0
- /package/dist/client/{lcd → rest}/api/MoveAPI.d.ts +0 -0
- /package/dist/client/{lcd → rest}/api/MstakingAPI.d.ts +0 -0
- /package/dist/client/{lcd → rest}/api/OpchildAPI.d.ts +0 -0
- /package/dist/client/{lcd → rest}/api/OphostAPI.d.ts +0 -0
- /package/dist/client/{lcd → rest}/api/OracleAPI.d.ts +0 -0
- /package/dist/client/{lcd → rest}/api/RewardAPI.d.ts +0 -0
- /package/dist/client/{lcd → rest}/api/SlashingAPI.d.ts +0 -0
- /package/dist/client/{lcd → rest}/api/TendermintAPI.d.ts +0 -0
- /package/dist/client/{lcd → rest}/api/TokenfactoryAPI.d.ts +0 -0
- /package/dist/client/{lcd → rest}/api/UpgradeAPI.d.ts +0 -0
- /package/dist/client/{lcd → rest}/api/WasmAPI.d.ts +0 -0
- /package/dist/client/{lcd → rest}/api/index.d.ts +0 -0
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ Initia.js is a TypeScript-written JavaScript SDK tailored for the Initia blockch
|
|
|
4
4
|
## Main Features
|
|
5
5
|
- **Improved TypeScript Definitions**: Offers comprehensive integration with Initia core data structures for an enhanced developer experience.
|
|
6
6
|
- **Core Layer**: Includes key management, BCS serialization, and support for initia.proto.
|
|
7
|
-
- **Client Layer**: Facilitates API request generation and
|
|
7
|
+
- **Client Layer**: Facilitates API request generation and REST provider interaction.
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
## Installation
|
|
@@ -19,15 +19,15 @@ npm install @initia/initia.js
|
|
|
19
19
|
|
|
20
20
|
The usage section of this document provides detailed explanations and code examples of the most commonly used classes of the Initia.js library, which can be utilized both in a Node.js environment and within a browser.
|
|
21
21
|
|
|
22
|
-
###
|
|
22
|
+
### REST client 
|
|
23
23
|
|
|
24
|
-
**
|
|
24
|
+
**REST**(previously LCD) class facilitates interaction with the Initia blockchain.
|
|
25
25
|
|
|
26
26
|
```typescript
|
|
27
|
-
import {
|
|
27
|
+
import { RESTClient } from '@initia/initia.js';
|
|
28
28
|
|
|
29
|
-
const
|
|
30
|
-
chainId: '
|
|
29
|
+
const rest = new RESTClient('https://rest.testnet.initia.xyz', {
|
|
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
|
});
|
|
@@ -159,20 +159,20 @@ const msg = new MsgExecute(
|
|
|
159
159
|
Create a wallet and sign transaction.  
|
|
160
160
|
|
|
161
161
|
```typescript
|
|
162
|
-
import { Wallet,
|
|
162
|
+
import { Wallet, RESTClient, MnemonicKey } from '@initia/initia.js';
|
|
163
163
|
|
|
164
164
|
const key = new MnemonicKey({
|
|
165
165
|
mnemonic:
|
|
166
166
|
'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
167
|
});
|
|
168
168
|
|
|
169
|
-
const
|
|
170
|
-
chainId: '
|
|
169
|
+
const rest = new RESTClient('https://rest.testnet.initia.xyz', {
|
|
170
|
+
chainId: 'initiation-2',
|
|
171
171
|
gasPrices: '0.15uinit', // default gas prices
|
|
172
172
|
gasAdjustment: '1.75', // default gas adjustment for fee estimation
|
|
173
173
|
});
|
|
174
174
|
|
|
175
|
-
const wallet = new Wallet(
|
|
175
|
+
const wallet = new Wallet(rest, key);
|
|
176
176
|
|
|
177
177
|
const sendMsg = new MsgSend(
|
|
178
178
|
'init14l3c2vxrdvu6y0sqykppey930s4kufsvt97aeu', // sender address
|
|
@@ -193,7 +193,7 @@ When sending coins with `MsgSend`, sender address should be same with wallet add
|
|
|
193
193
|
`broadcast()` is the action that sends your transaction to the blockchain code.
|
|
194
194
|
|
|
195
195
|
```typescript
|
|
196
|
-
const broadcastResult = await
|
|
196
|
+
const broadcastResult = await rest.tx.broadcast(signedTx);
|
|
197
197
|
```
|
|
198
198
|
|
|
199
199
|
### Queries 
|
|
@@ -203,7 +203,7 @@ const broadcastResult = await lcd.tx.broadcast(signedTx);
|
|
|
203
203
|
Query the balance of the account.
|
|
204
204
|
|
|
205
205
|
```typescript
|
|
206
|
-
const balances = await
|
|
206
|
+
const balances = await rest.bank.balance('init14l3c2vxrdvu6y0sqykppey930s4kufsvt97aeu');
|
|
207
207
|
```
|
|
208
208
|
|
|
209
209
|
* `viewfunction()`
|
|
@@ -211,7 +211,7 @@ const balances = await lcd.bank.balance('init14l3c2vxrdvu6y0sqykppey930s4kufsvt9
|
|
|
211
211
|
Obtain the return values of a Move view function.
|
|
212
212
|
|
|
213
213
|
```typescript
|
|
214
|
-
const res = await
|
|
214
|
+
const res = await rest.move.viewFunction(
|
|
215
215
|
'0x1', // owner of the module
|
|
216
216
|
'dex', // name of the module
|
|
217
217
|
'get_swap_simulation', // function name
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Wallet } from './
|
|
3
|
-
export declare class LocalInitia extends
|
|
1
|
+
import { RESTClient } from './rest/RESTClient';
|
|
2
|
+
import { Wallet } from './rest/Wallet';
|
|
3
|
+
export declare class LocalInitia extends RESTClient {
|
|
4
4
|
wallets: {
|
|
5
5
|
validator: Wallet;
|
|
6
6
|
test1: Wallet;
|
package/dist/client/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './
|
|
4
|
-
export * from './
|
|
1
|
+
export * from './rest/APIRequester';
|
|
2
|
+
export * from './rest/RESTClient';
|
|
3
|
+
export * from './rest/Wallet';
|
|
4
|
+
export * from './rest/api';
|
|
5
5
|
export * from './LocalInitia';
|
|
6
6
|
export * from './WebSocketClient';
|
|
@@ -3,14 +3,14 @@ import { AuctionAPI, AuthAPI, AuthzAPI, BankAPI, DistributionAPI, EvidenceAPI, E
|
|
|
3
3
|
import { Wallet } from './Wallet';
|
|
4
4
|
import { Coins } from '../../core';
|
|
5
5
|
import { Key } from '../../key';
|
|
6
|
-
export interface
|
|
6
|
+
export interface RESTClientConfig {
|
|
7
7
|
chainId?: string;
|
|
8
8
|
gasPrices?: Coins.Input;
|
|
9
9
|
gasAdjustment?: string;
|
|
10
10
|
}
|
|
11
|
-
export declare class
|
|
11
|
+
export declare class RESTClient {
|
|
12
12
|
URL: string;
|
|
13
|
-
config:
|
|
13
|
+
config: RESTClientConfig;
|
|
14
14
|
apiRequester: APIRequester;
|
|
15
15
|
auction: AuctionAPI;
|
|
16
16
|
auth: AuthAPI;
|
|
@@ -42,6 +42,8 @@ export declare class LCDClient {
|
|
|
42
42
|
tx: TxAPI;
|
|
43
43
|
upgrade: UpgradeAPI;
|
|
44
44
|
wasm: WasmAPI;
|
|
45
|
-
constructor(URL: string, config?:
|
|
45
|
+
constructor(URL: string, config?: RESTClientConfig, apiRequester?: APIRequester);
|
|
46
46
|
wallet(key: Key): Wallet;
|
|
47
47
|
}
|
|
48
|
+
export declare class LCDClient extends RESTClient {
|
|
49
|
+
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RESTClient } from './RESTClient';
|
|
2
2
|
import { Key } from '../../key';
|
|
3
|
-
import { CreateTxOptions } from '
|
|
3
|
+
import { CreateTxOptions } from './api/TxAPI';
|
|
4
4
|
import { Tx } from '../../core';
|
|
5
5
|
import { SignMode } from '@initia/initia.proto/cosmos/tx/signing/v1beta1/signing';
|
|
6
6
|
export declare class Wallet {
|
|
7
|
-
|
|
7
|
+
rest: RESTClient;
|
|
8
8
|
key: Key;
|
|
9
9
|
private accAddress;
|
|
10
|
-
constructor(
|
|
10
|
+
constructor(rest: RESTClient, key: Key);
|
|
11
11
|
setAccountAddress(accAddress: string): void;
|
|
12
12
|
accountNumberAndSequence(): Promise<{
|
|
13
13
|
account_number: number;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BaseAPI } from './BaseAPI';
|
|
2
2
|
import { Msg, Tx, Coins, TxInfo, Fee, PublicKey, TxLog, Event } from '../../../core';
|
|
3
|
-
import {
|
|
3
|
+
import { RESTClient } from '../RESTClient';
|
|
4
4
|
import { APIParams, Pagination, PaginationOptions } from '../APIRequester';
|
|
5
5
|
interface Wait {
|
|
6
6
|
height: number;
|
|
@@ -162,8 +162,8 @@ export interface TxSearchOptions extends PaginationOptions {
|
|
|
162
162
|
query: TxSearchQuery[];
|
|
163
163
|
}
|
|
164
164
|
export declare class TxAPI extends BaseAPI {
|
|
165
|
-
|
|
166
|
-
constructor(
|
|
165
|
+
rest: RESTClient;
|
|
166
|
+
constructor(rest: RESTClient);
|
|
167
167
|
txInfo(txHash: string, params?: APIParams): Promise<TxInfo>;
|
|
168
168
|
create(signers: SignerOptions[], options: CreateTxOptions): Promise<Tx>;
|
|
169
169
|
txInfosByHeight(height: number | undefined): Promise<TxInfo[]>;
|
package/dist/core/PublicKey.d.ts
CHANGED
|
@@ -3,10 +3,11 @@ import { LegacyAminoPubKey as LegacyAminoPubKey_pb } from '@initia/initia.proto/
|
|
|
3
3
|
import { Any } from '@initia/initia.proto/google/protobuf/any';
|
|
4
4
|
import { PubKey as PubKey_pb } from '@initia/initia.proto/cosmos/crypto/secp256k1/keys';
|
|
5
5
|
import { PubKey as ValConsPubKey_pb } from '@initia/initia.proto/cosmos/crypto/ed25519/keys';
|
|
6
|
-
|
|
6
|
+
import { PubKey as EthPubKey_pb } from '@initia/initia.proto/initia/crypto/v1beta1/ethsecp256k1/keys';
|
|
7
|
+
export type PublicKey = SimplePublicKey | LegacyAminoMultisigPublicKey | ValConsPublicKey | EthPublicKey;
|
|
7
8
|
export declare namespace PublicKey {
|
|
8
|
-
type Amino = SimplePublicKey.Amino | LegacyAminoMultisigPublicKey.Amino | ValConsPublicKey.Amino;
|
|
9
|
-
type Data = SimplePublicKey.Data | LegacyAminoMultisigPublicKey.Data | ValConsPublicKey.Data;
|
|
9
|
+
type Amino = SimplePublicKey.Amino | LegacyAminoMultisigPublicKey.Amino | ValConsPublicKey.Amino | EthPublicKey.Amino;
|
|
10
|
+
type Data = SimplePublicKey.Data | LegacyAminoMultisigPublicKey.Data | ValConsPublicKey.Data | EthPublicKey.Data;
|
|
10
11
|
type Proto = Any;
|
|
11
12
|
function fromAmino(data: PublicKey.Amino): PublicKey;
|
|
12
13
|
function fromData(data: PublicKey.Data): PublicKey;
|
|
@@ -26,7 +27,6 @@ export declare class SimplePublicKey extends JSONSerializable<SimplePublicKey.Am
|
|
|
26
27
|
encodeAminoPubkey(): Uint8Array;
|
|
27
28
|
rawAddress(): Uint8Array;
|
|
28
29
|
address(): string;
|
|
29
|
-
pubkeyAddress(): string;
|
|
30
30
|
}
|
|
31
31
|
export declare namespace SimplePublicKey {
|
|
32
32
|
interface Amino {
|
|
@@ -46,7 +46,6 @@ export declare class LegacyAminoMultisigPublicKey extends JSONSerializable<Legac
|
|
|
46
46
|
encodeAminoPubkey(): Uint8Array;
|
|
47
47
|
rawAddress(): Uint8Array;
|
|
48
48
|
address(): string;
|
|
49
|
-
pubkeyAddress(): string;
|
|
50
49
|
static fromAmino(data: LegacyAminoMultisigPublicKey.Amino): LegacyAminoMultisigPublicKey;
|
|
51
50
|
toAmino(): LegacyAminoMultisigPublicKey.Amino;
|
|
52
51
|
static fromData(data: LegacyAminoMultisigPublicKey.Data): LegacyAminoMultisigPublicKey;
|
|
@@ -82,10 +81,8 @@ export declare class ValConsPublicKey extends JSONSerializable<ValConsPublicKey.
|
|
|
82
81
|
toProto(): ValConsPublicKey.Proto;
|
|
83
82
|
packAny(): Any;
|
|
84
83
|
static unpackAny(pubkeyAny: Any): ValConsPublicKey;
|
|
85
|
-
encodeAminoPubkey(): Uint8Array;
|
|
86
84
|
rawAddress(): Uint8Array;
|
|
87
85
|
address(): string;
|
|
88
|
-
pubkeyAddress(): string;
|
|
89
86
|
}
|
|
90
87
|
export declare namespace ValConsPublicKey {
|
|
91
88
|
interface Amino {
|
|
@@ -98,3 +95,28 @@ export declare namespace ValConsPublicKey {
|
|
|
98
95
|
}
|
|
99
96
|
type Proto = ValConsPubKey_pb;
|
|
100
97
|
}
|
|
98
|
+
export declare class EthPublicKey extends JSONSerializable<EthPublicKey.Amino, EthPublicKey.Data, EthPublicKey.Proto> {
|
|
99
|
+
key: string;
|
|
100
|
+
constructor(key: string);
|
|
101
|
+
static fromAmino(data: EthPublicKey.Amino): EthPublicKey;
|
|
102
|
+
toAmino(): EthPublicKey.Amino;
|
|
103
|
+
static fromData(data: EthPublicKey.Data): EthPublicKey;
|
|
104
|
+
toData(): EthPublicKey.Data;
|
|
105
|
+
static fromProto(pubkeyProto: EthPublicKey.Proto): EthPublicKey;
|
|
106
|
+
toProto(): EthPublicKey.Proto;
|
|
107
|
+
packAny(): Any;
|
|
108
|
+
static unpackAny(pubkeyAny: Any): EthPublicKey;
|
|
109
|
+
rawAddress(): Uint8Array;
|
|
110
|
+
address(): string;
|
|
111
|
+
}
|
|
112
|
+
export declare namespace EthPublicKey {
|
|
113
|
+
interface Amino {
|
|
114
|
+
type: 'initia/PubKeyEthSecp256k1';
|
|
115
|
+
value: string;
|
|
116
|
+
}
|
|
117
|
+
interface Data {
|
|
118
|
+
'@type': '/initia.crypto.v1beta1.ethsecp256k1.PubKey';
|
|
119
|
+
key: string;
|
|
120
|
+
}
|
|
121
|
+
type Proto = EthPubKey_pb;
|
|
122
|
+
}
|
package/dist/core/tx/Tx.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { CompactBitArray } from './CompactBitArray';
|
|
|
6
6
|
import { Msg } from '../Msg';
|
|
7
7
|
import { Fee } from './Fee';
|
|
8
8
|
import { SignatureV2 } from './SignatureV2';
|
|
9
|
-
import { SignerData } from '../../client
|
|
9
|
+
import { SignerData } from '../../client';
|
|
10
10
|
export declare class Tx {
|
|
11
11
|
body: TxBody;
|
|
12
12
|
auth_info: AuthInfo;
|