@recoillink/cosmos-sdk 0.0.0-stage → 45.0.1
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 +193 -0
- package/README.md +82 -2
- package/dist/clients/protocol.d.ts +26 -0
- package/dist/clients/protocol.d.ts.map +1 -0
- package/dist/clients/protocol.js +72 -0
- package/dist/clients/protocol.js.map +1 -0
- package/dist/clients/provider.d.ts +34 -0
- package/dist/clients/provider.d.ts.map +1 -0
- package/dist/clients/provider.js +220 -0
- package/dist/clients/provider.js.map +1 -0
- package/dist/clients/signer.d.ts +25 -0
- package/dist/clients/signer.d.ts.map +1 -0
- package/dist/clients/signer.js +92 -0
- package/dist/clients/signer.js.map +1 -0
- package/dist/clients/stargate.d.ts +15 -0
- package/dist/clients/stargate.d.ts.map +1 -0
- package/dist/clients/stargate.js +81 -0
- package/dist/clients/stargate.js.map +1 -0
- package/dist/hook/hook-artifact-manager.d.ts +72 -0
- package/dist/hook/hook-artifact-manager.d.ts.map +1 -0
- package/dist/hook/hook-artifact-manager.js +139 -0
- package/dist/hook/hook-artifact-manager.js.map +1 -0
- package/dist/hook/hook-query.d.ts +42 -0
- package/dist/hook/hook-query.d.ts.map +1 -0
- package/dist/hook/hook-query.js +95 -0
- package/dist/hook/hook-query.js.map +1 -0
- package/dist/hook/hook-tx.d.ts +47 -0
- package/dist/hook/hook-tx.d.ts.map +1 -0
- package/dist/hook/hook-tx.js +76 -0
- package/dist/hook/hook-tx.js.map +1 -0
- package/dist/hook/igp-hook.d.ts +30 -0
- package/dist/hook/igp-hook.d.ts.map +1 -0
- package/dist/hook/igp-hook.js +150 -0
- package/dist/hook/igp-hook.js.map +1 -0
- package/dist/hook/merkle-tree-hook.d.ts +32 -0
- package/dist/hook/merkle-tree-hook.d.ts.map +1 -0
- package/dist/hook/merkle-tree-hook.js +60 -0
- package/dist/hook/merkle-tree-hook.js.map +1 -0
- package/dist/hyperlane/core/messages.d.ts +16 -0
- package/dist/hyperlane/core/messages.d.ts.map +1 -0
- package/dist/hyperlane/core/messages.js +2 -0
- package/dist/hyperlane/core/messages.js.map +1 -0
- package/dist/hyperlane/core/query.d.ts +18 -0
- package/dist/hyperlane/core/query.d.ts.map +1 -0
- package/dist/hyperlane/core/query.js +18 -0
- package/dist/hyperlane/core/query.js.map +1 -0
- package/dist/hyperlane/interchain_security/messages.d.ts +36 -0
- package/dist/hyperlane/interchain_security/messages.d.ts.map +1 -0
- package/dist/hyperlane/interchain_security/messages.js +2 -0
- package/dist/hyperlane/interchain_security/messages.js.map +1 -0
- package/dist/hyperlane/interchain_security/query.d.ts +36 -0
- package/dist/hyperlane/interchain_security/query.d.ts.map +1 -0
- package/dist/hyperlane/interchain_security/query.js +49 -0
- package/dist/hyperlane/interchain_security/query.js.map +1 -0
- package/dist/hyperlane/post_dispatch/messages.d.ts +32 -0
- package/dist/hyperlane/post_dispatch/messages.d.ts.map +1 -0
- package/dist/hyperlane/post_dispatch/messages.js +2 -0
- package/dist/hyperlane/post_dispatch/messages.js.map +1 -0
- package/dist/hyperlane/post_dispatch/query.d.ts +24 -0
- package/dist/hyperlane/post_dispatch/query.d.ts.map +1 -0
- package/dist/hyperlane/post_dispatch/query.js +21 -0
- package/dist/hyperlane/post_dispatch/query.js.map +1 -0
- package/dist/hyperlane/warp/messages.d.ts +28 -0
- package/dist/hyperlane/warp/messages.d.ts.map +1 -0
- package/dist/hyperlane/warp/messages.js +2 -0
- package/dist/hyperlane/warp/messages.js.map +1 -0
- package/dist/hyperlane/warp/query.d.ts +18 -0
- package/dist/hyperlane/warp/query.d.ts.map +1 -0
- package/dist/hyperlane/warp/query.js +16 -0
- package/dist/hyperlane/warp/query.js.map +1 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +37 -0
- package/dist/index.js.map +1 -0
- package/dist/ism/ism-artifact-manager.d.ts +69 -0
- package/dist/ism/ism-artifact-manager.d.ts.map +1 -0
- package/dist/ism/ism-artifact-manager.js +146 -0
- package/dist/ism/ism-artifact-manager.js.map +1 -0
- package/dist/ism/ism-query.d.ts +71 -0
- package/dist/ism/ism-query.d.ts.map +1 -0
- package/dist/ism/ism-query.js +133 -0
- package/dist/ism/ism-query.js.map +1 -0
- package/dist/ism/ism-tx.d.ts +30 -0
- package/dist/ism/ism-tx.d.ts.map +1 -0
- package/dist/ism/ism-tx.js +76 -0
- package/dist/ism/ism-tx.js.map +1 -0
- package/dist/ism/multisig-ism.d.ts +51 -0
- package/dist/ism/multisig-ism.d.ts.map +1 -0
- package/dist/ism/multisig-ism.js +120 -0
- package/dist/ism/multisig-ism.js.map +1 -0
- package/dist/ism/routing-ism.d.ts +30 -0
- package/dist/ism/routing-ism.d.ts.map +1 -0
- package/dist/ism/routing-ism.js +137 -0
- package/dist/ism/routing-ism.js.map +1 -0
- package/dist/ism/test-ism.d.ts +29 -0
- package/dist/ism/test-ism.d.ts.map +1 -0
- package/dist/ism/test-ism.js +56 -0
- package/dist/ism/test-ism.js.map +1 -0
- package/dist/mailbox/mailbox-artifact-manager.d.ts +48 -0
- package/dist/mailbox/mailbox-artifact-manager.d.ts.map +1 -0
- package/dist/mailbox/mailbox-artifact-manager.js +82 -0
- package/dist/mailbox/mailbox-artifact-manager.js.map +1 -0
- package/dist/mailbox/mailbox-query.d.ts +12 -0
- package/dist/mailbox/mailbox-query.d.ts.map +1 -0
- package/dist/mailbox/mailbox-query.js +29 -0
- package/dist/mailbox/mailbox-query.js.map +1 -0
- package/dist/mailbox/mailbox-tx.d.ts +37 -0
- package/dist/mailbox/mailbox-tx.d.ts.map +1 -0
- package/dist/mailbox/mailbox-tx.js +68 -0
- package/dist/mailbox/mailbox-tx.js.map +1 -0
- package/dist/mailbox/mailbox.d.ts +30 -0
- package/dist/mailbox/mailbox.d.ts.map +1 -0
- package/dist/mailbox/mailbox.js +168 -0
- package/dist/mailbox/mailbox.js.map +1 -0
- package/dist/registry.d.ts +21 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +373 -0
- package/dist/registry.js.map +1 -0
- package/dist/runtime.d.ts +5 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +4 -0
- package/dist/runtime.js.map +1 -0
- package/dist/testing/constants.d.ts +10 -0
- package/dist/testing/constants.d.ts.map +1 -0
- package/dist/testing/constants.js +34 -0
- package/dist/testing/constants.js.map +1 -0
- package/dist/testing/index.d.ts +8 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +10 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/testing/node.d.ts +4 -0
- package/dist/testing/node.d.ts.map +1 -0
- package/dist/testing/node.js +35 -0
- package/dist/testing/node.js.map +1 -0
- package/dist/testing/utils.d.ts +11 -0
- package/dist/testing/utils.d.ts.map +1 -0
- package/dist/testing/utils.js +21 -0
- package/dist/testing/utils.js.map +1 -0
- package/dist/tests/5_warp_artifact.e2e-test.d.ts +2 -0
- package/dist/tests/5_warp_artifact.e2e-test.d.ts.map +1 -0
- package/dist/tests/5_warp_artifact.e2e-test.js +554 -0
- package/dist/tests/5_warp_artifact.e2e-test.js.map +1 -0
- package/dist/tests/e2e-test.setup.d.ts +2 -0
- package/dist/tests/e2e-test.setup.d.ts.map +1 -0
- package/dist/tests/e2e-test.setup.js +13 -0
- package/dist/tests/e2e-test.setup.js.map +1 -0
- package/dist/tests/hooks.e2e-test.d.ts +2 -0
- package/dist/tests/hooks.e2e-test.d.ts.map +1 -0
- package/dist/tests/hooks.e2e-test.js +350 -0
- package/dist/tests/hooks.e2e-test.js.map +1 -0
- package/dist/tests/ism.e2e-test.d.ts +2 -0
- package/dist/tests/ism.e2e-test.d.ts.map +1 -0
- package/dist/tests/ism.e2e-test.js +249 -0
- package/dist/tests/ism.e2e-test.js.map +1 -0
- package/dist/tests/mailbox.e2e-test.d.ts +2 -0
- package/dist/tests/mailbox.e2e-test.d.ts.map +1 -0
- package/dist/tests/mailbox.e2e-test.js +356 -0
- package/dist/tests/mailbox.e2e-test.js.map +1 -0
- package/dist/tests/warp-deploy-gas.unit-test.d.ts +2 -0
- package/dist/tests/warp-deploy-gas.unit-test.d.ts.map +1 -0
- package/dist/tests/warp-deploy-gas.unit-test.js +44 -0
- package/dist/tests/warp-deploy-gas.unit-test.js.map +1 -0
- package/dist/utils/base.d.ts +22 -0
- package/dist/utils/base.d.ts.map +1 -0
- package/dist/utils/base.js +35 -0
- package/dist/utils/base.js.map +1 -0
- package/dist/utils/types.d.ts +44 -0
- package/dist/utils/types.d.ts.map +1 -0
- package/dist/utils/types.js +2 -0
- package/dist/utils/types.js.map +1 -0
- package/dist/warp/collateral-token.d.ts +21 -0
- package/dist/warp/collateral-token.d.ts.map +1 -0
- package/dist/warp/collateral-token.js +119 -0
- package/dist/warp/collateral-token.js.map +1 -0
- package/dist/warp/synthetic-token.d.ts +21 -0
- package/dist/warp/synthetic-token.d.ts.map +1 -0
- package/dist/warp/synthetic-token.js +98 -0
- package/dist/warp/synthetic-token.js.map +1 -0
- package/dist/warp/warp-artifact-manager.d.ts +17 -0
- package/dist/warp/warp-artifact-manager.d.ts.map +1 -0
- package/dist/warp/warp-artifact-manager.js +103 -0
- package/dist/warp/warp-artifact-manager.js.map +1 -0
- package/dist/warp/warp-query.d.ts +9 -0
- package/dist/warp/warp-query.d.ts.map +1 -0
- package/dist/warp/warp-query.js +105 -0
- package/dist/warp/warp-query.js.map +1 -0
- package/dist/warp/warp-tx.d.ts +31 -0
- package/dist/warp/warp-tx.d.ts.map +1 -0
- package/dist/warp/warp-tx.js +127 -0
- package/dist/warp/warp-tx.js.map +1 -0
- package/package.json +73 -3
package/LICENSE.md
ADDED
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
# Apache License
|
|
2
|
+
|
|
3
|
+
_Version 2.0, January 2004_
|
|
4
|
+
_<<http://www.apache.org/licenses/>>_
|
|
5
|
+
|
|
6
|
+
### Terms and Conditions for use, reproduction, and distribution
|
|
7
|
+
|
|
8
|
+
#### 1. Definitions
|
|
9
|
+
|
|
10
|
+
“License” shall mean the terms and conditions for use, reproduction, and
|
|
11
|
+
distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
“Licensor” shall mean the copyright owner or entity authorized by the copyright
|
|
14
|
+
owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
“Legal Entity” shall mean the union of the acting entity and all other entities
|
|
17
|
+
that control, are controlled by, or are under common control with that entity.
|
|
18
|
+
For the purposes of this definition, “control” means **(i)** the power, direct or
|
|
19
|
+
indirect, to cause the direction or management of such entity, whether by
|
|
20
|
+
contract or 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 exercising
|
|
24
|
+
permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
“Source” form shall mean the preferred form for making modifications, including
|
|
27
|
+
but not limited to software source code, documentation source, and configuration
|
|
28
|
+
files.
|
|
29
|
+
|
|
30
|
+
“Object” form shall mean any form resulting from mechanical transformation or
|
|
31
|
+
translation of a Source form, including but not limited to compiled object code,
|
|
32
|
+
generated documentation, and conversions to other media types.
|
|
33
|
+
|
|
34
|
+
“Work” shall mean the work of authorship, whether in Source or Object form, made
|
|
35
|
+
available under the License, as indicated by a copyright notice that is included
|
|
36
|
+
in or attached to the work (an example is provided in the Appendix below).
|
|
37
|
+
|
|
38
|
+
“Derivative Works” shall mean any work, whether in Source or Object form, that
|
|
39
|
+
is based on (or derived from) the Work and for which the editorial revisions,
|
|
40
|
+
annotations, elaborations, or other modifications represent, as a whole, an
|
|
41
|
+
original work of authorship. For the purposes of this License, Derivative Works
|
|
42
|
+
shall not include works that remain separable from, or merely link (or bind by
|
|
43
|
+
name) to the interfaces of, the Work and Derivative Works thereof.
|
|
44
|
+
|
|
45
|
+
“Contribution” shall mean any work of authorship, including the original version
|
|
46
|
+
of the Work and any modifications or additions to that Work or Derivative Works
|
|
47
|
+
thereof, that is intentionally submitted to Licensor for inclusion in the Work
|
|
48
|
+
by the copyright owner or by an individual or Legal Entity authorized to submit
|
|
49
|
+
on behalf of the copyright owner. For the purposes of this definition,
|
|
50
|
+
“submitted” means any form of electronic, verbal, or written communication sent
|
|
51
|
+
to the Licensor or its representatives, including but not limited to
|
|
52
|
+
communication on electronic mailing lists, source code control systems, and
|
|
53
|
+
issue tracking systems that are managed by, or on behalf of, the Licensor for
|
|
54
|
+
the purpose of discussing and improving the Work, but excluding communication
|
|
55
|
+
that is conspicuously marked or otherwise designated in writing by the copyright
|
|
56
|
+
owner as “Not a Contribution.”
|
|
57
|
+
|
|
58
|
+
“Contributor” shall mean Licensor and any individual or Legal Entity on behalf
|
|
59
|
+
of whom a Contribution has been received by Licensor and subsequently
|
|
60
|
+
incorporated within the Work.
|
|
61
|
+
|
|
62
|
+
#### 2. Grant of Copyright License
|
|
63
|
+
|
|
64
|
+
Subject to the terms and conditions of this License, each Contributor hereby
|
|
65
|
+
grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
|
|
66
|
+
irrevocable copyright license to reproduce, prepare Derivative Works of,
|
|
67
|
+
publicly display, publicly perform, sublicense, and distribute the Work and such
|
|
68
|
+
Derivative Works in Source or Object form.
|
|
69
|
+
|
|
70
|
+
#### 3. Grant of Patent License
|
|
71
|
+
|
|
72
|
+
Subject to the terms and conditions of this License, each Contributor hereby
|
|
73
|
+
grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
|
|
74
|
+
irrevocable (except as stated in this section) patent license to make, have
|
|
75
|
+
made, use, offer to sell, sell, import, and otherwise transfer the Work, where
|
|
76
|
+
such license applies only to those patent claims licensable by such Contributor
|
|
77
|
+
that are necessarily infringed by their Contribution(s) alone or by combination
|
|
78
|
+
of their Contribution(s) with the Work to which such Contribution(s) was
|
|
79
|
+
submitted. If You institute patent litigation against any entity (including a
|
|
80
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work or a
|
|
81
|
+
Contribution incorporated within the Work constitutes direct or contributory
|
|
82
|
+
patent infringement, then any patent licenses granted to You under this License
|
|
83
|
+
for that Work shall terminate as of the date such litigation is filed.
|
|
84
|
+
|
|
85
|
+
#### 4. Redistribution
|
|
86
|
+
|
|
87
|
+
You may reproduce and distribute copies of the Work or Derivative Works thereof
|
|
88
|
+
in any medium, with or without modifications, and in Source or Object form,
|
|
89
|
+
provided that You meet the following conditions:
|
|
90
|
+
|
|
91
|
+
- **(a)** You must give any other recipients of the Work or Derivative Works a copy of
|
|
92
|
+
this License; and
|
|
93
|
+
- **(b)** You must cause any modified files to carry prominent notices stating that You
|
|
94
|
+
changed the files; and
|
|
95
|
+
- **(c)** You must retain, in the Source form of any Derivative Works that You distribute,
|
|
96
|
+
all copyright, patent, trademark, and attribution notices from the Source form
|
|
97
|
+
of the Work, excluding those notices that do not pertain to any part of the
|
|
98
|
+
Derivative Works; and
|
|
99
|
+
- **(d)** If the Work includes a “NOTICE” text file as part of its distribution, then any
|
|
100
|
+
Derivative Works that You distribute must include a readable copy of the
|
|
101
|
+
attribution notices contained within such NOTICE file, excluding those notices
|
|
102
|
+
that do not pertain to any part of the Derivative Works, in at least one of the
|
|
103
|
+
following places: within a NOTICE text file distributed as part of the
|
|
104
|
+
Derivative Works; within the Source form or documentation, if provided along
|
|
105
|
+
with the Derivative Works; or, within a display generated by the Derivative
|
|
106
|
+
Works, if and wherever such third-party notices normally appear. The contents of
|
|
107
|
+
the NOTICE file are for informational purposes only and do not modify the
|
|
108
|
+
License. You may add Your own attribution notices within Derivative Works that
|
|
109
|
+
You distribute, alongside or as an addendum to the NOTICE text from the Work,
|
|
110
|
+
provided that such additional attribution notices cannot be construed as
|
|
111
|
+
modifying the License.
|
|
112
|
+
|
|
113
|
+
You may add Your own copyright statement to Your modifications and may provide
|
|
114
|
+
additional or different license terms and conditions for use, reproduction, or
|
|
115
|
+
distribution of Your modifications, or for any such Derivative Works as a whole,
|
|
116
|
+
provided Your use, reproduction, and distribution of the Work otherwise complies
|
|
117
|
+
with the conditions stated in this License.
|
|
118
|
+
|
|
119
|
+
#### 5. Submission of Contributions
|
|
120
|
+
|
|
121
|
+
Unless You explicitly state otherwise, any Contribution intentionally submitted
|
|
122
|
+
for inclusion in the Work by You to the Licensor shall be under the terms and
|
|
123
|
+
conditions of this License, without any additional terms or conditions.
|
|
124
|
+
Notwithstanding the above, nothing herein shall supersede or modify the terms of
|
|
125
|
+
any separate license agreement you may have executed with Licensor regarding
|
|
126
|
+
such Contributions.
|
|
127
|
+
|
|
128
|
+
#### 6. Trademarks
|
|
129
|
+
|
|
130
|
+
This License does not grant permission to use the trade names, trademarks,
|
|
131
|
+
service marks, or product names of the Licensor, except as required for
|
|
132
|
+
reasonable and customary use in describing the origin of the Work and
|
|
133
|
+
reproducing the content of the NOTICE file.
|
|
134
|
+
|
|
135
|
+
#### 7. Disclaimer of Warranty
|
|
136
|
+
|
|
137
|
+
Unless required by applicable law or agreed to in writing, Licensor provides the
|
|
138
|
+
Work (and each Contributor provides its Contributions) on an “AS IS” BASIS,
|
|
139
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
|
|
140
|
+
including, without limitation, any warranties or conditions of TITLE,
|
|
141
|
+
NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are
|
|
142
|
+
solely responsible for determining the appropriateness of using or
|
|
143
|
+
redistributing the Work and assume any risks associated with Your exercise of
|
|
144
|
+
permissions under this License.
|
|
145
|
+
|
|
146
|
+
#### 8. Limitation of Liability
|
|
147
|
+
|
|
148
|
+
In no event and under no legal theory, whether in tort (including negligence),
|
|
149
|
+
contract, or otherwise, unless required by applicable law (such as deliberate
|
|
150
|
+
and grossly negligent acts) or agreed to in writing, shall any Contributor be
|
|
151
|
+
liable to You for damages, including any direct, indirect, special, incidental,
|
|
152
|
+
or consequential damages of any character arising as a result of this License or
|
|
153
|
+
out of the use or inability to use the Work (including but not limited to
|
|
154
|
+
damages for loss of goodwill, work stoppage, computer failure or malfunction, or
|
|
155
|
+
any and all other commercial damages or losses), even if such Contributor has
|
|
156
|
+
been advised of the possibility of such damages.
|
|
157
|
+
|
|
158
|
+
#### 9. Accepting Warranty or Additional Liability
|
|
159
|
+
|
|
160
|
+
While redistributing the Work or Derivative Works thereof, You may choose to
|
|
161
|
+
offer, and charge a fee for, acceptance of support, warranty, indemnity, or
|
|
162
|
+
other liability obligations and/or rights consistent with this License. However,
|
|
163
|
+
in accepting such obligations, You may act only on Your own behalf and on Your
|
|
164
|
+
sole responsibility, not on behalf of any other Contributor, and only if You
|
|
165
|
+
agree to indemnify, defend, and hold each Contributor harmless for any liability
|
|
166
|
+
incurred by, or claims asserted against, such Contributor by reason of your
|
|
167
|
+
accepting any such warranty or additional liability.
|
|
168
|
+
|
|
169
|
+
_END OF TERMS AND CONDITIONS_
|
|
170
|
+
|
|
171
|
+
### APPENDIX: How to apply the Apache License to your work
|
|
172
|
+
|
|
173
|
+
To apply the Apache License to your work, attach the following boilerplate
|
|
174
|
+
notice, with the fields enclosed by brackets `[]` replaced with your own
|
|
175
|
+
identifying information. (Don't include the brackets!) The text should be
|
|
176
|
+
enclosed in the appropriate comment syntax for the file format. We also
|
|
177
|
+
recommend that a file or class name and description of purpose be included on
|
|
178
|
+
the same “printed page” as the copyright notice for easier identification within
|
|
179
|
+
third-party archives.
|
|
180
|
+
|
|
181
|
+
Copyright [yyyy] [name of copyright owner]
|
|
182
|
+
|
|
183
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
184
|
+
you may not use this file except in compliance with the License.
|
|
185
|
+
You may obtain a copy of the License at
|
|
186
|
+
|
|
187
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
188
|
+
|
|
189
|
+
Unless required by applicable law or agreed to in writing, software
|
|
190
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
191
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
192
|
+
See the License for the specific language governing permissions and
|
|
193
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,83 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Hyperlane Cosmos Module SDK
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The Hyperlane Cosmos Module SDK is a fully typed TypeScript SDK for the [Cosmos Hyperlane Module Implementation](https://github.com/bcp-innovations/hyperlane-cosmos).
|
|
4
|
+
It can be used as a standalone SDK for frontend or in backend applications which want to connect to a Cosmos SDK chain which has the Hyperlane Module installed.
|
|
5
|
+
|
|
6
|
+
## Install
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
# Install with NPM
|
|
10
|
+
npm install @recoillink/cosmos-sdk
|
|
11
|
+
|
|
12
|
+
# Or with pnpm
|
|
13
|
+
pnpm add @recoillink/cosmos-sdk
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Usage
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
import { CosmosNativeProvider, CosmosNativeSigner } from "@recoillink/cosmos-sdk";
|
|
20
|
+
import { ChainMetadataForAltVM, ProtocolType } from "@recoillink/provider-sdk";
|
|
21
|
+
import { DirectSecp256k1Wallet } from '@cosmjs/proto-signing';
|
|
22
|
+
|
|
23
|
+
const metadata: ChainMetadataForAltVM = {
|
|
24
|
+
name: 'mychain',
|
|
25
|
+
protocol: ProtocolType.CosmosNative,
|
|
26
|
+
chainId: 'mychain-1',
|
|
27
|
+
domainId: 1234,
|
|
28
|
+
bech32Prefix: 'test',
|
|
29
|
+
gasPrice: {
|
|
30
|
+
amount: '0.2',
|
|
31
|
+
denom: 'denom',
|
|
32
|
+
},
|
|
33
|
+
rpcUrls: [{ http: 'https://rpc-endpoint:26657' }],
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
// using hyperlane queries without needing signers
|
|
37
|
+
const client = await CosmosNativeProvider.connect(metadata);
|
|
38
|
+
|
|
39
|
+
const mailbox = await client.getMailbox('mailbox-id');
|
|
40
|
+
const bridgedSupply = await client.getBridgedSupply({ id: "token-id" });
|
|
41
|
+
...
|
|
42
|
+
|
|
43
|
+
// performing hyperlane transactions
|
|
44
|
+
const wallet = await DirectSecp256k1Wallet.fromKey(PRIV_KEY);
|
|
45
|
+
|
|
46
|
+
const signer = await CosmosNativeSigner.connectWithSigner(metadata, wallet);
|
|
47
|
+
|
|
48
|
+
const { mailbox_id } = await signer.createMailbox({
|
|
49
|
+
owner: '...',
|
|
50
|
+
localDomain: '...',
|
|
51
|
+
defaultIsm: '...',
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
await signer.remoteTransfer({
|
|
55
|
+
sender: '...',
|
|
56
|
+
tokenAddress: '...',
|
|
57
|
+
destinationDomainId: '...',
|
|
58
|
+
recipient: '...',
|
|
59
|
+
amount: '...',
|
|
60
|
+
...
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
// sign and broadcast custom messages
|
|
64
|
+
await signer.signAndBroadcast([txs...]);
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Setup
|
|
68
|
+
|
|
69
|
+
Node 22 or newer is required.
|
|
70
|
+
|
|
71
|
+
## Testing
|
|
72
|
+
|
|
73
|
+
We have a `cosmos-sdk-e2e` job in CI that first runs a local node and then runs a suite of end-to-end tests. The `hyperlane-cosmos-simapp` image is created ad-hoc by the `hypd-docker` workflow, intended to be triggered manually by a developer when a new hyperlane-cosmos release is made.
|
|
74
|
+
|
|
75
|
+
> Note: When updating the `cosmos-sdk` and `cosmos-types` package to a new `hyperlane-cosmos` version, it's important to release a new `hyperlane-cosmos-simapp` image and update the tag used in the `cosmos-sdk-e2e` job. This ensures that the end-to-end tests run against the correct version of the `hyperlane-cosmos` module.
|
|
76
|
+
|
|
77
|
+
## Contribute
|
|
78
|
+
|
|
79
|
+
First you need to install the dependencies by running `pnpm install`.
|
|
80
|
+
|
|
81
|
+
### Building the project
|
|
82
|
+
|
|
83
|
+
You can build the project with `pnpm build`, the build output can be found under `dist`.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type AltVM, type ChainMetadataForAltVM, type ITransactionSubmitter, type MinimumRequiredGasByAction, type ProtocolProvider, type SignerConfig, type TransactionSubmitterConfig } from '@recoillink/provider-sdk';
|
|
2
|
+
import { type IProvider } from '@recoillink/provider-sdk/altvm';
|
|
3
|
+
import { type IRawHookArtifactManager } from '@recoillink/provider-sdk/hook';
|
|
4
|
+
import { type IRawIsmArtifactManager } from '@recoillink/provider-sdk/ism';
|
|
5
|
+
import { type IRawMailboxArtifactManager } from '@recoillink/provider-sdk/mailbox';
|
|
6
|
+
import { type AnnotatedTx, type TxReceipt } from '@recoillink/provider-sdk/module';
|
|
7
|
+
import { type IRawWarpArtifactManager } from '@recoillink/provider-sdk/warp';
|
|
8
|
+
import { type FeeReadContext, type IRawFeeArtifactManager } from '@recoillink/provider-sdk/fee';
|
|
9
|
+
import { type IRawValidatorAnnounceArtifactManager } from '@recoillink/provider-sdk/validator-announce';
|
|
10
|
+
export declare class CosmosNativeProtocolProvider implements ProtocolProvider {
|
|
11
|
+
createProvider(chainMetadata: ChainMetadataForAltVM): Promise<IProvider>;
|
|
12
|
+
createSigner(chainMetadata: ChainMetadataForAltVM, config: SignerConfig): Promise<AltVM.ISigner<AnnotatedTx, TxReceipt>>;
|
|
13
|
+
createSubmitter<TConfig extends TransactionSubmitterConfig>(_chainMetadata: ChainMetadataForAltVM, _config: TConfig): Promise<ITransactionSubmitter>;
|
|
14
|
+
createIsmArtifactManager(chainMetadata: ChainMetadataForAltVM): IRawIsmArtifactManager;
|
|
15
|
+
createHookArtifactManager(chainMetadata: ChainMetadataForAltVM, context?: {
|
|
16
|
+
mailbox?: string;
|
|
17
|
+
}): IRawHookArtifactManager;
|
|
18
|
+
createWarpArtifactManager(chainMetadata: ChainMetadataForAltVM, _context?: {
|
|
19
|
+
mailbox?: string;
|
|
20
|
+
}): IRawWarpArtifactManager;
|
|
21
|
+
createMailboxArtifactManager(chainMetadata: ChainMetadataForAltVM): IRawMailboxArtifactManager;
|
|
22
|
+
createValidatorAnnounceArtifactManager(_chainMetadata: ChainMetadataForAltVM): IRawValidatorAnnounceArtifactManager | null;
|
|
23
|
+
createFeeArtifactManager(_chainMetadata: ChainMetadataForAltVM, _context: FeeReadContext): IRawFeeArtifactManager | null;
|
|
24
|
+
getMinGas(): MinimumRequiredGasByAction;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=protocol.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../../src/clients/protocol.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,KAAK,EACV,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAC1B,KAAK,0BAA0B,EAC/B,KAAK,gBAAgB,EACrB,KAAK,YAAY,EACjB,KAAK,0BAA0B,EAChC,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,EAAE,KAAK,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAC7E,OAAO,EAAE,KAAK,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAC3E,OAAO,EAAE,KAAK,0BAA0B,EAAE,MAAM,kCAAkC,CAAC;AACnF,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,SAAS,EACf,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,KAAK,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAC7E,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,sBAAsB,EAC5B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,KAAK,oCAAoC,EAAE,MAAM,6CAA6C,CAAC;AAgBxG,qBAAa,4BAA6B,YAAW,gBAAgB;IACnE,cAAc,CAAC,aAAa,EAAE,qBAAqB,GAAG,OAAO,CAAC,SAAS,CAAC,CAEvE;IAEK,YAAY,CAChB,aAAa,EAAE,qBAAqB,EACpC,MAAM,EAAE,YAAY,GACnB,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC,CAIhD;IAED,eAAe,CAAC,OAAO,SAAS,0BAA0B,EACxD,cAAc,EAAE,qBAAqB,EACrC,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,qBAAqB,CAAC,CAGhC;IAED,wBAAwB,CACtB,aAAa,EAAE,qBAAqB,GACnC,sBAAsB,CAKxB;IAED,yBAAyB,CACvB,aAAa,EAAE,qBAAqB,EACpC,OAAO,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,GAC7B,uBAAuB,CAgBzB;IAED,yBAAyB,CACvB,aAAa,EAAE,qBAAqB,EACpC,QAAQ,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,GAC9B,uBAAuB,CAIzB;IAED,4BAA4B,CAC1B,aAAa,EAAE,qBAAqB,GACnC,0BAA0B,CAY5B;IAED,sCAAsC,CACpC,cAAc,EAAE,qBAAqB,GACpC,oCAAoC,GAAG,IAAI,CAG7C;IAED,wBAAwB,CACtB,cAAc,EAAE,qBAAqB,EACrC,QAAQ,EAAE,cAAc,GACvB,sBAAsB,GAAG,IAAI,CAE/B;IAED,SAAS,IAAI,0BAA0B,CAStC;CACF"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { assert } from '@recoillink/utils';
|
|
2
|
+
import { CosmosHookArtifactManager } from '../hook/hook-artifact-manager.js';
|
|
3
|
+
import { CosmosIsmArtifactManager } from '../ism/ism-artifact-manager.js';
|
|
4
|
+
import { CosmosWarpArtifactManager } from '../warp/warp-artifact-manager.js';
|
|
5
|
+
import { CosmosNativeProvider } from './provider.js';
|
|
6
|
+
import { CosmosNativeSigner } from './signer.js';
|
|
7
|
+
import { CosmosMailboxArtifactManager } from '../mailbox/mailbox-artifact-manager.js';
|
|
8
|
+
// Base router deploy cost in gas units (ugas), used to size
|
|
9
|
+
// getMinGas().WARP_DEPLOY_GAS. The composable per-config breakdown lives on
|
|
10
|
+
// CosmosNativeProvider.getMinGasForWarpDeploy.
|
|
11
|
+
const WARP_DEPLOY_BASE_UGAS = BigInt(3e6);
|
|
12
|
+
export class CosmosNativeProtocolProvider {
|
|
13
|
+
createProvider(chainMetadata) {
|
|
14
|
+
return CosmosNativeProvider.connect(chainMetadata);
|
|
15
|
+
}
|
|
16
|
+
async createSigner(chainMetadata, config) {
|
|
17
|
+
const { privateKey } = config;
|
|
18
|
+
return CosmosNativeSigner.connectWithSigner(chainMetadata, privateKey);
|
|
19
|
+
}
|
|
20
|
+
createSubmitter(_chainMetadata, _config) {
|
|
21
|
+
// @TODO Implement in a follow up PR
|
|
22
|
+
throw Error('Not implemented');
|
|
23
|
+
}
|
|
24
|
+
createIsmArtifactManager(chainMetadata) {
|
|
25
|
+
assert(chainMetadata.rpcUrls, 'rpc urls undefined');
|
|
26
|
+
const rpcUrls = chainMetadata.rpcUrls.map((rpc) => rpc.http);
|
|
27
|
+
return new CosmosIsmArtifactManager(rpcUrls);
|
|
28
|
+
}
|
|
29
|
+
createHookArtifactManager(chainMetadata, context) {
|
|
30
|
+
const [mainRpcUrl, ...otherRpcUrls] = (chainMetadata.rpcUrls ?? []).map((rpc) => rpc.http);
|
|
31
|
+
assert(mainRpcUrl, 'At least one rpc url is required');
|
|
32
|
+
assert(chainMetadata.nativeToken?.denom, 'native token denom undefined');
|
|
33
|
+
const mailboxAddress = context?.mailbox;
|
|
34
|
+
const nativeTokenDenom = chainMetadata.nativeToken.denom;
|
|
35
|
+
return new CosmosHookArtifactManager({
|
|
36
|
+
rpcUrls: [mainRpcUrl, ...otherRpcUrls],
|
|
37
|
+
mailboxAddress,
|
|
38
|
+
nativeTokenDenom,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
createWarpArtifactManager(chainMetadata, _context) {
|
|
42
|
+
assert(chainMetadata.rpcUrls, 'rpc urls undefined');
|
|
43
|
+
const rpcUrls = chainMetadata.rpcUrls.map((rpc) => rpc.http);
|
|
44
|
+
return new CosmosWarpArtifactManager(rpcUrls);
|
|
45
|
+
}
|
|
46
|
+
createMailboxArtifactManager(chainMetadata) {
|
|
47
|
+
const [rpcUrl, ...otherRpcUrls] = chainMetadata.rpcUrls?.map((rpc) => rpc.http) ?? [];
|
|
48
|
+
assert(rpcUrl, `Expected at least one rpc url for chain ${chainMetadata.name}`);
|
|
49
|
+
return new CosmosMailboxArtifactManager({
|
|
50
|
+
domainId: chainMetadata.domainId,
|
|
51
|
+
rpcUrls: [rpcUrl, ...otherRpcUrls],
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
createValidatorAnnounceArtifactManager(_chainMetadata) {
|
|
55
|
+
// Cosmos does not support validator announce
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
createFeeArtifactManager(_chainMetadata, _context) {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
getMinGas() {
|
|
62
|
+
return {
|
|
63
|
+
CORE_DEPLOY_GAS: BigInt(1e6),
|
|
64
|
+
WARP_DEPLOY_GAS: WARP_DEPLOY_BASE_UGAS,
|
|
65
|
+
TEST_SEND_GAS: BigInt(3e5),
|
|
66
|
+
AVS_GAS: BigInt(3e6),
|
|
67
|
+
ISM_DEPLOY_GAS: BigInt(5e5),
|
|
68
|
+
HOOK_DEPLOY_GAS: BigInt(5e5),
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=protocol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol.js","sourceRoot":"","sources":["../../src/clients/protocol.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAC;AAC7E,OAAO,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAC1E,OAAO,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAC;AAE7E,OAAO,EAAE,o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BAAqB;YACtC,aAAa,EAAE,MAAM,CAAC,GAAG,CAAC;YAC1B,OAAO,EAAE,MAAM,CAAC,GAAG,CAAC;YACpB,cAAc,EAAE,MAAM,CAAC,GAAG,CAAC;YAC3B,eAAe,EAAE,MAAM,CAAC,GAAG,CAAC;SAC7B,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { type EncodeObject } from '@cosmjs/proto-signing';
|
|
2
|
+
import { type MsgSendEncodeObject } from '@cosmjs/stargate';
|
|
3
|
+
import { type CometClient } from '@cosmjs/tendermint-rpc';
|
|
4
|
+
import { type AltVM } from '@recoillink/provider-sdk';
|
|
5
|
+
import type { ChainMetadataForAltVM } from '@recoillink/provider-sdk/chain';
|
|
6
|
+
import { type WarpArtifactConfig } from '@recoillink/provider-sdk/warp';
|
|
7
|
+
import { type MsgRemoteTransferEncodeObject } from '../hyperlane/warp/messages.js';
|
|
8
|
+
export declare class CosmosNativeProvider implements AltVM.IProvider<EncodeObject> {
|
|
9
|
+
private readonly query;
|
|
10
|
+
private readonly registry;
|
|
11
|
+
private readonly cometClient;
|
|
12
|
+
private readonly rpcUrls;
|
|
13
|
+
protected readonly chainMetadata: ChainMetadataForAltVM;
|
|
14
|
+
private readonly stargateClients;
|
|
15
|
+
static connect(metadata: ChainMetadataForAltVM): Promise<CosmosNativeProvider>;
|
|
16
|
+
protected constructor(cometClient: CometClient, rpcUrls: [string, ...string[]], chainMetadata: ChainMetadataForAltVM);
|
|
17
|
+
getMinGasForWarpDeploy(warpConfig: WarpArtifactConfig): Promise<bigint>;
|
|
18
|
+
isHealthy(): Promise<boolean>;
|
|
19
|
+
getRpcUrls(): [string, ...string[]];
|
|
20
|
+
getHeight(): Promise<number>;
|
|
21
|
+
getBalance(req: AltVM.ReqGetBalance): Promise<bigint>;
|
|
22
|
+
getTotalSupply(req: AltVM.ReqGetTotalSupply): Promise<bigint>;
|
|
23
|
+
estimateTransactionFee(req: AltVM.ReqEstimateTransactionFee<EncodeObject>): Promise<AltVM.ResEstimateTransactionFee>;
|
|
24
|
+
private getStargateClient;
|
|
25
|
+
disconnect(): void;
|
|
26
|
+
isMessageDelivered(req: AltVM.ReqIsMessageDelivered): Promise<boolean>;
|
|
27
|
+
getToken(req: AltVM.ReqGetToken): Promise<AltVM.ResGetToken>;
|
|
28
|
+
getRemoteRouters(req: AltVM.ReqGetRemoteRouters): Promise<AltVM.ResGetRemoteRouters>;
|
|
29
|
+
getBridgedSupply(req: AltVM.ReqGetBridgedSupply): Promise<bigint>;
|
|
30
|
+
quoteRemoteTransfer(req: AltVM.ReqQuoteRemoteTransfer): Promise<AltVM.ResQuoteRemoteTransfer>;
|
|
31
|
+
getTransferTransaction(req: AltVM.ReqTransfer): Promise<MsgSendEncodeObject>;
|
|
32
|
+
getRemoteTransferTransaction(req: AltVM.ReqRemoteTransfer): Promise<MsgRemoteTransferEncodeObject>;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../src/clients/provider.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,YAAY,EAAY,MAAM,uBAAuB,CAAC;AACpE,OAAO,EAEL,KAAK,mBAAmB,EAKzB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,KAAK,WAAW,EAAgB,MAAM,wBAAwB,CAAC;AAExE,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAC5E,OAAO,EAGL,KAAK,kBAAkB,EACxB,MAAM,+BAA+B,CAAC;AAGvC,OAAO,EAAE,KAAK,6BAA6B,EAAE,MAAM,+BAA+B,CAAC;AAgCnF,qBAAa,oBAAqB,YAAW,KAAK,CAAC,SAAS,CAAC,YAAY,CAAC;IACxE,OAAO,CAAC,QAAQ,CAAC,KA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AAC,mBAAmB,GAC7B,OAAO,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAapC;IAEK,gBAAgB,CAAC,GAAG,EAAE,KAAK,CAAC,mBAAmB,GAAG,OAAO,CAAC,MAAM,CAAC,CAUtE;IAEK,mBAAmB,CACvB,GAAG,EAAE,KAAK,CAAC,sBAAsB,GAChC,OAAO,CAAC,KAAK,CAAC,sBAAsB,CAAC,CAgBvC;IAEK,sBAAsB,CAC1B,GAAG,EAAE,KAAK,CAAC,WAAW,GACrB,OAAO,CAAC,mBAAmB,CAAC,CAgB9B;IAEK,4BAA4B,CAChC,GAAG,EAAE,KAAK,CAAC,iBAAiB,GAC3B,OAAO,CAAC,6BAA6B,CAAC,CAexC;CACF"}
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import { encodeSecp256k1Pubkey } from '@cosmjs/amino';
|
|
2
|
+
import { Uint53 } from '@cosmjs/math';
|
|
3
|
+
import { Registry } from '@cosmjs/proto-signing';
|
|
4
|
+
import { QueryClient, defaultRegistryTypes, setupBankExtension, } from '@cosmjs/stargate';
|
|
5
|
+
import { connectComet } from '@cosmjs/tendermint-rpc';
|
|
6
|
+
import { composeWarpDeployGas, nativeAmountFromGasUnits, } from '@recoillink/provider-sdk/warp';
|
|
7
|
+
import { assert, strip0x } from '@recoillink/utils';
|
|
8
|
+
import { setupCoreExtension, } from '../hyperlane/core/query.js';
|
|
9
|
+
import { setupWarpExtension, } from '../hyperlane/warp/query.js';
|
|
10
|
+
import { COSMOS_MODULE_MESSAGE_REGISTRY as R } from '../registry.js';
|
|
11
|
+
import { getWarpTokenType } from '../warp/warp-query.js';
|
|
12
|
+
import { StargateClientCache, disconnectStargateClient, shouldCacheStargateClient, } from './stargate.js';
|
|
13
|
+
// Warp-deploy cost breakdown for Cosmos-native. Composed additively in
|
|
14
|
+
// getMinGasForWarpDeploy() based on the WarpConfig shape. Unlike rent-metered
|
|
15
|
+
// protocols, these are gas UNITS (ugas) that get multiplied by the chain's
|
|
16
|
+
// gas price to yield a native-denom amount.
|
|
17
|
+
//
|
|
18
|
+
// TODO: fill from observed deploy — we don't have a measured breakdown for
|
|
19
|
+
// feature-heavy warp deploys on Cosmos-native yet, so all extras currently
|
|
20
|
+
// contribute nothing.
|
|
21
|
+
const WARP_DEPLOY_BASE_UGAS = BigInt(3e6); // base router deploy
|
|
22
|
+
const WARP_DEPLOY_CROSS_COLLATERAL_EXTRA_UGAS = 0n; // + crossCollateral router extras
|
|
23
|
+
const WARP_DEPLOY_FEE_PROGRAM_UGAS = 0n; // + fee program (config.fee object)
|
|
24
|
+
const WARP_DEPLOY_CUSTOM_ISM_UGAS = 0n; // + custom ISM (config.interchainSecurityModule object)
|
|
25
|
+
const WARP_DEPLOY_CUSTOM_HOOK_UGAS = 0n; // + custom hook / IGP (config.hook object)
|
|
26
|
+
export class CosmosNativeProvider {
|
|
27
|
+
query;
|
|
28
|
+
registry;
|
|
29
|
+
cometClient;
|
|
30
|
+
rpcUrls;
|
|
31
|
+
chainMetadata;
|
|
32
|
+
stargateClients = new StargateClientCache(1);
|
|
33
|
+
static async connect(metadata) {
|
|
34
|
+
const rpcUrls = (metadata.rpcUrls ?? []).map((rpc) => rpc.http);
|
|
35
|
+
const [rpcUrl, ...otherRpcUrls] = rpcUrls;
|
|
36
|
+
assert(rpcUrl, `${CosmosNativeProvider.name} got no rpcUrls`);
|
|
37
|
+
const client = await connectComet(rpcUrl);
|
|
38
|
+
return new CosmosNativeProvider(client, [rpcUrl, ...otherRpcUrls], metadata);
|
|
39
|
+
}
|
|
40
|
+
constructor(cometClient, rpcUrls, chainMetadata) {
|
|
41
|
+
this.query = QueryClient.withExtensions(cometClient, setupBankExtension, setupCoreExtension, setupWarpExtension);
|
|
42
|
+
this.registry = new Registry([...defaultRegistryTypes]);
|
|
43
|
+
// register all the custom tx types
|
|
44
|
+
Object.values(R).forEach(({ proto }) => {
|
|
45
|
+
this.registry.register(proto.type, proto.converter);
|
|
46
|
+
});
|
|
47
|
+
this.cometClient = cometClient;
|
|
48
|
+
this.rpcUrls = rpcUrls;
|
|
49
|
+
this.chainMetadata = chainMetadata;
|
|
50
|
+
}
|
|
51
|
+
async getMinGasForWarpDeploy(warpConfig) {
|
|
52
|
+
const units = composeWarpDeployGas(warpConfig, {
|
|
53
|
+
base: WARP_DEPLOY_BASE_UGAS,
|
|
54
|
+
crossCollateralExtra: WARP_DEPLOY_CROSS_COLLATERAL_EXTRA_UGAS,
|
|
55
|
+
feeProgram: WARP_DEPLOY_FEE_PROGRAM_UGAS,
|
|
56
|
+
customIsm: WARP_DEPLOY_CUSTOM_ISM_UGAS,
|
|
57
|
+
customHook: WARP_DEPLOY_CUSTOM_HOOK_UGAS,
|
|
58
|
+
});
|
|
59
|
+
assert(this.chainMetadata.gasPrice, `gasPrice not defined on chain ${this.chainMetadata.name}`);
|
|
60
|
+
return nativeAmountFromGasUnits(units, this.chainMetadata.gasPrice);
|
|
61
|
+
}
|
|
62
|
+
// ### QUERY BASE ###
|
|
63
|
+
async isHealthy() {
|
|
64
|
+
const status = await this.cometClient.status();
|
|
65
|
+
return status.syncInfo.latestBlockHeight > 0;
|
|
66
|
+
}
|
|
67
|
+
getRpcUrls() {
|
|
68
|
+
return this.rpcUrls;
|
|
69
|
+
}
|
|
70
|
+
async getHeight() {
|
|
71
|
+
const status = await this.cometClient.status();
|
|
72
|
+
return status.syncInfo.latestBlockHeight;
|
|
73
|
+
}
|
|
74
|
+
async getBalance(req) {
|
|
75
|
+
assert(req.denom, `denom required by ${CosmosNativeProvider.name}`);
|
|
76
|
+
const coin = await this.query.bank.balance(req.address, req.denom);
|
|
77
|
+
return BigInt(coin.amount);
|
|
78
|
+
}
|
|
79
|
+
async getTotalSupply(req) {
|
|
80
|
+
assert(req.denom, `denom required by ${CosmosNativeProvider.name}`);
|
|
81
|
+
const coin = await this.query.bank.supplyOf(req.denom);
|
|
82
|
+
return BigInt(coin.amount);
|
|
83
|
+
}
|
|
84
|
+
async estimateTransactionFee(req) {
|
|
85
|
+
assert(req.estimatedGasPrice, `Cosmos Native requires a estimatedGasPrice to estimate the transaction fee`);
|
|
86
|
+
assert(req.senderAddress, `Cosmos Native requires a senderAddress to estimate the transaction fee`);
|
|
87
|
+
assert(req.senderPubKey, `Cosmos Native requires a sender public key to estimate the transaction fee`);
|
|
88
|
+
const stargateClientPromise = this.getStargateClient();
|
|
89
|
+
let stargateClient;
|
|
90
|
+
try {
|
|
91
|
+
stargateClient = await stargateClientPromise;
|
|
92
|
+
const message = this.registry.encodeAsAny(req.transaction);
|
|
93
|
+
const pubKey = encodeSecp256k1Pubkey(new Uint8Array(Buffer.from(strip0x(req.senderPubKey), 'hex')));
|
|
94
|
+
const queryClient = stargateClient
|
|
95
|
+
// @ts-ignore force access to protected method
|
|
96
|
+
.forceGetQueryClient();
|
|
97
|
+
const { sequence } = await stargateClient.getSequence(req.senderAddress);
|
|
98
|
+
const { gasInfo } = await queryClient.tx.simulate([message], undefined, pubKey, sequence);
|
|
99
|
+
const gasUnits = Uint53.fromString(gasInfo?.gasUsed.toString() ?? '0').toNumber();
|
|
100
|
+
const gasPrice = parseFloat(req.estimatedGasPrice.toString());
|
|
101
|
+
return {
|
|
102
|
+
gasUnits: BigInt(gasUnits),
|
|
103
|
+
gasPrice,
|
|
104
|
+
fee: BigInt(Math.floor(gasUnits * gasPrice)),
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
catch (error) {
|
|
108
|
+
this.stargateClients.evict(this.rpcUrls[0], stargateClientPromise);
|
|
109
|
+
throw error;
|
|
110
|
+
}
|
|
111
|
+
finally {
|
|
112
|
+
if (shouldCacheStargateClient(this.rpcUrls[0])) {
|
|
113
|
+
this.stargateClients.release(stargateClientPromise);
|
|
114
|
+
}
|
|
115
|
+
else if (stargateClient) {
|
|
116
|
+
disconnectStargateClient(Promise.resolve(stargateClient));
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
getStargateClient() {
|
|
121
|
+
return this.stargateClients.get(this.rpcUrls[0]);
|
|
122
|
+
}
|
|
123
|
+
disconnect() {
|
|
124
|
+
this.cometClient.disconnect();
|
|
125
|
+
this.stargateClients.clear();
|
|
126
|
+
}
|
|
127
|
+
async isMessageDelivered(req) {
|
|
128
|
+
const { delivered } = await this.query.core.Delivered({
|
|
129
|
+
id: req.mailboxAddress,
|
|
130
|
+
message_id: req.messageId,
|
|
131
|
+
});
|
|
132
|
+
return delivered;
|
|
133
|
+
}
|
|
134
|
+
// ### QUERY WARP ###
|
|
135
|
+
async getToken(req) {
|
|
136
|
+
const { token } = await this.query.warp.Token({
|
|
137
|
+
id: req.tokenAddress,
|
|
138
|
+
});
|
|
139
|
+
assert(token, `found no token for id ${req.tokenAddress}`);
|
|
140
|
+
const token_type = await getWarpTokenType(this.query, req.tokenAddress);
|
|
141
|
+
return {
|
|
142
|
+
address: token.id,
|
|
143
|
+
owner: token.owner,
|
|
144
|
+
tokenType: token_type,
|
|
145
|
+
mailboxAddress: token.origin_mailbox,
|
|
146
|
+
ismAddress: token.ism_id,
|
|
147
|
+
hookAddress: '',
|
|
148
|
+
denom: token.origin_denom,
|
|
149
|
+
name: '',
|
|
150
|
+
symbol: '',
|
|
151
|
+
decimals: 0,
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
async getRemoteRouters(req) {
|
|
155
|
+
const { remote_routers } = await this.query.warp.RemoteRouters({
|
|
156
|
+
id: req.tokenAddress,
|
|
157
|
+
});
|
|
158
|
+
return {
|
|
159
|
+
address: req.tokenAddress,
|
|
160
|
+
remoteRouters: remote_routers.map((r) => ({
|
|
161
|
+
receiverDomainId: r.receiver_domain,
|
|
162
|
+
receiverAddress: r.receiver_contract,
|
|
163
|
+
gas: r.gas,
|
|
164
|
+
})),
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
async getBridgedSupply(req) {
|
|
168
|
+
const { bridged_supply } = await this.query.warp.BridgedSupply({
|
|
169
|
+
id: req.tokenAddress,
|
|
170
|
+
});
|
|
171
|
+
assert(bridged_supply, `found no bridged supply for token id ${req.tokenAddress}`);
|
|
172
|
+
return BigInt(bridged_supply.amount);
|
|
173
|
+
}
|
|
174
|
+
async quoteRemoteTransfer(req) {
|
|
175
|
+
const { gas_payment } = await this.query.warp.QuoteRemoteTransfer({
|
|
176
|
+
id: req.tokenAddress,
|
|
177
|
+
destination_domain: req.destinationDomainId.toString(),
|
|
178
|
+
custom_hook_id: req.customHookAddress || '',
|
|
179
|
+
custom_hook_metadata: req.customHookMetadata || '',
|
|
180
|
+
});
|
|
181
|
+
assert(gas_payment && gas_payment[0], `found no quote for token id ${req.tokenAddress} and destination domain ${req.destinationDomainId}`);
|
|
182
|
+
return {
|
|
183
|
+
denom: gas_payment[0].denom,
|
|
184
|
+
amount: BigInt(gas_payment[0].amount),
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
async getTransferTransaction(req) {
|
|
188
|
+
assert(req.denom, `denom required by ${CosmosNativeProvider.name}`);
|
|
189
|
+
return {
|
|
190
|
+
typeUrl: '/cosmos.bank.v1beta1.MsgSend',
|
|
191
|
+
value: {
|
|
192
|
+
fromAddress: req.signer,
|
|
193
|
+
toAddress: req.recipient,
|
|
194
|
+
amount: [
|
|
195
|
+
{
|
|
196
|
+
denom: req.denom,
|
|
197
|
+
amount: req.amount,
|
|
198
|
+
},
|
|
199
|
+
],
|
|
200
|
+
},
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
async getRemoteTransferTransaction(req) {
|
|
204
|
+
return {
|
|
205
|
+
typeUrl: R.MsgRemoteTransfer.proto.type,
|
|
206
|
+
value: R.MsgRemoteTransfer.proto.converter.create({
|
|
207
|
+
sender: req.signer,
|
|
208
|
+
token_id: req.tokenAddress,
|
|
209
|
+
destination_domain: req.destinationDomainId,
|
|
210
|
+
recipient: req.recipient,
|
|
211
|
+
amount: req.amount,
|
|
212
|
+
custom_hook_id: req.customHookAddress,
|
|
213
|
+
gas_limit: req.gasLimit,
|
|
214
|
+
max_fee: req.maxFee,
|
|
215
|
+
custom_hook_metadata: req.customHookMetadata,
|
|
216
|
+
}),
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
//# sourceMappingURL=provider.js.map
|