From 3545713fe7dcac6c1b27787e70297c3cd36e127c Mon Sep 17 00:00:00 2001 From: hopeyen Date: Wed, 16 Oct 2024 10:18:54 -0700 Subject: [PATCH] refactor: update TableExists name and TokenAmount type --- common/aws/dynamodb/client.go | 4 ++-- core/data.go | 8 +++++++- core/meterer/offchain_store.go | 6 +++--- core/meterer/onchain_state_test.go | 2 +- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/common/aws/dynamodb/client.go b/common/aws/dynamodb/client.go index 5c62089520..53587495df 100644 --- a/common/aws/dynamodb/client.go +++ b/common/aws/dynamodb/client.go @@ -410,8 +410,8 @@ func (c *Client) readItems(ctx context.Context, tableName string, keys []Key) ([ return items, nil } -// TableCheck checks if a table exists and can be described -func (c *Client) TableCheck(ctx context.Context, name string) error { +// TableExists checks if a table exists and can be described +func (c *Client) TableExists(ctx context.Context, name string) error { if name == "" { return errors.New("table name is empty") } diff --git a/core/data.go b/core/data.go index 96593ffd18..91c4141734 100644 --- a/core/data.go +++ b/core/data.go @@ -4,6 +4,7 @@ import ( "encoding/binary" "errors" "fmt" + "math/big" "github.com/Layr-Labs/eigenda/common" "github.com/Layr-Labs/eigenda/encoding" @@ -502,7 +503,12 @@ func (pm *PaymentMetadata) Hash() []byte { return crypto.Keccak256(data) } -type TokenAmount uint64 // TODO: change to uint128 +type TokenAmount big.Int + +// Add this new function +func NewTokenAmount(amount uint64) TokenAmount { + return TokenAmount(*big.NewInt(int64(amount))) +} // OperatorInfo contains information about an operator which is stored on the blockchain state, // corresponding to a particular quorum diff --git a/core/meterer/offchain_store.go b/core/meterer/offchain_store.go index 52df410d06..d253a1b7e2 100644 --- a/core/meterer/offchain_store.go +++ b/core/meterer/offchain_store.go @@ -36,15 +36,15 @@ func NewOffchainStore( return OffchainStore{}, err } - err = dynamoClient.TableCheck(context.Background(), reservationTableName) + err = dynamoClient.TableExists(context.Background(), reservationTableName) if err != nil { return OffchainStore{}, err } - err = dynamoClient.TableCheck(context.Background(), onDemandTableName) + err = dynamoClient.TableExists(context.Background(), onDemandTableName) if err != nil { return OffchainStore{}, err } - err = dynamoClient.TableCheck(context.Background(), globalBinTableName) + err = dynamoClient.TableExists(context.Background(), globalBinTableName) if err != nil { return OffchainStore{}, err } diff --git a/core/meterer/onchain_state_test.go b/core/meterer/onchain_state_test.go index d866474b68..525056ed4c 100644 --- a/core/meterer/onchain_state_test.go +++ b/core/meterer/onchain_state_test.go @@ -20,7 +20,7 @@ var ( QuorumSplit: []byte{50, 50}, } dummyOnDemandPayment = core.OnDemandPayment{ - CumulativePayment: core.TokenAmount(1000), + CumulativePayment: core.NewTokenAmount(1000), } )