Skip to content

Commit

Permalink
simplify Swift template
Browse files Browse the repository at this point in the history
  • Loading branch information
pileks committed Oct 26, 2023
1 parent a980f95 commit c4666c6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 23 deletions.
29 changes: 9 additions & 20 deletions packages/templates/app/ios/Template/PolywrapDemo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,15 @@ import UIKit
import PolywrapClient

func polywrapDemo() {
print("Invoking: Logging.info(...)")
print("Invoking: Sha3.sha3_256(...)")

let logger = Logging()
let logArgs = LoggingArgsLog(level: .INFO, message: "Hello there")
try? logger.log(args: logArgs)

// Ethers.encodeParams
print("Invoking: Ethers.encodeParams(...)")

let eth = Ethers()
let encodeArgs = EthersArgsEncodeParams(
types: ["address", "uint256"],
values: ["0xB1B7586656116D546033e3bAFF69BFcD6592225E", "500"]
)
do {
let encoded = try eth.encodeParams(args: encodeArgs)
print("Ethers.encodeParams:\n\(encoded)")
let sha3 = Sha3()
let sha3_256Args = Sha3ArgsSha3256(message: "Hello Polywrap!")

do{
let result = try sha3.sha3_256(args: sha3_256Args)
print("Sha3.sha3_256: \(result)")
} catch {
let logArgs = LoggingArgsLog(level: .ERROR, message: "Error - Ethers.encodeParams: \(error)")
try? logger.log(args: logArgs)
return
print("Error - Sha3.sha3_256: \(error)")
}
}
}
3 changes: 1 addition & 2 deletions packages/templates/app/ios/polywrap.graphql
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
#import * into Logging from "wrapscan.io/polywrap/logger@1.0"
#import * into Ethers from "wrapscan.io/polywrap/ethers@1.1"
#import * into Sha3 from "wrapscan.io/polywrap/sha3@1"
2 changes: 1 addition & 1 deletion packages/templates/app/ios/polywrap.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
format: 0.4.0
format: 0.5.0
project:
name: Sample
type: app/swift
Expand Down

0 comments on commit c4666c6

Please sign in to comment.