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 get proxy method #332

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
7 changes: 7 additions & 0 deletions abi/generated_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,13 @@ func TestWhalesNominators(t *testing.T) {
params := v.(GetParams_WhalesNominatorResult)
fmt.Printf("%+v\n", params)

_, v, err = GetProxy(context.Background(), client, address)
if err != nil {
t.Fatal(err)
}
proxy := v.(GetProxy_WhalesNominatorResult)
fmt.Printf("%+v\n", proxy)

}

func TestDedustFactory(t *testing.T) {
Expand Down
36 changes: 36 additions & 0 deletions abi/get_methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ var KnownGetMethodsDecoder = map[string][]func(tlb.VmStack) (string, any, error)
"get_pool_status": {DecodeGetPoolStatusResult},
"get_position_manager_contract_data": {DecodeGetPositionManagerContractData_StormResult},
"get_pow_params": {DecodeGetPowParamsResult},
"get_proxy": {DecodeGetProxy_WhalesNominatorResult},
"get_public_key": {DecodeGetPublicKeyResult},
"get_referral_collection_address": {DecodeGetReferralCollectionAddress_StormResult},
"get_referral_data": {DecodeGetReferralData_StormResult},
Expand Down Expand Up @@ -121,6 +122,7 @@ var KnownSimpleGetMethods = map[int][]func(ctx context.Context, executor Executo
69506: {GetTelemintTokenName},
69628: {GetChannelData},
71463: {GetTorrentHash},
71479: {GetProxy},
72748: {GetSaleData},
73490: {GetLockerData},
75065: {GetExecutorBalances},
Expand Down Expand Up @@ -265,6 +267,7 @@ var resultTypes = []interface{}{
&GetPoolStatusResult{},
&GetPositionManagerContractData_StormResult{},
&GetPowParamsResult{},
&GetProxy_WhalesNominatorResult{},
&GetPublicKeyResult{},
&GetReferralCollectionAddress_StormResult{},
&GetReferralData_StormResult{},
Expand Down Expand Up @@ -2623,6 +2626,39 @@ func DecodeGetPowParamsResult(stack tlb.VmStack) (resultType string, resultAny a
return "GetPowParamsResult", result, err
}

type GetProxy_WhalesNominatorResult struct {
Proxy tlb.MsgAddress
}

func GetProxy(ctx context.Context, executor Executor, reqAccountID ton.AccountID) (string, any, error) {
stack := tlb.VmStack{}

// MethodID = 71479 for "get_proxy" method
errCode, stack, err := executor.RunSmcMethodByID(ctx, reqAccountID, 71479, 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){DecodeGetProxy_WhalesNominatorResult} {
s, r, err := f(stack)
if err == nil {
return s, r, nil
}
}
return "", nil, fmt.Errorf("can not decode outputs")
}

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

type GetPublicKeyResult struct {
PublicKey tlb.Int257
}
Expand Down
4 changes: 4 additions & 0 deletions abi/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,10 @@ var methodInvocationOrder = []MethodDescription{
Name: "get_pow_params",
InvokeFn: GetPowParams,
},
{
Name: "get_proxy",
InvokeFn: GetProxy,
},
{
Name: "get_public_key",
InvokeFn: GetPublicKey,
Expand Down
5 changes: 5 additions & 0 deletions abi/schemas/whales.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@
<int name="receipt_price">int64</int>
</output>
</get_method>
<get_method name="get_proxy">
<output version="whales_nominator" fixed_length="true">
<slice name="proxy">msgaddress</slice>
</output>
</get_method>

<internal name="whales_nominators_withdraw">
withdraw#da803efd query_id:int64 gas:Grams amount:Grams = Withdraw;
Expand Down