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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
filippo.io/edwards25519 v1.1.0
github.com/aws/aws-sdk-go-v2 v0.17.0
github.com/code-payments/code-vm-indexer v1.2.0
github.com/code-payments/ocp-protobuf-api v0.12.0
github.com/code-payments/ocp-protobuf-api v0.13.0
github.com/emirpasic/gods v1.12.0
github.com/envoyproxy/protoc-gen-validate v1.2.1
github.com/golang/protobuf v1.5.4
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ github.com/cockroachdb/apd v1.1.0 h1:3LFP3629v+1aKXU5Q37mxmRxX/pIu1nijXydLShEq5I
github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ=
github.com/code-payments/code-vm-indexer v1.2.0 h1:rSHpBMiT9BKgmKcXg/VIoi/h0t7jNxGx07Qz59m+6Q0=
github.com/code-payments/code-vm-indexer v1.2.0/go.mod h1:vn91YN2qNqb+gGJeZe2+l+TNxVmEEiRHXXnIn2Y40h8=
github.com/code-payments/ocp-protobuf-api v0.12.0 h1:X5lo7ABDYxsiC/D3viFuNJUhTWKISZBg6MzAy2PP10Y=
github.com/code-payments/ocp-protobuf-api v0.12.0/go.mod h1:tw6BooY5a8l6CtSZnKOruyKII0W04n89pcM4BizrgG8=
github.com/code-payments/ocp-protobuf-api v0.13.0 h1:TotuJZLLlpLKqgDGa9VQzkxiforFw4K+UsV//i6W28M=
github.com/code-payments/ocp-protobuf-api v0.13.0/go.mod h1:tw6BooY5a8l6CtSZnKOruyKII0W04n89pcM4BizrgG8=
github.com/containerd/continuity v0.0.0-20190827140505-75bee3e2ccb6 h1:NmTXa/uVnDyp0TY5MKi197+3HWcnYWfnHGyaFthlnGw=
github.com/containerd/continuity v0.0.0-20190827140505-75bee3e2ccb6/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y=
github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
Expand Down
29 changes: 17 additions & 12 deletions ocp/rpc/currency/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,18 +117,6 @@ func (s *currencyServer) GetMints(ctx context.Context, req *currencypb.GetMintsR
return nil, status.Error(codes.Internal, "")
}

err = s.liveMintStateWorker.waitForData(ctx)
if err != nil {
log.With(zap.Error(err)).Warn("failed to wait for live mint data")
return nil, status.Error(codes.Internal, "")
}

liveReserveState, err := s.liveMintStateWorker.getReserveState(mintAccount)
if err != nil {
log.With(zap.Error(err)).Warn("failed to get live mint reserve state")
return nil, status.Error(codes.Internal, "")
}

vmConfig, err := common.GetVmConfigForMint(ctx, s.data, mintAccount)
if err != nil {
log.With(zap.Error(err)).Warn("failure getting vm config")
Expand Down Expand Up @@ -166,6 +154,21 @@ func (s *currencyServer) GetMints(ctx context.Context, req *currencypb.GetMintsR
return nil, status.Error(codes.Internal, "")
}

err = s.liveMintStateWorker.waitForData(ctx)
if err != nil {
log.With(zap.Error(err)).Warn("failed to wait for live mint data")
return nil, status.Error(codes.Internal, "")
}

liveReserveState, err := s.liveMintStateWorker.getReserveState(mintAccount)
if err != nil {
log.With(zap.Error(err)).Warn("failed to get live mint reserve state")
return nil, status.Error(codes.Internal, "")
}

spotPrice, _ := currencycreator.EstimateCurrentPrice(liveReserveState.SupplyFromBonding).Float64()
marketCap := calculateMarketCap(liveReserveState.SupplyFromBonding, 1.0)

protoMetadata = &currencypb.Mint{
Address: protoMintAddress,
Decimals: uint32(metadataRecord.Decimals),
Expand All @@ -188,6 +191,8 @@ func (s *currencyServer) GetMints(ctx context.Context, req *currencypb.GetMintsR
CoreMintVault: coreMintVaultAccount.ToProto(),
SupplyFromBonding: liveReserveState.SupplyFromBonding,
SellFeeBps: uint32(metadataRecord.SellFeeBps),
Price: spotPrice,
MarketCap: marketCap,
},
CreatedAt: timestamppb.New(metadataRecord.CreatedAt),
}
Expand Down
Loading