@@ -74,7 +74,7 @@ public class ERC1155: IERC1155 {
74
74
var transactionOptions = CodableTransaction . emptyTransaction
75
75
transactionOptions. callOnBlock = . latest
76
76
77
- guard let tokenIdPromise = try await contract. read ( " id " , parameters: [ ] as [ AnyObject ] , extraData: Data ( ) , transactionOptions: transactionOptions) ? . decodedData ( ) else { return }
77
+ guard let tokenIdPromise = try await contract. createReadOperation ( " id " , parameters: [ ] as [ AnyObject ] , extraData: Data ( ) , transactionOptions: transactionOptions) ? . decodedData ( ) else { return }
78
78
79
79
guard let tokenId = tokenIdPromise [ " 0 " ] as? BigUInt else { return }
80
80
self . _tokenId = tokenId
@@ -88,7 +88,7 @@ public class ERC1155: IERC1155 {
88
88
basicOptions. from = from
89
89
basicOptions. to = self . address
90
90
91
- let tx = contract. write ( " safeTransferFrom " , parameters: [ originalOwner, to, id, value, data] as [ AnyObject ] , transactionOptions: basicOptions) !
91
+ let tx = contract. createWriteOperation ( " safeTransferFrom " , parameters: [ originalOwner, to, id, value, data] as [ AnyObject ] , transactionOptions: basicOptions) !
92
92
return tx
93
93
}
94
94
@@ -98,15 +98,26 @@ public class ERC1155: IERC1155 {
98
98
basicOptions. from = from
99
99
basicOptions. to = self . address
100
100
101
- let tx = contract. write ( " safeBatchTransferFrom " , parameters: [ originalOwner, to, ids, values, data] as [ AnyObject ] , transactionOptions: basicOptions) !
101
+ let tx = contract
102
+ . createWriteOperation ( " safeBatchTransferFrom " , parameters: [ originalOwner, to, ids, values, data] as [ AnyObject ] , transactionOptions: basicOptions) !
102
103
return tx
103
104
}
104
105
105
106
public func balanceOf( account: EthereumAddress , id: BigUInt ) async throws -> BigUInt {
106
107
let contract = self . contract
107
108
var transactionOptions = CodableTransaction . emptyTransaction
108
109
transactionOptions. callOnBlock = . latest
109
- let result = try await contract. read ( " balanceOf " , parameters: [ account, id] as [ AnyObject ] , extraData: Data ( ) , transactionOptions: self . transactionOptions) !. decodedData ( )
110
+ let result = try await contract
111
+ . createReadOperation ( " balanceOf " , parameters: [ account, id] as [ AnyObject ] , extraData: Data ( ) , transactionOptions: self . transactionOptions) !
112
+ . decodedData ( )
113
+
114
+ /*
115
+ let result = try await contract
116
+ .prepareToRead("balanceOf", parameters: [account, id] as [AnyObject], extraData: Data(), transactionOptions: self.transactionOptions)!
117
+ .execute()
118
+ .decodeData()
119
+
120
+ */
110
121
guard let res = result [ " 0 " ] as? BigUInt else { throw Web3Error . processingError ( desc: " Failed to get result of expected type from the Ethereum node " ) }
111
122
return res
112
123
}
@@ -117,15 +128,15 @@ public class ERC1155: IERC1155 {
117
128
basicOptions. from = from
118
129
basicOptions. to = self . address
119
130
120
- let tx = contract. write ( " setApprovalForAll " , parameters: [ user, approved, scope] as [ AnyObject ] , transactionOptions: basicOptions) !
131
+ let tx = contract. createWriteOperation ( " setApprovalForAll " , parameters: [ user, approved, scope] as [ AnyObject ] , transactionOptions: basicOptions) !
121
132
return tx
122
133
}
123
134
124
135
public func isApprovedForAll( owner: EthereumAddress , operator user: EthereumAddress , scope: Data ) async throws -> Bool {
125
136
let contract = self . contract
126
137
var basicOptions = CodableTransaction . emptyTransaction
127
138
basicOptions. callOnBlock = . latest
128
- let result = try await contract. read ( " isApprovedForAll " , parameters: [ owner, user, scope] as [ AnyObject ] , extraData: Data ( ) , transactionOptions: self . transactionOptions) !. decodedData ( )
139
+ let result = try await contract. createReadOperation ( " isApprovedForAll " , parameters: [ owner, user, scope] as [ AnyObject ] , extraData: Data ( ) , transactionOptions: self . transactionOptions) !. decodedData ( )
129
140
guard let res = result [ " 0 " ] as? Bool else { throw Web3Error . processingError ( desc: " Failed to get result of expected type from the Ethereum node " ) }
130
141
return res
131
142
}
@@ -135,7 +146,7 @@ public class ERC1155: IERC1155 {
135
146
var transactionOptions = CodableTransaction . emptyTransaction
136
147
transactionOptions. callOnBlock = . latest
137
148
transactionOptions. gasLimitPolicy = . manual( 30000 )
138
- let result = try await contract. read ( " supportsInterface " , parameters: [ interfaceID] as [ AnyObject ] , extraData: Data ( ) , transactionOptions: self . transactionOptions) !. decodedData ( )
149
+ let result = try await contract. createReadOperation ( " supportsInterface " , parameters: [ interfaceID] as [ AnyObject ] , extraData: Data ( ) , transactionOptions: self . transactionOptions) !. decodedData ( )
139
150
guard let res = result [ " 0 " ] as? Bool else { throw Web3Error . processingError ( desc: " Failed to get result of expected type from the Ethereum node " ) }
140
151
return res
141
152
}
0 commit comments