@xchainjs/xchain-thorchain 0.23.0 → 0.24.0-alpha.1

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,15 +1,14 @@
1
- import { AccAddress, Msg } from 'cosmos-client';
2
- import { StdTxFee } from 'cosmos-client/api';
3
- import { StdSignature } from 'cosmos-client/x/auth';
1
+ import { cosmosclient, proto } from '@cosmos-client/core';
2
+ import { Asset } from '@xchainjs/xchain-util';
4
3
  export declare type MsgCoin = {
5
- asset: string;
4
+ asset: Asset;
6
5
  amount: string;
7
6
  };
8
- export declare class MsgNativeTx extends Msg {
7
+ export declare class MsgNativeTx {
9
8
  coins: MsgCoin[];
10
9
  memo: string;
11
- signer: AccAddress;
12
- constructor(coins: MsgCoin[], memo: string, signer: AccAddress);
10
+ signer: cosmosclient.AccAddress;
11
+ constructor(coins: MsgCoin[], memo: string, signer: cosmosclient.AccAddress);
13
12
  }
14
13
  /**
15
14
  * This creates MsgNativeTx from json.
@@ -32,8 +31,8 @@ export declare type ThorchainDepositResponse = AminoWrapping<{
32
31
  memo: string;
33
32
  signer: string;
34
33
  }>[];
35
- fee: StdTxFee;
36
- signatures: StdSignature[];
34
+ fee: proto.cosmos.tx.v1beta1.Fee;
35
+ signatures: string[];
37
36
  memo: string;
38
37
  timeout_height: string;
39
38
  }>;
package/lib/util.d.ts CHANGED
@@ -1,9 +1,7 @@
1
+ import { cosmosclient, proto } from '@cosmos-client/core';
1
2
  import { Address, Balance, Fees, Network, TxHash } from '@xchainjs/xchain-client';
2
3
  import { CosmosSDKClient, TxLog } from '@xchainjs/xchain-cosmos';
3
- import { Asset } from '@xchainjs/xchain-util';
4
- import { Msg } from 'cosmos-client';
5
- import { StdTx } from 'cosmos-client/x/auth';
6
- import { MsgMultiSend, MsgSend } from 'cosmos-client/x/bank';
4
+ import { Asset, BaseAmount } from '@xchainjs/xchain-util';
7
5
  import { ChainId, ChainIds, ClientUrl, ExplorerUrls, TxData } from './types';
8
6
  import { MsgNativeTx } from './types/messages';
9
7
  export declare const DECIMAL = 8;
@@ -31,20 +29,6 @@ export declare const getDenom: (asset: Asset) => string;
31
29
  * @returns {Asset|null} The asset of the given denomination.
32
30
  */
33
31
  export declare const assetFromDenom: (denom: string) => Asset | null;
34
- /**
35
- * Type guard for MsgSend
36
- *
37
- * @param {Msg} msg
38
- * @returns {boolean} `true` or `false`.
39
- */
40
- export declare const isMsgSend: (msg: Msg) => msg is MsgSend;
41
- /**
42
- * Type guard for MsgMultiSend
43
- *
44
- * @param {Msg} msg
45
- * @returns {boolean} `true` or `false`.
46
- */
47
- export declare const isMsgMultiSend: (msg: Msg) => msg is MsgMultiSend;
48
32
  /**
49
33
  * Response guard for transaction broadcast
50
34
  *
@@ -65,7 +49,13 @@ export declare const getPrefix: (network: Network) => "thor" | "sthor" | "tthor"
65
49
  *
66
50
  * @param {string} prefix
67
51
  */
68
- export declare const registerCodecs: (prefix: string) => void;
52
+ export declare const registerDespositCodecs: () => Promise<void>;
53
+ /**
54
+ * Register Codecs based on the prefix.
55
+ *
56
+ * @param {string} prefix
57
+ */
58
+ export declare const registerSendCodecs: () => Promise<void>;
69
59
  /**
70
60
  * Parse transaction data from event logs
71
61
  *
@@ -99,7 +89,24 @@ export declare const getChainId: (nodeUrl: string) => Promise<ChainId>;
99
89
  */
100
90
  export declare const getChainIds: (client: ClientUrl) => Promise<ChainIds>;
101
91
  /**
102
- * Structure StdTx from MsgNativeTx.
92
+ * Builds final unsigned TX
93
+ *
94
+ * @param cosmosSdk - CosmosSDK
95
+ * @param txBody - txBody with encoded Msgs
96
+ * @param signerPubkey - signerPubkey string
97
+ * @param sequence - account sequence
98
+ * @param gasLimit - transaction gas limit
99
+ * @returns
100
+ */
101
+ export declare const buildUnsignedTx: ({ cosmosSdk, txBody, signerPubkey, sequence, gasLimit, }: {
102
+ cosmosSdk: cosmosclient.CosmosSDK;
103
+ txBody: proto.cosmos.tx.v1beta1.TxBody;
104
+ signerPubkey: proto.google.protobuf.Any;
105
+ sequence: cosmosclient.Long;
106
+ gasLimit: string;
107
+ }) => cosmosclient.TxBuilder;
108
+ /**
109
+ * Structure a MsgDeposit
103
110
  *
104
111
  * @param {MsgNativeTx} msgNativeTx Msg of type `MsgNativeTx`.
105
112
  * @param {string} nodeUrl Node url
@@ -113,7 +120,27 @@ export declare const buildDepositTx: ({ msgNativeTx, nodeUrl, chainId, }: {
113
120
  msgNativeTx: MsgNativeTx;
114
121
  nodeUrl: string;
115
122
  chainId: ChainId;
116
- }) => Promise<StdTx>;
123
+ }) => Promise<proto.cosmos.tx.v1beta1.TxBody>;
124
+ /**
125
+ * Structure a MsgSend
126
+ *
127
+ * @param fromAddress - required, from address string
128
+ * @param toAddress - required, to address string
129
+ * @param assetAmount - required, asset amount string (e.g. "10000")
130
+ * @param assetDenom - required, asset denom string (e.g. "rune")
131
+ * @param memo - optional, memo string
132
+ *
133
+ * @returns
134
+ */
135
+ export declare const buildTransferTx: ({ fromAddress, toAddress, assetAmount, assetDenom, memo, nodeUrl, chainId, }: {
136
+ fromAddress: Address;
137
+ toAddress: Address;
138
+ assetAmount: BaseAmount;
139
+ assetDenom: string;
140
+ memo?: string | undefined;
141
+ nodeUrl: string;
142
+ chainId: ChainId;
143
+ }) => Promise<proto.cosmos.tx.v1beta1.TxBody>;
117
144
  /**
118
145
  * Get the balance of a given address.
119
146
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xchainjs/xchain-thorchain",
3
- "version": "0.23.0",
3
+ "version": "0.24.0-alpha.1",
4
4
  "description": "Custom Thorchain client and utilities used by XChainJS clients",
5
5
  "keywords": [
6
6
  "THORChain",
@@ -27,29 +27,33 @@
27
27
  "clean": "rimraf lib/**",
28
28
  "build": "yarn clean && rollup -c",
29
29
  "test": "jest",
30
+ "e2e": "jest --config jest.config.e2e.js",
30
31
  "lint": "eslint \"{src,__tests__}/**/*.ts\" --fix --max-warnings 0",
31
32
  "prepublishOnly": "yarn build",
32
- "start:example": "ts-node example/index.ts"
33
+ "start:example": "ts-node example/index.ts",
34
+ "generate:ThorchainMsgs": "./genMsgs.sh"
33
35
  },
34
36
  "devDependencies": {
37
+ "@cosmos-client/core": "^0.45.1",
35
38
  "@types/big.js": "^6.0.0",
36
39
  "@xchainjs/xchain-client": "^0.11.1",
37
- "@xchainjs/xchain-cosmos": "^0.16.1",
40
+ "@xchainjs/xchain-cosmos": "^0.17.0-alpha.1",
38
41
  "@xchainjs/xchain-crypto": "^0.2.4",
39
42
  "@xchainjs/xchain-util": "^0.5.1",
40
43
  "axios": "^0.25.0",
41
- "cosmos-client": "0.39.2",
44
+ "bech32-buffer": "^0.2.0",
42
45
  "nock": "^13.0.5"
43
46
  },
44
47
  "publishConfig": {
45
48
  "access": "public"
46
49
  },
47
50
  "peerDependencies": {
51
+ "@cosmos-client/core": "^0.45.1",
48
52
  "@xchainjs/xchain-client": "^0.11.1",
49
- "@xchainjs/xchain-cosmos": "^0.16.1",
53
+ "@xchainjs/xchain-cosmos": "^0.17.0",
50
54
  "@xchainjs/xchain-crypto": "^0.2.4",
51
55
  "@xchainjs/xchain-util": "^0.5.1",
52
56
  "axios": "^0.25.0",
53
- "cosmos-client": "0.39.2"
57
+ "bech32-buffer": "^0.2.0"
54
58
  }
55
- }
59
+ }