@bitgo-beta/sdk-coin-iota 1.0.1-beta.323 → 1.0.1-beta.325

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 (42) hide show
  1. package/dist/src/iota.d.ts +123 -27
  2. package/dist/src/iota.d.ts.map +1 -1
  3. package/dist/src/iota.js +217 -103
  4. package/dist/src/lib/constants.d.ts +50 -1
  5. package/dist/src/lib/constants.d.ts.map +1 -1
  6. package/dist/src/lib/constants.js +68 -4
  7. package/dist/src/lib/iface.d.ts +141 -1
  8. package/dist/src/lib/iface.d.ts.map +1 -1
  9. package/dist/src/lib/iface.js +1 -1
  10. package/dist/src/lib/keyPair.d.ts +100 -6
  11. package/dist/src/lib/keyPair.d.ts.map +1 -1
  12. package/dist/src/lib/keyPair.js +103 -10
  13. package/dist/src/lib/transaction.d.ts +117 -14
  14. package/dist/src/lib/transaction.d.ts.map +1 -1
  15. package/dist/src/lib/transaction.js +190 -70
  16. package/dist/src/lib/transactionBuilder.d.ts +73 -34
  17. package/dist/src/lib/transactionBuilder.d.ts.map +1 -1
  18. package/dist/src/lib/transactionBuilder.js +90 -45
  19. package/dist/src/lib/transactionBuilderFactory.d.ts +89 -6
  20. package/dist/src/lib/transactionBuilderFactory.d.ts.map +1 -1
  21. package/dist/src/lib/transactionBuilderFactory.js +103 -16
  22. package/dist/src/lib/transferBuilder.d.ts +43 -0
  23. package/dist/src/lib/transferBuilder.d.ts.map +1 -1
  24. package/dist/src/lib/transferBuilder.js +50 -5
  25. package/dist/src/lib/transferTransaction.d.ts +97 -1
  26. package/dist/src/lib/transferTransaction.d.ts.map +1 -1
  27. package/dist/src/lib/transferTransaction.js +223 -52
  28. package/dist/src/lib/utils.d.ts +107 -8
  29. package/dist/src/lib/utils.d.ts.map +1 -1
  30. package/dist/src/lib/utils.js +134 -23
  31. package/dist/test/unit/helpers/testHelpers.d.ts +57 -0
  32. package/dist/test/unit/helpers/testHelpers.d.ts.map +1 -0
  33. package/dist/test/unit/helpers/testHelpers.js +176 -0
  34. package/dist/test/unit/iota.js +47 -152
  35. package/dist/test/unit/keyPair.js +34 -61
  36. package/dist/test/unit/transactionBuilder/transactionBuilder.js +137 -255
  37. package/dist/test/unit/transactionBuilder/transactionBuilderFactory.js +43 -108
  38. package/dist/test/unit/transactionBuilder/transferBuilder.js +334 -319
  39. package/dist/test/unit/transferTransaction.js +106 -353
  40. package/dist/test/unit/utils.js +171 -197
  41. package/dist/tsconfig.tsbuildinfo +1 -1
  42. package/package.json +7 -7
@@ -1,69 +1,165 @@
1
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
3
  import { ExplainTransactionOptions, IotaParseTransactionOptions, TransactionExplanation } from './lib/iface';
4
+ /**
5
+ * IOTA coin implementation.
6
+ * Supports TSS (Threshold Signature Scheme) with EDDSA algorithm.
7
+ */
4
8
  export declare class Iota extends BaseCoin {
5
9
  protected readonly _staticsCoin: Readonly<StaticsBaseCoin>;
6
10
  protected constructor(bitgo: BitGoBase, staticsCoin?: Readonly<StaticsBaseCoin>);
11
+ /**
12
+ * Factory method to create an IOTA coin instance.
13
+ */
7
14
  static createInstance(bitgo: BitGoBase, staticsCoin?: Readonly<StaticsBaseCoin>): BaseCoin;
8
15
  getBaseFactor(): string | number;
9
16
  getChain(): string;
10
17
  getFamily(): CoinFamily;
11
18
  getFullName(): string;
12
- /** @inheritDoc */
13
19
  supportsTss(): boolean;
14
- /** inherited doc */
15
20
  getDefaultMultisigType(): MultisigType;
16
21
  getMPCAlgorithm(): MPCAlgorithm;
17
22
  /**
18
- * Check if an address is valid
19
- * @param address the address to be validated
23
+ * Validates an IOTA address.
24
+ * @param address - The address to validate (64-character hex string)
20
25
  * @returns true if the address is valid
21
26
  */
22
27
  isValidAddress(address: string): boolean;
23
28
  /**
24
- * @inheritDoc
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
- explainTransaction(params: ExplainTransactionOptions): Promise<TransactionExplanation>;
33
+ isValidPub(pub: string): boolean;
27
34
  /**
28
- * Verifies that a transaction prebuild complies with the original intention
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
- verifyTransaction(params: VerifyTransactionOptions): Promise<boolean>;
39
+ isWalletAddress(params: TssVerifyAddressOptions): Promise<boolean>;
32
40
  /**
33
- * Check if an address belongs to a wallet
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
- isWalletAddress(params: TssVerifyAddressOptions): Promise<boolean>;
46
+ explainTransaction(params: ExplainTransactionOptions): Promise<TransactionExplanation>;
37
47
  /**
38
- * Parse a transaction
39
- * @param params
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
- parseTransaction(params: IotaParseTransactionOptions): Promise<ParsedTransaction>;
55
+ verifyTransaction(params: VerifyTransactionOptions): Promise<boolean>;
42
56
  /**
43
- * Generate a key pair
44
- * @param seed Optional seed to generate key pair from
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
- generateKeyPair(seed?: Buffer): KeyPair;
61
+ parseTransaction(params: IotaParseTransactionOptions): Promise<ParsedTransaction>;
47
62
  /**
48
- * Check if a public key is valid
49
- * @param pub Public key to check
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
50
67
  */
51
- isValidPub(pub: string): boolean;
68
+ generateKeyPair(seed?: Buffer): KeyPair;
52
69
  /**
53
- * Sign a transaction
54
- * @param params
70
+ * Signs a transaction (not implemented for IOTA).
71
+ * IOTA transactions are signed externally using TSS.
55
72
  */
56
73
  signTransaction(params: SignTransactionOptions): Promise<SignedTransaction>;
57
74
  /**
58
- * Audit a decrypted private key to ensure it's valid
59
- * @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
60
78
  */
61
79
  auditDecryptedKey({ multiSigType, prv, publicKey }: AuditDecryptedKeyParams): void;
62
- /** @inheritDoc */
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
+ */
63
85
  getSignablePayload(serializedTx: string): Promise<Buffer>;
64
- /** inherited doc */
86
+ /**
87
+ * Sets coin-specific fields in the transaction intent.
88
+ * @param intent - The populated intent object to modify
89
+ * @param params - Parameters containing unspents data
90
+ */
65
91
  setCoinSpecificFieldsInIntent(intent: PopulatedIntent, params: PrebuildTransactionWithIntentOptions): void;
92
+ /**
93
+ * Validates and extracts transaction hex from parameters.
94
+ * @param txHex - The transaction hex to validate
95
+ * @param operation - The operation being performed (for error messages)
96
+ * @returns The validated transaction hex
97
+ * @throws Error if txHex is missing
98
+ */
99
+ private validateAndExtractTxHex;
100
+ /**
101
+ * Validates that the transaction is a TransferTransaction.
102
+ * @param transaction - The transaction to validate
103
+ * @throws Error if transaction is not a TransferTransaction
104
+ */
105
+ private validateTransactionType;
106
+ /**
107
+ * Verifies that transaction recipients match the expected recipients.
108
+ * @param transaction - The transfer transaction to verify
109
+ * @param expectedRecipients - The expected recipients from transaction params
110
+ * @throws Error if recipients don't match
111
+ */
112
+ private verifyTransactionRecipients;
113
+ /**
114
+ * Normalizes recipients by extracting only relevant fields.
115
+ * @param recipients - Recipients to normalize
116
+ * @returns Normalized recipients with address, amount, and tokenName only
117
+ */
118
+ private normalizeRecipients;
119
+ /**
120
+ * Checks if expected recipients match actual recipients.
121
+ * @param expected - Expected recipients
122
+ * @param actual - Actual recipients from transaction
123
+ * @returns true if all expected recipients are found in actual recipients
124
+ */
125
+ private recipientsMatch;
126
+ /**
127
+ * Creates an empty parsed transaction result.
128
+ * Used when transaction has no outputs.
129
+ */
130
+ private createEmptyParsedTransaction;
131
+ /**
132
+ * Calculates the transaction fee from the explanation.
133
+ * @param explanation - The transaction explanation
134
+ * @returns The fee as a BigNumber
135
+ */
136
+ private calculateTransactionFee;
137
+ /**
138
+ * Builds the inputs array for a parsed transaction.
139
+ * Includes sender input and optionally sponsor input if present.
140
+ *
141
+ * @param explanation - The transaction explanation
142
+ * @param fee - The calculated transaction fee
143
+ * @returns Array of transaction inputs
144
+ */
145
+ private buildTransactionInputs;
146
+ /**
147
+ * Builds the outputs array for a parsed transaction.
148
+ * @param explanation - The transaction explanation
149
+ * @returns Array of transaction outputs
150
+ */
151
+ private buildTransactionOutputs;
152
+ /**
153
+ * Creates a transaction builder factory instance.
154
+ * @returns TransactionBuilderFactory for this coin
155
+ */
66
156
  private getTxBuilderFactory;
157
+ /**
158
+ * Rebuilds a transaction from its hex representation.
159
+ * @param txHex - The transaction hex to rebuild
160
+ * @returns The rebuilt transaction
161
+ * @throws Error if transaction cannot be rebuilt
162
+ */
67
163
  private rebuildTransaction;
68
164
  }
69
165
  //# 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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