Skip to content

Commit

Permalink
XDR definitions for Soroban constructor support. (#202)
Browse files Browse the repository at this point in the history
  • Loading branch information
dmkozh authored Aug 13, 2024
1 parent 93e8e3e commit 72868e9
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions Stellar-transaction.x
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,8 @@ enum HostFunctionType
{
HOST_FUNCTION_TYPE_INVOKE_CONTRACT = 0,
HOST_FUNCTION_TYPE_CREATE_CONTRACT = 1,
HOST_FUNCTION_TYPE_UPLOAD_CONTRACT_WASM = 2
HOST_FUNCTION_TYPE_UPLOAD_CONTRACT_WASM = 2,
HOST_FUNCTION_TYPE_CREATE_CONTRACT_V2 = 3
};

enum ContractIDPreimageType
Expand All @@ -503,6 +504,14 @@ struct CreateContractArgs
ContractExecutable executable;
};

struct CreateContractArgsV2
{
ContractIDPreimage contractIDPreimage;
ContractExecutable executable;
// Arguments of the contract's constructor.
SCVal constructorArgs<>;
};

struct InvokeContractArgs {
SCAddress contractAddress;
SCSymbol functionName;
Expand All @@ -517,20 +526,29 @@ case HOST_FUNCTION_TYPE_CREATE_CONTRACT:
CreateContractArgs createContract;
case HOST_FUNCTION_TYPE_UPLOAD_CONTRACT_WASM:
opaque wasm<>;
case HOST_FUNCTION_TYPE_CREATE_CONTRACT_V2:
CreateContractArgsV2 createContractV2;
};

enum SorobanAuthorizedFunctionType
{
SOROBAN_AUTHORIZED_FUNCTION_TYPE_CONTRACT_FN = 0,
SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_HOST_FN = 1
SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_HOST_FN = 1,
SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_V2_HOST_FN = 2
};

union SorobanAuthorizedFunction switch (SorobanAuthorizedFunctionType type)
{
case SOROBAN_AUTHORIZED_FUNCTION_TYPE_CONTRACT_FN:
InvokeContractArgs contractFn;
// This variant of auth payload for creating new contract instances is no
// longer accepted after protocol 22.
case SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_HOST_FN:
CreateContractArgs createContractHostFn;
// This variant of auth payload for creating new contract instances
// is only accepted in and after protocol 22.
case SOROBAN_AUTHORIZED_FUNCTION_TYPE_CREATE_CONTRACT_V2_HOST_FN:
CreateContractArgsV2 createContractV2HostFn;
};

struct SorobanAuthorizedInvocation
Expand Down

0 comments on commit 72868e9

Please sign in to comment.