@bitgo-beta/sdk-coin-iota 1.0.1-beta.324 → 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.
- package/dist/src/iota.d.ts +123 -27
- package/dist/src/iota.d.ts.map +1 -1
- package/dist/src/iota.js +217 -103
- package/dist/src/lib/constants.d.ts +50 -1
- package/dist/src/lib/constants.d.ts.map +1 -1
- package/dist/src/lib/constants.js +68 -4
- package/dist/src/lib/iface.d.ts +141 -1
- package/dist/src/lib/iface.d.ts.map +1 -1
- package/dist/src/lib/iface.js +1 -1
- package/dist/src/lib/keyPair.d.ts +100 -6
- package/dist/src/lib/keyPair.d.ts.map +1 -1
- package/dist/src/lib/keyPair.js +103 -10
- package/dist/src/lib/transaction.d.ts +117 -14
- package/dist/src/lib/transaction.d.ts.map +1 -1
- package/dist/src/lib/transaction.js +190 -67
- package/dist/src/lib/transactionBuilder.d.ts +73 -34
- package/dist/src/lib/transactionBuilder.d.ts.map +1 -1
- package/dist/src/lib/transactionBuilder.js +90 -45
- package/dist/src/lib/transactionBuilderFactory.d.ts +89 -6
- package/dist/src/lib/transactionBuilderFactory.d.ts.map +1 -1
- package/dist/src/lib/transactionBuilderFactory.js +103 -16
- package/dist/src/lib/transferBuilder.d.ts +43 -0
- package/dist/src/lib/transferBuilder.d.ts.map +1 -1
- package/dist/src/lib/transferBuilder.js +50 -5
- package/dist/src/lib/transferTransaction.d.ts +93 -2
- package/dist/src/lib/transferTransaction.d.ts.map +1 -1
- package/dist/src/lib/transferTransaction.js +180 -51
- package/dist/src/lib/utils.d.ts +107 -8
- package/dist/src/lib/utils.d.ts.map +1 -1
- package/dist/src/lib/utils.js +134 -23
- package/dist/test/unit/helpers/testHelpers.d.ts +57 -0
- package/dist/test/unit/helpers/testHelpers.d.ts.map +1 -0
- package/dist/test/unit/helpers/testHelpers.js +176 -0
- package/dist/test/unit/iota.js +47 -152
- package/dist/test/unit/keyPair.js +34 -61
- package/dist/test/unit/transactionBuilder/transactionBuilder.js +137 -255
- package/dist/test/unit/transactionBuilder/transactionBuilderFactory.js +43 -108
- package/dist/test/unit/transactionBuilder/transferBuilder.js +296 -762
- package/dist/test/unit/transferTransaction.js +106 -353
- package/dist/test/unit/utils.js +171 -197
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -7
|
@@ -2,9 +2,11 @@ import { BaseKey, BaseTransaction, PublicKey, TransactionType } from '@bitgo-bet
|
|
|
2
2
|
import { BaseCoin as CoinConfig } from '@bitgo-beta/statics';
|
|
3
3
|
import { Transaction as IotaTransaction } from '@iota/iota-sdk/transactions';
|
|
4
4
|
import { TxData, TransactionObjectInput, TransactionExplanation } from './iface';
|
|
5
|
+
/**
|
|
6
|
+
* Base class for IOTA transactions.
|
|
7
|
+
* Manages transaction state, gas data, signatures, and building/serialization.
|
|
8
|
+
*/
|
|
5
9
|
export declare abstract class Transaction extends BaseTransaction {
|
|
6
|
-
static EMPTY_PUBLIC_KEY: Buffer<ArrayBuffer>;
|
|
7
|
-
static EMPTY_SIGNATURE: Buffer<ArrayBuffer>;
|
|
8
10
|
protected _rebuildRequired: boolean;
|
|
9
11
|
protected _type: TransactionType;
|
|
10
12
|
protected _iotaTransaction: IotaTransaction;
|
|
@@ -13,12 +15,12 @@ export declare abstract class Transaction extends BaseTransaction {
|
|
|
13
15
|
private _gasPrice?;
|
|
14
16
|
private _gasSponsor?;
|
|
15
17
|
private _sender;
|
|
18
|
+
private _txDataBytes?;
|
|
19
|
+
private _isSimulateTx;
|
|
16
20
|
private _signature?;
|
|
17
21
|
private _serializedSignature?;
|
|
18
22
|
private _gasSponsorSignature?;
|
|
19
23
|
private _serializedGasSponsorSignature?;
|
|
20
|
-
private _txDataBytes?;
|
|
21
|
-
private _isSimulateTx;
|
|
22
24
|
protected constructor(coinConfig: Readonly<CoinConfig>);
|
|
23
25
|
get gasBudget(): number | undefined;
|
|
24
26
|
set gasBudget(value: number | undefined);
|
|
@@ -30,46 +32,147 @@ export declare abstract class Transaction extends BaseTransaction {
|
|
|
30
32
|
set gasSponsor(value: string | undefined);
|
|
31
33
|
get sender(): string;
|
|
32
34
|
set sender(value: string);
|
|
35
|
+
/**
|
|
36
|
+
* Indicates whether this is a simulate transaction (dry run) or a real transaction.
|
|
37
|
+
* Simulate transactions use maximum gas values for estimation purposes.
|
|
38
|
+
*/
|
|
33
39
|
get isSimulateTx(): boolean;
|
|
34
40
|
set isSimulateTx(value: boolean);
|
|
41
|
+
/**
|
|
42
|
+
* Marks that the transaction needs to be rebuilt before it can be signed or broadcast.
|
|
43
|
+
*/
|
|
44
|
+
private markRebuildRequired;
|
|
45
|
+
/**
|
|
46
|
+
* Validates transaction data when switching from simulate to real transaction mode.
|
|
47
|
+
*/
|
|
48
|
+
private validateTxDataForRealTransaction;
|
|
49
|
+
/**
|
|
50
|
+
* Returns the signable payload for this transaction.
|
|
51
|
+
* This is the Blake2b hash of the transaction data with intent message.
|
|
52
|
+
* @throws Error if transaction is in simulate mode or not built
|
|
53
|
+
*/
|
|
35
54
|
get signablePayload(): Buffer;
|
|
36
|
-
/**
|
|
55
|
+
/**
|
|
56
|
+
* Returns the transaction digest (ID).
|
|
57
|
+
* @throws Error if transaction is not built or needs rebuilding
|
|
58
|
+
*/
|
|
37
59
|
get id(): string;
|
|
60
|
+
/**
|
|
61
|
+
* Ensures the transaction is built and doesn't need rebuilding.
|
|
62
|
+
* @throws Error if transaction is not built or rebuild is required
|
|
63
|
+
*/
|
|
64
|
+
private ensureTransactionIsBuilt;
|
|
65
|
+
/**
|
|
66
|
+
* Adds a signature from the transaction sender.
|
|
67
|
+
*/
|
|
38
68
|
addSignature(publicKey: PublicKey, signature: Buffer): void;
|
|
69
|
+
/**
|
|
70
|
+
* Adds a signature from the gas sponsor (if different from sender).
|
|
71
|
+
*/
|
|
39
72
|
addGasSponsorSignature(publicKey: PublicKey, signature: Buffer): void;
|
|
73
|
+
/**
|
|
74
|
+
* Checks if this transaction can be signed.
|
|
75
|
+
* Only real transactions (not simulate) can be signed.
|
|
76
|
+
*/
|
|
40
77
|
canSign(_key: BaseKey): boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Returns the transaction fee (gas budget).
|
|
80
|
+
*/
|
|
41
81
|
getFee(): string | undefined;
|
|
42
82
|
get serializedGasSponsorSignature(): string | undefined;
|
|
43
83
|
get serializedSignature(): string | undefined;
|
|
84
|
+
/**
|
|
85
|
+
* Serializes all signatures for the transaction.
|
|
86
|
+
* Includes both sender signature and gas sponsor signature if present.
|
|
87
|
+
*/
|
|
44
88
|
serializeSignatures(): void;
|
|
89
|
+
/**
|
|
90
|
+
* Converts the transaction to broadcast format (base64 encoded).
|
|
91
|
+
*/
|
|
45
92
|
toBroadcastFormat(): Promise<string>;
|
|
93
|
+
/**
|
|
94
|
+
* Builds the transaction bytes.
|
|
95
|
+
* If in simulate mode, builds a dry run transaction with max gas values.
|
|
96
|
+
* Otherwise, builds a real transaction with actual gas data.
|
|
97
|
+
*/
|
|
46
98
|
build(): Promise<Uint8Array<ArrayBufferLike>>;
|
|
47
99
|
toJson(): TxData;
|
|
48
100
|
parseFromJSON(txData: TxData): void;
|
|
101
|
+
/**
|
|
102
|
+
* Parses transaction data from its broadcast format (base64 or raw bytes).
|
|
103
|
+
* Extracts sender, gas data, and gas sponsor information.
|
|
104
|
+
*/
|
|
49
105
|
parseFromBroadcastTx(tx: string | Uint8Array): void;
|
|
106
|
+
/**
|
|
107
|
+
* Parses the sender address from transaction data.
|
|
108
|
+
*/
|
|
109
|
+
private parseSender;
|
|
110
|
+
/**
|
|
111
|
+
* Parses gas-related data from transaction data.
|
|
112
|
+
*/
|
|
113
|
+
private parseGasData;
|
|
50
114
|
/**
|
|
51
115
|
* @inheritDoc
|
|
52
116
|
*/
|
|
53
117
|
explainTransaction(): any;
|
|
118
|
+
/**
|
|
119
|
+
* Updates the simulate transaction flag based on gas data availability.
|
|
120
|
+
* If all gas data is present, switches to real transaction mode.
|
|
121
|
+
*/
|
|
54
122
|
protected updateIsSimulateTx(): void;
|
|
55
123
|
protected abstract messageWithIntent(message: Uint8Array): Uint8Array;
|
|
56
124
|
protected abstract populateTxInputsAndCommands(): void;
|
|
57
125
|
protected abstract validateTxDataImplementation(): void;
|
|
58
|
-
/**
|
|
59
|
-
* Add the input and output entries for this transaction.
|
|
60
|
-
*/
|
|
61
126
|
abstract addInputsAndOutputs(): void;
|
|
127
|
+
protected abstract explainTransactionImplementation(json: TxData, explanationResult: TransactionExplanation): TransactionExplanation;
|
|
62
128
|
/**
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
* @param {TransactionExplanation} explanationResult The transaction explanation to be completed
|
|
66
|
-
* @returns {TransactionExplanation}
|
|
129
|
+
* Builds a dry run (simulate) transaction with maximum gas values.
|
|
130
|
+
* Used for gas estimation without committing the transaction.
|
|
67
131
|
*/
|
|
68
|
-
protected abstract explainTransactionImplementation(json: TxData, explanationResult: TransactionExplanation): TransactionExplanation;
|
|
69
132
|
private buildDryRunTransaction;
|
|
70
|
-
|
|
133
|
+
/**
|
|
134
|
+
* Builds a real transaction with actual gas data.
|
|
135
|
+
* Only builds if necessary (first time or rebuild required).
|
|
136
|
+
*/
|
|
137
|
+
private buildRealTransaction;
|
|
138
|
+
/**
|
|
139
|
+
* Sets gas data on the IOTA transaction object.
|
|
140
|
+
*/
|
|
141
|
+
private setGasDataOnTransaction;
|
|
142
|
+
/**
|
|
143
|
+
* Populates the IOTA transaction with inputs, commands, and gas sponsor if applicable.
|
|
144
|
+
*/
|
|
71
145
|
private populateTxData;
|
|
146
|
+
/**
|
|
147
|
+
* Checks if the transaction has a gas sponsor different from the sender.
|
|
148
|
+
*/
|
|
149
|
+
private hasDifferentGasSponsor;
|
|
150
|
+
/**
|
|
151
|
+
* Sets up a gas-sponsored transaction by building the transaction kind
|
|
152
|
+
* and setting the gas owner.
|
|
153
|
+
*/
|
|
154
|
+
private setupGasSponsoredTransaction;
|
|
155
|
+
/**
|
|
156
|
+
* Serializes a signature into IOTA's expected format.
|
|
157
|
+
* Format: [signature_scheme_flag (1 byte), signature, public_key]
|
|
158
|
+
* Currently hardcoded to EDDSA (0x00) as IOTA only supports this scheme.
|
|
159
|
+
*/
|
|
72
160
|
private serializeSignature;
|
|
161
|
+
/**
|
|
162
|
+
* Validates all transaction data required for a real (non-simulate) transaction.
|
|
163
|
+
*/
|
|
73
164
|
private validateTxData;
|
|
165
|
+
/**
|
|
166
|
+
* Validates common transaction data (sender, gas data).
|
|
167
|
+
*/
|
|
168
|
+
private validateCommonTxData;
|
|
169
|
+
/**
|
|
170
|
+
* Validates sender and gas sponsor signatures if present.
|
|
171
|
+
*/
|
|
172
|
+
private validateSignatures;
|
|
173
|
+
/**
|
|
174
|
+
* Checks if a signature has valid public key and signature data.
|
|
175
|
+
*/
|
|
176
|
+
private isValidSignature;
|
|
74
177
|
}
|
|
75
178
|
//# sourceMappingURL=transaction.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../../../src/lib/transaction.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,eAAe,EAEf,SAAS,EAGT,eAAe,EAChB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,QAAQ,IAAI,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAEL,WAAW,IAAI,eAAe,EAE/B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,MAAM,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../../../src/lib/transaction.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,eAAe,EAEf,SAAS,EAGT,eAAe,EAChB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,QAAQ,IAAI,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAEL,WAAW,IAAI,eAAe,EAE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