spb/os-vault Public
Self-custody, multi-chain crypto wallet for macOS. One recovery phrase, six chain families, zero API keys — nothing leaves your Mac.
Swift 96%
Shell 3.4%
Makefile 0.6%
1import WalletCoreC2import Foundation3// SPDX-License-Identifier: Apache-2.04//5// Copyright © 2017 Trust Wallet.6//7// This is a GENERATED FILE, changes made here WILL BE LOST.8//910import Foundation1112/// Represents Ethereum ABI function13public final class EthereumAbiFunction {1415 let rawValue: OpaquePointer1617 init(rawValue: OpaquePointer) {18 self.rawValue = rawValue19 }2021 public init(name: String) {22 let nameString = TWStringCreateWithNSString(name)23 defer {24 TWStringDelete(nameString)25 }26 rawValue = TWEthereumAbiFunctionCreateWithString(nameString)27 }2829 deinit {30 TWEthereumAbiFunctionDelete(rawValue)31 }3233 /// Return the function type signature, of the form "baz(int32,uint256)"34 ///35 /// - Parameter fn: A Non-null eth abi function36 /// - Returns: function type signature as a Non-null string.37 public func getType() -> String {38 return TWStringNSString(TWEthereumAbiFunctionGetType(rawValue))39 }4041 /// Methods for adding parameters of the given type (input or output).42 /// For output parameters (isOutput=true) a value has to be specified, although usually not need;43 /// Add a uint8 type parameter44 ///45 /// - Parameter fn: A Non-null eth abi function46 /// - Parameter val: for output parameters, value has to be specified47 /// - Parameter isOutput: determines if the parameter is an input or output48 /// - Returns: the index of the parameter (0-based).49 @discardableResult50 public func addParamUInt8(val: UInt8, isOutput: Bool) -> Int32 {51 return TWEthereumAbiFunctionAddParamUInt8(rawValue, val, isOutput)52 }5354 /// Add a uint16 type parameter55 ///56 /// - Parameter fn: A Non-null eth abi function57 /// - Parameter val: for output parameters, value has to be specified58 /// - Parameter isOutput: determines if the parameter is an input or output59 /// - Returns: the index of the parameter (0-based).60 @discardableResult61 public func addParamUInt16(val: UInt16, isOutput: Bool) -> Int32 {62 return TWEthereumAbiFunctionAddParamUInt16(rawValue, val, isOutput)63 }6465 /// Add a uint32 type parameter66 ///67 /// - Parameter fn: A Non-null eth abi function68 /// - Parameter val: for output parameters, value has to be specified69 /// - Parameter isOutput: determines if the parameter is an input or output70 /// - Returns: the index of the parameter (0-based).71 @discardableResult72 public func addParamUInt32(val: UInt32, isOutput: Bool) -> Int32 {73 return TWEthereumAbiFunctionAddParamUInt32(rawValue, val, isOutput)74 }7576 /// Add a uint64 type parameter77 ///78 /// - Parameter fn: A Non-null eth abi function79 /// - Parameter val: for output parameters, value has to be specified80 /// - Parameter isOutput: determines if the parameter is an input or output81 /// - Returns: the index of the parameter (0-based).82 @discardableResult83 public func addParamUInt64(val: UInt64, isOutput: Bool) -> Int32 {84 return TWEthereumAbiFunctionAddParamUInt64(rawValue, val, isOutput)85 }8687 /// Add a uint256 type parameter88 ///89 /// - Parameter fn: A Non-null eth abi function90 /// - Parameter val: for output parameters, value has to be specified91 /// - Parameter isOutput: determines if the parameter is an input or output92 /// - Returns: the index of the parameter (0-based).93 @discardableResult94 public func addParamUInt256(val: Data, isOutput: Bool) -> Int32 {95 let valData = TWDataCreateWithNSData(val)96 defer {97 TWDataDelete(valData)98 }99 return TWEthereumAbiFunctionAddParamUInt256(rawValue, valData, isOutput)100 }101102 /// Add a uint(bits) type parameter103 ///104 /// - Parameter fn: A Non-null eth abi function105 /// - Parameter val: for output parameters, value has to be specified106 /// - Parameter isOutput: determines if the parameter is an input or output107 /// - Returns: the index of the parameter (0-based).108 @discardableResult109 public func addParamUIntN(bits: Int32, val: Data, isOutput: Bool) -> Int32 {110 let valData = TWDataCreateWithNSData(val)111 defer {112 TWDataDelete(valData)113 }114 return TWEthereumAbiFunctionAddParamUIntN(rawValue, Int32(bits), valData, isOutput)115 }116117 /// Add a int8 type parameter118 ///119 /// - Parameter fn: A Non-null eth abi function120 /// - Parameter val: for output parameters, value has to be specified121 /// - Parameter isOutput: determines if the parameter is an input or output122 /// - Returns: the index of the parameter (0-based).123 @discardableResult124 public func addParamInt8(val: Int8, isOutput: Bool) -> Int32 {125 return TWEthereumAbiFunctionAddParamInt8(rawValue, val, isOutput)126 }127128 /// Add a int16 type parameter129 ///130 /// - Parameter fn: A Non-null eth abi function131 /// - Parameter val: for output parameters, value has to be specified132 /// - Parameter isOutput: determines if the parameter is an input or output133 /// - Returns: the index of the parameter (0-based).134 @discardableResult135 public func addParamInt16(val: Int16, isOutput: Bool) -> Int32 {136 return TWEthereumAbiFunctionAddParamInt16(rawValue, val, isOutput)137 }138139 /// Add a int32 type parameter140 ///141 /// - Parameter fn: A Non-null eth abi function142 /// - Parameter val: for output parameters, value has to be specified143 /// - Parameter isOutput: determines if the parameter is an input or output144 /// - Returns: the index of the parameter (0-based).145 @discardableResult146 public func addParamInt32(val: Int32, isOutput: Bool) -> Int32 {147 return TWEthereumAbiFunctionAddParamInt32(rawValue, val, isOutput)148 }149150 /// Add a int64 type parameter151 ///152 /// - Parameter fn: A Non-null eth abi function153 /// - Parameter val: for output parameters, value has to be specified154 /// - Parameter isOutput: determines if the parameter is an input or output155 /// - Returns: the index of the parameter (0-based).156 @discardableResult157 public func addParamInt64(val: Int64, isOutput: Bool) -> Int32 {158 return TWEthereumAbiFunctionAddParamInt64(rawValue, val, isOutput)159 }160161 /// Add a int256 type parameter162 ///163 /// - Parameter fn: A Non-null eth abi function164 /// - Parameter val: for output parameters, value has to be specified (stored in a block of data)165 /// - Parameter isOutput: determines if the parameter is an input or output166 /// - Returns: the index of the parameter (0-based).167 @discardableResult168 public func addParamInt256(val: Data, isOutput: Bool) -> Int32 {169 let valData = TWDataCreateWithNSData(val)170 defer {171 TWDataDelete(valData)172 }173 return TWEthereumAbiFunctionAddParamInt256(rawValue, valData, isOutput)174 }175176 /// Add a int(bits) type parameter177 ///178 /// - Parameter fn: A Non-null eth abi function179 /// - Parameter bits: Number of bits of the integer parameter180 /// - Parameter val: for output parameters, value has to be specified181 /// - Parameter isOutput: determines if the parameter is an input or output182 /// - Returns: the index of the parameter (0-based).183 @discardableResult184 public func addParamIntN(bits: Int32, val: Data, isOutput: Bool) -> Int32 {185 let valData = TWDataCreateWithNSData(val)186 defer {187 TWDataDelete(valData)188 }189 return TWEthereumAbiFunctionAddParamIntN(rawValue, Int32(bits), valData, isOutput)190 }191192 /// Add a bool type parameter193 ///194 /// - Parameter fn: A Non-null eth abi function195 /// - Parameter val: for output parameters, value has to be specified196 /// - Parameter isOutput: determines if the parameter is an input or output197 /// - Returns: the index of the parameter (0-based).198 @discardableResult199 public func addParamBool(val: Bool, isOutput: Bool) -> Int32 {200 return TWEthereumAbiFunctionAddParamBool(rawValue, val, isOutput)201 }202203 /// Add a string type parameter204 ///205 /// - Parameter fn: A Non-null eth abi function206 /// - Parameter val: for output parameters, value has to be specified207 /// - Parameter isOutput: determines if the parameter is an input or output208 /// - Returns: the index of the parameter (0-based).209 @discardableResult210 public func addParamString(val: String, isOutput: Bool) -> Int32 {211 let valString = TWStringCreateWithNSString(val)212 defer {213 TWStringDelete(valString)214 }215 return TWEthereumAbiFunctionAddParamString(rawValue, valString, isOutput)216 }217218 /// Add an address type parameter219 ///220 /// - Parameter fn: A Non-null eth abi function221 /// - Parameter val: for output parameters, value has to be specified222 /// - Parameter isOutput: determines if the parameter is an input or output223 /// - Returns: the index of the parameter (0-based).224 @discardableResult225 public func addParamAddress(val: Data, isOutput: Bool) -> Int32 {226 let valData = TWDataCreateWithNSData(val)227 defer {228 TWDataDelete(valData)229 }230 return TWEthereumAbiFunctionAddParamAddress(rawValue, valData, isOutput)231 }232233 /// Add a bytes type parameter234 ///235 /// - Parameter fn: A Non-null eth abi function236 /// - Parameter val: for output parameters, value has to be specified237 /// - Parameter isOutput: determines if the parameter is an input or output238 /// - Returns: the index of the parameter (0-based).239 @discardableResult240 public func addParamBytes(val: Data, isOutput: Bool) -> Int32 {241 let valData = TWDataCreateWithNSData(val)242 defer {243 TWDataDelete(valData)244 }245 return TWEthereumAbiFunctionAddParamBytes(rawValue, valData, isOutput)246 }247248 /// Add a bytes[N] type parameter249 ///250 /// - Parameter fn: A Non-null eth abi function251 /// - Parameter size: fixed size of the bytes array parameter (val).252 /// - Parameter val: for output parameters, value has to be specified253 /// - Parameter isOutput: determines if the parameter is an input or output254 /// - Returns: the index of the parameter (0-based).255 @discardableResult256 public func addParamBytesFix(size: Int, val: Data, isOutput: Bool) -> Int32 {257 let valData = TWDataCreateWithNSData(val)258 defer {259 TWDataDelete(valData)260 }261 return TWEthereumAbiFunctionAddParamBytesFix(rawValue, size, valData, isOutput)262 }263264 /// Add a type[] type parameter265 ///266 /// - Parameter fn: A Non-null eth abi function267 /// - Parameter val: for output parameters, value has to be specified268 /// - Parameter isOutput: determines if the parameter is an input or output269 /// - Returns: the index of the parameter (0-based).270 @discardableResult271 public func addParamArray(isOutput: Bool) -> Int32 {272 return TWEthereumAbiFunctionAddParamArray(rawValue, isOutput)273 }274275 /// Methods for accessing the value of an output or input parameter, of different types.276 /// Get a uint8 type parameter at the given index277 ///278 /// - Parameter fn: A Non-null eth abi function279 /// - Parameter idx: index for the parameter (0-based).280 /// - Parameter isOutput: determines if the parameter is an input or output281 /// - Returns: the value of the parameter.282 public func getParamUInt8(idx: Int32, isOutput: Bool) -> UInt8 {283 return TWEthereumAbiFunctionGetParamUInt8(rawValue, Int32(idx), isOutput)284 }285286 /// Get a uint64 type parameter at the given index287 ///288 /// - Parameter fn: A Non-null eth abi function289 /// - Parameter idx: index for the parameter (0-based).290 /// - Parameter isOutput: determines if the parameter is an input or output291 /// - Returns: the value of the parameter.292 public func getParamUInt64(idx: Int32, isOutput: Bool) -> UInt64 {293 return TWEthereumAbiFunctionGetParamUInt64(rawValue, Int32(idx), isOutput)294 }295296 /// Get a uint256 type parameter at the given index297 ///298 /// - Parameter fn: A Non-null eth abi function299 /// - Parameter idx: index for the parameter (0-based).300 /// - Parameter isOutput: determines if the parameter is an input or output301 /// - Returns: the value of the parameter stored in a block of data.302 public func getParamUInt256(idx: Int32, isOutput: Bool) -> Data {303 return TWDataNSData(TWEthereumAbiFunctionGetParamUInt256(rawValue, Int32(idx), isOutput))304 }305306 /// Get a bool type parameter at the given index307 ///308 /// - Parameter fn: A Non-null eth abi function309 /// - Parameter idx: index for the parameter (0-based).310 /// - Parameter isOutput: determines if the parameter is an input or output311 /// - Returns: the value of the parameter.312 public func getParamBool(idx: Int32, isOutput: Bool) -> Bool {313 return TWEthereumAbiFunctionGetParamBool(rawValue, Int32(idx), isOutput)314 }315316 /// Get a string type parameter at the given index317 ///318 /// - Parameter fn: A Non-null eth abi function319 /// - Parameter idx: index for the parameter (0-based).320 /// - Parameter isOutput: determines if the parameter is an input or output321 /// - Returns: the value of the parameter.322 public func getParamString(idx: Int32, isOutput: Bool) -> String {323 return TWStringNSString(TWEthereumAbiFunctionGetParamString(rawValue, Int32(idx), isOutput))324 }325326 /// Get an address type parameter at the given index327 ///328 /// - Parameter fn: A Non-null eth abi function329 /// - Parameter idx: index for the parameter (0-based).330 /// - Parameter isOutput: determines if the parameter is an input or output331 /// - Returns: the value of the parameter.332 public func getParamAddress(idx: Int32, isOutput: Bool) -> Data {333 return TWDataNSData(TWEthereumAbiFunctionGetParamAddress(rawValue, Int32(idx), isOutput))334 }335336 /// Methods for adding a parameter of the given type to a top-level input parameter array. Returns the index of the parameter (0-based).337 /// Note that nested ParamArrays are not possible through this API, could be done by using index paths like "1/0"338 /// Adding a uint8 type parameter of to the top-level input parameter array339 ///340 /// - Parameter fn: A Non-null eth abi function341 /// - Parameter arrayIdx: array index for the abi function (0-based).342 /// - Parameter val: the value of the parameter343 /// - Returns: the index of the added parameter (0-based).344 @discardableResult345 public func addInArrayParamUInt8(arrayIdx: Int32, val: UInt8) -> Int32 {346 return TWEthereumAbiFunctionAddInArrayParamUInt8(rawValue, Int32(arrayIdx), val)347 }348349 /// Adding a uint16 type parameter of to the top-level input parameter array350 ///351 /// - Parameter fn: A Non-null eth abi function352 /// - Parameter arrayIdx: array index for the abi function (0-based).353 /// - Parameter val: the value of the parameter354 /// - Returns: the index of the added parameter (0-based).355 @discardableResult356 public func addInArrayParamUInt16(arrayIdx: Int32, val: UInt16) -> Int32 {357 return TWEthereumAbiFunctionAddInArrayParamUInt16(rawValue, Int32(arrayIdx), val)358 }359360 /// Adding a uint32 type parameter of to the top-level input parameter array361 ///362 /// - Parameter fn: A Non-null eth abi function363 /// - Parameter arrayIdx: array index for the abi function (0-based).364 /// - Parameter val: the value of the parameter365 /// - Returns: the index of the added parameter (0-based).366 @discardableResult367 public func addInArrayParamUInt32(arrayIdx: Int32, val: UInt32) -> Int32 {368 return TWEthereumAbiFunctionAddInArrayParamUInt32(rawValue, Int32(arrayIdx), val)369 }370371 /// Adding a uint64 type parameter of to the top-level input parameter array372 ///373 /// - Parameter fn: A Non-null eth abi function374 /// - Parameter arrayIdx: array index for the abi function (0-based).375 /// - Parameter val: the value of the parameter376 /// - Returns: the index of the added parameter (0-based).377 @discardableResult378 public func addInArrayParamUInt64(arrayIdx: Int32, val: UInt64) -> Int32 {379 return TWEthereumAbiFunctionAddInArrayParamUInt64(rawValue, Int32(arrayIdx), val)380 }381382 /// Adding a uint256 type parameter of to the top-level input parameter array383 ///384 /// - Parameter fn: A Non-null eth abi function385 /// - Parameter arrayIdx: array index for the abi function (0-based).386 /// - Parameter val: the value of the parameter stored in a block of data387 /// - Returns: the index of the added parameter (0-based).388 @discardableResult389 public func addInArrayParamUInt256(arrayIdx: Int32, val: Data) -> Int32 {390 let valData = TWDataCreateWithNSData(val)391 defer {392 TWDataDelete(valData)393 }394 return TWEthereumAbiFunctionAddInArrayParamUInt256(rawValue, Int32(arrayIdx), valData)395 }396397 /// Adding a uint[N] type parameter of to the top-level input parameter array398 ///399 /// - Parameter fn: A Non-null eth abi function400 /// - Parameter bits: Number of bits of the integer parameter401 /// - Parameter arrayIdx: array index for the abi function (0-based).402 /// - Parameter val: the value of the parameter stored in a block of data403 /// - Returns: the index of the added parameter (0-based).404 @discardableResult405 public func addInArrayParamUIntN(arrayIdx: Int32, bits: Int32, val: Data) -> Int32 {406 let valData = TWDataCreateWithNSData(val)407 defer {408 TWDataDelete(valData)409 }410 return TWEthereumAbiFunctionAddInArrayParamUIntN(rawValue, Int32(arrayIdx), Int32(bits), valData)411 }412413 /// Adding a int8 type parameter of to the top-level input parameter array414 ///415 /// - Parameter fn: A Non-null eth abi function416 /// - Parameter arrayIdx: array index for the abi function (0-based).417 /// - Parameter val: the value of the parameter418 /// - Returns: the index of the added parameter (0-based).419 @discardableResult420 public func addInArrayParamInt8(arrayIdx: Int32, val: Int8) -> Int32 {421 return TWEthereumAbiFunctionAddInArrayParamInt8(rawValue, Int32(arrayIdx), val)422 }423424 /// Adding a int16 type parameter of to the top-level input parameter array425 ///426 /// - Parameter fn: A Non-null eth abi function427 /// - Parameter arrayIdx: array index for the abi function (0-based).428 /// - Parameter val: the value of the parameter429 /// - Returns: the index of the added parameter (0-based).430 @discardableResult431 public func addInArrayParamInt16(arrayIdx: Int32, val: Int16) -> Int32 {432 return TWEthereumAbiFunctionAddInArrayParamInt16(rawValue, Int32(arrayIdx), val)433 }434435 /// Adding a int32 type parameter of to the top-level input parameter array436 ///437 /// - Parameter fn: A Non-null eth abi function438 /// - Parameter arrayIdx: array index for the abi function (0-based).439 /// - Parameter val: the value of the parameter440 /// - Returns: the index of the added parameter (0-based).441 @discardableResult442 public func addInArrayParamInt32(arrayIdx: Int32, val: Int32) -> Int32 {443 return TWEthereumAbiFunctionAddInArrayParamInt32(rawValue, Int32(arrayIdx), val)444 }445446 /// Adding a int64 type parameter of to the top-level input parameter array447 ///448 /// - Parameter fn: A Non-null eth abi function449 /// - Parameter arrayIdx: array index for the abi function (0-based).450 /// - Parameter val: the value of the parameter451 /// - Returns: the index of the added parameter (0-based).452 @discardableResult453 public func addInArrayParamInt64(arrayIdx: Int32, val: Int64) -> Int32 {454 return TWEthereumAbiFunctionAddInArrayParamInt64(rawValue, Int32(arrayIdx), val)455 }456457 /// Adding a int256 type parameter of to the top-level input parameter array458 ///459 /// - Parameter fn: A Non-null eth abi function460 /// - Parameter arrayIdx: array index for the abi function (0-based).461 /// - Parameter val: the value of the parameter stored in a block of data462 /// - Returns: the index of the added parameter (0-based).463 @discardableResult464 public func addInArrayParamInt256(arrayIdx: Int32, val: Data) -> Int32 {465 let valData = TWDataCreateWithNSData(val)466 defer {467 TWDataDelete(valData)468 }469 return TWEthereumAbiFunctionAddInArrayParamInt256(rawValue, Int32(arrayIdx), valData)470 }471472 /// Adding a int[N] type parameter of to the top-level input parameter array473 ///474 /// - Parameter fn: A Non-null eth abi function475 /// - Parameter bits: Number of bits of the integer parameter476 /// - Parameter arrayIdx: array index for the abi function (0-based).477 /// - Parameter val: the value of the parameter stored in a block of data478 /// - Returns: the index of the added parameter (0-based).479 @discardableResult480 public func addInArrayParamIntN(arrayIdx: Int32, bits: Int32, val: Data) -> Int32 {481 let valData = TWDataCreateWithNSData(val)482 defer {483 TWDataDelete(valData)484 }485 return TWEthereumAbiFunctionAddInArrayParamIntN(rawValue, Int32(arrayIdx), Int32(bits), valData)486 }487488 /// Adding a bool type parameter of to the top-level input parameter array489 ///490 /// - Parameter fn: A Non-null eth abi function491 /// - Parameter arrayIdx: array index for the abi function (0-based).492 /// - Parameter val: the value of the parameter493 /// - Returns: the index of the added parameter (0-based).494 @discardableResult495 public func addInArrayParamBool(arrayIdx: Int32, val: Bool) -> Int32 {496 return TWEthereumAbiFunctionAddInArrayParamBool(rawValue, Int32(arrayIdx), val)497 }498499 /// Adding a string type parameter of to the top-level input parameter array500 ///501 /// - Parameter fn: A Non-null eth abi function502 /// - Parameter arrayIdx: array index for the abi function (0-based).503 /// - Parameter val: the value of the parameter504 /// - Returns: the index of the added parameter (0-based).505 @discardableResult506 public func addInArrayParamString(arrayIdx: Int32, val: String) -> Int32 {507 let valString = TWStringCreateWithNSString(val)508 defer {509 TWStringDelete(valString)510 }511 return TWEthereumAbiFunctionAddInArrayParamString(rawValue, Int32(arrayIdx), valString)512 }513514 /// Adding an address type parameter of to the top-level input parameter array515 ///516 /// - Parameter fn: A Non-null eth abi function517 /// - Parameter arrayIdx: array index for the abi function (0-based).518 /// - Parameter val: the value of the parameter519 /// - Returns: the index of the added parameter (0-based).520 @discardableResult521 public func addInArrayParamAddress(arrayIdx: Int32, val: Data) -> Int32 {522 let valData = TWDataCreateWithNSData(val)523 defer {524 TWDataDelete(valData)525 }526 return TWEthereumAbiFunctionAddInArrayParamAddress(rawValue, Int32(arrayIdx), valData)527 }528529 /// Adding a bytes type parameter of to the top-level input parameter array530 ///531 /// - Parameter fn: A Non-null eth abi function532 /// - Parameter arrayIdx: array index for the abi function (0-based).533 /// - Parameter val: the value of the parameter534 /// - Returns: the index of the added parameter (0-based).535 @discardableResult536 public func addInArrayParamBytes(arrayIdx: Int32, val: Data) -> Int32 {537 let valData = TWDataCreateWithNSData(val)538 defer {539 TWDataDelete(valData)540 }541 return TWEthereumAbiFunctionAddInArrayParamBytes(rawValue, Int32(arrayIdx), valData)542 }543544 /// Adding a int64 type parameter of to the top-level input parameter array545 ///546 /// - Parameter fn: A Non-null eth abi function547 /// - Parameter arrayIdx: array index for the abi function (0-based).548 /// - Parameter size: fixed size of the bytes array parameter (val).549 /// - Parameter val: the value of the parameter550 /// - Returns: the index of the added parameter (0-based).551 @discardableResult552 public func addInArrayParamBytesFix(arrayIdx: Int32, size: Int, val: Data) -> Int32 {553 let valData = TWDataCreateWithNSData(val)554 defer {555 TWDataDelete(valData)556 }557 return TWEthereumAbiFunctionAddInArrayParamBytesFix(rawValue, Int32(arrayIdx), size, valData)558 }559560}561