@tapforce/pod-bridge-sdk 1.2.4 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +115 -156
- package/dist/clients/action/pod-to-source-chain-client.d.ts +20 -21
- package/dist/clients/action/pod-to-source-chain-client.js +25 -27
- package/dist/clients/action/source-chain-to-pod-client.d.ts +7 -6
- package/dist/clients/action/source-chain-to-pod-client.js +9 -8
- package/dist/clients/tracker/client.d.ts +5 -9
- package/dist/clients/tracker/client.js +12 -17
- package/dist/clients/tracker/pod-tracker.service.d.ts +4 -13
- package/dist/clients/tracker/pod-tracker.service.js +34 -31
- package/dist/clients/tracker/source-chain-tracker.service.d.ts +5 -10
- package/dist/clients/tracker/source-chain-tracker.service.js +25 -20
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -11
- package/dist/libs/abi/bridge.abi.d.ts +14 -6
- package/dist/libs/abi/bridge.abi.js +30 -20
- package/dist/libs/helpers/bridge-claim-proof.helper.d.ts +16 -0
- package/dist/libs/helpers/bridge-claim-proof.helper.js +27 -0
- package/dist/libs/helpers/convert-certified-log.helper.d.ts +2 -6
- package/dist/libs/helpers/convert-certified-log.helper.js +4 -8
- package/dist/libs/types/pod-bridge.types.d.ts +54 -17
- package/package.json +1 -1
- package/dist/libs/helpers/signature-recovery.helper.d.ts +0 -161
- package/dist/libs/helpers/signature-recovery.helper.js +0 -447
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getBridgeClaimProof = getBridgeClaimProof;
|
|
4
|
+
/**
|
|
5
|
+
* Convert a number[] byte array to a 0x-prefixed hex string.
|
|
6
|
+
*/
|
|
7
|
+
function bytesToHex(bytes) {
|
|
8
|
+
return '0x' + bytes.map(b => b.toString(16).padStart(2, '0')).join('');
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Fetch bridge claim proof from Pod RPC.
|
|
12
|
+
*
|
|
13
|
+
* Calls the `pod_getBridgeClaimProof` RPC method with the deposit transaction hash
|
|
14
|
+
* and returns the proof data formatted for use with the ETH bridge claim function.
|
|
15
|
+
*
|
|
16
|
+
* @param podProvider A JsonRpcProvider connected to the Pod RPC
|
|
17
|
+
* @param depositTxHash The deposit transaction hash on Pod
|
|
18
|
+
* @returns Formatted proof data ready for the claim call
|
|
19
|
+
*/
|
|
20
|
+
async function getBridgeClaimProof(podProvider, depositTxHash) {
|
|
21
|
+
const response = await podProvider.send('pod_getBridgeClaimProof', [depositTxHash]);
|
|
22
|
+
return {
|
|
23
|
+
proof: bytesToHex(response.proof),
|
|
24
|
+
committeeEpoch: response.committee_epoch,
|
|
25
|
+
auxTxSuffix: bytesToHex(response.aux_tx_suffix),
|
|
26
|
+
};
|
|
27
|
+
}
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @deprecated This helper is no longer needed in the new bridge architecture.
|
|
3
3
|
*
|
|
4
|
-
* The new bridge uses
|
|
5
|
-
* See
|
|
6
|
-
*
|
|
7
|
-
* New architecture:
|
|
8
|
-
* - ETH -> Pod: Auto-claim on Pod (no claim transaction needed)
|
|
9
|
-
* - Pod -> ETH: Claim with aggregated 65-byte ECDSA signatures
|
|
4
|
+
* The new bridge uses pod_getBridgeClaimProof RPC for claim proofs.
|
|
5
|
+
* See bridge-claim-proof.helper.ts for the new helper.
|
|
10
6
|
*/
|
|
11
7
|
export declare const convertFFICertifiedLog: (_ffi: unknown) => never;
|
|
@@ -2,18 +2,14 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* @deprecated This helper is no longer needed in the new bridge architecture.
|
|
4
4
|
*
|
|
5
|
-
* The new bridge uses
|
|
6
|
-
* See
|
|
7
|
-
*
|
|
8
|
-
* New architecture:
|
|
9
|
-
* - ETH -> Pod: Auto-claim on Pod (no claim transaction needed)
|
|
10
|
-
* - Pod -> ETH: Claim with aggregated 65-byte ECDSA signatures
|
|
5
|
+
* The new bridge uses pod_getBridgeClaimProof RPC for claim proofs.
|
|
6
|
+
* See bridge-claim-proof.helper.ts for the new helper.
|
|
11
7
|
*/
|
|
12
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
9
|
exports.convertFFICertifiedLog = void 0;
|
|
14
10
|
// Kept for backwards compatibility, but will be removed in future versions
|
|
15
11
|
const convertFFICertifiedLog = (_ffi) => {
|
|
16
|
-
console.warn('[DEPRECATED] convertFFICertifiedLog is deprecated. Use
|
|
17
|
-
throw new Error('CertifiedLog format is no longer supported. Use ClaimProofData with
|
|
12
|
+
console.warn('[DEPRECATED] convertFFICertifiedLog is deprecated. Use getBridgeClaimProof instead.');
|
|
13
|
+
throw new Error('CertifiedLog format is no longer supported. Use ClaimProofData with proof from pod_getBridgeClaimProof.');
|
|
18
14
|
};
|
|
19
15
|
exports.convertFFICertifiedLog = convertFFICertifiedLog;
|
|
@@ -69,13 +69,12 @@ export interface UnsignedTransaction {
|
|
|
69
69
|
*
|
|
70
70
|
* Flow:
|
|
71
71
|
* 1. User deposits on Pod: pod_bridge.deposit(pod_token, amount, recipient)
|
|
72
|
-
* 2.
|
|
73
|
-
* 3. User claims on ETH: eth_bridge.claim(eth_token, amount, recipient,
|
|
72
|
+
* 2. Call pod_getBridgeClaimProof(depositTxHash) to get proof
|
|
73
|
+
* 3. User claims on ETH: eth_bridge.claim(eth_token, amount, recipient, proof, auxTxSuffix)
|
|
74
74
|
*
|
|
75
75
|
* Important:
|
|
76
76
|
* - Token addresses differ between Pod and ETH (deposit AAAA on Pod, claim BBBB on ETH)
|
|
77
|
-
* -
|
|
78
|
-
* - Proof is the deposit transaction hash from Pod
|
|
77
|
+
* - Use getBridgeClaimProof helper or call pod_getBridgeClaimProof RPC directly
|
|
79
78
|
*/
|
|
80
79
|
export interface ClaimProofData {
|
|
81
80
|
/** Token address on ETH to claim (different from Pod token address) */
|
|
@@ -84,17 +83,55 @@ export interface ClaimProofData {
|
|
|
84
83
|
amount: string | bigint;
|
|
85
84
|
/** Recipient address (same as deposit recipient) */
|
|
86
85
|
to: string;
|
|
87
|
-
/**
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
86
|
+
/** Hex-encoded proof bytes from pod_getBridgeClaimProof */
|
|
87
|
+
proof: string;
|
|
88
|
+
/** Hex-encoded aux_tx_suffix bytes from pod_getBridgeClaimProof */
|
|
89
|
+
auxTxSuffix: string;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Raw response from pod_getBridgeClaimProof RPC method
|
|
93
|
+
*/
|
|
94
|
+
export interface BridgeClaimProofResponse {
|
|
95
|
+
proof: number[];
|
|
96
|
+
committee_epoch: number;
|
|
97
|
+
aux_tx_suffix: number[];
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Attestation from a validator (POD-specific)
|
|
101
|
+
* From: eth_getTransactionReceipt result.pod_metadata.attestations[]
|
|
102
|
+
*/
|
|
103
|
+
export interface RpcAttestation {
|
|
104
|
+
validator_address: string;
|
|
105
|
+
sequence_number: number;
|
|
106
|
+
batch_index: number;
|
|
107
|
+
timestamp: number;
|
|
108
|
+
signature: string;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* POD metadata from receipt
|
|
112
|
+
* From: eth_getTransactionReceipt result.pod_metadata
|
|
113
|
+
*/
|
|
114
|
+
export interface RpcPodMetadata {
|
|
115
|
+
attestations: RpcAttestation[];
|
|
116
|
+
committee_epoch: number;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Raw eth_getTransactionReceipt response for POD chain
|
|
120
|
+
*/
|
|
121
|
+
export interface RpcPodTransactionReceipt {
|
|
122
|
+
type: string;
|
|
123
|
+
status: string;
|
|
124
|
+
cumulativeGasUsed: string;
|
|
125
|
+
logs: any[];
|
|
126
|
+
logsBloom: string;
|
|
127
|
+
transactionHash: string;
|
|
128
|
+
transactionIndex: string;
|
|
129
|
+
blockHash: string;
|
|
130
|
+
blockNumber: string;
|
|
131
|
+
gasUsed: string;
|
|
132
|
+
effectiveGasPrice: string;
|
|
133
|
+
from: string;
|
|
134
|
+
to: string;
|
|
135
|
+
contractAddress: string | null;
|
|
136
|
+
pod_metadata: RpcPodMetadata;
|
|
100
137
|
}
|
package/package.json
CHANGED
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
import { PodTransactionReceipt } from '../pod-sdk/src/types/responses';
|
|
2
|
-
/**
|
|
3
|
-
* Parse a DER-encoded ECDSA signature to extract r and s components.
|
|
4
|
-
*
|
|
5
|
-
* DER format:
|
|
6
|
-
* 0x30 [total-length] 0x02 [r-length] [r] 0x02 [s-length] [s]
|
|
7
|
-
*
|
|
8
|
-
* Example: 3044022020749ca9...0220292484ed...
|
|
9
|
-
* - 30 = SEQUENCE tag
|
|
10
|
-
* - 44 = total length (68 bytes)
|
|
11
|
-
* - 02 = INTEGER tag for r
|
|
12
|
-
* - 20 = r length (32 bytes)
|
|
13
|
-
* - [32 bytes of r]
|
|
14
|
-
* - 02 = INTEGER tag for s
|
|
15
|
-
* - 20 = s length (32 bytes)
|
|
16
|
-
* - [32 bytes of s]
|
|
17
|
-
*
|
|
18
|
-
* @param derSignature The DER-encoded signature as hex string
|
|
19
|
-
* @returns Object with r and s as 32-byte hex strings (0x prefixed)
|
|
20
|
-
*/
|
|
21
|
-
export declare function parseDerSignature(derSignature: string): {
|
|
22
|
-
r: string;
|
|
23
|
-
s: string;
|
|
24
|
-
};
|
|
25
|
-
/**
|
|
26
|
-
* Derive Ethereum address from a public key.
|
|
27
|
-
*
|
|
28
|
-
* @param publicKey The public key (uncompressed 65 bytes with 04 prefix, or 64 bytes x||y)
|
|
29
|
-
* @returns The Ethereum address
|
|
30
|
-
*/
|
|
31
|
-
export declare function addressFromPublicKey(publicKey: string): string;
|
|
32
|
-
/**
|
|
33
|
-
* Recover a 65-byte ECDSA signature (r,s,v) from a 64-byte compact signature.
|
|
34
|
-
*
|
|
35
|
-
* Exactly matches the Rust implementation:
|
|
36
|
-
* ```rust
|
|
37
|
-
* pub fn recover_65b_signature(
|
|
38
|
-
* sig: &Signature,
|
|
39
|
-
* msg_hash: [u8; 32],
|
|
40
|
-
* pubkey: &PublicKey,
|
|
41
|
-
* ) -> anyhow::Result<[u8; 65]> {
|
|
42
|
-
* let secp = Secp256k1::new();
|
|
43
|
-
* let msg = Message::from_digest(msg_hash);
|
|
44
|
-
* let sig_bytes = sig.serialize_compact();
|
|
45
|
-
*
|
|
46
|
-
* for recovery_id in [RecoveryId::Zero, RecoveryId::One] {
|
|
47
|
-
* let recoverable_sig = RecoverableSignature::from_compact(&sig_bytes, recovery_id)?;
|
|
48
|
-
* match secp.recover_ecdsa(msg, &recoverable_sig) {
|
|
49
|
-
* Ok(recovered_key) => {
|
|
50
|
-
* if recovered_key == *pubkey {
|
|
51
|
-
* return Ok(recoverable_sig.to_alloy().as_bytes());
|
|
52
|
-
* }
|
|
53
|
-
* }
|
|
54
|
-
* Err(e) => { ... }
|
|
55
|
-
* }
|
|
56
|
-
* }
|
|
57
|
-
* Err(anyhow!("Could not find valid recovery ID for signature"))
|
|
58
|
-
* }
|
|
59
|
-
* ```
|
|
60
|
-
*
|
|
61
|
-
* @param r The r component of the signature (32 bytes hex)
|
|
62
|
-
* @param s The s component of the signature (32 bytes hex)
|
|
63
|
-
* @param msgHash The 32-byte message hash that was signed
|
|
64
|
-
* @param publicKey The expected signer's public key
|
|
65
|
-
* @returns The 65-byte signature (r || s || v) or null if recovery fails
|
|
66
|
-
*/
|
|
67
|
-
export declare function recoverSignature65B(r: string, s: string, msgHash: string, publicKey: string): string | null;
|
|
68
|
-
/**
|
|
69
|
-
* Recover multiple 65-byte signatures from concatenated 64-byte signatures.
|
|
70
|
-
*
|
|
71
|
-
* @param aggregatedSig64 Concatenated 64-byte signatures (r || s for each)
|
|
72
|
-
* @param msgHash The message hash that was signed
|
|
73
|
-
* @param publicKeys Array of expected signer public keys in order
|
|
74
|
-
* @returns Concatenated 65-byte signatures or null if any recovery fails
|
|
75
|
-
*/
|
|
76
|
-
export declare function recoverAggregatedSignatures65B(aggregatedSig64: string | Uint8Array, msgHash: string, publicKeys: string[]): string | null;
|
|
77
|
-
/**
|
|
78
|
-
* Compute the transaction hash for a bridge deposit that needs to be signed.
|
|
79
|
-
* This matches the depositTxHash function in the Bridge.sol contract.
|
|
80
|
-
*
|
|
81
|
-
* @param domainSeparator The domain separator from the bridge contract
|
|
82
|
-
* @param bridgeContract The address of the bridge contract on the other chain
|
|
83
|
-
* @param token The token address
|
|
84
|
-
* @param amount The amount
|
|
85
|
-
* @param to The recipient address
|
|
86
|
-
* @param proof The proof (deposit TX hash)
|
|
87
|
-
* @returns The transaction hash to be signed
|
|
88
|
-
*/
|
|
89
|
-
export declare function computeDepositTxHash(domainSeparator: string, bridgeContract: string, token: string, amount: bigint | string, to: string, proof: string): string;
|
|
90
|
-
/**
|
|
91
|
-
* Extract aggregated 65-byte signatures from Pod transaction receipt.
|
|
92
|
-
*
|
|
93
|
-
* Receipt format:
|
|
94
|
-
* - attested_tx.hash: The transaction hash that was signed
|
|
95
|
-
* - signatures: Object with numeric keys containing DER-encoded signatures
|
|
96
|
-
*
|
|
97
|
-
* @param receipt The Pod transaction receipt
|
|
98
|
-
* @param msgHash Optional override for the message hash (defaults to attested_tx.hash)
|
|
99
|
-
* @param committeePublicKeys Optional array of validator public keys for v-value recovery
|
|
100
|
-
* @returns Concatenated 65-byte signatures (r || s || v for each signature)
|
|
101
|
-
*/
|
|
102
|
-
export declare function extractAggregatedSignatures(receipt: PodTransactionReceipt, msgHash?: string, committeePublicKeys?: string[]): string;
|
|
103
|
-
/**
|
|
104
|
-
* Recover a 65-byte signature without knowing the public key.
|
|
105
|
-
* Tries both v values (27 and 28) and returns the first valid recovery.
|
|
106
|
-
*
|
|
107
|
-
* WARNING: This is less secure as we can't verify the signer.
|
|
108
|
-
* Use recoverSignature65B with public key when possible.
|
|
109
|
-
*
|
|
110
|
-
* @param r The r component
|
|
111
|
-
* @param s The s component
|
|
112
|
-
* @param msgHash The message hash
|
|
113
|
-
* @returns The 65-byte signature with v=27 (tries 27 first, then 28)
|
|
114
|
-
*/
|
|
115
|
-
export declare function recoverSignatureWithoutPubkey(r: string, s: string, msgHash: string): string;
|
|
116
|
-
/**
|
|
117
|
-
* Recover a 65-byte signature by checking which v-value recovers to a known validator address.
|
|
118
|
-
*
|
|
119
|
-
* @param r The r component
|
|
120
|
-
* @param s The s component
|
|
121
|
-
* @param msgHash The message hash
|
|
122
|
-
* @param validatorAddresses Set of known validator addresses (lowercase)
|
|
123
|
-
* @returns Object with signature and recovered address, or null if no validator match
|
|
124
|
-
*/
|
|
125
|
-
export declare function recoverSignatureWithValidators(r: string, s: string, msgHash: string, validatorAddresses: Set<string>): {
|
|
126
|
-
signature: string;
|
|
127
|
-
recoveredAddress: string;
|
|
128
|
-
} | null;
|
|
129
|
-
/**
|
|
130
|
-
* Decompress a compressed secp256k1 public key (33 bytes) to uncompressed format.
|
|
131
|
-
* Compressed format: 02/03 prefix + 32-byte x coordinate
|
|
132
|
-
* Uncompressed format: 04 prefix + 32-byte x + 32-byte y
|
|
133
|
-
*
|
|
134
|
-
* @param compressedPubKey The compressed public key (66 hex chars with 02/03 prefix)
|
|
135
|
-
* @returns The uncompressed public key (130 hex chars with 04 prefix)
|
|
136
|
-
*/
|
|
137
|
-
export declare function decompressPublicKey(compressedPubKey: string): string;
|
|
138
|
-
/**
|
|
139
|
-
* Extract aggregated 65-byte signatures using validator public keys for v-value recovery.
|
|
140
|
-
* Committee format: Array of [index, compressed_public_key] tuples
|
|
141
|
-
*
|
|
142
|
-
* @param receipt The Pod transaction receipt
|
|
143
|
-
* @param validators Array of [index, compressedPubKey] tuples from pod_getCommittee
|
|
144
|
-
* @param msgHash Optional override for the message hash
|
|
145
|
-
* @returns Concatenated 65-byte signatures (r || s || v for each signature)
|
|
146
|
-
*/
|
|
147
|
-
export declare function extractAggregatedSignaturesWithValidators(receipt: PodTransactionReceipt, validators: [number, string][], msgHash?: string): string;
|
|
148
|
-
/**
|
|
149
|
-
* Extract signature info from Pod receipt for debugging/verification.
|
|
150
|
-
*
|
|
151
|
-
* @param receipt The Pod transaction receipt
|
|
152
|
-
* @param msgHash Optional override for the message hash
|
|
153
|
-
* @returns Array of signature info with recovered 65-byte signatures
|
|
154
|
-
*/
|
|
155
|
-
export declare function extractSignatureInfo(receipt: PodTransactionReceipt, msgHash?: string): Array<{
|
|
156
|
-
index: number;
|
|
157
|
-
derSignature: string;
|
|
158
|
-
r: string;
|
|
159
|
-
s: string;
|
|
160
|
-
signature65: string;
|
|
161
|
-
}>;
|