Skip to content

Commit

Permalink
Merge pull request #122 from Agoric/main
Browse files Browse the repository at this point in the history
Deploy main to production
  • Loading branch information
samsiegart authored Aug 31, 2023
2 parents 456fb00 + a1233fe commit e784bc7
Show file tree
Hide file tree
Showing 18 changed files with 271 additions and 227 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ typings/
bundle-*.js
/.vagrant
.DS_Store
.vscode/
.idea/

/packages.png
Expand Down
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
"start": "web-dev-server --port=3000 packages/wallet/public/",
"preview": "web-dev-server --port=3001 build/",
"test": "yarn workspaces run test",
"pretty-fix": "prettier --write '**/*.{js,html}'",
"pretty-check": "prettier --check '**/*.{js,html}'",
"format": "prettier --write '**/*.{js,html}'",
"lint:format": "prettier --check '**/*.{js,html}'",
"lint-fix": "yarn lint:eslint --fix && yarn lint:types",
"lint-check": "yarn lint",
"lint:check": "yarn lint",
"lint": "yarn lint:types && yarn lint:eslint",
"lint:types": "tsc -p jsconfig.json",
"lint:eslint": "eslint '**/*.js'"
Expand Down Expand Up @@ -52,7 +52,7 @@
"eslint-plugin-jsdoc": "^30.7.0",
"eslint-plugin-jsx-a11y": "^6.4.0",
"eslint-plugin-prettier": "^3.2.0",
"prettier": "^1.18.2",
"prettier": "3.0.0",
"rollup-plugin-minify-html-literals": "^1.2.6",
"rollup-plugin-multi-input": "^1.3.1",
"rollup-plugin-summary": "^1.3.0",
Expand Down
19 changes: 10 additions & 9 deletions wallet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
"@agoric/smart-wallet": "^0.5.4-dev-6bce049.0",
"@agoric/ui-components": "^0.3.9-dev-2c6fbc5.0",
"@agoric/web-components": "^0.6.4-dev-2c6fbc5.0",
"@cosmjs/crypto": "0.29.3",
"@cosmjs/encoding": "0.29.3",
"@cosmjs/proto-signing": "0.29.3",
"@cosmjs/stargate": "0.29.3",
"@cosmjs/tendermint-rpc": "0.29.3",
"@cosmjs/crypto": "^0.31.1",
"@cosmjs/encoding": "^0.31.1",
"@cosmjs/proto-signing": "^0.31.1",
"@cosmjs/stargate": "^0.31.1",
"@cosmjs/tendermint-rpc": "^0.31.1",
"@emotion/react": "^11.5.0",
"@emotion/styled": "^11.3.0",
"@endo/captp": "^3.1.1",
Expand All @@ -45,7 +45,7 @@
},
"devDependencies": {
"@agoric/vats": "^0.15.2-dev-6bce049.0",
"@keplr-wallet/types": "^0.11.7",
"@keplr-wallet/types": "^0.12.22",
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10",
Expand All @@ -64,7 +64,7 @@
"eslint-plugin-react-hooks": "^4.6.0",
"npm-run-all": "^4.1.5",
"patch-package": "^6.5.0",
"prettier": "^2.7.1",
"prettier": "3.0.0",
"process": "^0.11.10",
"react-app-rewire-multiple-entry": "^2.2.3",
"react-app-rewired": "^2.2.1",
Expand All @@ -83,9 +83,10 @@
"build": "yarn build:ses && yarn build:react",
"build:ses": "cp node_modules/ses/dist/lockdown.umd.js public/",
"build:react": "react-app-rewired build",
"format": "yarn prettier --write .",
"lint:format": "yarn prettier --check '**/*.{js,jsx,ts,tsx}'",
"format": "yarn prettier --write '**/*.{js,jsx,ts,tsx}'",
"lint": "run-s --continue-on-error lint:*",
"lint:eslint": "eslint '**/*.{js,jsx}'",
"lint:eslint": "eslint '**/*.{js,jsx,ts,tsx}'",
"lint:types": "yarn tsc",
"lint-fix": "yarn lint:eslint --fix",
"postinstall": "patch-package",
Expand Down
15 changes: 15 additions & 0 deletions wallet/public/tokens/statom.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions wallet/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ import Issuers from './views/Issuers';

import './App.scss';

window.addEventListener('keplr_keystorechange', () => {
console.log('Key store in Keplr has changed.');
window.location.reload();
});

const useStyles = makeStyles(theme => ({
main: {
boxSizing: 'border-box',
Expand Down Expand Up @@ -36,6 +41,7 @@ const useStyles = makeStyles(theme => ({

const App = () => {
const classes = useStyles(useTheme());

return (
<span className="App">
<span className={classes.navMenu}>
Expand Down
2 changes: 1 addition & 1 deletion wallet/src/components/ConnectionSettingsDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ const ConnectionSettingsDialog = ({
break;
case 'localhost':
setConfig({
href: `http://localhost:3000/wallet/network-config`,
href: `${window.location.origin}/wallet/network-config`,
});
break;
case 'custom':
Expand Down
74 changes: 74 additions & 0 deletions wallet/src/components/tests/ConnectionSettingsDialog.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import { mount } from 'enzyme';
import ConnectionSettingsDialog from '../ConnectionSettingsDialog';
import {
DEFAULT_CONNECTION_CONFIGS,
KnownNetworkConfigUrls,
} from '../../util/connections';
import { Select, TextField, ThemeProvider, createTheme } from '@mui/material';
import { act } from '@testing-library/react';

jest.mock('lodash-es/isEqual', () => () => true);

const appTheme = createTheme({
palette: {
// @ts-expect-error not in Palette
cancel: {
main: '#595959',
},
},
});

const MOCK_LOCALHOST = 'http://foobar:440';

const withApplicationContext =
(Component, _) =>
({ ...props }) => {
return (
<ThemeProvider theme={appTheme}>
<Component {...props} />
</ThemeProvider>
);
};

jest.mock('../../contexts/Application', () => {
return { withApplicationContext };
});

describe('Connection setting dialog', () => {
const { location } = window;

beforeAll(() => {
// @ts-expect-error mocking window.location
delete window.location;

// @ts-expect-error mocking window.location
window.location = { origin: MOCK_LOCALHOST };
});

afterAll(() => {
window.location = location;
});

test('displays the dapp', () => {
const component = mount(
<ConnectionSettingsDialog
allConnectionConfigs={DEFAULT_CONNECTION_CONFIGS}
connectionConfig={{ href: KnownNetworkConfigUrls.main }}
open
/>,
);

const networkSelect = component.find(Select).first();
act(() =>
networkSelect.props().onChange({ target: { value: 'localhost' } }),
);
component.update();

const textField = component.find(TextField).first();
const inputField = textField.find('input').first();

expect(inputField.prop('value')).toEqual(
`${MOCK_LOCALHOST}/wallet/network-config`,
);
});
});
8 changes: 0 additions & 8 deletions wallet/src/lockdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,6 @@ const consoleTaming = '%NODE_ENV%' === 'development' ? 'unsafe' : 'safe';
// eslint-disable-next-line no-constant-condition
const errorTaming = '%NODE_ENV%' === 'development' ? 'unsafe' : 'safe';

// eslint-disable-next-line no-restricted-properties
const { pow: mathPow } = Math;
// eslint-disable-next-line no-restricted-properties
Math.pow = (base, exp) =>
typeof base === 'bigint' && typeof exp === 'bigint'
? base ** exp
: mathPow(base, exp);

lockdown({
errorTaming,
overrideTaming: 'severe',
Expand Down
5 changes: 2 additions & 3 deletions wallet/src/service/Offers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,8 @@ export const getOfferService = (
const unserializedAmount = await E(boardIdMarshaller).unserialize(
entry.amount,
);
entry.pursePetname = brandToPurse.get(
unserializedAmount.brand,
)?.pursePetname;
entry.pursePetname = brandToPurse.get(unserializedAmount.brand)
?.pursePetname;
entry.value = String(unserializedAmount.value);
}
return [kw, entry];
Expand Down
1 change: 1 addition & 0 deletions wallet/src/setupTests.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable import/no-extraneous-dependencies */
// jest-dom adds custom jest matchers for asserting on DOM nodes.
// allows you to do things like:
// expect(element).toHaveTextContent(/react/i)
Expand Down
1 change: 1 addition & 0 deletions wallet/src/util/Icons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export const icons = {
USDT_grv: 'tokens/USDT_grv.webp',
USDT_axl: 'tokens/USDT_axl.png',
DAI_axl: 'tokens/DAI_axl.png',
stATOM: 'tokens/statom.svg',
DAI_grv: 'tokens/DAI_grv.png',
};

Expand Down
24 changes: 22 additions & 2 deletions wallet/src/util/ibc-assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const ibcAssets: IbcAssets = {
chainInfo: {
chainName: 'Cosmos Hub',
chainId: 'cosmoshub-4',
rpc: 'https://cosmoshub-rpc.stakely.io/',
rpc: 'https://cosmos-rpc.polkachu.com:443',
addressPrefix: 'cosmos',
explorerPath: 'cosmos',
gas: '100000',
Expand All @@ -39,9 +39,29 @@ export const ibcAssets: IbcAssets = {
withdraw: {
sourcePort: 'transfer',
sourceChannel: 'channel-5',
// XXX This will be redundant once `agoricNames.vbankAssets` is published.
denom:
'ibc/BA313C4A19DFBF943586C0387E6B11286F9E416B4DD27574E6909CABE0E342FA',
},
},
stATOM: {
chainInfo: {
chainName: 'Stride',
chainId: 'stride-1',
rpc: 'https://stride-rpc.polkachu.com:443',
addressPrefix: 'stride',
explorerPath: 'stride',
gas: '100000',
},
deposit: {
sourcePort: 'transfer',
sourceChannel: 'channel-148',
denom: 'stuatom',
},
withdraw: {
sourcePort: 'transfer',
sourceChannel: 'channel-59',
denom:
'ibc/B1E6288B5A0224565D915D1F66716486F16D8A44BF33A9EC323DD6BA30764C35',
},
},
};
2 changes: 1 addition & 1 deletion wallet/src/util/ibcTransfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const timeoutTimestampSeconds = () =>
Math.round(Date.now() / 1000) + secondsUntilTimeout;

export const agoricChainId = 'agoric-3';
const agoricRpc = 'https://agoric-rpc.stakely.io/';
const agoricRpc = 'https://agoric-rpc.polkachu.com:443';
const agoricGas = '500000';

export const sendIbcTokens = async (
Expand Down
2 changes: 0 additions & 2 deletions wallet/src/util/keyManagement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,6 @@ export const makeBackgroundSigner = async ({
granter: string,
rpcClient: import('@cosmjs/tendermint-rpc').Tendermint34Client,
): Promise<GenericAuthorization[]> => {
// @ts-expect-error
const base = QueryClient.withExtensions(rpcClient);
const rpc = createProtobufRpcClient(base);
const queryService = new QueryClientImpl(rpc);
Expand Down Expand Up @@ -403,7 +402,6 @@ export const makeInteractiveSigner = async (
};
const signingClient = await connectWithSigner(chainInfo.rpc, offlineSigner, {
aminoTypes: new AminoTypes(converters),
// @ts-expect-error
registry: SwingsetRegistry,
});
console.debug('InteractiveSigner', { signingClient });
Expand Down
1 change: 0 additions & 1 deletion wallet/src/util/queryBankBalances.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export const queryBankBalances = async (
rpc: HttpEndpoint,
): Promise<Coin[]> => {
const tendermint = await Tendermint34Client.connect(rpc);
// @ts-expect-error
const queryClient = new QueryClient(tendermint);
const rpcClient = createProtobufRpcClient(queryClient);
const bankQueryService = new QueryClientImpl(rpcClient);
Expand Down
10 changes: 0 additions & 10 deletions wallet/src/util/querySwingsetParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,6 @@ export const querySwingsetParams = async (
): Promise<QueryParamsResponse> => {
const http = new HttpClient(endpoint);
const trpc = await Tendermint34Client.create(http);
/**
* XXX
*
* Argument of type
* 'import("~/wallet-app/wallet/node_modules/@cosmjs/tendermint-rpc/build/tendermint34/tendermint34client").Tendermint34Client'
* is not assignable to parameter of type
* 'import("~/wallet-app/wallet/node_modules/@cosmjs/stargate/node_modules/@cosmjs/tendermint-rpc/build/tendermint34/tendermint34client").Tendermint34Client'.
* Types have separate declarations of a private property 'client'.
*/
// @ts-expect-error
const base = QueryClient.withExtensions(trpc);
const rpc = createProtobufRpcClient(base);
const queryService = new QueryClientImpl(rpc);
Expand Down
Loading

0 comments on commit e784bc7

Please sign in to comment.