add back code that language server still uses
@@ -320,6 +320,22 @@ func (a *Accounts) AddContract(
return a.addContract(account, contractName, contractFilename, updateExisting)
}
+// AddContractForAddress adds a new contract to an address using private key specified
+func (a *Accounts) AddContractForAddress(
+ accountAddress string,
+ accountPrivateKey string,
+ contractName string,
+ contractFilename string,
+ updateExisting bool,
+) (*flow.Account, error) {
+ account, err := accountFromAddressAndKey(accountAddress, accountPrivateKey)
+ if err != nil {
+ return nil, err
+ }
+
+ return a.addContract(account, contractName, contractFilename, updateExisting)
+}
+
func (a *Accounts) addContract(
account *project.Account,
contractName string,
@@ -439,3 +455,16 @@ func (a *Accounts) RemoveContract(
return a.gateway.GetAccount(account.Address())
}
+
+// AccountFromAddressAndKey get account from address and private key
+func accountFromAddressAndKey(address string, accountPrivateKey string) (*project.Account, error) {
+ privateKey, err := crypto.DecodePrivateKeyHex(crypto.ECDSA_P256, accountPrivateKey)
+ if err != nil {
+ return nil, fmt.Errorf("private key is not correct")
+ }
+
+ return project.AccountFromAddressAndKey(
+ flow.HexToAddress(address),
+ privateKey,
+ ), nil
+}
