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
40 changes: 19 additions & 21 deletions ocp/common/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,27 +33,25 @@ func GetVmConfigForMint(ctx context.Context, data ocp_data.Provider, mint *Accou
Omnibus: CoreMintVmOmnibusAccount,
Mint: CoreMintAccount,
}, nil
/*
case jeffyMintAccount.PublicKey().ToBase58():
if jeffyAuthority.PrivateKey() == nil {
vaultRecord, err := data.GetKey(ctx, jeffyAuthority.PublicKey().ToBase58())
if err != nil {
return nil, err
}

jeffyAuthority, err = NewAccountFromPrivateKeyString(vaultRecord.PrivateKey)
if err != nil {
return nil, err
}
}

return &VmConfig{
Authority: jeffyAuthority,
Vm: jeffyVmAccount,
Omnibus: jeffyVmOmnibusAccount,
Mint: mint,
}, nil
*/
case jeffyMintAccount.PublicKey().ToBase58():
if jeffyAuthority.PrivateKey() == nil {
vaultRecord, err := data.GetKey(ctx, jeffyAuthority.PublicKey().ToBase58())
if err != nil {
return nil, err
}

jeffyAuthority, err = NewAccountFromPrivateKeyString(vaultRecord.PrivateKey)
if err != nil {
return nil, err
}
}

return &VmConfig{
Authority: jeffyAuthority,
Vm: jeffyVmAccount,
Omnibus: jeffyVmOmnibusAccount,
Mint: mint,
}, nil
default:
return nil, ErrUnsupportedMint
}
Expand Down
7 changes: 3 additions & 4 deletions ocp/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,11 @@ const (
CoreMintVmAccountPublicKey = "JACkaKsm2Rd6TNJwH4UB7G6tHrWUATJPTgNNnRVsg4ip"
CoreMintVmOmnibusPublicKey = "D8oUTXRvarxhx9cjYdFJqWAVj2rmzry58bS6JSTiQsv5"

// todo: replace with new Jeffy
// todo: DB store to track VM per mint
JeffyMintPublicKey = "52MNGpgvydSwCtC2H4qeiZXZ1TxEuRVCRGa8LAfk2kSj"
JeffyMintPublicKey = "54ggcQ23uen5b9QXMAns99MQNTKn7iyzq4wvCW6e8r25"
JeffyAuthorityPublicKey = "jfy1btcfsjSn2WCqLVaxiEjp4zgmemGyRsdCPbPwnZV"
JeffyVmAccountPublicKey = "Bii3UFB9DzPq6UxgewF5iv9h1Gi8ZnP6mr7PtocHGNta"
JeffyVmOmnibusPublicKey = "CQ5jni8XTXEcMFXS1ytNyTVbJBZHtHCzEtjBPowB3MLD"
JeffyVmAccountPublicKey = "8rwgUXsLSq1Pn51UJs4NGVA1cTkemwBgKyWPfFYgnm3B"
JeffyVmOmnibusPublicKey = "9XiqBPYSG2cBwpb8MqJeuFmLaQaAAr6gwikyBrPZDQ8R"
)

var (
Expand Down
7 changes: 4 additions & 3 deletions ocp/worker/currency/reserve.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

"github.com/code-payments/ocp-server/metrics"
"github.com/code-payments/ocp-server/ocp/common"
"github.com/code-payments/ocp-server/ocp/config"
ocp_data "github.com/code-payments/ocp-server/ocp/data"
"github.com/code-payments/ocp-server/ocp/data/currency"
"github.com/code-payments/ocp-server/ocp/worker"
Expand All @@ -34,7 +35,7 @@ func (p *reserveRuntime) Start(runtimeCtx context.Context, interval time.Duratio
for {
_, err := retry.Retry(
func() error {
p.log.Debug("updating exchange rates")
p.log.Debug("updating reserves")

provider := runtimeCtx.Value(metrics.ProviderContextKey).(metrics.Provider)
trace := provider.StartTrace("currency_reserve_runtime")
Expand Down Expand Up @@ -72,8 +73,8 @@ func (p *reserveRuntime) Start(runtimeCtx context.Context, interval time.Duratio
// todo: Don't hardcode Jeffy and other Flipcash currencies
func (p *reserveRuntime) UpdateAllLaunchpadCurrencyReserves(ctx context.Context) error {
err1 := func() error {
jeffyMintAccount, _ := common.NewAccountFromPublicKeyString("todo")
jeffyVaultAccount, _ := common.NewAccountFromPublicKeyString("todo")
jeffyMintAccount, _ := common.NewAccountFromPublicKeyString(config.JeffyMintPublicKey)
jeffyVaultAccount, _ := common.NewAccountFromPublicKeyString("BMYftxDcbLDTzRCkLmQ9amwNgqsZ74A1wsd1gURum3Ep")

var tokenAccount token.Account
ai, err := p.data.GetBlockchainAccountInfo(ctx, jeffyVaultAccount.PublicKey().ToBase58(), solana.CommitmentFinalized)
Expand Down
4 changes: 3 additions & 1 deletion ocp/worker/geyser/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/pkg/errors"

indexerpb "github.com/code-payments/code-vm-indexer/generated/indexer/v1"
"github.com/code-payments/ocp-server/ocp/config"
geyserpb "github.com/code-payments/ocp-server/ocp/worker/geyser/api/gen"

"github.com/code-payments/ocp-server/ocp/common"
Expand Down Expand Up @@ -85,7 +86,8 @@ func (h *TokenProgramAccountHandler) Handle(ctx context.Context, update *geyserp

switch mintAccount.PublicKey().ToBase58() {

case common.CoreMintAccount.PublicKey().ToBase58():
// todo: Don't hardcode Jeffy and other Flipcash currencies
case common.CoreMintAccount.PublicKey().ToBase58(), config.JeffyMintPublicKey:
// Not an ATA, so filter it out. It cannot be a VM deposit ATA
if bytes.Equal(tokenAccount.PublicKey().ToBytes(), ownerAccount.PublicKey().ToBytes()) {
return nil
Expand Down
2 changes: 2 additions & 0 deletions ocp/worker/nonce/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
indexerpb "github.com/code-payments/code-vm-indexer/generated/indexer/v1"

"github.com/code-payments/ocp-server/ocp/common"
"github.com/code-payments/ocp-server/ocp/config"
ocp_data "github.com/code-payments/ocp-server/ocp/data"
"github.com/code-payments/ocp-server/ocp/data/nonce"
"github.com/code-payments/ocp-server/ocp/worker"
Expand Down Expand Up @@ -69,6 +70,7 @@ func (p *runtime) Start(ctx context.Context, interval time.Duration) error {
// todo: Dynamically detect VMs
for _, vm := range []string{
common.CoreMintVmAccount.PublicKey().ToBase58(),
config.JeffyVmAccountPublicKey,
} {
for _, state := range []nonce.State{
nonce.StateReleased,
Expand Down
Loading