Skip to content

Commit 144a46b

Browse files
committed
Update client sdk
1 parent 6024b68 commit 144a46b

File tree

9 files changed

+322
-17
lines changed

9 files changed

+322
-17
lines changed

pkg/client-sdk/client/client.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -361,12 +361,18 @@ type TransactionHistoryResponse struct {
361361
Page PageResponse
362362
}
363363

364-
type Transactions struct {
365-
Txs []string
364+
type ChainWithExpiry struct {
365+
Txs []ChainTx
366+
ExpiresAt int64
367+
}
368+
369+
type ChainTx struct {
370+
Txid string
371+
Type string
366372
}
367373

368374
type VtxoChainResponse struct {
369-
Graph map[string]*Transactions
375+
Graph map[string]*ChainWithExpiry
370376
Page PageResponse
371377
}
372378

pkg/client-sdk/client/grpc/client.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -755,10 +755,11 @@ func (a *grpcClient) GetVtxoChain(ctx context.Context, outpoint client.Outpoint,
755755
return nil, err
756756
}
757757

758-
graph := make(map[string]*client.Transactions)
759-
for txid, txs := range resp.GetGraph() {
760-
graph[txid] = &client.Transactions{
761-
Txs: txs.GetTxs(),
758+
graph := make(map[string]*client.ChainWithExpiry)
759+
for txid, chain := range resp.GetGraph() {
760+
graph[txid] = &client.ChainWithExpiry{
761+
Txs: txChain{chain.GetTxs()}.parse(),
762+
ExpiresAt: chain.GetExpiresAt(),
762763
}
763764
}
764765

pkg/client-sdk/client/grpc/types.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,3 +203,18 @@ func (c connectorsIndexFromProto) parse() map[string]client.Outpoint {
203203
}
204204
return connectorsIndex
205205
}
206+
207+
type txChain struct {
208+
chain []*arkv1.IndexerChain
209+
}
210+
211+
func (c txChain) parse() []client.ChainTx {
212+
txs := make([]client.ChainTx, 0, len(c.chain))
213+
for _, tx := range c.chain {
214+
txs = append(txs, client.ChainTx{
215+
Txid: tx.GetTxid(),
216+
Type: tx.GetType().String(),
217+
})
218+
}
219+
return txs
220+
}

pkg/client-sdk/client/rest/client.go

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1241,10 +1241,26 @@ func (a *restClient) GetVtxoChain(ctx context.Context, outpoint client.Outpoint,
12411241
return nil, err
12421242
}
12431243

1244-
graph := make(map[string]*client.Transactions)
1244+
graph := make(map[string]*client.ChainWithExpiry)
12451245
for k, v := range resp.Payload.Graph {
1246-
graph[k] = &client.Transactions{
1247-
Txs: v.Txs,
1246+
txs := make([]client.ChainTx, 0, len(v.Txs))
1247+
for _, tx := range v.Txs {
1248+
txType := "virtual"
1249+
if *tx.Type == models.V1IndexerChainedTxTypeINDEXERCHAINEDTXTYPECOMMITMENT {
1250+
txType = "commitment"
1251+
}
1252+
txs = append(txs, client.ChainTx{
1253+
Txid: tx.Txid,
1254+
Type: txType,
1255+
})
1256+
}
1257+
expiresAt, err := strconv.ParseInt(v.ExpiresAt, 10, 64)
1258+
if err != nil {
1259+
return nil, err
1260+
}
1261+
graph[k] = &client.ChainWithExpiry{
1262+
Txs: txs,
1263+
ExpiresAt: expiresAt,
12481264
}
12491265
}
12501266

pkg/client-sdk/client/rest/service/indexerservice/indexer_service/indexer_service_client.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/client-sdk/client/rest/service/indexerservice/indexer_service/indexer_service_get_spendable_vtxos_responses.go

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/client-sdk/client/rest/service/models/v1_indexer_chain.go

Lines changed: 112 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/client-sdk/client/rest/service/models/v1_indexer_chained_tx_type.go

Lines changed: 81 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)