Skip to content

Commit

Permalink
[SDK] Add RoundInterval to StoreData (#283)
Browse files Browse the repository at this point in the history
Co-authored-by: altafan <[email protected]>
  • Loading branch information
bordalix and altafan committed Sep 16, 2024
1 parent 3782793 commit 0fe5238
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pkg/client-sdk/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ func (a *arkClient) InitWithWallet(
ClientType: args.ClientType,
Network: network,
RoundLifetime: info.RoundLifetime,
RoundInterval: info.RoundInterval,
UnilateralExitDelay: info.UnilateralExitDelay,
Dust: info.Dust,
BoardingDescriptorTemplate: info.BoardingDescriptorTemplate,
Expand Down Expand Up @@ -174,6 +175,7 @@ func (a *arkClient) Init(
ClientType: args.ClientType,
Network: network,
RoundLifetime: info.RoundLifetime,
RoundInterval: info.RoundInterval,
UnilateralExitDelay: info.UnilateralExitDelay,
Dust: info.Dust,
BoardingDescriptorTemplate: info.BoardingDescriptorTemplate,
Expand Down
5 changes: 5 additions & 0 deletions pkg/client-sdk/store/file/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type storeData struct {
ClientType string `json:"client_type"`
Network string `json:"network"`
RoundLifetime string `json:"round_lifetime"`
RoundInterval string `json:"round_interval"`
UnilateralExitDelay string `json:"unilateral_exit_delay"`
Dust string `json:"dust"`
BoardingDescriptorTemplate string `json:"boarding_descriptor_template"`
Expand All @@ -40,6 +41,7 @@ func (d storeData) isEmpty() bool {
func (d storeData) decode() store.StoreData {
network := utils.NetworkFromString(d.Network)
roundLifetime, _ := strconv.Atoi(d.RoundLifetime)
roundInterval, _ := strconv.Atoi(d.RoundInterval)
unilateralExitDelay, _ := strconv.Atoi(d.UnilateralExitDelay)
dust, _ := strconv.Atoi(d.Dust)
buf, _ := hex.DecodeString(d.AspPubkey)
Expand All @@ -53,6 +55,7 @@ func (d storeData) decode() store.StoreData {
Network: network,
RoundLifetime: int64(roundLifetime),
UnilateralExitDelay: int64(unilateralExitDelay),
RoundInterval: int64(roundInterval),
Dust: uint64(dust),
BoardingDescriptorTemplate: d.BoardingDescriptorTemplate,
ExplorerURL: explorerURL,
Expand All @@ -67,6 +70,7 @@ func (d storeData) asMap() map[string]string {
"client_type": d.ClientType,
"network": d.Network,
"round_lifetime": d.RoundLifetime,
"round_interval": d.RoundInterval,
"unilateral_exit_delay": d.UnilateralExitDelay,
"dust": d.Dust,
"boarding_descriptor_template": d.BoardingDescriptorTemplate,
Expand Down Expand Up @@ -113,6 +117,7 @@ func (s *Store) AddData(ctx context.Context, data store.StoreData) error {
ClientType: data.ClientType,
Network: data.Network.Name,
RoundLifetime: fmt.Sprintf("%d", data.RoundLifetime),
RoundInterval: fmt.Sprintf("%d", data.RoundInterval),
UnilateralExitDelay: fmt.Sprintf("%d", data.UnilateralExitDelay),
Dust: fmt.Sprintf("%d", data.Dust),
BoardingDescriptorTemplate: data.BoardingDescriptorTemplate,
Expand Down
1 change: 1 addition & 0 deletions pkg/client-sdk/store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type StoreData struct {
ClientType string
Network common.Network
RoundLifetime int64
RoundInterval int64
UnilateralExitDelay int64
Dust uint64
BoardingDescriptorTemplate string
Expand Down
1 change: 1 addition & 0 deletions pkg/client-sdk/store/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ func TestStore(t *testing.T) {
ClientType: client.GrpcClient,
Network: common.LiquidRegTest,
RoundLifetime: 512,
RoundInterval: 10,
UnilateralExitDelay: 512,
Dust: 1000,
BoardingDescriptorTemplate: "tr(0250929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0,{ and(pk(873079a0091c9b16abd1f8c508320b07f0d50144d09ccd792ce9c915dac60465), pk(USER)), and(older(604672), pk(USER)) })",
Expand Down
1 change: 1 addition & 0 deletions pkg/client-sdk/wallet/wallet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ func TestWallet(t *testing.T) {
ClientType: client.GrpcClient,
Network: common.LiquidRegTest,
RoundLifetime: 512,
RoundInterval: 10,
UnilateralExitDelay: 512,
Dust: 1000,
BoardingDescriptorTemplate: "tr(0250929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0,{ and(pk(873079a0091c9b16abd1f8c508320b07f0d50144d09ccd792ce9c915dac60465), pk(USER)), and(older(604672), pk(USER)) })",
Expand Down
4 changes: 4 additions & 0 deletions pkg/client-sdk/wasm/browser/config_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type storeData struct {
ExplorerURL string `json:"explorer_url"`
Network string `json:"network"`
RoundLifetime string `json:"round_lifetime"`
RoundInterval string `json:"round_interval"`
UnilateralExitDelay string `json:"unilateral_exit_delay"`
Dust string `json:"dust"`
}
Expand Down Expand Up @@ -57,6 +58,7 @@ func (s *localStorageStore) AddData(ctx context.Context, data store.StoreData) e
ClientType: data.ClientType,
Network: data.Network.Name,
RoundLifetime: fmt.Sprintf("%d", data.RoundLifetime),
RoundInterval: fmt.Sprintf("%d", data.RoundInterval),
UnilateralExitDelay: fmt.Sprintf("%d", data.UnilateralExitDelay),
Dust: fmt.Sprintf("%d", data.Dust),
}
Expand All @@ -82,6 +84,7 @@ func (s *localStorageStore) GetData(ctx context.Context) (*store.StoreData, erro
}
network := utils.NetworkFromString(s.store.Call("getItem", "network").String())
roundLifetime, _ := strconv.Atoi(s.store.Call("getItem", "round_lifetime").String())
roundInterval, _ := strconv.Atoi(s.store.Call("getItem", "round_interval").String())
unilateralExitDelay, _ := strconv.Atoi(s.store.Call("getItem", "unilateral_exit_delay").String())
dust, _ := strconv.Atoi(s.store.Call("getItem", "min_relay_fee").String())

Expand All @@ -92,6 +95,7 @@ func (s *localStorageStore) GetData(ctx context.Context) (*store.StoreData, erro
ClientType: s.store.Call("getItem", "client_type").String(),
Network: network,
RoundLifetime: int64(roundLifetime),
RoundInterval: int64(roundInterval),
UnilateralExitDelay: int64(unilateralExitDelay),
Dust: uint64(dust),
}, nil
Expand Down

0 comments on commit 0fe5238

Please sign in to comment.