@thru/thru-sdk 0.0.4

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 (63) hide show
  1. package/README.md +7 -0
  2. package/buf.gen.yaml +12 -0
  3. package/buf.lock +9 -0
  4. package/buf.yaml +15 -0
  5. package/dist/sdk.d.ts +1354 -0
  6. package/dist/sdk.js +1130 -0
  7. package/dist/sdk.js.map +1 -0
  8. package/package.json +39 -0
  9. package/proto/thru/common/v1/consensus.proto +75 -0
  10. package/proto/thru/common/v1/errors.proto +67 -0
  11. package/proto/thru/common/v1/filters.proto +50 -0
  12. package/proto/thru/common/v1/pagination.proto +47 -0
  13. package/proto/thru/core/v1/account.proto +138 -0
  14. package/proto/thru/core/v1/block.proto +82 -0
  15. package/proto/thru/core/v1/state.proto +37 -0
  16. package/proto/thru/core/v1/transaction.proto +95 -0
  17. package/proto/thru/core/v1/types.proto +52 -0
  18. package/proto/thru/services/v1/command_service.proto +45 -0
  19. package/proto/thru/services/v1/query_service.proto +344 -0
  20. package/proto/thru/services/v1/streaming_service.proto +128 -0
  21. package/thru-ts-client-sdk/core/bound-client.ts +129 -0
  22. package/thru-ts-client-sdk/core/client.ts +38 -0
  23. package/thru-ts-client-sdk/counter.ts +216 -0
  24. package/thru-ts-client-sdk/create-account.ts +78 -0
  25. package/thru-ts-client-sdk/defaults.ts +17 -0
  26. package/thru-ts-client-sdk/get-height.ts +52 -0
  27. package/thru-ts-client-sdk/modules/accounts.ts +137 -0
  28. package/thru-ts-client-sdk/modules/blocks.ts +75 -0
  29. package/thru-ts-client-sdk/modules/events.ts +20 -0
  30. package/thru-ts-client-sdk/modules/height.ts +9 -0
  31. package/thru-ts-client-sdk/modules/helpers.ts +340 -0
  32. package/thru-ts-client-sdk/modules/proofs.ts +20 -0
  33. package/thru-ts-client-sdk/modules/streaming.ts +34 -0
  34. package/thru-ts-client-sdk/modules/transactions.ts +274 -0
  35. package/thru-ts-client-sdk/proto/buf/validate/validate_pb.ts +4761 -0
  36. package/thru-ts-client-sdk/proto/google/api/annotations_pb.ts +39 -0
  37. package/thru-ts-client-sdk/proto/google/api/client_pb.ts +953 -0
  38. package/thru-ts-client-sdk/proto/google/api/field_behavior_pb.ts +157 -0
  39. package/thru-ts-client-sdk/proto/google/api/http_pb.ts +474 -0
  40. package/thru-ts-client-sdk/proto/google/api/launch_stage_pb.ts +118 -0
  41. package/thru-ts-client-sdk/proto/thru/common/v1/consensus_pb.ts +163 -0
  42. package/thru-ts-client-sdk/proto/thru/common/v1/errors_pb.ts +130 -0
  43. package/thru-ts-client-sdk/proto/thru/common/v1/filters_pb.ts +81 -0
  44. package/thru-ts-client-sdk/proto/thru/common/v1/pagination_pb.ts +80 -0
  45. package/thru-ts-client-sdk/proto/thru/core/v1/account_pb.ts +358 -0
  46. package/thru-ts-client-sdk/proto/thru/core/v1/block_pb.ts +260 -0
  47. package/thru-ts-client-sdk/proto/thru/core/v1/state_pb.ts +104 -0
  48. package/thru-ts-client-sdk/proto/thru/core/v1/transaction_pb.ts +327 -0
  49. package/thru-ts-client-sdk/proto/thru/core/v1/types_pb.ts +101 -0
  50. package/thru-ts-client-sdk/proto/thru/services/v1/command_service_pb.ts +81 -0
  51. package/thru-ts-client-sdk/proto/thru/services/v1/query_service_pb.ts +813 -0
  52. package/thru-ts-client-sdk/proto/thru/services/v1/streaming_service_pb.ts +391 -0
  53. package/thru-ts-client-sdk/sdk.ts +58 -0
  54. package/thru-ts-client-sdk/transactions/Transaction.ts +240 -0
  55. package/thru-ts-client-sdk/transactions/TransactionBuilder.ts +48 -0
  56. package/thru-ts-client-sdk/transactions/__tests__/transaction.test.ts +95 -0
  57. package/thru-ts-client-sdk/transactions/index.ts +3 -0
  58. package/thru-ts-client-sdk/transactions/types.ts +64 -0
  59. package/thru-ts-client-sdk/transactions/utils.ts +134 -0
  60. package/thru-ts-client-sdk/types/types.ts +8 -0
  61. package/thru-ts-client-sdk/utils/utils.ts +70 -0
  62. package/tsconfig.json +9 -0
  63. package/tsup.config.ts +10 -0
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "@thru/thru-sdk",
3
+ "version": "0.0.4",
4
+ "type": "module",
5
+ "main": "./dist/sdk.js",
6
+ "types": "./dist/sdk.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "import": "./dist/sdk.js",
10
+ "types": "./dist/sdk.d.ts"
11
+ }
12
+ },
13
+ "dependencies": {
14
+ "@bufbuild/protobuf": "^2.9.0",
15
+ "@connectrpc/connect": "^2.1.0",
16
+ "@connectrpc/connect-web": "^2.1.0",
17
+ "@noble/ed25519": "^2.3.0",
18
+ "@noble/hashes": "^1.4.0"
19
+ },
20
+ "devDependencies": {
21
+ "@bufbuild/buf": "^1.58.0",
22
+ "@bufbuild/protoc-gen-es": "^2.9.0",
23
+ "ts-node": "^10.9.1",
24
+ "tsx": "^4.20.6",
25
+ "typescript": "^5.9.3"
26
+ },
27
+ "scripts": {
28
+ "get-height": "ts-node thru-ts-client-sdk/get-height.ts",
29
+ "counter": "tsx --tsconfig tsconfig.json thru-ts-client-sdk/counter.ts",
30
+ "create-account": "tsx --tsconfig tsconfig.json thru-ts-client-sdk/create-account.ts",
31
+ "protobufs:pull": "rm -rf proto && cp -a ../../../proto ./proto",
32
+ "protobufs:generate": "buf generate --include-imports",
33
+ "build": "tsup",
34
+ "dev": "tsup --watch",
35
+ "lint": "eslint src/",
36
+ "test:transactions": "node --loader ts-node/esm --test \"thru-ts-client-sdk/transactions/__tests__/*.test.ts\"",
37
+ "clean": "rm -rf dist"
38
+ }
39
+ }
@@ -0,0 +1,75 @@
1
+ edition = "2023";
2
+
3
+ package thru.common.v1;
4
+
5
+ option features.field_presence = EXPLICIT;
6
+
7
+ import "buf/validate/validate.proto";
8
+ import "google/api/field_behavior.proto";
9
+ import "google/protobuf/timestamp.proto";
10
+
11
+ option go_package = "github.com/Unto-Labs/thru-net/grpc/pkg/proto/thru/common/v1;commonv1";
12
+ option java_multiple_files = true;
13
+ option java_package = "network.thru.common.v1";
14
+ option csharp_namespace = "Thru.Common.V1";
15
+ option ruby_package = "Thru::Common::V1";
16
+ option objc_class_prefix = "THU";
17
+ option swift_prefix = "THU";
18
+
19
+ // ConsensusStatus represents the minimum consensus level a resource has
20
+ // achieved when returned by the service.
21
+ enum ConsensusStatus {
22
+ // CONSENSUS_STATUS_UNSPECIFIED indicates the consensus status is unknown.
23
+ CONSENSUS_STATUS_UNSPECIFIED = 0;
24
+
25
+ // CONSENSUS_STATUS_OBSERVED indicates the resource has been observed but
26
+ // not yet confirmed in a finalized block.
27
+ CONSENSUS_STATUS_OBSERVED = 1;
28
+
29
+ // CONSENSUS_STATUS_INCLUDED indicates the resource has been included in the
30
+ // ledger but may not be finalized.
31
+ CONSENSUS_STATUS_INCLUDED = 2;
32
+
33
+ // CONSENSUS_STATUS_FINALIZED indicates the resource is finalized for a slot.
34
+ CONSENSUS_STATUS_FINALIZED = 3;
35
+
36
+ // CONSENSUS_STATUS_LOCALLY_EXECUTED indicates the local node executed the
37
+ // resource but broader cluster finality may not have been achieved.
38
+ CONSENSUS_STATUS_LOCALLY_EXECUTED = 4;
39
+
40
+ // CONSENSUS_STATUS_CLUSTER_EXECUTED indicates the entire cluster has
41
+ // executed and agreed on the resource.
42
+ CONSENSUS_STATUS_CLUSTER_EXECUTED = 5;
43
+ }
44
+
45
+ // VersionContext selects which logical version of a resource should be
46
+ // returned. At least one field must be set.
47
+ message VersionContext {
48
+ option (buf.validate.message).cel = {
49
+ id: "version_context_has_selector"
50
+ message: "one of current, slot, or timestamp must be set"
51
+ expression: "has(this.current) || has(this.slot) || has(this.timestamp)"
52
+ };
53
+
54
+ // Specifies the desired version semantics.
55
+ oneof version {
56
+ // Request the latest version available at request time.
57
+ CurrentVersion current = 1 [(google.api.field_behavior) = OPTIONAL];
58
+
59
+ // Request the latest version, or historical on.
60
+ CurrentOrHistoricalVersion currentOrHistorical = 2 [(google.api.field_behavior) = OPTIONAL];
61
+
62
+ // Request the version for a specific slot number.
63
+ uint64 slot = 3 [(google.api.field_behavior) = OPTIONAL];
64
+
65
+ // Request the version nearest to the provided block timestamp.
66
+ google.protobuf.Timestamp timestamp = 4
67
+ [(google.api.field_behavior) = OPTIONAL];
68
+ }
69
+ }
70
+
71
+ // CurrentVersion is an empty marker message for VersionContext.current.
72
+ message CurrentVersion {}
73
+
74
+ // CurrentOrHistoricalVersion is an empty marker message for VersionContext.current.
75
+ message CurrentOrHistoricalVersion {}
@@ -0,0 +1,67 @@
1
+ edition = "2023";
2
+
3
+ package thru.common.v1;
4
+
5
+ option features.field_presence = EXPLICIT;
6
+
7
+ import "buf/validate/validate.proto";
8
+ import "google/api/field_behavior.proto";
9
+ import "google/protobuf/timestamp.proto";
10
+
11
+ option go_package = "github.com/Unto-Labs/thru-net/grpc/pkg/proto/thru/common/v1;commonv1";
12
+ option java_multiple_files = true;
13
+ option java_package = "network.thru.common.v1";
14
+ option csharp_namespace = "Thru.Common.V1";
15
+ option ruby_package = "Thru::Common::V1";
16
+ option objc_class_prefix = "THU";
17
+ option swift_prefix = "THU";
18
+
19
+ // ErrorType captures structured error categories returned by the services.
20
+ enum ErrorType {
21
+ // ERROR_TYPE_UNSPECIFIED is an unknown error condition.
22
+ ERROR_TYPE_UNSPECIFIED = 0;
23
+
24
+ // ERROR_TYPE_NOT_FOUND indicates requested data does not exist.
25
+ ERROR_TYPE_NOT_FOUND = 1;
26
+
27
+ // ERROR_TYPE_NOT_RETAINED indicates requested data was not retained under TTL.
28
+ ERROR_TYPE_NOT_RETAINED = 2;
29
+
30
+ // ERROR_TYPE_NOT_FOUND_OR_NOT_RETAINED indicates an ambiguous not found vs TTL case.
31
+ ERROR_TYPE_NOT_FOUND_OR_NOT_RETAINED = 3;
32
+
33
+ // ERROR_TYPE_INVALID_REQUEST indicates the request failed validation.
34
+ ERROR_TYPE_INVALID_REQUEST = 4;
35
+
36
+ // ERROR_TYPE_CEL_VALIDATION_FAILED indicates a CEL filter failed validation.
37
+ ERROR_TYPE_CEL_VALIDATION_FAILED = 5;
38
+
39
+ // ERROR_TYPE_INTERNAL_ERROR indicates an internal server error occurred.
40
+ ERROR_TYPE_INTERNAL_ERROR = 6;
41
+ }
42
+
43
+ // ErrorDetail provides structured error metadata attached to gRPC errors.
44
+ message ErrorDetail {
45
+ // High-level error category.
46
+ ErrorType error_type = 1 [(google.api.field_behavior) = REQUIRED];
47
+
48
+ // Human-readable error summary.
49
+ string message = 2 [
50
+ (google.api.field_behavior) = REQUIRED,
51
+ (buf.validate.field).string.max_len = 1024
52
+ ];
53
+
54
+ // Optional retention window expressed in slots when applicable.
55
+ uint64 retention_window_slots = 3
56
+ [(google.api.field_behavior) = OPTIONAL];
57
+
58
+ // Optional retention cutoff timestamp when applicable.
59
+ google.protobuf.Timestamp retention_cutoff = 4
60
+ [(google.api.field_behavior) = OPTIONAL];
61
+
62
+ // Optional name of the field associated with the error.
63
+ string field_name = 5 [
64
+ (google.api.field_behavior) = OPTIONAL,
65
+ (buf.validate.field).string.max_len = 128
66
+ ];
67
+ }
@@ -0,0 +1,50 @@
1
+ edition = "2023";
2
+
3
+ package thru.common.v1;
4
+
5
+ option features.field_presence = EXPLICIT;
6
+
7
+ import "buf/validate/validate.proto";
8
+ import "google/api/field_behavior.proto";
9
+
10
+ option go_package = "github.com/Unto-Labs/thru-net/grpc/pkg/proto/thru/common/v1;commonv1";
11
+ option java_multiple_files = true;
12
+ option java_package = "network.thru.common.v1";
13
+ option csharp_namespace = "Thru.Common.V1";
14
+ option ruby_package = "Thru::Common::V1";
15
+ option objc_class_prefix = "THU";
16
+ option swift_prefix = "THU";
17
+
18
+ // Filter represents a CEL-based expression applied to query or stream results.
19
+ message Filter {
20
+ // CEL expression applied server-side. Empty expressions are treated as no-op.
21
+ string expression = 1 [
22
+ (google.api.field_behavior) = OPTIONAL,
23
+ (buf.validate.field).string.max_len = 4096
24
+ ];
25
+
26
+ // Named parameter bindings for expression parameterization.
27
+ map<string, string> params = 2 [(google.api.field_behavior) = OPTIONAL];
28
+ }
29
+
30
+ // CelFilterValidation describes the validation configuration returned to
31
+ // clients to help them build safe filter expressions.
32
+ message CelFilterValidation {
33
+ // List of allowed CEL function names for a specific request type.
34
+ repeated string allowed_functions = 1 [
35
+ (google.api.field_behavior) = OPTIONAL,
36
+ (buf.validate.field).repeated.max_items = 128
37
+ ];
38
+
39
+ // List of allowed field names accessible to the CEL expression.
40
+ repeated string allowed_fields = 2 [
41
+ (google.api.field_behavior) = OPTIONAL,
42
+ (buf.validate.field).repeated.max_items = 256
43
+ ];
44
+
45
+ // Maximum AST node count permitted for a CEL expression.
46
+ uint32 max_complexity = 3 [
47
+ (google.api.field_behavior) = OPTIONAL,
48
+ (buf.validate.field).uint32.lte = 1000
49
+ ];
50
+ }
@@ -0,0 +1,47 @@
1
+ edition = "2023";
2
+
3
+ package thru.common.v1;
4
+
5
+ option features.field_presence = EXPLICIT;
6
+
7
+ import "buf/validate/validate.proto";
8
+ import "google/api/field_behavior.proto";
9
+
10
+ option go_package = "github.com/Unto-Labs/thru-net/grpc/pkg/proto/thru/common/v1;commonv1";
11
+ option java_multiple_files = true;
12
+ option java_package = "network.thru.common.v1";
13
+ option csharp_namespace = "Thru.Common.V1";
14
+ option ruby_package = "Thru::Common::V1";
15
+ option objc_class_prefix = "THU";
16
+ option swift_prefix = "THU";
17
+
18
+ // PageRequest contains pagination parameters for listing RPCs.
19
+ message PageRequest {
20
+ // Maximum number of items to return in a single response.
21
+ uint32 page_size = 1 [
22
+ (google.api.field_behavior) = OPTIONAL,
23
+ (buf.validate.field).uint32.gte = 1,
24
+ (buf.validate.field).uint32.lte = 1000
25
+ ];
26
+
27
+ // Token identifying the position to resume from.
28
+ string page_token = 2 [
29
+ (google.api.field_behavior) = OPTIONAL,
30
+ (buf.validate.field).string.max_len = 512
31
+ ];
32
+
33
+ // Optional ordering specification in "field [asc|desc]" form.
34
+ string order_by = 3 [
35
+ (google.api.field_behavior) = OPTIONAL,
36
+ (buf.validate.field).string.max_len = 256
37
+ ];
38
+ }
39
+
40
+ // PageResponse captures pagination metadata returned with list results.
41
+ message PageResponse {
42
+ // Token to retrieve the next page of results, if any.
43
+ string next_page_token = 1 [(google.api.field_behavior) = OPTIONAL];
44
+
45
+ // Total number of items available when known.
46
+ uint64 total_size = 2 [(google.api.field_behavior) = OPTIONAL];
47
+ }
@@ -0,0 +1,138 @@
1
+ edition = "2023";
2
+
3
+ package thru.core.v1;
4
+
5
+ option features.field_presence = EXPLICIT;
6
+
7
+ import "buf/validate/validate.proto";
8
+ import "google/api/field_behavior.proto";
9
+ import "google/protobuf/timestamp.proto";
10
+ import "thru/common/v1/consensus.proto";
11
+ import "thru/core/v1/types.proto";
12
+
13
+ option go_package = "github.com/Unto-Labs/thru-net/grpc/pkg/proto/thru/core/v1;corev1";
14
+ option java_multiple_files = true;
15
+ option java_package = "network.thru.core.v1";
16
+ option csharp_namespace = "Thru.Core.V1";
17
+ option ruby_package = "Thru::Core::V1";
18
+ option objc_class_prefix = "THUC";
19
+ option swift_prefix = "THUC";
20
+
21
+ // AccountView controls which sections of account resources are returned.
22
+ enum AccountView {
23
+ // ACCOUNT_VIEW_UNSPECIFIED uses service defaults.
24
+ ACCOUNT_VIEW_UNSPECIFIED = 0;
25
+
26
+ // ACCOUNT_VIEW_PUBKEY_ONLY returns only the account address.
27
+ ACCOUNT_VIEW_PUBKEY_ONLY = 1;
28
+
29
+ // ACCOUNT_VIEW_META_ONLY returns only account metadata.
30
+ ACCOUNT_VIEW_META_ONLY = 2;
31
+
32
+ // ACCOUNT_VIEW_DATA_ONLY returns only account data.
33
+ ACCOUNT_VIEW_DATA_ONLY = 3;
34
+
35
+ // ACCOUNT_VIEW_FULL returns address, metadata, and data.
36
+ ACCOUNT_VIEW_FULL = 4;
37
+ }
38
+
39
+ // AccountFlags enumerates boolean account capability flags.
40
+ message AccountFlags {
41
+ bool is_program = 1 [(google.api.field_behavior) = OPTIONAL];
42
+ bool is_privileged = 2 [(google.api.field_behavior) = OPTIONAL];
43
+ bool is_uncompressable = 3 [(google.api.field_behavior) = OPTIONAL];
44
+ bool is_ephemeral = 4 [(google.api.field_behavior) = OPTIONAL];
45
+ bool is_deleted = 5 [(google.api.field_behavior) = OPTIONAL];
46
+ bool is_new = 6 [(google.api.field_behavior) = OPTIONAL];
47
+ bool is_compressed = 7 [(google.api.field_behavior) = OPTIONAL];
48
+ }
49
+
50
+ // AccountMeta captures metadata associated with an account.
51
+ message AccountMeta {
52
+ uint32 version = 1 [
53
+ (google.api.field_behavior) = REQUIRED,
54
+ (buf.validate.field).uint32.gte = 1
55
+ ];
56
+ AccountFlags flags = 2 [(google.api.field_behavior) = OPTIONAL];
57
+ uint32 data_size = 3 [(google.api.field_behavior) = REQUIRED];
58
+ uint64 state_counter = 4 [(google.api.field_behavior) = OPTIONAL];
59
+ Pubkey owner = 5 [(google.api.field_behavior) = REQUIRED];
60
+ uint64 balance = 6 [(google.api.field_behavior) = OPTIONAL];
61
+ uint64 nonce = 7 [(google.api.field_behavior) = OPTIONAL];
62
+ }
63
+
64
+ // AccountData contains account data payloads.
65
+ message AccountData {
66
+ bytes data = 1 [
67
+ (google.api.field_behavior) = OPTIONAL,
68
+ (buf.validate.field).bytes.max_len = 16777216
69
+ ];
70
+ bool compressed = 2 [(google.api.field_behavior) = OPTIONAL];
71
+ string compression_algorithm = 3 [
72
+ (google.api.field_behavior) = OPTIONAL,
73
+ (buf.validate.field).string.max_len = 64
74
+ ];
75
+ }
76
+
77
+ // DataSlice describes a contiguous range of account data to return.
78
+ message DataSlice {
79
+ uint32 offset = 1 [
80
+ (google.api.field_behavior) = REQUIRED,
81
+ (buf.validate.field).uint64.lte = 16777216
82
+ ];
83
+ uint32 length = 2 [
84
+ (google.api.field_behavior) = REQUIRED,
85
+ (buf.validate.field).uint64.lte = 16777216
86
+ ];
87
+ }
88
+
89
+ // AccountPage represents a 4KB chunk for streaming account data.
90
+ message AccountPage {
91
+ uint32 page_idx = 1 [(google.api.field_behavior) = REQUIRED];
92
+ uint32 page_size = 2 [
93
+ (google.api.field_behavior) = REQUIRED,
94
+ (buf.validate.field).uint32.lte = 4096
95
+ ];
96
+ bytes page_data = 3 [
97
+ (google.api.field_behavior) = REQUIRED,
98
+ (buf.validate.field).bytes.max_len = 4096
99
+ ];
100
+ bool compressed = 4 [(google.api.field_behavior) = OPTIONAL];
101
+ string compression_algorithm = 5 [
102
+ (google.api.field_behavior) = OPTIONAL,
103
+ (buf.validate.field).string.max_len = 64
104
+ ];
105
+ }
106
+
107
+ // VersionContextMetadata captures context for a returned account state.
108
+ message VersionContextMetadata {
109
+ uint64 slot = 1 [(google.api.field_behavior) = OPTIONAL];
110
+ google.protobuf.Timestamp block_timestamp = 2
111
+ [(google.api.field_behavior) = OPTIONAL];
112
+ }
113
+
114
+ // Account models a fully decoded account resource.
115
+ message Account {
116
+ Pubkey address = 1 [(google.api.field_behavior) = REQUIRED];
117
+ AccountMeta meta = 2 [(google.api.field_behavior) = OPTIONAL];
118
+ AccountData data = 3 [(google.api.field_behavior) = OPTIONAL];
119
+ VersionContextMetadata version_context = 4
120
+ [(google.api.field_behavior) = OPTIONAL];
121
+ thru.common.v1.ConsensusStatus consensus_status = 5
122
+ [(google.api.field_behavior) = OPTIONAL];
123
+ }
124
+
125
+ // RawAccount captures raw serialized account bytes.
126
+ message RawAccount {
127
+ Pubkey address = 1 [(google.api.field_behavior) = REQUIRED];
128
+ bytes raw_meta = 2 [
129
+ (google.api.field_behavior) = REQUIRED,
130
+ (buf.validate.field).bytes.max_len = 4096
131
+ ];
132
+ bytes raw_data = 3 [
133
+ (google.api.field_behavior) = OPTIONAL,
134
+ (buf.validate.field).bytes.max_len = 16777216
135
+ ];
136
+ VersionContextMetadata version_context = 4
137
+ [(google.api.field_behavior) = OPTIONAL];
138
+ }
@@ -0,0 +1,82 @@
1
+ edition = "2023";
2
+
3
+ package thru.core.v1;
4
+
5
+ option features.field_presence = EXPLICIT;
6
+
7
+ import "buf/validate/validate.proto";
8
+ import "google/api/field_behavior.proto";
9
+ import "google/protobuf/timestamp.proto";
10
+ import "thru/common/v1/consensus.proto";
11
+ import "thru/core/v1/types.proto";
12
+
13
+ option go_package = "github.com/Unto-Labs/thru-net/grpc/pkg/proto/thru/core/v1;corev1";
14
+ option java_multiple_files = true;
15
+ option java_package = "network.thru.core.v1";
16
+ option csharp_namespace = "Thru.Core.V1";
17
+ option ruby_package = "Thru::Core::V1";
18
+ option objc_class_prefix = "THUC";
19
+ option swift_prefix = "THUC";
20
+
21
+ // BlockView controls how much of a block resource is returned.
22
+ enum BlockView {
23
+ BLOCK_VIEW_UNSPECIFIED = 0;
24
+ BLOCK_VIEW_HEADER_ONLY = 1;
25
+ BLOCK_VIEW_HEADER_AND_FOOTER = 2;
26
+ BLOCK_VIEW_BODY_ONLY = 3;
27
+ BLOCK_VIEW_FULL = 4;
28
+ }
29
+
30
+ // BlockHeader describes metadata about a block.
31
+ message BlockHeader {
32
+ uint64 slot = 1 [(google.api.field_behavior) = REQUIRED];
33
+ BlockHash block_hash = 2 [(google.api.field_behavior) = REQUIRED];
34
+ Signature header_signature = 3 [(google.api.field_behavior) = REQUIRED];
35
+ uint32 version = 4 [(google.api.field_behavior) = REQUIRED];
36
+ Pubkey producer = 5 [(google.api.field_behavior) = REQUIRED];
37
+ google.protobuf.Timestamp expiry_timestamp = 6
38
+ [(google.api.field_behavior) = OPTIONAL];
39
+ uint64 start_slot = 7 [(google.api.field_behavior) = OPTIONAL];
40
+ uint32 expiry_after = 8 [(google.api.field_behavior) = OPTIONAL];
41
+ uint32 max_block_size = 9 [(google.api.field_behavior) = OPTIONAL];
42
+ uint64 max_compute_units = 10 [(google.api.field_behavior) = OPTIONAL];
43
+ uint32 max_state_units = 11 [(google.api.field_behavior) = OPTIONAL];
44
+ uint64 price = 12 [(google.api.field_behavior) = OPTIONAL];
45
+ }
46
+
47
+ // ExecutionStatus enumerates block execution results.
48
+ enum ExecutionStatus {
49
+ EXECUTION_STATUS_UNSPECIFIED = 0;
50
+ EXECUTION_STATUS_PENDING = 1;
51
+ EXECUTION_STATUS_EXECUTED = 2;
52
+ EXECUTION_STATUS_FAILED = 3;
53
+ }
54
+
55
+ // BlockFooter captures execution result metadata for a block.
56
+ message BlockFooter {
57
+ Signature signature = 1 [(google.api.field_behavior) = REQUIRED];
58
+ ExecutionStatus status = 2 [(google.api.field_behavior) = REQUIRED];
59
+ uint64 consumed_compute_units = 3 [(google.api.field_behavior) = OPTIONAL];
60
+ uint32 consumed_state_units = 4 [(google.api.field_behavior) = OPTIONAL];
61
+ }
62
+
63
+ // Block represents a fully decoded block resource.
64
+ message Block {
65
+ BlockHeader header = 1 [(google.api.field_behavior) = REQUIRED];
66
+ BlockFooter footer = 2 [(google.api.field_behavior) = OPTIONAL];
67
+ bytes body = 3 [
68
+ (google.api.field_behavior) = OPTIONAL,
69
+ (buf.validate.field).bytes.max_len = 33554432
70
+ ];
71
+ thru.common.v1.ConsensusStatus consensus_status = 4
72
+ [(google.api.field_behavior) = OPTIONAL];
73
+ }
74
+
75
+ // RawBlock captures raw block bytes for direct access.
76
+ message RawBlock {
77
+ uint64 slot = 1 [(google.api.field_behavior) = REQUIRED];
78
+ bytes raw_block = 2 [
79
+ (google.api.field_behavior) = REQUIRED,
80
+ (buf.validate.field).bytes.max_len = 33554432
81
+ ];
82
+ }
@@ -0,0 +1,37 @@
1
+ edition = "2023";
2
+
3
+ package thru.core.v1;
4
+
5
+ option features.field_presence = EXPLICIT;
6
+
7
+ import "google/api/field_behavior.proto";
8
+ import "thru/core/v1/types.proto";
9
+
10
+ option go_package = "github.com/Unto-Labs/thru-net/grpc/pkg/proto/thru/core/v1;corev1";
11
+ option java_multiple_files = true;
12
+ option java_package = "network.thru.core.v1";
13
+ option csharp_namespace = "Thru.Core.V1";
14
+ option ruby_package = "Thru::Core::V1";
15
+ option objc_class_prefix = "THUC";
16
+ option swift_prefix = "THUC";
17
+
18
+ // StateProofType selects the type of state proof to generate.
19
+ enum StateProofType {
20
+ STATE_PROOF_TYPE_UNSPECIFIED = 0;
21
+ STATE_PROOF_TYPE_CREATING = 1;
22
+ STATE_PROOF_TYPE_UPDATING = 2;
23
+ STATE_PROOF_TYPE_EXISTING = 3;
24
+ }
25
+
26
+ // StateProofRequest describes a request to generate an account state proof.
27
+ message StateProofRequest {
28
+ Pubkey address = 1 [(google.api.field_behavior) = REQUIRED];
29
+ StateProofType proof_type = 2 [(google.api.field_behavior) = REQUIRED];
30
+ uint64 target_slot = 3 [(google.api.field_behavior) = OPTIONAL];
31
+ }
32
+
33
+ // StateProof returns binary proof data along with context.
34
+ message StateProof {
35
+ bytes proof = 1 [(google.api.field_behavior) = REQUIRED];
36
+ uint64 slot = 2 [(google.api.field_behavior) = REQUIRED];
37
+ }
@@ -0,0 +1,95 @@
1
+ edition = "2023";
2
+
3
+ package thru.core.v1;
4
+
5
+ option features.field_presence = EXPLICIT;
6
+
7
+ import "buf/validate/validate.proto";
8
+ import "google/api/field_behavior.proto";
9
+ import "thru/core/v1/types.proto";
10
+
11
+ option go_package = "github.com/Unto-Labs/thru-net/grpc/pkg/proto/thru/core/v1;corev1";
12
+ option java_multiple_files = true;
13
+ option java_package = "network.thru.core.v1";
14
+ option csharp_namespace = "Thru.Core.V1";
15
+ option ruby_package = "Thru::Core::V1";
16
+ option objc_class_prefix = "THUC";
17
+ option swift_prefix = "THUC";
18
+
19
+ // TransactionView controls how transactions are materialized in responses.
20
+ enum TransactionView {
21
+ TRANSACTION_VIEW_UNSPECIFIED = 0;
22
+ TRANSACTION_VIEW_SIGNATURE_ONLY = 1;
23
+ TRANSACTION_VIEW_HEADER_ONLY = 2;
24
+ TRANSACTION_VIEW_HEADER_AND_BODY = 3;
25
+ TRANSACTION_VIEW_FULL = 4;
26
+ }
27
+
28
+ // TransactionHeader carries structured metadata for a transaction.
29
+ message TransactionHeader {
30
+ Signature fee_payer_signature = 1 [(google.api.field_behavior) = REQUIRED];
31
+ uint32 version = 2 [(google.api.field_behavior) = REQUIRED];
32
+ uint32 flags = 3 [(google.api.field_behavior) = OPTIONAL];
33
+ uint32 readwrite_accounts_count = 4 [(google.api.field_behavior) = OPTIONAL];
34
+ uint32 readonly_accounts_count = 5 [(google.api.field_behavior) = OPTIONAL];
35
+ uint32 instruction_data_size = 6 [(google.api.field_behavior) = OPTIONAL];
36
+ uint32 requested_compute_units = 7 [(google.api.field_behavior) = OPTIONAL];
37
+ uint32 requested_state_units = 8 [(google.api.field_behavior) = OPTIONAL];
38
+ uint32 requested_memory_units = 9 [(google.api.field_behavior) = OPTIONAL];
39
+ uint32 expiry_after = 10 [(google.api.field_behavior) = OPTIONAL];
40
+ uint64 fee = 11 [(google.api.field_behavior) = OPTIONAL];
41
+ uint64 nonce = 12 [(google.api.field_behavior) = OPTIONAL];
42
+ uint64 start_slot = 13 [(google.api.field_behavior) = OPTIONAL];
43
+ Pubkey fee_payer_pubkey = 14 [(google.api.field_behavior) = OPTIONAL];
44
+ Pubkey program_pubkey = 15 [(google.api.field_behavior) = OPTIONAL];
45
+ }
46
+
47
+ // TransactionExecutionResult captures execution outcomes.
48
+ message TransactionExecutionResult {
49
+ uint32 consumed_compute_units = 1 [(google.api.field_behavior) = OPTIONAL];
50
+ uint32 consumed_memory_units = 2 [(google.api.field_behavior) = OPTIONAL];
51
+ uint32 consumed_state_units = 3 [(google.api.field_behavior) = OPTIONAL];
52
+ uint64 user_error_code = 4 [(google.api.field_behavior) = OPTIONAL];
53
+ uint32 vm_error = 5 [(google.api.field_behavior) = OPTIONAL];
54
+ uint64 execution_result = 6 [(google.api.field_behavior) = OPTIONAL];
55
+ uint32 pages_used = 7 [(google.api.field_behavior) = OPTIONAL];
56
+ uint32 events_count = 8 [(google.api.field_behavior) = OPTIONAL];
57
+ uint32 events_size = 9 [(google.api.field_behavior) = OPTIONAL];
58
+ repeated Pubkey readwrite_accounts = 10
59
+ [(google.api.field_behavior) = OPTIONAL];
60
+ repeated Pubkey readonly_accounts = 11
61
+ [(google.api.field_behavior) = OPTIONAL];
62
+ repeated TransactionEvent events = 12
63
+ [(google.api.field_behavior) = OPTIONAL];
64
+ }
65
+ // TransactionEvent describes an event emitted during transaction execution.
66
+ message TransactionEvent {
67
+ string event_id = 1 [(google.api.field_behavior) = OPTIONAL];
68
+ uint32 call_idx = 2 [(google.api.field_behavior) = OPTIONAL];
69
+ uint32 program_idx = 3 [(google.api.field_behavior) = OPTIONAL];
70
+ Pubkey program = 4 [(google.api.field_behavior) = OPTIONAL];
71
+ bytes payload = 5 [(google.api.field_behavior) = OPTIONAL];
72
+ }
73
+
74
+ // Transaction describes a fully decoded transaction resource.
75
+ message Transaction {
76
+ Signature signature = 1 [(google.api.field_behavior) = REQUIRED];
77
+ TransactionHeader header = 2 [(google.api.field_behavior) = OPTIONAL];
78
+ bytes body = 3 [
79
+ (google.api.field_behavior) = OPTIONAL,
80
+ (buf.validate.field).bytes.max_len = 16777216
81
+ ];
82
+ TransactionExecutionResult execution_result = 4
83
+ [(google.api.field_behavior) = OPTIONAL];
84
+ uint64 slot = 5 [(google.api.field_behavior) = OPTIONAL];
85
+ uint32 block_offset = 6 [(google.api.field_behavior) = OPTIONAL];
86
+ }
87
+
88
+ // RawTransaction provides direct access to serialized transaction bytes.
89
+ message RawTransaction {
90
+ Signature signature = 1 [(google.api.field_behavior) = REQUIRED];
91
+ bytes raw_transaction = 2 [
92
+ (google.api.field_behavior) = REQUIRED,
93
+ (buf.validate.field).bytes.max_len = 16777216
94
+ ];
95
+ }
@@ -0,0 +1,52 @@
1
+ edition = "2023";
2
+
3
+ package thru.core.v1;
4
+
5
+ option features.field_presence = EXPLICIT;
6
+
7
+ import "buf/validate/validate.proto";
8
+ import "google/api/field_behavior.proto";
9
+
10
+ option go_package = "github.com/Unto-Labs/thru-net/grpc/pkg/proto/thru/core/v1;corev1";
11
+ option java_multiple_files = true;
12
+ option java_package = "network.thru.core.v1";
13
+ option csharp_namespace = "Thru.Core.V1";
14
+ option ruby_package = "Thru::Core::V1";
15
+ option objc_class_prefix = "THUC";
16
+ option swift_prefix = "THUC";
17
+
18
+ // Pubkey represents a 32-byte public key value.
19
+ message Pubkey {
20
+ // 32-byte public key buffer.
21
+ bytes value = 1 [
22
+ (google.api.field_behavior) = REQUIRED,
23
+ (buf.validate.field).bytes.len = 32
24
+ ];
25
+ }
26
+
27
+ // Hash represents a 32-byte hash value.
28
+ message Hash {
29
+ // 32-byte hash buffer.
30
+ bytes value = 1 [
31
+ (google.api.field_behavior) = REQUIRED,
32
+ (buf.validate.field).bytes.len = 32
33
+ ];
34
+ }
35
+
36
+ // BlockHash represents a 64-byte hash for block identifiers.
37
+ message BlockHash {
38
+ // 64-byte block hash buffer.
39
+ bytes value = 1 [
40
+ (google.api.field_behavior) = REQUIRED,
41
+ (buf.validate.field).bytes.len = 64
42
+ ];
43
+ }
44
+
45
+ // Signature represents a 64-byte signature value.
46
+ message Signature {
47
+ // 64-byte signature buffer.
48
+ bytes value = 1 [
49
+ (google.api.field_behavior) = REQUIRED,
50
+ (buf.validate.field).bytes.len = 64
51
+ ];
52
+ }