Skip to content

Commit

Permalink
Merge pull request #71 from Concordium/cis2-client
Browse files Browse the repository at this point in the history
Cis2 client
  • Loading branch information
soerenbf authored Oct 9, 2024
2 parents ed5c928 + 0c96ab6 commit fdc953e
Show file tree
Hide file tree
Showing 17 changed files with 1,548 additions and 129 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `decryptAmount` and `combineEncryptedAmounts` to handle encrypted amounts

#### ID proofs
- `Statement` and `Proof` types for constructing ID statements and their corresponding proofs
- `IdentityStatement` and `IdentityProof` types for constructing ID statements and their corresponding proofs
- `VerifiablePresentation`, `Web3IdCredential`, and `VerifiableCredentialStatement` types for representing verifiable credentials and constructing
verifiable presentations for these.
- `VerifiablePresentationBuilder` has been added to ease the construction of `VerifiablePresentation`s of a given statement in the context of a verifiable credential.
Expand All @@ -26,6 +26,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `WalletConnectSendTransactionParam`, `WalletConnectSignMessageParam`, and `WalletConnectRequestVerifiablePresentationParam` for decoding parameters received with walletconnect requests.
- `WalletConnectRequest` represents and decodes walletconnect request variants

#### Contract standards (CIS)
- `CIS0Client` and `CIS2Client` which provides a default implementation of the respective contract standard functionality for any type which conforms to them.
- `CIS0` and `CIS2` (wallet MVP) namespaces for functionality related to the 2 standards.
- `CIS2` includes a `Contract` class for interacting with arbitrary (i.e. `CIS2.Contract`) CIS-2 contracts.


#### GRPC client
- `NodeClient.status` to query transaction status.
Expand Down
18 changes: 9 additions & 9 deletions Sources/Concordium/Domain/Account.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public struct CredentialRegistrationID: Serialize, Deserialize, FromGRPC, ToGRPC
return g
}

public func serializeInto(buffer: inout NIOCore.ByteBuffer) -> Int {
public func serialize(into buffer: inout NIOCore.ByteBuffer) -> Int {
buffer.writeData(value)
}

Expand Down Expand Up @@ -199,7 +199,7 @@ public struct AccountAddress: Hashable, Serialize, Deserialize, ToGRPC, FromGRPC
try .init(grpc.value)
}

public func serializeInto(buffer: inout NIOCore.ByteBuffer) -> Int {
public func serialize(into buffer: inout NIOCore.ByteBuffer) -> Int {
buffer.writeData(data)
}

Expand Down Expand Up @@ -289,15 +289,15 @@ extension CredentialPublicKeys: FromGRPC, Serialize, Deserialize {
)
}

public func serializeInto(buffer: inout ByteBuffer) -> Int {
public func serialize(into buffer: inout ByteBuffer) -> Int {
var res = 0
res += buffer.writeSerializable(map: keys, prefixLength: UInt8.self)
res += buffer.writeSerializable(map: keys, prefix: LengthPrefix<UInt8>())
res += buffer.writeInteger(threshold)
return res
}

public static func deserialize(_ data: inout Cursor) -> CredentialPublicKeys? {
guard let keys = data.deserialize(mapOf: VerifyKey.self, keys: UInt8.self, prefixLength: UInt8.self),
guard let keys = data.deserialize(mapOf: VerifyKey.self, keys: UInt8.self, prefix: LengthPrefix<UInt8>()),
let threshold = data.parseUInt(UInt8.self) else { return nil }
return CredentialPublicKeys(keys: keys, threshold: threshold)
}
Expand Down Expand Up @@ -345,7 +345,7 @@ public enum VerifyKeyError: Error, Equatable {

extension VerifyKey: FromGRPC, Serialize, Deserialize {
public static let SIZE: UInt8 = 32
public func serializeInto(buffer: inout NIOCore.ByteBuffer) -> Int {
public func serialize(into buffer: inout NIOCore.ByteBuffer) -> Int {
buffer.writeInteger(0, as: UInt8.self) + buffer.writeData(key) // We unwrap, as initializing safely will mean this always succeeds
}

Expand Down Expand Up @@ -637,7 +637,7 @@ public struct AmountFraction: FromGRPC, Equatable, Serialize, Deserialize {
.init(partsPerHundredThousand: grpc.partsPerHundredThousand)
}

public func serializeInto(buffer: inout NIOCore.ByteBuffer) -> Int {
public func serialize(into buffer: inout NIOCore.ByteBuffer) -> Int {
buffer.writeInteger(partsPerHundredThousand)
}

Expand Down Expand Up @@ -687,7 +687,7 @@ public enum OpenStatus: UInt8, FromGRPC, Equatable, Serialize, Deserialize, Coda
try .init(rawValue: UInt8(grpc.rawValue)) ?! GRPCError.unsupportedValue("open status '\(grpc.rawValue)'")
}

public func serializeInto(buffer: inout NIOCore.ByteBuffer) -> Int {
public func serialize(into buffer: inout NIOCore.ByteBuffer) -> Int {
buffer.writeInteger(rawValue)
}

Expand Down Expand Up @@ -750,7 +750,7 @@ public enum DelegationTarget: FromGRPC, Equatable, Serialize, Deserialize {
}
}

public func serializeInto(buffer: inout NIOCore.ByteBuffer) -> Int {
public func serialize(into buffer: inout NIOCore.ByteBuffer) -> Int {
var res = 0
switch self {
case .passive:
Expand Down
2 changes: 1 addition & 1 deletion Sources/Concordium/Domain/Amount.swift
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public struct CCDError: Error {
public struct CCD: CustomStringConvertible, Codable, Serialize, Deserialize, ToGRPC, FromGRPC, Equatable {
typealias GRPC = Concordium_V2_Amount

public func serializeInto(buffer: inout NIOCore.ByteBuffer) -> Int {
public func serialize(into buffer: inout NIOCore.ByteBuffer) -> Int {
buffer.writeInteger(microCCD)
}

Expand Down
Loading

0 comments on commit fdc953e

Please sign in to comment.