diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b125d2..127c10c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## [1.6.6] - 24.Oct.2023. +- update stable version of p20 + ## [1.6.5] - 03.Oct.2023. - update horizon responses for p20 - remove soroban experimental flag diff --git a/README.md b/README.md index 8e38e29..416c52f 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ The Soneso open source Stellar SDK for Flutter is build with Dart and provides A 1. Add the dependency to your pubspec.yaml file: ``` dependencies: - stellar_flutter_sdk: ^1.6.5 + stellar_flutter_sdk: ^1.6.6 ``` 2. Install it (command line or IDE): ``` diff --git a/documentation/sdk_api_doc.zip b/documentation/sdk_api_doc.zip index e27f772..766e46d 100644 Binary files a/documentation/sdk_api_doc.zip and b/documentation/sdk_api_doc.zip differ diff --git a/lib/src/extend_footprint_ttl_operation.dart b/lib/src/extend_footprint_ttl_operation.dart index ec7ecba..023fcc2 100644 --- a/lib/src/extend_footprint_ttl_operation.dart +++ b/lib/src/extend_footprint_ttl_operation.dart @@ -20,31 +20,33 @@ class ExtendFootprintTTLOperation extends Operation { @override XdrOperationBody toOperationBody() { XdrOperationBody body = - XdrOperationBody(XdrOperationType.EXTEND_FOOTPRINT_TTL); - body.bumpExpirationOp = XdrExtendFootprintTTLOp(XdrExtensionPoint(0), XdrUint32(this._extendTo)); + XdrOperationBody(XdrOperationType.EXTEND_FOOTPRINT_TTL); + body.bumpExpirationOp = XdrExtendFootprintTTLOp( + XdrExtensionPoint(0), XdrUint32(this._extendTo)); return body; } - static ExtendFootrintTTLOperationBuilder builder(XdrExtendFootprintTTLOp op) { - return ExtendFootrintTTLOperationBuilder(op.extendTo.uint32); + static ExtendFootprintTTLOperationBuilder builder( + XdrExtendFootprintTTLOp op) { + return ExtendFootprintTTLOperationBuilder(op.extendTo.uint32); } } -class ExtendFootrintTTLOperationBuilder { +class ExtendFootprintTTLOperationBuilder { int _extendTo; MuxedAccount? _mSourceAccount; - ExtendFootrintTTLOperationBuilder(this._extendTo); + ExtendFootprintTTLOperationBuilder(this._extendTo); /// Sets the source account for this operation represented by [sourceAccountId]. - ExtendFootrintTTLOperationBuilder setSourceAccount(String sourceAccountId) { + ExtendFootprintTTLOperationBuilder setSourceAccount(String sourceAccountId) { MuxedAccount? sa = MuxedAccount.fromAccountId(sourceAccountId); _mSourceAccount = checkNotNull(sa, "invalid sourceAccountId"); return this; } /// Sets the muxed source account for this operation represented by [sourceAccount]. - ExtendFootrintTTLOperationBuilder setMuxedSourceAccount( + ExtendFootprintTTLOperationBuilder setMuxedSourceAccount( MuxedAccount sourceAccount) { _mSourceAccount = sourceAccount; return this; @@ -52,7 +54,8 @@ class ExtendFootrintTTLOperationBuilder { ///Builds an operation ExtendFootprintTTLOperation build() { - ExtendFootprintTTLOperation operation = ExtendFootprintTTLOperation(_extendTo); + ExtendFootprintTTLOperation operation = + ExtendFootprintTTLOperation(_extendTo); if (_mSourceAccount != null) { operation.sourceAccount = _mSourceAccount; } diff --git a/lib/src/invoke_host_function_operation.dart b/lib/src/invoke_host_function_operation.dart index 7db719c..02865d8 100644 --- a/lib/src/invoke_host_function_operation.dart +++ b/lib/src/invoke_host_function_operation.dart @@ -57,7 +57,7 @@ abstract class HostFunction { wasmId, salt: xdr.createContract!.contractIDPreimage.salt!); } else if (xdr.createContract!.executable.type == - XdrContractExecutableType.CONTRACT_EXECUTABLE_TOKEN) { + XdrContractExecutableType.CONTRACT_EXECUTABLE_STELLAR_ASSET) { return DeploySACWithSourceAccountHostFunction( Address.fromXdr( xdr.createContract!.contractIDPreimage.address!), @@ -66,7 +66,7 @@ abstract class HostFunction { } else if (xdr.createContract!.contractIDPreimage.type == XdrContractIDPreimageType.CONTRACT_ID_PREIMAGE_FROM_ASSET && xdr.createContract!.executable.type == - XdrContractExecutableType.CONTRACT_EXECUTABLE_TOKEN) { + XdrContractExecutableType.CONTRACT_EXECUTABLE_STELLAR_ASSET) { return DeploySACWithAssetHostFunction(Asset.fromXdr( xdr.createContract!.contractIDPreimage.fromAsset!)); } diff --git a/lib/src/operation.dart b/lib/src/operation.dart index f181692..5f6b122 100644 --- a/lib/src/operation.dart +++ b/lib/src/operation.dart @@ -31,7 +31,7 @@ import 'set_trustline_flags_operation.dart'; import 'liquidity_pool_deposit_operation.dart'; import 'liquidity_pool_withdraw_operation.dart'; import 'invoke_host_function_operation.dart'; -import 'bump_footprint_expiration_operation.dart'; +import 'extend_footprint_ttl_operation.dart'; import 'restore_footprint_operation.dart'; /// Abstract class for operations. @@ -207,9 +207,9 @@ abstract class Operation { InvokeHostFunctionOperation.builder(body.invokeHostFunctionOp!) .build(); break; - case XdrOperationType.BUMP_FOOTPRINT_EXPIRATION: + case XdrOperationType.EXTEND_FOOTPRINT_TTL: operation = - BumpFootprintExpirationOperation.builder(body.bumpExpirationOp!) + ExtendFootprintTTLOperation.builder(body.bumpExpirationOp!) .build(); break; case XdrOperationType.RESTORE_FOOTPRINT: diff --git a/lib/src/responses/operations/operation_responses.dart b/lib/src/responses/operations/operation_responses.dart index c4f69ed..cc63ee4 100644 --- a/lib/src/responses/operations/operation_responses.dart +++ b/lib/src/responses/operations/operation_responses.dart @@ -20,7 +20,7 @@ import 'clawback_operations_responses.dart'; import 'set_trustline_flags_operation_response.dart'; import 'liquidity_pool_operations_responses.dart'; import 'invoke_host_function_operation_response.dart'; -import 'bump_footprint_expiration_operation_response.dart'; +import 'extend_footprint_ttl_operation_response.dart'; import 'restore_footprint_operation_response.dart'; /// Abstract class for operation responses. @@ -94,7 +94,7 @@ abstract class OperationResponse extends Response { case 24: return InvokeHostFunctionOperationResponse.fromJson(json); case 25: - return BumpFootprintExpirationOperationResponse.fromJson(json); + return ExtendFootprintTTLOperationResponse.fromJson(json); case 26: return RestoreFootprintOperationResponse.fromJson(json); default: diff --git a/lib/src/soroban/soroban_server.dart b/lib/src/soroban/soroban_server.dart index d7b7648..d22be9c 100644 --- a/lib/src/soroban/soroban_server.dart +++ b/lib/src/soroban/soroban_server.dart @@ -37,7 +37,6 @@ class SorobanServer { /// General node health check request. /// See: https://soroban.stellar.org/api/methods/getHealth Future getHealth() async { - JsonRpcMethod getHealth = JsonRpcMethod("getHealth"); dio.Response response = await _dio.post(_serverUrl, data: json.encode(getHealth), options: dio.Options(headers: _headers)); @@ -50,7 +49,6 @@ class SorobanServer { /// For finding out the current latest known ledger. /// See: https://soroban.stellar.org/api/methods/getLatestLedger Future getLatestLedger() async { - JsonRpcMethod getLatestLedger = JsonRpcMethod("getLatestLedger"); dio.Response response = await _dio.post(_serverUrl, data: json.encode(getLatestLedger), @@ -67,32 +65,31 @@ class SorobanServer { /// This is a backup way to access your contract data which may /// not be available via events or simulateTransaction. /// To fetch contract wasm byte-code, use the ContractCode ledger entry key. - /// See: https://soroban.stellar.org/api/methods/getLedgerEntry - Future getLedgerEntry(String base64EncodedKey) async { - - JsonRpcMethod getLedgerEntry = - JsonRpcMethod("getLedgerEntry", args: {'key': base64EncodedKey}); + /// See: https://soroban.stellar.org/api/methods/getLedgerEntries + Future getLedgerEntries( + List base64EncodedKeys) async { + JsonRpcMethod getLedgerEntries = + JsonRpcMethod("getLedgerEntries", args: {'keys': base64EncodedKeys}); dio.Response response = await _dio.post(_serverUrl, - data: json.encode(getLedgerEntry), + data: json.encode(getLedgerEntries), options: dio.Options(headers: _headers)); if (enableLogging) { - print("getLedgerEntry response: $response"); + print("getLedgerEntries response: $response"); } - return GetLedgerEntryResponse.fromJson(response.data); + return GetLedgerEntriesResponse.fromJson(response.data); } /// Loads the contract source code (including source code - wasm bytes) for a given wasm id. Future loadContractCodeForWasmId(String wasmId) async { XdrLedgerKey ledgerKey = XdrLedgerKey(XdrLedgerEntryType.CONTRACT_CODE); - ledgerKey.contractCode = XdrLedgerKeyContractCode( - XdrHash(Util.hexToBytes(wasmId))); - GetLedgerEntryResponse ledgerEntryResponse = - await getLedgerEntry(ledgerKey.toBase64EncodedXdrString()); - if (ledgerEntryResponse.ledgerEntryData != null) { - XdrLedgerEntryData ledgerEntryData = - XdrLedgerEntryData.fromBase64EncodedXdrString( - ledgerEntryResponse.ledgerEntryData!); - return ledgerEntryData.contractCode; + ledgerKey.contractCode = + XdrLedgerKeyContractCode(XdrHash(Util.hexToBytes(wasmId))); + GetLedgerEntriesResponse ledgerEntriesResponse = + await getLedgerEntries([ledgerKey.toBase64EncodedXdrString()]); + + if (ledgerEntriesResponse.entries != null && + ledgerEntriesResponse.entries!.length > 0) { + return ledgerEntriesResponse.entries![0].ledgerEntryDataXdr.contractCode; } return null; } @@ -106,15 +103,14 @@ class SorobanServer { XdrSCVal.forLedgerKeyContractInstance(), XdrContractDataDurability.PERSISTENT); - GetLedgerEntryResponse ledgerEntryResponse = - await getLedgerEntry(ledgerKey.toBase64EncodedXdrString()); - if (ledgerEntryResponse.ledgerEntryData != null) { + GetLedgerEntriesResponse ledgerEntriesResponse = + await getLedgerEntries([ledgerKey.toBase64EncodedXdrString()]); + if (ledgerEntriesResponse.entries != null && + ledgerEntriesResponse.entries!.length > 0) { XdrLedgerEntryData ledgerEntryData = - XdrLedgerEntryData.fromBase64EncodedXdrString( - ledgerEntryResponse.ledgerEntryData!); + ledgerEntriesResponse.entries![0].ledgerEntryDataXdr; if (ledgerEntryData.contractData != null && - ledgerEntryData - .contractData?.val.instance?.executable.wasmHash != + ledgerEntryData.contractData?.val.instance?.executable.wasmHash != null) { String wasmId = Util.bytesToHex(ledgerEntryData .contractData!.val.instance!.executable.wasmHash!.hash); @@ -127,7 +123,6 @@ class SorobanServer { /// General info about the currently configured network. /// See: https://soroban.stellar.org/api/methods/getNetwork Future getNetwork() async { - JsonRpcMethod getNetwork = JsonRpcMethod("getNetwork"); dio.Response response = await _dio.post(_serverUrl, data: json.encode(getNetwork), options: dio.Options(headers: _headers)); @@ -142,7 +137,6 @@ class SorobanServer { /// See: https://soroban.stellar.org/api/methods/simulateTransaction Future simulateTransaction( Transaction transaction) async { - String transactionEnvelopeXdr = transaction.toEnvelopeXdrBase64(); JsonRpcMethod getAccount = @@ -165,7 +159,6 @@ class SorobanServer { /// See: https://soroban.stellar.org/api/methods/sendTransaction Future sendTransaction( Transaction transaction) async { - String transactionEnvelopeXdr = transaction.toEnvelopeXdrBase64(); JsonRpcMethod getAccount = @@ -181,7 +174,6 @@ class SorobanServer { /// Clients will poll this to tell when the transaction has been completed. /// See: https://soroban.stellar.org/api/methods/getTransaction Future getTransaction(String transactionHash) async { - JsonRpcMethod getTransactionStatus = JsonRpcMethod("getTransaction", args: transactionHash); dio.Response response = await _dio.post(_serverUrl, @@ -202,7 +194,6 @@ class SorobanServer { /// By default soroban-rpc retains the most recent 24 hours of events. /// See: https://soroban.stellar.org/api/methods/getEvents Future getEvents(GetEventsRequest request) async { - JsonRpcMethod getEvents = JsonRpcMethod("getEvents", args: request.getRequestArgs()); dio.Response response = await _dio.post(_serverUrl, @@ -296,31 +287,22 @@ class SorobanRpcErrorResponse { } } -/// Response when reading the current values of ledger entries. -/// See: https://soroban.stellar.org/api/methods/getLedgerEntry -class GetLedgerEntryResponse extends SorobanRpcResponse { - /// The current value of the given ledger entry (serialized in a base64 string) - String? ledgerEntryData; - - /// The ledger number of the last time this entry was updated (optional) - String? lastModifiedLedgerSeq; +class GetLedgerEntriesResponse extends SorobanRpcResponse { + /// Entries + List? entries; /// The current latest ledger observed by the node when this response was generated. String? latestLedger; - XdrLedgerEntryData? get ledgerEntryDataXdr => ledgerEntryData == null - ? null - : XdrLedgerEntryData.fromBase64EncodedXdrString(ledgerEntryData!); - - GetLedgerEntryResponse(Map jsonResponse) + GetLedgerEntriesResponse(Map jsonResponse) : super(jsonResponse); - factory GetLedgerEntryResponse.fromJson(Map json) { - GetLedgerEntryResponse response = GetLedgerEntryResponse(json); + factory GetLedgerEntriesResponse.fromJson(Map json) { + GetLedgerEntriesResponse response = GetLedgerEntriesResponse(json); if (json['result'] != null) { - response.ledgerEntryData = json['result']['xdr']; - response.lastModifiedLedgerSeq = json['result']['lastModifiedLedgerSeq']; + response.entries = List.from( + json['result']['entries'].map((e) => LedgerEntry.fromJson(e))); response.latestLedger = json['result']['latestLedger']; } else if (json['error'] != null) { response.error = SorobanRpcErrorResponse.fromJson(json); @@ -329,6 +311,34 @@ class GetLedgerEntryResponse extends SorobanRpcResponse { } } +class LedgerEntry { + /// The key of the ledger entry (serialized in a base64 string) + String key; + + /// The current value of the given ledger entry (serialized in a base64 string) + String xdr; + + /// The ledger number of the last time this entry was updated (optional) + String lastModifiedLedgerSeq; + + /// The ledger sequence number after which the ledger entry would expire. This field exists only for ContractCodeEntry and ContractDataEntry ledger entries (optional). + String? expirationLedgerSeq; + + XdrLedgerEntryData get ledgerEntryDataXdr => + XdrLedgerEntryData.fromBase64EncodedXdrString(xdr); + + LedgerEntry( + this.key, this.xdr, this.lastModifiedLedgerSeq, this.expirationLedgerSeq); + + factory LedgerEntry.fromJson(Map json) { + String key = json['key']; + String xdr = json['xdr']; + String lastModifiedLedgerSeq = json['lastModifiedLedgerSeq']; + String? expirationLedgerSeq = json['expirationLedgerSeq']; + return LedgerEntry(key, xdr, lastModifiedLedgerSeq, expirationLedgerSeq); + } +} + /// See: https://soroban.stellar.org/api/methods/getNetwork class GetNetworkResponse extends SorobanRpcResponse { String? friendbotUrl; @@ -356,25 +366,22 @@ class GetNetworkResponse extends SorobanRpcResponse { /// The minResourceFee and transactionData fields should be used to construct the transaction /// containing the RestoreFootprint operation. class RestorePreamble { - /// The recommended Soroban Transaction Data to use when submitting the RestoreFootprint operation. XdrSorobanTransactionData transactionData; /// Recommended minimum resource fee to add when submitting the RestoreFootprint operation. This fee is to be added on top of the Stellar network fee. int minResourceFee; - RestorePreamble(this.transactionData, this.minResourceFee); factory RestorePreamble.fromJson(Map json) { - - XdrSorobanTransactionData transactionData = XdrSorobanTransactionData.fromBase64EncodedXdrString( - json['transactionData']); + XdrSorobanTransactionData transactionData = + XdrSorobanTransactionData.fromBase64EncodedXdrString( + json['transactionData']); int minResourceFee = convertInt(json['minResourceFee'])!; return RestorePreamble(transactionData, minResourceFee); } - } /// Response that will be received when submitting a trial contract invocation. @@ -441,7 +448,8 @@ class SimulateTransactionResponse extends SorobanRpcResponse { } if (json['restorePreamble'] != null) { - response.restorePreamble = RestorePreamble.fromJson(json['restorePreamble']); + response.restorePreamble = + RestorePreamble.fromJson(json['restorePreamble']); } response.minResourceFee = convertInt(json['result']['minResourceFee']); @@ -823,26 +831,23 @@ class EventInfo { String id; String paginationToken; List topic; - EventInfoValue value; + String value; EventInfo(this.type, this.ledger, this.ledgerCloseAt, this.contractId, this.id, this.paginationToken, this.topic, this.value); factory EventInfo.fromJson(Map json) { List topic = List.from(json['topic'].map((e) => e)); - EventInfoValue value = EventInfoValue.fromJson(json['value']); - return EventInfo(json['type'], json['ledger'], json['ledgerClosedAt'], - json['contractId'], json['id'], json['pagingToken'], topic, value); - } -} + String value = ""; -class EventInfoValue { - String xdr; - - EventInfoValue(this.xdr); + if (json['value'] is Map) { + value = json['value']['xdr']; + } else { + value = json['value']; + } - factory EventInfoValue.fromJson(Map json) { - return EventInfoValue(json['xdr']); + return EventInfo(json['type'], json['ledger'], json['ledgerClosedAt'], + json['contractId'], json['id'], json['pagingToken'], topic, value); } } diff --git a/lib/src/stellar_sdk.dart b/lib/src/stellar_sdk.dart index f60d466..6de3455 100644 --- a/lib/src/stellar_sdk.dart +++ b/lib/src/stellar_sdk.dart @@ -31,7 +31,7 @@ import 'requests/liquidity_pools_request_builder.dart'; /// Main class of the flutter stellar sdk. class StellarSDK { - static const versionNumber = "1.6.5"; + static const versionNumber = "1.6.6"; static final StellarSDK PUBLIC = StellarSDK("https://horizon.stellar.org"); static final StellarSDK TESTNET = StellarSDK("https://horizon-testnet.stellar.org"); diff --git a/lib/src/xdr/xdr_contract.dart b/lib/src/xdr/xdr_contract.dart index fa1f8b3..afb28ae 100644 --- a/lib/src/xdr/xdr_contract.dart +++ b/lib/src/xdr/xdr_contract.dart @@ -604,7 +604,7 @@ class XdrContractExecutableType { static const CONTRACT_EXECUTABLE_WASM = const XdrContractExecutableType._internal(0); - static const CONTRACT_EXECUTABLE_TOKEN = + static const CONTRACT_EXECUTABLE_STELLAR_ASSET = const XdrContractExecutableType._internal(1); static XdrContractExecutableType decode(XdrDataInputStream stream) { @@ -613,7 +613,7 @@ class XdrContractExecutableType { case 0: return CONTRACT_EXECUTABLE_WASM; case 1: - return CONTRACT_EXECUTABLE_TOKEN; + return CONTRACT_EXECUTABLE_STELLAR_ASSET; default: throw Exception("Unknown enum value: $value"); } @@ -642,7 +642,7 @@ class XdrContractExecutable { case XdrContractExecutableType.CONTRACT_EXECUTABLE_WASM: XdrHash.encode(stream, encoded.wasmHash!); break; - case XdrContractExecutableType.CONTRACT_EXECUTABLE_TOKEN: + case XdrContractExecutableType.CONTRACT_EXECUTABLE_STELLAR_ASSET: break; } } @@ -654,7 +654,7 @@ class XdrContractExecutable { case XdrContractExecutableType.CONTRACT_EXECUTABLE_WASM: decoded.wasmHash = XdrHash.decode(stream); break; - case XdrContractExecutableType.CONTRACT_EXECUTABLE_TOKEN: + case XdrContractExecutableType.CONTRACT_EXECUTABLE_STELLAR_ASSET: break; } return decoded; @@ -2415,7 +2415,7 @@ class XdrHostFunction { cId.address = address; cId.salt = salt; XdrContractExecutable cCode = XdrContractExecutable( - XdrContractExecutableType.CONTRACT_EXECUTABLE_TOKEN); + XdrContractExecutableType.CONTRACT_EXECUTABLE_STELLAR_ASSET); result.createContract = XdrCreateContractArgs(cId, cCode); return result; } @@ -2427,7 +2427,7 @@ class XdrHostFunction { XdrContractIDPreimageType.CONTRACT_ID_PREIMAGE_FROM_ASSET); cId.fromAsset = fromAsset; XdrContractExecutable cCode = XdrContractExecutable( - XdrContractExecutableType.CONTRACT_EXECUTABLE_TOKEN); + XdrContractExecutableType.CONTRACT_EXECUTABLE_STELLAR_ASSET); result.createContract = XdrCreateContractArgs(cId, cCode); return result; } @@ -2463,7 +2463,7 @@ class XdrInvokeHostFunctionResultCode { static const INVOKE_HOST_FUNCTION_RESOURCE_LIMIT_EXCEEDED = const XdrInvokeHostFunctionResultCode._internal(-3); - static const INVOKE_HOST_FUNCTION_ENTRY_EXPIRED = + static const INVOKE_HOST_FUNCTION_ENTRY_ARCHIVED = const XdrInvokeHostFunctionResultCode._internal(-4); static const INVOKE_HOST_FUNCTION_INSUFFICIENT_REFUNDABLE_FEE = @@ -2481,7 +2481,7 @@ class XdrInvokeHostFunctionResultCode { case -3: return INVOKE_HOST_FUNCTION_RESOURCE_LIMIT_EXCEEDED; case -4: - return INVOKE_HOST_FUNCTION_ENTRY_EXPIRED; + return INVOKE_HOST_FUNCTION_ENTRY_ARCHIVED; case -5: return INVOKE_HOST_FUNCTION_INSUFFICIENT_REFUNDABLE_FEE; default: @@ -2517,7 +2517,7 @@ class XdrInvokeHostFunctionResult { case XdrInvokeHostFunctionResultCode.INVOKE_HOST_FUNCTION_TRAPPED: case XdrInvokeHostFunctionResultCode .INVOKE_HOST_FUNCTION_RESOURCE_LIMIT_EXCEEDED: - case XdrInvokeHostFunctionResultCode.INVOKE_HOST_FUNCTION_ENTRY_EXPIRED: + case XdrInvokeHostFunctionResultCode.INVOKE_HOST_FUNCTION_ENTRY_ARCHIVED: case XdrInvokeHostFunctionResultCode .INVOKE_HOST_FUNCTION_INSUFFICIENT_REFUNDABLE_FEE: break; @@ -2537,7 +2537,7 @@ class XdrInvokeHostFunctionResult { case XdrInvokeHostFunctionResultCode.INVOKE_HOST_FUNCTION_TRAPPED: case XdrInvokeHostFunctionResultCode .INVOKE_HOST_FUNCTION_RESOURCE_LIMIT_EXCEEDED: - case XdrInvokeHostFunctionResultCode.INVOKE_HOST_FUNCTION_ENTRY_EXPIRED: + case XdrInvokeHostFunctionResultCode.INVOKE_HOST_FUNCTION_ENTRY_ARCHIVED: case XdrInvokeHostFunctionResultCode .INVOKE_HOST_FUNCTION_INSUFFICIENT_REFUNDABLE_FEE: break; @@ -2548,86 +2548,86 @@ class XdrInvokeHostFunctionResult { } } -class XdrBumpFootprintExpirationResultCode { +class XdrExtendFootprintTTLResultCode { final _value; - const XdrBumpFootprintExpirationResultCode._internal(this._value); - toString() => 'BumpFootprintExpirationResultCode.$_value'; - XdrBumpFootprintExpirationResultCode(this._value); + const XdrExtendFootprintTTLResultCode._internal(this._value); + toString() => 'ExtendFootprintTTLResultCode.$_value'; + XdrExtendFootprintTTLResultCode(this._value); get value => this._value; /// Success - static const BUMP_FOOTPRINT_EXPIRATION_SUCCESS = - const XdrBumpFootprintExpirationResultCode._internal(0); + static const EXTEND_FOOTPRINT_TTL_SUCCESS = + const XdrExtendFootprintTTLResultCode._internal(0); // codes considered as "failure" for the operation - static const BUMP_FOOTPRINT_EXPIRATION_MALFORMED = - const XdrBumpFootprintExpirationResultCode._internal(-1); - static const BUMP_FOOTPRINT_EXPIRATION_RESOURCE_LIMIT_EXCEEDED = - const XdrBumpFootprintExpirationResultCode._internal(-2); - static const BUMP_FOOTPRINT_EXPIRATION_INSUFFICIENT_REFUNDABLE_FEE = - const XdrBumpFootprintExpirationResultCode._internal(-3); - - static XdrBumpFootprintExpirationResultCode decode( + static const EXTEND_FOOTPRINT_TTL_MALFORMED = + const XdrExtendFootprintTTLResultCode._internal(-1); + static const EXTEND_FOOTPRINT_TTL_RESOURCE_LIMIT_EXCEEDED = + const XdrExtendFootprintTTLResultCode._internal(-2); + static const EXTEND_FOOTPRINT_TTL_INSUFFICIENT_REFUNDABLE_FEE = + const XdrExtendFootprintTTLResultCode._internal(-3); + + static XdrExtendFootprintTTLResultCode decode( XdrDataInputStream stream) { int value = stream.readInt(); switch (value) { case 0: - return BUMP_FOOTPRINT_EXPIRATION_SUCCESS; + return EXTEND_FOOTPRINT_TTL_SUCCESS; case -1: - return BUMP_FOOTPRINT_EXPIRATION_MALFORMED; + return EXTEND_FOOTPRINT_TTL_MALFORMED; case -2: - return BUMP_FOOTPRINT_EXPIRATION_RESOURCE_LIMIT_EXCEEDED; + return EXTEND_FOOTPRINT_TTL_RESOURCE_LIMIT_EXCEEDED; case -3: - return BUMP_FOOTPRINT_EXPIRATION_INSUFFICIENT_REFUNDABLE_FEE; + return EXTEND_FOOTPRINT_TTL_INSUFFICIENT_REFUNDABLE_FEE; default: throw Exception("Unknown enum value: $value"); } } static void encode( - XdrDataOutputStream stream, XdrBumpFootprintExpirationResultCode value) { + XdrDataOutputStream stream, XdrExtendFootprintTTLResultCode value) { stream.writeInt(value.value); } } -class XdrBumpFootprintExpirationResult { - XdrBumpFootprintExpirationResultCode _code; - XdrBumpFootprintExpirationResultCode get discriminant => this._code; - set discriminant(XdrBumpFootprintExpirationResultCode value) => +class XdrExtendFootprintTTLResult { + XdrExtendFootprintTTLResultCode _code; + XdrExtendFootprintTTLResultCode get discriminant => this._code; + set discriminant(XdrExtendFootprintTTLResultCode value) => this._code = value; - XdrBumpFootprintExpirationResult(this._code); + XdrExtendFootprintTTLResult(this._code); static void encode( - XdrDataOutputStream stream, XdrBumpFootprintExpirationResult encoded) { + XdrDataOutputStream stream, XdrExtendFootprintTTLResult encoded) { stream.writeInt(encoded.discriminant.value); switch (encoded.discriminant) { - case XdrBumpFootprintExpirationResultCode - .BUMP_FOOTPRINT_EXPIRATION_SUCCESS: - case XdrBumpFootprintExpirationResultCode - .BUMP_FOOTPRINT_EXPIRATION_MALFORMED: - case XdrBumpFootprintExpirationResultCode - .BUMP_FOOTPRINT_EXPIRATION_RESOURCE_LIMIT_EXCEEDED: - case XdrBumpFootprintExpirationResultCode - .BUMP_FOOTPRINT_EXPIRATION_INSUFFICIENT_REFUNDABLE_FEE: + case XdrExtendFootprintTTLResultCode + .EXTEND_FOOTPRINT_TTL_SUCCESS: + case XdrExtendFootprintTTLResultCode + .EXTEND_FOOTPRINT_TTL_MALFORMED: + case XdrExtendFootprintTTLResultCode + .EXTEND_FOOTPRINT_TTL_RESOURCE_LIMIT_EXCEEDED: + case XdrExtendFootprintTTLResultCode + .EXTEND_FOOTPRINT_TTL_INSUFFICIENT_REFUNDABLE_FEE: break; default: break; } } - static XdrBumpFootprintExpirationResult decode(XdrDataInputStream stream) { - XdrBumpFootprintExpirationResult decoded = XdrBumpFootprintExpirationResult( - XdrBumpFootprintExpirationResultCode.decode(stream)); + static XdrExtendFootprintTTLResult decode(XdrDataInputStream stream) { + XdrExtendFootprintTTLResult decoded = XdrExtendFootprintTTLResult( + XdrExtendFootprintTTLResultCode.decode(stream)); switch (decoded.discriminant) { - case XdrBumpFootprintExpirationResultCode - .BUMP_FOOTPRINT_EXPIRATION_SUCCESS: - case XdrBumpFootprintExpirationResultCode - .BUMP_FOOTPRINT_EXPIRATION_MALFORMED: - case XdrBumpFootprintExpirationResultCode - .BUMP_FOOTPRINT_EXPIRATION_RESOURCE_LIMIT_EXCEEDED: - case XdrBumpFootprintExpirationResultCode - .BUMP_FOOTPRINT_EXPIRATION_INSUFFICIENT_REFUNDABLE_FEE: + case XdrExtendFootprintTTLResultCode + .EXTEND_FOOTPRINT_TTL_SUCCESS: + case XdrExtendFootprintTTLResultCode + .EXTEND_FOOTPRINT_TTL_MALFORMED: + case XdrExtendFootprintTTLResultCode + .EXTEND_FOOTPRINT_TTL_RESOURCE_LIMIT_EXCEEDED: + case XdrExtendFootprintTTLResultCode + .EXTEND_FOOTPRINT_TTL_INSUFFICIENT_REFUNDABLE_FEE: break; default: break; @@ -2804,25 +2804,25 @@ class XdrInvokeHostFunctionOp { } } -class XdrBumpFootprintExpirationOp { +class XdrExtendFootprintTTLOp { XdrExtensionPoint _ext; XdrExtensionPoint get ext => this._ext; set ext(XdrExtensionPoint value) => this._ext = value; - XdrUint32 _ledgersToExpire; - XdrUint32 get ledgersToExpire => this._ledgersToExpire; - set ledgersToExpire(XdrUint32 value) => this._ledgersToExpire = value; + XdrUint32 _extendTo; + XdrUint32 get extendTo => this._extendTo; + set extendTo(XdrUint32 value) => this._extendTo = value; - XdrBumpFootprintExpirationOp(this._ext, this._ledgersToExpire); + XdrExtendFootprintTTLOp(this._ext, this._extendTo); static void encode( - XdrDataOutputStream stream, XdrBumpFootprintExpirationOp encoded) { + XdrDataOutputStream stream, XdrExtendFootprintTTLOp encoded) { XdrExtensionPoint.encode(stream, encoded.ext); - XdrUint32.encode(stream, encoded.ledgersToExpire); + XdrUint32.encode(stream, encoded.extendTo); } - static XdrBumpFootprintExpirationOp decode(XdrDataInputStream stream) { - return XdrBumpFootprintExpirationOp( + static XdrExtendFootprintTTLOp decode(XdrDataInputStream stream) { + return XdrExtendFootprintTTLOp( XdrExtensionPoint.decode(stream), XdrUint32.decode(stream)); } } diff --git a/lib/src/xdr/xdr_ledger.dart b/lib/src/xdr/xdr_ledger.dart index b669b17..6a8f55a 100644 --- a/lib/src/xdr/xdr_ledger.dart +++ b/lib/src/xdr/xdr_ledger.dart @@ -79,7 +79,7 @@ class XdrLedgerEntryType { static const CONTRACT_DATA = const XdrLedgerEntryType._internal(6); static const CONTRACT_CODE = const XdrLedgerEntryType._internal(7); static const CONFIG_SETTING = const XdrLedgerEntryType._internal(8); - static const EXPIRATION = const XdrLedgerEntryType._internal(9); + static const TTL = const XdrLedgerEntryType._internal(9); static XdrLedgerEntryType decode(XdrDataInputStream stream) { int value = stream.readInt(); @@ -103,7 +103,7 @@ class XdrLedgerEntryType { case 8: return CONFIG_SETTING; case 9: - return EXPIRATION; + return TTL; default: throw Exception("Unknown enum value: $value"); } @@ -881,21 +881,21 @@ class XdrLedgerKeyContractCode { } } -class XdrLedgerKeyExpiration { +class XdrLedgerKeyTTL { XdrHash _hashKey; XdrHash get hashKey => this._hashKey; set hash(XdrHash value) => this._hashKey = value; - XdrLedgerKeyExpiration(this._hashKey); + XdrLedgerKeyTTL(this._hashKey); static void encode( - XdrDataOutputStream stream, XdrLedgerKeyExpiration encoded) { + XdrDataOutputStream stream, XdrLedgerKeyTTL encoded) { XdrHash.encode(stream, encoded.hashKey); } - static XdrLedgerKeyExpiration decode(XdrDataInputStream stream) { - XdrLedgerKeyExpiration decoded = - XdrLedgerKeyExpiration(XdrHash.decode(stream)); + static XdrLedgerKeyTTL decode(XdrDataInputStream stream) { + XdrLedgerKeyTTL decoded = + XdrLedgerKeyTTL(XdrHash.decode(stream)); return decoded; } } @@ -945,9 +945,9 @@ class XdrLedgerKey { set contractCode(XdrLedgerKeyContractCode? value) => this._contractCode = value; - XdrLedgerKeyExpiration? _expiration; - XdrLedgerKeyExpiration? get expiration => this._expiration; - set expiration(XdrLedgerKeyExpiration? value) => this._expiration = value; + XdrLedgerKeyTTL? _ttl; + XdrLedgerKeyTTL? get ttl => this._ttl; + set ttl(XdrLedgerKeyTTL? value) => this._ttl = value; static void encode( XdrDataOutputStream stream, XdrLedgerKey encodedLedgerKey) { @@ -980,8 +980,8 @@ class XdrLedgerKey { case XdrLedgerEntryType.CONFIG_SETTING: XdrConfigSettingID.encode(stream, encodedLedgerKey.configSetting!); break; - case XdrLedgerEntryType.EXPIRATION: - XdrLedgerKeyExpiration.encode(stream, encodedLedgerKey.expiration!); + case XdrLedgerEntryType.TTL: + XdrLedgerKeyTTL.encode(stream, encodedLedgerKey.ttl!); break; } } @@ -1017,8 +1017,8 @@ class XdrLedgerKey { case XdrLedgerEntryType.CONFIG_SETTING: decodedLedgerKey.configSetting = XdrConfigSettingID.decode(stream); break; - case XdrLedgerEntryType.EXPIRATION: - decodedLedgerKey.expiration = XdrLedgerKeyExpiration.decode(stream); + case XdrLedgerEntryType.TTL: + decodedLedgerKey.ttl = XdrLedgerKeyTTL.decode(stream); break; } return decodedLedgerKey; @@ -1404,9 +1404,9 @@ class XdrLedgerEntryData { set configSetting(XdrConfigSettingEntry? value) => this._configSetting = value; - XdrExpirationEntry? _expiration; - XdrExpirationEntry? get expiration => this._expiration; - set expiration(XdrExpirationEntry? value) => this._expiration = value; + XdrTTLEntry? _expiration; + XdrTTLEntry? get expiration => this._expiration; + set expiration(XdrTTLEntry? value) => this._expiration = value; static void encode( XdrDataOutputStream stream, XdrLedgerEntryData encodedLedgerEntryData) { @@ -1444,8 +1444,8 @@ class XdrLedgerEntryData { XdrConfigSettingEntry.encode( stream, encodedLedgerEntryData.configSetting!); break; - case XdrLedgerEntryType.EXPIRATION: - XdrExpirationEntry.encode(stream, encodedLedgerEntryData.expiration!); + case XdrLedgerEntryType.TTL: + XdrTTLEntry.encode(stream, encodedLedgerEntryData.expiration!); break; } } @@ -1486,8 +1486,8 @@ class XdrLedgerEntryData { decodedLedgerEntryData.configSetting = XdrConfigSettingEntry.decode(stream); break; - case XdrLedgerEntryType.EXPIRATION: - decodedLedgerEntryData.expiration = XdrExpirationEntry.decode(stream); + case XdrLedgerEntryType.TTL: + decodedLedgerEntryData.expiration = XdrTTLEntry.decode(stream); break; } return decodedLedgerEntryData; @@ -2030,24 +2030,24 @@ class XdrContractDataEntry { } } -class XdrExpirationEntry { +class XdrTTLEntry { XdrHash _keyHash; XdrHash get keyHash => this._keyHash; set keyHash(XdrHash value) => this._keyHash = value; - XdrUint32 _expirationLedgerSeq; - XdrUint32 get expirationLedgerSeq => this._expirationLedgerSeq; - set expirationLedgerSeq(XdrUint32 value) => this._expirationLedgerSeq = value; + XdrUint32 _liveUntilLedgerSeq; + XdrUint32 get liveUntilLedgerSeq => this._liveUntilLedgerSeq; + set liveUntilLedgerSeq(XdrUint32 value) => this._liveUntilLedgerSeq = value; - XdrExpirationEntry(this._keyHash, this._expirationLedgerSeq); + XdrTTLEntry(this._keyHash, this._liveUntilLedgerSeq); - static void encode(XdrDataOutputStream stream, XdrExpirationEntry encoded) { + static void encode(XdrDataOutputStream stream, XdrTTLEntry encoded) { XdrHash.encode(stream, encoded.keyHash); - XdrUint32.encode(stream, encoded.expirationLedgerSeq); + XdrUint32.encode(stream, encoded.liveUntilLedgerSeq); } - static XdrExpirationEntry decode(XdrDataInputStream stream) { - return XdrExpirationEntry(XdrHash.decode(stream), XdrUint32.decode(stream)); + static XdrTTLEntry decode(XdrDataInputStream stream) { + return XdrTTLEntry(XdrHash.decode(stream), XdrUint32.decode(stream)); } } @@ -2106,7 +2106,7 @@ class XdrConfigSettingID { const XdrConfigSettingID._internal(8); static const CONFIG_SETTING_CONTRACT_DATA_ENTRY_SIZE_BYTES = const XdrConfigSettingID._internal(9); - static const CONFIG_SETTING_STATE_EXPIRATION = + static const CONFIG_SETTING_STATE_ARCHIVAL = const XdrConfigSettingID._internal(10); static const CONFIG_SETTING_CONTRACT_EXECUTION_LANES = const XdrConfigSettingID._internal(11); @@ -2139,7 +2139,7 @@ class XdrConfigSettingID { case 9: return CONFIG_SETTING_CONTRACT_DATA_ENTRY_SIZE_BYTES; case 10: - return CONFIG_SETTING_STATE_EXPIRATION; + return CONFIG_SETTING_STATE_ARCHIVAL; case 11: return CONFIG_SETTING_CONTRACT_EXECUTION_LANES; case 12: @@ -2156,21 +2156,21 @@ class XdrConfigSettingID { } } -class XdrStateExpirationSettings { - XdrUint32 _maxEntryExpiration; - XdrUint32 get maxEntryExpiration => this._maxEntryExpiration; - set maxEntryExpiration(XdrUint32 value) => this.maxEntryExpiration = value; +class XdrStateArchivalSettings { + XdrUint32 _maxEntryTTL; + XdrUint32 get maxEntryTTL => this._maxEntryTTL; + set maxEntryTTL(XdrUint32 value) => this.maxEntryTTL = value; - XdrUint32 _minTempEntryExpiration; - XdrUint32 get minTempEntryExpiration => this._minTempEntryExpiration; - set minTempEntryExpiration(XdrUint32 value) => - this._minTempEntryExpiration = value; + XdrUint32 _minTemporaryTTL; + XdrUint32 get minTemporaryTTL => this._minTemporaryTTL; + set minTemporaryTTL(XdrUint32 value) => + this._minTemporaryTTL = value; - XdrUint32 _minPersistentEntryExpiration; - XdrUint32 get minPersistentEntryExpiration => - this._minPersistentEntryExpiration; - set minPersistentEntryExpiration(XdrUint32 value) => - this.minPersistentEntryExpiration = value; + XdrUint32 _minPersistentTTL; + XdrUint32 get minPersistentTTL => + this._minPersistentTTL; + set minPersistentTTL(XdrUint32 value) => + this.minPersistentTTL = value; XdrInt64 _persistentRentRateDenominator; XdrInt64 get persistentRentRateDenominator => @@ -2183,9 +2183,9 @@ class XdrStateExpirationSettings { set tempRentRateDenominator(XdrInt64 value) => this._tempRentRateDenominator = value; - XdrUint32 _maxEntriesToExpire; - XdrUint32 get maxEntriesToExpire => this._maxEntriesToExpire; - set maxEntriesToExpire(XdrUint32 value) => this._maxEntriesToExpire = value; + XdrUint32 _maxEntriesToArchive; + XdrUint32 get maxEntriesToArchive => this._maxEntriesToArchive; + set maxEntriesToArchive(XdrUint32 value) => this._maxEntriesToArchive = value; XdrUint32 _bucketListSizeWindowSampleSize; XdrUint32 get bucketListSizeWindowSampleSize => @@ -2202,48 +2202,48 @@ class XdrStateExpirationSettings { set startingEvictionScanLevel(XdrUint32 value) => this._startingEvictionScanLevel = value; - XdrStateExpirationSettings( - this._maxEntryExpiration, - this._minTempEntryExpiration, - this._minPersistentEntryExpiration, + XdrStateArchivalSettings( + this._maxEntryTTL, + this._minTemporaryTTL, + this._minPersistentTTL, this._persistentRentRateDenominator, this._tempRentRateDenominator, - this._maxEntriesToExpire, + this._maxEntriesToArchive, this._bucketListSizeWindowSampleSize, this._evictionScanSize, this._startingEvictionScanLevel); static void encode( - XdrDataOutputStream stream, XdrStateExpirationSettings encoded) { - XdrUint32.encode(stream, encoded.maxEntryExpiration); - XdrUint32.encode(stream, encoded.minTempEntryExpiration); - XdrUint32.encode(stream, encoded.minPersistentEntryExpiration); + XdrDataOutputStream stream, XdrStateArchivalSettings encoded) { + XdrUint32.encode(stream, encoded.maxEntryTTL); + XdrUint32.encode(stream, encoded.minTemporaryTTL); + XdrUint32.encode(stream, encoded.minPersistentTTL); XdrInt64.encode(stream, encoded.persistentRentRateDenominator); XdrInt64.encode(stream, encoded.tempRentRateDenominator); - XdrUint32.encode(stream, encoded.maxEntriesToExpire); + XdrUint32.encode(stream, encoded.maxEntriesToArchive); XdrUint32.encode(stream, encoded.bucketListSizeWindowSampleSize); XdrUint64.encode(stream, encoded.evictionScanSize); XdrUint32.encode(stream, encoded.startingEvictionScanLevel); } - static XdrStateExpirationSettings decode(XdrDataInputStream stream) { - XdrUint32 maxEntryExpiration = XdrUint32.decode(stream); - XdrUint32 minTempEntryExpiration = XdrUint32.decode(stream); - XdrUint32 minRestorableEntryExpiration = XdrUint32.decode(stream); - XdrInt64 restorableRentRateDenominator = XdrInt64.decode(stream); + static XdrStateArchivalSettings decode(XdrDataInputStream stream) { + XdrUint32 maxEntryTTL = XdrUint32.decode(stream); + XdrUint32 minTemporaryTTL = XdrUint32.decode(stream); + XdrUint32 minPersistentTTL = XdrUint32.decode(stream); + XdrInt64 persistentRentRateDenominator = XdrInt64.decode(stream); XdrInt64 tempRentRateDenominator = XdrInt64.decode(stream); - XdrUint32 maxEntriesToExpire = XdrUint32.decode(stream); + XdrUint32 maxEntriesToArchive = XdrUint32.decode(stream); XdrUint32 bucketListSizeWindowSampleSize = XdrUint32.decode(stream); XdrUint64 evictionScanSize = XdrUint64.decode(stream); XdrUint32 startingEvictionScanLevel = XdrUint32.decode(stream); - return XdrStateExpirationSettings( - maxEntryExpiration, - minTempEntryExpiration, - minRestorableEntryExpiration, - restorableRentRateDenominator, + return XdrStateArchivalSettings( + maxEntryTTL, + minTemporaryTTL, + minPersistentTTL, + persistentRentRateDenominator, tempRentRateDenominator, - maxEntriesToExpire, + maxEntriesToArchive, bucketListSizeWindowSampleSize, evictionScanSize, startingEvictionScanLevel); @@ -2583,36 +2583,30 @@ class XdrContractCostType { get value => this._value; static const WasmInsnExec = const XdrContractCostType._internal(0); - static const WasmMemAlloc = const XdrContractCostType._internal(1); - static const HostMemAlloc = const XdrContractCostType._internal(2); - static const HostMemCpy = const XdrContractCostType._internal(3); - static const HostMemCmp = const XdrContractCostType._internal(4); - static const DispatchHostFunction = const XdrContractCostType._internal(5); - static const VisitObject = const XdrContractCostType._internal(6); - static const ValSer = const XdrContractCostType._internal(7); - static const ValDeser = const XdrContractCostType._internal(8); - static const ComputeSha256Hash = const XdrContractCostType._internal(9); - static const ComputeEd25519PubKey = const XdrContractCostType._internal(10); - static const MapEntry = const XdrContractCostType._internal(11); - static const VecEntry = const XdrContractCostType._internal(12); - static const VerifyEd25519Sig = const XdrContractCostType._internal(13); - static const VmMemRead = const XdrContractCostType._internal(14); - static const VmMemWrite = const XdrContractCostType._internal(15); - static const VmInstantiation = const XdrContractCostType._internal(16); - static const VmCachedInstantiation = const XdrContractCostType._internal(17); - static const InvokeVmFunction = const XdrContractCostType._internal(18); - static const ComputeKeccak256Hash = const XdrContractCostType._internal(19); - static const ComputeEcdsaSecp256k1Key = - const XdrContractCostType._internal(20); + static const MemAlloc = const XdrContractCostType._internal(1); + static const MemCpy = const XdrContractCostType._internal(2); + static const MemCmp = const XdrContractCostType._internal(3); + static const DispatchHostFunction = const XdrContractCostType._internal(4); + static const VisitObject = const XdrContractCostType._internal(5); + static const ValSer = const XdrContractCostType._internal(6); + static const ValDeser = const XdrContractCostType._internal(7); + static const ComputeSha256Hash = const XdrContractCostType._internal(8); + static const ComputeEd25519PubKey = const XdrContractCostType._internal(9); + static const VerifyEd25519Sig = const XdrContractCostType._internal(10); + static const VmInstantiation = const XdrContractCostType._internal(11); + static const VmCachedInstantiation = const XdrContractCostType._internal(12); + static const InvokeVmFunction = const XdrContractCostType._internal(13); + static const ComputeKeccak256Hash = const XdrContractCostType._internal(14); static const ComputeEcdsaSecp256k1Sig = - const XdrContractCostType._internal(21); - static const RecoverEcdsaSecp256k1Key = - const XdrContractCostType._internal(22); - static const Int256AddSub = const XdrContractCostType._internal(23); - static const Int256Mul = const XdrContractCostType._internal(24); - static const Int256Div = const XdrContractCostType._internal(25); - static const Int256Pow = const XdrContractCostType._internal(26); - static const Int256Shift = const XdrContractCostType._internal(27); + const XdrContractCostType._internal(15); + static const ComputeEcdsaSecp256k1Key = + const XdrContractCostType._internal(16); + static const Int256AddSub = const XdrContractCostType._internal(17); + static const Int256Mul = const XdrContractCostType._internal(18); + static const Int256Div = const XdrContractCostType._internal(19); + static const Int256Pow = const XdrContractCostType._internal(20); + static const Int256Shift = const XdrContractCostType._internal(21); + static const ChaCha20DrawBytes = const XdrContractCostType._internal(22); static XdrContractCostType decode(XdrDataInputStream stream) { int value = stream.readInt(); @@ -2620,59 +2614,49 @@ class XdrContractCostType { case 0: return WasmInsnExec; case 1: - return WasmMemAlloc; + return MemAlloc; case 2: - return HostMemAlloc; + return MemCpy; case 3: - return HostMemCpy; + return MemCmp; case 4: - return HostMemCmp; - case 5: return DispatchHostFunction; - case 6: + case 5: return VisitObject; - case 7: + case 6: return ValSer; - case 8: + case 7: return ValDeser; - case 9: + case 8: return ComputeSha256Hash; - case 10: + case 9: return ComputeEd25519PubKey; + case 10: + return VerifyEd25519Sig; case 11: - return MapEntry; + return VmInstantiation; case 12: - return VecEntry; + return VmCachedInstantiation; case 13: - return VerifyEd25519Sig; + return InvokeVmFunction; case 14: - return VmMemRead; + return ComputeKeccak256Hash; case 15: - return VmMemWrite; + return ComputeEcdsaSecp256k1Sig; case 16: - return VmInstantiation; - case 17: - return VmCachedInstantiation; - case 18: - return InvokeVmFunction; - case 19: - return ComputeKeccak256Hash; - case 20: return ComputeEcdsaSecp256k1Key; - case 21: - return ComputeEcdsaSecp256k1Sig; - case 22: - return RecoverEcdsaSecp256k1Key; - case 23: + case 17: return Int256AddSub; - case 24: + case 18: return Int256Mul; - case 25: + case 19: return Int256Div; - case 26: + case 20: return Int256Pow; - case 27: + case 21: return Int256Shift; + case 22: + return ChaCha20DrawBytes; default: throw Exception("Unknown enum value: $value"); } @@ -2803,11 +2787,11 @@ class XdrConfigSettingEntry { set contractDataEntrySizeBytes(XdrUint32? value) => this._contractDataEntrySizeBytes = value; - XdrStateExpirationSettings? _stateExpirationSettings; - XdrStateExpirationSettings? get stateExpirationSettings => - this._stateExpirationSettings; - set stateExpirationSettings(XdrStateExpirationSettings? value) => - this._stateExpirationSettings = value; + XdrStateArchivalSettings? _stateArchivalSettings; + XdrStateArchivalSettings? get stateArchivalSettings => + this._stateArchivalSettings; + set stateArchivalSettings(XdrStateArchivalSettings? value) => + this._stateArchivalSettings = value; XdrConfigSettingContractExecutionLanesV0? _contractExecutionLanes; XdrConfigSettingContractExecutionLanesV0? get contractExecutionLanes => @@ -2869,9 +2853,9 @@ class XdrConfigSettingEntry { case XdrConfigSettingID.CONFIG_SETTING_CONTRACT_DATA_ENTRY_SIZE_BYTES: XdrUint32.encode(stream, encoded.contractDataEntrySizeBytes!); break; - case XdrConfigSettingID.CONFIG_SETTING_STATE_EXPIRATION: - XdrStateExpirationSettings.encode( - stream, encoded.stateExpirationSettings!); + case XdrConfigSettingID.CONFIG_SETTING_STATE_ARCHIVAL: + XdrStateArchivalSettings.encode( + stream, encoded.stateArchivalSettings!); break; case XdrConfigSettingID.CONFIG_SETTING_CONTRACT_EXECUTION_LANES: XdrConfigSettingContractExecutionLanesV0.encode( @@ -2932,9 +2916,9 @@ class XdrConfigSettingEntry { case XdrConfigSettingID.CONFIG_SETTING_CONTRACT_DATA_ENTRY_SIZE_BYTES: decoded.contractDataEntrySizeBytes = XdrUint32.decode(stream); break; - case XdrConfigSettingID.CONFIG_SETTING_STATE_EXPIRATION: - decoded.stateExpirationSettings = - XdrStateExpirationSettings.decode(stream); + case XdrConfigSettingID.CONFIG_SETTING_STATE_ARCHIVAL: + decoded.stateArchivalSettings = + XdrStateArchivalSettings.decode(stream); break; case XdrConfigSettingID.CONFIG_SETTING_CONTRACT_EXECUTION_LANES: decoded.contractExecutionLanes = diff --git a/lib/src/xdr/xdr_operation.dart b/lib/src/xdr/xdr_operation.dart index 13bfb50..02bedd1 100644 --- a/lib/src/xdr/xdr_operation.dart +++ b/lib/src/xdr/xdr_operation.dart @@ -50,7 +50,7 @@ class XdrOperationType { static const LIQUIDITY_POOL_DEPOSIT = const XdrOperationType._internal(22); static const LIQUIDITY_POOL_WITHDRAW = const XdrOperationType._internal(23); static const INVOKE_HOST_FUNCTION = const XdrOperationType._internal(24); - static const BUMP_FOOTPRINT_EXPIRATION = const XdrOperationType._internal(25); + static const EXTEND_FOOTPRINT_TTL = const XdrOperationType._internal(25); static const RESTORE_FOOTPRINT = const XdrOperationType._internal(26); static XdrOperationType decode(XdrDataInputStream stream) { @@ -107,7 +107,7 @@ class XdrOperationType { case 24: return INVOKE_HOST_FUNCTION; case 25: - return BUMP_FOOTPRINT_EXPIRATION; + return EXTEND_FOOTPRINT_TTL; case 26: return RESTORE_FOOTPRINT; default: @@ -284,9 +284,9 @@ class XdrOperationBody { set invokeHostFunctionOp(XdrInvokeHostFunctionOp? value) => this._invokeHostFunctionOp = value; - XdrBumpFootprintExpirationOp? _bumpExpirationOp; - XdrBumpFootprintExpirationOp? get bumpExpirationOp => this._bumpExpirationOp; - set bumpExpirationOp(XdrBumpFootprintExpirationOp? value) => + XdrExtendFootprintTTLOp? _bumpExpirationOp; + XdrExtendFootprintTTLOp? get bumpExpirationOp => this._bumpExpirationOp; + set bumpExpirationOp(XdrExtendFootprintTTLOp? value) => this._bumpExpirationOp = value; XdrRestoreFootprintOp? _restoreFootprintOp; @@ -386,8 +386,8 @@ class XdrOperationBody { XdrInvokeHostFunctionOp.encode( stream, encodedOperationBody.invokeHostFunctionOp!); break; - case XdrOperationType.BUMP_FOOTPRINT_EXPIRATION: - XdrBumpFootprintExpirationOp.encode( + case XdrOperationType.EXTEND_FOOTPRINT_TTL: + XdrExtendFootprintTTLOp.encode( stream, encodedOperationBody.bumpExpirationOp!); break; case XdrOperationType.RESTORE_FOOTPRINT: @@ -489,9 +489,9 @@ class XdrOperationBody { decodedOperationBody.invokeHostFunctionOp = XdrInvokeHostFunctionOp.decode(stream); break; - case XdrOperationType.BUMP_FOOTPRINT_EXPIRATION: + case XdrOperationType.EXTEND_FOOTPRINT_TTL: decodedOperationBody.bumpExpirationOp = - XdrBumpFootprintExpirationOp.decode(stream); + XdrExtendFootprintTTLOp.decode(stream); break; case XdrOperationType.RESTORE_FOOTPRINT: decodedOperationBody.restoreFootprintOp = @@ -696,10 +696,10 @@ class XdrOperationResultTr { set invokeHostFunctionResult(XdrInvokeHostFunctionResult? value) => this._invokeHostFunctionResult = value; - XdrBumpFootprintExpirationResult? _bumpExpirationResult; - XdrBumpFootprintExpirationResult? get bumpExpirationResult => + XdrExtendFootprintTTLResult? _bumpExpirationResult; + XdrExtendFootprintTTLResult? get bumpExpirationResult => this._bumpExpirationResult; - set bumpExpirationResult(XdrBumpFootprintExpirationResult? value) => + set bumpExpirationResult(XdrExtendFootprintTTLResult? value) => this._bumpExpirationResult = value; XdrRestoreFootprintResult? _restoreFootprintResult; @@ -812,8 +812,8 @@ class XdrOperationResultTr { XdrInvokeHostFunctionResult.encode( stream, encodedOperationResultTr.invokeHostFunctionResult!); break; - case XdrOperationType.BUMP_FOOTPRINT_EXPIRATION: - XdrBumpFootprintExpirationResult.encode( + case XdrOperationType.EXTEND_FOOTPRINT_TTL: + XdrExtendFootprintTTLResult.encode( stream, encodedOperationResultTr.bumpExpirationResult!); break; case XdrOperationType.RESTORE_FOOTPRINT: @@ -928,9 +928,9 @@ class XdrOperationResultTr { decodedOperationResultTr.invokeHostFunctionResult = XdrInvokeHostFunctionResult.decode(stream); break; - case XdrOperationType.BUMP_FOOTPRINT_EXPIRATION: + case XdrOperationType.EXTEND_FOOTPRINT_TTL: decodedOperationResultTr.bumpExpirationResult = - XdrBumpFootprintExpirationResult.decode(stream); + XdrExtendFootprintTTLResult.decode(stream); break; case XdrOperationType.RESTORE_FOOTPRINT: decodedOperationResultTr.restoreFootprintResult = diff --git a/lib/src/xdr/xdr_transaction.dart b/lib/src/xdr/xdr_transaction.dart index f44b880..b939035 100644 --- a/lib/src/xdr/xdr_transaction.dart +++ b/lib/src/xdr/xdr_transaction.dart @@ -810,24 +810,24 @@ class XdrSorobanTransactionData { XdrSorobanResources get resources => this._resources; set resources(XdrSorobanResources value) => this._resources = value; - XdrInt64 _refundableFee; - XdrInt64 get refundableFee => this._refundableFee; - set refundableFee(XdrInt64 value) => this._refundableFee = value; + XdrInt64 _resourceFee; + XdrInt64 get resourceFee => this._resourceFee; + set resourceFee(XdrInt64 value) => this._resourceFee = value; - XdrSorobanTransactionData(this._ext, this._resources, this._refundableFee); + XdrSorobanTransactionData(this._ext, this._resources, this._resourceFee); static void encode( XdrDataOutputStream stream, XdrSorobanTransactionData encoded) { XdrExtensionPoint.encode(stream, encoded.ext); XdrSorobanResources.encode(stream, encoded.resources); - XdrInt64.encode(stream, encoded.refundableFee); + XdrInt64.encode(stream, encoded.resourceFee); } static XdrSorobanTransactionData decode(XdrDataInputStream stream) { XdrExtensionPoint ext = XdrExtensionPoint.decode(stream); XdrSorobanResources resources = XdrSorobanResources.decode(stream); - XdrInt64 refundableFee = XdrInt64.decode(stream); - return XdrSorobanTransactionData(ext, resources, refundableFee); + XdrInt64 resourceFee = XdrInt64.decode(stream); + return XdrSorobanTransactionData(ext, resources, resourceFee); } String toBase64EncodedXdrString() { diff --git a/lib/stellar_flutter_sdk.dart b/lib/stellar_flutter_sdk.dart index d51566f..cbbf2e4 100644 --- a/lib/stellar_flutter_sdk.dart +++ b/lib/stellar_flutter_sdk.dart @@ -48,7 +48,7 @@ export 'src/set_trustline_flags_operation.dart'; export 'src/liquidity_pool_deposit_operation.dart'; export 'src/liquidity_pool_withdraw_operation.dart'; export 'src/invoke_host_function_operation.dart'; -export 'src/bump_footprint_expiration_operation.dart'; +export 'src/extend_footprint_ttl_operation.dart'; export 'src/restore_footprint_operation.dart'; // Responses from Horizon @@ -90,7 +90,7 @@ export 'src/responses/operations/set_trustline_flags_operation_response.dart'; export 'src/responses/operations/liquidity_pool_operations_responses.dart'; export 'src/responses/operations/invoke_host_function_operation_response.dart'; export 'src/responses/operations/restore_footprint_operation_response.dart'; -export 'src/responses/operations/bump_footprint_expiration_operation_response.dart'; +export 'src/responses/operations/extend_footprint_ttl_operation_response.dart'; export 'src/responses/effects/account_effects_responses.dart'; export 'src/responses/effects/signer_effects_responses.dart'; export 'src/responses/effects/trustline_effects_responses.dart'; diff --git a/pubspec.yaml b/pubspec.yaml index f4dbbb7..a72cd68 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: stellar_flutter_sdk description: A stellar blockchain sdk that query's horizon, build, signs and submits transactions to the stellar network. -version: 1.6.5 +version: 1.6.6 homepage: https://github.com/Soneso/stellar_flutter_sdk environment: diff --git a/soroban.md b/soroban.md index 0a63e5b..9765315 100644 --- a/soroban.md +++ b/soroban.md @@ -186,8 +186,8 @@ XdrLedgerKey ledgerKey = XdrLedgerKey(XdrLedgerEntryType.CONTRACT_CODE); ledgerKey.contractCode = XdrLedgerKeyContractCode(XdrHash(Util.hexToBytes(wasmId)), XdrContractEntryBodyType.DATA_ENTRY); -GetLedgerEntryResponse ledgerEntryResponse = - await getLedgerEntry(ledgerKey.toBase64EncodedXdrString()); +GetLedgerEntriesResponse ledgerEntriesResponse = + await getLedgerEntries([ledgerKey.toBase64EncodedXdrString()]); ``` If you already have a contractId you can load the code as follows: @@ -197,7 +197,6 @@ XdrContractCodeEntry? cCodeEntry = await sorobanServer.loadContractCodeForContra if (cCodeEntry != null) { Uint8List sourceCode = cCodeEntry.body.code!.dataValue; - int expirationLedgerSeq = cCodeEntry.expirationLedgerSeq.uint32; } ``` diff --git a/test/payments_test.dart b/test/payments_test.dart index 26f191f..108f791 100644 --- a/test/payments_test.dart +++ b/test/payments_test.dart @@ -87,7 +87,7 @@ void main() { TransactionPreconditions precond = TransactionPreconditions(); precond.timeBounds = new TimeBounds(1652110741, 1752110741); - precond.ledgerBounds = new LedgerBounds(1, 1892052); + precond.ledgerBounds = new LedgerBounds(1, 4173594); await Future.delayed(const Duration(seconds: 6), (){}); precond.minSeqAge = 1; precond.minSeqLedgerGap = 1; @@ -115,7 +115,7 @@ void main() { assert(conds.timeBounds!.minTime == "1652110741"); assert(conds.timeBounds!.maxTime == "1752110741"); assert(conds.ledgerBounds!.minLedger == 1); - assert(conds.ledgerBounds!.maxLedger == 1892052); + assert(conds.ledgerBounds!.maxLedger == 4173594); assert(conds.minAccountSequence == testSeqNr.toString()); assert(conds.minAccountSequenceAge == "1"); assert(conds.minAccountSequenceLedgerGap == 1); diff --git a/test/soroban_test.dart b/test/soroban_test.dart index f0bc49d..2957b1f 100644 --- a/test/soroban_test.dart +++ b/test/soroban_test.dart @@ -125,14 +125,14 @@ void main() { GetTransactionResponse.STATUS_SUCCESS == rpcTransactionResponse.status); } - Future bumpContractCodeFootprint(String wasmId, int ledgersToExpire) async { + Future extendContractCodeFootprintTTL(String wasmId, int extendTo) async { await Future.delayed(Duration(seconds: 5)); // load account AccountResponse accountA = await sdk.accounts.account(accountAId); - BumpFootprintExpirationOperation bumpFunction = - BumpFootprintExpirationOperationBuilder(ledgersToExpire).build(); + ExtendFootprintTTLOperation bumpFunction = + ExtendFootprintTTLOperationBuilder(extendTo).build(); // create transaction for bumping Transaction transaction = new TransactionBuilder(accountA).addOperation(bumpFunction).build(); @@ -199,7 +199,7 @@ void main() { assert(operations.records != null && operations.records!.length > 0); OperationResponse operationResponse = operations.records!.first; - if (operationResponse is BumpFootprintExpirationOperationResponse) { + if (operationResponse is ExtendFootprintTTLOperationResponse) { assert("bump_footprint_expiration" == operationResponse.type); } else { assert(false); @@ -323,7 +323,7 @@ void main() { } else { assert(false); } - await bumpContractCodeFootprint(helloContractWasmId!, 100000); + await extendContractCodeFootprintTTL(helloContractWasmId!, 100000); }); test('test create contract', () async { @@ -633,7 +633,7 @@ void main() { assert(eventsResponse.events != null); assert(eventsResponse.events!.length > 0); - await bumpContractCodeFootprint(eventsContractWasmId, 100000); + await extendContractCodeFootprintTTL(eventsContractWasmId, 100000); }); test('test get ledger entries', () async { @@ -645,19 +645,17 @@ void main() { helloContractCreateFootprint!.getContractDataLedgerKey(); assert(contractDataKey != null); - GetLedgerEntryResponse contractCodeEntry = - await sorobanServer.getLedgerEntry(contractCodeKey!); - assert(contractCodeEntry.ledgerEntryData != null); - assert(contractCodeEntry.lastModifiedLedgerSeq != null); - assert(contractCodeEntry.latestLedger != null); - assert(contractCodeEntry.ledgerEntryDataXdr != null); - GetLedgerEntryResponse contractDataEntry = - await sorobanServer.getLedgerEntry(contractDataKey!); - assert(contractDataEntry.ledgerEntryData != null); - assert(contractDataEntry.lastModifiedLedgerSeq != null); - assert(contractDataEntry.latestLedger != null); - assert(contractDataEntry.ledgerEntryDataXdr != null); - assert(true); + GetLedgerEntriesResponse contractCodeEntries = + await sorobanServer.getLedgerEntries([contractCodeKey!]); + assert(contractCodeEntries.latestLedger != null); + assert(contractCodeEntries.entries != null); + assert(contractCodeEntries.entries!.length == 1); + + GetLedgerEntriesResponse contractDataEntries = + await sorobanServer.getLedgerEntries([contractDataKey!]); + assert(contractDataEntries.latestLedger != null); + assert(contractDataEntries.entries != null); + assert(contractDataEntries.entries!.length == 1); XdrContractCodeEntry? cCodeEntry = await sorobanServer.loadContractCodeForWasmId(helloContractWasmId!); assert(cCodeEntry != null); diff --git a/test/soroban_test_atomic_swap.dart b/test/soroban_test_atomic_swap.dart index 6f20652..d8d9aef 100644 --- a/test/soroban_test_atomic_swap.dart +++ b/test/soroban_test_atomic_swap.dart @@ -386,14 +386,14 @@ void main() { GetTransactionResponse.STATUS_SUCCESS == rpcTransactionResponse.status); } - Future bumpContractCodeFootprint(String wasmId, int ledgersToExpire) async { + Future extendContractCodeFootprintTTL(String wasmId, int extendTo) async { await Future.delayed(Duration(seconds: 5)); // load account AccountResponse accountA = await sdk.accounts.account(adminId); - BumpFootprintExpirationOperation bumpFunction = - BumpFootprintExpirationOperationBuilder(ledgersToExpire).build(); + ExtendFootprintTTLOperation bumpFunction = + ExtendFootprintTTLOperationBuilder(extendTo).build(); // create transaction for bumping Transaction transaction = new TransactionBuilder(accountA).addOperation(bumpFunction).build(); @@ -458,7 +458,7 @@ void main() { assert(operations.records != null && operations.records!.length > 0); OperationResponse operationResponse = operations.records!.first; - if (operationResponse is BumpFootprintExpirationOperationResponse) { + if (operationResponse is ExtendFootprintTTLOperationResponse) { assert("bump_footprint_expiration" == operationResponse.type); } else { assert(false); @@ -474,12 +474,12 @@ void main() { test('test install contracts', () async { tokenAContractWasmId = await installContract(tokenContractPath); await Future.delayed(Duration(seconds: 5)); - await bumpContractCodeFootprint(tokenAContractWasmId!, 100000); + await extendContractCodeFootprintTTL(tokenAContractWasmId!, 100000); tokenBContractWasmId = await installContract(tokenContractPath); await Future.delayed(Duration(seconds: 5)); - await bumpContractCodeFootprint(tokenBContractWasmId!, 100000); + await extendContractCodeFootprintTTL(tokenBContractWasmId!, 100000); swapContractWasmId = await installContract(swapContractPath); - await bumpContractCodeFootprint(swapContractWasmId!, 100000); + await extendContractCodeFootprintTTL(swapContractWasmId!, 100000); await Future.delayed(Duration(seconds: 5)); }); diff --git a/test/soroban_test_auth.dart b/test/soroban_test_auth.dart index ff6d9b2..d82a2f6 100644 --- a/test/soroban_test_auth.dart +++ b/test/soroban_test_auth.dart @@ -123,14 +123,14 @@ void main() { GetTransactionResponse.STATUS_SUCCESS == rpcTransactionResponse.status); } - Future bumpContractCodeFootprint(String wasmId, int ledgersToExpire) async { + Future extendContractCodeFootprintTTL(String wasmId, int extendTo) async { await Future.delayed(Duration(seconds: 5)); // load account AccountResponse accountA = await sdk.accounts.account(submitterId); - BumpFootprintExpirationOperation bumpFunction = - BumpFootprintExpirationOperationBuilder(ledgersToExpire).build(); + ExtendFootprintTTLOperation bumpFunction = + ExtendFootprintTTLOperationBuilder(extendTo).build(); // create transaction for bumping Transaction transaction = new TransactionBuilder(accountA).addOperation(bumpFunction).build(); @@ -195,7 +195,7 @@ void main() { assert(operations.records != null && operations.records!.length > 0); OperationResponse operationResponse = operations.records!.first; - if (operationResponse is BumpFootprintExpirationOperationResponse) { + if (operationResponse is ExtendFootprintTTLOperationResponse) { assert("bump_footprint_expiration" == operationResponse.type); } else { assert(false); @@ -250,7 +250,7 @@ void main() { authContractWasmId = rpcTransactionResponse.getWasmId(); assert(authContractWasmId != null); - await bumpContractCodeFootprint(authContractWasmId!, 100000); + await extendContractCodeFootprintTTL(authContractWasmId!, 100000); }); test('test create auth contract', () async {