Skip to content

Commit 65c1f6f

Browse files
sarinrgithub-actions[bot]
authored andcommitted
feat: update generated Swift files from latest OpenAPI spec
1 parent 57be463 commit 65c1f6f

File tree

4 files changed

+185
-3
lines changed

4 files changed

+185
-3
lines changed

Scripts/openapi.json

Lines changed: 79 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"openapi": "3.0.0",
33
"info": {
44
"title": "NEAR Protocol JSON RPC API",
5-
"version": "1.2.1"
5+
"version": "1.2.2"
66
},
77
"paths": {
88
"/EXPERIMENTAL_changes": {
@@ -10575,6 +10575,19 @@
1057510575
},
1057610576
"type": "array"
1057710577
},
10578+
"refund_to": {
10579+
"anyOf": [
10580+
{
10581+
"$ref": "#/components/schemas/AccountId"
10582+
},
10583+
{
10584+
"enum": [
10585+
null
10586+
],
10587+
"nullable": true
10588+
}
10589+
]
10590+
},
1057810591
"signer_id": {
1057910592
"$ref": "#/components/schemas/AccountId"
1058010593
},
@@ -11317,6 +11330,12 @@
1131711330
"minItems": 2,
1131811331
"type": "array"
1131911332
},
11333+
"chunks_cache_height_horizon": {
11334+
"description": "Height horizon for the chunk cache. A chunk is removed from the cache\nif its height + chunks_cache_height_horizon < largest_seen_height.\nThe default value is DEFAULT_CHUNKS_CACHE_HEIGHT_HORIZON.",
11335+
"format": "uint64",
11336+
"minimum": 0,
11337+
"type": "integer"
11338+
},
1132011339
"client_background_migration_threads": {
1132111340
"description": "Number of threads to execute background migration work in client.",
1132211341
"format": "uint",
@@ -16170,7 +16189,7 @@
1617016189
"$ref": "#/components/schemas/NearToken"
1617116190
}
1617216191
],
16173-
"description": "Amount of yN per byte required to have on the account. See\n<https://nomicon.io/Economics/Economic#state-stake> for details."
16192+
"description": "Amount of yN per byte required to have on the account. See\n<https://nomicon.io/Economics/Economics.html#state-stake> for details."
1617416193
},
1617516194
"transaction_costs": {
1617616195
"allOf": [
@@ -16301,6 +16320,18 @@
1630116320
"V2"
1630216321
],
1630316322
"type": "object"
16323+
},
16324+
{
16325+
"additionalProperties": false,
16326+
"properties": {
16327+
"V3": {
16328+
"$ref": "#/components/schemas/ShardLayoutV3"
16329+
}
16330+
},
16331+
"required": [
16332+
"V3"
16333+
],
16334+
"type": "object"
1630416335
}
1630516336
]
1630616337
},
@@ -16428,6 +16459,51 @@
1642816459
],
1642916460
"type": "object"
1643016461
},
16462+
"ShardLayoutV3": {
16463+
"description": "Counterpart to `ShardLayoutV3` composed of maps with string keys to aid\nserde serialization.",
16464+
"properties": {
16465+
"boundary_accounts": {
16466+
"items": {
16467+
"$ref": "#/components/schemas/AccountId"
16468+
},
16469+
"type": "array"
16470+
},
16471+
"id_to_index_map": {
16472+
"additionalProperties": {
16473+
"format": "uint",
16474+
"minimum": 0,
16475+
"type": "integer"
16476+
},
16477+
"type": "object"
16478+
},
16479+
"last_split": {
16480+
"$ref": "#/components/schemas/ShardId"
16481+
},
16482+
"shard_ids": {
16483+
"items": {
16484+
"$ref": "#/components/schemas/ShardId"
16485+
},
16486+
"type": "array"
16487+
},
16488+
"shards_split_map": {
16489+
"additionalProperties": {
16490+
"items": {
16491+
"$ref": "#/components/schemas/ShardId"
16492+
},
16493+
"type": "array"
16494+
},
16495+
"type": "object"
16496+
}
16497+
},
16498+
"required": [
16499+
"boundary_accounts",
16500+
"shard_ids",
16501+
"id_to_index_map",
16502+
"shards_split_map",
16503+
"last_split"
16504+
],
16505+
"type": "object"
16506+
},
1643116507
"ShardUId": {
1643216508
"description": "`ShardUId` is a unique representation for shards from different shard layouts.\n\nComparing to `ShardId`, which is just an ordinal number ranging from 0 to NUM_SHARDS-1,\n`ShardUId` provides a way to unique identify shards when shard layouts may change across epochs.\nThis is important because we store states indexed by shards in our database, so we need a\nway to unique identify shard even when shards change across epochs.\nAnother difference between `ShardUId` and `ShardId` is that `ShardUId` should only exist in\na node's internal state while `ShardId` can be exposed to outside APIs and used in protocol\nlevel information (for example, `ShardChunkHeader` contains `ShardId` instead of `ShardUId`)",
1643316509
"properties": {
@@ -17760,7 +17836,7 @@
1776017836
"type": "integer"
1776117837
},
1776217838
"implicit_account_creation": {
17763-
"description": "See [VMConfig::implicit_account_creation](crate::vm::Config::implicit_account_creation).",
17839+
"description": "Deprecated",
1776417840
"type": "boolean"
1776517841
},
1776617842
"limit_config": {

Sources/NearJsonRpcTypes/Types.swift

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8730,6 +8730,7 @@ public struct ReceiptEnumViewOneOfActionInline: Codable, Sendable {
87308730
public let inputDataIds: [CryptoHash]
87318731
public let isPromiseYield: Bool?
87328732
public let outputDataReceivers: [DataReceiverView]
8733+
public let refundTo: AccountId?
87338734
public let signerId: AccountId
87348735
public let signerPublicKey: PublicKey
87358736

@@ -8739,6 +8740,7 @@ public struct ReceiptEnumViewOneOfActionInline: Codable, Sendable {
87398740
inputDataIds: [CryptoHash],
87408741
isPromiseYield: Bool?,
87418742
outputDataReceivers: [DataReceiverView],
8743+
refundTo: AccountId?,
87428744
signerId: AccountId,
87438745
signerPublicKey: PublicKey,
87448746
) {
@@ -8747,6 +8749,7 @@ public struct ReceiptEnumViewOneOfActionInline: Codable, Sendable {
87478749
self.inputDataIds = inputDataIds
87488750
self.isPromiseYield = isPromiseYield
87498751
self.outputDataReceivers = outputDataReceivers
8752+
self.refundTo = refundTo
87508753
self.signerId = signerId
87518754
self.signerPublicKey = signerPublicKey
87528755
}
@@ -13352,6 +13355,7 @@ public enum ShardLayout: Codable, Sendable {
1335213355
case v0(ShardLayoutV0)
1335313356
case v1(ShardLayoutV1)
1335413357
case v2(ShardLayoutV2)
13358+
case v3(ShardLayoutV3)
1335513359

1335613360
public init(from decoder: Decoder) throws {
1335713361
var decodingErrors: [String] = []
@@ -13392,6 +13396,18 @@ public enum ShardLayout: Codable, Sendable {
1339213396
} catch {
1339313397
decodingErrors.append(".v2: \(describeDecodingError(error))")
1339413398
}
13399+
do {
13400+
if let container = anyKeyContainer {
13401+
if let matchingKey = container.allKeys
13402+
.first(where: { key in key.stringValue.caseInsensitiveCompare("V3") == .orderedSame }) {
13403+
let value = try container.decode(ShardLayoutV3.self, forKey: matchingKey)
13404+
self = .v3(value)
13405+
return
13406+
}
13407+
}
13408+
} catch {
13409+
decodingErrors.append(".v3: \(describeDecodingError(error))")
13410+
}
1339513411
let contextDescription: String
1339613412
if decodingErrors.isEmpty {
1339713413
let availableKeys: String
@@ -13413,6 +13429,7 @@ public enum ShardLayout: Codable, Sendable {
1341313429
case v0 = "V0"
1341413430
case v1 = "V1"
1341513431
case v2 = "V2"
13432+
case v3 = "V3"
1341613433
}
1341713434

1341813435
public func encode(to encoder: Encoder) throws {
@@ -13426,6 +13443,9 @@ public enum ShardLayout: Codable, Sendable {
1342613443
case let .v2(value):
1342713444
var container = encoder.container(keyedBy: CodingKeys.self)
1342813445
try container.encode(value, forKey: .v2)
13446+
case let .v3(value):
13447+
var container = encoder.container(keyedBy: CodingKeys.self)
13448+
try container.encode(value, forKey: .v3)
1342913449
}
1343013450
}
1343113451
}
@@ -17704,6 +17724,7 @@ public struct RpcClientConfigResponse: Codable, Sendable {
1770417724
public let chunkRequestRetryPeriod: [UInt64]?
1770517725
public let chunkValidationThreads: Int?
1770617726
public let chunkWaitMult: [Int32]?
17727+
public let chunksCacheHeightHorizon: UInt64?
1770717728
public let clientBackgroundMigrationThreads: Int?
1770817729
public let cloudArchivalWriter: CloudArchivalWriterConfig?
1770917730
public let disableTxRouting: Bool?
@@ -17775,6 +17796,7 @@ public struct RpcClientConfigResponse: Codable, Sendable {
1777517796
chunkRequestRetryPeriod: [UInt64]?,
1777617797
chunkValidationThreads: Int?,
1777717798
chunkWaitMult: [Int32]?,
17799+
chunksCacheHeightHorizon: UInt64?,
1777817800
clientBackgroundMigrationThreads: Int?,
1777917801
cloudArchivalWriter: CloudArchivalWriterConfig?,
1778017802
disableTxRouting: Bool?,
@@ -17845,6 +17867,7 @@ public struct RpcClientConfigResponse: Codable, Sendable {
1784517867
self.chunkRequestRetryPeriod = chunkRequestRetryPeriod
1784617868
self.chunkValidationThreads = chunkValidationThreads
1784717869
self.chunkWaitMult = chunkWaitMult
17870+
self.chunksCacheHeightHorizon = chunksCacheHeightHorizon
1784817871
self.clientBackgroundMigrationThreads = clientBackgroundMigrationThreads
1784917872
self.cloudArchivalWriter = cloudArchivalWriter
1785017873
self.disableTxRouting = disableTxRouting
@@ -18540,6 +18563,30 @@ public struct ShardLayoutV2: Codable, Sendable {
1854018563
}
1854118564
}
1854218565

18566+
// MARK: - ShardLayoutV3
18567+
18568+
public struct ShardLayoutV3: Codable, Sendable {
18569+
public let boundaryAccounts: [AccountId]
18570+
public let idToIndexMap: [String: Int]
18571+
public let lastSplit: ShardId
18572+
public let shardIds: [ShardId]
18573+
public let shardsSplitMap: [String: [ShardId]]
18574+
18575+
public init(
18576+
boundaryAccounts: [AccountId],
18577+
idToIndexMap: [String: Int],
18578+
lastSplit: ShardId,
18579+
shardIds: [ShardId],
18580+
shardsSplitMap: [String: [ShardId]],
18581+
) {
18582+
self.boundaryAccounts = boundaryAccounts
18583+
self.idToIndexMap = idToIndexMap
18584+
self.lastSplit = lastSplit
18585+
self.shardIds = shardIds
18586+
self.shardsSplitMap = shardsSplitMap
18587+
}
18588+
}
18589+
1854318590
// MARK: - ShardUId
1854418591

1854518592
public struct ShardUId: Codable, Sendable {

Tests/NearJsonRpcTypesTests/EnhancedCoverageTests.swift

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6235,6 +6235,20 @@ struct EnhancedCoverageTests {
62356235
#expect(!encoded2.isEmpty)
62366236
}
62376237

6238+
@Test("ShardLayout variant 3 encoding stability")
6239+
func shardLayoutVariant3EncodingStability() throws {
6240+
let data = try loadMockJSON("ShardLayout_Variant3.json")
6241+
let decoded = try decoder.decode(ShardLayout.self, from: data)
6242+
6243+
// Multiple encoding cycles should produce consistent results
6244+
let encoded1 = try encoder.encode(decoded)
6245+
let decoded2 = try decoder.decode(ShardLayout.self, from: encoded1)
6246+
let encoded2 = try encoder.encode(decoded2)
6247+
6248+
#expect(!encoded1.isEmpty)
6249+
#expect(!encoded2.isEmpty)
6250+
}
6251+
62386252
@Test("ShardLayoutV0 decoded instance is valid")
62396253
func shardLayoutV0Validity() throws {
62406254
let data = try loadMockJSON("ShardLayoutV0.json")
@@ -6280,6 +6294,21 @@ struct EnhancedCoverageTests {
62806294
#expect(!reencoded.isEmpty)
62816295
}
62826296

6297+
@Test("ShardLayoutV3 decoded instance is valid")
6298+
func shardLayoutV3Validity() throws {
6299+
let data = try loadMockJSON("ShardLayoutV3.json")
6300+
let decoded = try decoder.decode(ShardLayoutV3.self, from: data)
6301+
6302+
// Verify the decoded instance is valid by re-encoding
6303+
let encoded = try encoder.encode(decoded)
6304+
#expect(!encoded.isEmpty)
6305+
6306+
// Verify round-trip
6307+
let redecoded = try decoder.decode(ShardLayoutV3.self, from: encoded)
6308+
let reencoded = try encoder.encode(redecoded)
6309+
#expect(!reencoded.isEmpty)
6310+
}
6311+
62836312
@Test("ShardUId decoded instance is valid")
62846313
func shardUIdValidity() throws {
62856314
let data = try loadMockJSON("ShardUId.json")

Tests/NearJsonRpcTypesTests/StandaloneTypesTests.swift

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6799,6 +6799,21 @@ struct StandaloneTypesTests {
67996799
_ = try decoder.decode(ShardLayout.self, from: encoded)
68006800
}
68016801

6802+
@Test("ShardLayout variant 3 can be decoded and re-encoded")
6803+
func shardLayoutVariant3DecodingAndEncoding() throws {
6804+
let data = try loadMockJSON("ShardLayout_Variant3.json")
6805+
6806+
// Test decoding
6807+
let decoded = try decoder.decode(ShardLayout.self, from: data)
6808+
6809+
// Test encoding
6810+
let encoded = try encoder.encode(decoded)
6811+
#expect(!encoded.isEmpty)
6812+
6813+
// Test round-trip
6814+
_ = try decoder.decode(ShardLayout.self, from: encoded)
6815+
}
6816+
68026817
@Test("ShardLayoutV0 can be decoded from mock and re-encoded")
68036818
func shardLayoutV0DecodingAndEncoding() throws {
68046819
let data = try loadMockJSON("ShardLayoutV0.json")
@@ -6844,6 +6859,21 @@ struct StandaloneTypesTests {
68446859
_ = try decoder.decode(ShardLayoutV2.self, from: encoded)
68456860
}
68466861

6862+
@Test("ShardLayoutV3 can be decoded from mock and re-encoded")
6863+
func shardLayoutV3DecodingAndEncoding() throws {
6864+
let data = try loadMockJSON("ShardLayoutV3.json")
6865+
6866+
// Test decoding
6867+
let decoded = try decoder.decode(ShardLayoutV3.self, from: data)
6868+
6869+
// Test encoding
6870+
let encoded = try encoder.encode(decoded)
6871+
#expect(!encoded.isEmpty)
6872+
6873+
// Test round-trip
6874+
_ = try decoder.decode(ShardLayoutV3.self, from: encoded)
6875+
}
6876+
68476877
@Test("ShardUId can be decoded from mock and re-encoded")
68486878
func shardUIdDecodingAndEncoding() throws {
68496879
let data = try loadMockJSON("ShardUId.json")

0 commit comments

Comments
 (0)