Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cust linking xyzabc 3 #1886

Merged
merged 4 commits into from
Jul 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libs/datastore/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ var (
}
dbs = map[string]*sqlx.DB{}
// CurrentMigrationVersion holds the default migration version
CurrentMigrationVersion = uint(60)
CurrentMigrationVersion = uint(61)
// MigrationTracks holds the migration version for a given track (eyeshade, promotion, wallet)
MigrationTracks = map[string]uint{
"eyeshade": 20,
Expand Down
5 changes: 5 additions & 0 deletions migrations/0061_wallet_custodian_check_custodian.down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ALTER TABLE wallet_custodian
DROP CONSTRAINT IF EXISTS check_custodian,
ADD CONSTRAINT check_custodian CHECK (
custodian IN ('brave', 'uphold', 'bitflyer', 'gemini')
);
5 changes: 5 additions & 0 deletions migrations/0061_wallet_custodian_check_custodian.up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ALTER TABLE wallet_custodian
DROP CONSTRAINT IF EXISTS check_custodian,
ADD CONSTRAINT check_custodian CHECK (
custodian IN ('brave', 'uphold', 'bitflyer', 'gemini', 'xyzabc')
);
2 changes: 1 addition & 1 deletion services/wallet/controllers_v3_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,7 @@ func TestLinkXyzAbcWalletV3(t *testing.T) {
"POST",
fmt.Sprintf("/v3/wallet/xyzabc/%s/claim", idFrom),
bytes.NewBufferString(fmt.Sprintf(
`{"linkingInfo": "%s"}`,
`{"linking_info": "%s"}`,
linkingInfo,
)),
)
Expand Down
6 changes: 3 additions & 3 deletions services/wallet/datastore.go
Original file line number Diff line number Diff line change
Expand Up @@ -973,7 +973,7 @@ func (pg *Postgres) ConnectCustodialWallet(ctx context.Context, cl *CustodianLin
) values (
$1, $2, $3
)
on conflict (wallet_id, custodian, linking_id)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My editor is set up to remove trailing spaces, so here and below in this file it did just that.

on conflict (wallet_id, custodian, linking_id)
do update set updated_at=now(), disconnected_at=null, unlinked_at=null, linked_at=now()
returning *
`
Expand Down Expand Up @@ -1019,7 +1019,7 @@ func (pg *Postgres) ConnectCustodialWallet(ctx context.Context, cl *CustodianLin

// InsertVerifiedWalletOutboxTx inserts a verifiedWalletOutbox for processing.
func (pg *Postgres) InsertVerifiedWalletOutboxTx(ctx context.Context, tx *sqlx.Tx, walletID uuid.UUID, verifiedWallet bool) error {
_, err := tx.ExecContext(ctx, `insert into verified_wallet_outbox(payment_id, verified_wallet)
_, err := tx.ExecContext(ctx, `insert into verified_wallet_outbox(payment_id, verified_wallet)
values ($1, $2)`, walletID, verifiedWallet)
if err != nil {
return fmt.Errorf("error inserting values into vefified wallet outbox: %w", err)
Expand All @@ -1041,7 +1041,7 @@ func (pg *Postgres) SendVerifiedWalletOutbox(ctx context.Context, client reputat
}
defer rollback()

err = tx.Get(&vw, `select id, payment_id, verified_wallet from verified_wallet_outbox
err = tx.Get(&vw, `select id, payment_id, verified_wallet from verified_wallet_outbox
order by created_at asc for update skip locked limit 1`)
if err != nil {
return false, fmt.Errorf("error get verified wallet: %w", err)
Expand Down
2 changes: 1 addition & 1 deletion services/wallet/inputs.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ func (lbdar *LinkBraveDepositAccountRequest) HandleErrors(err error) *handlers.A

// XyzAbcLinkingRequest holds info needed to link xyzabc account.
type XyzAbcLinkingRequest struct {
VerificationToken string `json:"linkingInfo"`
VerificationToken string `json:"linking_info"`
}

// Validate implements DecodeValidate interface.
Expand Down
5 changes: 2 additions & 3 deletions services/wallet/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -456,8 +456,7 @@ func (service *Service) LinkXyzAbcWallet(ctx context.Context, walletID uuid.UUID
providerLinkingID := uuid.NewV5(ClaimNamespace, accountID)

// tx.Destination will be stored as UserDepositDestination in the wallet info upon linking.
// FIXME - correct country
if err := service.Datastore.LinkWallet(ctx, walletID.String(), depositID, providerLinkingID, nil, "xyzabc", "US"); err != nil {
if err := service.Datastore.LinkWallet(ctx, walletID.String(), depositID, providerLinkingID, nil, "xyzabc", "IN"); err != nil {
if errors.Is(err, ErrUnusualActivity) {
return handlers.WrapError(err, "unable to link - unusual activity", http.StatusBadRequest)
}
Expand All @@ -471,7 +470,7 @@ func (service *Service) LinkXyzAbcWallet(ctx context.Context, walletID uuid.UUID
status = http.StatusConflict
}

return handlers.WrapError(err, "unable to link gemini wallets", status)
return handlers.WrapError(err, "unable to link xyzabc wallets", status)
}

return nil
Expand Down
Loading