Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BCI-2588: Changes for STOM #361

Merged
merged 2 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ golangci-lint 1.55.0
actionlint 1.6.12
shellcheck 0.8.0
scarb 2.5.4
postgres 13.3
postgres 15.1

# Kubernetes
k3d 5.4.4
Expand Down
6 changes: 3 additions & 3 deletions monitoring/pkg/monitoring/source_envelope.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,14 +168,14 @@ var zeroBigInt = big.NewInt(0)
func (s *envelopeSource) fetchLinkBalance(ctx context.Context, linkTokenAddress, contractAddress *felt.Felt) (*big.Int, error) {
results, err := s.ocr2Reader.BaseReader().CallContract(ctx, starknet.CallOps{
ContractAddress: linkTokenAddress,
Selector: starknetutils.GetSelectorFromNameFelt("balanceOf"),
Selector: starknetutils.GetSelectorFromNameFelt("balance_of"),
Calldata: []*felt.Felt{contractAddress},
})
if err != nil {
return nil, fmt.Errorf("failed call to ECR20 contract, balanceOf method: %w", err)
return nil, fmt.Errorf("failed call to ECR20 contract, balance_of method: %w", err)
}
if len(results) < 1 {
return nil, fmt.Errorf("insufficient data from balanceOf '%v': %w", results, err)
return nil, fmt.Errorf("insufficient data from balance_of '%v': %w", results, err)
}
linkBalance := results[0].BigInt(big.NewInt(0))
if linkBalance.Cmp(zeroBigInt) == 0 {
Expand Down
2 changes: 1 addition & 1 deletion monitoring/pkg/monitoring/source_envelope_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func TestEnvelopeSource(t *testing.T) {
mock.Anything, // ctx
starknet.CallOps{
ContractAddress: chainConfig.GetLinkTokenAddress(),
Selector: "balanceOf",
Selector: "balance_of",
Calldata: []string{
starknetutils.HexToBN(feedConfig.ContractAddress).String(),
},
Expand Down
11 changes: 9 additions & 2 deletions relayer/pkg/chainlink/ocr2/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,17 @@ func (c *Client) LinkAvailableForPayment(ctx context.Context, address *felt.Felt
if err != nil {
return nil, errors.Wrap(err, "failed to call the contract with selector 'link_available_for_payment'")
}
if len(results) != 1 {
if len(results) != 2 {
return nil, errors.Wrap(err, "insufficient data from selector 'link_available_for_payment'")
}
return results[0].BigInt(big.NewInt(0)), nil

isNegative := !results[0].IsZero()
ans := results[1].BigInt(big.NewInt(0))
if isNegative {
ans.Neg(ans)
}

return ans, nil
}

func (c *Client) fetchEventsFromBlock(ctx context.Context, address *felt.Felt, eventType string, blockNum uint64) (eventsAsFeltArrs [][]*felt.Felt, err error) {
Expand Down
Loading