Compare commits
54 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
235a20059f | ||
![]() |
ef8f844cc3 | ||
![]() |
86e71e6d73 | ||
![]() |
0ed31320cb | ||
![]() |
db4b6da5f3 | ||
![]() |
0ae4b54bd8 | ||
![]() |
4341ccfeff | ||
![]() |
2f745f2216 | ||
![]() |
ba0d976e42 | ||
![]() |
ceb8cca8dc | ||
![]() |
676e1176de | ||
![]() |
2e1c76976d | ||
![]() |
b29fa53af3 | ||
![]() |
3edab20653 | ||
![]() |
e0591c1be5 | ||
![]() |
faa45df02c | ||
![]() |
01c4789cbe | ||
![]() |
aa8b8bebb6 | ||
![]() |
97b7edbe2d | ||
![]() |
a1ce68e561 | ||
![]() |
fc0cef2074 | ||
![]() |
28a639f13d | ||
![]() |
c85848ceec | ||
![]() |
6cc9b2ee3a | ||
![]() |
460477293d | ||
![]() |
a316fc750f | ||
![]() |
f8498487ba | ||
![]() |
2db473a365 | ||
![]() |
a08c12c535 | ||
![]() |
eb045cc5c9 | ||
![]() |
8c43cfe55a | ||
![]() |
22abde8821 | ||
![]() |
0f366b87c7 | ||
![]() |
f63ccb25ec | ||
![]() |
14dc3debbd | ||
![]() |
222f84307a | ||
![]() |
c2a36696b2 | ||
![]() |
6f3262af9d | ||
![]() |
13fdc25a54 | ||
![]() |
bf4875bf19 | ||
![]() |
91c7b9b940 | ||
![]() |
1a1ca431e3 | ||
![]() |
1824e4230e | ||
![]() |
47c1c81ccb | ||
![]() |
6f6fdd52b9 | ||
![]() |
cb688bae3f | ||
![]() |
2cd244f3d3 | ||
![]() |
e055eaba7f | ||
![]() |
f6ed757a1c | ||
![]() |
92fa1b635b | ||
![]() |
1b99631036 | ||
![]() |
e4e055fc1c | ||
![]() |
d34ffec0ed | ||
![]() |
014c155318 |
14
patches/web3-core-method+1.7.4.patch
Normal file
14
patches/web3-core-method+1.7.4.patch
Normal file
@ -0,0 +1,14 @@
|
||||
diff --git a/node_modules/web3-core-method/lib/index.js b/node_modules/web3-core-method/lib/index.js
|
||||
index 84cb1c3..4eb4592 100644
|
||||
--- a/node_modules/web3-core-method/lib/index.js
|
||||
+++ b/node_modules/web3-core-method/lib/index.js
|
||||
@@ -561,6 +561,9 @@ Method.prototype.buildCall = function () {
|
||||
};
|
||||
// SENDS the SIGNED SIGNATURE
|
||||
var sendSignedTx = function (sign) {
|
||||
+ var returnObj = Object.assign({}, payload.params[0]);
|
||||
+ returnObj.transactionHash = sign.transactionHash;
|
||||
+ defer.eventEmitter.emit('presend', returnObj);
|
||||
var signedPayload = { ...payload,
|
||||
method: 'eth_sendRawTransaction',
|
||||
params: [sign.rawTransaction]
|
37
src/JCWallet.d.ts
vendored
37
src/JCWallet.d.ts
vendored
@ -14,25 +14,34 @@ declare namespace jc {
|
||||
|
||||
declare namespace jsb {
|
||||
export function walletSign(str: string);
|
||||
export function loadLocalStorage(key: string);
|
||||
export function loadLocalStorage(key: string): string;
|
||||
export function saveLocalStorage(key: string, val: string);
|
||||
export function signWithGoogle(id: number);
|
||||
export function signWithApple(id: number);
|
||||
export function signWithTikTok(id: number);
|
||||
export function signWithFacebook(id: number);
|
||||
export function callJcVoidMethodJNI(id: number, methodName: string);
|
||||
export function signWithTwitter(id: number);
|
||||
export function signWithEmail(id: number);
|
||||
export function signOutGoogle(id: number);
|
||||
export function showWebPage(url: string);
|
||||
export function openURL(url: string);
|
||||
export function scanQRCode(id: number, title: string);
|
||||
export function restoreKey(id: number, oid: string);
|
||||
export function generateWallet(idHash: string, seedHash: string);
|
||||
export function prepareWallet(
|
||||
idHash: string,
|
||||
seedHash: string,
|
||||
key_master: string
|
||||
);
|
||||
export function restoreWallet(
|
||||
idHash: string,
|
||||
seedHash: string,
|
||||
key_master: string,
|
||||
key_restore: any
|
||||
);
|
||||
export function hexDeflate(str: string): string;
|
||||
export function hexInflate(str: string): string;
|
||||
export function hashSvrPass(pass: string): string;
|
||||
export function walletEncrypt(str: string): string;
|
||||
export function walletDecrypt(str: string): string;
|
||||
export function beginBuy(id: number, productId: string, orderId: string): string;
|
||||
export function queryPurchase(id: number): string;
|
||||
export function getClientId(id: number);
|
||||
export function passStorageState(id: number, account: string);
|
||||
export function storagePass(id: number, account: string, pass: string);
|
||||
export function authGetStoragePass(id: number, key: string);
|
||||
export function queryProducts(id: number, str: string): string;
|
||||
export function finishTransaction(id: number, str: string);
|
||||
export function walletSecKey(id: string, openid: string, key_master: string, salt: string, pass: string): string;
|
||||
export function prepareWallet(id: string, openid: string, key_master: string, salt: string, pass: string): string;
|
||||
}
|
||||
|
||||
declare let window: Window;
|
||||
|
140
src/abis/abiERC721Staking.ts
Normal file
140
src/abis/abiERC721Staking.ts
Normal file
@ -0,0 +1,140 @@
|
||||
import { AbiItem } from 'web3-utils';
|
||||
|
||||
export let abiERC721Staking: AbiItem[] = [
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'address[]',
|
||||
name: 'nfts',
|
||||
type: 'address[]',
|
||||
},
|
||||
{
|
||||
internalType: 'uint256[]',
|
||||
name: 'tokenIds',
|
||||
type: 'uint256[]',
|
||||
},
|
||||
{
|
||||
internalType: 'uint64[]',
|
||||
name: 'staketimes',
|
||||
type: 'uint64[]',
|
||||
},
|
||||
],
|
||||
name: 'stake',
|
||||
outputs: [],
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'address[]',
|
||||
name: 'nfts',
|
||||
type: 'address[]',
|
||||
},
|
||||
{
|
||||
internalType: 'uint256[]',
|
||||
name: 'tokenIds',
|
||||
type: 'uint256[]',
|
||||
},
|
||||
],
|
||||
name: 'redeem',
|
||||
outputs: [],
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'uint64',
|
||||
name: '',
|
||||
type: 'uint64',
|
||||
},
|
||||
],
|
||||
name: 'periods',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'bool',
|
||||
name: '',
|
||||
type: 'bool',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: 'cooldownSeconds',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: '',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: '',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
name: 'erc721Supported',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'bool',
|
||||
name: '',
|
||||
type: 'bool',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: '',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: '',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
name: 'stakingMap',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: 'user',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
internalType: 'address',
|
||||
name: 'nft',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: 'tokenId',
|
||||
type: 'uint256',
|
||||
},
|
||||
{
|
||||
internalType: 'uint64',
|
||||
name: 'start',
|
||||
type: 'uint64',
|
||||
},
|
||||
{
|
||||
internalType: 'uint64',
|
||||
name: 'stakeTime',
|
||||
type: 'uint64',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
];
|
18
src/abis/abiFeeAddress.ts
Normal file
18
src/abis/abiFeeAddress.ts
Normal file
@ -0,0 +1,18 @@
|
||||
import { AbiItem } from "web3-utils";
|
||||
|
||||
export let abiEvolveFactory: AbiItem[] = [
|
||||
{
|
||||
inputs: [],
|
||||
name: "feeToAddress",
|
||||
outputs: [
|
||||
{
|
||||
internalType: "address",
|
||||
name: "",
|
||||
type: "address",
|
||||
},
|
||||
],
|
||||
stateMutability: "view",
|
||||
type: "function",
|
||||
constant: true,
|
||||
},
|
||||
];
|
388
src/abis/abiGameMall.ts
Normal file
388
src/abis/abiGameMall.ts
Normal file
@ -0,0 +1,388 @@
|
||||
import { AbiItem } from "web3-utils";
|
||||
|
||||
export let abiGameMall: AbiItem[] = [
|
||||
{
|
||||
inputs: [],
|
||||
stateMutability: "nonpayable",
|
||||
type: "constructor",
|
||||
},
|
||||
{
|
||||
anonymous: false,
|
||||
inputs: [
|
||||
{
|
||||
indexed: false,
|
||||
internalType: "address",
|
||||
name: "erc20",
|
||||
type: "address",
|
||||
},
|
||||
],
|
||||
name: "AddERC20Suppout",
|
||||
type: "event",
|
||||
},
|
||||
{
|
||||
anonymous: false,
|
||||
inputs: [
|
||||
{
|
||||
indexed: true,
|
||||
internalType: "address",
|
||||
name: "buyer",
|
||||
type: "address",
|
||||
},
|
||||
{
|
||||
indexed: true,
|
||||
internalType: "uint256",
|
||||
name: "orderId",
|
||||
type: "uint256",
|
||||
},
|
||||
{
|
||||
indexed: false,
|
||||
internalType: "address",
|
||||
name: "currency",
|
||||
type: "address",
|
||||
},
|
||||
{
|
||||
indexed: false,
|
||||
internalType: "uint256",
|
||||
name: "price",
|
||||
type: "uint256",
|
||||
},
|
||||
],
|
||||
name: "ItemSoldOut",
|
||||
type: "event",
|
||||
},
|
||||
{
|
||||
anonymous: false,
|
||||
inputs: [
|
||||
{
|
||||
indexed: true,
|
||||
internalType: "address",
|
||||
name: "previousOwner",
|
||||
type: "address",
|
||||
},
|
||||
{
|
||||
indexed: true,
|
||||
internalType: "address",
|
||||
name: "newOwner",
|
||||
type: "address",
|
||||
},
|
||||
],
|
||||
name: "OwnershipTransferred",
|
||||
type: "event",
|
||||
},
|
||||
{
|
||||
anonymous: false,
|
||||
inputs: [
|
||||
{
|
||||
indexed: false,
|
||||
internalType: "address",
|
||||
name: "erc20",
|
||||
type: "address",
|
||||
},
|
||||
],
|
||||
name: "RemoveERC20Suppout",
|
||||
type: "event",
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: "address",
|
||||
name: "erc20",
|
||||
type: "address",
|
||||
},
|
||||
],
|
||||
name: "addERC20Support",
|
||||
outputs: [],
|
||||
stateMutability: "nonpayable",
|
||||
type: "function",
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: "address",
|
||||
name: "signer",
|
||||
type: "address",
|
||||
},
|
||||
{
|
||||
internalType: "bytes32",
|
||||
name: "hash",
|
||||
type: "bytes32",
|
||||
},
|
||||
{
|
||||
internalType: "bytes",
|
||||
name: "signature",
|
||||
type: "bytes",
|
||||
},
|
||||
],
|
||||
name: "checkSigner",
|
||||
outputs: [],
|
||||
stateMutability: "pure",
|
||||
type: "function",
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: "address",
|
||||
name: "signer",
|
||||
type: "address",
|
||||
},
|
||||
{
|
||||
internalType: "bytes32",
|
||||
name: "structHash",
|
||||
type: "bytes32",
|
||||
},
|
||||
{
|
||||
internalType: "bytes",
|
||||
name: "signature",
|
||||
type: "bytes",
|
||||
},
|
||||
],
|
||||
name: "checkSigner712",
|
||||
outputs: [],
|
||||
stateMutability: "view",
|
||||
type: "function",
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: "address",
|
||||
name: "",
|
||||
type: "address",
|
||||
},
|
||||
],
|
||||
name: "erc20Supported",
|
||||
outputs: [
|
||||
{
|
||||
internalType: "bool",
|
||||
name: "",
|
||||
type: "bool",
|
||||
},
|
||||
],
|
||||
stateMutability: "view",
|
||||
type: "function",
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: "executor",
|
||||
outputs: [
|
||||
{
|
||||
internalType: "address",
|
||||
name: "",
|
||||
type: "address",
|
||||
},
|
||||
],
|
||||
stateMutability: "view",
|
||||
type: "function",
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: "feeToAddress",
|
||||
outputs: [
|
||||
{
|
||||
internalType: "address",
|
||||
name: "",
|
||||
type: "address",
|
||||
},
|
||||
],
|
||||
stateMutability: "view",
|
||||
type: "function",
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: "getDuration",
|
||||
outputs: [
|
||||
{
|
||||
internalType: "uint256",
|
||||
name: "duration",
|
||||
type: "uint256",
|
||||
},
|
||||
],
|
||||
stateMutability: "view",
|
||||
type: "function",
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: "uint256",
|
||||
name: "",
|
||||
type: "uint256",
|
||||
},
|
||||
],
|
||||
name: "orderIdUsed",
|
||||
outputs: [
|
||||
{
|
||||
internalType: "address",
|
||||
name: "",
|
||||
type: "address",
|
||||
},
|
||||
],
|
||||
stateMutability: "view",
|
||||
type: "function",
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: "owner",
|
||||
outputs: [
|
||||
{
|
||||
internalType: "address",
|
||||
name: "",
|
||||
type: "address",
|
||||
},
|
||||
],
|
||||
stateMutability: "view",
|
||||
type: "function",
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: "address",
|
||||
name: "erc20",
|
||||
type: "address",
|
||||
},
|
||||
],
|
||||
name: "removeERC20Support",
|
||||
outputs: [],
|
||||
stateMutability: "nonpayable",
|
||||
type: "function",
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: "renounceOwnership",
|
||||
outputs: [],
|
||||
stateMutability: "nonpayable",
|
||||
type: "function",
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: "address",
|
||||
name: "_feeToAddress",
|
||||
type: "address",
|
||||
},
|
||||
],
|
||||
name: "setFeeToAddress",
|
||||
outputs: [],
|
||||
stateMutability: "nonpayable",
|
||||
type: "function",
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: "address",
|
||||
name: "newOwner",
|
||||
type: "address",
|
||||
},
|
||||
],
|
||||
name: "transferOwnership",
|
||||
outputs: [],
|
||||
stateMutability: "nonpayable",
|
||||
type: "function",
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: "uint256",
|
||||
name: "valNew",
|
||||
type: "uint256",
|
||||
},
|
||||
],
|
||||
name: "updateDuation",
|
||||
outputs: [],
|
||||
stateMutability: "nonpayable",
|
||||
type: "function",
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: "address",
|
||||
name: "account",
|
||||
type: "address",
|
||||
},
|
||||
],
|
||||
name: "updateExecutor",
|
||||
outputs: [],
|
||||
stateMutability: "nonpayable",
|
||||
type: "function",
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: "uint256",
|
||||
name: "orderId",
|
||||
type: "uint256",
|
||||
},
|
||||
{
|
||||
internalType: "address",
|
||||
name: "currency",
|
||||
type: "address",
|
||||
},
|
||||
{
|
||||
internalType: "uint256",
|
||||
name: "price",
|
||||
type: "uint256",
|
||||
},
|
||||
{
|
||||
internalType: "uint256",
|
||||
name: "startTime",
|
||||
type: "uint256",
|
||||
},
|
||||
{
|
||||
internalType: "uint256",
|
||||
name: "saltNonce",
|
||||
type: "uint256",
|
||||
},
|
||||
{
|
||||
internalType: "bytes",
|
||||
name: "signature",
|
||||
type: "bytes",
|
||||
},
|
||||
],
|
||||
name: "buy",
|
||||
outputs: [],
|
||||
stateMutability: "nonpayable",
|
||||
type: "function",
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: "address",
|
||||
name: "_buyer",
|
||||
type: "address",
|
||||
},
|
||||
{
|
||||
internalType: "uint256",
|
||||
name: "_orderId",
|
||||
type: "uint256",
|
||||
},
|
||||
{
|
||||
internalType: "address",
|
||||
name: "_currency",
|
||||
type: "address",
|
||||
},
|
||||
{
|
||||
internalType: "uint256",
|
||||
name: "_price",
|
||||
type: "uint256",
|
||||
},
|
||||
{
|
||||
internalType: "uint256",
|
||||
name: "_startTime",
|
||||
type: "uint256",
|
||||
},
|
||||
{
|
||||
internalType: "uint256",
|
||||
name: "_saltNonce",
|
||||
type: "uint256",
|
||||
},
|
||||
],
|
||||
name: "getMessageHash",
|
||||
outputs: [
|
||||
{
|
||||
internalType: "bytes32",
|
||||
name: "",
|
||||
type: "bytes32",
|
||||
},
|
||||
],
|
||||
stateMutability: "pure",
|
||||
type: "function",
|
||||
},
|
||||
];
|
@ -1,6 +1,6 @@
|
||||
import { AbiItem } from "web3-utils";
|
||||
|
||||
export let abiNftMall: AbiItem[] = [
|
||||
export let abiGameMarket: AbiItem[] = [
|
||||
{
|
||||
inputs: [],
|
||||
stateMutability: "nonpayable",
|
||||
@ -10,37 +10,13 @@ export let abiNftMall: AbiItem[] = [
|
||||
anonymous: false,
|
||||
inputs: [
|
||||
{
|
||||
indexed: true,
|
||||
indexed: false,
|
||||
internalType: "address",
|
||||
name: "buyer",
|
||||
name: "erc20",
|
||||
type: "address",
|
||||
},
|
||||
{
|
||||
indexed: true,
|
||||
internalType: "uint256",
|
||||
name: "nonce",
|
||||
type: "uint256",
|
||||
},
|
||||
{
|
||||
indexed: false,
|
||||
internalType: "uint256",
|
||||
name: "tokenId",
|
||||
type: "uint256",
|
||||
},
|
||||
{
|
||||
indexed: false,
|
||||
internalType: "address[3]",
|
||||
name: "addresses",
|
||||
type: "address[3]",
|
||||
},
|
||||
{
|
||||
indexed: false,
|
||||
internalType: "uint256",
|
||||
name: "price",
|
||||
type: "uint256",
|
||||
},
|
||||
],
|
||||
name: "BuyTransaction",
|
||||
name: "AddERC20Suppout",
|
||||
type: "event",
|
||||
},
|
||||
{
|
||||
@ -52,17 +28,23 @@ export let abiNftMall: AbiItem[] = [
|
||||
name: "buyer",
|
||||
type: "address",
|
||||
},
|
||||
{
|
||||
indexed: true,
|
||||
internalType: "address",
|
||||
name: "seller",
|
||||
type: "address",
|
||||
},
|
||||
{
|
||||
indexed: true,
|
||||
internalType: "uint256",
|
||||
name: "nonce",
|
||||
name: "orderId",
|
||||
type: "uint256",
|
||||
},
|
||||
{
|
||||
indexed: false,
|
||||
internalType: "address[3]",
|
||||
name: "addresses",
|
||||
type: "address[3]",
|
||||
internalType: "address",
|
||||
name: "currency",
|
||||
type: "address",
|
||||
},
|
||||
{
|
||||
indexed: false,
|
||||
@ -70,20 +52,8 @@ export let abiNftMall: AbiItem[] = [
|
||||
name: "price",
|
||||
type: "uint256",
|
||||
},
|
||||
{
|
||||
indexed: false,
|
||||
internalType: "uint256[]",
|
||||
name: "ids",
|
||||
type: "uint256[]",
|
||||
},
|
||||
{
|
||||
indexed: false,
|
||||
internalType: "uint256[]",
|
||||
name: "amounts",
|
||||
type: "uint256[]",
|
||||
},
|
||||
],
|
||||
name: "BuyTransactionBatch",
|
||||
name: "ItemSoldOut",
|
||||
type: "event",
|
||||
},
|
||||
{
|
||||
@ -106,14 +76,53 @@ export let abiNftMall: AbiItem[] = [
|
||||
type: "event",
|
||||
},
|
||||
{
|
||||
anonymous: false,
|
||||
inputs: [
|
||||
{
|
||||
indexed: false,
|
||||
internalType: "address",
|
||||
name: "user",
|
||||
name: "erc20",
|
||||
type: "address",
|
||||
},
|
||||
],
|
||||
name: "addApprovalList",
|
||||
name: "RemoveERC20Suppout",
|
||||
type: "event",
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: "MAX_TRANSACTION_FEE",
|
||||
outputs: [
|
||||
{
|
||||
internalType: "uint256",
|
||||
name: "",
|
||||
type: "uint256",
|
||||
},
|
||||
],
|
||||
stateMutability: "view",
|
||||
type: "function",
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: "MIN_TRANSACTION_FEE",
|
||||
outputs: [
|
||||
{
|
||||
internalType: "uint256",
|
||||
name: "",
|
||||
type: "uint256",
|
||||
},
|
||||
],
|
||||
stateMutability: "view",
|
||||
type: "function",
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: "address",
|
||||
name: "erc20",
|
||||
type: "address",
|
||||
},
|
||||
],
|
||||
name: "addERC20Support",
|
||||
outputs: [],
|
||||
stateMutability: "nonpayable",
|
||||
type: "function",
|
||||
@ -140,7 +149,6 @@ export let abiNftMall: AbiItem[] = [
|
||||
outputs: [],
|
||||
stateMutability: "pure",
|
||||
type: "function",
|
||||
constant: true,
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
@ -164,7 +172,38 @@ export let abiNftMall: AbiItem[] = [
|
||||
outputs: [],
|
||||
stateMutability: "view",
|
||||
type: "function",
|
||||
constant: true,
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: "address",
|
||||
name: "",
|
||||
type: "address",
|
||||
},
|
||||
],
|
||||
name: "erc20Supported",
|
||||
outputs: [
|
||||
{
|
||||
internalType: "bool",
|
||||
name: "",
|
||||
type: "bool",
|
||||
},
|
||||
],
|
||||
stateMutability: "view",
|
||||
type: "function",
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: "executor",
|
||||
outputs: [
|
||||
{
|
||||
internalType: "address",
|
||||
name: "",
|
||||
type: "address",
|
||||
},
|
||||
],
|
||||
stateMutability: "view",
|
||||
type: "function",
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
@ -178,7 +217,6 @@ export let abiNftMall: AbiItem[] = [
|
||||
],
|
||||
stateMutability: "view",
|
||||
type: "function",
|
||||
constant: true,
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
@ -192,27 +230,25 @@ export let abiNftMall: AbiItem[] = [
|
||||
],
|
||||
stateMutability: "view",
|
||||
type: "function",
|
||||
constant: true,
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: "uint256",
|
||||
name: "",
|
||||
type: "uint256",
|
||||
},
|
||||
],
|
||||
name: "orderIdUsed",
|
||||
outputs: [
|
||||
{
|
||||
internalType: "address",
|
||||
name: "",
|
||||
type: "address",
|
||||
},
|
||||
],
|
||||
name: "nftTokenSupported",
|
||||
outputs: [
|
||||
{
|
||||
internalType: "bool",
|
||||
name: "",
|
||||
type: "bool",
|
||||
},
|
||||
],
|
||||
stateMutability: "view",
|
||||
type: "function",
|
||||
constant: true,
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
@ -226,37 +262,16 @@ export let abiNftMall: AbiItem[] = [
|
||||
],
|
||||
stateMutability: "view",
|
||||
type: "function",
|
||||
constant: true,
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: "address",
|
||||
name: "",
|
||||
name: "erc20",
|
||||
type: "address",
|
||||
},
|
||||
],
|
||||
name: "paymentTokens",
|
||||
outputs: [
|
||||
{
|
||||
internalType: "bool",
|
||||
name: "",
|
||||
type: "bool",
|
||||
},
|
||||
],
|
||||
stateMutability: "view",
|
||||
type: "function",
|
||||
constant: true,
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: "address",
|
||||
name: "user",
|
||||
type: "address",
|
||||
},
|
||||
],
|
||||
name: "removeApprovalList",
|
||||
name: "removeERC20Support",
|
||||
outputs: [],
|
||||
stateMutability: "nonpayable",
|
||||
type: "function",
|
||||
@ -268,6 +283,32 @@ export let abiNftMall: AbiItem[] = [
|
||||
stateMutability: "nonpayable",
|
||||
type: "function",
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: "address",
|
||||
name: "_feeToAddress",
|
||||
type: "address",
|
||||
},
|
||||
],
|
||||
name: "setFeeToAddress",
|
||||
outputs: [],
|
||||
stateMutability: "nonpayable",
|
||||
type: "function",
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: "transactionFee",
|
||||
outputs: [
|
||||
{
|
||||
internalType: "uint256",
|
||||
name: "",
|
||||
type: "uint256",
|
||||
},
|
||||
],
|
||||
stateMutability: "view",
|
||||
type: "function",
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
@ -294,48 +335,15 @@ export let abiNftMall: AbiItem[] = [
|
||||
stateMutability: "nonpayable",
|
||||
type: "function",
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: "bytes",
|
||||
name: "signature",
|
||||
type: "bytes",
|
||||
},
|
||||
],
|
||||
name: "useSignature",
|
||||
outputs: [],
|
||||
stateMutability: "nonpayable",
|
||||
type: "function",
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: "bytes",
|
||||
name: "",
|
||||
type: "bytes",
|
||||
},
|
||||
],
|
||||
name: "usedSignatures",
|
||||
outputs: [
|
||||
{
|
||||
internalType: "bool",
|
||||
name: "",
|
||||
type: "bool",
|
||||
},
|
||||
],
|
||||
stateMutability: "view",
|
||||
type: "function",
|
||||
constant: true,
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: "address",
|
||||
name: "_feeToAddress",
|
||||
name: "account",
|
||||
type: "address",
|
||||
},
|
||||
],
|
||||
name: "setFeeToAddress",
|
||||
name: "updateExecutor",
|
||||
outputs: [],
|
||||
stateMutability: "nonpayable",
|
||||
type: "function",
|
||||
@ -343,66 +351,34 @@ export let abiNftMall: AbiItem[] = [
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: "address[]",
|
||||
name: "_paymentTokens",
|
||||
type: "address[]",
|
||||
internalType: "uint256",
|
||||
name: "orderId",
|
||||
type: "uint256",
|
||||
},
|
||||
],
|
||||
name: "setPaymentTokens",
|
||||
outputs: [],
|
||||
stateMutability: "nonpayable",
|
||||
type: "function",
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: "address[]",
|
||||
name: "_removedPaymentTokens",
|
||||
type: "address[]",
|
||||
},
|
||||
],
|
||||
name: "removePaymentTokens",
|
||||
outputs: [],
|
||||
stateMutability: "nonpayable",
|
||||
type: "function",
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: "address",
|
||||
name: "nftToken",
|
||||
name: "seller",
|
||||
type: "address",
|
||||
},
|
||||
],
|
||||
name: "addNFTTokenSupport",
|
||||
outputs: [],
|
||||
stateMutability: "nonpayable",
|
||||
type: "function",
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: "address",
|
||||
name: "nftToken",
|
||||
name: "currency",
|
||||
type: "address",
|
||||
},
|
||||
],
|
||||
name: "removeNFTTokenSupport",
|
||||
outputs: [],
|
||||
stateMutability: "nonpayable",
|
||||
type: "function",
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: "address[4]",
|
||||
name: "addresses",
|
||||
type: "address[4]",
|
||||
internalType: "uint256",
|
||||
name: "price",
|
||||
type: "uint256",
|
||||
},
|
||||
{
|
||||
internalType: "uint256[]",
|
||||
name: "signArray",
|
||||
type: "uint256[]",
|
||||
internalType: "uint256",
|
||||
name: "startTime",
|
||||
type: "uint256",
|
||||
},
|
||||
{
|
||||
internalType: "uint256",
|
||||
name: "saltNonce",
|
||||
type: "uint256",
|
||||
},
|
||||
{
|
||||
internalType: "bytes",
|
||||
@ -410,7 +386,7 @@ export let abiNftMall: AbiItem[] = [
|
||||
type: "bytes",
|
||||
},
|
||||
],
|
||||
name: "ignoreSignature",
|
||||
name: "buy",
|
||||
outputs: [],
|
||||
stateMutability: "nonpayable",
|
||||
type: "function",
|
||||
@ -418,55 +394,12 @@ export let abiNftMall: AbiItem[] = [
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: "address[3]",
|
||||
name: "addresses",
|
||||
type: "address[3]",
|
||||
},
|
||||
{
|
||||
internalType: "uint256[4]",
|
||||
name: "values",
|
||||
type: "uint256[4]",
|
||||
},
|
||||
{
|
||||
internalType: "bytes",
|
||||
name: "signature",
|
||||
type: "bytes",
|
||||
internalType: "uint256",
|
||||
name: "_transactionFee",
|
||||
type: "uint256",
|
||||
},
|
||||
],
|
||||
name: "buy721NFT",
|
||||
outputs: [],
|
||||
stateMutability: "nonpayable",
|
||||
type: "function",
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: "address[3]",
|
||||
name: "addresses",
|
||||
type: "address[3]",
|
||||
},
|
||||
{
|
||||
internalType: "uint256[3]",
|
||||
name: "values",
|
||||
type: "uint256[3]",
|
||||
},
|
||||
{
|
||||
internalType: "uint256[]",
|
||||
name: "ids",
|
||||
type: "uint256[]",
|
||||
},
|
||||
{
|
||||
internalType: "uint256[]",
|
||||
name: "amounts",
|
||||
type: "uint256[]",
|
||||
},
|
||||
{
|
||||
internalType: "bytes",
|
||||
name: "signature",
|
||||
type: "bytes",
|
||||
},
|
||||
],
|
||||
name: "buy1155NFT",
|
||||
name: "setTransactionFee",
|
||||
outputs: [],
|
||||
stateMutability: "nonpayable",
|
||||
type: "function",
|
||||
@ -475,23 +408,38 @@ export let abiNftMall: AbiItem[] = [
|
||||
inputs: [
|
||||
{
|
||||
internalType: "address",
|
||||
name: "_nftAddress",
|
||||
name: "_buyer",
|
||||
type: "address",
|
||||
},
|
||||
{
|
||||
internalType: "address",
|
||||
name: "_tokenAddress",
|
||||
name: "_seller",
|
||||
type: "address",
|
||||
},
|
||||
{
|
||||
internalType: "uint256",
|
||||
name: "_orderId",
|
||||
type: "uint256",
|
||||
},
|
||||
{
|
||||
internalType: "address",
|
||||
name: "_buyerAddress",
|
||||
name: "_currency",
|
||||
type: "address",
|
||||
},
|
||||
{
|
||||
internalType: "uint256[]",
|
||||
name: "_datas",
|
||||
type: "uint256[]",
|
||||
internalType: "uint256",
|
||||
name: "_price",
|
||||
type: "uint256",
|
||||
},
|
||||
{
|
||||
internalType: "uint256",
|
||||
name: "_startTime",
|
||||
type: "uint256",
|
||||
},
|
||||
{
|
||||
internalType: "uint256",
|
||||
name: "_saltNonce",
|
||||
type: "uint256",
|
||||
},
|
||||
],
|
||||
name: "getMessageHash",
|
||||
@ -504,6 +452,5 @@ export let abiNftMall: AbiItem[] = [
|
||||
],
|
||||
stateMutability: "pure",
|
||||
type: "function",
|
||||
constant: true,
|
||||
},
|
||||
];
|
493
src/abis/abiMall.ts
Normal file
493
src/abis/abiMall.ts
Normal file
@ -0,0 +1,493 @@
|
||||
import { AbiItem } from 'web3-utils';
|
||||
|
||||
export let abiMall: AbiItem[] = [
|
||||
{
|
||||
inputs: [],
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'constructor',
|
||||
},
|
||||
{
|
||||
anonymous: false,
|
||||
inputs: [
|
||||
{
|
||||
indexed: false,
|
||||
internalType: 'address',
|
||||
name: 'erc20',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
name: 'AddERC20Suppout',
|
||||
type: 'event',
|
||||
},
|
||||
{
|
||||
anonymous: false,
|
||||
inputs: [
|
||||
{
|
||||
indexed: false,
|
||||
internalType: 'address',
|
||||
name: 'nftToken',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
name: 'AddNFTSuppout',
|
||||
type: 'event',
|
||||
},
|
||||
{
|
||||
anonymous: false,
|
||||
inputs: [
|
||||
{
|
||||
indexed: true,
|
||||
internalType: 'address',
|
||||
name: 'buyer',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
indexed: true,
|
||||
internalType: 'uint256',
|
||||
name: 'orderId',
|
||||
type: 'uint256',
|
||||
},
|
||||
{
|
||||
indexed: false,
|
||||
internalType: 'address',
|
||||
name: 'currency',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
indexed: false,
|
||||
internalType: 'uint256',
|
||||
name: 'price',
|
||||
type: 'uint256',
|
||||
},
|
||||
{
|
||||
indexed: false,
|
||||
internalType: 'address[]',
|
||||
name: 'nftAddresses',
|
||||
type: 'address[]',
|
||||
},
|
||||
{
|
||||
indexed: false,
|
||||
internalType: 'uint256[]',
|
||||
name: 'ids',
|
||||
type: 'uint256[]',
|
||||
},
|
||||
{
|
||||
indexed: false,
|
||||
internalType: 'uint256[]',
|
||||
name: 'amounts',
|
||||
type: 'uint256[]',
|
||||
},
|
||||
],
|
||||
name: 'BuyTransaction',
|
||||
type: 'event',
|
||||
},
|
||||
{
|
||||
anonymous: false,
|
||||
inputs: [
|
||||
{
|
||||
indexed: true,
|
||||
internalType: 'address',
|
||||
name: 'previousOwner',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
indexed: true,
|
||||
internalType: 'address',
|
||||
name: 'newOwner',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
name: 'OwnershipTransferred',
|
||||
type: 'event',
|
||||
},
|
||||
{
|
||||
anonymous: false,
|
||||
inputs: [
|
||||
{
|
||||
indexed: false,
|
||||
internalType: 'address',
|
||||
name: 'erc20',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
name: 'RemoveERC20Suppout',
|
||||
type: 'event',
|
||||
},
|
||||
{
|
||||
anonymous: false,
|
||||
inputs: [
|
||||
{
|
||||
indexed: false,
|
||||
internalType: 'address',
|
||||
name: 'nftToken',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
name: 'RemoveNFTSuppout',
|
||||
type: 'event',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: 'erc20',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
name: 'addERC20Support',
|
||||
outputs: [],
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: 'signer',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
internalType: 'bytes32',
|
||||
name: 'hash',
|
||||
type: 'bytes32',
|
||||
},
|
||||
{
|
||||
internalType: 'bytes',
|
||||
name: 'signature',
|
||||
type: 'bytes',
|
||||
},
|
||||
],
|
||||
name: 'checkSigner',
|
||||
outputs: [],
|
||||
stateMutability: 'pure',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: 'signer',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
internalType: 'bytes32',
|
||||
name: 'structHash',
|
||||
type: 'bytes32',
|
||||
},
|
||||
{
|
||||
internalType: 'bytes',
|
||||
name: 'signature',
|
||||
type: 'bytes',
|
||||
},
|
||||
],
|
||||
name: 'checkSigner712',
|
||||
outputs: [],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: '',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
name: 'erc1155Supported',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'bool',
|
||||
name: '',
|
||||
type: 'bool',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: '',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
name: 'erc20Supported',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'bool',
|
||||
name: '',
|
||||
type: 'bool',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: '',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
name: 'erc721Supported',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'bool',
|
||||
name: '',
|
||||
type: 'bool',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: 'executor',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: '',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: 'feeToAddress',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: '',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: 'getDuration',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: 'duration',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: 'owner',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: '',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: 'erc20',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
name: 'removeERC20Support',
|
||||
outputs: [],
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: 'renounceOwnership',
|
||||
outputs: [],
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: '_feeToAddress',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
name: 'setFeeToAddress',
|
||||
outputs: [],
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: 'newOwner',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
name: 'transferOwnership',
|
||||
outputs: [],
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: 'valNew',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
name: 'updateDuation',
|
||||
outputs: [],
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: 'account',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
name: 'updateExecutor',
|
||||
outputs: [],
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: 'nftToken',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
name: 'addERC721Support',
|
||||
outputs: [],
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: 'nftToken',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
name: 'removeERC721Support',
|
||||
outputs: [],
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: 'nftToken',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
name: 'addERC1155Support',
|
||||
outputs: [],
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: 'nftToken',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
name: 'removeERC1155Support',
|
||||
outputs: [],
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: 'currency',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
internalType: 'address[]',
|
||||
name: 'nftAddresses',
|
||||
type: 'address[]',
|
||||
},
|
||||
{
|
||||
internalType: 'uint256[]',
|
||||
name: 'ids',
|
||||
type: 'uint256[]',
|
||||
},
|
||||
{
|
||||
internalType: 'uint256[]',
|
||||
name: 'amounts',
|
||||
type: 'uint256[]',
|
||||
},
|
||||
{
|
||||
internalType: 'uint256[]',
|
||||
name: 'values',
|
||||
type: 'uint256[]',
|
||||
},
|
||||
{
|
||||
internalType: 'bytes',
|
||||
name: 'signature',
|
||||
type: 'bytes',
|
||||
},
|
||||
],
|
||||
name: 'buyNFT',
|
||||
outputs: [],
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: '_tokenAddress',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
internalType: 'address',
|
||||
name: '_buyerAddress',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
internalType: 'address[]',
|
||||
name: '_nftAddresses',
|
||||
type: 'address[]',
|
||||
},
|
||||
{
|
||||
internalType: 'uint256[]',
|
||||
name: '_datas',
|
||||
type: 'uint256[]',
|
||||
},
|
||||
],
|
||||
name: 'getMessageHash',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'bytes32',
|
||||
name: '',
|
||||
type: 'bytes32',
|
||||
},
|
||||
],
|
||||
stateMutability: 'pure',
|
||||
type: 'function',
|
||||
},
|
||||
];
|
978
src/abis/abiMarket.ts
Normal file
978
src/abis/abiMarket.ts
Normal file
@ -0,0 +1,978 @@
|
||||
import { AbiItem } from 'web3-utils';
|
||||
|
||||
export let abiMarket: AbiItem[] = [
|
||||
{
|
||||
anonymous: false,
|
||||
inputs: [
|
||||
{
|
||||
indexed: false,
|
||||
internalType: 'address',
|
||||
name: 'erc20',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
name: 'AddERC20Suppout',
|
||||
type: 'event',
|
||||
},
|
||||
{
|
||||
anonymous: false,
|
||||
inputs: [
|
||||
{
|
||||
indexed: false,
|
||||
internalType: 'address',
|
||||
name: 'nftToken',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
name: 'AddNFTSuppout',
|
||||
type: 'event',
|
||||
},
|
||||
{
|
||||
anonymous: false,
|
||||
inputs: [
|
||||
{
|
||||
indexed: true,
|
||||
internalType: 'uint256',
|
||||
name: 'tokenId',
|
||||
type: 'uint256',
|
||||
},
|
||||
{
|
||||
indexed: false,
|
||||
internalType: 'uint256',
|
||||
name: 'orderId',
|
||||
type: 'uint256',
|
||||
},
|
||||
{
|
||||
indexed: false,
|
||||
internalType: 'address',
|
||||
name: 'nftToken',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
indexed: false,
|
||||
internalType: 'uint256',
|
||||
name: 'amount',
|
||||
type: 'uint256',
|
||||
},
|
||||
{
|
||||
indexed: false,
|
||||
internalType: 'address',
|
||||
name: 'seller',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
indexed: false,
|
||||
internalType: 'address',
|
||||
name: 'buyer',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
indexed: false,
|
||||
internalType: 'address',
|
||||
name: 'erc20',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
indexed: false,
|
||||
internalType: 'uint256',
|
||||
name: 'price',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
name: 'BuyOrder',
|
||||
type: 'event',
|
||||
},
|
||||
{
|
||||
anonymous: false,
|
||||
inputs: [
|
||||
{
|
||||
indexed: true,
|
||||
internalType: 'uint256',
|
||||
name: 'orderId',
|
||||
type: 'uint256',
|
||||
},
|
||||
{
|
||||
indexed: true,
|
||||
internalType: 'address',
|
||||
name: 'nftToken',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
indexed: true,
|
||||
internalType: 'uint256',
|
||||
name: 'tokenId',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
name: 'CancelOrder',
|
||||
type: 'event',
|
||||
},
|
||||
{
|
||||
anonymous: false,
|
||||
inputs: [
|
||||
{
|
||||
indexed: true,
|
||||
internalType: 'address',
|
||||
name: 'previousOwner',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
indexed: true,
|
||||
internalType: 'address',
|
||||
name: 'newOwner',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
name: 'OwnershipTransferred',
|
||||
type: 'event',
|
||||
},
|
||||
{
|
||||
anonymous: false,
|
||||
inputs: [
|
||||
{
|
||||
indexed: true,
|
||||
internalType: 'uint256',
|
||||
name: 'orderId',
|
||||
type: 'uint256',
|
||||
},
|
||||
{
|
||||
indexed: true,
|
||||
internalType: 'address',
|
||||
name: 'nftToken',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
indexed: true,
|
||||
internalType: 'uint256',
|
||||
name: 'tokenId',
|
||||
type: 'uint256',
|
||||
},
|
||||
{
|
||||
indexed: false,
|
||||
internalType: 'uint256',
|
||||
name: 'priceOld',
|
||||
type: 'uint256',
|
||||
},
|
||||
{
|
||||
indexed: false,
|
||||
internalType: 'uint256',
|
||||
name: 'price',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
name: 'PriceUpdate',
|
||||
type: 'event',
|
||||
},
|
||||
{
|
||||
anonymous: false,
|
||||
inputs: [
|
||||
{
|
||||
indexed: false,
|
||||
internalType: 'address',
|
||||
name: 'erc20',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
name: 'RemoveERC20Suppout',
|
||||
type: 'event',
|
||||
},
|
||||
{
|
||||
anonymous: false,
|
||||
inputs: [
|
||||
{
|
||||
indexed: false,
|
||||
internalType: 'address',
|
||||
name: 'nftToken',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
name: 'RemoveNFTSuppout',
|
||||
type: 'event',
|
||||
},
|
||||
{
|
||||
anonymous: false,
|
||||
inputs: [
|
||||
{
|
||||
indexed: true,
|
||||
internalType: 'uint256',
|
||||
name: 'tokenId',
|
||||
type: 'uint256',
|
||||
},
|
||||
{
|
||||
indexed: true,
|
||||
internalType: 'address',
|
||||
name: 'owner',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
indexed: true,
|
||||
internalType: 'address',
|
||||
name: 'nftToken',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
indexed: false,
|
||||
internalType: 'uint256',
|
||||
name: 'amount',
|
||||
type: 'uint256',
|
||||
},
|
||||
{
|
||||
indexed: false,
|
||||
internalType: 'uint256',
|
||||
name: 'orderId',
|
||||
type: 'uint256',
|
||||
},
|
||||
{
|
||||
indexed: false,
|
||||
internalType: 'address',
|
||||
name: 'currency',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
indexed: false,
|
||||
internalType: 'uint256',
|
||||
name: 'price',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
name: 'SellOrder',
|
||||
type: 'event',
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: 'MAX_TRANSACTION_FEE',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: '',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: 'MAX_TRANSACTION_TAX',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: '',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: 'MIN_TRANSACTION_FEE',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: '',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: 'MIN_TRANSACTION_TAX',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: '',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: '',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
name: 'erc1155Supported',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'bool',
|
||||
name: '',
|
||||
type: 'bool',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: '',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
name: 'erc1155SupportedHistory',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'bool',
|
||||
name: '',
|
||||
type: 'bool',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: '',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
name: 'erc20Supported',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'bool',
|
||||
name: '',
|
||||
type: 'bool',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: '',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
name: 'erc721Supported',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'bool',
|
||||
name: '',
|
||||
type: 'bool',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: '',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
name: 'erc721SupportedHistory',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'bool',
|
||||
name: '',
|
||||
type: 'bool',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: 'feeToAddress',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: '',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: 'incrId',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: '',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: '',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
name: 'nftPriceMaxLimit',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: '',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: '',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
name: 'nftPriceMinLimit',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: '',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: '',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
internalType: 'address',
|
||||
name: '',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
internalType: 'uint256[]',
|
||||
name: '',
|
||||
type: 'uint256[]',
|
||||
},
|
||||
{
|
||||
internalType: 'uint256[]',
|
||||
name: '',
|
||||
type: 'uint256[]',
|
||||
},
|
||||
{
|
||||
internalType: 'bytes',
|
||||
name: '',
|
||||
type: 'bytes',
|
||||
},
|
||||
],
|
||||
name: 'onERC1155BatchReceived',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'bytes4',
|
||||
name: '',
|
||||
type: 'bytes4',
|
||||
},
|
||||
],
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: '',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
internalType: 'address',
|
||||
name: '',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: '',
|
||||
type: 'uint256',
|
||||
},
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: '',
|
||||
type: 'uint256',
|
||||
},
|
||||
{
|
||||
internalType: 'bytes',
|
||||
name: '',
|
||||
type: 'bytes',
|
||||
},
|
||||
],
|
||||
name: 'onERC1155Received',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'bytes4',
|
||||
name: '',
|
||||
type: 'bytes4',
|
||||
},
|
||||
],
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: '',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
internalType: 'address',
|
||||
name: '',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: '',
|
||||
type: 'uint256',
|
||||
},
|
||||
{
|
||||
internalType: 'bytes',
|
||||
name: '',
|
||||
type: 'bytes',
|
||||
},
|
||||
],
|
||||
name: 'onERC721Received',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'bytes4',
|
||||
name: '',
|
||||
type: 'bytes4',
|
||||
},
|
||||
],
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: '',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
name: 'orderInfos',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: 'orderId',
|
||||
type: 'uint256',
|
||||
},
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: 'tokenId',
|
||||
type: 'uint256',
|
||||
},
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: 'amount',
|
||||
type: 'uint256',
|
||||
},
|
||||
{
|
||||
internalType: 'address',
|
||||
name: 'owner',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: 'price',
|
||||
type: 'uint256',
|
||||
},
|
||||
{
|
||||
internalType: 'address',
|
||||
name: 'nftToken',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
internalType: 'address',
|
||||
name: 'currency',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: 'owner',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: '',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: 'renounceOwnership',
|
||||
outputs: [],
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'bytes4',
|
||||
name: 'interfaceId',
|
||||
type: 'bytes4',
|
||||
},
|
||||
],
|
||||
name: 'supportsInterface',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'bool',
|
||||
name: '',
|
||||
type: 'bool',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: 'taxToAddress',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: '',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: 'tranFeeTotal',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: '',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: 'tranTaxTotal',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: '',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: 'transactionFee',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: '',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: 'transactionTax',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: '',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: 'newOwner',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
name: 'transferOwnership',
|
||||
outputs: [],
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: 'nftToken',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
internalType: 'address',
|
||||
name: 'currency',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: 'tokenId',
|
||||
type: 'uint256',
|
||||
},
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: 'price',
|
||||
type: 'uint256',
|
||||
},
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: 'amount',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
name: 'sell',
|
||||
outputs: [],
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: 'orderId',
|
||||
type: 'uint256',
|
||||
},
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: 'price',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
name: 'buy',
|
||||
outputs: [],
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: 'orderId',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
name: 'cancelOrder',
|
||||
outputs: [],
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: 'orderId',
|
||||
type: 'uint256',
|
||||
},
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: 'price',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
name: 'updatePrice',
|
||||
outputs: [],
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: 'nftToken',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
name: 'addERC721Support',
|
||||
outputs: [],
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: 'nftToken',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
name: 'removeERC721Support',
|
||||
outputs: [],
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: 'nftToken',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
name: 'addERC1155Support',
|
||||
outputs: [],
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: 'nftToken',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
name: 'removeERC1155Support',
|
||||
outputs: [],
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: 'erc20',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
name: 'addERC20Support',
|
||||
outputs: [],
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: 'erc20',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
name: 'removeERC20Support',
|
||||
outputs: [],
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: 'nftToken',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: 'maxLimit',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
name: 'setNFTPriceMaxLimit',
|
||||
outputs: [],
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: 'nftToken',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: 'minLimit',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
name: 'setNFTPriceMinLimit',
|
||||
outputs: [],
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: '_transactionFee',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
name: 'setTransactionFee',
|
||||
outputs: [],
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: '_feeToAddress',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
name: 'setFeeToAddress',
|
||||
outputs: [],
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: '_transactionTax',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
name: 'setTransactionTax',
|
||||
outputs: [],
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: '_taxToAddress',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
name: 'setTaxToAddress',
|
||||
outputs: [],
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'function',
|
||||
},
|
||||
];
|
390
src/abis/abiTokenMall.ts
Normal file
390
src/abis/abiTokenMall.ts
Normal file
@ -0,0 +1,390 @@
|
||||
import { AbiItem } from 'web3-utils';
|
||||
|
||||
export let abiTokenMall: AbiItem[] = [
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: '_tokenAddress',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
internalType: 'address',
|
||||
name: '_seller',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'constructor',
|
||||
},
|
||||
{
|
||||
anonymous: false,
|
||||
inputs: [
|
||||
{
|
||||
indexed: false,
|
||||
internalType: 'address',
|
||||
name: 'erc20',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
name: 'AddERC20Suppout',
|
||||
type: 'event',
|
||||
},
|
||||
{
|
||||
anonymous: false,
|
||||
inputs: [
|
||||
{
|
||||
indexed: true,
|
||||
internalType: 'address',
|
||||
name: 'buyer',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
indexed: false,
|
||||
internalType: 'address',
|
||||
name: 'tokenAddress',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
indexed: false,
|
||||
internalType: 'address',
|
||||
name: 'currency',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
indexed: false,
|
||||
internalType: 'uint256',
|
||||
name: 'amount',
|
||||
type: 'uint256',
|
||||
},
|
||||
{
|
||||
indexed: false,
|
||||
internalType: 'uint256',
|
||||
name: 'tokenAmount',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
name: 'BuyTransaction',
|
||||
type: 'event',
|
||||
},
|
||||
{
|
||||
anonymous: false,
|
||||
inputs: [
|
||||
{
|
||||
indexed: true,
|
||||
internalType: 'address',
|
||||
name: 'previousOwner',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
indexed: true,
|
||||
internalType: 'address',
|
||||
name: 'newOwner',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
name: 'OwnershipTransferred',
|
||||
type: 'event',
|
||||
},
|
||||
{
|
||||
anonymous: false,
|
||||
inputs: [
|
||||
{
|
||||
indexed: false,
|
||||
internalType: 'address',
|
||||
name: 'erc20',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
name: 'RemoveERC20Suppout',
|
||||
type: 'event',
|
||||
},
|
||||
{
|
||||
anonymous: false,
|
||||
inputs: [
|
||||
{
|
||||
indexed: false,
|
||||
internalType: 'address',
|
||||
name: 'seller',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
name: 'SellerUpdated',
|
||||
type: 'event',
|
||||
},
|
||||
{
|
||||
anonymous: false,
|
||||
inputs: [
|
||||
{
|
||||
indexed: false,
|
||||
internalType: 'address',
|
||||
name: 'tokenAddress',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
name: 'TokenAddressUpdated',
|
||||
type: 'event',
|
||||
},
|
||||
{
|
||||
anonymous: false,
|
||||
inputs: [
|
||||
{
|
||||
indexed: false,
|
||||
internalType: 'address',
|
||||
name: 'currency',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
indexed: false,
|
||||
internalType: 'uint256',
|
||||
name: 'price',
|
||||
type: 'uint256',
|
||||
},
|
||||
{
|
||||
indexed: false,
|
||||
internalType: 'uint256',
|
||||
name: 'pricePre',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
name: 'UpdateTokenPrice',
|
||||
type: 'event',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: 'erc20',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
name: 'addERC20Support',
|
||||
outputs: [],
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: '',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
name: 'erc20Supported',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'bool',
|
||||
name: '',
|
||||
type: 'bool',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: 'executor',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: '',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: 'feeToAddress',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: '',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: 'owner',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: '',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: '',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
name: 'prices',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: '',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: 'erc20',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
name: 'removeERC20Support',
|
||||
outputs: [],
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: 'renounceOwnership',
|
||||
outputs: [],
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: 'seller',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: '',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: '_feeToAddress',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
name: 'setFeeToAddress',
|
||||
outputs: [],
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: 'tokenAddress',
|
||||
outputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: '',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: 'newOwner',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
name: 'transferOwnership',
|
||||
outputs: [],
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: 'account',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
name: 'updateExecutor',
|
||||
outputs: [],
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: '_tokenAddress',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
name: 'updateTokenAddress',
|
||||
outputs: [],
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: '_seller',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
name: 'updateSeller',
|
||||
outputs: [],
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: 'currency',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: 'price',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
name: 'updateTokenPrice',
|
||||
outputs: [],
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: 'address',
|
||||
name: 'currency',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
internalType: 'uint256',
|
||||
name: 'amount',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
name: 'buyToken',
|
||||
outputs: [],
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'function',
|
||||
},
|
||||
];
|
@ -1,6 +1,11 @@
|
||||
import { AbiItem } from "web3-utils";
|
||||
|
||||
export let abiMinterFactory: AbiItem[] = [
|
||||
{
|
||||
inputs: [],
|
||||
stateMutability: "nonpayable",
|
||||
type: "constructor",
|
||||
},
|
||||
{
|
||||
anonymous: false,
|
||||
inputs: [
|
||||
@ -23,6 +28,12 @@ export let abiMinterFactory: AbiItem[] = [
|
||||
{
|
||||
anonymous: false,
|
||||
inputs: [
|
||||
{
|
||||
indexed: true,
|
||||
internalType: "address",
|
||||
name: "nftAddress",
|
||||
type: "address",
|
||||
},
|
||||
{
|
||||
indexed: true,
|
||||
internalType: "address",
|
||||
@ -37,67 +48,91 @@ export let abiMinterFactory: AbiItem[] = [
|
||||
},
|
||||
{
|
||||
indexed: false,
|
||||
internalType: "uint256",
|
||||
name: "startTime",
|
||||
type: "uint256",
|
||||
},
|
||||
{
|
||||
indexed: false,
|
||||
internalType: "uint256[]",
|
||||
name: "ids",
|
||||
type: "uint256[]",
|
||||
},
|
||||
],
|
||||
name: "TokenMinted",
|
||||
type: "event",
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: "address",
|
||||
name: "signer",
|
||||
type: "address",
|
||||
},
|
||||
{
|
||||
internalType: "bytes32",
|
||||
name: "hash",
|
||||
type: "bytes32",
|
||||
},
|
||||
{
|
||||
internalType: "bytes",
|
||||
name: "signature",
|
||||
type: "bytes",
|
||||
},
|
||||
],
|
||||
name: "checkSigner",
|
||||
outputs: [],
|
||||
stateMutability: "pure",
|
||||
type: "function",
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
indexed: false,
|
||||
internalType: "string",
|
||||
name: "reason",
|
||||
type: "string",
|
||||
internalType: "address",
|
||||
name: "signer",
|
||||
type: "address",
|
||||
},
|
||||
{
|
||||
internalType: "bytes32",
|
||||
name: "structHash",
|
||||
type: "bytes32",
|
||||
},
|
||||
{
|
||||
indexed: false,
|
||||
internalType: "bytes",
|
||||
name: "byteReason",
|
||||
name: "signature",
|
||||
type: "bytes",
|
||||
},
|
||||
],
|
||||
name: "TokenMintFail",
|
||||
type: "event",
|
||||
name: "checkSigner712",
|
||||
outputs: [],
|
||||
stateMutability: "view",
|
||||
type: "function",
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: "chip",
|
||||
name: "executor",
|
||||
outputs: [
|
||||
{
|
||||
internalType: "contract IBEERC1155",
|
||||
internalType: "address",
|
||||
name: "",
|
||||
type: "address",
|
||||
},
|
||||
],
|
||||
stateMutability: "view",
|
||||
type: "function",
|
||||
constant: true,
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: "equip",
|
||||
name: "getDuration",
|
||||
outputs: [
|
||||
{
|
||||
internalType: "contract IBEERC721",
|
||||
name: "",
|
||||
type: "address",
|
||||
internalType: "uint256",
|
||||
name: "duration",
|
||||
type: "uint256",
|
||||
},
|
||||
],
|
||||
stateMutability: "view",
|
||||
type: "function",
|
||||
constant: true,
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: "hero",
|
||||
outputs: [
|
||||
{
|
||||
internalType: "contract IBEERC721",
|
||||
name: "",
|
||||
type: "address",
|
||||
},
|
||||
],
|
||||
stateMutability: "view",
|
||||
type: "function",
|
||||
constant: true,
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
@ -111,7 +146,6 @@ export let abiMinterFactory: AbiItem[] = [
|
||||
],
|
||||
stateMutability: "view",
|
||||
type: "function",
|
||||
constant: true,
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
@ -121,18 +155,23 @@ export let abiMinterFactory: AbiItem[] = [
|
||||
type: "function",
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: "shard",
|
||||
outputs: [
|
||||
inputs: [
|
||||
{
|
||||
internalType: "contract IBEERC1155",
|
||||
internalType: "address",
|
||||
name: "",
|
||||
type: "address",
|
||||
},
|
||||
],
|
||||
name: "tokenSupported",
|
||||
outputs: [
|
||||
{
|
||||
internalType: "bool",
|
||||
name: "",
|
||||
type: "bool",
|
||||
},
|
||||
],
|
||||
stateMutability: "view",
|
||||
type: "function",
|
||||
constant: true,
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
@ -150,12 +189,12 @@ export let abiMinterFactory: AbiItem[] = [
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: "address[5]",
|
||||
name: "addressArr",
|
||||
type: "address[5]",
|
||||
internalType: "uint256",
|
||||
name: "valNew",
|
||||
type: "uint256",
|
||||
},
|
||||
],
|
||||
name: "init",
|
||||
name: "updateDuation",
|
||||
outputs: [],
|
||||
stateMutability: "nonpayable",
|
||||
type: "function",
|
||||
@ -163,76 +202,13 @@ export let abiMinterFactory: AbiItem[] = [
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: "uint256",
|
||||
name: "tokenId",
|
||||
type: "uint256",
|
||||
internalType: "address",
|
||||
name: "nftAddress",
|
||||
type: "address",
|
||||
},
|
||||
{
|
||||
internalType: "uint256",
|
||||
name: "startTime",
|
||||
type: "uint256",
|
||||
},
|
||||
{
|
||||
internalType: "uint256",
|
||||
name: "saltNonce",
|
||||
type: "uint256",
|
||||
},
|
||||
{
|
||||
internalType: "bytes",
|
||||
name: "signature",
|
||||
type: "bytes",
|
||||
},
|
||||
],
|
||||
name: "mintHeroUser",
|
||||
outputs: [
|
||||
{
|
||||
internalType: "bool",
|
||||
name: "success",
|
||||
type: "bool",
|
||||
},
|
||||
],
|
||||
stateMutability: "nonpayable",
|
||||
type: "function",
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: "uint256",
|
||||
name: "tokenId",
|
||||
type: "uint256",
|
||||
},
|
||||
{
|
||||
internalType: "uint256",
|
||||
name: "startTime",
|
||||
type: "uint256",
|
||||
},
|
||||
{
|
||||
internalType: "uint256",
|
||||
name: "saltNonce",
|
||||
type: "uint256",
|
||||
},
|
||||
{
|
||||
internalType: "bytes",
|
||||
name: "signature",
|
||||
type: "bytes",
|
||||
},
|
||||
],
|
||||
name: "mintEquipUser",
|
||||
outputs: [
|
||||
{
|
||||
internalType: "bool",
|
||||
name: "success",
|
||||
type: "bool",
|
||||
},
|
||||
],
|
||||
stateMutability: "nonpayable",
|
||||
type: "function",
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: "uint256[]",
|
||||
name: "ids",
|
||||
name: "tokenIds",
|
||||
type: "uint256[]",
|
||||
},
|
||||
{
|
||||
@ -251,113 +227,87 @@ export let abiMinterFactory: AbiItem[] = [
|
||||
type: "bytes",
|
||||
},
|
||||
],
|
||||
name: "mintChipBatchUser",
|
||||
outputs: [
|
||||
{
|
||||
internalType: "bool",
|
||||
name: "success",
|
||||
type: "bool",
|
||||
},
|
||||
],
|
||||
name: "mintNft",
|
||||
outputs: [],
|
||||
stateMutability: "nonpayable",
|
||||
type: "function",
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: "uint256[]",
|
||||
name: "ids",
|
||||
type: "uint256[]",
|
||||
},
|
||||
{
|
||||
internalType: "uint256[]",
|
||||
name: "amounts",
|
||||
type: "uint256[]",
|
||||
},
|
||||
{
|
||||
internalType: "uint256",
|
||||
name: "startTime",
|
||||
type: "uint256",
|
||||
},
|
||||
{
|
||||
internalType: "uint256",
|
||||
name: "saltNonce",
|
||||
type: "uint256",
|
||||
},
|
||||
{
|
||||
internalType: "bytes",
|
||||
name: "signature",
|
||||
type: "bytes",
|
||||
},
|
||||
],
|
||||
name: "mintShardBatchUser",
|
||||
outputs: [
|
||||
{
|
||||
internalType: "bool",
|
||||
name: "success",
|
||||
type: "bool",
|
||||
internalType: "address",
|
||||
name: "nftToken",
|
||||
type: "address",
|
||||
},
|
||||
],
|
||||
name: "addTokenSupport",
|
||||
outputs: [],
|
||||
stateMutability: "nonpayable",
|
||||
type: "function",
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: "uint256",
|
||||
name: "nftId",
|
||||
type: "uint256",
|
||||
internalType: "address",
|
||||
name: "nftToken",
|
||||
type: "address",
|
||||
},
|
||||
],
|
||||
name: "removeTokenSupport",
|
||||
outputs: [],
|
||||
stateMutability: "nonpayable",
|
||||
type: "function",
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: "uint8",
|
||||
name: "nftType",
|
||||
type: "uint8",
|
||||
internalType: "address",
|
||||
name: "account",
|
||||
type: "address",
|
||||
},
|
||||
],
|
||||
name: "updateExecutor",
|
||||
outputs: [],
|
||||
stateMutability: "nonpayable",
|
||||
type: "function",
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: "address",
|
||||
name: "_to",
|
||||
type: "address",
|
||||
},
|
||||
{
|
||||
internalType: "address",
|
||||
name: "payToken",
|
||||
name: "_nftAddress",
|
||||
type: "address",
|
||||
},
|
||||
{
|
||||
internalType: "uint256",
|
||||
name: "payAmount",
|
||||
type: "uint256",
|
||||
},
|
||||
{
|
||||
internalType: "uint256[]",
|
||||
name: "ids",
|
||||
type: "uint256[]",
|
||||
},
|
||||
{
|
||||
internalType: "uint256[]",
|
||||
name: "amounts",
|
||||
type: "uint256[]",
|
||||
},
|
||||
{
|
||||
internalType: "uint256",
|
||||
name: "startTime",
|
||||
name: "_startTime",
|
||||
type: "uint256",
|
||||
},
|
||||
{
|
||||
internalType: "uint256",
|
||||
name: "saltNonce",
|
||||
name: "_saltNonce",
|
||||
type: "uint256",
|
||||
},
|
||||
{
|
||||
internalType: "bytes",
|
||||
name: "signature",
|
||||
type: "bytes",
|
||||
internalType: "uint256[]",
|
||||
name: "_ids",
|
||||
type: "uint256[]",
|
||||
},
|
||||
],
|
||||
name: "shardMixByUser",
|
||||
name: "getMessageHash",
|
||||
outputs: [
|
||||
{
|
||||
internalType: "bool",
|
||||
name: "success",
|
||||
type: "bool",
|
||||
internalType: "bytes32",
|
||||
name: "",
|
||||
type: "bytes32",
|
||||
},
|
||||
],
|
||||
stateMutability: "nonpayable",
|
||||
stateMutability: "pure",
|
||||
type: "function",
|
||||
},
|
||||
];
|
||||
|
37
src/api/EmailApi.ts
Normal file
37
src/api/EmailApi.ts
Normal file
@ -0,0 +1,37 @@
|
||||
import { WALLET_API_HOST } from "../config/constants";
|
||||
import { GET_JSON, POST_JSON } from "../lib/Http";
|
||||
|
||||
// request /wallet/info/email to get if email is verified
|
||||
export function isEmailVerified() {
|
||||
const url = `${WALLET_API_HOST}/wallet/info/email`;
|
||||
return GET_JSON(url);
|
||||
}
|
||||
|
||||
export function sendCode(data) {
|
||||
const url = `${WALLET_API_HOST}/email/send_code`;
|
||||
return POST_JSON(url, data);
|
||||
}
|
||||
|
||||
export function verifyEmailByCode(data) {
|
||||
const url = `${WALLET_API_HOST}/email/verify_by_code`;
|
||||
return POST_JSON(url, data);
|
||||
}
|
||||
|
||||
export function checkEmailRegister(data) {
|
||||
const url = `${WALLET_API_HOST}/email/check`;
|
||||
return POST_JSON(url, data);
|
||||
}
|
||||
|
||||
export function emailRegister(data) {
|
||||
const url = `${WALLET_API_HOST}/email/regist`;
|
||||
return POST_JSON(url, data);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param data {email, pass}
|
||||
* @returns
|
||||
*/
|
||||
export function emailLogin(data) {
|
||||
const url = `${WALLET_API_HOST}/wallet/login/email`;
|
||||
return POST_JSON(url, data);
|
||||
}
|
40
src/api/PayApi.ts
Normal file
40
src/api/PayApi.ts
Normal file
@ -0,0 +1,40 @@
|
||||
import { PAY_API_HOST_ETH } from '../config/constants';
|
||||
import { GET_JSON, POST_JSON } from '../lib/Http';
|
||||
|
||||
export function reqAlchemyPrePay(data: any) {
|
||||
const url = `${jc.wallet.payUrl}/pay/alchemy/buy`;
|
||||
return POST_JSON(url, data);
|
||||
}
|
||||
|
||||
export function reqAlchemyPayETH(data: any) {
|
||||
const url = `${PAY_API_HOST_ETH}/pay/alchemy/buy`;
|
||||
return POST_JSON(url, data);
|
||||
}
|
||||
|
||||
export function queryTokenUsdPrice(eth: string, chain: string, env: string) {
|
||||
const url = `${jc.wallet.payUrl}/pay/alchemy/crypto_price`;
|
||||
return POST_JSON(url, { token: eth, chain, env });
|
||||
}
|
||||
/**
|
||||
* check if user can buy eth from treasury
|
||||
* @returns
|
||||
*/
|
||||
export function checkBuyTreasury() {
|
||||
const url = `${jc.wallet.payUrl}/pay/alchemy/can_i_buy_treasury`;
|
||||
return GET_JSON(url);
|
||||
}
|
||||
|
||||
export function queryFiatList() {
|
||||
const url = `${jc.wallet.payUrl}/pay/alchemy/fait_list`;
|
||||
return GET_JSON(url);
|
||||
}
|
||||
|
||||
export function verifyGooglePay(data: any) {
|
||||
const url = `${jc.wallet.payUrl}/pay/google/verify`;
|
||||
return POST_JSON(url, data);
|
||||
}
|
||||
|
||||
export function verifyApplePay(data: any) {
|
||||
const url = `${jc.wallet.payUrl}/pay/apple/verify`;
|
||||
return POST_JSON(url, data);
|
||||
}
|
17
src/api/RecordApi.ts
Normal file
17
src/api/RecordApi.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import { WALLET_API_HOST } from "../config/constants";
|
||||
import { DELETE_JSON, POST_JSON } from "../lib/Http";
|
||||
|
||||
export function saveRecord(data) {
|
||||
const url = `${WALLET_API_HOST}/trans/record`;
|
||||
return POST_JSON(url, data);
|
||||
}
|
||||
|
||||
export function records(data) {
|
||||
const url = `${WALLET_API_HOST}/trans/records`;
|
||||
return POST_JSON(url, data);
|
||||
}
|
||||
|
||||
export function removeRecord(data) {
|
||||
const url = `${WALLET_API_HOST}/trans/record`;
|
||||
return DELETE_JSON(url, data);
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
import { WALLET_API_HOST } from "../config/constants";
|
||||
import { GET_JSON, POST_JSON } from "../lib/Http";
|
||||
import { WALLET_API_HOST } from '../config/constants';
|
||||
import { GET_JSON, POST_JSON } from '../lib/Http';
|
||||
|
||||
export function googleAuth(idToken: string) {
|
||||
const url = `${WALLET_API_HOST}/wallet/login/google`;
|
||||
@ -16,13 +16,27 @@ export function tikTokAuth(idToken: string) {
|
||||
return POST_JSON(url, { code: idToken });
|
||||
}
|
||||
|
||||
export function facebookAuth(idToken: string) {
|
||||
const url = `${WALLET_API_HOST}/wallet/login/facebook`;
|
||||
return POST_JSON(url, { code: idToken });
|
||||
}
|
||||
|
||||
export function twitterAuth(idToken: string) {
|
||||
const url = `${WALLET_API_HOST}/wallet/login/twitter`;
|
||||
return POST_JSON(url, { code: idToken });
|
||||
}
|
||||
|
||||
export function clientAuth(idToken: string) {
|
||||
const url = `${WALLET_API_HOST}/wallet/login/client`;
|
||||
return POST_JSON(url, { code: idToken });
|
||||
}
|
||||
|
||||
export function getWalletInfo() {
|
||||
const url = `${WALLET_API_HOST}/wallet/info`;
|
||||
return GET_JSON(url);
|
||||
}
|
||||
|
||||
export function uploadWalletInfo(data) {
|
||||
console.log("uploadWalletInfo: " + data);
|
||||
const url = `${WALLET_API_HOST}/wallet/info`;
|
||||
return POST_JSON(url, data);
|
||||
}
|
||||
@ -36,3 +50,18 @@ export function uploadUserCollection(data) {
|
||||
const url = `${WALLET_API_HOST}/wallet/collection`;
|
||||
return POST_JSON(url, data);
|
||||
}
|
||||
|
||||
export function uploadInfoForWebLogin(data) {
|
||||
const url = `${WALLET_API_HOST}/bridge/upload`;
|
||||
return POST_JSON(url, data);
|
||||
}
|
||||
|
||||
export function resetWallet() {
|
||||
const url = `${WALLET_API_HOST}/wallet/reset`;
|
||||
return POST_JSON(url, {});
|
||||
}
|
||||
|
||||
export function resetAccount() {
|
||||
const url = `${WALLET_API_HOST}/wallet/account/reset`;
|
||||
return POST_JSON(url, {});
|
||||
}
|
||||
|
107
src/common/AsyncQueue.ts
Normal file
107
src/common/AsyncQueue.ts
Normal file
@ -0,0 +1,107 @@
|
||||
type Callback<T> = () => Promise<T>
|
||||
|
||||
export type AsyncQueue<T = void> = {
|
||||
push: (task: Callback<T>) => Promise<T>
|
||||
flush: () => Promise<void>
|
||||
size: number
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that each callback pushed onto the queue is executed in series.
|
||||
* Such a quetie 😻
|
||||
* @param opts.dedupeConcurrent If dedupeConcurrent is `true` it ensures that if multiple
|
||||
* tasks are pushed onto the queue while there is an active task, only the
|
||||
* last one will be executed, once the active task has completed.
|
||||
* e.g. in the below example, only 0 and 3 will be executed.
|
||||
* ```
|
||||
* const queue = createAsyncQueue({ dedupeConcurrent: true })
|
||||
* queue.push(async () => console.log(0)) // returns 0
|
||||
* queue.push(async () => console.log(1)) // returns 3
|
||||
* queue.push(async () => console.log(2)) // returns 3
|
||||
* queue.push(async () => console.log(3)) // returns 3
|
||||
* ```
|
||||
* */
|
||||
export function createAsyncQueue<T = void>(opts = { dedupeConcurrent: false }): AsyncQueue<T> {
|
||||
const { dedupeConcurrent } = opts
|
||||
let queue: Callback<T>[] = []
|
||||
let running: Promise<void> | undefined
|
||||
let nextPromise = new DeferredPromise<T>()
|
||||
const push = (task: Callback<T>) => {
|
||||
let taskPromise = new DeferredPromise<T>()
|
||||
if (dedupeConcurrent) {
|
||||
queue = []
|
||||
if (nextPromise.started) nextPromise = new DeferredPromise<T>()
|
||||
taskPromise = nextPromise
|
||||
}
|
||||
queue.push(() => {
|
||||
taskPromise.started = true
|
||||
task().then(taskPromise.resolve).catch(taskPromise.reject)
|
||||
return taskPromise.promise
|
||||
})
|
||||
if (!running) running = start()
|
||||
return taskPromise.promise
|
||||
}
|
||||
const start = async () => {
|
||||
while (queue.length) {
|
||||
const task = queue.shift()!
|
||||
await task().catch(() => {})
|
||||
}
|
||||
running = undefined
|
||||
}
|
||||
return {
|
||||
push,
|
||||
flush: () => running || Promise.resolve(),
|
||||
get size() {
|
||||
return queue.length
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
export const createAsyncQueues = <T = void>(opts = { dedupeConcurrent: false }) => {
|
||||
const queues: { [queueId: string]: AsyncQueue<T> } = {}
|
||||
const push = (queueId: string, task: Callback<T>) => {
|
||||
if (!queues[queueId]) queues[queueId] = createAsyncQueue<T>(opts)
|
||||
return queues[queueId].push(task)
|
||||
}
|
||||
const flush = (queueId: string) => {
|
||||
if (!queues[queueId]) queues[queueId] = createAsyncQueue<T>(opts)
|
||||
return queues[queueId].flush()
|
||||
}
|
||||
return { push, flush }
|
||||
}
|
||||
|
||||
class DeferredPromise<T = void, E = any> {
|
||||
started = false
|
||||
resolve: (x: T | PromiseLike<T>) => void = () => {}
|
||||
reject: (x: E) => void = () => {}
|
||||
promise: Promise<T>
|
||||
|
||||
constructor() {
|
||||
this.promise = new Promise<T>((res, rej) => {
|
||||
this.resolve = res
|
||||
this.reject = rej
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// function main() {
|
||||
// const queue = createAsyncQueue()
|
||||
// queue.push(async () => {
|
||||
// console.log(0)
|
||||
// }) // returns 0
|
||||
// queue.push(async () => {
|
||||
// console.log(1)
|
||||
|
||||
// return new Promise((resolve, reject) => {
|
||||
// setTimeout(() => {
|
||||
// console.log('12')
|
||||
// resolve()
|
||||
// }, 1000)
|
||||
// })
|
||||
// }) // returns 3
|
||||
// queue.push(async () => console.log(2)) // returns 3
|
||||
// queue.push(async () => console.log(3)) // returns 3
|
||||
// console.log('hi')
|
||||
// }
|
||||
|
||||
// main()
|
@ -1,5 +1,5 @@
|
||||
import { IChainData } from "..";
|
||||
import WalletConnectProvider from "../lib/WalletConnectProvider";
|
||||
import { IChainData } from "../types/data.types";
|
||||
import { toHexChainId } from "../util/chain.util";
|
||||
|
||||
export class ZWalletConnect {
|
||||
|
@ -3,7 +3,21 @@ import { singleton } from "../decorator/singleton.decorator";
|
||||
|
||||
@singleton
|
||||
export class WalletEnv {
|
||||
public idToken: string;
|
||||
public token: string;
|
||||
public address: string;
|
||||
public key: string;
|
||||
public salt: string;
|
||||
|
||||
public handler = createWalletEvents();
|
||||
|
||||
public get tokenData(): any {
|
||||
if (!this.token) {
|
||||
return {};
|
||||
}
|
||||
let datas = this.token.split(".");
|
||||
if (datas.length < 2) {
|
||||
return {};
|
||||
}
|
||||
return JSON.parse(window.atob(datas[1]));
|
||||
}
|
||||
}
|
||||
|
80
src/config/cfg_421613_dev.js
Normal file
80
src/config/cfg_421613_dev.js
Normal file
@ -0,0 +1,80 @@
|
||||
module.exports = {
|
||||
tokens: [
|
||||
{
|
||||
type: 'eth',
|
||||
address: 'eth',
|
||||
symbol: 'AGOR',
|
||||
decimal: 18,
|
||||
},
|
||||
{
|
||||
type: 'erc20',
|
||||
address: '0x8dd1439E0C3254b4543d6D68b3C0C891E5Bd2eCE',
|
||||
symbol: 'CEC',
|
||||
decimal: 18,
|
||||
},
|
||||
{
|
||||
type: 'erc20',
|
||||
address: '0x2C7221588D4FBac2585D71618CD540e74c7413B8',
|
||||
symbol: 'CEG',
|
||||
decimal: 18,
|
||||
},
|
||||
{
|
||||
address: '0xE6A69474E04B93De50dd07F239d62879dB9bF716',
|
||||
name: 'hero',
|
||||
type: 'erc721',
|
||||
},
|
||||
{
|
||||
address: '0x8Ce844402bE22fA1276a375Ff2354DD27aDEF285',
|
||||
name: 'weapon',
|
||||
type: 'erc721',
|
||||
},
|
||||
{
|
||||
address: '0x4678fE0177B15538F441264cB851364d9F3872AA',
|
||||
name: 'chip',
|
||||
type: 'erc721',
|
||||
},
|
||||
{
|
||||
type: 'erc20',
|
||||
address: '0xaa34B79A0Ab433eaC900fB3CB9f191F5Cd27501D',
|
||||
symbol: 'USDT',
|
||||
decimal: 18,
|
||||
thirdparty: 1,
|
||||
},
|
||||
{
|
||||
type: 'erc20',
|
||||
address: '0x944D0A8463B2c955F90F7252bBb99A3395087155',
|
||||
symbol: 'USDC',
|
||||
decimal: 6,
|
||||
thirdparty: 1,
|
||||
},
|
||||
{
|
||||
address: '0xEbC170185ad614C05Af38C820020b70E458717F5',
|
||||
name: 'gacha',
|
||||
type: 'erc721',
|
||||
},
|
||||
{
|
||||
address: '0xae37bb7BcA26Bab9a11D8BaE8fdB97f63b82c189',
|
||||
name: 'TestHero',
|
||||
type: 'erc721',
|
||||
},
|
||||
],
|
||||
contracts: {
|
||||
minterFactory: '0x1A27515c35a92Fb276c2670fa27C85ffAd75D094',
|
||||
nftmarket: '0xB9720d2c9D01FE36a1aA1224cbB06BF8e436812E',
|
||||
nftmall: '0x4d71dE0428328112A78D402A6fdd7ceD1C96B71e',
|
||||
gamemarket: '0x46e2C612756b702b3d68d89F97c88FFa725F6fab',
|
||||
gamemall: '0x1D058c7c7451c34BbfF9c0dF1C16b95C5d171d64',
|
||||
tokenmall: '0x22557f3fe7fbA53C66a35a3D70527D014704fd4D',
|
||||
nftStaking: '0xefe4b6b4C94b7514543A7ed912C877D6F560DdC2',
|
||||
},
|
||||
gasInfo: {
|
||||
nftApprove: 49340,
|
||||
cecApprove: 46962,
|
||||
marketSellNFT: 270740,
|
||||
marketCancelOrder: 119027,
|
||||
marketUpdatePrice: 41272,
|
||||
marketBuy: 207735,
|
||||
gameMallBuy: 119416,
|
||||
gameMarketBuy: 133251,
|
||||
},
|
||||
};
|
41
src/config/cfg_421613_release.js
Normal file
41
src/config/cfg_421613_release.js
Normal file
@ -0,0 +1,41 @@
|
||||
module.exports = {
|
||||
tokens: [
|
||||
{
|
||||
type: "eth",
|
||||
address: "eth",
|
||||
symbol: "AGOR",
|
||||
decimal: 18,
|
||||
},
|
||||
{
|
||||
type: "erc20",
|
||||
address: "0x8dd1439E0C3254b4543d6D68b3C0C891E5Bd2eCE",
|
||||
symbol: "CEC",
|
||||
decimal: 18,
|
||||
},
|
||||
{
|
||||
type: "erc20",
|
||||
address: "0x2C7221588D4FBac2585D71618CD540e74c7413B8",
|
||||
symbol: "CEG",
|
||||
decimal: 18,
|
||||
},
|
||||
{
|
||||
address: "0xE6A69474E04B93De50dd07F239d62879dB9bF716",
|
||||
name: "hero",
|
||||
type: "erc721",
|
||||
},
|
||||
{
|
||||
address: "0x8Ce844402bE22fA1276a375Ff2354DD27aDEF285",
|
||||
name: "weapon",
|
||||
type: "erc721",
|
||||
},
|
||||
{
|
||||
address: "0x4678fE0177B15538F441264cB851364d9F3872AA",
|
||||
name: "chip",
|
||||
type: "erc721",
|
||||
},
|
||||
],
|
||||
contracts: {
|
||||
minterFactory: "0x1A27515c35a92Fb276c2670fa27C85ffAd75D094",
|
||||
market: "0xb80E19c50747972E735c68C0BA5651AD952d70BC",
|
||||
},
|
||||
};
|
67
src/config/cfg_42161_release.js
Normal file
67
src/config/cfg_42161_release.js
Normal file
@ -0,0 +1,67 @@
|
||||
module.exports = {
|
||||
tokens: [
|
||||
{
|
||||
type: 'eth',
|
||||
address: 'eth',
|
||||
symbol: 'ETH',
|
||||
decimal: 18,
|
||||
},
|
||||
{
|
||||
type: 'erc20',
|
||||
address: '0x741482aE1480E552735E44Ff3A733448AcBbeD8d',
|
||||
symbol: 'CEG',
|
||||
decimal: 18,
|
||||
},
|
||||
{
|
||||
address: '0x79fc2a4216A1e595DBD09D13c4B4bD3B095d5bb2',
|
||||
name: 'hero',
|
||||
type: 'erc721',
|
||||
},
|
||||
{
|
||||
address: '0x551838d7754157D13e7D945b8a37bBD6Ad50dDC7',
|
||||
name: 'chip',
|
||||
type: 'erc721',
|
||||
},
|
||||
{
|
||||
address: '0xD728de3d9ebeD90E84aBe84539280cbC5b18E304',
|
||||
name: 'genesis',
|
||||
type: 'erc721',
|
||||
},
|
||||
{
|
||||
address: '0x3F13F83E6363D97d0353cAAfACA08B05D9BF3637',
|
||||
name: 'gacha',
|
||||
type: 'erc721',
|
||||
},
|
||||
{
|
||||
type: 'erc20',
|
||||
address: '0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9',
|
||||
symbol: 'USDT',
|
||||
decimal: 6,
|
||||
thirdparty: 1,
|
||||
},
|
||||
{
|
||||
type: 'erc20',
|
||||
address: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831',
|
||||
symbol: 'USDC',
|
||||
decimal: 6,
|
||||
thirdparty: 1,
|
||||
},
|
||||
],
|
||||
contracts: {
|
||||
minterFactory: '0x24499444b2BE6A8E3F800D47E4Ed0c36B5c0747e',
|
||||
nftmarket: '0xA683c7BC5f3c73782fce9fc614Fda7C999934db8',
|
||||
nftmall: '0xb5EF2FAC11c385041f847E34E0b1B4740436f769',
|
||||
gamemarket: '0x6232d2B720C22D6BCB633560b05002C472a64f18',
|
||||
gamemall: '0x1Ee01D949C848aF1ceDb80165b290554937819d9',
|
||||
},
|
||||
gasInfo: {
|
||||
nftApprove: 49340,
|
||||
cecApprove: 46962,
|
||||
marketSellNFT: 270740,
|
||||
marketCancelOrder: 119027,
|
||||
marketUpdatePrice: 41272,
|
||||
marketBuy: 207735,
|
||||
gameMallBuy: 119416,
|
||||
gameMarketBuy: 133251,
|
||||
},
|
||||
};
|
50
src/config/cfg_80001_dev.js
Normal file
50
src/config/cfg_80001_dev.js
Normal file
@ -0,0 +1,50 @@
|
||||
module.exports = {
|
||||
tokens: [
|
||||
{
|
||||
type: "eth",
|
||||
address: "eth",
|
||||
symbol: "MATIC",
|
||||
decimal: 18,
|
||||
},
|
||||
{
|
||||
type: "erc20",
|
||||
address: "0xfa513999031dC1DCf86e99d91101e17d07839235",
|
||||
symbol: "CEC",
|
||||
decimal: 18,
|
||||
},
|
||||
{
|
||||
type: "erc20",
|
||||
address: "0x9f87eCA8F0479383fF11a5AB2336b5A6c383d6F3",
|
||||
symbol: "CEG",
|
||||
decimal: 18,
|
||||
},
|
||||
{
|
||||
address: "0x3EBF5196dADC8F3F09C808333f98FE8A4b7d1e62",
|
||||
name: "hero",
|
||||
type: "erc721",
|
||||
},
|
||||
{
|
||||
address: "0x2F2Ed1c403cB7156617449795dE1CB47A0302a25",
|
||||
name: "weapon",
|
||||
type: "erc721",
|
||||
},
|
||||
{
|
||||
address: "0x73482411443E87CAC124C12A10B34e9Aaa2De168",
|
||||
name: "chip",
|
||||
type: "erc1155",
|
||||
},
|
||||
{
|
||||
address: "0xFc21A863bFb4E4534B246078772e2074e076f0a7",
|
||||
name: "shard",
|
||||
type: "erc1155",
|
||||
},
|
||||
],
|
||||
contracts: {
|
||||
nftMall: "0x1F6293c44633a50311Ec5Ab02ff14034b5c31272",
|
||||
evolveFactory: "0x9e6167B11Ad15D8407865E21D4770E9F6CF10853",
|
||||
minterFactory: "0xb60c7312F56da4303CE3bf27124f1850dBe1D0E5",
|
||||
chipLocker: "0x4Ef766854EE104053cF2D243620b7A643fCC2B54",
|
||||
nftFactory: "0xEA374dC9f94E7A3A2eE8C0C910954cE15E2C469E",
|
||||
market: "0x806eA3301c2bA2a3C710D97931a6C0Fe00E45B33",
|
||||
},
|
||||
};
|
50
src/config/cfg_80001_release.js
Normal file
50
src/config/cfg_80001_release.js
Normal file
@ -0,0 +1,50 @@
|
||||
module.exports = {
|
||||
tokens: [
|
||||
{
|
||||
type: "eth",
|
||||
address: "eth",
|
||||
symbol: "MATIC",
|
||||
decimal: 18,
|
||||
},
|
||||
{
|
||||
type: "erc20",
|
||||
address: "0xfa513999031dC1DCf86e99d91101e17d07839235",
|
||||
symbol: "CEC",
|
||||
decimal: 18,
|
||||
},
|
||||
{
|
||||
type: "erc20",
|
||||
address: "0x9f87eCA8F0479383fF11a5AB2336b5A6c383d6F3",
|
||||
symbol: "CEG",
|
||||
decimal: 18,
|
||||
},
|
||||
{
|
||||
address: "0x3EBF5196dADC8F3F09C808333f98FE8A4b7d1e62",
|
||||
name: "hero",
|
||||
type: "erc721",
|
||||
},
|
||||
{
|
||||
address: "0x2F2Ed1c403cB7156617449795dE1CB47A0302a25",
|
||||
name: "weapon",
|
||||
type: "erc721",
|
||||
},
|
||||
{
|
||||
address: "0x73482411443E87CAC124C12A10B34e9Aaa2De168",
|
||||
name: "chip",
|
||||
type: "erc1155",
|
||||
},
|
||||
{
|
||||
address: "0xFc21A863bFb4E4534B246078772e2074e076f0a7",
|
||||
name: "shard",
|
||||
type: "erc1155",
|
||||
},
|
||||
],
|
||||
contracts: {
|
||||
nftMall: "0x1F6293c44633a50311Ec5Ab02ff14034b5c31272",
|
||||
evolveFactory: "0x9e6167B11Ad15D8407865E21D4770E9F6CF10853",
|
||||
minterFactory: "0xb60c7312F56da4303CE3bf27124f1850dBe1D0E5",
|
||||
chipLocker: "0x4Ef766854EE104053cF2D243620b7A643fCC2B54",
|
||||
nftFactory: "0xEA374dC9f94E7A3A2eE8C0C910954cE15E2C469E",
|
||||
market: "0x806eA3301c2bA2a3C710D97931a6C0Fe00E45B33",
|
||||
},
|
||||
};
|
@ -1,231 +0,0 @@
|
||||
export const BASE_TOKEN_URI = "https://market.cebg.games/api/nft/info/";
|
||||
|
||||
export const DEFALUT_TOKENS = {
|
||||
321: [
|
||||
{
|
||||
type: "eth",
|
||||
address: "eth",
|
||||
symbol: "KCS",
|
||||
decimal: 18,
|
||||
},
|
||||
{
|
||||
type: "erc20",
|
||||
address: "0xcaA011E902103752435AC98657B046B282E36509",
|
||||
symbol: "CEC",
|
||||
decimal: 18,
|
||||
},
|
||||
{
|
||||
type: "erc20",
|
||||
address: "0xBE023C9D294A4668f0d510E2570CB81B4536cE77",
|
||||
symbol: "CEG",
|
||||
decimal: 18,
|
||||
},
|
||||
],
|
||||
322: [
|
||||
{
|
||||
type: "eth",
|
||||
address: "eth",
|
||||
symbol: "tKCS",
|
||||
decimal: 18,
|
||||
},
|
||||
{
|
||||
type: "erc20",
|
||||
address: "0xdb6D4bB22E2C12686Efff25a79EC78f9f078fe7D",
|
||||
symbol: "CEC",
|
||||
decimal: 18,
|
||||
},
|
||||
{
|
||||
type: "erc20",
|
||||
address: "0xC5Cd606b3e9B80b758e8274B198c76D929aA094A",
|
||||
symbol: "CEG",
|
||||
decimal: 18,
|
||||
},
|
||||
],
|
||||
97: [
|
||||
{
|
||||
type: "eth",
|
||||
address: "eth",
|
||||
symbol: "BNB",
|
||||
decimal: 18,
|
||||
},
|
||||
],
|
||||
56: [
|
||||
{
|
||||
type: "eth",
|
||||
address: "eth",
|
||||
symbol: "BNB",
|
||||
decimal: 18,
|
||||
},
|
||||
],
|
||||
137: [
|
||||
{
|
||||
type: "eth",
|
||||
address: "eth",
|
||||
symbol: "MATIC",
|
||||
decimal: 18,
|
||||
},
|
||||
],
|
||||
80001: [
|
||||
{
|
||||
type: "eth",
|
||||
address: "eth",
|
||||
symbol: "MATIC",
|
||||
decimal: 18,
|
||||
},
|
||||
{
|
||||
type: "erc20",
|
||||
address: "0xfa513999031dC1DCf86e99d91101e17d07839235",
|
||||
symbol: "CEC",
|
||||
decimal: 18,
|
||||
},
|
||||
{
|
||||
type: "erc20",
|
||||
address: "0x9f87eCA8F0479383fF11a5AB2336b5A6c383d6F3",
|
||||
symbol: "CEG",
|
||||
decimal: 18,
|
||||
},
|
||||
],
|
||||
1338: [
|
||||
{
|
||||
type: "eth",
|
||||
address: "eth",
|
||||
symbol: "ETH",
|
||||
decimal: 18,
|
||||
},
|
||||
{
|
||||
type: "erc20",
|
||||
address: "0x9561C133DD8580860B6b7E504bC5Aa500f0f06a7",
|
||||
symbol: "CEC",
|
||||
decimal: 18,
|
||||
},
|
||||
{
|
||||
type: "erc20",
|
||||
address: "0x59d3631c86BbE35EF041872d502F218A39FBa150",
|
||||
symbol: "CEG",
|
||||
decimal: 18,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
export const DEFAULT_NFT_TYPES = {
|
||||
321: {
|
||||
hero: {
|
||||
address: "0x0EB362BD40F2288fF25A6Ee1b487cB0cb4638e0D",
|
||||
type: "erc721",
|
||||
},
|
||||
weapon: {
|
||||
address: "0x29F67A372AC1c6AcF478A564992D421FE20F2cc8",
|
||||
type: "erc721",
|
||||
},
|
||||
chip: {
|
||||
address: "0x54B6ED7EDe9355b471985439421Aa1DC7Da6Dc20",
|
||||
type: "erc1155",
|
||||
},
|
||||
shard: {
|
||||
address: "0x54B6ED7EDe9355b471985439421Aa1DC7Da6Dc20",
|
||||
type: "erc1155",
|
||||
},
|
||||
},
|
||||
322: {
|
||||
hero: {
|
||||
address: "0x52917087cd4E48bDb5f336012E677f471f9E1C2D",
|
||||
type: "erc721",
|
||||
},
|
||||
weapon: {
|
||||
address: "0x500AD8A4D50d71Af5cA8eA3b12B914f7aE5466f7",
|
||||
type: "erc721",
|
||||
},
|
||||
chip: {
|
||||
address: "0x0640958BDb4D7956e1452FacEBD550C6Cf42aC94",
|
||||
type: "erc1155",
|
||||
},
|
||||
shard: {
|
||||
address: "0x54B6ED7EDe9355b471985439421Aa1DC7Da6Dc20",
|
||||
type: "erc1155",
|
||||
},
|
||||
},
|
||||
137: {
|
||||
hero: {
|
||||
address: "0xaE08adb5278B107D2501e7c61907e41FEf3887D7",
|
||||
type: "erc721",
|
||||
},
|
||||
weapon: {
|
||||
address: "0xee0044BF2ACEf7C3D7f6781d8f5DC4d2Dd1CE64c",
|
||||
type: "erc721",
|
||||
},
|
||||
chip: {
|
||||
address: "0xc058411B15E544291765F15B13c88582b7bceaD0",
|
||||
type: "erc1155",
|
||||
},
|
||||
shard: {
|
||||
address: "0x1d4c7908E6a6795aE4335D0F072B0A129AAFFdc1",
|
||||
type: "erc1155",
|
||||
},
|
||||
},
|
||||
80001: {
|
||||
hero: {
|
||||
address: "0x3EBF5196dADC8F3F09C808333f98FE8A4b7d1e62",
|
||||
type: "erc721",
|
||||
},
|
||||
weapon: {
|
||||
address: "0x2F2Ed1c403cB7156617449795dE1CB47A0302a25",
|
||||
type: "erc721",
|
||||
},
|
||||
chip: {
|
||||
address: "0x73482411443E87CAC124C12A10B34e9Aaa2De168",
|
||||
type: "erc1155",
|
||||
},
|
||||
shard: {
|
||||
address: "0xFc21A863bFb4E4534B246078772e2074e076f0a7",
|
||||
type: "erc1155",
|
||||
},
|
||||
},
|
||||
1338: {
|
||||
hero: {
|
||||
address: "0x9b1f7F645351AF3631a656421eD2e40f2802E6c0",
|
||||
type: "erc721",
|
||||
},
|
||||
weapon: {
|
||||
address: "0x2612Af3A521c2df9EAF28422Ca335b04AdF3ac66",
|
||||
type: "erc721",
|
||||
},
|
||||
chip: {
|
||||
address: "0x26b4AFb60d6C903165150C6F0AA14F8016bE4aec",
|
||||
type: "erc1155",
|
||||
},
|
||||
shard: {
|
||||
address: "0x0E696947A06550DEf604e82C26fd9E493e576337",
|
||||
type: "erc1155",
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export const JC_CONTRACTS = {
|
||||
321: {
|
||||
nftMall: "0xa44927698D0aC8EF29e91508839cd6e10f773EE0",
|
||||
evolveFactory: "0x07Bad070e403a4Bad2Eec3BA3894c4524d3d2674",
|
||||
minterFactory: "0x5ecEFA2707e3f09B9A169ae696B36Df8dB7410ED",
|
||||
},
|
||||
322: {
|
||||
nftMall: "0xa44927698D0aC8EF29e91508839cd6e10f773EE0",
|
||||
evolveFactory: "0x07Bad070e403a4Bad2Eec3BA3894c4524d3d2674",
|
||||
minterFactory: "0x5ecEFA2707e3f09B9A169ae696B36Df8dB7410ED",
|
||||
},
|
||||
137: {
|
||||
nftMall: "0xa44927698D0aC8EF29e91508839cd6e10f773EE0",
|
||||
evolveFactory: "0x07Bad070e403a4Bad2Eec3BA3894c4524d3d2674",
|
||||
minterFactory: "0x5ecEFA2707e3f09B9A169ae696B36Df8dB7410ED",
|
||||
},
|
||||
80001: {
|
||||
nftMall: "0x1F6293c44633a50311Ec5Ab02ff14034b5c31272",
|
||||
evolveFactory: "0x9e6167B11Ad15D8407865E21D4770E9F6CF10853",
|
||||
minterFactory: "0xb60c7312F56da4303CE3bf27124f1850dBe1D0E5",
|
||||
chipLocker: "0x4Ef766854EE104053cF2D243620b7A643fCC2B54",
|
||||
},
|
||||
1338: {
|
||||
nftMall: "0x5017A545b09ab9a30499DE7F431DF0855bCb7275",
|
||||
evolveFactory: "0xaD888d0Ade988EbEe74B8D4F39BF29a8d0fe8A8D",
|
||||
minterFactory: "0x6eD79Aa1c71FD7BdBC515EfdA3Bd4e26394435cC",
|
||||
chipLocker: "0xFF6049B87215476aBf744eaA3a476cBAd46fB1cA",
|
||||
},
|
||||
};
|
@ -1,7 +1,26 @@
|
||||
export const WALLET_STORAGE_KEY_NAME = "jc_wallet_data";
|
||||
export const WALLET_STORAGE_KEY_NAME = 'jc_wallet_data';
|
||||
|
||||
export const WALLET_API_HOST = "https://wallet.cebggame.com";
|
||||
// export const WALLET_API_HOST = 'http://192.168.100.183:3007';
|
||||
// export const PAY_API_HOST = 'http://192.168.100.183:3007';
|
||||
export const WALLET_API_HOST = 'https://wallet.cebggame.com';
|
||||
export const PAY_API_HOST = 'https://pay.cebggame.com/v2';
|
||||
export const PAY_API_HOST_ETH = 'https://pay.cebggame.com/v1';
|
||||
export const PAY_API_HOST_TEST = 'https://pay.cebggame.com/v0';
|
||||
|
||||
export const MAX_TRY_COUNT = 6;
|
||||
|
||||
export const MAX_UPLOAD_COUNT = 10;
|
||||
|
||||
export const TX_CONFIRM_BLOCKS = 6;
|
||||
|
||||
export const NATIVE_PK_PREFIX = '0x000000000000000000000000';
|
||||
|
||||
export const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
|
||||
|
||||
export const AVAILABLE_CHAINS = [80001, 421613, 137, 42161];
|
||||
|
||||
export const BASE_TOKEN_URI = 'https://market.cebg.games/api/nft/info/';
|
||||
|
||||
export const GAS_BOOST = 1.2;
|
||||
|
||||
export const VERSION_CODE = 1;
|
||||
|
@ -1,79 +0,0 @@
|
||||
import { DEFALUT_TOKENS } from "../config/chain_config";
|
||||
|
||||
export interface IToken {
|
||||
address: string;
|
||||
type: "eth" | "erc20";
|
||||
default: boolean;
|
||||
symbol?: string;
|
||||
balance?: string;
|
||||
decimal: number;
|
||||
image?: string;
|
||||
last?: number;
|
||||
}
|
||||
|
||||
export interface INFT {
|
||||
address: string;
|
||||
type: "erc721" | "erc1155";
|
||||
index: number;
|
||||
tokenId?: string;
|
||||
image?: string;
|
||||
name?: string;
|
||||
desc?: string;
|
||||
last?: number;
|
||||
}
|
||||
|
||||
export function initNFT(address: string, index: number, type: 'erc721'|'erc1155') {
|
||||
return {
|
||||
address,
|
||||
index,
|
||||
type
|
||||
};
|
||||
}
|
||||
|
||||
export interface ITokenData {
|
||||
tokens: IToken[];
|
||||
heros: INFT[];
|
||||
weapons: INFT[];
|
||||
chips: INFT[];
|
||||
}
|
||||
export interface IAccount {
|
||||
address: string;
|
||||
type: number;
|
||||
index: number;
|
||||
nickname?: string;
|
||||
avatar?: string;
|
||||
tokenData: {
|
||||
[key: number]: ITokenData;
|
||||
};
|
||||
}
|
||||
|
||||
export function initAccount({
|
||||
address,
|
||||
chain,
|
||||
nickname,
|
||||
type,
|
||||
index
|
||||
}: {
|
||||
address: string;
|
||||
chain: number;
|
||||
nickname: string;
|
||||
type: number,
|
||||
index: number
|
||||
}): IAccount {
|
||||
let chainData = {};
|
||||
let data: IAccount = {
|
||||
address,
|
||||
nickname,
|
||||
type,
|
||||
index,
|
||||
tokenData: chainData,
|
||||
};
|
||||
let tokens = DEFALUT_TOKENS[chain];
|
||||
chainData[chain] = {
|
||||
tokens,
|
||||
heros: [],
|
||||
weapons: [],
|
||||
chips: [],
|
||||
};
|
||||
return data;
|
||||
}
|
@ -1,282 +1,309 @@
|
||||
export const AllChains = [
|
||||
{
|
||||
name: "Ethereum Mainnet RPC",
|
||||
type: "Mainnet",
|
||||
rpc: "https://rpc.ankr.com/eth",
|
||||
name: 'Ethereum Mainnet RPC',
|
||||
type: 'Mainnet',
|
||||
rpc: 'https://rpc.ankr.com/eth',
|
||||
id: 1,
|
||||
symbol: "ETH",
|
||||
explorerurl: "https://etherscan.io",
|
||||
symbol: 'ETH',
|
||||
explorerurl: 'https://etherscan.io',
|
||||
},
|
||||
{
|
||||
name: "Ethereum Ropsten Testnet RPC",
|
||||
type: "Testnet",
|
||||
rpc: "https://ropsten.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161",
|
||||
name: 'Ethereum Ropsten Testnet RPC',
|
||||
type: 'Testnet',
|
||||
rpc: 'https://ropsten.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161',
|
||||
id: 3,
|
||||
symbol: "ETH",
|
||||
explorerurl: "https://ropsten.etherscan.io",
|
||||
symbol: 'ETH',
|
||||
explorerurl: 'https://ropsten.etherscan.io',
|
||||
},
|
||||
{
|
||||
name: "Ethereum Rinkeby Testnet RPC",
|
||||
type: "Testnet",
|
||||
rpc: "https://rinkey.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161",
|
||||
name: 'Ethereum Rinkeby Testnet RPC',
|
||||
type: 'Testnet',
|
||||
rpc: 'https://rinkey.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161',
|
||||
id: 4,
|
||||
symbol: "ETH",
|
||||
explorerurl: "https://rinkey.etherscan.io",
|
||||
symbol: 'ETH',
|
||||
explorerurl: 'https://rinkey.etherscan.io',
|
||||
},
|
||||
{
|
||||
name: "Ethereum Goerli Testnet RPC",
|
||||
type: "Testnet",
|
||||
rpc: "https://goerli.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161",
|
||||
name: 'Ethereum Goerli Testnet RPC',
|
||||
type: 'Testnet',
|
||||
rpc: 'https://goerli.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161',
|
||||
id: 5,
|
||||
symbol: "ETH",
|
||||
explorerurl: "https://goerli.etherscan.io",
|
||||
symbol: 'ETH',
|
||||
explorerurl: 'https://goerli.etherscan.io',
|
||||
},
|
||||
{
|
||||
name: "Ethereum Kovan Testnet RPC",
|
||||
type: "Testnet",
|
||||
rpc: "https://kovan.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161",
|
||||
name: 'Ethereum Kovan Testnet RPC',
|
||||
type: 'Testnet',
|
||||
rpc: 'https://kovan.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161',
|
||||
id: 6,
|
||||
symbol: "ETH",
|
||||
explorerurl: "https://kovan.etherscan.io",
|
||||
symbol: 'ETH',
|
||||
explorerurl: 'https://kovan.etherscan.io',
|
||||
},
|
||||
{
|
||||
name: "Ubiq Mainnet RPC",
|
||||
type: "Mainnet",
|
||||
rpc: "https://rpc.octano.dev/",
|
||||
name: 'Ubiq Mainnet RPC',
|
||||
type: 'Mainnet',
|
||||
rpc: 'https://rpc.octano.dev/',
|
||||
id: 8,
|
||||
symbol: "UBQ",
|
||||
explorerurl: "https://ubiqscan.io/",
|
||||
symbol: 'UBQ',
|
||||
explorerurl: 'https://ubiqscan.io/',
|
||||
},
|
||||
{
|
||||
name: "Elastos ETH Mainnet RPC",
|
||||
type: "Mainnet",
|
||||
rpc: "https://api.elastos.io/eth",
|
||||
name: 'Elastos ETH Mainnet RPC',
|
||||
type: 'Mainnet',
|
||||
rpc: 'https://api.elastos.io/eth',
|
||||
id: 20,
|
||||
symbol: "ELA",
|
||||
explorerurl: "https://explorer.elaeth.io/",
|
||||
symbol: 'ELA',
|
||||
explorerurl: 'https://explorer.elaeth.io/',
|
||||
},
|
||||
{
|
||||
name: "Cronos Mainnet RPC",
|
||||
type: "Mainnet",
|
||||
rpc: "https://evm-cronos.crypto.org",
|
||||
name: 'Cronos Mainnet RPC',
|
||||
type: 'Mainnet',
|
||||
rpc: 'https://evm-cronos.crypto.org',
|
||||
id: 25,
|
||||
symbol: "CRO",
|
||||
explorerurl: "https://cronos.crypto.org/explorer/",
|
||||
symbol: 'CRO',
|
||||
explorerurl: 'https://cronos.crypto.org/explorer/',
|
||||
},
|
||||
{
|
||||
name: "Telos EVM Mainnet RPC",
|
||||
type: "Mainnet",
|
||||
rpc: "https://mainnet.telos.net/evm",
|
||||
name: 'Telos EVM Mainnet RPC',
|
||||
type: 'Mainnet',
|
||||
rpc: 'https://mainnet.telos.net/evm',
|
||||
id: 40,
|
||||
symbol: "TLOS",
|
||||
explorerurl: "https://telos.net/",
|
||||
symbol: 'TLOS',
|
||||
explorerurl: 'https://telos.net/',
|
||||
},
|
||||
{
|
||||
name: "Binance Smart Chain",
|
||||
type: "Mainnet",
|
||||
rpc: "https://rpc.ankr.com/bsc",
|
||||
name: 'Binance Smart Chain',
|
||||
type: 'Mainnet',
|
||||
rpc: 'https://rpc.ankr.com/bsc',
|
||||
id: 56,
|
||||
symbol: "BNB",
|
||||
explorerurl: "https://bscscan.com",
|
||||
symbol: 'BNB',
|
||||
explorerurl: 'https://bscscan.com',
|
||||
},
|
||||
{
|
||||
name: "OKExChain Mainnet RPC",
|
||||
type: "Mainnet",
|
||||
rpc: "https://exchainrpc.okex.org",
|
||||
name: 'OKExChain Mainnet RPC',
|
||||
type: 'Mainnet',
|
||||
rpc: 'https://exchainrpc.okex.org',
|
||||
id: 66,
|
||||
symbol: "OKT",
|
||||
explorerurl: "https://www.oklink.com/okexchain",
|
||||
symbol: 'OKT',
|
||||
explorerurl: 'https://www.oklink.com/okexchain',
|
||||
},
|
||||
{
|
||||
name: "Hoo Mainnet RPC",
|
||||
type: "Mainnet",
|
||||
rpc: "https://http-mainnet.hoosmartchain.com",
|
||||
name: 'Hoo Mainnet RPC',
|
||||
type: 'Mainnet',
|
||||
rpc: 'https://http-mainnet.hoosmartchain.com',
|
||||
id: 70,
|
||||
symbol: "HOO",
|
||||
explorerurl: "https://hooscan.com",
|
||||
symbol: 'HOO',
|
||||
explorerurl: 'https://hooscan.com',
|
||||
},
|
||||
{
|
||||
name: "Binance Testnet",
|
||||
type: "Testnet",
|
||||
rpc: "https://data-seed-prebsc-1-s1.binance.org:8545/",
|
||||
name: 'Binance Testnet',
|
||||
type: 'Testnet',
|
||||
rpc: 'https://data-seed-prebsc-1-s1.binance.org:8545/',
|
||||
id: 97,
|
||||
symbol: "BNB",
|
||||
explorerurl: "https://testnet.bscscan.com",
|
||||
symbol: 'BNB',
|
||||
explorerurl: 'https://testnet.bscscan.com',
|
||||
},
|
||||
{
|
||||
name: "xDai Mainnet RPC",
|
||||
type: "Mainnet",
|
||||
rpc: "https://rpc.xdaichain.com/",
|
||||
name: 'xDai Mainnet RPC',
|
||||
type: 'Mainnet',
|
||||
rpc: 'https://rpc.xdaichain.com/',
|
||||
id: 100,
|
||||
symbol: "XDAI",
|
||||
explorerurl: "https://blockscout.com/xdai/mainnet/",
|
||||
symbol: 'XDAI',
|
||||
explorerurl: 'https://blockscout.com/xdai/mainnet/',
|
||||
},
|
||||
{
|
||||
name: "Fuse Mainnet RPC",
|
||||
type: "Mainnet",
|
||||
rpc: "https://rpc.fuse.io",
|
||||
name: 'Fuse Mainnet RPC',
|
||||
type: 'Mainnet',
|
||||
rpc: 'https://rpc.fuse.io',
|
||||
id: 122,
|
||||
symbol: "FUSE",
|
||||
explorerurl: "https://explorer.fuse.io/",
|
||||
symbol: 'FUSE',
|
||||
explorerurl: 'https://explorer.fuse.io/',
|
||||
},
|
||||
{
|
||||
name: "HECO Mainnet RPC",
|
||||
type: "Mainnet",
|
||||
rpc: "https://http-mainnet-node.huobichain.com/",
|
||||
name: 'HECO Mainnet RPC',
|
||||
type: 'Mainnet',
|
||||
rpc: 'https://http-mainnet-node.huobichain.com/',
|
||||
id: 128,
|
||||
symbol: "HT",
|
||||
explorerurl: "https://hecoinfo.com/",
|
||||
symbol: 'HT',
|
||||
explorerurl: 'https://hecoinfo.com/',
|
||||
},
|
||||
{
|
||||
name: "Matic Mainnet RPC",
|
||||
type: "Mainnet",
|
||||
rpc: "https://polygon-rpc.com",
|
||||
name: 'Matic Mainnet RPC',
|
||||
type: 'Mainnet',
|
||||
rpc: 'https://polygon-rpc.com',
|
||||
id: 137,
|
||||
symbol: "MATIC",
|
||||
explorerurl: "https://explorer.matic.network/",
|
||||
symbol: 'MATIC',
|
||||
explorerurl: 'https://explorer.matic.network/',
|
||||
},
|
||||
{
|
||||
name: "Fantom Opera Mainnet RPC",
|
||||
type: "Mainnet",
|
||||
rpc: "https://rpc.ftm.tools/",
|
||||
name: 'Fantom Opera Mainnet RPC',
|
||||
type: 'Mainnet',
|
||||
rpc: 'https://rpc.ftm.tools/',
|
||||
id: 250,
|
||||
symbol: "FTM",
|
||||
explorerurl: "https://ftmscan.com",
|
||||
symbol: 'FTM',
|
||||
explorerurl: 'https://ftmscan.com',
|
||||
},
|
||||
{
|
||||
name: "HECO Testnet RPC",
|
||||
type: "Testnet",
|
||||
rpc: "https://http-testnet.hecochain.com",
|
||||
name: 'HECO Testnet RPC',
|
||||
type: 'Testnet',
|
||||
rpc: 'https://http-testnet.hecochain.com',
|
||||
id: 256,
|
||||
symbol: "HT",
|
||||
explorerurl: "https://testnet.hecoinfo.com/",
|
||||
symbol: 'HT',
|
||||
explorerurl: 'https://testnet.hecoinfo.com/',
|
||||
},
|
||||
{
|
||||
name: "KCC Mainnet",
|
||||
type: "Mainnet",
|
||||
rpc: "https://rpc-mainnet.kcc.network",
|
||||
name: 'KCC Mainnet',
|
||||
type: 'Mainnet',
|
||||
rpc: 'https://rpc-mainnet.kcc.network',
|
||||
id: 321,
|
||||
symbol: "KCS",
|
||||
explorerurl: "https://scan.kcc.network",
|
||||
symbol: 'KCS',
|
||||
explorerurl: 'https://scan.kcc.network',
|
||||
},
|
||||
{
|
||||
name: "KCC Testnet",
|
||||
type: "Testnet",
|
||||
rpc: "https://rpc-testnet.kcc.network",
|
||||
name: 'KCC Testnet',
|
||||
type: 'Testnet',
|
||||
rpc: 'https://rpc-testnet.kcc.network',
|
||||
id: 322,
|
||||
symbol: "tKCS",
|
||||
explorerurl: "https://scan-testnet.kcc.network",
|
||||
symbol: 'tKCS',
|
||||
explorerurl: 'https://scan-testnet.kcc.network',
|
||||
},
|
||||
{
|
||||
name: "Moonriver Mainnet RPC",
|
||||
type: "Mainnet",
|
||||
rpc: "https://rpc.moonriver.moonbeam.network",
|
||||
name: 'Moonriver Mainnet RPC',
|
||||
type: 'Mainnet',
|
||||
rpc: 'https://rpc.moonriver.moonbeam.network',
|
||||
id: 1285,
|
||||
symbol: "MOVR",
|
||||
explorerurl: "https://blockscout.moonriver.moonbeam.network/",
|
||||
symbol: 'MOVR',
|
||||
explorerurl: 'https://blockscout.moonriver.moonbeam.network/',
|
||||
},
|
||||
{
|
||||
name: "Fantom Testnet RPC",
|
||||
type: "Testnet",
|
||||
rpc: "https://rpc.testnet.fantom.network/",
|
||||
name: 'Fantom Testnet RPC',
|
||||
type: 'Testnet',
|
||||
rpc: 'https://rpc.testnet.fantom.network/',
|
||||
id: 4002,
|
||||
symbol: "FTM",
|
||||
explorerurl: "https://testnet.ftmscan.com",
|
||||
symbol: 'FTM',
|
||||
explorerurl: 'https://testnet.ftmscan.com',
|
||||
},
|
||||
{
|
||||
name: "IoTeX Mainnet RPC",
|
||||
type: "Mainnet",
|
||||
rpc: "https://babel-api.mainnet.iotex.io",
|
||||
name: 'IoTeX Mainnet RPC',
|
||||
type: 'Mainnet',
|
||||
rpc: 'https://babel-api.mainnet.iotex.io',
|
||||
id: 4689,
|
||||
symbol: "IOTEX",
|
||||
explorerurl: "https://iotexscan.io/",
|
||||
symbol: 'IOTEX',
|
||||
explorerurl: 'https://iotexscan.io/',
|
||||
},
|
||||
{
|
||||
name: "Nahmii Mainnet RPC",
|
||||
type: "Mainnet",
|
||||
rpc: "https://l2.nahmii.io/",
|
||||
name: 'Nahmii Mainnet RPC',
|
||||
type: 'Mainnet',
|
||||
rpc: 'https://l2.nahmii.io/',
|
||||
id: 5551,
|
||||
symbol: "ETH",
|
||||
explorerurl: "https://explorer.nahmii.io/",
|
||||
symbol: 'ETH',
|
||||
explorerurl: 'https://explorer.nahmii.io/',
|
||||
},
|
||||
{
|
||||
name: "Nahmii Testnet RPC",
|
||||
type: "Testnet",
|
||||
rpc: "https://l2.testnet.nahmii.io/",
|
||||
name: 'Nahmii Testnet RPC',
|
||||
type: 'Testnet',
|
||||
rpc: 'https://l2.testnet.nahmii.io/',
|
||||
id: 5553,
|
||||
symbol: "ETH",
|
||||
explorerurl: "https://explorer.testnet.nahmii.io/",
|
||||
symbol: 'ETH',
|
||||
explorerurl: 'https://explorer.testnet.nahmii.io/',
|
||||
},
|
||||
{
|
||||
name: "Arbitrum Mainnet RPC",
|
||||
type: "Mainnet",
|
||||
rpc: "https://rpc.ankr.com/arbitrum",
|
||||
name: 'Arbitrum One',
|
||||
type: 'Mainnet',
|
||||
rpc: 'https://arb1.arbitrum.io/rpc',
|
||||
id: 42161,
|
||||
symbol: "ETH",
|
||||
explorerurl: "https://arbiscan.io/",
|
||||
network: 'ARBITRUM',
|
||||
symbol: 'ETH',
|
||||
explorerurl: 'https://arbiscan.io/',
|
||||
},
|
||||
{
|
||||
name: "Celo Mainnet RPC",
|
||||
type: "Mainnet",
|
||||
rpc: "https://rpc.ankr.com/celo",
|
||||
name: 'Arbitrum Goerli',
|
||||
type: 'Testnet',
|
||||
rpc: 'https://endpoints.omniatech.io/v1/arbitrum/goerli/public',
|
||||
id: 421613,
|
||||
network: 'AGOR',
|
||||
symbol: 'AGOR',
|
||||
explorerurl: 'https://testnet.arbiscan.io',
|
||||
},
|
||||
{
|
||||
name: 'Celo Mainnet RPC',
|
||||
type: 'Mainnet',
|
||||
rpc: 'https://rpc.ankr.com/celo',
|
||||
id: 42220,
|
||||
symbol: "CELO",
|
||||
explorerurl: "https://celoscan.com",
|
||||
symbol: 'CELO',
|
||||
explorerurl: 'https://celoscan.com',
|
||||
},
|
||||
{
|
||||
name: "Avalanche C Chain Local RPC",
|
||||
type: "Testnet",
|
||||
rpc: "https://localhost:9650/ext/bc/C/rpc",
|
||||
name: 'Avalanche C Chain Local RPC',
|
||||
type: 'Testnet',
|
||||
rpc: 'https://localhost:9650/ext/bc/C/rpc',
|
||||
id: 43112,
|
||||
symbol: "AVAX",
|
||||
explorerurl: "https://snowtrace.io",
|
||||
symbol: 'AVAX',
|
||||
explorerurl: 'https://snowtrace.io',
|
||||
},
|
||||
{
|
||||
name: "Avalanche FUJI Testnet RPC",
|
||||
type: "Testnet",
|
||||
rpc: "https://api.avax-test.network/ext/bc/C/rpc",
|
||||
name: 'Avalanche FUJI Testnet RPC',
|
||||
type: 'Testnet',
|
||||
rpc: 'https://api.avax-test.network/ext/bc/C/rpc',
|
||||
id: 43113,
|
||||
symbol: "AVAX",
|
||||
explorerurl: "https://testnet.explorer.avax.network/",
|
||||
symbol: 'AVAX',
|
||||
explorerurl: 'https://testnet.explorer.avax.network/',
|
||||
},
|
||||
{
|
||||
name: "Avalanche C Chain Mainnet RPC",
|
||||
type: "Mainnet",
|
||||
rpc: "https://rpc.ankr.com/avalanche",
|
||||
name: 'Avalanche C Chain Mainnet RPC',
|
||||
type: 'Mainnet',
|
||||
rpc: 'https://rpc.ankr.com/avalanche',
|
||||
id: 43114,
|
||||
symbol: "AVAX",
|
||||
explorerurl: "https://snowtrace.io",
|
||||
symbol: 'AVAX',
|
||||
explorerurl: 'https://snowtrace.io',
|
||||
},
|
||||
{
|
||||
name: "Matic Testnet RPC",
|
||||
type: "Testnet",
|
||||
rpc: "https://rpc-mumbai.maticvigil.com",
|
||||
name: 'Matic Testnet RPC',
|
||||
type: 'Testnet',
|
||||
rpc: 'https://rpc-mumbai.maticvigil.com',
|
||||
id: 80001,
|
||||
symbol: "MATIC",
|
||||
explorerurl: "https://mumbai.polygonscan.com/",
|
||||
symbol: 'MATIC',
|
||||
explorerurl: 'https://mumbai.polygonscan.com/',
|
||||
},
|
||||
|
||||
{
|
||||
name: "Harmony Mainnet RPC",
|
||||
type: "Mainnet",
|
||||
rpc: "https://api.harmony.one/",
|
||||
name: 'Harmony Mainnet RPC',
|
||||
type: 'Mainnet',
|
||||
rpc: 'https://api.harmony.one/',
|
||||
id: 1666600000,
|
||||
symbol: "ONE",
|
||||
explorerurl: "https://explorer.harmony.one",
|
||||
symbol: 'ONE',
|
||||
explorerurl: 'https://explorer.harmony.one',
|
||||
},
|
||||
{
|
||||
name: "Harmony Testnet RPC",
|
||||
type: "Testnet",
|
||||
rpc: "https://api.s0.b.hmny.io/",
|
||||
name: 'Harmony Testnet RPC',
|
||||
type: 'Testnet',
|
||||
rpc: 'https://api.s0.b.hmny.io/',
|
||||
id: 1666700000,
|
||||
symbol: "ONE",
|
||||
explorerurl: "https://explorer.harmony.one",
|
||||
symbol: 'ONE',
|
||||
explorerurl: 'https://explorer.harmony.one',
|
||||
},
|
||||
{
|
||||
name: "Local Testnet",
|
||||
type: "Local",
|
||||
rpc: "https://login-test.kingsome.cn/rpc",
|
||||
name: 'zkSync Era Mainnet',
|
||||
type: 'Mainnet',
|
||||
rpc: 'https://mainnet.era.zksync.io',
|
||||
id: 324,
|
||||
symbol: 'ETH',
|
||||
explorerurl: 'https://explorer.zksync.io',
|
||||
},
|
||||
{
|
||||
name: 'zkSync Era Testnet',
|
||||
type: 'Testnet',
|
||||
rpc: 'https://testnet.era.zksync.dev',
|
||||
id: 280,
|
||||
symbol: 'ETH',
|
||||
explorerurl: 'https://goerli.explorer.zksync.io',
|
||||
},
|
||||
{
|
||||
name: 'Local Testnet',
|
||||
type: 'Local',
|
||||
rpc: 'https://login-test.kingsome.cn/rpc',
|
||||
id: 1338,
|
||||
symbol: "ETH",
|
||||
explorerurl: "https://explorer.harmony.one",
|
||||
symbol: 'ETH',
|
||||
explorerurl: 'https://explorer.harmony.one',
|
||||
},
|
||||
];
|
||||
|
593
src/index.ts
593
src/index.ts
@ -1,65 +1,56 @@
|
||||
import { singleton } from "./decorator/singleton.decorator";
|
||||
import Web3 from "web3";
|
||||
import { recoverTypedSignature, signTypedData, SignTypedDataVersion } from '@metamask/eth-sig-util';
|
||||
import Web3 from 'web3';
|
||||
import 'whatwg-fetch';
|
||||
import { JazzIcon } from './comp/JazzIcon';
|
||||
import { ZWalletConnect } from './comp/ZWalletConnect';
|
||||
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";
|
||||
import { ERC20Standard } from "./standards/ERC20Standard";
|
||||
import { ERC721Standard } from "./standards/ERC721Standard";
|
||||
import { IAccount, INFT, initAccount, initNFT } from "./data/DataModel";
|
||||
import { loadToken, saveData } from "./manage/DataManage";
|
||||
import { WALLET_STORAGE_KEY_NAME } from "./config/constants";
|
||||
import { DEFALUT_TOKENS } from "./config/chain_config";
|
||||
AVAILABLE_CHAINS,
|
||||
NATIVE_PK_PREFIX,
|
||||
PAY_API_HOST,
|
||||
PAY_API_HOST_TEST,
|
||||
TX_CONFIRM_BLOCKS,
|
||||
WALLET_STORAGE_KEY_NAME,
|
||||
} from './config/constants';
|
||||
import { AllChains } from './data/allchain';
|
||||
import { singleton } from './decorator/singleton.decorator';
|
||||
import { parseUrl } from './manage/SchemeManage';
|
||||
import {
|
||||
exportSecKey,
|
||||
loadInternalWallet,
|
||||
restoreWalletByMnemonic,
|
||||
} from "./manage/WalletManage";
|
||||
import { buildLoginSignMsg, signLogin } from "./util/sign.util";
|
||||
import { JazzIcon } from "./comp/JazzIcon";
|
||||
import { ERC1155Standard } from "./standards/ERC1155Standard";
|
||||
import { ZWalletConnect } from "./comp/ZWalletConnect";
|
||||
import { getJCErc721Info, getTypeByAddress, UNKNOW } from "./util/chain.util";
|
||||
import { JCStandard } from "./standards/JCStandard";
|
||||
import { NativeSvr } from "./services/NativeSvr";
|
||||
import { ChainCommon } from "./standards/ChainCommon";
|
||||
import { fromTokenMinimalUnit } from "./util/number.util";
|
||||
loginByEmail,
|
||||
syncWalletEnv,
|
||||
verifyPassword,
|
||||
walletPreLogin,
|
||||
} from './manage/WalletManage';
|
||||
import { EmailVerifySvr } from './services/EmailVerifySvr';
|
||||
import { NativeSvr } from './services/NativeSvr';
|
||||
import { PaySvr } from './services/PaySvr';
|
||||
import { TranHistorySvr } from './services/TranHistorySvr';
|
||||
import { ChainCommon } from './standards/ChainCommon';
|
||||
import { ERC1155Standard } from './standards/ERC1155Standard';
|
||||
import { ERC20Standard } from './standards/ERC20Standard';
|
||||
import { ERC721Standard } from './standards/ERC721Standard';
|
||||
import { JCStandard } from './standards/JCStandard';
|
||||
import { WalletType } from './types/data.enums';
|
||||
import { IChainData } from './types/data.types';
|
||||
import { universalChainCb } from './util/chain.util';
|
||||
import { fromTokenMinimalUnit, renderFromTokenMinimalUnit, safeNumberToBN } from './util/number.util';
|
||||
import { buildLoginSignMsg, signLogin } from './util/sign.util';
|
||||
import { resetAccount, resetWallet } from './api/WalletApi';
|
||||
|
||||
var global =
|
||||
(typeof globalThis !== "undefined" && globalThis) ||
|
||||
(typeof self !== "undefined" && self) ||
|
||||
(typeof global !== "undefined" && global) ||
|
||||
(typeof globalThis !== 'undefined' && globalThis) ||
|
||||
(typeof self !== 'undefined' && self) ||
|
||||
(typeof global !== 'undefined' && global) ||
|
||||
{};
|
||||
|
||||
window.debug = false;
|
||||
window.debug = true;
|
||||
|
||||
export interface IChainData {
|
||||
name: string;
|
||||
type: string;
|
||||
rpc: string;
|
||||
id: number;
|
||||
symbol: string;
|
||||
explorerurl: string;
|
||||
decimals?: number;
|
||||
}
|
||||
|
||||
export enum WalletType {
|
||||
INTERNAL = 0,
|
||||
THIRD_PATH = 1,
|
||||
}
|
||||
@singleton
|
||||
export default class JCWallet {
|
||||
web3: Web3 = null;
|
||||
private wallet: any = null;
|
||||
private password: string = "111111";
|
||||
private password: string = '111111';
|
||||
private chainSet: Set<number> = new Set();
|
||||
private chainMap: Map<number, IChainData> = new Map();
|
||||
private _currentChain: IChainData;
|
||||
@ -69,77 +60,107 @@ export default class JCWallet {
|
||||
public chainCommon: ChainCommon;
|
||||
public jcStandard: JCStandard;
|
||||
public nativeSvr: NativeSvr;
|
||||
public historySvr: TranHistorySvr;
|
||||
public emailVerifySvr: EmailVerifySvr;
|
||||
public paySvr: PaySvr;
|
||||
public wConnect: ZWalletConnect;
|
||||
public mainHandlers = createWalletEvents();
|
||||
public data: IAccount[] = [];
|
||||
public iconType = "jazz";
|
||||
private accountIndex = 0;
|
||||
private walletType: WalletType = WalletType.INTERNAL;
|
||||
private rpcUrl: string = "";
|
||||
private rpcUrl: string = '';
|
||||
public rpc: any = {};
|
||||
public nativeAccount = "";
|
||||
public nativeAccount = '';
|
||||
public env = 'dev';
|
||||
private web3Map = new Map();
|
||||
|
||||
constructor({ type, chain }: { type: number; chain: number }) {
|
||||
constructor({ type }: { type: number }) {
|
||||
this.nativeSvr = new NativeSvr();
|
||||
this.historySvr = new TranHistorySvr();
|
||||
this.emailVerifySvr = new EmailVerifySvr();
|
||||
this.paySvr = new PaySvr();
|
||||
this.walletType = type;
|
||||
window.jc = { wallet: this };
|
||||
this.init();
|
||||
}
|
||||
|
||||
private updateChain(chain: number) {
|
||||
chain = chain || 80001;
|
||||
let data = AllChains.find((o) => o.id === chain);
|
||||
let data = this.chainMap.get(chain);
|
||||
if (!data) {
|
||||
throw new Error("no current chain data");
|
||||
throw new Error('no current chain data');
|
||||
}
|
||||
this._currentChain = data;
|
||||
this.rpcUrl = data.rpc;
|
||||
console.log(`rpc url: ${this.rpcUrl}`);
|
||||
this.init({ chains: [chain], password: this.password });
|
||||
window.jc = { wallet: this };
|
||||
}
|
||||
|
||||
public get isInternal() {
|
||||
return this.walletType === WalletType.INTERNAL;
|
||||
}
|
||||
|
||||
public async initInternalWallet(channel: number) {
|
||||
public get payUrl() {
|
||||
if (this.env === 'release') {
|
||||
return PAY_API_HOST;
|
||||
} else {
|
||||
return PAY_API_HOST_TEST;
|
||||
}
|
||||
}
|
||||
|
||||
public get platform() {
|
||||
// @ts-ignore
|
||||
if (window.JavascriptJavaBridge) {
|
||||
console.log('regist android jsb.reflection');
|
||||
return 'android';
|
||||
// @ts-ignore
|
||||
} else if (window.JavaScriptObjCBridge) {
|
||||
return 'ios';
|
||||
}
|
||||
}
|
||||
|
||||
public preLogin(channel: number, env: string = 'dev') {
|
||||
this.env = env;
|
||||
return walletPreLogin(channel);
|
||||
}
|
||||
|
||||
public verifyLocalPass(pass: string) {
|
||||
return verifyPassword(pass);
|
||||
}
|
||||
|
||||
public exportPrivateKey(pass: string) {
|
||||
return exportSecKey(pass);
|
||||
}
|
||||
|
||||
public emailLogin(email: string, password: string) {
|
||||
return loginByEmail(email, password);
|
||||
}
|
||||
|
||||
public async initInternalWallet(chain: number, pass: string, env: string = 'dev') {
|
||||
this.env = env;
|
||||
this.walletType = WalletType.INTERNAL;
|
||||
let address: string = await loadInternalWallet(channel);
|
||||
this.updateChain(chain);
|
||||
let address: string = await loadInternalWallet(pass);
|
||||
this.nativeAccount = address;
|
||||
console.log("native wallet address: " + address);
|
||||
console.log('native wallet address: ' + address);
|
||||
var start = Date.now();
|
||||
this.web3 = new Web3(this.rpcUrl);
|
||||
console.log(`init web3 cost: ${(Date.now() - start) / 1000}`);
|
||||
this.web3 = this.generateWeb3(chain);
|
||||
console.log(`init web3 cost: ${(Date.now() - start) / 1000}s`);
|
||||
this.erc20Standard = new ERC20Standard(this.web3);
|
||||
console.log("init Erc20Standard");
|
||||
console.log('init Erc20Standard');
|
||||
this.erc721Standard = new ERC721Standard(this.web3);
|
||||
console.log("init Erc721Standard");
|
||||
console.log('init Erc721Standard');
|
||||
this.erc1155Standard = new ERC1155Standard(this.web3);
|
||||
console.log("init ERC1155Standard");
|
||||
console.log('init ERC1155Standard');
|
||||
this.jcStandard = new JCStandard(this.web3);
|
||||
this.chainCommon = new ChainCommon(this.web3);
|
||||
console.log("init JCStandard");
|
||||
this.createAccount();
|
||||
// this.wallet = this.web3.eth.accounts.wallet.load(
|
||||
// this.password,
|
||||
// WALLET_STORAGE_KEY_NAME
|
||||
// );
|
||||
// console.log(`load wallet cost: ${(Date.now() - start) / 1000}`);
|
||||
console.log(JSON.stringify(this.wallet[0]));
|
||||
console.log(
|
||||
"this.web3.eth.defaultAccount: " +
|
||||
JSON.stringify(this.web3.eth.defaultAccount)
|
||||
);
|
||||
// if (!this.wallet || this.wallet.length === 0) {
|
||||
// // this.createAccount();
|
||||
// this.newWallet(this.password);
|
||||
// }
|
||||
// start = Date.now();
|
||||
// this.data = loadData();
|
||||
// console.log(`init wallet ext data cost: ${(Date.now() - start) / 1000}`);
|
||||
console.log('init JCStandard');
|
||||
console.log('this.web3.eth.defaultAccount: ' + JSON.stringify(this.web3.eth.defaultAccount));
|
||||
}
|
||||
/**
|
||||
* init wallet connect
|
||||
* @returns
|
||||
*/
|
||||
public async initThirdPartyWallet() {
|
||||
public async initThirdPartyWallet(chain: number, env: string = 'dev') {
|
||||
this.env = env;
|
||||
this.walletType = WalletType.THIRD_PATH;
|
||||
this.updateChain(chain);
|
||||
return new Promise(async (resolve, reject) => {
|
||||
for (const d of AllChains) {
|
||||
const id = d.id;
|
||||
@ -164,19 +185,19 @@ export default class JCWallet {
|
||||
})
|
||||
.then((chainId: number) => {
|
||||
if (chainId === this._currentChain.id) {
|
||||
resolve && resolve("");
|
||||
resolve && resolve('');
|
||||
} else {
|
||||
this.updateCurrentChain(this.currentChain.id)
|
||||
.then(() => {
|
||||
resolve && resolve("");
|
||||
resolve && resolve('');
|
||||
})
|
||||
.catch((err) => {
|
||||
reject && reject("error change network");
|
||||
reject && reject('error change network');
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch((err: Error) => {
|
||||
console.log("initThirdPartyWallet error: " + err);
|
||||
console.log('initThirdPartyWallet error: ' + err);
|
||||
reject && reject(err.message);
|
||||
});
|
||||
});
|
||||
@ -186,52 +207,40 @@ export default class JCWallet {
|
||||
* create local wallet data if there is no local wallet data
|
||||
* @returns
|
||||
*/
|
||||
private init({ chains, password }: { chains: number[]; password: string }) {
|
||||
for (let chain of chains) {
|
||||
private init() {
|
||||
for (let chain of AVAILABLE_CHAINS) {
|
||||
this.chainSet.add(chain);
|
||||
if (!this.chainMap.has(chain)) {
|
||||
let data = AllChains.find((o) => o.id === chain);
|
||||
if (data) {
|
||||
this.chainMap.set(chain, data);
|
||||
if (!this._currentChain) {
|
||||
this._currentChain = data;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
// if (this.walletType !== WalletType.INTERNAL) {
|
||||
// return;
|
||||
// }
|
||||
}
|
||||
|
||||
public newWallet(password: string) {
|
||||
this.password = password;
|
||||
this.createAccount();
|
||||
}
|
||||
|
||||
private restoreFromMnemonic(mnemonic: string, password: string) {
|
||||
this.password = password;
|
||||
this.wallet.clear();
|
||||
restoreWalletByMnemonic(mnemonic, this.password);
|
||||
return this.createAccount();
|
||||
}
|
||||
|
||||
get currentChain() {
|
||||
return this._currentChain;
|
||||
}
|
||||
|
||||
get currentChainCfg() {
|
||||
return require(`./config/cfg_${this.currentChain.id}_${this.env}.js`);
|
||||
}
|
||||
|
||||
updateCurrentChain(chainId: number) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (this.walletType === WalletType.INTERNAL) {
|
||||
const chainData = this.chainMap.get(chainId);
|
||||
if (!chainData) {
|
||||
reject && reject('chain data not found');
|
||||
return;
|
||||
}
|
||||
this._currentChain = chainData;
|
||||
this.web3.eth.setProvider(chainData.rpc);
|
||||
this.mainHandlers.emit(WALLET_CHAIN_CHANGE, chainData);
|
||||
this.updateListType("tokens");
|
||||
resolve && resolve(this.currentChain);
|
||||
} else {
|
||||
console.log("third party wallet change chain: " + chainId);
|
||||
console.log('third party wallet change chain: ' + chainId);
|
||||
const chainData = this.chainMap.get(chainId);
|
||||
this.wConnect
|
||||
.addOrChangeChain(chainData)
|
||||
@ -249,29 +258,33 @@ export default class JCWallet {
|
||||
});
|
||||
}
|
||||
|
||||
updateListType(type: string) {
|
||||
this.mainHandlers.emit(WALLET_TOKEN_TYPE_CHANGE, type);
|
||||
}
|
||||
|
||||
get chainList() {
|
||||
return [...this.chainMap.values()];
|
||||
}
|
||||
|
||||
public saveLocal() {}
|
||||
|
||||
public loadLocal() {}
|
||||
|
||||
public saveRemote() {}
|
||||
|
||||
public loadRemote() {}
|
||||
|
||||
public currentAccount() {
|
||||
if (this.walletType === WalletType.INTERNAL) {
|
||||
return this.wallet[this.accountIndex];
|
||||
return this.wallet[0];
|
||||
} else {
|
||||
return this.wConnect.accounts[0];
|
||||
}
|
||||
}
|
||||
|
||||
public generateWeb3(chainId: number, isDefault: boolean = true) {
|
||||
if (this.web3Map.has(chainId)) {
|
||||
return this.web3Map.get(chainId);
|
||||
}
|
||||
const chainData = this.chainMap.get(chainId);
|
||||
if (!chainData) {
|
||||
return null;
|
||||
}
|
||||
let web3 = new Web3(chainData.rpc);
|
||||
web3.eth.transactionConfirmationBlocks = TX_CONFIRM_BLOCKS;
|
||||
this.injectAccount(web3, isDefault);
|
||||
this.web3Map.set(chainId, web3);
|
||||
return web3;
|
||||
}
|
||||
|
||||
public get currentAccAddr() {
|
||||
if (this.walletType === WalletType.INTERNAL) {
|
||||
return this.nativeAccount;
|
||||
@ -280,147 +293,90 @@ export default class JCWallet {
|
||||
}
|
||||
}
|
||||
|
||||
get currentAccountData() {
|
||||
let address = this.currentAccAddr;
|
||||
const chain = this.currentChain.id;
|
||||
let data = this.data.find((o) => o.address === address);
|
||||
if (!data) {
|
||||
throw new Error("account data not found");
|
||||
public injectAccount(web3: any, isDefault: boolean = true) {
|
||||
const nativePrivateKey = `${NATIVE_PK_PREFIX}${this.currentAccAddr.slice(2)}`;
|
||||
const acc = web3.eth.accounts.privateKeyToAccount(nativePrivateKey);
|
||||
const account = web3.eth.accounts.wallet.add(acc);
|
||||
web3.eth.defaultAccount = account.address;
|
||||
console.log('web3 account: ' + JSON.stringify(web3.eth.accounts.wallet[0]));
|
||||
if (isDefault) {
|
||||
this.wallet = web3.eth.accounts.wallet;
|
||||
web3.eth.accounts.wallet.save(this.password, WALLET_STORAGE_KEY_NAME);
|
||||
}
|
||||
|
||||
if (!data.tokenData[chain]) {
|
||||
let tokens = DEFALUT_TOKENS[chain];
|
||||
data.tokenData[chain] = {
|
||||
tokens,
|
||||
heros: [],
|
||||
weapons: [],
|
||||
chips: [],
|
||||
};
|
||||
}
|
||||
|
||||
saveData(this.data);
|
||||
return data;
|
||||
}
|
||||
|
||||
get accounts() {
|
||||
return this.data;
|
||||
}
|
||||
|
||||
public createAccount() {
|
||||
// let account = this.web3.eth.accounts.create()
|
||||
this.wallet = this.web3.eth.accounts.wallet;
|
||||
const index = this.getMaxIdexOfType(0);
|
||||
const nativePrefix = "0x000000000000000000000000";
|
||||
const nativePrivateKey = `${nativePrefix}${this.currentAccAddr.slice(2)}`;
|
||||
const acc = this.web3.eth.accounts.privateKeyToAccount(nativePrivateKey);
|
||||
const account = this.wallet.add(acc);
|
||||
this.web3.eth.defaultAccount = account.address;
|
||||
console.log("web3 account: " + JSON.stringify(this.wallet[0]));
|
||||
|
||||
this.wallet.save(this.password, WALLET_STORAGE_KEY_NAME);
|
||||
const chain = this.currentChain.id;
|
||||
let data = this.data.find((o) => o.address === account.address);
|
||||
if (!data) {
|
||||
const nickname = `Account ${index + 1}`;
|
||||
data = initAccount({
|
||||
address: account.address,
|
||||
chain,
|
||||
nickname,
|
||||
type: 0,
|
||||
index,
|
||||
});
|
||||
this.data.push(data);
|
||||
saveData(this.data);
|
||||
}
|
||||
|
||||
this.accountIndex = this.wallet.length - 1;
|
||||
this.mainHandlers.emit(WALLET_ACCOUNT_CHANGE, account.address);
|
||||
return account.address;
|
||||
}
|
||||
|
||||
public importAccount(privateKey: string) {
|
||||
const account = this.wallet.add(privateKey);
|
||||
const chain = this.currentChain.id;
|
||||
let data = this.data.find((o) => o.address === account.address);
|
||||
if (!data) {
|
||||
const index = this.getMaxIdexOfType(1);
|
||||
const nickname = `Imported ${index + 1}`;
|
||||
data = initAccount({
|
||||
address: account.address,
|
||||
chain,
|
||||
nickname,
|
||||
type: 1,
|
||||
index,
|
||||
});
|
||||
this.data.push(data);
|
||||
saveData(this.data);
|
||||
}
|
||||
this.web3.eth.accounts.wallet.save(this.password, WALLET_STORAGE_KEY_NAME);
|
||||
this.accountIndex = this.wallet.length - 1;
|
||||
this.mainHandlers.emit(WALLET_ACCOUNT_CHANGE, account.address);
|
||||
return account.address;
|
||||
}
|
||||
|
||||
private getMaxIdexOfType(type: number) {
|
||||
let maxIdx = -1;
|
||||
for (let i = 0, l = this.data.length; i < l; i++) {
|
||||
if (this.data[i].type !== type) {
|
||||
continue;
|
||||
}
|
||||
maxIdx = Math.max(this.data[i].index, maxIdx);
|
||||
}
|
||||
return maxIdx + 1;
|
||||
}
|
||||
private getAccountByAddress(address: string) {
|
||||
let account;
|
||||
let index = 0;
|
||||
for (let i = 0, l = this.wallet.length; i < l; i++) {
|
||||
if (this.wallet[i].address === address) {
|
||||
account = this.wallet[i];
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return { account, index };
|
||||
}
|
||||
|
||||
public selectAccount(address: string) {
|
||||
const { index } = this.getAccountByAddress(address);
|
||||
if (index !== this.accountIndex && index < this.wallet.length) {
|
||||
this.accountIndex = index;
|
||||
this.mainHandlers.emit(WALLET_ACCOUNT_CHANGE, this.wallet[index].address);
|
||||
}
|
||||
return address;
|
||||
}
|
||||
|
||||
public async generateGasShow(gas: any) {
|
||||
let price = await this.web3.eth.getGasPrice();
|
||||
let ehtBN = this.web3.utils.toBN(price).mul(this.web3.utils.toBN(gas));
|
||||
let chainData = this.currentChain;
|
||||
let price = await new PaySvr().getGasPrice(chainData.id);
|
||||
let ehtBN = safeNumberToBN(price).mul(safeNumberToBN(gas));
|
||||
let ethSymbol = chainData.type !== 'Testnet' ? chainData.symbol : 'ETH';
|
||||
let network = chainData.type !== 'Testnet' ? chainData.network || chainData.symbol : 'ETH';
|
||||
let fiatPrice = await new PaySvr().queryTokenPrice(network, ethSymbol);
|
||||
let priceFloat = parseFloat(fiatPrice) * 100;
|
||||
let fiatPriceBN = safeNumberToBN(priceFloat);
|
||||
let usd = fromTokenMinimalUnit(ehtBN.mul(fiatPriceBN), 20);
|
||||
let eth = fromTokenMinimalUnit(ehtBN, 18);
|
||||
return { gas, price, eth };
|
||||
return { gas, price, eth, usd };
|
||||
}
|
||||
|
||||
public async fetchGasPrice() {
|
||||
let gasPrice = await this.web3.eth.getGasPrice();
|
||||
console.log('fetchGasPrice::' + gasPrice);
|
||||
let gasPriceNum = (parseInt(gasPrice) * 1.3) | 0;
|
||||
return gasPriceNum + '';
|
||||
}
|
||||
/**
|
||||
* 查询token的法币价格
|
||||
* token 必须已经在去中心化交易所上架
|
||||
* @param tokenName token名称
|
||||
* @param amount token数量
|
||||
* @returns
|
||||
*/
|
||||
public async calcTokenPrice(tokenName: string, amount: string) {
|
||||
let chainData = this.currentChain;
|
||||
let network = chainData.type !== 'Testnet' ? chainData.network || chainData.symbol : 'ETH';
|
||||
let env = this.env;
|
||||
let fiatPrice = await new PaySvr().queryTokenPrice(network, tokenName, env);
|
||||
let priceFloat = parseFloat(fiatPrice);
|
||||
return priceFloat * parseFloat(amount);
|
||||
}
|
||||
|
||||
public async sendEth(to: string, amount: number | string, estimate: number) {
|
||||
let from = this.currentAccAddr;
|
||||
const amountToSend = this.web3.utils.toWei(amount + "", "ether");
|
||||
const amountToSend = this.web3.utils.toWei(amount + '', 'ether');
|
||||
let gas = await this.web3.eth.estimateGas({
|
||||
from,
|
||||
to,
|
||||
value: amountToSend,
|
||||
value: '0',
|
||||
});
|
||||
if (estimate) {
|
||||
return this.generateGasShow(gas);
|
||||
}
|
||||
return this.web3.eth.sendTransaction({
|
||||
const reqData = {
|
||||
from,
|
||||
to,
|
||||
gas,
|
||||
value: amountToSend,
|
||||
});
|
||||
};
|
||||
const logData = {
|
||||
gas,
|
||||
title: 'transfer',
|
||||
details: [
|
||||
{
|
||||
address: 'eth',
|
||||
from,
|
||||
to,
|
||||
value: amountToSend,
|
||||
id: '0',
|
||||
},
|
||||
],
|
||||
};
|
||||
return universalChainCb(logData, this.web3.eth.sendTransaction(reqData));
|
||||
}
|
||||
|
||||
public async getBalance(account?: string) {
|
||||
console.log("get balance with address: ", account);
|
||||
console.log('get balance with address: ', account);
|
||||
let balance = await this.chainCommon.getBalance(account);
|
||||
return balance;
|
||||
}
|
||||
@ -429,7 +385,7 @@ export default class JCWallet {
|
||||
const account = this.currentAccount();
|
||||
return signTypedData({
|
||||
data: signObj,
|
||||
privateKey: Buffer.from(account.privateKey.replace("0x", ""), "hex"),
|
||||
privateKey: Buffer.from(account.privateKey.replace('0x', ''), 'hex'),
|
||||
version: SignTypedDataVersion.V4,
|
||||
});
|
||||
}
|
||||
@ -471,6 +427,10 @@ export default class JCWallet {
|
||||
return icon.init(msg, diameter);
|
||||
}
|
||||
|
||||
public formatPrice(value: string | number, decimal: number, fixed: number) {
|
||||
return renderFromTokenMinimalUnit(value, decimal, fixed);
|
||||
}
|
||||
|
||||
public async erc20Info(address: string) {
|
||||
let symbol = await this.erc20Standard.getTokenSymbol(address);
|
||||
let decimal = await this.erc20Standard.getTokenDecimals(address);
|
||||
@ -485,12 +445,7 @@ export default class JCWallet {
|
||||
return result;
|
||||
}
|
||||
|
||||
public async sendErc20(
|
||||
address: string,
|
||||
to: string,
|
||||
amount: string,
|
||||
estimate: number
|
||||
) {
|
||||
public async sendErc20(address: string, to: string, amount: string, estimate: number) {
|
||||
let from = this.currentAccAddr;
|
||||
let result = await this.erc20Standard.transfer({
|
||||
address,
|
||||
@ -502,75 +457,7 @@ export default class JCWallet {
|
||||
return result;
|
||||
}
|
||||
|
||||
private async updateTokenInfo(
|
||||
data: INFT,
|
||||
address: string,
|
||||
index: number,
|
||||
account: string
|
||||
) {
|
||||
const tokenId = await this.wallet.erc721Standard.getCollectibleTokenId(
|
||||
address,
|
||||
account,
|
||||
index
|
||||
);
|
||||
const info = await getJCErc721Info(tokenId);
|
||||
data.tokenId = tokenId;
|
||||
data.name = info.name;
|
||||
data.desc = info.description;
|
||||
data.image = info.image;
|
||||
data.last = Date.now();
|
||||
}
|
||||
|
||||
public async nftInfo(
|
||||
address: string,
|
||||
index: number,
|
||||
account: string,
|
||||
refresh: boolean
|
||||
) {
|
||||
account = account || this.currentAccAddr;
|
||||
const chain = this.wallet.currentChain.id;
|
||||
const { categor, type } = getTypeByAddress(chain, address);
|
||||
let nfts = [];
|
||||
if (categor !== UNKNOW) {
|
||||
nfts = this.currentAccountData.tokenData[chain][`${categor}s`];
|
||||
}
|
||||
let needRefresh = !(nfts.length > index && nfts[index].tokenId && !refresh);
|
||||
if (needRefresh) {
|
||||
this.updateTokenInfo(nfts[index], address, index, account);
|
||||
saveData(this.data);
|
||||
}
|
||||
return nfts[index];
|
||||
}
|
||||
|
||||
public async nftList(address: string, account?: string) {
|
||||
account = account || this.currentAccAddr;
|
||||
const chain = this.wallet.currentChain.id;
|
||||
const amount = await this.erc721Standard.getBalance(address, account);
|
||||
const { categor, type } = getTypeByAddress(chain, address);
|
||||
let nfts = [];
|
||||
if (categor !== UNKNOW) {
|
||||
nfts = this.currentAccountData.tokenData[chain][`${categor}s`];
|
||||
}
|
||||
let refresh = false;
|
||||
if (nfts.length !== amount) {
|
||||
refresh = true;
|
||||
}
|
||||
if (refresh) {
|
||||
nfts.length = 0;
|
||||
for (let i = 0; i < amount; i++) {
|
||||
const nftData = initNFT(address, i, type);
|
||||
nfts.push(nftData);
|
||||
}
|
||||
}
|
||||
return nfts;
|
||||
}
|
||||
|
||||
public async sendNFT(
|
||||
address: string,
|
||||
to: string,
|
||||
tokenId: string,
|
||||
estimate: number
|
||||
) {
|
||||
public async sendNFT(address: string, to: string, tokenId: string, estimate: number) {
|
||||
let from = this.currentAccAddr;
|
||||
return this.erc721Standard.transfer({
|
||||
address,
|
||||
@ -581,16 +468,8 @@ export default class JCWallet {
|
||||
});
|
||||
}
|
||||
|
||||
public async erc1155Balance(
|
||||
address: string,
|
||||
account: string,
|
||||
tokenId: string
|
||||
) {
|
||||
let result = await this.erc1155Standard.getBalanceOf(
|
||||
address,
|
||||
account,
|
||||
tokenId
|
||||
);
|
||||
public async erc1155Balance(address: string, account: string, tokenId: string) {
|
||||
let result = await this.erc1155Standard.getBalanceOf(address, account, tokenId);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -602,13 +481,7 @@ export default class JCWallet {
|
||||
}
|
||||
}
|
||||
|
||||
public async sendErc1155(
|
||||
address: string,
|
||||
to: string,
|
||||
tokenIds: string[],
|
||||
amounts: string[],
|
||||
estimate: number
|
||||
) {
|
||||
public async sendErc1155(address: string, to: string, tokenIds: string[], amounts: string[], estimate: number) {
|
||||
let from = this.currentAccAddr;
|
||||
return this.erc1155Standard.transferBatch({
|
||||
address,
|
||||
@ -619,14 +492,42 @@ export default class JCWallet {
|
||||
estimate,
|
||||
});
|
||||
}
|
||||
|
||||
public async scanQr(title: string) {
|
||||
let result = (await this.nativeSvr.scanQRCode(title)) + '';
|
||||
console.log('scan qr code: ' + result);
|
||||
if (result && result.indexOf('://') >= 0) {
|
||||
parseUrl(result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public async deleteAccount() {
|
||||
await resetAccount();
|
||||
return {};
|
||||
}
|
||||
|
||||
public async resetWalletAddress() {
|
||||
await resetWallet();
|
||||
await syncWalletEnv();
|
||||
return {};
|
||||
}
|
||||
|
||||
public saveLocalItem(key: string, value: string) {
|
||||
jsb.saveLocalStorage(key, value);
|
||||
}
|
||||
|
||||
public loadLocalItem(key: string) {
|
||||
let val = jsb.loadLocalStorage(key);
|
||||
console.log('loadLocalItem:: ' + val);
|
||||
return val;
|
||||
}
|
||||
}
|
||||
|
||||
// window.jc = window.jc || {wallet: new JCWallet()};
|
||||
|
||||
export * from "./common/WalletEvent";
|
||||
export * from "./common/ZError";
|
||||
export * from "./config/chain_config";
|
||||
export * from "./util/number.util";
|
||||
export * from "./util/wallet.util";
|
||||
export * from "./data/DataModel";
|
||||
export * from "./lib/WalletConnect";
|
||||
export * from './common/WalletEvent';
|
||||
export * from './common/ZError';
|
||||
export * from './lib/WalletConnect';
|
||||
export * from './util/number.util';
|
||||
export * from './util/wallet.util';
|
||||
|
@ -1,47 +1,79 @@
|
||||
import "whatwg-fetch";
|
||||
import { WalletEnv } from "../config/WalletEnv";
|
||||
import { fetch } from 'whatwg-fetch';
|
||||
import { WalletEnv } from '../config/WalletEnv';
|
||||
import { VERSION_CODE } from '../config/constants';
|
||||
|
||||
export async function request(url, option) {
|
||||
export function request(url, option) {
|
||||
let headers = new Headers();
|
||||
headers.append("Content-Type", "application/json");
|
||||
headers.append('Content-Type', 'application/json');
|
||||
let walletEnv = new WalletEnv();
|
||||
if (walletEnv.token) {
|
||||
headers.append("Authorization", `Bearer ${walletEnv.token}`);
|
||||
headers.append('Authorization', `Bearer ${walletEnv.token}`);
|
||||
}
|
||||
headers.append('api_version', VERSION_CODE + '');
|
||||
headers.append('api_env', jc.wallet.env);
|
||||
headers.append('api_platform', jc.wallet.platform);
|
||||
let optionInt: any = {
|
||||
method: "GET",
|
||||
mode: "cors",
|
||||
method: 'GET',
|
||||
mode: 'cors',
|
||||
headers,
|
||||
cache: "no-cache",
|
||||
cache: 'no-cache',
|
||||
};
|
||||
Object.assign(optionInt, option);
|
||||
// console.log("request option", JSON.stringify(optionInt));
|
||||
return fetch(url, optionInt);
|
||||
}
|
||||
|
||||
export async function GET(url: string) {
|
||||
export function GET(url: string) {
|
||||
return request(url, {});
|
||||
}
|
||||
|
||||
export async function GET_JSON(url: string) {
|
||||
export function GET_JSON(url: string) {
|
||||
return GET(url).then((res) => {
|
||||
return res.json();
|
||||
});
|
||||
}
|
||||
|
||||
export async function POST(url, data) {
|
||||
export function POST(url, data) {
|
||||
let option = {
|
||||
method: "POST",
|
||||
method: 'POST',
|
||||
body: JSON.stringify(data),
|
||||
};
|
||||
return request(url, option);
|
||||
}
|
||||
|
||||
export async function POST_JSON(url, data) {
|
||||
export function DELETE(url, data) {
|
||||
let option = {
|
||||
method: 'DELETE',
|
||||
body: JSON.stringify(data),
|
||||
};
|
||||
return request(url, option);
|
||||
}
|
||||
|
||||
export function PUT(url, data) {
|
||||
let option = {
|
||||
method: 'PUT',
|
||||
body: JSON.stringify(data),
|
||||
};
|
||||
return request(url, option);
|
||||
}
|
||||
|
||||
export function POST_JSON(url, data) {
|
||||
return POST(url, data).then((res) => {
|
||||
return res.json();
|
||||
});
|
||||
}
|
||||
|
||||
export function DELETE_JSON(url, data) {
|
||||
return DELETE(url, data).then((res) => {
|
||||
return res.json();
|
||||
});
|
||||
}
|
||||
|
||||
export function PUT_JSON(url, data) {
|
||||
return PUT(url, data).then((res) => {
|
||||
return res.json();
|
||||
});
|
||||
}
|
||||
/**
|
||||
* var headers = new Headers();
|
||||
headers.append("Content-Type", "application/json");
|
||||
|
@ -1,4 +1,3 @@
|
||||
import { IAccount } from "../data/DataModel";
|
||||
import { aesDecrypt, aesEncrypt } from "../util/crypto.util";
|
||||
import sha256 from "crypto-js/sha256";
|
||||
|
||||
@ -18,7 +17,7 @@ export function saveToken(token: string) {
|
||||
|
||||
export function loadData() {
|
||||
const dataStr = localStorage.getItem(LOCAL_ACCOUNT_DATAS);
|
||||
let result: IAccount[] = [];
|
||||
let result = [];
|
||||
if (dataStr) {
|
||||
try {
|
||||
result = JSON.parse(dataStr);
|
||||
@ -29,7 +28,7 @@ export function loadData() {
|
||||
return result;
|
||||
}
|
||||
|
||||
export function saveData(datas: IAccount[]) {
|
||||
export function saveData(datas: []) {
|
||||
const dataStr = JSON.stringify(datas);
|
||||
localStorage.setItem(LOCAL_ACCOUNT_DATAS, dataStr);
|
||||
}
|
||||
|
17
src/manage/SchemeManage.ts
Normal file
17
src/manage/SchemeManage.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import { findUrlScheme } from "../util/string.util";
|
||||
import { parseWebLogin } from "./WalletManage";
|
||||
|
||||
export function parseUrl(str: string) {
|
||||
let scheme = findUrlScheme(str);
|
||||
if (!scheme) {
|
||||
return;
|
||||
}
|
||||
const dataStr = str.replace(scheme + "://", "");
|
||||
switch (scheme) {
|
||||
case "weblogin":
|
||||
parseWebLogin(dataStr);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
@ -1,18 +1,22 @@
|
||||
import { hdkey } from "ethereumjs-wallet";
|
||||
import { generateMnemonic, mnemonicToSeedSync } from "bip39";
|
||||
import { loadMnemonic, saveMnemonic } from "./DataManage";
|
||||
import { NativeSvr } from "../services/NativeSvr";
|
||||
import { hdkey } from 'ethereumjs-wallet';
|
||||
import { generateMnemonic, mnemonicToSeedSync } from 'bip39';
|
||||
import { loadMnemonic, saveMnemonic } from './DataManage';
|
||||
import { NativeSvr } from '../services/NativeSvr';
|
||||
import {
|
||||
appleAuth,
|
||||
clientAuth,
|
||||
facebookAuth,
|
||||
getWalletInfo,
|
||||
googleAuth,
|
||||
tikTokAuth,
|
||||
twitterAuth,
|
||||
uploadWalletInfo,
|
||||
} from "../api/WalletApi";
|
||||
import { WalletEnv } from "../config/WalletEnv";
|
||||
import { md5Hash, sha1Hash } from "../util/crypto.util";
|
||||
import { retry } from "../util/promise.util";
|
||||
import { MAX_TRY_COUNT, MAX_UPLOAD_COUNT } from "../config/constants";
|
||||
} from '../api/WalletApi';
|
||||
import { WalletEnv } from '../config/WalletEnv';
|
||||
import { retry } from '../util/promise.util';
|
||||
import { MAX_TRY_COUNT, MAX_UPLOAD_COUNT } from '../config/constants';
|
||||
import { ZError } from '../common/ZError';
|
||||
import { emailLogin } from '../api/EmailApi';
|
||||
|
||||
export function newAccount(password: string, index: number) {
|
||||
const mnemonic = loadMnemonic(password);
|
||||
@ -36,94 +40,131 @@ export function restoreWalletByMnemonic(mnemonic: string, password: string) {
|
||||
saveMnemonic(mnemonic, password);
|
||||
}
|
||||
|
||||
export async function loadInternalWallet(channel: number) {
|
||||
export async function syncWalletEnv() {
|
||||
let walletEnv = new WalletEnv();
|
||||
let infoRes = await retry(() => getWalletInfo(), MAX_TRY_COUNT);
|
||||
if (infoRes.errcode) {
|
||||
throw new ZError(infoRes.errcode, infoRes.errmsg);
|
||||
}
|
||||
walletEnv.address = infoRes.data.address;
|
||||
walletEnv.key = infoRes.data.key;
|
||||
walletEnv.salt = infoRes.data.salt;
|
||||
}
|
||||
|
||||
export async function walletPreLogin(channel: number) {
|
||||
let walletEnv = new WalletEnv();
|
||||
let tokenRes: any;
|
||||
if (channel == 1) {
|
||||
let res: any = await new NativeSvr().signWithApple();
|
||||
console.log("native apple res: " + res);
|
||||
window.debug && console.log('native apple res: ' + res);
|
||||
tokenRes = await appleAuth(res);
|
||||
} else if (channel == 2) {
|
||||
let res: any = await new NativeSvr().signWithTikTok();
|
||||
console.log("native tiktok res: " + res);
|
||||
window.debug && console.log('native tiktok res: ' + res);
|
||||
tokenRes = await tikTokAuth(res);
|
||||
} else if (channel == 3) {
|
||||
let res: any = await new NativeSvr().signWithFacebook();
|
||||
window.debug && console.log('native facebook res: ' + res);
|
||||
tokenRes = await facebookAuth(res);
|
||||
} else if (channel == 4) {
|
||||
let res: any = await new NativeSvr().signWithTwitter();
|
||||
window.debug && console.log('native twitter res: ' + res);
|
||||
tokenRes = await twitterAuth(res);
|
||||
} else if (channel == 10) {
|
||||
let res: any = await new NativeSvr().clientLogin();
|
||||
console.log('native client res: ' + res);
|
||||
tokenRes = await clientAuth(res);
|
||||
} else {
|
||||
let res: any = await new NativeSvr().signWithGoogle();
|
||||
console.log("native google res: " + res);
|
||||
window.debug && console.log('native google res: ' + res);
|
||||
tokenRes = await googleAuth(res);
|
||||
}
|
||||
console.log("wallet token: " + tokenRes.data?.token);
|
||||
console.log(tokenRes);
|
||||
window.debug && console.log(tokenRes);
|
||||
window.debug && console.log('wallet token: ' + tokenRes.data?.token);
|
||||
if (tokenRes.errcode || !tokenRes.data?.token) {
|
||||
return;
|
||||
throw new ZError(tokenRes.errcode, tokenRes.errmsg);
|
||||
}
|
||||
walletEnv.token = tokenRes.data.token;
|
||||
await syncWalletEnv();
|
||||
return { token: walletEnv.token, address: walletEnv.address };
|
||||
}
|
||||
|
||||
new WalletEnv().token = tokenRes.data.token;
|
||||
let infoRes = await retry(() => getWalletInfo(), MAX_TRY_COUNT);
|
||||
if (infoRes.errcode) {
|
||||
return;
|
||||
export async function loginByEmail(email: string, password: string) {
|
||||
password = jsb.hashSvrPass(password);
|
||||
let tokenRes = await emailLogin({ email, password });
|
||||
if (tokenRes.errcode || !tokenRes.data?.token) {
|
||||
throw new ZError(tokenRes.errcode, tokenRes.errmsg);
|
||||
}
|
||||
// let infoRes = {
|
||||
// data: {
|
||||
// oid: "636cce78a95e553cb061c0f1",
|
||||
// account: "636b6acaa95e553cb0609ce2",
|
||||
// is: "2e0316fa555a",
|
||||
// salt: "6824413b37",
|
||||
// key: "aec87426c4655cf81a6059964ca919fc8fc995886078931681ba1b6431db281c",
|
||||
// },
|
||||
// };
|
||||
console.log("wallet info: " + JSON.stringify(infoRes.data));
|
||||
let seed = infoRes.data.oid + infoRes.data.is + infoRes.data.salt;
|
||||
let seedHash = md5Hash(seed);
|
||||
let address;
|
||||
let idHash = md5Hash(infoRes.data.oid);
|
||||
if (!infoRes.data.key) {
|
||||
let time = Date.now();
|
||||
let strWallet = jsb.generateWallet(idHash, seedHash);
|
||||
console.log("generate wallet cost: " + (Date.now() - time) / 1000);
|
||||
window.debug && console.log("native wallet info " + strWallet);
|
||||
let walletInfo = JSON.parse(strWallet);
|
||||
address = walletInfo.address;
|
||||
// setImmediate(function () {
|
||||
let walletEnv = new WalletEnv();
|
||||
walletEnv.token = tokenRes.data.token;
|
||||
await syncWalletEnv();
|
||||
return { token: walletEnv.token, address: walletEnv.address };
|
||||
}
|
||||
|
||||
// });
|
||||
retry(() => uploadWalletInfo({ key: walletInfo.master }), MAX_UPLOAD_COUNT);
|
||||
} else {
|
||||
let localSKey, localBKey;
|
||||
if (jsb.loadLocalStorage) {
|
||||
localSKey = jsb.loadLocalStorage("cebg_wallet_s_" + idHash);
|
||||
localBKey = jsb.loadLocalStorage("cebg_wallet_b_" + idHash);
|
||||
} else {
|
||||
localSKey = localStorage.getItem("cebg_wallet_s_" + idHash);
|
||||
localBKey = localStorage.getItem("cebg_wallet_b_" + idHash);
|
||||
}
|
||||
|
||||
if (localSKey || localBKey) {
|
||||
let strWallet = jsb.prepareWallet(idHash, seedHash, infoRes.data.key);
|
||||
let walletInfo = JSON.parse(strWallet);
|
||||
address = walletInfo.address;
|
||||
} else {
|
||||
let qrResult = await new NativeSvr().restoreKey(idHash);
|
||||
let strWallet = jsb.restoreWallet(
|
||||
idHash,
|
||||
seedHash,
|
||||
infoRes.data.key,
|
||||
qrResult
|
||||
);
|
||||
window.debug && console.log("restore native wallet info " + strWallet);
|
||||
let walletInfo = JSON.parse(strWallet);
|
||||
address = walletInfo.address;
|
||||
// setImmediate(function () {
|
||||
// retry(
|
||||
// () => uploadWalletInfo({ key: walletInfo.master }),
|
||||
// MAX_UPLOAD_COUNT
|
||||
// );
|
||||
// });
|
||||
}
|
||||
export async function loadInternalWallet(pass: string) {
|
||||
let walletEnv = new WalletEnv();
|
||||
let address = await prepareInternalWallet(pass);
|
||||
if (walletEnv.address && walletEnv.address !== address) {
|
||||
throw new ZError(10, 'address not match, perhaps wrong password');
|
||||
}
|
||||
if (!walletEnv.address) {
|
||||
retry(() => uploadWalletInfo({ address }), MAX_UPLOAD_COUNT);
|
||||
}
|
||||
walletEnv.address = address;
|
||||
return address;
|
||||
}
|
||||
|
||||
async function prepareInternalWallet(pass: string) {
|
||||
let walletEnv = new WalletEnv();
|
||||
if (!walletEnv.key) {
|
||||
await syncWalletEnv();
|
||||
}
|
||||
|
||||
let { id, openid } = walletEnv.tokenData;
|
||||
let address = jsb.prepareWallet(id, openid, walletEnv.key, walletEnv.salt, pass);
|
||||
return address;
|
||||
}
|
||||
/**
|
||||
* calc wallet address and check if address is same with walletEnv.address
|
||||
* @param pass
|
||||
* @returns
|
||||
*/
|
||||
export async function verifyPassword(pass: string) {
|
||||
let address = await prepareInternalWallet(pass);
|
||||
return new WalletEnv().address === address;
|
||||
}
|
||||
|
||||
export function exportSecKey(pass: string) {
|
||||
let walletEnv = new WalletEnv();
|
||||
if (!walletEnv.address || !walletEnv.key) {
|
||||
throw new ZError(10, 'wallet not found');
|
||||
}
|
||||
let { id, openid } = walletEnv.tokenData;
|
||||
let resultStr = jsb.walletSecKey(id, openid, walletEnv.key, walletEnv.salt, pass);
|
||||
let result = JSON.parse(resultStr);
|
||||
if (result.address !== walletEnv.address) {
|
||||
throw new ZError(11, 'address not match, perhaps wrong password');
|
||||
}
|
||||
return result.key;
|
||||
}
|
||||
|
||||
export function walletSign(str: string) {
|
||||
let result = jsb.walletSign(str);
|
||||
return result;
|
||||
}
|
||||
|
||||
export async function parseWebLogin(dataStr: string) {
|
||||
console.log('found web login scheme, begin login');
|
||||
// if (dataStr.indexOf("|") < 0) {
|
||||
// return;
|
||||
// }
|
||||
// let datas = dataStr.split("|");
|
||||
// let webtoken = datas[0];
|
||||
// let pk64 = datas[1];
|
||||
// let pk = jsb.hexInflate(pk64);
|
||||
// let keyEncrypt = jsb.encryptedLocalKey(pk);
|
||||
// console.log("webtoken: " + webtoken);
|
||||
// console.log("local key: " + keyEncrypt);
|
||||
// let result = await uploadInfoForWebLogin({ key: keyEncrypt, webtoken });
|
||||
// console.log("login result: " + result);
|
||||
}
|
||||
|
23
src/queue/record.queue.ts
Normal file
23
src/queue/record.queue.ts
Normal file
@ -0,0 +1,23 @@
|
||||
import { saveRecord } from "../api/RecordApi";
|
||||
import { AsyncQueue, createAsyncQueue } from "../common/AsyncQueue";
|
||||
import { singleton } from "../decorator/singleton.decorator";
|
||||
|
||||
@singleton
|
||||
export class LoggerQueue {
|
||||
private queue: AsyncQueue;
|
||||
|
||||
constructor() {
|
||||
this.queue = createAsyncQueue();
|
||||
}
|
||||
|
||||
public addLog(data: any) {
|
||||
this.queue.push(async () => {
|
||||
try {
|
||||
await saveRecord(data);
|
||||
} catch (err) {
|
||||
console.log("error save tx record: ");
|
||||
console.log(err);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
78
src/services/EmailVerifySvr.ts
Normal file
78
src/services/EmailVerifySvr.ts
Normal file
@ -0,0 +1,78 @@
|
||||
import {
|
||||
checkEmailRegister,
|
||||
emailRegister,
|
||||
isEmailVerified,
|
||||
sendCode,
|
||||
verifyEmailByCode,
|
||||
} from "../api/EmailApi";
|
||||
import { ZError } from "../common/ZError";
|
||||
|
||||
import { singleton } from "../decorator/singleton.decorator";
|
||||
|
||||
@singleton
|
||||
export class EmailVerifySvr {
|
||||
/**
|
||||
* Checks if the user's email is verified
|
||||
* @returns an object containing the verification status and the user's email
|
||||
*/
|
||||
public async checkEmailVerified(): Promise<{
|
||||
verified: number;
|
||||
email: string | null;
|
||||
}> {
|
||||
let res = await isEmailVerified();
|
||||
if (res.errcode) {
|
||||
throw new ZError(res.errcode, res.errmsg); //Throw error if call to the checking function fails
|
||||
}
|
||||
|
||||
const { data } = res;
|
||||
if (!data) {
|
||||
throw new Error("Invalid response from the server"); //Throw error if the expected data structure is missing
|
||||
}
|
||||
|
||||
const { verified, email } = data;
|
||||
if (!email || typeof verified !== "number") {
|
||||
throw new Error("Invalid values returned from server"); //Throw error if the data doesn't have the expected types or values
|
||||
}
|
||||
|
||||
return { verified, email };
|
||||
}
|
||||
|
||||
/**
|
||||
* Begins the process of verifying the user's email
|
||||
* @param email - the email to be verified
|
||||
*/
|
||||
|
||||
public async sendEmailCode(email: string, type: number) {
|
||||
let result = await sendCode({ email, type });
|
||||
console.log(JSON.stringify(result));
|
||||
if (result.errcode) {
|
||||
throw new ZError(result.errcode, result.errmsg);
|
||||
}
|
||||
return result.data;
|
||||
}
|
||||
|
||||
public async updateEmailVerify(email: string, code: string) {
|
||||
let result = await verifyEmailByCode({ email, code });
|
||||
if (result.errcode) {
|
||||
throw new ZError(result.errcode, result.errmsg);
|
||||
}
|
||||
return result.data;
|
||||
}
|
||||
|
||||
public async isEmailRegister(email: string) {
|
||||
let result = await checkEmailRegister({ email });
|
||||
if (result.errcode) {
|
||||
throw new ZError(result.errcode, result.errmsg);
|
||||
}
|
||||
return result.data;
|
||||
}
|
||||
|
||||
public async registByEmail(email: string, password: string, code: string) {
|
||||
password = jsb.hashSvrPass(password);
|
||||
let result = await emailRegister({ email, password, code });
|
||||
if (result.errcode) {
|
||||
throw new ZError(result.errcode, result.errmsg);
|
||||
}
|
||||
return result.data;
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
import { payloadId } from "@walletconnect/utils";
|
||||
import { createWalletEvents } from "../common/WalletEvent";
|
||||
import { singleton } from "../decorator/singleton.decorator";
|
||||
import { payloadId } from '@walletconnect/utils';
|
||||
import { createWalletEvents } from '../common/WalletEvent';
|
||||
import { singleton } from '../decorator/singleton.decorator';
|
||||
|
||||
@singleton
|
||||
export class NativeSvr {
|
||||
@ -46,6 +46,24 @@ export class NativeSvr {
|
||||
return this._subscribeToCallResponse(id);
|
||||
}
|
||||
|
||||
public signWithFacebook() {
|
||||
let id = payloadId();
|
||||
jsb.signWithFacebook(id);
|
||||
return this._subscribeToCallResponse(id);
|
||||
}
|
||||
|
||||
public signWithTwitter() {
|
||||
let id = payloadId();
|
||||
jsb.signWithTwitter(id);
|
||||
return this._subscribeToCallResponse(id);
|
||||
}
|
||||
|
||||
public signWithEmail() {
|
||||
let id = payloadId();
|
||||
jsb.signWithEmail(id);
|
||||
return this._subscribeToCallResponse(id);
|
||||
}
|
||||
|
||||
public signOutGoogle() {
|
||||
let id = payloadId();
|
||||
jsb.signOutGoogle(id);
|
||||
@ -58,9 +76,51 @@ export class NativeSvr {
|
||||
return this._subscribeToCallResponse(id);
|
||||
}
|
||||
|
||||
public restoreKey(oid: string) {
|
||||
public buyProduct(productId: string, orderId: string) {
|
||||
let id = payloadId();
|
||||
jsb.restoreKey(id, oid);
|
||||
jsb.beginBuy(id, productId, orderId);
|
||||
return this._subscribeToCallResponse(id);
|
||||
}
|
||||
|
||||
public queryPurchase() {
|
||||
let id = payloadId();
|
||||
jsb.queryPurchase(id);
|
||||
return this._subscribeToCallResponse(id);
|
||||
}
|
||||
|
||||
public queryProducts(productIds: string) {
|
||||
let id = payloadId();
|
||||
jsb.queryProducts(id, productIds);
|
||||
return this._subscribeToCallResponse(id);
|
||||
}
|
||||
|
||||
public finishTransaction(transactionId: string) {
|
||||
let id = payloadId();
|
||||
jsb.finishTransaction(id, transactionId);
|
||||
return this._subscribeToCallResponse(id);
|
||||
}
|
||||
|
||||
public authGetStoragePass(key: string) {
|
||||
let id = payloadId();
|
||||
jsb.authGetStoragePass(id, key);
|
||||
return this._subscribeToCallResponse(id);
|
||||
}
|
||||
|
||||
public passStorageState(key: string) {
|
||||
let id = payloadId();
|
||||
jsb.passStorageState(id, key);
|
||||
return this._subscribeToCallResponse(id);
|
||||
}
|
||||
|
||||
public storagePass(key: string, pass: string) {
|
||||
let id = payloadId();
|
||||
jsb.storagePass(id, key, pass);
|
||||
return this._subscribeToCallResponse(id);
|
||||
}
|
||||
|
||||
public clientLogin() {
|
||||
let id = payloadId();
|
||||
jsb.getClientId(id);
|
||||
return this._subscribeToCallResponse(id);
|
||||
}
|
||||
}
|
||||
|
168
src/services/PaySvr.ts
Normal file
168
src/services/PaySvr.ts
Normal file
@ -0,0 +1,168 @@
|
||||
import { queryFiatList, queryTokenUsdPrice, reqAlchemyPrePay, verifyApplePay, verifyGooglePay } from '../api/PayApi';
|
||||
import { ZError } from '../common/ZError';
|
||||
import { VERSION_CODE } from '../config/constants';
|
||||
import { singleton } from '../decorator/singleton.decorator';
|
||||
import { IPayData } from '../types/data.types';
|
||||
import { NativeSvr } from './NativeSvr';
|
||||
|
||||
@singleton
|
||||
export class PaySvr {
|
||||
private priceMap: Map<string, string> = new Map();
|
||||
/**
|
||||
* Calls the alchemyPrePay function with the given data.
|
||||
* @param data - The data to be passed to the alchemyPrePay function.
|
||||
* @returns The result of the alchemyPrePay function.
|
||||
*/
|
||||
public async alchemyPrePay(data: any) {
|
||||
// data.network = data.network || jc.wallet.currentChain.network;
|
||||
// data.crypto = data.crypto.toUpperCase();
|
||||
// data.country = data.country.toUpperCase();
|
||||
// data.fiat = data.fiat.toUpperCase();
|
||||
data.evn = jc.wallet.env;
|
||||
data.version = VERSION_CODE;
|
||||
let res = await reqAlchemyPrePay(data);
|
||||
if (res.errcode) {
|
||||
throw new Error(res.errmsg);
|
||||
}
|
||||
if (!res.data) {
|
||||
throw new Error('No data returned');
|
||||
}
|
||||
const url = res.data.url;
|
||||
if (!url) {
|
||||
throw new Error('No url returned');
|
||||
}
|
||||
console.log('pay url::', url);
|
||||
return res.data;
|
||||
}
|
||||
|
||||
public async getGasPrice(chainId: number) {
|
||||
const key = `gasprice_${chainId}`;
|
||||
if (!this.priceMap.has(key)) {
|
||||
let price = await new jc.wallet.web3.eth.getGasPrice();
|
||||
this.priceMap.set(key, price + '');
|
||||
} else {
|
||||
setImmediate(async () => {
|
||||
let price = await new jc.wallet.web3.eth.getGasPrice();
|
||||
this.priceMap.set(key, price + '');
|
||||
});
|
||||
}
|
||||
console.log('gas price', this.priceMap.get(key));
|
||||
return this.priceMap.get(key);
|
||||
}
|
||||
|
||||
private async updateTokenPrice(chain: string, tokenName: string, env: string) {
|
||||
const key = `crypto_usd_${chain}_${tokenName}_${env}`;
|
||||
let priceData = await queryTokenUsdPrice(tokenName, chain, env);
|
||||
console.log('ETH price data', JSON.stringify(priceData));
|
||||
let price = priceData.data.price;
|
||||
this.priceMap.set(key, price + '');
|
||||
}
|
||||
|
||||
public async queryTokenPrice(chain: string, tokenName: string, env: string = 'release') {
|
||||
chain = chain.toUpperCase();
|
||||
tokenName = tokenName.toUpperCase();
|
||||
const key = `crypto_usd_${chain}_${tokenName}_${env}`;
|
||||
if (!this.priceMap.has(key)) {
|
||||
try {
|
||||
await this.updateTokenPrice(chain, tokenName, env);
|
||||
} catch (err) {
|
||||
console.log('ETH price err', err);
|
||||
}
|
||||
} else {
|
||||
setImmediate(async () => {
|
||||
try {
|
||||
await this.updateTokenPrice(chain, tokenName, env);
|
||||
} catch (err) {
|
||||
console.log('ETH price err', err);
|
||||
}
|
||||
});
|
||||
}
|
||||
console.log('ETH price', this.priceMap.get(key));
|
||||
return this.priceMap.get(key);
|
||||
}
|
||||
|
||||
public async fetchFiatList() {
|
||||
return queryFiatList();
|
||||
}
|
||||
|
||||
// begin of google pay
|
||||
public async queryGoogleProducts(productIds: string[]) {
|
||||
let str = await new NativeSvr().queryProducts(productIds.join(','));
|
||||
return str;
|
||||
}
|
||||
|
||||
public async queryGooglePurchases() {
|
||||
let result = await new NativeSvr().queryPurchase();
|
||||
let data = JSON.parse(result + '');
|
||||
console.log('query purchase result:: ' + data);
|
||||
if (data.length === 0) {
|
||||
throw new ZError(10, 'no records');
|
||||
}
|
||||
let res = await verifyGooglePay({ list: data });
|
||||
if (res.errcode) {
|
||||
throw new ZError(res.errcode, res.errmsg);
|
||||
}
|
||||
return res.data;
|
||||
}
|
||||
|
||||
public async buyGoogleProduct(productId: string, orderId: string) {
|
||||
let result = await new NativeSvr().buyProduct(productId, orderId);
|
||||
let data = JSON.parse(result + '');
|
||||
console.log('native buy result:: ' + data);
|
||||
if (data.length === 0) {
|
||||
throw new ZError(10, 'no records');
|
||||
}
|
||||
let res = await verifyGooglePay({ list: data });
|
||||
if (res.errcode) {
|
||||
throw new ZError(res.errcode, res.errmsg);
|
||||
}
|
||||
return res.data;
|
||||
}
|
||||
|
||||
// end of google pay
|
||||
|
||||
// begin of iOS purchase
|
||||
public async queryIOSProducts(productIds: string[]) {
|
||||
let str = await new NativeSvr().queryProducts(productIds.join(','));
|
||||
return str;
|
||||
}
|
||||
|
||||
public async queryIOSPurchases() {
|
||||
let result = await new NativeSvr().queryPurchase();
|
||||
let data = JSON.parse(result + '');
|
||||
console.log('query apple purchase result:: ' + result);
|
||||
if (data.length === 0) {
|
||||
throw new ZError(10, 'no records');
|
||||
}
|
||||
let res = await verifyApplePay({ list: data });
|
||||
if (res.errcode) {
|
||||
throw new ZError(res.errcode, res.errmsg);
|
||||
}
|
||||
if (res.data.length > 0) {
|
||||
for (let i = 0; i < res.data.length; i++) {
|
||||
await new NativeSvr().finishTransaction(res.data[i]);
|
||||
}
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
public async beginIOSPurchase(productId: string, orderId: string) {
|
||||
let result = await new NativeSvr().buyProduct(productId, orderId);
|
||||
let data = JSON.parse(result + '');
|
||||
console.log('apple purchase result:: ' + result);
|
||||
if (data.length === 0) {
|
||||
throw new ZError(10, 'no records');
|
||||
}
|
||||
let res = await verifyApplePay({ list: data });
|
||||
if (res.errcode) {
|
||||
throw new ZError(res.errcode, res.errmsg);
|
||||
}
|
||||
if (res.data.length > 0) {
|
||||
for (let i = 0; i < res.data.length; i++) {
|
||||
await new NativeSvr().finishTransaction(res.data[i]);
|
||||
}
|
||||
}
|
||||
return data;
|
||||
}
|
||||
// end of iOS purchase
|
||||
}
|
47
src/services/TranHistorySvr.ts
Normal file
47
src/services/TranHistorySvr.ts
Normal file
@ -0,0 +1,47 @@
|
||||
import { records } from '../api/RecordApi';
|
||||
import { singleton } from '../decorator/singleton.decorator';
|
||||
|
||||
@singleton
|
||||
export class TranHistorySvr {
|
||||
/**
|
||||
* eth history
|
||||
*/
|
||||
public async ethRecords(start: number, limit: number, moreParam: any) {
|
||||
start = start | 0;
|
||||
limit = limit | 0;
|
||||
let data = { start, limit, chain: jc.wallet.currentChain.id };
|
||||
Object.assign(data, moreParam);
|
||||
return records(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* token history
|
||||
*/
|
||||
public async tokenRecords({
|
||||
address,
|
||||
tokenId,
|
||||
start,
|
||||
limit,
|
||||
moreParam,
|
||||
}: {
|
||||
address: string;
|
||||
tokenId?: string;
|
||||
start: number;
|
||||
limit: number;
|
||||
moreParam: any;
|
||||
}) {
|
||||
start = start | 0;
|
||||
limit = limit | 0;
|
||||
let data: any = {
|
||||
start,
|
||||
limit,
|
||||
chain: jc.wallet.currentChain.id,
|
||||
'details.address': address,
|
||||
};
|
||||
if (tokenId) {
|
||||
data['details.id'] = tokenId + '';
|
||||
}
|
||||
Object.assign(data, moreParam);
|
||||
return records(data);
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
import Web3 from "web3";
|
||||
import { BN } from "ethereumjs-util";
|
||||
import Web3 from 'web3';
|
||||
import { BN } from 'ethereumjs-util';
|
||||
|
||||
export const SAMPLE_GAS = 1000000;
|
||||
|
||||
@ -13,9 +13,9 @@ export class ChainCommon {
|
||||
public async checkEthEnough(gas: string, address?: string) {
|
||||
address = address || jc.wallet.currentAccAddr;
|
||||
let gasPrice = await this.web3.eth.getGasPrice();
|
||||
console.log("gasPrice: " + new BN(gasPrice));
|
||||
console.log('gasPrice: ' + new BN(gasPrice));
|
||||
let balance = await this.web3.eth.getBalance(address);
|
||||
console.log("eth balance: " + new BN(balance));
|
||||
console.log('eth balance: ' + new BN(balance));
|
||||
return new BN(balance).gte(new BN(gasPrice).mul(new BN(gas)));
|
||||
}
|
||||
|
||||
|
@ -1,12 +1,14 @@
|
||||
import Web3 from "web3";
|
||||
import { abiERC1155 } from "../abis/abiERC1155";
|
||||
import { timeoutFetch } from "../util/net.util";
|
||||
import { getFormattedIpfsUrl } from "../util/wallet.util";
|
||||
import Web3 from 'web3';
|
||||
import { abiERC1155 } from '../abis/abiERC1155';
|
||||
import { universalChainCb } from '../util/chain.util';
|
||||
import { timeoutFetch } from '../util/net.util';
|
||||
import { getFormattedIpfsUrl } from '../util/wallet.util';
|
||||
import { GAS_BOOST } from '../config/constants';
|
||||
|
||||
export const ERC1155 = "ERC1155";
|
||||
export const ERC1155_INTERFACE_ID = "0xd9b67a26";
|
||||
export const ERC1155_METADATA_URI_INTERFACE_ID = "0x0e89341c";
|
||||
export const ERC1155_TOKEN_RECEIVER_INTERFACE_ID = "0x4e2312e0";
|
||||
export const ERC1155 = 'ERC1155';
|
||||
export const ERC1155_INTERFACE_ID = '0xd9b67a26';
|
||||
export const ERC1155_METADATA_URI_INTERFACE_ID = '0x0e89341c';
|
||||
export const ERC1155_TOKEN_RECEIVER_INTERFACE_ID = '0x4e2312e0';
|
||||
|
||||
export class ERC1155Standard {
|
||||
private web3: Web3;
|
||||
@ -21,13 +23,8 @@ export class ERC1155Standard {
|
||||
* @param address - ERC1155 asset contract address.
|
||||
* @returns Promise resolving to whether the contract implements ERC1155 URI Metadata interface.
|
||||
*/
|
||||
contractSupportsURIMetadataInterface = async (
|
||||
address: string
|
||||
): Promise<boolean> => {
|
||||
return this.contractSupportsInterface(
|
||||
address,
|
||||
ERC1155_METADATA_URI_INTERFACE_ID
|
||||
);
|
||||
contractSupportsURIMetadataInterface = async (address: string): Promise<boolean> => {
|
||||
return this.contractSupportsInterface(address, ERC1155_METADATA_URI_INTERFACE_ID);
|
||||
};
|
||||
|
||||
/**
|
||||
@ -36,13 +33,8 @@ export class ERC1155Standard {
|
||||
* @param address - ERC1155 asset contract address.
|
||||
* @returns Promise resolving to whether the contract implements ERC1155 Token Receiver interface.
|
||||
*/
|
||||
contractSupportsTokenReceiverInterface = async (
|
||||
address: string
|
||||
): Promise<boolean> => {
|
||||
return this.contractSupportsInterface(
|
||||
address,
|
||||
ERC1155_TOKEN_RECEIVER_INTERFACE_ID
|
||||
);
|
||||
contractSupportsTokenReceiverInterface = async (address: string): Promise<boolean> => {
|
||||
return this.contractSupportsInterface(address, ERC1155_TOKEN_RECEIVER_INTERFACE_ID);
|
||||
};
|
||||
|
||||
/**
|
||||
@ -51,9 +43,7 @@ export class ERC1155Standard {
|
||||
* @param address - ERC1155 asset contract address.
|
||||
* @returns Promise resolving to whether the contract implements the base ERC1155 interface.
|
||||
*/
|
||||
contractSupportsBase1155Interface = async (
|
||||
address: string
|
||||
): Promise<boolean> => {
|
||||
contractSupportsBase1155Interface = async (address: string): Promise<boolean> => {
|
||||
return this.contractSupportsInterface(address, ERC1155_INTERFACE_ID);
|
||||
};
|
||||
|
||||
@ -67,16 +57,14 @@ export class ERC1155Standard {
|
||||
getTokenURI = async (address: string, tokenId: string): Promise<string> => {
|
||||
const contract = new this.web3.eth.Contract(abiERC1155, address);
|
||||
return new Promise<string>((resolve, reject) => {
|
||||
contract.methods
|
||||
.tokenURI(tokenId)
|
||||
.call((error: Error, result: string) => {
|
||||
/* istanbul ignore if */
|
||||
if (error) {
|
||||
reject(error);
|
||||
return;
|
||||
}
|
||||
resolve(result);
|
||||
});
|
||||
contract.methods.tokenURI(tokenId).call((error: Error, result: string) => {
|
||||
/* istanbul ignore if */
|
||||
if (error) {
|
||||
reject(error);
|
||||
return;
|
||||
}
|
||||
resolve(result);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
@ -88,64 +76,17 @@ export class ERC1155Standard {
|
||||
* @param tokenId - ERC1155 asset identifier.
|
||||
* @returns Promise resolving to the 'balanceOf'.
|
||||
*/
|
||||
getBalanceOf = async (
|
||||
contractAddress: string,
|
||||
address: string,
|
||||
tokenId: string
|
||||
): Promise<number> => {
|
||||
getBalanceOf = async (contractAddress: string, address: string, tokenId: string): Promise<number> => {
|
||||
const contract = new this.web3.eth.Contract(abiERC1155, contractAddress);
|
||||
return new Promise<number>((resolve, reject) => {
|
||||
contract.methods.balanceOf(
|
||||
address,
|
||||
tokenId,
|
||||
(error: Error, result: number) => {
|
||||
/* istanbul ignore if */
|
||||
if (error) {
|
||||
reject(error);
|
||||
return;
|
||||
}
|
||||
resolve(result);
|
||||
contract.methods.balanceOf(address, tokenId, (error: Error, result: number) => {
|
||||
/* istanbul ignore if */
|
||||
if (error) {
|
||||
reject(error);
|
||||
return;
|
||||
}
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Transfer single ERC1155 token.
|
||||
* When minting/creating tokens, the from arg MUST be set to 0x0 (i.e. zero address).
|
||||
* When burning/destroying tokens, the to arg MUST be set to 0x0 (i.e. zero address).
|
||||
*
|
||||
* @param operator - ERC1155 token address.
|
||||
* @param from - ERC1155 token holder.
|
||||
* @param to - ERC1155 token recipient.
|
||||
* @param id - ERC1155 token id.
|
||||
* @param value - Number of tokens to be sent.
|
||||
* @returns Promise resolving to the 'transferSingle'.
|
||||
*/
|
||||
transferSingle = async (
|
||||
operator: string,
|
||||
from: string,
|
||||
to: string,
|
||||
id: string,
|
||||
value: string
|
||||
): Promise<void> => {
|
||||
const contract = new this.web3.eth.Contract(abiERC1155, operator);
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
contract.methods.transferSingle(
|
||||
operator,
|
||||
from,
|
||||
to,
|
||||
id,
|
||||
value,
|
||||
(error: Error, result: void) => {
|
||||
/* istanbul ignore if */
|
||||
if (error) {
|
||||
reject(error);
|
||||
return;
|
||||
}
|
||||
resolve(result);
|
||||
}
|
||||
);
|
||||
resolve(result);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
@ -156,23 +97,17 @@ export class ERC1155Standard {
|
||||
* @param interfaceId - Interface identifier.
|
||||
* @returns Promise resolving to whether the contract implements `interfaceID`.
|
||||
*/
|
||||
private contractSupportsInterface = async (
|
||||
address: string,
|
||||
interfaceId: string
|
||||
): Promise<boolean> => {
|
||||
private contractSupportsInterface = async (address: string, interfaceId: string): Promise<boolean> => {
|
||||
const contract = new this.web3.eth.Contract(abiERC1155, address);
|
||||
return new Promise<boolean>((resolve, reject) => {
|
||||
contract.methods.supportsInterface(
|
||||
interfaceId,
|
||||
(error: Error, result: boolean) => {
|
||||
/* istanbul ignore if */
|
||||
if (error) {
|
||||
reject(error);
|
||||
return;
|
||||
}
|
||||
resolve(result);
|
||||
contract.methods.supportsInterface(interfaceId, (error: Error, result: boolean) => {
|
||||
/* istanbul ignore if */
|
||||
if (error) {
|
||||
reject(error);
|
||||
return;
|
||||
}
|
||||
);
|
||||
resolve(result);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
@ -202,7 +137,7 @@ export class ERC1155Standard {
|
||||
|
||||
if (tokenId) {
|
||||
tokenURI = await this.getTokenURI(address, tokenId);
|
||||
if (tokenURI.startsWith("ipfs://")) {
|
||||
if (tokenURI.startsWith('ipfs://')) {
|
||||
tokenURI = getFormattedIpfsUrl(ipfsGateway, tokenURI, true);
|
||||
}
|
||||
|
||||
@ -210,7 +145,7 @@ export class ERC1155Standard {
|
||||
const response = await timeoutFetch(tokenURI);
|
||||
const object = await response.json();
|
||||
image = object?.image;
|
||||
if (image?.startsWith("ipfs://")) {
|
||||
if (image?.startsWith('ipfs://')) {
|
||||
image = getFormattedIpfsUrl(ipfsGateway, image, true);
|
||||
}
|
||||
} catch {
|
||||
@ -245,19 +180,35 @@ export class ERC1155Standard {
|
||||
}) {
|
||||
const contract = new this.web3.eth.Contract(abiERC1155, address);
|
||||
if (!gas) {
|
||||
gas = await contract.methods
|
||||
.safeBatchTransferFrom(from, to, tokenIds, amounts, "")
|
||||
.estimateGas({ gas: 1000000 });
|
||||
gas = await contract.methods.safeBatchTransferFrom(from, to, tokenIds, amounts, []).estimateGas();
|
||||
}
|
||||
gas = (gas * 1.1) | 1;
|
||||
gas = (gas * GAS_BOOST) | 1;
|
||||
if (estimate) {
|
||||
return jc.wallet.generateGasShow(gas);
|
||||
}
|
||||
return contract.methods
|
||||
.safeBatchTransferFrom(from, to, tokenIds, amounts, "")
|
||||
.send({
|
||||
const detailArr = [];
|
||||
for (let i = 0, l = tokenIds.length; i < l; i++) {
|
||||
detailArr.push({
|
||||
address,
|
||||
from,
|
||||
to,
|
||||
id: tokenIds[i],
|
||||
amount: amounts[i],
|
||||
});
|
||||
}
|
||||
const logData = {
|
||||
gas,
|
||||
title: 'transfer',
|
||||
details: detailArr,
|
||||
};
|
||||
let gasPrice = await jc.wallet.fetchGasPrice();
|
||||
return universalChainCb(
|
||||
logData,
|
||||
contract.methods.safeBatchTransferFrom(from, to, tokenIds, amounts, []).send({
|
||||
from,
|
||||
gas,
|
||||
});
|
||||
gasPrice,
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,9 @@
|
||||
import Web3 from "web3";
|
||||
import { abiERC20 } from "../abis/abiERC20";
|
||||
import { BN, toUtf8 } from "ethereumjs-util";
|
||||
import Web3 from 'web3';
|
||||
import { abiERC20 } from '../abis/abiERC20';
|
||||
import { BN, toUtf8 } from 'ethereumjs-util';
|
||||
import { universalChainCb } from '../util/chain.util';
|
||||
import { toWeiBn } from '../util/number.util';
|
||||
import { GAS_BOOST } from '../config/constants';
|
||||
|
||||
export class ERC20Standard {
|
||||
private web3: Web3;
|
||||
@ -19,17 +22,15 @@ export class ERC20Standard {
|
||||
async getBalanceOf(address: string, selectedAddress: string): Promise<BN> {
|
||||
const contract = new this.web3.eth.Contract(abiERC20, address);
|
||||
return new Promise<BN>((resolve, reject) => {
|
||||
contract.methods
|
||||
.balanceOf(selectedAddress)
|
||||
.call({ from: selectedAddress }, (error: Error, result: BN) => {
|
||||
/* istanbul ignore if */
|
||||
if (error) {
|
||||
reject(error);
|
||||
return;
|
||||
}
|
||||
console.log("getBalanceOf success " + result);
|
||||
resolve(result);
|
||||
});
|
||||
contract.methods.balanceOf(selectedAddress).call({ from: selectedAddress }, (error: Error, result: BN) => {
|
||||
/* istanbul ignore if */
|
||||
if (error) {
|
||||
reject(error);
|
||||
return;
|
||||
}
|
||||
console.log('getBalanceOf success ' + result);
|
||||
resolve(result);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@ -124,10 +125,7 @@ export class ERC20Standard {
|
||||
decimals: string | undefined;
|
||||
balance: BN | undefined;
|
||||
}> {
|
||||
const [decimals, symbol] = await Promise.all([
|
||||
this.getTokenDecimals(address),
|
||||
this.getTokenSymbol(address),
|
||||
]);
|
||||
const [decimals, symbol] = await Promise.all([this.getTokenDecimals(address), this.getTokenSymbol(address)]);
|
||||
let balance;
|
||||
if (userAddress) {
|
||||
balance = await this.getBalanceOf(address, userAddress);
|
||||
@ -136,7 +134,7 @@ export class ERC20Standard {
|
||||
decimals,
|
||||
symbol,
|
||||
balance,
|
||||
standard: "ERC20",
|
||||
standard: 'ERC20',
|
||||
};
|
||||
}
|
||||
|
||||
@ -145,6 +143,7 @@ export class ERC20Standard {
|
||||
from,
|
||||
to,
|
||||
amount,
|
||||
decimal,
|
||||
gas,
|
||||
estimate,
|
||||
}: {
|
||||
@ -152,23 +151,47 @@ export class ERC20Standard {
|
||||
from: string;
|
||||
to: string;
|
||||
amount: number | string;
|
||||
decimal?: string;
|
||||
gas?: number;
|
||||
estimate: number;
|
||||
}) {
|
||||
const contract = new this.web3.eth.Contract(abiERC20, address);
|
||||
const amountBN = Web3.utils.toBN(Web3.utils.toWei(amount + ""));
|
||||
if (!gas) {
|
||||
gas = await contract.methods
|
||||
.transfer(to, amountBN)
|
||||
.estimateGas({ gas: 1000000 });
|
||||
if (!decimal) {
|
||||
decimal = await this.getTokenDecimals(address);
|
||||
}
|
||||
gas = (gas * 1.1) | 1;
|
||||
let amountBN = toWeiBn(amount, +decimal);
|
||||
if (!gas) {
|
||||
gas = await contract.methods.transfer(to, '0').estimateGas();
|
||||
let toBalance = await this.getBalanceOf(address, to);
|
||||
if (toBalance == '0') {
|
||||
gas += 12000; // SSTORE new value is more expensive
|
||||
}
|
||||
}
|
||||
gas = (gas * GAS_BOOST) | 1;
|
||||
if (estimate) {
|
||||
return jc.wallet.generateGasShow(gas);
|
||||
}
|
||||
return contract.methods.transfer(to, amountBN).send({
|
||||
from,
|
||||
const logData = {
|
||||
gas,
|
||||
});
|
||||
title: 'transfer',
|
||||
details: [
|
||||
{
|
||||
address,
|
||||
from,
|
||||
to,
|
||||
value: amountBN,
|
||||
id: '0',
|
||||
},
|
||||
],
|
||||
};
|
||||
let gasPrice = await jc.wallet.fetchGasPrice();
|
||||
return universalChainCb(
|
||||
logData,
|
||||
contract.methods.transfer(to, amountBN).send({
|
||||
from,
|
||||
gas,
|
||||
gasPrice,
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,14 @@
|
||||
import Web3 from "web3";
|
||||
import { abiERC721 } from "../abis/abiERC721";
|
||||
import { timeoutFetch } from "../util/net.util";
|
||||
import { getFormattedIpfsUrl } from "../util/wallet.util";
|
||||
import Web3 from 'web3';
|
||||
import { abiERC721 } from '../abis/abiERC721';
|
||||
import { universalChainCb } from '../util/chain.util';
|
||||
import { timeoutFetch } from '../util/net.util';
|
||||
import { getFormattedIpfsUrl } from '../util/wallet.util';
|
||||
import { GAS_BOOST } from '../config/constants';
|
||||
|
||||
export const ERC721 = "ERC721";
|
||||
export const ERC721_INTERFACE_ID = "0x80ac58cd";
|
||||
export const ERC721_METADATA_INTERFACE_ID = "0x5b5e139f";
|
||||
export const ERC721_ENUMERABLE_INTERFACE_ID = "0x780e9d63";
|
||||
export const ERC721 = 'ERC721';
|
||||
export const ERC721_INTERFACE_ID = '0x80ac58cd';
|
||||
export const ERC721_METADATA_INTERFACE_ID = '0x5b5e139f';
|
||||
export const ERC721_ENUMERABLE_INTERFACE_ID = '0x780e9d63';
|
||||
|
||||
export class ERC721Standard {
|
||||
private web3: Web3;
|
||||
@ -21,13 +23,8 @@ export class ERC721Standard {
|
||||
* @param address - ERC721 asset contract address.
|
||||
* @returns Promise resolving to whether the contract implements ERC721Metadata interface.
|
||||
*/
|
||||
contractSupportsMetadataInterface = async (
|
||||
address: string
|
||||
): Promise<boolean> => {
|
||||
return this.contractSupportsInterface(
|
||||
address,
|
||||
ERC721_METADATA_INTERFACE_ID
|
||||
);
|
||||
contractSupportsMetadataInterface = async (address: string): Promise<boolean> => {
|
||||
return this.contractSupportsInterface(address, ERC721_METADATA_INTERFACE_ID);
|
||||
};
|
||||
|
||||
/**
|
||||
@ -36,13 +33,8 @@ export class ERC721Standard {
|
||||
* @param address - ERC721 asset contract address.
|
||||
* @returns Promise resolving to whether the contract implements ERC721Enumerable interface.
|
||||
*/
|
||||
contractSupportsEnumerableInterface = async (
|
||||
address: string
|
||||
): Promise<boolean> => {
|
||||
return this.contractSupportsInterface(
|
||||
address,
|
||||
ERC721_ENUMERABLE_INTERFACE_ID
|
||||
);
|
||||
contractSupportsEnumerableInterface = async (address: string): Promise<boolean> => {
|
||||
return this.contractSupportsInterface(address, ERC721_ENUMERABLE_INTERFACE_ID);
|
||||
};
|
||||
|
||||
/**
|
||||
@ -51,9 +43,7 @@ export class ERC721Standard {
|
||||
* @param address - ERC721 asset contract address.
|
||||
* @returns Promise resolving to whether the contract implements ERC721 interface.
|
||||
*/
|
||||
contractSupportsBase721Interface = async (
|
||||
address: string
|
||||
): Promise<boolean> => {
|
||||
contractSupportsBase721Interface = async (address: string): Promise<boolean> => {
|
||||
return this.contractSupportsInterface(address, ERC721_INTERFACE_ID);
|
||||
};
|
||||
|
||||
@ -65,42 +55,35 @@ export class ERC721Standard {
|
||||
* @param index - A collectible counter less than `balanceOf(selectedAddress)`.
|
||||
* @returns Promise resolving to token identifier for the 'index'th asset assigned to 'selectedAddress'.
|
||||
*/
|
||||
getCollectibleTokenId = async (
|
||||
address: string,
|
||||
selectedAddress: string,
|
||||
index: number
|
||||
): Promise<string> => {
|
||||
getCollectibleTokenId = async (address: string, selectedAddress: string, index: number): Promise<string> => {
|
||||
const contract = new this.web3.eth.Contract(abiERC721, address);
|
||||
return new Promise<string>((resolve, reject) => {
|
||||
contract.methods
|
||||
.tokenOfOwnerByIndex(selectedAddress, index)
|
||||
.call((error: Error, result: string) => {
|
||||
/* istanbul ignore if */
|
||||
if (error) {
|
||||
reject(error);
|
||||
return;
|
||||
}
|
||||
resolve(result);
|
||||
});
|
||||
contract.methods.tokenOfOwnerByIndex(selectedAddress, index).call((error: Error, result: string) => {
|
||||
/* istanbul ignore if */
|
||||
if (error) {
|
||||
reject(error);
|
||||
return;
|
||||
}
|
||||
resolve(result);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
getBalance = async (
|
||||
address: string,
|
||||
selectedAddress: string
|
||||
): Promise<number> => {
|
||||
const contract = new this.web3.eth.Contract(abiERC721, address);
|
||||
getBalance = async (address: string, selectedAddress: string, chainId?: string): Promise<number> => {
|
||||
let web3 = this.web3;
|
||||
if (chainId && parseInt(chainId) !== jc.wallet.currentChain.id) {
|
||||
web3 = jc.wallet.generateWeb3(parseInt(chainId), false);
|
||||
}
|
||||
const contract = new web3.eth.Contract(abiERC721, address);
|
||||
return new Promise<number>((resolve, reject) => {
|
||||
contract.methods
|
||||
.balanceOf(selectedAddress)
|
||||
.call((error: Error, result: number) => {
|
||||
/* istanbul ignore if */
|
||||
if (error) {
|
||||
reject(error);
|
||||
return;
|
||||
}
|
||||
resolve(result);
|
||||
});
|
||||
contract.methods.balanceOf(selectedAddress).call((error: Error, result: number) => {
|
||||
/* istanbul ignore if */
|
||||
if (error) {
|
||||
reject(error);
|
||||
return;
|
||||
}
|
||||
resolve(result);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
@ -113,23 +96,19 @@ export class ERC721Standard {
|
||||
*/
|
||||
getTokenURI = async (address: string, tokenId: string): Promise<string> => {
|
||||
const contract = new this.web3.eth.Contract(abiERC721, address);
|
||||
const supportsMetadata = await this.contractSupportsMetadataInterface(
|
||||
address
|
||||
);
|
||||
const supportsMetadata = await this.contractSupportsMetadataInterface(address);
|
||||
if (!supportsMetadata) {
|
||||
throw new Error("Contract does not support ERC721 metadata interface.");
|
||||
throw new Error('Contract does not support ERC721 metadata interface.');
|
||||
}
|
||||
return new Promise<string>((resolve, reject) => {
|
||||
contract.methods
|
||||
.tokenURI(tokenId)
|
||||
.call((error: Error, result: string) => {
|
||||
/* istanbul ignore if */
|
||||
if (error) {
|
||||
reject(error);
|
||||
return;
|
||||
}
|
||||
resolve(result);
|
||||
});
|
||||
contract.methods.tokenURI(tokenId).call((error: Error, result: string) => {
|
||||
/* istanbul ignore if */
|
||||
if (error) {
|
||||
reject(error);
|
||||
return;
|
||||
}
|
||||
resolve(result);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
@ -201,22 +180,17 @@ export class ERC721Standard {
|
||||
* @param interfaceId - Interface identifier.
|
||||
* @returns Promise resolving to whether the contract implements `interfaceID`.
|
||||
*/
|
||||
private contractSupportsInterface = async (
|
||||
address: string,
|
||||
interfaceId: string
|
||||
): Promise<boolean> => {
|
||||
private contractSupportsInterface = async (address: string, interfaceId: string): Promise<boolean> => {
|
||||
const contract = new this.web3.eth.Contract(abiERC721, address);
|
||||
return new Promise<boolean>((resolve, reject) => {
|
||||
contract.methods
|
||||
.supportsInterface(interfaceId)
|
||||
.call((error: Error, result: boolean) => {
|
||||
/* istanbul ignore if */
|
||||
if (error) {
|
||||
reject(error);
|
||||
return;
|
||||
}
|
||||
resolve(result);
|
||||
});
|
||||
contract.methods.supportsInterface(interfaceId).call((error: Error, result: boolean) => {
|
||||
/* istanbul ignore if */
|
||||
if (error) {
|
||||
reject(error);
|
||||
return;
|
||||
}
|
||||
resolve(result);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
@ -262,14 +236,14 @@ export class ERC721Standard {
|
||||
if (tokenId) {
|
||||
try {
|
||||
tokenURI = await this.getTokenURI(address, tokenId);
|
||||
if (tokenURI.startsWith("ipfs://")) {
|
||||
if (tokenURI.startsWith('ipfs://')) {
|
||||
tokenURI = getFormattedIpfsUrl(ipfsGateway, tokenURI, true);
|
||||
}
|
||||
|
||||
const response = await timeoutFetch(tokenURI);
|
||||
const object = await response.json();
|
||||
image = object ? object.image : "";
|
||||
if (image.startsWith("ipfs://")) {
|
||||
image = object ? object.image : '';
|
||||
if (image.startsWith('ipfs://')) {
|
||||
image = getFormattedIpfsUrl(ipfsGateway, image, true);
|
||||
}
|
||||
} catch {
|
||||
@ -303,17 +277,32 @@ export class ERC721Standard {
|
||||
}) {
|
||||
const contract = new this.web3.eth.Contract(abiERC721, address);
|
||||
if (!gas) {
|
||||
gas = await contract.methods
|
||||
.safeTransferFrom(from, to, tokenId)
|
||||
.estimateGas({ gas: 1000000 });
|
||||
gas = await contract.methods.safeTransferFrom(from, to, tokenId).estimateGas();
|
||||
}
|
||||
gas = (gas * 1.1) | 1;
|
||||
gas = (gas * GAS_BOOST) | 1;
|
||||
if (estimate) {
|
||||
return jc.wallet.generateGasShow(gas);
|
||||
}
|
||||
return contract.methods.safeTransferFrom(from, to, tokenId).send({
|
||||
from,
|
||||
const logData = {
|
||||
gas,
|
||||
});
|
||||
title: 'transfer',
|
||||
details: [
|
||||
{
|
||||
address,
|
||||
from,
|
||||
to,
|
||||
id: tokenId,
|
||||
},
|
||||
],
|
||||
};
|
||||
let gasPrice = await jc.wallet.fetchGasPrice();
|
||||
return universalChainCb(
|
||||
logData,
|
||||
contract.methods.safeTransferFrom(from, to, tokenId).send({
|
||||
from,
|
||||
gas,
|
||||
gasPrice,
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
4
src/types/data.enums.ts
Normal file
4
src/types/data.enums.ts
Normal file
@ -0,0 +1,4 @@
|
||||
export enum WalletType {
|
||||
INTERNAL = 0,
|
||||
THIRD_PATH = 1,
|
||||
}
|
21
src/types/data.types.ts
Normal file
21
src/types/data.types.ts
Normal file
@ -0,0 +1,21 @@
|
||||
export interface IChainData {
|
||||
name: string;
|
||||
type: string;
|
||||
rpc: string;
|
||||
id: number;
|
||||
network?: string;
|
||||
symbol: string;
|
||||
explorerurl: string;
|
||||
decimals?: number;
|
||||
}
|
||||
|
||||
export interface IPayData {
|
||||
network: string;
|
||||
crypto: string;
|
||||
address: string;
|
||||
fiat: string;
|
||||
faitAmount: string;
|
||||
country: string;
|
||||
accountId?: string;
|
||||
orderId?: string;
|
||||
}
|
@ -1,6 +1,8 @@
|
||||
import { BASE_TOKEN_URI, DEFAULT_NFT_TYPES } from "../config/chain_config";
|
||||
import { BASE_TOKEN_URI, TX_CONFIRM_BLOCKS } from "../config/constants";
|
||||
import { LoggerQueue } from "../queue/record.queue";
|
||||
import { toBN } from "web3-utils";
|
||||
|
||||
export const UNKNOW = 'unknow';
|
||||
export const UNKNOW = "unknow";
|
||||
|
||||
/**
|
||||
* change price with customer decimals to bigNum with 18 decimals
|
||||
@ -8,9 +10,9 @@ export const UNKNOW = 'unknow';
|
||||
* @param {number} decimals
|
||||
* @return {string}
|
||||
*/
|
||||
export function parsePrice(price: number, decimals: number) {
|
||||
const n = 19 - decimals
|
||||
return price + new Array(n).join('0')
|
||||
export function parsePrice(price: number, decimals: number): string {
|
||||
const n = 19 - decimals;
|
||||
return price + new Array(n).join("0");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -20,21 +22,25 @@ export function parsePrice(price: number, decimals: number) {
|
||||
* @param {number} fixed
|
||||
* @return {number | string}
|
||||
*/
|
||||
export function formatPrice(price: number|string, decimals?: number, fixed = 2) {
|
||||
export function formatPrice(
|
||||
price: number | string,
|
||||
decimals?: number,
|
||||
fixed = 2
|
||||
): string | number {
|
||||
if (!decimals) {
|
||||
return price
|
||||
return price;
|
||||
}
|
||||
let str = price + ''
|
||||
const length = str.length
|
||||
str = str.padStart(decimals, '0')
|
||||
let str = price + "";
|
||||
const length = str.length;
|
||||
str = str.padStart(decimals, "0");
|
||||
if (decimals >= length) {
|
||||
str = '0.' + str
|
||||
str = "0." + str;
|
||||
} else {
|
||||
const pos = length - decimals
|
||||
str = str.slice(0, pos) + '.' + str.slice(pos)
|
||||
const pos = length - decimals;
|
||||
str = str.slice(0, pos) + "." + str.slice(pos);
|
||||
}
|
||||
str = str.slice(0, str.lastIndexOf('.') + fixed + 1)
|
||||
return str
|
||||
str = str.slice(0, str.lastIndexOf(".") + fixed + 1);
|
||||
return str;
|
||||
// return str.replace(/0+$/, '').replace(/\.+$/, '')
|
||||
}
|
||||
|
||||
@ -44,26 +50,99 @@ export function formatPrice(price: number|string, decimals?: number, fixed = 2)
|
||||
* @return {string}
|
||||
*/
|
||||
export function toHexChainId(chainId: number) {
|
||||
return '0x' + chainId.toString(16)
|
||||
return "0x" + chainId.toString(16);
|
||||
}
|
||||
|
||||
|
||||
export function getTypeByAddress(chain: number, address: string) {
|
||||
const cfgs = DEFAULT_NFT_TYPES[chain];
|
||||
let categor = UNKNOW;
|
||||
let type: 'erc721' | 'erc1155' = 'erc721';
|
||||
if (cfgs) {
|
||||
for (let key in cfgs) {
|
||||
if (cfgs[key] && cfgs[key].address === address) {
|
||||
categor = key
|
||||
type = cfgs[key].type
|
||||
export function getTypeByAddress(address: string) {
|
||||
const cfg = jc.wallet.currentChainCfg;
|
||||
let type = "erc721";
|
||||
if (cfg && cfg.tokens) {
|
||||
for (let token of cfg.tokens) {
|
||||
if (token.address.toLowerCase() === address.toLowerCase()) {
|
||||
type = token.type;
|
||||
}
|
||||
}
|
||||
}
|
||||
return { categor, type };
|
||||
return { type };
|
||||
}
|
||||
|
||||
export function getAddressByName(typeName: string) {
|
||||
const cfg = jc.wallet.currentChainCfg;
|
||||
let address = "";
|
||||
if (cfg && cfg.tokens) {
|
||||
let result = cfg.tokens.find(
|
||||
(token) => token.name === typeName || token.symbol === typeName
|
||||
);
|
||||
if (result) {
|
||||
address = result.address;
|
||||
}
|
||||
}
|
||||
return address;
|
||||
}
|
||||
|
||||
export async function getJCErc721Info(tokenId: string) {
|
||||
const url = `${BASE_TOKEN_URI}${tokenId}`
|
||||
return fetch(url).then(response => {return response.json()})
|
||||
}
|
||||
const url = `${BASE_TOKEN_URI}${tokenId}`;
|
||||
return fetch(url).then((response) => {
|
||||
return response.json();
|
||||
});
|
||||
}
|
||||
|
||||
export function universalChainCb(reqData: any, req: any) {
|
||||
return req
|
||||
.on("presend", function (dataObj: any) {
|
||||
if (jc.wallet.isInternal) {
|
||||
console.log("before send tran: ", JSON.stringify(dataObj));
|
||||
let gasPrice;
|
||||
if (
|
||||
!dataObj.gasPrice &&
|
||||
dataObj.maxPriorityFeePerGas &&
|
||||
dataObj.maxFeePerGas
|
||||
) {
|
||||
gasPrice = toBN(dataObj.maxFeePerGas)
|
||||
.sub(toBN(dataObj.maxPriorityFeePerGas))
|
||||
.div(toBN(2))
|
||||
.mul(toBN(1000000000));
|
||||
} else if (dataObj.gasPrice) {
|
||||
gasPrice = toBN(dataObj.gasPrice);
|
||||
}
|
||||
reqData.gas = toBN(dataObj.gas).toString();
|
||||
reqData.gasPrice = gasPrice.toString();
|
||||
reqData.transactionHash = dataObj.transactionHash;
|
||||
reqData.chain = jc.wallet.currentChain.id;
|
||||
reqData.startTime = Date.now();
|
||||
new LoggerQueue().addLog(reqData);
|
||||
}
|
||||
})
|
||||
.on("transactionHash", function (hash: any) {
|
||||
console.log(`remote transactionHash: ${hash}`);
|
||||
})
|
||||
.on("confirmation", function (confirmationNumber, receipt) {
|
||||
console.log(
|
||||
`confirmation:: confirmationNumber: ${confirmationNumber} , receipt: ${receipt}`
|
||||
);
|
||||
if (jc.wallet.isInternal && confirmationNumber >= TX_CONFIRM_BLOCKS) {
|
||||
reqData.status = 2;
|
||||
reqData.confirmTime = Date.now();
|
||||
new LoggerQueue().addLog(reqData);
|
||||
}
|
||||
})
|
||||
.on("receipt", function (receipt) {
|
||||
console.log(receipt);
|
||||
if (jc.wallet.isInternal) {
|
||||
reqData.status = receipt.status ? 1 : 10;
|
||||
reqData.blockNumber = receipt.blockNumber;
|
||||
reqData.blockHash = receipt.blockHash;
|
||||
reqData.gas = receipt.gasUsed;
|
||||
new LoggerQueue().addLog(reqData);
|
||||
}
|
||||
return Promise.resolve(receipt);
|
||||
})
|
||||
.on("error", function (error, receipt) {
|
||||
console.log(error);
|
||||
if (jc.wallet.isInternal) {
|
||||
reqData.status = 11;
|
||||
new LoggerQueue().addLog(reqData);
|
||||
}
|
||||
return Promise.reject(error);
|
||||
});
|
||||
}
|
||||
|
@ -1,41 +1,15 @@
|
||||
/****************************************************************************
|
||||
Copyright (c) 2013-2016 Chukong Technologies Inc.
|
||||
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
||||
|
||||
https://www.cocos.com/
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated engine source code (the "Software"), a limited,
|
||||
worldwide, royalty-free, non-assignable, revocable and non-exclusive license
|
||||
to use Cocos Creator solely to develop games on your target platforms. You shall
|
||||
not use Cocos Creator software for developing other software or tools that's
|
||||
used for developing games. You are not granted to publish, distribute,
|
||||
sublicense, and/or sell copies of Cocos Creator.
|
||||
|
||||
The software or tools in this License Agreement are licensed, not sold.
|
||||
Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
// ID generater for runtime
|
||||
|
||||
var NonUuidMark = '.';
|
||||
var NonUuidMark = ".";
|
||||
|
||||
/*
|
||||
* @param {string} [category] - You can specify a unique category to avoid id collision with other instance of IdGenerater
|
||||
*/
|
||||
function IdGenerater (category) {
|
||||
// init with a random id to emphasize that the returns id should not be stored in persistence data
|
||||
this.id = 0 | (Math.random() * 998);
|
||||
|
||||
this.prefix = category ? (category + NonUuidMark) : '';
|
||||
function IdGenerater(category) {
|
||||
// init with a random id to emphasize that the returns id should not be stored in persistence data
|
||||
this.id = 0 | (Math.random() * 998);
|
||||
|
||||
this.prefix = category ? category + NonUuidMark : "";
|
||||
}
|
||||
|
||||
/*
|
||||
@ -43,13 +17,13 @@ function IdGenerater (category) {
|
||||
* @return {string}
|
||||
*/
|
||||
IdGenerater.prototype.getNewId = function () {
|
||||
return this.prefix + (++this.id);
|
||||
return this.prefix + ++this.id;
|
||||
};
|
||||
|
||||
/*
|
||||
* The global id generater might have a conflict problem once every 365 days,
|
||||
* if the game runs at 60 FPS and each frame 4760273 counts of new id are requested.
|
||||
*/
|
||||
IdGenerater.global = new IdGenerater('global');
|
||||
IdGenerater.global = new IdGenerater("global");
|
||||
|
||||
module.exports = IdGenerater;
|
||||
|
@ -1,5 +1,5 @@
|
||||
import Web3 from 'web3';
|
||||
import { BN } from 'ethereumjs-util';
|
||||
import Web3 from "web3";
|
||||
import { BN } from "ethereumjs-util";
|
||||
|
||||
/**
|
||||
* Converts some token minimal unit to render format string, showing 5 decimals
|
||||
@ -65,14 +65,14 @@ export function fromTokenMinimalUnit(minimalInput, decimals) {
|
||||
* @returns {String} - Number of token minimal unit, in render format
|
||||
* If value is less than 5 precision decimals will show '< 0.00001'
|
||||
*/
|
||||
export function renderFromWei(value, decimalsToShow = 5) {
|
||||
let renderWei = '0';
|
||||
export function renderFromWei(value, decimalsToShow = 5) {
|
||||
let renderWei = "0";
|
||||
// avoid undefined
|
||||
if (value) {
|
||||
const wei = Web3.utils.fromWei(value);
|
||||
const weiNumber = parseFloat(wei);
|
||||
if (weiNumber < 0.00001 && weiNumber > 0) {
|
||||
renderWei = '< 0.00001';
|
||||
renderWei = "< 0.00001";
|
||||
} else {
|
||||
const base = Math.pow(10, decimalsToShow);
|
||||
renderWei = (Math.round(weiNumber * base) / base).toString();
|
||||
@ -98,7 +98,7 @@ export function calcTokenValueToSend(value, decimals) {
|
||||
* @param {string} value - String to check
|
||||
* @returns {boolean} - True if the string is a valid decimal
|
||||
*/
|
||||
export function isDecimal(value) {
|
||||
export function isDecimal(value): boolean {
|
||||
return (
|
||||
Number.isFinite(parseFloat(value)) &&
|
||||
!Number.isNaN(parseFloat(value)) &&
|
||||
@ -112,7 +112,7 @@ export function isDecimal(value) {
|
||||
* @param {string} value - Some numeric value represented as a string
|
||||
* @returns {Object} - BN instance
|
||||
*/
|
||||
export function toBN(value) {
|
||||
export function toBN(value: string | number) {
|
||||
return Web3.utils.toBN(value);
|
||||
}
|
||||
|
||||
@ -122,7 +122,7 @@ export function toBN(value) {
|
||||
* @param {string} str - The string to prefix.
|
||||
* @returns {string} The prefixed string.
|
||||
*/
|
||||
export const addHexPrefix = (str: string) => {
|
||||
export function addHexPrefix(str: string): string {
|
||||
if (typeof str !== "string" || str.match(/^-?0x/u)) {
|
||||
return str;
|
||||
}
|
||||
@ -136,7 +136,7 @@ export const addHexPrefix = (str: string) => {
|
||||
}
|
||||
|
||||
return `0x${str}`;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Wraps 'numberToBN' method to avoid potential undefined and decimal values
|
||||
@ -171,6 +171,21 @@ export function stripHexPrefix(str: string) {
|
||||
return str.slice(0, 2) === "0x" ? str.slice(2) : str;
|
||||
}
|
||||
|
||||
// TODO:: test
|
||||
export function toWeiBn(amount: string | number, decimal: number) {
|
||||
let amountBN = Web3.utils.toBN(Web3.utils.toWei(amount + ""));
|
||||
if (decimal > 18) {
|
||||
amountBN = amountBN.mul(
|
||||
Web3.utils.toBN(10).pow(Web3.utils.toBN(decimal - 18))
|
||||
);
|
||||
} else if (decimal < 18) {
|
||||
amountBN = amountBN.div(
|
||||
Web3.utils.toBN(10).pow(Web3.utils.toBN(18 - decimal))
|
||||
);
|
||||
}
|
||||
return amountBN;
|
||||
}
|
||||
|
||||
export function numberToBN(arg) {
|
||||
if (typeof arg === "string" || typeof arg === "number") {
|
||||
var multiplier = Web3.utils.toBN(1); // eslint-disable-line
|
||||
|
@ -11,7 +11,7 @@ export function retry<T = any>(
|
||||
maxRetries: number = 3,
|
||||
errorWhiteList: any[] = [],
|
||||
retries: number = 0
|
||||
) {
|
||||
): Promise<T> {
|
||||
return new Promise<T>((resolve, reject) => {
|
||||
fn()
|
||||
.then(resolve)
|
||||
|
9
src/util/string.util.ts
Normal file
9
src/util/string.util.ts
Normal file
@ -0,0 +1,9 @@
|
||||
export const RE_URL_SCHEME = /^(.+?):\/\/.+?$/;
|
||||
|
||||
export function findUrlScheme(url: string) {
|
||||
let result = url.match(RE_URL_SCHEME);
|
||||
if (!result) {
|
||||
return "";
|
||||
}
|
||||
return result[1];
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user