forked from zksync-sdk/zksync-go
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b12eac1
commit 9510ee6
Showing
11 changed files
with
354 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
package zksync | ||
|
||
import ( | ||
"encoding/hex" | ||
"github.com/ethereum/go-ethereum/common" | ||
) | ||
|
||
type ChangePubKey struct { | ||
Type string `json:"type"` | ||
AccountId uint32 `json:"accountId"` | ||
Account common.Address `json:"account"` | ||
NewPkHash string `json:"newPkHash"` | ||
FeeToken uint32 `json:"feeToken"` | ||
Fee string `json:"fee"` | ||
Nonce uint32 `json:"nonce"` | ||
Signature *Signature `json:"signature"` | ||
EthAuthData ChangePubKeyVariant `json:"ethAuthData"` | ||
*TimeRange | ||
} | ||
|
||
func (t *ChangePubKey) getType() string { | ||
return "ChangePubKey" | ||
} | ||
|
||
type ChangePubKeyAuthType string | ||
|
||
const ( | ||
ChangePubKeyAuthTypeOnchain ChangePubKeyAuthType = `Onchain` | ||
ChangePubKeyAuthTypeECDSA ChangePubKeyAuthType = `ECDSA` | ||
ChangePubKeyAuthTypeCREATE2 ChangePubKeyAuthType = `CREATE2` | ||
) | ||
|
||
type ChangePubKeyVariant interface { | ||
getType() ChangePubKeyAuthType | ||
getBytes() []byte | ||
} | ||
|
||
type ChangePubKeyOnchain struct { | ||
Type ChangePubKeyAuthType `json:"type"` | ||
} | ||
|
||
func (t *ChangePubKeyOnchain) getType() ChangePubKeyAuthType { | ||
return ChangePubKeyAuthTypeOnchain | ||
} | ||
|
||
func (t *ChangePubKeyOnchain) getBytes() []byte { | ||
return make([]byte, 32) | ||
} | ||
|
||
type ChangePubKeyECDSA struct { | ||
Type ChangePubKeyAuthType `json:"type"` | ||
EthSignature string `json:"ethSignature"` | ||
BatchHash string `json:"batchHash"` | ||
} | ||
|
||
func (t *ChangePubKeyECDSA) getType() ChangePubKeyAuthType { | ||
return ChangePubKeyAuthTypeECDSA | ||
} | ||
|
||
func (t *ChangePubKeyECDSA) getBytes() []byte { | ||
res, _ := hex.DecodeString(t.BatchHash) | ||
return res | ||
} | ||
|
||
type ChangePubKeyCREATE2 struct { | ||
Type ChangePubKeyAuthType `json:"type"` | ||
CreatorAddress string `json:"creatorAddress"` | ||
SaltArg string `json:"saltArg"` | ||
CodeHash string `json:"codeHash"` | ||
} | ||
|
||
func (t *ChangePubKeyCREATE2) getType() ChangePubKeyAuthType { | ||
return ChangePubKeyAuthTypeCREATE2 | ||
} | ||
|
||
//func (t *ChangePubKeyCREATE2) getBytes() []byte { | ||
// return make([]byte, 32) | ||
//} | ||
|
||
type Signature struct { | ||
PubKey string `json:"pubKey"` | ||
Signature string `json:"signature"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.