@bitgo/public-types 4.28.2 → 4.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.
@@ -1 +1,2 @@
1
1
  export * from "./sendTransactions";
2
+ export * from "./tronTransaction";
@@ -15,4 +15,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./sendTransactions"), exports);
18
+ __exportStar(require("./tronTransaction"), exports);
18
19
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/schema/transactions/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAAmC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/schema/transactions/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAAmC;AACnC,oDAAkC"}
@@ -0,0 +1,284 @@
1
+ import * as t from "io-ts";
2
+ export declare const TronResourceType: t.KeyofC<{
3
+ BANDWIDTH: number;
4
+ ENERGY: number;
5
+ }>;
6
+ export type TronResourceType = t.TypeOf<typeof TronResourceType>;
7
+ export declare const TronTransactionType: t.KeyofC<{
8
+ freeze: number;
9
+ unfreeze: number;
10
+ vote: number;
11
+ claimRewards: number;
12
+ delegateResource: number;
13
+ undelegateResource: number;
14
+ withdrawExpireUnfreeze: number;
15
+ }>;
16
+ export type TronTransactionType = t.TypeOf<typeof TronTransactionType>;
17
+ export declare const TronTransactionBase: t.TypeC<{
18
+ transactionType: t.KeyofC<{
19
+ freeze: number;
20
+ unfreeze: number;
21
+ vote: number;
22
+ claimRewards: number;
23
+ delegateResource: number;
24
+ undelegateResource: number;
25
+ withdrawExpireUnfreeze: number;
26
+ }>;
27
+ }>;
28
+ export declare const TronFreezeTransaction: t.IntersectionC<[t.TypeC<{
29
+ transactionType: t.KeyofC<{
30
+ freeze: number;
31
+ unfreeze: number;
32
+ vote: number;
33
+ claimRewards: number;
34
+ delegateResource: number;
35
+ undelegateResource: number;
36
+ withdrawExpireUnfreeze: number;
37
+ }>;
38
+ }>, t.TypeC<{
39
+ transactionType: t.LiteralC<"freeze">;
40
+ owner_address: t.StringC;
41
+ frozen_balance: t.StringC;
42
+ resource: t.KeyofC<{
43
+ BANDWIDTH: number;
44
+ ENERGY: number;
45
+ }>;
46
+ }>]>;
47
+ export declare const TronUnfreezeTransaction: t.IntersectionC<[t.TypeC<{
48
+ transactionType: t.KeyofC<{
49
+ freeze: number;
50
+ unfreeze: number;
51
+ vote: number;
52
+ claimRewards: number;
53
+ delegateResource: number;
54
+ undelegateResource: number;
55
+ withdrawExpireUnfreeze: number;
56
+ }>;
57
+ }>, t.TypeC<{
58
+ transactionType: t.LiteralC<"unfreeze">;
59
+ owner_address: t.StringC;
60
+ unfreeze_balance: t.StringC;
61
+ resource: t.KeyofC<{
62
+ BANDWIDTH: number;
63
+ ENERGY: number;
64
+ }>;
65
+ }>]>;
66
+ export declare const TronVoteTransaction: t.IntersectionC<[t.TypeC<{
67
+ transactionType: t.KeyofC<{
68
+ freeze: number;
69
+ unfreeze: number;
70
+ vote: number;
71
+ claimRewards: number;
72
+ delegateResource: number;
73
+ undelegateResource: number;
74
+ withdrawExpireUnfreeze: number;
75
+ }>;
76
+ }>, t.TypeC<{
77
+ transactionType: t.LiteralC<"vote">;
78
+ owner_address: t.StringC;
79
+ votes: t.ArrayC<t.TypeC<{
80
+ vote_address: t.StringC;
81
+ vote_count: t.StringC;
82
+ }>>;
83
+ }>]>;
84
+ export declare const TronDelegateResourceTransaction: t.IntersectionC<[t.TypeC<{
85
+ transactionType: t.KeyofC<{
86
+ freeze: number;
87
+ unfreeze: number;
88
+ vote: number;
89
+ claimRewards: number;
90
+ delegateResource: number;
91
+ undelegateResource: number;
92
+ withdrawExpireUnfreeze: number;
93
+ }>;
94
+ }>, t.TypeC<{
95
+ transactionType: t.LiteralC<"delegateResource">;
96
+ owner_address: t.StringC;
97
+ resource: t.KeyofC<{
98
+ BANDWIDTH: number;
99
+ ENERGY: number;
100
+ }>;
101
+ receiver_address: t.StringC;
102
+ balance: t.StringC;
103
+ }>, t.PartialC<{
104
+ lock: t.BooleanC;
105
+ lock_period: t.UnionC<[t.Type<number, number, unknown>, t.UndefinedC]>;
106
+ }>]>;
107
+ export declare const TronUndelegateResourceTransaction: t.IntersectionC<[t.TypeC<{
108
+ transactionType: t.KeyofC<{
109
+ freeze: number;
110
+ unfreeze: number;
111
+ vote: number;
112
+ claimRewards: number;
113
+ delegateResource: number;
114
+ undelegateResource: number;
115
+ withdrawExpireUnfreeze: number;
116
+ }>;
117
+ }>, t.TypeC<{
118
+ transactionType: t.LiteralC<"undelegateResource">;
119
+ owner_address: t.StringC;
120
+ resource: t.KeyofC<{
121
+ BANDWIDTH: number;
122
+ ENERGY: number;
123
+ }>;
124
+ receiver_address: t.StringC;
125
+ balance: t.StringC;
126
+ }>]>;
127
+ export declare const TronClaimRewardsTransaction: t.IntersectionC<[t.TypeC<{
128
+ transactionType: t.KeyofC<{
129
+ freeze: number;
130
+ unfreeze: number;
131
+ vote: number;
132
+ claimRewards: number;
133
+ delegateResource: number;
134
+ undelegateResource: number;
135
+ withdrawExpireUnfreeze: number;
136
+ }>;
137
+ }>, t.TypeC<{
138
+ transactionType: t.LiteralC<"claimRewards">;
139
+ owner_address: t.StringC;
140
+ }>]>;
141
+ export declare const TronWithdrawExpireUnfreezeTransaction: t.IntersectionC<[t.TypeC<{
142
+ transactionType: t.KeyofC<{
143
+ freeze: number;
144
+ unfreeze: number;
145
+ vote: number;
146
+ claimRewards: number;
147
+ delegateResource: number;
148
+ undelegateResource: number;
149
+ withdrawExpireUnfreeze: number;
150
+ }>;
151
+ }>, t.TypeC<{
152
+ transactionType: t.LiteralC<"withdrawExpireUnfreeze">;
153
+ owner_address: t.StringC;
154
+ }>]>;
155
+ export declare const TronTransaction: t.UnionC<[t.IntersectionC<[t.TypeC<{
156
+ transactionType: t.KeyofC<{
157
+ freeze: number;
158
+ unfreeze: number;
159
+ vote: number;
160
+ claimRewards: number;
161
+ delegateResource: number;
162
+ undelegateResource: number;
163
+ withdrawExpireUnfreeze: number;
164
+ }>;
165
+ }>, t.TypeC<{
166
+ transactionType: t.LiteralC<"freeze">;
167
+ owner_address: t.StringC;
168
+ frozen_balance: t.StringC;
169
+ resource: t.KeyofC<{
170
+ BANDWIDTH: number;
171
+ ENERGY: number;
172
+ }>;
173
+ }>]>, t.IntersectionC<[t.TypeC<{
174
+ transactionType: t.KeyofC<{
175
+ freeze: number;
176
+ unfreeze: number;
177
+ vote: number;
178
+ claimRewards: number;
179
+ delegateResource: number;
180
+ undelegateResource: number;
181
+ withdrawExpireUnfreeze: number;
182
+ }>;
183
+ }>, t.TypeC<{
184
+ transactionType: t.LiteralC<"unfreeze">;
185
+ owner_address: t.StringC;
186
+ unfreeze_balance: t.StringC;
187
+ resource: t.KeyofC<{
188
+ BANDWIDTH: number;
189
+ ENERGY: number;
190
+ }>;
191
+ }>]>, t.IntersectionC<[t.TypeC<{
192
+ transactionType: t.KeyofC<{
193
+ freeze: number;
194
+ unfreeze: number;
195
+ vote: number;
196
+ claimRewards: number;
197
+ delegateResource: number;
198
+ undelegateResource: number;
199
+ withdrawExpireUnfreeze: number;
200
+ }>;
201
+ }>, t.TypeC<{
202
+ transactionType: t.LiteralC<"vote">;
203
+ owner_address: t.StringC;
204
+ votes: t.ArrayC<t.TypeC<{
205
+ vote_address: t.StringC;
206
+ vote_count: t.StringC;
207
+ }>>;
208
+ }>]>, t.IntersectionC<[t.TypeC<{
209
+ transactionType: t.KeyofC<{
210
+ freeze: number;
211
+ unfreeze: number;
212
+ vote: number;
213
+ claimRewards: number;
214
+ delegateResource: number;
215
+ undelegateResource: number;
216
+ withdrawExpireUnfreeze: number;
217
+ }>;
218
+ }>, t.TypeC<{
219
+ transactionType: t.LiteralC<"delegateResource">;
220
+ owner_address: t.StringC;
221
+ resource: t.KeyofC<{
222
+ BANDWIDTH: number;
223
+ ENERGY: number;
224
+ }>;
225
+ receiver_address: t.StringC;
226
+ balance: t.StringC;
227
+ }>, t.PartialC<{
228
+ lock: t.BooleanC;
229
+ lock_period: t.UnionC<[t.Type<number, number, unknown>, t.UndefinedC]>;
230
+ }>]>, t.IntersectionC<[t.TypeC<{
231
+ transactionType: t.KeyofC<{
232
+ freeze: number;
233
+ unfreeze: number;
234
+ vote: number;
235
+ claimRewards: number;
236
+ delegateResource: number;
237
+ undelegateResource: number;
238
+ withdrawExpireUnfreeze: number;
239
+ }>;
240
+ }>, t.TypeC<{
241
+ transactionType: t.LiteralC<"undelegateResource">;
242
+ owner_address: t.StringC;
243
+ resource: t.KeyofC<{
244
+ BANDWIDTH: number;
245
+ ENERGY: number;
246
+ }>;
247
+ receiver_address: t.StringC;
248
+ balance: t.StringC;
249
+ }>]>, t.IntersectionC<[t.TypeC<{
250
+ transactionType: t.KeyofC<{
251
+ freeze: number;
252
+ unfreeze: number;
253
+ vote: number;
254
+ claimRewards: number;
255
+ delegateResource: number;
256
+ undelegateResource: number;
257
+ withdrawExpireUnfreeze: number;
258
+ }>;
259
+ }>, t.TypeC<{
260
+ transactionType: t.LiteralC<"claimRewards">;
261
+ owner_address: t.StringC;
262
+ }>]>, t.IntersectionC<[t.TypeC<{
263
+ transactionType: t.KeyofC<{
264
+ freeze: number;
265
+ unfreeze: number;
266
+ vote: number;
267
+ claimRewards: number;
268
+ delegateResource: number;
269
+ undelegateResource: number;
270
+ withdrawExpireUnfreeze: number;
271
+ }>;
272
+ }>, t.TypeC<{
273
+ transactionType: t.LiteralC<"withdrawExpireUnfreeze">;
274
+ owner_address: t.StringC;
275
+ }>]>]>;
276
+ export type TronTransactionBase = t.TypeOf<typeof TronTransactionBase>;
277
+ export type TronFreezeTransaction = t.TypeOf<typeof TronFreezeTransaction>;
278
+ export type TronUnfreezeTransaction = t.TypeOf<typeof TronUnfreezeTransaction>;
279
+ export type TronVoteTransaction = t.TypeOf<typeof TronVoteTransaction>;
280
+ export type TronDelegateResourceTransaction = t.TypeOf<typeof TronDelegateResourceTransaction>;
281
+ export type TronUndelegateResourceTransaction = t.TypeOf<typeof TronUndelegateResourceTransaction>;
282
+ export type TronClaimRewardsTransaction = t.TypeOf<typeof TronClaimRewardsTransaction>;
283
+ export type TronWithdrawExpireUnfreezeTransaction = t.TypeOf<typeof TronWithdrawExpireUnfreezeTransaction>;
284
+ export type TronTransaction = t.TypeOf<typeof TronTransaction>;
@@ -0,0 +1,121 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.TronTransaction = exports.TronWithdrawExpireUnfreezeTransaction = exports.TronClaimRewardsTransaction = exports.TronUndelegateResourceTransaction = exports.TronDelegateResourceTransaction = exports.TronVoteTransaction = exports.TronUnfreezeTransaction = exports.TronFreezeTransaction = exports.TronTransactionBase = exports.TronTransactionType = exports.TronResourceType = void 0;
27
+ const t = __importStar(require("io-ts"));
28
+ const utils_1 = require("../../utils");
29
+ exports.TronResourceType = t.keyof({
30
+ BANDWIDTH: 1,
31
+ ENERGY: 1,
32
+ });
33
+ exports.TronTransactionType = t.keyof({
34
+ freeze: 1,
35
+ unfreeze: 1,
36
+ vote: 1,
37
+ claimRewards: 1,
38
+ delegateResource: 1,
39
+ undelegateResource: 1,
40
+ withdrawExpireUnfreeze: 1,
41
+ });
42
+ exports.TronTransactionBase = t.type({
43
+ transactionType: exports.TronTransactionType,
44
+ });
45
+ exports.TronFreezeTransaction = t.intersection([
46
+ exports.TronTransactionBase,
47
+ t.type({
48
+ transactionType: t.literal("freeze"),
49
+ owner_address: t.string,
50
+ frozen_balance: t.string,
51
+ resource: exports.TronResourceType,
52
+ }),
53
+ ]);
54
+ exports.TronUnfreezeTransaction = t.intersection([
55
+ exports.TronTransactionBase,
56
+ t.type({
57
+ transactionType: t.literal("unfreeze"),
58
+ owner_address: t.string,
59
+ unfreeze_balance: t.string,
60
+ resource: exports.TronResourceType,
61
+ }),
62
+ ]);
63
+ exports.TronVoteTransaction = t.intersection([
64
+ exports.TronTransactionBase,
65
+ t.type({
66
+ transactionType: t.literal("vote"),
67
+ owner_address: t.string,
68
+ votes: t.array(t.type({
69
+ vote_address: t.string,
70
+ vote_count: t.string,
71
+ })),
72
+ }),
73
+ ]);
74
+ exports.TronDelegateResourceTransaction = t.intersection([
75
+ exports.TronTransactionBase,
76
+ t.type({
77
+ transactionType: t.literal("delegateResource"),
78
+ owner_address: t.string,
79
+ resource: exports.TronResourceType,
80
+ receiver_address: t.string,
81
+ balance: t.string,
82
+ }),
83
+ t.partial({
84
+ lock: t.boolean,
85
+ lock_period: utils_1.optionalNumber,
86
+ }),
87
+ ]);
88
+ exports.TronUndelegateResourceTransaction = t.intersection([
89
+ exports.TronTransactionBase,
90
+ t.type({
91
+ transactionType: t.literal("undelegateResource"),
92
+ owner_address: t.string,
93
+ resource: exports.TronResourceType,
94
+ receiver_address: t.string,
95
+ balance: t.string,
96
+ }),
97
+ ]);
98
+ exports.TronClaimRewardsTransaction = t.intersection([
99
+ exports.TronTransactionBase,
100
+ t.type({
101
+ transactionType: t.literal("claimRewards"),
102
+ owner_address: t.string,
103
+ }),
104
+ ]);
105
+ exports.TronWithdrawExpireUnfreezeTransaction = t.intersection([
106
+ exports.TronTransactionBase,
107
+ t.type({
108
+ transactionType: t.literal("withdrawExpireUnfreeze"),
109
+ owner_address: t.string,
110
+ }),
111
+ ]);
112
+ exports.TronTransaction = t.union([
113
+ exports.TronFreezeTransaction,
114
+ exports.TronUnfreezeTransaction,
115
+ exports.TronVoteTransaction,
116
+ exports.TronDelegateResourceTransaction,
117
+ exports.TronUndelegateResourceTransaction,
118
+ exports.TronClaimRewardsTransaction,
119
+ exports.TronWithdrawExpireUnfreezeTransaction,
120
+ ]);
121
+ //# sourceMappingURL=tronTransaction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tronTransaction.js","sourceRoot":"","sources":["../../../../src/schema/transactions/tronTransaction.ts"],"names":[],"mappings":"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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bitgo/public-types",
3
- "version": "4.28.2",
3
+ "version": "4.29.0",
4
4
  "description": "Collection of types exposed externally as part of the BitGo public API",
5
5
  "license": "UNLICENSED",
6
6
  "author": "",
@@ -1 +1,2 @@
1
1
  export * from "./sendTransactions";
2
+ export * from "./tronTransaction";
@@ -0,0 +1,127 @@
1
+ import * as t from "io-ts";
2
+ import { optionalNumber } from "../../utils";
3
+
4
+ export const TronResourceType = t.keyof({
5
+ BANDWIDTH: 1,
6
+ ENERGY: 1,
7
+ });
8
+ export type TronResourceType = t.TypeOf<typeof TronResourceType>;
9
+
10
+ export const TronTransactionType = t.keyof({
11
+ freeze: 1,
12
+ unfreeze: 1,
13
+ vote: 1,
14
+ claimRewards: 1,
15
+ delegateResource: 1,
16
+ undelegateResource: 1,
17
+ withdrawExpireUnfreeze: 1,
18
+ });
19
+ export type TronTransactionType = t.TypeOf<typeof TronTransactionType>;
20
+
21
+ export const TronTransactionBase = t.type({
22
+ transactionType: TronTransactionType,
23
+ });
24
+
25
+ export const TronFreezeTransaction = t.intersection([
26
+ TronTransactionBase,
27
+ t.type({
28
+ transactionType: t.literal("freeze"),
29
+ owner_address: t.string,
30
+ frozen_balance: t.string,
31
+ resource: TronResourceType,
32
+ }),
33
+ ]);
34
+
35
+ export const TronUnfreezeTransaction = t.intersection([
36
+ TronTransactionBase,
37
+ t.type({
38
+ transactionType: t.literal("unfreeze"),
39
+ owner_address: t.string,
40
+ unfreeze_balance: t.string,
41
+ resource: TronResourceType,
42
+ }),
43
+ ]);
44
+
45
+ export const TronVoteTransaction = t.intersection([
46
+ TronTransactionBase,
47
+ t.type({
48
+ transactionType: t.literal("vote"),
49
+ owner_address: t.string,
50
+ votes: t.array(
51
+ t.type({
52
+ vote_address: t.string,
53
+ vote_count: t.string,
54
+ }),
55
+ ),
56
+ }),
57
+ ]);
58
+
59
+ export const TronDelegateResourceTransaction = t.intersection([
60
+ TronTransactionBase,
61
+ t.type({
62
+ transactionType: t.literal("delegateResource"),
63
+ owner_address: t.string,
64
+ resource: TronResourceType,
65
+ receiver_address: t.string,
66
+ balance: t.string,
67
+ }),
68
+ t.partial({
69
+ lock: t.boolean,
70
+ lock_period: optionalNumber,
71
+ }),
72
+ ]);
73
+
74
+ export const TronUndelegateResourceTransaction = t.intersection([
75
+ TronTransactionBase,
76
+ t.type({
77
+ transactionType: t.literal("undelegateResource"),
78
+ owner_address: t.string,
79
+ resource: TronResourceType,
80
+ receiver_address: t.string,
81
+ balance: t.string,
82
+ }),
83
+ ]);
84
+
85
+ export const TronClaimRewardsTransaction = t.intersection([
86
+ TronTransactionBase,
87
+ t.type({
88
+ transactionType: t.literal("claimRewards"),
89
+ owner_address: t.string,
90
+ }),
91
+ ]);
92
+
93
+ export const TronWithdrawExpireUnfreezeTransaction = t.intersection([
94
+ TronTransactionBase,
95
+ t.type({
96
+ transactionType: t.literal("withdrawExpireUnfreeze"),
97
+ owner_address: t.string,
98
+ }),
99
+ ]);
100
+
101
+ export const TronTransaction = t.union([
102
+ TronFreezeTransaction,
103
+ TronUnfreezeTransaction,
104
+ TronVoteTransaction,
105
+ TronDelegateResourceTransaction,
106
+ TronUndelegateResourceTransaction,
107
+ TronClaimRewardsTransaction,
108
+ TronWithdrawExpireUnfreezeTransaction,
109
+ ]);
110
+
111
+ export type TronTransactionBase = t.TypeOf<typeof TronTransactionBase>;
112
+ export type TronFreezeTransaction = t.TypeOf<typeof TronFreezeTransaction>;
113
+ export type TronUnfreezeTransaction = t.TypeOf<typeof TronUnfreezeTransaction>;
114
+ export type TronVoteTransaction = t.TypeOf<typeof TronVoteTransaction>;
115
+ export type TronDelegateResourceTransaction = t.TypeOf<
116
+ typeof TronDelegateResourceTransaction
117
+ >;
118
+ export type TronUndelegateResourceTransaction = t.TypeOf<
119
+ typeof TronUndelegateResourceTransaction
120
+ >;
121
+ export type TronClaimRewardsTransaction = t.TypeOf<
122
+ typeof TronClaimRewardsTransaction
123
+ >;
124
+ export type TronWithdrawExpireUnfreezeTransaction = t.TypeOf<
125
+ typeof TronWithdrawExpireUnfreezeTransaction
126
+ >;
127
+ export type TronTransaction = t.TypeOf<typeof TronTransaction>;