parent
3b13975d04
commit
1a37fe29f2
|
@ -1,12 +1,12 @@
|
|||
###
|
||||
# @LastEditors: John
|
||||
# @Date: 2024-06-18 10:12:21
|
||||
# @LastEditTime: 2024-06-22 11:22:13
|
||||
# @LastEditTime: 2024-06-24 18:25:07
|
||||
# @Author: John
|
||||
###
|
||||
VITE_BASE_URL=http://192.168.10.167:5173/
|
||||
VITE_BASE_API_URL=/dev
|
||||
VITE_PARTICIPATE_CHAIN_ID=97
|
||||
VITE_PURCHASED_CONTRACT_ADDRESS=0x37644e2E1Ac2D0b87f693Ad64A154f3A7fe09b93
|
||||
VITE_NETWORK_USDT_ADDRESS=0xACFE3DF8ACeF83De51d53E22ADE30F18eaB4969A
|
||||
VITE_PURCHASED_CONTRACT_ADDRESS=0xD70762bf8682b68bd0cbbBC0cdeC81db4f00AEc6
|
||||
VITE_NETWORK_USDT_ADDRESS=0xf9A18B7FC8Eb118f8Ad59fBD6eb1A181eaCb4E63
|
||||
VITE_CHECK_TRANSACTION_DETAILS_URL=https://testnet.bscscan.com/
|
|
@ -1,5 +1,6 @@
|
|||
VITE_BASE_URL=/
|
||||
VITE_BASE_API_URL=/dev
|
||||
VITE_PARTICIPATE_CHAIN_ID=56
|
||||
VITE_NETWORK_USDT_ADDRESS=0x55d398326f99059ff775485246999027b3197955
|
||||
VITE_PURCHASED_CONTRACT_ADDRESS=
|
||||
VITE_NETWORK_USDT_ADDRESS=
|
||||
VITE_CHECK_TRANSACTION_DETAILS_URL=https://bscscan.com/
|
|
@ -1,268 +1,457 @@
|
|||
[
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "amount",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "orderId",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "buyHMNFT",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "hongMoAddr",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "payAddr",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "constructor"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "owner",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "OwnableInvalidOwner",
|
||||
"type": "error"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "account",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "OwnableUnauthorizedAccount",
|
||||
"type": "error"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "uint256",
|
||||
"name": "tokenId",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "uint256",
|
||||
"name": "amount",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "address",
|
||||
"name": "buyAddr",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "uint256",
|
||||
"name": "orderId",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "BuySuccess",
|
||||
"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"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "renounceOwnership",
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "tokenIn",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "setTokenIndex",
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "newOwner",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "transferOwnership",
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "amount",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "orderId",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "upgradePrivilege",
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "uint256",
|
||||
"name": "amount",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "address",
|
||||
"name": "buyAddr",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "uint256",
|
||||
"name": "orderId",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "UpgradeRange",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "hongMoNFT",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "contract HongMoNFT",
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "owner",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "price",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "tokenIndex",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "totalSupply",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "usdc",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "contract IERC20",
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
}
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "hongMoAddr",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "payAddr",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "p1",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "p2",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "constructor"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "owner",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "OwnableInvalidOwner",
|
||||
"type": "error"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "account",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "OwnableUnauthorizedAccount",
|
||||
"type": "error"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "uint256",
|
||||
"name": "tokenId",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "uint256",
|
||||
"name": "amount",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "address",
|
||||
"name": "buyAddr",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "uint256",
|
||||
"name": "orderId",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "BuySuccess",
|
||||
"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": "uint256",
|
||||
"name": "amount",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "address",
|
||||
"name": "buyAddr",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "uint256",
|
||||
"name": "orderId",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "RewardSuccess",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "uint256",
|
||||
"name": "amount",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "address",
|
||||
"name": "buyAddr",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "uint256",
|
||||
"name": "orderId",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "UpgradeRange",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "amount",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "orderId",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "paymentType",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "buyHMNFT",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "orderId",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "getOrderStatus",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "hongMoNFT",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "contract HongMoNFT",
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "owner",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "payee1",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "payee2",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "price",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "renounceOwnership",
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "amount",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "paymentTime",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "orderId",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"internalType": "bytes32",
|
||||
"name": "hashStr",
|
||||
"type": "bytes32"
|
||||
}
|
||||
],
|
||||
"name": "reward",
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "addr",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "setNFTAddress",
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "a",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "b",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "setPayeeAddress",
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "p",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "setPrice",
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "addr",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "setTokenIndex",
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "addr",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "setUSDCAddress",
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "string",
|
||||
"name": "source",
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"name": "stringToBytes32",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "bytes32",
|
||||
"name": "result",
|
||||
"type": "bytes32"
|
||||
}
|
||||
],
|
||||
"stateMutability": "pure",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "tokenIndex",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "totalSupply",
|
||||
"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": "uint256",
|
||||
"name": "amount",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "orderId",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "upgradePrivilege",
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "usdc",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "contract IERC20",
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
}
|
||||
]
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* @LastEditors: John
|
||||
* @Date: 2024-06-19 15:48:57
|
||||
* @LastEditTime: 2024-06-24 11:09:12
|
||||
* @LastEditTime: 2024-06-24 18:25:44
|
||||
* @Author: John
|
||||
*/
|
||||
import { config } from "@/components/WalletProvider";
|
||||
|
@ -16,8 +16,6 @@ import { encodeFunctionData } from "viem/utils";
|
|||
import erc20Abi from "@/contract/abi/erc20abi.json";
|
||||
import usdtAbi from "@/contract/abi/USDT.json";
|
||||
import RedDevilsAbi from "@/contract/abi/RedDevils.json";
|
||||
import Toast from "antd-mobile/es/components/toast";
|
||||
import { EstimateGasErrorType, WriteContractErrorType } from "viem";
|
||||
import i18next from "i18next";
|
||||
import { BaseError } from "wagmi";
|
||||
|
||||
|
@ -145,7 +143,11 @@ export const authorizedU = async (uNum: bigint) => {
|
|||
* @param orderID
|
||||
* @returns
|
||||
*/
|
||||
export async function payByContract(amount: bigint, orderID: string) {
|
||||
export async function payByContract(
|
||||
amount: bigint,
|
||||
orderID: string,
|
||||
payInduction: number
|
||||
) {
|
||||
console.log("pay buy contract params", { amount, orderID });
|
||||
console.log("NETWORK_USDT:", import.meta.env.VITE_NETWORK_USDT_ADDRESS);
|
||||
|
||||
|
@ -164,13 +166,13 @@ export async function payByContract(amount: bigint, orderID: string) {
|
|||
await authorizedU(amount);
|
||||
}
|
||||
|
||||
console.log("参数:", amount, orderID);
|
||||
console.log("参数:", amount, orderID, payInduction);
|
||||
estimateGas(config, {
|
||||
to: import.meta.env.VITE_PURCHASED_CONTRACT_ADDRESS,
|
||||
data: encodeFunctionData({
|
||||
abi: RedDevilsAbi,
|
||||
functionName: "buyHMNFT",
|
||||
args: [amount, orderID],
|
||||
args: [amount, orderID, payInduction],
|
||||
}),
|
||||
})
|
||||
.then((gas) => {
|
||||
|
@ -180,7 +182,7 @@ export async function payByContract(amount: bigint, orderID: string) {
|
|||
abi: RedDevilsAbi,
|
||||
address: import.meta.env.VITE_PURCHASED_CONTRACT_ADDRESS,
|
||||
functionName: "buyHMNFT",
|
||||
args: [amount, orderID],
|
||||
args: [amount, orderID, payInduction],
|
||||
gas: gasPrice,
|
||||
})
|
||||
.then((receipt) => {
|
||||
|
@ -188,12 +190,12 @@ export async function payByContract(amount: bigint, orderID: string) {
|
|||
reslove(receipt);
|
||||
})
|
||||
.catch((err: BaseError) => {
|
||||
console.log("buyHMNFT Transaction err", err.details);
|
||||
console.log("buyHMNFT Transaction err", err);
|
||||
reject(err);
|
||||
});
|
||||
})
|
||||
.catch((err: BaseError) => {
|
||||
console.log("buyHMNFT estimateGas err", err.details);
|
||||
console.log("buyHMNFT estimateGas err", err);
|
||||
reject(err);
|
||||
});
|
||||
} catch (err) {
|
||||
|
@ -252,12 +254,12 @@ export async function upGradeByContract(amount: bigint, orderID: string) {
|
|||
reslove(receipt);
|
||||
})
|
||||
.catch((err: BaseError) => {
|
||||
console.log("upgradePrivilege Transaction err", err.details);
|
||||
console.log("upgradePrivilege Transaction err", err);
|
||||
reject(err);
|
||||
});
|
||||
})
|
||||
.catch((err: BaseError) => {
|
||||
console.log("upgradePrivilege estimateGas err", err.details);
|
||||
console.log("upgradePrivilege estimateGas err", err);
|
||||
reject(err);
|
||||
});
|
||||
} catch (err) {
|
||||
|
@ -272,9 +274,64 @@ export async function upGradeByContract(amount: bigint, orderID: string) {
|
|||
* @param orderID
|
||||
* @returns
|
||||
*/
|
||||
export async function receiveByContract(amount: bigint, orderID: string) {
|
||||
export async function receiveByContract(
|
||||
amount: bigint,
|
||||
paymentTime: number,
|
||||
orderID: string,
|
||||
hashStr: string
|
||||
) {
|
||||
console.log("pay buy contract params", { amount, orderID });
|
||||
console.log("NETWORK_USDT:", import.meta.env.VITE_NETWORK_USDT_ADDRESS);
|
||||
|
||||
return new Promise<string>(async (reslove, reject) => {});
|
||||
return new Promise<string>(async (reslove, reject) => {
|
||||
try {
|
||||
const balance = await getBalance();
|
||||
if (balance < amount) {
|
||||
console.log("用户代币余额不足");
|
||||
reject(new BaseError(i18next.t("余额不足")));
|
||||
return;
|
||||
}
|
||||
|
||||
console.log("当前要授权的U:", amount);
|
||||
let approvedU = await getApproveUsdt();
|
||||
if (approvedU < amount) {
|
||||
await authorizedU(amount);
|
||||
}
|
||||
|
||||
console.log("参数:", amount, paymentTime, orderID, hashStr);
|
||||
estimateGas(config, {
|
||||
to: import.meta.env.VITE_PURCHASED_CONTRACT_ADDRESS,
|
||||
data: encodeFunctionData({
|
||||
abi: RedDevilsAbi,
|
||||
functionName: "reward",
|
||||
args: [amount, paymentTime, orderID, hashStr],
|
||||
}),
|
||||
})
|
||||
.then((gas) => {
|
||||
const gasPrice = (gas * 12n) / 10n;
|
||||
console.log("estimate gas:%d , my gas: %d", gas, gasPrice);
|
||||
writeContract(config, {
|
||||
abi: RedDevilsAbi,
|
||||
address: import.meta.env.VITE_PURCHASED_CONTRACT_ADDRESS,
|
||||
functionName: "reward",
|
||||
args: [amount, paymentTime, orderID, hashStr],
|
||||
gas: gasPrice,
|
||||
})
|
||||
.then((receipt) => {
|
||||
console.log("write contract success!, receipt:", receipt);
|
||||
reslove(receipt);
|
||||
})
|
||||
.catch((err: BaseError) => {
|
||||
console.log("reward Transaction err", err);
|
||||
reject(err);
|
||||
});
|
||||
})
|
||||
.catch((err: BaseError) => {
|
||||
console.log("reward estimateGas err", err);
|
||||
reject(err);
|
||||
});
|
||||
} catch (err) {
|
||||
reject(new BaseError(`${err}`));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -13,13 +13,9 @@ import { BaseError, useAccount } from "wagmi";
|
|||
import { disconnect } from "wagmi/actions";
|
||||
import { config } from "@/components/WalletProvider";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { Button, Dialog, Ellipsis, Empty, Toast } from "antd-mobile";
|
||||
import { loginOut, signAndLogin } from "@/utils/wallet";
|
||||
import {
|
||||
api_claim_income,
|
||||
api_get_homepage_user_data,
|
||||
api_users_cancel_orders,
|
||||
} from "@/server/api";
|
||||
import { Button, Dialog, Empty, Toast } from "antd-mobile";
|
||||
import { loginOut } from "@/utils/wallet";
|
||||
import { api_claim_income, api_get_homepage_user_data } from "@/server/api";
|
||||
import { UserHomeData } from "@/server/module";
|
||||
import { UrlQueryParamsKey } from "@/constants";
|
||||
import { receiveByContract } from "@/contract/utils";
|
||||
|
@ -44,7 +40,7 @@ export default function () {
|
|||
[userData]
|
||||
);
|
||||
const receiveLoadingToast = useRef<ToastHandler>();
|
||||
const { transcationStatus, startPollingCheckBuyStatus } =
|
||||
const { transcationStatus, startPollingCheckBuyStatus,stopPollingCheckBuyStatus } =
|
||||
usePollingCheckBuyStatus("NORMAL");
|
||||
|
||||
useEffect(() => {
|
||||
|
@ -55,6 +51,7 @@ export default function () {
|
|||
useEffect(() => {
|
||||
if (transcationStatus == "success") {
|
||||
receiveLoadingToast.current?.close();
|
||||
stopPollingCheckBuyStatus()
|
||||
Dialog.alert({
|
||||
content: `${t("领取成功,前往钱包查看")}`,
|
||||
confirmText: "OK",
|
||||
|
@ -297,7 +294,12 @@ export default function () {
|
|||
const buyAmount = BigInt(
|
||||
orderInfo?.claimQuantity || ""
|
||||
);
|
||||
receiveByContract(buyAmount, orderInfo?.orderNumber)
|
||||
receiveByContract(
|
||||
buyAmount,
|
||||
orderInfo.time,
|
||||
orderInfo?.orderNumber,
|
||||
orderInfo.hash
|
||||
)
|
||||
.then((hash) => {
|
||||
console.log("领取成功!hash:", hash);
|
||||
getHomeData();
|
||||
|
|
|
@ -38,8 +38,11 @@ export default function () {
|
|||
const upgradeLoadingtoast = useRef<ToastHandler>();
|
||||
const orderInfo = useRef<UpgradeOrder>();
|
||||
|
||||
const { transcationStatus, startPollingCheckBuyStatus } =
|
||||
usePollingCheckBuyStatus("NORMAL");
|
||||
const {
|
||||
transcationStatus,
|
||||
startPollingCheckBuyStatus,
|
||||
stopPollingCheckBuyStatus,
|
||||
} = usePollingCheckBuyStatus("NORMAL");
|
||||
useEffect(() => {
|
||||
updateUserUpgrdeInfo();
|
||||
return () => {};
|
||||
|
@ -66,6 +69,7 @@ export default function () {
|
|||
useEffect(() => {
|
||||
if (transcationStatus == "success") {
|
||||
upgradeLoadingtoast.current?.close();
|
||||
stopPollingCheckBuyStatus();
|
||||
Dialog.alert({
|
||||
content: `${t("升级成功,返回首页查看")}`,
|
||||
confirmText: "OK",
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* @LastEditors: John
|
||||
* @Date: 2024-06-18 15:28:03
|
||||
* @LastEditTime: 2024-06-24 11:08:14
|
||||
* @LastEditTime: 2024-06-24 18:28:07
|
||||
* @Author: John
|
||||
*/
|
||||
import { cn } from "@/utils";
|
||||
|
@ -41,7 +41,7 @@ export default function () {
|
|||
|
||||
const buyLoadingToast = useRef<ToastHandler>();
|
||||
const approveLoadingToast = useRef<ToastHandler>();
|
||||
const { buyNftIds, startPollingCheckBuyStatus } =
|
||||
const { buyNftIds, startPollingCheckBuyStatus, stopPollingCheckBuyStatus } =
|
||||
usePollingCheckBuyStatus("NFT");
|
||||
|
||||
const approvePrice = useMemo(
|
||||
|
@ -73,6 +73,7 @@ export default function () {
|
|||
useEffect(() => {
|
||||
if (buyNftIds) {
|
||||
buyLoadingToast.current?.close();
|
||||
stopPollingCheckBuyStatus();
|
||||
Dialog.alert({
|
||||
content: `${t("MINT成功,返回首页查看")}`,
|
||||
confirmText: "OK",
|
||||
|
@ -176,7 +177,11 @@ export default function () {
|
|||
orderInfo.current = orderRes?.data;
|
||||
if (!orderInfo.current?.orderNumber) return;
|
||||
const buyAmount = BigInt(orderInfo.current?.buyAmount || "");
|
||||
payByContract(buyAmount, orderInfo.current?.orderNumber)
|
||||
payByContract(
|
||||
buyAmount,
|
||||
orderInfo.current?.orderNumber,
|
||||
orderInfo.current.payInduction
|
||||
)
|
||||
.then((hash) => {
|
||||
console.log("购买成功!hash:", hash);
|
||||
updateNftConfig();
|
||||
|
|
|
@ -102,6 +102,7 @@ export interface NftOrder {
|
|||
updateBy: string;
|
||||
updateTime: string;
|
||||
userId: number;
|
||||
payInduction: number;
|
||||
}
|
||||
|
||||
export interface PreprelionListItem {
|
||||
|
@ -133,5 +134,5 @@ export interface ClaimIncome {
|
|||
claimQuantity: string;
|
||||
hash: string;
|
||||
orderNumber: string;
|
||||
time: string;
|
||||
time: number;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* @LastEditors: John
|
||||
* @Date: 2024-06-17 18:19:27
|
||||
* @LastEditTime: 2024-06-22 15:26:37
|
||||
* @LastEditTime: 2024-06-24 14:49:16
|
||||
* @Author: John
|
||||
*/
|
||||
import { type ClassValue, clsx } from "clsx";
|
||||
|
@ -14,7 +14,6 @@ export const ua = navigator.userAgent;
|
|||
export const isIOS = /iphone|ipad|ipod|ios/i.test(ua);
|
||||
export const isAndroid = /android|XiaoMi|MiuiBrowser/i.test(ua);
|
||||
export const isMobile = isIOS || isAndroid;
|
||||
export const isOKApp = /OKApp/i.test(ua);
|
||||
|
||||
export function shortenString(
|
||||
inputString: string,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* @LastEditors: John
|
||||
* @Date: 2024-06-19 15:55:07
|
||||
* @LastEditTime: 2024-06-20 16:30:22
|
||||
* @LastEditTime: 2024-06-24 14:01:50
|
||||
* @Author: John
|
||||
*/
|
||||
import { config } from "@/components/WalletProvider";
|
||||
|
@ -13,17 +13,11 @@ import {
|
|||
} from "@/server/api";
|
||||
import useUserStore from "@/store/User";
|
||||
import {
|
||||
writeContract,
|
||||
readContract,
|
||||
estimateGas,
|
||||
waitForTransactionReceipt,
|
||||
getConnectorClient,
|
||||
signMessage,
|
||||
getChains,
|
||||
switchChain,
|
||||
getChainId,
|
||||
disconnect,
|
||||
getAccount,
|
||||
} from "@wagmi/core";
|
||||
import Toast from "antd-mobile/es/components/toast";
|
||||
import i18next from "i18next";
|
||||
|
|
Loading…
Reference in New Issue