Skip to content

Commit da3a735

Browse files
authored
Merge branch 'develop' into crathage-upgrade
2 parents b3d054c + 3dd323b commit da3a735

File tree

3 files changed

+129
-62
lines changed

3 files changed

+129
-62
lines changed

Documentation/BUILD_GUIDE.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
1-
## Default web3swift build:
1+
## Build
2+
3+
### Default web3swift build:
24

35
1. Install carthage:
46
```
5-
$ brew install carthage
7+
brew install carthage
68
```
79
2. Run carthage update:
8-
```
9-
$ carthage update --platform iOS
10-
# Available platforms: `iOS, macOS`
10+
```
11+
# Available platforms: `iOS, macOS`
12+
carthage update --platform iOS --use-xcframeworks
1113
```
1214
3. Build project in XCode:
13-
Command + B
15+
`Command + B`
1416

15-
## Build web3swift into .framework:
17+
### Build web3swift into .framework:
1618
```
17-
$ carthage build --no-skip-current --platform iOS
19+
carthage build --no-skip-current --platform iOS
1820
```

README.md

Lines changed: 118 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
## [Join our discord](https://discord.gg/8tXjHK3pus) if you need a support or want to contribute to web3swift development!
55

6-
![matter-github-swift](https://github.com/matter-labs/web3swift/blob/develop/web3swift-logo.png)
6+
![matter-github-swift](https://github.com/skywinder/web3swift/blob/develop/web3swift-logo.png)
77
[![Build Status](https://travis-ci.com/skywinder/web3swift.svg?branch=develop)](https://travis-ci.com/skywinder/web3swift)
88
[![Swift](https://img.shields.io/badge/Swift-5.4-orange.svg?style=flat)](https://developer.apple.com/swift/)
99
[![Platform](https://img.shields.io/cocoapods/p/web3swift.svg?style=flat)](http://cocoapods.org/pods/web3.swift.pod)
@@ -58,7 +58,7 @@
5858

5959
- [x] **[BIP32](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki) (HD Wallets), [BIP39](https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki) (Seed phrases), [BIP44](https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki) (Key generation prefixes)**
6060
- [x] **[EIP-20](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md)** (Standart interface for tokens - ERC-20), **[EIP-67](https://github.com/ethereum/EIPs/issues/67)** (Standard URI scheme), **[EIP-155](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-155.md)** (Replay attacks protection)
61-
- [x] **And many others** *(For details about this EIP's look at [Documentation page](https://github.com/matter-labs/web3swift/blob/master/Documentation/))*: EIP-681, EIP-721, EIP-165, EIP-777, EIP-820, EIP-888, EIP-1400, EIP-1410, EIP-1594, EIP-1643, EIP-1644, EIP-1633, EIP-721, EIP-1155, EIP-1376, ST-20
61+
- [x] **And many others** *(For details about this EIP's look at [Documentation page](https://github.com/skywinder/web3swift/blob/master/Documentation/))*: EIP-681, EIP-721, EIP-165, EIP-777, EIP-820, EIP-888, EIP-1400, EIP-1410, EIP-1594, EIP-1643, EIP-1644, EIP-1633, EIP-721, EIP-1155, EIP-1376, ST-20
6262

6363
- [x] 🗜 **Batched requests** in concurrent mode
6464
- [x] **RLP encoding**
@@ -118,7 +118,7 @@ $ open -a Xcode Cartfile
118118
Add the following line to the Cartfile and save it:
119119

120120
```ogdl
121-
github "matter-labs/web3swift" "master"
121+
github "skywinder/web3swift" "master"
122122
```
123123

124124
Run `carthage update --no-use-binaries --platform iOS` to build the framework. By default, Carthage performs checkouts and creates a new directory 'Carthage' in the same location as your Cartfile. Open this directory, go to 'Build' directory, choose iOS or macOS directory, and use the selected directory framework in your Xcode project.
@@ -138,8 +138,7 @@ import web3swift
138138

139139
##### Send Ether
140140

141-
```
142-
141+
```swift
143142
let value: String = "1.0" // In Ether
144143
let walletAddress = EthereumAddress(wallet.address)! // Your wallet address
145144
let toAddress = EthereumAddress(toAddressString)!
@@ -151,10 +150,10 @@ options.from = walletAddress
151150
options.gasPrice = .automatic
152151
options.gasLimit = .automatic
153152
let tx = contract.write(
154-
"fallback",
155-
parameters: [AnyObject](),
156-
extraData: Data(),
157-
transactionOptions: options)!
153+
"fallback",
154+
parameters: [AnyObject](),
155+
extraData: Data(),
156+
transactionOptions: options)!
158157
```
159158

160159
##### Send ERC-20 Token
@@ -174,10 +173,10 @@ options.gasPrice = .automatic
174173
options.gasLimit = .automatic
175174
let method = "transfer"
176175
let tx = contract.write(
177-
method,
178-
parameters: [toAddress, amount] as [AnyObject],
179-
extraData: Data(),
180-
transactionOptions: options)!
176+
method,
177+
parameters: [toAddress, amount] as [AnyObject],
178+
extraData: Data(),
179+
transactionOptions: options)!
181180
```
182181

183182

@@ -209,33 +208,96 @@ options.from = walletAddress
209208
options.gasPrice = .automatic
210209
options.gasLimit = .automatic
211210
let tx = contract.write(
212-
contractMethod,
213-
parameters: parameters,
214-
extraData: extraData,
215-
transactionOptions: options)!
211+
contractMethod,
212+
parameters: parameters,
213+
extraData: extraData,
214+
transactionOptions: options)!
215+
```
216+
217+
218+
#### Write Transaction with your custom contract ABI
219+
#### Requirement : Your custom contract ABI string
220+
```Code
221+
func contractTransactionMethod(){
222+
let yourCoin = self.yourbalance.text ?? "0.0" //Get token for sending
223+
let userDir = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0] //get user directory for keystore
224+
if (FileManager.default.fileExists(atPath: userDir + "/keystore/key.json")) {
225+
//Create Keystore
226+
guard let manager = FilestoreWrapper.getKeystoreManager() else {
227+
print("Manager not found ")
228+
return
229+
}
230+
wethioKeystoreManager = manager
231+
guard let urlStr = URL(string: "Your rpc url here") else { return }
232+
guard let kManager = yourKeystoreManager else { return }
233+
234+
//Create Web3Provider Instance with key manager
235+
web3ProvideInstance = Web3HttpProvider(urlStr, keystoreManager: kManager)
236+
guard let wProvier = self.web3ProvideInstance else {return}
237+
self.web3Instance = Web3(provider: wProvier) //Set provide instance with web3
238+
guard let wInstance = self.web3Instance else {return}
239+
self.receiverAddressString = self.walletAddressTF.text //get receiver address string
240+
print("Receiver address is : ", self.receiverAddressString ?? " ")
241+
self.etheriumAccountAddress = self.wethioKeystoreManager?.addresses.first?.address //get sender address in string
242+
/*
243+
convert address string into etherium addresss
244+
*/
245+
let senderEthAddress = EthereumAddress(self.etheriumAccountAddress ?? "")
246+
//Run on backgrounnd tread
247+
DispatchQueue.global(qos: .background).async {
248+
do {
249+
//Convert receiver address in to etherium address
250+
let toaddress = EthereumAddress(self.receiverAddressString ?? "")
251+
var options = Web3Options.defaultOptions() //Create web3 options
252+
let amountDouble = BigInt((Double(yourCoin) ?? 0.1)*pow(10, 18)) //Convert amount into BIGINT
253+
print("Total amount in double value : ", amountDouble)
254+
var amount = BigUInt.init(amountDouble) //Convert amount in BIG UI Int
255+
let estimateGasPrice = try wInstance.eth.getGasPrice() //estimate gas price
256+
257+
guard let eGasReult = self.estimatedGasResult else {
258+
print("Unable to find gas price")
259+
return
260+
}
261+
let nonce = try wInstance.eth.getTransactionCount(address: senderEthAddress) //Get nonce or transaction count
262+
print("Is the Transaction count", nonce)
263+
let fee = estimateGasPrice * eGasReult
264+
/*
265+
adding
266+
- sender address
267+
- Gas Result
268+
- Gas price
269+
- amount
270+
*/
271+
var sendTransactionIntermediateOptions = Web3Options.defaultOptions()
272+
sendTransactionIntermediateOptions.from = senderEthAddress
273+
sendTransactionIntermediateOptions.gasLimit = eGasReult
274+
sendTransactionIntermediateOptions.gasPrice = estimateGasPrice
275+
var tokenTransactionIntermediate: TransactionIntermediate! //Create transaction intermediate
276+
tokenTransactionIntermediate = try wInstance.contract("Your custom contract ABI string", at: contractAddress).method("transfer", args: toaddress, amount, options: sendTransactionIntermediateOptions)
277+
let mainTransaction = try tokenTransactionIntermediate.send(options: sendTransactionIntermediateOptions, onBlock: "latest")
278+
print(mainTransaction.hash, "is the hash of your transaction")
279+
}
280+
}
281+
}
282+
}
283+
216284
```
217285

218286
### Web3View example
219287

220288
You can see how to our demo project: **WKWebView with injected "web3" provider**:
221289

222290
``` bash
223-
git clone https://github.com/matter-labs/web3swift.git
291+
git clone https://github.com/skywinder/web3swift.git
224292
cd web3swift/Example/web3swiftBrowser
225293
pod install
226294
open ./web3swiftBrowser.xcworkspace
227295
```
228296

229297
### Build from source
230298

231-
1. Clone repo `git clone https://github.com/skywinder/web3swift`
232-
233-
2. Install dependencies
234-
- `carthage update --no-use-binaries --platform iOS`
235-
- *Workaround that works with both Xcode 11 and 12*:
236-
- via `./carthage-build.sh update --no-use-binaries --platform iOS` ( workaround, for of Carthage bug. [For details please look at this comment](https://github.com/Carthage/Carthage/issues/3019#issuecomment-665136323)
237-
3. `open web3swift.xcworkspace`
238-
4. choose target `web3swift` and build it
299+
- Clone repo
300+
- Install dependencies via `./carthage-build.sh --platform iOS` (temp workaround, foe of Carthage bug. [For details please look at](https://github.com/Carthage/Carthage/issues/3019#issuecomment-665136323)
239301

240302
### Requirements
241303

@@ -249,23 +311,23 @@ open ./web3swiftBrowser.xcworkspace
249311

250312
## Documentation
251313

252-
For full documentation details and FAQ, please look at [Documentation](https://github.com/matter-labs/web3swift/blob/master/Documentation/)
314+
For full documentation details and FAQ, please look at [Documentation](https://github.com/skywinder/web3swift/blob/master/Documentation/)
253315

254-
*If you need to find or understand an API, check [Usage.md](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md).*
316+
*If you need to find or understand an API, check [Usage.md](https://github.com/skywinder/web3swift/blob/master/Documentation/Usage.md).*
255317

256-
**FAQ moved [Documentation Page](https://github.com/matter-labs/web3swift/blob/master/Documentation/)**
318+
**FAQ moved [Documentation Page](https://github.com/skywinder/web3swift/blob/master/Documentation/)**
257319

258320
Here are quick references for essential features:
259321

260-
- [Preffered models](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#preffered-models)
261-
- [Account Management (create, import, private keys managments, etc.)](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#account-management)
262-
- [Ethereum Endpoints interaction (web3, balance, tx's operations, chain state)](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#ethereum-endpoints-interaction)
263-
- [Websockets](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#websockets)
264-
- [ENS](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#ens)
322+
- [Preffered models](https://github.com/skywinder/web3swift/blob/master/Documentation/Usage.md#preffered-models)
323+
- [Account Management (create, import, private keys managments, etc.)](https://github.com/skywinder/web3swift/blob/master/Documentation/Usage.md#account-management)
324+
- [Ethereum Endpoints interaction (web3, balance, tx's operations, chain state)](https://github.com/skywinder/web3swift/blob/master/Documentation/Usage.md#ethereum-endpoints-interaction)
325+
- [Websockets](https://github.com/skywinder/web3swift/blob/master/Documentation/Usage.md#websockets)
326+
- [ENS](https://github.com/skywinder/web3swift/blob/master/Documentation/Usage.md#ens)
265327

266328
## Projects that are using web3swift
267329

268-
If you are using this library in your project, please [add a link](https://github.com/matter-labs/web3swift/edit/develop/README.md) to this repo.
330+
If you are using this library in your project, please [add a link](https://github.com/skywinder/web3swift/edit/develop/README.md) to this repo.
269331

270332
* [MyEtherWallet/MEWconnect-iOS](https://github.com/MyEtherWallet/MEWconnect-iOS)
271333
* [Peepeth iOS client](https://github.com/matterinc/PeepethClient)
@@ -282,17 +344,20 @@ If you are using this library in your project, please [add a link](https://githu
282344
* [Biomedical Data Sharing dApp - Geolocation](https://github.com/HD2i/Geolocation-iOS)
283345
* [Alice Wallet](https://github.com/alicedapp/AliceX)
284346
* [web3-react-native](https://github.com/cawfree/web3-react-native)
285-
* [YOUR APP CAN BE THERE (click me)](https://github.com/matter-labs/web3swift/edit/develop/README.md) :wink:
347+
* [ProLabArt](https://prolabart.com)
348+
<!-- Add your project below -->
349+
<!-- * [Project Name](link to projext) -->
350+
* [YOUR APP CAN BE THERE (click me)](https://github.com/skywinder/web3swift/edit/develop/README.md) :wink:
286351

287352
*Nothing makes developers happier than seeing someone else use our work and go wild with it.*
288353

289354
## Support
290355

291356
**[Join our discord](https://discord.gg/DZKFJFn3) if you need a support or want to contribute to web3swift development!**
292357

293-
- If you **need help**, [open an issue](https://github.com/matter-labs/web3swift/issues).
294-
- If you'd like to **see web3swift best practices**, check [Projects that using web3swift](https://github.com/matter-labs/web3swift#projects-that-using-web3swift).
295-
- If you **found a bug**, [open an issue](https://github.com/matter-labs/web3swift/issues).
358+
- If you **need help**, [open an issue](https://github.com/skywinder/web3swift/issues).
359+
- If you'd like to **see web3swift best practices**, check [Projects that using web3swift](https://github.com/skywinder/web3swift#projects-that-using-web3swift).
360+
- If you **found a bug**, [open an issue](https://github.com/skywinder/web3swift/issues).
296361

297362

298363
## Contribute
@@ -301,47 +366,47 @@ Want to improve? It's awesome:
301366

302367
Then good news for you: **We are ready to pay for your contribution via [@gitcoin bot](https://gitcoin.co/grants/358/web3swift)!**
303368

304-
- If you **have a feature request**, [open an issue](https://github.com/matter-labs/web3swift/issues).
369+
- If you **have a feature request**, [open an issue](https://github.com/skywinder/web3swift/issues).
305370

306-
- If you **want to contribute**, read [contribution policy](https://github.com/matter-labs/web3swift/blob/master/Documentation/CONTRIBUTION_POLICY.md) & [submit a pull request](https://github.com/matter-labs/web3swift/pulls).
371+
- If you **want to contribute**, read [contribution policy](https://github.com/skywinder/web3swift/blob/master/Documentation/CONTRIBUTION_POLICY.md) & [submit a pull request](https://github.com/skywinder/web3swift/pulls).
307372

308373
If you use any of our libraries for work, see if your employers would be interested in donating. Any amount you can donate today to help us reach our goal would be much appreciated.
309374

310-
[Matter Labs](https://github.com/orgs/matter-labs/people) are charged with open-sourсe and do not require money for using their web3swift lib.
375+
[Matter Labs](https://github.com/orgs/skywinder/people) are charged with open-sourсe and do not require money for using their web3swift lib.
311376
We want to continue to do everything we can to move the needle forward.
312377

313378
- **Support us** via [@gitcoin Grant program](https://gitcoin.co/grants/358/web3swift)
314379
- Ether wallet address: `0x6A3738c6299f45c31697aceA647D49EdCC9C28A4`
315380

316-
<img src="https://raw.githubusercontent.com/matter-labs/web3swift/develop/img/Ether-donations.jpeg" width="300" />
381+
<img src="https://raw.githubusercontent.com/skywinder/web3swift/develop/img/Ether-donations.jpeg" width="300" />
317382

318383
### Future steps
319384

320385
You are more than welcome to participate! **Your contribution will be paid via [@gitcoin Grant program](https://gitcoin.co/grants/358/web3swift).**
321386

387+
- [x] Performance Improvements thanks to @**[xdozorx](https://github.com/xdozorx)** for [Update perfomance of import account](https://github.com/skywinder/web3swift/pull/336)
388+
322389
- [ ] **L2 support** (such as [ZkSync](https://zksync.io/))
323390

324391
- [ ] **Modularity** with the basic Web3 subspec/SPM (the most basic functions like transaction signing and interacting with an http rpc server) and other modules with additional functionality
325-
326-
- [ ] Complete Documentation (https://web3swift.github.io/web3swift)
327-
328-
- [ ] Performance Improvements
392+
- [ ] [Complete Documentation](https://web3swift.github.io/web3swift)
329393

330394
- [ ] Convenient methods for namespaces
331395

332-
396+
333397

334398
## Credits
335399

336-
- Alex Vlasov, [@shamatar](https://github.com/shamatar)
337-
- Petr Korolev, [@skywinder](https://github.com/skywinder)
338-
- Anton Grigorev, [@baldyash](https://github.com/BaldyAsh)
400+
- Alex Vlasov, [@shamatar](https://github.com/shamatar) - for the initial implementation
401+
- Petr Korolev, [@skywinder](https://github.com/skywinder) - botstrap and continous support
402+
- Anton Grigorev, [@baldyash](https://github.com/BaldyAsh) - core contributor, who use it and making a lot of ipmprovments
403+
- Yhanks to [web3swift's growing list of contributors](https://github.com/skywinder/web3swift/graphs/contributors).
339404

340405
## Security Disclosure
341406

342-
If you believe you have identified a security vulnerability with web3swift, you should report it as soon as possible via email to [hello@matter-labs.io](mailto:hello@matter-labs.io). Please do not post it to a public issue tracker.
407+
If you believe you have identified a security vulnerability with web3swift, you should report it as soon as possible via email to [web3swift@oxor.io](mailto:web3swift@oxor.io). Please do not post it to a public issue tracker.
343408

344409

345410
## License
346411

347-
web3swift is available under the Apache License 2.0 license. See the [LICENSE](https://github.com/matter-labs/web3swift/blob/master/LICENSE) for details.
412+
web3swift is available under the Apache License 2.0 license. See the [LICENSE](https://github.com/skywinder/web3swift/blob/master/LICENSE) for details.

web3swift.xcodeproj/project.pbxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1195,7 +1195,7 @@
11951195
);
11961196
runOnlyForDeploymentPostprocessing = 0;
11971197
shellPath = /bin/sh;
1198-
shellScript = "/usr/local/bin/carthage copy-frameworks\n";
1198+
shellScript = "/opt/homebrew/bin/carthage copy-frameworks\n";
11991199
};
12001200
139751F0219AFA500044D2B0 /* Carthage */ = {
12011201
isa = PBXShellScriptBuildPhase;

0 commit comments

Comments
 (0)