1
- import { Rpc , RpcTransport , SolanaRpcApiFromTransport } from "@solana/kit" ;
1
+ import { Address , Rpc , RpcTransport , SolanaRpcApiFromTransport } from "@solana/kit" ;
2
2
import winston from "winston" ;
3
- import { SVMEventNames , SvmSpokeEventsClient , unwrapEventData } from "../../arch/svm" ;
3
+ import {
4
+ SVMEventNames ,
5
+ SvmSpokeEventsClient ,
6
+ unwrapEventData ,
7
+ getFillDeadline ,
8
+ getTimestampForBlock ,
9
+ getStatePda ,
10
+ } from "../../arch/svm" ;
4
11
import { FillStatus , RelayData , SortableEvent } from "../../interfaces" ;
5
12
import {
6
13
BigNumber ,
@@ -27,6 +34,8 @@ export class SvmSpokePoolClient extends SpokePoolClient {
27
34
chainId : number ,
28
35
deploymentSlot : bigint , // Using slot instead of block number for SVM
29
36
eventSearchConfig : MakeOptional < EventSearchConfig , "toBlock" > ,
37
+ protected programId : Address ,
38
+ protected statePda : Address ,
30
39
protected svmEventsClient : SvmSpokeEventsClient ,
31
40
protected rpc : Rpc < SolanaRpcApiFromTransport < RpcTransport > >
32
41
) {
@@ -46,12 +55,16 @@ export class SvmSpokePoolClient extends SpokePoolClient {
46
55
rpc : Rpc < SolanaRpcApiFromTransport < RpcTransport > >
47
56
) : Promise < SvmSpokePoolClient > {
48
57
const svmEventsClient = await SvmSpokeEventsClient . create ( rpc ) ;
58
+ const programId = svmEventsClient . getSvmSpokeAddress ( ) ;
59
+ const statePda = await getStatePda ( programId ) ;
49
60
return new SvmSpokePoolClient (
50
61
logger ,
51
62
hubPoolClient ,
52
63
chainId ,
53
64
deploymentSlot ,
54
65
eventSearchConfig ,
66
+ programId ,
67
+ statePda ,
55
68
svmEventsClient ,
56
69
rpc
57
70
) ;
@@ -152,18 +165,18 @@ export class SvmSpokePoolClient extends SpokePoolClient {
152
165
}
153
166
154
167
/**
155
- * Retrieves the maximum fill deadline buffer.
156
- * TODO: Implement SVM equivalent, perhaps reading from a config account .
168
+ * Retrieves the fill deadline buffer fetched from the State PDA .
169
+ * @note This function assumes that fill deadline buffer is a constant value in svm environments .
157
170
*/
158
- public getMaxFillDeadlineInRange ( _startSlot : number , _endSlot : number ) : Promise < number > {
159
- throw new Error ( "getMaxFillDeadlineInRange not implemented for SVM" ) ;
171
+ public override getMaxFillDeadlineInRange ( _startSlot : number , _endSlot : number ) : Promise < number > {
172
+ return getFillDeadline ( this . rpc , this . statePda ) ;
160
173
}
161
174
162
175
/**
163
176
* Retrieves the timestamp for a given SVM slot number.
164
177
*/
165
- public getTimestampForBlock ( _blockNumber : number ) : Promise < number > {
166
- throw new Error ( " getTimestampForBlock not implemented for SVM" ) ;
178
+ public override getTimestampForBlock ( blockNumber : number ) : Promise < number > {
179
+ return getTimestampForBlock ( this . rpc , blockNumber ) ;
167
180
}
168
181
169
182
/**
0 commit comments