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
@@ -1,4 +1,4 @@
1
- import { c as Address, J as SvmTxBuildParams, I as SvmTransaction } from './workspace-ZNpsa6W7.js';
1
+ import { c as Address, J as SvmTxBuildParams, I as SvmTransaction } from './workspace-CFDXsaHa.js';
2
2
 
3
3
  interface SvmInstruction {
4
4
  readonly programId: string;
@@ -1,4 +1,4 @@
1
- import { c as Address, J as SvmTxBuildParams, I as SvmTransaction } from './workspace-ZNpsa6W7.cjs';
1
+ import { c as Address, J as SvmTxBuildParams, I as SvmTransaction } from './workspace-CFDXsaHa.cjs';
2
2
 
3
3
  interface SvmInstruction {
4
4
  readonly programId: string;
@@ -248,6 +248,18 @@ interface TransferRequest {
248
248
  asset?: AssetRef;
249
249
  amount: bigint;
250
250
  }
251
+
252
+ type TransferPayload = {
253
+ readonly vm: "evm";
254
+ readonly to: string;
255
+ readonly value: bigint;
256
+ readonly data: string;
257
+ } | {
258
+ readonly vm: "svm";
259
+ readonly recipient: string;
260
+ readonly amount: bigint;
261
+ readonly instructions?: ReadonlyArray<unknown>;
262
+ };
251
263
  interface Transaction {
252
264
  readonly vm: VmToken;
253
265
  readonly status: TransactionStatus;
@@ -477,6 +489,18 @@ declare class Address {
477
489
  messageHash: string;
478
490
  };
479
491
 
492
+ signDigest(digest: Uint8Array | string): {
493
+ r: string;
494
+ s: string;
495
+ recovery: 0 | 1;
496
+ signature: string;
497
+ };
498
+
499
+ signBytes(message: Uint8Array | string): {
500
+ signature: string;
501
+ signatureHex: string;
502
+ };
503
+
480
504
  signTypedData(typedData: unknown, chainId: number | bigint): {
481
505
  signature: string;
482
506
  domainSeparator: string;
@@ -486,7 +510,7 @@ declare class Address {
486
510
  buildTransaction(params: EvmTxBuildParams): EvmTransaction;
487
511
  buildTransaction(params: SvmTxBuildParams): SvmTransaction;
488
512
 
489
- transfer(req: TransferRequest): Transaction;
513
+ buildTransferPayload(req: TransferRequest): TransferPayload;
490
514
 
491
515
  signTransaction<T extends Transaction>(transaction: T): T;
492
516
 
@@ -799,4 +823,4 @@ declare class Workspace {
799
823
  } | null;
800
824
  }
801
825
 
802
- export { type WativeErrorOpts as $, Account as A, type SimulationResult as B, type ChainId as C, type SinkConfig as D, type EvmAddress as E, type Slug as F, type SvmAddress as G, SvmSigner as H, SvmTransaction as I, type SvmTxBuildParams as J, type TransactionReceipt as K, type LogLevel as L, type TransactionStateChange as M, Network as N, type OpenOptions as O, Provider as P, type TransactionStatus as Q, Record$1 as R, type Settling as S, type Transaction as T, type TransactionTracker as U, type TransferRequest as V, type VmToken as W, Wallet as X, type WalletCollection as Y, WativeError as Z, type WativeErrorCode as _, type AccountCollection as a, Workspace as a0, type WorkspaceConfig as a1, newMnemonic as a2, type SuiAddress as a3, type AccountOrgType as b, Address as c, Asset as d, type AssetBalance as e, type AssetCollection as f, type AssetId as g, type AssetInitObject as h, type AssetRef as i, type ChainVM as j, ConsoleSink as k, type ContainerState as l, type EvmRawTx as m, EvmSigner as n, EvmTransaction as o, type EvmTxBuildParams as p, EvmTxType as q, type LogRecord as r, type LogSink as s, Logger as t, type LoggerConfig as u, type NetworkCollection as v, type NetworkInit as w, type NetworkLike as x, type RecordInit as y, type RecordType as z };
826
+ export { type WativeErrorCode as $, Account as A, type SimulationResult as B, type ChainId as C, type SinkConfig as D, type EvmAddress as E, type Slug as F, type SvmAddress as G, SvmSigner as H, SvmTransaction as I, type SvmTxBuildParams as J, type TransactionReceipt as K, type LogLevel as L, type TransactionStateChange as M, Network as N, type OpenOptions as O, Provider as P, type TransactionStatus as Q, Record$1 as R, type Settling as S, type Transaction as T, type TransactionTracker as U, type TransferPayload as V, type TransferRequest as W, type VmToken as X, Wallet as Y, type WalletCollection as Z, WativeError as _, type AccountCollection as a, type WativeErrorOpts as a0, Workspace as a1, type WorkspaceConfig as a2, newMnemonic as a3, type SuiAddress as a4, type AccountOrgType as b, Address as c, Asset as d, type AssetBalance as e, type AssetCollection as f, type AssetId as g, type AssetInitObject as h, type AssetRef as i, type ChainVM as j, ConsoleSink as k, type ContainerState as l, type EvmRawTx as m, EvmSigner as n, EvmTransaction as o, type EvmTxBuildParams as p, EvmTxType as q, type LogRecord as r, type LogSink as s, Logger as t, type LoggerConfig as u, type NetworkCollection as v, type NetworkInit as w, type NetworkLike as x, type RecordInit as y, type RecordType as z };
@@ -248,6 +248,18 @@ interface TransferRequest {
248
248
  asset?: AssetRef;
249
249
  amount: bigint;
250
250
  }
251
+
252
+ type TransferPayload = {
253
+ readonly vm: "evm";
254
+ readonly to: string;
255
+ readonly value: bigint;
256
+ readonly data: string;
257
+ } | {
258
+ readonly vm: "svm";
259
+ readonly recipient: string;
260
+ readonly amount: bigint;
261
+ readonly instructions?: ReadonlyArray<unknown>;
262
+ };
251
263
  interface Transaction {
252
264
  readonly vm: VmToken;
253
265
  readonly status: TransactionStatus;
@@ -477,6 +489,18 @@ declare class Address {
477
489
  messageHash: string;
478
490
  };
479
491
 
492
+ signDigest(digest: Uint8Array | string): {
493
+ r: string;
494
+ s: string;
495
+ recovery: 0 | 1;
496
+ signature: string;
497
+ };
498
+
499
+ signBytes(message: Uint8Array | string): {
500
+ signature: string;
501
+ signatureHex: string;
502
+ };
503
+
480
504
  signTypedData(typedData: unknown, chainId: number | bigint): {
481
505
  signature: string;
482
506
  domainSeparator: string;
@@ -486,7 +510,7 @@ declare class Address {
486
510
  buildTransaction(params: EvmTxBuildParams): EvmTransaction;
487
511
  buildTransaction(params: SvmTxBuildParams): SvmTransaction;
488
512
 
489
- transfer(req: TransferRequest): Transaction;
513
+ buildTransferPayload(req: TransferRequest): TransferPayload;
490
514
 
491
515
  signTransaction<T extends Transaction>(transaction: T): T;
492
516
 
@@ -799,4 +823,4 @@ declare class Workspace {
799
823
  } | null;
800
824
  }
801
825
 
802
- export { type WativeErrorOpts as $, Account as A, type SimulationResult as B, type ChainId as C, type SinkConfig as D, type EvmAddress as E, type Slug as F, type SvmAddress as G, SvmSigner as H, SvmTransaction as I, type SvmTxBuildParams as J, type TransactionReceipt as K, type LogLevel as L, type TransactionStateChange as M, Network as N, type OpenOptions as O, Provider as P, type TransactionStatus as Q, Record$1 as R, type Settling as S, type Transaction as T, type TransactionTracker as U, type TransferRequest as V, type VmToken as W, Wallet as X, type WalletCollection as Y, WativeError as Z, type WativeErrorCode as _, type AccountCollection as a, Workspace as a0, type WorkspaceConfig as a1, newMnemonic as a2, type SuiAddress as a3, type AccountOrgType as b, Address as c, Asset as d, type AssetBalance as e, type AssetCollection as f, type AssetId as g, type AssetInitObject as h, type AssetRef as i, type ChainVM as j, ConsoleSink as k, type ContainerState as l, type EvmRawTx as m, EvmSigner as n, EvmTransaction as o, type EvmTxBuildParams as p, EvmTxType as q, type LogRecord as r, type LogSink as s, Logger as t, type LoggerConfig as u, type NetworkCollection as v, type NetworkInit as w, type NetworkLike as x, type RecordInit as y, type RecordType as z };
826
+ export { type WativeErrorCode as $, Account as A, type SimulationResult as B, type ChainId as C, type SinkConfig as D, type EvmAddress as E, type Slug as F, type SvmAddress as G, SvmSigner as H, SvmTransaction as I, type SvmTxBuildParams as J, type TransactionReceipt as K, type LogLevel as L, type TransactionStateChange as M, Network as N, type OpenOptions as O, Provider as P, type TransactionStatus as Q, Record$1 as R, type Settling as S, type Transaction as T, type TransactionTracker as U, type TransferPayload as V, type TransferRequest as W, type VmToken as X, Wallet as Y, type WalletCollection as Z, WativeError as _, type AccountCollection as a, type WativeErrorOpts as a0, Workspace as a1, type WorkspaceConfig as a2, newMnemonic as a3, type SuiAddress as a4, type AccountOrgType as b, Address as c, Asset as d, type AssetBalance as e, type AssetCollection as f, type AssetId as g, type AssetInitObject as h, type AssetRef as i, type ChainVM as j, ConsoleSink as k, type ContainerState as l, type EvmRawTx as m, EvmSigner as n, EvmTransaction as o, type EvmTxBuildParams as p, EvmTxType as q, type LogRecord as r, type LogSink as s, Logger as t, type LoggerConfig as u, type NetworkCollection as v, type NetworkInit as w, type NetworkLike as x, type RecordInit as y, type RecordType as z };
@@ -56,6 +56,7 @@ test("a locked account refuses every operation that needs key material", async (
56
56
  await refuses("ACCOUNT_LOCKED", "dumpPrivateKey", () => wallet.dumpPrivateKey("evm"));
57
57
  await refuses("ACCOUNT_LOCKED", "signMessage", () => address.signMessage("hello"));
58
58
  await refuses("ACCOUNT_LOCKED", "signTypedData", () => address.signTypedData(TYPED_DATA));
59
+ await refuses("ACCOUNT_LOCKED", "signDigest", () => address.signDigest("0x" + "ab".repeat(32)));
59
60
  await refuses("ACCOUNT_LOCKED", "deriveWallets", () => account.deriveWallets(1));
60
61
 
61
62
  await ws.unlock("wsp-pwd").catch(() => {});
@@ -48,10 +48,10 @@ class XvmDialect extends ChainDialect {
48
48
  buildTransaction(ctx, params) {
49
49
  return { vm: "xvm", from: String(ctx.publicKey), to: params.to, value: params.value ?? 0n, nonce: params.nonce ?? 0 };
50
50
  }
51
- transfer(ctx, req) {
52
- const tx = { vm: "xvm", from: String(ctx.publicKey), to: req.to, amount: req.amount };
53
- if (req.asset && req.asset.address) tx.token = req.asset.address;
54
- return tx;
51
+ buildTransferPayload(ctx, req) {
52
+ const payload = { vm: "xvm", from: String(ctx.publicKey), to: req.to, amount: req.amount };
53
+ if (req.asset && req.asset.address) payload.token = req.asset.address;
54
+ return payload;
55
55
  }
56
56
  derive(seed, index) {
57
57
  const h = toyHash(`${Buffer.from(seed).toString("hex")}:${index}`);
@@ -125,12 +125,12 @@ test("the custom dialect signs, builds a tx, and transfers via a keyless ctx", (
125
125
  assert.strictEqual(tx.to, "xvm1recipient");
126
126
  assert.strictEqual(tx.nonce, 7);
127
127
 
128
- const native = dialect.transfer(ctx, { to: "xvm1bob", amount: 500n });
128
+ const native = dialect.buildTransferPayload(ctx, { to: "xvm1bob", amount: 500n });
129
129
  assert.strictEqual(native.to, "xvm1bob");
130
130
  assert.strictEqual(native.amount, 500n);
131
131
  assert.strictEqual(native.token, undefined);
132
132
 
133
- const token = dialect.transfer(ctx, { to: "xvm1bob", asset: { address: "xtoken1" }, amount: 5n });
133
+ const token = dialect.buildTransferPayload(ctx, { to: "xvm1bob", asset: { address: "xtoken1" }, amount: 5n });
134
134
  assert.strictEqual(token.token, "xtoken1");
135
135
  });
136
136
 
@@ -1,4 +1,4 @@
1
- // 21 — Token-aware transfer(): one intent lowered per chain — native, ERC-20 by address, SPL by mint, and by symbol. Built offline; amounts are raw base units.
1
+ // 21 — Token-aware buildTransferPayload(): one intent lowered per chain into the buildTransaction payload — native value, ERC-20 by address, SPL by mint, and by symbol. Payload only (does not send); amounts are raw base units.
2
2
 
3
3
  const test = require("node:test");
4
4
  const assert = require("node:assert");
@@ -24,22 +24,22 @@ async function twoWallets() {
24
24
  return { ws, w0: acc.wallets[0], w1: acc.wallets[1] };
25
25
  }
26
26
 
27
- test("transfer() — native value on EVM and SVM (asset omitted)", async () => {
27
+ test("buildTransferPayload() —native value on EVM and SVM (asset omitted)", async () => {
28
28
  const { ws, w0, w1 } = await twoWallets();
29
29
 
30
- const evmTx = w0.evm.transfer({ to: String(w1.evm.publicKey), amount: 1_000_000_000_000_000n });
30
+ const evmTx = w0.evm.buildTransferPayload({ to: String(w1.evm.publicKey), amount: 1_000_000_000_000_000n });
31
31
  assert.strictEqual(String(evmTx.to).toLowerCase(), String(w1.evm.publicKey).toLowerCase());
32
32
  assert.strictEqual(evmTx.value, 1_000_000_000_000_000n);
33
33
 
34
- const svmTx = w0.svm.transfer({ to: String(w1.svm.publicKey), amount: 5000n });
34
+ const svmTx = w0.svm.buildTransferPayload({ to: String(w1.svm.publicKey), amount: 5000n });
35
35
  assert.ok(svmTx);
36
36
 
37
37
  await ws.lock();
38
38
  });
39
39
 
40
- test("transfer() — EVM ERC-20 by contract address", async () => {
40
+ test("buildTransferPayload() —EVM ERC-20 by contract address", async () => {
41
41
  const { ws, w0, w1 } = await twoWallets();
42
- const tx = w0.evm.transfer({ to: String(w1.evm.publicKey), asset: { address: USDC_EVM }, amount: 1_000_000n });
42
+ const tx = w0.evm.buildTransferPayload({ to: String(w1.evm.publicKey), asset: { address: USDC_EVM }, amount: 1_000_000n });
43
43
 
44
44
  assert.strictEqual(String(tx.to).toLowerCase(), USDC_EVM.toLowerCase());
45
45
  assert.strictEqual(tx.value, 0n);
@@ -49,9 +49,9 @@ test("transfer() — EVM ERC-20 by contract address", async () => {
49
49
  await ws.lock();
50
50
  });
51
51
 
52
- test("transfer() — SVM SPL by mint prepends an idempotent recipient-ATA create", async () => {
52
+ test("buildTransferPayload() —SVM SPL by mint prepends an idempotent recipient-ATA create", async () => {
53
53
  const { ws, w0, w1 } = await twoWallets();
54
- const tx = w0.svm.transfer({ to: String(w1.svm.publicKey), asset: { address: USDC_SVM_MINT }, amount: 1_000_000n });
54
+ const tx = w0.svm.buildTransferPayload({ to: String(w1.svm.publicKey), asset: { address: USDC_SVM_MINT }, amount: 1_000_000n });
55
55
 
56
56
  assert.ok(Array.isArray(tx.instructions));
57
57
  assert.strictEqual(tx.instructions.length, 2);
@@ -59,23 +59,23 @@ test("transfer() — SVM SPL by mint prepends an idempotent recipient-ATA create
59
59
  await ws.lock();
60
60
  });
61
61
 
62
- test("transfer() — by token symbol resolves to native vs token", async () => {
62
+ test("buildTransferPayload() —by token symbol resolves to native vs token", async () => {
63
63
  const { ws, w0, w1 } = await twoWallets();
64
64
 
65
- const usdc = w0.evm.transfer({ to: String(w1.evm.publicKey), asset: { symbol: "USDC" }, amount: 1_000_000n });
65
+ const usdc = w0.evm.buildTransferPayload({ to: String(w1.evm.publicKey), asset: { symbol: "USDC" }, amount: 1_000_000n });
66
66
  assert.strictEqual(String(usdc.data).slice(0, 10), "0xa9059cbb");
67
67
 
68
- const eth = w0.evm.transfer({ to: String(w1.evm.publicKey), asset: { symbol: "ETH" }, amount: 777n });
68
+ const eth = w0.evm.buildTransferPayload({ to: String(w1.evm.publicKey), asset: { symbol: "ETH" }, amount: 777n });
69
69
  assert.strictEqual(eth.value, 777n);
70
70
 
71
71
  await ws.lock();
72
72
  });
73
73
 
74
- test("transfer() — an out-of-range amount is a PARAMETER_ERROR", async () => {
74
+ test("buildTransferPayload() —an out-of-range amount is a PARAMETER_ERROR", async () => {
75
75
  const { ws, w0, w1 } = await twoWallets();
76
76
  let code;
77
77
  try {
78
- w0.evm.transfer({ to: String(w1.evm.publicKey), asset: { address: USDC_EVM }, amount: -1n });
78
+ w0.evm.buildTransferPayload({ to: String(w1.evm.publicKey), asset: { address: USDC_EVM }, amount: -1n });
79
79
  } catch (e) {
80
80
  code = e.code;
81
81
  }
@@ -50,8 +50,8 @@ All tests work fully offline — no RPC calls, no real networks. Each test creat
50
50
  | [17-locked-state.test.cjs](17-locked-state.test.cjs) | What locking enforces — which operations refuse and with which error code, that a locked account holds no mnemonic in the clear, and that unlocking restores identical behaviour. |
51
51
  | [18-envelope-v3.test.cjs](18-envelope-v3.test.cjs) | `HybridProviderV3` — writing a workspace that derives one key for the whole workspace instead of one per stored secret, reopening it, and confirming a wrong password is still refused. |
52
52
  | [19-simple-provider.test.cjs](19-simple-provider.test.cjs) | The short way to write a storage backend — extend `ContainerProvider` and implement six methods that move bytes. Runs a whole workspace on a `Map`, signs from a derived address, reopens it, and checks that nothing readable reaches the store. |
53
- | [20-custom-chain-dialect.test.cjs](20-custom-chain-dialect.test.cjs) | Adding a whole new blockchain — subclass `ChainDialect` and `registerDialect` its vm, the same shape as extending `Provider`. A fictional `xvm` chain becomes a first-class network (and an unregistered vm is still refused), its dialect signs / builds a transaction / transfers / derives through the keyless `ChainCtx`, and `XvmSigner` names the per-chain signer just as `EvmSigner` / `SvmSigner` do. |
54
- | [21-token-transfer.test.cjs](21-token-transfer.test.cjs) | `address.transfer({ to, asset, amount })` — one intent lowered per chain: native value, EVM ERC-20 by contract address, SVM SPL by mint (with an idempotent recipient-ATA create), and by token `symbol`. All built offline; `amount` is raw base units. |
53
+ | [20-custom-chain-dialect.test.cjs](20-custom-chain-dialect.test.cjs) | Adding a whole new blockchain — subclass `ChainDialect` and `registerDialect` its vm, the same shape as extending `Provider`. A fictional `xvm` chain becomes a first-class network (and an unregistered vm is still refused), its dialect signs / builds a transaction / builds transfer payloads / derives through the keyless `ChainCtx`, and `XvmSigner` names the per-chain signer just as `EvmSigner` / `SvmSigner` do. |
54
+ | [21-token-transfer.test.cjs](21-token-transfer.test.cjs) | `address.buildTransferPayload({ to, asset, amount })` — one intent lowered per chain into the payload for `buildTransaction`: native value, EVM ERC-20 by contract address, SVM SPL by mint (with an idempotent recipient-ATA create), and by token `symbol`. Payload only (does not send); `amount` is raw base units. |
55
55
 
56
56
  ## Adapting for your project
57
57
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wative-core",
3
- "version": "2.5.0",
3
+ "version": "2.5.2",
4
4
  "description": "Hyperscale crypto wallet management library — multi-workspace, multi-chain, originally designed for on-chain market makers",
5
5
  "type": "module",
6
6
  "main": "./dist/index.node.cjs",