@bitgo-beta/abstract-eth 1.2.3-alpha.89 → 1.2.3-alpha.90

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 (62) hide show
  1. package/dist/src/abstractEthLikeCoin.d.ts +3 -2
  2. package/dist/src/abstractEthLikeCoin.d.ts.map +1 -1
  3. package/dist/src/abstractEthLikeCoin.js +9 -9
  4. package/dist/src/abstractEthLikeNewCoins.d.ts +93 -0
  5. package/dist/src/abstractEthLikeNewCoins.d.ts.map +1 -0
  6. package/dist/src/abstractEthLikeNewCoins.js +147 -0
  7. package/dist/src/ethLikeToken.d.ts +7 -2
  8. package/dist/src/ethLikeToken.d.ts.map +1 -1
  9. package/dist/src/ethLikeToken.js +8 -5
  10. package/dist/src/index.d.ts +2 -2
  11. package/dist/src/index.d.ts.map +1 -1
  12. package/dist/src/index.js +3 -3
  13. package/dist/src/lib/contractCall.d.ts +8 -0
  14. package/dist/src/lib/contractCall.d.ts.map +1 -0
  15. package/dist/src/lib/contractCall.js +17 -0
  16. package/dist/src/lib/iface.d.ts +130 -0
  17. package/dist/src/lib/iface.d.ts.map +1 -0
  18. package/dist/src/lib/iface.js +8 -0
  19. package/dist/src/lib/index.d.ts +15 -0
  20. package/dist/src/lib/index.d.ts.map +1 -0
  21. package/dist/src/lib/index.js +42 -0
  22. package/dist/src/lib/keyPair.d.ts +26 -0
  23. package/dist/src/lib/keyPair.d.ts.map +1 -0
  24. package/dist/src/lib/keyPair.js +66 -0
  25. package/dist/src/lib/transaction.d.ts +64 -0
  26. package/dist/src/lib/transaction.d.ts.map +1 -0
  27. package/dist/src/lib/transaction.js +137 -0
  28. package/dist/src/lib/transactionBuilder.d.ts +231 -0
  29. package/dist/src/lib/transactionBuilder.d.ts.map +1 -0
  30. package/dist/src/lib/transactionBuilder.js +674 -0
  31. package/dist/src/lib/transferBuilder.d.ts +65 -0
  32. package/dist/src/lib/transferBuilder.d.ts.map +1 -0
  33. package/dist/src/lib/transferBuilder.js +221 -0
  34. package/dist/src/lib/transferBuilders/baseNFTTransferBuilder.d.ts +47 -0
  35. package/dist/src/lib/transferBuilders/baseNFTTransferBuilder.d.ts.map +1 -0
  36. package/dist/src/lib/transferBuilders/baseNFTTransferBuilder.js +113 -0
  37. package/dist/src/lib/transferBuilders/index.d.ts +4 -0
  38. package/dist/src/lib/transferBuilders/index.d.ts.map +1 -0
  39. package/dist/src/lib/transferBuilders/index.js +16 -0
  40. package/dist/src/lib/transferBuilders/transferBuilderERC1155.d.ts +14 -0
  41. package/dist/src/lib/transferBuilders/transferBuilderERC1155.d.ts.map +1 -0
  42. package/dist/src/lib/transferBuilders/transferBuilderERC1155.js +83 -0
  43. package/dist/src/lib/transferBuilders/transferBuilderERC721.d.ts +13 -0
  44. package/dist/src/lib/transferBuilders/transferBuilderERC721.d.ts.map +1 -0
  45. package/dist/src/lib/transferBuilders/transferBuilderERC721.js +68 -0
  46. package/dist/src/lib/types.d.ts +39 -0
  47. package/dist/src/lib/types.d.ts.map +1 -0
  48. package/dist/src/lib/types.js +137 -0
  49. package/dist/src/lib/utils.d.ts +228 -0
  50. package/dist/src/lib/utils.d.ts.map +1 -0
  51. package/dist/src/lib/utils.js +577 -0
  52. package/dist/src/lib/walletUtil.d.ts +26 -0
  53. package/dist/src/lib/walletUtil.d.ts.map +1 -0
  54. package/dist/src/lib/walletUtil.js +29 -0
  55. package/dist/tsconfig.tsbuildinfo +1 -1
  56. package/package.json +13 -7
  57. package/dist/src/abstractEthLikeMPCCoin.d.ts +0 -12
  58. package/dist/src/abstractEthLikeMPCCoin.d.ts.map +0 -1
  59. package/dist/src/abstractEthLikeMPCCoin.js +0 -16
  60. package/dist/src/ethLikeMPCToken.d.ts +0 -12
  61. package/dist/src/ethLikeMPCToken.d.ts.map +0 -1
  62. package/dist/src/ethLikeMPCToken.js +0 -16
@@ -0,0 +1,231 @@
1
+ import { BaseCoin as CoinConfig } from '@bitgo-beta/statics';
2
+ import EthereumCommon from '@ethereumjs/common';
3
+ import BigNumber from 'bignumber.js';
4
+ import { BaseAddress, BaseKey, BaseTransaction, BaseTransactionBuilder, TransactionType } from '@bitgo-beta/sdk-core';
5
+ import { KeyPair } from './keyPair';
6
+ import { Fee, TxData } from './iface';
7
+ import { ERC1155TransferBuilder } from './transferBuilders/transferBuilderERC1155';
8
+ import { ERC721TransferBuilder } from './transferBuilders/transferBuilderERC721';
9
+ import { Transaction } from './transaction';
10
+ import { TransferBuilder } from './transferBuilder';
11
+ /**
12
+ * EthereumLike transaction builder.
13
+ */
14
+ export declare abstract class TransactionBuilder extends BaseTransactionBuilder {
15
+ protected _type: TransactionType;
16
+ protected _common: EthereumCommon;
17
+ protected _sourceKeyPair: KeyPair;
18
+ private _transaction;
19
+ private _counter;
20
+ private _fee;
21
+ protected _value: string;
22
+ private _txSignature;
23
+ private _walletOwnerAddresses;
24
+ private _walletVersion;
25
+ private _forwarderAddress;
26
+ private _tokenAddress;
27
+ protected _transfer: TransferBuilder | ERC721TransferBuilder | ERC1155TransferBuilder;
28
+ private _contractAddress;
29
+ private _contractCounter;
30
+ private _forwarderVersion;
31
+ private _initCode;
32
+ private _baseAddress;
33
+ private _data;
34
+ private _salt;
35
+ /**
36
+ * Public constructor.
37
+ *
38
+ * @param _coinConfig
39
+ */
40
+ constructor(_coinConfig: Readonly<CoinConfig>);
41
+ /** @inheritdoc */
42
+ protected buildImplementation(): Promise<BaseTransaction>;
43
+ protected getTransactionData(): TxData;
44
+ /** @inheritdoc */
45
+ protected fromImplementation(rawTransaction: string): Transaction;
46
+ /**
47
+ * Load the builder data using the deserialized transaction
48
+ *
49
+ * @param {TxData} transactionJson the deserialized transaction json
50
+ */
51
+ protected loadBuilderInput(transactionJson: TxData): void;
52
+ protected setTransactionTypeFields(decodedType: TransactionType, transactionJson: TxData): void;
53
+ /** @inheritdoc */
54
+ protected signImplementation(key: BaseKey): BaseTransaction;
55
+ /** @inheritdoc */
56
+ validateAddress(address: BaseAddress): void;
57
+ /** @inheritdoc */
58
+ validateKey(key: BaseKey): void;
59
+ /**
60
+ * Validate the raw transaction is either a JSON or
61
+ * a hex encoded transaction
62
+ *
63
+ * @param {any} rawTransaction The raw transaction to be validated
64
+ */
65
+ validateRawTransaction(rawTransaction: any): void;
66
+ private isEip1559Txn;
67
+ private isRLPDecodable;
68
+ protected validateBaseTransactionFields(): void;
69
+ /** @inheritdoc */
70
+ validateTransaction(transaction: BaseTransaction): void;
71
+ /**
72
+ * Check wallet owner addresses for wallet initialization transactions are valid or throw.
73
+ */
74
+ private validateWalletInitializationFields;
75
+ /**
76
+ * Check if a token address for the tx was defined or throw.
77
+ */
78
+ private validateTokenAddress;
79
+ /**
80
+ * Check if a forwarder address for the tx was defined or throw.
81
+ */
82
+ private validateForwarderAddress;
83
+ /**
84
+ * Check if a contract address for the wallet was defined or throw.
85
+ */
86
+ private validateContractAddress;
87
+ /**
88
+ * Checks if a contract call data field was defined or throws otherwise
89
+ */
90
+ private validateDataField;
91
+ private setContract;
92
+ validateValue(value: BigNumber): void;
93
+ /**
94
+ * The type of transaction being built.
95
+ *
96
+ * @param {TransactionType} type
97
+ */
98
+ type(type: TransactionType): void;
99
+ /**
100
+ * Set the transaction fees. Low fees may get a transaction rejected or never picked up by bakers.
101
+ *
102
+ * @param {Fee} fee Baker fees. May also include the maximum gas to pay
103
+ */
104
+ fee(fee: Fee): void;
105
+ /**
106
+ * Set the transaction counter to prevent submitting repeated transactions.
107
+ *
108
+ * @param {number} counter The counter to use
109
+ */
110
+ counter(counter: number): void;
111
+ /**
112
+ * The value to send along with this transaction. 0 by default
113
+ *
114
+ * @param {string} value The value to send along with this transaction
115
+ */
116
+ value(value: string): void;
117
+ protected buildBase(data: string): TxData;
118
+ /**
119
+ * Set one of the owners of the multisig wallet.
120
+ *
121
+ * @param {string} address An Ethereum address
122
+ */
123
+ owner(address: string): void;
124
+ /**
125
+ * Build a transaction for a generic multisig contract.
126
+ *
127
+ * @returns {TxData} The Ethereum transaction data
128
+ */
129
+ protected buildWalletInitializationTransaction(walletVersion?: number): TxData;
130
+ /**
131
+ * Returns the smart contract encoded data
132
+ *
133
+ * @param {string[]} addresses - the contract signers
134
+ * @returns {string} - the smart contract encoded data
135
+ */
136
+ protected abstract getContractData(addresses: string[]): string;
137
+ contract(address: string): void;
138
+ /**
139
+ * Gets the transfer funds builder if exist, or creates a new one for this transaction and returns it
140
+ *
141
+ * @param [data] transfer data to initialize the transfer builder with, empty if none given
142
+ * @returns {TransferBuilder | ERC721TransferBuilder | ERC1155TransferBuilder} the transfer builder
143
+ */
144
+ abstract transfer(data?: string): TransferBuilder | ERC721TransferBuilder | ERC1155TransferBuilder;
145
+ /**
146
+ * Returns the serialized sendMultiSig contract method data
147
+ *
148
+ * @returns {string} serialized sendMultiSig data
149
+ */
150
+ private getSendData;
151
+ private buildSendTransaction;
152
+ /**
153
+ * Set the contract transaction nonce to calculate the forwarder address.
154
+ *
155
+ * @param {number} contractCounter The counter to use
156
+ */
157
+ contractCounter(contractCounter: number): void;
158
+ /**
159
+ * Build a transaction to create a forwarder.
160
+ *
161
+ * @returns {TxData} The Ethereum transaction data
162
+ */
163
+ private buildAddressInitializationTransaction;
164
+ /**
165
+ * Set the forwarder address to flush
166
+ *
167
+ * @param {string} address The address to flush
168
+ */
169
+ forwarderAddress(address: string): void;
170
+ /**
171
+ * Set the address of the ERC20 token contract that we are flushing tokens for
172
+ *
173
+ * @param {string} address the contract address of the token to flush
174
+ */
175
+ tokenAddress(address: string): void;
176
+ /**
177
+ * Build a transaction to flush tokens from a forwarder.
178
+ *
179
+ * @returns {TxData} The Ethereum transaction data
180
+ */
181
+ private buildFlushTokensTransaction;
182
+ /**
183
+ * Build a transaction to flush tokens from a forwarder.
184
+ *
185
+ * @returns {TxData} The Ethereum transaction data
186
+ */
187
+ private buildFlushCoinsTransaction;
188
+ data(encodedCall: string): void;
189
+ private buildGenericContractCallTransaction;
190
+ /** @inheritdoc */
191
+ protected get transaction(): Transaction;
192
+ /** @inheritdoc */
193
+ protected set transaction(transaction: Transaction);
194
+ /**
195
+ * Get the final v value. Final v is described in EIP-155.
196
+ *
197
+ * @protected for internal use when the enableFinalVField flag is true.
198
+ */
199
+ protected getFinalV(): string;
200
+ /**
201
+ * Set the forwarder version for address to be initialized
202
+ *
203
+ * @param {number} version forwarder version
204
+ */
205
+ forwarderVersion(version: number): void;
206
+ /**
207
+ * Set the salt to create the address using create2
208
+ *
209
+ * @param {string} salt The salt to create the address using create2, hex string
210
+ */
211
+ salt(salt: string): void;
212
+ /**
213
+ * Take the implementation address for the proxy contract, and get the binary initcode for the associated proxy
214
+ *
215
+ * @param {string} implementationAddress The address of the implementation contract
216
+ */
217
+ initCode(implementationAddress: string): void;
218
+ /**
219
+ * Set the wallet version for wallet to be initialized
220
+ *
221
+ * @param {number} version wallet version
222
+ */
223
+ walletVersion(version: number): void;
224
+ /**
225
+ * Set the base address of the wallet
226
+ *
227
+ * @param {string} address The wallet contract address
228
+ */
229
+ baseAddress(address: string): void;
230
+ }
231
+ //# sourceMappingURL=transactionBuilder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transactionBuilder.d.ts","sourceRoot":"","sources":["../../../src/lib/transactionBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,UAAU,EAAmB,MAAM,qBAAqB,CAAC;AAC9E,OAAO,cAAc,MAAM,oBAAoB,CAAC;AAEhD,OAAO,SAAS,MAAM,cAAc,CAAC;AAIrC,OAAO,EACL,WAAW,EACX,OAAO,EACP,eAAe,EACf,sBAAsB,EAOtB,eAAe,EAChB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAsB,GAAG,EAAkB,MAAM,EAAE,MAAM,SAAS,CAAC;AAmB1E,OAAO,EAAE,sBAAsB,EAAE,MAAM,2CAA2C,CAAC;AACnF,OAAO,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAC;AACjF,OAAO,EAA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