Skip to content

Commit 7d14efc

Browse files
authored
Merge pull request #41 from urnetwork/fix-type-alias
Fix type alias
2 parents cd8f028 + f63fb15 commit 7d14efc

13 files changed

+139
-132
lines changed

Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ build_android:
1414
# *important* gradle does not handle symbolic links consistently
1515
# the build dir swap is non-atomic
1616
# note android/amd64 is needed for chromebook devices
17+
WARPCTL="../warp/warpctl/build/$$(uname | tr '[:upper:]' '[:lower:]')/$$(uname -m)/warpctl"; \
1718
BUILD_DIR=build/android.`date +%s`; \
18-
WARP_VERSION=`warpctl ls version`; \
19+
WARP_VERSION=`$$WARPCTL ls version`; \
1920
mkdir -p "$$BUILD_DIR"; \
2021
gomobile bind \
2122
-target android/arm64,android/arm,android/amd64 -androidapi 24 \
@@ -50,8 +51,9 @@ build_ios:
5051
build_apple:
5152
# *important* Xcode does not handle symbolic links consistently
5253
# the build dir swap is non-atomic
54+
WARPCTL="../warp/warpctl/build/$$(uname | tr '[:upper:]' '[:lower:]')/$$(uname -m)/warpctl"; \
5355
BUILD_DIR=build/apple.`date +%s`; \
54-
WARP_VERSION=`warpctl ls version`; \
56+
WARP_VERSION=`$$WARPCTL ls version`; \
5557
mkdir -p "$$BUILD_DIR"; \
5658
gomobile bind \
5759
-ldflags "-X client.Version=$$WARP_VERSION" \

api.go

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ type NetworkClientInfo struct {
436436
AuthTime *Time `json:"auth_time"`
437437

438438
Resident *NetworkClientResident `json:"resident,omitempty"`
439-
ProvideMode ProvideMode `json:"provide_mode"`
439+
ProvideMode /*ProvideMode*/int `json:"provide_mode"`
440440
Connections *NetworkClientConnectionList `json:"connections"`
441441
}
442442

@@ -487,7 +487,7 @@ type FindLocationsResult struct {
487487

488488
type LocationResult struct {
489489
LocationId *Id `json:"location_id"`
490-
LocationType LocationType `json:"location_type"`
490+
LocationType /*LocationType*/string `json:"location_type"`
491491
Name string `json:"name"`
492492
// FIXME
493493
City string `json:"city,omitempty"`
@@ -694,23 +694,21 @@ func (self *Api) WalletValidateAddress(walletValidateAddress *WalletValidateAddr
694694
})
695695
}
696696

697-
type WalletType = string
698-
697+
// type WalletType = string
699698
const (
700-
WalletTypeCircleUserControlled WalletType = "circle_uc"
701-
WalletTypeXch WalletType = "xch"
702-
WalletTypeSol WalletType = "sol"
699+
WalletTypeCircleUserControlled /*WalletType*/string = "circle_uc"
700+
WalletTypeXch /*WalletType*/string = "xch"
701+
WalletTypeSol /*WalletType*/string = "sol"
703702
)
704703

705-
type Blockchain = string
706-
704+
// type Blockchain = string
707705
const (
708-
SOL Blockchain = "SOL"
709-
MATIC Blockchain = "MATIC"
706+
SOL /*Blockchain*/string = "SOL"
707+
MATIC /*Blockchain*/string = "MATIC"
710708
)
711709

712710
type CreateAccountWalletArgs struct {
713-
Blockchain Blockchain `json:"blockchain"`
711+
Blockchain /*Blockchain*/string `json:"blockchain"`
714712
WalletAddress string `json:"wallet_address"`
715713
DefaultTokenType string `json:"default_token_type"`
716714
}
@@ -811,7 +809,7 @@ type CircleWalletInfo struct {
811809
Blockchain string `json:"blockchain"`
812810
BlockchainSymbol string `json:"blockchain_symbol"`
813811
CreateDate string `json:"create_date"`
814-
BalanceUsdcNanoCents NanoCents `json:"balance_usdc_nano_cents"`
812+
BalanceUsdcNanoCents /*NanoCents*/int64 `json:"balance_usdc_nano_cents"`
815813
}
816814

817815
type WalletBalanceCallback connect.ApiCallback[*WalletBalanceResult]
@@ -861,7 +859,7 @@ type WalletCircleTransferOutCallback connect.ApiCallback[*WalletCircleTransferOu
861859

862860
type WalletCircleTransferOutArgs struct {
863861
ToAddress string `json:"to_address"`
864-
AmountUsdcNanoCents NanoCents `json:"amount_usdc_nano_cents"`
862+
AmountUsdcNanoCents /*NanoCents*/int64 `json:"amount_usdc_nano_cents"`
865863
Terms bool `json:"terms"`
866864
}
867865

@@ -900,19 +898,19 @@ type TransferBalance struct {
900898
NetworkId *Id `json:"network_id"`
901899
StartTime string `json:"start_time"`
902900
EndTime string `json:"end_time"`
903-
StartBalanceByteCount ByteCount `json:"start_balance_byte_count"`
901+
StartBalanceByteCount /*ByteCount*/int64 `json:"start_balance_byte_count"`
904902
// how much money the platform made after subtracting fees
905-
NetRevenue NanoCents `json:"net_revenue"`
906-
BalanceByteCount ByteCount `json:"balance_byte_count"`
903+
NetRevenue /*NanoCents*/int64 `json:"net_revenue"`
904+
BalanceByteCount /*ByteCount*/int64 `json:"balance_byte_count"`
907905
}
908906

909907
type SubscriptionBalanceCallback connect.ApiCallback[*SubscriptionBalanceResult]
910908

911909
type SubscriptionBalanceResult struct {
912-
BalanceByteCount ByteCount `json:"balance_byte_count"`
910+
BalanceByteCount /*ByteCount*/int64 `json:"balance_byte_count"`
913911
CurrentSubscription *Subscription `json:"current_subscription,omitempty"`
914912
ActiveTransferBalances *TransferBalanceList `json:"active_transfer_balances,omitempty"`
915-
PendingPayoutUsdNanoCents NanoCents `json:"pending_payout_usd_nano_cents"`
913+
PendingPayoutUsdNanoCents /*NanoCents*/int64 `json:"pending_payout_usd_nano_cents"`
916914
WalletInfo *CircleWalletInfo `json:"wallet_info,omitempty"`
917915
UpdateTime string `json:"update_time"`
918916
}
@@ -1178,8 +1176,8 @@ func (self *Api) AccountPreferencesGet(callback AccountPreferencesGetCallback) {
11781176
**/
11791177

11801178
type TransferStatsResult struct {
1181-
PaidBytesProvided ByteCount `json:"paid_bytes_provided"`
1182-
UnpaidBytesProvided ByteCount `json:"unpaid_bytes_provided"`
1179+
PaidBytesProvided /*ByteCount*/int64 `json:"paid_bytes_provided"`
1180+
UnpaidBytesProvided /*ByteCount*/int64 `json:"unpaid_bytes_provided"`
11831181
}
11841182

11851183
type GetTransferStatsCallback connect.ApiCallback[*TransferStatsResult]

connect_view_controller.go

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ import (
1515
"github.com/urnetwork/connect"
1616
)
1717

18-
type ConnectionStatus = string
18+
// type ConnectionStatus = string
1919

2020
const (
21-
Disconnected ConnectionStatus = "DISCONNECTED"
22-
Connecting ConnectionStatus = "CONNECTING"
23-
DestinationSet ConnectionStatus = "DESTINATION_SET"
24-
Connected ConnectionStatus = "CONNECTED"
21+
Disconnected /*ConnectionStatus*/string = "DISCONNECTED"
22+
Connecting /*ConnectionStatus*/string = "CONNECTING"
23+
DestinationSet /*ConnectionStatus*/string = "DESTINATION_SET"
24+
Connected /*ConnectionStatus*/string = "CONNECTED"
2525
)
2626

2727
type SelectedLocationListener interface {
@@ -51,7 +51,7 @@ type ConnectViewController struct {
5151

5252
// this is set when the client is connected
5353
connected bool
54-
connectionStatus ConnectionStatus
54+
connectionStatus /*ConnectionStatus*/string
5555
selectedLocation *ConnectLocation
5656
grid *ConnectGrid
5757
// providerGridPointList *ProviderGridPointList
@@ -120,13 +120,13 @@ func (self *ConnectViewController) GetConnected() bool {
120120
return self.connected
121121
}
122122

123-
func (self *ConnectViewController) GetConnectionStatus() ConnectionStatus {
123+
func (self *ConnectViewController) GetConnectionStatus() /*ConnectionStatus*/string {
124124
self.stateLock.Lock()
125125
defer self.stateLock.Unlock()
126126
return self.connectionStatus
127127
}
128128

129-
func (self *ConnectViewController) setConnectionStatus(status ConnectionStatus) {
129+
func (self *ConnectViewController) setConnectionStatus(status /*ConnectionStatus*/string) {
130130
changed := false
131131
func() {
132132
self.stateLock.Lock()
@@ -323,17 +323,17 @@ func (self *ConnectViewController) GetGrid() *ConnectGrid {
323323
return self.grid
324324
}
325325

326-
type ProviderState = string
326+
// type ProviderState = string
327327

328328
const (
329-
ProviderStateInEvaluation ProviderState = "InEvaluation"
330-
ProviderStateEvaluationFailed ProviderState = "EvaluationFailed"
331-
ProviderStateNotAdded ProviderState = "NotAdded"
332-
ProviderStateAdded ProviderState = "Added"
333-
ProviderStateRemoved ProviderState = "Removed"
329+
ProviderStateInEvaluation /*ProviderState*/string = "InEvaluation"
330+
ProviderStateEvaluationFailed /*ProviderState*/string = "EvaluationFailed"
331+
ProviderStateNotAdded /*ProviderState*/string = "NotAdded"
332+
ProviderStateAdded /*ProviderState*/string = "Added"
333+
ProviderStateRemoved /*ProviderState*/string = "Removed"
334334
)
335335

336-
func parseProviderState(state connect.ProviderState) (ProviderState, error) {
336+
func parseProviderState(state connect.ProviderState) (/*ProviderState*/string, error) {
337337
switch state {
338338
case connect.ProviderStateInEvaluation:
339339
return ProviderStateInEvaluation, nil
@@ -350,7 +350,7 @@ func parseProviderState(state connect.ProviderState) (ProviderState, error) {
350350
}
351351
}
352352

353-
func providerStateIsTerminal(state ProviderState) bool {
353+
func providerStateIsTerminal(state /*ProviderState*/string) bool {
354354
switch state {
355355
case ProviderStateEvaluationFailed, ProviderStateNotAdded, ProviderStateRemoved:
356356
return true
@@ -359,7 +359,7 @@ func providerStateIsTerminal(state ProviderState) bool {
359359
}
360360
}
361361

362-
func providerStateIsActive(state ProviderState) bool {
362+
func providerStateIsActive(state /*ProviderState*/string) bool {
363363
switch state {
364364
case ProviderStateAdded:
365365
return true
@@ -374,7 +374,7 @@ type ProviderGridPoint struct {
374374
Y int32
375375
ClientId *Id
376376
// EventTime *Time
377-
State ProviderState
377+
State /*ProviderState*/string
378378
// the time when this point will be removed
379379
// the ui can transition out based on this value
380380
EndTime *Time
@@ -682,7 +682,7 @@ func (self *ConnectGrid) windowMonitorEventCallback(windowExpandEvent *connect.W
682682
done := false
683683
windowSizeChanged := false
684684
providerGridPointChanged := false
685-
var connectionStatus ConnectionStatus
685+
var connectionStatus /*ConnectionStatus*/string
686686
func() {
687687
self.stateLock.Lock()
688688
defer self.stateLock.Unlock()

device.go

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,17 @@ type ProvideSecretKeysListener interface {
5555
}
5656

5757

58-
type IpProtocol = int
59-
const IpProtocolUnkown = 0
60-
const IpProtocolUdp = 1
61-
const IpProtocolTcp = 2
58+
// type IpProtocol = int
59+
const (
60+
IpProtocolUnkown /*IpProtocol*/int = 0
61+
IpProtocolUdp /*IpProtocol*/int = 1
62+
IpProtocolTcp /*IpProtocol*/int = 2
63+
)
64+
6265

6366
// receive a packet into the local raw socket
6467
type ReceivePacket interface {
65-
ReceivePacket(ipVersion int, ipProtocol IpProtocol, packet []byte)
68+
ReceivePacket(ipVersion int, ipProtocol /*IpProtocol*/int, packet []byte)
6669
}
6770

6871
type TunnelChangeListener interface {
@@ -119,9 +122,9 @@ type Device interface {
119122

120123
GetConnectEnabled() bool
121124

122-
SetProvideMode(provideMode ProvideMode)
125+
SetProvideMode(provideMode /*ProvideMode*/int)
123126

124-
GetProvideMode() ProvideMode
127+
GetProvideMode() /*ProvideMode*/int
125128

126129
SetProvidePaused(providePaused bool)
127130

@@ -137,7 +140,7 @@ type Device interface {
137140

138141
RemoveDestination()
139142

140-
SetDestination(location *ConnectLocation, specs *ProviderSpecList, provideMode ProvideMode)
143+
SetDestination(location *ConnectLocation, specs *ProviderSpecList, provideMode /*ProvideMode*/int)
141144

142145
SetConnectLocation(location *ConnectLocation)
143146

@@ -920,7 +923,7 @@ func (self *DeviceLocal) GetProvideSecretKeys() *ProvideSecretKeyList {
920923
provideSecretKeyList := NewProvideSecretKeyList()
921924
for provideMode, provideSecretKey := range provideSecretKeys {
922925
provideSecretKey := &ProvideSecretKey{
923-
ProvideMode: ProvideMode(provideMode),
926+
ProvideMode: /*ProvideMode*/int(provideMode),
924927
ProvideSecretKey: string(provideSecretKey),
925928
}
926929
provideSecretKeyList.Add(provideSecretKey)
@@ -960,7 +963,7 @@ func (self *DeviceLocal) GetConnectEnabled() bool {
960963
return self.remoteUserNatClient != nil
961964
}
962965

963-
func (self *DeviceLocal) SetProvideMode(provideMode ProvideMode) {
966+
func (self *DeviceLocal) SetProvideMode(provideMode /*ProvideMode*/int) {
964967
func() {
965968
self.stateLock.Lock()
966969
defer self.stateLock.Unlock()
@@ -997,12 +1000,12 @@ func (self *DeviceLocal) SetProvideMode(provideMode ProvideMode) {
9971000
self.provideChanged(self.GetProvideEnabled())
9981001
}
9991002

1000-
func (self *DeviceLocal) GetProvideMode() ProvideMode {
1003+
func (self *DeviceLocal) GetProvideMode() /*ProvideMode*/int {
10011004
maxProvideMode := protocol.ProvideMode_None
10021005
for provideMode, _ := range self.client.ContractManager().GetProvideModes() {
10031006
maxProvideMode = max(maxProvideMode, provideMode)
10041007
}
1005-
return ProvideMode(maxProvideMode)
1008+
return /*ProvideMode*/int(maxProvideMode)
10061009
}
10071010

10081011
func (self *DeviceLocal) SetProvidePaused(providePaused bool) {
@@ -1053,7 +1056,7 @@ func (self *DeviceLocal) RemoveDestination() {
10531056
self.SetDestination(nil, nil, ProvideModeNone)
10541057
}
10551058

1056-
func (self *DeviceLocal) SetDestination(location *ConnectLocation, specs *ProviderSpecList, provideMode ProvideMode) {
1059+
func (self *DeviceLocal) SetDestination(location *ConnectLocation, specs *ProviderSpecList, provideMode /*ProvideMode*/int) {
10571060
func() {
10581061
self.stateLock.Lock()
10591062
defer self.stateLock.Unlock()
@@ -1088,7 +1091,7 @@ func (self *DeviceLocal) SetDestination(location *ConnectLocation, specs *Provid
10881091
connect.DefaultApiMultiClientGeneratorSettings(),
10891092
)
10901093
remoteReceive := func(source connect.TransferPath, provideMode protocol.ProvideMode, ipPath *connect.IpPath, packet []byte) {
1091-
self.stats.UpdateRemoteReceive(ByteCount(len(packet)))
1094+
self.stats.UpdateRemoteReceive(/*ByteCount*/int64(len(packet)))
10921095
self.receive(source, provideMode, ipPath, packet)
10931096
}
10941097
multi := connect.NewRemoteUserNatMultiClientWithDefaults(
@@ -1160,7 +1163,7 @@ func (self *DeviceLocal) SendPacket(packet []byte, n int32) bool {
11601163
}()
11611164

11621165
if remoteUserNatClient != nil {
1163-
self.stats.UpdateRemoteSend(ByteCount(n))
1166+
self.stats.UpdateRemoteSend(/*ByteCount*/int64(n))
11641167
return remoteUserNatClient.SendPacket(
11651168
source,
11661169
protocol.ProvideMode_Network,
@@ -1182,7 +1185,7 @@ func (self *DeviceLocal) SendPacket(packet []byte, n int32) bool {
11821185

11831186
func (self *DeviceLocal) AddReceivePacket(receivePacket ReceivePacket) Sub {
11841187
receive := func(source connect.TransferPath, provideMode protocol.ProvideMode, ipPath *connect.IpPath, packet []byte) {
1185-
var ipProtocol IpProtocol
1188+
var ipProtocol /*IpProtocol*/int
11861189
switch ipPath.Protocol {
11871190
case connect.IpProtocolUdp:
11881191
ipProtocol = IpProtocolUdp

0 commit comments

Comments
 (0)