Skip to content

Commit

Permalink
change address arguments to strings
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuahannan committed Feb 14, 2024
1 parent 48f42d9 commit 1bf01d6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 17 deletions.
12 changes: 6 additions & 6 deletions lib/go/contracts/contracts.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ const (
)

// NonFungibleToken returns the NonFungibleToken contract interface.
func NonFungibleToken(resolverAddress flow.Address) []byte {
func NonFungibleToken(resolverAddress string) []byte {
code := assets.MustAssetString(filenameNonFungibleToken)
code = placeholderResolver.ReplaceAllString(code, "0x"+resolverAddress.String())
code = placeholderResolver.ReplaceAllString(code, "0x"+resolverAddress)
return []byte(code)
}

Expand All @@ -52,12 +52,12 @@ func ExampleNFT(nftAddress, metadataAddress, resolverAddress flow.Address) []byt
return []byte(code)
}

func MetadataViews(ftAddress, nftAddress, resolverAddress flow.Address) []byte {
func MetadataViews(ftAddress, nftAddress, resolverAddress string) []byte {
code := assets.MustAssetString(filenameMetadataViews)

code = placeholderFungibleToken.ReplaceAllString(code, "0x"+ftAddress.String())
code = placeholderNonFungibleToken.ReplaceAllString(code, "0x"+nftAddress.String())
code = placeholderResolver.ReplaceAllString(code, "0x"+resolverAddress.String())
code = placeholderFungibleToken.ReplaceAllString(code, "0x"+ftAddress)
code = placeholderNonFungibleToken.ReplaceAllString(code, "0x"+nftAddress)
code = placeholderResolver.ReplaceAllString(code, "0x"+resolverAddress)

return []byte(code)
}
Expand Down
12 changes: 3 additions & 9 deletions lib/go/contracts/contracts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@ import (
"github.com/onflow/flow-nft/lib/go/contracts"
)

const addrA = "0x0A"
const addrA = "0A"

func TestNonFungibleTokenContract(t *testing.T) {
addresses := test.AddressGenerator()
addressA := addresses.New()
contract := contracts.NonFungibleToken(addressA)
contract := contracts.NonFungibleToken(addrA)
assert.NotNil(t, contract)
}

Expand All @@ -34,10 +32,6 @@ func TestExampleNFTContract(t *testing.T) {
}

func TestMetadataViewsContract(t *testing.T) {
addresses := test.AddressGenerator()
addressA := addresses.New()
addressB := addresses.New()
addressC := addresses.New()
contract := contracts.MetadataViews(addressA, addressB, addressC)
contract := contracts.MetadataViews(addrA, addrA, addrA)
assert.NotNil(t, contract)
}
4 changes: 2 additions & 2 deletions lib/go/test/nft_test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func deployNFTContracts(
nftAddress, err := adapter.CreateAccount(context.Background(), []*flow.AccountKey{nftAccountKey}, []sdktemplates.Contract{
{
Name: "NonFungibleToken",
Source: string(contracts.NonFungibleToken(resolverAddress)),
Source: string(contracts.NonFungibleToken(resolverAddress.String())),
},
})
if !assert.NoError(t, err) {
Expand All @@ -80,7 +80,7 @@ func deployNFTContracts(
_, err = b.CommitBlock()
assert.NoError(t, err)

metadataAddress := deploy(t, b, adapter, "MetadataViews", contracts.MetadataViews(flow.HexToAddress(emulatorFTAddress), nftAddress, resolverAddress), nftAccountKey)
metadataAddress := deploy(t, b, adapter, "MetadataViews", contracts.MetadataViews(emulatorFTAddress, nftAddress.String(), resolverAddress.String()), nftAccountKey)

exampleNFTAddress := deploy(
t, b, adapter,
Expand Down

0 comments on commit 1bf01d6

Please sign in to comment.