Skip to content

Commit

Permalink
working stom changes (#361)
Browse files Browse the repository at this point in the history
Co-authored-by: Blaž Hrastnik <[email protected]>
  • Loading branch information
augustbleeds and archseer authored Feb 27, 2024
1 parent a8374fc commit 4c6911c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
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

0 comments on commit 4c6911c

Please sign in to comment.