@kaspacom/kcc20-tx-builder 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (234) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +104 -0
  3. package/artifacts/KCC20.placeholder.json +77479 -0
  4. package/artifacts/KCC20FeeTicket.placeholder.json +16846 -0
  5. package/artifacts/KCC20Orderbook.placeholder.json +78001 -0
  6. package/artifacts/KCC20Vesting.placeholder.json +4298 -0
  7. package/artifacts/KCC20Wrapper.placeholder.json +12246 -0
  8. package/dist/abi.d.ts +44 -0
  9. package/dist/abi.d.ts.map +1 -0
  10. package/dist/abi.js +336 -0
  11. package/dist/abi.js.map +1 -0
  12. package/dist/action-source-resolver.d.ts +80 -0
  13. package/dist/action-source-resolver.d.ts.map +1 -0
  14. package/dist/action-source-resolver.js +412 -0
  15. package/dist/action-source-resolver.js.map +1 -0
  16. package/dist/artifacts.d.ts +14 -0
  17. package/dist/artifacts.d.ts.map +1 -0
  18. package/dist/artifacts.js +44 -0
  19. package/dist/artifacts.js.map +1 -0
  20. package/dist/builder.d.ts +12 -0
  21. package/dist/builder.d.ts.map +1 -0
  22. package/dist/builder.js +18 -0
  23. package/dist/builder.js.map +1 -0
  24. package/dist/cjs/abi.d.ts +43 -0
  25. package/dist/cjs/abi.js +361 -0
  26. package/dist/cjs/abi.js.map +1 -0
  27. package/dist/cjs/action-source-resolver.d.ts +79 -0
  28. package/dist/cjs/action-source-resolver.js +435 -0
  29. package/dist/cjs/action-source-resolver.js.map +1 -0
  30. package/dist/cjs/artifacts.d.ts +13 -0
  31. package/dist/cjs/artifacts.js +51 -0
  32. package/dist/cjs/artifacts.js.map +1 -0
  33. package/dist/cjs/builder.d.ts +11 -0
  34. package/dist/cjs/builder.js +22 -0
  35. package/dist/cjs/builder.js.map +1 -0
  36. package/dist/cjs/deploy-operation.d.ts +103 -0
  37. package/dist/cjs/deploy-operation.js +335 -0
  38. package/dist/cjs/deploy-operation.js.map +1 -0
  39. package/dist/cjs/encoding.d.ts +5 -0
  40. package/dist/cjs/encoding.js +51 -0
  41. package/dist/cjs/encoding.js.map +1 -0
  42. package/dist/cjs/engine.d.ts +40 -0
  43. package/dist/cjs/engine.js +8972 -0
  44. package/dist/cjs/engine.js.map +1 -0
  45. package/dist/cjs/errors.d.ts +7 -0
  46. package/dist/cjs/errors.js +23 -0
  47. package/dist/cjs/errors.js.map +1 -0
  48. package/dist/cjs/fee-ticket-operation.d.ts +204 -0
  49. package/dist/cjs/fee-ticket-operation.js +327 -0
  50. package/dist/cjs/fee-ticket-operation.js.map +1 -0
  51. package/dist/cjs/index.d.ts +27 -0
  52. package/dist/cjs/index.js +45 -0
  53. package/dist/cjs/index.js.map +1 -0
  54. package/dist/cjs/ladder-limit-orders.d.ts +41 -0
  55. package/dist/cjs/ladder-limit-orders.js +129 -0
  56. package/dist/cjs/ladder-limit-orders.js.map +1 -0
  57. package/dist/cjs/mint-availability-operation.d.ts +56 -0
  58. package/dist/cjs/mint-availability-operation.js +95 -0
  59. package/dist/cjs/mint-availability-operation.js.map +1 -0
  60. package/dist/cjs/models.d.ts +90 -0
  61. package/dist/cjs/models.js +6 -0
  62. package/dist/cjs/models.js.map +1 -0
  63. package/dist/cjs/operations.d.ts +6 -0
  64. package/dist/cjs/operations.js +41 -0
  65. package/dist/cjs/operations.js.map +1 -0
  66. package/dist/cjs/package.json +1 -0
  67. package/dist/cjs/paid-mint-amount.d.ts +69 -0
  68. package/dist/cjs/paid-mint-amount.js +281 -0
  69. package/dist/cjs/paid-mint-amount.js.map +1 -0
  70. package/dist/cjs/protocol.d.ts +21 -0
  71. package/dist/cjs/protocol.js +25 -0
  72. package/dist/cjs/protocol.js.map +1 -0
  73. package/dist/cjs/runtime.d.ts +27 -0
  74. package/dist/cjs/runtime.js +3 -0
  75. package/dist/cjs/runtime.js.map +1 -0
  76. package/dist/cjs/sale-common.d.ts +287 -0
  77. package/dist/cjs/sale-common.js +928 -0
  78. package/dist/cjs/sale-common.js.map +1 -0
  79. package/dist/cjs/source-provider.d.ts +11 -0
  80. package/dist/cjs/source-provider.js +3 -0
  81. package/dist/cjs/source-provider.js.map +1 -0
  82. package/dist/cjs/source-validation.d.ts +9 -0
  83. package/dist/cjs/source-validation.js +33 -0
  84. package/dist/cjs/source-validation.js.map +1 -0
  85. package/dist/cjs/token-amount.d.ts +31 -0
  86. package/dist/cjs/token-amount.js +252 -0
  87. package/dist/cjs/token-amount.js.map +1 -0
  88. package/dist/cjs/token-operation.d.ts +135 -0
  89. package/dist/cjs/token-operation.js +236 -0
  90. package/dist/cjs/token-operation.js.map +1 -0
  91. package/dist/cjs/trade-fee.d.ts +60 -0
  92. package/dist/cjs/trade-fee.js +185 -0
  93. package/dist/cjs/trade-fee.js.map +1 -0
  94. package/dist/cjs/trading-operation.d.ts +212 -0
  95. package/dist/cjs/trading-operation.js +587 -0
  96. package/dist/cjs/trading-operation.js.map +1 -0
  97. package/dist/cjs/verify-operation.d.ts +79 -0
  98. package/dist/cjs/verify-operation.js +246 -0
  99. package/dist/cjs/verify-operation.js.map +1 -0
  100. package/dist/cjs/wallet-operation.d.ts +52 -0
  101. package/dist/cjs/wallet-operation.js +58 -0
  102. package/dist/cjs/wallet-operation.js.map +1 -0
  103. package/dist/cjs/wasm-provider.d.ts +15 -0
  104. package/dist/cjs/wasm-provider.js +20 -0
  105. package/dist/cjs/wasm-provider.js.map +1 -0
  106. package/dist/cjs/wrapper-operation.d.ts +196 -0
  107. package/dist/cjs/wrapper-operation.js +317 -0
  108. package/dist/cjs/wrapper-operation.js.map +1 -0
  109. package/dist/deploy-operation.d.ts +104 -0
  110. package/dist/deploy-operation.d.ts.map +1 -0
  111. package/dist/deploy-operation.js +327 -0
  112. package/dist/deploy-operation.js.map +1 -0
  113. package/dist/encoding.d.ts +6 -0
  114. package/dist/encoding.d.ts.map +1 -0
  115. package/dist/encoding.js +44 -0
  116. package/dist/encoding.js.map +1 -0
  117. package/dist/engine.d.ts +41 -0
  118. package/dist/engine.d.ts.map +1 -0
  119. package/dist/engine.js +8969 -0
  120. package/dist/engine.js.map +1 -0
  121. package/dist/errors.d.ts +8 -0
  122. package/dist/errors.d.ts.map +1 -0
  123. package/dist/errors.js +18 -0
  124. package/dist/errors.js.map +1 -0
  125. package/dist/fee-ticket-operation.d.ts +205 -0
  126. package/dist/fee-ticket-operation.d.ts.map +1 -0
  127. package/dist/fee-ticket-operation.js +320 -0
  128. package/dist/fee-ticket-operation.js.map +1 -0
  129. package/dist/index.d.ts +28 -0
  130. package/dist/index.d.ts.map +1 -0
  131. package/dist/index.js +28 -0
  132. package/dist/index.js.map +1 -0
  133. package/dist/ladder-limit-orders.d.ts +42 -0
  134. package/dist/ladder-limit-orders.d.ts.map +1 -0
  135. package/dist/ladder-limit-orders.js +121 -0
  136. package/dist/ladder-limit-orders.js.map +1 -0
  137. package/dist/mint-availability-operation.d.ts +57 -0
  138. package/dist/mint-availability-operation.d.ts.map +1 -0
  139. package/dist/mint-availability-operation.js +91 -0
  140. package/dist/mint-availability-operation.js.map +1 -0
  141. package/dist/models.d.ts +91 -0
  142. package/dist/models.d.ts.map +1 -0
  143. package/dist/models.js +3 -0
  144. package/dist/models.js.map +1 -0
  145. package/dist/operations.d.ts +7 -0
  146. package/dist/operations.d.ts.map +1 -0
  147. package/dist/operations.js +36 -0
  148. package/dist/operations.js.map +1 -0
  149. package/dist/paid-mint-amount.d.ts +70 -0
  150. package/dist/paid-mint-amount.d.ts.map +1 -0
  151. package/dist/paid-mint-amount.js +268 -0
  152. package/dist/paid-mint-amount.js.map +1 -0
  153. package/dist/protocol.d.ts +22 -0
  154. package/dist/protocol.d.ts.map +1 -0
  155. package/dist/protocol.js +22 -0
  156. package/dist/protocol.js.map +1 -0
  157. package/dist/runtime.d.ts +28 -0
  158. package/dist/runtime.d.ts.map +1 -0
  159. package/dist/runtime.js +2 -0
  160. package/dist/runtime.js.map +1 -0
  161. package/dist/sale-common.d.ts +288 -0
  162. package/dist/sale-common.d.ts.map +1 -0
  163. package/dist/sale-common.js +844 -0
  164. package/dist/sale-common.js.map +1 -0
  165. package/dist/source-provider.d.ts +12 -0
  166. package/dist/source-provider.d.ts.map +1 -0
  167. package/dist/source-provider.js +2 -0
  168. package/dist/source-provider.js.map +1 -0
  169. package/dist/source-validation.d.ts +10 -0
  170. package/dist/source-validation.d.ts.map +1 -0
  171. package/dist/source-validation.js +28 -0
  172. package/dist/source-validation.js.map +1 -0
  173. package/dist/token-amount.d.ts +32 -0
  174. package/dist/token-amount.d.ts.map +1 -0
  175. package/dist/token-amount.js +237 -0
  176. package/dist/token-amount.js.map +1 -0
  177. package/dist/token-operation.d.ts +136 -0
  178. package/dist/token-operation.d.ts.map +1 -0
  179. package/dist/token-operation.js +231 -0
  180. package/dist/token-operation.js.map +1 -0
  181. package/dist/trade-fee.d.ts +61 -0
  182. package/dist/trade-fee.d.ts.map +1 -0
  183. package/dist/trade-fee.js +173 -0
  184. package/dist/trade-fee.js.map +1 -0
  185. package/dist/trading-operation.d.ts +213 -0
  186. package/dist/trading-operation.d.ts.map +1 -0
  187. package/dist/trading-operation.js +580 -0
  188. package/dist/trading-operation.js.map +1 -0
  189. package/dist/verify-operation.d.ts +80 -0
  190. package/dist/verify-operation.d.ts.map +1 -0
  191. package/dist/verify-operation.js +243 -0
  192. package/dist/verify-operation.js.map +1 -0
  193. package/dist/wallet-operation.d.ts +53 -0
  194. package/dist/wallet-operation.d.ts.map +1 -0
  195. package/dist/wallet-operation.js +55 -0
  196. package/dist/wallet-operation.js.map +1 -0
  197. package/dist/wasm-provider.d.ts +16 -0
  198. package/dist/wasm-provider.d.ts.map +1 -0
  199. package/dist/wasm-provider.js +17 -0
  200. package/dist/wasm-provider.js.map +1 -0
  201. package/dist/wrapper-operation.d.ts +197 -0
  202. package/dist/wrapper-operation.d.ts.map +1 -0
  203. package/dist/wrapper-operation.js +311 -0
  204. package/dist/wrapper-operation.js.map +1 -0
  205. package/index.d.ts +1 -0
  206. package/package.json +84 -0
  207. package/src/abi.ts +493 -0
  208. package/src/action-source-resolver.ts +660 -0
  209. package/src/artifacts.ts +87 -0
  210. package/src/builder.ts +37 -0
  211. package/src/deploy-operation.ts +458 -0
  212. package/src/encoding.ts +58 -0
  213. package/src/engine.ts +13226 -0
  214. package/src/errors.ts +35 -0
  215. package/src/fee-ticket-operation.ts +518 -0
  216. package/src/index.ts +27 -0
  217. package/src/ladder-limit-orders.ts +184 -0
  218. package/src/mint-availability-operation.ts +146 -0
  219. package/src/models.ts +103 -0
  220. package/src/operations.ts +46 -0
  221. package/src/paid-mint-amount.ts +402 -0
  222. package/src/protocol.ts +28 -0
  223. package/src/runtime.ts +29 -0
  224. package/src/sale-common.ts +1238 -0
  225. package/src/source-provider.ts +12 -0
  226. package/src/source-validation.ts +47 -0
  227. package/src/token-amount.ts +302 -0
  228. package/src/token-operation.ts +384 -0
  229. package/src/trade-fee.ts +264 -0
  230. package/src/trading-operation.ts +842 -0
  231. package/src/verify-operation.ts +400 -0
  232. package/src/wallet-operation.ts +86 -0
  233. package/src/wasm-provider.ts +32 -0
  234. package/src/wrapper-operation.ts +531 -0
@@ -0,0 +1,196 @@
1
+ import { type Kcc20IndexedCovenantUtxo, type Kcc20WrapperSourceInfo } from "./action-source-resolver.js";
2
+ export interface Kcc20WrapperWalletInfo {
3
+ walletAddress: string;
4
+ kcc20Owner: string;
5
+ }
6
+ export interface Kcc20WrapperMarketInfo {
7
+ wrapperId: string;
8
+ marketId: string;
9
+ canonicalTokenId?: string | null;
10
+ contractCanonicalTokenId?: string | null;
11
+ feeTicketId?: string | null;
12
+ }
13
+ export interface Kcc20WrapperActiveResolution {
14
+ selected?: Record<string, unknown> | null;
15
+ candidates?: Record<string, unknown>[];
16
+ ambiguous?: boolean;
17
+ activeCovenantId?: string | null;
18
+ }
19
+ export interface Kcc20WrapperHolderSummary {
20
+ aggregateAmount?: string;
21
+ maxSingleUtxoAmount?: string;
22
+ utxoCount?: number;
23
+ fragmented?: boolean;
24
+ maxSingleUtxoOutpoint?: string;
25
+ recommendedAction?: string;
26
+ }
27
+ export interface Kcc20BuildWrapOperationInput {
28
+ canonicalCovenantId: string;
29
+ wrappedMarketId: string;
30
+ tokenAmount: string;
31
+ priceScale?: string;
32
+ wrapper: Kcc20WrapperMarketInfo;
33
+ activeHolderUtxo: Record<string, unknown> | null;
34
+ activeHolderSummary?: Kcc20WrapperHolderSummary;
35
+ activeWrapperResolution?: Kcc20WrapperActiveResolution;
36
+ activeHolderNativeCovenantId?: string | null;
37
+ }
38
+ export interface Kcc20WrapOperationOptions {
39
+ network?: string;
40
+ createdAt?: string;
41
+ requestId?: string;
42
+ }
43
+ export declare function buildKcc20WrapTokenOperation(walletInfo: Kcc20WrapperWalletInfo, input: Kcc20BuildWrapOperationInput, options?: Kcc20WrapOperationOptions): {
44
+ requestId: string;
45
+ description: string;
46
+ payload: {
47
+ params: Record<string, unknown>;
48
+ signing: {
49
+ standard: string;
50
+ walletAction: string;
51
+ status: string;
52
+ builderKey: string;
53
+ builderStatus: string;
54
+ submitTransactionSupported: boolean;
55
+ missingDependencies: string[];
56
+ missingSources: never[];
57
+ };
58
+ sourceRequirements: Record<string, unknown>[];
59
+ signerRequirements: Record<string, unknown>[];
60
+ warnings: string[];
61
+ tokenIdentity?: Record<string, unknown> | undefined;
62
+ schema: string;
63
+ status: string;
64
+ requestId: string;
65
+ chain: string;
66
+ network: string;
67
+ createdAt: string;
68
+ owner: import("./wallet-operation.js").Kcc20WalletOperationOwner;
69
+ operation: string;
70
+ contract: string;
71
+ action: string;
72
+ };
73
+ };
74
+ export interface Kcc20BuildWrapFromSnapshotInput {
75
+ canonicalCovenantId: string;
76
+ tokenDecimals?: number | null;
77
+ wrappedMarketId: string;
78
+ tokenAmount: string;
79
+ wrapper: Kcc20WrapperSourceInfo;
80
+ canonicalTokenUtxos: readonly Kcc20IndexedCovenantUtxo[];
81
+ wrapperUtxos: readonly Kcc20IndexedCovenantUtxo[];
82
+ }
83
+ /**
84
+ * Resolves the native holder and wrapper controller in the shared package.
85
+ * The host only supplies a generic indexed snapshot; no action planner is
86
+ * consulted.
87
+ */
88
+ export declare function buildKcc20WrapTokenOperationFromSnapshot(walletInfo: Kcc20WrapperWalletInfo, input: Kcc20BuildWrapFromSnapshotInput, options?: Kcc20WrapOperationOptions): {
89
+ requestId: string;
90
+ description: string;
91
+ payload: {
92
+ params: Record<string, unknown>;
93
+ signing: {
94
+ standard: string;
95
+ walletAction: string;
96
+ status: string;
97
+ builderKey: string;
98
+ builderStatus: string;
99
+ submitTransactionSupported: boolean;
100
+ missingDependencies: string[];
101
+ missingSources: never[];
102
+ };
103
+ sourceRequirements: Record<string, unknown>[];
104
+ signerRequirements: Record<string, unknown>[];
105
+ warnings: string[];
106
+ tokenIdentity?: Record<string, unknown> | undefined;
107
+ schema: string;
108
+ status: string;
109
+ requestId: string;
110
+ chain: string;
111
+ network: string;
112
+ createdAt: string;
113
+ owner: import("./wallet-operation.js").Kcc20WalletOperationOwner;
114
+ operation: string;
115
+ contract: string;
116
+ action: string;
117
+ };
118
+ };
119
+ export interface Kcc20BuildUnwrapFromSnapshotInput {
120
+ canonicalCovenantId: string;
121
+ tokenDecimals?: number | null;
122
+ wrappedMarketId: string;
123
+ tokenAmount: string;
124
+ wrapper: Kcc20WrapperSourceInfo;
125
+ canonicalTokenUtxos: readonly Kcc20IndexedCovenantUtxo[];
126
+ wrappedTokenUtxos: readonly Kcc20IndexedCovenantUtxo[];
127
+ wrapperUtxos: readonly Kcc20IndexedCovenantUtxo[];
128
+ }
129
+ export declare function buildKcc20UnwrapTokenOperationFromSnapshot(walletInfo: Kcc20WrapperWalletInfo, input: Kcc20BuildUnwrapFromSnapshotInput, options?: Kcc20WrapOperationOptions): {
130
+ requestId: string;
131
+ description: string;
132
+ payload: {
133
+ params: Record<string, unknown>;
134
+ signing: {
135
+ standard: string;
136
+ walletAction: string;
137
+ status: string;
138
+ builderKey: string;
139
+ builderStatus: string;
140
+ submitTransactionSupported: boolean;
141
+ missingDependencies: string[];
142
+ missingSources: never[];
143
+ };
144
+ sourceRequirements: Record<string, unknown>[];
145
+ signerRequirements: Record<string, unknown>[];
146
+ warnings: string[];
147
+ tokenIdentity?: Record<string, unknown> | undefined;
148
+ schema: string;
149
+ status: string;
150
+ requestId: string;
151
+ chain: string;
152
+ network: string;
153
+ createdAt: string;
154
+ owner: import("./wallet-operation.js").Kcc20WalletOperationOwner;
155
+ operation: string;
156
+ contract: string;
157
+ action: string;
158
+ };
159
+ };
160
+ export declare function buildKcc20WrapperMarketDeployOperation(walletInfo: Kcc20WrapperWalletInfo, input: {
161
+ canonicalCovenantId: string;
162
+ contractCanonicalCovenantId?: string | null;
163
+ tokenDecimals?: number | null;
164
+ wrappedRootAmount?: string;
165
+ feeTicketId?: string | null;
166
+ }, options?: Kcc20WrapOperationOptions): {
167
+ requestId: string;
168
+ description: string;
169
+ payload: {
170
+ params: Record<string, unknown>;
171
+ signing: {
172
+ standard: string;
173
+ walletAction: string;
174
+ status: string;
175
+ builderKey: string;
176
+ builderStatus: string;
177
+ submitTransactionSupported: boolean;
178
+ missingDependencies: string[];
179
+ missingSources: never[];
180
+ };
181
+ sourceRequirements: Record<string, unknown>[];
182
+ signerRequirements: Record<string, unknown>[];
183
+ warnings: string[];
184
+ tokenIdentity?: Record<string, unknown> | undefined;
185
+ schema: string;
186
+ status: string;
187
+ requestId: string;
188
+ chain: string;
189
+ network: string;
190
+ createdAt: string;
191
+ owner: import("./wallet-operation.js").Kcc20WalletOperationOwner;
192
+ operation: string;
193
+ contract: string;
194
+ action: string;
195
+ };
196
+ };
@@ -0,0 +1,317 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildKcc20WrapTokenOperation = buildKcc20WrapTokenOperation;
4
+ exports.buildKcc20WrapTokenOperationFromSnapshot = buildKcc20WrapTokenOperationFromSnapshot;
5
+ exports.buildKcc20UnwrapTokenOperationFromSnapshot = buildKcc20UnwrapTokenOperationFromSnapshot;
6
+ exports.buildKcc20WrapperMarketDeployOperation = buildKcc20WrapperMarketDeployOperation;
7
+ const wallet_operation_js_1 = require("./wallet-operation.js");
8
+ const action_source_resolver_js_1 = require("./action-source-resolver.js");
9
+ const token_amount_js_1 = require("./token-amount.js");
10
+ function buildKcc20WrapTokenOperation(walletInfo, input, options = {}) {
11
+ const appCanonicalId = normalizeHex32(input.canonicalCovenantId, "canonicalCovenantId");
12
+ const wrappedMarketId = normalizeHex32(input.wrappedMarketId || input.wrapper.marketId, "wrappedMarketId");
13
+ const holderNativeCovenantId = input.activeHolderNativeCovenantId
14
+ ? normalizeHex32(input.activeHolderNativeCovenantId, "activeHolderNativeCovenantId")
15
+ : undefined;
16
+ const contractCanonicalId = normalizeHex32(input.wrapper.contractCanonicalTokenId ??
17
+ input.wrapper.canonicalTokenId ??
18
+ holderNativeCovenantId ??
19
+ appCanonicalId, "contractCanonicalCovenantId");
20
+ const activeWrapperCovenantId = input.activeWrapperResolution
21
+ ?.activeCovenantId
22
+ ? normalizeHex32(input.activeWrapperResolution.activeCovenantId, "activeWrapperCovenantId")
23
+ : undefined;
24
+ const tokenAmount = parsePositiveIntegerString(input.tokenAmount, "tokenAmount");
25
+ const priceScale = input.priceScale
26
+ ? parsePositiveIntegerString(input.priceScale, "priceScale")
27
+ : undefined;
28
+ return (0, wallet_operation_js_1.buildKcc20WalletOperationFromPlan)(walletInfo, {
29
+ builderKey: "kcc20wrapper.wrap",
30
+ operation: "wrap-token",
31
+ contract: "KCC20Wrapper",
32
+ action: "wrap",
33
+ description: "Build a KCC20 to DEX Orderbook V1 deposit request.",
34
+ params: {
35
+ canonicalCovenantId: contractCanonicalId,
36
+ appCanonicalCovenantId: appCanonicalId,
37
+ contractCanonicalCovenantId: contractCanonicalId,
38
+ ...(holderNativeCovenantId
39
+ ? { activeHolderNativeCovenantId: holderNativeCovenantId }
40
+ : {}),
41
+ wrappedMarketId,
42
+ tokenAmount,
43
+ ...(priceScale ? { priceScale } : {}),
44
+ recipientOwner: normalizeHex32(walletInfo.kcc20Owner, "kcc20Owner"),
45
+ recipientOwnerType: "pubkey",
46
+ feeTicketId: input.wrapper.feeTicketId ?? null,
47
+ ...(activeWrapperCovenantId ? { activeWrapperCovenantId } : {}),
48
+ activeHolderUtxo: input.activeHolderUtxo,
49
+ activeWrapperUtxo: input.activeWrapperResolution?.selected,
50
+ activeWrapperCandidateUtxos: input.activeWrapperResolution?.candidates ?? [],
51
+ },
52
+ sourceRequirements: [
53
+ {
54
+ type: "kcc20-holder-utxo",
55
+ covenantId: appCanonicalId,
56
+ ...(contractCanonicalId !== appCanonicalId
57
+ ? { contractCanonicalCovenantId: contractCanonicalId }
58
+ : {}),
59
+ ...(holderNativeCovenantId
60
+ ? { activeHolderNativeCovenantId: holderNativeCovenantId }
61
+ : {}),
62
+ owner: normalizeHex32(walletInfo.kcc20Owner, "kcc20Owner"),
63
+ minimumTokenAmount: tokenAmount,
64
+ ...holderSummaryFields(input.activeHolderSummary),
65
+ outpoint: input.activeHolderUtxo
66
+ ? utxoOutpoint(input.activeHolderUtxo)
67
+ : undefined,
68
+ amount: utxoStateAmount(input.activeHolderUtxo),
69
+ },
70
+ wrapperReserveOutput({
71
+ wrapperId: wrappedMarketId,
72
+ activeWrapperResolution: input.activeWrapperResolution,
73
+ purpose: "increase wrapper reserve and issue DEX Orderbook V1 holder output",
74
+ }),
75
+ ],
76
+ warnings: [
77
+ "Wallet must preserve canonical reserve accounting between KCC20 escrow and orderbook supply.",
78
+ ],
79
+ }, options);
80
+ }
81
+ /**
82
+ * Resolves the native holder and wrapper controller in the shared package.
83
+ * The host only supplies a generic indexed snapshot; no action planner is
84
+ * consulted.
85
+ */
86
+ function buildKcc20WrapTokenOperationFromSnapshot(walletInfo, input, options = {}) {
87
+ if (input.wrapper.enabled === false) {
88
+ throw new Error("Wrapped trading is disabled for this market");
89
+ }
90
+ const decimals = (0, token_amount_js_1.normalizeKcc20Decimals)(input.tokenDecimals);
91
+ const tokenAmount = (0, token_amount_js_1.parseKcc20DisplayAmountToBaseUnits)(input.tokenAmount, decimals, "tokenAmount");
92
+ const ownerUtxos = (0, action_source_resolver_js_1.ownerNativeHolderUtxos)(input.canonicalTokenUtxos, walletInfo.kcc20Owner);
93
+ const holder = (0, action_source_resolver_js_1.selectOwnerNativeHolderUtxo)(input.canonicalTokenUtxos, walletInfo.kcc20Owner, tokenAmount);
94
+ const summary = (0, action_source_resolver_js_1.summarizeHolderUtxos)(ownerUtxos, tokenAmount);
95
+ if (!holder) {
96
+ throw new Error(summary.fragmented
97
+ ? "No single KCC20 holder UTXO is large enough; consolidate the token balance first"
98
+ : "No KCC20 holder UTXO is available for this wallet and amount");
99
+ }
100
+ const wrapperResolution = (0, action_source_resolver_js_1.resolveActiveWrapperUtxo)(input.wrapper, input.wrapperUtxos);
101
+ return buildKcc20WrapTokenOperation(walletInfo, {
102
+ canonicalCovenantId: input.canonicalCovenantId,
103
+ wrappedMarketId: input.wrapper.marketId || input.wrappedMarketId,
104
+ tokenAmount,
105
+ priceScale: (0, token_amount_js_1.kcc20DisplayScaleForDecimals)(decimals).toString(),
106
+ wrapper: input.wrapper,
107
+ activeHolderUtxo: holder,
108
+ activeHolderSummary: summary,
109
+ activeWrapperResolution: wrapperResolution,
110
+ activeHolderNativeCovenantId: holder.covenantId ??
111
+ input.wrapper.contractCanonicalTokenId ??
112
+ input.canonicalCovenantId,
113
+ }, options);
114
+ }
115
+ function buildKcc20UnwrapTokenOperationFromSnapshot(walletInfo, input, options = {}) {
116
+ if (input.wrapper.enabled === false) {
117
+ throw new Error("Wrapped trading is disabled for this market");
118
+ }
119
+ const appCanonicalId = normalizeHex32(input.canonicalCovenantId, "canonicalCovenantId");
120
+ const contractCanonicalId = normalizeHex32(input.wrapper.contractCanonicalTokenId ??
121
+ input.wrapper.canonicalTokenId ??
122
+ appCanonicalId, "contractCanonicalCovenantId");
123
+ const marketId = normalizeHex32(input.wrapper.marketId || input.wrappedMarketId, "wrappedMarketId");
124
+ const decimals = (0, token_amount_js_1.normalizeKcc20Decimals)(input.tokenDecimals);
125
+ const tokenAmount = (0, token_amount_js_1.parseKcc20DisplayAmountToBaseUnits)(input.tokenAmount, decimals, "tokenAmount");
126
+ const holderCandidates = (0, action_source_resolver_js_1.ownerWrappedHolderUtxos)(input.wrappedTokenUtxos, walletInfo.kcc20Owner, contractCanonicalId);
127
+ const holder = (0, action_source_resolver_js_1.selectOwnerWrappedHolderUtxo)(input.wrappedTokenUtxos, walletInfo.kcc20Owner, tokenAmount, contractCanonicalId);
128
+ const holderSummary = (0, action_source_resolver_js_1.summarizeHolderUtxos)(holderCandidates, tokenAmount);
129
+ if (!holder) {
130
+ throw new Error(holderSummary.fragmented
131
+ ? "No single wrapped holder UTXO is large enough; consolidate the wrapped balance first"
132
+ : "No wrapped holder UTXO is available for this wallet and amount");
133
+ }
134
+ const wrapperResolution = (0, action_source_resolver_js_1.resolveActiveWrapperUtxo)(input.wrapper, input.wrapperUtxos);
135
+ const reserveIds = [
136
+ wrapperResolution.activeCovenantId,
137
+ input.wrapper.activeCovenantId,
138
+ input.wrapper.wrapperId,
139
+ marketId,
140
+ ].filter((value) => Boolean(value));
141
+ const reserve = (0, action_source_resolver_js_1.selectWrapperReserveUtxo)(input.canonicalTokenUtxos, reserveIds, tokenAmount);
142
+ if (!reserve) {
143
+ throw new Error("Wrapper reserve does not contain enough canonical token balance");
144
+ }
145
+ return (0, wallet_operation_js_1.buildKcc20WalletOperationFromPlan)(walletInfo, {
146
+ builderKey: "kcc20wrapper.unwrap",
147
+ operation: "unwrap",
148
+ contract: "KCC20Wrapper",
149
+ action: "unwrap",
150
+ description: "Build a KCC20 DEX Orderbook V1 to Token V1 withdrawal request.",
151
+ params: {
152
+ canonicalCovenantId: contractCanonicalId,
153
+ appCanonicalCovenantId: appCanonicalId,
154
+ contractCanonicalCovenantId: contractCanonicalId,
155
+ wrappedMarketId: marketId,
156
+ tokenAmount,
157
+ recipientOwner: normalizeHex32(walletInfo.kcc20Owner, "kcc20Owner"),
158
+ recipientOwnerType: "pubkey",
159
+ ...(wrapperResolution.activeCovenantId
160
+ ? { activeWrapperCovenantId: wrapperResolution.activeCovenantId }
161
+ : {}),
162
+ activeWrappedHolderUtxo: holder,
163
+ activeReserveUtxo: reserve,
164
+ activeWrapperUtxo: wrapperResolution.selected,
165
+ activeWrapperCandidateUtxos: wrapperResolution.candidates,
166
+ },
167
+ sourceRequirements: [
168
+ {
169
+ type: "kcc20-orderbook-holder-utxo",
170
+ covenantId: marketId,
171
+ contractCanonicalCovenantId: contractCanonicalId,
172
+ owner: walletInfo.kcc20Owner,
173
+ minimumTokenAmount: tokenAmount,
174
+ ...holderSummaryFields(holderSummary),
175
+ outpoint: holder.outpoint,
176
+ amount: holder.state?.["amount"],
177
+ },
178
+ wrapperReserveOutput({
179
+ wrapperId: marketId,
180
+ activeWrapperResolution: wrapperResolution,
181
+ reserveUtxo: reserve,
182
+ purpose: "release canonical Token V1 reserve and burn DEX Orderbook V1 amount",
183
+ }),
184
+ ],
185
+ warnings: [
186
+ "Wallet must prove wrapped burn and canonical reserve release in the same transaction.",
187
+ ],
188
+ }, options);
189
+ }
190
+ function buildKcc20WrapperMarketDeployOperation(walletInfo, input, options = {}) {
191
+ const appCanonicalId = normalizeHex32(input.canonicalCovenantId, "canonicalCovenantId");
192
+ const contractCanonicalId = normalizeHex32(input.contractCanonicalCovenantId ?? appCanonicalId, "contractCanonicalCovenantId");
193
+ const rootAmount = String(input.wrappedRootAmount ?? "0").trim();
194
+ if (!/^\d+$/.test(rootAmount)) {
195
+ throw new Error("wrappedRootAmount must be an unsigned integer string");
196
+ }
197
+ const decimals = (0, token_amount_js_1.normalizeKcc20Decimals)(input.tokenDecimals);
198
+ const feeTicketId = input.feeTicketId
199
+ ? normalizeHex32(input.feeTicketId, "feeTicketId")
200
+ : null;
201
+ return (0, wallet_operation_js_1.buildKcc20WalletOperationFromPlan)(walletInfo, {
202
+ builderKey: "kcc20wrapper.deploy-market",
203
+ operation: "deploy-wrapper-market",
204
+ contract: "KCC20Wrapper",
205
+ action: "deployMarket",
206
+ description: "Build a KCC20 Wrapper Reserve V1 market deploy request.",
207
+ params: {
208
+ canonicalCovenantId: appCanonicalId,
209
+ contractCanonicalCovenantId: contractCanonicalId,
210
+ feeTicketId,
211
+ wrappedRootAmount: rootAmount,
212
+ priceScale: (0, token_amount_js_1.kcc20DisplayScaleForDecimals)(decimals).toString(),
213
+ tokenDecimals: String(decimals),
214
+ deployerOwner: normalizeHex32(walletInfo.kcc20Owner, "kcc20Owner"),
215
+ deployerOwnerType: "pubkey",
216
+ },
217
+ sourceRequirements: [
218
+ {
219
+ type: "canonical-kcc20-token",
220
+ covenantId: appCanonicalId,
221
+ ...(contractCanonicalId !== appCanonicalId
222
+ ? { contractCanonicalCovenantId: contractCanonicalId }
223
+ : {}),
224
+ purpose: "bind wrapper market to the canonical token identity",
225
+ },
226
+ {
227
+ type: "kaspa-funding-utxo",
228
+ ownerAddress: walletInfo.walletAddress,
229
+ purpose: "fund wrapper/root outputs and network fee",
230
+ },
231
+ {
232
+ type: "compiled-contract-artifacts",
233
+ templates: ["KCC20Wrapper", "KCC20Orderbook"],
234
+ },
235
+ ...(feeTicketId
236
+ ? [
237
+ {
238
+ type: "fee-ticket-root",
239
+ covenantId: feeTicketId,
240
+ purpose: "bind configured standalone fill discount policy",
241
+ },
242
+ ]
243
+ : []),
244
+ ],
245
+ warnings: [
246
+ "The canonical KCC20 covenantId remains the token identity; the wrapper market ID is only the DEX orderbook mode.",
247
+ "Wrapper deploy builders must create both wrapper reserve and wrapped-root outputs consistently.",
248
+ ],
249
+ }, options);
250
+ }
251
+ function wrapperReserveOutput(input) {
252
+ const selected = input.activeWrapperResolution?.selected;
253
+ return {
254
+ type: "wrapper-reserve-output",
255
+ wrapperId: input.wrapperId,
256
+ ...(input.reserveUtxo
257
+ ? {
258
+ reserveOutpoint: utxoOutpoint(input.reserveUtxo),
259
+ reserveAmount: utxoStateAmount(input.reserveUtxo),
260
+ }
261
+ : {}),
262
+ ...(selected
263
+ ? {
264
+ selectedOutpoint: selected["outpoint"],
265
+ amountSompi: selected["amountSompi"],
266
+ address: selected["address"],
267
+ }
268
+ : {}),
269
+ ...(input.activeWrapperResolution?.ambiguous
270
+ ? {
271
+ ambiguous: true,
272
+ candidateOutpoints: (input.activeWrapperResolution.candidates ?? []).map((candidate) => candidate["outpoint"]),
273
+ }
274
+ : {}),
275
+ purpose: input.purpose,
276
+ };
277
+ }
278
+ function holderSummaryFields(summary) {
279
+ if (!summary)
280
+ return {};
281
+ return {
282
+ aggregateAmount: summary.aggregateAmount,
283
+ maxSingleUtxoAmount: summary.maxSingleUtxoAmount,
284
+ utxoCount: summary.utxoCount,
285
+ fragmented: summary.fragmented,
286
+ maxSingleUtxoOutpoint: summary.maxSingleUtxoOutpoint,
287
+ recommendedAction: summary.recommendedAction,
288
+ };
289
+ }
290
+ function utxoOutpoint(utxo) {
291
+ const txidHex = typeof utxo["txidHex"] === "string" ? utxo["txidHex"] : "";
292
+ const vout = utxo["vout"];
293
+ if (!txidHex || (typeof vout !== "number" && typeof vout !== "string")) {
294
+ return undefined;
295
+ }
296
+ return `${txidHex}:${vout}`;
297
+ }
298
+ function utxoStateAmount(utxo) {
299
+ const state = utxo && typeof utxo["state"] === "object" && utxo["state"] !== null
300
+ ? utxo["state"]
301
+ : undefined;
302
+ return typeof state?.["amount"] === "string" ? state["amount"] : undefined;
303
+ }
304
+ function parsePositiveIntegerString(value, field) {
305
+ if (!/^[1-9]\d*$/.test(value)) {
306
+ throw new Error(`${field} must be a positive integer string`);
307
+ }
308
+ return value;
309
+ }
310
+ function normalizeHex32(value, field) {
311
+ const normalized = value.trim().toLowerCase().replace(/^0x/, "");
312
+ if (!/^[0-9a-f]{64}$/.test(normalized)) {
313
+ throw new Error(`${field} must be 64 hex characters`);
314
+ }
315
+ return normalized;
316
+ }
317
+ //# sourceMappingURL=wrapper-operation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wrapper-operation.js","sourceRoot":"","sources":["../../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AAC,CAAC,SAAS,CAAC;IAChB,OAAO,OAAO,KAAK,EAAE,CAAC,QAAQ,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AAC7E,CAAC;AAED,SAAS,0BAA0B,CAAC,KAAa,EAAE,KAAa;IAC9D,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QAC9B,MAAM,IAAI,KAAK,CAAC,GAAG,KAAK,oCAAoC,CAAC,CAAC;IAChE,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,cAAc,CAAC,KAAa,EAAE,KAAa;IAClD,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IACjE,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;QACvC,MAAM,IAAI,KAAK,CAAC,GAAG,KAAK,4BAA4B,CAAC,CAAC;IACxD,CAAC;IACD,OAAO,UAAU,CAAC;AACpB,CAAC"}
@@ -0,0 +1,104 @@
1
+ export interface Kcc20DeployTokenDraft {
2
+ ticker?: string;
3
+ tokenName?: string;
4
+ maxSupply: string;
5
+ premintSupply: string;
6
+ decimals?: number;
7
+ premintRecipient?: string;
8
+ mintPolicy: "fixed" | "controlled" | "public";
9
+ mintLaneCount?: number;
10
+ mintPricePerTokenSompi: string;
11
+ treasuryRecipient?: string;
12
+ }
13
+ export interface Kcc20DeployWalletInfo {
14
+ walletAddress: string;
15
+ kcc20Owner: string;
16
+ }
17
+ export interface Kcc20DeployOperationOptions {
18
+ network?: string;
19
+ protocolFeeRecipient?: string;
20
+ protocolFeeBps?: number | string | bigint;
21
+ createdAt?: string;
22
+ requestId?: string;
23
+ }
24
+ export interface Kcc20ValidatedDeployToken {
25
+ ticker: string;
26
+ tokenName: string;
27
+ maxSupply: bigint;
28
+ premintSupply: bigint;
29
+ decimals: number;
30
+ premintRecipient: string;
31
+ mintPricePerTokenSompi: bigint;
32
+ mintPolicy: number;
33
+ treasuryRecipient: string;
34
+ protocolFeeRecipient: string;
35
+ protocolFeeBps: number;
36
+ mintLaneCount?: number;
37
+ }
38
+ export declare function buildKcc20DeployTokenOperation(walletInfo: Kcc20DeployWalletInfo, draft: Kcc20DeployTokenDraft, options?: Kcc20DeployOperationOptions): {
39
+ requestId: string;
40
+ description: string;
41
+ payload: {
42
+ params: Record<string, unknown>;
43
+ signing: {
44
+ standard: string;
45
+ walletAction: string;
46
+ status: string;
47
+ builderKey: string;
48
+ builderStatus: string;
49
+ submitTransactionSupported: boolean;
50
+ missingDependencies: string[];
51
+ missingSources: never[];
52
+ };
53
+ sourceRequirements: Record<string, unknown>[];
54
+ signerRequirements: Record<string, unknown>[];
55
+ warnings: string[];
56
+ tokenIdentity?: Record<string, unknown> | undefined;
57
+ schema: string;
58
+ status: string;
59
+ requestId: string;
60
+ chain: string;
61
+ network: string;
62
+ createdAt: string;
63
+ owner: import("./wallet-operation.js").Kcc20WalletOperationOwner;
64
+ operation: string;
65
+ contract: string;
66
+ action: string;
67
+ };
68
+ };
69
+ export declare function buildKcc20DeployTokenOperationFromValidated(walletInfo: Kcc20DeployWalletInfo, draft: Kcc20DeployTokenDraft, validated: Kcc20ValidatedDeployToken, options?: Kcc20DeployOperationOptions): {
70
+ requestId: string;
71
+ description: string;
72
+ payload: {
73
+ params: Record<string, unknown>;
74
+ signing: {
75
+ standard: string;
76
+ walletAction: string;
77
+ status: string;
78
+ builderKey: string;
79
+ builderStatus: string;
80
+ submitTransactionSupported: boolean;
81
+ missingDependencies: string[];
82
+ missingSources: never[];
83
+ };
84
+ sourceRequirements: Record<string, unknown>[];
85
+ signerRequirements: Record<string, unknown>[];
86
+ warnings: string[];
87
+ tokenIdentity?: Record<string, unknown> | undefined;
88
+ schema: string;
89
+ status: string;
90
+ requestId: string;
91
+ chain: string;
92
+ network: string;
93
+ createdAt: string;
94
+ owner: import("./wallet-operation.js").Kcc20WalletOperationOwner;
95
+ operation: string;
96
+ contract: string;
97
+ action: string;
98
+ };
99
+ };
100
+ export declare function validateKcc20DeployToken(walletInfo: Kcc20DeployWalletInfo, draft: Kcc20DeployTokenDraft, options?: Kcc20DeployOperationOptions): Kcc20ValidatedDeployToken;
101
+ export declare function normalizeKcc20Ticker(value: string | undefined): string;
102
+ export declare function normalizeKcc20TokenName(value: string | undefined): string;
103
+ export declare function parseKcc20U64(value: string, field: string): bigint;
104
+ //# sourceMappingURL=deploy-operation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deploy-operation.d.ts","sourceRoot":"","sources":["../src/deploy-operation.ts"],"names":[],"mappings":"AA0BA,MAAM,WAAW,qBAAqB;IACpC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,UAAU,EAAE,OAAO,GAAG,YAAY,GAAG,QAAQ,CAAC;IAC9C,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,sBAAsB,EAAE,MAAM,CAAC;IAC/B,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,qBAAqB;IACpC,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,2BAA2B;IAC1C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,cAAc,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;IAC1C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW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