diff --git a/go.mod b/go.mod index c2624a8..b217f0c 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/aws/aws-sdk-go-v2/feature/rds/auth v1.6.25 github.com/aws/aws-sdk-go-v2/service/s3 v1.102.2 github.com/code-payments/code-vm-indexer v1.2.0 - github.com/code-payments/ocp-protobuf-api v1.13.0 + github.com/code-payments/ocp-protobuf-api v1.13.2-0.20260610171241-de46af911053 github.com/emirpasic/gods v1.12.0 github.com/envoyproxy/protoc-gen-validate v1.2.1 github.com/golang/protobuf v1.5.4 diff --git a/go.sum b/go.sum index 73ae0de..9175ac0 100644 --- a/go.sum +++ b/go.sum @@ -102,8 +102,8 @@ github.com/cockroachdb/apd v1.1.0 h1:3LFP3629v+1aKXU5Q37mxmRxX/pIu1nijXydLShEq5I github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ= github.com/code-payments/code-vm-indexer v1.2.0 h1:rSHpBMiT9BKgmKcXg/VIoi/h0t7jNxGx07Qz59m+6Q0= github.com/code-payments/code-vm-indexer v1.2.0/go.mod h1:vn91YN2qNqb+gGJeZe2+l+TNxVmEEiRHXXnIn2Y40h8= -github.com/code-payments/ocp-protobuf-api v1.13.0 h1:Skzi+h0wqAu1e8zMNN7jCeQoJB3t1BVAVpnv0JuRDIU= -github.com/code-payments/ocp-protobuf-api v1.13.0/go.mod h1:tw6BooY5a8l6CtSZnKOruyKII0W04n89pcM4BizrgG8= +github.com/code-payments/ocp-protobuf-api v1.13.2-0.20260610171241-de46af911053 h1:0B96K7/z7TpFbAJeyzP43A0eM58Ie/KRuu5U6PUrses= +github.com/code-payments/ocp-protobuf-api v1.13.2-0.20260610171241-de46af911053/go.mod h1:tw6BooY5a8l6CtSZnKOruyKII0W04n89pcM4BizrgG8= github.com/containerd/continuity v0.0.0-20190827140505-75bee3e2ccb6 h1:NmTXa/uVnDyp0TY5MKi197+3HWcnYWfnHGyaFthlnGw= github.com/containerd/continuity v0.0.0-20190827140505-75bee3e2ccb6/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y= github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= diff --git a/ocp/aml/guard_test.go b/ocp/aml/guard_test.go index c741337..bb81663 100644 --- a/ocp/aml/guard_test.go +++ b/ocp/aml/guard_test.go @@ -194,9 +194,9 @@ func makeReceivePaymentsPubliclyIntent(t *testing.T, owner *common.Account, usdM IntentType: intent.ReceivePaymentsPublicly, ReceivePaymentsPubliclyMetadata: &intent.ReceivePaymentsPubliclyMetadata{ - Source: testutil.NewRandomAccount(t).PublicKey().ToBase58(), - Quantity: uint64(usdMarketValue), - IsRemoteSend: true, + Source: testutil.NewRandomAccount(t).PublicKey().ToBase58(), + Quantity: uint64(usdMarketValue), + IsIndirectSend: true, OriginalExchangeCurrency: currency_lib.USD, OriginalExchangeRate: 1.0, diff --git a/ocp/data/intent/intent.go b/ocp/data/intent/intent.go index 95342f4..104aafd 100644 --- a/ocp/data/intent/intent.go +++ b/ocp/data/intent/intent.go @@ -80,16 +80,16 @@ type SendPublicPaymentMetadata struct { NativeAmount float64 UsdMarketValue float64 - IsWithdrawal bool - IsRemoteSend bool - IsSwapSell bool + IsWithdrawal bool + IsIndirectSend bool + IsSwapSell bool } type ReceivePaymentsPubliclyMetadata struct { Source string Quantity uint64 - IsRemoteSend bool + IsIndirectSend bool IsReturned bool IsIssuerVoidingGiftCard bool @@ -358,9 +358,9 @@ func (m *SendPublicPaymentMetadata) Clone() SendPublicPaymentMetadata { NativeAmount: m.NativeAmount, UsdMarketValue: m.UsdMarketValue, - IsWithdrawal: m.IsWithdrawal, - IsRemoteSend: m.IsRemoteSend, - IsSwapSell: m.IsSwapSell, + IsWithdrawal: m.IsWithdrawal, + IsIndirectSend: m.IsIndirectSend, + IsSwapSell: m.IsSwapSell, } } @@ -375,7 +375,7 @@ func (m *SendPublicPaymentMetadata) CopyTo(dst *SendPublicPaymentMetadata) { dst.UsdMarketValue = m.UsdMarketValue dst.IsWithdrawal = m.IsWithdrawal - dst.IsRemoteSend = m.IsRemoteSend + dst.IsIndirectSend = m.IsIndirectSend dst.IsSwapSell = m.IsSwapSell } @@ -412,7 +412,7 @@ func (m *ReceivePaymentsPubliclyMetadata) Clone() ReceivePaymentsPubliclyMetadat Source: m.Source, Quantity: m.Quantity, - IsRemoteSend: m.IsRemoteSend, + IsIndirectSend: m.IsIndirectSend, IsReturned: m.IsReturned, IsIssuerVoidingGiftCard: m.IsIssuerVoidingGiftCard, @@ -428,7 +428,7 @@ func (m *ReceivePaymentsPubliclyMetadata) CopyTo(dst *ReceivePaymentsPubliclyMet dst.Source = m.Source dst.Quantity = m.Quantity - dst.IsRemoteSend = m.IsRemoteSend + dst.IsIndirectSend = m.IsIndirectSend dst.IsReturned = m.IsReturned dst.IsIssuerVoidingGiftCard = m.IsIssuerVoidingGiftCard diff --git a/ocp/data/intent/memory/store.go b/ocp/data/intent/memory/store.go index 6aacce7..469a267 100644 --- a/ocp/data/intent/memory/store.go +++ b/ocp/data/intent/memory/store.go @@ -194,16 +194,16 @@ func (s *store) filterByType(items []*intent.Record, intentType intent.Type) []* return res } -func (s *store) filterByRemoteSendFlag(items []*intent.Record, want bool) []*intent.Record { +func (s *store) filterByIndirectSendFlag(items []*intent.Record, want bool) []*intent.Record { var res []*intent.Record for _, item := range items { switch item.IntentType { case intent.SendPublicPayment: - if item.SendPublicPaymentMetadata.IsRemoteSend == want { + if item.SendPublicPaymentMetadata.IsIndirectSend == want { res = append(res, item) } case intent.ReceivePaymentsPublicly: - if item.ReceivePaymentsPubliclyMetadata.IsRemoteSend == want { + if item.ReceivePaymentsPubliclyMetadata.IsIndirectSend == want { res = append(res, item) } } @@ -319,7 +319,7 @@ func (s *store) GetOriginalGiftCardIssuedIntent(ctx context.Context, giftCardVau items := s.findByDestination(giftCardVault) items = s.filterByType(items, intent.SendPublicPayment) items = s.filterByState(items, false, intent.StateRevoked) - items = s.filterByRemoteSendFlag(items, true) + items = s.filterByIndirectSendFlag(items, true) if len(items) == 0 { return nil, intent.ErrIntentNotFound @@ -340,7 +340,7 @@ func (s *store) GetGiftCardClaimedIntent(ctx context.Context, giftCardVault stri items := s.findBySource(giftCardVault) items = s.filterByType(items, intent.ReceivePaymentsPublicly) items = s.filterByState(items, false, intent.StateRevoked) - items = s.filterByRemoteSendFlag(items, true) + items = s.filterByIndirectSendFlag(items, true) if len(items) == 0 { return nil, intent.ErrIntentNotFound diff --git a/ocp/data/intent/postgres/model.go b/ocp/data/intent/postgres/model.go index d53ff3c..dcfecbd 100644 --- a/ocp/data/intent/postgres/model.go +++ b/ocp/data/intent/postgres/model.go @@ -40,7 +40,7 @@ type intentModel struct { UsdMarketValue float64 `db:"usd_market_value"` OriginalUsdMarketValue float64 `db:"original_usd_market_value"` IsWithdrawal bool `db:"is_withdraw"` - IsRemoteSend bool `db:"is_remote_send"` + IsIndirectSend bool `db:"is_remote_send"` // todo: rename column IsReturned bool `db:"is_returned"` IsIssuerVoidingGiftCard bool `db:"is_issuer_voiding_gift_card"` IsSwap bool `db:"is_swap"` @@ -106,13 +106,13 @@ func toIntentModel(obj *intent.Record) (*intentModel, error) { m.OriginalUsdMarketValue = obj.SendPublicPaymentMetadata.UsdMarketValue m.IsWithdrawal = obj.SendPublicPaymentMetadata.IsWithdrawal - m.IsRemoteSend = obj.SendPublicPaymentMetadata.IsRemoteSend + m.IsIndirectSend = obj.SendPublicPaymentMetadata.IsIndirectSend m.IsSwap = obj.SendPublicPaymentMetadata.IsSwapSell case intent.ReceivePaymentsPublicly: m.Source = obj.ReceivePaymentsPubliclyMetadata.Source m.Quantity = obj.ReceivePaymentsPubliclyMetadata.Quantity - m.IsRemoteSend = obj.ReceivePaymentsPubliclyMetadata.IsRemoteSend + m.IsIndirectSend = obj.ReceivePaymentsPubliclyMetadata.IsIndirectSend m.IsReturned = obj.ReceivePaymentsPubliclyMetadata.IsReturned m.IsIssuerVoidingGiftCard = obj.ReceivePaymentsPubliclyMetadata.IsIssuerVoidingGiftCard @@ -189,16 +189,16 @@ func fromIntentModel(obj *intentModel) *intent.Record { NativeAmount: obj.NativeAmount, UsdMarketValue: obj.UsdMarketValue, - IsWithdrawal: obj.IsWithdrawal, - IsRemoteSend: obj.IsRemoteSend, - IsSwapSell: obj.IsSwap, + IsWithdrawal: obj.IsWithdrawal, + IsIndirectSend: obj.IsIndirectSend, + IsSwapSell: obj.IsSwap, } case intent.ReceivePaymentsPublicly: record.ReceivePaymentsPubliclyMetadata = &intent.ReceivePaymentsPubliclyMetadata{ Source: obj.Source, Quantity: obj.Quantity, - IsRemoteSend: obj.IsRemoteSend, + IsIndirectSend: obj.IsIndirectSend, IsReturned: obj.IsReturned, IsIssuerVoidingGiftCard: obj.IsIssuerVoidingGiftCard, @@ -256,7 +256,7 @@ func (m *intentModel) dbSave(ctx context.Context, db *sqlx.DB) error { m.UsdMarketValue, m.OriginalUsdMarketValue, m.IsWithdrawal, - m.IsRemoteSend, + m.IsIndirectSend, m.IsReturned, m.IsIssuerVoidingGiftCard, m.IsSwap, diff --git a/ocp/data/intent/tests/tests.go b/ocp/data/intent/tests/tests.go index 4bd135b..cb42c28 100644 --- a/ocp/data/intent/tests/tests.go +++ b/ocp/data/intent/tests/tests.go @@ -151,9 +151,9 @@ func testSendPublicPaymentRoundTrip(t *testing.T, s intent.Store) { NativeAmount: 0.00073 * 12345, UsdMarketValue: 0.00042, - IsWithdrawal: true, - IsRemoteSend: true, - IsSwapSell: true, + IsWithdrawal: true, + IsIndirectSend: true, + IsSwapSell: true, }, AppMetadata: []byte("test_app_metadata"), State: intent.StateUnknown, @@ -180,7 +180,7 @@ func testSendPublicPaymentRoundTrip(t *testing.T, s intent.Store) { assert.Equal(t, cloned.SendPublicPaymentMetadata.NativeAmount, actual.SendPublicPaymentMetadata.NativeAmount) assert.Equal(t, cloned.SendPublicPaymentMetadata.UsdMarketValue, actual.SendPublicPaymentMetadata.UsdMarketValue) assert.Equal(t, cloned.SendPublicPaymentMetadata.IsWithdrawal, actual.SendPublicPaymentMetadata.IsWithdrawal) - assert.Equal(t, cloned.SendPublicPaymentMetadata.IsRemoteSend, actual.SendPublicPaymentMetadata.IsRemoteSend) + assert.Equal(t, cloned.SendPublicPaymentMetadata.IsIndirectSend, actual.SendPublicPaymentMetadata.IsIndirectSend) assert.Equal(t, cloned.SendPublicPaymentMetadata.IsSwapSell, actual.SendPublicPaymentMetadata.IsSwapSell) assert.Equal(t, cloned.AppMetadata, actual.AppMetadata) assert.Equal(t, cloned.State, actual.State) @@ -207,7 +207,7 @@ func testReceivePaymentsPubliclyRoundTrip(t *testing.T, s intent.Store) { ReceivePaymentsPubliclyMetadata: &intent.ReceivePaymentsPubliclyMetadata{ Source: "test_source", Quantity: 12345, - IsRemoteSend: true, + IsIndirectSend: true, IsReturned: true, IsIssuerVoidingGiftCard: true, OriginalExchangeCurrency: "usd", @@ -233,7 +233,7 @@ func testReceivePaymentsPubliclyRoundTrip(t *testing.T, s intent.Store) { require.NotNil(t, actual.ReceivePaymentsPubliclyMetadata) assert.Equal(t, cloned.ReceivePaymentsPubliclyMetadata.Source, actual.ReceivePaymentsPubliclyMetadata.Source) assert.Equal(t, cloned.ReceivePaymentsPubliclyMetadata.Quantity, actual.ReceivePaymentsPubliclyMetadata.Quantity) - assert.Equal(t, cloned.ReceivePaymentsPubliclyMetadata.IsRemoteSend, actual.ReceivePaymentsPubliclyMetadata.IsRemoteSend) + assert.Equal(t, cloned.ReceivePaymentsPubliclyMetadata.IsIndirectSend, actual.ReceivePaymentsPubliclyMetadata.IsIndirectSend) assert.Equal(t, cloned.ReceivePaymentsPubliclyMetadata.IsReturned, actual.ReceivePaymentsPubliclyMetadata.IsReturned) assert.Equal(t, cloned.ReceivePaymentsPubliclyMetadata.IsIssuerVoidingGiftCard, actual.ReceivePaymentsPubliclyMetadata.IsIssuerVoidingGiftCard) assert.Equal(t, cloned.ReceivePaymentsPubliclyMetadata.OriginalExchangeCurrency, actual.ReceivePaymentsPubliclyMetadata.OriginalExchangeCurrency) @@ -407,17 +407,17 @@ func testGetOriginalGiftCardIssuedIntent(t *testing.T, s intent.Store) { ctx := context.Background() records := []*intent.Record{ - {IntentId: "i1", IntentType: intent.SendPublicPayment, SendPublicPaymentMetadata: &intent.SendPublicPaymentMetadata{IsRemoteSend: false, DestinationTokenAccount: "a1", DestinationOwnerAccount: "o1", Quantity: 1, ExchangeCurrency: currency.USD, ExchangeRate: 1, NativeAmount: 1, UsdMarketValue: 1}, MintAccount: "mint", InitiatorOwnerAccount: "user", State: intent.StateConfirmed}, + {IntentId: "i1", IntentType: intent.SendPublicPayment, SendPublicPaymentMetadata: &intent.SendPublicPaymentMetadata{IsIndirectSend: false, DestinationTokenAccount: "a1", DestinationOwnerAccount: "o1", Quantity: 1, ExchangeCurrency: currency.USD, ExchangeRate: 1, NativeAmount: 1, UsdMarketValue: 1}, MintAccount: "mint", InitiatorOwnerAccount: "user", State: intent.StateConfirmed}, - {IntentId: "i2", IntentType: intent.SendPublicPayment, SendPublicPaymentMetadata: &intent.SendPublicPaymentMetadata{IsRemoteSend: true, DestinationTokenAccount: "a2", DestinationOwnerAccount: "o2", Quantity: 1, ExchangeCurrency: currency.USD, ExchangeRate: 1, NativeAmount: 1, UsdMarketValue: 1}, MintAccount: "mint", InitiatorOwnerAccount: "user", State: intent.StateConfirmed}, - {IntentId: "i3", IntentType: intent.SendPublicPayment, SendPublicPaymentMetadata: &intent.SendPublicPaymentMetadata{IsRemoteSend: false, DestinationTokenAccount: "a2", DestinationOwnerAccount: "o2", Quantity: 1, ExchangeCurrency: currency.USD, ExchangeRate: 1, NativeAmount: 1, UsdMarketValue: 1}, MintAccount: "mint", InitiatorOwnerAccount: "user", State: intent.StateConfirmed}, + {IntentId: "i2", IntentType: intent.SendPublicPayment, SendPublicPaymentMetadata: &intent.SendPublicPaymentMetadata{IsIndirectSend: true, DestinationTokenAccount: "a2", DestinationOwnerAccount: "o2", Quantity: 1, ExchangeCurrency: currency.USD, ExchangeRate: 1, NativeAmount: 1, UsdMarketValue: 1}, MintAccount: "mint", InitiatorOwnerAccount: "user", State: intent.StateConfirmed}, + {IntentId: "i3", IntentType: intent.SendPublicPayment, SendPublicPaymentMetadata: &intent.SendPublicPaymentMetadata{IsIndirectSend: false, DestinationTokenAccount: "a2", DestinationOwnerAccount: "o2", Quantity: 1, ExchangeCurrency: currency.USD, ExchangeRate: 1, NativeAmount: 1, UsdMarketValue: 1}, MintAccount: "mint", InitiatorOwnerAccount: "user", State: intent.StateConfirmed}, {IntentId: "i4", IntentType: intent.ExternalDeposit, ExternalDepositMetadata: &intent.ExternalDepositMetadata{DestinationTokenAccount: "a2", ExchangeCurrency: currency.USD, ExchangeRate: 1, NativeAmount: 1, Quantity: 1, UsdMarketValue: 1}, MintAccount: "mint", InitiatorOwnerAccount: "user", State: intent.StateConfirmed}, - {IntentId: "i5", IntentType: intent.SendPublicPayment, SendPublicPaymentMetadata: &intent.SendPublicPaymentMetadata{IsRemoteSend: true, DestinationTokenAccount: "a3", DestinationOwnerAccount: "o3", Quantity: 1, ExchangeCurrency: currency.USD, ExchangeRate: 1, NativeAmount: 1, UsdMarketValue: 1}, MintAccount: "mint", InitiatorOwnerAccount: "user", State: intent.StateConfirmed}, - {IntentId: "i6", IntentType: intent.SendPublicPayment, SendPublicPaymentMetadata: &intent.SendPublicPaymentMetadata{IsRemoteSend: true, DestinationTokenAccount: "a3", DestinationOwnerAccount: "o3", Quantity: 1, ExchangeCurrency: currency.USD, ExchangeRate: 1, NativeAmount: 1, UsdMarketValue: 1}, MintAccount: "mint", InitiatorOwnerAccount: "user", State: intent.StateConfirmed}, + {IntentId: "i5", IntentType: intent.SendPublicPayment, SendPublicPaymentMetadata: &intent.SendPublicPaymentMetadata{IsIndirectSend: true, DestinationTokenAccount: "a3", DestinationOwnerAccount: "o3", Quantity: 1, ExchangeCurrency: currency.USD, ExchangeRate: 1, NativeAmount: 1, UsdMarketValue: 1}, MintAccount: "mint", InitiatorOwnerAccount: "user", State: intent.StateConfirmed}, + {IntentId: "i6", IntentType: intent.SendPublicPayment, SendPublicPaymentMetadata: &intent.SendPublicPaymentMetadata{IsIndirectSend: true, DestinationTokenAccount: "a3", DestinationOwnerAccount: "o3", Quantity: 1, ExchangeCurrency: currency.USD, ExchangeRate: 1, NativeAmount: 1, UsdMarketValue: 1}, MintAccount: "mint", InitiatorOwnerAccount: "user", State: intent.StateConfirmed}, - {IntentId: "i7", IntentType: intent.SendPublicPayment, SendPublicPaymentMetadata: &intent.SendPublicPaymentMetadata{IsRemoteSend: true, DestinationTokenAccount: "a4", DestinationOwnerAccount: "o4", Quantity: 1, ExchangeCurrency: currency.USD, ExchangeRate: 1, NativeAmount: 1, UsdMarketValue: 1}, MintAccount: "mint", InitiatorOwnerAccount: "user", State: intent.StatePending}, - {IntentId: "i8", IntentType: intent.SendPublicPayment, SendPublicPaymentMetadata: &intent.SendPublicPaymentMetadata{IsRemoteSend: true, DestinationTokenAccount: "a4", DestinationOwnerAccount: "o4", Quantity: 1, ExchangeCurrency: currency.USD, ExchangeRate: 1, NativeAmount: 1, UsdMarketValue: 1}, MintAccount: "mint", InitiatorOwnerAccount: "user", State: intent.StateRevoked}, + {IntentId: "i7", IntentType: intent.SendPublicPayment, SendPublicPaymentMetadata: &intent.SendPublicPaymentMetadata{IsIndirectSend: true, DestinationTokenAccount: "a4", DestinationOwnerAccount: "o4", Quantity: 1, ExchangeCurrency: currency.USD, ExchangeRate: 1, NativeAmount: 1, UsdMarketValue: 1}, MintAccount: "mint", InitiatorOwnerAccount: "user", State: intent.StatePending}, + {IntentId: "i8", IntentType: intent.SendPublicPayment, SendPublicPaymentMetadata: &intent.SendPublicPaymentMetadata{IsIndirectSend: true, DestinationTokenAccount: "a4", DestinationOwnerAccount: "o4", Quantity: 1, ExchangeCurrency: currency.USD, ExchangeRate: 1, NativeAmount: 1, UsdMarketValue: 1}, MintAccount: "mint", InitiatorOwnerAccount: "user", State: intent.StateRevoked}, } for _, record := range records { @@ -448,16 +448,16 @@ func testGetGiftCardClaimedIntent(t *testing.T, s intent.Store) { ctx := context.Background() records := []*intent.Record{ - {IntentId: "i1", IntentType: intent.ReceivePaymentsPublicly, ReceivePaymentsPubliclyMetadata: &intent.ReceivePaymentsPubliclyMetadata{IsRemoteSend: false, Source: "a1", Quantity: 1, OriginalExchangeCurrency: currency.USD, OriginalExchangeRate: 1, OriginalNativeAmount: 1, UsdMarketValue: 1}, MintAccount: "mint", InitiatorOwnerAccount: "user", State: intent.StateConfirmed}, + {IntentId: "i1", IntentType: intent.ReceivePaymentsPublicly, ReceivePaymentsPubliclyMetadata: &intent.ReceivePaymentsPubliclyMetadata{IsIndirectSend: false, Source: "a1", Quantity: 1, OriginalExchangeCurrency: currency.USD, OriginalExchangeRate: 1, OriginalNativeAmount: 1, UsdMarketValue: 1}, MintAccount: "mint", InitiatorOwnerAccount: "user", State: intent.StateConfirmed}, - {IntentId: "i2", IntentType: intent.ReceivePaymentsPublicly, ReceivePaymentsPubliclyMetadata: &intent.ReceivePaymentsPubliclyMetadata{IsRemoteSend: false, Source: "a2", Quantity: 1, OriginalExchangeCurrency: currency.USD, OriginalExchangeRate: 1, OriginalNativeAmount: 1, UsdMarketValue: 1}, MintAccount: "mint", InitiatorOwnerAccount: "user", State: intent.StateConfirmed}, - {IntentId: "i3", IntentType: intent.ReceivePaymentsPublicly, ReceivePaymentsPubliclyMetadata: &intent.ReceivePaymentsPubliclyMetadata{IsRemoteSend: true, Source: "a2", Quantity: 1, OriginalExchangeCurrency: currency.USD, OriginalExchangeRate: 1, OriginalNativeAmount: 1, UsdMarketValue: 1}, MintAccount: "mint", InitiatorOwnerAccount: "user", State: intent.StateConfirmed}, + {IntentId: "i2", IntentType: intent.ReceivePaymentsPublicly, ReceivePaymentsPubliclyMetadata: &intent.ReceivePaymentsPubliclyMetadata{IsIndirectSend: false, Source: "a2", Quantity: 1, OriginalExchangeCurrency: currency.USD, OriginalExchangeRate: 1, OriginalNativeAmount: 1, UsdMarketValue: 1}, MintAccount: "mint", InitiatorOwnerAccount: "user", State: intent.StateConfirmed}, + {IntentId: "i3", IntentType: intent.ReceivePaymentsPublicly, ReceivePaymentsPubliclyMetadata: &intent.ReceivePaymentsPubliclyMetadata{IsIndirectSend: true, Source: "a2", Quantity: 1, OriginalExchangeCurrency: currency.USD, OriginalExchangeRate: 1, OriginalNativeAmount: 1, UsdMarketValue: 1}, MintAccount: "mint", InitiatorOwnerAccount: "user", State: intent.StateConfirmed}, - {IntentId: "i4", IntentType: intent.ReceivePaymentsPublicly, ReceivePaymentsPubliclyMetadata: &intent.ReceivePaymentsPubliclyMetadata{IsRemoteSend: true, Source: "a3", Quantity: 1, OriginalExchangeCurrency: currency.USD, OriginalExchangeRate: 1, OriginalNativeAmount: 1, UsdMarketValue: 1}, MintAccount: "mint", InitiatorOwnerAccount: "user", State: intent.StateConfirmed}, - {IntentId: "i5", IntentType: intent.ReceivePaymentsPublicly, ReceivePaymentsPubliclyMetadata: &intent.ReceivePaymentsPubliclyMetadata{IsRemoteSend: true, Source: "a3", Quantity: 1, OriginalExchangeCurrency: currency.USD, OriginalExchangeRate: 1, OriginalNativeAmount: 1, UsdMarketValue: 1}, MintAccount: "mint", InitiatorOwnerAccount: "user", State: intent.StateConfirmed}, + {IntentId: "i4", IntentType: intent.ReceivePaymentsPublicly, ReceivePaymentsPubliclyMetadata: &intent.ReceivePaymentsPubliclyMetadata{IsIndirectSend: true, Source: "a3", Quantity: 1, OriginalExchangeCurrency: currency.USD, OriginalExchangeRate: 1, OriginalNativeAmount: 1, UsdMarketValue: 1}, MintAccount: "mint", InitiatorOwnerAccount: "user", State: intent.StateConfirmed}, + {IntentId: "i5", IntentType: intent.ReceivePaymentsPublicly, ReceivePaymentsPubliclyMetadata: &intent.ReceivePaymentsPubliclyMetadata{IsIndirectSend: true, Source: "a3", Quantity: 1, OriginalExchangeCurrency: currency.USD, OriginalExchangeRate: 1, OriginalNativeAmount: 1, UsdMarketValue: 1}, MintAccount: "mint", InitiatorOwnerAccount: "user", State: intent.StateConfirmed}, - {IntentId: "i6", IntentType: intent.ReceivePaymentsPublicly, ReceivePaymentsPubliclyMetadata: &intent.ReceivePaymentsPubliclyMetadata{IsRemoteSend: true, Source: "a4", Quantity: 1, OriginalExchangeCurrency: currency.USD, OriginalExchangeRate: 1, OriginalNativeAmount: 1, UsdMarketValue: 1}, MintAccount: "mint", InitiatorOwnerAccount: "user", State: intent.StateRevoked}, - {IntentId: "i7", IntentType: intent.ReceivePaymentsPublicly, ReceivePaymentsPubliclyMetadata: &intent.ReceivePaymentsPubliclyMetadata{IsRemoteSend: true, Source: "a4", Quantity: 1, OriginalExchangeCurrency: currency.USD, OriginalExchangeRate: 1, OriginalNativeAmount: 1, UsdMarketValue: 1}, MintAccount: "mint", InitiatorOwnerAccount: "user", State: intent.StatePending}, + {IntentId: "i6", IntentType: intent.ReceivePaymentsPublicly, ReceivePaymentsPubliclyMetadata: &intent.ReceivePaymentsPubliclyMetadata{IsIndirectSend: true, Source: "a4", Quantity: 1, OriginalExchangeCurrency: currency.USD, OriginalExchangeRate: 1, OriginalNativeAmount: 1, UsdMarketValue: 1}, MintAccount: "mint", InitiatorOwnerAccount: "user", State: intent.StateRevoked}, + {IntentId: "i7", IntentType: intent.ReceivePaymentsPublicly, ReceivePaymentsPubliclyMetadata: &intent.ReceivePaymentsPubliclyMetadata{IsIndirectSend: true, Source: "a4", Quantity: 1, OriginalExchangeCurrency: currency.USD, OriginalExchangeRate: 1, OriginalNativeAmount: 1, UsdMarketValue: 1}, MintAccount: "mint", InitiatorOwnerAccount: "user", State: intent.StatePending}, } for _, record := range records { diff --git a/ocp/rpc/account/server_test.go b/ocp/rpc/account/server_test.go index 6ea5205..f86a7d3 100644 --- a/ocp/rpc/account/server_test.go +++ b/ocp/rpc/account/server_test.go @@ -462,8 +462,8 @@ func TestGetTokenAccountInfos_RemoteSendGiftCard_HappyPath(t *testing.T) { NativeAmount: 12.3, UsdMarketValue: 24.6, - IsWithdrawal: false, - IsRemoteSend: true, + IsWithdrawal: false, + IsIndirectSend: true, }, State: intent.StatePending, diff --git a/ocp/rpc/transaction/intent.go b/ocp/rpc/transaction/intent.go index 3d1b9b4..c9ccd3f 100644 --- a/ocp/rpc/transaction/intent.go +++ b/ocp/rpc/transaction/intent.go @@ -141,7 +141,7 @@ func (s *transactionServer) SubmitIntent(streamer transactionpb.Transaction_Subm initiatorOwnerAccount = submitActionsOwnerAccount case common.OwnerTypeRemoteSendGiftCard: // Remote send gift cards can only be the owner of an intent for a - // remote send public receive. In this instance, we need to inspect + // indirect send public receive. In this instance, we need to inspect // the destination account, which should be a user's primary // account. // @@ -149,7 +149,7 @@ func (s *transactionServer) SubmitIntent(streamer transactionpb.Transaction_Subm // method for intent handlers. switch typed := submitActionsReq.Metadata.Type.(type) { case *transactionpb.Metadata_ReceivePaymentsPublicly: - if typed.ReceivePaymentsPublicly.IsRemoteSend { + if typed.ReceivePaymentsPublicly.IsIndirectSend { switch typed := submitActionsReq.Actions[0].Type.(type) { case *transactionpb.Action_NoPrivacyWithdraw: accountInfoRecord, err := s.data.GetAccountInfoByTokenAddress(ctx, base58.Encode(typed.NoPrivacyWithdraw.Destination.Value)) @@ -853,9 +853,9 @@ func (s *transactionServer) GetIntentMetadata(ctx context.Context, req *transact Mint: mintAccount.ToProto(), }, }, - IsRemoteSend: intentRecord.SendPublicPaymentMetadata.IsRemoteSend, - IsWithdrawal: intentRecord.SendPublicPaymentMetadata.IsWithdrawal, - Mint: mintAccount.ToProto(), + IsIndirectSend: intentRecord.SendPublicPaymentMetadata.IsIndirectSend, + IsWithdrawal: intentRecord.SendPublicPaymentMetadata.IsWithdrawal, + Mint: mintAccount.ToProto(), }, }, } @@ -875,9 +875,9 @@ func (s *transactionServer) GetIntentMetadata(ctx context.Context, req *transact metadata = &transactionpb.Metadata{ Type: &transactionpb.Metadata_ReceivePaymentsPublicly{ ReceivePaymentsPublicly: &transactionpb.ReceivePaymentsPubliclyMetadata{ - Source: sourceAccount.ToProto(), - Quarks: intentRecord.ReceivePaymentsPubliclyMetadata.Quantity, - IsRemoteSend: intentRecord.ReceivePaymentsPubliclyMetadata.IsRemoteSend, + Source: sourceAccount.ToProto(), + Quarks: intentRecord.ReceivePaymentsPubliclyMetadata.Quantity, + IsIndirectSend: intentRecord.ReceivePaymentsPubliclyMetadata.IsIndirectSend, ExchangeData: &transactionpb.ExchangeData{ Currency: string(intentRecord.ReceivePaymentsPubliclyMetadata.OriginalExchangeCurrency), ExchangeRate: intentRecord.ReceivePaymentsPubliclyMetadata.OriginalExchangeRate, diff --git a/ocp/rpc/transaction/intent_handler.go b/ocp/rpc/transaction/intent_handler.go index 4c70f2f..de882d2 100644 --- a/ocp/rpc/transaction/intent_handler.go +++ b/ocp/rpc/transaction/intent_handler.go @@ -457,13 +457,13 @@ func (h *SendPublicPaymentIntentHandler) PopulateMetadata(ctx context.Context, i NativeAmount: nativeAmount, UsdMarketValue: usdMarketValue, - IsWithdrawal: typedProtoMetadata.IsWithdrawal, - IsRemoteSend: typedProtoMetadata.IsRemoteSend, + IsWithdrawal: typedProtoMetadata.IsWithdrawal, + IsIndirectSend: typedProtoMetadata.IsIndirectSend, } if destinationAccountInfo != nil { intentRecord.SendPublicPaymentMetadata.DestinationOwnerAccount = destinationAccountInfo.OwnerAccount - } else if !typedProtoMetadata.IsWithdrawal && !typedProtoMetadata.IsRemoteSend && typedProtoMetadata.DestinationOwner != nil { + } else if !typedProtoMetadata.IsWithdrawal && !typedProtoMetadata.IsIndirectSend && typedProtoMetadata.DestinationOwner != nil { // Direct primary-to-primary payment where the destination doesn't have // a primary account for the intent's mint yet. If the destination owner // is an existing OCP user, we'll synthesize an OpenAccounts intent for @@ -719,18 +719,18 @@ func (h *SendPublicPaymentIntentHandler) validateActions( // Part 1: High-level action validation based on intent metadata // - if metadata.IsRemoteSend && metadata.IsWithdrawal { - return NewIntentValidationError("remote send cannot be a withdraw") + if metadata.IsIndirectSend && metadata.IsWithdrawal { + return NewIntentValidationError("indirect send cannot be a withdraw") } - if !metadata.IsWithdrawal && !metadata.IsRemoteSend && len(actions) != 1 { + if !metadata.IsWithdrawal && !metadata.IsIndirectSend && len(actions) != 1 { return NewIntentValidationError("expected 1 action for payment") } if metadata.IsWithdrawal && len(actions) != 1 && len(actions) != 2 { return NewIntentValidationError("expected 1 or 2 actions for withdrawal") } - if metadata.IsRemoteSend && len(actions) != 3 { - return NewIntentValidationError("expected 3 actions for remote send") + if metadata.IsIndirectSend && len(actions) != 3 { + return NewIntentValidationError("expected 3 actions for indirect send") } // @@ -756,8 +756,8 @@ func (h *SendPublicPaymentIntentHandler) validateActions( } if h.cachedDestinationAccountInfoRecord != nil { - // Remote sends must be to a brand new gift card account - if metadata.IsRemoteSend { + // Indirect sends must be to a brand new gift card account + if metadata.IsIndirectSend { return NewIntentValidationError("destination must be a brand new gift card account") } @@ -802,7 +802,7 @@ func (h *SendPublicPaymentIntentHandler) validateActions( err = func() error { // Destination is to a brand new gift card that will be created as part of this // intent - if metadata.IsRemoteSend { + if metadata.IsIndirectSend { return nil } @@ -943,7 +943,7 @@ func (h *SendPublicPaymentIntentHandler) validateActions( // Part 6: Validate open and closed accounts - if metadata.IsRemoteSend { + if metadata.IsIndirectSend { if len(simResult.GetOpenedAccounts()) != 1 { return NewIntentValidationError("expected 1 account opened") } @@ -1049,7 +1049,7 @@ func (h *ReceivePaymentsPubliclyIntentHandler) PopulateMetadata(ctx context.Cont } // This is an optimization for payment history. Original fiat amounts are not - // easily linked due to the nature of gift cards and the remote send flow. We + // easily linked due to the nature of gift cards and the indirect send flow. We // fetch this metadata up front so we don't need to do it every time in history. giftCardIssuedIntentRecord, err := h.data.GetOriginalGiftCardIssuedIntent(ctx, giftCardVault.PublicKey().ToBase58()) if err == intent.ErrIntentNotFound { @@ -1065,7 +1065,7 @@ func (h *ReceivePaymentsPubliclyIntentHandler) PopulateMetadata(ctx context.Cont Source: giftCardVault.PublicKey().ToBase58(), Quantity: typedProtoMetadata.Quarks, - IsRemoteSend: typedProtoMetadata.IsRemoteSend, + IsIndirectSend: typedProtoMetadata.IsIndirectSend, IsReturned: false, IsIssuerVoidingGiftCard: false, @@ -1112,8 +1112,8 @@ func (h *ReceivePaymentsPubliclyIntentHandler) AllowCreation(ctx context.Context return errors.New("unexpected metadata proto message") } - if !typedMetadata.IsRemoteSend { - return NewIntentValidationError("only remote send is supported") + if !typedMetadata.IsIndirectSend { + return NewIntentValidationError("only indirect send is supported") } if typedMetadata.ExchangeData != nil { @@ -1736,7 +1736,7 @@ func validateMoneyMovementActionUserAccounts( } case *transactionpb.Action_NoPrivacyWithdraw: // No privacy withdraws are used in two ways depending on the intent: - // 1. As an auto-return action back to the payer's primary account in a public payment intent for remote send + // 1. As an auto-return action back to the payer's primary account in a public payment intent for indirect send // 2. As a receiver of funds to the primary account in a public receive mint, err = common.GetBackwardsCompatMint(typedAction.NoPrivacyWithdraw.Mint) diff --git a/ocp/worker/account/gift_card.go b/ocp/worker/account/gift_card.go index 038d839..70962fc 100644 --- a/ocp/worker/account/gift_card.go +++ b/ocp/worker/account/gift_card.go @@ -323,7 +323,7 @@ func insertAutoReturnIntentRecord(ctx context.Context, data ocp_data.Provider, g Source: giftCardIssuedIntent.SendPublicPaymentMetadata.DestinationTokenAccount, Quantity: giftCardIssuedIntent.SendPublicPaymentMetadata.Quantity, - IsRemoteSend: true, + IsIndirectSend: true, IsIssuerVoidingGiftCard: isVoidedByUser, IsReturned: !isVoidedByUser, diff --git a/ocp/worker/account/testutil.go b/ocp/worker/account/testutil.go index d8fe628..ece8876 100644 --- a/ocp/worker/account/testutil.go +++ b/ocp/worker/account/testutil.go @@ -99,7 +99,7 @@ func (e *testEnv) generateRandomGiftCard(t *testing.T, creationTs time.Time) *te NativeAmount: 12345, UsdMarketValue: 1000.0, - IsRemoteSend: true, + IsIndirectSend: true, }, State: intent.StatePending, @@ -210,7 +210,7 @@ func (e *testEnv) assertGiftCardAutoReturned(t *testing.T, giftCard *testGiftCar require.NotNil(t, historyRecord.ReceivePaymentsPubliclyMetadata) assert.Equal(t, giftCard.accountInfoRecord.TokenAccount, historyRecord.ReceivePaymentsPubliclyMetadata.Source) assert.Equal(t, giftCard.issuedIntentRecord.SendPublicPaymentMetadata.Quantity, historyRecord.ReceivePaymentsPubliclyMetadata.Quantity) - assert.True(t, historyRecord.ReceivePaymentsPubliclyMetadata.IsRemoteSend) + assert.True(t, historyRecord.ReceivePaymentsPubliclyMetadata.IsIndirectSend) assert.True(t, historyRecord.ReceivePaymentsPubliclyMetadata.IsReturned) assert.Equal(t, giftCard.issuedIntentRecord.SendPublicPaymentMetadata.ExchangeCurrency, historyRecord.ReceivePaymentsPubliclyMetadata.OriginalExchangeCurrency) assert.Equal(t, giftCard.issuedIntentRecord.SendPublicPaymentMetadata.ExchangeRate, historyRecord.ReceivePaymentsPubliclyMetadata.OriginalExchangeRate) diff --git a/ocp/worker/sequencer/intent_handler.go b/ocp/worker/sequencer/intent_handler.go index 70c6b16..84ca1ca 100644 --- a/ocp/worker/sequencer/intent_handler.go +++ b/ocp/worker/sequencer/intent_handler.go @@ -73,7 +73,7 @@ func (h *SendPublicPaymentIntentHandler) OnActionUpdated(ctx context.Context, in // Do not include the auto-return action, which is a different server-side // initiated intent using the final action here. // - // todo: Assumes > 2 case is just remote send, but saves a DB call + // todo: Assumes > 2 case is just indirect send, but saves a DB call actionRecordsToCheck = actionRecordsToCheck[:len(actionRecordsToCheck)-1] }