diff --git a/abi-tolk/contracts_errors.go b/abi-tolk/contracts_errors.go new file mode 100644 index 00000000..81cb0153 --- /dev/null +++ b/abi-tolk/contracts_errors.go @@ -0,0 +1,89 @@ +package abitolk + +// Code autogenerated. DO NOT EDIT. + +import () + +var contractErrors = map[ContractInterface]map[int32]string{ + TonCocoonClient: {1000: "ERROR_OLD_MESSAGE", + 1001: "ERROR_LOW_SMC_BALANCE", + 1003: "ERROR_LOW_MSG_VALUE", + 1005: "ERROR_SIGNED_MSG_FORMAT_MISMATCH", + 1006: "ERROR_CLOSED", + 1007: "ERROR_BAD_SIGNATURE", + 1009: "ERROR_EXPECTED_OWNER", + 1010: "ERROR_EXPECTED_MESSAGE_FROM_OWNER", + 1011: "ERROR_NOT_UNLOCKED_YET", + 1015: "ERROR_EXPECTED_MY_ADDRESS", + }, + TonCocoonProxy: {1003: "ERROR_LOW_MSG_VALUE", + 1005: "ERROR_SIGNED_MSG_FORMAT_MISMATCH", + 1006: "ERROR_CLOSED", + 1007: "ERROR_BAD_SIGNATURE", + 1010: "ERROR_EXPECTED_MESSAGE_FROM_OWNER", + 1011: "ERROR_NOT_UNLOCKED_YET", + 1013: "ERROR_UNKNOWN_TEXT_OP", + 1014: "ERROR_CONTRACT_ADDRESS_MISMATCH", + 1015: "ERROR_EXPECTED_MY_ADDRESS", + }, + TonCocoonRoot: {1004: "ERROR_MSG_FORMAT_MISMATCH", + 1005: "ERROR_SIGNED_MSG_FORMAT_MISMATCH", + 1007: "ERROR_BAD_SIGNATURE", + 1010: "ERROR_EXPECTED_MESSAGE_FROM_OWNER", + 2000: "ERROR_UNKNOWN_PROXY_TYPE", + }, + TonCocoonWallet: {1005: "ERROR_SIGNED_MSG_FORMAT_MISMATCH", + 1007: "ERROR_BAD_SIGNATURE", + }, + TonCocoonWorker: {1000: "ERROR_OLD_MESSAGE", + 1003: "ERROR_LOW_MSG_VALUE", + 1005: "ERROR_SIGNED_MSG_FORMAT_MISMATCH", + 1006: "ERROR_CLOSED", + 1007: "ERROR_BAD_SIGNATURE", + 1010: "ERROR_EXPECTED_MESSAGE_FROM_OWNER", + 1015: "ERROR_EXPECTED_MY_ADDRESS", + }, + TonTep74JettonMinter: {73: "ERR_NOT_FROM_ADMIN", + 74: "ERR_UNAUTHORIZED_BURN", + 75: "ERR_NOT_ENOUGH_AMOUNT_TO_RESPOND", + }, + TonTep74JettonWallet: {333: "ERR_WRONG_WORKCHAIN", + 705: "ERR_NOT_FROM_OWNER", + 706: "ERR_NOT_ENOUGH_BALANCE", + 707: "ERR_INVALID_WALLET", + 708: "ERR_INVALID_PAYLOAD", + 709: "ERR_NOT_ENOUGH_TON", + }, +} + +var defaultExitCodes = map[int32]string{ + 0: "Ok", + 1: "Ok", + 2: "Stack underflow", + 3: "Stack overflow", + 4: "Integer overflow or division by zero", + 5: "Integer out of expected range", + 6: "Invalid opcode", + 7: "Type check error", + 8: "Cell overflow", + 9: "Cell underflow", + 10: "Dictionary error", + 11: "Unknown error", + 12: "Impossible situation error", + 13: "Out of gas error", + -14: "Out of gas error", +} + +func GetContractError(interfaces []ContractInterface, code int32) *string { + for _, i := range interfaces { + if errors, ok := contractErrors[i]; ok { + if msg, ok := errors[code]; ok { + return &msg + } + } + } + if msg, ok := defaultExitCodes[code]; ok { + return &msg + } + return nil +} diff --git a/abi-tolk/generator.go b/abi-tolk/generator.go new file mode 100644 index 00000000..a0387cde --- /dev/null +++ b/abi-tolk/generator.go @@ -0,0 +1,131 @@ +//go:build ignore + +package main + +import ( + "fmt" + "go/format" + "io/fs" + "os" + "path/filepath" + "strings" + + parser "github.com/tonkeeper/tongo/abi-tolk/parser" + "github.com/tonkeeper/tongo/tolk" +) + +const HEADER = `package abitolk +// Code autogenerated. DO NOT EDIT. + +import ( +%v +) + +` +const SCHEMAS_PATH = "schemas/" + +func mergeMethods(abis []tolk.ABI) (map[string][]parser.GetMethodWithAbi, error) { + methodsMap := map[string][]parser.GetMethodWithAbi{} + for _, abi := range abis { + for _, method := range abi.GetMethods { + current, ok := methodsMap[method.Name] + if !ok { + methodsMap[method.Name] = append(methodsMap[method.Name], parser.GetMethodWithAbi{ + ABI: abi, + GetMethod: method, + }) + continue + } + if len(current[0].GetMethod.Parameters) != len(method.Parameters) { + return nil, fmt.Errorf("method '%s' has a version with input params, it has to be defined with golang_name to avoid collision", method.Name) + } + current = append(current, parser.GetMethodWithAbi{ + ABI: abi, + GetMethod: method, + }) + methodsMap[method.Name] = current + } + } + + return methodsMap, nil +} + +func main() { + var abi []tolk.ABI + filepath.Walk(SCHEMAS_PATH, func(path string, info fs.FileInfo, err error) error { + if !strings.HasSuffix(info.Name(), ".json") { + return nil + } + scheme, err := os.ReadFile(path) + if err != nil { + panic(err) + } + a, err := parser.ParseABI(scheme) + if err != nil { + panic(err) + } + abi = append(abi, a) + return nil + }) + + uniqueGetMethods, err := mergeMethods(abi) + if err != nil { + panic(err) + } + + gen := parser.NewGenerator(abi, uniqueGetMethods) + types := gen.CollectedTypes() + msgDecoder := gen.GenerateMsgDecoder() + + getMethods, simpleMethods, err := gen.GetMethods() + if err != nil { + panic(err) + } + invocationOrder, err := gen.RenderInvocationOrderList(simpleMethods) + if err != nil { + panic(err) + } + messagesMD, err := gen.RenderMessagesMD() + if err != nil { + panic(err) + } + payloads, err := gen.RenderPayload() + if err != nil { + panic(err) + } + contractErrors, err := gen.RenderContractErrors() + if err != nil { + panic(err) + } + + for _, f := range [][]string{ + {types, "types.go", `"github.com/tonkeeper/tongo/tlb"`, `"fmt"`, `"encoding/json"`}, + {msgDecoder, "messages_generated.go", `"github.com/tonkeeper/tongo/tlb"`}, + {getMethods, "get_methods.go", `"context"`, `"fmt"`, `"github.com/tonkeeper/tongo/ton"`, `"github.com/tonkeeper/tongo/tlb"`}, + {invocationOrder, "interfaces.go", `"github.com/tonkeeper/tongo/ton"`}, + {payloads, "payload_msg_types.go", `"github.com/tonkeeper/tongo/boc"`, `"github.com/tonkeeper/tongo/tlb"`}, + {contractErrors, "contracts_errors.go"}, + } { + file, err := os.Create(f[1]) + if err != nil { + panic(err) + } + code := []byte(fmt.Sprintf(HEADER, strings.Join(f[2:], "\n")) + f[0]) + formatedCode, err := format.Source(code) + if err != nil { + formatedCode = code + //panic(err) + } + _, err = file.Write(formatedCode) + if err != nil { + panic(err) + } + err = file.Close() + if err != nil { + panic(err) + } + } + if err := os.WriteFile("messages.md", []byte(messagesMD), 0644); err != nil { + panic(err) + } +} diff --git a/abi-tolk/get_methods.go b/abi-tolk/get_methods.go new file mode 100644 index 00000000..bd6c5de7 --- /dev/null +++ b/abi-tolk/get_methods.go @@ -0,0 +1,784 @@ +package abitolk + +// Code autogenerated. DO NOT EDIT. + +import ( + "context" + "fmt" + "github.com/tonkeeper/tongo/tlb" + "github.com/tonkeeper/tongo/ton" +) + +var KnownGetMethodsDecoder = map[string][]func(tlb.VmStack) (string, any, error){ + "model_hash_is_valid": {DecodeTonCocoonRoot_ModelHashIsValidResult}, + "get_wallet_data": {DecodeTonTep74JettonWallet_GetWalletDataResult}, + "get_cocoon_proxy_data": {DecodeTonCocoonProxy_GetCocoonProxyDataResult}, + "last_proxy_seqno": {DecodeTonCocoonRoot_LastProxySeqnoResult}, + "proxy_hash_is_valid": {DecodeTonCocoonRoot_ProxyHashIsValidResult}, + "get_owner_address": {DecodeTonCocoonWallet_GetOwnerAddressResult}, + "get_cocoon_worker_data": {DecodeTonCocoonWorker_GetCocoonWorkerDataResult}, + "get_wallet_address": {DecodeTonTep74JettonMinter_GetWalletAddressResult}, + "get_pool_data": {DecodeTonStonfiV1Pool_GetPoolDataResult, DecodeTonStonfiV2PoolConstProduct_GetPoolDataResult, DecodeTonStonfiV2PoolStableSwap_GetPoolDataResult, DecodeTonStonfiV2PoolWeightedStableSwap_GetPoolDataResult}, + "get_cur_params": {DecodeTonCocoonRoot_GetCurParamsResult}, + "get_public_key": {DecodeTonCocoonWallet_GetPublicKeyResult}, + "get_jetton_data": {DecodeTonTep74JettonMinter_GetJettonDataResult}, + "worker_hash_is_valid": {DecodeTonCocoonRoot_WorkerHashIsValidResult}, + "seqno": {DecodeTonCocoonWallet_SeqnoResult}, + "get_lp_account_address": {DecodeTonStonfiV2Pool_GetLpAccountAddressResult, DecodeTonStonfiV2PoolConstProduct_GetLpAccountAddressResult, DecodeTonStonfiV2PoolStableSwap_GetLpAccountAddressResult, DecodeTonStonfiV2PoolWeightedStableSwap_GetLpAccountAddressResult}, + "get_cocoon_client_data": {DecodeTonCocoonClient_GetCocoonClientDataResult}, + "get_cocoon_data": {DecodeTonCocoonRoot_GetCocoonDataResult}, +} + +var KnownSimpleGetMethods = map[int][]func(ctx context.Context, executor Executor, reqAccountID ton.AccountID) (string, any, error){ + 65647: {LastProxySeqno}, + 75156: {GetCocoonClientData}, + 78748: {GetPublicKey}, + 81689: {GetPoolData}, + 85143: {Seqno}, + 89457: {GetCurParams}, + 96613: {GetCocoonData}, + 97026: {GetWalletData}, + 97687: {GetCocoonProxyData}, + 106029: {GetJettonData}, + 106427: {GetCocoonWorkerData}, + 114619: {GetOwnerAddress}, +} + +var resultTypes = []interface{}{ + &TonCocoonRoot_ModelHashIsValidResult{}, + &TonTep74JettonWallet_GetWalletDataResult{}, + &TonCocoonProxy_GetCocoonProxyDataResult{}, + &TonCocoonRoot_LastProxySeqnoResult{}, + &TonCocoonRoot_ProxyHashIsValidResult{}, + &TonCocoonWallet_GetOwnerAddressResult{}, + &TonCocoonWorker_GetCocoonWorkerDataResult{}, + &TonTep74JettonMinter_GetWalletAddressResult{}, + &TonStonfiV1Pool_GetPoolDataResult{}, + &TonStonfiV2PoolConstProduct_GetPoolDataResult{}, + &TonStonfiV2PoolStableSwap_GetPoolDataResult{}, + &TonStonfiV2PoolWeightedStableSwap_GetPoolDataResult{}, + &TonCocoonRoot_GetCurParamsResult{}, + &TonCocoonWallet_GetPublicKeyResult{}, + &TonTep74JettonMinter_GetJettonDataResult{}, + &TonCocoonRoot_WorkerHashIsValidResult{}, + &TonCocoonWallet_SeqnoResult{}, + &TonStonfiV2PoolConstProduct_GetLpAccountAddressResult{}, + &TonStonfiV2PoolStableSwap_GetLpAccountAddressResult{}, + &TonStonfiV2PoolWeightedStableSwap_GetLpAccountAddressResult{}, + &TonStonfiV2Pool_GetLpAccountAddressResult{}, + &TonCocoonClient_GetCocoonClientDataResult{}, + &TonCocoonRoot_GetCocoonDataResult{}, +} + +type Executor interface { + RunSmcMethodByID(ctx context.Context, accountID ton.AccountID, methodID int, params tlb.VmStack) (uint32, tlb.VmStack, error) +} +type TonCocoonRoot_ModelHashIsValidResult struct { + Value tlb.Int257 +} + +func ModelHashIsValid(ctx context.Context, executor Executor, reqAccountID ton.AccountID, hash tlb.Int257) (string, any, error) { + stack := tlb.VmStack{} + var ( + val tlb.VmStackValue + err error + ) + val = tlb.VmStackValue{SumType: "VmStkInt", VmStkInt: hash} + stack.Put(val) + + // MethodID = 72587 for "model_hash_is_valid" method + errCode, stack, err := executor.RunSmcMethodByID(ctx, reqAccountID, 72587, 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){DecodeTonCocoonRoot_ModelHashIsValidResult} { + s, r, err := f(stack) + if err == nil { + return s, r, nil + } + } + return "", nil, fmt.Errorf("can not decode outputs") +} + +func DecodeTonCocoonRoot_ModelHashIsValidResult(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 TonCocoonRoot_ModelHashIsValidResult + err = stack.Unmarshal(&result) + return "TonCocoonRoot_ModelHashIsValidResult", result, err +} + +type TonTep74JettonWallet_GetWalletDataResult = TonTep74JettonWalletDataReply + +func GetWalletData(ctx context.Context, executor Executor, reqAccountID ton.AccountID) (string, any, error) { + stack := tlb.VmStack{} + + // MethodID = 97026 for "get_wallet_data" method + errCode, stack, err := executor.RunSmcMethodByID(ctx, reqAccountID, 97026, 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){DecodeTonTep74JettonWallet_GetWalletDataResult} { + s, r, err := f(stack) + if err == nil { + return s, r, nil + } + } + return "", nil, fmt.Errorf("can not decode outputs") +} + +func DecodeTonTep74JettonWallet_GetWalletDataResult(stack tlb.VmStack) (resultType string, resultAny any, err error) { + if len(stack) != 4 || (stack[0].SumType != "VmStkTinyInt" && stack[0].SumType != "VmStkInt") || (stack[1].SumType != "VmStkSlice") || (stack[2].SumType != "VmStkSlice") || (stack[3].SumType != "VmStkCell") { + return "", nil, fmt.Errorf("invalid stack format") + } + var result TonTep74JettonWallet_GetWalletDataResult + err = stack.Unmarshal(&result) + return "TonTep74JettonWallet_GetWalletDataResult", result, err +} + +type TonCocoonProxy_GetCocoonProxyDataResult struct { + Field struct { + Field0 tlb.MsgAddress + Field1 tlb.Int257 + Field2 tlb.MsgAddress + Field3 tlb.Int257 + Field4 tlb.VarUInteger16 + Field5 tlb.VarUInteger16 + Field6 tlb.Int257 + Field7 tlb.Int257 + Field8 tlb.Int257 + Field9 tlb.VarUInteger16 + Field10 tlb.VarUInteger16 + Field11 tlb.Int257 + } `vmStackHint:"tensor"` +} + +func GetCocoonProxyData(ctx context.Context, executor Executor, reqAccountID ton.AccountID) (string, any, error) { + stack := tlb.VmStack{} + + // MethodID = 97687 for "get_cocoon_proxy_data" method + errCode, stack, err := executor.RunSmcMethodByID(ctx, reqAccountID, 97687, 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){DecodeTonCocoonProxy_GetCocoonProxyDataResult} { + s, r, err := f(stack) + if err == nil { + return s, r, nil + } + } + return "", nil, fmt.Errorf("can not decode outputs") +} + +func DecodeTonCocoonProxy_GetCocoonProxyDataResult(stack tlb.VmStack) (resultType string, resultAny any, err error) { + if len(stack) != 12 || (stack[0].SumType != "VmStkSlice") || (stack[1].SumType != "VmStkTinyInt" && stack[1].SumType != "VmStkInt") || (stack[2].SumType != "VmStkSlice") || (stack[3].SumType != "VmStkTinyInt" && stack[3].SumType != "VmStkInt") || (stack[4].SumType != "VmStkTinyInt" && stack[4].SumType != "VmStkInt") || (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 != "VmStkTinyInt" && stack[8].SumType != "VmStkInt") || (stack[9].SumType != "VmStkTinyInt" && stack[9].SumType != "VmStkInt") || (stack[10].SumType != "VmStkTinyInt" && stack[10].SumType != "VmStkInt") || (stack[11].SumType != "VmStkTinyInt" && stack[11].SumType != "VmStkInt") { + return "", nil, fmt.Errorf("invalid stack format") + } + var result TonCocoonProxy_GetCocoonProxyDataResult + err = stack.Unmarshal(&result) + return "TonCocoonProxy_GetCocoonProxyDataResult", result, err +} + +type TonCocoonRoot_LastProxySeqnoResult struct { + Value tlb.Int257 +} + +func LastProxySeqno(ctx context.Context, executor Executor, reqAccountID ton.AccountID) (string, any, error) { + stack := tlb.VmStack{} + + // MethodID = 65647 for "last_proxy_seqno" method + errCode, stack, err := executor.RunSmcMethodByID(ctx, reqAccountID, 65647, 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){DecodeTonCocoonRoot_LastProxySeqnoResult} { + s, r, err := f(stack) + if err == nil { + return s, r, nil + } + } + return "", nil, fmt.Errorf("can not decode outputs") +} + +func DecodeTonCocoonRoot_LastProxySeqnoResult(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 TonCocoonRoot_LastProxySeqnoResult + err = stack.Unmarshal(&result) + return "TonCocoonRoot_LastProxySeqnoResult", result, err +} + +type TonCocoonRoot_ProxyHashIsValidResult struct { + Value tlb.Int257 +} + +func ProxyHashIsValid(ctx context.Context, executor Executor, reqAccountID ton.AccountID, hash tlb.Int257) (string, any, error) { + stack := tlb.VmStack{} + var ( + val tlb.VmStackValue + err error + ) + val = tlb.VmStackValue{SumType: "VmStkInt", VmStkInt: hash} + stack.Put(val) + + // MethodID = 129381 for "proxy_hash_is_valid" method + errCode, stack, err := executor.RunSmcMethodByID(ctx, reqAccountID, 129381, 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){DecodeTonCocoonRoot_ProxyHashIsValidResult} { + s, r, err := f(stack) + if err == nil { + return s, r, nil + } + } + return "", nil, fmt.Errorf("can not decode outputs") +} + +func DecodeTonCocoonRoot_ProxyHashIsValidResult(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 TonCocoonRoot_ProxyHashIsValidResult + err = stack.Unmarshal(&result) + return "TonCocoonRoot_ProxyHashIsValidResult", result, err +} + +type TonCocoonWallet_GetOwnerAddressResult struct { + Value tlb.MsgAddress +} + +func GetOwnerAddress(ctx context.Context, executor Executor, reqAccountID ton.AccountID) (string, any, error) { + stack := tlb.VmStack{} + + // MethodID = 114619 for "get_owner_address" method + errCode, stack, err := executor.RunSmcMethodByID(ctx, reqAccountID, 114619, 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){DecodeTonCocoonWallet_GetOwnerAddressResult} { + s, r, err := f(stack) + if err == nil { + return s, r, nil + } + } + return "", nil, fmt.Errorf("can not decode outputs") +} + +func DecodeTonCocoonWallet_GetOwnerAddressResult(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 TonCocoonWallet_GetOwnerAddressResult + err = stack.Unmarshal(&result) + return "TonCocoonWallet_GetOwnerAddressResult", result, err +} + +type TonCocoonWorker_GetCocoonWorkerDataResult struct { + Field struct { + Field0 tlb.MsgAddress + Field1 tlb.MsgAddress + Field2 tlb.Int257 + Field3 tlb.Int257 + Field4 tlb.Int257 + } `vmStackHint:"tensor"` +} + +func GetCocoonWorkerData(ctx context.Context, executor Executor, reqAccountID ton.AccountID) (string, any, error) { + stack := tlb.VmStack{} + + // MethodID = 106427 for "get_cocoon_worker_data" method + errCode, stack, err := executor.RunSmcMethodByID(ctx, reqAccountID, 106427, 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){DecodeTonCocoonWorker_GetCocoonWorkerDataResult} { + s, r, err := f(stack) + if err == nil { + return s, r, nil + } + } + return "", nil, fmt.Errorf("can not decode outputs") +} + +func DecodeTonCocoonWorker_GetCocoonWorkerDataResult(stack tlb.VmStack) (resultType string, resultAny any, err error) { + if len(stack) != 5 || (stack[0].SumType != "VmStkSlice") || (stack[1].SumType != "VmStkSlice") || (stack[2].SumType != "VmStkTinyInt" && stack[2].SumType != "VmStkInt") || (stack[3].SumType != "VmStkTinyInt" && stack[3].SumType != "VmStkInt") || (stack[4].SumType != "VmStkTinyInt" && stack[4].SumType != "VmStkInt") { + return "", nil, fmt.Errorf("invalid stack format") + } + var result TonCocoonWorker_GetCocoonWorkerDataResult + err = stack.Unmarshal(&result) + return "TonCocoonWorker_GetCocoonWorkerDataResult", result, err +} + +type TonTep74JettonMinter_GetWalletAddressResult struct { + Value tlb.MsgAddress +} + +func GetWalletAddress(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 = 103289 for "get_wallet_address" method + errCode, stack, err := executor.RunSmcMethodByID(ctx, reqAccountID, 103289, 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){DecodeTonTep74JettonMinter_GetWalletAddressResult} { + s, r, err := f(stack) + if err == nil { + return s, r, nil + } + } + return "", nil, fmt.Errorf("can not decode outputs") +} + +func DecodeTonTep74JettonMinter_GetWalletAddressResult(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 TonTep74JettonMinter_GetWalletAddressResult + err = stack.Unmarshal(&result) + return "TonTep74JettonMinter_GetWalletAddressResult", result, err +} + +type TonStonfiV1Pool_GetPoolDataResult = TonStonfiV1GetPoolDataStonfiV1 + +type TonStonfiV2PoolConstProduct_GetPoolDataResult = TonStonfiV2GetPoolDataStonfiV2 + +type TonStonfiV2PoolStableSwap_GetPoolDataResult = TonStonfiV2GetPoolDataStonfiV2StableSwap + +type TonStonfiV2PoolWeightedStableSwap_GetPoolDataResult = TonStonfiV2GetPoolDataStonfiV2WeightedStableSwap + +func GetPoolData(ctx context.Context, executor Executor, reqAccountID ton.AccountID) (string, any, error) { + stack := tlb.VmStack{} + + // MethodID = 81689 for "get_pool_data" method + errCode, stack, err := executor.RunSmcMethodByID(ctx, reqAccountID, 81689, 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){DecodeTonStonfiV1Pool_GetPoolDataResult, DecodeTonStonfiV2PoolConstProduct_GetPoolDataResult, DecodeTonStonfiV2PoolStableSwap_GetPoolDataResult, DecodeTonStonfiV2PoolWeightedStableSwap_GetPoolDataResult} { + s, r, err := f(stack) + if err == nil { + return s, r, nil + } + } + return "", nil, fmt.Errorf("can not decode outputs") +} + +func DecodeTonStonfiV1Pool_GetPoolDataResult(stack tlb.VmStack) (resultType string, resultAny any, err error) { + if len(stack) != 10 || (stack[0].SumType != "VmStkTinyInt" && stack[0].SumType != "VmStkInt") || (stack[1].SumType != "VmStkTinyInt" && stack[1].SumType != "VmStkInt") || (stack[2].SumType != "VmStkSlice") || (stack[3].SumType != "VmStkSlice") || (stack[4].SumType != "VmStkTinyInt" && stack[4].SumType != "VmStkInt") || (stack[5].SumType != "VmStkTinyInt" && stack[5].SumType != "VmStkInt") || (stack[6].SumType != "VmStkTinyInt" && stack[6].SumType != "VmStkInt") || (stack[7].SumType != "VmStkSlice") || (stack[8].SumType != "VmStkTinyInt" && stack[8].SumType != "VmStkInt") || (stack[9].SumType != "VmStkTinyInt" && stack[9].SumType != "VmStkInt") { + return "", nil, fmt.Errorf("invalid stack format") + } + var result TonStonfiV1Pool_GetPoolDataResult + err = stack.Unmarshal(&result) + return "TonStonfiV1Pool_GetPoolDataResult", result, err +} + +func DecodeTonStonfiV2PoolConstProduct_GetPoolDataResult(stack tlb.VmStack) (resultType string, resultAny any, err error) { + if len(stack) != 12 || (stack[0].SumType != "VmStkTinyInt" && stack[0].SumType != "VmStkInt") || (stack[1].SumType != "VmStkSlice") || (stack[2].SumType != "VmStkTinyInt" && stack[2].SumType != "VmStkInt") || (stack[3].SumType != "VmStkTinyInt" && stack[3].SumType != "VmStkInt") || (stack[4].SumType != "VmStkTinyInt" && stack[4].SumType != "VmStkInt") || (stack[5].SumType != "VmStkSlice") || (stack[6].SumType != "VmStkSlice") || (stack[7].SumType != "VmStkTinyInt" && stack[7].SumType != "VmStkInt") || (stack[8].SumType != "VmStkTinyInt" && stack[8].SumType != "VmStkInt") || (stack[9].SumType != "VmStkSlice") || (stack[10].SumType != "VmStkTinyInt" && stack[10].SumType != "VmStkInt") || (stack[11].SumType != "VmStkTinyInt" && stack[11].SumType != "VmStkInt") { + return "", nil, fmt.Errorf("invalid stack format") + } + var result TonStonfiV2PoolConstProduct_GetPoolDataResult + err = stack.Unmarshal(&result) + return "TonStonfiV2PoolConstProduct_GetPoolDataResult", result, err +} + +func DecodeTonStonfiV2PoolStableSwap_GetPoolDataResult(stack tlb.VmStack) (resultType string, resultAny any, err error) { + if len(stack) != 13 || (stack[0].SumType != "VmStkTinyInt" && stack[0].SumType != "VmStkInt") || (stack[1].SumType != "VmStkSlice") || (stack[2].SumType != "VmStkTinyInt" && stack[2].SumType != "VmStkInt") || (stack[3].SumType != "VmStkTinyInt" && stack[3].SumType != "VmStkInt") || (stack[4].SumType != "VmStkTinyInt" && stack[4].SumType != "VmStkInt") || (stack[5].SumType != "VmStkSlice") || (stack[6].SumType != "VmStkSlice") || (stack[7].SumType != "VmStkTinyInt" && stack[7].SumType != "VmStkInt") || (stack[8].SumType != "VmStkTinyInt" && stack[8].SumType != "VmStkInt") || (stack[9].SumType != "VmStkSlice") || (stack[10].SumType != "VmStkTinyInt" && stack[10].SumType != "VmStkInt") || (stack[11].SumType != "VmStkTinyInt" && stack[11].SumType != "VmStkInt") || (stack[12].SumType != "VmStkTinyInt" && stack[12].SumType != "VmStkInt") { + return "", nil, fmt.Errorf("invalid stack format") + } + var result TonStonfiV2PoolStableSwap_GetPoolDataResult + err = stack.Unmarshal(&result) + return "TonStonfiV2PoolStableSwap_GetPoolDataResult", result, err +} + +func DecodeTonStonfiV2PoolWeightedStableSwap_GetPoolDataResult(stack tlb.VmStack) (resultType string, resultAny any, err error) { + if len(stack) != 16 || (stack[0].SumType != "VmStkTinyInt" && stack[0].SumType != "VmStkInt") || (stack[1].SumType != "VmStkSlice") || (stack[2].SumType != "VmStkTinyInt" && stack[2].SumType != "VmStkInt") || (stack[3].SumType != "VmStkTinyInt" && stack[3].SumType != "VmStkInt") || (stack[4].SumType != "VmStkTinyInt" && stack[4].SumType != "VmStkInt") || (stack[5].SumType != "VmStkSlice") || (stack[6].SumType != "VmStkSlice") || (stack[7].SumType != "VmStkTinyInt" && stack[7].SumType != "VmStkInt") || (stack[8].SumType != "VmStkTinyInt" && stack[8].SumType != "VmStkInt") || (stack[9].SumType != "VmStkSlice") || (stack[10].SumType != "VmStkTinyInt" && stack[10].SumType != "VmStkInt") || (stack[11].SumType != "VmStkTinyInt" && stack[11].SumType != "VmStkInt") || (stack[12].SumType != "VmStkTinyInt" && stack[12].SumType != "VmStkInt") || (stack[13].SumType != "VmStkTinyInt" && stack[13].SumType != "VmStkInt") || (stack[14].SumType != "VmStkTinyInt" && stack[14].SumType != "VmStkInt") || (stack[15].SumType != "VmStkSlice") { + return "", nil, fmt.Errorf("invalid stack format") + } + var result TonStonfiV2PoolWeightedStableSwap_GetPoolDataResult + err = stack.Unmarshal(&result) + return "TonStonfiV2PoolWeightedStableSwap_GetPoolDataResult", result, err +} + +type TonCocoonRoot_GetCurParamsResult struct { + Field struct { + Field0 tlb.Int257 + Field1 tlb.Int257 + Field2 tlb.Int257 + Field3 tlb.Int257 + Field4 tlb.Int257 + Field5 tlb.Int257 + Field6 tlb.Int257 + Field7 tlb.Int257 + Field8 tlb.Int257 + Field9 tlb.Int257 + Field10 tlb.Int257 + Field11 tlb.Int257 + Field12 tlb.Int257 + Field13 tlb.Int257 + } `vmStackHint:"tensor"` +} + +func GetCurParams(ctx context.Context, executor Executor, reqAccountID ton.AccountID) (string, any, error) { + stack := tlb.VmStack{} + + // MethodID = 89457 for "get_cur_params" method + errCode, stack, err := executor.RunSmcMethodByID(ctx, reqAccountID, 89457, 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){DecodeTonCocoonRoot_GetCurParamsResult} { + s, r, err := f(stack) + if err == nil { + return s, r, nil + } + } + return "", nil, fmt.Errorf("can not decode outputs") +} + +func DecodeTonCocoonRoot_GetCurParamsResult(stack tlb.VmStack) (resultType string, resultAny any, err error) { + if len(stack) != 14 || (stack[0].SumType != "VmStkTinyInt" && stack[0].SumType != "VmStkInt") || (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 != "VmStkTinyInt" && stack[4].SumType != "VmStkInt") || (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 != "VmStkTinyInt" && stack[8].SumType != "VmStkInt") || (stack[9].SumType != "VmStkTinyInt" && stack[9].SumType != "VmStkInt") || (stack[10].SumType != "VmStkTinyInt" && stack[10].SumType != "VmStkInt") || (stack[11].SumType != "VmStkTinyInt" && stack[11].SumType != "VmStkInt") || (stack[12].SumType != "VmStkTinyInt" && stack[12].SumType != "VmStkInt") || (stack[13].SumType != "VmStkTinyInt" && stack[13].SumType != "VmStkInt") { + return "", nil, fmt.Errorf("invalid stack format") + } + var result TonCocoonRoot_GetCurParamsResult + err = stack.Unmarshal(&result) + return "TonCocoonRoot_GetCurParamsResult", result, err +} + +type TonCocoonWallet_GetPublicKeyResult struct { + Value tlb.Int257 +} + +func GetPublicKey(ctx context.Context, executor Executor, reqAccountID ton.AccountID) (string, any, error) { + stack := tlb.VmStack{} + + // MethodID = 78748 for "get_public_key" method + errCode, stack, err := executor.RunSmcMethodByID(ctx, reqAccountID, 78748, 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){DecodeTonCocoonWallet_GetPublicKeyResult} { + s, r, err := f(stack) + if err == nil { + return s, r, nil + } + } + return "", nil, fmt.Errorf("can not decode outputs") +} + +func DecodeTonCocoonWallet_GetPublicKeyResult(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 TonCocoonWallet_GetPublicKeyResult + err = stack.Unmarshal(&result) + return "TonCocoonWallet_GetPublicKeyResult", result, err +} + +type TonTep74JettonMinter_GetJettonDataResult = TonTep74JettonDataReply + +func GetJettonData(ctx context.Context, executor Executor, reqAccountID ton.AccountID) (string, any, error) { + stack := tlb.VmStack{} + + // MethodID = 106029 for "get_jetton_data" method + errCode, stack, err := executor.RunSmcMethodByID(ctx, reqAccountID, 106029, 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){DecodeTonTep74JettonMinter_GetJettonDataResult} { + s, r, err := f(stack) + if err == nil { + return s, r, nil + } + } + return "", nil, fmt.Errorf("can not decode outputs") +} + +func DecodeTonTep74JettonMinter_GetJettonDataResult(stack tlb.VmStack) (resultType string, resultAny any, err error) { + if len(stack) != 5 || (stack[0].SumType != "VmStkTinyInt" && stack[0].SumType != "VmStkInt") || (stack[1].SumType != "VmStkTinyInt" && stack[1].SumType != "VmStkInt") || (stack[2].SumType != "VmStkSlice") || (stack[3].SumType != "VmStkCell") || (stack[4].SumType != "VmStkCell") { + return "", nil, fmt.Errorf("invalid stack format") + } + var result TonTep74JettonMinter_GetJettonDataResult + err = stack.Unmarshal(&result) + return "TonTep74JettonMinter_GetJettonDataResult", result, err +} + +type TonCocoonRoot_WorkerHashIsValidResult struct { + Value tlb.Int257 +} + +func WorkerHashIsValid(ctx context.Context, executor Executor, reqAccountID ton.AccountID, hash tlb.Int257) (string, any, error) { + stack := tlb.VmStack{} + var ( + val tlb.VmStackValue + err error + ) + val = tlb.VmStackValue{SumType: "VmStkInt", VmStkInt: hash} + stack.Put(val) + + // MethodID = 95753 for "worker_hash_is_valid" method + errCode, stack, err := executor.RunSmcMethodByID(ctx, reqAccountID, 95753, 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){DecodeTonCocoonRoot_WorkerHashIsValidResult} { + s, r, err := f(stack) + if err == nil { + return s, r, nil + } + } + return "", nil, fmt.Errorf("can not decode outputs") +} + +func DecodeTonCocoonRoot_WorkerHashIsValidResult(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 TonCocoonRoot_WorkerHashIsValidResult + err = stack.Unmarshal(&result) + return "TonCocoonRoot_WorkerHashIsValidResult", result, err +} + +type TonCocoonWallet_SeqnoResult struct { + Value tlb.Int257 +} + +func Seqno(ctx context.Context, executor Executor, reqAccountID ton.AccountID) (string, any, error) { + stack := tlb.VmStack{} + + // MethodID = 85143 for "seqno" method + errCode, stack, err := executor.RunSmcMethodByID(ctx, reqAccountID, 85143, 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){DecodeTonCocoonWallet_SeqnoResult} { + s, r, err := f(stack) + if err == nil { + return s, r, nil + } + } + return "", nil, fmt.Errorf("can not decode outputs") +} + +func DecodeTonCocoonWallet_SeqnoResult(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 TonCocoonWallet_SeqnoResult + err = stack.Unmarshal(&result) + return "TonCocoonWallet_SeqnoResult", result, err +} + +type TonStonfiV2PoolConstProduct_GetLpAccountAddressResult = TonStonfiV2GetLpAccountAddressResult + +type TonStonfiV2PoolStableSwap_GetLpAccountAddressResult = TonStonfiV2GetLpAccountAddressResult + +type TonStonfiV2PoolWeightedStableSwap_GetLpAccountAddressResult = TonStonfiV2GetLpAccountAddressResult + +type TonStonfiV2Pool_GetLpAccountAddressResult = TonStonfiV2GetLpAccountAddressResult + +func GetLpAccountAddress(ctx context.Context, executor Executor, reqAccountID ton.AccountID, owner tlb.MsgAddress) (string, any, error) { + stack := tlb.VmStack{} + var ( + val tlb.VmStackValue + err error + ) + val, err = tlb.TlbStructToVmCellSlice(owner) + if err != nil { + return "", nil, err + } + stack.Put(val) + + // MethodID = 87316 for "get_lp_account_address" method + errCode, stack, err := executor.RunSmcMethodByID(ctx, reqAccountID, 87316, 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){DecodeTonStonfiV2Pool_GetLpAccountAddressResult, DecodeTonStonfiV2PoolConstProduct_GetLpAccountAddressResult, DecodeTonStonfiV2PoolStableSwap_GetLpAccountAddressResult, DecodeTonStonfiV2PoolWeightedStableSwap_GetLpAccountAddressResult} { + s, r, err := f(stack) + if err == nil { + return s, r, nil + } + } + return "", nil, fmt.Errorf("can not decode outputs") +} + +func DecodeTonStonfiV2Pool_GetLpAccountAddressResult(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 TonStonfiV2Pool_GetLpAccountAddressResult + err = stack.Unmarshal(&result) + return "TonStonfiV2Pool_GetLpAccountAddressResult", result, err +} + +func DecodeTonStonfiV2PoolConstProduct_GetLpAccountAddressResult(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 TonStonfiV2PoolConstProduct_GetLpAccountAddressResult + err = stack.Unmarshal(&result) + return "TonStonfiV2PoolConstProduct_GetLpAccountAddressResult", result, err +} + +func DecodeTonStonfiV2PoolStableSwap_GetLpAccountAddressResult(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 TonStonfiV2PoolStableSwap_GetLpAccountAddressResult + err = stack.Unmarshal(&result) + return "TonStonfiV2PoolStableSwap_GetLpAccountAddressResult", result, err +} + +func DecodeTonStonfiV2PoolWeightedStableSwap_GetLpAccountAddressResult(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 TonStonfiV2PoolWeightedStableSwap_GetLpAccountAddressResult + err = stack.Unmarshal(&result) + return "TonStonfiV2PoolWeightedStableSwap_GetLpAccountAddressResult", result, err +} + +type TonCocoonClient_GetCocoonClientDataResult struct { + Field struct { + Field0 tlb.MsgAddress + Field1 tlb.MsgAddress + Field2 tlb.Int257 + Field3 tlb.Int257 + Field4 tlb.Int257 + Field5 tlb.Int257 + Field6 tlb.Int257 + Field7 tlb.Int257 + Field8 tlb.Int257 + } `vmStackHint:"tensor"` +} + +func GetCocoonClientData(ctx context.Context, executor Executor, reqAccountID ton.AccountID) (string, any, error) { + stack := tlb.VmStack{} + + // MethodID = 75156 for "get_cocoon_client_data" method + errCode, stack, err := executor.RunSmcMethodByID(ctx, reqAccountID, 75156, 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){DecodeTonCocoonClient_GetCocoonClientDataResult} { + s, r, err := f(stack) + if err == nil { + return s, r, nil + } + } + return "", nil, fmt.Errorf("can not decode outputs") +} + +func DecodeTonCocoonClient_GetCocoonClientDataResult(stack tlb.VmStack) (resultType string, resultAny any, err error) { + if len(stack) != 9 || (stack[0].SumType != "VmStkSlice") || (stack[1].SumType != "VmStkSlice") || (stack[2].SumType != "VmStkTinyInt" && stack[2].SumType != "VmStkInt") || (stack[3].SumType != "VmStkTinyInt" && stack[3].SumType != "VmStkInt") || (stack[4].SumType != "VmStkTinyInt" && stack[4].SumType != "VmStkInt") || (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 != "VmStkTinyInt" && stack[8].SumType != "VmStkInt") { + return "", nil, fmt.Errorf("invalid stack format") + } + var result TonCocoonClient_GetCocoonClientDataResult + err = stack.Unmarshal(&result) + return "TonCocoonClient_GetCocoonClientDataResult", result, err +} + +type TonCocoonRoot_GetCocoonDataResult struct { + Field struct { + Field0 tlb.Int257 + Field1 tlb.Int257 + Field2 tlb.Int257 + Field3 tlb.Int257 + Field4 tlb.Int257 + Field5 tlb.Int257 + Field6 tlb.Int257 + Field7 tlb.Int257 + Field8 tlb.Int257 + Field9 tlb.Any + } `vmStackHint:"tensor"` +} + +func GetCocoonData(ctx context.Context, executor Executor, reqAccountID ton.AccountID) (string, any, error) { + stack := tlb.VmStack{} + + // MethodID = 96613 for "get_cocoon_data" method + errCode, stack, err := executor.RunSmcMethodByID(ctx, reqAccountID, 96613, 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){DecodeTonCocoonRoot_GetCocoonDataResult} { + s, r, err := f(stack) + if err == nil { + return s, r, nil + } + } + return "", nil, fmt.Errorf("can not decode outputs") +} + +func DecodeTonCocoonRoot_GetCocoonDataResult(stack tlb.VmStack) (resultType string, resultAny any, err error) { + if len(stack) != 10 || (stack[0].SumType != "VmStkTinyInt" && stack[0].SumType != "VmStkInt") || (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 != "VmStkTinyInt" && stack[4].SumType != "VmStkInt") || (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 != "VmStkTinyInt" && stack[8].SumType != "VmStkInt") || (stack[9].SumType != "VmStkSlice") { + return "", nil, fmt.Errorf("invalid stack format") + } + var result TonCocoonRoot_GetCocoonDataResult + err = stack.Unmarshal(&result) + return "TonCocoonRoot_GetCocoonDataResult", result, err +} diff --git a/abi-tolk/inspect.go b/abi-tolk/inspect.go new file mode 100644 index 00000000..8db98dbf --- /dev/null +++ b/abi-tolk/inspect.go @@ -0,0 +1,319 @@ +package abitolk + +import ( + "context" + "encoding/json" + "fmt" + + "github.com/tonkeeper/tongo/boc" + codePkg "github.com/tonkeeper/tongo/code" + "github.com/tonkeeper/tongo/tlb" + "github.com/tonkeeper/tongo/ton" + "github.com/tonkeeper/tongo/utils" +) + +type MethodInvocation struct { + Result any + TypeHint string +} + +type ContractDescription struct { + // Interfaces is a list of interfaces implemented by a contract. + ContractInterfaces []ContractInterface + GetMethods []MethodInvocation + MethodsInspected int +} + +func (d ContractDescription) hasAllResults(results []string) bool { + for _, r := range results { + found := false + for _, m := range d.GetMethods { + if m.TypeHint == r { + found = true + break + } + } + if !found { + return false + } + } + return true +} + +type libResolver interface { + GetLibraries(ctx context.Context, libraryList []ton.Bits256) (map[ton.Bits256]*boc.Cell, error) +} + +type contractInspector struct { + knownMethods []MethodDescription + knownInterfaces []InterfaceDescription + scanAllMethods bool + libResolver libResolver +} + +type InspectorOptions struct { + additionalMethods []MethodDescription + knownInterfaces []InterfaceDescription + scanAllMethods bool + libResolver libResolver +} + +type contractNamespace uint32 + +type ContractInterface uint32 + +func toTlbContractInterface(ifaces []ContractInterface) []tlb.ContractInterface { + res := make([]tlb.ContractInterface, len(ifaces)) + for i, iface := range ifaces { + res[i] = tlb.ContractInterface(iface) + } + return res +} + +func fromTlbContractInterface(ifaces []tlb.ContractInterface) []ContractInterface { + res := make([]ContractInterface, len(ifaces)) + for i, iface := range ifaces { + res[i] = ContractInterface(iface) + } + return res +} + +func (c ContractInterface) getNamespace() contractNamespace { + return namespaceByInterface[c] +} + +func (c ContractInterface) MarshalJSON() ([]byte, error) { + return json.Marshal(c.String()) +} + +func (c *ContractInterface) UnmarshalJSON(data []byte) error { + var s string + if err := json.Unmarshal(data, &s); err != nil { + return err + } + + *c = ContractInterfaceFromString(s) + return nil +} + +func (c ContractInterface) Implements(other ContractInterface) bool { + if c == other { + return true + } + return c.recursiveImplements(other) +} + +type InvokeFn func(ctx context.Context, executor Executor, reqAccountID ton.AccountID) (string, any, error) + +// MethodDescription describes a particular method and provides a function to execute it. +type MethodDescription struct { + Name string + // InvokeFn executes this method on a contract and returns parsed execution results. + InvokeFn InvokeFn +} + +type knownContractDescription struct { + contractInterfaces []ContractInterface + getMethods []InvokeFn +} + +type InterfaceDescription struct { + Name ContractInterface + Results []string +} + +type InspectorOption func(o *InspectorOptions) + +func InspectWithAdditionalMethods(list []MethodDescription) InspectorOption { + return func(o *InspectorOptions) { + o.additionalMethods = list + } +} + +func InspectWithAdditionalInterfaces(list []InterfaceDescription) InspectorOption { + return func(o *InspectorOptions) { + o.knownInterfaces = list + } +} +func InspectWithAllMethods() InspectorOption { + return func(o *InspectorOptions) { + o.scanAllMethods = true + } +} + +func InspectWithLibraryResolver(resolver libResolver) InspectorOption { + return func(o *InspectorOptions) { + o.libResolver = resolver + } +} + +func NewContractInspector(opts ...InspectorOption) *contractInspector { + options := &InspectorOptions{} + for _, o := range opts { + o(options) + } + return &contractInspector{ + knownMethods: append(methodInvocationOrder, options.additionalMethods...), + knownInterfaces: append(contractInterfacesOrder, options.knownInterfaces...), + scanAllMethods: options.scanAllMethods, + libResolver: options.libResolver, + } +} + +// InspectContract tries to execute all known get method on a contract and returns a summary. +// The contract is not provided directly, +// instead, it is expected that "executor" has been created with knowledge of the contract's code and data. +// Executor must be ready to execute multiple different methods and must not rely on a particular order of execution. +func (ci contractInspector) InspectContract(ctx context.Context, code []byte, executor Executor, reqAccountID ton.AccountID) (*ContractDescription, error) { + if len(code) == 0 { + return &ContractDescription{}, nil + } + desc := ContractDescription{} + info, err := GetCodeInfo(ctx, code, ci.libResolver) + if err != nil { + return nil, err + } + + if contract, ok := knownContracts[info.Hash]; ok { //for known contracts we just need to run get methods + desc.ContractInterfaces = contract.contractInterfaces + for _, method := range contract.getMethods { + desc.MethodsInspected += 1 + typeHint, result, err := method(ctx, executor, reqAccountID) + if err != nil { + return &desc, nil + } + desc.GetMethods = append(desc.GetMethods, MethodInvocation{ + Result: result, + TypeHint: typeHint, + }) + } + return &desc, nil + } + + for _, method := range ci.knownMethods { + // let's avoid running get methods that we know don't exist + if !ci.scanAllMethods && !info.isMethodOkToTry(method.Name) { + continue + } + desc.MethodsInspected += 1 + typeHint, result, err := method.InvokeFn(ctx, executor, reqAccountID) + if err != nil { + continue + } + desc.GetMethods = append(desc.GetMethods, MethodInvocation{ + Result: result, + TypeHint: typeHint, + }) + } + for _, iface := range ci.knownInterfaces { + if desc.hasAllResults(iface.Results) { + desc.ContractInterfaces = append(desc.ContractInterfaces, iface.Name) + } + } + + return &desc, nil +} + +type CodeInfo struct { + Hash ton.Bits256 + Methods map[int64]struct{} +} + +func (i CodeInfo) isMethodOkToTry(name string) bool { + if i.Methods == nil { + return false + } + methodID := utils.MethodIdFromName(name) + _, ok := i.Methods[int64(methodID)] + return ok +} + +func GetCodeInfo(ctx context.Context, code []byte, resolver libResolver) (*CodeInfo, error) { + cells, err := boc.DeserializeBoc(code) + if err != nil { + return nil, err + } + if len(cells) == 0 { + return nil, fmt.Errorf("failed to find a root cell") + } + root := cells[0] + libHashes, err := codePkg.FindLibraries(root) + if err != nil { + return nil, fmt.Errorf("failed while looking for libraries inside cell: %w", err) + } + var libs map[ton.Bits256]*boc.Cell + if len(libHashes) > 0 { + if resolver == nil { + return nil, fmt.Errorf("found libraries in cell, but no resolver provided") + } + libs, err = resolver.GetLibraries(ctx, libHashes) + if err != nil { + return nil, fmt.Errorf("failed to fetch libraries: %w", err) + } + } + h, err := root.Hash256() + if err != nil { + return nil, err + } + root.ResetCounters() + if root.IsLibrary() { + hash, err := root.GetLibraryHash() + if err != nil { + return nil, err + } + cell, ok := libs[ton.Bits256(hash)] + if !ok { + return nil, fmt.Errorf("library not found") + } + root = cell + } + c, err := root.NextRef() + if err != nil { + // we are OK, if there is no information about get methods + return &CodeInfo{Hash: h}, nil + } + if c.IsLibrary() { + hash, err := c.GetLibraryHash() + if err != nil { + return nil, err + } + cell, ok := libs[ton.Bits256(hash)] + if !ok { + return nil, fmt.Errorf("library not found") + } + c = cell + } + type GetMethods struct { + Hashmap tlb.Hashmap[tlb.Uint19, boc.Cell] + } + var getMethods GetMethods + decoder := tlb.NewDecoder().WithLibraryResolver(func(hash tlb.Bits256) (*boc.Cell, error) { + if resolver == nil { + return nil, fmt.Errorf("failed to fetch library: no resolver provided") + } + cell, ok := libs[ton.Bits256(hash)] + if ok { + return cell, nil + } + localLibs, err := resolver.GetLibraries(ctx, []ton.Bits256{ton.Bits256(hash)}) + if err != nil { + return nil, err + } + if len(localLibs) == 0 { + return nil, fmt.Errorf("library not found") + } + return localLibs[ton.Bits256(hash)], nil + }) + + err = decoder.Unmarshal(c, &getMethods) + if err != nil { + // we are OK, if there is no information about get methods + return &CodeInfo{Hash: h}, nil + } + keys := getMethods.Hashmap.Keys() + methods := make(map[int64]struct{}, len(keys)) + for _, key := range keys { + methods[int64(key)] = struct{}{} + } + return &CodeInfo{Hash: h, Methods: methods}, nil +} diff --git a/abi-tolk/inspect_test.go b/abi-tolk/inspect_test.go new file mode 100644 index 00000000..4eb0116f --- /dev/null +++ b/abi-tolk/inspect_test.go @@ -0,0 +1,219 @@ +package abitolk + +import ( + "context" + "encoding/hex" + "fmt" + "reflect" + "testing" + + "github.com/tonkeeper/tongo/code" + "github.com/tonkeeper/tongo/liteapi" + "github.com/tonkeeper/tongo/txemulator" + + "github.com/tonkeeper/tongo/boc" + "github.com/tonkeeper/tongo/ton" + "github.com/tonkeeper/tongo/tvm" +) + +const ( + mainnetConfig = "te6ccgICBKsAAQAAtpkAAAIBIAABBJUCB7AAAAEAAgRuAgEgAAMAkwIBIAAEAGkCASAABQAWAgEgAAYADgIBIAAHAAwCASAACAAKAQEgAAkAQFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVAQEgAAsAQDMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzAQFIAA0AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgEgAA8AEQEBSAAQAEDlZ1T4NCb2mwkme9h2rJfESCE0W34ma9lWp7+/uY3zXAEBWAASAQHAABMCASAAFAAVABW+AAADvLNnDcFVUAAVv////7y9GpSiABACASAAFwBgAgEgABgAPwIBIAAZABsBASAAGgAaxAAAAAIAAAAAAAAALgEBIAAcAgPNQAAdAD4CASAARAArAgEgAEUASAIB1ABTAFMAASAAASACASAASQBMAgEgAEoAVwABWAABSAIBIABXAE4AAUgCASAAUwBTAAEgAAEgAgEgACwAOQIBIAAtADICASAATgBXAgEgAFMAUwABIAABIAABSAIBIABOAE4CASAAUwBTAAEgAAEgAgEgAFMAUwABIAABIAIBIAA6AFgCAUgAUwBTAAEgAAEgAAHUAAOooAIBIABAAFwBASAAQQIBIABCAFkCAtkAQwBUAgEgAEQAUQIBIABFAEgCAdQAUwBTAAE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mPmrhYUEAAEAAACA32IABoAGwEDfl4AIgEBIAAcAQEgACABAcAAHQIBagAeAB8Aib9XMZWjfzvPw3sGF0f3UsEcwyEEu7ue/bWPCj3C1NJdAgEAG8jRoUufDZBtmCMw8ItF21EfGFTKKdC52Dqx2KiEjCDAIABDv2gnjujq/MkM7nBXrQtARITIFwjfO5JIq0VAiXOGTzq0AwGD6ZuBuutlVjSoRYvwfEX6BjPL23mMs7nT5CQnYNZtYUePRBrDlM+U0Ng6djQDZU14CdL1tn3xbxfsVO+BWpK2WYAEACEAg6AJiI5MfROcghrShIqORPcKyAc1RTUjL/kTjvaiu0A14IAAAAAAAAAAAAAAABE6Jddhm5Z/wACLk7L7FX+L7Ykv0AEDoGAAIwIBIAAkACUAW6vgAAAAAAca/UmNAAAR4O6XV9q/0dnz73f38iwsZnjoTmHeqNHXfIisHyZx9sEAW6v/////wAca/UmNAAAR4O6XV9q/0dnz73f38iwsZnjoTmHeqNHXfIisHyZx9sECASAAKAApAgEgAEAAQQIBIAAqACsCASAAMQAyAgEgACwALQEBSAAwAQEgAC4BASAALwBAVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVUAQDMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzAEDBPkSoNoJxvMA1kM9gncikPodLov3jSJy4UHJ4IsulrQIBIAAzADQCASAANwA4AQEgADUBASAANgBA7+cdE4YK+qaurq9jb5FoSH+A8QMbC/jZOa5J0+p/faAAUwH//////////////////////////////////////////4AAAACAAAABQAEBIAA5AQEgADoAEkO5rKAEO5rKAAEBwAA7AgEgADwAPQIC1wA+AD8AFb////+8vRqUogAQABW+RA3gtrPFMWUAQAAPvvLNnDcFVUACASAAQgBDAgEgAEQARQIBIABPAFACASAAWwBcAgEgAEYARwIBIABLAEwBASAASAEBIABKAQHAAEkAt9BTLudOzwEBAnAAKtiftocOhhpk4QsHt8jHSWwV/O7nxvFyZKUf75zoqiN3Bfb/JZk7D9mvTw7EDHU5B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BIAKYApkCASACmgKbAIG+48b24m9Mm9wyr0AQ3By/4XYOzYwrqo1ENPbfIYJoVaAAAAAAAAAAAAAAAARBqTGRqDSHeRfNLAc1oJ46PgD9lACBvrBPHHIowG5pGgSVX8n4KmOaX+EEjvnOSBRlQvVsJWPwAAAAAAAAAAAAAAAHoNPEL3lbottwfUIa3THe2p8f7BgAgb6scGDsgJPh9GBgXO9IGRSXOqKlL3B8sFPsiTQX0jYfgAAAAAAAAAAAAAAAAxVOZAxW0COpiJBCaiTRp3L1o4soAgEgAp4CnwCBv2nMYYa/nc54baaRlQoPpBaoy+uaznXR59ZsMkY9a2IEAAAAAAAAAAAAAAAAkX6U8H2fb/NVlW0aUWDftf5vWIcAgb8PX4U5vzalEQU+BbsCXM2Vnt/Ree+YZqRbbfClZ4gsCAAAAAAAAAAAAAAAAQ5MbjCnjSowWaVQIzVYyf1Ec8IaAIG/Ebg96xQ8jVKbl7QQJ1k8pClQLmO1Ci68nuNfbLdm9uQAAAAAAAAAAAAAAAJVK5kuwJosG/++7b0VIZ6XyyzF3g==" +) + +func Test_contractInspector_InspectContract(t *testing.T) { + + //mainnetConfig, _ := boc.DeserializeBocBase64(mainnetConfig) + //testnetConfig, _ := boc.DeserializeBocBase64(testnetConfig) + + tests := []struct { + name string + code string + account string + data string + hasLibrary bool + emulatorConfig *boc.Cell + want []ContractInterface + wantValidate func(d *ContractDescription) error + }{ + { + name: "cocoon root", + account: "EQCns7bYSp0igFvS1wpb5wsZjCKCV19MD5AVzI4EyxsnU73k", + code: "b5ee9c72010221010004a1000114ff00f4a413f4bcf2c80b0102016202030202ca040502012017180201200607020162151602d1d3b68bb7ec831c02497c13816a87e0be820822625a02d825c3ec0807434c0c05c6c2456f83e900c0074c7c86084268491f02ea497c0f834cffb51343c0814edf1c17cb8fc8aa08438d2c7182ea7ce81f4fff462c21004e0c1fd0581a938c39425fc06040dd18510d4e0809020158111201662a82108d94a79aba9d3a07d3ffd1588307f45b3006a48e9a2a8210c146134dba9e3a07d3ffd18b08028307f41606a4e30e16e20a003806c8f40015f40013cb1ff400f400c9c85004cf16cb1f12ccccc9ed5401fa2a821092b11c18ba9d3a07d3ffd1018307f45b3006a48ee42a821071860e80ba9f3a07d3ffd18b0840168307f41606a48ec72a82103c41d0b2ba9e3a07d3ffd150058307f45b3006a48ead2a8210927c7cb5ba8e1d3a27d30001c000f2e3ecd30601aa02d721d103a45427058020f41602a4e30e10461023e2e21046e20b04fe2a82106d49eaf2ba9e3a07d31fd150048020f45b3006a48fe52a82109c7924baba8f592a8210c52ed8d4ba8eca2a820a2fa189ba8e3f3a09f01d6c333337371110fa00fa00d31fd31ffa00fa00d11117a40ea40f10de10cd105c104b109a108910781067103645400311170312011117011115f01ce30ee30d081036e30de20c0d0e0f01ee2a8210a2370f61ba8e692a821011aefd51ba963a07d4d1fb048e562a8210563c1d96ba9c35355b3603d16d6d6d6d04a48e392a82104f7c5789ba8e105f086c12d4d4d101ed54fb04f018db31e00a8210c4a1ae54ba973606fa40d105a49537f2c3f406e210281026103412e20608103459e208e30d106810006e3a09f01d3b3b1114fa00fa00d11117a40ea40f10de1c1d0b11170b109a108910781067105610451034102302111502011117011115f01c00623a07d31f20d30001c000f2e3ecd30601aa02d721d153158020f40e6fa131c000f2d7d0c801cf16c9d040158020f41606a400081036102300603a09f01d5f031113d4d4d4d11117a40ea40f10de10cd10bc10ab109a108910781067105610451034031115031117f01c0045d410812b2c9a640082801b83801e46582ac678b00fd0165b509658fe59fe4c1837d804020148131400691cf232c1c044440072c7c7b2c7c732c01402be8094023e8085b2c7c532c7c4b2c7f2c7f2c7f2c7c07e80807e80bd003d003d00326000553434c1c07000fcb8fc34c7f4c7f4c03e803e8034c7f4c7f4c7f4c7f4c7f4c7fe803e803d013d013d010c200043d6a00e800fd20017a027a02698ffa027a021803698fea180833882b0822881a0811c0047f642805678b2804678b0b65ffe482646580a801fd0100fd01659f89658f8965ffe66664c020120191a0025bfcb2f6a26878100833af83c183fa0737d098c0201481b1c0201201d1e0017b01bfb51343c080411d7c1e00025b2e2fb51343c080409d7c1e0c1fd039be84c600081b7ae3da89a1e040d8e3e03a7072e0a8e002dd672c6405a1f202b12267c454dd672c6013a1f202132275c44edd672a620da1f203226fc420f020ae208c206a886100201581f200025af04f6a2687810081baf83c183fa0737d098c00027acb2f6a26878101a9aad80f80eaf81b6312a8440", + data: "b5ee9c7201025301000f6500024b801cf2d92ae46c8da46ab425cd6bd2c8df012a80d8d7e09fe29111cba0f077ec66c00000075001020409c0000000f803040506035f030000000e000000ef08a08980001388000001f400009c4000009c400000a8c000005460281bf08eb00281bf08eb00780f101102016a0708004ea0000000022139312e3130382e342e31313a353232322039312e3130382e342e31313a38383838020148090a0043a009d1a1a2b504c2ba9f4b5ff176f42282a58f82f4a2f5013af4ece182920f3a5a700041bf6cfa8a802d4f0de619ba9500d69de2c1e9c56379e4379b0465fa2159a77715d10041bf446561784f2d2e3dd8485e62fb633b49df7fa25b85dd60f8cfd07213d13256250201200b0c0042bfbdb5a40cf2aa89face97204c00ade5ea80fa8466c955238e584ff11ed0d2aab20041bf498402666a867ef57dc6c962a1485b15125cf2f5ece55b05320bd719a5ea579f0201200d0e0041bf18cbe9b165d548f2fa93ead658799dd7388269d446b68c676b01e23ac4b7f1120041bf118aaa2fee29e538b1560a5de6fc745308ae7359b2a92cabfd79c0c974ff0c1a0114ff00f4a413f4bcf2c80b1c0114ff00f4a413f4bcf2c80b120114ff00f4a413f4bcf2c80b3002016213140202ca15160025a13f77da89a1f481f481a7ffa603a67fa8606102012017360049a9f21402b3c5940233c585b2fff2413232c05400fe80807e80b2cfc4b2c7c4b2fff333326002e3d3b68bb7ec831c02497c138144ca87e0be8208401a39de02d82407434c0c05c6c2497c1383e900c00f4c7c86084268491f02ea497c17834cffb51343e903e9034fff4c074cff50c08b000bcb4fb8a208428102b4a2e8a60843d7c9a8daeac78c08c0c81a08409bb5fd96eb8c097c27cb0fd2181902aa3b54357624f01b6f2201d33ffa40d10b821005f5e100bcf2e3ebf8281bc705f2e3f72af01d5f0b6c223253b7a15302a85023a1a8098210a040ad28bae30f035045c85006cf165004cf1612cbffcb01cb3fccc9ed541a1b00ae07821005f5e100bcf2e3eb5171c705f2e3f201fa40d10470fb02504371530510680510480348886d82104d725d2c801840947003c8cb0558cf1601fa02cb6a17cb1f15cb3f5003cf16cb01cb3ff400c901fb00f018db3100b4516ab9f2e3e80870fb02225140104754332a481350ab821008e7d036c8cb1f5003fa0201fa0201cf1670830602c91282104d725d2c801840947003c8cb0558cf1601fa02cb6a17cb1f15cb3f5003cf16cb01cb3ff400c901fb0000c232385148bbf2e3e872820898968070fb02225140104754332a481350ab821008e7d036c8cb1f5003fa0201fa0201cf1670830602c91282104d725d2c801840947003c8cb0558cf1601fa02cb6a17cb1f15cb3f5003cf16cb01cb3ff400c901fb000201621d1e0202ca1f200041a0fb2fda89a1f481a7fff481a603f401f401a63fa861e03abe06a174be10aa400902012021360201484b2f03c5d3b68bb7ec831c02497c138144ca87e0be820822625a02d82407434c0c05c6c2497c1383e900c00f4c7c86084268491f02ea497c1781c08b0c0250c34cfc077bb51343e9034fffe9034c07e803e8034c7f50c0aa084135c974b2eb8c3d41d910150c4e22232402ea3a3b07fa408042d721d30001c000956cc1d1db31e0d401d001d129f01d303155c06d6d6df01cf828245449430170530010575e334106c85006cf165004cf1612cbffcb01cb3fccc921c8cb0113f40012f400cb00c9f9007074c8cb02ca07cbffc9d01dc705f2e3f60bd31f01821008e7d036bae30f252602ca2a821065448ff4ba8ed72a82107610e6ebba8e453a3c07fa40d10a821005f5e100bef2e3eb21c002f2d3ee5188a170fb028210c59a7cd3801054205a7003c8cb0558cf1601fa02cb6a18cb1f5240cb3fc971fb00077004f018e30e102710261025e30d105727280036c85008cf1616cbff5004cf1612cb0101fa0201fa02cb1fccc9ed540078fa00fa00fa40d124c002f2d3ee5033a051a1a170fb028210c59a7cd3801050d27003c8cb0558cf1601fa02cb6a1bcb1f5250cb3fc971fb005094f018001230353738f2c3f4102501f82a82109713f187ba8e283a3c07fa00fa40d1821005f5e10022a01cbef2e3eb22c002f2d3ee5177a05097a070fb025084f0188ec52a8210636a4391ba8e323d54189726f01b6f2201fa40d10b821005f5e100bef2e3eb22c000f2e3eef8281bc705f2e3f71610574734545a2250baf02de30e10271046445302e210252902dc3a3b07fa40d431d30001c000956cc1d1db31e0d401d001d129f01d6c2155b12d6d6d6df01cf8282554134a4133705470005300109b5e3710461035104a55020bf02722c8cb0112f400f400cb00c9f9007074c8cb02ca07cbffc9d01dc705f2e3f60bd31f2182105cfc6b87bae30f2c2d01f22a8210e511abc7ba8e323d54189726f01b6f2201fa40d10b821005f5e100bef2e3eb22c001f2e3eef8281bc705f2e3f71610574734545a2250baf02d8eba2a8210b51d5a01ba8e2a3a08fa40d10b821005f5e100bef2e3eb22c000f2e3ee51b5c705f2e3f2506415103a5420135448baf02de30e10471046e22a01f20ac0008ee208d307d120c0638e57c0778e400a821005f5e100bef2e3eb21c002f2d3ee51a4c705f2e3f25079a170fb02708210c59a7cd3801053427003c8cb0558cf1601fa02cb6acb1f14cb3fc98306fb009d36383838f2c3f5106710261025e250764330e30d9c3737383838f2c3f406507315e2106710562b004c300a821005f5e100bef2e3eb21c000f2e3ee51a4c705f2e3f205041039480054697052baf02d0024313b0afa00fa40d15099a070fb025074f01801e6218210a35cb580ba945f0ddb31e0218210c68ebc7bba8e59018210f4c354c9ba8e42fa00fa40d123c3029c5318bc93315270de5181a108de51a1a170fb028210c59a7cd3801050d27003c8cb0558cf1601fa02cb6a1bcb1f5250cb3fc971fb005074f0189b30353738f2c3f410271025e2e30d2e006431fa00fa40d151a1a170fb028210c59a7cd3801050d27003c8cb0558cf1601fa02cb6a1bcb1f5250cb3fc971fb005074f01800adba646c4d80013c626a08e1f604a047e030e204e0b3c00d80031c64a2a7424542e1f60504218b34f9a607002007402ae00791960ab19e2c03f40596d5963ea441967f92e3f60003e030e4e0a601c0be0de587dce4e0a60102016231320202ca33340047a04b29da89a1a803a1f481f481a7fe6007a603f401f401a67fa63fa7ffa860211220f0610201203536020120494a02d3d0831c02497c13817687e0be8208401a39de02d8240b434c0c05c6c2497c1783e900c0074c7c86084268491f02ea497c1b834cffb51343500743e903e9034ffcc00f4c07e803e8034cff4c7f4fff50c0422441e0b20843c5cb9b0aeb8c3d245d42151180408fc09fb5523738020158434400b83c3c08fa00fa40d125c300f2d3ee21821005f5e100a0500fbbf2e3eb20821005f5e100a02da0500fbbf2e3e9512da00b70fb0224481326546c24545b222f0201111301111282105cfc6b87c8cb1f58fa0201cf1670830602c912f02d01ec2c82108473b408ba8e68313b08fa00d3fffa40d126c002f2d3ee22821005f5e100a0011110bbf2e3eb21821005f5e100a02ea0011110bbf2e3e951b7c705f2e3f2512aa00b70fb0224481326546c24545b2256120201111001111282105cfc6b87c8cb1f58fa0201cf1670830602c912f02de30e10693901f42c8210c45f9f3bba8e683c09d33ffa40d126c002f2d3ee821005f5e100011110bbf2e3eb821005f5e1002ea0011110bbf2e3e951b7c705f2e3f20b70fb0224481326546924545e222c020111130111128210a35cb580c8cb1f12cb3f715202c92a10ac09108c07106c05104c5033f02df018e30e1039104710363a04fc2c8210a9357034ba8f6e2c82106a1f6a60ba8edc2c8210da068e78ba8e4a3c09fa40d125c000f2e3ee821005f5e100500fbbf2e3eb821005f5e1002da0500fbbf2e3e951a6c705f2e3f15cbcf2e3e966a154411b70fb0224481326546c242b544e302c021112f031e30e104910671046e30d103910371036e30d107910673b3c3d3e02fc2c8210fafa6cc1ba8eec3d2b8210bb63ff93ba8e575419ba27f01b6f2201d33ffa40d126c002f2d3ee821005f5e100011110bbf2e3eb821005f5e1002ea0011110bbf2e3e9531eb9f2e3e8f8281ec705f2e3f7400d2af0330a70fb02544370545500546cf0546bd01111f030e30e10895e3310451034e30d1079107810473f4000943c09fa00fa40d126c002f2d3ee821005f5e100011110bbf2e3eb821005f5e1002ea0011110bbf2e3e951b7c705f2e3f252d2bcf2e3eb0a70fb025443705455005469f0546eb01111f030008a313b08d3fffa40d125c002f2d3ee821005f5e100500fbbf2e3eb821005f5e1002da0500fbbf2e3e951a6c705f2e3f20a70fb025443705455005469d052d05611011111f0300004103601fe2b8210efd711e1ba8e65315418a926f01b6f2201d33ffa40d105c00224c000b0f2d3ee821005f5e100500ebbf2e3eb821005f5e100500ca0500dbbf2e3e9535abbf2e3e8f82812c705f2e3f7440927f033727020820898968021fb022648132654321056105449302e0211111af0319e3939393a3a3af2c3f41079503815e24101ac3c09fa40d125c002f2d3ee821005f5e100500fbbf2e3eb821005f5e1002da0500fbbf2e3e951a6c705f2e3f102c0008e232bf823b9f2e3f3727051bbfb02244813265422132d546d242c0211121ef03210491047e30d4200080750481300803b26f01d105f5f0f71f82358a00a70fb0253b1bc8e1551b1a15313481326544e30547c012c0211121ef0318e12544370546580545e00546db01111f0301049e2020120454602014847480045482102565934c80105003707003c8cb0558cf1601fa02cb6a12cb1fcb3fc98306fb0080053503fa408308d718d401d001d120f9014006f910f2e3ef03d31fd33f5024baf2e3ed01baf2e3ed016f02800691cf232c1c044440072c7c7b2c7c732c01402be8094023e8085b2c7c532c7c4b2c7f2c7f2c7f2c7c07e80807e80bd003d003d00326000553434c1c07000fcb8fc34c7f4c7f4c03e803e8034c7f4c7f4c7f4c7f4c7f4c7fe803e803d013d013d010c200201204b4c0201624d4e0047fe42805678b2804678b0b65ffe482646580a801fd0100fd01659f89658f8965ffe66664c0077ba0f919602a00df404a009f40425967f97ff930420ca891fe900308106e00791960ab19e2c03f40596d42d963e29967eb19e2c279825e8019203f6010201204f50020120515200291c54c20426c2041ec18416c1040ed65b7c0b7c0620002f208431a3af1ef232c7d63e808073c59c20c180b244bc0b60002f20843d30d5327232c7d63e808073c59c20c180b244bc0b60003514c4eee456f83c074433d7c3d485285400ea14c06e64687816dc20", + want: []ContractInterface{ + TonCocoonRoot, + }, + }, + { + name: "cocoon proxy", + account: "EQCZF7z1shg8z-IiOJCYQ7GgIUHDwPidsdwuWd7j12UToPOK", + code: "b5ee9c7201021d0100064b000114ff00f4a413f4bcf2c80b0102016202030202ca04050041a0fb2fda89a1f481a7fff481a603f401f401a63fa861e03abe06a174be10aa400902012006070201481b1c03c5d3b68bb7ec831c02497c138144ca87e0be820822625a02d82407434c0c05c6c2497c1383e900c00f4c7c86084268491f02ea497c1781c08b0c0250c34cfc077bb51343e9034fffe9034c07e803e8034c7f50c0aa084135c974b2eb8c3d41d910150c4e08090a020158151602ea3a3b07fa408042d721d30001c000956cc1d1db31e0d401d001d129f01d303155c06d6d6df01cf828245449430170530010575e334106c85006cf165004cf1612cbffcb01cb3fccc921c8cb0113f40012f400cb00c9f9007074c8cb02ca07cbffc9d01dc705f2e3f60bd31f01821008e7d036bae30f0b0c02c22a821065448ff4ba8ed52a82107610e6ebba8e453a3c07fa40d10a821005f5e100bef2e3eb21c002f2d3ee5188a170fb028210c59a7cd3801054205a7003c8cb0558cf1601fa02cb6a18cb1f5240cb3fc971fb00077004f018e30e10671025e30d0d0e0036c85008cf1616cbff5004cf1612cb0101fa0201fa02cb1fccc9ed540078fa00fa00fa40d124c002f2d3ee5033a051a1a170fb028210c59a7cd3801050d27003c8cb0558cf1601fa02cb6a1bcb1f5250cb3fc971fb005094f018001230353738f2c3f4102501f82a82109713f187ba8e283a3c07fa00fa40d1821005f5e10022a01cbef2e3eb22c002f2d3ee5177a05097a070fb025084f0188ec52a8210636a4391ba8e323d54189726f01b6f2201fa40d10b821005f5e100bef2e3eb22c000f2e3eef8281bc705f2e3f71610574734545a2250baf02de30e10271046445302e210250f02dc3a3b07fa40d431d30001c000956cc1d1db31e0d401d001d129f01d6c2155b12d6d6d6df01cf8282554134a4133705470005300109b5e3710461035104a55020bf02722c8cb0112f400f400cb00c9f9007074c8cb02ca07cbffc9d01dc705f2e3f60bd31f2182105cfc6b87bae30f121301f22a8210e511abc7ba8e323d54189726f01b6f2201fa40d10b821005f5e100bef2e3eb22c001f2e3eef8281bc705f2e3f71610574734545a2250baf02d8eba2a8210b51d5a01ba8e2a3a08fa40d10b821005f5e100bef2e3eb22c000f2e3ee51b5c705f2e3f2506415103a5420135448baf02de30e10471046e21001f20ac0008ee208d307d120c0638e57c0778e400a821005f5e100bef2e3eb21c002f2d3ee51a4c705f2e3f25079a170fb02708210c59a7cd3801053427003c8cb0558cf1601fa02cb6acb1f14cb3fc98306fb009d36383838f2c3f5106710261025e250764330e30d9c3737383838f2c3f406507315e21067105611004c300a821005f5e100bef2e3eb21c000f2e3ee51a4c705f2e3f205041039480054697052baf02d007e31fa00fa40d123c000963c19a070fb028e280a70fb028210c59a7cd3801050d27003c8cb0558cf1601fa02cb6a1bcb1f5250cb3fc970fb001079e25094f01801f2218210a35cb580ba945f0ddb31e0218210c68ebc7bba8e5d018210f4c354c9ba8e42fa00fa40d123c002f2d3ee5318bc93315270de5181a151a1a170fb028210c59a7cd3801050d27003c8cb0558cf1601fa02cb6a1bcb1f5250cb3fc971fb005054f0189d30353738f2c3f4102710351023e21035e30d105714007031fa00fa40d123c002f2d3ee51a1a170fb028210c59a7cd3801050d27003c8cb0558cf1601fa02cb6a1bcb1f5250cb3fc971fb005074f0180201201718020148191a0045482102565934c80105003707003c8cb0558cf1601fa02cb6a12cb1fcb3fc98306fb0080053503fa408308d718d401d001d120f9014006f910f2e3ef03d31fd33f5024baf2e3ed01baf2e3ed016f02800691cf232c1c044440072c7c7b2c7c732c01402be8094023e8085b2c7c532c7c4b2c7f2c7f2c7f2c7c07e80807e80bd003d003d00326000553434c1c07000fcb8fc34c7f4c7f4c03e803e8034c7f4c7f4c7f4c7f4c7f4c7fe803e803d013d013d010c200047fe42805678b2804678b0b65ffe482646580a801fd0100fd01659f89658f8965ffe66664c00cdba5180011c30666c6ce1f60409e03a20debe1ea069e030e3f046a0094005c0be06d8440780031c6bf046b17de5c7e70411312d00e1f60504218b34f9a70020a006e0e00791960ab19e2c03f40596d425963f967f93060df600e4e0a601c0be07e587dce4e0a601", + data: "b5ee9c72010231010009490001d0801cf2d92ae46c8da46ab425cd6bd2c8df012a80d8d7e09fe29111cba0f077ec66df443e46941030a1b70c264fc08617cbd87e680cfff82afcd8f0722a4926396e70029ecedb612a748a016f4b5c296f9c2c66308a095d7d303e40573238132c6c9d4d00692c6ae701025b0300000007000000ef085084800013880000138800001388000013880000a8c00000546021dcd650021dcd65003802030114ff00f4a413f4bcf2c80b040114ff00f4a413f4bcf2c80b0e02016205060202ca07080025a13f77da89a1f481f481a7ffa603a67fa8606102012009140049a9f21402b3c5940233c585b2fff2413232c05400fe80807e80b2cfc4b2c7c4b2fff333326002e3d3b68bb7ec831c02497c138144ca87e0be8208401a39de02d82407434c0c05c6c2497c1383e900c00f4c7c86084268491f02ea497c17834cffb51343e903e9034fff4c074cff50c08b000bcb4fb8a208428102b4a2e8a60843d7c9a8daeac78c08c0c81a08409bb5fd96eb8c097c27cb0fd20a0b02aa3b54357624f01b6f2201d33ffa40d10b821005f5e100bcf2e3ebf8281bc705f2e3f72af01d5f0b6c223253b7a15302a85023a1a8098210a040ad28bae30f035045c85006cf165004cf1612cbffcb01cb3fccc9ed540c0d00ae07821005f5e100bcf2e3eb5171c705f2e3f201fa40d10470fb02504371530510680510480348886d82104d725d2c801840947003c8cb0558cf1601fa02cb6a17cb1f15cb3f5003cf16cb01cb3ff400c901fb00f018db3100b4516ab9f2e3e80870fb02225140104754332a481350ab821008e7d036c8cb1f5003fa0201fa0201cf1670830602c91282104d725d2c801840947003c8cb0558cf1601fa02cb6a17cb1f15cb3f5003cf16cb01cb3ff400c901fb0000c232385148bbf2e3e872820898968070fb02225140104754332a481350ab821008e7d036c8cb1f5003fa0201fa0201cf1670830602c91282104d725d2c801840947003c8cb0558cf1601fa02cb6a17cb1f15cb3f5003cf16cb01cb3ff400c901fb000201620f100202ca11120047a04b29da89a1a803a1f481f481a7fe6007a603f401f401a67fa63fa7ffa860211220f0610201201314020120272802d3d0831c02497c13817687e0be8208401a39de02d8240b434c0c05c6c2497c1783e900c0074c7c86084268491f02ea497c1b834cffb51343500743e903e9034ffcc00f4c07e803e8034cff4c7f4fff50c0422441e0b20843c5cb9b0aeb8c3d245d42151180408fc09fb5521516020158212200b83c3c08fa00fa40d125c002f2d3ee21821005f5e100a0500fbbf2e3eb20821005f5e100a02da0500fbbf2e3e9512da00b70fb0224481326546c24545b222f0201111301111282105cfc6b87c8cb1f58fa0201cf1670830602c912f02d01ec2c82108473b408ba8e68313b08fa00d3fffa40d126c002f2d3ee22821005f5e100a0011110bbf2e3eb21821005f5e100a02ea0011110bbf2e3e951b7c705f2e3f2512aa00b70fb0224481326546c24545b2256120201111001111282105cfc6b87c8cb1f58fa0201cf1670830602c912f02de30e10691701f42c8210c45f9f3bba8e683c09d33ffa40d126c002f2d3ee821005f5e100011110bbf2e3eb821005f5e1002ea0011110bbf2e3e951b7c705f2e3f20b70fb0224481326546924545e222c020111130111128210a35cb580c8cb1f12cb3f715202c92a10ac09108c07106c05104c5033f02df018e30e1039104710361804fc2c8210a9357034ba8f6e2c82106a1f6a60ba8edc2c8210da068e78ba8e4a3c09fa40d125c000f2e3ee821005f5e100500fbbf2e3eb821005f5e1002da0500fbbf2e3e951a6c705f2e3f15cbcf2e3e966a154411b70fb0224481326546c242b544e302c021112f031e30e104910671046e30d103910371036e30d10791067191a1b1c02fc2c8210fafa6cc1ba8eec3d2b8210bb63ff93ba8e575419ba27f01b6f2201d33ffa40d126c002f2d3ee821005f5e100011110bbf2e3eb821005f5e1002ea0011110bbf2e3e9531eb9f2e3e8f8281ec705f2e3f7400d2af0330a70fb02544370545500546cf0546bd01111f030e30e10895e3310451034e30d1079107810471d1e00943c09fa00fa40d126c002f2d3ee821005f5e100011110bbf2e3eb821005f5e1002ea0011110bbf2e3e951b7c705f2e3f252d2bbf2e3eb0a70fb025443705455005469f0546eb01111f030008a313b08d3fffa40d125c002f2d3ee821005f5e100500fbbf2e3eb821005f5e1002da0500fbbf2e3e951a6c705f2e3f20a70fb025443705455005469d052d05611011111f0300004103601fe2b8210efd711e1ba8e65315418a926f01b6f2201d33ffa40d105c00224c000b0f2d3ee821005f5e100500ebbf2e3eb821005f5e100500ca0500dbbf2e3e9535abbf2e3e8f82812c705f2e3f7440927f033727020820898968021fb022648132654321056105449302e0211111af0319e3939393a3a3af2c3f41079503815e21f01ac3c09fa40d125c002f2d3ee821005f5e100500fbbf2e3eb821005f5e1002da0500fbbf2e3e951a6c705f2e3f102c0008e232bf823b9f2e3f3727051bbfb02244813265422132d546d242c0211121ef03210491047e30d2000080750481300803b26f01d105f5f0f71f82358a00a70fb0253b1bc8e1551b1a15313481326544e30547c012c0211121ef0318e12544370546580545e00546db01111f0301049e2020120232402014825260045482102565934c80105003707003c8cb0558cf1601fa02cb6a12cb1fcb3fc98306fb0080053503fa408308d718d401d001d120f9014006f910f2e3ef03d31fd33f5024baf2e3ed01baf2e3ed016f02800691cf232c1c044440072c7c7b2c7c732c01402be8094023e8085b2c7c532c7c4b2c7f2c7f2c7f2c7c07e80807e80bd003d003d00326000553434c1c07000fcb8fc34c7f4c7f4c03e803e8034c7f4c7f4c7f4c7f4c7f4c7fe803e803d013d013d010c20020120292a0201622b2c0047fe42805678b2804678b0b65ffe482646580a801fd0100fd01659f89658f8965ffe66664c0077ba0f919602a00df404a009f40425967f97ff930420ca891fe900308106e00791960ab19e2c03f40596d42d963e29967eb19e2c279825e8019203f6010201202d2e0201202f3000291c54c20426c2041ec18416c1040ed65b7c0b7c0620002f208431a3af1ef232c7d63e808073c59c20c180b244bc0b60002f20843d30d5327232c7d63e808073c59c20c180b244bc0b60003514c4eee456f83c074433d7c3d485285400ea14c06e64687816dc20", + want: []ContractInterface{ + TonCocoonProxy, + }, + }, + { + name: "cocoon client", + account: "EQCIPXuSCiC7qohgSP-nTsUCYmCHBbWLts7Cgpe7YqN6qL98", + code: "b5ee9c720102240100066d000114ff00f4a413f4bcf2c80b0102016202030202ca04050047a04b29da89a1a803a1f481f481a7fe6007a603f401f401a67fa63fa7ffa860211220f06102012006070201201a1b02d3d0831c02497c13817687e0be8208401a39de02d8240b434c0c05c6c2497c1783e900c0074c7c86084268491f02ea497c1b834cffb51343500743e903e9034ffcc00f4c07e803e8034cff4c7f4fff50c0422441e0b20843c5cb9b0aeb8c3d245d42151180408fc09fb5520809020158141500b83c3c08fa00fa40d125c002f2d3ee21821005f5e100a0500fbbf2e3eb20821005f5e100a02da0500fbbf2e3e9512da00b70fb0224481326546c24545b222f0201111301111282105cfc6b87c8cb1f58fa0201cf1670830602c912f02d01ec2c82108473b408ba8e68313b08fa00d3fffa40d126c002f2d3ee22821005f5e100a0011110bbf2e3eb21821005f5e100a02ea0011110bbf2e3e951b7c705f2e3f2512aa00b70fb0224481326546c24545b2256120201111001111282105cfc6b87c8cb1f58fa0201cf1670830602c912f02de30e10690a01f42c8210c45f9f3bba8e683c09d33ffa40d126c002f2d3ee821005f5e100011110bbf2e3eb821005f5e1002ea0011110bbf2e3e951b7c705f2e3f20b70fb0224481326546924545e222c020111130111128210a35cb580c8cb1f12cb3f715202c92a10ac09108c07106c05104c5033f02df018e30e1039104710360b04fc2c8210a9357034ba8f6e2c82106a1f6a60ba8edc2c8210da068e78ba8e4a3c09fa40d125c000f2e3ee821005f5e100500fbbf2e3eb821005f5e1002da0500fbbf2e3e951a6c705f2e3f15cbcf2e3e966a154411b70fb0224481326546c242b544e302c021112f031e30e104910671046e30d103910371036e30d107910670c0d0e0f02fc2c8210fafa6cc1ba8eec3d2b8210bb63ff93ba8e575419ba27f01b6f2201d33ffa40d126c002f2d3ee821005f5e100011110bbf2e3eb821005f5e1002ea0011110bbf2e3e9531eb9f2e3e8f8281ec705f2e3f7400d2af0330a70fb02544370545500546cf0546bd01111f030e30e10895e3310451034e30d107910781047101100943c09fa00fa40d126c002f2d3ee821005f5e100011110bbf2e3eb821005f5e1002ea0011110bbf2e3e951b7c705f2e3f252d2bcf2e3eb0a70fb025443705455005469f0546eb01111f030008a313b08d3fffa40d125c002f2d3ee821005f5e100500fbbf2e3eb821005f5e1002da0500fbbf2e3e951a6c705f2e3f20a70fb025443705455005469d052d05611011111f0300004103601fe2b8210efd711e1ba8e65315418a926f01b6f2201d33ffa40d105c00224c000b0f2d3ee821005f5e100500ebbf2e3eb821005f5e100500ca0500dbbf2e3e9535abbf2e3e8f82812c705f2e3f7440927f033727020820898968021fb022648132654321056105449302e0211111af0319e3939393a3a3af2c3f41079503815e21201ac3c09fa40d125c002f2d3ee821005f5e100500fbbf2e3eb821005f5e1002da0500fbbf2e3e951a6c705f2e3f102c0008e232bf823b9f2e3f3727051bbfb02244813265422132d546d242c0211121ef03210491047e30d1300080750481300803b26f01d105f5f0f71f82358a00a70fb0253b1bc8e1551b1a15313481326544e30547c012c0211121ef0318e12544370546580545e00546db01111f0301049e2020120161702014818190045482102565934c80105003707003c8cb0558cf1601fa02cb6a12cb1fcb3fc98306fb0080053503fa408308d718d401d001d120f9014006f910f2e3ef03d31fd33f5024baf2e3ed01baf2e3ed016f02800691cf232c1c044440072c7c7b2c7c732c01402be8094023e8085b2c7c532c7c4b2c7f2c7f2c7f2c7c07e80807e80bd003d003d00326000553434c1c07000fcb8fc34c7f4c7f4c03e803e8034c7f4c7f4c7f4c7f4c7f4c7fe803e803d013d013d010c200201201c1d0201621e1f0047fe42805678b2804678b0b65ffe482646580a801fd0100fd01659f89658f8965ffe66664c0077ba0f919602a00df404a009f40425967f97ff930420ca891fe900308106e00791960ab19e2c03f40596d42d963e29967eb19e2c279825e8019203f6010201202021020120222300291c54c20426c2041ec18416c1040ed65b7c0b7c0620002f208431a3af1ef232c7d63e808073c59c20c180b244bc0b60002f20843d30d5327232c7d63e808073c59c20c180b244bc0b60003514c4eee456f83c074433d7c3d485285400ea14c06e64687816dc20", + data: "b5ee9c720101030100ce0002658140df8475800000000003daa4eb0000000038ec3110a63f070526befd32265bee4909eb90791926e4d329256646de14ae1560010200c58005229ad6bc35fb51c549a4cdee21158de12f6df8c390ac060dc4ee830cdeefabf00301a79cc950ac1e56bed29c1674e8796a4044d1700d660bc98f9b2612355f6a7039f94ce2439d8a7342b2eaa10e7e3521a7eb06593c8256b3481a37defd429df2005f030000000c000000ef08a08980001388000001f400009c4000009c400000a8c000005460281bf08eb00281bf08eb0008", + want: []ContractInterface{ + TonCocoonClient, + }, + }, + { + name: "cocoon worker", + account: "EQBLNAwS0I3XwiAMcSgTkPjRFA05iSzgZBuo6gpddqI9pFT4", + code: "b5ee9c7201021201000303000114ff00f4a413f4bcf2c80b0102016202030202ca04050025a13f77da89a1f481f481a7ffa603a67fa8606102012006070049a9f21402b3c5940233c585b2fff2413232c05400fe80807e80b2cfc4b2c7c4b2fff333326002e3d3b68bb7ec831c02497c138144ca87e0be8208401a39de02d82407434c0c05c6c2497c1383e900c00f4c7c86084268491f02ea497c17834cffb51343e903e9034fff4c074cff50c08b000bcb4fb8a208428102b4a2e8a60843d7c9a8daeac78c08c0c81a08409bb5fd96eb8c097c27cb0fd208090201580c0d02aa3b54357624f01b6f2201d33ffa40d10b821005f5e100bcf2e3ebf8281bc705f2e3f72af01d5f0b6c223253b7a15302a85023a1a8098210a040ad28bae30f035045c85006cf165004cf1612cbffcb01cb3fccc9ed540a0b00ae07821005f5e100bcf2e3eb5171c705f2e3f201fa40d10470fb02504371530510680510480348886d82104d725d2c801840947003c8cb0558cf1601fa02cb6a17cb1f15cb3f5003cf16cb01cb3ff400c901fb00f018db3100b4516ab9f2e3e80870fb02225140104754332a481350ab821008e7d036c8cb1f5003fa0201fa0201cf1670830602c91282104d725d2c801840947003c8cb0558cf1601fa02cb6a17cb1f15cb3f5003cf16cb01cb3ff400c901fb0000c232385148bbf2e3e872820898968070fb02225140104754332a481350ab821008e7d036c8cb1f5003fa0201fa0201cf1670830602c91282104d725d2c801840947003c8cb0558cf1601fa02cb6a17cb1f15cb3f5003cf16cb01cb3ff400c901fb000201200e0f02014810110045482102565934c80105003707003c8cb0558cf1601fa02cb6a12cb1fcb3fc98306fb0080053503fa408308d718d401d001d120f9014006f910f2e3ef03d31fd33f5024baf2e3ed01baf2e3ed016f02800691cf232c1c044440072c7c7b2c7c732c01402be8094023e8085b2c7c532c7c4b2c7f2c7f2c7f2c7c07e80807e80bd003d003d00326000553434c1c07000fcb8fc34c7f4c7f4c03e803e8034c7f4c7f4c7f4c7f4c7f4c7fe803e803d013d013d010c20", + data: "b5ee9c7201010201009e0001d6801cf2d92ae46c8da46ab425cd6bd2c8df012a80d8d7e09fe29111cba0f077ec66d001bae161b6dcd7bea8670e1a1d4f6cf6157a944bc0e30db083254faf571dcbc22be887c8d282061436e184c9f810c2f97b0fcd019fff055f9b1e0e454924c72dcc000000000000000001005b0300000008000000ef084083800013880000138800001388000013880000a8c00000546021dcd650021dcd650008", + want: []ContractInterface{ + TonCocoonWorker, + }, + }, + { + name: "cocoon wallet", + account: "EQAJHTejCFK3mWMxkmZpA7oh89xSdLNWKAV9u1yj48JDCWz5", + code: "b5ee9c720102110100024b000114ff00f4a413f4bcf2c80b010201200203020148040500e0f28308d71820d31fd31fd31f02f823bbf2d406ed44d0d31fd31fd3ffd31ffa40d12171b0f2d4075154baf2e4085162baf2e40906f901541076f910f2e40af8276f2230821077359400b9f2d40bf800029320d74a96d307d402fb00e83001a4c8cb1f14cb1f12cbffcb1f01cf16c9ed540202ca06070201200d0e02012008090049a9f21402b3c5940233c585b2fff2413232c05400fe80807e80b2cfc4b2c7c4b2fff333326001f5d3b68bb7edb088831c02456f8007434c0c05c6c2456f83e900c0074c7c86084095964d32e88a08431669f34eeac48a084268491f02eac6497c0f83b513434c7f4c7f4fff4c7fe903454dc31c17cb90409a084271a7cddaea78415d7c1f4cfcc74c1f50c007ec03801b0003cb9044134c1f448301dc8701880b01d60a0202760b0c00ea5312b121b1f2e411018e295f07820898968072fb0280777080185410337003c8cb0558cf1601fa02cb6a12cb1fcb07c98306fb00e0378e19350271b101c8cb1f12cb1f13cbff12cb1f01cf16c9ed54db31e0058e1d028210fffffffeb001c8cb1f12cb1f13cbff12cb1f01cf16c9ed54db31e05f0500691cf232c1c044440072c7c7b2c7c732c01402be8094023e8085b2c7c532c7c4b2c7f2c7f2c7f2c7c07e80807e80bd003d003d00326000553434c1c07000fcb8fc34c7f4c7f4c03e803e8034c7f4c7f4c7f4c7f4c7f4c7fe803e803d013d013d010c200201200f10001bbdfddf6a2684080b06b90fd201840017bb39ced44d0d33f31d70bff80011b8c97ed44d0d70b1f8", + data: "b5ee9c7201010101005000009b0000000e00000000b04f495dd705f11c1d53cfae6ea9665b6cab3c2c6d1de55a441b20efca81df3300000000801cf2d92ae46c8da46ab425cd6bd2c8df012a80d8d7e09fe29111cba0f077ec66d0", + want: []ContractInterface{ + TonCocoonWallet, + }, + }, + { + name: "stonfi pool", + account: "0:0A95E1D4EBE7860D051F8B861730DBDEE1440FD11180211914E0089146580351", + code: "B5EE9C7201023A01001053000114FF00F4A413F4BCF2C80B0102016202030202CD04050201200D0E03F1D106380492F827000E8698180B8D8492F827076A2687D2000FC30E98380FC31698380FC31E98380FC327D2000FC32FD2000FC337D0000FC33EA00E87D0000FC347D0000FC34FD2000FC357D0000FC35FD00187C366A00FC36EA187C377D2001698FE99F9141083DEECBEF5D71811141082B6FF5C55D71811140607080101D43002FE3235FA00FA40FA40308161A870DB3C05FA4031FA003171D721FA00315365BC01FA0030A7065270BCB0F2E053F828F84D235970542013541403C85004FA0258CF1601CF16CCC922C8CB0112F400F400CB00C9F9007074C8CB02CA07CBFFC9D05004C705F2E05221C200F2E051F84B5220A8F847A904F84C5230A8F847A904212E0902FE326C3301FA00FA00FA40FA0030F828F84E235970530010351024C85004CF1658CF1601FA0201FA02C921C8CB0113F40012F400CB00C920F9007074C8CB02CA07CBFFC9D027C705F2E052F847C0008E16F8475250A8F84BA904F8475250A8F84CA904B6085003E30DF84B26A0F86BF84C25A0F86CF84722A0F8675213B9F84B0A0B04FE821089446A42BA8ED7326C3301FA00FA00FA4030F828F84E225970530010351024C85004CF1658CF1601FA0201FA02C921C8CB0113F40012F400CB00C9F9007074C8CB02CA07CBFFC9D05005C705F2E0527080400445538210DE7DBBC202DB3CE0F8415240C7058F153333441450338F0CEDFB24821025938561BAE30FD8E0311E1F2003B0C20021C200B0F2E051F84B22A1F86BF84C21A1F86CF8475004A1F86770804025D70B01C3008E9D5B5054A1AB00708210D53276DBC8CB1F5270CB3FC954425572DB3C0304951027353530E2103540148210DDA48B6A02DB3C32312A00C0325DA820C0008E508100B55311837FBE9931AB7F8100B5AA3F01DE20833FBE96AB3F01AA1F01DE20831FBE96AB1F01AA0F01DE20830FBE96AB0F01AA0701DE830FA0A8AB1177965CA904A0AB00E466A9045CB991309131E2DF8103E8A9048B0203DC8477BCF84C8477BCB1B18F6034355B12F828F84D235970542013541403C85004FA0258CF1601CF16CCC922C8CB0112F400F400CB00C920F9007074C8CB02CA07CBFFC9D0708210178D4519C8CB1F16CB3F5003FA02F828CF165003CF1623FA0213CB007001C943308040DB3CE30D262A0C013E5B82103EBE5431C8CB1F14CB3F58FA0201FA0270FA027001C943308042DB3C260201200F10020120161700C1BBF19ED44D0FA4001F861D30701F862D30701F863D30701F864FA4001F865FA4001F866FA0001F867D401D0FA0001F868FA0001F869FA4001F86AFA0001F86BFA0030F86CD401F86DD430F86EF84BF84CF845F846F842F843F844F84AF848F8498020120111201A1B6A29DA89A1F48003F0C3A60E03F0C5A60E03F0C7A60E03F0C9F48003F0CBF48003F0CDF40003F0CFA803A1F40003F0D1F40003F0D3F48003F0D5F40003F0D7F40061F0D9A803F0DBA861F0DDF051F09D01302016E1415006070530010351024C85004CF1658CF1601FA0201FA02C921C8CB0113F40012F400CB00C9F9007074C8CB02CA07CBFFC9D000BCA87EED44D0FA4001F861D30701F862D30701F863D30701F864FA4001F865FA4001F866FA0001F867D401D0FA0001F868FA0001F869FA4001F86AFA0001F86BFA0030F86CD401F86DD430F86EF84712A8F84BA904F84712A8F84CA904B60800DAA903ED44D0FA4001F861D30701F862D30701F863D30701F864FA4001F865FA4001F866FA0001F867D401D0FA0001F868FA0001F869FA4001F86AFA0001F86BFA0030F86CD401F86DD430F86E20C200F2E051F84B5210A8F847A904F84C12A8F847A90421C20021C200B0F2E051020166181902E3B83FDED44D0FA4001F861D30701F862D30701F863D30701F864FA4001F865FA4001F866FA0001F867D401D0FA0001F868FA0001F869FA4001F86AFA0001F86BFA0030F86CD401F86DD430F86EF8478103E8BCF2E050705300F8455240C705E300F84614C7059133E30D20C100923070DE5981C1D00FBADBCF6A2687D2000FC30E98380FC31698380FC31E98380FC327D2000FC32FD2000FC337D0000FC33EA00E87D0000FC347D0000FC34FD2000FC357D0000FC35FD00187C366A00FC36EA187C377C147C26B82A1009AA0A01E428027D012C678B00E78B666491646580897A007A00658064FC80383A6465816503E5FFE4E84001E1AF16F6A2687D2000FC30E98380FC31698380FC31E98380FC327D2000FC32FD2000FC337D0000FC33EA00E87D0000FC347D0000FC34FD2000FC357D0000FC35FD00187C366A00FC36EA187C377C147D2218B8E46583C682AD0E8E8E0E6745E5ED8E05CE6E8DEDC5CCCD25E60750678B00C01A01FE20C0008E1830C8709320C14097803058CB0701A4E801C9D001AA02D7198E4C209320C30092AB03E830800FC89322C3008E175321B020C20995A63701CB0795A63001CB07E202AB0302E831C832C9D080409320C2009DA520AA02522078D72413CF1602E85BC9D08308D719E2CF168B52E6A736F6E8CF16C9F8477FF841F84D1B00081034413000965F0370F84BF84C2459812710F842A113A85203A801812710A858A0A9047020F843C2009C31F8435220A8812710A90601DEF844C20014B09C32F8445210A8812710A90602DE5302A012A10200985F0370F84CF84B1023812710F842A113A85203A801812710A858A0A9047020F843C2009C31F8435220A8812710A90601DEF844C20014B09C32F8445210A8812710A90602DE5302A012A10258048A3233FA40FA40FA00FA00D300D430D0FA4070208B02804053268E915F03208161A821DB3C1CA1AB0003FA403092353CE2F84519C705E30FF847C10124C1015195BE19B118B12E21222303F431238210FCF9E58FBA8EE2316C12FA40FA00FA00FA0030F828F84E102570530010351024C85004CF1658CF1601FA0201FA02C921C8CB0113F40012F400CB00C920F9007074C8CB02CA07CBFFC9D082103EBE5431C8CB1F16CB3F58FA025003FA0201FA027001C943308040DB3CE023821042A0FB43BAE302312226272803E4362182101FCB7D3DBAE30203FA4031FA003171D721FA0031FA00300443357074FB0223821043C034E6BA8EBF306C2232F844F843F842C8CB07CB07CB07F84ACF16F848FA02F849FA02C9821043C034E6C8CB1F12CB3FF84BFA02F84CFA02F845CF16F846CF16CCC9DB3C7FE30EDC840FF2F02C392D009831F84BF84C27103659812710F842A113A85203A801812710A858A0A9047020F843C2009C31F8435220A8812710A90601DEF844C20014B09C32F8445210A8812710A90602DE5302A012A10227009A30F84CF84B27103659812710F842A113A85203A801812710A858A0A9047020F843C2009C31F8435220A8812710A90601DEF844C20014B09C32F8445210A8812710A90602DE5302A012A102270603AE8E945F046C333470804004455382105FFE129502DB3CE026E30FF84EF84DC8F848FA02F849FA02F84ACF16F84BFA02F84CFA02C9F844F843F842C8F841CF16CB07CB07CB07F845CF16F846CF16F847FA02CCCCCCC9ED5431242503D0F84B5008A0F86BF84C5321A028A0A1F86CF84901A0F869F84B8477BCF84CC101B18E955B6C3334708040044553821038976E9B02DB3CDB31E06C223226C0008E952672B182104507854070235159040550874330DB3C926C22E20443138210C64370E5587001DB3C31313103CCF84B5DA022A0A1F86BF84C5008A0F86CF84801A0F868F84C8477BCF84BC101B18E955B6C3334708040044553821038976E9B02DB3CDB31E06C223226C0008E952672B1821045078540702351590405084373DB3C01926C22E20443138210C64370E55870DB3C313131002E778018C8CB055005CF165005FA0213CB6BCCCCC901FB00011C135F038208989680A1F84170DB3C2903D482101FCB7D3DBA8F503031F848C200F849C200B0F2E050F84A8D0860000000000000000000000000000000000000000000000000000000000000000004C705B3F2E05B708040F84A22F848F84910561045DB3C70F86870F869E031018210355423E5BAE30230840FF2F0312A2B0028708018C8CB055003CF165003FA02CB6AC901FB00007AF84EF84DC8F848FA02F849FA02F84ACF16F84BFA02F84CFA02C9F844F843F842C8F841CF16CB07CB07CB07F845CF16F846CF16F847FA02CCCCCCC9ED5400D0D307D307D307FA40307F24C165B0F2E0557F23C165B0F2E0557F22C165B0F2E05503F86201F863F864F86AF84EF84DC8F848FA02F849FA02F84ACF16F84BFA02F84CFA02C9F844F843F842C8F841CF16CB07CB07CB07F845CF16F846CF16F847FA02CCCCCCC9ED5402FE313233F8478103E8BCF2E050F84882080F4240BCF84982080F4240BCB0F2E058F84A8D0860000000000000000000000000000000000000000000000000000000000000000004C705B3F2E05B82009C4070DB3C5320A182103B9ACA00BCF2E05312A1AB01F8488103E8A904F8498103E8A904F84822A1F868F84921A1F869212E2F04EA238210ED4D8B67BAE3022382109163A98ABA8ECE6C33FA40308210ED4D8B67C8CB1F13CB3FF828F84E102470530010351024C85004CF1658CF1601FA0201FA02C921C8CB0113F40012F400CB00C9F9007074C8CB02CA07CBFFC9D012CF16C9DB3C7FE02382109CE632C5BAE3022382108751801FBA333934350144C0FF948014F833948015F833E2D0DB3C6C135DB993135F03985AA101AB0FA801A0E23002E4C20021C200B0F2E051F848C200F849C200B0F2E05122A70370F84A21F848F849295530DB3C1024720443137002DB3C70F86870F869F84EF84DC8F848FA02F849FA02F84ACF16F84BFA02F84CFA02C9F844F843F842C8F841CF16CB07CB07CB07F845CF16F846CF16F847FA02CCCCCCC9ED5431310058D307218100D1BA9C31D33FD33F5902F0046C2113E0218100DEBA028100DDBA12B196D33F01705202E0705300015CC858FA02F845CF1601FA02F846CF16C9718210F93BB43FC8CB1F15CB3F5003CF16CB1F12CB00CCF84101C958DB3C32002C718010C8CB055004CF165004FA0212CB6ACCC901FB0002FC6C33F8478103E8BCF2E050FA00FA403070705311F8455250C7058E4E5F047F70F84BF84C2559812710F842A113A85203A801812710A858A0A9047020F843C2009C31F8435220A8812710A90601DEF844C20014B09C32F8445210A8812710A90602DE5302A012A1021023DEF84615C7059134E30DF2E0568210ED4D8B67C83637015C6C33FA4031FA00FA0030F847A8F84BA904F84712A8F84CA904B60882109CE632C5C8CB1F13CB3F58FA02C9DB3C7F3902988EBC6C33FA003020C200F2E051F84B5210A8F847A904F84C12A8F847A90421C20021C200B0F2E05182108751801FC8CB1F14CB3F01FA0258FA02C9DB3C7FE00382102C76B973BAE3025F0570393800A05F047F70F84CF84B10231024812710F842A113A85203A801812710A858A0A9047020F843C2009C31F8435220A8812710A90601DEF844C20014B09C32F8445210A8812710A90602DE5302A012A10240030136CB1F15CB3F24C1019234709104E214FA0201FA0258FA02C9DB3C7F3901E0038208989680A014BCF2E04BFA40D3003095C821CF16C9916DE28210D1735400C8CB1F14CB3F21FA4430C0008E35F828F84D102370542013541403C85004FA0258CF1601CF16CCC922C8CB0112F400F400CB00C9F9007074C8CB02CA07CBFFC9D0CF16947032CB01E212F400C9DB3C7F39002C718018C8CB055003CF1670FA0212CB6ACCC98306FB00", + data: "B5EE9C7201021D0100064F0003D9800EF3B9902A271B2A01C8938A523CFE24E71847AAEB6A620001ED44A77AC0E709C28141500052B01CB158A448CB5F364F77B04808D717973D78809FD26EF16A89DB974893620008A85A8C5931356A8C4CFCC443FC4125B8032A2B22AFBFF1409F80934CD2030FA81C0E0BA87C0102030071430CDAEDE572CA5126B28000000000000000000000000000000000000000000000000000000000000000000B1BF933B410E0324B7E198E84F00114FF00F4A413F4BCF2C80B040114FF00F4A413F4BCF2C80B1202016205060202CC0708001BA0F605DA89A1F401F481F481A86100B7D906380492F827000E8698180B8D84A89AF81F806707D207D2018FD0018B8EB90FD0018FD001801698F90C10807C53F52DD4A989A2CF804F010C1080BC6A28CDD4B18A22201F805701AC1082CAF83DE5D49ACF805F02F824207F9784020120090A0201200B0C0081D40106B90F6A2687D007D207D206A1802698F90C1080BC6A28CDD0141083DEECBEF5D0958F97162E99F98FD001809D02811E428027D012C678B00E78B6664F6AA401F5503D33FFA00FA407022805501FA443058BAF2F4ED44D0FA00FA40FA40D4305136A1522AC705F2E2C128C2FFF2E2C254344270542013541403C85004FA0258CF1601CF16CCC922C8CB0112F400F400CB00C920F9007074C8CB02CA07CBFFC9D004FA40F40431FA0020D749C200F2E2C4778018C8CB055008CF167080D0201200E0F00ACFA0217CB6B13CC8210178D4519C8CB1F19CB3F5007FA0222CF165006CF1625FA025003CF16C95005CC2391729171E25008A813A08209C9C380A014BCF2E2C504C98040FB001023C85004FA0258CF1601CF16CCC9ED5402F73B51343E803E903E90350C0234CFFE80145468017E903E9014D6F1C1551CDB5C150804D50500F214013E809633C58073C5B33248B232C044BD003D0032C0327E401C1D3232C0B281F2FFF274140371C1472C7CB8B0C2BE80146A2860822625A019AD822860822625A028062849E5C412440E0DD7C138C34975C2C060101100D73B51343E803E903E90350C01F4CFFE803E900C145468549271C17CB8B049F0BFFCB8B08160824C4B402805AF3CB8B0E0841EF765F7B232C7C572CFD400FE8088B3C58073C5B25C60063232C14933C59C3E80B2DAB33260103EC01004F214013E809633C58073C5B3327B552000705279A018A182107362D09CC8CB1F5230CB3F58FA025007CF165007CF16C9718018C8CB0524CF165006FA0215CB6A14CCC971FB0010241023007CC30023C200B08E218210D53276DB708010C8CB055008CF165004FA0216CB6A12CB1F12CB3FC972FB0093356C21E203C85004FA0258CF1601CF16CCC9ED54020162131403A4D020C700925F04E001D0D303ED44D0FA4001F861FA4001F862FA0001F863FA0030F8640171B0925F04E0FA40307021805501FA443058BAF2F401D31FD33FF8425240C705E302F8415240C705E302343443131516170043A1BA6DDA89A1F48003F0C3F48003F0C5F40003F0C7F40061F0C9F083F085F087F08901F63355216C210282103EBE5431BA8EE501FA00FA00FA0030F8435003A0F863F84401A0F864F8438103E8BCF8448103E8BCB05210B08EA7821056DFEB8AC8CB1F12CB3FF843FA02F844FA02F841CF1601FA02F84201C9DB3C70F86370F864915BE2C8F841CF16F842CF16F843FA02F844FA02C9ED54955B840FF2F0E21C02B6335521312382100BF3F447BA8ECB10235F03F843C200F844C200B1F2E050821089446A42C8CB1FCB3FF843FA02F844FA02F841CF1670F84202C9128040DB3C70F86370F864C8F841CF16F842CF16F843FA02F844FA02C9ED54E30E1918016E307074FB020282101D439AE0BA8E9F82101D439AE0C8CB1FCB3FF841CF16F842CF16F843FA02F844FA02C9DB3C7F925B70E2DC840FF2F01C02FE2382104CF82803BA8EEA316C12FA00FA00FA0030228103E8BC228103E8BCB05210B0F2E051F84323A1F863F84422A1F864F843C2FFF844C2FFB0F2E050821056DFEB8AC8CB1F14CB3F58FA0201FA02F841CF1601FA0270F84202C9128040DB3CC8F841CF16F842CF16F843FA02F844FA02C9ED54E0303101821042A0FB43BA191A002C718018C8CB055004CF165004FA0212CB6ACCC901FB00013A8E95208208989680BCF2E0538208989680A1F84170DB3CE030840FF2F01B0028708018C8CB055003CF165003FA02CB6AC901FB00002C718018C8CB055003CF1670FA0212CB6ACCC98306FB00", + want: []ContractInterface{ + TonStonfiV1Pool, + }, + }, + { + name: "stonfi v2 const product", + account: "EQCGScrZe1xbyWqWDvdI6mzP-GAcAWFv6ZXuaJOuSqemxku4", + code: "b5ee9c7201010101002300084202a9338ecd624ca15d37e4a8d9bf677ddc9b84f0e98f05f2fb84c7afe332a281b4", + data: "b5ee9c720101040100d7000149301a140f832fdb823ba1bfb5be3f31b7c3443fd0faa362f8616032132169133960002800150102c980125c28235ca8d125e676591513d520721b1fe99f7722f4c87723ce7ee0dfb73a300248b589f5f63b6f4039388ef6c31529dbb9787d195ce86bd105e15fe8f88fa47e00491060c0d367f56688dbdc7b109c6f8ddce6415b769330e97afd7710259f7d90400203084202c00836440d084e44fb94316132ac5a21417ef4f429ee09b5560b5678b334c3e8084202c95a2ed22ab516f77f9d4898dc4578e72f18a2448e8f6832334b0b4bf501bc79", + hasLibrary: true, + want: []ContractInterface{ + TonTep74JettonMinter, TonStonfiV2PoolConstProduct, + }, + }, + { + name: "stonfi v2 stableswap", + account: "EQBSUY4UWGJFAps0KwHY4tpOGqzU41DZhyrT8OuyAWWtnezy", + code: "b5ee9c72010101010023000842023c882eb9ede6be2459b2d2e469680af9f8e48ab16ec0726f0d07b0e5686be718", + data: "b5ee9c720101040100f800018c301d364b8c6e5b01e9cb72c7ffb03bd138d8a68a36b9f0f3a375b46f1c00000000000000000000000000000000000000000000000000000000000000000000000001000000640102c9800a46afff33251480ab6dab42434437a3fe464a9dbe5f525f9642ab4d2ef6eac89001466aa0b3a89e00a1dd7ccf9e8a225962fc32536722c3351274978f9861d9e8ee0029ee48e6b746e6db45008d68a4de088ac64064b6fcbb98f3a46f9583bb409e2a400203084202c00836440d084e44fb94316132ac5a21417ef4f429ee09b5560b5678b334c3e8084202c3b3ef256ddc9bd4e35db3e3863c048b18465c9f403f1d5a2b559395e11cfee6", + hasLibrary: true, + want: []ContractInterface{ + TonTep74JettonMinter, TonStonfiV2PoolStableSwap, + }, + }, + { + name: "stonfi v2 weighted stableswap", + account: "EQAF6mNbKhaMrfyhdNcrEnRKW1fXA3jmkS6KM7azm9PunYx5", + code: "b5ee9c72010101010023000842029e5038ab735973d5450fae1a14e7707b332dcd8e744f5dbb3b6a0d994d400c59", + data: "b5ee9c72010205010001280002413008a53a7fe1e300cd07f2d7d5320e45240c65220ff1049ba08971348000080003010200a30000000000000002b5e3af16b188000000000000000000001131cfef7cb58000000000000000000003782dace9d900008000000000000000000000000000000000000000000000000000000000000000001002c98000cafb7e1aeb694b6c81c13012e24c43b95cf99bd3c84fb900ee31e9b144096fb0001aa0db2d3fc8f1224da5badf8994c74a05048d50963e42b0d8d71fe2b849569a0003770d21f96c46cd550df24da7d76c88d13cbed0cc691d4e91c69706ae47137bc00304084202c00836440d084e44fb94316132ac5a21417ef4f429ee09b5560b5678b334c3e8084202e398c874e2bb0017b7447c3cbc534ca368d96533c1b120101d4c8c097d12c6e3", + hasLibrary: true, + want: []ContractInterface{ + TonTep74JettonMinter, TonStonfiV2PoolWeightedStableSwap, + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + codeBytes, _ := hex.DecodeString(tt.code) + dataBytes, _ := hex.DecodeString(tt.data) + codeCell, _ := boc.DeserializeBoc(codeBytes) + dataCell, _ := boc.DeserializeBoc(dataBytes) + account := ton.MustParseAccountID(tt.account) + emulatorConfig := tt.emulatorConfig + if tt.emulatorConfig == nil { + emulatorConfig = boc.MustDeserializeSinglRootBase64(txemulator.DefaultConfig) + } + cli, err := liteapi.NewClient(liteapi.Testnet()) + if err != nil { + t.Fatalf("failed to create liteapi client: %v", err) + } + ci := NewContractInspector(InspectWithLibraryResolver(cli)) + emulator, err := tvm.NewEmulator(codeCell[0], dataCell[0], emulatorConfig, tvm.WithLibraryResolver(cli)) + if err != nil { + t.Fatalf("NewEmulator() failed: %v", err) + } + if tt.hasLibrary { + if !codeCell[0].IsLibrary() { + t.Fatal("code cell is not library cell") + } + libHash, err := codeCell[0].GetLibraryHash() + if err != nil { + t.Fatalf("NewEmulator() failed: %v", err) + } + libs, err := cli.GetLibraries(context.Background(), []ton.Bits256{libHash}) + if err != nil { + t.Fatalf("GetLibraries() failed: %v", err) + } + base64Libs, err := code.LibrariesToBase64(libs) + if err != nil { + t.Fatalf("LibrariesToBase64() failed: %v", err) + } + emulator, err = tvm.NewEmulator(codeCell[0], dataCell[0], emulatorConfig, tvm.WithLibraryResolver(cli), tvm.WithLibrariesBase64(base64Libs)) + if err != nil { + t.Fatalf("NewEmulator() with library failed: %v", err) + } + } + contractDescription, err := ci.InspectContract(context.Background(), codeBytes, emulator, account) + if err != nil { + t.Fatalf("InspectContract() failed: %v", err) + } + + if !reflect.DeepEqual(contractDescription.ContractInterfaces, tt.want) { + t.Errorf("InspectContract() got = %v, want %v", contractDescription.ContractInterfaces, tt.want) + } + if tt.wantValidate != nil { + if err = tt.wantValidate(contractDescription); err != nil { + t.Fatalf("wantValidate() failed: %v", err) + } + } + for _, method := range contractDescription.GetMethods { + fmt.Printf("%v -> %#v\n", method.TypeHint, method.Result) + } + }) + } +} + +func Test_getCodeInfo(t *testing.T) { + tests := []struct { + name string + code string + wantHash string + wantMethods map[int64]struct{} + }{ + { + code: "b5ee9c72010214010002d4000114ff00f4a413f4bcf2c80b01020120020f020148030602e6d001d0d3032171b0925f04e022d749c120925f04e002d31f218210706c7567bd22821064737472bdb0925f05e003fa403020fa4401c8ca07cbffc9d0ed44d0810140d721f404305c810108f40a6fa131b3925f07e005d33fc8258210706c7567ba923830e30d03821064737472ba925f06e30d0405007801fa00f40430f8276f2230500aa121bef2e0508210706c7567831eb17080185004cb0526cf1658fa0219f400cb6917cb1f5260cb3f20c98040fb0006008a5004810108f45930ed44d0810140d720c801cf16f400c9ed540172b08e23821064737472831eb17080185005cb055003cf1623fa0213cb6acb1fcb3fc98040fb00925f03e2020120070e020120080d020158090a003db29dfb513420405035c87d010c00b23281f2fff274006040423d029be84c600201200b0c0019adce76a26840206b90eb85ffc00019af1df6a26840106b90eb858fc00011b8c97ed44d0d70b1f80059bd242b6f6a2684080a06b90fa0218470d4080847a4937d29910ce6903e9ff9837812801b7810148987159f318404f8f28308d71820d31fd31fd31f02f823bbf264ed44d0d31fd31fd3fff404d15143baf2a15151baf2a205f901541064f910f2a3f80024a4c8cb1f5240cb1f5230cbff5210f400c9ed54f80f01d30721c0009f6c519320d74a96d307d402fb00e830e021c001e30021c002e30001c0039130e30d03a4c8cb1f12cb1fcbff10111213006ed207fa00d4d422f90005c8ca0715cbffc9d077748018c8cb05cb0222cf165005fa0214cb6b12ccccc973fb00c84014810108f451f2a7020070810108d718fa00d33fc8542047810108f451f2a782106e6f746570748018c8cb05cb025006cf165004fa0214cb6a12cb1fcb3fc973fb0002006c810108d718fa00d33f305224810108f459f2a782106473747270748018c8cb05cb025005cf165003fa0213cb6acb1f12cb3fc973fb00000af400c9ed54", + wantHash: "feb5ff6820e2ff0d9483e7e0d62c817d846789fb4ae580c878866d959dabd5c0", + wantMethods: map[int64]struct{}{ + 0: {}, 76407: {}, 78748: {}, 81467: {}, 85143: {}, 107653: {}, 524287: {}, + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + code, err := hex.DecodeString(tt.code) + if err != nil { + t.Fatalf("hex.DecodeString() failed: %v", err) + } + got, err := GetCodeInfo(context.Background(), code, nil) + if err != nil { + t.Fatalf("GetCodeInfo() failed: %v", err) + } + if got.Hash.Hex() != tt.wantHash { + t.Fatalf("GetCodeInfo() got = %v, want %v", got.Hash.Hex(), tt.wantHash) + } + if !reflect.DeepEqual(got.Methods, tt.wantMethods) { + t.Errorf("GetCodeInfo() got = %v, want %v", got.Methods, tt.wantMethods) + } + }) + } +} diff --git a/abi-tolk/interfaces.go b/abi-tolk/interfaces.go new file mode 100644 index 00000000..477bae14 --- /dev/null +++ b/abi-tolk/interfaces.go @@ -0,0 +1,375 @@ +package abitolk + +// Code autogenerated. DO NOT EDIT. + +import ( + "github.com/tonkeeper/tongo/ton" +) + +const ( + IUnknown ContractInterface = iota + TonCocoonClient + TonCocoonProxy + TonCocoonRoot + TonCocoonWallet + TonCocoonWorker + TonCoffeePool + TonDedustPool + TonStonfiV1Pool + TonStonfiV2Pool + TonStonfiV2PoolConstProduct + TonStonfiV2PoolStableSwap + TonStonfiV2PoolWeightedStableSwap + TonTep74JettonMinter + TonTep74JettonWallet + TonTolkTestsPayloads +) + +const ( + NUnknown contractNamespace = iota + TonCocoon + TonCoffee + TonDedust + TonStonfiV1 + TonStonfiV2 + TonTep74 + TonTolkTests +) + +var namespaceByInterface = map[ContractInterface]contractNamespace{ + IUnknown: NUnknown, + TonCocoonClient: TonCocoon, + TonCocoonProxy: TonCocoon, + TonCocoonRoot: TonCocoon, + TonCocoonWallet: TonCocoon, + TonCocoonWorker: TonCocoon, + TonCoffeePool: TonCoffee, + TonDedustPool: TonDedust, + TonStonfiV1Pool: TonStonfiV1, + TonStonfiV2Pool: TonStonfiV2, + TonStonfiV2PoolConstProduct: TonStonfiV2, + TonStonfiV2PoolStableSwap: TonStonfiV2, + TonStonfiV2PoolWeightedStableSwap: TonStonfiV2, + TonTep74JettonMinter: TonTep74, + TonTep74JettonWallet: TonTep74, + TonTolkTestsPayloads: TonTolkTests, +} + +func (c ContractInterface) String() string { + switch c { + case TonCocoonClient: + return "ton_cocoon_client" + case TonCocoonProxy: + return "ton_cocoon_proxy" + case TonCocoonRoot: + return "ton_cocoon_root" + case TonCocoonWallet: + return "ton_cocoon_wallet" + case TonCocoonWorker: + return "ton_cocoon_worker" + case TonCoffeePool: + return "ton_coffee_pool" + case TonDedustPool: + return "ton_dedust_pool" + case TonStonfiV1Pool: + return "ton_stonfi_v1_pool" + case TonStonfiV2Pool: + return "ton_stonfi_v2_pool" + case TonStonfiV2PoolConstProduct: + return "ton_stonfi_v2_pool_const_product" + case TonStonfiV2PoolStableSwap: + return "ton_stonfi_v2_pool_stable_swap" + case TonStonfiV2PoolWeightedStableSwap: + return "ton_stonfi_v2_pool_weighted_stable_swap" + case TonTep74JettonMinter: + return "ton_tep74_jetton_minter" + case TonTep74JettonWallet: + return "ton_tep74_jetton_wallet" + case TonTolkTestsPayloads: + return "ton_tolk_tests_payloads" + default: + return "unknown" + } +} + +func ContractInterfaceFromString(s string) ContractInterface { + switch s { + case "ton_cocoon_client": + return TonCocoonClient + case "ton_cocoon_proxy": + return TonCocoonProxy + case "ton_cocoon_root": + return TonCocoonRoot + case "ton_cocoon_wallet": + return TonCocoonWallet + case "ton_cocoon_worker": + return TonCocoonWorker + case "ton_coffee_pool": + return TonCoffeePool + case "ton_dedust_pool": + return TonDedustPool + case "ton_stonfi_v1_pool": + return TonStonfiV1Pool + case "ton_stonfi_v2_pool": + return TonStonfiV2Pool + case "ton_stonfi_v2_pool_const_product": + return TonStonfiV2PoolConstProduct + case "ton_stonfi_v2_pool_stable_swap": + return TonStonfiV2PoolStableSwap + case "ton_stonfi_v2_pool_weighted_stable_swap": + return TonStonfiV2PoolWeightedStableSwap + case "ton_tep74_jetton_minter": + return TonTep74JettonMinter + case "ton_tep74_jetton_wallet": + return TonTep74JettonWallet + case "ton_tolk_tests_payloads": + return TonTolkTestsPayloads + default: + return IUnknown + } +} + +var methodInvocationOrder = []MethodDescription{ + { + Name: "get_cocoon_client_data", + InvokeFn: GetCocoonClientData, + }, + { + Name: "get_cocoon_data", + InvokeFn: GetCocoonData, + }, + { + Name: "get_cocoon_proxy_data", + InvokeFn: GetCocoonProxyData, + }, + { + Name: "get_cocoon_worker_data", + InvokeFn: GetCocoonWorkerData, + }, + { + Name: "get_cur_params", + InvokeFn: GetCurParams, + }, + { + Name: "get_jetton_data", + InvokeFn: GetJettonData, + }, + { + Name: "get_owner_address", + InvokeFn: GetOwnerAddress, + }, + { + Name: "get_pool_data", + InvokeFn: GetPoolData, + }, + { + Name: "get_public_key", + InvokeFn: GetPublicKey, + }, + { + Name: "get_wallet_data", + InvokeFn: GetWalletData, + }, + { + Name: "last_proxy_seqno", + InvokeFn: LastProxySeqno, + }, + { + Name: "seqno", + InvokeFn: Seqno, + }, +} + +var contractInterfacesOrder = []InterfaceDescription{ + { + Name: TonCocoonClient, + Results: []string{ + "TonCocoonClient_GetCocoonClientDataResult", + }, + }, + { + Name: TonCocoonProxy, + Results: []string{ + "TonCocoonProxy_GetCocoonProxyDataResult", + }, + }, + { + Name: TonCocoonRoot, + Results: []string{ + "TonCocoonRoot_GetCocoonDataResult", + "TonCocoonRoot_GetCurParamsResult", + "TonCocoonRoot_LastProxySeqnoResult", + }, + }, + { + Name: TonCocoonWallet, + Results: []string{ + "TonCocoonWallet_GetOwnerAddressResult", + "TonCocoonWallet_GetPublicKeyResult", + "TonCocoonWallet_SeqnoResult", + }, + }, + { + Name: TonCocoonWorker, + Results: []string{ + "TonCocoonWorker_GetCocoonWorkerDataResult", + }, + }, + { + Name: TonTep74JettonMinter, + Results: []string{ + "TonTep74JettonMinter_GetJettonDataResult", + }, + }, + { + Name: TonTep74JettonWallet, + Results: []string{ + "TonTep74JettonWallet_GetWalletDataResult", + }, + }, + { + Name: TonStonfiV1Pool, + Results: []string{ + "TonStonfiV1Pool_GetPoolDataResult", + }, + }, + { + Name: TonStonfiV2PoolConstProduct, + Results: []string{ + "TonStonfiV2PoolConstProduct_GetPoolDataResult", + }, + }, + { + Name: TonStonfiV2PoolStableSwap, + Results: []string{ + "TonStonfiV2PoolStableSwap_GetPoolDataResult", + }, + }, + { + Name: TonStonfiV2PoolWeightedStableSwap, + Results: []string{ + "TonStonfiV2PoolWeightedStableSwap_GetPoolDataResult", + }, + }, +} + +func (c ContractInterface) recursiveImplements(other ContractInterface) bool { + switch c { + } + return false +} + +var knownContracts = map[ton.Bits256]knownContractDescription{} + +func (c ContractInterface) IntMsgs() []msgDecoderFunc { + switch c { + case TonCocoonClient: + return []msgDecoderFunc{ + decodeFuncTonCocoonExtClientChargeSignedMsgBody, + decodeFuncTonCocoonExtClientGrantRefundSignedMsgBody, + decodeFuncTonCocoonExtClientTopUpMsgBody, + decodeFuncTonCocoonOwnerClientChangeSecretHashAndTopUpMsgBody, + decodeFuncTonCocoonOwnerClientRegisterMsgBody, + decodeFuncTonCocoonOwnerClientChangeSecretHashMsgBody, + decodeFuncTonCocoonOwnerClientIncreaseStakeMsgBody, + decodeFuncTonCocoonOwnerClientWithdrawMsgBody, + decodeFuncTonCocoonOwnerClientRequestRefundMsgBody, + decodeFuncTonCocoonReturnExcessesBackMsgBody, + decodeFuncTonCocoonPayoutMsgBody, + decodeFuncTonCocoonClientProxyRequestMsgBody, + } + case TonCocoonProxy: + return []msgDecoderFunc{ + decodeFuncTonCocoonTextCmdMsgBody, + decodeFuncTonCocoonExtProxyCloseRequestSignedMsgBody, + decodeFuncTonCocoonExtProxyCloseCompleteRequestSignedMsgBody, + decodeFuncTonCocoonExtProxyPayoutRequestMsgBody, + decodeFuncTonCocoonExtProxyIncreaseStakeMsgBody, + decodeFuncTonCocoonOwnerProxyCloseMsgBody, + decodeFuncTonCocoonWorkerProxyRequestMsgBody, + decodeFuncTonCocoonClientProxyRequestMsgBody, + decodeFuncTonCocoonReturnExcessesBackMsgBody, + decodeFuncTonCocoonPayoutMsgBody, + } + case TonCocoonRoot: + return []msgDecoderFunc{ + decodeFuncTonCocoonAddWorkerTypeMsgBody, + decodeFuncTonCocoonDelWorkerTypeMsgBody, + decodeFuncTonCocoonAddModelTypeMsgBody, + decodeFuncTonCocoonDelModelTypeMsgBody, + decodeFuncTonCocoonAddProxyTypeMsgBody, + decodeFuncTonCocoonDelProxyTypeMsgBody, + decodeFuncTonCocoonRegisterProxyMsgBody, + decodeFuncTonCocoonUnregisterProxyMsgBody, + decodeFuncTonCocoonUpdateProxyMsgBody, + decodeFuncTonCocoonChangeFeesMsgBody, + decodeFuncTonCocoonChangeParamsMsgBody, + decodeFuncTonCocoonUpgradeContractsMsgBody, + decodeFuncTonCocoonUpgradeCodeMsgBody, + decodeFuncTonCocoonResetRootMsgBody, + decodeFuncTonCocoonUpgradeFullMsgBody, + decodeFuncTonCocoonChangeOwnerMsgBody, + decodeFuncTonCocoonReturnExcessesBackMsgBody, + decodeFuncTonCocoonPayoutMsgBody, + } + case TonCocoonWallet: + return []msgDecoderFunc{ + decodeFuncTonCocoonOwnerWalletSendMessageMsgBody, + decodeFuncTonCocoonTextCommandMsgBody, + decodeFuncTonCocoonReturnExcessesBackMsgBody, + decodeFuncTonCocoonPayoutMsgBody, + decodeFuncTonCocoonTextCommandMsgBody, + } + case TonCocoonWorker: + return []msgDecoderFunc{ + decodeFuncTonCocoonExtWorkerPayoutRequestSignedMsgBody, + decodeFuncTonCocoonExtWorkerLastPayoutRequestSignedMsgBody, + decodeFuncTonCocoonOwnerWorkerRegisterMsgBody, + decodeFuncTonCocoonReturnExcessesBackMsgBody, + decodeFuncTonCocoonPayoutMsgBody, + decodeFuncTonCocoonWorkerProxyRequestMsgBody, + } + case TonCoffeePool: + return []msgDecoderFunc{ + decodeFuncTonCoffeeCrossDexResendMsgBody, + } + case TonTep74JettonMinter: + return []msgDecoderFunc{ + decodeFuncTonTep74MintNewJettonsMsgBody, + decodeFuncTonTep74BurnNotificationForMinterMsgBody, + decodeFuncTonTep74RequestWalletAddressMsgBody, + decodeFuncTonTep74ChangeMinterAdminMsgBody, + decodeFuncTonTep74ChangeMinterContentMsgBody, + decodeFuncTonTep74ReturnExcessesBackMsgBody, + decodeFuncTonTep74ResponseWalletAddressMsgBody, + decodeFuncTonTep74InternalTransferStepMsgBody, + } + case TonTep74JettonWallet: + return []msgDecoderFunc{ + decodeFuncTonTep74AskToTransferMsgBody, + decodeFuncTonTep74AskToBurnMsgBody, + decodeFuncTonTep74InternalTransferStepMsgBody, + decodeFuncTonTep74AboaLisaMsgBody, + decodeFuncTonTep74TransferNotificationForRecipientMsgBody, + decodeFuncTonTep74ReturnExcessesBackMsgBody, + decodeFuncTonTep74InternalTransferStepMsgBody, + decodeFuncTonTep74BurnNotificationForMinterMsgBody, + } + default: + return nil + } +} + +func (c ContractInterface) ExtInMsgs() []msgDecoderFunc { + switch c { + default: + return nil + } +} + +func (c ContractInterface) ExtOutMsgs() []msgDecoderFunc { + switch c { + default: + return nil + } +} diff --git a/abi-tolk/messages.go b/abi-tolk/messages.go new file mode 100644 index 00000000..c9806411 --- /dev/null +++ b/abi-tolk/messages.go @@ -0,0 +1,388 @@ +package abitolk + +import ( + "bytes" + "encoding/hex" + "encoding/json" + "fmt" + "reflect" + + "github.com/tonkeeper/tongo/boc" + "github.com/tonkeeper/tongo/tlb" +) + +func pointer[T any](t T) *T { + return &t +} + +func decodeMsg(tag tlb.Tag, name MsgOpName, bodyType any) msgDecoderFunc { + return func(cell *boc.Cell, decoder *tlb.Decoder) (*uint32, *MsgOpName, any, error) { + cell.ResetCounters() + readTag, err := cell.ReadUint(tag.Len) + if err != nil { + return nil, nil, nil, err + } + var uintTag *uint32 + if readTag != tag.Val { + return nil, nil, nil, fmt.Errorf("invalid tag") + } + if tag.Len == 32 { + uintTag = pointer(uint32(readTag)) + } + body := reflect.New(reflect.TypeOf(bodyType)) + if decoder == nil { + decoder = tlb.NewDecoder() + } + err = decoder.Unmarshal(cell, body.Interface()) + if err == nil { + return uintTag, pointer(name), body.Elem().Interface(), nil + } + return uintTag, nil, nil, err + } +} + +func decodeMultipleMsgs(funcs []msgDecoderFunc, tag string) msgDecoderFunc { + return func(cell *boc.Cell, decoder *tlb.Decoder) (*uint32, *MsgOpName, any, error) { + for _, f := range funcs { + tag, opName, object, err := f(cell, decoder) + if err == nil && completedRead(cell) { + return tag, opName, object, err + } + } + return nil, nil, nil, fmt.Errorf("no one message can be unmarshled for %v", tag) + } +} + +type InMsgBody struct { + SumType MsgOpName + OpCode *uint32 + Value any +} + +func (body InMsgBody) MarshalTLB(c *boc.Cell, encoder *tlb.Encoder) error { + if body.SumType == EmptyMsgOp { + return nil + } + if body.OpCode != nil { + err := c.WriteUint(uint64(*body.OpCode), 32) + if err != nil { + return err + } + } + return tlb.Marshal(c, body.Value) +} + +func (body *InMsgBody) UnmarshalTLB(cell *boc.Cell, decoder *tlb.Decoder) error { + body.SumType = UnknownMsgOp + ifaces := fromTlbContractInterface(decoder.GetContractInterfaces()) + tag, name, value, err := InternalMessageDecoder(cell, ifaces) + if err != nil { + return err + } + if tag == nil && name == nil { + body.SumType = EmptyMsgOp + return nil + } + body.OpCode = tag + if name != nil { + body.SumType = *name + body.Value = value + } else { + if cell.BitsAvailableForRead() != cell.BitSize() { + cell = cell.CopyRemaining() //because body can be part of the message cell + } + body.Value = cell + } + return nil +} + +func (body *InMsgBody) UnmarshalJSON(data []byte) error { + var r struct { + SumType string + OpCode *uint32 + Value json.RawMessage + } + if err := json.Unmarshal(data, &r); err != nil { + return err + } + body.SumType = r.SumType + body.OpCode = r.OpCode + if body.SumType == EmptyMsgOp { + return nil + } + if body.SumType == UnknownMsgOp { + c := boc.NewCell() + err := json.Unmarshal(r.Value, c) + if err != nil { + return err + } + body.Value = c + return nil + } + t, ok := KnownMsgInTypes[body.SumType] + if !ok { + return fmt.Errorf("unknown message body type '%v'", body.SumType) + } + o := reflect.New(reflect.TypeOf(t)) + err := json.Unmarshal(r.Value, o.Interface()) + if err != nil { + return err + } + body.Value = o.Elem().Interface() + return nil +} + +func (body InMsgBody) MarshalJSON() ([]byte, error) { + if body.SumType == EmptyMsgOp { + return []byte("{}"), nil + } + buf := bytes.NewBufferString(`{"SumType": "` + body.SumType + `",`) + if body.OpCode != nil { + fmt.Fprintf(buf, `"OpCode":%v,`, *body.OpCode) + } + buf.WriteString(`"Value":`) + if body.SumType == UnknownMsgOp { + c, ok := body.Value.(*boc.Cell) + if !ok { + return nil, fmt.Errorf("unknown MsgBody should be Cell") + } + b, err := c.ToBoc() + if err != nil { + return nil, err + } + buf.WriteRune('"') + hex.NewEncoder(buf).Write(b) + buf.WriteString(`"}`) + return buf.Bytes(), nil + } + if KnownMsgInTypes[body.SumType] == nil { + return nil, fmt.Errorf("unknown MsgBody type %v", body.SumType) + } + b, err := json.Marshal(body.Value) + if err != nil { + return nil, err + } + buf.Write(b) + buf.WriteRune('}') + return buf.Bytes(), nil +} + +type ExtOutMsgBody struct { + SumType string + OpCode *uint32 + Value any +} + +func (b *ExtOutMsgBody) UnmarshalTLB(cell *boc.Cell, decoder *tlb.Decoder) error { + b.SumType = UnknownMsgOp + tag, name, value, err := ExtOutMessageDecoder(cell, nil, tlb.MsgAddress{SumType: "AddrNone"}) + if err != nil { + return err + } + if tag == nil && name == nil { + b.SumType = EmptyMsgOp + } + b.OpCode = tag + if name != nil { + b.SumType = *name + b.Value = value + } else { + if cell.BitsAvailableForRead() != cell.BitSize() { + cell = cell.CopyRemaining() //because body can be part of the message cell + } + b.Value = cell + } + return nil +} + +func (body *ExtOutMsgBody) UnmarshalJSON(data []byte) error { + var r struct { + SumType string + OpCode *uint32 + Value json.RawMessage + } + if err := json.Unmarshal(data, &r); err != nil { + return err + } + body.SumType = r.SumType + body.OpCode = r.OpCode + if body.SumType == EmptyMsgOp { + return nil + } + if body.SumType == UnknownMsgOp { + c := boc.NewCell() + err := json.Unmarshal(r.Value, c) + if err != nil { + return err + } + body.Value = c + return nil + } + t, ok := KnownMsgExtOutTypes[body.SumType] + if !ok { + return fmt.Errorf("unknown message body type '%v'", body.SumType) + } + o := reflect.New(reflect.TypeOf(t)) + err := json.Unmarshal(r.Value, o.Interface()) + if err != nil { + return err + } + body.Value = o.Elem().Interface() + return nil +} + +func (body ExtOutMsgBody) MarshalJSON() ([]byte, error) { + if body.SumType == EmptyMsgOp { + return []byte("{}"), nil + } + buf := bytes.NewBufferString(`{"SumType": "` + body.SumType + `",`) + if body.OpCode != nil { + fmt.Fprintf(buf, `"OpCode":%v,`, *body.OpCode) + } + buf.WriteString(`"Value":`) + if body.SumType == UnknownMsgOp { + c, ok := body.Value.(*boc.Cell) + if !ok { + return nil, fmt.Errorf("unknown MsgBody should be Cell") + } + b, err := c.ToBoc() + if err != nil { + return nil, err + } + buf.WriteRune('"') + hex.NewEncoder(buf).Write(b) + buf.WriteString(`"}`) + return buf.Bytes(), nil + } + if KnownMsgExtOutTypes[body.SumType] == nil { + return nil, fmt.Errorf("unknown MsgBody type %v", body.SumType) + } + b, err := json.Marshal(body.Value) + if err != nil { + return nil, err + } + buf.Write(b) + buf.WriteRune('}') + return buf.Bytes(), nil +} + +type msgDecoderFunc func(cell *boc.Cell, decoder *tlb.Decoder) (*uint32, *MsgOpName, any, error) + +// InternalMessageDecoder takes in a message body as a cell and tries to decode it based on the contract type or the first 4 bytes. +// It returns an opcode, an operation name and a decoded body. +func InternalMessageDecoder(cell *boc.Cell, interfaces []ContractInterface) (*MsgOpCode, *MsgOpName, any, error) { + if cell.BitsAvailableForRead() < 32 { + return nil, nil, nil, nil + } + if cell.BitsAvailableForRead() != cell.BitSize() { + cell = cell.CopyRemaining() //because body can be part of the message cell + } + ifaces := toTlbContractInterface(interfaces) + decoder := tlb.NewDecoder() + decoder.WithContractInterfaces(ifaces) + for _, i := range interfaces { + for _, f := range i.IntMsgs() { + t, m, v, err := f(cell, decoder) + if err == nil { + return t, m, v, nil + } + } + } + cell.ResetCounters() + tag64, err := cell.PickUint(32) + if err != nil { + return nil, nil, nil, err + } + tag := uint32(tag64) + f := opcodedMsgInDecodeFunctions[tag] + if f != nil { + t, o, b, err := f(cell, nil) + if err == nil { + return t, o, b, nil + } + } + return &tag, nil, nil, nil +} + +func ExtInMessageDecoder(cell *boc.Cell, interfaces []ContractInterface) (*MsgOpCode, *MsgOpName, any, error) { + if cell.BitsAvailableForRead() < 32 { + return nil, nil, nil, nil + } + if cell.BitsAvailableForRead() != cell.BitSize() { + cell = cell.CopyRemaining() //because body can be part of the message cell + } + ifaces := toTlbContractInterface(interfaces) + decoder := tlb.NewDecoder() + decoder.WithContractInterfaces(ifaces) + for _, i := range interfaces { + for _, f := range i.ExtInMsgs() { + t, m, v, err := f(cell, decoder) + if err == nil { + return t, m, v, nil + } + } + } + cell.ResetCounters() + tag64, err := cell.PickUint(32) + if err != nil { + return nil, nil, nil, err + } + tag := uint32(tag64) + f := opcodedMsgExtInDecodeFunctions[tag] + if f != nil { + t, o, b, err := f(cell, nil) + if err == nil { + return t, o, b, nil + } + } + return &tag, nil, nil, nil +} + +func ExtOutMessageDecoder(cell *boc.Cell, interfaces []ContractInterface, dest tlb.MsgAddress) (*MsgOpCode, *MsgOpName, any, error) { //todo: change to tlb.MsgAddressExt + if cell.BitsAvailableForRead() < 32 { + return nil, nil, nil, nil + } + if cell.BitsAvailableForRead() != cell.BitSize() { + cell = cell.CopyRemaining() //because body can be part of the message cell + } + ifaces := toTlbContractInterface(interfaces) + decoder := tlb.NewDecoder() + decoder.WithContractInterfaces(ifaces) + for _, i := range interfaces { + for _, f := range i.ExtOutMsgs() { + t, m, v, err := f(cell, decoder) + if err == nil { + return t, m, v, nil + } + } + } + cell.ResetCounters() + tag64, err := cell.PickUint(32) + if err != nil { + return nil, nil, nil, err + } + tag := uint32(tag64) + f := opcodedMsgExtOutDecodeFunctions[tag] + if f != nil { + t, o, b, err := f(cell, nil) + if err == nil { + return t, o, b, nil + } + } + return &tag, nil, nil, nil +} + +func completedRead(cell *boc.Cell) bool { + return cell.RefsAvailableForRead() == 0 && cell.BitsAvailableForRead() == 0 +} + +// MsgOpName is a human-friendly name for a message's operation which is identified by the first 4 bytes of the message's body. +type MsgOpName = string + +const ( + UnknownMsgOp MsgOpName = "Unknown" + EmptyMsgOp MsgOpName = "" +) + +// MsgOpCode is the first 4 bytes of a message body identifying an operation to be performed. +type MsgOpCode = uint32 diff --git a/abi-tolk/messages.md b/abi-tolk/messages.md new file mode 100644 index 00000000..e24b67aa --- /dev/null +++ b/abi-tolk/messages.md @@ -0,0 +1,62 @@ + +# List of supported message opcodes + +The first 4 bytes of a message's body identify the `operation` to be performed, or the `method` of the smart contract to be invoked. + +The list below contains the supported message operations, their names and opcodes. + +| Name | Message operation code | +|-------------|------------------------| +| TonCocoonAddModelType| 0xc146134d | +| TonCocoonAddProxyType| 0x71860e80 | +| TonCocoonAddWorkerType| 0xe34b1c60 | +| TonCocoonChangeFees| 0xc52ed8d4 | +| TonCocoonChangeOwner| 0xc4a1ae54 | +| TonCocoonChangeParams| 0x022fa189 | +| TonCocoonClientProxyRequest| 0x65448ff4 | +| TonCocoonDelModelType| 0x92b11c18 | +| TonCocoonDelProxyType| 0x3c41d0b2 | +| TonCocoonDelWorkerType| 0x8d94a79a | +| TonCocoonExtClientChargeSigned| 0xbb63ff93 | +| TonCocoonExtClientGrantRefundSigned| 0xefd711e1 | +| TonCocoonExtClientTopUp| 0xf172e6c2 | +| TonCocoonExtProxyCloseCompleteRequestSigned| 0xe511abc7 | +| TonCocoonExtProxyCloseRequestSigned| 0x636a4391 | +| TonCocoonExtProxyIncreaseStake| 0x9713f187 | +| TonCocoonExtProxyPayoutRequest| 0x7610e6eb | +| TonCocoonExtWorkerLastPayoutRequestSigned| 0xf5f26a36 | +| TonCocoonExtWorkerPayoutRequestSigned| 0xa040ad28 | +| TonCocoonOwnerClientChangeSecretHash| 0xa9357034 | +| TonCocoonOwnerClientChangeSecretHashAndTopUp| 0x8473b408 | +| TonCocoonOwnerClientIncreaseStake| 0x6a1f6a60 | +| TonCocoonOwnerClientRegister| 0xc45f9f3b | +| TonCocoonOwnerClientRequestRefund| 0xfafa6cc1 | +| TonCocoonOwnerClientWithdraw| 0xda068e78 | +| TonCocoonOwnerProxyClose| 0xb51d5a01 | +| TonCocoonOwnerWalletSendMessage| 0x9c69f376 | +| TonCocoonOwnerWorkerRegister| 0x26ed7f65 | +| TonCocoonPayout| 0xc59a7cd3 | +| TonCocoonRegisterProxy| 0x927c7cb5 | +| TonCocoonResetRoot| 0x563c1d96 | +| TonCocoonReturnExcessesBack| 0xd53276db | +| TonCocoonTextCmd| 0x00000000 | +| TonCocoonTextCommand| 0x00000000 | +| TonCocoonUnregisterProxy| 0x6d49eaf2 | +| TonCocoonUpdateProxy| 0x9c7924ba | +| TonCocoonUpgradeCode| 0x11aefd51 | +| TonCocoonUpgradeContracts| 0xa2370f61 | +| TonCocoonUpgradeFull| 0x4f7c5789 | +| TonCocoonWorkerProxyRequest| 0x4d725d2c | +| TonCoffeeCrossDexResend| 0x200f9086 | +| TonTep74AboaLisa| 0xd53276db | +| TonTep74AskToBurn| 0x595f07bc | +| TonTep74AskToTransfer| 0x0f8a7ea5 | +| TonTep74BurnNotificationForMinter| 0x7bdd97de | +| TonTep74ChangeMinterAdmin| 0x00000003 | +| TonTep74ChangeMinterContent| 0x00000004 | +| TonTep74InternalTransferStep| 0x178d4519 | +| TonTep74MintNewJettons| 0x00000015 | +| TonTep74RequestWalletAddress| 0x2c76b973 | +| TonTep74ResponseWalletAddress| 0xd1735400 | +| TonTep74ReturnExcessesBack| 0xd53276db | +| TonTep74TransferNotificationForRecipient| 0x7362d09c | diff --git a/abi-tolk/messages_generated.go b/abi-tolk/messages_generated.go new file mode 100644 index 00000000..7627ee9a --- /dev/null +++ b/abi-tolk/messages_generated.go @@ -0,0 +1,572 @@ +package abitolk + +// Code autogenerated. DO NOT EDIT. + +import ( + "github.com/tonkeeper/tongo/tlb" +) + +var ( + // 0x00000000 + decodeFuncTonCocoonTextCmdMsgBody = decodeMsg(tlb.Tag{Val: 0x00000000, Len: 32}, TonCocoonTextCmdMsgOp, TonCocoonTextCmdMsgBody{}) + // 0x00000000 + decodeFuncTonCocoonTextCommandMsgBody = decodeMsg(tlb.Tag{Val: 0x00000000, Len: 32}, TonCocoonTextCommandMsgOp, TonCocoonTextCommandMsgBody{}) + // 0x00000003 + decodeFuncTonTep74ChangeMinterAdminMsgBody = decodeMsg(tlb.Tag{Val: 0x00000003, Len: 32}, TonTep74ChangeMinterAdminMsgOp, TonTep74ChangeMinterAdminMsgBody{}) + // 0x00000004 + decodeFuncTonTep74ChangeMinterContentMsgBody = decodeMsg(tlb.Tag{Val: 0x00000004, Len: 32}, TonTep74ChangeMinterContentMsgOp, TonTep74ChangeMinterContentMsgBody{}) + // 0x00000015 + decodeFuncTonTep74MintNewJettonsMsgBody = decodeMsg(tlb.Tag{Val: 0x00000015, Len: 32}, TonTep74MintNewJettonsMsgOp, TonTep74MintNewJettonsMsgBody{}) + // 0x022fa189 + decodeFuncTonCocoonChangeParamsMsgBody = decodeMsg(tlb.Tag{Val: 0x022fa189, Len: 32}, TonCocoonChangeParamsMsgOp, TonCocoonChangeParamsMsgBody{}) + // 0x0f8a7ea5 + decodeFuncTonTep74AskToTransferMsgBody = decodeMsg(tlb.Tag{Val: 0x0f8a7ea5, Len: 32}, TonTep74AskToTransferMsgOp, TonTep74AskToTransferMsgBody{}) + // 0x11aefd51 + decodeFuncTonCocoonUpgradeCodeMsgBody = decodeMsg(tlb.Tag{Val: 0x11aefd51, Len: 32}, TonCocoonUpgradeCodeMsgOp, TonCocoonUpgradeCodeMsgBody{}) + // 0x178d4519 + decodeFuncTonTep74InternalTransferStepMsgBody = decodeMsg(tlb.Tag{Val: 0x178d4519, Len: 32}, TonTep74InternalTransferStepMsgOp, TonTep74InternalTransferStepMsgBody{}) + // 0x200f9086 + decodeFuncTonCoffeeCrossDexResendMsgBody = decodeMsg(tlb.Tag{Val: 0x200f9086, Len: 32}, TonCoffeeCrossDexResendMsgOp, TonCoffeeCrossDexResendMsgBody{}) + // 0x26ed7f65 + decodeFuncTonCocoonOwnerWorkerRegisterMsgBody = decodeMsg(tlb.Tag{Val: 0x26ed7f65, Len: 32}, TonCocoonOwnerWorkerRegisterMsgOp, TonCocoonOwnerWorkerRegisterMsgBody{}) + // 0x2c76b973 + decodeFuncTonTep74RequestWalletAddressMsgBody = decodeMsg(tlb.Tag{Val: 0x2c76b973, Len: 32}, TonTep74RequestWalletAddressMsgOp, TonTep74RequestWalletAddressMsgBody{}) + // 0x3c41d0b2 + decodeFuncTonCocoonDelProxyTypeMsgBody = decodeMsg(tlb.Tag{Val: 0x3c41d0b2, Len: 32}, TonCocoonDelProxyTypeMsgOp, TonCocoonDelProxyTypeMsgBody{}) + // 0x4d725d2c + decodeFuncTonCocoonWorkerProxyRequestMsgBody = decodeMsg(tlb.Tag{Val: 0x4d725d2c, Len: 32}, TonCocoonWorkerProxyRequestMsgOp, TonCocoonWorkerProxyRequestMsgBody{}) + // 0x4f7c5789 + decodeFuncTonCocoonUpgradeFullMsgBody = decodeMsg(tlb.Tag{Val: 0x4f7c5789, Len: 32}, TonCocoonUpgradeFullMsgOp, TonCocoonUpgradeFullMsgBody{}) + // 0x563c1d96 + decodeFuncTonCocoonResetRootMsgBody = decodeMsg(tlb.Tag{Val: 0x563c1d96, Len: 32}, TonCocoonResetRootMsgOp, TonCocoonResetRootMsgBody{}) + // 0x595f07bc + decodeFuncTonTep74AskToBurnMsgBody = decodeMsg(tlb.Tag{Val: 0x595f07bc, Len: 32}, TonTep74AskToBurnMsgOp, TonTep74AskToBurnMsgBody{}) + // 0x636a4391 + decodeFuncTonCocoonExtProxyCloseRequestSignedMsgBody = decodeMsg(tlb.Tag{Val: 0x636a4391, Len: 32}, TonCocoonExtProxyCloseRequestSignedMsgOp, TonCocoonExtProxyCloseRequestSignedMsgBody{}) + // 0x65448ff4 + decodeFuncTonCocoonClientProxyRequestMsgBody = decodeMsg(tlb.Tag{Val: 0x65448ff4, Len: 32}, TonCocoonClientProxyRequestMsgOp, TonCocoonClientProxyRequestMsgBody{}) + // 0x6a1f6a60 + decodeFuncTonCocoonOwnerClientIncreaseStakeMsgBody = decodeMsg(tlb.Tag{Val: 0x6a1f6a60, Len: 32}, TonCocoonOwnerClientIncreaseStakeMsgOp, TonCocoonOwnerClientIncreaseStakeMsgBody{}) + // 0x6d49eaf2 + decodeFuncTonCocoonUnregisterProxyMsgBody = decodeMsg(tlb.Tag{Val: 0x6d49eaf2, Len: 32}, TonCocoonUnregisterProxyMsgOp, TonCocoonUnregisterProxyMsgBody{}) + // 0x71860e80 + decodeFuncTonCocoonAddProxyTypeMsgBody = decodeMsg(tlb.Tag{Val: 0x71860e80, Len: 32}, TonCocoonAddProxyTypeMsgOp, TonCocoonAddProxyTypeMsgBody{}) + // 0x7362d09c + decodeFuncTonTep74TransferNotificationForRecipientMsgBody = decodeMsg(tlb.Tag{Val: 0x7362d09c, Len: 32}, TonTep74TransferNotificationForRecipientMsgOp, TonTep74TransferNotificationForRecipientMsgBody{}) + // 0x7610e6eb + decodeFuncTonCocoonExtProxyPayoutRequestMsgBody = decodeMsg(tlb.Tag{Val: 0x7610e6eb, Len: 32}, TonCocoonExtProxyPayoutRequestMsgOp, TonCocoonExtProxyPayoutRequestMsgBody{}) + // 0x7bdd97de + decodeFuncTonTep74BurnNotificationForMinterMsgBody = decodeMsg(tlb.Tag{Val: 0x7bdd97de, Len: 32}, TonTep74BurnNotificationForMinterMsgOp, TonTep74BurnNotificationForMinterMsgBody{}) + // 0x8473b408 + decodeFuncTonCocoonOwnerClientChangeSecretHashAndTopUpMsgBody = decodeMsg(tlb.Tag{Val: 0x8473b408, Len: 32}, TonCocoonOwnerClientChangeSecretHashAndTopUpMsgOp, TonCocoonOwnerClientChangeSecretHashAndTopUpMsgBody{}) + // 0x8d94a79a + decodeFuncTonCocoonDelWorkerTypeMsgBody = decodeMsg(tlb.Tag{Val: 0x8d94a79a, Len: 32}, TonCocoonDelWorkerTypeMsgOp, TonCocoonDelWorkerTypeMsgBody{}) + // 0x927c7cb5 + decodeFuncTonCocoonRegisterProxyMsgBody = decodeMsg(tlb.Tag{Val: 0x927c7cb5, Len: 32}, TonCocoonRegisterProxyMsgOp, TonCocoonRegisterProxyMsgBody{}) + // 0x92b11c18 + decodeFuncTonCocoonDelModelTypeMsgBody = decodeMsg(tlb.Tag{Val: 0x92b11c18, Len: 32}, TonCocoonDelModelTypeMsgOp, TonCocoonDelModelTypeMsgBody{}) + // 0x9713f187 + decodeFuncTonCocoonExtProxyIncreaseStakeMsgBody = decodeMsg(tlb.Tag{Val: 0x9713f187, Len: 32}, TonCocoonExtProxyIncreaseStakeMsgOp, TonCocoonExtProxyIncreaseStakeMsgBody{}) + // 0x9c69f376 + decodeFuncTonCocoonOwnerWalletSendMessageMsgBody = decodeMsg(tlb.Tag{Val: 0x9c69f376, Len: 32}, TonCocoonOwnerWalletSendMessageMsgOp, TonCocoonOwnerWalletSendMessageMsgBody{}) + // 0x9c7924ba + decodeFuncTonCocoonUpdateProxyMsgBody = decodeMsg(tlb.Tag{Val: 0x9c7924ba, Len: 32}, TonCocoonUpdateProxyMsgOp, TonCocoonUpdateProxyMsgBody{}) + // 0xa040ad28 + decodeFuncTonCocoonExtWorkerPayoutRequestSignedMsgBody = decodeMsg(tlb.Tag{Val: 0xa040ad28, Len: 32}, TonCocoonExtWorkerPayoutRequestSignedMsgOp, TonCocoonExtWorkerPayoutRequestSignedMsgBody{}) + // 0xa2370f61 + decodeFuncTonCocoonUpgradeContractsMsgBody = decodeMsg(tlb.Tag{Val: 0xa2370f61, Len: 32}, TonCocoonUpgradeContractsMsgOp, TonCocoonUpgradeContractsMsgBody{}) + // 0xa9357034 + decodeFuncTonCocoonOwnerClientChangeSecretHashMsgBody = decodeMsg(tlb.Tag{Val: 0xa9357034, Len: 32}, TonCocoonOwnerClientChangeSecretHashMsgOp, TonCocoonOwnerClientChangeSecretHashMsgBody{}) + // 0xb51d5a01 + decodeFuncTonCocoonOwnerProxyCloseMsgBody = decodeMsg(tlb.Tag{Val: 0xb51d5a01, Len: 32}, TonCocoonOwnerProxyCloseMsgOp, TonCocoonOwnerProxyCloseMsgBody{}) + // 0xbb63ff93 + decodeFuncTonCocoonExtClientChargeSignedMsgBody = decodeMsg(tlb.Tag{Val: 0xbb63ff93, Len: 32}, TonCocoonExtClientChargeSignedMsgOp, TonCocoonExtClientChargeSignedMsgBody{}) + // 0xc146134d + decodeFuncTonCocoonAddModelTypeMsgBody = decodeMsg(tlb.Tag{Val: 0xc146134d, Len: 32}, TonCocoonAddModelTypeMsgOp, TonCocoonAddModelTypeMsgBody{}) + // 0xc45f9f3b + decodeFuncTonCocoonOwnerClientRegisterMsgBody = decodeMsg(tlb.Tag{Val: 0xc45f9f3b, Len: 32}, TonCocoonOwnerClientRegisterMsgOp, TonCocoonOwnerClientRegisterMsgBody{}) + // 0xc4a1ae54 + decodeFuncTonCocoonChangeOwnerMsgBody = decodeMsg(tlb.Tag{Val: 0xc4a1ae54, Len: 32}, TonCocoonChangeOwnerMsgOp, TonCocoonChangeOwnerMsgBody{}) + // 0xc52ed8d4 + decodeFuncTonCocoonChangeFeesMsgBody = decodeMsg(tlb.Tag{Val: 0xc52ed8d4, Len: 32}, TonCocoonChangeFeesMsgOp, TonCocoonChangeFeesMsgBody{}) + // 0xc59a7cd3 + decodeFuncTonCocoonPayoutMsgBody = decodeMsg(tlb.Tag{Val: 0xc59a7cd3, Len: 32}, TonCocoonPayoutMsgOp, TonCocoonPayoutMsgBody{}) + // 0xd1735400 + decodeFuncTonTep74ResponseWalletAddressMsgBody = decodeMsg(tlb.Tag{Val: 0xd1735400, Len: 32}, TonTep74ResponseWalletAddressMsgOp, TonTep74ResponseWalletAddressMsgBody{}) + // 0xd53276db + decodeFuncTonCocoonReturnExcessesBackMsgBody = decodeMsg(tlb.Tag{Val: 0xd53276db, Len: 32}, TonCocoonReturnExcessesBackMsgOp, TonCocoonReturnExcessesBackMsgBody{}) + // 0xd53276db + decodeFuncTonTep74ReturnExcessesBackMsgBody = decodeMsg(tlb.Tag{Val: 0xd53276db, Len: 32}, TonTep74ReturnExcessesBackMsgOp, TonTep74ReturnExcessesBackMsgBody{}) + // 0xd53276db + decodeFuncTonTep74AboaLisaMsgBody = decodeMsg(tlb.Tag{Val: 0xd53276db, Len: 32}, TonTep74AboaLisaMsgOp, TonTep74AboaLisaMsgBody{}) + // 0xda068e78 + decodeFuncTonCocoonOwnerClientWithdrawMsgBody = decodeMsg(tlb.Tag{Val: 0xda068e78, Len: 32}, TonCocoonOwnerClientWithdrawMsgOp, TonCocoonOwnerClientWithdrawMsgBody{}) + // 0xe34b1c60 + decodeFuncTonCocoonAddWorkerTypeMsgBody = decodeMsg(tlb.Tag{Val: 0xe34b1c60, Len: 32}, TonCocoonAddWorkerTypeMsgOp, TonCocoonAddWorkerTypeMsgBody{}) + // 0xe511abc7 + decodeFuncTonCocoonExtProxyCloseCompleteRequestSignedMsgBody = decodeMsg(tlb.Tag{Val: 0xe511abc7, Len: 32}, TonCocoonExtProxyCloseCompleteRequestSignedMsgOp, TonCocoonExtProxyCloseCompleteRequestSignedMsgBody{}) + // 0xefd711e1 + decodeFuncTonCocoonExtClientGrantRefundSignedMsgBody = decodeMsg(tlb.Tag{Val: 0xefd711e1, Len: 32}, TonCocoonExtClientGrantRefundSignedMsgOp, TonCocoonExtClientGrantRefundSignedMsgBody{}) + // 0xf172e6c2 + decodeFuncTonCocoonExtClientTopUpMsgBody = decodeMsg(tlb.Tag{Val: 0xf172e6c2, Len: 32}, TonCocoonExtClientTopUpMsgOp, TonCocoonExtClientTopUpMsgBody{}) + // 0xf5f26a36 + decodeFuncTonCocoonExtWorkerLastPayoutRequestSignedMsgBody = decodeMsg(tlb.Tag{Val: 0xf5f26a36, Len: 32}, TonCocoonExtWorkerLastPayoutRequestSignedMsgOp, TonCocoonExtWorkerLastPayoutRequestSignedMsgBody{}) + // 0xfafa6cc1 + decodeFuncTonCocoonOwnerClientRequestRefundMsgBody = decodeMsg(tlb.Tag{Val: 0xfafa6cc1, Len: 32}, TonCocoonOwnerClientRequestRefundMsgOp, TonCocoonOwnerClientRequestRefundMsgBody{}) +) + +var opcodedMsgInDecodeFunctions = map[uint32]msgDecoderFunc{ + + //TonCocoonTextCmd, TonCocoonTextCommand, + 0x00000000: decodeMultipleMsgs([]msgDecoderFunc{ + decodeFuncTonCocoonTextCmdMsgBody, + decodeFuncTonCocoonTextCommandMsgBody}, + "0x00000000", + ), + + // 0x00000003 + TonTep74ChangeMinterAdminMsgOpCode: decodeFuncTonTep74ChangeMinterAdminMsgBody, + + // 0x00000004 + TonTep74ChangeMinterContentMsgOpCode: decodeFuncTonTep74ChangeMinterContentMsgBody, + + // 0x00000015 + TonTep74MintNewJettonsMsgOpCode: decodeFuncTonTep74MintNewJettonsMsgBody, + + // 0x022fa189 + TonCocoonChangeParamsMsgOpCode: decodeFuncTonCocoonChangeParamsMsgBody, + + // 0x0f8a7ea5 + TonTep74AskToTransferMsgOpCode: decodeFuncTonTep74AskToTransferMsgBody, + + // 0x11aefd51 + TonCocoonUpgradeCodeMsgOpCode: decodeFuncTonCocoonUpgradeCodeMsgBody, + + // 0x178d4519 + TonTep74InternalTransferStepMsgOpCode: decodeFuncTonTep74InternalTransferStepMsgBody, + + // 0x200f9086 + TonCoffeeCrossDexResendMsgOpCode: decodeFuncTonCoffeeCrossDexResendMsgBody, + + // 0x26ed7f65 + TonCocoonOwnerWorkerRegisterMsgOpCode: decodeFuncTonCocoonOwnerWorkerRegisterMsgBody, + + // 0x2c76b973 + TonTep74RequestWalletAddressMsgOpCode: decodeFuncTonTep74RequestWalletAddressMsgBody, + + // 0x3c41d0b2 + TonCocoonDelProxyTypeMsgOpCode: decodeFuncTonCocoonDelProxyTypeMsgBody, + + // 0x4d725d2c + TonCocoonWorkerProxyRequestMsgOpCode: decodeFuncTonCocoonWorkerProxyRequestMsgBody, + + // 0x4f7c5789 + TonCocoonUpgradeFullMsgOpCode: decodeFuncTonCocoonUpgradeFullMsgBody, + + // 0x563c1d96 + TonCocoonResetRootMsgOpCode: decodeFuncTonCocoonResetRootMsgBody, + + // 0x595f07bc + TonTep74AskToBurnMsgOpCode: decodeFuncTonTep74AskToBurnMsgBody, + + // 0x636a4391 + TonCocoonExtProxyCloseRequestSignedMsgOpCode: decodeFuncTonCocoonExtProxyCloseRequestSignedMsgBody, + + // 0x65448ff4 + TonCocoonClientProxyRequestMsgOpCode: decodeFuncTonCocoonClientProxyRequestMsgBody, + + // 0x6a1f6a60 + TonCocoonOwnerClientIncreaseStakeMsgOpCode: decodeFuncTonCocoonOwnerClientIncreaseStakeMsgBody, + + // 0x6d49eaf2 + TonCocoonUnregisterProxyMsgOpCode: decodeFuncTonCocoonUnregisterProxyMsgBody, + + // 0x71860e80 + TonCocoonAddProxyTypeMsgOpCode: decodeFuncTonCocoonAddProxyTypeMsgBody, + + // 0x7362d09c + TonTep74TransferNotificationForRecipientMsgOpCode: decodeFuncTonTep74TransferNotificationForRecipientMsgBody, + + // 0x7610e6eb + TonCocoonExtProxyPayoutRequestMsgOpCode: decodeFuncTonCocoonExtProxyPayoutRequestMsgBody, + + // 0x7bdd97de + TonTep74BurnNotificationForMinterMsgOpCode: decodeFuncTonTep74BurnNotificationForMinterMsgBody, + + // 0x8473b408 + TonCocoonOwnerClientChangeSecretHashAndTopUpMsgOpCode: decodeFuncTonCocoonOwnerClientChangeSecretHashAndTopUpMsgBody, + + // 0x8d94a79a + TonCocoonDelWorkerTypeMsgOpCode: decodeFuncTonCocoonDelWorkerTypeMsgBody, + + // 0x927c7cb5 + TonCocoonRegisterProxyMsgOpCode: decodeFuncTonCocoonRegisterProxyMsgBody, + + // 0x92b11c18 + TonCocoonDelModelTypeMsgOpCode: decodeFuncTonCocoonDelModelTypeMsgBody, + + // 0x9713f187 + TonCocoonExtProxyIncreaseStakeMsgOpCode: decodeFuncTonCocoonExtProxyIncreaseStakeMsgBody, + + // 0x9c69f376 + TonCocoonOwnerWalletSendMessageMsgOpCode: decodeFuncTonCocoonOwnerWalletSendMessageMsgBody, + + // 0x9c7924ba + TonCocoonUpdateProxyMsgOpCode: decodeFuncTonCocoonUpdateProxyMsgBody, + + // 0xa040ad28 + TonCocoonExtWorkerPayoutRequestSignedMsgOpCode: decodeFuncTonCocoonExtWorkerPayoutRequestSignedMsgBody, + + // 0xa2370f61 + TonCocoonUpgradeContractsMsgOpCode: decodeFuncTonCocoonUpgradeContractsMsgBody, + + // 0xa9357034 + TonCocoonOwnerClientChangeSecretHashMsgOpCode: decodeFuncTonCocoonOwnerClientChangeSecretHashMsgBody, + + // 0xb51d5a01 + TonCocoonOwnerProxyCloseMsgOpCode: decodeFuncTonCocoonOwnerProxyCloseMsgBody, + + // 0xbb63ff93 + TonCocoonExtClientChargeSignedMsgOpCode: decodeFuncTonCocoonExtClientChargeSignedMsgBody, + + // 0xc146134d + TonCocoonAddModelTypeMsgOpCode: decodeFuncTonCocoonAddModelTypeMsgBody, + + // 0xc45f9f3b + TonCocoonOwnerClientRegisterMsgOpCode: decodeFuncTonCocoonOwnerClientRegisterMsgBody, + + // 0xc4a1ae54 + TonCocoonChangeOwnerMsgOpCode: decodeFuncTonCocoonChangeOwnerMsgBody, + + // 0xc52ed8d4 + TonCocoonChangeFeesMsgOpCode: decodeFuncTonCocoonChangeFeesMsgBody, + + // 0xc59a7cd3 + TonCocoonPayoutMsgOpCode: decodeFuncTonCocoonPayoutMsgBody, + + // 0xd1735400 + TonTep74ResponseWalletAddressMsgOpCode: decodeFuncTonTep74ResponseWalletAddressMsgBody, + + //TonCocoonReturnExcessesBack, TonTep74ReturnExcessesBack, TonTep74AboaLisa, + 0xd53276db: decodeMultipleMsgs([]msgDecoderFunc{ + decodeFuncTonCocoonReturnExcessesBackMsgBody, + decodeFuncTonTep74ReturnExcessesBackMsgBody, + decodeFuncTonTep74AboaLisaMsgBody}, + "0xd53276db", + ), + + // 0xda068e78 + TonCocoonOwnerClientWithdrawMsgOpCode: decodeFuncTonCocoonOwnerClientWithdrawMsgBody, + + // 0xe34b1c60 + TonCocoonAddWorkerTypeMsgOpCode: decodeFuncTonCocoonAddWorkerTypeMsgBody, + + // 0xe511abc7 + TonCocoonExtProxyCloseCompleteRequestSignedMsgOpCode: decodeFuncTonCocoonExtProxyCloseCompleteRequestSignedMsgBody, + + // 0xefd711e1 + TonCocoonExtClientGrantRefundSignedMsgOpCode: decodeFuncTonCocoonExtClientGrantRefundSignedMsgBody, + + // 0xf172e6c2 + TonCocoonExtClientTopUpMsgOpCode: decodeFuncTonCocoonExtClientTopUpMsgBody, + + // 0xf5f26a36 + TonCocoonExtWorkerLastPayoutRequestSignedMsgOpCode: decodeFuncTonCocoonExtWorkerLastPayoutRequestSignedMsgBody, + + // 0xfafa6cc1 + TonCocoonOwnerClientRequestRefundMsgOpCode: decodeFuncTonCocoonOwnerClientRequestRefundMsgBody, +} + +const ( + TonCocoonTextCmdMsgOp MsgOpName = "TonCocoonTextCmd" + TonCocoonTextCommandMsgOp MsgOpName = "TonCocoonTextCommand" + TonTep74ChangeMinterAdminMsgOp MsgOpName = "TonTep74ChangeMinterAdmin" + TonTep74ChangeMinterContentMsgOp MsgOpName = "TonTep74ChangeMinterContent" + TonTep74MintNewJettonsMsgOp MsgOpName = "TonTep74MintNewJettons" + TonCocoonChangeParamsMsgOp MsgOpName = "TonCocoonChangeParams" + TonTep74AskToTransferMsgOp MsgOpName = "TonTep74AskToTransfer" + TonCocoonUpgradeCodeMsgOp MsgOpName = "TonCocoonUpgradeCode" + TonTep74InternalTransferStepMsgOp MsgOpName = "TonTep74InternalTransferStep" + TonCoffeeCrossDexResendMsgOp MsgOpName = "TonCoffeeCrossDexResend" + TonCocoonOwnerWorkerRegisterMsgOp MsgOpName = "TonCocoonOwnerWorkerRegister" + TonTep74RequestWalletAddressMsgOp MsgOpName = "TonTep74RequestWalletAddress" + TonCocoonDelProxyTypeMsgOp MsgOpName = "TonCocoonDelProxyType" + TonCocoonWorkerProxyRequestMsgOp MsgOpName = "TonCocoonWorkerProxyRequest" + TonCocoonUpgradeFullMsgOp MsgOpName = "TonCocoonUpgradeFull" + TonCocoonResetRootMsgOp MsgOpName = "TonCocoonResetRoot" + TonTep74AskToBurnMsgOp MsgOpName = "TonTep74AskToBurn" + TonCocoonExtProxyCloseRequestSignedMsgOp MsgOpName = "TonCocoonExtProxyCloseRequestSigned" + TonCocoonClientProxyRequestMsgOp MsgOpName = "TonCocoonClientProxyRequest" + TonCocoonOwnerClientIncreaseStakeMsgOp MsgOpName = "TonCocoonOwnerClientIncreaseStake" + TonCocoonUnregisterProxyMsgOp MsgOpName = "TonCocoonUnregisterProxy" + TonCocoonAddProxyTypeMsgOp MsgOpName = "TonCocoonAddProxyType" + TonTep74TransferNotificationForRecipientMsgOp MsgOpName = "TonTep74TransferNotificationForRecipient" + TonCocoonExtProxyPayoutRequestMsgOp MsgOpName = "TonCocoonExtProxyPayoutRequest" + TonTep74BurnNotificationForMinterMsgOp MsgOpName = "TonTep74BurnNotificationForMinter" + TonCocoonOwnerClientChangeSecretHashAndTopUpMsgOp MsgOpName = "TonCocoonOwnerClientChangeSecretHashAndTopUp" + TonCocoonDelWorkerTypeMsgOp MsgOpName = "TonCocoonDelWorkerType" + TonCocoonRegisterProxyMsgOp MsgOpName = "TonCocoonRegisterProxy" + TonCocoonDelModelTypeMsgOp MsgOpName = "TonCocoonDelModelType" + TonCocoonExtProxyIncreaseStakeMsgOp MsgOpName = "TonCocoonExtProxyIncreaseStake" + TonCocoonOwnerWalletSendMessageMsgOp MsgOpName = "TonCocoonOwnerWalletSendMessage" + TonCocoonUpdateProxyMsgOp MsgOpName = "TonCocoonUpdateProxy" + TonCocoonExtWorkerPayoutRequestSignedMsgOp MsgOpName = "TonCocoonExtWorkerPayoutRequestSigned" + TonCocoonUpgradeContractsMsgOp MsgOpName = "TonCocoonUpgradeContracts" + TonCocoonOwnerClientChangeSecretHashMsgOp MsgOpName = "TonCocoonOwnerClientChangeSecretHash" + TonCocoonOwnerProxyCloseMsgOp MsgOpName = "TonCocoonOwnerProxyClose" + TonCocoonExtClientChargeSignedMsgOp MsgOpName = "TonCocoonExtClientChargeSigned" + TonCocoonAddModelTypeMsgOp MsgOpName = "TonCocoonAddModelType" + TonCocoonOwnerClientRegisterMsgOp MsgOpName = "TonCocoonOwnerClientRegister" + TonCocoonChangeOwnerMsgOp MsgOpName = "TonCocoonChangeOwner" + TonCocoonChangeFeesMsgOp MsgOpName = "TonCocoonChangeFees" + TonCocoonPayoutMsgOp MsgOpName = "TonCocoonPayout" + TonTep74ResponseWalletAddressMsgOp MsgOpName = "TonTep74ResponseWalletAddress" + TonCocoonReturnExcessesBackMsgOp MsgOpName = "TonCocoonReturnExcessesBack" + TonTep74ReturnExcessesBackMsgOp MsgOpName = "TonTep74ReturnExcessesBack" + TonTep74AboaLisaMsgOp MsgOpName = "TonTep74AboaLisa" + TonCocoonOwnerClientWithdrawMsgOp MsgOpName = "TonCocoonOwnerClientWithdraw" + TonCocoonAddWorkerTypeMsgOp MsgOpName = "TonCocoonAddWorkerType" + TonCocoonExtProxyCloseCompleteRequestSignedMsgOp MsgOpName = "TonCocoonExtProxyCloseCompleteRequestSigned" + TonCocoonExtClientGrantRefundSignedMsgOp MsgOpName = "TonCocoonExtClientGrantRefundSigned" + TonCocoonExtClientTopUpMsgOp MsgOpName = "TonCocoonExtClientTopUp" + TonCocoonExtWorkerLastPayoutRequestSignedMsgOp MsgOpName = "TonCocoonExtWorkerLastPayoutRequestSigned" + TonCocoonOwnerClientRequestRefundMsgOp MsgOpName = "TonCocoonOwnerClientRequestRefund" +) + +const ( + TonCocoonTextCmdMsgOpCode MsgOpCode = 0x00000000 + TonCocoonTextCommandMsgOpCode MsgOpCode = 0x00000000 + TonTep74ChangeMinterAdminMsgOpCode MsgOpCode = 0x00000003 + TonTep74ChangeMinterContentMsgOpCode MsgOpCode = 0x00000004 + TonTep74MintNewJettonsMsgOpCode MsgOpCode = 0x00000015 + TonCocoonChangeParamsMsgOpCode MsgOpCode = 0x022fa189 + TonTep74AskToTransferMsgOpCode MsgOpCode = 0x0f8a7ea5 + TonCocoonUpgradeCodeMsgOpCode MsgOpCode = 0x11aefd51 + TonTep74InternalTransferStepMsgOpCode MsgOpCode = 0x178d4519 + TonCoffeeCrossDexResendMsgOpCode MsgOpCode = 0x200f9086 + TonCocoonOwnerWorkerRegisterMsgOpCode MsgOpCode = 0x26ed7f65 + TonTep74RequestWalletAddressMsgOpCode MsgOpCode = 0x2c76b973 + TonCocoonDelProxyTypeMsgOpCode MsgOpCode = 0x3c41d0b2 + TonCocoonWorkerProxyRequestMsgOpCode MsgOpCode = 0x4d725d2c + TonCocoonUpgradeFullMsgOpCode MsgOpCode = 0x4f7c5789 + TonCocoonResetRootMsgOpCode MsgOpCode = 0x563c1d96 + TonTep74AskToBurnMsgOpCode MsgOpCode = 0x595f07bc + TonCocoonExtProxyCloseRequestSignedMsgOpCode MsgOpCode = 0x636a4391 + TonCocoonClientProxyRequestMsgOpCode MsgOpCode = 0x65448ff4 + TonCocoonOwnerClientIncreaseStakeMsgOpCode MsgOpCode = 0x6a1f6a60 + TonCocoonUnregisterProxyMsgOpCode MsgOpCode = 0x6d49eaf2 + TonCocoonAddProxyTypeMsgOpCode MsgOpCode = 0x71860e80 + TonTep74TransferNotificationForRecipientMsgOpCode MsgOpCode = 0x7362d09c + TonCocoonExtProxyPayoutRequestMsgOpCode MsgOpCode = 0x7610e6eb + TonTep74BurnNotificationForMinterMsgOpCode MsgOpCode = 0x7bdd97de + TonCocoonOwnerClientChangeSecretHashAndTopUpMsgOpCode MsgOpCode = 0x8473b408 + TonCocoonDelWorkerTypeMsgOpCode MsgOpCode = 0x8d94a79a + TonCocoonRegisterProxyMsgOpCode MsgOpCode = 0x927c7cb5 + TonCocoonDelModelTypeMsgOpCode MsgOpCode = 0x92b11c18 + TonCocoonExtProxyIncreaseStakeMsgOpCode MsgOpCode = 0x9713f187 + TonCocoonOwnerWalletSendMessageMsgOpCode MsgOpCode = 0x9c69f376 + TonCocoonUpdateProxyMsgOpCode MsgOpCode = 0x9c7924ba + TonCocoonExtWorkerPayoutRequestSignedMsgOpCode MsgOpCode = 0xa040ad28 + TonCocoonUpgradeContractsMsgOpCode MsgOpCode = 0xa2370f61 + TonCocoonOwnerClientChangeSecretHashMsgOpCode MsgOpCode = 0xa9357034 + TonCocoonOwnerProxyCloseMsgOpCode MsgOpCode = 0xb51d5a01 + TonCocoonExtClientChargeSignedMsgOpCode MsgOpCode = 0xbb63ff93 + TonCocoonAddModelTypeMsgOpCode MsgOpCode = 0xc146134d + TonCocoonOwnerClientRegisterMsgOpCode MsgOpCode = 0xc45f9f3b + TonCocoonChangeOwnerMsgOpCode MsgOpCode = 0xc4a1ae54 + TonCocoonChangeFeesMsgOpCode MsgOpCode = 0xc52ed8d4 + TonCocoonPayoutMsgOpCode MsgOpCode = 0xc59a7cd3 + TonTep74ResponseWalletAddressMsgOpCode MsgOpCode = 0xd1735400 + TonCocoonReturnExcessesBackMsgOpCode MsgOpCode = 0xd53276db + TonTep74ReturnExcessesBackMsgOpCode MsgOpCode = 0xd53276db + TonTep74AboaLisaMsgOpCode MsgOpCode = 0xd53276db + TonCocoonOwnerClientWithdrawMsgOpCode MsgOpCode = 0xda068e78 + TonCocoonAddWorkerTypeMsgOpCode MsgOpCode = 0xe34b1c60 + TonCocoonExtProxyCloseCompleteRequestSignedMsgOpCode MsgOpCode = 0xe511abc7 + TonCocoonExtClientGrantRefundSignedMsgOpCode MsgOpCode = 0xefd711e1 + TonCocoonExtClientTopUpMsgOpCode MsgOpCode = 0xf172e6c2 + TonCocoonExtWorkerLastPayoutRequestSignedMsgOpCode MsgOpCode = 0xf5f26a36 + TonCocoonOwnerClientRequestRefundMsgOpCode MsgOpCode = 0xfafa6cc1 +) + +type TonCocoonTextCmdMsgBody = TonCocoonTextCmd + +type TonCocoonTextCommandMsgBody = TonCocoonTextCommand + +type TonTep74ChangeMinterAdminMsgBody = TonTep74ChangeMinterAdmin + +type TonTep74ChangeMinterContentMsgBody = TonTep74ChangeMinterContent + +type TonTep74MintNewJettonsMsgBody = TonTep74MintNewJettons + +type TonCocoonChangeParamsMsgBody = TonCocoonChangeParams + +type TonTep74AskToTransferMsgBody = TonTep74AskToTransfer + +type TonCocoonUpgradeCodeMsgBody = TonCocoonUpgradeCode + +type TonTep74InternalTransferStepMsgBody = TonTep74InternalTransferStep + +type TonCoffeeCrossDexResendMsgBody = TonCoffeeCrossDexResend + +type TonCocoonOwnerWorkerRegisterMsgBody = TonCocoonOwnerWorkerRegister + +type TonTep74RequestWalletAddressMsgBody = TonTep74RequestWalletAddress + +type TonCocoonDelProxyTypeMsgBody = TonCocoonDelProxyType + +type TonCocoonWorkerProxyRequestMsgBody = TonCocoonWorkerProxyRequest + +type TonCocoonUpgradeFullMsgBody = TonCocoonUpgradeFull + +type TonCocoonResetRootMsgBody = TonCocoonResetRoot + +type TonTep74AskToBurnMsgBody = TonTep74AskToBurn + +type TonCocoonExtProxyCloseRequestSignedMsgBody = TonCocoonExtProxyCloseRequestSigned + +type TonCocoonClientProxyRequestMsgBody = TonCocoonClientProxyRequest + +type TonCocoonOwnerClientIncreaseStakeMsgBody = TonCocoonOwnerClientIncreaseStake + +type TonCocoonUnregisterProxyMsgBody = TonCocoonUnregisterProxy + +type TonCocoonAddProxyTypeMsgBody = TonCocoonAddProxyType + +type TonTep74TransferNotificationForRecipientMsgBody = TonTep74TransferNotificationForRecipient + +type TonCocoonExtProxyPayoutRequestMsgBody = TonCocoonExtProxyPayoutRequest + +type TonTep74BurnNotificationForMinterMsgBody = TonTep74BurnNotificationForMinter + +type TonCocoonOwnerClientChangeSecretHashAndTopUpMsgBody = TonCocoonOwnerClientChangeSecretHashAndTopUp + +type TonCocoonDelWorkerTypeMsgBody = TonCocoonDelWorkerType + +type TonCocoonRegisterProxyMsgBody = TonCocoonRegisterProxy + +type TonCocoonDelModelTypeMsgBody = TonCocoonDelModelType + +type TonCocoonExtProxyIncreaseStakeMsgBody = TonCocoonExtProxyIncreaseStake + +type TonCocoonOwnerWalletSendMessageMsgBody = TonCocoonOwnerWalletSendMessage + +type TonCocoonUpdateProxyMsgBody = TonCocoonUpdateProxy + +type TonCocoonExtWorkerPayoutRequestSignedMsgBody = TonCocoonExtWorkerPayoutRequestSigned + +type TonCocoonUpgradeContractsMsgBody = TonCocoonUpgradeContracts + +type TonCocoonOwnerClientChangeSecretHashMsgBody = TonCocoonOwnerClientChangeSecretHash + +type TonCocoonOwnerProxyCloseMsgBody = TonCocoonOwnerProxyClose + +type TonCocoonExtClientChargeSignedMsgBody = TonCocoonExtClientChargeSigned + +type TonCocoonAddModelTypeMsgBody = TonCocoonAddModelType + +type TonCocoonOwnerClientRegisterMsgBody = TonCocoonOwnerClientRegister + +type TonCocoonChangeOwnerMsgBody = TonCocoonChangeOwner + +type TonCocoonChangeFeesMsgBody = TonCocoonChangeFees + +type TonCocoonPayoutMsgBody = TonCocoonPayout + +type TonTep74ResponseWalletAddressMsgBody = TonTep74ResponseWalletAddress + +type TonCocoonReturnExcessesBackMsgBody = TonCocoonReturnExcessesBack + +type TonTep74ReturnExcessesBackMsgBody = TonTep74ReturnExcessesBack + +type TonTep74AboaLisaMsgBody = TonTep74AboaLisa + +type TonCocoonOwnerClientWithdrawMsgBody = TonCocoonOwnerClientWithdraw + +type TonCocoonAddWorkerTypeMsgBody = TonCocoonAddWorkerType + +type TonCocoonExtProxyCloseCompleteRequestSignedMsgBody = TonCocoonExtProxyCloseCompleteRequestSigned + +type TonCocoonExtClientGrantRefundSignedMsgBody = TonCocoonExtClientGrantRefundSigned + +type TonCocoonExtClientTopUpMsgBody = TonCocoonExtClientTopUp + +type TonCocoonExtWorkerLastPayoutRequestSignedMsgBody = TonCocoonExtWorkerLastPayoutRequestSigned + +type TonCocoonOwnerClientRequestRefundMsgBody = TonCocoonOwnerClientRequestRefund + +var KnownMsgInTypes = map[string]any{ + TonCocoonTextCmdMsgOp: TonCocoonTextCmdMsgBody{}, + TonCocoonTextCommandMsgOp: TonCocoonTextCommandMsgBody{}, + TonTep74ChangeMinterAdminMsgOp: TonTep74ChangeMinterAdminMsgBody{}, + TonTep74ChangeMinterContentMsgOp: TonTep74ChangeMinterContentMsgBody{}, + TonTep74MintNewJettonsMsgOp: TonTep74MintNewJettonsMsgBody{}, + TonCocoonChangeParamsMsgOp: TonCocoonChangeParamsMsgBody{}, + TonTep74AskToTransferMsgOp: TonTep74AskToTransferMsgBody{}, + TonCocoonUpgradeCodeMsgOp: TonCocoonUpgradeCodeMsgBody{}, + TonTep74InternalTransferStepMsgOp: TonTep74InternalTransferStepMsgBody{}, + TonCoffeeCrossDexResendMsgOp: TonCoffeeCrossDexResendMsgBody{}, + TonCocoonOwnerWorkerRegisterMsgOp: TonCocoonOwnerWorkerRegisterMsgBody{}, + TonTep74RequestWalletAddressMsgOp: TonTep74RequestWalletAddressMsgBody{}, + TonCocoonDelProxyTypeMsgOp: TonCocoonDelProxyTypeMsgBody{}, + TonCocoonWorkerProxyRequestMsgOp: TonCocoonWorkerProxyRequestMsgBody{}, + TonCocoonUpgradeFullMsgOp: TonCocoonUpgradeFullMsgBody{}, + TonCocoonResetRootMsgOp: TonCocoonResetRootMsgBody{}, + TonTep74AskToBurnMsgOp: TonTep74AskToBurnMsgBody{}, + TonCocoonExtProxyCloseRequestSignedMsgOp: TonCocoonExtProxyCloseRequestSignedMsgBody{}, + TonCocoonClientProxyRequestMsgOp: TonCocoonClientProxyRequestMsgBody{}, + TonCocoonOwnerClientIncreaseStakeMsgOp: TonCocoonOwnerClientIncreaseStakeMsgBody{}, + TonCocoonUnregisterProxyMsgOp: TonCocoonUnregisterProxyMsgBody{}, + TonCocoonAddProxyTypeMsgOp: TonCocoonAddProxyTypeMsgBody{}, + TonTep74TransferNotificationForRecipientMsgOp: TonTep74TransferNotificationForRecipientMsgBody{}, + TonCocoonExtProxyPayoutRequestMsgOp: TonCocoonExtProxyPayoutRequestMsgBody{}, + TonTep74BurnNotificationForMinterMsgOp: TonTep74BurnNotificationForMinterMsgBody{}, + TonCocoonOwnerClientChangeSecretHashAndTopUpMsgOp: TonCocoonOwnerClientChangeSecretHashAndTopUpMsgBody{}, + TonCocoonDelWorkerTypeMsgOp: TonCocoonDelWorkerTypeMsgBody{}, + TonCocoonRegisterProxyMsgOp: TonCocoonRegisterProxyMsgBody{}, + TonCocoonDelModelTypeMsgOp: TonCocoonDelModelTypeMsgBody{}, + TonCocoonExtProxyIncreaseStakeMsgOp: TonCocoonExtProxyIncreaseStakeMsgBody{}, + TonCocoonOwnerWalletSendMessageMsgOp: TonCocoonOwnerWalletSendMessageMsgBody{}, + TonCocoonUpdateProxyMsgOp: TonCocoonUpdateProxyMsgBody{}, + TonCocoonExtWorkerPayoutRequestSignedMsgOp: TonCocoonExtWorkerPayoutRequestSignedMsgBody{}, + TonCocoonUpgradeContractsMsgOp: TonCocoonUpgradeContractsMsgBody{}, + TonCocoonOwnerClientChangeSecretHashMsgOp: TonCocoonOwnerClientChangeSecretHashMsgBody{}, + TonCocoonOwnerProxyCloseMsgOp: TonCocoonOwnerProxyCloseMsgBody{}, + TonCocoonExtClientChargeSignedMsgOp: TonCocoonExtClientChargeSignedMsgBody{}, + TonCocoonAddModelTypeMsgOp: TonCocoonAddModelTypeMsgBody{}, + TonCocoonOwnerClientRegisterMsgOp: TonCocoonOwnerClientRegisterMsgBody{}, + TonCocoonChangeOwnerMsgOp: TonCocoonChangeOwnerMsgBody{}, + TonCocoonChangeFeesMsgOp: TonCocoonChangeFeesMsgBody{}, + TonCocoonPayoutMsgOp: TonCocoonPayoutMsgBody{}, + TonTep74ResponseWalletAddressMsgOp: TonTep74ResponseWalletAddressMsgBody{}, + TonCocoonReturnExcessesBackMsgOp: TonCocoonReturnExcessesBackMsgBody{}, + TonTep74ReturnExcessesBackMsgOp: TonTep74ReturnExcessesBackMsgBody{}, + TonTep74AboaLisaMsgOp: TonTep74AboaLisaMsgBody{}, + TonCocoonOwnerClientWithdrawMsgOp: TonCocoonOwnerClientWithdrawMsgBody{}, + TonCocoonAddWorkerTypeMsgOp: TonCocoonAddWorkerTypeMsgBody{}, + TonCocoonExtProxyCloseCompleteRequestSignedMsgOp: TonCocoonExtProxyCloseCompleteRequestSignedMsgBody{}, + TonCocoonExtClientGrantRefundSignedMsgOp: TonCocoonExtClientGrantRefundSignedMsgBody{}, + TonCocoonExtClientTopUpMsgOp: TonCocoonExtClientTopUpMsgBody{}, + TonCocoonExtWorkerLastPayoutRequestSignedMsgOp: TonCocoonExtWorkerLastPayoutRequestSignedMsgBody{}, + TonCocoonOwnerClientRequestRefundMsgOp: TonCocoonOwnerClientRequestRefundMsgBody{}, +} + +var () + +var opcodedMsgExtInDecodeFunctions = map[uint32]msgDecoderFunc{} + +const () + +const () + +var KnownMsgExtInTypes = map[string]any{} + +var () + +var opcodedMsgExtOutDecodeFunctions = map[uint32]msgDecoderFunc{} + +const () + +const () + +var KnownMsgExtOutTypes = map[string]any{} diff --git a/abi-tolk/messages_test.go b/abi-tolk/messages_test.go new file mode 100644 index 00000000..38c98185 --- /dev/null +++ b/abi-tolk/messages_test.go @@ -0,0 +1,30 @@ +package abitolk + +import ( + "fmt" + "testing" + + "github.com/tonkeeper/tongo/boc" + "github.com/tonkeeper/tongo/tlb" +) + +func TestDecodeAndEncodeUnknownInMsgBody(t *testing.T) { + data := "b5ee9c720101010100570000a9178d4519000000006948345d40bab36908010e3f58e634ebf4cca5296ea1ade141563bf278c85e3ff08161e79367808987cf0021c7eb1cc69d7e9994a52dd435bc282ac77e4f190bc7fe102c3cf26cf01130f9c405" + boc1, _ := boc.DeserializeBocHex(data) + + var x InMsgBody + if err := tlb.Unmarshal(boc1[0], &x); err != nil { + t.Fatalf("Unable to unmarshal: %v", err) + } + + boc2 := boc.NewCell() + if err := tlb.Marshal(boc2, x); err != nil { + t.Fatalf("Unable to marshal: %v", err) + } + + b, _ := boc2.ToBoc() + res := fmt.Sprintf("%x", b) + if res != data { + t.Fatalf("got different result") + } +} diff --git a/abi-tolk/parser/errors.tmpl b/abi-tolk/parser/errors.tmpl new file mode 100644 index 00000000..797706da --- /dev/null +++ b/abi-tolk/parser/errors.tmpl @@ -0,0 +1,45 @@ + + +var contractErrors = map[ContractInterface]map[int32]string{ +{{range $Interface, $Errors := .Interfaces}} + {{- if ne (len $Errors) 0 -}} + {{- $Interface}}: { + {{- range $Code, $Name := $Errors -}} + {{ $Code}}: "{{$Name}}", + {{ end -}} }, + {{ end -}} +{{- end -}} +} + + +var defaultExitCodes = map[int32]string{ + 0: "Ok", + 1: "Ok", + 2: "Stack underflow", + 3: "Stack overflow", + 4: "Integer overflow or division by zero", + 5: "Integer out of expected range", + 6: "Invalid opcode", + 7: "Type check error", + 8: "Cell overflow", + 9: "Cell underflow", + 10: "Dictionary error", + 11: "Unknown error", + 12: "Impossible situation error", + 13: "Out of gas error", + -14: "Out of gas error", + } + +func GetContractError(interfaces []ContractInterface, code int32) *string { + for _, i := range interfaces { + if errors, ok := contractErrors[i]; ok { + if msg, ok := errors[code]; ok { + return &msg + } + } + } + if msg, ok := defaultExitCodes[code]; ok { + return &msg + } + return nil +} diff --git a/abi-tolk/parser/generator.go b/abi-tolk/parser/generator.go new file mode 100644 index 00000000..4bdb2c29 --- /dev/null +++ b/abi-tolk/parser/generator.go @@ -0,0 +1,976 @@ +package parser + +import ( + "bytes" + _ "embed" + "fmt" + "go/format" + "slices" + "sort" + "strings" + "text/template" + + "github.com/tonkeeper/tongo/tlb" + "github.com/tonkeeper/tongo/tolk" + tolkParser "github.com/tonkeeper/tongo/tolk/parser" + "github.com/tonkeeper/tongo/utils" + "golang.org/x/exp/maps" +) + +var ( + returnInvalidStack = "{return \"\", nil, fmt.Errorf(\"invalid stack format\")}\n" + returnStrNilErr = "if err != nil {return \"\", nil, err}\n" + //go:embed messages.md.tmpl + messagesMDTemplate string + //go:embed interfaces.tmpl + invocationOrderTemplate string + //go:embed get_methods.tmpl + getMethodsTemplate string + //go:embed messages.tmpl + messagesTemplate string + //go:embed payloads.tmpl + payloadTmpl string + //go:embed errors.tmpl + contractErrorsTmpl string +) + +const ( + MsgTypeInt MsgType = 0 + MsgTypeExtIn MsgType = 1 + MsgTypeExtOut MsgType = 2 + MsgTypePayload MsgType = 3 +) + +type TLBMsgBody struct { + Type MsgType + GolangTypeName string + GolangOpcodeName string + OperationName string + Tag uint64 + Code string + FixedLength bool +} + +type GetMethodWithAbi struct { + ABI tolk.ABI + GetMethod tolk.GetMethod +} + +type Generator struct { + structRefs map[string]tolk.StructDeclaration + aliasRefs map[string]tolk.AliasDeclaration + enumRefs map[string]tolk.EnumDeclaration + abi []tolk.ABI + abiByGetMethod map[string][]GetMethodWithAbi + newTlbTypes map[string]struct{} + loadedTlbTypes []string + loadedTlbMsgTypes map[tlb.Tag][]TLBMsgBody + loadedTlbPayloadTypes map[string]map[tlb.Tag][]TLBMsgBody + contractToNamespace map[string]string +} + +type MsgType int + +func NewGenerator(abi []tolk.ABI, abiByGetMethod map[string][]GetMethodWithAbi) *Generator { + g := &Generator{ + structRefs: make(map[string]tolk.StructDeclaration), + aliasRefs: make(map[string]tolk.AliasDeclaration), + enumRefs: make(map[string]tolk.EnumDeclaration), + loadedTlbMsgTypes: make(map[tlb.Tag][]TLBMsgBody), + loadedTlbPayloadTypes: make(map[string]map[tlb.Tag][]TLBMsgBody), + contractToNamespace: make(map[string]string), + newTlbTypes: make(map[string]struct{}), + abi: abi, + abiByGetMethod: abiByGetMethod, + } + err := g.registerABI() + if err != nil { + panic(err) + } + + return g +} + +func (g *Generator) registerABI() error { + if err := g.mapRefs(); err != nil { + return err + } + + msgsName := make(map[string]struct{}) + for _, abi := range g.abi { + contractName := abi.GetGolangNamespace() + fullName := abi.GetGolangContractName() + + g.contractToNamespace[fullName] = contractName + + for _, declr := range abi.Declarations { + err := g.registerType(declr, contractName) + if err != nil { + return err + } + } + + for _, intMsg := range abi.IncomingMessages { + err := g.registerMsgType(MsgTypeInt, intMsg.BodyTy, contractName, fullName, msgsName) + if err != nil { + return err + } + err = g.registerMsgType(MsgTypePayload, intMsg.BodyTy, contractName, fullName, msgsName) + if err != nil { + return err + } + } + for _, intMsg := range abi.OutgoingMessages { + err := g.registerMsgType(MsgTypeInt, intMsg.BodyTy, contractName, fullName, msgsName) + if err != nil { + return err + } + err = g.registerMsgType(MsgTypePayload, intMsg.BodyTy, contractName, fullName, msgsName) + if err != nil { + return err + } + } + for _, extOutMsg := range abi.EmittedMessages { + err := g.registerMsgType(MsgTypeExtOut, extOutMsg.BodyTy, contractName, fullName, msgsName) + if err != nil { + return err + } + err = g.registerMsgType(MsgTypePayload, extOutMsg.BodyTy, contractName, fullName, msgsName) + if err != nil { + return err + } + } + if abi.IncomingExternal != nil { + err := g.registerMsgType(MsgTypeExtIn, abi.IncomingExternal.BodyTy, contractName, fullName, msgsName) + if err != nil { + return err + } + err = g.registerMsgType(MsgTypePayload, abi.IncomingExternal.BodyTy, contractName, fullName, msgsName) + if err != nil { + return err + } + } + } + + return nil +} + +func (g *Generator) registerType(declr tolk.Declaration, namespace string) error { + var result *tolkParser.DeclrResult + var err error + switch declr.SumType { + case "Struct": + result, err = tolkParser.ParseStructDeclr(declr.StructDeclaration, namespace) + if err != nil { + return err + } + case "Alias": + result, err = tolkParser.ParseAliasDeclr(declr.AliasDeclaration, namespace) + if err != nil { + return err + } + case "Enum": + result, err = tolkParser.ParseEnumDeclr(declr.EnumDeclaration, namespace) + if err != nil { + return err + } + default: + return fmt.Errorf("unknown declaration type") + } + + if _, ok := g.newTlbTypes[result.Name]; ok { + return nil + } + + g.newTlbTypes[result.Name] = struct{}{} + if declr.PayloadType == nil { + g.loadedTlbTypes = append(g.loadedTlbTypes, result.Code) + } else { + err = g.registerPayload(result, result.Tag, *declr.PayloadType, namespace) + if err != nil { + return err + } + } + + return nil +} + +func (g *Generator) registerPayload(result *tolkParser.DeclrResult, tag tolkParser.Tag, payloadType string, namespace string) error { + key := tlb.Tag{ + Len: tag.Len, + Val: tag.Val, + } + + payloadName := utils.ToCamelCase(payloadType) + + msg := TLBMsgBody{ + Type: MsgTypePayload, + GolangTypeName: result.Name, + GolangOpcodeName: result.Name + payloadName + "PayloadOp", + OperationName: result.Name + payloadName + "Payload", + Tag: tag.Val, + Code: result.Code, + } + if _, init := g.loadedTlbPayloadTypes[namespace]; !init { + g.loadedTlbPayloadTypes[namespace] = make(map[tlb.Tag][]TLBMsgBody) + } + g.loadedTlbPayloadTypes[namespace][key] = append(g.loadedTlbPayloadTypes[namespace][key], msg) + + return nil +} + +func (g *Generator) registerMsgType(mType MsgType, ty tolk.Ty, namespace, fullName string, msgsName map[string]struct{}) error { + tag, err := tolkParser.ParseTag(ty, g.structRefs, g.aliasRefs, g.enumRefs) + if err != nil { + return fmt.Errorf("can't decode tag error %w", err) + } + key := tlb.Tag{ + Len: tag.Len, + Val: tag.Val, + } + var typeSuffix string + var opSuffix string + switch mType { + case MsgTypeInt: + opSuffix = "MsgOp" + typeSuffix = "MsgBody" + case MsgTypeExtIn: + opSuffix = "ExtInMsgOp" + typeSuffix = "ExtInMsgBody" + case MsgTypeExtOut: + opSuffix = "ExtOutMsgOp" + typeSuffix = "ExtOutMsgBody" + case MsgTypePayload: + opSuffix = "Op" + typeSuffix = "PayloadBody" + } + + var typePrefix string + var msgName string + var res *tolkParser.MsgResult + switch ty.SumType { + case "StructRef": + typePrefix = utils.ToCamelCase(ty.StructRef.StructName) + msgName = namespace + typePrefix + typeSuffix + res, err = tolkParser.ParseStructMsg(ty, msgName, namespace) + if err != nil { + return err + } + case "AliasRef": + typePrefix = utils.ToCamelCase(ty.AliasRef.AliasName) + msgName = namespace + typePrefix + typeSuffix + res, err = tolkParser.ParseAliasMsg(ty, msgName, namespace) + if err != nil { + return err + } + default: + return fmt.Errorf("message type must be either struct or alias, got %v", ty.SumType) + } + + if _, ok := msgsName[msgName]; ok { + return nil + } + msgsName[msgName] = struct{}{} + msg := TLBMsgBody{ + Type: mType, + GolangTypeName: msgName, + GolangOpcodeName: namespace + typePrefix + opSuffix, + OperationName: namespace + typePrefix, + Tag: tag.Val, + Code: res.Code, + } + + if mType != MsgTypePayload { + g.loadedTlbMsgTypes[key] = append(g.loadedTlbMsgTypes[key], msg) + } else { + if _, init := g.loadedTlbPayloadTypes[fullName]; !init { + g.loadedTlbPayloadTypes[fullName] = make(map[tlb.Tag][]TLBMsgBody) + } + g.loadedTlbPayloadTypes[fullName][key] = append(g.loadedTlbPayloadTypes[fullName][key], msg) + } + + return nil +} + +func (g *Generator) mapRefs() error { + for _, abi := range g.abi { + for _, declr := range abi.Declarations { + switch declr.SumType { + case "Struct": + g.structRefs[declr.StructDeclaration.Name] = declr.StructDeclaration + case "Alias": + g.aliasRefs[declr.AliasDeclaration.Name] = declr.AliasDeclaration + case "Enum": + g.enumRefs[declr.EnumDeclaration.Name] = declr.EnumDeclaration + default: + return fmt.Errorf("unknown declaration type") + } + } + } + return nil +} + +func (g *Generator) CollectedTypes() string { + var builder strings.Builder + builder.WriteString(strings.Join(g.loadedTlbTypes, "\n\n")) + + builder.WriteRune('\n') + b, err := format.Source([]byte(builder.String())) + if err != nil { + panic(err) + } + return string(b) +} + +type messagesContext struct { + OperationsByIface map[string]map[tlb.Tag][]TLBMsgBody + OperationsByTag map[tlb.Tag][]TLBMsgBody + WhatRender string +} + +func (g *Generator) GenerateMsgDecoder() string { + s := g.generateMsgDecoder(MsgTypeInt, "MsgIn") + s += g.generateMsgDecoder(MsgTypeExtIn, "MsgExtIn") + s += g.generateMsgDecoder(MsgTypeExtOut, "MsgExtOut") + return s +} + +func (g *Generator) generateMsgDecoder(msgType MsgType, what string) string { + context := messagesContext{ + OperationsByTag: make(map[tlb.Tag][]TLBMsgBody), + WhatRender: what, + } + + for tag, operation := range g.loadedTlbMsgTypes { + filtered := make([]TLBMsgBody, 0, len(operation)) + for _, body := range operation { + if body.Type == msgType { + filtered = append(filtered, body) + } + } + if len(filtered) > 0 { + context.OperationsByTag[tag] = filtered + } + } + tmpl, err := template.New("messages").Parse(messagesTemplate) + if err != nil { + panic(err) + return "" + } + var buf bytes.Buffer + if err := tmpl.Execute(&buf, context); err != nil { + panic(err) + return "" + } + return buf.String() +} + +type getMethodContext struct { + GetMethods []getMethodDesc + SimpleMethods map[int][]string +} +type getMethodDesc struct { + Name string + MethodName string + ID int + Body string + Decoders []string + ResultTypes map[string]string +} + +func (g *Generator) GetMethods() (string, []string, error) { + context := getMethodContext{ + SimpleMethods: map[int][]string{}, + GetMethods: []getMethodDesc{}, + } + + usedNames := map[string]struct{}{} + var simpleMethods []string + for name, methods := range g.abiByGetMethod { + m0 := methods[0] + methodName := m0.GetMethod.GolangFunctionName() + var err error + desc := getMethodDesc{ + Name: name, + MethodName: methodName, + ResultTypes: make(map[string]string), + } + var methodID int + if m0.GetMethod.TvmMethodID != 0 { + methodID = m0.GetMethod.TvmMethodID + } else { + methodID = utils.MethodIdFromName(name) + } + if _, ok := usedNames[methodName]; ok { + continue + } + usedNames[methodName] = struct{}{} + + if len(m0.GetMethod.Parameters) == 0 { + simpleMethods = append(simpleMethods, m0.GetMethod.Name) + context.SimpleMethods[methodID] = append(context.SimpleMethods[methodID], methodName) + } + + desc.Body, err = g.getMethod(name, methodID, methods) + if err != nil { + return "", nil, err + } + + for _, m := range methods { + contractNamespace := m.ABI.GetGolangContractName() + resultTypeName := m.GetMethod.FullResultName(contractNamespace) + desc.Decoders = append(desc.Decoders, "Decode"+resultTypeName) + r, err := tolkParser.ParseGetMethodCode(m.GetMethod.ReturnTy, m.ABI.GetGolangNamespace()) + if err != nil { + return "", nil, err + } + desc.ResultTypes[resultTypeName] = r + } + + context.GetMethods = append(context.GetMethods, desc) + } + + tmpl, err := template.New("getMethods").Parse(getMethodsTemplate) + if err != nil { + return "", nil, err + } + var buf bytes.Buffer + if err := tmpl.Execute(&buf, context); err != nil { + return "", nil, err + } + b, err := format.Source([]byte(buf.String())) + if err != nil { + return "", nil, err + } + return string(b), simpleMethods, nil +} + +func (g *Generator) getMethod(methodName string, methodID int, m []GetMethodWithAbi) (string, error) { + var builder strings.Builder + var args []string + + builder.WriteString(fmt.Sprintf("func %v(ctx context.Context, executor Executor, reqAccountID ton.AccountID, ", m[0].GetMethod.GolangFunctionName())) + + for _, p := range m[0].GetMethod.Parameters { + t, err := tolkParser.ParseType(p.Ty, m[0].ABI.GetGolangNamespace()) + if err != nil { + return "", err + } + args = append(args, fmt.Sprintf("%v %v", utils.ToCamelCasePrivate(p.Name), t)) + } + builder.WriteString(strings.Join(args, ", ")) + builder.WriteString(") (string, any, error) {\n") + + builder.WriteString(buildInputStackValues(m[0].GetMethod.Parameters)) + builder.WriteRune('\n') + + builder.WriteString(fmt.Sprintf("// MethodID = %d for \"%s\" method\n", methodID, methodName)) + builder.WriteString(fmt.Sprintf("errCode, stack, err := executor.RunSmcMethodByID(ctx, reqAccountID, %d, stack)\n", methodID)) + builder.WriteString(returnStrNilErr) + builder.WriteString("if errCode != 0 && errCode != 1 {return \"\", nil, fmt.Errorf(\"method execution failed with code: %v\", errCode)}\n") + + decoders := "" + builder.WriteString("for _, f := range []func(tlb.VmStack)(string, any, error){") + + for _, curr := range m { + name := curr.GetMethod.FullResultName(curr.ABI.GetGolangContractName()) + builder.WriteString(fmt.Sprintf("Decode%s, ", name)) + resDecoder, err := g.buildOutputDecoder(name, curr.GetMethod.ReturnTy) + if err != nil { + return "", err + } + decoders = decoders + "\n\n" + resDecoder + } + + builder.WriteString("} {\n") + builder.WriteString("s, r, err := f(stack)\n") + builder.WriteString("if err == nil {return s, r, nil}\n") + builder.WriteString("}\n") + builder.WriteString("return \"\", nil, fmt.Errorf(\"can not decode outputs\")\n}\n") + builder.WriteString(decoders) + builder.WriteRune('\n') + + return builder.String(), nil +} + +func buildInputStackValues(p []tolk.Parameter) string { + var builder strings.Builder + builder.WriteString("stack := tlb.VmStack{}\n") + + if len(p) > 0 { + builder.WriteString("var (val tlb.VmStackValue\n err error)\n") + } + + for _, s := range p { + switch s.Ty.SumType { + case "IntN": + if s.Ty.IntN.N <= 64 { + builder.WriteString(fmt.Sprintf("val = tlb.VmStackValue{SumType: \"VmStkTinyInt\", VmStkTinyInt: int64(%s)}\n", + utils.ToCamelCasePrivate(s.Name))) + } else { + builder.WriteString(fmt.Sprintf("val = tlb.VmStackValue{SumType: \"VmStkInt\", VmStkInt: %s}\n", + utils.ToCamelCasePrivate(s.Name))) + } + case "UintN": + if s.Ty.UintN.N <= 63 { + builder.WriteString(fmt.Sprintf("val = tlb.VmStackValue{SumType: \"VmStkTinyInt\", VmStkTinyInt: int64(%s)}\n", + utils.ToCamelCasePrivate(s.Name))) + } else { + builder.WriteString(fmt.Sprintf("val = tlb.VmStackValue{SumType: \"VmStkInt\", VmStkInt: %s}\n", + utils.ToCamelCasePrivate(s.Name))) + } + case "Bool": + builder.WriteString(fmt.Sprintf("val = tlb.VmStackValue{SumType: \"VmStkTinyInt\", VmStkTinyInt: BoolToInt64(%s)}\n", + utils.ToCamelCasePrivate(s.Name))) + case "Coins": + builder.WriteString(fmt.Sprintf("val = tlb.VmStackValue{SumType: \"VmStkInt\", VmStkInt: tlb.Int257(BigIntFromUint(uint64(%s)))}\n", + utils.ToCamelCasePrivate(s.Name))) + case "VarIntN", "VarUintN", "Int": + builder.WriteString(fmt.Sprintf("val = tlb.VmStackValue{SumType: \"VmStkInt\", VmStkInt: %s}\n", + utils.ToCamelCasePrivate(s.Name))) + case "Address", "AddressExt", "AddressOpt", "AddressAny", "Slice", "Remaining", "BitsN": + builder.WriteString(fmt.Sprintf("val, err = tlb.TlbStructToVmCellSlice(%s)\n", + utils.ToCamelCasePrivate(s.Name))) + builder.WriteString(returnStrNilErr) + case "Cell", "Builder", "CellOf", "Map": + builder.WriteString(fmt.Sprintf("val, err = tlb.TlbStructToVmCell(%s)\n", + utils.ToCamelCasePrivate(s.Name))) + builder.WriteString(returnStrNilErr) + case "NullLiteral", "Void": + builder.WriteString("val = tlb.VmStackValue{SumType: \"VmStkNull\"}\n") + default: + builder.WriteString(fmt.Sprintf("val, err = tlb.TlbStructToVmCell(%s)\n", + utils.ToCamelCasePrivate(s.Name))) + builder.WriteString(returnStrNilErr) + } + builder.WriteString("stack.Put(val)\n") + } + + return builder.String() +} + +func (g *Generator) buildOutputDecoder(name string, ty tolk.Ty) (string, error) { + builder := new(strings.Builder) + + builder.WriteString(fmt.Sprintf("func Decode%s(stack tlb.VmStack) (resultType string, resultAny any, err error) {\n", name)) + + output, err := g.buildOutputStackCheck(ty) + if err != nil { + return "", err + } + builder.WriteString(output) + builder.WriteString(fmt.Sprintf("var result %v\n", name)) + builder.WriteString("err = stack.Unmarshal(&result)\n") + + builder.WriteString(fmt.Sprintf("return \"%s\",result, err", name)) + + builder.WriteString("}\n") + + return builder.String(), nil +} + +func (g *Generator) buildOutputStackCheck(ty tolk.Ty) (string, error) { + var builder strings.Builder + + var checksBuilder strings.Builder + res, err := g.buildOutputStackTy(ty, &checksBuilder, 0, false, make(map[string]tolk.Ty)) + if err != nil { + return "", err + } + + builder.WriteString(fmt.Sprintf("if len(stack) != %d ", res+1)) + builder.WriteString(checksBuilder.String()) + builder.WriteString(returnInvalidStack) + return builder.String(), nil +} + +func (g *Generator) buildOutputStackTy( + ty tolk.Ty, + builder *strings.Builder, + stackIndex int, + isNullable bool, + genericsMap map[string]tolk.Ty, +) (int, error) { + stackType := fmt.Sprintf("stack[%d].SumType", stackIndex) + nullableCheck := "" + if isNullable { + nullableCheck = fmt.Sprintf(" && %s != \"VmStkNull\"", stackType) + } + + switch ty.SumType { + case "IntN", "UintN", "VarIntN", "VarUintN", "Coins", "Bool", "Int": + builder.WriteString(fmt.Sprintf("|| ((%s != \"VmStkTinyInt\" && %s != \"VmStkInt\")%s) ", stackType, stackType, nullableCheck)) + case "Address", "AddressExt", "AddressOpt", "AddressAny", "Slice", "Remaining", "BitsN": + builder.WriteString(fmt.Sprintf("|| (%s != \"VmStkSlice\"%s) ", stackType, nullableCheck)) + case "Cell", "Builder", "CellOf", "Map": + builder.WriteString(fmt.Sprintf("|| (%s != \"VmStkCell\"%s) ", stackType, nullableCheck)) + case "Tensor": + for _, item := range ty.Tensor.Items { + i, err := g.buildOutputStackTy(item, builder, stackIndex, isNullable, genericsMap) + if err != nil { + return 0, err + } + stackIndex = i + 1 + } + return stackIndex - 1, nil + case "TupleWith": + for _, item := range ty.TupleWith.Items { + i, err := g.buildOutputStackTy(item, builder, stackIndex, isNullable, genericsMap) + if err != nil { + return 0, err + } + stackIndex = i + 1 + } + return stackIndex - 1, nil + case "NullLiteral", "Void": + builder.WriteString(fmt.Sprintf("|| (%s != \"VmStkNull\") ", stackType)) + case "Callable": + builder.WriteString(fmt.Sprintf("|| (%s != \"VmStkCont\") ", stackType)) + case "Nullable": + i, err := g.buildOutputStackTy(ty.Nullable.Inner, builder, stackIndex, true, genericsMap) + if err != nil { + return 0, err + } + return i, nil + case "EnumRef": + enumTy, found := g.enumRefs[ty.EnumRef.EnumName] + if !found { + return 0, fmt.Errorf("EnumRef %s not found in enumRefs", ty.EnumRef.EnumName) + } + i, err := g.buildOutputStackTy(enumTy.EncodedAs, builder, stackIndex, isNullable, genericsMap) + if err != nil { + return 0, err + } + return i, nil + case "AliasRef": + aliasTy, found := g.aliasRefs[ty.AliasRef.AliasName] + if !found { + return 0, fmt.Errorf("alias %s not found in aliasRefs", ty.AliasRef.AliasName) + } + genericMap := make(map[string]tolk.Ty) + for i, genericName := range aliasTy.TypeParams { + resolvedTy, err := g.resolveGenericT(genericsMap, ty.AliasRef.TypeArgs[i]) + if err != nil { + return 0, err + } + genericMap[genericName] = *resolvedTy + } + i, err := g.buildOutputStackTy(aliasTy.TargetTy, builder, stackIndex, isNullable, genericMap) + if err != nil { + return 0, err + } + return i, nil + case "StructRef": + structTy, found := g.structRefs[ty.StructRef.StructName] + if !found { + return 0, fmt.Errorf("StructRef %s not found in structRefs", ty.StructRef.StructName) + } + genericMap := make(map[string]tolk.Ty) + for i, genericName := range structTy.TypeParams { + resolvedTy, err := g.resolveGenericT(genericsMap, ty.StructRef.TypeArgs[i]) + if err != nil { + return 0, err + } + genericMap[genericName] = *resolvedTy + } + for _, f := range structTy.Fields { + i, err := g.buildOutputStackTy(f.Ty, builder, stackIndex, isNullable, genericMap) + if err != nil { + return 0, err + } + stackIndex = i + 1 + } + return stackIndex - 1, nil + case "Generic": + currTy, ok := genericsMap[ty.Generic.NameT] + if !ok { + return 0, fmt.Errorf("type for generic %v not found", ty.Generic.NameT) + } + i, err := g.buildOutputStackTy(currTy, builder, stackIndex, isNullable, genericsMap) + if err != nil { + return 0, err + } + return i, nil + default: + return 0, fmt.Errorf("unsupported type %s", ty.SumType) + } + return stackIndex, nil +} + +func (g *Generator) resolveGenericT(genericMap map[string]tolk.Ty, ty tolk.Ty) (*tolk.Ty, error) { + switch ty.SumType { + case "Generic": + resolvedTy, ok := genericMap[ty.Generic.NameT] + if !ok { + return nil, fmt.Errorf("type for generic %v not found", ty.Generic.NameT) + } + return &resolvedTy, nil + } + return &ty, nil +} + +type methodDescription struct { + Name string + InvokeFnName string +} + +type interfaceDescription struct { + Name string + Results []string + GetMethods []string +} + +func (g *Generator) RenderInvocationOrderList(simpleMethods []string) (string, error) { + context := struct { + NamespaceToInterfaces map[string][]string + Interfaces map[string]string + InvocationOrder []methodDescription + InterfaceOrder []interfaceDescription + KnownHashes map[string]interfaceDescription + Inheritance map[string]string + IntMsgs, ExtInMsgs, ExtOutMsgs map[string][]string + }{ + NamespaceToInterfaces: map[string][]string{}, + Interfaces: map[string]string{}, + KnownHashes: map[string]interfaceDescription{}, + Inheritance: map[string]string{}, + IntMsgs: map[string][]string{}, + ExtInMsgs: map[string][]string{}, + ExtOutMsgs: map[string][]string{}, + } + descriptions := map[string]methodDescription{} + + inheritance := map[string]string{} // interface name -> parent interface + methodsByIface := map[string]map[string]string{} // interface name -> method name -> result name + + for _, methods := range g.abiByGetMethod { + method := methods[0] + if !method.GetMethod.UsedByIntrospection() { + continue + } + + invokeFnName := method.GetMethod.GolangFunctionName() + desc, ok := descriptions[invokeFnName] + if ok { + return "", fmt.Errorf("method duplicate %v", invokeFnName) + } + + desc = methodDescription{ + Name: method.GetMethod.Name, + InvokeFnName: invokeFnName, + } + descriptions[invokeFnName] = desc + } + for _, abi := range g.abi { + ifaceName := abi.GetGolangContractName() + methodsByIface[ifaceName] = map[string]string{} + if abi.InheritsContract != "" { + inheritance[ifaceName] = utils.ToCamelCase(abi.InheritsContract) + } + for _, method := range abi.GetMethods { + if !slices.Contains(simpleMethods, method.Name) { + continue + } + methodName := utils.ToCamelCase(method.Name) + resultName := fmt.Sprintf("%s_%sResult", ifaceName, methodName) + if _, ok := methodsByIface[ifaceName][methodName]; ok { + return "", fmt.Errorf("method duplicate %v, interface %v", methodName, ifaceName) + } + methodsByIface[ifaceName][methodName] = resultName + } + } + + context.Inheritance = inheritance + + for _, abi := range g.abi { + ifaceName := abi.GetGolangContractName() + namespace := abi.GetGolangNamespace() + context.Interfaces[ifaceName] = utils.ToSnakeCase(ifaceName) + context.NamespaceToInterfaces[namespace] = append(context.NamespaceToInterfaces[namespace], ifaceName) + ifaceMethods := map[string]string{} + for currentIface := ifaceName; currentIface != ""; currentIface = inheritance[currentIface] { + currentMethods := methodsByIface[currentIface] + for methodName, resultName := range currentMethods { + ifaceMethods[methodName] = resultName + } + } + description := interfaceDescription{ + Name: ifaceName, + } + methodNames := maps.Keys(ifaceMethods) + sort.Strings(methodNames) + for _, methodName := range methodNames { + description.GetMethods = append(description.GetMethods, methodName) + description.Results = append(description.Results, ifaceMethods[methodName]) + } + for _, m := range abi.IncomingMessages { + name, err := m.GetMsgName() + if err != nil { + return "", err + } + name = abi.GetGolangNamespace() + name + context.IntMsgs[ifaceName] = append(context.IntMsgs[ifaceName], utils.ToCamelCase(name)) + } + for _, m := range abi.OutgoingMessages { + name, err := m.GetMsgName() + if err != nil { + return "", err + } + name = abi.GetGolangNamespace() + name + context.IntMsgs[ifaceName] = append(context.IntMsgs[ifaceName], utils.ToCamelCase(name)) + } + for _, m := range abi.EmittedMessages { + name, err := m.GetMsgName() + if err != nil { + return "", err + } + name = abi.GetGolangNamespace() + name + context.ExtOutMsgs[ifaceName] = append(context.ExtOutMsgs[ifaceName], utils.ToCamelCase(name)) + } + if abi.IncomingExternal != nil { + name, err := abi.IncomingExternal.GetMsgName() + if err != nil { + return "", err + } + name = abi.GetGolangNamespace() + name + context.ExtInMsgs[ifaceName] = append(context.ExtInMsgs[ifaceName], utils.ToCamelCase(name)) + } + if len(abi.CodeHashes) > 0 { //we don't need to detect interfaces with code hashes because we can them directly + for _, hash := range abi.CodeHashes { + context.KnownHashes[hash] = description + } + } else { + context.InterfaceOrder = append(context.InterfaceOrder, description) + } + } + + for _, desc := range descriptions { + context.InvocationOrder = append(context.InvocationOrder, desc) + } + sort.Slice(context.InvocationOrder, func(i, j int) bool { + return context.InvocationOrder[i].Name < context.InvocationOrder[j].Name + }) + tmpl, err := template.New("invocationOrder").Parse(invocationOrderTemplate) + if err != nil { + return "", err + } + var buf bytes.Buffer + if err := tmpl.Execute(&buf, context); err != nil { + return "", err + } + return buf.String(), nil +} + +func (g *Generator) RenderPayload() (string, error) { + context := messagesContext{ + OperationsByIface: make(map[string]map[tlb.Tag][]TLBMsgBody), + OperationsByTag: make(map[tlb.Tag][]TLBMsgBody), + } + for tag, operation := range g.loadedTlbMsgTypes { + for _, body := range operation { + if body.Type == MsgTypePayload { + context.OperationsByTag[tag] = append(context.OperationsByTag[tag], body) + } + } + } + for _, payloads := range g.loadedTlbPayloadTypes { + for tag, operation := range payloads { + for _, body := range operation { + context.OperationsByTag[tag] = append(context.OperationsByTag[tag], body) + } + } + } + + for name, operations := range g.loadedTlbPayloadTypes { + _, found := g.contractToNamespace[name] // get namespace for contract + if !found { // current name is already namespace + continue + } + + context.OperationsByIface[name] = operations + } + for contractName, namespace := range g.contractToNamespace { + for tag, bodies := range g.loadedTlbPayloadTypes[namespace] { + if _, init := context.OperationsByIface[contractName]; !init { + context.OperationsByIface[contractName] = make(map[tlb.Tag][]TLBMsgBody) + } + context.OperationsByIface[contractName][tag] = append(context.OperationsByIface[contractName][tag], bodies...) + } + } + tmpl, err := template.New("payloads").Parse(payloadTmpl) + if err != nil { + return "", err + } + var buf bytes.Buffer + if err := tmpl.Execute(&buf, context); err != nil { + return "", err + } + return buf.String(), nil +} + +type messageOperation struct { + Name string + OpCode string + OpCodeLen int +} + +type messagesMDContext struct { + Operations []messageOperation +} + +// RenderMessagesMD renders messages.md file with messages and their names + opcodes. +func (g *Generator) RenderMessagesMD() (string, error) { + context := messagesMDContext{} + for opcode, bodies := range g.loadedTlbMsgTypes { + for _, body := range bodies { + operation := messageOperation{ + Name: body.OperationName, + OpCode: fmt.Sprintf("0x%08x", opcode.Val), + OpCodeLen: opcode.Len, + } + context.Operations = append(context.Operations, operation) + } + } + sort.Slice(context.Operations, func(i, j int) bool { + if context.Operations[i].Name == context.Operations[j].Name { + return context.Operations[i].OpCode < context.Operations[j].OpCode + } + return context.Operations[i].Name < context.Operations[j].Name + }) + tmpl, err := template.New("messagesMD").Parse(messagesMDTemplate) + if err != nil { + return "", err + } + var buf bytes.Buffer + if err := tmpl.Execute(&buf, context); err != nil { + return "", err + } + return buf.String(), nil +} + +func (g *Generator) RenderContractErrors() (string, error) { + tmpl, err := template.New("contractErrors").Parse(contractErrorsTmpl) + if err != nil { + return "", err + } + var context = struct { + Interfaces map[string]map[int]string + }{ + Interfaces: map[string]map[int]string{}, + } + for _, abi := range g.abi { + ifaceName := abi.GetGolangContractName() + context.Interfaces[ifaceName] = map[int]string{} + for _, e := range abi.ThrownErrors { + if e.Name == "" { + continue // skip unnamed errors + } + context.Interfaces[ifaceName][e.ErrCode] = e.Name + } + } + var buf bytes.Buffer + + err = tmpl.Execute(&buf, context) + return buf.String(), err + +} diff --git a/abi-tolk/parser/get_methods.tmpl b/abi-tolk/parser/get_methods.tmpl new file mode 100644 index 00000000..a240ac1e --- /dev/null +++ b/abi-tolk/parser/get_methods.tmpl @@ -0,0 +1,45 @@ + +var KnownGetMethodsDecoder = map[string][]func(tlb.VmStack) (string, any, error){ +{{- range $method := .GetMethods}} + "{{ $method.Name }}": { + {{- range $decoder := $method.Decoders }} + {{- $decoder -}}, + {{- end }} + }, +{{- end }} +} + +var KnownSimpleGetMethods = map[int][]func(ctx context.Context, executor Executor, reqAccountID ton.AccountID) (string, any, error){ +{{- range $id, $methods := .SimpleMethods}} + {{ $id }}: { + {{- range $name := $methods }} + {{- $name -}}, + {{- end }} + }, +{{- end }} +} + +var resultTypes = []interface{}{ +{{- range $method := .GetMethods }} + {{- range $name, $type := $method.ResultTypes }} + &{{ $name }}{}, + {{- end }} +{{- end }} +} + + +type Executor interface { + RunSmcMethodByID(ctx context.Context, accountID ton.AccountID, methodID int, params tlb.VmStack) (uint32, tlb.VmStack, error) +} + + + + +{{- range $method := .GetMethods }} +{{- range $name, $type := $method.ResultTypes }} + type {{ $name }} {{ $type }} +{{- end }} + + {{ $method.Body }} +{{- end }} + diff --git a/abi-tolk/parser/interfaces.tmpl b/abi-tolk/parser/interfaces.tmpl new file mode 100644 index 00000000..28dc42ef --- /dev/null +++ b/abi-tolk/parser/interfaces.tmpl @@ -0,0 +1,141 @@ + +const ( + IUnknown ContractInterface = iota +{{- range $name, $iface := .Interfaces }} + {{ $name }} +{{- end }} +) + +const ( + NUnknown contractNamespace = iota +{{- range $namespace, $ifaces := .NamespaceToInterfaces }} + {{ $namespace }} +{{- end }} +) + +var namespaceByInterface = map[ContractInterface]contractNamespace{ + IUnknown: NUnknown, + {{- range $namespace, $ifaces := .NamespaceToInterfaces }} + {{- range $iface := $ifaces }} + {{ $iface }}: {{ $namespace }}, + {{- end }} + {{- end }} +} + +func (c ContractInterface) String() string { +switch c { + {{- range $name, $iface := .Interfaces }} + case {{ $name }}: + return "{{ $iface }}" + {{- end }} + default: + return "unknown" + } +} + +func ContractInterfaceFromString(s string) ContractInterface { +switch s { + {{- range $name, $iface := .Interfaces }} + case "{{ $iface }}": + return {{ $name }} + {{- end }} + default: + return IUnknown + } +} + + +var methodInvocationOrder = []MethodDescription{ +{{- range $method := .InvocationOrder }} + { + Name: "{{ $method.Name }}", + InvokeFn: {{ $method.InvokeFnName }}, + + }, +{{- end }} +} + +var contractInterfacesOrder = []InterfaceDescription{ +{{- range $interface := .InterfaceOrder }} +{{- if $interface.Results }} + { + Name: {{ $interface.Name }}, + Results: []string{ + {{- range $r := $interface.Results }} + "{{ $r }}", + {{- end }} + }, + }, +{{- end }} +{{- end }} +} + +func (c ContractInterface) recursiveImplements(other ContractInterface) bool { + switch c { + {{- range $interface, $inherits := .Inheritance }} + case {{ $interface }}: + return {{ $inherits }}.Implements(other) + {{- end }} + } + return false +} + +var knownContracts = map[ton.Bits256]knownContractDescription{ +{{- range $hash, $interface := .KnownHashes }} + ton.MustParseHash("{{ $hash }}"): { + contractInterfaces: []ContractInterface{ {{ $interface.Name }} }, + getMethods: []InvokeFn{ + {{- range $method := $interface.GetMethods }} + {{ $method }}, + {{- end }} + + }, + }, + +{{- end }} +} + +func (c ContractInterface) IntMsgs() []msgDecoderFunc { + switch c { + {{- range $interface, $msgs := .IntMsgs }} + case {{ $interface }}: + return []msgDecoderFunc{ + {{- range $msg := $msgs }} + decodeFunc{{ $msg }}MsgBody, + {{- end }} + } + {{- end }} + default: + return nil + } +} + +func (c ContractInterface) ExtInMsgs() []msgDecoderFunc { + switch c { + {{- range $interface, $msgs := .ExtInMsgs }} + case {{ $interface }}: + return []msgDecoderFunc{ + {{- range $msg := $msgs }} + decodeFunc{{ $msg }}ExtInMsgBody, + {{- end }} + } + {{- end }} + default: + return nil + } +} + +func (c ContractInterface) ExtOutMsgs() []msgDecoderFunc { + switch c { + {{- range $interface, $msgs := .ExtOutMsgs }} + case {{ $interface }}: + return []msgDecoderFunc{ + {{- range $msg := $msgs }} + decodeFunc{{ $msg }}ExtOutMsgBody, + {{- end }} + } + {{- end }} + default: + return nil + } +} \ No newline at end of file diff --git a/abi-tolk/parser/messages.md.tmpl b/abi-tolk/parser/messages.md.tmpl new file mode 100644 index 00000000..5f03d81d --- /dev/null +++ b/abi-tolk/parser/messages.md.tmpl @@ -0,0 +1,12 @@ + +# List of supported message opcodes + +The first 4 bytes of a message's body identify the `operation` to be performed, or the `method` of the smart contract to be invoked. + +The list below contains the supported message operations, their names and opcodes. + +| Name | Message operation code | +|-------------|------------------------| +{{- range $_, $op := .Operations }} +| {{ $op.Name }}| {{ $op.OpCode }} | +{{- end }} diff --git a/abi-tolk/parser/messages.tmpl b/abi-tolk/parser/messages.tmpl new file mode 100644 index 00000000..31cc49cb --- /dev/null +++ b/abi-tolk/parser/messages.tmpl @@ -0,0 +1,60 @@ + + +var ( +{{- range $tag, $ops := .OperationsByTag }} + {{- range $op := $ops }} + // 0x{{ printf "%08x" $tag.Val }} + decodeFunc{{ $op.GolangTypeName }} = decodeMsg(tlb.Tag{Val:0x{{ printf "%08x" $tag.Val }},Len:{{ $tag.Len }}}, {{ $op.GolangOpcodeName }}, {{ $op.GolangTypeName }}{}) + {{- end }} + {{- end }} +) + +var opcoded{{ $.WhatRender }}DecodeFunctions = map[uint32]msgDecoderFunc { +{{- range $tag, $ops := .OperationsByTag }} + {{ if ne $tag.Len 32 }} {{continue}} {{end}} + {{- if gt (len $ops) 1 }} + // {{- range $op := $ops}}{{ $op.OperationName }}, {{ end }} + 0x{{ printf "%08x" $tag.Val }}:decodeMultipleMsgs([]msgDecoderFunc{ + {{- range $op := $ops }} + decodeFunc{{ $op.GolangTypeName }}, + {{- end }} }, + "0x{{ printf "%08x" $tag.Val }}", + ), + {{- else }} + {{- $op := index $ops 0 }} + // 0x{{ printf "%08x" $tag.Val }} + {{ $op.GolangOpcodeName }}Code: decodeFunc{{ $op.GolangTypeName }}, + {{- end }} + {{- end }} +} + + +const ( +{{- range $tag, $ops := .OperationsByTag }} + {{- range $op := $ops}} + {{ $op.GolangOpcodeName }} MsgOpName = "{{ $op.OperationName }}" + {{- end }} +{{- end }} +) + +const ( +{{- range $tag, $ops := .OperationsByTag }} + {{- range $op := $ops}} + {{ $op.GolangOpcodeName }}Code MsgOpCode = 0x{{ printf "%08x" $op.Tag }} + {{- end }} +{{- end }} +) + +{{- range $tag, $ops := .OperationsByTag }} + {{- range $op := $ops}} + {{ $op.Code }} + {{- end }} +{{- end }} + +var Known{{ $.WhatRender }}Types = map[string]any{ +{{- range $tag, $ops := .OperationsByTag }} + {{- range $op := $ops}} + {{ $op.GolangOpcodeName }}: {{ $op.GolangTypeName }}{}, + {{- end }} +{{- end }} +} \ No newline at end of file diff --git a/abi-tolk/parser/parser.go b/abi-tolk/parser/parser.go new file mode 100644 index 00000000..d67f57df --- /dev/null +++ b/abi-tolk/parser/parser.go @@ -0,0 +1,13 @@ +package parser + +import ( + "encoding/json" + + "github.com/tonkeeper/tongo/tolk" +) + +func ParseABI(s []byte) (tolk.ABI, error) { + var abi tolk.ABI + err := json.Unmarshal(s, &abi) + return abi, err +} diff --git a/abi-tolk/parser/parser_test.go b/abi-tolk/parser/parser_test.go new file mode 100644 index 00000000..d7844fbd --- /dev/null +++ b/abi-tolk/parser/parser_test.go @@ -0,0 +1,52 @@ +package parser + +import ( + "bytes" + _ "embed" + "encoding/json" + "fmt" + "os" + "testing" +) + +func TestParseABY(t *testing.T) { + type Case struct { + name string + filenamePrefix string + } + for _, c := range []Case{ + { + name: "simple abi", + filenamePrefix: "simple", + }, + { + name: "a lot of wrappers in abi", + filenamePrefix: "alot-wrappers", + }, + } { + t.Run(c.name, func(t *testing.T) { + inputFilename := fmt.Sprintf("testdata/%v.json", c.filenamePrefix) + outputFilename := fmt.Sprintf("testdata/%v.output.json", c.filenamePrefix) + expected, err := os.ReadFile(inputFilename) + if err != nil { + t.Fatal(err) + } + parsed, err := ParseABI(expected) + if err != nil { + t.Errorf("failed to unmarshall abi: %v", err) + } + + bs, err := json.MarshalIndent(parsed, " ", " ") + if err != nil { + t.Fatal(err) + } + err = os.WriteFile(outputFilename, bs, 0644) + if err != nil { + t.Errorf("failed to write output: %v", err) + } + if !bytes.Equal(bs, expected) { + t.Errorf("output does not match expected output") + } + }) + } +} diff --git a/abi-tolk/parser/payloads.tmpl b/abi-tolk/parser/payloads.tmpl new file mode 100644 index 00000000..f80e0aec --- /dev/null +++ b/abi-tolk/parser/payloads.tmpl @@ -0,0 +1,93 @@ + +{{- range $tag, $ops := .OperationsByTag }} + {{- range $op := $ops}} + func decode{{ $op.GolangOpcodeName }}Payload(j *Payload, c *boc.Cell) error { + var res {{ $op.GolangTypeName }} + err := tlb.Unmarshal(c, &res) + if err == nil {{if $op.FixedLength }} && completedRead(c) {{end}} { + j.SumType = {{ $op.GolangOpcodeName }} + j.Value = res + return nil + } + return err + } + {{ end }} +{{- end }} + + +const ( +{{- range $tag, $ops := .OperationsByTag }} + {{- range $op := $ops}} + {{ $op.GolangOpcodeName }} PayloadOpName = "{{ $op.OperationName }}" + {{- end }} +{{- end }} + +{{ range $tag, $ops := .OperationsByTag -}} + {{- range $op := $ops}} + {{ $op.GolangOpcodeName }}Code PayloadOpCode = 0x{{ printf "%08x" $op.Tag }} + {{- end }} +{{- end }} +) + +var KnownPayloadTypes = map[string]any{ +{{- range $tag, $ops := .OperationsByTag }} + {{- range $op := $ops}} + {{ $op.GolangOpcodeName }}: {{ $op.GolangTypeName }}{}, + {{- end }} +{{- end }} + +} +var PayloadOpCodes = map[PayloadOpName]PayloadOpCode{ +{{- range $tag, $ops := .OperationsByTag }} + {{- range $op := $ops}} + {{ $op.GolangOpcodeName }}: {{ $op.GolangOpcodeName }}Code, + {{- end }} +{{- end }} +} + +func (c ContractInterface) Payloads() map[PayloadOpCode][]func(*Payload, *boc.Cell) error { + switch c { + {{- range $iface, $opsByTag := .OperationsByIface }} + case {{ $iface }}: return map[PayloadOpCode][]func(*Payload, *boc.Cell) error{ + {{- range $tag, $ops := $opsByTag}} + {{- if eq (len $ops) 1}} + {{- range $op := $ops}} + {{ $op.GolangOpcodeName }}Code: {decode{{ $op.GolangOpcodeName }}Payload}, + {{- end}} + {{- else}} + {{ $tag.Val }}: { + {{- range $op := $ops}} + decode{{ $op.GolangOpcodeName }}Payload, + {{- end}} + }, + {{- end }} + {{- end }} + } + {{- end }} + default: + return nil + } +} + +var funcPayloadDecodersMapping = map[PayloadOpCode][]func(*Payload, *boc.Cell) error{ +{{- range $tag, $ops := .OperationsByTag }} + {{- if eq (len $ops) 1}} + {{- range $op := $ops}} + {{ $op.GolangOpcodeName }}Code: {decode{{ $op.GolangOpcodeName }}Payload}, + {{- end}} + {{- else}} + {{ $tag.Val }}: { + {{- range $op := $ops}} + decode{{ $op.GolangOpcodeName }}Payload, + {{- end}} + }, + {{- end }} +{{- end }} +} + + +{{- range $tag, $ops := .OperationsByTag }} + {{- range $op := $ops}} + {{ $op.Code }} + {{- end }} +{{- end }} \ No newline at end of file diff --git a/abi-tolk/parser/testdata/alot-wrappers.json b/abi-tolk/parser/testdata/alot-wrappers.json new file mode 100644 index 00000000..0bd3b945 --- /dev/null +++ b/abi-tolk/parser/testdata/alot-wrappers.json @@ -0,0 +1,3572 @@ +{ + "contractName": "LotsOfWrappers", + "declarations": [ + { + "kind": "Struct", + "name": "JustUint5", + "fields": [ + { + "name": "value", + "ty": { + "kind": "uintN", + "n": 5 + } + } + ] + }, + { + "kind": "Struct", + "name": "JustInt32", + "fields": [ + { + "name": "value", + "ty": { + "kind": "intN", + "n": 32 + } + } + ] + }, + { + "kind": "Struct", + "name": "JustMaybeInt32", + "fields": [ + { + "name": "value", + "ty": { + "kind": "nullable", + "inner": { + "kind": "intN", + "n": 32 + } + }, + "defaultValue": { + "kind": "null" + } + } + ] + }, + { + "kind": "Struct", + "name": "TwoInts32AndCoins", + "fields": [ + { + "name": "op", + "ty": { + "kind": "intN", + "n": 32 + } + }, + { + "name": "amount", + "ty": { + "kind": "coins" + }, + "defaultValue": { + "kind": "int", + "v": "1000000000" + } + } + ] + }, + { + "kind": "Struct", + "name": "TwoInts32And64", + "fields": [ + { + "name": "op", + "ty": { + "kind": "intN", + "n": 32 + } + }, + { + "name": "query_id", + "ty": { + "kind": "uintN", + "n": 64 + } + } + ] + }, + { + "kind": "Struct", + "name": "TwoInts32AndRef64", + "fields": [ + { + "name": "op", + "ty": { + "kind": "intN", + "n": 32 + } + }, + { + "name": "query_id_ref", + "ty": { + "kind": "cellOf", + "inner": { + "kind": "uintN", + "n": 64 + } + } + } + ] + }, + { + "kind": "Struct", + "name": "TwoInts32AndMaybe64", + "fields": [ + { + "name": "op", + "ty": { + "kind": "intN", + "n": 32 + } + }, + { + "name": "query_id", + "ty": { + "kind": "nullable", + "inner": { + "kind": "uintN", + "n": 64 + } + } + }, + { + "name": "demo_bool_field", + "ty": { + "kind": "bool" + } + } + ] + }, + { + "kind": "Struct", + "name": "JustAddress", + "fields": [ + { + "name": "addr", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "TwoInts32And64SepByAddress", + "fields": [ + { + "name": "op", + "ty": { + "kind": "intN", + "n": 32 + } + }, + { + "name": "addr_e", + "ty": { + "kind": "addressAny" + } + }, + { + "name": "query_id", + "ty": { + "kind": "uintN", + "n": 64 + } + } + ] + }, + { + "kind": "Struct", + "name": "IntAndEitherInt8Or256", + "fields": [ + { + "name": "op", + "ty": { + "kind": "intN", + "n": 32 + } + }, + { + "name": "i8or256", + "ty": { + "kind": "union", + "variants": [ + { + "prefixStr": "0", + "prefixLen": 1, + "prefixEatInPlace": true, + "variantTy": { + "kind": "intN", + "n": 8 + } + }, + { + "prefixStr": "1", + "prefixLen": 1, + "prefixEatInPlace": true, + "variantTy": { + "kind": "intN", + "n": 256 + } + } + ] + } + } + ] + }, + { + "kind": "Struct", + "name": "Inner1", + "fields": [ + { + "name": "query_id_ref", + "ty": { + "kind": "uintN", + "n": 64 + } + } + ] + }, + { + "kind": "Struct", + "name": "Inner2", + "fields": [ + { + "name": "i64_in_ref", + "ty": { + "kind": "intN", + "n": 64 + } + } + ] + }, + { + "kind": "Struct", + "name": "IntAndEither32OrRef64", + "fields": [ + { + "name": "op", + "ty": { + "kind": "intN", + "n": 32 + } + }, + { + "name": "i32orRef", + "ty": { + "kind": "union", + "variants": [ + { + "prefixStr": "0", + "prefixLen": 1, + "prefixEatInPlace": true, + "variantTy": { + "kind": "intN", + "n": 32 + } + }, + { + "prefixStr": "1", + "prefixLen": 1, + "prefixEatInPlace": true, + "variantTy": { + "kind": "cellOf", + "inner": { + "kind": "StructRef", + "structName": "Inner2" + } + } + } + ] + } + }, + { + "name": "query_id_maybe_ref", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cellOf", + "inner": { + "kind": "StructRef", + "structName": "Inner1" + } + } + } + } + ] + }, + { + "kind": "Struct", + "name": "EitherLeft", + "typeParams": [ + "T" + ], + "fields": [ + { + "name": "value", + "ty": { + "kind": "genericT", + "nameT": "T" + } + } + ] + }, + { + "kind": "Struct", + "name": "EitherRight", + "typeParams": [ + "T" + ], + "fields": [ + { + "name": "value", + "ty": { + "kind": "genericT", + "nameT": "T" + } + } + ] + }, + { + "kind": "Struct", + "name": "IntAndEither8OrMaybe256", + "fields": [ + { + "name": "value", + "ty": { + "kind": "AliasRef", + "aliasName": "Either", + "typeArgs": [ + { + "kind": "intN", + "n": 8 + }, + { + "kind": "nullable", + "inner": { + "kind": "intN", + "n": 256 + } + } + ] + } + }, + { + "name": "op", + "ty": { + "kind": "intN", + "n": 32 + } + } + ] + }, + { + "kind": "Struct", + "name": "MaybeNothing", + "fields": [] + }, + { + "kind": "Struct", + "name": "MaybeJust", + "typeParams": [ + "T" + ], + "fields": [ + { + "name": "value", + "ty": { + "kind": "genericT", + "nameT": "T" + } + } + ] + }, + { + "kind": "Struct", + "name": "IntAndMaybeMaybe8", + "fields": [ + { + "name": "value", + "ty": { + "kind": "AliasRef", + "aliasName": "Maybe", + "typeArgs": [ + { + "kind": "AliasRef", + "aliasName": "Maybe", + "typeArgs": [ + { + "kind": "intN", + "n": 8 + } + ] + } + ] + } + }, + { + "name": "op", + "ty": { + "kind": "intN", + "n": 32 + } + } + ] + }, + { + "kind": "Struct", + "name": "SomeBytesFields", + "fields": [ + { + "name": "f1", + "ty": { + "kind": "bitsN", + "n": 8 + } + }, + { + "name": "f2", + "ty": { + "kind": "bitsN", + "n": 3 + } + }, + { + "name": "f3", + "ty": { + "kind": "nullable", + "inner": { + "kind": "bitsN", + "n": 20 + } + } + }, + { + "name": "f4", + "ty": { + "kind": "union", + "variants": [ + { + "prefixStr": "0", + "prefixLen": 1, + "prefixEatInPlace": true, + "variantTy": { + "kind": "bitsN", + "n": 100 + } + }, + { + "prefixStr": "1", + "prefixLen": 1, + "prefixEatInPlace": true, + "variantTy": { + "kind": "bitsN", + "n": 200 + } + } + ] + } + } + ] + }, + { + "kind": "Struct", + "name": "IntAndRestInlineCell", + "fields": [ + { + "name": "op", + "ty": { + "kind": "intN", + "n": 32 + } + }, + { + "name": "rest", + "ty": { + "kind": "remaining" + } + } + ] + }, + { + "kind": "Struct", + "name": "IntAndRestRefCell", + "fields": [ + { + "name": "op", + "ty": { + "kind": "intN", + "n": 32 + } + }, + { + "name": "rest", + "ty": { + "kind": "cell" + } + } + ] + }, + { + "kind": "Struct", + "name": "IntAndRestEitherCellOrRefCell", + "fields": [ + { + "name": "op", + "ty": { + "kind": "intN", + "n": 32 + } + }, + { + "name": "rest", + "ty": { + "kind": "union", + "variants": [ + { + "prefixStr": "0", + "prefixLen": 1, + "prefixEatInPlace": true, + "variantTy": { + "kind": "remaining" + } + }, + { + "prefixStr": "1", + "prefixLen": 1, + "prefixEatInPlace": true, + "variantTy": { + "kind": "cell" + } + } + ] + } + } + ] + }, + { + "kind": "Struct", + "name": "DifferentMaybeRefs", + "fields": [ + { + "name": "op", + "ty": { + "kind": "intN", + "n": 32 + }, + "defaultValue": { + "kind": "int", + "v": "123" + } + }, + { + "name": "ref1m", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cell" + } + } + }, + { + "name": "ref2m", + "ty": { + "kind": "AliasRef", + "aliasName": "dict" + } + }, + { + "name": "ref3", + "ty": { + "kind": "cell" + } + }, + { + "name": "ref4m32", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cellOf", + "inner": { + "kind": "StructRef", + "structName": "JustInt32" + } + } + } + }, + { + "name": "query_id", + "ty": { + "kind": "intN", + "n": 64 + } + } + ] + }, + { + "kind": "Struct", + "name": "DifferentIntsWithMaybe", + "fields": [ + { + "name": "ji", + "ty": { + "kind": "StructRef", + "structName": "JustInt32" + } + }, + { + "name": "jmi", + "ty": { + "kind": "StructRef", + "structName": "JustMaybeInt32" + } + }, + { + "name": "jiMaybe", + "ty": { + "kind": "nullable", + "inner": { + "kind": "StructRef", + "structName": "JustInt32" + } + } + }, + { + "name": "jmiMaybe", + "ty": { + "kind": "nullable", + "inner": { + "kind": "StructRef", + "structName": "JustMaybeInt32" + } + } + } + ] + }, + { + "kind": "Struct", + "name": "DifferentMix1", + "fields": [ + { + "name": "ja1", + "ty": { + "kind": "StructRef", + "structName": "JustAddress" + } + }, + { + "name": "ja2m", + "ty": { + "kind": "nullable", + "inner": { + "kind": "StructRef", + "structName": "JustAddress" + } + } + }, + { + "name": "ext_nn", + "ty": { + "kind": "addressAny" + } + }, + { + "name": "imm", + "ty": { + "kind": "StructRef", + "structName": "IntAndMaybeMaybe8" + } + }, + { + "name": "tis", + "ty": { + "kind": "StructRef", + "structName": "TwoInts32And64SepByAddress" + } + } + ] + }, + { + "kind": "Struct", + "name": "DifferentMix2", + "fields": [ + { + "name": "iae", + "ty": { + "kind": "cellOf", + "inner": { + "kind": "StructRef", + "structName": "IntAndEither32OrRef64" + } + } + }, + { + "name": "tic", + "ty": { + "kind": "StructRef", + "structName": "TwoInts32AndCoins" + } + }, + { + "name": "rest", + "ty": { + "kind": "remaining" + } + } + ] + }, + { + "kind": "Struct", + "name": "DifferentMix3", + "fields": [ + { + "name": "bod", + "ty": { + "kind": "union", + "variants": [ + { + "prefixStr": "0", + "prefixLen": 1, + "prefixEatInPlace": true, + "variantTy": { + "kind": "cellOf", + "inner": { + "kind": "StructRef", + "structName": "TwoInts32AndCoins" + } + } + }, + { + "prefixStr": "1", + "prefixLen": 1, + "prefixEatInPlace": true, + "variantTy": { + "kind": "cellOf", + "inner": { + "kind": "StructRef", + "structName": "JustInt32" + } + } + } + ] + } + }, + { + "name": "tim", + "ty": { + "kind": "nullable", + "inner": { + "kind": "StructRef", + "structName": "TwoInts32AndCoins" + } + } + }, + { + "name": "pairm", + "ty": { + "kind": "nullable", + "inner": { + "kind": "tensor", + "items": [ + { + "kind": "intN", + "n": 32 + }, + { + "kind": "intN", + "n": 64 + } + ] + } + }, + "defaultValue": { + "kind": "null" + } + } + ] + }, + { + "kind": "Struct", + "name": "WithVariadicInts", + "fields": [ + { + "name": "ui16", + "ty": { + "kind": "varuintN", + "n": 16 + } + }, + { + "name": "i16", + "ty": { + "kind": "varintN", + "n": 16 + } + }, + { + "name": "ui32", + "ty": { + "kind": "varuintN", + "n": 32 + } + }, + { + "name": "i32", + "ty": { + "kind": "varintN", + "n": 32 + } + } + ] + }, + { + "kind": "Struct", + "name": "EdgeCaseInts", + "fields": [ + { + "name": "maxUint", + "ty": { + "kind": "uintN", + "n": 256 + }, + "defaultValue": { + "kind": "int", + "v": "115792089237316195423570985008687907853269984665640564039457584007913129639935" + } + }, + { + "name": "maxInt", + "ty": { + "kind": "intN", + "n": 257 + }, + "defaultValue": { + "kind": "int", + "v": "115792089237316195423570985008687907853269984665640564039457584007913129639935" + } + }, + { + "name": "minInt", + "ty": { + "kind": "intN", + "n": 257 + }, + "defaultValue": { + "kind": "int", + "v": "-115792089237316195423570985008687907853269984665640564039457584007913129639936" + } + } + ] + }, + { + "kind": "Struct", + "name": "WriteWithBuilder", + "fields": [ + { + "name": "f1", + "ty": { + "kind": "intN", + "n": 32 + } + }, + { + "name": "rest", + "ty": { + "kind": "builder" + } + } + ] + }, + { + "kind": "Struct", + "name": "WriteWithSlice", + "fields": [ + { + "name": "f1", + "ty": { + "kind": "intN", + "n": 32 + } + }, + { + "name": "rest", + "ty": { + "kind": "slice" + } + } + ] + }, + { + "kind": "Struct", + "name": "ReadWrittenWithBuilder", + "fields": [ + { + "name": "f1", + "ty": { + "kind": "intN", + "n": 32 + } + }, + { + "name": "someInt", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "someCell", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cell" + } + } + } + ] + }, + { + "kind": "Struct", + "name": "ReadWriteRest", + "typeParams": [ + "T" + ], + "fields": [ + { + "name": "f1", + "ty": { + "kind": "intN", + "n": 32 + } + }, + { + "name": "f2", + "ty": { + "kind": "coins" + } + }, + { + "name": "rest", + "ty": { + "kind": "genericT", + "nameT": "T" + } + } + ] + }, + { + "kind": "Struct", + "name": "Tail224", + "fields": [ + { + "name": "ji", + "ty": { + "kind": "StructRef", + "structName": "JustInt32" + } + }, + { + "name": "addr", + "ty": { + "kind": "address" + } + }, + { + "name": "ref1", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cellOf", + "inner": { + "kind": "intN", + "n": 32 + } + } + } + }, + { + "name": "ref2", + "ty": { + "kind": "cellOf", + "inner": { + "kind": "StructRef", + "structName": "JustAddress" + } + } + } + ] + }, + { + "kind": "Struct", + "name": "ReadWriteMid", + "typeParams": [ + "T" + ], + "fields": [ + { + "name": "f1", + "ty": { + "kind": "intN", + "n": 32 + } + }, + { + "name": "mid", + "ty": { + "kind": "genericT", + "nameT": "T" + } + }, + { + "name": "f3", + "ty": { + "kind": "coins" + } + } + ] + }, + { + "kind": "Struct", + "name": "WithTwoRestFields", + "fields": [ + { + "name": "i32", + "ty": { + "kind": "intN", + "n": 32 + } + }, + { + "name": "rest1", + "ty": { + "kind": "remaining" + } + }, + { + "name": "rest2", + "ty": { + "kind": "remaining" + } + } + ] + }, + { + "kind": "Struct", + "name": "MoreTrickyCells", + "typeParams": [ + "T3", + "T4" + ], + "fields": [ + { + "name": "c1", + "ty": { + "kind": "cellOf", + "inner": { + "kind": "union", + "variants": [ + { + "prefixStr": "0", + "prefixLen": 1, + "prefixEatInPlace": true, + "variantTy": { + "kind": "intN", + "n": 32 + } + }, + { + "prefixStr": "1", + "prefixLen": 1, + "prefixEatInPlace": true, + "variantTy": { + "kind": "intN", + "n": 64 + } + } + ] + } + } + }, + { + "name": "c2", + "ty": { + "kind": "cellOf", + "inner": { + "kind": "cellOf", + "inner": { + "kind": "addressAny" + } + } + } + }, + { + "name": "c3", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cellOf", + "inner": { + "kind": "genericT", + "nameT": "T3" + } + } + } + }, + { + "name": "c4", + "ty": { + "kind": "union", + "variants": [ + { + "prefixStr": "0", + "prefixLen": 1, + "prefixEatInPlace": true, + "variantTy": { + "kind": "cellOf", + "inner": { + "kind": "genericT", + "nameT": "T4" + } + } + }, + { + "prefixStr": "1", + "prefixLen": 1, + "prefixEatInPlace": true, + "variantTy": { + "kind": "bool" + } + } + ] + } + } + ] + }, + { + "kind": "Struct", + "name": "WithMoreTrickyCells", + "fields": [ + { + "name": "before", + "ty": { + "kind": "intN", + "n": 8 + } + }, + { + "name": "tricky", + "ty": { + "kind": "StructRef", + "structName": "MoreTrickyCells", + "typeArgs": [ + { + "kind": "StructRef", + "structName": "TwoInts32And64" + }, + { + "kind": "union", + "variants": [ + { + "prefixStr": "0b00", + "prefixLen": 2, + "prefixEatInPlace": true, + "variantTy": { + "kind": "StructRef", + "structName": "MaybeJust", + "typeArgs": [ + { + "kind": "intN", + "n": 8 + } + ] + } + }, + { + "prefixStr": "0b01", + "prefixLen": 2, + "prefixEatInPlace": true, + "variantTy": { + "kind": "intN", + "n": 16 + } + }, + { + "prefixStr": "0b10", + "prefixLen": 2, + "prefixEatInPlace": true, + "variantTy": { + "kind": "StructRef", + "structName": "MaybeNothing" + } + } + ] + } + ] + } + }, + { + "name": "after", + "ty": { + "kind": "intN", + "n": 8 + } + } + ] + }, + { + "kind": "Struct", + "name": "WithMoreTrickyAddresses1", + "fields": [ + { + "name": "a1", + "ty": { + "kind": "addressOpt" + } + }, + { + "name": "a2", + "ty": { + "kind": "union", + "variants": [ + { + "prefixStr": "0b00", + "prefixLen": 2, + "prefixEatInPlace": true, + "variantTy": { + "kind": "address" + } + }, + { + "prefixStr": "0b01", + "prefixLen": 2, + "prefixEatInPlace": true, + "variantTy": { + "kind": "AliasRef", + "aliasName": "MyInt32" + } + }, + { + "prefixStr": "0b10", + "prefixLen": 2, + "prefixEatInPlace": true, + "variantTy": { + "kind": "StructRef", + "structName": "MaybeNothing" + } + } + ] + } + }, + { + "name": "a3", + "ty": { + "kind": "union", + "variants": [ + { + "prefixStr": "0", + "prefixLen": 1, + "prefixEatInPlace": true, + "variantTy": { + "kind": "StructRef", + "structName": "TwoInts32And64" + } + }, + { + "prefixStr": "1", + "prefixLen": 1, + "prefixEatInPlace": true, + "variantTy": { + "kind": "AliasRef", + "aliasName": "MaybeJustOfAddress" + } + } + ] + } + }, + { + "name": "a4", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cellOf", + "inner": { + "kind": "addressOpt" + } + } + } + }, + { + "name": "a5", + "ty": { + "kind": "union", + "variants": [ + { + "prefixStr": "0", + "prefixLen": 1, + "prefixEatInPlace": true, + "variantTy": { + "kind": "address" + } + }, + { + "prefixStr": "1", + "prefixLen": 1, + "prefixEatInPlace": true, + "variantTy": { + "kind": "cellOf", + "inner": { + "kind": "addressAny" + } + } + } + ] + } + } + ] + }, + { + "kind": "Struct", + "name": "WithMoreTrickyAddresses2", + "fields": [ + { + "name": "a1", + "ty": { + "kind": "AliasRef", + "aliasName": "Maybe", + "typeArgs": [ + { + "kind": "address" + } + ] + } + }, + { + "name": "a2", + "ty": { + "kind": "AliasRef", + "aliasName": "Maybe", + "typeArgs": [ + { + "kind": "addressOpt" + } + ] + } + }, + { + "name": "a3", + "ty": { + "kind": "nullable", + "inner": { + "kind": "StructRef", + "structName": "JustAddress" + } + } + }, + { + "name": "a4", + "ty": { + "kind": "union", + "variants": [ + { + "prefixStr": "0b10", + "prefixLen": 2, + "prefixEatInPlace": true, + "variantTy": { + "kind": "address" + } + }, + { + "prefixStr": "0b11", + "prefixLen": 2, + "prefixEatInPlace": true, + "variantTy": { + "kind": "intN", + "n": 64 + } + }, + { + "prefixStr": "0b0", + "prefixLen": 1, + "prefixEatInPlace": true, + "variantTy": { + "kind": "nullLiteral" + } + } + ] + } + }, + { + "name": "a5", + "ty": { + "kind": "union", + "variants": [ + { + "prefixStr": "0", + "prefixLen": 1, + "prefixEatInPlace": true, + "variantTy": { + "kind": "address" + } + }, + { + "prefixStr": "1", + "prefixLen": 1, + "prefixEatInPlace": true, + "variantTy": { + "kind": "cellOf", + "inner": { + "kind": "address" + } + } + } + ] + } + } + ] + }, + { + "kind": "Struct", + "name": "WithAnyAddress", + "fields": [ + { + "name": "a1", + "ty": { + "kind": "addressAny" + } + }, + { + "name": "a2", + "ty": { + "kind": "nullable", + "inner": { + "kind": "addressAny" + } + } + }, + { + "name": "a3", + "ty": { + "kind": "union", + "variants": [ + { + "prefixStr": "0", + "prefixLen": 1, + "prefixEatInPlace": true, + "variantTy": { + "kind": "addressAny" + } + }, + { + "prefixStr": "1", + "prefixLen": 1, + "prefixEatInPlace": true, + "variantTy": { + "kind": "intN", + "n": 64 + } + } + ] + } + }, + { + "name": "a4", + "ty": { + "kind": "union", + "variants": [ + { + "prefixStr": "0", + "prefixLen": 1, + "prefixEatInPlace": true, + "variantTy": { + "kind": "address" + } + }, + { + "prefixStr": "1", + "prefixLen": 1, + "prefixEatInPlace": true, + "variantTy": { + "kind": "addressAny" + } + } + ] + } + }, + { + "name": "a5", + "ty": { + "kind": "AliasRef", + "aliasName": "Maybe", + "typeArgs": [ + { + "kind": "addressAny" + } + ] + } + }, + { + "name": "a6", + "ty": { + "kind": "cellOf", + "inner": { + "kind": "addressAny" + } + } + }, + { + "name": "a7", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cellOf", + "inner": { + "kind": "nullable", + "inner": { + "kind": "addressAny" + } + } + } + } + } + ] + }, + { + "kind": "Struct", + "name": "MsgSinglePrefix32", + "prefix": { + "prefixStr": "0x87654321", + "prefixLen": 32 + }, + "fields": [ + { + "name": "amount1", + "ty": { + "kind": "coins" + } + }, + { + "name": "amount2", + "ty": { + "kind": "coins" + } + } + ] + }, + { + "kind": "Struct", + "name": "MsgSinglePrefix48", + "prefix": { + "prefixStr": "0x876543211234", + "prefixLen": 48 + }, + "fields": [ + { + "name": "amount", + "ty": { + "kind": "union", + "variants": [ + { + "prefixStr": "0", + "prefixLen": 1, + "prefixEatInPlace": true, + "variantTy": { + "kind": "coins" + } + }, + { + "prefixStr": "1", + "prefixLen": 1, + "prefixEatInPlace": true, + "variantTy": { + "kind": "uintN", + "n": 64 + } + } + ] + } + } + ] + }, + { + "kind": "Struct", + "name": "CounterIncrement", + "prefix": { + "prefixStr": "0x12345678", + "prefixLen": 32 + }, + "fields": [ + { + "name": "counter_id", + "ty": { + "kind": "intN", + "n": 8 + } + }, + { + "name": "inc_by", + "ty": { + "kind": "intN", + "n": 32 + } + } + ] + }, + { + "kind": "Struct", + "name": "CounterDecrement", + "prefix": { + "prefixStr": "0x23456789", + "prefixLen": 32 + }, + "fields": [ + { + "name": "counter_id", + "ty": { + "kind": "intN", + "n": 8 + } + }, + { + "name": "dec_by", + "ty": { + "kind": "intN", + "n": 32 + } + } + ] + }, + { + "kind": "Struct", + "name": "CounterReset0", + "prefix": { + "prefixStr": "0x34567890", + "prefixLen": 32 + }, + "fields": [ + { + "name": "counter_id", + "ty": { + "kind": "intN", + "n": 8 + } + } + ] + }, + { + "kind": "Struct", + "name": "CounterResetTo", + "prefix": { + "prefixStr": "0x00184300", + "prefixLen": 32 + }, + "fields": [ + { + "name": "counter_id", + "ty": { + "kind": "intN", + "n": 8 + } + }, + { + "name": "initial_value", + "ty": { + "kind": "intN", + "n": 64 + } + } + ] + }, + { + "kind": "Alias", + "name": "CounterIncrementAlias", + "targetTy": { + "kind": "StructRef", + "structName": "CounterIncrement" + } + }, + { + "kind": "Struct", + "name": "BodyPayload1", + "prefix": { + "prefixStr": "0b001", + "prefixLen": 3 + }, + "fields": [ + { + "name": "should_forward", + "ty": { + "kind": "bool" + } + }, + { + "name": "n_times", + "ty": { + "kind": "intN", + "n": 32 + } + }, + { + "name": "content", + "ty": { + "kind": "remaining" + } + } + ] + }, + { + "kind": "Struct", + "name": "BodyPayload2", + "prefix": { + "prefixStr": "0b01", + "prefixLen": 2 + }, + "fields": [ + { + "name": "master_id", + "ty": { + "kind": "intN", + "n": 8 + } + }, + { + "name": "owner_address", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "SayHiAndGoodbye", + "prefix": { + "prefixStr": "0x89", + "prefixLen": 8 + }, + "fields": [ + { + "name": "dest_addr", + "ty": { + "kind": "addressOpt" + } + }, + { + "name": "body", + "ty": { + "kind": "AliasRef", + "aliasName": "BodyPayload" + } + } + ] + }, + { + "kind": "Struct", + "name": "SayStoreInChain", + "prefix": { + "prefixStr": "0x0013", + "prefixLen": 16 + }, + "fields": [ + { + "name": "in_masterchain", + "ty": { + "kind": "bool" + } + }, + { + "name": "contents", + "ty": { + "kind": "cellOf", + "inner": { + "kind": "AliasRef", + "aliasName": "BodyPayload" + } + } + } + ] + }, + { + "kind": "Struct", + "name": "TransferParams1", + "prefix": { + "prefixStr": "0x794", + "prefixLen": 12 + }, + "fields": [ + { + "name": "dest_int", + "ty": { + "kind": "address" + } + }, + { + "name": "amount", + "ty": { + "kind": "coins" + } + }, + { + "name": "dest_ext", + "ty": { + "kind": "addressAny" + } + } + ] + }, + { + "kind": "Struct", + "name": "TransferParams2", + "prefix": { + "prefixStr": "0x9", + "prefixLen": 4 + }, + "fields": [ + { + "name": "intVector", + "ty": { + "kind": "tensor", + "items": [ + { + "kind": "intN", + "n": 32 + }, + { + "kind": "nullable", + "inner": { + "kind": "coins" + } + }, + { + "kind": "uintN", + "n": 64 + } + ] + } + }, + { + "name": "needs_more", + "ty": { + "kind": "cellOf", + "inner": { + "kind": "bool" + } + } + } + ] + }, + { + "kind": "Struct", + "name": "MsgTransfer", + "prefix": { + "prefixStr": "0xFB3701FF", + "prefixLen": 32 + }, + "fields": [ + { + "name": "params", + "ty": { + "kind": "AliasRef", + "aliasName": "Either", + "typeArgs": [ + { + "kind": "AliasRef", + "aliasName": "TransferParams" + }, + { + "kind": "cellOf", + "inner": { + "kind": "AliasRef", + "aliasName": "TransferParams" + } + } + ] + } + } + ] + }, + { + "kind": "Alias", + "name": "ReadRest_Remaining", + "targetTy": { + "kind": "StructRef", + "structName": "ReadWriteRest", + "typeArgs": [ + { + "kind": "remaining" + } + ] + } + }, + { + "kind": "Alias", + "name": "MyInt32", + "targetTy": { + "kind": "intN", + "n": 32 + } + }, + { + "kind": "Alias", + "name": "MaybeJustOfAddress", + "targetTy": { + "kind": "StructRef", + "structName": "MaybeJust", + "typeArgs": [ + { + "kind": "address" + } + ] + } + }, + { + "kind": "Alias", + "name": "AddressAlias", + "targetTy": { + "kind": "address" + } + }, + { + "kind": "Alias", + "name": "Either", + "targetTy": { + "kind": "union", + "variants": [ + { + "prefixStr": "0", + "prefixLen": 1, + "prefixEatInPlace": true, + "variantTy": { + "kind": "StructRef", + "structName": "EitherLeft", + "typeArgs": [ + { + "kind": "genericT", + "nameT": "L" + } + ] + } + }, + { + "prefixStr": "1", + "prefixLen": 1, + "prefixEatInPlace": true, + "variantTy": { + "kind": "StructRef", + "structName": "EitherRight", + "typeArgs": [ + { + "kind": "genericT", + "nameT": "R" + } + ] + } + } + ] + }, + "typeParams": [ + "L", + "R" + ] + }, + { + "kind": "Alias", + "name": "Maybe", + "targetTy": { + "kind": "union", + "variants": [ + { + "prefixStr": "0", + "prefixLen": 1, + "prefixEatInPlace": true, + "variantTy": { + "kind": "StructRef", + "structName": "MaybeNothing" + } + }, + { + "prefixStr": "1", + "prefixLen": 1, + "prefixEatInPlace": true, + "variantTy": { + "kind": "StructRef", + "structName": "MaybeJust", + "typeArgs": [ + { + "kind": "genericT", + "nameT": "T" + } + ] + } + } + ] + }, + "typeParams": [ + "T" + ] + }, + { + "kind": "Alias", + "name": "MsgCounter1", + "targetTy": { + "kind": "union", + "variants": [ + { + "prefixStr": "0x12345678", + "prefixLen": 32, + "variantTy": { + "kind": "AliasRef", + "aliasName": "CounterIncrementAlias" + } + }, + { + "prefixStr": "0x23456789", + "prefixLen": 32, + "variantTy": { + "kind": "StructRef", + "structName": "CounterDecrement" + } + }, + { + "prefixStr": "0x34567890", + "prefixLen": 32, + "variantTy": { + "kind": "StructRef", + "structName": "CounterReset0" + } + }, + { + "prefixStr": "0x00184300", + "prefixLen": 32, + "variantTy": { + "kind": "StructRef", + "structName": "CounterResetTo" + } + } + ] + } + }, + { + "kind": "Alias", + "name": "BodyPayload", + "targetTy": { + "kind": "union", + "variants": [ + { + "prefixStr": "0b001", + "prefixLen": 3, + "variantTy": { + "kind": "StructRef", + "structName": "BodyPayload1" + } + }, + { + "prefixStr": "0b01", + "prefixLen": 2, + "variantTy": { + "kind": "StructRef", + "structName": "BodyPayload2" + } + } + ] + } + }, + { + "kind": "Alias", + "name": "MsgExternal1", + "targetTy": { + "kind": "union", + "variants": [ + { + "prefixStr": "0x89", + "prefixLen": 8, + "variantTy": { + "kind": "StructRef", + "structName": "SayHiAndGoodbye" + } + }, + { + "prefixStr": "0x0013", + "prefixLen": 16, + "variantTy": { + "kind": "StructRef", + "structName": "SayStoreInChain" + } + } + ] + } + }, + { + "kind": "Alias", + "name": "TransferParams", + "targetTy": { + "kind": "union", + "variants": [ + { + "prefixStr": "0x794", + "prefixLen": 12, + "variantTy": { + "kind": "StructRef", + "structName": "TransferParams1" + } + }, + { + "prefixStr": "0x9", + "prefixLen": 4, + "variantTy": { + "kind": "StructRef", + "structName": "TransferParams2" + } + } + ] + } + }, + { + "kind": "Alias", + "name": "Union_8_16_32", + "targetTy": { + "kind": "union", + "variants": [ + { + "prefixStr": "0b00", + "prefixLen": 2, + "prefixEatInPlace": true, + "variantTy": { + "kind": "intN", + "n": 8 + } + }, + { + "prefixStr": "0b01", + "prefixLen": 2, + "prefixEatInPlace": true, + "variantTy": { + "kind": "intN", + "n": 16 + } + }, + { + "prefixStr": "0b10", + "prefixLen": 2, + "prefixEatInPlace": true, + "variantTy": { + "kind": "intN", + "n": 32 + } + } + ] + } + }, + { + "kind": "Alias", + "name": "Union_8_16_32_n", + "targetTy": { + "kind": "union", + "variants": [ + { + "prefixStr": "0b100", + "prefixLen": 3, + "prefixEatInPlace": true, + "variantTy": { + "kind": "intN", + "n": 8 + } + }, + { + "prefixStr": "0b101", + "prefixLen": 3, + "prefixEatInPlace": true, + "variantTy": { + "kind": "intN", + "n": 16 + } + }, + { + "prefixStr": "0b110", + "prefixLen": 3, + "prefixEatInPlace": true, + "variantTy": { + "kind": "intN", + "n": 32 + } + }, + { + "prefixStr": "0b0", + "prefixLen": 1, + "prefixEatInPlace": true, + "variantTy": { + "kind": "nullLiteral" + } + } + ] + } + }, + { + "kind": "Enum", + "name": "EStoredAsInt8", + "encodedAs": { + "kind": "intN", + "n": 8 + }, + "members": [ + { + "name": "M100", + "value": "-100" + }, + { + "name": "Z", + "value": "0" + }, + { + "name": "P100", + "value": "100" + } + ] + }, + { + "kind": "Enum", + "name": "EStoredAsUint1", + "encodedAs": { + "kind": "uintN", + "n": 1 + }, + "members": [ + { + "name": "ZERO", + "value": "0" + }, + { + "name": "ONE", + "value": "1" + } + ] + }, + { + "kind": "Struct", + "name": "WithEnums", + "fields": [ + { + "name": "e1", + "ty": { + "kind": "EnumRef", + "enumName": "EStoredAsInt8" + } + }, + { + "name": "e2", + "ty": { + "kind": "EnumRef", + "enumName": "EStoredAsUint1" + } + }, + { + "name": "rem", + "ty": { + "kind": "uintN", + "n": 7 + } + } + ] + }, + { + "kind": "Struct", + "name": "Test4_8", + "fields": [ + { + "name": "a", + "ty": { + "kind": "intN", + "n": 8 + } + } + ] + }, + { + "kind": "Struct", + "name": "Test4_16", + "fields": [ + { + "name": "a", + "ty": { + "kind": "intN", + "n": 16 + } + } + ] + }, + { + "kind": "Struct", + "name": "Test4_32", + "fields": [ + { + "name": "a", + "ty": { + "kind": "intN", + "n": 32 + } + } + ] + }, + { + "kind": "Struct", + "name": "StorWithStr", + "fields": [ + { + "name": "a", + "ty": { + "kind": "intN", + "n": 32 + } + }, + { + "name": "str", + "ty": { + "kind": "AliasRef", + "aliasName": "TelegramString" + } + }, + { + "name": "b", + "ty": { + "kind": "intN", + "n": 32 + } + } + ] + }, + { + "kind": "Struct", + "name": "PointWithCustomInt", + "fields": [ + { + "name": "a", + "ty": { + "kind": "AliasRef", + "aliasName": "Custom8" + } + }, + { + "name": "b", + "ty": { + "kind": "intN", + "n": 8 + } + } + ] + }, + { + "kind": "Struct", + "name": "WithMyBorder", + "fields": [ + { + "name": "a", + "ty": { + "kind": "intN", + "n": 8 + } + }, + { + "name": "b", + "ty": { + "kind": "AliasRef", + "aliasName": "MyBorderedInt" + } + } + ] + }, + { + "kind": "Struct", + "name": "WithFakeWriter", + "fields": [ + { + "name": "a", + "ty": { + "kind": "intN", + "n": 8 + } + }, + { + "name": "fake", + "ty": { + "kind": "AliasRef", + "aliasName": "MyCustomNothing" + } + }, + { + "name": "b", + "ty": { + "kind": "intN", + "n": 8 + } + } + ] + }, + { + "kind": "Struct", + "name": "WithEnumsUnion", + "fields": [ + { + "name": "u", + "ty": { + "kind": "union", + "variants": [ + { + "prefixStr": "0b10", + "prefixLen": 2, + "prefixEatInPlace": true, + "variantTy": { + "kind": "EnumRef", + "enumName": "EFits8Bits" + } + }, + { + "prefixStr": "0b11", + "prefixLen": 2, + "prefixEatInPlace": true, + "variantTy": { + "kind": "EnumRef", + "enumName": "EStartFromM2" + } + }, + { + "prefixStr": "0b0", + "prefixLen": 1, + "prefixEatInPlace": true, + "variantTy": { + "kind": "nullLiteral" + } + } + ] + } + } + ] + }, + { + "kind": "Alias", + "name": "UnionStructs_8_16_32", + "targetTy": { + "kind": "union", + "variants": [ + { + "prefixStr": "0b00", + "prefixLen": 2, + "prefixEatInPlace": true, + "variantTy": { + "kind": "intN", + "n": 8 + } + }, + { + "prefixStr": "0b01", + "prefixLen": 2, + "prefixEatInPlace": true, + "variantTy": { + "kind": "StructRef", + "structName": "Test4_16" + } + }, + { + "prefixStr": "0b10", + "prefixLen": 2, + "prefixEatInPlace": true, + "variantTy": { + "kind": "StructRef", + "structName": "Test4_32" + } + } + ] + } + }, + { + "kind": "Alias", + "name": "UnionStructs_8_16_32_n", + "targetTy": { + "kind": "union", + "variants": [ + { + "prefixStr": "0b100", + "prefixLen": 3, + "prefixEatInPlace": true, + "variantTy": { + "kind": "StructRef", + "structName": "Test4_8" + } + }, + { + "prefixStr": "0b101", + "prefixLen": 3, + "prefixEatInPlace": true, + "variantTy": { + "kind": "intN", + "n": 16 + } + }, + { + "prefixStr": "0b110", + "prefixLen": 3, + "prefixEatInPlace": true, + "variantTy": { + "kind": "intN", + "n": 32 + } + }, + { + "prefixStr": "0b0", + "prefixLen": 1, + "prefixEatInPlace": true, + "variantTy": { + "kind": "nullLiteral" + } + } + ] + } + }, + { + "kind": "Alias", + "name": "U105", + "targetTy": { + "kind": "union", + "variants": [ + { + "prefixStr": "0b00", + "prefixLen": 2, + "prefixEatInPlace": true, + "variantTy": { + "kind": "intN", + "n": 8 + } + }, + { + "prefixStr": "0b01", + "prefixLen": 2, + "prefixEatInPlace": true, + "variantTy": { + "kind": "intN", + "n": 32 + } + }, + { + "prefixStr": "0b10", + "prefixLen": 2, + "prefixEatInPlace": true, + "variantTy": { + "kind": "intN", + "n": 64 + } + } + ] + } + }, + { + "kind": "Alias", + "name": "U106", + "targetTy": { + "kind": "union", + "variants": [ + { + "prefixStr": "0b00", + "prefixLen": 2, + "prefixEatInPlace": true, + "variantTy": { + "kind": "intN", + "n": 8 + } + }, + { + "prefixStr": "0b01", + "prefixLen": 2, + "prefixEatInPlace": true, + "variantTy": { + "kind": "intN", + "n": 16 + } + }, + { + "prefixStr": "0b10", + "prefixLen": 2, + "prefixEatInPlace": true, + "variantTy": { + "kind": "intN", + "n": 32 + } + }, + { + "prefixStr": "0b11", + "prefixLen": 2, + "prefixEatInPlace": true, + "variantTy": { + "kind": "intN", + "n": 64 + } + } + ] + } + }, + { + "kind": "Alias", + "name": "TelegramString", + "targetTy": { + "kind": "slice" + }, + "customPackToBuilder": true, + "customUnpackFromSlice": true + }, + { + "kind": "Alias", + "name": "Custom8", + "targetTy": { + "kind": "uintN", + "n": 8 + }, + "customPackToBuilder": true, + "customUnpackFromSlice": true + }, + { + "kind": "Alias", + "name": "MyBorderedInt", + "targetTy": { + "kind": "intN", + "n": 257 + }, + "customPackToBuilder": true, + "customUnpackFromSlice": true + }, + { + "kind": "Alias", + "name": "MyCustomNothing", + "targetTy": { + "kind": "tensor", + "items": [] + }, + "customPackToBuilder": true + }, + { + "kind": "Alias", + "name": "Tensor3Skipping1", + "targetTy": { + "kind": "tensor", + "items": [ + { + "kind": "uintN", + "n": 8 + }, + { + "kind": "uintN", + "n": 8 + }, + { + "kind": "uintN", + "n": 8 + } + ] + }, + "customPackToBuilder": true, + "customUnpackFromSlice": true + }, + { + "kind": "Alias", + "name": "UnsafeColor", + "targetTy": { + "kind": "EnumRef", + "enumName": "Color" + }, + "customPackToBuilder": true, + "customUnpackFromSlice": true + }, + { + "kind": "Alias", + "name": "TwoRoles", + "targetTy": { + "kind": "tensor", + "items": [ + { + "kind": "EnumRef", + "enumName": "Role" + }, + { + "kind": "EnumRef", + "enumName": "Role" + } + ] + } + }, + { + "kind": "Enum", + "name": "Color", + "encodedAs": { + "kind": "uintN", + "n": 2 + }, + "members": [ + { + "name": "Red", + "value": "0" + }, + { + "name": "Green", + "value": "1" + }, + { + "name": "Blue", + "value": "2" + } + ] + }, + { + "kind": "Enum", + "name": "EFits2Bits", + "encodedAs": { + "kind": "uintN", + "n": 2 + }, + "members": [ + { + "name": "ZERO", + "value": "0" + }, + { + "name": "ONE", + "value": "1" + }, + { + "name": "TWO", + "value": "2" + } + ] + }, + { + "kind": "Enum", + "name": "EStartFrom1", + "encodedAs": { + "kind": "uintN", + "n": 2 + }, + "members": [ + { + "name": "ONE", + "value": "1" + }, + { + "name": "TWO", + "value": "2" + }, + { + "name": "THREE", + "value": "3" + } + ] + }, + { + "kind": "Enum", + "name": "EStartFromM2", + "encodedAs": { + "kind": "intN", + "n": 3 + }, + "members": [ + { + "name": "M2", + "value": "-2" + }, + { + "name": "M1", + "value": "-1" + }, + { + "name": "ZERO", + "value": "0" + }, + { + "name": "P1", + "value": "1" + }, + { + "name": "P2", + "value": "2" + }, + { + "name": "P3", + "value": "3" + } + ] + }, + { + "kind": "Enum", + "name": "EFits8Bits", + "encodedAs": { + "kind": "uintN", + "n": 8 + }, + "members": [ + { + "name": "E0", + "value": "0" + }, + { + "name": "E110", + "value": "110" + }, + { + "name": "E220", + "value": "220" + } + ] + }, + { + "kind": "Enum", + "name": "EMinMax", + "encodedAs": { + "kind": "intN", + "n": 257 + }, + "members": [ + { + "name": "MIN_INT", + "value": "-115792089237316195423570985008687907853269984665640564039457584007913129639936" + }, + { + "name": "MAX_INT", + "value": "115792089237316195423570985008687907853269984665640564039457584007913129639935" + } + ] + }, + { + "kind": "Enum", + "name": "E0Max", + "encodedAs": { + "kind": "uintN", + "n": 256 + }, + "members": [ + { + "name": "ZERO", + "value": "0" + }, + { + "name": "MAX_INT", + "value": "115792089237316195423570985008687907853269984665640564039457584007913129639935" + } + ] + }, + { + "kind": "Enum", + "name": "Role", + "encodedAs": { + "kind": "intN", + "n": 8 + }, + "members": [ + { + "name": "Admin", + "value": "0" + }, + { + "name": "User", + "value": "1" + } + ] + }, + { + "kind": "Enum", + "name": "EncodedVari", + "encodedAs": { + "kind": "varintN", + "n": 16 + }, + "members": [ + { + "name": "ONE", + "value": "1" + }, + { + "name": "TWO", + "value": "2" + }, + { + "name": "MANY", + "value": "1267650600228229401496703205376" + } + ] + }, + { + "kind": "Enum", + "name": "ECollisionNames", + "encodedAs": { + "kind": "uintN", + "n": 2 + }, + "members": [ + { + "name": "fromSlice", + "value": "0" + }, + { + "name": "store", + "value": "1" + }, + { + "name": "toCell", + "value": "2" + }, + { + "name": "ToCell", + "value": "3" + } + ] + }, + { + "kind": "Struct", + "name": "Wrapper", + "typeParams": [ + "T" + ], + "fields": [ + { + "name": "item", + "ty": { + "kind": "genericT", + "nameT": "T" + } + } + ] + }, + { + "kind": "Struct", + "name": "WithMaps0", + "fields": [ + { + "name": "m1", + "ty": { + "kind": "mapKV", + "k": { + "kind": "intN", + "n": 16 + }, + "v": { + "kind": "intN", + "n": 32 + } + } + }, + { + "name": "m2", + "ty": { + "kind": "mapKV", + "k": { + "kind": "intN", + "n": 16 + }, + "v": { + "kind": "tensor", + "items": [ + { + "kind": "intN", + "n": 8 + }, + { + "kind": "intN", + "n": 8 + } + ] + } + } + }, + { + "name": "m3", + "ty": { + "kind": "mapKV", + "k": { + "kind": "uintN", + "n": 16 + }, + "v": { + "kind": "addressAny" + } + } + }, + { + "name": "m4", + "ty": { + "kind": "mapKV", + "k": { + "kind": "address" + }, + "v": { + "kind": "remaining" + } + } + } + ] + }, + { + "kind": "Struct", + "name": "WithNullableMaps", + "fields": [ + { + "name": "m1", + "ty": { + "kind": "nullable", + "inner": { + "kind": "mapKV", + "k": { + "kind": "intN", + "n": 32 + }, + "v": { + "kind": "intN", + "n": 64 + } + } + } + }, + { + "name": "m2", + "ty": { + "kind": "nullable", + "inner": { + "kind": "mapKV", + "k": { + "kind": "intN", + "n": 32 + }, + "v": { + "kind": "intN", + "n": 64 + } + } + } + }, + { + "name": "m3", + "ty": { + "kind": "nullable", + "inner": { + "kind": "mapKV", + "k": { + "kind": "intN", + "n": 32 + }, + "v": { + "kind": "intN", + "n": 64 + } + } + } + }, + { + "name": "m4", + "ty": { + "kind": "union", + "variants": [ + { + "prefixStr": "0", + "prefixLen": 1, + "prefixEatInPlace": true, + "variantTy": { + "kind": "mapKV", + "k": { + "kind": "intN", + "n": 32 + }, + "v": { + "kind": "intN", + "n": 64 + } + } + }, + { + "prefixStr": "1", + "prefixLen": 1, + "prefixEatInPlace": true, + "variantTy": { + "kind": "intN", + "n": 32 + } + } + ] + } + }, + { + "name": "m5", + "ty": { + "kind": "union", + "variants": [ + { + "prefixStr": "0b00", + "prefixLen": 2, + "prefixEatInPlace": true, + "variantTy": { + "kind": "mapKV", + "k": { + "kind": "intN", + "n": 8 + }, + "v": { + "kind": "intN", + "n": 8 + } + } + }, + { + "prefixStr": "0b01", + "prefixLen": 2, + "prefixEatInPlace": true, + "variantTy": { + "kind": "mapKV", + "k": { + "kind": "intN", + "n": 16 + }, + "v": { + "kind": "intN", + "n": 16 + } + } + }, + { + "prefixStr": "0b10", + "prefixLen": 2, + "prefixEatInPlace": true, + "variantTy": { + "kind": "mapKV", + "k": { + "kind": "intN", + "n": 32 + }, + "v": { + "kind": "intN", + "n": 32 + } + } + } + ] + } + } + ] + }, + { + "kind": "Struct", + "name": "WithMoreTrickyTypes", + "fields": [ + { + "name": "uni1", + "ty": { + "kind": "union", + "variants": [ + { + "prefixStr": "0", + "prefixLen": 1, + "prefixEatInPlace": true, + "variantTy": { + "kind": "tensor", + "items": [ + { + "kind": "intN", + "n": 8 + }, + { + "kind": "intN", + "n": 16 + } + ] + } + }, + { + "prefixStr": "1", + "prefixLen": 1, + "prefixEatInPlace": true, + "variantTy": { + "kind": "tensor", + "items": [ + { + "kind": "intN", + "n": 8 + }, + { + "kind": "intN", + "n": 16 + }, + { + "kind": "intN", + "n": 32 + } + ] + } + } + ] + } + }, + { + "name": "r1", + "ty": { + "kind": "cellOf", + "inner": { + "kind": "StructRef", + "structName": "Wrapper", + "typeArgs": [ + { + "kind": "intN", + "n": 8 + } + ] + } + } + }, + { + "name": "r2", + "ty": { + "kind": "cellOf", + "inner": { + "kind": "union", + "variants": [ + { + "prefixStr": "0", + "prefixLen": 1, + "prefixEatInPlace": true, + "variantTy": { + "kind": "addressAny" + } + }, + { + "prefixStr": "1", + "prefixLen": 1, + "prefixEatInPlace": true, + "variantTy": { + "kind": "StructRef", + "structName": "Wrapper", + "typeArgs": [ + { + "kind": "addressAny" + } + ] + } + } + ] + } + } + }, + { + "name": "nullable1", + "ty": { + "kind": "nullable", + "inner": { + "kind": "AliasRef", + "aliasName": "CounterIncrementAlias" + } + } + }, + { + "name": "nestedM", + "ty": { + "kind": "mapKV", + "k": { + "kind": "intN", + "n": 8 + }, + "v": { + "kind": "mapKV", + "k": { + "kind": "uintN", + "n": 16 + }, + "v": { + "kind": "StructRef", + "structName": "JustInt32" + } + } + } + }, + { + "name": "uni2", + "ty": { + "kind": "union", + "variants": [ + { + "prefixStr": "0", + "prefixLen": 1, + "prefixEatInPlace": true, + "variantTy": { + "kind": "StructRef", + "structName": "Wrapper", + "typeArgs": [ + { + "kind": "intN", + "n": 8 + } + ] + } + }, + { + "prefixStr": "1", + "prefixLen": 1, + "prefixEatInPlace": true, + "variantTy": { + "kind": "StructRef", + "structName": "Wrapper", + "typeArgs": [ + { + "kind": "intN", + "n": 16 + } + ] + } + } + ] + } + } + ] + }, + { + "kind": "Struct", + "name": "invalid-js-naming%", + "fields": [ + { + "name": "foo-bar", + "ty": { + "kind": "intN", + "n": 32 + } + }, + { + "name": "rule()", + "ty": { + "kind": "intN", + "n": 32 + } + }, + { + "name": "A^@'\"B", + "ty": { + "kind": "intN", + "n": 32 + } + }, + { + "name": "void", + "ty": { + "kind": "void" + } + } + ] + }, + { + "kind": "Struct", + "name": "NotPackable1", + "fields": [ + { + "name": "n", + "ty": { + "kind": "intN", + "n": 8 + } + }, + { + "name": "a", + "ty": { + "kind": "tensor", + "items": [ + { + "kind": "intN", + "n": 8 + }, + { + "kind": "int" + } + ] + } + } + ] + }, + { + "kind": "Struct", + "name": "NotPackable3", + "fields": [ + { + "name": "t", + "ty": { + "kind": "tupleAny" + } + } + ] + }, + { + "kind": "Struct", + "name": "NotPackable5", + "fields": [ + { + "name": "t", + "ty": { + "kind": "tupleWith", + "items": [ + { + "kind": "intN", + "n": 8 + }, + { + "kind": "builder" + } + ] + } + } + ] + }, + { + "kind": "Struct", + "name": "NotPackable6", + "fields": [ + { + "name": "c", + "ty": { + "kind": "callable" + } + } + ] + }, + { + "kind": "Struct", + "name": "NotPackable7", + "fields": [ + { + "name": "f", + "ty": { + "kind": "callable" + } + } + ] + }, + { + "kind": "Struct", + "name": "NotUnpackable1", + "fields": [ + { + "name": "e", + "ty": { + "kind": "tensor", + "items": [ + { + "kind": "intN", + "n": 8 + }, + { + "kind": "tensor", + "items": [ + { + "kind": "intN", + "n": 8 + }, + { + "kind": "builder" + } + ] + } + ] + } + } + ] + }, + { + "kind": "Struct", + "name": "WithNotPackable", + "fields": [ + { + "name": "k", + "ty": { + "kind": "intN", + "n": 8 + } + }, + { + "name": "nestedNot", + "ty": { + "kind": "StructRef", + "structName": "NotPackable3" + } + } + ] + }, + { + "kind": "Alias", + "name": "NotPackable3Alias", + "targetTy": { + "kind": "StructRef", + "structName": "NotPackable3" + } + }, + { + "kind": "Alias", + "name": "NotPackable4Alias", + "targetTy": { + "kind": "tensor", + "items": [ + { + "kind": "intN", + "n": 8 + }, + { + "kind": "intN", + "n": 16 + }, + { + "kind": "int" + } + ] + } + }, + { + "kind": "Alias", + "name": "OnlyWithPack", + "targetTy": { + "kind": "intN", + "n": 8 + }, + "customPackToBuilder": true + }, + { + "kind": "Alias", + "name": "OnlyWithUnpack", + "targetTy": { + "kind": "int" + }, + "customUnpackFromSlice": true + }, + { + "kind": "Struct", + "name": "HasOnlyWithUnpack", + "fields": [ + { + "name": "wu", + "ty": { + "kind": "AliasRef", + "aliasName": "OnlyWithUnpack" + } + } + ] + }, + { + "kind": "Alias", + "name": "dict", + "targetTy": { + "kind": "nullable", + "inner": { + "kind": "cell" + } + } + } + ], + "incomingMessages": [], + "outgoingMessages": [], + "emittedEvents": [], + "getMethods": [], + "thrownErrors": [ + { + "constName": "", + "errCode": 123 + } + ], + "compilerName": "tolk", + "compilerVersion": "1.2.0", + "codeBoc64": "te6ccgEBAgEAEAABFP8A9KQT9LzyyAsBAALT" + } \ No newline at end of file diff --git a/abi-tolk/parser/testdata/simple.json b/abi-tolk/parser/testdata/simple.json new file mode 100644 index 00000000..0e872fed --- /dev/null +++ b/abi-tolk/parser/testdata/simple.json @@ -0,0 +1,253 @@ +{ + "contractName": "LotsOfAnnotations", + "author": "A K", + "version": "1.0", + "description": "some d", + "declarations": [ + { + "kind": "Struct", + "name": "Msg1", + "prefix": { + "prefixStr": "0x12345678", + "prefixLen": 32 + }, + "fields": [] + }, + { + "kind": "Struct", + "name": "ResetTo", + "typeParams": [ + "T" + ], + "prefix": { + "prefixStr": "0x23456789", + "prefixLen": 32 + }, + "fields": [ + { + "name": "counter_id", + "ty": { + "kind": "intN", + "n": 32 + } + }, + { + "name": "reset_to", + "ty": { + "kind": "genericT", + "nameT": "T" + }, + "defaultValue": { + "kind": "int", + "v": "0" + } + } + ] + }, + { + "kind": "Struct", + "name": "Transfer", + "prefix": { + "prefixStr": "0x3456789A", + "prefixLen": 32 + }, + "fields": [ + { + "name": "owner", + "ty": { + "kind": "address" + } + }, + { + "name": "forwardPayload", + "ty": { + "kind": "remaining" + }, + "description": "actually it's not a slice" + } + ] + }, + { + "kind": "Struct", + "name": "Out2", + "fields": [ + { + "name": "v2", + "ty": { + "kind": "intN", + "n": 8 + } + } + ] + }, + { + "kind": "Struct", + "name": "Out3", + "typeParams": [ + "PayloadT" + ], + "fields": [ + { + "name": "payload", + "ty": { + "kind": "genericT", + "nameT": "PayloadT" + } + } + ] + }, + { + "kind": "Struct", + "name": "OutExt4", + "fields": [ + { + "name": "v4", + "ty": { + "kind": "intN", + "n": 8 + } + } + ] + }, + { + "kind": "Struct", + "name": "MyStorage", + "fields": [ + { + "name": "collectionAddress", + "ty": { + "kind": "address" + } + }, + { + "name": "content", + "ty": { + "kind": "cell" + } + } + ] + }, + { + "kind": "Struct", + "name": "ActualExternalShape", + "fields": [ + { + "name": "v", + "ty": { + "kind": "intN", + "n": 32 + } + }, + { + "name": "sign", + "ty": { + "kind": "bitsN", + "n": 512 + } + } + ] + } + ], + "incomingMessages": [ + { + "bodyTy": { + "kind": "StructRef", + "structName": "Msg1" + }, + "minimalMsgValue": 500000000, + "description": "mmm1", + "preferredSendMode": 17 + }, + { + "bodyTy": { + "kind": "StructRef", + "structName": "ResetTo", + "typeArgs": [ + { + "kind": "intN", + "n": 32 + } + ] + }, + "description": "mmmReset" + }, + { + "bodyTy": { + "kind": "StructRef", + "structName": "Transfer" + } + } + ], + "incomingExternal": { + "bodyTy": { + "kind": "StructRef", + "structName": "ActualExternalShape" + }, + "description": "mmmShape" + }, + "outgoingMessages": [ + { + "bodyTy": { + "kind": "intN", + "n": 8 + } + }, + { + "bodyTy": { + "kind": "StructRef", + "structName": "Transfer" + } + }, + { + "bodyTy": { + "kind": "StructRef", + "structName": "Out2" + } + }, + { + "bodyTy": { + "kind": "StructRef", + "structName": "Out3", + "typeArgs": [ + { + "kind": "tensor", + "items": [ + { + "kind": "intN", + "n": 8 + }, + { + "kind": "intN", + "n": 16 + } + ] + } + ] + } + } + ], + "emittedEvents": [ + { + "bodyTy": { + "kind": "StructRef", + "structName": "OutExt4" + }, + "description": "mmmOut4" + } + ], + "getMethods": [ + { + "tvmMethodId": 90137, + "name": "getFirst", + "parameters": [], + "returnTy": { + "kind": "int" + }, + "description": "get1" + } + ], + "thrownErrors": [], + "compilerName": "tolk", + "compilerVersion": "1.2.0", + "codeBoc64": "te6ccgEBBgEATAABFP8A9KQT9LzyyAsBAgEgAgMCAUgEBQAE8jAAUtAw+JHyQPiVIMAAkTDgIMAKkTDgIMAUkTDgIMAekTDgIMAokTDgwDLcAAegwDLj" + } \ No newline at end of file diff --git a/abi-tolk/payload.go b/abi-tolk/payload.go new file mode 100644 index 00000000..e6b1b188 --- /dev/null +++ b/abi-tolk/payload.go @@ -0,0 +1,168 @@ +package abitolk + +import ( + "bytes" + "encoding/hex" + "encoding/json" + "errors" + "fmt" + "reflect" + + "github.com/tonkeeper/tongo/boc" + "github.com/tonkeeper/tongo/tlb" +) + +type Payload struct { + SumType string + OpCode *uint32 + Value any +} + +type PayloadOpName = string + +const ( + EmptyPayloadOp PayloadOpName = "" + UnknownPayloadOp PayloadOpName = "Cell" +) + +// OpCode is the first 4 bytes of a message body identifying an operation to be performed. +type PayloadOpCode = uint32 + +func (p *Payload) UnmarshalJSON(data []byte) error { + var r struct { + SumType string + OpCode *uint32 + Value json.RawMessage + } + + if err := json.Unmarshal(data, &r); err != nil { + return err + } + p.SumType = r.SumType + p.OpCode = r.OpCode + if p.SumType == EmptyPayloadOp { + return nil + } + if p.SumType == UnknownPayloadOp { + c := boc.NewCell() + err := json.Unmarshal(r.Value, c) + if err != nil { + return err + } + p.Value = c + return nil + } + t, ok := KnownPayloadTypes[p.SumType] + if !ok { + return fmt.Errorf("unknown payload type '%v'", p.SumType) + } + o := reflect.New(reflect.TypeOf(t)) + err := json.Unmarshal(r.Value, o.Interface()) + if err != nil { + return err + } + p.Value = o.Elem().Interface() + return nil +} + +func (p Payload) MarshalJSON() ([]byte, error) { + if p.SumType == EmptyPayloadOp { + return []byte("{}"), nil + } + buf := bytes.NewBufferString(`{"SumType": "` + p.SumType + `",`) + if p.OpCode != nil { + fmt.Fprintf(buf, `"OpCode":%v,`, *p.OpCode) + } + buf.WriteString(`"Value":`) + if p.SumType == UnknownPayloadOp { + c, ok := p.Value.(*boc.Cell) + if !ok { + return nil, fmt.Errorf("unknown payload should be Cell") + } + b, err := c.ToBoc() + if err != nil { + return nil, err + } + buf.WriteRune('"') + hex.NewEncoder(buf).Write(b) + buf.WriteString(`"}`) + return buf.Bytes(), nil + } + if KnownPayloadTypes[p.SumType] == nil { + return nil, fmt.Errorf("unknown payload type %v", p.SumType) + } + b, err := json.Marshal(p.Value) + if err != nil { + return nil, err + } + buf.Write(b) + buf.WriteRune('}') + return buf.Bytes(), nil +} + +func (p Payload) MarshalTLB(c *boc.Cell, e *tlb.Encoder) error { + if p.SumType == EmptyPayloadOp { + return nil + } + if p.OpCode != nil { + err := c.WriteUint(uint64(*p.OpCode), 32) + if err != nil { + return err + } + } else if op, ok := PayloadOpCodes[p.SumType]; ok { + err := c.WriteUint(uint64(op), 32) + if err != nil { + return err + } + } + return tlb.Marshal(c, p.Value) +} + +func (p *Payload) UnmarshalTLB(cell *boc.Cell, decoder *tlb.Decoder) error { + if completedRead(cell) { + return nil + } + tempCell := cell.CopyRemaining() + op64, err := tempCell.ReadUint(32) + if errors.Is(err, boc.ErrNotEnoughBits) { + p.SumType = UnknownPayloadOp + p.Value = cell.CopyRemaining() + cell.ReadRemainingBits() + return nil + } + op := uint32(op64) + p.OpCode = &op + ifaces := decoder.GetContractInterfaces() + for _, iface := range ifaces { + ifacePayloads := ContractInterface(iface).Payloads() + fs, ok := ifacePayloads[PayloadOpCode(op64)] + if ok && len(fs) > 0 { + for _, f := range fs { + tryCell := tempCell.CopyRemaining() + err = f(p, tryCell) + if err == nil { + cell.ReadRemainingBits() + return nil + } + } + } + } + + fs, ok := funcPayloadDecodersMapping[PayloadOpCode(op64)] + + if ok && len(fs) > 0 { + for _, f := range fs { + err = f(p, tempCell) + if err == nil { + cell.ReadRemainingBits() + return nil + } + } + } + + p.SumType = UnknownPayloadOp + p.Value = cell.CopyRemaining() + cell.ReadRemainingBits() + + return nil +} diff --git a/abi-tolk/payload_msg_types.go b/abi-tolk/payload_msg_types.go new file mode 100644 index 00000000..182525ca --- /dev/null +++ b/abi-tolk/payload_msg_types.go @@ -0,0 +1,2049 @@ +package abitolk + +// Code autogenerated. DO NOT EDIT. + +import ( + "github.com/tonkeeper/tongo/boc" + "github.com/tonkeeper/tongo/tlb" +) + +func decodeTonCocoonTextCmdOpPayload(j *Payload, c *boc.Cell) error { + var res TonCocoonTextCmdPayloadBody + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonCocoonTextCmdOp + j.Value = res + return nil + } + return err +} + +func decodeTonCocoonTextCommandOpPayload(j *Payload, c *boc.Cell) error { + var res TonCocoonTextCommandPayloadBody + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonCocoonTextCommandOp + j.Value = res + return nil + } + return err +} + +func decodeTonTolkTestsTextCommentJettonPayloadOpPayload(j *Payload, c *boc.Cell) error { + var res TonTolkTestsTextComment + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonTolkTestsTextCommentJettonPayloadOp + j.Value = res + return nil + } + return err +} + +func decodeTonTep74ChangeMinterAdminOpPayload(j *Payload, c *boc.Cell) error { + var res TonTep74ChangeMinterAdminPayloadBody + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonTep74ChangeMinterAdminOp + j.Value = res + return nil + } + return err +} + +func decodeTonTep74ChangeMinterContentOpPayload(j *Payload, c *boc.Cell) error { + var res TonTep74ChangeMinterContentPayloadBody + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonTep74ChangeMinterContentOp + j.Value = res + return nil + } + return err +} + +func decodeTonTep74MintNewJettonsOpPayload(j *Payload, c *boc.Cell) error { + var res TonTep74MintNewJettonsPayloadBody + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonTep74MintNewJettonsOp + j.Value = res + return nil + } + return err +} + +func decodeTonTolkTestsTegroJettonSwapJettonPayloadOpPayload(j *Payload, c *boc.Cell) error { + var res TonTolkTestsTegroJettonSwap + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonTolkTestsTegroJettonSwapJettonPayloadOp + j.Value = res + return nil + } + return err +} + +func decodeTonCocoonChangeParamsOpPayload(j *Payload, c *boc.Cell) error { + var res TonCocoonChangeParamsPayloadBody + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonCocoonChangeParamsOp + j.Value = res + return nil + } + return err +} + +func decodeTonTolkTestsCoffeeStakingLockJettonPayloadOpPayload(j *Payload, c *boc.Cell) error { + var res TonTolkTestsCoffeeStakingLock + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonTolkTestsCoffeeStakingLockJettonPayloadOp + j.Value = res + return nil + } + return err +} + +func decodeTonTep74AskToTransferOpPayload(j *Payload, c *boc.Cell) error { + var res TonTep74AskToTransferPayloadBody + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonTep74AskToTransferOp + j.Value = res + return nil + } + return err +} + +func decodeTonCocoonUpgradeCodeOpPayload(j *Payload, c *boc.Cell) error { + var res TonCocoonUpgradeCodePayloadBody + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonCocoonUpgradeCodeOp + j.Value = res + return nil + } + return err +} + +func decodeTonTep74InternalTransferStepOpPayload(j *Payload, c *boc.Cell) error { + var res TonTep74InternalTransferStepPayloadBody + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonTep74InternalTransferStepOp + j.Value = res + return nil + } + return err +} + +func decodeTonCoffeeCrossDexResendOpPayload(j *Payload, c *boc.Cell) error { + var res TonCoffeeCrossDexResendPayloadBody + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonCoffeeCrossDexResendOp + j.Value = res + return nil + } + return err +} + +func decodeTonTolkTestsEncryptedTextCommentJettonPayloadOpPayload(j *Payload, c *boc.Cell) error { + var res TonTolkTestsEncryptedTextComment + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonTolkTestsEncryptedTextCommentJettonPayloadOp + j.Value = res + return nil + } + return err +} + +func decodeTonStonfiV1StonfiSwapJettonPayloadOpPayload(j *Payload, c *boc.Cell) error { + var res TonStonfiV1StonfiSwap + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonStonfiV1StonfiSwapJettonPayloadOp + j.Value = res + return nil + } + return err +} + +func decodeTonCocoonOwnerWorkerRegisterOpPayload(j *Payload, c *boc.Cell) error { + var res TonCocoonOwnerWorkerRegisterPayloadBody + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonCocoonOwnerWorkerRegisterOp + j.Value = res + return nil + } + return err +} + +func decodeTonTolkTestsTegroAddLiquidityJettonPayloadOpPayload(j *Payload, c *boc.Cell) error { + var res TonTolkTestsTegroAddLiquidity + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonTolkTestsTegroAddLiquidityJettonPayloadOp + j.Value = res + return nil + } + return err +} + +func decodeTonTep74RequestWalletAddressOpPayload(j *Payload, c *boc.Cell) error { + var res TonTep74RequestWalletAddressPayloadBody + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonTep74RequestWalletAddressOp + j.Value = res + return nil + } + return err +} + +func decodeTonStonfiV2StonfiProvideLpV2JettonPayloadOpPayload(j *Payload, c *boc.Cell) error { + var res TonStonfiV2StonfiProvideLpV2 + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonStonfiV2StonfiProvideLpV2JettonPayloadOp + j.Value = res + return nil + } + return err +} + +func decodeTonCocoonDelProxyTypeOpPayload(j *Payload, c *boc.Cell) error { + var res TonCocoonDelProxyTypePayloadBody + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonCocoonDelProxyTypeOp + j.Value = res + return nil + } + return err +} + +func decodeTonTolkTestsBidaskProvideBothJettonPayloadOpPayload(j *Payload, c *boc.Cell) error { + var res TonTolkTestsBidaskProvideBoth + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonTolkTestsBidaskProvideBothJettonPayloadOp + j.Value = res + return nil + } + return err +} + +func decodeTonTolkTestsDedustDepositLiquidityJettonPayloadOpPayload(j *Payload, c *boc.Cell) error { + var res TonTolkTestsDedustDepositLiquidity + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonTolkTestsDedustDepositLiquidityJettonPayloadOp + j.Value = res + return nil + } + return err +} + +func decodeTonTolkTestsPoolFundAccountJettonPayloadOpPayload(j *Payload, c *boc.Cell) error { + var res TonTolkTestsPoolFundAccount + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonTolkTestsPoolFundAccountJettonPayloadOp + j.Value = res + return nil + } + return err +} + +func decodeTonStonfiV1StonfiSwapOkRefJettonPayloadOpPayload(j *Payload, c *boc.Cell) error { + var res TonStonfiV1StonfiSwapOkRef + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonStonfiV1StonfiSwapOkRefJettonPayloadOp + j.Value = res + return nil + } + return err +} + +func decodeTonCocoonWorkerProxyRequestOpPayload(j *Payload, c *boc.Cell) error { + var res TonCocoonWorkerProxyRequestPayloadBody + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonCocoonWorkerProxyRequestOp + j.Value = res + return nil + } + return err +} + +func decodeTonTolkTestsCoffeeCrossDexResendJettonPayloadOpPayload(j *Payload, c *boc.Cell) error { + var res TonTolkTestsCoffeeCrossDexResend + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonTolkTestsCoffeeCrossDexResendJettonPayloadOp + j.Value = res + return nil + } + return err +} + +func decodeTonCocoonUpgradeFullOpPayload(j *Payload, c *boc.Cell) error { + var res TonCocoonUpgradeFullPayloadBody + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonCocoonUpgradeFullOp + j.Value = res + return nil + } + return err +} + +func decodeTonCocoonResetRootOpPayload(j *Payload, c *boc.Cell) error { + var res TonCocoonResetRootPayloadBody + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonCocoonResetRootOp + j.Value = res + return nil + } + return err +} + +func decodeTonTep74AskToBurnOpPayload(j *Payload, c *boc.Cell) error { + var res TonTep74AskToBurnPayloadBody + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonTep74AskToBurnOp + j.Value = res + return nil + } + return err +} + +func decodeTonCocoonExtProxyCloseRequestSignedOpPayload(j *Payload, c *boc.Cell) error { + var res TonCocoonExtProxyCloseRequestSignedPayloadBody + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonCocoonExtProxyCloseRequestSignedOp + j.Value = res + return nil + } + return err +} + +func decodeTonTolkTestsBidaskDammProvideJettonPayloadOpPayload(j *Payload, c *boc.Cell) error { + var res TonTolkTestsBidaskDammProvide + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonTolkTestsBidaskDammProvideJettonPayloadOp + j.Value = res + return nil + } + return err +} + +func decodeTonCocoonClientProxyRequestOpPayload(j *Payload, c *boc.Cell) error { + var res TonCocoonClientProxyRequestPayloadBody + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonCocoonClientProxyRequestOp + j.Value = res + return nil + } + return err +} + +func decodeTonStonfiV2StonfiSwapV2JettonPayloadOpPayload(j *Payload, c *boc.Cell) error { + var res TonStonfiV2StonfiSwapV2 + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonStonfiV2StonfiSwapV2JettonPayloadOp + j.Value = res + return nil + } + return err +} + +func decodeTonCocoonOwnerClientIncreaseStakeOpPayload(j *Payload, c *boc.Cell) error { + var res TonCocoonOwnerClientIncreaseStakePayloadBody + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonCocoonOwnerClientIncreaseStakeOp + j.Value = res + return nil + } + return err +} + +func decodeTonCocoonUnregisterProxyOpPayload(j *Payload, c *boc.Cell) error { + var res TonCocoonUnregisterProxyPayloadBody + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonCocoonUnregisterProxyOp + j.Value = res + return nil + } + return err +} + +func decodeTonCocoonAddProxyTypeOpPayload(j *Payload, c *boc.Cell) error { + var res TonCocoonAddProxyTypePayloadBody + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonCocoonAddProxyTypeOp + j.Value = res + return nil + } + return err +} + +func decodeTonTolkTestsBidaskDammProvideOneSideJettonPayloadOpPayload(j *Payload, c *boc.Cell) error { + var res TonTolkTestsBidaskDammProvideOneSide + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonTolkTestsBidaskDammProvideOneSideJettonPayloadOp + j.Value = res + return nil + } + return err +} + +func decodeTonTep74TransferNotificationForRecipientOpPayload(j *Payload, c *boc.Cell) error { + var res TonTep74TransferNotificationForRecipientPayloadBody + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonTep74TransferNotificationForRecipientOp + j.Value = res + return nil + } + return err +} + +func decodeTonCocoonExtProxyPayoutRequestOpPayload(j *Payload, c *boc.Cell) error { + var res TonCocoonExtProxyPayoutRequestPayloadBody + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonCocoonExtProxyPayoutRequestOp + j.Value = res + return nil + } + return err +} + +func decodeTonTolkTestsStormDepositJettonJettonPayloadOpPayload(j *Payload, c *boc.Cell) error { + var res TonTolkTestsStormDepositJetton + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonTolkTestsStormDepositJettonJettonPayloadOp + j.Value = res + return nil + } + return err +} + +func decodeTonTolkTestsInvoicePayloadJettonPayloadOpPayload(j *Payload, c *boc.Cell) error { + var res TonTolkTestsInvoicePayload + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonTolkTestsInvoicePayloadJettonPayloadOp + j.Value = res + return nil + } + return err +} + +func decodeTonTep74BurnNotificationForMinterOpPayload(j *Payload, c *boc.Cell) error { + var res TonTep74BurnNotificationForMinterPayloadBody + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonTep74BurnNotificationForMinterOp + j.Value = res + return nil + } + return err +} + +func decodeTonCocoonOwnerClientChangeSecretHashAndTopUpOpPayload(j *Payload, c *boc.Cell) error { + var res TonCocoonOwnerClientChangeSecretHashAndTopUpPayloadBody + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonCocoonOwnerClientChangeSecretHashAndTopUpOp + j.Value = res + return nil + } + return err +} + +func decodeTonTolkTestsTonkeeperRelayerFeeJettonPayloadOpPayload(j *Payload, c *boc.Cell) error { + var res TonTolkTestsTonkeeperRelayerFee + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonTolkTestsTonkeeperRelayerFeeJettonPayloadOp + j.Value = res + return nil + } + return err +} + +func decodeTonTolkTestsBidaskSwapV2JettonPayloadOpPayload(j *Payload, c *boc.Cell) error { + var res TonTolkTestsBidaskSwapV2 + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonTolkTestsBidaskSwapV2JettonPayloadOp + j.Value = res + return nil + } + return err +} + +func decodeTonCocoonDelWorkerTypeOpPayload(j *Payload, c *boc.Cell) error { + var res TonCocoonDelWorkerTypePayloadBody + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonCocoonDelWorkerTypeOp + j.Value = res + return nil + } + return err +} + +func decodeTonCocoonRegisterProxyOpPayload(j *Payload, c *boc.Cell) error { + var res TonCocoonRegisterProxyPayloadBody + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonCocoonRegisterProxyOp + j.Value = res + return nil + } + return err +} + +func decodeTonCocoonDelModelTypeOpPayload(j *Payload, c *boc.Cell) error { + var res TonCocoonDelModelTypePayloadBody + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonCocoonDelModelTypeOp + j.Value = res + return nil + } + return err +} + +func decodeTonTolkTestsMoonBoostPoolJettonPayloadOpPayload(j *Payload, c *boc.Cell) error { + var res TonTolkTestsMoonBoostPool + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonTolkTestsMoonBoostPoolJettonPayloadOp + j.Value = res + return nil + } + return err +} + +func decodeTonTolkTestsBidaskProvideJettonPayloadOpPayload(j *Payload, c *boc.Cell) error { + var res TonTolkTestsBidaskProvide + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonTolkTestsBidaskProvideJettonPayloadOp + j.Value = res + return nil + } + return err +} + +func decodeTonCocoonExtProxyIncreaseStakeOpPayload(j *Payload, c *boc.Cell) error { + var res TonCocoonExtProxyIncreaseStakePayloadBody + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonCocoonExtProxyIncreaseStakeOp + j.Value = res + return nil + } + return err +} + +func decodeTonTolkTestsMoonFillOrderJettonPayloadOpPayload(j *Payload, c *boc.Cell) error { + var res TonTolkTestsMoonFillOrder + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonTolkTestsMoonFillOrderJettonPayloadOp + j.Value = res + return nil + } + return err +} + +func decodeTonCocoonOwnerWalletSendMessageOpPayload(j *Payload, c *boc.Cell) error { + var res TonCocoonOwnerWalletSendMessagePayloadBody + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonCocoonOwnerWalletSendMessageOp + j.Value = res + return nil + } + return err +} + +func decodeTonCocoonUpdateProxyOpPayload(j *Payload, c *boc.Cell) error { + var res TonCocoonUpdateProxyPayloadBody + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonCocoonUpdateProxyOp + j.Value = res + return nil + } + return err +} + +func decodeTonCocoonExtWorkerPayoutRequestSignedOpPayload(j *Payload, c *boc.Cell) error { + var res TonCocoonExtWorkerPayoutRequestSignedPayloadBody + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonCocoonExtWorkerPayoutRequestSignedOp + j.Value = res + return nil + } + return err +} + +func decodeTonCocoonUpgradeContractsOpPayload(j *Payload, c *boc.Cell) error { + var res TonCocoonUpgradeContractsPayloadBody + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonCocoonUpgradeContractsOp + j.Value = res + return nil + } + return err +} + +func decodeTonTolkTestsBidaskDammProvideBothJettonPayloadOpPayload(j *Payload, c *boc.Cell) error { + var res TonTolkTestsBidaskDammProvideBoth + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonTolkTestsBidaskDammProvideBothJettonPayloadOp + j.Value = res + return nil + } + return err +} + +func decodeTonCocoonOwnerClientChangeSecretHashOpPayload(j *Payload, c *boc.Cell) error { + var res TonCocoonOwnerClientChangeSecretHashPayloadBody + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonCocoonOwnerClientChangeSecretHashOp + j.Value = res + return nil + } + return err +} + +func decodeTonTolkTestsMoonDepositLiquidityJettonPayloadOpPayload(j *Payload, c *boc.Cell) error { + var res TonTolkTestsMoonDepositLiquidity + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonTolkTestsMoonDepositLiquidityJettonPayloadOp + j.Value = res + return nil + } + return err +} + +func decodeTonTolkTestsMoonSwapJettonPayloadOpPayload(j *Payload, c *boc.Cell) error { + var res TonTolkTestsMoonSwap + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonTolkTestsMoonSwapJettonPayloadOp + j.Value = res + return nil + } + return err +} + +func decodeTonCocoonOwnerProxyCloseOpPayload(j *Payload, c *boc.Cell) error { + var res TonCocoonOwnerProxyClosePayloadBody + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonCocoonOwnerProxyCloseOp + j.Value = res + return nil + } + return err +} + +func decodeTonTolkTestsCoffeeCrossDexFailureJettonPayloadOpPayload(j *Payload, c *boc.Cell) error { + var res TonTolkTestsCoffeeCrossDexFailure + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonTolkTestsCoffeeCrossDexFailureJettonPayloadOp + j.Value = res + return nil + } + return err +} + +func decodeTonCocoonExtClientChargeSignedOpPayload(j *Payload, c *boc.Cell) error { + var res TonCocoonExtClientChargeSignedPayloadBody + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonCocoonExtClientChargeSignedOp + j.Value = res + return nil + } + return err +} + +func decodeTonTolkTestsCoffeeSwapJettonPayloadOpPayload(j *Payload, c *boc.Cell) error { + var res TonTolkTestsCoffeeSwap + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonTolkTestsCoffeeSwapJettonPayloadOp + j.Value = res + return nil + } + return err +} + +func decodeTonTolkTestsCoffeeCreatePoolJettonPayloadOpPayload(j *Payload, c *boc.Cell) error { + var res TonTolkTestsCoffeeCreatePool + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonTolkTestsCoffeeCreatePoolJettonPayloadOp + j.Value = res + return nil + } + return err +} + +func decodeTonTolkTestsCoffeeDepositLiquidityJettonPayloadOpPayload(j *Payload, c *boc.Cell) error { + var res TonTolkTestsCoffeeDepositLiquidity + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonTolkTestsCoffeeDepositLiquidityJettonPayloadOp + j.Value = res + return nil + } + return err +} + +func decodeTonTolkTestsCoffeeNotificationJettonPayloadOpPayload(j *Payload, c *boc.Cell) error { + var res TonTolkTestsCoffeeNotification + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonTolkTestsCoffeeNotificationJettonPayloadOp + j.Value = res + return nil + } + return err +} + +func decodeTonCocoonAddModelTypeOpPayload(j *Payload, c *boc.Cell) error { + var res TonCocoonAddModelTypePayloadBody + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonCocoonAddModelTypeOp + j.Value = res + return nil + } + return err +} + +func decodeTonCocoonOwnerClientRegisterOpPayload(j *Payload, c *boc.Cell) error { + var res TonCocoonOwnerClientRegisterPayloadBody + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonCocoonOwnerClientRegisterOp + j.Value = res + return nil + } + return err +} + +func decodeTonTolkTestsMoonSwapFailedJettonPayloadOpPayload(j *Payload, c *boc.Cell) error { + var res TonTolkTestsMoonSwapFailed + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonTolkTestsMoonSwapFailedJettonPayloadOp + j.Value = res + return nil + } + return err +} + +func decodeTonCocoonChangeOwnerOpPayload(j *Payload, c *boc.Cell) error { + var res TonCocoonChangeOwnerPayloadBody + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonCocoonChangeOwnerOp + j.Value = res + return nil + } + return err +} + +func decodeTonCocoonChangeFeesOpPayload(j *Payload, c *boc.Cell) error { + var res TonCocoonChangeFeesPayloadBody + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonCocoonChangeFeesOp + j.Value = res + return nil + } + return err +} + +func decodeTonCocoonPayoutOpPayload(j *Payload, c *boc.Cell) error { + var res TonCocoonPayoutPayloadBody + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonCocoonPayoutOp + j.Value = res + return nil + } + return err +} + +func decodeTonStonfiV2StonfiSwapOkJettonPayloadOpPayload(j *Payload, c *boc.Cell) error { + var res TonStonfiV2StonfiSwapOk + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonStonfiV2StonfiSwapOkJettonPayloadOp + j.Value = res + return nil + } + return err +} + +func decodeTonTolkTestsStormStakeJettonPayloadOpPayload(j *Payload, c *boc.Cell) error { + var res TonTolkTestsStormStake + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonTolkTestsStormStakeJettonPayloadOp + j.Value = res + return nil + } + return err +} + +func decodeTonTolkTestsWithdrawPayloadJettonPayloadOpPayload(j *Payload, c *boc.Cell) error { + var res TonTolkTestsWithdrawPayload + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonTolkTestsWithdrawPayloadJettonPayloadOp + j.Value = res + return nil + } + return err +} + +func decodeTonTolkTestsMoonSwapSucceedJettonPayloadOpPayload(j *Payload, c *boc.Cell) error { + var res TonTolkTestsMoonSwapSucceed + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonTolkTestsMoonSwapSucceedJettonPayloadOp + j.Value = res + return nil + } + return err +} + +func decodeTonTep74ResponseWalletAddressOpPayload(j *Payload, c *boc.Cell) error { + var res TonTep74ResponseWalletAddressPayloadBody + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonTep74ResponseWalletAddressOp + j.Value = res + return nil + } + return err +} + +func decodeTonCocoonReturnExcessesBackOpPayload(j *Payload, c *boc.Cell) error { + var res TonCocoonReturnExcessesBackPayloadBody + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonCocoonReturnExcessesBackOp + j.Value = res + return nil + } + return err +} + +func decodeTonTep74ReturnExcessesBackOpPayload(j *Payload, c *boc.Cell) error { + var res TonTep74ReturnExcessesBackPayloadBody + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonTep74ReturnExcessesBackOp + j.Value = res + return nil + } + return err +} + +func decodeTonTep74AboaLisaOpPayload(j *Payload, c *boc.Cell) error { + var res TonTep74AboaLisaPayloadBody + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonTep74AboaLisaOp + j.Value = res + return nil + } + return err +} + +func decodeTonTolkTestsMoonCreateOrderJettonPayloadOpPayload(j *Payload, c *boc.Cell) error { + var res TonTolkTestsMoonCreateOrder + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonTolkTestsMoonCreateOrderJettonPayloadOp + j.Value = res + return nil + } + return err +} + +func decodeTonCocoonOwnerClientWithdrawOpPayload(j *Payload, c *boc.Cell) error { + var res TonCocoonOwnerClientWithdrawPayloadBody + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonCocoonOwnerClientWithdrawOp + j.Value = res + return nil + } + return err +} + +func decodeTonTolkTestsBidaskDammSwapJettonPayloadOpPayload(j *Payload, c *boc.Cell) error { + var res TonTolkTestsBidaskDammSwap + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonTolkTestsBidaskDammSwapJettonPayloadOp + j.Value = res + return nil + } + return err +} + +func decodeTonCocoonAddWorkerTypeOpPayload(j *Payload, c *boc.Cell) error { + var res TonCocoonAddWorkerTypePayloadBody + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonCocoonAddWorkerTypeOp + j.Value = res + return nil + } + return err +} + +func decodeTonTolkTestsDedustSwapJettonPayloadOpPayload(j *Payload, c *boc.Cell) error { + var res TonTolkTestsDedustSwap + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonTolkTestsDedustSwapJettonPayloadOp + j.Value = res + return nil + } + return err +} + +func decodeTonCocoonExtProxyCloseCompleteRequestSignedOpPayload(j *Payload, c *boc.Cell) error { + var res TonCocoonExtProxyCloseCompleteRequestSignedPayloadBody + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonCocoonExtProxyCloseCompleteRequestSignedOp + j.Value = res + return nil + } + return err +} + +func decodeTonTolkTestsCoffeeMevProtectFailedSwapJettonPayloadOpPayload(j *Payload, c *boc.Cell) error { + var res TonTolkTestsCoffeeMevProtectFailedSwap + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonTolkTestsCoffeeMevProtectFailedSwapJettonPayloadOp + j.Value = res + return nil + } + return err +} + +func decodeTonCocoonExtClientGrantRefundSignedOpPayload(j *Payload, c *boc.Cell) error { + var res TonCocoonExtClientGrantRefundSignedPayloadBody + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonCocoonExtClientGrantRefundSignedOp + j.Value = res + return nil + } + return err +} + +func decodeTonCocoonExtClientTopUpOpPayload(j *Payload, c *boc.Cell) error { + var res TonCocoonExtClientTopUpPayloadBody + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonCocoonExtClientTopUpOp + j.Value = res + return nil + } + return err +} + +func decodeTonTolkTestsBidaskSwapJettonPayloadOpPayload(j *Payload, c *boc.Cell) error { + var res TonTolkTestsBidaskSwap + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonTolkTestsBidaskSwapJettonPayloadOp + j.Value = res + return nil + } + return err +} + +func decodeTonCocoonExtWorkerLastPayoutRequestSignedOpPayload(j *Payload, c *boc.Cell) error { + var res TonCocoonExtWorkerLastPayoutRequestSignedPayloadBody + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonCocoonExtWorkerLastPayoutRequestSignedOp + j.Value = res + return nil + } + return err +} + +func decodeTonTolkTestsDepositPayloadJettonPayloadOpPayload(j *Payload, c *boc.Cell) error { + var res TonTolkTestsDepositPayload + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonTolkTestsDepositPayloadJettonPayloadOp + j.Value = res + return nil + } + return err +} + +func decodeTonCocoonOwnerClientRequestRefundOpPayload(j *Payload, c *boc.Cell) error { + var res TonCocoonOwnerClientRequestRefundPayloadBody + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonCocoonOwnerClientRequestRefundOp + j.Value = res + return nil + } + return err +} + +func decodeTonStonfiV2StonfiProvideLiquidityJettonPayloadOpPayload(j *Payload, c *boc.Cell) error { + var res TonStonfiV2StonfiProvideLiquidity + err := tlb.Unmarshal(c, &res) + if err == nil { + j.SumType = TonStonfiV2StonfiProvideLiquidityJettonPayloadOp + j.Value = res + return nil + } + return err +} + +const ( + TonCocoonTextCmdOp PayloadOpName = "TonCocoonTextCmd" + TonCocoonTextCommandOp PayloadOpName = "TonCocoonTextCommand" + TonTolkTestsTextCommentJettonPayloadOp PayloadOpName = "TonTolkTestsTextCommentJettonPayload" + TonTep74ChangeMinterAdminOp PayloadOpName = "TonTep74ChangeMinterAdmin" + TonTep74ChangeMinterContentOp PayloadOpName = "TonTep74ChangeMinterContent" + TonTep74MintNewJettonsOp PayloadOpName = "TonTep74MintNewJettons" + TonTolkTestsTegroJettonSwapJettonPayloadOp PayloadOpName = "TonTolkTestsTegroJettonSwapJettonPayload" + TonCocoonChangeParamsOp PayloadOpName = "TonCocoonChangeParams" + TonTolkTestsCoffeeStakingLockJettonPayloadOp PayloadOpName = "TonTolkTestsCoffeeStakingLockJettonPayload" + TonTep74AskToTransferOp PayloadOpName = "TonTep74AskToTransfer" + TonCocoonUpgradeCodeOp PayloadOpName = "TonCocoonUpgradeCode" + TonTep74InternalTransferStepOp PayloadOpName = "TonTep74InternalTransferStep" + TonCoffeeCrossDexResendOp PayloadOpName = "TonCoffeeCrossDexResend" + TonTolkTestsEncryptedTextCommentJettonPayloadOp PayloadOpName = "TonTolkTestsEncryptedTextCommentJettonPayload" + TonStonfiV1StonfiSwapJettonPayloadOp PayloadOpName = "TonStonfiV1StonfiSwapJettonPayload" + TonCocoonOwnerWorkerRegisterOp PayloadOpName = "TonCocoonOwnerWorkerRegister" + TonTolkTestsTegroAddLiquidityJettonPayloadOp PayloadOpName = "TonTolkTestsTegroAddLiquidityJettonPayload" + TonTep74RequestWalletAddressOp PayloadOpName = "TonTep74RequestWalletAddress" + TonStonfiV2StonfiProvideLpV2JettonPayloadOp PayloadOpName = "TonStonfiV2StonfiProvideLpV2JettonPayload" + TonCocoonDelProxyTypeOp PayloadOpName = "TonCocoonDelProxyType" + TonTolkTestsBidaskProvideBothJettonPayloadOp PayloadOpName = "TonTolkTestsBidaskProvideBothJettonPayload" + TonTolkTestsDedustDepositLiquidityJettonPayloadOp PayloadOpName = "TonTolkTestsDedustDepositLiquidityJettonPayload" + TonTolkTestsPoolFundAccountJettonPayloadOp PayloadOpName = "TonTolkTestsPoolFundAccountJettonPayload" + TonStonfiV1StonfiSwapOkRefJettonPayloadOp PayloadOpName = "TonStonfiV1StonfiSwapOkRefJettonPayload" + TonCocoonWorkerProxyRequestOp PayloadOpName = "TonCocoonWorkerProxyRequest" + TonTolkTestsCoffeeCrossDexResendJettonPayloadOp PayloadOpName = "TonTolkTestsCoffeeCrossDexResendJettonPayload" + TonCocoonUpgradeFullOp PayloadOpName = "TonCocoonUpgradeFull" + TonCocoonResetRootOp PayloadOpName = "TonCocoonResetRoot" + TonTep74AskToBurnOp PayloadOpName = "TonTep74AskToBurn" + TonCocoonExtProxyCloseRequestSignedOp PayloadOpName = "TonCocoonExtProxyCloseRequestSigned" + TonTolkTestsBidaskDammProvideJettonPayloadOp PayloadOpName = "TonTolkTestsBidaskDammProvideJettonPayload" + TonCocoonClientProxyRequestOp PayloadOpName = "TonCocoonClientProxyRequest" + TonStonfiV2StonfiSwapV2JettonPayloadOp PayloadOpName = "TonStonfiV2StonfiSwapV2JettonPayload" + TonCocoonOwnerClientIncreaseStakeOp PayloadOpName = "TonCocoonOwnerClientIncreaseStake" + TonCocoonUnregisterProxyOp PayloadOpName = "TonCocoonUnregisterProxy" + TonCocoonAddProxyTypeOp PayloadOpName = "TonCocoonAddProxyType" + TonTolkTestsBidaskDammProvideOneSideJettonPayloadOp PayloadOpName = "TonTolkTestsBidaskDammProvideOneSideJettonPayload" + TonTep74TransferNotificationForRecipientOp PayloadOpName = "TonTep74TransferNotificationForRecipient" + TonCocoonExtProxyPayoutRequestOp PayloadOpName = "TonCocoonExtProxyPayoutRequest" + TonTolkTestsStormDepositJettonJettonPayloadOp PayloadOpName = "TonTolkTestsStormDepositJettonJettonPayload" + TonTolkTestsInvoicePayloadJettonPayloadOp PayloadOpName = "TonTolkTestsInvoicePayloadJettonPayload" + TonTep74BurnNotificationForMinterOp PayloadOpName = "TonTep74BurnNotificationForMinter" + TonCocoonOwnerClientChangeSecretHashAndTopUpOp PayloadOpName = "TonCocoonOwnerClientChangeSecretHashAndTopUp" + TonTolkTestsTonkeeperRelayerFeeJettonPayloadOp PayloadOpName = "TonTolkTestsTonkeeperRelayerFeeJettonPayload" + TonTolkTestsBidaskSwapV2JettonPayloadOp PayloadOpName = "TonTolkTestsBidaskSwapV2JettonPayload" + TonCocoonDelWorkerTypeOp PayloadOpName = "TonCocoonDelWorkerType" + TonCocoonRegisterProxyOp PayloadOpName = "TonCocoonRegisterProxy" + TonCocoonDelModelTypeOp PayloadOpName = "TonCocoonDelModelType" + TonTolkTestsMoonBoostPoolJettonPayloadOp PayloadOpName = "TonTolkTestsMoonBoostPoolJettonPayload" + TonTolkTestsBidaskProvideJettonPayloadOp PayloadOpName = "TonTolkTestsBidaskProvideJettonPayload" + TonCocoonExtProxyIncreaseStakeOp PayloadOpName = "TonCocoonExtProxyIncreaseStake" + TonTolkTestsMoonFillOrderJettonPayloadOp PayloadOpName = "TonTolkTestsMoonFillOrderJettonPayload" + TonCocoonOwnerWalletSendMessageOp PayloadOpName = "TonCocoonOwnerWalletSendMessage" + TonCocoonUpdateProxyOp PayloadOpName = "TonCocoonUpdateProxy" + TonCocoonExtWorkerPayoutRequestSignedOp PayloadOpName = "TonCocoonExtWorkerPayoutRequestSigned" + TonCocoonUpgradeContractsOp PayloadOpName = "TonCocoonUpgradeContracts" + TonTolkTestsBidaskDammProvideBothJettonPayloadOp PayloadOpName = "TonTolkTestsBidaskDammProvideBothJettonPayload" + TonCocoonOwnerClientChangeSecretHashOp PayloadOpName = "TonCocoonOwnerClientChangeSecretHash" + TonTolkTestsMoonDepositLiquidityJettonPayloadOp PayloadOpName = "TonTolkTestsMoonDepositLiquidityJettonPayload" + TonTolkTestsMoonSwapJettonPayloadOp PayloadOpName = "TonTolkTestsMoonSwapJettonPayload" + TonCocoonOwnerProxyCloseOp PayloadOpName = "TonCocoonOwnerProxyClose" + TonTolkTestsCoffeeCrossDexFailureJettonPayloadOp PayloadOpName = "TonTolkTestsCoffeeCrossDexFailureJettonPayload" + TonCocoonExtClientChargeSignedOp PayloadOpName = "TonCocoonExtClientChargeSigned" + TonTolkTestsCoffeeSwapJettonPayloadOp PayloadOpName = "TonTolkTestsCoffeeSwapJettonPayload" + TonTolkTestsCoffeeCreatePoolJettonPayloadOp PayloadOpName = "TonTolkTestsCoffeeCreatePoolJettonPayload" + TonTolkTestsCoffeeDepositLiquidityJettonPayloadOp PayloadOpName = "TonTolkTestsCoffeeDepositLiquidityJettonPayload" + TonTolkTestsCoffeeNotificationJettonPayloadOp PayloadOpName = "TonTolkTestsCoffeeNotificationJettonPayload" + TonCocoonAddModelTypeOp PayloadOpName = "TonCocoonAddModelType" + TonCocoonOwnerClientRegisterOp PayloadOpName = "TonCocoonOwnerClientRegister" + TonTolkTestsMoonSwapFailedJettonPayloadOp PayloadOpName = "TonTolkTestsMoonSwapFailedJettonPayload" + TonCocoonChangeOwnerOp PayloadOpName = "TonCocoonChangeOwner" + TonCocoonChangeFeesOp PayloadOpName = "TonCocoonChangeFees" + TonCocoonPayoutOp PayloadOpName = "TonCocoonPayout" + TonStonfiV2StonfiSwapOkJettonPayloadOp PayloadOpName = "TonStonfiV2StonfiSwapOkJettonPayload" + TonTolkTestsStormStakeJettonPayloadOp PayloadOpName = "TonTolkTestsStormStakeJettonPayload" + TonTolkTestsWithdrawPayloadJettonPayloadOp PayloadOpName = "TonTolkTestsWithdrawPayloadJettonPayload" + TonTolkTestsMoonSwapSucceedJettonPayloadOp PayloadOpName = "TonTolkTestsMoonSwapSucceedJettonPayload" + TonTep74ResponseWalletAddressOp PayloadOpName = "TonTep74ResponseWalletAddress" + TonCocoonReturnExcessesBackOp PayloadOpName = "TonCocoonReturnExcessesBack" + TonTep74ReturnExcessesBackOp PayloadOpName = "TonTep74ReturnExcessesBack" + TonTep74AboaLisaOp PayloadOpName = "TonTep74AboaLisa" + TonTolkTestsMoonCreateOrderJettonPayloadOp PayloadOpName = "TonTolkTestsMoonCreateOrderJettonPayload" + TonCocoonOwnerClientWithdrawOp PayloadOpName = "TonCocoonOwnerClientWithdraw" + TonTolkTestsBidaskDammSwapJettonPayloadOp PayloadOpName = "TonTolkTestsBidaskDammSwapJettonPayload" + TonCocoonAddWorkerTypeOp PayloadOpName = "TonCocoonAddWorkerType" + TonTolkTestsDedustSwapJettonPayloadOp PayloadOpName = "TonTolkTestsDedustSwapJettonPayload" + TonCocoonExtProxyCloseCompleteRequestSignedOp PayloadOpName = "TonCocoonExtProxyCloseCompleteRequestSigned" + TonTolkTestsCoffeeMevProtectFailedSwapJettonPayloadOp PayloadOpName = "TonTolkTestsCoffeeMevProtectFailedSwapJettonPayload" + TonCocoonExtClientGrantRefundSignedOp PayloadOpName = "TonCocoonExtClientGrantRefundSigned" + TonCocoonExtClientTopUpOp PayloadOpName = "TonCocoonExtClientTopUp" + TonTolkTestsBidaskSwapJettonPayloadOp PayloadOpName = "TonTolkTestsBidaskSwapJettonPayload" + TonCocoonExtWorkerLastPayoutRequestSignedOp PayloadOpName = "TonCocoonExtWorkerLastPayoutRequestSigned" + TonTolkTestsDepositPayloadJettonPayloadOp PayloadOpName = "TonTolkTestsDepositPayloadJettonPayload" + TonCocoonOwnerClientRequestRefundOp PayloadOpName = "TonCocoonOwnerClientRequestRefund" + TonStonfiV2StonfiProvideLiquidityJettonPayloadOp PayloadOpName = "TonStonfiV2StonfiProvideLiquidityJettonPayload" + + TonCocoonTextCmdOpCode PayloadOpCode = 0x00000000 + TonCocoonTextCommandOpCode PayloadOpCode = 0x00000000 + TonTolkTestsTextCommentJettonPayloadOpCode PayloadOpCode = 0x00000000 + TonTep74ChangeMinterAdminOpCode PayloadOpCode = 0x00000003 + TonTep74ChangeMinterContentOpCode PayloadOpCode = 0x00000004 + TonTep74MintNewJettonsOpCode PayloadOpCode = 0x00000015 + TonTolkTestsTegroJettonSwapJettonPayloadOpCode PayloadOpCode = 0x01fb7a25 + TonCocoonChangeParamsOpCode PayloadOpCode = 0x022fa189 + TonTolkTestsCoffeeStakingLockJettonPayloadOpCode PayloadOpCode = 0x0c0ffede + TonTep74AskToTransferOpCode PayloadOpCode = 0x0f8a7ea5 + TonCocoonUpgradeCodeOpCode PayloadOpCode = 0x11aefd51 + TonTep74InternalTransferStepOpCode PayloadOpCode = 0x178d4519 + TonCoffeeCrossDexResendOpCode PayloadOpCode = 0x200f9086 + TonTolkTestsEncryptedTextCommentJettonPayloadOpCode PayloadOpCode = 0x2167da4b + TonStonfiV1StonfiSwapJettonPayloadOpCode PayloadOpCode = 0x25938561 + TonCocoonOwnerWorkerRegisterOpCode PayloadOpCode = 0x26ed7f65 + TonTolkTestsTegroAddLiquidityJettonPayloadOpCode PayloadOpCode = 0x287e167a + TonTep74RequestWalletAddressOpCode PayloadOpCode = 0x2c76b973 + TonStonfiV2StonfiProvideLpV2JettonPayloadOpCode PayloadOpCode = 0x37c096df + TonCocoonDelProxyTypeOpCode PayloadOpCode = 0x3c41d0b2 + TonTolkTestsBidaskProvideBothJettonPayloadOpCode PayloadOpCode = 0x3ea0bafc + TonTolkTestsDedustDepositLiquidityJettonPayloadOpCode PayloadOpCode = 0x40e108d6 + TonTolkTestsPoolFundAccountJettonPayloadOpCode PayloadOpCode = 0x4468de77 + TonStonfiV1StonfiSwapOkRefJettonPayloadOpCode PayloadOpCode = 0x45078540 + TonCocoonWorkerProxyRequestOpCode PayloadOpCode = 0x4d725d2c + TonTolkTestsCoffeeCrossDexResendJettonPayloadOpCode PayloadOpCode = 0x4ee9b106 + TonCocoonUpgradeFullOpCode PayloadOpCode = 0x4f7c5789 + TonCocoonResetRootOpCode PayloadOpCode = 0x563c1d96 + TonTep74AskToBurnOpCode PayloadOpCode = 0x595f07bc + TonCocoonExtProxyCloseRequestSignedOpCode PayloadOpCode = 0x636a4391 + TonTolkTestsBidaskDammProvideJettonPayloadOpCode PayloadOpCode = 0x63ec24ae + TonCocoonClientProxyRequestOpCode PayloadOpCode = 0x65448ff4 + TonStonfiV2StonfiSwapV2JettonPayloadOpCode PayloadOpCode = 0x6664de2a + TonCocoonOwnerClientIncreaseStakeOpCode PayloadOpCode = 0x6a1f6a60 + TonCocoonUnregisterProxyOpCode PayloadOpCode = 0x6d49eaf2 + TonCocoonAddProxyTypeOpCode PayloadOpCode = 0x71860e80 + TonTolkTestsBidaskDammProvideOneSideJettonPayloadOpCode PayloadOpCode = 0x729c04c8 + TonTep74TransferNotificationForRecipientOpCode PayloadOpCode = 0x7362d09c + TonCocoonExtProxyPayoutRequestOpCode PayloadOpCode = 0x7610e6eb + TonTolkTestsStormDepositJettonJettonPayloadOpCode PayloadOpCode = 0x76840119 + TonTolkTestsInvoicePayloadJettonPayloadOpCode PayloadOpCode = 0x7aa23eb5 + TonTep74BurnNotificationForMinterOpCode PayloadOpCode = 0x7bdd97de + TonCocoonOwnerClientChangeSecretHashAndTopUpOpCode PayloadOpCode = 0x8473b408 + TonTolkTestsTonkeeperRelayerFeeJettonPayloadOpCode PayloadOpCode = 0x878da6e3 + TonTolkTestsBidaskSwapV2JettonPayloadOpCode PayloadOpCode = 0x87d36990 + TonCocoonDelWorkerTypeOpCode PayloadOpCode = 0x8d94a79a + TonCocoonRegisterProxyOpCode PayloadOpCode = 0x927c7cb5 + TonCocoonDelModelTypeOpCode PayloadOpCode = 0x92b11c18 + TonTolkTestsMoonBoostPoolJettonPayloadOpCode PayloadOpCode = 0x96aa1586 + TonTolkTestsBidaskProvideJettonPayloadOpCode PayloadOpCode = 0x96feef7b + TonCocoonExtProxyIncreaseStakeOpCode PayloadOpCode = 0x9713f187 + TonTolkTestsMoonFillOrderJettonPayloadOpCode PayloadOpCode = 0x99b49842 + TonCocoonOwnerWalletSendMessageOpCode PayloadOpCode = 0x9c69f376 + TonCocoonUpdateProxyOpCode PayloadOpCode = 0x9c7924ba + TonCocoonExtWorkerPayoutRequestSignedOpCode PayloadOpCode = 0xa040ad28 + TonCocoonUpgradeContractsOpCode PayloadOpCode = 0xa2370f61 + TonTolkTestsBidaskDammProvideBothJettonPayloadOpCode PayloadOpCode = 0xa8904134 + TonCocoonOwnerClientChangeSecretHashOpCode PayloadOpCode = 0xa9357034 + TonTolkTestsMoonDepositLiquidityJettonPayloadOpCode PayloadOpCode = 0xb31db781 + TonTolkTestsMoonSwapJettonPayloadOpCode PayloadOpCode = 0xb37a900b + TonCocoonOwnerProxyCloseOpCode PayloadOpCode = 0xb51d5a01 + TonTolkTestsCoffeeCrossDexFailureJettonPayloadOpCode PayloadOpCode = 0xb902e61a + TonCocoonExtClientChargeSignedOpCode PayloadOpCode = 0xbb63ff93 + TonTolkTestsCoffeeSwapJettonPayloadOpCode PayloadOpCode = 0xc0ffee10 + TonTolkTestsCoffeeCreatePoolJettonPayloadOpCode PayloadOpCode = 0xc0ffee11 + TonTolkTestsCoffeeDepositLiquidityJettonPayloadOpCode PayloadOpCode = 0xc0ffee12 + TonTolkTestsCoffeeNotificationJettonPayloadOpCode PayloadOpCode = 0xc0ffee36 + TonCocoonAddModelTypeOpCode PayloadOpCode = 0xc146134d + TonCocoonOwnerClientRegisterOpCode PayloadOpCode = 0xc45f9f3b + TonTolkTestsMoonSwapFailedJettonPayloadOpCode PayloadOpCode = 0xc47c1f57 + TonCocoonChangeOwnerOpCode PayloadOpCode = 0xc4a1ae54 + TonCocoonChangeFeesOpCode PayloadOpCode = 0xc52ed8d4 + TonCocoonPayoutOpCode PayloadOpCode = 0xc59a7cd3 + TonStonfiV2StonfiSwapOkJettonPayloadOpCode PayloadOpCode = 0xc64370e5 + TonTolkTestsStormStakeJettonPayloadOpCode PayloadOpCode = 0xc89a3ee4 + TonTolkTestsWithdrawPayloadJettonPayloadOpCode PayloadOpCode = 0xcb03bfaf + TonTolkTestsMoonSwapSucceedJettonPayloadOpCode PayloadOpCode = 0xcb7f38d6 + TonTep74ResponseWalletAddressOpCode PayloadOpCode = 0xd1735400 + TonCocoonReturnExcessesBackOpCode PayloadOpCode = 0xd53276db + TonTep74ReturnExcessesBackOpCode PayloadOpCode = 0xd53276db + TonTep74AboaLisaOpCode PayloadOpCode = 0xd53276db + TonTolkTestsMoonCreateOrderJettonPayloadOpCode PayloadOpCode = 0xda067c19 + TonCocoonOwnerClientWithdrawOpCode PayloadOpCode = 0xda068e78 + TonTolkTestsBidaskDammSwapJettonPayloadOpCode PayloadOpCode = 0xdd79732c + TonCocoonAddWorkerTypeOpCode PayloadOpCode = 0xe34b1c60 + TonTolkTestsDedustSwapJettonPayloadOpCode PayloadOpCode = 0xe3a0d482 + TonCocoonExtProxyCloseCompleteRequestSignedOpCode PayloadOpCode = 0xe511abc7 + TonTolkTestsCoffeeMevProtectFailedSwapJettonPayloadOpCode PayloadOpCode = 0xee51ce51 + TonCocoonExtClientGrantRefundSignedOpCode PayloadOpCode = 0xefd711e1 + TonCocoonExtClientTopUpOpCode PayloadOpCode = 0xf172e6c2 + TonTolkTestsBidaskSwapJettonPayloadOpCode PayloadOpCode = 0xf2ef6c1b + TonCocoonExtWorkerLastPayoutRequestSignedOpCode PayloadOpCode = 0xf5f26a36 + TonTolkTestsDepositPayloadJettonPayloadOpCode PayloadOpCode = 0xf9471134 + TonCocoonOwnerClientRequestRefundOpCode PayloadOpCode = 0xfafa6cc1 + TonStonfiV2StonfiProvideLiquidityJettonPayloadOpCode PayloadOpCode = 0xfcf9e58f +) + +var KnownPayloadTypes = map[string]any{ + TonCocoonTextCmdOp: TonCocoonTextCmdPayloadBody{}, + TonCocoonTextCommandOp: TonCocoonTextCommandPayloadBody{}, + TonTolkTestsTextCommentJettonPayloadOp: TonTolkTestsTextComment{}, + TonTep74ChangeMinterAdminOp: TonTep74ChangeMinterAdminPayloadBody{}, + TonTep74ChangeMinterContentOp: TonTep74ChangeMinterContentPayloadBody{}, + TonTep74MintNewJettonsOp: TonTep74MintNewJettonsPayloadBody{}, + TonTolkTestsTegroJettonSwapJettonPayloadOp: TonTolkTestsTegroJettonSwap{}, + TonCocoonChangeParamsOp: TonCocoonChangeParamsPayloadBody{}, + TonTolkTestsCoffeeStakingLockJettonPayloadOp: TonTolkTestsCoffeeStakingLock{}, + TonTep74AskToTransferOp: TonTep74AskToTransferPayloadBody{}, + TonCocoonUpgradeCodeOp: TonCocoonUpgradeCodePayloadBody{}, + TonTep74InternalTransferStepOp: TonTep74InternalTransferStepPayloadBody{}, + TonCoffeeCrossDexResendOp: TonCoffeeCrossDexResendPayloadBody{}, + TonTolkTestsEncryptedTextCommentJettonPayloadOp: TonTolkTestsEncryptedTextComment{}, + TonStonfiV1StonfiSwapJettonPayloadOp: TonStonfiV1StonfiSwap{}, + TonCocoonOwnerWorkerRegisterOp: TonCocoonOwnerWorkerRegisterPayloadBody{}, + TonTolkTestsTegroAddLiquidityJettonPayloadOp: TonTolkTestsTegroAddLiquidity{}, + TonTep74RequestWalletAddressOp: TonTep74RequestWalletAddressPayloadBody{}, + TonStonfiV2StonfiProvideLpV2JettonPayloadOp: TonStonfiV2StonfiProvideLpV2{}, + TonCocoonDelProxyTypeOp: TonCocoonDelProxyTypePayloadBody{}, + TonTolkTestsBidaskProvideBothJettonPayloadOp: TonTolkTestsBidaskProvideBoth{}, + TonTolkTestsDedustDepositLiquidityJettonPayloadOp: TonTolkTestsDedustDepositLiquidity{}, + TonTolkTestsPoolFundAccountJettonPayloadOp: TonTolkTestsPoolFundAccount{}, + TonStonfiV1StonfiSwapOkRefJettonPayloadOp: TonStonfiV1StonfiSwapOkRef{}, + TonCocoonWorkerProxyRequestOp: TonCocoonWorkerProxyRequestPayloadBody{}, + TonTolkTestsCoffeeCrossDexResendJettonPayloadOp: TonTolkTestsCoffeeCrossDexResend{}, + TonCocoonUpgradeFullOp: TonCocoonUpgradeFullPayloadBody{}, + TonCocoonResetRootOp: TonCocoonResetRootPayloadBody{}, + TonTep74AskToBurnOp: TonTep74AskToBurnPayloadBody{}, + TonCocoonExtProxyCloseRequestSignedOp: TonCocoonExtProxyCloseRequestSignedPayloadBody{}, + TonTolkTestsBidaskDammProvideJettonPayloadOp: TonTolkTestsBidaskDammProvide{}, + TonCocoonClientProxyRequestOp: TonCocoonClientProxyRequestPayloadBody{}, + TonStonfiV2StonfiSwapV2JettonPayloadOp: TonStonfiV2StonfiSwapV2{}, + TonCocoonOwnerClientIncreaseStakeOp: TonCocoonOwnerClientIncreaseStakePayloadBody{}, + TonCocoonUnregisterProxyOp: TonCocoonUnregisterProxyPayloadBody{}, + TonCocoonAddProxyTypeOp: TonCocoonAddProxyTypePayloadBody{}, + TonTolkTestsBidaskDammProvideOneSideJettonPayloadOp: TonTolkTestsBidaskDammProvideOneSide{}, + TonTep74TransferNotificationForRecipientOp: TonTep74TransferNotificationForRecipientPayloadBody{}, + TonCocoonExtProxyPayoutRequestOp: TonCocoonExtProxyPayoutRequestPayloadBody{}, + TonTolkTestsStormDepositJettonJettonPayloadOp: TonTolkTestsStormDepositJetton{}, + TonTolkTestsInvoicePayloadJettonPayloadOp: TonTolkTestsInvoicePayload{}, + TonTep74BurnNotificationForMinterOp: TonTep74BurnNotificationForMinterPayloadBody{}, + TonCocoonOwnerClientChangeSecretHashAndTopUpOp: TonCocoonOwnerClientChangeSecretHashAndTopUpPayloadBody{}, + TonTolkTestsTonkeeperRelayerFeeJettonPayloadOp: TonTolkTestsTonkeeperRelayerFee{}, + TonTolkTestsBidaskSwapV2JettonPayloadOp: TonTolkTestsBidaskSwapV2{}, + TonCocoonDelWorkerTypeOp: TonCocoonDelWorkerTypePayloadBody{}, + TonCocoonRegisterProxyOp: TonCocoonRegisterProxyPayloadBody{}, + TonCocoonDelModelTypeOp: TonCocoonDelModelTypePayloadBody{}, + TonTolkTestsMoonBoostPoolJettonPayloadOp: TonTolkTestsMoonBoostPool{}, + TonTolkTestsBidaskProvideJettonPayloadOp: TonTolkTestsBidaskProvide{}, + TonCocoonExtProxyIncreaseStakeOp: TonCocoonExtProxyIncreaseStakePayloadBody{}, + TonTolkTestsMoonFillOrderJettonPayloadOp: TonTolkTestsMoonFillOrder{}, + TonCocoonOwnerWalletSendMessageOp: TonCocoonOwnerWalletSendMessagePayloadBody{}, + TonCocoonUpdateProxyOp: TonCocoonUpdateProxyPayloadBody{}, + TonCocoonExtWorkerPayoutRequestSignedOp: TonCocoonExtWorkerPayoutRequestSignedPayloadBody{}, + TonCocoonUpgradeContractsOp: TonCocoonUpgradeContractsPayloadBody{}, + TonTolkTestsBidaskDammProvideBothJettonPayloadOp: TonTolkTestsBidaskDammProvideBoth{}, + TonCocoonOwnerClientChangeSecretHashOp: TonCocoonOwnerClientChangeSecretHashPayloadBody{}, + TonTolkTestsMoonDepositLiquidityJettonPayloadOp: TonTolkTestsMoonDepositLiquidity{}, + TonTolkTestsMoonSwapJettonPayloadOp: TonTolkTestsMoonSwap{}, + TonCocoonOwnerProxyCloseOp: TonCocoonOwnerProxyClosePayloadBody{}, + TonTolkTestsCoffeeCrossDexFailureJettonPayloadOp: TonTolkTestsCoffeeCrossDexFailure{}, + TonCocoonExtClientChargeSignedOp: TonCocoonExtClientChargeSignedPayloadBody{}, + TonTolkTestsCoffeeSwapJettonPayloadOp: TonTolkTestsCoffeeSwap{}, + TonTolkTestsCoffeeCreatePoolJettonPayloadOp: TonTolkTestsCoffeeCreatePool{}, + TonTolkTestsCoffeeDepositLiquidityJettonPayloadOp: TonTolkTestsCoffeeDepositLiquidity{}, + TonTolkTestsCoffeeNotificationJettonPayloadOp: TonTolkTestsCoffeeNotification{}, + TonCocoonAddModelTypeOp: TonCocoonAddModelTypePayloadBody{}, + TonCocoonOwnerClientRegisterOp: TonCocoonOwnerClientRegisterPayloadBody{}, + TonTolkTestsMoonSwapFailedJettonPayloadOp: TonTolkTestsMoonSwapFailed{}, + TonCocoonChangeOwnerOp: TonCocoonChangeOwnerPayloadBody{}, + TonCocoonChangeFeesOp: TonCocoonChangeFeesPayloadBody{}, + TonCocoonPayoutOp: TonCocoonPayoutPayloadBody{}, + TonStonfiV2StonfiSwapOkJettonPayloadOp: TonStonfiV2StonfiSwapOk{}, + TonTolkTestsStormStakeJettonPayloadOp: TonTolkTestsStormStake{}, + TonTolkTestsWithdrawPayloadJettonPayloadOp: TonTolkTestsWithdrawPayload{}, + TonTolkTestsMoonSwapSucceedJettonPayloadOp: TonTolkTestsMoonSwapSucceed{}, + TonTep74ResponseWalletAddressOp: TonTep74ResponseWalletAddressPayloadBody{}, + TonCocoonReturnExcessesBackOp: TonCocoonReturnExcessesBackPayloadBody{}, + TonTep74ReturnExcessesBackOp: TonTep74ReturnExcessesBackPayloadBody{}, + TonTep74AboaLisaOp: TonTep74AboaLisaPayloadBody{}, + TonTolkTestsMoonCreateOrderJettonPayloadOp: TonTolkTestsMoonCreateOrder{}, + TonCocoonOwnerClientWithdrawOp: TonCocoonOwnerClientWithdrawPayloadBody{}, + TonTolkTestsBidaskDammSwapJettonPayloadOp: TonTolkTestsBidaskDammSwap{}, + TonCocoonAddWorkerTypeOp: TonCocoonAddWorkerTypePayloadBody{}, + TonTolkTestsDedustSwapJettonPayloadOp: TonTolkTestsDedustSwap{}, + TonCocoonExtProxyCloseCompleteRequestSignedOp: TonCocoonExtProxyCloseCompleteRequestSignedPayloadBody{}, + TonTolkTestsCoffeeMevProtectFailedSwapJettonPayloadOp: TonTolkTestsCoffeeMevProtectFailedSwap{}, + TonCocoonExtClientGrantRefundSignedOp: TonCocoonExtClientGrantRefundSignedPayloadBody{}, + TonCocoonExtClientTopUpOp: TonCocoonExtClientTopUpPayloadBody{}, + TonTolkTestsBidaskSwapJettonPayloadOp: TonTolkTestsBidaskSwap{}, + TonCocoonExtWorkerLastPayoutRequestSignedOp: TonCocoonExtWorkerLastPayoutRequestSignedPayloadBody{}, + TonTolkTestsDepositPayloadJettonPayloadOp: TonTolkTestsDepositPayload{}, + TonCocoonOwnerClientRequestRefundOp: TonCocoonOwnerClientRequestRefundPayloadBody{}, + TonStonfiV2StonfiProvideLiquidityJettonPayloadOp: TonStonfiV2StonfiProvideLiquidity{}, +} +var PayloadOpCodes = map[PayloadOpName]PayloadOpCode{ + TonCocoonTextCmdOp: TonCocoonTextCmdOpCode, + TonCocoonTextCommandOp: TonCocoonTextCommandOpCode, + TonTolkTestsTextCommentJettonPayloadOp: TonTolkTestsTextCommentJettonPayloadOpCode, + TonTep74ChangeMinterAdminOp: TonTep74ChangeMinterAdminOpCode, + TonTep74ChangeMinterContentOp: TonTep74ChangeMinterContentOpCode, + TonTep74MintNewJettonsOp: TonTep74MintNewJettonsOpCode, + TonTolkTestsTegroJettonSwapJettonPayloadOp: TonTolkTestsTegroJettonSwapJettonPayloadOpCode, + TonCocoonChangeParamsOp: TonCocoonChangeParamsOpCode, + TonTolkTestsCoffeeStakingLockJettonPayloadOp: TonTolkTestsCoffeeStakingLockJettonPayloadOpCode, + TonTep74AskToTransferOp: TonTep74AskToTransferOpCode, + TonCocoonUpgradeCodeOp: TonCocoonUpgradeCodeOpCode, + TonTep74InternalTransferStepOp: TonTep74InternalTransferStepOpCode, + TonCoffeeCrossDexResendOp: TonCoffeeCrossDexResendOpCode, + TonTolkTestsEncryptedTextCommentJettonPayloadOp: TonTolkTestsEncryptedTextCommentJettonPayloadOpCode, + TonStonfiV1StonfiSwapJettonPayloadOp: TonStonfiV1StonfiSwapJettonPayloadOpCode, + TonCocoonOwnerWorkerRegisterOp: TonCocoonOwnerWorkerRegisterOpCode, + TonTolkTestsTegroAddLiquidityJettonPayloadOp: TonTolkTestsTegroAddLiquidityJettonPayloadOpCode, + TonTep74RequestWalletAddressOp: TonTep74RequestWalletAddressOpCode, + TonStonfiV2StonfiProvideLpV2JettonPayloadOp: TonStonfiV2StonfiProvideLpV2JettonPayloadOpCode, + TonCocoonDelProxyTypeOp: TonCocoonDelProxyTypeOpCode, + TonTolkTestsBidaskProvideBothJettonPayloadOp: TonTolkTestsBidaskProvideBothJettonPayloadOpCode, + TonTolkTestsDedustDepositLiquidityJettonPayloadOp: TonTolkTestsDedustDepositLiquidityJettonPayloadOpCode, + TonTolkTestsPoolFundAccountJettonPayloadOp: TonTolkTestsPoolFundAccountJettonPayloadOpCode, + TonStonfiV1StonfiSwapOkRefJettonPayloadOp: TonStonfiV1StonfiSwapOkRefJettonPayloadOpCode, + TonCocoonWorkerProxyRequestOp: TonCocoonWorkerProxyRequestOpCode, + TonTolkTestsCoffeeCrossDexResendJettonPayloadOp: TonTolkTestsCoffeeCrossDexResendJettonPayloadOpCode, + TonCocoonUpgradeFullOp: TonCocoonUpgradeFullOpCode, + TonCocoonResetRootOp: TonCocoonResetRootOpCode, + TonTep74AskToBurnOp: TonTep74AskToBurnOpCode, + TonCocoonExtProxyCloseRequestSignedOp: TonCocoonExtProxyCloseRequestSignedOpCode, + TonTolkTestsBidaskDammProvideJettonPayloadOp: TonTolkTestsBidaskDammProvideJettonPayloadOpCode, + TonCocoonClientProxyRequestOp: TonCocoonClientProxyRequestOpCode, + TonStonfiV2StonfiSwapV2JettonPayloadOp: TonStonfiV2StonfiSwapV2JettonPayloadOpCode, + TonCocoonOwnerClientIncreaseStakeOp: TonCocoonOwnerClientIncreaseStakeOpCode, + TonCocoonUnregisterProxyOp: TonCocoonUnregisterProxyOpCode, + TonCocoonAddProxyTypeOp: TonCocoonAddProxyTypeOpCode, + TonTolkTestsBidaskDammProvideOneSideJettonPayloadOp: TonTolkTestsBidaskDammProvideOneSideJettonPayloadOpCode, + TonTep74TransferNotificationForRecipientOp: TonTep74TransferNotificationForRecipientOpCode, + TonCocoonExtProxyPayoutRequestOp: TonCocoonExtProxyPayoutRequestOpCode, + TonTolkTestsStormDepositJettonJettonPayloadOp: TonTolkTestsStormDepositJettonJettonPayloadOpCode, + TonTolkTestsInvoicePayloadJettonPayloadOp: TonTolkTestsInvoicePayloadJettonPayloadOpCode, + TonTep74BurnNotificationForMinterOp: TonTep74BurnNotificationForMinterOpCode, + TonCocoonOwnerClientChangeSecretHashAndTopUpOp: TonCocoonOwnerClientChangeSecretHashAndTopUpOpCode, + TonTolkTestsTonkeeperRelayerFeeJettonPayloadOp: TonTolkTestsTonkeeperRelayerFeeJettonPayloadOpCode, + TonTolkTestsBidaskSwapV2JettonPayloadOp: TonTolkTestsBidaskSwapV2JettonPayloadOpCode, + TonCocoonDelWorkerTypeOp: TonCocoonDelWorkerTypeOpCode, + TonCocoonRegisterProxyOp: TonCocoonRegisterProxyOpCode, + TonCocoonDelModelTypeOp: TonCocoonDelModelTypeOpCode, + TonTolkTestsMoonBoostPoolJettonPayloadOp: TonTolkTestsMoonBoostPoolJettonPayloadOpCode, + TonTolkTestsBidaskProvideJettonPayloadOp: TonTolkTestsBidaskProvideJettonPayloadOpCode, + TonCocoonExtProxyIncreaseStakeOp: TonCocoonExtProxyIncreaseStakeOpCode, + TonTolkTestsMoonFillOrderJettonPayloadOp: TonTolkTestsMoonFillOrderJettonPayloadOpCode, + TonCocoonOwnerWalletSendMessageOp: TonCocoonOwnerWalletSendMessageOpCode, + TonCocoonUpdateProxyOp: TonCocoonUpdateProxyOpCode, + TonCocoonExtWorkerPayoutRequestSignedOp: TonCocoonExtWorkerPayoutRequestSignedOpCode, + TonCocoonUpgradeContractsOp: TonCocoonUpgradeContractsOpCode, + TonTolkTestsBidaskDammProvideBothJettonPayloadOp: TonTolkTestsBidaskDammProvideBothJettonPayloadOpCode, + TonCocoonOwnerClientChangeSecretHashOp: TonCocoonOwnerClientChangeSecretHashOpCode, + TonTolkTestsMoonDepositLiquidityJettonPayloadOp: TonTolkTestsMoonDepositLiquidityJettonPayloadOpCode, + TonTolkTestsMoonSwapJettonPayloadOp: TonTolkTestsMoonSwapJettonPayloadOpCode, + TonCocoonOwnerProxyCloseOp: TonCocoonOwnerProxyCloseOpCode, + TonTolkTestsCoffeeCrossDexFailureJettonPayloadOp: TonTolkTestsCoffeeCrossDexFailureJettonPayloadOpCode, + TonCocoonExtClientChargeSignedOp: TonCocoonExtClientChargeSignedOpCode, + TonTolkTestsCoffeeSwapJettonPayloadOp: TonTolkTestsCoffeeSwapJettonPayloadOpCode, + TonTolkTestsCoffeeCreatePoolJettonPayloadOp: TonTolkTestsCoffeeCreatePoolJettonPayloadOpCode, + TonTolkTestsCoffeeDepositLiquidityJettonPayloadOp: TonTolkTestsCoffeeDepositLiquidityJettonPayloadOpCode, + TonTolkTestsCoffeeNotificationJettonPayloadOp: TonTolkTestsCoffeeNotificationJettonPayloadOpCode, + TonCocoonAddModelTypeOp: TonCocoonAddModelTypeOpCode, + TonCocoonOwnerClientRegisterOp: TonCocoonOwnerClientRegisterOpCode, + TonTolkTestsMoonSwapFailedJettonPayloadOp: TonTolkTestsMoonSwapFailedJettonPayloadOpCode, + TonCocoonChangeOwnerOp: TonCocoonChangeOwnerOpCode, + TonCocoonChangeFeesOp: TonCocoonChangeFeesOpCode, + TonCocoonPayoutOp: TonCocoonPayoutOpCode, + TonStonfiV2StonfiSwapOkJettonPayloadOp: TonStonfiV2StonfiSwapOkJettonPayloadOpCode, + TonTolkTestsStormStakeJettonPayloadOp: TonTolkTestsStormStakeJettonPayloadOpCode, + TonTolkTestsWithdrawPayloadJettonPayloadOp: TonTolkTestsWithdrawPayloadJettonPayloadOpCode, + TonTolkTestsMoonSwapSucceedJettonPayloadOp: TonTolkTestsMoonSwapSucceedJettonPayloadOpCode, + TonTep74ResponseWalletAddressOp: TonTep74ResponseWalletAddressOpCode, + TonCocoonReturnExcessesBackOp: TonCocoonReturnExcessesBackOpCode, + TonTep74ReturnExcessesBackOp: TonTep74ReturnExcessesBackOpCode, + TonTep74AboaLisaOp: TonTep74AboaLisaOpCode, + TonTolkTestsMoonCreateOrderJettonPayloadOp: TonTolkTestsMoonCreateOrderJettonPayloadOpCode, + TonCocoonOwnerClientWithdrawOp: TonCocoonOwnerClientWithdrawOpCode, + TonTolkTestsBidaskDammSwapJettonPayloadOp: TonTolkTestsBidaskDammSwapJettonPayloadOpCode, + TonCocoonAddWorkerTypeOp: TonCocoonAddWorkerTypeOpCode, + TonTolkTestsDedustSwapJettonPayloadOp: TonTolkTestsDedustSwapJettonPayloadOpCode, + TonCocoonExtProxyCloseCompleteRequestSignedOp: TonCocoonExtProxyCloseCompleteRequestSignedOpCode, + TonTolkTestsCoffeeMevProtectFailedSwapJettonPayloadOp: TonTolkTestsCoffeeMevProtectFailedSwapJettonPayloadOpCode, + TonCocoonExtClientGrantRefundSignedOp: TonCocoonExtClientGrantRefundSignedOpCode, + TonCocoonExtClientTopUpOp: TonCocoonExtClientTopUpOpCode, + TonTolkTestsBidaskSwapJettonPayloadOp: TonTolkTestsBidaskSwapJettonPayloadOpCode, + TonCocoonExtWorkerLastPayoutRequestSignedOp: TonCocoonExtWorkerLastPayoutRequestSignedOpCode, + TonTolkTestsDepositPayloadJettonPayloadOp: TonTolkTestsDepositPayloadJettonPayloadOpCode, + TonCocoonOwnerClientRequestRefundOp: TonCocoonOwnerClientRequestRefundOpCode, + TonStonfiV2StonfiProvideLiquidityJettonPayloadOp: TonStonfiV2StonfiProvideLiquidityJettonPayloadOpCode, +} + +func (c ContractInterface) Payloads() map[PayloadOpCode][]func(*Payload, *boc.Cell) error { + switch c { + case TonCocoonClient: + return map[PayloadOpCode][]func(*Payload, *boc.Cell) error{ + TonCocoonClientProxyRequestOpCode: {decodeTonCocoonClientProxyRequestOpPayload}, + TonCocoonOwnerClientIncreaseStakeOpCode: {decodeTonCocoonOwnerClientIncreaseStakeOpPayload}, + TonCocoonOwnerClientChangeSecretHashAndTopUpOpCode: {decodeTonCocoonOwnerClientChangeSecretHashAndTopUpOpPayload}, + TonCocoonOwnerClientChangeSecretHashOpCode: {decodeTonCocoonOwnerClientChangeSecretHashOpPayload}, + TonCocoonExtClientChargeSignedOpCode: {decodeTonCocoonExtClientChargeSignedOpPayload}, + TonCocoonOwnerClientRegisterOpCode: {decodeTonCocoonOwnerClientRegisterOpPayload}, + TonCocoonPayoutOpCode: {decodeTonCocoonPayoutOpPayload}, + TonCocoonReturnExcessesBackOpCode: {decodeTonCocoonReturnExcessesBackOpPayload}, + TonCocoonOwnerClientWithdrawOpCode: {decodeTonCocoonOwnerClientWithdrawOpPayload}, + TonCocoonExtClientGrantRefundSignedOpCode: {decodeTonCocoonExtClientGrantRefundSignedOpPayload}, + TonCocoonExtClientTopUpOpCode: {decodeTonCocoonExtClientTopUpOpPayload}, + TonCocoonOwnerClientRequestRefundOpCode: {decodeTonCocoonOwnerClientRequestRefundOpPayload}, + } + case TonCocoonProxy: + return map[PayloadOpCode][]func(*Payload, *boc.Cell) error{ + TonCocoonTextCmdOpCode: {decodeTonCocoonTextCmdOpPayload}, + TonCocoonWorkerProxyRequestOpCode: {decodeTonCocoonWorkerProxyRequestOpPayload}, + TonCocoonExtProxyCloseRequestSignedOpCode: {decodeTonCocoonExtProxyCloseRequestSignedOpPayload}, + TonCocoonExtProxyPayoutRequestOpCode: {decodeTonCocoonExtProxyPayoutRequestOpPayload}, + TonCocoonExtProxyIncreaseStakeOpCode: {decodeTonCocoonExtProxyIncreaseStakeOpPayload}, + TonCocoonOwnerProxyCloseOpCode: {decodeTonCocoonOwnerProxyCloseOpPayload}, + TonCocoonExtProxyCloseCompleteRequestSignedOpCode: {decodeTonCocoonExtProxyCloseCompleteRequestSignedOpPayload}, + } + case TonCocoonRoot: + return map[PayloadOpCode][]func(*Payload, *boc.Cell) error{ + TonCocoonChangeParamsOpCode: {decodeTonCocoonChangeParamsOpPayload}, + TonCocoonUpgradeCodeOpCode: {decodeTonCocoonUpgradeCodeOpPayload}, + TonCocoonDelProxyTypeOpCode: {decodeTonCocoonDelProxyTypeOpPayload}, + TonCocoonUpgradeFullOpCode: {decodeTonCocoonUpgradeFullOpPayload}, + TonCocoonResetRootOpCode: {decodeTonCocoonResetRootOpPayload}, + TonCocoonUnregisterProxyOpCode: {decodeTonCocoonUnregisterProxyOpPayload}, + TonCocoonAddProxyTypeOpCode: {decodeTonCocoonAddProxyTypeOpPayload}, + TonCocoonDelWorkerTypeOpCode: {decodeTonCocoonDelWorkerTypeOpPayload}, + TonCocoonRegisterProxyOpCode: {decodeTonCocoonRegisterProxyOpPayload}, + TonCocoonDelModelTypeOpCode: {decodeTonCocoonDelModelTypeOpPayload}, + TonCocoonUpdateProxyOpCode: {decodeTonCocoonUpdateProxyOpPayload}, + TonCocoonUpgradeContractsOpCode: {decodeTonCocoonUpgradeContractsOpPayload}, + TonCocoonAddModelTypeOpCode: {decodeTonCocoonAddModelTypeOpPayload}, + TonCocoonChangeOwnerOpCode: {decodeTonCocoonChangeOwnerOpPayload}, + TonCocoonChangeFeesOpCode: {decodeTonCocoonChangeFeesOpPayload}, + TonCocoonAddWorkerTypeOpCode: {decodeTonCocoonAddWorkerTypeOpPayload}, + } + case TonCocoonWallet: + return map[PayloadOpCode][]func(*Payload, *boc.Cell) error{ + TonCocoonTextCommandOpCode: {decodeTonCocoonTextCommandOpPayload}, + TonCocoonOwnerWalletSendMessageOpCode: {decodeTonCocoonOwnerWalletSendMessageOpPayload}, + } + case TonCocoonWorker: + return map[PayloadOpCode][]func(*Payload, *boc.Cell) error{ + TonCocoonOwnerWorkerRegisterOpCode: {decodeTonCocoonOwnerWorkerRegisterOpPayload}, + TonCocoonExtWorkerPayoutRequestSignedOpCode: {decodeTonCocoonExtWorkerPayoutRequestSignedOpPayload}, + TonCocoonExtWorkerLastPayoutRequestSignedOpCode: {decodeTonCocoonExtWorkerLastPayoutRequestSignedOpPayload}, + } + case TonCoffeePool: + return map[PayloadOpCode][]func(*Payload, *boc.Cell) error{ + TonCoffeeCrossDexResendOpCode: {decodeTonCoffeeCrossDexResendOpPayload}, + } + case TonStonfiV1Pool: + return map[PayloadOpCode][]func(*Payload, *boc.Cell) error{ + TonStonfiV1StonfiSwapJettonPayloadOpCode: {decodeTonStonfiV1StonfiSwapJettonPayloadOpPayload}, + TonStonfiV1StonfiSwapOkRefJettonPayloadOpCode: {decodeTonStonfiV1StonfiSwapOkRefJettonPayloadOpPayload}, + } + case TonStonfiV2Pool: + return map[PayloadOpCode][]func(*Payload, *boc.Cell) error{ + TonStonfiV2StonfiProvideLpV2JettonPayloadOpCode: {decodeTonStonfiV2StonfiProvideLpV2JettonPayloadOpPayload}, + TonStonfiV2StonfiSwapV2JettonPayloadOpCode: {decodeTonStonfiV2StonfiSwapV2JettonPayloadOpPayload}, + TonStonfiV2StonfiSwapOkJettonPayloadOpCode: {decodeTonStonfiV2StonfiSwapOkJettonPayloadOpPayload}, + TonStonfiV2StonfiProvideLiquidityJettonPayloadOpCode: {decodeTonStonfiV2StonfiProvideLiquidityJettonPayloadOpPayload}, + } + case TonStonfiV2PoolConstProduct: + return map[PayloadOpCode][]func(*Payload, *boc.Cell) error{ + TonStonfiV2StonfiProvideLpV2JettonPayloadOpCode: {decodeTonStonfiV2StonfiProvideLpV2JettonPayloadOpPayload}, + TonStonfiV2StonfiSwapV2JettonPayloadOpCode: {decodeTonStonfiV2StonfiSwapV2JettonPayloadOpPayload}, + TonStonfiV2StonfiSwapOkJettonPayloadOpCode: {decodeTonStonfiV2StonfiSwapOkJettonPayloadOpPayload}, + TonStonfiV2StonfiProvideLiquidityJettonPayloadOpCode: {decodeTonStonfiV2StonfiProvideLiquidityJettonPayloadOpPayload}, + } + case TonStonfiV2PoolStableSwap: + return map[PayloadOpCode][]func(*Payload, *boc.Cell) error{ + TonStonfiV2StonfiProvideLpV2JettonPayloadOpCode: {decodeTonStonfiV2StonfiProvideLpV2JettonPayloadOpPayload}, + TonStonfiV2StonfiSwapV2JettonPayloadOpCode: {decodeTonStonfiV2StonfiSwapV2JettonPayloadOpPayload}, + TonStonfiV2StonfiSwapOkJettonPayloadOpCode: {decodeTonStonfiV2StonfiSwapOkJettonPayloadOpPayload}, + TonStonfiV2StonfiProvideLiquidityJettonPayloadOpCode: {decodeTonStonfiV2StonfiProvideLiquidityJettonPayloadOpPayload}, + } + case TonStonfiV2PoolWeightedStableSwap: + return map[PayloadOpCode][]func(*Payload, *boc.Cell) error{ + TonStonfiV2StonfiProvideLpV2JettonPayloadOpCode: {decodeTonStonfiV2StonfiProvideLpV2JettonPayloadOpPayload}, + TonStonfiV2StonfiSwapV2JettonPayloadOpCode: {decodeTonStonfiV2StonfiSwapV2JettonPayloadOpPayload}, + TonStonfiV2StonfiSwapOkJettonPayloadOpCode: {decodeTonStonfiV2StonfiSwapOkJettonPayloadOpPayload}, + TonStonfiV2StonfiProvideLiquidityJettonPayloadOpCode: {decodeTonStonfiV2StonfiProvideLiquidityJettonPayloadOpPayload}, + } + case TonTep74JettonMinter: + return map[PayloadOpCode][]func(*Payload, *boc.Cell) error{ + TonTep74ChangeMinterAdminOpCode: {decodeTonTep74ChangeMinterAdminOpPayload}, + TonTep74ChangeMinterContentOpCode: {decodeTonTep74ChangeMinterContentOpPayload}, + TonTep74MintNewJettonsOpCode: {decodeTonTep74MintNewJettonsOpPayload}, + TonTep74InternalTransferStepOpCode: {decodeTonTep74InternalTransferStepOpPayload}, + TonTep74RequestWalletAddressOpCode: {decodeTonTep74RequestWalletAddressOpPayload}, + TonTep74BurnNotificationForMinterOpCode: {decodeTonTep74BurnNotificationForMinterOpPayload}, + TonTep74ResponseWalletAddressOpCode: {decodeTonTep74ResponseWalletAddressOpPayload}, + TonTep74ReturnExcessesBackOpCode: {decodeTonTep74ReturnExcessesBackOpPayload}, + } + case TonTep74JettonWallet: + return map[PayloadOpCode][]func(*Payload, *boc.Cell) error{ + TonTep74AskToTransferOpCode: {decodeTonTep74AskToTransferOpPayload}, + TonTep74AskToBurnOpCode: {decodeTonTep74AskToBurnOpPayload}, + TonTep74TransferNotificationForRecipientOpCode: {decodeTonTep74TransferNotificationForRecipientOpPayload}, + TonTep74AboaLisaOpCode: {decodeTonTep74AboaLisaOpPayload}, + } + case TonTolkTestsPayloads: + return map[PayloadOpCode][]func(*Payload, *boc.Cell) error{ + TonTolkTestsTextCommentJettonPayloadOpCode: {decodeTonTolkTestsTextCommentJettonPayloadOpPayload}, + TonTolkTestsTegroJettonSwapJettonPayloadOpCode: {decodeTonTolkTestsTegroJettonSwapJettonPayloadOpPayload}, + TonTolkTestsCoffeeStakingLockJettonPayloadOpCode: {decodeTonTolkTestsCoffeeStakingLockJettonPayloadOpPayload}, + TonTolkTestsEncryptedTextCommentJettonPayloadOpCode: {decodeTonTolkTestsEncryptedTextCommentJettonPayloadOpPayload}, + TonTolkTestsTegroAddLiquidityJettonPayloadOpCode: {decodeTonTolkTestsTegroAddLiquidityJettonPayloadOpPayload}, + TonTolkTestsBidaskProvideBothJettonPayloadOpCode: {decodeTonTolkTestsBidaskProvideBothJettonPayloadOpPayload}, + TonTolkTestsDedustDepositLiquidityJettonPayloadOpCode: {decodeTonTolkTestsDedustDepositLiquidityJettonPayloadOpPayload}, + TonTolkTestsPoolFundAccountJettonPayloadOpCode: {decodeTonTolkTestsPoolFundAccountJettonPayloadOpPayload}, + TonTolkTestsCoffeeCrossDexResendJettonPayloadOpCode: {decodeTonTolkTestsCoffeeCrossDexResendJettonPayloadOpPayload}, + TonTolkTestsBidaskDammProvideJettonPayloadOpCode: {decodeTonTolkTestsBidaskDammProvideJettonPayloadOpPayload}, + TonTolkTestsBidaskDammProvideOneSideJettonPayloadOpCode: {decodeTonTolkTestsBidaskDammProvideOneSideJettonPayloadOpPayload}, + TonTolkTestsStormDepositJettonJettonPayloadOpCode: {decodeTonTolkTestsStormDepositJettonJettonPayloadOpPayload}, + TonTolkTestsInvoicePayloadJettonPayloadOpCode: {decodeTonTolkTestsInvoicePayloadJettonPayloadOpPayload}, + TonTolkTestsTonkeeperRelayerFeeJettonPayloadOpCode: {decodeTonTolkTestsTonkeeperRelayerFeeJettonPayloadOpPayload}, + TonTolkTestsBidaskSwapV2JettonPayloadOpCode: {decodeTonTolkTestsBidaskSwapV2JettonPayloadOpPayload}, + TonTolkTestsMoonBoostPoolJettonPayloadOpCode: {decodeTonTolkTestsMoonBoostPoolJettonPayloadOpPayload}, + TonTolkTestsBidaskProvideJettonPayloadOpCode: {decodeTonTolkTestsBidaskProvideJettonPayloadOpPayload}, + TonTolkTestsMoonFillOrderJettonPayloadOpCode: {decodeTonTolkTestsMoonFillOrderJettonPayloadOpPayload}, + TonTolkTestsBidaskDammProvideBothJettonPayloadOpCode: {decodeTonTolkTestsBidaskDammProvideBothJettonPayloadOpPayload}, + TonTolkTestsMoonDepositLiquidityJettonPayloadOpCode: {decodeTonTolkTestsMoonDepositLiquidityJettonPayloadOpPayload}, + TonTolkTestsMoonSwapJettonPayloadOpCode: {decodeTonTolkTestsMoonSwapJettonPayloadOpPayload}, + TonTolkTestsCoffeeCrossDexFailureJettonPayloadOpCode: {decodeTonTolkTestsCoffeeCrossDexFailureJettonPayloadOpPayload}, + TonTolkTestsCoffeeSwapJettonPayloadOpCode: {decodeTonTolkTestsCoffeeSwapJettonPayloadOpPayload}, + TonTolkTestsCoffeeCreatePoolJettonPayloadOpCode: {decodeTonTolkTestsCoffeeCreatePoolJettonPayloadOpPayload}, + TonTolkTestsCoffeeDepositLiquidityJettonPayloadOpCode: {decodeTonTolkTestsCoffeeDepositLiquidityJettonPayloadOpPayload}, + TonTolkTestsCoffeeNotificationJettonPayloadOpCode: {decodeTonTolkTestsCoffeeNotificationJettonPayloadOpPayload}, + TonTolkTestsMoonSwapFailedJettonPayloadOpCode: {decodeTonTolkTestsMoonSwapFailedJettonPayloadOpPayload}, + TonTolkTestsStormStakeJettonPayloadOpCode: {decodeTonTolkTestsStormStakeJettonPayloadOpPayload}, + TonTolkTestsWithdrawPayloadJettonPayloadOpCode: {decodeTonTolkTestsWithdrawPayloadJettonPayloadOpPayload}, + TonTolkTestsMoonSwapSucceedJettonPayloadOpCode: {decodeTonTolkTestsMoonSwapSucceedJettonPayloadOpPayload}, + TonTolkTestsMoonCreateOrderJettonPayloadOpCode: {decodeTonTolkTestsMoonCreateOrderJettonPayloadOpPayload}, + TonTolkTestsBidaskDammSwapJettonPayloadOpCode: {decodeTonTolkTestsBidaskDammSwapJettonPayloadOpPayload}, + TonTolkTestsDedustSwapJettonPayloadOpCode: {decodeTonTolkTestsDedustSwapJettonPayloadOpPayload}, + TonTolkTestsCoffeeMevProtectFailedSwapJettonPayloadOpCode: {decodeTonTolkTestsCoffeeMevProtectFailedSwapJettonPayloadOpPayload}, + TonTolkTestsBidaskSwapJettonPayloadOpCode: {decodeTonTolkTestsBidaskSwapJettonPayloadOpPayload}, + TonTolkTestsDepositPayloadJettonPayloadOpCode: {decodeTonTolkTestsDepositPayloadJettonPayloadOpPayload}, + } + default: + return nil + } +} + +var funcPayloadDecodersMapping = map[PayloadOpCode][]func(*Payload, *boc.Cell) error{ + 0: { + decodeTonCocoonTextCmdOpPayload, + decodeTonCocoonTextCommandOpPayload, + decodeTonTolkTestsTextCommentJettonPayloadOpPayload, + }, + TonTep74ChangeMinterAdminOpCode: {decodeTonTep74ChangeMinterAdminOpPayload}, + TonTep74ChangeMinterContentOpCode: {decodeTonTep74ChangeMinterContentOpPayload}, + TonTep74MintNewJettonsOpCode: {decodeTonTep74MintNewJettonsOpPayload}, + TonTolkTestsTegroJettonSwapJettonPayloadOpCode: {decodeTonTolkTestsTegroJettonSwapJettonPayloadOpPayload}, + TonCocoonChangeParamsOpCode: {decodeTonCocoonChangeParamsOpPayload}, + TonTolkTestsCoffeeStakingLockJettonPayloadOpCode: {decodeTonTolkTestsCoffeeStakingLockJettonPayloadOpPayload}, + TonTep74AskToTransferOpCode: {decodeTonTep74AskToTransferOpPayload}, + TonCocoonUpgradeCodeOpCode: {decodeTonCocoonUpgradeCodeOpPayload}, + TonTep74InternalTransferStepOpCode: {decodeTonTep74InternalTransferStepOpPayload}, + TonCoffeeCrossDexResendOpCode: {decodeTonCoffeeCrossDexResendOpPayload}, + TonTolkTestsEncryptedTextCommentJettonPayloadOpCode: {decodeTonTolkTestsEncryptedTextCommentJettonPayloadOpPayload}, + TonStonfiV1StonfiSwapJettonPayloadOpCode: {decodeTonStonfiV1StonfiSwapJettonPayloadOpPayload}, + TonCocoonOwnerWorkerRegisterOpCode: {decodeTonCocoonOwnerWorkerRegisterOpPayload}, + TonTolkTestsTegroAddLiquidityJettonPayloadOpCode: {decodeTonTolkTestsTegroAddLiquidityJettonPayloadOpPayload}, + TonTep74RequestWalletAddressOpCode: {decodeTonTep74RequestWalletAddressOpPayload}, + TonStonfiV2StonfiProvideLpV2JettonPayloadOpCode: {decodeTonStonfiV2StonfiProvideLpV2JettonPayloadOpPayload}, + TonCocoonDelProxyTypeOpCode: {decodeTonCocoonDelProxyTypeOpPayload}, + TonTolkTestsBidaskProvideBothJettonPayloadOpCode: {decodeTonTolkTestsBidaskProvideBothJettonPayloadOpPayload}, + TonTolkTestsDedustDepositLiquidityJettonPayloadOpCode: {decodeTonTolkTestsDedustDepositLiquidityJettonPayloadOpPayload}, + TonTolkTestsPoolFundAccountJettonPayloadOpCode: {decodeTonTolkTestsPoolFundAccountJettonPayloadOpPayload}, + TonStonfiV1StonfiSwapOkRefJettonPayloadOpCode: {decodeTonStonfiV1StonfiSwapOkRefJettonPayloadOpPayload}, + TonCocoonWorkerProxyRequestOpCode: {decodeTonCocoonWorkerProxyRequestOpPayload}, + TonTolkTestsCoffeeCrossDexResendJettonPayloadOpCode: {decodeTonTolkTestsCoffeeCrossDexResendJettonPayloadOpPayload}, + TonCocoonUpgradeFullOpCode: {decodeTonCocoonUpgradeFullOpPayload}, + TonCocoonResetRootOpCode: {decodeTonCocoonResetRootOpPayload}, + TonTep74AskToBurnOpCode: {decodeTonTep74AskToBurnOpPayload}, + TonCocoonExtProxyCloseRequestSignedOpCode: {decodeTonCocoonExtProxyCloseRequestSignedOpPayload}, + TonTolkTestsBidaskDammProvideJettonPayloadOpCode: {decodeTonTolkTestsBidaskDammProvideJettonPayloadOpPayload}, + TonCocoonClientProxyRequestOpCode: {decodeTonCocoonClientProxyRequestOpPayload}, + TonStonfiV2StonfiSwapV2JettonPayloadOpCode: {decodeTonStonfiV2StonfiSwapV2JettonPayloadOpPayload}, + TonCocoonOwnerClientIncreaseStakeOpCode: {decodeTonCocoonOwnerClientIncreaseStakeOpPayload}, + TonCocoonUnregisterProxyOpCode: {decodeTonCocoonUnregisterProxyOpPayload}, + TonCocoonAddProxyTypeOpCode: {decodeTonCocoonAddProxyTypeOpPayload}, + TonTolkTestsBidaskDammProvideOneSideJettonPayloadOpCode: {decodeTonTolkTestsBidaskDammProvideOneSideJettonPayloadOpPayload}, + TonTep74TransferNotificationForRecipientOpCode: {decodeTonTep74TransferNotificationForRecipientOpPayload}, + TonCocoonExtProxyPayoutRequestOpCode: {decodeTonCocoonExtProxyPayoutRequestOpPayload}, + TonTolkTestsStormDepositJettonJettonPayloadOpCode: {decodeTonTolkTestsStormDepositJettonJettonPayloadOpPayload}, + TonTolkTestsInvoicePayloadJettonPayloadOpCode: {decodeTonTolkTestsInvoicePayloadJettonPayloadOpPayload}, + TonTep74BurnNotificationForMinterOpCode: {decodeTonTep74BurnNotificationForMinterOpPayload}, + TonCocoonOwnerClientChangeSecretHashAndTopUpOpCode: {decodeTonCocoonOwnerClientChangeSecretHashAndTopUpOpPayload}, + TonTolkTestsTonkeeperRelayerFeeJettonPayloadOpCode: {decodeTonTolkTestsTonkeeperRelayerFeeJettonPayloadOpPayload}, + TonTolkTestsBidaskSwapV2JettonPayloadOpCode: {decodeTonTolkTestsBidaskSwapV2JettonPayloadOpPayload}, + TonCocoonDelWorkerTypeOpCode: {decodeTonCocoonDelWorkerTypeOpPayload}, + TonCocoonRegisterProxyOpCode: {decodeTonCocoonRegisterProxyOpPayload}, + TonCocoonDelModelTypeOpCode: {decodeTonCocoonDelModelTypeOpPayload}, + TonTolkTestsMoonBoostPoolJettonPayloadOpCode: {decodeTonTolkTestsMoonBoostPoolJettonPayloadOpPayload}, + TonTolkTestsBidaskProvideJettonPayloadOpCode: {decodeTonTolkTestsBidaskProvideJettonPayloadOpPayload}, + TonCocoonExtProxyIncreaseStakeOpCode: {decodeTonCocoonExtProxyIncreaseStakeOpPayload}, + TonTolkTestsMoonFillOrderJettonPayloadOpCode: {decodeTonTolkTestsMoonFillOrderJettonPayloadOpPayload}, + TonCocoonOwnerWalletSendMessageOpCode: {decodeTonCocoonOwnerWalletSendMessageOpPayload}, + TonCocoonUpdateProxyOpCode: {decodeTonCocoonUpdateProxyOpPayload}, + TonCocoonExtWorkerPayoutRequestSignedOpCode: {decodeTonCocoonExtWorkerPayoutRequestSignedOpPayload}, + TonCocoonUpgradeContractsOpCode: {decodeTonCocoonUpgradeContractsOpPayload}, + TonTolkTestsBidaskDammProvideBothJettonPayloadOpCode: {decodeTonTolkTestsBidaskDammProvideBothJettonPayloadOpPayload}, + TonCocoonOwnerClientChangeSecretHashOpCode: {decodeTonCocoonOwnerClientChangeSecretHashOpPayload}, + TonTolkTestsMoonDepositLiquidityJettonPayloadOpCode: {decodeTonTolkTestsMoonDepositLiquidityJettonPayloadOpPayload}, + TonTolkTestsMoonSwapJettonPayloadOpCode: {decodeTonTolkTestsMoonSwapJettonPayloadOpPayload}, + TonCocoonOwnerProxyCloseOpCode: {decodeTonCocoonOwnerProxyCloseOpPayload}, + TonTolkTestsCoffeeCrossDexFailureJettonPayloadOpCode: {decodeTonTolkTestsCoffeeCrossDexFailureJettonPayloadOpPayload}, + TonCocoonExtClientChargeSignedOpCode: {decodeTonCocoonExtClientChargeSignedOpPayload}, + TonTolkTestsCoffeeSwapJettonPayloadOpCode: {decodeTonTolkTestsCoffeeSwapJettonPayloadOpPayload}, + TonTolkTestsCoffeeCreatePoolJettonPayloadOpCode: {decodeTonTolkTestsCoffeeCreatePoolJettonPayloadOpPayload}, + TonTolkTestsCoffeeDepositLiquidityJettonPayloadOpCode: {decodeTonTolkTestsCoffeeDepositLiquidityJettonPayloadOpPayload}, + TonTolkTestsCoffeeNotificationJettonPayloadOpCode: {decodeTonTolkTestsCoffeeNotificationJettonPayloadOpPayload}, + TonCocoonAddModelTypeOpCode: {decodeTonCocoonAddModelTypeOpPayload}, + TonCocoonOwnerClientRegisterOpCode: {decodeTonCocoonOwnerClientRegisterOpPayload}, + TonTolkTestsMoonSwapFailedJettonPayloadOpCode: {decodeTonTolkTestsMoonSwapFailedJettonPayloadOpPayload}, + TonCocoonChangeOwnerOpCode: {decodeTonCocoonChangeOwnerOpPayload}, + TonCocoonChangeFeesOpCode: {decodeTonCocoonChangeFeesOpPayload}, + TonCocoonPayoutOpCode: {decodeTonCocoonPayoutOpPayload}, + TonStonfiV2StonfiSwapOkJettonPayloadOpCode: {decodeTonStonfiV2StonfiSwapOkJettonPayloadOpPayload}, + TonTolkTestsStormStakeJettonPayloadOpCode: {decodeTonTolkTestsStormStakeJettonPayloadOpPayload}, + TonTolkTestsWithdrawPayloadJettonPayloadOpCode: {decodeTonTolkTestsWithdrawPayloadJettonPayloadOpPayload}, + TonTolkTestsMoonSwapSucceedJettonPayloadOpCode: {decodeTonTolkTestsMoonSwapSucceedJettonPayloadOpPayload}, + TonTep74ResponseWalletAddressOpCode: {decodeTonTep74ResponseWalletAddressOpPayload}, + 3576854235: { + decodeTonCocoonReturnExcessesBackOpPayload, + decodeTonTep74ReturnExcessesBackOpPayload, + decodeTonTep74AboaLisaOpPayload, + }, + TonTolkTestsMoonCreateOrderJettonPayloadOpCode: {decodeTonTolkTestsMoonCreateOrderJettonPayloadOpPayload}, + TonCocoonOwnerClientWithdrawOpCode: {decodeTonCocoonOwnerClientWithdrawOpPayload}, + TonTolkTestsBidaskDammSwapJettonPayloadOpCode: {decodeTonTolkTestsBidaskDammSwapJettonPayloadOpPayload}, + TonCocoonAddWorkerTypeOpCode: {decodeTonCocoonAddWorkerTypeOpPayload}, + TonTolkTestsDedustSwapJettonPayloadOpCode: {decodeTonTolkTestsDedustSwapJettonPayloadOpPayload}, + TonCocoonExtProxyCloseCompleteRequestSignedOpCode: {decodeTonCocoonExtProxyCloseCompleteRequestSignedOpPayload}, + TonTolkTestsCoffeeMevProtectFailedSwapJettonPayloadOpCode: {decodeTonTolkTestsCoffeeMevProtectFailedSwapJettonPayloadOpPayload}, + TonCocoonExtClientGrantRefundSignedOpCode: {decodeTonCocoonExtClientGrantRefundSignedOpPayload}, + TonCocoonExtClientTopUpOpCode: {decodeTonCocoonExtClientTopUpOpPayload}, + TonTolkTestsBidaskSwapJettonPayloadOpCode: {decodeTonTolkTestsBidaskSwapJettonPayloadOpPayload}, + TonCocoonExtWorkerLastPayoutRequestSignedOpCode: {decodeTonCocoonExtWorkerLastPayoutRequestSignedOpPayload}, + TonTolkTestsDepositPayloadJettonPayloadOpCode: {decodeTonTolkTestsDepositPayloadJettonPayloadOpPayload}, + TonCocoonOwnerClientRequestRefundOpCode: {decodeTonCocoonOwnerClientRequestRefundOpPayload}, + TonStonfiV2StonfiProvideLiquidityJettonPayloadOpCode: {decodeTonStonfiV2StonfiProvideLiquidityJettonPayloadOpPayload}, +} + +type TonCocoonTextCmdPayloadBody = TonCocoonTextCmd + +type TonCocoonTextCommandPayloadBody = TonCocoonTextCommand + +type TonTolkTestsTextComment struct { + Text tlb.Any +} + +type TonTep74ChangeMinterAdminPayloadBody = TonTep74ChangeMinterAdmin + +type TonTep74ChangeMinterContentPayloadBody = TonTep74ChangeMinterContent + +type TonTep74MintNewJettonsPayloadBody = TonTep74MintNewJettons + +type TonTolkTestsTegroJettonSwap struct { + Extract bool + MaxIn tlb.VarUInteger16 + MinOut tlb.VarUInteger16 + Destination tlb.MsgAddress + ErrorDestination tlb.MsgAddress + Payload tlb.Any `tlb:"^"` +} + +type TonCocoonChangeParamsPayloadBody = TonCocoonChangeParams + +type TonTolkTestsCoffeeStakingLock struct { + PeriodID uint32 +} + +type TonTep74AskToTransferPayloadBody = TonTep74AskToTransfer + +type TonCocoonUpgradeCodePayloadBody = TonCocoonUpgradeCode + +type TonTep74InternalTransferStepPayloadBody = TonTep74InternalTransferStep + +type TonCoffeeCrossDexResendPayloadBody = TonCoffeeCrossDexResend + +type TonTolkTestsEncryptedTextComment struct { + CipherText tlb.Any +} + +type TonStonfiV1StonfiSwap struct { + TokenWallet tlb.MsgAddress + MinOut tlb.VarUInteger16 + ToAddress tlb.MsgAddress + ReferralAddress tlb.MsgAddress +} + +type TonCocoonOwnerWorkerRegisterPayloadBody = TonCocoonOwnerWorkerRegister + +type TonTolkTestsTegroAddLiquidity struct { + AmountA tlb.VarUInteger16 + AmountB tlb.VarUInteger16 +} + +type TonTep74RequestWalletAddressPayloadBody = TonTep74RequestWalletAddress + +type TonStonfiV2StonfiProvideLpV2 struct { + TokenWallet1 tlb.MsgAddress + RefundAddress tlb.MsgAddress + ExcessesAddress tlb.MsgAddress + TxDeadline uint64 + CrossProvideLpBody TonStonfiV2CrossProvideLpBody `tlb:"^"` +} + +type TonCocoonDelProxyTypePayloadBody = TonCocoonDelProxyType + +type TonTolkTestsBidaskProvideBoth struct { + TonAmount tlb.VarUInteger16 + DepositType tlb.Uint4 + LiquidityDict tlb.HashmapE[tlb.Uint32, int32] + RejectPayload *tlb.Any `tlb:"maybe^"` + ForwardPayload *tlb.Any `tlb:"maybe^"` +} + +type TonTolkTestsDedustDepositLiquidity struct { + PoolType TonTolkTestsDedustPoolType + Asset0 TonTolkTestsDedustAsset + Asset1 TonTolkTestsDedustAsset + Asset0TargetBalance tlb.VarUInteger16 + Asset1TargetBalance tlb.VarUInteger16 + FulfillPayload *tlb.Any `tlb:"maybe^"` + RejectPayload *tlb.Any `tlb:"maybe^"` +} + +type TonTolkTestsPoolFundAccount struct { + JettonTarget tlb.MsgAddress + Enough0 tlb.VarUInteger16 + Enough1 tlb.VarUInteger16 + Liquidity tlb.Uint128 + TickLower tlb.Int24 + TickUpper tlb.Int24 +} + +type TonStonfiV1StonfiSwapOkRef struct { +} + +type TonCocoonWorkerProxyRequestPayloadBody = TonCocoonWorkerProxyRequest + +type TonTolkTestsCoffeeCrossDexResend struct { + Next *tlb.Any `tlb:"maybe^"` +} + +type TonCocoonUpgradeFullPayloadBody = TonCocoonUpgradeFull + +type TonCocoonResetRootPayloadBody = TonCocoonResetRoot + +type TonTep74AskToBurnPayloadBody = TonTep74AskToBurn + +type TonCocoonExtProxyCloseRequestSignedPayloadBody = TonCocoonExtProxyCloseRequestSigned + +type TonTolkTestsBidaskDammProvide struct { + Receiver tlb.MsgAddress + LockLiquidity bool + RejectPayload *tlb.Any `tlb:"maybe^"` + ForwardPayload *tlb.Any `tlb:"maybe^"` +} + +type TonCocoonClientProxyRequestPayloadBody = TonCocoonClientProxyRequest + +type TonStonfiV2StonfiSwapV2 struct { + TokenWallet1 tlb.MsgAddress + RefundAddress tlb.MsgAddress + ExcessesAddress tlb.MsgAddress + TxDeadline uint64 + CrossSwapBody TonStonfiV2CrossSwapBody `tlb:"^"` +} + +type TonCocoonOwnerClientIncreaseStakePayloadBody = TonCocoonOwnerClientIncreaseStake + +type TonCocoonUnregisterProxyPayloadBody = TonCocoonUnregisterProxy + +type TonCocoonAddProxyTypePayloadBody = TonCocoonAddProxyType + +type TonTolkTestsBidaskDammProvideOneSide struct { + Receiver tlb.MsgAddress + LockLiquidity bool + RejectPayload *tlb.Any `tlb:"maybe^"` + ForwardPayload *tlb.Any `tlb:"maybe^"` +} + +type TonTep74TransferNotificationForRecipientPayloadBody = TonTep74TransferNotificationForRecipient + +type TonCocoonExtProxyPayoutRequestPayloadBody = TonCocoonExtProxyPayoutRequest + +type TonTolkTestsStormDepositJetton struct { + QueryId uint64 + ReceiverAddress tlb.MsgAddress + Init bool + KeyInit TonTolkTestsInitializationRequest +} + +type TonTolkTestsInvoicePayload struct { + Id tlb.Bits128 + Url TonTolkTestsInvoiceUrl +} + +type TonTep74BurnNotificationForMinterPayloadBody = TonTep74BurnNotificationForMinter + +type TonCocoonOwnerClientChangeSecretHashAndTopUpPayloadBody = TonCocoonOwnerClientChangeSecretHashAndTopUp + +type TonTolkTestsTonkeeperRelayerFee struct { +} + +type TonTolkTestsBidaskSwapV2 struct { + ToAddress tlb.MsgAddress + Slippage tlb.Either[tlb.VarUInteger16, tlb.Uint256] + ExactOut tlb.VarUInteger16 + AdditionalData *TonTolkTestsAdditionalData `tlb:"maybe^"` + RejectPayload *tlb.Any `tlb:"maybe^"` + ForwardPayload *tlb.Any `tlb:"maybe^"` +} + +type TonCocoonDelWorkerTypePayloadBody = TonCocoonDelWorkerType + +type TonCocoonRegisterProxyPayloadBody = TonCocoonRegisterProxy + +type TonCocoonDelModelTypePayloadBody = TonCocoonDelModelType + +type TonTolkTestsMoonBoostPool struct { +} + +type TonTolkTestsBidaskProvide struct { + DepositType tlb.Uint4 + LiquidityDict tlb.HashmapE[tlb.Uint32, int32] + RejectPayload *tlb.Any `tlb:"maybe^"` + ForwardPayload *tlb.Any `tlb:"maybe^"` +} + +type TonCocoonExtProxyIncreaseStakePayloadBody = TonCocoonExtProxyIncreaseStake + +type TonTolkTestsMoonFillOrder struct { + Recipient tlb.MsgAddress + RecipientPayload *tlb.Any `tlb:"maybe^"` + RejectAddress tlb.MsgAddress +} + +type TonCocoonOwnerWalletSendMessagePayloadBody = TonCocoonOwnerWalletSendMessage + +type TonCocoonUpdateProxyPayloadBody = TonCocoonUpdateProxy + +type TonCocoonExtWorkerPayoutRequestSignedPayloadBody = TonCocoonExtWorkerPayoutRequestSigned + +type TonCocoonUpgradeContractsPayloadBody = TonCocoonUpgradeContracts + +type TonTolkTestsBidaskDammProvideBoth struct { + NativeAmount tlb.VarUInteger16 + Reciever tlb.MsgAddress + LockLiquidity bool + RejectPayload *tlb.Any `tlb:"maybe^"` + ForwardPayload *tlb.Any `tlb:"maybe^"` +} + +type TonCocoonOwnerClientChangeSecretHashPayloadBody = TonCocoonOwnerClientChangeSecretHash + +type TonTolkTestsMoonDepositLiquidity struct { + MinLpOut tlb.VarUInteger16 +} + +type TonTolkTestsMoonSwap struct { + MoonSwap TonTolkTestsMoonSwapParams +} + +type TonCocoonOwnerProxyClosePayloadBody = TonCocoonOwnerProxyClose + +type TonTolkTestsCoffeeCrossDexFailure struct { + QueryId uint64 + Recipient tlb.MsgAddress +} + +type TonCocoonExtClientChargeSignedPayloadBody = TonCocoonExtClientChargeSigned + +type TonTolkTestsCoffeeSwap struct { + Step TonTolkTestsCoffeeSwapStepParams + Params TonTolkTestsCoffeeSwapParams `tlb:"^"` +} + +type TonTolkTestsCoffeeCreatePool struct { + Params TonTolkTestsCoffeePoolParams + CreationParams TonTolkTestsCoffeePoolCreationParams +} + +type TonTolkTestsCoffeeDepositLiquidity struct { + Params TonTolkTestsCoffeeDepositLiquidityParams +} + +type TonTolkTestsCoffeeNotification struct { + QueryId uint64 + Body tlb.Any `tlb:"^"` +} + +type TonCocoonAddModelTypePayloadBody = TonCocoonAddModelType + +type TonCocoonOwnerClientRegisterPayloadBody = TonCocoonOwnerClientRegister + +type TonTolkTestsMoonSwapFailed struct { +} + +type TonCocoonChangeOwnerPayloadBody = TonCocoonChangeOwner + +type TonCocoonChangeFeesPayloadBody = TonCocoonChangeFees + +type TonCocoonPayoutPayloadBody = TonCocoonPayout + +type TonStonfiV2StonfiSwapOk struct { +} + +type TonTolkTestsStormStake struct { +} + +type TonTolkTestsWithdrawPayload struct { + AssetAddress tlb.MsgAddress + OracleParams *tlb.Any `tlb:"maybe^"` + ForwardTonAmount tlb.VarUInteger16 + ForwardPayload *tlb.Any `tlb:"maybe^"` +} + +type TonTolkTestsMoonSwapSucceed struct { +} + +type TonTep74ResponseWalletAddressPayloadBody = TonTep74ResponseWalletAddress + +type TonCocoonReturnExcessesBackPayloadBody = TonCocoonReturnExcessesBack + +type TonTep74ReturnExcessesBackPayloadBody = TonTep74ReturnExcessesBack + +type TonTep74AboaLisaPayloadBody = TonTep74AboaLisa + +type TonTolkTestsMoonCreateOrder struct { + Asset1 tlb.MsgAddress + Asset2 tlb.MsgAddress + OrderData TonTolkTestsMoonOrderParams +} + +type TonCocoonOwnerClientWithdrawPayloadBody = TonCocoonOwnerClientWithdraw + +type TonTolkTestsBidaskDammSwap struct { + ToAddress tlb.MsgAddress + Slippage tlb.VarUInteger16 + FromAddress tlb.MsgAddress + ExactOut tlb.VarUInteger16 + AdditionalData *tlb.Any `tlb:"maybe^"` + RejectPayload *tlb.Any `tlb:"maybe^"` + ForwardPayload *tlb.Any `tlb:"maybe^"` +} + +type TonCocoonAddWorkerTypePayloadBody = TonCocoonAddWorkerType + +type TonTolkTestsDedustSwap struct { + Step TonTolkTestsDedustSwapStep + SwapParams TonTolkTestsDedustSwapParams `tlb:"^"` +} + +type TonCocoonExtProxyCloseCompleteRequestSignedPayloadBody = TonCocoonExtProxyCloseCompleteRequestSigned + +type TonTolkTestsCoffeeMevProtectFailedSwap struct { + QueryId uint64 + Recipient tlb.MsgAddress +} + +type TonCocoonExtClientGrantRefundSignedPayloadBody = TonCocoonExtClientGrantRefundSigned + +type TonCocoonExtClientTopUpPayloadBody = TonCocoonExtClientTopUp + +type TonTolkTestsBidaskSwap struct { + ToAddress tlb.MsgAddress + Slippage tlb.Either[tlb.VarUInteger16, tlb.Uint256] + ExactOut tlb.VarUInteger16 + RefAddress tlb.MsgAddress + AdditionalData *tlb.Any `tlb:"maybe^"` + RejectPayload *tlb.Any `tlb:"maybe^"` + ForwardPayload *tlb.Any `tlb:"maybe^"` +} + +type TonCocoonExtWorkerLastPayoutRequestSignedPayloadBody = TonCocoonExtWorkerLastPayoutRequestSigned + +type TonTolkTestsDepositPayload struct { + OracleParams *tlb.Any `tlb:"maybe^"` + ForwardTonAmount tlb.VarUInteger16 + ForwardPayload *tlb.Any `tlb:"maybe^"` +} + +type TonCocoonOwnerClientRequestRefundPayloadBody = TonCocoonOwnerClientRequestRefund + +type TonStonfiV2StonfiProvideLiquidity struct { + TokenWallet tlb.MsgAddress + MinLpOut tlb.VarUInteger16 +} diff --git a/abi-tolk/payload_test.go b/abi-tolk/payload_test.go new file mode 100644 index 00000000..d3099cca --- /dev/null +++ b/abi-tolk/payload_test.go @@ -0,0 +1,212 @@ +package abitolk + +import ( + "encoding/json" + "fmt" + "testing" + + "github.com/tonkeeper/tongo/boc" + "github.com/tonkeeper/tongo/tlb" +) + +func TestDecodeAndEncodeStonfiSwapPayload(t *testing.T) { + data := "b5ee9c720101030100fd0001b1178d4519ca4d2d8911062e4253087a4ad408017ff5ba4e14e70a63b4f627751f880704d84b0c2e7f3dbd3862df56a778b3590d0018cafe48d8e51fc3a324d17dfd74f55cc5ad294a1420bf80e39620cb7212f09c905cbead030101e16664de2a800c597b2db76f2c8617ac5f9802ab6d934b9d61ef13b9ab84ba05cae018fdd4a550023cb6103b0174463e61166815ec7f2ad4d715ee4dc488af85599ffba4cb3abd4e004796c207602e88c7cc22cd02bd8fe55a9ae2bdc9b89115f0ab33ff74996757a9800000007fffffffc0020055533ba4e6ad58011e5b081d80ba231f308b340af63f956a6b8af726e24457c2accffdd2659d5ea600000010" + boc1, _ := boc.DeserializeBocHex(data) + + var x InMsgBody + if err := tlb.Unmarshal(boc1[0], &x); err != nil { + t.Fatalf("Unable to unmarshal: %v", err) + } + + boc2 := boc.NewCell() + if err := tlb.Marshal(boc2, x); err != nil { + t.Fatalf("Unable to marshal: %v", err) + } + + b, _ := boc2.ToBoc() + res := fmt.Sprintf("%x", b) + if res != data { + t.Fatalf("got different result") + } +} + +func TestDecodeAndEncodeDedustSwapPayloadWithContractIfaces(t *testing.T) { + data := "b5ee9c72010206010001d40001ae0f8a7ea5a9d57b6fda293e0932191c080031551c5ddaa2e8fb5c06780f3727107b28395b1eca8b3e5dd39ae8e96d71dabb0029af18b3e5aaa14e6fd77d47290de6f1a8bd6078d4d6eb3eca9f0dc1f8dd96b0c82160ec01010155e3a0d4828007cbff951bbf9e6d86d93fe8de62ac5556a37322908b5ad84d97bcc93ab14ab1044a0ec2a44002024b00000000801384bfb142ca3fb8918eeee76e56e38a22c9b94832508c035fcfe938a41dac3ba7030401d11a3c2fc38014d78c59f2d550a737ebbea39486f378d45eb03c6a6b759f654f86e0fc6ecb5870029af18b3e5aaa14e6fd77d47290de6f1a8bd6078d4d6eb3eca9f0dc1f8dd96b0e00535e3167cb55429cdfaefa8e521bcde3517ac0f1a9add67d953e1b83f1bb2d61c005008d3c37d7e98014d78c59f2d550a737ebbea39486f378d45eb03c6a6b759f654f86e0fc6ecb5870029af18b3e5aaa14e6fd77d47290de6f1a8bd6078d4d6eb3eca9f0dc1f8dd96b0e00d58012bd3391b8d4870a4dbe92c326dfea2413e60f45186f8d8f06219c28156f156ca001500000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000040" + boc1, _ := boc.DeserializeBocHex(data) + + decoder := tlb.NewDecoder() + decoder.WithContractInterfaces([]tlb.ContractInterface{tlb.ContractInterface(TonTep74JettonWallet), tlb.ContractInterface(TonDedustPool)}) + + var x InMsgBody + if err := decoder.Unmarshal(boc1[0], &x); err != nil { + t.Fatalf("Unable to unmarshal: %v", err) + } + + boc2 := boc.NewCell() + if err := tlb.Marshal(boc2, x); err != nil { + t.Fatalf("Unable to marshal: %v", err) + } + + b, _ := boc2.ToBoc() + res := fmt.Sprintf("%x", b) + if res != data { + t.Fatalf("got different result") + } +} + +func TestDecodeAndEncodeStonfiSwapPayloadWithContractIfaces(t *testing.T) { + data := "b5ee9c720101030100fd0001b1178d4519ca4d2d8911062e4253087a4ad408017ff5ba4e14e70a63b4f627751f880704d84b0c2e7f3dbd3862df56a778b3590d0018cafe48d8e51fc3a324d17dfd74f55cc5ad294a1420bf80e39620cb7212f09c905cbead030101e16664de2a800c597b2db76f2c8617ac5f9802ab6d934b9d61ef13b9ab84ba05cae018fdd4a550023cb6103b0174463e61166815ec7f2ad4d715ee4dc488af85599ffba4cb3abd4e004796c207602e88c7cc22cd02bd8fe55a9ae2bdc9b89115f0ab33ff74996757a9800000007fffffffc0020055533ba4e6ad58011e5b081d80ba231f308b340af63f956a6b8af726e24457c2accffdd2659d5ea600000010" + boc1, _ := boc.DeserializeBocHex(data) + + decoder := tlb.NewDecoder() + decoder.WithContractInterfaces([]tlb.ContractInterface{tlb.ContractInterface(TonTep74JettonWallet), tlb.ContractInterface(TonStonfiV2PoolWeightedStableSwap)}) + + var x InMsgBody + if err := decoder.Unmarshal(boc1[0], &x); err != nil { + t.Fatalf("Unable to unmarshal: %v", err) + } + + boc2 := boc.NewCell() + if err := tlb.Marshal(boc2, x); err != nil { + t.Fatalf("Unable to marshal: %v", err) + } + + b, _ := boc2.ToBoc() + res := fmt.Sprintf("%x", b) + if res != data { + t.Fatalf("got different result") + } +} + +func TestDecodeAndEncodeJsonDedustSwapPayloadWithContractIfaces(t *testing.T) { + data := "b5ee9c72010206010001d40001ae0f8a7ea5a9d57b6fda293e0932191c080031551c5ddaa2e8fb5c06780f3727107b28395b1eca8b3e5dd39ae8e96d71dabb0029af18b3e5aaa14e6fd77d47290de6f1a8bd6078d4d6eb3eca9f0dc1f8dd96b0c82160ec01010155e3a0d4828007cbff951bbf9e6d86d93fe8de62ac5556a37322908b5ad84d97bcc93ab14ab1044a0ec2a44002024b00000000801384bfb142ca3fb8918eeee76e56e38a22c9b94832508c035fcfe938a41dac3ba7030401d11a3c2fc38014d78c59f2d550a737ebbea39486f378d45eb03c6a6b759f654f86e0fc6ecb5870029af18b3e5aaa14e6fd77d47290de6f1a8bd6078d4d6eb3eca9f0dc1f8dd96b0e00535e3167cb55429cdfaefa8e521bcde3517ac0f1a9add67d953e1b83f1bb2d61c005008d3c37d7e98014d78c59f2d550a737ebbea39486f378d45eb03c6a6b759f654f86e0fc6ecb5870029af18b3e5aaa14e6fd77d47290de6f1a8bd6078d4d6eb3eca9f0dc1f8dd96b0e00d58012bd3391b8d4870a4dbe92c326dfea2413e60f45186f8d8f06219c28156f156ca001500000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000040" + boc1, _ := boc.DeserializeBocHex(data) + + decoder := tlb.NewDecoder() + decoder.WithContractInterfaces([]tlb.ContractInterface{tlb.ContractInterface(TonTep74JettonWallet), tlb.ContractInterface(TonDedustPool)}) + + var x InMsgBody + if err := decoder.Unmarshal(boc1[0], &x); err != nil { + t.Fatalf("Unable to unmarshal tlb: %v", err) + } + + val, err := json.Marshal(x) + if err != nil { + t.Fatalf("Unable to marshal json: %v", err) + } + + var x2 InMsgBody + if err = json.Unmarshal(val, &x2); err != nil { + t.Fatalf("Unable to unmarshal json: %v", err) + } + + boc2 := boc.NewCell() + if err := tlb.Marshal(boc2, x2); err != nil { + t.Fatalf("Unable to marshal tlb: %v", err) + } + + b, _ := boc2.ToBoc() + res := fmt.Sprintf("%x", b) + if res != data { + t.Fatalf("got different result") + } +} + +func TestDecodeAndEncodeJsonStonfiSwapPayloadWithContractIfaces(t *testing.T) { + data := "b5ee9c720101030100fd0001b1178d4519ca4d2d8911062e4253087a4ad408017ff5ba4e14e70a63b4f627751f880704d84b0c2e7f3dbd3862df56a778b3590d0018cafe48d8e51fc3a324d17dfd74f55cc5ad294a1420bf80e39620cb7212f09c905cbead030101e16664de2a800c597b2db76f2c8617ac5f9802ab6d934b9d61ef13b9ab84ba05cae018fdd4a550023cb6103b0174463e61166815ec7f2ad4d715ee4dc488af85599ffba4cb3abd4e004796c207602e88c7cc22cd02bd8fe55a9ae2bdc9b89115f0ab33ff74996757a9800000007fffffffc0020055533ba4e6ad58011e5b081d80ba231f308b340af63f956a6b8af726e24457c2accffdd2659d5ea600000010" + boc1, _ := boc.DeserializeBocHex(data) + + decoder := tlb.NewDecoder() + decoder.WithContractInterfaces([]tlb.ContractInterface{tlb.ContractInterface(TonTep74JettonWallet), tlb.ContractInterface(TonStonfiV2PoolWeightedStableSwap)}) + + var x InMsgBody + if err := decoder.Unmarshal(boc1[0], &x); err != nil { + t.Fatalf("Unable to unmarshal: %v", err) + } + + val, err := json.Marshal(x) + if err != nil { + t.Fatalf("Unable to marshal: %v", err) + } + + var x2 InMsgBody + if err = json.Unmarshal(val, &x2); err != nil { + t.Fatalf("Unable to unmarshal json: %v", err) + } + + boc2 := boc.NewCell() + if err := tlb.Marshal(boc2, x2); err != nil { + t.Fatalf("Unable to marshal tlb: %v", err) + } + + b, _ := boc2.ToBoc() + res := fmt.Sprintf("%x", b) + if res != data { + t.Fatalf("got different result") + } +} + +func TestDecodeAndEncodeMsgBodyAsPayload(t *testing.T) { + data := "b5ee9c72010208010001c70001647362d09c003c0fe80cf0e9214a68044f58007e4e412c9642ff78a8bcbca9617ffbb0089f5ad246aa43abc4450b3814d934a9010265b37a900b41d8ff761000000006959debc80198878c1df5ae2b8ab947e54ff1f43b2844478fa09540b211901c50ff97ea69be7002030143801805cd40b77025720f35948aa8494d02f8792e1260c1027394054d029e1fda303804004380198878c1df5ae2b8ab947e54ff1f43b2844478fa09540b211901c50ff97ea69be8016d200f9086003c0fe80cf0e921800a6c058f698d02b034457bdb713bd7ffba89d0aa020ac5da9f7bca9b0c4d590e684e614ec082faf0801005016401f3835d003c0fe80cf0e92141d978ab880198878c1df5ae2b8ab947e54ff1f43b2844478fa09540b211901c50ff97ea69bf0601e16664de2a801d856fe796bb3c9254b6c849a88d49ac7df0b951c591dad7dd8f6eefcc37fd337003310f183beb5c5715728fca9fe3e87650888f1f412a8164232038a1ff2fd4d37e006621e3077d6b8ae2ae51f953fc7d0eca1111e3e825502c846407143fe5fa9a6f8000000034acef5e40070059702a14bc8b4d37580198878c1df5ae2b8ab947e54ff1f43b2844478fa09540b211901c50ff97ea69be00000010" + boc1, _ := boc.DeserializeBocHex(data) + + decoder := tlb.NewDecoder() + decoder.WithContractInterfaces([]tlb.ContractInterface{tlb.ContractInterface(TonTep74JettonWallet), tlb.ContractInterface(TonTolkTestsPayloads), tlb.ContractInterface(TonCoffeePool)}) + + var x InMsgBody + if err := decoder.Unmarshal(boc1[0], &x); err != nil { + t.Fatalf("Unable to unmarshal: %v", err) + } + + val, err := json.Marshal(x) + if err != nil { + t.Fatalf("Unable to marshal: %v", err) + } + + var x2 InMsgBody + if err = json.Unmarshal(val, &x2); err != nil { + t.Fatalf("Unable to unmarshal json: %v", err) + } + + boc2 := boc.NewCell() + if err := tlb.Marshal(boc2, x2); err != nil { + t.Fatalf("Unable to marshal tlb: %v", err) + } + + b, _ := boc2.ToBoc() + res := fmt.Sprintf("%x", b) + if res != data { + t.Fatalf("got different result") + } +} + +func TestDecodeAndEncodeMsgBodyAsPayloadWithoutIntefaces(t *testing.T) { + data := "b5ee9c72010208010001c70001647362d09c003c0fe80cf0e9214a68044f58007e4e412c9642ff78a8bcbca9617ffbb0089f5ad246aa43abc4450b3814d934a9010265b37a900b41d8ff761000000006959debc80198878c1df5ae2b8ab947e54ff1f43b2844478fa09540b211901c50ff97ea69be7002030143801805cd40b77025720f35948aa8494d02f8792e1260c1027394054d029e1fda303804004380198878c1df5ae2b8ab947e54ff1f43b2844478fa09540b211901c50ff97ea69be8016d200f9086003c0fe80cf0e921800a6c058f698d02b034457bdb713bd7ffba89d0aa020ac5da9f7bca9b0c4d590e684e614ec082faf0801005016401f3835d003c0fe80cf0e92141d978ab880198878c1df5ae2b8ab947e54ff1f43b2844478fa09540b211901c50ff97ea69bf0601e16664de2a801d856fe796bb3c9254b6c849a88d49ac7df0b951c591dad7dd8f6eefcc37fd337003310f183beb5c5715728fca9fe3e87650888f1f412a8164232038a1ff2fd4d37e006621e3077d6b8ae2ae51f953fc7d0eca1111e3e825502c846407143fe5fa9a6f8000000034acef5e40070059702a14bc8b4d37580198878c1df5ae2b8ab947e54ff1f43b2844478fa09540b211901c50ff97ea69be00000010" + boc1, _ := boc.DeserializeBocHex(data) + + var x InMsgBody + if err := tlb.Unmarshal(boc1[0], &x); err != nil { + t.Fatalf("Unable to unmarshal: %v", err) + } + + val, err := json.Marshal(x) + if err != nil { + t.Fatalf("Unable to marshal: %v", err) + } + + var x2 InMsgBody + if err = json.Unmarshal(val, &x2); err != nil { + t.Fatalf("Unable to unmarshal json: %v", err) + } + + boc2 := boc.NewCell() + if err := tlb.Marshal(boc2, x2); err != nil { + t.Fatalf("Unable to marshal tlb: %v", err) + } + + b, _ := boc2.ToBoc() + res := fmt.Sprintf("%x", b) + if res != data { + t.Fatalf("got different result") + } +} diff --git a/abi-tolk/schemas/cocoon-client.json b/abi-tolk/schemas/cocoon-client.json new file mode 100644 index 00000000..7cd60e30 --- /dev/null +++ b/abi-tolk/schemas/cocoon-client.json @@ -0,0 +1,2012 @@ +{ + "namespace": "ton.cocoon", + "contractName": "Client", + "declarations": [ + { + "kind": "Struct", + "name": "ReturnExcessesBack", + "prefix": { + "prefixStr": "0x2565934c", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + } + ] + }, + { + "kind": "Struct", + "name": "Payout", + "prefix": { + "prefixStr": "0xc59a7cd3", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + } + ] + }, + { + "kind": "Struct", + "name": "WorkerProxyRequest", + "prefix": { + "prefixStr": "0x4d725d2c", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "ownerAddress", + "ty": { + "kind": "address" + } + }, + { + "name": "state", + "ty": { + "kind": "uintN", + "n": 2 + } + }, + { + "name": "tokens", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "payload", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cell" + } + } + } + ] + }, + { + "kind": "Struct", + "name": "WorkerProxyPayoutRequest", + "prefix": { + "prefixStr": "0x08e7d036", + "prefixLen": 32 + }, + "fields": [ + { + "name": "workerPart", + "ty": { + "kind": "coins" + } + }, + { + "name": "proxyPart", + "ty": { + "kind": "coins" + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "ClientStateData", + "fields": [ + { + "name": "state", + "ty": { + "kind": "uintN", + "n": 2 + } + }, + { + "name": "balance", + "ty": { + "kind": "coins" + } + }, + { + "name": "stake", + "ty": { + "kind": "coins" + } + }, + { + "name": "tokensUsed", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "secretHash", + "ty": { + "kind": "uintN", + "n": 256 + } + } + ] + }, + { + "kind": "Struct", + "name": "ClientProxyRequest", + "prefix": { + "prefixStr": "0x65448ff4", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "ownerAddress", + "ty": { + "kind": "address" + } + }, + { + "name": "stateData", + "ty": { + "kind": "cellOf", + "inner": { + "kind": "StructRef", + "structName": "ClientStateData" + } + } + }, + { + "name": "payload", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cell" + } + } + } + ] + }, + { + "kind": "Struct", + "name": "ClientProxyTopUp", + "prefix": { + "prefixStr": "0x5cfc6b87", + "prefixLen": 32 + }, + "fields": [ + { + "name": "topUpCoins", + "ty": { + "kind": "coins" + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "ClientProxyRegister", + "prefix": { + "prefixStr": "0xa35cb580", + "prefixLen": 32 + }, + "fields": [] + }, + { + "kind": "Struct", + "name": "ClientProxyRefundGranted", + "prefix": { + "prefixStr": "0xc68ebc7b", + "prefixLen": 32 + }, + "fields": [ + { + "name": "coins", + "ty": { + "kind": "coins" + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "ClientProxyRefundForce", + "prefix": { + "prefixStr": "0xf4c354c9", + "prefixLen": 32 + }, + "fields": [ + { + "name": "coins", + "ty": { + "kind": "coins" + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "QueryHeader", + "fields": [ + { + "name": "op", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + } + ] + }, + { + "kind": "Struct", + "name": "SignedMessage", + "fields": [ + { + "name": "op", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "address" + } + }, + { + "name": "signature", + "ty": { + "kind": "bitsN", + "n": 512 + } + }, + { + "name": "signedDataCell", + "ty": { + "kind": "cell" + } + } + ] + }, + { + "kind": "Struct", + "name": "PayoutPayloadData", + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "newTokens", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "expectedMyAddress", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "PayoutPayload", + "prefix": { + "prefixStr": "0xa040ad28", + "prefixLen": 32 + }, + "fields": [ + { + "name": "data", + "ty": { + "kind": "StructRef", + "structName": "PayoutPayloadData" + } + } + ] + }, + { + "kind": "Struct", + "name": "LastPayoutPayload", + "prefix": { + "prefixStr": "0xf5f26a36", + "prefixLen": 32 + }, + "fields": [ + { + "name": "data", + "ty": { + "kind": "StructRef", + "structName": "PayoutPayloadData" + } + } + ] + }, + { + "kind": "Struct", + "name": "AddWorkerType", + "prefix": { + "prefixStr": "0xe34b1c60", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "workerHash", + "ty": { + "kind": "uintN", + "n": 256 + } + } + ] + }, + { + "kind": "Struct", + "name": "DelWorkerType", + "prefix": { + "prefixStr": "0x8d94a79a", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "workerHash", + "ty": { + "kind": "uintN", + "n": 256 + } + } + ] + }, + { + "kind": "Struct", + "name": "AddModelType", + "prefix": { + "prefixStr": "0xc146134d", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "modelHash", + "ty": { + "kind": "uintN", + "n": 256 + } + } + ] + }, + { + "kind": "Struct", + "name": "DelModelType", + "prefix": { + "prefixStr": "0x92b11c18", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "modelHash", + "ty": { + "kind": "uintN", + "n": 256 + } + } + ] + }, + { + "kind": "Struct", + "name": "AddProxyType", + "prefix": { + "prefixStr": "0x71860e80", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "proxyHash", + "ty": { + "kind": "uintN", + "n": 256 + } + } + ] + }, + { + "kind": "Struct", + "name": "DelProxyType", + "prefix": { + "prefixStr": "0x3c41d0b2", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "proxyHash", + "ty": { + "kind": "uintN", + "n": 256 + } + } + ] + }, + { + "kind": "Struct", + "name": "RegisterProxy", + "prefix": { + "prefixStr": "0x927c7cb5", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "proxyInfo", + "ty": { + "kind": "remaining" + } + } + ] + }, + { + "kind": "Struct", + "name": "UnregisterProxy", + "prefix": { + "prefixStr": "0x6d49eaf2", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "seqno", + "ty": { + "kind": "uintN", + "n": 32 + } + } + ] + }, + { + "kind": "Struct", + "name": "UpdateProxy", + "prefix": { + "prefixStr": "0x9c7924ba", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "seqno", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "proxyAddr", + "ty": { + "kind": "remaining" + } + } + ] + }, + { + "kind": "Struct", + "name": "ChangeFees", + "prefix": { + "prefixStr": "0xc52ed8d4", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "pricePerToken", + "ty": { + "kind": "coins" + } + }, + { + "name": "workerFeePerToken", + "ty": { + "kind": "coins" + } + } + ] + }, + { + "kind": "Struct", + "name": "ChangeParams", + "prefix": { + "prefixStr": "0x022fa189", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "pricePerToken", + "ty": { + "kind": "coins" + } + }, + { + "name": "workerFeePerToken", + "ty": { + "kind": "coins" + } + }, + { + "name": "proxyDelayBeforeClose", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "clientDelayBeforeClose", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "minProxyStake", + "ty": { + "kind": "coins" + } + }, + { + "name": "minClientStake", + "ty": { + "kind": "coins" + } + } + ] + }, + { + "kind": "Struct", + "name": "UpgradeContracts", + "prefix": { + "prefixStr": "0xa2370f61", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "proxyCode", + "ty": { + "kind": "cell" + } + }, + { + "name": "workerCode", + "ty": { + "kind": "cell" + } + }, + { + "name": "clientCode", + "ty": { + "kind": "cell" + } + } + ] + }, + { + "kind": "Struct", + "name": "UpgradeCode", + "prefix": { + "prefixStr": "0x11aefd51", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "newCode", + "ty": { + "kind": "cell" + } + } + ] + }, + { + "kind": "Struct", + "name": "ResetRoot", + "prefix": { + "prefixStr": "0x563c1d96", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + } + ] + }, + { + "kind": "Struct", + "name": "UpgradeFull", + "prefix": { + "prefixStr": "0x4f7c5789", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "newData", + "ty": { + "kind": "cell" + } + }, + { + "name": "newCode", + "ty": { + "kind": "cell" + } + } + ] + }, + { + "kind": "Struct", + "name": "ChangeOwner", + "prefix": { + "prefixStr": "0xc4a1ae54", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "newOwnerAddress", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "OwnerWorkerRegister", + "prefix": { + "prefixStr": "0x26ed7f65", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "ExtProxyPayoutRequest", + "prefix": { + "prefixStr": "0x7610e6eb", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "ExtProxyIncreaseStake", + "prefix": { + "prefixStr": "0x9713f187", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "grams", + "ty": { + "kind": "coins" + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "OwnerProxyClose", + "prefix": { + "prefixStr": "0xb51d5a01", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "CloseRequestPayload", + "prefix": { + "prefixStr": "0x636a4391", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "expectedMyAddress", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "CloseCompleteRequestPayload", + "prefix": { + "prefixStr": "0xe511abc7", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "expectedMyAddress", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "ExtClientTopUp", + "prefix": { + "prefixStr": "0xf172e6c2", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "topUpAmount", + "ty": { + "kind": "coins" + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "OwnerClientChangeSecretHashAndTopUp", + "prefix": { + "prefixStr": "0x8473b408", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "topUpAmount", + "ty": { + "kind": "coins" + } + }, + { + "name": "newSecretHash", + "ty": { + "kind": "uintN", + "n": 256 + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "OwnerClientRegister", + "prefix": { + "prefixStr": "0xc45f9f3b", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "nonce", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "OwnerClientChangeSecretHash", + "prefix": { + "prefixStr": "0xa9357034", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "newSecretHash", + "ty": { + "kind": "uintN", + "n": 256 + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "OwnerClientIncreaseStake", + "prefix": { + "prefixStr": "0x6a1f6a60", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "newStake", + "ty": { + "kind": "coins" + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "OwnerClientWithdraw", + "prefix": { + "prefixStr": "0xda068e78", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "OwnerClientRequestRefund", + "prefix": { + "prefixStr": "0xfafa6cc1", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "ChargePayload", + "prefix": { + "prefixStr": "0xbb63ff93", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "newTokensUsed", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "expectedMyAddress", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "GrantRefundPayload", + "prefix": { + "prefixStr": "0xefd711e1", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "newTokensUsed", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "expectedMyAddress", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "CocoonParams", + "fields": [ + { + "name": "structVersion", + "ty": { + "kind": "uintN", + "n": 8 + } + }, + { + "name": "paramsVersion", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "uniqueId", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "isTest", + "ty": { + "kind": "bool" + } + }, + { + "name": "pricePerToken", + "ty": { + "kind": "coins" + } + }, + { + "name": "workerFeePerToken", + "ty": { + "kind": "coins" + } + }, + { + "name": "promptTokensPriceMultiplier", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "cachedTokensPriceMultiplier", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "completionTokensPriceMultiplier", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "reasoningTokensPriceMultiplier", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "proxyDelayBeforeClose", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "clientDelayBeforeClose", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "minProxyStake", + "ty": { + "kind": "coins" + } + }, + { + "name": "minClientStake", + "ty": { + "kind": "coins" + } + }, + { + "name": "proxyScCode", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cell" + } + } + }, + { + "name": "workerScCode", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cell" + } + } + }, + { + "name": "clientScCode", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cell" + } + } + } + ] + }, + { + "kind": "Struct", + "name": "RootData", + "fields": [ + { + "name": "proxyHashes", + "ty": { + "kind": "AliasRef", + "aliasName": "dict" + } + }, + { + "name": "workerHashes", + "ty": { + "kind": "AliasRef", + "aliasName": "dict" + } + }, + { + "name": "lastProxySeqno", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "registeredProxies", + "ty": { + "kind": "AliasRef", + "aliasName": "dict" + } + }, + { + "name": "modelHashes", + "ty": { + "kind": "AliasRef", + "aliasName": "dict" + } + } + ] + }, + { + "kind": "Struct", + "name": "RootStorage", + "fields": [ + { + "name": "ownerAddress", + "ty": { + "kind": "address" + } + }, + { + "name": "version", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "data", + "ty": { + "kind": "cellOf", + "inner": { + "kind": "StructRef", + "structName": "RootData" + } + } + }, + { + "name": "params", + "ty": { + "kind": "cellOf", + "inner": { + "kind": "StructRef", + "structName": "CocoonParams" + } + } + } + ] + }, + { + "kind": "Struct", + "name": "ProxyStorage", + "fields": [ + { + "name": "ownerAddress", + "ty": { + "kind": "address" + } + }, + { + "name": "proxyPublicKey", + "ty": { + "kind": "uintN", + "n": 256 + } + }, + { + "name": "rootAddress", + "ty": { + "kind": "address" + } + }, + { + "name": "state", + "ty": { + "kind": "uintN", + "n": 2 + } + }, + { + "name": "balance", + "ty": { + "kind": "coins" + } + }, + { + "name": "stake", + "ty": { + "kind": "coins" + } + }, + { + "name": "unlockTs", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "params", + "ty": { + "kind": "cellOf", + "inner": { + "kind": "StructRef", + "structName": "CocoonParams" + } + } + } + ] + }, + { + "kind": "Struct", + "name": "WorkerStorage", + "fields": [ + { + "name": "ownerAddress", + "ty": { + "kind": "address" + } + }, + { + "name": "proxyAddress", + "ty": { + "kind": "address" + } + }, + { + "name": "proxyPublicKey", + "ty": { + "kind": "uintN", + "n": 256 + } + }, + { + "name": "state", + "ty": { + "kind": "uintN", + "n": 2 + } + }, + { + "name": "tokens", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "params", + "ty": { + "kind": "cellOf", + "inner": { + "kind": "StructRef", + "structName": "CocoonParams" + } + } + } + ] + }, + { + "kind": "Struct", + "name": "ClientConstData", + "fields": [ + { + "name": "ownerAddress", + "ty": { + "kind": "address" + } + }, + { + "name": "proxyAddress", + "ty": { + "kind": "address" + } + }, + { + "name": "proxyPublicKey", + "ty": { + "kind": "uintN", + "n": 256 + } + } + ] + }, + { + "kind": "Struct", + "name": "ClientStorage", + "fields": [ + { + "name": "state", + "ty": { + "kind": "uintN", + "n": 2 + } + }, + { + "name": "balance", + "ty": { + "kind": "coins" + } + }, + { + "name": "stake", + "ty": { + "kind": "coins" + } + }, + { + "name": "tokensUsed", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "unlockTs", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "secretHash", + "ty": { + "kind": "uintN", + "n": 256 + } + }, + { + "name": "constDataRef", + "ty": { + "kind": "cellOf", + "inner": { + "kind": "StructRef", + "structName": "ClientConstData" + } + } + }, + { + "name": "params", + "ty": { + "kind": "cellOf", + "inner": { + "kind": "StructRef", + "structName": "CocoonParams" + } + } + } + ] + }, + { + "kind": "Struct", + "name": "WalletStorage", + "fields": [ + { + "name": "seqno", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "subwalletId", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "publicKey", + "ty": { + "kind": "uintN", + "n": 256 + } + }, + { + "name": "status", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "ownerAddress", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "ExtClientChargeSigned", + "prefix": { + "prefixStr": "0xbb63ff93", + "prefixLen": 32 + }, + "fields": [ + { + "name": "rest", + "ty": { + "kind": "remaining" + } + } + ] + }, + { + "kind": "Struct", + "name": "ExtClientGrantRefundSigned", + "prefix": { + "prefixStr": "0xefd711e1", + "prefixLen": 32 + }, + "fields": [ + { + "name": "rest", + "ty": { + "kind": "remaining" + } + } + ] + }, + { + "kind": "Alias", + "name": "SignedClientMessage", + "targetTy": { + "kind": "union", + "variants": [ + { + "variantTy": { + "kind": "StructRef", + "structName": "ExtClientChargeSigned" + }, + "prefixStr": "0xbb63ff93", + "prefixLen": 32 + }, + { + "variantTy": { + "kind": "StructRef", + "structName": "ExtClientGrantRefundSigned" + }, + "prefixStr": "0xefd711e1", + "prefixLen": 32 + } + ] + } + }, + { + "kind": "Alias", + "name": "ClientSignedPayload", + "targetTy": { + "kind": "union", + "variants": [ + { + "variantTy": { + "kind": "StructRef", + "structName": "ChargePayload" + }, + "prefixStr": "0xbb63ff93", + "prefixLen": 32 + }, + { + "variantTy": { + "kind": "StructRef", + "structName": "GrantRefundPayload" + }, + "prefixStr": "0xefd711e1", + "prefixLen": 32 + } + ] + } + }, + { + "kind": "Alias", + "name": "ClientMessage", + "targetTy": { + "kind": "union", + "variants": [ + { + "variantTy": { + "kind": "StructRef", + "structName": "ExtClientChargeSigned" + }, + "prefixStr": "0xbb63ff93", + "prefixLen": 32 + }, + { + "variantTy": { + "kind": "StructRef", + "structName": "ExtClientGrantRefundSigned" + }, + "prefixStr": "0xefd711e1", + "prefixLen": 32 + }, + { + "variantTy": { + "kind": "StructRef", + "structName": "ExtClientTopUp" + }, + "prefixStr": "0xf172e6c2", + "prefixLen": 32 + }, + { + "variantTy": { + "kind": "StructRef", + "structName": "OwnerClientChangeSecretHashAndTopUp" + }, + "prefixStr": "0x8473b408", + "prefixLen": 32 + }, + { + "variantTy": { + "kind": "StructRef", + "structName": "OwnerClientRegister" + }, + "prefixStr": "0xc45f9f3b", + "prefixLen": 32 + }, + { + "variantTy": { + "kind": "StructRef", + "structName": "OwnerClientChangeSecretHash" + }, + "prefixStr": "0xa9357034", + "prefixLen": 32 + }, + { + "variantTy": { + "kind": "StructRef", + "structName": "OwnerClientIncreaseStake" + }, + "prefixStr": "0x6a1f6a60", + "prefixLen": 32 + }, + { + "variantTy": { + "kind": "StructRef", + "structName": "OwnerClientWithdraw" + }, + "prefixStr": "0xda068e78", + "prefixLen": 32 + }, + { + "variantTy": { + "kind": "StructRef", + "structName": "OwnerClientRequestRefund" + }, + "prefixStr": "0xfafa6cc1", + "prefixLen": 32 + } + ] + } + }, + { + "kind": "Alias", + "name": "dict", + "targetTy": { + "kind": "nullable", + "inner": { + "kind": "cell" + } + } + } + ], + "incomingMessages": [ + { + "bodyTy": { + "kind": "StructRef", + "structName": "ExtClientChargeSigned" + } + }, + { + "bodyTy": { + "kind": "StructRef", + "structName": "ExtClientGrantRefundSigned" + } + }, + { + "bodyTy": { + "kind": "StructRef", + "structName": "ExtClientTopUp" + } + }, + { + "bodyTy": { + "kind": "StructRef", + "structName": "OwnerClientChangeSecretHashAndTopUp" + } + }, + { + "bodyTy": { + "kind": "StructRef", + "structName": "OwnerClientRegister" + } + }, + { + "bodyTy": { + "kind": "StructRef", + "structName": "OwnerClientChangeSecretHash" + } + }, + { + "bodyTy": { + "kind": "StructRef", + "structName": "OwnerClientIncreaseStake" + } + }, + { + "bodyTy": { + "kind": "StructRef", + "structName": "OwnerClientWithdraw" + } + }, + { + "bodyTy": { + "kind": "StructRef", + "structName": "OwnerClientRequestRefund" + } + } + ], + "outgoingMessages": [ + { + "bodyTy": { + "kind": "StructRef", + "structName": "ReturnExcessesBack" + } + }, + { + "bodyTy": { + "kind": "StructRef", + "structName": "Payout" + } + }, + { + "bodyTy": { + "kind": "StructRef", + "structName": "ClientProxyRequest" + } + } + ], + "emittedEvents": [], + "storage": { + "storageTy": { + "kind": "StructRef", + "structName": "ClientStorage" + } + }, + "getMethods": [ + { + "tvmMethodId": 75156, + "name": "get_cocoon_client_data", + "parameters": [], + "returnTy": { + "kind": "tensor", + "items": [ + { + "kind": "address" + }, + { + "kind": "address" + }, + { + "kind": "int" + }, + { + "kind": "int" + }, + { + "kind": "int" + }, + { + "kind": "int" + }, + { + "kind": "int" + }, + { + "kind": "int" + }, + { + "kind": "int" + } + ] + } + } + ], + "thrownErrors": [ + { + "constName": "ERROR_OLD_MESSAGE", + "errCode": 1000 + }, + { + "constName": "ERROR_LOW_SMC_BALANCE", + "errCode": 1001 + }, + { + "constName": "ERROR_LOW_MSG_VALUE", + "errCode": 1003 + }, + { + "constName": "ERROR_SIGNED_MSG_FORMAT_MISMATCH", + "errCode": 1005 + }, + { + "constName": "ERROR_CLOSED", + "errCode": 1006 + }, + { + "constName": "ERROR_BAD_SIGNATURE", + "errCode": 1007 + }, + { + "constName": "ERROR_EXPECTED_OWNER", + "errCode": 1009 + }, + { + "constName": "ERROR_EXPECTED_MESSAGE_FROM_OWNER", + "errCode": 1010 + }, + { + "constName": "ERROR_NOT_UNLOCKED_YET", + "errCode": 1011 + }, + { + "constName": "ERROR_EXPECTED_MY_ADDRESS", + "errCode": 1015 + } + ], + "compilerName": "tolk", + "compilerVersion": "1.2.0", + "codeBoc64": "te6ccgECIwEACG8AART/APSkE/S88sgLAQIBYgIDAgLOBAUAP6BLKdqJoaYD9AH0AaZ/pj+n/6moY6Oh9JH0kaf/oqqlAgEgBgcD9UbCKCEAX14QBQA7vy4+uCEAX14QAioPgnbxC78uPpAtMf0z/6SIMI1xjU0SD5AEAH+RDy4+8k0NMf1ws/BLry4+0CuvLj7QLQ1ywl2x/8nJnTP9M/+kiBAIWOFNcsJ364jwyS8j/h0z/TP/pIgQCG4gHRgQCFuuMPEEeB4fIAL3PiR8kAgxwCRMOD4J28Q+Jeh+C+gghAGjneAtgkh1wsfghCaEkfAupFb4O1E0NMB+gD6ANM/0x/T/9TU0SHQ+kj6SNP/0SzXLCXbH/ycjhUw+JcQvRCsEJsQihB5EGgQVwQG8ALjDgfIywFQBvoCUAT6AhLLP8sfy//MzIAgJAJsUwW7kTDgIdDTBzHTHzHTHzHSADH6APoAMdMfMdMfMdMfMdMfMdMfMdMfMfoAMfoAMfQEMfQEMfQEMdFSF6FQBqhTB7mSF6GTMDZw4gaACZtcsJ364jwyOFTD4lxC9EKwQmxCKEHkQaBBXBAbwAo8SPVsK1ywni5c2FOMPEFcQNVUS4goLAAbJ7VQB+jonwwLy4+4J0z/6APpIMCGCEAX14QCg+Je78uPrIYIQBfXhAKAroPgnbxC78uPpUYGgCnD7AsjPkXPxrh4B+gIX+lLJIdD6SPpI0/8x0VR5p1OXBMjLAVAD+gIB+gLLP8v/ycjPkZUSP9Iayz8S+lIYzPQAycjPhYgX+lJxDAMw1ywkI52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oon-proxy.json b/abi-tolk/schemas/cocoon-proxy.json new file mode 100644 index 00000000..b9411ef0 --- /dev/null +++ b/abi-tolk/schemas/cocoon-proxy.json @@ -0,0 +1,2063 @@ +{ + "namespace": "ton.cocoon", + "contractName": "Proxy", + "declarations": [ + { + "kind": "Struct", + "name": "ReturnExcessesBack", + "prefix": { + "prefixStr": "0x2565934c", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + } + ] + }, + { + "kind": "Struct", + "name": "Payout", + "prefix": { + "prefixStr": "0xc59a7cd3", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + } + ] + }, + { + "kind": "Struct", + "name": "WorkerProxyRequest", + "prefix": { + "prefixStr": "0x4d725d2c", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "ownerAddress", + "ty": { + "kind": "address" + } + }, + { + "name": "state", + "ty": { + "kind": "uintN", + "n": 2 + } + }, + { + "name": "tokens", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "payload", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cell" + } + } + } + ] + }, + { + "kind": "Struct", + "name": "WorkerProxyPayoutRequest", + "prefix": { + "prefixStr": "0x08e7d036", + "prefixLen": 32 + }, + "fields": [ + { + "name": "workerPart", + "ty": { + "kind": "coins" + } + }, + { + "name": "proxyPart", + "ty": { + "kind": "coins" + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "ClientStateData", + "fields": [ + { + "name": "state", + "ty": { + "kind": "uintN", + "n": 2 + } + }, + { + "name": "balance", + "ty": { + "kind": "coins" + } + }, + { + "name": "stake", + "ty": { + "kind": "coins" + } + }, + { + "name": "tokensUsed", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "secretHash", + "ty": { + "kind": "uintN", + "n": 256 + } + } + ] + }, + { + "kind": "Struct", + "name": "ClientProxyRequest", + "prefix": { + "prefixStr": "0x65448ff4", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "ownerAddress", + "ty": { + "kind": "address" + } + }, + { + "name": "stateData", + "ty": { + "kind": "cellOf", + "inner": { + "kind": "StructRef", + "structName": "ClientStateData" + } + } + }, + { + "name": "payload", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cell" + } + } + } + ] + }, + { + "kind": "Struct", + "name": "ClientProxyTopUp", + "prefix": { + "prefixStr": "0x5cfc6b87", + "prefixLen": 32 + }, + "fields": [ + { + "name": "topUpCoins", + "ty": { + "kind": "coins" + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "ClientProxyRegister", + "prefix": { + "prefixStr": "0xa35cb580", + "prefixLen": 32 + }, + "fields": [] + }, + { + "kind": "Struct", + "name": "ClientProxyRefundGranted", + "prefix": { + "prefixStr": "0xc68ebc7b", + "prefixLen": 32 + }, + "fields": [ + { + "name": "coins", + "ty": { + "kind": "coins" + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "ClientProxyRefundForce", + "prefix": { + "prefixStr": "0xf4c354c9", + "prefixLen": 32 + }, + "fields": [ + { + "name": "coins", + "ty": { + "kind": "coins" + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "QueryHeader", + "fields": [ + { + "name": "op", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + } + ] + }, + { + "kind": "Struct", + "name": "SignedMessage", + "fields": [ + { + "name": "op", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "address" + } + }, + { + "name": "signature", + "ty": { + "kind": "bitsN", + "n": 512 + } + }, + { + "name": "signedDataCell", + "ty": { + "kind": "cell" + } + } + ] + }, + { + "kind": "Struct", + "name": "PayoutPayloadData", + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "newTokens", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "expectedMyAddress", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "PayoutPayload", + "prefix": { + "prefixStr": "0xa040ad28", + "prefixLen": 32 + }, + "fields": [ + { + "name": "data", + "ty": { + "kind": "StructRef", + "structName": "PayoutPayloadData" + } + } + ] + }, + { + "kind": "Struct", + "name": "LastPayoutPayload", + "prefix": { + "prefixStr": "0xf5f26a36", + "prefixLen": 32 + }, + "fields": [ + { + "name": "data", + "ty": { + "kind": "StructRef", + "structName": "PayoutPayloadData" + } + } + ] + }, + { + "kind": "Struct", + "name": "AddWorkerType", + "prefix": { + "prefixStr": "0xe34b1c60", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "workerHash", + "ty": { + "kind": "uintN", + "n": 256 + } + } + ] + }, + { + "kind": "Struct", + "name": "DelWorkerType", + "prefix": { + "prefixStr": "0x8d94a79a", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "workerHash", + "ty": { + "kind": "uintN", + "n": 256 + } + } + ] + }, + { + "kind": "Struct", + "name": "AddModelType", + "prefix": { + "prefixStr": "0xc146134d", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "modelHash", + "ty": { + "kind": "uintN", + "n": 256 + } + } + ] + }, + { + "kind": "Struct", + "name": "DelModelType", + "prefix": { + "prefixStr": "0x92b11c18", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "modelHash", + "ty": { + "kind": "uintN", + "n": 256 + } + } + ] + }, + { + "kind": "Struct", + "name": "AddProxyType", + "prefix": { + "prefixStr": "0x71860e80", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "proxyHash", + "ty": { + "kind": "uintN", + "n": 256 + } + } + ] + }, + { + "kind": "Struct", + "name": "DelProxyType", + "prefix": { + "prefixStr": "0x3c41d0b2", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "proxyHash", + "ty": { + "kind": "uintN", + "n": 256 + } + } + ] + }, + { + "kind": "Struct", + "name": "RegisterProxy", + "prefix": { + "prefixStr": "0x927c7cb5", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "proxyInfo", + "ty": { + "kind": "remaining" + } + } + ] + }, + { + "kind": "Struct", + "name": "UnregisterProxy", + "prefix": { + "prefixStr": "0x6d49eaf2", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "seqno", + "ty": { + "kind": "uintN", + "n": 32 + } + } + ] + }, + { + "kind": "Struct", + "name": "UpdateProxy", + "prefix": { + "prefixStr": "0x9c7924ba", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "seqno", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "proxyAddr", + "ty": { + "kind": "remaining" + } + } + ] + }, + { + "kind": "Struct", + "name": "ChangeFees", + "prefix": { + "prefixStr": "0xc52ed8d4", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "pricePerToken", + "ty": { + "kind": "coins" + } + }, + { + "name": "workerFeePerToken", + "ty": { + "kind": "coins" + } + } + ] + }, + { + "kind": "Struct", + "name": "ChangeParams", + "prefix": { + "prefixStr": "0x022fa189", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "pricePerToken", + "ty": { + "kind": "coins" + } + }, + { + "name": "workerFeePerToken", + "ty": { + "kind": "coins" + } + }, + { + "name": "proxyDelayBeforeClose", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "clientDelayBeforeClose", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "minProxyStake", + "ty": { + "kind": "coins" + } + }, + { + "name": "minClientStake", + "ty": { + "kind": "coins" + } + } + ] + }, + { + "kind": "Struct", + "name": "UpgradeContracts", + "prefix": { + "prefixStr": "0xa2370f61", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "proxyCode", + "ty": { + "kind": "cell" + } + }, + { + "name": "workerCode", + "ty": { + "kind": "cell" + } + }, + { + "name": "clientCode", + "ty": { + "kind": "cell" + } + } + ] + }, + { + "kind": "Struct", + "name": "UpgradeCode", + "prefix": { + "prefixStr": "0x11aefd51", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "newCode", + "ty": { + "kind": "cell" + } + } + ] + }, + { + "kind": "Struct", + "name": "ResetRoot", + "prefix": { + "prefixStr": "0x563c1d96", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + } + ] + }, + { + "kind": "Struct", + "name": "UpgradeFull", + "prefix": { + "prefixStr": "0x4f7c5789", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "newData", + "ty": { + "kind": "cell" + } + }, + { + "name": "newCode", + "ty": { + "kind": "cell" + } + } + ] + }, + { + "kind": "Struct", + "name": "ChangeOwner", + "prefix": { + "prefixStr": "0xc4a1ae54", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "newOwnerAddress", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "OwnerWorkerRegister", + "prefix": { + "prefixStr": "0x26ed7f65", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "ExtProxyPayoutRequest", + "prefix": { + "prefixStr": "0x7610e6eb", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "ExtProxyIncreaseStake", + "prefix": { + "prefixStr": "0x9713f187", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "grams", + "ty": { + "kind": "coins" + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "OwnerProxyClose", + "prefix": { + "prefixStr": "0xb51d5a01", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "CloseRequestPayload", + "prefix": { + "prefixStr": "0x636a4391", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "expectedMyAddress", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "CloseCompleteRequestPayload", + "prefix": { + "prefixStr": "0xe511abc7", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "expectedMyAddress", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "ExtClientTopUp", + "prefix": { + "prefixStr": "0xf172e6c2", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "topUpAmount", + "ty": { + "kind": "coins" + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "OwnerClientChangeSecretHashAndTopUp", + "prefix": { + "prefixStr": "0x8473b408", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "topUpAmount", + "ty": { + "kind": "coins" + } + }, + { + "name": "newSecretHash", + "ty": { + "kind": "uintN", + "n": 256 + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "OwnerClientRegister", + "prefix": { + "prefixStr": "0xc45f9f3b", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "nonce", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "OwnerClientChangeSecretHash", + "prefix": { + "prefixStr": "0xa9357034", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "newSecretHash", + "ty": { + "kind": "uintN", + "n": 256 + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "OwnerClientIncreaseStake", + "prefix": { + "prefixStr": "0x6a1f6a60", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "newStake", + "ty": { + "kind": "coins" + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "OwnerClientWithdraw", + "prefix": { + "prefixStr": "0xda068e78", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "OwnerClientRequestRefund", + "prefix": { + "prefixStr": "0xfafa6cc1", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "ChargePayload", + "prefix": { + "prefixStr": "0xbb63ff93", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "newTokensUsed", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "expectedMyAddress", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "GrantRefundPayload", + "prefix": { + "prefixStr": "0xefd711e1", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "newTokensUsed", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "expectedMyAddress", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "CocoonParams", + "fields": [ + { + "name": "structVersion", + "ty": { + "kind": "uintN", + "n": 8 + } + }, + { + "name": "paramsVersion", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "uniqueId", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "isTest", + "ty": { + "kind": "bool" + } + }, + { + "name": "pricePerToken", + "ty": { + "kind": "coins" + } + }, + { + "name": "workerFeePerToken", + "ty": { + "kind": "coins" + } + }, + { + "name": "promptTokensPriceMultiplier", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "cachedTokensPriceMultiplier", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "completionTokensPriceMultiplier", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "reasoningTokensPriceMultiplier", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "proxyDelayBeforeClose", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "clientDelayBeforeClose", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "minProxyStake", + "ty": { + "kind": "coins" + } + }, + { + "name": "minClientStake", + "ty": { + "kind": "coins" + } + }, + { + "name": "proxyScCode", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cell" + } + } + }, + { + "name": "workerScCode", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cell" + } + } + }, + { + "name": "clientScCode", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cell" + } + } + } + ] + }, + { + "kind": "Struct", + "name": "RootData", + "fields": [ + { + "name": "proxyHashes", + "ty": { + "kind": "AliasRef", + "aliasName": "dict" + } + }, + { + "name": "workerHashes", + "ty": { + "kind": "AliasRef", + "aliasName": "dict" + } + }, + { + "name": "lastProxySeqno", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "registeredProxies", + "ty": { + "kind": "AliasRef", + "aliasName": "dict" + } + }, + { + "name": "modelHashes", + "ty": { + "kind": "AliasRef", + "aliasName": "dict" + } + } + ] + }, + { + "kind": "Struct", + "name": "RootStorage", + "fields": [ + { + "name": "ownerAddress", + "ty": { + "kind": "address" + } + }, + { + "name": "version", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "data", + "ty": { + "kind": "cellOf", + "inner": { + "kind": "StructRef", + "structName": "RootData" + } + } + }, + { + "name": "params", + "ty": { + "kind": "cellOf", + "inner": { + "kind": "StructRef", + "structName": "CocoonParams" + } + } + } + ] + }, + { + "kind": "Struct", + "name": "ProxyStorage", + "fields": [ + { + "name": "ownerAddress", + "ty": { + "kind": "address" + } + }, + { + "name": "proxyPublicKey", + "ty": { + "kind": "uintN", + "n": 256 + } + }, + { + "name": "rootAddress", + "ty": { + "kind": "address" + } + }, + { + "name": "state", + "ty": { + "kind": "uintN", + "n": 2 + } + }, + { + "name": "balance", + "ty": { + "kind": "coins" + } + }, + { + "name": "stake", + "ty": { + "kind": "coins" + } + }, + { + "name": "unlockTs", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "params", + "ty": { + "kind": "cellOf", + "inner": { + "kind": "StructRef", + "structName": "CocoonParams" + } + } + } + ] + }, + { + "kind": "Struct", + "name": "WorkerStorage", + "fields": [ + { + "name": "ownerAddress", + "ty": { + "kind": "address" + } + }, + { + "name": "proxyAddress", + "ty": { + "kind": "address" + } + }, + { + "name": "proxyPublicKey", + "ty": { + "kind": "uintN", + "n": 256 + } + }, + { + "name": "state", + "ty": { + "kind": "uintN", + "n": 2 + } + }, + { + "name": "tokens", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "params", + "ty": { + "kind": "cellOf", + "inner": { + "kind": "StructRef", + "structName": "CocoonParams" + } + } + } + ] + }, + { + "kind": "Struct", + "name": "ClientConstData", + "fields": [ + { + "name": "ownerAddress", + "ty": { + "kind": "address" + } + }, + { + "name": "proxyAddress", + "ty": { + "kind": "address" + } + }, + { + "name": "proxyPublicKey", + "ty": { + "kind": "uintN", + "n": 256 + } + } + ] + }, + { + "kind": "Struct", + "name": "ClientStorage", + "fields": [ + { + "name": "state", + "ty": { + "kind": "uintN", + "n": 2 + } + }, + { + "name": "balance", + "ty": { + "kind": "coins" + } + }, + { + "name": "stake", + "ty": { + "kind": "coins" + } + }, + { + "name": "tokensUsed", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "unlockTs", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "secretHash", + "ty": { + "kind": "uintN", + "n": 256 + } + }, + { + "name": "constDataRef", + "ty": { + "kind": "cellOf", + "inner": { + "kind": "StructRef", + "structName": "ClientConstData" + } + } + }, + { + "name": "params", + "ty": { + "kind": "cellOf", + "inner": { + "kind": "StructRef", + "structName": "CocoonParams" + } + } + } + ] + }, + { + "kind": "Struct", + "name": "WalletStorage", + "fields": [ + { + "name": "seqno", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "subwalletId", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "publicKey", + "ty": { + "kind": "uintN", + "n": 256 + } + }, + { + "name": "status", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "ownerAddress", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "TextCmd", + "prefix": { + "prefixStr": "0x00000000", + "prefixLen": 32 + }, + "fields": [ + { + "name": "action", + "ty": { + "kind": "uintN", + "n": 8 + } + } + ] + }, + { + "kind": "Alias", + "name": "SignedProxyPayload", + "targetTy": { + "kind": "union", + "variants": [ + { + "variantTy": { + "kind": "StructRef", + "structName": "CloseRequestPayload" + }, + "prefixStr": "0x636a4391", + "prefixLen": 32 + }, + { + "variantTy": { + "kind": "StructRef", + "structName": "CloseCompleteRequestPayload" + }, + "prefixStr": "0xe511abc7", + "prefixLen": 32 + } + ] + } + }, + { + "kind": "Struct", + "name": "ExtProxyCloseRequestSigned", + "prefix": { + "prefixStr": "0x636a4391", + "prefixLen": 32 + }, + "fields": [ + { + "name": "rest", + "ty": { + "kind": "remaining" + } + } + ] + }, + { + "kind": "Struct", + "name": "ExtProxyCloseCompleteRequestSigned", + "prefix": { + "prefixStr": "0xe511abc7", + "prefixLen": 32 + }, + "fields": [ + { + "name": "rest", + "ty": { + "kind": "remaining" + } + } + ] + }, + { + "kind": "Alias", + "name": "SignedProxyMessage", + "targetTy": { + "kind": "union", + "variants": [ + { + "variantTy": { + "kind": "StructRef", + "structName": "ExtProxyCloseRequestSigned" + }, + "prefixStr": "0x636a4391", + "prefixLen": 32 + }, + { + "variantTy": { + "kind": "StructRef", + "structName": "ExtProxyCloseCompleteRequestSigned" + }, + "prefixStr": "0xe511abc7", + "prefixLen": 32 + } + ] + } + }, + { + "kind": "Alias", + "name": "ClientProxyPayload", + "targetTy": { + "kind": "union", + "variants": [ + { + "variantTy": { + "kind": "StructRef", + "structName": "ClientProxyTopUp" + }, + "prefixStr": "0x5cfc6b87", + "prefixLen": 32 + }, + { + "variantTy": { + "kind": "StructRef", + "structName": "ClientProxyRegister" + }, + "prefixStr": "0xa35cb580", + "prefixLen": 32 + }, + { + "variantTy": { + "kind": "StructRef", + "structName": "ClientProxyRefundGranted" + }, + "prefixStr": "0xc68ebc7b", + "prefixLen": 32 + }, + { + "variantTy": { + "kind": "StructRef", + "structName": "ClientProxyRefundForce" + }, + "prefixStr": "0xf4c354c9", + "prefixLen": 32 + } + ] + } + }, + { + "kind": "Alias", + "name": "WorkerProxyPayload", + "targetTy": { + "kind": "StructRef", + "structName": "WorkerProxyPayoutRequest" + } + }, + { + "kind": "Alias", + "name": "ProxyMessage", + "targetTy": { + "kind": "union", + "variants": [ + { + "variantTy": { + "kind": "StructRef", + "structName": "TextCmd" + }, + "prefixStr": "0x00000000", + "prefixLen": 32 + }, + { + "variantTy": { + "kind": "StructRef", + "structName": "ExtProxyCloseRequestSigned" + }, + "prefixStr": "0x636a4391", + "prefixLen": 32 + }, + { + "variantTy": { + "kind": "StructRef", + "structName": "ExtProxyCloseCompleteRequestSigned" + }, + "prefixStr": "0xe511abc7", + "prefixLen": 32 + }, + { + "variantTy": { + "kind": "StructRef", + "structName": "ExtProxyPayoutRequest" + }, + "prefixStr": "0x7610e6eb", + "prefixLen": 32 + }, + { + "variantTy": { + "kind": "StructRef", + "structName": "ExtProxyIncreaseStake" + }, + "prefixStr": "0x9713f187", + "prefixLen": 32 + }, + { + "variantTy": { + "kind": "StructRef", + "structName": "OwnerProxyClose" + }, + "prefixStr": "0xb51d5a01", + "prefixLen": 32 + }, + { + "variantTy": { + "kind": "StructRef", + "structName": "WorkerProxyRequest" + }, + "prefixStr": "0x4d725d2c", + "prefixLen": 32 + }, + { + "variantTy": { + "kind": "StructRef", + "structName": "ClientProxyRequest" + }, + "prefixStr": "0x65448ff4", + "prefixLen": 32 + } + ] + } + }, + { + "kind": "Alias", + "name": "dict", + "targetTy": { + "kind": "nullable", + "inner": { + "kind": "cell" + } + } + } + ], + "incomingMessages": [ + { + "bodyTy": { + "kind": "StructRef", + "structName": "TextCmd" + } + }, + { + "bodyTy": { + "kind": "StructRef", + "structName": "ExtProxyCloseRequestSigned" + } + }, + { + "bodyTy": { + "kind": "StructRef", + "structName": "ExtProxyCloseCompleteRequestSigned" + } + }, + { + "bodyTy": { + "kind": "StructRef", + "structName": "ExtProxyPayoutRequest" + } + }, + { + "bodyTy": { + "kind": "StructRef", + "structName": "ExtProxyIncreaseStake" + } + }, + { + "bodyTy": { + "kind": "StructRef", + "structName": "OwnerProxyClose" + } + }, + { + "bodyTy": { + "kind": "StructRef", + "structName": "WorkerProxyRequest" + } + }, + { + "bodyTy": { + "kind": "StructRef", + "structName": "ClientProxyRequest" + } + } + ], + "outgoingMessages": [ + { + "bodyTy": { + "kind": "StructRef", + "structName": "ReturnExcessesBack" + } + }, + { + "bodyTy": { + "kind": "StructRef", + "structName": "Payout" + } + } + ], + "emittedEvents": [], + "storage": { + "storageTy": { + "kind": "StructRef", + "structName": "ProxyStorage" + } + }, + "getMethods": [ + { + "tvmMethodId": 97687, + "name": "get_cocoon_proxy_data", + "parameters": [], + "returnTy": { + "kind": "tensor", + "items": [ + { + "kind": "address" + }, + { + "kind": "int" + }, + { + "kind": "address" + }, + { + "kind": "int" + }, + { + "kind": "coins" + }, + { + "kind": "coins" + }, + { + "kind": "int" + }, + { + "kind": "int" + }, + { + "kind": "int" + }, + { + "kind": "coins" + }, + { + "kind": "coins" + }, + { + "kind": "int" + } + ] + } + } + ], + "thrownErrors": [ + { + "constName": "ERROR_LOW_MSG_VALUE", + "errCode": 1003 + }, + { + "constName": "ERROR_SIGNED_MSG_FORMAT_MISMATCH", + "errCode": 1005 + }, + { + "constName": "ERROR_CLOSED", + "errCode": 1006 + }, + { + "constName": "ERROR_BAD_SIGNATURE", + "errCode": 1007 + }, + { + "constName": "ERROR_EXPECTED_MESSAGE_FROM_OWNER", + "errCode": 1010 + }, + { + "constName": "ERROR_NOT_UNLOCKED_YET", + "errCode": 1011 + }, + { + "constName": "ERROR_UNKNOWN_TEXT_OP", + "errCode": 1013 + }, + { + "constName": "ERROR_CONTRACT_ADDRESS_MISMATCH", + "errCode": 1014 + }, + { + "constName": "ERROR_EXPECTED_MY_ADDRESS", + "errCode": 1015 + } + ], + "compilerName": "tolk", + "compilerVersion": "1.2.0", + "codeBoc64": "te6ccgECGwEABuMAART/APSkE/S88sgLAQIBYgIDAgLNBAUAj6D7L9qJofSRp//0kaYD9AH0AaY/qaOhpg5jpj+mPmOkAGP0AfQBpj5jpj5jpj5jpj5jpj5jpj5j9AH0AegIY+gIY+gIY6KqBwIBIAYHAffXbRdv2ZkLdJL4LwEuhpg+mP6Y/pAH0AfQBpj+mP6Y/pj+mP6Y/9AH0AegIY+gIY+gJotra2/BQrC2R9KX0pKw9nhf/kiIlkZYOAiIiA5Y+P5Y+O5QAoBf0BKAT9AQvlj4rlj4nlj+WP5Y/lj4D9ARD9AQn6AAn6AAn6AEFwIBIAgJAgEgExQD9z4kfJAIMcAkTDg+CdvEPiXofgvoIIImJaAtgkh1wsfghCaEkfAupFb4O1E0FIg+kjT//pI0wH6APoA0x/XTAjXLCAAAAAE4wLXLCMbUhyMjhUw+JcmEIsKEGkQWBBHEDZeIlUC8ALjDgfI+lIWy/8U+lISywEB+gIB+gKAKCwwBhwnwACOOlszMwPAAZPyw+7h+CNQA77y4/OCCJiWgHD7AoMGyM+FCFJg+lKCEMWafNPPC44Tyz/JWPsAcnBUUCHjDVAEgEgL+OgnXCwcgwGOOXMB3k/LD9eGCEAX14QD4l7vy4+siwwLy4+74kibHBfLj8geicPsCcIMGyM+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AAS9AAS9ADJJsj6UhP6Ui7PC/9wzwtBgFgAcKPLT7vgoxwXy4/dY8AEA5BLMyQHIz4TQzMz5FnDIz4ZAygfL/89QE8cF8uP2AdDXLCBHPoG0kvI/4SjDAvLj7voA+gD6SDAJoFEhoXD7AnHIz4UIFPpSAfoCghDFmnzTzwuKI88LP8lY+wDIz4UIFvpSghAlZZNMzwuOyz/Jgwb7AAJwycjPhAhQA/oCcM8LX3DPC/8TzMzJAcjPhNDMzPkWcMjPhkDKB8v/z1DHBfLj9tDXLCLn41w84w8YGQCO+gD6SDApwACVM6Bw+wKOIAJw+wJwyM+FCBT6UgH6AoIQxZp8088LiiPPCz/JWPsA4sjPhQj6UoIQJWWTTM8Ljss/yYMG+wAB5NcsJRrlrASUXwTbMeDXLCY0dePcjlrXLCemGqZMkvI/4SjDAvLj7voA+kgwUxe8kzFSYN5RcaFRIaFw+wJxyM+FCBT6UgH6AoIQxZp8088LiiPPCz/JWPsAyM+FCBX6UoIQJWWTTM8Ljss/yYMG+wDjDRoAhijDAvLj7voA+kgwUSGhcPsCccjPhQgU+lIB+gKCEMWafNPPC4ojzws/yVj7AMjPhQj6UoIQJWWTTM8Ljss/yYMG+wA=" +} \ No newline at end of file diff --git a/abi-tolk/schemas/cocoon_root.json b/abi-tolk/schemas/cocoon_root.json new file mode 100644 index 00000000..8067bd19 --- /dev/null +++ b/abi-tolk/schemas/cocoon_root.json @@ -0,0 +1,2110 @@ +{ + "namespace": "ton.cocoon", + "contractName": "Root", + "declarations": [ + { + "kind": "Struct", + "name": "ReturnExcessesBack", + "prefix": { + "prefixStr": "0x2565934c", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + } + ] + }, + { + "kind": "Struct", + "name": "Payout", + "prefix": { + "prefixStr": "0xc59a7cd3", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + } + ] + }, + { + "kind": "Struct", + "name": "WorkerProxyRequest", + "prefix": { + "prefixStr": "0x4d725d2c", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "ownerAddress", + "ty": { + "kind": "address" + } + }, + { + "name": "state", + "ty": { + "kind": "uintN", + "n": 2 + } + }, + { + "name": "tokens", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "payload", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cell" + } + } + } + ] + }, + { + "kind": "Struct", + "name": "WorkerProxyPayoutRequest", + "prefix": { + "prefixStr": "0x08e7d036", + "prefixLen": 32 + }, + "fields": [ + { + "name": "workerPart", + "ty": { + "kind": "coins" + } + }, + { + "name": "proxyPart", + "ty": { + "kind": "coins" + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "ClientStateData", + "fields": [ + { + "name": "state", + "ty": { + "kind": "uintN", + "n": 2 + } + }, + { + "name": "balance", + "ty": { + "kind": "coins" + } + }, + { + "name": "stake", + "ty": { + "kind": "coins" + } + }, + { + "name": "tokensUsed", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "secretHash", + "ty": { + "kind": "uintN", + "n": 256 + } + } + ] + }, + { + "kind": "Struct", + "name": "ClientProxyRequest", + "prefix": { + "prefixStr": "0x65448ff4", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "ownerAddress", + "ty": { + "kind": "address" + } + }, + { + "name": "stateData", + "ty": { + "kind": "cellOf", + "inner": { + "kind": "StructRef", + "structName": "ClientStateData" + } + } + }, + { + "name": "payload", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cell" + } + } + } + ] + }, + { + "kind": "Struct", + "name": "ClientProxyTopUp", + "prefix": { + "prefixStr": "0x5cfc6b87", + "prefixLen": 32 + }, + "fields": [ + { + "name": "topUpCoins", + "ty": { + "kind": "coins" + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "ClientProxyRegister", + "prefix": { + "prefixStr": "0xa35cb580", + "prefixLen": 32 + }, + "fields": [] + }, + { + "kind": "Struct", + "name": "ClientProxyRefundGranted", + "prefix": { + "prefixStr": "0xc68ebc7b", + "prefixLen": 32 + }, + "fields": [ + { + "name": "coins", + "ty": { + "kind": "coins" + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "ClientProxyRefundForce", + "prefix": { + "prefixStr": "0xf4c354c9", + "prefixLen": 32 + }, + "fields": [ + { + "name": "coins", + "ty": { + "kind": "coins" + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "QueryHeader", + "fields": [ + { + "name": "op", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + } + ] + }, + { + "kind": "Struct", + "name": "SignedMessage", + "fields": [ + { + "name": "op", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "address" + } + }, + { + "name": "signature", + "ty": { + "kind": "bitsN", + "n": 512 + } + }, + { + "name": "signedDataCell", + "ty": { + "kind": "cell" + } + } + ] + }, + { + "kind": "Struct", + "name": "PayoutPayloadData", + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "newTokens", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "expectedMyAddress", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "PayoutPayload", + "prefix": { + "prefixStr": "0xa040ad28", + "prefixLen": 32 + }, + "fields": [ + { + "name": "data", + "ty": { + "kind": "StructRef", + "structName": "PayoutPayloadData" + } + } + ] + }, + { + "kind": "Struct", + "name": "LastPayoutPayload", + "prefix": { + "prefixStr": "0xf5f26a36", + "prefixLen": 32 + }, + "fields": [ + { + "name": "data", + "ty": { + "kind": "StructRef", + "structName": "PayoutPayloadData" + } + } + ] + }, + { + "kind": "Struct", + "name": "AddWorkerType", + "prefix": { + "prefixStr": "0xe34b1c60", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "workerHash", + "ty": { + "kind": "uintN", + "n": 256 + } + } + ] + }, + { + "kind": "Struct", + "name": "DelWorkerType", + "prefix": { + "prefixStr": "0x8d94a79a", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "workerHash", + "ty": { + "kind": "uintN", + "n": 256 + } + } + ] + }, + { + "kind": "Struct", + "name": "AddModelType", + "prefix": { + "prefixStr": "0xc146134d", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "modelHash", + "ty": { + "kind": "uintN", + "n": 256 + } + } + ] + }, + { + "kind": "Struct", + "name": "DelModelType", + "prefix": { + "prefixStr": "0x92b11c18", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "modelHash", + "ty": { + "kind": "uintN", + "n": 256 + } + } + ] + }, + { + "kind": "Struct", + "name": "AddProxyType", + "prefix": { + "prefixStr": "0x71860e80", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "proxyHash", + "ty": { + "kind": "uintN", + "n": 256 + } + } + ] + }, + { + "kind": "Struct", + "name": "DelProxyType", + "prefix": { + "prefixStr": "0x3c41d0b2", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "proxyHash", + "ty": { + "kind": "uintN", + "n": 256 + } + } + ] + }, + { + "kind": "Struct", + "name": "RegisterProxy", + "prefix": { + "prefixStr": "0x927c7cb5", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "proxyInfo", + "ty": { + "kind": "remaining" + } + } + ] + }, + { + "kind": "Struct", + "name": "UnregisterProxy", + "prefix": { + "prefixStr": "0x6d49eaf2", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "seqno", + "ty": { + "kind": "uintN", + "n": 32 + } + } + ] + }, + { + "kind": "Struct", + "name": "UpdateProxy", + "prefix": { + "prefixStr": "0x9c7924ba", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "seqno", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "proxyAddr", + "ty": { + "kind": "remaining" + } + } + ] + }, + { + "kind": "Struct", + "name": "ChangeFees", + "prefix": { + "prefixStr": "0xc52ed8d4", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "pricePerToken", + "ty": { + "kind": "coins" + } + }, + { + "name": "workerFeePerToken", + "ty": { + "kind": "coins" + } + } + ] + }, + { + "kind": "Struct", + "name": "ChangeParams", + "prefix": { + "prefixStr": "0x022fa189", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "pricePerToken", + "ty": { + "kind": "coins" + } + }, + { + "name": "workerFeePerToken", + "ty": { + "kind": "coins" + } + }, + { + "name": "proxyDelayBeforeClose", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "clientDelayBeforeClose", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "minProxyStake", + "ty": { + "kind": "coins" + } + }, + { + "name": "minClientStake", + "ty": { + "kind": "coins" + } + } + ] + }, + { + "kind": "Struct", + "name": "UpgradeContracts", + "prefix": { + "prefixStr": "0xa2370f61", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "proxyCode", + "ty": { + "kind": "cell" + } + }, + { + "name": "workerCode", + "ty": { + "kind": "cell" + } + }, + { + "name": "clientCode", + "ty": { + "kind": "cell" + } + } + ] + }, + { + "kind": "Struct", + "name": "UpgradeCode", + "prefix": { + "prefixStr": "0x11aefd51", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "newCode", + "ty": { + "kind": "cell" + } + } + ] + }, + { + "kind": "Struct", + "name": "ResetRoot", + "prefix": { + "prefixStr": "0x563c1d96", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + } + ] + }, + { + "kind": "Struct", + "name": "UpgradeFull", + "prefix": { + "prefixStr": "0x4f7c5789", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "newData", + "ty": { + "kind": "cell" + } + }, + { + "name": "newCode", + "ty": { + "kind": "cell" + } + } + ] + }, + { + "kind": "Struct", + "name": "ChangeOwner", + "prefix": { + "prefixStr": "0xc4a1ae54", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "newOwnerAddress", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "OwnerWorkerRegister", + "prefix": { + "prefixStr": "0x26ed7f65", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "ExtProxyPayoutRequest", + "prefix": { + "prefixStr": "0x7610e6eb", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "ExtProxyIncreaseStake", + "prefix": { + "prefixStr": "0x9713f187", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "grams", + "ty": { + "kind": "coins" + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "OwnerProxyClose", + "prefix": { + "prefixStr": "0xb51d5a01", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "CloseRequestPayload", + "prefix": { + "prefixStr": "0x636a4391", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "expectedMyAddress", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "CloseCompleteRequestPayload", + "prefix": { + "prefixStr": "0xe511abc7", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "expectedMyAddress", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "ExtClientTopUp", + "prefix": { + "prefixStr": "0xf172e6c2", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "topUpAmount", + "ty": { + "kind": "coins" + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "OwnerClientChangeSecretHashAndTopUp", + "prefix": { + "prefixStr": "0x8473b408", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "topUpAmount", + "ty": { + "kind": "coins" + } + }, + { + "name": "newSecretHash", + "ty": { + "kind": "uintN", + "n": 256 + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "OwnerClientRegister", + "prefix": { + "prefixStr": "0xc45f9f3b", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "nonce", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "OwnerClientChangeSecretHash", + "prefix": { + "prefixStr": "0xa9357034", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "newSecretHash", + "ty": { + "kind": "uintN", + "n": 256 + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "OwnerClientIncreaseStake", + "prefix": { + "prefixStr": "0x6a1f6a60", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "newStake", + "ty": { + "kind": "coins" + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "OwnerClientWithdraw", + "prefix": { + "prefixStr": "0xda068e78", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "OwnerClientRequestRefund", + "prefix": { + "prefixStr": "0xfafa6cc1", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "ChargePayload", + "prefix": { + "prefixStr": "0xbb63ff93", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "newTokensUsed", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "expectedMyAddress", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "GrantRefundPayload", + "prefix": { + "prefixStr": "0xefd711e1", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "newTokensUsed", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "expectedMyAddress", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "CocoonParams", + "fields": [ + { + "name": "structVersion", + "ty": { + "kind": "uintN", + "n": 8 + } + }, + { + "name": "paramsVersion", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "uniqueId", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "isTest", + "ty": { + "kind": "bool" + } + }, + { + "name": "pricePerToken", + "ty": { + "kind": "coins" + } + }, + { + "name": "workerFeePerToken", + "ty": { + "kind": "coins" + } + }, + { + "name": "promptTokensPriceMultiplier", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "cachedTokensPriceMultiplier", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "completionTokensPriceMultiplier", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "reasoningTokensPriceMultiplier", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "proxyDelayBeforeClose", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "clientDelayBeforeClose", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "minProxyStake", + "ty": { + "kind": "coins" + } + }, + { + "name": "minClientStake", + "ty": { + "kind": "coins" + } + }, + { + "name": "proxyScCode", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cell" + } + } + }, + { + "name": "workerScCode", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cell" + } + } + }, + { + "name": "clientScCode", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cell" + } + } + } + ] + }, + { + "kind": "Struct", + "name": "RootData", + "fields": [ + { + "name": "proxyHashes", + "ty": { + "kind": "AliasRef", + "aliasName": "dict" + } + }, + { + "name": "workerHashes", + "ty": { + "kind": "AliasRef", + "aliasName": "dict" + } + }, + { + "name": "lastProxySeqno", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "registeredProxies", + "ty": { + "kind": "AliasRef", + "aliasName": "dict" + } + }, + { + "name": "modelHashes", + "ty": { + "kind": "AliasRef", + "aliasName": "dict" + } + } + ] + }, + { + "kind": "Struct", + "name": "RootStorage", + "fields": [ + { + "name": "ownerAddress", + "ty": { + "kind": "address" + } + }, + { + "name": "version", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "data", + "ty": { + "kind": "cellOf", + "inner": { + "kind": "StructRef", + "structName": "RootData" + } + } + }, + { + "name": "params", + "ty": { + "kind": "cellOf", + "inner": { + "kind": "StructRef", + "structName": "CocoonParams" + } + } + } + ] + }, + { + "kind": "Struct", + "name": "ProxyStorage", + "fields": [ + { + "name": "ownerAddress", + "ty": { + "kind": "address" + } + }, + { + "name": "proxyPublicKey", + "ty": { + "kind": "uintN", + "n": 256 + } + }, + { + "name": "rootAddress", + "ty": { + "kind": "address" + } + }, + { + "name": "state", + "ty": { + "kind": "uintN", + "n": 2 + } + }, + { + "name": "balance", + "ty": { + "kind": "coins" + } + }, + { + "name": "stake", + "ty": { + "kind": "coins" + } + }, + { + "name": "unlockTs", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "params", + "ty": { + "kind": "cellOf", + "inner": { + "kind": "StructRef", + "structName": "CocoonParams" + } + } + } + ] + }, + { + "kind": "Struct", + "name": "WorkerStorage", + "fields": [ + { + "name": "ownerAddress", + "ty": { + "kind": "address" + } + }, + { + "name": "proxyAddress", + "ty": { + "kind": "address" + } + }, + { + "name": "proxyPublicKey", + "ty": { + "kind": "uintN", + "n": 256 + } + }, + { + "name": "state", + "ty": { + "kind": "uintN", + "n": 2 + } + }, + { + "name": "tokens", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "params", + "ty": { + "kind": "cellOf", + "inner": { + "kind": "StructRef", + "structName": "CocoonParams" + } + } + } + ] + }, + { + "kind": "Struct", + "name": "ClientConstData", + "fields": [ + { + "name": "ownerAddress", + "ty": { + "kind": "address" + } + }, + { + "name": "proxyAddress", + "ty": { + "kind": "address" + } + }, + { + "name": "proxyPublicKey", + "ty": { + "kind": "uintN", + "n": 256 + } + } + ] + }, + { + "kind": "Struct", + "name": "ClientStorage", + "fields": [ + { + "name": "state", + "ty": { + "kind": "uintN", + "n": 2 + } + }, + { + "name": "balance", + "ty": { + "kind": "coins" + } + }, + { + "name": "stake", + "ty": { + "kind": "coins" + } + }, + { + "name": "tokensUsed", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "unlockTs", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "secretHash", + "ty": { + "kind": "uintN", + "n": 256 + } + }, + { + "name": "constDataRef", + "ty": { + "kind": "cellOf", + "inner": { + "kind": "StructRef", + "structName": "ClientConstData" + } + } + }, + { + "name": "params", + "ty": { + "kind": "cellOf", + "inner": { + "kind": "StructRef", + "structName": "CocoonParams" + } + } + } + ] + }, + { + "kind": "Struct", + "name": "WalletStorage", + "fields": [ + { + "name": "seqno", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "subwalletId", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "publicKey", + "ty": { + "kind": "uintN", + "n": 256 + } + }, + { + "name": "status", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "ownerAddress", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Alias", + "name": "RootMessage", + "targetTy": { + "kind": "union", + "variants": [ + { + "variantTy": { + "kind": "StructRef", + "structName": "AddWorkerType" + }, + "prefixStr": "0xe34b1c60", + "prefixLen": 32 + }, + { + "variantTy": { + "kind": "StructRef", + "structName": "DelWorkerType" + }, + "prefixStr": "0x8d94a79a", + "prefixLen": 32 + }, + { + "variantTy": { + "kind": "StructRef", + "structName": "AddModelType" + }, + "prefixStr": "0xc146134d", + "prefixLen": 32 + }, + { + "variantTy": { + "kind": "StructRef", + "structName": "DelModelType" + }, + "prefixStr": "0x92b11c18", + "prefixLen": 32 + }, + { + "variantTy": { + "kind": "StructRef", + "structName": "AddProxyType" + }, + "prefixStr": "0x71860e80", + "prefixLen": 32 + }, + { + "variantTy": { + "kind": "StructRef", + "structName": "DelProxyType" + }, + "prefixStr": "0x3c41d0b2", + "prefixLen": 32 + }, + { + "variantTy": { + "kind": "StructRef", + "structName": "RegisterProxy" + }, + "prefixStr": "0x927c7cb5", + "prefixLen": 32 + }, + { + "variantTy": { + "kind": "StructRef", + "structName": "UnregisterProxy" + }, + "prefixStr": "0x6d49eaf2", + "prefixLen": 32 + }, + { + "variantTy": { + "kind": "StructRef", + "structName": "UpdateProxy" + }, + "prefixStr": "0x9c7924ba", + "prefixLen": 32 + }, + { + "variantTy": { + "kind": "StructRef", + "structName": "ChangeFees" + }, + "prefixStr": "0xc52ed8d4", + "prefixLen": 32 + }, + { + "variantTy": { + "kind": "StructRef", + "structName": "ChangeParams" + }, + "prefixStr": "0x022fa189", + "prefixLen": 32 + }, + { + "variantTy": { + "kind": "StructRef", + "structName": "UpgradeContracts" + }, + "prefixStr": "0xa2370f61", + "prefixLen": 32 + }, + { + "variantTy": { + "kind": "StructRef", + "structName": "UpgradeCode" + }, + "prefixStr": "0x11aefd51", + "prefixLen": 32 + }, + { + "variantTy": { + "kind": "StructRef", + "structName": "ResetRoot" + }, + "prefixStr": "0x563c1d96", + "prefixLen": 32 + }, + { + "variantTy": { + "kind": "StructRef", + "structName": "UpgradeFull" + }, + "prefixStr": "0x4f7c5789", + "prefixLen": 32 + }, + { + "variantTy": { + "kind": "StructRef", + "structName": "ChangeOwner" + }, + "prefixStr": "0xc4a1ae54", + "prefixLen": 32 + } + ] + } + }, + { + "kind": "Alias", + "name": "dict", + "targetTy": { + "kind": "nullable", + "inner": { + "kind": "cell" + } + } + } + ], + "incomingMessages": [ + { + "bodyTy": { + "kind": "StructRef", + "structName": "AddWorkerType" + } + }, + { + "bodyTy": { + "kind": "StructRef", + "structName": "DelWorkerType" + } + }, + { + "bodyTy": { + "kind": "StructRef", + "structName": "AddModelType" + } + }, + { + "bodyTy": { + "kind": "StructRef", + "structName": "DelModelType" + } + }, + { + "bodyTy": { + "kind": "StructRef", + "structName": "AddProxyType" + } + }, + { + "bodyTy": { + "kind": "StructRef", + "structName": "DelProxyType" + } + }, + { + "bodyTy": { + "kind": "StructRef", + "structName": "RegisterProxy" + } + }, + { + "bodyTy": { + "kind": "StructRef", + "structName": "UnregisterProxy" + } + }, + { + "bodyTy": { + "kind": "StructRef", + "structName": "UpdateProxy" + } + }, + { + "bodyTy": { + "kind": "StructRef", + "structName": "ChangeFees" + } + }, + { + "bodyTy": { + "kind": "StructRef", + "structName": "ChangeParams" + } + }, + { + "bodyTy": { + "kind": "StructRef", + "structName": "UpgradeContracts" + } + }, + { + "bodyTy": { + "kind": "StructRef", + "structName": "UpgradeCode" + } + }, + { + "bodyTy": { + "kind": "StructRef", + "structName": "ResetRoot" + } + }, + { + "bodyTy": { + "kind": "StructRef", + "structName": "UpgradeFull" + } + }, + { + "bodyTy": { + "kind": "StructRef", + "structName": "ChangeOwner" + } + } + ], + "outgoingMessages": [ + { + "bodyTy": { + "kind": "StructRef", + "structName": "ReturnExcessesBack" + } + }, + { + "bodyTy": { + "kind": "StructRef", + "structName": "Payout" + } + } + ], + "emittedEvents": [], + "storage": { + "storageTy": { + "kind": "StructRef", + "structName": "RootStorage" + } + }, + "getMethods": [ + { + "tvmMethodId": 65647, + "name": "last_proxy_seqno", + "parameters": [], + "returnTy": { + "kind": "int" + } + }, + { + "tvmMethodId": 96613, + "name": "get_cocoon_data", + "parameters": [], + "returnTy": { + "kind": "tensor", + "items": [ + { + "kind": "int" + }, + { + "kind": "int" + }, + { + "kind": "int" + }, + { + "kind": "int" + }, + { + "kind": "int" + }, + { + "kind": "int" + }, + { + "kind": "int" + }, + { + "kind": "int" + }, + { + "kind": "int" + }, + { + "kind": "slice" + } + ] + } + }, + { + "tvmMethodId": 89457, + "name": "get_cur_params", + "parameters": [], + "returnTy": { + "kind": "tensor", + "items": [ + { + "kind": "int" + }, + { + "kind": "int" + }, + { + "kind": "int" + }, + { + "kind": "int" + }, + { + "kind": "int" + }, + { + "kind": "int" + }, + { + "kind": "int" + }, + { + "kind": "int" + }, + { + "kind": "int" + }, + { + "kind": "int" + }, + { + "kind": "int" + }, + { + "kind": "int" + }, + { + "kind": "int" + }, + { + "kind": "int" + } + ] + } + }, + { + "tvmMethodId": 129381, + "name": "proxy_hash_is_valid", + "parameters": [ + { + "name": "hash", + "ty": { + "kind": "int" + } + } + ], + "returnTy": { + "kind": "int" + } + }, + { + "tvmMethodId": 95753, + "name": "worker_hash_is_valid", + "parameters": [ + { + "name": "hash", + "ty": { + "kind": "int" + } + } + ], + "returnTy": { + "kind": "int" + } + }, + { + "tvmMethodId": 72587, + "name": "model_hash_is_valid", + "parameters": [ + { + "name": "hash", + "ty": { + "kind": "int" + } + } + ], + "returnTy": { + "kind": "int" + } + } + ], + "thrownErrors": [ + { + "constName": "ERROR_MSG_FORMAT_MISMATCH", + "errCode": 1004 + }, + { + "constName": "ERROR_SIGNED_MSG_FORMAT_MISMATCH", + "errCode": 1005 + }, + { + "constName": "ERROR_BAD_SIGNATURE", + "errCode": 1007 + }, + { + "constName": "ERROR_EXPECTED_MESSAGE_FROM_OWNER", + "errCode": 1010 + }, + { + "constName": "ERROR_UNKNOWN_PROXY_TYPE", + "errCode": 2000 + } + ], + "compilerName": "tolk", + "compilerVersion": "1.2.0", + "codeBoc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BIA8QAFW/yy9qJofSQY6Y+Y6moY6Oh6AnoCGOmPmPoCGPoCGOjBg/oHN9CYv7hxgkAgFIERICASATFAA/sBv7UTQ+kgx0x8x1NQx0dD0BDH0BDHTH/QEMfQEMdGAAVbLi+1E0PpIMdMfMdTUMdHQ9AQx9AQx0x8x9AQx9ATRgwf0Dm+hMX9w4wSAAvbeuPaiaH0kGOmPmOoY6mjoaYOY6Y/pj+kAfQB9AGmPmOmP6Y+Y6Y/pj+mP/QB9AHoCegJ6AmiFuLhxghE3WcmBfIBJGThxELdZyYD8gEkYuHEVt1nJhfyASR24cSDYQAgFYFRYAVa8E9qJofSQY6Y+Y6moY6Oh6Ahj6AmmPmPoCGPoCGOjBg/oHN9CYv7hxgkAAu6yy9qJofSRpj+pqaIDoegIY+gIY6Y/6Ahj6AhjogOhpg5jpj+mP6QB9AH0AaY+Y6Y+Y6Y+Y6Y+Y6Y+Y6Y+Y/QB9AHoCGPoCGPoCGOiCOLhxgghEiDwIM4KDCBogmEA=" +} \ No newline at end of file diff --git a/abi-tolk/schemas/cocoon_wallet.json b/abi-tolk/schemas/cocoon_wallet.json new file mode 100644 index 00000000..2e23bc9e --- /dev/null +++ b/abi-tolk/schemas/cocoon_wallet.json @@ -0,0 +1,1899 @@ +{ + "namespace": "ton.cocoon", + "contractName": "Wallet", + "declarations": [ + { + "kind": "Struct", + "name": "ReturnExcessesBack", + "prefix": { + "prefixStr": "0x2565934c", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + } + ] + }, + { + "kind": "Struct", + "name": "Payout", + "prefix": { + "prefixStr": "0xc59a7cd3", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + } + ] + }, + { + "kind": "Struct", + "name": "WorkerProxyRequest", + "prefix": { + "prefixStr": "0x4d725d2c", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "ownerAddress", + "ty": { + "kind": "address" + } + }, + { + "name": "state", + "ty": { + "kind": "uintN", + "n": 2 + } + }, + { + "name": "tokens", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "payload", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cell" + } + } + } + ] + }, + { + "kind": "Struct", + "name": "WorkerProxyPayoutRequest", + "prefix": { + "prefixStr": "0x08e7d036", + "prefixLen": 32 + }, + "fields": [ + { + "name": "workerPart", + "ty": { + "kind": "coins" + } + }, + { + "name": "proxyPart", + "ty": { + "kind": "coins" + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "ClientStateData", + "fields": [ + { + "name": "state", + "ty": { + "kind": "uintN", + "n": 2 + } + }, + { + "name": "balance", + "ty": { + "kind": "coins" + } + }, + { + "name": "stake", + "ty": { + "kind": "coins" + } + }, + { + "name": "tokensUsed", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "secretHash", + "ty": { + "kind": "uintN", + "n": 256 + } + } + ] + }, + { + "kind": "Struct", + "name": "ClientProxyRequest", + "prefix": { + "prefixStr": "0x65448ff4", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "ownerAddress", + "ty": { + "kind": "address" + } + }, + { + "name": "stateData", + "ty": { + "kind": "cellOf", + "inner": { + "kind": "StructRef", + "structName": "ClientStateData" + } + } + }, + { + "name": "payload", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cell" + } + } + } + ] + }, + { + "kind": "Struct", + "name": "ClientProxyTopUp", + "prefix": { + "prefixStr": "0x5cfc6b87", + "prefixLen": 32 + }, + "fields": [ + { + "name": "topUpCoins", + "ty": { + "kind": "coins" + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "ClientProxyRegister", + "prefix": { + "prefixStr": "0xa35cb580", + "prefixLen": 32 + }, + "fields": [] + }, + { + "kind": "Struct", + "name": "ClientProxyRefundGranted", + "prefix": { + "prefixStr": "0xc68ebc7b", + "prefixLen": 32 + }, + "fields": [ + { + "name": "coins", + "ty": { + "kind": "coins" + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "ClientProxyRefundForce", + "prefix": { + "prefixStr": "0xf4c354c9", + "prefixLen": 32 + }, + "fields": [ + { + "name": "coins", + "ty": { + "kind": "coins" + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "QueryHeader", + "fields": [ + { + "name": "op", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + } + ] + }, + { + "kind": "Struct", + "name": "SignedMessage", + "fields": [ + { + "name": "op", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "address" + } + }, + { + "name": "signature", + "ty": { + "kind": "bitsN", + "n": 512 + } + }, + { + "name": "signedDataCell", + "ty": { + "kind": "cell" + } + } + ] + }, + { + "kind": "Struct", + "name": "PayoutPayloadData", + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "newTokens", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "expectedMyAddress", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "PayoutPayload", + "prefix": { + "prefixStr": "0xa040ad28", + "prefixLen": 32 + }, + "fields": [ + { + "name": "data", + "ty": { + "kind": "StructRef", + "structName": "PayoutPayloadData" + } + } + ] + }, + { + "kind": "Struct", + "name": "LastPayoutPayload", + "prefix": { + "prefixStr": "0xf5f26a36", + "prefixLen": 32 + }, + "fields": [ + { + "name": "data", + "ty": { + "kind": "StructRef", + "structName": "PayoutPayloadData" + } + } + ] + }, + { + "kind": "Struct", + "name": "AddWorkerType", + "prefix": { + "prefixStr": "0xe34b1c60", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "workerHash", + "ty": { + "kind": "uintN", + "n": 256 + } + } + ] + }, + { + "kind": "Struct", + "name": "DelWorkerType", + "prefix": { + "prefixStr": "0x8d94a79a", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "workerHash", + "ty": { + "kind": "uintN", + "n": 256 + } + } + ] + }, + { + "kind": "Struct", + "name": "AddModelType", + "prefix": { + "prefixStr": "0xc146134d", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "modelHash", + "ty": { + "kind": "uintN", + "n": 256 + } + } + ] + }, + { + "kind": "Struct", + "name": "DelModelType", + "prefix": { + "prefixStr": "0x92b11c18", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "modelHash", + "ty": { + "kind": "uintN", + "n": 256 + } + } + ] + }, + { + "kind": "Struct", + "name": "AddProxyType", + "prefix": { + "prefixStr": "0x71860e80", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "proxyHash", + "ty": { + "kind": "uintN", + "n": 256 + } + } + ] + }, + { + "kind": "Struct", + "name": "DelProxyType", + "prefix": { + "prefixStr": "0x3c41d0b2", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "proxyHash", + "ty": { + "kind": "uintN", + "n": 256 + } + } + ] + }, + { + "kind": "Struct", + "name": "RegisterProxy", + "prefix": { + "prefixStr": "0x927c7cb5", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "proxyInfo", + "ty": { + "kind": "remaining" + } + } + ] + }, + { + "kind": "Struct", + "name": "UnregisterProxy", + "prefix": { + "prefixStr": "0x6d49eaf2", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "seqno", + "ty": { + "kind": "uintN", + "n": 32 + } + } + ] + }, + { + "kind": "Struct", + "name": "UpdateProxy", + "prefix": { + "prefixStr": "0x9c7924ba", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "seqno", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "proxyAddr", + "ty": { + "kind": "remaining" + } + } + ] + }, + { + "kind": "Struct", + "name": "ChangeFees", + "prefix": { + "prefixStr": "0xc52ed8d4", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "pricePerToken", + "ty": { + "kind": "coins" + } + }, + { + "name": "workerFeePerToken", + "ty": { + "kind": "coins" + } + } + ] + }, + { + "kind": "Struct", + "name": "ChangeParams", + "prefix": { + "prefixStr": "0x022fa189", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "pricePerToken", + "ty": { + "kind": "coins" + } + }, + { + "name": "workerFeePerToken", + "ty": { + "kind": "coins" + } + }, + { + "name": "proxyDelayBeforeClose", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "clientDelayBeforeClose", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "minProxyStake", + "ty": { + "kind": "coins" + } + }, + { + "name": "minClientStake", + "ty": { + "kind": "coins" + } + } + ] + }, + { + "kind": "Struct", + "name": "UpgradeContracts", + "prefix": { + "prefixStr": "0xa2370f61", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "proxyCode", + "ty": { + "kind": "cell" + } + }, + { + "name": "workerCode", + "ty": { + "kind": "cell" + } + }, + { + "name": "clientCode", + "ty": { + "kind": "cell" + } + } + ] + }, + { + "kind": "Struct", + "name": "UpgradeCode", + "prefix": { + "prefixStr": "0x11aefd51", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "newCode", + "ty": { + "kind": "cell" + } + } + ] + }, + { + "kind": "Struct", + "name": "ResetRoot", + "prefix": { + "prefixStr": "0x563c1d96", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + } + ] + }, + { + "kind": "Struct", + "name": "UpgradeFull", + "prefix": { + "prefixStr": "0x4f7c5789", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "newData", + "ty": { + "kind": "cell" + } + }, + { + "name": "newCode", + "ty": { + "kind": "cell" + } + } + ] + }, + { + "kind": "Struct", + "name": "ChangeOwner", + "prefix": { + "prefixStr": "0xc4a1ae54", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "newOwnerAddress", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "OwnerWorkerRegister", + "prefix": { + "prefixStr": "0x26ed7f65", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "ExtProxyPayoutRequest", + "prefix": { + "prefixStr": "0x7610e6eb", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "ExtProxyIncreaseStake", + "prefix": { + "prefixStr": "0x9713f187", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "grams", + "ty": { + "kind": "coins" + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "OwnerProxyClose", + "prefix": { + "prefixStr": "0xb51d5a01", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "CloseRequestPayload", + "prefix": { + "prefixStr": "0x636a4391", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "expectedMyAddress", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "CloseCompleteRequestPayload", + "prefix": { + "prefixStr": "0xe511abc7", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "expectedMyAddress", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "ExtClientTopUp", + "prefix": { + "prefixStr": "0xf172e6c2", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "topUpAmount", + "ty": { + "kind": "coins" + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "OwnerClientChangeSecretHashAndTopUp", + "prefix": { + "prefixStr": "0x8473b408", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "topUpAmount", + "ty": { + "kind": "coins" + } + }, + { + "name": "newSecretHash", + "ty": { + "kind": "uintN", + "n": 256 + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "OwnerClientRegister", + "prefix": { + "prefixStr": "0xc45f9f3b", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "nonce", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "OwnerClientChangeSecretHash", + "prefix": { + "prefixStr": "0xa9357034", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "newSecretHash", + "ty": { + "kind": "uintN", + "n": 256 + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "OwnerClientIncreaseStake", + "prefix": { + "prefixStr": "0x6a1f6a60", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "newStake", + "ty": { + "kind": "coins" + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "OwnerClientWithdraw", + "prefix": { + "prefixStr": "0xda068e78", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "OwnerClientRequestRefund", + "prefix": { + "prefixStr": "0xfafa6cc1", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "ChargePayload", + "prefix": { + "prefixStr": "0xbb63ff93", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "newTokensUsed", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "expectedMyAddress", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "GrantRefundPayload", + "prefix": { + "prefixStr": "0xefd711e1", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "newTokensUsed", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "expectedMyAddress", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "CocoonParams", + "fields": [ + { + "name": "structVersion", + "ty": { + "kind": "uintN", + "n": 8 + } + }, + { + "name": "paramsVersion", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "uniqueId", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "isTest", + "ty": { + "kind": "bool" + } + }, + { + "name": "pricePerToken", + "ty": { + "kind": "coins" + } + }, + { + "name": "workerFeePerToken", + "ty": { + "kind": "coins" + } + }, + { + "name": "promptTokensPriceMultiplier", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "cachedTokensPriceMultiplier", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "completionTokensPriceMultiplier", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "reasoningTokensPriceMultiplier", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "proxyDelayBeforeClose", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "clientDelayBeforeClose", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "minProxyStake", + "ty": { + "kind": "coins" + } + }, + { + "name": "minClientStake", + "ty": { + "kind": "coins" + } + }, + { + "name": "proxyScCode", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cell" + } + } + }, + { + "name": "workerScCode", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cell" + } + } + }, + { + "name": "clientScCode", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cell" + } + } + } + ] + }, + { + "kind": "Struct", + "name": "RootData", + "fields": [ + { + "name": "proxyHashes", + "ty": { + "kind": "AliasRef", + "aliasName": "dict" + } + }, + { + "name": "workerHashes", + "ty": { + "kind": "AliasRef", + "aliasName": "dict" + } + }, + { + "name": "lastProxySeqno", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "registeredProxies", + "ty": { + "kind": "AliasRef", + "aliasName": "dict" + } + }, + { + "name": "modelHashes", + "ty": { + "kind": "AliasRef", + "aliasName": "dict" + } + } + ] + }, + { + "kind": "Struct", + "name": "RootStorage", + "fields": [ + { + "name": "ownerAddress", + "ty": { + "kind": "address" + } + }, + { + "name": "version", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "data", + "ty": { + "kind": "cellOf", + "inner": { + "kind": "StructRef", + "structName": "RootData" + } + } + }, + { + "name": "params", + "ty": { + "kind": "cellOf", + "inner": { + "kind": "StructRef", + "structName": "CocoonParams" + } + } + } + ] + }, + { + "kind": "Struct", + "name": "ProxyStorage", + "fields": [ + { + "name": "ownerAddress", + "ty": { + "kind": "address" + } + }, + { + "name": "proxyPublicKey", + "ty": { + "kind": "uintN", + "n": 256 + } + }, + { + "name": "rootAddress", + "ty": { + "kind": "address" + } + }, + { + "name": "state", + "ty": { + "kind": "uintN", + "n": 2 + } + }, + { + "name": "balance", + "ty": { + "kind": "coins" + } + }, + { + "name": "stake", + "ty": { + "kind": "coins" + } + }, + { + "name": "unlockTs", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "params", + "ty": { + "kind": "cellOf", + "inner": { + "kind": "StructRef", + "structName": "CocoonParams" + } + } + } + ] + }, + { + "kind": "Struct", + "name": "WorkerStorage", + "fields": [ + { + "name": "ownerAddress", + "ty": { + "kind": "address" + } + }, + { + "name": "proxyAddress", + "ty": { + "kind": "address" + } + }, + { + "name": "proxyPublicKey", + "ty": { + "kind": "uintN", + "n": 256 + } + }, + { + "name": "state", + "ty": { + "kind": "uintN", + "n": 2 + } + }, + { + "name": "tokens", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "params", + "ty": { + "kind": "cellOf", + "inner": { + "kind": "StructRef", + "structName": "CocoonParams" + } + } + } + ] + }, + { + "kind": "Struct", + "name": "ClientConstData", + "fields": [ + { + "name": "ownerAddress", + "ty": { + "kind": "address" + } + }, + { + "name": "proxyAddress", + "ty": { + "kind": "address" + } + }, + { + "name": "proxyPublicKey", + "ty": { + "kind": "uintN", + "n": 256 + } + } + ] + }, + { + "kind": "Struct", + "name": "ClientStorage", + "fields": [ + { + "name": "state", + "ty": { + "kind": "uintN", + "n": 2 + } + }, + { + "name": "balance", + "ty": { + "kind": "coins" + } + }, + { + "name": "stake", + "ty": { + "kind": "coins" + } + }, + { + "name": "tokensUsed", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "unlockTs", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "secretHash", + "ty": { + "kind": "uintN", + "n": 256 + } + }, + { + "name": "constDataRef", + "ty": { + "kind": "cellOf", + "inner": { + "kind": "StructRef", + "structName": "ClientConstData" + } + } + }, + { + "name": "params", + "ty": { + "kind": "cellOf", + "inner": { + "kind": "StructRef", + "structName": "CocoonParams" + } + } + } + ] + }, + { + "kind": "Struct", + "name": "WalletStorage", + "fields": [ + { + "name": "seqno", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "subwalletId", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "publicKey", + "ty": { + "kind": "uintN", + "n": 256 + } + }, + { + "name": "status", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "ownerAddress", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "ExternalSignedMessage", + "fields": [ + { + "name": "subwalletId", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "validUntil", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "msgSeqno", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "rest", + "ty": { + "kind": "remaining" + } + } + ] + }, + { + "kind": "Struct", + "name": "OwnerWalletSendMessage", + "prefix": { + "prefixStr": "0x9c69f376", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "mode", + "ty": { + "kind": "uintN", + "n": 8 + } + }, + { + "name": "body", + "ty": { + "kind": "cell" + } + } + ] + }, + { + "kind": "Struct", + "name": "TextCommand", + "prefix": { + "prefixStr": "0x00000000", + "prefixLen": 32 + }, + "fields": [ + { + "name": "action", + "ty": { + "kind": "uintN", + "n": 8 + } + } + ] + }, + { + "kind": "Alias", + "name": "AllowedInternalMessage", + "targetTy": { + "kind": "union", + "variants": [ + { + "variantTy": { + "kind": "StructRef", + "structName": "OwnerWalletSendMessage" + }, + "prefixStr": "0x9c69f376", + "prefixLen": 32 + }, + { + "variantTy": { + "kind": "StructRef", + "structName": "TextCommand" + }, + "prefixStr": "0x00000000", + "prefixLen": 32 + } + ] + } + }, + { + "kind": "Alias", + "name": "dict", + "targetTy": { + "kind": "nullable", + "inner": { + "kind": "cell" + } + } + } + ], + "incomingMessages": [ + { + "bodyTy": { + "kind": "StructRef", + "structName": "OwnerWalletSendMessage" + } + }, + { + "bodyTy": { + "kind": "StructRef", + "structName": "TextCommand" + } + } + ], + "outgoingMessages": [ + { + "bodyTy": { + "kind": "StructRef", + "structName": "ReturnExcessesBack" + } + }, + { + "bodyTy": { + "kind": "StructRef", + "structName": "Payout" + } + }, + { + "bodyTy": { + "kind": "StructRef", + "structName": "TextCommand" + } + } + ], + "emittedEvents": [], + "storage": { + "storageTy": { + "kind": "StructRef", + "structName": "WalletStorage" + } + }, + "getMethods": [ + { + "tvmMethodId": 85143, + "name": "seqno", + "parameters": [], + "returnTy": { + "kind": "int" + } + }, + { + "tvmMethodId": 78748, + "name": "get_public_key", + "parameters": [], + "returnTy": { + "kind": "int" + } + }, + { + "tvmMethodId": 114619, + "name": "get_owner_address", + "parameters": [], + "returnTy": { + "kind": "address" + } + } + ], + "thrownErrors": [ + { + "constName": "ERROR_SIGNED_MSG_FORMAT_MISMATCH", + "errCode": 1005 + }, + { + "constName": "ERROR_BAD_SIGNATURE", + "errCode": 1007 + }, + { + "constName": "", + "errCode": 1030 + }, + { + "constName": "", + "errCode": 1031 + }, + { + "constName": "", + "errCode": 1032 + }, + { + "constName": "", + "errCode": 1033 + }, + { + "constName": "", + "errCode": 1034 + }, + { + "constName": "", + "errCode": 1035 + }, + { + "constName": "", + "errCode": 1040 + }, + { + "constName": "", + "errCode": 1041 + } + ], + "compilerName": "tolk", + "compilerVersion": "1.2.0", + "codeBoc64": "te6ccgECCwEAAX8AART/APSkE/S88sgLAQIBIAIDAgFIBAUA4vKDCNcYINMf0x/THwL4I7zy5AbtRNDTH9Mf0//TH/pI0SFxsPLUB1FUuvLkCFFiuvLkCQb5AVQQdvkQ8uQK+CdvEIIQdzWUAL7y5Av4AJUi10rCAJgC0wfUAvsAAuhsEqTIyx8Uyx8Sy//LH/pSye1UAdjQ+JHyQCDHAJEw4CDXCx8gghAlZZNMupF/miCCEMWafNO6wwDikjB/mYIQmhJHwLrDAOKRMODtRNCBAUDXGNMfIPpIMPiSxwXy5BAD1ywk40+btJxsMdM/MdMH10wB+wDg1ywgAAAABOMC8j8GAgEgBwgAotcLByDAd44cXwSCCJiWgHL7AviSyM+FiPpSgHfPC5bJgwb7AI4qIMBinDBxsQHIzssfzsntVI4XwHWT8sQR4YIQ/////rAByM7LH87J7VTi4gIBIAkKABu9/d9qJoQICwa5D9JBhAAXuznO1E0NM/MdcL/4ABG4yX7UTQ1wsfg=" +} \ No newline at end of file diff --git a/abi-tolk/schemas/cocoon_worker.json b/abi-tolk/schemas/cocoon_worker.json new file mode 100644 index 00000000..748d6596 --- /dev/null +++ b/abi-tolk/schemas/cocoon_worker.json @@ -0,0 +1,1904 @@ +{ + "namespace": "ton.cocoon", + "contractName": "Worker", + "declarations": [ + { + "kind": "Struct", + "name": "ReturnExcessesBack", + "prefix": { + "prefixStr": "0x2565934c", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + } + ] + }, + { + "kind": "Struct", + "name": "Payout", + "prefix": { + "prefixStr": "0xc59a7cd3", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + } + ] + }, + { + "kind": "Struct", + "name": "WorkerProxyRequest", + "prefix": { + "prefixStr": "0x4d725d2c", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "ownerAddress", + "ty": { + "kind": "address" + } + }, + { + "name": "state", + "ty": { + "kind": "uintN", + "n": 2 + } + }, + { + "name": "tokens", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "payload", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cell" + } + } + } + ] + }, + { + "kind": "Struct", + "name": "WorkerProxyPayoutRequest", + "prefix": { + "prefixStr": "0x08e7d036", + "prefixLen": 32 + }, + "fields": [ + { + "name": "workerPart", + "ty": { + "kind": "coins" + } + }, + { + "name": "proxyPart", + "ty": { + "kind": "coins" + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "ClientStateData", + "fields": [ + { + "name": "state", + "ty": { + "kind": "uintN", + "n": 2 + } + }, + { + "name": "balance", + "ty": { + "kind": "coins" + } + }, + { + "name": "stake", + "ty": { + "kind": "coins" + } + }, + { + "name": "tokensUsed", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "secretHash", + "ty": { + "kind": "uintN", + "n": 256 + } + } + ] + }, + { + "kind": "Struct", + "name": "ClientProxyRequest", + "prefix": { + "prefixStr": "0x65448ff4", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "ownerAddress", + "ty": { + "kind": "address" + } + }, + { + "name": "stateData", + "ty": { + "kind": "cellOf", + "inner": { + "kind": "StructRef", + "structName": "ClientStateData" + } + } + }, + { + "name": "payload", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cell" + } + } + } + ] + }, + { + "kind": "Struct", + "name": "ClientProxyTopUp", + "prefix": { + "prefixStr": "0x5cfc6b87", + "prefixLen": 32 + }, + "fields": [ + { + "name": "topUpCoins", + "ty": { + "kind": "coins" + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "ClientProxyRegister", + "prefix": { + "prefixStr": "0xa35cb580", + "prefixLen": 32 + }, + "fields": [] + }, + { + "kind": "Struct", + "name": "ClientProxyRefundGranted", + "prefix": { + "prefixStr": "0xc68ebc7b", + "prefixLen": 32 + }, + "fields": [ + { + "name": "coins", + "ty": { + "kind": "coins" + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "ClientProxyRefundForce", + "prefix": { + "prefixStr": "0xf4c354c9", + "prefixLen": 32 + }, + "fields": [ + { + "name": "coins", + "ty": { + "kind": "coins" + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "QueryHeader", + "fields": [ + { + "name": "op", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + } + ] + }, + { + "kind": "Struct", + "name": "SignedMessage", + "fields": [ + { + "name": "op", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "address" + } + }, + { + "name": "signature", + "ty": { + "kind": "bitsN", + "n": 512 + } + }, + { + "name": "signedDataCell", + "ty": { + "kind": "cell" + } + } + ] + }, + { + "kind": "Struct", + "name": "PayoutPayloadData", + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "newTokens", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "expectedMyAddress", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "PayoutPayload", + "prefix": { + "prefixStr": "0xa040ad28", + "prefixLen": 32 + }, + "fields": [ + { + "name": "data", + "ty": { + "kind": "StructRef", + "structName": "PayoutPayloadData" + } + } + ] + }, + { + "kind": "Struct", + "name": "LastPayoutPayload", + "prefix": { + "prefixStr": "0xf5f26a36", + "prefixLen": 32 + }, + "fields": [ + { + "name": "data", + "ty": { + "kind": "StructRef", + "structName": "PayoutPayloadData" + } + } + ] + }, + { + "kind": "Struct", + "name": "AddWorkerType", + "prefix": { + "prefixStr": "0xe34b1c60", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "workerHash", + "ty": { + "kind": "uintN", + "n": 256 + } + } + ] + }, + { + "kind": "Struct", + "name": "DelWorkerType", + "prefix": { + "prefixStr": "0x8d94a79a", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "workerHash", + "ty": { + "kind": "uintN", + "n": 256 + } + } + ] + }, + { + "kind": "Struct", + "name": "AddModelType", + "prefix": { + "prefixStr": "0xc146134d", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "modelHash", + "ty": { + "kind": "uintN", + "n": 256 + } + } + ] + }, + { + "kind": "Struct", + "name": "DelModelType", + "prefix": { + "prefixStr": "0x92b11c18", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "modelHash", + "ty": { + "kind": "uintN", + "n": 256 + } + } + ] + }, + { + "kind": "Struct", + "name": "AddProxyType", + "prefix": { + "prefixStr": "0x71860e80", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "proxyHash", + "ty": { + "kind": "uintN", + "n": 256 + } + } + ] + }, + { + "kind": "Struct", + "name": "DelProxyType", + "prefix": { + "prefixStr": "0x3c41d0b2", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "proxyHash", + "ty": { + "kind": "uintN", + "n": 256 + } + } + ] + }, + { + "kind": "Struct", + "name": "RegisterProxy", + "prefix": { + "prefixStr": "0x927c7cb5", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "proxyInfo", + "ty": { + "kind": "remaining" + } + } + ] + }, + { + "kind": "Struct", + "name": "UnregisterProxy", + "prefix": { + "prefixStr": "0x6d49eaf2", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "seqno", + "ty": { + "kind": "uintN", + "n": 32 + } + } + ] + }, + { + "kind": "Struct", + "name": "UpdateProxy", + "prefix": { + "prefixStr": "0x9c7924ba", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "seqno", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "proxyAddr", + "ty": { + "kind": "remaining" + } + } + ] + }, + { + "kind": "Struct", + "name": "ChangeFees", + "prefix": { + "prefixStr": "0xc52ed8d4", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "pricePerToken", + "ty": { + "kind": "coins" + } + }, + { + "name": "workerFeePerToken", + "ty": { + "kind": "coins" + } + } + ] + }, + { + "kind": "Struct", + "name": "ChangeParams", + "prefix": { + "prefixStr": "0x022fa189", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "pricePerToken", + "ty": { + "kind": "coins" + } + }, + { + "name": "workerFeePerToken", + "ty": { + "kind": "coins" + } + }, + { + "name": "proxyDelayBeforeClose", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "clientDelayBeforeClose", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "minProxyStake", + "ty": { + "kind": "coins" + } + }, + { + "name": "minClientStake", + "ty": { + "kind": "coins" + } + } + ] + }, + { + "kind": "Struct", + "name": "UpgradeContracts", + "prefix": { + "prefixStr": "0xa2370f61", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "proxyCode", + "ty": { + "kind": "cell" + } + }, + { + "name": "workerCode", + "ty": { + "kind": "cell" + } + }, + { + "name": "clientCode", + "ty": { + "kind": "cell" + } + } + ] + }, + { + "kind": "Struct", + "name": "UpgradeCode", + "prefix": { + "prefixStr": "0x11aefd51", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "newCode", + "ty": { + "kind": "cell" + } + } + ] + }, + { + "kind": "Struct", + "name": "ResetRoot", + "prefix": { + "prefixStr": "0x563c1d96", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + } + ] + }, + { + "kind": "Struct", + "name": "UpgradeFull", + "prefix": { + "prefixStr": "0x4f7c5789", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "newData", + "ty": { + "kind": "cell" + } + }, + { + "name": "newCode", + "ty": { + "kind": "cell" + } + } + ] + }, + { + "kind": "Struct", + "name": "ChangeOwner", + "prefix": { + "prefixStr": "0xc4a1ae54", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "newOwnerAddress", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "OwnerWorkerRegister", + "prefix": { + "prefixStr": "0x26ed7f65", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "ExtProxyPayoutRequest", + "prefix": { + "prefixStr": "0x7610e6eb", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "ExtProxyIncreaseStake", + "prefix": { + "prefixStr": "0x9713f187", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "grams", + "ty": { + "kind": "coins" + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "OwnerProxyClose", + "prefix": { + "prefixStr": "0xb51d5a01", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "CloseRequestPayload", + "prefix": { + "prefixStr": "0x636a4391", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "expectedMyAddress", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "CloseCompleteRequestPayload", + "prefix": { + "prefixStr": "0xe511abc7", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "expectedMyAddress", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "ExtClientTopUp", + "prefix": { + "prefixStr": "0xf172e6c2", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "topUpAmount", + "ty": { + "kind": "coins" + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "OwnerClientChangeSecretHashAndTopUp", + "prefix": { + "prefixStr": "0x8473b408", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "topUpAmount", + "ty": { + "kind": "coins" + } + }, + { + "name": "newSecretHash", + "ty": { + "kind": "uintN", + "n": 256 + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "OwnerClientRegister", + "prefix": { + "prefixStr": "0xc45f9f3b", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "nonce", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "OwnerClientChangeSecretHash", + "prefix": { + "prefixStr": "0xa9357034", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "newSecretHash", + "ty": { + "kind": "uintN", + "n": 256 + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "OwnerClientIncreaseStake", + "prefix": { + "prefixStr": "0x6a1f6a60", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "newStake", + "ty": { + "kind": "coins" + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "OwnerClientWithdraw", + "prefix": { + "prefixStr": "0xda068e78", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "OwnerClientRequestRefund", + "prefix": { + "prefixStr": "0xfafa6cc1", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "ChargePayload", + "prefix": { + "prefixStr": "0xbb63ff93", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "newTokensUsed", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "expectedMyAddress", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "GrantRefundPayload", + "prefix": { + "prefixStr": "0xefd711e1", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "newTokensUsed", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "expectedMyAddress", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "CocoonParams", + "fields": [ + { + "name": "structVersion", + "ty": { + "kind": "uintN", + "n": 8 + } + }, + { + "name": "paramsVersion", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "uniqueId", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "isTest", + "ty": { + "kind": "bool" + } + }, + { + "name": "pricePerToken", + "ty": { + "kind": "coins" + } + }, + { + "name": "workerFeePerToken", + "ty": { + "kind": "coins" + } + }, + { + "name": "promptTokensPriceMultiplier", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "cachedTokensPriceMultiplier", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "completionTokensPriceMultiplier", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "reasoningTokensPriceMultiplier", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "proxyDelayBeforeClose", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "clientDelayBeforeClose", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "minProxyStake", + "ty": { + "kind": "coins" + } + }, + { + "name": "minClientStake", + "ty": { + "kind": "coins" + } + }, + { + "name": "proxyScCode", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cell" + } + } + }, + { + "name": "workerScCode", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cell" + } + } + }, + { + "name": "clientScCode", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cell" + } + } + } + ] + }, + { + "kind": "Struct", + "name": "RootData", + "fields": [ + { + "name": "proxyHashes", + "ty": { + "kind": "AliasRef", + "aliasName": "dict" + } + }, + { + "name": "workerHashes", + "ty": { + "kind": "AliasRef", + "aliasName": "dict" + } + }, + { + "name": "lastProxySeqno", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "registeredProxies", + "ty": { + "kind": "AliasRef", + "aliasName": "dict" + } + }, + { + "name": "modelHashes", + "ty": { + "kind": "AliasRef", + "aliasName": "dict" + } + } + ] + }, + { + "kind": "Struct", + "name": "RootStorage", + "fields": [ + { + "name": "ownerAddress", + "ty": { + "kind": "address" + } + }, + { + "name": "version", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "data", + "ty": { + "kind": "cellOf", + "inner": { + "kind": "StructRef", + "structName": "RootData" + } + } + }, + { + "name": "params", + "ty": { + "kind": "cellOf", + "inner": { + "kind": "StructRef", + "structName": "CocoonParams" + } + } + } + ] + }, + { + "kind": "Struct", + "name": "ProxyStorage", + "fields": [ + { + "name": "ownerAddress", + "ty": { + "kind": "address" + } + }, + { + "name": "proxyPublicKey", + "ty": { + "kind": "uintN", + "n": 256 + } + }, + { + "name": "rootAddress", + "ty": { + "kind": "address" + } + }, + { + "name": "state", + "ty": { + "kind": "uintN", + "n": 2 + } + }, + { + "name": "balance", + "ty": { + "kind": "coins" + } + }, + { + "name": "stake", + "ty": { + "kind": "coins" + } + }, + { + "name": "unlockTs", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "params", + "ty": { + "kind": "cellOf", + "inner": { + "kind": "StructRef", + "structName": "CocoonParams" + } + } + } + ] + }, + { + "kind": "Struct", + "name": "WorkerStorage", + "fields": [ + { + "name": "ownerAddress", + "ty": { + "kind": "address" + } + }, + { + "name": "proxyAddress", + "ty": { + "kind": "address" + } + }, + { + "name": "proxyPublicKey", + "ty": { + "kind": "uintN", + "n": 256 + } + }, + { + "name": "state", + "ty": { + "kind": "uintN", + "n": 2 + } + }, + { + "name": "tokens", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "params", + "ty": { + "kind": "cellOf", + "inner": { + "kind": "StructRef", + "structName": "CocoonParams" + } + } + } + ] + }, + { + "kind": "Struct", + "name": "ClientConstData", + "fields": [ + { + "name": "ownerAddress", + "ty": { + "kind": "address" + } + }, + { + "name": "proxyAddress", + "ty": { + "kind": "address" + } + }, + { + "name": "proxyPublicKey", + "ty": { + "kind": "uintN", + "n": 256 + } + } + ] + }, + { + "kind": "Struct", + "name": "ClientStorage", + "fields": [ + { + "name": "state", + "ty": { + "kind": "uintN", + "n": 2 + } + }, + { + "name": "balance", + "ty": { + "kind": "coins" + } + }, + { + "name": "stake", + "ty": { + "kind": "coins" + } + }, + { + "name": "tokensUsed", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "unlockTs", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "secretHash", + "ty": { + "kind": "uintN", + "n": 256 + } + }, + { + "name": "constDataRef", + "ty": { + "kind": "cellOf", + "inner": { + "kind": "StructRef", + "structName": "ClientConstData" + } + } + }, + { + "name": "params", + "ty": { + "kind": "cellOf", + "inner": { + "kind": "StructRef", + "structName": "CocoonParams" + } + } + } + ] + }, + { + "kind": "Struct", + "name": "WalletStorage", + "fields": [ + { + "name": "seqno", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "subwalletId", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "publicKey", + "ty": { + "kind": "uintN", + "n": 256 + } + }, + { + "name": "status", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "ownerAddress", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "ExtWorkerPayoutRequestSigned", + "prefix": { + "prefixStr": "0xa040ad28", + "prefixLen": 32 + }, + "fields": [ + { + "name": "rest", + "ty": { + "kind": "remaining" + } + } + ] + }, + { + "kind": "Struct", + "name": "ExtWorkerLastPayoutRequestSigned", + "prefix": { + "prefixStr": "0xf5f26a36", + "prefixLen": 32 + }, + "fields": [ + { + "name": "rest", + "ty": { + "kind": "remaining" + } + } + ] + }, + { + "kind": "Alias", + "name": "SignedWorkerMessage", + "targetTy": { + "kind": "union", + "variants": [ + { + "variantTy": { + "kind": "StructRef", + "structName": "ExtWorkerPayoutRequestSigned" + }, + "prefixStr": "0xa040ad28", + "prefixLen": 32 + }, + { + "variantTy": { + "kind": "StructRef", + "structName": "ExtWorkerLastPayoutRequestSigned" + }, + "prefixStr": "0xf5f26a36", + "prefixLen": 32 + } + ] + } + }, + { + "kind": "Alias", + "name": "SignedPayload", + "targetTy": { + "kind": "union", + "variants": [ + { + "variantTy": { + "kind": "StructRef", + "structName": "PayoutPayload" + }, + "prefixStr": "0xa040ad28", + "prefixLen": 32 + }, + { + "variantTy": { + "kind": "StructRef", + "structName": "LastPayoutPayload" + }, + "prefixStr": "0xf5f26a36", + "prefixLen": 32 + } + ] + } + }, + { + "kind": "Alias", + "name": "WorkerMessage", + "targetTy": { + "kind": "union", + "variants": [ + { + "variantTy": { + "kind": "StructRef", + "structName": "ExtWorkerPayoutRequestSigned" + }, + "prefixStr": "0xa040ad28", + "prefixLen": 32 + }, + { + "variantTy": { + "kind": "StructRef", + "structName": "ExtWorkerLastPayoutRequestSigned" + }, + "prefixStr": "0xf5f26a36", + "prefixLen": 32 + }, + { + "variantTy": { + "kind": "StructRef", + "structName": "OwnerWorkerRegister" + }, + "prefixStr": "0x26ed7f65", + "prefixLen": 32 + } + ] + } + }, + { + "kind": "Alias", + "name": "dict", + "targetTy": { + "kind": "nullable", + "inner": { + "kind": "cell" + } + } + } + ], + "incomingMessages": [ + { + "bodyTy": { + "kind": "StructRef", + "structName": "ExtWorkerPayoutRequestSigned" + } + }, + { + "bodyTy": { + "kind": "StructRef", + "structName": "ExtWorkerLastPayoutRequestSigned" + } + }, + { + "bodyTy": { + "kind": "StructRef", + "structName": "OwnerWorkerRegister" + } + } + ], + "outgoingMessages": [ + { + "bodyTy": { + "kind": "StructRef", + "structName": "ReturnExcessesBack" + } + }, + { + "bodyTy": { + "kind": "StructRef", + "structName": "Payout" + } + }, + { + "bodyTy": { + "kind": "StructRef", + "structName": "WorkerProxyRequest" + } + } + ], + "emittedEvents": [], + "storage": { + "storageTy": { + "kind": "StructRef", + "structName": "WorkerStorage" + } + }, + "getMethods": [ + { + "tvmMethodId": 106427, + "name": "get_cocoon_worker_data", + "parameters": [], + "returnTy": { + "kind": "tensor", + "items": [ + { + "kind": "address" + }, + { + "kind": "address" + }, + { + "kind": "int" + }, + { + "kind": "int" + }, + { + "kind": "int" + } + ] + } + } + ], + "thrownErrors": [ + { + "constName": "ERROR_OLD_MESSAGE", + "errCode": 1000 + }, + { + "constName": "ERROR_LOW_MSG_VALUE", + "errCode": 1003 + }, + { + "constName": "ERROR_SIGNED_MSG_FORMAT_MISMATCH", + "errCode": 1005 + }, + { + "constName": "ERROR_CLOSED", + "errCode": 1006 + }, + { + "constName": "ERROR_BAD_SIGNATURE", + "errCode": 1007 + }, + { + "constName": "ERROR_EXPECTED_MESSAGE_FROM_OWNER", + "errCode": 1010 + }, + { + "constName": "ERROR_EXPECTED_MY_ADDRESS", + "errCode": 1015 + } + ], + "compilerName": "tolk", + "compilerVersion": "1.2.0", + "codeBoc64": "te6ccgECCgEAAg8AART/APSkE/S88sgLAQIBYgIDAgLPBAUAJaE/d9qJofSR9JGn/6YDpn+oY6MD2z4kfJAIMcAkTDg+CdvEPiXofgvoIIQBo53gLYJIdcLH4IQmhJHwLqRW+DtRND6SPpI0//TAdM/10wiwwLy4+74l4IQBfXhALzy4+sn1ywlAgVpROMC1ywnr5NRtOMCMTM2AdcsITdr+yzjAvI/gBgYHAfUMzQ0NvgoEscF8uP3BI4RMzVTMbvy4+iCCJiWgHD7AnKbU1C58uPoA3D7AgXiI9DTSDH6APoAMFJHoVMGqFAnoajIz5Ajn0DaUAb6AlAF+gIV+lLJyM+FiFJw+lKCEE1yXSzPC44Vyz9ScPpSI88LASHPCz8U9ADJgwaAJAcQwB9Mf0z/6SIMI1xjU0SD5AFMo+RDy4+8g0NMf1ws/URa68uPtJLry4+0g0NcsJQIFaUSOK9csJ6+TUbSS8j/h0z/TP/pIMBDOEL0QrBCbEIoQiRB4EGcQVhBFEDR/8AHjDQgApPiSJMcF8uPyBHD7AgPTP/pIMHFtyM+FiBX6UgH6AoIQTXJdLM8LiiLPCz8U+lIUywEUyz8T9ADJcfsAyM+FCBL6UoIQJWWTTM8Ljss/yYMG+wAAQNM/0z/6SDAQzhC9EKwQmxCKEIkQeBBnEFYQRRA0cPABACr7AAXI+lIU+lISy/8SywHLP8zJ7VQ=" +} \ No newline at end of file diff --git a/abi-tolk/schemas/coffee-pool.json b/abi-tolk/schemas/coffee-pool.json new file mode 100644 index 00000000..fb7f5678 --- /dev/null +++ b/abi-tolk/schemas/coffee-pool.json @@ -0,0 +1,67 @@ +{ + "namespace": "ton.coffee", + "contractName": "Pool", + "declarations": [ + { + "kind": "Struct", + "name": "CrossDexResend", + "prefix": { + "prefixStr": "0x200f9086", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "nextRecipient", + "ty": { + "kind": "address" + } + }, + { + "name": "next", + "ty": { + "kind": "cell" + } + }, + { + "name": "totalGas", + "ty": { + "kind": "coins" + } + }, + { + "name": "nextGas", + "ty": { + "kind": "coins" + } + } + ] + } + ], + "incomingMessages": [ + { + "bodyTy": { + "kind": "StructRef", + "structName": "CrossDexResend" + } + } + ], + "outgoingMessages": [], + "emittedEvents": [], + "storage": { + "storageTy": { + "kind": "nullLiteral" + } + }, + "getMethods": [], + "thrownErrors": [], + "compilerName": "tolk", + "compilerVersion": "1.2.0", + "codeBoc64": "te6ccgEBAgEAFQABFP8A9KQT9LzyyAsBAAzTMPiR8kA=" +} \ No newline at end of file diff --git a/abi-tolk/schemas/dedust-test.json b/abi-tolk/schemas/dedust-test.json new file mode 100644 index 00000000..c6090afb --- /dev/null +++ b/abi-tolk/schemas/dedust-test.json @@ -0,0 +1,118 @@ +{ + "namespace": "ton.dedust", + "contractName": "Pool", + "declarations": [ + { + "kind": "Struct", + "name": "Step", + "fields": [ + { + "name": "kindOut", + "ty": { + "kind": "bool" + } + }, + { + "name": "limit", + "ty": { + "kind": "varintN", + "n": 16 + } + }, + { + "name": "next", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cell" + } + } + } + ] + }, + { + "kind": "Struct", + "name": "SwapParams", + "fields": [ + { + "name": "deadline", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "recipientAddr", + "ty": { + "kind": "address" + } + }, + { + "name": "referralAddr", + "ty": { + "kind": "addressOpt" + } + }, + { + "name": "fulfillPayload", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cell" + } + } + }, + { + "name": "rejectPayload", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cell" + } + } + } + ] + }, + { + "kind": "Struct", + "name": "DedustSwap", + "payloadName": "jetton", + "prefix": { + "prefixStr": "0xe3a0d482", + "prefixLen": 32 + }, + "fields": [ + { + "name": "step", + "ty": { + "kind": "StructRef", + "structName": "Step" + } + }, + { + "name": "params", + "ty": { + "kind": "cellOf", + "inner": { + "kind": "StructRef", + "structName": "SwapParams" + } + } + } + ] + } + ], + "incomingMessages": [], + "outgoingMessages": [], + "emittedEvents": [], + "storage": { + "storageTy": { + "kind": "nullLiteral" + } + }, + "getMethods": [], + "thrownErrors": [], + "compilerName": "tolk", + "compilerVersion": "1.2.0", + "codeBoc64": "te6ccgEBAgEAFQABFP8A9KQT9LzyyAsBAAzTMPiR8kA=" +} \ No newline at end of file diff --git a/abi-tolk/schemas/jetton-minter.json b/abi-tolk/schemas/jetton-minter.json new file mode 100644 index 00000000..00c39a66 --- /dev/null +++ b/abi-tolk/schemas/jetton-minter.json @@ -0,0 +1,646 @@ +{ + "namespace": "ton.tep74", + "contractName": "JettonMinter", + "declarations": [ + { + "kind": "Struct", + "name": "WalletStorage", + "fields": [ + { + "name": "jettonBalance", + "ty": { + "kind": "coins" + }, + "defaultValue": { + "kind": "int", + "v": "0" + } + }, + { + "name": "ownerAddress", + "ty": { + "kind": "address" + } + }, + { + "name": "minterAddress", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "MinterStorage", + "fields": [ + { + "name": "totalSupply", + "ty": { + "kind": "coins" + } + }, + { + "name": "adminAddress", + "ty": { + "kind": "address" + } + }, + { + "name": "content", + "ty": { + "kind": "cell" + } + }, + { + "name": "jettonWalletCode", + "ty": { + "kind": "cell" + } + } + ] + }, + { + "kind": "Alias", + "name": "ForwardPayloadRemainder", + "targetTy": { + "kind": "remaining" + } + }, + { + "kind": "Struct", + "name": "AskToTransfer", + "prefix": { + "prefixStr": "0x0f8a7ea5", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "jettonAmount", + "ty": { + "kind": "coins" + } + }, + { + "name": "transferRecipient", + "ty": { + "kind": "address" + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "addressOpt" + } + }, + { + "name": "customPayload", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cell" + } + } + }, + { + "name": "forwardTonAmount", + "ty": { + "kind": "coins" + } + }, + { + "name": "forwardPayload", + "isPayload": true, + "ty": { + "kind": "AliasRef", + "aliasName": "ForwardPayloadRemainder" + } + } + ] + }, + { + "kind": "Struct", + "name": "TransferNotificationForRecipient", + "prefix": { + "prefixStr": "0x7362d09c", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "jettonAmount", + "ty": { + "kind": "coins" + } + }, + { + "name": "transferInitiator", + "ty": { + "kind": "addressOpt" + } + }, + { + "name": "forwardPayload", + "isPayload": true, + "ty": { + "kind": "AliasRef", + "aliasName": "ForwardPayloadRemainder" + } + } + ] + }, + { + "kind": "Struct", + "name": "InternalTransferStep", + "prefix": { + "prefixStr": "0x178d4519", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "jettonAmount", + "ty": { + "kind": "coins" + } + }, + { + "name": "transferInitiator", + "ty": { + "kind": "addressOpt" + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "addressOpt" + } + }, + { + "name": "forwardTonAmount", + "ty": { + "kind": "coins" + } + }, + { + "name": "forwardPayload", + "isPayload": true, + "ty": { + "kind": "AliasRef", + "aliasName": "ForwardPayloadRemainder" + } + } + ] + }, + { + "kind": "Struct", + "name": "ReturnExcessesBack", + "prefix": { + "prefixStr": "0xd53276db", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + } + ] + }, + { + "kind": "Struct", + "name": "AskToBurn", + "prefix": { + "prefixStr": "0x595f07bc", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "jettonAmount", + "ty": { + "kind": "coins" + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "addressOpt" + } + }, + { + "name": "customPayload", + "isPayload": true, + "ty": { + "kind": "nullable", + "inner": { + "kind": "cell" + } + } + } + ] + }, + { + "kind": "Struct", + "name": "BurnNotificationForMinter", + "prefix": { + "prefixStr": "0x7bdd97de", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "jettonAmount", + "ty": { + "kind": "coins" + } + }, + { + "name": "burnInitiator", + "ty": { + "kind": "address" + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "addressOpt" + } + } + ] + }, + { + "kind": "Struct", + "name": "RequestWalletAddress", + "prefix": { + "prefixStr": "0x2c76b973", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "ownerAddress", + "ty": { + "kind": "address" + } + }, + { + "name": "includeOwnerAddress", + "ty": { + "kind": "bool" + } + } + ] + }, + { + "kind": "Struct", + "name": "ResponseWalletAddress", + "prefix": { + "prefixStr": "0xd1735400", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "jettonWalletAddress", + "ty": { + "kind": "addressOpt" + } + }, + { + "name": "ownerAddress", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cellOf", + "inner": { + "kind": "address" + } + } + } + } + ] + }, + { + "kind": "Struct", + "name": "MintNewJettons", + "prefix": { + "prefixStr": "0x00000015", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "mintRecipient", + "ty": { + "kind": "address" + } + }, + { + "name": "tonAmount", + "ty": { + "kind": "coins" + } + }, + { + "name": "internalTransferMsg", + "ty": { + "kind": "cellOf", + "inner": { + "kind": "StructRef", + "structName": "InternalTransferStep" + } + } + } + ] + }, + { + "kind": "Struct", + "name": "ChangeMinterAdmin", + "prefix": { + "prefixStr": "0x00000003", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "newAdminAddress", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "ChangeMinterContent", + "prefix": { + "prefixStr": "0x00000004", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "newContent", + "ty": { + "kind": "cell" + } + } + ] + }, + { + "kind": "Alias", + "name": "AllowedMessageToMinter", + "targetTy": { + "kind": "union", + "variants": [ + { + "variantTy": { + "kind": "StructRef", + "structName": "MintNewJettons" + }, + "prefixStr": "0x00000015", + "prefixLen": 32 + }, + { + "variantTy": { + "kind": "StructRef", + "structName": "BurnNotificationForMinter" + }, + "prefixStr": "0x7bdd97de", + "prefixLen": 32 + }, + { + "variantTy": { + "kind": "StructRef", + "structName": "RequestWalletAddress" + }, + "prefixStr": "0x2c76b973", + "prefixLen": 32 + }, + { + "variantTy": { + "kind": "StructRef", + "structName": "ChangeMinterAdmin" + }, + "prefixStr": "0x00000003", + "prefixLen": 32 + }, + { + "variantTy": { + "kind": "StructRef", + "structName": "ChangeMinterContent" + }, + "prefixStr": "0x00000004", + "prefixLen": 32 + } + ] + } + }, + { + "kind": "Struct", + "name": "JettonDataReply", + "fields": [ + { + "name": "totalSupply", + "ty": { + "kind": "int" + } + }, + { + "name": "mintable", + "ty": { + "kind": "bool" + } + }, + { + "name": "adminAddress", + "ty": { + "kind": "address" + } + }, + { + "name": "jettonContent", + "ty": { + "kind": "cell" + } + }, + { + "name": "jettonWalletCode", + "ty": { + "kind": "cell" + } + } + ] + } + ], + "incomingMessages": [ + { + "bodyTy": { + "kind": "StructRef", + "structName": "MintNewJettons" + } + }, + { + "bodyTy": { + "kind": "StructRef", + "structName": "BurnNotificationForMinter" + } + }, + { + "bodyTy": { + "kind": "StructRef", + "structName": "RequestWalletAddress" + } + }, + { + "bodyTy": { + "kind": "StructRef", + "structName": "ChangeMinterAdmin" + } + }, + { + "bodyTy": { + "kind": "StructRef", + "structName": "ChangeMinterContent" + } + } + ], + "outgoingMessages": [ + { + "bodyTy": { + "kind": "StructRef", + "structName": "ReturnExcessesBack" + } + }, + { + "bodyTy": { + "kind": "StructRef", + "structName": "ResponseWalletAddress" + } + }, + { + "bodyTy": { + "kind": "StructRef", + "structName": "InternalTransferStep" + } + } + ], + "emittedEvents": [], + "storage": { + "storageTy": { + "kind": "StructRef", + "structName": "MinterStorage" + } + }, + "getMethods": [ + { + "tvmMethodId": 106029, + "name": "get_jetton_data", + "parameters": [], + "returnTy": { + "kind": "StructRef", + "structName": "JettonDataReply" + } + }, + { + "tvmMethodId": 103289, + "name": "get_wallet_address", + "parameters": [ + { + "name": "ownerAddress", + "ty": { + "kind": "address" + } + } + ], + "returnTy": { + "kind": "address" + } + } + ], + "thrownErrors": [ + { + "constName": "ERR_NOT_FROM_ADMIN", + "errCode": 73 + }, + { + "constName": "ERR_UNAUTHORIZED_BURN", + "errCode": 74 + }, + { + "constName": "ERR_NOT_ENOUGH_AMOUNT_TO_RESPOND", + "errCode": 75 + }, + { + "constName": "", + "errCode": 65535 + } + ], + "compilerName": "tolk", + "compilerVersion": "1.2.0", + "codeBoc64": "te6ccgECDAEAAioAART/APSkE/S88sgLAQIBYgIDAvjQ+JHyQCDXLCPe7L70jmMx7UTQAdM/+gD6SPpQMAT6ACDUMddM+JL4KMjPhCAW+lIV+lLJAcjPhNDMzPkWyM+KAEDL/89QE8cF8uBKWKHIAfoCzsntVCFukVvgyM+FCBL6UoIQ1TJ2288Ljss/yYBC+wDg1ywhY7XLnOMCBAUCA3pgCgsA5jH4l/iTcPg6ggiYloCgvPLgS9M/+kjXCgCVIMj6UsmRbeJtIvpEMMAAjigw7UTQ1DHXTPgoyM+EIBT6UhP6UslYyM+E0MzM+RbIz4oAQMv/z1ABkTLi+JLIz4WI+lKCENFzVADPC44Tyz/6VPQAyYBA+wAE+onXJ45rMe1E0PoAIPpI1DHXTPiSWMcF8uBJA9M/MfpI+gDXTCDQ1ywgvGoozPK/0z8x+gAwFaDIAfoCE87J7VT4KMjPhCAS+lL6UsnIz4mIAVMUyM+E0MzM+RbPC/9Y+gKBAI3PC3ATzBLMzMlx+wDg1ywgAAAAHOMCidcnBgcICQAIAAAAFQBCMe1E0PoA+kj4kljHBfLgSQLTPzH6SDDIWPoC+lLOye1UAAgAAAAEAFiOITHtRND6APpI1DH4kiLHBfLgSQPXTMhQA/oC+lLMzsntVOAwhA8BxwDy9ABRrbz2omhqGOumfBRkZ8IQCf0pCX0pZIDkZ8JoZmZ8i2RnxQAgZf/nqEAAH68W9qJofQB9JGprpj+qkEA=" +} \ No newline at end of file diff --git a/abi-tolk/schemas/jetton-wallet.json b/abi-tolk/schemas/jetton-wallet.json new file mode 100644 index 00000000..46ed108a --- /dev/null +++ b/abi-tolk/schemas/jetton-wallet.json @@ -0,0 +1,655 @@ +{ + "namespace": "ton.tep74", + "contractName": "JettonWallet", + "declarations": [ + { + "kind": "Struct", + "name": "WalletStorage", + "fields": [ + { + "name": "jettonBalance", + "ty": { + "kind": "coins" + }, + "defaultValue": { + "kind": "int", + "v": "0" + } + }, + { + "name": "ownerAddress", + "ty": { + "kind": "address" + } + }, + { + "name": "minterAddress", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "MinterStorage", + "fields": [ + { + "name": "totalSupply", + "ty": { + "kind": "coins" + } + }, + { + "name": "adminAddress", + "ty": { + "kind": "address" + } + }, + { + "name": "content", + "ty": { + "kind": "cell" + } + }, + { + "name": "jettonWalletCode", + "ty": { + "kind": "cell" + } + } + ] + }, + { + "kind": "Alias", + "name": "ForwardPayloadRemainder", + "targetTy": { + "kind": "remaining" + } + }, + { + "kind": "Struct", + "name": "AskToTransfer", + "prefix": { + "prefixStr": "0x0f8a7ea5", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "jettonAmount", + "ty": { + "kind": "coins" + } + }, + { + "name": "transferRecipient", + "ty": { + "kind": "address" + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "addressOpt" + } + }, + { + "name": "customPayload", + "isPayload": true, + "ty": { + "kind": "nullable", + "inner": { + "kind": "cell" + } + } + }, + { + "name": "forwardTonAmount", + "ty": { + "kind": "coins" + } + }, + { + "name": "forwardPayload", + "isPayload": true, + "ty": { + "kind": "AliasRef", + "aliasName": "ForwardPayloadRemainder" + } + } + ] + }, + { + "kind": "Struct", + "name": "TransferNotificationForRecipient", + "prefix": { + "prefixStr": "0x7362d09c", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "jettonAmount", + "ty": { + "kind": "coins" + } + }, + { + "name": "transferInitiator", + "ty": { + "kind": "addressOpt" + } + }, + { + "name": "forwardPayload", + "isPayload": true, + "ty": { + "kind": "AliasRef", + "aliasName": "ForwardPayloadRemainder" + } + } + ] + }, + { + "kind": "Struct", + "name": "InternalTransferStep", + "prefix": { + "prefixStr": "0x178d4519", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "jettonAmount", + "ty": { + "kind": "coins" + } + }, + { + "name": "transferInitiator", + "ty": { + "kind": "addressOpt" + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "addressOpt" + } + }, + { + "name": "forwardTonAmount", + "ty": { + "kind": "coins" + } + }, + { + "name": "forwardPayload", + "isPayload": true, + "ty": { + "kind": "AliasRef", + "aliasName": "ForwardPayloadRemainder" + } + } + ] + }, + { + "kind": "Struct", + "name": "ReturnExcessesBack", + "prefix": { + "prefixStr": "0xd53276db", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + } + ] + }, + { + "kind": "Struct", + "name": "AskToBurn", + "prefix": { + "prefixStr": "0x595f07bc", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "jettonAmount", + "ty": { + "kind": "coins" + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "addressOpt" + } + }, + { + "name": "customPayload", + "isPayload": true, + "ty": { + "kind": "nullable", + "inner": { + "kind": "cell" + } + } + } + ] + }, + { + "kind": "Struct", + "name": "BurnNotificationForMinter", + "prefix": { + "prefixStr": "0x7bdd97de", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "jettonAmount", + "ty": { + "kind": "coins" + } + }, + { + "name": "burnInitiator", + "ty": { + "kind": "address" + } + }, + { + "name": "sendExcessesTo", + "ty": { + "kind": "addressOpt" + } + } + ] + }, + { + "kind": "Struct", + "name": "RequestWalletAddress", + "prefix": { + "prefixStr": "0x2c76b973", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "ownerAddress", + "ty": { + "kind": "address" + } + }, + { + "name": "includeOwnerAddress", + "ty": { + "kind": "bool" + } + } + ] + }, + { + "kind": "Struct", + "name": "ResponseWalletAddress", + "prefix": { + "prefixStr": "0xd1735400", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "jettonWalletAddress", + "ty": { + "kind": "addressOpt" + } + }, + { + "name": "ownerAddress", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cellOf", + "inner": { + "kind": "address" + } + } + } + } + ] + }, + { + "kind": "Struct", + "name": "MintNewJettons", + "prefix": { + "prefixStr": "0x00000015", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "mintRecipient", + "ty": { + "kind": "address" + } + }, + { + "name": "tonAmount", + "ty": { + "kind": "coins" + } + }, + { + "name": "internalTransferMsg", + "ty": { + "kind": "cellOf", + "inner": { + "kind": "StructRef", + "structName": "InternalTransferStep" + } + } + } + ] + }, + { + "kind": "Struct", + "name": "ChangeMinterAdmin", + "prefix": { + "prefixStr": "0x00000003", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "newAdminAddress", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "ChangeMinterContent", + "prefix": { + "prefixStr": "0x00000004", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "newContent", + "ty": { + "kind": "cell" + } + } + ] + }, + { + "kind": "Alias", + "name": "AboaLisa", + "targetTy": { + "kind": "StructRef", + "structName": "ReturnExcessesBack" + } + }, + { + "kind": "Alias", + "name": "AllowedMessageToWallet", + "targetTy": { + "kind": "union", + "variants": [ + { + "variantTy": { + "kind": "StructRef", + "structName": "AskToTransfer" + }, + "prefixStr": "0x0f8a7ea5", + "prefixLen": 32 + }, + { + "variantTy": { + "kind": "StructRef", + "structName": "AskToBurn" + }, + "prefixStr": "0x595f07bc", + "prefixLen": 32 + }, + { + "variantTy": { + "kind": "StructRef", + "structName": "InternalTransferStep" + }, + "prefixStr": "0x178d4519", + "prefixLen": 32 + } + ] + } + }, + { + "kind": "Alias", + "name": "BounceOpToHandle", + "targetTy": { + "kind": "union", + "variants": [ + { + "variantTy": { + "kind": "StructRef", + "structName": "InternalTransferStep" + }, + "prefixStr": "0x178d4519", + "prefixLen": 32 + }, + { + "variantTy": { + "kind": "StructRef", + "structName": "BurnNotificationForMinter" + }, + "prefixStr": "0x7bdd97de", + "prefixLen": 32 + } + ] + } + }, + { + "kind": "Struct", + "name": "JettonWalletDataReply", + "fields": [ + { + "name": "jettonBalance", + "ty": { + "kind": "coins" + } + }, + { + "name": "ownerAddress", + "ty": { + "kind": "address" + } + }, + { + "name": "minterAddress", + "ty": { + "kind": "address" + } + }, + { + "name": "jettonWalletCode", + "ty": { + "kind": "cell" + } + } + ] + } + ], + "incomingMessages": [ + { + "bodyTy": { + "kind": "StructRef", + "structName": "AskToTransfer" + } + }, + { + "bodyTy": { + "kind": "StructRef", + "structName": "AskToBurn" + } + }, + { + "bodyTy": { + "kind": "StructRef", + "structName": "InternalTransferStep" + } + } + ], + "outgoingMessages": [ + { + "bodyTy": { + "kind": "AliasRef", + "aliasName": "AboaLisa" + } + }, + { + "bodyTy": { + "kind": "StructRef", + "structName": "TransferNotificationForRecipient" + } + }, + { + "bodyTy": { + "kind": "StructRef", + "structName": "ReturnExcessesBack" + } + }, + { + "bodyTy": { + "kind": "StructRef", + "structName": "InternalTransferStep" + } + }, + { + "bodyTy": { + "kind": "StructRef", + "structName": "BurnNotificationForMinter" + } + } + ], + "emittedEvents": [], + "storage": { + "storageTy": { + "kind": "StructRef", + "structName": "WalletStorage" + } + }, + "getMethods": [ + { + "tvmMethodId": 97026, + "name": "get_wallet_data", + "parameters": [], + "returnTy": { + "kind": "StructRef", + "structName": "JettonWalletDataReply" + } + } + ], + "thrownErrors": [ + { + "constName": "ERR_WRONG_WORKCHAIN", + "errCode": 333 + }, + { + "constName": "ERR_NOT_FROM_OWNER", + "errCode": 705 + }, + { + "constName": "ERR_NOT_ENOUGH_BALANCE", + "errCode": 706 + }, + { + "constName": "ERR_INVALID_WALLET", + "errCode": 707 + }, + { + "constName": "ERR_INVALID_PAYLOAD", + "errCode": 708 + }, + { + "constName": "ERR_NOT_ENOUGH_TON", + "errCode": 709 + }, + { + "constName": "", + "errCode": 65535 + } + ], + "compilerName": "tolk", + "compilerVersion": "1.2.0", + "codeBoc64": "te6ccgECCwEAAm4AART/APSkE/S88sgLAQIBYgIDA7zQ+JGONNMfMdcsILxqKMyW0z8x+gAwjhHXLCPe7L70kvI/4dM/MfoAMOLtRND6AAKgyAH6As7J7VTgINcsILxqKMzjAtcsIHxT9SzjAtcsIsr4PeTjAjCEDwHHAPL0BAUGAB2g9gXaiaH0AfSR9JBh8FUD+DHtRNAB0z/6APpQ+lD6AAb6ACD6SPpIMPiSIccFkTCOJviS+CooyM+EIPpSE/pSyVjIz4TQzMz5FsjPigBAy//PUMcF8uLD4lEmoMgB+gLOye1U+Jf4J28QIaGCCJiWgGa2CKGCCOThwKChIpQ3W2wh4w0gbrMjwgCw4w8HCAkB/jHTP/oA+kj6UPQB+gAg10ny4sQj+kQw8tFN7UTQ+gAg+kj6SDD4kiLHBfLiwVM4vvLiwlE4ocgB+gISzsntVCNyceME+Jf4k3D4OhKoJaCCCmJaAKC88uLF+CrIz4QgF/pSEvpSycjPkF41FGYYyz9QBvoCFfpUEvpUAfoCEs4KAKAx7UTQ+gAg+kj6SDD4kiLHBfLiwQTTP/oA+lAwU1G+8uLCUVGhyAH6AhTOye1UyM+R73Zfess/WPoC+lL6VMnIz4WIEvpScc8LbszJgFD7AACe+JNw+DojoKHIz4UIUiD6UiP6AoIQ1TJ2288LiifPCz/JgBD7AMjPkc2LQnInzws/UAb6AhT6VBbOycjPhQgT+lJQBfoCcc8LaszJcfsAAgAwyM+FCPpSWPoCghDVMnbbzwuKyz/JcvsAAARfAwBEycjPiYgBXcjPhNDMzPkWzwv/gQCNzwt0EswSzMzJgED7AA==" +} \ No newline at end of file diff --git a/abi-tolk/schemas/payload-test.json b/abi-tolk/schemas/payload-test.json new file mode 100644 index 00000000..4b873615 --- /dev/null +++ b/abi-tolk/schemas/payload-test.json @@ -0,0 +1,2195 @@ +{ + "namespace": "ton.tolk.tests", + "contractName": "Payloads", + "declarations": [ + { + "kind": "Struct", + "name": "CoffeeStakingLock", + "payloadType": "jetton", + "prefix": { + "prefixStr": "0x0c0ffede", + "prefixLen": 32 + }, + "fields": [ + { + "name": "periodID", + "ty": { + "kind": "uintN", + "n": 32 + } + } + ] + }, + { + "kind": "Struct", + "name": "TextComment", + "payloadType": "jetton", + "prefix": { + "prefixStr": "0x00000000", + "prefixLen": 32 + }, + "fields": [ + { + "name": "text", + "ty": { + "kind": "slice" + } + } + ] + }, + { + "kind": "Struct", + "payloadType": "jetton", + "name": "TegroJettonSwap", + "prefix": { + "prefixStr": "0x01fb7a25", + "prefixLen": 32 + }, + "fields": [ + { + "name": "extract", + "ty": { + "kind": "bool" + } + }, + { + "name": "maxIn", + "ty": { + "kind": "coins" + } + }, + { + "name": "minOut", + "ty": { + "kind": "coins" + } + }, + { + "name": "destination", + "ty": { + "kind": "address" + } + }, + { + "name": "errorDestination", + "ty": { + "kind": "address" + } + }, + { + "name": "payload", + "ty": { + "kind": "cell" + } + } + ] + }, + { + "kind": "Struct", + "name": "EncryptedTextComment", + "payloadType": "jetton", + "prefix": { + "prefixStr": "0x2167da4b", + "prefixLen": 32 + }, + "fields": [ + { + "name": "cipherText", + "ty": { + "kind": "slice" + } + } + ] + }, + { + "kind": "Struct", + "name": "TegroAddLiquidity", + "payloadType": "jetton", + "prefix": { + "prefixStr": "0x287e167a", + "prefixLen": 32 + }, + "fields": [ + { + "name": "amountA", + "ty": { + "kind": "coins" + } + }, + { + "name": "amountB", + "ty": { + "kind": "coins" + } + } + ] + }, + { + "kind": "Struct", + "name": "BidaskProvideBoth", + "payloadType": "jetton", + "prefix": { + "prefixStr": "0x3ea0bafc", + "prefixLen": 32 + }, + "fields": [ + { + "name": "tonAmount", + "ty": { + "kind": "coins" + } + }, + { + "name": "depositType", + "ty": { + "kind": "uintN", + "n": 4 + } + }, + { + "name": "liquidityDict", + "ty": { + "kind": "mapKV", + "k": { + "kind": "uintN", + "n": 32 + }, + "v": { + "kind": "intN", + "n": 32 + } + } + }, + { + "name": "rejectPayload", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cell" + } + } + }, + { + "name": "forwardPayload", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cell" + } + } + } + ] + }, + { + "kind": "Struct", + "name": "DedustVolatile", + "prefix": { + "prefixStr": "0b0", + "prefixLen": 1 + }, + "fields": [] + }, + { + "kind": "Struct", + "name": "DedustStable", + "prefix": { + "prefixStr": "0b1", + "prefixLen": 1 + }, + "fields": [] + }, + { + "kind": "Struct", + "name": "DedustAssetNative", + "prefix": { + "prefixStr": "0b0000", + "prefixLen": 4 + }, + "fields": [] + }, + { + "kind": "Struct", + "name": "DedustAssetJetton", + "prefix": { + "prefixStr": "0b0001", + "prefixLen": 4 + }, + "fields": [ + { + "name": "workchain", + "ty": { + "kind": "intN", + "n": 8 + } + }, + { + "name": "hash", + "ty": { + "kind": "bitsN", + "n": 256 + } + } + ] + }, + { + "kind": "Struct", + "name": "DedustAssetExtraCurrency", + "prefix": { + "prefixStr": "0b0010", + "prefixLen": 4 + }, + "fields": [ + { + "name": "currencyId", + "ty": { + "kind": "intN", + "n": 32 + } + } + ] + }, + { + "kind": "Alias", + "name": "DedustPoolType", + "targetTy": { + "kind": "union", + "variants": [ + { + "variantTy": { + "kind": "StructRef", + "structName": "DedustVolatile" + }, + "prefixStr": "0b0", + "prefixLen": 1 + }, + { + "variantTy": { + "kind": "StructRef", + "structName": "DedustStable" + }, + "prefixStr": "0b1", + "prefixLen": 1 + } + ] + } + }, + { + "kind": "Alias", + "name": "DedustAsset", + "targetTy": { + "kind": "union", + "variants": [ + { + "variantTy": { + "kind": "StructRef", + "structName": "DedustAssetNative" + }, + "prefixStr": "0b0000", + "prefixLen": 4 + }, + { + "variantTy": { + "kind": "StructRef", + "structName": "DedustAssetJetton" + }, + "prefixStr": "0b0001", + "prefixLen": 4 + }, + { + "variantTy": { + "kind": "StructRef", + "structName": "DedustAssetExtraCurrency" + }, + "prefixStr": "0b0010", + "prefixLen": 4 + } + ] + } + }, + { + "kind": "Struct", + "name": "DedustDepositLiquidity", + "payloadType": "jetton", + "prefix": { + "prefixStr": "0x40e108d6", + "prefixLen": 32 + }, + "fields": [ + { + "name": "poolType", + "ty": { + "kind": "AliasRef", + "aliasName": "DedustPoolType" + } + }, + { + "name": "asset0", + "ty": { + "kind": "AliasRef", + "aliasName": "DedustAsset" + } + }, + { + "name": "asset1", + "ty": { + "kind": "AliasRef", + "aliasName": "DedustAsset" + } + }, + { + "name": "asset0TargetBalance", + "ty": { + "kind": "coins" + } + }, + { + "name": "asset1TargetBalance", + "ty": { + "kind": "coins" + } + }, + { + "name": "fulfillPayload", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cell" + } + } + }, + { + "name": "rejectPayload", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cell" + } + } + } + ] + }, + { + "kind": "Struct", + "name": "PoolFundAccount", + "payloadType": "jetton", + "prefix": { + "prefixStr": "0x4468de77", + "prefixLen": 32 + }, + "fields": [ + { + "name": "jettonTarget", + "ty": { + "kind": "address" + } + }, + { + "name": "enough0", + "ty": { + "kind": "coins" + } + }, + { + "name": "enough1", + "ty": { + "kind": "coins" + } + }, + { + "name": "liquidity", + "ty": { + "kind": "uintN", + "n": 128 + } + }, + { + "name": "tickLower", + "ty": { + "kind": "intN", + "n": 24 + } + }, + { + "name": "tickUpper", + "ty": { + "kind": "intN", + "n": 24 + } + } + ] + }, + { + "kind": "Struct", + "name": "CoffeeCrossDexResend", + "payloadType": "jetton", + "prefix": { + "prefixStr": "0x4ee9b106", + "prefixLen": 32 + }, + "fields": [ + { + "name": "next", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cell" + } + } + } + ] + }, + { + "kind": "Struct", + "name": "BidaskDammProvide", + "payloadType": "jetton", + "prefix": { + "prefixStr": "0x63ec24ae", + "prefixLen": 32 + }, + "fields": [ + { + "name": "receiver", + "ty": { + "kind": "address" + } + }, + { + "name": "lockLiquidity", + "ty": { + "kind": "bool" + } + }, + { + "name": "rejectPayload", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cell" + } + } + }, + { + "name": "forwardPayload", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cell" + } + } + } + ] + }, + { + "kind": "Struct", + "name": "BidaskDammProvideOneSide", + "payloadType": "jetton", + "prefix": { + "prefixStr": "0x729c04c8", + "prefixLen": 32 + }, + "fields": [ + { + "name": "receiver", + "ty": { + "kind": "address" + } + }, + { + "name": "lockLiquidity", + "ty": { + "kind": "bool" + } + }, + { + "name": "rejectPayload", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cell" + } + } + }, + { + "name": "forwardPayload", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cell" + } + } + } + ] + }, + { + "kind": "Struct", + "name": "StormNoKeyInit", + "fields": [] + }, + { + "kind": "Struct", + "name": "StormNeedKeyInit", + "fields": [ + { + "name": "userPublicKeys", + "ty": { + "kind": "mapKV", + "k": { + "kind": "uintN", + "n": 256 + }, + "v": { + "kind": "cell" + } + } + } + ] + }, + { + "kind": "Alias", + "name": "InitializationRequest", + "targetTy": { + "kind": "union", + "variants": [ + { + "prefixStr": "0", + "prefixLen": 1, + "prefixEatInPlace": true, + "variantTy": { + "kind": "StructRef", + "structName": "StormNoKeyInit" + } + }, + { + "prefixStr": "1", + "prefixLen": 1, + "prefixEatInPlace": true, + "variantTy": { + "kind": "StructRef", + "structName": "StormNeedKeyInit" + } + } + ] + } + }, + { + "kind": "Struct", + "name": "StormDepositJetton", + "payloadType": "jetton", + "prefix": { + "prefixStr": "0x76840119", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "receiverAddress", + "ty": { + "kind": "address" + } + }, + { + "name": "init", + "ty": { + "kind": "bool" + } + }, + { + "name": "keyInit", + "ty": { + "kind": "AliasRef", + "aliasName": "InitializationRequest" + } + } + ] + }, + { + "kind": "Struct", + "name": "InvoiceUrlNone", + "prefix": { + "prefixStr": "0x00", + "prefixLen": 8 + }, + "fields": [] + }, + { + "kind": "Struct", + "name": "InvoiceUrlTonsite", + "prefix": { + "prefixStr": "0x01", + "prefixLen": 8 + }, + "fields": [ + { + "name": "address", + "ty": { + "kind": "bitsN", + "n": 256 + } + } + ] + }, + { + "kind": "Alias", + "name": "InvoiceUrl", + "targetTy": { + "kind": "union", + "variants": [ + { + "variantTy": { + "kind": "StructRef", + "structName": "InvoiceUrlNone" + }, + "prefixStr": "0x00", + "prefixLen": 8 + }, + { + "variantTy": { + "kind": "StructRef", + "structName": "InvoiceUrlTonsite" + }, + "prefixStr": "0x01", + "prefixLen": 8 + } + ] + } + }, + { + "kind": "Struct", + "name": "InvoicePayload", + "payloadType": "jetton", + "prefix": { + "prefixStr": "0x7aa23eb5", + "prefixLen": 32 + }, + "fields": [ + { + "name": "id", + "ty": { + "kind": "bitsN", + "n": 128 + } + }, + { + "name": "url", + "ty": { + "kind": "AliasRef", + "aliasName": "InvoiceUrl" + } + } + ] + }, + { + "kind": "Struct", + "name": "TonkeeperRelayerFee", + "payloadType": "jetton", + "prefix": { + "prefixStr": "0x878da6e3", + "prefixLen": 32 + }, + "fields": [] + }, + { + "kind": "Struct", + "name": "AdditionalData", + "fields": [ + { + "name": "fromAddress", + "ty": { + "kind": "address" + } + }, + { + "name": "refAddress", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "BidaskSwapV2", + "payloadType": "jetton", + "prefix": { + "prefixStr": "0x87d36990", + "prefixLen": 32 + }, + "fields": [ + { + "name": "toAddress", + "ty": { + "kind": "address" + } + }, + { + "name": "slippage", + "ty": { + "kind": "union", + "variants": [ + { + "prefixStr": "0", + "prefixLen": 1, + "prefixEatInPlace": true, + "variantTy": { + "kind": "coins" + } + }, + { + "prefixStr": "1", + "prefixLen": 1, + "prefixEatInPlace": true, + "variantTy": { + "kind": "uintN", + "n": 256 + } + } + ] + } + }, + { + "name": "exactOut", + "ty": { + "kind": "coins" + } + }, + { + "name": "additionalData", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cellOf", + "inner": { + "kind": "StructRef", + "structName": "AdditionalData" + } + } + } + }, + { + "name": "rejectPayload", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cell" + } + } + }, + { + "name": "forwardPayload", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cell" + } + } + } + ] + }, + { + "kind": "Struct", + "name": "MoonBoostPool", + "payloadType": "jetton", + "prefix": { + "prefixStr": "0x96aa1586", + "prefixLen": 32 + }, + "fields": [] + }, + { + "kind": "Struct", + "name": "BidaskProvide", + "payloadType": "jetton", + "prefix": { + "prefixStr": "0x96feef7b", + "prefixLen": 32 + }, + "fields": [ + { + "name": "depositType", + "ty": { + "kind": "uintN", + "n": 4 + } + }, + { + "name": "liquidityDict", + "ty": { + "kind": "mapKV", + "k": { + "kind": "uintN", + "n": 32 + }, + "v": { + "kind": "intN", + "n": 32 + } + } + }, + { + "name": "rejectPayload", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cell" + } + } + }, + { + "name": "forwardPayload", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cell" + } + } + } + ] + }, + { + "kind": "Struct", + "name": "MoonFillOrder", + "payloadType": "jetton", + "prefix": { + "prefixStr": "0x99b49842", + "prefixLen": 32 + }, + "fields": [ + { + "name": "recipient", + "ty": { + "kind": "address" + } + }, + { + "name": "recipientPayload", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cell" + } + } + }, + { + "name": "rejectAddress", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "BidaskDammProvideBoth", + "payloadType": "jetton", + "prefix": { + "prefixStr": "0xa8904134", + "prefixLen": 32 + }, + "fields": [ + { + "name": "nativeAmount", + "ty": { + "kind": "coins" + } + }, + { + "name": "reciever", + "ty": { + "kind": "address" + } + }, + { + "name": "lockLiquidity", + "ty": { + "kind": "bool" + } + }, + { + "name": "rejectPayload", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cell" + } + } + }, + { + "name": "forwardPayload", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cell" + } + } + } + ] + }, + { + "kind": "Struct", + "name": "MoonDepositLiquidity", + "payloadType": "jetton", + "prefix": { + "prefixStr": "0xb31db781", + "prefixLen": 32 + }, + "fields": [ + { + "name": "minLpOut", + "ty": { + "kind": "coins" + } + } + ] + }, + { + "kind": "Struct", + "name": "MoonNextPayload", + "fields": [ + { + "name": "recipient", + "ty": { + "kind": "address" + } + }, + { + "name": "payload", + "isPayload": true, + "ty": { + "kind": "nullable", + "inner": { + "kind": "cell" + } + } + } + ] + }, + { + "kind": "Struct", + "name": "MoonSwapParams", + "fields": [ + { + "name": "minOut", + "ty": { + "kind": "coins" + } + }, + { + "name": "deadline", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "excess", + "ty": { + "kind": "address" + } + }, + { + "name": "referral", + "ty": { + "kind": "address" + } + }, + { + "name": "nextFulfill", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cellOf", + "inner": { + "kind": "StructRef", + "structName": "MoonNextPayload" + } + } + } + }, + { + "name": "nextReject", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cellOf", + "inner": { + "kind": "StructRef", + "structName": "MoonNextPayload" + } + } + } + } + ] + }, + { + "kind": "Struct", + "name": "MoonSwap", + "payloadType": "jetton", + "prefix": { + "prefixStr": "0xb37a900b", + "prefixLen": 32 + }, + "fields": [ + { + "name": "moonSwap", + "ty": { + "kind": "StructRef", + "structName": "MoonSwapParams" + } + } + ] + }, + { + "kind": "Struct", + "name": "CoffeeCrossDexFailure", + "payloadType": "jetton", + "prefix": { + "prefixStr": "0xb902e61a", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "recipient", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "CoffeeSwapStepParams", + "fields": [ + { + "name": "poolAddressHash", + "ty": { + "kind": "uintN", + "n": 256 + } + }, + { + "name": "minOutAmount", + "ty": { + "kind": "coins" + } + }, + { + "name": "next", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cellOf", + "inner": { + "kind": "StructRef", + "structName": "CoffeeSwapStepParams" + } + } + } + } + ] + }, + { + "kind": "Struct", + "name": "CoffeeNotificationDataSingle", + "fields": [ + { + "name": "reciever", + "ty": { + "kind": "address" + } + }, + { + "name": "fwdGas", + "ty": { + "kind": "coins" + } + }, + { + "name": "payload", + "ty": { + "kind": "cell" + } + } + ] + }, + { + "kind": "Struct", + "name": "CoffeeNotificationData", + "fields": [ + { + "name": "onSuccess", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cellOf", + "inner": { + "kind": "StructRef", + "structName": "CoffeeNotificationDataSingle" + } + } + } + }, + { + "name": "onFailure", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cellOf", + "inner": { + "kind": "StructRef", + "structName": "CoffeeNotificationDataSingle" + } + } + } + } + ] + }, + { + "kind": "Struct", + "name": "CoffeeSwapParams", + "fields": [ + { + "name": "deadline", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "recipient", + "ty": { + "kind": "address" + } + }, + { + "name": "referral", + "ty": { + "kind": "address" + } + }, + { + "name": "notificationData", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cellOf", + "inner": { + "kind": "StructRef", + "structName": "CoffeeNotificationData" + } + } + } + } + ] + }, + { + "kind": "Struct", + "name": "CoffeeSwap", + "payloadType": "jetton", + "prefix": { + "prefixStr": "0xc0ffee10", + "prefixLen": 32 + }, + "fields": [ + { + "name": "step", + "ty": { + "kind": "StructRef", + "structName": "CoffeeSwapStepParams" + } + }, + { + "name": "params", + "ty": { + "kind": "cellOf", + "inner": { + "kind": "StructRef", + "structName": "CoffeeSwapParams" + } + } + } + ] + }, + { + "kind": "Struct", + "name": "CoffeeAssetNative", + "prefix": { + "prefixStr": "0b00", + "prefixLen": 2 + }, + "fields": [] + }, + { + "kind": "Struct", + "name": "CoffeeAssetJetton", + "prefix": { + "prefixStr": "0b01", + "prefixLen": 2 + }, + "fields": [ + { + "name": "chain", + "ty": { + "kind": "uintN", + "n": 8 + } + }, + { + "name": "hash", + "ty": { + "kind": "uintN", + "n": 256 + } + } + ] + }, + { + "kind": "Struct", + "name": "CoffeAssetExtra", + "prefix": { + "prefixStr": "0b10", + "prefixLen": 2 + }, + "fields": [ + { + "name": "id", + "ty": { + "kind": "uintN", + "n": 32 + } + } + ] + }, + { + "kind": "Alias", + "name": "CoffeeAsset", + "targetTy": { + "kind": "union", + "variants": [ + { + "variantTy": { + "kind": "StructRef", + "structName": "CoffeeAssetNative" + }, + "prefixStr": "0b00", + "prefixLen": 2 + }, + { + "variantTy": { + "kind": "StructRef", + "structName": "CoffeeAssetJetton" + }, + "prefixStr": "0b01", + "prefixLen": 2 + }, + { + "variantTy": { + "kind": "StructRef", + "structName": "CoffeAssetExtra" + }, + "prefixStr": "0b10", + "prefixLen": 2 + } + ] + } + }, + { + "kind": "Struct", + "name": "CoffeeAmmConstProd", + "prefix": { + "prefixStr": "0b000", + "prefixLen": 3 + }, + "fields": [] + }, + { + "kind": "Struct", + "name": "CoffeeAmmCurveFiStable", + "prefix": { + "prefixStr": "0b001", + "prefixLen": 3 + }, + "fields": [] + }, + { + "kind": "Alias", + "name": "CoffeeAmm", + "targetTy": { + "kind": "union", + "variants": [ + { + "variantTy": { + "kind": "StructRef", + "structName": "CoffeeAmmConstProd" + }, + "prefixStr": "0b000", + "prefixLen": 3 + }, + { + "variantTy": { + "kind": "StructRef", + "structName": "CoffeeAmmCurveFiStable" + }, + "prefixStr": "0b001", + "prefixLen": 3 + } + ] + } + }, + { + "kind": "Struct", + "name": "CoffeePoolParams", + "fields": [ + { + "name": "first", + "ty": { + "kind": "AliasRef", + "aliasName": "CoffeeAsset" + } + }, + { + "name": "second", + "ty": { + "kind": "AliasRef", + "aliasName": "CoffeeAsset" + } + }, + { + "name": "amm", + "ty": { + "kind": "AliasRef", + "aliasName": "CoffeeAmm" + } + }, + { + "name": "ammSettings", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cell" + } + } + } + ] + }, + { + "kind": "Struct", + "name": "CoffeePublicPoolCreationParams", + "fields": [ + { + "name": "recipient", + "ty": { + "kind": "address" + } + }, + { + "name": "useRecipientOnFailure", + "ty": { + "kind": "bool" + } + }, + { + "name": "notificationData", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cell" + } + } + } + ] + }, + { + "kind": "Struct", + "name": "CoffeePrivatePoolCreationParams", + "fields": [ + { + "name": "isActive", + "ty": { + "kind": "bool" + } + }, + { + "name": "extraSettings", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cell" + } + } + } + ] + }, + { + "kind": "Struct", + "name": "CoffeePoolCreationParams", + "fields": [ + { + "name": "public", + "ty": { + "kind": "StructRef", + "structName": "CoffeePublicPoolCreationParams" + } + }, + { + "name": "privateP", + "ty": { + "kind": "StructRef", + "structName": "CoffeePrivatePoolCreationParams" + } + } + ] + }, + { + "kind": "Struct", + "name": "CoffeeCreatePool", + "payloadType": "jetton", + "prefix": { + "prefixStr": "0xc0ffee11", + "prefixLen": 32 + }, + "fields": [ + { + "name": "params", + "ty": { + "kind": "StructRef", + "structName": "CoffeePoolParams" + } + }, + { + "name": "creationParams", + "ty": { + "kind": "StructRef", + "structName": "CoffeePoolCreationParams" + } + } + ] + }, + { + "kind": "Struct", + "name": "CoffeeDepositLiquidityConditionNone", + "prefix": { + "prefixStr": "0b00", + "prefixLen": 2 + }, + "fields": [] + }, + { + "kind": "Struct", + "name": "CoffeeDepositLiquidityConditionLpQuantity", + "prefix": { + "prefixStr": "0b01", + "prefixLen": 2 + }, + "fields": [ + { + "name": "minLpAmount", + "ty": { + "kind": "coins" + } + } + ] + }, + { + "kind": "Struct", + "name": "CoffeeDepositLiquidityConditionReservedRatio", + "prefix": { + "prefixStr": "0b10", + "prefixLen": 2 + }, + "fields": [ + { + "name": "denominator", + "ty": { + "kind": "coins" + } + }, + { + "name": "minNominator", + "ty": { + "kind": "coins" + } + }, + { + "name": "maxNominator", + "ty": { + "kind": "coins" + } + } + ] + }, + { + "kind": "Struct", + "name": "CoffeeDepositLiquidityConditionComplex", + "prefix": { + "prefixStr": "0b11", + "prefixLen": 2 + }, + "fields": [ + { + "name": "minLpAmoint", + "ty": { + "kind": "coins" + } + }, + { + "name": "denominator", + "ty": { + "kind": "coins" + } + }, + { + "name": "minNominator", + "ty": { + "kind": "coins" + } + }, + { + "name": "maxNominator", + "ty": { + "kind": "coins" + } + } + ] + }, + { + "kind": "Alias", + "name": "CoffeeDepositLiquidityCondition", + "targetTy": { + "kind": "union", + "variants": [ + { + "variantTy": { + "kind": "StructRef", + "structName": "CoffeeDepositLiquidityConditionNone" + }, + "prefixStr": "0b00", + "prefixLen": 2 + }, + { + "variantTy": { + "kind": "StructRef", + "structName": "CoffeeDepositLiquidityConditionLpQuantity" + }, + "prefixStr": "0b01", + "prefixLen": 2 + }, + { + "variantTy": { + "kind": "StructRef", + "structName": "CoffeeDepositLiquidityConditionReservedRatio" + }, + "prefixStr": "0b10", + "prefixLen": 2 + }, + { + "variantTy": { + "kind": "StructRef", + "structName": "CoffeeDepositLiquidityConditionComplex" + }, + "prefixStr": "0b11", + "prefixLen": 2 + } + ] + } + }, + { + "kind": "Struct", + "name": "CoffeeDepositLiquidityParamsTrimmed", + "fields": [ + { + "name": "recipient", + "ty": { + "kind": "address" + } + }, + { + "name": "useRecipientOnFailure", + "ty": { + "kind": "bool" + } + }, + { + "name": "referral", + "ty": { + "kind": "addressOpt" + } + }, + { + "name": "deadline", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "condition", + "ty": { + "kind": "AliasRef", + "aliasName": "CoffeeDepositLiquidityCondition" + } + }, + { + "name": "extraSettings", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cell" + } + } + }, + { + "name": "notificationData", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cellOf", + "inner": { + "kind": "StructRef", + "structName": "CoffeeNotificationData" + } + } + } + } + ] + }, + { + "kind": "Struct", + "name": "CoffeeDepositLiquidityParams", + "fields": [ + { + "name": "params", + "ty": { + "kind": "StructRef", + "structName": "CoffeeDepositLiquidityParamsTrimmed" + } + }, + { + "name": "poolParmas", + "ty": { + "kind": "StructRef", + "structName": "CoffeePoolParams" + } + } + ] + }, + { + "kind": "Struct", + "name": "CoffeeDepositLiquidity", + "payloadType": "jetton", + "prefix": { + "prefixStr": "0xc0ffee12", + "prefixLen": 32 + }, + "fields": [ + { + "name": "params", + "ty": { + "kind": "StructRef", + "structName": "CoffeeDepositLiquidityParams" + } + } + ] + }, + { + "kind": "Struct", + "name": "CoffeeNotification", + "payloadType": "jetton", + "prefix": { + "prefixStr": "0xc0ffee36", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "body", + "ty": { + "kind": "cell" + } + } + ] + }, + { + "kind": "Struct", + "name": "MoonSwapFailed", + "payloadType": "jetton", + "prefix": { + "prefixStr": "0xc47c1f57", + "prefixLen": 32 + }, + "fields": [] + }, + { + "kind": "Struct", + "name": "StormStake", + "payloadType": "jetton", + "prefix": { + "prefixStr": "0xc89a3ee4", + "prefixLen": 32 + }, + "fields": [] + }, + { + "kind": "Struct", + "name": "WithdrawPayload", + "payloadType": "jetton", + "prefix": { + "prefixStr": "0xcb03bfaf", + "prefixLen": 32 + }, + "fields": [ + { + "name": "assetAddress", + "ty": { + "kind": "address" + } + }, + { + "name": "oracleParams", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cell" + } + } + }, + { + "name": "forwardTonAmount", + "ty": { + "kind": "coins" + } + }, + { + "name": "forwardPayload", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cell" + } + } + } + ] + }, + { + "kind": "Struct", + "name": "MoonSwapSucceed", + "payloadType": "jetton", + "prefix": { + "prefixStr": "0xcb7f38d6", + "prefixLen": 32 + }, + "fields": [] + }, + { + "kind": "Struct", + "name": "MoonOrderParams", + "fields": [ + { + "name": "rate", + "ty": { + "kind": "uintN", + "n": 256 + } + }, + { + "name": "lock", + "ty": { + "kind": "uintN", + "n": 2 + } + }, + { + "name": "vestingTime", + "ty": { + "kind": "uintN", + "n": 64 + } + } + ] + }, + { + "kind": "Struct", + "name": "MoonCreateOrder", + "payloadType": "jetton", + "prefix": { + "prefixStr": "0xda067c19", + "prefixLen": 32 + }, + "fields": [ + { + "name": "asset1", + "ty": { + "kind": "address" + } + }, + { + "name": "asset2", + "ty": { + "kind": "address" + } + }, + { + "name": "orderData", + "ty": { + "kind": "StructRef", + "structName": "MoonOrderParams" + } + } + ] + }, + { + "kind": "Struct", + "name": "BidaskDammSwap", + "payloadType": "jetton", + "prefix": { + "prefixStr": "0xdd79732c", + "prefixLen": 32 + }, + "fields": [ + { + "name": "toAddress", + "ty": { + "kind": "address" + } + }, + { + "name": "slippage", + "ty": { + "kind": "coins" + } + }, + { + "name": "fromAddress", + "ty": { + "kind": "address" + } + }, + { + "name": "exactOut", + "ty": { + "kind": "coins" + } + }, + { + "name": "additionalData", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cell" + } + } + }, + { + "name": "rejectPayload", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cell" + } + } + }, + { + "name": "forwardPayload", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cell" + } + } + } + ] + }, + { + "kind": "Struct", + "name": "DedustSwapStepParams", + "fields": [ + { + "name": "kindOut", + "ty": { + "kind": "bool" + } + }, + { + "name": "limit", + "ty": { + "kind": "coins" + } + }, + { + "name": "next", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cellOf", + "inner": { + "kind": "StructRef", + "structName": "DedustSwapStep" + } + } + } + } + ] + }, + { + "kind": "Struct", + "name": "DedustSwapStep", + "fields": [ + { + "name": "poolAddr", + "ty": { + "kind": "address" + } + }, + { + "name": "params", + "ty": { + "kind": "StructRef", + "structName": "DedustSwapStepParams" + } + } + ] + }, + { + "kind": "Struct", + "name": "DedustSwapParams", + "fields": [ + { + "name": "deadline", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "recipientAddr", + "ty": { + "kind": "address" + } + }, + { + "name": "referralAddr", + "ty": { + "kind": "address" + } + }, + { + "name": "fulfillPayload", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cell" + } + } + }, + { + "name": "rejectPayload", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cell" + } + } + } + ] + }, + { + "kind": "Struct", + "name": "DedustSwap", + "payloadType": "jetton", + "prefix": { + "prefixStr": "0xe3a0d482", + "prefixLen": 32 + }, + "fields": [ + { + "name": "step", + "ty": { + "kind": "StructRef", + "structName": "DedustSwapStep" + } + }, + { + "name": "swapParams", + "ty": { + "kind": "cellOf", + "inner": { + "kind": "StructRef", + "structName": "DedustSwapParams" + } + } + } + ] + }, + { + "kind": "Struct", + "name": "CoffeeMevProtectFailedSwap", + "payloadType": "jetton", + "prefix": { + "prefixStr": "0xee51ce51", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "recipient", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "BidaskSwap", + "payloadType": "jetton", + "prefix": { + "prefixStr": "0xf2ef6c1b", + "prefixLen": 32 + }, + "fields": [ + { + "name": "toAddress", + "ty": { + "kind": "address" + } + }, + { + "name": "slippage", + "ty": { + "kind": "union", + "variants": [ + { + "prefixStr": "0", + "prefixLen": 1, + "prefixEatInPlace": true, + "variantTy": { + "kind": "coins" + } + }, + { + "prefixStr": "1", + "prefixLen": 1, + "prefixEatInPlace": true, + "variantTy": { + "kind": "uintN", + "n": 256 + } + } + ] + } + }, + { + "name": "exactOut", + "ty": { + "kind": "coins" + } + }, + { + "name": "refAddress", + "ty": { + "kind": "address" + } + }, + { + "name": "additionalData", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cell" + } + } + }, + { + "name": "rejectPayload", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cell" + } + } + }, + { + "name": "forwardPayload", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cell" + } + } + } + ] + }, + { + "kind": "Struct", + "name": "DepositPayload", + "payloadType": "jetton", + "prefix": { + "prefixStr": "0xf9471134", + "prefixLen": 32 + }, + "fields": [ + { + "name": "oracleParams", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cell" + } + } + }, + { + "name": "forwardTonAmount", + "ty": { + "kind": "coins" + } + }, + { + "name": "forwardPayload", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cell" + } + } + } + ] + } + ], + "incomingMessages": [], + "outgoingMessages": [], + "emittedEvents": [], + "storage": { + "storageTy": { + "kind": "nullLiteral" + } + }, + "getMethods": [], + "thrownErrors": [], + "compilerName": "tolk", + "compilerVersion": "1.2.0", + "codeBoc64": "te6ccgEBAgEAFQABFP8A9KQT9LzyyAsBAAzTMPiR8kA=" +} \ No newline at end of file diff --git a/abi-tolk/schemas/stonfi_v1.json b/abi-tolk/schemas/stonfi_v1.json new file mode 100644 index 00000000..ed4ac512 --- /dev/null +++ b/abi-tolk/schemas/stonfi_v1.json @@ -0,0 +1,143 @@ +{ + "namespace": "ton.stonfi.v1", + "contractName": "Pool", + "declarations": [ + { + "kind": "Struct", + "name": "GetPoolDataStonfiV1", + "fields": [ + { + "name": "reserve0", + "ty": { + "kind": "coins" + } + }, + { + "name": "reserve1", + "ty": { + "kind": "coins" + } + }, + { + "name": "token0Address", + "ty": { + "kind": "address" + } + }, + { + "name": "token1Address", + "ty": { + "kind": "address" + } + }, + { + "name": "lpFee", + "ty": { + "kind": "uintN", + "n": 8 + } + }, + { + "name": "protocolFee", + "ty": { + "kind": "uintN", + "n": 8 + } + }, + { + "name": "refFee", + "ty": { + "kind": "uintN", + "n": 8 + } + }, + { + "name": "protocolFeeAddress", + "ty": { + "kind": "address" + } + }, + { + "name": "collectedToken0ProtocolFee", + "ty": { + "kind": "coins" + } + }, + { + "name": "collectedToken1ProtocolFee", + "ty": { + "kind": "coins" + } + } + ] + }, + { + "kind": "Struct", + "name": "StonfiSwap", + "payloadType": "jetton", + "prefix": { + "prefixStr": "0x25938561", + "prefixLen": 32 + }, + "fields": [ + { + "name": "tokenWallet", + "ty": { + "kind": "address" + } + }, + { + "name": "minOut", + "ty": { + "kind": "coins" + } + }, + { + "name": "toAddress", + "ty": { + "kind": "address" + } + }, + { + "name": "referralAddress", + "ty": { + "kind": "addressOpt" + } + } + ] + }, + { + "kind": "Struct", + "name": "StonfiSwapOkRef", + "payloadType": "jetton", + "prefix": { + "prefixStr": "0x45078540", + "prefixLen": 32 + }, + "fields": [] + } + ], + "incomingMessages": [], + "outgoingMessages": [], + "emittedEvents": [], + "storage": { + "storageTy": { + "kind": "nullLiteral" + } + }, + "getMethods": [ + { + "tvmMethodId": 81689, + "name": "get_pool_data", + "parameters": [], + "returnTy": { + "kind": "StructRef", + "structName": "GetPoolDataStonfiV1" + } + } + ], + "thrownErrors": [], + "compilerName": "tolk", + "compilerVersion": "1.2.0", + "codeBoc64": "te6ccgEBBAEAlwABFP8A9KQT9LzyyAsBAgFiAgMADNAw+JHyQAD1oH4zBCAL68IAQRoQwAGCXVPSRUXCgMDGb9zKg9EFYwRDBjv+JoMDibUwTh0duRoQwAGCXVPSRUXCgMDGb9zKg9EFYwRDBjv+JoMDibUwTh0duOCmARoQwAGCXVPSRUXCgMDGb9zKg9EFYwRDBjv+JoMDibUwTh0duKYt" +} \ No newline at end of file diff --git a/abi-tolk/schemas/stonfi_v2.json b/abi-tolk/schemas/stonfi_v2.json new file mode 100644 index 00000000..87eba04d --- /dev/null +++ b/abi-tolk/schemas/stonfi_v2.json @@ -0,0 +1,140 @@ +{ + "namespace": "ton.stonfi.v2", + "contractName": "Pool", + "declarations": [ + { + "kind": "Struct", + "name": "GetLpAccountAddressResult", + "fields": [ + { + "name": "lpAccountAddress", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "StonfiProvideLpV2", + "payloadType": "jetton", + "prefix": { + "prefixStr": "0x37c096df", + "prefixLen": 32 + }, + "fields": [ + { + "name": "tokenWallet1", + "ty": { + "kind": "address" + } + }, + { + "name": "refundAddress", + "ty": { + "kind": "address" + } + }, + { + "name": "excessesAddress", + "ty": { + "kind": "address" + } + }, + { + "name": "txDeadline", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "crossProvideLpBody", + "ty": { + "kind": "cellOf", + "inner": { + "kind": "StructRef", + "structName": "CrossProvideLpBody" + } + } + } + ] + }, + { + "kind": "Struct", + "name": "StonfiSwapV2", + "payloadType": "jetton", + "prefix": { + "prefixStr": "0x6664de2a", + "prefixLen": 32 + }, + "fields": [ + { + "name": "tokenWallet1", + "ty": { + "kind": "address" + } + }, + { + "name": "refundAddress", + "ty": { + "kind": "address" + } + }, + { + "name": "excessesAddress", + "ty": { + "kind": "address" + } + }, + { + "name": "txDeadline", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "crossSwapBody", + "ty": { + "kind": "cellOf", + "inner": { + "kind": "StructRef", + "structName": "CrossSwapBody" + } + } + } + ] + } + ], + "incomingMessages": [], + "outgoingMessages": [], + "emittedEvents": [], + "storage": { + "storageTy": { + "kind": "nullLiteral" + } + }, + "getMethods": [ + { + "tvmMethodId": 87316, + "name": "get_lp_account_address", + "parameters": [ + { + "name": "owner", + "ty": { + "kind": "address" + } + } + ], + "returnTy": { + "kind": "StructRef", + "structName": "GetLpAccountAddressResult" + } + } + ], + "thrownErrors": [], + "compilerName": "tolk", + "compilerVersion": "1.2.0", + "codeBoc64": "te6ccgEBBAEARAABFP8A9KQT9LzyyAsBAgFiAgMADNAw+JHyQABPoKooYRoQwAGCXVPSRUXCgMDGb9zKg9EFYwRDBjv+JoMDibUwTh0duQ==" +} \ No newline at end of file diff --git a/abi-tolk/schemas/stonfi_v2_const_prod.json b/abi-tolk/schemas/stonfi_v2_const_prod.json new file mode 100644 index 00000000..e39db07f --- /dev/null +++ b/abi-tolk/schemas/stonfi_v2_const_prod.json @@ -0,0 +1,147 @@ +{ + "namespace": "ton.stonfi.v2", + "contractName": "PoolConstProduct", + "declarations": [ + { + "kind": "Struct", + "name": "GetPoolDataStonfiV2", + "fields": [ + { + "name": "isLocked", + "ty": { + "kind": "bool" + } + }, + { + "name": "routerAddress", + "ty": { + "kind": "address" + } + }, + { + "name": "totalSupply", + "ty": { + "kind": "coins" + } + }, + { + "name": "reserve0", + "ty": { + "kind": "coins" + } + }, + { + "name": "reserve1", + "ty": { + "kind": "coins" + } + }, + { + "name": "token0Address", + "ty": { + "kind": "address" + } + }, + { + "name": "token1Address", + "ty": { + "kind": "address" + } + }, + { + "name": "lpFee", + "ty": { + "kind": "uintN", + "n": 8 + } + }, + { + "name": "protocolFee", + "ty": { + "kind": "uintN", + "n": 8 + } + }, + { + "name": "protocolFeeAddress", + "ty": { + "kind": "address" + } + }, + { + "name": "collectedToken0ProtocolFee", + "ty": { + "kind": "coins" + } + }, + { + "name": "collectedToken1ProtocolFee", + "ty": { + "kind": "coins" + } + } + ] + }, + { + "kind": "Struct", + "name": "GetLpAccountAddressResult", + "fields": [ + { + "name": "lpAccountAddress", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "StonfiSwapOk", + "payloadType": "jetton", + "prefix": { + "prefixStr": "0xc64370e5", + "prefixLen": 32 + }, + "fields": [] + } + ], + "incomingMessages": [], + "outgoingMessages": [], + "emittedEvents": [], + "storage": { + "storageTy": { + "kind": "nullLiteral" + } + }, + "getMethods": [ + { + "tvmMethodId": 81689, + "name": "get_pool_data", + "parameters": [], + "returnTy": { + "kind": "StructRef", + "structName": "GetPoolDataStonfiV2" + } + }, + { + "tvmMethodId": 87316, + "name": "get_lp_account_address", + "parameters": [ + { + "name": "owner", + "ty": { + "kind": "address" + } + } + ], + "returnTy": { + "kind": "StructRef", + "structName": "GetLpAccountAddressResult" + } + } + ], + "thrownErrors": [], + "compilerName": "tolk", + "compilerVersion": "1.2.0", + "codeBoc64": "te6ccgEBBQEAvgABFP8A9KQT9LzyyAsBAgFiAgMADNAw+JHyQAH5oH4y4RoQwAGCXVPSRUXCgMDGb9zKg9EFYwRDBjv+JoMDibUwTh0duQQgC+vCAKYBGhDAAYJdU9JFRcKAwMZv3MqD0QVjBEMGO/4mgwOJtTBOHR25GhDAAYJdU9JFRcKAwMZv3MqD0QVjBEMGO/4mgwOJtTBOHR244EESpisEAEOAAwS6p6SKi4UBgYzfuZUHogrGCIYMd/xNBgcTamCcOjtw" +} \ No newline at end of file diff --git a/abi-tolk/schemas/stonfi_v2_stable_swap.json b/abi-tolk/schemas/stonfi_v2_stable_swap.json new file mode 100644 index 00000000..aad6fa7e --- /dev/null +++ b/abi-tolk/schemas/stonfi_v2_stable_swap.json @@ -0,0 +1,228 @@ +{ + "namespace": "ton.stonfi.v2", + "contractName": "PoolStableSwap", + "declarations": [ + { + "kind": "Struct", + "name": "GetPoolDataStonfiV2StableSwap", + "fields": [ + { + "name": "isLocked", + "ty": { + "kind": "bool" + } + }, + { + "name": "routerAddress", + "ty": { + "kind": "address" + } + }, + { + "name": "totalSupply", + "ty": { + "kind": "coins" + } + }, + { + "name": "reserve0", + "ty": { + "kind": "coins" + } + }, + { + "name": "reserve1", + "ty": { + "kind": "coins" + } + }, + { + "name": "token0Address", + "ty": { + "kind": "address" + } + }, + { + "name": "token1Address", + "ty": { + "kind": "address" + } + }, + { + "name": "lpFee", + "ty": { + "kind": "uintN", + "n": 8 + } + }, + { + "name": "protocolFee", + "ty": { + "kind": "uintN", + "n": 8 + } + }, + { + "name": "protocolFeeAddress", + "ty": { + "kind": "address" + } + }, + { + "name": "collectedToken0ProtocolFee", + "ty": { + "kind": "coins" + } + }, + { + "name": "collectedToken1ProtocolFee", + "ty": { + "kind": "coins" + } + }, + { + "name": "additional", + "ty": { + "kind": "uintN", + "n": 128 + } + } + ] + }, + { + "kind": "Struct", + "name": "GetLpAccountAddressResult", + "fields": [ + { + "name": "lpAccountAddress", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "StonfiProvideLiquidity", + "payloadType": "jetton", + "prefix": { + "prefixStr": "0xfcf9e58f", + "prefixLen": 32 + }, + "fields": [ + { + "name": "tokenWallet", + "ty": { + "kind": "address" + } + }, + { + "name": "minLpOut", + "ty": { + "kind": "coins" + } + } + ] + }, + { + "kind": "Struct", + "name": "CrossSwapBody", + "fields": [ + { + "name": "minOut", + "ty": { + "kind": "coins" + } + }, + { + "name": "receiver", + "ty": { + "kind": "address" + } + }, + { + "name": "fwdGas", + "ty": { + "kind": "coins" + } + }, + { + "name": "customPayload", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cell" + } + } + }, + { + "name": "refundFwdGas", + "ty": { + "kind": "coins" + } + }, + { + "name": "refundPayload", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cell" + } + } + }, + { + "name": "refFee", + "ty": { + "kind": "uintN", + "n": 16 + } + }, + { + "name": "refAddress", + "ty": { + "kind": "address" + } + } + ] + } + ], + "incomingMessages": [], + "outgoingMessages": [], + "emittedEvents": [], + "storage": { + "storageTy": { + "kind": "nullLiteral" + } + }, + "getMethods": [ + { + "tvmMethodId": 81689, + "name": "get_pool_data", + "parameters": [], + "returnTy": { + "kind": "StructRef", + "structName": "GetPoolDataStonfiV2StableSwap" + } + }, + { + "tvmMethodId": 87316, + "name": "get_lp_account_address", + "parameters": [ + { + "name": "owner", + "ty": { + "kind": "address" + } + } + ], + "returnTy": { + "kind": "StructRef", + "structName": "GetLpAccountAddressResult" + } + } + ], + "thrownErrors": [], + "compilerName": "tolk", + "compilerVersion": "1.2.0", + "codeBoc64": "te6ccgEBBQEAvwABFP8A9KQT9LzyyAsBAgFiAgMADNAw+JHyQAH7oH4y4RoQwAGCXVPSRUXCgMDGb9zKg9EFYwRDBjv+JoMDibUwTh0duQQgC+vCAKYBGhDAAYJdU9JFRcKAwMZv3MqD0QVjBEMGO/4mgwOJtTBOHR25GhDAAYJdU9JFRcKAwMZv3MqD0QVjBEMGO/4mgwOJtTBOHR244EESpirjBABDgAMEuqekiouFAYGM37mVB6IKxgiGDHf8TQYHE2pgnDo7cA==" +} \ No newline at end of file diff --git a/abi-tolk/schemas/stonfi_v2_weighted_stable_swap.json b/abi-tolk/schemas/stonfi_v2_weighted_stable_swap.json new file mode 100644 index 00000000..e4ac294a --- /dev/null +++ b/abi-tolk/schemas/stonfi_v2_weighted_stable_swap.json @@ -0,0 +1,203 @@ +{ + "namespace": "ton.stonfi.v2", + "contractName": "PoolWeightedStableSwap", + "declarations": [ + { + "kind": "Struct", + "name": "GetPoolDataStonfiV2WeightedStableSwap", + "fields": [ + { + "name": "isLocked", + "ty": { + "kind": "bool" + } + }, + { + "name": "routerAddress", + "ty": { + "kind": "address" + } + }, + { + "name": "totalSupply", + "ty": { + "kind": "coins" + } + }, + { + "name": "reserve0", + "ty": { + "kind": "coins" + } + }, + { + "name": "reserve1", + "ty": { + "kind": "coins" + } + }, + { + "name": "token0Address", + "ty": { + "kind": "address" + } + }, + { + "name": "token1Address", + "ty": { + "kind": "address" + } + }, + { + "name": "lpFee", + "ty": { + "kind": "uintN", + "n": 8 + } + }, + { + "name": "protocolFee", + "ty": { + "kind": "uintN", + "n": 8 + } + }, + { + "name": "protocolFeeAddress", + "ty": { + "kind": "address" + } + }, + { + "name": "collectedToken0ProtocolFee", + "ty": { + "kind": "coins" + } + }, + { + "name": "collectedToken1ProtocolFee", + "ty": { + "kind": "coins" + } + }, + { + "name": "amp", + "ty": { + "kind": "uintN", + "n": 128 + } + }, + { + "name": "rate", + "ty": { + "kind": "uintN", + "n": 128 + } + }, + { + "name": "w0", + "ty": { + "kind": "uintN", + "n": 128 + } + }, + { + "name": "rate_setter", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "GetLpAccountAddressResult", + "fields": [ + { + "name": "lpAccountAddress", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "CrossProvideLpBody", + "fields": [ + { + "name": "minLpOut", + "ty": { + "kind": "coins" + } + }, + { + "name": "toAddress", + "ty": { + "kind": "address" + } + }, + { + "name": "bothPositive", + "ty": { + "kind": "bool" + } + }, + { + "name": "fwdAmount", + "ty": { + "kind": "coins" + } + }, + { + "name": "customPayload", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cell" + } + } + } + ] + } + ], + "incomingMessages": [], + "outgoingMessages": [], + "emittedEvents": [], + "storage": { + "storageTy": { + "kind": "nullLiteral" + } + }, + "getMethods": [ + { + "tvmMethodId": 81689, + "name": "get_pool_data", + "parameters": [], + "returnTy": { + "kind": "StructRef", + "structName": "GetPoolDataStonfiV2WeightedStableSwap" + } + }, + { + "tvmMethodId": 87316, + "name": "get_lp_account_address", + "parameters": [ + { + "name": "owner", + "ty": { + "kind": "address" + } + } + ], + "returnTy": { + "kind": "StructRef", + "structName": "GetLpAccountAddressResult" + } + } + ], + "thrownErrors": [], + "compilerName": "tolk", + "compilerVersion": "1.2.0", + "codeBoc64": "te6ccgEBBQEAvwABFP8A9KQT9LzyyAsBAgFiAgMADNAw+JHyQAH7oH4y4RoQwAGCXVPSRUXCgMDGb9zKg9EFYwRDBjv+JoMDibUwTh0duQQgC+vCAKYBGhDAAYJdU9JFRcKAwMZv3MqD0QVjBEMGO/4mgwOJtTBOHR25GhDAAYJdU9JFRcKAwMZv3MqD0QVjBEMGO/4mgwOJtTBOHR244EESpirjBABDgAMEuqekiouFAYGM37mVB6IKxgiGDHf8TQYHE2pgnDo7cA==" +} \ No newline at end of file diff --git a/abi-tolk/types.go b/abi-tolk/types.go new file mode 100644 index 00000000..3440a51c --- /dev/null +++ b/abi-tolk/types.go @@ -0,0 +1,1371 @@ +package abitolk + +// Code autogenerated. DO NOT EDIT. + +import ( + "encoding/json" + "fmt" + "github.com/tonkeeper/tongo/tlb" +) + +type TonCocoonReturnExcessesBack struct { + QueryId uint64 +} + +type TonCocoonPayout struct { + QueryId uint64 +} + +type TonCocoonWorkerProxyRequest struct { + QueryId uint64 + OwnerAddress tlb.MsgAddress + State tlb.Uint2 + Tokens uint64 + Payload *tlb.Any `tlb:"maybe^"` +} + +type TonCocoonWorkerProxyPayoutRequest struct { + WorkerPart tlb.VarUInteger16 + ProxyPart tlb.VarUInteger16 + SendExcessesTo tlb.MsgAddress +} + +type TonCocoonClientStateData struct { + State tlb.Uint2 + Balance tlb.VarUInteger16 + Stake tlb.VarUInteger16 + TokensUsed uint64 + SecretHash tlb.Uint256 +} + +type TonCocoonClientProxyRequest struct { + QueryId uint64 + OwnerAddress tlb.MsgAddress + StateData TonCocoonClientStateData `tlb:"^"` + Payload *tlb.Any `tlb:"maybe^"` +} + +type TonCocoonClientProxyTopUp struct { + TopUpCoins tlb.VarUInteger16 + SendExcessesTo tlb.MsgAddress +} + +type TonCocoonClientProxyRegister struct { +} + +type TonCocoonClientProxyRefundGranted struct { + Coins tlb.VarUInteger16 + SendExcessesTo tlb.MsgAddress +} + +type TonCocoonClientProxyRefundForce struct { + Coins tlb.VarUInteger16 + SendExcessesTo tlb.MsgAddress +} + +type TonCocoonQueryHeader struct { + Op uint32 + QueryId uint64 +} + +type TonCocoonSignedMessage struct { + Op uint32 + QueryId uint64 + SendExcessesTo tlb.MsgAddress + Signature tlb.Bits512 + SignedDataCell tlb.Any `tlb:"^"` +} + +type TonCocoonPayoutPayloadData struct { + QueryId uint64 + NewTokens uint64 + ExpectedMyAddress tlb.MsgAddress +} + +type TonCocoonPayoutPayload struct { + Data TonCocoonPayoutPayloadData +} + +type TonCocoonLastPayoutPayload struct { + Data TonCocoonPayoutPayloadData +} + +type TonCocoonAddWorkerType struct { + QueryId uint64 + WorkerHash tlb.Uint256 +} + +type TonCocoonDelWorkerType struct { + QueryId uint64 + WorkerHash tlb.Uint256 +} + +type TonCocoonAddModelType struct { + QueryId uint64 + ModelHash tlb.Uint256 +} + +type TonCocoonDelModelType struct { + QueryId uint64 + ModelHash tlb.Uint256 +} + +type TonCocoonAddProxyType struct { + QueryId uint64 + ProxyHash tlb.Uint256 +} + +type TonCocoonDelProxyType struct { + QueryId uint64 + ProxyHash tlb.Uint256 +} + +type TonCocoonRegisterProxy struct { + QueryId uint64 + ProxyInfo tlb.Any +} + +type TonCocoonUnregisterProxy struct { + QueryId uint64 + Seqno uint32 +} + +type TonCocoonUpdateProxy struct { + QueryId uint64 + Seqno uint32 + ProxyAddr tlb.Any +} + +type TonCocoonChangeFees struct { + QueryId uint64 + PricePerToken tlb.VarUInteger16 + WorkerFeePerToken tlb.VarUInteger16 +} + +type TonCocoonChangeParams struct { + QueryId uint64 + PricePerToken tlb.VarUInteger16 + WorkerFeePerToken tlb.VarUInteger16 + ProxyDelayBeforeClose uint32 + ClientDelayBeforeClose uint32 + MinProxyStake tlb.VarUInteger16 + MinClientStake tlb.VarUInteger16 +} + +type TonCocoonUpgradeContracts struct { + QueryId uint64 + ProxyCode tlb.Any `tlb:"^"` + WorkerCode tlb.Any `tlb:"^"` + ClientCode tlb.Any `tlb:"^"` +} + +type TonCocoonUpgradeCode struct { + QueryId uint64 + NewCode tlb.Any `tlb:"^"` +} + +type TonCocoonResetRoot struct { + QueryId uint64 +} + +type TonCocoonUpgradeFull struct { + QueryId uint64 + NewData tlb.Any `tlb:"^"` + NewCode tlb.Any `tlb:"^"` +} + +type TonCocoonChangeOwner struct { + QueryId uint64 + NewOwnerAddress tlb.MsgAddress +} + +type TonCocoonOwnerWorkerRegister struct { + QueryId uint64 + SendExcessesTo tlb.MsgAddress +} + +type TonCocoonExtProxyPayoutRequest struct { + QueryId uint64 + SendExcessesTo tlb.MsgAddress +} + +type TonCocoonExtProxyIncreaseStake struct { + QueryId uint64 + Grams tlb.VarUInteger16 + SendExcessesTo tlb.MsgAddress +} + +type TonCocoonOwnerProxyClose struct { + QueryId uint64 + SendExcessesTo tlb.MsgAddress +} + +type TonCocoonCloseRequestPayload struct { + QueryId uint64 + ExpectedMyAddress tlb.MsgAddress +} + +type TonCocoonCloseCompleteRequestPayload struct { + QueryId uint64 + ExpectedMyAddress tlb.MsgAddress +} + +type TonCocoonExtClientTopUp struct { + QueryId uint64 + TopUpAmount tlb.VarUInteger16 + SendExcessesTo tlb.MsgAddress +} + +type TonCocoonOwnerClientChangeSecretHashAndTopUp struct { + QueryId uint64 + TopUpAmount tlb.VarUInteger16 + NewSecretHash tlb.Uint256 + SendExcessesTo tlb.MsgAddress +} + +type TonCocoonOwnerClientRegister struct { + QueryId uint64 + Nonce uint64 + SendExcessesTo tlb.MsgAddress +} + +type TonCocoonOwnerClientChangeSecretHash struct { + QueryId uint64 + NewSecretHash tlb.Uint256 + SendExcessesTo tlb.MsgAddress +} + +type TonCocoonOwnerClientIncreaseStake struct { + QueryId uint64 + NewStake tlb.VarUInteger16 + SendExcessesTo tlb.MsgAddress +} + +type TonCocoonOwnerClientWithdraw struct { + QueryId uint64 + SendExcessesTo tlb.MsgAddress +} + +type TonCocoonOwnerClientRequestRefund struct { + QueryId uint64 + SendExcessesTo tlb.MsgAddress +} + +type TonCocoonChargePayload struct { + QueryId uint64 + NewTokensUsed uint64 + ExpectedMyAddress tlb.MsgAddress +} + +type TonCocoonGrantRefundPayload struct { + QueryId uint64 + NewTokensUsed uint64 + ExpectedMyAddress tlb.MsgAddress +} + +type TonCocoonCocoonParams struct { + StructVersion uint8 + ParamsVersion uint32 + UniqueId uint32 + IsTest bool + PricePerToken tlb.VarUInteger16 + WorkerFeePerToken tlb.VarUInteger16 + PromptTokensPriceMultiplier uint32 + CachedTokensPriceMultiplier uint32 + CompletionTokensPriceMultiplier uint32 + ReasoningTokensPriceMultiplier uint32 + ProxyDelayBeforeClose uint32 + ClientDelayBeforeClose uint32 + MinProxyStake tlb.VarUInteger16 + MinClientStake tlb.VarUInteger16 + ProxyScCode *tlb.Any `tlb:"maybe^"` + WorkerScCode *tlb.Any `tlb:"maybe^"` + ClientScCode *tlb.Any `tlb:"maybe^"` +} + +type TonCocoonRootData struct { + ProxyHashes TonCocoonDict + WorkerHashes TonCocoonDict + LastProxySeqno uint32 + RegisteredProxies TonCocoonDict + ModelHashes TonCocoonDict +} + +type TonCocoonRootStorage struct { + OwnerAddress tlb.MsgAddress + Version uint32 + Data TonCocoonRootData `tlb:"^"` + Params TonCocoonCocoonParams `tlb:"^"` +} + +type TonCocoonProxyStorage struct { + OwnerAddress tlb.MsgAddress + ProxyPublicKey tlb.Uint256 + RootAddress tlb.MsgAddress + State tlb.Uint2 + Balance tlb.VarUInteger16 + Stake tlb.VarUInteger16 + UnlockTs uint32 + Params TonCocoonCocoonParams `tlb:"^"` +} + +type TonCocoonWorkerStorage struct { + OwnerAddress tlb.MsgAddress + ProxyAddress tlb.MsgAddress + ProxyPublicKey tlb.Uint256 + State tlb.Uint2 + Tokens uint64 + Params TonCocoonCocoonParams `tlb:"^"` +} + +type TonCocoonClientConstData struct { + OwnerAddress tlb.MsgAddress + ProxyAddress tlb.MsgAddress + ProxyPublicKey tlb.Uint256 +} + +type TonCocoonClientStorage struct { + State tlb.Uint2 + Balance tlb.VarUInteger16 + Stake tlb.VarUInteger16 + TokensUsed uint64 + UnlockTs uint32 + SecretHash tlb.Uint256 + ConstDataRef TonCocoonClientConstData `tlb:"^"` + Params TonCocoonCocoonParams `tlb:"^"` +} + +type TonCocoonWalletStorage struct { + Seqno uint32 + SubwalletId uint32 + PublicKey tlb.Uint256 + Status uint32 + OwnerAddress tlb.MsgAddress +} + +type TonCocoonExtClientChargeSigned struct { + Rest tlb.Any +} + +type TonCocoonExtClientGrantRefundSigned struct { + Rest tlb.Any +} + +type TonCocoonSignedClientMessage struct { + tlb.SumType + UnionVariant0 TonCocoonExtClientChargeSigned `tlbSumType:"#bb63ff93"` + UnionVariant1 TonCocoonExtClientGrantRefundSigned `tlbSumType:"#efd711e1"` +} + +type TonCocoonClientSignedPayload struct { + tlb.SumType + UnionVariant0 TonCocoonChargePayload `tlbSumType:"#bb63ff93"` + UnionVariant1 TonCocoonGrantRefundPayload `tlbSumType:"#efd711e1"` +} + +type TonCocoonClientMessage struct { + tlb.SumType + UnionVariant0 TonCocoonExtClientChargeSigned `tlbSumType:"#bb63ff93"` + UnionVariant1 TonCocoonExtClientGrantRefundSigned `tlbSumType:"#efd711e1"` + UnionVariant2 TonCocoonExtClientTopUp `tlbSumType:"#f172e6c2"` + UnionVariant3 TonCocoonOwnerClientChangeSecretHashAndTopUp `tlbSumType:"#8473b408"` + UnionVariant4 TonCocoonOwnerClientRegister `tlbSumType:"#c45f9f3b"` + UnionVariant5 TonCocoonOwnerClientChangeSecretHash `tlbSumType:"#a9357034"` + UnionVariant6 TonCocoonOwnerClientIncreaseStake `tlbSumType:"#6a1f6a60"` + UnionVariant7 TonCocoonOwnerClientWithdraw `tlbSumType:"#da068e78"` + UnionVariant8 TonCocoonOwnerClientRequestRefund `tlbSumType:"#fafa6cc1"` +} + +func (t *TonCocoonClientMessage) MarshalJSON() ([]byte, error) { + switch t.SumType { + case "UnionVariant0": + bytes, err := json.Marshal(t.UnionVariant0) + if err != nil { + return nil, err + } + return []byte(fmt.Sprintf(`{"SumType": "UnionVariant0","UnionVariant0":%v}`, string(bytes))), nil + case "UnionVariant1": + bytes, err := json.Marshal(t.UnionVariant1) + if err != nil { + return nil, err + } + return []byte(fmt.Sprintf(`{"SumType": "UnionVariant1","UnionVariant1":%v}`, string(bytes))), nil + case "UnionVariant2": + bytes, err := json.Marshal(t.UnionVariant2) + if err != nil { + return nil, err + } + return []byte(fmt.Sprintf(`{"SumType": "UnionVariant2","UnionVariant2":%v}`, string(bytes))), nil + case "UnionVariant3": + bytes, err := json.Marshal(t.UnionVariant3) + if err != nil { + return nil, err + } + return []byte(fmt.Sprintf(`{"SumType": "UnionVariant3","UnionVariant3":%v}`, string(bytes))), nil + case "UnionVariant4": + bytes, err := json.Marshal(t.UnionVariant4) + if err != nil { + return nil, err + } + return []byte(fmt.Sprintf(`{"SumType": "UnionVariant4","UnionVariant4":%v}`, string(bytes))), nil + case "UnionVariant5": + bytes, err := json.Marshal(t.UnionVariant5) + if err != nil { + return nil, err + } + return []byte(fmt.Sprintf(`{"SumType": "UnionVariant5","UnionVariant5":%v}`, string(bytes))), nil + case "UnionVariant6": + bytes, err := json.Marshal(t.UnionVariant6) + if err != nil { + return nil, err + } + return []byte(fmt.Sprintf(`{"SumType": "UnionVariant6","UnionVariant6":%v}`, string(bytes))), nil + case "UnionVariant7": + bytes, err := json.Marshal(t.UnionVariant7) + if err != nil { + return nil, err + } + return []byte(fmt.Sprintf(`{"SumType": "UnionVariant7","UnionVariant7":%v}`, string(bytes))), nil + case "UnionVariant8": + bytes, err := json.Marshal(t.UnionVariant8) + if err != nil { + return nil, err + } + return []byte(fmt.Sprintf(`{"SumType": "UnionVariant8","UnionVariant8":%v}`, string(bytes))), nil + default: + return nil, fmt.Errorf("unknown sum type %v", t.SumType) + } +} + +type TonCocoonDict tlb.Maybe[tlb.Ref[tlb.Any]] + +type TonCocoonTextCmd struct { + Action uint8 +} + +type TonCocoonSignedProxyPayload struct { + tlb.SumType + UnionVariant0 TonCocoonCloseRequestPayload `tlbSumType:"#636a4391"` + UnionVariant1 TonCocoonCloseCompleteRequestPayload `tlbSumType:"#e511abc7"` +} + +type TonCocoonExtProxyCloseRequestSigned struct { + Rest tlb.Any +} + +type TonCocoonExtProxyCloseCompleteRequestSigned struct { + Rest tlb.Any +} + +type TonCocoonSignedProxyMessage struct { + tlb.SumType + UnionVariant0 TonCocoonExtProxyCloseRequestSigned `tlbSumType:"#636a4391"` + UnionVariant1 TonCocoonExtProxyCloseCompleteRequestSigned `tlbSumType:"#e511abc7"` +} + +type TonCocoonClientProxyPayload struct { + tlb.SumType + UnionVariant0 TonCocoonClientProxyTopUp `tlbSumType:"#5cfc6b87"` + UnionVariant1 TonCocoonClientProxyRegister `tlbSumType:"#a35cb580"` + UnionVariant2 TonCocoonClientProxyRefundGranted `tlbSumType:"#c68ebc7b"` + UnionVariant3 TonCocoonClientProxyRefundForce `tlbSumType:"#f4c354c9"` +} + +func (t *TonCocoonClientProxyPayload) MarshalJSON() ([]byte, error) { + switch t.SumType { + case "UnionVariant0": + bytes, err := json.Marshal(t.UnionVariant0) + if err != nil { + return nil, err + } + return []byte(fmt.Sprintf(`{"SumType": "UnionVariant0","UnionVariant0":%v}`, string(bytes))), nil + case "UnionVariant1": + bytes, err := json.Marshal(t.UnionVariant1) + if err != nil { + return nil, err + } + return []byte(fmt.Sprintf(`{"SumType": "UnionVariant1","UnionVariant1":%v}`, string(bytes))), nil + case "UnionVariant2": + bytes, err := json.Marshal(t.UnionVariant2) + if err != nil { + return nil, err + } + return []byte(fmt.Sprintf(`{"SumType": "UnionVariant2","UnionVariant2":%v}`, string(bytes))), nil + case "UnionVariant3": + bytes, err := json.Marshal(t.UnionVariant3) + if err != nil { + return nil, err + } + return []byte(fmt.Sprintf(`{"SumType": "UnionVariant3","UnionVariant3":%v}`, string(bytes))), nil + default: + return nil, fmt.Errorf("unknown sum type %v", t.SumType) + } +} + +type TonCocoonWorkerProxyPayload TonCocoonWorkerProxyPayoutRequest + +type TonCocoonProxyMessage struct { + tlb.SumType + UnionVariant0 TonCocoonTextCmd `tlbSumType:"#00000000"` + UnionVariant1 TonCocoonExtProxyCloseRequestSigned `tlbSumType:"#636a4391"` + UnionVariant2 TonCocoonExtProxyCloseCompleteRequestSigned `tlbSumType:"#e511abc7"` + UnionVariant3 TonCocoonExtProxyPayoutRequest `tlbSumType:"#7610e6eb"` + UnionVariant4 TonCocoonExtProxyIncreaseStake `tlbSumType:"#9713f187"` + UnionVariant5 TonCocoonOwnerProxyClose `tlbSumType:"#b51d5a01"` + UnionVariant6 TonCocoonWorkerProxyRequest `tlbSumType:"#4d725d2c"` + UnionVariant7 TonCocoonClientProxyRequest `tlbSumType:"#65448ff4"` +} + +func (t *TonCocoonProxyMessage) MarshalJSON() ([]byte, error) { + switch t.SumType { + case "UnionVariant0": + bytes, err := json.Marshal(t.UnionVariant0) + if err != nil { + return nil, err + } + return []byte(fmt.Sprintf(`{"SumType": "UnionVariant0","UnionVariant0":%v}`, string(bytes))), nil + case "UnionVariant1": + bytes, err := json.Marshal(t.UnionVariant1) + if err != nil { + return nil, err + } + return []byte(fmt.Sprintf(`{"SumType": "UnionVariant1","UnionVariant1":%v}`, string(bytes))), nil + case "UnionVariant2": + bytes, err := json.Marshal(t.UnionVariant2) + if err != nil { + return nil, err + } + return []byte(fmt.Sprintf(`{"SumType": "UnionVariant2","UnionVariant2":%v}`, string(bytes))), nil + case "UnionVariant3": + bytes, err := json.Marshal(t.UnionVariant3) + if err != nil { + return nil, err + } + return []byte(fmt.Sprintf(`{"SumType": "UnionVariant3","UnionVariant3":%v}`, string(bytes))), nil + case "UnionVariant4": + bytes, err := json.Marshal(t.UnionVariant4) + if err != nil { + return nil, err + } + return []byte(fmt.Sprintf(`{"SumType": "UnionVariant4","UnionVariant4":%v}`, string(bytes))), nil + case "UnionVariant5": + bytes, err := json.Marshal(t.UnionVariant5) + if err != nil { + return nil, err + } + return []byte(fmt.Sprintf(`{"SumType": "UnionVariant5","UnionVariant5":%v}`, string(bytes))), nil + case "UnionVariant6": + bytes, err := json.Marshal(t.UnionVariant6) + if err != nil { + return nil, err + } + return []byte(fmt.Sprintf(`{"SumType": "UnionVariant6","UnionVariant6":%v}`, string(bytes))), nil + case "UnionVariant7": + bytes, err := json.Marshal(t.UnionVariant7) + if err != nil { + return nil, err + } + return []byte(fmt.Sprintf(`{"SumType": "UnionVariant7","UnionVariant7":%v}`, string(bytes))), nil + default: + return nil, fmt.Errorf("unknown sum type %v", t.SumType) + } +} + +type TonCocoonRootMessage struct { + tlb.SumType + UnionVariant0 TonCocoonAddWorkerType `tlbSumType:"#e34b1c60"` + UnionVariant1 TonCocoonDelWorkerType `tlbSumType:"#8d94a79a"` + UnionVariant2 TonCocoonAddModelType `tlbSumType:"#c146134d"` + UnionVariant3 TonCocoonDelModelType `tlbSumType:"#92b11c18"` + UnionVariant4 TonCocoonAddProxyType `tlbSumType:"#71860e80"` + UnionVariant5 TonCocoonDelProxyType `tlbSumType:"#3c41d0b2"` + UnionVariant6 TonCocoonRegisterProxy `tlbSumType:"#927c7cb5"` + UnionVariant7 TonCocoonUnregisterProxy `tlbSumType:"#6d49eaf2"` + UnionVariant8 TonCocoonUpdateProxy `tlbSumType:"#9c7924ba"` + UnionVariant9 TonCocoonChangeFees `tlbSumType:"#c52ed8d4"` + UnionVariant10 TonCocoonChangeParams `tlbSumType:"#022fa189"` + UnionVariant11 TonCocoonUpgradeContracts `tlbSumType:"#a2370f61"` + UnionVariant12 TonCocoonUpgradeCode `tlbSumType:"#11aefd51"` + UnionVariant13 TonCocoonResetRoot `tlbSumType:"#563c1d96"` + UnionVariant14 TonCocoonUpgradeFull `tlbSumType:"#4f7c5789"` + UnionVariant15 TonCocoonChangeOwner `tlbSumType:"#c4a1ae54"` +} + +func (t *TonCocoonRootMessage) MarshalJSON() ([]byte, error) { + switch t.SumType { + case "UnionVariant0": + bytes, err := json.Marshal(t.UnionVariant0) + if err != nil { + return nil, err + } + return []byte(fmt.Sprintf(`{"SumType": "UnionVariant0","UnionVariant0":%v}`, string(bytes))), nil + case "UnionVariant1": + bytes, err := json.Marshal(t.UnionVariant1) + if err != nil { + return nil, err + } + return []byte(fmt.Sprintf(`{"SumType": "UnionVariant1","UnionVariant1":%v}`, string(bytes))), nil + case "UnionVariant2": + bytes, err := json.Marshal(t.UnionVariant2) + if err != nil { + return nil, err + } + return []byte(fmt.Sprintf(`{"SumType": "UnionVariant2","UnionVariant2":%v}`, string(bytes))), nil + case "UnionVariant3": + bytes, err := json.Marshal(t.UnionVariant3) + if err != nil { + return nil, err + } + return []byte(fmt.Sprintf(`{"SumType": "UnionVariant3","UnionVariant3":%v}`, string(bytes))), nil + case "UnionVariant4": + bytes, err := json.Marshal(t.UnionVariant4) + if err != nil { + return nil, err + } + return []byte(fmt.Sprintf(`{"SumType": "UnionVariant4","UnionVariant4":%v}`, string(bytes))), nil + case "UnionVariant5": + bytes, err := json.Marshal(t.UnionVariant5) + if err != nil { + return nil, err + } + return []byte(fmt.Sprintf(`{"SumType": "UnionVariant5","UnionVariant5":%v}`, string(bytes))), nil + case "UnionVariant6": + bytes, err := json.Marshal(t.UnionVariant6) + if err != nil { + return nil, err + } + return []byte(fmt.Sprintf(`{"SumType": "UnionVariant6","UnionVariant6":%v}`, string(bytes))), nil + case "UnionVariant7": + bytes, err := json.Marshal(t.UnionVariant7) + if err != nil { + return nil, err + } + return []byte(fmt.Sprintf(`{"SumType": "UnionVariant7","UnionVariant7":%v}`, string(bytes))), nil + case "UnionVariant8": + bytes, err := json.Marshal(t.UnionVariant8) + if err != nil { + return nil, err + } + return []byte(fmt.Sprintf(`{"SumType": "UnionVariant8","UnionVariant8":%v}`, string(bytes))), nil + case "UnionVariant9": + bytes, err := json.Marshal(t.UnionVariant9) + if err != nil { + return nil, err + } + return []byte(fmt.Sprintf(`{"SumType": "UnionVariant9","UnionVariant9":%v}`, string(bytes))), nil + case "UnionVariant10": + bytes, err := json.Marshal(t.UnionVariant10) + if err != nil { + return nil, err + } + return []byte(fmt.Sprintf(`{"SumType": "UnionVariant10","UnionVariant10":%v}`, string(bytes))), nil + case "UnionVariant11": + bytes, err := json.Marshal(t.UnionVariant11) + if err != nil { + return nil, err + } + return []byte(fmt.Sprintf(`{"SumType": "UnionVariant11","UnionVariant11":%v}`, string(bytes))), nil + case "UnionVariant12": + bytes, err := json.Marshal(t.UnionVariant12) + if err != nil { + return nil, err + } + return []byte(fmt.Sprintf(`{"SumType": "UnionVariant12","UnionVariant12":%v}`, string(bytes))), nil + case "UnionVariant13": + bytes, err := json.Marshal(t.UnionVariant13) + if err != nil { + return nil, err + } + return []byte(fmt.Sprintf(`{"SumType": "UnionVariant13","UnionVariant13":%v}`, string(bytes))), nil + case "UnionVariant14": + bytes, err := json.Marshal(t.UnionVariant14) + if err != nil { + return nil, err + } + return []byte(fmt.Sprintf(`{"SumType": "UnionVariant14","UnionVariant14":%v}`, string(bytes))), nil + case "UnionVariant15": + bytes, err := json.Marshal(t.UnionVariant15) + if err != nil { + return nil, err + } + return []byte(fmt.Sprintf(`{"SumType": "UnionVariant15","UnionVariant15":%v}`, string(bytes))), nil + default: + return nil, fmt.Errorf("unknown sum type %v", t.SumType) + } +} + +type TonCocoonExternalSignedMessage struct { + SubwalletId uint32 + ValidUntil uint32 + MsgSeqno uint32 + Rest tlb.Any +} + +type TonCocoonOwnerWalletSendMessage struct { + QueryId uint64 + Mode uint8 + Body tlb.Any `tlb:"^"` +} + +type TonCocoonTextCommand struct { + Action uint8 +} + +type TonCocoonAllowedInternalMessage struct { + tlb.SumType + UnionVariant0 TonCocoonOwnerWalletSendMessage `tlbSumType:"#9c69f376"` + UnionVariant1 TonCocoonTextCommand `tlbSumType:"#00000000"` +} + +type TonCocoonExtWorkerPayoutRequestSigned struct { + Rest tlb.Any +} + +type TonCocoonExtWorkerLastPayoutRequestSigned struct { + Rest tlb.Any +} + +type TonCocoonSignedWorkerMessage struct { + tlb.SumType + UnionVariant0 TonCocoonExtWorkerPayoutRequestSigned `tlbSumType:"#a040ad28"` + UnionVariant1 TonCocoonExtWorkerLastPayoutRequestSigned `tlbSumType:"#f5f26a36"` +} + +type TonCocoonSignedPayload struct { + tlb.SumType + UnionVariant0 TonCocoonPayoutPayload `tlbSumType:"#a040ad28"` + UnionVariant1 TonCocoonLastPayoutPayload `tlbSumType:"#f5f26a36"` +} + +type TonCocoonWorkerMessage struct { + tlb.SumType + UnionVariant0 TonCocoonExtWorkerPayoutRequestSigned `tlbSumType:"#a040ad28"` + UnionVariant1 TonCocoonExtWorkerLastPayoutRequestSigned `tlbSumType:"#f5f26a36"` + UnionVariant2 TonCocoonOwnerWorkerRegister `tlbSumType:"#26ed7f65"` +} + +func (t *TonCocoonWorkerMessage) MarshalJSON() ([]byte, error) { + switch t.SumType { + case "UnionVariant0": + bytes, err := json.Marshal(t.UnionVariant0) + if err != nil { + return nil, err + } + return []byte(fmt.Sprintf(`{"SumType": "UnionVariant0","UnionVariant0":%v}`, string(bytes))), nil + case "UnionVariant1": + bytes, err := json.Marshal(t.UnionVariant1) + if err != nil { + return nil, err + } + return []byte(fmt.Sprintf(`{"SumType": "UnionVariant1","UnionVariant1":%v}`, string(bytes))), nil + case "UnionVariant2": + bytes, err := json.Marshal(t.UnionVariant2) + if err != nil { + return nil, err + } + return []byte(fmt.Sprintf(`{"SumType": "UnionVariant2","UnionVariant2":%v}`, string(bytes))), nil + default: + return nil, fmt.Errorf("unknown sum type %v", t.SumType) + } +} + +type TonCoffeeCrossDexResend struct { + QueryId uint64 + NextRecipient tlb.MsgAddress + Next tlb.Any `tlb:"^"` + TotalGas tlb.VarUInteger16 + NextGas tlb.VarUInteger16 +} + +type TonDedustStep struct { + KindOut bool + Limit tlb.VarUInteger16 + Next *tlb.Any `tlb:"maybe^"` +} + +type TonDedustSwapParams struct { + Deadline uint32 + RecipientAddr tlb.MsgAddress + ReferralAddr tlb.MsgAddress + FulfillPayload *tlb.Any `tlb:"maybe^"` + RejectPayload *tlb.Any `tlb:"maybe^"` +} + +type TonDedustDedustSwap struct { + Step TonDedustStep + Params TonDedustSwapParams `tlb:"^"` +} + +type TonTep74WalletStorage struct { + JettonBalance tlb.VarUInteger16 + OwnerAddress tlb.MsgAddress + MinterAddress tlb.MsgAddress +} + +type TonTep74MinterStorage struct { + TotalSupply tlb.VarUInteger16 + AdminAddress tlb.MsgAddress + Content tlb.Any `tlb:"^"` + JettonWalletCode tlb.Any `tlb:"^"` +} + +type TonTep74ForwardPayloadRemainder tlb.Any + +type TonTep74AskToTransfer struct { + QueryId uint64 + JettonAmount tlb.VarUInteger16 + TransferRecipient tlb.MsgAddress + SendExcessesTo tlb.MsgAddress + CustomPayload *tlb.Any `tlb:"maybe^"` + ForwardTonAmount tlb.VarUInteger16 + ForwardPayload tlb.EitherRef[Payload] +} + +type TonTep74TransferNotificationForRecipient struct { + QueryId uint64 + JettonAmount tlb.VarUInteger16 + TransferInitiator tlb.MsgAddress + ForwardPayload tlb.EitherRef[Payload] +} + +type TonTep74InternalTransferStep struct { + QueryId uint64 + JettonAmount tlb.VarUInteger16 + TransferInitiator tlb.MsgAddress + SendExcessesTo tlb.MsgAddress + ForwardTonAmount tlb.VarUInteger16 + ForwardPayload tlb.EitherRef[Payload] +} + +type TonTep74ReturnExcessesBack struct { + QueryId uint64 +} + +type TonTep74AskToBurn struct { + QueryId uint64 + JettonAmount tlb.VarUInteger16 + SendExcessesTo tlb.MsgAddress + CustomPayload tlb.EitherRef[Payload] +} + +type TonTep74BurnNotificationForMinter struct { + QueryId uint64 + JettonAmount tlb.VarUInteger16 + BurnInitiator tlb.MsgAddress + SendExcessesTo tlb.MsgAddress +} + +type TonTep74RequestWalletAddress struct { + QueryId uint64 + OwnerAddress tlb.MsgAddress + IncludeOwnerAddress bool +} + +type TonTep74ResponseWalletAddress struct { + QueryId uint64 + JettonWalletAddress tlb.MsgAddress + OwnerAddress *tlb.MsgAddress `tlb:"maybe^"` +} + +type TonTep74MintNewJettons struct { + QueryId uint64 + MintRecipient tlb.MsgAddress + TonAmount tlb.VarUInteger16 + InternalTransferMsg TonTep74InternalTransferStep `tlb:"^"` +} + +type TonTep74ChangeMinterAdmin struct { + QueryId uint64 + NewAdminAddress tlb.MsgAddress +} + +type TonTep74ChangeMinterContent struct { + QueryId uint64 + NewContent tlb.Any `tlb:"^"` +} + +type TonTep74AllowedMessageToMinter struct { + tlb.SumType + UnionVariant0 TonTep74MintNewJettons `tlbSumType:"#00000015"` + UnionVariant1 TonTep74BurnNotificationForMinter `tlbSumType:"#7bdd97de"` + UnionVariant2 TonTep74RequestWalletAddress `tlbSumType:"#2c76b973"` + UnionVariant3 TonTep74ChangeMinterAdmin `tlbSumType:"#00000003"` + UnionVariant4 TonTep74ChangeMinterContent `tlbSumType:"#00000004"` +} + +func (t *TonTep74AllowedMessageToMinter) MarshalJSON() ([]byte, error) { + switch t.SumType { + case "UnionVariant0": + bytes, err := json.Marshal(t.UnionVariant0) + if err != nil { + return nil, err + } + return []byte(fmt.Sprintf(`{"SumType": "UnionVariant0","UnionVariant0":%v}`, string(bytes))), nil + case "UnionVariant1": + bytes, err := json.Marshal(t.UnionVariant1) + if err != nil { + return nil, err + } + return []byte(fmt.Sprintf(`{"SumType": "UnionVariant1","UnionVariant1":%v}`, string(bytes))), nil + case "UnionVariant2": + bytes, err := json.Marshal(t.UnionVariant2) + if err != nil { + return nil, err + } + return []byte(fmt.Sprintf(`{"SumType": "UnionVariant2","UnionVariant2":%v}`, string(bytes))), nil + case "UnionVariant3": + bytes, err := json.Marshal(t.UnionVariant3) + if err != nil { + return nil, err + } + return []byte(fmt.Sprintf(`{"SumType": "UnionVariant3","UnionVariant3":%v}`, string(bytes))), nil + case "UnionVariant4": + bytes, err := json.Marshal(t.UnionVariant4) + if err != nil { + return nil, err + } + return []byte(fmt.Sprintf(`{"SumType": "UnionVariant4","UnionVariant4":%v}`, string(bytes))), nil + default: + return nil, fmt.Errorf("unknown sum type %v", t.SumType) + } +} + +type TonTep74JettonDataReply struct { + TotalSupply tlb.Int257 + Mintable bool + AdminAddress tlb.MsgAddress + JettonContent tlb.Any `tlb:"^"` + JettonWalletCode tlb.Any `tlb:"^"` +} + +type TonTep74AboaLisa TonTep74ReturnExcessesBack + +type TonTep74AllowedMessageToWallet struct { + tlb.SumType + UnionVariant0 TonTep74AskToTransfer `tlbSumType:"#0f8a7ea5"` + UnionVariant1 TonTep74AskToBurn `tlbSumType:"#595f07bc"` + UnionVariant2 TonTep74InternalTransferStep `tlbSumType:"#178d4519"` +} + +func (t *TonTep74AllowedMessageToWallet) MarshalJSON() ([]byte, error) { + switch t.SumType { + case "UnionVariant0": + bytes, err := json.Marshal(t.UnionVariant0) + if err != nil { + return nil, err + } + return []byte(fmt.Sprintf(`{"SumType": "UnionVariant0","UnionVariant0":%v}`, string(bytes))), nil + case "UnionVariant1": + bytes, err := json.Marshal(t.UnionVariant1) + if err != nil { + return nil, err + } + return []byte(fmt.Sprintf(`{"SumType": "UnionVariant1","UnionVariant1":%v}`, string(bytes))), nil + case "UnionVariant2": + bytes, err := json.Marshal(t.UnionVariant2) + if err != nil { + return nil, err + } + return []byte(fmt.Sprintf(`{"SumType": "UnionVariant2","UnionVariant2":%v}`, string(bytes))), nil + default: + return nil, fmt.Errorf("unknown sum type %v", t.SumType) + } +} + +type TonTep74BounceOpToHandle struct { + tlb.SumType + UnionVariant0 TonTep74InternalTransferStep `tlbSumType:"#178d4519"` + UnionVariant1 TonTep74BurnNotificationForMinter `tlbSumType:"#7bdd97de"` +} + +type TonTep74JettonWalletDataReply struct { + JettonBalance tlb.VarUInteger16 + OwnerAddress tlb.MsgAddress + MinterAddress tlb.MsgAddress + JettonWalletCode tlb.Any `tlb:"^"` +} + +type TonTolkTestsDedustVolatile struct { +} + +type TonTolkTestsDedustStable struct { +} + +type TonTolkTestsDedustAssetNative struct { +} + +type TonTolkTestsDedustAssetJetton struct { + Workchain int8 + Hash tlb.Bits256 +} + +type TonTolkTestsDedustAssetExtraCurrency struct { + CurrencyId int32 +} + +type TonTolkTestsDedustPoolType struct { + tlb.SumType + UnionVariant0 TonTolkTestsDedustVolatile `tlbSumType:"$0"` + UnionVariant1 TonTolkTestsDedustStable `tlbSumType:"$1"` +} + +type TonTolkTestsDedustAsset struct { + tlb.SumType + UnionVariant0 TonTolkTestsDedustAssetNative `tlbSumType:"$0000"` + UnionVariant1 TonTolkTestsDedustAssetJetton `tlbSumType:"$0001"` + UnionVariant2 TonTolkTestsDedustAssetExtraCurrency `tlbSumType:"$0010"` +} + +func (t *TonTolkTestsDedustAsset) MarshalJSON() ([]byte, error) { + switch t.SumType { + case "UnionVariant0": + bytes, err := json.Marshal(t.UnionVariant0) + if err != nil { + return nil, err + } + return []byte(fmt.Sprintf(`{"SumType": "UnionVariant0","UnionVariant0":%v}`, string(bytes))), nil + case "UnionVariant1": + bytes, err := json.Marshal(t.UnionVariant1) + if err != nil { + return nil, err + } + return []byte(fmt.Sprintf(`{"SumType": "UnionVariant1","UnionVariant1":%v}`, string(bytes))), nil + case "UnionVariant2": + bytes, err := json.Marshal(t.UnionVariant2) + if err != nil { + return nil, err + } + return []byte(fmt.Sprintf(`{"SumType": "UnionVariant2","UnionVariant2":%v}`, string(bytes))), nil + default: + return nil, fmt.Errorf("unknown sum type %v", t.SumType) + } +} + +type TonTolkTestsStormNoKeyInit struct { +} + +type TonTolkTestsStormNeedKeyInit struct { + UserPublicKeys tlb.HashmapE[tlb.Uint256, tlb.Ref[tlb.Any]] +} + +type TonTolkTestsInitializationRequest tlb.Either[TonTolkTestsStormNoKeyInit, TonTolkTestsStormNeedKeyInit] + +type TonTolkTestsInvoiceUrlNone struct { +} + +type TonTolkTestsInvoiceUrlTonsite struct { + Address tlb.Bits256 +} + +type TonTolkTestsInvoiceUrl struct { + tlb.SumType + UnionVariant0 TonTolkTestsInvoiceUrlNone `tlbSumType:"#00"` + UnionVariant1 TonTolkTestsInvoiceUrlTonsite `tlbSumType:"#01"` +} + +type TonTolkTestsAdditionalData struct { + FromAddress tlb.MsgAddress + RefAddress tlb.MsgAddress +} + +type TonTolkTestsMoonNextPayload struct { + Recipient tlb.MsgAddress + Payload tlb.EitherRef[Payload] +} + +type TonTolkTestsMoonSwapParams struct { + MinOut tlb.VarUInteger16 + Deadline uint64 + Excess tlb.MsgAddress + Referral tlb.MsgAddress + NextFulfill *TonTolkTestsMoonNextPayload `tlb:"maybe^"` + NextReject *TonTolkTestsMoonNextPayload `tlb:"maybe^"` +} + +type TonTolkTestsCoffeeSwapStepParams struct { + PoolAddressHash tlb.Uint256 + MinOutAmount tlb.VarUInteger16 + Next *TonTolkTestsCoffeeSwapStepParams `tlb:"maybe^"` +} + +type TonTolkTestsCoffeeNotificationDataSingle struct { + Reciever tlb.MsgAddress + FwdGas tlb.VarUInteger16 + Payload tlb.Any `tlb:"^"` +} + +type TonTolkTestsCoffeeNotificationData struct { + OnSuccess *TonTolkTestsCoffeeNotificationDataSingle `tlb:"maybe^"` + OnFailure *TonTolkTestsCoffeeNotificationDataSingle `tlb:"maybe^"` +} + +type TonTolkTestsCoffeeSwapParams struct { + Deadline uint32 + Recipient tlb.MsgAddress + Referral tlb.MsgAddress + NotificationData *TonTolkTestsCoffeeNotificationData `tlb:"maybe^"` +} + +type TonTolkTestsCoffeeAssetNative struct { +} + +type TonTolkTestsCoffeeAssetJetton struct { + Chain uint8 + Hash tlb.Uint256 +} + +type TonTolkTestsCoffeAssetExtra struct { + Id uint32 +} + +type TonTolkTestsCoffeeAsset struct { + tlb.SumType + UnionVariant0 TonTolkTestsCoffeeAssetNative `tlbSumType:"$00"` + UnionVariant1 TonTolkTestsCoffeeAssetJetton `tlbSumType:"$01"` + UnionVariant2 TonTolkTestsCoffeAssetExtra `tlbSumType:"$10"` +} + +func (t *TonTolkTestsCoffeeAsset) MarshalJSON() ([]byte, error) { + switch t.SumType { + case "UnionVariant0": + bytes, err := json.Marshal(t.UnionVariant0) + if err != nil { + return nil, err + } + return []byte(fmt.Sprintf(`{"SumType": "UnionVariant0","UnionVariant0":%v}`, string(bytes))), nil + case "UnionVariant1": + bytes, err := json.Marshal(t.UnionVariant1) + if err != nil { + return nil, err + } + return []byte(fmt.Sprintf(`{"SumType": "UnionVariant1","UnionVariant1":%v}`, string(bytes))), nil + case "UnionVariant2": + bytes, err := json.Marshal(t.UnionVariant2) + if err != nil { + return nil, err + } + return []byte(fmt.Sprintf(`{"SumType": "UnionVariant2","UnionVariant2":%v}`, string(bytes))), nil + default: + return nil, fmt.Errorf("unknown sum type %v", t.SumType) + } +} + +type TonTolkTestsCoffeeAmmConstProd struct { +} + +type TonTolkTestsCoffeeAmmCurveFiStable struct { +} + +type TonTolkTestsCoffeeAmm struct { + tlb.SumType + UnionVariant0 TonTolkTestsCoffeeAmmConstProd `tlbSumType:"$000"` + UnionVariant1 TonTolkTestsCoffeeAmmCurveFiStable `tlbSumType:"$001"` +} + +type TonTolkTestsCoffeePoolParams struct { + First TonTolkTestsCoffeeAsset + Second TonTolkTestsCoffeeAsset + Amm TonTolkTestsCoffeeAmm + AmmSettings *tlb.Any `tlb:"maybe^"` +} + +type TonTolkTestsCoffeePublicPoolCreationParams struct { + Recipient tlb.MsgAddress + UseRecipientOnFailure bool + NotificationData *tlb.Any `tlb:"maybe^"` +} + +type TonTolkTestsCoffeePrivatePoolCreationParams struct { + IsActive bool + ExtraSettings *tlb.Any `tlb:"maybe^"` +} + +type TonTolkTestsCoffeePoolCreationParams struct { + Public TonTolkTestsCoffeePublicPoolCreationParams + PrivateP TonTolkTestsCoffeePrivatePoolCreationParams +} + +type TonTolkTestsCoffeeDepositLiquidityConditionNone struct { +} + +type TonTolkTestsCoffeeDepositLiquidityConditionLpQuantity struct { + MinLpAmount tlb.VarUInteger16 +} + +type TonTolkTestsCoffeeDepositLiquidityConditionReservedRatio struct { + Denominator tlb.VarUInteger16 + MinNominator tlb.VarUInteger16 + MaxNominator tlb.VarUInteger16 +} + +type TonTolkTestsCoffeeDepositLiquidityConditionComplex struct { + MinLpAmoint tlb.VarUInteger16 + Denominator tlb.VarUInteger16 + MinNominator tlb.VarUInteger16 + MaxNominator tlb.VarUInteger16 +} + +type TonTolkTestsCoffeeDepositLiquidityCondition struct { + tlb.SumType + UnionVariant0 TonTolkTestsCoffeeDepositLiquidityConditionNone `tlbSumType:"$00"` + UnionVariant1 TonTolkTestsCoffeeDepositLiquidityConditionLpQuantity `tlbSumType:"$01"` + UnionVariant2 TonTolkTestsCoffeeDepositLiquidityConditionReservedRatio `tlbSumType:"$10"` + UnionVariant3 TonTolkTestsCoffeeDepositLiquidityConditionComplex `tlbSumType:"$11"` +} + +func (t *TonTolkTestsCoffeeDepositLiquidityCondition) MarshalJSON() ([]byte, error) { + switch t.SumType { + case "UnionVariant0": + bytes, err := json.Marshal(t.UnionVariant0) + if err != nil { + return nil, err + } + return []byte(fmt.Sprintf(`{"SumType": "UnionVariant0","UnionVariant0":%v}`, string(bytes))), nil + case "UnionVariant1": + bytes, err := json.Marshal(t.UnionVariant1) + if err != nil { + return nil, err + } + return []byte(fmt.Sprintf(`{"SumType": "UnionVariant1","UnionVariant1":%v}`, string(bytes))), nil + case "UnionVariant2": + bytes, err := json.Marshal(t.UnionVariant2) + if err != nil { + return nil, err + } + return []byte(fmt.Sprintf(`{"SumType": "UnionVariant2","UnionVariant2":%v}`, string(bytes))), nil + case "UnionVariant3": + bytes, err := json.Marshal(t.UnionVariant3) + if err != nil { + return nil, err + } + return []byte(fmt.Sprintf(`{"SumType": "UnionVariant3","UnionVariant3":%v}`, string(bytes))), nil + default: + return nil, fmt.Errorf("unknown sum type %v", t.SumType) + } +} + +type TonTolkTestsCoffeeDepositLiquidityParamsTrimmed struct { + Recipient tlb.MsgAddress + UseRecipientOnFailure bool + Referral tlb.MsgAddress + Deadline uint32 + Condition TonTolkTestsCoffeeDepositLiquidityCondition + ExtraSettings *tlb.Any `tlb:"maybe^"` + NotificationData *TonTolkTestsCoffeeNotificationData `tlb:"maybe^"` +} + +type TonTolkTestsCoffeeDepositLiquidityParams struct { + Params TonTolkTestsCoffeeDepositLiquidityParamsTrimmed + PoolParmas TonTolkTestsCoffeePoolParams +} + +type TonTolkTestsMoonOrderParams struct { + Rate tlb.Uint256 + Lock tlb.Uint2 + VestingTime uint64 +} + +type TonTolkTestsDedustSwapStepParams struct { + KindOut bool + Limit tlb.VarUInteger16 + Next *TonTolkTestsDedustSwapStep `tlb:"maybe^"` +} + +type TonTolkTestsDedustSwapStep struct { + PoolAddr tlb.MsgAddress + Params TonTolkTestsDedustSwapStepParams +} + +type TonTolkTestsDedustSwapParams struct { + Deadline uint32 + RecipientAddr tlb.MsgAddress + ReferralAddr tlb.MsgAddress + FulfillPayload *tlb.Any `tlb:"maybe^"` + RejectPayload *tlb.Any `tlb:"maybe^"` +} + +type TonStonfiV1GetPoolDataStonfiV1 struct { + Reserve0 tlb.VarUInteger16 + Reserve1 tlb.VarUInteger16 + Token0Address tlb.MsgAddress + Token1Address tlb.MsgAddress + LpFee uint8 + ProtocolFee uint8 + RefFee uint8 + ProtocolFeeAddress tlb.MsgAddress + CollectedToken0ProtocolFee tlb.VarUInteger16 + CollectedToken1ProtocolFee tlb.VarUInteger16 +} + +type TonStonfiV2GetLpAccountAddressResult struct { + LpAccountAddress tlb.MsgAddress +} + +type TonStonfiV2GetPoolDataStonfiV2 struct { + IsLocked bool + RouterAddress tlb.MsgAddress + TotalSupply tlb.VarUInteger16 + Reserve0 tlb.VarUInteger16 + Reserve1 tlb.VarUInteger16 + Token0Address tlb.MsgAddress + Token1Address tlb.MsgAddress + LpFee uint8 + ProtocolFee uint8 + ProtocolFeeAddress tlb.MsgAddress + CollectedToken0ProtocolFee tlb.VarUInteger16 + CollectedToken1ProtocolFee tlb.VarUInteger16 +} + +type TonStonfiV2GetPoolDataStonfiV2StableSwap struct { + IsLocked bool + RouterAddress tlb.MsgAddress + TotalSupply tlb.VarUInteger16 + Reserve0 tlb.VarUInteger16 + Reserve1 tlb.VarUInteger16 + Token0Address tlb.MsgAddress + Token1Address tlb.MsgAddress + LpFee uint8 + ProtocolFee uint8 + ProtocolFeeAddress tlb.MsgAddress + CollectedToken0ProtocolFee tlb.VarUInteger16 + CollectedToken1ProtocolFee tlb.VarUInteger16 + Additional tlb.Uint128 +} + +type TonStonfiV2CrossSwapBody struct { + MinOut tlb.VarUInteger16 + Receiver tlb.MsgAddress + FwdGas tlb.VarUInteger16 + CustomPayload *tlb.Any `tlb:"maybe^"` + RefundFwdGas tlb.VarUInteger16 + RefundPayload *tlb.Any `tlb:"maybe^"` + RefFee uint16 + RefAddress tlb.MsgAddress +} + +type TonStonfiV2GetPoolDataStonfiV2WeightedStableSwap struct { + IsLocked bool + RouterAddress tlb.MsgAddress + TotalSupply tlb.VarUInteger16 + Reserve0 tlb.VarUInteger16 + Reserve1 tlb.VarUInteger16 + Token0Address tlb.MsgAddress + Token1Address tlb.MsgAddress + LpFee uint8 + ProtocolFee uint8 + ProtocolFeeAddress tlb.MsgAddress + CollectedToken0ProtocolFee tlb.VarUInteger16 + CollectedToken1ProtocolFee tlb.VarUInteger16 + Amp tlb.Uint128 + Rate tlb.Uint128 + W0 tlb.Uint128 + RateSetter tlb.MsgAddress +} + +type TonStonfiV2CrossProvideLpBody struct { + MinLpOut tlb.VarUInteger16 + ToAddress tlb.MsgAddress + BothPositive bool + FwdAmount tlb.VarUInteger16 + CustomPayload *tlb.Any `tlb:"maybe^"` +} diff --git a/abi-tolk/utils.go b/abi-tolk/utils.go new file mode 100644 index 00000000..5e0f9b45 --- /dev/null +++ b/abi-tolk/utils.go @@ -0,0 +1,27 @@ +package abitolk + +import ( + "fmt" + "math/big" +) + +func MustBigInt(s string) big.Int { + b := big.Int{} + res, ok := b.SetString(s, 10) + if !ok { + panic(fmt.Sprintf("bigint %v cannot not be parsed", s)) + } + return *res +} + +func BigIntFromUint(i uint64) big.Int { + b := big.Int{} + return *b.SetUint64(i) +} + +func BoolToInt64(b bool) int64 { + if b { + return 1 + } + return 0 +} diff --git a/abi/messages_test.go b/abi/messages_test.go index 70aae7dc..c8c60295 100644 --- a/abi/messages_test.go +++ b/abi/messages_test.go @@ -2,11 +2,12 @@ package abi import ( "fmt" + "reflect" + "testing" + "github.com/tonkeeper/tongo/boc" "github.com/tonkeeper/tongo/tlb" "github.com/tonkeeper/tongo/ton" - "reflect" - "testing" ) func TestEncodeAndDecodeInMsgBody(t *testing.T) { @@ -42,7 +43,7 @@ func TestEncodeAndDecodeInMsgBody(t *testing.T) { } func TestDecodeAndEncodeUnknownInMsgBody(t *testing.T) { - data := "b5ee9c720101010100350000650000022800000000000000005012a05f200800c46663fd6592a0ca9ff0f04ed928fe74019bac1756d06092c14464fb3ce8d373" + data := "b5ee9c7201010101005c0000b3178d45190000000000000000a0165ceda7f1e7eda8000801b26778d9535dc370f56d2e34225d4619deb1e0f4080a7bdde114618639d1574b001643971209f95b121f5600b0fd68e03bdb7b0994f0dfdd4a9550a2a3e56e23f382" boc1, _ := boc.DeserializeBocHex(data) var x InMsgBody diff --git a/boc/bitString.go b/boc/bitString.go index 66cceaff..e554ad37 100644 --- a/boc/bitString.go +++ b/boc/bitString.go @@ -213,10 +213,11 @@ func (s *BitString) ReadBigUint(bitLen int) (*big.Int, error) { } b = []byte{byte(firstByte)} } - b, err = s.ReadBytes(bitLen / 8) + normalizeB, err := s.ReadBytes(bitLen / 8) if err != nil { return nil, err } + b = append(b, normalizeB...) num.SetBytes(b) return num, nil } diff --git a/examples/tolk/abi.json b/examples/tolk/abi.json new file mode 100644 index 00000000..41207cdd --- /dev/null +++ b/examples/tolk/abi.json @@ -0,0 +1,68 @@ +{ + "contractName": "Example", + "declarations": [ + { + "kind": "Struct", + "name": "Transfer", + "prefix": { + "prefixStr": "0x5fcc3d14", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "newOwner", + "ty": { + "kind": "address" + } + }, + { + "name": "responseDestination", + "ty": { + "kind": "address" + } + }, + { + "name": "customPayload", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cell" + } + } + }, + { + "name": "forwardAmount", + "ty": { + "kind": "coins" + } + }, + { + "name": "forwardPayload", + "ty": { + "kind": "remaining" + } + } + ] + } + ], + "incomingMessages": [], + "outgoingMessages": [], + "emittedEvents": [], + "storage": { + "storageTy": { + "kind": "nullLiteral" + } + }, + "getMethods": [], + "thrownErrors": [], + "compilerName": "tolk", + "compilerVersion": "1.2.0", + "codeBoc64": "te6ccgEBAgEAFQABFP8A9KQT9LzyyAsBAAzTMPiR8kA=" +} \ No newline at end of file diff --git a/examples/tolk/main.go b/examples/tolk/main.go new file mode 100644 index 00000000..a3459778 --- /dev/null +++ b/examples/tolk/main.go @@ -0,0 +1,114 @@ +package main + +import ( + "encoding/hex" + "encoding/json" + "fmt" + + "github.com/tonkeeper/tongo/boc" + "github.com/tonkeeper/tongo/tolk" +) +import _ "embed" + +//go:embed abi.json +var abiData []byte + +func main() { + var abi tolk.ABI + err := json.Unmarshal(abiData, &abi) + if err != nil { + panic(err) + } + + ty := tolk.Ty{ + SumType: "StructRef", + StructRef: &tolk.StructRef{ + StructName: "Transfer", + }, + } + b, err := hex.DecodeString("b5ee9c72c10101010056000000a75fcc3d140000000000000000800c0674dd00e3a7231084788441cc873e60eb8681f44901cba3a9107c5c322dc4500034a37c6673343b360e10d4e438483b555805a20e5f056742b6a42ba35311994c802625a008a90c976e") + if err != nil { + panic(err) + } + cell, err := boc.DeserializeBoc(b) + if err != nil { + panic(err) + } + + decoder := tolk.NewDecoder() + decoder.WithABI(abi) + res, err := decoder.UnmarshalTolk(cell[0], ty) + if err != nil { + panic(err) + } + tolkStruct, ok := res.GetStruct() + if !ok { + panic("Struct Transfer not found") + } + prefix, exists := tolkStruct.GetPrefix() + if !exists { + panic("Transfer prefix not found") + } + + queryId, ok := tolkStruct.GetField("queryId") + if !ok { + panic("transfer.queryId not found") + } + queryIdValue, ok := queryId.GetSmallUInt() + if !ok { + panic("cannot get transfer.queryId value") + } + + newOwner, ok := tolkStruct.GetField("newOwner") + if !ok { + panic("transfer.newOwner not found") + } + newOwnerValue, ok := newOwner.GetAddress() + if !ok { + panic("cannot get transfer.newOwner value") + } + + responseDestination, ok := tolkStruct.GetField("responseDestination") + if !ok { + panic("transfer.responseDestination not found") + } + responseDestinationValue, ok := responseDestination.GetAddress() + if !ok { + panic("cannot get transfer.responseDestination value") + } + + customPayload, ok := tolkStruct.GetField("customPayload") + if !ok { + panic("transfer.customPayload not found") + } + customPayloadValue, ok := customPayload.GetOptionalValue() + if !ok { + panic("cannot get transfer.customPayload value") + } + + forwardAmount, ok := tolkStruct.GetField("forwardAmount") + if !ok { + panic("transfer.forwardAmount not found") + } + forwardAmountValue, ok := forwardAmount.GetCoins() + if !ok { + panic("cannot get transfer.forwardAmount value") + } + + forwardPayload, ok := tolkStruct.GetField("forwardPayload") + if !ok { + panic("transfer.forwardPayload not found") + } + forwardPayloadValue, ok := forwardPayload.GetRemaining() + if !ok { + panic("cannot get transfer.forwardPayload value") + } + + fmt.Printf("Transfer prefix: 0x%x\n", prefix.Prefix) + fmt.Printf("Transfer query id: %v\n", queryIdValue) + fmt.Printf("Transfer new owner: %v\n", newOwnerValue.ToRaw()) + fmt.Printf("Transfer response destination: %v\n", responseDestinationValue.ToRaw()) + fmt.Printf("Transfer is custom payload exists: %v\n", customPayloadValue.IsExists) + fmt.Printf("Transfer forward amount: %x\n", forwardAmountValue.String()) + fmt.Printf("Transfer forward value: %x\n", forwardPayloadValue.ReadRemainingBits()) +} diff --git a/go.mod b/go.mod index 727a9b34..72ba29fd 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/tonkeeper/tongo -go 1.19 +go 1.23 require ( github.com/alecthomas/participle/v2 v2.0.0-beta.5 diff --git a/tlb/address.go b/tlb/address.go index 76943d3d..7f6bcab0 100644 --- a/tlb/address.go +++ b/tlb/address.go @@ -2,7 +2,11 @@ package tlb import ( "bytes" + "encoding/hex" "fmt" + "math" + "strconv" + "strings" "github.com/tonkeeper/tongo/boc" ) @@ -62,3 +66,95 @@ func (addr AddressWithWorkchain) MarshalJSON() ([]byte, error) { raw := fmt.Sprintf("%v:%x", addr.Workchain, addr.Address) return []byte(`"` + raw + `"`), nil } + +// InternalAddress is a TL-B type that represents only internal message address: +// addr_std$10 anycast:(Maybe Anycast) workchain_id:int8 address:bits256 = MsgAddressInt; +// Anycast is deprecated since TVM 10, so internal message always has `100` prefix +type InternalAddress struct { + Workchain int8 + Address Bits256 +} + +func (addr InternalAddress) Equal(other any) bool { + otherAddr, ok := other.(InternalAddress) + if !ok { + return false + } + return addr.Workchain == otherAddr.Workchain && addr.Address == otherAddr.Address +} + +// Compare returns an integer comparing two addresses lexicographically. +// The result will be 0 if both are equal, -1 if addr < other, and +1 if addr > other. +func (addr InternalAddress) Compare(other any) (int, bool) { + otherAddr, ok := other.(InternalAddress) + if !ok { + return 0, false + } + workchain := uint32(addr.Workchain) + otherWorkchain := uint32(otherAddr.Workchain) + if workchain < otherWorkchain { + return -1, true + } + if workchain > otherWorkchain { + return 1, true + } + return bytes.Compare(addr.Address[:], otherAddr.Address[:]), true +} + +func (addr InternalAddress) FixedSize() int { + return 267 +} + +func (addr *InternalAddress) UnmarshalTLB(c *boc.Cell, decoder *Decoder) error { + err := c.Skip(3) // $100 prefix + if err != nil { + return err + } + workchain, err := c.ReadInt(8) + if err != nil { + return err + } + address, err := c.ReadBytes(32) + if err != nil { + return err + } + addr.Workchain = int8(workchain) + copy(addr.Address[:], address) + return nil +} + +func (addr InternalAddress) MarshalTLB(c *boc.Cell, encoder *Encoder) error { + if err := c.WriteUint(2, 3); err != nil { + return err + } + if err := c.WriteInt(int64(addr.Workchain), 8); err != nil { + return err + } + return c.WriteBytes(addr.Address[:]) +} + +func (addr InternalAddress) MarshalJSON() ([]byte, error) { + var anycastExtra string + x := fmt.Sprintf("%d:%s", addr.Workchain, addr.Address.Hex()) + return []byte(fmt.Sprintf(`"%s%s"`, x, anycastExtra)), nil +} + +func (addr *InternalAddress) UnmarshalJSON(b []byte) error { + parts := strings.Split(string(b), ":") + if len(parts) != 2 { + return fmt.Errorf("invalid address: %s", string(b)) + } + num, err := strconv.ParseInt(parts[0], 10, 32) + isWorkchainInt8 := err == nil && num >= int64(math.MinInt8) && num <= int64(math.MaxInt8) + if !isWorkchainInt8 { + return fmt.Errorf("invalid address: %s", string(b)) + } + var dst [32]byte + _, err = hex.Decode(dst[:], []byte(parts[1])) + if err != nil { + return err + } + addr.Workchain = int8(num) + addr.Address = dst + return nil +} diff --git a/tlb/decoder.go b/tlb/decoder.go index 09fecf00..5d460009 100644 --- a/tlb/decoder.go +++ b/tlb/decoder.go @@ -9,12 +9,15 @@ import ( type resolveLib func(hash Bits256) (*boc.Cell, error) +type ContractInterface uint32 + // Decoder unmarshals a cell into a golang type. type Decoder struct { - hasher *boc.Hasher - withDebug bool - debugPath []string - resolveLib resolveLib + hasher *boc.Hasher + withDebug bool + debugPath []string + resolveLib resolveLib + contractInterfaces []ContractInterface } func (d *Decoder) WithDebug() *Decoder { @@ -28,6 +31,11 @@ func (d *Decoder) WithLibraryResolver(resolveLib resolveLib) *Decoder { return d } +func (d *Decoder) WithContractInterfaces(contractInterfaces []ContractInterface) *Decoder { + d.contractInterfaces = contractInterfaces + return d +} + // NewDecoder returns a new Decoder. func NewDecoder() *Decoder { return &Decoder{ @@ -40,6 +48,10 @@ func (dec *Decoder) Unmarshal(c *boc.Cell, o any) error { return decode(c, "", reflect.ValueOf(o), dec) } +func (dec *Decoder) GetContractInterfaces() []ContractInterface { + return dec.contractInterfaces +} + // UnmarshalerTLB contains method UnmarshalTLB that must be implemented by a struct // if it provides specific unmarshalling code. type UnmarshalerTLB interface { diff --git a/tlb/integers.go b/tlb/integers.go index d09ddaea..a3a172c7 100644 --- a/tlb/integers.go +++ b/tlb/integers.go @@ -1,5 +1,6 @@ package tlb -// Code autogenerated. DO NOT EDIT. + +// Code autogenerated. DO NOT EDIT. import ( "bytes" @@ -7712,6 +7713,26 @@ func (u Int128) FixedSize() int { return 128 } +func (u Int128) Equal(other any) bool { + otherInt, ok := other.(Int128) + if !ok { + return false + } + bigU := big.Int(u) + otherBigInt := big.Int(otherInt) + return bigU.Cmp(&otherBigInt) == 0 +} + +func (u Int128) Compare(other any) (int, bool) { + otherInt, ok := other.(Int128) + if !ok { + return 0, false + } + bigU := big.Int(u) + otherBigInt := big.Int(otherInt) + return bigU.Cmp(&otherBigInt), true +} + func (u Int128) MarshalJSON() ([]byte, error) { i := big.Int(u) return []byte(fmt.Sprintf("\"%s\"", i.String())), nil @@ -7747,6 +7768,26 @@ func (u Int256) FixedSize() int { return 256 } +func (u Int256) Equal(other any) bool { + otherInt, ok := other.(Int256) + if !ok { + return false + } + bigU := big.Int(u) + otherBigInt := big.Int(otherInt) + return bigU.Cmp(&otherBigInt) == 0 +} + +func (u Int256) Compare(other any) (int, bool) { + otherInt, ok := other.(Int256) + if !ok { + return 0, false + } + bigU := big.Int(u) + otherBigInt := big.Int(otherInt) + return bigU.Cmp(&otherBigInt), true +} + func (u Int256) MarshalJSON() ([]byte, error) { i := big.Int(u) return []byte(fmt.Sprintf("\"%s\"", i.String())), nil @@ -7782,6 +7823,26 @@ func (u Int257) FixedSize() int { return 257 } +func (u Int257) Equal(other any) bool { + otherInt, ok := other.(Int257) + if !ok { + return false + } + bigU := big.Int(u) + otherBigInt := big.Int(otherInt) + return bigU.Cmp(&otherBigInt) == 0 +} + +func (u Int257) Compare(other any) (int, bool) { + otherInt, ok := other.(Int257) + if !ok { + return 0, false + } + bigU := big.Int(u) + otherBigInt := big.Int(otherInt) + return bigU.Cmp(&otherBigInt), true +} + func (u Int257) MarshalJSON() ([]byte, error) { i := big.Int(u) return []byte(fmt.Sprintf("\"%s\"", i.String())), nil @@ -7817,6 +7878,26 @@ func (u Uint128) FixedSize() int { return 128 } +func (u Uint128) Equal(other any) bool { + otherUint, ok := other.(Uint128) + if !ok { + return false + } + bigU := big.Int(u) + otherBigUint := big.Int(otherUint) + return bigU.Cmp(&otherBigUint) == 0 +} + +func (u Uint128) Compare(other any) (int, bool) { + otherUint, ok := other.(Uint128) + if !ok { + return 0, false + } + bigU := big.Int(u) + otherBigUint := big.Int(otherUint) + return bigU.Cmp(&otherBigUint), true +} + func (u Uint128) MarshalJSON() ([]byte, error) { i := big.Int(u) return []byte(fmt.Sprintf("\"%s\"", i.String())), nil @@ -7852,6 +7933,26 @@ func (u Uint160) FixedSize() int { return 160 } +func (u Uint160) Equal(other any) bool { + otherUint, ok := other.(Uint160) + if !ok { + return false + } + bigU := big.Int(u) + otherBigUint := big.Int(otherUint) + return bigU.Cmp(&otherBigUint) == 0 +} + +func (u Uint160) Compare(other any) (int, bool) { + otherUint, ok := other.(Uint160) + if !ok { + return 0, false + } + bigU := big.Int(u) + otherBigUint := big.Int(otherUint) + return bigU.Cmp(&otherBigUint), true +} + func (u Uint160) MarshalJSON() ([]byte, error) { i := big.Int(u) return []byte(fmt.Sprintf("\"%s\"", i.String())), nil @@ -7887,6 +7988,26 @@ func (u Uint220) FixedSize() int { return 220 } +func (u Uint220) Equal(other any) bool { + otherUint, ok := other.(Uint220) + if !ok { + return false + } + bigU := big.Int(u) + otherBigUint := big.Int(otherUint) + return bigU.Cmp(&otherBigUint) == 0 +} + +func (u Uint220) Compare(other any) (int, bool) { + otherUint, ok := other.(Uint220) + if !ok { + return 0, false + } + bigU := big.Int(u) + otherBigUint := big.Int(otherUint) + return bigU.Cmp(&otherBigUint), true +} + func (u Uint220) MarshalJSON() ([]byte, error) { i := big.Int(u) return []byte(fmt.Sprintf("\"%s\"", i.String())), nil @@ -7922,6 +8043,26 @@ func (u Uint256) FixedSize() int { return 256 } +func (u Uint256) Equal(other any) bool { + otherUint, ok := other.(Uint256) + if !ok { + return false + } + bigU := big.Int(u) + otherBigUint := big.Int(otherUint) + return bigU.Cmp(&otherBigUint) == 0 +} + +func (u Uint256) Compare(other any) (int, bool) { + otherUint, ok := other.(Uint256) + if !ok { + return 0, false + } + bigU := big.Int(u) + otherBigUint := big.Int(otherUint) + return bigU.Cmp(&otherBigUint), true +} + func (u Uint256) MarshalJSON() ([]byte, error) { i := big.Int(u) return []byte(fmt.Sprintf("\"%s\"", i.String())), nil @@ -8240,4 +8381,3 @@ func (u Bits512) Compare(other any) (int, bool) { } return bytes.Compare(u[:], otherBits[:]), true } - \ No newline at end of file diff --git a/tlb/parser/builtin_generator.go b/tlb/parser/builtin_generator.go index 989233cc..43cf75b7 100644 --- a/tlb/parser/builtin_generator.go +++ b/tlb/parser/builtin_generator.go @@ -234,6 +234,26 @@ func (u Int{{.NameIndex}}) FixedSize() int { return {{.NameIndex}} } +func (u Int{{.NameIndex}}) Equal(other any) bool { + otherInt, ok := other.(Int{{.NameIndex}}) + if !ok { + return false + } + bigU := big.Int(u) + otherBigInt := big.Int(otherInt) + return bigU.Cmp(&otherBigInt) == 0 +} + +func (u Int{{.NameIndex}}) Compare(other any) (int, bool) { + otherInt, ok := other.(Int{{.NameIndex}}) + if !ok { + return 0, false + } + bigU := big.Int(u) + otherBigInt := big.Int(otherInt) + return bigU.Cmp(&otherBigInt), true +} + func (u Int{{.NameIndex}}) MarshalJSON() ([]byte, error) { i := big.Int(u) return []byte(fmt.Sprintf("\"%s\"", i.String())), nil @@ -293,6 +313,26 @@ func (u Uint{{.NameIndex}}) FixedSize() int { return {{.NameIndex}} } +func (u Uint{{.NameIndex}}) Equal(other any) bool { + otherUint, ok := other.(Uint{{.NameIndex}}) + if !ok { + return false + } + bigU := big.Int(u) + otherBigUint := big.Int(otherUint) + return bigU.Cmp(&otherBigUint) == 0 +} + +func (u Uint{{.NameIndex}}) Compare(other any) (int, bool) { + otherUint, ok := other.(Uint{{.NameIndex}}) + if !ok { + return 0, false + } + bigU := big.Int(u) + otherBigUint := big.Int(otherUint) + return bigU.Cmp(&otherBigUint), true +} + func (u Uint{{.NameIndex}}) MarshalJSON() ([]byte, error) { i := big.Int(u) return []byte(fmt.Sprintf("\"%s\"", i.String())), nil diff --git a/tlb/primitives.go b/tlb/primitives.go index 7a5c5db6..0cdd51cd 100644 --- a/tlb/primitives.go +++ b/tlb/primitives.go @@ -15,6 +15,10 @@ type SumType string type Magic uint32 +type Void struct{} + +type NullLiteral = Void + type Maybe[T any] struct { Exists bool Value T @@ -97,6 +101,25 @@ func (m Magic) EncodeTag(c *boc.Cell, tag string) error { return encodeSumTag(c, tag) } +func (v Void) MarshalTLB(c *boc.Cell, encoder *Encoder) error { + return nil +} + +func (v *Void) UnmarshalTLB(c *boc.Cell, decoder *Decoder) error { + return nil +} + +func (v Void) MarshalJSON() ([]byte, error) { + return []byte("null"), nil +} + +func (v *Void) UnmarshalJSON(b []byte) error { + if string(b) == "null" { + return nil + } + return fmt.Errorf("not a void value %v", string(b)) +} + func (m Maybe[_]) MarshalTLB(c *boc.Cell, encoder *Encoder) error { err := c.WriteBit(m.Exists) if err != nil { diff --git a/tlb/stack.go b/tlb/stack.go index 86987952..14c644f5 100644 --- a/tlb/stack.go +++ b/tlb/stack.go @@ -621,6 +621,14 @@ func (s VmStack) Unmarshal(dest any) error { return fmt.Errorf("not enough values in stack") } for i := 0; i < val.Elem().Type().NumField(); i++ { + tag := val.Elem().Type().Field(i).Tag.Get("vmStackHint") + if tag == "tensor" { + err := s.Unmarshal(val.Elem().Field(i).Addr().Interface()) + if err != nil { + return err + } + continue + } fieldType := val.Elem().Field(i).Type() if s[i].SumType == "VmStkNull" { kind := fieldType.Kind() diff --git a/tolk/abi_types.go b/tolk/abi_types.go new file mode 100644 index 00000000..5788fb8c --- /dev/null +++ b/tolk/abi_types.go @@ -0,0 +1,1182 @@ +package tolk + +import ( + "encoding/hex" + "encoding/json" + "fmt" + "math/big" + + "github.com/tonkeeper/tongo/boc" + "github.com/tonkeeper/tongo/ton" + "github.com/tonkeeper/tongo/utils" +) + +type Kind struct { + Kind string `json:"kind"` +} + +type ABI struct { + Namespace string `json:"namespace"` + ContractName string `json:"contractName"` + InheritsContract string `json:"inheritsContract,omitempty"` + Author string `json:"author,omitempty"` + Version string `json:"version,omitempty"` + Description string `json:"description,omitempty"` + Declarations []Declaration `json:"declarations"` + IncomingMessages []IncomingMessage `json:"incomingMessages"` + IncomingExternal *IncomingExternal `json:"incomingExternal,omitempty"` + OutgoingMessages []OutgoingMessage `json:"outgoingMessages"` + EmittedMessages []OutgoingMessage `json:"emittedEvents"` + GetMethods []GetMethod `json:"getMethods"` + ThrownErrors []ThrownError `json:"thrownErrors"` + CompilerName string `json:"compilerName"` + CompilerVersion string `json:"compilerVersion"` + CodeBoc64 string `json:"codeBoc64"` + CodeHashes []string `json:"codeHashes,omitempty"` +} + +func (a *ABI) GetGolangNamespace() string { + return utils.ToCamelCase(a.Namespace) +} + +func (a *ABI) GetGolangContractName() string { + return a.GetGolangNamespace() + utils.ToCamelCase(a.ContractName) +} + +type Declaration struct { + SumType string `json:"kind"` + PayloadType *string `json:"payloadType,omitempty"` // todo: think abt naming + StructDeclaration StructDeclaration + AliasDeclaration AliasDeclaration + EnumDeclaration EnumDeclaration +} + +func (d *Declaration) UnmarshalJSON(b []byte) error { + var r struct { + Kind string `json:"kind"` + PayloadType *string `json:"payloadType,omitempty"` + } + if err := json.Unmarshal(b, &r); err != nil { + return err + } + + d.SumType = r.Kind + d.PayloadType = r.PayloadType + switch d.SumType { + case "Struct": + if err := json.Unmarshal(b, &d.StructDeclaration); err != nil { + return err + } + case "Alias": + if err := json.Unmarshal(b, &d.AliasDeclaration); err != nil { + return err + } + case "Enum": + if err := json.Unmarshal(b, &d.EnumDeclaration); err != nil { + return err + } + default: + return fmt.Errorf("unknown declaration type %q", d.SumType) + } + + return nil +} + +func (d Declaration) MarshalJSON() ([]byte, error) { + var kind Kind + kind.Kind = d.SumType + + var payload []byte + prefix, err := json.Marshal(kind) + if err != nil { + return nil, err + } + + switch d.SumType { + case "Struct": + payload, err = json.Marshal(d.StructDeclaration) + if err != nil { + return nil, err + } + return concatPrefixAndPayload(prefix, payload), nil + case "Alias": + payload, err = json.Marshal(d.AliasDeclaration) + if err != nil { + return nil, err + } + return concatPrefixAndPayload(prefix, payload), nil + case "Enum": + payload, err = json.Marshal(d.EnumDeclaration) + if err != nil { + return nil, err + } + return concatPrefixAndPayload(prefix, payload), nil + default: + return nil, fmt.Errorf("unknown declaration type %q", d.SumType) + } +} + +type StructDeclaration struct { + Name string `json:"name"` + TypeParams []string `json:"typeParams,omitempty"` + Prefix *Prefix `json:"prefix,omitempty"` + Fields []Field `json:"fields"` +} + +type Prefix struct { + PrefixStr string `json:"prefixStr"` + PrefixLen int `json:"prefixLen"` +} + +type Field struct { + Name string `json:"name"` + IsPayload *bool `json:"isPayload,omitempty"` + Ty Ty `json:"ty"` + DefaultValue *DefaultValue `json:"defaultValue,omitempty"` + Description string `json:"description,omitempty"` +} + +type DefaultValue struct { + SumType string `json:"kind"` + IntDefaultValue struct { + V string `json:"v"` + } + BoolDefaultValue struct { + V bool `json:"v"` + } + SliceDefaultValue struct { + Hex string `json:"hex"` + } + AddressDefaultValue struct { + Address string `json:"addr"` + } + TensorDefaultValue struct { + Items []DefaultValue `json:"items"` + } + NullDefaultValue struct{} +} + +func (d *DefaultValue) UnmarshalJSON(b []byte) error { + var kind Kind + + if err := json.Unmarshal(b, &kind); err != nil { + return err + } + + switch kind.Kind { + case "int": + d.SumType = "IntDefaultValue" + if err := json.Unmarshal(b, &d.IntDefaultValue); err != nil { + return err + } + case "bool": + d.SumType = "BoolDefaultValue" + if err := json.Unmarshal(b, &d.BoolDefaultValue); err != nil { + return err + } + case "slice": + d.SumType = "SliceDefaultValue" + if err := json.Unmarshal(b, &d.SliceDefaultValue); err != nil { + return err + } + case "address": + d.SumType = "AddressDefaultValue" + if err := json.Unmarshal(b, &d.AddressDefaultValue); err != nil { + return err + } + case "tensor": + d.SumType = "TensorDefaultValue" + if err := json.Unmarshal(b, &d.TensorDefaultValue); err != nil { + return err + } + case "null": + d.SumType = "NullDefaultValue" + default: + return fmt.Errorf("unknown default value type %q", d.SumType) + } + + return nil +} + +func (d *DefaultValue) MarshalJSON() ([]byte, error) { + var kind Kind + var payload []byte + var err error + + switch d.SumType { + case "IntDefaultValue": + kind.Kind = "int" + payload, err = json.Marshal(d.IntDefaultValue) + if err != nil { + return nil, err + } + case "BoolDefaultValue": + kind.Kind = "bool" + payload, err = json.Marshal(d.BoolDefaultValue) + if err != nil { + return nil, err + } + case "SliceDefaultValue": + kind.Kind = "slice" + payload, err = json.Marshal(d.SliceDefaultValue) + if err != nil { + return nil, err + } + case "AddressDefaultValue": + kind.Kind = "address" + payload, err = json.Marshal(d.AddressDefaultValue) + if err != nil { + return nil, err + } + case "TensorDefaultValue": + kind.Kind = "tensor" + payload, err = json.Marshal(d.TensorDefaultValue) + if err != nil { + return nil, err + } + case "NullDefaultValue": + kind.Kind = "null" + default: + return nil, fmt.Errorf("unknown default value type %q", d.SumType) + } + + prefix, err := json.Marshal(kind) + if err != nil { + return nil, err + } + return concatPrefixAndPayload(prefix, payload), nil +} + +func (d *DefaultValue) unmarshalDefaultValue(v *Value, vType Ty) (bool, error) { + switch d.SumType { + case "IntDefaultValue": + val, err := binDecHexToUint(d.IntDefaultValue.V) + if err != nil { + return false, err + } + err = v.SetValue(BigInt(*val), vType) + if err != nil { + return false, err + } + case "BoolDefaultValue": + err := v.SetValue(BoolValue(d.BoolDefaultValue.V), vType) + if err != nil { + return false, err + } + case "SliceDefaultValue": + val, err := hex.DecodeString(d.SliceDefaultValue.Hex) + if err != nil { + return false, err + } + bs := boc.NewBitString(hex.DecodedLen(len(val))) + err = bs.WriteBytes(val) + if err != nil { + return false, err + } + err = v.SetValue(*boc.NewCellWithBits(bs), vType) + if err != nil { + return false, err + } + case "AddressDefaultValue": + accountID, err := ton.ParseAccountID(d.AddressDefaultValue.Address) + if err != nil { + return false, err + } + err = v.SetValue(InternalAddress{ + Workchain: int8(accountID.Workchain), + Address: accountID.Address, + }, vType) + if err != nil { + return false, err + } + case "TensorDefaultValue": + if vType.SumType != "Tensor" { + return false, fmt.Errorf("tensor default value type must be tensor, got %q", d.SumType) + } + tensor := make([]Value, len(d.TensorDefaultValue.Items)) + for i, item := range d.TensorDefaultValue.Items { + val := Value{} + _, err := item.unmarshalDefaultValue(&val, vType.Tensor.Items[i]) + if err != nil { + return false, err + } + tensor[i] = val + } + err := v.SetValue(tensor, vType) + if err != nil { + return false, err + } + case "NullDefaultValue": + return false, nil + default: + return false, fmt.Errorf("unknown default value type %q", d.SumType) + } + + return true, nil +} + +type AliasDeclaration struct { + Name string `json:"name"` + TargetTy Ty `json:"targetTy"` + TypeParams []string `json:"typeParams,omitempty"` + CustomPackToBuilder bool `json:"customPackToBuilder,omitempty"` + CustomUnpackFromSlice bool `json:"customUnpackFromSlice,omitempty"` +} + +type EnumDeclaration struct { + Name string `json:"name"` + EncodedAs Ty `json:"encodedAs"` + Members []EnumMember `json:"members"` +} + +type EnumMember struct { + Name string `json:"name"` + Value string `json:"value"` +} + +type Ty struct { + SumType string `json:"kind"` + Int *Int + IntN *IntN + UintN *UintN + VarIntN *VarIntN + VarUintN *VarUintN + BitsN *BitsN + Coins *Coins + Bool *Bool + Cell *Cell + Slice *Slice + Builder *Builder + Callable *Callable + Remaining *Remaining + Address *Address + AddressOpt *AddressOpt + AddressExt *AddressExt + AddressAny *AddressAny + Nullable *Nullable + CellOf *CellOf + Tensor *Tensor + TupleWith *TupleWith + Map *Map + EnumRef *EnumRef + AliasRef *AliasRef + StructRef *StructRef + Generic *Generic + Union *Union + TupleAny *TupleAny + NullLiteral *NullLiteral + Void *Void +} + +func (t *Ty) UnmarshalJSON(b []byte) error { + var kind Kind + if err := json.Unmarshal(b, &kind); err != nil { + return err + } + switch kind.Kind { + case "intN": + t.SumType = "IntN" + if err := json.Unmarshal(b, &t.IntN); err != nil { + return err + } + case "uintN": + t.SumType = "UintN" + if err := json.Unmarshal(b, &t.UintN); err != nil { + return err + } + case "varintN": + t.SumType = "VarIntN" + if err := json.Unmarshal(b, &t.VarIntN); err != nil { + return err + } + case "varuintN": + t.SumType = "VarUintN" + if err := json.Unmarshal(b, &t.VarUintN); err != nil { + return err + } + case "bitsN": + t.SumType = "BitsN" + if err := json.Unmarshal(b, &t.BitsN); err != nil { + return err + } + case "nullable": + t.SumType = "Nullable" + if err := json.Unmarshal(b, &t.Nullable); err != nil { + return err + } + case "cellOf": + t.SumType = "CellOf" + if err := json.Unmarshal(b, &t.CellOf); err != nil { + return err + } + case "tensor": + t.SumType = "Tensor" + if err := json.Unmarshal(b, &t.Tensor); err != nil { + return err + } + case "tupleWith": + t.SumType = "TupleWith" + if err := json.Unmarshal(b, &t.TupleWith); err != nil { + return err + } + case "mapKV": + t.SumType = "Map" + if err := json.Unmarshal(b, &t.Map); err != nil { + return err + } + case "EnumRef": + t.SumType = "EnumRef" + if err := json.Unmarshal(b, &t.EnumRef); err != nil { + return err + } + case "StructRef": + t.SumType = "StructRef" + if err := json.Unmarshal(b, &t.StructRef); err != nil { + return err + } + case "AliasRef": + t.SumType = "AliasRef" + if err := json.Unmarshal(b, &t.AliasRef); err != nil { + return err + } + case "genericT": + t.SumType = "Generic" + if err := json.Unmarshal(b, &t.Generic); err != nil { + return err + } + case "union": + t.SumType = "Union" + if err := json.Unmarshal(b, &t.Union); err != nil { + return err + } + case "int": + t.SumType = "Int" + t.IntN = &IntN{} + case "coins": + t.SumType = "Coins" + t.Coins = &Coins{} + case "bool": + t.SumType = "Bool" + t.Bool = &Bool{} + case "cell": + t.SumType = "Cell" + t.Cell = &Cell{} + case "slice": + t.SumType = "Slice" + t.Slice = &Slice{} + case "builder": + t.SumType = "Builder" + t.Builder = &Builder{} + case "remaining": + t.SumType = "Remaining" + t.Remaining = &Remaining{} + case "address": + t.SumType = "Address" + t.Address = &Address{} + case "addressOpt": + t.SumType = "AddressOpt" + t.AddressOpt = &AddressOpt{} + case "addressExt": + t.SumType = "AddressExt" + t.AddressExt = &AddressExt{} + case "addressAny": + t.SumType = "AddressAny" + t.AddressAny = &AddressAny{} + case "tupleAny": + t.SumType = "TupleAny" + t.TupleAny = &TupleAny{} + case "nullLiteral": + t.SumType = "NullLiteral" + t.NullLiteral = &NullLiteral{} + case "callable": + t.SumType = "Callable" + t.Callable = &Callable{} + case "void": + t.SumType = "Void" + t.Void = &Void{} + default: + return fmt.Errorf("unknown ty type %q", kind.Kind) + } + + return nil +} + +func (t *Ty) MarshalJSON() ([]byte, error) { + var kind Kind + var prefix []byte + var payload []byte + var err error + + switch t.SumType { + case "IntN": + kind.Kind = "intN" + payload, err = json.Marshal(t.IntN) + if err != nil { + return nil, err + } + case "UintN": + kind.Kind = "uintN" + payload, err = json.Marshal(t.UintN) + if err != nil { + return nil, err + } + case "VarIntN": + kind.Kind = "varintN" + payload, err = json.Marshal(t.VarIntN) + if err != nil { + return nil, err + } + case "VarUintN": + kind.Kind = "varuintN" + payload, err = json.Marshal(t.VarUintN) + if err != nil { + return nil, err + } + case "BitsN": + kind.Kind = "bitsN" + payload, err = json.Marshal(t.BitsN) + if err != nil { + return nil, err + } + case "Nullable": + kind.Kind = "nullable" + payload, err = json.Marshal(t.Nullable) + if err != nil { + return nil, err + } + case "CellOf": + kind.Kind = "cellOf" + payload, err = json.Marshal(t.CellOf) + if err != nil { + return nil, err + } + case "Tensor": + kind.Kind = "tensor" + payload, err = json.Marshal(t.Tensor) + if err != nil { + return nil, err + } + case "TupleWith": + kind.Kind = "tupleWith" + payload, err = json.Marshal(t.TupleWith) + if err != nil { + return nil, err + } + case "Map": + kind.Kind = "mapKV" + payload, err = json.Marshal(t.Map) + if err != nil { + return nil, err + } + case "EnumRef": + kind.Kind = "EnumRef" + payload, err = json.Marshal(t.EnumRef) + if err != nil { + return nil, err + } + case "StructRef": + kind.Kind = "StructRef" + payload, err = json.Marshal(t.StructRef) + if err != nil { + return nil, err + } + case "AliasRef": + kind.Kind = "AliasRef" + payload, err = json.Marshal(t.AliasRef) + if err != nil { + return nil, err + } + case "Generic": + kind.Kind = "genericT" + payload, err = json.Marshal(t.Generic) + if err != nil { + return nil, err + } + case "Union": + kind.Kind = "union" + payload, err = json.Marshal(t.Union) + if err != nil { + return nil, err + } + case "Int": + kind.Kind = "int" + case "Coins": + kind.Kind = "coins" + case "Bool": + kind.Kind = "bool" + case "Cell": + kind.Kind = "cell" + case "Slice": + kind.Kind = "slice" + case "Builder": + kind.Kind = "builder" + case "Remaining": + kind.Kind = "remaining" + case "Address": + kind.Kind = "address" + case "AddressOpt": + kind.Kind = "addressOpt" + case "AddressExt": + kind.Kind = "addressExt" + case "AddressAny": + kind.Kind = "addressAny" + case "TupleAny": + kind.Kind = "tupleAny" + case "NullLiteral": + kind.Kind = "nullLiteral" + case "Callable": + kind.Kind = "callable" + case "Void": + kind.Kind = "void" + default: + return nil, fmt.Errorf("unknown ty type %q", t.SumType) + } + + prefix, err = json.Marshal(kind) + if err != nil { + return nil, err + } + return concatPrefixAndPayload(prefix, payload), nil +} + +func (t *Ty) UnmarshalTolk2(cell *boc.Cell, v *Value, decoder *Decoder) error { + switch t.SumType { + case "Int": + err := t.Int.UnmarshalTolk(cell, v, decoder) + if err != nil { + return fmt.Errorf("failed to unmarshal unmarshal Int: %w", err) + } + return nil + case "NullLiteral": + err := t.NullLiteral.UnmarshalTolk(cell, v, decoder) + if err != nil { + return fmt.Errorf("failed to unmarshal NullLiteral Int: %w", err) + } + return nil + case "Void": + err := t.Void.UnmarshalTolk(cell, v, decoder) + if err != nil { + return fmt.Errorf("failed to unmarshal Void: %w", err) + } + return nil + case "IntN": + err := t.IntN.UnmarshalTolk(cell, v, decoder) + if err != nil { + return fmt.Errorf("failed to unmarshal IntN: %w", err) + } + return nil + case "UintN": + err := t.UintN.UnmarshalTolk(cell, v, decoder) + if err != nil { + return fmt.Errorf("failed to unmarshal UintN: %w", err) + } + return nil + case "VarIntN": + err := t.VarIntN.UnmarshalTolk(cell, v, decoder) + if err != nil { + return fmt.Errorf("failed to unmarshal VarIntN: %w", err) + } + return nil + case "VarUintN": + err := t.VarUintN.UnmarshalTolk(cell, v, decoder) + if err != nil { + return fmt.Errorf("failed to unmarshal VarUintN: %w", err) + } + return nil + case "BitsN": + err := t.BitsN.UnmarshalTolk(cell, v, decoder) + if err != nil { + return fmt.Errorf("failed to unmarshal BitsN: %w", err) + } + return nil + case "Coins": + err := t.Coins.UnmarshalTolk(cell, v, decoder) + if err != nil { + return fmt.Errorf("failed to unmarshal Coins: %w", err) + } + return nil + case "Bool": + err := t.Bool.UnmarshalTolk(cell, v, decoder) + if err != nil { + return fmt.Errorf("failed to unmarshal Bool: %w", err) + } + return nil + case "Cell": + err := t.Cell.UnmarshalTolk(cell, v, decoder) + if err != nil { + return fmt.Errorf("failed to unmarshal Cell: %w", err) + } + return nil + case "Slice": + err := t.Slice.UnmarshalTolk(cell, v, decoder) + if err != nil { + return fmt.Errorf("failed to unmarshal Slice: %w", err) + } + return nil + case "Builder": + err := t.Builder.UnmarshalTolk(cell, v, decoder) + if err != nil { + return fmt.Errorf("failed to unmarshal Builder: %w", err) + } + return nil + case "Callable": + err := t.Callable.UnmarshalTolk(cell, v, decoder) + if err != nil { + return fmt.Errorf("failed to unmarshal Callable: %w", err) + } + return nil + case "Remaining": + err := t.Remaining.UnmarshalTolk(cell, v, decoder) + if err != nil { + return fmt.Errorf("failed to unmarshal Remaining: %w", err) + } + return nil + case "Address": + err := t.Address.UnmarshalTolk(cell, v, decoder) + if err != nil { + return fmt.Errorf("failed to unmarshal Address: %w", err) + } + return nil + case "AddressOpt": + err := t.AddressOpt.UnmarshalTolk(cell, v, decoder) + if err != nil { + return fmt.Errorf("failed to unmarshal AddressOpt: %w", err) + } + return nil + case "AddressExt": + err := t.AddressExt.UnmarshalTolk(cell, v, decoder) + if err != nil { + return fmt.Errorf("failed to unmarshal AddressExt: %w", err) + } + return nil + case "AddressAny": + err := t.AddressAny.UnmarshalTolk(cell, v, decoder) + if err != nil { + return fmt.Errorf("failed to unmarshal AddressAny: %w", err) + } + return nil + case "Nullable": + err := t.Nullable.UnmarshalTolk(cell, v, decoder) + if err != nil { + return fmt.Errorf("failed to unmarshal Nullable: %w", err) + } + return nil + case "CellOf": + err := t.CellOf.UnmarshalTolk(cell, v, decoder) + if err != nil { + return fmt.Errorf("failed to unmarshal CellOf: %w", err) + } + return nil + case "Tensor": + err := t.Tensor.UnmarshalTolk(cell, v, decoder) + if err != nil { + return fmt.Errorf("failed to unmarshal Tensor: %w", err) + } + return nil + case "TupleWith": + err := t.TupleWith.UnmarshalTolk(cell, v, decoder) + if err != nil { + return fmt.Errorf("failed to unmarshal TupleWith: %w", err) + } + return nil + case "TupleAny": + err := t.TupleAny.UnmarshalTolk(cell, v, decoder) + if err != nil { + return fmt.Errorf("failed to unmarshal TupleAny: %w", err) + } + return nil + case "Map": + err := t.Map.UnmarshalTolk(cell, v, decoder) + if err != nil { + return fmt.Errorf("failed to unmarshal Map: %w", err) + } + return nil + case "EnumRef": + err := t.EnumRef.UnmarshalTolk(cell, v, decoder) + if err != nil { + return fmt.Errorf("failed to unmarshal EnumRef: %w", err) + } + return nil + case "StructRef": + err := t.StructRef.UnmarshalTolk(cell, v, decoder) + if err != nil { + return fmt.Errorf("failed to unmarshal StructRef: %w", err) + } + return nil + case "AliasRef": + err := t.AliasRef.UnmarshalTolk(cell, v, decoder) + if err != nil { + return fmt.Errorf("failed to unmarshal AliasRef: %w", err) + } + return nil + case "Generic": + err := t.Generic.UnmarshalTolk(cell, v, decoder) + if err != nil { + return fmt.Errorf("failed to unmarshal Generic: %w", err) + } + return nil + case "Union": + err := t.Union.UnmarshalTolk(cell, v, decoder) + if err != nil { + return fmt.Errorf("failed to unmarshal Union: %w", err) + } + return nil + default: + return fmt.Errorf("unknown type %q", t.SumType) + } +} + +func (t *Ty) MarshalTolk(cell *boc.Cell, v *Value) error { + switch t.SumType { + case "Int": + err := t.Int.MarshalTolk(cell, v) + if err != nil { + return fmt.Errorf("failed to marshal unmarshal Int: %w", err) + } + return nil + case "NullLiteral": + err := t.NullLiteral.MarshalTolk(cell, v) + if err != nil { + return fmt.Errorf("failed to marshal NullLiteral Int: %w", err) + } + return nil + case "Void": + err := t.Void.MarshalTolk(cell, v) + if err != nil { + return fmt.Errorf("failed to marshal Void: %w", err) + } + return nil + case "IntN": + err := t.IntN.MarshalTolk(cell, v) + if err != nil { + return fmt.Errorf("failed to marshal IntN: %w", err) + } + return nil + case "UintN": + err := t.UintN.MarshalTolk(cell, v) + if err != nil { + return fmt.Errorf("failed to marshal UintN: %w", err) + } + return nil + case "VarIntN": + err := t.VarIntN.MarshalTolk(cell, v) + if err != nil { + return fmt.Errorf("failed to marshal VarIntN: %w", err) + } + return nil + case "VarUintN": + err := t.VarUintN.MarshalTolk(cell, v) + if err != nil { + return fmt.Errorf("failed to marshal VarUintN: %w", err) + } + return nil + case "BitsN": + err := t.BitsN.MarshalTolk(cell, v) + if err != nil { + return fmt.Errorf("failed to marshal BitsN: %w", err) + } + return nil + case "Coins": + err := t.Coins.MarshalTolk(cell, v) + if err != nil { + return fmt.Errorf("failed to marshal Coins: %w", err) + } + return nil + case "Bool": + err := t.Bool.MarshalTolk(cell, v) + if err != nil { + return fmt.Errorf("failed to marshal Bool: %w", err) + } + return nil + case "Cell": + err := t.Cell.MarshalTolk(cell, v) + if err != nil { + return fmt.Errorf("failed to marshal Cell: %w", err) + } + return nil + case "Slice": + err := t.Slice.MarshalTolk(cell, v) + if err != nil { + return fmt.Errorf("failed to marshal Slice: %w", err) + } + return nil + case "Builder": + err := t.Builder.MarshalTolk(cell, v) + if err != nil { + return fmt.Errorf("failed to marshal Builder: %w", err) + } + return nil + case "Callable": + err := t.Callable.MarshalTolk(cell, v) + if err != nil { + return fmt.Errorf("failed to marshal Callable: %w", err) + } + return nil + case "Remaining": + err := t.Remaining.MarshalTolk(cell, v) + if err != nil { + return fmt.Errorf("failed to marshal Remaining: %w", err) + } + return nil + case "Address": + err := t.Address.MarshalTolk(cell, v) + if err != nil { + return fmt.Errorf("failed to marshal Address: %w", err) + } + return nil + case "AddressOpt": + err := t.AddressOpt.MarshalTolk(cell, v) + if err != nil { + return fmt.Errorf("failed to marshal AddressOpt: %w", err) + } + return nil + case "AddressExt": + err := t.AddressExt.MarshalTolk(cell, v) + if err != nil { + return fmt.Errorf("failed to marshal AddressExt: %w", err) + } + return nil + case "AddressAny": + err := t.AddressAny.MarshalTolk(cell, v) + if err != nil { + return fmt.Errorf("failed to marshal AddressAny: %w", err) + } + return nil + case "Nullable": + err := t.Nullable.MarshalTolk(cell, v) + if err != nil { + return fmt.Errorf("failed to marshal Nullable: %w", err) + } + return nil + case "CellOf": + err := t.CellOf.MarshalTolk(cell, v) + if err != nil { + return fmt.Errorf("failed to marshal CellOf: %w", err) + } + return nil + case "Tensor": + err := t.Tensor.MarshalTolk(cell, v) + if err != nil { + return fmt.Errorf("failed to marshal Tensor: %w", err) + } + return nil + case "TupleWith": + err := t.TupleWith.MarshalTolk(cell, v) + if err != nil { + return fmt.Errorf("failed to marshal TupleWith: %w", err) + } + return nil + case "TupleAny": + err := t.TupleAny.MarshalTolk(cell, v) + if err != nil { + return fmt.Errorf("failed to marshal TupleAny: %w", err) + } + return nil + case "Map": + err := t.Map.MarshalTolk(cell, v) + if err != nil { + return fmt.Errorf("failed to marshal Map: %w", err) + } + return nil + case "EnumRef": + err := t.EnumRef.MarshalTolk(cell, v) + if err != nil { + return fmt.Errorf("failed to marshal EnumRef: %w", err) + } + return nil + case "StructRef": + err := t.StructRef.MarshalTolk(cell, v) + if err != nil { + return fmt.Errorf("failed to marshal StructRef: %w", err) + } + return nil + case "AliasRef": + err := t.AliasRef.MarshalTolk(cell, v) + if err != nil { + return fmt.Errorf("failed to marshal AliasRef: %w", err) + } + return nil + case "Generic": + err := t.Generic.MarshalTolk(cell, v) + if err != nil { + return fmt.Errorf("failed to marshal Generic: %w", err) + } + return nil + case "Union": + err := t.Union.MarshalTolk(cell, v) + if err != nil { + return fmt.Errorf("failed to marshal Union: %w", err) + } + return nil + default: + return fmt.Errorf("unknown type %q", t.SumType) + } +} + +func (t *Ty) GetComparableType() (TolkComparableType, bool) { + var tolkType TolkType + switch t.SumType { + case "Int": + tolkType = t.Int + case "NullLiteral": + tolkType = t.NullLiteral + case "Void": + tolkType = t.Void + case "IntN": + tolkType = t.IntN + case "UintN": + tolkType = t.UintN + case "VarIntN": + tolkType = t.VarIntN + case "VarUintN": + tolkType = t.VarUintN + case "BitsN": + tolkType = t.BitsN + case "Coins": + tolkType = t.Coins + case "Bool": + tolkType = t.Bool + case "Cell": + tolkType = t.Cell + case "Slice": + tolkType = t.Slice + case "Builder": + tolkType = t.Builder + case "Callable": + tolkType = t.Callable + case "Remaining": + tolkType = t.Remaining + case "Address": + tolkType = t.Address + case "AddressOpt": + tolkType = t.AddressOpt + case "AddressExt": + tolkType = t.AddressExt + case "AddressAny": + tolkType = t.AddressAny + case "Nullable": + tolkType = t.Nullable + case "CellOf": + tolkType = t.CellOf + case "Tensor": + tolkType = t.Tensor + case "TupleWith": + tolkType = t.TupleWith + case "TupleAny": + tolkType = t.TupleAny + case "Map": + tolkType = t.Map + case "EnumRef": + tolkType = t.EnumRef + case "StructRef": + tolkType = t.StructRef + case "AliasRef": + tolkType = t.AliasRef + case "Generic": + tolkType = t.Generic + case "Union": + tolkType = t.Union + default: + return nil, false + } + + var comparableType TolkComparableType + var ok bool + comparableType, ok = tolkType.(TolkComparableType) + return comparableType, ok +} + +type UnionVariant struct { + PrefixStr string `json:"prefixStr"` + PrefixLen int `json:"prefixLen"` + PrefixEatInPlace bool `json:"prefixEatInPlace,omitempty"` + VariantTy Ty `json:"variantTy"` +} + +type IncomingMessage struct { + BodyTy Ty `json:"bodyTy"` + MinimalMsgValue *big.Int `json:"minimalMsgValue,omitempty"` + Description string `json:"description,omitempty"` + PreferredSendMode int16 `json:"preferredSendMode,omitempty"` +} + +func (m *IncomingMessage) GetMsgName() (string, error) { + return getMsgName(m.BodyTy) +} + +type IncomingExternal struct { + BodyTy Ty `json:"bodyTy"` + Description string `json:"description,omitempty"` +} + +func (m *IncomingExternal) GetMsgName() (string, error) { + return getMsgName(m.BodyTy) +} + +type OutgoingMessage struct { + BodyTy Ty `json:"bodyTy"` + Description string `json:"description,omitempty"` +} + +func (m *OutgoingMessage) GetMsgName() (string, error) { + return getMsgName(m.BodyTy) +} + +func getMsgName(ty Ty) (string, error) { + switch ty.SumType { + case "StructRef": + return ty.StructRef.StructName, nil + case "AliasRef": + return ty.AliasRef.AliasName, nil + default: + return "", fmt.Errorf("cannot get name for %q body", ty.SumType) + } +} + +type GetMethod struct { + TvmMethodID int `json:"tvmMethodId"` + Name string `json:"name"` + Parameters []Parameter `json:"parameters"` + ReturnTy Ty `json:"returnTy"` + Description string `json:"description,omitempty"` +} + +func (g GetMethod) GolangFunctionName() string { + return utils.ToCamelCase(g.Name) +} + +func (g GetMethod) FullResultName(contractName string) string { + res := "" + if contractName != "" { + res = contractName + "_" + } + res += utils.ToCamelCase(g.Name) + + return res + "Result" +} + +func (g GetMethod) UsedByIntrospection() bool { + return len(g.Parameters) == 0 +} + +type Parameter struct { + Name string `json:"name"` + Ty Ty `json:"ty"` +} + +type ThrownError struct { + Name string `json:"constName"` + ErrCode int `json:"errCode"` +} + +func concatPrefixAndPayload(prefix, payload []byte) []byte { + if len(payload) == 0 { + return prefix + } + prefix = prefix[:len(prefix)-1] // remove '}' + payload[0] = ',' // replace '{' with ',' + result := make([]byte, 0, len(prefix)+len(payload)) + result = append(result, prefix...) + result = append(result, payload...) + return result +} diff --git a/tolk/addresses.go b/tolk/addresses.go new file mode 100644 index 00000000..29bd8679 --- /dev/null +++ b/tolk/addresses.go @@ -0,0 +1,523 @@ +package tolk + +import ( + "fmt" + + "github.com/tonkeeper/tongo/boc" +) + +type Address struct{} + +func (Address) SetValue(v *Value, val any) error { + a, ok := val.(InternalAddress) + if !ok { + return fmt.Errorf("value is not an internal address") + } + v.sumType = "internalAddress" + v.internalAddress = &a + return nil +} + +func (a Address) UnmarshalTolk(cell *boc.Cell, v *Value, abiCtx *Decoder) error { + err := cell.Skip(3) // skip addr type ($10) and anycast (0) + if err != nil { + return err + } + workchain, err := cell.ReadInt(8) + if err != nil { + return err + } + address, err := cell.ReadBytes(32) + if err != nil { + return err + } + err = a.SetValue(v, InternalAddress{ + Workchain: int8(workchain), + Address: [32]byte(address), + }) + if err != nil { + return err + } + return nil +} + +func (i *InternalAddress) UnmarshalTolk(cell *boc.Cell, ty Address, abiCtx *Decoder) error { + err := cell.Skip(3) // skip addr type ($10) and anycast (0) + if err != nil { + return err + } + workchain, err := cell.ReadInt(8) + if err != nil { + return err + } + address, err := cell.ReadBytes(32) + if err != nil { + return err + } + *i = InternalAddress{ + Workchain: int8(workchain), + Address: [32]byte(address), + } + return nil +} + +func (Address) MarshalTolk(cell *boc.Cell, v *Value) error { + if v.internalAddress == nil { + return fmt.Errorf("address not found") + } + + err := cell.WriteUint(0b100, 3) // internal addr type ($10) and anycast (0) + if err != nil { + return err + } + err = cell.WriteInt(int64(v.internalAddress.Workchain), 8) + if err != nil { + return err + } + err = cell.WriteBytes(v.internalAddress.Address[:]) + if err != nil { + return err + } + return nil +} + +func (Address) Equal(v Value, o Value) bool { + if v.internalAddress == nil || o.internalAddress == nil { + return false + } + vi := *v.internalAddress + oi := *o.internalAddress + return vi.Workchain == oi.Workchain && vi.Address == oi.Address +} + +func (Address) GetFixedSize() int { + return 267 +} + +type AddressOpt struct { +} + +func (AddressOpt) SetValue(v *Value, val any) error { + a, ok := val.(OptionalAddress) + if !ok { + return fmt.Errorf("value is not an optional address") + } + v.sumType = "optionalAddress" + v.optionalAddress = &a + return nil +} + +func (a AddressOpt) UnmarshalTolk(cell *boc.Cell, v *Value, abiCtx *Decoder) error { + tag, err := cell.ReadUint(2) + if err != nil { + return err + } + if tag == 0 { + err = a.SetValue(v, OptionalAddress{ + SumType: "NoneAddress", + }) + if err != nil { + return err + } + return nil + } + err = cell.Skip(1) // skip anycast (0) + if err != nil { + return err + } + workchain, err := cell.ReadInt(8) + if err != nil { + return err + } + address, err := cell.ReadBytes(32) + if err != nil { + return err + } + err = a.SetValue(v, OptionalAddress{ + SumType: "InternalAddress", + InternalAddress: InternalAddress{ + Workchain: int8(workchain), + Address: [32]byte(address), + }, + }) + if err != nil { + return err + } + + return nil +} + +func (o *OptionalAddress) UnmarshalTolk(cell *boc.Cell, ty AddressOpt, abiCtx *Decoder) error { + tag, err := cell.ReadUint(2) + if err != nil { + return err + } + if tag == 0 { + o.SumType = "NoneAddress" + return nil + } + err = cell.Skip(1) // skip anycast (0) + if err != nil { + return err + } + workchain, err := cell.ReadInt(8) + if err != nil { + return err + } + address, err := cell.ReadBytes(32) + if err != nil { + return err + } + o.SumType = "InternalAddress" + o.InternalAddress = InternalAddress{ + Workchain: int8(workchain), + Address: [32]byte(address), + } + + return nil +} + +func (AddressOpt) MarshalTolk(cell *boc.Cell, v *Value) error { + if v.optionalAddress == nil { + return fmt.Errorf("optional address not found") + } + + if v.optionalAddress.SumType == "NoneAddress" { + err := cell.WriteUint(0, 2) + if err != nil { + return err + } + + return nil + } + + err := cell.WriteUint(0b100, 3) // internal addr type ($10) and anycast (0) + if err != nil { + return err + } + err = cell.WriteInt(int64(v.optionalAddress.InternalAddress.Workchain), 8) + if err != nil { + return err + } + err = cell.WriteBytes(v.optionalAddress.InternalAddress.Address[:]) + if err != nil { + return err + } + return nil +} + +func (AddressOpt) Equal(v Value, o Value) bool { + return false +} + +type AddressExt struct{} + +func (AddressExt) SetValue(v *Value, val any) error { + a, ok := val.(ExternalAddress) + if !ok { + return fmt.Errorf("value is not an external address") + } + v.externalAddress = &a + v.sumType = "externalAddress" + return nil +} + +func (a AddressExt) UnmarshalTolk(cell *boc.Cell, v *Value, abiCtx *Decoder) error { + err := cell.Skip(2) + if err != nil { + return err + } + ln, err := cell.ReadUint(9) + if err != nil { + return err + } + bs, err := cell.ReadBits(int(ln)) + if err != nil { + return err + } + err = a.SetValue(v, ExternalAddress{ + Len: int16(ln), + Address: bs, + }) + if err != nil { + return err + } + + return nil +} + +func (e *ExternalAddress) UnmarshalTolk(cell *boc.Cell, ty AddressExt, abiCtx *Decoder) error { + err := cell.Skip(2) + if err != nil { + return err + } + ln, err := cell.ReadUint(9) + if err != nil { + return err + } + bs, err := cell.ReadBits(int(ln)) + if err != nil { + return err + } + *e = ExternalAddress{ + Len: int16(ln), + Address: bs, + } + + return nil +} + +func (AddressExt) MarshalTolk(cell *boc.Cell, v *Value) error { + if v.externalAddress == nil { + return fmt.Errorf("external address not found") + } + + err := cell.WriteUint(1, 2) // external addr type ($01) + if err != nil { + return err + } + err = cell.WriteUint(uint64(v.externalAddress.Len), 9) + if err != nil { + return err + } + err = cell.WriteBitString(v.externalAddress.Address) + if err != nil { + return err + } + return nil +} + +func (AddressExt) Equal(v Value, o Value) bool { + return false +} + +type AddressAny struct{} + +func (AddressAny) SetValue(v *Value, val any) error { + a, ok := val.(AnyAddress) + if !ok { + return fmt.Errorf("value is not an any address") + } + v.anyAddress = &a + v.sumType = "anyAddress" + return nil +} + +func (a AddressAny) UnmarshalTolk(cell *boc.Cell, v *Value, abiCtx *Decoder) error { + tag, err := cell.ReadUint(2) + if err != nil { + return err + } + switch tag { + case 0: + err = a.SetValue(v, AnyAddress{ + SumType: "NoneAddress", + }) + if err != nil { + return err + } + case 1: + ln, err := cell.ReadUint(9) + if err != nil { + return err + } + bs, err := cell.ReadBits(int(ln)) + if err != nil { + return err + } + err = a.SetValue(v, AnyAddress{ + SumType: "ExternalAddress", + ExternalAddress: &ExternalAddress{ + Len: int16(ln), + Address: bs, + }, + }) + if err != nil { + return err + } + case 2: + err = cell.Skip(1) // skip anycast (0) + if err != nil { + return err + } + workchain, err := cell.ReadInt(8) + if err != nil { + return err + } + address, err := cell.ReadBytes(32) + if err != nil { + return err + } + err = a.SetValue(v, AnyAddress{ + SumType: "InternalAddress", + InternalAddress: &InternalAddress{ + Workchain: int8(workchain), + Address: [32]byte(address), + }, + }) + if err != nil { + return err + } + case 3: + err = cell.Skip(1) // skip anycast (0) + if err != nil { + return err + } + ln, err := cell.ReadUint(9) + if err != nil { + return err + } + workchain, err := cell.ReadInt(32) + if err != nil { + return err + } + bs, err := cell.ReadBits(int(ln)) + if err != nil { + return err + } + err = a.SetValue(v, AnyAddress{ + SumType: "VarAddress", + VarAddress: &VarAddress{ + Len: int16(ln), + Workchain: int32(workchain), + Address: bs, + }, + }) + if err != nil { + return err + } + } + + return nil +} + +func (a *AnyAddress) UnmarshalTolk(cell *boc.Cell, ty AddressAny, abiCtx *Decoder) error { + tag, err := cell.ReadUint(2) + if err != nil { + return err + } + switch tag { + case 0: + a.SumType = "NoneAddress" + case 1: + ln, err := cell.ReadUint(9) + if err != nil { + return err + } + bs, err := cell.ReadBits(int(ln)) + if err != nil { + return err + } + a.SumType = "ExternalAddress" + a.ExternalAddress = &ExternalAddress{ + Len: int16(ln), + Address: bs, + } + case 2: + err = cell.Skip(1) // skip anycast (0) + if err != nil { + return err + } + workchain, err := cell.ReadInt(8) + if err != nil { + return err + } + address, err := cell.ReadBytes(32) + if err != nil { + return err + } + a.SumType = "InternalAddress" + a.InternalAddress = &InternalAddress{ + Workchain: int8(workchain), + Address: [32]byte(address), + } + case 3: + err = cell.Skip(1) // skip anycast (0) + if err != nil { + return err + } + ln, err := cell.ReadUint(9) + if err != nil { + return err + } + workchain, err := cell.ReadInt(32) + if err != nil { + return err + } + bs, err := cell.ReadBits(int(ln)) + if err != nil { + return err + } + a.SumType = "VarAddress" + a.VarAddress = &VarAddress{ + Len: int16(ln), + Workchain: int32(workchain), + Address: bs, + } + } + + return nil +} + +func (AddressAny) MarshalTolk(cell *boc.Cell, v *Value) error { + if v.anyAddress == nil { + return fmt.Errorf("any address not found") + } + + switch v.anyAddress.SumType { + case "NoneAddress": + err := cell.WriteUint(0, 2) + if err != nil { + return err + } + case "InternalAddress": + err := cell.WriteUint(0b100, 3) // internal addr type ($10) and anycast (0) + if err != nil { + return err + } + err = cell.WriteInt(int64(v.anyAddress.InternalAddress.Workchain), 8) + if err != nil { + return err + } + err = cell.WriteBytes(v.anyAddress.InternalAddress.Address[:]) + if err != nil { + return err + } + case "ExternalAddress": + err := cell.WriteUint(1, 2) // external addr type ($01) + if err != nil { + return err + } + err = cell.WriteUint(uint64(v.anyAddress.ExternalAddress.Len), 9) + if err != nil { + return err + } + err = cell.WriteBitString(v.anyAddress.ExternalAddress.Address) + if err != nil { + return err + } + case "VarAddress": + err := cell.WriteUint(0b110, 3) // var addr type ($11) and anycast (0) + if err != nil { + return err + } + err = cell.WriteUint(uint64(v.anyAddress.VarAddress.Len), 9) + if err != nil { + return err + } + err = cell.WriteInt(int64(v.anyAddress.VarAddress.Workchain), 32) + if err != nil { + return err + } + err = cell.WriteBitString(v.anyAddress.VarAddress.Address) + if err != nil { + return err + } + } + + return nil +} + +func (AddressAny) Equal(v Value, o Value) bool { + return false +} diff --git a/tolk/cells.go b/tolk/cells.go new file mode 100644 index 00000000..43b636b6 --- /dev/null +++ b/tolk/cells.go @@ -0,0 +1,316 @@ +package tolk + +import ( + "fmt" + + "github.com/tonkeeper/tongo/boc" +) + +type Cell struct{} + +func (Cell) SetValue(v *Value, val any) error { + a, ok := val.(Any) + if !ok { + return fmt.Errorf("value is not a cell") + } + v.cell = &a + v.sumType = "cell" + return nil +} + +func (c Cell) UnmarshalTolk(cell *boc.Cell, v *Value, decoder *Decoder) error { + ref, err := cell.NextRef() + if err != nil { + return err + } + err = c.SetValue(v, Any(*ref)) + if err != nil { + return err + } + return nil +} + +func (a *Any) UnmarshalTolk(cell *boc.Cell, ty Cell, decoder *Decoder) error { + ref, err := cell.NextRef() + if err != nil { + return err + } + *a = Any(*ref) + + return nil +} + +func (Cell) MarshalTolk(cell *boc.Cell, v *Value) error { + if v.cell == nil { + return fmt.Errorf("ref not found") + } + + c := boc.Cell(*v.cell) + ref := c.CopyRemaining() + err := cell.AddRef(ref) + if err != nil { + return err + } + + return nil +} + +func (Cell) Equal(v Value, o Value) bool { + return false +} + +type Slice struct{} + +func (Slice) SetValue(v *Value, val any) error { + return fmt.Errorf("slice is not supported") +} + +func (Slice) UnmarshalTolk(cell *boc.Cell, v *Value, decoder *Decoder) error { + return fmt.Errorf("slice is not supported") +} + +func (Slice) MarshalTolk(cell *boc.Cell, v *Value) error { + return fmt.Errorf("slice is not supported") +} + +func (Slice) Equal(v Value, o Value) bool { + return false +} + +type Builder struct{} + +func (Builder) SetValue(v *Value, val any) error { + return fmt.Errorf("builder is not supported") +} + +func (Builder) UnmarshalTolk(cell *boc.Cell, v *Value, decoder *Decoder) error { + return fmt.Errorf("builder is not supported") +} + +func (Builder) MarshalTolk(cell *boc.Cell, v *Value) error { + return fmt.Errorf("builder is not supported") +} + +func (Builder) Equal(v Value, o Value) bool { + return false +} + +type Callable struct{} + +func (Callable) SetValue(v *Value, val any) error { + return fmt.Errorf("callable is not supported") +} + +func (Callable) UnmarshalTolk(cell *boc.Cell, v *Value, decoder *Decoder) error { + return fmt.Errorf("callable is not supported") +} + +func (Callable) MarshalTolk(cell *boc.Cell, v *Value) error { + return fmt.Errorf("callable is not supported") +} + +func (Callable) Equal(v Value, o Value) bool { + return false +} + +type Remaining struct{} + +func (Remaining) SetValue(v *Value, val any) error { + a, ok := val.(Any) + if !ok { + return fmt.Errorf("value is not a cell") + } + v.cell = &a + v.sumType = "cell" + return nil +} + +func (r Remaining) UnmarshalTolk(cell *boc.Cell, v *Value, decoder *Decoder) error { + rem := cell.CopyRemaining() + if rem != nil { + err := r.SetValue(v, Any(*rem)) + if err != nil { + return err + } + } + return nil +} + +func (r *RemainingValue) UnmarshalTolk(cell *boc.Cell, ty Remaining, decoder *Decoder) error { + rem := cell.CopyRemaining() + if rem != nil { + *r = RemainingValue(*rem) + } + return nil +} + +func (Remaining) MarshalTolk(cell *boc.Cell, v *Value) error { + if v.cell == nil { + return fmt.Errorf("remaining not found") + } + c := boc.Cell(*v.cell) + err := cell.WriteBitString(c.ReadRemainingBits()) + if err != nil { + return err + } + for _, ref := range c.Refs() { + err = cell.AddRef(ref) + if err != nil { + return err + } + } + + return nil +} + +func (Remaining) Equal(v Value, o Value) bool { + return false +} + +type Nullable struct { + Inner Ty `json:"inner"` +} + +func (Nullable) SetValue(v *Value, val any) error { + o, ok := val.(OptValue) + if !ok { + return fmt.Errorf("value is not an optional value") + } + v.optionalValue = &o + v.sumType = "optionalValue" + return nil +} + +func (n Nullable) UnmarshalTolk(cell *boc.Cell, v *Value, decoder *Decoder) error { + isExists, err := cell.ReadBit() + if err != nil { + return err + } + innerV := Value{} + optV := OptValue{ + IsExists: isExists, + Val: innerV, + } + if isExists { + err = innerV.UnmarshalTolk(cell, n.Inner, decoder) + if err != nil { + return err + } + optV.Val = innerV + } + err = n.SetValue(v, optV) + if err != nil { + return err + } + return nil +} + +func (o *OptValue) UnmarshalTolk(cell *boc.Cell, ty Nullable, decoder *Decoder) error { + isExists, err := cell.ReadBit() + if err != nil { + return err + } + o.IsExists = isExists + if isExists { + err = o.Val.UnmarshalTolk(cell, ty.Inner, decoder) + if err != nil { + return err + } + } + return nil +} + +func (Nullable) MarshalTolk(cell *boc.Cell, v *Value) error { + //if v.optionalValue == nil { + // return fmt.Errorf("optional value not found") + //} + //exists := v.optionalValue.IsExists + //err := cell.WriteBit(exists) + //if err != nil { + // return err + //} + // + //if exists { + // val := v.optionalValue.Val + // err = val.valType.MarshalTolk(cell, &val) + // if err != nil { + // return err + // } + //} + + return nil +} + +func (Nullable) Equal(v Value, o Value) bool { + return false +} + +type CellOf struct { + Inner Ty `json:"inner"` +} + +func (CellOf) SetValue(v *Value, val any) error { + r, ok := val.(RefValue) + if !ok { + return fmt.Errorf("value is not a ref value") + } + v.refValue = &r + v.sumType = "refValue" + return nil +} + +func (c CellOf) UnmarshalTolk(cell *boc.Cell, v *Value, decoder *Decoder) error { + ref, err := cell.NextRef() + if err != nil { + return err + } + innerV := Value{} + err = innerV.UnmarshalTolk(ref, c.Inner, decoder) + if err != nil { + return err + } + err = c.SetValue(v, RefValue(innerV)) + if err != nil { + return err + } + + return nil +} + +func (r *RefValue) UnmarshalTolk(cell *boc.Cell, ty CellOf, decoder *Decoder) error { + ref, err := cell.NextRef() + if err != nil { + return err + } + innerV := Value{} + err = innerV.UnmarshalTolk(ref, ty.Inner, decoder) + if err != nil { + return err + } + *r = RefValue(innerV) + + return nil +} + +func (CellOf) MarshalTolk(cell *boc.Cell, v *Value) error { + //if v.refValue == nil { + // return fmt.Errorf("ref value not found") + //} + //ref := boc.NewCell() + //val := Value(*v.refValue) + //err := val.valType.MarshalTolk(ref, &val) + //if err != nil { + // return err + //} + // + //err = cell.AddRef(ref) + //if err != nil { + // return err + //} + + return nil +} + +func (CellOf) Equal(v Value, o Value) bool { + return false +} diff --git a/tolk/integers.go b/tolk/integers.go new file mode 100644 index 00000000..68839b1b --- /dev/null +++ b/tolk/integers.go @@ -0,0 +1,549 @@ +package tolk + +import ( + "bytes" + "fmt" + "math/big" + + "github.com/tonkeeper/tongo/boc" +) + +type Int struct{} + +func (i Int) SetValue(v *Value, val any) error { + return fmt.Errorf("int is not supported") +} + +func (Int) UnmarshalTolk(cell *boc.Cell, v *Value, decoder *Decoder) error { + return fmt.Errorf("int is not supported") +} + +func (Int) MarshalTolk(cell *boc.Cell, v *Value) error { + return fmt.Errorf("int is not supported") +} + +func (Int) Equal(v Value, o Value) bool { + return false +} + +type IntN struct { + N int `json:"n"` +} + +func (i IntN) SetValue(v *Value, val any) error { + n := i.N + if n > 64 { + bi, ok := val.(BigInt) + if !ok { + return fmt.Errorf("value is not a BigInt") + } + v.bigInt = &bi + v.sumType = "bigInt" + } else { + i64, ok := val.(Int64) + if !ok { + bi, ok := val.(BigInt) + if !ok { + return fmt.Errorf("value is not a BigInt or Int64") + } + b := big.Int(bi) + i64 = Int64(b.Int64()) + } + v.smallInt = &i64 + v.sumType = "smallInt" + } + return nil +} + +func (i IntN) UnmarshalTolk(cell *boc.Cell, v *Value, decoder *Decoder) error { + num, err := cell.ReadBigInt(i.N) + if err != nil { + return err + } + err = i.SetValue(v, BigInt(*num)) + if err != nil { + return err + } + return nil +} + +func (i *Int64) UnmarshalTolk(cell *boc.Cell, ty IntN, decoder *Decoder) error { + num, err := cell.ReadInt(ty.N) + if err != nil { + return err + } + *i = Int64(num) + return nil +} + +func (b *BigInt) UnmarshalTolk(cell *boc.Cell, ty IntN, decoder *Decoder) error { + num, err := cell.ReadBigInt(ty.N) + if err != nil { + return err + } + *b = BigInt(*num) + return nil +} + +func (i IntN) MarshalTolk(cell *boc.Cell, v *Value) error { + if i.N > 64 { + if v.bigInt == nil { + return fmt.Errorf("big int not found") + } + bi := big.Int(*v.bigInt) + + err := cell.WriteBigInt(&bi, i.N) + if err != nil { + return err + } + } else { + if v.smallInt == nil { + return fmt.Errorf("small int not found") + } + + i64 := int64(*v.smallInt) + err := cell.WriteInt(i64, i.N) + if err != nil { + return err + } + } + + return nil +} + +func (i IntN) GetFixedSize() int { + return i.N +} + +func (IntN) Equal(v Value, o Value) bool { + if v.smallInt == nil && o.smallInt == nil { + if v.bigInt == nil || o.bigInt == nil { + return false + } + + vb := big.Int(*v.bigInt) + ob := big.Int(*o.bigInt) + return vb.Cmp(&ob) == 0 + } + + if v.smallInt == nil || o.smallInt == nil { + return false + } + + return *v.smallInt == *o.smallInt +} + +type UintN struct { + N int `json:"n"` +} + +func (u UintN) SetValue(v *Value, val any) error { + n := u.N + if n > 64 { + bi, ok := val.(BigInt) + if !ok { + return fmt.Errorf("value is not a BigInt") + } + v.bigInt = &bi + v.sumType = "bigInt" + } else { + ui64, ok := val.(UInt64) + if !ok { + bi, ok := val.(BigInt) + if !ok { + return fmt.Errorf("value is not a BigInt or UInt64") + } + b := big.Int(bi) + ui64 = UInt64(b.Uint64()) + } + v.smallUint = &ui64 + v.sumType = "smallUint" + } + return nil +} + +func (u UintN) UnmarshalTolk(cell *boc.Cell, v *Value, decoder *Decoder) error { + num, err := cell.ReadBigUint(u.N) + if err != nil { + return err + } + err = u.SetValue(v, BigInt(*num)) + if err != nil { + return err + } + return nil +} + +func (i *UInt64) UnmarshalTolk(cell *boc.Cell, ty UintN, decoder *Decoder) error { + num, err := cell.ReadUint(ty.N) + if err != nil { + return err + } + *i = UInt64(num) + return nil +} + +func (b *BigUInt) UnmarshalTolk(cell *boc.Cell, ty UintN, decoder *Decoder) error { + num, err := cell.ReadBigUint(ty.N) + if err != nil { + return err + } + *b = BigUInt(*num) + return nil +} + +func (u UintN) MarshalTolk(cell *boc.Cell, v *Value) error { + if u.N > 64 { + if v.bigInt == nil { + return fmt.Errorf("big int not found") + } + bi := big.Int(*v.bigInt) + + err := cell.WriteBigUint(&bi, u.N) + if err != nil { + return err + } + } else { + if v.smallUint == nil { + return fmt.Errorf("small uint not found") + } + + ui64 := uint64(*v.smallUint) + err := cell.WriteUint(ui64, u.N) + if err != nil { + return err + } + } + + return nil +} + +func (u UintN) GetFixedSize() int { + return u.N +} + +func (UintN) Equal(v Value, o Value) bool { + if v.smallUint == nil && o.smallUint == nil { + if v.bigInt == nil || o.bigInt == nil { + return false + } + + vb := big.Int(*v.bigInt) + ob := big.Int(*o.bigInt) + return vb.Cmp(&ob) == 0 + } + + if v.smallUint == nil || o.smallUint == nil { + return false + } + + return *v.smallUint == *o.smallUint +} + +type VarIntN struct { + N int `json:"n"` +} + +func (VarIntN) SetValue(v *Value, val any) error { + bi, ok := val.(BigInt) + if !ok { + return fmt.Errorf("value is not a BigInt") + } + v.bigInt = &bi + v.sumType = "bigInt" + return nil +} + +func (vi VarIntN) UnmarshalTolk(cell *boc.Cell, v *Value, decoder *Decoder) error { + n := vi.N + ln, err := cell.ReadLimUint(n - 1) + if err != nil { + return err + } + val, err := cell.ReadBigInt(int(ln) * 8) + if err != nil { + return err + } + err = vi.SetValue(v, BigInt(*val)) + if err != nil { + return err + } + return nil +} + +func (vi *VarInt) UnmarshalTolk(cell *boc.Cell, ty VarIntN, decoder *Decoder) error { + ln, err := cell.ReadLimUint(ty.N - 1) + if err != nil { + return err + } + val, err := cell.ReadBigInt(int(ln) * 8) + if err != nil { + return err + } + *vi = VarInt(*val) + return nil +} + +func (vi VarIntN) MarshalTolk(cell *boc.Cell, v *Value) error { + if v.bigInt == nil { + return fmt.Errorf("BigInt is nil") + } + bi := big.Int(*v.bigInt) + num := bi.Bytes() + err := cell.WriteLimUint(len(num), vi.N-1) + if err != nil { + return err + } + err = cell.WriteBigInt(&bi, len(num)*8) + if err != nil { + return err + } + + return nil +} + +func (VarIntN) Equal(v Value, o Value) bool { + return false +} + +type VarUintN struct { + N int `json:"n"` +} + +func (VarUintN) SetValue(v *Value, val any) error { + vu, ok := val.(BigInt) + if !ok { + return fmt.Errorf("value is not a BigInt") + } + v.bigInt = &vu + v.sumType = "bigInt" + return nil +} + +func (vu VarUintN) UnmarshalTolk(cell *boc.Cell, v *Value, decoder *Decoder) error { + n := vu.N + ln, err := cell.ReadLimUint(n - 1) + if err != nil { + return err + } + val, err := cell.ReadBigUint(int(ln) * 8) + if err != nil { + return err + } + err = vu.SetValue(v, BigInt(*val)) + if err != nil { + return err + } + return nil +} + +func (vu *VarUInt) UnmarshalTolk(cell *boc.Cell, ty VarUintN, decoder *Decoder) error { + ln, err := cell.ReadLimUint(ty.N - 1) + if err != nil { + return err + } + val, err := cell.ReadBigInt(int(ln) * 8) + if err != nil { + return err + } + *vu = VarUInt(*val) + return nil +} + +func (vu VarUintN) MarshalTolk(cell *boc.Cell, v *Value) error { + if v.bigInt == nil { + return fmt.Errorf("BigInt is nil") + } + bi := big.Int(*v.bigInt) + num := bi.Bytes() + err := cell.WriteLimUint(len(num), vu.N-1) + if err != nil { + return err + } + err = cell.WriteBytes(num) + if err != nil { + return err + } + + return nil +} + +func (VarUintN) Equal(v Value, o Value) bool { + return false +} + +type BitsN struct { + N int `json:"n"` +} + +func (BitsN) SetValue(v *Value, val any) error { + bits, ok := val.(Bits) + if !ok { + return fmt.Errorf("value is not a Bits") + } + v.bits = &bits + v.sumType = "bits" + return nil +} + +func (b BitsN) UnmarshalTolk(cell *boc.Cell, v *Value, decoder *Decoder) error { + n := b.N + val, err := cell.ReadBits(n) + if err != nil { + return err + } + err = b.SetValue(v, Bits(val)) + if err != nil { + return err + } + return nil +} + +func (b *Bits) UnmarshalTolk(cell *boc.Cell, ty BitsN, decoder *Decoder) error { + val, err := cell.ReadBits(ty.N) + if err != nil { + return err + } + *b = Bits(val) + return nil +} + +func (BitsN) MarshalTolk(cell *boc.Cell, v *Value) error { + if v.bits == nil { + return fmt.Errorf("bits is nil") + } + bi := boc.BitString(*v.bits) + err := cell.WriteBitString(bi) + if err != nil { + return err + } + + return nil +} + +func (b BitsN) GetFixedSize() int { + return b.N +} + +func (BitsN) Equal(v Value, o Value) bool { + if v.bits == nil || o.bits == nil { + return false + } + vb := boc.BitString(*v.bits) + ob := boc.BitString(*o.bits) + return bytes.Equal(vb.Buffer(), ob.Buffer()) +} + +type Coins struct { +} + +func (Coins) SetValue(v *Value, val any) error { + bi, ok := val.(BigInt) + if !ok { + return fmt.Errorf("value is not a BigInt") + } + v.bigInt = &bi + v.sumType = "bigInt" + return nil +} + +func (c Coins) UnmarshalTolk(cell *boc.Cell, v *Value, decoder *Decoder) error { + ln, err := cell.ReadLimUint(15) + if err != nil { + return err + } + val, err := cell.ReadBigUint(int(ln) * 8) + if err != nil { + return err + } + err = c.SetValue(v, BigInt(*val)) + if err != nil { + return err + } + return nil +} + +func (c *CoinsValue) UnmarshalTolk(cell *boc.Cell, ty Coins, decoder *Decoder) error { + ln, err := cell.ReadLimUint(15) + if err != nil { + return err + } + val, err := cell.ReadBigInt(int(ln) * 8) + if err != nil { + return err + } + *c = CoinsValue(*val) + return nil +} + +func (Coins) MarshalTolk(cell *boc.Cell, v *Value) error { + if v.bigInt == nil { + return fmt.Errorf("BigInt is nil") + } + bi := big.Int(*v.bigInt) + num := bi.Bytes() + err := cell.WriteLimUint(len(num), 15) + if err != nil { + return err + } + err = cell.WriteBytes(num) + if err != nil { + return err + } + + return nil +} + +func (Coins) Equal(v Value, o Value) bool { + return false +} + +type Bool struct{} + +func (Bool) SetValue(v *Value, val any) error { + b, ok := val.(BoolValue) + if !ok { + return fmt.Errorf("value is not a BoolValue") + } + v.bool = &b + v.sumType = "bool" + return nil +} + +func (b Bool) UnmarshalTolk(cell *boc.Cell, v *Value, decoder *Decoder) error { + val, err := cell.ReadBit() + if err != nil { + return err + } + err = b.SetValue(v, BoolValue(val)) + if err != nil { + return err + } + return nil +} + +func (b *BoolValue) UnmarshalTolk(cell *boc.Cell, ty Bool, decoder *Decoder) error { + val, err := cell.ReadBit() + if err != nil { + return err + } + *b = BoolValue(val) + return nil +} + +func (Bool) MarshalTolk(cell *boc.Cell, v *Value) error { + if v.bool == nil { + return fmt.Errorf("bool is nil") + } + + err := cell.WriteBit(bool(*v.bool)) + if err != nil { + return err + } + + return nil +} + +func (Bool) Equal(v Value, o Value) bool { + return false +} diff --git a/tolk/map.go b/tolk/map.go new file mode 100644 index 00000000..702faf9f --- /dev/null +++ b/tolk/map.go @@ -0,0 +1,413 @@ +package tolk + +import ( + "fmt" + + "github.com/tonkeeper/tongo/boc" +) + +type TolkType interface { + UnmarshalTolk(cell *boc.Cell, v *Value, decoder *Decoder) error +} + +type TolkComparableType interface { + GetFixedSize() int +} + +type Map struct { + K Ty `json:"k"` + V Ty `json:"v"` +} + +func (Map) SetValue(v *Value, val any) error { + m, ok := val.(MapValue) + if !ok { + return fmt.Errorf("value is not a map") + } + v.mp = &m + v.sumType = "mp" + return nil +} + +func (m Map) UnmarshalTolk(cell *boc.Cell, v *Value, decoder *Decoder) error { + cmp, ok := m.K.GetComparableType() + if !ok { + return fmt.Errorf("%v is not comparable", m.K.SumType) + } + keySize := cmp.GetFixedSize() + keyPrefix := boc.NewBitString(cmp.GetFixedSize()) + + isNotEmpty, err := cell.ReadBit() + if err != nil { + return err + } + mp := MapValue{ + keys: make([]Value, 0), + values: make([]Value, 0), + } + if isNotEmpty { + mpCell, err := cell.NextRef() + if err != nil { + return err + } + err = mapInner(keySize, keySize, mpCell, &keyPrefix, m.K, m.V, &mp.keys, &mp.values, decoder) + if err != nil { + return err + } + } + + mp.len = len(mp.keys) + err = m.SetValue(v, mp) + if err != nil { + return err + } + + return nil +} + +func (m *MapValue) UnmarshalTolk(cell *boc.Cell, ty Map, decoder *Decoder) error { + cmp, ok := ty.K.GetComparableType() + if !ok { + return fmt.Errorf("%v is not comparable", ty.K.SumType) + } + keySize := cmp.GetFixedSize() + keyPrefix := boc.NewBitString(cmp.GetFixedSize()) + + isNotEmpty, err := cell.ReadBit() + if err != nil { + return err + } + mp := MapValue{ + keys: make([]Value, 0), + values: make([]Value, 0), + } + if isNotEmpty { + mpCell, err := cell.NextRef() + if err != nil { + return err + } + err = mapInner(keySize, keySize, mpCell, &keyPrefix, ty.K, ty.V, &mp.keys, &mp.values, decoder) + if err != nil { + return err + } + } + + m.len = len(mp.keys) + m.keys = mp.keys + m.values = mp.values + + return nil +} + +func mapInner( + keySize, leftKeySize int, + c *boc.Cell, + keyPrefix *boc.BitString, + kt, vt Ty, + keys, values *[]Value, + decoder *Decoder, +) error { + var err error + var size int + if c.CellType() == boc.PrunedBranchCell { + return nil + } + size, keyPrefix, err = loadLabel(leftKeySize, c, keyPrefix) + if err != nil { + return err + } + // until key size is not equals we go deeper + if keyPrefix.BitsAvailableForRead() < keySize { + // 0 bit branch + left, err := c.NextRef() + if err != nil { + return err + } + lp := keyPrefix.Copy() + err = lp.WriteBit(false) + if err != nil { + return err + } + err = mapInner(keySize, leftKeySize-(1+size), left, &lp, kt, vt, keys, values, decoder) + if err != nil { + return err + } + // 1 bit branch + right, err := c.NextRef() + if err != nil { + return err + } + rp := keyPrefix.Copy() + err = rp.WriteBit(true) + if err != nil { + return err + } + err = mapInner(keySize, leftKeySize-(1+size), right, &rp, kt, vt, keys, values, decoder) + if err != nil { + return err + } + return nil + } + // add node to map + v := Value{} + err = v.UnmarshalTolk(c, vt, decoder) + if err != nil { + return err + } + *values = append(*values, v) + + key, err := keyPrefix.ReadBits(keySize) + if err != nil { + return err + } + k := Value{} + cell := boc.NewCellWithBits(key) + err = k.UnmarshalTolk(cell, kt, decoder) + if err != nil { + return err + } + *keys = append(*keys, k) + + return nil +} + +func loadLabel(size int, c *boc.Cell, key *boc.BitString) (int, *boc.BitString, error) { + first, err := c.ReadBit() + if err != nil { + return 0, nil, err + } + // hml_short$0 + if !first { + // Unary, while 1, add to ln + ln, err := c.ReadUnary() + if err != nil { + return 0, nil, err + } + // add bits to key + for i := 0; i < int(ln); i++ { + bit, err := c.ReadBit() + if err != nil { + return 0, nil, err + } + err = key.WriteBit(bit) + if err != nil { + return 0, nil, err + } + } + return int(ln), key, nil + } + second, err := c.ReadBit() + if err != nil { + return 0, nil, err + } + // hml_long$10 + if !second { + ln, err := c.ReadLimUint(size) + if err != nil { + return 0, nil, err + } + for i := 0; i < int(ln); i++ { + bit, err := c.ReadBit() + if err != nil { + return 0, nil, err + } + err = key.WriteBit(bit) + if err != nil { + return 0, nil, err + } + } + return int(ln), key, nil + } + // hml_same$11 + bitType, err := c.ReadBit() + if err != nil { + return 0, nil, err + } + ln, err := c.ReadLimUint(size) + if err != nil { + return 0, nil, err + } + for i := 0; i < int(ln); i++ { + err = key.WriteBit(bitType) + if err != nil { + return 0, nil, err + } + } + return int(ln), key, nil +} + +func (Map) MarshalTolk(cell *boc.Cell, v *Value) error { + return nil +} + +// if v.mp == nil { +// return fmt.Errorf("map is nil") +// } +// +// compKey, ok := v.mp.keyType.GetComparableType() +// if !ok { +// return fmt.Errorf("map key is not a comparable type, got %v", v.mp.keyType.SumType) +// } +// +// if len(v.mp.values) == 0 { +// err := cell.WriteBit(false) +// if err != nil { +// return err +// } +// return nil +// } +// +// err := cell.WriteBit(true) +// if err != nil { +// return err +// } +// +// keys := make([]boc.BitString, 0, len(v.mp.keys)) +// for _, k := range v.mp.keys { +// keyCell := boc.NewCell() +// err = k.valType.MarshalTolk(keyCell, &k) +// if err != nil { +// return err +// } +// keys = append(keys, keyCell.RawBitString()) +// } +// +// ref := boc.NewCell() +// err = encodeMap(ref, keys, v.mp.values, compKey.GetFixedSize(), v.mp.valType) +// if err != nil { +// return err +// } +// +// err = cell.AddRef(ref) +// if err != nil { +// return err +// } +// +// return nil +//} +// +//func encodeMap(c *boc.Cell, keys []boc.BitString, values []Value, keySize int, vt Ty) error { +// if len(keys) == 0 || len(values) == 0 { +// return fmt.Errorf("keys or values are empty") +// } +// label, err := encodeLabel(c, &keys[0], &keys[len(keys)-1], keySize) +// if err != nil { +// return err +// } +// keySize = keySize - label.BitsAvailableForRead() - 1 // l = n - m - 1 // see tlb +// var leftKeys, rightKeys []boc.BitString +// var leftValues, rightValues []Value +// if len(keys) > 1 { +// for i := range keys { +// _, err := keys[i].ReadBits(label.BitsAvailableForRead()) // skip common label +// if err != nil { +// return err +// } +// isRight, err := keys[i].ReadBit() +// if err != nil { +// return err +// } +// if isRight { +// rightKeys = append(rightKeys, keys[i].ReadRemainingBits()) +// rightValues = append(rightValues, values[i]) +// } else { +// leftKeys = append(leftKeys, keys[i].ReadRemainingBits()) +// leftValues = append(leftValues, values[i]) +// } +// } +// l, err := c.NewRef() +// if err != nil { +// return err +// } +// err = encodeMap(l, leftKeys, leftValues, keySize, vt) +// if err != nil { +// return err +// } +// r, err := c.NewRef() +// if err != nil { +// return err +// } +// err = encodeMap(r, rightKeys, rightValues, keySize, vt) +// if err != nil { +// return err +// } +// return err +// } +// // marshal value +// err = vt.MarshalTolk(c, &values[0]) +// if err != nil { +// return err +// } +// return nil +//} +// +//func encodeLabel(c *boc.Cell, keyFirst, keyLast *boc.BitString, keySize int) (boc.BitString, error) { +// label := boc.NewBitString(keySize) +// if keyFirst != keyLast { +// bitLeft, err := keyFirst.ReadBit() +// if err != nil { +// return boc.BitString{}, err +// } +// for keyFirst.BitsAvailableForRead() > 0 { +// bitRight, err := keyLast.ReadBit() +// if err != nil { +// return boc.BitString{}, err +// } +// if bitLeft != bitRight { +// break +// } +// if err := label.WriteBit(bitLeft); err != nil { +// return boc.BitString{}, err +// } +// bitLeft, err = keyFirst.ReadBit() +// if err != nil { +// return boc.BitString{}, err +// } +// } +// } else { +// label = keyFirst.Copy() +// } +// keyFirst.ResetCounter() +// keyLast.ResetCounter() +// if label.BitsAvailableForRead() < 8 { +// //hml_short$0 {m:#} {n:#} len:(Unary ~n) {n <= m} s:(n * Bit) = HmLabel ~n m; +// err := c.WriteBit(false) +// if err != nil { +// return boc.BitString{}, err +// } +// // todo pack label +// err = c.WriteUnary(uint(label.BitsAvailableForRead())) +// if err != nil { +// return boc.BitString{}, err +// } +// err = c.WriteBitString(label) +// if err != nil { +// return boc.BitString{}, err +// } +// +// } else { +// // hml_long$10 {m:#} n:(#<= m) s:(n * Bit) = HmLabel ~n m; +// err := c.WriteBit(true) +// if err != nil { +// return boc.BitString{}, err +// } +// err = c.WriteBit(false) +// if err != nil { +// return boc.BitString{}, err +// } +// // todo pack label +// err = c.WriteLimUint(label.BitsAvailableForRead(), keySize) +// if err != nil { +// return boc.BitString{}, err +// } +// err = c.WriteBitString(label) +// if err != nil { +// return boc.BitString{}, err +// } +// } +// return label, nil +//} + +func (Map) Equal(v Value, o Value) bool { + return false +} diff --git a/tolk/null.go b/tolk/null.go new file mode 100644 index 00000000..4d61bccc --- /dev/null +++ b/tolk/null.go @@ -0,0 +1,51 @@ +package tolk + +import ( + "github.com/tonkeeper/tongo/boc" +) + +type NullLiteral struct{} + +func (NullLiteral) SetValue(v *Value, val any) error { + v.sumType = "nullLiteral" + return nil +} + +func (NullLiteral) UnmarshalTolk(cell *boc.Cell, v *Value, decoder *Decoder) error { + return nil +} + +func (n *NullValue) UnmarshalTolk(cell *boc.Cell, ty NullLiteral, decoder *Decoder) error { + return nil +} + +func (NullLiteral) MarshalTolk(cell *boc.Cell, v *Value) error { + return nil +} + +func (NullLiteral) Equal(v Value, o Value) bool { + return false +} + +type Void struct{} + +func (Void) SetValue(v *Value, val any) error { + v.sumType = "void" + return nil +} + +func (Void) UnmarshalTolk(cell *boc.Cell, v *Value, decoder *Decoder) error { + return nil +} + +func (v *VoidValue) UnmarshalTolk(cell *boc.Cell, ty Void, decoder *Decoder) error { + return nil +} + +func (Void) MarshalTolk(cell *boc.Cell, v *Value) error { + return nil +} + +func (Void) Equal(v Value, o Value) bool { + return false +} diff --git a/tolk/parser/parser.go b/tolk/parser/parser.go new file mode 100644 index 00000000..c417f6ac --- /dev/null +++ b/tolk/parser/parser.go @@ -0,0 +1,655 @@ +package tolkParser + +import ( + "fmt" + "strconv" + "strings" + + "github.com/tonkeeper/tongo/tolk" + "github.com/tonkeeper/tongo/utils" +) + +type DefaultType struct { + Name string + IsRef bool +} + +var ( + defaultKnownTypes = map[string]DefaultType{ + "Int": {"tlb.Int257", false}, + "Coins": {"tlb.VarUInteger16", false}, + "Bool": {"bool", false}, + "Cell": {"tlb.Any", true}, + "Slice": {"tlb.Any", false}, + "Builder": {"tlb.Any", false}, + "Remaining": {"tlb.Any", false}, + "Address": {"tlb.MsgAddress", false}, + "AddressOpt": {"tlb.MsgAddress", false}, + "AddressExt": {"tlb.MsgAddress", false}, + "AddressAny": {"tlb.MsgAddress", false}, + "Void": {"tlb.Void", false}, + } +) + +type DeclrResult struct { + Tag Tag + Name string + Code string +} + +type MsgResult struct { + Code string +} + +type Tag struct { + Len int + Val uint64 +} + +func ParseStructMsg(ty tolk.Ty, msgName, contractName string) (*MsgResult, error) { + var res strings.Builder + res.WriteString("type ") + res.WriteString(msgName) + res.WriteRune(' ') + code, err := createGolangAlias(ty.StructRef.StructName, ty.StructRef.TypeArgs, contractName) + if err != nil { + return nil, err + } + res.WriteString(code) + + return &MsgResult{ + Code: res.String(), + }, nil +} + +func ParseAliasMsg(ty tolk.Ty, msgName, contractName string) (*MsgResult, error) { + var res strings.Builder + res.WriteString("type ") + res.WriteString(msgName) + res.WriteRune(' ') + code, err := createGolangAlias(ty.AliasRef.AliasName, ty.AliasRef.TypeArgs, contractName) + if err != nil { + return nil, err + } + res.WriteString(code) + + return &MsgResult{ + Code: res.String(), + }, nil +} + +func ParseGetMethodCode(ty tolk.Ty, contractName string) (string, error) { + switch ty.SumType { + case "StructRef": + name := utils.ToCamelCase(ty.StructRef.StructName) + return createGolangAlias(name, ty.StructRef.TypeArgs, contractName) + case "AliasRef": + name := utils.ToCamelCase(ty.AliasRef.AliasName) + return createGolangAlias(name, ty.AliasRef.TypeArgs, contractName) + case "Tensor": + var res strings.Builder + res.WriteString("struct {\nField ") + tlbType, _, err := parseTy(ty, contractName) + if err != nil { + return "", err + } + res.WriteString(tlbType) + res.WriteString("`vmStackHint:\"tensor\"`\n}\n") + + return res.String(), nil + case "TupleWith": + var res strings.Builder + res.WriteString("struct {\nField ") + tlbType, _, err := parseTy(ty, contractName) + if err != nil { + return "", err + } + res.WriteString(tlbType) + res.WriteString("\n}\n") + + return res.String(), nil + default: + var res strings.Builder + res.WriteString("struct {\nValue ") + tlbType, tlbTag, err := parseTy(ty, contractName) + if err != nil { + return "", err + } + wrappedType := wrapTlbTypeIntoTlbTag(tlbType, tlbTag) + res.WriteString(wrappedType) + res.WriteString("\n}\n") + + return res.String(), nil + } +} + +func createGolangAlias(aliasType string, typeArgs []tolk.Ty, contractName string) (string, error) { + var res strings.Builder + res.WriteString(" = ") + res.WriteString(contractName + aliasType) + + err := writeGenericTypesPart(&res, typeArgs, contractName) + if err != nil { + return "", err + } + + res.WriteRune('\n') + return res.String(), nil +} + +func ParseTag( + ty tolk.Ty, + structRefs map[string]tolk.StructDeclaration, + aliasRefs map[string]tolk.AliasDeclaration, + enumRefs map[string]tolk.EnumDeclaration, +) (*Tag, error) { + switch ty.SumType { + case "StructRef": + prefix := structRefs[ty.StructRef.StructName].Prefix + if prefix == nil { + return nil, fmt.Errorf("%v tag is nil", ty.StructRef.StructName) + } + convertedTag, err := convertPrefixTagToInt(*prefix) + if err != nil { + return nil, err + } + return convertedTag, nil + case "AliasRef": + aliasRef := aliasRefs[ty.AliasRef.AliasName] + return ParseTag(aliasRef.TargetTy, structRefs, aliasRefs, enumRefs) + case "EnumRef": + enumRef := enumRefs[ty.EnumRef.EnumName] + return ParseTag(enumRef.EncodedAs, structRefs, aliasRefs, enumRefs) + default: + return nil, fmt.Errorf("cannot get tag from %s type", ty.SumType) + } +} + +func ParseStructDeclr(declr tolk.StructDeclaration, contractName string) (*DeclrResult, error) { + result := DeclrResult{} + + unionStructs := make([]string, 0) + var res strings.Builder + if declr.Prefix != nil { + convertedTag, err := convertPrefixTagToInt(*declr.Prefix) + if err != nil { + return nil, err + } + result.Tag = *convertedTag + } + typeName := contractName + utils.ToCamelCase(declr.Name) + res.WriteString("type ") + res.WriteString(typeName) + writeGenericStructPart(&res, declr.TypeParams) + res.WriteString(" struct {\n") + for _, field := range declr.Fields { + tlbField, unionStruct, err := parseField(typeName, field, contractName) + if err != nil { + return nil, err + } + if unionStruct != "" { + unionStructs = append(unionStructs, unionStruct) + } + res.WriteString(tlbField) + res.WriteRune('\n') + } + res.WriteString("}\n\n") + + for _, unionStruct := range unionStructs { + res.WriteString(unionStruct) + res.WriteRune('\n') + } + + result.Code = res.String() + result.Name = typeName + + return &result, nil +} + +func ParseAliasDeclr(declr tolk.AliasDeclaration, contractName string) (*DeclrResult, error) { + result := DeclrResult{} + + typeName := contractName + utils.ToCamelCase(declr.Name) + var res strings.Builder + res.WriteString("type ") + res.WriteString(typeName) + writeGenericStructPart(&res, declr.TypeParams) + res.WriteRune(' ') + tlbType, tlbTag, err := parseTy(declr.TargetTy, contractName) + if err != nil { + return nil, err + } + wrappedType := wrapTlbTypeIntoTlbTag(tlbType, tlbTag) + + res.WriteString(wrappedType) + res.WriteRune('\n') + + if declr.TargetTy.SumType == "Union" { + res.WriteString(generateJSONMarshalForUnion(declr.TargetTy, typeName)) + } + + result.Code = res.String() + result.Name = typeName + + return &result, nil +} + +func ParseEnumDeclr(declr tolk.EnumDeclaration, contractName string) (*DeclrResult, error) { + result := DeclrResult{} + + isBigInt := false + // enum is always an integer + // if number has >64 bits or its varint/varuint then type should be bigInt + switch declr.EncodedAs.SumType { + case "IntN": + if declr.EncodedAs.IntN.N > 64 { + isBigInt = true + } + case "UintN": + if declr.EncodedAs.UintN.N > 64 { + isBigInt = true + } + case "VarIntN", "VarUintN": + isBigInt = true + default: + return nil, fmt.Errorf("enum encode type must be integer, got: %s", declr.EncodedAs.SumType) + } + + var res strings.Builder + enumName := contractName + utils.ToCamelCase(declr.Name) + res.WriteString("type ") + res.WriteString(enumName) + res.WriteString(" = ") + + tlbType, tlbTag, err := parseTy(declr.EncodedAs, contractName) + if err != nil { + return nil, err + } + wrappedType := wrapTlbTypeIntoTlbTag(tlbType, tlbTag) + + res.WriteString(wrappedType) + if isBigInt { + res.WriteString("\n\n var (\n") + } else { + res.WriteString("\n\n const (\n") + } + for _, member := range declr.Members { + res.WriteString(enumName) + res.WriteRune('_') + res.WriteString(utils.ToCamelCase(member.Name)) + res.WriteString(" = ") + res.WriteString(enumName) + res.WriteRune('(') + if isBigInt { + res.WriteString("MustBigInt(\"") + res.WriteString(member.Value) + res.WriteString("\")") + } else { + res.WriteString(member.Value) + } + res.WriteString(")\n") + } + res.WriteString(")\n\n") + + result.Code = res.String() + result.Name = enumName + + return &result, nil +} + +func parseField(structName string, field tolk.Field, contractName string) (string, string, error) { + var res strings.Builder + var unionStruct strings.Builder + name := utils.ToCamelCase(field.Name) + res.WriteString(name) + res.WriteRune(' ') + + if field.IsPayload != nil && *field.IsPayload == true { + res.WriteString("tlb.EitherRef[Payload]") + + return res.String(), "", nil + } + + tlbTypePart, tlbTagPart, err := parseTy(field.Ty, contractName) + if err != nil { + return "", "", err + } + // union and not tlb.Either + if field.Ty.SumType == "Union" && len(field.Ty.Union.Variants) > 2 { + res.WriteString(structName + name) + + unionStruct.WriteString("type ") + unionStruct.WriteString(structName + name) + unionStruct.WriteString(" ") + unionStruct.WriteString(tlbTypePart) + unionStruct.WriteString("\n\n") + + unionStruct.WriteString(generateJSONMarshalForUnion(field.Ty, name)) + } else { + res.WriteString(tlbTypePart) + } + if tlbTagPart != "" { + res.WriteRune(' ') + res.WriteString(fmt.Sprintf("`tlb:\"%v\"`", tlbTagPart)) + } + + return res.String(), unionStruct.String(), nil +} + +func generateJSONMarshalForUnion(union tolk.Ty, structName string) string { + if len(union.Union.Variants) == 2 { // tlb.Either + return "" + } + var res strings.Builder + res.WriteString(fmt.Sprintf("func (t *%v) MarshalJSON() ([]byte, error) {\n", structName)) + res.WriteString(" switch t.SumType {") + for i := range union.Union.Variants { + name := fmt.Sprintf("UnionVariant%v", i) + res.WriteString(fmt.Sprintf(`case "%v": `, name)) + res.WriteString(fmt.Sprintf(`bytes, err := json.Marshal(t.%v)`, name)) + res.WriteString("\nif err != nil {\n") + res.WriteString("\treturn nil, err\n") + res.WriteString("}\n") + res.WriteString("return []byte(fmt.Sprintf(`{\"SumType\": \"" + name + "\",\"" + name + "\":%v}`, string(bytes))), nil\n") + } + res.WriteString("default: ") + res.WriteString(`return nil, fmt.Errorf("unknown sum type %v", t.SumType)`) + res.WriteString("}\n") + res.WriteString("}\n") + return res.String() +} + +func ParseType(ty tolk.Ty, contractName string) (string, error) { + tlbType, tlbTag, err := parseTy(ty, contractName) + if err != nil { + return "", err + } + + return wrapTlbTypeIntoTlbTag(tlbType, tlbTag), nil +} + +// todo: избавится от огромного switch case +func parseTy(ty tolk.Ty, contractName string) (string, string, error) { + var tlbType strings.Builder + var tlbTag strings.Builder + defaultType, ok := defaultKnownTypes[ty.SumType] + if ok { + if defaultType.IsRef { + tlbTag.WriteRune('^') + } + tlbType.WriteString(defaultType.Name) + return tlbType.String(), tlbTag.String(), nil + } + + switch ty.SumType { + case "IntN": + n := ty.IntN.N + tlbIntType := fmt.Sprintf("tlb.Int%v", n) + if n == 8 { + tlbIntType = "int8" + } else if n == 16 { + tlbIntType = "int16" + } else if n == 32 { + tlbIntType = "int32" + } else if n == 64 { + tlbIntType = "int64" + } + tlbType.WriteString(tlbIntType) + case "UintN": + n := ty.UintN.N + tlbUIntType := fmt.Sprintf("tlb.Uint%v", n) + if n == 8 { + tlbUIntType = "uint8" + } else if n == 16 { + tlbUIntType = "uint16" + } else if n == 32 { + tlbUIntType = "uint32" + } else if n == 64 { + tlbUIntType = "uint64" + } + tlbType.WriteString(tlbUIntType) + case "VarIntN": + tlbVarUIntType := fmt.Sprintf("tlb.VarUInteger%v", ty.VarIntN.N) + tlbType.WriteString(tlbVarUIntType) + case "VarUintN": + tlbVarUIntType := fmt.Sprintf("tlb.VarUInteger%v", ty.VarUintN.N) + tlbType.WriteString(tlbVarUIntType) + case "BitsN": + tlbVarUIntType := fmt.Sprintf("tlb.Bits%v", ty.BitsN.N) + tlbType.WriteString(tlbVarUIntType) + case "Nullable": + tlbMaybeType, tlbMaybeTag, err := parseTy(ty.Nullable.Inner, contractName) + if err != nil { + return "", "", err + } + + tlbTag.WriteString("maybe") + tlbTag.WriteString(tlbMaybeTag) + + tlbType.WriteRune('*') + tlbType.WriteString(tlbMaybeType) + tlbType.WriteRune(' ') + case "CellOf": + tlbRefType, tlbRefTag, err := parseTy(ty.CellOf.Inner, contractName) + if err != nil { + return "", "", err + } + tlbTag.WriteRune('^') + tlbTag.WriteString(tlbRefTag) + + tlbType.WriteString(tlbRefType) + tlbType.WriteRune(' ') + case "Tensor": + tlbType.WriteString("struct{\n") + for i, innerTy := range ty.Tensor.Items { + innerTlbType, innerTlbTag, err := parseTy(innerTy, contractName) + if err != nil { + return "", "", err + } + + wrappedType := wrapTlbTypeIntoTlbTag(innerTlbType, innerTlbTag) + + tlbType.WriteString("Field") + tlbType.WriteString(strconv.Itoa(i)) + tlbType.WriteRune(' ') + tlbType.WriteString(wrappedType) + tlbType.WriteRune('\n') + } + tlbType.WriteRune('}') + case "TupleWith": + tlbType.WriteString("struct{\n") + for i, innerTy := range ty.TupleWith.Items { + innerTlbType, innerTlbTag, err := parseTy(innerTy, contractName) + if err != nil { + return "", "", err + } + + wrappedType := wrapTlbTypeIntoTlbTag(innerTlbType, innerTlbTag) + + tlbType.WriteString("Field") + tlbType.WriteString(strconv.Itoa(i)) + tlbType.WriteRune(' ') + tlbType.WriteString(wrappedType) + tlbType.WriteRune('\n') + } + tlbType.WriteRune('}') + case "Map": + tlbType.WriteString("tlb.HashmapE[") + fixedType, err := getFixedSizeTypeForMap(ty.Map.K) + if err != nil { + return "", "", err + } + valueType, valueTypeTag, err := parseTy(ty.Map.V, contractName) + wrappedType := wrapTlbTypeIntoTlbTag(valueType, valueTypeTag) + + tlbType.WriteString(fixedType) + tlbType.WriteRune(',') + tlbType.WriteString(wrappedType) + tlbType.WriteRune(']') + case "EnumRef": + name := contractName + utils.ToCamelCase(ty.EnumRef.EnumName) + tlbType.WriteString(name) + case "StructRef": + name := contractName + utils.ToCamelCase(ty.StructRef.StructName) + tlbType.WriteString(name) + err := writeGenericTypesPart(&tlbType, ty.StructRef.TypeArgs, contractName) + if err != nil { + return "", "", err + } + case "AliasRef": + name := contractName + utils.ToCamelCase(ty.AliasRef.AliasName) + tlbType.WriteString(name) + err := writeGenericTypesPart(&tlbType, ty.AliasRef.TypeArgs, contractName) + if err != nil { + return "", "", err + } + case "Generic": + name := ty.Generic.NameT + tlbType.WriteString(utils.ToCamelCase(name)) + case "Union": + if len(ty.Union.Variants) == 2 && ty.Union.Variants[0].PrefixStr == "0" { + tlbType.WriteString("tlb.Either[") + + for _, variant := range ty.Union.Variants { + tlbTypeArg, tlbTagArg, err := parseTy(variant.VariantTy, contractName) + if err != nil { + return "", "", err + } + wrappedType := wrapTlbTypeIntoTlbTag(tlbTypeArg, tlbTagArg) + tlbType.WriteString(wrappedType) + + tlbType.WriteRune(',') + } + + tlbType.WriteRune(']') + } else { + tlbType.WriteString("struct{\ntlb.SumType\n") + for i, variant := range ty.Union.Variants { + sumTypeSymbol := "$" + if strings.HasPrefix(variant.PrefixStr, "0x") { + sumTypeSymbol = "#" + } + + tlbType.WriteString(fmt.Sprintf("UnionVariant%v ", i)) + + tlbTypeArg, tlbTagArg, err := parseTy(variant.VariantTy, contractName) + if err != nil { + return "", "", err + } + tlbType.WriteString(tlbTypeArg) + + tlbType.WriteString(fmt.Sprintf(" `tlbSumType:\"%v%v\"`\n", sumTypeSymbol, variant.PrefixStr[2:])) + tlbTag.WriteString(tlbTagArg) + } + tlbType.WriteRune('}') + } + case "NullLiteral": + tlbType.WriteString("tlb.NullLiteral") + case "TupleAny", "Callable": + return "", "", fmt.Errorf("cannot convert type %v", ty.SumType) + default: + return "", "", fmt.Errorf("unknown ty type %q", ty.SumType) + } + + return tlbType.String(), tlbTag.String(), nil +} + +func getFixedSizeTypeForMap(ty tolk.Ty) (string, error) { + switch ty.SumType { + case "IntN": + n := ty.IntN.N + tlbIntType := fmt.Sprintf("tlb.Int%v", n) + return tlbIntType, nil + case "UintN": + n := ty.UintN.N + tlbIntType := fmt.Sprintf("tlb.Uint%v", n) + return tlbIntType, nil + case "VarIntN": + tlbVarUIntType := fmt.Sprintf("tlb.VarUInteger%v", ty.VarIntN.N) + return tlbVarUIntType, nil + case "VarUintN": + tlbVarUIntType := fmt.Sprintf("tlb.VarUInteger%v", ty.VarUintN.N) + return tlbVarUIntType, nil + case "BitsN": + tlbVarUIntType := fmt.Sprintf("tlb.Bits%v", ty.BitsN.N) + return tlbVarUIntType, nil + case "Bool": + return "tlb.Uint1", nil + case "Address", "AddressOpt", "AddressExt", "AddressAny": + return "tlb.InternalAddress", nil + default: + return "", fmt.Errorf("%v not supported as map key", ty.SumType) + } +} + +func wrapTlbTypeIntoTlbTag(tlbTypeArg, tlbTagArg string) string { + var tlbType strings.Builder + cnt := 0 + i := 0 + for i < len(tlbTagArg) { + if tlbTagArg[i] == 'm' { // maybe + i += 5 + tlbType.WriteString("tlb.Maybe[") + } else if tlbTagArg[i] == '^' { // ref + i += 1 + tlbType.WriteString("tlb.Ref[") + } else { + panic(fmt.Sprintf("unknown tag start %v in %v", tlbTagArg[i], tlbTagArg)) + } + + cnt += 1 + } + if tlbTypeArg[0] == '*' { // remove pointer since it wrapping into type + tlbTypeArg = tlbTypeArg[1:] + } + tlbType.WriteString(tlbTypeArg) + tlbType.WriteString(strings.Repeat("]", cnt)) + + return tlbType.String() +} + +func convertPrefixTagToInt(tag tolk.Prefix) (*Tag, error) { + if tag.PrefixLen == 0 { + return nil, fmt.Errorf("prefix tag len must be > 0") + } + + val, err := tolk.PrefixToUint(tag.PrefixStr) + if err != nil { + return nil, err + } + + return &Tag{ + Len: tag.PrefixLen, + Val: val, + }, nil +} + +func writeGenericStructPart(builder *strings.Builder, typeParams []string) { + if len(typeParams) > 0 { + builder.WriteRune('[') + for _, param := range typeParams { + builder.WriteString(utils.ToCamelCase(param)) + builder.WriteString(" any,") + } + builder.WriteRune(']') + } +} + +func writeGenericTypesPart(builder *strings.Builder, typeArgs []tolk.Ty, contractName string) error { + if len(typeArgs) > 0 { + builder.WriteRune('[') + for _, typeArg := range typeArgs { + tlbType, tlbTag, err := parseTy(typeArg, contractName) + if err != nil { + return err + } + + wrappedType := wrapTlbTypeIntoTlbTag(tlbType, tlbTag) + builder.WriteString(wrappedType) + builder.WriteRune(',') + } + builder.WriteRune(']') + } + + return nil +} diff --git a/tolk/refs.go b/tolk/refs.go new file mode 100644 index 00000000..103687de --- /dev/null +++ b/tolk/refs.go @@ -0,0 +1,529 @@ +package tolk + +import ( + "fmt" + "math/big" + + "github.com/tonkeeper/tongo/boc" + "golang.org/x/exp/maps" +) + +type EnumRef struct { + EnumName string `json:"enumName"` +} + +func (EnumRef) SetValue(v *Value, val any) error { + e, ok := val.(EnumValue) + if !ok { + return fmt.Errorf("value is not an enum value") + } + v.enum = &e + v.sumType = "enum" + return nil +} + +func (e EnumRef) UnmarshalTolk(cell *boc.Cell, v *Value, decoder *Decoder) error { + if decoder.abiRefs.enumRefs == nil { + return fmt.Errorf("struct has enum reference, but no abi has been given") + } + enum, found := decoder.abiRefs.enumRefs[e.EnumName] + if !found { + return fmt.Errorf("no enum with name %s was found in given abi", e.EnumName) + } + + enumVal := Value{} + err := enumVal.UnmarshalTolk(cell, enum.EncodedAs, decoder) + if err != nil { + return err + } + var bigEnumVal big.Int + switch enum.EncodedAs.SumType { + case "IntN": + if enum.EncodedAs.IntN.N > 64 { + bigEnumVal = big.Int(*enumVal.bigInt) + } else { + bigEnumVal = *big.NewInt(int64(*enumVal.smallInt)) + } + case "UintN": + if enum.EncodedAs.UintN.N > 64 { + bigEnumVal = big.Int(*enumVal.bigInt) + } else { + bigEnumVal = *new(big.Int).SetUint64(uint64(*enumVal.smallUint)) + } + case "VarIntN", "VarUintN": + bigEnumVal = big.Int(*enumVal.bigInt) + default: + return fmt.Errorf("enum encode type must be integer, got: %s", enum.EncodedAs.SumType) + } + + for _, member := range enum.Members { + val, ok := new(big.Int).SetString(member.Value, 10) + if !ok { + return fmt.Errorf("invalid enum %v value %v for member %s", e.EnumName, member.Value, member.Name) + } + + if val.Cmp(&bigEnumVal) == 0 { + err = e.SetValue(v, EnumValue{ + val: enumVal, + Name: member.Name, + Value: *val, + }) + if err != nil { + return err + } + + return nil + } + } + // todo: maybe return err? + err = e.SetValue(v, EnumValue{ + val: enumVal, + Name: "Unknown", + Value: bigEnumVal, + }) + if err != nil { + return err + } + + return nil +} + +func (e *EnumValue) UnmarshalTolk(cell *boc.Cell, ty EnumRef, decoder *Decoder) error { + if decoder.abiRefs.enumRefs == nil { + return fmt.Errorf("struct has enum reference, but no abi has been given") + } + enum, found := decoder.abiRefs.enumRefs[ty.EnumName] + if !found { + return fmt.Errorf("no enum with name %s was found in given abi", ty.EnumName) + } + + enumVal := Value{} + err := enumVal.UnmarshalTolk(cell, enum.EncodedAs, decoder) + if err != nil { + return err + } + var bigEnumVal big.Int + switch enum.EncodedAs.SumType { + case "IntN": + if enum.EncodedAs.IntN.N > 64 { + bigEnumVal = big.Int(*enumVal.bigInt) + } else { + bigEnumVal = *big.NewInt(int64(*enumVal.smallInt)) + } + case "UintN": + if enum.EncodedAs.UintN.N > 64 { + bigEnumVal = big.Int(*enumVal.bigInt) + } else { + bigEnumVal = *new(big.Int).SetUint64(uint64(*enumVal.smallUint)) + } + case "VarIntN": + bigEnumVal = big.Int(*enumVal.varInt) + case "VarUintN": + bigEnumVal = big.Int(*enumVal.varUint) + default: + return fmt.Errorf("enum encode type must be integer, got: %s", enum.EncodedAs.SumType) + } + + for _, member := range enum.Members { + val, ok := new(big.Int).SetString(member.Value, 10) + if !ok { + return fmt.Errorf("invalid enum %v value %v for member %s", ty.EnumName, member.Value, member.Name) + } + + if val.Cmp(&bigEnumVal) == 0 { + *e = EnumValue{ + val: enumVal, + Name: member.Name, + Value: *val, + } + + return nil + } + } + // todo: maybe return err? + *e = EnumValue{ + val: enumVal, + Name: "Unknown", + Value: bigEnumVal, + } + + return nil +} + +func (EnumRef) MarshalTolk(cell *boc.Cell, v *Value) error { + //if v.enum == nil { + // return fmt.Errorf("enum is nil") + //} + // + //valType := v.enum.enumType + //if valType.SumType != "IntN" && valType.SumType != "UintN" && valType.SumType != "VarIntN" && valType.SumType != "VarUintN" { + // return fmt.Errorf("enum type must be interger, got: %s", valType.SumType) + //} + //err := valType.MarshalTolk(cell, &v.enum.val) + //if err != nil { + // return err + //} + + return nil +} + +func (EnumRef) Equal(v Value, o Value) bool { + return false +} + +type StructRef struct { + StructName string `json:"structName"` + TypeArgs []Ty `json:"typeArgs,omitempty"` +} + +func (StructRef) SetValue(v *Value, val any) error { + s, ok := val.(Struct) + if !ok { + return fmt.Errorf("value is not a struct") + } + v.structValue = &s + v.sumType = "structValue" + return nil +} + +func (s StructRef) UnmarshalTolk(cell *boc.Cell, v *Value, decoder *Decoder) error { + if decoder.abiRefs.structRefs == nil { + return fmt.Errorf("struct has struct reference, but no abi has been given") + } + strct, found := decoder.abiRefs.structRefs[s.StructName] + if !found { + return fmt.Errorf("no struct with name %s was found in given abi", s.StructName) + } + tolkStruct := Struct{ + field: make(map[string]Value), + } + if strct.Prefix != nil { + prefixLen := strct.Prefix.PrefixLen + if prefixLen > 64 { + return fmt.Errorf("struct %v prefix length must be lower than 64", strct.Name) + } + + prefix, err := cell.ReadUint(prefixLen) + if err != nil { + return err + } + actualPrefix, err := binHexToUint64(strct.Prefix.PrefixStr) + if err != nil { + return err + } + + if prefix != actualPrefix { + return fmt.Errorf("struct %v prefix does not match actual prefix %v", strct.Name, actualPrefix) + } + tolkStruct.hasPrefix = true + tolkStruct.prefix = TolkPrefix{ + Len: int16(prefixLen), + Prefix: prefix, + } + } + + oldGenericMap := decoder.abiRefs.genericRefs + genericMap, err := resolveGeneric(s.TypeArgs, strct.TypeParams, decoder) + if err != nil { + return err + } + decoder.abiRefs.genericRefs = genericMap + + for _, field := range strct.Fields { + fieldVal := Value{} + err = fieldVal.UnmarshalTolk(cell, field.Ty, decoder) + if err != nil { + return err + } + + if field.Ty.SumType == "Nullable" { + optVal := *fieldVal.optionalValue + defVal := field.DefaultValue + if !optVal.IsExists && defVal != nil { + val := Value{} + exists, err := defVal.unmarshalDefaultValue(&val, field.Ty) + if err != nil { + return err + } + if exists { + optVal.IsExists = true + optVal.Val = val + } + } + } + + tolkStruct.field[field.Name] = fieldVal + } + decoder.abiRefs.genericRefs = oldGenericMap + + err = s.SetValue(v, tolkStruct) + if err != nil { + return err + } + + return nil +} + +func (s *Struct) UnmarshalTolk(cell *boc.Cell, ty StructRef, decoder *Decoder) error { + if decoder.abiRefs.structRefs == nil { + return fmt.Errorf("struct has struct reference, but no abi has been given") + } + strct, found := decoder.abiRefs.structRefs[ty.StructName] + if !found { + return fmt.Errorf("no struct with name %s was found in given abi", ty.StructName) + } + tolkStruct := Struct{ + field: make(map[string]Value), + } + if strct.Prefix != nil { + prefixLen := strct.Prefix.PrefixLen + if prefixLen > 64 { + return fmt.Errorf("struct %v prefix length must be lower than 64", strct.Name) + } + + prefix, err := cell.ReadUint(prefixLen) + if err != nil { + return err + } + actualPrefix, err := binHexToUint64(strct.Prefix.PrefixStr) + if err != nil { + return err + } + + if prefix != actualPrefix { + return fmt.Errorf("struct %v prefix does not match actual prefix %v", strct.Name, actualPrefix) + } + tolkStruct.hasPrefix = true + tolkStruct.prefix = TolkPrefix{ + Len: int16(prefixLen), + Prefix: prefix, + } + } + + oldGenericMap := decoder.abiRefs.genericRefs + genericMap, err := resolveGeneric(ty.TypeArgs, strct.TypeParams, decoder) + if err != nil { + return err + } + decoder.abiRefs.genericRefs = genericMap + + for _, field := range strct.Fields { + fieldVal := Value{} + err = fieldVal.UnmarshalTolk(cell, field.Ty, decoder) + if err != nil { + return err + } + + if field.Ty.SumType == "Nullable" { + optVal := *fieldVal.optionalValue + defVal := field.DefaultValue + if !optVal.IsExists && defVal != nil { + val := Value{} + exists, err := defVal.unmarshalDefaultValue(&val, field.Ty) + if err != nil { + return err + } + if exists { + optVal.IsExists = true + optVal.Val = val + } + } + } + + tolkStruct.field[field.Name] = fieldVal + } + + decoder.abiRefs.genericRefs = oldGenericMap + *s = tolkStruct + + return nil +} + +func (StructRef) MarshalTolk(cell *boc.Cell, v *Value) error { + //if v.structValue == nil { + // return fmt.Errorf("struct is nil") + //} + // + //if v.structValue.hasPrefix { + // err := cell.WriteUint(v.structValue.prefix.Prefix, int(v.structValue.prefix.Len)) + // if err != nil { + // return err + // } + //} + // + //for _, f := range v.structValue.field { + // err := f.valType.MarshalTolk(cell, &f) + // if err != nil { + // return err + // } + //} + + return nil +} + +func (StructRef) Equal(v Value, o Value) bool { + return false +} + +type AliasRef struct { + AliasName string `json:"aliasName"` + TypeArgs []Ty `json:"typeArgs,omitempty"` +} + +func (AliasRef) SetValue(v *Value, val any) error { + return fmt.Errorf("alias cannot be a value") +} + +func (a AliasRef) UnmarshalTolk(cell *boc.Cell, v *Value, decoder *Decoder) error { + if decoder.abiRefs.aliasRefs == nil { + return fmt.Errorf("struct has alias reference, but no abi has been given") + } + alias, found := decoder.abiRefs.aliasRefs[a.AliasName] + if !found { + return fmt.Errorf("no alias with name %s was found in given abi", a.AliasName) + } + + if alias.CustomUnpackFromSlice { + // todo: maybe simply return error? + fmt.Println("WARNING! alias has custom unpack method. Standard unpacking can be incorrect!") + } + + oldGenericMap := decoder.abiRefs.genericRefs + genericMap, err := resolveGeneric(a.TypeArgs, alias.TypeParams, decoder) + if err != nil { + return err + } + decoder.abiRefs.genericRefs = genericMap + + val := Value{} + err = val.UnmarshalTolk(cell, alias.TargetTy, decoder) + if err != nil { + return err + } + decoder.abiRefs.genericRefs = oldGenericMap + + fmt.Println(123) + err = a.SetValue(v, val) + if err != nil { + return err + } + + return nil +} + +func (a *AliasValue) UnmarshalTolk(cell *boc.Cell, ty AliasRef, decoder *Decoder) error { + if decoder.abiRefs.aliasRefs == nil { + return fmt.Errorf("struct has alias reference, but no abi has been given") + } + alias, found := decoder.abiRefs.aliasRefs[ty.AliasName] + if !found { + return fmt.Errorf("no alias with name %s was found in given abi", ty.AliasName) + } + + if alias.CustomUnpackFromSlice { + // todo: maybe simply return error? + fmt.Println("WARNING! alias has custom unpack method. Standard unpacking can be incorrect!") + } + + oldGenericMap := decoder.abiRefs.genericRefs + genericMap, err := resolveGeneric(ty.TypeArgs, alias.TypeParams, decoder) + if err != nil { + return err + } + decoder.abiRefs.genericRefs = genericMap + + val := Value{} + err = val.UnmarshalTolk(cell, alias.TargetTy, decoder) + if err != nil { + return err + } + + decoder.abiRefs.genericRefs = oldGenericMap + *a = AliasValue(val) + + return nil +} + +func (AliasRef) MarshalTolk(cell *boc.Cell, v *Value) error { + return fmt.Errorf("alias ref cannot be a value") +} + +func (AliasRef) Equal(v Value, o Value) bool { + return false +} + +type Generic struct { + NameT string `json:"nameT"` +} + +func (Generic) SetValue(v *Value, val any) error { + return fmt.Errorf("generic cannot be a value") +} + +func (g Generic) UnmarshalTolk(cell *boc.Cell, v *Value, decoder *Decoder) error { + currentTy, found := decoder.abiRefs.genericRefs[g.NameT] + if !found { + return fmt.Errorf("cannot resolve generic type %v ", g) + } + val := Value{} + err := val.UnmarshalTolk(cell, currentTy, decoder) + if err != nil { + return err + } + + err = g.SetValue(v, val) + if err != nil { + return err + } + + return nil +} + +func (g *GenericValue) UnmarshalTolk(cell *boc.Cell, ty Generic, decoder *Decoder) error { + currentTy, found := decoder.abiRefs.genericRefs[ty.NameT] + if !found { + return fmt.Errorf("cannot resolve generic type %v ", ty.NameT) + } + val := Value{} + err := val.UnmarshalTolk(cell, currentTy, decoder) + if err != nil { + return err + } + + *g = GenericValue(val) + + return nil +} + +func (Generic) MarshalTolk(cell *boc.Cell, v *Value) error { + return fmt.Errorf("generic cannot be a value") +} + +func (Generic) Equal(v Value, o Value) bool { + return false +} + +func resolveGeneric(typeArgs []Ty, typeParams []string, d *Decoder) (map[string]Ty, error) { + genericMap := make(map[string]Ty) + if d.abiRefs.genericRefs != nil { + maps.Copy(genericMap, d.abiRefs.genericRefs) + } + + for i, genericTy := range typeArgs { + genericMap[typeParams[i]] = genericTy + + if genericTy.SumType == "Generic" { + if d.abiRefs.genericRefs == nil { + return nil, fmt.Errorf("cannot resolve generic type %v", genericTy.Generic.NameT) + } + + ty, found := d.abiRefs.genericRefs[genericTy.Generic.NameT] + if !found { + return nil, fmt.Errorf("generic type %v not found", genericTy.Generic.NameT) + } + genericMap[typeParams[i]] = ty + } + } + + return genericMap, nil +} diff --git a/tolk/runtime.go b/tolk/runtime.go new file mode 100644 index 00000000..b567914b --- /dev/null +++ b/tolk/runtime.go @@ -0,0 +1,63 @@ +package tolk + +import ( + "github.com/tonkeeper/tongo/boc" +) + +type TolkUnmarshaler interface { + UnmarshalTolk(cell *boc.Cell, v *Value, d *Decoder) error +} + +type abiRefs struct { + structRefs map[string]StructDeclaration + aliasRefs map[string]AliasDeclaration + enumRefs map[string]EnumDeclaration + genericRefs map[string]Ty +} + +type Decoder struct { + abiRefs abiRefs +} + +func NewDecoder() *Decoder { + return &Decoder{} +} + +func (a *Decoder) WithABI(abi ABI) *Decoder { + a.abiRefs = abiRefs{ + structRefs: make(map[string]StructDeclaration), + aliasRefs: make(map[string]AliasDeclaration), + enumRefs: make(map[string]EnumDeclaration), + genericRefs: make(map[string]Ty), + } + for _, declr := range abi.Declarations { + switch declr.SumType { + case "Struct": + a.abiRefs.structRefs[declr.StructDeclaration.Name] = declr.StructDeclaration + case "Alias": + a.abiRefs.aliasRefs[declr.AliasDeclaration.Name] = declr.AliasDeclaration + case "Enum": + a.abiRefs.enumRefs[declr.EnumDeclaration.Name] = declr.EnumDeclaration + } + } + return a +} + +func UnmarshalTolk(cell *boc.Cell, ty Ty) (*Value, error) { + a := NewDecoder() + return a.UnmarshalTolk(cell, ty) +} + +func (a *Decoder) UnmarshalTolk(cell *boc.Cell, ty Ty) (*Value, error) { + res := &Value{} + err := res.UnmarshalTolk(cell, ty, a) + if err != nil { + return nil, err + } + return res, nil +} + +func MarshalTolk(c *boc.Cell, v *Value) error { + return nil + //return v.valType.MarshalTolk(c, v) +} diff --git a/tolk/runtime_test.go b/tolk/runtime_test.go new file mode 100644 index 00000000..318172da --- /dev/null +++ b/tolk/runtime_test.go @@ -0,0 +1,4599 @@ +package tolk + +import ( + "bytes" + "encoding/json" + "fmt" + "math/big" + "os" + "testing" + + "github.com/tonkeeper/tongo" + "github.com/tonkeeper/tongo/boc" + "github.com/tonkeeper/tongo/ton" +) + +func TestRuntime_UnmarshalSmallInt(t *testing.T) { + ty := Ty{ + SumType: "IntN", + IntN: &IntN{ + N: 24, + }, + } + + currCell, err := boc.DeserializeBocHex("b5ee9c72410101010005000006ff76c41616db06") + if err != nil { + t.Fatal(err) + } + v, err := UnmarshalTolk(currCell[0], ty) + if err != nil { + t.Fatal(err) + } + + val, ok := v.GetSmallInt() + if !ok { + t.Errorf("v.GetSmallInt() not successeded") + } + if val != -35132 { + t.Errorf("val != -35132, got %v", val) + } +} + +func TestRuntime_UnmarshalBigInt(t *testing.T) { + ty := Ty{ + SumType: "IntN", + IntN: &IntN{ + N: 183, + }, + } + + currCell, err := boc.DeserializeBocHex("b5ee9c7241010101001900002dfffffffffffffffffffffffffffffffffff99bfeac6423a6f0b50c") + if err != nil { + t.Fatal(err) + } + v, err := UnmarshalTolk(currCell[0], ty) + if err != nil { + t.Fatal(err) + } + + val, ok := v.GetBigInt() + if !ok { + t.Errorf("v.GetBigInt() not successeded") + } + if val.Cmp(big.NewInt(-3513294376431)) != 0 { + t.Errorf("val != -3513294376431, got %v", val) + } +} + +func TestRuntime_UnmarshalSmallUInt(t *testing.T) { + ty := Ty{ + SumType: "UintN", + UintN: &UintN{ + N: 53, + }, + } + + currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000900000d00000000001d34e435eafd") + if err != nil { + t.Fatal(err) + } + v, err := UnmarshalTolk(currCell[0], ty) + if err != nil { + t.Fatal(err) + } + + val, ok := v.GetSmallUInt() + if !ok { + t.Errorf("v.GetSmallUInt() not successeded") + } + if val != 934 { + t.Errorf("val != 934, got %v", val) + } +} + +func TestRuntime_UnmarshalBigUInt(t *testing.T) { + ty := Ty{ + SumType: "UintN", + UintN: &UintN{ + N: 257, + }, + } + + currCell, err := boc.DeserializeBocHex("b5ee9c7241010101002300004100000000000000000000000000000000000000000000000000009fc4212a38ba40b11cce12") + if err != nil { + t.Fatal(err) + } + v, err := UnmarshalTolk(currCell[0], ty) + if err != nil { + t.Fatal(err) + } + + val, ok := v.GetBigUInt() + if !ok { + t.Errorf("v.GetBigUInt() not successeded") + } + if val.Cmp(big.NewInt(351329437643124)) != 0 { + t.Errorf("val != 351329437643124, got %v", val.String()) + } +} + +func TestRuntime_UnmarshalVarInt(t *testing.T) { + ty := Ty{ + SumType: "VarIntN", + VarIntN: &VarIntN{ + N: 16, + }, + } + + currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000600000730c98588449b6923") + if err != nil { + t.Fatal(err) + } + v, err := UnmarshalTolk(currCell[0], ty) + if err != nil { + t.Fatal(err) + } + + val, ok := v.GetVarInt() + if !ok { + t.Errorf("v.GetVarInt() not successeded") + } + if val.Cmp(big.NewInt(825432)) != 0 { + t.Errorf("val != 825432, got %v", val.String()) + } +} + +func TestRuntime_UnmarshalVarUInt(t *testing.T) { + ty := Ty{ + SumType: "VarUintN", + VarUintN: &VarUintN{ + N: 32, + }, + } + + currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000800000b28119ab36b44d3a86c0f") + if err != nil { + t.Fatal(err) + } + v, err := UnmarshalTolk(currCell[0], ty) + if err != nil { + t.Fatal(err) + } + + val, ok := v.GetVarUInt() + if !ok { + t.Errorf("v.GetVarUInt() not successeded") + } + if val.Cmp(big.NewInt(9451236712)) != 0 { + t.Errorf("val != 9451236712, got %v", val.String()) + } +} + +func TestRuntime_UnmarshalBits(t *testing.T) { + ty := Ty{ + SumType: "BitsN", + BitsN: &BitsN{ + N: 24, + }, + } + + currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000500000631323318854035") + if err != nil { + t.Fatal(err) + } + v, err := UnmarshalTolk(currCell[0], ty) + if err != nil { + t.Fatal(err) + } + + val, ok := v.GetBits() + if !ok { + t.Errorf("v.GetBits() not successeded") + } + if bytes.Equal(val.Buffer(), []byte{55, 56, 57}) { + t.Errorf("val != {55, 56, 57}, got %v", val) + } +} + +func TestRuntime_UnmarshalCoins(t *testing.T) { + ty := Ty{ + SumType: "Coins", + Coins: &Coins{}, + } + + currCell, err := boc.DeserializeBocHex("b5ee9c72410101010007000009436ec6e0189ebbd7f4") + if err != nil { + t.Fatal(err) + } + v, err := UnmarshalTolk(currCell[0], ty) + if err != nil { + t.Fatal(err) + } + + val, ok := v.GetCoins() + if !ok { + t.Errorf("v.GetCoins() not successeded") + } + if val.Cmp(big.NewInt(921464321)) != 0 { + t.Errorf("val != 921464321, got %v", val) + } +} + +func TestRuntime_UnmarshalBool(t *testing.T) { + ty := Ty{ + SumType: "Bool", + Bool: &Bool{}, + } + + currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000300000140f6d24034") + if err != nil { + t.Fatal(err) + } + v, err := UnmarshalTolk(currCell[0], ty) + if err != nil { + t.Fatal(err) + } + + val, ok := v.GetBool() + if !ok { + t.Errorf("v.GetBool() not successeded") + } + if val { + t.Error("val is true") + } +} + +func TestRuntime_UnmarshalCell(t *testing.T) { + ty := Ty{ + SumType: "Cell", + Cell: &Cell{}, + } + + currCell, err := boc.DeserializeBocHex("b5ee9c724101020100090001000100080000007ba52a3292") + if err != nil { + t.Fatal(err) + } + v, err := UnmarshalTolk(currCell[0], ty) + if err != nil { + t.Fatal(err) + } + + val, ok := v.GetCell() + if !ok { + t.Errorf("v.GetCell() not successeded") + } + hs, err := val.HashString() + if err != nil { + t.Fatal(err) + } + if hs != "644e68a539c5107401d194bc82169cbf0ad1635796891551e0750705ab2d74ae" { + t.Errorf("val.Hash() != 644e68a539c5107401d194bc82169cbf0ad1635796891551e0750705ab2d74ae, got %v", hs) + } +} + +func TestRuntime_UnmarshalRemaining(t *testing.T) { + ty := Ty{ + SumType: "Remaining", + Remaining: &Remaining{}, + } + + currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000900000dc0800000000ab8d04726e4") + if err != nil { + t.Fatal(err) + } + v, err := UnmarshalTolk(currCell[0], ty) + if err != nil { + t.Fatal(err) + } + + val, ok := v.GetRemaining() + if !ok { + t.Errorf("v.GetCell() not successeded") + } + hs, err := val.HashString() + if err != nil { + t.Fatal(err) + } + if hs != "f1c4e07fbd1786411c2caa9ac9f5d7240aa2007a2a1d5e5ac44f8a168cd4e36b" { + t.Errorf("val.Hash() != f1c4e07fbd1786411c2caa9ac9f5d7240aa2007a2a1d5e5ac44f8a168cd4e36b, got %v", hs) + } +} + +func TestRuntime_UnmarshalAddress(t *testing.T) { + ty := Ty{ + SumType: "Address", + Address: &Address{}, + } + + currCell, err := boc.DeserializeBocHex("b5ee9c7241010101002400004380107bfaaa5cc6e5368e5f9799188bd798cd22e04ab16d1d8ea4fc37480741e6351064a3e1a6") + if err != nil { + t.Fatal(err) + } + v, err := UnmarshalTolk(currCell[0], ty) + if err != nil { + t.Fatal(err) + } + + val, ok := v.GetAddress() + if !ok { + t.Errorf("v.GetAddress() not successeded") + } + if val.ToRaw() != "0:83dfd552e63729b472fcbcc8c45ebcc6691702558b68ec7527e1ba403a0f31a8" { + t.Errorf("val.GetAddress() != 0:83dfd552e63729b472fcbcc8c45ebcc6691702558b68ec7527e1ba403a0f31a8, got %v", val.ToRaw()) + } +} + +func TestRuntime_UnmarshalNotExitsOptionalAddress(t *testing.T) { + ty := Ty{ + SumType: "AddressOpt", + AddressOpt: &AddressOpt{}, + } + + currCell, err := boc.DeserializeBocHex("b5ee9c724101010100030000012094418655") + if err != nil { + t.Fatal(err) + } + v, err := UnmarshalTolk(currCell[0], ty) + if err != nil { + t.Fatal(err) + } + + val, ok := v.GetOptionalAddress() + if !ok { + t.Errorf("v.GetOptionalAddress() not successeded") + } + + if val.SumType != "NoneAddress" { + t.Errorf("val.GetAddress() != none address") + } +} + +func TestRuntime_UnmarshalExistsOptionalAddress(t *testing.T) { + ty := Ty{ + SumType: "AddressOpt", + AddressOpt: &AddressOpt{}, + } + + currCell, err := boc.DeserializeBocHex("b5ee9c7241010101002400004380107bfaaa5cc6e5368e5f9799188bd798cd22e04ab16d1d8ea4fc37480741e6351064a3e1a6") + if err != nil { + t.Fatal(err) + } + v, err := UnmarshalTolk(currCell[0], ty) + if err != nil { + t.Fatal(err) + } + + val, ok := v.GetOptionalAddress() + if !ok { + t.Errorf("v.GetOptionalAddress() not successeded") + } + + if val.SumType == "InternalAddress" && val.InternalAddress.ToRaw() != "0:83dfd552e63729b472fcbcc8c45ebcc6691702558b68ec7527e1ba403a0f31a8" { + t.Errorf("val.GetAddress() != 0:83dfd552e63729b472fcbcc8c45ebcc6691702558b68ec7527e1ba403a0f31a8, got %v", val.InternalAddress.ToRaw()) + } +} + +func TestRuntime_UnmarshalExternalAddress(t *testing.T) { + ty := Ty{ + SumType: "AddressExt", + AddressExt: &AddressExt{}, + } + + currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000600000742082850fcbd94fd") + if err != nil { + t.Fatal(err) + } + v, err := UnmarshalTolk(currCell[0], ty) + if err != nil { + t.Fatal(err) + } + + val, ok := v.GetExternalAddress() + if !ok { + t.Errorf("v.GetExternalAddress() not successeded") + } + addressPart := boc.NewBitString(16) + err = addressPart.WriteBytes([]byte{97, 98}) + if err != nil { + t.Fatal(err) + } + if val.Len != 8 && bytes.Equal(val.Address.Buffer(), []byte{97, 98}) { + t.Errorf("val.GetExternalAddress() != {97, 98}, got %v", val.Address.Buffer()) + } +} + +func TestRuntime_UnmarshalAnyNoneAddress(t *testing.T) { + ty := Ty{ + SumType: "AddressAny", + AddressAny: &AddressAny{}, + } + + currCell, err := boc.DeserializeBocHex("b5ee9c724101010100030000012094418655") + if err != nil { + t.Fatal(err) + } + v, err := UnmarshalTolk(currCell[0], ty) + if err != nil { + t.Fatal(err) + } + + val, ok := v.GetAnyAddress() + if !ok { + t.Errorf("v.GetAnyAddress() not successeded") + } + if val.SumType != "NoneAddress" { + t.Errorf("val.GetAddress() != none address") + } +} + +func TestRuntime_UnmarshalAnyInternalAddress(t *testing.T) { + ty := Ty{ + SumType: "AddressAny", + AddressAny: &AddressAny{}, + } + + currCell, err := boc.DeserializeBocHex("b5ee9c7241010101002400004380107bfaaa5cc6e5368e5f9799188bd798cd22e04ab16d1d8ea4fc37480741e6351064a3e1a6") + if err != nil { + t.Fatal(err) + } + v, err := UnmarshalTolk(currCell[0], ty) + if err != nil { + t.Fatal(err) + } + + val, ok := v.GetAnyAddress() + if !ok { + t.Errorf("v.GetAnyAddress() not successeded") + } + if val.SumType == "InternalAddress" && val.InternalAddress.ToRaw() != "0:83dfd552e63729b472fcbcc8c45ebcc6691702558b68ec7527e1ba403a0f31a8" { + t.Errorf("val.GetAddress() != 0:83dfd552e63729b472fcbcc8c45ebcc6691702558b68ec7527e1ba403a0f31a8, got %v", val.InternalAddress.ToRaw()) + } +} + +func TestRuntime_UnmarshalAnyExternalAddress(t *testing.T) { + ty := Ty{ + SumType: "AddressAny", + AddressAny: &AddressAny{}, + } + + currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000600000742082850fcbd94fd") + if err != nil { + t.Fatal(err) + } + v, err := UnmarshalTolk(currCell[0], ty) + if err != nil { + t.Fatal(err) + } + + val, ok := v.GetAnyAddress() + if !ok { + t.Errorf("v.GetAnyAddress() not successeded") + } + addressPart := boc.NewBitString(16) + err = addressPart.WriteBytes([]byte{97, 98}) + if err != nil { + t.Fatal(err) + } + if val.SumType == "ExternalAddress" && val.ExternalAddress.Len != 8 && bytes.Equal(val.ExternalAddress.Address.Buffer(), []byte{97, 98}) { + t.Errorf("val.GetExternalAddress() != {97, 98}, got %v", val.ExternalAddress.Address.Buffer()) + } +} + +func TestRuntime_UnmarshalAnyVarAddress(t *testing.T) { + ty := Ty{ + SumType: "AddressAny", + AddressAny: &AddressAny{}, + } + + currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000900000dc0800000000ab8d04726e4") + if err != nil { + t.Fatal(err) + } + v, err := UnmarshalTolk(currCell[0], ty) + if err != nil { + t.Fatal(err) + } + + val, ok := v.GetAnyAddress() + if !ok { + t.Errorf("v.GetAnyAddress() not successeded") + } + if val.SumType != "VarAddress" { + t.Errorf("val.GetAddress() != VarAddress") + } + if val.VarAddress.Len != 8 { + t.Errorf("val.VarAddress.Len != 8, got %v", val.VarAddress.Len) + } + if val.VarAddress.Workchain != 0 { + t.Errorf("val.VarAddress.Workchain != 0, got %v", val.VarAddress.Workchain) + } + if bytes.Equal(val.VarAddress.Address.Buffer(), []byte{97, 98}) { + t.Errorf("val.GetExternalAddress() != {97, 98}, got %v", val.ExternalAddress.Address.Buffer()) + } +} + +func TestRuntime_UnmarshalNotExistsNullable(t *testing.T) { + ty := Ty{ + SumType: "Nullable", + Nullable: &Nullable{ + Inner: Ty{ + SumType: "Remaining", + Remaining: &Remaining{}, + }, + }, + } + + currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000300000140f6d24034") + if err != nil { + t.Fatal(err) + } + v, err := UnmarshalTolk(currCell[0], ty) + if err != nil { + t.Fatal(err) + } + + val, ok := v.GetOptionalValue() + if !ok { + t.Errorf("v.GetOptionalValue() not successeded") + } + if val.IsExists { + t.Errorf("v.GetOptionalValue() is exists") + } +} + +func TestRuntime_UnmarshalExistsNullable(t *testing.T) { + ty := Ty{ + SumType: "Nullable", + Nullable: &Nullable{ + Inner: Ty{ + SumType: "Cell", + Cell: &Cell{}, + }, + }, + } + + currCell, err := boc.DeserializeBocHex("b5ee9c7241010201000b000101c001000900000c0ae007880db9") + if err != nil { + t.Fatal(err) + } + v, err := UnmarshalTolk(currCell[0], ty) + if err != nil { + t.Fatal(err) + } + + val, ok := v.GetOptionalValue() + if !ok { + t.Errorf("v.GetOptionalValue() not successeded") + } + if !val.IsExists { + t.Errorf("v.GetOptionalValue() != exists") + } + innerVal, ok := val.Val.GetCell() + if !ok { + t.Errorf("v.GetOptionalValue().GetCell() not successeded") + } + hs, err := innerVal.HashString() + if err != nil { + t.Fatal(err) + } + if hs != "df05386a55563049a4834a4cc1ec0dc22f3dcb63c04f7258ae475c5d28981773" { + t.Errorf("v.GetOptionalValue().GetCell() != df05386a55563049a4834a4cc1ec0dc22f3dcb63c04f7258ae475c5d28981773, got %v", hs) + } +} + +func TestRuntime_UnmarshalRef(t *testing.T) { + ty := Ty{ + SumType: "CellOf", + CellOf: &CellOf{ + Inner: Ty{ + SumType: "IntN", + IntN: &IntN{ + N: 65, + }, + }, + }, + } + + currCell, err := boc.DeserializeBocHex("b5ee9c7241010201000e000100010011000000000009689e40e150b4c5") + if err != nil { + t.Fatal(err) + } + v, err := UnmarshalTolk(currCell[0], ty) + if err != nil { + t.Fatal(err) + } + + val, ok := v.GetRefValue() + if !ok { + t.Errorf("v.GetRefValue() not successeded") + } + innerVal, ok := val.GetBigInt() + if !ok { + t.Errorf("v.GetRefValue().GetBigInt() not successeded") + } + if innerVal.Cmp(big.NewInt(1233212)) != 0 { + t.Errorf("v.GetRefValue().GetBigInt() != 1233212, got %v", innerVal.String()) + } +} + +func TestRuntime_UnmarshalEmptyTensor(t *testing.T) { + ty := Ty{ + SumType: "Tensor", + Tensor: &Tensor{}, + } + + currCell, err := boc.DeserializeBocHex("b5ee9c724101010100020000004cacb9cd") + if err != nil { + t.Fatal(err) + } + v, err := UnmarshalTolk(currCell[0], ty) + if err != nil { + t.Fatal(err) + } + + val, ok := v.GetTensor() + if !ok { + t.Errorf("v.GetTensor() not successeded") + } + + if len(val) != 0 { + t.Errorf("v.GetTensor() != empty") + } +} + +func TestRuntime_UnmarshalTensor(t *testing.T) { + ty := Ty{ + SumType: "Tensor", + Tensor: &Tensor{ + Items: []Ty{ + { + SumType: "UintN", + UintN: &UintN{ + N: 123, + }, + }, + { + SumType: "Bool", + Bool: &Bool{}, + }, + { + SumType: "Coins", + Coins: &Coins{}, + }, + { + SumType: "Tensor", + Tensor: &Tensor{ + Items: []Ty{ + { + SumType: "IntN", + IntN: &IntN{ + N: 23, + }, + }, + { + SumType: "Nullable", + Nullable: &Nullable{ + Inner: Ty{ + SumType: "IntN", + IntN: &IntN{ + N: 2, + }, + }, + }, + }, + }, + }, + }, + { + SumType: "VarIntN", + VarIntN: &VarIntN{ + N: 32, + }, + }, + }, + }, + } + + currCell, err := boc.DeserializeBocHex("b5ee9c7241010101001f00003900000000000000000000000000021cb43b9aca00fffd550bfbaae07401a2a98117") + if err != nil { + t.Fatal(err) + } + v, err := UnmarshalTolk(currCell[0], ty) + if err != nil { + t.Fatal(err) + } + + val, ok := v.GetTensor() + if !ok { + t.Errorf("v.GetTensor() not successeded") + } + + val0, ok := val[0].GetBigUInt() + if !ok { + t.Errorf("val[0].GetBigUInt() not successeded") + } + if val0.Cmp(big.NewInt(4325)) != 0 { + t.Errorf("val[0].GetBigUInt() != 4325, got %v", val0.String()) + } + + val1, ok := val[1].GetBool() + if !ok { + t.Errorf("val[1].GetBool() not successeded") + } + if !val1 { + t.Error("val[1].GetBool() is false") + } + + val2, ok := val[2].GetCoins() + if !ok { + t.Errorf("val[2].GetCoins() not successeded") + } + if val2.Cmp(big.NewInt(1_000_000_000)) != 0 { + t.Errorf("val[2].GetCoins() != 1000000000, got %v", val2.String()) + } + + val3, ok := val[3].GetTensor() + if !ok { + t.Errorf("val[3].GetTensor() not successeded") + } + + val30, ok := val3[0].GetSmallInt() + if !ok { + t.Errorf("val[3][0].GetSmallInt() not successeded") + } + if val30 != -342 { + t.Errorf("val[3][0].GetSmallInt() != -342, got %v", val30) + } + + optVal31, ok := val3[1].GetOptionalValue() + if !ok { + t.Errorf("val[3][1].GetOptionalValue() not successeded") + } + if !optVal31.IsExists { + t.Errorf("val[3][1].GetOptionalValue() != exists") + } + val31, ok := optVal31.Val.GetSmallInt() + if !ok { + t.Errorf("val[3][1].GetOptionalValue().GetSmallInt() not successeded") + } + if val31 != 0 { + t.Errorf("val[3][1].GetOptionalValue().GetSmallInt() != 0, got %v", val31) + } + + val4, ok := val[4].GetVarInt() + if !ok { + t.Errorf("val[4].GetVarInt() not successeded") + } + if val4.Cmp(big.NewInt(-9_304_000_000)) != 0 { + t.Errorf("val[4].GetVarInt() != -9304000000, got %v", val4.String()) + } +} + +func TestRuntime_UnmarshalIntKeyMap(t *testing.T) { + ty := Ty{ + SumType: "Map", + Map: &Map{ + K: Ty{ + SumType: "IntN", + IntN: &IntN{ + N: 32, + }, + }, + V: Ty{ + SumType: "Bool", + Bool: &Bool{}, + }, + }, + } + + currCell, err := boc.DeserializeBocHex("b5ee9c7241010201000c000101c001000ba00000007bc09a662c32") + if err != nil { + t.Fatal(err) + } + v, err := UnmarshalTolk(currCell[0], ty) + if err != nil { + t.Fatal(err) + } + + val, ok := v.GetMap() + if !ok { + t.Errorf("v.GetMap() not successeded") + } + val123, ok := val.GetBySmallInt(Int64(123)) + if !ok { + t.Errorf("val[123] not found") + } + val123Val, ok := val123.GetBool() + if !ok { + t.Errorf("val[123].GetBool() not successeded") + } + if !val123Val { + t.Errorf("val[123] is false") + } + + _, ok = val.GetBySmallInt(Int64(0)) + if ok { + t.Errorf("val[0] was found") + } +} + +func TestRuntime_UnmarshalUIntKeyMap(t *testing.T) { + ty := Ty{ + SumType: "Map", + Map: &Map{ + K: Ty{ + SumType: "UintN", + UintN: &UintN{ + N: 16, + }, + }, + V: Ty{ + SumType: "Address", + Address: &Address{}, + }, + }, + } + + currCell, err := boc.DeserializeBocHex("b5ee9c72410104010053000101c0010202cb02030045a7400b113a994b5024a16719f69139328eb759596c38a25f59028b146fecdc3621dfe80045a3cff5555555555555555555555555555555555555555555555555555555555555555888440ce8") + if err != nil { + t.Fatal(err) + } + v, err := UnmarshalTolk(currCell[0], ty) + if err != nil { + t.Fatal(err) + } + + val, ok := v.GetMap() + if !ok { + t.Errorf("v.GetMap() not successeded") + } + val23, ok := val.GetBySmallUInt(UInt64(23)) + if !ok { + t.Errorf("val[23] not found") + } + val23Val, ok := val23.GetAddress() + if !ok { + t.Errorf("val[23].GetAddress() not successeded") + } + if val23Val.ToRaw() != "-1:5555555555555555555555555555555555555555555555555555555555555555" { + t.Errorf("val[23] != -1:5555555555555555555555555555555555555555555555555555555555555555, got %v", val23Val.ToRaw()) + } + + val14, ok := val.GetBySmallUInt(UInt64(14)) + if !ok { + t.Errorf("val[14] not found") + } + val14Val, ok := val14.GetAddress() + if !ok { + t.Errorf("val[14].GetAddress() not successeded") + } + if val14Val.ToRaw() != "0:b113a994b5024a16719f69139328eb759596c38a25f59028b146fecdc3621dfe" { + t.Errorf("val[14] != 0:b113a994b5024a16719f69139328eb759596c38a25f59028b146fecdc3621dfe, got %v", val23Val.ToRaw()) + } + + _, ok = val.GetBySmallInt(Int64(0)) + if ok { + t.Errorf("val[0] was found") + } +} + +func TestRuntime_UnmarshalBigIntKeyMap(t *testing.T) { + ty := Ty{ + SumType: "Map", + Map: &Map{ + K: Ty{ + SumType: "UintN", + UintN: &UintN{ + N: 78, + }, + }, + V: Ty{ + SumType: "Cell", + Cell: &Cell{}, + }, + }, + } + + currCell, err := boc.DeserializeBocHex("b5ee9c7241010301001a000101c0010115a70000000000000047550902000b000000001ab01d5bf1a9") + if err != nil { + t.Fatal(err) + } + v, err := UnmarshalTolk(currCell[0], ty) + if err != nil { + t.Fatal(err) + } + + val, ok := v.GetMap() + if !ok { + t.Errorf("v.GetMap() not successeded") + } + val1, ok := val.GetByBigUInt(BigUInt(*big.NewInt(2337412))) + if !ok { + t.Errorf("val[2337412] not found") + } + val1Val, ok := val1.GetCell() + if !ok { + t.Errorf("val[2337412].GetCell() not successeded") + } + hs1, err := val1Val.HashString() + if err != nil { + t.Fatal(err) + } + if hs1 != "8be375797c46a090b06973ee57e96b1d1ae127609c400ceba7194e77e41c5150" { + t.Errorf("val[2337412].GetCell().GetHashString() != 8be375797c46a090b06973ee57e96b1d1ae127609c400ceba7194e77e41c5150, got %v", hs1) + } + + _, ok = val.GetByBigInt(BigInt(*big.NewInt(34))) + if ok { + t.Errorf("val[34] was found") + } +} + +func TestRuntime_UnmarshalBitsKeyMap(t *testing.T) { + ty := Ty{ + SumType: "Map", + Map: &Map{ + K: Ty{ + SumType: "BitsN", + BitsN: &BitsN{ + N: 16, + }, + }, + V: Ty{ + SumType: "Map", + Map: &Map{ + K: Ty{ + SumType: "IntN", + IntN: &IntN{ + N: 64, + }, + }, + V: Ty{ + SumType: "Tensor", + Tensor: &Tensor{ + Items: []Ty{ + { + SumType: "Address", + Address: &Address{}, + }, + { + SumType: "Coins", + Coins: &Coins{}, + }, + }, + }, + }, + }, + }, + }, + } + + currCell, err := boc.DeserializeBocHex("b5ee9c7241010301003b000101c0010106a0828502005ea0000000000000003e400b113a994b5024a16719f69139328eb759596c38a25f59028b146fecdc3621dfe43b9aca00b89cdc86") + if err != nil { + t.Fatal(err) + } + v, err := UnmarshalTolk(currCell[0], ty) + if err != nil { + t.Fatal(err) + } + + val, ok := v.GetMap() + if !ok { + t.Errorf("v.GetMap() not successeded") + } + key1 := boc.NewBitString(16) + err = key1.WriteBytes([]byte{65, 66}) + if err != nil { + t.Fatal(err) + } + val1, ok := val.GetByBits(Bits(key1)) + if !ok { + t.Errorf("val[{65, 66}] not found") + } + + mp, ok := val1.GetMap() + if !ok { + t.Errorf("val[{65, 66}].GetMap() not successeded") + } + val1_124, ok := mp.GetBySmallInt(124) + if !ok { + t.Errorf("val[{65, 66}][124] not found") + } + val1_124Val, ok := val1_124.GetTensor() + if !ok { + t.Errorf("val[{65, 66}][124].GetTensor() not successeded") + } + val1_124Val0, ok := val1_124Val[0].GetAddress() + if !ok { + t.Errorf("val[{65, 66}][124][0].GetAddress() not successeded") + } + if val1_124Val0.ToRaw() != "0:b113a994b5024a16719f69139328eb759596c38a25f59028b146fecdc3621dfe" { + t.Errorf("val[{65, 66}][124][0].GetAddress() != 0:b113a994b5024a16719f69139328eb759596c38a25f59028b146fecdc3621dfe, got %v", val1_124Val0.ToRaw()) + } + + val1_124Val1, ok := val1_124Val[1].GetCoins() + if !ok { + t.Errorf("val[{97, 98}][124][1].GetCoins() not successeded") + } + if val1_124Val1.Cmp(big.NewInt(1_000_000_000)) != 0 { + t.Errorf("val[{97, 98}][124][1].GetCoins() != 1_000_000_000, got %v", val1_124Val1.String()) + } + + key2 := boc.NewBitString(16) + err = key2.WriteBytes([]byte{98, 99}) + if err != nil { + t.Fatal(err) + } + _, ok = val.GetByBits(Bits(key2)) + if ok { + t.Errorf("val[{98, 99}] was found") + } +} + +func TestRuntime_UnmarshalAddressKeyMap(t *testing.T) { + ty := Ty{ + SumType: "Map", + Map: &Map{ + K: Ty{ + SumType: "Address", + Address: &Address{}, + }, + V: Ty{ + SumType: "Coins", + Coins: &Coins{}, + }, + }, + } + + currCell, err := boc.DeserializeBocHex("b5ee9c7241010201002f000101c0010051a17002c44ea652d4092859c67da44e4ca3add6565b0e2897d640a2c51bfb370d8877f9409502f9002016fdc16e") + if err != nil { + t.Fatal(err) + } + v, err := UnmarshalTolk(currCell[0], ty) + if err != nil { + t.Fatal(err) + } + + val, ok := v.GetMap() + if !ok { + t.Errorf("v.GetMap() not successeded") + } + // todo: create converter + addr := tongo.MustParseAddress("EQCxE6mUtQJKFnGfaROTKOt1lZbDiiX1kCixRv7Nw2Id_sDs") + val1, ok := val.GetByInternalAddress(InternalAddress{ + Workchain: int8(addr.ID.Workchain), + Address: addr.ID.Address, + }) + if !ok { + t.Errorf("val[\"EQCxE6mUtQJKFnGfaROTKOt1lZbDiiX1kCixRv7Nw2Id_sDs\"] not found") + } + val1Val, ok := val1.GetCoins() + if !ok { + t.Errorf("val[\"EQCxE6mUtQJKFnGfaROTKOt1lZbDiiX1kCixRv7Nw2Id_sDs\"].GetCoins() not successeded") + } + if val1Val.Cmp(big.NewInt(10_000_000_000)) != 0 { + t.Errorf("val[\"EQCxE6mUtQJKFnGfaROTKOt1lZbDiiX1kCixRv7Nw2Id_sDs\"].GetCoins() != 10_000_000_000, got %v", val1Val) + } + + addr = tongo.MustParseAddress("UQCD39VS5jcptHL8vMjEXrzGaRcCVYto7HUn4bpAOg8xqEBI") + _, ok = val.GetByInternalAddress(InternalAddress{ + Workchain: int8(addr.ID.Workchain), + Address: addr.ID.Address, + }) + if ok { + t.Errorf("val[\"UQCD39VS5jcptHL8vMjEXrzGaRcCVYto7HUn4bpAOg8xqEBI\"] was found") + } +} + +func TestRuntime_UnmarshalUnionWithDecPrefix(t *testing.T) { + ty := Ty{ + SumType: "Union", + Union: &Union{ + Variants: []UnionVariant{ + { + PrefixStr: "0", + PrefixLen: 1, + PrefixEatInPlace: true, + VariantTy: Ty{ + SumType: "IntN", + IntN: &IntN{ + N: 16, + }, + }, + }, + { + PrefixStr: "1", + PrefixLen: 1, + PrefixEatInPlace: true, + VariantTy: Ty{ + SumType: "IntN", + IntN: &IntN{ + N: 128, + }, + }, + }, + }, + }, + } + + currCell, err := boc.DeserializeBocHex("b5ee9c7241010101001300002180000000000000000000000003b5577dc0660d6029") + if err != nil { + t.Fatal(err) + } + v, err := UnmarshalTolk(currCell[0], ty) + if err != nil { + t.Fatal(err) + } + + val, ok := v.GetUnion() + if !ok { + t.Errorf("v.GetUnion() not successeded") + } + if val.Prefix.Len != 1 { + t.Errorf("val.Prefix.Len != 1") + } + if val.Prefix.Prefix != 1 { + t.Errorf("val.Prefix != 1, got %v", val.Prefix.Prefix) + } + + unionVal, ok := val.Val.GetBigInt() + if !ok { + t.Errorf("val.Val.GetBigInt() not successeded") + } + if unionVal.Cmp(big.NewInt(124432123)) != 0 { + t.Errorf("val.Val.GetBigInt() != 124432123, got %v", unionVal.String()) + } +} + +func TestRuntime_UnmarshalUnionWithBinPrefix(t *testing.T) { + inputFilename := "testdata/bin_union.json" + data, err := os.ReadFile(inputFilename) + if err != nil { + t.Fatal(err) + } + + var abi ABI + err = json.Unmarshal(data, &abi) + if err != nil { + t.Fatal(err) + } + + ty := Ty{ + SumType: "Union", + Union: &Union{ + Variants: []UnionVariant{ + { + PrefixStr: "0b001", + PrefixLen: 3, + VariantTy: Ty{ + SumType: "StructRef", + StructRef: &StructRef{ + StructName: "AddressWithPrefix", + }, + }, + }, + { + PrefixStr: "0b011", + PrefixLen: 3, + VariantTy: Ty{ + SumType: "StructRef", + StructRef: &StructRef{ + StructName: "MapWithPrefix", + }, + }, + }, + { + PrefixStr: "0b111", + PrefixLen: 3, + VariantTy: Ty{ + SumType: "StructRef", + StructRef: &StructRef{ + StructName: "CellWithPrefix", + }, + }, + }, + }, + }, + } + + currCell, err := boc.DeserializeBocHex("b5ee9c7241010201002e0001017801004fa17002c44ea652d4092859c67da44e4ca3add6565b0e2897d640a2c51bfb370d8877f900a4d89920c413c650") + if err != nil { + t.Fatal(err) + } + decoder := NewDecoder() + decoder.WithABI(abi) + v, err := decoder.UnmarshalTolk(currCell[0], ty) + if err != nil { + t.Fatal(err) + } + + val, ok := v.GetUnion() + if !ok { + t.Errorf("v.GetUnion() not successeded") + } + if val.Prefix.Len != 3 { + t.Errorf("val.Prefix.Len != 3, got %v", val.Prefix.Len) + } + if val.Prefix.Prefix != 3 { + t.Errorf("val.Prefix.Prefix != 3, got %v", val.Prefix.Prefix) + } + + mapStruct, ok := val.Val.GetStruct() + if !ok { + t.Errorf("val.GetStruct() not successeded") + } + mapStructVal, ok := mapStruct.GetField("v") + if !ok { + t.Errorf("val[v] not successeded") + } + unionVal, ok := mapStructVal.GetMap() + if !ok { + t.Errorf("val[v].GetMap() not successeded") + } + addr := tongo.MustParseAddress("EQCxE6mUtQJKFnGfaROTKOt1lZbDiiX1kCixRv7Nw2Id_sDs") + mapVal, ok := unionVal.GetByInternalAddress(InternalAddress{ + Workchain: int8(addr.ID.Workchain), + Address: addr.ID.Address, + }) + if !ok { + t.Errorf("val.GetMap()[\"EQCxE6mUtQJKFnGfaROTKOt1lZbDiiX1kCixRv7Nw2Id_sDs\"] not successeded") + } + mapCoins, ok := mapVal.GetCoins() + if !ok { + t.Errorf("val.GetMap()[\"EQCxE6mUtQJKFnGfaROTKOt1lZbDiiX1kCixRv7Nw2Id_sDs\"].GetCoins() not successeded") + } + if mapCoins.Cmp(big.NewInt(43213412)) != 0 { + t.Errorf("val.GetMap()[\"EQCxE6mUtQJKFnGfaROTKOt1lZbDiiX1kCixRv7Nw2Id_sDs\"].GetCoins() != 43213412, got %v", mapCoins.String()) + } +} + +func TestRuntime_UnmarshalUnionWithHexPrefix(t *testing.T) { + inputFilename := "testdata/hex_union.json" + data, err := os.ReadFile(inputFilename) + if err != nil { + t.Fatal(err) + } + + var abi ABI + err = json.Unmarshal(data, &abi) + if err != nil { + t.Fatal(err) + } + + ty := Ty{ + SumType: "Union", + Union: &Union{ + Variants: []UnionVariant{ + { + PrefixStr: "0x12345678", + PrefixLen: 32, + VariantTy: Ty{ + SumType: "StructRef", + StructRef: &StructRef{ + StructName: "UInt66WithPrefix", + }, + }, + }, + { + PrefixStr: "0xdeadbeef", + PrefixLen: 32, + VariantTy: Ty{ + SumType: "StructRef", + StructRef: &StructRef{ + StructName: "UInt33WithPrefix", + }, + }, + }, + { + PrefixStr: "0x89abcdef", + PrefixLen: 32, + VariantTy: Ty{ + SumType: "StructRef", + StructRef: &StructRef{ + StructName: "UInt4WithPrefix", + }, + }, + }, + }, + }, + } + + currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000b000011deadbeef00000000c0d75977b9") + if err != nil { + t.Fatal(err) + } + decoder := NewDecoder() + decoder.WithABI(abi) + v, err := decoder.UnmarshalTolk(currCell[0], ty) + if err != nil { + t.Fatal(err) + } + + val, ok := v.GetUnion() + if !ok { + t.Errorf("v.GetUnion() not successeded") + } + if val.Prefix.Len != 32 { + t.Errorf("val.Prefix.Len != 32, got %v", val.Prefix.Len) + } + if val.Prefix.Prefix != 0xdeadbeef { + t.Errorf("val.Prefix.Prefix != 0xdeadbeef, got %x", val.Prefix.Prefix) + } + + structVal, ok := val.Val.GetStruct() + if !ok { + t.Errorf("val.Val.GetStruct() not successeded") + } + structV, ok := structVal.GetField("v") + if !ok { + t.Errorf("val.Val[v] not successeded") + } + unionVal, ok := structV.GetSmallUInt() + if !ok { + t.Errorf("val.GetSmallUInt() not successeded") + } + if unionVal != 1 { + t.Errorf("val.GetSmallUInt() != 1, got %v", unionVal) + } +} + +func TestRuntime_UnmarshalALotRefsFromAlias(t *testing.T) { + inputFilename := "testdata/refs.json" + data, err := os.ReadFile(inputFilename) + if err != nil { + t.Fatal(err) + } + + var abi ABI + err = json.Unmarshal(data, &abi) + if err != nil { + t.Fatal(err) + } + + ty := Ty{ + SumType: "AliasRef", + AliasRef: &AliasRef{ + AliasName: "GoodNamingForMsg", + }, + } + + currCell, err := boc.DeserializeBocHex("b5ee9c724101040100b7000377deadbeef80107bfaaa5cc6e5368e5f9799188bd798cd22e04ab16d1d8ea4fc37480741e635087735940143ffffffffffffffffffffffffffff63c006010203004b80010df454cebee868f611ba8c0d4a9371fb73105396505783293a7625f75db3b9880bebc20100438006e05909e22b2e5e6087533314ee56505f85212914bd5547941a2a658ac62fe101004f801622753296a04942ce33ed2272651d6eb2b2d87144beb2051628dfd9b86c43bfcc12309ce54001e09a48b8") + if err != nil { + t.Fatal(err) + } + decoder := NewDecoder() + decoder.WithABI(abi) + v, err := decoder.UnmarshalTolk(currCell[0], ty) + if err != nil { + t.Fatal(err) + } + + currAlias, ok := v.GetAlias() + if !ok { + t.Errorf("v.GetAlias() not successeded") + } + currStruct, ok := currAlias.GetStruct() + if !ok { + t.Fatalf("struct not found") + } + pref, ok := currStruct.GetPrefix() + if !ok { + t.Fatalf("currStruct.Prefix not found") + } + if pref.Len != 32 { + t.Errorf("pref.Len != 32, got %v", pref.Len) + } + if pref.Prefix != 0xdeadbeef { + t.Errorf("val.Prefix.Prefix != 0xdeadbeef, got %x", pref.Prefix) + } + + user1, ok := currStruct.GetField("user1") + if !ok { + t.Fatalf("currStruct[user1] not found") + } + user1Alias, ok := user1.GetAlias() + if !ok { + t.Fatalf("currStruct[user1].GetAlias() not found") + } + user1Val, ok := user1Alias.GetStruct() + if !ok { + t.Fatalf("currStruct[user1].GetStruct() not successeded") + } + + user1Addr, ok := user1Val.GetField("addr") + if !ok { + t.Fatalf("currStruct[user1][addr] not found") + } + user1AddrVal, ok := user1Addr.GetAddress() + if !ok { + t.Fatalf("currStruct[user1][addr].GetAddress() not successeded") + } + if user1AddrVal.ToRaw() != "0:83dfd552e63729b472fcbcc8c45ebcc6691702558b68ec7527e1ba403a0f31a8" { + t.Errorf("user1AddrVal.ToRaw() != 0:83dfd552e63729b472fcbcc8c45ebcc6691702558b68ec7527e1ba403a0f31a8, got %v", user1AddrVal.ToRaw()) + } + + user1Balance, ok := user1Val.GetField("balance") + if !ok { + t.Fatalf("currStruct[user1][balance] not found") + } + user1BalanceVal, ok := user1Balance.GetCoins() + if !ok { + t.Fatalf("currStruct[user1][balance].GetCoins() not successeded") + } + if user1BalanceVal.Cmp(big.NewInt(1_000_000_000)) != 0 { + t.Errorf("currStruct[user1][balance].GetCoins() != 1000000000, got %v", user1BalanceVal.String()) + } + + user2, ok := currStruct.GetField("user2") + if !ok { + t.Fatalf("currStruct[user2] not found") + } + user2Opt, ok := user2.GetOptionalValue() + if !ok { + t.Fatalf("currStruct[user2].GetOptionalValue() not successeded") + } + if !user2Opt.IsExists { + t.Errorf("currStruct[user2] is not exists") + } + user2Ref, ok := user2Opt.Val.GetRefValue() + if !ok { + t.Fatalf("currStruct[user2].GetRefValue() not successeded") + } + user2Alias, ok := user2Ref.GetAlias() + if !ok { + t.Fatalf("currStruct[user2].GetAlias() not found") + } + user2Val, ok := user2Alias.GetStruct() + if !ok { + t.Fatalf("currStruct[user2].GetStruct() not successeded") + } + + user2Addr, ok := user2Val.GetField("addr") + if !ok { + t.Fatalf("currStruct[user2][addr] not found") + } + user2AddrVal, ok := user2Addr.GetAddress() + if !ok { + t.Fatalf("currStruct[user2][addr].GetAddress() not successeded") + } + if user2AddrVal.ToRaw() != "0:086fa2a675f74347b08dd4606a549b8fdb98829cb282bc1949d3b12fbaed9dcc" { + t.Errorf("user1AddrVal.ToRaw() != 0:086fa2a675f74347b08dd4606a549b8fdb98829cb282bc1949d3b12fbaed9dcc, got %v", user2AddrVal.ToRaw()) + } + + user2Balance, ok := user2Val.GetField("balance") + if !ok { + t.Fatalf("currStruct[user2][balance] not found") + } + user2BalanceVal, ok := user2Balance.GetCoins() + if !ok { + t.Fatalf("currStruct[user2][balance].GetCoins() not successeded") + } + if user2BalanceVal.Cmp(big.NewInt(100_000_000)) != 0 { + t.Errorf("currStruct[user2][balance].GetCoins() != 100000000, got %v", user2BalanceVal.String()) + } + + user3, ok := currStruct.GetField("user3") + if !ok { + t.Fatalf("currStruct[user3] not found") + } + user3Val, ok := user3.GetCell() + if !ok { + t.Fatalf("currStruct[user3].GetCell() not successeded") + } + hs, err := user3Val.HashString() + if err != nil { + t.Fatal(err) + } + if hs != "47f4b117a301111ec48d763a3cd668a246c174efd2df9ba8bd1db406f017453a" { + t.Errorf("currStruct[user3][hashString].Hash != 47f4b117a301111ec48d763a3cd668a246c174efd2df9ba8bd1db406f017453a, got %v", hs) + } + + user4, ok := currStruct.GetField("user4") + if !ok { + t.Fatalf("currStruct[user4] not found") + } + user4Opt, ok := user4.GetOptionalValue() + if !ok { + t.Fatalf("currStruct[user4].GetOptionalValue() not successeded") + } + if user4Opt.IsExists { + t.Errorf("currStruct[user4] exists") + } + + user5, ok := currStruct.GetField("user5") + if !ok { + t.Fatalf("currStruct[user2] not found") + } + user5Ref, ok := user5.GetRefValue() + if !ok { + t.Fatalf("currStruct[user5].GetRefValue() not successeded") + } + user5Val, ok := user5Ref.GetStruct() + if !ok { + t.Fatalf("currStruct[user5].GetStruct() not successeded") + } + + user5Addr, ok := user5Val.GetField("addr") + if !ok { + t.Fatalf("currStruct[user5][addr] not found") + } + user5AddrVal, ok := user5Addr.GetAddress() + if !ok { + t.Fatalf("currStruct[user5][addr].GetAddress() not successeded") + } + if user5AddrVal.ToRaw() != "0:b113a994b5024a16719f69139328eb759596c38a25f59028b146fecdc3621dfe" { + t.Errorf("user1AddrVal.ToRaw() != 0:b113a994b5024a16719f69139328eb759596c38a25f59028b146fecdc3621dfe, got %v", user5AddrVal.ToRaw()) + } + + user5Balance, ok := user5Val.GetField("balance") + if !ok { + t.Fatalf("currStruct[user5][balance] not found") + } + user5BalanceVal, ok := user5Balance.GetCoins() + if !ok { + t.Fatalf("currStruct[user5][balance].GetCoins() not successeded") + } + if user5BalanceVal.Cmp(big.NewInt(10_000_000_000_000)) != 0 { + t.Errorf("currStruct[user5][balance].GetCoins() != 10000000000000, got %v", user5BalanceVal.String()) + } + + role, ok := currStruct.GetField("role") + if !ok { + t.Fatalf("currStruct[role] not found") + } + roleEnum, ok := role.GetEnum() + if !ok { + t.Fatalf("currStruct[role].GetEnum() not successeded") + } + if roleEnum.Value.Cmp(big.NewInt(1)) != 0 { + t.Errorf("currStruct[role].GetEnum().Value != 1, got %v", roleEnum.Value.String()) + } + if roleEnum.Name != "Aboba" { + t.Errorf("currStruct[role].GetEnum().Name != Aboba, got %v", roleEnum.Name) + } + + oper1, ok := currStruct.GetField("oper1") + if !ok { + t.Fatalf("currStruct[oper1] not found") + } + oper1Enum, ok := oper1.GetEnum() + if !ok { + t.Fatalf("currStruct[oper1].GetEnum() not successeded") + } + if oper1Enum.Value.Cmp(big.NewInt(0)) != 0 { + t.Errorf("currStruct[oper1].GetEnum().Value != 0, got %v", oper1Enum.Value.String()) + } + if oper1Enum.Name != "Add" { + t.Errorf("currStruct[oper1].GetEnum().Name != Add, got %v", oper1Enum.Name) + } + + oper2, ok := currStruct.GetField("oper2") + if !ok { + t.Fatalf("currStruct[oper2] not found") + } + oper2Enum, ok := oper2.GetEnum() + if !ok { + t.Fatalf("currStruct[oper2].GetEnum() not successeded") + } + if oper2Enum.Value.Cmp(big.NewInt(-10000)) != 0 { + t.Errorf("currStruct[oper2].GetEnum().Value != -10000, got %v", oper2Enum.Value.String()) + } + if oper2Enum.Name != "TopUp" { + t.Errorf("currStruct[oper2].GetEnum().Name != TopUp, got %v", oper2Enum.Name) + } + + oper3, ok := currStruct.GetField("oper3") + if !ok { + t.Fatalf("currStruct[oper3] not found") + } + oper3Enum, ok := oper3.GetEnum() + if !ok { + t.Fatalf("currStruct[oper3].GetEnum() not successeded") + } + if oper3Enum.Value.Cmp(big.NewInt(1)) != 0 { + t.Errorf("currStruct[oper3].GetEnum().Value != 1, got %v", oper3Enum.Value.String()) + } + if oper3Enum.Name != "Something" { + t.Errorf("currStruct[oper3].GetEnum().Name != Something, got %v", oper3Enum.Name) + } +} + +func TestRuntime_UnmarshalALotRefsFromStruct(t *testing.T) { + inputFilename := "testdata/refs.json" + data, err := os.ReadFile(inputFilename) + if err != nil { + t.Fatal(err) + } + + var abi ABI + err = json.Unmarshal(data, &abi) + if err != nil { + t.Fatal(err) + } + + ty := Ty{ + SumType: "StructRef", + StructRef: &StructRef{ + StructName: "ManyRefsMsg", + }, + } + + currCell, err := boc.DeserializeBocHex("b5ee9c724101040100b7000377deadbeef80107bfaaa5cc6e5368e5f9799188bd798cd22e04ab16d1d8ea4fc37480741e635087735940143ffffffffffffffffffffffffffff63c006010203004b80010df454cebee868f611ba8c0d4a9371fb73105396505783293a7625f75db3b9880bebc20100438006e05909e22b2e5e6087533314ee56505f85212914bd5547941a2a658ac62fe101004f801622753296a04942ce33ed2272651d6eb2b2d87144beb2051628dfd9b86c43bfcc12309ce54001e09a48b8") + if err != nil { + t.Fatal(err) + } + decoder := NewDecoder() + decoder.WithABI(abi) + v, err := decoder.UnmarshalTolk(currCell[0], ty) + if err != nil { + t.Fatal(err) + } + + currStruct, ok := v.GetStruct() + if !ok { + t.Fatalf("struct not found") + } + pref, ok := currStruct.GetPrefix() + if !ok { + t.Fatalf("currStruct.Prefix not found") + } + if pref.Len != 32 { + t.Errorf("pref.Len != 32, got %v", pref.Len) + } + if pref.Prefix != 0xdeadbeef { + t.Errorf("val.Prefix.Prefix != 0xdeadbeef, got %x", pref.Prefix) + } + + user1, ok := currStruct.GetField("user1") + if !ok { + t.Fatalf("currStruct[user1] not found") + } + user1Alias, ok := user1.GetAlias() + if !ok { + t.Fatalf("currStruct[user1].GetAlias() not found") + } + user1Val, ok := user1Alias.GetStruct() + if !ok { + t.Fatalf("currStruct[user1].GetStruct() not successeded") + } + + user1Addr, ok := user1Val.GetField("addr") + if !ok { + t.Fatalf("currStruct[user1][addr] not found") + } + user1AddrVal, ok := user1Addr.GetAddress() + if !ok { + t.Fatalf("currStruct[user1][addr].GetAddress() not successeded") + } + if user1AddrVal.ToRaw() != "0:83dfd552e63729b472fcbcc8c45ebcc6691702558b68ec7527e1ba403a0f31a8" { + t.Errorf("user1AddrVal.ToRaw() != 0:83dfd552e63729b472fcbcc8c45ebcc6691702558b68ec7527e1ba403a0f31a8, got %v", user1AddrVal.ToRaw()) + } + + user1Balance, ok := user1Val.GetField("balance") + if !ok { + t.Fatalf("currStruct[user1][balance] not found") + } + user1BalanceVal, ok := user1Balance.GetCoins() + if !ok { + t.Fatalf("currStruct[user1][balance].GetCoins() not successeded") + } + if user1BalanceVal.Cmp(big.NewInt(1_000_000_000)) != 0 { + t.Errorf("currStruct[user1][balance].GetCoins() != 1000000000, got %v", user1BalanceVal.String()) + } + + user2, ok := currStruct.GetField("user2") + if !ok { + t.Fatalf("currStruct[user2] not found") + } + user2Opt, ok := user2.GetOptionalValue() + if !ok { + t.Fatalf("currStruct[user2].GetOptionalValue() not successeded") + } + if !user2Opt.IsExists { + t.Errorf("currStruct[user2] is not exists") + } + user2Ref, ok := user2Opt.Val.GetRefValue() + if !ok { + t.Fatalf("currStruct[user2].GetRefValue() not successeded") + } + user2Alias, ok := user2Ref.GetAlias() + if !ok { + t.Fatalf("currStruct[user2].GetAlias() not found") + } + user2Val, ok := user2Alias.GetStruct() + if !ok { + t.Fatalf("currStruct[user2].GetStruct() not successeded") + } + + user2Addr, ok := user2Val.GetField("addr") + if !ok { + t.Fatalf("currStruct[user2][addr] not found") + } + user2AddrVal, ok := user2Addr.GetAddress() + if !ok { + t.Fatalf("currStruct[user2][addr].GetAddress() not successeded") + } + if user2AddrVal.ToRaw() != "0:086fa2a675f74347b08dd4606a549b8fdb98829cb282bc1949d3b12fbaed9dcc" { + t.Errorf("user1AddrVal.ToRaw() != 0:086fa2a675f74347b08dd4606a549b8fdb98829cb282bc1949d3b12fbaed9dcc, got %v", user2AddrVal.ToRaw()) + } + + user2Balance, ok := user2Val.GetField("balance") + if !ok { + t.Fatalf("currStruct[user2][balance] not found") + } + user2BalanceVal, ok := user2Balance.GetCoins() + if !ok { + t.Fatalf("currStruct[user2][balance].GetCoins() not successeded") + } + if user2BalanceVal.Cmp(big.NewInt(100_000_000)) != 0 { + t.Errorf("currStruct[user2][balance].GetCoins() != 100000000, got %v", user2BalanceVal.String()) + } + + user3, ok := currStruct.GetField("user3") + if !ok { + t.Fatalf("currStruct[user3] not found") + } + user3Val, ok := user3.GetCell() + if !ok { + t.Fatalf("currStruct[user3].GetCell() not successeded") + } + hs, err := user3Val.HashString() + if err != nil { + t.Fatal(err) + } + if hs != "47f4b117a301111ec48d763a3cd668a246c174efd2df9ba8bd1db406f017453a" { + t.Errorf("currStruct[user3][hashString].Hash != 47f4b117a301111ec48d763a3cd668a246c174efd2df9ba8bd1db406f017453a, got %v", hs) + } + + user4, ok := currStruct.GetField("user4") + if !ok { + t.Fatalf("currStruct[user4] not found") + } + user4Opt, ok := user4.GetOptionalValue() + if !ok { + t.Fatalf("currStruct[user4].GetOptionalValue() not successeded") + } + if user4Opt.IsExists { + t.Errorf("currStruct[user4] exists") + } + + user5, ok := currStruct.GetField("user5") + if !ok { + t.Fatalf("currStruct[user2] not found") + } + user5Ref, ok := user5.GetRefValue() + if !ok { + t.Fatalf("currStruct[user5].GetRefValue() not successeded") + } + user5Val, ok := user5Ref.GetStruct() + if !ok { + t.Fatalf("currStruct[user5].GetStruct() not successeded") + } + + user5Addr, ok := user5Val.GetField("addr") + if !ok { + t.Fatalf("currStruct[user5][addr] not found") + } + user5AddrVal, ok := user5Addr.GetAddress() + if !ok { + t.Fatalf("currStruct[user5][addr].GetAddress() not successeded") + } + if user5AddrVal.ToRaw() != "0:b113a994b5024a16719f69139328eb759596c38a25f59028b146fecdc3621dfe" { + t.Errorf("user1AddrVal.ToRaw() != 0:b113a994b5024a16719f69139328eb759596c38a25f59028b146fecdc3621dfe, got %v", user5AddrVal.ToRaw()) + } + + user5Balance, ok := user5Val.GetField("balance") + if !ok { + t.Fatalf("currStruct[user5][balance] not found") + } + user5BalanceVal, ok := user5Balance.GetCoins() + if !ok { + t.Fatalf("currStruct[user5][balance].GetCoins() not successeded") + } + if user5BalanceVal.Cmp(big.NewInt(10_000_000_000_000)) != 0 { + t.Errorf("currStruct[user5][balance].GetCoins() != 10000000000000, got %v", user5BalanceVal.String()) + } + + role, ok := currStruct.GetField("role") + if !ok { + t.Fatalf("currStruct[role] not found") + } + roleEnum, ok := role.GetEnum() + if !ok { + t.Fatalf("currStruct[role].GetEnum() not successeded") + } + if roleEnum.Value.Cmp(big.NewInt(1)) != 0 { + t.Errorf("currStruct[role].GetEnum().Value != 1, got %v", roleEnum.Value.String()) + } + if roleEnum.Name != "Aboba" { + t.Errorf("currStruct[role].GetEnum().Name != Aboba, got %v", roleEnum.Name) + } + + oper1, ok := currStruct.GetField("oper1") + if !ok { + t.Fatalf("currStruct[oper1] not found") + } + oper1Enum, ok := oper1.GetEnum() + if !ok { + t.Fatalf("currStruct[oper1].GetEnum() not successeded") + } + if oper1Enum.Value.Cmp(big.NewInt(0)) != 0 { + t.Errorf("currStruct[oper1].GetEnum().Value != 0, got %v", oper1Enum.Value.String()) + } + if oper1Enum.Name != "Add" { + t.Errorf("currStruct[oper1].GetEnum().Name != Add, got %v", oper1Enum.Name) + } + + oper2, ok := currStruct.GetField("oper2") + if !ok { + t.Fatalf("currStruct[oper2] not found") + } + oper2Enum, ok := oper2.GetEnum() + if !ok { + t.Fatalf("currStruct[oper2].GetEnum() not successeded") + } + if oper2Enum.Value.Cmp(big.NewInt(-10000)) != 0 { + t.Errorf("currStruct[oper2].GetEnum().Value != -10000, got %v", oper2Enum.Value.String()) + } + if oper2Enum.Name != "TopUp" { + t.Errorf("currStruct[oper2].GetEnum().Name != TopUp, got %v", oper2Enum.Name) + } + + oper3, ok := currStruct.GetField("oper3") + if !ok { + t.Fatalf("currStruct[oper3] not found") + } + oper3Enum, ok := oper3.GetEnum() + if !ok { + t.Fatalf("currStruct[oper3].GetEnum() not successeded") + } + if oper3Enum.Value.Cmp(big.NewInt(1)) != 0 { + t.Errorf("currStruct[oper3].GetEnum().Value != 1, got %v", oper3Enum.Value.String()) + } + if oper3Enum.Name != "Something" { + t.Errorf("currStruct[oper3].GetEnum().Name != Something, got %v", oper3Enum.Name) + } +} + +func TestRuntime_UnmarshalALotGenericsFromStruct(t *testing.T) { + inputFilename := "testdata/generics.json" + data, err := os.ReadFile(inputFilename) + if err != nil { + t.Fatal(err) + } + + var abi ABI + err = json.Unmarshal(data, &abi) + if err != nil { + t.Fatal(err) + } + + ty := Ty{ + SumType: "StructRef", + StructRef: &StructRef{ + StructName: "ManyRefsMsg", + TypeArgs: []Ty{ + { + SumType: "UintN", + UintN: &UintN{ + N: 16, + }, + }, + }, + }, + } + + currCell, err := boc.DeserializeBocHex("b5ee9c72410103010043000217d017d7840343b9aca0000108010200080000007b005543b9aca001017d78402005889d4ca5a81250b38cfb489c99475bacacb61c512fac81458a37f66e1b10eff422fc7647") + if err != nil { + t.Fatal(err) + } + decoder := NewDecoder() + decoder.WithABI(abi) + v, err := decoder.UnmarshalTolk(currCell[0], ty) + if err != nil { + t.Fatal(err) + } + + currStruct, ok := v.GetStruct() + if !ok { + t.Fatalf("struct not found") + } + + payloadV, ok := currStruct.GetField("payload") + if !ok { + t.Fatalf("currStruct[payload] not found") + } + payloadStruct, ok := payloadV.GetStruct() + if !ok { + t.Fatalf("currStruct[payload].GetStruct() not found") + } + payloadRef, ok := payloadStruct.GetField("value") + if !ok { + t.Fatalf("currStruct[payload][value] not found") + } + payloadUnion, ok := payloadRef.GetUnion() + if !ok { + t.Fatalf("currStruct[payload][value].GetUnion() not found") + } + payload, ok := payloadUnion.Val.GetRefValue() + if !ok { + t.Fatalf("currStruct[payload].GetRefValue() not successeded") + } + // todo: remove GetGeneric because its not convenient + payloadGeneric, ok := payload.GetGeneric() + if !ok { + t.Fatalf("currStruct[payload].GetGeneric() not found") + } + payloadVal, ok := payloadGeneric.GetSmallUInt() + if !ok { + t.Fatalf("currStruct[payload].GetSmallUInt() not found") + } + if payloadVal != 123 { + t.Errorf("currStruct[payload].GetSmallUInt() != 123, got %v", payloadVal) + } + + either, ok := currStruct.GetField("either") + if !ok { + t.Fatalf("currStruct[either] not found") + } + eitherAlias, ok := either.GetAlias() + if !ok { + t.Fatalf("currStruct[either].GetAlias() not found") + } + eitherUnion, ok := eitherAlias.GetUnion() + if !ok { + t.Fatalf("currStruct[either].GetUnion() not successeded") + } + eitherStruct, ok := eitherUnion.Val.GetStruct() + if !ok { + t.Fatalf("currStruct[either].GetStruct() not successeded") + } + eitherV, ok := eitherStruct.GetField("value") + if !ok { + t.Fatalf("currStruct[either][value] not successeded") + } + eitherValGeneric, ok := eitherV.GetGeneric() + if !ok { + t.Fatalf("currStruct[either][value].GetGeneric() not found") + } + eitherVal, ok := eitherValGeneric.GetCoins() + if !ok { + t.Fatalf("currStruct[either][value].GetCoins() not successeded") + } + if eitherVal.Cmp(big.NewInt(100000000)) != 0 { + t.Fatalf("currStruct[either][value].GetCoins() != 1000000000, got %v", eitherVal.String()) + } + + anotherEither, ok := currStruct.GetField("anotherEither") + if !ok { + t.Fatalf("currStruct[anotherEither] not found") + } + anotherEitherAlias, ok := anotherEither.GetAlias() + if !ok { + t.Fatalf("currStruct[anotherEither].GetAlias() not found") + } + anotherEitherAliasAlias, ok := anotherEitherAlias.GetAlias() + if !ok { + t.Fatalf("currStruct[anotherEither].GetAlias().GetAlias() not found") + } + anotherEitherUnion, ok := anotherEitherAliasAlias.GetUnion() + if !ok { + t.Fatalf("currStruct[anotherEither].GetUnion() not successeded") + } + anotherEitherStruct, ok := anotherEitherUnion.Val.GetStruct() + if !ok { + t.Fatalf("currStruct[anotherEither].GetStruct() not successeded") + } + anotherEitherV, ok := anotherEitherStruct.GetField("value") + if !ok { + t.Fatalf("currStruct[anotherEither][value] not successeded") + } + anotherEitherVGeneric, ok := anotherEitherV.GetGeneric() + if !ok { + t.Fatalf("currStruct[anotherEither][value].GetGeneric() not found") + } + anotherEitherVal, ok := anotherEitherVGeneric.GetTensor() + if !ok { + t.Fatalf("currStruct[anotherEither][value].GetTensor() not successeded") + } + + anotherEitherValBool, ok := anotherEitherVal[0].GetBool() + if !ok { + t.Fatalf("currStruct[anotherEither][value][0].GetBool() not successeded") + } + if !anotherEitherValBool { + t.Fatalf("currStruct[anotherEither][value][0].GetBool() is false") + } + anotherEitherValCoins, ok := anotherEitherVal[1].GetCoins() + if !ok { + t.Fatalf("currStruct[anotherEither][value][0].GetCoins() not successeded") + } + if anotherEitherValCoins.Cmp(big.NewInt(1_000_000_000)) != 0 { + t.Fatalf("currStruct[anotherEither][value][0].GetCoins() != 1000000000, got %v", anotherEitherValCoins.String()) + } + + doubler, ok := currStruct.GetField("doubler") + if !ok { + t.Fatalf("currStruct[doubler] not found") + } + doublerRef, ok := doubler.GetRefValue() + if !ok { + t.Fatalf("currStruct[doubler].GetRefValue() not successeded") + } + doublerRefAlias, ok := doublerRef.GetAlias() + if !ok { + t.Fatalf("currStruct[doubler].GetAlias() not found") + } + doublerTensor, ok := doublerRefAlias.GetTensor() + if !ok { + t.Fatalf("currStruct[doubler].GetTensor() not successeded") + } + + doublerGenric0, ok := doublerTensor[0].GetGeneric() + if !ok { + t.Fatalf("currStruct[doubler][0].GetGeneric() not successeded") + } + doublerTensor0, ok := doublerGenric0.GetTensor() + if !ok { + t.Fatalf("currStruct[doubler][0].GetTensor() not successeded") + } + doublerTensor0Coins, ok := doublerTensor0[0].GetCoins() + if !ok { + t.Fatalf("currStruct[doubler][0][0].GetCoins() not successeded") + } + if doublerTensor0Coins.Cmp(big.NewInt(1_000_000_000)) != 0 { + t.Fatalf("currStruct[doubler][0][0].GetBigInt() != 1000000000, got %v", doublerTensor0Coins.String()) + } + + doublerTensor0Addr, ok := doublerTensor0[1].GetOptionalAddress() + if !ok { + t.Fatalf("currStruct[doubler][0][1].GetOptionalAddress() not successeded") + } + if doublerTensor0Addr.SumType != "NoneAddress" { + t.Fatalf("currStruct[doubler][0][1].GetOptionalAddress() != NoneAddress") + } + + doublerUnion1, ok := doublerTensor[1].GetGeneric() + if !ok { + t.Fatalf("currStruct[doubler][1].GetGeneric() not successeded") + } + doublerTensor1, ok := doublerUnion1.GetTensor() + if !ok { + t.Fatalf("currStruct[doubler][1] not successeded") + } + doublerTensor1Coins, ok := doublerTensor1[0].GetCoins() + if !ok { + t.Fatalf("currStruct[doubler][1][0].GetCoins() not successeded") + } + if doublerTensor1Coins.Cmp(big.NewInt(100_000_000)) != 0 { + t.Fatalf("currStruct[doubler][1][0].GetCoins() != 100000000, got %v", doublerTensor1Coins.String()) + } + + doublerTensor1Addr, ok := doublerTensor1[1].GetOptionalAddress() + if !ok { + t.Fatalf("currStruct[doubler][1][1].GetOptionalAddress() not successeded") + } + if doublerTensor1Addr.SumType != "InternalAddress" { + t.Fatalf("currStruct[doubler][1][1].GetOptionalAddress() != InternalAddress") + } + if doublerTensor1Addr.InternalAddress.ToRaw() != "0:b113a994b5024a16719f69139328eb759596c38a25f59028b146fecdc3621dfe" { + t.Fatalf("currStruct[doubler][1][1] != 0:b113a994b5024a16719f69139328eb759596c38a25f59028b146fecdc3621dfe, got %v", doublerTensor1Addr.InternalAddress.ToRaw()) + } + + myVal, ok := currStruct.GetField("myVal") + if !ok { + t.Fatalf("currStruct[myVal] not found") + } + myValAlias, ok := myVal.GetAlias() + if !ok { + t.Fatalf("currStruct[myVal].GetAlias() not found") + } + myValGeneric, ok := myValAlias.GetGeneric() + if !ok { + t.Fatalf("currStruct[myVal].GetGeneric() not found") + } + myValVal, ok := myValGeneric.GetSmallUInt() + if !ok { + t.Fatalf("currStruct[myVal].GetSmallUInt() not successed") + } + if myValVal != 16 { + t.Fatalf("currStruct[myVal] != 16, got %v", myValVal) + } +} + +func TestRuntime_UnmarshalALotGenericsFromAlias(t *testing.T) { + inputFilename := "testdata/generics.json" + data, err := os.ReadFile(inputFilename) + if err != nil { + t.Fatal(err) + } + + var abi ABI + err = json.Unmarshal(data, &abi) + if err != nil { + t.Fatal(err) + } + + ty := Ty{ + SumType: "AliasRef", + AliasRef: &AliasRef{ + AliasName: "GoodNamingForMsg", + TypeArgs: []Ty{ + { + SumType: "UintN", + UintN: &UintN{ + N: 16, + }, + }, + }, + }, + } + + currCell, err := boc.DeserializeBocHex("b5ee9c72410103010043000217d017d7840343b9aca0000108010200080000007b005543b9aca001017d78402005889d4ca5a81250b38cfb489c99475bacacb61c512fac81458a37f66e1b10eff422fc7647") + if err != nil { + t.Fatal(err) + } + decoder := NewDecoder() + decoder.WithABI(abi) + v, err := decoder.UnmarshalTolk(currCell[0], ty) + if err != nil { + t.Fatal(err) + } + + currAlias, ok := v.GetAlias() + if !ok { + t.Fatalf("v.GetAlias() not found") + } + currStruct, ok := currAlias.GetStruct() + if !ok { + t.Fatalf("struct not found") + } + + payloadV, ok := currStruct.GetField("payload") + if !ok { + t.Fatalf("currStruct[payload] not found") + } + payloadStruct, ok := payloadV.GetStruct() + if !ok { + t.Fatalf("currStruct[payload].GetStruct() not found") + } + payloadRef, ok := payloadStruct.GetField("value") + if !ok { + t.Fatalf("currStruct[payload][value] not found") + } + payloadUnion, ok := payloadRef.GetUnion() + if !ok { + t.Fatalf("currStruct[payload][value].GetUnion() not found") + } + payload, ok := payloadUnion.Val.GetRefValue() + if !ok { + t.Fatalf("currStruct[payload].GetRefValue() not successeded") + } + // todo: remove GetGeneric because its not convenient + payloadGeneric, ok := payload.GetGeneric() + if !ok { + t.Fatalf("currStruct[payload].GetGeneric() not found") + } + payloadVal, ok := payloadGeneric.GetSmallUInt() + if !ok { + t.Fatalf("currStruct[payload].GetSmallUInt() not found") + } + if payloadVal != 123 { + t.Errorf("currStruct[payload].GetSmallUInt() != 123, got %v", payloadVal) + } + + either, ok := currStruct.GetField("either") + if !ok { + t.Fatalf("currStruct[either] not found") + } + eitherAlias, ok := either.GetAlias() + if !ok { + t.Fatalf("currStruct[either].GetAlias() not found") + } + eitherUnion, ok := eitherAlias.GetUnion() + if !ok { + t.Fatalf("currStruct[either].GetUnion() not successeded") + } + eitherStruct, ok := eitherUnion.Val.GetStruct() + if !ok { + t.Fatalf("currStruct[either].GetStruct() not successeded") + } + eitherV, ok := eitherStruct.GetField("value") + if !ok { + t.Fatalf("currStruct[either][value] not successeded") + } + eitherValGeneric, ok := eitherV.GetGeneric() + if !ok { + t.Fatalf("currStruct[either][value].GetGeneric() not found") + } + eitherVal, ok := eitherValGeneric.GetCoins() + if !ok { + t.Fatalf("currStruct[either][value].GetCoins() not successeded") + } + if eitherVal.Cmp(big.NewInt(100000000)) != 0 { + t.Fatalf("currStruct[either][value].GetCoins() != 1000000000, got %v", eitherVal.String()) + } + + anotherEither, ok := currStruct.GetField("anotherEither") + if !ok { + t.Fatalf("currStruct[anotherEither] not found") + } + anotherEitherAlias, ok := anotherEither.GetAlias() + if !ok { + t.Fatalf("currStruct[anotherEither].GetAlias() not found") + } + anotherEitherAliasAlias, ok := anotherEitherAlias.GetAlias() + if !ok { + t.Fatalf("currStruct[anotherEither].GetAlias().GetAlias() not found") + } + anotherEitherUnion, ok := anotherEitherAliasAlias.GetUnion() + if !ok { + t.Fatalf("currStruct[anotherEither].GetUnion() not successeded") + } + anotherEitherStruct, ok := anotherEitherUnion.Val.GetStruct() + if !ok { + t.Fatalf("currStruct[anotherEither].GetStruct() not successeded") + } + anotherEitherV, ok := anotherEitherStruct.GetField("value") + if !ok { + t.Fatalf("currStruct[anotherEither][value] not successeded") + } + anotherEitherVGeneric, ok := anotherEitherV.GetGeneric() + if !ok { + t.Fatalf("currStruct[anotherEither][value].GetGeneric() not found") + } + anotherEitherVal, ok := anotherEitherVGeneric.GetTensor() + if !ok { + t.Fatalf("currStruct[anotherEither][value].GetTensor() not successeded") + } + + anotherEitherValBool, ok := anotherEitherVal[0].GetBool() + if !ok { + t.Fatalf("currStruct[anotherEither][value][0].GetBool() not successeded") + } + if !anotherEitherValBool { + t.Fatalf("currStruct[anotherEither][value][0].GetBool() is false") + } + anotherEitherValCoins, ok := anotherEitherVal[1].GetCoins() + if !ok { + t.Fatalf("currStruct[anotherEither][value][0].GetCoins() not successeded") + } + if anotherEitherValCoins.Cmp(big.NewInt(1_000_000_000)) != 0 { + t.Fatalf("currStruct[anotherEither][value][0].GetCoins() != 1000000000, got %v", anotherEitherValCoins.String()) + } + + doubler, ok := currStruct.GetField("doubler") + if !ok { + t.Fatalf("currStruct[doubler] not found") + } + doublerRef, ok := doubler.GetRefValue() + if !ok { + t.Fatalf("currStruct[doubler].GetRefValue() not successeded") + } + doublerRefAlias, ok := doublerRef.GetAlias() + if !ok { + t.Fatalf("currStruct[doubler].GetAlias() not found") + } + doublerTensor, ok := doublerRefAlias.GetTensor() + if !ok { + t.Fatalf("currStruct[doubler].GetTensor() not successeded") + } + + doublerGenric0, ok := doublerTensor[0].GetGeneric() + if !ok { + t.Fatalf("currStruct[doubler][0].GetGeneric() not successeded") + } + doublerTensor0, ok := doublerGenric0.GetTensor() + if !ok { + t.Fatalf("currStruct[doubler][0].GetTensor() not successeded") + } + doublerTensor0Coins, ok := doublerTensor0[0].GetCoins() + if !ok { + t.Fatalf("currStruct[doubler][0][0].GetCoins() not successeded") + } + if doublerTensor0Coins.Cmp(big.NewInt(1_000_000_000)) != 0 { + t.Fatalf("currStruct[doubler][0][0].GetBigInt() != 1000000000, got %v", doublerTensor0Coins.String()) + } + + doublerTensor0Addr, ok := doublerTensor0[1].GetOptionalAddress() + if !ok { + t.Fatalf("currStruct[doubler][0][1].GetOptionalAddress() not successeded") + } + if doublerTensor0Addr.SumType != "NoneAddress" { + t.Fatalf("currStruct[doubler][0][1].GetOptionalAddress() != NoneAddress") + } + + doublerUnion1, ok := doublerTensor[1].GetGeneric() + if !ok { + t.Fatalf("currStruct[doubler][1].GetGeneric() not successeded") + } + doublerTensor1, ok := doublerUnion1.GetTensor() + if !ok { + t.Fatalf("currStruct[doubler][1] not successeded") + } + doublerTensor1Coins, ok := doublerTensor1[0].GetCoins() + if !ok { + t.Fatalf("currStruct[doubler][1][0].GetCoins() not successeded") + } + if doublerTensor1Coins.Cmp(big.NewInt(100_000_000)) != 0 { + t.Fatalf("currStruct[doubler][1][0].GetCoins() != 100000000, got %v", doublerTensor1Coins.String()) + } + + doublerTensor1Addr, ok := doublerTensor1[1].GetOptionalAddress() + if !ok { + t.Fatalf("currStruct[doubler][1][1].GetOptionalAddress() not successeded") + } + if doublerTensor1Addr.SumType != "InternalAddress" { + t.Fatalf("currStruct[doubler][1][1].GetOptionalAddress() != InternalAddress") + } + if doublerTensor1Addr.InternalAddress.ToRaw() != "0:b113a994b5024a16719f69139328eb759596c38a25f59028b146fecdc3621dfe" { + t.Fatalf("currStruct[doubler][1][1] != 0:b113a994b5024a16719f69139328eb759596c38a25f59028b146fecdc3621dfe, got %v", doublerTensor1Addr.InternalAddress.ToRaw()) + } + + myVal, ok := currStruct.GetField("myVal") + if !ok { + t.Fatalf("currStruct[myVal] not found") + } + myValAlias, ok := myVal.GetAlias() + if !ok { + t.Fatalf("currStruct[myVal].GetAlias() not found") + } + myValGeneric, ok := myValAlias.GetGeneric() + if !ok { + t.Fatalf("currStruct[myVal].GetGeneric() not found") + } + myValVal, ok := myValGeneric.GetSmallUInt() + if !ok { + t.Fatalf("currStruct[myVal].GetSmallUInt() not successed") + } + if myValVal != 16 { + t.Fatalf("currStruct[myVal] != 16, got %v", myValVal) + } +} + +func TestRuntime_UnmarshalStructWithDefaultValues(t *testing.T) { + inputFilename := "testdata/default_values.json" + data, err := os.ReadFile(inputFilename) + if err != nil { + t.Fatal(err) + } + + var abi ABI + err = json.Unmarshal(data, &abi) + if err != nil { + t.Fatal(err) + } + + ty := Ty{ + SumType: "StructRef", + StructRef: &StructRef{ + StructName: "DefaultTest", + }, + } + + currCell, err := boc.DeserializeBocHex("b5ee9c7241010101003100005d80000002414801622753296a04942ce33ed2272651d6eb2b2d87144beb2051628dfd9b86c43bfd00000156ac2c4c70811a9dde") + if err != nil { + t.Fatal(err) + } + decoder := NewDecoder() + decoder.WithABI(abi) + v, err := decoder.UnmarshalTolk(currCell[0], ty) + if err != nil { + t.Fatal(err) + } + + currStruct, ok := v.GetStruct() + if !ok { + t.Fatalf("struct not found") + } + + optNum1, ok := currStruct.GetField("num1") + if !ok { + t.Fatalf("currStruct[num1] not found") + } + num1, ok := optNum1.GetOptionalValue() + if !ok { + t.Fatalf("currStruct[num1].GetOptionalValue() not successeded") + } + if !num1.IsExists { + t.Fatalf("currStruct[num1] is not exists") + } + num1Val, ok := num1.Val.GetSmallUInt() + if !ok { + t.Fatalf("currStruct[num1].GetSmallUInt() not successeded") + } + if num1Val != 4 { + t.Fatalf("currStruct[num1].GetSmallUInt() != 4, got %v", num1Val) + } + + optNum2, ok := currStruct.GetField("num2") + if !ok { + t.Fatalf("currStruct[num2] not found") + } + num2, ok := optNum2.GetOptionalValue() + if !ok { + t.Fatalf("currStruct[num2].GetOptionalValue() not successeded") + } + if !num2.IsExists { + t.Fatalf("currStruct[num2] is not exists") + } + num2Alias, ok := num2.Val.GetAlias() + if !ok { + t.Fatalf("currStruct[num2].GetAlias() not found") + } + num2Val, ok := num2Alias.GetSmallInt() + if !ok { + t.Fatalf("currStruct[num2].GetSmallInt() not successeded") + } + if num2Val != 5 { + t.Fatalf("currStruct[num2].GetSmallInt() != 5, got %v", num2Val) + } + + optSlice3, ok := currStruct.GetField("slice3") + if !ok { + t.Fatalf("currStruct[slice3] not found") + } + slice3, ok := optSlice3.GetOptionalValue() + if !ok { + t.Fatalf("currStruct[slice3].GetOptionalValue() not successeded") + } + if !slice3.IsExists { + t.Fatalf("currStruct[slice3] is not exists") + } + slice3Val, ok := slice3.Val.GetRemaining() + if !ok { + t.Fatalf("currStruct[slice3].GetRemaining() not successeded") + } + hs, err := slice3Val.HashString() + if err != nil { + t.Fatal(err) + } + if hs != "55e960f1409af0d7670e382c61276a559fa9330185984d91faffebf32d5fa383" { + t.Fatalf("currStruct[slice3].GetRemaining().Hash() != 55e960f1409af0d7670e382c61276a559fa9330185984d91faffebf32d5fa383, got %v", hs) + } + + optAddr4, ok := currStruct.GetField("addr4") + if !ok { + t.Fatalf("currStruct[addr4] not found") + } + addr4, ok := optAddr4.GetOptionalAddress() + if !ok { + t.Fatalf("currStruct[addr4].GetOptionalAddress() not successeded") + } + if addr4.SumType != "NoneAddress" { + t.Fatalf("currStruct[addr4].GetOptionalAddress() != NoneAddress") + } + + optAddr5, ok := currStruct.GetField("addr5") + if !ok { + t.Fatalf("currStruct[addr5] not found") + } + addr5, ok := optAddr5.GetOptionalAddress() + if !ok { + t.Fatalf("currStruct[addr5].GetOptionalAddress() not successeded") + } + if addr5.SumType != "InternalAddress" { + t.Fatalf("currStruct[addr5].GetOptionalAddress() != InternalAddress") + } + if addr5.InternalAddress.ToRaw() != "0:b113a994b5024a16719f69139328eb759596c38a25f59028b146fecdc3621dfe" { + t.Fatalf("currStruct[addr5].GetOptionalAddress() != 0:b113a994b5024a16719f69139328eb759596c38a25f59028b146fecdc3621dfe, got %v", addr5.InternalAddress.ToRaw()) + } + + optTensor6, ok := currStruct.GetField("tensor6") + if !ok { + t.Fatalf("currStruct[tensor6] not found") + } + tensor6, ok := optTensor6.GetOptionalValue() + if !ok { + t.Fatalf("currStruct[tensor6].GetOptionalValue() not successeded") + } + if !tensor6.IsExists { + t.Fatalf("currStruct[tensor6] is not exists") + } + tensor6Val, ok := tensor6.Val.GetTensor() + if !ok { + t.Fatalf("currStruct[tensor6].GetTensor() not successeded") + } + tensor6Val0, ok := tensor6Val[0].GetSmallInt() + if !ok { + t.Fatalf("currStruct[tensor6][0].GetSmallInt() not successed") + } + if tensor6Val0 != 342 { + t.Fatalf("currStruct[tensor6][0] != 342, got %v", tensor6Val0) + } + + tensor6Val1, ok := tensor6Val[1].GetBool() + if !ok { + t.Fatalf("currStruct[tensor6][1].GetBool() not successed") + } + if !tensor6Val1 { + t.Fatalf("currStruct[tensor6][0] is false") + } + + optNum7, ok := currStruct.GetField("num7") + if !ok { + t.Fatalf("currStruct[num7] not found") + } + num7, ok := optNum7.GetOptionalValue() + if !ok { + t.Fatalf("currStruct[num7].GetOptionalValue() not successeded") + } + if num7.IsExists { + t.Fatalf("currStruct[num7] exists") + } +} + +func TestRuntime_UnmarshalALotNumbers(t *testing.T) { + inputFilename := "testdata/numbers.json" + data, err := os.ReadFile(inputFilename) + if err != nil { + t.Fatal(err) + } + + var abi ABI + err = json.Unmarshal(data, &abi) + if err != nil { + t.Fatal(err) + } + + ty := Ty{ + SumType: "StructRef", + StructRef: &StructRef{ + StructName: "Numbers", + }, + } + + currCell, err := boc.DeserializeBocHex("b5ee9c72410101010033000062000000000000000000000000000000000000000000000000000000000000000000000000000000f1106aecc4c800020926dc62f014") + if err != nil { + t.Fatal(err) + } + decoder := NewDecoder() + decoder.WithABI(abi) + v, err := decoder.UnmarshalTolk(currCell[0], ty) + if err != nil { + t.Fatal(err) + } + + currStruct, ok := v.GetStruct() + if !ok { + t.Fatalf("struct not found") + } + num1, ok := currStruct.GetField("num1") + if !ok { + t.Fatalf("num1 not found") + } + val1, ok := num1.GetSmallUInt() + if !ok { + t.Fatalf("num1.GetSmallUInt() not successeded") + } + if val1 != 0 { + t.Fatalf("num1 != 0, got %v", val1) + } + + num3, ok := currStruct.GetField("num3") + if !ok { + t.Fatalf("num3 not found") + } + val3, ok := num3.GetBigUInt() + if !ok { + t.Fatalf("num3.GetBigUInt() not successeded") + } + if val3.Cmp(big.NewInt(241)) != 0 { + t.Fatalf("num3 != 241, got %v", val3.String()) + } + + num4, ok := currStruct.GetField("num4") + if !ok { + t.Fatalf("num4 not found") + } + val4, ok := num4.GetVarUInt() + if !ok { + t.Fatalf("num4.GetVarUInt() not successeded") + } + if val4.Cmp(big.NewInt(3421)) != 0 { + t.Fatalf("num4 != 3421, got %s", val4.String()) + } + + num5, ok := currStruct.GetField("num5") + if !ok { + t.Fatalf("num5 not found") + } + val5, ok := num5.GetBool() + if !ok { + t.Fatalf("num5.GetBool() not successeded") + } + if !val5 { + t.Fatalf("num5 != true") + } + + num7, ok := currStruct.GetField("num7") + if !ok { + t.Fatalf("num7 not found") + } + val7, ok := num7.GetBits() + if !ok { + t.Fatalf("num7.GetBits() not successeded") + } + if !bytes.Equal(val7.Buffer(), []byte{49, 50}) { + t.Fatalf("num7 != \"12\", got %v", val7.Buffer()) + } + + num8, ok := currStruct.GetField("num8") + if !ok { + t.Fatalf("num8 not found") + } + val8, ok := num8.GetSmallInt() + if !ok { + t.Fatalf("num8.GetSmallInt() not successeded") + } + if val8 != 0 { + t.Fatalf("num8 != 0, got %v", val8) + } + + num9, ok := currStruct.GetField("num9") + if !ok { + t.Fatalf("num9 not found") + } + val9, ok := num9.GetVarInt() + if !ok { + t.Fatalf("num9.GetVarInt() not successeded") + } + if val9.Cmp(big.NewInt(2342)) != 0 { + t.Fatalf("num9 != 2342, got %s", val9.String()) + } +} + +func TestRuntime_UnmarshalALotRandomFields(t *testing.T) { + inputFilename := "testdata/random_fields.json" + data, err := os.ReadFile(inputFilename) + if err != nil { + t.Fatal(err) + } + + var abi ABI + err = json.Unmarshal(data, &abi) + if err != nil { + t.Fatal(err) + } + + ty := Ty{ + SumType: "StructRef", + StructRef: &StructRef{ + StructName: "RandomFields", + }, + } + + currCell, err := boc.DeserializeBocHex("b5ee9c7241010301007800028b79480107bfaaa5cc6e5368e5f9799188bd798cd22e04ab16d1d8ea4fc37480741e6350e038d7eb37c5e80000000ab50ee6b28000000000000016e4c000006c175300001801bc01020001c00051000000000005120041efeaa9731b94da397e5e64622f5e63348b812ac5b4763a93f0dd201d0798d4409e337ceb") + if err != nil { + t.Fatal(err) + } + decoder := NewDecoder() + decoder.WithABI(abi) + v, err := decoder.UnmarshalTolk(currCell[0], ty) + if err != nil { + t.Fatal(err) + } + + addr := ton.MustParseAccountID("UQCD39VS5jcptHL8vMjEXrzGaRcCVYto7HUn4bpAOg8xqEBI") + + currStruct, ok := v.GetStruct() + if !ok { + t.Fatalf("struct not found") + } + pref, ok := currStruct.GetPrefix() + if !ok { + t.Fatalf("struct prefix not found") + } + if pref.Len != 12 { + t.Fatalf("pref.Len != 12, got %d", pref.Len) + } + if pref.Prefix != 1940 { + t.Fatalf("struct prefix != 1940, got %d", pref) + } + + destInt, ok := currStruct.GetField("dest_int") + if !ok { + t.Fatalf("dest_int not found") + } + destIntVal, ok := destInt.GetAddress() + if !ok { + t.Fatalf("num1.GetAddress() not successeded") + } + if destIntVal.ToRaw() != addr.ToRaw() { + t.Fatalf("destInt != UQCD39VS5jcptHL8vMjEXrzGaRcCVYto7HUn4bpAOg8xqEBI") + } + + amount, ok := currStruct.GetField("amount") + if !ok { + t.Fatalf("amount not found") + } + amountVal, ok := amount.GetCoins() + if !ok { + t.Fatalf("amount.GetCoins() not successeded") + } + expectedAmount, ok := big.NewInt(0).SetString("500000123400000", 10) + if !ok { + t.Fatalf("cannot set 500000123400000 value to big.Int") + } + if amountVal.Cmp(expectedAmount) != 0 { + t.Fatalf("amount != 500000123400000, got %s", amountVal.String()) + } + + destExt, ok := currStruct.GetField("dest_ext") + if !ok { + t.Fatalf("num4 dest_ext found") + } + destExtVal, ok := destExt.GetAnyAddress() + if !ok { + t.Fatalf("num4.GetAnyAddress() not successeded") + } + if destExtVal.SumType != "NoneAddress" { + t.Fatalf("destExt != a none address") + } + + intVector, ok := currStruct.GetField("intVector") + if !ok { + t.Fatalf("intVector not found") + } + intVectorVal, ok := intVector.GetTensor() + if !ok { + t.Fatalf("num5.GetTensor() not successeded") + } + val1, ok := intVectorVal[0].GetSmallInt() + if !ok { + t.Fatalf("intVector[0].GetSmallInt() not successeded") + } + if val1 != 342 { + t.Fatalf("intVector[0].GetSmallInt() != 342, got %v", val1) + } + + optVal2, ok := intVectorVal[1].GetOptionalValue() + if !ok { + t.Fatalf("intVector[1].GetOptionalValue() not successeded") + } + if !optVal2.IsExists { + t.Fatalf("intVector[1].GetOptionalValue() != exists") + } + val2, ok := optVal2.Val.GetCoins() + if !ok { + t.Fatalf("intVector[1].GetOptionalValue().GetCoins() not successeded") + } + if val2.Cmp(big.NewInt(1000000000)) != 0 { + t.Fatalf("intVector[1].GetOptionalValue().GetCoins() != 1000000000, got %v", val1) + } + + val3, ok := intVectorVal[2].GetSmallUInt() + if !ok { + t.Fatalf("intVector[2].GetSmallUInt() not successeded") + } + if val3 != 23443 { + t.Fatalf("intVector[2].GetSmallUInt() != 23443, got %v", val1) + } + + needsMoreRef, ok := currStruct.GetField("needs_more") + if !ok { + t.Fatalf("needs_more not found") + } + needsMore, ok := needsMoreRef.GetRefValue() + if !ok { + t.Fatalf("needsMoreRef.GetRefValue() not successeded") + } + needsMoreVal, ok := needsMore.GetBool() + if !ok { + t.Fatalf("needsMore.GetBool() not successeded") + } + if !needsMoreVal { + t.Fatalf("needsMore != true") + } + + somePayload, ok := currStruct.GetField("some_payload") + if !ok { + t.Fatalf("some_payload not found") + } + somePayloadVal, ok := somePayload.GetCell() + if !ok { + t.Fatalf("num8.GetCell() not successeded") + } + somePayloadHash, err := somePayloadVal.HashString() + if err != nil { + t.Fatalf("somePayload.HashString() not successeded") + } + if somePayloadHash != "f2017ee9d429c16689ba2243d26d2a070a1e8e4a6106cee2129a049deee727d9" { + t.Fatalf("somePayloadHash != f2017ee9d429c16689ba2243d26d2a070a1e8e4a6106cee2129a049deee727d9, got %v", somePayloadHash) + } + + myInt, ok := currStruct.GetField("my_int") + if !ok { + t.Fatalf("my_int not found") + } + myIntAlias, ok := myInt.GetAlias() + if !ok { + t.Fatalf("my_int.GetAlias() not successeded") + } + myIntVal, ok := myIntAlias.GetSmallInt() + if !ok { + t.Fatalf("my_int.GetSmallInt() not successeded") + } + if myIntVal != 432 { + t.Fatalf("my_int != 432, got %v", myIntVal) + } + + someUnion, ok := currStruct.GetField("some_union") + if !ok { + t.Fatalf("my_int not found") + } + someUnionVal, ok := someUnion.GetUnion() + if !ok { + t.Fatalf("someUnion.GetSmallInt() not successeded") + } + unionVal, ok := someUnionVal.Val.GetSmallInt() + if !ok { + t.Fatalf("someUnion.GetSmallInt() not successeded") + } + if unionVal != 30000 { + t.Fatalf("some_union != 30000, got %v", someUnionVal) + } + + default1, ok := currStruct.GetField("default_1") + if !ok { + t.Fatalf("default_1 not found") + } + default1Val, ok := default1.GetSmallInt() + if !ok { + t.Fatalf("default1.GetSmallInt() not successeded") + } + if default1Val != 1 { + t.Fatalf("default1 != 1, got %v", default1Val) + } + + optDefault2, ok := currStruct.GetField("default_2") + if !ok { + t.Fatalf("default_2 not found") + } + default2, ok := optDefault2.GetOptionalValue() + if !ok { + t.Fatalf("default2.GetOptionalValue() not successeded") + } + if !default2.IsExists { + t.Fatalf("default2.GetOptionalValue() != exists") + } + default2Val, ok := default2.Val.GetSmallInt() + if !ok { + t.Fatalf("default2.GetSmallInt() not successeded") + } + if default2Val != 55 { + t.Fatalf("default2 != 55, got %v", default2Val) + } +} + +func TestRuntime_MarshalSmallInt(t *testing.T) { + ty := Ty{ + SumType: "IntN", + IntN: &IntN{ + N: 24, + }, + } + + currCell, err := boc.DeserializeBocHex("b5ee9c72410101010005000006ff76c41616db06") + if err != nil { + t.Fatal(err) + } + v, err := UnmarshalTolk(currCell[0], ty) + if err != nil { + t.Fatal(err) + } + + newCell := boc.NewCell() + err = MarshalTolk(newCell, v) + if err != nil { + t.Error(err) + } + + oldHs, err := currCell[0].HashString() + if err != nil { + t.Fatal(err) + } + newHs, err := newCell.HashString() + if err != nil { + t.Fatal(err) + } + if oldHs != newHs { + t.Errorf("input and output cells are different") + } +} + +func TestRuntime_MarshalBigInt(t *testing.T) { + ty := Ty{ + SumType: "IntN", + IntN: &IntN{ + N: 183, + }, + } + + currCell, err := boc.DeserializeBocHex("b5ee9c7241010101001900002dfffffffffffffffffffffffffffffffffff99bfeac6423a6f0b50c") + if err != nil { + t.Fatal(err) + } + v, err := UnmarshalTolk(currCell[0], ty) + if err != nil { + t.Fatal(err) + } + + newCell := boc.NewCell() + err = MarshalTolk(newCell, v) + if err != nil { + t.Error(err) + } + + oldHs, err := currCell[0].HashString() + if err != nil { + t.Fatal(err) + } + newHs, err := newCell.HashString() + if err != nil { + t.Fatal(err) + } + if oldHs != newHs { + t.Errorf("input and output cells are different") + } +} + +func TestRuntime_MarshalSmallUInt(t *testing.T) { + ty := Ty{ + SumType: "UintN", + UintN: &UintN{ + N: 53, + }, + } + + currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000900000d00000000001d34e435eafd") + if err != nil { + t.Fatal(err) + } + v, err := UnmarshalTolk(currCell[0], ty) + if err != nil { + t.Fatal(err) + } + + newCell := boc.NewCell() + err = MarshalTolk(newCell, v) + if err != nil { + t.Error(err) + } + + oldHs, err := currCell[0].HashString() + if err != nil { + t.Fatal(err) + } + newHs, err := newCell.HashString() + if err != nil { + t.Fatal(err) + } + if oldHs != newHs { + t.Errorf("input and output cells are different") + } +} + +func TestRuntime_MarshalBigUInt(t *testing.T) { + ty := Ty{ + SumType: "UintN", + UintN: &UintN{ + N: 257, + }, + } + + currCell, err := boc.DeserializeBocHex("b5ee9c7241010101002300004100000000000000000000000000000000000000000000000000009fc4212a38ba40b11cce12") + if err != nil { + t.Fatal(err) + } + v, err := UnmarshalTolk(currCell[0], ty) + if err != nil { + t.Fatal(err) + } + + newCell := boc.NewCell() + err = MarshalTolk(newCell, v) + if err != nil { + t.Error(err) + } + + oldHs, err := currCell[0].HashString() + if err != nil { + t.Fatal(err) + } + newHs, err := newCell.HashString() + if err != nil { + t.Fatal(err) + } + if oldHs != newHs { + t.Errorf("input and output cells are different") + } +} + +func TestRuntime_MarshalVarInt(t *testing.T) { + ty := Ty{ + SumType: "VarIntN", + VarIntN: &VarIntN{ + N: 16, + }, + } + + currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000600000730c98588449b6923") + if err != nil { + t.Fatal(err) + } + v, err := UnmarshalTolk(currCell[0], ty) + if err != nil { + t.Fatal(err) + } + + newCell := boc.NewCell() + err = MarshalTolk(newCell, v) + if err != nil { + t.Error(err) + } + + oldHs, err := currCell[0].HashString() + if err != nil { + t.Fatal(err) + } + newHs, err := newCell.HashString() + if err != nil { + t.Fatal(err) + } + if oldHs != newHs { + t.Errorf("input and output cells are different") + } +} + +func TestRuntime_MarshalVarUInt(t *testing.T) { + ty := Ty{ + SumType: "VarUintN", + VarUintN: &VarUintN{ + N: 32, + }, + } + + currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000800000b28119ab36b44d3a86c0f") + if err != nil { + t.Fatal(err) + } + v, err := UnmarshalTolk(currCell[0], ty) + if err != nil { + t.Fatal(err) + } + + newCell := boc.NewCell() + err = MarshalTolk(newCell, v) + if err != nil { + t.Error(err) + } + + oldHs, err := currCell[0].HashString() + if err != nil { + t.Fatal(err) + } + newHs, err := newCell.HashString() + if err != nil { + t.Fatal(err) + } + if oldHs != newHs { + t.Errorf("input and output cells are different") + } +} + +func TestRuntime_MarshalBits(t *testing.T) { + ty := Ty{ + SumType: "BitsN", + BitsN: &BitsN{ + N: 24, + }, + } + + currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000500000631323318854035") + if err != nil { + t.Fatal(err) + } + v, err := UnmarshalTolk(currCell[0], ty) + if err != nil { + t.Fatal(err) + } + + newCell := boc.NewCell() + err = MarshalTolk(newCell, v) + if err != nil { + t.Error(err) + } + + oldHs, err := currCell[0].HashString() + if err != nil { + t.Fatal(err) + } + newHs, err := newCell.HashString() + if err != nil { + t.Fatal(err) + } + if oldHs != newHs { + t.Errorf("input and output cells are different") + } +} + +func TestRuntime_MarshalCoins(t *testing.T) { + ty := Ty{ + SumType: "Coins", + Coins: &Coins{}, + } + + currCell, err := boc.DeserializeBocHex("b5ee9c72410101010007000009436ec6e0189ebbd7f4") + if err != nil { + t.Fatal(err) + } + v, err := UnmarshalTolk(currCell[0], ty) + if err != nil { + t.Fatal(err) + } + + newCell := boc.NewCell() + err = MarshalTolk(newCell, v) + if err != nil { + t.Error(err) + } + + oldHs, err := currCell[0].HashString() + if err != nil { + t.Fatal(err) + } + newHs, err := newCell.HashString() + if err != nil { + t.Fatal(err) + } + if oldHs != newHs { + t.Errorf("input and output cells are different") + } +} + +func TestRuntime_MarshalBool(t *testing.T) { + ty := Ty{ + SumType: "Bool", + Bool: &Bool{}, + } + + currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000300000140f6d24034") + if err != nil { + t.Fatal(err) + } + v, err := UnmarshalTolk(currCell[0], ty) + if err != nil { + t.Fatal(err) + } + + newCell := boc.NewCell() + err = MarshalTolk(newCell, v) + if err != nil { + t.Error(err) + } + + oldHs, err := currCell[0].HashString() + if err != nil { + t.Fatal(err) + } + newHs, err := newCell.HashString() + if err != nil { + t.Fatal(err) + } + if oldHs != newHs { + t.Errorf("input and output cells are different") + } +} + +func TestRuntime_MarshalCell(t *testing.T) { + ty := Ty{ + SumType: "Cell", + Cell: &Cell{}, + } + + currCell, err := boc.DeserializeBocHex("b5ee9c724101020100090001000100080000007ba52a3292") + if err != nil { + t.Fatal(err) + } + v, err := UnmarshalTolk(currCell[0], ty) + if err != nil { + t.Fatal(err) + } + + newCell := boc.NewCell() + err = MarshalTolk(newCell, v) + if err != nil { + t.Error(err) + } + + oldHs, err := currCell[0].HashString() + if err != nil { + t.Fatal(err) + } + newHs, err := newCell.HashString() + if err != nil { + t.Fatal(err) + } + if oldHs != newHs { + t.Errorf("input and output cells are different") + } +} + +func TestRuntime_MarshalRemaining(t *testing.T) { + ty := Ty{ + SumType: "Remaining", + Remaining: &Remaining{}, + } + + currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000900000dc0800000000ab8d04726e4") + if err != nil { + t.Fatal(err) + } + v, err := UnmarshalTolk(currCell[0], ty) + if err != nil { + t.Fatal(err) + } + + newCell := boc.NewCell() + err = MarshalTolk(newCell, v) + if err != nil { + t.Error(err) + } + + oldHs, err := currCell[0].HashString() + if err != nil { + t.Fatal(err) + } + newHs, err := newCell.HashString() + if err != nil { + t.Fatal(err) + } + if oldHs != newHs { + t.Errorf("input and output cells are different") + } +} + +func TestRuntime_MarshalAddress(t *testing.T) { + ty := Ty{ + SumType: "Address", + Address: &Address{}, + } + + currCell, err := boc.DeserializeBocHex("b5ee9c7241010101002400004380107bfaaa5cc6e5368e5f9799188bd798cd22e04ab16d1d8ea4fc37480741e6351064a3e1a6") + if err != nil { + t.Fatal(err) + } + v, err := UnmarshalTolk(currCell[0], ty) + if err != nil { + t.Fatal(err) + } + + newCell := boc.NewCell() + err = MarshalTolk(newCell, v) + if err != nil { + t.Error(err) + } + + oldHs, err := currCell[0].HashString() + if err != nil { + t.Fatal(err) + } + newHs, err := newCell.HashString() + if err != nil { + t.Fatal(err) + } + if oldHs != newHs { + t.Errorf("input and output cells are different") + } +} + +func TestRuntime_MarshalNotExitsOptionalAddress(t *testing.T) { + ty := Ty{ + SumType: "AddressOpt", + AddressOpt: &AddressOpt{}, + } + + currCell, err := boc.DeserializeBocHex("b5ee9c724101010100030000012094418655") + if err != nil { + t.Fatal(err) + } + v, err := UnmarshalTolk(currCell[0], ty) + if err != nil { + t.Fatal(err) + } + + newCell := boc.NewCell() + err = MarshalTolk(newCell, v) + if err != nil { + t.Error(err) + } + + oldHs, err := currCell[0].HashString() + if err != nil { + t.Fatal(err) + } + newHs, err := newCell.HashString() + if err != nil { + t.Fatal(err) + } + if oldHs != newHs { + t.Errorf("input and output cells are different") + } +} + +func TestRuntime_MarshalExistsOptionalAddress(t *testing.T) { + ty := Ty{ + SumType: "AddressOpt", + AddressOpt: &AddressOpt{}, + } + + currCell, err := boc.DeserializeBocHex("b5ee9c7241010101002400004380107bfaaa5cc6e5368e5f9799188bd798cd22e04ab16d1d8ea4fc37480741e6351064a3e1a6") + if err != nil { + t.Fatal(err) + } + v, err := UnmarshalTolk(currCell[0], ty) + if err != nil { + t.Fatal(err) + } + + newCell := boc.NewCell() + err = MarshalTolk(newCell, v) + if err != nil { + t.Error(err) + } + + oldHs, err := currCell[0].HashString() + if err != nil { + t.Fatal(err) + } + newHs, err := newCell.HashString() + if err != nil { + t.Fatal(err) + } + if oldHs != newHs { + t.Errorf("input and output cells are different") + } +} + +func TestRuntime_MarshalExternalAddress(t *testing.T) { + ty := Ty{ + SumType: "AddressExt", + AddressExt: &AddressExt{}, + } + + currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000600000742082850fcbd94fd") + if err != nil { + t.Fatal(err) + } + v, err := UnmarshalTolk(currCell[0], ty) + if err != nil { + t.Fatal(err) + } + + newCell := boc.NewCell() + err = MarshalTolk(newCell, v) + if err != nil { + t.Error(err) + } + + oldHs, err := currCell[0].HashString() + if err != nil { + t.Fatal(err) + } + newHs, err := newCell.HashString() + if err != nil { + t.Fatal(err) + } + if oldHs != newHs { + t.Errorf("input and output cells are different") + } +} + +func TestRuntime_MarshalAnyNoneAddress(t *testing.T) { + ty := Ty{ + SumType: "AddressAny", + AddressAny: &AddressAny{}, + } + + currCell, err := boc.DeserializeBocHex("b5ee9c724101010100030000012094418655") + if err != nil { + t.Fatal(err) + } + v, err := UnmarshalTolk(currCell[0], ty) + if err != nil { + t.Fatal(err) + } + + newCell := boc.NewCell() + err = MarshalTolk(newCell, v) + if err != nil { + t.Error(err) + } + + oldHs, err := currCell[0].HashString() + if err != nil { + t.Fatal(err) + } + newHs, err := newCell.HashString() + if err != nil { + t.Fatal(err) + } + if oldHs != newHs { + t.Errorf("input and output cells are different") + } +} + +func TestRuntime_MarshalAnyInternalAddress(t *testing.T) { + ty := Ty{ + SumType: "AddressAny", + AddressAny: &AddressAny{}, + } + + currCell, err := boc.DeserializeBocHex("b5ee9c7241010101002400004380107bfaaa5cc6e5368e5f9799188bd798cd22e04ab16d1d8ea4fc37480741e6351064a3e1a6") + if err != nil { + t.Fatal(err) + } + v, err := UnmarshalTolk(currCell[0], ty) + if err != nil { + t.Fatal(err) + } + + newCell := boc.NewCell() + err = MarshalTolk(newCell, v) + if err != nil { + t.Error(err) + } + + oldHs, err := currCell[0].HashString() + if err != nil { + t.Fatal(err) + } + newHs, err := newCell.HashString() + if err != nil { + t.Fatal(err) + } + if oldHs != newHs { + t.Errorf("input and output cells are different") + } +} + +func TestRuntime_MarshalAnyExternalAddress(t *testing.T) { + ty := Ty{ + SumType: "AddressAny", + AddressAny: &AddressAny{}, + } + + currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000600000742082850fcbd94fd") + if err != nil { + t.Fatal(err) + } + v, err := UnmarshalTolk(currCell[0], ty) + if err != nil { + t.Fatal(err) + } + + newCell := boc.NewCell() + err = MarshalTolk(newCell, v) + if err != nil { + t.Error(err) + } + + oldHs, err := currCell[0].HashString() + if err != nil { + t.Fatal(err) + } + newHs, err := newCell.HashString() + if err != nil { + t.Fatal(err) + } + if oldHs != newHs { + t.Errorf("input and output cells are different") + } +} + +func TestRuntime_MarshalAnyVarAddress(t *testing.T) { + ty := Ty{ + SumType: "AddressAny", + AddressAny: &AddressAny{}, + } + + currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000900000dc0800000000ab8d04726e4") + if err != nil { + t.Fatal(err) + } + v, err := UnmarshalTolk(currCell[0], ty) + if err != nil { + t.Fatal(err) + } + + newCell := boc.NewCell() + err = MarshalTolk(newCell, v) + if err != nil { + t.Error(err) + } + + oldHs, err := currCell[0].HashString() + if err != nil { + t.Fatal(err) + } + newHs, err := newCell.HashString() + if err != nil { + t.Fatal(err) + } + if oldHs != newHs { + t.Errorf("input and output cells are different") + } +} + +func TestRuntime_MarshalNotExistsNullable(t *testing.T) { + ty := Ty{ + SumType: "Nullable", + Nullable: &Nullable{ + Inner: Ty{ + SumType: "Remaining", + Remaining: &Remaining{}, + }, + }, + } + + currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000300000140f6d24034") + if err != nil { + t.Fatal(err) + } + v, err := UnmarshalTolk(currCell[0], ty) + if err != nil { + t.Fatal(err) + } + + newCell := boc.NewCell() + err = MarshalTolk(newCell, v) + if err != nil { + t.Error(err) + } + + oldHs, err := currCell[0].HashString() + if err != nil { + t.Fatal(err) + } + newHs, err := newCell.HashString() + if err != nil { + t.Fatal(err) + } + if oldHs != newHs { + t.Errorf("input and output cells are different") + } +} + +func TestRuntime_MarshalExistsNullable(t *testing.T) { + ty := Ty{ + SumType: "Nullable", + Nullable: &Nullable{ + Inner: Ty{ + SumType: "Cell", + Cell: &Cell{}, + }, + }, + } + + currCell, err := boc.DeserializeBocHex("b5ee9c7241010201000b000101c001000900000c0ae007880db9") + if err != nil { + t.Fatal(err) + } + v, err := UnmarshalTolk(currCell[0], ty) + if err != nil { + t.Fatal(err) + } + + newCell := boc.NewCell() + err = MarshalTolk(newCell, v) + if err != nil { + t.Error(err) + } + + oldHs, err := currCell[0].HashString() + if err != nil { + t.Fatal(err) + } + newHs, err := newCell.HashString() + if err != nil { + t.Fatal(err) + } + if oldHs != newHs { + t.Errorf("input and output cells are different") + } +} + +func TestRuntime_MarshalRef(t *testing.T) { + ty := Ty{ + SumType: "CellOf", + CellOf: &CellOf{ + Inner: Ty{ + SumType: "IntN", + IntN: &IntN{ + N: 65, + }, + }, + }, + } + + currCell, err := boc.DeserializeBocHex("b5ee9c7241010201000e000100010011000000000009689e40e150b4c5") + if err != nil { + t.Fatal(err) + } + v, err := UnmarshalTolk(currCell[0], ty) + if err != nil { + t.Fatal(err) + } + + newCell := boc.NewCell() + err = MarshalTolk(newCell, v) + if err != nil { + t.Error(err) + } + + oldHs, err := currCell[0].HashString() + if err != nil { + t.Fatal(err) + } + newHs, err := newCell.HashString() + if err != nil { + t.Fatal(err) + } + if oldHs != newHs { + t.Errorf("input and output cells are different") + } +} + +func TestRuntime_MarshalEmptyTensor(t *testing.T) { + ty := Ty{ + SumType: "Tensor", + Tensor: &Tensor{}, + } + + currCell, err := boc.DeserializeBocHex("b5ee9c724101010100020000004cacb9cd") + if err != nil { + t.Fatal(err) + } + v, err := UnmarshalTolk(currCell[0], ty) + if err != nil { + t.Fatal(err) + } + + newCell := boc.NewCell() + err = MarshalTolk(newCell, v) + if err != nil { + t.Error(err) + } + + oldHs, err := currCell[0].HashString() + if err != nil { + t.Fatal(err) + } + newHs, err := newCell.HashString() + if err != nil { + t.Fatal(err) + } + if oldHs != newHs { + t.Errorf("input and output cells are different") + } +} + +func TestRuntime_MarshalTensor(t *testing.T) { + ty := Ty{ + SumType: "Tensor", + Tensor: &Tensor{ + Items: []Ty{ + { + SumType: "UintN", + UintN: &UintN{ + N: 123, + }, + }, + { + SumType: "Bool", + Bool: &Bool{}, + }, + { + SumType: "Coins", + Coins: &Coins{}, + }, + { + SumType: "Tensor", + Tensor: &Tensor{ + Items: []Ty{ + { + SumType: "IntN", + IntN: &IntN{ + N: 23, + }, + }, + { + SumType: "Nullable", + Nullable: &Nullable{ + Inner: Ty{ + SumType: "IntN", + IntN: &IntN{ + N: 2, + }, + }, + }, + }, + }, + }, + }, + { + SumType: "VarIntN", + VarIntN: &VarIntN{ + N: 32, + }, + }, + }, + }, + } + + currCell, err := boc.DeserializeBocHex("b5ee9c7241010101001f00003900000000000000000000000000021cb43b9aca00fffd550bfbaae07401a2a98117") + if err != nil { + t.Fatal(err) + } + v, err := UnmarshalTolk(currCell[0], ty) + if err != nil { + t.Fatal(err) + } + + newCell := boc.NewCell() + err = MarshalTolk(newCell, v) + if err != nil { + t.Error(err) + } + + oldHs, err := currCell[0].HashString() + if err != nil { + t.Fatal(err) + } + newHs, err := newCell.HashString() + if err != nil { + t.Fatal(err) + } + if oldHs != newHs { + t.Errorf("input and output cells are different") + } +} + +func TestRuntime_MarshalIntKeyMap(t *testing.T) { + ty := Ty{ + SumType: "Map", + Map: &Map{ + K: Ty{ + SumType: "IntN", + IntN: &IntN{ + N: 32, + }, + }, + V: Ty{ + SumType: "Bool", + Bool: &Bool{}, + }, + }, + } + + currCell, err := boc.DeserializeBocHex("b5ee9c7241010201000c000101c001000ba00000007bc09a662c32") + if err != nil { + t.Fatal(err) + } + v, err := UnmarshalTolk(currCell[0], ty) + if err != nil { + t.Fatal(err) + } + + newCell := boc.NewCell() + err = MarshalTolk(newCell, v) + if err != nil { + t.Error(err) + } + + oldHs, err := currCell[0].HashString() + if err != nil { + t.Fatal(err) + } + newHs, err := newCell.HashString() + if err != nil { + t.Fatal(err) + } + if oldHs != newHs { + t.Errorf("input and output cells are different") + } +} + +func TestRuntime_MarshalUIntKeyMap(t *testing.T) { + ty := Ty{ + SumType: "Map", + Map: &Map{ + K: Ty{ + SumType: "UintN", + UintN: &UintN{ + N: 16, + }, + }, + V: Ty{ + SumType: "Address", + Address: &Address{}, + }, + }, + } + + currCell, err := boc.DeserializeBocHex("b5ee9c72410104010053000101c0010202cb02030045a7400b113a994b5024a16719f69139328eb759596c38a25f59028b146fecdc3621dfe80045a3cff5555555555555555555555555555555555555555555555555555555555555555888440ce8") + if err != nil { + t.Fatal(err) + } + v, err := UnmarshalTolk(currCell[0], ty) + if err != nil { + t.Fatal(err) + } + + newCell := boc.NewCell() + err = MarshalTolk(newCell, v) + if err != nil { + t.Fatal(err) + } + + oldHs, err := currCell[0].HashString() + if err != nil { + t.Fatal(err) + } + newHs, err := newCell.HashString() + if err != nil { + t.Fatal(err) + } + if oldHs != newHs { + t.Errorf("input and output cells are different") + } +} + +func TestRuntime_MarshalBigIntKeyMap(t *testing.T) { + ty := Ty{ + SumType: "Map", + Map: &Map{ + K: Ty{ + SumType: "UintN", + UintN: &UintN{ + N: 78, + }, + }, + V: Ty{ + SumType: "Cell", + Cell: &Cell{}, + }, + }, + } + + currCell, err := boc.DeserializeBocHex("b5ee9c7241010301001a000101c0010115a70000000000000047550902000b000000001ab01d5bf1a9") + if err != nil { + t.Fatal(err) + } + v, err := UnmarshalTolk(currCell[0], ty) + if err != nil { + t.Fatal(err) + } + + newCell := boc.NewCell() + err = MarshalTolk(newCell, v) + if err != nil { + t.Error(err) + } + + oldHs, err := currCell[0].HashString() + if err != nil { + t.Fatal(err) + } + newHs, err := newCell.HashString() + if err != nil { + t.Fatal(err) + } + if oldHs != newHs { + t.Errorf("input and output cells are different") + } +} + +func TestRuntime_MarshalBitsKeyMap(t *testing.T) { + ty := Ty{ + SumType: "Map", + Map: &Map{ + K: Ty{ + SumType: "BitsN", + BitsN: &BitsN{ + N: 16, + }, + }, + V: Ty{ + SumType: "Map", + Map: &Map{ + K: Ty{ + SumType: "IntN", + IntN: &IntN{ + N: 64, + }, + }, + V: Ty{ + SumType: "Tensor", + Tensor: &Tensor{ + Items: []Ty{ + { + SumType: "Address", + Address: &Address{}, + }, + { + SumType: "Coins", + Coins: &Coins{}, + }, + }, + }, + }, + }, + }, + }, + } + + currCell, err := boc.DeserializeBocHex("b5ee9c7241010301003b000101c0010106a0828502005ea0000000000000003e400b113a994b5024a16719f69139328eb759596c38a25f59028b146fecdc3621dfe43b9aca00b89cdc86") + if err != nil { + t.Fatal(err) + } + v, err := UnmarshalTolk(currCell[0], ty) + if err != nil { + t.Fatal(err) + } + + newCell := boc.NewCell() + err = MarshalTolk(newCell, v) + if err != nil { + t.Error(err) + } + + oldHs, err := currCell[0].HashString() + if err != nil { + t.Fatal(err) + } + newHs, err := newCell.HashString() + if err != nil { + t.Fatal(err) + } + if oldHs != newHs { + t.Errorf("input and output cells are different") + } +} + +func TestRuntime_MarshalAddressKeyMap(t *testing.T) { + ty := Ty{ + SumType: "Map", + Map: &Map{ + K: Ty{ + SumType: "Address", + Address: &Address{}, + }, + V: Ty{ + SumType: "Coins", + Coins: &Coins{}, + }, + }, + } + + currCell, err := boc.DeserializeBocHex("b5ee9c7241010201002f000101c0010051a17002c44ea652d4092859c67da44e4ca3add6565b0e2897d640a2c51bfb370d8877f9409502f9002016fdc16e") + if err != nil { + t.Fatal(err) + } + v, err := UnmarshalTolk(currCell[0], ty) + if err != nil { + t.Fatal(err) + } + + newCell := boc.NewCell() + err = MarshalTolk(newCell, v) + if err != nil { + t.Error(err) + } + + oldHs, err := currCell[0].HashString() + if err != nil { + t.Fatal(err) + } + newHs, err := newCell.HashString() + if err != nil { + t.Fatal(err) + } + if oldHs != newHs { + t.Errorf("input and output cells are different") + } +} + +func TestRuntime_MarshalUnionWithDecPrefix(t *testing.T) { + ty := Ty{ + SumType: "Union", + Union: &Union{ + Variants: []UnionVariant{ + { + PrefixStr: "0", + PrefixLen: 1, + PrefixEatInPlace: true, + VariantTy: Ty{ + SumType: "IntN", + IntN: &IntN{ + N: 16, + }, + }, + }, + { + PrefixStr: "1", + PrefixLen: 1, + PrefixEatInPlace: true, + VariantTy: Ty{ + SumType: "IntN", + IntN: &IntN{ + N: 128, + }, + }, + }, + }, + }, + } + + currCell, err := boc.DeserializeBocHex("b5ee9c7241010101001300002180000000000000000000000003b5577dc0660d6029") + if err != nil { + t.Fatal(err) + } + v, err := UnmarshalTolk(currCell[0], ty) + if err != nil { + t.Fatal(err) + } + + newCell := boc.NewCell() + err = MarshalTolk(newCell, v) + if err != nil { + t.Error(err) + } + + oldHs, err := currCell[0].HashString() + if err != nil { + t.Fatal(err) + } + newHs, err := newCell.HashString() + if err != nil { + t.Fatal(err) + } + if oldHs != newHs { + t.Errorf("input and output cells are different") + } +} + +func TestRuntime_MarshalUnionWithBinPrefix(t *testing.T) { + inputFilename := "testdata/bin_union.json" + data, err := os.ReadFile(inputFilename) + if err != nil { + t.Fatal(err) + } + + var abi ABI + err = json.Unmarshal(data, &abi) + if err != nil { + t.Fatal(err) + } + + ty := Ty{ + SumType: "Union", + Union: &Union{ + Variants: []UnionVariant{ + { + PrefixStr: "0b001", + PrefixLen: 3, + VariantTy: Ty{ + SumType: "StructRef", + StructRef: &StructRef{ + StructName: "AddressWithPrefix", + }, + }, + }, + { + PrefixStr: "0b011", + PrefixLen: 3, + VariantTy: Ty{ + SumType: "StructRef", + StructRef: &StructRef{ + StructName: "MapWithPrefix", + }, + }, + }, + { + PrefixStr: "0b111", + PrefixLen: 3, + VariantTy: Ty{ + SumType: "StructRef", + StructRef: &StructRef{ + StructName: "CellWithPrefix", + }, + }, + }, + }, + }, + } + + currCell, err := boc.DeserializeBocHex("b5ee9c7241010201002e0001017801004fa17002c44ea652d4092859c67da44e4ca3add6565b0e2897d640a2c51bfb370d8877f900a4d89920c413c650") + if err != nil { + t.Fatal(err) + } + decoder := NewDecoder() + decoder.WithABI(abi) + v, err := decoder.UnmarshalTolk(currCell[0], ty) + if err != nil { + t.Fatal(err) + } + + newCell := boc.NewCell() + err = MarshalTolk(newCell, v) + if err != nil { + t.Error(err) + } + + oldHs, err := currCell[0].HashString() + if err != nil { + t.Fatal(err) + } + newHs, err := newCell.HashString() + if err != nil { + t.Fatal(err) + } + if oldHs != newHs { + t.Errorf("input and output cells are different") + } +} + +func TestRuntime_MarshalUnionWithHexPrefix(t *testing.T) { + inputFilename := "testdata/hex_union.json" + data, err := os.ReadFile(inputFilename) + if err != nil { + t.Fatal(err) + } + + var abi ABI + err = json.Unmarshal(data, &abi) + if err != nil { + t.Fatal(err) + } + + ty := Ty{ + SumType: "Union", + Union: &Union{ + Variants: []UnionVariant{ + { + PrefixStr: "0x12345678", + PrefixLen: 32, + VariantTy: Ty{ + SumType: "StructRef", + StructRef: &StructRef{ + StructName: "UInt66WithPrefix", + }, + }, + }, + { + PrefixStr: "0xdeadbeef", + PrefixLen: 32, + VariantTy: Ty{ + SumType: "StructRef", + StructRef: &StructRef{ + StructName: "UInt33WithPrefix", + }, + }, + }, + { + PrefixStr: "0x89abcdef", + PrefixLen: 32, + VariantTy: Ty{ + SumType: "StructRef", + StructRef: &StructRef{ + StructName: "UInt4WithPrefix", + }, + }, + }, + }, + }, + } + + currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000b000011deadbeef00000000c0d75977b9") + if err != nil { + t.Fatal(err) + } + decoder := NewDecoder() + decoder.WithABI(abi) + v, err := decoder.UnmarshalTolk(currCell[0], ty) + if err != nil { + t.Fatal(err) + } + + newCell := boc.NewCell() + err = MarshalTolk(newCell, v) + if err != nil { + t.Error(err) + } + + oldHs, err := currCell[0].HashString() + if err != nil { + t.Fatal(err) + } + newHs, err := newCell.HashString() + if err != nil { + t.Fatal(err) + } + if oldHs != newHs { + t.Errorf("input and output cells are different") + } +} + +func TestRuntime_MarshalALotRefsFromAlias(t *testing.T) { + inputFilename := "testdata/refs.json" + data, err := os.ReadFile(inputFilename) + if err != nil { + t.Fatal(err) + } + + var abi ABI + err = json.Unmarshal(data, &abi) + if err != nil { + t.Fatal(err) + } + + ty := Ty{ + SumType: "AliasRef", + AliasRef: &AliasRef{ + AliasName: "GoodNamingForMsg", + }, + } + + currCell, err := boc.DeserializeBocHex("b5ee9c724101040100b7000377deadbeef80107bfaaa5cc6e5368e5f9799188bd798cd22e04ab16d1d8ea4fc37480741e635087735940143ffffffffffffffffffffffffffff63c006010203004b80010df454cebee868f611ba8c0d4a9371fb73105396505783293a7625f75db3b9880bebc20100438006e05909e22b2e5e6087533314ee56505f85212914bd5547941a2a658ac62fe101004f801622753296a04942ce33ed2272651d6eb2b2d87144beb2051628dfd9b86c43bfcc12309ce54001e09a48b8") + if err != nil { + t.Fatal(err) + } + decoder := NewDecoder() + decoder.WithABI(abi) + v, err := decoder.UnmarshalTolk(currCell[0], ty) + if err != nil { + t.Fatal(err) + } + + newCell := boc.NewCell() + err = MarshalTolk(newCell, v) + if err != nil { + t.Fatal(err) + } + + cb := currCell[0].Refs()[0].RawBitString() + fmt.Println(cb.BinaryString()) + + nb := newCell.Refs()[0].RawBitString() + fmt.Println(nb.BinaryString()) + + oldHs, err := currCell[0].HashString() + if err != nil { + t.Fatal(err) + } + newHs, err := newCell.HashString() + if err != nil { + t.Fatal(err) + } + if oldHs != newHs { + t.Errorf("input and output cells are different") + } +} + +func TestRuntime_MarshalALotRefsFromStruct(t *testing.T) { + inputFilename := "testdata/refs.json" + data, err := os.ReadFile(inputFilename) + if err != nil { + t.Fatal(err) + } + + var abi ABI + err = json.Unmarshal(data, &abi) + if err != nil { + t.Fatal(err) + } + + ty := Ty{ + SumType: "StructRef", + StructRef: &StructRef{ + StructName: "ManyRefsMsg", + }, + } + + currCell, err := boc.DeserializeBocHex("b5ee9c724101040100b7000377deadbeef80107bfaaa5cc6e5368e5f9799188bd798cd22e04ab16d1d8ea4fc37480741e635087735940143ffffffffffffffffffffffffffff63c006010203004b80010df454cebee868f611ba8c0d4a9371fb73105396505783293a7625f75db3b9880bebc20100438006e05909e22b2e5e6087533314ee56505f85212914bd5547941a2a658ac62fe101004f801622753296a04942ce33ed2272651d6eb2b2d87144beb2051628dfd9b86c43bfcc12309ce54001e09a48b8") + if err != nil { + t.Fatal(err) + } + decoder := NewDecoder() + decoder.WithABI(abi) + v, err := decoder.UnmarshalTolk(currCell[0], ty) + if err != nil { + t.Fatal(err) + } + + newCell := boc.NewCell() + err = MarshalTolk(newCell, v) + if err != nil { + t.Error(err) + } + + oldHs, err := currCell[0].HashString() + if err != nil { + t.Fatal(err) + } + newHs, err := newCell.HashString() + if err != nil { + t.Fatal(err) + } + if oldHs != newHs { + t.Errorf("input and output cells are different") + } +} + +func TestRuntime_MarshalALotGenericsFromStruct(t *testing.T) { + inputFilename := "testdata/generics.json" + data, err := os.ReadFile(inputFilename) + if err != nil { + t.Fatal(err) + } + + var abi ABI + err = json.Unmarshal(data, &abi) + if err != nil { + t.Fatal(err) + } + + ty := Ty{ + SumType: "StructRef", + StructRef: &StructRef{ + StructName: "ManyRefsMsg", + TypeArgs: []Ty{ + { + SumType: "UintN", + UintN: &UintN{ + N: 16, + }, + }, + }, + }, + } + + currCell, err := boc.DeserializeBocHex("b5ee9c72410103010043000217d017d7840343b9aca0000108010200080000007b005543b9aca001017d78402005889d4ca5a81250b38cfb489c99475bacacb61c512fac81458a37f66e1b10eff422fc7647") + if err != nil { + t.Fatal(err) + } + decoder := NewDecoder() + decoder.WithABI(abi) + v, err := decoder.UnmarshalTolk(currCell[0], ty) + if err != nil { + t.Fatal(err) + } + + newCell := boc.NewCell() + err = MarshalTolk(newCell, v) + if err != nil { + t.Error(err) + } + + oldHs, err := currCell[0].HashString() + if err != nil { + t.Fatal(err) + } + newHs, err := newCell.HashString() + if err != nil { + t.Fatal(err) + } + if oldHs != newHs { + t.Errorf("input and output cells are different") + } +} + +func TestRuntime_MarshalALotGenericsFromAlias(t *testing.T) { + inputFilename := "testdata/generics.json" + data, err := os.ReadFile(inputFilename) + if err != nil { + t.Fatal(err) + } + + var abi ABI + err = json.Unmarshal(data, &abi) + if err != nil { + t.Fatal(err) + } + + ty := Ty{ + SumType: "AliasRef", + AliasRef: &AliasRef{ + AliasName: "GoodNamingForMsg", + TypeArgs: []Ty{ + { + SumType: "UintN", + UintN: &UintN{ + N: 16, + }, + }, + }, + }, + } + + currCell, err := boc.DeserializeBocHex("b5ee9c72410103010043000217d017d7840343b9aca0000108010200080000007b005543b9aca001017d78402005889d4ca5a81250b38cfb489c99475bacacb61c512fac81458a37f66e1b10eff422fc7647") + if err != nil { + t.Fatal(err) + } + decoder := NewDecoder() + decoder.WithABI(abi) + v, err := decoder.UnmarshalTolk(currCell[0], ty) + if err != nil { + t.Fatal(err) + } + + newCell := boc.NewCell() + err = MarshalTolk(newCell, v) + if err != nil { + t.Error(err) + } + + oldHs, err := currCell[0].HashString() + if err != nil { + t.Fatal(err) + } + newHs, err := newCell.HashString() + if err != nil { + t.Fatal(err) + } + if oldHs != newHs { + t.Errorf("input and output cells are different") + } +} + +func TestRuntime_MarshalStructWithDefaultValues(t *testing.T) { + inputFilename := "testdata/default_values.json" + data, err := os.ReadFile(inputFilename) + if err != nil { + t.Fatal(err) + } + + var abi ABI + err = json.Unmarshal(data, &abi) + if err != nil { + t.Fatal(err) + } + + ty := Ty{ + SumType: "StructRef", + StructRef: &StructRef{ + StructName: "DefaultTest", + }, + } + + currCell, err := boc.DeserializeBocHex("b5ee9c7241010101003100005d80000002414801622753296a04942ce33ed2272651d6eb2b2d87144beb2051628dfd9b86c43bfd00000156ac2c4c70811a9dde") + if err != nil { + t.Fatal(err) + } + decoder := NewDecoder() + decoder.WithABI(abi) + v, err := decoder.UnmarshalTolk(currCell[0], ty) + if err != nil { + t.Fatal(err) + } + + newCell := boc.NewCell() + err = MarshalTolk(newCell, v) + if err != nil { + t.Error(err) + } + + oldHs, err := currCell[0].HashString() + if err != nil { + t.Fatal(err) + } + newHs, err := newCell.HashString() + if err != nil { + t.Fatal(err) + } + if oldHs != newHs { + t.Errorf("input and output cells are different") + } +} + +func TestRuntime_MarshalALotNumbers(t *testing.T) { + inputFilename := "testdata/numbers.json" + data, err := os.ReadFile(inputFilename) + if err != nil { + t.Fatal(err) + } + + var abi ABI + err = json.Unmarshal(data, &abi) + if err != nil { + t.Fatal(err) + } + + ty := Ty{ + SumType: "StructRef", + StructRef: &StructRef{ + StructName: "Numbers", + }, + } + + currCell, err := boc.DeserializeBocHex("b5ee9c72410101010033000062000000000000000000000000000000000000000000000000000000000000000000000000000000f1106aecc4c800020926dc62f014") + if err != nil { + t.Fatal(err) + } + decoder := NewDecoder() + decoder.WithABI(abi) + v, err := decoder.UnmarshalTolk(currCell[0], ty) + if err != nil { + t.Fatal(err) + } + + newCell := boc.NewCell() + err = MarshalTolk(newCell, v) + if err != nil { + t.Error(err) + } + + oldHs, err := currCell[0].HashString() + if err != nil { + t.Fatal(err) + } + newHs, err := newCell.HashString() + if err != nil { + t.Fatal(err) + } + if oldHs != newHs { + t.Errorf("input and output cells are different") + } +} + +func TestRuntime_MarshalALotRandomFields(t *testing.T) { + inputFilename := "testdata/random_fields.json" + data, err := os.ReadFile(inputFilename) + if err != nil { + t.Fatal(err) + } + + var abi ABI + err = json.Unmarshal(data, &abi) + if err != nil { + t.Fatal(err) + } + + ty := Ty{ + SumType: "StructRef", + StructRef: &StructRef{ + StructName: "RandomFields", + }, + } + + currCell, err := boc.DeserializeBocHex("b5ee9c7241010301007800028b79480107bfaaa5cc6e5368e5f9799188bd798cd22e04ab16d1d8ea4fc37480741e6350e038d7eb37c5e80000000ab50ee6b28000000000000016e4c000006c175300001801bc01020001c00051000000000005120041efeaa9731b94da397e5e64622f5e63348b812ac5b4763a93f0dd201d0798d4409e337ceb") + if err != nil { + t.Fatal(err) + } + decoder := NewDecoder() + decoder.WithABI(abi) + v, err := decoder.UnmarshalTolk(currCell[0], ty) + if err != nil { + t.Fatal(err) + } + + newCell := boc.NewCell() + err = MarshalTolk(newCell, v) + if err != nil { + t.Error(err) + } + + oldHs, err := currCell[0].HashString() + if err != nil { + t.Fatal(err) + } + newHs, err := newCell.HashString() + if err != nil { + t.Fatal(err) + } + if oldHs != newHs { + t.Errorf("input and output cells are different") + } +} diff --git a/tolk/runtime_types.go b/tolk/runtime_types.go new file mode 100644 index 00000000..86f292d3 --- /dev/null +++ b/tolk/runtime_types.go @@ -0,0 +1,1335 @@ +package tolk + +// todo: move this to some package or rename somehow. + +import ( + "bytes" + "fmt" + "maps" + "math/big" + + "github.com/tonkeeper/tongo/boc" +) + +type SumType string + +type TolkPrefix struct { + Len int16 + Prefix uint64 +} + +type Struct struct { + hasPrefix bool + prefix TolkPrefix + field map[string]Value +} + +func (s *Struct) GetField(field string) (Value, bool) { + val, ok := s.field[field] + return val, ok +} + +// SetField set new value only if types are the same +func (s *Struct) SetField(field string, v Value) bool { + s.field[field] = v + return true +} + +func (s *Struct) RemoveField(field string) { + delete(s.field, field) +} + +func (s *Struct) GetPrefix() (TolkPrefix, bool) { + if !s.hasPrefix { + return TolkPrefix{}, false + } + + return s.prefix, true +} + +func (s *Struct) Equal(o any) bool { + otherStruct, ok := o.(Struct) + if !ok { + return false + } + if s.hasPrefix != otherStruct.hasPrefix { + return false + } + if s.hasPrefix { + if s.prefix != otherStruct.prefix { + return false + } + } + return maps.Equal(s.field, otherStruct.field) +} + +type Value struct { + sumType SumType + bool *BoolValue + smallInt *Int64 + smallUint *UInt64 + bigInt *BigInt + bigUint *BigUInt + varInt *VarInt + varUint *VarUInt + coins *CoinsValue + bits *Bits + cell *Any + remaining *RemainingValue + internalAddress *InternalAddress + optionalAddress *OptionalAddress + externalAddress *ExternalAddress + anyAddress *AnyAddress + optionalValue *OptValue + refValue *RefValue + tupleWith *TupleValues + tensor *TensorValues + mp *MapValue + structValue *Struct + alias *AliasValue + enum *EnumValue + generic *GenericValue + union *UnionValue + null *NullValue + void *VoidValue +} + +func (v *Value) GetBool() (bool, bool) { + if v.bool == nil { + return false, false + } + return bool(*v.bool), true +} + +func (v *Value) GetSmallInt() (int64, bool) { + if v.smallInt == nil { + return 0, false + } + return int64(*v.smallInt), true +} + +func (v *Value) GetBigInt() (big.Int, bool) { + if v.bigInt == nil { + return big.Int{}, false + } + return big.Int(*v.bigInt), true +} + +func (v *Value) GetSmallUInt() (uint64, bool) { + if v.smallUint == nil { + return 0, false + } + return uint64(*v.smallUint), true +} + +func (v *Value) GetBigUInt() (big.Int, bool) { + if v.bigUint == nil { + return big.Int{}, false + } + return big.Int(*v.bigUint), true +} + +func (v *Value) GetVarInt() (big.Int, bool) { + if v.varInt == nil { + return big.Int{}, false + } + return big.Int(*v.varInt), true +} + +func (v *Value) GetVarUInt() (big.Int, bool) { + if v.varUint == nil { + return big.Int{}, false + } + return big.Int(*v.varUint), true +} + +func (v *Value) GetCoins() (big.Int, bool) { + if v.coins == nil { + return big.Int{}, false + } + return big.Int(*v.coins), true +} + +func (v *Value) GetBits() (boc.BitString, bool) { + if v.bits == nil { + return boc.BitString{}, false + } + return boc.BitString(*v.bits), true +} + +func (v *Value) GetAddress() (InternalAddress, bool) { + if v.internalAddress == nil { + return InternalAddress{}, false + } + return *v.internalAddress, true +} + +func (v *Value) GetOptionalAddress() (OptionalAddress, bool) { + if v.optionalAddress == nil { + return OptionalAddress{}, false + } + return *v.optionalAddress, true +} + +func (v *Value) GetExternalAddress() (ExternalAddress, bool) { + if v.externalAddress == nil { + return ExternalAddress{}, false + } + return *v.externalAddress, true +} + +func (v *Value) GetAnyAddress() (AnyAddress, bool) { + if v.anyAddress == nil { + return AnyAddress{}, false + } + return *v.anyAddress, true +} + +func (v *Value) GetOptionalValue() (OptValue, bool) { + if v.optionalValue == nil { + return OptValue{}, false + } + return *v.optionalValue, true +} + +func (v *Value) GetRefValue() (Value, bool) { + if v.refValue == nil { + return Value{}, false + } + return Value(*v.refValue), true +} + +func (v *Value) GetTensor() ([]Value, bool) { + if v.tensor == nil { + return TensorValues{}, false + } + return *v.tensor, true +} + +func (v *Value) GetMap() (MapValue, bool) { + if v.mp == nil { + return MapValue{}, false + } + return *v.mp, true +} + +func (v *Value) GetStruct() (Struct, bool) { + if v.structValue == nil { + return Struct{}, false + } + return *v.structValue, true +} + +func (v *Value) GetAlias() (Value, bool) { + if v.alias == nil { + return Value{}, false + } + return Value(*v.alias), true +} + +func (v *Value) GetGeneric() (Value, bool) { + if v.generic == nil { + return Value{}, false + } + return Value(*v.generic), true +} + +func (v *Value) GetEnum() (EnumValue, bool) { + if v.enum == nil { + return EnumValue{}, false + } + return *v.enum, true +} + +func (v *Value) GetUnion() (UnionValue, bool) { + if v.union == nil { + return UnionValue{}, false + } + return *v.union, true +} + +func (v *Value) GetTupleValues() ([]Value, bool) { + if v.tupleWith == nil { + return TupleValues{}, false + } + return *v.tupleWith, true +} + +func (v *Value) GetCell() (boc.Cell, bool) { + if v.cell == nil { + return boc.Cell{}, false + } + return boc.Cell(*v.cell), true +} + +func (v *Value) GetRemaining() (boc.Cell, bool) { + if v.remaining == nil { + return boc.Cell{}, false + } + return boc.Cell(*v.remaining), true +} + +func (v *Value) Equal(o any) bool { + otherValue, ok := o.(Value) + if !ok { + return false + } + + switch v.sumType { + case "bool": + if otherValue.bool == nil { + return false + } + return v.bool.Equal(*otherValue.bool) + case "smallInt": + if otherValue.smallInt == nil { + return false + } + return v.smallInt.Equal(*otherValue.smallInt) + case "smallUint": + if otherValue.smallUint == nil { + return false + } + return v.smallUint.Equal(*otherValue.smallUint) + case "bigInt": + if otherValue.bigInt == nil { + return false + } + return v.bigInt.Equal(*otherValue.bigInt) + case "bigUint": + if otherValue.bigUint == nil { + return false + } + return v.bigUint.Equal(*otherValue.bigUint) + case "varInt": + if otherValue.varInt == nil { + return false + } + return v.varInt.Equal(*otherValue.varInt) + case "varUint": + if otherValue.varUint == nil { + return false + } + return v.varUint.Equal(*otherValue.varUint) + case "coins": + if otherValue.coins == nil { + return false + } + return v.coins.Equal(*otherValue.coins) + case "bits": + if otherValue.bits == nil { + return false + } + return v.bits.Equal(*otherValue.bits) + case "cell": + if otherValue.cell == nil { + return false + } + return v.cell.Equal(*otherValue.cell) + case "remaining": + if otherValue.remaining == nil { + return false + } + return v.remaining.Equal(*otherValue.remaining) + case "internalAddress": + if otherValue.internalAddress == nil { + return false + } + return v.internalAddress.Equal(*otherValue.internalAddress) + case "optionalAddress": + if otherValue.optionalAddress == nil { + return false + } + return v.optionalAddress.Equal(*otherValue.optionalAddress) + case "externalAddress": + if otherValue.externalAddress == nil { + return false + } + return v.externalAddress.Equal(*otherValue.externalAddress) + case "anyAddress": + if otherValue.anyAddress == nil { + return false + } + return v.anyAddress.Equal(*otherValue.anyAddress) + case "optionalValue": + if otherValue.optionalValue == nil { + return false + } + return v.optionalValue.Equal(*otherValue.optionalValue) + case "refValue": + if otherValue.refValue == nil { + return false + } + return v.refValue.Equal(*otherValue.refValue) + case "tupleWith": + if otherValue.tupleWith == nil { + return false + } + return v.tupleWith.Equal(*otherValue.tupleWith) + case "tensor": + if otherValue.tensor == nil { + return false + } + return v.tensor.Equal(*otherValue.tensor) + case "mp": + if otherValue.mp == nil { + return false + } + return v.mp.Equal(*otherValue.mp) + case "structValue": + if otherValue.structValue == nil { + return false + } + return v.structValue.Equal(*otherValue.structValue) + case "alias": + if otherValue.alias == nil { + return false + } + return v.alias.Equal(*otherValue.alias) + case "enum": + if otherValue.enum == nil { + return false + } + return v.enum.Equal(*otherValue.enum) + case "generic": + if otherValue.generic == nil { + return false + } + return v.generic.Equal(*otherValue.generic) + case "union": + if otherValue.union == nil { + return false + } + return v.union.Equal(*otherValue.union) + case "null": + if otherValue.null == nil { + return false + } + return v.null.Equal(*otherValue.null) + case "void": + if otherValue.void == nil { + return false + } + return v.void.Equal(*otherValue.void) + default: + return false + } +} + +func (v *Value) UnmarshalTolk(cell *boc.Cell, ty Ty, decoder *Decoder) error { + var err error + switch ty.SumType { + case "IntN": + if ty.IntN.N <= 64 { + v.sumType = "smallInt" + def := Int64(0) + v.smallInt = &def + err = v.smallInt.UnmarshalTolk(cell, *ty.IntN, decoder) + } else { + v.sumType = "bigInt" + v.bigInt = &BigInt{} + err = v.bigInt.UnmarshalTolk(cell, *ty.IntN, decoder) + } + case "UintN": + if ty.UintN.N <= 64 { + v.sumType = "smallUint" + def := UInt64(0) + v.smallUint = &def + err = v.smallUint.UnmarshalTolk(cell, *ty.UintN, decoder) + } else { + v.sumType = "bigUint" + v.bigUint = &BigUInt{} + err = v.bigUint.UnmarshalTolk(cell, *ty.UintN, decoder) + } + case "VarIntN": + v.sumType = "varInt" + v.varInt = &VarInt{} + err = v.varInt.UnmarshalTolk(cell, *ty.VarIntN, decoder) + case "VarUintN": + v.sumType = "varUint" + v.varUint = &VarUInt{} + err = v.varUint.UnmarshalTolk(cell, *ty.VarUintN, decoder) + case "BitsN": + v.sumType = "bits" + v.bits = &Bits{} + err = v.bits.UnmarshalTolk(cell, *ty.BitsN, decoder) + case "Nullable": + v.sumType = "optionalValue" + v.optionalValue = &OptValue{} + err = v.optionalValue.UnmarshalTolk(cell, *ty.Nullable, decoder) + case "CellOf": + v.sumType = "refValue" + v.refValue = &RefValue{} + err = v.refValue.UnmarshalTolk(cell, *ty.CellOf, decoder) + case "Tensor": + v.sumType = "tensor" + v.tensor = &TensorValues{} + err = v.tensor.UnmarshalTolk(cell, *ty.Tensor, decoder) + case "TupleWith": + v.sumType = "tupleWith" + v.tupleWith = &TupleValues{} + err = v.tupleWith.UnmarshalTolk(cell, *ty.TupleWith, decoder) + case "Map": + v.sumType = "mp" + v.mp = &MapValue{} + err = v.mp.UnmarshalTolk(cell, *ty.Map, decoder) + case "EnumRef": + v.sumType = "enum" + v.enum = &EnumValue{} + err = v.enum.UnmarshalTolk(cell, *ty.EnumRef, decoder) + case "StructRef": + v.sumType = "structValue" + v.structValue = &Struct{} + err = v.structValue.UnmarshalTolk(cell, *ty.StructRef, decoder) + case "AliasRef": + v.sumType = "alias" + v.alias = &AliasValue{} + err = v.alias.UnmarshalTolk(cell, *ty.AliasRef, decoder) + case "Generic": + v.sumType = "generic" + v.generic = &GenericValue{} + err = v.generic.UnmarshalTolk(cell, *ty.Generic, decoder) + case "Union": + v.sumType = "union" + v.union = &UnionValue{} + err = v.union.UnmarshalTolk(cell, *ty.Union, decoder) + case "Int": + err = fmt.Errorf("int not supported") + case "Coins": + v.sumType = "coins" + v.coins = &CoinsValue{} + err = v.coins.UnmarshalTolk(cell, *ty.Coins, decoder) + case "Bool": + v.sumType = "bool" + def := BoolValue(false) + v.bool = &def + err = v.bool.UnmarshalTolk(cell, *ty.Bool, decoder) + case "Cell": + v.sumType = "cell" + v.cell = &Any{} + err = v.cell.UnmarshalTolk(cell, *ty.Cell, decoder) + case "Slice": + err = fmt.Errorf("slice not supported") + case "Builder": + err = fmt.Errorf("builder not supported") + case "Callable": + err = fmt.Errorf("callable not supported") + case "Remaining": + v.sumType = "remaining" + v.remaining = &RemainingValue{} + err = v.remaining.UnmarshalTolk(cell, *ty.Remaining, decoder) + case "Address": + v.sumType = "internalAddress" + v.internalAddress = &InternalAddress{} + err = v.internalAddress.UnmarshalTolk(cell, *ty.Address, decoder) + case "AddressOpt": + v.sumType = "optionalAddress" + v.optionalAddress = &OptionalAddress{} + err = v.optionalAddress.UnmarshalTolk(cell, *ty.AddressOpt, decoder) + case "AddressExt": + v.sumType = "externalAddress" + v.externalAddress = &ExternalAddress{} + err = v.externalAddress.UnmarshalTolk(cell, *ty.AddressExt, decoder) + case "AddressAny": + v.sumType = "anyAddress" + v.anyAddress = &AnyAddress{} + err = v.anyAddress.UnmarshalTolk(cell, *ty.AddressAny, decoder) + case "TupleAny": + err = fmt.Errorf("tuple any not supported") + case "NullLiteral": + v.sumType = "null" + v.null = &NullValue{} + err = v.null.UnmarshalTolk(cell, *ty.NullLiteral, decoder) + case "Void": + v.sumType = "void" + v.void = &VoidValue{} + err = v.void.UnmarshalTolk(cell, *ty.Void, decoder) + default: + return fmt.Errorf("unknown ty type %q", ty.SumType) + } + if err != nil { + return err + } + return nil +} + +func (v *Value) SetValue(val any, ty Ty) error { + switch ty.SumType { + case "IntN": + bi, ok := val.(BigInt) + if !ok { + return fmt.Errorf("cannot convert %v to BigInt", val) + } + if ty.IntN.N <= 64 { + b := big.Int(bi) + wVal := Int64(b.Int64()) + v.smallInt = &wVal + } else { + v.bigInt = &bi + } + case "UintN": + bi, ok := val.(BigUInt) + if !ok { + return fmt.Errorf("cannot convert %v to BigUInt", val) + } + if ty.UintN.N <= 64 { + b := big.Int(bi) + wVal := UInt64(b.Uint64()) + v.smallUint = &wVal + } else { + v.bigUint = &bi + } + case "VarIntN": + vi, ok := val.(VarInt) + if !ok { + return fmt.Errorf("cannot convert %v to VarInt", val) + } + v.varInt = &vi + case "VarUintN": + vi, ok := val.(VarUInt) + if !ok { + return fmt.Errorf("cannot convert %v to VarUInt", val) + } + v.varUint = &vi + case "BitsN": + b, ok := val.(Bits) + if !ok { + return fmt.Errorf("cannot convert %v to Bits", val) + } + v.bits = &b + case "Nullable": + o, ok := val.(OptValue) + if !ok { + return fmt.Errorf("cannot convert %v to OptValue", val) + } + v.optionalValue = &o + case "CellOf": + r, ok := val.(RefValue) + if !ok { + return fmt.Errorf("cannot convert %v to RefValue", val) + } + v.refValue = &r + case "Tensor": + t, ok := val.(TensorValues) + if !ok { + return fmt.Errorf("cannot convert %v to TensorValues", val) + } + v.tensor = &t + case "TupleWith": + t, ok := val.(TupleValues) + if !ok { + return fmt.Errorf("cannot convert %v to TupleValues", val) + } + v.tupleWith = &t + case "Map": + m, ok := val.(MapValue) + if !ok { + return fmt.Errorf("cannot convert %v to MapValue", val) + } + v.mp = &m + case "EnumRef": + e, ok := val.(EnumValue) + if !ok { + return fmt.Errorf("cannot convert %v to EnumValue", val) + } + v.enum = &e + case "StructRef": + s, ok := val.(Struct) + if !ok { + return fmt.Errorf("cannot convert %v to Struct", val) + } + v.structValue = &s + case "AliasRef": + a, ok := val.(AliasValue) + if !ok { + return fmt.Errorf("cannot convert %v to AliasValue", val) + } + v.alias = &a + case "Generic": + g, ok := val.(GenericValue) + if !ok { + return fmt.Errorf("cannot convert %v to GenericValue", val) + } + v.generic = &g + case "Union": + u, ok := val.(UnionValue) + if !ok { + return fmt.Errorf("cannot convert %v to UnionValue", val) + } + v.union = &u + case "Int": + return fmt.Errorf("int not supported") + case "Coins": + c, ok := val.(CoinsValue) + if !ok { + return fmt.Errorf("cannot convert %v to CoinsValue", val) + } + v.coins = &c + case "Bool": + b, ok := val.(BoolValue) + if !ok { + return fmt.Errorf("cannot convert %v to BoolValue", val) + } + v.bool = &b + case "Cell": + a, ok := val.(Any) + if !ok { + return fmt.Errorf("cannot convert %v to Any", val) + } + v.cell = &a + case "Slice": + return fmt.Errorf("slice not supported") + case "Builder": + return fmt.Errorf("builder not supported") + case "Callable": + return fmt.Errorf("callable not supported") + case "Remaining": + r, ok := val.(RemainingValue) + if !ok { + return fmt.Errorf("cannot convert %v to RemainingValue", val) + } + v.remaining = &r + case "Address": + i, ok := val.(InternalAddress) + if !ok { + return fmt.Errorf("cannot convert %v to InternalAddress", val) + } + v.internalAddress = &i + case "AddressOpt": + o, ok := val.(OptionalAddress) + if !ok { + return fmt.Errorf("cannot convert %v to OptionalAddress", val) + } + v.optionalAddress = &o + case "AddressExt": + e, ok := val.(ExternalAddress) + if !ok { + return fmt.Errorf("cannot convert %v to ExternalAddress", val) + } + v.externalAddress = &e + case "AddressAny": + a, ok := val.(AnyAddress) + if !ok { + return fmt.Errorf("cannot convert %v to AnyAddress", val) + } + v.anyAddress = &a + case "TupleAny": + return fmt.Errorf("tuple any not supported") + case "NullLiteral": + n, ok := val.(NullValue) + if !ok { + return fmt.Errorf("cannot convert %v to NullValue", val) + } + v.null = &n + case "Void": + vo, ok := val.(VoidValue) + if !ok { + return fmt.Errorf("cannot convert %v to VoidValue", val) + } + v.void = &vo + default: + return fmt.Errorf("unknown ty type %q", ty.SumType) + } + return nil +} + +type BoolValue bool + +func (b *BoolValue) Equal(o any) bool { + otherBool, ok := o.(BoolValue) + if !ok { + return false + } + return *b == otherBool +} + +type Any boc.Cell + +func (a *Any) Equal(o any) bool { + other, ok := o.(Any) + if !ok { + return false + } + cellV := boc.Cell(*a) + vHash, err := cellV.HashString() + if err != nil { + return false + } + cellO := boc.Cell(other) + oHash, err := cellO.HashString() + if err != nil { + return false + } + return oHash == vHash +} + +type RemainingValue boc.Cell + +func (r *RemainingValue) Equal(o any) bool { + other, ok := o.(RemainingValue) + if !ok { + return false + } + cellV := boc.Cell(*r) + vHash, err := cellV.HashString() + if err != nil { + return false + } + cellO := boc.Cell(other) + oHash, err := cellO.HashString() + if err != nil { + return false + } + return oHash == vHash +} + +type Int64 int64 + +func (i *Int64) Equal(other any) bool { + otherInt, ok := other.(Int64) + if !ok { + return false + } + return *i == otherInt +} + +type UInt64 uint64 + +func (i *UInt64) Equal(other any) bool { + otherUint, ok := other.(UInt64) + if !ok { + return false + } + return *i == otherUint +} + +type BigInt big.Int + +func (b *BigInt) Equal(other any) bool { + otherBigInt, ok := other.(BigInt) + if !ok { + return false + } + bi := big.Int(*b) + otherBi := big.Int(otherBigInt) + return bi.Cmp(&otherBi) == 0 +} + +type BigUInt big.Int + +func (b *BigUInt) Equal(other any) bool { + otherBigInt, ok := other.(BigUInt) + if !ok { + return false + } + bi := big.Int(*b) + otherBi := big.Int(otherBigInt) + return bi.Cmp(&otherBi) == 0 +} + +type VarInt big.Int + +func (vi *VarInt) Equal(other any) bool { + otherBigInt, ok := other.(VarInt) + if !ok { + return false + } + bi := big.Int(*vi) + otherBi := big.Int(otherBigInt) + return bi.Cmp(&otherBi) == 0 +} + +type VarUInt big.Int + +func (vu *VarUInt) Equal(other any) bool { + otherBigInt, ok := other.(VarUInt) + if !ok { + return false + } + bi := big.Int(*vu) + otherBi := big.Int(otherBigInt) + return bi.Cmp(&otherBi) == 0 +} + +type CoinsValue big.Int + +func (c *CoinsValue) Equal(other any) bool { + otherBigInt, ok := other.(CoinsValue) + if !ok { + return false + } + bi := big.Int(*c) + otherBi := big.Int(otherBigInt) + return bi.Cmp(&otherBi) == 0 +} + +type Bits boc.BitString + +func (b *Bits) Equal(other any) bool { + otherBits, ok := other.(Bits) + if !ok { + return false + } + bs := boc.BitString(*b) + otherBs := boc.BitString(otherBits) + return bytes.Equal(bs.Buffer(), otherBs.Buffer()) +} + +type MapKey Value + +type RefValue Value + +func (r *RefValue) Equal(other any) bool { + otherRefValue, ok := other.(RefValue) + if !ok { + return false + } + return r.Equal(otherRefValue) +} + +type OptValue struct { + IsExists bool + Val Value +} + +func (o *OptValue) Equal(other any) bool { + otherOptValue, ok := other.(OptValue) + if !ok { + return false + } + if o.IsExists != otherOptValue.IsExists { + return false + } + if o.IsExists { + return o.Val.Equal(otherOptValue.Val) + } + return true +} + +type UnionValue struct { + Prefix TolkPrefix + Val Value +} + +func (u *UnionValue) Equal(other any) bool { + otherUnionValue, ok := other.(UnionValue) + if !ok { + return false + } + if u.Prefix != otherUnionValue.Prefix { + return false + } + return u.Val.Equal(otherUnionValue.Val) +} + +type EnumValue struct { + val Value + Name string + Value big.Int +} + +func (e *EnumValue) Equal(other any) bool { + otherEnumValue, ok := other.(EnumValue) + if !ok { + return false + } + if e.Name != otherEnumValue.Name { + return false + } + if e.Value.Cmp(&otherEnumValue.Value) != 0 { + return false + } + return e.val.Equal(otherEnumValue.val) +} + +type AnyAddress struct { + SumType + InternalAddress *InternalAddress + NoneAddress *NoneAddress + ExternalAddress *ExternalAddress + VarAddress *VarAddress +} + +func (a *AnyAddress) Equal(other any) bool { + otherAnyAddress, ok := other.(AnyAddress) + if !ok { + return false + } + if otherAnyAddress.SumType != a.SumType { + return false + } + switch a.SumType { + case "NoneAddress": + return true + case "InternalAddress": + return a.InternalAddress.Equal(otherAnyAddress.InternalAddress) + case "ExternalAddress": + return a.ExternalAddress.Equal(otherAnyAddress.ExternalAddress) + case "VarAddress": + return a.VarAddress.Equal(otherAnyAddress.VarAddress) + } + return false +} + +type NoneAddress struct { +} + +type ExternalAddress struct { + Len int16 + Address boc.BitString +} + +func (e *ExternalAddress) Equal(other any) bool { + otherExternalAddress, ok := other.(ExternalAddress) + if !ok { + return false + } + if e.Len != otherExternalAddress.Len { + return false + } + return bytes.Equal(e.Address.Buffer(), otherExternalAddress.Address.Buffer()) +} + +type InternalAddress struct { + Workchain int8 + Address [32]byte +} + +func (i *InternalAddress) Equal(other any) bool { + otherInternalAddress, ok := other.(InternalAddress) + if !ok { + return false + } + return *i == otherInternalAddress +} + +func (i *InternalAddress) ToRaw() string { + return fmt.Sprintf("%v:%x", i.Workchain, i.Address) +} + +type VarAddress struct { + Len int16 + Workchain int32 + Address boc.BitString +} + +func (v *VarAddress) Equal(other any) bool { + otherVarAddress, ok := other.(VarAddress) + if !ok { + return false + } + if v.Len != otherVarAddress.Len { + return false + } + if v.Workchain != otherVarAddress.Workchain { + return false + } + return bytes.Equal(v.Address.Buffer(), otherVarAddress.Address.Buffer()) +} + +type OptionalAddress struct { + SumType + NoneAddress NoneAddress + InternalAddress InternalAddress +} + +func (o *OptionalAddress) Equal(other any) bool { + otherOptionalAddress, ok := other.(OptionalAddress) + if !ok { + return false + } + if o.SumType != otherOptionalAddress.SumType { + return false + } + if o.SumType == "InternalAddress" { + return o.InternalAddress.Equal(otherOptionalAddress.InternalAddress) + } + return true +} + +type TupleValues []Value + +func (v *TupleValues) Equal(other any) bool { + otherTupleValues, ok := other.(TupleValues) + if !ok { + return false + } + wV := *v + if len(otherTupleValues) != len(wV) { + return false + } + for i := range wV { + if !wV[i].Equal(otherTupleValues[i]) { + return false + } + } + return true +} + +type TensorValues []Value + +func (v *TensorValues) Equal(other any) bool { + otherTensorValues, ok := other.(TensorValues) + if !ok { + return false + } + wV := *v + if len(otherTensorValues) != len(wV) { + return false + } + for i := range wV { + if !wV[i].Equal(otherTensorValues[i]) { + return false + } + } + return true +} + +type MapValue struct { + keys []Value + values []Value + len int +} + +func (m *MapValue) Equal(other any) bool { + otherMapValue, ok := other.(MapValue) + if !ok { + return false + } + if m.len != otherMapValue.len { + return false + } + for i := range m.keys { + if !m.keys[i].Equal(otherMapValue.keys[i]) { + return false + } + if !m.values[i].Equal(otherMapValue.values[i]) { + return false + } + } + return true +} + +func (m *MapValue) Get(key MapKey) (Value, bool) { + for i, k := range m.keys { + if k.Equal(Value(key)) { + return m.values[i], true + } + } + + return Value{}, false +} + +func (m *MapValue) GetBySmallInt(v Int64) (Value, bool) { + key := MapKey{ + sumType: "smallInt", + smallInt: &v, + } + return m.Get(key) +} + +func (m *MapValue) GetBySmallUInt(v UInt64) (Value, bool) { + key := MapKey{ + sumType: "smallUint", + smallUint: &v, + } + return m.Get(key) +} + +func (m *MapValue) GetByBigInt(v BigInt) (Value, bool) { + key := MapKey{ + sumType: "bigInt", + bigInt: &v, + } + return m.Get(key) +} + +func (m *MapValue) GetByBigUInt(v BigUInt) (Value, bool) { + key := MapKey{ + sumType: "bigUint", + bigUint: &v, + } + return m.Get(key) +} + +func (m *MapValue) GetByBits(v Bits) (Value, bool) { + key := MapKey{ + sumType: "bits", + bits: &v, + } + return m.Get(key) +} + +func (m *MapValue) GetByInternalAddress(v InternalAddress) (Value, bool) { + key := MapKey{ + sumType: "internalAddress", + internalAddress: &v, + } + return m.Get(key) +} + +func (m *MapValue) Set(key MapKey, value Value) (bool, error) { + for i, k := range m.keys { + if k.Equal(Value(key)) { + m.values[i] = value + return true, nil + } + } + + m.keys = append(m.keys, Value(key)) + m.values = append(m.values, value) + m.len++ + return true, nil +} + +func (m *MapValue) SetBySmallInt(k Int64, value Value) (bool, error) { + key := MapKey{ + sumType: "smallInt", + smallInt: &k, + } + return m.Set(key, value) +} + +func (m *MapValue) SetBySmallUInt(k UInt64, value Value) (bool, error) { + key := MapKey{ + sumType: "smallUint", + smallUint: &k, + } + return m.Set(key, value) +} + +func (m *MapValue) SetByBigInt(k BigInt, value Value) (bool, error) { + key := MapKey{ + sumType: "bigInt", + bigInt: &k, + } + return m.Set(key, value) +} + +func (m *MapValue) SetByBigUInt(k BigUInt, value Value) (bool, error) { + key := MapKey{ + sumType: "bigUint", + bigUint: &k, + } + return m.Set(key, value) +} + +func (m *MapValue) SetByBits(k Bits, value Value) (bool, error) { + key := MapKey{ + sumType: "bits", + bits: &k, + } + return m.Set(key, value) +} + +func (m *MapValue) SetByInternalAddress(k InternalAddress, value Value) (bool, error) { + key := MapKey{ + sumType: "internalAddress", + internalAddress: &k, + } + return m.Set(key, value) +} + +func (m *MapValue) Delete(key MapKey) { + for i, k := range m.keys { + if k.Equal(Value(key)) { + m.keys[i] = Value{} + m.values[i] = Value{} + m.len-- + } + } +} + +func (m *MapValue) DeleteBySmallInt(k Int64) { + key := MapKey{ + sumType: "smallInt", + smallInt: &k, + } + m.Delete(key) +} + +func (m *MapValue) DeleteBySmallUInt(k UInt64) { + key := MapKey{ + sumType: "smallUint", + smallUint: &k, + } + m.Delete(key) +} + +func (m *MapValue) DeleteByBigInt(k BigInt) { + key := MapKey{ + sumType: "bigInt", + bigInt: &k, + } + m.Delete(key) +} + +func (m *MapValue) DeleteByBigUInt(k BigUInt) { + key := MapKey{ + sumType: "bigUint", + bigUint: &k, + } + m.Delete(key) +} + +func (m *MapValue) DeleteByBits(k Bits) { + key := MapKey{ + sumType: "bits", + bits: &k, + } + m.Delete(key) +} + +func (m *MapValue) DeleteByInternalAddress(k InternalAddress) { + key := MapKey{ + sumType: "internalAddress", + internalAddress: &k, + } + m.Delete(key) +} + +func (m *MapValue) Len() int { + return m.len +} + +type AliasValue Value + +func (a *AliasValue) Equal(other any) bool { + otherAlias, ok := other.(AliasValue) + if !ok { + return false + } + v := Value(*a) + return v.Equal(Value(otherAlias)) +} + +type GenericValue Value + +func (g *GenericValue) Equal(other any) bool { + otherGeneric, ok := other.(GenericValue) + if !ok { + return false + } + v := Value(*g) + return v.Equal(Value(otherGeneric)) +} + +type NullValue struct{} + +func (n *NullValue) Equal(other any) bool { + _, ok := other.(NullValue) + if !ok { + return false + } + return true +} + +type VoidValue struct{} + +func (v *VoidValue) Equal(other any) bool { + _, ok := other.(VoidValue) + if !ok { + return false + } + return true +} diff --git a/tolk/testdata/bin_union.json b/tolk/testdata/bin_union.json new file mode 100644 index 00000000..8d25bb9d --- /dev/null +++ b/tolk/testdata/bin_union.json @@ -0,0 +1,72 @@ +{ + "contractName": "Test", + "declarations": [ + { + "kind": "Struct", + "name": "AddressWithPrefix", + "prefix": { + "prefixStr": "0b001", + "prefixLen": 3 + }, + "fields": [ + { + "name": "v", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "MapWithPrefix", + "prefix": { + "prefixStr": "0b011", + "prefixLen": 3 + }, + "fields": [ + { + "name": "v", + "ty": { + "kind": "mapKV", + "k": { + "kind": "address" + }, + "v": { + "kind": "coins" + } + } + } + ] + }, + { + "kind": "Struct", + "name": "CellWithPrefix", + "prefix": { + "prefixStr": "0b111", + "prefixLen": 3 + }, + "fields": [ + { + "name": "v", + "ty": { + "kind": "cell" + } + } + ] + } + ], + "incomingMessages": [], + "outgoingMessages": [], + "emittedEvents": [], + "storage": { + "storageTy": { + "kind": "nullLiteral" + } + }, + "getMethods": [], + "thrownErrors": [], + "compilerName": "tolk", + "compilerVersion": "1.2.0", + "codeBoc64": "te6ccgEBAgEAFQABFP8A9KQT9LzyyAsBAAzTMPiR8kA=" +} \ No newline at end of file diff --git a/tolk/testdata/default_values.json b/tolk/testdata/default_values.json new file mode 100644 index 00000000..02b781dc --- /dev/null +++ b/tolk/testdata/default_values.json @@ -0,0 +1,143 @@ +{ + "contractName": "Test", + "declarations": [ + { + "kind": "Alias", + "name": "Int8", + "targetTy": { + "kind": "intN", + "n": 8 + } + }, + { + "kind": "Alias", + "name": "Addr", + "targetTy": { + "kind": "address" + } + }, + { + "kind": "Struct", + "name": "DefaultTest", + "fields": [ + { + "name": "num1", + "ty": { + "kind": "nullable", + "inner": { + "kind": "uintN", + "n": 32 + } + }, + "defaultValue": { + "kind": "int", + "v": "4" + } + }, + { + "name": "num2", + "ty": { + "kind": "nullable", + "inner": { + "kind": "AliasRef", + "aliasName": "Int8" + } + }, + "defaultValue": { + "kind": "int", + "v": "5" + } + }, + { + "name": "addr4", + "ty": { + "kind": "addressOpt" + }, + "defaultValue": { + "kind": "null" + } + }, + { + "name": "addr5", + "ty": { + "kind": "addressOpt" + }, + "defaultValue": { + "kind": "address", + "addr": "0:b113a994b5024a16719f69139328eb759596c38a25f59028b146fecdc3621dfe" + } + }, + { + "name": "tensor6", + "ty": { + "kind": "nullable", + "inner": { + "kind": "tensor", + "items": [ + { + "kind": "intN", + "n": 32 + }, + { + "kind": "bool" + } + ] + } + }, + "defaultValue": { + "kind": "tensor", + "items": [ + { + "kind": "int", + "v": "342" + }, + { + "kind": "bool", + "v": true + } + ] + } + }, + { + "name": "num7", + "ty": { + "kind": "nullable", + "inner": { + "kind": "intN", + "n": 128 + } + }, + "defaultValue": { + "kind": "null" + } + }, + { + "name": "slice3", + "ty": { + "kind": "nullable", + "inner": { + "kind": "remaining" + } + }, + "defaultValue": { + "kind": "slice", + "hex": "616263" + } + } + ] + } + ], + "incomingMessages": [], + "outgoingMessages": [], + "emittedEvents": [], + "storage": { + "storageTy": { + "kind": "nullLiteral" + } + }, + "getMethods": [], + "thrownErrors": [], + "compilerName": "tolk", + "compilerVersion": "1.2.0", + "codeBoc64": "te6ccgEBAgEAFQABFP8A9KQT9LzyyAsBAAzTMPiR8kA=" +} \ No newline at end of file diff --git a/tolk/testdata/generics.json b/tolk/testdata/generics.json new file mode 100644 index 00000000..deb2d0c3 --- /dev/null +++ b/tolk/testdata/generics.json @@ -0,0 +1,297 @@ +{ + "contractName": "Test", + "declarations": [ + { + "kind": "Alias", + "name": "Wrapper", + "targetTy": { + "kind": "genericT", + "nameT": "W" + }, + "typeParams": [ + "W" + ] + }, + { + "kind": "Struct", + "name": "EitherLeft", + "typeParams": [ + "R" + ], + "fields": [ + { + "name": "value", + "ty": { + "kind": "genericT", + "nameT": "R" + } + } + ] + }, + { + "kind": "Struct", + "name": "EitherRight", + "typeParams": [ + "T" + ], + "fields": [ + { + "name": "value", + "ty": { + "kind": "genericT", + "nameT": "T" + } + } + ] + }, + { + "kind": "Alias", + "name": "Either", + "targetTy": { + "kind": "union", + "variants": [ + { + "prefixStr": "0", + "prefixLen": 1, + "prefixEatInPlace": true, + "variantTy": { + "kind": "StructRef", + "structName": "EitherLeft", + "typeArgs": [ + { + "kind": "genericT", + "nameT": "L" + } + ] + } + }, + { + "prefixStr": "1", + "prefixLen": 1, + "prefixEatInPlace": true, + "variantTy": { + "kind": "StructRef", + "structName": "EitherRight", + "typeArgs": [ + { + "kind": "genericT", + "nameT": "R" + } + ] + } + } + ] + }, + "typeParams": [ + "L", + "R" + ] + }, + { + "kind": "Struct", + "name": "EitherRef", + "typeParams": [ + "I" + ], + "fields": [ + { + "name": "value", + "ty": { + "kind": "union", + "variants": [ + { + "prefixStr": "0", + "prefixLen": 1, + "prefixEatInPlace": true, + "variantTy": { + "kind": "genericT", + "nameT": "I" + } + }, + { + "prefixStr": "1", + "prefixLen": 1, + "prefixEatInPlace": true, + "variantTy": { + "kind": "cellOf", + "inner": { + "kind": "genericT", + "nameT": "I" + } + } + } + ] + } + } + ] + }, + { + "kind": "Alias", + "name": "EitherAlias", + "targetTy": { + "kind": "AliasRef", + "aliasName": "Either", + "typeArgs": [ + { + "kind": "genericT", + "nameT": "R" + }, + { + "kind": "genericT", + "nameT": "L" + } + ] + }, + "typeParams": [ + "R", + "L" + ] + }, + { + "kind": "Alias", + "name": "Doubler", + "targetTy": { + "kind": "tensor", + "items": [ + { + "kind": "genericT", + "nameT": "U" + }, + { + "kind": "genericT", + "nameT": "U" + } + ] + }, + "typeParams": [ + "U" + ] + }, + { + "kind": "Struct", + "name": "ManyRefsMsg", + "typeParams": [ + "T" + ], + "fields": [ + { + "name": "payload", + "ty": { + "kind": "StructRef", + "structName": "EitherRef", + "typeArgs": [ + { + "kind": "uintN", + "n": 32 + } + ] + } + }, + { + "name": "either", + "ty": { + "kind": "AliasRef", + "aliasName": "Either", + "typeArgs": [ + { + "kind": "address" + }, + { + "kind": "coins" + } + ] + } + }, + { + "name": "anotherEither", + "ty": { + "kind": "AliasRef", + "aliasName": "EitherAlias", + "typeArgs": [ + { + "kind": "bool" + }, + { + "kind": "tensor", + "items": [ + { + "kind": "bool" + }, + { + "kind": "coins" + } + ] + } + ] + } + }, + { + "name": "doubler", + "ty": { + "kind": "cellOf", + "inner": { + "kind": "AliasRef", + "aliasName": "Doubler", + "typeArgs": [ + { + "kind": "tensor", + "items": [ + { + "kind": "coins" + }, + { + "kind": "addressOpt" + } + ] + } + ] + } + } + }, + { + "name": "myVal", + "ty": { + "kind": "AliasRef", + "aliasName": "Wrapper", + "typeArgs": [ + { + "kind": "genericT", + "nameT": "T" + } + ] + } + } + ] + }, + { + "kind": "Alias", + "name": "GoodNamingForMsg", + "targetTy": { + "kind": "StructRef", + "structName": "ManyRefsMsg", + "typeArgs": [ + { + "kind": "genericT", + "nameT": "T" + } + ] + }, + "typeParams": [ + "T" + ] + } + ], + "incomingMessages": [], + "outgoingMessages": [], + "emittedEvents": [], + "storage": { + "storageTy": { + "kind": "nullLiteral" + } + }, + "getMethods": [], + "thrownErrors": [], + "compilerName": "tolk", + "compilerVersion": "1.2.0", + "codeBoc64": "te6ccgEBAgEAFQABFP8A9KQT9LzyyAsBAAzTMPiR8kA=" +} \ No newline at end of file diff --git a/tolk/testdata/hex_union.json b/tolk/testdata/hex_union.json new file mode 100644 index 00000000..7b7b4120 --- /dev/null +++ b/tolk/testdata/hex_union.json @@ -0,0 +1,69 @@ +{ + "contractName": "Test", + "declarations": [ + { + "kind": "Struct", + "name": "UInt66WithPrefix", + "prefix": { + "prefixStr": "0x12345678", + "prefixLen": 32 + }, + "fields": [ + { + "name": "v", + "ty": { + "kind": "uintN", + "n": 66 + } + } + ] + }, + { + "kind": "Struct", + "name": "UInt33WithPrefix", + "prefix": { + "prefixStr": "0xdeadbeef", + "prefixLen": 32 + }, + "fields": [ + { + "name": "v", + "ty": { + "kind": "uintN", + "n": 33 + } + } + ] + }, + { + "kind": "Struct", + "name": "UInt4WithPrefix", + "prefix": { + "prefixStr": "0x89abcdef", + "prefixLen": 32 + }, + "fields": [ + { + "name": "v", + "ty": { + "kind": "uintN", + "n": 4 + } + } + ] + } + ], + "incomingMessages": [], + "outgoingMessages": [], + "emittedEvents": [], + "storage": { + "storageTy": { + "kind": "nullLiteral" + } + }, + "getMethods": [], + "thrownErrors": [], + "compilerName": "tolk", + "compilerVersion": "1.2.0", + "codeBoc64": "te6ccgEBAgEAFQABFP8A9KQT9LzyyAsBAAzTMPiR8kA=" +} \ No newline at end of file diff --git a/tolk/testdata/numbers.json b/tolk/testdata/numbers.json new file mode 100644 index 00000000..5ba658f6 --- /dev/null +++ b/tolk/testdata/numbers.json @@ -0,0 +1,72 @@ +{ + "contractName": "Test", + "declarations": [ + { + "kind": "Struct", + "name": "Numbers", + "fields": [ + { + "name": "num1", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "num3", + "ty": { + "kind": "uintN", + "n": 256 + } + }, + { + "name": "num4", + "ty": { + "kind": "varuintN", + "n": 32 + } + }, + { + "name": "num5", + "ty": { + "kind": "bool" + } + }, + { + "name": "num7", + "ty": { + "kind": "bitsN", + "n": 16 + } + }, + { + "name": "num8", + "ty": { + "kind": "intN", + "n": 14 + } + }, + { + "name": "num9", + "ty": { + "kind": "varintN", + "n": 16 + } + } + ] + } + ], + "incomingMessages": [], + "outgoingMessages": [], + "emittedEvents": [], + "storage": { + "storageTy": { + "kind": "nullLiteral" + } + }, + "getMethods": [], + "thrownErrors": [], + "compilerName": "tolk", + "compilerVersion": "1.2.0", + "codeBoc64": "te6ccgEBAgEAFQABFP8A9KQT9LzyyAsBAAzTMPiR8kA=" +} \ No newline at end of file diff --git a/tolk/testdata/random_fields.json b/tolk/testdata/random_fields.json new file mode 100644 index 00000000..8dbea0cc --- /dev/null +++ b/tolk/testdata/random_fields.json @@ -0,0 +1,158 @@ +{ + "contractName": "Test", + "declarations": [ + { + "kind": "Alias", + "name": "MyInt32", + "targetTy": { + "kind": "intN", + "n": 32 + } + }, + { + "kind": "Struct", + "name": "RandomFields", + "prefix": { + "prefixStr": "0x794", + "prefixLen": 12 + }, + "fields": [ + { + "name": "dest_int", + "ty": { + "kind": "address" + } + }, + { + "name": "amount", + "ty": { + "kind": "coins" + } + }, + { + "name": "dest_ext", + "ty": { + "kind": "addressAny" + } + }, + { + "name": "intVector", + "ty": { + "kind": "tensor", + "items": [ + { + "kind": "intN", + "n": 32 + }, + { + "kind": "nullable", + "inner": { + "kind": "coins" + } + }, + { + "kind": "uintN", + "n": 64 + } + ] + } + }, + { + "name": "needs_more", + "ty": { + "kind": "cellOf", + "inner": { + "kind": "bool" + } + } + }, + { + "name": "some_payload", + "ty": { + "kind": "cell" + } + }, + { + "name": "my_int", + "ty": { + "kind": "AliasRef", + "aliasName": "MyInt32" + } + }, + { + "name": "some_union", + "ty": { + "kind": "union", + "variants": [ + { + "variantTy": { + "kind": "intN", + "n": 8 + }, + "prefixStr": "0b00", + "prefixLen": 2, + "prefixEatInPlace": true + }, + { + "variantTy": { + "kind": "intN", + "n": 16 + }, + "prefixStr": "0b01", + "prefixLen": 2, + "prefixEatInPlace": true + }, + { + "variantTy": { + "kind": "intN", + "n": 256 + }, + "prefixStr": "0b10", + "prefixLen": 2, + "prefixEatInPlace": true + } + ] + } + }, + { + "name": "default_1", + "ty": { + "kind": "intN", + "n": 16 + }, + "defaultValue": { + "kind": "int", + "v": "1" + } + }, + { + "name": "default_2", + "ty": { + "kind": "nullable", + "inner": { + "kind": "intN", + "n": 16 + } + }, + "defaultValue": { + "kind": "int", + "v": "55" + } + } + ] + } + ], + "incomingMessages": [], + "outgoingMessages": [], + "emittedEvents": [], + "storage": { + "storageTy": { + "kind": "nullLiteral" + } + }, + "getMethods": [], + "thrownErrors": [], + "compilerName": "tolk", + "compilerVersion": "1.2.0", + "codeBoc64": "te6ccgEBAgEAFQABFP8A9KQT9LzyyAsBAAzTMPiR8kA=" +} \ No newline at end of file diff --git a/tolk/testdata/refs.json b/tolk/testdata/refs.json new file mode 100644 index 00000000..33d0b9f4 --- /dev/null +++ b/tolk/testdata/refs.json @@ -0,0 +1,211 @@ +{ + "contractName": "Test", + "declarations": [ + { + "kind": "Struct", + "name": "AddressAndBalance", + "fields": [ + { + "name": "addr", + "ty": { + "kind": "address" + } + }, + { + "name": "balance", + "ty": { + "kind": "coins" + } + } + ] + }, + { + "kind": "Alias", + "name": "GoodNaming", + "targetTy": { + "kind": "StructRef", + "structName": "AddressAndBalance" + } + }, + { + "kind": "Enum", + "name": "Role", + "encodedAs": { + "kind": "uintN", + "n": 1 + }, + "members": [ + { + "name": "Admin", + "value": "0" + }, + { + "name": "Aboba", + "value": "1" + } + ] + }, + { + "kind": "Enum", + "name": "Operation", + "encodedAs": { + "kind": "varuintN", + "n": 16 + }, + "members": [ + { + "name": "Add", + "value": "0" + }, + { + "name": "Sub", + "value": "100000000000000" + } + ] + }, + { + "kind": "Enum", + "name": "Operation2", + "encodedAs": { + "kind": "intN", + "n": 128 + }, + "members": [ + { + "name": "TopUp", + "value": "-10000" + }, + { + "name": "Withdraw", + "value": "10000" + } + ] + }, + { + "kind": "Enum", + "name": "Operation3", + "encodedAs": { + "kind": "uintN", + "n": 8 + }, + "members": [ + { + "name": "Nothing", + "value": "10" + }, + { + "name": "Something", + "value": "1" + } + ] + }, + { + "kind": "Struct", + "name": "ManyRefsMsg", + "prefix": { + "prefixStr": "0xdeadbeef", + "prefixLen": 32 + }, + "fields": [ + { + "name": "user1", + "ty": { + "kind": "AliasRef", + "aliasName": "GoodNaming" + } + }, + { + "name": "user2", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cellOf", + "inner": { + "kind": "AliasRef", + "aliasName": "GoodNaming" + } + } + } + }, + { + "name": "user3", + "ty": { + "kind": "cell" + } + }, + { + "name": "user4", + "ty": { + "kind": "nullable", + "inner": { + "kind": "StructRef", + "structName": "AddressAndBalance" + } + }, + "defaultValue": { + "kind": "null" + } + }, + { + "name": "user5", + "ty": { + "kind": "cellOf", + "inner": { + "kind": "StructRef", + "structName": "AddressAndBalance" + } + } + }, + { + "name": "role", + "ty": { + "kind": "EnumRef", + "enumName": "Role" + } + }, + { + "name": "oper1", + "ty": { + "kind": "EnumRef", + "enumName": "Operation" + } + }, + { + "name": "oper2", + "ty": { + "kind": "EnumRef", + "enumName": "Operation2" + } + }, + { + "name": "oper3", + "ty": { + "kind": "EnumRef", + "enumName": "Operation3" + } + } + ] + }, + { + "kind": "Alias", + "name": "GoodNamingForMsg", + "targetTy": { + "kind": "StructRef", + "structName": "ManyRefsMsg" + } + } + ], + "incomingMessages": [], + "outgoingMessages": [], + "emittedEvents": [], + "storage": { + "storageTy": { + "kind": "nullLiteral" + } + }, + "getMethods": [], + "thrownErrors": [], + "compilerName": "tolk", + "compilerVersion": "1.2.0", + "codeBoc64": "te6ccgEBAgEAFQABFP8A9KQT9LzyyAsBAAzTMPiR8kA=" +} \ No newline at end of file diff --git a/tolk/testdata/simple.json b/tolk/testdata/simple.json new file mode 100644 index 00000000..cb07aa46 --- /dev/null +++ b/tolk/testdata/simple.json @@ -0,0 +1,17 @@ +{ + "contractName": "Test", + "declarations": [], + "incomingMessages": [], + "outgoingMessages": [], + "emittedEvents": [], + "storage": { + "storageTy": { + "kind": "nullLiteral" + } + }, + "getMethods": [], + "thrownErrors": [], + "compilerName": "tolk", + "compilerVersion": "1.2.0", + "codeBoc64": "te6ccgEBAgEAFQABFP8A9KQT9LzyyAsBAAzTMPiR8kA=" +} \ No newline at end of file diff --git a/tolk/tuples.go b/tolk/tuples.go new file mode 100644 index 00000000..48515b2f --- /dev/null +++ b/tolk/tuples.go @@ -0,0 +1,154 @@ +package tolk + +import ( + "fmt" + + "github.com/tonkeeper/tongo/boc" +) + +type Tensor struct { + Items []Ty `json:"items"` +} + +func (Tensor) SetValue(v *Value, val any) error { + t, ok := val.(TensorValues) + if !ok { + return fmt.Errorf("value is not a tensor") + } + v.tensor = &t + v.sumType = "tensor" + return nil +} + +func (t Tensor) UnmarshalTolk(cell *boc.Cell, v *Value, decoder *Decoder) error { + list := make(TensorValues, len(t.Items)) + for i, item := range t.Items { + inner := Value{} + err := inner.UnmarshalTolk(cell, item, decoder) + if err != nil { + return err + } + list[i] = inner + } + err := t.SetValue(v, list) + if err != nil { + return err + } + return nil +} + +func (v *TensorValues) UnmarshalTolk(cell *boc.Cell, ty Tensor, decoder *Decoder) error { + list := make(TensorValues, len(ty.Items)) + for i, item := range ty.Items { + inner := Value{} + err := inner.UnmarshalTolk(cell, item, decoder) + if err != nil { + return err + } + list[i] = inner + } + *v = list + return nil +} + +func (Tensor) MarshalTolk(cell *boc.Cell, v *Value) error { + //if v.tensor == nil { + // return fmt.Errorf("tensor is nil") + //} + // + //for _, tv := range []Value(*v.tensor) { + // err := tv.valType.MarshalTolk(cell, &tv) + // if err != nil { + // return err + // } + //} + + return nil +} + +func (Tensor) Equal(v Value, o Value) bool { + return false +} + +type TupleWith struct { + Items []Ty `json:"items"` +} + +func (TupleWith) SetValue(v *Value, val any) error { + t, ok := val.(TupleValues) + if !ok { + return fmt.Errorf("value is not a tuple") + } + v.tupleWith = &t + v.sumType = "tupleWith" + return nil +} + +func (t TupleWith) UnmarshalTolk(cell *boc.Cell, v *Value, decoder *Decoder) error { + list := make(TupleValues, len(t.Items)) + for i, item := range t.Items { + inner := Value{} + err := inner.UnmarshalTolk(cell, item, decoder) + if err != nil { + return err + } + list[i] = inner + } + err := t.SetValue(v, list) + if err != nil { + return err + } + + return nil +} + +func (v *TupleValues) UnmarshalTolk(cell *boc.Cell, ty TupleWith, decoder *Decoder) error { + list := make(TupleValues, len(ty.Items)) + for i, item := range ty.Items { + inner := Value{} + err := inner.UnmarshalTolk(cell, item, decoder) + if err != nil { + return err + } + list[i] = inner + } + *v = list + return nil +} + +func (TupleWith) MarshalTolk(cell *boc.Cell, v *Value) error { + //if v.tupleWith == nil { + // return fmt.Errorf("tupleWith is nil") + //} + // + //for _, tv := range []Value(*v.tupleWith) { + // err := tv.valType.MarshalTolk(cell, &tv) + // if err != nil { + // return err + // } + //} + + return nil +} + +func (TupleWith) Equal(v Value, o Value) bool { + return false +} + +type TupleAny struct{} + +func (TupleAny) SetValue(v *Value, val any) error { + return fmt.Errorf("tuple any is not supported") +} + +func (TupleAny) UnmarshalTolk(cell *boc.Cell, v *Value, decoder *Decoder) error { + return fmt.Errorf("tuple any is not supported") +} + +func (TupleAny) MarshalTolk(cell *boc.Cell, v *Value) error { + return fmt.Errorf("tuple any is not supported") +} + +func (TupleAny) Equal(v Value, o Value) bool { + return false +} diff --git a/tolk/union.go b/tolk/union.go new file mode 100644 index 00000000..4cc3824d --- /dev/null +++ b/tolk/union.go @@ -0,0 +1,158 @@ +package tolk + +import ( + "fmt" + + "github.com/tonkeeper/tongo/boc" +) + +type Union struct { + Variants []UnionVariant `json:"variants"` +} + +func (Union) SetValue(v *Value, val any) error { + u, ok := val.(UnionValue) + if !ok { + return fmt.Errorf("value is not an union") + } + v.union = &u + v.sumType = "union" + return nil +} + +func (u Union) UnmarshalTolk(cell *boc.Cell, v *Value, decoder *Decoder) error { + unionV := UnionValue{} + if len(u.Variants) < 2 { + return fmt.Errorf("union length must be at least 2") + } + prefixLen := u.Variants[0].PrefixLen + eatPrefix := u.Variants[0].PrefixEatInPlace + if prefixLen > 64 { + // todo: maybe prefix len can be bigger than 64? + return fmt.Errorf("union prefix length must be less than 64") + } + + var prefix uint64 + var err error + if !eatPrefix { + copyCell := cell.CopyRemaining() + prefix, err = copyCell.ReadUint(prefixLen) + if err != nil { + return err + } + } else { + prefix, err = cell.ReadUint(prefixLen) + if err != nil { + return err + } + } + + for _, variant := range u.Variants { + variantPrefix, err := PrefixToUint(variant.PrefixStr) + if err != nil { + return err + } + + if prefix == variantPrefix { + unionV.Prefix = TolkPrefix{ + Len: int16(variant.PrefixLen), + Prefix: prefix, + } + innerV := Value{} + err = innerV.UnmarshalTolk(cell, variant.VariantTy, decoder) + if err != nil { + return err + } + unionV.Val = innerV + err = u.SetValue(v, unionV) + if err != nil { + return err + } + + return nil + } + } + + return fmt.Errorf("none of union prefixes matched") +} + +func (u *UnionValue) UnmarshalTolk(cell *boc.Cell, ty Union, decoder *Decoder) error { + unionV := UnionValue{} + if len(ty.Variants) < 2 { + return fmt.Errorf("union length must be at least 2") + } + prefixLen := ty.Variants[0].PrefixLen + eatPrefix := ty.Variants[0].PrefixEatInPlace + if prefixLen > 64 { + // todo: maybe prefix len can be bigger than 64? + return fmt.Errorf("union prefix length must be less than 64") + } + + var prefix uint64 + var err error + if !eatPrefix { + copyCell := cell.CopyRemaining() + prefix, err = copyCell.ReadUint(prefixLen) + if err != nil { + return err + } + } else { + prefix, err = cell.ReadUint(prefixLen) + if err != nil { + return err + } + } + + for _, variant := range ty.Variants { + variantPrefix, err := PrefixToUint(variant.PrefixStr) + if err != nil { + return err + } + + if prefix == variantPrefix { + unionV.Prefix = TolkPrefix{ + Len: int16(variant.PrefixLen), + Prefix: prefix, + } + innerV := Value{} + err = innerV.UnmarshalTolk(cell, variant.VariantTy, decoder) + if err != nil { + return err + } + unionV.Val = innerV + *u = unionV + + return nil + } + } + + return fmt.Errorf("none of union prefixes matched") +} + +func (u Union) MarshalTolk(cell *boc.Cell, v *Value) error { + //if v.union == nil { + // return fmt.Errorf("union is nil") + //} + //if len(u.Variants) < 2 { + // return fmt.Errorf("union length must be at least 2") + //} + // + //if u.Variants[0].PrefixEatInPlace { + // err := cell.WriteUint(v.union.Prefix.Prefix, int(v.union.Prefix.Len)) + // if err != nil { + // return err + // } + //} + // + //val := v.union.Val + //err := val.valType.MarshalTolk(cell, &val) + //if err != nil { + // return err + //} + + return nil +} + +func (Union) Equal(v Value, o Value) bool { + return false +} diff --git a/tolk/utils.go b/tolk/utils.go new file mode 100644 index 00000000..1aeed3fc --- /dev/null +++ b/tolk/utils.go @@ -0,0 +1,101 @@ +package tolk + +import ( + "errors" + "fmt" + "math/big" + "strconv" +) + +func binHexToUint64(s string) (uint64, error) { + if len(s) <= 2 { + return 0, errors.New("number length must be greater than 2") + } + + if s[1] == 'b' { + val, err := strconv.ParseUint(s[2:], 2, 64) + if err != nil { + return 0, err + } + return val, nil + } else if s[1] == 'x' { + val, err := strconv.ParseUint(s[2:], 16, 64) + if err != nil { + return 0, err + } + return val, nil + } else { + return 0, fmt.Errorf("invalid number base, must be either bin or hex, got") + } +} + +func binDecHexToUint(num string) (*big.Int, error) { + if len(num) == 0 { + return nil, fmt.Errorf("number string is empty") + } + + if len(num) == 1 { + val, ok := new(big.Int).SetString(num, 10) + if !ok { + return nil, fmt.Errorf("canont convert %s to int", num) + } + return val, nil + } + + if num[1] == 'b' { + val, ok := new(big.Int).SetString(num, 2) + if !ok { + return nil, fmt.Errorf("canont convert %s to int", num) + } + return val, nil + } else if num[1] == 'x' { + val, ok := new(big.Int).SetString(num, 16) + if !ok { + return nil, fmt.Errorf("canont convert %s to int", num) + } + return val, nil + } else { + val, ok := new(big.Int).SetString(num, 10) + if !ok { + return nil, fmt.Errorf("canont convert %s to int", num) + } + return val, nil + } +} + +func PrefixToUint(prefix string) (uint64, error) { + if prefix == "" { + return 0, errors.New("invalid prefix") + } + + if len(prefix) == 1 { + intPrefix, err := strconv.ParseUint(prefix, 10, 64) + if err != nil { + return 0, err + } + + return intPrefix, nil + } + + if len(prefix) == 2 { + return 0, fmt.Errorf("prefix tag len must be either 1 or >2") + } + + var intPrefix uint64 + var err error + if prefix[1] == 'b' { + intPrefix, err = strconv.ParseUint(prefix[2:], 2, 64) + if err != nil { + return 0, err + } + } else if prefix[1] == 'x' { + intPrefix, err = strconv.ParseUint(prefix[2:], 16, 64) + if err != nil { + return 0, err + } + } else { + return 0, fmt.Errorf("prefix tag must be either binary or hex format") + } + + return intPrefix, nil +} diff --git a/utils/generator.go b/utils/generator.go index 36d88fe0..ff42509b 100644 --- a/utils/generator.go +++ b/utils/generator.go @@ -52,6 +52,35 @@ func ToCamelCasePrivate(s string) string { return res } +func ToSnakeCase(s string) string { + s = strings.TrimSpace(s) + if s == "" { + return s + } + + n := strings.Builder{} + n.Grow(len(s)) + for i, v := range []byte(s) { + vIsCap := v >= 'A' && v <= 'Z' + vIsLow := v >= 'a' && v <= 'z' + vIsNum := v >= '0' && v <= '9' + + if i != 0 && (vIsCap || v == '_' || v == ' ' || v == '-' || v == '.') { + n.WriteByte('_') + } + + if vIsCap { + v += 'a' + v -= 'A' + } + + if vIsLow || vIsCap || vIsNum { + n.WriteByte(v) + } + } + return n.String() +} + func GetOrderedKeys[M ~map[K]V, K constraints.Ordered, V any](m M) []K { keys := maps.Keys(m) slices.Sort(keys) diff --git a/utils/generator_test.go b/utils/generator_test.go new file mode 100644 index 00000000..916e0600 --- /dev/null +++ b/utils/generator_test.go @@ -0,0 +1,42 @@ +package utils + +import "testing" + +func TestToSnakeCaseString(t *testing.T) { + tests := []struct { + data string + want string + }{ + { + data: "CocoonTest", + want: "cocoon_test", + }, + { + data: "ton.cocoon.test", + want: "ton_cocoon_test", + }, + { + data: "cocoonTest", + want: "cocoon_test", + }, + { + data: "cocoon123Test", + want: "cocoon123_test", + }, + { + data: "Cocoon123test", + want: "cocoon123test", + }, + { + data: "COcoon123Test", + want: "c_ocoon123_test", + }, + } + for _, tt := range tests { + t.Run(tt.data, func(t *testing.T) { + if got := ToSnakeCase(tt.data); got != tt.want { + t.Errorf("ToSnakeCase() = %v, want %v", got, tt.want) + } + }) + } +}