@dydxprotocol/v4-client-js 1.0.5 → 1.0.7

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.
@@ -12,20 +12,19 @@ import { GAS_MULTIPLIER } from './constants';
12
12
  import LocalWallet from './modules/local-wallet';
13
13
 
14
14
  export class NobleClient {
15
- private stargateClient?: SigningStargateClient;
16
15
  private wallet?: LocalWallet;
16
+ private restEndpoint: string;
17
+ private stargateClient?: SigningStargateClient;
17
18
 
18
- static async connect(
19
- restEndpoint: string,
20
- wallet: LocalWallet,
21
- ): Promise<NobleClient> {
22
- const client = new NobleClient();
23
- await client.initialize(restEndpoint, wallet);
24
- return client;
19
+ constructor(restEndpoint: string) {
20
+ this.restEndpoint = restEndpoint;
25
21
  }
26
22
 
27
- private async initialize(
28
- restEndpoint: string,
23
+ get isConnected(): boolean {
24
+ return Boolean(this.stargateClient);
25
+ }
26
+
27
+ async connect(
29
28
  wallet: LocalWallet,
30
29
  ): Promise<void> {
31
30
  if (wallet?.offlineSigner === undefined) {
@@ -33,24 +32,24 @@ export class NobleClient {
33
32
  }
34
33
  this.wallet = wallet;
35
34
  this.stargateClient = await SigningStargateClient.connectWithSigner(
36
- restEndpoint,
35
+ this.restEndpoint,
37
36
  wallet.offlineSigner,
38
37
  { registry: new Registry(defaultRegistryTypes) },
39
38
  );
40
39
  }
41
40
 
42
- getAccountBalances(address: string): Promise<readonly Coin[]> {
43
- if (!this.stargateClient) {
41
+ getAccountBalances(): Promise<readonly Coin[]> {
42
+ if (!this.stargateClient || this.wallet?.address === undefined) {
44
43
  throw new Error('stargateClient not initialized');
45
44
  }
46
- return this.stargateClient.getAllBalances(address);
45
+ return this.stargateClient.getAllBalances(this.wallet.address);
47
46
  }
48
47
 
49
- getAccountBalance(address: string, denom: string): Promise<Coin> {
50
- if (!this.stargateClient) {
48
+ getAccountBalance(denom: string): Promise<Coin> {
49
+ if (!this.stargateClient || this.wallet?.address === undefined) {
51
50
  throw new Error('stargateClient not initialized');
52
51
  }
53
- return this.stargateClient.getBalance(address, denom);
52
+ return this.stargateClient.getBalance(this.wallet.address, denom);
54
53
  }
55
54
 
56
55
  async send(
package/src/index.ts CHANGED
@@ -9,6 +9,7 @@ export * as onboarding from './lib/onboarding';
9
9
  export { default as LocalWallet } from './clients/modules/local-wallet';
10
10
  export { SubaccountInfo as SubaccountClient } from './clients/subaccount';
11
11
  export { CompositeClient } from './clients/composite-client';
12
+ export { NobleClient } from './clients/noble-client';
12
13
  export { IndexerClient } from './clients/indexer-client';
13
14
  export { ValidatorClient } from './clients/validator-client';
14
15
  export { FaucetClient } from './clients/faucet-client';
@@ -1,4 +0,0 @@
1
- #!/bin/sh
2
-
3
- npm run webpack
4
- cp __native__/__ios__/v4-native-client.js ~/native-ios-v4/dydx/dydxPresenters/dydxPresenters/_Features