diff --git a/Makefile b/Makefile index c5b0a24..e27800f 100644 --- a/Makefile +++ b/Makefile @@ -14,8 +14,9 @@ build_android: # *important* gradle does not handle symbolic links consistently # the build dir swap is non-atomic # note android/amd64 is needed for chromebook devices + WARPCTL="../warp/warpctl/build/$$(uname | tr '[:upper:]' '[:lower:]')/$$(uname -m)/warpctl"; \ BUILD_DIR=build/android.`date +%s`; \ - WARP_VERSION=`warpctl ls version`; \ + WARP_VERSION=`$$WARPCTL ls version`; \ mkdir -p "$$BUILD_DIR"; \ gomobile bind \ -target android/arm64,android/arm,android/amd64 -androidapi 24 \ @@ -50,8 +51,9 @@ build_ios: build_apple: # *important* Xcode does not handle symbolic links consistently # the build dir swap is non-atomic + WARPCTL="../warp/warpctl/build/$$(uname | tr '[:upper:]' '[:lower:]')/$$(uname -m)/warpctl"; \ BUILD_DIR=build/apple.`date +%s`; \ - WARP_VERSION=`warpctl ls version`; \ + WARP_VERSION=`$$WARPCTL ls version`; \ mkdir -p "$$BUILD_DIR"; \ gomobile bind \ -ldflags "-X client.Version=$$WARP_VERSION" \ diff --git a/api.go b/api.go index 4586f75..6dd7149 100644 --- a/api.go +++ b/api.go @@ -436,7 +436,7 @@ type NetworkClientInfo struct { AuthTime *Time `json:"auth_time"` Resident *NetworkClientResident `json:"resident,omitempty"` - ProvideMode ProvideMode `json:"provide_mode"` + ProvideMode /*ProvideMode*/int `json:"provide_mode"` Connections *NetworkClientConnectionList `json:"connections"` } @@ -487,7 +487,7 @@ type FindLocationsResult struct { type LocationResult struct { LocationId *Id `json:"location_id"` - LocationType LocationType `json:"location_type"` + LocationType /*LocationType*/string `json:"location_type"` Name string `json:"name"` // FIXME City string `json:"city,omitempty"` @@ -694,23 +694,21 @@ func (self *Api) WalletValidateAddress(walletValidateAddress *WalletValidateAddr }) } -type WalletType = string - +// type WalletType = string const ( - WalletTypeCircleUserControlled WalletType = "circle_uc" - WalletTypeXch WalletType = "xch" - WalletTypeSol WalletType = "sol" + WalletTypeCircleUserControlled /*WalletType*/string = "circle_uc" + WalletTypeXch /*WalletType*/string = "xch" + WalletTypeSol /*WalletType*/string = "sol" ) -type Blockchain = string - +// type Blockchain = string const ( - SOL Blockchain = "SOL" - MATIC Blockchain = "MATIC" + SOL /*Blockchain*/string = "SOL" + MATIC /*Blockchain*/string = "MATIC" ) type CreateAccountWalletArgs struct { - Blockchain Blockchain `json:"blockchain"` + Blockchain /*Blockchain*/string `json:"blockchain"` WalletAddress string `json:"wallet_address"` DefaultTokenType string `json:"default_token_type"` } @@ -811,7 +809,7 @@ type CircleWalletInfo struct { Blockchain string `json:"blockchain"` BlockchainSymbol string `json:"blockchain_symbol"` CreateDate string `json:"create_date"` - BalanceUsdcNanoCents NanoCents `json:"balance_usdc_nano_cents"` + BalanceUsdcNanoCents /*NanoCents*/int64 `json:"balance_usdc_nano_cents"` } type WalletBalanceCallback connect.ApiCallback[*WalletBalanceResult] @@ -861,7 +859,7 @@ type WalletCircleTransferOutCallback connect.ApiCallback[*WalletCircleTransferOu type WalletCircleTransferOutArgs struct { ToAddress string `json:"to_address"` - AmountUsdcNanoCents NanoCents `json:"amount_usdc_nano_cents"` + AmountUsdcNanoCents /*NanoCents*/int64 `json:"amount_usdc_nano_cents"` Terms bool `json:"terms"` } @@ -900,19 +898,19 @@ type TransferBalance struct { NetworkId *Id `json:"network_id"` StartTime string `json:"start_time"` EndTime string `json:"end_time"` - StartBalanceByteCount ByteCount `json:"start_balance_byte_count"` + StartBalanceByteCount /*ByteCount*/int64 `json:"start_balance_byte_count"` // how much money the platform made after subtracting fees - NetRevenue NanoCents `json:"net_revenue"` - BalanceByteCount ByteCount `json:"balance_byte_count"` + NetRevenue /*NanoCents*/int64 `json:"net_revenue"` + BalanceByteCount /*ByteCount*/int64 `json:"balance_byte_count"` } type SubscriptionBalanceCallback connect.ApiCallback[*SubscriptionBalanceResult] type SubscriptionBalanceResult struct { - BalanceByteCount ByteCount `json:"balance_byte_count"` + BalanceByteCount /*ByteCount*/int64 `json:"balance_byte_count"` CurrentSubscription *Subscription `json:"current_subscription,omitempty"` ActiveTransferBalances *TransferBalanceList `json:"active_transfer_balances,omitempty"` - PendingPayoutUsdNanoCents NanoCents `json:"pending_payout_usd_nano_cents"` + PendingPayoutUsdNanoCents /*NanoCents*/int64 `json:"pending_payout_usd_nano_cents"` WalletInfo *CircleWalletInfo `json:"wallet_info,omitempty"` UpdateTime string `json:"update_time"` } @@ -1178,8 +1176,8 @@ func (self *Api) AccountPreferencesGet(callback AccountPreferencesGetCallback) { **/ type TransferStatsResult struct { - PaidBytesProvided ByteCount `json:"paid_bytes_provided"` - UnpaidBytesProvided ByteCount `json:"unpaid_bytes_provided"` + PaidBytesProvided /*ByteCount*/int64 `json:"paid_bytes_provided"` + UnpaidBytesProvided /*ByteCount*/int64 `json:"unpaid_bytes_provided"` } type GetTransferStatsCallback connect.ApiCallback[*TransferStatsResult] diff --git a/connect_view_controller.go b/connect_view_controller.go index 7cb67fb..fa6b207 100644 --- a/connect_view_controller.go +++ b/connect_view_controller.go @@ -15,13 +15,13 @@ import ( "github.com/urnetwork/connect" ) -type ConnectionStatus = string +// type ConnectionStatus = string const ( - Disconnected ConnectionStatus = "DISCONNECTED" - Connecting ConnectionStatus = "CONNECTING" - DestinationSet ConnectionStatus = "DESTINATION_SET" - Connected ConnectionStatus = "CONNECTED" + Disconnected /*ConnectionStatus*/string = "DISCONNECTED" + Connecting /*ConnectionStatus*/string = "CONNECTING" + DestinationSet /*ConnectionStatus*/string = "DESTINATION_SET" + Connected /*ConnectionStatus*/string = "CONNECTED" ) type SelectedLocationListener interface { @@ -51,7 +51,7 @@ type ConnectViewController struct { // this is set when the client is connected connected bool - connectionStatus ConnectionStatus + connectionStatus /*ConnectionStatus*/string selectedLocation *ConnectLocation grid *ConnectGrid // providerGridPointList *ProviderGridPointList @@ -120,13 +120,13 @@ func (self *ConnectViewController) GetConnected() bool { return self.connected } -func (self *ConnectViewController) GetConnectionStatus() ConnectionStatus { +func (self *ConnectViewController) GetConnectionStatus() /*ConnectionStatus*/string { self.stateLock.Lock() defer self.stateLock.Unlock() return self.connectionStatus } -func (self *ConnectViewController) setConnectionStatus(status ConnectionStatus) { +func (self *ConnectViewController) setConnectionStatus(status /*ConnectionStatus*/string) { changed := false func() { self.stateLock.Lock() @@ -323,17 +323,17 @@ func (self *ConnectViewController) GetGrid() *ConnectGrid { return self.grid } -type ProviderState = string +// type ProviderState = string const ( - ProviderStateInEvaluation ProviderState = "InEvaluation" - ProviderStateEvaluationFailed ProviderState = "EvaluationFailed" - ProviderStateNotAdded ProviderState = "NotAdded" - ProviderStateAdded ProviderState = "Added" - ProviderStateRemoved ProviderState = "Removed" + ProviderStateInEvaluation /*ProviderState*/string = "InEvaluation" + ProviderStateEvaluationFailed /*ProviderState*/string = "EvaluationFailed" + ProviderStateNotAdded /*ProviderState*/string = "NotAdded" + ProviderStateAdded /*ProviderState*/string = "Added" + ProviderStateRemoved /*ProviderState*/string = "Removed" ) -func parseProviderState(state connect.ProviderState) (ProviderState, error) { +func parseProviderState(state connect.ProviderState) (/*ProviderState*/string, error) { switch state { case connect.ProviderStateInEvaluation: return ProviderStateInEvaluation, nil @@ -350,7 +350,7 @@ func parseProviderState(state connect.ProviderState) (ProviderState, error) { } } -func providerStateIsTerminal(state ProviderState) bool { +func providerStateIsTerminal(state /*ProviderState*/string) bool { switch state { case ProviderStateEvaluationFailed, ProviderStateNotAdded, ProviderStateRemoved: return true @@ -359,7 +359,7 @@ func providerStateIsTerminal(state ProviderState) bool { } } -func providerStateIsActive(state ProviderState) bool { +func providerStateIsActive(state /*ProviderState*/string) bool { switch state { case ProviderStateAdded: return true @@ -374,7 +374,7 @@ type ProviderGridPoint struct { Y int32 ClientId *Id // EventTime *Time - State ProviderState + State /*ProviderState*/string // the time when this point will be removed // the ui can transition out based on this value EndTime *Time @@ -682,7 +682,7 @@ func (self *ConnectGrid) windowMonitorEventCallback(windowExpandEvent *connect.W done := false windowSizeChanged := false providerGridPointChanged := false - var connectionStatus ConnectionStatus + var connectionStatus /*ConnectionStatus*/string func() { self.stateLock.Lock() defer self.stateLock.Unlock() diff --git a/device.go b/device.go index 9e9e03b..52304f0 100644 --- a/device.go +++ b/device.go @@ -55,14 +55,17 @@ type ProvideSecretKeysListener interface { } -type IpProtocol = int -const IpProtocolUnkown = 0 -const IpProtocolUdp = 1 -const IpProtocolTcp = 2 +// type IpProtocol = int +const ( + IpProtocolUnkown /*IpProtocol*/int = 0 + IpProtocolUdp /*IpProtocol*/int = 1 + IpProtocolTcp /*IpProtocol*/int = 2 +) + // receive a packet into the local raw socket type ReceivePacket interface { - ReceivePacket(ipVersion int, ipProtocol IpProtocol, packet []byte) + ReceivePacket(ipVersion int, ipProtocol /*IpProtocol*/int, packet []byte) } type TunnelChangeListener interface { @@ -119,9 +122,9 @@ type Device interface { GetConnectEnabled() bool - SetProvideMode(provideMode ProvideMode) + SetProvideMode(provideMode /*ProvideMode*/int) - GetProvideMode() ProvideMode + GetProvideMode() /*ProvideMode*/int SetProvidePaused(providePaused bool) @@ -137,7 +140,7 @@ type Device interface { RemoveDestination() - SetDestination(location *ConnectLocation, specs *ProviderSpecList, provideMode ProvideMode) + SetDestination(location *ConnectLocation, specs *ProviderSpecList, provideMode /*ProvideMode*/int) SetConnectLocation(location *ConnectLocation) @@ -920,7 +923,7 @@ func (self *DeviceLocal) GetProvideSecretKeys() *ProvideSecretKeyList { provideSecretKeyList := NewProvideSecretKeyList() for provideMode, provideSecretKey := range provideSecretKeys { provideSecretKey := &ProvideSecretKey{ - ProvideMode: ProvideMode(provideMode), + ProvideMode: /*ProvideMode*/int(provideMode), ProvideSecretKey: string(provideSecretKey), } provideSecretKeyList.Add(provideSecretKey) @@ -960,7 +963,7 @@ func (self *DeviceLocal) GetConnectEnabled() bool { return self.remoteUserNatClient != nil } -func (self *DeviceLocal) SetProvideMode(provideMode ProvideMode) { +func (self *DeviceLocal) SetProvideMode(provideMode /*ProvideMode*/int) { func() { self.stateLock.Lock() defer self.stateLock.Unlock() @@ -997,12 +1000,12 @@ func (self *DeviceLocal) SetProvideMode(provideMode ProvideMode) { self.provideChanged(self.GetProvideEnabled()) } -func (self *DeviceLocal) GetProvideMode() ProvideMode { +func (self *DeviceLocal) GetProvideMode() /*ProvideMode*/int { maxProvideMode := protocol.ProvideMode_None for provideMode, _ := range self.client.ContractManager().GetProvideModes() { maxProvideMode = max(maxProvideMode, provideMode) } - return ProvideMode(maxProvideMode) + return /*ProvideMode*/int(maxProvideMode) } func (self *DeviceLocal) SetProvidePaused(providePaused bool) { @@ -1053,7 +1056,7 @@ func (self *DeviceLocal) RemoveDestination() { self.SetDestination(nil, nil, ProvideModeNone) } -func (self *DeviceLocal) SetDestination(location *ConnectLocation, specs *ProviderSpecList, provideMode ProvideMode) { +func (self *DeviceLocal) SetDestination(location *ConnectLocation, specs *ProviderSpecList, provideMode /*ProvideMode*/int) { func() { self.stateLock.Lock() defer self.stateLock.Unlock() @@ -1088,7 +1091,7 @@ func (self *DeviceLocal) SetDestination(location *ConnectLocation, specs *Provid connect.DefaultApiMultiClientGeneratorSettings(), ) remoteReceive := func(source connect.TransferPath, provideMode protocol.ProvideMode, ipPath *connect.IpPath, packet []byte) { - self.stats.UpdateRemoteReceive(ByteCount(len(packet))) + self.stats.UpdateRemoteReceive(/*ByteCount*/int64(len(packet))) self.receive(source, provideMode, ipPath, packet) } multi := connect.NewRemoteUserNatMultiClientWithDefaults( @@ -1160,7 +1163,7 @@ func (self *DeviceLocal) SendPacket(packet []byte, n int32) bool { }() if remoteUserNatClient != nil { - self.stats.UpdateRemoteSend(ByteCount(n)) + self.stats.UpdateRemoteSend(/*ByteCount*/int64(n)) return remoteUserNatClient.SendPacket( source, protocol.ProvideMode_Network, @@ -1182,7 +1185,7 @@ func (self *DeviceLocal) SendPacket(packet []byte, n int32) bool { func (self *DeviceLocal) AddReceivePacket(receivePacket ReceivePacket) Sub { receive := func(source connect.TransferPath, provideMode protocol.ProvideMode, ipPath *connect.IpPath, packet []byte) { - var ipProtocol IpProtocol + var ipProtocol /*IpProtocol*/int switch ipPath.Protocol { case connect.IpProtocolUdp: ipProtocol = IpProtocolUdp diff --git a/device_rpc.go b/device_rpc.go index a04e896..17a878f 100644 --- a/device_rpc.go +++ b/device_rpc.go @@ -1108,7 +1108,7 @@ func (self *DeviceRemote) GetConnectEnabled() bool { } } -func (self *DeviceRemote) SetProvideMode(provideMode ProvideMode) { +func (self *DeviceRemote) SetProvideMode(provideMode /*ProvideMode*/int) { self.stateLock.Lock() defer self.stateLock.Unlock() @@ -1130,19 +1130,19 @@ func (self *DeviceRemote) SetProvideMode(provideMode ProvideMode) { state.ProvideMode.Set(provideMode) } -func (self *DeviceRemote) GetProvideMode() ProvideMode { +func (self *DeviceRemote) GetProvideMode() /*ProvideMode*/int { self.stateLock.Lock() defer self.stateLock.Unlock() - provideMode, success := func()(ProvideMode, bool) { + provideMode, success := func()(/*ProvideMode*/int, bool) { if self.service == nil { - var empty ProvideMode + var empty /*ProvideMode*/int return empty, false } - provideMode, err := rpcCallNoArg[ProvideMode](self.service, "DeviceLocalRpc.GetProvideMode", self.closeService) + provideMode, err := rpcCallNoArg[/*ProvideMode*/int](self.service, "DeviceLocalRpc.GetProvideMode", self.closeService) if err != nil { - var empty ProvideMode + var empty /*ProvideMode*/int return empty, false } self.lastKnownState.ProvideMode.Set(provideMode) @@ -1355,7 +1355,7 @@ func (self *DeviceRemote) RemoveDestination() { } } -func (self *DeviceRemote) SetDestination(location *ConnectLocation, specs *ProviderSpecList, provideMode ProvideMode) { +func (self *DeviceRemote) SetDestination(location *ConnectLocation, specs *ProviderSpecList, provideMode /*ProvideMode*/int) { event := false func() { self.stateLock.Lock() @@ -2151,7 +2151,7 @@ func (self *DeviceRemote) remoteChanged(remoteConnected bool) { type DeviceRemoteDestination struct { Location *DeviceRemoteConnectLocation Specs []*ProviderSpec - ProvideMode ProvideMode + ProvideMode /*ProvideMode*/int } //gomobile:noexport @@ -2245,7 +2245,7 @@ type DeviceRemoteState struct { RouteLocal deviceRemoteValue[bool] InitProvideSecretKeys deviceRemoteValue[bool] LoadProvideSecretKeys deviceRemoteValue[[]*ProvideSecretKey] - ProvideMode deviceRemoteValue[ProvideMode] + ProvideMode deviceRemoteValue[/*ProvideMode*/int] ProvidePaused deviceRemoteValue[bool] Offline deviceRemoteValue[bool] VpnInterfaceWhileOffline deviceRemoteValue[bool] @@ -2436,7 +2436,7 @@ type DeviceRemoteConnectLocationValue struct { Promoted bool MatchDistance int32 - LocationType LocationType + LocationType /*LocationType*/string City string Region string @@ -3836,12 +3836,12 @@ func (self *DeviceLocalRpc) GetConnectEnabled(_ RpcNoArg, connectEnabled *bool) return nil } -func (self *DeviceLocalRpc) SetProvideMode(provideMode ProvideMode, _ RpcVoid) error { +func (self *DeviceLocalRpc) SetProvideMode(provideMode /*ProvideMode*/int, _ RpcVoid) error { self.deviceLocal.SetProvideMode(provideMode) return nil } -func (self *DeviceLocalRpc) GetProvideMode(_ RpcNoArg, provideMode *ProvideMode) error { +func (self *DeviceLocalRpc) GetProvideMode(_ RpcNoArg, provideMode */*ProvideMode*/int) error { *provideMode = self.deviceLocal.GetProvideMode() return nil } diff --git a/device_stats.go b/device_stats.go index 47806f8..11ada54 100644 --- a/device_stats.go +++ b/device_stats.go @@ -12,11 +12,11 @@ type DeviceStats struct { connectCount int netConnectDuration time.Duration maxConnectDuration time.Duration - netRemoteSendByteCount ByteCount - netRemoteReceiveByteCount ByteCount + netRemoteSendByteCount /*ByteCount*/int64 + netRemoteReceiveByteCount /*ByteCount*/int64 successConnectDuration time.Duration - successByteCount ByteCount + successByteCount /*ByteCount*/int64 } func newDeviceStats() *DeviceStats { @@ -26,11 +26,11 @@ func newDeviceStats() *DeviceStats { connectCount: 0, netConnectDuration: time.Duration(0), maxConnectDuration: time.Duration(0), - netRemoteSendByteCount: ByteCount(0), - netRemoteReceiveByteCount: ByteCount(0), + netRemoteSendByteCount: /*ByteCount*/int64(0), + netRemoteReceiveByteCount: /*ByteCount*/int64(0), successConnectDuration: 120 * time.Second, - successByteCount: ByteCount(64 * 1024 * 1024), + successByteCount: /*ByteCount*/int64(64 * 1024 * 1024), } } @@ -55,14 +55,14 @@ func (self *DeviceStats) GetMaxConnectDurationSeconds() int { return int(self.maxConnectDuration / time.Second) } -func (self *DeviceStats) GetNetRemoteSendByteCount() ByteCount { +func (self *DeviceStats) GetNetRemoteSendByteCount() /*ByteCount*/int64 { self.stateLock.Lock() defer self.stateLock.Unlock() return self.netRemoteSendByteCount } -func (self *DeviceStats) GetNetRemoteReceiveByteCount() ByteCount { +func (self *DeviceStats) GetNetRemoteReceiveByteCount() /*ByteCount*/int64 { self.stateLock.Lock() defer self.stateLock.Unlock() @@ -105,14 +105,14 @@ func (self *DeviceStats) UpdateConnect(connectEnabled bool) { } } -func (self *DeviceStats) UpdateRemoteReceive(remoteReceiveByteCount ByteCount) { +func (self *DeviceStats) UpdateRemoteReceive(remoteReceiveByteCount /*ByteCount*/int64) { self.stateLock.Lock() defer self.stateLock.Unlock() self.netRemoteReceiveByteCount += remoteReceiveByteCount } -func (self *DeviceStats) UpdateRemoteSend(remoteSendByteCount ByteCount) { +func (self *DeviceStats) UpdateRemoteSend(remoteSendByteCount /*ByteCount*/int64) { self.stateLock.Lock() defer self.stateLock.Unlock() diff --git a/device_stats_test.go b/device_stats_test.go index 525728e..1b1a659 100644 --- a/device_stats_test.go +++ b/device_stats_test.go @@ -26,8 +26,8 @@ func TestDeviceStats(t *testing.T) { assert.Equal(t, deviceStats.GetConnectCount(), 0) assert.Equal(t, deviceStats.GetNetConnectDurationSeconds(), 0) assert.Equal(t, deviceStats.GetMaxConnectDurationSeconds(), 0) - assert.Equal(t, deviceStats.GetNetRemoteSendByteCount(), ByteCount(0)) - assert.Equal(t, deviceStats.GetNetRemoteReceiveByteCount(), ByteCount(0)) + assert.Equal(t, deviceStats.GetNetRemoteSendByteCount(), /*ByteCount*/int64(0)) + assert.Equal(t, deviceStats.GetNetRemoteReceiveByteCount(), /*ByteCount*/int64(0)) assert.Equal(t, deviceStats.GetUserSuccess(), false) deviceStats.UpdateConnect(true) @@ -40,8 +40,8 @@ func TestDeviceStats(t *testing.T) { assert.Equal(t, deviceStats.GetNetConnectDurationSeconds(), 0) assert.Equal(t, deviceStats.GetMaxConnectDurationSeconds(), 0) - deviceStats.UpdateRemoteSend(ByteCount(1024)) - deviceStats.UpdateRemoteReceive(ByteCount(1024 * 1024)) + deviceStats.UpdateRemoteSend(/*ByteCount*/int64(1024)) + deviceStats.UpdateRemoteReceive(/*ByteCount*/int64(1024 * 1024)) deviceStats.UpdateConnect(true) connectTime2 := time.Now() @@ -49,15 +49,15 @@ func TestDeviceStats(t *testing.T) { assert.Equal(t, deviceStats.GetConnectCount(), 1) assert.Equal(t, deviceStats.GetNetConnectDurationSeconds(), int(connectTime2.Sub(connectTime1)/time.Second)) assert.Equal(t, deviceStats.GetMaxConnectDurationSeconds(), int(connectTime2.Sub(connectTime1)/time.Second)) - assert.Equal(t, deviceStats.GetNetRemoteSendByteCount(), ByteCount(1024)) - assert.Equal(t, deviceStats.GetNetRemoteReceiveByteCount(), ByteCount(1024*1024)) + assert.Equal(t, deviceStats.GetNetRemoteSendByteCount(), /*ByteCount*/int64(1024)) + assert.Equal(t, deviceStats.GetNetRemoteReceiveByteCount(), /*ByteCount*/int64(1024*1024)) select { case <-time.After(2 * time.Second): } - deviceStats.UpdateRemoteSend(ByteCount(2 * 1024)) - deviceStats.UpdateRemoteReceive(ByteCount(2 * 1024 * 1024)) + deviceStats.UpdateRemoteSend(/*ByteCount*/int64(2 * 1024)) + deviceStats.UpdateRemoteReceive(/*ByteCount*/int64(2 * 1024 * 1024)) deviceStats.UpdateConnect(false) connectTime3 := time.Now() @@ -65,7 +65,7 @@ func TestDeviceStats(t *testing.T) { assert.Equal(t, deviceStats.GetConnectCount(), 2) assert.Equal(t, deviceStats.GetNetConnectDurationSeconds(), int((connectTime2.Sub(connectTime1)+connectTime3.Sub(connectTime2))/time.Second)) assert.Equal(t, deviceStats.GetMaxConnectDurationSeconds(), int(connectTime3.Sub(connectTime2)/time.Second)) - assert.Equal(t, deviceStats.GetNetRemoteSendByteCount(), ByteCount(1024)+ByteCount(2*1024)) - assert.Equal(t, deviceStats.GetNetRemoteReceiveByteCount(), ByteCount(1024*1024)+ByteCount(2*1024*1024)) + assert.Equal(t, deviceStats.GetNetRemoteSendByteCount(), /*ByteCount*/int64(1024)+/*ByteCount*/int64(2*1024)) + assert.Equal(t, deviceStats.GetNetRemoteReceiveByteCount(), /*ByteCount*/int64(1024*1024)+/*ByteCount*/int64(2*1024*1024)) } diff --git a/go.mod b/go.mod index f34b577..92bafec 100644 --- a/go.mod +++ b/go.mod @@ -10,14 +10,14 @@ require ( github.com/urnetwork/connect v0.0.0 github.com/urnetwork/connect/protocol v0.0.0 golang.org/x/crypto v0.33.0 - golang.org/x/exp v0.0.0-20250210185358-939b2ce775ac + golang.org/x/exp v0.0.0-20250218142911-aa4b98e5adaa ) require ( github.com/google/gopacket v1.1.19 // indirect github.com/gorilla/websocket v1.5.3 // indirect github.com/oklog/ulid/v2 v2.1.0 // indirect - golang.org/x/mobile v0.0.0-20250210185054-b38b8813d607 // indirect + golang.org/x/mobile v0.0.0-20250218173827-cd096645fcd3 // indirect golang.org/x/mod v0.23.0 // indirect golang.org/x/net v0.35.0 // indirect golang.org/x/sync v0.11.0 // indirect diff --git a/go.sum b/go.sum index 815ff4d..0ce117e 100644 --- a/go.sum +++ b/go.sum @@ -42,9 +42,15 @@ golang.org/x/crypto v0.33.0 h1:IOBPskki6Lysi0lo9qQvbxiQ+FvsCC/YWOecCHAixus= golang.org/x/crypto v0.33.0/go.mod h1:bVdXmD7IV/4GdElGPozy6U7lWdRXA4qyRVGJV57uQ5M= golang.org/x/exp v0.0.0-20250210185358-939b2ce775ac h1:l5+whBCLH3iH2ZNHYLbAe58bo7yrN4mVcnkHDYz5vvs= golang.org/x/exp v0.0.0-20250210185358-939b2ce775ac/go.mod h1:hH+7mtFmImwwcMvScyxUhjuVHR3HGaDPMn9rMSUUbxo= +golang.org/x/exp v0.0.0-20250218142911-aa4b98e5adaa h1:t2QcU6V556bFjYgu4L6C+6VrCPyJZ+eyRsABUPs1mz4= +golang.org/x/exp v0.0.0-20250218142911-aa4b98e5adaa/go.mod h1:BHOTPb3L19zxehTsLoJXVaTktb06DFgmdW6Wb9s8jqk= golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/mobile v0.0.0-20250210185054-b38b8813d607 h1:8AYwUPNm7g4OIzg1y7Gol6RZQRoQdgcYHnM3HjfOoFI= golang.org/x/mobile v0.0.0-20250210185054-b38b8813d607/go.mod h1:r/F+l0hqAYkCz3NEMpHN/JAnG61+T6FsHfS0IB0/qys= +golang.org/x/mobile v0.0.0-20250218170336-ba142f8e7d3c h1:31/9466TbNlJBUpMNvtQTQN3e6Qp8v66tOsF2+CCR1Q= +golang.org/x/mobile v0.0.0-20250218170336-ba142f8e7d3c/go.mod h1:wIKdhGfB5qMMvmaH+TSl32A4l8AuMh1DYIuZBos68Uw= +golang.org/x/mobile v0.0.0-20250218173827-cd096645fcd3 h1:0V/7Y1FEaFdAzb9DkVDh4QFp4vL4yYCiJ5cjk80lZyA= +golang.org/x/mobile v0.0.0-20250218173827-cd096645fcd3/go.mod h1:j5VYNgQ6lZYZlzHFjdgS2UeqRSZunDk+/zXVTAIA3z4= golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.23.0 h1:Zb7khfcRGKk+kqfxFaP5tZqCnDZMjC5VtUBs87Hr6QM= golang.org/x/mod v0.23.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= diff --git a/local_state.go b/local_state.go index 2ab05be..89d0c7d 100644 --- a/local_state.go +++ b/local_state.go @@ -165,16 +165,16 @@ func (self *LocalState) SetInstanceId(instanceId *Id) error { } } -func (self *LocalState) SetProvideMode(provideMode ProvideMode) error { +func (self *LocalState) SetProvideMode(provideMode /*ProvideMode*/int) error { path := filepath.Join(self.localStorageDir, ".provide_mode") provideModeBytes := []byte(fmt.Sprintf("%d", provideMode)) return os.WriteFile(path, provideModeBytes, LocalStorageFilePermissions) } -func (self *LocalState) GetProvideMode() ProvideMode { +func (self *LocalState) GetProvideMode() /*ProvideMode*/int { path := filepath.Join(self.localStorageDir, ".provide_mode") if provideModeBytes, err := os.ReadFile(path); err == nil { - var provideMode ProvideMode + var provideMode /*ProvideMode*/int if _, err := fmt.Sscanf(string(provideModeBytes), "%d", &provideMode); err == nil { return provideMode } diff --git a/locations_view_controller.go b/locations_view_controller.go index 2e494dc..d8e3fb6 100644 --- a/locations_view_controller.go +++ b/locations_view_controller.go @@ -14,12 +14,12 @@ import ( "github.com/urnetwork/connect" ) -type FilterLocationsState = string +// type FilterLocationsState = string const ( - LocationsLoading FilterLocationsState = "LOCATIONS_LOADING" - LocationsLoaded FilterLocationsState = "LOCATIONS_LOADED" - LocationsError FilterLocationsState = "LOCATIONS_ERROR" + LocationsLoading /*FilterLocationsState*/string = "LOCATIONS_LOADING" + LocationsLoaded /*FilterLocationsState*/string = "LOCATIONS_LOADED" + LocationsError /*FilterLocationsState*/string = "LOCATIONS_ERROR" ) type FilteredLocations struct { @@ -36,7 +36,7 @@ type FilteredLocations struct { // } type FilteredLocationsListener interface { - FilteredLocationsChanged(locations *FilteredLocations, state FilterLocationsState) + FilteredLocationsChanged(locations *FilteredLocations, state /*FilterLocationsState*/string) } type LocationsViewController struct { @@ -50,7 +50,7 @@ type LocationsViewController struct { previousFilterSequenceNumber int64 filteredLocations *FilteredLocations - filteredLocationState FilterLocationsState + filteredLocationState /*FilterLocationsState*/string filteredLocationListeners *connect.CallbackList[FilteredLocationsListener] // filteredLocationsStateListeners *connect.CallbackList[FilteredLocationsStateListener] @@ -97,13 +97,13 @@ func (self *LocationsViewController) GetFilteredLocations() *FilteredLocations { return self.filteredLocations } -func (self *LocationsViewController) GetFilteredLocationState() FilterLocationsState { +func (self *LocationsViewController) GetFilteredLocationState() /*FilterLocationsState*/string { self.stateLock.Lock() defer self.stateLock.Unlock() return self.filteredLocationState } -func (self *LocationsViewController) filteredLocationsChanged(locations *FilteredLocations, state FilterLocationsState) { +func (self *LocationsViewController) filteredLocationsChanged(locations *FilteredLocations, state /*FilterLocationsState*/string) { for _, listener := range self.filteredLocationListeners.Get() { connect.HandleError(func() { listener.FilteredLocationsChanged(locations, state) diff --git a/sdk.go b/sdk.go index 33755dd..3136a91 100644 --- a/sdk.go +++ b/sdk.go @@ -225,33 +225,31 @@ func (self *TransferPath) toConnect() connect.TransferPath { return path } -type ProvideMode = int - +// type ProvideMode = int const ( - ProvideModeNone ProvideMode = ProvideMode(protocol.ProvideMode_None) - ProvideModeNetwork ProvideMode = ProvideMode(protocol.ProvideMode_Network) - ProvideModeFriendsAndFamily ProvideMode = ProvideMode(protocol.ProvideMode_FriendsAndFamily) - ProvideModePublic ProvideMode = ProvideMode(protocol.ProvideMode_Public) - ProvideModeStream ProvideMode = ProvideMode(protocol.ProvideMode_Stream) + ProvideModeNone /*ProvideMode*/int = /*ProvideMode*/int(protocol.ProvideMode_None) + ProvideModeNetwork /*ProvideMode*/int = /*ProvideMode*/int(protocol.ProvideMode_Network) + ProvideModeFriendsAndFamily /*ProvideMode*/int = /*ProvideMode*/int(protocol.ProvideMode_FriendsAndFamily) + ProvideModePublic /*ProvideMode*/int = /*ProvideMode*/int(protocol.ProvideMode_Public) + ProvideModeStream /*ProvideMode*/int = /*ProvideMode*/int(protocol.ProvideMode_Stream) ) -type LocationType = string - +// type LocationType = string const ( - LocationTypeCountry LocationType = "country" - LocationTypeRegion LocationType = "region" - LocationTypeCity LocationType = "city" + LocationTypeCountry /*LocationType*/string = "country" + LocationTypeRegion /*LocationType*/string = "region" + LocationTypeCity /*LocationType*/string = "city" ) -type ByteCount = int64 +// type ByteCount = int64 -type NanoCents = int64 +// type NanoCents = int64 -func UsdToNanoCents(usd float64) NanoCents { - return NanoCents(math.Round(usd * float64(1000000000))) +func UsdToNanoCents(usd float64) /*NanoCents*/int64 { + return /*NanoCents*/int64(math.Round(usd * float64(1000000000))) } -func NanoCentsToUsd(nanoCents NanoCents) float64 { +func NanoCentsToUsd(nanoCents /*NanoCents*/int64) float64 { return float64(nanoCents) / float64(1000000000) } @@ -264,7 +262,7 @@ type ConnectLocation struct { Promoted bool `json:"promoted,omitempty"` MatchDistance int32 `json:"match_distance,omitempty"` - LocationType LocationType `json:"location_type,omitempty"` + LocationType /*LocationType*/string `json:"location_type,omitempty"` City string `json:"city,omitempty"` Region string `json:"region,omitempty"` @@ -412,7 +410,7 @@ func (self *ConnectLocationId) String() string { } type ProvideSecretKey struct { - ProvideMode ProvideMode `json:"provide_mode"` + ProvideMode /*ProvideMode*/int `json:"provide_mode"` ProvideSecretKey string `json:"provide_secret_key"` } diff --git a/wallet_view_controller.go b/wallet_view_controller.go index b0781bd..c2624b8 100644 --- a/wallet_view_controller.go +++ b/wallet_view_controller.go @@ -29,7 +29,7 @@ type IsRemovingWalletListener interface { } type UnpaidByteCountListener interface { - StateChanged(ByteCount) + StateChanged(/*ByteCount*/int64) } type PayoutWalletListener interface { @@ -40,7 +40,7 @@ type AccountWallet struct { WalletId *Id `json:"wallet_id"` CircleWalletId string `json:"circle_wallet_id,omitempty"` NetworkId *Id `json:"network_id"` - WalletType WalletType `json:"wallet_type"` + WalletType /*WalletType*/string `json:"wallet_type"` Blockchain string `json:"blockchain"` WalletAddress string `json:"wallet_address"` Active bool `json:"active"` @@ -53,8 +53,8 @@ type AccountPayment struct { PaymentPlanId *Id `json:"payment_plan_id"` WalletId *Id `json:"wallet_id"` NetworkId *Id `json:"network_id"` - PayoutByteCount ByteCount `json:"payout_byte_count"` - Payout NanoCents `json:"payout_nano_cents"` + PayoutByteCount /*ByteCount*/int64 `json:"payout_byte_count"` + Payout /*NanoCents*/int64 `json:"payout_nano_cents"` MinSweepTime *Time `json:"min_sweep_time"` CreateTime *Time `json:"create_time"` @@ -85,7 +85,7 @@ type WalletViewController struct { isPollingAccountWallets bool isPollingPayoutWallet bool isFetchingTransferStats bool - unpaidByteCount ByteCount + unpaidByteCount /*ByteCount*/int64 stateLock sync.Mutex @@ -182,7 +182,7 @@ func NewValidateAddressCallback(sendResult func(bool)) *validateAddressCallbackI func (vc *WalletViewController) ValidateAddress( address string, - blockchain Blockchain, + blockchain /*Blockchain*/string, callback ValidateAddressCallback, ) { @@ -231,7 +231,7 @@ func (vc *WalletViewController) setIsCreatingExternalWallet(state bool) { } -func (vc *WalletViewController) AddExternalWallet(address string, blockchain Blockchain) { +func (vc *WalletViewController) AddExternalWallet(address string, blockchain /*Blockchain*/string) { if !vc.isAddingExternalWallet { @@ -631,7 +631,7 @@ func (self *WalletViewController) AddUnpaidByteCountListener(listener UnpaidByte }) } -func (self *WalletViewController) unpaidByteCountChanged(count ByteCount) { +func (self *WalletViewController) unpaidByteCountChanged(count /*ByteCount*/int64) { for _, listener := range self.unpaidByteCountListeners.Get() { connect.HandleError(func() { listener.StateChanged(count) @@ -639,7 +639,7 @@ func (self *WalletViewController) unpaidByteCountChanged(count ByteCount) { } } -func (self *WalletViewController) setUnpaidByteCount(count ByteCount) { +func (self *WalletViewController) setUnpaidByteCount(count /*ByteCount*/int64) { func() { self.stateLock.Lock() defer self.stateLock.Unlock() @@ -649,7 +649,7 @@ func (self *WalletViewController) setUnpaidByteCount(count ByteCount) { self.unpaidByteCountChanged(count) } -func (self *WalletViewController) GetUnpaidByteCount() ByteCount { +func (self *WalletViewController) GetUnpaidByteCount() /*ByteCount*/int64 { return self.unpaidByteCount }