Skip to content

Commit

Permalink
update generic transfer transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuahannan committed Feb 13, 2024
1 parent 2ab8303 commit 959b707
Show file tree
Hide file tree
Showing 8 changed files with 244 additions and 122 deletions.
34 changes: 17 additions & 17 deletions coverage.json
Original file line number Diff line number Diff line change
Expand Up @@ -588,28 +588,28 @@
}
},
"excluded_locations": [
"A.0000000000000001.NonFungibleToken",
"A.0000000000000002.FungibleToken",
"A.0000000000000001.ExampleNFT",
"I.Test",
"I.BlockchainHelpers",
"A.0000000000000001.StakingProxy",
"A.0000000000000001.FlowDKG",
"A.0000000000000002.FungibleTokenMetadataViews",
"A.0000000000000001.FlowStakingCollection",
"s.7465737400000000000000000000000000000000000000000000000000000000",
"A.0000000000000001.FlowServiceAccount",
"A.0000000000000004.FlowFees",
"A.0000000000000001.FlowEpoch",
"s.7465737400000000000000000000000000000000000000000000000000000000",
"A.0000000000000003.FlowToken",
"A.0000000000000001.MetadataViews",
"A.0000000000000001.ViewResolver",
"A.0000000000000001.FlowIDTableStaking",
"A.0000000000000001.NonFungibleToken",
"I.Test",
"A.0000000000000001.RandomBeaconHistory",
"I.Crypto",
"A.0000000000000001.FlowClusterQC",
"A.0000000000000001.FlowServiceAccount",
"A.0000000000000001.NodeVersionBeacon",
"A.0000000000000002.FungibleTokenMetadataViews",
"A.0000000000000001.ExampleNFT",
"A.0000000000000004.FlowFees",
"A.0000000000000001.FlowDKG",
"A.0000000000000001.FlowStakingCollection",
"A.0000000000000001.FlowIDTableStaking",
"A.0000000000000001.StakingProxy",
"A.0000000000000001.FlowStorageFees",
"A.0000000000000001.LockedTokens"
"A.0000000000000001.FlowClusterQC",
"I.Crypto",
"A.0000000000000001.LockedTokens",
"A.0000000000000001.ViewResolver",
"A.0000000000000001.MetadataViews",
"I.BlockchainHelpers"
]
}
45 changes: 34 additions & 11 deletions lib/go/templates/internal/assets/assets.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 34 additions & 12 deletions lib/go/templates/transaction_templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ import (
)

const (
transferTokensFilename = "transfer_tokens.cdc"
genericTransferFilename = "generic_transfer.cdc"
transferManyAccountsFilename = "transfer_many_accounts.cdc"
setupAccountFilename = "setup_account.cdc"
setupGenericVaultFilename = "metadata/setup_account_from_address.cdc"
mintTokensFilename = "mint_tokens.cdc"
createForwarderFilename = "create_forwarder.cdc"
burnTokensFilename = "burn_tokens.cdc"
transferTokensFilename = "transfer_tokens.cdc"
genericTransferWithPathsFilename = "generic_transfer_with_paths.cdc"
genericTransferWithAddressFilename = "generic_transfer_with_address.cdc"
transferManyAccountsFilename = "transfer_many_accounts.cdc"
setupAccountFilename = "setup_account.cdc"
setupGenericVaultFilename = "metadata/setup_account_from_address.cdc"
mintTokensFilename = "mint_tokens.cdc"
createForwarderFilename = "create_forwarder.cdc"
burnTokensFilename = "burn_tokens.cdc"
)

// GenerateCreateTokenScript creates a script that instantiates
Expand Down Expand Up @@ -64,11 +65,11 @@ func GenerateTransferVaultScript(env Environment) []byte {
return []byte(ReplaceAddresses(code, env))
}

// GenerateTransferGenericVaultScript creates a script that withdraws an tokens from an account
// and deposits it to another account's vault for any vault type
func GenerateTransferGenericVaultScript(fungibleTokenAddr string) []byte {
// GenerateTransferGenericVaultWithPathsScript creates a script that withdraws an tokens from an account
// and deposits it to another account's vault for any vault type using paths as arguments
func GenerateTransferGenericVaultWithPathsScript(fungibleTokenAddr string) []byte {

code := assets.MustAssetString(genericTransferFilename)
code := assets.MustAssetString(genericTransferWithPathsFilename)

code = strings.ReplaceAll(
code,
Expand All @@ -79,6 +80,27 @@ func GenerateTransferGenericVaultScript(fungibleTokenAddr string) []byte {
return []byte(code)
}

// GenerateTransferGenericVaultWithAddressScript creates a script that withdraws an tokens from an account
// and deposits it to another account's vault for any vault type using the contract's address and name as arguments
func GenerateTransferGenericVaultWithAddressScript(fungibleTokenAddr, ftMetadataViewsAddr string) []byte {

code := assets.MustAssetString(genericTransferWithAddressFilename)

code = strings.ReplaceAll(
code,
placeholderFungibleToken,
withHexPrefix(fungibleTokenAddr),
)

code = strings.ReplaceAll(
code,
placeholderFTMetadataViews,
withHexPrefix(ftMetadataViewsAddr),
)

return []byte(code)
}

// GenerateTransferManyAccountsScript creates a script that transfers the same number of tokens
// to a list of accounts
func GenerateTransferManyAccountsScript(env Environment) []byte {
Expand Down
Loading

0 comments on commit 959b707

Please sign in to comment.