feat: use new smart contracts sdk (#479)

This commit is contained in:
Dexter Edwards 2022-05-27 18:44:10 +01:00 committed by GitHub
parent da0536f8a8
commit 29e6cb5074
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
39 changed files with 63 additions and 67 deletions

View File

@ -8,10 +8,11 @@
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,
"noPropertyAccessFromIndexSignature": false,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"lib": ["es5", "es6", "dom", "dom.iterable"]
"lib": ["es5", "es6", "dom", "dom.iterable"],
"resolveJsonModule": true
},
"files": [],
"include": [],

View File

@ -1,4 +1,4 @@
import type { TxData } from '@vegaprotocol/smart-contracts-sdk';
import type { TxData } from '@vegaprotocol/smart-contracts';
import { Dialog, EtherscanLink } from '@vegaprotocol/ui-toolkit';
import React from 'react';
import { useTranslation } from 'react-i18next';

View File

@ -1,8 +1,8 @@
import type { EthereumChainId } from '@vegaprotocol/smart-contracts-sdk';
import type { EthereumChainId } from '@vegaprotocol/smart-contracts';
import {
EnvironmentConfig,
EthereumChainIds,
} from '@vegaprotocol/smart-contracts-sdk';
} from '@vegaprotocol/smart-contracts';
import type { Networks } from './vega';

View File

@ -1,4 +1,4 @@
import type { Tranche } from '@vegaprotocol/smart-contracts-sdk';
import type { Tranche } from '@vegaprotocol/smart-contracts';
import React from 'react';
import type { BigNumber } from '../../lib/bignumber';

View File

@ -5,7 +5,7 @@ import type {
VegaStaking,
ERC20Token,
VegaVesting,
} from '@vegaprotocol/smart-contracts-sdk';
} from '@vegaprotocol/smart-contracts';
import React from 'react';
export interface ContractsContextShape {

View File

@ -1,11 +1,11 @@
import type { TxData } from '@vegaprotocol/smart-contracts-sdk';
import type { TxData } from '@vegaprotocol/smart-contracts';
import {
VegaClaim,
VegaErc20Bridge,
VegaStaking,
ERC20Token,
VegaVesting,
} from '@vegaprotocol/smart-contracts-sdk';
} from '@vegaprotocol/smart-contracts';
import { Splash } from '@vegaprotocol/ui-toolkit';
import { useWeb3React } from '@web3-react/core';
import uniqBy from 'lodash/uniqBy';

View File

@ -1,6 +1,6 @@
import parseJSON from 'date-fns/parseJSON';
import { BigNumber } from '../../lib/bignumber';
import type { Tranche } from '@vegaprotocol/smart-contracts-sdk';
import type { Tranche } from '@vegaprotocol/smart-contracts';
const json: Tranche[] = [
{
@ -71,7 +71,7 @@ const json: Tranche[] = [
],
withdrawals: [],
total_tokens: new BigNumber('112323.67'),
withdrawn_tokens: '0',
withdrawn_tokens: new BigNumber('0'),
remaining_tokens: new BigNumber('112323.67'),
},
],
@ -254,7 +254,7 @@ const json: Tranche[] = [
],
withdrawals: [],
total_tokens: new BigNumber('44499.2'),
withdrawn_tokens: '0',
withdrawn_tokens: new BigNumber('0'),
remaining_tokens: new BigNumber('44499.2'),
},
{
@ -373,7 +373,7 @@ const json: Tranche[] = [
],
withdrawals: [],
total_tokens: new BigNumber('1104995.291'),
withdrawn_tokens: '0',
withdrawn_tokens: new BigNumber('0'),
remaining_tokens: new BigNumber('1104995.291'),
},
{

View File

@ -1,7 +1,7 @@
import React from 'react';
import { useContracts } from '../../contexts/contracts/contracts-context';
import mock from './tranches-mock';
import type { Tranche } from '@vegaprotocol/smart-contracts-sdk';
import type { Tranche } from '@vegaprotocol/smart-contracts';
export function useTranches() {
const { vesting } = useContracts();

View File

@ -1,9 +1,6 @@
import React from 'react';
import * as Sentry from '@sentry/react';
import type {
VegaStaking,
VegaVesting,
} from '@vegaprotocol/smart-contracts-sdk';
import type { VegaStaking, VegaVesting } from '@vegaprotocol/smart-contracts';
import {
AppStateActionType,

View File

@ -1,6 +1,6 @@
import React from 'react';
import * as Sentry from '@sentry/react';
import type { VegaVesting } from '@vegaprotocol/smart-contracts-sdk';
import type { VegaVesting } from '@vegaprotocol/smart-contracts';
import {
AppStateActionType,

View File

@ -1,5 +1,5 @@
import { useFetch } from '@vegaprotocol/react-helpers';
import type { Networks, Tranche } from '@vegaprotocol/smart-contracts-sdk';
import type { Networks, Tranche } from '@vegaprotocol/smart-contracts';
import React, { useEffect } from 'react';
import { APP_ENV } from '../config';

View File

@ -17,8 +17,14 @@
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="assets/manifest.json" />
<link
rel="preload"
href="https://static.vega.xyz/AlphaLyrae-Medium.woff2"
as="font"
type="font/woff2"
crossorigin="anonymous"
/>
<title>Vega Token dApp</title>
<link rel="stylesheet" href="https://static.vega.xyz/fonts.css" />
</head>
<body class="h-full">
<noscript>You need to enable JavaScript to run this app.</noscript>

View File

@ -1,4 +1,4 @@
import type { Tranche } from '@vegaprotocol/smart-contracts-sdk';
import type { Tranche } from '@vegaprotocol/smart-contracts';
import { BigNumber } from '../bignumber';

View File

@ -1,10 +1,10 @@
import * as Sentry from '@sentry/react';
import { UNSPENT_CODE } from '@vegaprotocol/smart-contracts-sdk';
import { UNSPENT_CODE } from '@vegaprotocol/smart-contracts';
import { format } from 'date-fns';
import React from 'react';
import { Trans, useTranslation } from 'react-i18next';
import { Link } from 'react-router-dom';
import type { Tranche } from '@vegaprotocol/smart-contracts-sdk';
import type { Tranche } from '@vegaprotocol/smart-contracts';
import { KeyValueTable, KeyValueTableRow } from '@vegaprotocol/ui-toolkit';
import { useContracts } from '../../contexts/contracts/contracts-context';

View File

@ -1,6 +1,6 @@
import { useTranslation } from 'react-i18next';
import { format } from 'date-fns';
import type { Tranche } from '@vegaprotocol/smart-contracts-sdk';
import type { Tranche } from '@vegaprotocol/smart-contracts';
import { DATE_FORMAT_LONG } from '../../lib/date-formats';

View File

@ -1,6 +1,6 @@
import { BigNumber } from '../../lib/bignumber';
import { addDecimal } from '../../lib/decimals';
import type { IClaimTokenParams } from '@vegaprotocol/smart-contracts-sdk';
import type { IClaimTokenParams } from '@vegaprotocol/smart-contracts';
export enum ClaimStatus {
Ready,

View File

@ -13,7 +13,7 @@ import {
initialClaimState,
} from './claim-reducer';
import type { Tranche } from '@vegaprotocol/smart-contracts-sdk';
import type { Tranche } from '@vegaprotocol/smart-contracts';
const Claim = ({
address,

View File

@ -1,6 +1,6 @@
import { useContracts } from '../../contexts/contracts/contracts-context';
import { useTransaction } from '../../hooks/use-transaction';
import type { IClaimTokenParams } from '@vegaprotocol/smart-contracts-sdk';
import type { IClaimTokenParams } from '@vegaprotocol/smart-contracts';
export const useClaim = (claimData: IClaimTokenParams, address: string) => {
const claimArgs = {

View File

@ -1,4 +1,4 @@
import type { IClaimTokenParams } from '@vegaprotocol/smart-contracts-sdk';
import type { IClaimTokenParams } from '@vegaprotocol/smart-contracts';
import { FormGroup } from '@vegaprotocol/ui-toolkit';
import React from 'react';
import { useTranslation } from 'react-i18next';

View File

@ -1,4 +1,4 @@
import type { IClaimTokenParams } from '@vegaprotocol/smart-contracts-sdk';
import type { IClaimTokenParams } from '@vegaprotocol/smart-contracts';
import { FormGroup } from '@vegaprotocol/ui-toolkit';
import { BigNumber } from '../../../lib/bignumber';
import React from 'react';

View File

@ -1,6 +1,6 @@
import { BigNumber } from '../../../lib/bignumber';
import { sumCirculatingTokens } from './token-details-circulating';
import type { Tranche } from '@vegaprotocol/smart-contracts-sdk';
import type { Tranche } from '@vegaprotocol/smart-contracts';
test('It sums some easy tranches correctly', () => {
const tranches: Partial<Tranche>[] = [

View File

@ -1,6 +1,6 @@
import { BigNumber } from '../../../lib/bignumber';
import { formatNumber } from '../../../lib/format-number';
import type { Tranche } from '@vegaprotocol/smart-contracts-sdk';
import type { Tranche } from '@vegaprotocol/smart-contracts';
/**
* Add together the circulating tokens from all tranches

View File

@ -1,4 +1,4 @@
import type { Tranche } from '@vegaprotocol/smart-contracts-sdk';
import type { Tranche } from '@vegaprotocol/smart-contracts';
import type { BigNumber } from '../../lib/bignumber';
export interface TrancheBalance {

View File

@ -1,4 +1,4 @@
import type { Tranche as ITranche } from '@vegaprotocol/smart-contracts-sdk';
import type { Tranche as ITranche } from '@vegaprotocol/smart-contracts';
import { useWeb3React } from '@web3-react/core';
import React from 'react';
import { useTranslation } from 'react-i18next';
@ -75,8 +75,10 @@ export const Tranche = () => {
{tranche.users.length ? (
<ul role="list">
{tranche.users.map((user, i) => {
const unlocked = user.remaining_tokens.times(lockedData?.unlocked);
const locked = user.remaining_tokens.times(lockedData?.locked);
const unlocked = user.remaining_tokens.times(
lockedData?.unlocked || 0
);
const locked = user.remaining_tokens.times(lockedData?.locked || 0);
return (
<li className="pb-4" key={i}>
<EtherscanLink address={user.address} text={user.address} />

View File

@ -1,5 +1,5 @@
import { useOutletContext } from 'react-router-dom';
import type { Tranche } from '@vegaprotocol/smart-contracts-sdk';
import type { Tranche } from '@vegaprotocol/smart-contracts';
import { useWeb3React } from '@web3-react/core';
import React from 'react';
import { useTranslation } from 'react-i18next';

View File

@ -8,7 +8,7 @@
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,
"noPropertyAccessFromIndexSignature": false,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"resolveJsonModule": true

View File

@ -1,4 +1,4 @@
import type { ERC20Token } from '@vegaprotocol/smart-contracts-sdk';
import type { ERC20Token } from '@vegaprotocol/smart-contracts';
import { useWeb3React } from '@web3-react/core';
import { useCallback } from 'react';
import { useEthereumReadContract } from '@vegaprotocol/web3';

View File

@ -1,5 +1,5 @@
import { useEthereumReadContract } from '@vegaprotocol/web3';
import type { ERC20Token } from '@vegaprotocol/smart-contracts-sdk';
import type { ERC20Token } from '@vegaprotocol/smart-contracts';
import { useWeb3React } from '@web3-react/core';
import { useCallback } from 'react';

View File

@ -1,6 +1,6 @@
import type BigNumber from 'bignumber.js';
import { useCallback } from 'react';
import type { VegaErc20Bridge } from '@vegaprotocol/smart-contracts-sdk';
import type { VegaErc20Bridge } from '@vegaprotocol/smart-contracts';
import type { Asset } from './deposit-manager';
import { useEthereumReadContract } from '@vegaprotocol/web3';

View File

@ -1,4 +1,4 @@
import type { ERC20Token } from '@vegaprotocol/smart-contracts-sdk';
import type { ERC20Token } from '@vegaprotocol/smart-contracts';
import { useEthereumTransaction } from '@vegaprotocol/web3';
export const useSubmitApproval = (

View File

@ -8,7 +8,7 @@ import { DepositStatus } from '@vegaprotocol/types';
import { useState } from 'react';
import { remove0x } from '@vegaprotocol/react-helpers';
import { useEthereumTransaction } from '@vegaprotocol/web3';
import type { VegaErc20Bridge } from '@vegaprotocol/smart-contracts-sdk';
import type { VegaErc20Bridge } from '@vegaprotocol/smart-contracts';
const DEPOSIT_EVENT_SUB = gql`
subscription DepositEvent($partyId: ID!) {

View File

@ -1,4 +1,4 @@
import type { ERC20Token } from '@vegaprotocol/smart-contracts-sdk';
import type { ERC20Token } from '@vegaprotocol/smart-contracts';
import { useEthereumTransaction } from '@vegaprotocol/web3';
export const useSubmitFaucet = (contract: ERC20Token | null) => {

View File

@ -0,0 +1,3 @@
{
"presets": ["@babel/preset-typescript"]
}

View File

@ -1,5 +1,5 @@
import type { Networks } from '@vegaprotocol/smart-contracts-sdk';
import { VegaErc20Bridge } from '@vegaprotocol/smart-contracts-sdk';
import type { Networks } from '@vegaprotocol/smart-contracts';
import { VegaErc20Bridge } from '@vegaprotocol/smart-contracts';
import { useWeb3React } from '@web3-react/core';
import { useMemo } from 'react';

View File

@ -1,4 +1,4 @@
import { ERC20Token } from '@vegaprotocol/smart-contracts-sdk';
import { ERC20Token } from '@vegaprotocol/smart-contracts';
import { useWeb3React } from '@web3-react/core';
import { useMemo } from 'react';

View File

@ -2,7 +2,8 @@ module.exports = {
displayName: 'withdraws',
preset: '../../jest.preset.js',
transform: {
'^.+\\.[tj]sx?$': 'babel-jest',
'^(?!.*\\.(js|jsx|ts|tsx|css|json)$)': '@nrwl/react/plugins/jest',
'^.+\\.[tj]sx?$': 'ts-jest',
},
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
coverageDirectory: '../../coverage/libs/withdraws',

View File

@ -3,14 +3,15 @@
"compilerOptions": {
"jsx": "react-jsx",
"allowJs": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,
"noPropertyAccessFromIndexSignature": false,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true
"noFallthroughCasesInSwitch": true,
"resolveJsonModule": true,
"esModuleInterop": true
},
"files": [],
"include": [],

View File

@ -27,7 +27,6 @@
"@sentry/nextjs": "^6.19.3",
"@sentry/react": "^6.19.2",
"@sentry/tracing": "^6.19.2",
"@vegaprotocol/smart-contracts-sdk": "^1.6.0",
"@vegaprotocol/vegawallet-service-api-client": "^0.4.11",
"@walletconnect/ethereum-provider": "^1.7.5",
"@web3-react/core": "8.0.20-beta.0",

View File

@ -6179,15 +6179,6 @@
"@typescript-eslint/types" "5.22.0"
eslint-visitor-keys "^3.0.0"
"@vegaprotocol/smart-contracts-sdk@^1.6.0":
version "1.6.0"
resolved "https://registry.yarnpkg.com/@vegaprotocol/smart-contracts-sdk/-/smart-contracts-sdk-1.6.0.tgz#c689d5928148113dddbe39ed963c74817f432d5e"
integrity sha512-cNFDywrtrvR3V5WQL5BadMS8pckRaetXyxA5ttLZEghlpkMcz5BQ51GuAfK0ufank8vY3xYN0m1DalbfADQIGw==
dependencies:
deprecated-decorator "^0.1.6"
ethers "^5.5.2"
lodash "^4.17.21"
"@vegaprotocol/vegawallet-service-api-client@^0.4.11":
version "0.4.11"
resolved "https://registry.yarnpkg.com/@vegaprotocol/vegawallet-service-api-client/-/vegawallet-service-api-client-0.4.11.tgz#41a623afc9957dcf8b5425f74280ba7861e92b74"
@ -10407,11 +10398,6 @@ depd@~1.1.2:
resolved "https://registry.yarnpkg.com/depd/-/depd-1.1.2.tgz#9bcd52e14c097763e749b274c4346ed2e560b5a9"
integrity sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=
deprecated-decorator@^0.1.6:
version "0.1.6"
resolved "https://registry.yarnpkg.com/deprecated-decorator/-/deprecated-decorator-0.1.6.tgz#00966317b7a12fe92f3cc831f7583af329b86c37"
integrity sha1-AJZjF7ehL+kvPMgx91g68ym4bDc=
deps-sort@^2.0.0, deps-sort@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/deps-sort/-/deps-sort-2.0.1.tgz#9dfdc876d2bcec3386b6829ac52162cda9fa208d"
@ -11478,7 +11464,7 @@ etag@1.8.1, etag@~1.8.1:
resolved "https://registry.yarnpkg.com/etag/-/etag-1.8.1.tgz#41ae2eeb65efa62268aebfea83ac7d79299b0887"
integrity sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=
ethers@^5.5.2, ethers@^5.6.0:
ethers@^5.6.0:
version "5.6.2"
resolved "https://registry.yarnpkg.com/ethers/-/ethers-5.6.2.tgz#e75bac7f038c5e0fdde667dba62fc223924143a2"
integrity sha512-EzGCbns24/Yluu7+ToWnMca3SXJ1Jk1BvWB7CCmVNxyOeM4LLvw2OLuIHhlkhQk1dtOcj9UMsdkxUh8RiG1dxQ==