@cheqd/sdk 5.3.4 → 5.3.5
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/build/esm/package.json +1 -1
- package/package.json +1 -1
- package/build/esm/build/LICENSE +0 -190
- package/build/esm/build/README.md +0 -382
- /package/build/esm/{build/index.d.ts → index.d.ts} +0 -0
- /package/build/esm/{build/index.d.ts.map → index.d.ts.map} +0 -0
- /package/build/esm/{build/index.js → index.js} +0 -0
- /package/build/esm/{build/index.js.map → index.js.map} +0 -0
- /package/build/esm/{build/modules → modules}/_.d.ts +0 -0
- /package/build/esm/{build/modules → modules}/_.d.ts.map +0 -0
- /package/build/esm/{build/modules → modules}/_.js +0 -0
- /package/build/esm/{build/modules → modules}/_.js.map +0 -0
- /package/build/esm/{build/modules → modules}/did.d.ts +0 -0
- /package/build/esm/{build/modules → modules}/did.d.ts.map +0 -0
- /package/build/esm/{build/modules → modules}/did.js +0 -0
- /package/build/esm/{build/modules → modules}/did.js.map +0 -0
- /package/build/esm/{build/modules → modules}/feeabstraction.d.ts +0 -0
- /package/build/esm/{build/modules → modules}/feeabstraction.d.ts.map +0 -0
- /package/build/esm/{build/modules → modules}/feeabstraction.js +0 -0
- /package/build/esm/{build/modules → modules}/feeabstraction.js.map +0 -0
- /package/build/esm/{build/modules → modules}/feemarket.d.ts +0 -0
- /package/build/esm/{build/modules → modules}/feemarket.d.ts.map +0 -0
- /package/build/esm/{build/modules → modules}/feemarket.js +0 -0
- /package/build/esm/{build/modules → modules}/feemarket.js.map +0 -0
- /package/build/esm/{build/modules → modules}/resource.d.ts +0 -0
- /package/build/esm/{build/modules → modules}/resource.d.ts.map +0 -0
- /package/build/esm/{build/modules → modules}/resource.js +0 -0
- /package/build/esm/{build/modules → modules}/resource.js.map +0 -0
- /package/build/esm/{build/querier.d.ts → querier.d.ts} +0 -0
- /package/build/esm/{build/querier.d.ts.map → querier.d.ts.map} +0 -0
- /package/build/esm/{build/querier.js → querier.js} +0 -0
- /package/build/esm/{build/querier.js.map → querier.js.map} +0 -0
- /package/build/esm/{build/registry.d.ts → registry.d.ts} +0 -0
- /package/build/esm/{build/registry.d.ts.map → registry.d.ts.map} +0 -0
- /package/build/esm/{build/registry.js → registry.js} +0 -0
- /package/build/esm/{build/registry.js.map → registry.js.map} +0 -0
- /package/build/esm/{build/signer.d.ts → signer.d.ts} +0 -0
- /package/build/esm/{build/signer.d.ts.map → signer.d.ts.map} +0 -0
- /package/build/esm/{build/signer.js → signer.js} +0 -0
- /package/build/esm/{build/signer.js.map → signer.js.map} +0 -0
- /package/build/esm/{build/types.d.ts → types.d.ts} +0 -0
- /package/build/esm/{build/types.d.ts.map → types.d.ts.map} +0 -0
- /package/build/esm/{build/types.js → types.js} +0 -0
- /package/build/esm/{build/types.js.map → types.js.map} +0 -0
- /package/build/esm/{build/utils.d.ts → utils.d.ts} +0 -0
- /package/build/esm/{build/utils.d.ts.map → utils.d.ts.map} +0 -0
- /package/build/esm/{build/utils.js → utils.js} +0 -0
- /package/build/esm/{build/utils.js.map → utils.js.map} +0 -0
package/build/esm/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cheqd/sdk-esm",
|
|
3
|
-
"version": "5.3.
|
|
3
|
+
"version": "5.3.5-develop.1",
|
|
4
4
|
"description": "A TypeScript SDK built with CosmJS to interact with cheqd network ledger",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Cheqd Foundation Limited (https://github.com/cheqd)",
|
package/package.json
CHANGED
package/build/esm/build/LICENSE
DELETED
|
@@ -1,190 +0,0 @@
|
|
|
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
|
-
Copyright 2021 Cheqd Foundation Limited (doing business as "cheqd")
|
|
179
|
-
|
|
180
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
181
|
-
you may not use this file except in compliance with the License.
|
|
182
|
-
You may obtain a copy of the License at
|
|
183
|
-
|
|
184
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
185
|
-
|
|
186
|
-
Unless required by applicable law or agreed to in writing, software
|
|
187
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
188
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
189
|
-
See the License for the specific language governing permissions and
|
|
190
|
-
limitations under the License.
|
|
@@ -1,382 +0,0 @@
|
|
|
1
|
-
# TypeScript SDK for cheqd
|
|
2
|
-
|
|
3
|
-
[](https://github.com/cheqd/sdk/releases/latest)  [](https://github.com/cheqd/sdk/blob/main/LICENSE)
|
|
4
|
-
|
|
5
|
-
[](https://github.com/cheqd/sdk/releases/)  [](https://github.com/cheqd/sdk/graphs/contributors)
|
|
6
|
-
|
|
7
|
-
[](https://github.com/cheqd/sdk/actions/workflows/dispatch.yml) [](https://github.com/cheqd/sdk/actions/workflows/codeql.yml) 
|
|
8
|
-
|
|
9
|
-
## ℹ️ Overview
|
|
10
|
-
|
|
11
|
-
The purpose of this [`@cheqd/sdk` NPM package](https://www.npmjs.com/package/@cheqd/sdk) is to provide base functionality for interacting with cheqd network. It combines the [Decentralized Identifier (DID)](https://docs.cheqd.io/product/architecture/adr-list/adr-001-cheqd-did-method) and [DID-Linked Resources](https://docs.cheqd.io/product/studio/did-linked-resources) modules, putting them into a Cosmos transaction wrapper using [CosmJS](https://github.com/cosmos/cosmjs).
|
|
12
|
-
|
|
13
|
-
This package is consumed by other SDKs/libraries such as [Veramo SDK for cheqd](https://docs.cheqd.io/product/sdk/veramo) and [Credo](https://github.com/openwallet-foundation/credo-ts) to add cheqd network support.
|
|
14
|
-
|
|
15
|
-
This package includes:
|
|
16
|
-
|
|
17
|
-
* [TypeScript Protobuf definitions](https://github.com/cheqd/ts-proto) for custom cheqd Cosmos SDK modules
|
|
18
|
-
* [CosmJS](https://github.com/cosmos/cosmjs), for base Cosmos SDK module functions
|
|
19
|
-
|
|
20
|
-
## 🆔 Features
|
|
21
|
-
|
|
22
|
-
Our identity documentation site provides [tutorials for utilising the identity features](https://docs.cheqd.io/product) on cheqd network.
|
|
23
|
-
|
|
24
|
-
With this SDK, developers are able to:
|
|
25
|
-
|
|
26
|
-
* ✅ Create a `did:cheqd` method [DID](https://docs.cheqd.io/product/architecture/adr-list/adr-001-cheqd-did-method)
|
|
27
|
-
* ✅ Update a `did:cheqd` method [DID](https://docs.cheqd.io/product/architecture/adr-list/adr-001-cheqd-did-method)
|
|
28
|
-
* ✅ Deactivate a `did:cheqd` method [DID](https://docs.cheqd.io/product/architecture/adr-list/adr-001-cheqd-did-method)
|
|
29
|
-
* ✅ Create or update [a DID-Linked Resource](https://docs.cheqd.io/product/studio/did-linked-resources)
|
|
30
|
-
|
|
31
|
-
### 🧰 Tooling
|
|
32
|
-
|
|
33
|
-
* ✅ **Raw payload creator**: Enables users to generate a valid raw DID payload which is ready to be populated, depending on the use case. For example, `did-provider-cheqd` leverages this helper in the CLI application.
|
|
34
|
-
* ✅ **Identity key converter**: Enables users to convert specific key formats from different kinds of SDKs, by transforming the input keys into valid sign inputs for a cheqd specific DID transaction (e.g. `createDidDocTx`, `updateDidDocTx`). For example, the Veramo SDK for cheqd uses this helper to enable users to pass a key in a Veramo SDK specific format to a cheqd sign input keys interface.
|
|
35
|
-
|
|
36
|
-
## 💰 Fee Abstraction
|
|
37
|
-
|
|
38
|
-
The Cheqd SDK provides comprehensive fee abstraction functionality that allows users to pay transaction fees using IBC tokens from other chains instead of native CHEQ tokens. This feature enables cross-chain interoperability and improved user experience by allowing users to transact without holding native tokens.
|
|
39
|
-
|
|
40
|
-
### Overview
|
|
41
|
-
|
|
42
|
-
Fee abstraction on Cheqd enables:
|
|
43
|
-
|
|
44
|
-
* **Cross-chain fee payments**: Pay transaction fees using tokens from other Cosmos chains
|
|
45
|
-
* **Host zone management**: Add and configure supported chains for fee abstraction
|
|
46
|
-
* **Automatic token swaps**: Convert IBC tokens to CHEQ for fee payment behind the scenes
|
|
47
|
-
* **Module account funding**: Provide liquidity for fee abstraction operations
|
|
48
|
-
|
|
49
|
-
### 📁 Module Files
|
|
50
|
-
|
|
51
|
-
The fee abstraction functionality is implemented in the following files:
|
|
52
|
-
|
|
53
|
-
**CJS (CommonJS)**:
|
|
54
|
-
|
|
55
|
-
* Main module: [`cjs/src/modules/feeabstraction.ts`](./cjs/src/modules/feeabstraction.ts)
|
|
56
|
-
* Type definitions: [`cjs/src/types.ts`](./cjs/src/types.ts)
|
|
57
|
-
|
|
58
|
-
**ESM (ECMAScript Modules)**:
|
|
59
|
-
|
|
60
|
-
* Main module: [`esm/src/modules/feeabstraction.ts`](./esm/src/modules/feeabstraction.ts)
|
|
61
|
-
* Type definitions: [`esm/src/types.ts`](./esm/src/types.ts)
|
|
62
|
-
|
|
63
|
-
### 🚀 Basic Usage
|
|
64
|
-
|
|
65
|
-
#### Setting up Fee Abstraction
|
|
66
|
-
|
|
67
|
-
```typescript
|
|
68
|
-
import { createCheqdSDK, CheqdNetwork } from '@cheqd/sdk';
|
|
69
|
-
|
|
70
|
-
// Create wallet instance (e.g., using DirectSecp256k1HdWallet from CosmJS)
|
|
71
|
-
import { DirectSecp256k1HdWallet } from '@cosmjs/proto-signing';
|
|
72
|
-
const wallet = await DirectSecp256k1HdWallet.fromMnemonic('your mnemonic here', { prefix: 'cheqd' }); // replace with your mnemonic, remember to keep it secure
|
|
73
|
-
|
|
74
|
-
// Set up the SDK options with fee abstraction capabilities
|
|
75
|
-
const sdkOptions = {
|
|
76
|
-
modules: [
|
|
77
|
-
FeeabstractionModule as unknown as AbstractCheqdSDKModule,
|
|
78
|
-
// other modules can be added here
|
|
79
|
-
],
|
|
80
|
-
// other SDK options can be configured here
|
|
81
|
-
rpcUrl: 'https://rpc.cheqd.network', // or your preferred RPC endpoint
|
|
82
|
-
network: CheqdNetwork.Testnet, // or CheqdNetwork.Mainnet
|
|
83
|
-
wallet,
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
// Initialize SDK with fee abstraction support
|
|
87
|
-
const sdk = await createCheqdSDK(sdkOptions);
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
### 💳 IBC Asset Requirements
|
|
91
|
-
|
|
92
|
-
Before using fee abstraction functionality, ensure that your account has the necessary IBC assets bridged from supported chains like Osmosis:
|
|
93
|
-
|
|
94
|
-
#### Bridging Assets from Osmosis
|
|
95
|
-
|
|
96
|
-
To use fee abstraction, you'll need to have IBC tokens in your Cheqd account that were bridged from Osmosis:
|
|
97
|
-
|
|
98
|
-
```typescript
|
|
99
|
-
// Example IBC denominations that might be supported
|
|
100
|
-
const supportedIBCDenoms = [
|
|
101
|
-
'ibc/1480B8FD20AD5FCAE81EA87584D269547DD4D436843C1D20F15E00EB64743EF4', // ATOM from Osmosis
|
|
102
|
-
'ibc/14F9BC3E44B8A9C1BE1FB08980FAB87034C9905EF17CF2442BE1FA40E2E5F16', // OSMO from Osmosis
|
|
103
|
-
// Add other supported IBC denominations
|
|
104
|
-
];
|
|
105
|
-
|
|
106
|
-
// Your account should have these IBC tokens available
|
|
107
|
-
async function checkIBCBalances(accountAddress: string) {
|
|
108
|
-
const balances = await sdk.querier.bank.allBalances({ address: accountAddress });
|
|
109
|
-
|
|
110
|
-
const ibcBalances = balances.balances.filter(balance =>
|
|
111
|
-
balance.denom.startsWith('ibc/')
|
|
112
|
-
);
|
|
113
|
-
|
|
114
|
-
console.log('Available IBC tokens:', ibcBalances);
|
|
115
|
-
return ibcBalances;
|
|
116
|
-
}
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
**Note**: To bridge assets from Osmosis to Cheqd, you can use:
|
|
120
|
-
|
|
121
|
-
* [Osmosis Frontend](https://app.osmosis.zone/) for manual transfers
|
|
122
|
-
* [IBC Transfer tools](https://ibc.fun/) for cross-chain transfers
|
|
123
|
-
* Direct IBC transfer commands via CLI
|
|
124
|
-
|
|
125
|
-
### 📊 Querying Fee Abstraction Data
|
|
126
|
-
|
|
127
|
-
#### Host Chain Configuration
|
|
128
|
-
|
|
129
|
-
```typescript
|
|
130
|
-
async function queryHostChainConfig() {
|
|
131
|
-
const configResponse = await sdk.querier[defaultFeeabstractionExtensionKey].hostChainConfig({
|
|
132
|
-
// Query parameters can be added here if needed
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
console.log('Host chain configuration:', configResponse);
|
|
136
|
-
}
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
#### Module Balances
|
|
140
|
-
|
|
141
|
-
```typescript
|
|
142
|
-
async function queryModuleBalances() {
|
|
143
|
-
const balancesResponse = await sdk.querier[defaultFeeabstractionExtensionKey].feeabsModuleBalances({
|
|
144
|
-
// Query parameters can be added here if needed
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
console.log('Fee abstraction module balances:', balancesResponse);
|
|
148
|
-
}
|
|
149
|
-
```
|
|
150
|
-
|
|
151
|
-
#### Osmosis TWAP Data
|
|
152
|
-
|
|
153
|
-
```typescript
|
|
154
|
-
async function queryOsmosisTWAP() {
|
|
155
|
-
const twapResponse = await sdk.querier[defaultFeeabstractionExtensionKey].osmosisArithmeticTwap({
|
|
156
|
-
poolId: '1', // Pool ID on Osmosis
|
|
157
|
-
baseAsset: 'uosmo',
|
|
158
|
-
quoteAsset: 'ibc/ABC123...',
|
|
159
|
-
startTime: new Date(Date.now() - 24 * 60 * 60 * 1000), // 24 hours ago
|
|
160
|
-
endTime: new Date()
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
console.log('TWAP data:', twapResponse);
|
|
164
|
-
}
|
|
165
|
-
```
|
|
166
|
-
|
|
167
|
-
### 🏛️ Governance Operations
|
|
168
|
-
|
|
169
|
-
Fee abstraction supports governance proposals for configuration changes:
|
|
170
|
-
|
|
171
|
-
#### Adding a Host Zone
|
|
172
|
-
|
|
173
|
-
```typescript
|
|
174
|
-
import { MsgAddHostZone } from '@cheqd/ts-proto/feeabstraction/feeabs/v1beta1/index';
|
|
175
|
-
|
|
176
|
-
async function proposeAddHostZone() {
|
|
177
|
-
const hostZoneData: MsgAddHostZone = {
|
|
178
|
-
authority: 'cheqd1gov...', // Governance authority address
|
|
179
|
-
hostChainId: 'osmosis-1',
|
|
180
|
-
connectionId: 'connection-0',
|
|
181
|
-
ibcDenom: 'ibc/ABC123...',
|
|
182
|
-
nativeDenom: 'uosmo',
|
|
183
|
-
transferChannelId: 'channel-0',
|
|
184
|
-
minSwapAmount: '1000'
|
|
185
|
-
};
|
|
186
|
-
|
|
187
|
-
const proposalResponse = await sdk.addHostZoneProposal(
|
|
188
|
-
hostZoneData,
|
|
189
|
-
'Add Osmosis as Host Zone', // Proposal title
|
|
190
|
-
[{ denom: 'ncheq', amount: '10000000000' }], // Deposit
|
|
191
|
-
'cheqd1proposer...', // Proposer address
|
|
192
|
-
{
|
|
193
|
-
amount: [{ denom: 'ncheq', amount: '5000' }],
|
|
194
|
-
gas: '300000'
|
|
195
|
-
}
|
|
196
|
-
);
|
|
197
|
-
|
|
198
|
-
console.log('Host zone proposal submitted:', proposalResponse.transactionHash);
|
|
199
|
-
}
|
|
200
|
-
```
|
|
201
|
-
|
|
202
|
-
#### Updating Host Zone Configuration
|
|
203
|
-
|
|
204
|
-
```typescript
|
|
205
|
-
async function proposeUpdateHostZone() {
|
|
206
|
-
const updateData = {
|
|
207
|
-
authority: 'cheqd1gov...',
|
|
208
|
-
hostChainId: 'osmosis-1',
|
|
209
|
-
// Updated configuration parameters
|
|
210
|
-
minSwapAmount: '2000' // New minimum swap amount
|
|
211
|
-
};
|
|
212
|
-
|
|
213
|
-
const updateResponse = await sdk.updateHostZoneProposal(
|
|
214
|
-
updateData,
|
|
215
|
-
'Update Osmosis Host Zone Configuration',
|
|
216
|
-
[{ denom: 'ncheq', amount: '10000000000' }],
|
|
217
|
-
'cheqd1proposer...',
|
|
218
|
-
{
|
|
219
|
-
amount: [{ denom: 'ncheq', amount: '5000' }],
|
|
220
|
-
gas: '300000'
|
|
221
|
-
}
|
|
222
|
-
);
|
|
223
|
-
|
|
224
|
-
console.log('Update proposal submitted:', updateResponse.transactionHash);
|
|
225
|
-
}
|
|
226
|
-
```
|
|
227
|
-
|
|
228
|
-
### 🔧 Advanced Configuration
|
|
229
|
-
|
|
230
|
-
#### TWAP Query for Price Data
|
|
231
|
-
|
|
232
|
-
```typescript
|
|
233
|
-
async function sendTWAPQuery() {
|
|
234
|
-
const twapQueryResponse = await sdk.sendQueryIbcDenomTWAP(
|
|
235
|
-
'cheqd1sender...',
|
|
236
|
-
'ibc/ABC123...', // IBC denomination
|
|
237
|
-
{
|
|
238
|
-
amount: [{ denom: 'ncheq', amount: '5000' }],
|
|
239
|
-
gas: '200000'
|
|
240
|
-
},
|
|
241
|
-
'Query TWAP for price data'
|
|
242
|
-
);
|
|
243
|
-
|
|
244
|
-
console.log('TWAP query sent:', twapQueryResponse);
|
|
245
|
-
}
|
|
246
|
-
```
|
|
247
|
-
|
|
248
|
-
#### Complete Fee Abstraction Workflow
|
|
249
|
-
|
|
250
|
-
```typescript
|
|
251
|
-
async function completeFeeAbstractionWorkflow() {
|
|
252
|
-
try {
|
|
253
|
-
// 1. Check account has IBC assets available
|
|
254
|
-
const accountAddress = 'cheqd1sender...';
|
|
255
|
-
const ibcBalances = await checkIBCBalances(accountAddress);
|
|
256
|
-
|
|
257
|
-
if (ibcBalances.length === 0) {
|
|
258
|
-
throw new Error('No IBC tokens available. Please bridge assets from Osmosis first.');
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
// 2. Query host chain configuration
|
|
262
|
-
const hostConfig = await sdk.querier[defaultFeeabstractionExtensionKey].hostChainConfig({});
|
|
263
|
-
console.log('Host chain config:', hostConfig);
|
|
264
|
-
|
|
265
|
-
// 3. Query current module balances
|
|
266
|
-
const moduleBalances = await sdk.querier[defaultFeeabstractionExtensionKey].feeabsModuleBalances({});
|
|
267
|
-
console.log('Module balances:', moduleBalances);
|
|
268
|
-
|
|
269
|
-
// 4. Use IBC tokens for transaction fees directly
|
|
270
|
-
// Fee abstraction automatically handles the conversion behind the scenes
|
|
271
|
-
console.log('Fee abstraction is ready for use with IBC tokens');
|
|
272
|
-
|
|
273
|
-
console.log('Fee abstraction workflow completed successfully');
|
|
274
|
-
} catch (error) {
|
|
275
|
-
console.error('Fee abstraction workflow failed:', error);
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
```
|
|
279
|
-
|
|
280
|
-
### 📋 Error Handling
|
|
281
|
-
|
|
282
|
-
```typescript
|
|
283
|
-
async function handleFeeAbstractionErrors() {
|
|
284
|
-
try {
|
|
285
|
-
// Example: Using fee abstraction in a DID operation
|
|
286
|
-
const didCreationResponse = await sdk.createDidDocTx(
|
|
287
|
-
'cheqd1sender...',
|
|
288
|
-
didDocument,
|
|
289
|
-
'key1',
|
|
290
|
-
{ amount: [{ denom: 'ibc/ABC123...', amount: '100000' }], gas: '300000' }
|
|
291
|
-
);
|
|
292
|
-
} catch (error) {
|
|
293
|
-
if (error.message.includes('insufficient funds')) {
|
|
294
|
-
console.error('Account has insufficient IBC tokens');
|
|
295
|
-
console.log('Please bridge more assets from Osmosis');
|
|
296
|
-
} else if (error.message.includes('invalid denom')) {
|
|
297
|
-
console.error('Invalid IBC denomination provided');
|
|
298
|
-
console.log('Check supported IBC denominations');
|
|
299
|
-
} else if (error.message.includes('host zone not found')) {
|
|
300
|
-
console.error('Host zone not configured for this IBC token');
|
|
301
|
-
} else {
|
|
302
|
-
console.error('Unexpected fee abstraction error:', error);
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
```
|
|
307
|
-
|
|
308
|
-
### 🔗 Integration with Other Modules
|
|
309
|
-
|
|
310
|
-
Fee abstraction can be used alongside other Cheqd SDK modules:
|
|
311
|
-
|
|
312
|
-
```typescript
|
|
313
|
-
async function useWithDIDOperations() {
|
|
314
|
-
// Create a DID document using fee abstraction for payment
|
|
315
|
-
const didDocument = {
|
|
316
|
-
// DID document structure
|
|
317
|
-
};
|
|
318
|
-
|
|
319
|
-
// Use IBC tokens for fee payment via fee abstraction
|
|
320
|
-
const didCreationResponse = await sdk.createDidDocTx(
|
|
321
|
-
'cheqd1creator...',
|
|
322
|
-
didDocument,
|
|
323
|
-
'key1',
|
|
324
|
-
{
|
|
325
|
-
amount: [{ denom: 'ibc/ABC123...', amount: '100000' }], // Pay with IBC tokens
|
|
326
|
-
gas: '300000'
|
|
327
|
-
}
|
|
328
|
-
);
|
|
329
|
-
|
|
330
|
-
console.log('DID created with fee abstraction:', didCreationResponse.transactionHash);
|
|
331
|
-
}
|
|
332
|
-
```
|
|
333
|
-
|
|
334
|
-
### 💡 Best Practices
|
|
335
|
-
|
|
336
|
-
1. **Bridge IBC Assets First**: Ensure you have bridged the required IBC tokens from Osmosis before attempting to use fee abstraction
|
|
337
|
-
2. **Check Account Balances**: Verify your account has sufficient IBC token balances before transactions
|
|
338
|
-
3. **Handle IBC Delays**: Account for IBC token transfer delays in your application flow
|
|
339
|
-
4. **Validate Host Zones**: Always verify that host zones are properly configured before using IBC tokens
|
|
340
|
-
5. **Error Recovery**: Implement robust error handling for network and token-related issues
|
|
341
|
-
6. **Gas Estimation**: Use appropriate gas limits for transactions using fee abstraction
|
|
342
|
-
7. **Monitor Supported Denominations**: Keep track of which IBC denominations are supported for fee abstraction
|
|
343
|
-
|
|
344
|
-
For more detailed information about fee abstraction concepts and implementation, visit our [fee abstraction documentation](https://docs.cheqd.io/product).
|
|
345
|
-
|
|
346
|
-
## 🧑💻 Developer Guide
|
|
347
|
-
|
|
348
|
-
### Installing in ESM projects
|
|
349
|
-
|
|
350
|
-
To install this NPM package in a project that needs ESM builds, use our `latest` release channel to install the stable version:
|
|
351
|
-
|
|
352
|
-
```bash
|
|
353
|
-
npm install @cheqd/sdk@latest
|
|
354
|
-
```
|
|
355
|
-
|
|
356
|
-
To install beta releases instead, use our `-develop` releases from the `beta` channel:
|
|
357
|
-
|
|
358
|
-
```bash
|
|
359
|
-
npm install @cheqd/sdk@beta
|
|
360
|
-
```
|
|
361
|
-
|
|
362
|
-
### Installing in CommonJS projects
|
|
363
|
-
|
|
364
|
-
To install this NPM package in a project that needs CommonJS builds, use our `cjs` release channel to install the latest stable CommonJS version:
|
|
365
|
-
|
|
366
|
-
```bash
|
|
367
|
-
npm install @cheqd/sdk@cjs
|
|
368
|
-
```
|
|
369
|
-
|
|
370
|
-
## 📖 Documentation
|
|
371
|
-
|
|
372
|
-
Our [product documentation site](https://docs.cheqd.io/product) explains how `@cheqd/sdk` is [consumed in Veramo SDK for cheqd](https://docs.cheqd.io/product/sdk/veramo) (as an example of how this package can be consumed).
|
|
373
|
-
|
|
374
|
-
## 💬 Community
|
|
375
|
-
|
|
376
|
-
Our [**Discord server**](http://cheqd.link/discord-github) is the primary chat channel for our open-source community, software developers, and node operators.
|
|
377
|
-
|
|
378
|
-
Please reach out to us there for discussions, help, and feedback on the project.
|
|
379
|
-
|
|
380
|
-
## 🙋 Find us elsewhere
|
|
381
|
-
|
|
382
|
-
[](https://t.me/cheqd) [](http://cheqd.link/discord-github) [](https://twitter.com/intent/follow?screen\_name=cheqd\_io) [](http://cheqd.link/linkedin) [](https://blog.cheqd.io) [](https://www.youtube.com/channel/UCBUGvvH6t3BAYo5u41hJPzw/)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|