wative-core 2.4.7 → 2.5.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 (36) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/README.md +49 -5
  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-D4yopeO_.d.ts → container-provider-CBBJbpUn.d.ts} +1 -1
  12. package/dist/{container-provider-Dh55EEx5.d.cts → container-provider-COvXmCLM.d.cts} +1 -1
  13. package/dist/{evm-B-cOplST.d.ts → evm-Dk4ceFz0.d.ts} +1 -1
  14. package/dist/{evm-CkUAeSHX.d.cts → evm-V5Fn53uW.d.cts} +1 -1
  15. package/dist/{file-sink-GTK4Vv_k.d.ts → file-sink-Bf9mpegF.d.ts} +2 -2
  16. package/dist/{file-sink-ClLrovbG.d.cts → file-sink-BjbtAHUL.d.cts} +2 -2
  17. package/dist/index.cjs +1 -1
  18. package/dist/index.d.cts +55 -7
  19. package/dist/index.d.ts +55 -7
  20. package/dist/index.js +1 -1
  21. package/dist/index.node.cjs +1 -1
  22. package/dist/index.node.d.cts +6 -6
  23. package/dist/index.node.d.ts +6 -6
  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-BVmGEWtP.d.cts → svm-CjNIJZ4l.d.cts} +1 -1
  30. package/dist/{svm-B0khNLa5.d.ts → svm-D8zsWS64.d.ts} +1 -1
  31. package/dist/{workspace-B3nsEAmk.d.cts → workspace-DqUdScht.d.cts} +44 -11
  32. package/dist/{workspace-B3nsEAmk.d.ts → workspace-DqUdScht.d.ts} +44 -11
  33. package/examples/20-custom-chain-dialect.test.cjs +155 -0
  34. package/examples/21-token-transfer.test.cjs +85 -0
  35. package/examples/README.md +5 -2
  36. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -2,6 +2,23 @@
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.1] — 2026-09-12
6
+
7
+ Renames the transfer helper and improves fee handling.
8
+
9
+ ### Changed
10
+ - 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()`.
11
+ - 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.
12
+ - The built-in `evm` and `svm` chains can no longer be replaced through `registerDialect`; registering your own chain under a new name is unaffected.
13
+
14
+ ## [2.5.0] — 2026-09-12
15
+
16
+ Adds token-aware transfers and a public way to add your own chain.
17
+
18
+ ### Added
19
+ - `address.transfer({ to, asset, amount })` sends in one call: the native coin (omit `asset`), a token by its contract address or mint, or a token by symbol. Amounts are given in the token's smallest unit.
20
+ - Support for a chain the library does not ship: subclass the exported `ChainDialect`, implement its methods, and register it with `registerDialect` — the same way you extend `Provider` for storage. `ChainDialect`, `ChainCtx` and the per-chain `EvmSigner` / `SvmSigner` types are now exported.
21
+
5
22
  ## [2.4.7] — 2026-09-11
6
23
 
7
24
  Adds more built-in networks and updates the Solana network identifiers.
package/README.md CHANGED
@@ -308,7 +308,7 @@ The copy is required: Node's test runner skips anything under `node_modules`, so
308
308
  node node_modules/wative-core/examples/01-quick-start.test.cjs
309
309
  ```
310
310
 
311
- Files cover: quick start, HD vs PK accounts, network management, asset management, address signing, custom storage backends, persistence, workspace search, default-network selection, subpath imports, the workspace logger, workspace config, the ESM entry, package resolution, known-answer vectors, locked-state behaviour, and one-key-per-workspace derivation. See [examples/README.md](./examples/README.md) for the full index — it is the list that stays current.
311
+ Files cover: quick start, HD vs PK accounts, network management, asset management, address signing, custom storage backends, persistence, workspace search, default-network selection, subpath imports, the workspace logger, workspace config, the ESM entry, package resolution, known-answer vectors, locked-state behaviour, one-key-per-workspace derivation, adding a custom chain, and token transfers. See [examples/README.md](./examples/README.md) for the full index — it is the list that stays current.
312
312
 
313
313
  ## What you can do
314
314
 
@@ -317,19 +317,21 @@ The library is organized around seven things you'll work with:
317
317
  - **`Workspace`** — your top-level container. Holds the password, your accounts, your network and asset list, and a built-in logger.
318
318
  - **`Account`** — either an HD account (one BIP-39 mnemonic, can derive many wallets) or a PK account (raw private keys you import one at a time). Each account can have its own password or share the workspace password.
319
319
  - **`Wallet`** — a unit inside an account, holding one address per `(vm, network)`. Both kinds give you an EVM and a Solana address: an HD slot derives one per chain from the mnemonic, an import derives its sibling from the imported key. Treat `wallet.addresses` as the list it is.
320
- - **`Address`** — an on-chain identity. Sign messages, build transactions, send them.
321
- - **`Network`** — chain metadata. 10 networks ship pre-loaded.
322
- - **`Asset`** — token metadata. 25 tokens ship pre-loaded.
320
+ - **`Address`** — an on-chain identity. Sign messages, build transactions, transfer native coins or tokens, and send them.
321
+ - **`Network`** — chain metadata. 14 networks ship pre-loaded.
322
+ - **`Asset`** — token metadata. 29 tokens ship pre-loaded.
323
323
  - **`Transaction`** — `EvmTransaction` or `SvmTransaction`. Subscribe to lifecycle events (`change` / `confirmed` / `failed`) or await terminal states (`whenSubmitted` / `whenMined` / `whenConfirmed` / `whenFinalized`). Tracking stops at first inclusion, so `whenConfirmed(n)` with `n > 1` rejects `UNSUPPORTED_OP` — call it with no argument and poll `receipt.blockNumber` against the chain head if you need depth — and `whenFinalized()` rejects `UNSUPPORTED_OP` unless the node reported finality directly.
324
324
 
325
325
  Everything is encrypted on disk under your workspace password.
326
326
 
327
327
  ### Pre-loaded networks and tokens
328
328
 
329
- | Networks (10) | Tokens (25) |
329
+ | Networks (14) | Tokens (29) |
330
330
  |---|---|
331
331
  | ethereum, base, bnbchain, arbitrum, optimism | native gas + USDC + USDT on each EVM mainnet (BSC versions are 18-decimal Binance-Peg); plus WETH on ethereum |
332
+ | hyperevm, robinhood | native HYPE on HyperEVM; native ETH on Robinhood Chain |
332
333
  | sepolia, arbitrum-sepolia | native ETH on both testnets; plus USDC on arbitrum-sepolia |
334
+ | hyperevm-testnet, robinhood-testnet | native HYPE / native ETH, mirroring their mainnets |
333
335
  | solana, solana-testnet, solana-devnet | native SOL + USDC + USDT + WSOL on solana mainnet; native-only on testnets |
334
336
 
335
337
  ## Examples by domain
@@ -489,6 +491,23 @@ const sim = await evmAddr.simulateTransaction(tx);
489
491
  console.log(sim.gasUsed);
490
492
  ```
491
493
 
494
+ `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
+
496
+ ```ts
497
+ // native coin (omit `asset`)
498
+ const nativePayload = evmAddr.buildTransferPayload({ to: recipient, amount: 1_000_000_000_000_000n });
499
+ // an ERC-20 / SPL token, by contract address or mint
500
+ const tokenPayload = evmAddr.buildTransferPayload({ to: recipient, asset: { address: usdcAddress }, amount: 1_000_000n });
501
+ // or by symbol, resolved against the network's known tokens
502
+ const bySymbol = evmAddr.buildTransferPayload({ to: recipient, asset: { symbol: "USDC" }, amount: 1_000_000n });
503
+
504
+ // build the transaction from the payload, then sign/send it
505
+ const tx = evmAddr.buildTransaction({ ...nativePayload, chainId: 1 });
506
+ await evmAddr.signTransaction(tx);
507
+ ```
508
+
509
+ 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.
510
+
492
511
  ### Network — pre-loaded networks + your own
493
512
 
494
513
  ```ts
@@ -761,6 +780,31 @@ may need to override:
761
780
  `unreadableRecordSlugs()` carry defaults in the same family — see their JSDoc
762
781
  before overriding either.
763
782
 
783
+ ## Adding a chain
784
+
785
+ To support a blockchain the library does not ship — its own address format, signing and transactions — subclass **`ChainDialect`** and register it under a vm token. This is the chain-side parallel to extending `Provider` for storage: `Workspace` and `Address` route every per-chain operation through the registered dialect, so no library code branches on which chain you added.
786
+
787
+ ```ts
788
+ import { ChainDialect, registerDialect, type ChainCtx } from "wative-core";
789
+
790
+ class MyDialect extends ChainDialect {
791
+ readonly vm = "mychain";
792
+ readonly curve = "ed25519"; // reuse a built-in signing curve
793
+
794
+ signMessage(ctx: ChainCtx, message: string): string { /* build a digest, sign via ctx._signBytes, format */ }
795
+ buildTransaction(ctx, params) { /* return your chain's transaction */ }
796
+ buildTransferPayload(ctx, req) { /* lower { to, asset, amount } to a transfer payload */ }
797
+ derive(seed, index) { /* return { publicKey, privateKey } at this index */ }
798
+ addressFromPrivateKey(pk) { /* the address a key controls */ }
799
+ privateKeyMatches(pk, publicKey) { /* whether a key controls an address */ }
800
+ // signMessageEncoded / signTypedData round out the contract
801
+ }
802
+
803
+ registerDialect("mychain", () => new MyDialect());
804
+ ```
805
+
806
+ Your dialect never receives the private key: it signs through a keyless view (`ctx._signBytes`) the library hands it and declares which built-in curve to use. A runnable end-to-end example — a fictional chain that signs, builds a transaction, transfers and derives — is in [20-custom-chain-dialect.test.cjs](./examples/20-custom-chain-dialect.test.cjs).
807
+
764
808
  ## Imports from sub-paths
765
809
 
766
810
  Heavier chain helpers are kept on separate import paths so you only pull them in if you need them: