diff --git a/api/gateway/chain/client/rail_gateway_test.go b/api/gateway/chain/client/rail_gateway_test.go index 81defdfa..95dac86f 100644 --- a/api/gateway/chain/client/rail_gateway_test.go +++ b/api/gateway/chain/client/rail_gateway_test.go @@ -7,7 +7,7 @@ import ( ) func TestNewRailGateway_NormalizesRail(t *testing.T) { - gw := NewRailGateway(nil, RailGatewayConfig{Rail: "card_payout", Network: "tron"}) + gw := NewRailGateway(nil, RailGatewayConfig{Rail: "card", Network: "tron"}) if got, want := gw.Rail(), discovery.RailCardPayout; got != want { t.Fatalf("unexpected rail: got=%q want=%q", got, want) } diff --git a/api/gateway/chain/internal/service/gateway/service.go b/api/gateway/chain/internal/service/gateway/service.go index ad157adf..437bd0da 100644 --- a/api/gateway/chain/internal/service/gateway/service.go +++ b/api/gateway/chain/internal/service/gateway/service.go @@ -223,6 +223,7 @@ func (s *Service) startDiscoveryAnnouncers() { } announce := discovery.Announcement{ ID: discovery.StableCryptoRailGatewayID(string(network.Name)), + InstanceID: discovery.InstanceID(), Service: "CRYPTO_RAIL_GATEWAY", Rail: discovery.RailCrypto, Operations: discovery.CryptoRailGatewayOperations(), diff --git a/api/gateway/tron/client/rail_gateway_test.go b/api/gateway/tron/client/rail_gateway_test.go index 81defdfa..95dac86f 100644 --- a/api/gateway/tron/client/rail_gateway_test.go +++ b/api/gateway/tron/client/rail_gateway_test.go @@ -7,7 +7,7 @@ import ( ) func TestNewRailGateway_NormalizesRail(t *testing.T) { - gw := NewRailGateway(nil, RailGatewayConfig{Rail: "card_payout", Network: "tron"}) + gw := NewRailGateway(nil, RailGatewayConfig{Rail: "card", Network: "tron"}) if got, want := gw.Rail(), discovery.RailCardPayout; got != want { t.Fatalf("unexpected rail: got=%q want=%q", got, want) } diff --git a/api/gateway/tron/internal/service/gateway/options.go b/api/gateway/tron/internal/service/gateway/options.go index 34c8571b..03499bfe 100644 --- a/api/gateway/tron/internal/service/gateway/options.go +++ b/api/gateway/tron/internal/service/gateway/options.go @@ -55,7 +55,7 @@ func WithNetworks(networks []shared.Network) Option { } for i := range clone.TokenConfigs { clone.TokenConfigs[i].Symbol = strings.ToUpper(strings.TrimSpace(clone.TokenConfigs[i].Symbol)) - clone.TokenConfigs[i].ContractAddress = strings.ToLower(strings.TrimSpace(clone.TokenConfigs[i].ContractAddress)) + clone.TokenConfigs[i].ContractAddress = strings.TrimSpace(clone.TokenConfigs[i].ContractAddress) } clone.Name = network.Name s.networks[clone.Name.String()] = clone diff --git a/api/gateway/tron/internal/service/gateway/service.go b/api/gateway/tron/internal/service/gateway/service.go index 650680cf..e9d49a6b 100644 --- a/api/gateway/tron/internal/service/gateway/service.go +++ b/api/gateway/tron/internal/service/gateway/service.go @@ -228,6 +228,7 @@ func (s *Service) startDiscoveryAnnouncers() { } announce := discovery.Announcement{ ID: discovery.StableCryptoRailGatewayID(network.Name.String()), + InstanceID: discovery.InstanceID(), Service: "CRYPTO_RAIL_GATEWAY", Rail: discovery.RailCrypto, Operations: discovery.CryptoRailGatewayOperations(), diff --git a/api/gateway/tron/internal/service/gateway/service_test.go b/api/gateway/tron/internal/service/gateway/service_test.go index f1195b49..fdf28a88 100644 --- a/api/gateway/tron/internal/service/gateway/service_test.go +++ b/api/gateway/tron/internal/service/gateway/service_test.go @@ -18,6 +18,7 @@ import ( "go.uber.org/zap" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" + "google.golang.org/protobuf/types/known/structpb" "github.com/tech/sendico/gateway/tron/internal/keymanager" "github.com/tech/sendico/gateway/tron/internal/service/gateway/drivers" @@ -88,6 +89,56 @@ func TestCreateManagedWallet_NativeTokenWithoutContract(t *testing.T) { require.Empty(t, resp.GetWallet().GetAsset().GetContractAddress()) } +func TestCreateManagedWallet_ResolvedContractPreservesCase(t *testing.T) { + svc, _ := newTestService(t) + ctx := context.Background() + + resp, err := svc.CreateManagedWallet(ctx, &ichainv1.CreateManagedWalletRequest{ + IdempotencyKey: "idem-contract-case", + OrganizationRef: "org-1", + OwnerRef: "owner-1", + Asset: &ichainv1.Asset{ + Chain: ichainv1.ChainNetwork_CHAIN_NETWORK_TRON_MAINNET, + TokenSymbol: "USDT", + }, + }) + require.NoError(t, err) + require.NotNil(t, resp.GetWallet()) + require.Equal(t, "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t", resp.GetWallet().GetAsset().GetContractAddress()) +} + +func TestOpenAccount_PreservesContractAddressCase(t *testing.T) { + svc, _ := newTestService(t) + ctx := context.Background() + + const contract = "TR7NhQjeKQxGTCi8q8ZY4pL8otSzgjLj6T" + params, err := structpb.NewStruct(map[string]interface{}{ + "organization_ref": "org-1", + "network": "TRON_MAINNET", + "token_symbol": "USDT", + "contract_address": contract, + }) + require.NoError(t, err) + + resp, err := svc.OpenAccount(ctx, &connectorv1.OpenAccountRequest{ + IdempotencyKey: "idem-open-account-contract-case", + Kind: connectorv1.AccountKind_CHAIN_MANAGED_WALLET, + Asset: "USDT-TRC20", + OwnerRef: "owner-1", + Params: params, + }) + require.NoError(t, err) + require.NotNil(t, resp) + require.Nil(t, resp.GetError()) + require.NotNil(t, resp.GetAccount()) + + details := resp.GetAccount().GetProviderDetails() + require.NotNil(t, details) + field, ok := details.GetFields()["contract_address"] + require.True(t, ok) + require.Equal(t, contract, field.GetStringValue()) +} + func TestListAccounts_OrganizationRefFilters(t *testing.T) { svc, _ := newTestService(t) ctx := context.Background() diff --git a/api/gateway/tron/shared/helpers.go b/api/gateway/tron/shared/helpers.go index 6677ab02..e834e9d3 100644 --- a/api/gateway/tron/shared/helpers.go +++ b/api/gateway/tron/shared/helpers.go @@ -38,7 +38,7 @@ func ResolveContractAddress(tokens []TokenContract, symbol string) string { upper := strings.ToUpper(symbol) for _, token := range tokens { if strings.EqualFold(token.Symbol, upper) && token.ContractAddress != "" { - return strings.ToLower(token.ContractAddress) + return strings.TrimSpace(token.ContractAddress) } } return ""