@metoncash/sdk-v1 0.2.0 → 0.2.1

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.
@@ -1,23 +1,65 @@
1
1
  /**
2
- * utils/keys.ts — wallet key generation.
2
+ * utils/keys.ts - wallet key generation.
3
3
  *
4
- * Each wallet has a SPEND key (authorizes spends; bound on-chain by address)
5
- * and a VIEW key derived one-way from it. `viewSk` decrypts incoming notes and
6
- * is safe to share with an auditor — it grants read access, not spend ability.
4
+ * Each wallet has a SPEND secret (the client-side root seed) and a VIEW key
5
+ * derived one-way from it. Only `viewPk` ever reaches the chain (Register,
6
+ * immutable once set); `viewSk` decrypts incoming notes and is safe to share
7
+ * with an auditor - it grants read access, not spend ability. There is no
8
+ * on-chain spend key: spend authority is the owner's TON address, enforced by
9
+ * the Wallet contract's sender check. `spendPk` exists for convenience only and
10
+ * is never registered or checked on-chain.
11
+ *
12
+ * Persist `spendSk` (everything else re-derives from it) and never publish it.
7
13
  */
8
14
  import { Point } from "../jubjub";
15
+ import type { SubgroupWitness, CellRef } from "../wrappers/Minter.gen";
16
+ /** A wallet's full key set. `spendSk` is the root secret; the rest derive from it. */
9
17
  export interface WalletKeys {
18
+ /** SECRET root seed in [1, L); persist it, never share it */
10
19
  spendSk: bigint;
20
+ /** sk_spend * G; not used by the protocol */
11
21
  spendPk: Point;
22
+ /** MiMC(7, spendSk) mod L, one-way from spendSk; shareable for audit */
12
23
  viewSk: bigint;
24
+ /** sk_view * G - registered on-chain, notes are encrypted to this */
13
25
  viewPk: Point;
14
26
  }
15
- /** Generate a fresh wallet keypair (random spend secret + derived view key). */
27
+ /**
28
+ * Generate a fresh wallet keypair (random spend secret + derived view key).
29
+ * The spend secret comes from randomScalar (CSPRNG, never 0), so `viewPk` is
30
+ * always a non-identity prime-order-subgroup point and passes registerWitness.
31
+ */
16
32
  export declare function generateWalletKeys(): WalletKeys;
17
- /** Derive the full key set from an existing spend secret. */
33
+ /**
34
+ * Derive the full key set from an existing spend secret (deterministic, so a
35
+ * wallet can be restored from `spendSk` alone).
36
+ * @param spendSk any integer; a sane seed is in [1, L)
37
+ */
18
38
  export declare function walletKeysFromSpend(spendSk: bigint): WalletKeys;
19
- /** Derive just the viewing keypair (read-only; shareable for audit). */
39
+ /**
40
+ * Derive just the viewing keypair (read-only; shareable for audit). Same
41
+ * derivation as walletKeysFromSpend without computing spendPk.
42
+ */
20
43
  export declare function viewKeyFromSpend(spendSk: bigint): {
21
44
  viewSk: bigint;
22
45
  viewPk: Point;
23
46
  };
47
+ /**
48
+ * The `witness` field of a `Register` message: the cofactor witness the Minter
49
+ * uses to verify `viewPk` is in the Jubjub prime-order subgroup without a
50
+ * scalar multiplication on-chain (Q = [8^-1 mod L]*pk, [2]Q, [4]Q; it checks
51
+ * [8]*Q == pk). Keys from `generateWalletKeys()` always qualify.
52
+ *
53
+ * Why the Minter insists: the transfer circuit requires every receiver key to be
54
+ * a subgroup point, and the registered key is immutable, so a torsion or
55
+ * mixed-order key would make the wallet permanently unable to receive. The
56
+ * Minter checks Q on-curve and q2 == Q (+) Q, q4 == q2 (+) q2, pk == q4 (+) q4
57
+ * with Point.verifySum (Errors.InvalidPoint on failure); the two doublings are
58
+ * shipped in refs because two points do not fit one cell.
59
+ * @param viewPk the key that goes in `Register.publicViewKey` (same message)
60
+ * @returns the `Register.witness` field, ready for the Minter wrapper
61
+ * @throws RangeError if a coordinate is not canonical (< r), the key is the
62
+ * identity, off-curve or not of prime order - the same cases the Minter
63
+ * rejects (requireField / isIdentity / isOnCurve / the doubling chain)
64
+ */
65
+ export declare function registerWitness(viewPk: Point): CellRef<SubgroupWitness>;
@@ -1,28 +1,78 @@
1
1
  "use strict";
2
2
  /**
3
- * utils/keys.ts — wallet key generation.
3
+ * utils/keys.ts - wallet key generation.
4
4
  *
5
- * Each wallet has a SPEND key (authorizes spends; bound on-chain by address)
6
- * and a VIEW key derived one-way from it. `viewSk` decrypts incoming notes and
7
- * is safe to share with an auditor — it grants read access, not spend ability.
5
+ * Each wallet has a SPEND secret (the client-side root seed) and a VIEW key
6
+ * derived one-way from it. Only `viewPk` ever reaches the chain (Register,
7
+ * immutable once set); `viewSk` decrypts incoming notes and is safe to share
8
+ * with an auditor - it grants read access, not spend ability. There is no
9
+ * on-chain spend key: spend authority is the owner's TON address, enforced by
10
+ * the Wallet contract's sender check. `spendPk` exists for convenience only and
11
+ * is never registered or checked on-chain.
12
+ *
13
+ * Persist `spendSk` (everything else re-derives from it) and never publish it.
8
14
  */
9
15
  Object.defineProperty(exports, "__esModule", { value: true });
10
16
  exports.generateWalletKeys = generateWalletKeys;
11
17
  exports.walletKeysFromSpend = walletKeysFromSpend;
12
18
  exports.viewKeyFromSpend = viewKeyFromSpend;
19
+ exports.registerWitness = registerWitness;
13
20
  const jubjub_1 = require("../jubjub");
14
21
  const note_1 = require("../note");
15
- /** Generate a fresh wallet keypair (random spend secret + derived view key). */
22
+ /**
23
+ * Generate a fresh wallet keypair (random spend secret + derived view key).
24
+ * The spend secret comes from randomScalar (CSPRNG, never 0), so `viewPk` is
25
+ * always a non-identity prime-order-subgroup point and passes registerWitness.
26
+ */
16
27
  function generateWalletKeys() {
17
28
  return walletKeysFromSpend((0, jubjub_1.randomScalar)(252));
18
29
  }
19
- /** Derive the full key set from an existing spend secret. */
30
+ /**
31
+ * Derive the full key set from an existing spend secret (deterministic, so a
32
+ * wallet can be restored from `spendSk` alone).
33
+ * @param spendSk any integer; a sane seed is in [1, L)
34
+ */
20
35
  function walletKeysFromSpend(spendSk) {
21
36
  const { skView, pkView } = (0, note_1.deriveViewKey)(spendSk);
22
37
  return { spendSk, spendPk: (0, jubjub_1.derivePub)(spendSk), viewSk: skView, viewPk: pkView };
23
38
  }
24
- /** Derive just the viewing keypair (read-only; shareable for audit). */
39
+ /**
40
+ * Derive just the viewing keypair (read-only; shareable for audit). Same
41
+ * derivation as walletKeysFromSpend without computing spendPk.
42
+ */
25
43
  function viewKeyFromSpend(spendSk) {
26
44
  const { skView, pkView } = (0, note_1.deriveViewKey)(spendSk);
27
45
  return { viewSk: skView, viewPk: pkView };
28
46
  }
47
+ /**
48
+ * The `witness` field of a `Register` message: the cofactor witness the Minter
49
+ * uses to verify `viewPk` is in the Jubjub prime-order subgroup without a
50
+ * scalar multiplication on-chain (Q = [8^-1 mod L]*pk, [2]Q, [4]Q; it checks
51
+ * [8]*Q == pk). Keys from `generateWalletKeys()` always qualify.
52
+ *
53
+ * Why the Minter insists: the transfer circuit requires every receiver key to be
54
+ * a subgroup point, and the registered key is immutable, so a torsion or
55
+ * mixed-order key would make the wallet permanently unable to receive. The
56
+ * Minter checks Q on-curve and q2 == Q (+) Q, q4 == q2 (+) q2, pk == q4 (+) q4
57
+ * with Point.verifySum (Errors.InvalidPoint on failure); the two doublings are
58
+ * shipped in refs because two points do not fit one cell.
59
+ * @param viewPk the key that goes in `Register.publicViewKey` (same message)
60
+ * @returns the `Register.witness` field, ready for the Minter wrapper
61
+ * @throws RangeError if a coordinate is not canonical (< r), the key is the
62
+ * identity, off-curve or not of prime order - the same cases the Minter
63
+ * rejects (requireField / isIdentity / isOnCurve / the doubling chain)
64
+ */
65
+ function registerWitness(viewPk) {
66
+ const [x, y] = viewPk;
67
+ // mirror the contract's checks so a bad key fails here with a clear message
68
+ if (x < 0n || x >= jubjub_1.r || y < 0n || y >= jubjub_1.r)
69
+ throw new RangeError("registerWitness: viewPk coordinates must be canonical (< r)");
70
+ if ((0, jubjub_1.isIdentity)(x, y))
71
+ throw new RangeError("registerWitness: viewPk must not be the identity");
72
+ if (!(0, jubjub_1.isInPrimeSubgroup)(x, y)) {
73
+ throw new RangeError("registerWitness: viewPk is not a Jubjub prime-order-subgroup point");
74
+ }
75
+ const { q, q2, q4 } = (0, jubjub_1.cofactorWitness)(viewPk[0], viewPk[1]);
76
+ const pt = (p) => ({ $: "Point", x: p[0], y: p[1] });
77
+ return { ref: { $: "SubgroupWitness", q: pt(q), q2: { ref: pt(q2) }, q4: { ref: pt(q4) } } };
78
+ }
@@ -1,28 +1,51 @@
1
1
  /**
2
- * utils/note.ts — seal an encrypted note for a recipient.
2
+ * utils/note.ts - seal an encrypted note for a recipient.
3
3
  *
4
4
  * "Signing" a note here means producing the sender-side ECDH-sealed payload
5
- * (R, enc_amount, enc_blind): a fresh ephemeral key R = k·G, with the amount and
6
- * blind masked by a key derived from the ECDH shared secret k·pk_view. Only the
5
+ * (R, enc_amount, enc_blind): a fresh ephemeral key R = k*G, with the amount and
6
+ * blind masked by a key derived from the ECDH shared secret k*pk_view. Only the
7
7
  * holder of the recipient's viewing secret can open it. There is no separate
8
- * signature — authenticity/secrecy come from the ECDH to the recipient's key.
8
+ * signature - authenticity/secrecy come from the ECDH to the recipient's key.
9
9
  */
10
10
  import { Point } from "../jubjub";
11
11
  import { Note } from "../note";
12
- /** Minimal note fields needed to open it (the on-chain payload). */
13
- export type SealedNote = Pick<Note, "Rx" | "Ry" | "enc_amount" | "enc_blind">;
12
+ /** The on-chain note payload (public). Kept as an alias for API stability. */
13
+ export type SealedNote = Note;
14
+ /** Inputs for sealNote. */
14
15
  export interface SealNoteArgs {
16
+ /** the amount being transferred (64-bit) */
15
17
  amount: bigint;
18
+ /** the blinding of the amount commitment the receiver will open (252-bit) */
16
19
  amountBlind: bigint;
20
+ /** recipient's registered pk_view; must be a non-identity subgroup point */
17
21
  receiverViewPk: Point;
18
- /** Ephemeral scalar k. Defaults to fresh randomness — MUST be unique per note. */
22
+ /** Ephemeral scalar k. Defaults to fresh randomness - MUST be unique per note. */
19
23
  ephScalar?: bigint;
20
24
  }
21
- /** Seal (encrypt) a note to the recipient's viewing key. */
22
- export declare function sealNote(args: SealNoteArgs): Note;
25
+ /**
26
+ * Seal (encrypt) a note to the recipient's viewing key.
27
+ *
28
+ * Returns the PUBLIC note (safe to put on-chain) and, separately, the ephemeral
29
+ * scalar that was used - a secret: never publish it, it re-derives the masks.
30
+ *
31
+ * Performs no validation of `receiverViewPk` or a caller-supplied `ephScalar`;
32
+ * `MetonSDK.transfer()` builds the same note with full checks and is the normal
33
+ * path. This helper is for callers that only need the ciphertext (tests,
34
+ * re-encryption, off-line tooling).
35
+ */
36
+ export declare function sealNote(args: SealNoteArgs): {
37
+ note: SealedNote;
38
+ ephScalar: bigint;
39
+ };
23
40
  /**
24
41
  * Open a sealed note with the recipient's viewing secret, recovering the
25
42
  * transferred amount and its blinding.
43
+ *
44
+ * Validates R (non-identity subgroup point, canonical coordinates) before
45
+ * using the secret. Does NOT check the result against the on-chain amount
46
+ * commitment - a wrong key yields garbage silently; use `viewNote` when the
47
+ * commitment is available.
48
+ * @throws Error if the note's R is malformed (see decryptNote)
26
49
  */
27
50
  export declare function openNote(viewSk: bigint, note: SealedNote): {
28
51
  amount: bigint;
@@ -1,26 +1,43 @@
1
1
  "use strict";
2
2
  /**
3
- * utils/note.ts — seal an encrypted note for a recipient.
3
+ * utils/note.ts - seal an encrypted note for a recipient.
4
4
  *
5
5
  * "Signing" a note here means producing the sender-side ECDH-sealed payload
6
- * (R, enc_amount, enc_blind): a fresh ephemeral key R = k·G, with the amount and
7
- * blind masked by a key derived from the ECDH shared secret k·pk_view. Only the
6
+ * (R, enc_amount, enc_blind): a fresh ephemeral key R = k*G, with the amount and
7
+ * blind masked by a key derived from the ECDH shared secret k*pk_view. Only the
8
8
  * holder of the recipient's viewing secret can open it. There is no separate
9
- * signature — authenticity/secrecy come from the ECDH to the recipient's key.
9
+ * signature - authenticity/secrecy come from the ECDH to the recipient's key.
10
10
  */
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.sealNote = sealNote;
13
13
  exports.openNote = openNote;
14
14
  const jubjub_1 = require("../jubjub");
15
15
  const note_1 = require("../note");
16
- /** Seal (encrypt) a note to the recipient's viewing key. */
16
+ /**
17
+ * Seal (encrypt) a note to the recipient's viewing key.
18
+ *
19
+ * Returns the PUBLIC note (safe to put on-chain) and, separately, the ephemeral
20
+ * scalar that was used - a secret: never publish it, it re-derives the masks.
21
+ *
22
+ * Performs no validation of `receiverViewPk` or a caller-supplied `ephScalar`;
23
+ * `MetonSDK.transfer()` builds the same note with full checks and is the normal
24
+ * path. This helper is for callers that only need the ciphertext (tests,
25
+ * re-encryption, off-line tooling).
26
+ */
17
27
  function sealNote(args) {
18
28
  const k = args.ephScalar ?? (0, jubjub_1.randomScalar)(252);
19
- return (0, note_1.encryptNote)(args.amount, args.amountBlind, args.receiverViewPk[0], args.receiverViewPk[1], k);
29
+ const note = (0, note_1.encryptNote)(args.amount, args.amountBlind, args.receiverViewPk[0], args.receiverViewPk[1], k);
30
+ return { note, ephScalar: k };
20
31
  }
21
32
  /**
22
33
  * Open a sealed note with the recipient's viewing secret, recovering the
23
34
  * transferred amount and its blinding.
35
+ *
36
+ * Validates R (non-identity subgroup point, canonical coordinates) before
37
+ * using the secret. Does NOT check the result against the on-chain amount
38
+ * commitment - a wrong key yields garbage silently; use `viewNote` when the
39
+ * commitment is available.
40
+ * @throws Error if the note's R is malformed (see decryptNote)
24
41
  */
25
42
  function openNote(viewSk, note) {
26
43
  return (0, note_1.decryptNote)(viewSk, note.Rx, note.Ry, note.enc_amount, note.enc_blind);
@@ -201,22 +201,48 @@ export declare const InternalInitMinter: {
201
201
  store(self: InternalInitMinter, b: c.Builder): void;
202
202
  toCell(self: InternalInitMinter): c.Cell;
203
203
  };
204
+ /**
205
+ > struct SubgroupWitness {
206
+ > q: Point
207
+ > q2: Cell<Point>
208
+ > q4: Cell<Point>
209
+ > }
210
+ */
211
+ export interface SubgroupWitness {
212
+ readonly $: 'SubgroupWitness';
213
+ q: Point;
214
+ q2: CellRef<Point>;
215
+ q4: CellRef<Point>;
216
+ }
217
+ export declare const SubgroupWitness: {
218
+ create(args: {
219
+ q: Point;
220
+ q2: CellRef<Point>;
221
+ q4: CellRef<Point>;
222
+ }): SubgroupWitness;
223
+ fromSlice(s: c.Slice): SubgroupWitness;
224
+ store(self: SubgroupWitness, b: c.Builder): void;
225
+ toCell(self: SubgroupWitness): c.Cell;
226
+ };
204
227
  /**
205
228
  > struct (0xa68f2242) Register {
206
229
  > queryId: uint64
207
230
  > publicViewKey: Point
231
+ > witness: Cell<SubgroupWitness>
208
232
  > }
209
233
  */
210
234
  export interface Register {
211
235
  readonly $: 'Register';
212
236
  queryId: uint64;
213
237
  publicViewKey: Point;
238
+ witness: CellRef<SubgroupWitness>;
214
239
  }
215
240
  export declare const Register: {
216
241
  PREFIX: number;
217
242
  create(args: {
218
243
  queryId: uint64;
219
244
  publicViewKey: Point;
245
+ witness: CellRef<SubgroupWitness>;
220
246
  }): Register;
221
247
  fromSlice(s: c.Slice): Register;
222
248
  store(self: Register, b: c.Builder): void;
@@ -449,6 +475,7 @@ export declare class Minter implements c.Contract {
449
475
  static createCellOfRegister(body: {
450
476
  queryId: uint64;
451
477
  publicViewKey: Point;
478
+ witness: CellRef<SubgroupWitness>;
452
479
  }): c.Cell;
453
480
  static createCellOfInternalWithdraw(body: {
454
481
  queryId: uint64;
@@ -481,6 +508,7 @@ export declare class Minter implements c.Contract {
481
508
  sendRegister(provider: ContractProvider, via: Sender, msgValue: coins, body: {
482
509
  queryId: uint64;
483
510
  publicViewKey: Point;
511
+ witness: CellRef<SubgroupWitness>;
484
512
  }, extraOptions?: ExtraSendOptions): Promise<void>;
485
513
  sendInternalWithdraw(provider: ContractProvider, via: Sender, msgValue: coins, body: {
486
514
  queryId: uint64;
@@ -36,7 +36,7 @@ var __importStar = (this && this.__importStar) || (function () {
36
36
  };
37
37
  })();
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.Minter = exports.Proof = exports.Point = exports.InternalFlipWalletStatus = exports.InternalRegister = exports.InternalDeposit = exports.InternalResetGas = exports.FlipWalletStatus = exports.InternalWithdraw = exports.Register = exports.InternalInitMinter = exports.MinterStorage = exports.MinterStorageAdditionalData = exports.MinterRuntimeStorage = exports.ExcessMessage = exports.JettonTransferNotification = exports.JettonTransfer = void 0;
39
+ exports.Minter = exports.Proof = exports.Point = exports.InternalFlipWalletStatus = exports.InternalRegister = exports.InternalDeposit = exports.InternalResetGas = exports.FlipWalletStatus = exports.InternalWithdraw = exports.Register = exports.SubgroupWitness = exports.InternalInitMinter = exports.MinterStorage = exports.MinterStorageAdditionalData = exports.MinterRuntimeStorage = exports.ExcessMessage = exports.JettonTransferNotification = exports.JettonTransfer = void 0;
40
40
  const c = __importStar(require("@ton/core"));
41
41
  const core_1 = require("@ton/core");
42
42
  function makeCellFrom(self, storeFn_T) {
@@ -344,6 +344,30 @@ exports.InternalInitMinter = {
344
344
  return makeCellFrom(self, exports.InternalInitMinter.store);
345
345
  }
346
346
  };
347
+ exports.SubgroupWitness = {
348
+ create(args) {
349
+ return {
350
+ $: 'SubgroupWitness',
351
+ ...args
352
+ };
353
+ },
354
+ fromSlice(s) {
355
+ return {
356
+ $: 'SubgroupWitness',
357
+ q: exports.Point.fromSlice(s),
358
+ q2: loadCellRef(s, exports.Point.fromSlice),
359
+ q4: loadCellRef(s, exports.Point.fromSlice),
360
+ };
361
+ },
362
+ store(self, b) {
363
+ exports.Point.store(self.q, b);
364
+ storeCellRef(self.q2, b, exports.Point.store);
365
+ storeCellRef(self.q4, b, exports.Point.store);
366
+ },
367
+ toCell(self) {
368
+ return makeCellFrom(self, exports.SubgroupWitness.store);
369
+ }
370
+ };
347
371
  exports.Register = {
348
372
  PREFIX: 0xa68f2242,
349
373
  create(args) {
@@ -358,12 +382,14 @@ exports.Register = {
358
382
  $: 'Register',
359
383
  queryId: s.loadUintBig(64),
360
384
  publicViewKey: exports.Point.fromSlice(s),
385
+ witness: loadCellRef(s, exports.SubgroupWitness.fromSlice),
361
386
  };
362
387
  },
363
388
  store(self, b) {
364
389
  b.storeUint(0xa68f2242, 32);
365
390
  b.storeUint(self.queryId, 64);
366
391
  exports.Point.store(self.publicViewKey, b);
392
+ storeCellRef(self.witness, b, exports.SubgroupWitness.store);
367
393
  },
368
394
  toCell(self) {
369
395
  return makeCellFrom(self, exports.Register.store);
@@ -28,6 +28,7 @@ export declare const ExcessMessage: {
28
28
  /**
29
29
  > struct WalletRuntimeStorage {
30
30
  > locked: bool
31
+ > onlySender: bool
31
32
  > minter: address
32
33
  > owner: address
33
34
  > seqNo: uint32
@@ -38,6 +39,7 @@ export declare const ExcessMessage: {
38
39
  export interface WalletRuntimeStorage {
39
40
  readonly $: 'WalletRuntimeStorage';
40
41
  locked: boolean;
42
+ onlySender: boolean;
41
43
  minter: c.Address;
42
44
  owner: c.Address;
43
45
  seqNo: uint32;
@@ -47,6 +49,7 @@ export interface WalletRuntimeStorage {
47
49
  export declare const WalletRuntimeStorage: {
48
50
  create(args: {
49
51
  locked: boolean;
52
+ onlySender: boolean;
50
53
  minter: c.Address;
51
54
  owner: c.Address;
52
55
  seqNo: uint32;
@@ -60,6 +63,7 @@ export declare const WalletRuntimeStorage: {
60
63
  /**
61
64
  > struct WalletStorage {
62
65
  > locked: bool
66
+ > onlySender: bool
63
67
  > minter: address
64
68
  > owner: address
65
69
  > seqNo: uint32
@@ -70,6 +74,7 @@ export declare const WalletRuntimeStorage: {
70
74
  export interface WalletStorage {
71
75
  readonly $: 'WalletStorage';
72
76
  locked: boolean;
77
+ onlySender: boolean;
73
78
  minter: c.Address;
74
79
  owner: c.Address;
75
80
  seqNo: uint32;
@@ -79,6 +84,7 @@ export interface WalletStorage {
79
84
  export declare const WalletStorage: {
80
85
  create(args: {
81
86
  locked?: boolean;
87
+ onlySender?: boolean;
82
88
  minter: c.Address;
83
89
  owner: c.Address;
84
90
  seqNo?: uint32;
@@ -311,6 +317,27 @@ export declare const InitWithdraw: {
311
317
  store(self: InitWithdraw, b: c.Builder): void;
312
318
  toCell(self: InitWithdraw): c.Cell;
313
319
  };
320
+ /**
321
+ > struct (0x5b9a6a02) FlipOnlySender {
322
+ > queryId: uint64
323
+ > excess: address
324
+ > }
325
+ */
326
+ export interface FlipOnlySender {
327
+ readonly $: 'FlipOnlySender';
328
+ queryId: uint64;
329
+ excess: c.Address;
330
+ }
331
+ export declare const FlipOnlySender: {
332
+ PREFIX: number;
333
+ create(args: {
334
+ queryId: uint64;
335
+ excess: c.Address;
336
+ }): FlipOnlySender;
337
+ fromSlice(s: c.Slice): FlipOnlySender;
338
+ store(self: FlipOnlySender, b: c.Builder): void;
339
+ toCell(self: FlipOnlySender): c.Cell;
340
+ };
314
341
  /**
315
342
  > struct (0xdde0f974) InternalRegister {
316
343
  > queryId: uint64
@@ -472,6 +499,7 @@ export declare class Wallet implements c.Contract {
472
499
  'Errors.InvalidProof': number;
473
500
  'Errors.InvalidAmount': number;
474
501
  'Errors.AlreadyInitialized': number;
502
+ 'Errors.ReceiveDisabled': number;
475
503
  'Errors.NotAlreadyInitialized': number;
476
504
  'Errors.NotEnoughGas': number;
477
505
  'Errors.InvalidPoint': number;
@@ -533,6 +561,10 @@ export declare class Wallet implements c.Contract {
533
561
  queryId: uint64;
534
562
  excess: c.Address;
535
563
  }): c.Cell;
564
+ static createCellOfFlipOnlySender(body: {
565
+ queryId: uint64;
566
+ excess: c.Address;
567
+ }): c.Cell;
536
568
  sendDeploy(provider: ContractProvider, via: Sender, msgValue: coins, extraOptions?: ExtraSendOptions): Promise<void>;
537
569
  sendInternalDeposit(provider: ContractProvider, via: Sender, msgValue: coins, body: {
538
570
  queryId: uint64;
@@ -577,6 +609,10 @@ export declare class Wallet implements c.Contract {
577
609
  queryId: uint64;
578
610
  excess: c.Address;
579
611
  }, extraOptions?: ExtraSendOptions): Promise<void>;
612
+ sendFlipOnlySender(provider: ContractProvider, via: Sender, msgValue: coins, body: {
613
+ queryId: uint64;
614
+ excess: c.Address;
615
+ }, extraOptions?: ExtraSendOptions): Promise<void>;
580
616
  getWalletState(provider: ContractProvider): Promise<WalletRuntimeStorage>;
581
617
  getWalletData(provider: ContractProvider): Promise<[
582
618
  bigint,
@@ -36,7 +36,7 @@ var __importStar = (this && this.__importStar) || (function () {
36
36
  };
37
37
  })();
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.Wallet = exports.InternalWithdraw = exports.Proof = exports.Point = exports.TransferNotification = exports.InternalFlipWalletStatus = exports.InternalRegister = exports.InitWithdraw = exports.InternalDeposit = exports.TransferCallback = exports.InternalTransfer = exports.InternalTransferAdditionalData = exports.InitTransfer = exports.TransferAdditionalData = exports.TransferAdditionalData2 = exports.WalletStorage = exports.WalletRuntimeStorage = exports.ExcessMessage = void 0;
39
+ exports.Wallet = exports.InternalWithdraw = exports.Proof = exports.Point = exports.TransferNotification = exports.InternalFlipWalletStatus = exports.InternalRegister = exports.FlipOnlySender = exports.InitWithdraw = exports.InternalDeposit = exports.TransferCallback = exports.InternalTransfer = exports.InternalTransferAdditionalData = exports.InitTransfer = exports.TransferAdditionalData = exports.TransferAdditionalData2 = exports.WalletStorage = exports.WalletRuntimeStorage = exports.ExcessMessage = void 0;
40
40
  const c = __importStar(require("@ton/core"));
41
41
  const core_1 = require("@ton/core");
42
42
  function makeCellFrom(self, storeFn_T) {
@@ -152,6 +152,7 @@ exports.WalletRuntimeStorage = {
152
152
  return {
153
153
  $: 'WalletRuntimeStorage',
154
154
  locked: s.loadBoolean(),
155
+ onlySender: s.loadBoolean(),
155
156
  minter: s.loadAddress(),
156
157
  owner: s.loadAddress(),
157
158
  seqNo: s.loadUintBig(32),
@@ -161,6 +162,7 @@ exports.WalletRuntimeStorage = {
161
162
  },
162
163
  store(self, b) {
163
164
  b.storeBit(self.locked);
165
+ b.storeBit(self.onlySender);
164
166
  b.storeAddress(self.minter);
165
167
  b.storeAddress(self.owner);
166
168
  b.storeUint(self.seqNo, 32);
@@ -176,6 +178,7 @@ exports.WalletStorage = {
176
178
  return {
177
179
  $: 'WalletStorage',
178
180
  locked: false,
181
+ onlySender: false,
179
182
  seqNo: 0n,
180
183
  ...args
181
184
  };
@@ -184,6 +187,7 @@ exports.WalletStorage = {
184
187
  return {
185
188
  $: 'WalletStorage',
186
189
  locked: s.loadBoolean(),
190
+ onlySender: s.loadBoolean(),
187
191
  minter: s.loadAddress(),
188
192
  owner: s.loadAddress(),
189
193
  seqNo: s.loadUintBig(32),
@@ -193,6 +197,7 @@ exports.WalletStorage = {
193
197
  },
194
198
  store(self, b) {
195
199
  b.storeBit(self.locked);
200
+ b.storeBit(self.onlySender);
196
201
  b.storeAddress(self.minter);
197
202
  b.storeAddress(self.owner);
198
203
  b.storeUint(self.seqNo, 32);
@@ -432,6 +437,31 @@ exports.InitWithdraw = {
432
437
  return makeCellFrom(self, exports.InitWithdraw.store);
433
438
  }
434
439
  };
440
+ exports.FlipOnlySender = {
441
+ PREFIX: 0x5b9a6a02,
442
+ create(args) {
443
+ return {
444
+ $: 'FlipOnlySender',
445
+ ...args
446
+ };
447
+ },
448
+ fromSlice(s) {
449
+ loadAndCheckPrefix32(s, 0x5b9a6a02, 'FlipOnlySender');
450
+ return {
451
+ $: 'FlipOnlySender',
452
+ queryId: s.loadUintBig(64),
453
+ excess: s.loadAddress(),
454
+ };
455
+ },
456
+ store(self, b) {
457
+ b.storeUint(0x5b9a6a02, 32);
458
+ b.storeUint(self.queryId, 64);
459
+ b.storeAddress(self.excess);
460
+ },
461
+ toCell(self) {
462
+ return makeCellFrom(self, exports.FlipOnlySender.store);
463
+ }
464
+ };
435
465
  exports.InternalRegister = {
436
466
  PREFIX: 0xdde0f974,
437
467
  create(args) {
@@ -615,6 +645,9 @@ class Wallet {
615
645
  static createCellOfInternalFlipWalletStatus(body) {
616
646
  return exports.InternalFlipWalletStatus.toCell(exports.InternalFlipWalletStatus.create(body));
617
647
  }
648
+ static createCellOfFlipOnlySender(body) {
649
+ return exports.FlipOnlySender.toCell(exports.FlipOnlySender.create(body));
650
+ }
618
651
  async sendDeploy(provider, via, msgValue, extraOptions) {
619
652
  return provider.internal(via, {
620
653
  value: msgValue,
@@ -671,11 +704,19 @@ class Wallet {
671
704
  ...extraOptions
672
705
  });
673
706
  }
707
+ async sendFlipOnlySender(provider, via, msgValue, body, extraOptions) {
708
+ return provider.internal(via, {
709
+ value: msgValue,
710
+ body: exports.FlipOnlySender.toCell(exports.FlipOnlySender.create(body)),
711
+ ...extraOptions
712
+ });
713
+ }
674
714
  async getWalletState(provider) {
675
- const r = StackReader.fromGetMethod(8, await provider.get('getWalletState', []));
715
+ const r = StackReader.fromGetMethod(9, await provider.get('getWalletState', []));
676
716
  return ({
677
717
  $: 'WalletRuntimeStorage',
678
718
  locked: r.readBoolean(),
719
+ onlySender: r.readBoolean(),
679
720
  minter: r.readSlice().loadAddress(),
680
721
  owner: r.readSlice().loadAddress(),
681
722
  seqNo: r.readBigInt(),
@@ -710,6 +751,7 @@ Wallet.Errors = {
710
751
  'Errors.InvalidProof': 519,
711
752
  'Errors.InvalidAmount': 3775,
712
753
  'Errors.AlreadyInitialized': 16689,
754
+ 'Errors.ReceiveDisabled': 22023,
713
755
  'Errors.NotAlreadyInitialized': 22161,
714
756
  'Errors.NotEnoughGas': 29432,
715
757
  'Errors.InvalidPoint': 37828,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metoncash/sdk-v1",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",