diff --git a/integration-tests/common/gauntlet_common.go b/integration-tests/common/gauntlet_common.go deleted file mode 100644 index 6d3b5255..00000000 --- a/integration-tests/common/gauntlet_common.go +++ /dev/null @@ -1,165 +0,0 @@ -package common - -import ( - "encoding/json" - "errors" - "fmt" - "github.com/smartcontractkit/chainlink-starknet/integration-tests/utils" - "os" -) - -func (m *OCRv2TestState) fundNodes() ([]string, error) { - l := utils.GetTestLogger(m.TestConfig.T) - var nAccounts []string - for _, key := range m.GetNodeKeys() { - if key.TXKey.Data.Attributes.StarkKey == "" { - return nil, errors.New("stark key can't be empty") - } - //nAccount, err := m.Clients.GauntletClient.DeployAccountContract(100, key.TXKey.Data.Attributes.StarkKey) - nAccount, err := m.Clients.GauntletPPClient.DeployOzAccount(key.TXKey.Data.Attributes.StarkKey) - if err != nil { - return nil, err - } - nAccounts = append(nAccounts, nAccount) - } - - if *m.Common.TestConfig.Common.Network == "testnet" { - for _, key := range nAccounts { - // We are not deploying in parallel here due to testnet limitations (429 too many requests) - l.Debug().Msg(fmt.Sprintf("Funding node with address: %s", key)) - //_, err := m.Clients.GauntletClient.TransferToken(m.Common.ChainDetails.StarkTokenAddress, key, "10000000000000000000") // Transferring 10 STRK to each node - err := m.Clients.GauntletPPClient.TransferToken(m.Common.ChainDetails.StarkTokenAddress, key, "10000000000000000000") - if err != nil { - return nil, err - } - } - } else { - // The starknet provided mint method does not work so we send a req directly - for _, key := range nAccounts { - res, err := m.TestConfig.Resty.R().SetBody(map[string]any{ - "address": key, - "amount": 900000000000000000, - }).Post("/mint") - if err != nil { - return nil, err - } - l.Info().Msg(fmt.Sprintf("Funding account (WEI): %s", string(res.Body()))) - res, err = m.TestConfig.Resty.R().SetBody(map[string]any{ - "address": key, - "amount": 900000000000000000, - "unit": m.Common.ChainDetails.TokenName, - }).Post("/mint") - if err != nil { - return nil, err - } - l.Info().Msg(fmt.Sprintf("Funding account (FRI): %s", string(res.Body()))) - } - } - - return nAccounts, nil -} - -func (m *OCRv2TestState) deployLinkToken() error { - var err error - m.Contracts.LinkTokenAddr, err = m.Clients.GauntletClient.DeployLinkTokenContract() - if err != nil { - return err - } - err = os.Setenv("LINK", m.Contracts.LinkTokenAddr) - if err != nil { - return err - } - return nil -} - -func (m *OCRv2TestState) deployAccessController() error { - var err error - m.Contracts.AccessControllerAddr, err = m.Clients.GauntletClient.DeployAccessControllerContract() - if err != nil { - return err - } - err = os.Setenv("BILLING_ACCESS_CONTROLLER", m.Contracts.AccessControllerAddr) - if err != nil { - return err - } - return nil -} - -func (m *OCRv2TestState) setConfigDetails(ocrAddress string) error { - cfg, err := m.LoadOCR2Config() - if err != nil { - return err - } - var parsedConfig []byte - parsedConfig, err = json.Marshal(cfg) - if err != nil { - return err - } - _, err = m.Clients.GauntletClient.SetConfigDetails(string(parsedConfig), ocrAddress) - return err -} - -func (m *OCRv2TestState) DeployGauntlet(minSubmissionValue int64, maxSubmissionValue int64, decimals int, name string, observationPaymentGjuels int64, transmissionPaymentGjuels int64) error { - err := m.Clients.GauntletClient.InstallDependencies() - if err != nil { - return err - } - - m.Clients.ChainlinkClient.AccountAddresses, err = m.fundNodes() - if err != nil { - return err - } - - err = m.deployLinkTokenWithGpp() - if err != nil { - return err - } - - err = m.deployAccessControllerWithGpp() - if err != nil { - return err - } - // m.Contracts.OCRAddr, err = m.Clients.GauntletClient.DeployOCR2ControllerContract(minSubmissionValue, maxSubmissionValue, decimals, name, m.Contracts.LinkTokenAddr) - // if err != nil { - // return err - // } - - m.Contracts.OCRAddr, err = m.Clients.GauntletPPClient.DeployOCR2ControllerContract(minSubmissionValue, maxSubmissionValue, decimals, name, - m.Contracts.LinkTokenAddr, m.Account.Account, m.Contracts.AccessControllerAddr) - if err != nil { - return err - } - - // m.Contracts.ProxyAddr, err = m.Clients.GauntletClient.DeployOCR2ProxyContract(m.Contracts.OCRAddr) - // if err != nil { - // return err - // } - - m.Contracts.ProxyAddr, err = m.Clients.GauntletPPClient.DeployOCR2ControllerProxyContract(m.Account.Account, m.Contracts.OCRAddr) - if err != nil { - return err - } - - // _, err = m.Clients.GauntletClient.AddAccess(m.Contracts.OCRAddr, m.Contracts.ProxyAddr) - // if err != nil { - // return err - // } - - err = m.Clients.GauntletPPClient.AddAccess(m.Contracts.OCRAddr, m.Contracts.ProxyAddr) - if err != nil { - return err - } - - _, err = m.Clients.GauntletClient.MintLinkToken(m.Contracts.LinkTokenAddr, m.Contracts.OCRAddr, "100000000000000000000") - if err != nil { - return err - } - - _, err = m.Clients.GauntletPPClient.SetOCRBilling(observationPaymentGjuels, transmissionPaymentGjuels, m.Contracts.OCRAddr) - if err != nil { - return err - } - - err = m.setConfigDetails(m.Contracts.OCRAddr) - return err -} diff --git a/ops/gauntlet/gauntlet_starknet.go b/ops/gauntlet/gauntlet_starknet.go index ee0145ec..dfb27cb9 100644 --- a/ops/gauntlet/gauntlet_starknet.go +++ b/ops/gauntlet/gauntlet_starknet.go @@ -94,30 +94,6 @@ func (sg *StarknetGauntlet) InstallDependencies() error { return nil } -func (sg *StarknetGauntlet) DeployAccountContract(salt int64, pubKey string) (string, error) { - _, err := sg.G.ExecCommand([]string{"account:deploy", fmt.Sprintf("--salt=%d", salt), fmt.Sprintf("--publicKey=%s", pubKey)}, *sg.options) - if err != nil { - return "", err - } - sg.gr, err = sg.FetchGauntletJSONOutput() - if err != nil { - return "", err - } - return sg.gr.Responses[0].Contract, nil -} - -func (sg *StarknetGauntlet) DeployLinkTokenContract() (string, error) { - _, err := sg.G.ExecCommand([]string{"token:deploy", "--link"}, *sg.options) - if err != nil { - return "", err - } - sg.gr, err = sg.FetchGauntletJSONOutput() - if err != nil { - return "", err - } - return sg.gr.Responses[0].Contract, nil -} - func (sg *StarknetGauntlet) MintLinkToken(token, to, amount string) (string, error) { _, err := sg.G.ExecCommand([]string{"token:mint", fmt.Sprintf("--recipient=%s", to), fmt.Sprintf("--amount=%s", amount), token}, *sg.options) if err != nil { @@ -129,87 +105,3 @@ func (sg *StarknetGauntlet) MintLinkToken(token, to, amount string) (string, err } return sg.gr.Responses[0].Contract, nil } - -func (sg *StarknetGauntlet) TransferToken(token, to, amount string) (string, error) { - _, err := sg.G.ExecCommand([]string{"token:transfer", fmt.Sprintf("--recipient=%s", to), fmt.Sprintf("--amount=%s", amount), token}, *sg.options) - if err != nil { - return "", err - } - sg.gr, err = sg.FetchGauntletJSONOutput() - if err != nil { - return "", err - } - return sg.gr.Responses[0].Contract, nil -} - -func (sg *StarknetGauntlet) DeployOCR2ControllerContract(minSubmissionValue int64, maxSubmissionValue int64, decimals int, name string, linkTokenAddress string) (string, error) { - _, err := sg.G.ExecCommand([]string{"ocr2:deploy", fmt.Sprintf("--minSubmissionValue=%d", minSubmissionValue), fmt.Sprintf("--maxSubmissionValue=%d", maxSubmissionValue), fmt.Sprintf("--decimals=%d", decimals), fmt.Sprintf("--name=%s", name), fmt.Sprintf("--link=%s", linkTokenAddress)}, *sg.options) - if err != nil { - return "", err - } - sg.gr, err = sg.FetchGauntletJSONOutput() - if err != nil { - return "", err - } - return sg.gr.Responses[0].Contract, nil -} - -func (sg *StarknetGauntlet) DeployAccessControllerContract() (string, error) { - _, err := sg.G.ExecCommand([]string{"access_controller:deploy"}, *sg.options) - if err != nil { - return "", err - } - sg.gr, err = sg.FetchGauntletJSONOutput() - if err != nil { - return "", err - } - return sg.gr.Responses[0].Contract, nil -} - -func (sg *StarknetGauntlet) DeployOCR2ProxyContract(aggregator string) (string, error) { - _, err := sg.G.ExecCommand([]string{"proxy:deploy", fmt.Sprintf("--address=%s", aggregator)}, *sg.options) - if err != nil { - return "", err - } - sg.gr, err = sg.FetchGauntletJSONOutput() - if err != nil { - return "", err - } - return sg.gr.Responses[0].Contract, nil -} - -func (sg *StarknetGauntlet) SetOCRBilling(observationPaymentGjuels int64, transmissionPaymentGjuels int64, ocrAddress string) (string, error) { - _, err := sg.G.ExecCommand([]string{"ocr2:set_billing", fmt.Sprintf("--observationPaymentGjuels=%d", observationPaymentGjuels), fmt.Sprintf("--transmissionPaymentGjuels=%d", transmissionPaymentGjuels), ocrAddress}, *sg.options) - if err != nil { - return "", err - } - sg.gr, err = sg.FetchGauntletJSONOutput() - if err != nil { - return "", err - } - return sg.gr.Responses[0].Contract, nil -} - -func (sg *StarknetGauntlet) SetConfigDetails(cfg string, ocrAddress string) (string, error) { - _, err := sg.G.ExecCommand([]string{"ocr2:set_config", "--input=" + cfg, ocrAddress}, *sg.options) - if err != nil { - return "", err - } - sg.gr, err = sg.FetchGauntletJSONOutput() - if err != nil { - return "", err - } - return sg.gr.Responses[0].Contract, nil -} - -func (sg *StarknetGauntlet) AddAccess(aggregator, address string) (string, error) { - _, err := sg.G.ExecCommand([]string{"ocr2:add_access", fmt.Sprintf("--address=%s", address), aggregator}, *sg.options) - if err != nil { - return "", err - } - sg.gr, err = sg.FetchGauntletJSONOutput() - if err != nil { - return "", err - } - return sg.gr.Responses[0].Contract, nil -}