Skip to content
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
8 changes: 4 additions & 4 deletions pkg/internal/unit21/transaction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,12 @@ func mockTransactionRows(mock sqlmock.Sqlmock, transaction model.Transaction, us
AddRow(transaction.DestinationTxLegId, time.Now(), "1", transaction.TransactionAmount, assetId2, userId, instrumentId2)
mock.ExpectQuery("SELECT * FROM tx_leg WHERE id = $1 AND deleted_at IS NULL").WithArgs(transaction.DestinationTxLegId).WillReturnRows(mockedTxLegRow2)

mockedAssetRow1 := sqlmock.NewRows([]string{"id", "name", "description", "decimals", "is_crypto", "network_id", "value_oracle"}).
AddRow(assetId1, "USD", "fiat USD", 6, false, transaction.NetworkId, "self")
mockedAssetRow1 := sqlmock.NewRows([]string{"id", "name", "description", "decimals", "is_crypto", "value_oracle"}).
AddRow(assetId1, "USD", "fiat USD", 6, false, "self")
mock.ExpectQuery("SELECT * FROM asset WHERE id = $1 AND deleted_at IS NULL").WithArgs(assetId1).WillReturnRows(mockedAssetRow1)

mockedAssetRow2 := sqlmock.NewRows([]string{"id", "name", "description", "decimals", "is_crypto", "network_id", "value_oracle"}).
AddRow(assetId2, "Noose The Goose", "Noose the Goose NFT", 0, true, transaction.NetworkId, "joepegs.com")
mockedAssetRow2 := sqlmock.NewRows([]string{"id", "name", "description", "decimals", "is_crypto", "value_oracle"}).
AddRow(assetId2, "Noose The Goose", "Noose the Goose NFT", 0, true, "joepegs.com")
mock.ExpectQuery("SELECT * FROM asset WHERE id = $1 AND deleted_at IS NULL").WithArgs(assetId2).WillReturnRows(mockedAssetRow2)

mockedDeviceRow := sqlmock.NewRows([]string{"id", "type", "description", "fingerprint", "ip_addresses", "user_id"}).
Expand Down
1 change: 0 additions & 1 deletion pkg/model/entity.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ type Asset struct {
Description string `json:"description" db:"description"`
Decimals uint64 `json:"decimals" db:"decimals"`
IsCrypto bool `json:"isCrypto" db:"is_crypto"`
NetworkId sql.NullString `json:"networkId" db:"network_id"`
ValueOracle sql.NullString `json:"valueOracle" db:"value_oracle"`
ValueOracle2 sql.NullString `json:"valueOracle2" db:"value_oracle_2"`
}
Expand Down
12 changes: 10 additions & 2 deletions pkg/repository/asset.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,16 @@ func (a asset[T]) Create(ctx context.Context, insert model.Asset) (model.Asset,
m := model.Asset{}

query, args, err := a.Named(`
INSERT INTO asset (name, description, decimals, is_crypto, network_id, value_oracle, value_oracle_2)
VALUES(:name, :description, :decimals, :is_crypto, :network_id, :value_oracle, :value_oracle_2) RETURNING *`, insert)
WITH insert_asset AS (
INSERT INTO asset (name, description, decimals, is_crypto, value_oracle, value_oracle_2)
VALUES(:name, :description, :decimals, :is_crypto, :value_oracle, :value_oracle_2)
ON CONFLICT (name) DO NOTHING
RETURNING *
)
INSERT INTO asset_to_network (asset_id, network_id)
VALUES(insert_asset.id, :network_id)
ON CONFLICT (asset_id, network_id) DO NOTHING
`, insert)

if err != nil {
return m, libcommon.StringError(err)
Expand Down
2 changes: 1 addition & 1 deletion pkg/service/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,7 @@ func (t transaction) addWalletInstrumentIdIfNew(ctx context.Context, address str
}

// Create a new instrument
instrument = model.Instrument{Type: "crypto wallet", Status: "external", Network: "ethereum", PublicKey: address, UserId: id} // No locationId or userId because this wallet was not registered with the user and is some other recipient
instrument = model.Instrument{Type: "crypto wallet", Status: "external", Network: "EVM", PublicKey: address, UserId: id} // No locationId or userId because this wallet was not registered with the user and is some other recipient
instrument, err = t.repos.Instrument.Create(ctx, instrument)
if err != nil {
return "", libcommon.StringError(err)
Expand Down