Skip to content

Commit

Permalink
Merge pull request #5 from tangem/IOS-3888-Update-to-latest-master
Browse files Browse the repository at this point in the history
IOS-3888 Update to latest master at 035f447b43a0dd0f4e0c2c5577f32b101ca834cb
  • Loading branch information
Balashov152 committed Jun 27, 2023
2 parents 50686e6 + 664a7a3 commit d46e24e
Show file tree
Hide file tree
Showing 24 changed files with 680 additions and 6 deletions.
2 changes: 1 addition & 1 deletion TangemWalletCore.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Pod::Spec.new do |s|
s.name = 'TangemWalletCore'
s.version = '3.1.9-tangem1'
s.version = '3.2.1-tangem1'
s.summary = 'Use TW xcframework for Tangem integration'

# This description is used to generate tags and improve search results.
Expand Down
10 changes: 5 additions & 5 deletions WalletCore.xcframework/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,30 @@
<array>
<dict>
<key>LibraryIdentifier</key>
<string>ios-arm64_x86_64-simulator</string>
<string>ios-arm64</string>
<key>LibraryPath</key>
<string>WalletCore.framework</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
<string>x86_64</string>
</array>
<key>SupportedPlatform</key>
<string>ios</string>
<key>SupportedPlatformVariant</key>
<string>simulator</string>
</dict>
<dict>
<key>LibraryIdentifier</key>
<string>ios-arm64</string>
<string>ios-arm64_x86_64-simulator</string>
<key>LibraryPath</key>
<string>WalletCore.framework</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
<string>x86_64</string>
</array>
<key>SupportedPlatform</key>
<string>ios</string>
<key>SupportedPlatformVariant</key>
<string>simulator</string>
</dict>
</array>
<key>CFBundlePackageType</key>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright © 2017-2023 Trust Wallet.
//
// This file is part of Trust. The full Trust copyright notice, including
// terms governing use, modification, and redistribution, is contained in the
// file LICENSE at the root of the source code distribution tree.

#pragma once

#include "TWData.h"

TW_EXTERN_C_BEGIN

/// Represents an ASN.1 DER parser.
TW_EXPORT_STRUCT
struct TWAsnParser;

/// Parses the given ECDSA signature from ASN.1 DER encoded bytes.
///
/// \param encoded The ASN.1 DER encoded signature.
/// \return The ECDSA signature standard binary representation: RS, where R - 32 byte array, S - 32 byte array.
TW_EXPORT_STATIC_METHOD
TWData* _Nullable TWAsnParserEcdsaSignatureFromDer(TWData* _Nonnull encoded);

TW_EXTERN_C_END
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Copyright © 2017-2023 Trust Wallet.
//
// This file is part of Trust. The full Trust copyright notice, including
// terms governing use, modification, and redistribution, is contained in the
// file LICENSE at the root of the source code distribution tree.
#pragma once

#include "TWBase.h"
#include "TWData.h"
#include "TWString.h"
#include "TWPublicKey.h"

TW_EXTERN_C_BEGIN

/// Barz functions
TW_EXPORT_STRUCT
struct TWBarz;

/// Calculate a counterfactual address for the smart contract wallet
///
/// \param input The serialized data of ContractAddressInput.
/// \return The address.
TW_EXPORT_STATIC_METHOD
TWString *_Nonnull TWBarzGetCounterfactualAddress(TWData *_Nonnull input);

/// Returns the init code parameter of ERC-4337 User Operation
///
/// \param factory Wallet factory address (BarzFactory)
/// \param publicKey Public key for the verification facet
/// \param verificationFacet Verification facet address
/// \return The address.
TW_EXPORT_STATIC_METHOD
TWData *_Nonnull TWBarzGetInitCode(TWString* _Nonnull factory, struct TWPublicKey* _Nonnull publicKey, TWString* _Nonnull verificationFacet);

/// Converts the original ASN-encoded signature from webauthn to the format accepted by Barz
///
/// \param signature Original signature
/// \param challenge The original challenge that was signed
/// \param authenticatorData Returned from Webauthn API
/// \param clientDataJSON Returned from Webauthn API
/// \return Bytes of the formatted signature
TW_EXPORT_STATIC_METHOD
TWData *_Nonnull TWBarzGetFormattedSignature(TWData* _Nonnull signature, TWData* _Nonnull challenge, TWData* _Nonnull authenticatorData, TWString* _Nonnull clientDataJSON);
TW_EXTERN_C_END
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Copyright © 2017-2023 Trust Wallet.
//
// This file is part of Trust. The full Trust copyright notice, including
// terms governing use, modification, and redistribution, is contained in the
// file LICENSE at the root of the source code distribution tree.

#pragma once

#include "TWBase.h"
#include "TWData.h"
#include "TWString.h"

TW_EXTERN_C_BEGIN

/// Filecoin-Ethereum address converter.
TW_EXPORT_STRUCT
struct TWFilecoinAddressConverter;

/// Converts a Filecoin address to Ethereum.
///
/// \param filecoinAddress: a Filecoin address.
/// \returns the Ethereum address. On invalid input empty string is returned. Returned object needs to be deleted after use.
TW_EXPORT_STATIC_METHOD
TWString* _Nonnull TWFilecoinAddressConverterConvertToEthereum(TWString* _Nonnull filecoinAddress);

/// Converts an Ethereum address to Filecoin.
///
/// \param ethAddress: an Ethereum address.
/// \returns the Filecoin address. On invalid input empty string is returned. Returned object needs to be deleted after use.
TW_EXPORT_STATIC_METHOD
TWString* _Nonnull TWFilecoinAddressConverterConvertFromEthereum(TWString* _Nonnull ethAddress);

TW_EXTERN_C_END
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright © 2017-2023 Trust Wallet.
//
// This file is part of Trust. The full Trust copyright notice, including
// terms governing use, modification, and redistribution, is contained in the
// file LICENSE at the root of the source code distribution tree.

#pragma once

#include "TWBase.h"

TW_EXTERN_C_BEGIN

/// Filecoin address type.
TW_EXPORT_ENUM(uint32_t)
enum TWFilecoinAddressType {
TWFilecoinAddressTypeDefault = 0, // default
TWFilecoinAddressTypeDelegated = 1,
};

TW_EXTERN_C_END
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright © 2017-2023 Trust Wallet.
//
// This file is part of Trust. The full Trust copyright notice, including
// terms governing use, modification, and redistribution, is contained in the
// file LICENSE at the root of the source code distribution tree.
#pragma once

#include "TWBase.h"
#include "TWData.h"
#include "TWString.h"

TW_EXTERN_C_BEGIN

/// THORChain swap functions
TW_EXPORT_STRUCT
struct TWLiquidStaking;

/// Builds a LiquidStaking transaction input.
///
/// \param input The serialized data of LiquidStakingInput.
/// \return The serialized data of LiquidStakingOutput.
TW_EXPORT_STATIC_METHOD
TWData *_Nonnull TWLiquidStakingBuildRequest(TWData *_Nonnull input);

TW_EXTERN_C_END
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Copyright © 2017-2023 Trust Wallet.
//
// This file is part of Trust. The full Trust copyright notice, including
// terms governing use, modification, and redistribution, is contained in the
// file LICENSE at the root of the source code distribution tree.

#pragma once

#include "TWBase.h"
#include "TWData.h"
#include "TWHRP.h"
#include "TWString.h"

// TODO: Adjust definitions below

TW_EXTERN_C_BEGIN

struct TWPublicKey;

/// Represents a Substrate address.
TW_EXPORT_CLASS
struct TWSubstrateAddress;

/// Compares two addresses for equality.
TW_EXPORT_STATIC_METHOD
bool TWSubstrateAddressEqual(struct TWSubstrateAddress *_Nonnull lhs, struct TWSubstrateAddress *_Nonnull rhs);

/// Determines if the string is a valid Substrate address.
TW_EXPORT_STATIC_METHOD
bool TWSubstrateAddressIsValidString(TWString *_Nonnull string, int32_t network);

/// Creates an address from a string representaion.
TW_EXPORT_STATIC_METHOD
struct TWSubstrateAddress *_Nullable TWSubstrateAddressCreateWithString(TWString *_Nonnull string, int32_t network);

/// Creates an address from a public key.
TW_EXPORT_STATIC_METHOD
struct TWSubstrateAddress *_Nonnull TWSubstrateAddressCreateWithPublicKey(struct TWPublicKey *_Nonnull publicKey, int32_t network);

/// Delete address object
TW_EXPORT_METHOD
void TWSubstrateAddressDelete(struct TWSubstrateAddress *_Nonnull address);

/// Returns the address string representation.
TW_EXPORT_PROPERTY
TWString *_Nonnull TWSubstrateAddressDescription(struct TWSubstrateAddress *_Nonnull address);

TW_EXTERN_C_END
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright © 2017-2023 Trust Wallet.
//
// This file is part of Trust. The full Trust copyright notice, including
// terms governing use, modification, and redistribution, is contained in the
// file LICENSE at the root of the source code distribution tree.

#pragma once

#include "TWBase.h"
#include "TWData.h"
#include "TWSubstrateSigner.h"

TW_EXTERN_C_BEGIN

TW_EXPORT_CLASS
struct TWSubstrateSigner;

/// Builds a message to be signed
TW_EXPORT_STATIC_METHOD
TWData *_Nonnull TWSubstrateSignerMessage(TWData *_Nonnull data);

/// Builds a transaction to be broadcasted
TW_EXPORT_STATIC_METHOD
TWData *_Nonnull TWSubstrateSignerTransaction(TWData *_Nonnull data, TWData *_Nonnull publicKey, TWData *_Nonnull signature);

TW_EXTERN_C_END
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// Copyright © 2017-2023 Trust Wallet.
//
// This file is part of Trust. The full Trust copyright notice, including
// terms governing use, modification, and redistribution, is contained in the
// file LICENSE at the root of the source code distribution tree.

#pragma once

#include "TWBase.h"
#include "TWData.h"
#include "TWString.h"
#include "TWPrivateKey.h"
#include "TWPublicKey.h"

TW_EXTERN_C_BEGIN

/// Tezos message signing, verification and utilities.
TW_EXPORT_STRUCT
struct TWTezosMessageSigner;

/// Implement format input as described in https://tezostaquito.io/docs/signing/
///
/// \param message message to format e.g: Hello, World
/// \param dAppUrl the app url, e.g: testUrl
/// \returns the formatted message as a string
TW_EXPORT_STATIC_METHOD
TWString* _Nonnull TWTezosMessageSignerFormatMessage(TWString* _Nonnull message, TWString* _Nonnull url);

/// Implement input to payload as described in: https://tezostaquito.io/docs/signing/
///
/// \param message formatted message to be turned into an hex payload
/// \return the hexpayload of the formated message as a hex string
TW_EXPORT_STATIC_METHOD
TWString* _Nonnull TWTezosMessageSignerInputToPayload(TWString* _Nonnull message);

/// Sign a message as described in https://tezostaquito.io/docs/signing/
///
/// \param privateKey: the private key used for signing
/// \param message: A custom message payload (hex) which is input to the signing.
/// \returns the signature, Hex-encoded. On invalid input empty string is returned. Returned object needs to be deleted after use.
TW_EXPORT_STATIC_METHOD
TWString* _Nonnull TWTezosMessageSignerSignMessage(const struct TWPrivateKey* _Nonnull privateKey, TWString* _Nonnull message);

/// Verify signature for a message as described in https://tezostaquito.io/docs/signing/
///
/// \param pubKey: pubKey that will verify the message from the signature
/// \param message: the message signed as a payload (hex)
/// \param signature: in Base58-encoded form.
/// \returns false on any invalid input (does not throw), true if the message can be verified from the signature
TW_EXPORT_STATIC_METHOD
bool TWTezosMessageSignerVerifyMessage(const struct TWPublicKey* _Nonnull pubKey, TWString* _Nonnull message, TWString* _Nonnull signature);

TW_EXTERN_C_END
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Copyright © 2017-2023 Trust Wallet.
//
// This file is part of Trust. The full Trust copyright notice, including
// terms governing use, modification, and redistribution, is contained in the
// file LICENSE at the root of the source code distribution tree.

#pragma once

#include "TWBase.h"
#include "TWData.h"
#include "TWString.h"
#include "TWPrivateKey.h"
#include "TWPublicKey.h"

TW_EXTERN_C_BEGIN

/// Tron message signing and verification.
///
/// Tron and some other wallets support a message signing & verification format, to create a proof (a signature)
/// that someone has access to the private keys of a specific address.
TW_EXPORT_STRUCT
struct TWTronMessageSigner;

/// Sign a message.
///
/// \param privateKey: the private key used for signing
/// \param message: A custom message which is input to the signing.
/// \returns the signature, Hex-encoded. On invalid input empty string is returned. Returned object needs to be deleted after use.
TW_EXPORT_STATIC_METHOD
TWString* _Nonnull TWTronMessageSignerSignMessage(const struct TWPrivateKey* _Nonnull privateKey, TWString* _Nonnull message);

/// Verify signature for a message.
///
/// \param pubKey: pubKey that will verify and recover the message from the signature
/// \param message: the message signed (without prefix)
/// \param signature: in Hex-encoded form.
/// \returns false on any invalid input (does not throw), true if the message can be recovered from the signature
TW_EXPORT_STATIC_METHOD
bool TWTronMessageSignerVerifyMessage(const struct TWPublicKey* _Nonnull pubKey, TWString* _Nonnull message, TWString* _Nonnull signature);

TW_EXTERN_C_END
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright © 2017-2023 Trust Wallet.
//
// This file is part of Trust. The full Trust copyright notice, including
// terms governing use, modification, and redistribution, is contained in the
// file LICENSE at the root of the source code distribution tree.
#pragma once

#include "TWBase.h"
#include "TWData.h"
#include "TWPublicKey.h"

TW_EXTERN_C_BEGIN

TW_EXPORT_STRUCT
struct TWWebAuthn;

/// Converts attestation object to the public key on P256 curve
///
/// \param attestationObject Attestation object retrieved from webuthn.get method
/// \return Public key.
TW_EXPORT_STATIC_METHOD
struct TWPublicKey *_Nullable TWWebAuthnGetPublicKey(TWData *_Nonnull attestationObject);
TW_EXTERN_C_END
Binary file modified WalletCore.xcframework/ios-arm64/WalletCore.framework/WalletCore
Binary file not shown.
Loading

0 comments on commit d46e24e

Please sign in to comment.