upgrade project dependencies web3 & next

This commit is contained in:
Maximilian Schneider 2022-07-30 17:25:06 +02:00
parent cc6ae1cd0b
commit 1b7c251870
6 changed files with 2606 additions and 3695 deletions

5
next-env.d.ts vendored
View File

@ -1,2 +1,5 @@
/// <reference types="next" />
/// <reference types="next/types/global" />
/// <reference types="next/image-types/global" />
// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.

View File

@ -1,10 +1,18 @@
const withTM = require('next-transpile-modules')([
'@project-serum/sol-wallet-adapter',
])
const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true',
})
module.exports = withBundleAnalyzer({
module.exports = withBundleAnalyzer(withTM({
target: 'serverless',
webpack(config) {
webpack(config, {isServer}) {
if (!isServer) config.resolve.fallback.fs = false
config.module.rules.push({
test: /\.svg$/,
use: ['@svgr/webpack'],
@ -12,4 +20,4 @@ module.exports = withBundleAnalyzer({
return config
},
})
}))

View File

@ -36,20 +36,20 @@
"@emotion/styled": "^11.1.5",
"@headlessui/react": "^1.2.0",
"@heroicons/react": "^1.0.0",
"@project-serum/serum": "^0.13.20",
"@project-serum/sol-wallet-adapter": "^0.1.8",
"@solana/web3.js": "^0.95.0",
"@project-serum/serum": "^0.13.65",
"@project-serum/sol-wallet-adapter": "^0.2.6",
"@solana/web3.js": "^1.30.2",
"@tippyjs/react": "^4.2.5",
"babel-plugin-import": "^1.13.3",
"bn.js": "^5.2.0",
"bs58": "^4.0.1",
"buffer-layout": "^1.2.0",
"dayjs": "^1.10.4",
"immer": "^9.0.1",
"immutable-tuple": "^0.4.10",
"lodash-es": "^4.17.21",
"next": "^10.1.3",
"next": "^12.2.3",
"next-themes": "^0.0.14",
"next-transpile-modules": "^9.0.0",
"postcss-preset-env": "^6.7.0",
"rc-slider": "^9.7.2",
"react": "^17.0.1",
@ -70,7 +70,7 @@
"@testing-library/react": "^11.2.5",
"@types/jest": "^26.0.20",
"@types/node": "^14.14.25",
"@types/react": "^17.0.1",
"@types/react": "17.0.2",
"@typescript-eslint/eslint-plugin": "^4.14.2",
"@typescript-eslint/parser": "^4.14.2",
"babel-jest": "^26.6.3",
@ -91,5 +91,9 @@
"tailwindcss": "^2.1.2",
"twin.macro": "^2.4.1",
"typescript": "^4.1.3"
},
"resolutions": {
"@solana/spl-token": "0.1.6",
"@solana/web3.js": "1.50.1"
}
}

View File

@ -1,7 +1,11 @@
{
"compilerOptions": {
"target": "es6",
"lib": ["dom", "dom.iterable", "esnext"],
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"strict": false,
@ -12,9 +16,15 @@
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve"
"jsx": "preserve",
"incremental": true
},
"exclude": ["node_modules", ".next", "out", "public/datafeeds"],
"exclude": [
"node_modules",
".next",
"out",
"public/datafeeds"
],
"include": [
"next-env.d.ts",
"**/*.ts",

View File

@ -2,19 +2,14 @@ import { notify } from './notifications'
import { sleep } from './index'
import {
Account,
AccountInfo,
Commitment,
Connection,
PublicKey,
RpcResponseAndContext,
SimulatedTransactionResponse,
Transaction,
TransactionSignature,
} from '@solana/web3.js'
import Wallet from '@project-serum/sol-wallet-adapter'
import { Buffer } from 'buffer'
import assert from 'assert'
import { struct } from 'superstruct'
class TransactionError extends Error {
public txid: string
@ -261,98 +256,6 @@ async function awaitTransactionSignatureConfirmation(
return result
}
function jsonRpcResult(resultDescription: any) {
const jsonRpcVersion = struct.literal('2.0')
return struct.union([
struct({
jsonrpc: jsonRpcVersion,
id: 'string',
error: 'any',
}),
struct({
jsonrpc: jsonRpcVersion,
id: 'string',
error: 'null?',
result: resultDescription,
}),
])
}
function jsonRpcResultAndContext(resultDescription: any) {
return jsonRpcResult({
context: struct({
slot: 'number',
}),
value: resultDescription,
})
}
const AccountInfoResult = struct({
executable: 'boolean',
owner: 'string',
lamports: 'number',
data: 'any',
rentEpoch: 'number?',
})
export const GetMultipleAccountsAndContextRpcResult = jsonRpcResultAndContext(
struct.array([struct.union(['null', AccountInfoResult])])
)
export async function getMultipleSolanaAccounts(
connection: Connection,
publicKeys: PublicKey[]
): Promise<
RpcResponseAndContext<{ [key: string]: AccountInfo<Buffer> | null }>
> {
const args = [publicKeys.map((k) => k.toBase58()), { commitment: 'recent' }]
// @ts-ignore
const unsafeRes = await connection._rpcRequest('getMultipleAccounts', args)
const res = GetMultipleAccountsAndContextRpcResult(unsafeRes)
if (res.error) {
throw new Error(
'failed to get info about accounts ' +
publicKeys.map((k) => k.toBase58()).join(', ') +
': ' +
res.error.message
)
}
assert(typeof res.result !== 'undefined')
const accounts: Array<{
executable: any
owner: PublicKey
lamports: any
data: Buffer
} | null> = []
for (const account of res.result.value) {
let value: {
executable: any
owner: PublicKey
lamports: any
data: Buffer
} | null = null
if (res.result.value) {
const { executable, owner, lamports, data } = account
assert(data[1] === 'base64')
value = {
executable,
owner: new PublicKey(owner),
lamports,
data: Buffer.from(data[0], 'base64'),
}
}
accounts.push(value)
}
return {
context: {
slot: res.result.context.slot,
},
value: Object.fromEntries(
accounts.map((account, i) => [publicKeys[i].toBase58(), account])
),
}
}
/** Copy of Connection.simulateTransaction that takes a commitment parameter. */
async function simulateTransaction(
connection: Connection,

6153
yarn.lock

File diff suppressed because it is too large Load Diff