@bitgo-beta/sdk-coin-atom 1.0.1-beta.9 → 1.0.1-beta.91

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.
Files changed (41) hide show
  1. package/CHANGELOG.md +67 -0
  2. package/dist/src/atom.d.ts +36 -10
  3. package/dist/src/atom.d.ts.map +1 -1
  4. package/dist/src/atom.js +161 -23
  5. package/dist/src/lib/StakingActivateBuilder.d.ts +11 -0
  6. package/dist/src/lib/StakingActivateBuilder.d.ts.map +1 -0
  7. package/dist/src/lib/StakingActivateBuilder.js +31 -0
  8. package/dist/src/lib/StakingDeactivateBuilder.d.ts +11 -0
  9. package/dist/src/lib/StakingDeactivateBuilder.d.ts.map +1 -0
  10. package/dist/src/lib/StakingDeactivateBuilder.js +31 -0
  11. package/dist/src/lib/StakingWithdrawRewardsBuilder.d.ts +11 -0
  12. package/dist/src/lib/StakingWithdrawRewardsBuilder.d.ts.map +1 -0
  13. package/dist/src/lib/StakingWithdrawRewardsBuilder.js +31 -0
  14. package/dist/src/lib/constants.d.ts +8 -5
  15. package/dist/src/lib/constants.d.ts.map +1 -1
  16. package/dist/src/lib/constants.js +10 -8
  17. package/dist/src/lib/iface.d.ts +28 -13
  18. package/dist/src/lib/iface.d.ts.map +1 -1
  19. package/dist/src/lib/iface.js +1 -1
  20. package/dist/src/lib/index.d.ts +3 -0
  21. package/dist/src/lib/index.d.ts.map +1 -1
  22. package/dist/src/lib/index.js +8 -2
  23. package/dist/src/lib/keyPair.d.ts +0 -2
  24. package/dist/src/lib/keyPair.d.ts.map +1 -1
  25. package/dist/src/lib/keyPair.js +4 -12
  26. package/dist/src/lib/transaction.d.ts +25 -13
  27. package/dist/src/lib/transaction.d.ts.map +1 -1
  28. package/dist/src/lib/transaction.js +184 -75
  29. package/dist/src/lib/transactionBuilder.d.ts +38 -36
  30. package/dist/src/lib/transactionBuilder.d.ts.map +1 -1
  31. package/dist/src/lib/transactionBuilder.js +101 -134
  32. package/dist/src/lib/transactionBuilderFactory.d.ts +9 -6
  33. package/dist/src/lib/transactionBuilderFactory.d.ts.map +1 -1
  34. package/dist/src/lib/transactionBuilderFactory.js +25 -13
  35. package/dist/src/lib/transferBuilder.d.ts +5 -2
  36. package/dist/src/lib/transferBuilder.d.ts.map +1 -1
  37. package/dist/src/lib/transferBuilder.js +18 -2
  38. package/dist/src/lib/utils.d.ts +120 -36
  39. package/dist/src/lib/utils.d.ts.map +1 -1
  40. package/dist/src/lib/utils.js +439 -93
  41. package/package.json +11 -8
@@ -1,9 +1,11 @@
1
- import { BaseUtils } from '@bitgo-beta/sdk-core';
1
+ /// <reference types="node" />
2
+ import { BaseUtils, TransactionType } from '@bitgo-beta/sdk-core';
2
3
  import { DecodedTxRaw } from '@cosmjs/proto-signing';
3
- import { AtomTransaction, GasFeeLimitData, MessageData } from './iface';
4
- import { SignerData } from '@cosmjs/stargate';
5
- import { TxRaw, SignDoc } from 'cosmjs-types/cosmos/tx/v1beta1/tx';
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 */
@@ -15,70 +17,152 @@ export declare class Utils implements BaseUtils {
15
17
  /** @inheritdoc */
16
18
  isValidTransactionId(txId: string): boolean;
17
19
  /**
18
- * Checks if raw transaction can be deserialized
20
+ * Checks if transaction hash is in valid black2b format
21
+ */
22
+ validateBlake2b(hash: string): boolean;
23
+ /**
24
+ * Validates if the address matches with regex @see accountAddressRegex
19
25
  *
20
- * @param {string} rawTransaction - transaction in base64 string format
26
+ * @param {string} address
21
27
  * @returns {boolean} - the validation result
22
28
  */
23
- isValidRawTransaction(rawTransaction: string): boolean;
29
+ isValidAddress(address: string): boolean;
24
30
  /**
25
- * Check the raw transaction has a valid format in the blockchain context, throw otherwise.
31
+ * Validates if the address matches with regex @see accountAddressRegex
26
32
  *
27
- * @param {string} rawTransaction - Transaction in base64 string format
33
+ * @param {string} address
34
+ * @returns {boolean} - the validation result
28
35
  */
29
- validateRawTransaction(rawTransaction: string): void;
30
- isValidAddress(address: string): boolean;
36
+ isValidValidatorAddress(address: string): boolean;
31
37
  /**
32
- * Returns whether or not the string is a valid amount
38
+ * Validates whether amounts are in range
33
39
  *
34
40
  * @param {number[]} amounts - the amounts to validate
35
41
  * @returns {boolean} - the validation result
36
42
  */
37
43
  isValidAmounts(amounts: number[]): boolean;
44
+ /**
45
+ * Validates whether amount is in range
46
+ * @param {number} amount
47
+ * @returns {boolean} the validation result
48
+ */
38
49
  isValidAmount(amount: number): boolean;
39
50
  /**
40
51
  * Decodes raw tx data into messages, signing info, and fee data
41
- * @param txHex - raw base64 tx
52
+ * @param {string} txHex - raw base64 tx
53
+ * @returns {DecodedTxRaw} Decoded transaction
42
54
  */
43
55
  getDecodedTxFromRawBase64(txRaw: string): DecodedTxRaw;
44
56
  /**
45
57
  * Returns the array of messages in the body of the decoded transaction
46
- * @param decodedTx
58
+ * @param {DecodedTxRaw} decodedTx
59
+ * @returns {EncodeObject[]} messages along with type url
47
60
  */
48
61
  private getEncodedMessagesFromDecodedTx;
49
62
  /**
50
- * Arranges a decoded message into our MessageData value interface
51
- * @param decodedMessage
52
- * @private
63
+ * Pulls the sequence number from a DecodedTxRaw AuthInfo property
64
+ * @param {DecodedTxRaw} decodedTx
65
+ * @returns {number} sequence
53
66
  */
54
- private getMessageValueDataFromDecodedMessage;
67
+ getSequenceFromDecodedTx(decodedTx: DecodedTxRaw): number;
55
68
  /**
56
- * Returns an array of MessageData[] from an encoded messages array
57
- * @param encodedMessages
58
- * @private
69
+ * Pulls the typeUrl from the encoded message of a DecodedTxRaw
70
+ * @param {DecodedTxRaw} decodedTx
71
+ * @returns {string} cosmos proto type url
59
72
  */
60
- private getMessageDataFromEncodedMessages;
73
+ getTypeUrlFromDecodedTx(decodedTx: DecodedTxRaw): string;
61
74
  /**
62
- * Pulls the sequence number from a DecodedTxRaw AuthInfo property
63
- * @param decodedTx
64
- * @private
75
+ * Returns the fee data from the decoded transaction
76
+ * @param {DecodedTxRaw} decodedTx
77
+ * @returns {FeeData} fee data
65
78
  */
66
- private getSequenceFromDecodedTx;
79
+ getGasBudgetFromDecodedTx(decodedTx: DecodedTxRaw): FeeData;
67
80
  /**
68
- * Pulls the typeUrl from the encoded message of a DecodedTxRaw
69
- * @param decodedTx
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
70
84
  */
71
- getTypeUrlFromDecodedTx(decodedTx: DecodedTxRaw): string;
72
- getGasBudgetFromDecodedTx(decodedTx: DecodedTxRaw): GasFeeLimitData;
73
- getExplicitSignerDataFromDecodedTx(decodedTx: DecodedTxRaw): SignerData;
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[];
92
+ /**
93
+ * Returns the array of MessageData[] from the decoded transaction
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[];
74
104
  /**
75
105
  * Returns the array of MessageData[] from the decoded transaction
76
- * @param decodedTx
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
138
+ */
139
+ isSignedRawTx(rawTransaction: string): boolean;
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
77
160
  */
78
- getMessageDataFromDecodedTx(decodedTx: DecodedTxRaw): MessageData[];
79
- createSignDocFromAtomTransaction(pubkey: any, atomTransaction: AtomTransaction): import("cosmjs-types/cosmos/tx/v1beta1/tx").SignDoc;
80
- createSignedTxRaw(pubkey: string, signDoc: SignDoc, signature: any): TxRaw;
81
- createBase64SignedTxBytesFromSignedTxRaw(signedTxRaw: TxRaw): string;
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;
82
166
  }
83
167
  declare const utils: Utils;
84
168
  export default utils;
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/lib/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAyB,MAAM,sBAAsB,CAAC;AAIxE,OAAO,EACL,YAAY,EAMb,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACxE,OAAO,EAA8B,UAAU,EAAE,MAAM,kBAAkB,CAAC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