From 94c19e96a3e30e816825752f3c963a7b7dd2358f Mon Sep 17 00:00:00 2001 From: DavidYu <654070281@qq.com> Date: Mon, 4 Dec 2023 17:49:55 +0800 Subject: [PATCH] update prottobuf --- .../ABSDKWalletKit/protobuf/rpc.pb.swift | 250 +++++++++++- .../ABSDKWalletKit/protobuf/rpc.proto | 22 +- .../ABSDKWalletKit/protobuf/service.graphqls | 5 +- .../ABSDKWalletKit/protobuf/service.proto | 5 +- .../ABSDKWalletKit/protobuf/state.pb.swift | 38 +- .../ABSDKWalletKit/protobuf/state.proto | 23 +- .../protobuf/trace-type.pb.swift | 149 +++++++ .../ABSDKWalletKit/protobuf/trace-type.proto | 15 + .../ABSDKWalletKit/protobuf/tx.pb.swift | 137 ++++--- .../ABSDKWalletKit/protobuf/tx.proto | 20 +- .../ABSDKWalletKit/protobuf/type.pb.swift | 376 +++++++++++++++++- .../ABSDKWalletKit/protobuf/type.proto | 39 +- Makefile | 2 +- Podfile | 10 + Podfile.lock | 4 +- 15 files changed, 1001 insertions(+), 94 deletions(-) diff --git a/ArcBlockSDK/ABSDKCoreKit/ABSDKWalletKit/protobuf/rpc.pb.swift b/ArcBlockSDK/ABSDKCoreKit/ABSDKWalletKit/protobuf/rpc.pb.swift index ab9499d1..0ceb8a1a 100644 --- a/ArcBlockSDK/ABSDKCoreKit/ABSDKWalletKit/protobuf/rpc.pb.swift +++ b/ArcBlockSDK/ABSDKCoreKit/ABSDKWalletKit/protobuf/rpc.pb.swift @@ -229,9 +229,24 @@ public struct Ocap_ResponseGetBlocks { fileprivate var _page: Ocap_PageInfo? = nil } -/// get_account_state(address, key): retrieve the current state from a list of -/// wallet addresses, return the value of the key. If key is omitted, return -/// entire account states +public struct Ocap_RequestGetAccountState { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var address: String = String() + + public var keys: [String] = [] + + public var height: UInt64 = 0 + + public var traceMigration: Bool = false + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + public struct Ocap_ResponseGetAccountState { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for @@ -596,6 +611,15 @@ public struct Ocap_RequestListTransactions { /// Clears the value of `stakeFilter`. Subsequent reads from it will return its default value. public mutating func clearStakeFilter() {_uniqueStorage()._stakeFilter = nil} + public var delegationFilter: Ocap_DelegationFilter { + get {return _storage._delegationFilter ?? Ocap_DelegationFilter()} + set {_uniqueStorage()._delegationFilter = newValue} + } + /// Returns true if `delegationFilter` has been explicitly set. + public var hasDelegationFilter: Bool {return _storage._delegationFilter != nil} + /// Clears the value of `delegationFilter`. Subsequent reads from it will return its default value. + public mutating func clearDelegationFilter() {_uniqueStorage()._delegationFilter = nil} + public var unknownFields = SwiftProtobuf.UnknownStorage() public init() {} @@ -1575,6 +1599,66 @@ public struct Ocap_ResponseEstimateGas { fileprivate var _estimate: Ocap_GasEstimate? = nil } +public struct Ocap_RequestListDelegations { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var paging: Ocap_Page { + get {return _paging ?? Ocap_Page()} + set {_paging = newValue} + } + /// Returns true if `paging` has been explicitly set. + public var hasPaging: Bool {return self._paging != nil} + /// Clears the value of `paging`. Subsequent reads from it will return its default value. + public mutating func clearPaging() {self._paging = nil} + + public var from: String = String() + + public var to: String = String() + + public var timeFilter: Ocap_TimeFilter { + get {return _timeFilter ?? Ocap_TimeFilter()} + set {_timeFilter = newValue} + } + /// Returns true if `timeFilter` has been explicitly set. + public var hasTimeFilter: Bool {return self._timeFilter != nil} + /// Clears the value of `timeFilter`. Subsequent reads from it will return its default value. + public mutating func clearTimeFilter() {self._timeFilter = nil} + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + + fileprivate var _paging: Ocap_Page? = nil + fileprivate var _timeFilter: Ocap_TimeFilter? = nil +} + +public struct Ocap_ResponseListDelegations { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var code: Ocap_StatusCode = .ok + + public var page: Ocap_PageInfo { + get {return _page ?? Ocap_PageInfo()} + set {_page = newValue} + } + /// Returns true if `page` has been explicitly set. + public var hasPage: Bool {return self._page != nil} + /// Clears the value of `page`. Subsequent reads from it will return its default value. + public mutating func clearPage() {self._page = nil} + + public var delegations: [Ocap_IndexedDelegationState] = [] + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + + fileprivate var _page: Ocap_PageInfo? = nil +} + // MARK: - Code below here is support for the SwiftProtobuf runtime. fileprivate let _protobuf_package = "ocap" @@ -1997,6 +2081,56 @@ extension Ocap_ResponseGetBlocks: SwiftProtobuf.Message, SwiftProtobuf._MessageI } } +extension Ocap_RequestGetAccountState: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".RequestGetAccountState" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "address"), + 2: .same(proto: "keys"), + 3: .same(proto: "height"), + 4: .standard(proto: "trace_migration"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.address) }() + case 2: try { try decoder.decodeRepeatedStringField(value: &self.keys) }() + case 3: try { try decoder.decodeSingularUInt64Field(value: &self.height) }() + case 4: try { try decoder.decodeSingularBoolField(value: &self.traceMigration) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.address.isEmpty { + try visitor.visitSingularStringField(value: self.address, fieldNumber: 1) + } + if !self.keys.isEmpty { + try visitor.visitRepeatedStringField(value: self.keys, fieldNumber: 2) + } + if self.height != 0 { + try visitor.visitSingularUInt64Field(value: self.height, fieldNumber: 3) + } + if self.traceMigration != false { + try visitor.visitSingularBoolField(value: self.traceMigration, fieldNumber: 4) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Ocap_RequestGetAccountState, rhs: Ocap_RequestGetAccountState) -> Bool { + if lhs.address != rhs.address {return false} + if lhs.keys != rhs.keys {return false} + if lhs.height != rhs.height {return false} + if lhs.traceMigration != rhs.traceMigration {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + extension Ocap_ResponseGetAccountState: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { public static let protoMessageName: String = _protobuf_package + ".ResponseGetAccountState" public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ @@ -2500,6 +2634,7 @@ extension Ocap_RequestListTransactions: SwiftProtobuf.Message, SwiftProtobuf._Me 10: .standard(proto: "tx_filter"), 11: .standard(proto: "rollup_filter"), 12: .standard(proto: "stake_filter"), + 13: .standard(proto: "delegation_filter"), ] fileprivate class _StorageClass { @@ -2515,6 +2650,7 @@ extension Ocap_RequestListTransactions: SwiftProtobuf.Message, SwiftProtobuf._Me var _txFilter: Ocap_TxFilter? = nil var _rollupFilter: Ocap_RollupFilter? = nil var _stakeFilter: Ocap_StakeFilter? = nil + var _delegationFilter: Ocap_DelegationFilter? = nil static let defaultInstance = _StorageClass() @@ -2533,6 +2669,7 @@ extension Ocap_RequestListTransactions: SwiftProtobuf.Message, SwiftProtobuf._Me _txFilter = source._txFilter _rollupFilter = source._rollupFilter _stakeFilter = source._stakeFilter + _delegationFilter = source._delegationFilter } } @@ -2563,6 +2700,7 @@ extension Ocap_RequestListTransactions: SwiftProtobuf.Message, SwiftProtobuf._Me case 10: try { try decoder.decodeSingularMessageField(value: &_storage._txFilter) }() case 11: try { try decoder.decodeSingularMessageField(value: &_storage._rollupFilter) }() case 12: try { try decoder.decodeSingularMessageField(value: &_storage._stakeFilter) }() + case 13: try { try decoder.decodeSingularMessageField(value: &_storage._delegationFilter) }() default: break } } @@ -2611,6 +2749,9 @@ extension Ocap_RequestListTransactions: SwiftProtobuf.Message, SwiftProtobuf._Me try { if let v = _storage._stakeFilter { try visitor.visitSingularMessageField(value: v, fieldNumber: 12) } }() + try { if let v = _storage._delegationFilter { + try visitor.visitSingularMessageField(value: v, fieldNumber: 13) + } }() } try unknownFields.traverse(visitor: &visitor) } @@ -2632,6 +2773,7 @@ extension Ocap_RequestListTransactions: SwiftProtobuf.Message, SwiftProtobuf._Me if _storage._txFilter != rhs_storage._txFilter {return false} if _storage._rollupFilter != rhs_storage._rollupFilter {return false} if _storage._stakeFilter != rhs_storage._stakeFilter {return false} + if _storage._delegationFilter != rhs_storage._delegationFilter {return false} return true } if !storagesAreEqual {return false} @@ -4318,3 +4460,105 @@ extension Ocap_ResponseEstimateGas: SwiftProtobuf.Message, SwiftProtobuf._Messag return true } } + +extension Ocap_RequestListDelegations: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".RequestListDelegations" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "paging"), + 2: .same(proto: "from"), + 3: .same(proto: "to"), + 4: .standard(proto: "time_filter"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularMessageField(value: &self._paging) }() + case 2: try { try decoder.decodeSingularStringField(value: &self.from) }() + case 3: try { try decoder.decodeSingularStringField(value: &self.to) }() + case 4: try { try decoder.decodeSingularMessageField(value: &self._timeFilter) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = self._paging { + try visitor.visitSingularMessageField(value: v, fieldNumber: 1) + } }() + if !self.from.isEmpty { + try visitor.visitSingularStringField(value: self.from, fieldNumber: 2) + } + if !self.to.isEmpty { + try visitor.visitSingularStringField(value: self.to, fieldNumber: 3) + } + try { if let v = self._timeFilter { + try visitor.visitSingularMessageField(value: v, fieldNumber: 4) + } }() + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Ocap_RequestListDelegations, rhs: Ocap_RequestListDelegations) -> Bool { + if lhs._paging != rhs._paging {return false} + if lhs.from != rhs.from {return false} + if lhs.to != rhs.to {return false} + if lhs._timeFilter != rhs._timeFilter {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Ocap_ResponseListDelegations: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".ResponseListDelegations" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "code"), + 2: .same(proto: "page"), + 3: .same(proto: "delegations"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularEnumField(value: &self.code) }() + case 2: try { try decoder.decodeSingularMessageField(value: &self._page) }() + case 3: try { try decoder.decodeRepeatedMessageField(value: &self.delegations) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + if self.code != .ok { + try visitor.visitSingularEnumField(value: self.code, fieldNumber: 1) + } + try { if let v = self._page { + try visitor.visitSingularMessageField(value: v, fieldNumber: 2) + } }() + if !self.delegations.isEmpty { + try visitor.visitRepeatedMessageField(value: self.delegations, fieldNumber: 3) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Ocap_ResponseListDelegations, rhs: Ocap_ResponseListDelegations) -> Bool { + if lhs.code != rhs.code {return false} + if lhs._page != rhs._page {return false} + if lhs.delegations != rhs.delegations {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} diff --git a/ArcBlockSDK/ABSDKCoreKit/ABSDKWalletKit/protobuf/rpc.proto b/ArcBlockSDK/ABSDKCoreKit/ABSDKWalletKit/protobuf/rpc.proto index 34e07c11..f7e11dae 100644 --- a/ArcBlockSDK/ABSDKCoreKit/ABSDKWalletKit/protobuf/rpc.proto +++ b/ArcBlockSDK/ABSDKCoreKit/ABSDKWalletKit/protobuf/rpc.proto @@ -52,9 +52,12 @@ message ResponseGetBlocks { repeated BlockInfoSimple blocks = 3; } -// get_account_state(address, key): retrieve the current state from a list of -// wallet addresses, return the value of the key. If key is omitted, return -// entire account states +message RequestGetAccountState { + string address = 1; + repeated string keys = 2; + uint64 height = 3; + bool trace_migration = 4; +} message ResponseGetAccountState { StatusCode code = 1; AccountState state = 2; @@ -125,6 +128,7 @@ message RequestListTransactions { TxFilter tx_filter = 10; RollupFilter rollup_filter = 11; StakeFilter stake_filter = 12; + DelegationFilter delegation_filter = 13; } message ResponseListTransactions { StatusCode code = 1; @@ -324,3 +328,15 @@ message ResponseEstimateGas { StatusCode code = 1; GasEstimate estimate = 2; } + +message RequestListDelegations { + Page paging = 1; + string from = 2; + string to = 3; + TimeFilter time_filter = 4; +} +message ResponseListDelegations { + StatusCode code = 1; + PageInfo page = 2; + repeated IndexedDelegationState delegations = 3; +} diff --git a/ArcBlockSDK/ABSDKCoreKit/ABSDKWalletKit/protobuf/service.graphqls b/ArcBlockSDK/ABSDKCoreKit/ABSDKWalletKit/protobuf/service.graphqls index 732429f0..8b80a09f 100644 --- a/ArcBlockSDK/ABSDKCoreKit/ABSDKWalletKit/protobuf/service.graphqls +++ b/ArcBlockSDK/ABSDKCoreKit/ABSDKWalletKit/protobuf/service.graphqls @@ -37,7 +37,7 @@ type RootMutationType { } type RootQueryType { - getAccountState(address: String, height: String, keys: [String]): ResponseGetAccountState + getAccountState(address: String, height: String, keys: [String], traceMigration: Boolean): ResponseGetAccountState getAssetState(address: String, height: String, keys: [String]): ResponseGetAssetState getFactoryState(address: String): ResponseGetFactoryState getDelegateState(address: String, height: String, keys: [String]): ResponseGetDelegateState @@ -86,6 +86,7 @@ type RootQueryType { txFilter: TxFilterInput rollupFilter: RollupFilterInput stakeFilter: StakeFilterInput + delegationFilter: DelegationFilterInput ): ResponseListTransactions # since 1.7.0 @@ -129,6 +130,8 @@ type RootQueryType { ): ResponseListRollupBlocks listRollupValidators(paging: PageInput, rollupAddress: String): ResponseListRollupValidators + listDelegations(from: String, to: String, paging: PageInput, timeFilter: TimeFilterInput): ResponseListDelegations + # since v1.13.17 search(paging: PageInput, keyword: String): ResponseSearch diff --git a/ArcBlockSDK/ABSDKCoreKit/ABSDKWalletKit/protobuf/service.proto b/ArcBlockSDK/ABSDKCoreKit/ABSDKWalletKit/protobuf/service.proto index a402dfe9..c1d59ba6 100644 --- a/ArcBlockSDK/ABSDKCoreKit/ABSDKWalletKit/protobuf/service.proto +++ b/ArcBlockSDK/ABSDKCoreKit/ABSDKWalletKit/protobuf/service.proto @@ -20,7 +20,7 @@ service Query { rpc getForgeStats(RequestEmpty) returns (ResponseGetForgeStats); // state related - rpc getAccountState(stream RequestGetState) returns (stream ResponseGetAccountState); + rpc getAccountState(stream RequestGetAccountState) returns (stream ResponseGetAccountState); rpc getAssetState(stream RequestGetState) returns (stream ResponseGetAssetState); rpc getFactoryState(stream RequestGetState) returns (stream ResponseGetFactoryState); rpc getForgeState(RequestGetState) returns (ResponseGetForgeState); @@ -54,6 +54,9 @@ service Query { rpc listRollupBlocks(RequestListRollupBlocks) returns (ResponseListRollupBlocks); rpc listRollupValidators(RequestListRollupValidators) returns (ResponseListRollupValidators); + // delegation + rpc listDelegations(RequestListDelegations) returns (ResponseListDelegations); + // search rpc search(RequestSearch) returns (ResponseSearch); diff --git a/ArcBlockSDK/ABSDKCoreKit/ABSDKWalletKit/protobuf/state.pb.swift b/ArcBlockSDK/ABSDKCoreKit/ABSDKWalletKit/protobuf/state.pb.swift index 204b1558..0c9a7c7d 100644 --- a/ArcBlockSDK/ABSDKCoreKit/ABSDKWalletKit/protobuf/state.pb.swift +++ b/ArcBlockSDK/ABSDKCoreKit/ABSDKWalletKit/protobuf/state.pb.swift @@ -356,16 +356,11 @@ public struct Ocap_RootState { public init() {} } -/// a rule can check against the statistics values, e.g. state.num_txs < 10000, -/// state.balance_delta < 50000, delta is calculated based on the -/// configuration for interval. public struct Ocap_DelegateOpState { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. - /// all the individual rules in DelegateTx will be concat into one per type_url - /// by "AND" public var rule: String = String() public var numTxs: UInt64 = 0 @@ -390,12 +385,23 @@ public struct Ocap_DelegateOpState { /// Clears the value of `balanceDelta`. Subsequent reads from it will return its default value. public mutating func clearBalanceDelta() {self._balanceDelta = nil} + /// since v1.18.96 + public var limit: Ocap_DelegateLimit { + get {return _limit ?? Ocap_DelegateLimit()} + set {_limit = newValue} + } + /// Returns true if `limit` has been explicitly set. + public var hasLimit: Bool {return self._limit != nil} + /// Clears the value of `limit`. Subsequent reads from it will return its default value. + public mutating func clearLimit() {self._limit = nil} + public var unknownFields = SwiftProtobuf.UnknownStorage() public init() {} fileprivate var _balance: Ocap_BigUint? = nil fileprivate var _balanceDelta: Ocap_BigUint? = nil + fileprivate var _limit: Ocap_DelegateLimit? = nil } public struct Ocap_DelegateState { @@ -407,6 +413,10 @@ public struct Ocap_DelegateState { public var ops: Dictionary = [:] + public var from: String = String() + + public var to: String = String() + /// state context, replace exiting fields public var context: Ocap_StateContext { get {return _context ?? Ocap_StateContext()} @@ -1734,6 +1744,7 @@ extension Ocap_DelegateOpState: SwiftProtobuf.Message, SwiftProtobuf._MessageImp 3: .standard(proto: "num_txs_delta"), 4: .same(proto: "balance"), 5: .standard(proto: "balance_delta"), + 6: .same(proto: "limit"), ] public mutating func decodeMessage(decoder: inout D) throws { @@ -1747,6 +1758,7 @@ extension Ocap_DelegateOpState: SwiftProtobuf.Message, SwiftProtobuf._MessageImp case 3: try { try decoder.decodeSingularUInt64Field(value: &self.numTxsDelta) }() case 4: try { try decoder.decodeSingularMessageField(value: &self._balance) }() case 5: try { try decoder.decodeSingularMessageField(value: &self._balanceDelta) }() + case 6: try { try decoder.decodeSingularMessageField(value: &self._limit) }() default: break } } @@ -1772,6 +1784,9 @@ extension Ocap_DelegateOpState: SwiftProtobuf.Message, SwiftProtobuf._MessageImp try { if let v = self._balanceDelta { try visitor.visitSingularMessageField(value: v, fieldNumber: 5) } }() + try { if let v = self._limit { + try visitor.visitSingularMessageField(value: v, fieldNumber: 6) + } }() try unknownFields.traverse(visitor: &visitor) } @@ -1781,6 +1796,7 @@ extension Ocap_DelegateOpState: SwiftProtobuf.Message, SwiftProtobuf._MessageImp if lhs.numTxsDelta != rhs.numTxsDelta {return false} if lhs._balance != rhs._balance {return false} if lhs._balanceDelta != rhs._balanceDelta {return false} + if lhs._limit != rhs._limit {return false} if lhs.unknownFields != rhs.unknownFields {return false} return true } @@ -1791,6 +1807,8 @@ extension Ocap_DelegateState: SwiftProtobuf.Message, SwiftProtobuf._MessageImple public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ 1: .same(proto: "address"), 2: .same(proto: "ops"), + 3: .same(proto: "from"), + 4: .same(proto: "to"), 14: .same(proto: "context"), 15: .same(proto: "data"), ] @@ -1803,6 +1821,8 @@ extension Ocap_DelegateState: SwiftProtobuf.Message, SwiftProtobuf._MessageImple switch fieldNumber { case 1: try { try decoder.decodeSingularStringField(value: &self.address) }() case 2: try { try decoder.decodeMapField(fieldType: SwiftProtobuf._ProtobufMessageMap.self, value: &self.ops) }() + case 3: try { try decoder.decodeSingularStringField(value: &self.from) }() + case 4: try { try decoder.decodeSingularStringField(value: &self.to) }() case 14: try { try decoder.decodeSingularMessageField(value: &self._context) }() case 15: try { try decoder.decodeSingularMessageField(value: &self._data) }() default: break @@ -1821,6 +1841,12 @@ extension Ocap_DelegateState: SwiftProtobuf.Message, SwiftProtobuf._MessageImple if !self.ops.isEmpty { try visitor.visitMapField(fieldType: SwiftProtobuf._ProtobufMessageMap.self, value: self.ops, fieldNumber: 2) } + if !self.from.isEmpty { + try visitor.visitSingularStringField(value: self.from, fieldNumber: 3) + } + if !self.to.isEmpty { + try visitor.visitSingularStringField(value: self.to, fieldNumber: 4) + } try { if let v = self._context { try visitor.visitSingularMessageField(value: v, fieldNumber: 14) } }() @@ -1833,6 +1859,8 @@ extension Ocap_DelegateState: SwiftProtobuf.Message, SwiftProtobuf._MessageImple public static func ==(lhs: Ocap_DelegateState, rhs: Ocap_DelegateState) -> Bool { if lhs.address != rhs.address {return false} if lhs.ops != rhs.ops {return false} + if lhs.from != rhs.from {return false} + if lhs.to != rhs.to {return false} if lhs._context != rhs._context {return false} if lhs._data != rhs._data {return false} if lhs.unknownFields != rhs.unknownFields {return false} diff --git a/ArcBlockSDK/ABSDKCoreKit/ABSDKWalletKit/protobuf/state.proto b/ArcBlockSDK/ABSDKCoreKit/ABSDKWalletKit/protobuf/state.proto index cb358e13..61ff53c8 100644 --- a/ArcBlockSDK/ABSDKCoreKit/ABSDKWalletKit/protobuf/state.proto +++ b/ArcBlockSDK/ABSDKCoreKit/ABSDKWalletKit/protobuf/state.proto @@ -103,25 +103,24 @@ message RootState { bytes custom = 7; } -// a rule can check against the statistics values, e.g. state.num_txs < 10000, -// state.balance_delta < 50000, delta is calculated based on the -// configuration for interval. message DelegateOpState { - // all the individual rules in DelegateTx will be concat into one per type_url - // by "AND" - string rule = 1; - - uint64 num_txs = 2; - uint64 num_txs_delta = 3; - - BigUint balance = 4; - BigUint balance_delta = 5; + string rule = 1 [ deprecated = true ]; + uint64 num_txs = 2 [ deprecated = true ]; + uint64 num_txs_delta = 3 [ deprecated = true ]; + BigUint balance = 4 [ deprecated = true ]; + BigUint balance_delta = 5 [ deprecated = true ]; + + // since v1.18.96 + DelegateLimit limit = 6; } message DelegateState { string address = 1; map ops = 2; + string from = 3; + string to = 4; + // state context, replace exiting fields StateContext context = 14; diff --git a/ArcBlockSDK/ABSDKCoreKit/ABSDKWalletKit/protobuf/trace-type.pb.swift b/ArcBlockSDK/ABSDKCoreKit/ABSDKWalletKit/protobuf/trace-type.pb.swift index 7c90b37d..7f782d48 100644 --- a/ArcBlockSDK/ABSDKCoreKit/ABSDKWalletKit/protobuf/trace-type.pb.swift +++ b/ArcBlockSDK/ABSDKCoreKit/ABSDKWalletKit/protobuf/trace-type.pb.swift @@ -174,6 +174,18 @@ public struct Ocap_FactoryFilter { public init() {} } +public struct Ocap_DelegationFilter { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var delegations: [String] = [] + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + public struct Ocap_TokenFilter { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for @@ -1358,6 +1370,39 @@ public struct Ocap_IndexedRollupValidator { fileprivate var _storage = _StorageClass.defaultInstance } +public struct Ocap_IndexedDelegationState { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var address: String = String() + + public var from: String = String() + + public var to: String = String() + + public var genesisTime: String = String() + + public var renaissanceTime: String = String() + + public var ops: Dictionary = [:] + + public var data: SwiftProtobuf.Google_Protobuf_Any { + get {return _data ?? SwiftProtobuf.Google_Protobuf_Any()} + set {_data = newValue} + } + /// Returns true if `data` has been explicitly set. + public var hasData: Bool {return self._data != nil} + /// Clears the value of `data`. Subsequent reads from it will return its default value. + public mutating func clearData() {self._data = nil} + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + + fileprivate var _data: SwiftProtobuf.Google_Protobuf_Any? = nil +} + // MARK: - Code below here is support for the SwiftProtobuf runtime. fileprivate let _protobuf_package = "ocap" @@ -1556,6 +1601,38 @@ extension Ocap_FactoryFilter: SwiftProtobuf.Message, SwiftProtobuf._MessageImple } } +extension Ocap_DelegationFilter: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".DelegationFilter" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "delegations"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeRepeatedStringField(value: &self.delegations) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.delegations.isEmpty { + try visitor.visitRepeatedStringField(value: self.delegations, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Ocap_DelegationFilter, rhs: Ocap_DelegationFilter) -> Bool { + if lhs.delegations != rhs.delegations {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + extension Ocap_TokenFilter: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { public static let protoMessageName: String = _protobuf_package + ".TokenFilter" public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ @@ -3933,3 +4010,75 @@ extension Ocap_IndexedRollupValidator: SwiftProtobuf.Message, SwiftProtobuf._Mes return true } } + +extension Ocap_IndexedDelegationState: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".IndexedDelegationState" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "address"), + 2: .same(proto: "from"), + 3: .same(proto: "to"), + 4: .standard(proto: "genesis_time"), + 5: .standard(proto: "renaissance_time"), + 6: .same(proto: "ops"), + 7: .same(proto: "data"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.address) }() + case 2: try { try decoder.decodeSingularStringField(value: &self.from) }() + case 3: try { try decoder.decodeSingularStringField(value: &self.to) }() + case 4: try { try decoder.decodeSingularStringField(value: &self.genesisTime) }() + case 5: try { try decoder.decodeSingularStringField(value: &self.renaissanceTime) }() + case 6: try { try decoder.decodeMapField(fieldType: SwiftProtobuf._ProtobufMessageMap.self, value: &self.ops) }() + case 7: try { try decoder.decodeSingularMessageField(value: &self._data) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + if !self.address.isEmpty { + try visitor.visitSingularStringField(value: self.address, fieldNumber: 1) + } + if !self.from.isEmpty { + try visitor.visitSingularStringField(value: self.from, fieldNumber: 2) + } + if !self.to.isEmpty { + try visitor.visitSingularStringField(value: self.to, fieldNumber: 3) + } + if !self.genesisTime.isEmpty { + try visitor.visitSingularStringField(value: self.genesisTime, fieldNumber: 4) + } + if !self.renaissanceTime.isEmpty { + try visitor.visitSingularStringField(value: self.renaissanceTime, fieldNumber: 5) + } + if !self.ops.isEmpty { + try visitor.visitMapField(fieldType: SwiftProtobuf._ProtobufMessageMap.self, value: self.ops, fieldNumber: 6) + } + try { if let v = self._data { + try visitor.visitSingularMessageField(value: v, fieldNumber: 7) + } }() + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Ocap_IndexedDelegationState, rhs: Ocap_IndexedDelegationState) -> Bool { + if lhs.address != rhs.address {return false} + if lhs.from != rhs.from {return false} + if lhs.to != rhs.to {return false} + if lhs.genesisTime != rhs.genesisTime {return false} + if lhs.renaissanceTime != rhs.renaissanceTime {return false} + if lhs.ops != rhs.ops {return false} + if lhs._data != rhs._data {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} diff --git a/ArcBlockSDK/ABSDKCoreKit/ABSDKWalletKit/protobuf/trace-type.proto b/ArcBlockSDK/ABSDKCoreKit/ABSDKWalletKit/protobuf/trace-type.proto index 30161b16..a68c7921 100644 --- a/ArcBlockSDK/ABSDKCoreKit/ABSDKWalletKit/protobuf/trace-type.proto +++ b/ArcBlockSDK/ABSDKCoreKit/ABSDKWalletKit/protobuf/trace-type.proto @@ -3,6 +3,7 @@ package ocap; import "google/protobuf/any.proto"; import "type.proto"; +import "state.proto"; import "enum.proto"; import "tx.proto"; @@ -31,6 +32,10 @@ message FactoryFilter { repeated string factories = 1; } +message DelegationFilter { + repeated string delegations = 1; +} + message TokenFilter { repeated string tokens = 1; } @@ -348,3 +353,13 @@ message IndexedRollupValidator { string rollup = 17; } + +message IndexedDelegationState { + string address = 1; + string from = 2; + string to = 3; + string genesis_time = 4; + string renaissance_time = 5; + map ops = 6; + google.protobuf.Any data = 7; +} diff --git a/ArcBlockSDK/ABSDKCoreKit/ABSDKWalletKit/protobuf/tx.pb.swift b/ArcBlockSDK/ABSDKCoreKit/ABSDKWalletKit/protobuf/tx.pb.swift index a96b4c4b..7d0f7093 100644 --- a/ArcBlockSDK/ABSDKCoreKit/ABSDKWalletKit/protobuf/tx.pb.swift +++ b/ArcBlockSDK/ABSDKCoreKit/ABSDKWalletKit/protobuf/tx.pb.swift @@ -89,6 +89,33 @@ public struct Ocap_DeclareTx { fileprivate var _data: SwiftProtobuf.Google_Protobuf_Any? = nil } +/// if rules are empty, signature for this type_url is entirely delegated +public struct Ocap_DelegateOp { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var typeURL: String = String() + + public var rules: [String] = [] + + /// since v1.18.96 + public var limit: Ocap_DelegateLimit { + get {return _limit ?? Ocap_DelegateLimit()} + set {_limit = newValue} + } + /// Returns true if `limit` has been explicitly set. + public var hasLimit: Bool {return self._limit != nil} + /// Clears the value of `limit`. Subsequent reads from it will return its default value. + public mutating func clearLimit() {self._limit = nil} + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + + fileprivate var _limit: Ocap_DelegateLimit? = nil +} + public struct Ocap_DelegateTx { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for @@ -119,24 +146,6 @@ public struct Ocap_DelegateTx { fileprivate var _data: SwiftProtobuf.Google_Protobuf_Any? = nil } -/// if rules are empty, signature for this type_url is entirely delegated -/// otherwise rules are checked one by one, relationship between rules is AND. -/// a rule is an expression defined in rule_parser -/// (github.com/arcblock/rule-parser) one can setup -public struct Ocap_DelegateOp { - // SwiftProtobuf.Message conformance is added in an extension below. See the - // `Message` and `Message+*Additions` files in the SwiftProtobuf library for - // methods supported on all messages. - - public var typeURL: String = String() - - public var rules: [String] = [] - - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public init() {} -} - public struct Ocap_RevokeDelegateTx { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for @@ -747,6 +756,8 @@ public struct Ocap_UpdateAssetTx { public var moniker: String = String() + public var consumed: Bool = false + /// ocap won't update data into state if app is interested in this tx. public var data: SwiftProtobuf.Google_Protobuf_Any { get {return _data ?? SwiftProtobuf.Google_Protobuf_Any()} @@ -2342,13 +2353,12 @@ extension Ocap_DeclareTx: SwiftProtobuf.Message, SwiftProtobuf._MessageImplement } } -extension Ocap_DelegateTx: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".DelegateTx" +extension Ocap_DelegateOp: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".DelegateOp" public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .same(proto: "address"), - 2: .same(proto: "to"), - 3: .same(proto: "ops"), - 15: .same(proto: "data"), + 1: .standard(proto: "type_url"), + 2: .same(proto: "rules"), + 3: .same(proto: "limit"), ] public mutating func decodeMessage(decoder: inout D) throws { @@ -2357,10 +2367,9 @@ extension Ocap_DelegateTx: SwiftProtobuf.Message, SwiftProtobuf._MessageImplemen // allocates stack space for every case branch when no optimizations are // enabled. https://github.com/apple/swift-protobuf/issues/1034 switch fieldNumber { - case 1: try { try decoder.decodeSingularStringField(value: &self.address) }() - case 2: try { try decoder.decodeSingularStringField(value: &self.to) }() - case 3: try { try decoder.decodeRepeatedMessageField(value: &self.ops) }() - case 15: try { try decoder.decodeSingularMessageField(value: &self._data) }() + case 1: try { try decoder.decodeSingularStringField(value: &self.typeURL) }() + case 2: try { try decoder.decodeRepeatedStringField(value: &self.rules) }() + case 3: try { try decoder.decodeSingularMessageField(value: &self._limit) }() default: break } } @@ -2371,36 +2380,34 @@ extension Ocap_DelegateTx: SwiftProtobuf.Message, SwiftProtobuf._MessageImplemen // allocates stack space for every if/case branch local when no optimizations // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and // https://github.com/apple/swift-protobuf/issues/1182 - if !self.address.isEmpty { - try visitor.visitSingularStringField(value: self.address, fieldNumber: 1) - } - if !self.to.isEmpty { - try visitor.visitSingularStringField(value: self.to, fieldNumber: 2) + if !self.typeURL.isEmpty { + try visitor.visitSingularStringField(value: self.typeURL, fieldNumber: 1) } - if !self.ops.isEmpty { - try visitor.visitRepeatedMessageField(value: self.ops, fieldNumber: 3) + if !self.rules.isEmpty { + try visitor.visitRepeatedStringField(value: self.rules, fieldNumber: 2) } - try { if let v = self._data { - try visitor.visitSingularMessageField(value: v, fieldNumber: 15) + try { if let v = self._limit { + try visitor.visitSingularMessageField(value: v, fieldNumber: 3) } }() try unknownFields.traverse(visitor: &visitor) } - public static func ==(lhs: Ocap_DelegateTx, rhs: Ocap_DelegateTx) -> Bool { - if lhs.address != rhs.address {return false} - if lhs.to != rhs.to {return false} - if lhs.ops != rhs.ops {return false} - if lhs._data != rhs._data {return false} + public static func ==(lhs: Ocap_DelegateOp, rhs: Ocap_DelegateOp) -> Bool { + if lhs.typeURL != rhs.typeURL {return false} + if lhs.rules != rhs.rules {return false} + if lhs._limit != rhs._limit {return false} if lhs.unknownFields != rhs.unknownFields {return false} return true } } -extension Ocap_DelegateOp: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".DelegateOp" +extension Ocap_DelegateTx: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".DelegateTx" public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 1: .standard(proto: "type_url"), - 2: .same(proto: "rules"), + 1: .same(proto: "address"), + 2: .same(proto: "to"), + 3: .same(proto: "ops"), + 15: .same(proto: "data"), ] public mutating func decodeMessage(decoder: inout D) throws { @@ -2409,26 +2416,40 @@ extension Ocap_DelegateOp: SwiftProtobuf.Message, SwiftProtobuf._MessageImplemen // allocates stack space for every case branch when no optimizations are // enabled. https://github.com/apple/swift-protobuf/issues/1034 switch fieldNumber { - case 1: try { try decoder.decodeSingularStringField(value: &self.typeURL) }() - case 2: try { try decoder.decodeRepeatedStringField(value: &self.rules) }() + case 1: try { try decoder.decodeSingularStringField(value: &self.address) }() + case 2: try { try decoder.decodeSingularStringField(value: &self.to) }() + case 3: try { try decoder.decodeRepeatedMessageField(value: &self.ops) }() + case 15: try { try decoder.decodeSingularMessageField(value: &self._data) }() default: break } } } public func traverse(visitor: inout V) throws { - if !self.typeURL.isEmpty { - try visitor.visitSingularStringField(value: self.typeURL, fieldNumber: 1) + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + if !self.address.isEmpty { + try visitor.visitSingularStringField(value: self.address, fieldNumber: 1) } - if !self.rules.isEmpty { - try visitor.visitRepeatedStringField(value: self.rules, fieldNumber: 2) + if !self.to.isEmpty { + try visitor.visitSingularStringField(value: self.to, fieldNumber: 2) + } + if !self.ops.isEmpty { + try visitor.visitRepeatedMessageField(value: self.ops, fieldNumber: 3) } + try { if let v = self._data { + try visitor.visitSingularMessageField(value: v, fieldNumber: 15) + } }() try unknownFields.traverse(visitor: &visitor) } - public static func ==(lhs: Ocap_DelegateOp, rhs: Ocap_DelegateOp) -> Bool { - if lhs.typeURL != rhs.typeURL {return false} - if lhs.rules != rhs.rules {return false} + public static func ==(lhs: Ocap_DelegateTx, rhs: Ocap_DelegateTx) -> Bool { + if lhs.address != rhs.address {return false} + if lhs.to != rhs.to {return false} + if lhs.ops != rhs.ops {return false} + if lhs._data != rhs._data {return false} if lhs.unknownFields != rhs.unknownFields {return false} return true } @@ -3355,6 +3376,7 @@ extension Ocap_UpdateAssetTx: SwiftProtobuf.Message, SwiftProtobuf._MessageImple public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ 1: .same(proto: "address"), 2: .same(proto: "moniker"), + 3: .same(proto: "consumed"), 15: .same(proto: "data"), ] @@ -3366,6 +3388,7 @@ extension Ocap_UpdateAssetTx: SwiftProtobuf.Message, SwiftProtobuf._MessageImple switch fieldNumber { case 1: try { try decoder.decodeSingularStringField(value: &self.address) }() case 2: try { try decoder.decodeSingularStringField(value: &self.moniker) }() + case 3: try { try decoder.decodeSingularBoolField(value: &self.consumed) }() case 15: try { try decoder.decodeSingularMessageField(value: &self._data) }() default: break } @@ -3383,6 +3406,9 @@ extension Ocap_UpdateAssetTx: SwiftProtobuf.Message, SwiftProtobuf._MessageImple if !self.moniker.isEmpty { try visitor.visitSingularStringField(value: self.moniker, fieldNumber: 2) } + if self.consumed != false { + try visitor.visitSingularBoolField(value: self.consumed, fieldNumber: 3) + } try { if let v = self._data { try visitor.visitSingularMessageField(value: v, fieldNumber: 15) } }() @@ -3392,6 +3418,7 @@ extension Ocap_UpdateAssetTx: SwiftProtobuf.Message, SwiftProtobuf._MessageImple public static func ==(lhs: Ocap_UpdateAssetTx, rhs: Ocap_UpdateAssetTx) -> Bool { if lhs.address != rhs.address {return false} if lhs.moniker != rhs.moniker {return false} + if lhs.consumed != rhs.consumed {return false} if lhs._data != rhs._data {return false} if lhs.unknownFields != rhs.unknownFields {return false} return true diff --git a/ArcBlockSDK/ABSDKCoreKit/ABSDKWalletKit/protobuf/tx.proto b/ArcBlockSDK/ABSDKCoreKit/ABSDKWalletKit/protobuf/tx.proto index 0da8c3ac..82d3426a 100644 --- a/ArcBlockSDK/ABSDKCoreKit/ABSDKWalletKit/protobuf/tx.proto +++ b/ArcBlockSDK/ABSDKCoreKit/ABSDKWalletKit/protobuf/tx.proto @@ -24,6 +24,16 @@ message DeclareTx { // ocap won't update data into state if app is interested in this tx. google.protobuf.Any data = 15; } + +// if rules are empty, signature for this type_url is entirely delegated +message DelegateOp { + string type_url = 1; + + repeated string rules = 2 [ deprecated = true ]; + + // since v1.18.96 + DelegateLimit limit = 3; +} message DelegateTx { string address = 1; // address of the delegation between sender and receiver string to = 2; // delegatee's address @@ -31,15 +41,6 @@ message DelegateTx { google.protobuf.Any data = 15; } - -// if rules are empty, signature for this type_url is entirely delegated -// otherwise rules are checked one by one, relationship between rules is AND. -// a rule is an expression defined in rule_parser -// (github.com/arcblock/rule-parser) one can setup -message DelegateOp { - string type_url = 1; - repeated string rules = 2; -} message RevokeDelegateTx { string address = 1; // address of the delegation between sender and receiver string to = 2; // delegatee's address @@ -255,6 +256,7 @@ message CreateAssetTx { message UpdateAssetTx { string address = 1; string moniker = 2; + bool consumed = 3; // ocap won't update data into state if app is interested in this tx. google.protobuf.Any data = 15; diff --git a/ArcBlockSDK/ABSDKCoreKit/ABSDKWalletKit/protobuf/type.pb.swift b/ArcBlockSDK/ABSDKCoreKit/ABSDKWalletKit/protobuf/type.pb.swift index 18059150..42efd3a9 100644 --- a/ArcBlockSDK/ABSDKCoreKit/ABSDKWalletKit/protobuf/type.pb.swift +++ b/ArcBlockSDK/ABSDKCoreKit/ABSDKWalletKit/protobuf/type.pb.swift @@ -1279,7 +1279,7 @@ public struct Ocap_Evidence { public init() {} } -/// @link https://github.com/ArcBlock/asset-chain/issues/112#issuecomment-814487646 +/// @link https://github.com/ArcBlock/blockchain/issues/112#issuecomment-814487646 public struct Ocap_NFTEndpoint { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for @@ -1578,6 +1578,130 @@ public struct Ocap_GasEstimate { public init() {} } +public struct Ocap_RateLimit { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// interval in seconds + public var interval: UInt64 = 0 + + /// when to start the rate limit, default to current timestamp, can be future or past + public var anchor: UInt64 = 0 + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +public struct Ocap_TokenLimit { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// which token allowed to transfer + public var address: String = String() + + /// which address allowed to transfer to, empty is unlimited + public var to: [String] = [] + + /// how many txs allowed to send, 0 is unlimited + public var txCount: UInt32 = 0 + + /// how much token allowed to transfer, 0 is unlimited + public var txAllowance: String = String() + + /// how much token allowed to transfer, accumulated, 0 is unlimited + public var totalAllowance: String = String() + + /// in seconds, empty for unlimited + public var validUntil: UInt64 = 0 + + /// limit frequency, empty for unlimited + public var rate: Ocap_RateLimit { + get {return _rate ?? Ocap_RateLimit()} + set {_rate = newValue} + } + /// Returns true if `rate` has been explicitly set. + public var hasRate: Bool {return self._rate != nil} + /// Clears the value of `rate`. Subsequent reads from it will return its default value. + public mutating func clearRate() {self._rate = nil} + + /// stats fields maintained by chain + public var txSent: UInt32 = 0 + + /// how much token allowed to transfer, 0 is unlimited + public var spentAllowance: String = String() + + /// last tx time + public var lastTx: UInt64 = 0 + + /// fields used for display purpose + public var decimal: UInt32 = 0 + + public var symbol: String = String() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + + fileprivate var _rate: Ocap_RateLimit? = nil +} + +public struct Ocap_AssetLimit { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// which asset allowed to transfer, empty is unlimited + public var address: [String] = [] + + /// which address allowed to transfer to, empty is unlimited + public var to: [String] = [] + + /// how many txs allowed to send, 0 is unlimited + public var txCount: UInt32 = 0 + + /// in seconds, empty for unlimited + public var validUntil: UInt64 = 0 + + /// limit frequency, empty for unlimited + public var rate: Ocap_RateLimit { + get {return _rate ?? Ocap_RateLimit()} + set {_rate = newValue} + } + /// Returns true if `rate` has been explicitly set. + public var hasRate: Bool {return self._rate != nil} + /// Clears the value of `rate`. Subsequent reads from it will return its default value. + public mutating func clearRate() {self._rate = nil} + + /// how much tx allowed to send, accumulated, 0 is unlimited + public var txSent: UInt32 = 0 + + /// last tx time + public var lastTx: UInt64 = 0 + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + + fileprivate var _rate: Ocap_RateLimit? = nil +} + +public struct Ocap_DelegateLimit { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var tokens: [Ocap_TokenLimit] = [] + + public var assets: [Ocap_AssetLimit] = [] + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + // MARK: - Code below here is support for the SwiftProtobuf runtime. fileprivate let _protobuf_package = "ocap" @@ -4839,3 +4963,253 @@ extension Ocap_GasEstimate: SwiftProtobuf.Message, SwiftProtobuf._MessageImpleme return true } } + +extension Ocap_RateLimit: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".RateLimit" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "interval"), + 3: .same(proto: "anchor"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularUInt64Field(value: &self.interval) }() + case 3: try { try decoder.decodeSingularUInt64Field(value: &self.anchor) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if self.interval != 0 { + try visitor.visitSingularUInt64Field(value: self.interval, fieldNumber: 1) + } + if self.anchor != 0 { + try visitor.visitSingularUInt64Field(value: self.anchor, fieldNumber: 3) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Ocap_RateLimit, rhs: Ocap_RateLimit) -> Bool { + if lhs.interval != rhs.interval {return false} + if lhs.anchor != rhs.anchor {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Ocap_TokenLimit: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".TokenLimit" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "address"), + 2: .same(proto: "to"), + 3: .standard(proto: "tx_count"), + 4: .standard(proto: "tx_allowance"), + 5: .standard(proto: "total_allowance"), + 6: .standard(proto: "valid_until"), + 7: .same(proto: "rate"), + 8: .standard(proto: "tx_sent"), + 9: .standard(proto: "spent_allowance"), + 10: .standard(proto: "last_tx"), + 11: .same(proto: "decimal"), + 12: .same(proto: "symbol"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.address) }() + case 2: try { try decoder.decodeRepeatedStringField(value: &self.to) }() + case 3: try { try decoder.decodeSingularUInt32Field(value: &self.txCount) }() + case 4: try { try decoder.decodeSingularStringField(value: &self.txAllowance) }() + case 5: try { try decoder.decodeSingularStringField(value: &self.totalAllowance) }() + case 6: try { try decoder.decodeSingularUInt64Field(value: &self.validUntil) }() + case 7: try { try decoder.decodeSingularMessageField(value: &self._rate) }() + case 8: try { try decoder.decodeSingularUInt32Field(value: &self.txSent) }() + case 9: try { try decoder.decodeSingularStringField(value: &self.spentAllowance) }() + case 10: try { try decoder.decodeSingularUInt64Field(value: &self.lastTx) }() + case 11: try { try decoder.decodeSingularUInt32Field(value: &self.decimal) }() + case 12: try { try decoder.decodeSingularStringField(value: &self.symbol) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + if !self.address.isEmpty { + try visitor.visitSingularStringField(value: self.address, fieldNumber: 1) + } + if !self.to.isEmpty { + try visitor.visitRepeatedStringField(value: self.to, fieldNumber: 2) + } + if self.txCount != 0 { + try visitor.visitSingularUInt32Field(value: self.txCount, fieldNumber: 3) + } + if !self.txAllowance.isEmpty { + try visitor.visitSingularStringField(value: self.txAllowance, fieldNumber: 4) + } + if !self.totalAllowance.isEmpty { + try visitor.visitSingularStringField(value: self.totalAllowance, fieldNumber: 5) + } + if self.validUntil != 0 { + try visitor.visitSingularUInt64Field(value: self.validUntil, fieldNumber: 6) + } + try { if let v = self._rate { + try visitor.visitSingularMessageField(value: v, fieldNumber: 7) + } }() + if self.txSent != 0 { + try visitor.visitSingularUInt32Field(value: self.txSent, fieldNumber: 8) + } + if !self.spentAllowance.isEmpty { + try visitor.visitSingularStringField(value: self.spentAllowance, fieldNumber: 9) + } + if self.lastTx != 0 { + try visitor.visitSingularUInt64Field(value: self.lastTx, fieldNumber: 10) + } + if self.decimal != 0 { + try visitor.visitSingularUInt32Field(value: self.decimal, fieldNumber: 11) + } + if !self.symbol.isEmpty { + try visitor.visitSingularStringField(value: self.symbol, fieldNumber: 12) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Ocap_TokenLimit, rhs: Ocap_TokenLimit) -> Bool { + if lhs.address != rhs.address {return false} + if lhs.to != rhs.to {return false} + if lhs.txCount != rhs.txCount {return false} + if lhs.txAllowance != rhs.txAllowance {return false} + if lhs.totalAllowance != rhs.totalAllowance {return false} + if lhs.validUntil != rhs.validUntil {return false} + if lhs._rate != rhs._rate {return false} + if lhs.txSent != rhs.txSent {return false} + if lhs.spentAllowance != rhs.spentAllowance {return false} + if lhs.lastTx != rhs.lastTx {return false} + if lhs.decimal != rhs.decimal {return false} + if lhs.symbol != rhs.symbol {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Ocap_AssetLimit: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".AssetLimit" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "address"), + 2: .same(proto: "to"), + 3: .standard(proto: "tx_count"), + 4: .standard(proto: "valid_until"), + 5: .same(proto: "rate"), + 6: .standard(proto: "tx_sent"), + 7: .standard(proto: "last_tx"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeRepeatedStringField(value: &self.address) }() + case 2: try { try decoder.decodeRepeatedStringField(value: &self.to) }() + case 3: try { try decoder.decodeSingularUInt32Field(value: &self.txCount) }() + case 4: try { try decoder.decodeSingularUInt64Field(value: &self.validUntil) }() + case 5: try { try decoder.decodeSingularMessageField(value: &self._rate) }() + case 6: try { try decoder.decodeSingularUInt32Field(value: &self.txSent) }() + case 7: try { try decoder.decodeSingularUInt64Field(value: &self.lastTx) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + if !self.address.isEmpty { + try visitor.visitRepeatedStringField(value: self.address, fieldNumber: 1) + } + if !self.to.isEmpty { + try visitor.visitRepeatedStringField(value: self.to, fieldNumber: 2) + } + if self.txCount != 0 { + try visitor.visitSingularUInt32Field(value: self.txCount, fieldNumber: 3) + } + if self.validUntil != 0 { + try visitor.visitSingularUInt64Field(value: self.validUntil, fieldNumber: 4) + } + try { if let v = self._rate { + try visitor.visitSingularMessageField(value: v, fieldNumber: 5) + } }() + if self.txSent != 0 { + try visitor.visitSingularUInt32Field(value: self.txSent, fieldNumber: 6) + } + if self.lastTx != 0 { + try visitor.visitSingularUInt64Field(value: self.lastTx, fieldNumber: 7) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Ocap_AssetLimit, rhs: Ocap_AssetLimit) -> Bool { + if lhs.address != rhs.address {return false} + if lhs.to != rhs.to {return false} + if lhs.txCount != rhs.txCount {return false} + if lhs.validUntil != rhs.validUntil {return false} + if lhs._rate != rhs._rate {return false} + if lhs.txSent != rhs.txSent {return false} + if lhs.lastTx != rhs.lastTx {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Ocap_DelegateLimit: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".DelegateLimit" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "tokens"), + 2: .same(proto: "assets"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeRepeatedMessageField(value: &self.tokens) }() + case 2: try { try decoder.decodeRepeatedMessageField(value: &self.assets) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.tokens.isEmpty { + try visitor.visitRepeatedMessageField(value: self.tokens, fieldNumber: 1) + } + if !self.assets.isEmpty { + try visitor.visitRepeatedMessageField(value: self.assets, fieldNumber: 2) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Ocap_DelegateLimit, rhs: Ocap_DelegateLimit) -> Bool { + if lhs.tokens != rhs.tokens {return false} + if lhs.assets != rhs.assets {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} diff --git a/ArcBlockSDK/ABSDKCoreKit/ABSDKWalletKit/protobuf/type.proto b/ArcBlockSDK/ABSDKCoreKit/ABSDKWalletKit/protobuf/type.proto index bdfa4751..2c78c539 100644 --- a/ArcBlockSDK/ABSDKCoreKit/ABSDKWalletKit/protobuf/type.proto +++ b/ArcBlockSDK/ABSDKCoreKit/ABSDKWalletKit/protobuf/type.proto @@ -366,7 +366,7 @@ message Evidence { string hash = 1; // tx hash from a foreign chain } -// @link https://github.com/ArcBlock/asset-chain/issues/112#issuecomment-814487646 +// @link https://github.com/ArcBlock/blockchain/issues/112#issuecomment-814487646 message NFTEndpoint { // the url of the endpoint, must be a permanent url string id = 1; @@ -462,3 +462,40 @@ message ForgeStats { message GasEstimate { string max = 1; // max gas for this tx } + +message RateLimit { + uint64 interval = 1; // interval in seconds + uint64 anchor = 3; // when to start the rate limit, default to current timestamp, can be future or past +} +message TokenLimit { + string address = 1; // which token allowed to transfer + repeated string to = 2; // which address allowed to transfer to, empty is unlimited + uint32 tx_count = 3; // how many txs allowed to send, 0 is unlimited + string tx_allowance = 4; // how much token allowed to transfer, 0 is unlimited + string total_allowance = 5; // how much token allowed to transfer, accumulated, 0 is unlimited + uint64 valid_until = 6; // in seconds, empty for unlimited + RateLimit rate = 7; // limit frequency, empty for unlimited + + // stats fields maintained by chain + uint32 tx_sent = 8; // how much tx allowed to send, accumulated, 0 is unlimited + string spent_allowance = 9; // how much token allowed to transfer, 0 is unlimited + uint64 last_tx = 10; // last tx time + + // fields used for display purpose + uint32 decimal = 11; + string symbol = 12; +} +message AssetLimit { + repeated string address = 1; // which asset allowed to transfer, empty is unlimited + repeated string to = 2; // which address allowed to transfer to, empty is unlimited + uint32 tx_count = 3; // how many txs allowed to send, 0 is unlimited + uint64 valid_until = 4; // in seconds, empty for unlimited + RateLimit rate = 5; // limit frequency, empty for unlimited + + uint32 tx_sent = 6; // how much tx allowed to send, accumulated, 0 is unlimited + uint64 last_tx = 7; // last tx time +} +message DelegateLimit { + repeated TokenLimit tokens = 1; + repeated AssetLimit assets = 2; +} diff --git a/Makefile b/Makefile index 683cf0f3..a965d0a7 100644 --- a/Makefile +++ b/Makefile @@ -56,7 +56,7 @@ travis-deploy: protobuf-codegen: @echo "Generating protobuf swift codes..." - @protoc --swift_out=ArcBlockSDK/ABSDKWalletKit/protobuf/ --proto_path=ArcBlockSDK/ABSDKWalletKit/protobuf ArcBlockSDK/ABSDKWalletKit/protobuf/*.proto --swift_opt=Visibility=Public + @protoc --swift_out=ArcBlockSDK/ABSDKCoreKit/ABSDKWalletKit/protobuf/ --proto_path=ArcBlockSDK/ABSDKCoreKit/ABSDKWalletKit/protobuf ArcBlockSDK/ABSDKCoreKit/ABSDKWalletKit/protobuf/*.proto --swift_opt=Visibility=Public clean: @echo "Cleaning the build..." diff --git a/Podfile b/Podfile index c43e0a2c..ef401f48 100644 --- a/Podfile +++ b/Podfile @@ -18,3 +18,13 @@ target 'ArcBlockSDKTests' do pod 'SwiftProtobuf', '~> 1.0' pod 'web3swift', :git => 'https://github.com/ArcBlock/web3swift.git' end + +post_install do |installer| + installer.generated_projects.each do |project| + project.targets.each do |target| + target.build_configurations.each do |config| + config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '13.0' + end + end + end +end diff --git a/Podfile.lock b/Podfile.lock index c764f92b..02f74403 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -71,6 +71,6 @@ SPEC CHECKSUMS: SwiftProtobuf: 9c85136c6ba74b0a1b84279dbf0f6db8efb714e0 web3swift: 0e004984752645a0ed24736dcd5817a213f489bc -PODFILE CHECKSUM: 2653e2d1665cd8bb24092b4926c12a97706ac7e6 +PODFILE CHECKSUM: 37d3f6f230f0b3b0b0ce5085178af95ec7eededf -COCOAPODS: 1.11.2 +COCOAPODS: 1.12.0