Skip to content

Commit

Permalink
[PVM, Spend] Allow spend to deposit unlocked tokens for different owner
Browse files Browse the repository at this point in the history
  • Loading branch information
evlekht authored and evlekht committed May 28, 2024
1 parent f2dacf2 commit d99b70f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion vms/platformvm/utxo/camino_locked.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ func (h *handler) Lock(
insAmounts := make(map[ids.ID]OwnerAmounts)

var toOwnerID *ids.ID
if to != nil && appliedLockState == locked.StateUnlocked {
if to != nil && (appliedLockState == locked.StateUnlocked || appliedLockState == locked.StateDeposited) {
id, err := txs.GetOwnerID(to)
if err != nil {
return nil, nil, nil, nil, err
Expand Down
23 changes: 23 additions & 0 deletions vms/platformvm/utxo/camino_locked_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,29 @@ func TestLock(t *testing.T) {
}
},
},
"OK: deposit for new owner": {
args: args{
totalAmountToSpend: 1,
totalAmountToBurn: 1,
appliedLockState: locked.StateDeposited,
recipient: &recipientOwners,
change: &changeOwners,
},
utxos: []*avax.UTXO{
generateTestUTXO(ids.ID{8, 8}, ctx.AVAXAssetID, 5, outputOwners, ids.Empty, ids.Empty),
},
generateWant: func(utxos []*avax.UTXO) want {
return want{
ins: []*avax.TransferableInput{
generateTestInFromUTXO(utxos[0], []uint32{0}),
},
outs: []*avax.TransferableOutput{
generateTestOut(ctx.AVAXAssetID, 1, recipientOwners, locked.ThisTxID, ids.Empty),
generateTestOut(ctx.AVAXAssetID, 3, changeOwners, ids.Empty, ids.Empty),
},
}
},
},
}

for name, tt := range tests {
Expand Down

0 comments on commit d99b70f

Please sign in to comment.