diff --git a/graphql/graphql_test.go b/graphql/graphql_test.go index 4f9002700..1c2f36328 100644 --- a/graphql/graphql_test.go +++ b/graphql/graphql_test.go @@ -135,7 +135,7 @@ func testUserByAddress(t *testing.T) { userF := newUserFixture(t) c := authedHandlerClient(t, userF.ID) - response, err := userByAddressQuery(context.Background(), c, chainAddressInput(userF.Wallet.Address)) + response, err := userByAddressQuery(context.Background(), c, chainAddressInput(userF.Wallet.Address.String())) require.NoError(t, err) payload, _ := (*response.UserByAddress).(*userByAddressQueryUserByAddressGalleryUser) @@ -200,12 +200,12 @@ func testAddWallet(t *testing.T) { c := authedHandlerClient(t, userF.ID) nonce := newNonce(t, ctx, c, walletToAdd) - response, err := addUserWalletMutation(ctx, c, chainAddressInput(walletToAdd.Address), authMechanismInput(walletToAdd, nonce)) + response, err := addUserWalletMutation(ctx, c, chainAddressInput(walletToAdd.Address.String()), authMechanismInput(walletToAdd, nonce)) require.NoError(t, err) payload, _ := (*response.AddUserWallet).(*addUserWalletMutationAddUserWalletAddUserWalletPayload) wallets := payload.Viewer.User.Wallets - assert.Equal(t, walletToAdd.Address, *wallets[len(wallets)-1].ChainAddress.Address) + assert.Equal(t, walletToAdd.Address.String(), *wallets[len(wallets)-1].ChainAddress.Address) assert.Equal(t, Chain("Ethereum"), *wallets[len(wallets)-1].ChainAddress.Chain) assert.Len(t, wallets, 2) } @@ -216,7 +216,7 @@ func testRemoveWallet(t *testing.T) { ctx := context.Background() c := authedHandlerClient(t, userF.ID) nonce := newNonce(t, ctx, c, walletToRemove) - addResponse, err := addUserWalletMutation(ctx, c, chainAddressInput(walletToRemove.Address), authMechanismInput(walletToRemove, nonce)) + addResponse, err := addUserWalletMutation(ctx, c, chainAddressInput(walletToRemove.Address.String()), authMechanismInput(walletToRemove, nonce)) require.NoError(t, err) wallets := (*addResponse.AddUserWallet).(*addUserWalletMutationAddUserWalletAddUserWalletPayload).Viewer.User.Wallets lastWallet := wallets[len(wallets)-1] @@ -975,7 +975,7 @@ func testSyncShouldMergeDuplicatesAcrossProviders(t *testing.T) { } // newDummyMetadataProviderFixture creates a new handler configured with a stubbed provider that reads from a fixed dummy metadata server endpoint -func newDummyMetadataProviderFixture(t *testing.T, ctx context.Context, ownerAddress, dummyEndpointToHit string, opts ...providerOpt) http.Handler { +func newDummyMetadataProviderFixture(t *testing.T, ctx context.Context, ownerAddress persist.Address, dummyEndpointToHit string, opts ...providerOpt) http.Handler { metadataServerF := newMetadataServerFixture(t) metadataFetchF := fetchFromDummyEndpoint(metadataServerF.URL, dummyEndpointToHit) pOpts := append([]providerOpt{withFetchMetadata(metadataFetchF)}, opts...) @@ -1284,7 +1284,7 @@ func authMechanismInput(w wallet, nonce string) AuthMechanism { Nonce: nonce, Signature: w.Sign(nonce), ChainPubKey: ChainPubKeyInput{ - PubKey: w.Address, + PubKey: w.Address.String(), Chain: "Ethereum", }, }, @@ -1298,7 +1298,7 @@ func chainAddressInput(address string) ChainAddressInput { type wallet struct { PKey *ecdsa.PrivateKey PubKey *ecdsa.PublicKey - Address string + Address persist.Address } func (w *wallet) Sign(msg string) string { @@ -1321,13 +1321,13 @@ func newWallet(t *testing.T) wallet { return wallet{ PKey: pk, PubKey: pubKey, - Address: address, + Address: persist.Address(address), } } func newNonce(t *testing.T, ctx context.Context, c genql.Client, w wallet) string { t.Helper() - response, err := getAuthNonceMutation(ctx, c, chainAddressInput(w.Address)) + response, err := getAuthNonceMutation(ctx, c, chainAddressInput(w.Address.String())) require.NoError(t, err) payload := (*response.GetAuthNonce).(*getAuthNonceMutationGetAuthNonce) return *payload.Nonce @@ -1522,22 +1522,22 @@ func defaultLayout() CollectionLayoutInput { } // dummyToken returns a dummy token owned by the provided address -func dummyToken(ownerAddress string) multichain.ChainAgnosticToken { +func dummyToken(ownerAddress persist.Address) multichain.ChainAgnosticToken { return dummyTokenContract(ownerAddress, "0x123") } // dummyTokenContract returns a dummy token owned by the provided address from the provided contract -func dummyTokenContract(ownerAddress, contractAddress string) multichain.ChainAgnosticToken { +func dummyTokenContract(ownerAddress, contractAddress persist.Address) multichain.ChainAgnosticToken { return dummyTokenIDContract(ownerAddress, contractAddress, "1") } // dummyTokenIDContract returns a dummy token owned by the provided address from the provided contract with the given tokenID -func dummyTokenIDContract(ownerAddress, contractAddress string, tokenID persist.TokenID) multichain.ChainAgnosticToken { +func dummyTokenIDContract(ownerAddress, contractAddress persist.Address, tokenID persist.TokenID) multichain.ChainAgnosticToken { return multichain.ChainAgnosticToken{ - TokenID: persist.TokenID(tokenID), + TokenID: tokenID, Quantity: "1", - ContractAddress: persist.Address(contractAddress), - OwnerAddress: persist.Address(ownerAddress), + ContractAddress: contractAddress, + OwnerAddress: ownerAddress, } } diff --git a/graphql/stub_test.go b/graphql/stub_test.go index 74278418d..a042cd658 100644 --- a/graphql/stub_test.go +++ b/graphql/stub_test.go @@ -100,12 +100,12 @@ func withTokens(tokens []multichain.ChainAgnosticToken) providerOpt { } // withDummyTokenN will generate n dummy tokens from the provided contract -func withDummyTokenN(contract multichain.ChainAgnosticContract, ownerAddress string, n int) providerOpt { +func withDummyTokenN(contract multichain.ChainAgnosticContract, ownerAddress persist.Address, n int) providerOpt { return func(p *stubProvider) { tokens := []multichain.ChainAgnosticToken{} for i := 0; i < n; i++ { tokenID := persist.TokenID(fmt.Sprintf("%X", i)) - token := dummyTokenIDContract(ownerAddress, contract.Address.String(), tokenID) + token := dummyTokenIDContract(ownerAddress, contract.Address, tokenID) tokens = append(tokens, token) } withContracts([]multichain.ChainAgnosticContract{contract})(p) @@ -114,12 +114,11 @@ func withDummyTokenN(contract multichain.ChainAgnosticContract, ownerAddress str } // withDummyTokenID will generate a token with the provided token ID -func withDummyTokenID(ownerAddress string, tokenID persist.TokenID) providerOpt { - contractAddress := "0x123" - c := multichain.ChainAgnosticContract{Address: persist.Address(contractAddress)} +func withDummyTokenID(ownerAddress persist.Address, tokenID persist.TokenID) providerOpt { + c := multichain.ChainAgnosticContract{Address: "0x123"} return func(p *stubProvider) { withContracts([]multichain.ChainAgnosticContract{c})(p) - withTokens([]multichain.ChainAgnosticToken{dummyTokenIDContract(ownerAddress, contractAddress, tokenID)})(p) + withTokens([]multichain.ChainAgnosticToken{dummyTokenIDContract(ownerAddress, c.Address, tokenID)})(p) } } @@ -131,9 +130,9 @@ func withFetchMetadata(f func() (persist.TokenMetadata, error)) providerOpt { } // defaultStubProvider returns a stubProvider that returns dummy tokens -func defaultStubProvider(address string) stubProvider { +func defaultStubProvider(ownerAddress persist.Address) stubProvider { contract := multichain.ChainAgnosticContract{Address: "0x123", Descriptors: multichain.ChainAgnosticContractDescriptors{Name: "testContract"}} - return newStubProvider(withDummyTokenN(contract, address, 10)) + return newStubProvider(withDummyTokenN(contract, ownerAddress, 10)) } // newStubRecommender returns a recommender that returns a canned set of recommendations