Skip to content

Commit

Permalink
fix: unaligned 64-bit atomic operation.
Browse files Browse the repository at this point in the history
  • Loading branch information
Zhangguiguang committed Dec 9, 2024
1 parent a4c885a commit efca372
Show file tree
Hide file tree
Showing 23 changed files with 111 additions and 110 deletions.
14 changes: 7 additions & 7 deletions core/aptos/dapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,24 @@ import (
)

type SignMessagePayload struct {
// A nonce the dApp should generate
Nonce int64 `json:"nonce"`
// The message to be signed and displayed to the user
Message string `json:"message"`
// Should we include the address of the account in the message
Address bool `json:"address,omitempty"`
// Should we include the domain of the dApp
Application bool `json:"application,omitempty"`
// Should we include the current chain id the wallet is connected to
ChainId bool `json:"chainId,omitempty"`
// The message to be signed and displayed to the user
Message string `json:"message"`
// A nonce the dApp should generate
Nonce int64 `json:"nonce"`
}

type SignMessageResponse struct {
Address string `json:"address,omitempty"`
Application string `json:"application,omitempty"`
ChainId int64 `json:"chainId,omitempty"`
Message string `json:"message"` // The message passed in by the user
Nonce int64 `json:"nonce"`
Address string `json:"address,omitempty"`
Application string `json:"application,omitempty"`
Message string `json:"message"` // The message passed in by the user
Prefix string `json:"prefix"` // Should always be APTOS
FullMessage string `json:"fullMessage"` // The message that was generated to sign
Signature string `json:"signature"` // The signed full message
Expand Down
7 changes: 3 additions & 4 deletions core/aptos/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@ const (
)

type Token struct {
chain *Chain

token txbuilder.TypeTagStruct
chain *Chain
}

func NewMainToken(chain *Chain) *Token {
Expand All @@ -34,7 +33,7 @@ func NewToken(chain *Chain, tag string) (*Token, error) {
if err != nil {
return nil, err
}
return &Token{chain, *token}, nil
return &Token{*token, chain}, nil
}

// MARK - Implement the protocol Token
Expand All @@ -59,9 +58,9 @@ func (t *Token) TokenInfo() (*base.TokenInfo, error) {
return nil, err
}
info := struct {
Decimals int16 `json:"decimals"`
Name string `json:"name"`
Symbol string `json:"symbol"`
Decimals int16 `json:"decimals"`
}{}
err = json.Unmarshal(jsonData, &info)
if err != nil {
Expand Down
13 changes: 7 additions & 6 deletions core/base/nft.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@ import (
)

type NFT struct {
Timestamp int64 `json:"timestamp"`
Timestamp int64 `json:"timestamp"`

// Aptos token's largest_property_version
AptTokenVersion int64 `json:"apt_token_version"`
// Aptos token's amount
AptAmount int64 `json:"apt_amount"`

HashString string `json:"hashString"`

Id string `json:"id"`
Expand All @@ -22,11 +28,6 @@ type NFT struct {
ContractAddress string `json:"contract_address"`

RelatedUrl string `json:"related_url"`

// Aptos token's largest_property_version
AptTokenVersion int64 `json:"apt_token_version"`
// Aptos token's amount
AptAmount int64 `json:"apt_amount"`
}

func (n *NFT) GroupName() string {
Expand Down
6 changes: 3 additions & 3 deletions core/base/reach_monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import (
const reachFailedTime int64 = -1

type RpcLatency struct {
RpcUrl string `json:"rpcUrl"`
Latency int64 `json:"latency"`
Height int64 `json:"height"`
RpcUrl string `json:"rpcUrl"`
}

// You can customize the test latency method of rpc
Expand All @@ -31,12 +31,12 @@ type ReachMonitorDelegate interface {
}

type ReachMonitor struct {
// The number of network connectivity tests to be performed per rpc. 0 means infinite, default is 1
ReachCount int
// Timeout for each connectivity test (ms). default 20000ms
Timeout int64
// Time interval between two network connectivity tests (ms). default 1500ms
Delay int64
// The number of network connectivity tests to be performed per rpc. 0 means infinite, default is 1
ReachCount int

reachability RpcReachability

Expand Down
7 changes: 4 additions & 3 deletions core/base/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ const (

// Transaction details that can be fetched from the chain
type TransactionDetail struct {
// transaction completion timestamp (s), 0 if Status is in Pending
FinishTimestamp int64
Status TransactionStatus

// hash string on chain
HashString string

Expand All @@ -40,9 +44,6 @@ type TransactionDetail struct {
// receiver's address
ToAddress string

Status TransactionStatus
// transaction completion timestamp (s), 0 if Status is in Pending
FinishTimestamp int64
// failure message
FailureMessage string

Expand Down
24 changes: 12 additions & 12 deletions core/btc/brc20_mint.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@ import (
)

type Brc20MintTransaction struct {
NetworkFee int64 `json:"network_fee"`
SatpointFee int64 `json:"satpoint_fee"`
ServiceFee int64 `json:"service_fee"`
CommitFee int64 `json:"commit_fee"`
CommitVsize int64 `json:"commit_vsize"`

CommitId string `json:"commit_id"`
Commit string `json:"commit"`
Reveal *base.StringArray `json:"reveal"`
Inscription *base.StringArray `json:"inscription"`

CommitCustom *Brc20CommitCustom `json:"commit_custom"`

NetworkFee int64 `json:"network_fee"`
SatpointFee int64 `json:"satpoint_fee"`
ServiceFee int64 `json:"service_fee"`
CommitFee int64 `json:"commit_fee"`
CommitVsize int64 `json:"commit_vsize"`

signedTxn *SignedPsbtTransaction
}

Expand Down Expand Up @@ -159,18 +159,18 @@ func (c *Chain) BuildBrc20MintWithPostage(sender, receiver string, op, ticker, a
}

var r struct {
NetworkFee int64 `json:"network_fee"`
SatpointFee int64 `json:"satpoint_fee"`
ServiceFee int64 `json:"service_fee"`
CommitFee int64 `json:"commit_fee"`
CommitVsize int64 `json:"commit_vsize"`

CommitId string `json:"commit_id"`
CommitPsbt string `json:"commit_psbt"`
RevealTxs *base.StringArray `json:"reveal_txs"`
RevealIds *base.StringArray `json:"reveal_ids"`

CommitCustom *Brc20CommitCustom `json:"commit_custom"`

NetworkFee int64 `json:"network_fee"`
SatpointFee int64 `json:"satpoint_fee"`
ServiceFee int64 `json:"service_fee"`
CommitFee int64 `json:"commit_fee"`
CommitVsize int64 `json:"commit_vsize"`
}
err = json.Unmarshal(resp.Body, &r)
if err != nil {
Expand Down
48 changes: 24 additions & 24 deletions core/btc/brc20_token.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,30 +98,30 @@ func (t *Brc20Token) FullTokenInfo() (info *Brc20TokenInfo, err error) {
}

type Brc20TokenInfo struct {
Ticker string `json:"ticker"`
HoldersCount int64 `json:"holdersCount"`
HistoryCount int64 `json:"historyCount"`
InscriptionNumber int64 `json:"inscriptionNumber"`
InscriptionId string `json:"inscriptionId"`
Max string `json:"max"`
Limit string `json:"limit"`
Minted string `json:"minted"`
TotalMinted string `json:"totalMinted"`
ConfirmedMinted string `json:"confirmedMinted"`
ConfirmedMinted1h string `json:"confirmedMinted1H"`
ConfirmedMinted24h string `json:"confirmedMinted24H"`
MintTimes int64 `json:"mintTimes"`
Decimal int16 `json:"decimal"`
Creator string `json:"creator"`
Txid string `json:"txid"`
DeployHeight int64 `json:"deployHeight"`
DeployBlocktime int64 `json:"deployBlocktime"`
CompleteHeight int64 `json:"completeHeight"`
CompleteBlocktime int64 `json:"completeBlocktime"`
InscriptionNumberStart int64 `json:"inscriptionNumberStart"`
InscriptionNumberEnd int64 `json:"inscriptionNumberEnd"`

Price float64 `json:"price"`
Price float64 `json:"price"`
HoldersCount int64 `json:"holdersCount"`
HistoryCount int64 `json:"historyCount"`
InscriptionNumber int64 `json:"inscriptionNumber"`
MintTimes int64 `json:"mintTimes"`
DeployHeight int64 `json:"deployHeight"`
DeployBlocktime int64 `json:"deployBlocktime"`
CompleteHeight int64 `json:"completeHeight"`
CompleteBlocktime int64 `json:"completeBlocktime"`
InscriptionNumberStart int64 `json:"inscriptionNumberStart"`
InscriptionNumberEnd int64 `json:"inscriptionNumberEnd"`

Ticker string `json:"ticker"`
InscriptionId string `json:"inscriptionId"`
Max string `json:"max"`
Limit string `json:"limit"`
Minted string `json:"minted"`
TotalMinted string `json:"totalMinted"`
ConfirmedMinted string `json:"confirmedMinted"`
ConfirmedMinted1h string `json:"confirmedMinted1H"`
ConfirmedMinted24h string `json:"confirmedMinted24H"`
Decimal int16 `json:"decimal"`
Creator string `json:"creator"`
Txid string `json:"txid"`
}

func (j *Brc20TokenInfo) JsonString() (*base.OptionalString, error) {
Expand Down
10 changes: 5 additions & 5 deletions core/btc/brc20_transfer.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ import (
)

type Brc20TransferTransaction struct {
Transaction string `json:"transaction"`
NetworkFee int64 `json:"network_fee"`
CommitId string `json:"commit_id"`
CommitFee int64 `json:"commit_fee"`
CommitVsize int64 `json:"commit_vsize"`
Transaction string `json:"transaction"`
CommitId string `json:"commit_id"`

CommitCustom *Brc20CommitCustom `json:"commit_custom"`
}
Expand Down Expand Up @@ -82,12 +82,12 @@ func (c *Chain) BuildBrc20TransferTransaction(
}

var r struct {
Commit_id string `json:"commit_id"`
Commit_psbt string `json:"commit_psbt"`
Commit_fee int64 `json:"commit_fee"`
Commit_vsize int64 `json:"commit_vsize"`
Commit_custom *Brc20CommitCustom `json:"commit_custom"`
Network_fee int64 `json:"network_fee"`
Commit_id string `json:"commit_id"`
Commit_psbt string `json:"commit_psbt"`
Commit_custom *Brc20CommitCustom `json:"commit_custom"`
}
err = json.Unmarshal(resp.Body, &r)
if err != nil {
Expand Down
12 changes: 6 additions & 6 deletions core/btc/brc20_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,16 @@ type rawBrc20TokenBalancePage struct {
// - MARK -

type Brc20Inscription struct {
InscriptionId string `json:"inscriptionId"`
InscriptionNumber int64 `json:"inscriptionNumber"`
Address string `json:"address"`
OutputValue int64 `json:"outputValue"`
ContentLength int64 `json:"contentLength"`
Timestamp int64 `json:"timestamp"`
InscriptionId string `json:"inscriptionId"`
Address string `json:"address"`
Preview string `json:"preview"`
Content string `json:"content"`
ContentLength int64 `json:"contentLength"`
ContentType string `json:"contentType"`
ContentBody string `json:"contentBody"`
Timestamp int64 `json:"timestamp"`
GenesisTransaction string `json:"genesisTransaction"`
Location string `json:"location"`
Output string `json:"output"`
Expand Down Expand Up @@ -141,8 +141,8 @@ func (bp *Brc20InscriptionPage) AsNFTPage() *NFTPage {
}

type Brc20TransferableInscription struct {
InscriptionId string `json:"inscriptionId"`
InscriptionNumber int64 `json:"inscriptionNumber"`
InscriptionId string `json:"inscriptionId"`
Amount string `json:"amount"`
Ticker string `json:"ticker"`
Unconfirmed bool `json:"unconfirmed,omitempty"`
Expand Down Expand Up @@ -174,8 +174,8 @@ type unisatTokenSummary struct {
}

type Brc20UTXO struct {
Txid string `json:"txid"`
Index int64 `json:"index"`
Txid string `json:"txid"`
}

func NewBrc20UTXO(txid string, index int64) *Brc20UTXO {
Expand Down
5 changes: 2 additions & 3 deletions core/btc/transaction_decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@ import (
)

type TxOut struct {
Hash string `json:"hash,omitempty"`
Index int64 `json:"index,omitempty"`

Value int64 `json:"value,omitempty"`
Index int64 `json:"index,omitempty"`
Hash string `json:"hash,omitempty"`
Address string `json:"address,omitempty"`
}

Expand Down
2 changes: 1 addition & 1 deletion core/cosmos/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
)

type Account struct {
privKey types.PrivKey
Cointype int64
privKey types.PrivKey
AddressPrefix string
}

Expand Down
2 changes: 1 addition & 1 deletion core/doge/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ type TransactionOutput struct {

type Transaction struct {
// Demo: https://api.blockcypher.com/v1/doge/main/txs/7bc313903372776e1eb81d321e3fe27c9721ce8e71a9bcfee1bde6baea31b5c2
Confirmations int64 `json:"confirmations"`
HashString string `json:"hash"`
Total *big.Int `json:"total"`
Fees *big.Int `json:"fees"`
Received *time.Time `json:"received"`
Confirmed *time.Time `json:"confirmed"`
Confirmations int64 `json:"confirmations"`
Inputs []*TransactionInput `json:"inputs"`
Outputs []*TransactionOutput `json:"outputs"`
OpReturn string `json:"data_protocol"`
Expand Down
2 changes: 1 addition & 1 deletion core/eth/ethchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
)

type EthChain struct {
RemoteRpcClient *ethclient.Client
timeout time.Duration
RemoteRpcClient *ethclient.Client
chainId *big.Int
rpcUrl string
}
Expand Down
6 changes: 3 additions & 3 deletions core/eth/ethchain_zksync.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,22 @@ const zksync_chainid = 324
const zksync_chainid_testnet = 280

type zksync_Transaction struct {
Gas hexutil.Uint64 `json:"gas"`
Nonce hexutil.Uint64 `json:"nonce"`
TxType hexutil.Uint64 `json:"type"`
BlockHash common.Hash `json:"blockHash"`
BlockNumber *hexutil.Big `json:"blockNumber"`
ChainID hexutil.Big `json:"chainId"`
From common.Address `json:"from"`
Gas hexutil.Uint64 `json:"gas"`
GasPrice hexutil.Big `json:"gasPrice"`
Hash common.Hash `json:"hash"`
Data hexutil.Bytes `json:"input"`
L1BatchNumber hexutil.Big `json:"l1BatchNumber"`
L1BatchTxIndex hexutil.Big `json:"l1BatchTxIndex"`
MaxFeePerGas hexutil.Big `json:"maxFeePerGas"`
MaxPriorityFeePerGas hexutil.Big `json:"maxPriorityFeePerGas"`
Nonce hexutil.Uint64 `json:"nonce"`
To common.Address `json:"to"`
TransactionIndex hexutil.Uint `json:"transactionIndex"`
TxType hexutil.Uint64 `json:"type"`
Value hexutil.Big `json:"value"`
V hexutil.Big `json:"v"`
R hexutil.Big `json:"r"`
Expand Down
Loading

0 comments on commit efca372

Please sign in to comment.