1、gasprice溢价
2、重复添加token校验
This commit is contained in:
		| @ -71,7 +71,15 @@ func (e *WmToken) Get(d *dto.WmTokenGetReq, p *actions.DataPermission, model *mo | ||||
| func (e *WmToken) Insert(c *dto.WmTokenInsertReq) error { | ||||
| 	var err error | ||||
| 	var data models.WmToken | ||||
| 	var count int64 | ||||
| 	c.Generate(&data) | ||||
|  | ||||
| 	e.Orm.Model(models.WmToken{}).Where("network_id = ? and token_address = ?", data.NetworkId, data.TokenAddress).Count(&count) | ||||
|  | ||||
| 	if count > 0 { | ||||
| 		return errors.New("代币合约已存在") | ||||
| 	} | ||||
|  | ||||
| 	err = e.Orm.Create(&data).Error | ||||
| 	if err != nil { | ||||
| 		e.Log.Errorf("WmTokenService Insert error:%s \r\n", err) | ||||
| @ -86,6 +94,14 @@ func (e *WmToken) Insert(c *dto.WmTokenInsertReq) error { | ||||
| func (e *WmToken) Update(c *dto.WmTokenUpdateReq, p *actions.DataPermission) error { | ||||
| 	var err error | ||||
| 	var data = models.WmToken{} | ||||
| 	var count int64 | ||||
|  | ||||
| 	e.Orm.Model(models.WmToken{}).Where("network_id = ? and token_address = ? and id <> ?", data.NetworkId, data.TokenAddress, c.GetId()).Count(&count) | ||||
|  | ||||
| 	if count > 0 { | ||||
| 		return errors.New("代币合约已存在") | ||||
| 	} | ||||
|  | ||||
| 	e.Orm.Scopes( | ||||
| 		actions.Permission(data.TableName(), p), | ||||
| 	).First(&data, c.GetId()) | ||||
|  | ||||
| @ -49,7 +49,7 @@ settings: | ||||
|     demo: | ||||
|       name: data | ||||
|      | ||||
|     apiEndpoint: https://stylish-cool-fire.ethereum-sepolia.quiknode.pro/17572db4c091accfa5dc6faa0c60a805e5173459 | ||||
|     apiEndpoint: https://hidden-light-putty.quiknode.pro/9ec98f871f771663e9e8892b9cc34042f296c04b | ||||
|     proxyUrl: http://127.0.0.1:7890 | ||||
|   cache: | ||||
|     redis: | ||||
|  | ||||
| @ -58,6 +58,8 @@ func TransferEth(client *ethclient.Client, fromPrivateKey string, toAddress stri | ||||
| 		return nil, fmt.Errorf("获取 Gas 价格失败: %w", err) | ||||
| 	} | ||||
|  | ||||
| 	gasPrice = new(big.Int).Mul(gasPrice, big.NewInt(11)) | ||||
| 	gasPrice = new(big.Int).Div(gasPrice, big.NewInt(10)) | ||||
| 	// 6. 将地址字符串转换为 common.Address 类型 | ||||
| 	toAddressCommon := common.HexToAddress(toAddress) | ||||
|  | ||||
| @ -145,6 +147,8 @@ func TransferErc20Token( | ||||
| 		return nil, fmt.Errorf("获取 Gas 价格失败: %w", err) | ||||
| 	} | ||||
|  | ||||
| 	gasPrice = new(big.Int).Mul(gasPrice, big.NewInt(11)) | ||||
| 	gasPrice = new(big.Int).Div(gasPrice, big.NewInt(10)) | ||||
| 	// 6. 将地址字符串转换为 common.Address 类型 | ||||
| 	toAddressCommon := common.HexToAddress(toAddress) | ||||
| 	tokenAddressCommon := common.HexToAddress(tokenAddress) | ||||
|  | ||||
		Reference in New Issue
	
	Block a user