diff --git a/txnbuild/invoke_host_function.go b/txnbuild/invoke_host_function.go index eeb0ef6ca7..1a11a9baa3 100644 --- a/txnbuild/invoke_host_function.go +++ b/txnbuild/invoke_host_function.go @@ -8,6 +8,7 @@ import ( type InvokeHostFunction struct { Function xdr.HostFunction Footprint xdr.LedgerFootprint + Auth []xdr.ContractAuth SourceAccount string } @@ -17,6 +18,7 @@ func (f *InvokeHostFunction) BuildXDR() (xdr.Operation, error) { xdrOp := xdr.InvokeHostFunctionOp{ Function: f.Function, Footprint: f.Footprint, + Auth: f.Auth, } body, err := xdr.NewOperationBody(opType, xdrOp) @@ -37,6 +39,7 @@ func (f *InvokeHostFunction) FromXDR(xdrOp xdr.Operation) error { } f.SourceAccount = accountFromXDR(xdrOp.SourceAccount) + f.Auth = result.Auth f.Footprint = result.Footprint f.Function = result.Function diff --git a/txnbuild/invoke_host_function_test.go b/txnbuild/invoke_host_function_test.go index ee7bed6a8e..266028d88c 100644 --- a/txnbuild/invoke_host_function_test.go +++ b/txnbuild/invoke_host_function_test.go @@ -52,6 +52,7 @@ func TestInvokeHostFunctionRoundTrip(t *testing.T) { Type: xdr.ScObjectTypeScoI64, I64: &i64, } + accountId := xdr.MustAddress("GB7BDSZU2Y27LYNLALKKALB52WS2IZWYBDGY6EQBLEED3TJOCVMZRH7H") invokeHostFunctionOp := &InvokeHostFunction{ Function: xdr.HostFunction{ Type: xdr.HostFunctionTypeHostFunctionTypeInvokeContract, @@ -62,6 +63,24 @@ func TestInvokeHostFunctionRoundTrip(t *testing.T) { }, }, }, + Auth: []xdr.ContractAuth{ + { + AddressWithNonce: &xdr.AddressWithNonce{ + Address: xdr.ScAddress{ + Type: xdr.ScAddressTypeScAddressTypeAccount, + AccountId: &accountId, + }, + Nonce: 0, + }, + RootInvocation: xdr.AuthorizedInvocation{ + ContractId: xdr.Hash{0xaa, 0xbb}, + FunctionName: "foo", + Args: nil, + SubInvocations: nil, + }, + SignatureArgs: nil, + }, + }, Footprint: xdr.LedgerFootprint{ ReadOnly: []xdr.LedgerKey{ {