@apibara/starknet 0.1.1 → 0.2.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 (48) hide show
  1. package/dist/cursor.d.ts +19 -0
  2. package/dist/cursor.js +30 -0
  3. package/dist/cursor.js.map +1 -0
  4. package/dist/felt.d.ts +19 -0
  5. package/dist/felt.js +60 -0
  6. package/dist/felt.js.map +1 -0
  7. package/dist/felt.test.d.ts +1 -0
  8. package/dist/felt.test.js +22 -0
  9. package/dist/felt.test.js.map +1 -0
  10. package/dist/filter.d.ts +285 -0
  11. package/dist/filter.js +490 -0
  12. package/dist/filter.js.map +1 -0
  13. package/dist/filter.test.d.ts +1 -0
  14. package/dist/filter.test.js +54 -0
  15. package/dist/filter.test.js.map +1 -0
  16. package/dist/index.d.ts +4 -1
  17. package/dist/index.js +18 -18
  18. package/dist/index.js.map +1 -1
  19. package/dist/proto/filter.proto +154 -0
  20. package/dist/proto/generated.d.ts +4499 -0
  21. package/dist/proto/generated.js +10973 -0
  22. package/dist/proto/generated.js.map +1 -0
  23. package/dist/proto/index.d.ts +2 -0
  24. package/dist/proto/index.js +7 -0
  25. package/dist/proto/index.js.map +1 -0
  26. package/dist/proto/starknet.proto +220 -86
  27. package/dist/proto/types.proto +13 -0
  28. package/package.json +16 -7
  29. package/src/cursor.ts +26 -0
  30. package/src/felt.test.ts +24 -0
  31. package/src/felt.ts +61 -0
  32. package/src/filter.test.ts +63 -0
  33. package/src/filter.ts +620 -0
  34. package/src/index.ts +4 -18
  35. package/src/proto/filter.proto +154 -0
  36. package/src/proto/generated.d.ts +4499 -0
  37. package/src/proto/generated.js +11684 -0
  38. package/src/proto/index.ts +4 -0
  39. package/src/proto/starknet.proto +220 -86
  40. package/src/proto/types.proto +13 -0
  41. package/dist/proto/google/protobuf/timestamp.d.ts +0 -132
  42. package/dist/proto/google/protobuf/timestamp.js +0 -92
  43. package/dist/proto/google/protobuf/timestamp.js.map +0 -1
  44. package/dist/proto/starknet.d.ts +0 -1428
  45. package/dist/proto/starknet.js +0 -1506
  46. package/dist/proto/starknet.js.map +0 -1
  47. package/src/proto/google/protobuf/timestamp.ts +0 -216
  48. package/src/proto/starknet.ts +0 -1725
@@ -0,0 +1,4 @@
1
+ import { apibara } from './generated'
2
+
3
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
4
+ export import v1alpha2 = apibara.starknet.v1alpha2
@@ -1,132 +1,266 @@
1
- // # Apibara StarkNet Support
1
+ // Apibara StarkNet Support
2
2
  syntax = "proto3";
3
3
 
4
- package apibara.starknet.v1alpha1;
4
+ package apibara.starknet.v1alpha2;
5
5
 
6
6
  import "google/protobuf/timestamp.proto";
7
+ import "types.proto";
7
8
 
8
9
  // A StarkNet block.
9
10
  message Block {
10
- BlockHash block_hash = 1;
11
- BlockHash parent_block_hash = 2;
11
+ // Block status.
12
+ BlockStatus status = 1;
13
+ // Block header.
14
+ BlockHeader header = 2;
15
+ // Transactions in the block.
16
+ repeated TransactionWithReceipt transactions = 3;
17
+ // State update caused by the block.
18
+ StateUpdate state_update = 4;
19
+ // Events emitted in the block.
20
+ repeated EventWithTransaction events = 5;
21
+ // Messages to L1 sent in the block.
22
+ repeated L2ToL1MessageWithTransaction l2_to_l1_messages = 6;
23
+ }
24
+
25
+ // Block header.
26
+ message BlockHeader {
27
+ // Hash of the block.
28
+ FieldElement block_hash = 1;
29
+ // Hash of the block's parent.
30
+ FieldElement parent_block_hash = 2;
31
+ // Block height.
12
32
  uint64 block_number = 3;
13
- bytes sequencer_address = 4;
14
- bytes state_root = 5;
15
- bytes gas_price = 6;
16
- google.protobuf.Timestamp timestamp = 7;
17
- string starknet_version = 8;
18
- repeated Transaction transactions = 9;
19
- repeated TransactionReceipt transaction_receipts = 10;
33
+ // Sequencer address.
34
+ FieldElement sequencer_address = 4;
35
+ // New state root after the block.
36
+ FieldElement new_root = 5;
37
+ // Timestamp when block was produced.
38
+ google.protobuf.Timestamp timestamp = 6;
20
39
  }
21
40
 
22
- // The hash of a StarkNet block.
23
- message BlockHash { bytes hash = 1; }
41
+ // Status of a block.
42
+ enum BlockStatus {
43
+ // Unknown block status.
44
+ BLOCK_STATUS_UNSPECIFIED = 0;
45
+ // Block not accepted yet.
46
+ BLOCK_STATUS_PENDING = 1;
47
+ // Block accepted on L2.
48
+ BLOCK_STATUS_ACCEPTED_ON_L2 = 2;
49
+ // Block finalized on L1.
50
+ BLOCK_STATUS_ACCEPTED_ON_L1 = 3;
51
+ // Block was rejected and is not part of the canonical chain anymore.
52
+ BLOCK_STATUS_REJECTED = 4;
53
+ }
24
54
 
25
- // Status of a transaction.
26
- enum TransactionStatus {
27
- TRANSACTION_STATUS_UNSPECIFIED = 0;
28
- TRANSACTION_STATUS_RECEIVED = 1;
29
- TRANSACTION_STATUS_PENDING = 2;
30
- TRANSACTION_STATUS_ACCEPTED_ON_L2 = 3;
31
- TRANSACTION_STATUS_ACCEPTED_ON_L1 = 4;
32
- TRANSACTION_STATUS_REJECTED = 5;
55
+ // A transaction with its receipt.
56
+ message TransactionWithReceipt {
57
+ // The transaction
58
+ Transaction transaction = 1;
59
+ // The transaction receipt.
60
+ TransactionReceipt receipt = 2;
33
61
  }
34
62
 
63
+ // A transaction.
35
64
  message Transaction {
65
+ // Common transaction metadata.
66
+ TransactionMeta meta = 1;
36
67
  oneof transaction {
37
- InvokeTransaction invoke = 1;
38
- DeployTransaction deploy = 2;
39
- DeclareTransaction declare = 3;
40
- L1HandlerTransaction l1_handler = 4;
41
- DeployAccountTransaction deploy_account = 5;
68
+ // Transaction invoking a smart contract, V0.
69
+ InvokeTransactionV0 invoke_v0 = 2;
70
+ // Transaction invoking a smart contract, V1.
71
+ InvokeTransactionV1 invoke_v1 = 3;
72
+ // Transaction deploying a new smart contract.
73
+ DeployTransaction deploy = 4;
74
+ // Transaction declaring a smart contract.
75
+ DeclareTransaction declare = 5;
76
+ // Transaction handling a message from L1.
77
+ L1HandlerTransaction l1_handler = 6;
78
+ // Transaction deploying a new account.
79
+ DeployAccountTransaction deploy_account = 7;
42
80
  }
43
81
  }
44
82
 
45
- message TransactionCommon {
46
- bytes hash = 1;
47
- bytes max_fee = 2;
48
- repeated bytes signature = 3;
49
- bytes nonce = 4;
50
- bytes version = 5;
83
+ // Common transaction metadata.
84
+ message TransactionMeta {
85
+ // Transaction hash.
86
+ FieldElement hash = 1;
87
+ // Maximum fee to be paid.
88
+ FieldElement max_fee = 2;
89
+ // Signature by the user.
90
+ repeated FieldElement signature = 3;
91
+ // Nonce.
92
+ FieldElement nonce = 4;
93
+ // Version.
94
+ uint64 version = 5;
51
95
  }
52
96
 
53
- message InvokeTransaction {
54
- TransactionCommon common = 1;
55
- bytes contract_address = 2;
56
- bytes entry_point_selector = 3;
57
- repeated bytes calldata = 4;
97
+ // Transaction invoking a smart contract, V0.
98
+ message InvokeTransactionV0 {
99
+ // Target contract address.
100
+ FieldElement contract_address = 1;
101
+ // Selector of the function being invoked.
102
+ FieldElement entry_point_selector = 2;
103
+ // Raw calldata.
104
+ repeated FieldElement calldata = 3;
58
105
  }
59
106
 
60
- message DeclareTransaction {
61
- TransactionCommon common = 1;
62
- bytes class_hash = 2;
63
- bytes sender_address = 3;
107
+ // Transaction invoking a smart contract, V1.
108
+ message InvokeTransactionV1 {
109
+ // Address sending the transaction.
110
+ FieldElement sender_address = 1;
111
+ // Raw calldata.
112
+ repeated FieldElement calldata = 2;
64
113
  }
65
114
 
115
+ // Transaction deploying a new smart contract.
66
116
  message DeployTransaction {
67
- TransactionCommon common = 1;
68
- repeated bytes constructor_calldata = 2;
69
- bytes contract_address = 3;
70
- bytes contract_address_salt = 4;
71
- bytes class_hash = 5;
117
+ // Raw calldata passed to the constructor.
118
+ repeated FieldElement constructor_calldata = 2;
119
+ // Salt used when computing the contract's address.
120
+ FieldElement contract_address_salt = 3;
121
+ // Hash of the class being deployed.
122
+ FieldElement class_hash = 4;
123
+ }
124
+
125
+ // Transaction declaring a smart contract.
126
+ message DeclareTransaction {
127
+ // Class hash.
128
+ FieldElement class_hash = 1;
129
+ // Address of the account declaring the class.
130
+ FieldElement sender_address = 2;
72
131
  }
73
132
 
133
+ // Transaction handling a message from L1.
74
134
  message L1HandlerTransaction {
75
- TransactionCommon common = 1;
76
- bytes contract_address = 2;
77
- bytes entry_point_selector = 3;
78
- repeated bytes calldata = 4;
135
+ // Target contract address.
136
+ FieldElement contract_address = 2;
137
+ // Selector of the function being invoked.
138
+ FieldElement entry_point_selector = 3;
139
+ // Raw calldata.
140
+ repeated FieldElement calldata = 4;
79
141
  }
80
142
 
143
+ // Transaction deploying a new account.
81
144
  message DeployAccountTransaction {
82
- TransactionCommon common = 1;
83
- repeated bytes constructor_calldata = 2;
84
- bytes contract_address = 3;
85
- bytes contract_address_salt = 4;
86
- bytes class_hash = 5;
145
+ // Raw calldata passed to the constructor.
146
+ repeated FieldElement constructor_calldata = 2;
147
+ // Salt used when computing the contract's address.
148
+ FieldElement contract_address_salt = 3;
149
+ // Hash of the class being deployed.
150
+ FieldElement class_hash = 4;
87
151
  }
88
152
 
153
+ // Result of the execution of a transaction.
154
+ //
155
+ // This message only contains the receipt data, if you also need the
156
+ // transaction, request a `Transaction`.
89
157
  message TransactionReceipt {
90
- bytes transaction_hash = 1;
158
+ // Hash of the transaction.
159
+ FieldElement transaction_hash = 1;
160
+ // Transaction's indexe in the list of transactions in a block.
91
161
  uint64 transaction_index = 2;
92
- bytes actual_fee = 3;
93
- ExecutionResources execution_resources = 4;
94
- L1ToL2Message l1_to_l2_consumed_message = 5;
95
- repeated L2ToL1Message l2_to_l1_messages = 6;
96
- repeated Event events = 7;
162
+ // Feed paid.
163
+ FieldElement actual_fee = 3;
164
+ // Messages sent to L1 in the transactions.
165
+ repeated L2ToL1Message l2_to_l1_messages = 4;
166
+ // Events emitted in the transaction.
167
+ repeated Event events = 5;
97
168
  }
98
169
 
99
- message ExecutionResources {
100
- uint64 n_steps = 1;
101
- uint64 n_memory_holes = 2;
102
- BuiltinInstanceCounter builtin_instance_counter = 3;
170
+ // Message sent from L2 to L1 together with its transaction and receipt.
171
+ message L2ToL1MessageWithTransaction {
172
+ // The transaction that sent this message.
173
+ Transaction transaction = 1;
174
+ // The transaction receipt.
175
+ TransactionReceipt receipt = 2;
176
+ // The message.
177
+ L2ToL1Message message = 3;
103
178
  }
104
179
 
105
- message BuiltinInstanceCounter {
106
- optional uint64 pedersen_builtin = 1;
107
- optional uint64 range_check_builtin = 2;
108
- optional uint64 bitwise_builtin = 3;
109
- optional uint64 output_builtin = 4;
110
- optional uint64 ecdsa_builtin = 5;
111
- optional uint64 ec_op_builtin = 6;
180
+ // Message sent from L2 to L1.
181
+ message L2ToL1Message {
182
+ // Destination address.
183
+ FieldElement to_address = 3;
184
+ // Data contained in the message.
185
+ repeated FieldElement payload = 4;
112
186
  }
113
187
 
114
- message L1ToL2Message {
115
- bytes from_address = 1;
116
- bytes to_address = 2;
117
- bytes selector = 3;
118
- repeated bytes payload = 4;
119
- bytes nonce = 5;
188
+ // Event emitted by a transaction, together with its transaction and receipt.
189
+ message EventWithTransaction {
190
+ // The transaction emitting the event.
191
+ Transaction transaction = 1;
192
+ // The transaction receipt.
193
+ TransactionReceipt receipt = 2;
194
+ // The event.
195
+ Event event = 3;
120
196
  }
121
197
 
122
- message L2ToL1Message {
123
- bytes from_address = 1;
124
- bytes to_address = 2;
125
- repeated bytes payload = 3;
198
+ // Event emitted by a transaction.
199
+ message Event {
200
+ // Address of the smart contract emitting the event.
201
+ FieldElement from_address = 1;
202
+ // Event key.
203
+ repeated FieldElement keys = 2;
204
+ // Event data.
205
+ repeated FieldElement data = 3;
126
206
  }
127
207
 
128
- message Event {
129
- bytes from_address = 1;
130
- repeated bytes keys = 2;
131
- repeated bytes data = 3;
208
+ // State update.
209
+ message StateUpdate {
210
+ // New state root.
211
+ FieldElement new_root = 1;
212
+ // Previous state root.
213
+ FieldElement old_root = 2;
214
+ // State difference.
215
+ StateDiff state_diff = 3;
216
+ }
217
+
218
+ // Difference in state between blocks.
219
+ message StateDiff {
220
+ // Storage differences.
221
+ repeated StorageDiff storage_diffs = 1;
222
+ // Contracts declared.
223
+ repeated DeclaredContract declared_contracts = 2;
224
+ // Contracts deployed.
225
+ repeated DeployedContract deployed_contracts = 3;
226
+ // Nonces updated.
227
+ repeated NonceUpdate nonces = 4;
228
+ }
229
+
230
+ // Difference in storage values for a contract.
231
+ message StorageDiff {
232
+ // The contract address.
233
+ FieldElement contract_address = 1;
234
+ // Entries that changed.
235
+ repeated StorageEntry storage_entries = 2;
236
+ }
237
+
238
+ // Storage entry.
239
+ message StorageEntry {
240
+ // Storage location.
241
+ FieldElement key = 1;
242
+ // Storage value.
243
+ FieldElement value = 2;
244
+ }
245
+
246
+ // Contract declared.
247
+ message DeclaredContract {
248
+ // Class hash of the newly declared contract.
249
+ FieldElement class_hash = 1;
250
+ }
251
+
252
+ // Contract deployed.
253
+ message DeployedContract {
254
+ // Address of the newly deployed contract.
255
+ FieldElement contract_address = 1;
256
+ // Class hash of the deployed contract.
257
+ FieldElement class_hash = 2;
258
+ }
259
+
260
+ // Nonce update.
261
+ message NonceUpdate {
262
+ // Contract address.
263
+ FieldElement contract_address = 1;
264
+ // New nonce value.
265
+ FieldElement nonce = 2;
132
266
  }
@@ -0,0 +1,13 @@
1
+ syntax = "proto3";
2
+
3
+ package apibara.starknet.v1alpha2;
4
+
5
+ // StarkNet field element.
6
+ //
7
+ // Encoded as 4 packed uint64
8
+ message FieldElement {
9
+ fixed64 lo_lo = 1 [jstype = JS_STRING];
10
+ fixed64 lo_hi = 2 [jstype = JS_STRING];
11
+ fixed64 hi_lo = 3 [jstype = JS_STRING];
12
+ fixed64 hi_hi = 4 [jstype = JS_STRING];
13
+ }
@@ -1,132 +0,0 @@
1
- import _m0 from "protobufjs/minimal";
2
- export declare const protobufPackage = "google.protobuf";
3
- /**
4
- * A Timestamp represents a point in time independent of any time zone or local
5
- * calendar, encoded as a count of seconds and fractions of seconds at
6
- * nanosecond resolution. The count is relative to an epoch at UTC midnight on
7
- * January 1, 1970, in the proleptic Gregorian calendar which extends the
8
- * Gregorian calendar backwards to year one.
9
- *
10
- * All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap
11
- * second table is needed for interpretation, using a [24-hour linear
12
- * smear](https://developers.google.com/time/smear).
13
- *
14
- * The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By
15
- * restricting to that range, we ensure that we can convert to and from [RFC
16
- * 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings.
17
- *
18
- * # Examples
19
- *
20
- * Example 1: Compute Timestamp from POSIX `time()`.
21
- *
22
- * Timestamp timestamp;
23
- * timestamp.set_seconds(time(NULL));
24
- * timestamp.set_nanos(0);
25
- *
26
- * Example 2: Compute Timestamp from POSIX `gettimeofday()`.
27
- *
28
- * struct timeval tv;
29
- * gettimeofday(&tv, NULL);
30
- *
31
- * Timestamp timestamp;
32
- * timestamp.set_seconds(tv.tv_sec);
33
- * timestamp.set_nanos(tv.tv_usec * 1000);
34
- *
35
- * Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`.
36
- *
37
- * FILETIME ft;
38
- * GetSystemTimeAsFileTime(&ft);
39
- * UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime;
40
- *
41
- * // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z
42
- * // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z.
43
- * Timestamp timestamp;
44
- * timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL));
45
- * timestamp.set_nanos((INT32) ((ticks % 10000000) * 100));
46
- *
47
- * Example 4: Compute Timestamp from Java `System.currentTimeMillis()`.
48
- *
49
- * long millis = System.currentTimeMillis();
50
- *
51
- * Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000)
52
- * .setNanos((int) ((millis % 1000) * 1000000)).build();
53
- *
54
- * Example 5: Compute Timestamp from Java `Instant.now()`.
55
- *
56
- * Instant now = Instant.now();
57
- *
58
- * Timestamp timestamp =
59
- * Timestamp.newBuilder().setSeconds(now.getEpochSecond())
60
- * .setNanos(now.getNano()).build();
61
- *
62
- * Example 6: Compute Timestamp from current time in Python.
63
- *
64
- * timestamp = Timestamp()
65
- * timestamp.GetCurrentTime()
66
- *
67
- * # JSON Mapping
68
- *
69
- * In JSON format, the Timestamp type is encoded as a string in the
70
- * [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the
71
- * format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z"
72
- * where {year} is always expressed using four digits while {month}, {day},
73
- * {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional
74
- * seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution),
75
- * are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone
76
- * is required. A proto3 JSON serializer should always use UTC (as indicated by
77
- * "Z") when printing the Timestamp type and a proto3 JSON parser should be
78
- * able to accept both UTC and other timezones (as indicated by an offset).
79
- *
80
- * For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past
81
- * 01:30 UTC on January 15, 2017.
82
- *
83
- * In JavaScript, one can convert a Date object to this format using the
84
- * standard
85
- * [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString)
86
- * method. In Python, a standard `datetime.datetime` object can be converted
87
- * to this format using
88
- * [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with
89
- * the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use
90
- * the Joda Time's [`ISODateTimeFormat.dateTime()`](
91
- * http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime%2D%2D
92
- * ) to obtain a formatter capable of generating timestamps in this format.
93
- */
94
- export interface Timestamp {
95
- /**
96
- * Represents seconds of UTC time since Unix epoch
97
- * 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to
98
- * 9999-12-31T23:59:59Z inclusive.
99
- */
100
- seconds: number;
101
- /**
102
- * Non-negative fractions of a second at nanosecond resolution. Negative
103
- * second values with fractions must still have non-negative nanos values
104
- * that count forward in time. Must be from 0 to 999,999,999
105
- * inclusive.
106
- */
107
- nanos: number;
108
- }
109
- export declare const Timestamp: {
110
- encode(message: Timestamp, writer?: _m0.Writer): _m0.Writer;
111
- decode(input: _m0.Reader | Uint8Array, length?: number): Timestamp;
112
- fromJSON(object: any): Timestamp;
113
- toJSON(message: Timestamp): unknown;
114
- fromPartial<I extends {
115
- seconds?: number | undefined;
116
- nanos?: number | undefined;
117
- } & {
118
- seconds?: number | undefined;
119
- nanos?: number | undefined;
120
- } & { [K in Exclude<keyof I, keyof Timestamp>]: never; }>(object: I): Timestamp;
121
- };
122
- declare type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
123
- export declare type DeepPartial<T> = T extends Builtin ? T : T extends Array<infer U> ? Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends {} ? {
124
- [K in keyof T]?: DeepPartial<T[K]>;
125
- } : Partial<T>;
126
- declare type KeysOfUnion<T> = T extends T ? keyof T : never;
127
- export declare type Exact<P, I extends P> = P extends Builtin ? P : P & {
128
- [K in keyof P]: Exact<P[K], I[K]>;
129
- } & {
130
- [K in Exclude<keyof I, KeysOfUnion<P>>]: never;
131
- };
132
- export {};
@@ -1,92 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.Timestamp = exports.protobufPackage = void 0;
7
- /* eslint-disable */
8
- const long_1 = __importDefault(require("long"));
9
- const minimal_1 = __importDefault(require("protobufjs/minimal"));
10
- exports.protobufPackage = "google.protobuf";
11
- function createBaseTimestamp() {
12
- return { seconds: 0, nanos: 0 };
13
- }
14
- exports.Timestamp = {
15
- encode(message, writer = minimal_1.default.Writer.create()) {
16
- if (message.seconds !== 0) {
17
- writer.uint32(8).int64(message.seconds);
18
- }
19
- if (message.nanos !== 0) {
20
- writer.uint32(16).int32(message.nanos);
21
- }
22
- return writer;
23
- },
24
- decode(input, length) {
25
- const reader = input instanceof minimal_1.default.Reader ? input : new minimal_1.default.Reader(input);
26
- let end = length === undefined ? reader.len : reader.pos + length;
27
- const message = createBaseTimestamp();
28
- while (reader.pos < end) {
29
- const tag = reader.uint32();
30
- switch (tag >>> 3) {
31
- case 1:
32
- message.seconds = longToNumber(reader.int64());
33
- break;
34
- case 2:
35
- message.nanos = reader.int32();
36
- break;
37
- default:
38
- reader.skipType(tag & 7);
39
- break;
40
- }
41
- }
42
- return message;
43
- },
44
- fromJSON(object) {
45
- return {
46
- seconds: isSet(object.seconds) ? Number(object.seconds) : 0,
47
- nanos: isSet(object.nanos) ? Number(object.nanos) : 0,
48
- };
49
- },
50
- toJSON(message) {
51
- const obj = {};
52
- message.seconds !== undefined && (obj.seconds = Math.round(message.seconds));
53
- message.nanos !== undefined && (obj.nanos = Math.round(message.nanos));
54
- return obj;
55
- },
56
- fromPartial(object) {
57
- var _a, _b;
58
- const message = createBaseTimestamp();
59
- message.seconds = (_a = object.seconds) !== null && _a !== void 0 ? _a : 0;
60
- message.nanos = (_b = object.nanos) !== null && _b !== void 0 ? _b : 0;
61
- return message;
62
- },
63
- };
64
- var globalThis = (() => {
65
- if (typeof globalThis !== "undefined") {
66
- return globalThis;
67
- }
68
- if (typeof self !== "undefined") {
69
- return self;
70
- }
71
- if (typeof window !== "undefined") {
72
- return window;
73
- }
74
- if (typeof global !== "undefined") {
75
- return global;
76
- }
77
- throw "Unable to locate global object";
78
- })();
79
- function longToNumber(long) {
80
- if (long.gt(Number.MAX_SAFE_INTEGER)) {
81
- throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER");
82
- }
83
- return long.toNumber();
84
- }
85
- if (minimal_1.default.util.Long !== long_1.default) {
86
- minimal_1.default.util.Long = long_1.default;
87
- minimal_1.default.configure();
88
- }
89
- function isSet(value) {
90
- return value !== null && value !== undefined;
91
- }
92
- //# sourceMappingURL=timestamp.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"timestamp.js","sourceRoot":"","sources":["../../../../src/proto/google/protobuf/timestamp.ts"],"names":[],"mappings":";;;;;;AAAA,oBAAoB;AACpB,gDAAwB;AACxB,iEAAqC;AAExB,QAAA,eAAe,GAAG,iBAAiB,CAAC;AA6GjD,SAAS,mBAAmB;IAC1B,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;AAClC,CAAC;AAEY,QAAA,SAAS,GAAG;IACvB,MAAM,CAAC,OAAkB,EAAE,SAAqB,iBAAG,CAAC,MAAM,CAAC,MAAM,EAAE;QACjE,IAAI,OAAO,CAAC,OAAO,KAAK,CAAC,EAAE;YACzB,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;SACzC;QACD,IAAI,OAAO,CAAC,KAAK,KAAK,CAAC,EAAE;YACvB,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;SACxC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,MAAM,CAAC,KAA8B,EAAE,MAAe;QACpD,MAAM,MAAM,GAAG,KAAK,YAAY,iBAAG,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,iBAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC3E,IAAI,GAAG,GAAG,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,GAAG,MAAM,CAAC;QAClE,MAAM,OAAO,GAAG,mBAAmB,EAAE,CAAC;QACtC,OAAO,MAAM,CAAC,GAAG,GAAG,GAAG,EAAE;YACvB,MAAM,GAAG,GAAG,MAAM,CAAC,MAA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