@kynesyslabs/demosdk 4.0.12 → 4.0.13

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 (66) hide show
  1. package/build/websdk/DemosTransactions.d.ts +2 -2
  2. package/build/websdk/DemosTransactions.js +3 -3
  3. package/build/websdk/demosclass.d.ts +81 -1
  4. package/build/websdk/demosclass.js +84 -1
  5. package/build/websdk/demosclass.js.map +1 -1
  6. package/build/websdk/index.d.ts +1 -0
  7. package/build/websdk/index.js +3 -0
  8. package/build/websdk/index.js.map +1 -1
  9. package/build/websdk/programmatic/ProgrammaticTx.d.ts +118 -0
  10. package/build/websdk/programmatic/ProgrammaticTx.js +56 -0
  11. package/build/websdk/programmatic/ProgrammaticTx.js.map +1 -0
  12. package/build/websdk/programmatic/attest.d.ts +396 -0
  13. package/build/websdk/programmatic/attest.js +398 -0
  14. package/build/websdk/programmatic/attest.js.map +1 -0
  15. package/build/websdk/programmatic/bridge.d.ts +36 -0
  16. package/build/websdk/programmatic/bridge.js +37 -0
  17. package/build/websdk/programmatic/bridge.js.map +1 -0
  18. package/build/websdk/programmatic/context.d.ts +26 -0
  19. package/build/websdk/programmatic/context.js +9 -0
  20. package/build/websdk/programmatic/context.js.map +1 -0
  21. package/build/websdk/programmatic/contracts.d.ts +79 -0
  22. package/build/websdk/programmatic/contracts.js +81 -0
  23. package/build/websdk/programmatic/contracts.js.map +1 -0
  24. package/build/websdk/programmatic/d402.d.ts +33 -0
  25. package/build/websdk/programmatic/d402.js +35 -0
  26. package/build/websdk/programmatic/d402.js.map +1 -0
  27. package/build/websdk/programmatic/demoswork.d.ts +37 -0
  28. package/build/websdk/programmatic/demoswork.js +38 -0
  29. package/build/websdk/programmatic/demoswork.js.map +1 -0
  30. package/build/websdk/programmatic/errors.d.ts +20 -0
  31. package/build/websdk/programmatic/errors.js +24 -0
  32. package/build/websdk/programmatic/errors.js.map +1 -0
  33. package/build/websdk/programmatic/escrow.d.ts +75 -0
  34. package/build/websdk/programmatic/escrow.js +74 -0
  35. package/build/websdk/programmatic/escrow.js.map +1 -0
  36. package/build/websdk/programmatic/governance.d.ts +59 -0
  37. package/build/websdk/programmatic/governance.js +44 -0
  38. package/build/websdk/programmatic/governance.js.map +1 -0
  39. package/build/websdk/programmatic/index.d.ts +30 -0
  40. package/build/websdk/programmatic/index.js +31 -0
  41. package/build/websdk/programmatic/index.js.map +1 -0
  42. package/build/websdk/programmatic/ipfs.d.ts +74 -0
  43. package/build/websdk/programmatic/ipfs.js +103 -0
  44. package/build/websdk/programmatic/ipfs.js.map +1 -0
  45. package/build/websdk/programmatic/pay.d.ts +36 -0
  46. package/build/websdk/programmatic/pay.js +37 -0
  47. package/build/websdk/programmatic/pay.js.map +1 -0
  48. package/build/websdk/programmatic/runner.d.ts +30 -0
  49. package/build/websdk/programmatic/runner.js +186 -0
  50. package/build/websdk/programmatic/runner.js.map +1 -0
  51. package/build/websdk/programmatic/storage.d.ts +49 -0
  52. package/build/websdk/programmatic/storage.js +49 -0
  53. package/build/websdk/programmatic/storage.js.map +1 -0
  54. package/build/websdk/programmatic/tokens.d.ts +155 -0
  55. package/build/websdk/programmatic/tokens.js +157 -0
  56. package/build/websdk/programmatic/tokens.js.map +1 -0
  57. package/build/websdk/programmatic/types.d.ts +95 -0
  58. package/build/websdk/programmatic/types.js +8 -0
  59. package/build/websdk/programmatic/types.js.map +1 -0
  60. package/build/websdk/programmatic/validator.d.ts +63 -0
  61. package/build/websdk/programmatic/validator.js +64 -0
  62. package/build/websdk/programmatic/validator.js.map +1 -0
  63. package/build/websdk/programmatic/xm.d.ts +36 -0
  64. package/build/websdk/programmatic/xm.js +37 -0
  65. package/build/websdk/programmatic/xm.js.map +1 -0
  66. package/package.json +1 -1
@@ -0,0 +1,81 @@
1
+ import { DemosContracts } from "../DemosContracts.js";
2
+ /**
3
+ * Smart-contract operations exposed under `demos.run.contracts`.
4
+ *
5
+ * IMPORTANT — these do NOT go through the shared fee-cap runner. Unlike the
6
+ * other `demos.run.*` namespaces, contract deploy/call are **RPC-native**:
7
+ * they execute directly over `demos.rpcCall` and return the contract's own
8
+ * result types (`ContractInstance`, `ContractCallResult`, gas `bigint`),
9
+ * never a {@link ProgrammaticTxResult}. There is no separate
10
+ * `confirm → broadcast` stage here, so {@link ProgrammaticTxOptions}
11
+ * (`maxFee`, `confirm`, `wait`) do not apply.
12
+ *
13
+ * NOTE: like `ipfs.*` and `d402.pay`, the smart-contract path is **not
14
+ * enabled on production nodes yet** — these methods are wired and typed but
15
+ * cannot be exercised end-to-end until the network turns the feature on.
16
+ *
17
+ * The namespace is a thin, uniform surface over {@link DemosContracts};
18
+ * instantiate-free access for callers who want everything under
19
+ * `demos.run.*`.
20
+ */
21
+ export function createContractsNamespace(ctx) {
22
+ const contracts = new DemosContracts(ctx.demos);
23
+ return {
24
+ /**
25
+ * Deploy a smart contract from source. Requires a connected wallet.
26
+ *
27
+ * RPC-native (not fee-capped). Returns the deployed
28
+ * {@link ContractInstance}, not a `ProgrammaticTxResult`.
29
+ *
30
+ * @example
31
+ * ```ts
32
+ * const c = await demos.run.contracts.deploy(source, [arg1, arg2])
33
+ * await demos.run.contracts.call(c.address, "transfer", [to, 100])
34
+ * ```
35
+ *
36
+ * @param source - Contract source code.
37
+ * @param constructorArgs - Constructor arguments (default `[]`).
38
+ * @param options - Deploy options (gas, etc.).
39
+ */
40
+ deploy: (source, constructorArgs, options) => contracts.deploy(source, constructorArgs, options),
41
+ /**
42
+ * Get a handle to an already-deployed contract. Read-only; no tx.
43
+ *
44
+ * @param address - The contract address.
45
+ * @param abi - Optional ABI to type the instance.
46
+ */
47
+ at: (address, abi) => contracts.at(address, abi),
48
+ /**
49
+ * Call a method on an existing contract by address.
50
+ *
51
+ * RPC-native (not fee-capped). Returns the raw
52
+ * {@link ContractCallResult}, not a `ProgrammaticTxResult`.
53
+ *
54
+ * @param contractAddress - Target contract address.
55
+ * @param method - Method name to invoke.
56
+ * @param args - Method arguments (default `[]`).
57
+ * @param options - Call options (gas, etc.).
58
+ */
59
+ call: (contractAddress, method, args, options) => contracts.call(contractAddress, method, args, options),
60
+ /**
61
+ * Deploy a contract from a named template.
62
+ *
63
+ * @param templateName - Registered template name.
64
+ * @param params - Template parameters.
65
+ */
66
+ deployTemplate: (templateName, params) => contracts.deployTemplate(templateName, params),
67
+ /**
68
+ * Estimate gas for a contract call. Read-only; no tx.
69
+ *
70
+ * @param contractAddress - Target contract address.
71
+ * @param method - Method name.
72
+ * @param args - Method arguments (default `[]`).
73
+ */
74
+ estimateGas: (contractAddress, method, args) => contracts.estimateGas(contractAddress, method, args),
75
+ /** Start a batch of deploy/call operations (see {@link DemosContracts.batch}). */
76
+ batch: () => contracts.batch(),
77
+ /** List the available contract template names. */
78
+ getAvailableTemplates: () => contracts.getAvailableTemplates(),
79
+ };
80
+ }
81
+ //# sourceMappingURL=contracts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contracts.js","sourceRoot":"","sources":["../../../../src/websdk/programmatic/contracts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAUlD;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,wBAAwB,CAAC,GAAwB;IAC7D,MAAM,SAAS,GAAG,IAAI,cAAc,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;IAE/C,OAAO;QACH;;;;;;;;;;;;;;;WAeG;QACH,MAAM,EAAE,CACJ,MAAc,EACd,eAA2B,EAC3B,OAA+B,EACN,EAAE,CAC3B,SAAS,CAAC,MAAM,CAAC,MAAM,EAAE,eAAwB,EAAE,OAAO,CAAC;QAE/D;;;;;WAKG;QACH,EAAE,EAAE,CACA,OAAe,EACf,GAAiB,EACW,EAAE,CAAC,SAAS,CAAC,EAAE,CAAI,OAAO,EAAE,GAAG,CAAC;QAEhE;;;;;;;;;;WAUG;QACH,IAAI,EAAE,CACF,eAAuB,EACvB,MAAc,EACd,IAAgB,EAChB,OAA6B,EACC,EAAE,CAChC,SAAS,CAAC,IAAI,CAAI,eAAe,EAAE,MAAM,EAAE,IAAa,EAAE,OAAO,CAAC;QAEtE;;;;;WAKG;QACH,cAAc,EAAE,CACZ,YAAoB,EACpB,MAAgC,EACP,EAAE,CAC3B,SAAS,CAAC,cAAc,CAAC,YAAY,EAAE,MAAM,CAAC;QAElD;;;;;;WAMG;QACH,WAAW,EAAE,CACT,eAAuB,EACvB,MAAc,EACd,IAAgB,EACD,EAAE,CACjB,SAAS,CAAC,WAAW,CAAC,eAAe,EAAE,MAAM,EAAE,IAAa,CAAC;QAEjE,kFAAkF;QAClF,KAAK,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,KAAK,EAAE;QAE9B,kDAAkD;QAClD,qBAAqB,EAAE,GAAa,EAAE,CAClC,SAAS,CAAC,qBAAqB,EAAE;KACxC,CAAA;AACL,CAAC"}
@@ -0,0 +1,33 @@
1
+ import { type D402PaymentRequirement } from "../../d402/client";
2
+ import type { ProgrammaticContext } from "./context";
3
+ import type { ProgrammaticTxOptions, ProgrammaticTxResult } from "./types";
4
+ /**
5
+ * HTTP 402 ("d402") payments as one-call programmatic transactions.
6
+ *
7
+ * Wraps {@link D402Client.createPayment}, which turns the payment
8
+ * requirements from a 402 response into an UNSIGNED `d402_payment`
9
+ * transaction. The method hands a thunk producing that transaction to
10
+ * `ctx.run(...)`, which signs, confirms against the fee ceiling and
11
+ * auto-broadcasts — keeping fee-cap policy, confirmation strategy and result
12
+ * shape uniform with the rest of `demos.run.*`.
13
+ */
14
+ export declare function createD402Namespace(ctx: ProgrammaticContext): {
15
+ /**
16
+ * Settle an HTTP 402 payment requirement, end to end.
17
+ *
18
+ * @example
19
+ * ```ts
20
+ * const res = await fetch("/premium")
21
+ * if (res.status === 402) {
22
+ * const requirement = await res.json()
23
+ * // auto-broadcast within the 5 DEM fee cap:
24
+ * await demos.run.d402.pay(requirement)
25
+ * }
26
+ * ```
27
+ *
28
+ * @param requirement - Payment requirements from the 402 response
29
+ * (amount, recipient, resourceId, description).
30
+ * @param opts - Fee ceiling / confirmation strategy / wait behaviour.
31
+ */
32
+ pay: (requirement: D402PaymentRequirement, opts?: ProgrammaticTxOptions) => Promise<ProgrammaticTxResult>;
33
+ };
@@ -0,0 +1,35 @@
1
+ import { D402Client } from "../../d402/client/index.js";
2
+ /**
3
+ * HTTP 402 ("d402") payments as one-call programmatic transactions.
4
+ *
5
+ * Wraps {@link D402Client.createPayment}, which turns the payment
6
+ * requirements from a 402 response into an UNSIGNED `d402_payment`
7
+ * transaction. The method hands a thunk producing that transaction to
8
+ * `ctx.run(...)`, which signs, confirms against the fee ceiling and
9
+ * auto-broadcasts — keeping fee-cap policy, confirmation strategy and result
10
+ * shape uniform with the rest of `demos.run.*`.
11
+ */
12
+ export function createD402Namespace(ctx) {
13
+ const client = new D402Client(ctx.demos);
14
+ return {
15
+ /**
16
+ * Settle an HTTP 402 payment requirement, end to end.
17
+ *
18
+ * @example
19
+ * ```ts
20
+ * const res = await fetch("/premium")
21
+ * if (res.status === 402) {
22
+ * const requirement = await res.json()
23
+ * // auto-broadcast within the 5 DEM fee cap:
24
+ * await demos.run.d402.pay(requirement)
25
+ * }
26
+ * ```
27
+ *
28
+ * @param requirement - Payment requirements from the 402 response
29
+ * (amount, recipient, resourceId, description).
30
+ * @param opts - Fee ceiling / confirmation strategy / wait behaviour.
31
+ */
32
+ pay: (requirement, opts) => ctx.run(() => client.createPayment(requirement), opts),
33
+ };
34
+ }
35
+ //# sourceMappingURL=d402.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"d402.js","sourceRoot":"","sources":["../../../../src/websdk/programmatic/d402.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAA+B,MAAM,eAAe,CAAA;AAIvE;;;;;;;;;GASG;AACH,MAAM,UAAU,mBAAmB,CAAC,GAAwB;IACxD,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;IAExC,OAAO;QACH;;;;;;;;;;;;;;;;WAgBG;QACH,GAAG,EAAE,CACD,WAAmC,EACnC,IAA4B,EACC,EAAE,CAC/B,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,aAAa,CAAC,WAAW,CAAC,EAAE,IAAI,CAAC;KAC7D,CAAA;AACL,CAAC"}
@@ -0,0 +1,37 @@
1
+ import { type DemosWork } from "../../demoswork";
2
+ import type { ProgrammaticContext } from "./context";
3
+ import type { ProgrammaticTxOptions, ProgrammaticTxResult } from "./types";
4
+ /**
5
+ * DemosWork scripts as one-call programmatic transactions.
6
+ *
7
+ * Assembling a {@link DemosWork} (its steps, operations and conditionals) stays
8
+ * with the caller. Once built, this namespace collapses the classic
9
+ * `prepareDemosWorkPayload → confirm → broadcast` flow into a single call that
10
+ * auto-broadcasts within the configured fee ceiling.
11
+ */
12
+ export declare function createDemosworkNamespace(ctx: ProgrammaticContext): {
13
+ /**
14
+ * Submit an assembled {@link DemosWork} script as a `demoswork`
15
+ * transaction, end to end.
16
+ *
17
+ * `prepareDemosWorkPayload` serialises and signs the work; the shared
18
+ * runner then confirms it and (in `"auto"` mode) broadcasts it within
19
+ * the fee cap.
20
+ *
21
+ * @example
22
+ * ```ts
23
+ * import { DemosWork } from "@kynesyslabs/demosdk"
24
+ * const work = new DemosWork()
25
+ * // ... push steps / operations onto `work` ...
26
+ * // auto-broadcast within the fee cap:
27
+ * await demos.run.demoswork.submit(work)
28
+ * // build + confirm only, broadcast later yourself:
29
+ * const r = await demos.run.demoswork.submit(work, { confirm: "manual" })
30
+ * await demos.broadcast(r.validityData)
31
+ * ```
32
+ *
33
+ * @param work - The assembled DemosWork script to execute.
34
+ * @param opts - Fee ceiling / confirmation strategy / wait behaviour.
35
+ */
36
+ submit: (work: DemosWork, opts?: ProgrammaticTxOptions) => Promise<ProgrammaticTxResult>;
37
+ };
@@ -0,0 +1,38 @@
1
+ import { prepareDemosWorkPayload } from "../../demoswork/index.js";
2
+ /**
3
+ * DemosWork scripts as one-call programmatic transactions.
4
+ *
5
+ * Assembling a {@link DemosWork} (its steps, operations and conditionals) stays
6
+ * with the caller. Once built, this namespace collapses the classic
7
+ * `prepareDemosWorkPayload → confirm → broadcast` flow into a single call that
8
+ * auto-broadcasts within the configured fee ceiling.
9
+ */
10
+ export function createDemosworkNamespace(ctx) {
11
+ return {
12
+ /**
13
+ * Submit an assembled {@link DemosWork} script as a `demoswork`
14
+ * transaction, end to end.
15
+ *
16
+ * `prepareDemosWorkPayload` serialises and signs the work; the shared
17
+ * runner then confirms it and (in `"auto"` mode) broadcasts it within
18
+ * the fee cap.
19
+ *
20
+ * @example
21
+ * ```ts
22
+ * import { DemosWork } from "@kynesyslabs/demosdk"
23
+ * const work = new DemosWork()
24
+ * // ... push steps / operations onto `work` ...
25
+ * // auto-broadcast within the fee cap:
26
+ * await demos.run.demoswork.submit(work)
27
+ * // build + confirm only, broadcast later yourself:
28
+ * const r = await demos.run.demoswork.submit(work, { confirm: "manual" })
29
+ * await demos.broadcast(r.validityData)
30
+ * ```
31
+ *
32
+ * @param work - The assembled DemosWork script to execute.
33
+ * @param opts - Fee ceiling / confirmation strategy / wait behaviour.
34
+ */
35
+ submit: (work, opts) => ctx.run(() => prepareDemosWorkPayload(work, ctx.demos), opts),
36
+ };
37
+ }
38
+ //# sourceMappingURL=demoswork.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"demoswork.js","sourceRoot":"","sources":["../../../../src/websdk/programmatic/demoswork.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,uBAAuB,EAAE,MAAM,aAAa,CAAA;AAIrE;;;;;;;GAOG;AACH,MAAM,UAAU,wBAAwB,CAAC,GAAwB;IAC7D,OAAO;QACH;;;;;;;;;;;;;;;;;;;;;;WAsBG;QACH,MAAM,EAAE,CACJ,IAAe,EACf,IAA4B,EACC,EAAE,CAC/B,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,uBAAuB,CAAC,IAAI,EAAE,GAAG,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC;KACpE,CAAA;AACL,CAAC"}
@@ -0,0 +1,20 @@
1
+ import type { TxConfirmInfo } from "./types";
2
+ /**
3
+ * Thrown by the programmatic-tx runner when a transaction's confirmed fee
4
+ * exceeds the configured ceiling (`maxFee`, default 5 DEM) and the caller
5
+ * did not supply a confirmation callback to override the decision.
6
+ *
7
+ * The transaction has been *built, signed and confirmed* by the time this
8
+ * throws — it simply was NOT broadcast. Callers can catch this, inspect
9
+ * `info.validityData`, and either raise `maxFee` or re-run with an explicit
10
+ * `confirm` callback.
11
+ */
12
+ export declare class FeeCapExceededError extends Error {
13
+ /** Total confirmed fee, in OS (smallest unit). */
14
+ readonly feeOs: bigint;
15
+ /** Configured ceiling, in OS. */
16
+ readonly capOs: bigint;
17
+ /** The confirmation context (transaction, validityData, fee breakdown). */
18
+ readonly info: TxConfirmInfo;
19
+ constructor(feeOs: bigint, capOs: bigint, info: TxConfirmInfo);
20
+ }
@@ -0,0 +1,24 @@
1
+ import { osToDem } from "../../denomination/index.js";
2
+ /**
3
+ * Thrown by the programmatic-tx runner when a transaction's confirmed fee
4
+ * exceeds the configured ceiling (`maxFee`, default 5 DEM) and the caller
5
+ * did not supply a confirmation callback to override the decision.
6
+ *
7
+ * The transaction has been *built, signed and confirmed* by the time this
8
+ * throws — it simply was NOT broadcast. Callers can catch this, inspect
9
+ * `info.validityData`, and either raise `maxFee` or re-run with an explicit
10
+ * `confirm` callback.
11
+ */
12
+ export class FeeCapExceededError extends Error {
13
+ constructor(feeOs, capOs, info) {
14
+ super(`[programmatic-tx] fee ${osToDem(feeOs)} DEM exceeds the ` +
15
+ `maxFee ceiling of ${osToDem(capOs)} DEM; transaction was ` +
16
+ `signed and confirmed but NOT broadcast. Raise 'maxFee' or ` +
17
+ `pass a 'confirm' callback to override.`);
18
+ this.name = "FeeCapExceededError";
19
+ this.feeOs = feeOs;
20
+ this.capOs = capOs;
21
+ this.info = info;
22
+ }
23
+ }
24
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../../src/websdk/programmatic/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAGxC;;;;;;;;;GASG;AACH,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IAQ1C,YAAY,KAAa,EAAE,KAAa,EAAE,IAAmB;QACzD,KAAK,CACD,yBAAyB,OAAO,CAAC,KAAK,CAAC,mBAAmB;YACtD,qBAAqB,OAAO,CAAC,KAAK,CAAC,wBAAwB;YAC3D,4DAA4D;YAC5D,wCAAwC,CAC/C,CAAA;QACD,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAA;QACjC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QAClB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QAClB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IACpB,CAAC;CACJ"}
@@ -0,0 +1,75 @@
1
+ import type { ProgrammaticContext } from "./context";
2
+ import type { ProgrammaticTxOptions, ProgrammaticTxResult } from "./types";
3
+ /**
4
+ * Social-identity escrow as one-call programmatic transactions.
5
+ *
6
+ * Wraps the static {@link EscrowTransaction} builders so sending DEM to an
7
+ * unclaimed social identity, claiming it, or refunding an expired escrow
8
+ * collapses the classic `build/sign → confirm → broadcast` flow into a
9
+ * single call. Each builder here returns a SIGNED transaction; the method
10
+ * hands a thunk producing it to `ctx.run(...)`, which confirms against the
11
+ * fee ceiling and auto-broadcasts — keeping fee-cap policy, confirmation
12
+ * strategy and result shape uniform with the rest of `demos.run.*`.
13
+ */
14
+ export declare function createEscrowNamespace(ctx: ProgrammaticContext): {
15
+ /**
16
+ * Send DEM to a social-identity escrow, end to end.
17
+ *
18
+ * P4 dual-input amount: `bigint` OS (preferred) or `number` DEM
19
+ * (legacy, auto-converted). Sub-DEM precision against a pre-fork
20
+ * node throws.
21
+ *
22
+ * @example
23
+ * ```ts
24
+ * import { denomination } from "@kynesyslabs/demosdk"
25
+ * // auto-broadcast within the 5 DEM fee cap:
26
+ * await demos.run.escrow.send(
27
+ * "twitter", "@bob", denomination.demToOs(100),
28
+ * { expiryDays: 30, message: "Welcome to Demos!" },
29
+ * )
30
+ * // build + confirm only, broadcast later yourself:
31
+ * const r = await demos.run.escrow.send(
32
+ * "twitter", "@bob", 100n, undefined, { confirm: "manual" },
33
+ * )
34
+ * await demos.broadcast(r.validityData)
35
+ * ```
36
+ *
37
+ * @param platform - Social platform ("twitter", "github", "telegram").
38
+ * @param username - Username on that platform (e.g., "@bob").
39
+ * @param amount - DEM `number` (legacy) or OS `bigint` (preferred).
40
+ * @param options - Optional escrow parameters (expiry, memo).
41
+ * @param opts - Fee ceiling / confirmation strategy / wait behaviour.
42
+ */
43
+ send: (platform: "twitter" | "github" | "telegram", username: string, amount: number | bigint, options?: {
44
+ expiryDays?: number;
45
+ message?: string;
46
+ }, opts?: ProgrammaticTxOptions) => Promise<ProgrammaticTxResult>;
47
+ /**
48
+ * Claim escrowed funds for a social identity you have linked, end to
49
+ * end.
50
+ *
51
+ * @example
52
+ * ```ts
53
+ * await demos.run.escrow.claim("twitter", "@bob")
54
+ * ```
55
+ *
56
+ * @param platform - Social platform ("twitter", "github", "telegram").
57
+ * @param username - Username to claim for.
58
+ * @param opts - Fee ceiling / confirmation strategy / wait behaviour.
59
+ */
60
+ claim: (platform: "twitter" | "github" | "telegram", username: string, opts?: ProgrammaticTxOptions) => Promise<ProgrammaticTxResult>;
61
+ /**
62
+ * Refund an expired escrow back to the original depositor, end to
63
+ * end.
64
+ *
65
+ * @example
66
+ * ```ts
67
+ * await demos.run.escrow.refund("twitter", "@unclaimed_user")
68
+ * ```
69
+ *
70
+ * @param platform - Social platform ("twitter", "github", "telegram").
71
+ * @param username - Username whose expired escrow to refund.
72
+ * @param opts - Fee ceiling / confirmation strategy / wait behaviour.
73
+ */
74
+ refund: (platform: "twitter" | "github" | "telegram", username: string, opts?: ProgrammaticTxOptions) => Promise<ProgrammaticTxResult>;
75
+ };
@@ -0,0 +1,74 @@
1
+ import { EscrowTransaction } from "../../escrow/index.js";
2
+ /**
3
+ * Social-identity escrow as one-call programmatic transactions.
4
+ *
5
+ * Wraps the static {@link EscrowTransaction} builders so sending DEM to an
6
+ * unclaimed social identity, claiming it, or refunding an expired escrow
7
+ * collapses the classic `build/sign → confirm → broadcast` flow into a
8
+ * single call. Each builder here returns a SIGNED transaction; the method
9
+ * hands a thunk producing it to `ctx.run(...)`, which confirms against the
10
+ * fee ceiling and auto-broadcasts — keeping fee-cap policy, confirmation
11
+ * strategy and result shape uniform with the rest of `demos.run.*`.
12
+ */
13
+ export function createEscrowNamespace(ctx) {
14
+ return {
15
+ /**
16
+ * Send DEM to a social-identity escrow, end to end.
17
+ *
18
+ * P4 dual-input amount: `bigint` OS (preferred) or `number` DEM
19
+ * (legacy, auto-converted). Sub-DEM precision against a pre-fork
20
+ * node throws.
21
+ *
22
+ * @example
23
+ * ```ts
24
+ * import { denomination } from "@kynesyslabs/demosdk"
25
+ * // auto-broadcast within the 5 DEM fee cap:
26
+ * await demos.run.escrow.send(
27
+ * "twitter", "@bob", denomination.demToOs(100),
28
+ * { expiryDays: 30, message: "Welcome to Demos!" },
29
+ * )
30
+ * // build + confirm only, broadcast later yourself:
31
+ * const r = await demos.run.escrow.send(
32
+ * "twitter", "@bob", 100n, undefined, { confirm: "manual" },
33
+ * )
34
+ * await demos.broadcast(r.validityData)
35
+ * ```
36
+ *
37
+ * @param platform - Social platform ("twitter", "github", "telegram").
38
+ * @param username - Username on that platform (e.g., "@bob").
39
+ * @param amount - DEM `number` (legacy) or OS `bigint` (preferred).
40
+ * @param options - Optional escrow parameters (expiry, memo).
41
+ * @param opts - Fee ceiling / confirmation strategy / wait behaviour.
42
+ */
43
+ send: (platform, username, amount, options, opts) => ctx.run(() => EscrowTransaction.sendToIdentity(ctx.demos, platform, username, amount, options), opts),
44
+ /**
45
+ * Claim escrowed funds for a social identity you have linked, end to
46
+ * end.
47
+ *
48
+ * @example
49
+ * ```ts
50
+ * await demos.run.escrow.claim("twitter", "@bob")
51
+ * ```
52
+ *
53
+ * @param platform - Social platform ("twitter", "github", "telegram").
54
+ * @param username - Username to claim for.
55
+ * @param opts - Fee ceiling / confirmation strategy / wait behaviour.
56
+ */
57
+ claim: (platform, username, opts) => ctx.run(() => EscrowTransaction.claimEscrow(ctx.demos, platform, username), opts),
58
+ /**
59
+ * Refund an expired escrow back to the original depositor, end to
60
+ * end.
61
+ *
62
+ * @example
63
+ * ```ts
64
+ * await demos.run.escrow.refund("twitter", "@unclaimed_user")
65
+ * ```
66
+ *
67
+ * @param platform - Social platform ("twitter", "github", "telegram").
68
+ * @param username - Username whose expired escrow to refund.
69
+ * @param opts - Fee ceiling / confirmation strategy / wait behaviour.
70
+ */
71
+ refund: (platform, username, opts) => ctx.run(() => EscrowTransaction.refundExpiredEscrow(ctx.demos, platform, username), opts),
72
+ };
73
+ }
74
+ //# sourceMappingURL=escrow.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"escrow.js","sourceRoot":"","sources":["../../../../src/websdk/programmatic/escrow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA;AAI5C;;;;;;;;;;GAUG;AACH,MAAM,UAAU,qBAAqB,CAAC,GAAwB;IAC1D,OAAO;QACH;;;;;;;;;;;;;;;;;;;;;;;;;;;WA2BG;QACH,IAAI,EAAE,CACF,QAA2C,EAC3C,QAAgB,EAChB,MAAuB,EACvB,OAGC,EACD,IAA4B,EACC,EAAE,CAC/B,GAAG,CAAC,GAAG,CACH,GAAG,EAAE,CACD,iBAAiB,CAAC,cAAc,CAC5B,GAAG,CAAC,KAAK,EACT,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,OAAO,CACV,EACL,IAAI,CACP;QAEL;;;;;;;;;;;;WAYG;QACH,KAAK,EAAE,CACH,QAA2C,EAC3C,QAAgB,EAChB,IAA4B,EACC,EAAE,CAC/B,GAAG,CAAC,GAAG,CACH,GAAG,EAAE,CACD,iBAAiB,CAAC,WAAW,CACzB,GAAG,CAAC,KAAK,EACT,QAAQ,EACR,QAAQ,CACX,EACL,IAAI,CACP;QAEL;;;;;;;;;;;;WAYG;QACH,MAAM,EAAE,CACJ,QAA2C,EAC3C,QAAgB,EAChB,IAA4B,EACC,EAAE,CAC/B,GAAG,CAAC,GAAG,CACH,GAAG,EAAE,CACD,iBAAiB,CAAC,mBAAmB,CACjC,GAAG,CAAC,KAAK,EACT,QAAQ,EACR,QAAQ,CACX,EACL,IAAI,CACP;KACR,CAAA;AACL,CAAC"}
@@ -0,0 +1,59 @@
1
+ import type { NetworkParameters } from "../../types/blockchain/NetworkParameters";
2
+ import type { ProgrammaticContext } from "./context";
3
+ import type { ProgrammaticTxOptions, ProgrammaticTxResult } from "./types";
4
+ /**
5
+ * Parameters for a network-upgrade proposal.
6
+ *
7
+ * Mirrors the object accepted by `DemosTransactions.proposeNetworkUpgrade`.
8
+ */
9
+ export interface ProposeNetworkUpgradeParams {
10
+ /** UUID. Also used as lexicographic activation-order tiebreaker. */
11
+ proposalId: string;
12
+ /** Subset of {@link NetworkParameters} to change. */
13
+ proposedParameters: Partial<NetworkParameters>;
14
+ /** Human-readable reason, ≤1024 bytes. */
15
+ rationale: string;
16
+ /** Activation block. Must be ≥ tallyBlock + grace period. */
17
+ effectiveAtBlock: number;
18
+ }
19
+ /**
20
+ * On-chain governance (network upgrades) as one-call programmatic transactions.
21
+ *
22
+ * Collapses the classic `build → confirm → broadcast` flow for proposing and
23
+ * voting on network upgrades into a single call that auto-broadcasts within
24
+ * the configured fee ceiling.
25
+ */
26
+ export declare function createGovernanceNamespace(ctx: ProgrammaticContext): {
27
+ /**
28
+ * Submit a network-upgrade proposal, end to end.
29
+ *
30
+ * @example
31
+ * ```ts
32
+ * await demos.run.governance.propose({
33
+ * proposalId: crypto.randomUUID(),
34
+ * proposedParameters: { blockTimeMs: 5000 },
35
+ * rationale: "Reduce block time for lower latency.",
36
+ * effectiveAtBlock: 1_000_000,
37
+ * })
38
+ * ```
39
+ *
40
+ * @param params - Proposal fields (id, parameters, rationale, activation block).
41
+ * @param opts - Fee ceiling / confirmation strategy / wait behaviour.
42
+ */
43
+ propose: (params: ProposeNetworkUpgradeParams, opts?: ProgrammaticTxOptions) => Promise<ProgrammaticTxResult>;
44
+ /**
45
+ * Cast a vote on a pending network-upgrade proposal, end to end. The
46
+ * vote is final and non-revocable.
47
+ *
48
+ * @example
49
+ * ```ts
50
+ * await demos.run.governance.vote(proposalId, true) // yes
51
+ * await demos.run.governance.vote(proposalId, false) // no
52
+ * ```
53
+ *
54
+ * @param proposalId - The proposal to vote on.
55
+ * @param approve - `true` to approve, `false` to reject.
56
+ * @param opts - Fee ceiling / confirmation strategy / wait behaviour.
57
+ */
58
+ vote: (proposalId: string, approve: boolean, opts?: ProgrammaticTxOptions) => Promise<ProgrammaticTxResult>;
59
+ };
@@ -0,0 +1,44 @@
1
+ /**
2
+ * On-chain governance (network upgrades) as one-call programmatic transactions.
3
+ *
4
+ * Collapses the classic `build → confirm → broadcast` flow for proposing and
5
+ * voting on network upgrades into a single call that auto-broadcasts within
6
+ * the configured fee ceiling.
7
+ */
8
+ export function createGovernanceNamespace(ctx) {
9
+ return {
10
+ /**
11
+ * Submit a network-upgrade proposal, end to end.
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * await demos.run.governance.propose({
16
+ * proposalId: crypto.randomUUID(),
17
+ * proposedParameters: { blockTimeMs: 5000 },
18
+ * rationale: "Reduce block time for lower latency.",
19
+ * effectiveAtBlock: 1_000_000,
20
+ * })
21
+ * ```
22
+ *
23
+ * @param params - Proposal fields (id, parameters, rationale, activation block).
24
+ * @param opts - Fee ceiling / confirmation strategy / wait behaviour.
25
+ */
26
+ propose: (params, opts) => ctx.run(() => ctx.demos.tx.proposeNetworkUpgrade(params, ctx.demos), opts),
27
+ /**
28
+ * Cast a vote on a pending network-upgrade proposal, end to end. The
29
+ * vote is final and non-revocable.
30
+ *
31
+ * @example
32
+ * ```ts
33
+ * await demos.run.governance.vote(proposalId, true) // yes
34
+ * await demos.run.governance.vote(proposalId, false) // no
35
+ * ```
36
+ *
37
+ * @param proposalId - The proposal to vote on.
38
+ * @param approve - `true` to approve, `false` to reject.
39
+ * @param opts - Fee ceiling / confirmation strategy / wait behaviour.
40
+ */
41
+ vote: (proposalId, approve, opts) => ctx.run(() => ctx.demos.tx.voteOnUpgrade(proposalId, approve, ctx.demos), opts),
42
+ };
43
+ }
44
+ //# sourceMappingURL=governance.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"governance.js","sourceRoot":"","sources":["../../../../src/websdk/programmatic/governance.ts"],"names":[],"mappings":"AAoBA;;;;;;GAMG;AACH,MAAM,UAAU,yBAAyB,CAAC,GAAwB;IAC9D,OAAO;QACH;;;;;;;;;;;;;;;WAeG;QACH,OAAO,EAAE,CACL,MAAmC,EACnC,IAA4B,EACC,EAAE,CAC/B,GAAG,CAAC,GAAG,CACH,GAAG,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,qBAAqB,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,CAAC,EAC3D,IAAI,CACP;QAEL;;;;;;;;;;;;;WAaG;QACH,IAAI,EAAE,CACF,UAAkB,EAClB,OAAgB,EAChB,IAA4B,EACC,EAAE,CAC/B,GAAG,CAAC,GAAG,CACH,GAAG,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,aAAa,CAAC,UAAU,EAAE,OAAO,EAAE,GAAG,CAAC,KAAK,CAAC,EAChE,IAAI,CACP;KACR,CAAA;AACL,CAAC"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Programmatic transaction system.
3
+ *
4
+ * A single one-call method per transaction type that fills parameters from
5
+ * arguments and routes through one shared runner (`build → sign → confirm →
6
+ * broadcast`). Auto-broadcasts within a configurable fee ceiling (default
7
+ * 5 DEM); supports a `"manual"` confirm mode that returns the validity data
8
+ * unbroadcast (the classic flow), and a callback mode for custom
9
+ * confirmation.
10
+ *
11
+ * Reached via `demos.run.*` on a connected {@link Demos} instance.
12
+ */
13
+ export * from "./types";
14
+ export * from "./errors";
15
+ export * from "./runner";
16
+ export * from "./context";
17
+ export * from "./pay";
18
+ export * from "./attest";
19
+ export * from "./tokens";
20
+ export * from "./storage";
21
+ export * from "./escrow";
22
+ export * from "./validator";
23
+ export * from "./governance";
24
+ export * from "./xm";
25
+ export * from "./bridge";
26
+ export * from "./demoswork";
27
+ export * from "./ipfs";
28
+ export * from "./d402";
29
+ export * from "./contracts";
30
+ export * from "./ProgrammaticTx";
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Programmatic transaction system.
3
+ *
4
+ * A single one-call method per transaction type that fills parameters from
5
+ * arguments and routes through one shared runner (`build → sign → confirm →
6
+ * broadcast`). Auto-broadcasts within a configurable fee ceiling (default
7
+ * 5 DEM); supports a `"manual"` confirm mode that returns the validity data
8
+ * unbroadcast (the classic flow), and a callback mode for custom
9
+ * confirmation.
10
+ *
11
+ * Reached via `demos.run.*` on a connected {@link Demos} instance.
12
+ */
13
+ export * from "./types.js";
14
+ export * from "./errors.js";
15
+ export * from "./runner.js";
16
+ export * from "./context.js";
17
+ export * from "./pay.js";
18
+ export * from "./attest.js";
19
+ export * from "./tokens.js";
20
+ export * from "./storage.js";
21
+ export * from "./escrow.js";
22
+ export * from "./validator.js";
23
+ export * from "./governance.js";
24
+ export * from "./xm.js";
25
+ export * from "./bridge.js";
26
+ export * from "./demoswork.js";
27
+ export * from "./ipfs.js";
28
+ export * from "./d402.js";
29
+ export * from "./contracts.js";
30
+ export * from "./ProgrammaticTx.js";
31
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/websdk/programmatic/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA;AACxB,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,OAAO,CAAA;AACrB,cAAc,UAAU,CAAA;AACxB,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,UAAU,CAAA;AACxB,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,cAAc,MAAM,CAAA;AACpB,cAAc,UAAU,CAAA;AACxB,cAAc,aAAa,CAAA;AAC3B,cAAc,QAAQ,CAAA;AACtB,cAAc,QAAQ,CAAA;AACtB,cAAc,aAAa,CAAA;AAC3B,cAAc,kBAAkB,CAAA"}