Skip to content

Commit 5677192

Browse files
authored
Track USDC swap account (#41)
* Update account data packages to include mint * Update common data packages to include mint * Update account server to pull mint from DB records * Update transaction service to handle mint and fix tests * Fix tests everywhere else * Make external deposit store interface more generic * Pull in v1.8.4 APIs * Support swap account in account info store * Update core RPCs and utilities for swap account integration * Refactor Geyser external deposit handler to handle USDC swap accounts * Define chat messages used in manual USDC deposit swap flow * Integrate USDC being converted chat message into Swap RPC * Integrate USDC deposited chat message into Geyser * Detect if Kin external deposit is a Code swap, and message accordingly * Implement LinkAdditionalAccounts RPC in Account service * Update Swap RPC * Consistency in how common mints are constructed * Update TestIsCodeAccount_HappyPath to incorporate a swap account * Update CalculateFromBlockchain comments
1 parent 3ee4fc2 commit 5677192

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+1611
-633
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ require (
66
firebase.google.com/go/v4 v4.8.0
77
github.com/aws/aws-sdk-go-v2 v0.17.0
88
github.com/bits-and-blooms/bloom/v3 v3.1.0
9-
github.com/code-payments/code-protobuf-api v1.8.3
9+
github.com/code-payments/code-protobuf-api v1.9.0
1010
github.com/emirpasic/gods v1.12.0
1111
github.com/envoyproxy/protoc-gen-validate v0.1.0
1212
github.com/golang-jwt/jwt/v5 v5.0.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWH
108108
github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
109109
github.com/cockroachdb/apd v1.1.0 h1:3LFP3629v+1aKXU5Q37mxmRxX/pIu1nijXydLShEq5I=
110110
github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ=
111-
github.com/code-payments/code-protobuf-api v1.8.3 h1:BEGKUvHZu5TvfsX4zhzSppuvZGlHH/DbvVBS0/oB18M=
112-
github.com/code-payments/code-protobuf-api v1.8.3/go.mod h1:pHQm75vydD6Cm2qHAzlimW6drysm489Z4tVxC2zHSsU=
111+
github.com/code-payments/code-protobuf-api v1.9.0 h1:V8v/yAlZnVtcqh1LZ+zBIYC+Z04kOcCr8GRvwka69C0=
112+
github.com/code-payments/code-protobuf-api v1.9.0/go.mod h1:pHQm75vydD6Cm2qHAzlimW6drysm489Z4tVxC2zHSsU=
113113
github.com/containerd/continuity v0.0.0-20190827140505-75bee3e2ccb6 h1:NmTXa/uVnDyp0TY5MKi197+3HWcnYWfnHGyaFthlnGw=
114114
github.com/containerd/continuity v0.0.0-20190827140505-75bee3e2ccb6/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y=
115115
github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=

pkg/code/async/account/testutil.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,19 @@ import (
1111

1212
commonpb "github.com/code-payments/code-protobuf-api/generated/go/common/v1"
1313

14-
currency_lib "github.com/code-payments/code-server/pkg/currency"
15-
"github.com/code-payments/code-server/pkg/kin"
16-
"github.com/code-payments/code-server/pkg/pointer"
17-
memory_push "github.com/code-payments/code-server/pkg/push/memory"
18-
timelock_token "github.com/code-payments/code-server/pkg/solana/timelock/v1"
19-
"github.com/code-payments/code-server/pkg/testutil"
2014
"github.com/code-payments/code-server/pkg/code/common"
2115
code_data "github.com/code-payments/code-server/pkg/code/data"
2216
"github.com/code-payments/code-server/pkg/code/data/account"
2317
"github.com/code-payments/code-server/pkg/code/data/action"
2418
"github.com/code-payments/code-server/pkg/code/data/currency"
2519
"github.com/code-payments/code-server/pkg/code/data/fulfillment"
2620
"github.com/code-payments/code-server/pkg/code/data/intent"
21+
currency_lib "github.com/code-payments/code-server/pkg/currency"
22+
"github.com/code-payments/code-server/pkg/kin"
23+
"github.com/code-payments/code-server/pkg/pointer"
24+
memory_push "github.com/code-payments/code-server/pkg/push/memory"
25+
timelock_token "github.com/code-payments/code-server/pkg/solana/timelock/v1"
26+
"github.com/code-payments/code-server/pkg/testutil"
2727
)
2828

2929
type testEnv struct {
@@ -63,13 +63,14 @@ func setup(t *testing.T) *testEnv {
6363
func (e *testEnv) generateRandomGiftCard(t *testing.T, creationTs time.Time) *testGiftCard {
6464
authority := testutil.NewRandomAccount(t)
6565

66-
timelockAccounts, err := authority.GetTimelockAccounts(timelock_token.DataVersion1)
66+
timelockAccounts, err := authority.GetTimelockAccounts(timelock_token.DataVersion1, common.KinMintAccount)
6767
require.NoError(t, err)
6868

6969
accountInfoRecord := &account.Record{
7070
OwnerAccount: authority.PublicKey().ToBase58(),
7171
AuthorityAccount: authority.PublicKey().ToBase58(),
7272
TokenAccount: timelockAccounts.Vault.PublicKey().ToBase58(),
73+
MintAccount: timelockAccounts.Mint.PublicKey().ToBase58(),
7374

7475
AccountType: commonpb.AccountType_REMOTE_SEND_GIFT_CARD,
7576

pkg/code/async/commitment/testutil.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,6 @@ import (
1414
"github.com/stretchr/testify/assert"
1515
"github.com/stretchr/testify/require"
1616

17-
"github.com/code-payments/code-server/pkg/currency"
18-
"github.com/code-payments/code-server/pkg/kin"
19-
"github.com/code-payments/code-server/pkg/pointer"
20-
"github.com/code-payments/code-server/pkg/solana"
21-
splitter_token "github.com/code-payments/code-server/pkg/solana/splitter"
22-
"github.com/code-payments/code-server/pkg/solana/system"
23-
timelock_token_v1 "github.com/code-payments/code-server/pkg/solana/timelock/v1"
24-
"github.com/code-payments/code-server/pkg/testutil"
2517
"github.com/code-payments/code-server/pkg/code/common"
2618
code_data "github.com/code-payments/code-server/pkg/code/data"
2719
"github.com/code-payments/code-server/pkg/code/data/action"
@@ -32,6 +24,14 @@ import (
3224
"github.com/code-payments/code-server/pkg/code/data/nonce"
3325
"github.com/code-payments/code-server/pkg/code/data/treasury"
3426
"github.com/code-payments/code-server/pkg/code/data/vault"
27+
"github.com/code-payments/code-server/pkg/currency"
28+
"github.com/code-payments/code-server/pkg/kin"
29+
"github.com/code-payments/code-server/pkg/pointer"
30+
"github.com/code-payments/code-server/pkg/solana"
31+
splitter_token "github.com/code-payments/code-server/pkg/solana/splitter"
32+
"github.com/code-payments/code-server/pkg/solana/system"
33+
timelock_token_v1 "github.com/code-payments/code-server/pkg/solana/timelock/v1"
34+
"github.com/code-payments/code-server/pkg/testutil"
3535
)
3636

3737
type testEnv struct {
@@ -132,7 +132,7 @@ func (e testEnv) simulateCommitment(t *testing.T, recentRoot string, state commi
132132
require.NoError(t, e.data.SaveCommitment(e.ctx, commitmentRecord))
133133

134134
owner := testutil.NewRandomAccount(t)
135-
timelockAccounts, err := owner.GetTimelockAccounts(timelock_token_v1.DataVersion1)
135+
timelockAccounts, err := owner.GetTimelockAccounts(timelock_token_v1.DataVersion1, common.KinMintAccount)
136136
require.NoError(t, err)
137137

138138
intentRecord := &intent.Record{

0 commit comments

Comments
 (0)