Skip to content

Commit

Permalink
Add GetWalletStateInitAndSalt to abi
Browse files Browse the repository at this point in the history
  • Loading branch information
aleksej-paschenko committed Sep 13, 2024
1 parent 98dc84a commit 861eba6
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
45 changes: 45 additions & 0 deletions abi/get_methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ var KnownGetMethodsDecoder = map[string][]func(tlb.VmStack) (string, any, error)
"get_wallet_address": {DecodeGetWalletAddressResult},
"get_wallet_data": {DecodeGetWalletDataResult},
"get_wallet_params": {DecodeGetWalletParamsResult},
"get_wallet_state_init_and_salt": {DecodeGetWalletStateInitAndSaltResult},
"is_active": {DecodeIsActiveResult},
"is_claimed": {DecodeIsClaimedResult},
"is_plugin_installed": {DecodeIsPluginInstalledResult},
Expand Down Expand Up @@ -292,6 +293,7 @@ var resultTypes = []interface{}{
&GetWalletAddressResult{},
&GetWalletDataResult{},
&GetWalletParamsResult{},
&GetWalletStateInitAndSaltResult{},
&IsActiveResult{},
&IsClaimedResult{},
&IsPluginInstalledResult{},
Expand Down Expand Up @@ -3789,6 +3791,49 @@ func DecodeGetWalletParamsResult(stack tlb.VmStack) (resultType string, resultAn
return "GetWalletParamsResult", result, err
}

type GetWalletStateInitAndSaltResult struct {
StateInit tlb.Any
Salt int64
}

func GetWalletStateInitAndSalt(ctx context.Context, executor Executor, reqAccountID ton.AccountID, ownerAddress tlb.MsgAddress) (string, any, error) {
stack := tlb.VmStack{}
var (
val tlb.VmStackValue
err error
)
val, err = tlb.TlbStructToVmCellSlice(ownerAddress)
if err != nil {
return "", nil, err
}
stack.Put(val)

// MethodID = 69258 for "get_wallet_state_init_and_salt" method
errCode, stack, err := executor.RunSmcMethodByID(ctx, reqAccountID, 69258, stack)
if err != nil {
return "", nil, err
}
if errCode != 0 && errCode != 1 {
return "", nil, fmt.Errorf("method execution failed with code: %v", errCode)
}
for _, f := range []func(tlb.VmStack) (string, any, error){DecodeGetWalletStateInitAndSaltResult} {
s, r, err := f(stack)
if err == nil {
return s, r, nil
}
}
return "", nil, fmt.Errorf("can not decode outputs")
}

func DecodeGetWalletStateInitAndSaltResult(stack tlb.VmStack) (resultType string, resultAny any, err error) {
if len(stack) != 2 || (stack[0].SumType != "VmStkCell") || (stack[1].SumType != "VmStkTinyInt" && stack[1].SumType != "VmStkInt") {
return "", nil, fmt.Errorf("invalid stack format")
}
var result GetWalletStateInitAndSaltResult
err = stack.Unmarshal(&result)
return "GetWalletStateInitAndSaltResult", result, err
}

type IsActiveResult struct {
IsActive bool
}
Expand Down
10 changes: 10 additions & 0 deletions abi/schemas/jettons.xml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,16 @@
</output>
</get_method>

<get_method name="get_wallet_state_init_and_salt">
<input>
<slice name="owner_address">msgaddress</slice>
</input>
<output name="mintless" fixed_length="true">
<cell name="state_init">any</cell>
<int name="salt">int64</int>
</output>
</get_method>

<!-- Jettons -->
<internal name="jetton_transfer" >
transfer#0f8a7ea5 query_id:uint64 amount:(VarUInteger 16) destination:MsgAddress
Expand Down

0 comments on commit 861eba6

Please sign in to comment.