@bitgo-beta/sdk-coin-atom 1.1.2-alpha.26 → 1.1.2-alpha.28
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 +31 -0
- package/dist/src/atom.d.ts +110 -9
- package/dist/src/atom.d.ts.map +1 -1
- package/dist/src/atom.js +432 -31
- package/dist/src/lib/StakingActivateBuilder.d.ts +11 -0
- package/dist/src/lib/StakingActivateBuilder.d.ts.map +1 -0
- package/dist/src/lib/StakingActivateBuilder.js +31 -0
- package/dist/src/lib/StakingDeactivateBuilder.d.ts +11 -0
- package/dist/src/lib/StakingDeactivateBuilder.d.ts.map +1 -0
- package/dist/src/lib/StakingDeactivateBuilder.js +31 -0
- package/dist/src/lib/StakingWithdrawRewardsBuilder.d.ts +11 -0
- package/dist/src/lib/StakingWithdrawRewardsBuilder.d.ts.map +1 -0
- package/dist/src/lib/StakingWithdrawRewardsBuilder.js +31 -0
- package/dist/src/lib/constants.d.ts +8 -4
- package/dist/src/lib/constants.d.ts.map +1 -1
- package/dist/src/lib/constants.js +10 -7
- package/dist/src/lib/iface.d.ts +25 -13
- package/dist/src/lib/iface.d.ts.map +1 -1
- package/dist/src/lib/iface.js +1 -1
- package/dist/src/lib/index.d.ts +3 -0
- package/dist/src/lib/index.d.ts.map +1 -1
- package/dist/src/lib/index.js +8 -2
- package/dist/src/lib/keyPair.d.ts +0 -2
- package/dist/src/lib/keyPair.d.ts.map +1 -1
- package/dist/src/lib/keyPair.js +4 -12
- package/dist/src/lib/transaction.d.ts +18 -12
- package/dist/src/lib/transaction.d.ts.map +1 -1
- package/dist/src/lib/transaction.js +169 -69
- package/dist/src/lib/transactionBuilder.d.ts +26 -30
- package/dist/src/lib/transactionBuilder.d.ts.map +1 -1
- package/dist/src/lib/transactionBuilder.js +86 -130
- package/dist/src/lib/transactionBuilderFactory.d.ts +9 -6
- package/dist/src/lib/transactionBuilderFactory.d.ts.map +1 -1
- package/dist/src/lib/transactionBuilderFactory.js +25 -11
- package/dist/src/lib/transferBuilder.d.ts +5 -2
- package/dist/src/lib/transferBuilder.d.ts.map +1 -1
- package/dist/src/lib/transferBuilder.js +18 -2
- package/dist/src/lib/utils.d.ts +83 -69
- package/dist/src/lib/utils.d.ts.map +1 -1
- package/dist/src/lib/utils.js +348 -139
- package/package.json +12 -9
package/dist/src/lib/utils.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { BaseUtils,
|
|
2
|
+
import { BaseUtils, TransactionType } from '@bitgo-beta/sdk-core';
|
|
3
3
|
import { DecodedTxRaw } from '@cosmjs/proto-signing';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { Coin } from '@cosmjs/stargate';
|
|
5
|
+
import { SignDoc, TxRaw } from 'cosmjs-types/cosmos/tx/v1beta1/tx';
|
|
6
|
+
import { AtomTransaction, DelegateOrUndelegeteMessage, FeeData, MessageData, SendMessage, WithdrawDelegatorRewardsMessage } from './iface';
|
|
6
7
|
export declare class Utils implements BaseUtils {
|
|
7
8
|
private registry;
|
|
8
9
|
/** @inheritdoc */
|
|
@@ -20,24 +21,19 @@ export declare class Utils implements BaseUtils {
|
|
|
20
21
|
*/
|
|
21
22
|
validateBlake2b(hash: string): boolean;
|
|
22
23
|
/**
|
|
23
|
-
*
|
|
24
|
+
* Validates if the address matches with regex @see accountAddressRegex
|
|
24
25
|
*
|
|
25
|
-
* @param {string}
|
|
26
|
+
* @param {string} address
|
|
26
27
|
* @returns {boolean} - the validation result
|
|
27
28
|
*/
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Check the raw transaction has a valid format in the blockchain context, throw otherwise.
|
|
31
|
-
*
|
|
32
|
-
* @param {string} rawTransaction - Transaction in base64 string format
|
|
33
|
-
*/
|
|
34
|
-
validateRawTransaction(rawTransaction: string | undefined): void;
|
|
29
|
+
isValidAddress(address: string): boolean;
|
|
35
30
|
/**
|
|
36
31
|
* Validates if the address matches with regex @see accountAddressRegex
|
|
37
32
|
*
|
|
38
|
-
* @param address
|
|
33
|
+
* @param {string} address
|
|
34
|
+
* @returns {boolean} - the validation result
|
|
39
35
|
*/
|
|
40
|
-
|
|
36
|
+
isValidValidatorAddress(address: string): boolean;
|
|
41
37
|
/**
|
|
42
38
|
* Validates whether amounts are in range
|
|
43
39
|
*
|
|
@@ -47,108 +43,126 @@ export declare class Utils implements BaseUtils {
|
|
|
47
43
|
isValidAmounts(amounts: number[]): boolean;
|
|
48
44
|
/**
|
|
49
45
|
* Validates whether amount is in range
|
|
50
|
-
*
|
|
51
|
-
* @
|
|
52
|
-
* @returns
|
|
46
|
+
* @param {number} amount
|
|
47
|
+
* @returns {boolean} the validation result
|
|
53
48
|
*/
|
|
54
49
|
isValidAmount(amount: number): boolean;
|
|
55
50
|
/**
|
|
56
51
|
* Decodes raw tx data into messages, signing info, and fee data
|
|
57
|
-
* @param txHex - raw base64 tx
|
|
52
|
+
* @param {string} txHex - raw base64 tx
|
|
53
|
+
* @returns {DecodedTxRaw} Decoded transaction
|
|
58
54
|
*/
|
|
59
55
|
getDecodedTxFromRawBase64(txRaw: string): DecodedTxRaw;
|
|
60
56
|
/**
|
|
61
57
|
* Returns the array of messages in the body of the decoded transaction
|
|
62
|
-
* @param decodedTx
|
|
58
|
+
* @param {DecodedTxRaw} decodedTx
|
|
59
|
+
* @returns {EncodeObject[]} messages along with type url
|
|
63
60
|
*/
|
|
64
61
|
private getEncodedMessagesFromDecodedTx;
|
|
65
|
-
/**
|
|
66
|
-
* Arranges a decoded message into our MessageData value interface
|
|
67
|
-
* @param decodedMessage
|
|
68
|
-
* @private
|
|
69
|
-
*/
|
|
70
|
-
private getMessageValueDataFromDecodedMessage;
|
|
71
|
-
/**
|
|
72
|
-
* Returns an array of MessageData[] from an encoded messages array
|
|
73
|
-
* @param encodedMessages
|
|
74
|
-
* @private
|
|
75
|
-
*/
|
|
76
|
-
private getMessageDataFromEncodedMessages;
|
|
77
62
|
/**
|
|
78
63
|
* Pulls the sequence number from a DecodedTxRaw AuthInfo property
|
|
79
|
-
* @param decodedTx
|
|
80
|
-
* @
|
|
64
|
+
* @param {DecodedTxRaw} decodedTx
|
|
65
|
+
* @returns {number} sequence
|
|
81
66
|
*/
|
|
82
67
|
getSequenceFromDecodedTx(decodedTx: DecodedTxRaw): number;
|
|
83
68
|
/**
|
|
84
69
|
* Pulls the typeUrl from the encoded message of a DecodedTxRaw
|
|
85
|
-
* @param decodedTx
|
|
70
|
+
* @param {DecodedTxRaw} decodedTx
|
|
71
|
+
* @returns {string} cosmos proto type url
|
|
86
72
|
*/
|
|
87
73
|
getTypeUrlFromDecodedTx(decodedTx: DecodedTxRaw): string;
|
|
88
74
|
/**
|
|
89
75
|
* Returns the fee data from the decoded transaction
|
|
90
|
-
* @param decodedTx
|
|
91
|
-
* @returns
|
|
76
|
+
* @param {DecodedTxRaw} decodedTx
|
|
77
|
+
* @returns {FeeData} fee data
|
|
92
78
|
*/
|
|
93
79
|
getGasBudgetFromDecodedTx(decodedTx: DecodedTxRaw): FeeData;
|
|
94
80
|
/**
|
|
95
81
|
* Returns the publicKey from the decoded transaction
|
|
96
|
-
* @param decodedTx
|
|
97
|
-
* @returns publicKey in hex format if it exists, undefined otherwise
|
|
82
|
+
* @param {DecodedTxRaw} decodedTx
|
|
83
|
+
* @returns {string | undefined} publicKey in hex format if it exists, undefined otherwise
|
|
98
84
|
*/
|
|
99
85
|
getPublicKeyFromDecodedTx(decodedTx: DecodedTxRaw): string | undefined;
|
|
100
86
|
/**
|
|
101
87
|
* Returns the array of MessageData[] from the decoded transaction
|
|
102
|
-
* @param decodedTx
|
|
88
|
+
* @param {DecodedTxRaw} decodedTx
|
|
89
|
+
* @returns {MessageData[]} Send transaction message data
|
|
103
90
|
*/
|
|
104
|
-
|
|
91
|
+
getSendMessageDataFromDecodedTx(decodedTx: DecodedTxRaw): MessageData[];
|
|
105
92
|
/**
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
* @
|
|
109
|
-
* @param atomTransaction
|
|
110
|
-
* @returns
|
|
93
|
+
* Returns the array of MessageData[] from the decoded transaction
|
|
94
|
+
* @param {DecodedTxRaw} decodedTx
|
|
95
|
+
* @returns {MessageData[]} Delegate of undelegate transaction message data
|
|
111
96
|
*/
|
|
112
|
-
|
|
97
|
+
getDelegateOrUndelegateMessageDataFromDecodedTx(decodedTx: DecodedTxRaw): MessageData[];
|
|
98
|
+
/**
|
|
99
|
+
* Returns the array of MessageData[] from the decoded transaction
|
|
100
|
+
* @param {DecodedTxRaw} decodedTx
|
|
101
|
+
* @returns {MessageData[]} WithdrawDelegatorRewards transaction message data
|
|
102
|
+
*/
|
|
103
|
+
getWithdrawRewardsMessageDataFromDecodedTx(decodedTx: DecodedTxRaw): MessageData[];
|
|
104
|
+
/**
|
|
105
|
+
* Returns the array of MessageData[] from the decoded transaction
|
|
106
|
+
* @param {DecodedTxRaw} decodedTx
|
|
107
|
+
* @returns {MessageData[]} Delegate of undelegate transaction message data
|
|
108
|
+
*/
|
|
109
|
+
getWithdrawDelegatorRewardsMessageDataFromDecodedTx(decodedTx: DecodedTxRaw): MessageData[];
|
|
110
|
+
/**
|
|
111
|
+
* Determines bitgo transaction type based on cosmos proto type url
|
|
112
|
+
* @param {string} typeUrl
|
|
113
|
+
* @returns {TransactionType | undefined} TransactionType if url is supported else undefined
|
|
114
|
+
*/
|
|
115
|
+
getTransactionTypeFromTypeUrl(typeUrl: string): TransactionType | undefined;
|
|
113
116
|
/**
|
|
114
117
|
* Creates a txRaw from an atom transaction @see AtomTransaction
|
|
115
|
-
*
|
|
116
118
|
* @Precondition atomTransaction.publicKey must be defined
|
|
117
|
-
* @param atomTransaction
|
|
118
|
-
* @returns
|
|
119
|
+
* @param {AtomTransaction} atomTransaction
|
|
120
|
+
* @returns {TxRaw} Unsigned raw transaction
|
|
119
121
|
*/
|
|
120
122
|
createTxRawFromAtomTransaction(atomTransaction: AtomTransaction): TxRaw;
|
|
121
123
|
/**
|
|
122
124
|
* Encodes a signature into a txRaw
|
|
123
|
-
*
|
|
124
|
-
* @param signature
|
|
125
|
-
* @param
|
|
126
|
-
* @returns
|
|
125
|
+
* @param {string} publicKeyHex publicKey in hex encoded string format
|
|
126
|
+
* @param {string} signatureHex signature in hex encoded string format
|
|
127
|
+
* @param {TxRaw} unsignedTx raw transaction
|
|
128
|
+
* @returns {TxRaw} Signed raw transaction
|
|
127
129
|
*/
|
|
128
|
-
createSignedTxRaw(
|
|
130
|
+
createSignedTxRaw(publicKeyHex: string, signatureHex: string, unsignedTx: {
|
|
129
131
|
bodyBytes: Uint8Array;
|
|
130
132
|
authInfoBytes: Uint8Array;
|
|
131
133
|
}): TxRaw;
|
|
132
134
|
/**
|
|
133
135
|
* Decodes a raw transaction into a DecodedTxRaw and checks if it has non empty signatures
|
|
134
|
-
*
|
|
135
|
-
* @
|
|
136
|
-
* @returns
|
|
136
|
+
* @param {string} rawTransaction
|
|
137
|
+
* @returns {boolean} true if transaction is signed else false
|
|
137
138
|
*/
|
|
138
139
|
isSignedRawTx(rawTransaction: string): boolean;
|
|
139
140
|
/**
|
|
140
|
-
*
|
|
141
|
-
*
|
|
142
|
-
* @
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
141
|
+
* Deserializes base64 enocded raw transaction string into @see AtomTransaction
|
|
142
|
+
* @param {string} rawTx base64 enocded raw transaction string
|
|
143
|
+
* @returns {AtomTransaction} Deserialized atomTransaction
|
|
144
|
+
*/
|
|
145
|
+
deserializeAtomTransaction(rawTx: string): AtomTransaction;
|
|
146
|
+
createAtomTransaction(sequence: number, messages: MessageData[], gasBudget: FeeData, publicKey?: string, memo?: string): AtomTransaction;
|
|
147
|
+
createAtomTransactionWithHash(sequence: number, messages: MessageData[], gasBudget: FeeData, publicKey?: string, signature?: Buffer, memo?: string): AtomTransaction;
|
|
148
|
+
validateAtomTransaction(tx: AtomTransaction): void;
|
|
149
|
+
validateMessageData(messageData: MessageData): void;
|
|
150
|
+
validateAmountData(amountArray: Coin[]): void;
|
|
151
|
+
validateAmount(amount: Coin): void;
|
|
152
|
+
validateGasBudget(gasBudget: FeeData): void;
|
|
153
|
+
validateSequence(sequence: number): void;
|
|
154
|
+
validatePublicKey(publicKey: string | undefined): void;
|
|
155
|
+
/**
|
|
156
|
+
* Creates a sign doc from an atom transaction @see AtomTransaction
|
|
157
|
+
* @Precondition atomTransaction.accountNumber and atomTransaction.chainId must be defined
|
|
158
|
+
* @param {AtomTransaction} atomTransaction
|
|
159
|
+
* @returns {SignDoc} sign doc
|
|
160
|
+
*/
|
|
161
|
+
createSignDoc(atomTransaction: AtomTransaction, accountNumber: number | undefined, chainId: string | undefined): SignDoc;
|
|
162
|
+
validateDelegateOrUndelegateMessage(delegateMessage: DelegateOrUndelegeteMessage): void;
|
|
163
|
+
validateWithdrawRewardsMessage(withdrawRewardsMessage: WithdrawDelegatorRewardsMessage): void;
|
|
164
|
+
validateSendMessage(sendMessage: SendMessage): void;
|
|
165
|
+
isValidHexString(hexString: string): boolean;
|
|
152
166
|
}
|
|
153
167
|
declare const utils: Utils;
|
|
154
168
|
export default utils;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/lib/utils.ts"],"names":[],"mappings":";AAAA,OAAO,
|
|
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;AAKnE,OAAO,EACL,eAAe,EACf,2B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