@arxiumlabs/sdk 0.13.1 → 0.14.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.
package/README.md CHANGED
@@ -147,6 +147,10 @@ const dry = await rpc.simulateModule(address, { caller, input, gasLimit: gas });
147
147
 
148
148
  Only an attested account can deploy. A module holds a regulated asset only if it is attested like any holder, and it pays out only from its own account through the same checks as a transfer (freeze, claims, jurisdiction, caps, locks). Limits per module: 32 KiB of code, 1 KiB per stored value, 16 reads, 16 writes, 16 lookups, 4 transfers per call. A call is priced by its gas limit twice over: execution (one weight per 50 fuel) and the dispute-artifact bytes it could add (15,000 weight per 1,000 fuel, up to a whole block at 64 rows), so a tight limit is cheap and a 1,000,000 limit fills a block. Deploying costs 8 weight per code byte. There is no way to list a module's storage; keep your own index and read it by key.
149
149
 
150
+ Events a module emits (`emit_event`) are kept per block: `rpc.blockEffects(height).module_events` lists each one as a `ModuleEventLine` with the `CallModule`'s `action_index` and `signature`, the `module`, and `topic` and `data` in hex, in the order emitted. A call that traps, runs out of gas or is refused leaves none. `arx query events <height> [module]` prints them. Blocks a node wrote before it kept events return an empty list.
151
+
152
+ Stored state costs a deposit, paid from the **module's own balance** (fund it with an ordinary transfer): each row counts its key, its value and 64 bytes of overhead, times the chain's `module_storage_deposit_per_byte` (`rpc.actionFee()`, 0.001 ARX by default). `moduleStorageDeposit(keyBytes, valueBytes, perByte)` estimates it. A call that grows state the module cannot pay for is refused. Shrinking or deleting rows pays the deposit back to the module at the average price it paid. `rpc.module(address)` shows `storage_bytes` and `storage_deposit` (locked, not spendable).
153
+
150
154
  ### Programmable accounts
151
155
 
152
156
  The SDK exports bounded account-policy codecs and stateful owner/session/guardian witness helpers. `arx multisig build|sign|combine|link` lets each member sign separately, for both immutable and stateful account addresses. To verify a historical action, `verifySignedAction` needs the proven pre-action policy for stateful witnesses, and `arx verify SIGNATURE --policy FILE` accepts that policy. See [the programmable-account guide](../../docs/Programmable_Accounts.md).
package/dist/cli.js CHANGED
@@ -379,8 +379,9 @@ async function main() {
379
379
  : operation === "stakes" ? await rpc.stakes(value ?? throwUsage("stakes needs an address"))
380
380
  : operation === "module" ? await rpc.module(value ?? throwUsage("module needs an address"))
381
381
  : operation === "module-state" ? await rpc.moduleState(value ?? throwUsage("module-state needs <address> <key-hex>"), rest[2] ?? throwUsage("module-state needs <address> <key-hex>"))
382
- : operation === "fee" ? await rpc.actionFee()
383
- : throwUsage("use: arx query status|account|block|action|validators|validator|finality|search|assets [address]|asset|holders|balance|attestors|attestor|stakes|module|module-state|fee");
382
+ : operation === "events" ? (await rpc.blockEffects(/^\d+$/.test(value ?? "") ? Number(value) : throwUsage("events needs <height> [module]"))).module_events.filter((event) => !rest[2] || event.module === rest[2])
383
+ : operation === "fee" ? await rpc.actionFee()
384
+ : throwUsage("use: arx query status|account|block|action|validators|validator|finality|search|assets [address]|asset|holders|balance|attestors|attestor|stakes|module|module-state|events|fee");
384
385
  output(result, globals.json);
385
386
  return;
386
387
  }
package/dist/fees.d.ts CHANGED
@@ -6,8 +6,15 @@ export type FeeParams = {
6
6
  /** Fuel one weight unit pays for (`FUEL_PER_WEIGHT` in `arxd/runtime/src/module.rs`). */
7
7
  export declare const FUEL_PER_WEIGHT = 50;
8
8
  /** Dispute-artifact pricing for module actions (`BLOCK_PROOF_KEYS`, `PROOF_WEIGHT_PER_KEY`, `MODULE_BASE_KEYS`, `DEPLOY_WEIGHT_PER_CODE_BYTE`, `COST_READ` in metering.rs and `xc_wasm`). */
9
- export declare const BLOCK_PROOF_KEYS = 64, PROOF_WEIGHT_PER_KEY = 15000, MODULE_BASE_KEYS = 4, DEPLOY_WEIGHT_PER_CODE_BYTE = 7, COST_READ = 1000;
9
+ export declare const BLOCK_PROOF_KEYS = 64, PROOF_WEIGHT_PER_KEY = 15000, MODULE_BASE_KEYS = 5, DEPLOY_WEIGHT_PER_CODE_BYTE = 7, COST_READ = 1000;
10
10
  /** `POLICY_AUTHORIZATION_WEIGHT`: added when a stateful account policy authorizes the action. */
11
+ /** Bytes a module state row counts for the storage deposit beyond its key and value (`STATE_ROW_OVERHEAD` in module.rs). */
12
+ export declare const STATE_ROW_OVERHEAD = 64;
13
+ /**
14
+ * IUM a module locks from its own balance to store `value` under `key` (or frees, for a row it deletes), at the chain's
15
+ * `module_storage_deposit_per_byte` (`rpc.actionFee()`). A refund is at the average price the module paid, so it can differ.
16
+ */
17
+ export declare const moduleStorageDeposit: (keyBytes: number, valueBytes: number, perByte: bigint) => bigint;
11
18
  export declare const POLICY_AUTHORIZATION_WEIGHT = 5000;
12
19
  /** A single-key ed25519 signature: 64 bytes as hex. */
13
20
  export declare const SINGLE_SIGNATURE_LENGTH = 128;
package/dist/fees.js CHANGED
@@ -28,8 +28,15 @@ const BASE_WEIGHT = {
28
28
  /** Fuel one weight unit pays for (`FUEL_PER_WEIGHT` in `arxd/runtime/src/module.rs`). */
29
29
  export const FUEL_PER_WEIGHT = 50;
30
30
  /** Dispute-artifact pricing for module actions (`BLOCK_PROOF_KEYS`, `PROOF_WEIGHT_PER_KEY`, `MODULE_BASE_KEYS`, `DEPLOY_WEIGHT_PER_CODE_BYTE`, `COST_READ` in metering.rs and `xc_wasm`). */
31
- export const BLOCK_PROOF_KEYS = 64, PROOF_WEIGHT_PER_KEY = 15_000, MODULE_BASE_KEYS = 4, DEPLOY_WEIGHT_PER_CODE_BYTE = 7, COST_READ = 1_000;
31
+ export const BLOCK_PROOF_KEYS = 64, PROOF_WEIGHT_PER_KEY = 15_000, MODULE_BASE_KEYS = 5, DEPLOY_WEIGHT_PER_CODE_BYTE = 7, COST_READ = 1_000;
32
32
  /** `POLICY_AUTHORIZATION_WEIGHT`: added when a stateful account policy authorizes the action. */
33
+ /** Bytes a module state row counts for the storage deposit beyond its key and value (`STATE_ROW_OVERHEAD` in module.rs). */
34
+ export const STATE_ROW_OVERHEAD = 64;
35
+ /**
36
+ * IUM a module locks from its own balance to store `value` under `key` (or frees, for a row it deletes), at the chain's
37
+ * `module_storage_deposit_per_byte` (`rpc.actionFee()`). A refund is at the average price the module paid, so it can differ.
38
+ */
39
+ export const moduleStorageDeposit = (keyBytes, valueBytes, perByte) => BigInt(keyBytes + valueBytes + STATE_ROW_OVERHEAD) * perByte;
33
40
  export const POLICY_AUTHORIZATION_WEIGHT = 5_000;
34
41
  /** A single-key ed25519 signature: 64 bytes as hex. */
35
42
  export const SINGLE_SIGNATURE_LENGTH = 128;
package/dist/rpc.d.ts CHANGED
@@ -208,6 +208,8 @@ export type ModuleInfo = {
208
208
  deployed_at: number;
209
209
  version: number;
210
210
  code_size: number;
211
+ storage_bytes: number;
212
+ storage_deposit: bigint;
211
213
  };
212
214
  /** A collateral pledge as stored (`xc_primitives::Pledge`). `asset` is `"Native"` or `{ Asset: ref }`, the node's JSON for `SpendAsset`. */
213
215
  export type Pledge = {
@@ -241,11 +243,20 @@ export type PledgeEffect = {
241
243
  pledge: string;
242
244
  record: Pledge | null;
243
245
  };
244
- /** `rpc.blockEffects(height)`. `corporate_actions` and `pledges` are typed; the other fields mirror the node's `BlockEffects`. */
246
+ /** One `emit_event` of a module call the block applied (`topic` and `data` are hex). A call that traps or is refused leaves none. */
247
+ export type ModuleEventLine = {
248
+ action_index: number;
249
+ signature: string;
250
+ module: string;
251
+ topic: string;
252
+ data: string;
253
+ };
254
+ /** `rpc.blockEffects(height)`. `corporate_actions`, `pledges` and `module_events` are typed; the other fields mirror the node's `BlockEffects`. */
245
255
  export type BlockEffects = {
246
256
  height: number;
247
257
  corporate_actions: CorporateActionLine[];
248
258
  pledges: PledgeEffect[];
259
+ module_events: ModuleEventLine[];
249
260
  [field: string]: unknown;
250
261
  };
251
262
  export type ActionFeeInfo = {
@@ -253,6 +264,7 @@ export type ActionFeeInfo = {
253
264
  weight_fee: bigint;
254
265
  max_block_weight: number;
255
266
  token_create_fee: bigint;
267
+ module_storage_deposit_per_byte: bigint;
256
268
  };
257
269
  export type { AssetClass };
258
270
  /**
package/dist/rpc.js CHANGED
@@ -20,7 +20,7 @@ export class ActionDroppedError extends Error {
20
20
  }
21
21
  }
22
22
  /** Keys whose integer values are token amounts (u128 on the node): always `bigint`, so callers never see a rounded balance. */
23
- const AMOUNT_KEYS = new Set(["balance", "amount", "stake", "active_amount", "frozen_amount", "total_supply", "max_supply", "max_balance_per_holder", "total", "action_fee", "weight_fee", "token_create_fee", "min_stake", "exposure", "unit_price", "collateral_value", "shortfall"]);
23
+ const AMOUNT_KEYS = new Set(["balance", "amount", "stake", "active_amount", "frozen_amount", "total_supply", "max_supply", "max_balance_per_holder", "total", "action_fee", "weight_fee", "token_create_fee", "min_stake", "exposure", "unit_price", "collateral_value", "shortfall", "storage_deposit", "module_storage_deposit_per_byte"]);
24
24
  const MARK = "\u0000int:";
25
25
  /**
26
26
  * `JSON.parse` that never rounds an integer: the node writes u128 amounts as bare JSON numbers, and anything above 2^53
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arxiumlabs/sdk",
3
- "version": "0.13.1",
3
+ "version": "0.14.0",
4
4
  "description": "Arxium TypeScript SDK and arx CLI",
5
5
  "type": "module",
6
6
  "private": false,