@bitgo-beta/abstract-cosmos 1.0.1-beta.34 → 1.0.1-beta.340
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/CHANGELOG.md +583 -0
- package/dist/src/cosmosCoin.d.ts +41 -5
- package/dist/src/cosmosCoin.d.ts.map +1 -1
- package/dist/src/cosmosCoin.js +298 -22
- package/dist/src/index.js +6 -2
- package/dist/src/lib/ContractCallBuilder.js +2 -2
- package/dist/src/lib/StakingRedelegateBuilder.d.ts +13 -0
- package/dist/src/lib/StakingRedelegateBuilder.d.ts.map +1 -0
- package/dist/src/lib/StakingRedelegateBuilder.js +28 -0
- package/dist/src/lib/constants.d.ts +2 -0
- package/dist/src/lib/constants.d.ts.map +1 -1
- package/dist/src/lib/constants.js +4 -2
- package/dist/src/lib/iface.d.ts +36 -1
- package/dist/src/lib/iface.d.ts.map +1 -1
- package/dist/src/lib/iface.js +18 -1
- package/dist/src/lib/index.d.ts +1 -0
- package/dist/src/lib/index.d.ts.map +1 -1
- package/dist/src/lib/index.js +9 -3
- package/dist/src/lib/keyPair.js +5 -5
- package/dist/src/lib/transaction.d.ts.map +1 -1
- package/dist/src/lib/transaction.js +124 -85
- package/dist/src/lib/transactionBuilder.js +2 -2
- package/dist/src/lib/utils.d.ts +70 -4
- package/dist/src/lib/utils.d.ts.map +1 -1
- package/dist/src/lib/utils.js +152 -17
- package/dist/tsconfig.tsbuildinfo +1 -11052
- package/package.json +8 -7
package/dist/src/lib/utils.d.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
2
3
|
import { BaseUtils, TransactionType } from '@bitgo-beta/sdk-core';
|
|
3
4
|
import { DecodedTxRaw } from '@cosmjs/proto-signing';
|
|
4
5
|
import { Coin } from '@cosmjs/stargate';
|
|
5
6
|
import { SignDoc, TxRaw } from 'cosmjs-types/cosmos/tx/v1beta1/tx';
|
|
6
|
-
import {
|
|
7
|
+
import { Any } from 'cosmjs-types/google/protobuf/any';
|
|
8
|
+
import { Hash } from 'crypto';
|
|
9
|
+
import { CosmosLikeTransaction, DelegateOrUndelegeteMessage, ExecuteContractMessage, FeeData, MessageData, RedelegateMessage, SendMessage, WithdrawDelegatorRewardsMessage } from './iface';
|
|
7
10
|
export declare class CosmosUtils implements BaseUtils {
|
|
8
11
|
private registry;
|
|
9
12
|
constructor();
|
|
@@ -87,6 +90,12 @@ export declare class CosmosUtils implements BaseUtils {
|
|
|
87
90
|
* @returns {MessageData[]} Delegate of undelegate transaction message data
|
|
88
91
|
*/
|
|
89
92
|
getDelegateOrUndelegateMessageDataFromDecodedTx(decodedTx: DecodedTxRaw): MessageData[];
|
|
93
|
+
/**
|
|
94
|
+
* Returns the array of MessageData[] from the decoded transaction
|
|
95
|
+
* @param {DecodedTxRaw} decodedTx
|
|
96
|
+
* @returns {MessageData[]} Redelegate transaction message data
|
|
97
|
+
*/
|
|
98
|
+
getRedelegateMessageDataFromDecodedTx(decodedTx: DecodedTxRaw): MessageData[];
|
|
90
99
|
/**
|
|
91
100
|
* Returns the array of MessageData[] from the decoded transaction
|
|
92
101
|
* @param {DecodedTxRaw} decodedTx
|
|
@@ -99,6 +108,20 @@ export declare class CosmosUtils implements BaseUtils {
|
|
|
99
108
|
* @returns {MessageData[]} Delegate of undelegate transaction message data
|
|
100
109
|
*/
|
|
101
110
|
getWithdrawDelegatorRewardsMessageDataFromDecodedTx(decodedTx: DecodedTxRaw): MessageData[];
|
|
111
|
+
/**
|
|
112
|
+
* Get a cosmos chain address from its equivalent hex
|
|
113
|
+
* @param {string} prefix
|
|
114
|
+
* @param {string} addressHex
|
|
115
|
+
* @returns {string}
|
|
116
|
+
*/
|
|
117
|
+
getCosmosLikeAddressFromHex(prefix: string, addressHex: string): string;
|
|
118
|
+
/**
|
|
119
|
+
* Get a EVM chain address from its equivalent hex
|
|
120
|
+
* @param {string} prefix
|
|
121
|
+
* @param {string} addressHex
|
|
122
|
+
* @returns {string}
|
|
123
|
+
*/
|
|
124
|
+
getEvmLikeAddressFromCosmos(cosmosLikeAddress: string): string;
|
|
102
125
|
/**
|
|
103
126
|
* Returns the array of MessageData[] from the decoded transaction
|
|
104
127
|
* @param {DecodedTxRaw} decodedTx
|
|
@@ -111,6 +134,13 @@ export declare class CosmosUtils implements BaseUtils {
|
|
|
111
134
|
* @returns {TransactionType | undefined} TransactionType if url is supported else undefined
|
|
112
135
|
*/
|
|
113
136
|
getTransactionTypeFromTypeUrl(typeUrl: string): TransactionType | undefined;
|
|
137
|
+
/**
|
|
138
|
+
* Takes a hex encoded pubkey, converts it to the Amino JSON representation (type/value wrapper)
|
|
139
|
+
* and returns it as protobuf `Any`
|
|
140
|
+
* @param {string} pubkey hex encoded compressed secp256k1 public key
|
|
141
|
+
* @returns {Any} pubkey encoded as protobuf `Any`
|
|
142
|
+
*/
|
|
143
|
+
getEncodedPubkey(pubkey: string): Any;
|
|
114
144
|
/**
|
|
115
145
|
* Creates a txRaw from an cosmos like transaction @see CosmosLikeTransaction
|
|
116
146
|
* @Precondition cosmosLikeTransaction.publicKey must be defined
|
|
@@ -174,6 +204,12 @@ export declare class CosmosUtils implements BaseUtils {
|
|
|
174
204
|
* @throws {InvalidTransactionError} Throws an error if the validatorAddress, delegatorAddress, or amount is invalid or missing.
|
|
175
205
|
*/
|
|
176
206
|
validateDelegateOrUndelegateMessage(delegateMessage: DelegateOrUndelegeteMessage): void;
|
|
207
|
+
/**
|
|
208
|
+
* Validates the RedelegateMessage
|
|
209
|
+
* @param {DelegateOrUndelegeteMessage} redelegateMessage - The RedelegateMessage to validate.
|
|
210
|
+
* @throws {InvalidTransactionError} Throws an error if the validatorSrcAddress, validatorDstAddress, delegatorAddress, or amount is invalid or missing.
|
|
211
|
+
*/
|
|
212
|
+
validateRedelegateMessage(redelegateMessage: RedelegateMessage): void;
|
|
177
213
|
/**
|
|
178
214
|
* Validates the MessageData
|
|
179
215
|
* @param {MessageData} messageData - The MessageData to validate.
|
|
@@ -217,8 +253,9 @@ export declare class CosmosUtils implements BaseUtils {
|
|
|
217
253
|
/**
|
|
218
254
|
* Validates an array of coin amounts.
|
|
219
255
|
* @param {Coin[]} amountArray - The array of coin amounts to validate.
|
|
256
|
+
* @param {TransactionType} transactionType - optional field for transaction type
|
|
220
257
|
*/
|
|
221
|
-
validateAmountData(amountArray: Coin[]): void;
|
|
258
|
+
validateAmountData(amountArray: Coin[], transactionType?: TransactionType): void;
|
|
222
259
|
/**
|
|
223
260
|
* Validates the gas limit and gas amount for a transaction.
|
|
224
261
|
* @param {FeeData} gasBudget - The gas budget to validate.
|
|
@@ -234,9 +271,32 @@ export declare class CosmosUtils implements BaseUtils {
|
|
|
234
271
|
/**
|
|
235
272
|
* Validates a coin amount.
|
|
236
273
|
* @param {Coin} amount - The coin amount to validate.
|
|
274
|
+
* @param {TransactionType} transactionType - optional field for transaction type
|
|
237
275
|
* @throws {InvalidTransactionError} Throws an error if the coin amount is invalid.
|
|
238
276
|
*/
|
|
239
|
-
validateAmount(amount: Coin): void;
|
|
277
|
+
validateAmount(amount: Coin, transactionType?: TransactionType): void;
|
|
278
|
+
/**
|
|
279
|
+
* Checks if a cosmos like Bech32 address matches given regular expression and
|
|
280
|
+
* validates memoId if present
|
|
281
|
+
* @param {string} address
|
|
282
|
+
* @param {RegExp} regExp Regular expression to validate the root address against after trimming the memoId
|
|
283
|
+
* @returns {boolean} true if address is valid
|
|
284
|
+
*/
|
|
285
|
+
protected isValidCosmosLikeAddressWithMemoId(address: string, regExp: RegExp): boolean;
|
|
286
|
+
/**
|
|
287
|
+
* Checks if address is valid Bech32 and matches given regular expression
|
|
288
|
+
* @param {string} address
|
|
289
|
+
* @param {RegExp} regExp Regular expression to validate the address against
|
|
290
|
+
* @returns {boolean} true if address is valid
|
|
291
|
+
*/
|
|
292
|
+
protected isValidBech32AddressMatchingRegex(address: string, regExp: RegExp): boolean;
|
|
293
|
+
/**
|
|
294
|
+
* Return boolean indicating whether a memo id is valid
|
|
295
|
+
*
|
|
296
|
+
* @param memoId memo id
|
|
297
|
+
* @returns true if memo id is valid
|
|
298
|
+
*/
|
|
299
|
+
isValidMemoId(memoId: string): boolean;
|
|
240
300
|
/**
|
|
241
301
|
* Validates if the address matches with regex @see accountAddressRegex
|
|
242
302
|
* @param {string} address
|
|
@@ -258,9 +318,15 @@ export declare class CosmosUtils implements BaseUtils {
|
|
|
258
318
|
/**
|
|
259
319
|
* Validates a execute contract message
|
|
260
320
|
* @param {ExecuteContractMessage} message - The execute contract message to validate
|
|
321
|
+
* @param {TransactionType} transactionType - optional field for transaction type
|
|
261
322
|
* @throws {InvalidTransactionError} Throws an error if the message is invalid
|
|
262
323
|
*/
|
|
263
|
-
validateExecuteContractMessage(message: ExecuteContractMessage): void;
|
|
324
|
+
validateExecuteContractMessage(message: ExecuteContractMessage, transactionType?: TransactionType): void;
|
|
325
|
+
/**
|
|
326
|
+
* Get coin specific hash function
|
|
327
|
+
* @returns {Hash} The hash function
|
|
328
|
+
*/
|
|
329
|
+
getHashFunction(): Hash;
|
|
264
330
|
}
|
|
265
331
|
declare const utils: CosmosUtils;
|
|
266
332
|
export default utils;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/lib/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/lib/utils.ts"],"names":[],"mappings":";;AAAA,OAAO,EACL,SAAS,EAIT,eAAe,EAChB,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EACL,YAAY,EAQb,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,IAAI,EAAwB,MAAM,kBAAkB,CAAC;AAE9D,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,mCAAmC,CAAC;AACnE,OAAO,EAAE,GAAG,EAAE,MAAM,kCAAkC,CAAC;AAGvD,OAAO,EAAE,IAAI,EAAc,MAAM,QA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