@kaspacom/kcc20-tx-builder 0.2.5 → 0.4.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 (127) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.md +54 -8
  3. package/RELEASING.md +93 -0
  4. package/SECURITY.md +16 -0
  5. package/artifacts/KCC20SnapshotBootstrap.placeholder.json +101677 -0
  6. package/artifacts/KCC20SnapshotController.placeholder.json +46547 -0
  7. package/artifacts/kcc20-snapshot-bootstrap/KCC20SnapshotBootstrap.placeholder.json +101677 -0
  8. package/artifacts/kcc20-snapshot-controller/KCC20SnapshotController.placeholder.json +46547 -0
  9. package/artifacts/snapshot-standards.lock.json +56 -0
  10. package/dist/artifacts.d.ts +31 -0
  11. package/dist/artifacts.d.ts.map +1 -1
  12. package/dist/artifacts.js +31 -0
  13. package/dist/artifacts.js.map +1 -1
  14. package/dist/cjs/artifacts.d.ts +31 -0
  15. package/dist/cjs/artifacts.js +32 -1
  16. package/dist/cjs/artifacts.js.map +1 -1
  17. package/dist/cjs/engine.js +58 -44
  18. package/dist/cjs/engine.js.map +1 -1
  19. package/dist/cjs/index.d.ts +7 -0
  20. package/dist/cjs/index.js +8 -1
  21. package/dist/cjs/index.js.map +1 -1
  22. package/dist/cjs/operations.d.ts +1 -1
  23. package/dist/cjs/operations.js +4 -0
  24. package/dist/cjs/operations.js.map +1 -1
  25. package/dist/cjs/sale-common.d.ts +1 -1
  26. package/dist/cjs/sale-common.js +39 -4
  27. package/dist/cjs/sale-common.js.map +1 -1
  28. package/dist/cjs/snapshot-deployment.d.ts +82 -0
  29. package/dist/cjs/snapshot-deployment.js +82 -0
  30. package/dist/cjs/snapshot-deployment.js.map +1 -0
  31. package/dist/cjs/snapshot-operation.d.ts +27 -0
  32. package/dist/cjs/snapshot-operation.js +2433 -0
  33. package/dist/cjs/snapshot-operation.js.map +1 -0
  34. package/dist/cjs/snapshot-signerless-transactions.d.ts +132 -0
  35. package/dist/cjs/snapshot-signerless-transactions.js +746 -0
  36. package/dist/cjs/snapshot-signerless-transactions.js.map +1 -0
  37. package/dist/cjs/snapshot-signerless.d.ts +226 -0
  38. package/dist/cjs/snapshot-signerless.js +1022 -0
  39. package/dist/cjs/snapshot-signerless.js.map +1 -0
  40. package/dist/cjs/snapshot-verification.d.ts +57 -0
  41. package/dist/cjs/snapshot-verification.js +96 -0
  42. package/dist/cjs/snapshot-verification.js.map +1 -0
  43. package/dist/cjs/token-operation.js +3 -3
  44. package/dist/cjs/token-operation.js.map +1 -1
  45. package/dist/engine.d.ts.map +1 -1
  46. package/dist/engine.js +58 -44
  47. package/dist/engine.js.map +1 -1
  48. package/dist/index.d.ts +7 -0
  49. package/dist/index.d.ts.map +1 -1
  50. package/dist/index.js +7 -0
  51. package/dist/index.js.map +1 -1
  52. package/dist/operations.d.ts +1 -1
  53. package/dist/operations.d.ts.map +1 -1
  54. package/dist/operations.js +4 -0
  55. package/dist/operations.js.map +1 -1
  56. package/dist/sale-common.d.ts +1 -1
  57. package/dist/sale-common.d.ts.map +1 -1
  58. package/dist/sale-common.js +39 -4
  59. package/dist/sale-common.js.map +1 -1
  60. package/dist/snapshot-deployment.d.ts +83 -0
  61. package/dist/snapshot-deployment.d.ts.map +1 -0
  62. package/dist/snapshot-deployment.js +78 -0
  63. package/dist/snapshot-deployment.js.map +1 -0
  64. package/dist/snapshot-operation.d.ts +28 -0
  65. package/dist/snapshot-operation.d.ts.map +1 -0
  66. package/dist/snapshot-operation.js +2428 -0
  67. package/dist/snapshot-operation.js.map +1 -0
  68. package/dist/snapshot-signerless-transactions.d.ts +133 -0
  69. package/dist/snapshot-signerless-transactions.d.ts.map +1 -0
  70. package/dist/snapshot-signerless-transactions.js +735 -0
  71. package/dist/snapshot-signerless-transactions.js.map +1 -0
  72. package/dist/snapshot-signerless.d.ts +227 -0
  73. package/dist/snapshot-signerless.d.ts.map +1 -0
  74. package/dist/snapshot-signerless.js +993 -0
  75. package/dist/snapshot-signerless.js.map +1 -0
  76. package/dist/snapshot-verification.d.ts +58 -0
  77. package/dist/snapshot-verification.d.ts.map +1 -0
  78. package/dist/snapshot-verification.js +92 -0
  79. package/dist/snapshot-verification.js.map +1 -0
  80. package/dist/token-operation.js +3 -3
  81. package/dist/token-operation.js.map +1 -1
  82. package/docs/API.md +67 -0
  83. package/docs/COMPATIBILITY.json +84 -0
  84. package/docs/INTEGRATION.md +215 -0
  85. package/docs/LIVE_TRANSFER.md +106 -0
  86. package/docs/RECIPES.md +175 -0
  87. package/docs/TRANSACTION_GUIDE.md +163 -0
  88. package/docs/snapshot-start.md +27 -0
  89. package/examples/README.md +81 -0
  90. package/examples/backend/cli.ts +55 -0
  91. package/examples/backend/recipe.ts +39 -0
  92. package/examples/backend/runtime.ts +13 -0
  93. package/examples/frontend/index.html +48 -0
  94. package/examples/frontend/main.ts +213 -0
  95. package/examples/frontend/runtime.ts +14 -0
  96. package/examples/package-lock.json +1287 -0
  97. package/examples/package.json +23 -0
  98. package/examples/shared/build.ts +179 -0
  99. package/examples/shared/fixture.ts +24 -0
  100. package/examples/shared/live-transfer.ts +155 -0
  101. package/examples/shared/recipe-fixtures.ts +543 -0
  102. package/examples/shared/recipes.ts +55 -0
  103. package/examples/shared/signing.ts +110 -0
  104. package/examples/shared/timeout.ts +8 -0
  105. package/examples/test/browser.ts +116 -0
  106. package/examples/test/build.test.ts +197 -0
  107. package/examples/test/recipes.test.ts +59 -0
  108. package/examples/test/sources.test.ts +73 -0
  109. package/examples/tsconfig.json +26 -0
  110. package/examples/vendor/NOTICE.md +15 -0
  111. package/examples/vendor/kaspa/LICENSE +15 -0
  112. package/examples/vendor/kaspa/kaspa.d.ts +8908 -0
  113. package/examples/vendor/kaspa/kaspa.js +15202 -0
  114. package/examples/vendor/kaspa/kaspa_bg.wasm +0 -0
  115. package/examples/vendor/kaspa/package.json +24 -0
  116. package/package.json +21 -4
  117. package/src/artifacts.ts +35 -0
  118. package/src/engine.ts +91 -97
  119. package/src/index.ts +8 -0
  120. package/src/operations.ts +4 -0
  121. package/src/sale-common.ts +44 -3
  122. package/src/snapshot-deployment.ts +108 -0
  123. package/src/snapshot-operation.ts +3592 -0
  124. package/src/snapshot-signerless-transactions.ts +1272 -0
  125. package/src/snapshot-signerless.ts +1525 -0
  126. package/src/snapshot-verification.ts +86 -0
  127. package/src/token-operation.ts +3 -3
package/CHANGELOG.md ADDED
@@ -0,0 +1,21 @@
1
+ # Changelog
2
+
3
+ ## 0.4.0 (unreleased)
4
+
5
+ - Add signerless snapshot deployment, start, claim, transfer, and verification builders with pinned contract artifacts and transaction tests.
6
+ - Reject conflicting explicit native covenant IDs during transfer while retaining legacy alias resolution.
7
+ - Preserve pre-authorized covenant witnesses and validate wallet signature encodings and sighash bytes.
8
+ - Add 24 executable operation scenarios, a validated live-transfer source adapter, and tests run from extracted package contents.
9
+ - Add integration and API guides, including amount examples, host-supplied WASM,
10
+ artifact loading, source transport, request schemas, signing, and errors.
11
+ - Include guides, release instructions, and security reporting in the npm tarball.
12
+ - Replace the README's host-specific bridge example with the exported engine API.
13
+ - Document public npm registry overrides and replace obsolete first-release steps.
14
+
15
+ The engine RPC adapter now supports frozen WASM exports from browser bundlers.
16
+
17
+ ### Public integration examples
18
+
19
+ - Add runnable browser and Node deploy/transfer examples with WASM and offline fixtures.
20
+ - Fix the engine RPC adapter for frozen WASM module exports produced by bundlers.
21
+ - Verify packed-package browser/Node parity without external network requests.
package/README.md CHANGED
@@ -7,7 +7,9 @@ frontend and the Node backend.
7
7
  ## Install
8
8
 
9
9
  ```sh
10
- npm install @kaspacom/kcc20-tx-builder
10
+ npm install --save-exact @kaspacom/kcc20-tx-builder@0.4.0 \
11
+ --registry=https://registry.npmjs.org/ \
12
+ --@kaspacom:registry=https://registry.npmjs.org/
11
13
  ```
12
14
 
13
15
  The package provides ESM and CommonJS entry points and requires Node.js 20 or
@@ -16,6 +18,21 @@ Browser consumers must provide their already-loaded browser Kaspa WASM runtime;
16
18
  Node consumers provide their Node Kaspa WASM runtime. Kaspa WASM is deliberately
17
19
  not bundled or initialized by this package.
18
20
 
21
+ ## Documentation
22
+
23
+ - [Integration guide](docs/INTEGRATION.md): amount calculations, engine setup,
24
+ artifacts, source providers, signing boundaries, and error handling.
25
+ - [API guide](docs/API.md): public entry points and operation families.
26
+ - [Independent indexing](https://github.com/KASPACOM/kaspa-covenants/blob/develop/docs/INDEPENDENT_INDEXING.md): self-hosted data boundaries and lightweight-indexer release gates. The lightweight indexer is not yet a live data source.
27
+ - [Snapshot builders](docs/snapshot-start.md): signerless deployment, claims and verification; funded DEV rehearsal is still required.
28
+ - [Release guide](RELEASING.md): publishing and consumer verification.
29
+
30
+ Public npm installation does not require a GitHub token. The explicit scoped
31
+ registry flag overrides project settings that route `@kaspacom` to GitHub Packages.
32
+ This branch prepares `0.4.0` with expanded documentation and signerless snapshot
33
+ builders. Pin the same exact version across wallet and server adapters. See
34
+ [the changelog](CHANGELOG.md) for the release contents.
35
+
19
36
  ## Runtime boundary
20
37
 
21
38
  The package deliberately does not import Kaspa WASM, Angular, NestJS, Node
@@ -33,21 +50,35 @@ amount/fee calculations, and action-specific UTXO selection. It supports
33
50
  deploy, verify, mint, mint availability, transfer, native/wrapped
34
51
  consolidation, wrap, unwrap, wrapper-market deploy, create/fill/sweep/cancel
35
52
  orders, FeeTicket root/create/burn/transfer/update operations, and the
36
- deterministic matcher/operator transaction builders. Matcher/operator
53
+ immutable bootstrap and controller deployments, signerless snapshot start,
54
+ claims, recipient transfers, and deterministic matcher/operator transaction
55
+ builders. Matcher/operator
37
56
  invocation, authorization, scheduling, and key custody remain backend-only;
38
57
  hosts must explicitly enable those builders with `allowBackendOnly`.
39
58
 
40
59
  The package ships the KCC20 contract artifacts under `artifacts/`, but the
41
60
  engine still accepts supplied artifacts and UTXO/RPC access and never reads
42
61
  files, environment variables, or WASM assets itself. Browser and backend hosts
43
- decide how to load package artifacts for their runtime. The frontend host can
44
- configure the bridge with its already-loaded runtime:
62
+ decide how to load package artifacts for their runtime. The host can
63
+ configure the exported engine with its already-loaded runtime:
45
64
 
46
65
  ```ts
47
- clientBuilder.configure({
66
+ import { createKcc20PsktBuilderEngine } from "@kaspacom/kcc20-tx-builder";
67
+
68
+ createKcc20PsktBuilderEngine({
48
69
  wasm: loadedKaspa,
49
- artifactProvider: (key) =>
50
- fetch(`/kcc20-artifacts/${key}`).then((response) => response.json()),
70
+ artifacts: {},
71
+ artifactProvider: async (key) => {
72
+ const response = await fetch(
73
+ `/kcc20-artifacts/${encodeURIComponent(key)}`,
74
+ );
75
+ if (!response.ok) throw new Error(`Cannot load artifact ${key}`);
76
+ const rawBytes = new Uint8Array(await response.arrayBuffer());
77
+ return {
78
+ artifact: JSON.parse(new TextDecoder().decode(rawBytes)),
79
+ rawBytes,
80
+ };
81
+ },
51
82
  sourceProvider: {
52
83
  getUtxosByAddresses: (request) =>
53
84
  applicationRpcConnection.getUtxosByAddresses(request),
@@ -59,6 +90,11 @@ The artifact and source providers are host policies. Private operator keys
59
90
  must never be embedded in this package; a trusted backend may inject one at
60
91
  runtime for an explicitly authorized operator build.
61
92
 
93
+ Snapshot builds require the raw artifact bytes so the package can compare the
94
+ file SHA-256 with the migration's frozen artifact pins before constructing a
95
+ transaction. Returning only parsed JSON is intentionally insufficient for that
96
+ check.
97
+
62
98
  When `sourceProvider` is present, its connection lifecycle belongs entirely to
63
99
  the host: the builder does not construct, connect, or disconnect an RPC client.
64
100
  This allows a browser application to reuse one reconnecting websocket across
@@ -85,7 +121,8 @@ import kcc20Artifact from "@kaspacom/kcc20-tx-builder/artifacts/KCC20.placeholde
85
121
  ```
86
122
 
87
123
  The published, hash-pinned set contains `KCC20`, `KCC20Wrapper`,
88
- `KCC20Orderbook`, `KCC20FeeTicket`, and `KCC20Vesting`. Consumers should not
124
+ `KCC20Orderbook`, `KCC20FeeTicket`, `KCC20Vesting`,
125
+ `KCC20SnapshotBootstrap`, and `KCC20SnapshotController`. Consumers should not
89
126
  vendor separate copies of these files.
90
127
 
91
128
  How JSON modules are loaded depends on the consuming runtime and bundler. A
@@ -102,3 +139,12 @@ backend secrets into this package in a browser.
102
139
  ## License
103
140
 
104
141
  Apache-2.0
142
+
143
+ ## Runnable transaction examples
144
+
145
+ Start with the [frontend and backend examples](examples/README.md), then read
146
+ the [transaction construction guide](docs/TRANSACTION_GUIDE.md) and
147
+ [operation recipes](docs/RECIPES.md). Both applications construct transactions
148
+ locally using packaged artifacts and host-supplied chain data.
149
+
150
+ For independently retrieved holder state, see the [live transfer walkthrough](docs/LIVE_TRANSFER.md); all supported user operation families have [runnable offline recipes](docs/RECIPES.md).
package/RELEASING.md ADDED
@@ -0,0 +1,93 @@
1
+ # Releasing
2
+
3
+ The package is published under the same version to both registries:
4
+
5
+ - npmjs (`https://registry.npmjs.org`) is the public distribution for general
6
+ consumers and the backend.
7
+ - GitHub Packages (`https://npm.pkg.github.com`) supports KaspaCom projects
8
+ whose `.npmrc` maps the entire `@kaspacom` scope to GitHub Packages.
9
+
10
+ Never publish different contents under the same version. npm package versions
11
+ are immutable, so update `package.json` before each release.
12
+
13
+ ## Publishing setup
14
+
15
+ The package is already public on npmjs at `0.2.5`. GitHub Releases trigger
16
+ `.github/workflows/publish.yml`, which has independent npmjs and GitHub Packages
17
+ jobs. Both jobs install dependencies, run tests, and require the release tag to
18
+ match `v` plus the checked-out `package.json` version.
19
+
20
+ npmjs uses trusted OIDC publishing with provenance on Node 24. Its trusted
21
+ publisher identifies organization `KASPACOM`, repository `kcc20-tx-builder`,
22
+ and workflow `publish.yml`, with no GitHub environment configured. GitHub
23
+ Packages uses the workflow's short-lived `GITHUB_TOKEN` and `packages: write`.
24
+ Do not add long-lived npm tokens or publish from an unreviewed checkout.
25
+
26
+ ## Prepare a release
27
+
28
+ 1. Start from reviewed `main` and update the version in a release PR.
29
+ 2. Run `npm ci`, `npm test`, and `npm pack --dry-run`.
30
+ 3. Inspect the tarball for compiled ESM/CommonJS entry points, declarations,
31
+ artifacts, documentation, and license. Check that no credentials or local
32
+ wallet files are included.
33
+ 4. Merge the release PR after CI and review pass.
34
+ 5. Create the matching `v<version>` tag and GitHub Release from that commit.
35
+ 6. Confirm both publish jobs succeed and inspect registry metadata and the
36
+ package tarball before upgrading consumers.
37
+
38
+ Creating a GitHub Release publishes the package automatically. Prepare and
39
+ review the release first; do not create a release merely to test the workflow.
40
+
41
+ ## Consumer upgrades
42
+
43
+ Install the exact released version using the registry used by your CI:
44
+
45
+ ```sh
46
+ npm install --save-exact @kaspacom/kcc20-tx-builder@0.2.5 \
47
+ --registry=https://registry.npmjs.org/ \
48
+ --@kaspacom:registry=https://registry.npmjs.org/
49
+ ```
50
+
51
+ Replace `0.2.5` with the reviewed version for a later upgrade. Commit both
52
+ `package.json` and `package-lock.json`. Keep frontend and backend on the same
53
+ exact package version. Remove any `file:../kcc20-tx-builder` resolution before
54
+ independent CI or deployment. Run package, backend, and frontend verification
55
+ against the registry package rather than a neighboring checkout.
56
+
57
+ ## Live release gate
58
+
59
+ Before deploying either consumer, run one TN10 wallet smoke test with the
60
+ published package (not the local `file:` dependency):
61
+
62
+ 1. Deploy and verify a token, then reload the page and confirm unfinished
63
+ deploy recovery and backend settlement tracking still find it.
64
+ 2. Mint, transfer, wrap, unwrap, and consolidate both native and wrapped
65
+ holder UTXOs.
66
+ 3. Create buy and sell orders; fill, sweep, and cancel both sides.
67
+ 4. Deploy/update the FeeTicket root; create, use, transfer, and burn a ticket.
68
+ 5. Confirm browser network traffic contains no KCC20 `/plan`, `/build`, or
69
+ `/sources` requests and that all RPC-backed actions reuse one persistent
70
+ Kaspa WebSocket connection.
71
+
72
+ Treat this as a release gate: unit tests prove deterministic construction and
73
+ adapter behavior, while this smoke test proves compatibility with the live
74
+ wallet, WASM, node, and indexer versions being deployed.
75
+
76
+ ## Verify registry metadata
77
+
78
+ Projects may map the entire `@kaspacom` scope to GitHub Packages. Override that
79
+ mapping when checking public npm:
80
+
81
+ ```sh
82
+ npm view @kaspacom/kcc20-tx-builder version dist-tags \
83
+ --registry=https://registry.npmjs.org/ \
84
+ --@kaspacom:registry=https://registry.npmjs.org/
85
+ ```
86
+
87
+ A green publishing workflow confirms an upload, not consumer compatibility.
88
+ Inspect the installed tarball and complete the live release gate before
89
+ consumer deployment. Record any unverified operation families explicitly.
90
+
91
+ ## Snapshot release gate
92
+
93
+ The current candidate is version `0.4.0`. Keep publication blocked until the release workflow and trusted-publisher configuration are verified for the final release revision. Run `test:snapshot:transactions` with the pinned WASM and close the snapshot artifact reproduction and funded-rehearsal gates before creating the `v0.4.0` tag.
package/SECURITY.md ADDED
@@ -0,0 +1,16 @@
1
+ # Security policy
2
+
3
+ Report wallet, transaction-construction, artifact, or publishing vulnerabilities
4
+ through GitHub private vulnerability reporting when available. Otherwise email
5
+ `security@kaspa.com` with a summary and request a private disclosure channel
6
+ before sending exploit details. Do not post private keys, signed transaction
7
+ payloads containing sensitive data, or exploit details in a public issue.
8
+
9
+ Use a reviewed package version and its matching artifacts. Applications must
10
+ validate transaction intent, source ownership, recipients, and resulting chain
11
+ state independently. Browser-built PSKTs are untrusted at a server boundary.
12
+ The backend-only engine flag enables construction; your host remains responsible
13
+ for authorization, private-key custody, signing, and broadcasting.
14
+
15
+ Fixes are prepared on `main`. Historical package versions are not guaranteed
16
+ to receive backports; consult release notes before upgrading.