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