@bitgo/sdk-coin-atom 2.1.0 → 3.1.0
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 +27 -0
- package/dist/src/atom.d.ts +36 -10
- package/dist/src/atom.d.ts.map +1 -1
- package/dist/src/atom.js +161 -23
- 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 +7 -4
- package/dist/src/lib/constants.d.ts.map +1 -1
- package/dist/src/lib/constants.js +9 -7
- package/dist/src/lib/iface.d.ts +27 -12
- 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 +24 -12
- package/dist/src/lib/transaction.d.ts.map +1 -1
- package/dist/src/lib/transaction.js +181 -71
- package/dist/src/lib/transactionBuilder.d.ts +36 -34
- package/dist/src/lib/transactionBuilder.d.ts.map +1 -1
- package/dist/src/lib/transactionBuilder.js +97 -129
- 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 -13
- 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 +117 -40
- package/dist/src/lib/utils.d.ts.map +1 -1
- package/dist/src/lib/utils.js +421 -97
- package/package.json +12 -8
package/dist/src/lib/utils.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { BaseUtils,
|
|
2
|
+
import { BaseUtils, TransactionType } from '@bitgo/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 {
|
|
8
|
+
private registry;
|
|
7
9
|
/** @inheritdoc */
|
|
8
10
|
isValidBlockId(hash: string): boolean;
|
|
9
11
|
/** @inheritdoc */
|
|
@@ -14,78 +16,153 @@ export declare class Utils implements BaseUtils {
|
|
|
14
16
|
isValidSignature(signature: string): boolean;
|
|
15
17
|
/** @inheritdoc */
|
|
16
18
|
isValidTransactionId(txId: string): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Checks if transaction hash is in valid black2b format
|
|
21
|
+
*/
|
|
17
22
|
validateBlake2b(hash: string): boolean;
|
|
18
23
|
/**
|
|
19
|
-
*
|
|
24
|
+
* Validates if the address matches with regex @see accountAddressRegex
|
|
20
25
|
*
|
|
21
|
-
* @param {string}
|
|
26
|
+
* @param {string} address
|
|
22
27
|
* @returns {boolean} - the validation result
|
|
23
28
|
*/
|
|
24
|
-
|
|
29
|
+
isValidAddress(address: string): boolean;
|
|
25
30
|
/**
|
|
26
|
-
*
|
|
31
|
+
* Validates if the address matches with regex @see accountAddressRegex
|
|
27
32
|
*
|
|
28
|
-
* @param {string}
|
|
33
|
+
* @param {string} address
|
|
34
|
+
* @returns {boolean} - the validation result
|
|
29
35
|
*/
|
|
30
|
-
|
|
31
|
-
isValidAddress(address: string): boolean;
|
|
36
|
+
isValidValidatorAddress(address: string): boolean;
|
|
32
37
|
/**
|
|
33
|
-
*
|
|
38
|
+
* Validates whether amounts are in range
|
|
34
39
|
*
|
|
35
40
|
* @param {number[]} amounts - the amounts to validate
|
|
36
41
|
* @returns {boolean} - the validation result
|
|
37
42
|
*/
|
|
38
43
|
isValidAmounts(amounts: number[]): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Validates whether amount is in range
|
|
46
|
+
* @param {number} amount
|
|
47
|
+
* @returns {boolean} the validation result
|
|
48
|
+
*/
|
|
39
49
|
isValidAmount(amount: number): boolean;
|
|
40
50
|
/**
|
|
41
51
|
* Decodes raw tx data into messages, signing info, and fee data
|
|
42
|
-
* @param txHex - raw base64 tx
|
|
52
|
+
* @param {string} txHex - raw base64 tx
|
|
53
|
+
* @returns {DecodedTxRaw} Decoded transaction
|
|
43
54
|
*/
|
|
44
55
|
getDecodedTxFromRawBase64(txRaw: string): DecodedTxRaw;
|
|
45
56
|
/**
|
|
46
57
|
* Returns the array of messages in the body of the decoded transaction
|
|
47
|
-
* @param decodedTx
|
|
58
|
+
* @param {DecodedTxRaw} decodedTx
|
|
59
|
+
* @returns {EncodeObject[]} messages along with type url
|
|
48
60
|
*/
|
|
49
61
|
private getEncodedMessagesFromDecodedTx;
|
|
50
|
-
/**
|
|
51
|
-
* Arranges a decoded message into our MessageData value interface
|
|
52
|
-
* @param decodedMessage
|
|
53
|
-
* @private
|
|
54
|
-
*/
|
|
55
|
-
private getMessageValueDataFromDecodedMessage;
|
|
56
|
-
/**
|
|
57
|
-
* Returns an array of MessageData[] from an encoded messages array
|
|
58
|
-
* @param encodedMessages
|
|
59
|
-
* @private
|
|
60
|
-
*/
|
|
61
|
-
private getMessageDataFromEncodedMessages;
|
|
62
62
|
/**
|
|
63
63
|
* Pulls the sequence number from a DecodedTxRaw AuthInfo property
|
|
64
|
-
* @param decodedTx
|
|
65
|
-
* @
|
|
64
|
+
* @param {DecodedTxRaw} decodedTx
|
|
65
|
+
* @returns {number} sequence
|
|
66
66
|
*/
|
|
67
67
|
getSequenceFromDecodedTx(decodedTx: DecodedTxRaw): number;
|
|
68
68
|
/**
|
|
69
69
|
* Pulls the typeUrl from the encoded message of a DecodedTxRaw
|
|
70
|
-
* @param decodedTx
|
|
70
|
+
* @param {DecodedTxRaw} decodedTx
|
|
71
|
+
* @returns {string} cosmos proto type url
|
|
71
72
|
*/
|
|
72
73
|
getTypeUrlFromDecodedTx(decodedTx: DecodedTxRaw): string;
|
|
73
|
-
|
|
74
|
+
/**
|
|
75
|
+
* Returns the fee data from the decoded transaction
|
|
76
|
+
* @param {DecodedTxRaw} decodedTx
|
|
77
|
+
* @returns {FeeData} fee data
|
|
78
|
+
*/
|
|
79
|
+
getGasBudgetFromDecodedTx(decodedTx: DecodedTxRaw): FeeData;
|
|
80
|
+
/**
|
|
81
|
+
* Returns the publicKey from the decoded transaction
|
|
82
|
+
* @param {DecodedTxRaw} decodedTx
|
|
83
|
+
* @returns {string | undefined} publicKey in hex format if it exists, undefined otherwise
|
|
84
|
+
*/
|
|
85
|
+
getPublicKeyFromDecodedTx(decodedTx: DecodedTxRaw): string | undefined;
|
|
86
|
+
/**
|
|
87
|
+
* Returns the array of MessageData[] from the decoded transaction
|
|
88
|
+
* @param {DecodedTxRaw} decodedTx
|
|
89
|
+
* @returns {MessageData[]} Send transaction message data
|
|
90
|
+
*/
|
|
91
|
+
getSendMessageDataFromDecodedTx(decodedTx: DecodedTxRaw): MessageData[];
|
|
74
92
|
/**
|
|
75
93
|
* Returns the array of MessageData[] from the decoded transaction
|
|
76
|
-
* @param decodedTx
|
|
94
|
+
* @param {DecodedTxRaw} decodedTx
|
|
95
|
+
* @returns {MessageData[]} Delegate of undelegate transaction message data
|
|
96
|
+
*/
|
|
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;
|
|
116
|
+
/**
|
|
117
|
+
* Creates a txRaw from an atom transaction @see AtomTransaction
|
|
118
|
+
* @Precondition atomTransaction.publicKey must be defined
|
|
119
|
+
* @param {AtomTransaction} atomTransaction
|
|
120
|
+
* @returns {TxRaw} Unsigned raw transaction
|
|
121
|
+
*/
|
|
122
|
+
createTxRawFromAtomTransaction(atomTransaction: AtomTransaction): TxRaw;
|
|
123
|
+
/**
|
|
124
|
+
* Encodes a signature into a txRaw
|
|
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
|
|
129
|
+
*/
|
|
130
|
+
createSignedTxRaw(publicKeyHex: string, signatureHex: string, unsignedTx: {
|
|
131
|
+
bodyBytes: Uint8Array;
|
|
132
|
+
authInfoBytes: Uint8Array;
|
|
133
|
+
}): TxRaw;
|
|
134
|
+
/**
|
|
135
|
+
* Decodes a raw transaction into a DecodedTxRaw and checks if it has non empty signatures
|
|
136
|
+
* @param {string} rawTransaction
|
|
137
|
+
* @returns {boolean} true if transaction is signed else false
|
|
77
138
|
*/
|
|
78
|
-
getMessageDataFromDecodedTx(decodedTx: DecodedTxRaw): MessageData[];
|
|
79
|
-
createSignDocFromAtomTransaction(pubkey: any, atomTransaction: AtomTransaction): import("cosmjs-types/cosmos/tx/v1beta1/tx").SignDoc;
|
|
80
|
-
createSignedTxRaw(atomSignature: Signature, signDoc: SignDoc): TxRaw;
|
|
81
|
-
createBase64SignedTxBytesFromSignedTxRaw(signedTxRaw: TxRaw): string;
|
|
82
139
|
isSignedRawTx(rawTransaction: string): boolean;
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
140
|
+
/**
|
|
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;
|
|
89
166
|
}
|
|
90
167
|
declare const utils: Utils;
|
|
91
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,iBAAiB,CAAC;AAGzB,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,2BAA2B,EAC3B,OAAO,EACP,WAAW,EACX,WAAW,EACX,+BAA+B,EAChC,MAAM,SAAS,CAAC;AAGjB,qBAAa,KAAM,YAAW,SAAS;IACrC,OAAO,CAAC,QAAQ,CAA2C;IAE3D,kBAAkB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