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

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 (62) hide show
  1. package/dist/compact-descriptors.d.ts +8 -0
  2. package/dist/compact-descriptors.d.ts.map +1 -1
  3. package/dist/compact-descriptors.js +13 -1
  4. package/dist/compact-descriptors.js.map +1 -1
  5. package/dist/constants.d.ts.map +1 -1
  6. package/dist/constants.js +18 -9
  7. package/dist/constants.js.map +1 -1
  8. package/dist/index.d.ts +5 -1
  9. package/dist/index.d.ts.map +1 -1
  10. package/dist/index.js +7 -2
  11. package/dist/index.js.map +1 -1
  12. package/dist/managed/compiler/contract-info.json +714 -5
  13. package/dist/managed/compiler/contract-manifest.json +8 -8
  14. package/dist/managed/contract/index.d.ts +168 -1
  15. package/dist/managed/contract/index.js +678 -312
  16. package/dist/managed/contract/index.js.map +1 -1
  17. package/dist/signature-requests-state-reader.d.ts +3 -3
  18. package/dist/signature-requests-state-reader.d.ts.map +1 -1
  19. package/dist/signature-requests-state-reader.js +6 -2
  20. package/dist/signature-requests-state-reader.js.map +1 -1
  21. package/dist/signature-response-verification.d.ts +24 -9
  22. package/dist/signature-response-verification.d.ts.map +1 -1
  23. package/dist/signature-response-verification.js +35 -12
  24. package/dist/signature-response-verification.js.map +1 -1
  25. package/dist/signet-contract-events.d.ts +6 -0
  26. package/dist/signet-contract-events.d.ts.map +1 -1
  27. package/dist/signet-contract-events.js +8 -6
  28. package/dist/signet-contract-events.js.map +1 -1
  29. package/dist/signet-evtype2tx-requests.d.ts.map +1 -1
  30. package/dist/signet-evtype2tx-requests.js +1 -7
  31. package/dist/signet-evtype2tx-requests.js.map +1 -1
  32. package/dist/signet-request-id.d.ts +2 -2
  33. package/dist/signet-request-id.d.ts.map +1 -1
  34. package/dist/signet-request-id.js +18 -8
  35. package/dist/signet-request-id.js.map +1 -1
  36. package/dist/signet-request-response-reader.d.ts +35 -11
  37. package/dist/signet-request-response-reader.d.ts.map +1 -1
  38. package/dist/signet-request-response-reader.js +76 -29
  39. package/dist/signet-request-response-reader.js.map +1 -1
  40. package/dist/signet-requests.d.ts +18 -10
  41. package/dist/signet-requests.d.ts.map +1 -1
  42. package/dist/signet-requests.js +19 -10
  43. package/dist/signet-requests.js.map +1 -1
  44. package/dist/signet-tron-record-decoding.d.ts +11 -0
  45. package/dist/signet-tron-record-decoding.d.ts.map +1 -0
  46. package/dist/signet-tron-record-decoding.js +29 -0
  47. package/dist/signet-tron-record-decoding.js.map +1 -0
  48. package/dist/signet-tron-requests.d.ts +36 -0
  49. package/dist/signet-tron-requests.d.ts.map +1 -0
  50. package/dist/signet-tron-requests.js +76 -0
  51. package/dist/signet-tron-requests.js.map +1 -0
  52. package/dist/tron-transactions.d.ts +52 -0
  53. package/dist/tron-transactions.d.ts.map +1 -0
  54. package/dist/tron-transactions.js +181 -0
  55. package/dist/tron-transactions.js.map +1 -0
  56. package/dist/url-redaction.d.ts +11 -0
  57. package/dist/url-redaction.d.ts.map +1 -0
  58. package/dist/url-redaction.js +21 -0
  59. package/dist/url-redaction.js.map +1 -0
  60. package/package.json +2 -2
  61. package/src/Signet.compact +71 -1
  62. package/src/circuits.compact +26 -0
@@ -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;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AI,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,52 @@
1
+ import type { MpcSignature } from "./signet-contract-events.ts";
2
+ import type { TronTxParams } from "./signet-tron-requests.ts";
3
+ /**
4
+ * @param evm - The 20-byte EVM address, as bytes or hex (optional `0x`, any case)
5
+ * @returns The 21-byte Tron address
6
+ * @throws {Error} If the input is not exactly 20 bytes
7
+ */
8
+ export declare function tronAddressFromEvm(evm: string | Uint8Array): Uint8Array;
9
+ /**
10
+ * @param address - The 21-byte, `0x41`-prefixed Tron address
11
+ * @returns The base58check text
12
+ * @throws {Error} If the address has the wrong length or prefix
13
+ */
14
+ export declare function tronAddressToBase58(address: Uint8Array): string;
15
+ /**
16
+ * @param text - The base58check text (`T…`)
17
+ * @returns The 21-byte Tron address
18
+ * @throws {Error} If the text is not base58, not 25 bytes, fails its checksum or does not carry the `0x41` prefix
19
+ */
20
+ export declare function tronAddressFromBase58(text: string): Uint8Array;
21
+ /** */
22
+ export interface TronAddress {
23
+ bytes: Uint8Array;
24
+ base58: string;
25
+ }
26
+ /**
27
+ * @param mpcSecp256k1PublicKey - The MPC root secp256k1 public key, in any spelling `parseSecp256k1PublicKey` accepts
28
+ * @param contractAddress - The Midnight contract address the request originates from (`0x` prefix optional, case-insensitive)
29
+ * @param path - The derivation path string
30
+ * @returns The derived address in both forms
31
+ */
32
+ export declare function deriveTronAddress(mpcSecp256k1PublicKey: string, contractAddress: string, path: string): TronAddress;
33
+ /**
34
+ * @param params - The request's transaction parameters
35
+ * @param owner - The 21-byte Tron address of the request signing key (see {@link deriveTronAddress})
36
+ * @returns The raw transaction bytes
37
+ * @throws {Error} If a field cannot be represented
38
+ */
39
+ export declare function buildTronRawTransaction(params: TronTxParams, owner: Uint8Array): Uint8Array;
40
+ /**
41
+ * @param raw - The raw transaction bytes ({@link buildTronRawTransaction})
42
+ * @returns The 32-byte transaction id
43
+ */
44
+ export declare function tronTransactionId(raw: Uint8Array): Uint8Array;
45
+ /**
46
+ * @param raw - The raw transaction bytes ({@link buildTronRawTransaction})
47
+ * @param signature - The signature as the MPC posts it
48
+ * @returns The signed transaction bytes
49
+ * @throws {Error} If the signature is malformed (see `mpcSignatureToEcdsaSignature`)
50
+ */
51
+ export declare function buildSignedTronTransaction(raw: Uint8Array, signature: MpcSignature): Uint8Array;
52
+ //# 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":"AAMA,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,CAiB9D;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,CAGb;AAmDD;;;;;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,181 @@
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 } 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 or does not carry the `0x41` prefix
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
+ return address;
66
+ }
67
+ /**
68
+ * @param mpcSecp256k1PublicKey - The MPC root secp256k1 public key, in any spelling `parseSecp256k1PublicKey` accepts
69
+ * @param contractAddress - The Midnight contract address the request originates from (`0x` prefix optional, case-insensitive)
70
+ * @param path - The derivation path string
71
+ * @returns The derived address in both forms
72
+ */
73
+ export function deriveTronAddress(mpcSecp256k1PublicKey, contractAddress, path) {
74
+ const bytes = tronAddressFromEvm(deriveEvmAddress(mpcSecp256k1PublicKey, contractAddress, path));
75
+ return { bytes, base58: tronAddressToBase58(bytes) };
76
+ }
77
+ const TRIGGER_SMART_CONTRACT_TYPE_URL = "type.googleapis.com/protocol.TriggerSmartContract";
78
+ const TRIGGER_SMART_CONTRACT_TYPE = 31n;
79
+ const INT64_LIMIT = 2n ** 63n;
80
+ function varint(value) {
81
+ const out = [];
82
+ let rest = value;
83
+ while (rest >= 0x80n) {
84
+ out.push(Number(rest & 0x7fn) | 0x80);
85
+ rest >>= 7n;
86
+ }
87
+ out.push(Number(rest));
88
+ return out;
89
+ }
90
+ function varintField(field, value) {
91
+ return value === 0n ? [] : [...varint(BigInt(field << 3)), ...varint(value)];
92
+ }
93
+ function int64Field(field, value, name) {
94
+ if (value < 0n || value >= INT64_LIMIT) {
95
+ throw new Error(`${name} ${String(value)} exceeds the int64 wire field`);
96
+ }
97
+ return varintField(field, value);
98
+ }
99
+ function lengthDelimitedField(field, bytes) {
100
+ return [...varint(BigInt((field << 3) | 2)), ...varint(BigInt(bytes.length)), ...bytes];
101
+ }
102
+ function bytesField(field, bytes) {
103
+ return bytes.length === 0 ? [] : lengthDelimitedField(field, bytes);
104
+ }
105
+ function tronCalldata(params) {
106
+ if (!params.calldata.is_some) {
107
+ return [];
108
+ }
109
+ const { selector, noWords, words } = params.calldata.value;
110
+ if (noWords > BigInt(words.length)) {
111
+ throw new Error(`calldata noWords ${String(noWords)} exceeds the capacity of ${String(words.length)}`);
112
+ }
113
+ return [...selector, ...words.slice(0, Number(noWords)).flatMap((word) => [...word])];
114
+ }
115
+ /**
116
+ * @param params - The request's transaction parameters
117
+ * @param owner - The 21-byte Tron address of the request signing key (see {@link deriveTronAddress})
118
+ * @returns The raw transaction bytes
119
+ * @throws {Error} If a field cannot be represented
120
+ */
121
+ export function buildTronRawTransaction(params, owner) {
122
+ if (params.refBlockBytes.length !== 2) {
123
+ throw new Error("refBlockBytes must be TaPoS' two bytes");
124
+ }
125
+ if (params.refBlockHash.length !== 8) {
126
+ throw new Error("refBlockHash must be TaPoS' eight bytes");
127
+ }
128
+ if (params.expiration === 0n) {
129
+ throw new Error("missing expiration");
130
+ }
131
+ assertTronAddress(owner, "owner address");
132
+ assertTronAddress(params.contractAddress, "contract address");
133
+ const trigger = [
134
+ ...bytesField(1, owner),
135
+ ...bytesField(2, params.contractAddress),
136
+ ...int64Field(3, params.callValue, "callValue"),
137
+ ...bytesField(4, tronCalldata(params)),
138
+ ];
139
+ const parameter = [
140
+ ...bytesField(1, new TextEncoder().encode(TRIGGER_SMART_CONTRACT_TYPE_URL)),
141
+ ...bytesField(2, trigger),
142
+ ];
143
+ const contract = [
144
+ ...varintField(1, TRIGGER_SMART_CONTRACT_TYPE),
145
+ ...lengthDelimitedField(2, parameter),
146
+ ];
147
+ return Uint8Array.from([
148
+ ...bytesField(1, params.refBlockBytes),
149
+ ...bytesField(4, params.refBlockHash),
150
+ ...int64Field(8, params.expiration, "expiration"),
151
+ ...lengthDelimitedField(11, contract),
152
+ ...int64Field(14, params.timestamp, "timestamp"),
153
+ ...int64Field(18, params.feeLimit, "feeLimit"),
154
+ ]);
155
+ }
156
+ /**
157
+ * @param raw - The raw transaction bytes ({@link buildTronRawTransaction})
158
+ * @returns The 32-byte transaction id
159
+ */
160
+ export function tronTransactionId(raw) {
161
+ return getBytes(sha256(raw));
162
+ }
163
+ /**
164
+ * @param raw - The raw transaction bytes ({@link buildTronRawTransaction})
165
+ * @param signature - The signature as the MPC posts it
166
+ * @returns The signed transaction bytes
167
+ * @throws {Error} If the signature is malformed (see `mpcSignatureToEcdsaSignature`)
168
+ */
169
+ export function buildSignedTronTransaction(raw, signature) {
170
+ const { r, s, recoveryId } = mpcSignatureToEcdsaSignature(signature);
171
+ const signatureBytes = Uint8Array.from([
172
+ ...bigintToBytes32BE(r),
173
+ ...bigintToBytes32BE(s),
174
+ recoveryId,
175
+ ]);
176
+ return Uint8Array.from([
177
+ ...lengthDelimitedField(1, raw),
178
+ ...lengthDelimitedField(2, signatureBytes),
179
+ ]);
180
+ }
181
+ //# 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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AAM,CAAC,aAAa,CAAC;QACtC,GAAG,UAAU,CAAC,CAAC,EAAE,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"}
@@ -0,0 +1,21 @@
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 function redactUrlQuery(url) {
11
+ if (!URL.canParse(url))
12
+ return url;
13
+ const parsed = new URL(url);
14
+ if (parsed.search === "")
15
+ return url;
16
+ for (const name of [...parsed.searchParams.keys()]) {
17
+ parsed.searchParams.set(name, "REDACTED");
18
+ }
19
+ return parsed.toString();
20
+ }
21
+ //# sourceMappingURL=url-redaction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"url-redaction.js","sourceRoot":"","sources":["../src/url-redaction.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,UAAU,cAAc,CAAC,GAAW;IACxC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC;QAAE,OAAO,GAAG,CAAC;IACnC,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;IAC5B,IAAI,MAAM,CAAC,MAAM,KAAK,EAAE;QAAE,OAAO,GAAG,CAAC;IACrC,KAAK,MAAM,IAAI,IAAI,CAAC,GAAG,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC;QACnD,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IAC5C,CAAC;IACD,OAAO,MAAM,CAAC,QAAQ,EAAE,CAAC;AAC3B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sig-net/midnight",
3
- "version": "0.26.0-rc.9",
3
+ "version": "0.27.0-rc.2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/sig-net/midnight-integration",
@@ -49,7 +49,7 @@
49
49
  "@midnight-ntwrk/compact-runtime": "0.21.0",
50
50
  "@midnight-ntwrk/midnight-js-types": "5.0.0",
51
51
  "@noble/curves": "^2.2.0",
52
- "@sig-net/midnight-serde": "^0.26.0-rc.9",
52
+ "@sig-net/midnight-serde": "^0.27.0-rc.2",
53
53
  "ethers": "^6.17.0"
54
54
  },
55
55
  "devDependencies": {
@@ -77,6 +77,8 @@ module Signet {
77
77
  evmType2TxAccessEntry,
78
78
  evmType2TxStorageKey,
79
79
  attestedOutput,
80
+ tronTxHeader,
81
+ tronTxWord,
80
82
  }
81
83
 
82
84
  // ---- SignBidirectionalEvent ------------------------------------------------------------------------
@@ -160,7 +162,7 @@ module Signet {
160
162
  // contains so an off-chain consumer (e.g. the MPC) knows how to re-assemble it.
161
163
  export enum TxParamType {
162
164
  evmType2, // EvmType2TxParams: an EIP-1559 EVM transaction (envelope + calldata)
163
- reserved, // Reserved for future use. Exists to keep enum >= 2 (proof server bug).
165
+ tron,
164
166
  }
165
167
 
166
168
  // Construction helper for the canonical Signet SignBidirectionalEventV1.
@@ -679,6 +681,74 @@ module Signet {
679
681
  return calculateRequestIdV1(preimage);
680
682
  }
681
683
 
684
+ export pure circuit tronCaip2Id(): Bytes<64> {
685
+ return pad(64, "tron:mainnet");
686
+ }
687
+
688
+ export pure circuit tronAddress(evmAddress: Bytes<20>): Bytes<21> {
689
+ return Bytes[0x41, ...evmAddress];
690
+ }
691
+
692
+ export struct TronTxParams<#maxCalldataWords> {
693
+ refBlockBytes: Bytes<2>;
694
+ refBlockHash: Bytes<8>;
695
+ timestamp: Uint<64>;
696
+ expiration: Uint<64>;
697
+ feeLimit: Uint<64>;
698
+ contractAddress: Bytes<21>;
699
+ callValue: Uint<64>;
700
+ calldata: Maybe<EvmCalldata<maxCalldataWords>>;
701
+ }
702
+
703
+ export pure circuit calculateTronTxParamsDigestV1<#maxCalldataWords>(
704
+ txParams: TronTxParams<maxCalldataWords>
705
+ ): Bytes<32> {
706
+ const calldata = txParams.calldata;
707
+ const noWords = calldata.is_some ? calldata.value.noWords : 0 as Uint<16>;
708
+ const selector = calldata.is_some ? calldata.value.selector : default<Bytes<4>>;
709
+
710
+ assert(noWords <= maxCalldataWords, "calldata noWords exceeds capacity");
711
+
712
+ const head = transientHash<[HashDomain, Bytes<2>, Bytes<8>, Uint<64>, Uint<64>, Uint<64>, Bytes<21>, Uint<64>, Boolean, Bytes<4>, Uint<16>]>([
713
+ HashDomain.tronTxHeader,
714
+ txParams.refBlockBytes,
715
+ txParams.refBlockHash,
716
+ txParams.timestamp,
717
+ txParams.expiration,
718
+ txParams.feeLimit,
719
+ txParams.contractAddress,
720
+ txParams.callValue,
721
+ calldata.is_some,
722
+ selector,
723
+ noWords
724
+ ]);
725
+
726
+ const wordsScan = fold(
727
+ (acc: [Uint<16>, Field], word: Bytes<32>): [Uint<16>, Field] =>
728
+ [(acc[0] + 1) as Uint<16>, acc[0] < noWords ? transientHash<[HashDomain, Field, Bytes<32>]>([HashDomain.tronTxWord, acc[1], word]) : acc[1]],
729
+ [0 as Uint<16>, head],
730
+ calldata.value.words
731
+ );
732
+
733
+ return upgradeFromTransient(wordsScan[1]);
734
+ }
735
+
736
+ export pure circuit calculateTronRequestIdV1<#maxCalldataWords, #LenOutputDeserialization>(
737
+ request: SignBidirectionalEventV1<TronTxParams<maxCalldataWords>, LenOutputDeserialization, 0>
738
+ ): RequestId {
739
+ assert(request.txParamType == TxParamType.tron, "txParamType must tag txParams as tron");
740
+ const preimage = RequestIdPreimageV1 {
741
+ keyVersion: request.keyVersion,
742
+ sender: request.sender,
743
+ path: request.path,
744
+ algo: request.algo,
745
+ txParamType: request.txParamType,
746
+ txParamsDigest: calculateTronTxParamsDigestV1<maxCalldataWords>(request.txParams),
747
+ executionDest: request.executionDest,
748
+ };
749
+ return calculateRequestIdV1(preimage);
750
+ }
751
+
682
752
  // ---- ABI Calldata Word Construction Utilities ------------------------------------------------------
683
753
  // Canonical ABI word builders and readers. Words MUST be stored in canonical
684
754
  // ABI form (big-endian, per the ABI spec). These utilities help construct
@@ -16,6 +16,8 @@ export {
16
16
  verifyRespondBidirectionalAttestationV1,
17
17
  constructSignBidirectionalEventNotificationV1,
18
18
  ethereumCaip2Id,
19
+ tronCaip2Id,
20
+ tronAddress,
19
21
  evmAddressAbiWord,
20
22
  numericAbiWord,
21
23
  boolAbiWord,
@@ -154,3 +156,27 @@ export pure circuit constructSignBidirectionalEventV1_1_0_0_34(
154
156
  request.outputDeserializationSchema
155
157
  );
156
158
  }
159
+
160
+ export pure circuit calculateTronTxParamsDigestV1_1(
161
+ txParams: TronTxParams<1>
162
+ ): Bytes<32> {
163
+ return calculateTronTxParamsDigestV1<1>(txParams);
164
+ }
165
+
166
+ export pure circuit calculateTronTxParamsDigestV1_2(
167
+ txParams: TronTxParams<2>
168
+ ): Bytes<32> {
169
+ return calculateTronTxParamsDigestV1<2>(txParams);
170
+ }
171
+
172
+ export pure circuit calculateTronRequestIdV1_1_0(
173
+ request: SignBidirectionalEventV1<TronTxParams<1>, 0, 0>
174
+ ): RequestId {
175
+ return calculateTronRequestIdV1<1, 0>(request);
176
+ }
177
+
178
+ export pure circuit calculateTronRequestIdV1_2_0(
179
+ request: SignBidirectionalEventV1<TronTxParams<2>, 0, 0>
180
+ ): RequestId {
181
+ return calculateTronRequestIdV1<2, 0>(request);
182
+ }