From 6d19e12fd7db516177681244494375f89c286f8b Mon Sep 17 00:00:00 2001 From: Gkirito Date: Tue, 16 May 2023 10:46:20 +0800 Subject: [PATCH] build(mod): upgrade to v2 --- account/account.go | 4 +- account/account_test.go | 2 +- client/0_test.go | 6 +- client/bcs_test.go | 65 ++++++++------- client/client_call.go | 6 +- client/client_call_test.go | 6 +- client/client_call_unsafe_test.go | 9 ++- client/client_nft.go | 4 +- client/client_stake.go | 70 ++++++++++------ client/client_stake_test.go | 7 +- client/faucet.go | 2 +- go.mod | 2 +- move_types/language_storage.go | 2 +- sui_types/base_types.go | 4 +- sui_types/crypto.go | 4 +- sui_types/digest.go | 2 +- sui_types/dynamic_field.go | 2 +- sui_types/governance.go | 2 +- sui_types/intent.go | 2 +- sui_types/messages.go | 6 +- sui_types/object.go | 2 +- sui_types/programmable_transaction_builder.go | 4 +- .../programmable_transaction_builder_test.go | 2 +- sui_types/sui_system_state/system.go | 2 +- sui_types/transaction.go | 2 +- types/coin.go | 2 +- types/coin_test.go | 80 +++++++++++-------- types/common.go | 2 +- types/dynamic_field.go | 4 +- types/events.go | 2 +- types/move.go | 2 +- types/move_test.go | 52 +++++++----- types/objects.go | 4 +- types/response.go | 4 +- types/transactions.go | 4 +- types/types.go | 4 +- types/validator.go | 4 +- 37 files changed, 221 insertions(+), 162 deletions(-) diff --git a/account/account.go b/account/account.go index 5e64d34..bca3425 100644 --- a/account/account.go +++ b/account/account.go @@ -5,8 +5,8 @@ import ( "encoding/hex" "github.com/coming-chat/go-aptos/crypto/derivation" - "github.com/coming-chat/go-sui/lib" - "github.com/coming-chat/go-sui/sui_types" + "github.com/coming-chat/go-sui/v2/lib" + "github.com/coming-chat/go-sui/v2/sui_types" "github.com/tyler-smith/go-bip39" "golang.org/x/crypto/blake2b" ) diff --git a/account/account_test.go b/account/account_test.go index b23d4b8..6f32c1e 100644 --- a/account/account_test.go +++ b/account/account_test.go @@ -5,7 +5,7 @@ import ( "os" "testing" - "github.com/coming-chat/go-sui/sui_types" + "github.com/coming-chat/go-sui/v2/sui_types" "github.com/stretchr/testify/require" ) diff --git a/client/0_test.go b/client/0_test.go index 47723a6..7d5b1ab 100644 --- a/client/0_test.go +++ b/client/0_test.go @@ -6,11 +6,11 @@ import ( "strconv" "testing" - "github.com/coming-chat/go-sui/sui_types" - "github.com/coming-chat/go-sui/types" + "github.com/coming-chat/go-sui/v2/sui_types" + "github.com/coming-chat/go-sui/v2/types" "github.com/shopspring/decimal" - "github.com/coming-chat/go-sui/account" + "github.com/coming-chat/go-sui/v2/account" "github.com/stretchr/testify/require" ) diff --git a/client/bcs_test.go b/client/bcs_test.go index 23774fc..c07b7af 100644 --- a/client/bcs_test.go +++ b/client/bcs_test.go @@ -4,10 +4,10 @@ import ( "context" "testing" - "github.com/coming-chat/go-sui/lib" - "github.com/coming-chat/go-sui/sui_types" - "github.com/coming-chat/go-sui/sui_types/sui_system_state" - "github.com/coming-chat/go-sui/types" + "github.com/coming-chat/go-sui/v2/lib" + "github.com/coming-chat/go-sui/v2/sui_types" + "github.com/coming-chat/go-sui/v2/sui_types/sui_system_state" + "github.com/coming-chat/go-sui/v2/types" "github.com/fardream/go-bcs/bcs" "github.com/stretchr/testify/require" ) @@ -40,10 +40,12 @@ func TestBCS_TransferObject(t *testing.T) { require.NoError(t, err) // build with remote rpc - txn, err := cli.TransferObject(context.Background(), *sender, *recipient, + txn, err := cli.TransferObject( + context.Background(), *sender, *recipient, coin.CoinObjectId, &gas.CoinObjectId, - types.NewSafeSuiBigInt(gasBudget)) + types.NewSafeSuiBigInt(gasBudget), + ) require.NoError(t, err) txBytesRemote := txn.TxBytes.Data() @@ -78,9 +80,11 @@ func TestBCS_TransferSui(t *testing.T) { require.NoError(t, err) // build with remote rpc - txn, err := cli.TransferSui(context.Background(), *sender, *recipient, coin.CoinObjectId, + txn, err := cli.TransferSui( + context.Background(), *sender, *recipient, coin.CoinObjectId, types.NewSafeSuiBigInt(amount), - types.NewSafeSuiBigInt(gasBudget)) + types.NewSafeSuiBigInt(gasBudget), + ) require.NoError(t, err) txBytesRemote := txn.TxBytes.Data() @@ -160,11 +164,13 @@ func TestBCS_PayAllSui(t *testing.T) { require.NoError(t, err) // build with remote rpc - txn, err := cli.PayAllSui(context.Background(), *sender, *recipient, + txn, err := cli.PayAllSui( + context.Background(), *sender, *recipient, []suiObjectID{ coin.CoinObjectId, coin2.CoinObjectId, }, - types.NewSafeSuiBigInt(gasBudget)) + types.NewSafeSuiBigInt(gasBudget), + ) require.NoError(t, err) txBytesRemote := txn.TxBytes.Data() @@ -191,7 +197,8 @@ func TestBCS_Pay(t *testing.T) { err = ptb.Pay( []*sui_types.ObjectRef{coin.Reference()}, []suiAddress{*recipient2, *recipient2}, - []uint64{amount, amount}) + []uint64{amount, amount}, + ) require.NoError(t, err) pt := ptb.Finish() tx := sui_types.NewProgrammable( @@ -240,29 +247,33 @@ func TestBCS_MoveCall(t *testing.T) { // case 1: split target amount amtArg, err := ptb.Pure(SUI(1).Uint64()) require.NoError(t, err) - arg1 := ptb.Command(sui_types.Command{ - SplitCoins: &struct { - Argument sui_types.Argument - Arguments []sui_types.Argument - }{ - Argument: sui_types.Argument{GasCoin: &lib.EmptyEnum{}}, - Arguments: []sui_types.Argument{amtArg}, + arg1 := ptb.Command( + sui_types.Command{ + SplitCoins: &struct { + Argument sui_types.Argument + Arguments []sui_types.Argument + }{ + Argument: sui_types.Argument{GasCoin: &lib.EmptyEnum{}}, + Arguments: []sui_types.Argument{amtArg}, + }, }, - }) // the coin is split result argument + ) // the coin is split result argument arg2, err := ptb.Pure(validatorAddress) require.NoError(t, err) arg0, err := ptb.Obj(sui_types.SuiSystemMutObj) require.NoError(t, err) - ptb.Command(sui_types.Command{ - MoveCall: &sui_types.ProgrammableMoveCall{ - Package: *sui_types.SuiSystemAddress, - Module: sui_system_state.SuiSystemModuleName, - Function: sui_types.AddStakeFunName, - Arguments: []sui_types.Argument{ - arg0, arg1, arg2, + ptb.Command( + sui_types.Command{ + MoveCall: &sui_types.ProgrammableMoveCall{ + Package: *sui_types.SuiSystemAddress, + Module: sui_system_state.SuiSystemModuleName, + Function: sui_types.AddStakeFunName, + Arguments: []sui_types.Argument{ + arg0, arg1, arg2, + }, }, }, - }) + ) pt := ptb.Finish() tx := sui_types.NewProgrammable( *sender, []*sui_types.ObjectRef{ diff --git a/client/client_call.go b/client/client_call.go index bf09954..33fc008 100644 --- a/client/client_call.go +++ b/client/client_call.go @@ -4,9 +4,9 @@ import ( "context" "strings" - "github.com/coming-chat/go-sui/lib" - "github.com/coming-chat/go-sui/sui_types" - "github.com/coming-chat/go-sui/types" + "github.com/coming-chat/go-sui/v2/lib" + "github.com/coming-chat/go-sui/v2/sui_types" + "github.com/coming-chat/go-sui/v2/types" ) // NOTE: This copys the query limit from our Rust JSON RPC backend, this needs to be kept in sync! diff --git a/client/client_call_test.go b/client/client_call_test.go index a070a90..3ffaca4 100644 --- a/client/client_call_test.go +++ b/client/client_call_test.go @@ -7,10 +7,10 @@ import ( "math/big" "testing" - "github.com/coming-chat/go-sui/lib" - "github.com/coming-chat/go-sui/sui_types" + "github.com/coming-chat/go-sui/v2/lib" + "github.com/coming-chat/go-sui/v2/sui_types" - "github.com/coming-chat/go-sui/types" + "github.com/coming-chat/go-sui/v2/types" "github.com/stretchr/testify/require" ) diff --git a/client/client_call_unsafe_test.go b/client/client_call_unsafe_test.go index 93b0a3b..938b8ec 100644 --- a/client/client_call_unsafe_test.go +++ b/client/client_call_unsafe_test.go @@ -6,10 +6,10 @@ import ( "math/big" "testing" - "github.com/coming-chat/go-sui/sui_types" + "github.com/coming-chat/go-sui/v2/sui_types" - "github.com/coming-chat/go-sui/account" - "github.com/coming-chat/go-sui/types" + "github.com/coming-chat/go-sui/v2/account" + "github.com/coming-chat/go-sui/v2/types" "github.com/stretchr/testify/require" ) @@ -22,7 +22,8 @@ func TestClient_TransferObject(t *testing.T) { require.GreaterOrEqual(t, len(coins.Data), 2) coin := coins.Data[0] - txn, err := cli.TransferObject(context.Background(), *signer, *recipient, + txn, err := cli.TransferObject( + context.Background(), *signer, *recipient, coin.CoinObjectId, nil, types.NewSafeSuiBigInt(SUI(0.01).Uint64()), ) require.Nil(t, err) diff --git a/client/client_nft.go b/client/client_nft.go index 5d03aaf..00c06d9 100644 --- a/client/client_nft.go +++ b/client/client_nft.go @@ -3,8 +3,8 @@ package client import ( "context" - "github.com/coming-chat/go-sui/sui_types" - "github.com/coming-chat/go-sui/types" + "github.com/coming-chat/go-sui/v2/sui_types" + "github.com/coming-chat/go-sui/v2/types" ) // MintNFT diff --git a/client/client_stake.go b/client/client_stake.go index 9fe2a53..0f468a8 100644 --- a/client/client_stake.go +++ b/client/client_stake.go @@ -3,10 +3,10 @@ package client import ( "context" - "github.com/coming-chat/go-sui/lib" - "github.com/coming-chat/go-sui/sui_types" - "github.com/coming-chat/go-sui/sui_types/sui_system_state" - "github.com/coming-chat/go-sui/types" + "github.com/coming-chat/go-sui/v2/lib" + "github.com/coming-chat/go-sui/v2/sui_types" + "github.com/coming-chat/go-sui/v2/sui_types/sui_system_state" + "github.com/coming-chat/go-sui/v2/types" "github.com/fardream/go-bcs/bcs" ) @@ -30,17 +30,37 @@ func (c *Client) GetStakesByIds(ctx context.Context, stakedSuiIds []suiObjectID) return resp, c.CallContext(ctx, &resp, getStakesByIds, stakedSuiIds) } -func (c *Client) RequestAddStake(ctx context.Context, signer suiAddress, coins []suiObjectID, amount types.SuiBigInt, validator suiAddress, gas *suiObjectID, gasBudget types.SuiBigInt) (*types.TransactionBytes, error) { +func (c *Client) RequestAddStake( + ctx context.Context, + signer suiAddress, + coins []suiObjectID, + amount types.SuiBigInt, + validator suiAddress, + gas *suiObjectID, + gasBudget types.SuiBigInt, +) (*types.TransactionBytes, error) { var resp types.TransactionBytes return &resp, c.CallContext(ctx, &resp, requestAddStake, signer, coins, amount, validator, gas, gasBudget) } -func (c *Client) RequestWithdrawStake(ctx context.Context, signer suiAddress, stakedSuiId suiObjectID, gas *suiObjectID, gasBudget types.SuiBigInt) (*types.TransactionBytes, error) { +func (c *Client) RequestWithdrawStake( + ctx context.Context, + signer suiAddress, + stakedSuiId suiObjectID, + gas *suiObjectID, + gasBudget types.SuiBigInt, +) (*types.TransactionBytes, error) { var resp types.TransactionBytes return &resp, c.CallContext(ctx, &resp, requestWithdrawStake, signer, stakedSuiId, gas, gasBudget) } -func BCS_RequestAddStake(signer suiAddress, coins []*sui_types.ObjectRef, amount types.SafeSuiBigInt[uint64], validator suiAddress, gasPrice, gasBudget uint64) ([]byte, error) { +func BCS_RequestAddStake( + signer suiAddress, + coins []*sui_types.ObjectRef, + amount types.SafeSuiBigInt[uint64], + validator suiAddress, + gasPrice, gasBudget uint64, +) ([]byte, error) { // build with BCS ptb := sui_types.NewProgrammableTransactionBuilder() amtArg, err := ptb.Pure(amount.Uint64()) @@ -51,30 +71,34 @@ func BCS_RequestAddStake(signer suiAddress, coins []*sui_types.ObjectRef, amount if err != nil { return nil, err } - arg1 := ptb.Command(sui_types.Command{ - SplitCoins: &struct { - Argument sui_types.Argument - Arguments []sui_types.Argument - }{ - Argument: sui_types.Argument{GasCoin: &lib.EmptyEnum{}}, - Arguments: []sui_types.Argument{amtArg}, + arg1 := ptb.Command( + sui_types.Command{ + SplitCoins: &struct { + Argument sui_types.Argument + Arguments []sui_types.Argument + }{ + Argument: sui_types.Argument{GasCoin: &lib.EmptyEnum{}}, + Arguments: []sui_types.Argument{amtArg}, + }, }, - }) // the coin is split result argument + ) // the coin is split result argument arg2, err := ptb.Pure(validator) if err != nil { return nil, err } - ptb.Command(sui_types.Command{ - MoveCall: &sui_types.ProgrammableMoveCall{ - Package: *sui_types.SuiSystemAddress, - Module: sui_system_state.SuiSystemModuleName, - Function: sui_types.AddStakeFunName, - Arguments: []sui_types.Argument{ - arg0, arg1, arg2, + ptb.Command( + sui_types.Command{ + MoveCall: &sui_types.ProgrammableMoveCall{ + Package: *sui_types.SuiSystemAddress, + Module: sui_system_state.SuiSystemModuleName, + Function: sui_types.AddStakeFunName, + Arguments: []sui_types.Argument{ + arg0, arg1, arg2, + }, }, }, - }) + ) pt := ptb.Finish() tx := sui_types.NewProgrammable( signer, coins, pt, gasBudget, gasPrice, diff --git a/client/client_stake_test.go b/client/client_stake_test.go index e3b94cf..576969b 100644 --- a/client/client_stake_test.go +++ b/client/client_stake_test.go @@ -5,8 +5,8 @@ import ( "math/big" "testing" - "github.com/coming-chat/go-sui/sui_types" - "github.com/coming-chat/go-sui/types" + "github.com/coming-chat/go-sui/v2/sui_types" + "github.com/coming-chat/go-sui/v2/types" "github.com/stretchr/testify/require" ) @@ -88,7 +88,8 @@ func TestRequestAddDelegation(t *testing.T) { validator, err := sui_types.NewAddressFromHex(validatorAddress) require.Nil(t, err) - txBytes, err := BCS_RequestAddStake(*signer, + txBytes, err := BCS_RequestAddStake( + *signer, pickedCoins.CoinRefs(), types.NewSafeSuiBigInt(amount), *validator, diff --git a/client/faucet.go b/client/faucet.go index 58ada0c..e4766c3 100644 --- a/client/faucet.go +++ b/client/faucet.go @@ -9,7 +9,7 @@ import ( "net/http" "strings" - "github.com/coming-chat/go-sui/sui_types" + "github.com/coming-chat/go-sui/v2/sui_types" ) const ( diff --git a/go.mod b/go.mod index c351441..e6c8401 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/coming-chat/go-sui +module github.com/coming-chat/go-sui/v2 go 1.18 diff --git a/move_types/language_storage.go b/move_types/language_storage.go index 70c7ad2..ab41cc9 100644 --- a/move_types/language_storage.go +++ b/move_types/language_storage.go @@ -1,6 +1,6 @@ package move_types -import "github.com/coming-chat/go-sui/lib" +import "github.com/coming-chat/go-sui/v2/lib" type StructTag struct { Address AccountAddress diff --git a/sui_types/base_types.go b/sui_types/base_types.go index 7890adb..10dd469 100644 --- a/sui_types/base_types.go +++ b/sui_types/base_types.go @@ -1,8 +1,8 @@ package sui_types import ( - "github.com/coming-chat/go-sui/lib" - "github.com/coming-chat/go-sui/move_types" + "github.com/coming-chat/go-sui/v2/lib" + "github.com/coming-chat/go-sui/v2/move_types" ) type SuiAddress = move_types.AccountAddress diff --git a/sui_types/crypto.go b/sui_types/crypto.go index dd6e422..eb3d41e 100644 --- a/sui_types/crypto.go +++ b/sui_types/crypto.go @@ -5,9 +5,9 @@ import ( "crypto/ed25519" "encoding/json" "errors" - "github.com/coming-chat/go-sui/lib" + "github.com/coming-chat/go-sui/v2/lib" - "github.com/coming-chat/go-sui/crypto" + "github.com/coming-chat/go-sui/v2/crypto" "github.com/fardream/go-bcs/bcs" "golang.org/x/crypto/blake2b" ) diff --git a/sui_types/digest.go b/sui_types/digest.go index d645c20..a4cac4d 100644 --- a/sui_types/digest.go +++ b/sui_types/digest.go @@ -1,6 +1,6 @@ package sui_types -import "github.com/coming-chat/go-sui/lib" +import "github.com/coming-chat/go-sui/v2/lib" type Digest = lib.Base58 diff --git a/sui_types/dynamic_field.go b/sui_types/dynamic_field.go index c8d369d..f89a737 100644 --- a/sui_types/dynamic_field.go +++ b/sui_types/dynamic_field.go @@ -1,6 +1,6 @@ package sui_types -import "github.com/coming-chat/go-sui/lib" +import "github.com/coming-chat/go-sui/v2/lib" type DynamicFieldType struct { DynamicField *lib.EmptyEnum `json:"DynamicField"` diff --git a/sui_types/governance.go b/sui_types/governance.go index 859a5e8..554eadd 100644 --- a/sui_types/governance.go +++ b/sui_types/governance.go @@ -1,6 +1,6 @@ package sui_types -import "github.com/coming-chat/go-sui/move_types" +import "github.com/coming-chat/go-sui/v2/move_types" const ( StakingPoolModuleName = move_types.Identifier("staking_pool") diff --git a/sui_types/intent.go b/sui_types/intent.go index aec85d0..412ec61 100644 --- a/sui_types/intent.go +++ b/sui_types/intent.go @@ -1,6 +1,6 @@ package sui_types -import "github.com/coming-chat/go-sui/lib" +import "github.com/coming-chat/go-sui/v2/lib" type IntentScope struct { TransactionData *lib.EmptyEnum // Used for a user signature on a transaction data. diff --git a/sui_types/messages.go b/sui_types/messages.go index 31dffbd..27ff575 100644 --- a/sui_types/messages.go +++ b/sui_types/messages.go @@ -1,9 +1,9 @@ package sui_types import ( - "github.com/coming-chat/go-sui/lib" - "github.com/coming-chat/go-sui/move_types" - "github.com/coming-chat/go-sui/sui_protocol" + "github.com/coming-chat/go-sui/v2/lib" + "github.com/coming-chat/go-sui/v2/move_types" + "github.com/coming-chat/go-sui/v2/sui_protocol" ) type TransactionData struct { diff --git a/sui_types/object.go b/sui_types/object.go index 3c00fb6..db1b38b 100644 --- a/sui_types/object.go +++ b/sui_types/object.go @@ -1,6 +1,6 @@ package sui_types -import "github.com/coming-chat/go-sui/lib" +import "github.com/coming-chat/go-sui/v2/lib" const ( ObjectStartVersion = SequenceNumber(1) diff --git a/sui_types/programmable_transaction_builder.go b/sui_types/programmable_transaction_builder.go index 938162d..561248c 100644 --- a/sui_types/programmable_transaction_builder.go +++ b/sui_types/programmable_transaction_builder.go @@ -3,8 +3,8 @@ package sui_types import ( "errors" "fmt" - "github.com/coming-chat/go-sui/lib" - "github.com/coming-chat/go-sui/move_types" + "github.com/coming-chat/go-sui/v2/lib" + "github.com/coming-chat/go-sui/v2/move_types" "github.com/fardream/go-bcs/bcs" "github.com/mitchellh/hashstructure/v2" "strconv" diff --git a/sui_types/programmable_transaction_builder_test.go b/sui_types/programmable_transaction_builder_test.go index a9c01b5..bcc2d55 100644 --- a/sui_types/programmable_transaction_builder_test.go +++ b/sui_types/programmable_transaction_builder_test.go @@ -1,7 +1,7 @@ package sui_types import ( - "github.com/coming-chat/go-sui/move_types" + "github.com/coming-chat/go-sui/v2/move_types" "github.com/fardream/go-bcs/bcs" "github.com/stretchr/testify/require" "testing" diff --git a/sui_types/sui_system_state/system.go b/sui_types/sui_system_state/system.go index d55fd5e..310493a 100644 --- a/sui_types/sui_system_state/system.go +++ b/sui_types/sui_system_state/system.go @@ -1,6 +1,6 @@ package sui_system_state -import "github.com/coming-chat/go-sui/move_types" +import "github.com/coming-chat/go-sui/v2/move_types" const ( SuiSystemModuleName = move_types.Identifier("sui_system") diff --git a/sui_types/transaction.go b/sui_types/transaction.go index 855929d..b2840f7 100644 --- a/sui_types/transaction.go +++ b/sui_types/transaction.go @@ -1,6 +1,6 @@ package sui_types -import "github.com/coming-chat/go-sui/lib" +import "github.com/coming-chat/go-sui/v2/lib" var ( SuiSystemMut = CallArg{ diff --git a/types/coin.go b/types/coin.go index 9dbf9b2..cd4a92f 100644 --- a/types/coin.go +++ b/types/coin.go @@ -2,7 +2,7 @@ package types import ( "errors" - "github.com/coming-chat/go-sui/sui_types" + "github.com/coming-chat/go-sui/v2/sui_types" "math/big" "sort" ) diff --git a/types/coin_test.go b/types/coin_test.go index 2bd092f..eb715a0 100644 --- a/types/coin_test.go +++ b/types/coin_test.go @@ -5,7 +5,7 @@ import ( "reflect" "testing" - "github.com/coming-chat/go-sui/sui_types" + "github.com/coming-chat/go-sui/v2/sui_types" "github.com/stretchr/testify/require" ) @@ -136,21 +136,23 @@ func TestCoins_PickSUICoinsWithGas(t *testing.T) { }, } for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - got, got1, err := tt.cs.PickSUICoinsWithGas(tt.args.amount, tt.args.gasAmount, tt.args.pickMethod) - if (err != nil) != tt.wantErr { - t.Errorf("Coins.PickSUICoinsWithGas() error = %v, wantErr %v", err, tt.wantErr) - return - } - if len(got) != 0 && len(tt.want) != 0 { - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("Coins.PickSUICoinsWithGas() got = %v, want %v", got, tt.want) + t.Run( + tt.name, func(t *testing.T) { + got, got1, err := tt.cs.PickSUICoinsWithGas(tt.args.amount, tt.args.gasAmount, tt.args.pickMethod) + if (err != nil) != tt.wantErr { + t.Errorf("Coins.PickSUICoinsWithGas() error = %v, wantErr %v", err, tt.wantErr) + return + } + if len(got) != 0 && len(tt.want) != 0 { + if !reflect.DeepEqual(got, tt.want) { + t.Errorf("Coins.PickSUICoinsWithGas() got = %v, want %v", got, tt.want) + } + } + if !reflect.DeepEqual(got1, tt.want1) { + t.Errorf("Coins.PickSUICoinsWithGas() got1 = %v, want %v", got1, tt.want1) } - } - if !reflect.DeepEqual(got1, tt.want1) { - t.Errorf("Coins.PickSUICoinsWithGas() got1 = %v, want %v", got1, tt.want1) - } - }) + }, + ) } } @@ -225,16 +227,18 @@ func TestCoins_PickCoins(t *testing.T) { }, } for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - got, err := tt.cs.PickCoins(tt.args.amount, tt.args.pickMethod) - if (err != nil) != tt.wantErr { - t.Errorf("Coins.PickCoins() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("Coins.PickCoins() = %v, want %v", got, tt.want) - } - }) + t.Run( + tt.name, func(t *testing.T) { + got, err := tt.cs.PickCoins(tt.args.amount, tt.args.pickMethod) + if (err != nil) != tt.wantErr { + t.Errorf("Coins.PickCoins() error = %v, wantErr %v", err, tt.wantErr) + return + } + if !reflect.DeepEqual(got, tt.want) { + t.Errorf("Coins.PickCoins() = %v, want %v", got, tt.want) + } + }, + ) } } @@ -346,14 +350,22 @@ func TestPickupCoins(t *testing.T) { }, } for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - got, err := PickupCoins(tt.args.inputCoins, tt.args.targetAmount, tt.args.gasBudget, tt.args.limit, tt.args.moreCount) - if tt.wantErr != nil { - require.Equal(t, err, tt.wantErr) - } else { - require.Equal(t, got, tt.want) - t.Log("suggest max gas budget = ", tt.want.SuggestMaxGasBudget()) - } - }) + t.Run( + tt.name, func(t *testing.T) { + got, err := PickupCoins( + tt.args.inputCoins, + tt.args.targetAmount, + tt.args.gasBudget, + tt.args.limit, + tt.args.moreCount, + ) + if tt.wantErr != nil { + require.Equal(t, err, tt.wantErr) + } else { + require.Equal(t, got, tt.want) + t.Log("suggest max gas budget = ", tt.want.SuggestMaxGasBudget()) + } + }, + ) } } diff --git a/types/common.go b/types/common.go index 374bd17..2db70c5 100644 --- a/types/common.go +++ b/types/common.go @@ -2,7 +2,7 @@ package types import ( "fmt" - "github.com/coming-chat/go-sui/sui_types" + "github.com/coming-chat/go-sui/v2/sui_types" "github.com/shopspring/decimal" "math/big" ) diff --git a/types/dynamic_field.go b/types/dynamic_field.go index c412d1a..3391153 100644 --- a/types/dynamic_field.go +++ b/types/dynamic_field.go @@ -1,8 +1,8 @@ package types import ( - "github.com/coming-chat/go-sui/lib" - "github.com/coming-chat/go-sui/sui_types" + "github.com/coming-chat/go-sui/v2/lib" + "github.com/coming-chat/go-sui/v2/sui_types" ) type DynamicFieldInfo struct { diff --git a/types/events.go b/types/events.go index 67c4e61..d7e1824 100644 --- a/types/events.go +++ b/types/events.go @@ -1,6 +1,6 @@ package types -import "github.com/coming-chat/go-sui/sui_types" +import "github.com/coming-chat/go-sui/v2/sui_types" type EventId struct { TxDigest sui_types.TransactionDigest `json:"txDigest"` diff --git a/types/move.go b/types/move.go index 970f4dc..a8fd1b3 100644 --- a/types/move.go +++ b/types/move.go @@ -3,7 +3,7 @@ package types import ( "errors" "fmt" - "github.com/coming-chat/go-sui/sui_types" + "github.com/coming-chat/go-sui/v2/sui_types" "strings" ) diff --git a/types/move_test.go b/types/move_test.go index 4e7a8df..ad9be5d 100644 --- a/types/move_test.go +++ b/types/move_test.go @@ -4,7 +4,7 @@ import ( "reflect" "testing" - "github.com/coming-chat/go-sui/sui_types" + "github.com/coming-chat/go-sui/v2/sui_types" "github.com/stretchr/testify/require" ) @@ -29,8 +29,10 @@ func TestNewResourceType(t *testing.T) { { name: "three level", str: "0xabc::Coin::Xxxx<0x789::AAA::ppp<0x111::mod3::func3>>", - want: &ResourceType{AddressFromHex(t, "0xabc"), "Coin", "Xxxx", - &ResourceType{AddressFromHex(t, "0x789"), "AAA", "ppp", + want: &ResourceType{ + AddressFromHex(t, "0xabc"), "Coin", "Xxxx", + &ResourceType{ + AddressFromHex(t, "0x789"), "AAA", "ppp", &ResourceType{AddressFromHex(t, "0x111"), "mod3", "func3", nil}, }, }, @@ -57,16 +59,18 @@ func TestNewResourceType(t *testing.T) { }, } for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - got, err := NewResourceType(tt.str) - if (err != nil) != tt.wantErr { - t.Errorf("NewResourceType() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("NewResourceType() = %v, want %v", got, tt.want) - } - }) + t.Run( + tt.name, func(t *testing.T) { + got, err := NewResourceType(tt.str) + if (err != nil) != tt.wantErr { + t.Errorf("NewResourceType() error = %v, wantErr %v", err, tt.wantErr) + return + } + if !reflect.DeepEqual(got, tt.want) { + t.Errorf("NewResourceType() = %v, want %v", got, tt.want) + } + }, + ) } } @@ -90,17 +94,23 @@ func TestResourceType_ShortString(t *testing.T) { want: "0x1::m1::f1", }, { - arg: &ResourceType{AddressFromHex(t, "0x1"), "m1", "f1", - &ResourceType{AddressFromHex(t, "2"), "m2", "f2", - &ResourceType{AddressFromHex(t, "0x123abcdef"), "m3", "f3", nil}}}, + arg: &ResourceType{ + AddressFromHex(t, "0x1"), "m1", "f1", + &ResourceType{ + AddressFromHex(t, "2"), "m2", "f2", + &ResourceType{AddressFromHex(t, "0x123abcdef"), "m3", "f3", nil}, + }, + }, want: "0x1::m1::f1<0x2::m2::f2<0x123abcdef::m3::f3>>", }, } for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := tt.arg.ShortString(); got != tt.want { - t.Errorf("ResourceType.ShortString() = %v, want %v", got, tt.want) - } - }) + t.Run( + tt.name, func(t *testing.T) { + if got := tt.arg.ShortString(); got != tt.want { + t.Errorf("ResourceType.ShortString() = %v, want %v", got, tt.want) + } + }, + ) } } diff --git a/types/objects.go b/types/objects.go index 0def1bf..2eee1f4 100644 --- a/types/objects.go +++ b/types/objects.go @@ -1,8 +1,8 @@ package types import ( - "github.com/coming-chat/go-sui/lib" - "github.com/coming-chat/go-sui/sui_types" + "github.com/coming-chat/go-sui/v2/lib" + "github.com/coming-chat/go-sui/v2/sui_types" ) type SuiObjectRef struct { diff --git a/types/response.go b/types/response.go index 51e4912..9ea8875 100644 --- a/types/response.go +++ b/types/response.go @@ -1,8 +1,8 @@ package types import ( - "github.com/coming-chat/go-sui/lib" - "github.com/coming-chat/go-sui/sui_types" + "github.com/coming-chat/go-sui/v2/lib" + "github.com/coming-chat/go-sui/v2/sui_types" ) type AuthSignInfo interface{} diff --git a/types/transactions.go b/types/transactions.go index 170586f..48ddb21 100644 --- a/types/transactions.go +++ b/types/transactions.go @@ -1,8 +1,8 @@ package types import ( - "github.com/coming-chat/go-sui/lib" - "github.com/coming-chat/go-sui/sui_types" + "github.com/coming-chat/go-sui/v2/lib" + "github.com/coming-chat/go-sui/v2/sui_types" ) type ExecuteTransactionRequestType string diff --git a/types/types.go b/types/types.go index ac60fe8..caf1a60 100644 --- a/types/types.go +++ b/types/types.go @@ -4,8 +4,8 @@ import ( "bytes" "encoding/json" "errors" - "github.com/coming-chat/go-sui/lib" - "github.com/coming-chat/go-sui/sui_types" + "github.com/coming-chat/go-sui/v2/lib" + "github.com/coming-chat/go-sui/v2/sui_types" "strings" ) diff --git a/types/validator.go b/types/validator.go index 4a9eb1a..cf6f37e 100644 --- a/types/validator.go +++ b/types/validator.go @@ -6,8 +6,8 @@ import ( "reflect" "strings" - "github.com/coming-chat/go-sui/lib" - "github.com/coming-chat/go-sui/sui_types" + "github.com/coming-chat/go-sui/v2/lib" + "github.com/coming-chat/go-sui/v2/sui_types" ) type StakeStatus = lib.TagJson[Status]