Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update code to fit unique token symbol #36

Merged
merged 2 commits into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"@opentelemetry/exporter-trace-otlp-proto": "^0.45.0",
"@opentelemetry/sdk-metrics": "^1.17.1",
"@opentelemetry/sdk-trace-web": "^1.17.1",
"@topos-protocol/topos-smart-contracts": "^2.0.0",
"@topos-protocol/topos-smart-contracts": "^3.0.0-rc1",
"@types/event-source-polyfill": "^1.0.1",
"antd": "^5.4.0",
"axios": "^1.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/src/components/steps/Step2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ const Step2 = ({ onFinish }: StepProps) => {

return sendToken(
receivingSubnet?.id,
token?.addr,
token?.symbol,
recipientAddress,
parsedAmount
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ const providerSpy = vi
.spyOn(ethers.providers, 'WebSocketProvider')
.mockReturnValue({ getCode: getCodeMock } as any)

const getTokenByAddressMock = vi.fn().mockResolvedValue(tokenMock)
const getTokenBySymbolMock = vi.fn().mockResolvedValue(tokenMock)

const contractConnectMock = vi.fn().mockReturnValue({
getTokenByAddress: getTokenByAddressMock,
getTokenBySymbol: getTokenBySymbolMock,
})

const contractMock = {
Expand All @@ -65,7 +65,7 @@ describe('useCheckTokenOnReceivingSubnet', () => {
expect(contractSpy).toHaveBeenCalled()
expect(getCodeMock).toHaveBeenCalledWith(contractMock.address)
expect(contractConnectMock).toHaveBeenCalled()
expect(getTokenByAddressMock).toHaveBeenCalledWith(tokenMock.addr)
expect(getTokenBySymbolMock).toHaveBeenCalledWith(tokenMock.symbol)
})
})
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default function useCheckTokenOnSubnet() {
const contract = erc20MessagingContract.connect(subnetProvider)

const onChainToken = await contract
.getTokenByAddress(token.addr)
.getTokenBySymbol(token.symbol)
.finally(() => {
setLoading(false)
})
Expand Down
6 changes: 3 additions & 3 deletions packages/frontend/src/hooks/useSendToken.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,18 @@ describe('sendToken', () => {
const { result } = renderHook(() => useSendToken())

const receivingSubnetId = 'receiving'
const tokenAddress = 'tokenAddr'
const tokenSymbol = 'tokenSymbol'
const recipientAddress = 'receivingAddr'
const amount = BigNumber.from(1)

await act(() => {
result.current
.sendToken(receivingSubnetId, tokenAddress, recipientAddress, amount)
.sendToken(receivingSubnetId, tokenSymbol, recipientAddress, amount)
.then(() => {
expect(result.current.loading).toBe(true)
expect(sendTokenMock).toHaveBeenCalledWith(
receivingSubnetId,
tokenAddress,
tokenSymbol,
recipientAddress,
amount,
{ gasLimit: 4_000_000 }
Expand Down
14 changes: 4 additions & 10 deletions packages/frontend/src/hooks/useSendToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,17 @@ export default function useSendToken() {
const sendToken = useCallback(
(
receivingSubnetId: string,
tokenAddress: string,
tokenSymbol: string,
recipientAddress: string,
amount: BigNumber
) =>
new Promise<SendTokenOutput>((resolve, reject) => {
setLoading(true)

contract
.sendToken(
receivingSubnetId,
tokenAddress,
recipientAddress,
amount,
{
gasLimit: 4_000_000,
}
)
.sendToken(receivingSubnetId, tokenSymbol, recipientAddress, amount, {
gasLimit: 4_000_000,
})
.then((tx: ContractTransaction) => {
tx.wait()
.then((receipt) => {
Expand Down
Loading