@@ -289,6 +289,48 @@ func UpsertContractCodeChunksTransaction(
289
289
AddAuthorizer (service )
290
290
}
291
291
292
+ // CreateWFLOWTokenHandlerTransaction returns the transaction body for the transaction
293
+ // that creates a token handler for the WFLOW Solidity contract
294
+ func CreateWFLOWTokenHandlerTransaction (
295
+ service flow.Address ,
296
+ bridgeEnv bridge.Environment ,
297
+ env templates.Environment ,
298
+ wflowEVMAddress string ,
299
+ ) * flow.TransactionBody {
300
+ txScript , _ := bridge .GetCadenceTransactionCode ("cadence/transactions/bridge/admin/token-handler/create_wflow_token_handler.cdc" , bridgeEnv , env )
301
+
302
+ return flow .NewTransactionBody ().
303
+ SetScript ([]byte (
304
+ txScript ,
305
+ ),
306
+ ).
307
+ AddArgument (jsoncdc .MustEncode (cadence .String (wflowEVMAddress ))).
308
+ SetProposalKey (service , 0 , 0 ).
309
+ SetPayer (service ).
310
+ AddAuthorizer (service )
311
+ }
312
+
313
+ // EnableWFLOWTokenHandlerTransaction returns the transaction body for the transaction
314
+ // that enables the token handler for the WFLOW Solidity contract
315
+ func EnableWFLOWTokenHandlerTransaction (
316
+ service flow.Address ,
317
+ bridgeEnv bridge.Environment ,
318
+ env templates.Environment ,
319
+ flowTokenType string ,
320
+ ) * flow.TransactionBody {
321
+ txScript , _ := bridge .GetCadenceTransactionCode ("cadence/transactions/bridge/admin/token-handler/enable_token_handler.cdc" , bridgeEnv , env )
322
+
323
+ return flow .NewTransactionBody ().
324
+ SetScript ([]byte (
325
+ txScript ,
326
+ ),
327
+ ).
328
+ AddArgument (jsoncdc .MustEncode (cadence .String (flowTokenType ))).
329
+ SetProposalKey (service , 0 , 0 ).
330
+ SetPayer (service ).
331
+ AddAuthorizer (service )
332
+ }
333
+
292
334
// OnboardToBridgeByTypeIDTransaction returns the transaction body for the transaction
293
335
// that onboards a FT or NFT type to the bridge
294
336
func OnboardToBridgeByTypeIDTransaction (
@@ -309,3 +351,117 @@ func OnboardToBridgeByTypeIDTransaction(
309
351
SetPayer (service ).
310
352
AddAuthorizer (service )
311
353
}
354
+
355
+ // BridgeFTToEVMTransaction returns the transaction body for the transaction
356
+ // that bridges a fungible token from Cadence to EVM
357
+ func BridgeFTToEVMTransaction (
358
+ service flow.Address ,
359
+ bridgeEnv bridge.Environment ,
360
+ env templates.Environment ,
361
+ forType string ,
362
+ amount string ,
363
+ ) * flow.TransactionBody {
364
+ txScript , _ := bridge .GetCadenceTransactionCode ("cadence/transactions/bridge/tokens/bridge_tokens_to_evm.cdc" , bridgeEnv , env )
365
+ bridgeAmount , _ := cadence .NewUFix64 (amount )
366
+ return flow .NewTransactionBody ().
367
+ SetScript ([]byte (
368
+ txScript ,
369
+ ),
370
+ ).
371
+ AddArgument (jsoncdc .MustEncode (cadence .String (forType ))).
372
+ AddArgument (jsoncdc .MustEncode (bridgeAmount )).
373
+ SetProposalKey (service , 0 , 0 ).
374
+ SetPayer (service ).
375
+ AddAuthorizer (service )
376
+ }
377
+
378
+ // BridgeFTFromEVMTransaction returns the transaction body for the transaction
379
+ // that bridges a fungible token from EVM to Cadence
380
+ func BridgeFTFromEVMTransaction (
381
+ service flow.Address ,
382
+ bridgeEnv bridge.Environment ,
383
+ env templates.Environment ,
384
+ forType string ,
385
+ amount uint ,
386
+ ) * flow.TransactionBody {
387
+ txScript , _ := bridge .GetCadenceTransactionCode ("cadence/transactions/bridge/tokens/bridge_tokens_from_evm.cdc" , bridgeEnv , env )
388
+
389
+ return flow .NewTransactionBody ().
390
+ SetScript ([]byte (
391
+ txScript ,
392
+ ),
393
+ ).
394
+ AddArgument (jsoncdc .MustEncode (cadence .String (forType ))).
395
+ AddArgument (jsoncdc .MustEncode (cadence .NewUInt256 (amount ))).
396
+ SetProposalKey (service , 0 , 0 ).
397
+ SetPayer (service ).
398
+ AddAuthorizer (service )
399
+ }
400
+
401
+ // GetEscrowedTokenBalanceScript returns the script body for the script
402
+ // that gets the balance of an escrowed fungible token in the Cadence side of the VM bridge
403
+ func GetEscrowedTokenBalanceScript (
404
+ bridgeEnv bridge.Environment ,
405
+ env templates.Environment ,
406
+ ) []byte {
407
+ script , _ := bridge .GetCadenceTransactionCode ("cadence/scripts/escrow/get_locked_token_balance.cdc" , bridgeEnv , env )
408
+
409
+ return script
410
+ }
411
+
412
+ // BridgeNFTToEVMTransaction returns the transaction body for the transaction
413
+ // that bridges a non-fungible token from Cadence to EVM
414
+ func BridgeNFTToEVMTransaction (
415
+ service flow.Address ,
416
+ bridgeEnv bridge.Environment ,
417
+ env templates.Environment ,
418
+ forType string ,
419
+ id cadence.UInt64 ,
420
+ ) * flow.TransactionBody {
421
+ txScript , _ := bridge .GetCadenceTransactionCode ("cadence/transactions/bridge/nft/bridge_nft_to_evm.cdc" , bridgeEnv , env )
422
+
423
+ return flow .NewTransactionBody ().
424
+ SetScript ([]byte (
425
+ txScript ,
426
+ ),
427
+ ).
428
+ AddArgument (jsoncdc .MustEncode (cadence .String (forType ))).
429
+ AddArgument (jsoncdc .MustEncode (id )).
430
+ SetProposalKey (service , 0 , 0 ).
431
+ SetPayer (service ).
432
+ AddAuthorizer (service )
433
+ }
434
+
435
+ // BridgeNFTFromEVMTransaction returns the transaction body for the transaction
436
+ // that bridges a non-fungible token from EVM to Cadence
437
+ func BridgeNFTFromEVMTransaction (
438
+ service flow.Address ,
439
+ bridgeEnv bridge.Environment ,
440
+ env templates.Environment ,
441
+ forType string ,
442
+ id cadence.UInt256 ,
443
+ ) * flow.TransactionBody {
444
+ txScript , _ := bridge .GetCadenceTransactionCode ("cadence/transactions/bridge/nft/bridge_nft_from_evm.cdc" , bridgeEnv , env )
445
+
446
+ return flow .NewTransactionBody ().
447
+ SetScript ([]byte (
448
+ txScript ,
449
+ ),
450
+ ).
451
+ AddArgument (jsoncdc .MustEncode (cadence .String (forType ))).
452
+ AddArgument (jsoncdc .MustEncode (id )).
453
+ SetProposalKey (service , 0 , 0 ).
454
+ SetPayer (service ).
455
+ AddAuthorizer (service )
456
+ }
457
+
458
+ // GetIsNFTInEscrowScript returns the script body for the script
459
+ // that gets if an NFT is escrowed in the Cadence side of the VM bridge
460
+ func GetIsNFTInEscrowScript (
461
+ bridgeEnv bridge.Environment ,
462
+ env templates.Environment ,
463
+ ) []byte {
464
+ script , _ := bridge .GetCadenceTransactionCode ("cadence/scripts/escrow/is_nft_locked.cdc" , bridgeEnv , env )
465
+
466
+ return script
467
+ }
0 commit comments