@gnolang/tm2-js-client 1.0.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.
- package/LICENSE.md +201 -0
- package/README.md +78 -0
- package/bin/index.d.ts +4 -0
- package/bin/index.js +20 -0
- package/bin/proto/google/protobuf/any.d.ts +151 -0
- package/bin/proto/google/protobuf/any.js +124 -0
- package/bin/proto/index.d.ts +2 -0
- package/bin/proto/index.js +20 -0
- package/bin/proto/tm2/tx.d.ts +540 -0
- package/bin/proto/tm2/tx.js +365 -0
- package/bin/provider/endpoints.d.ts +28 -0
- package/bin/provider/endpoints.js +36 -0
- package/bin/provider/index.d.ts +6 -0
- package/bin/provider/index.js +22 -0
- package/bin/provider/jsonrpc/index.d.ts +1 -0
- package/bin/provider/jsonrpc/index.js +17 -0
- package/bin/provider/jsonrpc/jsonrpc.d.ts +27 -0
- package/bin/provider/jsonrpc/jsonrpc.js +219 -0
- package/bin/provider/jsonrpc/jsonrpc.test.d.ts +1 -0
- package/bin/provider/jsonrpc/jsonrpc.test.js +374 -0
- package/bin/provider/provider.d.ts +86 -0
- package/bin/provider/provider.js +2 -0
- package/bin/provider/types/abci.d.ts +39 -0
- package/bin/provider/types/abci.js +4 -0
- package/bin/provider/types/common.d.ts +154 -0
- package/bin/provider/types/common.js +2 -0
- package/bin/provider/types/index.d.ts +3 -0
- package/bin/provider/types/index.js +19 -0
- package/bin/provider/types/jsonrpc.d.ts +26 -0
- package/bin/provider/types/jsonrpc.js +2 -0
- package/bin/provider/utility/index.d.ts +2 -0
- package/bin/provider/utility/index.js +18 -0
- package/bin/provider/utility/provider.utility.d.ts +28 -0
- package/bin/provider/utility/provider.utility.js +194 -0
- package/bin/provider/utility/requests.utility.d.ts +33 -0
- package/bin/provider/utility/requests.utility.js +74 -0
- package/bin/provider/websocket/index.d.ts +1 -0
- package/bin/provider/websocket/index.js +17 -0
- package/bin/provider/websocket/ws.d.ts +55 -0
- package/bin/provider/websocket/ws.js +303 -0
- package/bin/provider/websocket/ws.test.d.ts +1 -0
- package/bin/provider/websocket/ws.test.js +535 -0
- package/bin/services/index.d.ts +2 -0
- package/bin/services/index.js +18 -0
- package/bin/services/rest/restService.d.ts +4 -0
- package/bin/services/rest/restService.js +72 -0
- package/bin/services/rest/restService.types.d.ts +6 -0
- package/bin/services/rest/restService.types.js +2 -0
- package/bin/wallet/index.d.ts +5 -0
- package/bin/wallet/index.js +21 -0
- package/bin/wallet/key/index.d.ts +1 -0
- package/bin/wallet/key/index.js +17 -0
- package/bin/wallet/key/key.d.ts +21 -0
- package/bin/wallet/key/key.js +102 -0
- package/bin/wallet/key/key.test.d.ts +1 -0
- package/bin/wallet/key/key.test.js +121 -0
- package/bin/wallet/ledger/index.d.ts +1 -0
- package/bin/wallet/ledger/index.js +17 -0
- package/bin/wallet/ledger/ledger.d.ts +22 -0
- package/bin/wallet/ledger/ledger.js +109 -0
- package/bin/wallet/signer.d.ts +29 -0
- package/bin/wallet/signer.js +2 -0
- package/bin/wallet/types/index.d.ts +2 -0
- package/bin/wallet/types/index.js +18 -0
- package/bin/wallet/types/sign.d.ts +17 -0
- package/bin/wallet/types/sign.js +4 -0
- package/bin/wallet/types/wallet.d.ts +5 -0
- package/bin/wallet/types/wallet.js +2 -0
- package/bin/wallet/utility/index.d.ts +1 -0
- package/bin/wallet/utility/index.js +17 -0
- package/bin/wallet/utility/utility.d.ts +30 -0
- package/bin/wallet/utility/utility.js +105 -0
- package/bin/wallet/wallet.d.ts +94 -0
- package/bin/wallet/wallet.js +340 -0
- package/bin/wallet/wallet.test.d.ts +1 -0
- package/bin/wallet/wallet.test.js +345 -0
- package/package.json +64 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
<h2 align="center">⚛️ Tendermint2 JS/TS Client ⚛️</h2>
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
`@gnolang/tm2-js-client` is a JavaScript/TypeScript client implementation for Tendermint2-based chains. It is designed
|
|
6
|
+
to make it
|
|
7
|
+
easy for developers to interact with TM2 chains, providing a simplified API for account and transaction management. By
|
|
8
|
+
doing all the heavy lifting behind the scenes, `@gnolang/tm2-js-client` enables developers to focus on what really
|
|
9
|
+
matters -
|
|
10
|
+
building their dApps.
|
|
11
|
+
|
|
12
|
+
## Key Features
|
|
13
|
+
|
|
14
|
+
- JSON-RPC and WebSocket client support via a `Provider`
|
|
15
|
+
- Simple account and transaction management API with a `Wallet`
|
|
16
|
+
- Designed for easy extension for custom TM2 chains, such as [Gnoland](https://gno.land)
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
To install `@gnolang/tm2-js-client`, use your preferred package manager:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
yarn add @gnolang/tm2-js-client
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
npm install @gnolang/tm2-js-client
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Common Terminology
|
|
31
|
+
|
|
32
|
+
### Provider
|
|
33
|
+
|
|
34
|
+
A `Provider` is an interface that abstracts the interaction with the Tendermint2 chain, making it easier for users to
|
|
35
|
+
communicate with it. Rather than requiring users to understand which endpoints are exposed, what their return types are,
|
|
36
|
+
and how they are parsed, the `Provider` abstraction handles all of this behind the scenes. It exposes useful API methods
|
|
37
|
+
that users can use and expects concrete types in return.
|
|
38
|
+
|
|
39
|
+
Currently, the `@gnolang/tm2-js-client` package provides support for two Provider implementations:
|
|
40
|
+
|
|
41
|
+
- `JSON-RPC Provider`: executes each call as a separate HTTP RPC call.
|
|
42
|
+
- `WS Provider`: executes each call through an active WebSocket connection, which requires closing when not needed
|
|
43
|
+
anymore.
|
|
44
|
+
|
|
45
|
+
### Signer
|
|
46
|
+
|
|
47
|
+
A `Signer` is an interface that abstracts the interaction with a single Secp256k1 key pair. It exposes methods for
|
|
48
|
+
signing data, verifying signatures, and getting metadata associated with the key pair, such as the address.
|
|
49
|
+
|
|
50
|
+
Currently, the `@gnolang/tm2-js-client` package provides support for two `Signer` implementations:
|
|
51
|
+
|
|
52
|
+
- `Key`: a signer that is based on a raw Secp256k1 key pair.
|
|
53
|
+
- `Ledger`: a signer that is based on a Ledger device, with all interaction flowing through the user's device.
|
|
54
|
+
|
|
55
|
+
### Wallet
|
|
56
|
+
|
|
57
|
+
A `Wallet` is a user-facing API that is used to interact with an account. A `Wallet` instance is tied to a single key
|
|
58
|
+
pair and essentially wraps the given `Provider` for that specific account.
|
|
59
|
+
|
|
60
|
+
A wallet can be generated from a randomly generated seed, a private key, or instantiated using a Ledger device.
|
|
61
|
+
|
|
62
|
+
Using the `Wallet`, users can easily interact with the Tendermint2 chain using their account without having to worry
|
|
63
|
+
about account management.
|
|
64
|
+
|
|
65
|
+
## Documentation
|
|
66
|
+
|
|
67
|
+
For the sake of keeping the README short and sweet, you can find the documentation and usage examples
|
|
68
|
+
for the package [here](https://onbloc.gitbook.io/gnoland-developer-portal/docs/tm2-js-client).
|
|
69
|
+
|
|
70
|
+
## Acknowledgements
|
|
71
|
+
|
|
72
|
+
`@gnolang/tm2-js-client` is, and will continue to be, [licensed under Apache 2](LICENSE).
|
|
73
|
+
|
|
74
|
+
It is made by the community, for the community, and any contribution is greatly appreciated.
|
|
75
|
+
|
|
76
|
+
A special thank-you goes out to the [Onbloc](https://github.com/onbloc) team, building
|
|
77
|
+
[Adena wallet](https://github.com/onbloc/adena-wallet) and other gno projects, whose extended supported
|
|
78
|
+
made this package possible.
|
package/bin/index.d.ts
ADDED
package/bin/index.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./provider"), exports);
|
|
18
|
+
__exportStar(require("./wallet"), exports);
|
|
19
|
+
__exportStar(require("./proto"), exports);
|
|
20
|
+
__exportStar(require("./services"), exports);
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import Long from 'long';
|
|
2
|
+
import _m0 from 'protobufjs/minimal';
|
|
3
|
+
export declare const protobufPackage = "google.protobuf";
|
|
4
|
+
/**
|
|
5
|
+
* `Any` contains an arbitrary serialized protocol buffer message along with a
|
|
6
|
+
* URL that describes the type of the serialized message.
|
|
7
|
+
*
|
|
8
|
+
* Protobuf library provides support to pack/unpack Any values in the form
|
|
9
|
+
* of utility functions or additional generated methods of the Any type.
|
|
10
|
+
*
|
|
11
|
+
* Example 1: Pack and unpack a message in C++.
|
|
12
|
+
*
|
|
13
|
+
* Foo foo = ...;
|
|
14
|
+
* Any any;
|
|
15
|
+
* any.PackFrom(foo);
|
|
16
|
+
* ...
|
|
17
|
+
* if (any.UnpackTo(&foo)) {
|
|
18
|
+
* ...
|
|
19
|
+
* }
|
|
20
|
+
*
|
|
21
|
+
* Example 2: Pack and unpack a message in Java.
|
|
22
|
+
*
|
|
23
|
+
* Foo foo = ...;
|
|
24
|
+
* Any any = Any.pack(foo);
|
|
25
|
+
* ...
|
|
26
|
+
* if (any.is(Foo.class)) {
|
|
27
|
+
* foo = any.unpack(Foo.class);
|
|
28
|
+
* }
|
|
29
|
+
*
|
|
30
|
+
* Example 3: Pack and unpack a message in Python.
|
|
31
|
+
*
|
|
32
|
+
* foo = Foo(...)
|
|
33
|
+
* any = Any()
|
|
34
|
+
* any.Pack(foo)
|
|
35
|
+
* ...
|
|
36
|
+
* if any.Is(Foo.DESCRIPTOR):
|
|
37
|
+
* any.Unpack(foo)
|
|
38
|
+
* ...
|
|
39
|
+
*
|
|
40
|
+
* Example 4: Pack and unpack a message in Go
|
|
41
|
+
*
|
|
42
|
+
* foo := &pb.Foo{...}
|
|
43
|
+
* any, err := anypb.New(foo)
|
|
44
|
+
* if err != nil {
|
|
45
|
+
* ...
|
|
46
|
+
* }
|
|
47
|
+
* ...
|
|
48
|
+
* foo := &pb.Foo{}
|
|
49
|
+
* if err := any.UnmarshalTo(foo); err != nil {
|
|
50
|
+
* ...
|
|
51
|
+
* }
|
|
52
|
+
*
|
|
53
|
+
* The pack methods provided by protobuf library will by default use
|
|
54
|
+
* 'type.googleapis.com/full.type.name' as the type URL and the unpack
|
|
55
|
+
* methods only use the fully qualified type name after the last '/'
|
|
56
|
+
* in the type URL, for example "foo.bar.com/x/y.z" will yield type
|
|
57
|
+
* name "y.z".
|
|
58
|
+
*
|
|
59
|
+
* JSON
|
|
60
|
+
*
|
|
61
|
+
* The JSON representation of an `Any` value uses the regular
|
|
62
|
+
* representation of the deserialized, embedded message, with an
|
|
63
|
+
* additional field `@type` which contains the type URL. Example:
|
|
64
|
+
*
|
|
65
|
+
* package google.profile;
|
|
66
|
+
* message Person {
|
|
67
|
+
* string first_name = 1;
|
|
68
|
+
* string last_name = 2;
|
|
69
|
+
* }
|
|
70
|
+
*
|
|
71
|
+
* {
|
|
72
|
+
* "@type": "type.googleapis.com/google.profile.Person",
|
|
73
|
+
* "firstName": <string>,
|
|
74
|
+
* "lastName": <string>
|
|
75
|
+
* }
|
|
76
|
+
*
|
|
77
|
+
* If the embedded message type is well-known and has a custom JSON
|
|
78
|
+
* representation, that representation will be embedded adding a field
|
|
79
|
+
* `value` which holds the custom JSON in addition to the `@type`
|
|
80
|
+
* field. Example (for message [google.protobuf.Duration][]):
|
|
81
|
+
*
|
|
82
|
+
* {
|
|
83
|
+
* "@type": "type.googleapis.com/google.protobuf.Duration",
|
|
84
|
+
* "value": "1.212s"
|
|
85
|
+
* }
|
|
86
|
+
*/
|
|
87
|
+
export interface Any {
|
|
88
|
+
/**
|
|
89
|
+
* A URL/resource name that uniquely identifies the type of the serialized
|
|
90
|
+
* protocol buffer message. This string must contain at least
|
|
91
|
+
* one "/" character. The last segment of the URL's path must represent
|
|
92
|
+
* the fully qualified name of the type (as in
|
|
93
|
+
* `path/google.protobuf.Duration`). The name should be in a canonical form
|
|
94
|
+
* (e.g., leading "." is not accepted).
|
|
95
|
+
*
|
|
96
|
+
* In practice, teams usually precompile into the binary all types that they
|
|
97
|
+
* expect it to use in the context of Any. However, for URLs which use the
|
|
98
|
+
* scheme `http`, `https`, or no scheme, one can optionally set up a type
|
|
99
|
+
* server that maps type URLs to message definitions as follows:
|
|
100
|
+
*
|
|
101
|
+
* * If no scheme is provided, `https` is assumed.
|
|
102
|
+
* * An HTTP GET on the URL must yield a [google.protobuf.Type][]
|
|
103
|
+
* value in binary format, or produce an error.
|
|
104
|
+
* * Applications are allowed to cache lookup results based on the
|
|
105
|
+
* URL, or have them precompiled into a binary to avoid any
|
|
106
|
+
* lookup. Therefore, binary compatibility needs to be preserved
|
|
107
|
+
* on changes to types. (Use versioned type names to manage
|
|
108
|
+
* breaking changes.)
|
|
109
|
+
*
|
|
110
|
+
* Note: this functionality is not currently available in the official
|
|
111
|
+
* protobuf release, and it is not used for type URLs beginning with
|
|
112
|
+
* type.googleapis.com.
|
|
113
|
+
*
|
|
114
|
+
* Schemes other than `http`, `https` (or the empty scheme) might be
|
|
115
|
+
* used with implementation specific semantics.
|
|
116
|
+
*/
|
|
117
|
+
typeUrl: string;
|
|
118
|
+
/** Must be a valid serialized protocol buffer of the above specified type. */
|
|
119
|
+
value: Uint8Array;
|
|
120
|
+
}
|
|
121
|
+
export declare const Any: {
|
|
122
|
+
encode(message: Any, writer?: _m0.Writer): _m0.Writer;
|
|
123
|
+
decode(input: _m0.Reader | Uint8Array, length?: number): Any;
|
|
124
|
+
fromJSON(object: any): Any;
|
|
125
|
+
toJSON(message: Any): unknown;
|
|
126
|
+
create<I extends {
|
|
127
|
+
typeUrl?: string | undefined;
|
|
128
|
+
value?: Uint8Array | undefined;
|
|
129
|
+
} & {
|
|
130
|
+
typeUrl?: string | undefined;
|
|
131
|
+
value?: Uint8Array | undefined;
|
|
132
|
+
} & { [K in Exclude<keyof I, keyof Any>]: never; }>(base?: I | undefined): Any;
|
|
133
|
+
fromPartial<I_1 extends {
|
|
134
|
+
typeUrl?: string | undefined;
|
|
135
|
+
value?: Uint8Array | undefined;
|
|
136
|
+
} & {
|
|
137
|
+
typeUrl?: string | undefined;
|
|
138
|
+
value?: Uint8Array | undefined;
|
|
139
|
+
} & { [K_1 in Exclude<keyof I_1, keyof Any>]: never; }>(object: I_1): Any;
|
|
140
|
+
};
|
|
141
|
+
type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
|
|
142
|
+
export type DeepPartial<T> = T extends Builtin ? T : T extends Long ? string | number | Long : T extends Array<infer U> ? Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends {} ? {
|
|
143
|
+
[K in keyof T]?: DeepPartial<T[K]>;
|
|
144
|
+
} : Partial<T>;
|
|
145
|
+
type KeysOfUnion<T> = T extends T ? keyof T : never;
|
|
146
|
+
export type Exact<P, I extends P> = P extends Builtin ? P : P & {
|
|
147
|
+
[K in keyof P]: Exact<P[K], I[K]>;
|
|
148
|
+
} & {
|
|
149
|
+
[K in Exclude<keyof I, KeysOfUnion<P>>]: never;
|
|
150
|
+
};
|
|
151
|
+
export {};
|
|
@@ -0,0 +1,124 @@
|
|
|
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.Any = exports.protobufPackage = void 0;
|
|
7
|
+
/* eslint-disable */
|
|
8
|
+
var long_1 = __importDefault(require("long"));
|
|
9
|
+
var minimal_1 = __importDefault(require("protobufjs/minimal"));
|
|
10
|
+
exports.protobufPackage = 'google.protobuf';
|
|
11
|
+
function createBaseAny() {
|
|
12
|
+
return { typeUrl: '', value: new Uint8Array() };
|
|
13
|
+
}
|
|
14
|
+
exports.Any = {
|
|
15
|
+
encode: function (message, writer) {
|
|
16
|
+
if (writer === void 0) { writer = minimal_1.default.Writer.create(); }
|
|
17
|
+
if (message.typeUrl !== '') {
|
|
18
|
+
writer.uint32(10).string(message.typeUrl);
|
|
19
|
+
}
|
|
20
|
+
if (message.value.length !== 0) {
|
|
21
|
+
writer.uint32(18).bytes(message.value);
|
|
22
|
+
}
|
|
23
|
+
return writer;
|
|
24
|
+
},
|
|
25
|
+
decode: function (input, length) {
|
|
26
|
+
var reader = input instanceof minimal_1.default.Reader ? input : minimal_1.default.Reader.create(input);
|
|
27
|
+
var end = length === undefined ? reader.len : reader.pos + length;
|
|
28
|
+
var message = createBaseAny();
|
|
29
|
+
while (reader.pos < end) {
|
|
30
|
+
var tag = reader.uint32();
|
|
31
|
+
switch (tag >>> 3) {
|
|
32
|
+
case 1:
|
|
33
|
+
if (tag != 10) {
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
message.typeUrl = reader.string();
|
|
37
|
+
continue;
|
|
38
|
+
case 2:
|
|
39
|
+
if (tag != 18) {
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
message.value = reader.bytes();
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
if ((tag & 7) == 4 || tag == 0) {
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
reader.skipType(tag & 7);
|
|
49
|
+
}
|
|
50
|
+
return message;
|
|
51
|
+
},
|
|
52
|
+
fromJSON: function (object) {
|
|
53
|
+
return {
|
|
54
|
+
typeUrl: isSet(object.typeUrl) ? String(object.typeUrl) : '',
|
|
55
|
+
value: isSet(object.value)
|
|
56
|
+
? bytesFromBase64(object.value)
|
|
57
|
+
: new Uint8Array(),
|
|
58
|
+
};
|
|
59
|
+
},
|
|
60
|
+
toJSON: function (message) {
|
|
61
|
+
var obj = {};
|
|
62
|
+
message.typeUrl !== undefined && (obj.typeUrl = message.typeUrl);
|
|
63
|
+
message.value !== undefined &&
|
|
64
|
+
(obj.value = base64FromBytes(message.value !== undefined ? message.value : new Uint8Array()));
|
|
65
|
+
return obj;
|
|
66
|
+
},
|
|
67
|
+
create: function (base) {
|
|
68
|
+
return exports.Any.fromPartial(base !== null && base !== void 0 ? base : {});
|
|
69
|
+
},
|
|
70
|
+
fromPartial: function (object) {
|
|
71
|
+
var _a, _b;
|
|
72
|
+
var message = createBaseAny();
|
|
73
|
+
message.typeUrl = (_a = object.typeUrl) !== null && _a !== void 0 ? _a : '';
|
|
74
|
+
message.value = (_b = object.value) !== null && _b !== void 0 ? _b : new Uint8Array();
|
|
75
|
+
return message;
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
var tsProtoGlobalThis = (function () {
|
|
79
|
+
if (typeof globalThis !== 'undefined') {
|
|
80
|
+
return globalThis;
|
|
81
|
+
}
|
|
82
|
+
if (typeof self !== 'undefined') {
|
|
83
|
+
return self;
|
|
84
|
+
}
|
|
85
|
+
if (typeof window !== 'undefined') {
|
|
86
|
+
return window;
|
|
87
|
+
}
|
|
88
|
+
if (typeof global !== 'undefined') {
|
|
89
|
+
return global;
|
|
90
|
+
}
|
|
91
|
+
throw 'Unable to locate global object';
|
|
92
|
+
})();
|
|
93
|
+
function bytesFromBase64(b64) {
|
|
94
|
+
if (tsProtoGlobalThis.Buffer) {
|
|
95
|
+
return Uint8Array.from(tsProtoGlobalThis.Buffer.from(b64, 'base64'));
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
var bin = tsProtoGlobalThis.atob(b64);
|
|
99
|
+
var arr = new Uint8Array(bin.length);
|
|
100
|
+
for (var i = 0; i < bin.length; ++i) {
|
|
101
|
+
arr[i] = bin.charCodeAt(i);
|
|
102
|
+
}
|
|
103
|
+
return arr;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
function base64FromBytes(arr) {
|
|
107
|
+
if (tsProtoGlobalThis.Buffer) {
|
|
108
|
+
return tsProtoGlobalThis.Buffer.from(arr).toString('base64');
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
var bin_1 = [];
|
|
112
|
+
arr.forEach(function (byte) {
|
|
113
|
+
bin_1.push(String.fromCharCode(byte));
|
|
114
|
+
});
|
|
115
|
+
return tsProtoGlobalThis.btoa(bin_1.join(''));
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
if (minimal_1.default.util.Long !== long_1.default) {
|
|
119
|
+
minimal_1.default.util.Long = long_1.default;
|
|
120
|
+
minimal_1.default.configure();
|
|
121
|
+
}
|
|
122
|
+
function isSet(value) {
|
|
123
|
+
return value !== null && value !== undefined;
|
|
124
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.Any = void 0;
|
|
18
|
+
__exportStar(require("./tm2/tx"), exports);
|
|
19
|
+
var any_1 = require("./google/protobuf/any");
|
|
20
|
+
Object.defineProperty(exports, "Any", { enumerable: true, get: function () { return any_1.Any; } });
|