@kynesyslabs/demosdk 4.0.11 → 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 (82) hide show
  1. package/build/abstraction/Identities.js +10 -2
  2. package/build/abstraction/Identities.js.map +1 -1
  3. package/build/l2ps/channel/finalize.d.ts +63 -0
  4. package/build/l2ps/channel/finalize.js +85 -0
  5. package/build/l2ps/channel/finalize.js.map +1 -0
  6. package/build/l2ps/channel/index.d.ts +3 -0
  7. package/build/l2ps/channel/index.js +3 -0
  8. package/build/l2ps/channel/index.js.map +1 -1
  9. package/build/l2ps/channel/negotiate.d.ts +106 -0
  10. package/build/l2ps/channel/negotiate.js +206 -0
  11. package/build/l2ps/channel/negotiate.js.map +1 -0
  12. package/build/l2ps/channel/transport.d.ts +117 -0
  13. package/build/l2ps/channel/transport.js +178 -0
  14. package/build/l2ps/channel/transport.js.map +1 -0
  15. package/build/websdk/BroadcastFailedError.js.map +1 -1
  16. package/build/websdk/DemosTransactions.d.ts +2 -2
  17. package/build/websdk/DemosTransactions.js +3 -3
  18. package/build/websdk/TransportError.js.map +1 -1
  19. package/build/websdk/demosclass.d.ts +81 -1
  20. package/build/websdk/demosclass.js +84 -1
  21. package/build/websdk/demosclass.js.map +1 -1
  22. package/build/websdk/index.d.ts +1 -0
  23. package/build/websdk/index.js +3 -0
  24. package/build/websdk/index.js.map +1 -1
  25. package/build/websdk/programmatic/ProgrammaticTx.d.ts +118 -0
  26. package/build/websdk/programmatic/ProgrammaticTx.js +56 -0
  27. package/build/websdk/programmatic/ProgrammaticTx.js.map +1 -0
  28. package/build/websdk/programmatic/attest.d.ts +396 -0
  29. package/build/websdk/programmatic/attest.js +398 -0
  30. package/build/websdk/programmatic/attest.js.map +1 -0
  31. package/build/websdk/programmatic/bridge.d.ts +36 -0
  32. package/build/websdk/programmatic/bridge.js +37 -0
  33. package/build/websdk/programmatic/bridge.js.map +1 -0
  34. package/build/websdk/programmatic/context.d.ts +26 -0
  35. package/build/websdk/programmatic/context.js +9 -0
  36. package/build/websdk/programmatic/context.js.map +1 -0
  37. package/build/websdk/programmatic/contracts.d.ts +79 -0
  38. package/build/websdk/programmatic/contracts.js +81 -0
  39. package/build/websdk/programmatic/contracts.js.map +1 -0
  40. package/build/websdk/programmatic/d402.d.ts +33 -0
  41. package/build/websdk/programmatic/d402.js +35 -0
  42. package/build/websdk/programmatic/d402.js.map +1 -0
  43. package/build/websdk/programmatic/demoswork.d.ts +37 -0
  44. package/build/websdk/programmatic/demoswork.js +38 -0
  45. package/build/websdk/programmatic/demoswork.js.map +1 -0
  46. package/build/websdk/programmatic/errors.d.ts +20 -0
  47. package/build/websdk/programmatic/errors.js +24 -0
  48. package/build/websdk/programmatic/errors.js.map +1 -0
  49. package/build/websdk/programmatic/escrow.d.ts +75 -0
  50. package/build/websdk/programmatic/escrow.js +74 -0
  51. package/build/websdk/programmatic/escrow.js.map +1 -0
  52. package/build/websdk/programmatic/governance.d.ts +59 -0
  53. package/build/websdk/programmatic/governance.js +44 -0
  54. package/build/websdk/programmatic/governance.js.map +1 -0
  55. package/build/websdk/programmatic/index.d.ts +30 -0
  56. package/build/websdk/programmatic/index.js +31 -0
  57. package/build/websdk/programmatic/index.js.map +1 -0
  58. package/build/websdk/programmatic/ipfs.d.ts +74 -0
  59. package/build/websdk/programmatic/ipfs.js +103 -0
  60. package/build/websdk/programmatic/ipfs.js.map +1 -0
  61. package/build/websdk/programmatic/pay.d.ts +36 -0
  62. package/build/websdk/programmatic/pay.js +37 -0
  63. package/build/websdk/programmatic/pay.js.map +1 -0
  64. package/build/websdk/programmatic/runner.d.ts +30 -0
  65. package/build/websdk/programmatic/runner.js +186 -0
  66. package/build/websdk/programmatic/runner.js.map +1 -0
  67. package/build/websdk/programmatic/storage.d.ts +49 -0
  68. package/build/websdk/programmatic/storage.js +49 -0
  69. package/build/websdk/programmatic/storage.js.map +1 -0
  70. package/build/websdk/programmatic/tokens.d.ts +155 -0
  71. package/build/websdk/programmatic/tokens.js +157 -0
  72. package/build/websdk/programmatic/tokens.js.map +1 -0
  73. package/build/websdk/programmatic/types.d.ts +95 -0
  74. package/build/websdk/programmatic/types.js +8 -0
  75. package/build/websdk/programmatic/types.js.map +1 -0
  76. package/build/websdk/programmatic/validator.d.ts +63 -0
  77. package/build/websdk/programmatic/validator.js +64 -0
  78. package/build/websdk/programmatic/validator.js.map +1 -0
  79. package/build/websdk/programmatic/xm.d.ts +36 -0
  80. package/build/websdk/programmatic/xm.js +37 -0
  81. package/build/websdk/programmatic/xm.js.map +1 -0
  82. package/package.json +1 -1
@@ -0,0 +1,155 @@
1
+ import type { TokenCreationParams, TokenHookType, TokenScriptMethod } from "../../types/token";
2
+ import type { ProgrammaticContext } from "./context";
3
+ import type { ProgrammaticTxOptions, ProgrammaticTxResult } from "./types";
4
+ /**
5
+ * Token creation and execution as one-call programmatic transactions.
6
+ *
7
+ * Wraps {@link DemosTokens} so deploying a token or running a token
8
+ * operation (transfer, approve, mint, burn, …) collapses the classic
9
+ * `build → sign → confirm → broadcast` flow into a single call. Each
10
+ * builder here returns an UNSIGNED transaction; the method hands a thunk
11
+ * producing it to `ctx.run(...)`, which signs, confirms against the fee
12
+ * ceiling and auto-broadcasts — keeping fee-cap policy, confirmation
13
+ * strategy and result shape uniform with the rest of `demos.run.*`.
14
+ *
15
+ * All amounts are bigint-valued decimal strings, mirroring
16
+ * {@link DemosTokens}.
17
+ */
18
+ export declare function createTokensNamespace(ctx: ProgrammaticContext): {
19
+ /**
20
+ * Deploy a new token, end to end.
21
+ *
22
+ * @example
23
+ * ```ts
24
+ * const r = await demos.run.tokens.create({
25
+ * name: "My Token",
26
+ * ticker: "MYT",
27
+ * decimals: 18,
28
+ * initialSupply: "1000000",
29
+ * })
30
+ * console.log(r.transaction.content.to) // derived token address
31
+ * ```
32
+ *
33
+ * @param params - Token creation parameters (name, ticker, decimals,
34
+ * initial supply, optional script/ACL).
35
+ * @param opts - Fee ceiling / confirmation strategy / wait behaviour.
36
+ */
37
+ create: (params: TokenCreationParams, opts?: ProgrammaticTxOptions) => Promise<ProgrammaticTxResult>;
38
+ /**
39
+ * Transfer tokens to another address, end to end.
40
+ *
41
+ * @example
42
+ * ```ts
43
+ * // auto-broadcast within the 5 DEM fee cap:
44
+ * await demos.run.tokens.transfer("0xToken...", "0xTo...", "1000")
45
+ * // build + confirm only, broadcast later yourself:
46
+ * const r = await demos.run.tokens.transfer(
47
+ * "0xToken...", "0xTo...", "1000", { confirm: "manual" },
48
+ * )
49
+ * await demos.broadcast(r.validityData)
50
+ * ```
51
+ *
52
+ * @param tokenAddress - Token contract address.
53
+ * @param to - Recipient address.
54
+ * @param amount - Amount to transfer (bigint-valued decimal string).
55
+ * @param opts - Fee ceiling / confirmation strategy / wait behaviour.
56
+ */
57
+ transfer: (tokenAddress: string, to: string, amount: string, opts?: ProgrammaticTxOptions) => Promise<ProgrammaticTxResult>;
58
+ /**
59
+ * Approve a spender to move tokens on your behalf, end to end.
60
+ *
61
+ * @param tokenAddress - Token contract address.
62
+ * @param spender - Spender address being granted the allowance.
63
+ * @param amount - Amount to approve (bigint-valued decimal string).
64
+ * @param opts - Fee ceiling / confirmation strategy / wait behaviour.
65
+ */
66
+ approve: (tokenAddress: string, spender: string, amount: string, opts?: ProgrammaticTxOptions) => Promise<ProgrammaticTxResult>;
67
+ /**
68
+ * Mint new tokens to an address, end to end.
69
+ *
70
+ * @param tokenAddress - Token contract address.
71
+ * @param to - Recipient of the minted tokens.
72
+ * @param amount - Amount to mint (bigint-valued decimal string).
73
+ * @param opts - Fee ceiling / confirmation strategy / wait behaviour.
74
+ */
75
+ mint: (tokenAddress: string, to: string, amount: string, opts?: ProgrammaticTxOptions) => Promise<ProgrammaticTxResult>;
76
+ /**
77
+ * Burn tokens from an address, end to end.
78
+ *
79
+ * @param tokenAddress - Token contract address.
80
+ * @param from - Address to burn tokens from.
81
+ * @param amount - Amount to burn (bigint-valued decimal string).
82
+ * @param opts - Fee ceiling / confirmation strategy / wait behaviour.
83
+ */
84
+ burn: (tokenAddress: string, from: string, amount: string, opts?: ProgrammaticTxOptions) => Promise<ProgrammaticTxResult>;
85
+ /**
86
+ * Transfer tokens from one address to another using an existing
87
+ * allowance, end to end.
88
+ *
89
+ * @param tokenAddress - Token contract address.
90
+ * @param from - Owner address the tokens are moved from.
91
+ * @param to - Recipient address.
92
+ * @param amount - Amount to transfer (bigint-valued decimal string).
93
+ * @param opts - Fee ceiling / confirmation strategy / wait behaviour.
94
+ */
95
+ transferFrom: (tokenAddress: string, from: string, to: string, amount: string, opts?: ProgrammaticTxOptions) => Promise<ProgrammaticTxResult>;
96
+ /**
97
+ * Pause all token operations, end to end.
98
+ *
99
+ * @param tokenAddress - Token contract address.
100
+ * @param opts - Fee ceiling / confirmation strategy / wait behaviour.
101
+ */
102
+ pause: (tokenAddress: string, opts?: ProgrammaticTxOptions) => Promise<ProgrammaticTxResult>;
103
+ /**
104
+ * Resume a paused token, end to end.
105
+ *
106
+ * @param tokenAddress - Token contract address.
107
+ * @param opts - Fee ceiling / confirmation strategy / wait behaviour.
108
+ */
109
+ unpause: (tokenAddress: string, opts?: ProgrammaticTxOptions) => Promise<ProgrammaticTxResult>;
110
+ /**
111
+ * Transfer ownership of the token to a new owner, end to end.
112
+ *
113
+ * @param tokenAddress - Token contract address.
114
+ * @param newOwner - Address of the new owner.
115
+ * @param opts - Fee ceiling / confirmation strategy / wait behaviour.
116
+ */
117
+ transferOwnership: (tokenAddress: string, newOwner: string, opts?: ProgrammaticTxOptions) => Promise<ProgrammaticTxResult>;
118
+ /**
119
+ * Grant ACL permissions to an address, end to end.
120
+ *
121
+ * @param tokenAddress - Token contract address.
122
+ * @param address - Address being granted the permissions.
123
+ * @param permissions - Permissions to grant.
124
+ * @param opts - Fee ceiling / confirmation strategy / wait behaviour.
125
+ */
126
+ grantPermissions: (tokenAddress: string, address: string, permissions: string[], opts?: ProgrammaticTxOptions) => Promise<ProgrammaticTxResult>;
127
+ /**
128
+ * Revoke ACL permissions from an address, end to end.
129
+ *
130
+ * @param tokenAddress - Token contract address.
131
+ * @param address - Address the permissions are revoked from.
132
+ * @param permissions - Permissions to revoke.
133
+ * @param opts - Fee ceiling / confirmation strategy / wait behaviour.
134
+ */
135
+ revokePermissions: (tokenAddress: string, address: string, permissions: string[], opts?: ProgrammaticTxOptions) => Promise<ProgrammaticTxResult>;
136
+ /**
137
+ * Upgrade the token's on-chain script, end to end.
138
+ *
139
+ * @param tokenAddress - Token contract address.
140
+ * @param newCode - New script code.
141
+ * @param newMethods - New method definitions to install.
142
+ * @param newHooks - New hooks to activate.
143
+ * @param opts - Fee ceiling / confirmation strategy / wait behaviour.
144
+ */
145
+ upgradeScript: (tokenAddress: string, newCode: string, newMethods: TokenScriptMethod[], newHooks: TokenHookType[], opts?: ProgrammaticTxOptions) => Promise<ProgrammaticTxResult>;
146
+ /**
147
+ * Call a custom script method on the token, end to end.
148
+ *
149
+ * @param tokenAddress - Token contract address.
150
+ * @param method - Method name to invoke.
151
+ * @param params - Method parameters.
152
+ * @param opts - Fee ceiling / confirmation strategy / wait behaviour.
153
+ */
154
+ callMethod: (tokenAddress: string, method: string, params: unknown[], opts?: ProgrammaticTxOptions) => Promise<ProgrammaticTxResult>;
155
+ };
@@ -0,0 +1,157 @@
1
+ import { DemosTokens } from "../DemosTokens.js";
2
+ /**
3
+ * Token creation and execution as one-call programmatic transactions.
4
+ *
5
+ * Wraps {@link DemosTokens} so deploying a token or running a token
6
+ * operation (transfer, approve, mint, burn, …) collapses the classic
7
+ * `build → sign → confirm → broadcast` flow into a single call. Each
8
+ * builder here returns an UNSIGNED transaction; the method hands a thunk
9
+ * producing it to `ctx.run(...)`, which signs, confirms against the fee
10
+ * ceiling and auto-broadcasts — keeping fee-cap policy, confirmation
11
+ * strategy and result shape uniform with the rest of `demos.run.*`.
12
+ *
13
+ * All amounts are bigint-valued decimal strings, mirroring
14
+ * {@link DemosTokens}.
15
+ */
16
+ export function createTokensNamespace(ctx) {
17
+ const tokens = new DemosTokens(ctx.demos);
18
+ return {
19
+ /**
20
+ * Deploy a new token, end to end.
21
+ *
22
+ * @example
23
+ * ```ts
24
+ * const r = await demos.run.tokens.create({
25
+ * name: "My Token",
26
+ * ticker: "MYT",
27
+ * decimals: 18,
28
+ * initialSupply: "1000000",
29
+ * })
30
+ * console.log(r.transaction.content.to) // derived token address
31
+ * ```
32
+ *
33
+ * @param params - Token creation parameters (name, ticker, decimals,
34
+ * initial supply, optional script/ACL).
35
+ * @param opts - Fee ceiling / confirmation strategy / wait behaviour.
36
+ */
37
+ create: (params, opts) => ctx.run(() => tokens.createToken(params), opts),
38
+ /**
39
+ * Transfer tokens to another address, end to end.
40
+ *
41
+ * @example
42
+ * ```ts
43
+ * // auto-broadcast within the 5 DEM fee cap:
44
+ * await demos.run.tokens.transfer("0xToken...", "0xTo...", "1000")
45
+ * // build + confirm only, broadcast later yourself:
46
+ * const r = await demos.run.tokens.transfer(
47
+ * "0xToken...", "0xTo...", "1000", { confirm: "manual" },
48
+ * )
49
+ * await demos.broadcast(r.validityData)
50
+ * ```
51
+ *
52
+ * @param tokenAddress - Token contract address.
53
+ * @param to - Recipient address.
54
+ * @param amount - Amount to transfer (bigint-valued decimal string).
55
+ * @param opts - Fee ceiling / confirmation strategy / wait behaviour.
56
+ */
57
+ transfer: (tokenAddress, to, amount, opts) => ctx.run(() => tokens.transfer(tokenAddress, to, amount), opts),
58
+ /**
59
+ * Approve a spender to move tokens on your behalf, end to end.
60
+ *
61
+ * @param tokenAddress - Token contract address.
62
+ * @param spender - Spender address being granted the allowance.
63
+ * @param amount - Amount to approve (bigint-valued decimal string).
64
+ * @param opts - Fee ceiling / confirmation strategy / wait behaviour.
65
+ */
66
+ approve: (tokenAddress, spender, amount, opts) => ctx.run(() => tokens.approve(tokenAddress, spender, amount), opts),
67
+ /**
68
+ * Mint new tokens to an address, end to end.
69
+ *
70
+ * @param tokenAddress - Token contract address.
71
+ * @param to - Recipient of the minted tokens.
72
+ * @param amount - Amount to mint (bigint-valued decimal string).
73
+ * @param opts - Fee ceiling / confirmation strategy / wait behaviour.
74
+ */
75
+ mint: (tokenAddress, to, amount, opts) => ctx.run(() => tokens.mint(tokenAddress, to, amount), opts),
76
+ /**
77
+ * Burn tokens from an address, end to end.
78
+ *
79
+ * @param tokenAddress - Token contract address.
80
+ * @param from - Address to burn tokens from.
81
+ * @param amount - Amount to burn (bigint-valued decimal string).
82
+ * @param opts - Fee ceiling / confirmation strategy / wait behaviour.
83
+ */
84
+ burn: (tokenAddress, from, amount, opts) => ctx.run(() => tokens.burn(tokenAddress, from, amount), opts),
85
+ /**
86
+ * Transfer tokens from one address to another using an existing
87
+ * allowance, end to end.
88
+ *
89
+ * @param tokenAddress - Token contract address.
90
+ * @param from - Owner address the tokens are moved from.
91
+ * @param to - Recipient address.
92
+ * @param amount - Amount to transfer (bigint-valued decimal string).
93
+ * @param opts - Fee ceiling / confirmation strategy / wait behaviour.
94
+ */
95
+ transferFrom: (tokenAddress, from, to, amount, opts) => ctx.run(() => tokens.transferFrom(tokenAddress, from, to, amount), opts),
96
+ /**
97
+ * Pause all token operations, end to end.
98
+ *
99
+ * @param tokenAddress - Token contract address.
100
+ * @param opts - Fee ceiling / confirmation strategy / wait behaviour.
101
+ */
102
+ pause: (tokenAddress, opts) => ctx.run(() => tokens.pause(tokenAddress), opts),
103
+ /**
104
+ * Resume a paused token, end to end.
105
+ *
106
+ * @param tokenAddress - Token contract address.
107
+ * @param opts - Fee ceiling / confirmation strategy / wait behaviour.
108
+ */
109
+ unpause: (tokenAddress, opts) => ctx.run(() => tokens.unpause(tokenAddress), opts),
110
+ /**
111
+ * Transfer ownership of the token to a new owner, end to end.
112
+ *
113
+ * @param tokenAddress - Token contract address.
114
+ * @param newOwner - Address of the new owner.
115
+ * @param opts - Fee ceiling / confirmation strategy / wait behaviour.
116
+ */
117
+ transferOwnership: (tokenAddress, newOwner, opts) => ctx.run(() => tokens.transferOwnership(tokenAddress, newOwner), opts),
118
+ /**
119
+ * Grant ACL permissions to an address, end to end.
120
+ *
121
+ * @param tokenAddress - Token contract address.
122
+ * @param address - Address being granted the permissions.
123
+ * @param permissions - Permissions to grant.
124
+ * @param opts - Fee ceiling / confirmation strategy / wait behaviour.
125
+ */
126
+ grantPermissions: (tokenAddress, address, permissions, opts) => ctx.run(() => tokens.grantPermissions(tokenAddress, address, permissions), opts),
127
+ /**
128
+ * Revoke ACL permissions from an address, end to end.
129
+ *
130
+ * @param tokenAddress - Token contract address.
131
+ * @param address - Address the permissions are revoked from.
132
+ * @param permissions - Permissions to revoke.
133
+ * @param opts - Fee ceiling / confirmation strategy / wait behaviour.
134
+ */
135
+ revokePermissions: (tokenAddress, address, permissions, opts) => ctx.run(() => tokens.revokePermissions(tokenAddress, address, permissions), opts),
136
+ /**
137
+ * Upgrade the token's on-chain script, end to end.
138
+ *
139
+ * @param tokenAddress - Token contract address.
140
+ * @param newCode - New script code.
141
+ * @param newMethods - New method definitions to install.
142
+ * @param newHooks - New hooks to activate.
143
+ * @param opts - Fee ceiling / confirmation strategy / wait behaviour.
144
+ */
145
+ upgradeScript: (tokenAddress, newCode, newMethods, newHooks, opts) => ctx.run(() => tokens.upgradeScript(tokenAddress, newCode, newMethods, newHooks), opts),
146
+ /**
147
+ * Call a custom script method on the token, end to end.
148
+ *
149
+ * @param tokenAddress - Token contract address.
150
+ * @param method - Method name to invoke.
151
+ * @param params - Method parameters.
152
+ * @param opts - Fee ceiling / confirmation strategy / wait behaviour.
153
+ */
154
+ callMethod: (tokenAddress, method, params, opts) => ctx.run(() => tokens.callMethod(tokenAddress, method, params), opts),
155
+ };
156
+ }
157
+ //# sourceMappingURL=tokens.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tokens.js","sourceRoot":"","sources":["../../../../src/websdk/programmatic/tokens.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAI5C;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,qBAAqB,CAAC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Aa,EAAE,CACX,YAAoB,EACpB,OAAe,EACf,UAA+B,EAC/B,QAAyB,EACzB,IAA4B,EACC,EAAE,CAC/B,GAAG,CAAC,GAAG,CACH,GAAG,EAAE,CACD,MAAM,CAAC,aAAa,CAChB,YAAY,EACZ,OAAO,EACP,UAAU,EACV,QAAQ,CACX,EACL,IAAI,CACP;QAEL;;;;;;;WAOG;QACH,UAAU,EAAE,CACR,YAAoB,EACpB,MAAc,EACd,MAAiB,EACjB,IAA4B,EACC,EAAE,CAC/B,GAAG,CAAC,GAAG,CACH,GAAG,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,YAAY,EAAE,MAAM,EAAE,MAAM,CAAC,EACrD,IAAI,CACP;KACR,CAAA;AACL,CAAC"}
@@ -0,0 +1,95 @@
1
+ import type { Transaction } from "../../types";
2
+ import type { RPCResponse, RPCResponseWithValidityData } from "../../types/communication/rpc";
3
+ /**
4
+ * Default fee ceiling, in DEM, applied by the programmatic-tx runner when
5
+ * `maxFee` is not specified. If a confirmed transaction's total fee exceeds
6
+ * this and no `confirm` callback is provided, the runner throws
7
+ * {@link FeeCapExceededError} instead of broadcasting.
8
+ */
9
+ export declare const DEFAULT_MAX_FEE_DEM = 5;
10
+ /**
11
+ * Anything the runner can turn into a confirmed transaction:
12
+ * - a `Transaction` (signed or unsigned — unsigned is signed first),
13
+ * - an already-confirmed `RPCResponseWithValidityData` (e.g. the value the
14
+ * `Identities.*` builders return), or
15
+ * - a thunk producing either of the above.
16
+ */
17
+ export type TxSource = Transaction | RPCResponseWithValidityData | (() => Promise<Transaction | RPCResponseWithValidityData>);
18
+ /**
19
+ * Snapshot handed to a {@link ConfirmHook} (and carried on
20
+ * {@link FeeCapExceededError}) after `confirm` but before `broadcast`.
21
+ */
22
+ export interface TxConfirmInfo {
23
+ /** The signed, confirmed transaction. */
24
+ transaction: Transaction;
25
+ /** Raw validity data from the node (gas operation, reference block, …). */
26
+ validityData: RPCResponseWithValidityData;
27
+ /** Total fee for this transaction, in OS (smallest unit). */
28
+ feeOs: bigint;
29
+ /** Total fee for this transaction, human-readable DEM string. */
30
+ feeDem: string;
31
+ /** Whether `feeOs` is within the configured `maxFee` ceiling. */
32
+ withinFeeCap: boolean;
33
+ /** Node reference block the tx was confirmed against. */
34
+ referenceBlock: number;
35
+ }
36
+ /**
37
+ * Decides whether a confirmed transaction should be broadcast. Return `true`
38
+ * to broadcast, `false` to skip (the result reports `skippedReason: "rejected"`).
39
+ */
40
+ export type ConfirmHook = (info: TxConfirmInfo) => boolean | Promise<boolean>;
41
+ export interface ProgrammaticTxOptions {
42
+ /**
43
+ * Fee ceiling, in DEM. When the confirmed fee exceeds this in `"auto"`
44
+ * mode the runner throws {@link FeeCapExceededError} rather than
45
+ * broadcasting. Defaults to {@link DEFAULT_MAX_FEE_DEM} (5 DEM). Pass
46
+ * `null` or `Infinity` to disable the cap entirely.
47
+ */
48
+ maxFee?: number | string | null;
49
+ /**
50
+ * Confirmation strategy:
51
+ * - `"auto"` (default): broadcast automatically, subject to `maxFee`.
52
+ * - `"manual"`: build + sign + confirm only; return the validity data
53
+ * without broadcasting (the classic three-step flow, collapsed to one
54
+ * call for the confirm stage).
55
+ * - a {@link ConfirmHook}: called with the fee/validity snapshot; the tx
56
+ * is broadcast only if it returns `true`. `maxFee` is not auto-enforced
57
+ * in this mode — the callback is the sole authority.
58
+ */
59
+ confirm?: "auto" | "manual" | ConfirmHook;
60
+ /**
61
+ * When broadcasting, wait for on-chain inclusion via `broadcastAndWait`
62
+ * instead of returning after the broadcast RPC. Defaults to `false`.
63
+ */
64
+ wait?: boolean;
65
+ /** Options forwarded to `broadcastAndWait` when `wait` is `true`. */
66
+ waitOptions?: {
67
+ timeoutMs?: number;
68
+ pollIntervalMs?: number;
69
+ };
70
+ }
71
+ /** Why a confirmed transaction was not broadcast. */
72
+ export type SkippedReason = "manual" | "rejected";
73
+ /**
74
+ * Uniform result of a programmatic transaction. `broadcasted` tells you
75
+ * whether the tx actually hit the network; everything needed to broadcast
76
+ * later (in `"manual"` mode) is on `validityData`.
77
+ */
78
+ export interface ProgrammaticTxResult {
79
+ /** `true` if the transaction was broadcast to the network. */
80
+ broadcasted: boolean;
81
+ /** Set when `broadcasted` is `false`, explaining why. */
82
+ skippedReason?: SkippedReason;
83
+ /** The signed, confirmed transaction. */
84
+ transaction: Transaction;
85
+ /** Transaction hash (as confirmed by the node). */
86
+ hash: string;
87
+ /** Raw validity data from `confirm`. */
88
+ validityData: RPCResponseWithValidityData;
89
+ /** Broadcast response, present only when `broadcasted` is `true`. */
90
+ broadcast?: RPCResponse;
91
+ /** Total fee, in OS (smallest unit). */
92
+ feeOs: bigint;
93
+ /** Total fee, human-readable DEM string. */
94
+ feeDem: string;
95
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Default fee ceiling, in DEM, applied by the programmatic-tx runner when
3
+ * `maxFee` is not specified. If a confirmed transaction's total fee exceeds
4
+ * this and no `confirm` callback is provided, the runner throws
5
+ * {@link FeeCapExceededError} instead of broadcasting.
6
+ */
7
+ export const DEFAULT_MAX_FEE_DEM = 5;
8
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/websdk/programmatic/types.ts"],"names":[],"mappings":"AAMA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAA"}
@@ -0,0 +1,63 @@
1
+ import type { ProgrammaticContext } from "./context";
2
+ import type { ProgrammaticTxOptions, ProgrammaticTxResult } from "./types";
3
+ /**
4
+ * Validator staking lifecycle as one-call programmatic transactions.
5
+ *
6
+ * Collapses the classic `build → confirm → broadcast` flow for the validator
7
+ * `stake`, `unstake` and `exit` operations into a single call that
8
+ * auto-broadcasts within the configured fee ceiling.
9
+ */
10
+ export declare function createValidatorNamespace(ctx: ProgrammaticContext): {
11
+ /**
12
+ * Stake toward validator registration, or top up an existing stake,
13
+ * end to end.
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * import { denomination } from "@kynesyslabs/demosdk"
18
+ * // register + auto-broadcast within the 5 DEM fee cap:
19
+ * await demos.run.validator.stake(
20
+ * denomination.demToOs(1000).toString(),
21
+ * "https://my-validator.example",
22
+ * )
23
+ * // build + confirm only, broadcast later yourself:
24
+ * const r = await demos.run.validator.stake(
25
+ * "1000000000",
26
+ * "https://my-validator.example",
27
+ * { confirm: "manual" },
28
+ * )
29
+ * await demos.broadcast(r.validityData)
30
+ * ```
31
+ *
32
+ * @param amount - Stake amount as a non-negative bigint-encoded string (OS).
33
+ * @param connectionUrl - Validator's public endpoint (required on first
34
+ * stake; used to reach the node).
35
+ * @param opts - Fee ceiling / confirmation strategy / wait behaviour.
36
+ */
37
+ stake: (amount: string, connectionUrl: string, opts?: ProgrammaticTxOptions) => Promise<ProgrammaticTxResult>;
38
+ /**
39
+ * Arm the unstake lock, end to end. Starts the timelock after which
40
+ * {@link exit} becomes accepted by the network.
41
+ *
42
+ * @example
43
+ * ```ts
44
+ * await demos.run.validator.unstake()
45
+ * ```
46
+ *
47
+ * @param opts - Fee ceiling / confirmation strategy / wait behaviour.
48
+ */
49
+ unstake: (opts?: ProgrammaticTxOptions) => Promise<ProgrammaticTxResult>;
50
+ /**
51
+ * Complete validator exit, end to end. Only accepted by the network
52
+ * once the unstake timelock has elapsed
53
+ * (`unstake_available_at <= currentBlock`).
54
+ *
55
+ * @example
56
+ * ```ts
57
+ * await demos.run.validator.exit()
58
+ * ```
59
+ *
60
+ * @param opts - Fee ceiling / confirmation strategy / wait behaviour.
61
+ */
62
+ exit: (opts?: ProgrammaticTxOptions) => Promise<ProgrammaticTxResult>;
63
+ };
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Validator staking lifecycle as one-call programmatic transactions.
3
+ *
4
+ * Collapses the classic `build → confirm → broadcast` flow for the validator
5
+ * `stake`, `unstake` and `exit` operations into a single call that
6
+ * auto-broadcasts within the configured fee ceiling.
7
+ */
8
+ export function createValidatorNamespace(ctx) {
9
+ return {
10
+ /**
11
+ * Stake toward validator registration, or top up an existing stake,
12
+ * end to end.
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * import { denomination } from "@kynesyslabs/demosdk"
17
+ * // register + auto-broadcast within the 5 DEM fee cap:
18
+ * await demos.run.validator.stake(
19
+ * denomination.demToOs(1000).toString(),
20
+ * "https://my-validator.example",
21
+ * )
22
+ * // build + confirm only, broadcast later yourself:
23
+ * const r = await demos.run.validator.stake(
24
+ * "1000000000",
25
+ * "https://my-validator.example",
26
+ * { confirm: "manual" },
27
+ * )
28
+ * await demos.broadcast(r.validityData)
29
+ * ```
30
+ *
31
+ * @param amount - Stake amount as a non-negative bigint-encoded string (OS).
32
+ * @param connectionUrl - Validator's public endpoint (required on first
33
+ * stake; used to reach the node).
34
+ * @param opts - Fee ceiling / confirmation strategy / wait behaviour.
35
+ */
36
+ stake: (amount, connectionUrl, opts) => ctx.run(() => ctx.demos.tx.stake(amount, connectionUrl, ctx.demos), opts),
37
+ /**
38
+ * Arm the unstake lock, end to end. Starts the timelock after which
39
+ * {@link exit} becomes accepted by the network.
40
+ *
41
+ * @example
42
+ * ```ts
43
+ * await demos.run.validator.unstake()
44
+ * ```
45
+ *
46
+ * @param opts - Fee ceiling / confirmation strategy / wait behaviour.
47
+ */
48
+ unstake: (opts) => ctx.run(() => ctx.demos.tx.unstake(ctx.demos), opts),
49
+ /**
50
+ * Complete validator exit, end to end. Only accepted by the network
51
+ * once the unstake timelock has elapsed
52
+ * (`unstake_available_at <= currentBlock`).
53
+ *
54
+ * @example
55
+ * ```ts
56
+ * await demos.run.validator.exit()
57
+ * ```
58
+ *
59
+ * @param opts - Fee ceiling / confirmation strategy / wait behaviour.
60
+ */
61
+ exit: (opts) => ctx.run(() => ctx.demos.tx.validatorExit(ctx.demos), opts),
62
+ };
63
+ }
64
+ //# sourceMappingURL=validator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validator.js","sourceRoot":"","sources":["../../../../src/websdk/programmatic/validator.ts"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,MAAM,UAAU,wBAAwB,CAAC,GAAwB;IAC7D,OAAO;QACH;;;;;;;;;;;;;;;;;;;;;;;;;WAyBG;QACH,KAAK,EAAE,CACH,MAAc,EACd,aAAqB,EACrB,IAA4B,EACC,EAAE,CAC/B,GAAG,CAAC,GAAG,CACH,GAAG,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE,aAAa,EAAE,GAAG,CAAC,KAAK,CAAC,EAC1D,IAAI,CACP;QAEL;;;;;;;;;;WAUG;QACH,OAAO,EAAE,CACL,IAA4B,EACC,EAAE,CAC/B,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC;QAExD;;;;;;;;;;;WAWG;QACH,IAAI,EAAE,CACF,IAA4B,EACC,EAAE,CAC/B,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,aAAa,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC;KACjE,CAAA;AACL,CAAC"}
@@ -0,0 +1,36 @@
1
+ import type { XMScript } from "../../types";
2
+ import type { ProgrammaticContext } from "./context";
3
+ import type { ProgrammaticTxOptions, ProgrammaticTxResult } from "./types";
4
+ /**
5
+ * Cross-chain (XM) operations as one-call programmatic transactions.
6
+ *
7
+ * Building the `XMScript` is inherently chain-specific (per-chain signed
8
+ * payloads, RPC selection, EVM vs non-EVM task shape, …) and therefore stays
9
+ * with the caller. Once a script is assembled, this namespace collapses the
10
+ * classic `prepareXMPayload → confirm → broadcast` flow into a single call
11
+ * that auto-broadcasts within the configured fee ceiling.
12
+ */
13
+ export declare function createXmNamespace(ctx: ProgrammaticContext): {
14
+ /**
15
+ * Submit a fully-built {@link XMScript} as a `crosschainOperation`
16
+ * transaction, end to end.
17
+ *
18
+ * `prepareXMPayload` signs the transaction; the shared runner then
19
+ * confirms it and (in `"auto"` mode) broadcasts it within the fee cap.
20
+ *
21
+ * @example
22
+ * ```ts
23
+ * import { prepareXMScript } from "@kynesyslabs/demosdk"
24
+ * const xmScript = prepareXMScript({ chain: "eth", ... })
25
+ * // auto-broadcast within the fee cap:
26
+ * await demos.run.xm.submit(xmScript)
27
+ * // build + confirm only, broadcast later yourself:
28
+ * const r = await demos.run.xm.submit(xmScript, { confirm: "manual" })
29
+ * await demos.broadcast(r.validityData)
30
+ * ```
31
+ *
32
+ * @param xmScript - The assembled cross-chain script to execute.
33
+ * @param opts - Fee ceiling / confirmation strategy / wait behaviour.
34
+ */
35
+ submit: (xmScript: XMScript, opts?: ProgrammaticTxOptions) => Promise<ProgrammaticTxResult>;
36
+ };
@@ -0,0 +1,37 @@
1
+ import { prepareXMPayload } from "../XMTransactions.js";
2
+ /**
3
+ * Cross-chain (XM) operations as one-call programmatic transactions.
4
+ *
5
+ * Building the `XMScript` is inherently chain-specific (per-chain signed
6
+ * payloads, RPC selection, EVM vs non-EVM task shape, …) and therefore stays
7
+ * with the caller. Once a script is assembled, this namespace collapses the
8
+ * classic `prepareXMPayload → confirm → broadcast` flow into a single call
9
+ * that auto-broadcasts within the configured fee ceiling.
10
+ */
11
+ export function createXmNamespace(ctx) {
12
+ return {
13
+ /**
14
+ * Submit a fully-built {@link XMScript} as a `crosschainOperation`
15
+ * transaction, end to end.
16
+ *
17
+ * `prepareXMPayload` signs the transaction; the shared runner then
18
+ * confirms it and (in `"auto"` mode) broadcasts it within the fee cap.
19
+ *
20
+ * @example
21
+ * ```ts
22
+ * import { prepareXMScript } from "@kynesyslabs/demosdk"
23
+ * const xmScript = prepareXMScript({ chain: "eth", ... })
24
+ * // auto-broadcast within the fee cap:
25
+ * await demos.run.xm.submit(xmScript)
26
+ * // build + confirm only, broadcast later yourself:
27
+ * const r = await demos.run.xm.submit(xmScript, { confirm: "manual" })
28
+ * await demos.broadcast(r.validityData)
29
+ * ```
30
+ *
31
+ * @param xmScript - The assembled cross-chain script to execute.
32
+ * @param opts - Fee ceiling / confirmation strategy / wait behaviour.
33
+ */
34
+ submit: (xmScript, opts) => ctx.run(() => prepareXMPayload(xmScript, ctx.demos), opts),
35
+ };
36
+ }
37
+ //# sourceMappingURL=xm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"xm.js","sourceRoot":"","sources":["../../../../src/websdk/programmatic/xm.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AAIpD;;;;;;;;GAQG;AACH,MAAM,UAAU,iBAAiB,CAAC,GAAwB;IACtD,OAAO;QACH;;;;;;;;;;;;;;;;;;;;WAoBG;QACH,MAAM,EAAE,CACJ,QAAkB,EAClB,IAA4B,EACC,EAAE,CAC/B,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,gBAAgB,CAAC,QAAQ,EAAE,GAAG,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC;KACjE,CAAA;AACL,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kynesyslabs/demosdk",
3
- "version": "4.0.11",
3
+ "version": "4.0.13",
4
4
  "type": "module",
5
5
  "description": "Demosdk is a JavaScript/TypeScript SDK that provides a unified interface for interacting with Demos network",
6
6
  "main": "build/index.js",