diff --git a/coverage.json b/coverage.json index 85db917..1f1c894 100644 --- a/coverage.json +++ b/coverage.json @@ -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" ] } \ No newline at end of file diff --git a/lib/go/templates/internal/assets/assets.go b/lib/go/templates/internal/assets/assets.go index 8a0b971..45d7ba8 100644 --- a/lib/go/templates/internal/assets/assets.go +++ b/lib/go/templates/internal/assets/assets.go @@ -2,7 +2,8 @@ // sources: // burn_tokens.cdc (1.718kB) // create_forwarder.cdc (3.03kB) -// generic_transfer.cdc (1.331kB) +// generic_transfer_with_address.cdc (2.1kB) +// generic_transfer_with_paths.cdc (1.697kB) // metadata/setup_account_from_address.cdc (1.906kB) // metadata/setup_account_from_vault_reference.cdc (1.909kB) // mint_tokens.cdc (1.827kB) @@ -147,23 +148,43 @@ func create_forwarderCdc() (*asset, error) { return a, nil } -var _generic_transferCdc = "\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x94\x54\x4d\x6f\xe2\x48\x10\x3d\x87\x5f\xf1\x96\x43\x02\x12\x71\x2e\xab\x3d\xa0\x7c\x6c\x36\x52\xf6\x1a\x65\x32\x99\x73\xd1\x5d\xe0\x9e\x98\x6e\xab\xbb\x8c\x83\x22\xfe\xfb\xa8\xcb\xc6\x40\xa2\x39\x0c\x17\x4c\x51\xf5\xde\xab\xd7\xcf\xed\xd6\x75\x88\x82\xc7\xc6\xaf\xdc\xa2\xe2\x97\xf0\xc6\x1e\xcb\x18\xd6\x18\x9f\xd4\xc6\xa3\xd1\xd5\xd5\x15\x1e\xc8\xa3\xa6\x94\xe0\x3c\xc8\x6f\x91\x24\x44\x5a\x31\x6a\x92\x12\xe4\x2d\x22\x1b\x76\x1b\x8e\x5d\xc5\xf9\x24\x4c\x16\x61\x89\x9f\x4d\x12\x48\xc9\xb0\xbc\xa4\xa6\x92\x42\xf1\x5e\x4a\x97\x50\xb1\x24\x6c\x43\x03\x53\x86\x90\x58\xbb\x44\x85\xe4\x62\x4b\x5e\x20\x01\x89\xbd\x05\x25\xb4\x5c\x55\xda\x62\xa8\xa6\x85\xab\x9c\x6c\xbf\xf6\xb9\xfc\xa8\x14\x4a\x73\xef\xb7\x3d\xa2\xca\x32\xe4\xb1\x60\x5d\x84\x15\x93\x3c\x28\xae\x9a\x35\x7b\x41\xc9\x91\x67\x48\x01\x2d\x55\xaa\x2c\x95\xa1\xa9\xac\xe2\x74\x8f\x30\x25\x9b\xb7\xc3\xc4\x86\xaa\x86\x53\xe6\x5e\xd3\x1b\x23\x35\xb1\xdb\xc1\x79\x61\x6f\xd9\x1e\x53\xbb\xb4\xa7\x75\x5e\xe5\x49\x24\x9f\xc8\x88\x0b\x7e\x42\xeb\xd0\x78\x99\xe3\xfb\xa3\x7b\xff\xe7\xef\x19\x24\xcc\x71\x6f\x6d\xe4\x94\x66\xba\x17\xc7\x27\x92\x72\x8e\x6f\x9d\xed\xf9\xc7\x6c\xb0\xbc\xfb\xeb\xa9\x59\x54\xce\xe4\xe7\x29\x3e\x46\x23\x00\x50\x9f\x19\xaf\xd9\x76\x44\x4e\xa1\x89\x26\x2b\x24\x41\x19\x2a\x9b\x0e\x86\xa7\xae\x4a\x91\xb1\x60\xe7\x57\x50\x75\x4b\x8e\x91\xad\x42\x55\x2c\x10\x5e\xd7\x8a\x35\xc7\xbf\x1f\x27\x21\x29\xb4\xbc\xeb\x58\xeb\xc8\x35\x45\x9e\x24\xb7\xf2\x1c\xe7\xa0\x46\xca\xc9\x7f\x21\xc6\xd0\xbe\x66\xc3\xa6\x38\xbf\x37\x26\x2f\x3c\x08\xed\xc5\xfe\xcf\x02\x42\xe4\x25\x47\xf6\x59\x69\x50\x85\x1d\xd0\x45\xd2\xd0\xb1\xc5\x26\x93\x0d\x73\x59\x99\x56\x9e\x79\x89\x9b\xbe\xb9\xe8\xf3\x59\x2c\x94\xf7\x5a\x35\x9c\x4a\xfe\xe1\xa4\xb4\x91\xda\x29\xce\x3f\x2d\xf3\x14\xc3\xc6\x59\x8e\xbb\xdb\x49\x7e\x21\xe6\x47\x27\x30\x1d\x9d\x9d\x9d\xdd\xdd\xa1\x26\xef\xcc\x64\xfc\xa0\xa9\xf0\x41\xd0\xf1\x7c\xd5\x1e\xda\x4e\xba\x1a\xf4\xd7\x78\x7a\xd8\x37\x71\xb5\x2c\x06\x4b\x71\x7d\x39\x6c\x51\xb4\xbd\xb4\x21\x17\xdd\xf7\x54\x67\x7b\x97\xf9\x9d\x4d\x23\x8c\x8f\x13\x23\x22\x1b\x57\xbb\x9c\xcd\x1b\xac\x58\x7a\x9f\x27\x12\xa6\x9f\xdb\x34\x39\x9d\x65\xc3\x50\x31\xbc\x59\x8e\xd3\xde\xba\xcf\xee\x3c\xf7\xb3\xbb\xdb\xc9\x71\x00\x0f\x04\xf9\xf3\x27\x16\x0d\xf4\x17\x09\x7b\xf0\x13\xa7\x72\x8c\xfb\x38\xee\xd3\xaa\x17\xd5\x6f\xb3\x71\x84\xdc\xdd\x49\x87\x1b\x63\x00\x3d\xb2\xa0\xb0\x5c\x87\xe4\xa4\x3f\xed\xeb\xcb\xd3\xa3\xd9\xdb\xbe\xfb\x15\x00\x00\xff\xff\xab\x62\xdc\x5e\x33\x05\x00\x00" +var _generic_transfer_with_addressCdc = "\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x8c\x55\x4d\x53\xe3\x46\x10\x3d\xe3\x5f\xf1\xf0\x81\x95\xaa\x58\x71\x49\xe5\xe0\x62\x21\x84\x14\x39\x25\xb5\xb5\xf1\x92\x73\x5b\x6a\x5b\x53\xc8\x33\xaa\x99\x96\xbd\x14\xc5\x7f\x4f\xcd\x87\x06\xcb\x0b\x04\x0e\xd8\x6e\x4d\xbf\x7e\xfd\xfa\xf5\x48\x6d\x7b\x63\x05\x77\x83\xde\xa8\x55\xc7\x4b\xf3\xc0\x1a\x6b\x6b\xb6\x98\x4f\x62\xf3\xd9\x6b\x27\xff\x62\xa1\x86\x84\xee\x15\xef\xdd\x6b\x69\x93\x03\xf3\xd9\xec\xe2\xe2\x02\xb7\xa4\xd1\x93\x73\x50\x1a\xa4\x1f\x51\x1b\x2d\x96\x6a\x01\x35\x8d\x65\xe7\x40\xba\x81\xa6\x2d\x43\x0c\xc4\x92\x76\x6b\xb6\x20\xc8\x0b\x37\x69\x49\x72\x5e\x00\x5d\xb6\xca\xa1\x63\x71\x78\x34\x03\xea\xd6\x18\xc7\x90\x96\x53\x96\x0f\xee\x49\x8b\x87\x74\xac\x1b\x9f\x13\xf2\x6e\x0e\x09\xd4\xa4\xb1\x62\x9f\xed\x58\xa3\x65\xcb\xe7\x70\x06\x7b\xea\x02\xb2\x6b\xcd\xd0\x35\xa8\x5b\xae\x1f\x40\x76\x33\x6c\x59\x0b\x76\xd4\x0d\xec\x02\x98\x18\x6c\xe9\x81\xe1\x06\x1b\x8b\x2b\x2d\xac\x1b\x6e\x12\x8b\x9e\xa4\x85\x72\xa1\x7b\x6e\xa0\x74\xa0\x11\x5a\xa4\x5a\x94\xd1\x05\x6d\xcd\xa0\x65\x81\xef\x77\xea\xc7\xaf\xbf\x9c\x43\xcc\x02\x37\x51\x96\xf3\xcc\x33\x05\x5e\x79\xf2\x37\x6d\x79\x81\x7f\xc4\x2a\xbd\x29\xf1\x34\x9b\x01\x40\x50\x87\x71\x4f\x43\x27\xb0\xec\xcc\x60\x6b\x8e\x12\xb6\xa6\x6b\xdc\x8b\x4c\x2e\x46\xc9\x32\x56\xac\xf4\x26\xab\x6f\xb9\x09\x50\x1d\x0b\x84\xb7\x7d\xc0\x5a\xe0\xb7\xa7\xc9\xb0\xab\x10\x7e\xce\x55\xef\x96\x21\xf0\x07\x09\xc1\x89\x1d\xea\x20\xff\x86\x25\x08\x11\xfd\x92\x61\x77\xe3\xd1\xc5\x3b\x16\xab\x0e\x20\x63\x99\xde\x72\x4f\x96\x0b\xa7\x36\x9a\xed\x02\x34\x48\x5b\xfc\x6e\xac\x35\xfb\x7b\x3f\x98\x12\x67\x37\x75\xed\x45\xcd\x7a\x24\x76\xf1\x10\x08\x96\xd7\x6c\x59\xd7\xd1\x6f\x2d\x47\x2a\x70\x62\x2c\x37\x30\x3a\xc4\xd2\xc8\x28\x62\x81\xe4\x30\xda\x0f\xab\x4e\xd5\x5f\x49\xda\x5c\xc0\xb7\xe4\xb5\xee\x76\x6c\xbf\xf1\x1a\x5f\x7c\xdf\x89\x49\x71\x34\xc8\x32\x67\xf9\xbf\x6a\x7c\xea\xaa\x55\xa0\x78\x79\x36\x11\xe4\xaa\xd0\x61\xca\x87\x33\x9f\x22\x5c\x5f\xa3\x27\xad\xea\x62\x7e\x1b\x0c\xab\x8d\x60\xf5\x66\xb7\xeb\x04\x9e\x3c\x3a\xc2\xce\xcb\x89\x5a\xdf\x5d\xb2\xcc\x24\xdf\xb2\x58\xc5\xbb\x68\xf6\xbb\xa5\x9f\x11\x72\x96\xe3\x6e\x5d\xe5\xb1\xe2\xcb\xa1\x1e\x55\xfa\x7e\x9b\xaa\xf9\xcc\x62\xf4\xe6\xf2\xb1\xe7\x05\xb4\xea\xce\xb1\x53\xbc\x8f\x3f\xfd\xff\xcb\x8f\x39\xe3\xaa\x28\x4b\x90\x3b\xfd\xa0\x91\xae\xff\x57\xbc\x44\x76\xec\x32\xb7\xe4\xd9\x61\x6d\x6c\x78\xb0\x51\x3b\xd6\xb9\xe4\xfb\x6a\xfe\xc9\xf2\xda\x28\xa2\x89\x3f\xb9\xd1\x7b\x41\xbc\x89\xa5\x42\x24\xfa\x29\x1e\xae\xfc\x51\xda\xf0\xe8\x95\xe0\xff\xe9\x56\xfe\xab\xa4\x6d\x2c\xed\x4b\x9c\x1d\xed\xeb\x57\x6b\x76\xaa\x61\xfb\x7c\x55\xf8\x5d\x5c\x1c\x8d\x6c\xc4\xf6\xc6\x2e\x67\x27\x27\x27\xef\x18\xeb\xa7\x5e\xcc\x3e\xb6\x12\xd4\x3a\x3d\xec\x3f\x14\xc9\xb7\x08\x2e\x3f\xe7\xae\xaa\x7d\xa2\x9a\xef\xc1\xf8\x19\xed\x9d\x2e\x16\xfe\xc1\xf5\x20\x8c\xa7\xa3\x5d\xab\x55\xaf\xfc\x7d\x3c\xd9\x34\x31\xe5\xf1\x31\x56\x79\x25\x73\x52\x55\x53\x4f\x2b\xd5\x29\x51\xfc\xb2\x76\x47\x6a\x7d\x4b\xb9\xcf\x57\xc5\x91\x4e\x23\x6a\x14\xea\x83\xab\xf8\x93\x62\x99\xcd\x27\x87\xb1\xd6\xe9\x91\x71\x96\xe3\xeb\x30\xdd\xd7\xe9\x6d\xf8\x86\x75\x0e\x90\x03\x1a\x72\x9b\x8f\x19\xf4\x40\x91\xaa\xe1\xde\x38\x25\xc9\x0c\x97\x9f\xa7\x93\x1a\xa7\xf0\xfc\x5f\x00\x00\x00\xff\xff\x12\x91\xfc\xab\x34\x08\x00\x00" -func generic_transferCdcBytes() ([]byte, error) { +func generic_transfer_with_addressCdcBytes() ([]byte, error) { return bindataRead( - _generic_transferCdc, - "generic_transfer.cdc", + _generic_transfer_with_addressCdc, + "generic_transfer_with_address.cdc", ) } -func generic_transferCdc() (*asset, error) { - bytes, err := generic_transferCdcBytes() +func generic_transfer_with_addressCdc() (*asset, error) { + bytes, err := generic_transfer_with_addressCdcBytes() if err != nil { return nil, err } - info := bindataFileInfo{name: "generic_transfer.cdc", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} - a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xa3, 0xa7, 0x57, 0x32, 0xee, 0x9d, 0x77, 0x16, 0x42, 0xa5, 0xd5, 0x7, 0xd8, 0x9e, 0xbc, 0xc3, 0x5e, 0x9c, 0x54, 0xb3, 0x9a, 0x47, 0x6f, 0x4d, 0x39, 0xf2, 0x89, 0xd2, 0xde, 0x79, 0x85, 0x57}} + info := bindataFileInfo{name: "generic_transfer_with_address.cdc", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} + a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xb9, 0x4a, 0xf4, 0x63, 0x63, 0x28, 0x2, 0xe, 0x4f, 0x4d, 0x7b, 0x6a, 0xf8, 0x97, 0x44, 0xa6, 0x87, 0xf8, 0xef, 0x51, 0xd7, 0xe6, 0xef, 0xad, 0x96, 0xea, 0x6d, 0x6c, 0xe7, 0xab, 0x13, 0xe7}} + return a, nil +} + +var _generic_transfer_with_pathsCdc = "\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x9c\x55\xcf\x6f\xda\x30\x14\x3e\x97\xbf\xe2\x2b\x87\x36\x48\x34\x5c\xa6\x1d\x50\x7f\xac\xab\xd4\x69\xb7\xaa\xed\xba\xb3\x71\x5e\x88\xd7\x60\x47\x7e\x2f\x50\x54\xf1\xbf\x4f\x76\x42\x20\x94\x69\xda\xb8\x90\x18\xe7\x7b\xdf\xaf\x18\xb3\xa8\x9c\x17\xdc\xd7\x76\x6e\x66\x25\x3d\xbb\x57\xb2\xc8\xbd\x5b\x60\xd8\x5b\x1b\x0e\x06\x93\xc9\x04\x77\xca\xa2\x52\xcc\x30\x16\xca\xae\xc1\xe2\xbc\x9a\x13\x2a\x25\x05\x94\xcd\xe0\x49\x93\x59\x92\x6f\x56\x4c\x46\x56\x4c\x6e\xc8\xc3\x58\x16\x52\x19\x5c\x8e\x5f\x35\x0b\xa4\x20\x64\x94\xab\xba\x94\x34\x42\x3f\x17\x86\x51\x92\x30\xd6\xae\x86\x2e\x9c\x63\x8a\xbb\x24\x72\x0a\x8b\x2b\x65\x05\xe2\xc0\x64\x33\x28\xc6\x8a\xca\x32\x6e\xd1\xaa\x52\x33\x53\x1a\x59\x7f\xdc\x67\xc2\x65\x1c\x11\xc7\xdc\xda\x75\x8b\x18\x19\x6a\x65\x31\xa3\xa8\x89\x22\xa6\xb2\x50\x7e\x5e\x2f\xc8\x0a\x0a\xf2\x34\x06\x3b\xac\x54\x19\x99\x71\xe1\xea\x32\x8b\x38\xcd\x25\x74\x41\xfa\x75\xf7\xc4\x52\x95\x35\x71\x98\xbd\x50\xaf\x04\xae\x7d\xa3\xc1\x58\x21\x9b\x51\xb6\x3f\xda\xf0\x76\xac\xb1\x91\x9e\x78\x65\x59\x69\x31\xce\x26\x6a\xe1\x6a\x2b\x53\xfc\xb8\x37\x6f\x9f\x3f\x8d\x21\x6e\x8a\xdb\x2c\xf3\xc4\x3c\x8e\xba\xc8\x3f\x28\x29\xbe\x77\x06\x4f\xf1\x24\xde\xd8\xf9\xb8\x8b\xe0\xf8\xef\x23\xbc\x0f\x06\x00\x10\x2d\x27\xbc\x84\x04\xe0\x89\x5d\xed\x75\x20\xab\x04\x85\x2b\x33\xde\x79\xcf\xcd\xaa\xf2\x84\x19\x19\x3b\x47\x24\x9a\x93\xf7\x94\x45\xa8\x92\x04\x42\x8b\x2a\x62\x4d\xf1\xe5\xbd\x57\x9d\x34\x2e\x6f\x9a\xa9\x95\xa7\x4a\x79\x4a\xd8\xcc\x6d\x20\xa5\x6a\x29\x92\xaf\xce\x7b\xb7\x7a\x09\xde\x8d\x70\x76\xab\x75\xd0\xde\x11\xdd\x4e\x68\xbb\x16\x64\xe1\x0a\x4f\xbb\xbb\xc4\xec\xa9\x3c\xe6\xcd\xa8\xc3\x09\x9f\x9b\x1b\x54\xca\x1a\x9d\x0c\xef\x62\x84\xd6\x09\xb4\xb3\x2c\xbe\xd6\x02\xd5\xef\x74\x7c\x15\x82\x13\x95\x77\x4b\x13\x12\x3c\x2c\x36\x47\x5b\x87\xa3\x1d\xd9\xc9\x04\xdf\x28\x20\x79\xca\xc9\x93\x0d\xb6\xba\x08\xd2\xa8\x3e\xe7\x38\x83\x32\x2c\x83\x33\x3d\x91\x71\xe5\x91\x72\x5c\xb5\x9b\xd3\x96\x4e\x3a\x8b\x26\x5d\x46\xc3\xfa\xfe\xfe\x34\x52\x64\x5e\xad\x46\x38\x3b\x70\xfe\xa1\x21\xed\x37\xd7\x49\x10\x32\xdd\xf7\x70\x34\x38\x39\x39\x39\xe6\x45\x33\xe8\x23\x79\xb7\x6a\xb8\xc7\x38\x4f\xf7\x05\x33\x95\x79\xda\x15\x00\x97\x17\x9d\x8c\x74\xd5\x72\xeb\x0a\xdd\x7c\x37\x89\xb4\x9d\xa0\x37\xd2\xb5\x10\xde\x7b\x4e\x54\xf5\xac\x34\xba\x4d\xfb\xa1\xbb\xe9\x85\x7d\xbc\xea\xff\x16\x77\x33\xe7\xff\xd3\x0e\x5c\x3d\x69\x53\x99\x70\x00\x5c\x61\x4e\xd2\x36\x38\x11\x37\x3a\xdc\x16\xe9\x36\xf9\x76\x0f\xa5\xdd\xf1\x65\x88\xb7\x39\x1f\x46\xf9\xd8\x3e\xbb\xb9\x4e\x76\xce\xfc\x5d\xe9\x9f\xc2\xec\x86\x9f\x33\xb6\xd0\xa7\x07\x25\x7e\x6e\x5f\xf3\xed\x29\xd0\xb9\x73\xb4\xc6\x7b\xc8\xcd\x3f\xc0\xee\x50\xee\x40\xf7\x0c\x48\x33\xaa\x1c\x1b\x69\x8b\x79\x79\xd1\x2f\xd1\xb6\x20\x9b\xdf\x01\x00\x00\xff\xff\x25\xb7\x7d\xef\xa1\x06\x00\x00" + +func generic_transfer_with_pathsCdcBytes() ([]byte, error) { + return bindataRead( + _generic_transfer_with_pathsCdc, + "generic_transfer_with_paths.cdc", + ) +} + +func generic_transfer_with_pathsCdc() (*asset, error) { + bytes, err := generic_transfer_with_pathsCdcBytes() + if err != nil { + return nil, err + } + + info := bindataFileInfo{name: "generic_transfer_with_paths.cdc", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} + a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x6a, 0xcb, 0x54, 0x6b, 0x40, 0x65, 0x79, 0x9c, 0xe2, 0x63, 0x61, 0x29, 0xb5, 0xe5, 0x8, 0xef, 0x33, 0xe6, 0x21, 0xf9, 0x11, 0xdc, 0x75, 0x77, 0x71, 0xaa, 0x2c, 0xb3, 0xd8, 0x46, 0xb7, 0xc}} return a, nil } @@ -960,7 +981,8 @@ func AssetNames() []string { var _bindata = map[string]func() (*asset, error){ "burn_tokens.cdc": burn_tokensCdc, "create_forwarder.cdc": create_forwarderCdc, - "generic_transfer.cdc": generic_transferCdc, + "generic_transfer_with_address.cdc": generic_transfer_with_addressCdc, + "generic_transfer_with_paths.cdc": generic_transfer_with_pathsCdc, "metadata/setup_account_from_address.cdc": metadataSetup_account_from_addressCdc, "metadata/setup_account_from_vault_reference.cdc": metadataSetup_account_from_vault_referenceCdc, "mint_tokens.cdc": mint_tokensCdc, @@ -1044,7 +1066,8 @@ type bintree struct { var _bintree = &bintree{nil, map[string]*bintree{ "burn_tokens.cdc": {burn_tokensCdc, map[string]*bintree{}}, "create_forwarder.cdc": {create_forwarderCdc, map[string]*bintree{}}, - "generic_transfer.cdc": {generic_transferCdc, map[string]*bintree{}}, + "generic_transfer_with_address.cdc": {generic_transfer_with_addressCdc, map[string]*bintree{}}, + "generic_transfer_with_paths.cdc": {generic_transfer_with_pathsCdc, map[string]*bintree{}}, "metadata": {nil, map[string]*bintree{ "setup_account_from_address.cdc": {metadataSetup_account_from_addressCdc, map[string]*bintree{}}, "setup_account_from_vault_reference.cdc": {metadataSetup_account_from_vault_referenceCdc, map[string]*bintree{}}, diff --git a/lib/go/templates/transaction_templates.go b/lib/go/templates/transaction_templates.go index aa607d7..f1f3bf1 100644 --- a/lib/go/templates/transaction_templates.go +++ b/lib/go/templates/transaction_templates.go @@ -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 @@ -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, @@ -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 { diff --git a/lib/go/test/go.mod b/lib/go/test/go.mod index 7d9c1f9..6c67044 100644 --- a/lib/go/test/go.mod +++ b/lib/go/test/go.mod @@ -4,12 +4,12 @@ go 1.18 require ( github.com/btcsuite/btcd/chaincfg/chainhash v1.0.2 - github.com/onflow/cadence v1.0.0-M4 - github.com/onflow/flow-emulator v1.0.0-M1 - github.com/onflow/flow-ft/lib/go/contracts v0.7.1-0.20240125205519-2e80d9b4bd01 + github.com/onflow/cadence v1.0.0-M5 + github.com/onflow/flow-emulator v1.0.0-M3 + github.com/onflow/flow-ft/lib/go/contracts v0.7.1-0.20240205224107-320aa3cf09e0 github.com/onflow/flow-ft/lib/go/templates v0.7.1-0.20240125205519-2e80d9b4bd01 - github.com/onflow/flow-go-sdk v1.0.0-M1 - github.com/onflow/flow-nft/lib/go/contracts v1.1.1-0.20240125205553-d2b571fb3fad + github.com/onflow/flow-go-sdk v1.0.0-M2 + github.com/onflow/flow-nft/lib/go/contracts v1.1.1-0.20240205233530-86ee8c352fa6 github.com/rs/zerolog v1.29.0 github.com/stretchr/testify v1.8.4 ) @@ -50,7 +50,7 @@ require ( github.com/fxamacker/cbor/v2 v2.4.1-0.20230228173756-c0c9f774e40c // indirect github.com/fxamacker/circlehash v0.3.0 // indirect github.com/getsentry/sentry-go v0.18.0 // indirect - github.com/glebarez/go-sqlite v1.21.1 // indirect + github.com/glebarez/go-sqlite v1.22.0 // indirect github.com/go-logr/logr v1.2.4 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/go-ole/go-ole v1.2.6 // indirect @@ -61,7 +61,7 @@ require ( github.com/golang/glog v1.1.2 // indirect github.com/golang/protobuf v1.5.3 // indirect github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect - github.com/google/uuid v1.4.0 // indirect + github.com/google/uuid v1.5.0 // indirect github.com/gorilla/websocket v1.5.0 // indirect github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.3 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect @@ -96,8 +96,8 @@ require ( github.com/logrusorgru/aurora/v4 v4.0.0 // indirect github.com/magiconair/properties v1.8.7 // indirect github.com/mattn/go-colorable v0.1.13 // indirect - github.com/mattn/go-isatty v0.0.19 // indirect - github.com/mattn/go-runewidth v0.0.14 // indirect + github.com/mattn/go-isatty v0.0.20 // indirect + github.com/mattn/go-runewidth v0.0.15 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect github.com/minio/sha256-simd v1.0.1 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect @@ -114,10 +114,10 @@ require ( github.com/olekukonko/tablewriter v0.0.5 // indirect github.com/onflow/atree v0.6.1-0.20230711151834-86040b30171f // indirect github.com/onflow/crypto v0.25.0 // indirect - github.com/onflow/flow-core-contracts/lib/go/contracts v0.15.1-0.20240125214229-b7a95136dd0d // indirect - github.com/onflow/flow-core-contracts/lib/go/templates v0.15.1-0.20240125214229-b7a95136dd0d // indirect - github.com/onflow/flow-go v0.33.2-0.20240126002816-f0770a716d61 // indirect - github.com/onflow/flow/protobuf/go/flow v0.3.2-0.20231213135419-ae911cc351a2 // indirect + github.com/onflow/flow-core-contracts/lib/go/contracts v0.15.2-0.20240206003101-928bf99024d7 // indirect + github.com/onflow/flow-core-contracts/lib/go/templates v0.15.2-0.20240206003101-928bf99024d7 // indirect + github.com/onflow/flow-go v0.33.2-0.20240206235622-50f8c81f1f43 // indirect + github.com/onflow/flow/protobuf/go/flow v0.3.7 // indirect github.com/onflow/sdks v0.5.1-0.20230912225508-b35402f12bba // indirect github.com/opentracing/opentracing-go v1.2.0 // indirect github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 // indirect @@ -175,8 +175,8 @@ require ( golang.org/x/sync v0.5.0 // indirect golang.org/x/sys v0.15.0 // indirect golang.org/x/text v0.14.0 // indirect - golang.org/x/tools v0.16.0 // indirect - golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect + golang.org/x/tools v0.16.1 // indirect + golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect gonum.org/v1/gonum v0.13.0 // indirect google.golang.org/appengine v1.6.7 // indirect google.golang.org/genproto v0.0.0-20231016165738-49dd2c1f3d0b // indirect @@ -187,10 +187,10 @@ require ( gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect lukechampine.com/blake3 v1.2.1 // indirect - modernc.org/libc v1.22.3 // indirect - modernc.org/mathutil v1.5.0 // indirect - modernc.org/memory v1.5.0 // indirect - modernc.org/sqlite v1.21.1 // indirect + modernc.org/libc v1.37.6 // indirect + modernc.org/mathutil v1.6.0 // indirect + modernc.org/memory v1.7.2 // indirect + modernc.org/sqlite v1.28.0 // indirect rsc.io/tmplfunc v0.0.3 // indirect ) diff --git a/lib/go/test/go.sum b/lib/go/test/go.sum index 8c33c47..17ee263 100644 --- a/lib/go/test/go.sum +++ b/lib/go/test/go.sum @@ -1254,6 +1254,8 @@ github.com/gin-contrib/sse v0.0.0-20190301062529-5545eab6dad3/go.mod h1:VJ0WA2NB github.com/gin-gonic/gin v1.4.0/go.mod h1:OW2EZn3DO8Ln9oIKOvM++LBO+5UPHJJDH72/q/3rZdM= github.com/glebarez/go-sqlite v1.21.1 h1:7MZyUPh2XTrHS7xNEHQbrhfMZuPSzhkm2A1qgg0y5NY= github.com/glebarez/go-sqlite v1.21.1/go.mod h1:ISs8MF6yk5cL4n/43rSOmVMGJJjHYr7L2MbZZ5Q4E2E= +github.com/glebarez/go-sqlite v1.22.0 h1:uAcMJhaA6r3LHMTFgP0SifzgXg46yJkgxqyuyec+ruQ= +github.com/glebarez/go-sqlite v1.22.0/go.mod h1:PlBIdHe0+aUEFn+r2/uthrWq4FxbzugL0L8Li6yQJbc= github.com/glycerine/go-unsnap-stream v0.0.0-20180323001048-9f0cb55181dd/go.mod h1:/20jfyN9Y5QPEAprSgKAUr+glWDY39ZiUEAYOEv5dsE= github.com/glycerine/goconvey v0.0.0-20190410193231-58a59202ab31/go.mod h1:Ogl1Tioa0aV7gstGFO7KhffUsb9M4ydbEbbxpcEDc24= github.com/go-check/check v0.0.0-20180628173108-788fd7840127/go.mod h1:9ES+weclKsC9YodN5RgxqK/VD9HM9JsCSh7rNhMZE98= @@ -1444,6 +1446,8 @@ github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+ github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.4.0 h1:MtMxsa51/r9yyhkyLsVeVt0B+BGQZzpQiTQ4eHZ8bc4= github.com/google/uuid v1.4.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.5.0 h1:1p67kYwdtXjb0gL0BPiP1Av9wiZPo5A8z2cWkTZ+eyU= +github.com/google/uuid v1.5.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/enterprise-certificate-proxy v0.0.0-20220520183353-fd19c99a87aa/go.mod h1:17drOmN3MwGY7t0e+Ei9b45FFGA3fBs3x36SsCg1hq8= github.com/googleapis/enterprise-certificate-proxy v0.1.0/go.mod h1:17drOmN3MwGY7t0e+Ei9b45FFGA3fBs3x36SsCg1hq8= github.com/googleapis/enterprise-certificate-proxy v0.2.0/go.mod h1:8C0jb7/mgJe/9KK8Lm7X9ctZC2t60YyIpYEI16jx0Qg= @@ -1712,12 +1716,16 @@ github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/ github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA= github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= +github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-runewidth v0.0.3/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/mattn/go-runewidth v0.0.6/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/mattn/go-runewidth v0.0.14 h1:+xnbZSEeDbOIg5/mE6JF0w6n9duR1l3/WmbinWVwUuU= github.com/mattn/go-runewidth v0.0.14/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= +github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U= +github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/mattn/go-sqlite3 v1.11.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= github.com/mattn/go-sqlite3 v1.14.5/go.mod h1:WVKg1VTActs4Qso6iwGbiFih2UIHo0ENGwNd0Lj+XmI= github.com/mattn/go-sqlite3 v1.14.14/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= @@ -1807,23 +1815,39 @@ github.com/onflow/atree v0.6.1-0.20230711151834-86040b30171f/go.mod h1:xvP61FoOs github.com/onflow/cadence v1.0.0-M3/go.mod h1:odXGZZ/wGNA5mwT8bC9v8u8EXACHllB2ABSZK65TGL8= github.com/onflow/cadence v1.0.0-M4 h1:/nt3j7vpYDxuI0ghIgAJrb2R01ijvJYZLAkKt+zbpTY= github.com/onflow/cadence v1.0.0-M4/go.mod h1:odXGZZ/wGNA5mwT8bC9v8u8EXACHllB2ABSZK65TGL8= +github.com/onflow/cadence v1.0.0-M5 h1:vNG7x2KLLrt2yfVr1HtEXUlUi4GdNo+rkXnPkhSzsFA= +github.com/onflow/cadence v1.0.0-M5/go.mod h1:a4mccDU90hmuxCLUFzs9J/ANG/rYbFa36h4Z0bBAqNU= github.com/onflow/crypto v0.25.0 h1:BeWbLsh3ZD13Ej+Uky6kg1PL1ZIVBDVX+2MVBNwqddg= github.com/onflow/crypto v0.25.0/go.mod h1:C8FbaX0x8y+FxWjbkHy0Q4EASCDR9bSPWZqlpCLYyVI= github.com/onflow/flow-core-contracts/lib/go/contracts v0.15.1-0.20240125214229-b7a95136dd0d h1:Afcfk/9jAQZ1v5PLGdP68FG/0yPPM60fn9Eq8ChBGS0= github.com/onflow/flow-core-contracts/lib/go/contracts v0.15.1-0.20240125214229-b7a95136dd0d/go.mod h1:Ts/HN+N0RaYJ6oPCqR1JPaMVFiVaMdKTSUH4OdSjjs0= +github.com/onflow/flow-core-contracts/lib/go/contracts v0.15.2-0.20240206003101-928bf99024d7 h1:OI/4F2NK/X/4x3dTUFFDGtuOsSa9pX+jjBeSEcBrY/M= +github.com/onflow/flow-core-contracts/lib/go/contracts v0.15.2-0.20240206003101-928bf99024d7/go.mod h1:GK+Ik1K3L3v8xmHmRQv5yxJz81lYhdYSNm0PQ63Xrws= github.com/onflow/flow-core-contracts/lib/go/templates v0.15.1-0.20240125214229-b7a95136dd0d h1:IQJpP3VLLjT4R8ItBpr+Mmp0IOnC/8iBcM0/67JNB9c= github.com/onflow/flow-core-contracts/lib/go/templates v0.15.1-0.20240125214229-b7a95136dd0d/go.mod h1:MZ2j5YVTQiSE0B99zuaYhxvGG5GcvimWpQK1Fw/1QBg= +github.com/onflow/flow-core-contracts/lib/go/templates v0.15.2-0.20240206003101-928bf99024d7 h1:WAx8ftVz1BeXiKvQ9gLKEf1J3NBWK26Pbczd0iH4C6I= +github.com/onflow/flow-core-contracts/lib/go/templates v0.15.2-0.20240206003101-928bf99024d7/go.mod h1:MZ2j5YVTQiSE0B99zuaYhxvGG5GcvimWpQK1Fw/1QBg= github.com/onflow/flow-emulator v1.0.0-M1 h1:0hBEmvm73F+5HhN5ugkOP3UyN+Ea9yGWflEmoeGzgdw= github.com/onflow/flow-emulator v1.0.0-M1/go.mod h1:JFJCeQVyhCQVD2Tq4QhctIXK6j5U6aU15yoEwMJt5AQ= +github.com/onflow/flow-emulator v1.0.0-M3 h1:+Rktq6OzQfJCLNVweJqtTUKZrHMc6eVVZn1tYI1PMMg= +github.com/onflow/flow-emulator v1.0.0-M3/go.mod h1:iMQ7WbzrEa+xQL23P8zCxrXv8YhAWUds8SvEdERB14o= github.com/onflow/flow-go v0.33.2-0.20240126002816-f0770a716d61 h1:Xq40zbxw9mDS1+Zz1p6DCzAxDYQwbHWLJ5B9HOp9Fk8= github.com/onflow/flow-go v0.33.2-0.20240126002816-f0770a716d61/go.mod h1:xdzERQeTalqsU0rHGSZgqQuE5krMfBQ4BA/4bgrLndY= +github.com/onflow/flow-go v0.33.2-0.20240206235622-50f8c81f1f43 h1:KB10iF+6HIQ/hKykzBf8n3P8cDDRHL4ytfc0R4ApCZM= +github.com/onflow/flow-go v0.33.2-0.20240206235622-50f8c81f1f43/go.mod h1:gWMjeDpt0YuJiwxtgdD8qxsM53PvUyoPHmjisZZmjR0= github.com/onflow/flow-go-sdk v1.0.0-M1 h1:mke/ebYwNRRWPZqcwCV56Alx0A8psew43ZbSEUQ4TL8= github.com/onflow/flow-go-sdk v1.0.0-M1/go.mod h1:TDW0MNuCs4SvqYRUzkbRnRmHQL1h4X8wURsCw9P9beo= +github.com/onflow/flow-go-sdk v1.0.0-M2 h1:YWeXTo112RF8s6swiOU5oW8JWbOOz392FCeAbGnm+W4= +github.com/onflow/flow-go-sdk v1.0.0-M2/go.mod h1:mllhNw5WAEug59EWvW3TudcrtPmB5VfLA3iUx7mAA4s= github.com/onflow/flow-nft/lib/go/contracts v1.1.1-0.20240125205553-d2b571fb3fad h1:I6LD9BOsilGbiqhGjP86FIIXJe0YdUz75d/oWdHFzDI= github.com/onflow/flow-nft/lib/go/contracts v1.1.1-0.20240125205553-d2b571fb3fad/go.mod h1:2gpbza+uzs1k7x31hkpBPlggIRkI53Suo0n2AyA2HcE= +github.com/onflow/flow-nft/lib/go/contracts v1.1.1-0.20240205233530-86ee8c352fa6 h1:/2vvjKkWG/3cKP3IpgiGNqXi0yskn4GmNTjmeCwMoz8= +github.com/onflow/flow-nft/lib/go/contracts v1.1.1-0.20240205233530-86ee8c352fa6/go.mod h1:2gpbza+uzs1k7x31hkpBPlggIRkI53Suo0n2AyA2HcE= github.com/onflow/flow/protobuf/go/flow v0.3.2-0.20231121210617-52ee94b830c2/go.mod h1:NA2pX2nw8zuaxfKphhKsk00kWLwfd+tv8mS23YXO4Sk= github.com/onflow/flow/protobuf/go/flow v0.3.2-0.20231213135419-ae911cc351a2 h1:+rT+UsfTR39JZO8ht2+4fkaWfHw74SCj1fyz1lWuX8A= github.com/onflow/flow/protobuf/go/flow v0.3.2-0.20231213135419-ae911cc351a2/go.mod h1:NA2pX2nw8zuaxfKphhKsk00kWLwfd+tv8mS23YXO4Sk= +github.com/onflow/flow/protobuf/go/flow v0.3.7 h1:+6sBdlE/u4ZMTVB9U1lA6Xn2Bd48lOOX96Bv9dNubsk= +github.com/onflow/flow/protobuf/go/flow v0.3.7/go.mod h1:NA2pX2nw8zuaxfKphhKsk00kWLwfd+tv8mS23YXO4Sk= github.com/onflow/sdks v0.5.1-0.20230912225508-b35402f12bba h1:rIehuhO6bj4FkwE4VzwEjX7MoAlOhUJENBJLqDqVxAo= github.com/onflow/sdks v0.5.1-0.20230912225508-b35402f12bba/go.mod h1:F0dj0EyHC55kknLkeD10js4mo14yTdMotnWMslPirrU= github.com/onflow/wal v0.0.0-20230529184820-bc9f8244608d h1:gAEqYPn3DS83rHIKEpsajnppVD1+zwuYPFyeDVFaQvg= @@ -2634,6 +2658,8 @@ golang.org/x/tools v0.10.0/go.mod h1:UJwyiVBsOA2uwvK/e5OY3GTpDUJriEd+/YlqAwLPmyM golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58= golang.org/x/tools v0.16.0 h1:GO788SKMRunPIBCXiQyo2AaexLstOrVhuAL5YwsckQM= golang.org/x/tools v0.16.0/go.mod h1:kYVVN6I1mBNoB1OX+noeBjbRk4IUEPa7JJ+TJMEooJ0= +golang.org/x/tools v0.16.1 h1:TLyB3WofjdOEepBHAU20JdNC1Zbg87elYofWYAY5oZA= +golang.org/x/tools v0.16.1/go.mod h1:kYVVN6I1mBNoB1OX+noeBjbRk4IUEPa7JJ+TJMEooJ0= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -2643,6 +2669,8 @@ golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df/go.mod h1:K8+ghG5WaK9qNq golang.org/x/xerrors v0.0.0-20220609144429-65e65417b02f/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 h1:H2TDz8ibqkAF6YGhCdN3jS9O0/s90v0rJh3X/OLHEUk= golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= +golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 h1:+cNy6SZtPcJQH3LJVLOSmiC7MMxXNOb3PU/VUEz+EhU= +golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028/go.mod h1:NDW/Ps6MPRej6fsCIbMTohpP40sJ/P/vI1MoTEGwX90= gonum.org/v1/gonum v0.0.0-20180816165407-929014505bf4/go.mod h1:Y+Yx5eoAFn32cQvJDxZx5Dpnq+c3wtXuadVZAcxbbBo= gonum.org/v1/gonum v0.0.0-20181121035319-3f7ecaa7e8ca/go.mod h1:Y+Yx5eoAFn32cQvJDxZx5Dpnq+c3wtXuadVZAcxbbBo= gonum.org/v1/gonum v0.6.0/go.mod h1:9mxDZsDKxgMAuccQkewq682L+0eCu4dCN2yonUJTCLU= @@ -3077,10 +3105,14 @@ modernc.org/libc v1.21.4/go.mod h1:przBsL5RDOZajTVslkugzLBj1evTue36jEomFQOoYuI= modernc.org/libc v1.22.2/go.mod h1:uvQavJ1pZ0hIoC/jfqNoMLURIMhKzINIWypNM17puug= modernc.org/libc v1.22.3 h1:D/g6O5ftAfavceqlLOFwaZuA5KYafKwmr30A6iSqoyY= modernc.org/libc v1.22.3/go.mod h1:MQrloYP209xa2zHome2a8HLiLm6k0UT8CoHpV74tOFw= +modernc.org/libc v1.37.6 h1:orZH3c5wmhIQFTXF+Nt+eeauyd+ZIt2BX6ARe+kD+aw= +modernc.org/libc v1.37.6/go.mod h1:YAXkAZ8ktnkCKaN9sw/UDeUVkGYJ/YquGO4FTi5nmHE= modernc.org/mathutil v1.2.2/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E= modernc.org/mathutil v1.4.1/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E= modernc.org/mathutil v1.5.0 h1:rV0Ko/6SfM+8G+yKiyI830l3Wuz1zRutdslNoQ0kfiQ= modernc.org/mathutil v1.5.0/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E= +modernc.org/mathutil v1.6.0 h1:fRe9+AmYlaej+64JsEEhoWuAYBkOtQiMEU7n/XgfYi4= +modernc.org/mathutil v1.6.0/go.mod h1:Ui5Q9q1TR2gFm0AQRqQUaBWFLAhQpCwNcuhBOSedWPo= modernc.org/memory v1.1.1/go.mod h1:/0wo5ibyrQiaoUoH7f9D8dnglAmILJ5/cxZlRECf+Nw= modernc.org/memory v1.2.0/go.mod h1:/0wo5ibyrQiaoUoH7f9D8dnglAmILJ5/cxZlRECf+Nw= modernc.org/memory v1.2.1/go.mod h1:PkUhL0Mugw21sHPeskwZW4D6VscE/GQJOnIpCnW6pSU= @@ -3088,12 +3120,16 @@ modernc.org/memory v1.3.0/go.mod h1:PkUhL0Mugw21sHPeskwZW4D6VscE/GQJOnIpCnW6pSU= modernc.org/memory v1.4.0/go.mod h1:PkUhL0Mugw21sHPeskwZW4D6VscE/GQJOnIpCnW6pSU= modernc.org/memory v1.5.0 h1:N+/8c5rE6EqugZwHii4IFsaJ7MUhoWX07J5tC/iI5Ds= modernc.org/memory v1.5.0/go.mod h1:PkUhL0Mugw21sHPeskwZW4D6VscE/GQJOnIpCnW6pSU= +modernc.org/memory v1.7.2 h1:Klh90S215mmH8c9gO98QxQFsY+W451E8AnzjoE2ee1E= +modernc.org/memory v1.7.2/go.mod h1:NO4NVCQy0N7ln+T9ngWqOQfi7ley4vpwvARR+Hjw95E= modernc.org/opt v0.1.1/go.mod h1:WdSiB5evDcignE70guQKxYUl14mgWtbClRi5wmkkTX0= modernc.org/opt v0.1.3/go.mod h1:WdSiB5evDcignE70guQKxYUl14mgWtbClRi5wmkkTX0= modernc.org/sqlite v1.18.1/go.mod h1:6ho+Gow7oX5V+OiOQ6Tr4xeqbx13UZ6t+Fw9IRUG4d4= modernc.org/sqlite v1.18.2/go.mod h1:kvrTLEWgxUcHa2GfHBQtanR1H9ht3hTJNtKpzH9k1u0= modernc.org/sqlite v1.21.1 h1:GyDFqNnESLOhwwDRaHGdp2jKLDzpyT/rNLglX3ZkMSU= modernc.org/sqlite v1.21.1/go.mod h1:XwQ0wZPIh1iKb5mkvCJ3szzbhk+tykC8ZWqTRTgYRwI= +modernc.org/sqlite v1.28.0 h1:Zx+LyDDmXczNnEQdvPuEfcFVA2ZPyaD7UCZDjef3BHQ= +modernc.org/sqlite v1.28.0/go.mod h1:Qxpazz0zH8Z1xCFyi5GSL3FzbtZ3fvbjmywNogldEW0= modernc.org/strutil v1.1.1/go.mod h1:DE+MQQ/hjKBZS2zNInV5hhcipt5rLPWkmpbGeW5mmdw= modernc.org/strutil v1.1.3/go.mod h1:MEHNA7PdEnEwLvspRMtWTNnp2nnyvMfkimT1NKNAGbw= modernc.org/tcl v1.13.1/go.mod h1:XOLfOwzhkljL4itZkK6T72ckMgvj0BDsnKNdZVUOecw= diff --git a/lib/go/test/token_test.go b/lib/go/test/token_test.go index 33808c3..c7460a8 100644 --- a/lib/go/test/token_test.go +++ b/lib/go/test/token_test.go @@ -1,14 +1,13 @@ package test import ( + "context" "testing" "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" "github.com/onflow/cadence" jsoncdc "github.com/onflow/cadence/encoding/json" - "github.com/onflow/cadence/runtime/common" "github.com/onflow/flow-go-sdk" "github.com/onflow/flow-go-sdk/crypto" @@ -45,7 +44,7 @@ func TestTokenSetupAccount(t *testing.T) { exampleTokenAccountKey, _ := accountKeys.NewWithSigner() env := templates.Environment{} - _ = deployTokenContracts(b, adapter, t, []*flow.AccountKey{exampleTokenAccountKey}, &env) + exampleTokenAddr := deployTokenContracts(b, adapter, t, []*flow.AccountKey{exampleTokenAccountKey}, &env) t.Run("Should be able to create empty Vault that doesn't affect supply", func(t *testing.T) { joshAddress, _, _ := createAccountWithVault(b, adapter, t, @@ -75,6 +74,33 @@ func TestTokenSetupAccount(t *testing.T) { }) assert.Equal(t, CadenceUFix64("1000.0"), supply) }) + + t.Run("Should be able to create empty Vault with the generic setup transaction", func(t *testing.T) { + newAccountKey, newSigner := accountKeys.NewWithSigner() + newAddress, _ := adapter.CreateAccount(context.Background(), []*flow.AccountKey{newAccountKey}, nil) + + serviceSigner, _ := b.ServiceKey().Signer() + + // Setup new account with an empty vault + script := templates.GenerateSetupAccountFromAddressScript(env.FungibleTokenAddress, env.FungibleTokenMetadataViewsAddress) + tx := createTxWithTemplateAndAuthorizer(b, script, newAddress) + + tx.AddArgument(cadence.NewAddress(exampleTokenAddr)) + tx.AddArgument(cadence.String("ExampleToken")) + + signAndSubmit( + t, b, tx, + []flow.Address{ + b.ServiceKey().Address, + newAddress, + }, + []crypto.Signer{ + serviceSigner, + newSigner, + }, + false, + ) + }) } // Steps: @@ -186,111 +212,76 @@ func TestTokenExternalTransfers(t *testing.T) { assert.Equal(t, CadenceUFix64("1000.0"), supply) }) - t.Run("Should be able to transfer to multiple accounts ", func(t *testing.T) { - - recipient1Address := cadence.Address(joshAddress) - recipient1Amount := CadenceUFix64("300.0") + t.Run("Should be able to transfer tokens with the generic transfer transactions", func(t *testing.T) { - pair := cadence.KeyValuePair{Key: recipient1Address, Value: recipient1Amount} - recipientPairs := make([]cadence.KeyValuePair, 1) - recipientPairs[0] = pair + script := templates.GenerateTransferGenericVaultWithPathsScript(env.FungibleTokenAddress) - script := templates.GenerateTransferManyAccountsScript(env) + tx := createTxWithTemplateAndAuthorizer(b, script, joshAddress) - tx := flow.NewTransaction(). - SetScript(script). - SetGasLimit(100). - SetProposalKey( - b.ServiceKey().Address, - b.ServiceKey().Index, - b.ServiceKey().SequenceNumber, - ). - SetPayer(b.ServiceKey().Address). - AddAuthorizer(exampleTokenAddr) + _ = tx.AddArgument(CadenceUFix64("300.0")) + _ = tx.AddArgument(cadence.NewAddress(exampleTokenAddr)) - _ = tx.AddArgument(cadence.NewDictionary(recipientPairs)) + tx.AddArgument(cadence.String("exampleTokenVault")) + tx.AddArgument(cadence.String("exampleTokenReceiver")) signAndSubmit( t, b, tx, []flow.Address{ b.ServiceKey().Address, - exampleTokenAddr, + joshAddress, }, []crypto.Signer{ serviceSigner, - exampleTokenSigner, + joshSigner, }, false, ) // Assert that the vaults' balances are correct - // Sender vault script = templates.GenerateInspectVaultScript(env) - result, err := b.ExecuteScript( + result := executeScriptAndCheck(t, b, script, [][]byte{ jsoncdc.MustEncode(cadence.Address(exampleTokenAddr)), }, ) - require.NoError(t, err) - if !assert.True(t, result.Succeeded()) { - t.Log(result.Error.Error()) - } - balance := result.Value - assert.Equal(t, CadenceUFix64("400.0"), balance) + assertEqual(t, CadenceUFix64("1000.0"), result) - // Receiver Vault script = templates.GenerateInspectVaultScript(env) - result, err = b.ExecuteScript( + result = executeScriptAndCheck(t, b, script, [][]byte{ jsoncdc.MustEncode(cadence.Address(joshAddress)), }, ) - require.NoError(t, err) - if !assert.True(t, result.Succeeded()) { - t.Log(result.Error.Error()) - } - balance = result.Value - assert.Equal(t, CadenceUFix64("600.0"), balance) - - // Supply should not have changed - script = templates.GenerateInspectSupplyScript(env) - supply := executeScriptAndCheck(t, b, script, nil) - assert.Equal(t, CadenceUFix64("1000.0"), supply) - }) - - t.Run("Should be able to transfer tokens with the generic transfer transaction", func(t *testing.T) { + assertEqual(t, CadenceUFix64("0.0"), result) - script := templates.GenerateTransferGenericVaultScript(env.FungibleTokenAddress) + script = templates.GenerateTransferGenericVaultWithAddressScript(env.FungibleTokenAddress, env.FungibleTokenMetadataViewsAddress) - tx := createTxWithTemplateAndAuthorizer(b, script, joshAddress) + tx = createTxWithTemplateAndAuthorizer(b, script, exampleTokenAddr) _ = tx.AddArgument(CadenceUFix64("300.0")) - _ = tx.AddArgument(cadence.NewAddress(exampleTokenAddr)) - - storagePath := cadence.Path{Domain: common.PathDomainStorage, Identifier: "exampleTokenVault"} - publicPath := cadence.Path{Domain: common.PathDomainPublic, Identifier: "exampleTokenReceiver"} + _ = tx.AddArgument(cadence.NewAddress(joshAddress)) - _ = tx.AddArgument(storagePath) - _ = tx.AddArgument(publicPath) + tx.AddArgument(cadence.NewAddress(exampleTokenAddr)) + tx.AddArgument(cadence.String("ExampleToken")) signAndSubmit( t, b, tx, []flow.Address{ b.ServiceKey().Address, - joshAddress, + exampleTokenAddr, }, []crypto.Signer{ serviceSigner, - joshSigner, + exampleTokenSigner, }, false, ) // Assert that the vaults' balances are correct script = templates.GenerateInspectVaultScript(env) - result := executeScriptAndCheck(t, b, + result = executeScriptAndCheck(t, b, script, [][]byte{ jsoncdc.MustEncode(cadence.Address(exampleTokenAddr)), diff --git a/transactions/generic_transfer_with_address.cdc b/transactions/generic_transfer_with_address.cdc new file mode 100644 index 0000000..7fb2023 --- /dev/null +++ b/transactions/generic_transfer_with_address.cdc @@ -0,0 +1,44 @@ +import FungibleToken from "FungibleToken" +import FungibleTokenMetadataViews from "FungibleTokenMetadataViews" + +/// Can pass in any contract address and name to transfer a token from that contract +/// This lets you choose the token you want to send +/// +/// Any contract can be chosen here, so wallets should check argument values +/// to make sure the intended token path is passed in +/// +transaction(amount: UFix64, to: Address, contractAddress: Address, contractName: String) { + + // The Vault resource that holds the tokens that are being transferred + let tempVault: @{FungibleToken.Vault} + + // FTVaultData struct to get paths from + let vaultData: FungibleTokenMetadataViews.FTVaultData + + prepare(signer: auth(BorrowValue) &Account) { + + // Borrow a reference to the vault stored on the passed account at the passed publicPath + let resolverRef = getAccount(contractAddress) + .contracts.borrow<&FungibleToken>(name: contractName) + ?? panic("Could not borrow a reference to the fungible token contract") + + // Use that reference to retrieve the FTView + self.vaultData = resolverRef.resolveContractView(resourceType: nil, viewType: Type()) as! FungibleTokenMetadataViews.FTVaultData? + ?? panic("Could not resolve the FTVaultData view for the given Fungible token contract") + + // Get a reference to the signer's stored vault + let vaultRef = signer.storage.borrow(from: self.vaultData.storagePath) + ?? panic("Could not borrow reference to the owner's Vault!") + + self.tempVault <- vaultRef.withdraw(amount: amount) + } + + execute { + let recipient = getAccount(to) + let receiverRef = recipient.capabilities.borrow<&{FungibleToken.Receiver}>(self.vaultData.receiverPath) + ?? panic("Could not borrow reference to the recipient's Receiver!") + + // Transfer tokens from the signer's stored vault to the receiver capability + receiverRef.deposit(from: <-self.tempVault) + } +} \ No newline at end of file diff --git a/transactions/generic_transfer.cdc b/transactions/generic_transfer_with_paths.cdc similarity index 62% rename from transactions/generic_transfer.cdc rename to transactions/generic_transfer_with_paths.cdc index e941698..16851ff 100644 --- a/transactions/generic_transfer.cdc +++ b/transactions/generic_transfer_with_paths.cdc @@ -1,28 +1,34 @@ import FungibleToken from "FungibleToken" -/// Can pass in any storage path and receiver path instead of just the default. +/// Can pass in any storage path and receiver path identifier instead of just the default. /// This lets you choose the token you want to send as well the capability you want to send it to. /// /// Any token path can be passed as an argument here, so wallets should /// should check argument values to make sure the intended token path is passed in /// -transaction(amount: UFix64, to: Address, senderPath: StoragePath, receiverPath: PublicPath) { +transaction(amount: UFix64, to: Address, senderPathIdentifier: String, receiverPathIdentifier: String) { // The Vault resource that holds the tokens that are being transferred let tempVault: @{FungibleToken.Vault} prepare(signer: auth(BorrowValue) &Account) { + let storagePath = StoragePath(identifier: senderPathIdentifier) + ?? panic("Could not construct a storage path from the provided path identifier string") + // Get a reference to the signer's stored vault - let vaultRef = signer.storage.borrow(from: senderPath) + let vaultRef = signer.storage.borrow(from: storagePath) ?? panic("Could not borrow reference to the owner's Vault!") self.tempVault <- vaultRef.withdraw(amount: amount) } execute { + let publicPath = PublicPath(identifier: receiverPathIdentifier) + ?? panic("Could not construct a public path from the provided path identifier string") + let recipient = getAccount(to) - let receiverRef = recipient.capabilities.borrow<&{FungibleToken.Receiver}>(receiverPath) + let receiverRef = recipient.capabilities.borrow<&{FungibleToken.Receiver}>(publicPath) ?? panic("Could not borrow reference to the recipient's Receiver!") // Transfer tokens from the signer's stored vault to the receiver capability