Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CreateMsgBodyWithoutSignature for w5 #276

Merged
merged 2 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tonconnect/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func NewTonConnect(executor abi.Executor, secret string, opts ...Option) (*Serve
var knownHashes = make(map[string]wallet.Version)

func init() {
for i := wallet.Version(0); i <= wallet.V5Beta; i++ {
for i := wallet.Version(0); i <= wallet.V5R1; i++ {
ver := wallet.GetCodeHashByVer(i)
knownHashes[hex.EncodeToString(ver[:])] = i
}
Expand Down
29 changes: 29 additions & 0 deletions wallet/wallet_v5.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,35 @@ func (w *walletV5R1) NextMessageParams(state tlb.ShardAccount) (NextMsgParams, e
return NextMsgParams{Init: init}, nil
}

func (w *walletV5R1) CreateMsgBodyWithoutSignature(internalMessages []RawMessage, msgConfig MessageConfig) (*boc.Cell, error) {
actions := make([]W5SendMessageAction, 0, len(internalMessages))
for _, msg := range internalMessages {
actions = append(actions, W5SendMessageAction{
Msg: msg.Message,
Mode: msg.Mode,
})
}
w5Actions := W5Actions(actions)
msg := extV5R1SignedMessage{
WalletId: w.walletID,
ValidUntil: uint32(msgConfig.ValidUntil.Unix()),
Seqno: msgConfig.Seqno,
Actions: &w5Actions,
}
bodyCell := boc.NewCell()
if err := bodyCell.WriteUint(uint64(msgConfig.V5MsgType), 32); err != nil {
return nil, err
}
if err := tlb.Marshal(bodyCell, msg); err != nil {
return nil, err
}
bytes := [64]byte{}
if err := bodyCell.WriteBytes(bytes[:]); err != nil {
return nil, err
}
return bodyCell, nil
}

// GetW5R1ExtensionsList returns a list of wallet v5 extensions added to a specific wallet.
func GetW5R1ExtensionsList(state tlb.ShardAccount, workchain int) (map[ton.AccountID]struct{}, error) {
if state.Account.Status() == tlb.AccountActive {
Expand Down
Loading