diff --git a/package-lock.json b/package-lock.json index 21b5cc4..9fa9e01 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6319,9 +6319,9 @@ } }, "node_modules/@topos-protocol/topos-smart-contracts": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@topos-protocol/topos-smart-contracts/-/topos-smart-contracts-2.0.0.tgz", - "integrity": "sha512-9ElAqlPg7puWCH0F58l7TgnXheybzkmyNr2ssla/olwKRxcfKJl10k3U5CN03KaTkbkZY+Jhp5JW7BLL+8xhNA==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@topos-protocol/topos-smart-contracts/-/topos-smart-contracts-3.0.0.tgz", + "integrity": "sha512-ABDny/flDSRzfZntdxeV3ZZWBO1s7amI1+3pxHYBdQ4EhvD5FJzlv8Go1QYbYrUf2q+vW1p+soY7+T9KDFE1QA==", "dependencies": { "@openzeppelin/contracts": "^4.8.3", "ethers": "^5.7.2", @@ -21649,7 +21649,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", "@types/event-source-polyfill": "^1.0.1", "antd": "^5.4.0", "axios": "^1.0.0", @@ -26148,9 +26148,9 @@ "dev": true }, "@topos-protocol/topos-smart-contracts": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@topos-protocol/topos-smart-contracts/-/topos-smart-contracts-2.0.0.tgz", - "integrity": "sha512-9ElAqlPg7puWCH0F58l7TgnXheybzkmyNr2ssla/olwKRxcfKJl10k3U5CN03KaTkbkZY+Jhp5JW7BLL+8xhNA==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@topos-protocol/topos-smart-contracts/-/topos-smart-contracts-3.0.0.tgz", + "integrity": "sha512-ABDny/flDSRzfZntdxeV3ZZWBO1s7amI1+3pxHYBdQ4EhvD5FJzlv8Go1QYbYrUf2q+vW1p+soY7+T9KDFE1QA==", "requires": { "@openzeppelin/contracts": "^4.8.3", "ethers": "^5.7.2", @@ -31094,7 +31094,7 @@ "@testing-library/jest-dom": "^5.16.5", "@testing-library/react": "14.0.0", "@testing-library/user-event": "^14.4.3", - "@topos-protocol/topos-smart-contracts": "^2.0.0", + "@topos-protocol/topos-smart-contracts": "^3.0.0", "@types/event-source-polyfill": "^1.0.1", "@types/react": "^18.0.28", "@types/react-dom": "^18.0.11", diff --git a/packages/frontend/package.json b/packages/frontend/package.json index 70b5847..f06d36a 100644 --- a/packages/frontend/package.json +++ b/packages/frontend/package.json @@ -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", "@types/event-source-polyfill": "^1.0.1", "antd": "^5.4.0", "axios": "^1.0.0", diff --git a/packages/frontend/src/components/steps/Step2.tsx b/packages/frontend/src/components/steps/Step2.tsx index 73f82e0..3a5182a 100644 --- a/packages/frontend/src/components/steps/Step2.tsx +++ b/packages/frontend/src/components/steps/Step2.tsx @@ -229,7 +229,7 @@ const Step2 = ({ onFinish }: StepProps) => { return sendToken( receivingSubnet?.id, - token?.addr, + token?.symbol, recipientAddress, parsedAmount ) diff --git a/packages/frontend/src/hooks/useCheckTokenOnReceivingSubnet.test.ts b/packages/frontend/src/hooks/useCheckTokenOnReceivingSubnet.test.ts index cf5b378..ca8d837 100644 --- a/packages/frontend/src/hooks/useCheckTokenOnReceivingSubnet.test.ts +++ b/packages/frontend/src/hooks/useCheckTokenOnReceivingSubnet.test.ts @@ -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 = { @@ -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) }) }) }) diff --git a/packages/frontend/src/hooks/useCheckTokenOnReceivingSubnet.ts b/packages/frontend/src/hooks/useCheckTokenOnReceivingSubnet.ts index 48a1dd8..00167f5 100644 --- a/packages/frontend/src/hooks/useCheckTokenOnReceivingSubnet.ts +++ b/packages/frontend/src/hooks/useCheckTokenOnReceivingSubnet.ts @@ -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) }) diff --git a/packages/frontend/src/hooks/useSendToken.test.ts b/packages/frontend/src/hooks/useSendToken.test.ts index 81ec757..3ad176f 100644 --- a/packages/frontend/src/hooks/useSendToken.test.ts +++ b/packages/frontend/src/hooks/useSendToken.test.ts @@ -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 } diff --git a/packages/frontend/src/hooks/useSendToken.ts b/packages/frontend/src/hooks/useSendToken.ts index bf45085..91da202 100644 --- a/packages/frontend/src/hooks/useSendToken.ts +++ b/packages/frontend/src/hooks/useSendToken.ts @@ -23,7 +23,7 @@ export default function useSendToken() { const sendToken = useCallback( ( receivingSubnetId: string, - tokenAddress: string, + tokenSymbol: string, recipientAddress: string, amount: BigNumber ) => @@ -31,15 +31,9 @@ export default function useSendToken() { 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) => {