Skip to content

Commit

Permalink
Some method renaming to match PR documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
yaroslavyaroslav committed Sep 7, 2022
1 parent c2d8444 commit 511c233
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 19 deletions.
14 changes: 7 additions & 7 deletions Sources/Core/Transaction/CodableTransaction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public struct CodableTransaction {

/// storage container for additional metadata returned by the node
/// when a transaction is decoded form a JSON stream
public var meta: EthereumMetadata?
public var meta: TransactionMetadata?

// MARK: - Properties that always sends to a Node

Expand Down Expand Up @@ -243,7 +243,7 @@ extension CodableTransaction: Codable {
maxPriorityFeePerGasPolicy = .automatic

// capture any metadata that might be present
self.meta = try EthereumMetadata(from: decoder)
self.meta = try TransactionMetadata(from: decoder)
}

public func encode(to encoder: Encoder) throws {
Expand Down Expand Up @@ -312,7 +312,7 @@ extension CodableTransaction {
case manual(BigUInt)
}

public func resolveNonce(provider: Web3Provider) async throws -> BigUInt {
func resolveNonce(provider: Web3Provider) async throws -> BigUInt {
switch noncePolicy {
case .pending, .latest, .earliest:
guard let address = from ?? sender else { throw Web3Error.valueError }
Expand All @@ -324,7 +324,7 @@ extension CodableTransaction {
}
}

public func resolveGasPrice(provider: Web3Provider) async throws -> BigUInt {
func resolveGasPrice(provider: Web3Provider) async throws -> BigUInt {
let oracle = Oracle(provider)
switch gasPricePolicy {
case .automatic, .withMargin:
Expand All @@ -334,7 +334,7 @@ extension CodableTransaction {
}
}

public func resolveGasLimit(provider: Web3Provider) async throws -> BigUInt {
func resolveGasLimit(provider: Web3Provider) async throws -> BigUInt {
let request: APIRequest = .estimateGas(self, self.callOnBlock ?? .latest)
let response: APIResponse<BigUInt> = try await APIRequest.sendRequest(with: provider, for: request)
switch gasLimitPolicy {
Expand All @@ -351,7 +351,7 @@ extension CodableTransaction {
}
}

public func resolveMaxFeePerGas(provider: Web3Provider) async throws -> BigUInt {
func resolveMaxFeePerGas(provider: Web3Provider) async throws -> BigUInt {
let oracle = Oracle(provider)
switch maxFeePerGasPolicy {
case .automatic:
Expand All @@ -361,7 +361,7 @@ extension CodableTransaction {
}
}

public func resolveMaxPriorityFeePerGas(provider: Web3Provider) async throws -> BigUInt {
func resolveMaxPriorityFeePerGas(provider: Web3Provider) async throws -> BigUInt {
let oracle = Oracle(provider)
switch maxPriorityFeePerGasPolicy {
case .automatic:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import BigInt
/// returned by nodes when reading a transaction
/// from the blockchain. The data here is not
/// part of the transaction itself
public struct EthereumMetadata {
public struct TransactionMetadata {

/// hash for the block that contains this transaction on chain
public var blockHash: Data?
Expand All @@ -34,7 +34,7 @@ public struct EthereumMetadata {
public var gasPrice: BigUInt?
}

public extension EthereumMetadata {
public extension TransactionMetadata {
private enum CodingKeys: String, CodingKey {
case blockHash
case blockNumber
Expand Down
2 changes: 1 addition & 1 deletion Sources/web3swift/Web3/Web3+Contract.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ extension web3 {
/// If extraData is supplied it is appended to encoded bytecode and constructor parameters.
///
/// Returns a "Transaction intermediate" object.
public func deploy(bytecode: Data,
public func prepareDeploy(bytecode: Data,
constructor: ABI.Element.Constructor? = nil,
parameters: [AnyObject]? = nil,
extraData: Data? = nil) -> WriteOperation? {
Expand Down
10 changes: 5 additions & 5 deletions Tests/web3swiftTests/localTests/AdvancedABIv2Tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class AdvancedABIv2Tests: LocalTestCase {
var contract = web3.contract(abiString, at: nil, abiVersion: 2)!

// MARK: Writing Data flow
let deployTx = contract.deploy(bytecode: bytecode)!
let deployTx = contract.prepareDeploy(bytecode: bytecode)!
deployTx.transaction.from = allAddresses[0]
deployTx.transaction.gasLimitPolicy = .manual(3000000)
// MARK: Sending Data flow
Expand Down Expand Up @@ -59,7 +59,7 @@ class AdvancedABIv2Tests: LocalTestCase {

let parameters = [] as [AnyObject]
// MARK: Writing Data flow
let deployTx = contract.deploy(bytecode: bytecode, parameters: parameters)!
let deployTx = contract.prepareDeploy(bytecode: bytecode, parameters: parameters)!
deployTx.transaction.from = allAddresses[0]
deployTx.transaction.gasLimitPolicy = .manual(3000000)
let result = try await deployTx.writeToChain(password: "web3swift")
Expand Down Expand Up @@ -96,7 +96,7 @@ class AdvancedABIv2Tests: LocalTestCase {

let parameters = [] as [AnyObject]
// MARK: Writing Data flow
let deployTx = contract.deploy(bytecode: bytecode, parameters: parameters)!
let deployTx = contract.prepareDeploy(bytecode: bytecode, parameters: parameters)!
deployTx.transaction.from = allAddresses[0]
deployTx.transaction.gasLimitPolicy = .manual(3000000)
let result = try await deployTx.writeToChain(password: "web3swift")
Expand Down Expand Up @@ -132,7 +132,7 @@ class AdvancedABIv2Tests: LocalTestCase {

let parameters = [] as [AnyObject]
// MARK: Writing Data flow
let deployTx = contract.deploy(bytecode: bytecode, parameters: parameters)!
let deployTx = contract.prepareDeploy(bytecode: bytecode, parameters: parameters)!
deployTx.transaction.from = allAddresses[0]
deployTx.transaction.gasLimitPolicy = .manual(3000000)
let result = try await deployTx.writeToChain(password: "web3swift")
Expand Down Expand Up @@ -169,7 +169,7 @@ class AdvancedABIv2Tests: LocalTestCase {

let parameters = [] as [AnyObject]
// MARK: Writing Data flow
let deployTx = contract.deploy(bytecode: bytecode, parameters: parameters)!
let deployTx = contract.prepareDeploy(bytecode: bytecode, parameters: parameters)!
deployTx.transaction.from = allAddresses[0]
deployTx.transaction.gasLimitPolicy = .manual(3000000)
let result = try await deployTx.writeToChain(password: "web3swift")
Expand Down
2 changes: 1 addition & 1 deletion Tests/web3swiftTests/localTests/BasicLocalNodeTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class BasicLocalNodeTests: LocalTestCase {

let parameters = [] as [AnyObject]
// MARK: Writing Data flow
let deployTx = contract.deploy(bytecode: bytecode, parameters: parameters)!
let deployTx = contract.prepareDeploy(bytecode: bytecode, parameters: parameters)!
deployTx.transaction.from = allAddresses[0]
deployTx.transaction.gasLimitPolicy = .manual(3000000)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class PersonalSignatureTests: XCTestCase {
let bytecode = Data.fromHex("0x608060405234801561001057600080fd5b506105ba806100206000396000f30060806040526004361061004c576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680632785e93714610051578063d01ec9a514610123575b600080fd5b34801561005d57600080fd5b506100e1600480360381019080803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290803560ff169060200190929190803560001916906020019092919080356000191690602001909291905050506101a8565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561012f57600080fd5b5061018a600480360381019080803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290505050610258565b60405180826000191660001916815260200191505060405180910390f35b6000806101b486610258565b9050601b8560ff1610156101c957601b850194505b600181868686604051600081526020016040526040518085600019166000191681526020018460ff1660ff1681526020018360001916600019168152602001826000191660001916815260200194505050505060206040516020810390808403906000865af1158015610240573d6000803e3d6000fd5b50505060206040510351915081915050949350505050565b600080825190506040805190810160405280601a81526020017f19457468657265756d205369676e6564204d6573736167653a0a00000000000081525061029e826103b4565b846040518084805190602001908083835b6020831015156102d457805182526020820191506020810190506020830392506102af565b6001836020036101000a03801982511681845116808217855250505050505090500183805190602001908083835b6020831015156103275780518252602082019150602081019050602083039250610302565b6001836020036101000a03801982511681845116808217855250505050505090500182805190602001908083835b60208310151561037a5780518252602082019150602081019050602083039250610355565b6001836020036101000a03801982511681845116808217855250505050505090500193505050506040518091039020915081915050919050565b606060006060600080600060649450846040519080825280601f01601f1916602001820160405280156103f65781602001602082028038833980820191505090505b509350600092505b60008714151561049557600a8781151561041457fe5b069150600a8781151561042357fe5b049650816030017f010000000000000000000000000000000000000000000000000000000000000002848480600101955081518110151561046057fe5b9060200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053506103fe565b826040519080825280601f01601f1916602001820160405280156104c85781602001602082028038833980820191505090505b509550600090505b8281101561058157838160018503038151811015156104eb57fe5b9060200101517f010000000000000000000000000000000000000000000000000000000000000090047f010000000000000000000000000000000000000000000000000000000000000002868281518110151561054457fe5b9060200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535080806001019150506104d0565b85955050505050509190505600a165627a7a723058204b567e6628d988bde2e19a4e9a457bf84bbeac15069a74fe993aba215fb024330029")!

var contract = web3.contract(abiString, at: nil, abiVersion: 2)!
let deployTx = contract.deploy(bytecode: bytecode)!
let deployTx = contract.prepareDeploy(bytecode: bytecode)!
let allAddresses = try await web3.eth.ownedAccounts()
deployTx.transaction.from = allAddresses[0]
deployTx.transaction.gasLimitPolicy = .manual(3000000)
Expand Down
2 changes: 1 addition & 1 deletion Tests/web3swiftTests/localTests/TestHelpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class TestHelpers {
EthereumAddress("0xe22b8979739D724343bd002F9f432F5990879901")!,
1024
] as [AnyObject]
let deployTx = contract.deploy(bytecode: bytecode,
let deployTx = contract.prepareDeploy(bytecode: bytecode,
constructor: contract.contract.constructor,
parameters: parameters)!
deployTx.transaction.from = allAddresses[0]
Expand Down
2 changes: 1 addition & 1 deletion Tests/web3swiftTests/localTests/UserCases.swift
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class UserCases: XCTestCase {
let contract = web3.contract(Web3.Utils.estimateGasTestABI, at: nil, abiVersion: 2)!

let parameters = [] as [AnyObject]
let deployTx = contract.deploy(bytecode: bytecode, parameters: parameters)!
let deployTx = contract.prepareDeploy(bytecode: bytecode, parameters: parameters)!
deployTx.transaction.from = allAddresses[0]
deployTx.transaction.gasLimitPolicy = .manual(3000000)
let result = try await deployTx.writeToChain(password: "web3swift")
Expand Down

0 comments on commit 511c233

Please sign in to comment.