@sig-net/midnight 0.27.0-rc.3 → 0.27.0-rc.5

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 (65) hide show
  1. package/README.md +4 -3
  2. package/dist/abi-serde.d.ts +18 -0
  3. package/dist/abi-serde.d.ts.map +1 -1
  4. package/dist/abi-serde.js +28 -0
  5. package/dist/abi-serde.js.map +1 -1
  6. package/dist/compact-descriptors.d.ts +6 -5
  7. package/dist/compact-descriptors.d.ts.map +1 -1
  8. package/dist/compact-descriptors.js +4 -4
  9. package/dist/compact-descriptors.js.map +1 -1
  10. package/dist/constants.d.ts +2 -2
  11. package/dist/constants.js +2 -2
  12. package/dist/ecdsa-attestation.d.ts +2 -1
  13. package/dist/ecdsa-attestation.d.ts.map +1 -1
  14. package/dist/ecdsa-attestation.js +4 -1
  15. package/dist/ecdsa-attestation.js.map +1 -1
  16. package/dist/epsilon-derivation.d.ts +8 -8
  17. package/dist/epsilon-derivation.js +7 -7
  18. package/dist/index.d.ts +3 -2
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.js +3 -2
  21. package/dist/index.js.map +1 -1
  22. package/dist/managed/compiler/contract-info.json +181 -0
  23. package/dist/managed/compiler/contract-manifest.json +16 -8
  24. package/dist/managed/contract/index.d.ts +48 -0
  25. package/dist/managed/contract/index.js +561 -349
  26. package/dist/managed/contract/index.js.map +2 -2
  27. package/dist/managed/zkir/assertTronExpirationWindowV1.zkir +63 -0
  28. package/dist/signature-requests-state-reader.d.ts +16 -10
  29. package/dist/signature-requests-state-reader.d.ts.map +1 -1
  30. package/dist/signature-requests-state-reader.js +31 -13
  31. package/dist/signature-requests-state-reader.js.map +1 -1
  32. package/dist/signature-response-verification.d.ts +52 -7
  33. package/dist/signature-response-verification.d.ts.map +1 -1
  34. package/dist/signature-response-verification.js +63 -13
  35. package/dist/signature-response-verification.js.map +1 -1
  36. package/dist/signet-contract-events.d.ts +1 -1
  37. package/dist/signet-request-id.js +3 -3
  38. package/dist/signet-request-id.js.map +1 -1
  39. package/dist/signet-request-response-reader.d.ts +112 -34
  40. package/dist/signet-request-response-reader.d.ts.map +1 -1
  41. package/dist/signet-request-response-reader.js +279 -96
  42. package/dist/signet-request-response-reader.js.map +1 -1
  43. package/dist/signet-requests.d.ts +9 -5
  44. package/dist/signet-requests.d.ts.map +1 -1
  45. package/dist/signet-requests.js +6 -2
  46. package/dist/signet-requests.js.map +1 -1
  47. package/dist/signet-tron-record-decoding.d.ts +2 -0
  48. package/dist/signet-tron-record-decoding.d.ts.map +1 -1
  49. package/dist/signet-tron-record-decoding.js +2 -0
  50. package/dist/signet-tron-record-decoding.js.map +1 -1
  51. package/dist/signet-tron-requests.d.ts +7 -3
  52. package/dist/signet-tron-requests.d.ts.map +1 -1
  53. package/dist/signet-tron-requests.js +6 -2
  54. package/dist/signet-tron-requests.js.map +1 -1
  55. package/dist/tron-node-api.d.ts +83 -0
  56. package/dist/tron-node-api.d.ts.map +1 -0
  57. package/dist/tron-node-api.js +134 -0
  58. package/dist/tron-node-api.js.map +1 -0
  59. package/dist/tron-transactions.d.ts +38 -1
  60. package/dist/tron-transactions.d.ts.map +1 -1
  61. package/dist/tron-transactions.js +35 -0
  62. package/dist/tron-transactions.js.map +1 -1
  63. package/package.json +2 -2
  64. package/src/Signet.compact +79 -10
  65. package/src/circuits.compact +9 -0
@@ -1 +1 @@
1
- {"version":3,"file":"signet-requests.d.ts","sourceRoot":"","sources":["../src/signet-requests.ts"],"names":[],"mappings":"AAWA,OAAO,EACL,KAAK,WAAW,EAGjB,MAAM,iCAAiC,CAAC;AAGzC,OAAO,EAKL,KAAK,eAAe,EAErB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AACvE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAG9D,YAAY,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,0BAA0B,CA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,CAAC,CAAC,iBAAiB,CAAC,EAAE,IAAI,CAAC;CACpC,CAAC;AAEF,wEAAwE;AACxE,MAAM,MAAM,2BAA2B,GAAG,GAAG,CAAC,YAAY,EAAE,yBAAyB,CAAC,CAAC;AAEvF;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,SAAS,EAAE,SAAS,GAAG,YAAY,CAE/D;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,CAM7D;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,EAAE,EAAE,YAAY,GAAG,SAAS,CAE1D;AAED;;;GAGG;AACH,eAAO,MAAM,UAAU,KAAK,CAAC;AAE7B;;;;;;;;GAQG;AACH,wBAAgB,6BAA6B,CAC3C,WAAW,EAAE,QAAQ,CAAC,CAAC,SAAS,EAAE,yBAAyB,CAAC,CAAC,GAC5D,2BAA2B,CAM7B"}
@@ -66,17 +66,21 @@ export const MPCDestination = {
66
66
  reserved: 1,
67
67
  };
68
68
  /**
69
+ * Type guard: narrow a request record to the evmType2 decomposition by its tag.
70
+ *
69
71
  * @param request - The request record
70
72
  * @returns `true` iff the record is tagged {@link TxParamType.evmType2}
71
73
  */
72
- export function isEvmType2SignBidirectionalEvent(request) {
74
+ export function isEvmRequest(request) {
73
75
  return request.txParamType === TxParamType.evmType2;
74
76
  }
75
77
  /**
78
+ * Type guard: narrow a request record to the Tron decomposition by its tag.
79
+ *
76
80
  * @param request - The request record
77
81
  * @returns `true` iff the record is tagged {@link TxParamType.tron}
78
82
  */
79
- export function isTronSignBidirectionalEvent(request) {
83
+ export function isTronRequest(request) {
80
84
  return request.txParamType === TxParamType.tron;
81
85
  }
82
86
  // ---- Runtime descriptor toolkit (TS twin of the compiled struct codecs) ----
@@ -1 +1 @@
1
- {"version":3,"file":"signet-requests.js","sourceRoot":"","sources":["../src/signet-requests.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,4EAA4E;AAC5E,4EA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AQ;QAChB,2BAA2B,EAAE,IAAI,gBAAgB,CAAC,wBAAwB,CAAC;QAC3E,0BAA0B,EAAE,IAAI,gBAAgB,CAAC,uBAAuB,CAAC;KAC1E,CAAC,CAAC;AACL,CAAC;AA4CD;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,SAAoB;IAC/C,OAAO,UAAU,CAAC,SAAS,CAAiB,CAAC;AAC/C,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAa;IAC7C,MAAM,GAAG,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;IACpD,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QAChC,MAAM,IAAI,KAAK,CAAC,qCAAqC,KAAK,GAAG,CAAC,CAAC;IACjE,CAAC;IACD,OAAO,GAAmB,CAAC;AAC7B,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAAC,EAAgB;IAC7C,OAAO,UAAU,CAAC,EAAE,CAAC,CAAC;AACxB,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,EAAE,CAAC;AAE7B;;;;;;;;GAQG;AACH,MAAM,UAAU,6BAA6B,CAC3C,WAA6D;IAE7D,MAAM,KAAK,GAAgC,IAAI,GAAG,EAAE,CAAC;IACrD,KAAK,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,IAAI,WAAW,EAAE,CAAC;QAC/C,KAAK,CAAC,GAAG,CAAC,YAAY,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,CAAC;IAC9C,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -2,6 +2,8 @@ import type { AlignedValue } from "@midnight-ntwrk/compact-runtime";
2
2
  import type { SignBidirectionalEvent } from "./signet-requests.ts";
3
3
  import { type TronTxParams } from "./signet-tron-requests.ts";
4
4
  /**
5
+ * Decode a stored Tron request record cell, reading its schema widths from the cell.
6
+ *
5
7
  * @param cell - The record cell as stored (value atoms plus alignment)
6
8
  * @param what - Error-message subject
7
9
  * @returns The decoded record
@@ -1 +1 @@
1
- {"version":3,"file":"signet-tron-record-decoding.d.ts","sourceRoot":"","sources":["../src/signet-tron-record-decoding.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAGpE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAwC,KAAK,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAMpG;;;;;GAKG;AACH,wBAAgB,gCAAgC,CAC9C,IAAI,EAAE,YAAY,EAClB,IAAI,EAAE,MAAM,GACX,sBAAsB,CAAC,YAAY,CAAC,CA0BtC"}
1
+ {"version":3,"file":"signet-tron-record-decoding.d.ts","sourceRoot":"","sources":["../src/signet-tron-record-decoding.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAGpE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAwC,KAAK,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAMpG;;;;;;;GAOG;AACH,wBAAgB,gCAAgC,CAC9C,IAAI,EAAE,YAAY,EAClB,IAAI,EAAE,MAAM,GACX,sBAAsB,CAAC,YAAY,CAAC,CA0BtC"}
@@ -4,6 +4,8 @@ const TRON_FIXED_ATOMS = 20;
4
4
  const TRON_HEAD_ATOMS = 15;
5
5
  const TRON_TAIL_ATOMS = 5;
6
6
  /**
7
+ * Decode a stored Tron request record cell, reading its schema widths from the cell.
8
+ *
7
9
  * @param cell - The record cell as stored (value atoms plus alignment)
8
10
  * @param what - Error-message subject
9
11
  * @returns The decoded record
@@ -1 +1 @@
1
- {"version":3,"file":"signet-tron-record-decoding.js","sourceRoot":"","sources":["../src/signet-tron-record-decoding.ts"],"names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AwB,KAAK,SAAS,IAAI,uBAAuB,KAAK,SAAS,EAAE,CAAC;QACpF,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,wCAAwC,CAAC,CAAC;IACnE,CAAC;IACD,OAAO,aAAa,CAClB,oCAAoC,CAClC,IAAI,GAAG,eAAe,EACtB,wBAAwB,EACxB,uBAAuB,CACxB,EACD,IAAI,CAAC,KAAK,EACV,IAAI,CACL,CAAC;AACJ,CAAC"}
@@ -2,9 +2,7 @@ import { type CompactType } from "@midnight-ntwrk/compact-runtime";
2
2
  import { type Maybe } from "./compact-descriptors.ts";
3
3
  import { type EvmCalldata } from "./signet-evtype2tx-requests.ts";
4
4
  import { type SignBidirectionalEvent } from "./signet-requests.ts";
5
- /** */
6
- export declare const TRON_CAIP2_ID = "tron:mainnet";
7
- /** */
5
+ /** The Tron transaction decomposition of a request (Compact: `TronTxParams`): a TriggerSmartContract call. */
8
6
  export interface TronTxParams {
9
7
  refBlockBytes: Uint8Array;
10
8
  refBlockHash: Uint8Array;
@@ -16,11 +14,15 @@ export interface TronTxParams {
16
14
  calldata: Maybe<EvmCalldata>;
17
15
  }
18
16
  /**
17
+ * Runtime descriptor of {@link TronTxParams} at a calldata word capacity.
18
+ *
19
19
  * @param maxCalldataWords - Calldata word capacity
20
20
  * @returns The tx-params descriptor
21
21
  */
22
22
  export declare function tronTxParamsDescriptor(maxCalldataWords: number): CompactType<TronTxParams>;
23
23
  /**
24
+ * Runtime descriptor of a Tron request record at the given capacities.
25
+ *
24
26
  * @param maxCalldataWords - Calldata word capacity
25
27
  * @param lenOutputDeserialization - Declared byte width of `outputDeserializationSchema` (Compact `#LenOutputDeserialization`)
26
28
  * @param lenRespondSerialization - Declared byte width of `respondSerializationSchema` (Compact `#LenRespondSerialization`)
@@ -28,6 +30,8 @@ export declare function tronTxParamsDescriptor(maxCalldataWords: number): Compac
28
30
  */
29
31
  export declare function tronSignBidirectionalEventDescriptor(maxCalldataWords: number, lenOutputDeserialization: number, lenRespondSerialization: number): CompactType<SignBidirectionalEvent<TronTxParams>>;
30
32
  /**
33
+ * Digest a Tron decomposition over its used calldata words: the TS twin of the `calculateTronTxParamsDigestV1` circuit.
34
+ *
31
35
  * @param txParams - The transaction decomposition to digest, at any capacity
32
36
  * @returns The 32-byte digest
33
37
  * @throws {Error} When the calldata word count exceeds its capacity
@@ -1 +1 @@
1
- {"version":3,"file":"signet-tron-requests.d.ts","sourceRoot":"","sources":["../src/signet-tron-requests.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,WAAW,EAGjB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAWL,KAAK,KAAK,EAGX,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,KAAK,WAAW,EAAyB,MAAM,gCAAgC,CAAC;AACzF,OAAO,EACL,KAAK,sBAAsB,EAE5B,MAAM,sBAAsB,CAAC;AAE9B,MAAM;AACN,eAAO,MAAM,aAAa,iBAAiB,CAAC;AAE5C,MAAM;AACN,MAAM,WAAW,YAAY;IAC3B,aAAa,EAAE,UAAU,CAAC;IAC1B,YAAY,EAAE,UAAU,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe,EAAE,UAAU,CAAC;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC;CAC9B;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,gBAAgB,EAAE,MAAM,GAAG,WAAW,CAAC,YAAY,CAAC,CAW1F;AAED;;;;;GAKG;AACH,wBAAgB,oCAAoC,CAClD,gBAAgB,EAAE,MAAM,EACxB,wBAAwB,EAAE,MAAM,EAChC,uBAAuB,EAAE,MAAM,GAC9B,WAAW,CAAC,sBAAsB,CAAC,YAAY,CAAC,CAAC,CAMnD;AA8BD;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,QAAQ,EAAE,YAAY,GAAG,UAAU,CAwB9E"}
1
+ {"version":3,"file":"signet-tron-requests.d.ts","sourceRoot":"","sources":["../src/signet-tron-requests.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,WAAW,EAGjB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAWL,KAAK,KAAK,EAGX,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,KAAK,WAAW,EAAyB,MAAM,gCAAgC,CAAC;AACzF,OAAO,EACL,KAAK,sBAAsB,EAE5B,MAAM,sBAAsB,CAAC;AAE9B,8GAA8G;AAC9G,MAAM,WAAW,YAAY;IAC3B,aAAa,EAAE,UAAU,CAAC;IAC1B,YAAY,EAAE,UAAU,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe,EAAE,UAAU,CAAC;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC;CAC9B;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,gBAAgB,EAAE,MAAM,GAAG,WAAW,CAAC,YAAY,CAAC,CAW1F;AAED;;;;;;;GAOG;AACH,wBAAgB,oCAAoC,CAClD,gBAAgB,EAAE,MAAM,EACxB,wBAAwB,EAAE,MAAM,EAChC,uBAAuB,EAAE,MAAM,GAC9B,WAAW,CAAC,sBAAsB,CAAC,YAAY,CAAC,CAAC,CAMnD;AA8BD;;;;;;GAMG;AACH,wBAAgB,2BAA2B,CAAC,QAAQ,EAAE,YAAY,GAAG,UAAU,CAwB9E"}
@@ -3,9 +3,9 @@ import { BOOLEAN, BYTES_2, BYTES_4, BYTES_8, BYTES_21, compactMaybeDescriptor, c
3
3
  import { HashDomain } from "./managed/contract/index.js";
4
4
  import { evmCalldataDescriptor } from "./signet-evtype2tx-requests.js";
5
5
  import { signBidirectionalEventDescriptorWith, } from "./signet-requests.js";
6
- /** */
7
- export const TRON_CAIP2_ID = "tron:mainnet";
8
6
  /**
7
+ * Runtime descriptor of {@link TronTxParams} at a calldata word capacity.
8
+ *
9
9
  * @param maxCalldataWords - Calldata word capacity
10
10
  * @returns The tx-params descriptor
11
11
  */
@@ -22,6 +22,8 @@ export function tronTxParamsDescriptor(maxCalldataWords) {
22
22
  });
23
23
  }
24
24
  /**
25
+ * Runtime descriptor of a Tron request record at the given capacities.
26
+ *
25
27
  * @param maxCalldataWords - Calldata word capacity
26
28
  * @param lenOutputDeserialization - Declared byte width of `outputDeserializationSchema` (Compact `#LenOutputDeserialization`)
27
29
  * @param lenRespondSerialization - Declared byte width of `respondSerializationSchema` (Compact `#LenRespondSerialization`)
@@ -44,6 +46,8 @@ const TRON_DIGEST_HEAD = compactTupleDescriptor([
44
46
  UINT_16,
45
47
  ]);
46
48
  /**
49
+ * Digest a Tron decomposition over its used calldata words: the TS twin of the `calculateTronTxParamsDigestV1` circuit.
50
+ *
47
51
  * @param txParams - The transaction decomposition to digest, at any capacity
48
52
  * @returns The 32-byte digest
49
53
  * @throws {Error} When the calldata word count exceeds its capacity
@@ -1 +1 @@
1
- {"version":3,"file":"signet-tron-requests.js","sourceRoot":"","sources":["../src/signet-tron-requests.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,aAAa,EACb,oBAAoB,GACrB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EACL,OAAO,EACP,OAAO,EACP,OAAO,EACP,OAAO,EACP,QAAQ,EACR,sBAAsB,EACtB,uBAAuB,EACvB,sBAAsB,EACtB,qBAAqB,EACrB,WAAW,EAEX,OAAO,EACP,OAAO,GACR,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAoB,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AACzF,OAAO,EAEL,oCAAoC,GACrC,MAAM,sBAAsB,CAAC;AAE9B,MAAM;AACN,MAAM,CAAC,MAAM,aAAa,GAAG,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C,gBAAgB,EAAE;QACxC,UAAU,CAAC,YAAY;QACvB,QAAQ,CAAC,aAAa;QACtB,QAAQ,CAAC,YAAY;QACrB,QAAQ,CAAC,SAAS;QAClB,QAAQ,CAAC,UAAU;QACnB,QAAQ,CAAC,QAAQ;QACjB,QAAQ,CAAC,eAAe;QACxB,QAAQ,CAAC,SAAS;QAClB,QAAQ,CAAC,OAAO;QAChB,QAAQ;QACR,OAAO;KACR,CAAC,CAAC;IACH,KAAK,MAAM,IAAI,IAAI,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC;QAClE,GAAG,GAAG,aAAa,CAAC,qBAAqB,EAAE,CAAC,UAAU,CAAC,UAAU,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC;IACjF,CAAC;IACD,OAAO,oBAAoB,CAAC,GAAG,CAAC,CAAC;AACnC,CAAC"}
@@ -0,0 +1,83 @@
1
+ import type { JsonValue } from "./abi-serde.ts";
2
+ /** The TaPoS reference fields of a Tron transaction, naming the block it is built on. */
3
+ export interface TronTaposReference {
4
+ /** Bytes 6..8 of the block number, big-endian: the number modulo 65536. */
5
+ readonly refBlockBytes: Uint8Array;
6
+ /** Bytes 8..16 of the block id. */
7
+ readonly refBlockHash: Uint8Array;
8
+ }
9
+ /**
10
+ * The TaPoS reference to a block, as java-tron builds it and the MPC resolves it.
11
+ *
12
+ * @param blockNumber - The block's number
13
+ * @param blockId - The block's 32-byte id
14
+ * @returns The reference fields
15
+ * @throws {Error} If the block id is not 32 bytes or the number does not fit 64 bits
16
+ */
17
+ export declare function tronTaposReference(blockNumber: bigint, blockId: Uint8Array): TronTaposReference;
18
+ /** A solidified block a request can reference, with the time its timestamp field should follow. */
19
+ export interface TronReferenceBlock extends TronTaposReference {
20
+ readonly number: bigint;
21
+ readonly blockId: Uint8Array;
22
+ /** The block's timestamp in milliseconds. */
23
+ readonly timestamp: bigint;
24
+ }
25
+ /**
26
+ * The solidified head (`/walletsolidity/getnowblock`) as a reference block. A solidified block
27
+ * cannot be reorganised away, so a transaction referencing it stays includable until it expires;
28
+ * one referencing an unsolidified head can name a block the chain drops, which the MPC signs but
29
+ * never answers.
30
+ *
31
+ * @param rpcUrl - The java-tron HTTP API base URL
32
+ * @returns The solidified head and its TaPoS reference
33
+ * @throws {Error} If the node cannot be reached or answers without a block
34
+ */
35
+ export declare function getSolidifiedTronReferenceBlock(rpcUrl: string): Promise<TronReferenceBlock>;
36
+ /** How the node took a broadcast it did not refuse. */
37
+ export declare enum TronBroadcastOutcome {
38
+ /** The node accepted the transaction now. */
39
+ Accepted = 0,
40
+ /**
41
+ * `DUP_TRANSACTION_ERROR`: the node already holds a transaction with this id, so an earlier
42
+ * broadcast (by anyone: the bytes are the same) reached it.
43
+ */
44
+ AlreadyKnown = 1
45
+ }
46
+ /**
47
+ * Broadcasts a signed transaction (`/wallet/broadcasthex`). A duplicate is not an error: the
48
+ * signed bytes are public once the MPC posts the signature, so another client may have sent them.
49
+ *
50
+ * @param rpcUrl - The java-tron HTTP API base URL
51
+ * @param signedTransaction - The signed `Transaction` protobuf bytes
52
+ * @returns Whether this call submitted it or the node already had it
53
+ * @throws {Error} If the node refuses it (for example `TRANSACTION_EXPIRATION_ERROR` once its
54
+ * expiration has passed, or `SERVER_BUSY`, which a caller may retry with the same bytes)
55
+ */
56
+ export declare function broadcastTronTransaction(rpcUrl: string, signedTransaction: Uint8Array): Promise<TronBroadcastOutcome>;
57
+ /** A final (solidified) Tron transaction receipt: what the MPC attests from. */
58
+ export interface TronTransactionReceipt {
59
+ readonly id: Uint8Array;
60
+ readonly blockNumber: bigint;
61
+ /** The block's timestamp in milliseconds. */
62
+ readonly blockTimestamp: bigint;
63
+ /** The total fee in sun. */
64
+ readonly fee: bigint;
65
+ /** `TransactionInfo.code`: java-tron prints it only on failure (`FAILED`). */
66
+ readonly result: string | undefined;
67
+ /** `receipt.result`, the VM's contract result (`SUCCESS`, `REVERT`, `OUT_OF_ENERGY`, ...). */
68
+ readonly receiptResult: string | undefined;
69
+ /** The top call's return data, the output the MPC attests. */
70
+ readonly contractResult: readonly Uint8Array[];
71
+ /** The node's answer as is, for `evmTraceOutputFromTronReceipt`. */
72
+ readonly body: JsonValue;
73
+ }
74
+ /**
75
+ * The final receipt of a transaction (`/walletsolidity/gettransactioninfobyid`).
76
+ *
77
+ * @param rpcUrl - The java-tron HTTP API base URL
78
+ * @param txId - The 32-byte transaction id
79
+ * @returns The receipt, or `undefined` while the transaction is not in a solidified block
80
+ * @throws {Error} If the node cannot be reached or answers a malformed receipt
81
+ */
82
+ export declare function getSolidifiedTronTransactionInfo(rpcUrl: string, txId: Uint8Array): Promise<TronTransactionReceipt | undefined>;
83
+ //# sourceMappingURL=tron-node-api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tron-node-api.d.ts","sourceRoot":"","sources":["../src/tron-node-api.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAoBhD,yFAAyF;AACzF,MAAM,WAAW,kBAAkB;IACjC,2EAA2E;IAC3E,QAAQ,CAAC,aAAa,EAAE,UAAU,CAAC;IACnC,mCAAmC;IACnC,QAAQ,CAAC,YAAY,EAAE,UAAU,CAAC;CACnC;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,GAAG,kBAAkB,CAU/F;AAED,mGAAmG;AACnG,MAAM,WAAW,kBAAmB,SAAQ,kBAAkB;IAC5D,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC;IAC7B,6CAA6C;IAC7C,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAOD;;;;;;;;;GASG;AACH,wBAAsB,+BAA+B,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAgBjG;AAED,uDAAuD;AACvD,oBAAY,oBAAoB;IAC9B,6CAA6C;IAC7C,QAAQ,IAAA;IACR;;;OAGG;IACH,YAAY,IAAA;CACb;AAiBD;;;;;;;;;GASG;AACH,wBAAsB,wBAAwB,CAC5C,MAAM,EAAE,MAAM,EACd,iBAAiB,EAAE,UAAU,GAC5B,OAAO,CAAC,oBAAoB,CAAC,CAY/B;AAED,gFAAgF;AAChF,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,EAAE,EAAE,UAAU,CAAC;IACxB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,6CAA6C;IAC7C,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,4BAA4B;IAC5B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,8EAA8E;IAC9E,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,8FAA8F;IAC9F,QAAQ,CAAC,aAAa,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3C,8DAA8D;IAC9D,QAAQ,CAAC,cAAc,EAAE,SAAS,UAAU,EAAE,CAAC;IAC/C,oEAAoE;IACpE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;CAC1B;AAYD;;;;;;;GAOG;AACH,wBAAsB,gCAAgC,CACpD,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,UAAU,GACf,OAAO,CAAC,sBAAsB,GAAG,SAAS,CAAC,CAqB7C"}
@@ -0,0 +1,134 @@
1
+ // The java-tron HTTP calls a Tron request's client makes around the MPC: the reference block to
2
+ // build a request on, the broadcast of the signed transaction, and the final receipt. Reads go to
3
+ // the solidity router (`/walletsolidity/...`), the finality the MPC itself reads, so the client
4
+ // sees what the MPC will attest.
5
+ import { bytesToHex, hexToBytes } from "./byte-codecs.js";
6
+ import { redactUrlQuery } from "./url-redaction.js";
7
+ async function tronNodePost(rpcUrl, path, body) {
8
+ const url = `${rpcUrl.replace(/\/+$/, "")}${path}`;
9
+ const response = await fetch(url, {
10
+ method: "POST",
11
+ headers: { "content-type": "application/json" },
12
+ body: JSON.stringify(body),
13
+ });
14
+ const text = await response.text();
15
+ if (!response.ok) {
16
+ throw new Error(`Tron node ${redactUrlQuery(url)} answered HTTP ${String(response.status)}: ${text}`);
17
+ }
18
+ return text;
19
+ }
20
+ /**
21
+ * The TaPoS reference to a block, as java-tron builds it and the MPC resolves it.
22
+ *
23
+ * @param blockNumber - The block's number
24
+ * @param blockId - The block's 32-byte id
25
+ * @returns The reference fields
26
+ * @throws {Error} If the block id is not 32 bytes or the number does not fit 64 bits
27
+ */
28
+ export function tronTaposReference(blockNumber, blockId) {
29
+ if (blockId.length !== 32) {
30
+ throw new Error(`a Tron block id is 32 bytes, got ${String(blockId.length)}`);
31
+ }
32
+ if (blockNumber < 0n || blockNumber >= 2n ** 64n) {
33
+ throw new Error(`Tron block number ${String(blockNumber)} does not fit 64 bits`);
34
+ }
35
+ const number = new Uint8Array(8);
36
+ new DataView(number.buffer).setBigUint64(0, blockNumber);
37
+ return { refBlockBytes: number.slice(6, 8), refBlockHash: blockId.slice(8, 16) };
38
+ }
39
+ /**
40
+ * The solidified head (`/walletsolidity/getnowblock`) as a reference block. A solidified block
41
+ * cannot be reorganised away, so a transaction referencing it stays includable until it expires;
42
+ * one referencing an unsolidified head can name a block the chain drops, which the MPC signs but
43
+ * never answers.
44
+ *
45
+ * @param rpcUrl - The java-tron HTTP API base URL
46
+ * @returns The solidified head and its TaPoS reference
47
+ * @throws {Error} If the node cannot be reached or answers without a block
48
+ */
49
+ export async function getSolidifiedTronReferenceBlock(rpcUrl) {
50
+ const answer = JSON.parse(await tronNodePost(rpcUrl, "/walletsolidity/getnowblock", {}));
51
+ const raw = answer.block_header?.raw_data;
52
+ if (answer.blockID === undefined || raw?.number === undefined || raw.timestamp === undefined) {
53
+ throw new Error("Tron /walletsolidity/getnowblock answered no block id, number or timestamp");
54
+ }
55
+ const number = BigInt(raw.number);
56
+ const blockId = hexToBytes(answer.blockID);
57
+ return {
58
+ ...tronTaposReference(number, blockId),
59
+ number,
60
+ blockId,
61
+ timestamp: BigInt(raw.timestamp),
62
+ };
63
+ }
64
+ /** How the node took a broadcast it did not refuse. */
65
+ export var TronBroadcastOutcome;
66
+ (function (TronBroadcastOutcome) {
67
+ /** The node accepted the transaction now. */
68
+ TronBroadcastOutcome[TronBroadcastOutcome["Accepted"] = 0] = "Accepted";
69
+ /**
70
+ * `DUP_TRANSACTION_ERROR`: the node already holds a transaction with this id, so an earlier
71
+ * broadcast (by anyone: the bytes are the same) reached it.
72
+ */
73
+ TronBroadcastOutcome[TronBroadcastOutcome["AlreadyKnown"] = 1] = "AlreadyKnown";
74
+ })(TronBroadcastOutcome || (TronBroadcastOutcome = {}));
75
+ // java-tron hex-encodes the ASCII message of some refusals.
76
+ function decodeTronMessage(message) {
77
+ if (!/^(?:[0-9a-fA-F]{2})+$/.test(message))
78
+ return message;
79
+ const bytes = hexToBytes(message);
80
+ return bytes.every((byte) => byte >= 0x20 && byte < 0x7f)
81
+ ? new TextDecoder().decode(bytes)
82
+ : message;
83
+ }
84
+ /**
85
+ * Broadcasts a signed transaction (`/wallet/broadcasthex`). A duplicate is not an error: the
86
+ * signed bytes are public once the MPC posts the signature, so another client may have sent them.
87
+ *
88
+ * @param rpcUrl - The java-tron HTTP API base URL
89
+ * @param signedTransaction - The signed `Transaction` protobuf bytes
90
+ * @returns Whether this call submitted it or the node already had it
91
+ * @throws {Error} If the node refuses it (for example `TRANSACTION_EXPIRATION_ERROR` once its
92
+ * expiration has passed, or `SERVER_BUSY`, which a caller may retry with the same bytes)
93
+ */
94
+ export async function broadcastTronTransaction(rpcUrl, signedTransaction) {
95
+ const answer = JSON.parse(await tronNodePost(rpcUrl, "/wallet/broadcasthex", {
96
+ transaction: bytesToHex(signedTransaction),
97
+ }));
98
+ if (answer.result === true)
99
+ return TronBroadcastOutcome.Accepted;
100
+ if (answer.code === "DUP_TRANSACTION_ERROR")
101
+ return TronBroadcastOutcome.AlreadyKnown;
102
+ throw new Error(`Tron node refused the transaction: ${answer.code ?? "no code"}: ` +
103
+ decodeTronMessage(answer.message ?? ""));
104
+ }
105
+ /**
106
+ * The final receipt of a transaction (`/walletsolidity/gettransactioninfobyid`).
107
+ *
108
+ * @param rpcUrl - The java-tron HTTP API base URL
109
+ * @param txId - The 32-byte transaction id
110
+ * @returns The receipt, or `undefined` while the transaction is not in a solidified block
111
+ * @throws {Error} If the node cannot be reached or answers a malformed receipt
112
+ */
113
+ export async function getSolidifiedTronTransactionInfo(rpcUrl, txId) {
114
+ const body = JSON.parse(await tronNodePost(rpcUrl, "/walletsolidity/gettransactioninfobyid", {
115
+ value: bytesToHex(txId),
116
+ }));
117
+ const answer = body;
118
+ if (answer.id === undefined)
119
+ return undefined;
120
+ if (answer.blockNumber === undefined || answer.blockTimeStamp === undefined) {
121
+ throw new Error(`Tron receipt ${answer.id} names no block`);
122
+ }
123
+ return {
124
+ id: hexToBytes(answer.id),
125
+ blockNumber: BigInt(answer.blockNumber),
126
+ blockTimestamp: BigInt(answer.blockTimeStamp),
127
+ fee: BigInt(answer.fee ?? 0),
128
+ result: answer.result,
129
+ receiptResult: answer.receipt?.result,
130
+ contractResult: (answer.contractResult ?? []).map((data) => hexToBytes(data)),
131
+ body,
132
+ };
133
+ }
134
+ //# sourceMappingURL=tron-node-api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tron-node-api.js","sourceRoot":"","sources":["../src/tron-node-api.ts"],"names":[],"mappings":"AAAA,gGAAgG;AAChG,kGAAkG;AAClG,gGAAgG;AAChG,iCAAiC;AAGjC,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD,KAAK,UAAU,YAAY,CAAC,MAAc,EAAE,IAAY,EAAE,IAAY;IACpE,MAAM,GAAG,GAAG,GAAG,MAAM,CAAC,OAAO,CAAC,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,EAAE,EAAE,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;QACzB,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC;QACvC,cAAc,EAAE,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC;QAC7C,GAAG,EAAE,MAAM,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC;QAC5B,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,aAAa,EAAE,MAAM,CAAC,OAAO,EAAE,MAAM;QACrC,cAAc,EAAE,CAAC,MAAM,CAAC,cAAc,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QAC7E,IAAI;KACL,CAAC;AACJ,CAAC"}
@@ -1,30 +1,39 @@
1
1
  import { type SignBidirectionalEventKeySelector } from "./epsilon-derivation.ts";
2
2
  import type { MpcSignature } from "./signet-contract-events.ts";
3
+ import { type SignBidirectionalEvent } from "./signet-requests.ts";
3
4
  import type { TronTxParams } from "./signet-tron-requests.ts";
4
5
  /**
6
+ * Turn a 20-byte EVM address into its 21-byte Tron address.
7
+ *
5
8
  * @param evm - The 20-byte EVM address, as bytes or hex (optional `0x`, any case)
6
9
  * @returns The 21-byte Tron address
7
10
  * @throws {Error} If the input is not exactly 20 bytes
8
11
  */
9
12
  export declare function tronAddressFromEvm(evm: string | Uint8Array): Uint8Array;
10
13
  /**
14
+ * Encode a 21-byte Tron address as base58check text.
15
+ *
11
16
  * @param address - The 21-byte, `0x41`-prefixed Tron address
12
17
  * @returns The base58check text
13
18
  * @throws {Error} If the address has the wrong length or prefix
14
19
  */
15
20
  export declare function tronAddressToBase58(address: Uint8Array): string;
16
21
  /**
22
+ * Decode base58check text into a 21-byte Tron address.
23
+ *
17
24
  * @param text - The base58check text (`T…`)
18
25
  * @returns The 21-byte Tron address
19
26
  * @throws {Error} If the text is not base58, not 25 bytes, fails its checksum, does not carry the `0x41` prefix or is not the canonical spelling of its bytes
20
27
  */
21
28
  export declare function tronAddressFromBase58(text: string): Uint8Array;
22
- /** */
29
+ /** A Tron address as its 21 bytes and its base58check text. */
23
30
  export interface TronAddress {
24
31
  bytes: Uint8Array;
25
32
  base58: string;
26
33
  }
27
34
  /**
35
+ * Derive the Tron address the MPC signs from for a contract and path.
36
+ *
28
37
  * @param mpcSecp256k1PublicKey - The MPC root secp256k1 public key, in any spelling `parseSecp256k1PublicKey` accepts
29
38
  * @param contractAddress - The Midnight contract address the request originates from (`0x` prefix optional, case-insensitive)
30
39
  * @param path - The derivation path string
@@ -32,24 +41,52 @@ export interface TronAddress {
32
41
  */
33
42
  export declare function deriveTronAddress(mpcSecp256k1PublicKey: string, contractAddress: string, path: string): TronAddress;
34
43
  /**
44
+ * Derive the Tron address the MPC signs a request's transaction from.
45
+ *
35
46
  * @param mpcSecp256k1PublicKey - The MPC root secp256k1 public key of the record's `keyVersion`, in any spelling `parseSecp256k1PublicKey` accepts
36
47
  * @param request - The on-ledger request record, or its `sender` and `path`
37
48
  * @returns The Tron address the MPC signs that request's transaction from, in both forms
38
49
  */
39
50
  export declare function deriveSignBidirectionalEventSignerTronAddress(mpcSecp256k1PublicKey: string, request: SignBidirectionalEventKeySelector): TronAddress;
40
51
  /**
52
+ * Build the protobuf raw bytes of the TriggerSmartContract transaction a request describes.
53
+ *
41
54
  * @param params - The request's transaction parameters
42
55
  * @param owner - The 21-byte Tron address of the request signing key (see {@link deriveTronAddress})
43
56
  * @returns The raw transaction bytes
44
57
  * @throws {Error} If a field cannot be represented
45
58
  */
46
59
  export declare function buildTronRawTransaction(params: TronTxParams, owner: Uint8Array): Uint8Array;
60
+ /** The unsigned Tron transaction the MPC signs for a request. */
61
+ export interface UnsignedTronTransaction {
62
+ /** The `raw` protobuf bytes. */
63
+ readonly raw: Uint8Array;
64
+ /** sha256 of `raw`: the transaction id, and the digest the MPC signs. */
65
+ readonly txId: Uint8Array;
66
+ /** The request's derived signer, the transaction's owner. */
67
+ readonly owner: TronAddress;
68
+ }
69
+ /**
70
+ * Rebuilds the exact unsigned transaction the MPC signs for an on-ledger Tron request record:
71
+ * its transaction parameters, owned by the key the MPC derives from the record's sender and path.
72
+ *
73
+ * @param request - The on-ledger request record
74
+ * @param mpcRootPublicKey - The MPC root secp256k1 public key of the record's `keyVersion`, in any
75
+ * spelling `parseSecp256k1PublicKey` accepts
76
+ * @returns The raw transaction, its id and its owner
77
+ * @throws {Error} If the record is not a Tron request or a field cannot be encoded
78
+ */
79
+ export declare function signBidirectionalEventToUnsignedTronTransaction(request: SignBidirectionalEvent<TronTxParams>, mpcRootPublicKey: string): UnsignedTronTransaction;
47
80
  /**
81
+ * The transaction id (sha256 of the raw bytes): the digest the MPC signs.
82
+ *
48
83
  * @param raw - The raw transaction bytes ({@link buildTronRawTransaction})
49
84
  * @returns The 32-byte transaction id
50
85
  */
51
86
  export declare function tronTransactionId(raw: Uint8Array): Uint8Array;
52
87
  /**
88
+ * Attach the MPC signature to raw transaction bytes, giving the protobuf `Transaction` to broadcast.
89
+ *
53
90
  * @param raw - The raw transaction bytes ({@link buildTronRawTransaction})
54
91
  * @param signature - The signature as the MPC posts it
55
92
  * @returns The signed transaction bytes
@@ -1 +1 @@
1
- {"version":3,"file":"tron-transactions.d.ts","sourceRoot":"","sources":["../src/tron-transactions.ts"],"names":[],"mappings":"AAIA,OAAO,EAGL,KAAK,iCAAiC,EACvC,MAAM,yBAAyB,CAAC;AAEjC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAY9D;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,GAAG,UAAU,CAYvE;AAMD;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,UAAU,GAAG,MAAM,CAG/D;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,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;AAED,+DAA+D;AAC/D,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,UAAU,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAC/B,qBAAqB,EAAE,MAAM,EAC7B,eAAe,EAAE,MAAM,EACvB,IAAI,EAAE,MAAM,GACX,WAAW,CAEb;AAED;;;;;;GAMG;AACH,wBAAgB,6CAA6C,CAC3D,qBAAqB,EAAE,MAAM,EAC7B,OAAO,EAAE,iCAAiC,GACzC,WAAW,CAIb;AAwDD;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,UAAU,GAAG,UAAU,CAkC3F;AAED,iEAAiE;AACjE,MAAM,WAAW,uBAAuB;IACtC,gCAAgC;IAChC,QAAQ,CAAC,GAAG,EAAE,UAAU,CAAC;IACzB,yEAAyE;IACzE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,6DAA6D;IAC7D,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;CAC7B;AAED;;;;;;;;;GASG;AACH,wBAAgB,+CAA+C,CAC7D,OAAO,EAAE,sBAAsB,CAAC,YAAY,CAAC,EAC7C,gBAAgB,EAAE,MAAM,GACvB,uBAAuB,CASzB;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,UAAU,GAAG,UAAU,CAE7D;AAED;;;;;;;GAOG;AACH,wBAAgB,0BAA0B,CAAC,GAAG,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,GAAG,UAAU,CAW/F"}
@@ -3,6 +3,7 @@ import { bigintToBytes32BE, hexToBytes, stripHexPrefix } from "./byte-codecs.js"
3
3
  import { mpcSignatureToEcdsaSignature } from "./ecdsa-attestation.js";
4
4
  import { deriveEvmAddress, deriveSignBidirectionalEventSignerEvmAddress, } from "./epsilon-derivation.js";
5
5
  import { pureCircuits } from "./managed/contract/index.js";
6
+ import { TxParamType } from "./signet-requests.js";
6
7
  const TRON_ADDRESS_PREFIX = 0x41;
7
8
  const TRON_ADDRESS_BYTES = 21;
8
9
  function assertTronAddress(address, name) {
@@ -11,6 +12,8 @@ function assertTronAddress(address, name) {
11
12
  }
12
13
  }
13
14
  /**
15
+ * Turn a 20-byte EVM address into its 21-byte Tron address.
16
+ *
14
17
  * @param evm - The 20-byte EVM address, as bytes or hex (optional `0x`, any case)
15
18
  * @returns The 21-byte Tron address
16
19
  * @throws {Error} If the input is not exactly 20 bytes
@@ -32,6 +35,8 @@ function base58CheckChecksum(address) {
32
35
  return getBytes(sha256(sha256(address))).slice(0, 4);
33
36
  }
34
37
  /**
38
+ * Encode a 21-byte Tron address as base58check text.
39
+ *
35
40
  * @param address - The 21-byte, `0x41`-prefixed Tron address
36
41
  * @returns The base58check text
37
42
  * @throws {Error} If the address has the wrong length or prefix
@@ -41,6 +46,8 @@ export function tronAddressToBase58(address) {
41
46
  return encodeBase58(Uint8Array.from([...address, ...base58CheckChecksum(address)]));
42
47
  }
43
48
  /**
49
+ * Decode base58check text into a 21-byte Tron address.
50
+ *
44
51
  * @param text - The base58check text (`T…`)
45
52
  * @returns The 21-byte Tron address
46
53
  * @throws {Error} If the text is not base58, not 25 bytes, fails its checksum, does not carry the `0x41` prefix or is not the canonical spelling of its bytes
@@ -68,6 +75,8 @@ export function tronAddressFromBase58(text) {
68
75
  return address;
69
76
  }
70
77
  /**
78
+ * Derive the Tron address the MPC signs from for a contract and path.
79
+ *
71
80
  * @param mpcSecp256k1PublicKey - The MPC root secp256k1 public key, in any spelling `parseSecp256k1PublicKey` accepts
72
81
  * @param contractAddress - The Midnight contract address the request originates from (`0x` prefix optional, case-insensitive)
73
82
  * @param path - The derivation path string
@@ -77,6 +86,8 @@ export function deriveTronAddress(mpcSecp256k1PublicKey, contractAddress, path)
77
86
  return tronAddressOfEvm(deriveEvmAddress(mpcSecp256k1PublicKey, contractAddress, path));
78
87
  }
79
88
  /**
89
+ * Derive the Tron address the MPC signs a request's transaction from.
90
+ *
80
91
  * @param mpcSecp256k1PublicKey - The MPC root secp256k1 public key of the record's `keyVersion`, in any spelling `parseSecp256k1PublicKey` accepts
81
92
  * @param request - The on-ledger request record, or its `sender` and `path`
82
93
  * @returns The Tron address the MPC signs that request's transaction from, in both forms
@@ -127,6 +138,8 @@ function tronCalldata(params) {
127
138
  return [...selector, ...words.slice(0, Number(noWords)).flatMap((word) => [...word])];
128
139
  }
129
140
  /**
141
+ * Build the protobuf raw bytes of the TriggerSmartContract transaction a request describes.
142
+ *
130
143
  * @param params - The request's transaction parameters
131
144
  * @param owner - The 21-byte Tron address of the request signing key (see {@link deriveTronAddress})
132
145
  * @returns The raw transaction bytes
@@ -168,6 +181,26 @@ export function buildTronRawTransaction(params, owner) {
168
181
  ]);
169
182
  }
170
183
  /**
184
+ * Rebuilds the exact unsigned transaction the MPC signs for an on-ledger Tron request record:
185
+ * its transaction parameters, owned by the key the MPC derives from the record's sender and path.
186
+ *
187
+ * @param request - The on-ledger request record
188
+ * @param mpcRootPublicKey - The MPC root secp256k1 public key of the record's `keyVersion`, in any
189
+ * spelling `parseSecp256k1PublicKey` accepts
190
+ * @returns The raw transaction, its id and its owner
191
+ * @throws {Error} If the record is not a Tron request or a field cannot be encoded
192
+ */
193
+ export function signBidirectionalEventToUnsignedTronTransaction(request, mpcRootPublicKey) {
194
+ if (request.txParamType !== TxParamType.tron) {
195
+ throw new Error(`expected a Tron request record, got txParamType ${String(request.txParamType)}`);
196
+ }
197
+ const owner = deriveSignBidirectionalEventSignerTronAddress(mpcRootPublicKey, request);
198
+ const raw = buildTronRawTransaction(request.txParams, owner.bytes);
199
+ return { raw, txId: tronTransactionId(raw), owner };
200
+ }
201
+ /**
202
+ * The transaction id (sha256 of the raw bytes): the digest the MPC signs.
203
+ *
171
204
  * @param raw - The raw transaction bytes ({@link buildTronRawTransaction})
172
205
  * @returns The 32-byte transaction id
173
206
  */
@@ -175,6 +208,8 @@ export function tronTransactionId(raw) {
175
208
  return getBytes(sha256(raw));
176
209
  }
177
210
  /**
211
+ * Attach the MPC signature to raw transaction bytes, giving the protobuf `Transaction` to broadcast.
212
+ *
178
213
  * @param raw - The raw transaction bytes ({@link buildTronRawTransaction})
179
214
  * @param signature - The signature as the MPC posts it
180
215
  * @returns The signed transaction bytes