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

Nonce return type #453

Merged
merged 4 commits into from
Oct 30, 2023
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
15 changes: 7 additions & 8 deletions account/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -604,17 +604,16 @@ func (account *Account) Events(ctx context.Context, input rpc.EventsInput) (*rpc
return account.provider.Events(ctx, input)
}

// Nonce returns the nonce for the specified account and contract address.
// Nonce retrieves the nonce for a given block ID and contract address.
//
// Parameters:
// - ctx: The context.Context object for the function
// - blockID: the rpc.BlockID object for the function
// - contractAddress: the felt.Felt (address of the contract) whose nonce we're seeking
//
// - ctx: is the context.Context for the function call
// - blockID: is the ID of the block
// - contractAddress: is the address of the contract
// Returns:
// - *string: a string pointer
// - error: an error
func (account *Account) Nonce(ctx context.Context, blockID rpc.BlockID, contractAddress *felt.Felt) (*string, error) {
// - *felt.Felt: the contract's nonce at the requested state
// - error: an error if any
func (account *Account) Nonce(ctx context.Context, blockID rpc.BlockID, contractAddress *felt.Felt) (*felt.Felt, error) {
return account.provider.Nonce(ctx, blockID, contractAddress)
}

Expand Down
2 changes: 1 addition & 1 deletion account/account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -932,7 +932,7 @@ func TestAddDeclareTxn(t *testing.T) {
require.NoError(t, err)

tx := rpc.DeclareTxnV2{
Nonce: utils.TestHexToFelt(t, *nonce),
Nonce: nonce,
MaxFee: utils.TestHexToFelt(t, "0x50c8f3053db"),
Type: rpc.TransactionType_Declare,
Version: rpc.TransactionV2,
Expand Down
5 changes: 2 additions & 3 deletions examples/simpleInvoke/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,8 @@ func main() {
panic(err.Error())
}

//Getting the nonce from the account, and then converting it into felt
nonce_string, _ := accnt.Nonce(context.Background(), rpc.BlockID{Tag: "latest"}, accnt.AccountAddress)
nonce, err := utils.HexToFelt(*nonce_string)
//Getting the nonce from the account
nonce, err := accnt.Nonce(context.Background(), rpc.BlockID{Tag: "latest"}, accnt.AccountAddress)
if err != nil {
panic(err.Error())
}
Expand Down
17 changes: 3 additions & 14 deletions mocks/mock_account.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading