@bitgo/account-lib 2.17.2-rc.8 → 2.18.0-rc.3

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 (77) hide show
  1. package/DEVELOPER.md +45 -18
  2. package/README.md +83 -48
  3. package/dist/browser/bitgo-account-lib.min.js +1 -1
  4. package/dist/package.json +6 -4
  5. package/dist/src/coin/baseCoin/ed25519KeyPair.d.ts +1 -1
  6. package/dist/src/coin/baseCoin/ed25519KeyPair.js +1 -1
  7. package/dist/src/coin/dot/addressInitializationBuilder.d.ts +3 -3
  8. package/dist/src/coin/dot/addressInitializationBuilder.js +1 -1
  9. package/dist/src/coin/dot/iface.d.ts +12 -5
  10. package/dist/src/coin/dot/iface.d.ts.map +1 -1
  11. package/dist/src/coin/dot/iface.js +15 -2
  12. package/dist/src/coin/dot/transferBuilder.d.ts +3 -3
  13. package/dist/src/coin/dot/transferBuilder.js +1 -1
  14. package/dist/src/coin/dot/utils.d.ts +8 -1
  15. package/dist/src/coin/dot/utils.d.ts.map +1 -1
  16. package/dist/src/coin/dot/utils.js +15 -6
  17. package/dist/src/coin/eth/transaction.js +2 -2
  18. package/dist/src/coin/eth/utils.d.ts +2 -2
  19. package/dist/src/coin/eth/utils.d.ts.map +1 -1
  20. package/dist/src/coin/eth/utils.js +3 -3
  21. package/dist/src/coin/sol/index.d.ts +3 -0
  22. package/dist/src/coin/sol/index.d.ts.map +1 -1
  23. package/dist/src/coin/sol/index.js +8 -2
  24. package/dist/src/coin/sol/keyPair.d.ts +4 -22
  25. package/dist/src/coin/sol/keyPair.d.ts.map +1 -1
  26. package/dist/src/coin/sol/keyPair.js +42 -89
  27. package/dist/src/coin/sol/transactionBuilder.d.ts.map +1 -1
  28. package/dist/src/coin/sol/transactionBuilder.js +8 -2
  29. package/dist/src/coin/sol/utils.d.ts.map +1 -1
  30. package/dist/src/coin/sol/utils.js +4 -7
  31. package/dist/src/coin/stx/abstractContractBuilder.d.ts +19 -0
  32. package/dist/src/coin/stx/abstractContractBuilder.d.ts.map +1 -0
  33. package/dist/src/coin/stx/abstractContractBuilder.js +140 -0
  34. package/dist/src/coin/stx/constants.d.ts +8 -0
  35. package/dist/src/coin/stx/constants.d.ts.map +1 -0
  36. package/dist/src/coin/stx/constants.js +19 -0
  37. package/dist/src/coin/stx/contractBuilder.d.ts +2 -11
  38. package/dist/src/coin/stx/contractBuilder.d.ts.map +1 -1
  39. package/dist/src/coin/stx/contractBuilder.js +14 -115
  40. package/dist/src/coin/stx/iface.d.ts +5 -0
  41. package/dist/src/coin/stx/iface.d.ts.map +1 -1
  42. package/dist/src/coin/stx/iface.js +1 -1
  43. package/dist/src/coin/stx/keyPair.d.ts.map +1 -1
  44. package/dist/src/coin/stx/keyPair.js +3 -3
  45. package/dist/src/coin/stx/sendmanyBuilder.d.ts +23 -0
  46. package/dist/src/coin/stx/sendmanyBuilder.d.ts.map +1 -0
  47. package/dist/src/coin/stx/sendmanyBuilder.js +140 -0
  48. package/dist/src/coin/stx/transaction.d.ts.map +1 -1
  49. package/dist/src/coin/stx/transaction.js +28 -15
  50. package/dist/src/coin/stx/transactionBuilder.d.ts +1 -1
  51. package/dist/src/coin/stx/transactionBuilder.d.ts.map +1 -1
  52. package/dist/src/coin/stx/transactionBuilder.js +6 -7
  53. package/dist/src/coin/stx/transactionBuilderFactory.d.ts +2 -0
  54. package/dist/src/coin/stx/transactionBuilderFactory.d.ts.map +1 -1
  55. package/dist/src/coin/stx/transactionBuilderFactory.js +8 -1
  56. package/dist/src/coin/stx/transferBuilder.d.ts +3 -3
  57. package/dist/src/coin/stx/transferBuilder.d.ts.map +1 -1
  58. package/dist/src/coin/stx/transferBuilder.js +2 -4
  59. package/dist/src/coin/stx/utils.d.ts +12 -5
  60. package/dist/src/coin/stx/utils.d.ts.map +1 -1
  61. package/dist/src/coin/stx/utils.js +32 -18
  62. package/dist/src/index.d.ts +2 -0
  63. package/dist/src/index.d.ts.map +1 -1
  64. package/dist/src/index.js +4 -2
  65. package/dist/src/mpc/curves.d.ts +14 -0
  66. package/dist/src/mpc/curves.d.ts.map +1 -0
  67. package/dist/src/mpc/curves.js +99 -0
  68. package/dist/src/mpc/shamir.d.ts +7 -0
  69. package/dist/src/mpc/shamir.d.ts.map +1 -0
  70. package/dist/src/mpc/shamir.js +91 -0
  71. package/dist/src/mpc/tss.d.ts +69 -0
  72. package/dist/src/mpc/tss.d.ts.map +1 -0
  73. package/dist/src/mpc/tss.js +255 -0
  74. package/dist/src/utils/ed25519KeyDeriver.d.ts +49 -0
  75. package/dist/src/utils/ed25519KeyDeriver.d.ts.map +1 -0
  76. package/dist/src/utils/ed25519KeyDeriver.js +92 -0
  77. package/package.json +6 -4
package/DEVELOPER.md CHANGED
@@ -1,20 +1,26 @@
1
1
  # Developer Guide
2
- Thanks for contributing to this library. Below are some tips to help you understand:
3
- * the structure of the project
4
- * the important classes and how they are used
5
- * how to run the test suite
6
- * how to contribute to the project
7
2
 
8
- ## Project Architecture
3
+ Thanks for contributing to this library. Below are some tips to help you
4
+ understand:
5
+
6
+ - the structure of the project
7
+ - the important classes and how they are used
8
+ - how to run the test suite
9
+ - how to contribute to the project
9
10
 
11
+ ## Project Architecture
10
12
 
11
13
  ### Base Classes
12
- As specified in [the project README](README.md), there are two main classes that users will interact with:
13
14
 
14
- * `TransactionBuilder`: A class that implements coin specific logic to handle the construction, validation, and signing of blockchain transactions.
15
- * `Transaction`: Javascript representations of blockchain transactions.
15
+ As specified in [the project README](README.md), there are two main classes that
16
+ users will interact with:
16
17
 
17
- The `TransactionBuilder`'s job is to build + sign `transactions` for a specific blockchain.
18
+ - `TransactionBuilder`: A class that implements coin specific logic to handle
19
+ the construction, validation, and signing of blockchain transactions.
20
+ - `Transaction`: JavaScript representations of blockchain transactions.
21
+
22
+ The `TransactionBuilder`'s job is to build and sign `transactions` for a
23
+ specific blockchain.
18
24
 
19
25
  The flow typically looks something like:
20
26
 
@@ -39,20 +45,35 @@ const signedTxJson = tx.toJson();
39
45
  ```
40
46
 
41
47
  ### Coin Specific Implementations
42
- If you have spent time poking around the project, you likely noticed that we have base `TransactionBuilder` and base `Transaction` classes - they live in `src/coin/baseCoin`. These classes define the core interfaces that all subclasses will extend and implement.
43
48
 
44
- Coin specific implementations of the `TransactionBuilder` and `Transaction` classes live under the coin's ticker symbol in `src/coin` (ie: `src/coin/trx` for Tron). This is where the meat of the signing, validation, and encoding logic lives for each blockchain supported by the library.
49
+ If you have spent time poking around the project, you likely noticed that we
50
+ have base `TransactionBuilder` and base `Transaction` classes - they live in
51
+ `src/coin/baseCoin`. These classes define the core interfaces that all
52
+ subclasses will extend and implement.
53
+
54
+ Coin specific implementations of the `TransactionBuilder` and `Transaction`
55
+ classes live under the coin's ticker symbol in `src/coin` (ie: `src/coin/trx`
56
+ for Tron). This is where the meat of the signing, validation, and encoding logic
57
+ lives for each blockchain supported by the library.
45
58
 
46
- It is recommended to follow this pattern when adding a new coin to the library.
59
+ We recommend that you follow this pattern when adding a new coin to the library:
47
60
 
48
61
  ### Test Structure
49
- This library comes with unit tests and it is expected that all changes introduced to the library increase test coverage. Tests live in `test`. Coin specific tests live in `test/unit/coin/<coin-ticker>/<coin-ticker.js>`.
50
62
 
63
+ Account Lib comes with unit tests and it is expected that all changes introduced
64
+ to the library increase test coverage. Tests live in `test`. Coin specific tests
65
+ live in `test/unit/coin/<coin-ticker>/<coin-ticker.js>`.
51
66
 
52
67
  ## (External) Resources
53
- There are situations in which this library requires upstream dependencies, but we don't want to pull in the entire library in order to use the tiny slice of functionality that we require. In these cases, we take snippets of that external code and stick them in `resources/`. See [the README in that directory for more information](resources/README.md).
68
+
69
+ There are situations in which this library requires upstream dependencies, but
70
+ you might not want to pull in the entire library only to use the tiny slice of
71
+ functionality that we require. Rather, you can take snippets of the external
72
+ code and stick them in `resources/`. See
73
+ [the README in that directory for more information](resources/README.md).
54
74
 
55
75
  ## Running Tests
76
+
56
77
  To run the test suite locally:
57
78
 
58
79
  ```
@@ -60,7 +81,13 @@ npm test
60
81
  ```
61
82
 
62
83
  ## Coding Norms & Expectations
63
- When contributing, it is recommended that you follow the existing patterns defined in the project. Pull requests that break these norms will likely be rejected or require a round of feedback. A few specific notes:
64
84
 
65
- - Do not specify default accessors. In Typescript, the default accessor for a class attribute is
66
- `public`, so specifying it for functions and attributes is redundant.
85
+ When contributing, we recommend that you follow the existing patterns defined in
86
+ the project. Pull requests that break these norms will likely be rejected or
87
+ require a round of feedback.
88
+
89
+ Take note:
90
+
91
+ > Do not specify default accessors. In TypeScript, the default accessor for a
92
+ > class attribute is `public`, so specifying it for functions and attributes is
93
+ > redundant.
package/README.md CHANGED
@@ -1,50 +1,72 @@
1
1
  # BitGo Account Lib
2
2
 
3
- This library is responsible for building and signing transactions for account-based coins (ie: coins such as Ethereum, Algorand, EOS, Tron, etc.). This library is used by BitGo and our multi-sig wallets, however, it can be used independently, outside of our wallet ecosystem.
3
+ This library is responsible for building and signing transactions for
4
+ account-based coins (for example, Ethereum, Algorand, EOS, Tron, etc.). Account
5
+ Lib was developed for BitGo and BitGo's multi-sig wallets, but it can also be
6
+ used independently, outside of our wallet ecosystem.
7
+
8
+ > Account Lib can be used in an offline environment.
4
9
 
5
10
  ## Supported Coins
6
- Below is the list of coins supported by this library -- as well as those that are on the roadmap.
7
-
8
- |Coin|Mainnet Ticker|Testnet Ticker|Supported In Library|
9
- |---|---|---|---|
10
- |Tron|trx|ttrx|Yes|
11
- |Tezos|xtz|txtz|Yes|
12
- |Ethereum|eth|teth|Yes|
13
- |CELO|celo|tcelo|Yes|
14
- |Ethereum Classic|etc|tetc|Yes|
15
- |RSK|rbtc|trbtc|Yes|
16
- |EOS|eos|teos|Not yet...|
17
- |Alogrand|algo|talgo|Not yet...|
18
- |Ripple|xrp|txrp|Not yet...|
19
- |Stellar|xlm|txlm|Not yet...|
11
+
12
+ Below is the list of coins supported by this library -- as well as those that
13
+ are on the roadmap.
14
+
15
+ | Coin | Mainnet Ticker | Testnet Ticker | Supported In Library |
16
+ | :--------------- | :------------- | :------------- | :------------------- |
17
+ | Tron | trx | ttrx | Yes |
18
+ | Tezos | xtz | txtz | Yes |
19
+ | Ethereum | eth | teth | Yes |
20
+ | CELO | celo | tcelo | Yes |
21
+ | Ethereum Classic | etc | tetc | Yes |
22
+ | RSK | rbtc | trbtc | Yes |
23
+ | EOS | eos | teos | Not yet... |
24
+ | Alogrand | algo | talgo | Not yet... |
25
+ | Ripple | xrp | txrp | Not yet... |
26
+ | Stellar | xlm | txlm | Not yet... |
20
27
 
21
28
  ## Core Concepts
22
29
 
23
30
  ### TransactionBuilder
24
- The `TranssactionBuilder` class guides a user through the construction of a transaction. The purpose of the `TransactionBuilder` is to yield `Transaction` object that is able to be broadcast to the network.
31
+
32
+ The `TranssactionBuilder` class guides a user through the construction of a
33
+ transaction. The purpose of the `TransactionBuilder` is to yield a `Transaction`
34
+ object that can broadcast to the network.
25
35
 
26
36
  ### Transaction
27
- `Transaction` objects are javascript representations of blockchain transactions that implement protocol specific validation rules. `Transactions` provide encoding mechanisms that allow them to be validly broadcast to their respective network.
37
+
38
+ `Transaction` objects are JavaScript representations of blockchain transactions
39
+ that implement protocol specific validation rules. `Transactions` provide
40
+ encoding mechanisms that allow them to be validly broadcast to their respective
41
+ network.
28
42
 
29
43
  #### Transaction Types
30
- The `TransactionBuilder` supports 3 types types of transactions
31
- ##### Send
32
- Transfers funds from a wallet
33
- ##### Wallet Initialization
34
- Initializes a wallet's account on the network (e.g. Multi-sig contract deployment)
35
- ##### Address Initialization
36
- Initializes a wallet's address on the network (e.g. Forwarder contract deployment)
37
- ##### Account Update
38
- Updates an account on the network (e.g. Public key revelation operation for Tezos)
44
+
45
+ `TransactionBuilder` supports the following transaction types:
46
+
47
+ - **Send**: Transfers funds from a wallet.
48
+
49
+ - **Wallet Initialization**: Initializes a wallet's account on the network
50
+ (e.g., multi-sig contract deployment).
51
+
52
+ - **Address Initialization**: Initializes a wallet's address on the network
53
+ (e.g., forwarder contract deployment).
54
+
55
+ - **Account Update**: Updates an account on the network (e.g., public key
56
+ revelation operation for Tezos).
39
57
 
40
58
  ### Offline Availability
41
- The intention is that this library can be used in an offline environment, for offline signings.
59
+
60
+ Account Lib was designed to be used for offline signings in an offline
61
+ environment.
42
62
 
43
63
  ---
44
64
 
45
65
  ## Installation
46
66
 
47
- Install the library via npm. If you plan on contributing to the project, you may wish to follow different installation instructions [outlined in this doc](DEVELOPER.md).
67
+ Install the library with npm. If you plan on contributing to the project, you
68
+ may wish to follow different installation instructions
69
+ [outlined in this doc](DEVELOPER.md).
48
70
 
49
71
  ```
50
72
  $ cd <your_project>
@@ -52,10 +74,13 @@ $ npm install @bitgo/account-lib
52
74
  ```
53
75
 
54
76
  ## Usage
55
- Below is an example that demonstrates how the library can be used to build and sign a Tron testnet transaction.
77
+
78
+ Below is an example that demonstrates how the library can be used to build and
79
+ sign a Tron testnet transaction.
56
80
 
57
81
  ### Instantiation
58
- Instantiate the `TransactionBuilder` for the coin you want to work sign with:
82
+
83
+ Instantiate the `TransactionBuilder` for the coin you want to work with:
59
84
 
60
85
  ```javascript
61
86
  // Import the package (javascript import)
@@ -67,8 +92,10 @@ import * as accountLib from '@bitgo/account-lib';
67
92
  const txBuilder = accountLib.getBuilder('ttrx');
68
93
  ```
69
94
 
70
- ### Transaction Construction + Signing
71
- Use that transaction builder instance to sign a transaction:
95
+ ### Transaction Construction and Signing
96
+
97
+ Use the transaction builder instance (created in the previous step) to sign a
98
+ transaction:
72
99
 
73
100
  ```javascript
74
101
  // Define an unsigned Tron transaction object
@@ -76,38 +103,46 @@ const unsignedBuildTransaction = {
76
103
  visible: false,
77
104
  txID: '80b8b9eaed51c8bba3b49f7f0e7cc5f21ac99a6f3e2893c663b544bf2c695b1d',
78
105
  raw_data: {
79
- contract: [ {
80
- parameter: {
81
- value: {
82
- amount: 1718,
83
- owner_address: '41c4530f6bfa902b7398ac773da56106a15af15f92',
84
- to_address: '4189ffaf9da8c6fae32189b2e6dce228249b1129aa'
106
+ contract: [
107
+ {
108
+ parameter: {
109
+ value: {
110
+ amount: 1718,
111
+ owner_address: '41c4530f6bfa902b7398ac773da56106a15af15f92',
112
+ to_address: '4189ffaf9da8c6fae32189b2e6dce228249b1129aa',
113
+ },
114
+ type_url: 'type.googleapis.com/protocol.TransferContract',
85
115
  },
86
- type_url: 'type.googleapis.com/protocol.TransferContract'
116
+ type: 'TransferContract',
87
117
  },
88
- type: 'TransferContract'
89
- } ],
118
+ ],
90
119
  ref_block_bytes: '90e4',
91
120
  ref_block_hash: 'a018bf9892ddb138',
92
121
  expiration: 1571811468000,
93
- timestamp: 1571811410819
122
+ timestamp: 1571811410819,
94
123
  },
95
- raw_data_hex: '0a0290e42208a018bf9892ddb13840e0c58ebadf2d5a66080112620a2d747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e5472616e73666572436f6e747261637412310a1541c4530f6bfa902b7398ac773da56106a15af15f9212154189ffaf9da8c6fae32189b2e6dce228249b1129aa18b60d7083878bbadf2d',
124
+ raw_data_hex:
125
+ '0a0290e42208a018bf9892ddb13840e0c58ebadf2d5a66080112620a2d747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e5472616e73666572436f6e747261637412310a1541c4530f6bfa902b7398ac773da56106a15af15f9212154189ffaf9da8c6fae32189b2e6dce228249b1129aa18b60d7083878bbadf2d',
96
126
  };
97
127
 
98
128
  // Use that object to build and sign a transaction
99
129
  txBuilder.from(unsignedBuildTransaction);
100
130
  txBuilder.sign({
101
- key: 'A81B2E0C55A7E2B2E837ZZC437A6397B316536196989A6F09EE49C19AD33590W'
131
+ key: 'A81B2E0C55A7E2B2E837ZZC437A6397B316536196989A6F09EE49C19AD33590W',
102
132
  });
103
133
  const tx = await txBuilder.build();
104
134
  ```
105
135
 
106
136
  More examples:
107
- * [Tron transaction building examples](https://github.com/BitGo/bitgo-account-lib/blob/master/test/unit/coin/trx/transactionBuilder.ts)
108
- * [Tezos transaction building examples](https://github.com/BitGo/bitgo-account-lib/blob/master/test/unit/coin/xtz/transactionBuilder.ts)
137
+
138
+ - [Tron transaction building examples](https://github.com/BitGo/bitgo-account-lib/blob/master/test/unit/coin/trx/transactionBuilder.ts)
139
+ - [Tezos transaction building examples](https://github.com/BitGo/bitgo-account-lib/blob/master/test/unit/coin/xtz/transactionBuilder.ts)
109
140
 
110
141
  ## Developers
111
- If you'd like to contribute to this project, see the [developer guide](DEVELOPER.md) for contribution norms and expectations.
112
142
 
113
- Note that there is a near-term goal to move this library towards a plugin-based architecture for coin registration. Until this library gets there (and this note is removed), PRs adding support for new coins will be put on hold.
143
+ If you'd like to contribute to this project, see the
144
+ [developer guide](DEVELOPER.md) for contribution norms and expectations.
145
+
146
+ There is a near-term goal to move this library toward a plugin-based
147
+ architecture for coin registration. Until then, PRs adding support for new coins
148
+ will be put on hold.