wative-core 2.4.6 → 2.5.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 (38) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +47 -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-CCBOKuHv.d.cts → container-provider-BCG7wTYx.d.cts} +1 -1
  12. package/dist/{container-provider-COf_p1JR.d.ts → container-provider-DMZGR5MP.d.ts} +1 -1
  13. package/dist/{evm-B5b_UPYy.d.ts → evm-BZoe2IFx.d.ts} +1 -1
  14. package/dist/{evm-BMB0sT3U.d.cts → evm-BeI4m7M5.d.cts} +1 -1
  15. package/dist/{file-sink-778TcqKz.d.cts → file-sink-BLqWAqHB.d.cts} +2 -2
  16. package/dist/{file-sink-Bu1YeJSR.d.ts → file-sink-CuPr45EN.d.ts} +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-CZ-D916M.d.ts → svm-BQMaUXEA.d.ts} +1 -1
  30. package/dist/{svm-BRKxogvC.d.cts → svm-Bi74PhrA.d.cts} +1 -1
  31. package/dist/{workspace-Clmfomrc.d.cts → workspace-ZNpsa6W7.d.cts} +36 -11
  32. package/dist/{workspace-Clmfomrc.d.ts → workspace-ZNpsa6W7.d.ts} +36 -11
  33. package/examples/04-network-management.test.cjs +5 -4
  34. package/examples/07-custom-provider.test.cjs +1 -1
  35. package/examples/20-custom-chain-dialect.test.cjs +155 -0
  36. package/examples/21-token-transfer.test.cjs +85 -0
  37. package/examples/README.md +5 -2
  38. 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.0] — 2026-09-12
6
+
7
+ Adds token-aware transfers and a public way to add your own chain.
8
+
9
+ ### Added
10
+ - `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.
11
+ - 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.
12
+
13
+ ## [2.4.7] — 2026-09-11
14
+
15
+ Adds more built-in networks and updates the Solana network identifiers.
16
+
17
+ ### Added
18
+ - Four built-in networks ship preloaded, each with its native coin: HyperEVM, HyperEVM Testnet, Robinhood Chain, and Robinhood Chain Testnet.
19
+
20
+ ### Changed
21
+ - The built-in Solana, Solana Testnet and Solana Devnet networks now report new chain ids. If you look a Solana network up by chain id, read it from the resolved network rather than assuming the earlier value.
22
+
5
23
  ## [2.4.6] — 2026-09-11
6
24
 
7
25
  Fixes across signing, contracts and storage, and corrections to the documentation.
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,21 @@ const sim = await evmAddr.simulateTransaction(tx);
489
491
  console.log(sim.gasUsed);
490
492
  ```
491
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:
495
+
496
+ ```ts
497
+ // native coin (omit `asset`)
498
+ const native = evmAddr.transfer({ to: recipient, amount: 1_000_000_000_000_000n });
499
+ // an ERC-20 / SPL token, by contract address or mint
500
+ const token = evmAddr.transfer({ to: recipient, asset: { address: usdcAddress }, amount: 1_000_000n });
501
+ // or by symbol, resolved against the network's known tokens
502
+ const bySymbol = evmAddr.transfer({ to: recipient, asset: { symbol: "USDC" }, amount: 1_000_000n });
503
+
504
+ await evmAddr.signTransaction(native);
505
+ ```
506
+
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.
508
+
492
509
  ### Network — pre-loaded networks + your own
493
510
 
494
511
  ```ts
@@ -761,6 +778,31 @@ may need to override:
761
778
  `unreadableRecordSlugs()` carry defaults in the same family — see their JSDoc
762
779
  before overriding either.
763
780
 
781
+ ## Adding a chain
782
+
783
+ 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.
784
+
785
+ ```ts
786
+ import { ChainDialect, registerDialect, type ChainCtx } from "wative-core";
787
+
788
+ class MyDialect extends ChainDialect {
789
+ readonly vm = "mychain";
790
+ readonly curve = "ed25519"; // reuse a built-in signing curve
791
+
792
+ signMessage(ctx: ChainCtx, message: string): string { /* build a digest, sign via ctx._signBytes, format */ }
793
+ buildTransaction(ctx, params) { /* return your chain's transaction */ }
794
+ transfer(ctx, req) { /* lower { to, asset, amount } to a transaction */ }
795
+ derive(seed, index) { /* return { publicKey, privateKey } at this index */ }
796
+ addressFromPrivateKey(pk) { /* the address a key controls */ }
797
+ privateKeyMatches(pk, publicKey) { /* whether a key controls an address */ }
798
+ // signMessageEncoded / signTypedData round out the contract
799
+ }
800
+
801
+ registerDialect("mychain", () => new MyDialect());
802
+ ```
803
+
804
+ 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).
805
+
764
806
  ## Imports from sub-paths
765
807
 
766
808
  Heavier chain helpers are kept on separate import paths so you only pull them in if you need them: