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: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@ 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.1.0 h1:sS2x2dwL94uZ/cGNvlStZmazY26b+dWT10bOFkk+1+c=
github.com/code-payments/ocp-protobuf-api v0.1.0/go.mod h1:tw6BooY5a8l6CtSZnKOruyKII0W04n89pcM4BizrgG8=
github.com/code-payments/ocp-protobuf-api v0.2.0 h1:XLDeVdPDjy+Y0xnvcu1KHf6JelWc4IgDQ4SOCRBJvzE=
github.com/code-payments/ocp-protobuf-api v0.2.0/go.mod h1:tw6BooY5a8l6CtSZnKOruyKII0W04n89pcM4BizrgG8=
github.com/containerd/continuity v0.0.0-20190827140505-75bee3e2ccb6 h1:NmTXa/uVnDyp0TY5MKi197+3HWcnYWfnHGyaFthlnGw=
Expand Down
18 changes: 9 additions & 9 deletions ocp/common/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import (
"github.com/code-payments/ocp-server/ocp/data/currency"
"github.com/code-payments/ocp-server/ocp/data/timelock"
"github.com/code-payments/ocp-server/solana"
"github.com/code-payments/ocp-server/solana/cvm"
timelock_token_v1 "github.com/code-payments/ocp-server/solana/timelock/v1"
"github.com/code-payments/ocp-server/solana/token"
"github.com/code-payments/ocp-server/solana/vm"
)

type Account struct {
Expand Down Expand Up @@ -239,7 +239,7 @@ func (a *Account) GetTimelockAccounts(vmConfig *VmConfig) (*TimelockAccounts, er
return nil, errors.Wrap(err, "error validating owner account")
}

stateAddress, stateBump, err := cvm.GetVirtualTimelockAccountAddress(&cvm.GetVirtualTimelockAccountAddressArgs{
stateAddress, stateBump, err := vm.GetVirtualTimelockAccountAddress(&vm.GetVirtualTimelockAccountAddressArgs{
Mint: vmConfig.Mint.PublicKey().ToBytes(),
VmAuthority: vmConfig.Authority.PublicKey().ToBytes(),
Owner: a.PublicKey().ToBytes(),
Expand All @@ -249,14 +249,14 @@ func (a *Account) GetTimelockAccounts(vmConfig *VmConfig) (*TimelockAccounts, er
return nil, errors.Wrap(err, "error getting timelock state address")
}

vaultAddress, vaultBump, err := cvm.GetVirtualTimelockVaultAddress(&cvm.GetVirtualTimelockVaultAddressArgs{
vaultAddress, vaultBump, err := vm.GetVirtualTimelockVaultAddress(&vm.GetVirtualTimelockVaultAddressArgs{
VirtualTimelock: stateAddress,
})
if err != nil {
return nil, errors.Wrap(err, "error getting vault address")
}

unlockAddress, unlockBump, err := cvm.GetVmUnlockStateAccountAddress(&cvm.GetVmUnlockStateAccountAddressArgs{
unlockAddress, unlockBump, err := vm.GetVmUnlockStateAccountAddress(&vm.GetVmUnlockStateAccountAddressArgs{
VirtualAccountOwner: a.publicKey.ToBytes(),
VirtualAccount: stateAddress,
Vm: vmConfig.Vm.PublicKey().ToBytes(),
Expand Down Expand Up @@ -311,7 +311,7 @@ func (a *Account) GetTimelockAccounts(vmConfig *VmConfig) (*TimelockAccounts, er
}

func (a *Account) GetVmDepositAccounts(vmConfig *VmConfig) (*VmDepositAccounts, error) {
depositPdaAddress, depositPdaBump, err := cvm.GetVmDepositAddress(&cvm.GetVmDepositAddressArgs{
depositPdaAddress, depositPdaBump, err := vm.GetVmDepositAddress(&vm.GetVmDepositAddressArgs{
Depositor: a.PublicKey().ToBytes(),
Vm: vmConfig.Vm.PublicKey().ToBytes(),
})
Expand Down Expand Up @@ -348,7 +348,7 @@ func (a *Account) GetVmDepositAccounts(vmConfig *VmConfig) (*VmDepositAccounts,
}

func (a *Account) GetVmSwapAccounts(vmConfig *VmConfig) (*VmSwapAccounts, error) {
swapPdaAddress, swapPdaBump, err := cvm.GetVmSwapAddress(&cvm.GetVmSwapAddressArgs{
swapPdaAddress, swapPdaBump, err := vm.GetVmSwapAddress(&vm.GetVmSwapAddressArgs{
Swapper: a.PublicKey().ToBytes(),
Vm: vmConfig.Vm.PublicKey().ToBytes(),
})
Expand Down Expand Up @@ -488,14 +488,14 @@ func (a *TimelockAccounts) GetDBRecord(ctx context.Context, data ocp_data.Provid

// GetInitializeInstruction gets a SystemTimelockInitInstruction instruction for a Timelock account
func (a *TimelockAccounts) GetInitializeInstruction(vmAuthority, memory *Account, accountIndex uint16) (solana.Instruction, error) {
return cvm.NewInitTimelockInstruction(
&cvm.InitTimelockInstructionAccounts{
return vm.NewInitTimelockInstruction(
&vm.InitTimelockInstructionAccounts{
VmAuthority: vmAuthority.PublicKey().ToBytes(),
Vm: a.Vm.PublicKey().ToBytes(),
VmMemory: memory.PublicKey().ToBytes(),
VirtualAccountOwner: a.VaultOwner.PublicKey().ToBytes(),
},
&cvm.InitTimelockInstructionArgs{
&vm.InitTimelockInstructionArgs{
AccountIndex: accountIndex,
VirtualTimelockBump: a.StateBump,
VirtualVaultBump: a.VaultBump,
Expand Down
16 changes: 8 additions & 8 deletions ocp/common/account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import (
commonpb "github.com/code-payments/ocp-protobuf-api/generated/go/common/v1"

ocp_data "github.com/code-payments/ocp-server/ocp/data"
"github.com/code-payments/ocp-server/solana/cvm"
timelock_token_v1 "github.com/code-payments/ocp-server/solana/timelock/v1"
"github.com/code-payments/ocp-server/solana/token"
"github.com/code-payments/ocp-server/solana/vm"
)

func TestAccountWithPublicKey(t *testing.T) {
Expand Down Expand Up @@ -107,15 +107,15 @@ func TestConvertToTimelockVault(t *testing.T) {

ownerAccount := newRandomTestAccount(t)

stateAddress, _, err := cvm.GetVirtualTimelockAccountAddress(&cvm.GetVirtualTimelockAccountAddressArgs{
stateAddress, _, err := vm.GetVirtualTimelockAccountAddress(&vm.GetVirtualTimelockAccountAddressArgs{
Mint: vmConfig.Mint.PublicKey().ToBytes(),
VmAuthority: vmConfig.Authority.PublicKey().ToBytes(),
Owner: ownerAccount.PublicKey().ToBytes(),
LockDuration: timelock_token_v1.DefaultNumDaysLocked,
})
require.NoError(t, err)

expectedVaultAddress, _, err := cvm.GetVirtualTimelockVaultAddress(&cvm.GetVirtualTimelockVaultAddressArgs{
expectedVaultAddress, _, err := vm.GetVirtualTimelockVaultAddress(&vm.GetVirtualTimelockVaultAddressArgs{
VirtualTimelock: stateAddress,
})
require.NoError(t, err)
Expand All @@ -130,20 +130,20 @@ func TestGetTimelockAccounts(t *testing.T) {

ownerAccount := newRandomTestAccount(t)

expectedStateAddress, expectedStateBump, err := cvm.GetVirtualTimelockAccountAddress(&cvm.GetVirtualTimelockAccountAddressArgs{
expectedStateAddress, expectedStateBump, err := vm.GetVirtualTimelockAccountAddress(&vm.GetVirtualTimelockAccountAddressArgs{
Mint: vmConfig.Mint.PublicKey().ToBytes(),
VmAuthority: vmConfig.Authority.PublicKey().ToBytes(),
Owner: ownerAccount.PublicKey().ToBytes(),
LockDuration: timelock_token_v1.DefaultNumDaysLocked,
})
require.NoError(t, err)

expectedVaultAddress, expectedVaultBump, err := cvm.GetVirtualTimelockVaultAddress(&cvm.GetVirtualTimelockVaultAddressArgs{
expectedVaultAddress, expectedVaultBump, err := vm.GetVirtualTimelockVaultAddress(&vm.GetVirtualTimelockVaultAddressArgs{
VirtualTimelock: expectedStateAddress,
})
require.NoError(t, err)

expectedUnlockAddress, expectedUnlockBump, err := cvm.GetVmUnlockStateAccountAddress(&cvm.GetVmUnlockStateAccountAddressArgs{
expectedUnlockAddress, expectedUnlockBump, err := vm.GetVmUnlockStateAccountAddress(&vm.GetVmUnlockStateAccountAddressArgs{
VirtualAccountOwner: ownerAccount.PublicKey().ToBytes(),
VirtualAccount: expectedStateAddress,
Vm: vmConfig.Vm.PublicKey().ToBytes(),
Expand All @@ -168,7 +168,7 @@ func TestGetVmDepositAccounts(t *testing.T) {

ownerAccount := newRandomTestAccount(t)

expectedDepositPdaAddress, expectedDepositPdaBump, err := cvm.GetVmDepositAddress(&cvm.GetVmDepositAddressArgs{
expectedDepositPdaAddress, expectedDepositPdaBump, err := vm.GetVmDepositAddress(&vm.GetVmDepositAddressArgs{
Depositor: ownerAccount.PublicKey().ToBytes(),
Vm: vmConfig.Vm.PublicKey().ToBytes(),
})
Expand All @@ -192,7 +192,7 @@ func TestGetVmSwapAccounts(t *testing.T) {

ownerAccount := newRandomTestAccount(t)

expectedSwapPdaAddress, expectedSwapPdaBump, err := cvm.GetVmSwapAddress(&cvm.GetVmSwapAddressArgs{
expectedSwapPdaAddress, expectedSwapPdaBump, err := vm.GetVmSwapAddress(&vm.GetVmSwapAddressArgs{
Swapper: ownerAccount.PublicKey().ToBytes(),
Vm: vmConfig.Vm.PublicKey().ToBytes(),
})
Expand Down
Loading
Loading