Skip to content
This repository has been archived by the owner on Oct 31, 2024. It is now read-only.

Commit

Permalink
feat: update code to fit unique token symbol
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastiendan committed Nov 22, 2023
1 parent 2da7342 commit 26c6fc1
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 27 deletions.
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

0 comments on commit 26c6fc1

Please sign in to comment.