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/bits-and-blooms/bloom/v3 v3.1.0
github.com/code-payments/code-protobuf-api v1.19.1-0.20250827160012-3edaffb82d79
github.com/code-payments/code-protobuf-api v1.19.1-0.20250909140022-32d989862f5a
github.com/code-payments/code-vm-indexer v0.1.11-0.20241028132209-23031e814fba
github.com/emirpasic/gods v1.12.0
github.com/envoyproxy/protoc-gen-validate v1.2.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnht
github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
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-protobuf-api v1.19.1-0.20250827160012-3edaffb82d79 h1:Td/jOwNQCuSaTL6NZstWSMxgjcyVhkC1Q/BmVRqY6qo=
github.com/code-payments/code-protobuf-api v1.19.1-0.20250827160012-3edaffb82d79/go.mod h1:ee6TzKbgMS42ZJgaFEMG3c4R3dGOiffHSu6MrY7WQvs=
github.com/code-payments/code-protobuf-api v1.19.1-0.20250909140022-32d989862f5a h1:KJHqqNz1gEOhjg97mw1B81Fvd4CClWeaSJw2AMOqSkA=
github.com/code-payments/code-protobuf-api v1.19.1-0.20250909140022-32d989862f5a/go.mod h1:ee6TzKbgMS42ZJgaFEMG3c4R3dGOiffHSu6MrY7WQvs=
github.com/code-payments/code-vm-indexer v0.1.11-0.20241028132209-23031e814fba h1:Bkp+gmeb6Y2PWXfkSCTMBGWkb2P1BujRDSjWeI+0j5I=
github.com/code-payments/code-vm-indexer v0.1.11-0.20241028132209-23031e814fba/go.mod h1:jSiifpiBpyBQ8q2R0MGEbkSgWC6sbdRTyDBntmW+j1E=
github.com/containerd/continuity v0.0.0-20190827140505-75bee3e2ccb6 h1:NmTXa/uVnDyp0TY5MKi197+3HWcnYWfnHGyaFthlnGw=
Expand Down
2 changes: 2 additions & 0 deletions pkg/code/aml/guard_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ func makeSendPublicPaymentIntent(t *testing.T, owner *common.Account, usdMarketV
IsWithdrawal: isWithdraw,
},

MintAccount: common.CoreMintAccount.PublicKey().ToBase58(),

InitiatorOwnerAccount: owner.PublicKey().ToBase58(),

State: intent.StatePending,
Expand Down
13 changes: 10 additions & 3 deletions pkg/code/async/account/gift_card.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ import (

"github.com/code-payments/code-server/pkg/code/balance"
"github.com/code-payments/code-server/pkg/code/common"
currency_util "github.com/code-payments/code-server/pkg/code/currency"
code_data "github.com/code-payments/code-server/pkg/code/data"
"github.com/code-payments/code-server/pkg/code/data/account"
"github.com/code-payments/code-server/pkg/code/data/action"
"github.com/code-payments/code-server/pkg/code/data/fulfillment"
"github.com/code-payments/code-server/pkg/code/data/intent"
"github.com/code-payments/code-server/pkg/currency"
"github.com/code-payments/code-server/pkg/metrics"
"github.com/code-payments/code-server/pkg/pointer"
"github.com/code-payments/code-server/pkg/retry"
Expand Down Expand Up @@ -300,7 +300,12 @@ func updateAutoReturnFulfillmentPreSorting(
}

func insertAutoReturnIntentRecord(ctx context.Context, data code_data.Provider, giftCardIssuedIntent *intent.Record, isVoidedByUser bool) error {
usdExchangeRecord, err := data.GetExchangeRate(ctx, currency.USD, time.Now())
mintAccount, err := common.NewAccountFromPublicKeyString(giftCardIssuedIntent.MintAccount)
if err != nil {
return err
}

usdMarketValue, err := currency_util.CalculateUsdMarketValue(ctx, data, mintAccount, giftCardIssuedIntent.SendPublicPaymentMetadata.Quantity, time.Now())
if err != nil {
return err
}
Expand All @@ -312,6 +317,8 @@ func insertAutoReturnIntentRecord(ctx context.Context, data code_data.Provider,
IntentId: getAutoReturnIntentId(giftCardIssuedIntent.IntentId),
IntentType: intent.ReceivePaymentsPublicly,

MintAccount: common.CoreMintAccount.PublicKey().ToBase58(),

InitiatorOwnerAccount: giftCardIssuedIntent.InitiatorOwnerAccount,

ReceivePaymentsPubliclyMetadata: &intent.ReceivePaymentsPubliclyMetadata{
Expand All @@ -326,7 +333,7 @@ func insertAutoReturnIntentRecord(ctx context.Context, data code_data.Provider,
OriginalExchangeRate: giftCardIssuedIntent.SendPublicPaymentMetadata.ExchangeRate,
OriginalNativeAmount: giftCardIssuedIntent.SendPublicPaymentMetadata.NativeAmount,

UsdMarketValue: usdExchangeRecord.Rate * float64(giftCardIssuedIntent.SendPublicPaymentMetadata.Quantity) / float64(common.CoreMintQuarksPerUnit),
UsdMarketValue: usdMarketValue,
},

State: intent.StateConfirmed,
Expand Down
7 changes: 6 additions & 1 deletion pkg/code/async/account/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ func (p *service) mustLoadAirdropper(ctx context.Context) {
})

err := func() error {
vmConfig, err := common.GetVmConfigForMint(ctx, p.data, common.CoreMintAccount)
if err != nil {
return err
}

vaultRecord, err := p.data.GetKey(ctx, p.conf.airdropperOwnerPublicKey.Get(ctx))
if err != nil {
return err
Expand All @@ -75,7 +80,7 @@ func (p *service) mustLoadAirdropper(ctx context.Context) {
return err
}

timelockAccounts, err := ownerAccount.GetTimelockAccounts(common.CodeVmAccount, common.CoreMintAccount)
timelockAccounts, err := ownerAccount.GetTimelockAccounts(vmConfig)
if err != nil {
return err
}
Expand Down
10 changes: 7 additions & 3 deletions pkg/code/async/account/testutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"github.com/code-payments/code-server/pkg/code/data/currency"
"github.com/code-payments/code-server/pkg/code/data/fulfillment"
"github.com/code-payments/code-server/pkg/code/data/intent"
currency_lib "github.com/code-payments/code-server/pkg/currency"
"github.com/code-payments/code-server/pkg/pointer"
"github.com/code-payments/code-server/pkg/testutil"
)
Expand Down Expand Up @@ -57,10 +58,11 @@ func setup(t *testing.T) *testEnv {
}

func (e *testEnv) generateRandomGiftCard(t *testing.T, creationTs time.Time) *testGiftCard {
vm := testutil.NewRandomAccount(t)
authority := testutil.NewRandomAccount(t)

timelockAccounts, err := authority.GetTimelockAccounts(vm, common.CoreMintAccount)
vmConfig := testutil.NewRandomVmConfig(t, true)

timelockAccounts, err := authority.GetTimelockAccounts(vmConfig)
require.NoError(t, err)

accountInfoRecord := &account.Record{
Expand All @@ -81,13 +83,15 @@ func (e *testEnv) generateRandomGiftCard(t *testing.T, creationTs time.Time) *te
IntentId: testutil.NewRandomAccount(t).PublicKey().ToBase58(),
IntentType: intent.SendPublicPayment,

MintAccount: vmConfig.Mint.PublicKey().ToBase58(),

InitiatorOwnerAccount: testutil.NewRandomAccount(t).PublicKey().ToBase58(),

SendPublicPaymentMetadata: &intent.SendPublicPaymentMetadata{
DestinationTokenAccount: accountInfoRecord.TokenAccount,
Quantity: common.ToCoreMintQuarks(12345),

ExchangeCurrency: common.CoreMintSymbol,
ExchangeCurrency: currency_lib.USD,
ExchangeRate: 1.0,
NativeAmount: 12345,
UsdMarketValue: 1000.0,
Expand Down
41 changes: 0 additions & 41 deletions pkg/code/async/airdrop/config.go

This file was deleted.

42 changes: 0 additions & 42 deletions pkg/code/async/airdrop/indexer.go

This file was deleted.

16 changes: 0 additions & 16 deletions pkg/code/async/airdrop/integration.go

This file was deleted.

34 changes: 0 additions & 34 deletions pkg/code/async/airdrop/nonce.go

This file was deleted.

122 changes: 0 additions & 122 deletions pkg/code/async/airdrop/service.go

This file was deleted.

Loading
Loading