diff --git a/lib/go/templates/internal/assets/assets.go b/lib/go/templates/internal/assets/assets.go index 096dde74..d171f339 100644 --- a/lib/go/templates/internal/assets/assets.go +++ b/lib/go/templates/internal/assets/assets.go @@ -6,7 +6,7 @@ // ../../../transactions/privateForwarder/create_account_private_forwarder.cdc (1.247kB) // ../../../transactions/privateForwarder/create_private_forwarder.cdc (961B) // ../../../transactions/privateForwarder/deploy_forwarder_contract.cdc (278B) -// ../../../transactions/privateForwarder/setup_and_create_forwarder.cdc (1.6kB) +// ../../../transactions/privateForwarder/setup_and_create_forwarder.cdc (1.812kB) // ../../../transactions/privateForwarder/transfer_private_many_accounts.cdc (1.066kB) // ../../../transactions/scripts/get_balance.cdc (468B) // ../../../transactions/scripts/get_supply.cdc (229B) @@ -202,7 +202,7 @@ func privateforwarderDeploy_forwarder_contractCdc() (*asset, error) { return a, nil } -var _privateforwarderSetup_and_create_forwarderCdc = "\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xac\x54\x4d\x6f\xe2\x40\x0c\xbd\xe7\x57\xf8\x54\x11\x89\x92\x3d\x23\xa8\x44\x4b\xa8\xd0\xae\x28\x02\xb6\x7b\x36\xc1\x24\xa3\x86\x99\x68\xe2\xf0\x21\xc4\x7f\x5f\x65\x48\x42\x86\x00\xaa\x56\x3b\x27\x18\x3f\x3f\x3f\xdb\x6f\xe2\x88\x4d\xa2\x34\xc3\x28\x93\xa1\x58\xc6\xb4\x50\x5f\x24\x61\xad\xd5\x06\x7e\xec\x47\xbf\x27\xef\xe3\xd7\x5f\xfe\xe2\xe3\xa7\x3f\x19\x0c\x87\x33\x7f\x3e\x2f\x13\xfc\x3d\x6e\x92\x2b\xfc\x2d\xdc\x54\x8b\x2d\x32\xcd\x28\x20\xb1\x25\x3d\x52\x7a\x87\x7a\x45\xba\xcc\x99\xce\xc6\x9f\x83\x85\x3f\xfa\x98\xfd\x19\xcc\x86\xe3\xc9\x7b\x99\xef\x78\x1e\x2c\x22\x91\x02\x6b\x94\x29\x06\x2c\x94\x04\x5c\xad\x52\x40\xf8\xc4\x2c\xe6\x36\x20\x24\x67\x76\xd0\x05\x3d\xac\x4b\xfe\x3c\x1d\x61\x89\x31\xca\x80\x20\xc0\x04\x97\x22\x16\x7c\x68\x03\xca\x55\x9e\x99\x2d\x63\x11\xd4\x02\x79\x2a\x70\x74\xe1\x72\x9c\x7a\xe5\xa3\xe3\x00\x00\x24\x9a\x12\xd4\xd4\x4a\x45\x28\x49\x77\x61\x90\x71\x34\x08\x02\x95\x49\x76\x4b\x4c\x7e\xc4\x1a\xce\x90\xce\x52\x69\xad\x76\xbd\xa7\xfa\xc0\x3a\xa6\x81\x97\x56\x3e\x83\x2e\x78\x29\x2b\x8d\x21\x79\x54\x83\x18\x84\x0b\xfd\x3e\x48\x11\xc3\xb1\x22\xce\x8f\xe7\xc1\x9b\xa6\xbc\x6f\x04\x49\x3b\x7b\x17\x26\xd1\x34\x99\x64\x0c\x82\x41\x48\x28\x0a\x58\x24\x85\xbc\x14\xb7\xd4\xb2\x02\xf9\xe9\x3d\x5b\x72\x03\x53\xcd\xdf\x24\x7c\x30\xf4\x2d\xb7\xdd\x48\x61\xf5\xa8\x13\x0b\xee\x56\xff\x4e\x97\x89\x15\x7a\x62\x21\xbf\x7a\x4f\x47\xcb\x8f\x9d\xd2\x3d\xa7\x17\x5b\xaa\x57\xec\xdf\xaa\x57\x82\x6d\x89\x8c\x3a\x24\xfe\x96\x44\xf7\x22\x2a\x26\xae\xfc\xf0\x76\xb1\x4a\xbf\x54\x1b\x12\x5f\xae\x1f\xc9\x7e\xa8\xb4\x56\xb0\xbe\xda\xa6\x45\x59\x19\x87\x9e\x57\xcc\x11\x32\x28\x19\x1f\x80\xf6\x89\x4a\x29\xad\x93\xe4\xb0\xd2\xfc\x6b\x41\xf1\x0a\x38\xd2\x2a\x0b\x23\x13\x79\x2d\x22\x42\x32\xe9\x35\x06\x74\x7b\x0b\x4d\xcb\x5e\x35\x58\xf0\x34\xd7\x62\x94\x5b\xbd\x16\xd0\xff\xb5\x94\xea\x9d\x43\xef\xf9\xee\x37\xa6\xf0\xed\x84\x76\xd5\x55\x4b\x53\x20\x12\x41\x92\xbb\x37\x16\xeb\x36\xec\x68\x9e\x47\xef\xb9\x2a\xd7\x36\x3e\xbf\x5b\xf0\x2a\x30\x3f\xb7\x35\x45\x8e\x9a\xd4\xe7\x19\xdf\xa5\xaa\x7e\x5d\x0d\xf7\xbb\xb5\xa7\x66\x07\x79\xe9\xdb\x33\xff\x87\x1e\x1c\xfb\x01\x9f\x9c\x93\xf3\x37\x00\x00\xff\xff\x04\x98\x5e\x52\x40\x06\x00\x00" +var _privateforwarderSetup_and_create_forwarderCdc = "\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xac\x54\x41\x6f\xa3\x3c\x10\xbd\xf3\x2b\xe6\x54\x81\x94\x86\xef\x5c\xa5\x95\xd2\x36\xa9\xaa\x6f\x95\x46\x69\xb6\x7b\x9e\x98\x09\x58\x25\x36\x32\x43\xd3\xa8\xca\x7f\x5f\xe1\x00\xc1\x05\xaa\xee\x6a\x7d\x42\xf8\xcd\xcc\x9b\x79\x6f\xec\xc9\x5d\xa6\x0d\xc3\xbc\x50\xb1\xdc\xa4\xb4\xd6\xaf\xa4\x60\x6b\xf4\x0e\xfe\x7b\x9f\xff\x5c\x3c\x3c\xde\xfe\x98\xad\x9f\xfe\x9f\x2d\xa6\xf7\xf7\xab\xd9\xf3\x73\x1d\x30\x7b\xc7\x5d\xf6\x09\xdf\x87\x5b\x1a\xf9\x86\x4c\x2b\x12\x24\xdf\xc8\xcc\xb5\xd9\xa3\x89\xc8\xd4\x31\xcb\xd5\xe3\xcb\x74\x3d\x9b\x3f\xad\x7e\x4d\x57\xf7\x8f\x8b\x87\x3a\xde\x0b\x43\x58\x27\x32\x07\x36\xa8\x72\x14\x2c\xb5\x02\x8c\xa2\x1c\x10\x5e\xb0\x48\x79\x04\x08\xd9\x29\x3b\x98\x2a\x3d\x6c\xeb\xfc\x65\x38\xc2\x06\x53\x54\x82\x40\x60\x86\x1b\x99\x4a\x3e\x8c\x00\x55\x54\x46\x16\x9b\x54\x8a\xd6\x45\x19\x0a\x9c\x9c\x73\x79\x5e\xbb\xf2\x87\xe7\x01\x00\x64\x86\x32\x34\xe4\xe7\x32\x56\x64\xae\x60\x5a\x70\x32\x15\x42\x17\x8a\x03\xf8\xb0\x90\xf2\xc8\x2d\x9c\x10\xe3\x98\xf8\xae\xa9\x31\xb9\x18\x1a\xc7\xb8\xf9\xba\xf1\x07\x31\x9f\x2e\x96\xb6\x85\x25\x72\x12\x8c\x45\x42\xe2\xd5\x6f\x53\x28\x4f\x18\x36\x13\x6a\x06\x03\x7b\xcc\x01\x53\x43\x18\x1d\x20\x27\x86\x22\x73\x62\x0c\x71\x61\x54\xf3\xeb\xe8\xf5\x34\xb5\xd1\xc6\xe8\xfd\xe4\xa2\x6d\x82\xb1\x15\xe5\xc6\x2f\x75\xbd\x82\x30\x67\x6d\x30\xa6\x90\x5a\x10\x8b\x08\xe0\xfa\x1a\x94\x4c\xbb\x54\xef\x0c\x95\x4c\x11\x14\xed\x5d\x7f\xd9\x40\x2b\x5c\x56\x30\x48\x06\xa9\xa0\x2a\xe0\x24\xa9\xe8\xe5\xf8\x46\xbe\x73\x51\x9e\xc9\xa5\x43\x57\xd8\x6a\xb3\x5d\xc6\x07\x9b\xde\x0f\x46\x9d\x10\xd6\x5f\x75\xe2\xc0\x83\xbe\x89\x55\x7c\x52\xa9\x5e\x27\x17\x1f\xce\x8e\x8d\x6b\x15\x8f\x37\x2e\xd5\xb0\x52\xcc\xa9\x57\x83\x5d\x8a\x8c\x26\x26\xfe\x16\xc5\xe0\x4c\x2a\x25\x6e\x3c\x7e\xb6\x26\x5c\x0f\x38\x76\x98\xf6\x97\x4c\x5b\x05\xdb\xd2\x76\xd7\x8e\xb5\xdd\xba\x93\xc4\x9c\x20\x83\x56\xe9\x01\xe8\x3d\xd3\x39\xe5\xed\x24\x25\xac\x5e\xe8\xad\xa4\x34\x02\x4e\x8c\x2e\xe2\xc4\xde\xdc\x56\x37\x52\x31\x99\x2d\x0a\xea\x57\xa1\x6b\xd9\x4f\x0d\x56\x79\xba\xb2\x58\xe6\x4e\xaf\x15\xf4\x5f\x89\x72\x5e\xd1\xc9\xe5\xe0\xbb\x59\xf9\x76\x41\xfb\xe6\x97\x6f\x48\xc8\x4c\x92\xe2\xab\x1e\x61\x83\x8e\x1d\xed\x7a\x4c\x2e\x9b\x72\x23\xeb\xf3\xef\xbe\x3a\xcf\xa7\xb6\xec\xb3\x33\xe0\xf4\xef\x3c\x72\xce\xcc\xfe\xfc\xc5\xeb\x9f\xf9\x5f\xf4\xe0\xb9\x0b\x7c\xf4\x8e\xde\xef\x00\x00\x00\xff\xff\x7f\x01\xad\xcb\x14\x07\x00\x00" func privateforwarderSetup_and_create_forwarderCdcBytes() ([]byte, error) { return bindataRead( @@ -218,7 +218,7 @@ func privateforwarderSetup_and_create_forwarderCdc() (*asset, error) { } info := bindataFileInfo{name: "privateForwarder/setup_and_create_forwarder.cdc", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} - a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xf1, 0xfa, 0xc8, 0x45, 0xbf, 0xbb, 0xd, 0x63, 0xc4, 0xbc, 0x54, 0xae, 0x90, 0xd7, 0xe7, 0x22, 0x3c, 0x72, 0x49, 0x69, 0xd3, 0xf1, 0x22, 0x3e, 0x56, 0x89, 0x75, 0x34, 0xbb, 0xb6, 0x41, 0x27}} + a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xfa, 0xc1, 0x39, 0xfd, 0x4e, 0xe0, 0x85, 0xe5, 0xc5, 0xa1, 0x4f, 0x5e, 0xf3, 0x1e, 0x14, 0x40, 0xec, 0xea, 0xa9, 0x80, 0x89, 0xc, 0xd1, 0x6a, 0x6b, 0xb0, 0x77, 0x8d, 0x13, 0xbb, 0x27, 0xa1}} return a, nil } diff --git a/lib/go/test/forwarding_test.go b/lib/go/test/forwarding_test.go index 3ff0ad2b..3f8fed98 100644 --- a/lib/go/test/forwarding_test.go +++ b/lib/go/test/forwarding_test.go @@ -183,4 +183,39 @@ func TestPrivateForwarder(t *testing.T) { ) }) + + t.Run("Should be able to do account setup a second time without change", func(t *testing.T) { + + script := templates.GenerateSetupAccountPrivateForwarderScript( + fungibleAddr, + exampleTokenAddr, + exampleTokenAddr, + "ExampleToken", + ) + + // send the same transaction one more time for the same address that's already set up + tx := flow.NewTransaction(). + SetScript(script). + SetGasLimit(100). + SetProposalKey( + b.ServiceKey().Address, + b.ServiceKey().Index, + b.ServiceKey().SequenceNumber, + ). + SetPayer(b.ServiceKey().Address). + AddAuthorizer(joshAddress) + + signAndSubmit( + t, b, tx, + []flow.Address{ + b.ServiceKey().Address, + joshAddress, + }, + []crypto.Signer{ + b.ServiceKey().Signer(), + joshSigner, + }, + false, + ) + }) } diff --git a/transactions/privateForwarder/setup_and_create_forwarder.cdc b/transactions/privateForwarder/setup_and_create_forwarder.cdc index 517a805e..23f012a9 100644 --- a/transactions/privateForwarder/setup_and_create_forwarder.cdc +++ b/transactions/privateForwarder/setup_and_create_forwarder.cdc @@ -9,6 +9,10 @@ import PrivateReceiverForwarder from 0xPRIVATEFORWARDINGADDRESS transaction { prepare(signer: AuthAccount) { + if signer.getCapability<&PrivateReceiverForwarder.Forwarder>(PrivateReceiverForwarder.PrivateReceiverPublicPath).check() { + // private forwarder was already set up + return + } if signer.borrow<&ExampleToken.Vault>(from: /storage/exampleTokenVault) == nil { // Create a new ExampleToken Vault and put it in storage