@@ -15,6 +15,7 @@ import {
15
15
NativeTransferBuilder ,
16
16
NativeUndelegateBuilder ,
17
17
PublicKey ,
18
+ SessionBuilder ,
18
19
Transaction ,
19
20
TransactionHash
20
21
} from '../types' ;
@@ -197,6 +198,80 @@ export class CasperNetwork {
197
198
return transferBuilder . buildFor1_5 ( ) ;
198
199
}
199
200
201
+ public createContractCallTransaction (
202
+ senderPublicKey : PublicKey ,
203
+ contractHash : string ,
204
+ entryPoint : string ,
205
+ networkName : string ,
206
+ deployCost : number ,
207
+ ttl : number ,
208
+ args : Args
209
+ ) : Transaction {
210
+ const contractCall = new ContractCallBuilder ( )
211
+ . byHash ( contractHash )
212
+ . from ( senderPublicKey )
213
+ . entryPoint ( entryPoint )
214
+ . chainName ( networkName )
215
+ . runtimeArgs ( args )
216
+ . ttl ( ttl )
217
+ . payment ( deployCost ) ;
218
+
219
+ if ( this . apiVersion === 2 ) {
220
+ return contractCall . build ( ) ;
221
+ }
222
+
223
+ return contractCall . buildFor1_5 ( ) ;
224
+ }
225
+
226
+ public createContractPackageTransaction (
227
+ senderPublicKey : PublicKey ,
228
+ contractPackageHash : string ,
229
+ entryPoint : string ,
230
+ networkName : string ,
231
+ deployCost : number ,
232
+ args : Args ,
233
+ ttl : number ,
234
+ contractVersion ?: number
235
+ ) : Transaction {
236
+ const contractCall = new ContractCallBuilder ( )
237
+ . byPackageHash ( contractPackageHash , contractVersion )
238
+ . from ( senderPublicKey )
239
+ . entryPoint ( entryPoint )
240
+ . chainName ( networkName )
241
+ . runtimeArgs ( args )
242
+ . ttl ( ttl )
243
+ . payment ( deployCost ) ;
244
+
245
+ if ( this . apiVersion === 2 ) {
246
+ return contractCall . build ( ) ;
247
+ }
248
+
249
+ return contractCall . buildFor1_5 ( ) ;
250
+ }
251
+
252
+ public createSessionWasmTransaction (
253
+ senderPublicKey : PublicKey ,
254
+ networkName : string ,
255
+ deployCost : number ,
256
+ ttl : number ,
257
+ bytes : Uint8Array ,
258
+ args : Args
259
+ ) : Transaction {
260
+ const sessionWasm = new SessionBuilder ( )
261
+ . from ( senderPublicKey )
262
+ . chainName ( networkName )
263
+ . payment ( deployCost )
264
+ . ttl ( ttl )
265
+ . wasm ( bytes )
266
+ . runtimeArgs ( args ) ;
267
+
268
+ if ( this . apiVersion === 2 ) {
269
+ return sessionWasm . build ( ) ;
270
+ }
271
+
272
+ return sessionWasm . buildFor1_5 ( ) ;
273
+ }
274
+
200
275
public async putTransaction (
201
276
transaction : Transaction
202
277
) : Promise < PutTransactionResult | PutDeployResult > {
@@ -216,7 +291,7 @@ export class CasperNetwork {
216
291
217
292
public async getTransaction (
218
293
hash : TransactionHash
219
- ) : Promise < InfoGetTransactionResult | InfoGetDeployResult > {
294
+ ) : Promise < InfoGetTransactionResult > {
220
295
if ( this . apiVersion == 2 ) {
221
296
if ( hash . transactionV1 ) {
222
297
return await this . rpcClient . getTransactionByTransactionHash (
@@ -232,7 +307,10 @@ export class CasperNetwork {
232
307
}
233
308
234
309
if ( hash . deploy ) {
235
- return await this . rpcClient . getDeploy ( hash . deploy . toHex ( ) ) ;
310
+ const getDeployResult = await this . rpcClient . getDeploy (
311
+ hash . deploy . toHex ( )
312
+ ) ;
313
+ return getDeployResult . toInfoGetTransactionResult ( ) ;
236
314
}
237
315
238
316
return Promise . reject ( 'Hash is not valid' ) ;
0 commit comments