Skip to content

Commit

Permalink
feat: remove all wert logic since its wrapped in dcl dapps now
Browse files Browse the repository at this point in the history
  • Loading branch information
juanmahidalgo committed Jan 22, 2024
1 parent 2c02020 commit 76a05dd
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 52 deletions.
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
import { ethers } from 'ethers'
import WertWidget from '@wert-io/widget-initializer'
import { getSigner } from 'decentraland-dapps/dist/lib/eth'
import { AuthIdentity } from 'decentraland-crypto-fetch'
import { fireEvent, waitFor } from '@testing-library/react'
import { Wallet } from 'decentraland-dapps/dist/modules/wallet/types'
import { t } from 'decentraland-dapps/dist/modules/translation/utils'
import { DCLController__factory } from '../../../contracts/factories/DCLController__factory'
import { renderWithProviders } from '../../../utils/test'
import { marketplaceAPI } from '../../../modules/vendor/decentraland/marketplace/api'
import ClaimNameFatFingerModal, {
CRYPTO_PAYMENT_METHOD_DATA_TESTID
} from './ClaimNameFatFingerModal'

jest.mock('../../../modules/vendor/decentraland/marketplace/api')

jest.mock('../../../contracts/factories/DCLController__factory')
jest.mock('decentraland-dapps/dist/lib/eth', () => ({
...jest.requireActual('decentraland-dapps/dist/lib/eth'),
getSigner: jest.fn()
}))
jest.mock('@wert-io/widget-initializer')

const getSignerMock = getSigner as jest.MockedFunction<typeof getSigner>
const signerMock = {
Expand Down Expand Up @@ -49,6 +45,7 @@ describe('ClaimNameFatFingerModal', () => {
onClaimNameClear: onClaimNameClearMock,
onAuthorizedAction: onAuthorizedActionMock,
onCloseAuthorization: jest.fn(),
onOpenFiatGateway: jest.fn(),
wallet: {} as Wallet,
isLoadingAuthorization: false
}
Expand Down Expand Up @@ -119,15 +116,8 @@ describe('ClaimNameFatFingerModal', () => {
})
})
describe('and does not have enough MANA balance to pay', () => {
let widgetOpenFnMock: jest.Mock
let identity: AuthIdentity
beforeEach(() => {
widgetOpenFnMock = jest.fn()
currentMana = 0
;(WertWidget as jest.Mock).mockImplementation(() => ({
open: widgetOpenFnMock
}))
identity = {} as AuthIdentity
getSignerMock.mockResolvedValueOnce(
(signerMock as unknown) as ethers.providers.JsonRpcSigner
)
Expand All @@ -136,13 +126,11 @@ describe('ClaimNameFatFingerModal', () => {
encodeFunctionData: jest.fn()
}
})
;(marketplaceAPI.signWertMessage as jest.Mock).mockResolvedValueOnce({})
})
it('should have MANA option disabled and open FIAT provider widget when claim button is clicked', async () => {
it('should have MANA option disabled and open FIAT gateway widget when claim button is clicked', async () => {
const { getByRole, getByText, getByTestId } = renderWithProviders(
<ClaimNameFatFingerModal
{...baseProps}
identity={identity}
currentMana={currentMana}
getContract={jest.fn().mockResolvedValue({
address: '0x0' // mana contract mock
Expand All @@ -169,7 +157,7 @@ describe('ClaimNameFatFingerModal', () => {
expect(onClaimMock).not.toHaveBeenCalledWith(name)

await waitFor(() => {
expect(widgetOpenFnMock).toHaveBeenCalled()
expect(baseProps.onOpenFiatGateway).toHaveBeenCalled()
})
})
})
Expand Down
29 changes: 1 addition & 28 deletions webapp/src/modules/vendor/decentraland/marketplace/api.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { ChainId } from '@dcl/schemas'
import { BaseAPI } from 'decentraland-dapps/dist/lib/api'
import signedFetch, { AuthIdentity } from 'decentraland-crypto-fetch'
import { Balance, WertMessage } from './types'
import { Balance } from './types'
import { config } from '../../../../config'
import { retryParams } from '../utils'

Expand All @@ -24,32 +23,6 @@ export class MarketplaceAPI extends BaseAPI {
)
return balances
}

signWertMessage = async (
message: WertMessage,
identity: AuthIdentity
): Promise<string> => {
const url = MARKETPLACE_SERVER_URL + '/wert/sign'
const response = await signedFetch(url, {
method: 'POST',
identity,
body: JSON.stringify(message),
headers: {
'Content-Type': 'application/json'
}
})
try {
const json = await response.json()
if (json.ok) {
return json.data
} else {
throw new Error(json.message)
}
} catch (error) {
console.log('error: ', error)
throw new Error((error as Error).message)
}
}
}

export const marketplaceAPI = new MarketplaceAPI(
Expand Down
9 changes: 0 additions & 9 deletions webapp/src/modules/vendor/decentraland/marketplace/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,3 @@ export type Balance = Omit<BalanceItem, 'balance' | 'balance_24h'> & {
balance: string | null
balance_24h: string | null
}

export type WertMessage = {
address: string
commodity: string
commodity_amount: number
network: string
sc_address: string
sc_input_data: string
}

0 comments on commit 76a05dd

Please sign in to comment.