Skip to content

Commit

Permalink
Merge pull request #30 from chernyshevuser/fix/gasObj
Browse files Browse the repository at this point in the history
Fix/gas obj
  • Loading branch information
JaydenLink authored Aug 14, 2024
2 parents 13f0bd3 + 403e4d9 commit 599a491
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 22 deletions.
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,12 @@ func main() {
priKey := signerAccount.PriKey
fmt.Printf("signerAccount.Address: %s\n", signerAccount.Address)

gasObj := "0xc699c6014da947778fe5f740b2e9caf905ca31fb4c81e346f467ae126e3c03f1"

rsp, err := cli.TransferObject(ctx, models.TransferObjectRequest{
Signer: signerAccount.Address,
ObjectId: "0x99b51302b66bd65b070cdb549b86e4b9aa7370cfddc70211c2b5a478140c7999",
Gas: "0xc699c6014da947778fe5f740b2e9caf905ca31fb4c81e346f467ae126e3c03f1",
Gas: &gasObj,
GasBudget: "100000000",
Recipient: "0xaf9f4d20c205f26051a7e1758601c4c47a9f99df3f9823f70926c17c80882d36",
})
Expand Down Expand Up @@ -268,6 +270,8 @@ func main() {
priKey := signerAccount.PriKey
fmt.Printf("signerAccount.Address: %s\n", signerAccount.Address)

gasObj := "0x58c103930dc52c0ab86319d99218e301596fda6fd80c4efafd7f4c9df1d0b6d0"

rsp, err := cli.MoveCall(ctx, models.MoveCallRequest{
Signer: signerAccount.Address,
PackageObjectId: "0x7d584c9a27ca4a546e8203b005b0e9ae746c9bec6c8c3c0bc84611bcf4ceab5f",
Expand All @@ -281,7 +285,7 @@ func main() {
"BlockVision",
"0xc699c6014da947778fe5f740b2e9caf905ca31fb4c81e346f467ae126e3c03f1",
},
Gas: "0x58c103930dc52c0ab86319d99218e301596fda6fd80c4efafd7f4c9df1d0b6d0",
Gas: &gasObj,
GasBudget: "100000000",
})

Expand Down Expand Up @@ -343,11 +347,13 @@ func main() {
priKey := signerAccount.PriKey
fmt.Printf("signerAccount.Address: %s\n", signerAccount.Address)

gasObj := "0xc699c6014da947778fe5f740b2e9caf905ca31fb4c81e346f467ae126e3c03f1"

rsp, err := cli.MergeCoins(ctx, models.MergeCoinsRequest{
Signer: signerAccount.Address,
PrimaryCoin: "0x180fe0c159644fe4b376e4488498e524b2a564919775cb2719734a4699ae7b28",
CoinToMerge: "0x3b4644f82b4dc339c17ed5f786f4050e1f765b38e9297ffdacdfc5ead482669f",
Gas: "0xc699c6014da947778fe5f740b2e9caf905ca31fb4c81e346f467ae126e3c03f1",
Gas: &gasObj,
GasBudget: "100000000",
})

Expand Down
41 changes: 31 additions & 10 deletions examples/transaction/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"context"
"fmt"

"github.com/block-vision/sui-go-sdk/constant"
"github.com/block-vision/sui-go-sdk/models"
"github.com/block-vision/sui-go-sdk/signer"
Expand Down Expand Up @@ -214,6 +215,8 @@ func SuiXQueryTransactionBlocks() {
}

func MoveCall() {
gasObj := "0xc699c6014da947778fe5f740b2e9caf905ca31fb4c81e346f467ae126e3c03f1"

rsp, err := cli.MoveCall(ctx, models.MoveCallRequest{
Signer: "0x4ae8be62692d1bbf892b657ee78a59954240ee0525f20a5b5687a70995cf0eff",
PackageObjectId: "0x7d584c9a27ca4a546e8203b005b0e9ae746c9bec6c8c3c0bc84611bcf4ceab5f",
Expand All @@ -227,7 +230,7 @@ func MoveCall() {
"web3",
"0xc699c6014da947778fe5f740b2e9caf905ca31fb4c81e346f467ae126e3c03f1",
},
Gas: "0xc699c6014da947778fe5f740b2e9caf905ca31fb4c81e346f467ae126e3c03f1",
Gas: &gasObj,
GasBudget: "1000",
})

Expand All @@ -240,11 +243,13 @@ func MoveCall() {
}

func MergeCoins() {
gasObj := "0xc699c6014da947778fe5f740b2e9caf905ca31fb4c81e346f467ae126e3c03f1"

rsp, err := cli.MergeCoins(ctx, models.MergeCoinsRequest{
Signer: "0x4ae8be62692d1bbf892b657ee78a59954240ee0525f20a5b5687a70995cf0eff",
PrimaryCoin: "0xc699c6014da947778fe5f740b2e9caf905ca31fb4c81e346f467ae126e3c03f1",
CoinToMerge: "0x92f03fdec6e0278dcb6fa3f4467eeee3e0bee1ac41825351ef53431677d2e2f7",
Gas: "0xc699c6014da947778fe5f740b2e9caf905ca31fb4c81e346f467ae126e3c03f1",
Gas: &gasObj,
GasBudget: "1000000",
})

Expand All @@ -257,11 +262,13 @@ func MergeCoins() {
}

func SplitCoin() {
gasObj := "0xc699c6014da947778fe5f740b2e9caf905ca31fb4c81e346f467ae126e3c03f1"

rsp, err := cli.SplitCoin(ctx, models.SplitCoinRequest{
Signer: "0x4ae8be62692d1bbf892b657ee78a59954240ee0525f20a5b5687a70995cf0eff",
CoinObjectId: "0xc699c6014da947778fe5f740b2e9caf905ca31fb4c81e346f467ae126e3c03f1",
SplitAmounts: []string{"1000", "1000"},
Gas: "0xc699c6014da947778fe5f740b2e9caf905ca31fb4c81e346f467ae126e3c03f1",
Gas: &gasObj,
GasBudget: "1000",
})

Expand All @@ -274,11 +281,13 @@ func SplitCoin() {
}

func SplitCoinEqual() {
gasObj := "0xc699c6014da947778fe5f740b2e9caf905ca31fb4c81e346f467ae126e3c03f1"

rsp, err := cli.SplitCoinEqual(ctx, models.SplitCoinEqualRequest{
Signer: "0x4ae8be62692d1bbf892b657ee78a59954240ee0525f20a5b5687a70995cf0eff",
CoinObjectId: "0xc699c6014da947778fe5f740b2e9caf905ca31fb4c81e346f467ae126e3c03f1",
SplitCount: "2",
Gas: "0xc699c6014da947778fe5f740b2e9caf905ca31fb4c81e346f467ae126e3c03f1",
Gas: &gasObj,
GasBudget: "1000",
})

Expand All @@ -291,13 +300,15 @@ func SplitCoinEqual() {
}

func Publish() {
gasObj := "0xc699c6014da947778fe5f740b2e9caf905ca31fb4c81e346f467ae126e3c03f1"

rsp, err := cli.Publish(ctx, models.PublishRequest{
Sender: "0x4ae8be62692d1bbf892b657ee78a59954240ee0525f20a5b5687a70995cf0eff",
CompiledModules: []string{
"oRzrCwUAAAALAQAOAg4kAz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AAAAAOAkSATgKAgEBAQIA",
},
Dependencies: []string{"0xc699c6014da947778fe5f740b2e9caf905ca31fb4c81e346f467ae126e3c03f1"},
Gas: "0xc699c6014da947778fe5f740b2e9caf905ca31fb4c81e346f467ae126e3c03f1",
Gas: &gasObj,
GasBudget: "1000",
})

Expand All @@ -310,10 +321,12 @@ func Publish() {
}

func TransferObject() {
gasObj := "0xc699c6014da947778fe5f740b2e9caf905ca31fb4c81e346f467ae126e3c03f1"

rsp, err := cli.TransferObject(ctx, models.TransferObjectRequest{
Signer: "0x4ae8be62692d1bbf892b657ee78a59954240ee0525f20a5b5687a70995cf0eff",
ObjectId: "0xc699c6014da947778fe5f740b2e9caf905ca31fb4c81e346f467ae126e3c03f1",
Gas: "0xc699c6014da947778fe5f740b2e9caf905ca31fb4c81e346f467ae126e3c03f1",
Gas: &gasObj,
GasBudget: "1000",
Recipient: "0x4ae8be62692d1bbf892b657ee78a59954240ee0525f20a5b5687a70995cf0eff",
})
Expand Down Expand Up @@ -344,12 +357,14 @@ func TransferSui() {
}

func Pay() {
gasObj := "0xc699c6014da947778fe5f740b2e9caf905ca31fb4c81e346f467ae126e3c03f1"

rsp, err := cli.Pay(ctx, models.PayRequest{
Signer: "0x4ae8be62692d1bbf892b657ee78a59954240ee0525f20a5b5687a70995cf0eff",
SuiObjectId: []string{"0x92f03fdec6e0278dcb6fa3f4467eeee3e0bee1ac41825351ef53431677d2e2f7"},
Recipient: []string{"0x4ae8be62692d1bbf892b657ee78a59954240ee0525f20a5b5687a70995cf0eff"},
Amount: []string{"1"},
Gas: "0xc699c6014da947778fe5f740b2e9caf905ca31fb4c81e346f467ae126e3c03f1",
Gas: &gasObj,
GasBudget: "1000000",
})

Expand Down Expand Up @@ -395,12 +410,14 @@ func PayAllSui() {
}

func RequestAddStake() {
gasObj := "0xc699c6014da947778fe5f740b2e9caf905ca31fb4c81e346f467ae126e3c03f1"

rsp, err := cli.RequestAddStake(ctx, models.AddStakeRequest{
Signer: "0x4ae8be62692d1bbf892b657ee78a59954240ee0525f20a5b5687a70995cf0eff",
Coins: []string{"0xc699c6014da947778fe5f740b2e9caf905ca31fb4c81e346f467ae126e3c03f1"},
Amount: "1",
Validator: "0x884515e99dab69c4c28662149db81ca563ed4c36e0c8ce44a58e40e25a0a64a1",
Gas: "0xc699c6014da947778fe5f740b2e9caf905ca31fb4c81e346f467ae126e3c03f1",
Gas: &gasObj,
GasBudget: "1000",
})

Expand All @@ -413,10 +430,12 @@ func RequestAddStake() {
}

func RequestWithdrawStake() {
gasObj := "0xc699c6014da947778fe5f740b2e9caf905ca31fb4c81e346f467ae126e3c03f1"

rsp, err := cli.RequestWithdrawStake(ctx, models.WithdrawStakeRequest{
Signer: "0x4ae8be62692d1bbf892b657ee78a59954240ee0525f20a5b5687a70995cf0eff",
StakedObjectId: "0xc699c6014da947778fe5f740b2e9caf905ca31fb4c81e346f467ae126e3c03f1",
Gas: "0xc699c6014da947778fe5f740b2e9caf905ca31fb4c81e346f467ae126e3c03f1",
Gas: &gasObj,
GasBudget: "1000",
})

Expand All @@ -429,6 +448,8 @@ func RequestWithdrawStake() {
}

func BatchTransaction() {
gasObj := "0xc699c6014da947778fe5f740b2e9caf905ca31fb4c81e346f467ae126e3c03f1"

rsp, err := cli.BatchTransaction(ctx, models.BatchTransactionRequest{
Signer: "0x4ae8be62692d1bbf892b657ee78a59954240ee0525f20a5b5687a70995cf0eff",
RPCTransactionRequestParams: []models.RPCTransactionRequestParams{
Expand All @@ -454,7 +475,7 @@ func BatchTransaction() {
},
},
},
Gas: "0xc699c6014da947778fe5f740b2e9caf905ca31fb4c81e346f467ae126e3c03f1",
Gas: &gasObj,
GasBudget: "1000",
SuiTransactionBlockBuilderMode: "DevInspect",
})
Expand Down
19 changes: 10 additions & 9 deletions models/write_transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package models

import (
"crypto/ed25519"

"github.com/block-vision/sui-go-sdk/models/sui_types"
)

Expand Down Expand Up @@ -45,7 +46,7 @@ type MergeCoinsRequest struct {
PrimaryCoin string `json:"primaryCoin"`
CoinToMerge string `json:"coinToMerge"`
// gas object to be used in this transaction, node will pick one from the signer's possession if not provided
Gas string `json:"gas"`
Gas *string `json:"gas"`
// the gas budget, the transaction will fail if the gas cost exceed the budget
GasBudget string `json:"gasBudget"`
}
Expand All @@ -56,7 +57,7 @@ type SplitCoinRequest struct {
CoinObjectId string `json:"coinObjectId"`
SplitAmounts []string `json:"splitAmounts"`
// gas object to be used in this transaction, node will pick one from the signer's possession if not provided
Gas string `json:"gas"`
Gas *string `json:"gas"`
// the gas budget, the transaction will fail if the gas cost exceed the budget
GasBudget string `json:"gasBudget"`
}
Expand All @@ -67,7 +68,7 @@ type SplitCoinEqualRequest struct {
CoinObjectId string `json:"coinObjectId"`
SplitCount string `json:"splitCount"`
// gas object to be used in this transaction, node will pick one from the signer's possession if not provided
Gas string `json:"gas"`
Gas *string `json:"gas"`
// the gas budget, the transaction will fail if the gas cost exceed the budget
GasBudget string `json:"gasBudget"`
}
Expand All @@ -78,7 +79,7 @@ type PublishRequest struct {
CompiledModules []string `json:"compiled_modules"`
Dependencies []string `json:"dependencies"`
// gas object to be used in this transaction, node will pick one from the signer's possession if not provided
Gas string `json:"gas"`
Gas *string `json:"gas"`
// the gas budget, the transaction will fail if the gas cost exceed the budget
GasBudget string `json:"gasBudget"`
}
Expand All @@ -88,7 +89,7 @@ type TransferObjectRequest struct {
Signer string `json:"signer"`
ObjectId string `json:"objectId"`
// gas object to be used in this transaction, node will pick one from the signer's possession if not provided
Gas string `json:"gas"`
Gas *string `json:"gas"`
// the gas budget, the transaction will fail if the gas cost exceed the budget
GasBudget string `json:"gasBudget"`
Recipient string `json:"recipient"`
Expand All @@ -111,7 +112,7 @@ type PayRequest struct {
Recipient []string `json:"recipient"`
Amount []string `json:"amount"`
// gas object to be used in this transaction, node will pick one from the signer's possession if not provided
Gas string `json:"gas"`
Gas *string `json:"gas"`
// the gas budget, the transaction will fail if the gas cost exceed the budget
GasBudget string `json:"gasBudget"`
}
Expand Down Expand Up @@ -145,7 +146,7 @@ type AddStakeRequest struct {
// the validator's Sui address
Validator string `json:"validator"`
// gas object to be used in this transaction, node will pick one from the signer's possession if not provided
Gas string `json:"gas"`
Gas *string `json:"gas"`
// the gas budget, the transaction will fail if the gas cost exceed the budget
GasBudget string `json:"gasBudget"`
}
Expand All @@ -156,7 +157,7 @@ type WithdrawStakeRequest struct {
// StakedSui object ID
StakedObjectId string `json:"stakedObjectId"`
// gas object to be used in this transaction, node will pick one from the signer's possession if not provided
Gas string `json:"gas"`
Gas *string `json:"gas"`
// the gas budget, the transaction will fail if the gas cost exceed the budget
GasBudget string `json:"gasBudget"`
}
Expand All @@ -173,7 +174,7 @@ type BatchTransactionRequest struct {
// list of transaction request parameters
RPCTransactionRequestParams []RPCTransactionRequestParams `json:"RPCTransactionRequestParams"`
// gas object to be used in this transaction, node will pick one from the signer's possession if not provided
Gas string `json:"gas"`
Gas *string `json:"gas"`
// the gas budget, the transaction will fail if the gas cost exceed the budget
GasBudget string `json:"gasBudget"`
// Whether this is a regular transaction or a Dev Inspect Transaction
Expand Down
1 change: 1 addition & 0 deletions sui/write_transaction_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"context"
"encoding/json"
"errors"

"github.com/block-vision/sui-go-sdk/common/httpconn"
"github.com/block-vision/sui-go-sdk/models"
"github.com/tidwall/gjson"
Expand Down

0 comments on commit 599a491

Please sign in to comment.