Skip to content

Commit

Permalink
test - declareTxnHashV3 works
Browse files Browse the repository at this point in the history
rianhughes committed Nov 22, 2023
1 parent 47143bf commit cb84d2e
Showing 3 changed files with 10 additions and 15 deletions.
14 changes: 6 additions & 8 deletions account/account.go
Original file line number Diff line number Diff line change
@@ -437,21 +437,19 @@ func (account *Account) TransactionHashDeclare(tx rpc.DeclareTxnType) (*felt.Fel
return nil, err
}

return hash.CalculateTransactionHashCommon(
return crypto.PoseidonArray(
PREFIX_DECLARE,
txnVersionFelt,
txn.SenderAddress,
tipAndResourcesHash(txn.Tip.Impl().Uint64(), txn.ResourceBounds),
crypto.PoseidonArray(txn.PayMasterData...),
account.ChainId,
txn.Nonce,
[]*felt.Felt{
new(felt.Felt).SetUint64(DAUint64),
crypto.PoseidonArray(txn.AccountDeploymentData...),
crypto.PoseidonArray(txn.ClassHash),
crypto.PoseidonArray(txn.CompiledClassHash),
},
)
new(felt.Felt).SetUint64(DAUint64),
crypto.PoseidonArray(txn.AccountDeploymentData...),
txn.ClassHash,
txn.CompiledClassHash,
), nil
}

return nil, ErrTxnTypeUnSupported
5 changes: 1 addition & 4 deletions account/account_test.go
Original file line number Diff line number Diff line change
@@ -874,17 +874,15 @@ func TestTransactionHashDeclare(t *testing.T) {
}

func TestTransactionHashDeclareINTEGRATION(t *testing.T) {

if testEnv != "integration" {
t.Skip("Skipping test as it requires a integration environment")
}
mockCtrl := gomock.NewController(t)
t.Cleanup(mockCtrl.Finish)
mockRpcProvider := mocks.NewMockRpcProvider(mockCtrl)
mockRpcProvider.EXPECT().ChainID(context.Background()).Return("SN_MAIN", nil)
mockRpcProvider.EXPECT().ChainID(context.Background()).Return("SN_GOERLI", nil)

acnt, err := account.NewAccount(mockRpcProvider, &felt.Zero, "", account.NewMemKeystore())
fmt.Println("acnt", acnt.ChainId)
require.NoError(t, err)

type testSetType struct {
@@ -895,7 +893,6 @@ func TestTransactionHashDeclareINTEGRATION(t *testing.T) {
testSet := map[string][]testSetType{
"integration": {
{
// Techincally this is for integration, not goerli. But should be fine.
// https://external.integration.starknet.io/feeder_gateway/get_transaction?transactionHash=0x41d1f5206ef58a443e7d3d1ca073171ec25fa75313394318fc83a074a6631c3
Txn: rpc.DeclareTxnV3{
Nonce: utils.TestHexToFelt(t, "0x1"),
6 changes: 3 additions & 3 deletions rpc/types_transaction.go
Original file line number Diff line number Diff line change
@@ -156,8 +156,8 @@ func (da *DAMode) UInt64() (uint64, error) {
type Resource string

const (
ResourceL1Gas Resource = "L1_Gas"
ResourceL2Gas Resource = "L2_Gas"
ResourceL1Gas Resource = "L1_GAS"
ResourceL2Gas Resource = "L2_GAS"
)

type ResourceBounds struct {
@@ -339,7 +339,7 @@ const (
TransactionV1Variant TransactionVersion = "0x100000000000000000000000000000001"
TransactionV2 TransactionVersion = "0x2"
TransactionV2Variant TransactionVersion = "0x100000000000000000000000000000002"
TransactionV3 TransactionVersion = "0x2"
TransactionV3 TransactionVersion = "0x3"
TransactionV3Variant TransactionVersion = "0x100000000000000000000000000000003"
)

0 comments on commit cb84d2e

Please sign in to comment.