@decentro-dev/polkadot-sufficient-assets 0.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.
Files changed (123) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +60 -0
  3. package/package.json +99 -0
  4. package/packages/client/README.md +333 -0
  5. package/packages/client/dist/chain-specs/ksmcc3/index.d.mts +1 -0
  6. package/packages/client/dist/chain-specs/ksmcc3/index.d.ts +1 -0
  7. package/packages/client/dist/chain-specs/ksmcc3/index.js +2 -0
  8. package/packages/client/dist/chain-specs/ksmcc3/index.mjs +2 -0
  9. package/packages/client/dist/chain-specs/ksmcc3_asset_hub/index.d.mts +1 -0
  10. package/packages/client/dist/chain-specs/ksmcc3_asset_hub/index.d.ts +1 -0
  11. package/packages/client/dist/chain-specs/ksmcc3_asset_hub/index.js +2 -0
  12. package/packages/client/dist/chain-specs/ksmcc3_asset_hub/index.mjs +2 -0
  13. package/packages/client/dist/chain-specs/paseo/index.d.mts +1 -0
  14. package/packages/client/dist/chain-specs/paseo/index.d.ts +1 -0
  15. package/packages/client/dist/chain-specs/paseo/index.js +2 -0
  16. package/packages/client/dist/chain-specs/paseo/index.mjs +2 -0
  17. package/packages/client/dist/chain-specs/paseo_asset_hub/index.d.mts +1 -0
  18. package/packages/client/dist/chain-specs/paseo_asset_hub/index.d.ts +1 -0
  19. package/packages/client/dist/chain-specs/paseo_asset_hub/index.js +2 -0
  20. package/packages/client/dist/chain-specs/paseo_asset_hub/index.mjs +2 -0
  21. package/packages/client/dist/chain-specs/polkadot/index.d.mts +1 -0
  22. package/packages/client/dist/chain-specs/polkadot/index.d.ts +1 -0
  23. package/packages/client/dist/chain-specs/polkadot/index.js +2 -0
  24. package/packages/client/dist/chain-specs/polkadot/index.mjs +2 -0
  25. package/packages/client/dist/chain-specs/polkadot_asset_hub/index.d.mts +1 -0
  26. package/packages/client/dist/chain-specs/polkadot_asset_hub/index.d.ts +1 -0
  27. package/packages/client/dist/chain-specs/polkadot_asset_hub/index.js +2 -0
  28. package/packages/client/dist/chain-specs/polkadot_asset_hub/index.mjs +2 -0
  29. package/packages/client/dist/chain-specs/rococo_v2_2/index.d.mts +1 -0
  30. package/packages/client/dist/chain-specs/rococo_v2_2/index.d.ts +1 -0
  31. package/packages/client/dist/chain-specs/rococo_v2_2/index.js +2 -0
  32. package/packages/client/dist/chain-specs/rococo_v2_2/index.mjs +2 -0
  33. package/packages/client/dist/chain-specs/rococo_v2_2_asset_hub/index.d.mts +1 -0
  34. package/packages/client/dist/chain-specs/rococo_v2_2_asset_hub/index.d.ts +1 -0
  35. package/packages/client/dist/chain-specs/rococo_v2_2_asset_hub/index.js +2 -0
  36. package/packages/client/dist/chain-specs/rococo_v2_2_asset_hub/index.mjs +2 -0
  37. package/packages/client/dist/chain-specs/westend2/index.d.mts +1 -0
  38. package/packages/client/dist/chain-specs/westend2/index.d.ts +1 -0
  39. package/packages/client/dist/chain-specs/westend2/index.js +2 -0
  40. package/packages/client/dist/chain-specs/westend2/index.mjs +2 -0
  41. package/packages/client/dist/chain-specs/westend2_asset_hub/index.d.mts +1 -0
  42. package/packages/client/dist/chain-specs/westend2_asset_hub/index.d.ts +1 -0
  43. package/packages/client/dist/chain-specs/westend2_asset_hub/index.js +2 -0
  44. package/packages/client/dist/chain-specs/westend2_asset_hub/index.mjs +2 -0
  45. package/packages/client/dist/index.d.mts +106 -0
  46. package/packages/client/dist/index.d.ts +106 -0
  47. package/packages/client/dist/index.js +2 -0
  48. package/packages/client/dist/index.mjs +2 -0
  49. package/packages/client/dist/smoldot/from-node-worker/index.d.mts +1 -0
  50. package/packages/client/dist/smoldot/from-node-worker/index.d.ts +1 -0
  51. package/packages/client/dist/smoldot/from-node-worker/index.js +2 -0
  52. package/packages/client/dist/smoldot/from-node-worker/index.mjs +2 -0
  53. package/packages/client/dist/smoldot/from-worker/index.d.mts +1 -0
  54. package/packages/client/dist/smoldot/from-worker/index.d.ts +1 -0
  55. package/packages/client/dist/smoldot/from-worker/index.js +2 -0
  56. package/packages/client/dist/smoldot/from-worker/index.mjs +2 -0
  57. package/packages/client/dist/smoldot/index.d.mts +14 -0
  58. package/packages/client/dist/smoldot/index.d.ts +14 -0
  59. package/packages/client/dist/smoldot/index.js +2 -0
  60. package/packages/client/dist/smoldot/index.mjs +2 -0
  61. package/packages/client/dist/smoldot/worker/index.d.mts +1 -0
  62. package/packages/client/dist/smoldot/worker/index.d.ts +1 -0
  63. package/packages/client/dist/smoldot/worker/index.js +2 -0
  64. package/packages/client/dist/smoldot/worker/index.mjs +2 -0
  65. package/packages/core/.papi/descriptors/dist/common-types.d.ts +21274 -0
  66. package/packages/core/.papi/descriptors/dist/descriptors-EQXQJ7SL.mjs +1 -0
  67. package/packages/core/.papi/descriptors/dist/descriptors.d.ts +11 -0
  68. package/packages/core/.papi/descriptors/dist/hdx.d.ts +366 -0
  69. package/packages/core/.papi/descriptors/dist/hdx_metadata-XH2Y6EGQ.mjs +1 -0
  70. package/packages/core/.papi/descriptors/dist/hdx_metadata.d.ts +2 -0
  71. package/packages/core/.papi/descriptors/dist/index.d.mts +24579 -0
  72. package/packages/core/.papi/descriptors/dist/index.d.ts +23 -0
  73. package/packages/core/.papi/descriptors/dist/index.js +1 -0
  74. package/packages/core/.papi/descriptors/dist/index.mjs +1 -0
  75. package/packages/core/.papi/descriptors/dist/kah.d.ts +434 -0
  76. package/packages/core/.papi/descriptors/dist/kah_metadata-OCBL5LAN.mjs +1 -0
  77. package/packages/core/.papi/descriptors/dist/kah_metadata.d.ts +2 -0
  78. package/packages/core/.papi/descriptors/dist/kusama.d.ts +291 -0
  79. package/packages/core/.papi/descriptors/dist/kusama_metadata-TGJ43LLG.mjs +1 -0
  80. package/packages/core/.papi/descriptors/dist/kusama_metadata.d.ts +2 -0
  81. package/packages/core/.papi/descriptors/dist/metadataTypes-MIM6CGSL.mjs +1 -0
  82. package/packages/core/.papi/descriptors/dist/metadataTypes.d.ts +2 -0
  83. package/packages/core/.papi/descriptors/dist/pah.d.ts +434 -0
  84. package/packages/core/.papi/descriptors/dist/pah_metadata-JG7F7QDO.mjs +1 -0
  85. package/packages/core/.papi/descriptors/dist/pah_metadata.d.ts +2 -0
  86. package/packages/core/.papi/descriptors/dist/paseo.d.ts +291 -0
  87. package/packages/core/.papi/descriptors/dist/paseo_metadata-5VVMOYKO.mjs +1 -0
  88. package/packages/core/.papi/descriptors/dist/paseo_metadata.d.ts +2 -0
  89. package/packages/core/.papi/descriptors/dist/paseoah.d.ts +242 -0
  90. package/packages/core/.papi/descriptors/dist/paseoah_metadata-KVQKFE5R.mjs +1 -0
  91. package/packages/core/.papi/descriptors/dist/paseoah_metadata.d.ts +2 -0
  92. package/packages/core/.papi/descriptors/dist/polkadot.d.ts +291 -0
  93. package/packages/core/.papi/descriptors/dist/polkadot_metadata-ASE5745E.mjs +1 -0
  94. package/packages/core/.papi/descriptors/dist/polkadot_metadata.d.ts +2 -0
  95. package/packages/core/.papi/descriptors/dist/rah.d.ts +434 -0
  96. package/packages/core/.papi/descriptors/dist/rah_metadata-FL7L2MWD.mjs +1 -0
  97. package/packages/core/.papi/descriptors/dist/rah_metadata.d.ts +2 -0
  98. package/packages/core/.papi/descriptors/dist/rococo.d.ts +291 -0
  99. package/packages/core/.papi/descriptors/dist/rococo_metadata-CHYQZIV5.mjs +1 -0
  100. package/packages/core/.papi/descriptors/dist/rococo_metadata.d.ts +2 -0
  101. package/packages/core/.papi/descriptors/dist/wah.d.ts +434 -0
  102. package/packages/core/.papi/descriptors/dist/wah_metadata-M2H6IX7C.mjs +1 -0
  103. package/packages/core/.papi/descriptors/dist/wah_metadata.d.ts +2 -0
  104. package/packages/core/.papi/descriptors/dist/westend.d.ts +291 -0
  105. package/packages/core/.papi/descriptors/dist/westend_metadata-IAM3KHRQ.mjs +1 -0
  106. package/packages/core/.papi/descriptors/dist/westend_metadata.d.ts +2 -0
  107. package/packages/core/.papi/descriptors/package.json +24 -0
  108. package/packages/core/.papi/metadata/hdx.scale +0 -0
  109. package/packages/core/.papi/metadata/kah.scale +0 -0
  110. package/packages/core/.papi/metadata/kusama.scale +0 -0
  111. package/packages/core/.papi/metadata/pah.scale +0 -0
  112. package/packages/core/.papi/metadata/paseo.scale +0 -0
  113. package/packages/core/.papi/metadata/paseoah.scale +0 -0
  114. package/packages/core/.papi/metadata/polkadot.scale +0 -0
  115. package/packages/core/.papi/metadata/rah.scale +0 -0
  116. package/packages/core/.papi/metadata/rococo.scale +0 -0
  117. package/packages/core/.papi/metadata/wah.scale +0 -0
  118. package/packages/core/.papi/metadata/westend.scale +0 -0
  119. package/packages/core/.papi/polkadot-api.json +50 -0
  120. package/packages/core/dist/index.d.mts +676 -0
  121. package/packages/core/dist/index.d.ts +676 -0
  122. package/packages/core/dist/index.js +1 -0
  123. package/packages/core/dist/index.mjs +1 -0
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 [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,60 @@
1
+ # Polkadot-Sufficient-Assets Monorepo
2
+
3
+ **Polkadot-Sufficient-Assets UI Library** is a developer-friendly tool that simplifies the process of building asset transfer functionalities within the Polkadot ecosystem. The library supports two types of transfers: same-chain transfers and multi-chain transfers via XCM (Cross-Consensus Messaging). Developers only need to configure the assets and chains to quickly integrate asset transfer features into their applications.
4
+
5
+ ## Prerequisites
6
+
7
+ Before using the library, ensure you have the following installed:
8
+
9
+ - **Node.js**: v20.6.0 or higher
10
+ - **pnpm**: v9.1.1 or higher
11
+
12
+ If you don't have `pnpm` installed, you can install it globally using `npm`:
13
+
14
+ ```bash
15
+ npm install -g pnpm
16
+ ```
17
+
18
+ ### Installation
19
+
20
+ Once the prerequisites are installed, navigate to the root directory of the project and run the following command to install the necessary dependencies:
21
+
22
+ ```bash
23
+ pnpm install
24
+ ```
25
+
26
+ ### Generate papi descriptors
27
+
28
+ To generate the PAPI descriptors required by the library, run the following command:
29
+
30
+ ```bash
31
+ pnpm papi:generate
32
+ ```
33
+
34
+ ### Running the Example Website (Development Mode)
35
+
36
+ To start the development server and test the website, use the command below:
37
+
38
+ ```bash
39
+ pnpm dev
40
+ ```
41
+
42
+ This will start all packages and expose the application at http://localhost:5173/ in your browser.
43
+
44
+ ---
45
+
46
+ ### With Docker Compose
47
+
48
+ To run the mini apps with docker compose, run the following command:
49
+
50
+ ```bash
51
+ docker-compose -f docker-compose.yml up -d
52
+ ```
53
+
54
+ ---
55
+
56
+ ### Running the Documentation Website
57
+
58
+ ```bash
59
+ pnpm dev:web
60
+ ```
package/package.json ADDED
@@ -0,0 +1,99 @@
1
+ {
2
+ "name": "@decentro-dev/polkadot-sufficient-assets",
3
+ "version": "0.0.1",
4
+ "description": "polkadot-sufficient-assets",
5
+ "license": "Apache-2.0",
6
+ "main": "./packages/client/dist/index.js",
7
+ "module": "./packages/client/dist/index.mjs",
8
+ "types": "./packages/client/dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./packages/client/dist/index.d.ts",
12
+ "module": "./packages/client/dist/index.mjs",
13
+ "import": "./packages/client/dist/index.mjs",
14
+ "require": "./packages/client/dist/index.js"
15
+ },
16
+ "./smoldot": {
17
+ "types": "./packages/client/dist/smoldot/index.d.ts",
18
+ "module": "./packages/client/dist/smoldot/index.mjs",
19
+ "import": "./packages/client/dist/smoldot/index.mjs",
20
+ "require": "./packages/client/dist/smoldot/index.js"
21
+ },
22
+ "./smoldot/*": {
23
+ "types": "./packages/client/dist/smoldot/*/index.d.ts",
24
+ "module": "./packages/client/dist/smoldot/*/index.mjs",
25
+ "import": "./packages/client/dist/smoldot/*/index.mjs",
26
+ "require": "./packages/client/dist/smoldot/*/index.js"
27
+ },
28
+ "./chain-specs/*": {
29
+ "types": "./packages/client/dist/chain-specs/*/index.d.ts",
30
+ "module": "./packages/client/dist/chain-specs/*/index.mjs",
31
+ "import": "./packages/client/dist/chain-specs/*/index.mjs",
32
+ "require": "./packages/client/dist/chain-specs/*/index.js"
33
+ }
34
+ },
35
+ "scripts": {
36
+ "clean:bundle": "rimraf dist && turbo clean:bundle",
37
+ "clean:papi": "rimraf dist && turbo clean:papi",
38
+ "clean:node_modules": "turbo daemon stop && turbo clean && pnpx rimraf node_modules && pnpx turbo clean:node_modules ",
39
+ "clean:turbo": "turbo daemon stop && rimraf .turbo && turbo clean:turbo",
40
+ "clean": "pnpm clean:bundle && pnpm clean:papi && pnpm clean:turbo && pnpm clean:node_modules",
41
+ "clean:install": "pnpm clean:node_modules && pnpm install --frozen-lockfile",
42
+ "build:package": "pnpm clean:bundle && turbo build:core && turbo build:client",
43
+ "build": "pnpm build:package && turbo build:app",
44
+ "dev": "pnpm clean:bundle && turbo ready && turbo watch dev --concurrency 20",
45
+ "dev:angular": "pnpm clean:bundle && turbo watch dev:angular --concurrency 20",
46
+ "dev:vue": "pnpm clean:bundle && turbo watch dev:vue --concurrency 20",
47
+ "dev:web": "pnpm clean:bundle && turbo dev:web",
48
+ "build:web": "pnpm clean:bundle && pnpm build:package && turbo build:web",
49
+ "dev:app": "pnpm clean:bundle && turbo dev:app",
50
+ "preview": "turbo preview --filter=mini-app",
51
+ "papi:generate": "turbo papi:generate",
52
+ "type-check": "turbo type-check",
53
+ "lint": "turbo lint --continue --",
54
+ "lint:fix": "turbo lint --continue -- --apply",
55
+ "format": "turbo format --continue --",
56
+ "format:fix": "turbo format --continue -- --write",
57
+ "test": "turbo test",
58
+ "test:cov": "turbo test:cov",
59
+ "test:client": "turbo test:client",
60
+ "test:client:cov": "turbo test:client:cov",
61
+ "prepare": "husky",
62
+ "update-version": "run-script-os",
63
+ "update-version:win32": "bash update_version.sh",
64
+ "update-version:default": "./update_version.sh"
65
+ },
66
+ "type": "module",
67
+ "files": ["packages/client/dist", "packages/client/README.md", "packages/core/dist", "packages/core/.papi"],
68
+ "peerDependencies": {
69
+ "@types/react": "^17.0.0 || ^18.0.0",
70
+ "react": "^17.0.0 || ^18.0.0",
71
+ "react-dom": "^17.0.0 || ^18.0.0"
72
+ },
73
+ "devDependencies": {
74
+ "@biomejs/biome": "1.9.0",
75
+ "@types/node": "^20.16.3",
76
+ "autoprefixer": "^10.4.19",
77
+ "cross-env": "^7.0.3",
78
+ "husky": "^9.1.4",
79
+ "lint-staged": "^15.2.7",
80
+ "rimraf": "^6.0.1",
81
+ "run-script-os": "^1.1.6",
82
+ "tsup": "^8.2.4",
83
+ "turbo": "^2.0.12",
84
+ "typescript": "^5.6.2"
85
+ },
86
+ "lint-staged": {
87
+ "*.{js,ts,cjs,mjs,d.cts,d.mts,jsx,tsx,json,jsonc}": ["pnpm format:fix"]
88
+ },
89
+ "packageManager": "pnpm@9.1.1",
90
+ "engines": {
91
+ "node": ">=20.6.0"
92
+ },
93
+ "optionalDependencies": {
94
+ "@rollup/rollup-linux-x64-gnu": "4.6.1"
95
+ },
96
+ "publishConfig": {
97
+ "access": "public"
98
+ }
99
+ }
@@ -0,0 +1,333 @@
1
+ # Polkadot-Sufficient-Assets UI Library Documentation
2
+
3
+ ## Overview
4
+
5
+ **Polkadot-Sufficient-Assets UI Library** A frictionless UI Library to integrate Polkadot sufficient assets into your dApp, enabling transaction fees to be paid in stablecoins.
6
+
7
+ ## Key Features
8
+
9
+ - **Same Chain Transfers**: Quickly configure and transfer assets within the same chain.
10
+ - **Multi-Chain Transfers**: Leverage XCM to transfer assets across different chains.
11
+ - **Configurable Tokens and Chains**: Support for native and non-native tokens, with easy configuration for custom chains and assets.
12
+
13
+ ## Prerequisites
14
+
15
+ Before you begin using the library, ensure that you have the following:
16
+
17
+ - A Polkadot wallet.
18
+ - A basic understanding of Polkadot, parachains, and how XCM (Cross-Consensus Messaging) works. For more information, check the [Polkadot documentation](https://wiki.polkadot.network/).
19
+
20
+ ## Installation
21
+
22
+ Install the library using npm or yarn:
23
+
24
+ ```bash
25
+ npm install polkadot-sufficient-assets
26
+ ```
27
+
28
+ or
29
+
30
+ ```bash
31
+ yarn add polkadot-sufficient-assets
32
+ ```
33
+
34
+ or
35
+
36
+ ```bash
37
+ pnpm add polkadot-sufficient-assets
38
+ ```
39
+
40
+ ## Usage
41
+
42
+ ### 1. Transfer on the Same Chain
43
+
44
+ To set up same-chain transfers, follow the steps below:
45
+
46
+ **Step 1: Define the Asset and Chain**
47
+ The library comes with some predefined tokens, but you can also define your own if necessary. Here's how to use predefined tokens:
48
+
49
+ ```typescript
50
+ import { createToken } from "./create-token";
51
+
52
+ export const tokens = {
53
+ WND: createToken({
54
+ type: "native",
55
+ decimals: 12,
56
+ symbol: "WND",
57
+ name: "Westend",
58
+ logo: "./img/tokens/WND.svg",
59
+ isSufficient: true,
60
+ }),
61
+ ROC: createToken({
62
+ type: "native",
63
+ decimals: 12,
64
+ symbol: "ROC",
65
+ name: "Rococo",
66
+ logo: "./img/tokens/ROC.svg",
67
+ isSufficient: true,
68
+ }),
69
+ // More predefined tokens...
70
+ };
71
+ ```
72
+
73
+ If your desired token is not predefined, you can create your own using the createToken function:
74
+
75
+ ```typescript
76
+ import { createToken } from "polkadot-sufficient-assets";
77
+
78
+ const myToken = createToken({
79
+ type: "asset",
80
+ assetId: 12345,
81
+ decimals: 18,
82
+ symbol: "MYT",
83
+ name: "MyToken",
84
+ logo: "./img/tokens/MYT.svg",
85
+ isSufficient: true,
86
+ });
87
+ ```
88
+
89
+ **Step 2: Define the Configuration**
90
+ Next, you need to define the configuration for the app, including the chain and token(s) to be used:
91
+
92
+ ```typescript
93
+ import {
94
+ chains,
95
+ createConfig,
96
+ createTheme,
97
+ tokens,
98
+ } from "polkadot-sufficient-assets";
99
+
100
+ export const config = createConfig({
101
+ sourceChains: [chains.polkadotAssetHubChain], // Specify the chain
102
+ tokens: {
103
+ pah: {
104
+ token: tokens.USDT, // Token you want to transfer
105
+ feeTokens: [tokens.DOT, tokens.USDT], // Tokens used to pay transaction fees
106
+ },
107
+ },
108
+ });
109
+ ```
110
+
111
+ **Here’s a breakdown of the configuration options:**
112
+
113
+ **sourceChains**: The network you want to transfer assets on. The library exports predefined chains, but you can also define your own (see below).
114
+ **tokens**: The assets you want to transfer, including tokens used for transaction fees. You can use native or asset-based tokens as fee tokens if supported by the chain.
115
+
116
+ **Defining a Custom Chain**
117
+ If you want to use a custom chain, you can create one using the createChain function:
118
+
119
+ ```typescript
120
+ import { createChain } from "polkadot-sufficient-assets";
121
+
122
+ const yourChain = createChain({
123
+ id: "pah",
124
+ name: "Polkadot Asset Hub",
125
+ specName: "asset-hub-polkadot",
126
+ wsUrls: ["wss://statemint-rpc.dwellir.com"], // WebSocket URL for RPC connection
127
+ relay: "polkadot", // The relay chain ('polkadot', 'kusama', etc.)
128
+ type: "system", // Type of chain ('system' or 'relay' or 'para')
129
+ chainId: 1000,
130
+ logo: "./chains/pah.svg", // Chain logo
131
+ blockExplorerUrl: "https://assethub-polkadot.subscan.io", // Block explorer URL
132
+ });
133
+ ```
134
+
135
+ **Rendering the UI**
136
+
137
+ For React:
138
+
139
+ ```jsx
140
+ import {
141
+ ConfigProvider,
142
+ createTheme,
143
+ PSADialog,
144
+ } from "polkadot-sufficient-assets";
145
+ import "./App.css";
146
+ import { libConfig } from "./lib/lib-config";
147
+
148
+ function App() {
149
+ const theme = createTheme({
150
+ palette: {
151
+ mode: "light",
152
+ },
153
+ });
154
+
155
+ return (
156
+ <ConfigProvider config={libConfig}>
157
+ <PSADialog theme={theme}>
158
+ <button
159
+ style={{
160
+ outline: "none",
161
+ color: "#fff",
162
+ }}
163
+ >
164
+ Open Dialog
165
+ </button>
166
+ </PSADialog>
167
+ </ConfigProvider>
168
+ );
169
+ }
170
+
171
+ export default App;
172
+ ```
173
+
174
+ **For other frameworks: We use web component so you can check out our [example folder](https://github.com/DecentroDev/polkadot-sufficient-assets/tree/main/example).**
175
+
176
+ ### 2. Multi-Chain Transfers via XCM
177
+
178
+ To configure multi-chain transfers, you will need to define additional parameters like assetPallet, assetIds, xcmExtrinsic, and location. Below is an example of how to configure a USDT transfer between the Hydration and Polkadot Asset Hub chains.
179
+
180
+ Example: USDT Transfer Between Hydration and Polkadot Asset Hub
181
+
182
+ You can set up USDT transfer using the following configuration:
183
+
184
+ ```typescript
185
+ import {
186
+ chains,
187
+ createToken,
188
+ tokens,
189
+ XcmV3Junction,
190
+ XcmV3Junctions,
191
+ XcmV3MultiassetAssetId,
192
+ XcmV3MultiassetFungibility,
193
+ XcmVersionedAssets,
194
+ } from "polkadot-sufficient-assets";
195
+
196
+ export const USDT = createToken({
197
+ type: "asset",
198
+ assetId: 10,
199
+ decimals: 6,
200
+ symbol: "USDT",
201
+ name: "Tether USD",
202
+ logo: "./img/tokens/USDT.svg",
203
+ isSufficient: true,
204
+
205
+ // Define the pallet where the asset is handled on each chain
206
+ assetPallet: {
207
+ [chains.hydration.id]: "tokens",
208
+ [chains.polkadotAssetHubChain.id]: "assets",
209
+ },
210
+
211
+ // Define the asset ID for each chain
212
+ assetIds: {
213
+ [chains.hydration.id]: 10,
214
+ [chains.polkadotAssetHubChain.id]: 1984,
215
+ },
216
+
217
+ // Define the extrinsic used for the XCM transfer on each chain
218
+ xcmExtrinsic: (originChain) => {
219
+ if (originChain.id === chains.polkadotAssetHubChain.id)
220
+ return "limited_reserve_transfer_assets";
221
+ if (originChain.id === chains.hydration.id)
222
+ return "XTokens.transfer_multiasset";
223
+ return "limited_reserve_transfer_assets";
224
+ },
225
+
226
+ // Define the location of the asset for XCM transfer
227
+ location: (plancks, originChain, destChain) => {
228
+ if (originChain.id === chains.hydration.id) {
229
+ return {
230
+ type: "V3",
231
+ value: {
232
+ id: XcmV3MultiassetAssetId.Concrete({
233
+ parents: 1,
234
+ interior: XcmV3Junctions.X3([
235
+ XcmV3Junction.Parachain(destChain.chainId!),
236
+ XcmV3Junction.PalletInstance(50),
237
+ XcmV3Junction.GeneralIndex(1984n),
238
+ ]),
239
+ }),
240
+ fun: XcmV3MultiassetFungibility.Fungible(plancks),
241
+ },
242
+ };
243
+ }
244
+
245
+ return XcmVersionedAssets.V3([
246
+ {
247
+ id: XcmV3MultiassetAssetId.Concrete({
248
+ parents: 0,
249
+ interior: XcmV3Junctions.X2([
250
+ XcmV3Junction.PalletInstance(50),
251
+ XcmV3Junction.GeneralIndex(1984n),
252
+ ]),
253
+ }),
254
+ fun: XcmV3MultiassetFungibility.Fungible(plancks),
255
+ },
256
+ ]);
257
+ },
258
+ });
259
+ ```
260
+
261
+ ## Explanation of XCM Parameters
262
+
263
+ ### `assetPallet`
264
+
265
+ Defines the pallet used to query balance information on each chain. Examples include `'assets'`, `'system'`, `'balances'`, `'tokens'`, and `'ormlTokens'`.
266
+
267
+ In the example:
268
+
269
+ - On **Hydration**, the asset is managed by the `tokens` pallet.
270
+ - On **Polkadot Asset Hub**, the asset is managed by the `assets` pallet.
271
+
272
+ ### `assetIds`
273
+
274
+ Specifies the asset ID on each chain, if native token then set to `0`.
275
+
276
+ For example:
277
+
278
+ - On **Hydration**, USDT has an asset ID of `10`.
279
+ - On **Polkadot Asset Hub**, USDT has an asset ID of `1984`.
280
+
281
+ ### `xcmExtrinsic`
282
+
283
+ Defines the extrinsic to be used for the XCM transfer. It accepts a callback function that takes the `originChain` and `destChain` as arguments and returns the appropriate extrinsic.
284
+
285
+ Possible values are:
286
+
287
+ - `limited_reserve_transfer_assets`
288
+ - `limited_teleport_assets`
289
+ - `reserve_transfer_assets`
290
+ - `teleport_assets`
291
+ - `XTokens.transfer_multiasset`
292
+ - `XTokens.transfer`
293
+ - `transfer_asset`
294
+
295
+ In the example:
296
+
297
+ - On **Polkadot Asset Hub**, the extrinsic is `limited_reserve_transfer_assets`.
298
+ - On **Hydration**, the extrinsic is `XTokens.transfer_multiasset`.
299
+
300
+ ### `location`
301
+
302
+ Defines the location of the asset on the `originChain` for the XCM transfer. This function takes `plancks`, `originChain`, and `destChain` as parameters and returns an `XcmVersionedAssets` or `XTokenVersionedAsset`.
303
+
304
+ In the example:
305
+
306
+ - On **Hydration**, the location is defined using `XcmV3Junctions.X3` with the parachain ID, pallet instance, and general index.
307
+ - On **Polkadot Asset Hub**, the location is defined using `XcmV3Junctions.X2`.
308
+
309
+ ## Updated Configuration
310
+
311
+ To set up the configuration for XCM transfers, including the use of USDT and other tokens, follow the example below:
312
+
313
+ ```typescript
314
+ import {
315
+ chains,
316
+ createConfig,
317
+ createTheme,
318
+ tokens,
319
+ } from "polkadot-sufficient-assets";
320
+ import { USDT } from "./assets";
321
+
322
+ export const libConfig = createConfig({
323
+ sourceChains: [chains.hydration],
324
+ tokens: {
325
+ hdx: {
326
+ token: USDT,
327
+ feeTokens: [tokens.HDX],
328
+ },
329
+ },
330
+ useXcmTransfer: true,
331
+ destinationChains: [chains.hydration],
332
+ });
333
+ ```