wative-core 2.5.0 → 2.5.2

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 (37) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +35 -9
  3. package/dist/artifacts/evm/index.cjs +1 -1
  4. package/dist/artifacts/evm/index.d.cts +2 -2
  5. package/dist/artifacts/evm/index.d.ts +2 -2
  6. package/dist/artifacts/evm/index.js +1 -1
  7. package/dist/artifacts/svm/index.cjs +1 -1
  8. package/dist/artifacts/svm/index.d.cts +3 -3
  9. package/dist/artifacts/svm/index.d.ts +3 -3
  10. package/dist/artifacts/svm/index.js +1 -1
  11. package/dist/{container-provider-DMZGR5MP.d.ts → container-provider-CH6Xg37M.d.ts} +1 -1
  12. package/dist/{container-provider-BCG7wTYx.d.cts → container-provider-CwaWx7dP.d.cts} +1 -1
  13. package/dist/{evm-BeI4m7M5.d.cts → evm-CNVThs9s.d.cts} +1 -1
  14. package/dist/{evm-BZoe2IFx.d.ts → evm-YfBR8PgX.d.ts} +1 -1
  15. package/dist/{file-sink-CuPr45EN.d.ts → file-sink-C0gUIm1T.d.ts} +2 -2
  16. package/dist/{file-sink-BLqWAqHB.d.cts → file-sink-WkxXiVRr.d.cts} +2 -2
  17. package/dist/index.cjs +1 -1
  18. package/dist/index.d.cts +8 -8
  19. package/dist/index.d.ts +8 -8
  20. package/dist/index.js +1 -1
  21. package/dist/index.node.cjs +1 -1
  22. package/dist/index.node.d.cts +5 -5
  23. package/dist/index.node.d.ts +5 -5
  24. package/dist/index.node.js +1 -1
  25. package/dist/node/index.cjs +1 -1
  26. package/dist/node/index.d.cts +3 -3
  27. package/dist/node/index.d.ts +3 -3
  28. package/dist/node/index.js +1 -1
  29. package/dist/{svm-BQMaUXEA.d.ts → svm-CK_DQNIq.d.ts} +1 -1
  30. package/dist/{svm-Bi74PhrA.d.cts → svm-DF7cHWms.d.cts} +1 -1
  31. package/dist/{workspace-ZNpsa6W7.d.cts → workspace-CFDXsaHa.d.cts} +26 -2
  32. package/dist/{workspace-ZNpsa6W7.d.ts → workspace-CFDXsaHa.d.ts} +26 -2
  33. package/examples/17-locked-state.test.cjs +1 -0
  34. package/examples/20-custom-chain-dialect.test.cjs +6 -6
  35. package/examples/21-token-transfer.test.cjs +13 -13
  36. package/examples/README.md +2 -2
  37. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -2,6 +2,24 @@
2
2
 
3
3
  All notable changes to `wative-core` are documented here. The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and the project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
4
4
 
5
+ ## [2.5.2] — 2026-09-18
6
+
7
+ Adds two methods for signing bytes you built yourself.
8
+
9
+ ### Added
10
+ - `address.signDigest(digest)` signs a 32-byte digest on an EVM address exactly as given, with no hashing and no prefix. It returns `r`, `s`, the recovery id (0 or 1), and a 65-byte `signature` with `v = 27 + recovery`. Build `v` from `recovery` for a typed or EIP-155 transaction.
11
+ - `address.signBytes(message)` signs arbitrary bytes on an SVM address exactly as given, for example a serialized Solana transaction message. It returns the 64-byte signature as base58 and as hex.
12
+ - Both take a `Uint8Array` or a `0x`-prefixed hex string of whole bytes, need the account unlocked, and sign whatever they are given, so pass only data you assembled yourself.
13
+
14
+ ## [2.5.1] — 2026-09-12
15
+
16
+ Renames the transfer helper and improves fee handling.
17
+
18
+ ### Changed
19
+ - BREAKING: `address.transfer(...)` is now `address.buildTransferPayload(...)`. It returns the transfer's parameters; pass them to `buildTransaction(...)` to sign and send — for example `buildTransaction({ ...buildTransferPayload({ to, asset, amount }), chainId }).send()`.
20
+ - When you don't set gas fees, they are now chosen with more headroom, so a transaction is less likely to sit unconfirmed while network fees rise.
21
+ - The built-in `evm` and `svm` chains can no longer be replaced through `registerDialect`; registering your own chain under a new name is unaffected.
22
+
5
23
  ## [2.5.0] — 2026-09-12
6
24
 
7
25
  Adds token-aware transfers and a public way to add your own chain.
package/README.md CHANGED
@@ -477,7 +477,7 @@ const tx = evmAddr.buildTransaction({
477
477
  value: 1_000_000_000_000_000n,
478
478
  chainId: 1,
479
479
  });
480
- await evmAddr.signTransaction(tx);
480
+ await tx.sign(); // resolves once the signature exists
481
481
  const tracker = await evmAddr.sendTransaction(tx);
482
482
 
483
483
  tracker.on("change", (state) => console.log("state →", state.status));
@@ -491,20 +491,45 @@ const sim = await evmAddr.simulateTransaction(tx);
491
491
  console.log(sim.gasUsed);
492
492
  ```
493
493
 
494
- `transfer()` is the one-call path for moving value — it builds the right transaction for the asset, then you sign and send it like any other:
494
+ `address.signTransaction(tx)` returns straight away and does not wait for the signature. To use the signed bytes (`tx.rawTransaction`, `tx.hash`), `await tx.sign()` first — it resolves once signing is done and is safe to call more than once.
495
+
496
+ `buildTransferPayload()` is the one-call path for moving value — it works out the right payload for the asset (native value, ERC-20 calldata, or SPL instructions). You then pass that payload to `buildTransaction()` and send it like any other transaction:
495
497
 
496
498
  ```ts
497
499
  // native coin (omit `asset`)
498
- const native = evmAddr.transfer({ to: recipient, amount: 1_000_000_000_000_000n });
500
+ const nativePayload = evmAddr.buildTransferPayload({ to: recipient, amount: 1_000_000_000_000_000n });
499
501
  // an ERC-20 / SPL token, by contract address or mint
500
- const token = evmAddr.transfer({ to: recipient, asset: { address: usdcAddress }, amount: 1_000_000n });
502
+ const tokenPayload = evmAddr.buildTransferPayload({ to: recipient, asset: { address: usdcAddress }, amount: 1_000_000n });
501
503
  // or by symbol, resolved against the network's known tokens
502
- const bySymbol = evmAddr.transfer({ to: recipient, asset: { symbol: "USDC" }, amount: 1_000_000n });
504
+ const bySymbol = evmAddr.buildTransferPayload({ to: recipient, asset: { symbol: "USDC" }, amount: 1_000_000n });
503
505
 
504
- await evmAddr.signTransaction(native);
506
+ // build the transaction from the payload, then sign/send it
507
+ const tx = evmAddr.buildTransaction({ ...nativePayload, chainId: 1 });
508
+ await tx.sign();
505
509
  ```
506
510
 
507
- Amounts are in the token's smallest unit. An SPL transfer to a recipient without a token account prepends the account-creation step for you.
511
+ Amounts are in the token's smallest unit. `buildTransaction` fills in nonce/gas/fees for you when you omit them, or uses the values you pass. An SPL transfer to a recipient without a token account prepends the account-creation step for you.
512
+
513
+ #### Signing bytes you built yourself
514
+
515
+ If you build and broadcast transactions yourself and only need a signature, two methods sign exactly the bytes you give them. Neither hashes its input, adds a prefix, or touches the network.
516
+
517
+ ```ts
518
+ // EVM: sign a 32-byte digest you computed (for example the keccak of an encoded transaction)
519
+ const { r, s, recovery, signature } = evmAddr.signDigest("0x" + "ab".repeat(32));
520
+ // r, s: 32-byte hex (s is low); recovery: 0 or 1; signature: 65 bytes, v = 27 + recovery
521
+
522
+ // SVM: sign arbitrary bytes, for example a serialized Solana transaction message
523
+ const { signature: sig58, signatureHex } = svmAddr.signBytes(messageBytes);
524
+ ```
525
+
526
+ - Both take a `Uint8Array` or a `0x`-prefixed hex string of whole bytes. Base64 and hex without the prefix are refused; decode base64 yourself first.
527
+ - `signDigest` requires exactly 32 bytes.
528
+ - `signBytes` accepts any length, including binary data that `signMessageEncoded(..., "ed25519")` cannot carry, because that method takes text.
529
+ - The 65-byte `signature` uses the message-signing convention for `v`. For a typed transaction use `recovery` as the y-parity, and for a legacy EIP-155 transaction use `35 + 2 * chainId + recovery`.
530
+ - `signDigest` works only on an EVM address and `signBytes` only on an SVM address. Each needs the account unlocked.
531
+
532
+ > ⚠️ These sign anything you hand them, with none of the checks `signTypedData` applies. Only pass digests and bytes you assembled yourself.
508
533
 
509
534
  ### Network — pre-loaded networks + your own
510
535
 
@@ -579,7 +604,8 @@ const evmTx = new EvmTransaction({
579
604
  maxFeePerGas: 50_000_000_000n,
580
605
  maxPriorityFeePerGas: 1_000_000_000n,
581
606
  });
582
- await evmAddr.signTransaction(evmTx);
607
+ evmAddr.signTransaction(evmTx); // checks `from` and attaches the transaction to this address
608
+ await evmTx.sign(); // resolves once the signature exists
583
609
  const evmTracker = await evmAddr.sendTransaction(evmTx);
584
610
 
585
611
  const receipt = await evmTracker.whenConfirmed();
@@ -791,7 +817,7 @@ class MyDialect extends ChainDialect {
791
817
 
792
818
  signMessage(ctx: ChainCtx, message: string): string { /* build a digest, sign via ctx._signBytes, format */ }
793
819
  buildTransaction(ctx, params) { /* return your chain's transaction */ }
794
- transfer(ctx, req) { /* lower { to, asset, amount } to a transaction */ }
820
+ buildTransferPayload(ctx, req) { /* lower { to, asset, amount } to a transfer payload */ }
795
821
  derive(seed, index) { /* return { publicKey, privateKey } at this index */ }
796
822
  addressFromPrivateKey(pk) { /* the address a key controls */ }
797
823
  privateKeyMatches(pk, publicKey) { /* whether a key controls an address */ }