Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Back-transfer Test & API change #791

Merged
merged 4 commits into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
Binary file modified test/features/composability/forwarder/output/forwarder.wasm
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,17 @@
"str:BackTransfer",
"0"
]
},
{
"address": "sc:forwarder",
"endpoint": "str:forward_sync_retrieve_funds",
"topics": [
"str:back_tranfers",
"1000"
],
"data": [
""
]
}
],
"gas": "*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,20 @@
"str:TEST-TOKENA",
"1000"
]
},
{
"address": "sc:forwarder",
"endpoint": "str:forward_sync_retrieve_funds",
"topics": [
"str:back_tranfers",
"0",
"str:TEST-TOKENA",
"0",
"1000"
],
"data": [
""
]
}
],
"gas": "*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,20 @@
"01",
"sc:forwarder"
]
},
{
"address": "sc:forwarder",
"endpoint": "str:forward_sync_retrieve_funds",
"topics": [
"str:back_tranfers",
"0",
"str:NFT-000001",
"5",
"1"
],
"data": [
""
]
}
],
"gas": "*",
Expand Down
4 changes: 2 additions & 2 deletions vmhost/contexts/managedType.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import (
"crypto/elliptic"
"encoding/binary"
"errors"
vmcommon "github.com/multiversx/mx-chain-vm-common-go"
"io"
basicMath "math"
"math/big"

"github.com/multiversx/mx-chain-core-go/core/check"
logger "github.com/multiversx/mx-chain-logger-go"
vmcommon "github.com/multiversx/mx-chain-vm-common-go"
"github.com/multiversx/mx-chain-vm-go/math"
"github.com/multiversx/mx-chain-vm-go/vmhost"
)
Expand Down Expand Up @@ -552,7 +552,7 @@ func (context *managedTypesContext) NewManagedBufferFromBytes(bytes []byte) int3
return mBufferHandle
}

// SetBytes sets the bytes given as value for the managed buffer
// SetBytes sets the bytes given as value for the managed buffer. Will create managed buffer if it doesn't exist.
func (context *managedTypesContext) SetBytes(mBufferHandle int32, bytes []byte) {
_, ok := context.managedTypesValues.mBufferValues[mBufferHandle]
if !ok {
Expand Down
5 changes: 3 additions & 2 deletions vmhost/vmhooks/managedei.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ func (context *VMHooksImpl) ManagedGetMultiESDTCallValue(multiCallValueHandle in

// ManagedGetBackTransfers VMHooks implementation.
// @autogenerate(VMHooks)
func (context *VMHooksImpl) ManagedGetBackTransfers(esdtTransfersValueHandle int32, callValueHandle int32) {
func (context *VMHooksImpl) ManagedGetBackTransfers(esdtTransfersValueHandle int32, egldValueHandle int32) {
metering := context.GetMeteringContext()
managedType := context.GetManagedTypesContext()

Expand All @@ -259,7 +259,8 @@ func (context *VMHooksImpl) ManagedGetBackTransfers(esdtTransfersValueHandle int
managedType.ConsumeGasForBytes(multiCallBytes)

managedType.SetBytes(esdtTransfersValueHandle, multiCallBytes)
managedType.SetBytes(callValueHandle, transferValue.Bytes())
egldValue := managedType.GetBigIntOrCreate(egldValueHandle)
egldValue.SetBytes(transferValue.Bytes())
}

// ManagedGetESDTBalance VMHooks implementation.
Expand Down
Loading