Skip to content

Commit

Permalink
Access Control
Browse files Browse the repository at this point in the history
- make NFTTransferData public
- make JettonTransferData public
- make CurrencyCollection and ExtraCurrencyCollection public
- make CommonMsgInfoRelaxedInternal properties public
- make CommonMsgInfoRelaxedExternalOut properties public
- make CommonMsgInfoInternal properties public
- make CommonMsgInfoExternalIn properties public
- make CommonMsgInfoExternalOut properties public
- make AnyAddress public
  • Loading branch information
grishamsc committed Dec 1, 2023
1 parent 3aaeeed commit 5df0817
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 61 deletions.
6 changes: 3 additions & 3 deletions Source/TonSwift/Address/AnyAddress.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import Foundation
/// _ _:MsgAddressExt = MsgAddress;
/// ```
///
enum AnyAddress {
public enum AnyAddress {
case none
case internalAddr(Address)
case externalAddr(ExternalAddress)
Expand Down Expand Up @@ -64,7 +64,7 @@ enum AnyAddress {
}

extension AnyAddress: CellCodable {
func storeTo(builder: Builder) throws {
public func storeTo(builder: Builder) throws {
switch self {
case .none:
try builder.store(uint: UInt64(0), bits: 2)
Expand All @@ -78,7 +78,7 @@ extension AnyAddress: CellCodable {
}
}

static func loadFrom(slice: Slice) throws -> AnyAddress {
public static func loadFrom(slice: Slice) throws -> AnyAddress {
let type = try slice.preloadUint(bits: 2)
switch type {
case 0:
Expand Down
34 changes: 17 additions & 17 deletions Source/TonSwift/Contracts/CommonMsgInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,29 +23,29 @@ import Foundation
*/

public struct CommonMsgInfoInternal {
let ihrDisabled: Bool
let bounce: Bool
let bounced: Bool
let src: Address
let dest: Address
let value: CurrencyCollection
let ihrFee: Coins
let forwardFee: Coins
let createdLt: UInt64
let createdAt: UInt32
public let ihrDisabled: Bool
public let bounce: Bool
public let bounced: Bool
public let src: Address
public let dest: Address
public let value: CurrencyCollection
public let ihrFee: Coins
public let forwardFee: Coins
public let createdLt: UInt64
public let createdAt: UInt32
}

public struct CommonMsgInfoExternalIn {
let src: ExternalAddress?
let dest: Address
let importFee: Coins
public let src: ExternalAddress?
public let dest: Address
public let importFee: Coins
}

public struct CommonMsgInfoExternalOut {
let src: Address
let dest: ExternalAddress?
let createdLt: UInt64
let createdAt: UInt32
public let src: Address
public let dest: ExternalAddress?
public let createdLt: UInt64
public let createdAt: UInt32
}

public enum CommonMsgInfo: CellCodable {
Expand Down
28 changes: 14 additions & 14 deletions Source/TonSwift/Contracts/CommonMsgInfoRelaxed.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,23 @@ import Foundation
*/

public struct CommonMsgInfoRelaxedInternal {
let ihrDisabled: Bool
let bounce: Bool
let bounced: Bool
let src: AnyAddress
let dest: Address
let value: CurrencyCollection
let ihrFee: Coins
let forwardFee: Coins
let createdLt: UInt64
let createdAt: UInt32
public let ihrDisabled: Bool
public let bounce: Bool
public let bounced: Bool
public let src: AnyAddress
public let dest: Address
public let value: CurrencyCollection
public let ihrFee: Coins
public let forwardFee: Coins
public let createdLt: UInt64
public let createdAt: UInt32
}

public struct CommonMsgInfoRelaxedExternalOut {
let src: AnyAddress
let dest: ExternalAddress?
let createdLt: UInt64
let createdAt: UInt32
public let src: AnyAddress
public let dest: ExternalAddress?
public let createdLt: UInt64
public let createdAt: UInt32
}

public enum CommonMsgInfoRelaxed: CellCodable {
Expand Down
12 changes: 6 additions & 6 deletions Source/TonSwift/Contracts/CurrencyCollection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,29 @@ import BigInt
/// ```
/// extra_currencies$_ dict:(HashmapE 32 (VarUInteger 32)) = ExtraCurrencyCollection;
/// ```
typealias ExtraCurrencyCollection = [UInt32: VarUInt248]
public typealias ExtraCurrencyCollection = [UInt32: VarUInt248]

/// Implements CurrencyCollection per TLB schema:
///
/// ```
/// currencies$_ grams:Grams other:ExtraCurrencyCollection = CurrencyCollection;
/// ```
struct CurrencyCollection: CellCodable {
let coins: Coins
let other: ExtraCurrencyCollection
public struct CurrencyCollection: CellCodable {
public let coins: Coins
public let other: ExtraCurrencyCollection

init(coins: Coins, other: ExtraCurrencyCollection = [:]) {
self.coins = coins
self.other = other
}

static func loadFrom(slice: Slice) throws -> CurrencyCollection {
public static func loadFrom(slice: Slice) throws -> CurrencyCollection {
let coins = try slice.loadCoins()
let other: ExtraCurrencyCollection = try slice.loadType()
return CurrencyCollection(coins: coins, other: other)
}

func storeTo(builder: Builder) throws {
public func storeTo(builder: Builder) throws {
try builder.store(coins: coins)
try builder.store(other)
}
Expand Down
25 changes: 13 additions & 12 deletions Source/TonSwift/Jettons/JettonTransferData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
import Foundation
import BigInt

struct JettonTransferData: CellCodable {
let queryId: UInt64
let amount: BigUInt
let toAddress: Address
let responseAddress: Address
let forwardAmount: BigUInt
let comment: String?
func storeTo(builder: Builder) throws {
public struct JettonTransferData: CellCodable {
public let queryId: UInt64
public let amount: BigUInt
public let toAddress: Address
public let responseAddress: Address
public let forwardAmount: BigUInt
public let comment: String?

public func storeTo(builder: Builder) throws {
try builder.store(uint: 0xf8a7ea5, bits: 32)
try builder.store(uint: queryId, bits: 64)
try builder.store(coins: Coins(amount.magnitude))
Expand All @@ -31,8 +31,8 @@ struct JettonTransferData: CellCodable {
try builder.store(bit: commentCell != nil)
try builder.storeMaybe(ref: commentCell)
}

static func loadFrom(slice: Slice) throws -> JettonTransferData {
public static func loadFrom(slice: Slice) throws -> JettonTransferData {
_ = try slice.loadUint(bits: 32)
let queryId = try slice.loadUint(bits: 64)
let amount = try slice.loadCoins().amount
Expand All @@ -43,7 +43,8 @@ struct JettonTransferData: CellCodable {

let hasComment = try slice.loadBoolean()
var comment: String?
if hasComment, let commentCell = try slice.loadMaybeRef() {
if hasComment {
let commentCell = try slice.loadRef()
let slice = try commentCell.toSlice()
try slice.skip(32)
comment = try slice.loadSnakeString()
Expand Down
18 changes: 9 additions & 9 deletions Source/TonSwift/NFT/NFTTransferData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
import Foundation
import BigInt

struct NFTTransferData: CellCodable {
let queryId: UInt64
let newOwnerAddress: Address
let responseAddress: Address
let forwardAmount: BigUInt
let forwardPayload: Cell?

func storeTo(builder: Builder) throws {
public struct NFTTransferData: CellCodable {
public let queryId: UInt64
public let newOwnerAddress: Address
public let responseAddress: Address
public let forwardAmount: BigUInt
public let forwardPayload: Cell?
public func storeTo(builder: Builder) throws {
try builder.store(uint: 0x5fcc3d14, bits: 32) // transfer op
try builder.store(uint: queryId, bits: 64)
try builder.store(AnyAddress(newOwnerAddress))
Expand All @@ -26,7 +26,7 @@ struct NFTTransferData: CellCodable {
try builder.storeMaybe(ref: forwardPayload)
}

static func loadFrom(slice: Slice) throws -> NFTTransferData {
public static func loadFrom(slice: Slice) throws -> NFTTransferData {
try slice.skip(32)
let queryId = try slice.loadUint(bits: 64)
let newOwnerAddress: Address = try slice.loadType()
Expand Down

0 comments on commit 5df0817

Please sign in to comment.