Skip to content

Commit

Permalink
Remove json rpc
Browse files Browse the repository at this point in the history
  • Loading branch information
DOBEN committed Aug 18, 2023
1 parent e0ae051 commit 6463fe7
Show file tree
Hide file tree
Showing 8 changed files with 209 additions and 40 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ node_modules
/coverage

# production
/build
/**/build

# misc
.idea
Expand Down
4 changes: 4 additions & 0 deletions signMessage/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 0.2.1

- Migrate dApp from using deprecated JSON-RPC client to new gRPC client.

## 0.2.0

- Add link to source code
Expand Down
7 changes: 5 additions & 2 deletions signMessage/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "sign_message",
"version": "0.2.0",
"version": "0.2.1",
"private": true,
"dependencies": {
"@concordium/browser-wallet-api-helpers": "^0.2.0",
"@concordium/web-sdk": "^0.4.0",
"@concordium/web-sdk": "^6.0.0",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
Expand All @@ -27,6 +27,9 @@
"typescript": "^4.8.3",
"web-vitals": "^2.1.4"
},
"resolutions": {
"@concordium/web-sdk": "^6.0.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
Expand Down
1 change: 0 additions & 1 deletion signMessage/src/App.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import { render, screen } from '@testing-library/react';
import App from './App';

Expand Down
9 changes: 2 additions & 7 deletions signMessage/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import React, {useCallback, useEffect, useState} from 'react';
import {useCallback, useEffect, useState} from 'react';

import './App.css';
import {Alert, Button, Col, Container, Row, Spinner} from "react-bootstrap";
import {HttpProvider, JsonRpcClient} from "@concordium/web-sdk";
import {
CHAIN_ID,
JSON_RPC_URL,
PING_INTERVAL_MS,
WALLET_CONNECT_PROJECT_ID,
} from "./config";
Expand All @@ -17,8 +15,6 @@ import {SessionTypes} from "@walletconnect/types";
import BrowserWallet, {trySendTransaction, sign, wrapPromise} from "./BrowserWallet";
import Footer from "./Footer";

const rpc = new JsonRpcClient(new HttpProvider(JSON_RPC_URL));

type Wallet = "browserwallet" | "walletconnect2";

export default function App() {
Expand Down Expand Up @@ -157,7 +153,7 @@ export default function App() {
sign(client, account, message),
),
)
} else if (wallet === "walletconnect2" && rpc) {
} else if (wallet === "walletconnect2") {
trySend(
walletconnect2Client,
walletconnect2ConnectedSession,
Expand All @@ -166,7 +162,6 @@ export default function App() {
signMessage(
client,
session,
rpc,
CHAIN_ID,
message,
)
Expand Down
5 changes: 1 addition & 4 deletions signMessage/src/WalletConnect2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ import QRCodeModal from "@walletconnect/qrcode-modal";
import {SessionTypes} from "@walletconnect/types";
import {Result, ResultAsync} from "neverthrow";
import {resultFromTruthy, resultFromTruthyResult} from "./util";
import {
JsonRpcClient,
} from "@concordium/web-sdk";
import {CHAIN_ID, WALLET_CONNECT_SESSION_NAMESPACE} from "./config";

async function connect(client: SignClient, setConnectedSession: (session: SessionTypes.Struct) => void) {
Expand Down Expand Up @@ -61,7 +58,7 @@ function isSignAndSendTransactionError(obj: any): obj is SignAndSendTransactionE
return 'code' in obj && 'message' in obj;
}

export async function signMessage(signClient: SignClient, session: SessionTypes.Struct, rpcClient: JsonRpcClient, chainId: string, message: string) {
export async function signMessage(signClient: SignClient, session: SessionTypes.Struct, chainId: string, message: string) {
try {
const signature = await signClient.request({
topic: session.topic,
Expand Down
5 changes: 2 additions & 3 deletions signMessage/src/config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import {GtuAmount} from "@concordium/web-sdk";
import {CcdAmount} from "@concordium/web-sdk";

export const JSON_RPC_URL = "https://json-rpc.testnet.concordium.com";
export const WALLET_CONNECT_PROJECT_ID = "76324905a70fe5c388bab46d3e0564dc";
export const WALLET_CONNECT_SESSION_NAMESPACE = "ccd";
export const DEFAULT_CONTRACT_INDEX = BigInt(81);
export const MAX_CONTRACT_EXECUTION_ENERGY = BigInt(30000);
export const CHAIN_ID = "ccd:testnet";
export const ZERO_AMOUNT = new GtuAmount(BigInt(0));
export const ZERO_AMOUNT = new CcdAmount(BigInt(0));
export const CCDSCAN_URL = "testnet.ccdscan.io";
export const PING_INTERVAL_MS = 5000;
Loading

0 comments on commit 6463fe7

Please sign in to comment.