@bitgo-beta/sdk-coin-iota 1.0.1-beta.44 → 1.0.1-beta.440

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 (69) hide show
  1. package/README.md +1 -1
  2. package/dist/src/iota.d.ts +134 -23
  3. package/dist/src/iota.d.ts.map +1 -1
  4. package/dist/src/iota.js +286 -46
  5. package/dist/src/lib/constants.d.ts +59 -6
  6. package/dist/src/lib/constants.d.ts.map +1 -1
  7. package/dist/src/lib/constants.js +76 -8
  8. package/dist/src/lib/iface.d.ts +174 -2
  9. package/dist/src/lib/iface.d.ts.map +1 -1
  10. package/dist/src/lib/iface.js +1 -1
  11. package/dist/src/lib/index.d.ts +1 -0
  12. package/dist/src/lib/index.d.ts.map +1 -1
  13. package/dist/src/lib/index.js +4 -2
  14. package/dist/src/lib/keyPair.d.ts +100 -6
  15. package/dist/src/lib/keyPair.d.ts.map +1 -1
  16. package/dist/src/lib/keyPair.js +103 -10
  17. package/dist/src/lib/transaction.d.ts +175 -5
  18. package/dist/src/lib/transaction.d.ts.map +1 -1
  19. package/dist/src/lib/transaction.js +390 -6
  20. package/dist/src/lib/transactionBuilder.d.ts +109 -9
  21. package/dist/src/lib/transactionBuilder.d.ts.map +1 -1
  22. package/dist/src/lib/transactionBuilder.js +200 -14
  23. package/dist/src/lib/transactionBuilderFactory.d.ts +98 -2
  24. package/dist/src/lib/transactionBuilderFactory.d.ts.map +1 -1
  25. package/dist/src/lib/transactionBuilderFactory.js +132 -5
  26. package/dist/src/lib/transferBuilder.d.ts +52 -2
  27. package/dist/src/lib/transferBuilder.d.ts.map +1 -1
  28. package/dist/src/lib/transferBuilder.js +86 -3
  29. package/dist/src/lib/transferTransaction.d.ts +124 -0
  30. package/dist/src/lib/transferTransaction.d.ts.map +1 -0
  31. package/dist/src/lib/transferTransaction.js +341 -0
  32. package/dist/src/lib/utils.d.ts +108 -7
  33. package/dist/src/lib/utils.d.ts.map +1 -1
  34. package/dist/src/lib/utils.js +146 -11
  35. package/dist/test/resources/iota.d.ts +35 -0
  36. package/dist/test/resources/iota.d.ts.map +1 -0
  37. package/dist/test/resources/iota.js +93 -0
  38. package/dist/test/unit/helpers/testHelpers.d.ts +57 -0
  39. package/dist/test/unit/helpers/testHelpers.d.ts.map +1 -0
  40. package/dist/test/unit/helpers/testHelpers.js +176 -0
  41. package/dist/test/unit/index.d.ts +2 -0
  42. package/dist/test/unit/index.d.ts.map +1 -0
  43. package/dist/test/unit/index.js +16 -0
  44. package/dist/test/unit/iota.d.ts +2 -0
  45. package/dist/test/unit/iota.d.ts.map +1 -0
  46. package/dist/test/unit/iota.js +501 -0
  47. package/dist/test/unit/keyPair.d.ts +2 -0
  48. package/dist/test/unit/keyPair.d.ts.map +1 -0
  49. package/dist/test/unit/keyPair.js +108 -0
  50. package/dist/test/unit/transactionBuilder/transactionBuilder.d.ts +2 -0
  51. package/dist/test/unit/transactionBuilder/transactionBuilder.d.ts.map +1 -0
  52. package/dist/test/unit/transactionBuilder/transactionBuilder.js +188 -0
  53. package/dist/test/unit/transactionBuilder/transactionBuilderFactory.d.ts +2 -0
  54. package/dist/test/unit/transactionBuilder/transactionBuilderFactory.d.ts.map +1 -0
  55. package/dist/test/unit/transactionBuilder/transactionBuilderFactory.js +178 -0
  56. package/dist/test/unit/transactionBuilder/transferBuilder.d.ts +2 -0
  57. package/dist/test/unit/transactionBuilder/transferBuilder.d.ts.map +1 -0
  58. package/dist/test/unit/transactionBuilder/transferBuilder.js +438 -0
  59. package/dist/test/unit/transferTransaction.d.ts +2 -0
  60. package/dist/test/unit/transferTransaction.d.ts.map +1 -0
  61. package/dist/test/unit/transferTransaction.js +218 -0
  62. package/dist/test/unit/utils.d.ts +2 -0
  63. package/dist/test/unit/utils.d.ts.map +1 -0
  64. package/dist/test/unit/utils.js +252 -0
  65. package/dist/tsconfig.tsbuildinfo +1 -0
  66. package/package.json +17 -11
  67. package/.eslintignore +0 -5
  68. package/.mocharc.yml +0 -8
  69. package/CHANGELOG.md +0 -28
package/README.md CHANGED
@@ -36,4 +36,4 @@ const iota = sdk.coin('iota');
36
36
 
37
37
  ## Documentation
38
38
 
39
- For detailed API documentation, see the [BitGo API reference](https://app.bitgo.com/docs/).
39
+ For detailed API documentation, view the BitGo [Developer Portal](https://developers.bitgo.com/reference/overview#/).
@@ -1,58 +1,169 @@
1
- import { AuditDecryptedKeyParams, BaseCoin, BitGoBase, KeyPair, ParseTransactionOptions, ParsedTransaction, SignTransactionOptions, SignedTransaction, VerifyTransactionOptions, MultisigType, MPCAlgorithm, TssVerifyAddressOptions } from '@bitgo-beta/sdk-core';
1
+ import { AuditDecryptedKeyParams, BaseCoin, BitGoBase, KeyPair, ParsedTransaction, SignTransactionOptions, SignedTransaction, VerifyTransactionOptions, MultisigType, MPCAlgorithm, TssVerifyAddressOptions, PopulatedIntent, PrebuildTransactionWithIntentOptions } from '@bitgo-beta/sdk-core';
2
2
  import { BaseCoin as StaticsBaseCoin, CoinFamily } from '@bitgo-beta/statics';
3
+ import { ExplainTransactionOptions, IotaParseTransactionOptions, TransactionExplanation } from './lib/iface';
4
+ /**
5
+ * IOTA coin implementation.
6
+ * Supports TSS (Threshold Signature Scheme) with EDDSA algorithm.
7
+ */
3
8
  export declare class Iota extends BaseCoin {
4
9
  protected readonly _staticsCoin: Readonly<StaticsBaseCoin>;
5
10
  protected constructor(bitgo: BitGoBase, staticsCoin?: Readonly<StaticsBaseCoin>);
11
+ /**
12
+ * Factory method to create an IOTA coin instance.
13
+ */
6
14
  static createInstance(bitgo: BitGoBase, staticsCoin?: Readonly<StaticsBaseCoin>): BaseCoin;
7
15
  getBaseFactor(): string | number;
8
16
  getChain(): string;
9
17
  getFamily(): CoinFamily;
10
18
  getFullName(): string;
11
- /** @inheritDoc */
12
19
  supportsTss(): boolean;
13
- /** inherited doc */
14
20
  getDefaultMultisigType(): MultisigType;
15
21
  getMPCAlgorithm(): MPCAlgorithm;
16
22
  /**
17
- * Check if an address is valid
18
- * @param address the address to be validated
23
+ * Validates an IOTA address.
24
+ * @param address - The address to validate (64-character hex string)
19
25
  * @returns true if the address is valid
20
26
  */
21
27
  isValidAddress(address: string): boolean;
22
28
  /**
23
- * Verifies that a transaction prebuild complies with the original intention
24
- * @param params
29
+ * Validates a public key.
30
+ * @param pub - The public key to validate
31
+ * @returns true if the public key is valid
25
32
  */
26
- verifyTransaction(params: VerifyTransactionOptions): Promise<boolean>;
33
+ isValidPub(pub: string): boolean;
27
34
  /**
28
- * Check if an address belongs to a wallet
29
- * @param params
35
+ * Verifies if an address belongs to a TSS wallet.
36
+ * @param params - Verification parameters including wallet address and user/backup public keys
37
+ * @returns true if the address belongs to the wallet
30
38
  */
31
39
  isWalletAddress(params: TssVerifyAddressOptions): Promise<boolean>;
32
40
  /**
33
- * Parse a transaction
34
- * @param params
41
+ * Explains a transaction by parsing its hex representation.
42
+ * @param params - Parameters containing the transaction hex
43
+ * @returns Detailed explanation of the transaction
44
+ * @throws Error if txHex is missing or transaction cannot be explained
35
45
  */
36
- parseTransaction(params: ParseTransactionOptions): Promise<ParsedTransaction>;
46
+ explainTransaction(params: ExplainTransactionOptions): Promise<TransactionExplanation>;
37
47
  /**
38
- * Generate a key pair
39
- * @param seed Optional seed to generate key pair from
48
+ * Verifies that a transaction prebuild matches the original transaction parameters.
49
+ * Ensures recipients and amounts align with the intended transaction.
50
+ *
51
+ * @param params - Verification parameters containing prebuild and original params
52
+ * @returns true if verification succeeds
53
+ * @throws Error if verification fails
40
54
  */
41
- generateKeyPair(seed?: Buffer): KeyPair;
55
+ verifyTransaction(params: VerifyTransactionOptions): Promise<boolean>;
42
56
  /**
43
- * Check if a public key is valid
44
- * @param pub Public key to check
57
+ * Parses a transaction and extracts inputs, outputs, and fees.
58
+ * @param params - Parameters containing the transaction hex
59
+ * @returns Parsed transaction with inputs, outputs, and fee information
45
60
  */
46
- isValidPub(pub: string): boolean;
61
+ parseTransaction(params: IotaParseTransactionOptions): Promise<ParsedTransaction>;
62
+ /**
63
+ * Generates a key pair for IOTA transactions.
64
+ * @param seed - Optional seed to generate deterministic key pair
65
+ * @returns Key pair with public and private keys
66
+ * @throws Error if private key generation fails
67
+ */
68
+ generateKeyPair(seed?: Buffer): KeyPair;
47
69
  /**
48
- * Sign a transaction
49
- * @param params
70
+ * Signs a transaction (not implemented for IOTA).
71
+ * IOTA transactions are signed externally using TSS.
50
72
  */
51
73
  signTransaction(params: SignTransactionOptions): Promise<SignedTransaction>;
52
74
  /**
53
- * Audit a decrypted private key to ensure it's valid
54
- * @param params
75
+ * Audits a decrypted private key to ensure it's valid for the given public key.
76
+ * @param params - Parameters containing multiSigType, private key, and public key
77
+ * @throws Error if multiSigType is not TSS or if key validation fails
55
78
  */
56
79
  auditDecryptedKey({ multiSigType, prv, publicKey }: AuditDecryptedKeyParams): void;
80
+ /**
81
+ * Extracts the signable payload from a serialized transaction.
82
+ * @param serializedTx - The serialized transaction hex
83
+ * @returns Buffer containing the signable payload
84
+ */
85
+ getSignablePayload(serializedTx: string): Promise<Buffer>;
86
+ /**
87
+ * @inheritDoc
88
+ */
89
+ allowsAccountConsolidations(): boolean;
90
+ /**
91
+ * Sets coin-specific fields in the transaction intent.
92
+ * @param intent - The populated intent object to modify
93
+ * @param params - Parameters containing unspents data
94
+ */
95
+ setCoinSpecificFieldsInIntent(intent: PopulatedIntent, params: PrebuildTransactionWithIntentOptions): void;
96
+ /**
97
+ * Validates and extracts transaction hex from parameters.
98
+ * @param txHex - The transaction hex to validate
99
+ * @param operation - The operation being performed (for error messages)
100
+ * @returns The validated transaction hex
101
+ * @throws Error if txHex is missing
102
+ */
103
+ private validateAndExtractTxHex;
104
+ /**
105
+ * Validates that the transaction is a TransferTransaction.
106
+ * @param transaction - The transaction to validate
107
+ * @throws Error if transaction is not a TransferTransaction
108
+ */
109
+ private validateTransactionType;
110
+ /**
111
+ * Verifies that transaction recipients match the expected recipients.
112
+ * @param transaction - The transfer transaction to verify
113
+ * @param expectedRecipients - The expected recipients from transaction params
114
+ * @throws Error if recipients don't match
115
+ */
116
+ private verifyTransactionRecipients;
117
+ /**
118
+ * Normalizes recipients by extracting only relevant fields.
119
+ * @param recipients - Recipients to normalize
120
+ * @returns Normalized recipients with address, amount, and tokenName only
121
+ */
122
+ private normalizeRecipients;
123
+ /**
124
+ * Checks if expected recipients match actual recipients.
125
+ * @param expected - Expected recipients
126
+ * @param actual - Actual recipients from transaction
127
+ * @returns true if all expected recipients are found in actual recipients
128
+ */
129
+ private recipientsMatch;
130
+ /**
131
+ * Creates an empty parsed transaction result.
132
+ * Used when transaction has no outputs.
133
+ */
134
+ private createEmptyParsedTransaction;
135
+ /**
136
+ * Calculates the transaction fee from the explanation.
137
+ * @param explanation - The transaction explanation
138
+ * @returns The fee as a BigNumber
139
+ */
140
+ private calculateTransactionFee;
141
+ /**
142
+ * Builds the inputs array for a parsed transaction.
143
+ * Includes sender input and optionally sponsor input if present.
144
+ *
145
+ * @param explanation - The transaction explanation
146
+ * @param fee - The calculated transaction fee
147
+ * @returns Array of transaction inputs
148
+ */
149
+ private buildTransactionInputs;
150
+ /**
151
+ * Builds the outputs array for a parsed transaction.
152
+ * @param explanation - The transaction explanation
153
+ * @returns Array of transaction outputs
154
+ */
155
+ private buildTransactionOutputs;
156
+ /**
157
+ * Creates a transaction builder factory instance.
158
+ * @returns TransactionBuilderFactory for this coin
159
+ */
160
+ private getTxBuilderFactory;
161
+ /**
162
+ * Rebuilds a transaction from its hex representation.
163
+ * @param txHex - The transaction hex to rebuild
164
+ * @returns The rebuilt transaction
165
+ * @throws Error if transaction cannot be rebuilt
166
+ */
167
+ private rebuildTransaction;
57
168
  }
58
169
  //# sourceMappingURL=iota.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"iota.d.ts","sourceRoot":"","sources":["../../src/iota.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,QAAQ,EACR,SAAS,EACT,OAAO,EACP,uBAAuB,EACvB,iBAAiB,EACjB,sBAAsB,EACtB,i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