Documentation ¶
Index ¶
- Constants
- Variables
- func LoadBchMainnetBurnt(ctx *mevmtypes.Context) *uint256.Int
- func LoadCCEpoch(ctx *mevmtypes.Context, epochNum int64) (epoch types.CCEpoch, ok bool)
- func LoadCCInfo(ctx *mevmtypes.Context) (info types.CCInfo)
- func LoadUTXO(ctx *mevmtypes.Context, utxo [36]byte) *uint256.Int
- func PackBurnBCH(utxo [36]byte) []byte
- func PackTransferBCHToMainnet(utxo [36]byte) []byte
- func SaveBchMainnetBurnt(ctx *mevmtypes.Context, amount *uint256.Int)
- func SaveCCEpoch(ctx *mevmtypes.Context, epochNum int64, epoch *types.CCEpoch)
- func SaveCCInfo(ctx *mevmtypes.Context, info types.CCInfo)
- func SaveUTXO(ctx *mevmtypes.Context, utxo [36]byte, amount *uint256.Int)
- func SwitchCCEpoch(ctx *mevmtypes.Context, epoch *types.CCEpoch)
- func UpdateBchBurnt(ctx *mevmtypes.Context, amount *uint256.Int) error
- type CcContractExecutor
- func (s *CcContractExecutor) Execute(ctx *mevmtypes.Context, currBlock *mevmtypes.BlockInfo, tx *mevmtypes.TxToRun) (status int, logs []mevmtypes.EvmLog, gasUsed uint64, outData []byte)
- func (_ *CcContractExecutor) Init(ctx *mevmtypes.Context)
- func (_ *CcContractExecutor) IsSystemContract(addr common.Address) bool
- func (_ *CcContractExecutor) RequiredGas(_ []byte) uint64
- func (_ *CcContractExecutor) Run(_ []byte) ([]byte, error)
Constants ¶
View Source
const ( StatusSuccess int = 0 StatusFailed int = 1 )
Variables ¶
View Source
var ( //contract address, 9999 //todo: transfer remain BCH to this address before working CCContractAddress [20]byte = [20]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x27, 0x09} /*------selector------*/ /*interface CC { function transferBCHToMainnet(bytes utxo) external; function burnBCH(bytes utxo) external; event TransferToMainnet(bytes32 indexed mainnetTxId, bytes4 indexed vOutIndex, address indexed from, uint256 value); event Burn(bytes32 indexed mainnetTxId, bytes4 indexed vOutIndex, uint256 value); }*/ SelectorTransferBchToMainnet [4]byte = [4]byte{0xa0, 0x4f, 0x3b, 0x01} SelectorBurnBCH [4]byte = [4]byte{0x18, 0x92, 0xa8, 0xb3} HashOfEventTransferToBch [32]byte = common.HexToHash("0x4a9f09be1e2df144675144ec10cb5fe6c05504a84262275b62028189c1d410c1") HashOfEventBurn [32]byte = common.HexToHash("0xeae299b236fc8161793d044c8260b3dc7f8c20b5b3b577eb7f075e4a9c3bf48d") GasOfCCOp uint64 = 400_000 InvalidCallData = errors.New("invalid call data") InvalidSelector = errors.New("invalid selector") BchAmountNotMatch = errors.New("value not match bch amount in utxo") BalanceNotEnough = errors.New("balance is not enough") BurnToMuch = errors.New("burn more bch than reality") SlotCCInfo string = strings.Repeat(string([]byte{0}), 32) SlotBCHAlreadyBurnt string = strings.Repeat(string([]byte{0}), 31) + string([]byte{1}) )
View Source
var ABI = ethutils.MustParseABI(`
[
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "bytes32",
"name": "mainnetTxId",
"type": "bytes32"
},
{
"indexed": true,
"internalType": "bytes4",
"name": "vOutIndex",
"type": "bytes4"
},
{
"indexed": false,
"internalType": "uint256",
"name": "value",
"type": "uint256"
}
],
"name": "Burn",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "bytes32",
"name": "mainnetTxId",
"type": "bytes32"
},
{
"indexed": true,
"internalType": "bytes4",
"name": "vOutIndex",
"type": "bytes4"
},
{
"indexed": true,
"internalType": "address",
"name": "from",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "value",
"type": "uint256"
}
],
"name": "TransferToMainnet",
"type": "event"
},
{
"inputs": [
{
"internalType": "bytes",
"name": "utxo",
"type": "bytes"
}
],
"name": "burnBCH",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes",
"name": "utxo",
"type": "bytes"
}
],
"name": "transferBCHToMainnet",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}
]
`)
Functions ¶
func LoadCCEpoch ¶
func PackBurnBCH ¶
Types ¶
type CcContractExecutor ¶
type CcContractExecutor struct {
// contains filtered or unexported fields
}
func NewCcContractExecutor ¶
func NewCcContractExecutor(logger log.Logger) *CcContractExecutor
func (*CcContractExecutor) Init ¶
func (_ *CcContractExecutor) Init(ctx *mevmtypes.Context)
func (*CcContractExecutor) IsSystemContract ¶
func (_ *CcContractExecutor) IsSystemContract(addr common.Address) bool
func (*CcContractExecutor) RequiredGas ¶
func (_ *CcContractExecutor) RequiredGas(_ []byte) uint64
this functions is called when other contract calls
Click to show internal directories.
Click to hide internal directories.