@sig-net/midnight 0.26.0-rc.9 → 0.27.0-rc.3

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 (73) hide show
  1. package/README.md +1 -1
  2. package/dist/abi-serde.d.ts +27 -0
  3. package/dist/abi-serde.d.ts.map +1 -1
  4. package/dist/abi-serde.js +101 -0
  5. package/dist/abi-serde.js.map +1 -1
  6. package/dist/compact-descriptors.d.ts +8 -0
  7. package/dist/compact-descriptors.d.ts.map +1 -1
  8. package/dist/compact-descriptors.js +13 -1
  9. package/dist/compact-descriptors.js.map +1 -1
  10. package/dist/constants.d.ts +0 -3
  11. package/dist/constants.d.ts.map +1 -1
  12. package/dist/constants.js +19 -29
  13. package/dist/constants.js.map +1 -1
  14. package/dist/index.d.ts +5 -1
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +7 -2
  17. package/dist/index.js.map +1 -1
  18. package/dist/managed/compiler/contract-info.json +1158 -5
  19. package/dist/managed/compiler/contract-manifest.json +8 -8
  20. package/dist/managed/contract/index.d.ts +270 -1
  21. package/dist/managed/contract/index.js +798 -312
  22. package/dist/managed/contract/index.js.map +1 -1
  23. package/dist/mpc-output-cache.d.ts +2 -3
  24. package/dist/mpc-output-cache.d.ts.map +1 -1
  25. package/dist/mpc-output-cache.js +1 -2
  26. package/dist/mpc-output-cache.js.map +1 -1
  27. package/dist/signature-requests-state-reader.d.ts +3 -3
  28. package/dist/signature-requests-state-reader.d.ts.map +1 -1
  29. package/dist/signature-requests-state-reader.js +6 -2
  30. package/dist/signature-requests-state-reader.js.map +1 -1
  31. package/dist/signature-response-verification.d.ts +29 -11
  32. package/dist/signature-response-verification.d.ts.map +1 -1
  33. package/dist/signature-response-verification.js +66 -24
  34. package/dist/signature-response-verification.js.map +1 -1
  35. package/dist/signet-contract-events.d.ts +6 -0
  36. package/dist/signet-contract-events.d.ts.map +1 -1
  37. package/dist/signet-contract-events.js +9 -7
  38. package/dist/signet-contract-events.js.map +1 -1
  39. package/dist/signet-evtype2tx-requests.d.ts +1 -1
  40. package/dist/signet-evtype2tx-requests.d.ts.map +1 -1
  41. package/dist/signet-evtype2tx-requests.js +2 -8
  42. package/dist/signet-evtype2tx-requests.js.map +1 -1
  43. package/dist/signet-request-id.d.ts +2 -2
  44. package/dist/signet-request-id.d.ts.map +1 -1
  45. package/dist/signet-request-id.js +18 -8
  46. package/dist/signet-request-id.js.map +1 -1
  47. package/dist/signet-request-response-reader.d.ts +51 -25
  48. package/dist/signet-request-response-reader.d.ts.map +1 -1
  49. package/dist/signet-request-response-reader.js +119 -71
  50. package/dist/signet-request-response-reader.js.map +1 -1
  51. package/dist/signet-requests.d.ts +18 -10
  52. package/dist/signet-requests.d.ts.map +1 -1
  53. package/dist/signet-requests.js +19 -10
  54. package/dist/signet-requests.js.map +1 -1
  55. package/dist/signet-tron-record-decoding.d.ts +11 -0
  56. package/dist/signet-tron-record-decoding.d.ts.map +1 -0
  57. package/dist/signet-tron-record-decoding.js +29 -0
  58. package/dist/signet-tron-record-decoding.js.map +1 -0
  59. package/dist/signet-tron-requests.d.ts +36 -0
  60. package/dist/signet-tron-requests.d.ts.map +1 -0
  61. package/dist/signet-tron-requests.js +76 -0
  62. package/dist/signet-tron-requests.js.map +1 -0
  63. package/dist/tron-transactions.d.ts +59 -0
  64. package/dist/tron-transactions.d.ts.map +1 -0
  65. package/dist/tron-transactions.js +195 -0
  66. package/dist/tron-transactions.js.map +1 -0
  67. package/dist/url-redaction.d.ts +11 -0
  68. package/dist/url-redaction.d.ts.map +1 -0
  69. package/dist/url-redaction.js +21 -0
  70. package/dist/url-redaction.js.map +1 -0
  71. package/package.json +2 -2
  72. package/src/Signet.compact +71 -1
  73. package/src/circuits.compact +38 -0
@@ -1,6 +1,7 @@
1
1
  import { type CompactType } from "@midnight-ntwrk/compact-runtime";
2
2
  import { type ContractAddress } from "./compact-descriptors.ts";
3
3
  import type { EvmType2TxParams } from "./signet-evtype2tx-requests.ts";
4
+ import type { TronTxParams } from "./signet-tron-requests.ts";
4
5
  export type { ContractAddress, Maybe } from "./compact-descriptors.ts";
5
6
  /**
6
7
  * Parse a contract address from its hex rendering (optional `0x`/`0X`
@@ -33,12 +34,7 @@ export declare const requestIdType: CompactType<RequestId>;
33
34
  export declare const TxParamType: {
34
35
  /** `EvmType2TxParams` (signet-evtype2tx-requests.ts): an EIP-1559 EVM transaction. */
35
36
  readonly evmType2: 0;
36
- /**
37
- * Never emitted: the Compact-side padding variant that keeps the enum at
38
- * >= 2 variants, so it compiles to a one-byte value rather than a
39
- * zero-byte one the proof server cannot parse inside a hash preimage.
40
- */
41
- readonly reserved: 1;
37
+ readonly tron: 1;
42
38
  };
43
39
  /**
44
40
  * Which signature algorithm the MPC uses (Compact:
@@ -47,7 +43,7 @@ export declare const TxParamType: {
47
43
  export declare const MPCSignatureAlgorithm: {
48
44
  /** ECDSA over secp256k1. */
49
45
  readonly ecdsa: 0;
50
- /** Never emitted: the >= 2 variants padding (see {@link TxParamType}). */
46
+ /** Never emitted: the >= 2 variants padding. */
51
47
  readonly reserved: 1;
52
48
  };
53
49
  /**
@@ -57,7 +53,7 @@ export declare const MPCSignatureAlgorithm: {
57
53
  export declare const MPCDestination: {
58
54
  /** The only currently-valid value. */
59
55
  readonly unused: 0;
60
- /** Never emitted: the >= 2 variants padding (see {@link TxParamType}). */
56
+ /** Never emitted: the >= 2 variants padding. */
61
57
  readonly reserved: 1;
62
58
  };
63
59
  /**
@@ -120,6 +116,18 @@ export interface SignBidirectionalEvent<TxParams = EvmType2TxParams> {
120
116
  /** Reserved and ignored by the MPC, contract-declared width (zero in the V1 helper). */
121
117
  respondSerializationSchema: Uint8Array;
122
118
  }
119
+ /** */
120
+ export type AnySignBidirectionalEvent = SignBidirectionalEvent | SignBidirectionalEvent<TronTxParams>;
121
+ /**
122
+ * @param request - The request record
123
+ * @returns `true` iff the record is tagged {@link TxParamType.evmType2}
124
+ */
125
+ export declare function isEvmType2SignBidirectionalEvent(request: AnySignBidirectionalEvent): request is SignBidirectionalEvent;
126
+ /**
127
+ * @param request - The request record
128
+ * @returns `true` iff the record is tagged {@link TxParamType.tron}
129
+ */
130
+ export declare function isTronSignBidirectionalEvent(request: AnySignBidirectionalEvent): request is SignBidirectionalEvent<TronTxParams>;
123
131
  /**
124
132
  * Descriptor of {@link RequestIdPreimage}: what {@link calculateRequestId}
125
133
  * hashes, in Compact declaration order.
@@ -179,7 +187,7 @@ export type RequestIdHex = string & {
179
187
  readonly [requestIdHexBrand]: true;
180
188
  };
181
189
  /** Plain-JS index parsed out of the ledger, keyed by hex request id. */
182
- export type SignBidirectionalEventIndex = Map<RequestIdHex, SignBidirectionalEvent>;
190
+ export type SignBidirectionalEventIndex = Map<RequestIdHex, AnySignBidirectionalEvent>;
183
191
  /**
184
192
  * Render a request id in its canonical TS form (see {@link RequestIdHex}).
185
193
  *
@@ -219,5 +227,5 @@ export declare const PATH_BYTES = 32;
219
227
  * {@link SignBidirectionalEventLedgerMap}).
220
228
  * @returns A new `Map` from {@link requestIdHex} key to request record.
221
229
  */
222
- export declare function toSignBidirectionalEventIndex(ledgerIndex: Iterable<[RequestId, SignBidirectionalEvent]>): SignBidirectionalEventIndex;
230
+ export declare function toSignBidirectionalEventIndex(ledgerIndex: Iterable<[RequestId, AnySignBidirectionalEvent]>): SignBidirectionalEventIndex;
223
231
  //# sourceMappingURL=signet-requests.d.ts.map
@@ -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;AAGvE,YAAY,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AAEvE;;;;;;;;;GASG;AACH,wBAAgB,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G;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"}
@@ -43,12 +43,7 @@ export const requestIdType = BYTES_32;
43
43
  export const TxParamType = {
44
44
  /** `EvmType2TxParams` (signet-evtype2tx-requests.ts): an EIP-1559 EVM transaction. */
45
45
  evmType2: 0,
46
- /**
47
- * Never emitted: the Compact-side padding variant that keeps the enum at
48
- * >= 2 variants, so it compiles to a one-byte value rather than a
49
- * zero-byte one the proof server cannot parse inside a hash preimage.
50
- */
51
- reserved: 1,
46
+ tron: 1,
52
47
  };
53
48
  /**
54
49
  * Which signature algorithm the MPC uses (Compact:
@@ -57,7 +52,7 @@ export const TxParamType = {
57
52
  export const MPCSignatureAlgorithm = {
58
53
  /** ECDSA over secp256k1. */
59
54
  ecdsa: 0,
60
- /** Never emitted: the >= 2 variants padding (see {@link TxParamType}). */
55
+ /** Never emitted: the >= 2 variants padding. */
61
56
  reserved: 1,
62
57
  };
63
58
  /**
@@ -67,9 +62,23 @@ export const MPCSignatureAlgorithm = {
67
62
  export const MPCDestination = {
68
63
  /** The only currently-valid value. */
69
64
  unused: 0,
70
- /** Never emitted: the >= 2 variants padding (see {@link TxParamType}). */
65
+ /** Never emitted: the >= 2 variants padding. */
71
66
  reserved: 1,
72
67
  };
68
+ /**
69
+ * @param request - The request record
70
+ * @returns `true` iff the record is tagged {@link TxParamType.evmType2}
71
+ */
72
+ export function isEvmType2SignBidirectionalEvent(request) {
73
+ return request.txParamType === TxParamType.evmType2;
74
+ }
75
+ /**
76
+ * @param request - The request record
77
+ * @returns `true` iff the record is tagged {@link TxParamType.tron}
78
+ */
79
+ export function isTronSignBidirectionalEvent(request) {
80
+ return request.txParamType === TxParamType.tron;
81
+ }
73
82
  // ---- Runtime descriptor toolkit (TS twin of the compiled struct codecs) ----
74
83
  //
75
84
  // DEVIATION from the "pure circuits are compiled, never re-written in TS"
@@ -84,8 +93,8 @@ export const MPCDestination = {
84
93
  // Runtime descriptors of the signet enums, at the literals the compiler
85
94
  // emits. NOTE: a 1-variant enum would compile to `CompactTypeEnum(0, 0)`,
86
95
  // zero bytes, which the proof server cannot parse inside a hash preimage.
87
- // Every enum therefore carries a padding `reserved` variant so it stays at
88
- // (1, 1). The Compact-generic base descriptors live in
96
+ // Every enum therefore carries at least two variants (a padding `reserved`
97
+ // one where needed) so it stays at (1, 1). The Compact-generic base descriptors live in
89
98
  // compact-descriptors.ts.
90
99
  const TX_PARAM_TYPE = new CompactTypeEnum(1, 1);
91
100
  const MPC_SIGNATURE_ALGORITHM = new CompactTypeEnum(1, 1);
@@ -1 +1 @@
1
- {"version":3,"file":"signet-requests.js","sourceRoot":"","sources":["../src/signet-requests.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,4EAA4E;AAC5E,4EAA4E;AAC5E,2EAA2E;AAC3E,qCAAqC;AACrC,EAAE;AACF,0EAA0E;AAC1E,6EAA6E;AAC7E,8CAA8C;AAC9C,yDAAyD;AAEzD,OAAO,EAEL,gBAAgB,EAChB,eAAe,GAChB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC1E,OAAO,EACL,QAAQ,EACR,QAAQ,EACR,uBAAuB,EACvB,gBAAgB,EAEhB,MAAM,GACP,MAAM,0BAA0B,CAAC;AAMlC;;;;;;;;;GASG;AACH,MAAM,UAAU,sBAAsB,CAAC,GAAW;IAChD,MAAM,MAAM,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC;IACnC,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,KAAK,CA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AAU,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"}
@@ -0,0 +1,11 @@
1
+ import type { AlignedValue } from "@midnight-ntwrk/compact-runtime";
2
+ import type { SignBidirectionalEvent } from "./signet-requests.ts";
3
+ import { type TronTxParams } from "./signet-tron-requests.ts";
4
+ /**
5
+ * @param cell - The record cell as stored (value atoms plus alignment)
6
+ * @param what - Error-message subject
7
+ * @returns The decoded record
8
+ * @throws {Error} If the cell is not a decodable Tron request record
9
+ */
10
+ export declare function decodeTronSignBidirectionalEvent(cell: AlignedValue, what: string): SignBidirectionalEvent<TronTxParams>;
11
+ //# sourceMappingURL=signet-tron-record-decoding.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,29 @@
1
+ import { declaredWidths, decodeExactly } from "./compact-descriptors.js";
2
+ import { tronSignBidirectionalEventDescriptor } from "./signet-tron-requests.js";
3
+ const TRON_FIXED_ATOMS = 20;
4
+ const TRON_HEAD_ATOMS = 15;
5
+ const TRON_TAIL_ATOMS = 5;
6
+ /**
7
+ * @param cell - The record cell as stored (value atoms plus alignment)
8
+ * @param what - Error-message subject
9
+ * @returns The decoded record
10
+ * @throws {Error} If the cell is not a decodable Tron request record
11
+ */
12
+ export function decodeTronSignBidirectionalEvent(cell, what) {
13
+ const widths = declaredWidths(cell, what);
14
+ if (widths.length < TRON_FIXED_ATOMS) {
15
+ throw new Error(`${what} has ${String(widths.length)} value atoms, fewer than the ` +
16
+ `${String(TRON_FIXED_ATOMS)} its fixed fields need`);
17
+ }
18
+ const tail = widths.length - TRON_TAIL_ATOMS;
19
+ if (!widths.slice(TRON_HEAD_ATOMS, tail).every((width) => width === 32)) {
20
+ throw new Error(`${what}'s calldata-word region holds a non-Bytes<32> atom`);
21
+ }
22
+ const lenOutputDeserialization = widths.at(-2);
23
+ const lenRespondSerialization = widths.at(-1);
24
+ if (lenOutputDeserialization === undefined || lenRespondSerialization === undefined) {
25
+ throw new Error(`${what} ends before its serialisation schemas`);
26
+ }
27
+ return decodeExactly(tronSignBidirectionalEventDescriptor(tail - TRON_HEAD_ATOMS, lenOutputDeserialization, lenRespondSerialization), cell.value, what);
28
+ }
29
+ //# sourceMappingURL=signet-tron-record-decoding.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signet-tron-record-decoding.js","sourceRoot":"","sources":["../src/signet-tron-record-decoding.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAEzE,OAAO,EAAE,oCAAoC,EAAqB,MAAM,2BAA2B,CAAC;AAEpG,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAC5B,MAAM,eAAe,GAAG,EAAE,CAAC;AAC3B,MAAM,eAAe,GAAG,CAAC,CAAC;AAE1B;;;;;GAKG;AACH,MAAM,UAAU,gCAAgC,CAC9C,IAAkB,EAClB,IAAY;IAEZ,MAAM,MAAM,GAAG,cAAc,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAC1C,IAAI,MAAM,CAAC,MAAM,GAAG,gBAAgB,EAAE,CAAC;QACrC,MAAM,IAAI,KAAK,CACb,GAAG,IAAI,QAAQ,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,+BAA+B;YACjE,GAAG,MAAM,CAAC,gBAAgB,CAAC,wBAAwB,CACtD,CAAC;IACJ,CAAC;IACD,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,GAAG,eAAe,CAAC;IAC7C,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,eAAe,EAAE,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,EAAE,CAAC,EAAE,CAAC;QACxE,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,oDAAoD,CAAC,CAAC;IAC/E,CAAC;IACD,MAAM,wBAAwB,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAC/C,MAAM,uBAAuB,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9C,IAAI,wBAAwB,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"}
@@ -0,0 +1,36 @@
1
+ import { type CompactType } from "@midnight-ntwrk/compact-runtime";
2
+ import { type Maybe } from "./compact-descriptors.ts";
3
+ import { type EvmCalldata } from "./signet-evtype2tx-requests.ts";
4
+ import { type SignBidirectionalEvent } from "./signet-requests.ts";
5
+ /** */
6
+ export declare const TRON_CAIP2_ID = "tron:mainnet";
7
+ /** */
8
+ export interface TronTxParams {
9
+ refBlockBytes: Uint8Array;
10
+ refBlockHash: Uint8Array;
11
+ timestamp: bigint;
12
+ expiration: bigint;
13
+ feeLimit: bigint;
14
+ contractAddress: Uint8Array;
15
+ callValue: bigint;
16
+ calldata: Maybe<EvmCalldata>;
17
+ }
18
+ /**
19
+ * @param maxCalldataWords - Calldata word capacity
20
+ * @returns The tx-params descriptor
21
+ */
22
+ export declare function tronTxParamsDescriptor(maxCalldataWords: number): CompactType<TronTxParams>;
23
+ /**
24
+ * @param maxCalldataWords - Calldata word capacity
25
+ * @param lenOutputDeserialization - Declared byte width of `outputDeserializationSchema` (Compact `#LenOutputDeserialization`)
26
+ * @param lenRespondSerialization - Declared byte width of `respondSerializationSchema` (Compact `#LenRespondSerialization`)
27
+ * @returns The event record descriptor
28
+ */
29
+ export declare function tronSignBidirectionalEventDescriptor(maxCalldataWords: number, lenOutputDeserialization: number, lenRespondSerialization: number): CompactType<SignBidirectionalEvent<TronTxParams>>;
30
+ /**
31
+ * @param txParams - The transaction decomposition to digest, at any capacity
32
+ * @returns The 32-byte digest
33
+ * @throws {Error} When the calldata word count exceeds its capacity
34
+ */
35
+ export declare function calculateTronTxParamsDigest(txParams: TronTxParams): Uint8Array;
36
+ //# sourceMappingURL=signet-tron-requests.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,76 @@
1
+ import { transientHash, upgradeFromTransient, } from "@midnight-ntwrk/compact-runtime";
2
+ import { BOOLEAN, BYTES_2, BYTES_4, BYTES_8, BYTES_21, compactMaybeDescriptor, compactStructDescriptor, compactTupleDescriptor, DOMAIN_FIELD_BYTES_32, HASH_DOMAIN, UINT_16, UINT_64, } from "./compact-descriptors.js";
3
+ import { HashDomain } from "./managed/contract/index.js";
4
+ import { evmCalldataDescriptor } from "./signet-evtype2tx-requests.js";
5
+ import { signBidirectionalEventDescriptorWith, } from "./signet-requests.js";
6
+ /** */
7
+ export const TRON_CAIP2_ID = "tron:mainnet";
8
+ /**
9
+ * @param maxCalldataWords - Calldata word capacity
10
+ * @returns The tx-params descriptor
11
+ */
12
+ export function tronTxParamsDescriptor(maxCalldataWords) {
13
+ return compactStructDescriptor({
14
+ refBlockBytes: BYTES_2,
15
+ refBlockHash: BYTES_8,
16
+ timestamp: UINT_64,
17
+ expiration: UINT_64,
18
+ feeLimit: UINT_64,
19
+ contractAddress: BYTES_21,
20
+ callValue: UINT_64,
21
+ calldata: compactMaybeDescriptor(evmCalldataDescriptor(maxCalldataWords)),
22
+ });
23
+ }
24
+ /**
25
+ * @param maxCalldataWords - Calldata word capacity
26
+ * @param lenOutputDeserialization - Declared byte width of `outputDeserializationSchema` (Compact `#LenOutputDeserialization`)
27
+ * @param lenRespondSerialization - Declared byte width of `respondSerializationSchema` (Compact `#LenRespondSerialization`)
28
+ * @returns The event record descriptor
29
+ */
30
+ export function tronSignBidirectionalEventDescriptor(maxCalldataWords, lenOutputDeserialization, lenRespondSerialization) {
31
+ return signBidirectionalEventDescriptorWith(tronTxParamsDescriptor(maxCalldataWords), lenOutputDeserialization, lenRespondSerialization);
32
+ }
33
+ const TRON_DIGEST_HEAD = compactTupleDescriptor([
34
+ HASH_DOMAIN,
35
+ BYTES_2,
36
+ BYTES_8,
37
+ UINT_64,
38
+ UINT_64,
39
+ UINT_64,
40
+ BYTES_21,
41
+ UINT_64,
42
+ BOOLEAN,
43
+ BYTES_4,
44
+ UINT_16,
45
+ ]);
46
+ /**
47
+ * @param txParams - The transaction decomposition to digest, at any capacity
48
+ * @returns The 32-byte digest
49
+ * @throws {Error} When the calldata word count exceeds its capacity
50
+ */
51
+ export function calculateTronTxParamsDigest(txParams) {
52
+ const { calldata } = txParams;
53
+ const noWords = calldata.is_some ? calldata.value.noWords : 0n;
54
+ const selector = calldata.is_some ? calldata.value.selector : new Uint8Array(4);
55
+ if (noWords > BigInt(calldata.value.words.length)) {
56
+ throw new Error("calldata noWords exceeds capacity");
57
+ }
58
+ let acc = transientHash(TRON_DIGEST_HEAD, [
59
+ HashDomain.tronTxHeader,
60
+ txParams.refBlockBytes,
61
+ txParams.refBlockHash,
62
+ txParams.timestamp,
63
+ txParams.expiration,
64
+ txParams.feeLimit,
65
+ txParams.contractAddress,
66
+ txParams.callValue,
67
+ calldata.is_some,
68
+ selector,
69
+ noWords,
70
+ ]);
71
+ for (const word of calldata.value.words.slice(0, Number(noWords))) {
72
+ acc = transientHash(DOMAIN_FIELD_BYTES_32, [HashDomain.tronTxWord, acc, word]);
73
+ }
74
+ return upgradeFromTransient(acc);
75
+ }
76
+ //# sourceMappingURL=signet-tron-requests.js.map
@@ -0,0 +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,cAAc,CAAC;AAc5C;;;GAGG;AACH,MAAM,UAAU,sBAAsB,CAAC,gBAAwB;IAC7D,OAAO,uBAAuB,CAAe;QAC3C,aAAa,EAAE,OAAO;QACtB,YAAY,EAAE,OAAO;QACrB,SAAS,EAAE,OAAO;QAClB,UAAU,EAAE,OAAO;QACnB,QAAQ,EAAE,OAAO;QACjB,eAAe,EAAE,QAAQ;QACzB,SAAS,EAAE,OAAO;QAClB,QAAQ,EAAE,sBAAsB,CAAC,qBAAqB,CAAC,gBAAgB,CAAC,CAAC;KAC1E,CAAC,CAAC;AACL,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,oCAAoC,CAClD,gBAAwB,EACxB,wBAAgC,EAChC,uBAA+B;IAE/B,OAAO,oCAAoC,CACzC,sBAAsB,CAAC,gBAAgB,CAAC,EACxC,wBAAwB,EACxB,uBAAuB,CACxB,CAAC;AACJ,CAAC;AAED,MAAM,gBAAgB,GAAG,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I,CAAC,CAAC,CAAC;IACjF,CAAC;IACD,OAAO,oBAAoB,CAAC,GAAG,CAAC,CAAC;AACnC,CAAC"}
@@ -0,0 +1,59 @@
1
+ import { type SignBidirectionalEventKeySelector } from "./epsilon-derivation.ts";
2
+ import type { MpcSignature } from "./signet-contract-events.ts";
3
+ import type { TronTxParams } from "./signet-tron-requests.ts";
4
+ /**
5
+ * @param evm - The 20-byte EVM address, as bytes or hex (optional `0x`, any case)
6
+ * @returns The 21-byte Tron address
7
+ * @throws {Error} If the input is not exactly 20 bytes
8
+ */
9
+ export declare function tronAddressFromEvm(evm: string | Uint8Array): Uint8Array;
10
+ /**
11
+ * @param address - The 21-byte, `0x41`-prefixed Tron address
12
+ * @returns The base58check text
13
+ * @throws {Error} If the address has the wrong length or prefix
14
+ */
15
+ export declare function tronAddressToBase58(address: Uint8Array): string;
16
+ /**
17
+ * @param text - The base58check text (`T…`)
18
+ * @returns The 21-byte Tron address
19
+ * @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
+ */
21
+ export declare function tronAddressFromBase58(text: string): Uint8Array;
22
+ /** */
23
+ export interface TronAddress {
24
+ bytes: Uint8Array;
25
+ base58: string;
26
+ }
27
+ /**
28
+ * @param mpcSecp256k1PublicKey - The MPC root secp256k1 public key, in any spelling `parseSecp256k1PublicKey` accepts
29
+ * @param contractAddress - The Midnight contract address the request originates from (`0x` prefix optional, case-insensitive)
30
+ * @param path - The derivation path string
31
+ * @returns The derived address in both forms
32
+ */
33
+ export declare function deriveTronAddress(mpcSecp256k1PublicKey: string, contractAddress: string, path: string): TronAddress;
34
+ /**
35
+ * @param mpcSecp256k1PublicKey - The MPC root secp256k1 public key of the record's `keyVersion`, in any spelling `parseSecp256k1PublicKey` accepts
36
+ * @param request - The on-ledger request record, or its `sender` and `path`
37
+ * @returns The Tron address the MPC signs that request's transaction from, in both forms
38
+ */
39
+ export declare function deriveSignBidirectionalEventSignerTronAddress(mpcSecp256k1PublicKey: string, request: SignBidirectionalEventKeySelector): TronAddress;
40
+ /**
41
+ * @param params - The request's transaction parameters
42
+ * @param owner - The 21-byte Tron address of the request signing key (see {@link deriveTronAddress})
43
+ * @returns The raw transaction bytes
44
+ * @throws {Error} If a field cannot be represented
45
+ */
46
+ export declare function buildTronRawTransaction(params: TronTxParams, owner: Uint8Array): Uint8Array;
47
+ /**
48
+ * @param raw - The raw transaction bytes ({@link buildTronRawTransaction})
49
+ * @returns The 32-byte transaction id
50
+ */
51
+ export declare function tronTransactionId(raw: Uint8Array): Uint8Array;
52
+ /**
53
+ * @param raw - The raw transaction bytes ({@link buildTronRawTransaction})
54
+ * @param signature - The signature as the MPC posts it
55
+ * @returns The signed transaction bytes
56
+ * @throws {Error} If the signature is malformed (see `mpcSignatureToEcdsaSignature`)
57
+ */
58
+ export declare function buildSignedTronTransaction(raw: Uint8Array, signature: MpcSignature): Uint8Array;
59
+ //# sourceMappingURL=tron-transactions.d.ts.map
@@ -0,0 +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,MAAM,GAAG,UAAU,CAoB9D;AAED,MAAM;AACN,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,UAAU,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,qBAAqB,EAAE,MAAM,EAC7B,eAAe,EAAE,MAAM,EACvB,IAAI,EAAE,MAAM,GACX,WAAW,CAEb;AAED;;;;GAIG;AACH,wBAAgB,6CAA6C,CAC3D,qBAAqB,EAAE,MAAM,EAC7B,OAAO,EAAE,iCAAiC,GACzC,WAAW,CAIb;AAwDD;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,UAAU,GAAG,UAAU,CAkC3F;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,UAAU,GAAG,UAAU,CAE7D;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,GAAG,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,GAAG,UAAU,CAW/F"}
@@ -0,0 +1,195 @@
1
+ import { decodeBase58, encodeBase58, getBytes, sha256, toBeArray } from "ethers";
2
+ import { bigintToBytes32BE, hexToBytes, stripHexPrefix } from "./byte-codecs.js";
3
+ import { mpcSignatureToEcdsaSignature } from "./ecdsa-attestation.js";
4
+ import { deriveEvmAddress, deriveSignBidirectionalEventSignerEvmAddress, } from "./epsilon-derivation.js";
5
+ import { pureCircuits } from "./managed/contract/index.js";
6
+ const TRON_ADDRESS_PREFIX = 0x41;
7
+ const TRON_ADDRESS_BYTES = 21;
8
+ function assertTronAddress(address, name) {
9
+ if (address.length !== TRON_ADDRESS_BYTES || address[0] !== TRON_ADDRESS_PREFIX) {
10
+ throw new Error(`${name} must be 21 bytes with the 0x41 prefix`);
11
+ }
12
+ }
13
+ /**
14
+ * @param evm - The 20-byte EVM address, as bytes or hex (optional `0x`, any case)
15
+ * @returns The 21-byte Tron address
16
+ * @throws {Error} If the input is not exactly 20 bytes
17
+ */
18
+ export function tronAddressFromEvm(evm) {
19
+ if (typeof evm === "string") {
20
+ const digits = stripHexPrefix(evm);
21
+ if (!/^[0-9a-fA-F]{40}$/.test(digits)) {
22
+ throw new Error(`not a 20-byte EVM address in hex: "${evm}"`);
23
+ }
24
+ return pureCircuits.tronAddress(hexToBytes(digits));
25
+ }
26
+ if (evm.length !== 20) {
27
+ throw new Error(`EVM address must be 20 bytes, got ${String(evm.length)}`);
28
+ }
29
+ return pureCircuits.tronAddress(evm);
30
+ }
31
+ function base58CheckChecksum(address) {
32
+ return getBytes(sha256(sha256(address))).slice(0, 4);
33
+ }
34
+ /**
35
+ * @param address - The 21-byte, `0x41`-prefixed Tron address
36
+ * @returns The base58check text
37
+ * @throws {Error} If the address has the wrong length or prefix
38
+ */
39
+ export function tronAddressToBase58(address) {
40
+ assertTronAddress(address, "Tron address");
41
+ return encodeBase58(Uint8Array.from([...address, ...base58CheckChecksum(address)]));
42
+ }
43
+ /**
44
+ * @param text - The base58check text (`T…`)
45
+ * @returns The 21-byte Tron address
46
+ * @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
47
+ */
48
+ export function tronAddressFromBase58(text) {
49
+ let decoded;
50
+ try {
51
+ decoded = toBeArray(decodeBase58(text));
52
+ }
53
+ catch (error) {
54
+ throw new Error(`not a base58 Tron address: "${text}"`, { cause: error });
55
+ }
56
+ if (decoded.length !== TRON_ADDRESS_BYTES + 4) {
57
+ throw new Error(`expected 25 bytes (21 payload + 4 checksum), got ${String(decoded.length)}`);
58
+ }
59
+ const address = decoded.slice(0, TRON_ADDRESS_BYTES);
60
+ const checksum = decoded.slice(TRON_ADDRESS_BYTES);
61
+ if (!base58CheckChecksum(address).every((byte, index) => byte === checksum[index])) {
62
+ throw new Error("base58check checksum mismatch");
63
+ }
64
+ assertTronAddress(address, "Tron address");
65
+ if (encodeBase58(decoded) !== text) {
66
+ throw new Error(`not a canonical base58 Tron address: "${text}"`);
67
+ }
68
+ return address;
69
+ }
70
+ /**
71
+ * @param mpcSecp256k1PublicKey - The MPC root secp256k1 public key, in any spelling `parseSecp256k1PublicKey` accepts
72
+ * @param contractAddress - The Midnight contract address the request originates from (`0x` prefix optional, case-insensitive)
73
+ * @param path - The derivation path string
74
+ * @returns The derived address in both forms
75
+ */
76
+ export function deriveTronAddress(mpcSecp256k1PublicKey, contractAddress, path) {
77
+ return tronAddressOfEvm(deriveEvmAddress(mpcSecp256k1PublicKey, contractAddress, path));
78
+ }
79
+ /**
80
+ * @param mpcSecp256k1PublicKey - The MPC root secp256k1 public key of the record's `keyVersion`, in any spelling `parseSecp256k1PublicKey` accepts
81
+ * @param request - The on-ledger request record, or its `sender` and `path`
82
+ * @returns The Tron address the MPC signs that request's transaction from, in both forms
83
+ */
84
+ export function deriveSignBidirectionalEventSignerTronAddress(mpcSecp256k1PublicKey, request) {
85
+ return tronAddressOfEvm(deriveSignBidirectionalEventSignerEvmAddress(mpcSecp256k1PublicKey, request));
86
+ }
87
+ function tronAddressOfEvm(evm) {
88
+ const bytes = tronAddressFromEvm(evm);
89
+ return { bytes, base58: tronAddressToBase58(bytes) };
90
+ }
91
+ const TRIGGER_SMART_CONTRACT_TYPE_URL = "type.googleapis.com/protocol.TriggerSmartContract";
92
+ const TRIGGER_SMART_CONTRACT_TYPE = 31n;
93
+ const INT64_LIMIT = 2n ** 63n;
94
+ function varint(value) {
95
+ const out = [];
96
+ let rest = value;
97
+ while (rest >= 0x80n) {
98
+ out.push(Number(rest & 0x7fn) | 0x80);
99
+ rest >>= 7n;
100
+ }
101
+ out.push(Number(rest));
102
+ return out;
103
+ }
104
+ function varintField(field, value) {
105
+ return value === 0n ? [] : [...varint(BigInt(field << 3)), ...varint(value)];
106
+ }
107
+ function int64Field(field, value, name) {
108
+ if (value < 0n || value >= INT64_LIMIT) {
109
+ throw new Error(`${name} ${String(value)} exceeds the int64 wire field`);
110
+ }
111
+ return varintField(field, value);
112
+ }
113
+ function lengthDelimitedField(field, bytes) {
114
+ return [...varint(BigInt((field << 3) | 2)), ...varint(BigInt(bytes.length)), ...bytes];
115
+ }
116
+ function bytesField(field, bytes) {
117
+ return bytes.length === 0 ? [] : lengthDelimitedField(field, bytes);
118
+ }
119
+ function tronCalldata(params) {
120
+ if (!params.calldata.is_some) {
121
+ return [];
122
+ }
123
+ const { selector, noWords, words } = params.calldata.value;
124
+ if (noWords > BigInt(words.length)) {
125
+ throw new Error(`calldata noWords ${String(noWords)} exceeds the capacity of ${String(words.length)}`);
126
+ }
127
+ return [...selector, ...words.slice(0, Number(noWords)).flatMap((word) => [...word])];
128
+ }
129
+ /**
130
+ * @param params - The request's transaction parameters
131
+ * @param owner - The 21-byte Tron address of the request signing key (see {@link deriveTronAddress})
132
+ * @returns The raw transaction bytes
133
+ * @throws {Error} If a field cannot be represented
134
+ */
135
+ export function buildTronRawTransaction(params, owner) {
136
+ if (params.refBlockBytes.length !== 2) {
137
+ throw new Error("refBlockBytes must be TaPoS' two bytes");
138
+ }
139
+ if (params.refBlockHash.length !== 8) {
140
+ throw new Error("refBlockHash must be TaPoS' eight bytes");
141
+ }
142
+ if (params.expiration === 0n) {
143
+ throw new Error("missing expiration");
144
+ }
145
+ assertTronAddress(owner, "owner address");
146
+ assertTronAddress(params.contractAddress, "contract address");
147
+ const trigger = [
148
+ ...bytesField(1, owner),
149
+ ...bytesField(2, params.contractAddress),
150
+ ...int64Field(3, params.callValue, "callValue"),
151
+ ...bytesField(4, tronCalldata(params)),
152
+ ];
153
+ const parameter = [
154
+ ...bytesField(1, new TextEncoder().encode(TRIGGER_SMART_CONTRACT_TYPE_URL)),
155
+ ...bytesField(2, trigger),
156
+ ];
157
+ const contract = [
158
+ ...varintField(1, TRIGGER_SMART_CONTRACT_TYPE),
159
+ ...lengthDelimitedField(2, parameter),
160
+ ];
161
+ return Uint8Array.from([
162
+ ...bytesField(1, params.refBlockBytes),
163
+ ...bytesField(4, params.refBlockHash),
164
+ ...int64Field(8, params.expiration, "expiration"),
165
+ ...lengthDelimitedField(11, contract),
166
+ ...int64Field(14, params.timestamp, "timestamp"),
167
+ ...int64Field(18, params.feeLimit, "feeLimit"),
168
+ ]);
169
+ }
170
+ /**
171
+ * @param raw - The raw transaction bytes ({@link buildTronRawTransaction})
172
+ * @returns The 32-byte transaction id
173
+ */
174
+ export function tronTransactionId(raw) {
175
+ return getBytes(sha256(raw));
176
+ }
177
+ /**
178
+ * @param raw - The raw transaction bytes ({@link buildTronRawTransaction})
179
+ * @param signature - The signature as the MPC posts it
180
+ * @returns The signed transaction bytes
181
+ * @throws {Error} If the signature is malformed (see `mpcSignatureToEcdsaSignature`)
182
+ */
183
+ export function buildSignedTronTransaction(raw, signature) {
184
+ const { r, s, recoveryId } = mpcSignatureToEcdsaSignature(signature);
185
+ const signatureBytes = Uint8Array.from([
186
+ ...bigintToBytes32BE(r),
187
+ ...bigintToBytes32BE(s),
188
+ recoveryId,
189
+ ]);
190
+ return Uint8Array.from([
191
+ ...lengthDelimitedField(1, raw),
192
+ ...lengthDelimitedField(2, signatureBytes),
193
+ ]);
194
+ }
195
+ //# sourceMappingURL=tron-transactions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tron-transactions.js","sourceRoot":"","sources":["../src/tron-transactions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAEjF,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACjF,OAAO,EAAE,4BAA4B,EAAE,MAAM,wBAAwB,CAAC;AACtE,OAAO,EACL,gBAAgB,EAChB,4CAA4C,GAE7C,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAI3D,MAAM,mBAAmB,GAAG,IAAI,CAAC;AAEjC,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAE9B,SAAS,iBAAiB,CAAC,OAAmB,EAAE,IAAY;IAC1D,IAAI,OAAO,CAAC,MAAM,KAAK,kBAAkB,IAAI,OAAO,CAAC,CAAC,CA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E,MAAM,CAAC,YAAY,CAAC;QACrC,GAAG,UAAU,CAAC,CAAC,EAAE,MAAM,CAAC,UAAU,EAAE,YAAY,CAAC;QACjD,GAAG,oBAAoB,CAAC,EAAE,EAAE,QAAQ,CAAC;QACrC,GAAG,UAAU,CAAC,EAAE,EAAE,MAAM,CAAC,SAAS,EAAE,WAAW,CAAC;QAChD,GAAG,UAAU,CAAC,EAAE,EAAE,MAAM,CAAC,QAAQ,EAAE,UAAU,CAAC;KAC/C,CAAC,CAAC;AACL,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,GAAe;IAC/C,OAAO,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;AAC/B,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,0BAA0B,CAAC,GAAe,EAAE,SAAuB;IACjF,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,UAAU,EAAE,GAAG,4BAA4B,CAAC,SAAS,CAAC,CAAC;IACrE,MAAM,cAAc,GAAG,UAAU,CAAC,IAAI,CAAC;QACrC,GAAG,iBAAiB,CAAC,CAAC,CAAC;QACvB,GAAG,iBAAiB,CAAC,CAAC,CAAC;QACvB,UAAU;KACX,CAAC,CAAC;IACH,OAAO,UAAU,CAAC,IAAI,CAAC;QACrB,GAAG,oBAAoB,CAAC,CAAC,EAAE,GAAG,CAAC;QAC/B,GAAG,oBAAoB,CAAC,CAAC,EAAE,cAAc,CAAC;KAC3C,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * A URL with every query parameter value masked, for logs and error
3
+ * messages: a hosted Midnight endpoint carries its access token in the query
4
+ * string (Blockfrost's `project_id`).
5
+ *
6
+ * @param url - The URL to render.
7
+ * @returns The URL with each query value replaced by `REDACTED`, or `url`
8
+ * unchanged when it has no query string or does not parse as a URL.
9
+ */
10
+ export declare function redactUrlQuery(url: string): string;
11
+ //# sourceMappingURL=url-redaction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"url-redaction.d.ts","sourceRoot":"","sources":["../src/url-redaction.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAQlD"}