jalin-sdk 0.1.0 → 0.2.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
@@ -18,11 +18,6 @@ the router's limits before you spend gas, and encodes them as calldata.
18
18
  npm install jalin-sdk
19
19
  ```
20
20
 
21
- > **Not on the registry yet.** Until this package is published, `jalin-sdk` is an
22
- > unclaimed name, and installing it would fetch whatever anyone else has put
23
- > there. Use it from the repository — `npm install github:PugarHuda/jalin` — or
24
- > wait for the published version.
25
-
26
21
  ## Building a plan
27
22
 
28
23
  ```js
@@ -53,7 +48,8 @@ the wallet resolves at submit time, so the note id never has to be known here.
53
48
 
54
49
  | | |
55
50
  |---|---|
56
- | `plan.ts` | `PlanBuilder`, `validatePlan`, `encodePlan`, `unclaimedTokens`, limits |
51
+ | `plan.ts` | `PlanBuilder`, `validatePlan`, `encodePlan`, `unclaimedTokens`, `FIELD_PRIME`, limits |
52
+ | `ballot.ts` | the governor's two operations: stake a private ballot, and take the stake back |
57
53
  | `recipes.ts` | `callStep` for any ABI, `depositStep` for ERC-4626, `oneWay` |
58
54
  | `receipt.ts` | reads a transaction receipt and says whether it really touched the pool |
59
55
  | `subaccounts.ts` | sub-account portfolios, and when one has no anonymity left |
@@ -63,6 +59,43 @@ the wallet resolves at submit time, so the note id never has to be known here.
63
59
 
64
60
  Every export is typed, and the package ships its own declarations.
65
61
 
62
+ ## The private ballot, and getting the stake back
63
+
64
+ A ballot stakes a token in the governor and hands the voter a secret. The
65
+ governor's `privacy_invoke` takes a fixed eight-felt argument list and switches
66
+ on the first of them, which is easy to hand-encode wrongly and was hand-encoded
67
+ in two places here before this module existed — while the operation that returns
68
+ the money was encoded nowhere at all.
69
+
70
+ ```js
71
+ import { castBallotActions, redeemBallotActions, ballotStage, decodeBallot } from 'jalin-sdk'
72
+
73
+ // Vote. The commitment is poseidon_hash_span([BALLOT_TAG, secret]); the secret
74
+ // itself never appears in this transaction.
75
+ const cast = castBallotActions({
76
+ governor: GOVERNOR,
77
+ proposalId: 3n,
78
+ amount: 10n ** 17n,
79
+ commitment,
80
+ ballotToken: STRK,
81
+ })
82
+
83
+ // Later, once voting has closed. This one does carry the secret, because the
84
+ // contract has to hash it — so it stops being a secret when this lands.
85
+ const redeem = redeemBallotActions({
86
+ governor: GOVERNOR,
87
+ secret,
88
+ ballotToken: STRK,
89
+ recipient: account,
90
+ })
91
+ ```
92
+
93
+ `ballotStage(decodeBallot(raw), proposal, head)` answers what the holder of a
94
+ secret can do right now — unknown, voting, redeemable or already claimed —
95
+ using the contract's own rule, which is that redemption opens at the block
96
+ *after* `end_block`. Asking first costs one `starknet_call`; getting it wrong
97
+ costs the gas of a revert after proving.
98
+
66
99
  ## Verifying a submission
67
100
 
68
101
  The router's deployment also answers for anyone, not just for Jalin:
@@ -13,7 +13,17 @@ import type { PoolEvent } from './crowd.ts';
13
13
  * The effective set is the perplexity of the flow distribution, 2^H — four
14
14
  * equal participants give exactly 4, and the lopsided four give about 1.2.
15
15
  */
16
- /** ~6 hours at Starknet mainnet's measured 1.68s per block. */
16
+ /**
17
+ * ~6 hours, at 1.68s per block.
18
+ *
19
+ * A default, and the callers that matter no longer take it: `app/lib/crowd-source.ts`
20
+ * measures the block time at read time and passes the width in, because 1.68
21
+ * is the figure this project's own findings disprove - it read 1.70 over
22
+ * 200,000 blocks and 1.72 over 2,000 a week later, and every cell boundary
23
+ * built on the stale number is out by about a percent and drifting. Kept for
24
+ * callers with no chain access, where a documented approximation beats a
25
+ * required argument they cannot answer.
26
+ */
17
27
  export declare const CELL_BLOCKS = 12888;
18
28
  export interface Cell {
19
29
  asset: string;
@@ -1 +1 @@
1
- {"version":3,"file":"anonymity.d.ts","sourceRoot":"","sources":["../src/anonymity.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAE3C;;;;;;;;;;;;;GAaG;AAEH,+DAA+D;AAC/D,eAAO,MAAM,WAAW,Q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,KAAK,EAAE,IAAI,EAAE,GAAG,WAAW,CAmBzD;AAED,MAAM,WAAW,QAAQ;IACvB,8DAA8D;IAC9D,SAAS,EAAE,MAAM,CAAA;IACjB,kEAAkE;IAClE,YAAY,EAAE,MAAM,CAAA;IACpB,oDAAoD;IACpD,iBAAiB,EAAE,MAAM,CAAA;IACzB;;;;;;OAMG;IACH,gBAAgB,EAAE,MAAM,CAAA;CACzB;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CACzB,MAAM,EAAE,SAAS,EAAE,EACnB,MAAM,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,EAC1D,UAAU,SAAc,GACvB,QAAQ,CAgCV;AAED,MAAM,WAAW,MAAM;IACrB,uDAAuD;IACvD,IAAI,EAAE,MAAM,CAAA;IACZ,4EAA4E;IAC5E,SAAS,EAAE,MAAM,CAAA;IACjB,sCAAsC;IACtC,KAAK,EAAE,MAAM,CAAA;IACb,6EAA6E;IAC7E,kBAAkB,EAAE,MAAM,CAAA;IAC1B,mDAAmD;IACnD,gBAAgB,EAAE,MAAM,CAAA;CACzB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,UAAU,SAAc,GAAG,MAAM,EAAE,CAoBhF"}
package/dist/anonymity.js CHANGED
@@ -12,7 +12,17 @@
12
12
  * The effective set is the perplexity of the flow distribution, 2^H — four
13
13
  * equal participants give exactly 4, and the lopsided four give about 1.2.
14
14
  */
15
- /** ~6 hours at Starknet mainnet's measured 1.68s per block. */
15
+ /**
16
+ * ~6 hours, at 1.68s per block.
17
+ *
18
+ * A default, and the callers that matter no longer take it: `app/lib/crowd-source.ts`
19
+ * measures the block time at read time and passes the width in, because 1.68
20
+ * is the figure this project's own findings disprove - it read 1.70 over
21
+ * 200,000 blocks and 1.72 over 2,000 a week later, and every cell boundary
22
+ * built on the stale number is out by about a percent and drifting. Kept for
23
+ * callers with no chain access, where a documented approximation beats a
24
+ * required argument they cannot answer.
25
+ */
16
26
  export const CELL_BLOCKS = 12_888;
17
27
  /** `keys[1]` is the depositor, `keys[2]` the asset, `data[0]` the amount. */
18
28
  function read(events) {
@@ -1 +1 @@
1
- {"version":3,"file":"anonymity.js","sourceRoot":"","sources":["../src/anonymity.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AAEH,+DAA+D;AAC/D,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAA;AAqBjC,6EAA6E;AAC7E,SAAS,IAAI,CAAC,MAAmB;IAC/B,MAAM,QAAQ,GAAc,EAAE,CAAA;IAE9B,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC;YAAE,SAAQ;QAClD,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,CAAA;QAC/C,IAAI,MAAM,KAAK,EAAE;YAAE,SAAQ;QAE3B,QAAQ,CAAC,IAAI,CAAC;YACZ,qDAAqD;YACrD,GAAG,EAAE,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAE,CAAC,CAAC,QAAQ,EAAE;YACtC,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAE,CAAC,CAAC,QAAQ,EAAE;YACxC,MAAM;YACN,KAAK,EAAE,KAAK,CAAC,YAAY,IAAI,CAAC;SAC/B,CAAC,CAAA;IACJ,CAAC;IAED,OAAO,QAAQ,CAAA;AACjB,CAAC;AAED,SAAS,WAAW,CAAC,MAAc;IACjC,OAAO,MAAM,CAAC,QAAQ,EAAE,CAAC,MAAM,CAAA;AACjC,CAAC;AAED,SAAS,GAAG,CAAC,KAAa,EAAE,SAAiB,EAAE,IAAY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@ -0,0 +1,132 @@
1
+ /**
2
+ * The governor's two ballot operations, as wallet actions.
3
+ *
4
+ * `JalinGovernor::privacy_invoke` takes a fixed eight-felt argument list and
5
+ * switches on the first of them:
6
+ *
7
+ * privacy_invoke(pool_address, operation, proposal_id, support,
8
+ * commitment, secret, amount, note_id)
9
+ *
10
+ * `CAST` reads `proposal_id`, `support`, `commitment` and `amount`, and returns
11
+ * an empty span - the stake stays in the governor, so there is nothing to credit
12
+ * back and no open note to declare. `REDEEM` reads `secret` and `note_id` and
13
+ * returns one `OpenNoteDeposit`, so it needs exactly one open note.
14
+ *
15
+ * That asymmetry is the whole reason this module exists. The cast half was
16
+ * hand-encoded in two places - the composer and `scripts/mainnet.mjs` - with the
17
+ * argument order written out in a comment beside each. The redeem half was
18
+ * written in Cairo, tested in Cairo, and then encoded nowhere at all, which made
19
+ * every ballot cast so far a stake with no way back. One encoder, one test, both
20
+ * operations.
21
+ *
22
+ * The commitment is an argument rather than something computed here. It is
23
+ * `poseidon_hash_span([BALLOT_TAG, secret])`, and Poseidon over the Starknet
24
+ * field is a dependency this package does not have and will not take on for one
25
+ * hash. The caller has starknet.js; `BALLOT_TAG` is exported so the two agree on
26
+ * the tag rather than each carrying its own copy of the string.
27
+ */
28
+ import { type Felt } from './plan.ts';
29
+ import { type Strk20Action } from './wallet.ts';
30
+ /** Domain separator the governor hashes with the secret. Matches `BALLOT_TAG`. */
31
+ export declare const BALLOT_TAG = "JALIN_BALLOT:V1";
32
+ /** `operation` in `privacy_invoke`. Matches `types::ops`. */
33
+ export declare const BALLOT_OPS: {
34
+ readonly CAST: 0n;
35
+ readonly REDEEM: 1n;
36
+ };
37
+ /** `support` in `privacy_invoke`. Anything non-zero is a yes to the contract. */
38
+ export declare const BALLOT_SUPPORT: {
39
+ readonly NO: 0n;
40
+ readonly YES: 1n;
41
+ };
42
+ export interface CastBallotArgs {
43
+ /** Deployed JalinGovernor address. */
44
+ governor: string;
45
+ /** The open proposal being voted on. Zero is not a proposal. */
46
+ proposalId: bigint;
47
+ /** Weight staked, in the governor's ballot token. */
48
+ amount: bigint;
49
+ /** `poseidon_hash_span([BALLOT_TAG, secret])`, computed by the caller. */
50
+ commitment: Felt;
51
+ /** The ballot token the pool withdraws to the governor. */
52
+ ballotToken: string;
53
+ /** Yes unless told otherwise; a ballot nobody meant to cast is a no. */
54
+ support?: bigint;
55
+ }
56
+ /**
57
+ * Stake, then vote, in one pool transaction.
58
+ *
59
+ * The withdraw sends the stake to the *governor*, not to the router: the
60
+ * governor holds its own escrow, and `cast` checks its token balance covers
61
+ * `outstanding + amount` before it counts the weight. A vote whose funds went
62
+ * somewhere else is the unbacked-weight defect this ordering exists to prevent.
63
+ */
64
+ export declare function castBallotActions(args: CastBallotArgs): Strk20Action[];
65
+ export interface RedeemBallotArgs {
66
+ /** Deployed JalinGovernor address. */
67
+ governor: string;
68
+ /** The secret held since the ballot was cast. Sent on chain by this action. */
69
+ secret: Felt;
70
+ /** The ballot token the stake comes back as. */
71
+ ballotToken: string;
72
+ /** Who the returned note belongs to - normally the connected account. */
73
+ recipient: string;
74
+ }
75
+ /**
76
+ * Take the stake back, once voting has closed.
77
+ *
78
+ * Two things about this are worth knowing before it is sent. The secret appears
79
+ * in the calldata, which is public: after redemption the commitment is linkable
80
+ * to whoever submitted this transaction, so redeeming from the account that cast
81
+ * the ballot rejoins the two halves the commitment separated. And the governor
82
+ * refuses while `block_number <= proposal.end_block`, so an early attempt costs
83
+ * gas and reverts with `GOV_VOTING_OPEN`.
84
+ *
85
+ * The open note is declared, not optional: `redeem` returns one
86
+ * `OpenNoteDeposit` naming `note_id`, and a transaction that returns a deposit
87
+ * without an open note to credit is rejected by the pool.
88
+ */
89
+ export declare function redeemBallotActions(args: RedeemBallotArgs): Strk20Action[];
90
+ /** What `get_ballot(commitment)` returns, decoded. */
91
+ export interface Ballot {
92
+ proposalId: bigint;
93
+ amount: bigint;
94
+ claimed: boolean;
95
+ }
96
+ /**
97
+ * `Ballot` from the three felts the view returns.
98
+ *
99
+ * A commitment nobody has staked against reads back as all zeros rather than as
100
+ * an error, so `proposalId === 0n` is the honest test for "no such ballot" -
101
+ * proposals are numbered from one for exactly this reason.
102
+ */
103
+ export declare function decodeBallot(felts: (string | bigint)[]): Ballot;
104
+ export type BallotStage =
105
+ /** No ballot was ever cast against this commitment. */
106
+ {
107
+ name: 'unknown';
108
+ }
109
+ /** Cast, and voting is still open. `blocksLeft` until it closes. */
110
+ | {
111
+ name: 'voting';
112
+ blocksLeft: number;
113
+ }
114
+ /** Voting has closed and the stake is redeemable now. */
115
+ | {
116
+ name: 'redeemable';
117
+ }
118
+ /** Already taken back. The secret is spent. */
119
+ | {
120
+ name: 'claimed';
121
+ };
122
+ /**
123
+ * What a holder of this secret can do right now.
124
+ *
125
+ * The rule is the contract's, not this page's: `redeem` asserts
126
+ * `get_block_number() > proposal.end_block`, so the last votable block is
127
+ * `end_block` itself and redemption opens at `end_block + 1`.
128
+ */
129
+ export declare function ballotStage(ballot: Ballot, proposal: {
130
+ endBlock: number;
131
+ }, head: number): BallotStage;
132
+ //# sourceMappingURL=ballot.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ballot.d.ts","sourceRoot":"","sources":["../src/ballot.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAA0B,KAAK,IAAI,EAAE,MAAM,WAAW,CAAA;AAC7D,OAAO,EAA0B,KAAK,YAAY,EAAE,MAAM,aAAa,CAAA;AAEvE,kFAAkF;AAClF,eAAO,MAAM,UAAU,oBAAoB,CAAA;AAE3C,6DAA6D;AAC7D,eAAO,MAAM,UAAU;;;CAAoC,CAAA;AAE3D,iFAAiF;AACjF,eAAO,MAAM,cAAc;;;CAA+B,CAAA;AAE1D,MAAM,WAAW,cAAc;IAC7B,sCAAsC;IACtC,QAAQ,EAAE,MAAM,CAAA;IAChB,gEAAgE;IAChE,UAAU,EAAE,MAAM,CAAA;IAClB,qDAAqD;IACrD,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I,EAAE,MAAM,GACX,WAAW,CAKb"}
package/dist/ballot.js ADDED
@@ -0,0 +1,153 @@
1
+ /**
2
+ * The governor's two ballot operations, as wallet actions.
3
+ *
4
+ * `JalinGovernor::privacy_invoke` takes a fixed eight-felt argument list and
5
+ * switches on the first of them:
6
+ *
7
+ * privacy_invoke(pool_address, operation, proposal_id, support,
8
+ * commitment, secret, amount, note_id)
9
+ *
10
+ * `CAST` reads `proposal_id`, `support`, `commitment` and `amount`, and returns
11
+ * an empty span - the stake stays in the governor, so there is nothing to credit
12
+ * back and no open note to declare. `REDEEM` reads `secret` and `note_id` and
13
+ * returns one `OpenNoteDeposit`, so it needs exactly one open note.
14
+ *
15
+ * That asymmetry is the whole reason this module exists. The cast half was
16
+ * hand-encoded in two places - the composer and `scripts/mainnet.mjs` - with the
17
+ * argument order written out in a comment beside each. The redeem half was
18
+ * written in Cairo, tested in Cairo, and then encoded nowhere at all, which made
19
+ * every ballot cast so far a stake with no way back. One encoder, one test, both
20
+ * operations.
21
+ *
22
+ * The commitment is an argument rather than something computed here. It is
23
+ * `poseidon_hash_span([BALLOT_TAG, secret])`, and Poseidon over the Starknet
24
+ * field is a dependency this package does not have and will not take on for one
25
+ * hash. The caller has starknet.js; `BALLOT_TAG` is exported so the two agree on
26
+ * the tag rather than each carrying its own copy of the string.
27
+ */
28
+ import { openNote, POOL_ADDRESS } from "./plan.js";
29
+ import { toFelt, feltsToStrings } from "./wallet.js";
30
+ /** Domain separator the governor hashes with the secret. Matches `BALLOT_TAG`. */
31
+ export const BALLOT_TAG = 'JALIN_BALLOT:V1';
32
+ /** `operation` in `privacy_invoke`. Matches `types::ops`. */
33
+ export const BALLOT_OPS = { CAST: 0n, REDEEM: 1n };
34
+ /** `support` in `privacy_invoke`. Anything non-zero is a yes to the contract. */
35
+ export const BALLOT_SUPPORT = { NO: 0n, YES: 1n };
36
+ /**
37
+ * Stake, then vote, in one pool transaction.
38
+ *
39
+ * The withdraw sends the stake to the *governor*, not to the router: the
40
+ * governor holds its own escrow, and `cast` checks its token balance covers
41
+ * `outstanding + amount` before it counts the weight. A vote whose funds went
42
+ * somewhere else is the unbacked-weight defect this ordering exists to prevent.
43
+ */
44
+ export function castBallotActions(args) {
45
+ if (args.proposalId <= 0n) {
46
+ throw new RangeError(`proposal id must be positive, got ${args.proposalId}`);
47
+ }
48
+ if (args.amount <= 0n) {
49
+ throw new RangeError(`a ballot stakes a positive amount, got ${args.amount}`);
50
+ }
51
+ const support = args.support ?? BALLOT_SUPPORT.YES;
52
+ return [
53
+ {
54
+ type: 'withdraw',
55
+ token: toFelt(args.ballotToken),
56
+ amount: toFelt(args.amount),
57
+ recipient: toFelt(args.governor),
58
+ },
59
+ {
60
+ type: 'invoke',
61
+ contract: toFelt(args.governor),
62
+ calldata: feltsToStrings([
63
+ POOL_ADDRESS,
64
+ BALLOT_OPS.CAST,
65
+ args.proposalId,
66
+ support,
67
+ args.commitment,
68
+ // The secret never leaves the voter. Sending it here would publish the
69
+ // bearer instrument in the calldata of the transaction that created it.
70
+ 0n,
71
+ args.amount,
72
+ 0n,
73
+ ]),
74
+ },
75
+ ];
76
+ }
77
+ /**
78
+ * Take the stake back, once voting has closed.
79
+ *
80
+ * Two things about this are worth knowing before it is sent. The secret appears
81
+ * in the calldata, which is public: after redemption the commitment is linkable
82
+ * to whoever submitted this transaction, so redeeming from the account that cast
83
+ * the ballot rejoins the two halves the commitment separated. And the governor
84
+ * refuses while `block_number <= proposal.end_block`, so an early attempt costs
85
+ * gas and reverts with `GOV_VOTING_OPEN`.
86
+ *
87
+ * The open note is declared, not optional: `redeem` returns one
88
+ * `OpenNoteDeposit` naming `note_id`, and a transaction that returns a deposit
89
+ * without an open note to credit is rejected by the pool.
90
+ */
91
+ export function redeemBallotActions(args) {
92
+ if (BigInt(args.secret) === 0n) {
93
+ throw new RangeError('zero is not a ballot secret');
94
+ }
95
+ return [
96
+ {
97
+ type: 'transfer',
98
+ token: toFelt(args.ballotToken),
99
+ amount: 'OPEN',
100
+ recipient: toFelt(args.recipient),
101
+ },
102
+ {
103
+ type: 'invoke',
104
+ contract: toFelt(args.governor),
105
+ calldata: feltsToStrings([
106
+ POOL_ADDRESS,
107
+ BALLOT_OPS.REDEEM,
108
+ // proposal_id, support and commitment are read only by CAST. The
109
+ // governor finds the ballot by hashing the secret.
110
+ 0n,
111
+ 0n,
112
+ 0n,
113
+ args.secret,
114
+ 0n,
115
+ openNote(0),
116
+ ]),
117
+ },
118
+ ];
119
+ }
120
+ /**
121
+ * `Ballot` from the three felts the view returns.
122
+ *
123
+ * A commitment nobody has staked against reads back as all zeros rather than as
124
+ * an error, so `proposalId === 0n` is the honest test for "no such ballot" -
125
+ * proposals are numbered from one for exactly this reason.
126
+ */
127
+ export function decodeBallot(felts) {
128
+ if (felts.length < 3) {
129
+ throw new Error(`get_ballot returns three felts, got ${felts.length}`);
130
+ }
131
+ return {
132
+ proposalId: BigInt(felts[0]),
133
+ amount: BigInt(felts[1]),
134
+ claimed: BigInt(felts[2]) !== 0n,
135
+ };
136
+ }
137
+ /**
138
+ * What a holder of this secret can do right now.
139
+ *
140
+ * The rule is the contract's, not this page's: `redeem` asserts
141
+ * `get_block_number() > proposal.end_block`, so the last votable block is
142
+ * `end_block` itself and redemption opens at `end_block + 1`.
143
+ */
144
+ export function ballotStage(ballot, proposal, head) {
145
+ if (ballot.proposalId === 0n)
146
+ return { name: 'unknown' };
147
+ if (ballot.claimed)
148
+ return { name: 'claimed' };
149
+ if (head <= proposal.endBlock)
150
+ return { name: 'voting', blocksLeft: proposal.endBlock - head + 1 };
151
+ return { name: 'redeemable' };
152
+ }
153
+ //# sourceMappingURL=ballot.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ballot.js","sourceRoot":"","sources":["../src/ballot.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAa,MAAM,WAAW,CAAA;AAC7D,OAAO,EAAE,MAAM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AAc,EACd,QAA8B,EAC9B,IAAY;IAEZ,IAAI,MAAM,CAAC,UAAU,KAAK,EAAE;QAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,CAAA;IACxD,IAAI,MAAM,CAAC,OAAO;QAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,CAAA;IAC9C,IAAI,IAAI,IAAI,QAAQ,CAAC,QAAQ;QAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,CAAC,QAAQ,GAAG,IAAI,GAAG,CAAC,EAAE,CAAA;IAClG,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,CAAA;AAC/B,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export * from './plan.ts';
2
2
  export * from './subaccounts.ts';
3
3
  export * from './shadow.ts';
4
+ export * from './ballot.ts';
4
5
  export * from './recipes.ts';
5
6
  export * from './disclosure.ts';
6
7
  export * from './wallet.ts';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,kBAAkB,CAAA;AAChC,cAAc,aAAa,CAAA;AAE3B,cAAc,cAAc,CAAA;AAC5B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,mBAAmB,CAAA;AACjC,cAAc,YAAY,CAAA;AAC1B,cAAc,cAAc,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,kBAAkB,CAAA;AAChC,cAAc,aAAa,CAAA;AAE3B,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,mBAAmB,CAAA;AACjC,cAAc,YAAY,CAAA;AAC1B,cAAc,cAAc,CAAA"}
package/dist/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  export * from "./plan.js";
2
2
  export * from "./subaccounts.js";
3
3
  export * from "./shadow.js";
4
+ export * from "./ballot.js";
4
5
  export * from "./recipes.js";
5
6
  export * from "./disclosure.js";
6
7
  export * from "./wallet.js";
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,kBAAkB,CAAA;AAChC,cAAc,aAAa,CAAA;AAE3B,cAAc,cAAc,CAAA;AAC5B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,mBAAmB,CAAA;AACjC,cAAc,YAAY,CAAA;AAC1B,cAAc,cAAc,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,kBAAkB,CAAA;AAChC,cAAc,aAAa,CAAA;AAE3B,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,mBAAmB,CAAA;AACjC,cAAc,YAAY,CAAA;AAC1B,cAAc,cAAc,CAAA"}
package/dist/plan.d.ts CHANGED
@@ -63,6 +63,16 @@ export interface PlanLimits {
63
63
  * `limits` being an argument everywhere below.
64
64
  */
65
65
  export declare const DEFAULT_LIMITS: PlanLimits;
66
+ /**
67
+ * The Starknet field prime. A felt is a residue mod this, so 2^251+17*2^192+1.
68
+ *
69
+ * Exported because a plan is not the only place a felt has to be one: an API
70
+ * route taking a commitment is a trust boundary too, and a felt over the prime
71
+ * reaches the node as a well-formed request the node then refuses with
72
+ * `Invalid params`, which the route can only report as a bad gateway. One
73
+ * definition, checked wherever a felt arrives from outside.
74
+ */
75
+ export declare const FIELD_PRIME: bigint;
66
76
  export declare function validatePlan(plan: Plan, limits?: PlanLimits): void;
67
77
  /** Tokens a step may move but no output claims. Each one must end at zero. */
68
78
  export declare function unclaimedTokens(plan: Plan): string[];
@@ -1 +1 @@
1
- {"version":3,"file":"plan.d.ts","sourceRoot":"","sources":["../src/plan.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,mEAAmE;AACnE,MAAM,MAAM,IAAI,GAAG,MAAM,GAAG,MAAM,CAAA;AAElC,MAAM,WAAW,QAAQ;IACvB,0CAA0C;IAC1C,KAAK,EAAE,IAAI,CAAA;IACX,oEAAoE;IACpE,MAAM,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,IAAI;IACnB,MAAM,EAAE,IAAI,CAAA;IACZ,6EAA6E;IAC7E,QAAQ,EAAE,IAAI,CAAA;IACd,SAAS,EAAE,QAAQ,EAAE,CAAA;IACrB,QAAQ,EAAE,IAAI,EAAE,CAAA;CACjB;AAED,MAAM,WAAW,MAAM;IACrB,KAAK,EAAE,IAAI,CAAA;IACX;;;OAGG;IACH,MAAM,EAAE,IAAI,CAAA;IACZ,0EAA0E;IAC1E,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,WAAW,IAAI;IACnB,KAAK,EAAE,IAAI,EAAE,CAAA;IACb,OAAO,EAAE,MAAM,EAAE,CAAA;CAClB;AAED,8EAA8E;AAC9E,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAK9C;AAED,6DAA6D;AAC7D,eAAO,MAAM,YAAY,mBAAmB,CAAA;AAE5C;;;;;GAKG;AACH,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,MA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AIP,MAAM,CAAC,MAAM,IAAI,WAAW;IAI5B,iFAAiF;IACjF,IAAI,CAAC,IAAI,EAAE,IAAI,GAAG,WAAW;IAI7B,gDAAgD;IAChD,QAAQ,CAAC,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,SAAK,GAAG,WAAW;IAOhE,KAAK,IAAI,IAAI;IAKb,MAAM,CAAC,WAAW,GAAE,IAAmB,GAAG,IAAI,EAAE;CAGjD"}
package/dist/plan.js CHANGED
@@ -31,8 +31,16 @@ export const POOL_ADDRESS = '${poolAddress}';
31
31
  export const DEFAULT_LIMITS = { maxSteps: 8, maxCalldata: 64 };
32
32
  /** Placeholders the wallet resolves at submit time; everything else is a felt. */
33
33
  const PLACEHOLDER = /^\$\{(?:openNoteIds\[[0-9]+\]|poolAddress)\}$/;
34
- /** The Starknet field prime. A felt is a residue mod this, so 2^251+17*2^192+1. */
35
- const FIELD_PRIME = 2n ** 251n + 17n * 2n ** 192n + 1n;
34
+ /**
35
+ * The Starknet field prime. A felt is a residue mod this, so 2^251+17*2^192+1.
36
+ *
37
+ * Exported because a plan is not the only place a felt has to be one: an API
38
+ * route taking a commitment is a trust boundary too, and a felt over the prime
39
+ * reaches the node as a well-formed request the node then refuses with
40
+ * `Invalid params`, which the route can only report as a bad gateway. One
41
+ * definition, checked wherever a felt arrives from outside.
42
+ */
43
+ export const FIELD_PRIME = 2n ** 251n + 17n * 2n ** 192n + 1n;
36
44
  /**
37
45
  * Every value in a plan is eventually a felt on the wire.
38
46
  *
@@ -78,18 +86,22 @@ export function validatePlan(plan, limits = DEFAULT_LIMITS) {
78
86
  throw new Error('minAmount cannot be negative');
79
87
  }
80
88
  for (const [i, step] of plan.steps.entries()) {
81
- checkFelt(step.target, `step ${i} target`);
82
- checkFelt(step.selector, `step ${i} selector`);
83
- step.calldata.forEach((felt, j) => checkFelt(felt, `step ${i} calldata[${j}]`));
89
+ // One-based, because every surface that shows a step calls the first one
90
+ // "Step 1". This counted from zero, so typing garbage into Step 3 was
91
+ // reported as "step 2 target is not a felt" - an error pointing at a
92
+ // different field, on a form where two steps look identical.
93
+ checkFelt(step.target, `step ${i + 1} target`);
94
+ checkFelt(step.selector, `step ${i + 1} selector`);
95
+ step.calldata.forEach((felt, j) => checkFelt(felt, `step ${i + 1} calldata[${j}]`));
84
96
  step.approvals.forEach((approval, j) => {
85
- checkFelt(approval.token, `step ${i} approval[${j}] token`);
97
+ checkFelt(approval.token, `step ${i + 1} approval[${j}] token`);
86
98
  });
87
99
  if (step.calldata.length > limits.maxCalldata) {
88
- throw new Error(`step ${i} has ${step.calldata.length} felts of calldata, the router allows ${limits.maxCalldata}`);
100
+ throw new Error(`step ${i + 1} has ${step.calldata.length} felts of calldata, the router allows ${limits.maxCalldata}`);
89
101
  }
90
102
  for (const approval of step.approvals) {
91
103
  if (approval.amount < 0n)
92
- throw new Error(`step ${i} approves a negative amount`);
104
+ throw new Error(`step ${i + 1} approves a negative amount`);
93
105
  }
94
106
  }
95
107
  // The residue rule bites here more often than anywhere else: a token a step is
package/dist/plan.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"plan.js","sourceRoot":"","sources":["../src/plan.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAoCH,8EAA8E;AAC9E,MAAM,UAAU,QAAQ,CAAC,KAAa;IACpC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;QAC1C,MAAM,IAAI,UAAU,CAAC,uDAAuD,KAAK,EAAE,CAAC,CAAA;IACtF,CAAC;IACD,OAAO,kBAAkB,KAAK,IAAI,CAAA;AACpC,CAAC;AAED,6DAA6D;AAC7D,MAAM,CAAC,MAAM,YAAY,GAAG,gBAAgB,CAAA;AAa5C;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAAe,EAAE,QAAQ,EAAE,CAAC,EAAE,WAAW,EAAE,EAAE,EAAE,CAAA;AAE1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G,EAAE,CAAA;IAC9B,OAAO,CAAC,KAAK,GAAG,IAAI,EAAE,KAAK,IAAI,IAAI,CAAC,CAAA;AACtC,CAAC;AAED,gFAAgF;AAChF,MAAM,OAAO,WAAW;IACb,IAAI,CAAM;IAEnB,YAAoB,IAAU;QAC5B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IAClB,CAAC;IAED,MAAM,CAAC,MAAM;QACX,OAAO,IAAI,WAAW,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAAA;IACpD,CAAC;IAED,iFAAiF;IACjF,IAAI,CAAC,IAAU;QACb,OAAO,IAAI,WAAW,CAAC,EAAE,GAAG,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC,CAAA;IAC7E,CAAC;IAED,gDAAgD;IAChD,QAAQ,CAAC,KAAW,EAAE,MAAY,EAAE,SAAS,GAAG,EAAE;QAChD,OAAO,IAAI,WAAW,CAAC;YACrB,GAAG,IAAI,CAAC,IAAI;YACZ,OAAO,EAAE,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;SAC9D,CAAC,CAAA;IACJ,CAAC;IAED,KAAK;QACH,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACvB,OAAO,IAAI,CAAC,IAAI,CAAA;IAClB,CAAC;IAED,MAAM,CAAC,cAAoB,YAAY;QACrC,OAAO,UAAU,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,WAAW,CAAC,CAAA;IAC9C,CAAC;CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jalin-sdk",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Plan encoding and sub-account portfolio helpers for the Jalin router on STRK20",
5
5
  "license": "MIT",
6
6
  "type": "module",