From cfd42d2964ee7403be44acea09abd34453f80204 Mon Sep 17 00:00:00 2001 From: Alex Logatski Date: Thu, 30 Jan 2025 22:34:45 +0100 Subject: [PATCH 1/4] Add `get_proxy` method for `whales_nominator` --- abi/schemas/whales.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/abi/schemas/whales.xml b/abi/schemas/whales.xml index ccc8d706..1d16763a 100644 --- a/abi/schemas/whales.xml +++ b/abi/schemas/whales.xml @@ -72,6 +72,11 @@ int64 + + + msgaddress + + withdraw#da803efd query_id:int64 gas:Grams amount:Grams = Withdraw; From f34ccb69a06bbdbc87036c8c8c5cbeee3c08c3ab Mon Sep 17 00:00:00 2001 From: Alex Logatski Date: Thu, 30 Jan 2025 22:38:22 +0100 Subject: [PATCH 2/4] Add generated method --- abi/get_methods.go | 36 ++++++++++++++++++++++++++++++++++++ abi/interfaces.go | 4 ++++ 2 files changed, 40 insertions(+) diff --git a/abi/get_methods.go b/abi/get_methods.go index 4c0c18ef..966ae507 100644 --- a/abi/get_methods.go +++ b/abi/get_methods.go @@ -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}, @@ -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}, @@ -265,6 +267,7 @@ var resultTypes = []interface{}{ &GetPoolStatusResult{}, &GetPositionManagerContractData_StormResult{}, &GetPowParamsResult{}, + &GetProxy_WhalesNominatorResult{}, &GetPublicKeyResult{}, &GetReferralCollectionAddress_StormResult{}, &GetReferralData_StormResult{}, @@ -2623,6 +2626,39 @@ func DecodeGetPowParamsResult(stack tlb.VmStack) (resultType string, resultAny a return "GetPowParamsResult", result, err } +type GetProxy_WhalesNominatorResult struct { + Address 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 != "VmStkTinyInt" && stack[0].SumType != "VmStkInt") { + 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 } diff --git a/abi/interfaces.go b/abi/interfaces.go index 51279168..2680a047 100644 --- a/abi/interfaces.go +++ b/abi/interfaces.go @@ -574,6 +574,10 @@ var methodInvocationOrder = []MethodDescription{ Name: "get_pow_params", InvokeFn: GetPowParams, }, + { + Name: "get_proxy", + InvokeFn: GetProxy, + }, { Name: "get_public_key", InvokeFn: GetPublicKey, From 1a9aa20ce8cc43885c1288184141e89717eb14de Mon Sep 17 00:00:00 2001 From: Alex Logatski Date: Thu, 30 Jan 2025 23:29:35 +0100 Subject: [PATCH 3/4] Fix type --- abi/get_methods.go | 4 ++-- abi/schemas/whales.xml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/abi/get_methods.go b/abi/get_methods.go index 966ae507..cd7d96aa 100644 --- a/abi/get_methods.go +++ b/abi/get_methods.go @@ -2627,7 +2627,7 @@ func DecodeGetPowParamsResult(stack tlb.VmStack) (resultType string, resultAny a } type GetProxy_WhalesNominatorResult struct { - Address tlb.MsgAddress + Proxy tlb.MsgAddress } func GetProxy(ctx context.Context, executor Executor, reqAccountID ton.AccountID) (string, any, error) { @@ -2651,7 +2651,7 @@ func GetProxy(ctx context.Context, executor Executor, reqAccountID ton.AccountID } func DecodeGetProxy_WhalesNominatorResult(stack tlb.VmStack) (resultType string, resultAny any, err error) { - if len(stack) != 1 || (stack[0].SumType != "VmStkTinyInt" && stack[0].SumType != "VmStkInt") { + if len(stack) != 1 || (stack[0].SumType != "VmStkSlice") { return "", nil, fmt.Errorf("invalid stack format") } var result GetProxy_WhalesNominatorResult diff --git a/abi/schemas/whales.xml b/abi/schemas/whales.xml index 1d16763a..6dff5583 100644 --- a/abi/schemas/whales.xml +++ b/abi/schemas/whales.xml @@ -74,7 +74,7 @@ - msgaddress + msgaddress From 88ac533bc219cb6f8ea515f97512a111dc1e66c1 Mon Sep 17 00:00:00 2001 From: Alex Logatski Date: Thu, 30 Jan 2025 23:29:47 +0100 Subject: [PATCH 4/4] Add test --- abi/generated_test.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/abi/generated_test.go b/abi/generated_test.go index 3700e0d1..809701a9 100644 --- a/abi/generated_test.go +++ b/abi/generated_test.go @@ -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) {