diff --git a/Stellar-contract.x b/Stellar-contract.x index 7c5fe68..d7f34b4 100644 --- a/Stellar-contract.x +++ b/Stellar-contract.x @@ -250,14 +250,14 @@ case NEGATIVE: enum SCContractCodeType { - SCCONTRACT_CODE_WASM = 0, + SCCONTRACT_CODE_WASM_REF = 0, SCCONTRACT_CODE_TOKEN = 1 }; union SCContractCode switch (SCContractCodeType type) { -case SCCONTRACT_CODE_WASM: - opaque wasm; +case SCCONTRACT_CODE_WASM_REF: + Hash wasm_id; case SCCONTRACT_CODE_TOKEN: void; }; diff --git a/Stellar-ledger-entries.x b/Stellar-ledger-entries.x index 9caf8bd..2616d2c 100644 --- a/Stellar-ledger-entries.x +++ b/Stellar-ledger-entries.x @@ -100,7 +100,8 @@ enum LedgerEntryType CLAIMABLE_BALANCE = 4, LIQUIDITY_POOL = 5, CONTRACT_DATA = 6, - CONFIG_SETTING = 7 + CONTRACT_CODE = 7, + CONFIG_SETTING = 8 }; struct Signer @@ -499,6 +500,13 @@ struct ContractDataEntry { SCVal val; }; +struct ContractCodeEntry { + ExtensionPoint ext; + + Hash hash; + opaque code; +}; + enum ConfigSettingType { CONFIG_SETTING_TYPE_UINT32 = 0 @@ -560,6 +568,8 @@ struct LedgerEntry LiquidityPoolEntry liquidityPool; case CONTRACT_DATA: ContractDataEntry contractData; + case CONTRACT_CODE: + ContractCodeEntry contractCode; case CONFIG_SETTING: ConfigSettingEntry configSetting; } @@ -622,6 +632,11 @@ case CONTRACT_DATA: Hash contractID; SCVal key; } contractData; +case CONTRACT_CODE: + struct + { + Hash hash; + } contractCode; case CONFIG_SETTING: struct { @@ -645,6 +660,7 @@ enum EnvelopeType ENVELOPE_TYPE_CONTRACT_ID_FROM_ED25519 = 8, ENVELOPE_TYPE_CONTRACT_ID_FROM_CONTRACT = 9, ENVELOPE_TYPE_CONTRACT_ID_FROM_ASSET = 10, - ENVELOPE_TYPE_CONTRACT_ID_FROM_SOURCE_ACCOUNT = 11 + ENVELOPE_TYPE_CONTRACT_ID_FROM_SOURCE_ACCOUNT = 11, + ENVELOPE_TYPE_CREATE_CONTRACT_ARGS = 12 }; } diff --git a/Stellar-transaction.x b/Stellar-transaction.x index cdf108b..ba291db 100644 --- a/Stellar-transaction.x +++ b/Stellar-transaction.x @@ -474,23 +474,66 @@ struct LiquidityPoolWithdrawOp int64 minAmountB; // minimum amount of second asset to withdraw }; -enum HostFunction +enum HostFunctionType { - HOST_FN_INVOKE_CONTRACT = 0, - HOST_FN_CREATE_CONTRACT_WITH_ED25519 = 1, - HOST_FN_CREATE_CONTRACT_WITH_SOURCE_ACCOUNT = 2, - HOST_FN_CREATE_TOKEN_CONTRACT_WITH_SOURCE_ACCOUNT = 3, - HOST_FN_CREATE_TOKEN_CONTRACT_WITH_ASSET = 4 + HOST_FUNCTION_TYPE_INVOKE_CONTRACT = 0, + HOST_FUNCTION_TYPE_CREATE_CONTRACT = 1, + HOST_FUNCTION_TYPE_INSTALL_CONTRACT_CODE = 2 +}; + +enum ContractIDType +{ + CONTRACT_ID_FROM_SOURCE_ACCOUNT = 0, + CONTRACT_ID_FROM_ED25519_PUBLIC_KEY = 1, + CONTRACT_ID_FROM_ASSET = 2 +}; + +enum ContractIDPublicKeyType +{ + CONTRACT_ID_PUBLIC_KEY_SOURCE_ACCOUNT = 0, + CONTRACT_ID_PUBLIC_KEY_ED25519 = 1 +}; + +struct InstallContractCodeArgs +{ + opaque code; +}; + +union ContractID switch (ContractIDType type) +{ +case CONTRACT_ID_FROM_SOURCE_ACCOUNT: + uint256 salt; +case CONTRACT_ID_FROM_ED25519_PUBLIC_KEY: + struct + { + uint256 key; + Signature signature; + uint256 salt; + } fromEd25519PublicKey; +case CONTRACT_ID_FROM_ASSET: + Asset asset; +}; + +struct CreateContractArgs +{ + ContractID contractID; + SCContractCode source; +}; + +union HostFunction switch (HostFunctionType type) +{ +case HOST_FUNCTION_TYPE_INVOKE_CONTRACT: + SCVec invokeArgs; +case HOST_FUNCTION_TYPE_CREATE_CONTRACT: + CreateContractArgs createContractArgs; +case HOST_FUNCTION_TYPE_INSTALL_CONTRACT_CODE: + InstallContractCodeArgs installContractCodeArgs; }; struct InvokeHostFunctionOp { // The host function to invoke HostFunction function; - - // Parameters to the host function - SCVec parameters; - // The footprint for this invocation LedgerFootprint footprint; }; @@ -580,23 +623,37 @@ case ENVELOPE_TYPE_POOL_REVOKE_OP_ID: case ENVELOPE_TYPE_CONTRACT_ID_FROM_ED25519: struct { + Hash networkID; uint256 ed25519; uint256 salt; } ed25519ContractID; case ENVELOPE_TYPE_CONTRACT_ID_FROM_CONTRACT: struct { + Hash networkID; Hash contractID; uint256 salt; } contractID; case ENVELOPE_TYPE_CONTRACT_ID_FROM_ASSET: - Asset fromAsset; + struct + { + Hash networkID; + Asset asset; + } fromAsset; case ENVELOPE_TYPE_CONTRACT_ID_FROM_SOURCE_ACCOUNT: struct { + Hash networkID; AccountID sourceAccount; uint256 salt; } sourceAccountContractID; +case ENVELOPE_TYPE_CREATE_CONTRACT_ARGS: + struct + { + Hash networkID; + SCContractCode source; + uint256 salt; + } createContractArgs; }; enum MemoType