Skip to content

Commit

Permalink
bump: deps (#260)
Browse files Browse the repository at this point in the history
* bump deps

* update comments
  • Loading branch information
beer-1 authored Sep 5, 2024
1 parent 9771096 commit e31f67d
Show file tree
Hide file tree
Showing 19 changed files with 149 additions and 118 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ARG TARGETARCH
ARG GOARCH

# See https://github.com/initia-labs/movevm/releases
ENV LIBMOVEVM_VERSION=v0.4.4
ENV LIBMOVEVM_VERSION=v0.4.5

# Install necessary packages
RUN set -eux; apk add --no-cache ca-certificates build-base git cmake
Expand Down
2 changes: 1 addition & 1 deletion app/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ func orderInitBlockers() []string {
authz.ModuleName, group.ModuleName, upgradetypes.ModuleName, feegrant.ModuleName,
consensusparamtypes.ModuleName, ibcexported.ModuleName, ibctransfertypes.ModuleName,
ibcnfttransfertypes.ModuleName, icatypes.ModuleName, icaauthtypes.ModuleName, ibcfeetypes.ModuleName,
ibcpermtypes.ModuleName, consensusparamtypes.ModuleName, auctiontypes.ModuleName, ophosttypes.ModuleName,
ibcpermtypes.ModuleName, auctiontypes.ModuleName, ophosttypes.ModuleName,
oracletypes.ModuleName, marketmaptypes.ModuleName, packetforwardtypes.ModuleName, ibchookstypes.ModuleName,
forwardingtypes.ModuleName, ratelimittypes.ModuleName,
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/move/move.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,11 @@ func moveEncodeCmd(ac address.Codec) *cobra.Command {
Provide BCS encoding for move arguments.
Supported types : u8, u16, u32, u64, u128, u256, bool, string, address, raw_hex, raw_base64,
vector<inner_type>, option<inner_type>, decimal128, decimal256, fixed_point32, fixed_point64
vector<inner_type>, option<inner_type>, biguint, bigdecimal, fixed_point32, fixed_point64
Example of args: address:0x1 bool:true u8:0 string:hello vector<u32>:a,b,c,d
Example:
$ %s move encode --args '["address:0x1", "bool:true", "u8:0x01", "u128:1234", "vector<u32>:a,b,c,d", "string:hello world"]'
$ %s move encode --args '["address:0x1", "bool:true", "u8:0x01", "u128:1234", "vector<u32>:a,b,c,d", "string:hello world", "bigdecimal:123.456"]'
`, version.AppName,
),
Args: cobra.ExactArgs(0),
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ require (
github.com/gorilla/mux v1.8.1
github.com/grpc-ecosystem/grpc-gateway v1.16.0
github.com/hashicorp/go-metrics v0.5.3
github.com/initia-labs/OPinit v0.4.2
github.com/initia-labs/OPinit v0.4.3
// we also need to update `LIBMOVEVM_VERSION` of Dockerfile#9
github.com/initia-labs/movevm v0.4.4
github.com/initia-labs/movevm v0.4.5
github.com/noble-assets/forwarding/v2 v2.0.0-20240521090705-86712c4c9e43
github.com/pelletier/go-toml v1.9.5
github.com/pkg/errors v0.9.1
Expand Down Expand Up @@ -148,7 +148,7 @@ require (
github.com/iancoleman/strcase v0.3.0 // indirect
github.com/improbable-eng/grpc-web v0.15.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/initia-labs/OPinit/api v0.4.1 // indirect
github.com/initia-labs/OPinit/api v0.4.3 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/jmhodges/levigo v1.0.0 // indirect
github.com/klauspost/compress v1.17.9 // indirect
Expand Down
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -727,14 +727,14 @@ github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANyt
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo=
github.com/initia-labs/OPinit v0.4.2 h1:cfE6LXb3EquDK1/UTDT62o9c2HOQL0E9pWTr5BWAf8g=
github.com/initia-labs/OPinit v0.4.2/go.mod h1:bM+tav+ER4uC6U84PB5vgnRUNyjc/phNgHGYQX9ALhg=
github.com/initia-labs/OPinit/api v0.4.1 h1:Q8etW92LiwekKZxzDYVFdiHF3uOpEA4nyajy8zpcxB0=
github.com/initia-labs/OPinit/api v0.4.1/go.mod h1:Xy/Nt3ubXLQ4zKn0m7RuQOM1sj8TVdlNNyek21TGYR0=
github.com/initia-labs/OPinit v0.4.3 h1:tFpcT9qeOLS49tFdEeK9ACEibeCEYd+V4Oz69gQPvp8=
github.com/initia-labs/OPinit v0.4.3/go.mod h1:1bf2//8NDHa2geXj81wm+2tLOW7zD6PQiGR6eakim00=
github.com/initia-labs/OPinit/api v0.4.3 h1:qljFODGw3F2ClGgJD4uiw1QXb3Px9tJX3jqWolPco/Q=
github.com/initia-labs/OPinit/api v0.4.3/go.mod h1:NorLLEBESDeLPQIzTFIT2XjvD/tkS1VRE6YL59TXYT0=
github.com/initia-labs/cometbft v0.0.0-20240802022359-e0a5ce0336b6 h1:ObKvj9nGiKE+MWZ/LnH3rPcXsnBVVn4c30/iw+fMsd4=
github.com/initia-labs/cometbft v0.0.0-20240802022359-e0a5ce0336b6/go.mod h1:jHPx9vQpWzPHEAiYI/7EDKaB1NXhK6o3SArrrY8ExKc=
github.com/initia-labs/movevm v0.4.4 h1:JUUzxi+SOdfhpazWPVVMHj88om0zGDe+PWEGV2Yi8aQ=
github.com/initia-labs/movevm v0.4.4/go.mod h1:6MxR4GP5zH3JUc1IMgfqAe1e483mZVS7fshPknZPJ30=
github.com/initia-labs/movevm v0.4.5 h1:C1KfVQJiIqH3fcSlQ/KELRmEu2y3VAsVMSSyKTBfE0k=
github.com/initia-labs/movevm v0.4.5/go.mod h1:aUWdvFZPdULjJ2McQTE+mLnfnG3CLAz0TWJRFzFFUwg=
github.com/jhump/protoreflect v1.15.3 h1:6SFRuqU45u9hIZPJAoZ8c28T3nK64BNdp9w6jFonzls=
github.com/jhump/protoreflect v1.15.3/go.mod h1:4ORHmSBmlCW8fh3xHmJMGyul1zNqZK4Elxc8qKP+p1k=
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
Expand Down
2 changes: 1 addition & 1 deletion x/ibc/nft-transfer/keeper/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func (suite *KeeperTestSuite) CreateNftClass(
movetypes.MoveModuleNameInitiaNft,
movetypes.FunctionNameInitiaNftCreateCollection,
[]vmtypes.TypeTag{},
[][]byte{descBz, {0}, nameBz, uriBz, {0}, {0}, {0}, {0}, {0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
[][]byte{descBz, {0}, nameBz, uriBz, {0}, {0}, {0}, {0}, {0}, {0}},
)
suite.Require().NoError(err, "MakeCollection error on chain")

Expand Down
4 changes: 2 additions & 2 deletions x/move/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ func GetCmdQueryViewFunction(ac address.Codec) *cobra.Command {
Get an view function execution result
Supported types : u8, u16, u32, u64, u128, u256, bool, string, address, raw_hex, raw_base64,
vector<inner_type>, option<inner_type>, decimal128, decimal256, fixed_point32, fixed_point64
vector<inner_type>, option<inner_type>, biguint, bigdecimal, fixed_point32, fixed_point64
Example of args: address:0x1 bool:true u8:0 string:hello vector<u32>:a,b,c,d
Example:
Expand Down Expand Up @@ -360,7 +360,7 @@ func GetCmdQueryViewJSONFunction(ac address.Codec) *cobra.Command {
Get an view function execution result
Supported types : u8, u16, u32, u64, u128, u256, bool, string, address, raw_hex, raw_base64,
vector<inner_type>, option<inner_type>, decimal128, decimal256, fixed_point32, fixed_point64
vector<inner_type>, option<inner_type>, biguint, bigdecimal, fixed_point32, fixed_point64
Example of args: "0x1" "true" "0" "hello vector" ["a","b","c","d"]
Example:
Expand Down
8 changes: 4 additions & 4 deletions x/move/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func ExecuteCmd(ac address.Codec) *cobra.Command {
Execute an entry function of a published module
Supported types : u8, u16, u32, u64, u128, u256, bool, string, address, raw_hex, raw_base64,
vector<inner_type>, option<inner_type>, decimal128, decimal256, fixed_point32, fixed_point64
vector<inner_type>, option<inner_type>, biguint, bigdecimal, fixed_point32, fixed_point64
Example of args: address:0x1 bool:true u8:0 string:hello vector<u32>:a,b,c,d
Example:
Expand Down Expand Up @@ -198,7 +198,7 @@ func ExecuteJSONCmd(ac address.Codec) *cobra.Command {
Execute an entry function of a published module
Supported types : u8, u16, u32, u64, u128, u256, bool, string, address, raw_hex, raw_base64,
vector<inner_type>, option<inner_type>, decimal128, decimal256, fixed_point32, fixed_point64
vector<inner_type>, option<inner_type>, biguint, bigdecimal, fixed_point32, fixed_point64
Example of args: "0x1" "true" "0" "hello vector" ["a","b","c","d"]
Example:
Expand Down Expand Up @@ -273,7 +273,7 @@ func ScriptCmd(ac address.Codec) *cobra.Command {
Execute a given script
Supported types : u8, u16, u32, u64, u128, u256, bool, string, address, raw_hex, raw_base64,
vector<inner_type>, option<inner_type>, decimal128, decimal256, fixed_point32, fixed_point64
vector<inner_type>, option<inner_type>, biguint, bigdecimal, fixed_point32, fixed_point64
Example of args: address:0x1 bool:true u8:0 string:hello vector<u32>:a,b,c,d
Example:
Expand Down Expand Up @@ -347,7 +347,7 @@ func ScriptJSONCmd(ac address.Codec) *cobra.Command {
Execute a given script
Supported types : u8, u16, u32, u64, u128, u256, bool, string, address, raw_hex, raw_base64,
vector<inner_type>, option<inner_type>, decimal128, decimal256, fixed_point32, fixed_point64
vector<inner_type>, option<inner_type>, biguint, bigdecimal, fixed_point32, fixed_point64
Example of args: address:0x1 bool:true u8:0 string:hello vector<u32>:a,b,c,d
Example:
Expand Down
27 changes: 19 additions & 8 deletions x/move/client/cli/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"fmt"
"math/big"
"regexp"
"slices"
"strconv"
"strings"

Expand Down Expand Up @@ -197,20 +198,30 @@ func bcsSerializeArg(argType string, arg string, s serde.Serializer, ac address.
High: highHigh,
})
return s.GetBytes(), nil
case "decimal128":
dec, err := sdkmath.LegacyNewDecFromStr(arg)
case "biguint":
n, err := sdkmath.ParseUint(arg)
if err != nil {
return nil, err
return nil, fmt.Errorf("failed to parse %q as biguint", err)
}
decstr := dec.MulInt64(1000000000000000000).TruncateInt().String()
return bcsSerializeArg("u128", decstr, s, ac)
case "decimal256":

// convert to little endian
bz := n.BigInt().Bytes()
slices.Reverse(bz)

err = s.SerializeBytes(bz)
return s.GetBytes(), err
case "bigdecimal":
dec, err := sdkmath.LegacyNewDecFromStr(arg)
if err != nil {
return nil, err
}
decstr := dec.MulInt64(1000000000000000000).TruncateInt().String()
return bcsSerializeArg("u256", decstr, s, ac)

// convert to little endian
bz := dec.BigInt().Bytes()
slices.Reverse(bz)

err = s.SerializeBytes(bz)
return s.GetBytes(), err
case "fixed_point32":
dec, err := sdkmath.LegacyNewDecFromStr(arg)
if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions x/move/client/cli/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ func Test_BCSEncode(t *testing.T) {
{"vector<u128>:0", []byte{0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, false, "vector<u128> 0"},
{"vector<u128>:1", []byte{0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, false, "vector<u128> 1"},
{"badtype:1", nil, true, "badtype 1"},
{"biguint:1077952576", []byte{4, 64, 64, 64, 64}, false, "biguint 1077952576"},
{"bigdecimal:0.00000027595585952", []byte{5, 64, 64, 64, 64, 64}, false, "bigdecimal 0.00000027595585952"},
}

ac := address.NewBech32Codec(sdk.GetConfig().GetBech32AccountAddrPrefix())
Expand Down
17 changes: 6 additions & 11 deletions x/move/common_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package move_test

import (
"bytes"
"encoding/binary"
"slices"
"testing"

initiaapp "github.com/initia-labs/initia/app"
Expand Down Expand Up @@ -113,18 +112,14 @@ func executeMsgs(t *testing.T, app *initiaapp.InitiaApp, msgs []sdk.Msg, account
}

func decToVmArgument(t *testing.T, val math.LegacyDec) []byte {
// big-endian bytes
bz := val.BigInt().Bytes()
diff := 16 - len(bz)
require.True(t, diff >= 0)
if diff > 0 {
bz = append(bytes.Repeat([]byte{0}, diff), bz...)
}

high := binary.BigEndian.Uint64(bz[:8])
low := binary.BigEndian.Uint64(bz[8:16])
// reverse bytes to little-endian
slices.Reverse(bz)

// serialize to uint128
bz, err := vmtypes.SerializeUint128(high, low)
// serialize bytes
bz, err := vmtypes.SerializeBytes(bz)
require.NoError(t, err)

return bz
Expand Down
17 changes: 11 additions & 6 deletions x/move/keeper/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,23 +55,23 @@ func (api GoApi) GetAccountInfo(addr vmtypes.AccountAddress) (bool /* found */,
}

// AmountToShare convert amount to share
func (api GoApi) AmountToShare(valBz []byte, metadata vmtypes.AccountAddress, amount uint64) (uint64, error) {
func (api GoApi) AmountToShare(valBz []byte, metadata vmtypes.AccountAddress, amount uint64) (string, error) {
valAddr, err := api.vc.StringToBytes(string(valBz))
if err != nil {
return 0, err
return "0", err
}

denom, err := types.DenomFromMetadataAddress(api.ctx, NewMoveBankKeeper(&api.Keeper), metadata)
if err != nil {
return 0, err
return "0", err
}

share, err := api.Keeper.AmountToShare(api.ctx, valAddr, sdk.NewCoin(denom, math.NewIntFromUint64(amount)))
return share.Uint64(), err
return share.String(), err
}

// ShareToAmount convert share to amount
func (api GoApi) ShareToAmount(valBz []byte, metadata vmtypes.AccountAddress, share uint64) (uint64, error) {
func (api GoApi) ShareToAmount(valBz []byte, metadata vmtypes.AccountAddress, share string) (uint64, error) {
valAddr, err := api.vc.StringToBytes(string(valBz))
if err != nil {
return 0, err
Expand All @@ -82,7 +82,12 @@ func (api GoApi) ShareToAmount(valBz []byte, metadata vmtypes.AccountAddress, sh
return 0, err
}

amount, err := api.Keeper.ShareToAmount(api.ctx, valAddr, sdk.NewDecCoin(denom, math.NewIntFromUint64(share)))
dec, err := math.LegacyNewDecFromStr(share)
if err != nil {
return 0, err
}

amount, err := api.Keeper.ShareToAmount(api.ctx, valAddr, sdk.NewDecCoinFromDec(denom, dec))
return amount.Uint64(), err
}

Expand Down
6 changes: 3 additions & 3 deletions x/move/keeper/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func Test_AmountToShareAPI(t *testing.T) {
api := keeper.NewApi(input.MoveKeeper, ctx)
amount, err := api.AmountToShare([]byte(valAddr.String()), metadata, 150)
require.NoError(t, err)
require.Equal(t, uint64(150), amount)
require.Equal(t, "150.000000000000000000", amount)
}

func Test_AmountToShareAPI_InvalidAddr(t *testing.T) {
Expand Down Expand Up @@ -154,7 +154,7 @@ func Test_ShareToAmountAPI(t *testing.T) {
require.NoError(t, err)

api := keeper.NewApi(input.MoveKeeper, ctx)
amount, err := api.ShareToAmount([]byte(valAddr.String()), metadata, 150)
amount, err := api.ShareToAmount([]byte(valAddr.String()), metadata, "150")
require.NoError(t, err)
require.Equal(t, uint64(150), amount)
}
Expand All @@ -178,7 +178,7 @@ func Test_ShareToAmountAPI_InvalidAddr(t *testing.T) {
require.NoError(t, err)

api := keeper.NewApi(input.MoveKeeper, ctx)
_, err = api.ShareToAmount(valAddr, metadata, 150)
_, err = api.ShareToAmount(valAddr, metadata, "150")
require.Error(t, err)
}

Expand Down
17 changes: 6 additions & 11 deletions x/move/keeper/dex_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package keeper_test

import (
"bytes"
"encoding/binary"
"slices"
"testing"

"cosmossdk.io/math"
Expand All @@ -16,18 +15,14 @@ import (
)

func decToVmArgument(t *testing.T, val math.LegacyDec) []byte {
// big-endian bytes
bz := val.BigInt().Bytes()
diff := 16 - len(bz)
require.True(t, diff >= 0)
if diff > 0 {
bz = append(bytes.Repeat([]byte{0}, diff), bz...)
}

high := binary.BigEndian.Uint64(bz[:8])
low := binary.BigEndian.Uint64(bz[8:16])
// reverse bytes to little-endian
slices.Reverse(bz)

// serialize to uint128
bz, err := vmtypes.SerializeUint128(high, low)
// serialize bytes
bz, err := vmtypes.SerializeBytes(bz)
require.NoError(t, err)

return bz
Expand Down
2 changes: 1 addition & 1 deletion x/move/keeper/nft.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ func (k NftKeeper) initializeCollection(ctx context.Context, collectionName, cla
types.MoveModuleNameInitiaNft,
types.FunctionNameInitiaNftCreateCollection,
[]vmtypes.TypeTag{},
[][]byte{collectionDescBz, {0}, collectionNameBz, collectionUriBz, {0}, {0}, {0}, {0}, {0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
[][]byte{collectionDescBz, {0}, collectionNameBz, collectionUriBz, {0}, {0}, {0}, {0}, {0}, {0}},
)
}

Expand Down
Loading

0 comments on commit e31f67d

Please sign in to comment.