Skip to content

Commit 301634e

Browse files
authored
Setup Jeffy (#45)
1 parent d16c73e commit 301634e

5 files changed

Lines changed: 31 additions & 29 deletions

File tree

ocp/common/vm.go

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -33,27 +33,25 @@ func GetVmConfigForMint(ctx context.Context, data ocp_data.Provider, mint *Accou
3333
Omnibus: CoreMintVmOmnibusAccount,
3434
Mint: CoreMintAccount,
3535
}, nil
36-
/*
37-
case jeffyMintAccount.PublicKey().ToBase58():
38-
if jeffyAuthority.PrivateKey() == nil {
39-
vaultRecord, err := data.GetKey(ctx, jeffyAuthority.PublicKey().ToBase58())
40-
if err != nil {
41-
return nil, err
42-
}
43-
44-
jeffyAuthority, err = NewAccountFromPrivateKeyString(vaultRecord.PrivateKey)
45-
if err != nil {
46-
return nil, err
47-
}
48-
}
49-
50-
return &VmConfig{
51-
Authority: jeffyAuthority,
52-
Vm: jeffyVmAccount,
53-
Omnibus: jeffyVmOmnibusAccount,
54-
Mint: mint,
55-
}, nil
56-
*/
36+
case jeffyMintAccount.PublicKey().ToBase58():
37+
if jeffyAuthority.PrivateKey() == nil {
38+
vaultRecord, err := data.GetKey(ctx, jeffyAuthority.PublicKey().ToBase58())
39+
if err != nil {
40+
return nil, err
41+
}
42+
43+
jeffyAuthority, err = NewAccountFromPrivateKeyString(vaultRecord.PrivateKey)
44+
if err != nil {
45+
return nil, err
46+
}
47+
}
48+
49+
return &VmConfig{
50+
Authority: jeffyAuthority,
51+
Vm: jeffyVmAccount,
52+
Omnibus: jeffyVmOmnibusAccount,
53+
Mint: mint,
54+
}, nil
5755
default:
5856
return nil, ErrUnsupportedMint
5957
}

ocp/config/config.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,11 @@ const (
2323
CoreMintVmAccountPublicKey = "JACkaKsm2Rd6TNJwH4UB7G6tHrWUATJPTgNNnRVsg4ip"
2424
CoreMintVmOmnibusPublicKey = "D8oUTXRvarxhx9cjYdFJqWAVj2rmzry58bS6JSTiQsv5"
2525

26-
// todo: replace with new Jeffy
2726
// todo: DB store to track VM per mint
28-
JeffyMintPublicKey = "52MNGpgvydSwCtC2H4qeiZXZ1TxEuRVCRGa8LAfk2kSj"
27+
JeffyMintPublicKey = "54ggcQ23uen5b9QXMAns99MQNTKn7iyzq4wvCW6e8r25"
2928
JeffyAuthorityPublicKey = "jfy1btcfsjSn2WCqLVaxiEjp4zgmemGyRsdCPbPwnZV"
30-
JeffyVmAccountPublicKey = "Bii3UFB9DzPq6UxgewF5iv9h1Gi8ZnP6mr7PtocHGNta"
31-
JeffyVmOmnibusPublicKey = "CQ5jni8XTXEcMFXS1ytNyTVbJBZHtHCzEtjBPowB3MLD"
29+
JeffyVmAccountPublicKey = "8rwgUXsLSq1Pn51UJs4NGVA1cTkemwBgKyWPfFYgnm3B"
30+
JeffyVmOmnibusPublicKey = "9XiqBPYSG2cBwpb8MqJeuFmLaQaAAr6gwikyBrPZDQ8R"
3231
)
3332

3433
var (

ocp/worker/currency/reserve.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88

99
"github.com/code-payments/ocp-server/metrics"
1010
"github.com/code-payments/ocp-server/ocp/common"
11+
"github.com/code-payments/ocp-server/ocp/config"
1112
ocp_data "github.com/code-payments/ocp-server/ocp/data"
1213
"github.com/code-payments/ocp-server/ocp/data/currency"
1314
"github.com/code-payments/ocp-server/ocp/worker"
@@ -34,7 +35,7 @@ func (p *reserveRuntime) Start(runtimeCtx context.Context, interval time.Duratio
3435
for {
3536
_, err := retry.Retry(
3637
func() error {
37-
p.log.Debug("updating exchange rates")
38+
p.log.Debug("updating reserves")
3839

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

7879
var tokenAccount token.Account
7980
ai, err := p.data.GetBlockchainAccountInfo(ctx, jeffyVaultAccount.PublicKey().ToBase58(), solana.CommitmentFinalized)

ocp/worker/geyser/handler.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"github.com/pkg/errors"
99

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

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

8687
switch mintAccount.PublicKey().ToBase58() {
8788

88-
case common.CoreMintAccount.PublicKey().ToBase58():
89+
// todo: Don't hardcode Jeffy and other Flipcash currencies
90+
case common.CoreMintAccount.PublicKey().ToBase58(), config.JeffyMintPublicKey:
8991
// Not an ATA, so filter it out. It cannot be a VM deposit ATA
9092
if bytes.Equal(tokenAccount.PublicKey().ToBytes(), ownerAccount.PublicKey().ToBytes()) {
9193
return nil

ocp/worker/nonce/runtime.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
indexerpb "github.com/code-payments/code-vm-indexer/generated/indexer/v1"
1212

1313
"github.com/code-payments/ocp-server/ocp/common"
14+
"github.com/code-payments/ocp-server/ocp/config"
1415
ocp_data "github.com/code-payments/ocp-server/ocp/data"
1516
"github.com/code-payments/ocp-server/ocp/data/nonce"
1617
"github.com/code-payments/ocp-server/ocp/worker"
@@ -69,6 +70,7 @@ func (p *runtime) Start(ctx context.Context, interval time.Duration) error {
6970
// todo: Dynamically detect VMs
7071
for _, vm := range []string{
7172
common.CoreMintVmAccount.PublicKey().ToBase58(),
73+
config.JeffyVmAccountPublicKey,
7274
} {
7375
for _, state := range []nonce.State{
7476
nonce.StateReleased,

0 commit comments

Comments
 (0)