From 7fc1502162a1bfd303003f39b74307319da309b5 Mon Sep 17 00:00:00 2001 From: denis subbotin Date: Mon, 10 Jun 2024 01:56:23 +0300 Subject: [PATCH] add multisig orders info --- abi/get_methods.go | 44 ++++++++++++++++++++++++++++++++++++++++ abi/interfaces.go | 12 +++++++++-- abi/parser/generator.go | 8 ++++++++ abi/schemas/multisig.xml | 17 ++++++++++++++++ 4 files changed, 79 insertions(+), 2 deletions(-) diff --git a/abi/get_methods.go b/abi/get_methods.go index b9da865..840f09b 100644 --- a/abi/get_methods.go +++ b/abi/get_methods.go @@ -44,6 +44,7 @@ var KnownGetMethodsDecoder = map[string][]func(tlb.VmStack) (string, any, error) "get_nft_content": {DecodeGetNftContentResult}, "get_nft_data": {DecodeGetNftDataResult}, "get_nominator_data": {DecodeGetNominatorDataResult}, + "get_order_data": {DecodeGetOrderDataResult}, "get_params": {DecodeGetParams_WhalesNominatorResult}, "get_plugin_list": {DecodeGetPluginListResult}, "get_pool_data": {DecodeGetPoolData_StonfiResult, DecodeGetPoolData_TfResult}, @@ -133,6 +134,7 @@ var KnownSimpleGetMethods = map[int][]func(ctx context.Context, executor Executo 120146: {GetPoolStatus}, 122058: {IsActive}, 122498: {GetTelemintAuctionState}, + 123832: {GetOrderData}, 123928: {GetStakingStatus}, 128085: {GetRouterData}, 128979: {JettonWalletLockData}, @@ -175,6 +177,7 @@ var resultTypes = []interface{}{ &GetNftContentResult{}, &GetNftDataResult{}, &GetNominatorDataResult{}, + &GetOrderDataResult{}, &GetParams_WhalesNominatorResult{}, &GetPluginListResult{}, &GetPoolData_StonfiResult{}, @@ -1449,6 +1452,47 @@ func DecodeGetNominatorDataResult(stack tlb.VmStack) (resultType string, resultA return "GetNominatorDataResult", result, err } +type GetOrderDataResult struct { + MultisigAddress tlb.MsgAddress + OrderSeqno tlb.Int256 + Threshold uint8 + SentForExecution bool + Signers tlb.Hashmap[tlb.Uint8, tlb.MsgAddress] + ApprovalsMask tlb.Int256 + ApprovalsNum uint8 + ExpirationDate uint64 + Order MultisigOrder +} + +func GetOrderData(ctx context.Context, executor Executor, reqAccountID ton.AccountID) (string, any, error) { + stack := tlb.VmStack{} + + // MethodID = 123832 for "get_order_data" method + errCode, stack, err := executor.RunSmcMethodByID(ctx, reqAccountID, 123832, 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){DecodeGetOrderDataResult} { + s, r, err := f(stack) + if err == nil { + return s, r, nil + } + } + return "", nil, fmt.Errorf("can not decode outputs") +} + +func DecodeGetOrderDataResult(stack tlb.VmStack) (resultType string, resultAny any, err error) { + if len(stack) < 9 || (stack[0].SumType != "VmStkSlice") || (stack[1].SumType != "VmStkTinyInt" && stack[1].SumType != "VmStkInt") || (stack[2].SumType != "VmStkTinyInt" && stack[2].SumType != "VmStkInt") || (stack[3].SumType != "VmStkTinyInt" && stack[3].SumType != "VmStkInt") || (stack[4].SumType != "VmStkCell") || (stack[5].SumType != "VmStkTinyInt" && stack[5].SumType != "VmStkInt") || (stack[6].SumType != "VmStkTinyInt" && stack[6].SumType != "VmStkInt") || (stack[7].SumType != "VmStkTinyInt" && stack[7].SumType != "VmStkInt") || (stack[8].SumType != "VmStkCell") { + return "", nil, fmt.Errorf("invalid stack format") + } + var result GetOrderDataResult + err = stack.Unmarshal(&result) + return "GetOrderDataResult", result, err +} + type GetParams_WhalesNominatorResult struct { Enabled bool UpdatesEnables bool diff --git a/abi/interfaces.go b/abi/interfaces.go index 44b169d..225f56b 100644 --- a/abi/interfaces.go +++ b/abi/interfaces.go @@ -418,6 +418,10 @@ var methodInvocationOrder = []MethodDescription{ Name: "get_nft_data", InvokeFn: GetNftData, }, + { + Name: "get_order_data", + InvokeFn: GetOrderData, + }, { Name: "get_params", InvokeFn: GetParams, @@ -890,7 +894,9 @@ var knownContracts = map[ton.Bits256]knownContractDescription{ }, ton.MustParseHash("a01e057fbd4288402b9898d78d67bd4e90254c93c5866879bc2d1d12865436bc"): { contractInterfaces: []ContractInterface{MultisigOrderV2}, - getMethods: []InvokeFn{}, + getMethods: []InvokeFn{ + GetOrderData, + }, }, ton.MustParseHash("a0cfc2c48aee16a271f2cfc0b7382d81756cecb1017d077faaab3bb602f6868c"): { contractInterfaces: []ContractInterface{WalletV1R1}, @@ -916,7 +922,9 @@ var knownContracts = map[ton.Bits256]knownContractDescription{ }, ton.MustParseHash("d3d14da9a627f0ec3533341829762af92b9540b21bf03665fac09c2b46eabbac"): { contractInterfaces: []ContractInterface{MultisigV2}, - getMethods: []InvokeFn{}, + getMethods: []InvokeFn{ + GetMultisigData, + }, }, ton.MustParseHash("d4902fcc9fad74698fa8e353220a68da0dcf72e32bcb2eb9ee04217c17d3062c"): { contractInterfaces: []ContractInterface{WalletV1R2}, diff --git a/abi/parser/generator.go b/abi/parser/generator.go index 56dc3d6..0f605c3 100644 --- a/abi/parser/generator.go +++ b/abi/parser/generator.go @@ -308,6 +308,14 @@ func (g *Generator) checkType(s string) (string, error) { if typeName, prs := g.knownTypes[strings.ToLower(s)]; prs { return typeName.Name, nil } + if strings.HasPrefix(s, "Hashmap") { + t := strings.Split(s, " ") + subType, err := g.checkType(t[2]) + if err != nil { + return "", err + } + return fmt.Sprintf("tlb.%v[tlb.Uint%s, %v]", t[0], t[1], subType), nil + } _, ok := g.newTlbTypes[s] if !ok { return "", fmt.Errorf("not defined type: %s", s) diff --git a/abi/schemas/multisig.xml b/abi/schemas/multisig.xml index 59172b9..f10db5b 100644 --- a/abi/schemas/multisig.xml +++ b/abi/schemas/multisig.xml @@ -15,6 +15,7 @@ d3d14da9a627f0ec3533341829762af92b9540b21bf03665fac09c2b46eabbac + Unauthorized proposer Invalid new order Not enough ton @@ -29,6 +30,7 @@ a01e057fbd4288402b9898d78d67bd4e90254c93c5866879bc2d1d12865436bc + Unauthorized init Already inited Unauthorized sign @@ -48,6 +50,21 @@ + + + + msgaddress + int256 + uint8 + bool + Hashmap 8 MsgAddress + int256 + uint8 + uint64 + MultisigOrder + + + new_order#f718510f query_id:uint64 order_seqno:uint256