@lifi/sdk-provider-zcash 0.0.0-preview-1b774eec
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/CHANGELOG.md +12 -0
- package/LICENSE +201 -0
- package/README.md +187 -0
- package/dist/cjs/ZcashProvider.d.ts +5 -0
- package/dist/cjs/ZcashProvider.js +22 -0
- package/dist/cjs/ZcashProvider.js.map +1 -0
- package/dist/cjs/index.d.ts +2 -0
- package/dist/cjs/index.js +3 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/utils/zcashAddress.d.ts +9 -0
- package/dist/cjs/utils/zcashAddress.js +22 -0
- package/dist/cjs/utils/zcashAddress.js.map +1 -0
- package/dist/cjs/version.d.ts +5 -0
- package/dist/cjs/version.js +9 -0
- package/dist/cjs/version.js.map +1 -0
- package/dist/esm/ZcashProvider.d.ts +5 -0
- package/dist/esm/ZcashProvider.d.ts.map +1 -0
- package/dist/esm/ZcashProvider.js +21 -0
- package/dist/esm/ZcashProvider.js.map +1 -0
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/package.json +1 -0
- package/dist/esm/utils/zcashAddress.d.ts +9 -0
- package/dist/esm/utils/zcashAddress.d.ts.map +1 -0
- package/dist/esm/utils/zcashAddress.js +22 -0
- package/dist/esm/utils/zcashAddress.js.map +1 -0
- package/dist/esm/version.d.ts +5 -0
- package/dist/esm/version.d.ts.map +1 -0
- package/dist/esm/version.js +7 -0
- package/dist/esm/version.js.map +1 -0
- package/package.json +70 -0
- package/src/ZcashProvider.ts +30 -0
- package/src/index.ts +2 -0
- package/src/utils/zcashAddress.ts +24 -0
- package/src/version.ts +2 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# @lifi/sdk-provider-zcash
|
|
2
|
+
|
|
3
|
+
## 0.0.0-preview-1b774eec
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#492](https://github.com/lifinance/sdk/pull/492) [`f03e2f8`](https://github.com/lifinance/sdk/commit/f03e2f8113f3531bd221d1d06d3452366a093dec) Thanks [@chybisov](https://github.com/chybisov)! - New package. `ZcashProvider()` validates receivers on ZEC, a destination-only chain: transparent `t1` and `t3` addresses with a valid checksum. It serves `ChainId.ZEC` beside `BitcoinProvider`, leaves balances unknown and cannot execute a step.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [[`a75a5b3`](https://github.com/lifinance/sdk/commit/a75a5b3f30716b53f6dca4b6b1bb83ba887c5243)]:
|
|
12
|
+
- @lifi/sdk@0.0.0-preview-1b774eec
|
package/LICENSE
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 LI.FI
|
|
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,187 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
[](/LICENSE)
|
|
4
|
+
[](https://www.npmjs.com/package/@lifi/sdk)
|
|
5
|
+
[](https://www.npmjs.com/package/@lifi/sdk)
|
|
6
|
+
[](https://twitter.com/lifiprotocol)
|
|
7
|
+
|
|
8
|
+
</div>
|
|
9
|
+
|
|
10
|
+
<h1 align="center">LI.FI SDK</h1>
|
|
11
|
+
|
|
12
|
+
[**LI.FI SDK**](https://docs.li.fi/sdk/overview) provides a powerful toolkit for developers to enable seamless cross-chain and on-chain swaps and bridging within their applications. Our JavaScript/TypeScript SDK can be implemented in front-end or back-end environments, allowing you to build robust UX/UI around our advanced bridge and swap functionalities. LI.FI SDK efficiently manages all communications between our smart routing API and smart contracts and ensures optimal performance, security, and scalability for your cross-chain and on-chain needs.
|
|
13
|
+
|
|
14
|
+
[**LI.FI SDK**](https://docs.li.fi/sdk/overview) features include:
|
|
15
|
+
|
|
16
|
+
- **Modular architecture** - Install only the provider packages you need for your supported blockchain ecosystems (EVM, Solana, Bitcoin, Sui, Tron, Stellar)
|
|
17
|
+
- All ecosystems, chains, bridges, exchanges, and solvers that [LI.FI](https://docs.li.fi/introduction/chains) supports
|
|
18
|
+
- Complete functionality covering full-cycle from obtaining routes/quotes to executing transactions
|
|
19
|
+
- Easy tracking of the route and quote execution through the robust event and hooks handling
|
|
20
|
+
- Highly customizable settings to tailor the SDK to your specific needs including configuration of RPCs and options to allow or deny certain chains, tokens, bridges, exchanges, solvers
|
|
21
|
+
- Supports widely adopted industry standards, including [EIP-5792](https://eips.ethereum.org/EIPS/eip-5792), [ERC-2612](https://eips.ethereum.org/EIPS/eip-2612), [EIP-712](https://eips.ethereum.org/EIPS/eip-712), and [Permit2](https://github.com/Uniswap/permit2)
|
|
22
|
+
- SDK ecosystem providers are based on industry-standard libraries ([Viem](https://viem.sh/) for EVM, [Solana Kit](https://github.com/anza-xyz/kit) for Solana, [Bigmi](https://github.com/lifinance/bigmi) for Bitcoin, [Mysten Sui SDK](https://github.com/MystenLabs/sui/tree/main/sdk) for Sui, [TronWeb](https://tronweb.network/) for Tron, [Stellar SDK](https://github.com/stellar/js-stellar-sdk) for Stellar)
|
|
23
|
+
- Support for arbitrary contract calls on the destination chain
|
|
24
|
+
- Designed for optimal performance with tree-shaking and dead-code elimination, ensuring minimal bundle sizes and faster page load times in front-end environments
|
|
25
|
+
- Compatibility tested with Node.js and popular front-end tools like Vite
|
|
26
|
+
|
|
27
|
+
## Installation
|
|
28
|
+
|
|
29
|
+
The LI.FI SDK follows a modular architecture. Install the core SDK package and the provider packages for the blockchain ecosystems you need:
|
|
30
|
+
|
|
31
|
+
### Core SDK
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
pnpm add @lifi/sdk
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
or
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
npm install --save @lifi/sdk
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Provider Packages
|
|
44
|
+
|
|
45
|
+
Install provider packages based on the blockchain ecosystems you want to support.
|
|
46
|
+
|
|
47
|
+
Each provider bundles its ecosystem library, but you configure a provider by handing it a
|
|
48
|
+
wallet or client object that **you** construct — so install the ecosystem library alongside
|
|
49
|
+
the provider whenever you import from it in your own code:
|
|
50
|
+
|
|
51
|
+
**EVM Chains (Ethereum, Polygon, Arbitrum, Optimism, etc.)**
|
|
52
|
+
```bash
|
|
53
|
+
pnpm add @lifi/sdk-provider-ethereum viem
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
**Solana**
|
|
57
|
+
```bash
|
|
58
|
+
pnpm add @lifi/sdk-provider-solana @wallet-standard/base
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
**Bitcoin**
|
|
62
|
+
```bash
|
|
63
|
+
pnpm add @lifi/sdk-provider-bitcoin @bigmi/core
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
**Sui**
|
|
67
|
+
```bash
|
|
68
|
+
pnpm add @lifi/sdk-provider-sui @mysten/sui
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
**Tron**
|
|
72
|
+
```bash
|
|
73
|
+
pnpm add @lifi/sdk-provider-tron @tronweb3/tronwallet-abstract-adapter
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
**Stellar**
|
|
77
|
+
```bash
|
|
78
|
+
pnpm add @lifi/sdk-provider-stellar
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
`StellarProvider` takes a small `StellarWallet` interface the package defines itself, so it
|
|
82
|
+
needs no ecosystem library. To discover and connect browser wallets such as Freighter,
|
|
83
|
+
xBull, or Lobstr, we recommend
|
|
84
|
+
[Stellar Wallets Kit](https://github.com/Creit-Tech/Stellar-Wallets-Kit).
|
|
85
|
+
|
|
86
|
+
**Zcash**
|
|
87
|
+
```bash
|
|
88
|
+
pnpm add @lifi/sdk-provider-zcash
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
ZEC is a destination-only chain: `ZcashProvider` validates transparent `t1` and `t3` receivers and needs no wallet. Register it after `BitcoinProvider`; it serves ZEC only.
|
|
92
|
+
|
|
93
|
+
## Architecture
|
|
94
|
+
|
|
95
|
+
The LI.FI SDK uses a modular provider architecture:
|
|
96
|
+
|
|
97
|
+
- **`@lifi/sdk`** - Core SDK package containing shared functionality, actions, and execution logic
|
|
98
|
+
- **Provider packages** - Ecosystem-specific packages that handle wallet interactions and transaction execution for different blockchain types
|
|
99
|
+
|
|
100
|
+
This architecture allows you to:
|
|
101
|
+
- Install only the providers you need, reducing bundle size
|
|
102
|
+
- Use ecosystem-specific libraries optimized for each blockchain
|
|
103
|
+
- Maintain clean separation between core SDK logic and blockchain-specific implementations
|
|
104
|
+
|
|
105
|
+
## Quick Start
|
|
106
|
+
|
|
107
|
+
### Set up the SDK
|
|
108
|
+
|
|
109
|
+
Create SDK config with your integrator string and configure the providers for the blockchain ecosystems you want to support.
|
|
110
|
+
|
|
111
|
+
**For EVM chains:**
|
|
112
|
+
```ts
|
|
113
|
+
import { createClient } from '@lifi/sdk'
|
|
114
|
+
import { EthereumProvider } from '@lifi/sdk-provider-ethereum'
|
|
115
|
+
import { createWalletClient, http } from 'viem'
|
|
116
|
+
import { mainnet } from 'viem/chains'
|
|
117
|
+
|
|
118
|
+
// Add your account (e.g. privateKeyToAccount, mnemonicToAccount)
|
|
119
|
+
const walletClient = createWalletClient({
|
|
120
|
+
account,
|
|
121
|
+
chain: mainnet,
|
|
122
|
+
transport: http(),
|
|
123
|
+
})
|
|
124
|
+
|
|
125
|
+
const client = createClient({
|
|
126
|
+
integrator: 'Your dApp/company name',
|
|
127
|
+
providers: [
|
|
128
|
+
EthereumProvider({
|
|
129
|
+
getWalletClient: () => Promise.resolve(walletClient),
|
|
130
|
+
}),
|
|
131
|
+
],
|
|
132
|
+
})
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
**For multiple ecosystems:**
|
|
136
|
+
```ts
|
|
137
|
+
import { createClient } from '@lifi/sdk'
|
|
138
|
+
import { EthereumProvider } from '@lifi/sdk-provider-ethereum'
|
|
139
|
+
import { SolanaProvider } from '@lifi/sdk-provider-solana'
|
|
140
|
+
import { BitcoinProvider } from '@lifi/sdk-provider-bitcoin'
|
|
141
|
+
import { SuiProvider } from '@lifi/sdk-provider-sui'
|
|
142
|
+
import { TronProvider } from '@lifi/sdk-provider-tron'
|
|
143
|
+
import { StellarProvider } from '@lifi/sdk-provider-stellar'
|
|
144
|
+
import { ZcashProvider } from '@lifi/sdk-provider-zcash'
|
|
145
|
+
|
|
146
|
+
const client = createClient({
|
|
147
|
+
integrator: 'Your dApp/company name',
|
|
148
|
+
providers: [
|
|
149
|
+
EthereumProvider({ /* options */ }),
|
|
150
|
+
SolanaProvider({ /* options */ }),
|
|
151
|
+
BitcoinProvider({ /* options */ }),
|
|
152
|
+
SuiProvider({ /* options */ }),
|
|
153
|
+
TronProvider({ /* options */ }),
|
|
154
|
+
StellarProvider({ /* options */ }),
|
|
155
|
+
ZcashProvider(),
|
|
156
|
+
],
|
|
157
|
+
})
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### Request a Quote
|
|
161
|
+
|
|
162
|
+
Now you can interact with the SDK and for example request a quote.
|
|
163
|
+
|
|
164
|
+
```ts
|
|
165
|
+
import { ChainId, getQuote } from '@lifi/sdk'
|
|
166
|
+
|
|
167
|
+
const quote = await getQuote(client, {
|
|
168
|
+
fromAddress: '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045',
|
|
169
|
+
fromChain: ChainId.ARB,
|
|
170
|
+
toChain: ChainId.OPT,
|
|
171
|
+
fromToken: '0x0000000000000000000000000000000000000000',
|
|
172
|
+
toToken: '0x0000000000000000000000000000000000000000',
|
|
173
|
+
fromAmount: '1000000000000000000',
|
|
174
|
+
})
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
## Examples
|
|
178
|
+
|
|
179
|
+
See [examples](/examples) folder in this repository.
|
|
180
|
+
|
|
181
|
+
## Documentation
|
|
182
|
+
|
|
183
|
+
Please checkout the [SDK documentation](https://docs.li.fi/sdk/overview) and our [API reference](https://docs.li.fi/api-reference/introduction) for further information.
|
|
184
|
+
|
|
185
|
+
## Changelog
|
|
186
|
+
|
|
187
|
+
The [changelog](/CHANGELOG.md) is regularly updated to reflect what's changed in each new release.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_utils_zcashAddress = require("./utils/zcashAddress.js");
|
|
3
|
+
let _lifi_sdk = require("@lifi/sdk");
|
|
4
|
+
//#region src/ZcashProvider.ts
|
|
5
|
+
function ZcashProvider() {
|
|
6
|
+
return {
|
|
7
|
+
get type() {
|
|
8
|
+
return _lifi_sdk.ChainType.UTXO;
|
|
9
|
+
},
|
|
10
|
+
chainIds: [_lifi_sdk.ChainId.ZEC],
|
|
11
|
+
isAddress: (address, chainId) => (chainId === void 0 || chainId === _lifi_sdk.ChainId.ZEC) && require_utils_zcashAddress.isZcashAddress(address),
|
|
12
|
+
resolveAddress: async () => void 0,
|
|
13
|
+
getBalance: async (_client, _walletAddress, tokens) => tokens.map((token) => ({ ...token })),
|
|
14
|
+
getStepExecutor: async () => {
|
|
15
|
+
throw new _lifi_sdk.ProviderError(_lifi_sdk.LiFiErrorCode.ProviderUnavailable, "ZEC is a destination-only chain.");
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
exports.ZcashProvider = ZcashProvider;
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=ZcashProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ZcashProvider.js","names":["ChainType","ChainId","isZcashAddress","ProviderError","LiFiErrorCode"],"sources":["../../src/ZcashProvider.ts"],"sourcesContent":["import {\n ChainId,\n ChainType,\n LiFiErrorCode,\n ProviderError,\n type SDKProvider,\n} from '@lifi/sdk'\nimport { isZcashAddress } from './utils/zcashAddress.js'\n\nexport function ZcashProvider(): SDKProvider {\n return {\n get type() {\n return ChainType.UTXO\n },\n chainIds: [ChainId.ZEC],\n isAddress: (address, chainId) =>\n (chainId === undefined || chainId === ChainId.ZEC) &&\n isZcashAddress(address),\n resolveAddress: async () => undefined,\n // No Zcash balance source yet, so every amount stays unknown.\n getBalance: async (_client, _walletAddress, tokens) =>\n tokens.map((token) => ({ ...token })),\n getStepExecutor: async () => {\n throw new ProviderError(\n LiFiErrorCode.ProviderUnavailable,\n 'ZEC is a destination-only chain.'\n )\n },\n }\n}\n"],"mappings":";;;;AASA,SAAgB,gBAA6B;CAC3C,OAAO;EACL,IAAI,OAAO;GACT,OAAOA,UAAAA,UAAU;EACnB;EACA,UAAU,CAACC,UAAAA,QAAQ,GAAG;EACtB,YAAY,SAAS,aAClB,YAAY,KAAA,KAAa,YAAYA,UAAAA,QAAQ,QAC9CC,2BAAAA,eAAe,OAAO;EACxB,gBAAgB,YAAY,KAAA;EAE5B,YAAY,OAAO,SAAS,gBAAgB,WAC1C,OAAO,KAAK,WAAW,EAAE,GAAG,MAAM,EAAE;EACtC,iBAAiB,YAAY;GAC3B,MAAM,IAAIC,UAAAA,cACRC,UAAAA,cAAc,qBACd,kCACF;EACF;CACF;AACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
//#region src/utils/zcashAddress.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Whether `address` is a mainnet transparent Zcash address (`t1` P2PKH or `t3`
|
|
4
|
+
* P2SH) with a valid checksum. The API handles transparent receivers only, so
|
|
5
|
+
* TEX, Sapling and unified addresses, and testnet forms, return `false`.
|
|
6
|
+
*/
|
|
7
|
+
export declare const isZcashAddress: (address: string) => boolean;
|
|
8
|
+
//#endregion
|
|
9
|
+
//# sourceMappingURL=zcashAddress.d.ts.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
let _noble_hashes_sha2 = require("@noble/hashes/sha2");
|
|
3
|
+
//#region src/utils/zcashAddress.ts
|
|
4
|
+
const base58check = (0, require("@scure/base").createBase58check)(_noble_hashes_sha2.sha256);
|
|
5
|
+
/**
|
|
6
|
+
* Whether `address` is a mainnet transparent Zcash address (`t1` P2PKH or `t3`
|
|
7
|
+
* P2SH) with a valid checksum. The API handles transparent receivers only, so
|
|
8
|
+
* TEX, Sapling and unified addresses, and testnet forms, return `false`.
|
|
9
|
+
*/
|
|
10
|
+
const isZcashAddress = (address) => {
|
|
11
|
+
let payload;
|
|
12
|
+
try {
|
|
13
|
+
payload = base58check.decode(address);
|
|
14
|
+
} catch {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
return payload.length === 22 && payload[0] === 28 && (payload[1] === 184 || payload[1] === 189);
|
|
18
|
+
};
|
|
19
|
+
//#endregion
|
|
20
|
+
exports.isZcashAddress = isZcashAddress;
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=zcashAddress.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zcashAddress.js","names":["createBase58check","sha256"],"sources":["../../../src/utils/zcashAddress.ts"],"sourcesContent":["import { sha256 } from '@noble/hashes/sha2'\nimport { createBase58check } from '@scure/base'\n\nconst base58check = createBase58check(sha256)\n\n/**\n * Whether `address` is a mainnet transparent Zcash address (`t1` P2PKH or `t3`\n * P2SH) with a valid checksum. The API handles transparent receivers only, so\n * TEX, Sapling and unified addresses, and testnet forms, return `false`.\n */\nexport const isZcashAddress = (address: string): boolean => {\n let payload: Uint8Array\n try {\n payload = base58check.decode(address)\n } catch {\n return false\n }\n // A 2-byte version prefix (0x1CB8 or 0x1CBD) and a 20-byte hash.\n return (\n payload.length === 22 &&\n payload[0] === 0x1c &&\n (payload[1] === 0xb8 || payload[1] === 0xbd)\n )\n}\n"],"mappings":";;;AAGA,MAAM,eAAA,wBAAcA,CAAAA,CAAAA,kBAAAA,CAAkBC,mBAAAA,MAAM;;;;;;AAO5C,MAAa,kBAAkB,YAA6B;CAC1D,IAAI;CACJ,IAAI;EACF,UAAU,YAAY,OAAO,OAAO;CACtC,QAAQ;EACN,OAAO;CACT;CAEA,OACE,QAAQ,WAAW,MACnB,QAAQ,OAAO,OACd,QAAQ,OAAO,OAAQ,QAAQ,OAAO;AAE3C"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region src/version.ts
|
|
3
|
+
const name = "@lifi/sdk-provider-zcash";
|
|
4
|
+
const version = "0.0.0-preview-1b774eec";
|
|
5
|
+
//#endregion
|
|
6
|
+
exports.name = name;
|
|
7
|
+
exports.version = version;
|
|
8
|
+
|
|
9
|
+
//# sourceMappingURL=version.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.js","names":[],"sources":["../../src/version.ts"],"sourcesContent":["export const name = '@lifi/sdk-provider-zcash'\nexport const version = '0.0.0-preview-1b774eec'\n"],"mappings":";;AAAA,MAAa,OAAO;AACpB,MAAa,UAAU"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ZcashProvider.d.ts","names":[],"sources":["../../src/ZcashProvider.ts"],"mappings":";;wBASgB,iBAAiB"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { isZcashAddress } from "./utils/zcashAddress.js";
|
|
2
|
+
import { ChainId, ChainType, LiFiErrorCode, ProviderError } from "@lifi/sdk";
|
|
3
|
+
//#region src/ZcashProvider.ts
|
|
4
|
+
function ZcashProvider() {
|
|
5
|
+
return {
|
|
6
|
+
get type() {
|
|
7
|
+
return ChainType.UTXO;
|
|
8
|
+
},
|
|
9
|
+
chainIds: [ChainId.ZEC],
|
|
10
|
+
isAddress: (address, chainId) => (chainId === void 0 || chainId === ChainId.ZEC) && isZcashAddress(address),
|
|
11
|
+
resolveAddress: async () => void 0,
|
|
12
|
+
getBalance: async (_client, _walletAddress, tokens) => tokens.map((token) => ({ ...token })),
|
|
13
|
+
getStepExecutor: async () => {
|
|
14
|
+
throw new ProviderError(LiFiErrorCode.ProviderUnavailable, "ZEC is a destination-only chain.");
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
export { ZcashProvider };
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=ZcashProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ZcashProvider.js","names":[],"sources":["../../src/ZcashProvider.ts"],"sourcesContent":["import {\n ChainId,\n ChainType,\n LiFiErrorCode,\n ProviderError,\n type SDKProvider,\n} from '@lifi/sdk'\nimport { isZcashAddress } from './utils/zcashAddress.js'\n\nexport function ZcashProvider(): SDKProvider {\n return {\n get type() {\n return ChainType.UTXO\n },\n chainIds: [ChainId.ZEC],\n isAddress: (address, chainId) =>\n (chainId === undefined || chainId === ChainId.ZEC) &&\n isZcashAddress(address),\n resolveAddress: async () => undefined,\n // No Zcash balance source yet, so every amount stays unknown.\n getBalance: async (_client, _walletAddress, tokens) =>\n tokens.map((token) => ({ ...token })),\n getStepExecutor: async () => {\n throw new ProviderError(\n LiFiErrorCode.ProviderUnavailable,\n 'ZEC is a destination-only chain.'\n )\n },\n }\n}\n"],"mappings":";;;AASA,SAAgB,gBAA6B;CAC3C,OAAO;EACL,IAAI,OAAO;GACT,OAAO,UAAU;EACnB;EACA,UAAU,CAAC,QAAQ,GAAG;EACtB,YAAY,SAAS,aAClB,YAAY,KAAA,KAAa,YAAY,QAAQ,QAC9C,eAAe,OAAO;EACxB,gBAAgB,YAAY,KAAA;EAE5B,YAAY,OAAO,SAAS,gBAAgB,WAC1C,OAAO,KAAK,WAAW,EAAE,GAAG,MAAM,EAAE;EACtC,iBAAiB,YAAY;GAC3B,MAAM,IAAI,cACR,cAAc,qBACd,kCACF;EACF;CACF;AACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module","sideEffects":false}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
//#region src/utils/zcashAddress.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Whether `address` is a mainnet transparent Zcash address (`t1` P2PKH or `t3`
|
|
4
|
+
* P2SH) with a valid checksum. The API handles transparent receivers only, so
|
|
5
|
+
* TEX, Sapling and unified addresses, and testnet forms, return `false`.
|
|
6
|
+
*/
|
|
7
|
+
export declare const isZcashAddress: (address: string) => boolean;
|
|
8
|
+
//#endregion
|
|
9
|
+
//# sourceMappingURL=zcashAddress.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zcashAddress.d.ts","names":[],"sources":["../../../src/utils/zcashAddress.ts"],"mappings":";;;;;;qBAUa,iBAAkB"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { sha256 } from "@noble/hashes/sha2";
|
|
2
|
+
import { createBase58check } from "@scure/base";
|
|
3
|
+
//#region src/utils/zcashAddress.ts
|
|
4
|
+
const base58check = createBase58check(sha256);
|
|
5
|
+
/**
|
|
6
|
+
* Whether `address` is a mainnet transparent Zcash address (`t1` P2PKH or `t3`
|
|
7
|
+
* P2SH) with a valid checksum. The API handles transparent receivers only, so
|
|
8
|
+
* TEX, Sapling and unified addresses, and testnet forms, return `false`.
|
|
9
|
+
*/
|
|
10
|
+
const isZcashAddress = (address) => {
|
|
11
|
+
let payload;
|
|
12
|
+
try {
|
|
13
|
+
payload = base58check.decode(address);
|
|
14
|
+
} catch {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
return payload.length === 22 && payload[0] === 28 && (payload[1] === 184 || payload[1] === 189);
|
|
18
|
+
};
|
|
19
|
+
//#endregion
|
|
20
|
+
export { isZcashAddress };
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=zcashAddress.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zcashAddress.js","names":[],"sources":["../../../src/utils/zcashAddress.ts"],"sourcesContent":["import { sha256 } from '@noble/hashes/sha2'\nimport { createBase58check } from '@scure/base'\n\nconst base58check = createBase58check(sha256)\n\n/**\n * Whether `address` is a mainnet transparent Zcash address (`t1` P2PKH or `t3`\n * P2SH) with a valid checksum. The API handles transparent receivers only, so\n * TEX, Sapling and unified addresses, and testnet forms, return `false`.\n */\nexport const isZcashAddress = (address: string): boolean => {\n let payload: Uint8Array\n try {\n payload = base58check.decode(address)\n } catch {\n return false\n }\n // A 2-byte version prefix (0x1CB8 or 0x1CBD) and a 20-byte hash.\n return (\n payload.length === 22 &&\n payload[0] === 0x1c &&\n (payload[1] === 0xb8 || payload[1] === 0xbd)\n )\n}\n"],"mappings":";;;AAGA,MAAM,cAAc,kBAAkB,MAAM;;;;;;AAO5C,MAAa,kBAAkB,YAA6B;CAC1D,IAAI;CACJ,IAAI;EACF,UAAU,YAAY,OAAO,OAAO;CACtC,QAAQ;EACN,OAAO;CACT;CAEA,OACE,QAAQ,WAAW,MACnB,QAAQ,OAAO,OACd,QAAQ,OAAO,OAAQ,QAAQ,OAAO;AAE3C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.d.ts","names":[],"sources":["../../src/version.ts"],"mappings":";qBAAa;qBACA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.js","names":[],"sources":["../../src/version.ts"],"sourcesContent":["export const name = '@lifi/sdk-provider-zcash'\nexport const version = '0.0.0-preview-1b774eec'\n"],"mappings":";AAAA,MAAa,OAAO;AACpB,MAAa,UAAU"}
|
package/package.json
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@lifi/sdk-provider-zcash",
|
|
3
|
+
"version": "0.0.0-preview-1b774eec",
|
|
4
|
+
"description": "LI.FI Zcash SDK Provider for Any-to-Any Cross-Chain-Swap",
|
|
5
|
+
"homepage": "https://github.com/lifinance/sdk",
|
|
6
|
+
"bugs": {
|
|
7
|
+
"url": "https://github.com/lifinance/sdk/issues"
|
|
8
|
+
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/lifinance/sdk.git",
|
|
12
|
+
"directory": "packages/sdk-provider-zcash"
|
|
13
|
+
},
|
|
14
|
+
"license": "Apache-2.0",
|
|
15
|
+
"author": "Eugene Chybisov <eugene@li.finance>",
|
|
16
|
+
"type": "module",
|
|
17
|
+
"sideEffects": false,
|
|
18
|
+
"main": "./dist/cjs/index.js",
|
|
19
|
+
"module": "./dist/esm/index.js",
|
|
20
|
+
"types": "./dist/esm/index.d.ts",
|
|
21
|
+
"typings": "./dist/esm/index.d.ts",
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"types": "./dist/esm/index.d.ts",
|
|
25
|
+
"import": "./dist/esm/index.js",
|
|
26
|
+
"default": "./dist/cjs/index.js"
|
|
27
|
+
},
|
|
28
|
+
"./package.json": "./package.json"
|
|
29
|
+
},
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@lifi/sdk": "0.0.0-preview-1b774eec",
|
|
32
|
+
"@noble/hashes": "^1.8.0",
|
|
33
|
+
"@scure/base": "^1.2.6"
|
|
34
|
+
},
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"access": "public"
|
|
37
|
+
},
|
|
38
|
+
"files": [
|
|
39
|
+
"CHANGELOG.md",
|
|
40
|
+
"dist/**",
|
|
41
|
+
"!dist/**/*.tsbuildinfo",
|
|
42
|
+
"src/**/*.ts",
|
|
43
|
+
"!src/**/*.spec.ts",
|
|
44
|
+
"!src/**/*.test.ts",
|
|
45
|
+
"!src/**/*.mock.ts",
|
|
46
|
+
"!src/**/*.spec.ts",
|
|
47
|
+
"!src/**/*.handlers.ts",
|
|
48
|
+
"!src/**/*.tsbuildinfo",
|
|
49
|
+
"!**/__mocks__/**",
|
|
50
|
+
"!*.tmp",
|
|
51
|
+
"!*.env",
|
|
52
|
+
"!tsconfig.json"
|
|
53
|
+
],
|
|
54
|
+
"keywords": [
|
|
55
|
+
"swap",
|
|
56
|
+
"bridge",
|
|
57
|
+
"bridge-aggregation",
|
|
58
|
+
"cross-chain",
|
|
59
|
+
"cross-chain-applications",
|
|
60
|
+
"cross-chain-bridge",
|
|
61
|
+
"dapp",
|
|
62
|
+
"defi",
|
|
63
|
+
"zcash",
|
|
64
|
+
"zec",
|
|
65
|
+
"lifi",
|
|
66
|
+
"multi-chain",
|
|
67
|
+
"sdk",
|
|
68
|
+
"web3"
|
|
69
|
+
]
|
|
70
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ChainId,
|
|
3
|
+
ChainType,
|
|
4
|
+
LiFiErrorCode,
|
|
5
|
+
ProviderError,
|
|
6
|
+
type SDKProvider,
|
|
7
|
+
} from '@lifi/sdk'
|
|
8
|
+
import { isZcashAddress } from './utils/zcashAddress.js'
|
|
9
|
+
|
|
10
|
+
export function ZcashProvider(): SDKProvider {
|
|
11
|
+
return {
|
|
12
|
+
get type() {
|
|
13
|
+
return ChainType.UTXO
|
|
14
|
+
},
|
|
15
|
+
chainIds: [ChainId.ZEC],
|
|
16
|
+
isAddress: (address, chainId) =>
|
|
17
|
+
(chainId === undefined || chainId === ChainId.ZEC) &&
|
|
18
|
+
isZcashAddress(address),
|
|
19
|
+
resolveAddress: async () => undefined,
|
|
20
|
+
// No Zcash balance source yet, so every amount stays unknown.
|
|
21
|
+
getBalance: async (_client, _walletAddress, tokens) =>
|
|
22
|
+
tokens.map((token) => ({ ...token })),
|
|
23
|
+
getStepExecutor: async () => {
|
|
24
|
+
throw new ProviderError(
|
|
25
|
+
LiFiErrorCode.ProviderUnavailable,
|
|
26
|
+
'ZEC is a destination-only chain.'
|
|
27
|
+
)
|
|
28
|
+
},
|
|
29
|
+
}
|
|
30
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { sha256 } from '@noble/hashes/sha2'
|
|
2
|
+
import { createBase58check } from '@scure/base'
|
|
3
|
+
|
|
4
|
+
const base58check = createBase58check(sha256)
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Whether `address` is a mainnet transparent Zcash address (`t1` P2PKH or `t3`
|
|
8
|
+
* P2SH) with a valid checksum. The API handles transparent receivers only, so
|
|
9
|
+
* TEX, Sapling and unified addresses, and testnet forms, return `false`.
|
|
10
|
+
*/
|
|
11
|
+
export const isZcashAddress = (address: string): boolean => {
|
|
12
|
+
let payload: Uint8Array
|
|
13
|
+
try {
|
|
14
|
+
payload = base58check.decode(address)
|
|
15
|
+
} catch {
|
|
16
|
+
return false
|
|
17
|
+
}
|
|
18
|
+
// A 2-byte version prefix (0x1CB8 or 0x1CBD) and a 20-byte hash.
|
|
19
|
+
return (
|
|
20
|
+
payload.length === 22 &&
|
|
21
|
+
payload[0] === 0x1c &&
|
|
22
|
+
(payload[1] === 0xb8 || payload[1] === 0xbd)
|
|
23
|
+
)
|
|
24
|
+
}
|
package/src/version.ts
ADDED