直接使用npm上的web3js
This commit is contained in:
parent
a66d11e368
commit
3e4ad763f5
@ -11,8 +11,10 @@
|
||||
"author": "zhl",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@metamask/eth-sig-util": "^4.0.1",
|
||||
"bip39": "^3.0.4",
|
||||
"ethereumjs-wallet": "^1.0.2",
|
||||
"web3": "^1.7.4",
|
||||
"whatwg-fetch": "^3.6.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
export const abiERC1155 = [
|
||||
import {AbiItem} from 'web3-utils';
|
||||
export const abiERC1155: AbiItem[] = [
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
import {AbiItem} from 'web3-utils';
|
||||
|
||||
|
||||
export let abiERC20 = [
|
||||
export let abiERC20: AbiItem[] = [
|
||||
{
|
||||
constant: true,
|
||||
inputs: [],
|
||||
|
@ -1,5 +1,6 @@
|
||||
import {AbiItem} from 'web3-utils';
|
||||
|
||||
export const abiERC721 = [
|
||||
export const abiERC721: AbiItem[] = [
|
||||
{
|
||||
constant: true,
|
||||
inputs: [
|
||||
|
14
src/index.ts
14
src/index.ts
@ -1,7 +1,7 @@
|
||||
|
||||
import { singleton } from "./decorator/singleton.decorator";
|
||||
import Web3 from './lib/web3.min.js';
|
||||
let sth = import('./lib/ethSigUtil.js');
|
||||
import Web3 from 'web3';
|
||||
import { recoverTypedSignature, signTypedData, SignTypedDataVersion } from '@metamask/eth-sig-util';
|
||||
import 'whatwg-fetch'
|
||||
import { AllChains } from "./data/allchain";
|
||||
import { createWalletEvents, WALLET_ACCOUNT_CHANGE, WALLET_CHAIN_CHANGE, WALLET_TOKEN_TYPE_CHANGE } from "./common/WalletEvent";
|
||||
@ -54,7 +54,7 @@ export default class JCWallet {
|
||||
|
||||
constructor() {
|
||||
// this.web3 = new Web3('https://rpc-mainnet.kcc.network')
|
||||
this.web3 = new Web3('https://rpc-testnet.kcc.network', {timeout: 30000})
|
||||
this.web3 = new Web3('https://rpc-testnet.kcc.network')
|
||||
this.erc20Standard = new ERC20Standard(this.web3);
|
||||
this.erc721Standard = new ERC721Standard(this.web3);
|
||||
this.wallet = this.web3.eth.accounts.wallet.load(this.password, WALLET_STORAGE_KEY_NAME)
|
||||
@ -213,18 +213,18 @@ export default class JCWallet {
|
||||
|
||||
public signTypedDataV4(signObj: any) {
|
||||
const account = this.currentAccount()
|
||||
return window.ethSigUtil.signTypedData({
|
||||
return signTypedData({
|
||||
data: signObj,
|
||||
privateKey: Buffer.from(account.privateKey.replace('0x', ''), 'hex'),
|
||||
version: 'V4'
|
||||
version: SignTypedDataVersion.V4
|
||||
})
|
||||
}
|
||||
|
||||
public recoverTypedSignatureV4(signObj: any, signature: string) {
|
||||
return window.ethSigUtil.recoverTypedSignature({
|
||||
return recoverTypedSignature({
|
||||
data: signObj,
|
||||
signature,
|
||||
version: 'V4'
|
||||
version: SignTypedDataVersion.V4
|
||||
})
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because one or more lines are too long
42858
src/lib/web3.min.js
vendored
42858
src/lib/web3.min.js
vendored
File diff suppressed because one or more lines are too long
@ -1,4 +1,4 @@
|
||||
import Web3 from '../lib/web3.min.js';
|
||||
import Web3 from 'web3';
|
||||
import { abiERC20 } from "../abis/abiERC20";
|
||||
import { BN, toUtf8 } from 'ethereumjs-util';
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
import Web3 from '../lib/web3.min.js';
|
||||
import Web3 from 'web3';
|
||||
import { abiERC721 } from "../abis/abiERC721";
|
||||
import { timeoutFetch } from '../util/net.util';
|
||||
import { getFormattedIpfsUrl } from '../util/wallet.util';
|
||||
|
@ -1,4 +1,4 @@
|
||||
import Web3 from '../lib/web3.min.js';
|
||||
import Web3 from 'web3';
|
||||
import { BN } from 'ethereumjs-util';
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user