@bitgo/public-types 5.28.0 → 5.29.0

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 (74) hide show
  1. package/README.md +1 -5
  2. package/dist/src/schema/enterprise/enterpriseIdString.d.ts +3 -0
  3. package/dist/src/schema/enterprise/enterpriseIdString.js +29 -0
  4. package/dist/src/schema/enterprise/enterpriseIdString.js.map +1 -0
  5. package/dist/src/schema/enterprise/index.d.ts +1 -0
  6. package/dist/src/schema/enterprise/index.js +18 -0
  7. package/dist/src/schema/enterprise/index.js.map +1 -0
  8. package/dist/src/schema/index.d.ts +1 -0
  9. package/dist/src/schema/index.js +1 -0
  10. package/dist/src/schema/index.js.map +1 -1
  11. package/dist/src/schema/transactionRequest/baseShare.d.ts +14 -0
  12. package/dist/src/schema/transactionRequest/baseShare.js +34 -0
  13. package/dist/src/schema/transactionRequest/baseShare.js.map +1 -0
  14. package/dist/src/schema/transactionRequest/commitmentShare.d.ts +17 -0
  15. package/dist/src/schema/transactionRequest/commitmentShare.js +35 -0
  16. package/dist/src/schema/transactionRequest/commitmentShare.js.map +1 -0
  17. package/dist/src/schema/transactionRequest/encryptedShare.d.ts +20 -0
  18. package/dist/src/schema/transactionRequest/encryptedShare.js +34 -0
  19. package/dist/src/schema/transactionRequest/encryptedShare.js.map +1 -0
  20. package/dist/src/schema/transactionRequest/index.d.ts +7 -0
  21. package/dist/src/schema/transactionRequest/index.js +7 -0
  22. package/dist/src/schema/transactionRequest/index.js.map +1 -1
  23. package/dist/src/schema/transactionRequest/message.d.ts +100 -0
  24. package/dist/src/schema/transactionRequest/message.js +56 -0
  25. package/dist/src/schema/transactionRequest/message.js.map +1 -0
  26. package/dist/src/schema/transactionRequest/shareType.d.ts +6 -0
  27. package/dist/src/schema/transactionRequest/shareType.js +32 -0
  28. package/dist/src/schema/transactionRequest/shareType.js.map +1 -0
  29. package/dist/src/schema/transactionRequest/signatureShare.d.ts +33 -0
  30. package/dist/src/schema/transactionRequest/signatureShare.js +42 -0
  31. package/dist/src/schema/transactionRequest/signatureShare.js.map +1 -0
  32. package/dist/src/schema/transactionRequest/signatureShareType.d.ts +7 -0
  33. package/dist/src/schema/transactionRequest/signatureShareType.js +33 -0
  34. package/dist/src/schema/transactionRequest/signatureShareType.js.map +1 -0
  35. package/dist/src/schema/transactionRequest/transaction.d.ts +105 -0
  36. package/dist/src/schema/transactionRequest/transaction.js +46 -0
  37. package/dist/src/schema/transactionRequest/transaction.js.map +1 -0
  38. package/dist/src/schema/transactionRequest/transactionRequest.d.ts +13532 -0
  39. package/dist/src/schema/transactionRequest/transactionRequest.js +87 -0
  40. package/dist/src/schema/transactionRequest/transactionRequest.js.map +1 -0
  41. package/dist/src/schema/transactionRequest/transactionRequestApiVersion.d.ts +6 -0
  42. package/dist/src/schema/transactionRequest/transactionRequestApiVersion.js +32 -0
  43. package/dist/src/schema/transactionRequest/transactionRequestApiVersion.js.map +1 -0
  44. package/dist/src/schema/transactionRequest/unsignedTransaction.d.ts +51 -0
  45. package/dist/src/schema/transactionRequest/unsignedTransaction.js +95 -0
  46. package/dist/src/schema/transactionRequest/unsignedTransaction.js.map +1 -0
  47. package/dist/src/schema/wallet/index.d.ts +1 -0
  48. package/dist/src/schema/wallet/index.js +1 -0
  49. package/dist/src/schema/wallet/index.js.map +1 -1
  50. package/dist/src/schema/wallet/wallet.d.ts +2 -0
  51. package/dist/src/schema/wallet/wallet.js +2 -1
  52. package/dist/src/schema/wallet/wallet.js.map +1 -1
  53. package/dist/src/schema/wallet/walletTypes.d.ts +11 -0
  54. package/dist/src/schema/wallet/walletTypes.js +37 -0
  55. package/dist/src/schema/wallet/walletTypes.js.map +1 -0
  56. package/package.json +1 -1
  57. package/src/schema/enterprise/enterpriseIdString.ts +9 -0
  58. package/src/schema/enterprise/index.ts +1 -0
  59. package/src/schema/index.ts +1 -0
  60. package/src/schema/transactionRequest/baseShare.ts +17 -0
  61. package/src/schema/transactionRequest/commitmentShare.ts +12 -0
  62. package/src/schema/transactionRequest/encryptedShare.ts +10 -0
  63. package/src/schema/transactionRequest/index.ts +7 -0
  64. package/src/schema/transactionRequest/message.ts +104 -0
  65. package/src/schema/transactionRequest/shareType.ts +10 -0
  66. package/src/schema/transactionRequest/signatureShare.ts +29 -0
  67. package/src/schema/transactionRequest/signatureShareType.ts +11 -0
  68. package/src/schema/transactionRequest/transaction.ts +24 -0
  69. package/src/schema/transactionRequest/transactionRequest.ts +118 -0
  70. package/src/schema/transactionRequest/transactionRequestApiVersion.ts +12 -0
  71. package/src/schema/transactionRequest/unsignedTransaction.ts +77 -0
  72. package/src/schema/wallet/index.ts +1 -0
  73. package/src/schema/wallet/wallet.ts +7 -0
  74. package/src/schema/wallet/walletTypes.ts +16 -0
@@ -0,0 +1,118 @@
1
+ import * as t from "io-ts";
2
+ import { DateFromISOString, NonEmptyString } from "io-ts-types";
3
+ import { WalletIdString } from "../wallet";
4
+ import { WalletTypes } from "../wallet/walletTypes";
5
+ import { EnterpriseIdString } from "../enterprise";
6
+ import { TransactionIntent, TransactionRequestState } from ".";
7
+ import { TransactionRequestApiVersion } from "./transactionRequestApiVersion";
8
+ import { CommitmentShare } from "./commitmentShare";
9
+ import { SignatureShare } from "./signatureShare";
10
+ import { UnsignedTransaction } from "./unsignedTransaction";
11
+ import { Message } from "./message";
12
+ import { Transaction } from "./transaction";
13
+
14
+ /**
15
+ * @format uuid
16
+ * @example 123e4567-e89b-12d3-a456-426614174000
17
+ */
18
+ export const TransactionRequestId = t.string;
19
+
20
+ export type TransactionRequestId = t.TypeOf<typeof TransactionRequestId>;
21
+
22
+ /**
23
+ * @format uuid
24
+ * @example 123e4567-e89b-12d3-a456-426614174000
25
+ */
26
+ export const TransactionRequestIdNonEmptyString = NonEmptyString; // Could also be UUID from io-ts-types if the team had complete confidence in the shape of all txRequestIds
27
+
28
+ export type TransactionRequestIdNonEmptyString = t.TypeOf<
29
+ typeof TransactionRequestIdNonEmptyString
30
+ >;
31
+
32
+ export const TransactionRequestBase = t.intersection([
33
+ // Required fields
34
+ t.type({
35
+ /** A unique ID for the TxRequest document across all wallets. The combination of the txRequestId and version will always be unique. */
36
+ txRequestId: TransactionRequestId,
37
+ /** The id of the Wallet the TxRequest is for. */
38
+ walletId: WalletIdString,
39
+ /** The version of the transaction request */
40
+ version: t.number,
41
+ /** The state of the transaction request */
42
+ state: TransactionRequestState,
43
+ /**
44
+ * The date and time this version of the TxRequest document was created.
45
+ * @example 2021-01-01T00:00:00Z
46
+ */
47
+ date: DateFromISOString,
48
+ /**
49
+ * The date and time the version 1 TxRequest document was created.
50
+ * @example 2021-01-01T00:00:00Z
51
+ */
52
+ createdDate: DateFromISOString,
53
+ /** The Id of the User that produced this version of the TxRequest document. Could have created a new document or updated an existing document. */
54
+ userId: t.string,
55
+ /** The Id of the User that originally created the TxRequest document (initiated the TxRequest). */
56
+ initiatedBy: t.string,
57
+ /** The Id of the User that last updated the TxRequest document. This is an alias for the userId field. */
58
+ updatedBy: t.string,
59
+ /** The intents of the transaction request */
60
+ intents: t.array(t.unknown),
61
+ /** Indicates if this is the latest transaction request */
62
+ latest: t.boolean,
63
+ }),
64
+ // Optional fields
65
+ t.partial({
66
+ /** The API version of the transaction request */
67
+ apiVersion: TransactionRequestApiVersion,
68
+ /** The idempotency key of the transaction request */
69
+ idempotencyKey: t.string,
70
+ /** The type describes who owns the keys to the wallet associated to the TxRequest. */
71
+ walletType: WalletTypes,
72
+ /** If the wallet that owns the TxRequest is owned by an enterprise then this is the Id of said enterprise. */
73
+ enterpriseId: EnterpriseIdString,
74
+ /** The intent of the transaction request */
75
+ intent: t.unknown,
76
+ /** The id of the Pending Approval that was created for the TxRequest if one was required. */
77
+ pendingApprovalId: t.string,
78
+ /** Indicates if the transaction request has been checked against the policies. */
79
+ policiesChecked: t.boolean,
80
+ /** True, if the transaction request is canceled. */
81
+ isCanceled: t.boolean,
82
+ }),
83
+ ]);
84
+
85
+ export const TransactionRequestLite = t.intersection([
86
+ TransactionRequestBase,
87
+ t.partial({
88
+ /** The intent of the transaction request */
89
+ intent: t.union([TransactionIntent, t.unknown]),
90
+ /** Holds all unsigned transactions that will be used to fulfill the TxRequest for MPC wallets. */
91
+ unsignedTxs: t.array(UnsignedTransaction),
92
+ /** Only used for MPC coins. This is used to collect signature shares from and exchange them with the user. */
93
+ signatureShares: t.array(SignatureShare),
94
+ /**Only used for MPC coins on EdDSA curve. This is used to collect commitment shares from and exchange them with the user. */
95
+ commitmentShares: t.array(CommitmentShare),
96
+ /** The hashes of all transactions from the TxRequest that have been signed and are pending broadcast. */
97
+ txHashes: t.array(t.string),
98
+ }),
99
+ ]);
100
+ export type TransactionRequestLite = t.TypeOf<typeof TransactionRequestLite>;
101
+
102
+ export const TransactionRequestFull = t.intersection([
103
+ TransactionRequestBase,
104
+ t.partial({
105
+ /** The transactions associated with the transaction request */
106
+ transactions: t.array(Transaction),
107
+ /** The messages associated with the transaction request */
108
+ messages: t.array(Message),
109
+ }),
110
+ ]);
111
+ export type TransactionRequestFull = t.TypeOf<typeof TransactionRequestFull>;
112
+
113
+ export const TransactionRequest = t.union([
114
+ TransactionRequestLite,
115
+ TransactionRequestFull,
116
+ ]);
117
+
118
+ export type TransactionRequest = t.TypeOf<typeof TransactionRequest>;
@@ -0,0 +1,12 @@
1
+ import * as t from "io-ts";
2
+
3
+ export const TransactionRequestApiVersion = t.keyof(
4
+ {
5
+ lite: 1,
6
+ full: 1,
7
+ },
8
+ "TransactionRequestApiVersion",
9
+ );
10
+ export type TransactionRequestApiVersion = t.TypeOf<
11
+ typeof TransactionRequestApiVersion
12
+ >;
@@ -0,0 +1,77 @@
1
+ import * as t from "io-ts";
2
+
3
+ const Input = t.intersection([
4
+ t.type({
5
+ valueString: t.string,
6
+ }),
7
+ t.partial({
8
+ _id: t.string,
9
+ address: t.string,
10
+ chain: t.number,
11
+ derivationIndex: t.number,
12
+ index: t.number,
13
+ value: t.union([t.number, t.bigint]),
14
+ }),
15
+ ]);
16
+
17
+ const Output = t.intersection([
18
+ t.type({
19
+ valueString: t.string,
20
+ }),
21
+ t.partial({
22
+ address: t.string,
23
+ change: t.boolean,
24
+ coinName: t.string,
25
+ data: t.string,
26
+ isPayGo: t.boolean,
27
+ value: t.union([t.number, t.bigint]),
28
+ wallet: t.string,
29
+ walletV1: t.string,
30
+ baseAddress: t.string,
31
+ enterprise: t.string,
32
+ }),
33
+ ]);
34
+
35
+ const ParsedTx = t.intersection([
36
+ t.type({
37
+ inputs: t.array(Input),
38
+ minerFee: t.union([t.string, t.number]),
39
+ outputs: t.array(Output),
40
+ spendAmount: t.union([t.string, t.number]),
41
+ }),
42
+ t.partial({
43
+ gasPrice: t.number,
44
+ hasUnvalidatedData: t.boolean,
45
+ payGoFee: t.union([t.string, t.number]),
46
+ spendAmounts: t.array(t.UnknownRecord),
47
+ type: t.string,
48
+ }),
49
+ ]);
50
+
51
+ export const UnsignedTransaction = t.intersection([
52
+ t.type({
53
+ parsedTx: ParsedTx,
54
+ /** The unsigned transaction as a hex string. */
55
+ serializedTxHex: t.string,
56
+ /** The portion of a transaction used to generate a signature (may or may not be the same as serializedTxHex) as a hex string. */
57
+ signableHex: t.string,
58
+ }),
59
+ t.partial({
60
+ /** A bip32 path. */
61
+ derivationPath: t.string,
62
+ /** Coin specific information. */
63
+ coinSpecific: t.intersection([
64
+ t.UnknownRecord,
65
+ t.partial({
66
+ nonceAddress: t.string,
67
+ stakingAddress: t.string,
68
+ signature: t.string,
69
+ }),
70
+ ]),
71
+ feeInfo: t.type({
72
+ fee: t.union([t.string, t.number]),
73
+ feeString: t.string,
74
+ }),
75
+ }),
76
+ ]);
77
+ export type UnsignedTransaction = t.TypeOf<typeof UnsignedTransaction>;
@@ -1,2 +1,3 @@
1
1
  export * from "./wallet";
2
2
  export * from "./multisigTypeVersion";
3
+ export * from "./walletTypes";
@@ -1,5 +1,12 @@
1
1
  import * as t from "io-ts";
2
2
 
3
+ /**
4
+ * @example 59cd72485007a239fb00282ed480da1f
5
+ * @pattern ^[0-9a-f]{32}$
6
+ */
7
+ export const WalletIdString = t.string;
8
+ export type WalletIdString = t.TypeOf<typeof WalletIdString>;
9
+
3
10
  export const WalletUser = t.type({
4
11
  user: t.string,
5
12
  permissions: t.array(t.string),
@@ -0,0 +1,16 @@
1
+ import * as t from "io-ts";
2
+
3
+ export const WalletTypes = t.keyof(
4
+ {
5
+ backing: 1,
6
+ cold: 1,
7
+ custodial: 1,
8
+ custodialPaired: 1,
9
+ hot: 1,
10
+ advanced: 1,
11
+ trading: 1,
12
+ },
13
+ "WalletTypes",
14
+ );
15
+
16
+ export type WalletTypes = t.TypeOf<typeof WalletTypes>;