From b7f818040ae964beb7296939b3c5eaddebf796ea Mon Sep 17 00:00:00 2001 From: Pavel Levchenko Date: Tue, 16 Dec 2025 18:52:40 +0300 Subject: [PATCH 01/16] init # Conflicts: # go.mod --- abi-tolk/contracts_errors.go | 89 + abi-tolk/generator.go | 131 + abi-tolk/get_methods.go | 784 ++++ abi-tolk/inspect.go | 319 ++ abi-tolk/inspect_test.go | 219 + abi-tolk/interfaces.go | 375 ++ abi-tolk/messages.go | 388 ++ abi-tolk/messages.md | 62 + abi-tolk/messages_generated.go | 572 +++ abi-tolk/messages_test.go | 30 + abi-tolk/parser/errors.tmpl | 45 + abi-tolk/parser/generator.go | 986 +++++ abi-tolk/parser/get_methods.tmpl | 45 + abi-tolk/parser/interfaces.tmpl | 141 + abi-tolk/parser/messages.md.tmpl | 12 + abi-tolk/parser/messages.tmpl | 60 + abi-tolk/parser/parser.go | 13 + abi-tolk/parser/parser_test.go | 52 + abi-tolk/parser/payloads.tmpl | 93 + abi-tolk/parser/testdata/alot-wrappers.json | 3572 +++++++++++++++++ abi-tolk/parser/testdata/simple.json | 253 ++ abi-tolk/payload.go | 168 + abi-tolk/payload_msg_types.go | 2049 ++++++++++ abi-tolk/payload_test.go | 212 + abi-tolk/schemas/cocoon-client.json | 2012 ++++++++++ abi-tolk/schemas/cocoon-proxy.json | 2063 ++++++++++ abi-tolk/schemas/cocoon_root.json | 2110 ++++++++++ abi-tolk/schemas/cocoon_wallet.json | 1899 +++++++++ abi-tolk/schemas/cocoon_worker.json | 1904 +++++++++ abi-tolk/schemas/coffee-pool.json | 67 + abi-tolk/schemas/dedust-test.json | 118 + abi-tolk/schemas/jetton-minter.json | 646 +++ abi-tolk/schemas/jetton-wallet.json | 655 +++ abi-tolk/schemas/payload-test.json | 2195 ++++++++++ abi-tolk/schemas/stonfi_v1.json | 143 + abi-tolk/schemas/stonfi_v2.json | 140 + abi-tolk/schemas/stonfi_v2_const_prod.json | 147 + abi-tolk/schemas/stonfi_v2_stable_swap.json | 228 ++ .../stonfi_v2_weighted_stable_swap.json | 203 + abi-tolk/types.go | 1371 +++++++ abi-tolk/utils.go | 27 + abi/messages_test.go | 2 +- tlb/address.go | 96 + tlb/decoder.go | 20 +- tlb/integers.go | 144 +- tlb/parser/builtin_generator.go | 40 + tlb/primitives.go | 23 + tlb/stack.go | 8 + tolk/abi/types.go | 539 +++ tolk/parser/parser.go | 682 ++++ utils/generator.go | 29 + utils/generator_test.go | 42 + 52 files changed, 28216 insertions(+), 7 deletions(-) create mode 100644 abi-tolk/contracts_errors.go create mode 100644 abi-tolk/generator.go create mode 100644 abi-tolk/get_methods.go create mode 100644 abi-tolk/inspect.go create mode 100644 abi-tolk/inspect_test.go create mode 100644 abi-tolk/interfaces.go create mode 100644 abi-tolk/messages.go create mode 100644 abi-tolk/messages.md create mode 100644 abi-tolk/messages_generated.go create mode 100644 abi-tolk/messages_test.go create mode 100644 abi-tolk/parser/errors.tmpl create mode 100644 abi-tolk/parser/generator.go create mode 100644 abi-tolk/parser/get_methods.tmpl create mode 100644 abi-tolk/parser/interfaces.tmpl create mode 100644 abi-tolk/parser/messages.md.tmpl create mode 100644 abi-tolk/parser/messages.tmpl create mode 100644 abi-tolk/parser/parser.go create mode 100644 abi-tolk/parser/parser_test.go create mode 100644 abi-tolk/parser/payloads.tmpl create mode 100644 abi-tolk/parser/testdata/alot-wrappers.json create mode 100644 abi-tolk/parser/testdata/simple.json create mode 100644 abi-tolk/payload.go create mode 100644 abi-tolk/payload_msg_types.go create mode 100644 abi-tolk/payload_test.go create mode 100644 abi-tolk/schemas/cocoon-client.json create mode 100644 abi-tolk/schemas/cocoon-proxy.json create mode 100644 abi-tolk/schemas/cocoon_root.json create mode 100644 abi-tolk/schemas/cocoon_wallet.json create mode 100644 abi-tolk/schemas/cocoon_worker.json create mode 100644 abi-tolk/schemas/coffee-pool.json create mode 100644 abi-tolk/schemas/dedust-test.json create mode 100644 abi-tolk/schemas/jetton-minter.json create mode 100644 abi-tolk/schemas/jetton-wallet.json create mode 100644 abi-tolk/schemas/payload-test.json create mode 100644 abi-tolk/schemas/stonfi_v1.json create mode 100644 abi-tolk/schemas/stonfi_v2.json create mode 100644 abi-tolk/schemas/stonfi_v2_const_prod.json create mode 100644 abi-tolk/schemas/stonfi_v2_stable_swap.json create mode 100644 abi-tolk/schemas/stonfi_v2_weighted_stable_swap.json create mode 100644 abi-tolk/types.go create mode 100644 abi-tolk/utils.go create mode 100644 tolk/abi/types.go create mode 100644 tolk/parser/parser.go create mode 100644 utils/generator_test.go 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..5e9b8fde --- /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" + tolkAbi "github.com/tonkeeper/tongo/tolk/abi" +) + +const HEADER = `package abitolk +// Code autogenerated. DO NOT EDIT. + +import ( +%v +) + +` +const SCHEMAS_PATH = "schemas/" + +func mergeMethods(abis []tolkAbi.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 []tolkAbi.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..317406c4 --- /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}, + "seqno": {DecodeTonCocoonWallet_SeqnoResult}, + "get_public_key": {DecodeTonCocoonWallet_GetPublicKeyResult}, + "get_owner_address": {DecodeTonCocoonWallet_GetOwnerAddressResult}, + "get_wallet_data": {DecodeTonTep74JettonWallet_GetWalletDataResult}, + "get_pool_data": {DecodeTonStonfiV1Pool_GetPoolDataResult, DecodeTonStonfiV2PoolConstProduct_GetPoolDataResult, DecodeTonStonfiV2PoolStableSwap_GetPoolDataResult, DecodeTonStonfiV2PoolWeightedStableSwap_GetPoolDataResult}, + "last_proxy_seqno": {DecodeTonCocoonRoot_LastProxySeqnoResult}, + "get_cur_params": {DecodeTonCocoonRoot_GetCurParamsResult}, + "proxy_hash_is_valid": {DecodeTonCocoonRoot_ProxyHashIsValidResult}, + "get_cocoon_worker_data": {DecodeTonCocoonWorker_GetCocoonWorkerDataResult}, + "get_lp_account_address": {DecodeTonStonfiV2Pool_GetLpAccountAddressResult, DecodeTonStonfiV2PoolConstProduct_GetLpAccountAddressResult, DecodeTonStonfiV2PoolStableSwap_GetLpAccountAddressResult, DecodeTonStonfiV2PoolWeightedStableSwap_GetLpAccountAddressResult}, + "get_cocoon_client_data": {DecodeTonCocoonClient_GetCocoonClientDataResult}, + "get_jetton_data": {DecodeTonTep74JettonMinter_GetJettonDataResult}, + "get_cocoon_data": {DecodeTonCocoonRoot_GetCocoonDataResult}, + "get_wallet_address": {DecodeTonTep74JettonMinter_GetWalletAddressResult}, + "get_cocoon_proxy_data": {DecodeTonCocoonProxy_GetCocoonProxyDataResult}, + "worker_hash_is_valid": {DecodeTonCocoonRoot_WorkerHashIsValidResult}, +} + +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{}, + &TonCocoonWallet_SeqnoResult{}, + &TonCocoonWallet_GetPublicKeyResult{}, + &TonCocoonWallet_GetOwnerAddressResult{}, + &TonTep74JettonWallet_GetWalletDataResult{}, + &TonStonfiV1Pool_GetPoolDataResult{}, + &TonStonfiV2PoolConstProduct_GetPoolDataResult{}, + &TonStonfiV2PoolStableSwap_GetPoolDataResult{}, + &TonStonfiV2PoolWeightedStableSwap_GetPoolDataResult{}, + &TonCocoonRoot_LastProxySeqnoResult{}, + &TonCocoonRoot_GetCurParamsResult{}, + &TonCocoonRoot_ProxyHashIsValidResult{}, + &TonCocoonWorker_GetCocoonWorkerDataResult{}, + &TonStonfiV2PoolConstProduct_GetLpAccountAddressResult{}, + &TonStonfiV2PoolStableSwap_GetLpAccountAddressResult{}, + &TonStonfiV2PoolWeightedStableSwap_GetLpAccountAddressResult{}, + &TonStonfiV2Pool_GetLpAccountAddressResult{}, + &TonCocoonClient_GetCocoonClientDataResult{}, + &TonTep74JettonMinter_GetJettonDataResult{}, + &TonCocoonRoot_GetCocoonDataResult{}, + &TonTep74JettonMinter_GetWalletAddressResult{}, + &TonCocoonProxy_GetCocoonProxyDataResult{}, + &TonCocoonRoot_WorkerHashIsValidResult{}, +} + +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 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 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 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 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 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_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_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 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 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 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 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_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 +} + +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 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_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 +} 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////7y9GpSiABACASAAFwBgAgEgABgAPwIBIAAZABsBASAAGgAaxAAAAAIAAAAAAA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IO/0+6rsz3U6T3AoIbe8U6aIvoPUsO4LZGA0smjodKh3NAAAAAAAAAAAAAAAAA2rxsPvwr1058gyCen2VPpZQIosUACASAClAKVAgEgApwCnQIBIAKWApcAgb9cGndssE4S7bcVNIHMFrkiUrizWnT5vI9yfOYIEc45BgAAAAAAAAAAAAAAAdcS6yzbXhkM5DgpcXb79xP5dzOVAIG/CbgwhUMYn2yHU343dcezKkvme3cyFJB7SHVY3FXhU9gAAAAAAAAAAAAAAAIsGpdN2JfQe6dn1Q0grZWLGV+pvgIBIAKYApkCASACmgKbAIG+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..dc3955be --- /dev/null +++ b/abi-tolk/parser/generator.go @@ -0,0 +1,986 @@ +package parser + +import ( + "bytes" + _ "embed" + "fmt" + "go/format" + "slices" + "sort" + "strings" + "text/template" + + "github.com/tonkeeper/tongo/tlb" + tolkAbi "github.com/tonkeeper/tongo/tolk/abi" + 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 tolkAbi.ABI + GetMethod tolkAbi.GetMethod +} + +type Generator struct { + structRefs map[string]tolkAbi.StructDeclaration + aliasRefs map[string]tolkAbi.AliasDeclaration + enumRefs map[string]tolkAbi.EnumDeclaration + abi []tolkAbi.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 []tolkAbi.ABI, abiByGetMethod map[string][]GetMethodWithAbi) *Generator { + g := &Generator{ + structRefs: make(map[string]tolkAbi.StructDeclaration), + aliasRefs: make(map[string]tolkAbi.AliasDeclaration), + enumRefs: make(map[string]tolkAbi.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 tolkAbi.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, + } + //g.loadedTlbMsgTypes[key] = append(g.loadedTlbMsgTypes[key], msg) + 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 tolkAbi.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.StructRefTy.StructName) + msgName = namespace + typePrefix + typeSuffix + res, err = tolkParser.ParseStructMsg(ty, msgName, namespace) + if err != nil { + return err + } + case "AliasRef": + typePrefix = utils.ToCamelCase(ty.AliasRefTy.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 []tolkAbi.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.NumberTy.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.NumberTy.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", "mapKV": + 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 tolkAbi.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 tolkAbi.Ty) (string, error) { + var builder strings.Builder + + var checksBuilder strings.Builder + res, err := g.buildOutputStackTy(ty, &checksBuilder, 0, false, make(map[string]tolkAbi.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 tolkAbi.Ty, + builder *strings.Builder, + stackIndex int, + isNullable bool, + genericsMap map[string]tolkAbi.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", "mapKV": + builder.WriteString(fmt.Sprintf("|| (%s != \"VmStkCell\"%s) ", stackType, nullableCheck)) + case "tensor": + for _, item := range ty.TensorTy.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.TupleWithTy.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": + if ty.NullableTy.Inner == nil { + return 0, fmt.Errorf("nullable must have inner ty") + } + i, err := g.buildOutputStackTy(*ty.NullableTy.Inner, builder, stackIndex, true, genericsMap) + if err != nil { + return 0, err + } + return i, nil + case "EnumRef": + enumTy, found := g.enumRefs[ty.EnumRefTy.EnumName] + if !found { + return 0, fmt.Errorf("EnumRefTy %s not found in enumRefs", ty.EnumRefTy.EnumName) + } + if enumTy.EncodedAs == nil { + return 0, fmt.Errorf("enum %s has no EncodedAs", enumTy.Name) + } + 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.AliasRefTy.AliasName] + if !found { + return 0, fmt.Errorf("alias %s not found in aliasRefs", ty.AliasRefTy.AliasName) + } + if aliasTy.TargetTy == nil { + return 0, fmt.Errorf("alias %s has no TargetTy", ty.AliasRefTy.AliasName) + } + genericMap := make(map[string]tolkAbi.Ty) + for i, genericName := range aliasTy.TypeParams { + resolvedTy, err := g.resolveGenericT(genericsMap, ty.AliasRefTy.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.StructRefTy.StructName] + if !found { + return 0, fmt.Errorf("StructRefTy %s not found in structRefs", ty.StructRefTy.StructName) + } + genericMap := make(map[string]tolkAbi.Ty) + for i, genericName := range structTy.TypeParams { + resolvedTy, err := g.resolveGenericT(genericsMap, ty.StructRefTy.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 "genericT": + currTy, ok := genericsMap[ty.GenericTy.NameT] + if !ok { + return 0, fmt.Errorf("type for generic %v not found", ty.GenericTy.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]tolkAbi.Ty, ty tolkAbi.Ty) (*tolkAbi.Ty, error) { + switch ty.SumType { + case "genericT": + resolvedTy, ok := genericMap[ty.GenericTy.NameT] + if !ok { + return nil, fmt.Errorf("type for generic %v not found", ty.GenericTy.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..9b59cf7e --- /dev/null +++ b/abi-tolk/parser/parser.go @@ -0,0 +1,13 @@ +package parser + +import ( + "encoding/json" + + "github.com/tonkeeper/tongo/tolk/abi" +) + +func ParseABI(s []byte) (tolkAbi.ABI, error) { + var abi tolkAbi.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..5b11d9e2 --- /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 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 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 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 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 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 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 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 ( + TonTolkTestsTextCommentJettonPayloadOp PayloadOpName = "TonTolkTestsTextCommentJettonPayload" + TonCocoonTextCommandOp PayloadOpName = "TonCocoonTextCommand" + TonCocoonTextCmdOp PayloadOpName = "TonCocoonTextCmd" + 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" + TonTep74AboaLisaOp PayloadOpName = "TonTep74AboaLisa" + TonCocoonReturnExcessesBackOp PayloadOpName = "TonCocoonReturnExcessesBack" + TonTep74ReturnExcessesBackOp PayloadOpName = "TonTep74ReturnExcessesBack" + 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" + + TonTolkTestsTextCommentJettonPayloadOpCode PayloadOpCode = 0x00000000 + TonCocoonTextCommandOpCode PayloadOpCode = 0x00000000 + TonCocoonTextCmdOpCode 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 + TonTep74AboaLisaOpCode PayloadOpCode = 0xd53276db + TonCocoonReturnExcessesBackOpCode PayloadOpCode = 0xd53276db + TonTep74ReturnExcessesBackOpCode 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{ + TonTolkTestsTextCommentJettonPayloadOp: TonTolkTestsTextComment{}, + TonCocoonTextCommandOp: TonCocoonTextCommandPayloadBody{}, + TonCocoonTextCmdOp: TonCocoonTextCmdPayloadBody{}, + 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{}, + TonTep74AboaLisaOp: TonTep74AboaLisaPayloadBody{}, + TonCocoonReturnExcessesBackOp: TonCocoonReturnExcessesBackPayloadBody{}, + TonTep74ReturnExcessesBackOp: TonTep74ReturnExcessesBackPayloadBody{}, + 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{ + TonTolkTestsTextCommentJettonPayloadOp: TonTolkTestsTextCommentJettonPayloadOpCode, + TonCocoonTextCommandOp: TonCocoonTextCommandOpCode, + TonCocoonTextCmdOp: TonCocoonTextCmdOpCode, + 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, + TonTep74AboaLisaOp: TonTep74AboaLisaOpCode, + TonCocoonReturnExcessesBackOp: TonCocoonReturnExcessesBackOpCode, + TonTep74ReturnExcessesBackOp: TonTep74ReturnExcessesBackOpCode, + 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: { + decodeTonTolkTestsTextCommentJettonPayloadOpPayload, + decodeTonCocoonTextCommandOpPayload, + decodeTonCocoonTextCmdOpPayload, + }, + 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: { + decodeTonTep74AboaLisaOpPayload, + decodeTonCocoonReturnExcessesBackOpPayload, + decodeTonTep74ReturnExcessesBackOpPayload, + }, + 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 TonTolkTestsTextComment struct { + Text tlb.Any +} + +type TonCocoonTextCommandPayloadBody = TonCocoonTextCommand + +type TonCocoonTextCmdPayloadBody = TonCocoonTextCmd + +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 TonTep74AboaLisaPayloadBody = TonTep74AboaLisa + +type TonCocoonReturnExcessesBackPayloadBody = TonCocoonReturnExcessesBack + +type TonTep74ReturnExcessesBackPayloadBody = TonTep74ReturnExcessesBack + +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/8n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oyM+FgFAE+gJY+gLLP8v/ySjIz5GVEj/Syz8U+lITzBP0AMnIz4WIE/pSAfoCcc8LaszJIfsAyM+FCBj6UoIQJWWTTM8LjhPLP8mDBvsAEEUAAWIAIM8WGvpScc8LbhnMyYMG+wAALsjPhQgZ+lKCECVlk0zPC47LP8mDBvsAACbJyM+FiBr6UnHPC24ZzMmDBvsAAf4swwLy4+5Tkbny4+j4KMcF8uP3EIsQehBpEFsQShA5S6DwAQpw+wJtIdD6SPpI0/8x0XFUephTqATIywFQA/oCAfoCyz/L/8ktyM+RlRI/0ss/FPpSE8wT9ADJyM+FiBP6UgH6AnHPC2rMyXH7AMjPhQgY+lKCECVlk0zPC44YIQH+MyvDAivDALHy4+5TgLvy4+j4KBPHBfLj9xCKXjYQWRBKEDlKmfABMzZycCCCCJiWgCH7AsjPkxo68e5QCPoCGvpSySfQ+kj6SNP/MdFUd2TIz4YIUAP6Ass/y//JyM+RlRI/0hzLPxL6UhrM9ADJyM+FiBn6UnHPC24YzMmDBiIABFUjAA7LP8mDBvsAAAz7AAZVMAc=" +} \ No newline at end of file diff --git a/abi-tolk/schemas/cocoon-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/q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YN5RcaFRIaFw+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", + "codeBoc64": "te6ccgECFwEABIsAART/APSkE/S88sgLAQIBYgIDAvTQ7aLt+/iR8kAgxwCRMOD4J28Q+Jeh+C+gggiYloC2CXD7AiDXCx+CEJoSR8C6kTDgINMfMdcLP+1E0PpI0x/U10wj+JIlxwXy4/IC0AHQAfQE9ATTH/QE9AUF1gfTH9Yg+gD6ANZ/0x/TH/oA+gD0BPQE9AURFonXJwQFAgEgDQ4ACONLHGAC/p/TPzHXC/+LCAIREIMH9BaOtNcsJGylPNSd0z8x1wv/UA+DB/RbMI6c1ywmCjCabJ/TPzHXC/+LCAIREoMH9BbjDhEQDuLiyM+FCAEREgH6UoIQJWWTTM8LjgERFAHLP8mDBvsADcj0AB/0ABrLHxj0ABv0AMkFyM4Uyx8SzgEGBwHy1ywklYjgxJ7TPzHXC/8BERGDB/RbMI7g1ywjjDB0BJ/TPzHXC/+LCA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+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 a10b4591..c8c60295 100644 --- a/abi/messages_test.go +++ b/abi/messages_test.go @@ -43,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/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..55c6b83a --- /dev/null +++ b/tolk/abi/types.go @@ -0,0 +1,539 @@ +package tolkAbi + +import ( + "encoding/json" + "fmt" + "math/big" + + "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"` + } +} + +func (d *DefaultValue) UnmarshalJSON(b []byte) error { + var kind Kind + + if err := json.Unmarshal(b, &kind); err != nil { + return err + } + + d.SumType = kind.Kind + switch d.SumType { + case "int": + if err := json.Unmarshal(b, &d.IntDefaultValue); err != nil { + return err + } + case "bool": + if err := json.Unmarshal(b, &d.BoolDefaultValue); err != nil { + return err + } + case "address": + if err := json.Unmarshal(b, &d.AddressDefaultValue); err != nil { + return err + } + case "tensor": + if err := json.Unmarshal(b, &d.TensorDefaultValue); err != nil { + return err + } + case "null": // do nothing since null value have no additional fields + default: + return fmt.Errorf("unknown default value type %q", d.SumType) + } + + return nil +} + +func (d *DefaultValue) 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 "int": + payload, err = json.Marshal(d.IntDefaultValue) + if err != nil { + return nil, err + } + return concatPrefixAndPayload(prefix, payload), nil + case "bool": + payload, err = json.Marshal(d.BoolDefaultValue) + if err != nil { + return nil, err + } + return concatPrefixAndPayload(prefix, payload), nil + case "address": + payload, err = json.Marshal(d.AddressDefaultValue) + if err != nil { + return nil, err + } + return concatPrefixAndPayload(prefix, payload), nil + case "tensor": + payload, err = json.Marshal(d.TensorDefaultValue) + if err != nil { + return nil, err + } + return concatPrefixAndPayload(prefix, payload), nil + case "null": + return prefix, nil + default: + return nil, fmt.Errorf("unknown default value type %q", d.SumType) + } +} + +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"` + NumberTy struct { + N int `json:"n"` + } + BitsTy struct { + N int `json:"n"` + } + NullableTy struct { + Inner *Ty `json:"inner"` + } + CellOf struct { + Inner *Ty `json:"inner"` + } + TensorTy struct { + Items []Ty `json:"items"` + } + TupleWithTy struct { + Items []Ty `json:"items"` + } + MapTy struct { + K *Ty `json:"k"` + V *Ty `json:"v"` + } + EnumRefTy struct { + EnumName string `json:"enumName"` + } + StructRefTy struct { + StructName string `json:"structName"` + TypeArgs []Ty `json:"typeArgs,omitempty"` + } + AliasRefTy struct { + AliasName string `json:"aliasName"` + TypeArgs []Ty `json:"typeArgs,omitempty"` + } + GenericTy struct { + NameT string `json:"nameT"` + } + Union struct { + Variants []UnionVariant `json:"variants"` + } +} + +func (t *Ty) UnmarshalJSON(b []byte) error { + var kind Kind + if err := json.Unmarshal(b, &kind); err != nil { + return err + } + + t.SumType = kind.Kind + switch t.SumType { + case "intN", "uintN", "varintN", "varuintN": + if err := json.Unmarshal(b, &t.NumberTy); err != nil { + return err + } + case "bitsN": + if err := json.Unmarshal(b, &t.BitsTy); err != nil { + return err + } + case "nullable": + if err := json.Unmarshal(b, &t.NullableTy); err != nil { + return err + } + case "cellOf": + if err := json.Unmarshal(b, &t.CellOf); err != nil { + return err + } + case "tensor": + if err := json.Unmarshal(b, &t.TensorTy); err != nil { + return err + } + case "tupleWith": + if err := json.Unmarshal(b, &t.TupleWithTy); err != nil { + return err + } + case "mapKV": + if err := json.Unmarshal(b, &t.MapTy); err != nil { + return err + } + case "EnumRef": + if err := json.Unmarshal(b, &t.EnumRefTy); err != nil { + return err + } + case "StructRef": + if err := json.Unmarshal(b, &t.StructRefTy); err != nil { + return err + } + case "AliasRef": + if err := json.Unmarshal(b, &t.AliasRefTy); err != nil { + return err + } + case "genericT": + if err := json.Unmarshal(b, &t.GenericTy); err != nil { + return err + } + case "union": + if err := json.Unmarshal(b, &t.Union); err != nil { + return err + } + case "int", "coins", "bool", "cell", "slice", "builder", "remaining", "address", "addressOpt", "addressExt", + "addressAny", "tupleAny", "nullLiteral", "callable", "void": + return nil + default: + return fmt.Errorf("unknown ty type %q", t.SumType) + } + + return nil +} + +func (t *Ty) MarshalJSON() ([]byte, error) { + var kind Kind + kind.Kind = t.SumType + + var payload []byte + prefix, err := json.Marshal(kind) + if err != nil { + return nil, err + } + + switch t.SumType { + case "intN", "uintN", "varintN", "varuintN": + payload, err = json.Marshal(t.NumberTy) + if err != nil { + return nil, err + } + return concatPrefixAndPayload(prefix, payload), nil + case "bitsN": + payload, err = json.Marshal(t.BitsTy) + if err != nil { + return nil, err + } + return concatPrefixAndPayload(prefix, payload), nil + case "nullable": + payload, err = json.Marshal(t.NullableTy) + if err != nil { + return nil, err + } + return concatPrefixAndPayload(prefix, payload), nil + case "cellOf": + payload, err = json.Marshal(t.CellOf) + if err != nil { + return nil, err + } + return concatPrefixAndPayload(prefix, payload), nil + case "tensor": + payload, err = json.Marshal(t.TensorTy) + if err != nil { + return nil, err + } + return concatPrefixAndPayload(prefix, payload), nil + case "tupleWith": + payload, err = json.Marshal(t.TupleWithTy) + if err != nil { + return nil, err + } + return concatPrefixAndPayload(prefix, payload), nil + case "mapKV": + payload, err = json.Marshal(t.MapTy) + if err != nil { + return nil, err + } + return concatPrefixAndPayload(prefix, payload), nil + case "EnumRef": + payload, err = json.Marshal(t.EnumRefTy) + if err != nil { + return nil, err + } + return concatPrefixAndPayload(prefix, payload), nil + case "StructRef": + payload, err = json.Marshal(t.StructRefTy) + if err != nil { + return nil, err + } + return concatPrefixAndPayload(prefix, payload), nil + case "AliasRef": + payload, err = json.Marshal(t.AliasRefTy) + if err != nil { + return nil, err + } + return concatPrefixAndPayload(prefix, payload), nil + case "genericT": + payload, err = json.Marshal(t.GenericTy) + if err != nil { + return nil, err + } + return concatPrefixAndPayload(prefix, payload), nil + case "union": + payload, err = json.Marshal(t.Union) + if err != nil { + return nil, err + } + return concatPrefixAndPayload(prefix, payload), nil + case "int", "coins", "bool", "cell", "slice", "builder", "remaining", "address", "addressOpt", "addressExt", + "addressAny", "tupleAny", "nullLiteral", "callable", "void": + return prefix, nil + default: + return nil, fmt.Errorf("unknown ty type %q", t.SumType) + } +} + +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.StructRefTy.StructName, nil + case "AliasRef": + return ty.AliasRefTy.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 { + 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/parser/parser.go b/tolk/parser/parser.go new file mode 100644 index 00000000..e810e25d --- /dev/null +++ b/tolk/parser/parser.go @@ -0,0 +1,682 @@ +package tolkParser + +import ( + "errors" + "fmt" + "strconv" + "strings" + + tolkAbi "github.com/tonkeeper/tongo/tolk/abi" + "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 tolkAbi.Ty, msgName, contractName string) (*MsgResult, error) { + var res strings.Builder + res.WriteString("type ") + res.WriteString(msgName) + res.WriteRune(' ') + code, err := createGolangAlias(ty.StructRefTy.StructName, ty.StructRefTy.TypeArgs, contractName) + if err != nil { + return nil, err + } + res.WriteString(code) + + return &MsgResult{ + Code: res.String(), + }, nil +} + +func ParseAliasMsg(ty tolkAbi.Ty, msgName, contractName string) (*MsgResult, error) { + var res strings.Builder + res.WriteString("type ") + res.WriteString(msgName) + res.WriteRune(' ') + code, err := createGolangAlias(ty.AliasRefTy.AliasName, ty.AliasRefTy.TypeArgs, contractName) + if err != nil { + return nil, err + } + res.WriteString(code) + + return &MsgResult{ + Code: res.String(), + }, nil +} + +func ParseGetMethodCode(ty tolkAbi.Ty, contractName string) (string, error) { + switch ty.SumType { + case "StructRef": + name := utils.ToCamelCase(ty.StructRefTy.StructName) + return createGolangAlias(name, ty.StructRefTy.TypeArgs, contractName) + case "AliasRef": + name := utils.ToCamelCase(ty.AliasRefTy.AliasName) + return createGolangAlias(name, ty.AliasRefTy.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 []tolkAbi.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 tolkAbi.Ty, + structRefs map[string]tolkAbi.StructDeclaration, + aliasRefs map[string]tolkAbi.AliasDeclaration, + enumRefs map[string]tolkAbi.EnumDeclaration, +) (*Tag, error) { + switch ty.SumType { + case "StructRef": + prefix := structRefs[ty.StructRefTy.StructName].Prefix + if prefix == nil { + return nil, fmt.Errorf("%v tag is nil", ty.StructRefTy.StructName) + } + convertedTag, err := convertPrefixTagToInt(*prefix) + if err != nil { + return nil, err + } + return convertedTag, nil + case "AliasRef": + aliasRef := aliasRefs[ty.AliasRefTy.AliasName] + if aliasRef.TargetTy == nil { + return nil, fmt.Errorf("alias ref ty cannot be nil") + } + return ParseTag(*aliasRef.TargetTy, structRefs, aliasRefs, enumRefs) + case "EnumRef": + enumRef := enumRefs[ty.EnumRefTy.EnumName] + if enumRef.EncodedAs == nil { + return nil, fmt.Errorf("enum ref ty cannot be nil") + } + return ParseTag(*enumRef.EncodedAs, structRefs, aliasRefs, enumRefs) + default: + return nil, fmt.Errorf("cannot get tag from %s type", ty.SumType) + } +} + +func ParseStructDeclr(declr tolkAbi.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 tolkAbi.AliasDeclaration, contractName string) (*DeclrResult, error) { + result := DeclrResult{} + + if declr.TargetTy == nil { + return nil, errors.New("target ty cannot be null") + } + + 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 tolkAbi.EnumDeclaration, contractName string) (*DeclrResult, error) { + result := DeclrResult{} + + if declr.EncodedAs == nil { + return nil, errors.New("target ty cannot be null") + } + + isBigInt := false + // enum is always an integer + // if number has >64 bits or its varint/varuint then type should be bigInt + if declr.EncodedAs.NumberTy.N > 64 || strings.HasPrefix(declr.EncodedAs.SumType, "var") { + isBigInt = true + } + + 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 tolkAbi.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 tolkAbi.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 tolkAbi.Ty, contractName string) (string, error) { + tlbType, tlbTag, err := parseTy(ty, contractName) + if err != nil { + return "", err + } + + return wrapTlbTypeIntoTlbTag(tlbType, tlbTag), nil +} + +func parseTy(ty tolkAbi.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.NumberTy.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.NumberTy.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", "varuintN": + tlbVarUIntType := fmt.Sprintf("tlb.VarUInteger%v", ty.NumberTy.N) + tlbType.WriteString(tlbVarUIntType) + case "bitsN": + tlbVarUIntType := fmt.Sprintf("tlb.Bits%v", ty.BitsTy.N) + tlbType.WriteString(tlbVarUIntType) + case "nullable": + if ty.NullableTy.Inner == nil { + return "", "", fmt.Errorf("inner nullable type cannot be null") + } + tlbMaybeType, tlbMaybeTag, err := parseTy(*ty.NullableTy.Inner, contractName) + if err != nil { + return "", "", err + } + + tlbTag.WriteString("maybe") + tlbTag.WriteString(tlbMaybeTag) + + tlbType.WriteRune('*') + tlbType.WriteString(tlbMaybeType) + tlbType.WriteRune(' ') + case "cellOf": + if ty.CellOf.Inner == nil { + return "", "", fmt.Errorf("inner cell type cannot be null") + } + 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.TensorTy.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.TupleWithTy.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 "mapKV": + if ty.MapTy.K == nil { + return "", "", fmt.Errorf("map key cannot be null") + } + if ty.MapTy.V == nil { + return "", "", fmt.Errorf("map value cannot be null") + } + tlbType.WriteString("tlb.HashmapE[") + fixedType, err := getFixedSizeTypeForMap(*ty.MapTy.K) + if err != nil { + return "", "", err + } + valueType, valueTypeTag, err := parseTy(*ty.MapTy.V, contractName) + wrappedType := wrapTlbTypeIntoTlbTag(valueType, valueTypeTag) + + tlbType.WriteString(fixedType) + tlbType.WriteRune(',') + tlbType.WriteString(wrappedType) + tlbType.WriteRune(']') + case "EnumRef": + name := contractName + utils.ToCamelCase(ty.EnumRefTy.EnumName) + tlbType.WriteString(name) + case "StructRef": + name := contractName + utils.ToCamelCase(ty.StructRefTy.StructName) + tlbType.WriteString(name) + err := writeGenericTypesPart(&tlbType, ty.StructRefTy.TypeArgs, contractName) + if err != nil { + return "", "", err + } + case "AliasRef": + name := contractName + utils.ToCamelCase(ty.AliasRefTy.AliasName) + tlbType.WriteString(name) + err := writeGenericTypesPart(&tlbType, ty.AliasRefTy.TypeArgs, contractName) + if err != nil { + return "", "", err + } + case "genericT": + name := ty.GenericTy.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 tolkAbi.Ty) (string, error) { + switch ty.SumType { + case "intN": + n := ty.NumberTy.N + tlbIntType := fmt.Sprintf("tlb.Int%v", n) + return tlbIntType, nil + case "uintN": + n := ty.NumberTy.N + tlbIntType := fmt.Sprintf("tlb.Uint%v", n) + return tlbIntType, nil + case "varintN", "varuintN": + tlbVarUIntType := fmt.Sprintf("tlb.VarUInteger%v", ty.NumberTy.N) + return tlbVarUIntType, nil + case "bitsN": + tlbVarUIntType := fmt.Sprintf("tlb.Bits%v", ty.BitsTy.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 tolkAbi.Prefix) (*Tag, error) { + if tag.PrefixLen == 0 { + return nil, fmt.Errorf("prefix tag len must be > 0") + } + + var val uint64 + var err error + if len(tag.PrefixStr) == 1 { + val, err = strconv.ParseUint(tag.PrefixStr, 10, 64) + if err != nil { + return nil, err + } + } else { + if tag.PrefixStr[1] == 'b' { + val, err = strconv.ParseUint(tag.PrefixStr[2:], 2, 64) + if err != nil { + return nil, err + } + } else if tag.PrefixStr[1] == 'x' { + val, err = strconv.ParseUint(tag.PrefixStr[2:], 16, 64) + if err != nil { + return nil, err + } + } else { + return nil, fmt.Errorf("prefix tag must be either binary or hex format") + } + } + + 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 []tolkAbi.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/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) + } + }) + } +} From d78349d55d8980734157110232605c8d9703978d Mon Sep 17 00:00:00 2001 From: Pavel Levchenko Date: Wed, 28 Jan 2026 20:08:56 +0300 Subject: [PATCH 02/16] implement runtime unmarshal --- abi-tolk/generator.go | 6 +- abi-tolk/get_methods.go | 518 +++--- abi-tolk/parser/generator.go | 132 +- abi-tolk/parser/parser.go | 6 +- abi-tolk/payload_msg_types.go | 72 +- boc/bitString.go | 3 +- tolk/abi/types.go | 539 ------ tolk/abi_types.go | 881 ++++++++++ tolk/addresses.go | 252 +++ tolk/cells.go | 195 +++ tolk/integers.go | 313 ++++ tolk/map.go | 214 +++ tolk/null.go | 31 + tolk/parser/parser.go | 249 ++- tolk/refs.go | 304 ++++ tolk/runtime.go | 62 + tolk/runtime_test.go | 2556 +++++++++++++++++++++++++++++ tolk/runtime_types.go | 845 ++++++++++ tolk/testdata/bin_union.json | 72 + tolk/testdata/default_values.json | 143 ++ tolk/testdata/generics.json | 297 ++++ tolk/testdata/hex_union.json | 69 + tolk/testdata/numbers.json | 72 + tolk/testdata/random_fields.json | 158 ++ tolk/testdata/refs.json | 211 +++ tolk/testdata/simple.json | 17 + tolk/tuples.go | 90 + tolk/union.go | 80 + tolk/utils.go | 101 ++ 29 files changed, 7438 insertions(+), 1050 deletions(-) delete mode 100644 tolk/abi/types.go create mode 100644 tolk/abi_types.go create mode 100644 tolk/addresses.go create mode 100644 tolk/cells.go create mode 100644 tolk/integers.go create mode 100644 tolk/map.go create mode 100644 tolk/null.go create mode 100644 tolk/refs.go create mode 100644 tolk/runtime.go create mode 100644 tolk/runtime_test.go create mode 100644 tolk/runtime_types.go create mode 100644 tolk/testdata/bin_union.json create mode 100644 tolk/testdata/default_values.json create mode 100644 tolk/testdata/generics.json create mode 100644 tolk/testdata/hex_union.json create mode 100644 tolk/testdata/numbers.json create mode 100644 tolk/testdata/random_fields.json create mode 100644 tolk/testdata/refs.json create mode 100644 tolk/testdata/simple.json create mode 100644 tolk/tuples.go create mode 100644 tolk/union.go create mode 100644 tolk/utils.go diff --git a/abi-tolk/generator.go b/abi-tolk/generator.go index 5e9b8fde..a0387cde 100644 --- a/abi-tolk/generator.go +++ b/abi-tolk/generator.go @@ -11,7 +11,7 @@ import ( "strings" parser "github.com/tonkeeper/tongo/abi-tolk/parser" - tolkAbi "github.com/tonkeeper/tongo/tolk/abi" + "github.com/tonkeeper/tongo/tolk" ) const HEADER = `package abitolk @@ -24,7 +24,7 @@ import ( ` const SCHEMAS_PATH = "schemas/" -func mergeMethods(abis []tolkAbi.ABI) (map[string][]parser.GetMethodWithAbi, error) { +func mergeMethods(abis []tolk.ABI) (map[string][]parser.GetMethodWithAbi, error) { methodsMap := map[string][]parser.GetMethodWithAbi{} for _, abi := range abis { for _, method := range abi.GetMethods { @@ -51,7 +51,7 @@ func mergeMethods(abis []tolkAbi.ABI) (map[string][]parser.GetMethodWithAbi, err } func main() { - var abi []tolkAbi.ABI + 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 diff --git a/abi-tolk/get_methods.go b/abi-tolk/get_methods.go index 317406c4..bd6c5de7 100644 --- a/abi-tolk/get_methods.go +++ b/abi-tolk/get_methods.go @@ -11,22 +11,22 @@ import ( var KnownGetMethodsDecoder = map[string][]func(tlb.VmStack) (string, any, error){ "model_hash_is_valid": {DecodeTonCocoonRoot_ModelHashIsValidResult}, - "seqno": {DecodeTonCocoonWallet_SeqnoResult}, - "get_public_key": {DecodeTonCocoonWallet_GetPublicKeyResult}, - "get_owner_address": {DecodeTonCocoonWallet_GetOwnerAddressResult}, "get_wallet_data": {DecodeTonTep74JettonWallet_GetWalletDataResult}, - "get_pool_data": {DecodeTonStonfiV1Pool_GetPoolDataResult, DecodeTonStonfiV2PoolConstProduct_GetPoolDataResult, DecodeTonStonfiV2PoolStableSwap_GetPoolDataResult, DecodeTonStonfiV2PoolWeightedStableSwap_GetPoolDataResult}, + "get_cocoon_proxy_data": {DecodeTonCocoonProxy_GetCocoonProxyDataResult}, "last_proxy_seqno": {DecodeTonCocoonRoot_LastProxySeqnoResult}, - "get_cur_params": {DecodeTonCocoonRoot_GetCurParamsResult}, "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_jetton_data": {DecodeTonTep74JettonMinter_GetJettonDataResult}, "get_cocoon_data": {DecodeTonCocoonRoot_GetCocoonDataResult}, - "get_wallet_address": {DecodeTonTep74JettonMinter_GetWalletAddressResult}, - "get_cocoon_proxy_data": {DecodeTonCocoonProxy_GetCocoonProxyDataResult}, - "worker_hash_is_valid": {DecodeTonCocoonRoot_WorkerHashIsValidResult}, } var KnownSimpleGetMethods = map[int][]func(ctx context.Context, executor Executor, reqAccountID ton.AccountID) (string, any, error){ @@ -46,28 +46,28 @@ var KnownSimpleGetMethods = map[int][]func(ctx context.Context, executor Executo var resultTypes = []interface{}{ &TonCocoonRoot_ModelHashIsValidResult{}, - &TonCocoonWallet_SeqnoResult{}, - &TonCocoonWallet_GetPublicKeyResult{}, - &TonCocoonWallet_GetOwnerAddressResult{}, &TonTep74JettonWallet_GetWalletDataResult{}, + &TonCocoonProxy_GetCocoonProxyDataResult{}, + &TonCocoonRoot_LastProxySeqnoResult{}, + &TonCocoonRoot_ProxyHashIsValidResult{}, + &TonCocoonWallet_GetOwnerAddressResult{}, + &TonCocoonWorker_GetCocoonWorkerDataResult{}, + &TonTep74JettonMinter_GetWalletAddressResult{}, &TonStonfiV1Pool_GetPoolDataResult{}, &TonStonfiV2PoolConstProduct_GetPoolDataResult{}, &TonStonfiV2PoolStableSwap_GetPoolDataResult{}, &TonStonfiV2PoolWeightedStableSwap_GetPoolDataResult{}, - &TonCocoonRoot_LastProxySeqnoResult{}, &TonCocoonRoot_GetCurParamsResult{}, - &TonCocoonRoot_ProxyHashIsValidResult{}, - &TonCocoonWorker_GetCocoonWorkerDataResult{}, + &TonCocoonWallet_GetPublicKeyResult{}, + &TonTep74JettonMinter_GetJettonDataResult{}, + &TonCocoonRoot_WorkerHashIsValidResult{}, + &TonCocoonWallet_SeqnoResult{}, &TonStonfiV2PoolConstProduct_GetLpAccountAddressResult{}, &TonStonfiV2PoolStableSwap_GetLpAccountAddressResult{}, &TonStonfiV2PoolWeightedStableSwap_GetLpAccountAddressResult{}, &TonStonfiV2Pool_GetLpAccountAddressResult{}, &TonCocoonClient_GetCocoonClientDataResult{}, - &TonTep74JettonMinter_GetJettonDataResult{}, &TonCocoonRoot_GetCocoonDataResult{}, - &TonTep74JettonMinter_GetWalletAddressResult{}, - &TonCocoonProxy_GetCocoonProxyDataResult{}, - &TonCocoonRoot_WorkerHashIsValidResult{}, } type Executor interface { @@ -112,22 +112,99 @@ func DecodeTonCocoonRoot_ModelHashIsValidResult(stack tlb.VmStack) (resultType s return "TonCocoonRoot_ModelHashIsValidResult", result, err } -type TonCocoonWallet_SeqnoResult struct { +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 Seqno(ctx context.Context, executor Executor, reqAccountID ton.AccountID) (string, any, error) { +func LastProxySeqno(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) + // 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){DecodeTonCocoonWallet_SeqnoResult} { + for _, f := range []func(tlb.VmStack) (string, any, error){DecodeTonCocoonRoot_LastProxySeqnoResult} { s, r, err := f(stack) if err == nil { return s, r, nil @@ -136,31 +213,37 @@ func Seqno(ctx context.Context, executor Executor, reqAccountID ton.AccountID) ( return "", nil, fmt.Errorf("can not decode outputs") } -func DecodeTonCocoonWallet_SeqnoResult(stack tlb.VmStack) (resultType string, resultAny any, err error) { +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 TonCocoonWallet_SeqnoResult + var result TonCocoonRoot_LastProxySeqnoResult err = stack.Unmarshal(&result) - return "TonCocoonWallet_SeqnoResult", result, err + return "TonCocoonRoot_LastProxySeqnoResult", result, err } -type TonCocoonWallet_GetPublicKeyResult struct { +type TonCocoonRoot_ProxyHashIsValidResult struct { Value tlb.Int257 } -func GetPublicKey(ctx context.Context, executor Executor, reqAccountID ton.AccountID) (string, any, error) { +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 = 78748 for "get_public_key" method - errCode, stack, err := executor.RunSmcMethodByID(ctx, reqAccountID, 78748, stack) + // 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){DecodeTonCocoonWallet_GetPublicKeyResult} { + for _, f := range []func(tlb.VmStack) (string, any, error){DecodeTonCocoonRoot_ProxyHashIsValidResult} { s, r, err := f(stack) if err == nil { return s, r, nil @@ -169,13 +252,13 @@ func GetPublicKey(ctx context.Context, executor Executor, reqAccountID ton.Accou return "", nil, fmt.Errorf("can not decode outputs") } -func DecodeTonCocoonWallet_GetPublicKeyResult(stack tlb.VmStack) (resultType string, resultAny any, err error) { +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 TonCocoonWallet_GetPublicKeyResult + var result TonCocoonRoot_ProxyHashIsValidResult err = stack.Unmarshal(&result) - return "TonCocoonWallet_GetPublicKeyResult", result, err + return "TonCocoonRoot_ProxyHashIsValidResult", result, err } type TonCocoonWallet_GetOwnerAddressResult struct { @@ -211,20 +294,28 @@ func DecodeTonCocoonWallet_GetOwnerAddressResult(stack tlb.VmStack) (resultType return "TonCocoonWallet_GetOwnerAddressResult", result, err } -type TonTep74JettonWallet_GetWalletDataResult = TonTep74JettonWalletDataReply +type TonCocoonWorker_GetCocoonWorkerDataResult struct { + Field struct { + Field0 tlb.MsgAddress + Field1 tlb.MsgAddress + Field2 tlb.Int257 + Field3 tlb.Int257 + Field4 tlb.Int257 + } `vmStackHint:"tensor"` +} -func GetWalletData(ctx context.Context, executor Executor, reqAccountID ton.AccountID) (string, any, error) { +func GetCocoonWorkerData(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) + // 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){DecodeTonTep74JettonWallet_GetWalletDataResult} { + for _, f := range []func(tlb.VmStack) (string, any, error){DecodeTonCocoonWorker_GetCocoonWorkerDataResult} { s, r, err := f(stack) if err == nil { return s, r, nil @@ -233,13 +324,55 @@ func GetWalletData(ctx context.Context, executor Executor, reqAccountID ton.Acco 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") { +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 TonTep74JettonWallet_GetWalletDataResult + var result TonCocoonWorker_GetCocoonWorkerDataResult err = stack.Unmarshal(&result) - return "TonTep74JettonWallet_GetWalletDataResult", result, err + 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 @@ -306,39 +439,6 @@ func DecodeTonStonfiV2PoolWeightedStableSwap_GetPoolDataResult(stack tlb.VmStack return "TonStonfiV2PoolWeightedStableSwap_GetPoolDataResult", 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_GetCurParamsResult struct { Field struct { Field0 tlb.Int257 @@ -387,11 +487,75 @@ func DecodeTonCocoonRoot_GetCurParamsResult(stack tlb.VmStack) (resultType strin return "TonCocoonRoot_GetCurParamsResult", result, err } -type TonCocoonRoot_ProxyHashIsValidResult struct { +type TonCocoonWallet_GetPublicKeyResult struct { Value tlb.Int257 } -func ProxyHashIsValid(ctx context.Context, executor Executor, reqAccountID ton.AccountID, hash tlb.Int257) (string, any, error) { +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 @@ -400,15 +564,15 @@ func ProxyHashIsValid(ctx context.Context, executor Executor, reqAccountID ton.A 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) + // 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_ProxyHashIsValidResult} { + for _, f := range []func(tlb.VmStack) (string, any, error){DecodeTonCocoonRoot_WorkerHashIsValidResult} { s, r, err := f(stack) if err == nil { return s, r, nil @@ -417,37 +581,31 @@ func ProxyHashIsValid(ctx context.Context, executor Executor, reqAccountID ton.A return "", nil, fmt.Errorf("can not decode outputs") } -func DecodeTonCocoonRoot_ProxyHashIsValidResult(stack tlb.VmStack) (resultType string, resultAny any, err error) { +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_ProxyHashIsValidResult + var result TonCocoonRoot_WorkerHashIsValidResult err = stack.Unmarshal(&result) - return "TonCocoonRoot_ProxyHashIsValidResult", result, err + return "TonCocoonRoot_WorkerHashIsValidResult", 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"` +type TonCocoonWallet_SeqnoResult struct { + Value tlb.Int257 } -func GetCocoonWorkerData(ctx context.Context, executor Executor, reqAccountID ton.AccountID) (string, any, error) { +func Seqno(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) + // 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){DecodeTonCocoonWorker_GetCocoonWorkerDataResult} { + for _, f := range []func(tlb.VmStack) (string, any, error){DecodeTonCocoonWallet_SeqnoResult} { s, r, err := f(stack) if err == nil { return s, r, nil @@ -456,13 +614,13 @@ func GetCocoonWorkerData(ctx context.Context, executor Executor, reqAccountID to 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") { +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 TonCocoonWorker_GetCocoonWorkerDataResult + var result TonCocoonWallet_SeqnoResult err = stack.Unmarshal(&result) - return "TonCocoonWorker_GetCocoonWorkerDataResult", result, err + return "TonCocoonWallet_SeqnoResult", result, err } type TonStonfiV2PoolConstProduct_GetLpAccountAddressResult = TonStonfiV2GetLpAccountAddressResult @@ -581,37 +739,6 @@ func DecodeTonCocoonClient_GetCocoonClientDataResult(stack tlb.VmStack) (resultT return "TonCocoonClient_GetCocoonClientDataResult", 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_GetCocoonDataResult struct { Field struct { Field0 tlb.Int257 @@ -655,130 +782,3 @@ func DecodeTonCocoonRoot_GetCocoonDataResult(stack tlb.VmStack) (resultType stri err = stack.Unmarshal(&result) return "TonCocoonRoot_GetCocoonDataResult", 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 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_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 -} diff --git a/abi-tolk/parser/generator.go b/abi-tolk/parser/generator.go index dc3955be..4bdb2c29 100644 --- a/abi-tolk/parser/generator.go +++ b/abi-tolk/parser/generator.go @@ -11,7 +11,7 @@ import ( "text/template" "github.com/tonkeeper/tongo/tlb" - tolkAbi "github.com/tonkeeper/tongo/tolk/abi" + "github.com/tonkeeper/tongo/tolk" tolkParser "github.com/tonkeeper/tongo/tolk/parser" "github.com/tonkeeper/tongo/utils" "golang.org/x/exp/maps" @@ -52,15 +52,15 @@ type TLBMsgBody struct { } type GetMethodWithAbi struct { - ABI tolkAbi.ABI - GetMethod tolkAbi.GetMethod + ABI tolk.ABI + GetMethod tolk.GetMethod } type Generator struct { - structRefs map[string]tolkAbi.StructDeclaration - aliasRefs map[string]tolkAbi.AliasDeclaration - enumRefs map[string]tolkAbi.EnumDeclaration - abi []tolkAbi.ABI + 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 @@ -71,11 +71,11 @@ type Generator struct { type MsgType int -func NewGenerator(abi []tolkAbi.ABI, abiByGetMethod map[string][]GetMethodWithAbi) *Generator { +func NewGenerator(abi []tolk.ABI, abiByGetMethod map[string][]GetMethodWithAbi) *Generator { g := &Generator{ - structRefs: make(map[string]tolkAbi.StructDeclaration), - aliasRefs: make(map[string]tolkAbi.AliasDeclaration), - enumRefs: make(map[string]tolkAbi.EnumDeclaration), + 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), @@ -155,7 +155,7 @@ func (g *Generator) registerABI() error { return nil } -func (g *Generator) registerType(declr tolkAbi.Declaration, namespace string) error { +func (g *Generator) registerType(declr tolk.Declaration, namespace string) error { var result *tolkParser.DeclrResult var err error switch declr.SumType { @@ -211,7 +211,6 @@ func (g *Generator) registerPayload(result *tolkParser.DeclrResult, tag tolkPars Tag: tag.Val, Code: result.Code, } - //g.loadedTlbMsgTypes[key] = append(g.loadedTlbMsgTypes[key], msg) if _, init := g.loadedTlbPayloadTypes[namespace]; !init { g.loadedTlbPayloadTypes[namespace] = make(map[tlb.Tag][]TLBMsgBody) } @@ -220,7 +219,7 @@ func (g *Generator) registerPayload(result *tolkParser.DeclrResult, tag tolkPars return nil } -func (g *Generator) registerMsgType(mType MsgType, ty tolkAbi.Ty, namespace, fullName string, msgsName map[string]struct{}) error { +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) @@ -251,14 +250,14 @@ func (g *Generator) registerMsgType(mType MsgType, ty tolkAbi.Ty, namespace, ful var res *tolkParser.MsgResult switch ty.SumType { case "StructRef": - typePrefix = utils.ToCamelCase(ty.StructRefTy.StructName) + 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.AliasRefTy.AliasName) + typePrefix = utils.ToCamelCase(ty.AliasRef.AliasName) msgName = namespace + typePrefix + typeSuffix res, err = tolkParser.ParseAliasMsg(ty, msgName, namespace) if err != nil { @@ -494,7 +493,7 @@ func (g *Generator) getMethod(methodName string, methodID int, m []GetMethodWith return builder.String(), nil } -func buildInputStackValues(p []tolkAbi.Parameter) string { +func buildInputStackValues(p []tolk.Parameter) string { var builder strings.Builder builder.WriteString("stack := tlb.VmStack{}\n") @@ -504,40 +503,40 @@ func buildInputStackValues(p []tolkAbi.Parameter) string { for _, s := range p { switch s.Ty.SumType { - case "intN": - if s.Ty.NumberTy.N <= 64 { + 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.NumberTy.N <= 63 { + 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": + case "Bool": builder.WriteString(fmt.Sprintf("val = tlb.VmStackValue{SumType: \"VmStkTinyInt\", VmStkTinyInt: BoolToInt64(%s)}\n", utils.ToCamelCasePrivate(s.Name))) - case "coins": + 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": + 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": + 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", "mapKV": + 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": + case "NullLiteral", "Void": builder.WriteString("val = tlb.VmStackValue{SumType: \"VmStkNull\"}\n") default: builder.WriteString(fmt.Sprintf("val, err = tlb.TlbStructToVmCell(%s)\n", @@ -550,7 +549,7 @@ func buildInputStackValues(p []tolkAbi.Parameter) string { return builder.String() } -func (g *Generator) buildOutputDecoder(name string, ty tolkAbi.Ty) (string, error) { +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)) @@ -570,11 +569,11 @@ func (g *Generator) buildOutputDecoder(name string, ty tolkAbi.Ty) (string, erro return builder.String(), nil } -func (g *Generator) buildOutputStackCheck(ty tolkAbi.Ty) (string, error) { +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]tolkAbi.Ty)) + res, err := g.buildOutputStackTy(ty, &checksBuilder, 0, false, make(map[string]tolk.Ty)) if err != nil { return "", err } @@ -586,11 +585,11 @@ func (g *Generator) buildOutputStackCheck(ty tolkAbi.Ty) (string, error) { } func (g *Generator) buildOutputStackTy( - ty tolkAbi.Ty, + ty tolk.Ty, builder *strings.Builder, stackIndex int, isNullable bool, - genericsMap map[string]tolkAbi.Ty, + genericsMap map[string]tolk.Ty, ) (int, error) { stackType := fmt.Sprintf("stack[%d].SumType", stackIndex) nullableCheck := "" @@ -599,14 +598,14 @@ func (g *Generator) buildOutputStackTy( } switch ty.SumType { - case "intN", "uintN", "varintN", "varuintN", "coins", "bool", "int": + 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": + case "Address", "AddressExt", "AddressOpt", "AddressAny", "Slice", "Remaining", "BitsN": builder.WriteString(fmt.Sprintf("|| (%s != \"VmStkSlice\"%s) ", stackType, nullableCheck)) - case "cell", "builder", "cellOf", "mapKV": + case "Cell", "Builder", "CellOf", "Map": builder.WriteString(fmt.Sprintf("|| (%s != \"VmStkCell\"%s) ", stackType, nullableCheck)) - case "tensor": - for _, item := range ty.TensorTy.Items { + case "Tensor": + for _, item := range ty.Tensor.Items { i, err := g.buildOutputStackTy(item, builder, stackIndex, isNullable, genericsMap) if err != nil { return 0, err @@ -614,8 +613,8 @@ func (g *Generator) buildOutputStackTy( stackIndex = i + 1 } return stackIndex - 1, nil - case "tupleWith": - for _, item := range ty.TupleWithTy.Items { + case "TupleWith": + for _, item := range ty.TupleWith.Items { i, err := g.buildOutputStackTy(item, builder, stackIndex, isNullable, genericsMap) if err != nil { return 0, err @@ -623,61 +622,52 @@ func (g *Generator) buildOutputStackTy( stackIndex = i + 1 } return stackIndex - 1, nil - case "nullLiteral", "void": + case "NullLiteral", "Void": builder.WriteString(fmt.Sprintf("|| (%s != \"VmStkNull\") ", stackType)) - case "callable": + case "Callable": builder.WriteString(fmt.Sprintf("|| (%s != \"VmStkCont\") ", stackType)) - case "nullable": - if ty.NullableTy.Inner == nil { - return 0, fmt.Errorf("nullable must have inner ty") - } - i, err := g.buildOutputStackTy(*ty.NullableTy.Inner, builder, stackIndex, true, genericsMap) + 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.EnumRefTy.EnumName] + enumTy, found := g.enumRefs[ty.EnumRef.EnumName] if !found { - return 0, fmt.Errorf("EnumRefTy %s not found in enumRefs", ty.EnumRefTy.EnumName) - } - if enumTy.EncodedAs == nil { - return 0, fmt.Errorf("enum %s has no EncodedAs", enumTy.Name) + return 0, fmt.Errorf("EnumRef %s not found in enumRefs", ty.EnumRef.EnumName) } - i, err := g.buildOutputStackTy(*enumTy.EncodedAs, builder, stackIndex, isNullable, genericsMap) + 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.AliasRefTy.AliasName] + aliasTy, found := g.aliasRefs[ty.AliasRef.AliasName] if !found { - return 0, fmt.Errorf("alias %s not found in aliasRefs", ty.AliasRefTy.AliasName) - } - if aliasTy.TargetTy == nil { - return 0, fmt.Errorf("alias %s has no TargetTy", ty.AliasRefTy.AliasName) + return 0, fmt.Errorf("alias %s not found in aliasRefs", ty.AliasRef.AliasName) } - genericMap := make(map[string]tolkAbi.Ty) + genericMap := make(map[string]tolk.Ty) for i, genericName := range aliasTy.TypeParams { - resolvedTy, err := g.resolveGenericT(genericsMap, ty.AliasRefTy.TypeArgs[i]) + 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) + 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.StructRefTy.StructName] + structTy, found := g.structRefs[ty.StructRef.StructName] if !found { - return 0, fmt.Errorf("StructRefTy %s not found in structRefs", ty.StructRefTy.StructName) + return 0, fmt.Errorf("StructRef %s not found in structRefs", ty.StructRef.StructName) } - genericMap := make(map[string]tolkAbi.Ty) + genericMap := make(map[string]tolk.Ty) for i, genericName := range structTy.TypeParams { - resolvedTy, err := g.resolveGenericT(genericsMap, ty.StructRefTy.TypeArgs[i]) + resolvedTy, err := g.resolveGenericT(genericsMap, ty.StructRef.TypeArgs[i]) if err != nil { return 0, err } @@ -691,10 +681,10 @@ func (g *Generator) buildOutputStackTy( stackIndex = i + 1 } return stackIndex - 1, nil - case "genericT": - currTy, ok := genericsMap[ty.GenericTy.NameT] + case "Generic": + currTy, ok := genericsMap[ty.Generic.NameT] if !ok { - return 0, fmt.Errorf("type for generic %v not found", ty.GenericTy.NameT) + 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 { @@ -707,12 +697,12 @@ func (g *Generator) buildOutputStackTy( return stackIndex, nil } -func (g *Generator) resolveGenericT(genericMap map[string]tolkAbi.Ty, ty tolkAbi.Ty) (*tolkAbi.Ty, error) { +func (g *Generator) resolveGenericT(genericMap map[string]tolk.Ty, ty tolk.Ty) (*tolk.Ty, error) { switch ty.SumType { - case "genericT": - resolvedTy, ok := genericMap[ty.GenericTy.NameT] + case "Generic": + resolvedTy, ok := genericMap[ty.Generic.NameT] if !ok { - return nil, fmt.Errorf("type for generic %v not found", ty.GenericTy.NameT) + return nil, fmt.Errorf("type for generic %v not found", ty.Generic.NameT) } return &resolvedTy, nil } diff --git a/abi-tolk/parser/parser.go b/abi-tolk/parser/parser.go index 9b59cf7e..d67f57df 100644 --- a/abi-tolk/parser/parser.go +++ b/abi-tolk/parser/parser.go @@ -3,11 +3,11 @@ package parser import ( "encoding/json" - "github.com/tonkeeper/tongo/tolk/abi" + "github.com/tonkeeper/tongo/tolk" ) -func ParseABI(s []byte) (tolkAbi.ABI, error) { - var abi tolkAbi.ABI +func ParseABI(s []byte) (tolk.ABI, error) { + var abi tolk.ABI err := json.Unmarshal(s, &abi) return abi, err } diff --git a/abi-tolk/payload_msg_types.go b/abi-tolk/payload_msg_types.go index 5b11d9e2..182525ca 100644 --- a/abi-tolk/payload_msg_types.go +++ b/abi-tolk/payload_msg_types.go @@ -7,11 +7,11 @@ import ( "github.com/tonkeeper/tongo/tlb" ) -func decodeTonTolkTestsTextCommentJettonPayloadOpPayload(j *Payload, c *boc.Cell) error { - var res TonTolkTestsTextComment +func decodeTonCocoonTextCmdOpPayload(j *Payload, c *boc.Cell) error { + var res TonCocoonTextCmdPayloadBody err := tlb.Unmarshal(c, &res) if err == nil { - j.SumType = TonTolkTestsTextCommentJettonPayloadOp + j.SumType = TonCocoonTextCmdOp j.Value = res return nil } @@ -29,11 +29,11 @@ func decodeTonCocoonTextCommandOpPayload(j *Payload, c *boc.Cell) error { return err } -func decodeTonCocoonTextCmdOpPayload(j *Payload, c *boc.Cell) error { - var res TonCocoonTextCmdPayloadBody +func decodeTonTolkTestsTextCommentJettonPayloadOpPayload(j *Payload, c *boc.Cell) error { + var res TonTolkTestsTextComment err := tlb.Unmarshal(c, &res) if err == nil { - j.SumType = TonCocoonTextCmdOp + j.SumType = TonTolkTestsTextCommentJettonPayloadOp j.Value = res return nil } @@ -865,33 +865,33 @@ func decodeTonTep74ResponseWalletAddressOpPayload(j *Payload, c *boc.Cell) error return err } -func decodeTonTep74AboaLisaOpPayload(j *Payload, c *boc.Cell) error { - var res TonTep74AboaLisaPayloadBody +func decodeTonCocoonReturnExcessesBackOpPayload(j *Payload, c *boc.Cell) error { + var res TonCocoonReturnExcessesBackPayloadBody err := tlb.Unmarshal(c, &res) if err == nil { - j.SumType = TonTep74AboaLisaOp + j.SumType = TonCocoonReturnExcessesBackOp j.Value = res return nil } return err } -func decodeTonCocoonReturnExcessesBackOpPayload(j *Payload, c *boc.Cell) error { - var res TonCocoonReturnExcessesBackPayloadBody +func decodeTonTep74ReturnExcessesBackOpPayload(j *Payload, c *boc.Cell) error { + var res TonTep74ReturnExcessesBackPayloadBody err := tlb.Unmarshal(c, &res) if err == nil { - j.SumType = TonCocoonReturnExcessesBackOp + j.SumType = TonTep74ReturnExcessesBackOp j.Value = res return nil } return err } -func decodeTonTep74ReturnExcessesBackOpPayload(j *Payload, c *boc.Cell) error { - var res TonTep74ReturnExcessesBackPayloadBody +func decodeTonTep74AboaLisaOpPayload(j *Payload, c *boc.Cell) error { + var res TonTep74AboaLisaPayloadBody err := tlb.Unmarshal(c, &res) if err == nil { - j.SumType = TonTep74ReturnExcessesBackOp + j.SumType = TonTep74AboaLisaOp j.Value = res return nil } @@ -1053,9 +1053,9 @@ func decodeTonStonfiV2StonfiProvideLiquidityJettonPayloadOpPayload(j *Payload, c } const ( - TonTolkTestsTextCommentJettonPayloadOp PayloadOpName = "TonTolkTestsTextCommentJettonPayload" - TonCocoonTextCommandOp PayloadOpName = "TonCocoonTextCommand" TonCocoonTextCmdOp PayloadOpName = "TonCocoonTextCmd" + TonCocoonTextCommandOp PayloadOpName = "TonCocoonTextCommand" + TonTolkTestsTextCommentJettonPayloadOp PayloadOpName = "TonTolkTestsTextCommentJettonPayload" TonTep74ChangeMinterAdminOp PayloadOpName = "TonTep74ChangeMinterAdmin" TonTep74ChangeMinterContentOp PayloadOpName = "TonTep74ChangeMinterContent" TonTep74MintNewJettonsOp PayloadOpName = "TonTep74MintNewJettons" @@ -1131,9 +1131,9 @@ const ( TonTolkTestsWithdrawPayloadJettonPayloadOp PayloadOpName = "TonTolkTestsWithdrawPayloadJettonPayload" TonTolkTestsMoonSwapSucceedJettonPayloadOp PayloadOpName = "TonTolkTestsMoonSwapSucceedJettonPayload" TonTep74ResponseWalletAddressOp PayloadOpName = "TonTep74ResponseWalletAddress" - TonTep74AboaLisaOp PayloadOpName = "TonTep74AboaLisa" TonCocoonReturnExcessesBackOp PayloadOpName = "TonCocoonReturnExcessesBack" TonTep74ReturnExcessesBackOp PayloadOpName = "TonTep74ReturnExcessesBack" + TonTep74AboaLisaOp PayloadOpName = "TonTep74AboaLisa" TonTolkTestsMoonCreateOrderJettonPayloadOp PayloadOpName = "TonTolkTestsMoonCreateOrderJettonPayload" TonCocoonOwnerClientWithdrawOp PayloadOpName = "TonCocoonOwnerClientWithdraw" TonTolkTestsBidaskDammSwapJettonPayloadOp PayloadOpName = "TonTolkTestsBidaskDammSwapJettonPayload" @@ -1149,9 +1149,9 @@ const ( TonCocoonOwnerClientRequestRefundOp PayloadOpName = "TonCocoonOwnerClientRequestRefund" TonStonfiV2StonfiProvideLiquidityJettonPayloadOp PayloadOpName = "TonStonfiV2StonfiProvideLiquidityJettonPayload" - TonTolkTestsTextCommentJettonPayloadOpCode PayloadOpCode = 0x00000000 - TonCocoonTextCommandOpCode PayloadOpCode = 0x00000000 TonCocoonTextCmdOpCode PayloadOpCode = 0x00000000 + TonCocoonTextCommandOpCode PayloadOpCode = 0x00000000 + TonTolkTestsTextCommentJettonPayloadOpCode PayloadOpCode = 0x00000000 TonTep74ChangeMinterAdminOpCode PayloadOpCode = 0x00000003 TonTep74ChangeMinterContentOpCode PayloadOpCode = 0x00000004 TonTep74MintNewJettonsOpCode PayloadOpCode = 0x00000015 @@ -1227,9 +1227,9 @@ const ( TonTolkTestsWithdrawPayloadJettonPayloadOpCode PayloadOpCode = 0xcb03bfaf TonTolkTestsMoonSwapSucceedJettonPayloadOpCode PayloadOpCode = 0xcb7f38d6 TonTep74ResponseWalletAddressOpCode PayloadOpCode = 0xd1735400 - TonTep74AboaLisaOpCode PayloadOpCode = 0xd53276db TonCocoonReturnExcessesBackOpCode PayloadOpCode = 0xd53276db TonTep74ReturnExcessesBackOpCode PayloadOpCode = 0xd53276db + TonTep74AboaLisaOpCode PayloadOpCode = 0xd53276db TonTolkTestsMoonCreateOrderJettonPayloadOpCode PayloadOpCode = 0xda067c19 TonCocoonOwnerClientWithdrawOpCode PayloadOpCode = 0xda068e78 TonTolkTestsBidaskDammSwapJettonPayloadOpCode PayloadOpCode = 0xdd79732c @@ -1247,9 +1247,9 @@ const ( ) var KnownPayloadTypes = map[string]any{ - TonTolkTestsTextCommentJettonPayloadOp: TonTolkTestsTextComment{}, - TonCocoonTextCommandOp: TonCocoonTextCommandPayloadBody{}, TonCocoonTextCmdOp: TonCocoonTextCmdPayloadBody{}, + TonCocoonTextCommandOp: TonCocoonTextCommandPayloadBody{}, + TonTolkTestsTextCommentJettonPayloadOp: TonTolkTestsTextComment{}, TonTep74ChangeMinterAdminOp: TonTep74ChangeMinterAdminPayloadBody{}, TonTep74ChangeMinterContentOp: TonTep74ChangeMinterContentPayloadBody{}, TonTep74MintNewJettonsOp: TonTep74MintNewJettonsPayloadBody{}, @@ -1325,9 +1325,9 @@ var KnownPayloadTypes = map[string]any{ TonTolkTestsWithdrawPayloadJettonPayloadOp: TonTolkTestsWithdrawPayload{}, TonTolkTestsMoonSwapSucceedJettonPayloadOp: TonTolkTestsMoonSwapSucceed{}, TonTep74ResponseWalletAddressOp: TonTep74ResponseWalletAddressPayloadBody{}, - TonTep74AboaLisaOp: TonTep74AboaLisaPayloadBody{}, TonCocoonReturnExcessesBackOp: TonCocoonReturnExcessesBackPayloadBody{}, TonTep74ReturnExcessesBackOp: TonTep74ReturnExcessesBackPayloadBody{}, + TonTep74AboaLisaOp: TonTep74AboaLisaPayloadBody{}, TonTolkTestsMoonCreateOrderJettonPayloadOp: TonTolkTestsMoonCreateOrder{}, TonCocoonOwnerClientWithdrawOp: TonCocoonOwnerClientWithdrawPayloadBody{}, TonTolkTestsBidaskDammSwapJettonPayloadOp: TonTolkTestsBidaskDammSwap{}, @@ -1344,9 +1344,9 @@ var KnownPayloadTypes = map[string]any{ TonStonfiV2StonfiProvideLiquidityJettonPayloadOp: TonStonfiV2StonfiProvideLiquidity{}, } var PayloadOpCodes = map[PayloadOpName]PayloadOpCode{ - TonTolkTestsTextCommentJettonPayloadOp: TonTolkTestsTextCommentJettonPayloadOpCode, - TonCocoonTextCommandOp: TonCocoonTextCommandOpCode, TonCocoonTextCmdOp: TonCocoonTextCmdOpCode, + TonCocoonTextCommandOp: TonCocoonTextCommandOpCode, + TonTolkTestsTextCommentJettonPayloadOp: TonTolkTestsTextCommentJettonPayloadOpCode, TonTep74ChangeMinterAdminOp: TonTep74ChangeMinterAdminOpCode, TonTep74ChangeMinterContentOp: TonTep74ChangeMinterContentOpCode, TonTep74MintNewJettonsOp: TonTep74MintNewJettonsOpCode, @@ -1422,9 +1422,9 @@ var PayloadOpCodes = map[PayloadOpName]PayloadOpCode{ TonTolkTestsWithdrawPayloadJettonPayloadOp: TonTolkTestsWithdrawPayloadJettonPayloadOpCode, TonTolkTestsMoonSwapSucceedJettonPayloadOp: TonTolkTestsMoonSwapSucceedJettonPayloadOpCode, TonTep74ResponseWalletAddressOp: TonTep74ResponseWalletAddressOpCode, - TonTep74AboaLisaOp: TonTep74AboaLisaOpCode, TonCocoonReturnExcessesBackOp: TonCocoonReturnExcessesBackOpCode, TonTep74ReturnExcessesBackOp: TonTep74ReturnExcessesBackOpCode, + TonTep74AboaLisaOp: TonTep74AboaLisaOpCode, TonTolkTestsMoonCreateOrderJettonPayloadOp: TonTolkTestsMoonCreateOrderJettonPayloadOpCode, TonCocoonOwnerClientWithdrawOp: TonCocoonOwnerClientWithdrawOpCode, TonTolkTestsBidaskDammSwapJettonPayloadOp: TonTolkTestsBidaskDammSwapJettonPayloadOpCode, @@ -1599,9 +1599,9 @@ func (c ContractInterface) Payloads() map[PayloadOpCode][]func(*Payload, *boc.Ce var funcPayloadDecodersMapping = map[PayloadOpCode][]func(*Payload, *boc.Cell) error{ 0: { - decodeTonTolkTestsTextCommentJettonPayloadOpPayload, - decodeTonCocoonTextCommandOpPayload, decodeTonCocoonTextCmdOpPayload, + decodeTonCocoonTextCommandOpPayload, + decodeTonTolkTestsTextCommentJettonPayloadOpPayload, }, TonTep74ChangeMinterAdminOpCode: {decodeTonTep74ChangeMinterAdminOpPayload}, TonTep74ChangeMinterContentOpCode: {decodeTonTep74ChangeMinterContentOpPayload}, @@ -1679,9 +1679,9 @@ var funcPayloadDecodersMapping = map[PayloadOpCode][]func(*Payload, *boc.Cell) e TonTolkTestsMoonSwapSucceedJettonPayloadOpCode: {decodeTonTolkTestsMoonSwapSucceedJettonPayloadOpPayload}, TonTep74ResponseWalletAddressOpCode: {decodeTonTep74ResponseWalletAddressOpPayload}, 3576854235: { - decodeTonTep74AboaLisaOpPayload, decodeTonCocoonReturnExcessesBackOpPayload, decodeTonTep74ReturnExcessesBackOpPayload, + decodeTonTep74AboaLisaOpPayload, }, TonTolkTestsMoonCreateOrderJettonPayloadOpCode: {decodeTonTolkTestsMoonCreateOrderJettonPayloadOpPayload}, TonCocoonOwnerClientWithdrawOpCode: {decodeTonCocoonOwnerClientWithdrawOpPayload}, @@ -1699,13 +1699,13 @@ var funcPayloadDecodersMapping = map[PayloadOpCode][]func(*Payload, *boc.Cell) e TonStonfiV2StonfiProvideLiquidityJettonPayloadOpCode: {decodeTonStonfiV2StonfiProvideLiquidityJettonPayloadOpPayload}, } -type TonTolkTestsTextComment struct { - Text tlb.Any -} +type TonCocoonTextCmdPayloadBody = TonCocoonTextCmd type TonCocoonTextCommandPayloadBody = TonCocoonTextCommand -type TonCocoonTextCmdPayloadBody = TonCocoonTextCmd +type TonTolkTestsTextComment struct { + Text tlb.Any +} type TonTep74ChangeMinterAdminPayloadBody = TonTep74ChangeMinterAdmin @@ -1981,12 +1981,12 @@ type TonTolkTestsMoonSwapSucceed struct { type TonTep74ResponseWalletAddressPayloadBody = TonTep74ResponseWalletAddress -type TonTep74AboaLisaPayloadBody = TonTep74AboaLisa - type TonCocoonReturnExcessesBackPayloadBody = TonCocoonReturnExcessesBack type TonTep74ReturnExcessesBackPayloadBody = TonTep74ReturnExcessesBack +type TonTep74AboaLisaPayloadBody = TonTep74AboaLisa + type TonTolkTestsMoonCreateOrder struct { Asset1 tlb.MsgAddress Asset2 tlb.MsgAddress diff --git a/boc/bitString.go b/boc/bitString.go index fb914333..56064013 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/tolk/abi/types.go b/tolk/abi/types.go deleted file mode 100644 index 55c6b83a..00000000 --- a/tolk/abi/types.go +++ /dev/null @@ -1,539 +0,0 @@ -package tolkAbi - -import ( - "encoding/json" - "fmt" - "math/big" - - "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"` - } -} - -func (d *DefaultValue) UnmarshalJSON(b []byte) error { - var kind Kind - - if err := json.Unmarshal(b, &kind); err != nil { - return err - } - - d.SumType = kind.Kind - switch d.SumType { - case "int": - if err := json.Unmarshal(b, &d.IntDefaultValue); err != nil { - return err - } - case "bool": - if err := json.Unmarshal(b, &d.BoolDefaultValue); err != nil { - return err - } - case "address": - if err := json.Unmarshal(b, &d.AddressDefaultValue); err != nil { - return err - } - case "tensor": - if err := json.Unmarshal(b, &d.TensorDefaultValue); err != nil { - return err - } - case "null": // do nothing since null value have no additional fields - default: - return fmt.Errorf("unknown default value type %q", d.SumType) - } - - return nil -} - -func (d *DefaultValue) 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 "int": - payload, err = json.Marshal(d.IntDefaultValue) - if err != nil { - return nil, err - } - return concatPrefixAndPayload(prefix, payload), nil - case "bool": - payload, err = json.Marshal(d.BoolDefaultValue) - if err != nil { - return nil, err - } - return concatPrefixAndPayload(prefix, payload), nil - case "address": - payload, err = json.Marshal(d.AddressDefaultValue) - if err != nil { - return nil, err - } - return concatPrefixAndPayload(prefix, payload), nil - case "tensor": - payload, err = json.Marshal(d.TensorDefaultValue) - if err != nil { - return nil, err - } - return concatPrefixAndPayload(prefix, payload), nil - case "null": - return prefix, nil - default: - return nil, fmt.Errorf("unknown default value type %q", d.SumType) - } -} - -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"` - NumberTy struct { - N int `json:"n"` - } - BitsTy struct { - N int `json:"n"` - } - NullableTy struct { - Inner *Ty `json:"inner"` - } - CellOf struct { - Inner *Ty `json:"inner"` - } - TensorTy struct { - Items []Ty `json:"items"` - } - TupleWithTy struct { - Items []Ty `json:"items"` - } - MapTy struct { - K *Ty `json:"k"` - V *Ty `json:"v"` - } - EnumRefTy struct { - EnumName string `json:"enumName"` - } - StructRefTy struct { - StructName string `json:"structName"` - TypeArgs []Ty `json:"typeArgs,omitempty"` - } - AliasRefTy struct { - AliasName string `json:"aliasName"` - TypeArgs []Ty `json:"typeArgs,omitempty"` - } - GenericTy struct { - NameT string `json:"nameT"` - } - Union struct { - Variants []UnionVariant `json:"variants"` - } -} - -func (t *Ty) UnmarshalJSON(b []byte) error { - var kind Kind - if err := json.Unmarshal(b, &kind); err != nil { - return err - } - - t.SumType = kind.Kind - switch t.SumType { - case "intN", "uintN", "varintN", "varuintN": - if err := json.Unmarshal(b, &t.NumberTy); err != nil { - return err - } - case "bitsN": - if err := json.Unmarshal(b, &t.BitsTy); err != nil { - return err - } - case "nullable": - if err := json.Unmarshal(b, &t.NullableTy); err != nil { - return err - } - case "cellOf": - if err := json.Unmarshal(b, &t.CellOf); err != nil { - return err - } - case "tensor": - if err := json.Unmarshal(b, &t.TensorTy); err != nil { - return err - } - case "tupleWith": - if err := json.Unmarshal(b, &t.TupleWithTy); err != nil { - return err - } - case "mapKV": - if err := json.Unmarshal(b, &t.MapTy); err != nil { - return err - } - case "EnumRef": - if err := json.Unmarshal(b, &t.EnumRefTy); err != nil { - return err - } - case "StructRef": - if err := json.Unmarshal(b, &t.StructRefTy); err != nil { - return err - } - case "AliasRef": - if err := json.Unmarshal(b, &t.AliasRefTy); err != nil { - return err - } - case "genericT": - if err := json.Unmarshal(b, &t.GenericTy); err != nil { - return err - } - case "union": - if err := json.Unmarshal(b, &t.Union); err != nil { - return err - } - case "int", "coins", "bool", "cell", "slice", "builder", "remaining", "address", "addressOpt", "addressExt", - "addressAny", "tupleAny", "nullLiteral", "callable", "void": - return nil - default: - return fmt.Errorf("unknown ty type %q", t.SumType) - } - - return nil -} - -func (t *Ty) MarshalJSON() ([]byte, error) { - var kind Kind - kind.Kind = t.SumType - - var payload []byte - prefix, err := json.Marshal(kind) - if err != nil { - return nil, err - } - - switch t.SumType { - case "intN", "uintN", "varintN", "varuintN": - payload, err = json.Marshal(t.NumberTy) - if err != nil { - return nil, err - } - return concatPrefixAndPayload(prefix, payload), nil - case "bitsN": - payload, err = json.Marshal(t.BitsTy) - if err != nil { - return nil, err - } - return concatPrefixAndPayload(prefix, payload), nil - case "nullable": - payload, err = json.Marshal(t.NullableTy) - if err != nil { - return nil, err - } - return concatPrefixAndPayload(prefix, payload), nil - case "cellOf": - payload, err = json.Marshal(t.CellOf) - if err != nil { - return nil, err - } - return concatPrefixAndPayload(prefix, payload), nil - case "tensor": - payload, err = json.Marshal(t.TensorTy) - if err != nil { - return nil, err - } - return concatPrefixAndPayload(prefix, payload), nil - case "tupleWith": - payload, err = json.Marshal(t.TupleWithTy) - if err != nil { - return nil, err - } - return concatPrefixAndPayload(prefix, payload), nil - case "mapKV": - payload, err = json.Marshal(t.MapTy) - if err != nil { - return nil, err - } - return concatPrefixAndPayload(prefix, payload), nil - case "EnumRef": - payload, err = json.Marshal(t.EnumRefTy) - if err != nil { - return nil, err - } - return concatPrefixAndPayload(prefix, payload), nil - case "StructRef": - payload, err = json.Marshal(t.StructRefTy) - if err != nil { - return nil, err - } - return concatPrefixAndPayload(prefix, payload), nil - case "AliasRef": - payload, err = json.Marshal(t.AliasRefTy) - if err != nil { - return nil, err - } - return concatPrefixAndPayload(prefix, payload), nil - case "genericT": - payload, err = json.Marshal(t.GenericTy) - if err != nil { - return nil, err - } - return concatPrefixAndPayload(prefix, payload), nil - case "union": - payload, err = json.Marshal(t.Union) - if err != nil { - return nil, err - } - return concatPrefixAndPayload(prefix, payload), nil - case "int", "coins", "bool", "cell", "slice", "builder", "remaining", "address", "addressOpt", "addressExt", - "addressAny", "tupleAny", "nullLiteral", "callable", "void": - return prefix, nil - default: - return nil, fmt.Errorf("unknown ty type %q", t.SumType) - } -} - -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.StructRefTy.StructName, nil - case "AliasRef": - return ty.AliasRefTy.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 { - 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/abi_types.go b/tolk/abi_types.go new file mode 100644 index 00000000..72ca065d --- /dev/null +++ b/tolk/abi_types.go @@ -0,0 +1,881 @@ +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 TolkValue) (bool, error) { + vType := v.GetType() + switch d.SumType { + case "IntDefaultValue": + val, err := binDecHexToUint(d.IntDefaultValue.V) + if err != nil { + return false, err + } + err = v.SetValue(val) + if err != nil { + return false, err + } + case "BoolDefaultValue": + err := v.SetValue(d.BoolDefaultValue.V) + if err != nil { + return false, err + } + case "SliceDefaultValue": + if vType.SumType != "Remaining" && vType.SumType != "Slice" { + return false, fmt.Errorf("default type %v and field type %v mismatch", d.SumType, vType.SumType) + } + 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 + } + anySlice := Any(*boc.NewCellWithBits(bs)) + err = v.SetValue(anySlice) + if err != nil { + return false, err + } + case "AddressDefaultValue": + if vType.SumType != "Address" { + return false, fmt.Errorf("default type %v and field type %v mismatch", d.SumType, vType.SumType) + } + accountID, err := ton.ParseAccountID(d.AddressDefaultValue.Address) + if err != nil { + return false, err + } + err = v.SetValue(InternalAddress{ + Workchain: int8(accountID.Workchain), + Address: accountID.Address, + }) + if err != nil { + return false, err + } + case "TensorDefaultValue": + tensor := make([]Value, len(d.TensorDefaultValue.Items)) + for i, item := range d.TensorDefaultValue.Items { + val := Value{} + _, err := item.UnmarshalDefaultValue(&val) + if err != nil { + return false, err + } + tensor[i] = val + } + err := v.SetValue(tensor) + 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) UnmarshalTolk(cell *boc.Cell, v TolkValue, decoder *Decoder) error { + v.SetType(*t) + switch t.SumType { + case "Int": + return t.Int.UnmarshalTolk(cell, v, decoder) + case "NullLiteral": + return t.NullLiteral.UnmarshalTolk(cell, v, decoder) + case "Void": + return t.Void.UnmarshalTolk(cell, v, decoder) + case "IntN": + return t.IntN.UnmarshalTolk(cell, v, decoder) + case "UintN": + return t.UintN.UnmarshalTolk(cell, v, decoder) + case "VarIntN": + return t.VarIntN.UnmarshalTolk(cell, v, decoder) + case "VarUintN": + return t.VarUintN.UnmarshalTolk(cell, v, decoder) + case "BitsN": + return t.BitsN.UnmarshalTolk(cell, v, decoder) + case "Coins": + return t.Coins.UnmarshalTolk(cell, v, decoder) + case "Bool": + return t.Bool.UnmarshalTolk(cell, v, decoder) + case "Cell": + return t.Cell.UnmarshalTolk(cell, v, decoder) + case "Slice": + return t.Slice.UnmarshalTolk(cell, v, decoder) + case "Builder": + return t.Builder.UnmarshalTolk(cell, v, decoder) + case "Callable": + return t.Callable.UnmarshalTolk(cell, v, decoder) + case "Remaining": + return t.Remaining.UnmarshalTolk(cell, v, decoder) + case "Address": + return t.Address.UnmarshalTolk(cell, v, decoder) + case "AddressOpt": + return t.AddressOpt.UnmarshalTolk(cell, v, decoder) + case "AddressExt": + return t.AddressExt.UnmarshalTolk(cell, v, decoder) + case "AddressAny": + return t.AddressAny.UnmarshalTolk(cell, v, decoder) + case "Nullable": + return t.Nullable.UnmarshalTolk(cell, v, decoder) + case "CellOf": + return t.CellOf.UnmarshalTolk(cell, v, decoder) + case "Tensor": + return t.Tensor.UnmarshalTolk(cell, v, decoder) + case "TupleWith": + return t.TupleWith.UnmarshalTolk(cell, v, decoder) + case "TupleAny": + return t.TupleAny.UnmarshalTolk(cell, v, decoder) + case "Map": + return t.Map.UnmarshalTolk(cell, v, decoder) + case "EnumRef": + return t.EnumRef.UnmarshalTolk(cell, v, decoder) + case "StructRef": + return t.StructRef.UnmarshalTolk(cell, v, decoder) + case "AliasRef": + return t.AliasRef.UnmarshalTolk(cell, v, decoder) + case "Generic": + return t.Generic.UnmarshalTolk(cell, v, decoder) + case "Union": + return t.Union.UnmarshalTolk(cell, v, decoder) + default: + return fmt.Errorf("unknown t 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..fb8089ff --- /dev/null +++ b/tolk/addresses.go @@ -0,0 +1,252 @@ +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.internalAddress = &a + return nil +} + +func (Address) UnmarshalTolk(cell *boc.Cell, v TolkValue, decoder *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 = v.SetValue(InternalAddress{ + Workchain: int8(workchain), + Address: [32]byte(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.optionalAddress = &a + return nil +} + +func (AddressOpt) UnmarshalTolk(cell *boc.Cell, v TolkValue, decoder *Decoder) error { + tag, err := cell.ReadUint(2) + if err != nil { + return err + } + if tag == 0 { + err = v.SetValue(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 = v.SetValue(OptionalAddress{ + SumType: "InternalAddress", + InternalAddress: InternalAddress{ + Workchain: int8(workchain), + Address: [32]byte(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 + return nil +} + +func (AddressExt) UnmarshalTolk(cell *boc.Cell, v TolkValue, decoder *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 = v.SetValue(ExternalAddress{ + Len: int16(ln), + Address: bs, + }) + 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 + return nil +} + +func (AddressAny) UnmarshalTolk(cell *boc.Cell, v TolkValue, decoder *Decoder) error { + tag, err := cell.ReadUint(2) + if err != nil { + return err + } + switch tag { + case 0: + err = v.SetValue(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 = v.SetValue(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 = v.SetValue(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 = v.SetValue(AnyAddress{ + SumType: "VarAddress", + VarAddress: &VarAddress{ + Len: int16(ln), + Workchain: int32(workchain), + Address: bs, + }, + }) + 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..ecaa82af --- /dev/null +++ b/tolk/cells.go @@ -0,0 +1,195 @@ +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 + return nil +} + +func (Cell) UnmarshalTolk(cell *boc.Cell, v TolkValue, decoder *Decoder) error { + ref, err := cell.NextRef() + if err != nil { + return err + } + err = v.SetValue(Any(*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 { + a, ok := val.(Any) + if !ok { + return fmt.Errorf("value is not a cell") + } + v.cell = &a + return nil +} + +func (Slice) UnmarshalTolk(cell *boc.Cell, v TolkValue, decoder *Decoder) 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 { + a, ok := val.(Any) + if !ok { + return fmt.Errorf("value is not a cell") + } + v.cell = &a + return nil +} + +func (Builder) UnmarshalTolk(cell *boc.Cell, v TolkValue, decoder *Decoder) 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 { + a, ok := val.(Any) + if !ok { + return fmt.Errorf("value is not a cell") + } + v.cell = &a + return nil +} + +func (Callable) UnmarshalTolk(cell *boc.Cell, v TolkValue, decoder *Decoder) 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 + return nil +} + +func (Remaining) UnmarshalTolk(cell *boc.Cell, v TolkValue, decoder *Decoder) error { + rem := cell.CopyRemaining() + if rem != nil { + err := v.SetValue(Any(*rem)) + 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 + return nil +} + +func (n Nullable) UnmarshalTolk(cell *boc.Cell, v TolkValue, decoder *Decoder) error { + isExists, err := cell.ReadBit() + if err != nil { + return err + } + innerV := Value{ + valType: n.Inner, + } + optV := OptValue{ + IsExists: isExists, + Val: innerV, + } + if isExists { + err = n.Inner.UnmarshalTolk(cell, &innerV, decoder) + if err != nil { + return err + } + optV.Val = innerV + } + err = v.SetValue(optV) + 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 + return nil +} + +func (c CellOf) UnmarshalTolk(cell *boc.Cell, v TolkValue, decoder *Decoder) error { + ref, err := cell.NextRef() + if err != nil { + return err + } + innerV := Value{} + err = c.Inner.UnmarshalTolk(ref, &innerV, decoder) + if err != nil { + return err + } + err = v.SetValue(RefValue(innerV)) + 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..9b14475b --- /dev/null +++ b/tolk/integers.go @@ -0,0 +1,313 @@ +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 TolkValue, decoder *Decoder) 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 + } 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()) + } + wi64 := i64 + v.smallInt = &wi64 + } + return nil +} + +func (i IntN) UnmarshalTolk(cell *boc.Cell, v TolkValue, decoder *Decoder) error { + num, err := cell.ReadBigInt(i.N) + if err != nil { + return err + } + err = v.SetValue(BigInt(*num)) + 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 + } 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()) + } + wui64 := ui64 + v.smallUint = &wui64 + } + return nil +} + +func (u UintN) UnmarshalTolk(cell *boc.Cell, v TolkValue, decoder *Decoder) error { + num, err := cell.ReadBigUint(u.N) + if err != nil { + return err + } + err = v.SetValue(BigInt(*num)) + 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 + return nil +} + +func (vi VarIntN) UnmarshalTolk(cell *boc.Cell, v TolkValue, 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 = v.SetValue(BigInt(*val)) + 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 { + bi, ok := val.(BigInt) + if !ok { + return fmt.Errorf("value is not a BigInt") + } + v.bigInt = &bi + return nil +} + +func (vu VarUintN) UnmarshalTolk(cell *boc.Cell, v TolkValue, 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 = v.SetValue(BigInt(*val)) + 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 + return nil +} + +func (b BitsN) UnmarshalTolk(cell *boc.Cell, v TolkValue, decoder *Decoder) error { + n := b.N + val, err := cell.ReadBits(n) + if err != nil { + return err + } + err = v.SetValue(Bits(val)) + 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 + return nil +} + +func (Coins) UnmarshalTolk(cell *boc.Cell, v TolkValue, 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 = v.SetValue(BigInt(*val)) + 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 + return nil +} + +func (Bool) UnmarshalTolk(cell *boc.Cell, v TolkValue, decoder *Decoder) error { + val, err := cell.ReadBit() + if err != nil { + return err + } + err = v.SetValue(BoolValue(val)) + 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..015f5b70 --- /dev/null +++ b/tolk/map.go @@ -0,0 +1,214 @@ +package tolk + +import ( + "fmt" + + "github.com/tonkeeper/tongo/boc" +) + +type TolkType interface { + UnmarshalTolk(cell *boc.Cell, v TolkValue, decoder *Decoder) error +} + +type TolkComparableType interface { + UnmarshalTolk(cell *boc.Cell, v TolkValue, decoder *Decoder) error + GetFixedSize() int +} + +type TolkComparableValue interface { + Equal(other any) bool + Compare(other any) (int, bool) +} + +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 + return nil +} + +func (m Map) UnmarshalTolk(cell *boc.Cell, v TolkValue, 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{ + keyType: m.K, + valType: m.V, + 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 = v.SetValue(mp) + if err != nil { + return err + } + + 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 = vt.UnmarshalTolk(c, &v, 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 = kt.UnmarshalTolk(cell, &k, 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) Equal(v Value, o Value) bool { + return false +} diff --git a/tolk/null.go b/tolk/null.go new file mode 100644 index 00000000..7cc46b22 --- /dev/null +++ b/tolk/null.go @@ -0,0 +1,31 @@ +package tolk + +import "github.com/tonkeeper/tongo/boc" + +type NullLiteral struct{} + +func (NullLiteral) SetValue(v *Value, val any) error { + return nil +} + +func (NullLiteral) UnmarshalTolk(cell *boc.Cell, v TolkValue, decoder *Decoder) error { + return nil +} + +func (NullLiteral) Equal(v Value, o Value) bool { + return false +} + +type Void struct{} + +func (Void) SetValue(v *Value, val any) error { + return nil +} + +func (Void) UnmarshalTolk(cell *boc.Cell, v TolkValue, decoder *Decoder) 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 index e810e25d..c417f6ac 100644 --- a/tolk/parser/parser.go +++ b/tolk/parser/parser.go @@ -1,12 +1,11 @@ package tolkParser import ( - "errors" "fmt" "strconv" "strings" - tolkAbi "github.com/tonkeeper/tongo/tolk/abi" + "github.com/tonkeeper/tongo/tolk" "github.com/tonkeeper/tongo/utils" ) @@ -17,18 +16,18 @@ type DefaultType struct { 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}, + "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}, } ) @@ -47,12 +46,12 @@ type Tag struct { Val uint64 } -func ParseStructMsg(ty tolkAbi.Ty, msgName, contractName string) (*MsgResult, error) { +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.StructRefTy.StructName, ty.StructRefTy.TypeArgs, contractName) + code, err := createGolangAlias(ty.StructRef.StructName, ty.StructRef.TypeArgs, contractName) if err != nil { return nil, err } @@ -63,12 +62,12 @@ func ParseStructMsg(ty tolkAbi.Ty, msgName, contractName string) (*MsgResult, er }, nil } -func ParseAliasMsg(ty tolkAbi.Ty, msgName, contractName string) (*MsgResult, error) { +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.AliasRefTy.AliasName, ty.AliasRefTy.TypeArgs, contractName) + code, err := createGolangAlias(ty.AliasRef.AliasName, ty.AliasRef.TypeArgs, contractName) if err != nil { return nil, err } @@ -79,15 +78,15 @@ func ParseAliasMsg(ty tolkAbi.Ty, msgName, contractName string) (*MsgResult, err }, nil } -func ParseGetMethodCode(ty tolkAbi.Ty, contractName string) (string, error) { +func ParseGetMethodCode(ty tolk.Ty, contractName string) (string, error) { switch ty.SumType { case "StructRef": - name := utils.ToCamelCase(ty.StructRefTy.StructName) - return createGolangAlias(name, ty.StructRefTy.TypeArgs, contractName) + name := utils.ToCamelCase(ty.StructRef.StructName) + return createGolangAlias(name, ty.StructRef.TypeArgs, contractName) case "AliasRef": - name := utils.ToCamelCase(ty.AliasRefTy.AliasName) - return createGolangAlias(name, ty.AliasRefTy.TypeArgs, contractName) - case "tensor": + 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) @@ -98,7 +97,7 @@ func ParseGetMethodCode(ty tolkAbi.Ty, contractName string) (string, error) { res.WriteString("`vmStackHint:\"tensor\"`\n}\n") return res.String(), nil - case "tupleWith": + case "TupleWith": var res strings.Builder res.WriteString("struct {\nField ") tlbType, _, err := parseTy(ty, contractName) @@ -124,7 +123,7 @@ func ParseGetMethodCode(ty tolkAbi.Ty, contractName string) (string, error) { } } -func createGolangAlias(aliasType string, typeArgs []tolkAbi.Ty, contractName string) (string, error) { +func createGolangAlias(aliasType string, typeArgs []tolk.Ty, contractName string) (string, error) { var res strings.Builder res.WriteString(" = ") res.WriteString(contractName + aliasType) @@ -139,16 +138,16 @@ func createGolangAlias(aliasType string, typeArgs []tolkAbi.Ty, contractName str } func ParseTag( - ty tolkAbi.Ty, - structRefs map[string]tolkAbi.StructDeclaration, - aliasRefs map[string]tolkAbi.AliasDeclaration, - enumRefs map[string]tolkAbi.EnumDeclaration, + 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.StructRefTy.StructName].Prefix + prefix := structRefs[ty.StructRef.StructName].Prefix if prefix == nil { - return nil, fmt.Errorf("%v tag is nil", ty.StructRefTy.StructName) + return nil, fmt.Errorf("%v tag is nil", ty.StructRef.StructName) } convertedTag, err := convertPrefixTagToInt(*prefix) if err != nil { @@ -156,23 +155,17 @@ func ParseTag( } return convertedTag, nil case "AliasRef": - aliasRef := aliasRefs[ty.AliasRefTy.AliasName] - if aliasRef.TargetTy == nil { - return nil, fmt.Errorf("alias ref ty cannot be nil") - } - return ParseTag(*aliasRef.TargetTy, structRefs, aliasRefs, enumRefs) + aliasRef := aliasRefs[ty.AliasRef.AliasName] + return ParseTag(aliasRef.TargetTy, structRefs, aliasRefs, enumRefs) case "EnumRef": - enumRef := enumRefs[ty.EnumRefTy.EnumName] - if enumRef.EncodedAs == nil { - return nil, fmt.Errorf("enum ref ty cannot be nil") - } - return ParseTag(*enumRef.EncodedAs, structRefs, aliasRefs, enumRefs) + 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 tolkAbi.StructDeclaration, contractName string) (*DeclrResult, error) { +func ParseStructDeclr(declr tolk.StructDeclaration, contractName string) (*DeclrResult, error) { result := DeclrResult{} unionStructs := make([]string, 0) @@ -213,20 +206,16 @@ func ParseStructDeclr(declr tolkAbi.StructDeclaration, contractName string) (*De return &result, nil } -func ParseAliasDeclr(declr tolkAbi.AliasDeclaration, contractName string) (*DeclrResult, error) { +func ParseAliasDeclr(declr tolk.AliasDeclaration, contractName string) (*DeclrResult, error) { result := DeclrResult{} - if declr.TargetTy == nil { - return nil, errors.New("target ty cannot be null") - } - 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) + tlbType, tlbTag, err := parseTy(declr.TargetTy, contractName) if err != nil { return nil, err } @@ -235,8 +224,8 @@ func ParseAliasDeclr(declr tolkAbi.AliasDeclaration, contractName string) (*Decl res.WriteString(wrappedType) res.WriteRune('\n') - if declr.TargetTy.SumType == "union" { - res.WriteString(generateJSONMarshalForUnion(*declr.TargetTy, typeName)) + if declr.TargetTy.SumType == "Union" { + res.WriteString(generateJSONMarshalForUnion(declr.TargetTy, typeName)) } result.Code = res.String() @@ -245,18 +234,25 @@ func ParseAliasDeclr(declr tolkAbi.AliasDeclaration, contractName string) (*Decl return &result, nil } -func ParseEnumDeclr(declr tolkAbi.EnumDeclaration, contractName string) (*DeclrResult, error) { +func ParseEnumDeclr(declr tolk.EnumDeclaration, contractName string) (*DeclrResult, error) { result := DeclrResult{} - if declr.EncodedAs == nil { - return nil, errors.New("target ty cannot be null") - } - isBigInt := false // enum is always an integer // if number has >64 bits or its varint/varuint then type should be bigInt - if declr.EncodedAs.NumberTy.N > 64 || strings.HasPrefix(declr.EncodedAs.SumType, "var") { + 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 @@ -265,7 +261,7 @@ func ParseEnumDeclr(declr tolkAbi.EnumDeclaration, contractName string) (*DeclrR res.WriteString(enumName) res.WriteString(" = ") - tlbType, tlbTag, err := parseTy(*declr.EncodedAs, contractName) + tlbType, tlbTag, err := parseTy(declr.EncodedAs, contractName) if err != nil { return nil, err } @@ -301,7 +297,7 @@ func ParseEnumDeclr(declr tolkAbi.EnumDeclaration, contractName string) (*DeclrR return &result, nil } -func parseField(structName string, field tolkAbi.Field, contractName string) (string, string, error) { +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) @@ -319,7 +315,7 @@ func parseField(structName string, field tolkAbi.Field, contractName string) (st return "", "", err } // union and not tlb.Either - if field.Ty.SumType == "union" && len(field.Ty.Union.Variants) > 2 { + if field.Ty.SumType == "Union" && len(field.Ty.Union.Variants) > 2 { res.WriteString(structName + name) unionStruct.WriteString("type ") @@ -340,7 +336,7 @@ func parseField(structName string, field tolkAbi.Field, contractName string) (st return res.String(), unionStruct.String(), nil } -func generateJSONMarshalForUnion(union tolkAbi.Ty, structName string) string { +func generateJSONMarshalForUnion(union tolk.Ty, structName string) string { if len(union.Union.Variants) == 2 { // tlb.Either return "" } @@ -363,7 +359,7 @@ func generateJSONMarshalForUnion(union tolkAbi.Ty, structName string) string { return res.String() } -func ParseType(ty tolkAbi.Ty, contractName string) (string, error) { +func ParseType(ty tolk.Ty, contractName string) (string, error) { tlbType, tlbTag, err := parseTy(ty, contractName) if err != nil { return "", err @@ -372,7 +368,8 @@ func ParseType(ty tolkAbi.Ty, contractName string) (string, error) { return wrapTlbTypeIntoTlbTag(tlbType, tlbTag), nil } -func parseTy(ty tolkAbi.Ty, contractName string) (string, string, error) { +// 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] @@ -385,8 +382,8 @@ func parseTy(ty tolkAbi.Ty, contractName string) (string, string, error) { } switch ty.SumType { - case "intN": - n := ty.NumberTy.N + case "IntN": + n := ty.IntN.N tlbIntType := fmt.Sprintf("tlb.Int%v", n) if n == 8 { tlbIntType = "int8" @@ -398,8 +395,8 @@ func parseTy(ty tolkAbi.Ty, contractName string) (string, string, error) { tlbIntType = "int64" } tlbType.WriteString(tlbIntType) - case "uintN": - n := ty.NumberTy.N + case "UintN": + n := ty.UintN.N tlbUIntType := fmt.Sprintf("tlb.Uint%v", n) if n == 8 { tlbUIntType = "uint8" @@ -411,17 +408,17 @@ func parseTy(ty tolkAbi.Ty, contractName string) (string, string, error) { tlbUIntType = "uint64" } tlbType.WriteString(tlbUIntType) - case "varintN", "varuintN": - tlbVarUIntType := fmt.Sprintf("tlb.VarUInteger%v", ty.NumberTy.N) + case "VarIntN": + tlbVarUIntType := fmt.Sprintf("tlb.VarUInteger%v", ty.VarIntN.N) tlbType.WriteString(tlbVarUIntType) - case "bitsN": - tlbVarUIntType := fmt.Sprintf("tlb.Bits%v", ty.BitsTy.N) + case "VarUintN": + tlbVarUIntType := fmt.Sprintf("tlb.VarUInteger%v", ty.VarUintN.N) tlbType.WriteString(tlbVarUIntType) - case "nullable": - if ty.NullableTy.Inner == nil { - return "", "", fmt.Errorf("inner nullable type cannot be null") - } - tlbMaybeType, tlbMaybeTag, err := parseTy(*ty.NullableTy.Inner, contractName) + 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 } @@ -432,11 +429,8 @@ func parseTy(ty tolkAbi.Ty, contractName string) (string, string, error) { tlbType.WriteRune('*') tlbType.WriteString(tlbMaybeType) tlbType.WriteRune(' ') - case "cellOf": - if ty.CellOf.Inner == nil { - return "", "", fmt.Errorf("inner cell type cannot be null") - } - tlbRefType, tlbRefTag, err := parseTy(*ty.CellOf.Inner, contractName) + case "CellOf": + tlbRefType, tlbRefTag, err := parseTy(ty.CellOf.Inner, contractName) if err != nil { return "", "", err } @@ -445,9 +439,9 @@ func parseTy(ty tolkAbi.Ty, contractName string) (string, string, error) { tlbType.WriteString(tlbRefType) tlbType.WriteRune(' ') - case "tensor": + case "Tensor": tlbType.WriteString("struct{\n") - for i, innerTy := range ty.TensorTy.Items { + for i, innerTy := range ty.Tensor.Items { innerTlbType, innerTlbTag, err := parseTy(innerTy, contractName) if err != nil { return "", "", err @@ -462,9 +456,9 @@ func parseTy(ty tolkAbi.Ty, contractName string) (string, string, error) { tlbType.WriteRune('\n') } tlbType.WriteRune('}') - case "tupleWith": + case "TupleWith": tlbType.WriteString("struct{\n") - for i, innerTy := range ty.TupleWithTy.Items { + for i, innerTy := range ty.TupleWith.Items { innerTlbType, innerTlbTag, err := parseTy(innerTy, contractName) if err != nil { return "", "", err @@ -479,19 +473,13 @@ func parseTy(ty tolkAbi.Ty, contractName string) (string, string, error) { tlbType.WriteRune('\n') } tlbType.WriteRune('}') - case "mapKV": - if ty.MapTy.K == nil { - return "", "", fmt.Errorf("map key cannot be null") - } - if ty.MapTy.V == nil { - return "", "", fmt.Errorf("map value cannot be null") - } + case "Map": tlbType.WriteString("tlb.HashmapE[") - fixedType, err := getFixedSizeTypeForMap(*ty.MapTy.K) + fixedType, err := getFixedSizeTypeForMap(ty.Map.K) if err != nil { return "", "", err } - valueType, valueTypeTag, err := parseTy(*ty.MapTy.V, contractName) + valueType, valueTypeTag, err := parseTy(ty.Map.V, contractName) wrappedType := wrapTlbTypeIntoTlbTag(valueType, valueTypeTag) tlbType.WriteString(fixedType) @@ -499,26 +487,26 @@ func parseTy(ty tolkAbi.Ty, contractName string) (string, string, error) { tlbType.WriteString(wrappedType) tlbType.WriteRune(']') case "EnumRef": - name := contractName + utils.ToCamelCase(ty.EnumRefTy.EnumName) + name := contractName + utils.ToCamelCase(ty.EnumRef.EnumName) tlbType.WriteString(name) case "StructRef": - name := contractName + utils.ToCamelCase(ty.StructRefTy.StructName) + name := contractName + utils.ToCamelCase(ty.StructRef.StructName) tlbType.WriteString(name) - err := writeGenericTypesPart(&tlbType, ty.StructRefTy.TypeArgs, contractName) + err := writeGenericTypesPart(&tlbType, ty.StructRef.TypeArgs, contractName) if err != nil { return "", "", err } case "AliasRef": - name := contractName + utils.ToCamelCase(ty.AliasRefTy.AliasName) + name := contractName + utils.ToCamelCase(ty.AliasRef.AliasName) tlbType.WriteString(name) - err := writeGenericTypesPart(&tlbType, ty.AliasRefTy.TypeArgs, contractName) + err := writeGenericTypesPart(&tlbType, ty.AliasRef.TypeArgs, contractName) if err != nil { return "", "", err } - case "genericT": - name := ty.GenericTy.NameT + case "Generic": + name := ty.Generic.NameT tlbType.WriteString(utils.ToCamelCase(name)) - case "union": + case "Union": if len(ty.Union.Variants) == 2 && ty.Union.Variants[0].PrefixStr == "0" { tlbType.WriteString("tlb.Either[") @@ -555,9 +543,9 @@ func parseTy(ty tolkAbi.Ty, contractName string) (string, string, error) { } tlbType.WriteRune('}') } - case "nullLiteral": + case "NullLiteral": tlbType.WriteString("tlb.NullLiteral") - case "tupleAny", "callable": + case "TupleAny", "Callable": return "", "", fmt.Errorf("cannot convert type %v", ty.SumType) default: return "", "", fmt.Errorf("unknown ty type %q", ty.SumType) @@ -566,25 +554,28 @@ func parseTy(ty tolkAbi.Ty, contractName string) (string, string, error) { return tlbType.String(), tlbTag.String(), nil } -func getFixedSizeTypeForMap(ty tolkAbi.Ty) (string, error) { +func getFixedSizeTypeForMap(ty tolk.Ty) (string, error) { switch ty.SumType { - case "intN": - n := ty.NumberTy.N + case "IntN": + n := ty.IntN.N tlbIntType := fmt.Sprintf("tlb.Int%v", n) return tlbIntType, nil - case "uintN": - n := ty.NumberTy.N + case "UintN": + n := ty.UintN.N tlbIntType := fmt.Sprintf("tlb.Uint%v", n) return tlbIntType, nil - case "varintN", "varuintN": - tlbVarUIntType := fmt.Sprintf("tlb.VarUInteger%v", ty.NumberTy.N) + case "VarIntN": + tlbVarUIntType := fmt.Sprintf("tlb.VarUInteger%v", ty.VarIntN.N) return tlbVarUIntType, nil - case "bitsN": - tlbVarUIntType := fmt.Sprintf("tlb.Bits%v", ty.BitsTy.N) + case "VarUintN": + tlbVarUIntType := fmt.Sprintf("tlb.VarUInteger%v", ty.VarUintN.N) return tlbVarUIntType, nil - case "bool": + 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": + case "Address", "AddressOpt", "AddressExt", "AddressAny": return "tlb.InternalAddress", nil default: return "", fmt.Errorf("%v not supported as map key", ty.SumType) @@ -617,32 +608,14 @@ func wrapTlbTypeIntoTlbTag(tlbTypeArg, tlbTagArg string) string { return tlbType.String() } -func convertPrefixTagToInt(tag tolkAbi.Prefix) (*Tag, error) { +func convertPrefixTagToInt(tag tolk.Prefix) (*Tag, error) { if tag.PrefixLen == 0 { return nil, fmt.Errorf("prefix tag len must be > 0") } - var val uint64 - var err error - if len(tag.PrefixStr) == 1 { - val, err = strconv.ParseUint(tag.PrefixStr, 10, 64) - if err != nil { - return nil, err - } - } else { - if tag.PrefixStr[1] == 'b' { - val, err = strconv.ParseUint(tag.PrefixStr[2:], 2, 64) - if err != nil { - return nil, err - } - } else if tag.PrefixStr[1] == 'x' { - val, err = strconv.ParseUint(tag.PrefixStr[2:], 16, 64) - if err != nil { - return nil, err - } - } else { - return nil, fmt.Errorf("prefix tag must be either binary or hex format") - } + val, err := tolk.PrefixToUint(tag.PrefixStr) + if err != nil { + return nil, err } return &Tag{ @@ -662,7 +635,7 @@ func writeGenericStructPart(builder *strings.Builder, typeParams []string) { } } -func writeGenericTypesPart(builder *strings.Builder, typeArgs []tolkAbi.Ty, contractName string) error { +func writeGenericTypesPart(builder *strings.Builder, typeArgs []tolk.Ty, contractName string) error { if len(typeArgs) > 0 { builder.WriteRune('[') for _, typeArg := range typeArgs { diff --git a/tolk/refs.go b/tolk/refs.go new file mode 100644 index 00000000..82ba9d92 --- /dev/null +++ b/tolk/refs.go @@ -0,0 +1,304 @@ +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 + return nil +} + +func (e EnumRef) UnmarshalTolk(cell *boc.Cell, v TolkValue, decoder *Decoder) error { + if decoder.abiCtx == nil { + return fmt.Errorf("struct has enum reference, but no abi has been given") + } + enum, found := decoder.abiCtx.enumRefs[e.EnumName] + if !found { + return fmt.Errorf("no enum with name %s was found in given abi", e.EnumName) + } + + enumVal := Value{} + err := enum.EncodedAs.UnmarshalTolk(cell, &enumVal, decoder) + if err != nil { + return err + } + var bigEnumVal big.Int + switch enumVal.valType.SumType { + case "IntN": + if enumVal.valType.IntN.N > 64 { + bigEnumVal = big.Int(*enumVal.bigInt) + } else { + bigEnumVal = *big.NewInt(int64(*enumVal.smallInt)) + } + case "UintN": + if enumVal.valType.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", enumVal.valType.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 = v.SetValue(EnumValue{ + enumType: enum.EncodedAs, + Name: member.Name, + Value: *val, + }) + if err != nil { + return err + } + + return nil + } + } + // todo: maybe return err? + err = v.SetValue(EnumValue{ + enumType: enum.EncodedAs, + Name: "Unknown", + Value: bigEnumVal, + }) + 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 + return nil +} + +func (s StructRef) UnmarshalTolk(cell *boc.Cell, v TolkValue, decoder *Decoder) error { + if decoder.abiCtx == nil { + return fmt.Errorf("struct has struct reference, but no abi has been given") + } + strct, found := decoder.abiCtx.structRefs[s.StructName] + if !found { + return fmt.Errorf("no struct with name %s was found in given abi", s.StructName) + } + cont := 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) + } + cont.hasPrefix = true + cont.prefix = TolkPrefix{ + Len: int16(prefixLen), + Prefix: prefix, + } + } + + oldGenericMap := decoder.abiCtx.genericRefs + genericMap, err := resolveGeneric(s.TypeArgs, strct.TypeParams, decoder) + if err != nil { + return err + } + decoder.abiCtx.genericRefs = genericMap + + for _, field := range strct.Fields { + fieldVal := Value{} + err = field.Ty.UnmarshalTolk(cell, &fieldVal, decoder) + if err != nil { + return err + } + + if fieldVal.valType.SumType == "Nullable" { + optVal := *fieldVal.optionalValue + defVal := field.DefaultValue + if !optVal.IsExists && defVal != nil { + val := Value{} + // todo remove decoder methods + exists, err := defVal.UnmarshalDefaultValue(&val) + if err != nil { + return err + } + if exists { + optVal.IsExists = true + optVal.Val = val + } + } + } + + cont.field[field.Name] = fieldVal + } + decoder.abiCtx.genericRefs = oldGenericMap + + err = v.SetValue(cont) + 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 value") +} + +func (a AliasRef) UnmarshalTolk(cell *boc.Cell, v TolkValue, decoder *Decoder) error { + if decoder.abiCtx == nil { + return fmt.Errorf("struct has alias reference, but no abi has been given") + } + alias, found := decoder.abiCtx.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.abiCtx.genericRefs + genericMap, err := resolveGeneric(a.TypeArgs, alias.TypeParams, decoder) + if err != nil { + return err + } + decoder.abiCtx.genericRefs = genericMap + + val := Value{} + err = alias.TargetTy.UnmarshalTolk(cell, &val, decoder) + if err != nil { + return err + } + decoder.abiCtx.genericRefs = oldGenericMap + + innerVal, err := val.GetAny() + if err != nil { + return err + } + v.SetType(val.valType) + err = v.SetValue(innerVal) + if err != nil { + return err + } + + return nil +} + +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 value") +} + +func (g Generic) UnmarshalTolk(cell *boc.Cell, v TolkValue, decoder *Decoder) error { + currentTy, found := decoder.abiCtx.genericRefs[g.NameT] + if !found { + return fmt.Errorf("cannot resolve generic type %v ", g) + } + val := Value{} + err := currentTy.UnmarshalTolk(cell, &val, decoder) + if err != nil { + return err + } + + innerVal, err := val.GetAny() + if err != nil { + return err + } + v.SetType(val.valType) + err = v.SetValue(innerVal) + if err != nil { + return err + } + + return nil +} + +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.abiCtx.genericRefs != nil { + maps.Copy(genericMap, d.abiCtx.genericRefs) + } + + for i, genericTy := range typeArgs { + genericMap[typeParams[i]] = genericTy + + if genericTy.SumType == "Generic" { + if d.abiCtx.genericRefs == nil { + return nil, fmt.Errorf("cannot resolve generic type %v", genericTy.Generic.NameT) + } + + ty, found := d.abiCtx.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..033c4a4f --- /dev/null +++ b/tolk/runtime.go @@ -0,0 +1,62 @@ +package tolk + +import ( + "github.com/tonkeeper/tongo/boc" +) + +type TolkUnmarshaler interface { + UnmarshalTolk(cell *boc.Cell, v *Value, d *Decoder) error +} + +type abiContext struct { + structRefs map[string]StructDeclaration + aliasRefs map[string]AliasDeclaration + enumRefs map[string]EnumDeclaration + genericRefs map[string]Ty +} + +type Decoder struct { + abiCtx *abiContext +} + +func NewDecoder() *Decoder { + return &Decoder{ + abiCtx: &abiContext{ + genericRefs: make(map[string]Ty), + }, + } +} + +func (d *Decoder) WithABI(abi ABI) *Decoder { + d.abiCtx = &abiContext{ + structRefs: make(map[string]StructDeclaration), + aliasRefs: make(map[string]AliasDeclaration), + enumRefs: make(map[string]EnumDeclaration), + } + for _, declr := range abi.Declarations { + switch declr.SumType { + case "Struct": + d.abiCtx.structRefs[declr.StructDeclaration.Name] = declr.StructDeclaration + case "Alias": + d.abiCtx.aliasRefs[declr.AliasDeclaration.Name] = declr.AliasDeclaration + case "Enum": + d.abiCtx.enumRefs[declr.EnumDeclaration.Name] = declr.EnumDeclaration + } + } + return d +} + +func UnmarshalTolk(cell *boc.Cell, ty Ty) (*Value, error) { + d := NewDecoder() + return d.UnmarshalTolk(cell, ty) +} + +// todo: maybe use only abi (guess best struct to unmarshal) +func (d *Decoder) UnmarshalTolk(cell *boc.Cell, ty Ty) (*Value, error) { + res := &Value{} + err := ty.UnmarshalTolk(cell, res, d) + if err != nil { + return nil, err + } + return res, nil +} diff --git a/tolk/runtime_test.go b/tolk/runtime_test.go new file mode 100644 index 00000000..2f3bf445 --- /dev/null +++ b/tolk/runtime_test.go @@ -0,0 +1,2556 @@ +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 TestRuntimeUnmarshal(t *testing.T) { + type cases struct { + name string + filename string + cell string + t Ty + check func(Value) + } + for _, c := range []cases{ + { + name: "unmarshal small int", + filename: "simple", + cell: "b5ee9c72410101010005000006ff76c41616db06", + t: Ty{ + SumType: "IntN", + IntN: &IntN{ + N: 24, + }, + }, + check: func(v Value) { + val, ok := v.GetSmallInt() + if !ok { + t.Errorf("v.GetSmallInt() not successeded") + } + if val != -35132 { + t.Errorf("val != -35132, got %v", val) + } + }, + }, + { + name: "unmarshal big int", + filename: "simple", + cell: "b5ee9c7241010101001900002dfffffffffffffffffffffffffffffffffff99bfeac6423a6f0b50c", + t: Ty{ + SumType: "IntN", + IntN: &IntN{ + N: 183, + }, + }, + check: func(v Value) { + 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) + } + }, + }, + { + name: "unmarshal small uint", + filename: "simple", + cell: "b5ee9c7241010101000900000d00000000001d34e435eafd", + t: Ty{ + SumType: "UintN", + UintN: &UintN{ + N: 53, + }, + }, + check: func(v Value) { + val, ok := v.GetSmallUInt() + if !ok { + t.Errorf("v.GetSmallUInt() not successeded") + } + if val != 934 { + t.Errorf("val != 934, got %v", val) + } + }, + }, + { + name: "unmarshal big uint", + filename: "simple", + cell: "b5ee9c7241010101002300004100000000000000000000000000000000000000000000000000009fc4212a38ba40b11cce12", + t: Ty{ + SumType: "UintN", + UintN: &UintN{ + N: 257, + }, + }, + check: func(v Value) { + val, ok := v.GetBigInt() + if !ok { + t.Errorf("v.GetBigInt() not successeded") + } + if val.Cmp(big.NewInt(351329437643124)) != 0 { + t.Errorf("val != 351329437643124, got %v", val) + } + }, + }, + { + name: "unmarshal varint", + filename: "simple", + cell: "b5ee9c7241010101000600000730c98588449b6923", + t: Ty{ + SumType: "VarIntN", + VarIntN: &VarIntN{ + N: 16, + }, + }, + check: func(v Value) { + val, ok := v.GetBigInt() + if !ok { + t.Errorf("v.GetBigInt() not successeded") + } + if val.Cmp(big.NewInt(825432)) != 0 { + t.Errorf("val != 825432, got %v", val) + } + }, + }, + { + name: "unmarshal varuint", + filename: "simple", + cell: "b5ee9c7241010101000800000b28119ab36b44d3a86c0f", + t: Ty{ + SumType: "VarUintN", + VarUintN: &VarUintN{ + N: 32, + }, + }, + check: func(v Value) { + val, ok := v.GetBigInt() + if !ok { + t.Errorf("v.GetBigInt() not successeded") + } + if val.Cmp(big.NewInt(9451236712)) != 0 { + t.Errorf("val != 9451236712, got %v", val) + } + }, + }, + { + name: "unmarshal bits", + filename: "simple", + cell: "b5ee9c7241010101000500000631323318854035", + t: Ty{ + SumType: "BitsN", + BitsN: &BitsN{ + N: 24, + }, + }, + check: func(v Value) { + 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) + } + }, + }, + { + name: "unmarshal coins", + filename: "simple", + cell: "b5ee9c72410101010007000009436ec6e0189ebbd7f4", + t: Ty{ + SumType: "Coins", + Coins: &Coins{}, + }, + check: func(v Value) { + val, ok := v.GetBigInt() + if !ok { + t.Errorf("v.GetBigInt() not successeded") + } + if val.Cmp(big.NewInt(921464321)) != 0 { + t.Errorf("val != 921464321, got %v", val) + } + }, + }, + { + name: "unmarshal bool", + filename: "simple", + cell: "b5ee9c7241010101000300000140f6d24034", + t: Ty{ + SumType: "Bool", + Bool: &Bool{}, + }, + check: func(v Value) { + val, ok := v.GetBool() + if !ok { + t.Errorf("v.GetBool() not successeded") + } + if val { + t.Error("val is true") + } + }, + }, + { + name: "unmarshal cell", + filename: "simple", + cell: "b5ee9c724101020100090001000100080000007ba52a3292", + t: Ty{ + SumType: "Cell", + Cell: &Cell{}, + }, + check: func(v Value) { + 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) + } + }, + }, + { + name: "unmarshal remaining", + filename: "simple", + cell: "b5ee9c7241010101000900000dc0800000000ab8d04726e4", + t: Ty{ + SumType: "Remaining", + Remaining: &Remaining{}, + }, + check: func(v Value) { + val, ok := v.GetCell() + 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) + } + }, + }, + { + name: "unmarshal address", + filename: "simple", + cell: "b5ee9c7241010101002400004380107bfaaa5cc6e5368e5f9799188bd798cd22e04ab16d1d8ea4fc37480741e6351064a3e1a6", + t: Ty{ + SumType: "Address", + Address: &Address{}, + }, + check: func(v Value) { + 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()) + } + }, + }, + { + name: "unmarshal not exists optional address", + filename: "simple", + cell: "b5ee9c724101010100030000012094418655", + t: Ty{ + SumType: "AddressOpt", + AddressOpt: &AddressOpt{}, + }, + check: func(v Value) { + val, ok := v.GetOptionalAddress() + if !ok { + t.Errorf("v.GetOptionalAddress() not successeded") + } + + if val.SumType != "NoneAddress" { + t.Errorf("val.GetAddress() != none address") + } + }, + }, + { + name: "unmarshal exists optional address", + filename: "simple", + cell: "b5ee9c7241010101002400004380107bfaaa5cc6e5368e5f9799188bd798cd22e04ab16d1d8ea4fc37480741e6351064a3e1a6", + t: Ty{ + SumType: "AddressOpt", + AddressOpt: &AddressOpt{}, + }, + check: func(v Value) { + 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()) + } + }, + }, + { + name: "unmarshal external address", + filename: "simple", + cell: "b5ee9c7241010101000600000742082850fcbd94fd", + t: Ty{ + SumType: "AddressExt", + AddressExt: &AddressExt{}, + }, + check: func(v Value) { + 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()) + } + }, + }, + { + name: "unmarshal none any address", + filename: "simple", + cell: "b5ee9c724101010100030000012094418655", + t: Ty{ + SumType: "AddressAny", + AddressAny: &AddressAny{}, + }, + check: func(v Value) { + val, ok := v.GetAnyAddress() + if !ok { + t.Errorf("v.GetAnyAddress() not successeded") + } + if val.SumType != "NoneAddress" { + t.Errorf("val.GetAddress() != none address") + } + }, + }, + { + name: "unmarshal internal any address", + filename: "simple", + cell: "b5ee9c7241010101002400004380107bfaaa5cc6e5368e5f9799188bd798cd22e04ab16d1d8ea4fc37480741e6351064a3e1a6", + t: Ty{ + SumType: "AddressAny", + AddressAny: &AddressAny{}, + }, + check: func(v Value) { + 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()) + } + }, + }, + { + name: "unmarshal external any address", + filename: "simple", + cell: "b5ee9c7241010101000600000742082850fcbd94fd", + t: Ty{ + SumType: "AddressAny", + AddressAny: &AddressAny{}, + }, + check: func(v Value) { + 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()) + } + }, + }, + { + name: "unmarshal var any address", + filename: "simple", + cell: "b5ee9c7241010101000900000dc0800000000ab8d04726e4", + t: Ty{ + SumType: "AddressAny", + AddressAny: &AddressAny{}, + }, + check: func(v Value) { + 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()) + } + }, + }, + { + name: "unmarshal not exists nullable", + filename: "simple", + cell: "b5ee9c7241010101000300000140f6d24034", + t: Ty{ + SumType: "Nullable", + Nullable: &Nullable{ + Inner: Ty{ + SumType: "Remaining", + Remaining: &Remaining{}, + }, + }, + }, + check: func(v Value) { + val, ok := v.GetOptionalValue() + if !ok { + t.Errorf("v.GetOptionalValue() not successeded") + } + if val.IsExists { + t.Errorf("v.GetOptionalValue() is exists") + } + }, + }, + { + name: "unmarshal exists nullable", + filename: "simple", + cell: "b5ee9c7241010201000b000101c001000900000c0ae007880db9", + t: Ty{ + SumType: "Nullable", + Nullable: &Nullable{ + Inner: Ty{ + SumType: "Cell", + Cell: &Cell{}, + }, + }, + }, + check: func(v Value) { + 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) + } + }, + }, + { + name: "unmarshal ref", + filename: "simple", + cell: "b5ee9c7241010201000e000100010011000000000009689e40e150b4c5", + t: Ty{ + SumType: "CellOf", + CellOf: &CellOf{ + Inner: Ty{ + SumType: "IntN", + IntN: &IntN{ + N: 65, + }, + }, + }, + }, + check: func(v Value) { + 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()) + } + }, + }, + { + name: "unmarshal empty tensor", + filename: "simple", + cell: "b5ee9c724101010100020000004cacb9cd", + t: Ty{ + SumType: "Tensor", + Tensor: &Tensor{}, + }, + check: func(v Value) { + val, ok := v.GetTensor() + if !ok { + t.Errorf("v.GetTensor() not successeded") + } + + if len(val) != 0 { + t.Errorf("v.GetTensor() != empty") + } + }, + }, + { + name: "unmarshal tensor", + filename: "simple", + cell: "b5ee9c7241010101001f00003900000000000000000000000000021cb43b9aca00fffd550bfbaae07401a2a98117", + t: 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, + }, + }, + }, + }, + }, + check: func(v Value) { + val, ok := v.GetTensor() + if !ok { + t.Errorf("v.GetTensor() not successeded") + } + + val0, ok := val[0].GetBigInt() + if !ok { + t.Errorf("val[0].GetBigInt() not successeded") + } + if val0.Cmp(big.NewInt(4325)) != 0 { + t.Errorf("val[0].GetBigInt() != 4325, got %v", val0.String()) + } + + val1, ok := val[1].GetBool() + if !ok { + t.Errorf("val[1].GetBigInt() not successeded") + } + if !val1 { + t.Error("val[1].GetBool() is false") + } + + val2, ok := val[2].GetBigInt() + if !ok { + t.Errorf("val[2].GetBigInt() not successeded") + } + if val2.Cmp(big.NewInt(1_000_000_000)) != 0 { + t.Errorf("val[2].GetBigInt() != 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].GetBigInt() + if !ok { + t.Errorf("val[4].GetBigInt() not successeded") + } + if val4.Cmp(big.NewInt(-9_304_000_000)) != 0 { + t.Errorf("val[4].GetBigInt() != -9304000000, got %v", val4.String()) + } + }, + }, + //{ + // name: "unmarshal empty tuple", + // filename: "simple", + // t: Ty{ + // SumType: "TupleWith", + // TupleWith: &TupleWith{}, + // }, + // check: func(v Value) { + // val, ok := v.GetTupleValues() + // if !ok { + // t.Errorf("v.GetTupleValues() not successeded") + // } + // + // if len(val) != 0 { + // t.Errorf("v.GetTupleValues() != empty") + // } + // }, + //}, + //{ + // name: "unmarshal tuple", + // filename: "simple", + // t: Ty{ + // SumType: "TupleWith", + // TupleWith: &TupleWith{ + // Items: []Ty{ + // { + // SumType: "Nullable", + // Nullable: &Nullable{ + // Inner: Ty{ + // SumType: "CellOf", + // CellOf: &CellOf{ + // Inner: Ty{ + // SumType: "IntN", + // IntN: &IntN{ + // N: 1, + // }, + // }, + // }, + // }, + // }, + // }, + // { + // SumType: "TupleWith", + // TupleWith: &TupleWith{ + // Items: []Ty{ + // { + // SumType: "UintN", + // UintN: &UintN{ + // N: 1, + // }, + // }, + // { + // SumType: "Tensor", + // Tensor: &Tensor{ + // Items: []Ty{ + // { + // SumType: "CellOf", + // CellOf: &CellOf{ + // Inner: Ty{ + // SumType: "Cell", + // Cell: &Cell{}, + // }, + // }, + // }, + // }, + // }, + // }, + // }, + // }, + // }, + // }, + // }, + // }, + // check: func(v Value) { + // val, ok := v.GetTupleValues() + // if !ok { + // t.Errorf("v.GetTupleValues() not successeded") + // } + // + // val0, ok := val[0].GetOptionalValue() + // if !ok { + // t.Errorf("val[0].GetOptionalValue() not successeded") + // } + // if !val0.IsExists { + // t.Errorf("val[0].GetOptionalValue() != exists") + // } + // val0Ref, ok := val0.Val.GetRefValue() + // if !ok { + // t.Errorf("val[0].GetOptionalValue().GetRefValue() not successeded") + // } + // val0RefVal, ok := val0Ref.GetSmallInt() + // if !ok { + // t.Errorf("val[0].GetOptionalValue().GetRefValue().GetSmallInt() not successeded") + // } + // if val0RefVal != -1 { + // t.Errorf("val[0].GetOptionalValue().GetRefValue().GetSmallInt() != -1, got %v", val0RefVal) + // } + // + // val1, ok := val[1].GetTupleValues() + // if !ok { + // t.Errorf("val[1].GetTupleValues() not successeded") + // } + // + // val10, ok := val1[0].GetSmallUInt() + // if !ok { + // t.Errorf("val[1][0].GetSmallUInt() not successeded") + // } + // if val10 != 1 { + // t.Errorf("val[1][0].GetSmallUInt() != 1, got %v", val0RefVal) + // } + // + // val11, ok := val1[1].GetTensor() + // if !ok { + // t.Errorf("val[1][1].GetTensor() not successeded") + // } + // + // val110Ref, ok := val11[0].GetRefValue() + // if !ok { + // t.Errorf("val[1][1][0].GetRefValue() not successeded") + // } + // val110, ok := val110Ref.GetCell() + // if !ok { + // t.Errorf("val[1][1][0].GetRefValue().GetCell() not successeded") + // } + // hs, err := val110.HashString() + // if err != nil { + // t.Fatal(err) + // } + // if hs != "123" { + // t.Errorf("val[1][1][0].GetHash() != 123, got %v", hs) + // } + // }, + //}, + { + name: "unmarshal int-key map", + filename: "simple", + cell: "b5ee9c7241010201000c000101c001000ba00000007bc09a662c32", + t: Ty{ + SumType: "Map", + Map: &Map{ + K: Ty{ + SumType: "IntN", + IntN: &IntN{ + N: 32, + }, + }, + V: Ty{ + SumType: "Bool", + Bool: &Bool{}, + }, + }, + }, + check: func(v Value) { + 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") + } + }, + }, + { + name: "unmarshal uint-key map", + filename: "simple", + cell: "b5ee9c72410104010053000101c0010202cb02030045a7400b113a994b5024a16719f69139328eb759596c38a25f59028b146fecdc3621dfe80045a3cff5555555555555555555555555555555555555555555555555555555555555555888440ce8", + t: Ty{ + SumType: "Map", + Map: &Map{ + K: Ty{ + SumType: "UintN", + UintN: &UintN{ + N: 16, + }, + }, + V: Ty{ + SumType: "Address", + Address: &Address{}, + }, + }, + }, + check: func(v Value) { + 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") + } + }, + }, + { + name: "unmarshal bigint-key map", + filename: "simple", + cell: "b5ee9c7241010301001a000101c0010115a70000000000000047550902000b000000001ab01d5bf1a9", + t: Ty{ + SumType: "Map", + Map: &Map{ + K: Ty{ + SumType: "UintN", + UintN: &UintN{ + N: 78, + }, + }, + V: Ty{ + SumType: "Cell", + Cell: &Cell{}, + }, + }, + }, + check: func(v Value) { + val, ok := v.GetMap() + if !ok { + t.Errorf("v.GetMap() not successeded") + } + val1, ok := val.GetByBigInt(BigInt(*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") + } + }, + }, + { + name: "unmarshal bits-key map", + filename: "simple", + cell: "b5ee9c7241010301003b000101c0010106a0828502005ea0000000000000003e400b113a994b5024a16719f69139328eb759596c38a25f59028b146fecdc3621dfe43b9aca00b89cdc86", + t: 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{}, + }, + }, + }, + }, + }, + }, + }, + }, + check: func(v Value) { + 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].GetBigInt() + if !ok { + t.Errorf("val[{97, 98}][124][1].GetBigInt() not successeded") + } + if val1_124Val1.Cmp(big.NewInt(1_000_000_000)) != 0 { + t.Errorf("val[{97, 98}][124][1].GetBigInt() != 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") + } + }, + }, + { + name: "unmarshal address-key map", + filename: "simple", + cell: "b5ee9c7241010201002f000101c0010051a17002c44ea652d4092859c67da44e4ca3add6565b0e2897d640a2c51bfb370d8877f9409502f9002016fdc16e", + t: Ty{ + SumType: "Map", + Map: &Map{ + K: Ty{ + SumType: "Address", + Address: &Address{}, + }, + V: Ty{ + SumType: "Coins", + Coins: &Coins{}, + }, + }, + }, + check: func(v Value) { + 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.GetBigInt() + 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") + } + }, + }, + { + name: "unmarshal union with dec prefix", + filename: "simple", + cell: "b5ee9c7241010101001300002180000000000000000000000003b5577dc0660d6029", + t: 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, + }, + }, + }, + }, + }, + }, + check: func(v Value) { + 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()) + } + }, + }, + { + name: "unmarshal union with bin prefix", + filename: "bin_union", + cell: "b5ee9c7241010201002e0001017801004fa17002c44ea652d4092859c67da44e4ca3add6565b0e2897d640a2c51bfb370d8877f900a4d89920c413c650", + t: 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", + }, + }, + }, + }, + }, + }, + check: func(v Value) { + 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.GetBigInt() + if !ok { + t.Errorf("val.GetMap()[\"EQCxE6mUtQJKFnGfaROTKOt1lZbDiiX1kCixRv7Nw2Id_sDs\"].GetBigInt() not successeded") + } + if mapCoins.Cmp(big.NewInt(43213412)) != 0 { + t.Errorf("val.GetMap()[\"EQCxE6mUtQJKFnGfaROTKOt1lZbDiiX1kCixRv7Nw2Id_sDs\"] != 43213412, got %v", mapCoins.String()) + } + }, + }, + { + name: "unmarshal union with hex prefix", + filename: "hex_union", + cell: "b5ee9c7241010101000b000011deadbeef00000000c0d75977b9", + t: 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", + }, + }, + }, + }, + }, + }, + check: func(v Value) { + 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) + } + }, + }, + { + name: "unmarshal a lot refs from alias", + filename: "refs", + cell: "b5ee9c724101040100b7000377deadbeef80107bfaaa5cc6e5368e5f9799188bd798cd22e04ab16d1d8ea4fc37480741e635087735940143ffffffffffffffffffffffffffff63c006010203004b80010df454cebee868f611ba8c0d4a9371fb73105396505783293a7625f75db3b9880bebc20100438006e05909e22b2e5e6087533314ee56505f85212914bd5547941a2a658ac62fe101004f801622753296a04942ce33ed2272651d6eb2b2d87144beb2051628dfd9b86c43bfcc12309ce54001e09a48b8", + t: Ty{ + SumType: "AliasRef", + AliasRef: &AliasRef{ + AliasName: "GoodNamingForMsg", + }, + }, + check: func(v Value) { + currStruct, ok := v.GetStruct() + if !ok { + t.Fatalf("struct not found") + } + pref, ok := currStruct.GetStructPrefix() + 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") + } + user1Val, ok := user1.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.GetBigInt() + if !ok { + t.Fatalf("currStruct[user1][balance].GetBigInt() not successeded") + } + if user1BalanceVal.Cmp(big.NewInt(1_000_000_000)) != 0 { + t.Errorf("currStruct[user1][balance].ToRaw() != 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") + } + user2Val, ok := user2Ref.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.GetBigInt() + if !ok { + t.Fatalf("currStruct[user2][balance].GetBigInt() not successeded") + } + if user2BalanceVal.Cmp(big.NewInt(100_000_000)) != 0 { + t.Errorf("currStruct[user2][balance].ToRaw() != 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.GetBigInt() + if !ok { + t.Fatalf("currStruct[user5][balance].GetBigInt() not successeded") + } + if user5BalanceVal.Cmp(big.NewInt(10_000_000_000_000)) != 0 { + t.Errorf("currStruct[user5][balance].ToRaw() != 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) + } + }, + }, + { + name: "unmarshal a lot refs from struct", + filename: "refs", + cell: "b5ee9c724101040100b7000377deadbeef80107bfaaa5cc6e5368e5f9799188bd798cd22e04ab16d1d8ea4fc37480741e635087735940143ffffffffffffffffffffffffffff63c006010203004b80010df454cebee868f611ba8c0d4a9371fb73105396505783293a7625f75db3b9880bebc20100438006e05909e22b2e5e6087533314ee56505f85212914bd5547941a2a658ac62fe101004f801622753296a04942ce33ed2272651d6eb2b2d87144beb2051628dfd9b86c43bfcc12309ce54001e09a48b8", + t: Ty{ + SumType: "StructRef", + StructRef: &StructRef{ + StructName: "ManyRefsMsg", + }, + }, + check: func(v Value) { + currStruct, ok := v.GetStruct() + if !ok { + t.Fatalf("struct not found") + } + pref, ok := currStruct.GetStructPrefix() + 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") + } + user1Val, ok := user1.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.GetBigInt() + if !ok { + t.Fatalf("currStruct[user1][balance].GetBigInt() not successeded") + } + if user1BalanceVal.Cmp(big.NewInt(1_000_000_000)) != 0 { + t.Errorf("currStruct[user1][balance].ToRaw() != 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") + } + user2Val, ok := user2Ref.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.GetBigInt() + if !ok { + t.Fatalf("currStruct[user2][balance].GetBigInt() not successeded") + } + if user2BalanceVal.Cmp(big.NewInt(100_000_000)) != 0 { + t.Errorf("currStruct[user2][balance].ToRaw() != 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.GetBigInt() + if !ok { + t.Fatalf("currStruct[user5][balance].GetBigInt() not successeded") + } + if user5BalanceVal.Cmp(big.NewInt(10_000_000_000_000)) != 0 { + t.Errorf("currStruct[user5][balance].ToRaw() != 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) + } + }, + }, + { + name: "unmarshal a lot generics with struct", + filename: "generics", + cell: "b5ee9c72410103010043000217d017d7840343b9aca0000108010200080000007b005543b9aca001017d78402005889d4ca5a81250b38cfb489c99475bacacb61c512fac81458a37f66e1b10eff422fc7647", + t: Ty{ + SumType: "StructRef", + StructRef: &StructRef{ + StructName: "ManyRefsMsg", + TypeArgs: []Ty{ + { + SumType: "UintN", + UintN: &UintN{ + N: 16, + }, + }, + }, + }, + }, + check: func(v Value) { + 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") + } + payloadVal, ok := payload.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") + } + eitherUnion, ok := either.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") + } + eitherVal, ok := eitherV.GetBigInt() + if !ok { + t.Fatalf("currStruct[either][value].GetBigInt() not successeded") + } + if eitherVal.Cmp(big.NewInt(100000000)) != 0 { + t.Fatalf("currStruct[either][value].GetBigInt() != 1000000000, got %v", eitherVal.String()) + } + + anotherEither, ok := currStruct.GetField("anotherEither") + if !ok { + t.Fatalf("currStruct[anotherEither] not found") + } + anotherEitherUnion, ok := anotherEither.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") + } + anotherEitherVal, ok := anotherEitherV.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].GetBigInt() + if !ok { + t.Fatalf("currStruct[anotherEither][value][0].GetBigInt() not successeded") + } + if anotherEitherValCoins.Cmp(big.NewInt(1_000_000_000)) != 0 { + t.Fatalf("currStruct[anotherEither][value][0].GetBigInt() != 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") + } + doublerTensor, ok := doublerRef.GetTensor() + if !ok { + t.Fatalf("currStruct[doubler].GetTensor() not successeded") + } + + doublerTensor0, ok := doublerTensor[0].GetTensor() + if !ok { + t.Fatalf("currStruct[doubler][0] not successeded") + } + doublerTensor0Coins, ok := doublerTensor0[0].GetBigInt() + if !ok { + t.Fatalf("currStruct[doubler][0][0].GetBigInt() 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") + } + + doublerTensor1, ok := doublerTensor[1].GetTensor() + if !ok { + t.Fatalf("currStruct[doubler][1] not successeded") + } + doublerTensor1Coins, ok := doublerTensor1[0].GetBigInt() + if !ok { + t.Fatalf("currStruct[doubler][1][0].GetBigInt() not successeded") + } + if doublerTensor1Coins.Cmp(big.NewInt(100_000_000)) != 0 { + t.Fatalf("currStruct[doubler][1][0].GetBigInt() != 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") + } + myValVal, ok := myVal.GetSmallUInt() + if !ok { + t.Fatalf("currStruct[myVal].GetSmallUInt() not successed") + } + if myValVal != 16 { + t.Fatalf("currStruct[myVal] != 16, got %v", myValVal) + } + }, + }, + { + name: "unmarshal a lot generics with alias", + filename: "generics", + cell: "b5ee9c72410103010043000217d017d7840343b9aca0000108010200080000007b005543b9aca001017d78402005889d4ca5a81250b38cfb489c99475bacacb61c512fac81458a37f66e1b10eff422fc7647", + t: Ty{ + SumType: "AliasRef", + AliasRef: &AliasRef{ + AliasName: "GoodNamingForMsg", + TypeArgs: []Ty{ + { + SumType: "UintN", + UintN: &UintN{ + N: 16, + }, + }, + }, + }, + }, + check: func(v Value) { + 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") + } + payloadVal, ok := payload.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") + } + eitherUnion, ok := either.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") + } + eitherVal, ok := eitherV.GetBigInt() + if !ok { + t.Fatalf("currStruct[either][value].GetBigInt() not successeded") + } + if eitherVal.Cmp(big.NewInt(100000000)) != 0 { + t.Fatalf("currStruct[either][value].GetBigInt() != 1000000000, got %v", eitherVal.String()) + } + + anotherEither, ok := currStruct.GetField("anotherEither") + if !ok { + t.Fatalf("currStruct[anotherEither] not found") + } + anotherEitherUnion, ok := anotherEither.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") + } + anotherEitherVal, ok := anotherEitherV.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].GetBigInt() + if !ok { + t.Fatalf("currStruct[anotherEither][value][0].GetBigInt() not successeded") + } + if anotherEitherValCoins.Cmp(big.NewInt(1_000_000_000)) != 0 { + t.Fatalf("currStruct[anotherEither][value][0].GetBigInt() != 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") + } + doublerTensor, ok := doublerRef.GetTensor() + if !ok { + t.Fatalf("currStruct[doubler].GetTensor() not successeded") + } + + doublerTensor0, ok := doublerTensor[0].GetTensor() + if !ok { + t.Fatalf("currStruct[doubler][0] not successeded") + } + doublerTensor0Coins, ok := doublerTensor0[0].GetBigInt() + if !ok { + t.Fatalf("currStruct[doubler][0][0].GetBigInt() 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") + } + + doublerTensor1, ok := doublerTensor[1].GetTensor() + if !ok { + t.Fatalf("currStruct[doubler][1] not successeded") + } + doublerTensor1Coins, ok := doublerTensor1[0].GetBigInt() + if !ok { + t.Fatalf("currStruct[doubler][1][0].GetBigInt() not successeded") + } + if doublerTensor1Coins.Cmp(big.NewInt(100_000_000)) != 0 { + t.Fatalf("currStruct[doubler][1][0].GetBigInt() != 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") + } + myValVal, ok := myVal.GetSmallUInt() + if !ok { + t.Fatalf("currStruct[myVal].GetSmallUInt() not successed") + } + if myValVal != 16 { + t.Fatalf("currStruct[myVal] != 16, got %v", myValVal) + } + }, + }, + { + name: "unmarshal a struct with default values", + filename: "default_values", + cell: "b5ee9c7241010101003100005d80000002414801622753296a04942ce33ed2272651d6eb2b2d87144beb2051628dfd9b86c43bfd00000156ac2c4c70811a9dde", + t: Ty{ + SumType: "StructRef", + StructRef: &StructRef{ + StructName: "DefaultTest", + }, + }, + check: func(v Value) { + 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") + } + num2Val, ok := num2.Val.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.GetCell() + if !ok { + t.Fatalf("currStruct[slice3].GetCell() not successeded") + } + hs, err := slice3Val.HashString() + if err != nil { + t.Fatal(err) + } + if hs != "55e960f1409af0d7670e382c61276a559fa9330185984d91faffebf32d5fa383" { + t.Fatalf("currStruct[slice3].GetCell().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") + } + }, + }, + { + name: "unmarshal numbers", + filename: "numbers", + cell: "b5ee9c72410101010033000062000000000000000000000000000000000000000000000000000000000000000000000000000000f1106aecc4c800020926dc62f014", + t: Ty{ + SumType: "StructRef", + StructRef: &StructRef{ + StructName: "Numbers", + }, + }, + check: func(v Value) { + 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.GetBigInt() + if !ok { + t.Fatalf("num3.GetBigInt() 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.GetBigInt() + if !ok { + t.Fatalf("num4.GetSmallUInt() 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.GetBigInt() + if !ok { + t.Fatalf("num9.GetSmallInt() not successeded") + } + if val9.Cmp(big.NewInt(2342)) != 0 { + t.Fatalf("num9 != 2342, got %s", val9.String()) + } + }, + }, + { + name: "unmarshal random fields", + filename: "random_fields", + cell: "b5ee9c7241010301007800028b79480107bfaaa5cc6e5368e5f9799188bd798cd22e04ab16d1d8ea4fc37480741e6350e038d7eb37c5e80000000ab50ee6b28000000000000016e4c000006c175300001801bc01020001c00051000000000005120041efeaa9731b94da397e5e64622f5e63348b812ac5b4763a93f0dd201d0798d4409e337ceb", + t: Ty{ + SumType: "StructRef", + StructRef: &StructRef{ + StructName: "RandomFields", + }, + }, + check: func(v Value) { + addr := ton.MustParseAccountID("UQCD39VS5jcptHL8vMjEXrzGaRcCVYto7HUn4bpAOg8xqEBI") + + currStruct, ok := v.GetStruct() + if !ok { + t.Fatalf("struct not found") + } + pref, ok := currStruct.GetStructPrefix() + 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.GetBigInt() + if !ok { + t.Fatalf("amount.GetBigInt() 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.GetBigInt() + if !ok { + t.Fatalf("intVector[1].GetOptionalValue().GetBigInt() not successeded") + } + if val2.Cmp(big.NewInt(1000000000)) != 0 { + t.Fatalf("intVector[1].GetOptionalValue().GetBigInt() != 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") + } + myIntVal, ok := myInt.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) + } + }, + }, + } { + t.Run(c.name, func(t *testing.T) { + inputFilename := fmt.Sprintf("testdata/%s.json", c.filename) + 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) + } + + currCell, err := boc.DeserializeBocHex(c.cell) + if err != nil { + t.Fatal(err) + } + decoder := NewDecoder() + decoder.WithABI(abi) + val, err := decoder.UnmarshalTolk(currCell[0], c.t) + if err != nil { + t.Fatal(err) + } + c.check(*val) + }) + } +} diff --git a/tolk/runtime_types.go b/tolk/runtime_types.go new file mode 100644 index 00000000..23780f76 --- /dev/null +++ b/tolk/runtime_types.go @@ -0,0 +1,845 @@ +package tolk + +// todo: move this to some package or rename somehow. + +import ( + "bytes" + "fmt" + "math/big" + + "github.com/tonkeeper/tongo/boc" +) + +type TolkValue interface { + GetType() Ty + SetType(Ty) + SetValue(any) error +} + +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 +} + +func (s *Struct) AddField(field string, v Value) bool { + if _, found := s.field[field]; found { + return false + } + + s.field[field] = v + return true +} + +// SetField set new value only if types are the same +func (s *Struct) SetField(field string, v Value) bool { + old, found := s.field[field] + if !found { + return false + } + if old.valType != v.valType { + return false + } + s.field[field] = v + return true +} + +// UpdateField set new value even if types mismatched +func (s *Struct) UpdateField(field string, v Value) bool { + _, found := s.field[field] + if !found { + return false + } + s.field[field] = v + return true +} + +func (s *Struct) RemoveField(field string) { + delete(s.field, field) +} + +func (s *Struct) GetStructPrefix() (TolkPrefix, bool) { + if !s.hasPrefix { + return TolkPrefix{}, false + } + + return s.prefix, true +} + +type Value struct { + valType Ty + bool *BoolValue + smallInt *Int64 + smallUint *UInt64 + bigInt *BigInt + bits *Bits + cell *Any + internalAddress *InternalAddress + optionalAddress *OptionalAddress + externalAddress *ExternalAddress + anyAddress *AnyAddress + optionalValue *OptValue + refValue *RefValue + tupleWith *TupleValues + tensor *TensorValues + mp *MapValue + structValue *Struct + alias *AliasValue + generic *GenericValue + enum *EnumValue + union *UnionValue +} + +func (v *Value) GetType() Ty { + return v.valType +} + +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) GetSmallUInt() (uint64, bool) { + if v.smallUint == nil { + return 0, false + } + return uint64(*v.smallUint), 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) 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) GetGeneric() (GenericValue, bool) { + if v.generic == nil { + return GenericValue{}, false + } + return *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 +} + +// todo: is good idea to use this method +func (v *Value) GetAny() (any, error) { + switch v.valType.SumType { + case "Int": + return v, fmt.Errorf("int is not supported") + case "NullLiteral": + return nil, nil + case "Void": + return nil, nil + case "IntN": + if i64, ok := v.GetSmallInt(); ok { + return Int64(i64), nil + } + if bi, ok := v.GetBigInt(); ok { + return BigInt(bi), nil + } + return nil, fmt.Errorf("value is not a BigInt or Int64") + case "UintN": + if ui64, ok := v.GetSmallUInt(); ok { + return UInt64(ui64), nil + } + if bi, ok := v.GetBigInt(); ok { + return BigInt(bi), nil + } + return nil, fmt.Errorf("value is not a BigInt or UInt64") + case "VarIntN": + if bi, ok := v.GetBigInt(); ok { + return BigInt(bi), nil + } + return nil, fmt.Errorf("value is not a BigInt") + case "VarUintN": + if bi, ok := v.GetBigInt(); ok { + return BigInt(bi), nil + } + return nil, fmt.Errorf("value is not a BigInt") + case "BitsN": + if bits, ok := v.GetBits(); ok { + return Bits(bits), nil + } + return nil, fmt.Errorf("value is not a Bits") + case "Coins": + if bi, ok := v.GetBigInt(); ok { + return BigInt(bi), nil + } + return nil, fmt.Errorf("value is not a BigInt") + case "Bool": + if b, ok := v.GetBool(); ok { + return BoolValue(b), nil + } + return nil, fmt.Errorf("value is not a Bool") + case "Cell": + if b, ok := v.GetCell(); ok { + return Any(b), nil + } + return nil, fmt.Errorf("value is not an Any") + case "Slice": + if b, ok := v.GetCell(); ok { + return Any(b), nil + } + return nil, fmt.Errorf("value is not an Any") + case "Builder": + if b, ok := v.GetCell(); ok { + return Any(b), nil + } + return nil, fmt.Errorf("value is not an Any") + case "Callable": + if b, ok := v.GetCell(); ok { + return Any(b), nil + } + return nil, fmt.Errorf("value is not an Any") + case "Remaining": + if b, ok := v.GetCell(); ok { + return Any(b), nil + } + return nil, fmt.Errorf("value is not an Any") + case "Address": + if a, ok := v.GetAddress(); ok { + return a, nil + } + return nil, fmt.Errorf("value is not an InternalAddress") + case "AddressOpt": + if a, ok := v.GetOptionalAddress(); ok { + return a, nil + } + return nil, fmt.Errorf("value is not an OptionalAddress") + case "AddressExt": + if a, ok := v.GetExternalAddress(); ok { + return a, nil + } + return nil, fmt.Errorf("value is not an ExternalAddress") + case "AddressAny": + if a, ok := v.GetAnyAddress(); ok { + return a, nil + } + return nil, fmt.Errorf("value is not an AnyAddress") + case "Nullable": + if o, ok := v.GetOptionalValue(); ok { + return o, nil + } + return nil, fmt.Errorf("value is not an OptionalValue") + case "CellOf": + if r, ok := v.GetRefValue(); ok { + return RefValue(r), nil + } + return nil, fmt.Errorf("value is not a RefValue") + case "Tensor": + if t, ok := v.GetTensor(); ok { + return TensorValues(t), nil + } + return nil, fmt.Errorf("value is not a Tensor") + case "TupleWith": + if t, ok := v.GetTupleValues(); ok { + return TupleValues(t), nil + } + return nil, fmt.Errorf("value is not a Tuple") + case "TupleAny": + return nil, fmt.Errorf("tuple any is not supported") + case "Map": + if m, ok := v.GetMap(); ok { + return m, nil + } + return nil, fmt.Errorf("value is not a Map") + case "EnumRef": + if e, ok := v.GetEnum(); ok { + return e, nil + } + return nil, fmt.Errorf("value is not an Enum") + case "StructRef": + if s, ok := v.GetStruct(); ok { + return s, nil + } + return nil, fmt.Errorf("value is not a Struct") + case "Union": + if u, ok := v.GetUnion(); ok { + return u, nil + } + return nil, fmt.Errorf("value is not an Union") + default: + return nil, fmt.Errorf("unknown value type %v", v.valType.SumType) + } +} + +func (v *Value) SetType(t Ty) { + v.valType = t +} + +func (v *Value) SetValue(val any) error { + switch v.valType.SumType { + case "Int": + return v.valType.Int.SetValue(v, val) + case "NullLiteral": + return v.valType.NullLiteral.SetValue(v, val) + case "Void": + return v.valType.Void.SetValue(v, val) + case "IntN": + return v.valType.IntN.SetValue(v, val) + case "UintN": + return v.valType.UintN.SetValue(v, val) + case "VarIntN": + return v.valType.VarIntN.SetValue(v, val) + case "VarUintN": + return v.valType.VarUintN.SetValue(v, val) + case "BitsN": + return v.valType.BitsN.SetValue(v, val) + case "Coins": + return v.valType.Coins.SetValue(v, val) + case "Bool": + return v.valType.Bool.SetValue(v, val) + case "Cell": + return v.valType.Cell.SetValue(v, val) + case "Slice": + return v.valType.Slice.SetValue(v, val) + case "Builder": + return v.valType.Builder.SetValue(v, val) + case "Callable": + return v.valType.Callable.SetValue(v, val) + case "Remaining": + return v.valType.Remaining.SetValue(v, val) + case "Address": + return v.valType.Address.SetValue(v, val) + case "AddressOpt": + return v.valType.AddressOpt.SetValue(v, val) + case "AddressExt": + return v.valType.AddressExt.SetValue(v, val) + case "AddressAny": + return v.valType.AddressAny.SetValue(v, val) + case "Nullable": + return v.valType.Nullable.SetValue(v, val) + case "CellOf": + return v.valType.CellOf.SetValue(v, val) + case "Tensor": + return v.valType.Tensor.SetValue(v, val) + case "TupleWith": + return v.valType.TupleWith.SetValue(v, val) + case "TupleAny": + return v.valType.TupleAny.SetValue(v, val) + case "Map": + return v.valType.Map.SetValue(v, val) + case "EnumRef": + return v.valType.EnumRef.SetValue(v, val) + case "StructRef": + return v.valType.StructRef.SetValue(v, val) + case "AliasRef": + return v.valType.AliasRef.SetValue(v, val) + case "Generic": + return v.valType.Generic.SetValue(v, val) + case "Union": + return v.valType.Union.SetValue(v, val) + default: + return fmt.Errorf("unknown t type %q", v.valType.SumType) + } +} + +func (v *Value) Equal(o Value) bool { + if v.valType != o.valType { + return false + } + switch v.valType.SumType { + case "Int": + return v.valType.Int.Equal(*v, o) + case "NullLiteral": + return v.valType.NullLiteral.Equal(*v, o) + case "Void": + return v.valType.Void.Equal(*v, o) + case "IntN": + return v.valType.IntN.Equal(*v, o) + case "UintN": + return v.valType.UintN.Equal(*v, o) + case "VarIntN": + return v.valType.VarIntN.Equal(*v, o) + case "VarUintN": + return v.valType.VarUintN.Equal(*v, o) + case "BitsN": + return v.valType.BitsN.Equal(*v, o) + case "Coins": + return v.valType.Coins.Equal(*v, o) + case "Bool": + return v.valType.Bool.Equal(*v, o) + case "Cell": + return v.valType.Cell.Equal(*v, o) + case "Slice": + return v.valType.Slice.Equal(*v, o) + case "Builder": + return v.valType.Builder.Equal(*v, o) + case "Callable": + return v.valType.Callable.Equal(*v, o) + case "Remaining": + return v.valType.Remaining.Equal(*v, o) + case "Address": + return v.valType.Address.Equal(*v, o) + case "AddressOpt": + return v.valType.AddressOpt.Equal(*v, o) + case "AddressExt": + return v.valType.AddressExt.Equal(*v, o) + case "AddressAny": + return v.valType.AddressAny.Equal(*v, o) + case "Nullable": + return v.valType.Nullable.Equal(*v, o) + case "CellOf": + return v.valType.CellOf.Equal(*v, o) + case "Tensor": + return v.valType.Tensor.Equal(*v, o) + case "TupleWith": + return v.valType.TupleWith.Equal(*v, o) + case "TupleAny": + return v.valType.TupleAny.Equal(*v, o) + case "Map": + return v.valType.Map.Equal(*v, o) + case "EnumRef": + return v.valType.EnumRef.Equal(*v, o) + case "StructRef": + return v.valType.StructRef.Equal(*v, o) + case "AliasRef": + return v.valType.AliasRef.Equal(*v, o) + case "Generic": + return v.valType.Generic.Equal(*v, o) + case "Union": + return v.valType.Union.Equal(*v, o) + default: + return false + } +} + +type BoolValue bool + +type Any boc.Cell + +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.(big.Int) + if !ok { + return false + } + bi := big.Int(b) + return bi.Cmp(&otherBigInt) == 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 + +type OptValue struct { + IsExists bool + Val Value +} + +type UnionValue struct { + Prefix TolkPrefix + Val Value +} + +type EnumValue struct { + enumType Ty + Name string + Value big.Int +} + +type AnyAddress struct { + SumType + InternalAddress *InternalAddress + NoneAddress *NoneAddress + ExternalAddress *ExternalAddress + VarAddress *VarAddress +} + +type NoneAddress struct { +} + +type ExternalAddress struct { + Len int16 + Address boc.BitString +} + +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 +} + +type OptionalAddress struct { + SumType + NoneAddress NoneAddress + InternalAddress InternalAddress +} + +type TupleValues []Value + +type TensorValues []Value + +type MapValue struct { + keyType Ty + valType Ty + keys []Value + values []Value + len int +} + +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{ + valType: m.keyType, + smallInt: &v, + } + return m.Get(key) +} + +func (m *MapValue) GetBySmallUInt(v UInt64) (Value, bool) { + key := MapKey{ + valType: m.keyType, + smallUint: &v, + } + return m.Get(key) +} + +func (m *MapValue) GetByBigInt(v BigInt) (Value, bool) { + key := MapKey{ + valType: m.keyType, + bigInt: &v, + } + return m.Get(key) +} + +func (m *MapValue) GetByBits(v Bits) (Value, bool) { + key := MapKey{ + valType: m.keyType, + bits: &v, + } + return m.Get(key) +} + +func (m *MapValue) GetByInternalAddress(v InternalAddress) (Value, bool) { + key := MapKey{ + valType: m.keyType, + internalAddress: &v, + } + return m.Get(key) +} + +func (m *MapValue) Set(key MapKey, value Value) (bool, error) { + if key.valType != m.keyType { + return false, fmt.Errorf("map key has type %v, got %v", m.keyType, key.valType) + } + if value.valType != m.valType { + return false, fmt.Errorf("map value has type %v, got %v", m.valType, value.valType) + } + 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) { + if m.keyType.SumType != "IntN" { + return false, fmt.Errorf("map key has type %v, got int64", m.keyType) + } + if value.valType != m.valType { + return false, fmt.Errorf("map value has type %v, got %v", m.valType, value.valType) + } + key := MapKey{ + valType: m.valType, + smallInt: &k, + } + return m.Set(key, value) +} + +func (m *MapValue) SetBySmallUInt(k UInt64, value Value) (bool, error) { + if m.keyType.SumType != "UintN" { + return false, fmt.Errorf("map key has type %v, got int64", m.keyType) + } + if value.valType != m.valType { + return false, fmt.Errorf("map value has type %v, got %v", m.valType, value.valType) + } + key := MapKey{ + valType: m.valType, + smallUint: &k, + } + return m.Set(key, value) +} + +func (m *MapValue) SetByBigInt(k BigInt, value Value) (bool, error) { + if m.keyType.SumType != "IntN" && m.keyType.SumType != "UintN" && m.keyType.SumType != "VarIntN" && m.keyType.SumType != "VarUintN" { + return false, fmt.Errorf("map key has type %v, got BigInt", m.keyType) + } + if value.valType != m.valType { + return false, fmt.Errorf("map value has type %v, got %v", m.valType, value.valType) + } + key := MapKey{ + valType: m.valType, + bigInt: &k, + } + return m.Set(key, value) +} + +func (m *MapValue) SetByBits(k Bits, value Value) (bool, error) { + if m.keyType.SumType != "BitsN" { + return false, fmt.Errorf("map key has type %v, got BitsN", m.keyType) + } + if value.valType != m.valType { + return false, fmt.Errorf("map value has type %v, got %v", m.valType, value.valType) + } + key := MapKey{ + valType: m.valType, + bits: &k, + } + return m.Set(key, value) +} + +func (m *MapValue) SetByInternalAddress(k InternalAddress, value Value) (bool, error) { + if m.keyType.SumType != "Address" { + return false, fmt.Errorf("map key has type %v, got Address", m.keyType) + } + if value.valType != m.valType { + return false, fmt.Errorf("map value has type %v, got %v", m.valType, value.valType) + } + key := MapKey{ + valType: m.valType, + 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{ + valType: m.valType, + smallInt: &k, + } + m.Delete(key) +} + +func (m *MapValue) DeleteBySmallUInt(k UInt64) { + key := MapKey{ + valType: m.valType, + smallUint: &k, + } + m.Delete(key) +} + +func (m *MapValue) DeleteByBigInt(k BigInt) { + key := MapKey{ + valType: m.valType, + bigInt: &k, + } + m.Delete(key) +} + +func (m *MapValue) DeleteByBits(k Bits) { + key := MapKey{ + valType: m.valType, + bits: &k, + } + m.Delete(key) +} + +func (m *MapValue) DeleteByInternalAddress(k InternalAddress) { + key := MapKey{ + valType: m.valType, + internalAddress: &k, + } + m.Delete(key) +} + +func (m *MapValue) Len() int { + return m.len +} + +type AliasValue Value + +type GenericValue Value 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..84d1694d --- /dev/null +++ b/tolk/tuples.go @@ -0,0 +1,90 @@ +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 + return nil +} + +func (t Tensor) UnmarshalTolk(cell *boc.Cell, v TolkValue, decoder *Decoder) error { + list := make(TensorValues, len(t.Items)) + for i, item := range t.Items { + inner := Value{} + err := item.UnmarshalTolk(cell, &inner, decoder) + if err != nil { + return err + } + list[i] = inner + } + err := v.SetValue(list) + 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 + return nil +} + +func (t TupleWith) UnmarshalTolk(cell *boc.Cell, v TolkValue, decoder *Decoder) error { + list := make(TupleValues, len(t.Items)) + for i, item := range t.Items { + inner := Value{} + err := item.UnmarshalTolk(cell, &inner, decoder) + if err != nil { + return err + } + list[i] = inner + } + err := v.SetValue(list) + 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 (t TupleAny) UnmarshalTolk(cell *boc.Cell, v TolkValue, decoder *Decoder) 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..f53966cc --- /dev/null +++ b/tolk/union.go @@ -0,0 +1,80 @@ +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 + return nil +} + +func (u Union) UnmarshalTolk(cell *boc.Cell, v TolkValue, 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 = variant.VariantTy.UnmarshalTolk(cell, &innerV, decoder) + if err != nil { + return err + } + unionV.Val = innerV + err = v.SetValue(unionV) + if err != nil { + return err + } + + return nil + } + } + + return fmt.Errorf("none of union prefixes matched") +} + +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 +} From 9a55ee1dd5fcad629e9eaedeb9f76b54a91fb8ae Mon Sep 17 00:00:00 2001 From: Pavel Levchenko Date: Fri, 30 Jan 2026 18:11:24 +0300 Subject: [PATCH 03/16] implement unmarshal and add an example --- examples/tolk/abi.json | 68 + examples/tolk/main.go | 114 + tolk/abi_types.go | 397 ++- tolk/addresses.go | 295 +- tolk/cells.go | 189 +- tolk/integers.go | 278 +- tolk/map.go | 229 +- tolk/null.go | 26 +- tolk/refs.go | 331 +- tolk/runtime.go | 43 +- tolk/runtime_test.go | 6921 ++++++++++++++++++++++++++-------------- tolk/runtime_types.go | 1144 +++++-- tolk/tuples.go | 78 +- tolk/union.go | 84 +- 14 files changed, 7214 insertions(+), 2983 deletions(-) create mode 100644 examples/tolk/abi.json create mode 100644 examples/tolk/main.go 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/tolk/abi_types.go b/tolk/abi_types.go index 72ca065d..5788fb8c 100644 --- a/tolk/abi_types.go +++ b/tolk/abi_types.go @@ -247,27 +247,23 @@ func (d *DefaultValue) MarshalJSON() ([]byte, error) { return concatPrefixAndPayload(prefix, payload), nil } -func (d *DefaultValue) UnmarshalDefaultValue(v TolkValue) (bool, error) { - vType := v.GetType() +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(val) + err = v.SetValue(BigInt(*val), vType) if err != nil { return false, err } case "BoolDefaultValue": - err := v.SetValue(d.BoolDefaultValue.V) + err := v.SetValue(BoolValue(d.BoolDefaultValue.V), vType) if err != nil { return false, err } case "SliceDefaultValue": - if vType.SumType != "Remaining" && vType.SumType != "Slice" { - return false, fmt.Errorf("default type %v and field type %v mismatch", d.SumType, vType.SumType) - } val, err := hex.DecodeString(d.SliceDefaultValue.Hex) if err != nil { return false, err @@ -277,15 +273,11 @@ func (d *DefaultValue) UnmarshalDefaultValue(v TolkValue) (bool, error) { if err != nil { return false, err } - anySlice := Any(*boc.NewCellWithBits(bs)) - err = v.SetValue(anySlice) + err = v.SetValue(*boc.NewCellWithBits(bs), vType) if err != nil { return false, err } case "AddressDefaultValue": - if vType.SumType != "Address" { - return false, fmt.Errorf("default type %v and field type %v mismatch", d.SumType, vType.SumType) - } accountID, err := ton.ParseAccountID(d.AddressDefaultValue.Address) if err != nil { return false, err @@ -293,21 +285,24 @@ func (d *DefaultValue) UnmarshalDefaultValue(v TolkValue) (bool, error) { 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) + _, err := item.unmarshalDefaultValue(&val, vType.Tensor.Items[i]) if err != nil { return false, err } tensor[i] = val } - err := v.SetValue(tensor) + err := v.SetValue(tensor, vType) if err != nil { return false, err } @@ -644,71 +639,377 @@ func (t *Ty) MarshalJSON() ([]byte, error) { return concatPrefixAndPayload(prefix, payload), nil } -func (t *Ty) UnmarshalTolk(cell *boc.Cell, v TolkValue, decoder *Decoder) error { - v.SetType(*t) +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": - return t.Int.UnmarshalTolk(cell, v, decoder) + err := t.Int.MarshalTolk(cell, v) + if err != nil { + return fmt.Errorf("failed to marshal unmarshal Int: %w", err) + } + return nil case "NullLiteral": - return t.NullLiteral.UnmarshalTolk(cell, v, decoder) + err := t.NullLiteral.MarshalTolk(cell, v) + if err != nil { + return fmt.Errorf("failed to marshal NullLiteral Int: %w", err) + } + return nil case "Void": - return t.Void.UnmarshalTolk(cell, v, decoder) + err := t.Void.MarshalTolk(cell, v) + if err != nil { + return fmt.Errorf("failed to marshal Void: %w", err) + } + return nil case "IntN": - return t.IntN.UnmarshalTolk(cell, v, decoder) + err := t.IntN.MarshalTolk(cell, v) + if err != nil { + return fmt.Errorf("failed to marshal IntN: %w", err) + } + return nil case "UintN": - return t.UintN.UnmarshalTolk(cell, v, decoder) + err := t.UintN.MarshalTolk(cell, v) + if err != nil { + return fmt.Errorf("failed to marshal UintN: %w", err) + } + return nil case "VarIntN": - return t.VarIntN.UnmarshalTolk(cell, v, decoder) + err := t.VarIntN.MarshalTolk(cell, v) + if err != nil { + return fmt.Errorf("failed to marshal VarIntN: %w", err) + } + return nil case "VarUintN": - return t.VarUintN.UnmarshalTolk(cell, v, decoder) + err := t.VarUintN.MarshalTolk(cell, v) + if err != nil { + return fmt.Errorf("failed to marshal VarUintN: %w", err) + } + return nil case "BitsN": - return t.BitsN.UnmarshalTolk(cell, v, decoder) + err := t.BitsN.MarshalTolk(cell, v) + if err != nil { + return fmt.Errorf("failed to marshal BitsN: %w", err) + } + return nil case "Coins": - return t.Coins.UnmarshalTolk(cell, v, decoder) + err := t.Coins.MarshalTolk(cell, v) + if err != nil { + return fmt.Errorf("failed to marshal Coins: %w", err) + } + return nil case "Bool": - return t.Bool.UnmarshalTolk(cell, v, decoder) + err := t.Bool.MarshalTolk(cell, v) + if err != nil { + return fmt.Errorf("failed to marshal Bool: %w", err) + } + return nil case "Cell": - return t.Cell.UnmarshalTolk(cell, v, decoder) + err := t.Cell.MarshalTolk(cell, v) + if err != nil { + return fmt.Errorf("failed to marshal Cell: %w", err) + } + return nil case "Slice": - return t.Slice.UnmarshalTolk(cell, v, decoder) + err := t.Slice.MarshalTolk(cell, v) + if err != nil { + return fmt.Errorf("failed to marshal Slice: %w", err) + } + return nil case "Builder": - return t.Builder.UnmarshalTolk(cell, v, decoder) + err := t.Builder.MarshalTolk(cell, v) + if err != nil { + return fmt.Errorf("failed to marshal Builder: %w", err) + } + return nil case "Callable": - return t.Callable.UnmarshalTolk(cell, v, decoder) + err := t.Callable.MarshalTolk(cell, v) + if err != nil { + return fmt.Errorf("failed to marshal Callable: %w", err) + } + return nil case "Remaining": - return t.Remaining.UnmarshalTolk(cell, v, decoder) + err := t.Remaining.MarshalTolk(cell, v) + if err != nil { + return fmt.Errorf("failed to marshal Remaining: %w", err) + } + return nil case "Address": - return t.Address.UnmarshalTolk(cell, v, decoder) + err := t.Address.MarshalTolk(cell, v) + if err != nil { + return fmt.Errorf("failed to marshal Address: %w", err) + } + return nil case "AddressOpt": - return t.AddressOpt.UnmarshalTolk(cell, v, decoder) + err := t.AddressOpt.MarshalTolk(cell, v) + if err != nil { + return fmt.Errorf("failed to marshal AddressOpt: %w", err) + } + return nil case "AddressExt": - return t.AddressExt.UnmarshalTolk(cell, v, decoder) + err := t.AddressExt.MarshalTolk(cell, v) + if err != nil { + return fmt.Errorf("failed to marshal AddressExt: %w", err) + } + return nil case "AddressAny": - return t.AddressAny.UnmarshalTolk(cell, v, decoder) + err := t.AddressAny.MarshalTolk(cell, v) + if err != nil { + return fmt.Errorf("failed to marshal AddressAny: %w", err) + } + return nil case "Nullable": - return t.Nullable.UnmarshalTolk(cell, v, decoder) + err := t.Nullable.MarshalTolk(cell, v) + if err != nil { + return fmt.Errorf("failed to marshal Nullable: %w", err) + } + return nil case "CellOf": - return t.CellOf.UnmarshalTolk(cell, v, decoder) + err := t.CellOf.MarshalTolk(cell, v) + if err != nil { + return fmt.Errorf("failed to marshal CellOf: %w", err) + } + return nil case "Tensor": - return t.Tensor.UnmarshalTolk(cell, v, decoder) + err := t.Tensor.MarshalTolk(cell, v) + if err != nil { + return fmt.Errorf("failed to marshal Tensor: %w", err) + } + return nil case "TupleWith": - return t.TupleWith.UnmarshalTolk(cell, v, decoder) + err := t.TupleWith.MarshalTolk(cell, v) + if err != nil { + return fmt.Errorf("failed to marshal TupleWith: %w", err) + } + return nil case "TupleAny": - return t.TupleAny.UnmarshalTolk(cell, v, decoder) + err := t.TupleAny.MarshalTolk(cell, v) + if err != nil { + return fmt.Errorf("failed to marshal TupleAny: %w", err) + } + return nil case "Map": - return t.Map.UnmarshalTolk(cell, v, decoder) + err := t.Map.MarshalTolk(cell, v) + if err != nil { + return fmt.Errorf("failed to marshal Map: %w", err) + } + return nil case "EnumRef": - return t.EnumRef.UnmarshalTolk(cell, v, decoder) + err := t.EnumRef.MarshalTolk(cell, v) + if err != nil { + return fmt.Errorf("failed to marshal EnumRef: %w", err) + } + return nil case "StructRef": - return t.StructRef.UnmarshalTolk(cell, v, decoder) + err := t.StructRef.MarshalTolk(cell, v) + if err != nil { + return fmt.Errorf("failed to marshal StructRef: %w", err) + } + return nil case "AliasRef": - return t.AliasRef.UnmarshalTolk(cell, v, decoder) + err := t.AliasRef.MarshalTolk(cell, v) + if err != nil { + return fmt.Errorf("failed to marshal AliasRef: %w", err) + } + return nil case "Generic": - return t.Generic.UnmarshalTolk(cell, v, decoder) + err := t.Generic.MarshalTolk(cell, v) + if err != nil { + return fmt.Errorf("failed to marshal Generic: %w", err) + } + return nil case "Union": - return t.Union.UnmarshalTolk(cell, v, decoder) + 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 t type %q", t.SumType) + return fmt.Errorf("unknown type %q", t.SumType) } } diff --git a/tolk/addresses.go b/tolk/addresses.go index fb8089ff..29bd8679 100644 --- a/tolk/addresses.go +++ b/tolk/addresses.go @@ -13,11 +13,12 @@ func (Address) SetValue(v *Value, val any) error { if !ok { return fmt.Errorf("value is not an internal address") } + v.sumType = "internalAddress" v.internalAddress = &a return nil } -func (Address) UnmarshalTolk(cell *boc.Cell, v TolkValue, decoder *Decoder) error { +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 @@ -30,7 +31,7 @@ func (Address) UnmarshalTolk(cell *boc.Cell, v TolkValue, decoder *Decoder) erro if err != nil { return err } - err = v.SetValue(InternalAddress{ + err = a.SetValue(v, InternalAddress{ Workchain: int8(workchain), Address: [32]byte(address), }) @@ -40,6 +41,46 @@ func (Address) UnmarshalTolk(cell *boc.Cell, v TolkValue, decoder *Decoder) erro 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 @@ -61,17 +102,18 @@ func (AddressOpt) SetValue(v *Value, val any) error { if !ok { return fmt.Errorf("value is not an optional address") } + v.sumType = "optionalAddress" v.optionalAddress = &a return nil } -func (AddressOpt) UnmarshalTolk(cell *boc.Cell, v TolkValue, decoder *Decoder) error { +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 = v.SetValue(OptionalAddress{ + err = a.SetValue(v, OptionalAddress{ SumType: "NoneAddress", }) if err != nil { @@ -91,7 +133,7 @@ func (AddressOpt) UnmarshalTolk(cell *boc.Cell, v TolkValue, decoder *Decoder) e if err != nil { return err } - err = v.SetValue(OptionalAddress{ + err = a.SetValue(v, OptionalAddress{ SumType: "InternalAddress", InternalAddress: InternalAddress{ Workchain: int8(workchain), @@ -105,6 +147,65 @@ func (AddressOpt) UnmarshalTolk(cell *boc.Cell, v TolkValue, decoder *Decoder) e 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 } @@ -117,10 +218,11 @@ func (AddressExt) SetValue(v *Value, val any) error { return fmt.Errorf("value is not an external address") } v.externalAddress = &a + v.sumType = "externalAddress" return nil } -func (AddressExt) UnmarshalTolk(cell *boc.Cell, v TolkValue, decoder *Decoder) error { +func (a AddressExt) UnmarshalTolk(cell *boc.Cell, v *Value, abiCtx *Decoder) error { err := cell.Skip(2) if err != nil { return err @@ -133,7 +235,7 @@ func (AddressExt) UnmarshalTolk(cell *boc.Cell, v TolkValue, decoder *Decoder) e if err != nil { return err } - err = v.SetValue(ExternalAddress{ + err = a.SetValue(v, ExternalAddress{ Len: int16(ln), Address: bs, }) @@ -144,6 +246,47 @@ func (AddressExt) UnmarshalTolk(cell *boc.Cell, v TolkValue, decoder *Decoder) e 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 } @@ -156,17 +299,18 @@ func (AddressAny) SetValue(v *Value, val any) error { return fmt.Errorf("value is not an any address") } v.anyAddress = &a + v.sumType = "anyAddress" return nil } -func (AddressAny) UnmarshalTolk(cell *boc.Cell, v TolkValue, decoder *Decoder) error { +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 = v.SetValue(AnyAddress{ + err = a.SetValue(v, AnyAddress{ SumType: "NoneAddress", }) if err != nil { @@ -181,7 +325,7 @@ func (AddressAny) UnmarshalTolk(cell *boc.Cell, v TolkValue, decoder *Decoder) e if err != nil { return err } - err = v.SetValue(AnyAddress{ + err = a.SetValue(v, AnyAddress{ SumType: "ExternalAddress", ExternalAddress: &ExternalAddress{ Len: int16(ln), @@ -204,7 +348,7 @@ func (AddressAny) UnmarshalTolk(cell *boc.Cell, v TolkValue, decoder *Decoder) e if err != nil { return err } - err = v.SetValue(AnyAddress{ + err = a.SetValue(v, AnyAddress{ SumType: "InternalAddress", InternalAddress: &InternalAddress{ Workchain: int8(workchain), @@ -231,7 +375,7 @@ func (AddressAny) UnmarshalTolk(cell *boc.Cell, v TolkValue, decoder *Decoder) e if err != nil { return err } - err = v.SetValue(AnyAddress{ + err = a.SetValue(v, AnyAddress{ SumType: "VarAddress", VarAddress: &VarAddress{ Len: int16(ln), @@ -247,6 +391,133 @@ func (AddressAny) UnmarshalTolk(cell *boc.Cell, v TolkValue, decoder *Decoder) e 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 index ecaa82af..43b636b6 100644 --- a/tolk/cells.go +++ b/tolk/cells.go @@ -14,21 +14,47 @@ func (Cell) SetValue(v *Value, val any) error { return fmt.Errorf("value is not a cell") } v.cell = &a + v.sumType = "cell" return nil } -func (Cell) UnmarshalTolk(cell *boc.Cell, v TolkValue, decoder *Decoder) error { +func (c Cell) UnmarshalTolk(cell *boc.Cell, v *Value, decoder *Decoder) error { ref, err := cell.NextRef() if err != nil { return err } - err = v.SetValue(Any(*ref)) + 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 } @@ -36,15 +62,14 @@ func (Cell) Equal(v Value, o Value) bool { type Slice struct{} func (Slice) SetValue(v *Value, val any) error { - a, ok := val.(Any) - if !ok { - return fmt.Errorf("value is not a cell") - } - v.cell = &a - return nil + 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) UnmarshalTolk(cell *boc.Cell, v TolkValue, decoder *Decoder) error { +func (Slice) MarshalTolk(cell *boc.Cell, v *Value) error { return fmt.Errorf("slice is not supported") } @@ -55,15 +80,14 @@ func (Slice) Equal(v Value, o Value) bool { type Builder struct{} func (Builder) SetValue(v *Value, val any) error { - a, ok := val.(Any) - if !ok { - return fmt.Errorf("value is not a cell") - } - v.cell = &a - return nil + 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) UnmarshalTolk(cell *boc.Cell, v TolkValue, decoder *Decoder) error { +func (Builder) MarshalTolk(cell *boc.Cell, v *Value) error { return fmt.Errorf("builder is not supported") } @@ -74,15 +98,14 @@ func (Builder) Equal(v Value, o Value) bool { type Callable struct{} func (Callable) SetValue(v *Value, val any) error { - a, ok := val.(Any) - if !ok { - return fmt.Errorf("value is not a cell") - } - v.cell = &a - return nil + return fmt.Errorf("callable is not supported") } -func (Callable) UnmarshalTolk(cell *boc.Cell, v TolkValue, decoder *Decoder) error { +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") } @@ -98,13 +121,14 @@ func (Remaining) SetValue(v *Value, val any) error { return fmt.Errorf("value is not a cell") } v.cell = &a + v.sumType = "cell" return nil } -func (Remaining) UnmarshalTolk(cell *boc.Cell, v TolkValue, decoder *Decoder) error { +func (r Remaining) UnmarshalTolk(cell *boc.Cell, v *Value, decoder *Decoder) error { rem := cell.CopyRemaining() if rem != nil { - err := v.SetValue(Any(*rem)) + err := r.SetValue(v, Any(*rem)) if err != nil { return err } @@ -112,6 +136,33 @@ func (Remaining) UnmarshalTolk(cell *boc.Cell, v TolkValue, decoder *Decoder) er 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 } @@ -126,35 +177,70 @@ func (Nullable) SetValue(v *Value, val any) error { 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 TolkValue, decoder *Decoder) error { +func (n Nullable) UnmarshalTolk(cell *boc.Cell, v *Value, decoder *Decoder) error { isExists, err := cell.ReadBit() if err != nil { return err } - innerV := Value{ - valType: n.Inner, - } + innerV := Value{} optV := OptValue{ IsExists: isExists, Val: innerV, } if isExists { - err = n.Inner.UnmarshalTolk(cell, &innerV, decoder) + err = innerV.UnmarshalTolk(cell, n.Inner, decoder) if err != nil { return err } optV.Val = innerV } - err = v.SetValue(optV) + 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 } @@ -169,23 +255,58 @@ func (CellOf) SetValue(v *Value, val any) error { 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 TolkValue, decoder *Decoder) error { +func (c CellOf) UnmarshalTolk(cell *boc.Cell, v *Value, decoder *Decoder) error { ref, err := cell.NextRef() if err != nil { return err } innerV := Value{} - err = c.Inner.UnmarshalTolk(ref, &innerV, decoder) + 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 } - err = v.SetValue(RefValue(innerV)) + 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 } diff --git a/tolk/integers.go b/tolk/integers.go index 9b14475b..68839b1b 100644 --- a/tolk/integers.go +++ b/tolk/integers.go @@ -14,7 +14,11 @@ func (i Int) SetValue(v *Value, val any) error { return fmt.Errorf("int is not supported") } -func (Int) UnmarshalTolk(cell *boc.Cell, v TolkValue, decoder *Decoder) error { +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") } @@ -34,6 +38,7 @@ func (i IntN) SetValue(v *Value, val any) error { return fmt.Errorf("value is not a BigInt") } v.bigInt = &bi + v.sumType = "bigInt" } else { i64, ok := val.(Int64) if !ok { @@ -44,21 +49,65 @@ func (i IntN) SetValue(v *Value, val any) error { b := big.Int(bi) i64 = Int64(b.Int64()) } - wi64 := i64 - v.smallInt = &wi64 + v.smallInt = &i64 + v.sumType = "smallInt" } return nil } -func (i IntN) UnmarshalTolk(cell *boc.Cell, v TolkValue, decoder *Decoder) error { +func (i IntN) UnmarshalTolk(cell *boc.Cell, v *Value, decoder *Decoder) error { num, err := cell.ReadBigInt(i.N) if err != nil { return err } - err = v.SetValue(BigInt(*num)) + 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 } @@ -96,6 +145,7 @@ func (u UintN) SetValue(v *Value, val any) error { return fmt.Errorf("value is not a BigInt") } v.bigInt = &bi + v.sumType = "bigInt" } else { ui64, ok := val.(UInt64) if !ok { @@ -106,21 +156,65 @@ func (u UintN) SetValue(v *Value, val any) error { b := big.Int(bi) ui64 = UInt64(b.Uint64()) } - wui64 := ui64 - v.smallUint = &wui64 + v.smallUint = &ui64 + v.sumType = "smallUint" } return nil } -func (u UintN) UnmarshalTolk(cell *boc.Cell, v TolkValue, decoder *Decoder) error { +func (u UintN) UnmarshalTolk(cell *boc.Cell, v *Value, decoder *Decoder) error { num, err := cell.ReadBigUint(u.N) if err != nil { return err } - err = v.SetValue(BigInt(*num)) + 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 } @@ -156,10 +250,11 @@ func (VarIntN) SetValue(v *Value, val any) error { return fmt.Errorf("value is not a BigInt") } v.bigInt = &bi + v.sumType = "bigInt" return nil } -func (vi VarIntN) UnmarshalTolk(cell *boc.Cell, v TolkValue, decoder *Decoder) error { +func (vi VarIntN) UnmarshalTolk(cell *boc.Cell, v *Value, decoder *Decoder) error { n := vi.N ln, err := cell.ReadLimUint(n - 1) if err != nil { @@ -169,13 +264,44 @@ func (vi VarIntN) UnmarshalTolk(cell *boc.Cell, v TolkValue, decoder *Decoder) e if err != nil { return err } - err = v.SetValue(BigInt(*val)) + 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 } @@ -185,15 +311,16 @@ type VarUintN struct { } func (VarUintN) SetValue(v *Value, val any) error { - bi, ok := val.(BigInt) + vu, ok := val.(BigInt) if !ok { return fmt.Errorf("value is not a BigInt") } - v.bigInt = &bi + v.bigInt = &vu + v.sumType = "bigInt" return nil } -func (vu VarUintN) UnmarshalTolk(cell *boc.Cell, v TolkValue, decoder *Decoder) error { +func (vu VarUintN) UnmarshalTolk(cell *boc.Cell, v *Value, decoder *Decoder) error { n := vu.N ln, err := cell.ReadLimUint(n - 1) if err != nil { @@ -203,13 +330,44 @@ func (vu VarUintN) UnmarshalTolk(cell *boc.Cell, v TolkValue, decoder *Decoder) if err != nil { return err } - err = v.SetValue(BigInt(*val)) + 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 } @@ -224,19 +382,42 @@ func (BitsN) SetValue(v *Value, val any) error { return fmt.Errorf("value is not a Bits") } v.bits = &bits + v.sumType = "bits" return nil } -func (b BitsN) UnmarshalTolk(cell *boc.Cell, v TolkValue, decoder *Decoder) error { +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 = v.SetValue(Bits(val)) + 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 } @@ -262,10 +443,11 @@ func (Coins) SetValue(v *Value, val any) error { return fmt.Errorf("value is not a BigInt") } v.bigInt = &bi + v.sumType = "bigInt" return nil } -func (Coins) UnmarshalTolk(cell *boc.Cell, v TolkValue, decoder *Decoder) error { +func (c Coins) UnmarshalTolk(cell *boc.Cell, v *Value, decoder *Decoder) error { ln, err := cell.ReadLimUint(15) if err != nil { return err @@ -274,13 +456,44 @@ func (Coins) UnmarshalTolk(cell *boc.Cell, v TolkValue, decoder *Decoder) error if err != nil { return err } - err = v.SetValue(BigInt(*val)) + 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 } @@ -293,18 +506,41 @@ func (Bool) SetValue(v *Value, val any) error { 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 (Bool) UnmarshalTolk(cell *boc.Cell, v TolkValue, decoder *Decoder) error { +func (b *BoolValue) UnmarshalTolk(cell *boc.Cell, ty Bool, decoder *Decoder) error { val, err := cell.ReadBit() if err != nil { return err } - err = v.SetValue(BoolValue(val)) + *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 } diff --git a/tolk/map.go b/tolk/map.go index 015f5b70..702faf9f 100644 --- a/tolk/map.go +++ b/tolk/map.go @@ -7,19 +7,13 @@ import ( ) type TolkType interface { - UnmarshalTolk(cell *boc.Cell, v TolkValue, decoder *Decoder) error + UnmarshalTolk(cell *boc.Cell, v *Value, decoder *Decoder) error } type TolkComparableType interface { - UnmarshalTolk(cell *boc.Cell, v TolkValue, decoder *Decoder) error GetFixedSize() int } -type TolkComparableValue interface { - Equal(other any) bool - Compare(other any) (int, bool) -} - type Map struct { K Ty `json:"k"` V Ty `json:"v"` @@ -31,10 +25,11 @@ func (Map) SetValue(v *Value, val any) error { return fmt.Errorf("value is not a map") } v.mp = &m + v.sumType = "mp" return nil } -func (m Map) UnmarshalTolk(cell *boc.Cell, v TolkValue, decoder *Decoder) error { +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) @@ -47,10 +42,8 @@ func (m Map) UnmarshalTolk(cell *boc.Cell, v TolkValue, decoder *Decoder) error return err } mp := MapValue{ - keyType: m.K, - valType: m.V, - keys: make([]Value, 0), - values: make([]Value, 0), + keys: make([]Value, 0), + values: make([]Value, 0), } if isNotEmpty { mpCell, err := cell.NextRef() @@ -64,7 +57,7 @@ func (m Map) UnmarshalTolk(cell *boc.Cell, v TolkValue, decoder *Decoder) error } mp.len = len(mp.keys) - err = v.SetValue(mp) + err = m.SetValue(v, mp) if err != nil { return err } @@ -72,6 +65,40 @@ func (m Map) UnmarshalTolk(cell *boc.Cell, v TolkValue, decoder *Decoder) error 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, @@ -123,7 +150,7 @@ func mapInner( } // add node to map v := Value{} - err = vt.UnmarshalTolk(c, &v, decoder) + err = v.UnmarshalTolk(c, vt, decoder) if err != nil { return err } @@ -135,7 +162,7 @@ func mapInner( } k := Value{} cell := boc.NewCellWithBits(key) - err = kt.UnmarshalTolk(cell, &k, decoder) + err = k.UnmarshalTolk(cell, kt, decoder) if err != nil { return err } @@ -209,6 +236,178 @@ func loadLabel(size int, c *boc.Cell, key *boc.BitString) (int, *boc.BitString, 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 index 7cc46b22..4d61bccc 100644 --- a/tolk/null.go +++ b/tolk/null.go @@ -1,14 +1,25 @@ package tolk -import "github.com/tonkeeper/tongo/boc" +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 TolkValue, decoder *Decoder) error { +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 } @@ -19,10 +30,19 @@ func (NullLiteral) Equal(v Value, o Value) bool { 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) UnmarshalTolk(cell *boc.Cell, v TolkValue, decoder *Decoder) error { +func (Void) MarshalTolk(cell *boc.Cell, v *Value) error { return nil } diff --git a/tolk/refs.go b/tolk/refs.go index 82ba9d92..103687de 100644 --- a/tolk/refs.go +++ b/tolk/refs.go @@ -18,33 +18,34 @@ func (EnumRef) SetValue(v *Value, val any) error { 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 TolkValue, decoder *Decoder) error { - if decoder.abiCtx == 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.abiCtx.enumRefs[e.EnumName] + 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 := enum.EncodedAs.UnmarshalTolk(cell, &enumVal, decoder) + err := enumVal.UnmarshalTolk(cell, enum.EncodedAs, decoder) if err != nil { return err } var bigEnumVal big.Int - switch enumVal.valType.SumType { + switch enum.EncodedAs.SumType { case "IntN": - if enumVal.valType.IntN.N > 64 { + if enum.EncodedAs.IntN.N > 64 { bigEnumVal = big.Int(*enumVal.bigInt) } else { bigEnumVal = *big.NewInt(int64(*enumVal.smallInt)) } case "UintN": - if enumVal.valType.UintN.N > 64 { + if enum.EncodedAs.UintN.N > 64 { bigEnumVal = big.Int(*enumVal.bigInt) } else { bigEnumVal = *new(big.Int).SetUint64(uint64(*enumVal.smallUint)) @@ -52,7 +53,7 @@ func (e EnumRef) UnmarshalTolk(cell *boc.Cell, v TolkValue, decoder *Decoder) er case "VarIntN", "VarUintN": bigEnumVal = big.Int(*enumVal.bigInt) default: - return fmt.Errorf("enum encode type must be integer, got: %s", enumVal.valType.SumType) + return fmt.Errorf("enum encode type must be integer, got: %s", enum.EncodedAs.SumType) } for _, member := range enum.Members { @@ -62,10 +63,10 @@ func (e EnumRef) UnmarshalTolk(cell *boc.Cell, v TolkValue, decoder *Decoder) er } if val.Cmp(&bigEnumVal) == 0 { - err = v.SetValue(EnumValue{ - enumType: enum.EncodedAs, - Name: member.Name, - Value: *val, + err = e.SetValue(v, EnumValue{ + val: enumVal, + Name: member.Name, + Value: *val, }) if err != nil { return err @@ -75,10 +76,10 @@ func (e EnumRef) UnmarshalTolk(cell *boc.Cell, v TolkValue, decoder *Decoder) er } } // todo: maybe return err? - err = v.SetValue(EnumValue{ - enumType: enum.EncodedAs, - Name: "Unknown", - Value: bigEnumVal, + err = e.SetValue(v, EnumValue{ + val: enumVal, + Name: "Unknown", + Value: bigEnumVal, }) if err != nil { return err @@ -87,6 +88,85 @@ func (e EnumRef) UnmarshalTolk(cell *boc.Cell, v TolkValue, decoder *Decoder) er 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 } @@ -102,18 +182,19 @@ func (StructRef) SetValue(v *Value, val any) error { return fmt.Errorf("value is not a struct") } v.structValue = &s + v.sumType = "structValue" return nil } -func (s StructRef) UnmarshalTolk(cell *boc.Cell, v TolkValue, decoder *Decoder) error { - if decoder.abiCtx == 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.abiCtx.structRefs[s.StructName] + strct, found := decoder.abiRefs.structRefs[s.StructName] if !found { return fmt.Errorf("no struct with name %s was found in given abi", s.StructName) } - cont := Struct{ + tolkStruct := Struct{ field: make(map[string]Value), } if strct.Prefix != nil { @@ -134,34 +215,33 @@ func (s StructRef) UnmarshalTolk(cell *boc.Cell, v TolkValue, decoder *Decoder) if prefix != actualPrefix { return fmt.Errorf("struct %v prefix does not match actual prefix %v", strct.Name, actualPrefix) } - cont.hasPrefix = true - cont.prefix = TolkPrefix{ + tolkStruct.hasPrefix = true + tolkStruct.prefix = TolkPrefix{ Len: int16(prefixLen), Prefix: prefix, } } - oldGenericMap := decoder.abiCtx.genericRefs + oldGenericMap := decoder.abiRefs.genericRefs genericMap, err := resolveGeneric(s.TypeArgs, strct.TypeParams, decoder) if err != nil { return err } - decoder.abiCtx.genericRefs = genericMap + decoder.abiRefs.genericRefs = genericMap for _, field := range strct.Fields { fieldVal := Value{} - err = field.Ty.UnmarshalTolk(cell, &fieldVal, decoder) + err = fieldVal.UnmarshalTolk(cell, field.Ty, decoder) if err != nil { return err } - if fieldVal.valType.SumType == "Nullable" { + if field.Ty.SumType == "Nullable" { optVal := *fieldVal.optionalValue defVal := field.DefaultValue if !optVal.IsExists && defVal != nil { val := Value{} - // todo remove decoder methods - exists, err := defVal.UnmarshalDefaultValue(&val) + exists, err := defVal.unmarshalDefaultValue(&val, field.Ty) if err != nil { return err } @@ -172,11 +252,11 @@ func (s StructRef) UnmarshalTolk(cell *boc.Cell, v TolkValue, decoder *Decoder) } } - cont.field[field.Name] = fieldVal + tolkStruct.field[field.Name] = fieldVal } - decoder.abiCtx.genericRefs = oldGenericMap + decoder.abiRefs.genericRefs = oldGenericMap - err = v.SetValue(cont) + err = s.SetValue(v, tolkStruct) if err != nil { return err } @@ -184,6 +264,103 @@ func (s StructRef) UnmarshalTolk(cell *boc.Cell, v TolkValue, decoder *Decoder) 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 } @@ -194,14 +371,14 @@ type AliasRef struct { } func (AliasRef) SetValue(v *Value, val any) error { - return fmt.Errorf("alias cannot be value") + return fmt.Errorf("alias cannot be a value") } -func (a AliasRef) UnmarshalTolk(cell *boc.Cell, v TolkValue, decoder *Decoder) error { - if decoder.abiCtx == nil { +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.abiCtx.aliasRefs[a.AliasName] + alias, found := decoder.abiRefs.aliasRefs[a.AliasName] if !found { return fmt.Errorf("no alias with name %s was found in given abi", a.AliasName) } @@ -211,33 +388,66 @@ func (a AliasRef) UnmarshalTolk(cell *boc.Cell, v TolkValue, decoder *Decoder) e fmt.Println("WARNING! alias has custom unpack method. Standard unpacking can be incorrect!") } - oldGenericMap := decoder.abiCtx.genericRefs + oldGenericMap := decoder.abiRefs.genericRefs genericMap, err := resolveGeneric(a.TypeArgs, alias.TypeParams, decoder) if err != nil { return err } - decoder.abiCtx.genericRefs = genericMap + decoder.abiRefs.genericRefs = genericMap val := Value{} - err = alias.TargetTy.UnmarshalTolk(cell, &val, decoder) + err = val.UnmarshalTolk(cell, alias.TargetTy, decoder) if err != nil { return err } - decoder.abiCtx.genericRefs = oldGenericMap + 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!") + } - innerVal, err := val.GetAny() + oldGenericMap := decoder.abiRefs.genericRefs + genericMap, err := resolveGeneric(ty.TypeArgs, alias.TypeParams, decoder) if err != nil { return err } - v.SetType(val.valType) - err = v.SetValue(innerVal) + 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 } @@ -247,52 +457,67 @@ type Generic struct { } func (Generic) SetValue(v *Value, val any) error { - return fmt.Errorf("generic cannot be value") + return fmt.Errorf("generic cannot be a value") } -func (g Generic) UnmarshalTolk(cell *boc.Cell, v TolkValue, decoder *Decoder) error { - currentTy, found := decoder.abiCtx.genericRefs[g.NameT] +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 := currentTy.UnmarshalTolk(cell, &val, decoder) + err := val.UnmarshalTolk(cell, currentTy, decoder) if err != nil { return err } - innerVal, err := val.GetAny() + err = g.SetValue(v, val) if err != nil { return err } - v.SetType(val.valType) - err = v.SetValue(innerVal) + + 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.abiCtx.genericRefs != nil { - maps.Copy(genericMap, d.abiCtx.genericRefs) + 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.abiCtx.genericRefs == nil { + if d.abiRefs.genericRefs == nil { return nil, fmt.Errorf("cannot resolve generic type %v", genericTy.Generic.NameT) } - ty, found := d.abiCtx.genericRefs[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) } diff --git a/tolk/runtime.go b/tolk/runtime.go index 033c4a4f..b567914b 100644 --- a/tolk/runtime.go +++ b/tolk/runtime.go @@ -8,7 +8,7 @@ type TolkUnmarshaler interface { UnmarshalTolk(cell *boc.Cell, v *Value, d *Decoder) error } -type abiContext struct { +type abiRefs struct { structRefs map[string]StructDeclaration aliasRefs map[string]AliasDeclaration enumRefs map[string]EnumDeclaration @@ -16,47 +16,48 @@ type abiContext struct { } type Decoder struct { - abiCtx *abiContext + abiRefs abiRefs } func NewDecoder() *Decoder { - return &Decoder{ - abiCtx: &abiContext{ - genericRefs: make(map[string]Ty), - }, - } + return &Decoder{} } -func (d *Decoder) WithABI(abi ABI) *Decoder { - d.abiCtx = &abiContext{ - structRefs: make(map[string]StructDeclaration), - aliasRefs: make(map[string]AliasDeclaration), - enumRefs: make(map[string]EnumDeclaration), +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": - d.abiCtx.structRefs[declr.StructDeclaration.Name] = declr.StructDeclaration + a.abiRefs.structRefs[declr.StructDeclaration.Name] = declr.StructDeclaration case "Alias": - d.abiCtx.aliasRefs[declr.AliasDeclaration.Name] = declr.AliasDeclaration + a.abiRefs.aliasRefs[declr.AliasDeclaration.Name] = declr.AliasDeclaration case "Enum": - d.abiCtx.enumRefs[declr.EnumDeclaration.Name] = declr.EnumDeclaration + a.abiRefs.enumRefs[declr.EnumDeclaration.Name] = declr.EnumDeclaration } } - return d + return a } func UnmarshalTolk(cell *boc.Cell, ty Ty) (*Value, error) { - d := NewDecoder() - return d.UnmarshalTolk(cell, ty) + a := NewDecoder() + return a.UnmarshalTolk(cell, ty) } -// todo: maybe use only abi (guess best struct to unmarshal) -func (d *Decoder) UnmarshalTolk(cell *boc.Cell, ty Ty) (*Value, error) { +func (a *Decoder) UnmarshalTolk(cell *boc.Cell, ty Ty) (*Value, error) { res := &Value{} - err := ty.UnmarshalTolk(cell, res, d) + 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 index 2f3bf445..318172da 100644 --- a/tolk/runtime_test.go +++ b/tolk/runtime_test.go @@ -13,2544 +13,4587 @@ import ( "github.com/tonkeeper/tongo/ton" ) -func TestRuntimeUnmarshal(t *testing.T) { - type cases struct { - name string - filename string - cell string - t Ty - check func(Value) - } - for _, c := range []cases{ - { - name: "unmarshal small int", - filename: "simple", - cell: "b5ee9c72410101010005000006ff76c41616db06", - t: Ty{ - SumType: "IntN", - IntN: &IntN{ - N: 24, - }, - }, - check: func(v Value) { - val, ok := v.GetSmallInt() - if !ok { - t.Errorf("v.GetSmallInt() not successeded") - } - if val != -35132 { - t.Errorf("val != -35132, got %v", val) - } - }, - }, - { - name: "unmarshal big int", - filename: "simple", - cell: "b5ee9c7241010101001900002dfffffffffffffffffffffffffffffffffff99bfeac6423a6f0b50c", - t: Ty{ - SumType: "IntN", - IntN: &IntN{ - N: 183, - }, - }, - check: func(v Value) { - 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_UnmarshalSmallInt(t *testing.T) { + ty := Ty{ + SumType: "IntN", + IntN: &IntN{ + N: 24, }, - { - name: "unmarshal small uint", - filename: "simple", - cell: "b5ee9c7241010101000900000d00000000001d34e435eafd", - t: Ty{ - SumType: "UintN", - UintN: &UintN{ - N: 53, - }, - }, - check: func(v Value) { - val, ok := v.GetSmallUInt() - if !ok { - t.Errorf("v.GetSmallUInt() not successeded") - } - if val != 934 { - t.Errorf("val != 934, got %v", val) - } - }, + } + + 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, }, - { - name: "unmarshal big uint", - filename: "simple", - cell: "b5ee9c7241010101002300004100000000000000000000000000000000000000000000000000009fc4212a38ba40b11cce12", - t: Ty{ - SumType: "UintN", - UintN: &UintN{ - N: 257, - }, - }, - check: func(v Value) { - val, ok := v.GetBigInt() - if !ok { - t.Errorf("v.GetBigInt() not successeded") - } - if val.Cmp(big.NewInt(351329437643124)) != 0 { - t.Errorf("val != 351329437643124, got %v", val) - } - }, + } + + 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, }, - { - name: "unmarshal varint", - filename: "simple", - cell: "b5ee9c7241010101000600000730c98588449b6923", - t: Ty{ - SumType: "VarIntN", - VarIntN: &VarIntN{ - N: 16, - }, - }, - check: func(v Value) { - val, ok := v.GetBigInt() - if !ok { - t.Errorf("v.GetBigInt() not successeded") - } - if val.Cmp(big.NewInt(825432)) != 0 { - t.Errorf("val != 825432, got %v", val) - } - }, + } + + 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, }, - { - name: "unmarshal varuint", - filename: "simple", - cell: "b5ee9c7241010101000800000b28119ab36b44d3a86c0f", - t: Ty{ - SumType: "VarUintN", - VarUintN: &VarUintN{ - N: 32, - }, - }, - check: func(v Value) { - val, ok := v.GetBigInt() - if !ok { - t.Errorf("v.GetBigInt() not successeded") - } - if val.Cmp(big.NewInt(9451236712)) != 0 { - t.Errorf("val != 9451236712, got %v", val) - } - }, + } + + 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, }, - { - name: "unmarshal bits", - filename: "simple", - cell: "b5ee9c7241010101000500000631323318854035", - t: Ty{ - SumType: "BitsN", - BitsN: &BitsN{ - N: 24, - }, - }, - check: func(v Value) { - 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) - } - }, + } + + 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, }, - { - name: "unmarshal coins", - filename: "simple", - cell: "b5ee9c72410101010007000009436ec6e0189ebbd7f4", - t: Ty{ - SumType: "Coins", - Coins: &Coins{}, - }, - check: func(v Value) { - val, ok := v.GetBigInt() - if !ok { - t.Errorf("v.GetBigInt() not successeded") - } - if val.Cmp(big.NewInt(921464321)) != 0 { - t.Errorf("val != 921464321, got %v", val) - } - }, + } + + 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, }, - { - name: "unmarshal bool", - filename: "simple", - cell: "b5ee9c7241010101000300000140f6d24034", - t: Ty{ - SumType: "Bool", - Bool: &Bool{}, - }, - check: func(v Value) { - val, ok := v.GetBool() - if !ok { - t.Errorf("v.GetBool() not successeded") - } - if val { - t.Error("val is true") - } + } + + 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{}, }, }, - { - name: "unmarshal cell", - filename: "simple", - cell: "b5ee9c724101020100090001000100080000007ba52a3292", - t: Ty{ + } + + 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{}, }, - check: func(v Value) { - 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) - } + }, + } + + 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, + }, }, }, - { - name: "unmarshal remaining", - filename: "simple", - cell: "b5ee9c7241010101000900000dc0800000000ab8d04726e4", - t: Ty{ + } + + 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{}, }, - check: func(v Value) { - val, ok := v.GetCell() - 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) - } - }, - }, - { - name: "unmarshal address", - filename: "simple", - cell: "b5ee9c7241010101002400004380107bfaaa5cc6e5368e5f9799188bd798cd22e04ab16d1d8ea4fc37480741e6351064a3e1a6", - t: Ty{ - SumType: "Address", - Address: &Address{}, - }, - check: func(v Value) { - 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()) - } - }, - }, - { - name: "unmarshal not exists optional address", - filename: "simple", - cell: "b5ee9c724101010100030000012094418655", - t: Ty{ - SumType: "AddressOpt", - AddressOpt: &AddressOpt{}, - }, - check: func(v Value) { - val, ok := v.GetOptionalAddress() - if !ok { - t.Errorf("v.GetOptionalAddress() not successeded") - } - - if val.SumType != "NoneAddress" { - t.Errorf("val.GetAddress() != none address") - } - }, - }, - { - name: "unmarshal exists optional address", - filename: "simple", - cell: "b5ee9c7241010101002400004380107bfaaa5cc6e5368e5f9799188bd798cd22e04ab16d1d8ea4fc37480741e6351064a3e1a6", - t: Ty{ - SumType: "AddressOpt", - AddressOpt: &AddressOpt{}, - }, - check: func(v Value) { - 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()) - } - }, - }, - { - name: "unmarshal external address", - filename: "simple", - cell: "b5ee9c7241010101000600000742082850fcbd94fd", - t: Ty{ - SumType: "AddressExt", - AddressExt: &AddressExt{}, - }, - check: func(v Value) { - 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()) - } - }, - }, - { - name: "unmarshal none any address", - filename: "simple", - cell: "b5ee9c724101010100030000012094418655", - t: Ty{ - SumType: "AddressAny", - AddressAny: &AddressAny{}, - }, - check: func(v Value) { - val, ok := v.GetAnyAddress() - if !ok { - t.Errorf("v.GetAnyAddress() not successeded") - } - if val.SumType != "NoneAddress" { - t.Errorf("val.GetAddress() != none address") - } - }, - }, - { - name: "unmarshal internal any address", - filename: "simple", - cell: "b5ee9c7241010101002400004380107bfaaa5cc6e5368e5f9799188bd798cd22e04ab16d1d8ea4fc37480741e6351064a3e1a6", - t: Ty{ - SumType: "AddressAny", - AddressAny: &AddressAny{}, - }, - check: func(v Value) { - 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()) - } - }, - }, - { - name: "unmarshal external any address", - filename: "simple", - cell: "b5ee9c7241010101000600000742082850fcbd94fd", - t: Ty{ - SumType: "AddressAny", - AddressAny: &AddressAny{}, - }, - check: func(v Value) { - 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()) - } - }, }, - { - name: "unmarshal var any address", - filename: "simple", - cell: "b5ee9c7241010101000900000dc0800000000ab8d04726e4", - t: Ty{ - SumType: "AddressAny", - AddressAny: &AddressAny{}, - }, - check: func(v Value) { - 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()) - } + } + + 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{}, }, }, - { - name: "unmarshal not exists nullable", - filename: "simple", - cell: "b5ee9c7241010101000300000140f6d24034", - t: Ty{ - SumType: "Nullable", - Nullable: &Nullable{ - Inner: Ty{ - SumType: "Remaining", - Remaining: &Remaining{}, - }, + } + + 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, }, }, - check: func(v Value) { - val, ok := v.GetOptionalValue() - if !ok { - t.Errorf("v.GetOptionalValue() not successeded") - } - if val.IsExists { - t.Errorf("v.GetOptionalValue() is exists") - } - }, }, - { - name: "unmarshal exists nullable", - filename: "simple", - cell: "b5ee9c7241010201000b000101c001000900000c0ae007880db9", - t: Ty{ - SumType: "Nullable", - Nullable: &Nullable{ - Inner: Ty{ - SumType: "Cell", - Cell: &Cell{}, + } + + 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, }, }, - }, - check: func(v Value) { - 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) - } - }, - }, - { - name: "unmarshal ref", - filename: "simple", - cell: "b5ee9c7241010201000e000100010011000000000009689e40e150b4c5", - t: Ty{ - SumType: "CellOf", - CellOf: &CellOf{ - Inner: Ty{ - SumType: "IntN", - IntN: &IntN{ - N: 65, - }, - }, + { + SumType: "Bool", + Bool: &Bool{}, }, - }, - check: func(v Value) { - 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()) - } - }, - }, - { - name: "unmarshal empty tensor", - filename: "simple", - cell: "b5ee9c724101010100020000004cacb9cd", - t: Ty{ - SumType: "Tensor", - Tensor: &Tensor{}, - }, - check: func(v Value) { - val, ok := v.GetTensor() - if !ok { - t.Errorf("v.GetTensor() not successeded") - } - - if len(val) != 0 { - t.Errorf("v.GetTensor() != empty") - } - }, - }, - { - name: "unmarshal tensor", - filename: "simple", - cell: "b5ee9c7241010101001f00003900000000000000000000000000021cb43b9aca00fffd550bfbaae07401a2a98117", - t: Ty{ - SumType: "Tensor", - Tensor: &Tensor{ - Items: []Ty{ - { - SumType: "UintN", - UintN: &UintN{ - N: 123, + { + SumType: "Coins", + Coins: &Coins{}, + }, + { + SumType: "Tensor", + Tensor: &Tensor{ + Items: []Ty{ + { + SumType: "IntN", + IntN: &IntN{ + N: 23, + }, }, - }, - { - SumType: "Bool", - Bool: &Bool{}, - }, - { - SumType: "Coins", - Coins: &Coins{}, - }, - { - SumType: "Tensor", - Tensor: &Tensor{ - Items: []Ty{ - { + { + SumType: "Nullable", + Nullable: &Nullable{ + Inner: Ty{ SumType: "IntN", IntN: &IntN{ - N: 23, - }, - }, - { - SumType: "Nullable", - Nullable: &Nullable{ - Inner: Ty{ - SumType: "IntN", - IntN: &IntN{ - N: 2, - }, - }, + N: 2, }, }, }, }, }, - { - SumType: "VarIntN", - VarIntN: &VarIntN{ - N: 32, - }, - }, }, }, - }, - check: func(v Value) { - val, ok := v.GetTensor() - if !ok { - t.Errorf("v.GetTensor() not successeded") - } - - val0, ok := val[0].GetBigInt() - if !ok { - t.Errorf("val[0].GetBigInt() not successeded") - } - if val0.Cmp(big.NewInt(4325)) != 0 { - t.Errorf("val[0].GetBigInt() != 4325, got %v", val0.String()) - } - - val1, ok := val[1].GetBool() - if !ok { - t.Errorf("val[1].GetBigInt() not successeded") - } - if !val1 { - t.Error("val[1].GetBool() is false") - } - - val2, ok := val[2].GetBigInt() - if !ok { - t.Errorf("val[2].GetBigInt() not successeded") - } - if val2.Cmp(big.NewInt(1_000_000_000)) != 0 { - t.Errorf("val[2].GetBigInt() != 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].GetBigInt() - if !ok { - t.Errorf("val[4].GetBigInt() not successeded") - } - if val4.Cmp(big.NewInt(-9_304_000_000)) != 0 { - t.Errorf("val[4].GetBigInt() != -9304000000, got %v", val4.String()) - } + { + SumType: "VarIntN", + VarIntN: &VarIntN{ + N: 32, + }, + }, }, }, - //{ - // name: "unmarshal empty tuple", - // filename: "simple", - // t: Ty{ - // SumType: "TupleWith", - // TupleWith: &TupleWith{}, - // }, - // check: func(v Value) { - // val, ok := v.GetTupleValues() - // if !ok { - // t.Errorf("v.GetTupleValues() not successeded") - // } - // - // if len(val) != 0 { - // t.Errorf("v.GetTupleValues() != empty") - // } - // }, - //}, - //{ - // name: "unmarshal tuple", - // filename: "simple", - // t: Ty{ - // SumType: "TupleWith", - // TupleWith: &TupleWith{ - // Items: []Ty{ - // { - // SumType: "Nullable", - // Nullable: &Nullable{ - // Inner: Ty{ - // SumType: "CellOf", - // CellOf: &CellOf{ - // Inner: Ty{ - // SumType: "IntN", - // IntN: &IntN{ - // N: 1, - // }, - // }, - // }, - // }, - // }, - // }, - // { - // SumType: "TupleWith", - // TupleWith: &TupleWith{ - // Items: []Ty{ - // { - // SumType: "UintN", - // UintN: &UintN{ - // N: 1, - // }, - // }, - // { - // SumType: "Tensor", - // Tensor: &Tensor{ - // Items: []Ty{ - // { - // SumType: "CellOf", - // CellOf: &CellOf{ - // Inner: Ty{ - // SumType: "Cell", - // Cell: &Cell{}, - // }, - // }, - // }, - // }, - // }, - // }, - // }, - // }, - // }, - // }, - // }, - // }, - // check: func(v Value) { - // val, ok := v.GetTupleValues() - // if !ok { - // t.Errorf("v.GetTupleValues() not successeded") - // } - // - // val0, ok := val[0].GetOptionalValue() - // if !ok { - // t.Errorf("val[0].GetOptionalValue() not successeded") - // } - // if !val0.IsExists { - // t.Errorf("val[0].GetOptionalValue() != exists") - // } - // val0Ref, ok := val0.Val.GetRefValue() - // if !ok { - // t.Errorf("val[0].GetOptionalValue().GetRefValue() not successeded") - // } - // val0RefVal, ok := val0Ref.GetSmallInt() - // if !ok { - // t.Errorf("val[0].GetOptionalValue().GetRefValue().GetSmallInt() not successeded") - // } - // if val0RefVal != -1 { - // t.Errorf("val[0].GetOptionalValue().GetRefValue().GetSmallInt() != -1, got %v", val0RefVal) - // } - // - // val1, ok := val[1].GetTupleValues() - // if !ok { - // t.Errorf("val[1].GetTupleValues() not successeded") - // } - // - // val10, ok := val1[0].GetSmallUInt() - // if !ok { - // t.Errorf("val[1][0].GetSmallUInt() not successeded") - // } - // if val10 != 1 { - // t.Errorf("val[1][0].GetSmallUInt() != 1, got %v", val0RefVal) - // } - // - // val11, ok := val1[1].GetTensor() - // if !ok { - // t.Errorf("val[1][1].GetTensor() not successeded") - // } - // - // val110Ref, ok := val11[0].GetRefValue() - // if !ok { - // t.Errorf("val[1][1][0].GetRefValue() not successeded") - // } - // val110, ok := val110Ref.GetCell() - // if !ok { - // t.Errorf("val[1][1][0].GetRefValue().GetCell() not successeded") - // } - // hs, err := val110.HashString() - // if err != nil { - // t.Fatal(err) - // } - // if hs != "123" { - // t.Errorf("val[1][1][0].GetHash() != 123, got %v", hs) - // } - // }, - //}, - { - name: "unmarshal int-key map", - filename: "simple", - cell: "b5ee9c7241010201000c000101c001000ba00000007bc09a662c32", - t: Ty{ - SumType: "Map", - Map: &Map{ - K: Ty{ - SumType: "IntN", - IntN: &IntN{ - N: 32, - }, - }, - V: Ty{ - SumType: "Bool", - Bool: &Bool{}, - }, + } + + 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, }, }, - check: func(v Value) { - 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") - } + V: Ty{ + SumType: "Bool", + Bool: &Bool{}, }, }, - { - name: "unmarshal uint-key map", - filename: "simple", - cell: "b5ee9c72410104010053000101c0010202cb02030045a7400b113a994b5024a16719f69139328eb759596c38a25f59028b146fecdc3621dfe80045a3cff5555555555555555555555555555555555555555555555555555555555555555888440ce8", - t: Ty{ - SumType: "Map", - Map: &Map{ - K: Ty{ - SumType: "UintN", - UintN: &UintN{ - N: 16, - }, - }, - V: Ty{ - SumType: "Address", - Address: &Address{}, - }, + } + + 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, }, }, - check: func(v Value) { - 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") - } + V: Ty{ + SumType: "Address", + Address: &Address{}, }, }, - { - name: "unmarshal bigint-key map", - filename: "simple", - cell: "b5ee9c7241010301001a000101c0010115a70000000000000047550902000b000000001ab01d5bf1a9", - t: Ty{ - SumType: "Map", - Map: &Map{ - K: Ty{ - SumType: "UintN", - UintN: &UintN{ - N: 78, - }, - }, - V: Ty{ - SumType: "Cell", - Cell: &Cell{}, - }, + } + + 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, }, }, - check: func(v Value) { - val, ok := v.GetMap() - if !ok { - t.Errorf("v.GetMap() not successeded") - } - val1, ok := val.GetByBigInt(BigInt(*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") - } + V: Ty{ + SumType: "Cell", + Cell: &Cell{}, }, }, - { - name: "unmarshal bits-key map", - filename: "simple", - cell: "b5ee9c7241010301003b000101c0010106a0828502005ea0000000000000003e400b113a994b5024a16719f69139328eb759596c38a25f59028b146fecdc3621dfe43b9aca00b89cdc86", - t: Ty{ + } + + 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: "BitsN", - BitsN: &BitsN{ - N: 16, + SumType: "IntN", + IntN: &IntN{ + N: 64, }, }, V: Ty{ - SumType: "Map", - Map: &Map{ - K: Ty{ - SumType: "IntN", - IntN: &IntN{ - N: 64, + SumType: "Tensor", + Tensor: &Tensor{ + Items: []Ty{ + { + SumType: "Address", + Address: &Address{}, }, - }, - V: Ty{ - SumType: "Tensor", - Tensor: &Tensor{ - Items: []Ty{ - { - SumType: "Address", - Address: &Address{}, - }, - { - SumType: "Coins", - Coins: &Coins{}, - }, - }, + { + SumType: "Coins", + Coins: &Coins{}, }, }, }, }, }, }, - check: func(v Value) { - 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].GetBigInt() - if !ok { - t.Errorf("val[{97, 98}][124][1].GetBigInt() not successeded") - } - if val1_124Val1.Cmp(big.NewInt(1_000_000_000)) != 0 { - t.Errorf("val[{97, 98}][124][1].GetBigInt() != 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") - } - }, }, - { - name: "unmarshal address-key map", - filename: "simple", - cell: "b5ee9c7241010201002f000101c0010051a17002c44ea652d4092859c67da44e4ca3add6565b0e2897d640a2c51bfb370d8877f9409502f9002016fdc16e", - t: Ty{ - SumType: "Map", - Map: &Map{ - K: Ty{ - SumType: "Address", - Address: &Address{}, - }, - V: Ty{ - 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{}, }, - check: func(v Value) { - 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.GetBigInt() - 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") - } + V: Ty{ + SumType: "Coins", + Coins: &Coins{}, }, }, - { - name: "unmarshal union with dec prefix", - filename: "simple", - cell: "b5ee9c7241010101001300002180000000000000000000000003b5577dc0660d6029", - t: Ty{ - SumType: "Union", - Union: &Union{ - Variants: []UnionVariant{ - { - PrefixStr: "0", - PrefixLen: 1, - PrefixEatInPlace: true, - VariantTy: Ty{ - SumType: "IntN", - IntN: &IntN{ - N: 16, - }, - }, + } + + 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, - }, - }, + }, + }, + { + PrefixStr: "1", + PrefixLen: 1, + PrefixEatInPlace: true, + VariantTy: Ty{ + SumType: "IntN", + IntN: &IntN{ + N: 128, }, }, }, }, - check: func(v Value) { - 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()) - } - }, }, - { - name: "unmarshal union with bin prefix", - filename: "bin_union", - cell: "b5ee9c7241010201002e0001017801004fa17002c44ea652d4092859c67da44e4ca3add6565b0e2897d640a2c51bfb370d8877f900a4d89920c413c650", - t: Ty{ - SumType: "Union", - Union: &Union{ - Variants: []UnionVariant{ - { - PrefixStr: "0b001", - PrefixLen: 3, - VariantTy: Ty{ - SumType: "StructRef", - StructRef: &StructRef{ - StructName: "AddressWithPrefix", - }, - }, + } + + 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: "0b011", + PrefixLen: 3, + VariantTy: Ty{ + SumType: "StructRef", + StructRef: &StructRef{ + StructName: "MapWithPrefix", }, - { - PrefixStr: "0b111", - PrefixLen: 3, - VariantTy: Ty{ - SumType: "StructRef", - StructRef: &StructRef{ - StructName: "CellWithPrefix", - }, - }, + }, + }, + { + PrefixStr: "0b111", + PrefixLen: 3, + VariantTy: Ty{ + SumType: "StructRef", + StructRef: &StructRef{ + StructName: "CellWithPrefix", }, }, }, }, - check: func(v Value) { - 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.GetBigInt() - if !ok { - t.Errorf("val.GetMap()[\"EQCxE6mUtQJKFnGfaROTKOt1lZbDiiX1kCixRv7Nw2Id_sDs\"].GetBigInt() not successeded") - } - if mapCoins.Cmp(big.NewInt(43213412)) != 0 { - t.Errorf("val.GetMap()[\"EQCxE6mUtQJKFnGfaROTKOt1lZbDiiX1kCixRv7Nw2Id_sDs\"] != 43213412, got %v", mapCoins.String()) - } - }, }, - { - name: "unmarshal union with hex prefix", - filename: "hex_union", - cell: "b5ee9c7241010101000b000011deadbeef00000000c0d75977b9", - t: Ty{ - SumType: "Union", - Union: &Union{ - Variants: []UnionVariant{ - { - PrefixStr: "0x12345678", - PrefixLen: 32, - VariantTy: Ty{ - SumType: "StructRef", - StructRef: &StructRef{ - StructName: "UInt66WithPrefix", - }, - }, + } + + 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: "0xdeadbeef", + PrefixLen: 32, + VariantTy: Ty{ + SumType: "StructRef", + StructRef: &StructRef{ + StructName: "UInt33WithPrefix", }, - { - PrefixStr: "0x89abcdef", - PrefixLen: 32, - VariantTy: Ty{ - SumType: "StructRef", - StructRef: &StructRef{ - StructName: "UInt4WithPrefix", - }, - }, + }, + }, + { + PrefixStr: "0x89abcdef", + PrefixLen: 32, + VariantTy: Ty{ + SumType: "StructRef", + StructRef: &StructRef{ + StructName: "UInt4WithPrefix", }, }, }, }, - check: func(v Value) { - 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) - } - }, }, - { - name: "unmarshal a lot refs from alias", - filename: "refs", - cell: "b5ee9c724101040100b7000377deadbeef80107bfaaa5cc6e5368e5f9799188bd798cd22e04ab16d1d8ea4fc37480741e635087735940143ffffffffffffffffffffffffffff63c006010203004b80010df454cebee868f611ba8c0d4a9371fb73105396505783293a7625f75db3b9880bebc20100438006e05909e22b2e5e6087533314ee56505f85212914bd5547941a2a658ac62fe101004f801622753296a04942ce33ed2272651d6eb2b2d87144beb2051628dfd9b86c43bfcc12309ce54001e09a48b8", - t: Ty{ - SumType: "AliasRef", - AliasRef: &AliasRef{ - AliasName: "GoodNamingForMsg", - }, - }, - check: func(v Value) { - currStruct, ok := v.GetStruct() - if !ok { - t.Fatalf("struct not found") - } - pref, ok := currStruct.GetStructPrefix() - 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") - } - user1Val, ok := user1.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.GetBigInt() - if !ok { - t.Fatalf("currStruct[user1][balance].GetBigInt() not successeded") - } - if user1BalanceVal.Cmp(big.NewInt(1_000_000_000)) != 0 { - t.Errorf("currStruct[user1][balance].ToRaw() != 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") - } - user2Val, ok := user2Ref.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.GetBigInt() - if !ok { - t.Fatalf("currStruct[user2][balance].GetBigInt() not successeded") - } - if user2BalanceVal.Cmp(big.NewInt(100_000_000)) != 0 { - t.Errorf("currStruct[user2][balance].ToRaw() != 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.GetBigInt() - if !ok { - t.Fatalf("currStruct[user5][balance].GetBigInt() not successeded") - } - if user5BalanceVal.Cmp(big.NewInt(10_000_000_000_000)) != 0 { - t.Errorf("currStruct[user5][balance].ToRaw() != 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) - } - }, + } + + 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", }, - { - name: "unmarshal a lot refs from struct", - filename: "refs", - cell: "b5ee9c724101040100b7000377deadbeef80107bfaaa5cc6e5368e5f9799188bd798cd22e04ab16d1d8ea4fc37480741e635087735940143ffffffffffffffffffffffffffff63c006010203004b80010df454cebee868f611ba8c0d4a9371fb73105396505783293a7625f75db3b9880bebc20100438006e05909e22b2e5e6087533314ee56505f85212914bd5547941a2a658ac62fe101004f801622753296a04942ce33ed2272651d6eb2b2d87144beb2051628dfd9b86c43bfcc12309ce54001e09a48b8", - t: Ty{ - SumType: "StructRef", - StructRef: &StructRef{ - StructName: "ManyRefsMsg", - }, - }, - check: func(v Value) { - currStruct, ok := v.GetStruct() - if !ok { - t.Fatalf("struct not found") - } - pref, ok := currStruct.GetStructPrefix() - 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") - } - user1Val, ok := user1.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.GetBigInt() - if !ok { - t.Fatalf("currStruct[user1][balance].GetBigInt() not successeded") - } - if user1BalanceVal.Cmp(big.NewInt(1_000_000_000)) != 0 { - t.Errorf("currStruct[user1][balance].ToRaw() != 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") - } - user2Val, ok := user2Ref.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.GetBigInt() - if !ok { - t.Fatalf("currStruct[user2][balance].GetBigInt() not successeded") - } - if user2BalanceVal.Cmp(big.NewInt(100_000_000)) != 0 { - t.Errorf("currStruct[user2][balance].ToRaw() != 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.GetBigInt() - if !ok { - t.Fatalf("currStruct[user5][balance].GetBigInt() not successeded") - } - if user5BalanceVal.Cmp(big.NewInt(10_000_000_000_000)) != 0 { - t.Errorf("currStruct[user5][balance].ToRaw() != 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) - } - }, + } + + 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", }, - { - name: "unmarshal a lot generics with struct", - filename: "generics", - cell: "b5ee9c72410103010043000217d017d7840343b9aca0000108010200080000007b005543b9aca001017d78402005889d4ca5a81250b38cfb489c99475bacacb61c512fac81458a37f66e1b10eff422fc7647", - t: Ty{ - SumType: "StructRef", - StructRef: &StructRef{ - StructName: "ManyRefsMsg", - TypeArgs: []Ty{ - { - SumType: "UintN", - UintN: &UintN{ - N: 16, - }, - }, + } + + 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, }, }, }, - check: func(v Value) { - 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") - } - payloadVal, ok := payload.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") - } - eitherUnion, ok := either.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") - } - eitherVal, ok := eitherV.GetBigInt() - if !ok { - t.Fatalf("currStruct[either][value].GetBigInt() not successeded") - } - if eitherVal.Cmp(big.NewInt(100000000)) != 0 { - t.Fatalf("currStruct[either][value].GetBigInt() != 1000000000, got %v", eitherVal.String()) - } - - anotherEither, ok := currStruct.GetField("anotherEither") - if !ok { - t.Fatalf("currStruct[anotherEither] not found") - } - anotherEitherUnion, ok := anotherEither.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") - } - anotherEitherVal, ok := anotherEitherV.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].GetBigInt() - if !ok { - t.Fatalf("currStruct[anotherEither][value][0].GetBigInt() not successeded") - } - if anotherEitherValCoins.Cmp(big.NewInt(1_000_000_000)) != 0 { - t.Fatalf("currStruct[anotherEither][value][0].GetBigInt() != 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") - } - doublerTensor, ok := doublerRef.GetTensor() - if !ok { - t.Fatalf("currStruct[doubler].GetTensor() not successeded") - } - - doublerTensor0, ok := doublerTensor[0].GetTensor() - if !ok { - t.Fatalf("currStruct[doubler][0] not successeded") - } - doublerTensor0Coins, ok := doublerTensor0[0].GetBigInt() - if !ok { - t.Fatalf("currStruct[doubler][0][0].GetBigInt() 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") - } - - doublerTensor1, ok := doublerTensor[1].GetTensor() - if !ok { - t.Fatalf("currStruct[doubler][1] not successeded") - } - doublerTensor1Coins, ok := doublerTensor1[0].GetBigInt() - if !ok { - t.Fatalf("currStruct[doubler][1][0].GetBigInt() not successeded") - } - if doublerTensor1Coins.Cmp(big.NewInt(100_000_000)) != 0 { - t.Fatalf("currStruct[doubler][1][0].GetBigInt() != 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") - } - myValVal, ok := myVal.GetSmallUInt() - if !ok { - t.Fatalf("currStruct[myVal].GetSmallUInt() not successed") - } - if myValVal != 16 { - t.Fatalf("currStruct[myVal] != 16, got %v", myValVal) - } - }, }, - { - name: "unmarshal a lot generics with alias", - filename: "generics", - cell: "b5ee9c72410103010043000217d017d7840343b9aca0000108010200080000007b005543b9aca001017d78402005889d4ca5a81250b38cfb489c99475bacacb61c512fac81458a37f66e1b10eff422fc7647", - t: 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_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, }, }, }, - check: func(v Value) { - 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") - } - payloadVal, ok := payload.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") - } - eitherUnion, ok := either.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") - } - eitherVal, ok := eitherV.GetBigInt() - if !ok { - t.Fatalf("currStruct[either][value].GetBigInt() not successeded") - } - if eitherVal.Cmp(big.NewInt(100000000)) != 0 { - t.Fatalf("currStruct[either][value].GetBigInt() != 1000000000, got %v", eitherVal.String()) - } - - anotherEither, ok := currStruct.GetField("anotherEither") - if !ok { - t.Fatalf("currStruct[anotherEither] not found") - } - anotherEitherUnion, ok := anotherEither.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") - } - anotherEitherVal, ok := anotherEitherV.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].GetBigInt() - if !ok { - t.Fatalf("currStruct[anotherEither][value][0].GetBigInt() not successeded") - } - if anotherEitherValCoins.Cmp(big.NewInt(1_000_000_000)) != 0 { - t.Fatalf("currStruct[anotherEither][value][0].GetBigInt() != 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") - } - doublerTensor, ok := doublerRef.GetTensor() - if !ok { - t.Fatalf("currStruct[doubler].GetTensor() not successeded") - } - - doublerTensor0, ok := doublerTensor[0].GetTensor() - if !ok { - t.Fatalf("currStruct[doubler][0] not successeded") - } - doublerTensor0Coins, ok := doublerTensor0[0].GetBigInt() - if !ok { - t.Fatalf("currStruct[doubler][0][0].GetBigInt() 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") - } - - doublerTensor1, ok := doublerTensor[1].GetTensor() - if !ok { - t.Fatalf("currStruct[doubler][1] not successeded") - } - doublerTensor1Coins, ok := doublerTensor1[0].GetBigInt() - if !ok { - t.Fatalf("currStruct[doubler][1][0].GetBigInt() not successeded") - } - if doublerTensor1Coins.Cmp(big.NewInt(100_000_000)) != 0 { - t.Fatalf("currStruct[doubler][1][0].GetBigInt() != 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") - } - myValVal, ok := myVal.GetSmallUInt() - if !ok { - t.Fatalf("currStruct[myVal].GetSmallUInt() not successed") - } - if myValVal != 16 { - t.Fatalf("currStruct[myVal] != 16, got %v", myValVal) - } - }, }, - { - name: "unmarshal a struct with default values", - filename: "default_values", - cell: "b5ee9c7241010101003100005d80000002414801622753296a04942ce33ed2272651d6eb2b2d87144beb2051628dfd9b86c43bfd00000156ac2c4c70811a9dde", - t: Ty{ - SumType: "StructRef", - StructRef: &StructRef{ - StructName: "DefaultTest", - }, - }, - check: func(v Value) { - 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") - } - num2Val, ok := num2.Val.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.GetCell() - if !ok { - t.Fatalf("currStruct[slice3].GetCell() not successeded") - } - hs, err := slice3Val.HashString() - if err != nil { - t.Fatal(err) - } - if hs != "55e960f1409af0d7670e382c61276a559fa9330185984d91faffebf32d5fa383" { - t.Fatalf("currStruct[slice3].GetCell().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") - } - }, + } + + 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", }, - { - name: "unmarshal numbers", - filename: "numbers", - cell: "b5ee9c72410101010033000062000000000000000000000000000000000000000000000000000000000000000000000000000000f1106aecc4c800020926dc62f014", - t: Ty{ - SumType: "StructRef", - StructRef: &StructRef{ - StructName: "Numbers", - }, - }, - check: func(v Value) { - 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.GetBigInt() - if !ok { - t.Fatalf("num3.GetBigInt() 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.GetBigInt() - if !ok { - t.Fatalf("num4.GetSmallUInt() 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.GetBigInt() - if !ok { - t.Fatalf("num9.GetSmallInt() not successeded") - } - if val9.Cmp(big.NewInt(2342)) != 0 { - t.Fatalf("num9 != 2342, got %s", val9.String()) - } - }, + } + + 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", }, - { - name: "unmarshal random fields", - filename: "random_fields", - cell: "b5ee9c7241010301007800028b79480107bfaaa5cc6e5368e5f9799188bd798cd22e04ab16d1d8ea4fc37480741e6350e038d7eb37c5e80000000ab50ee6b28000000000000016e4c000006c175300001801bc01020001c00051000000000005120041efeaa9731b94da397e5e64622f5e63348b812ac5b4763a93f0dd201d0798d4409e337ceb", - t: Ty{ - SumType: "StructRef", - StructRef: &StructRef{ - StructName: "RandomFields", - }, - }, - check: func(v Value) { - addr := ton.MustParseAccountID("UQCD39VS5jcptHL8vMjEXrzGaRcCVYto7HUn4bpAOg8xqEBI") - - currStruct, ok := v.GetStruct() - if !ok { - t.Fatalf("struct not found") - } - pref, ok := currStruct.GetStructPrefix() - 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.GetBigInt() - if !ok { - t.Fatalf("amount.GetBigInt() 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.GetBigInt() - if !ok { - t.Fatalf("intVector[1].GetOptionalValue().GetBigInt() not successeded") - } - if val2.Cmp(big.NewInt(1000000000)) != 0 { - t.Fatalf("intVector[1].GetOptionalValue().GetBigInt() != 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") - } - myIntVal, ok := myInt.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) - } - }, + } + + 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", }, - } { - t.Run(c.name, func(t *testing.T) { - inputFilename := fmt.Sprintf("testdata/%s.json", c.filename) - 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) - } - - currCell, err := boc.DeserializeBocHex(c.cell) - if err != nil { - t.Fatal(err) - } - decoder := NewDecoder() - decoder.WithABI(abi) - val, err := decoder.UnmarshalTolk(currCell[0], c.t) - if err != nil { - t.Fatal(err) - } - c.check(*val) - }) + } + + 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 index 23780f76..86f292d3 100644 --- a/tolk/runtime_types.go +++ b/tolk/runtime_types.go @@ -5,17 +5,12 @@ package tolk import ( "bytes" "fmt" + "maps" "math/big" "github.com/tonkeeper/tongo/boc" ) -type TolkValue interface { - GetType() Ty - SetType(Ty) - SetValue(any) error -} - type SumType string type TolkPrefix struct { @@ -34,34 +29,8 @@ func (s *Struct) GetField(field string) (Value, bool) { return val, ok } -func (s *Struct) AddField(field string, v Value) bool { - if _, found := s.field[field]; found { - return false - } - - s.field[field] = v - return true -} - // SetField set new value only if types are the same func (s *Struct) SetField(field string, v Value) bool { - old, found := s.field[field] - if !found { - return false - } - if old.valType != v.valType { - return false - } - s.field[field] = v - return true -} - -// UpdateField set new value even if types mismatched -func (s *Struct) UpdateField(field string, v Value) bool { - _, found := s.field[field] - if !found { - return false - } s.field[field] = v return true } @@ -70,7 +39,7 @@ func (s *Struct) RemoveField(field string) { delete(s.field, field) } -func (s *Struct) GetStructPrefix() (TolkPrefix, bool) { +func (s *Struct) GetPrefix() (TolkPrefix, bool) { if !s.hasPrefix { return TolkPrefix{}, false } @@ -78,14 +47,35 @@ func (s *Struct) GetStructPrefix() (TolkPrefix, bool) { 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 { - valType Ty + 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 @@ -97,13 +87,11 @@ type Value struct { mp *MapValue structValue *Struct alias *AliasValue - generic *GenericValue enum *EnumValue + generic *GenericValue union *UnionValue -} - -func (v *Value) GetType() Ty { - return v.valType + null *NullValue + void *VoidValue } func (v *Value) GetBool() (bool, bool) { @@ -120,6 +108,13 @@ func (v *Value) GetSmallInt() (int64, bool) { 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 @@ -127,11 +122,32 @@ func (v *Value) GetSmallUInt() (uint64, bool) { return uint64(*v.smallUint), true } -func (v *Value) GetBigInt() (big.Int, bool) { - if v.bigInt == nil { +func (v *Value) GetBigUInt() (big.Int, bool) { + if v.bigUint == nil { return big.Int{}, false } - return big.Int(*v.bigInt), true + 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) { @@ -204,11 +220,18 @@ func (v *Value) GetStruct() (Struct, bool) { return *v.structValue, true } -func (v *Value) GetGeneric() (GenericValue, bool) { +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 GenericValue{}, false + return Value{}, false } - return *v.generic, true + return Value(*v.generic), true } func (v *Value) GetEnum() (EnumValue, bool) { @@ -239,332 +262,615 @@ func (v *Value) GetCell() (boc.Cell, bool) { return boc.Cell(*v.cell), true } -// todo: is good idea to use this method -func (v *Value) GetAny() (any, error) { - switch v.valType.SumType { - case "Int": - return v, fmt.Errorf("int is not supported") - case "NullLiteral": - return nil, nil - case "Void": - return nil, nil - case "IntN": - if i64, ok := v.GetSmallInt(); ok { - return Int64(i64), nil +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 } - if bi, ok := v.GetBigInt(); ok { - return BigInt(bi), nil + return v.bool.Equal(*otherValue.bool) + case "smallInt": + if otherValue.smallInt == nil { + return false } - return nil, fmt.Errorf("value is not a BigInt or Int64") - case "UintN": - if ui64, ok := v.GetSmallUInt(); ok { - return UInt64(ui64), nil + return v.smallInt.Equal(*otherValue.smallInt) + case "smallUint": + if otherValue.smallUint == nil { + return false } - if bi, ok := v.GetBigInt(); ok { - return BigInt(bi), nil + return v.smallUint.Equal(*otherValue.smallUint) + case "bigInt": + if otherValue.bigInt == nil { + return false } - return nil, fmt.Errorf("value is not a BigInt or UInt64") - case "VarIntN": - if bi, ok := v.GetBigInt(); ok { - return BigInt(bi), nil + return v.bigInt.Equal(*otherValue.bigInt) + case "bigUint": + if otherValue.bigUint == nil { + return false } - return nil, fmt.Errorf("value is not a BigInt") - case "VarUintN": - if bi, ok := v.GetBigInt(); ok { - return BigInt(bi), nil + return v.bigUint.Equal(*otherValue.bigUint) + case "varInt": + if otherValue.varInt == nil { + return false } - return nil, fmt.Errorf("value is not a BigInt") - case "BitsN": - if bits, ok := v.GetBits(); ok { - return Bits(bits), nil + return v.varInt.Equal(*otherValue.varInt) + case "varUint": + if otherValue.varUint == nil { + return false } - return nil, fmt.Errorf("value is not a Bits") - case "Coins": - if bi, ok := v.GetBigInt(); ok { - return BigInt(bi), nil + return v.varUint.Equal(*otherValue.varUint) + case "coins": + if otherValue.coins == nil { + return false } - return nil, fmt.Errorf("value is not a BigInt") - case "Bool": - if b, ok := v.GetBool(); ok { - return BoolValue(b), nil + return v.coins.Equal(*otherValue.coins) + case "bits": + if otherValue.bits == nil { + return false } - return nil, fmt.Errorf("value is not a Bool") - case "Cell": - if b, ok := v.GetCell(); ok { - return Any(b), nil + return v.bits.Equal(*otherValue.bits) + case "cell": + if otherValue.cell == nil { + return false } - return nil, fmt.Errorf("value is not an Any") - case "Slice": - if b, ok := v.GetCell(); ok { - return Any(b), nil + return v.cell.Equal(*otherValue.cell) + case "remaining": + if otherValue.remaining == nil { + return false } - return nil, fmt.Errorf("value is not an Any") - case "Builder": - if b, ok := v.GetCell(); ok { - return Any(b), nil + return v.remaining.Equal(*otherValue.remaining) + case "internalAddress": + if otherValue.internalAddress == nil { + return false } - return nil, fmt.Errorf("value is not an Any") - case "Callable": - if b, ok := v.GetCell(); ok { - return Any(b), nil + return v.internalAddress.Equal(*otherValue.internalAddress) + case "optionalAddress": + if otherValue.optionalAddress == nil { + return false } - return nil, fmt.Errorf("value is not an Any") - case "Remaining": - if b, ok := v.GetCell(); ok { - return Any(b), nil + return v.optionalAddress.Equal(*otherValue.optionalAddress) + case "externalAddress": + if otherValue.externalAddress == nil { + return false } - return nil, fmt.Errorf("value is not an Any") - case "Address": - if a, ok := v.GetAddress(); ok { - return a, nil + return v.externalAddress.Equal(*otherValue.externalAddress) + case "anyAddress": + if otherValue.anyAddress == nil { + return false } - return nil, fmt.Errorf("value is not an InternalAddress") - case "AddressOpt": - if a, ok := v.GetOptionalAddress(); ok { - return a, nil + return v.anyAddress.Equal(*otherValue.anyAddress) + case "optionalValue": + if otherValue.optionalValue == nil { + return false } - return nil, fmt.Errorf("value is not an OptionalAddress") - case "AddressExt": - if a, ok := v.GetExternalAddress(); ok { - return a, nil + return v.optionalValue.Equal(*otherValue.optionalValue) + case "refValue": + if otherValue.refValue == nil { + return false } - return nil, fmt.Errorf("value is not an ExternalAddress") - case "AddressAny": - if a, ok := v.GetAnyAddress(); ok { - return a, nil + return v.refValue.Equal(*otherValue.refValue) + case "tupleWith": + if otherValue.tupleWith == nil { + return false } - return nil, fmt.Errorf("value is not an AnyAddress") - case "Nullable": - if o, ok := v.GetOptionalValue(); ok { - return o, nil + return v.tupleWith.Equal(*otherValue.tupleWith) + case "tensor": + if otherValue.tensor == nil { + return false } - return nil, fmt.Errorf("value is not an OptionalValue") - case "CellOf": - if r, ok := v.GetRefValue(); ok { - return RefValue(r), nil + return v.tensor.Equal(*otherValue.tensor) + case "mp": + if otherValue.mp == nil { + return false } - return nil, fmt.Errorf("value is not a RefValue") - case "Tensor": - if t, ok := v.GetTensor(); ok { - return TensorValues(t), nil + return v.mp.Equal(*otherValue.mp) + case "structValue": + if otherValue.structValue == nil { + return false } - return nil, fmt.Errorf("value is not a Tensor") - case "TupleWith": - if t, ok := v.GetTupleValues(); ok { - return TupleValues(t), nil + return v.structValue.Equal(*otherValue.structValue) + case "alias": + if otherValue.alias == nil { + return false } - return nil, fmt.Errorf("value is not a Tuple") - case "TupleAny": - return nil, fmt.Errorf("tuple any is not supported") - case "Map": - if m, ok := v.GetMap(); ok { - return m, nil + return v.alias.Equal(*otherValue.alias) + case "enum": + if otherValue.enum == nil { + return false } - return nil, fmt.Errorf("value is not a Map") - case "EnumRef": - if e, ok := v.GetEnum(); ok { - return e, nil + return v.enum.Equal(*otherValue.enum) + case "generic": + if otherValue.generic == nil { + return false } - return nil, fmt.Errorf("value is not an Enum") - case "StructRef": - if s, ok := v.GetStruct(); ok { - return s, nil + return v.generic.Equal(*otherValue.generic) + case "union": + if otherValue.union == nil { + return false } - return nil, fmt.Errorf("value is not a Struct") - case "Union": - if u, ok := v.GetUnion(); ok { - return u, nil + 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 nil, fmt.Errorf("value is not an Union") + return v.void.Equal(*otherValue.void) default: - return nil, fmt.Errorf("unknown value type %v", v.valType.SumType) + return false } } -func (v *Value) SetType(t Ty) { - v.valType = t -} - -func (v *Value) SetValue(val any) error { - switch v.valType.SumType { - case "Int": - return v.valType.Int.SetValue(v, val) - case "NullLiteral": - return v.valType.NullLiteral.SetValue(v, val) - case "Void": - return v.valType.Void.SetValue(v, val) +func (v *Value) UnmarshalTolk(cell *boc.Cell, ty Ty, decoder *Decoder) error { + var err error + switch ty.SumType { case "IntN": - return v.valType.IntN.SetValue(v, val) + 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": - return v.valType.UintN.SetValue(v, val) + 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": - return v.valType.VarIntN.SetValue(v, val) + v.sumType = "varInt" + v.varInt = &VarInt{} + err = v.varInt.UnmarshalTolk(cell, *ty.VarIntN, decoder) case "VarUintN": - return v.valType.VarUintN.SetValue(v, val) + v.sumType = "varUint" + v.varUint = &VarUInt{} + err = v.varUint.UnmarshalTolk(cell, *ty.VarUintN, decoder) case "BitsN": - return v.valType.BitsN.SetValue(v, val) + 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": - return v.valType.Coins.SetValue(v, val) + v.sumType = "coins" + v.coins = &CoinsValue{} + err = v.coins.UnmarshalTolk(cell, *ty.Coins, decoder) case "Bool": - return v.valType.Bool.SetValue(v, val) + v.sumType = "bool" + def := BoolValue(false) + v.bool = &def + err = v.bool.UnmarshalTolk(cell, *ty.Bool, decoder) case "Cell": - return v.valType.Cell.SetValue(v, val) + v.sumType = "cell" + v.cell = &Any{} + err = v.cell.UnmarshalTolk(cell, *ty.Cell, decoder) case "Slice": - return v.valType.Slice.SetValue(v, val) + err = fmt.Errorf("slice not supported") case "Builder": - return v.valType.Builder.SetValue(v, val) + err = fmt.Errorf("builder not supported") case "Callable": - return v.valType.Callable.SetValue(v, val) + err = fmt.Errorf("callable not supported") case "Remaining": - return v.valType.Remaining.SetValue(v, val) + v.sumType = "remaining" + v.remaining = &RemainingValue{} + err = v.remaining.UnmarshalTolk(cell, *ty.Remaining, decoder) case "Address": - return v.valType.Address.SetValue(v, val) + v.sumType = "internalAddress" + v.internalAddress = &InternalAddress{} + err = v.internalAddress.UnmarshalTolk(cell, *ty.Address, decoder) case "AddressOpt": - return v.valType.AddressOpt.SetValue(v, val) + v.sumType = "optionalAddress" + v.optionalAddress = &OptionalAddress{} + err = v.optionalAddress.UnmarshalTolk(cell, *ty.AddressOpt, decoder) case "AddressExt": - return v.valType.AddressExt.SetValue(v, val) + v.sumType = "externalAddress" + v.externalAddress = &ExternalAddress{} + err = v.externalAddress.UnmarshalTolk(cell, *ty.AddressExt, decoder) case "AddressAny": - return v.valType.AddressAny.SetValue(v, val) + 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": - return v.valType.Nullable.SetValue(v, val) + o, ok := val.(OptValue) + if !ok { + return fmt.Errorf("cannot convert %v to OptValue", val) + } + v.optionalValue = &o case "CellOf": - return v.valType.CellOf.SetValue(v, val) + r, ok := val.(RefValue) + if !ok { + return fmt.Errorf("cannot convert %v to RefValue", val) + } + v.refValue = &r case "Tensor": - return v.valType.Tensor.SetValue(v, val) + t, ok := val.(TensorValues) + if !ok { + return fmt.Errorf("cannot convert %v to TensorValues", val) + } + v.tensor = &t case "TupleWith": - return v.valType.TupleWith.SetValue(v, val) - case "TupleAny": - return v.valType.TupleAny.SetValue(v, val) + t, ok := val.(TupleValues) + if !ok { + return fmt.Errorf("cannot convert %v to TupleValues", val) + } + v.tupleWith = &t case "Map": - return v.valType.Map.SetValue(v, val) + m, ok := val.(MapValue) + if !ok { + return fmt.Errorf("cannot convert %v to MapValue", val) + } + v.mp = &m case "EnumRef": - return v.valType.EnumRef.SetValue(v, val) + e, ok := val.(EnumValue) + if !ok { + return fmt.Errorf("cannot convert %v to EnumValue", val) + } + v.enum = &e case "StructRef": - return v.valType.StructRef.SetValue(v, val) + s, ok := val.(Struct) + if !ok { + return fmt.Errorf("cannot convert %v to Struct", val) + } + v.structValue = &s case "AliasRef": - return v.valType.AliasRef.SetValue(v, val) + a, ok := val.(AliasValue) + if !ok { + return fmt.Errorf("cannot convert %v to AliasValue", val) + } + v.alias = &a case "Generic": - return v.valType.Generic.SetValue(v, val) + g, ok := val.(GenericValue) + if !ok { + return fmt.Errorf("cannot convert %v to GenericValue", val) + } + v.generic = &g case "Union": - return v.valType.Union.SetValue(v, val) - default: - return fmt.Errorf("unknown t type %q", v.valType.SumType) - } -} - -func (v *Value) Equal(o Value) bool { - if v.valType != o.valType { - return false - } - switch v.valType.SumType { + u, ok := val.(UnionValue) + if !ok { + return fmt.Errorf("cannot convert %v to UnionValue", val) + } + v.union = &u case "Int": - return v.valType.Int.Equal(*v, o) - case "NullLiteral": - return v.valType.NullLiteral.Equal(*v, o) - case "Void": - return v.valType.Void.Equal(*v, o) - case "IntN": - return v.valType.IntN.Equal(*v, o) - case "UintN": - return v.valType.UintN.Equal(*v, o) - case "VarIntN": - return v.valType.VarIntN.Equal(*v, o) - case "VarUintN": - return v.valType.VarUintN.Equal(*v, o) - case "BitsN": - return v.valType.BitsN.Equal(*v, o) + return fmt.Errorf("int not supported") case "Coins": - return v.valType.Coins.Equal(*v, o) + c, ok := val.(CoinsValue) + if !ok { + return fmt.Errorf("cannot convert %v to CoinsValue", val) + } + v.coins = &c case "Bool": - return v.valType.Bool.Equal(*v, o) + b, ok := val.(BoolValue) + if !ok { + return fmt.Errorf("cannot convert %v to BoolValue", val) + } + v.bool = &b case "Cell": - return v.valType.Cell.Equal(*v, o) + a, ok := val.(Any) + if !ok { + return fmt.Errorf("cannot convert %v to Any", val) + } + v.cell = &a case "Slice": - return v.valType.Slice.Equal(*v, o) + return fmt.Errorf("slice not supported") case "Builder": - return v.valType.Builder.Equal(*v, o) + return fmt.Errorf("builder not supported") case "Callable": - return v.valType.Callable.Equal(*v, o) + return fmt.Errorf("callable not supported") case "Remaining": - return v.valType.Remaining.Equal(*v, o) + r, ok := val.(RemainingValue) + if !ok { + return fmt.Errorf("cannot convert %v to RemainingValue", val) + } + v.remaining = &r case "Address": - return v.valType.Address.Equal(*v, o) + i, ok := val.(InternalAddress) + if !ok { + return fmt.Errorf("cannot convert %v to InternalAddress", val) + } + v.internalAddress = &i case "AddressOpt": - return v.valType.AddressOpt.Equal(*v, o) + o, ok := val.(OptionalAddress) + if !ok { + return fmt.Errorf("cannot convert %v to OptionalAddress", val) + } + v.optionalAddress = &o case "AddressExt": - return v.valType.AddressExt.Equal(*v, o) + e, ok := val.(ExternalAddress) + if !ok { + return fmt.Errorf("cannot convert %v to ExternalAddress", val) + } + v.externalAddress = &e case "AddressAny": - return v.valType.AddressAny.Equal(*v, o) - case "Nullable": - return v.valType.Nullable.Equal(*v, o) - case "CellOf": - return v.valType.CellOf.Equal(*v, o) - case "Tensor": - return v.valType.Tensor.Equal(*v, o) - case "TupleWith": - return v.valType.TupleWith.Equal(*v, o) + a, ok := val.(AnyAddress) + if !ok { + return fmt.Errorf("cannot convert %v to AnyAddress", val) + } + v.anyAddress = &a case "TupleAny": - return v.valType.TupleAny.Equal(*v, o) - case "Map": - return v.valType.Map.Equal(*v, o) - case "EnumRef": - return v.valType.EnumRef.Equal(*v, o) - case "StructRef": - return v.valType.StructRef.Equal(*v, o) - case "AliasRef": - return v.valType.AliasRef.Equal(*v, o) - case "Generic": - return v.valType.Generic.Equal(*v, o) - case "Union": - return v.valType.Union.Equal(*v, o) + 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 false + 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 { +func (i *Int64) Equal(other any) bool { otherInt, ok := other.(Int64) if !ok { return false } - return i == otherInt + return *i == otherInt } type UInt64 uint64 -func (i UInt64) Equal(other any) bool { +func (i *UInt64) Equal(other any) bool { otherUint, ok := other.(UInt64) if !ok { return false } - return i == otherUint + return *i == otherUint } type BigInt big.Int -func (b BigInt) Equal(other any) bool { - otherBigInt, ok := other.(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) - return bi.Cmp(&otherBigInt) == 0 + 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 { +func (b *Bits) Equal(other any) bool { otherBits, ok := other.(Bits) if !ok { return false } - bs := boc.BitString(b) + bs := boc.BitString(*b) otherBs := boc.BitString(otherBits) return bytes.Equal(bs.Buffer(), otherBs.Buffer()) } @@ -573,20 +879,67 @@ 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 { - enumType Ty - Name string - Value big.Int + 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 { @@ -597,6 +950,27 @@ type AnyAddress struct { 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 { } @@ -605,20 +979,31 @@ type ExternalAddress struct { 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 { +func (i *InternalAddress) Equal(other any) bool { otherInternalAddress, ok := other.(InternalAddress) if !ok { return false } - return i == otherInternalAddress + return *i == otherInternalAddress } -func (i InternalAddress) ToRaw() string { +func (i *InternalAddress) ToRaw() string { return fmt.Sprintf("%v:%x", i.Workchain, i.Address) } @@ -628,22 +1013,101 @@ type VarAddress struct { 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 { - keyType Ty - valType Ty - keys []Value - values []Value - len int + 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) { @@ -658,7 +1122,7 @@ func (m *MapValue) Get(key MapKey) (Value, bool) { func (m *MapValue) GetBySmallInt(v Int64) (Value, bool) { key := MapKey{ - valType: m.keyType, + sumType: "smallInt", smallInt: &v, } return m.Get(key) @@ -666,7 +1130,7 @@ func (m *MapValue) GetBySmallInt(v Int64) (Value, bool) { func (m *MapValue) GetBySmallUInt(v UInt64) (Value, bool) { key := MapKey{ - valType: m.keyType, + sumType: "smallUint", smallUint: &v, } return m.Get(key) @@ -674,15 +1138,23 @@ func (m *MapValue) GetBySmallUInt(v UInt64) (Value, bool) { func (m *MapValue) GetByBigInt(v BigInt) (Value, bool) { key := MapKey{ - valType: m.keyType, + 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{ - valType: m.keyType, + sumType: "bits", bits: &v, } return m.Get(key) @@ -690,19 +1162,13 @@ func (m *MapValue) GetByBits(v Bits) (Value, bool) { func (m *MapValue) GetByInternalAddress(v InternalAddress) (Value, bool) { key := MapKey{ - valType: m.keyType, + sumType: "internalAddress", internalAddress: &v, } return m.Get(key) } func (m *MapValue) Set(key MapKey, value Value) (bool, error) { - if key.valType != m.keyType { - return false, fmt.Errorf("map key has type %v, got %v", m.keyType, key.valType) - } - if value.valType != m.valType { - return false, fmt.Errorf("map value has type %v, got %v", m.valType, value.valType) - } for i, k := range m.keys { if k.Equal(Value(key)) { m.values[i] = value @@ -717,70 +1183,48 @@ func (m *MapValue) Set(key MapKey, value Value) (bool, error) { } func (m *MapValue) SetBySmallInt(k Int64, value Value) (bool, error) { - if m.keyType.SumType != "IntN" { - return false, fmt.Errorf("map key has type %v, got int64", m.keyType) - } - if value.valType != m.valType { - return false, fmt.Errorf("map value has type %v, got %v", m.valType, value.valType) - } key := MapKey{ - valType: m.valType, + sumType: "smallInt", smallInt: &k, } return m.Set(key, value) } func (m *MapValue) SetBySmallUInt(k UInt64, value Value) (bool, error) { - if m.keyType.SumType != "UintN" { - return false, fmt.Errorf("map key has type %v, got int64", m.keyType) - } - if value.valType != m.valType { - return false, fmt.Errorf("map value has type %v, got %v", m.valType, value.valType) - } key := MapKey{ - valType: m.valType, + sumType: "smallUint", smallUint: &k, } return m.Set(key, value) } func (m *MapValue) SetByBigInt(k BigInt, value Value) (bool, error) { - if m.keyType.SumType != "IntN" && m.keyType.SumType != "UintN" && m.keyType.SumType != "VarIntN" && m.keyType.SumType != "VarUintN" { - return false, fmt.Errorf("map key has type %v, got BigInt", m.keyType) - } - if value.valType != m.valType { - return false, fmt.Errorf("map value has type %v, got %v", m.valType, value.valType) - } key := MapKey{ - valType: m.valType, + sumType: "bigInt", bigInt: &k, } return m.Set(key, value) } -func (m *MapValue) SetByBits(k Bits, value Value) (bool, error) { - if m.keyType.SumType != "BitsN" { - return false, fmt.Errorf("map key has type %v, got BitsN", m.keyType) - } - if value.valType != m.valType { - return false, fmt.Errorf("map value has type %v, got %v", m.valType, value.valType) +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{ - valType: m.valType, + sumType: "bits", bits: &k, } return m.Set(key, value) } func (m *MapValue) SetByInternalAddress(k InternalAddress, value Value) (bool, error) { - if m.keyType.SumType != "Address" { - return false, fmt.Errorf("map key has type %v, got Address", m.keyType) - } - if value.valType != m.valType { - return false, fmt.Errorf("map value has type %v, got %v", m.valType, value.valType) - } key := MapKey{ - valType: m.valType, + sumType: "internalAddress", internalAddress: &k, } return m.Set(key, value) @@ -798,7 +1242,7 @@ func (m *MapValue) Delete(key MapKey) { func (m *MapValue) DeleteBySmallInt(k Int64) { key := MapKey{ - valType: m.valType, + sumType: "smallInt", smallInt: &k, } m.Delete(key) @@ -806,7 +1250,7 @@ func (m *MapValue) DeleteBySmallInt(k Int64) { func (m *MapValue) DeleteBySmallUInt(k UInt64) { key := MapKey{ - valType: m.valType, + sumType: "smallUint", smallUint: &k, } m.Delete(key) @@ -814,15 +1258,23 @@ func (m *MapValue) DeleteBySmallUInt(k UInt64) { func (m *MapValue) DeleteByBigInt(k BigInt) { key := MapKey{ - valType: m.valType, + 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{ - valType: m.valType, + sumType: "bits", bits: &k, } m.Delete(key) @@ -830,7 +1282,7 @@ func (m *MapValue) DeleteByBits(k Bits) { func (m *MapValue) DeleteByInternalAddress(k InternalAddress) { key := MapKey{ - valType: m.valType, + sumType: "internalAddress", internalAddress: &k, } m.Delete(key) @@ -842,4 +1294,42 @@ func (m *MapValue) Len() int { 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/tuples.go b/tolk/tuples.go index 84d1694d..48515b2f 100644 --- a/tolk/tuples.go +++ b/tolk/tuples.go @@ -16,26 +16,56 @@ func (Tensor) SetValue(v *Value, val any) error { return fmt.Errorf("value is not a tensor") } v.tensor = &t + v.sumType = "tensor" return nil } -func (t Tensor) UnmarshalTolk(cell *boc.Cell, v TolkValue, decoder *Decoder) error { +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 := item.UnmarshalTolk(cell, &inner, decoder) + err := inner.UnmarshalTolk(cell, item, decoder) if err != nil { return err } list[i] = inner } - err := v.SetValue(list) + 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 } @@ -50,20 +80,21 @@ func (TupleWith) SetValue(v *Value, val any) error { return fmt.Errorf("value is not a tuple") } v.tupleWith = &t + v.sumType = "tupleWith" return nil } -func (t TupleWith) UnmarshalTolk(cell *boc.Cell, v TolkValue, decoder *Decoder) error { +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 := item.UnmarshalTolk(cell, &inner, decoder) + err := inner.UnmarshalTolk(cell, item, decoder) if err != nil { return err } list[i] = inner } - err := v.SetValue(list) + err := t.SetValue(v, list) if err != nil { return err } @@ -71,6 +102,35 @@ func (t TupleWith) UnmarshalTolk(cell *boc.Cell, v TolkValue, decoder *Decoder) 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 } @@ -81,7 +141,11 @@ func (TupleAny) SetValue(v *Value, val any) error { return fmt.Errorf("tuple any is not supported") } -func (t TupleAny) UnmarshalTolk(cell *boc.Cell, v TolkValue, decoder *Decoder) error { +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") } diff --git a/tolk/union.go b/tolk/union.go index f53966cc..4cc3824d 100644 --- a/tolk/union.go +++ b/tolk/union.go @@ -16,10 +16,11 @@ func (Union) SetValue(v *Value, val any) error { return fmt.Errorf("value is not an union") } v.union = &u + v.sumType = "union" return nil } -func (u Union) UnmarshalTolk(cell *boc.Cell, v TolkValue, decoder *Decoder) error { +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") @@ -58,12 +59,12 @@ func (u Union) UnmarshalTolk(cell *boc.Cell, v TolkValue, decoder *Decoder) erro Prefix: prefix, } innerV := Value{} - err = variant.VariantTy.UnmarshalTolk(cell, &innerV, decoder) + err = innerV.UnmarshalTolk(cell, variant.VariantTy, decoder) if err != nil { return err } unionV.Val = innerV - err = v.SetValue(unionV) + err = u.SetValue(v, unionV) if err != nil { return err } @@ -75,6 +76,83 @@ func (u Union) UnmarshalTolk(cell *boc.Cell, v TolkValue, decoder *Decoder) erro 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 } From fbbeaae44252fb9d19bb3d3cb2dc88960ae78f95 Mon Sep 17 00:00:00 2001 From: Pavel Levchenko Date: Thu, 5 Feb 2026 15:05:55 +0300 Subject: [PATCH 04/16] finish runtime parser --- abi-tolk/contracts_errors.go | 89 - abi-tolk/generator.go | 131 - abi-tolk/get_methods.go | 784 ---- abi-tolk/inspect.go | 319 -- abi-tolk/inspect_test.go | 219 - abi-tolk/interfaces.go | 375 -- abi-tolk/messages.go | 388 -- abi-tolk/messages.md | 62 - abi-tolk/messages_generated.go | 572 --- abi-tolk/messages_test.go | 30 - abi-tolk/parser/errors.tmpl | 45 - abi-tolk/parser/generator.go | 976 ----- abi-tolk/parser/get_methods.tmpl | 45 - abi-tolk/parser/interfaces.tmpl | 141 - abi-tolk/parser/messages.md.tmpl | 12 - abi-tolk/parser/messages.tmpl | 60 - abi-tolk/parser/parser.go | 13 - abi-tolk/parser/parser_test.go | 52 - abi-tolk/parser/payloads.tmpl | 93 - abi-tolk/parser/testdata/alot-wrappers.json | 3572 ----------------- abi-tolk/parser/testdata/simple.json | 253 -- abi-tolk/payload.go | 168 - abi-tolk/payload_msg_types.go | 2049 ---------- abi-tolk/payload_test.go | 212 - abi-tolk/schemas/cocoon-client.json | 2012 ---------- abi-tolk/schemas/cocoon-proxy.json | 2063 ---------- abi-tolk/schemas/cocoon_root.json | 2110 ---------- abi-tolk/schemas/cocoon_wallet.json | 1899 --------- abi-tolk/schemas/cocoon_worker.json | 1904 --------- abi-tolk/schemas/coffee-pool.json | 67 - abi-tolk/schemas/dedust-test.json | 118 - abi-tolk/schemas/jetton-minter.json | 646 --- abi-tolk/schemas/jetton-wallet.json | 655 --- abi-tolk/schemas/payload-test.json | 2195 ---------- abi-tolk/schemas/stonfi_v1.json | 143 - abi-tolk/schemas/stonfi_v2.json | 140 - abi-tolk/schemas/stonfi_v2_const_prod.json | 147 - abi-tolk/schemas/stonfi_v2_stable_swap.json | 228 -- .../stonfi_v2_weighted_stable_swap.json | 203 - abi-tolk/types.go | 1371 ------- abi-tolk/utils.go | 27 - abi/messages_test.go | 58 + boc/cell.go | 26 + boc/immutable_cell.go | 10 +- examples/tolk/main.go | 9 +- tlb/hashmap.go | 119 +- tolk/addresses.go | 549 +-- tolk/cells.go | 287 +- tolk/integers.go | 481 +-- tolk/map.go | 673 ++-- tolk/null.go | 47 +- tolk/parser/parser.go | 655 --- tolk/{abi_types.go => parser/types.go} | 612 +-- tolk/refs.go | 562 ++- tolk/runtime.go | 76 +- tolk/runtime_test.go | 908 ++--- tolk/tuples.go | 158 +- tolk/union.go | 110 +- tolk/utils.go | 37 - tolk/{runtime_types.go => value.go} | 1534 +++---- 60 files changed, 2561 insertions(+), 30938 deletions(-) delete mode 100644 abi-tolk/contracts_errors.go delete mode 100644 abi-tolk/generator.go delete mode 100644 abi-tolk/get_methods.go delete mode 100644 abi-tolk/inspect.go delete mode 100644 abi-tolk/inspect_test.go delete mode 100644 abi-tolk/interfaces.go delete mode 100644 abi-tolk/messages.go delete mode 100644 abi-tolk/messages.md delete mode 100644 abi-tolk/messages_generated.go delete mode 100644 abi-tolk/messages_test.go delete mode 100644 abi-tolk/parser/errors.tmpl delete mode 100644 abi-tolk/parser/generator.go delete mode 100644 abi-tolk/parser/get_methods.tmpl delete mode 100644 abi-tolk/parser/interfaces.tmpl delete mode 100644 abi-tolk/parser/messages.md.tmpl delete mode 100644 abi-tolk/parser/messages.tmpl delete mode 100644 abi-tolk/parser/parser.go delete mode 100644 abi-tolk/parser/parser_test.go delete mode 100644 abi-tolk/parser/payloads.tmpl delete mode 100644 abi-tolk/parser/testdata/alot-wrappers.json delete mode 100644 abi-tolk/parser/testdata/simple.json delete mode 100644 abi-tolk/payload.go delete mode 100644 abi-tolk/payload_msg_types.go delete mode 100644 abi-tolk/payload_test.go delete mode 100644 abi-tolk/schemas/cocoon-client.json delete mode 100644 abi-tolk/schemas/cocoon-proxy.json delete mode 100644 abi-tolk/schemas/cocoon_root.json delete mode 100644 abi-tolk/schemas/cocoon_wallet.json delete mode 100644 abi-tolk/schemas/cocoon_worker.json delete mode 100644 abi-tolk/schemas/coffee-pool.json delete mode 100644 abi-tolk/schemas/dedust-test.json delete mode 100644 abi-tolk/schemas/jetton-minter.json delete mode 100644 abi-tolk/schemas/jetton-wallet.json delete mode 100644 abi-tolk/schemas/payload-test.json delete mode 100644 abi-tolk/schemas/stonfi_v1.json delete mode 100644 abi-tolk/schemas/stonfi_v2.json delete mode 100644 abi-tolk/schemas/stonfi_v2_const_prod.json delete mode 100644 abi-tolk/schemas/stonfi_v2_stable_swap.json delete mode 100644 abi-tolk/schemas/stonfi_v2_weighted_stable_swap.json delete mode 100644 abi-tolk/types.go delete mode 100644 abi-tolk/utils.go delete mode 100644 tolk/parser/parser.go rename tolk/{abi_types.go => parser/types.go} (54%) rename tolk/{runtime_types.go => value.go} (52%) diff --git a/abi-tolk/contracts_errors.go b/abi-tolk/contracts_errors.go deleted file mode 100644 index 81cb0153..00000000 --- a/abi-tolk/contracts_errors.go +++ /dev/null @@ -1,89 +0,0 @@ -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 deleted file mode 100644 index a0387cde..00000000 --- a/abi-tolk/generator.go +++ /dev/null @@ -1,131 +0,0 @@ -//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 deleted file mode 100644 index bd6c5de7..00000000 --- a/abi-tolk/get_methods.go +++ /dev/null @@ -1,784 +0,0 @@ -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 deleted file mode 100644 index 8db98dbf..00000000 --- a/abi-tolk/inspect.go +++ /dev/null @@ -1,319 +0,0 @@ -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 deleted file mode 100644 index 4eb0116f..00000000 --- a/abi-tolk/inspect_test.go +++ /dev/null @@ -1,219 +0,0 @@ -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////7y9GpSiABACASAAFwBgAgEgABgAPwIBIAAZABsBASAAGgAaxAAAAAIAAAAA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TAIO/0+6rsz3U6T3AoIbe8U6aIvoPUsO4LZGA0smjodKh3NAAAAAAAAAAAAAAAAA2rxsPvwr1058gyCen2VPpZQIosUACASAClAKVAgEgApwCnQIBIAKWApcAgb9cGndssE4S7bcVNIHMFrkiUrizWnT5vI9yfOYIEc45BgAAAAAAAAAAAAAAAdcS6yzbXhkM5DgpcXb79xP5dzOVAIG/CbgwhUMYn2yHU343dcezKkvme3cyFJB7SHVY3FXhU9gAAAAAAAAAAAAAAAIsGpdN2JfQe6dn1Q0grZWLGV+pvgIBIAKYApkCASACmgKbAIG+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 deleted file mode 100644 index 477bae14..00000000 --- a/abi-tolk/interfaces.go +++ /dev/null @@ -1,375 +0,0 @@ -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 deleted file mode 100644 index c9806411..00000000 --- a/abi-tolk/messages.go +++ /dev/null @@ -1,388 +0,0 @@ -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 deleted file mode 100644 index e24b67aa..00000000 --- a/abi-tolk/messages.md +++ /dev/null @@ -1,62 +0,0 @@ - -# 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 deleted file mode 100644 index 7627ee9a..00000000 --- a/abi-tolk/messages_generated.go +++ /dev/null @@ -1,572 +0,0 @@ -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 deleted file mode 100644 index 38c98185..00000000 --- a/abi-tolk/messages_test.go +++ /dev/null @@ -1,30 +0,0 @@ -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 deleted file mode 100644 index 797706da..00000000 --- a/abi-tolk/parser/errors.tmpl +++ /dev/null @@ -1,45 +0,0 @@ - - -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 deleted file mode 100644 index 4bdb2c29..00000000 --- a/abi-tolk/parser/generator.go +++ /dev/null @@ -1,976 +0,0 @@ -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 deleted file mode 100644 index a240ac1e..00000000 --- a/abi-tolk/parser/get_methods.tmpl +++ /dev/null @@ -1,45 +0,0 @@ - -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 deleted file mode 100644 index 28dc42ef..00000000 --- a/abi-tolk/parser/interfaces.tmpl +++ /dev/null @@ -1,141 +0,0 @@ - -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 deleted file mode 100644 index 5f03d81d..00000000 --- a/abi-tolk/parser/messages.md.tmpl +++ /dev/null @@ -1,12 +0,0 @@ - -# 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 deleted file mode 100644 index 31cc49cb..00000000 --- a/abi-tolk/parser/messages.tmpl +++ /dev/null @@ -1,60 +0,0 @@ - - -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 deleted file mode 100644 index d67f57df..00000000 --- a/abi-tolk/parser/parser.go +++ /dev/null @@ -1,13 +0,0 @@ -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 deleted file mode 100644 index d7844fbd..00000000 --- a/abi-tolk/parser/parser_test.go +++ /dev/null @@ -1,52 +0,0 @@ -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 deleted file mode 100644 index f80e0aec..00000000 --- a/abi-tolk/parser/payloads.tmpl +++ /dev/null @@ -1,93 +0,0 @@ - -{{- 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 deleted file mode 100644 index 0bd3b945..00000000 --- a/abi-tolk/parser/testdata/alot-wrappers.json +++ /dev/null @@ -1,3572 +0,0 @@ -{ - "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 deleted file mode 100644 index 0e872fed..00000000 --- a/abi-tolk/parser/testdata/simple.json +++ /dev/null @@ -1,253 +0,0 @@ -{ - "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 deleted file mode 100644 index e6b1b188..00000000 --- a/abi-tolk/payload.go +++ /dev/null @@ -1,168 +0,0 @@ -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 deleted file mode 100644 index 182525ca..00000000 --- a/abi-tolk/payload_msg_types.go +++ /dev/null @@ -1,2049 +0,0 @@ -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 deleted file mode 100644 index d3099cca..00000000 --- a/abi-tolk/payload_test.go +++ /dev/null @@ -1,212 +0,0 @@ -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 deleted file mode 100644 index 7cd60e30..00000000 --- a/abi-tolk/schemas/cocoon-client.json +++ /dev/null @@ -1,2012 +0,0 @@ -{ - "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//MzIAgJAJsUwW7kTDgIdDTBzHTHzHTHzHSADH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0XFUephTqATIywFQA/oCAfoCyz/L/8ktyM+RlRI/0ss/FPpSE8wT9ADJyM+FiBP6UgH6AnHPC2rMyXH7AMjPhQgY+lKCECVlk0zPC44YIQH+MyvDAivDALHy4+5TgLvy4+j4KBPHBfLj9xCKXjYQWRBKEDlKmfABMzZycCCCCJiWgCH7AsjPkxo68e5QCPoCGvpSySfQ+kj6SNP/MdFUd2TIz4YIUAP6Ass/y//JyM+RlRI/0hzLPxL6UhrM9ADJyM+FiBn6UnHPC24YzMmDBiIABFUjAA7LP8mDBvsAAAz7AAZVMAc=" -} \ No newline at end of file diff --git a/abi-tolk/schemas/cocoon-proxy.json b/abi-tolk/schemas/cocoon-proxy.json deleted file mode 100644 index b9411ef0..00000000 --- a/abi-tolk/schemas/cocoon-proxy.json +++ /dev/null @@ -1,2063 +0,0 @@ -{ - "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/lj4D9ARD9AQn6AAn6AAn6AEFwIBIAgJAg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W+lKCECVlk0zPC44Vyz/Jgwb7AHH4I1igAe8ghAF9eEAUAO78uPrAtMf0z/6SIMI1xjU0SD5AEAG+RDy4+8j0NMf1ws/BLry4+1RIbry4+0C0NcsIxtSHIyY0z8x+kiBAIWOE9csJyiNXjyS8j/h0z8x+kiBAIbiAdGBAIW6jhAowAHy4+74KMcF8uP3WPAB4w2AVAfcMzMgbpJfBeAl0NMH0x/TH9IA+gD6ANMf0x/TH9Mf0x/TH/oA+gD0BDH0BPQEMdFtbW34KBESyMsHARERAcsfH8sfHcoAUAv6AlAJ+gIXyx8Vyx8Tyx/LH8sfyx8B+gIB+gIS9AAS9AAS9ADJJsj6UhP6Ui7PC/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 deleted file mode 100644 index 8067bd19..00000000 --- a/abi-tolk/schemas/cocoon_root.json +++ /dev/null @@ -1,2110 +0,0 @@ -{ - "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", - "codeBoc64": "te6ccgECFwEABIsAART/APSkE/S88sgLAQIBYgIDAvTQ7aLt+/iR8kAgxwCRMOD4J28Q+Jeh+C+gggiYloC2CXD7AiDXCx+CEJoSR8C6kTDgINMfMdcLP+1E0PpI0x/U10wj+JIlxwXy4/IC0AHQAfQE9ATTH/QE9AUF1gfTH9Yg+gD6ANZ/0x/TH/oA+gD0BPQE9AURFonXJwQFAgEgDQ4ACONLHGAC/p/TPzHXC/+LCAIREIMH9BaOtNcsJGylPNSd0z8x1wv/UA+DB/RbMI6c1ywmCjCabJ/TPzHXC/+LCAIREoMH9BbjDhEQDuLiyM+FCAEREgH6UoIQJWWTTM8LjgERFAHLP8mDBvsADcj0AB/0ABrLHxj0ABv0AMkFyM4Uyx8SzgEGBwHy1ywklYjgxJ7TPzHXC/8BERGDB/RbMI7g1ywjjDB0BJ/TPzHXC/+LCAIREYMH9BaOw9csIeIOhZSe0z8x1wv/AREQgwf0WzCOqtcsJJPj5ayOG9M/MSDTAAHy0+zTBgGqAtch0Q6kVC4OgCD0FuMOEN8MDeLiDxEQ4ggAUPoCAfoCFs7LH8sfUAT6AgH6AhX0APQAFPQAyQOkAcj6UssfzMzJ7VQD+tcsI2pPV5SPcNcsJOPJJdSO5dcsJil2xqSdODgJpAbTPzH6APoAMI7H1ywgEX0MTI4YbDMzNDQFpAXTPzH6APoA0x/TH/oA+gAwjp3XLCURuHsMm1cWWwikERPU1NdM4w4RFUh6RUBBMOIQihB4VRPiEIwHUKoI4w3jDRDNCQoLAfrXLCCNd+qMnFcQXw9sYddM+wTbMeDXLCKx4Oy0mTA8PT09bW1tbY5U1ywie+K8TI4rVxBfDzVfAzLTP9TXTAHtVPsEyM+FCBL6UoIQJWWTTM8Ljss/yYMG+wDbMeBXFBET1ywmJQ1ypJLyP+HTPzH6SDAREwMREANP7EEw4gwATNM/MdMfINMAAfLT7NMGAaoC1yHRUx6AIPQOb6Ex8ufQQB6AIPQWABrTPzHXCx9QDYAg9FswABwKERUKAREQARA/TswDCgIBIA8QAFW/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 deleted file mode 100644 index 2e23bc9e..00000000 --- a/abi-tolk/schemas/cocoon_wallet.json +++ /dev/null @@ -1,1899 +0,0 @@ -{ - "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 deleted file mode 100644 index 748d6596..00000000 --- a/abi-tolk/schemas/cocoon_worker.json +++ /dev/null @@ -1,1904 +0,0 @@ -{ - "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 deleted file mode 100644 index fb7f5678..00000000 --- a/abi-tolk/schemas/coffee-pool.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "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 deleted file mode 100644 index c6090afb..00000000 --- a/abi-tolk/schemas/dedust-test.json +++ /dev/null @@ -1,118 +0,0 @@ -{ - "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 deleted file mode 100644 index 00c39a66..00000000 --- a/abi-tolk/schemas/jetton-minter.json +++ /dev/null @@ -1,646 +0,0 @@ -{ - "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 deleted file mode 100644 index 46ed108a..00000000 --- a/abi-tolk/schemas/jetton-wallet.json +++ /dev/null @@ -1,655 +0,0 @@ -{ - "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 deleted file mode 100644 index 4b873615..00000000 --- a/abi-tolk/schemas/payload-test.json +++ /dev/null @@ -1,2195 +0,0 @@ -{ - "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 deleted file mode 100644 index ed4ac512..00000000 --- a/abi-tolk/schemas/stonfi_v1.json +++ /dev/null @@ -1,143 +0,0 @@ -{ - "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 deleted file mode 100644 index 87eba04d..00000000 --- a/abi-tolk/schemas/stonfi_v2.json +++ /dev/null @@ -1,140 +0,0 @@ -{ - "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 deleted file mode 100644 index e39db07f..00000000 --- a/abi-tolk/schemas/stonfi_v2_const_prod.json +++ /dev/null @@ -1,147 +0,0 @@ -{ - "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 deleted file mode 100644 index aad6fa7e..00000000 --- a/abi-tolk/schemas/stonfi_v2_stable_swap.json +++ /dev/null @@ -1,228 +0,0 @@ -{ - "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 deleted file mode 100644 index e4ac294a..00000000 --- a/abi-tolk/schemas/stonfi_v2_weighted_stable_swap.json +++ /dev/null @@ -1,203 +0,0 @@ -{ - "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 deleted file mode 100644 index 3440a51c..00000000 --- a/abi-tolk/types.go +++ /dev/null @@ -1,1371 +0,0 @@ -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 deleted file mode 100644 index 5e0f9b45..00000000 --- a/abi-tolk/utils.go +++ /dev/null @@ -1,27 +0,0 @@ -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 c8c60295..feca10bf 100644 --- a/abi/messages_test.go +++ b/abi/messages_test.go @@ -62,3 +62,61 @@ func TestDecodeAndEncodeUnknownInMsgBody(t *testing.T) { t.Fatalf("got different result") } } + +func TestDecodeAndEncodeUnknownInMsgBody1(t *testing.T) { + data := "b5ee9c7241010b0100f4000202c8010a0201620209020120030802012004070201580506004327fd889d4ca5a81250b38cfb489c99475bacacb61c512fac81458a37f66e1b10eff400432002aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaac0044d4ff53355555555555555555555555555555555555555555555555555555555555550045bd002c44ea652d4092859c67da44e4ca3add6565b0e2897d640a2c51bfb370d8877fa00045a3cff555555555555555555555555555555555555555555555555555555555555555580045bd5800aa6aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab8a1b898e" + boc1, _ := boc.DeserializeBocHex(data) + + var x tlb.Hashmap[tlb.Uint16, tlb.MsgAddress] + 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) + } + + curr1 := boc1[0] + curr2 := boc2 + fmt.Println(equal(*curr1, *curr2)) + + hs1, _ := boc1[0].HashString() + hs2, _ := boc2.HashString() + if hs1 != hs2 { + t.Fatalf("got different result") + } +} + +func equal(curr1 boc.Cell, curr2 boc.Cell) bool { + curr1.ResetCounters() + curr2.ResetCounters() + bits1 := curr1.ReadRemainingBits() + bits2 := curr2.ReadRemainingBits() + if bits1.BinaryString() != bits2.BinaryString() { + //fmt.Println(bits1.BinaryString()) + //fmt.Println(bits2.BinaryString()) + return false + } + + if len(curr1.Refs()) != len(curr2.Refs()) { + fmt.Println(len(curr1.Refs()), len(curr2.Refs())) + return false + } + + for i := range curr1.Refs() { + if !equal(*curr1.Refs()[i], *curr2.Refs()[i]) { + curr1.Refs()[1].ResetCounters() + curr2.Refs()[1].ResetCounters() + bits3 := curr1.Refs()[1].ReadRemainingBits() + bits4 := curr2.Refs()[1].ReadRemainingBits() + if bits3.BitsAvailableForRead() == 269 { + fmt.Println(bits3.BinaryString()) + fmt.Println(bits4.BinaryString()) + } + return false + } + } + + return true +} diff --git a/boc/cell.go b/boc/cell.go index 0b8cc8f8..75f73550 100644 --- a/boc/cell.go +++ b/boc/cell.go @@ -106,6 +106,11 @@ func (c *Cell) BitSize() int { func (c *Cell) Hash() ([]byte, error) { return c.hash(map[*Cell]*immutableCell{}) } + +func (c *Cell) HashWithLevel(level int) ([]byte, error) { + return c.hashWithLevel(map[*Cell]*immutableCell{}, level) +} + func (c *Cell) Hash256() ([32]byte, error) { b, err := c.hash(map[*Cell]*immutableCell{}) if err != nil { @@ -124,6 +129,19 @@ func (c *Cell) HashString() (string, error) { return hex.EncodeToString(h), nil } +func (c *Cell) HashStringWithLevel(level int) (string, error) { + h, err := c.hashWithLevel(map[*Cell]*immutableCell{}, level) + if err != nil { + return "", err + } + return hex.EncodeToString(h), nil +} + +func (c *Cell) Depth() int { + imc, _ := newImmutableCell(c, make(map[*Cell]*immutableCell)) + return imc.Depth(0) +} + func (c *Cell) hash(cache map[*Cell]*immutableCell) ([]byte, error) { imc, err := newImmutableCell(c, cache) if err != nil { @@ -132,6 +150,14 @@ func (c *Cell) hash(cache map[*Cell]*immutableCell) ([]byte, error) { return imc.Hash(maxLevel), nil } +func (c *Cell) hashWithLevel(cache map[*Cell]*immutableCell, level int) ([]byte, error) { + imc, err := newImmutableCell(c, cache) + if err != nil { + return nil, err + } + return imc.Hash(level), nil +} + func (c *Cell) ToBoc() ([]byte, error) { bag := newBagOfCells() return bag.serializeBoc([]*Cell{c}, false, false, false, 0) diff --git a/boc/immutable_cell.go b/boc/immutable_cell.go index ca7b49ad..5213ea86 100644 --- a/boc/immutable_cell.go +++ b/boc/immutable_cell.go @@ -137,11 +137,11 @@ func newImmutableCell(c *Cell, cache map[*Cell]*immutableCell) (*immutableCell, func (ic *immutableCell) Hash(level int) []byte { index := ic.mask.Apply(level).HashIndex() if ic.cellType == PrunedBranchCell { - offset := ic.mask.HashIndex() - if index != offset { - return ic.bitsBuf[2+(index)*32 : 2+(index+1)*32] - } - index = 0 + //offset := ic.mask.HashIndex() + //if index != offset { + return ic.bitsBuf[2+(index)*32 : 2+(index+1)*32] + //} + //index = 0 } return ic.hashes[index] } diff --git a/examples/tolk/main.go b/examples/tolk/main.go index a3459778..a0924a0e 100644 --- a/examples/tolk/main.go +++ b/examples/tolk/main.go @@ -7,6 +7,7 @@ import ( "github.com/tonkeeper/tongo/boc" "github.com/tonkeeper/tongo/tolk" + "github.com/tonkeeper/tongo/tolk/parser" ) import _ "embed" @@ -14,15 +15,15 @@ import _ "embed" var abiData []byte func main() { - var abi tolk.ABI + var abi tolkParser.ABI err := json.Unmarshal(abiData, &abi) if err != nil { panic(err) } - ty := tolk.Ty{ + ty := tolkParser.Ty{ SumType: "StructRef", - StructRef: &tolk.StructRef{ + StructRef: &tolkParser.StructRef{ StructName: "Transfer", }, } @@ -37,7 +38,7 @@ func main() { decoder := tolk.NewDecoder() decoder.WithABI(abi) - res, err := decoder.UnmarshalTolk(cell[0], ty) + res, err := decoder.Unmarshal(cell[0], ty) if err != nil { panic(err) } diff --git a/tlb/hashmap.go b/tlb/hashmap.go index 49f5d549..e26b605e 100644 --- a/tlb/hashmap.go +++ b/tlb/hashmap.go @@ -4,6 +4,7 @@ import ( "encoding/json" "errors" "fmt" + "math" "slices" "strconv" "strings" @@ -409,45 +410,107 @@ func encodeLabel(c *boc.Cell, keyFirst, keyLast *boc.BitString, keySize int) (bo } 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 - } + labelLen := label.BitsAvailableForRead() + + // We must find the most compact way to serialize key + hmlShortSize := 2*labelLen + 2 + hmlLongSize := 2 + int(math.Ceil(math.Log2(float64(keySize)+1))) + labelLen + var encodeFunc func(*boc.Cell, int, boc.BitString) error + isShort := false + if hmlShortSize <= hmlLongSize { + isShort = true + encodeFunc = encodeShortLabel } 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) + encodeFunc = encodeLongLabel + } + + // If all bits in label are the same then we can use hml_same + isAllZero := true + isAllOne := true + for label.BitsAvailableForRead() > 0 { + bit, err := label.ReadBit() if err != nil { return boc.BitString{}, err } - // todo pack label - err = c.WriteLimUint(label.BitsAvailableForRead(), keySize) - if err != nil { - return boc.BitString{}, err + if bit { + isAllZero = false + } else { + isAllOne = false } - err = c.WriteBitString(label) - if err != nil { - return boc.BitString{}, err + } + label.ResetCounter() + if isAllZero || isAllOne { + hmlSameSize := 2 + 1 + int(math.Ceil(math.Log2(float64(keySize)+1))) + if isShort && hmlSameSize < hmlShortSize { + encodeFunc = encodeSameLabel + } else if !isShort && hmlSameSize < hmlLongSize { + encodeFunc = encodeSameLabel } } + + err := encodeFunc(c, keySize, label) + if err != nil { + return boc.BitString{}, err + } return label, nil } +func encodeShortLabel(c *boc.Cell, keySize int, label boc.BitString) error { + //hml_short$0 {m:#} {n:#} len:(Unary ~n) {n <= m} s:(n * Bit) = HmLabel ~n m; + err := c.WriteBit(false) + if err != nil { + return err + } + err = c.WriteUnary(uint(label.BitsAvailableForRead())) + if err != nil { + return err + } + err = c.WriteBitString(label) + if err != nil { + return err + } + return nil +} + +func encodeLongLabel(c *boc.Cell, keySize int, label boc.BitString) error { + // hml_long$10 {m:#} n:(#<= m) s:(n * Bit) = HmLabel ~n m; + err := c.WriteBit(true) + if err != nil { + return err + } + err = c.WriteBit(false) + if err != nil { + return err + } + err = c.WriteLimUint(label.BitsAvailableForRead(), keySize) + if err != nil { + return err + } + err = c.WriteBitString(label) + if err != nil { + return err + } + return nil +} + +func encodeSameLabel(c *boc.Cell, keySize int, label boc.BitString) error { + //hml_same$11 {m:#} v:Bit n:(#<= m) = HmLabel ~n m; + err := c.WriteUint(0b11, 2) + if err != nil { + return err + } + err = c.WriteBit(label.BinaryString()[0] == '1') + if err != nil { + return err + } + err = c.WriteLimUint(label.BitsAvailableForRead(), keySize) + if err != nil { + return err + } + return nil +} + type HashmapAug[keyT fixedSize, T1, T2 any] struct { keys []keyT values []T1 diff --git a/tolk/addresses.go b/tolk/addresses.go index 29bd8679..43d87d37 100644 --- a/tolk/addresses.go +++ b/tolk/addresses.go @@ -1,47 +1,19 @@ package tolk import ( + "bytes" "fmt" "github.com/tonkeeper/tongo/boc" + "github.com/tonkeeper/tongo/tolk/parser" ) -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 +type InternalAddress struct { + Workchain int8 + Address [32]byte } -func (i *InternalAddress) UnmarshalTolk(cell *boc.Cell, ty Address, abiCtx *Decoder) error { +func (i *InternalAddress) Unmarshal(cell *boc.Cell, ty tolkParser.Address, decoder *Decoder) error { err := cell.Skip(3) // skip addr type ($10) and anycast (0) if err != nil { return err @@ -61,85 +33,39 @@ func (i *InternalAddress) UnmarshalTolk(cell *boc.Cell, ty Address, abiCtx *Deco return nil } -func (Address) MarshalTolk(cell *boc.Cell, v *Value) error { - if v.internalAddress == nil { - return fmt.Errorf("address not found") - } - +func (i *InternalAddress) Marshal(cell *boc.Cell, ty tolkParser.Address, encoder *Encoder) error { 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) + err = cell.WriteInt(int64(i.Workchain), 8) if err != nil { return err } - err = cell.WriteBytes(v.internalAddress.Address[:]) + err = cell.WriteBytes(i.Address[:]) if err != nil { return err } return nil } -func (Address) Equal(v Value, o Value) bool { - if v.internalAddress == nil || o.internalAddress == nil { +func (i *InternalAddress) Equal(other any) bool { + otherInternalAddress, ok := other.(InternalAddress) + if !ok { return false } - vi := *v.internalAddress - oi := *o.internalAddress - return vi.Workchain == oi.Workchain && vi.Address == oi.Address + return *i == otherInternalAddress } -func (Address) GetFixedSize() int { - return 267 +func (i *InternalAddress) ToRaw() string { + return fmt.Sprintf("%v:%x", i.Workchain, i.Address) } -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 +type NoneAddress struct { } -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), - }, - }) +func (n *NoneAddress) Unmarshal(cell *boc.Cell, ty tolkParser.AddressOpt, decoder *Decoder) error { + _, err := cell.ReadUint(2) if err != nil { return err } @@ -147,106 +73,65 @@ func (a AddressOpt) UnmarshalTolk(cell *boc.Cell, v *Value, abiCtx *Decoder) err return nil } -func (o *OptionalAddress) UnmarshalTolk(cell *boc.Cell, ty AddressOpt, abiCtx *Decoder) error { - tag, err := cell.ReadUint(2) +func (n *NoneAddress) Marshal(cell *boc.Cell, ty tolkParser.AddressOpt, encoder *Encoder) error { + err := cell.WriteUint(0, 2) // none addr type ($00) 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 - } +type OptionalAddress struct { + SumType + NoneAddress *NoneAddress + InternalAddress *InternalAddress +} - return nil +func (o *OptionalAddress) Equal(other any) bool { + otherOptionalAddress, ok := other.(OptionalAddress) + if !ok { + return false } - - err := cell.WriteUint(0b100, 3) // internal addr type ($10) and anycast (0) - if err != nil { - return err + if o.SumType != otherOptionalAddress.SumType { + return false } - err = cell.WriteInt(int64(v.optionalAddress.InternalAddress.Workchain), 8) - if err != nil { - return err + if o.SumType == "InternalAddress" { + return o.InternalAddress.Equal(otherOptionalAddress.InternalAddress) } - err = cell.WriteBytes(v.optionalAddress.InternalAddress.Address[:]) + return true +} + +func (o *OptionalAddress) Unmarshal(cell *boc.Cell, ty tolkParser.AddressOpt, decoder *Decoder) error { + copyCell := cell.CopyRemaining() + tag, err := copyCell.ReadUint(2) if err != nil { return err } - return nil -} + if tag == 0 { + o.SumType = "NoneAddress" + o.NoneAddress = &NoneAddress{} + return o.NoneAddress.Unmarshal(cell, ty, decoder) + } -func (AddressOpt) Equal(v Value, o Value) bool { - return false + o.SumType = "InternalAddress" + o.InternalAddress = &InternalAddress{} + return o.InternalAddress.Unmarshal(cell, tolkParser.Address{}, decoder) } -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") +func (o *OptionalAddress) Marshal(cell *boc.Cell, ty tolkParser.AddressOpt, encoder *Encoder) error { + if o.SumType == "NoneAddress" { + return o.NoneAddress.Marshal(cell, ty, encoder) } - 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 o.InternalAddress.Marshal(cell, tolkParser.Address{}, encoder) +} - return nil +type ExternalAddress struct { + Len int16 + Address boc.BitString } -func (e *ExternalAddress) UnmarshalTolk(cell *boc.Cell, ty AddressExt, abiCtx *Decoder) error { +func (e *ExternalAddress) Unmarshal(cell *boc.Cell, ty tolkParser.AddressExt, decoder *Decoder) error { err := cell.Skip(2) if err != nil { return err @@ -267,257 +152,167 @@ func (e *ExternalAddress) UnmarshalTolk(cell *boc.Cell, ty AddressExt, abiCtx *D return nil } -func (AddressExt) MarshalTolk(cell *boc.Cell, v *Value) error { - if v.externalAddress == nil { - return fmt.Errorf("external address not found") - } - +func (e *ExternalAddress) Marshal(cell *boc.Cell, ty tolkParser.AddressExt, encoder *Encoder) error { err := cell.WriteUint(1, 2) // external addr type ($01) if err != nil { return err } - err = cell.WriteUint(uint64(v.externalAddress.Len), 9) + err = cell.WriteUint(uint64(e.Len), 9) if err != nil { return err } - err = cell.WriteBitString(v.externalAddress.Address) + err = cell.WriteBitString(e.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) +func (e *ExternalAddress) Equal(other any) bool { + otherExternalAddress, ok := other.(ExternalAddress) 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 + return false } - 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 - } + if e.Len != otherExternalAddress.Len { + return false } + return bytes.Equal(e.Address.Buffer(), otherExternalAddress.Address.Buffer()) +} - return nil +type AnyAddress struct { + SumType + InternalAddress *InternalAddress + NoneAddress *NoneAddress + ExternalAddress *ExternalAddress + VarAddress *VarAddress } -func (a *AnyAddress) UnmarshalTolk(cell *boc.Cell, ty AddressAny, abiCtx *Decoder) error { - tag, err := cell.ReadUint(2) +func (a *AnyAddress) Unmarshal(cell *boc.Cell, ty tolkParser.AddressAny, decoder *Decoder) error { + copyCell := cell.CopyRemaining() + tag, err := copyCell.ReadUint(2) if err != nil { return err } switch tag { case 0: a.SumType = "NoneAddress" + a.NoneAddress = &NoneAddress{} + return a.NoneAddress.Unmarshal(cell, tolkParser.AddressOpt{}, decoder) 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, - } + a.ExternalAddress = &ExternalAddress{} + return a.ExternalAddress.Unmarshal(cell, tolkParser.AddressExt{}, decoder) 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), - } + a.InternalAddress = &InternalAddress{} + return a.InternalAddress.Unmarshal(cell, tolkParser.Address{}, decoder) 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, - } + a.VarAddress = &VarAddress{} + return a.VarAddress.Unmarshal(cell, tolkParser.AddressExt{}, decoder) } return nil } -func (AddressAny) MarshalTolk(cell *boc.Cell, v *Value) error { - if v.anyAddress == nil { - return fmt.Errorf("any address not found") +func (a *AnyAddress) Marshal(cell *boc.Cell, ty tolkParser.AddressAny, encoder *Encoder) error { + switch a.SumType { + case "NoneAddress": + return a.NoneAddress.Marshal(cell, tolkParser.AddressOpt{}, encoder) + case "InternalAddress": + return a.InternalAddress.Marshal(cell, tolkParser.Address{}, encoder) + case "ExternalAddress": + return a.ExternalAddress.Marshal(cell, tolkParser.AddressExt{}, encoder) + case "VarAddress": + return a.VarAddress.Marshal(cell, tolkParser.AddressAny{}, encoder) } - switch v.anyAddress.SumType { + return nil +} + +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": - err := cell.WriteUint(0, 2) - if err != nil { - return err - } + return true 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 - } + return a.InternalAddress.Equal(otherAnyAddress.InternalAddress) 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 - } + return a.ExternalAddress.Equal(otherAnyAddress.ExternalAddress) 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 a.VarAddress.Equal(otherAnyAddress.VarAddress) + } + return false +} + +type VarAddress struct { + Len int16 + Workchain int32 + Address boc.BitString +} + +func (va *VarAddress) Equal(other any) bool { + otherVarAddress, ok := other.(VarAddress) + if !ok { + return false + } + if va.Len != otherVarAddress.Len { + return false + } + if va.Workchain != otherVarAddress.Workchain { + return false + } + return bytes.Equal(va.Address.Buffer(), otherVarAddress.Address.Buffer()) +} + +func (va *VarAddress) Unmarshal(cell *boc.Cell, ty tolkParser.AddressExt, decoder *Decoder) error { + err := cell.Skip(3) // skip var type ($11) and 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 + } + *va = VarAddress{ + Len: int16(ln), + Workchain: int32(workchain), + Address: bs, } return nil } -func (AddressAny) Equal(v Value, o Value) bool { - return false +func (va *VarAddress) Marshal(cell *boc.Cell, ty tolkParser.AddressAny, encoder *Encoder) error { + err := cell.WriteUint(0b110, 3) // var addr type ($11) and anycast (0) + if err != nil { + return err + } + err = cell.WriteUint(uint64(va.Len), 9) + if err != nil { + return err + } + err = cell.WriteInt(int64(va.Workchain), 32) + if err != nil { + return err + } + err = cell.WriteBitString(va.Address) + if err != nil { + return err + } + return nil } diff --git a/tolk/cells.go b/tolk/cells.go index 43b636b6..644363cc 100644 --- a/tolk/cells.go +++ b/tolk/cells.go @@ -1,36 +1,13 @@ package tolk import ( - "fmt" - "github.com/tonkeeper/tongo/boc" + "github.com/tonkeeper/tongo/tolk/parser" ) -type Cell struct{} +type Any boc.Cell -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 { +func (a *Any) Unmarshal(cell *boc.Cell, ty tolkParser.Cell, decoder *Decoder) error { ref, err := cell.NextRef() if err != nil { return err @@ -40,12 +17,8 @@ func (a *Any) UnmarshalTolk(cell *boc.Cell, ty Cell, decoder *Decoder) error { 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) +func (a *Any) Marshal(cell *boc.Cell, ty tolkParser.Cell, encoder *Encoder) error { + c := boc.Cell(*a) ref := c.CopyRemaining() err := cell.AddRef(ref) if err != nil { @@ -55,88 +28,27 @@ func (Cell) MarshalTolk(cell *boc.Cell, v *Value) error { 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) +func (a *Any) Equal(o any) bool { + other, ok := o.(Any) if !ok { - return fmt.Errorf("value is not a cell") + return false } - 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 - } + cellV := boc.Cell(*a) + vHash, err := cellV.HashString() + if err != nil { + return false } - return nil + cellO := boc.Cell(other) + oHash, err := cellO.HashString() + if err != nil { + return false + } + return oHash == vHash } -func (r *RemainingValue) UnmarshalTolk(cell *boc.Cell, ty Remaining, decoder *Decoder) error { +type RemainingValue boc.Cell + +func (r *RemainingValue) Unmarshal(cell *boc.Cell, ty tolkParser.Remaining, decoder *Decoder) error { rem := cell.CopyRemaining() if rem != nil { *r = RemainingValue(*rem) @@ -144,11 +56,8 @@ func (r *RemainingValue) UnmarshalTolk(cell *boc.Cell, ty Remaining, decoder *De 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) +func (r *RemainingValue) Marshal(cell *boc.Cell, ty tolkParser.Remaining, encoder *Encoder) error { + c := boc.Cell(*r) err := cell.WriteBitString(c.ReadRemainingBits()) if err != nil { return err @@ -163,56 +72,37 @@ func (Remaining) MarshalTolk(cell *boc.Cell, v *Value) error { 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) +func (r *RemainingValue) Equal(o any) bool { + other, ok := o.(RemainingValue) if !ok { - return fmt.Errorf("value is not an optional value") + return false } - v.optionalValue = &o - v.sumType = "optionalValue" - return nil -} - -func (n Nullable) UnmarshalTolk(cell *boc.Cell, v *Value, decoder *Decoder) error { - isExists, err := cell.ReadBit() + cellV := boc.Cell(*r) + vHash, err := cellV.HashString() if err != nil { - return err + return false } - 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) + cellO := boc.Cell(other) + oHash, err := cellO.HashString() if err != nil { - return err + return false } - return nil + return oHash == vHash } -func (o *OptValue) UnmarshalTolk(cell *boc.Cell, ty Nullable, decoder *Decoder) error { +type OptValue struct { + IsExists bool + Val Value +} + +func (o *OptValue) Unmarshal(cell *boc.Cell, ty tolkParser.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) + err = o.Val.Unmarshal(cell, ty.Inner, decoder) if err != nil { return err } @@ -220,97 +110,68 @@ func (o *OptValue) UnmarshalTolk(cell *boc.Cell, ty Nullable, decoder *Decoder) 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 - // } - //} +func (o *OptValue) Marshal(cell *boc.Cell, ty tolkParser.Nullable, encoder *Encoder) error { + err := cell.WriteBit(o.IsExists) + if err != nil { + return err + } + if o.IsExists { + return o.Val.Marshal(cell, ty.Inner, encoder) + } 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) +func (o *OptValue) Equal(other any) bool { + otherOptValue, ok := other.(OptValue) if !ok { - return fmt.Errorf("value is not a ref value") + return false } - v.refValue = &r - v.sumType = "refValue" - return nil + if o.IsExists != otherOptValue.IsExists { + return false + } + if o.IsExists { + return o.Val.Equal(otherOptValue.Val) + } + return true } -func (c CellOf) UnmarshalTolk(cell *boc.Cell, v *Value, decoder *Decoder) error { +type RefValue Value + +func (r *RefValue) Unmarshal(cell *boc.Cell, ty tolkParser.CellOf, 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)) + err = innerV.Unmarshal(ref, ty.Inner, decoder) if err != nil { return err } + *r = RefValue(innerV) return nil } -func (r *RefValue) UnmarshalTolk(cell *boc.Cell, ty CellOf, decoder *Decoder) error { - ref, err := cell.NextRef() +func (r *RefValue) Marshal(cell *boc.Cell, ty tolkParser.CellOf, encoder *Encoder) error { + val := Value(*r) + ref := boc.NewCell() + err := val.Marshal(ref, ty.Inner, encoder) if err != nil { return err } - innerV := Value{} - err = innerV.UnmarshalTolk(ref, ty.Inner, decoder) + err = cell.AddRef(ref) 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 +func (r *RefValue) Equal(other any) bool { + otherRefValue, ok := other.(RefValue) + if !ok { + return false + } + return r.Equal(otherRefValue) } diff --git a/tolk/integers.go b/tolk/integers.go index 68839b1b..6efafa05 100644 --- a/tolk/integers.go +++ b/tolk/integers.go @@ -2,81 +2,38 @@ package tolk import ( "bytes" - "fmt" "math/big" "github.com/tonkeeper/tongo/boc" + "github.com/tonkeeper/tongo/tolk/parser" ) -type Int struct{} +type Int64 int64 -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)) +func (i *Int64) Unmarshal(cell *boc.Cell, ty tolkParser.IntN, decoder *Decoder) error { + num, err := cell.ReadInt(ty.N) if err != nil { return err } + *i = Int64(num) 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 +func (i *Int64) Marshal(cell *boc.Cell, ty tolkParser.IntN, encoder *Encoder) error { + return cell.WriteInt(int64(*i), ty.N) +} + +func (i *Int64) Equal(other any) bool { + otherInt, ok := other.(Int64) + if !ok { + return false } - *i = Int64(num) - return nil + return *i == otherInt } -func (b *BigInt) UnmarshalTolk(cell *boc.Cell, ty IntN, decoder *Decoder) error { +type BigInt big.Int + +func (b *BigInt) Unmarshal(cell *boc.Cell, ty tolkParser.IntN, decoder *Decoder) error { num, err := cell.ReadBigInt(ty.N) if err != nil { return err @@ -85,96 +42,24 @@ func (b *BigInt) UnmarshalTolk(cell *boc.Cell, ty IntN, decoder *Decoder) error 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 (b *BigInt) Marshal(cell *boc.Cell, ty tolkParser.IntN, encoder *Encoder) error { + bi := big.Int(*b) + return cell.WriteBigInt(&bi, ty.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 { +func (b *BigInt) Equal(other any) bool { + otherBigInt, ok := other.(BigInt) + if !ok { return false } - - return *v.smallInt == *o.smallInt + bi := big.Int(*b) + otherBi := big.Int(otherBigInt) + return bi.Cmp(&otherBi) == 0 } -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 -} +type UInt64 uint64 -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 { +func (i *UInt64) Unmarshal(cell *boc.Cell, ty tolkParser.UintN, decoder *Decoder) error { num, err := cell.ReadUint(ty.N) if err != nil { return err @@ -183,95 +68,47 @@ func (i *UInt64) UnmarshalTolk(cell *boc.Cell, ty UintN, decoder *Decoder) error 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 (i *UInt64) Marshal(cell *boc.Cell, ty tolkParser.UintN, encoder *Encoder) error { + return cell.WriteUint(uint64(*i), ty.N) } -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 - } +func (i *UInt64) Equal(other any) bool { + otherUint, ok := other.(UInt64) + if !ok { + return false } - - return nil + return *i == otherUint } -func (u UintN) GetFixedSize() int { - return u.N -} +type BigUInt big.Int -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 +func (b *BigUInt) Unmarshal(cell *boc.Cell, ty tolkParser.UintN, decoder *Decoder) error { + num, err := cell.ReadBigUint(ty.N) + if err != nil { + return err } - - return *v.smallUint == *o.smallUint + *b = BigUInt(*num) + return nil } -type VarIntN struct { - N int `json:"n"` +func (b *BigUInt) Marshal(cell *boc.Cell, ty tolkParser.UintN, encoder *Encoder) error { + bi := big.Int(*b) + return cell.WriteBigUint(&bi, ty.N) } -func (VarIntN) SetValue(v *Value, val any) error { - bi, ok := val.(BigInt) +func (b *BigUInt) Equal(other any) bool { + otherBigInt, ok := other.(BigUInt) if !ok { - return fmt.Errorf("value is not a BigInt") + return false } - v.bigInt = &bi - v.sumType = "bigInt" - return nil + bi := big.Int(*b) + otherBi := big.Int(otherBigInt) + return bi.Cmp(&otherBi) == 0 } -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 -} +type VarInt big.Int -func (vi *VarInt) UnmarshalTolk(cell *boc.Cell, ty VarIntN, decoder *Decoder) error { +func (vi *VarInt) Unmarshal(cell *boc.Cell, ty tolkParser.VarIntN, decoder *Decoder) error { ln, err := cell.ReadLimUint(ty.N - 1) if err != nil { return err @@ -284,13 +121,10 @@ func (vi *VarInt) UnmarshalTolk(cell *boc.Cell, ty VarIntN, decoder *Decoder) er 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) +func (vi *VarInt) Marshal(cell *boc.Cell, ty tolkParser.VarIntN, encoder *Encoder) error { + bi := big.Int(*vi) num := bi.Bytes() - err := cell.WriteLimUint(len(num), vi.N-1) + err := cell.WriteLimUint(len(num), ty.N-1) if err != nil { return err } @@ -302,42 +136,19 @@ func (vi VarIntN) MarshalTolk(cell *boc.Cell, v *Value) error { 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) +func (vi *VarInt) Equal(other any) bool { + otherBigInt, ok := other.(VarInt) if !ok { - return fmt.Errorf("value is not a BigInt") + return false } - v.bigInt = &vu - v.sumType = "bigInt" - return nil + bi := big.Int(*vi) + otherBi := big.Int(otherBigInt) + return bi.Cmp(&otherBi) == 0 } -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 -} +type VarUInt big.Int -func (vu *VarUInt) UnmarshalTolk(cell *boc.Cell, ty VarUintN, decoder *Decoder) error { +func (vu *VarUInt) Unmarshal(cell *boc.Cell, ty tolkParser.VarUintN, decoder *Decoder) error { ln, err := cell.ReadLimUint(ty.N - 1) if err != nil { return err @@ -350,13 +161,10 @@ func (vu *VarUInt) UnmarshalTolk(cell *boc.Cell, ty VarUintN, decoder *Decoder) 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) +func (vu *VarUInt) Marshal(cell *boc.Cell, ty tolkParser.VarUintN, encoder *Encoder) error { + bi := big.Int(*vu) num := bi.Bytes() - err := cell.WriteLimUint(len(num), vu.N-1) + err := cell.WriteLimUint(len(num), ty.N-1) if err != nil { return err } @@ -368,38 +176,19 @@ func (vu VarUintN) MarshalTolk(cell *boc.Cell, v *Value) error { 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) +func (vu *VarUInt) Equal(other any) bool { + otherBigInt, ok := other.(VarUInt) if !ok { - return fmt.Errorf("value is not a Bits") + return false } - v.bits = &bits - v.sumType = "bits" - return nil + bi := big.Int(*vu) + otherBi := big.Int(otherBigInt) + return bi.Cmp(&otherBi) == 0 } -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 -} +type Bits boc.BitString -func (b *Bits) UnmarshalTolk(cell *boc.Cell, ty BitsN, decoder *Decoder) error { +func (b *Bits) Unmarshal(cell *boc.Cell, ty tolkParser.BitsN, decoder *Decoder) error { val, err := cell.ReadBits(ty.N) if err != nil { return err @@ -408,11 +197,8 @@ func (b *Bits) UnmarshalTolk(cell *boc.Cell, ty BitsN, decoder *Decoder) error { 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) +func (b *Bits) Marshal(cell *boc.Cell, ty tolkParser.BitsN, encoder *Encoder) error { + bi := boc.BitString(*b) err := cell.WriteBitString(bi) if err != nil { return err @@ -421,49 +207,19 @@ func (BitsN) MarshalTolk(cell *boc.Cell, v *Value) error { 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 { +func (b *Bits) Equal(other any) bool { + otherBits, ok := other.(Bits) + if !ok { return false } - vb := boc.BitString(*v.bits) - ob := boc.BitString(*o.bits) - return bytes.Equal(vb.Buffer(), ob.Buffer()) + bs := boc.BitString(*b) + otherBs := boc.BitString(otherBits) + return bytes.Equal(bs.Buffer(), otherBs.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 -} +type CoinsValue big.Int -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 { +func (c *CoinsValue) Unmarshal(cell *boc.Cell, ty tolkParser.Coins, decoder *Decoder) error { ln, err := cell.ReadLimUint(15) if err != nil { return err @@ -476,53 +232,32 @@ func (c *CoinsValue) UnmarshalTolk(cell *boc.Cell, ty Coins, decoder *Decoder) e 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 +func (c *CoinsValue) Marshal(cell *boc.Cell, ty tolkParser.Coins, encoder *Encoder) error { + varInt := VarInt(*c) + return varInt.Marshal(cell, tolkParser.VarIntN{N: 16}, encoder) // coins is actually varint16 } -type Bool struct{} - -func (Bool) SetValue(v *Value, val any) error { - b, ok := val.(BoolValue) +func (c *CoinsValue) Equal(other any) bool { + otherBigInt, ok := other.(CoinsValue) if !ok { - return fmt.Errorf("value is not a BoolValue") + return false } - v.bool = &b - v.sumType = "bool" - return nil + bi := big.Int(*c) + otherBi := big.Int(otherBigInt) + return bi.Cmp(&otherBi) == 0 } -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 +type BoolValue bool + +func (b *BoolValue) Equal(o any) bool { + otherBool, ok := o.(BoolValue) + if !ok { + return false } - return nil + return *b == otherBool } -func (b *BoolValue) UnmarshalTolk(cell *boc.Cell, ty Bool, decoder *Decoder) error { +func (b *BoolValue) Unmarshal(cell *boc.Cell, ty tolkParser.Bool, decoder *Decoder) error { val, err := cell.ReadBit() if err != nil { return err @@ -531,19 +266,11 @@ func (b *BoolValue) UnmarshalTolk(cell *boc.Cell, ty Bool, decoder *Decoder) err 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)) +func (b *BoolValue) Marshal(cell *boc.Cell, ty tolkParser.Bool, encoder *Encoder) error { + err := cell.WriteBit(bool(*b)) 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 index 702faf9f..45e17220 100644 --- a/tolk/map.go +++ b/tolk/map.go @@ -2,76 +2,24 @@ package tolk import ( "fmt" + "math" "github.com/tonkeeper/tongo/boc" + "github.com/tonkeeper/tongo/tolk/parser" ) -type TolkType interface { - UnmarshalTolk(cell *boc.Cell, v *Value, decoder *Decoder) error +type MapValue struct { + keys []Value + values []Value + len int } -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() +func (m *MapValue) Unmarshal(cell *boc.Cell, ty tolkParser.Map, decoder *Decoder) error { + keySize, ok := ty.K.GetFixedSize() if !ok { return fmt.Errorf("%v is not comparable", ty.K.SumType) } - keySize := cmp.GetFixedSize() - keyPrefix := boc.NewBitString(cmp.GetFixedSize()) + keyPrefix := boc.NewBitString(keySize) isNotEmpty, err := cell.ReadBit() if err != nil { @@ -103,7 +51,7 @@ func mapInner( keySize, leftKeySize int, c *boc.Cell, keyPrefix *boc.BitString, - kt, vt Ty, + kt, vt tolkParser.Ty, keys, values *[]Value, decoder *Decoder, ) error { @@ -150,7 +98,7 @@ func mapInner( } // add node to map v := Value{} - err = v.UnmarshalTolk(c, vt, decoder) + err = v.Unmarshal(c, vt, decoder) if err != nil { return err } @@ -162,7 +110,7 @@ func mapInner( } k := Value{} cell := boc.NewCellWithBits(key) - err = k.UnmarshalTolk(cell, kt, decoder) + err = k.Unmarshal(cell, kt, decoder) if err != nil { return err } @@ -236,178 +184,433 @@ func loadLabel(size int, c *boc.Cell, key *boc.BitString) (int, *boc.BitString, return int(ln), key, nil } -func (Map) MarshalTolk(cell *boc.Cell, v *Value) error { +func (m *MapValue) Marshal(cell *boc.Cell, ty tolkParser.Map, encoder *Encoder) error { + keySize, ok := ty.K.GetFixedSize() + if !ok { + return fmt.Errorf("map key is not a comparable type, got %v", ty.K.SumType) + } + + if len(m.keys) != len(m.values) { + return fmt.Errorf("map keys and values lengths do not match") + } + + if len(m.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, len(m.keys)) + for i, k := range m.keys { + keyCell := boc.NewCell() + err = k.Marshal(keyCell, ty.K, encoder) + if err != nil { + return err + } + keys[i] = keyCell.RawBitString() + } + + ref := boc.NewCell() + err = encodeMap(ref, keys, m.values, keySize, ty.V, encoder) + 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 tolkParser.Ty, encoder *Encoder) 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, encoder) + if err != nil { + return err + } + r, err := c.NewRef() + if err != nil { + return err + } + err = encodeMap(r, rightKeys, rightValues, keySize, vt, encoder) + if err != nil { + return err + } + return err + } + // marshal value + err = values[0].Marshal(c, vt, encoder) + 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() + labelLen := label.BitsAvailableForRead() + + // We must find the most compact way to serialize key + hmlShortSize := 2*labelLen + 2 + hmlLongSize := 2 + int(math.Ceil(math.Log2(float64(keySize)+1))) + labelLen + var encodeFunc func(*boc.Cell, int, boc.BitString) error + isShort := false + if hmlShortSize <= hmlLongSize { + isShort = true + encodeFunc = encodeShortLabel + } else { + encodeFunc = encodeLongLabel + } + + // If all bits in label are the same then we can use hml_same + isAllZero := true + isAllOne := true + for label.BitsAvailableForRead() > 0 { + bit, err := label.ReadBit() + if err != nil { + return boc.BitString{}, err + } + if bit { + isAllZero = false + } else { + isAllOne = false + } + } + label.ResetCounter() + if isAllZero || isAllOne { + hmlSameSize := 2 + 1 + int(math.Ceil(math.Log2(float64(keySize)+1))) + if isShort && hmlSameSize < hmlShortSize { + encodeFunc = encodeSameLabel + } else if !isShort && hmlSameSize < hmlLongSize { + encodeFunc = encodeSameLabel + } + } + + err := encodeFunc(c, keySize, label) + if err != nil { + return boc.BitString{}, err + } + return label, nil +} + +func encodeShortLabel(c *boc.Cell, keySize int, label boc.BitString) error { + //hml_short$0 {m:#} {n:#} len:(Unary ~n) {n <= m} s:(n * Bit) = HmLabel ~n m; + err := c.WriteBit(false) + if err != nil { + return err + } + err = c.WriteUnary(uint(label.BitsAvailableForRead())) + if err != nil { + return err + } + err = c.WriteBitString(label) + if err != nil { + return err + } + return nil +} + +func encodeLongLabel(c *boc.Cell, keySize int, label boc.BitString) error { + // hml_long$10 {m:#} n:(#<= m) s:(n * Bit) = HmLabel ~n m; + err := c.WriteBit(true) + if err != nil { + return err + } + err = c.WriteBit(false) + if err != nil { + return err + } + err = c.WriteLimUint(label.BitsAvailableForRead(), keySize) + if err != nil { + return err + } + err = c.WriteBitString(label) + if err != nil { + return err + } 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 +func encodeSameLabel(c *boc.Cell, keySize int, label boc.BitString) error { + //hml_same$11 {m:#} v:Bit n:(#<= m) = HmLabel ~n m; + err := c.WriteUint(0b11, 2) + if err != nil { + return err + } + err = c.WriteBit(label.BinaryString()[0] == '1') + if err != nil { + return err + } + err = c.WriteLimUint(label.BitsAvailableForRead(), keySize) + if err != nil { + return err + } + return nil +} + +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 Value) (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 := Value{ + sumType: "smallInt", + smallInt: &v, + } + return m.Get(key) +} + +func (m *MapValue) GetBySmallUInt(v UInt64) (Value, bool) { + key := Value{ + sumType: "smallUint", + smallUint: &v, + } + return m.Get(key) +} + +func (m *MapValue) GetByBigInt(v BigInt) (Value, bool) { + key := Value{ + sumType: "bigInt", + bigInt: &v, + } + return m.Get(key) +} + +func (m *MapValue) GetByBigUInt(v BigUInt) (Value, bool) { + key := Value{ + sumType: "bigUint", + bigUint: &v, + } + return m.Get(key) +} + +func (m *MapValue) GetByBits(v Bits) (Value, bool) { + key := Value{ + sumType: "bits", + bits: &v, + } + return m.Get(key) +} + +func (m *MapValue) GetByInternalAddress(v InternalAddress) (Value, bool) { + key := Value{ + sumType: "internalAddress", + internalAddress: &v, + } + return m.Get(key) +} + +func (m *MapValue) Set(key Value, 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 := Value{ + sumType: "smallInt", + smallInt: &k, + } + return m.Set(key, value) +} + +func (m *MapValue) SetBySmallUInt(k UInt64, value Value) (bool, error) { + key := Value{ + sumType: "smallUint", + smallUint: &k, + } + return m.Set(key, value) +} + +func (m *MapValue) SetByBigInt(k BigInt, value Value) (bool, error) { + key := Value{ + sumType: "bigInt", + bigInt: &k, + } + return m.Set(key, value) +} + +func (m *MapValue) SetByBigUInt(k BigUInt, value Value) (bool, error) { + key := Value{ + sumType: "bigUint", + bigUint: &k, + } + return m.Set(key, value) +} + +func (m *MapValue) SetByBits(k Bits, value Value) (bool, error) { + key := Value{ + sumType: "bits", + bits: &k, + } + return m.Set(key, value) +} + +func (m *MapValue) SetByInternalAddress(k InternalAddress, value Value) (bool, error) { + key := Value{ + sumType: "internalAddress", + internalAddress: &k, + } + return m.Set(key, value) +} + +func (m *MapValue) Delete(key Value) { + 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 := Value{ + sumType: "smallInt", + smallInt: &k, + } + m.Delete(key) +} + +func (m *MapValue) DeleteBySmallUInt(k UInt64) { + key := Value{ + sumType: "smallUint", + smallUint: &k, + } + m.Delete(key) +} + +func (m *MapValue) DeleteByBigInt(k BigInt) { + key := Value{ + sumType: "bigInt", + bigInt: &k, + } + m.Delete(key) +} + +func (m *MapValue) DeleteByBigUInt(k BigUInt) { + key := Value{ + sumType: "bigUint", + bigUint: &k, + } + m.Delete(key) +} + +func (m *MapValue) DeleteByBits(k Bits) { + key := Value{ + sumType: "bits", + bits: &k, + } + m.Delete(key) +} + +func (m *MapValue) DeleteByInternalAddress(k InternalAddress) { + key := Value{ + sumType: "internalAddress", + internalAddress: &k, + } + m.Delete(key) +} + +func (m *MapValue) Len() int { + return m.len } diff --git a/tolk/null.go b/tolk/null.go index 4d61bccc..c6c6b054 100644 --- a/tolk/null.go +++ b/tolk/null.go @@ -2,50 +2,41 @@ package tolk import ( "github.com/tonkeeper/tongo/boc" + "github.com/tonkeeper/tongo/tolk/parser" ) -type NullLiteral struct{} +type NullValue 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) Equal(other any) bool { + _, ok := other.(NullValue) + if !ok { + return false + } + return true } -func (n *NullValue) UnmarshalTolk(cell *boc.Cell, ty NullLiteral, decoder *Decoder) error { +func (n *NullValue) Unmarshal(cell *boc.Cell, ty tolkParser.NullLiteral, decoder *Decoder) error { return nil } -func (NullLiteral) MarshalTolk(cell *boc.Cell, v *Value) error { +func (n *NullValue) Marshal(cell *boc.Cell, ty tolkParser.NullLiteral, encoder *Encoder) error { return nil } -func (NullLiteral) Equal(v Value, o Value) bool { - return false -} - -type Void struct{} +type VoidValue 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) Equal(other any) bool { + _, ok := other.(VoidValue) + if !ok { + return false + } + return true } -func (v *VoidValue) UnmarshalTolk(cell *boc.Cell, ty Void, decoder *Decoder) error { +func (v *VoidValue) Unmarshal(cell *boc.Cell, ty tolkParser.Void, decoder *Decoder) error { return nil } -func (Void) MarshalTolk(cell *boc.Cell, v *Value) error { +func (v *VoidValue) Marshal(cell *boc.Cell, ty tolkParser.Void, encoder *Encoder) 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 deleted file mode 100644 index c417f6ac..00000000 --- a/tolk/parser/parser.go +++ /dev/null @@ -1,655 +0,0 @@ -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/abi_types.go b/tolk/parser/types.go similarity index 54% rename from tolk/abi_types.go rename to tolk/parser/types.go index 5788fb8c..e31fb4a3 100644 --- a/tolk/abi_types.go +++ b/tolk/parser/types.go @@ -1,13 +1,10 @@ -package tolk +package tolkParser import ( - "encoding/hex" "encoding/json" "fmt" "math/big" - "github.com/tonkeeper/tongo/boc" - "github.com/tonkeeper/tongo/ton" "github.com/tonkeeper/tongo/utils" ) @@ -247,74 +244,6 @@ func (d *DefaultValue) MarshalJSON() ([]byte, error) { 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"` @@ -368,6 +297,101 @@ type Ty struct { Void *Void } +type Int struct{} + +type IntN struct { + N int `json:"n"` +} + +type UintN struct { + N int `json:"n"` +} + +type VarIntN struct { + N int `json:"n"` +} + +type VarUintN struct { + N int `json:"n"` +} + +type BitsN struct { + N int `json:"n"` +} + +type Coins struct { +} + +type Bool struct{} + +type Address struct{} + +type AddressOpt struct { +} + +type AddressExt struct{} + +type AddressAny struct{} + +type Cell struct{} + +type Slice struct{} + +type Builder struct{} + +type Callable struct{} + +type Remaining struct{} + +type Nullable struct { + Inner Ty `json:"inner"` +} + +type CellOf struct { + Inner Ty `json:"inner"` +} + +type Map struct { + K Ty `json:"k"` + V Ty `json:"v"` +} + +type NullLiteral struct{} + +type Void struct{} + +type EnumRef struct { + EnumName string `json:"enumName"` +} + +type StructRef struct { + StructName string `json:"structName"` + TypeArgs []Ty `json:"typeArgs,omitempty"` +} + +type AliasRef struct { + AliasName string `json:"aliasName"` + TypeArgs []Ty `json:"typeArgs,omitempty"` +} + +type Generic struct { + NameT string `json:"nameT"` +} + +type Tensor struct { + Items []Ty `json:"items"` +} + +type TupleWith struct { + Items []Ty `json:"items"` +} + +type TupleAny struct{} + +type Union struct { + Variants []UnionVariant `json:"variants"` +} + func (t *Ty) UnmarshalJSON(b []byte) error { var kind Kind if err := json.Unmarshal(b, &kind); err != nil { @@ -639,453 +663,23 @@ func (t *Ty) MarshalJSON() ([]byte, error) { return concatPrefixAndPayload(prefix, payload), nil } -func (t *Ty) UnmarshalTolk2(cell *boc.Cell, v *Value, decoder *Decoder) error { +func (t *Ty) GetFixedSize() (int, bool) { 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 + return t.IntN.N, true 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 + return t.UintN.N, true 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 + return t.BitsN.N, true 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 + return 1, true 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 + return 267, true default: - return fmt.Errorf("unknown type %q", t.SumType) + return 0, false } } -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"` diff --git a/tolk/refs.go b/tolk/refs.go index 103687de..be2cf601 100644 --- a/tolk/refs.go +++ b/tolk/refs.go @@ -3,199 +3,36 @@ package tolk import ( "fmt" "math/big" + "slices" "github.com/tonkeeper/tongo/boc" + "github.com/tonkeeper/tongo/tolk/parser" "golang.org/x/exp/maps" ) -type EnumRef struct { - EnumName string `json:"enumName"` +type Prefix struct { + Len int16 + Prefix uint64 } -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 +type Struct struct { + hasPrefix bool + prefix Prefix + fieldNames []string + fieldValues []Value } -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 { +func (s *Struct) Unmarshal(cell *boc.Cell, ty tolkParser.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[s.StructName] + strct, found := decoder.abiRefs.structRefs[ty.StructName] if !found { - return fmt.Errorf("no struct with name %s was found in given abi", s.StructName) + return fmt.Errorf("no struct with name %s was found in given abi", ty.StructName) } tolkStruct := Struct{ - field: make(map[string]Value), + fieldNames: make([]string, 0), + fieldValues: make([]Value, 0), } if strct.Prefix != nil { prefixLen := strct.Prefix.PrefixLen @@ -216,14 +53,14 @@ func (s StructRef) UnmarshalTolk(cell *boc.Cell, v *Value, decoder *Decoder) err return fmt.Errorf("struct %v prefix does not match actual prefix %v", strct.Name, actualPrefix) } tolkStruct.hasPrefix = true - tolkStruct.prefix = TolkPrefix{ + tolkStruct.prefix = Prefix{ Len: int16(prefixLen), Prefix: prefix, } } oldGenericMap := decoder.abiRefs.genericRefs - genericMap, err := resolveGeneric(s.TypeArgs, strct.TypeParams, decoder) + genericMap, err := resolveGeneric(ty.TypeArgs, strct.TypeParams, &decoder.abiRefs) if err != nil { return err } @@ -231,7 +68,7 @@ func (s StructRef) UnmarshalTolk(cell *boc.Cell, v *Value, decoder *Decoder) err for _, field := range strct.Fields { fieldVal := Value{} - err = fieldVal.UnmarshalTolk(cell, field.Ty, decoder) + err = fieldVal.Unmarshal(cell, field.Ty, decoder) if err != nil { return err } @@ -241,7 +78,7 @@ func (s StructRef) UnmarshalTolk(cell *boc.Cell, v *Value, decoder *Decoder) err defVal := field.DefaultValue if !optVal.IsExists && defVal != nil { val := Value{} - exists, err := defVal.unmarshalDefaultValue(&val, field.Ty) + exists, err := val.unmarshalDefaultValue(defVal, field.Ty) if err != nil { return err } @@ -252,166 +89,241 @@ func (s StructRef) UnmarshalTolk(cell *boc.Cell, v *Value, decoder *Decoder) err } } - tolkStruct.field[field.Name] = fieldVal + tolkStruct.fieldNames = append(tolkStruct.fieldNames, field.Name) + tolkStruct.fieldValues = append(tolkStruct.fieldValues, fieldVal) } - decoder.abiRefs.genericRefs = oldGenericMap - err = s.SetValue(v, tolkStruct) - if err != nil { - return err - } + decoder.abiRefs.genericRefs = oldGenericMap + *s = tolkStruct return nil } -func (s *Struct) UnmarshalTolk(cell *boc.Cell, ty StructRef, decoder *Decoder) error { - if decoder.abiRefs.structRefs == nil { +func (s *Struct) Marshal(cell *boc.Cell, ty tolkParser.StructRef, encoder *Encoder) error { + if encoder.abiRefs.structRefs == nil { return fmt.Errorf("struct has struct reference, but no abi has been given") } - strct, found := decoder.abiRefs.structRefs[ty.StructName] + strct, found := encoder.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 - } + if strct.Prefix != nil { actualPrefix, err := binHexToUint64(strct.Prefix.PrefixStr) if err != nil { return err } - if prefix != actualPrefix { + if s.prefix.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, + + err = cell.WriteUint(s.prefix.Prefix, int(s.prefix.Len)) + if err != nil { + return err } } - oldGenericMap := decoder.abiRefs.genericRefs - genericMap, err := resolveGeneric(ty.TypeArgs, strct.TypeParams, decoder) + oldGenericMap := encoder.abiRefs.genericRefs + genericMap, err := resolveGeneric(ty.TypeArgs, strct.TypeParams, &encoder.abiRefs) if err != nil { return err } - decoder.abiRefs.genericRefs = genericMap + encoder.abiRefs.genericRefs = genericMap for _, field := range strct.Fields { - fieldVal := Value{} - err = fieldVal.UnmarshalTolk(cell, field.Ty, decoder) - if err != nil { - return err + val, ok := s.GetField(field.Name) + if !ok { + return fmt.Errorf("struct %v has no field %v", strct.Name, field.Name) } - 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 - } - } + err = val.Marshal(cell, field.Ty, encoder) + if err != nil { + return err } - - tolkStruct.field[field.Name] = fieldVal } - decoder.abiRefs.genericRefs = oldGenericMap - *s = tolkStruct + encoder.abiRefs.genericRefs = oldGenericMap 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 (s *Struct) GetField(field string) (Value, bool) { + for i, name := range s.fieldNames { + if name == field { + return s.fieldValues[i], true + } + } + return Value{}, false } -func (StructRef) Equal(v Value, o Value) bool { +func (s *Struct) SetField(field string, v Value) bool { + for i, name := range s.fieldNames { + if name == field { + s.fieldValues[i] = v + return true + } + } return false } -type AliasRef struct { - AliasName string `json:"aliasName"` - TypeArgs []Ty `json:"typeArgs,omitempty"` +func (s *Struct) RemoveField(field string) { + for i, name := range s.fieldNames { + if name == field { + s.fieldNames[i] = "|" // impossible symbol for field name in Tolk language + s.fieldValues[i] = Value{} + } + } } -func (AliasRef) SetValue(v *Value, val any) error { - return fmt.Errorf("alias cannot be a value") +func (s *Struct) GetPrefix() (Prefix, bool) { + if !s.hasPrefix { + return Prefix{}, false + } + + return s.prefix, true } -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") +func (s *Struct) Equal(o any) bool { + otherStruct, ok := o.(Struct) + if !ok { + return false } - 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 s.hasPrefix != otherStruct.hasPrefix { + return false + } + if s.hasPrefix { + if s.prefix != otherStruct.prefix { + return false + } } + if !slices.Equal(s.fieldNames, otherStruct.fieldNames) { + return false + } + return slices.Equal(s.fieldValues, otherStruct.fieldValues) +} - if alias.CustomUnpackFromSlice { - // todo: maybe simply return error? - fmt.Println("WARNING! alias has custom unpack method. Standard unpacking can be incorrect!") +type EnumValue struct { + val Value + Name string + Value big.Int +} + +func (e *EnumValue) Unmarshal(cell *boc.Cell, ty tolkParser.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) } - oldGenericMap := decoder.abiRefs.genericRefs - genericMap, err := resolveGeneric(a.TypeArgs, alias.TypeParams, decoder) + enumVal := Value{} + err := enumVal.Unmarshal(cell, enum.EncodedAs, decoder) if err != nil { return err } - decoder.abiRefs.genericRefs = genericMap + 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.bigUint) + } 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) + } - val := Value{} - err = val.UnmarshalTolk(cell, alias.TargetTy, decoder) - if err != nil { - return err + 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 (e *EnumValue) Marshal(cell *boc.Cell, ty tolkParser.EnumRef, encoder *Encoder) error { + if encoder.abiRefs.enumRefs == nil { + return fmt.Errorf("struct has enum reference, but no abi has been given") + } + enum, found := encoder.abiRefs.enumRefs[ty.EnumName] + if !found { + return fmt.Errorf("no enum with name %s was found in given abi", ty.EnumName) } - decoder.abiRefs.genericRefs = oldGenericMap - fmt.Println(123) - err = a.SetValue(v, val) + err := e.val.Marshal(cell, enum.EncodedAs, encoder) if err != nil { return err } - return nil + 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(&e.Value) == 0 { + return nil + } + } + return fmt.Errorf("enum value not matcher, got: %s", e.Value.String()) +} + +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 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)) } -func (a *AliasValue) UnmarshalTolk(cell *boc.Cell, ty AliasRef, decoder *Decoder) error { +func (a *AliasValue) Unmarshal(cell *boc.Cell, ty tolkParser.AliasRef, decoder *Decoder) error { if decoder.abiRefs.aliasRefs == nil { return fmt.Errorf("struct has alias reference, but no abi has been given") } @@ -422,18 +334,18 @@ func (a *AliasValue) UnmarshalTolk(cell *boc.Cell, ty AliasRef, decoder *Decoder if alias.CustomUnpackFromSlice { // todo: maybe simply return error? - fmt.Println("WARNING! alias has custom unpack method. Standard unpacking can be incorrect!") + fmt.Println("WARNING! alias has custom unpack method. Default unpacking can be incorrect!") } oldGenericMap := decoder.abiRefs.genericRefs - genericMap, err := resolveGeneric(ty.TypeArgs, alias.TypeParams, decoder) + genericMap, err := resolveGeneric(ty.TypeArgs, alias.TypeParams, &decoder.abiRefs) if err != nil { return err } decoder.abiRefs.genericRefs = genericMap val := Value{} - err = val.UnmarshalTolk(cell, alias.TargetTy, decoder) + err = val.Unmarshal(cell, alias.TargetTy, decoder) if err != nil { return err } @@ -444,48 +356,56 @@ func (a *AliasValue) UnmarshalTolk(cell *boc.Cell, ty AliasRef, decoder *Decoder 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] +func (a *AliasValue) Marshal(cell *boc.Cell, ty tolkParser.AliasRef, encoder *Encoder) error { + if encoder.abiRefs.aliasRefs == nil { + return fmt.Errorf("struct has alias reference, but no abi has been given") + } + alias, found := encoder.abiRefs.aliasRefs[ty.AliasName] if !found { - return fmt.Errorf("cannot resolve generic type %v ", g) + return fmt.Errorf("no alias with name %s was found in given abi", ty.AliasName) } - val := Value{} - err := val.UnmarshalTolk(cell, currentTy, decoder) + + if alias.CustomPackToBuilder { + // todo: maybe simply return error? + fmt.Println("WARNING! alias has custom pack method. Default packing can be incorrect!") + } + + oldGenericMap := encoder.abiRefs.genericRefs + genericMap, err := resolveGeneric(ty.TypeArgs, alias.TypeParams, &encoder.abiRefs) if err != nil { return err } + encoder.abiRefs.genericRefs = genericMap - err = g.SetValue(v, val) + val := Value(*a) + err = val.Marshal(cell, alias.TargetTy, encoder) if err != nil { return err } + encoder.abiRefs.genericRefs = oldGenericMap + return nil } -func (g *GenericValue) UnmarshalTolk(cell *boc.Cell, ty Generic, decoder *Decoder) error { +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)) +} + +func (g *GenericValue) Unmarshal(cell *boc.Cell, ty tolkParser.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) + err := val.Unmarshal(cell, currentTy, decoder) if err != nil { return err } @@ -495,29 +415,35 @@ func (g *GenericValue) UnmarshalTolk(cell *boc.Cell, ty Generic, decoder *Decode return nil } -func (Generic) MarshalTolk(cell *boc.Cell, v *Value) error { - return fmt.Errorf("generic cannot be a value") -} +func (g *GenericValue) Marshal(cell *boc.Cell, ty tolkParser.Generic, encoder *Encoder) error { + currentTy, found := encoder.abiRefs.genericRefs[ty.NameT] + if !found { + return fmt.Errorf("cannot resolve generic type %v ", ty.NameT) + } + val := Value(*g) + err := val.Marshal(cell, currentTy, encoder) + if err != nil { + return err + } -func (Generic) Equal(v Value, o Value) bool { - return false + return nil } -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) +func resolveGeneric(typeArgs []tolkParser.Ty, typeParams []string, abiRefs *abiRefs) (map[string]tolkParser.Ty, error) { + genericMap := make(map[string]tolkParser.Ty) + if abiRefs.genericRefs != nil { + maps.Copy(genericMap, abiRefs.genericRefs) } for i, genericTy := range typeArgs { genericMap[typeParams[i]] = genericTy if genericTy.SumType == "Generic" { - if d.abiRefs.genericRefs == nil { + if abiRefs.genericRefs == nil { return nil, fmt.Errorf("cannot resolve generic type %v", genericTy.Generic.NameT) } - ty, found := d.abiRefs.genericRefs[genericTy.Generic.NameT] + ty, found := abiRefs.genericRefs[genericTy.Generic.NameT] if !found { return nil, fmt.Errorf("generic type %v not found", genericTy.Generic.NameT) } diff --git a/tolk/runtime.go b/tolk/runtime.go index b567914b..a438db9d 100644 --- a/tolk/runtime.go +++ b/tolk/runtime.go @@ -2,17 +2,24 @@ package tolk import ( "github.com/tonkeeper/tongo/boc" + "github.com/tonkeeper/tongo/tolk/parser" ) -type TolkUnmarshaler interface { - UnmarshalTolk(cell *boc.Cell, v *Value, d *Decoder) error +func Unmarshal(cell *boc.Cell, ty tolkParser.Ty) (*Value, error) { + d := NewDecoder() + return d.Unmarshal(cell, ty) +} + +func Marshal(v *Value, ty tolkParser.Ty) (*boc.Cell, error) { + e := NewEncoder() + return e.Marshal(v, ty) } type abiRefs struct { - structRefs map[string]StructDeclaration - aliasRefs map[string]AliasDeclaration - enumRefs map[string]EnumDeclaration - genericRefs map[string]Ty + structRefs map[string]tolkParser.StructDeclaration + aliasRefs map[string]tolkParser.AliasDeclaration + enumRefs map[string]tolkParser.EnumDeclaration + genericRefs map[string]tolkParser.Ty } type Decoder struct { @@ -23,12 +30,12 @@ func NewDecoder() *Decoder { return &Decoder{} } -func (a *Decoder) WithABI(abi ABI) *Decoder { +func (a *Decoder) WithABI(abi tolkParser.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), + structRefs: make(map[string]tolkParser.StructDeclaration), + aliasRefs: make(map[string]tolkParser.AliasDeclaration), + enumRefs: make(map[string]tolkParser.EnumDeclaration), + genericRefs: make(map[string]tolkParser.Ty), } for _, declr := range abi.Declarations { switch declr.SumType { @@ -43,21 +50,48 @@ func (a *Decoder) WithABI(abi ABI) *Decoder { 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) { +func (a *Decoder) Unmarshal(cell *boc.Cell, ty tolkParser.Ty) (*Value, error) { res := &Value{} - err := res.UnmarshalTolk(cell, ty, a) + err := res.Unmarshal(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) +type Encoder struct { + abiRefs abiRefs +} + +func NewEncoder() *Encoder { + return &Encoder{} +} + +func (a *Encoder) WithABI(abi tolkParser.ABI) *Encoder { + a.abiRefs = abiRefs{ + structRefs: make(map[string]tolkParser.StructDeclaration), + aliasRefs: make(map[string]tolkParser.AliasDeclaration), + enumRefs: make(map[string]tolkParser.EnumDeclaration), + genericRefs: make(map[string]tolkParser.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 (a *Encoder) Marshal(v *Value, ty tolkParser.Ty) (*boc.Cell, error) { + cell := boc.NewCell() + err := v.Marshal(cell, ty, a) + if err != nil { + return nil, err + } + return cell, nil } diff --git a/tolk/runtime_test.go b/tolk/runtime_test.go index 318172da..c56dfbf2 100644 --- a/tolk/runtime_test.go +++ b/tolk/runtime_test.go @@ -10,13 +10,14 @@ import ( "github.com/tonkeeper/tongo" "github.com/tonkeeper/tongo/boc" + "github.com/tonkeeper/tongo/tolk/parser" "github.com/tonkeeper/tongo/ton" ) func TestRuntime_UnmarshalSmallInt(t *testing.T) { - ty := Ty{ + ty := tolkParser.Ty{ SumType: "IntN", - IntN: &IntN{ + IntN: &tolkParser.IntN{ N: 24, }, } @@ -25,7 +26,7 @@ func TestRuntime_UnmarshalSmallInt(t *testing.T) { if err != nil { t.Fatal(err) } - v, err := UnmarshalTolk(currCell[0], ty) + v, err := Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } @@ -40,9 +41,9 @@ func TestRuntime_UnmarshalSmallInt(t *testing.T) { } func TestRuntime_UnmarshalBigInt(t *testing.T) { - ty := Ty{ + ty := tolkParser.Ty{ SumType: "IntN", - IntN: &IntN{ + IntN: &tolkParser.IntN{ N: 183, }, } @@ -51,7 +52,7 @@ func TestRuntime_UnmarshalBigInt(t *testing.T) { if err != nil { t.Fatal(err) } - v, err := UnmarshalTolk(currCell[0], ty) + v, err := Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } @@ -66,9 +67,9 @@ func TestRuntime_UnmarshalBigInt(t *testing.T) { } func TestRuntime_UnmarshalSmallUInt(t *testing.T) { - ty := Ty{ + ty := tolkParser.Ty{ SumType: "UintN", - UintN: &UintN{ + UintN: &tolkParser.UintN{ N: 53, }, } @@ -77,7 +78,7 @@ func TestRuntime_UnmarshalSmallUInt(t *testing.T) { if err != nil { t.Fatal(err) } - v, err := UnmarshalTolk(currCell[0], ty) + v, err := Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } @@ -92,9 +93,9 @@ func TestRuntime_UnmarshalSmallUInt(t *testing.T) { } func TestRuntime_UnmarshalBigUInt(t *testing.T) { - ty := Ty{ + ty := tolkParser.Ty{ SumType: "UintN", - UintN: &UintN{ + UintN: &tolkParser.UintN{ N: 257, }, } @@ -103,7 +104,7 @@ func TestRuntime_UnmarshalBigUInt(t *testing.T) { if err != nil { t.Fatal(err) } - v, err := UnmarshalTolk(currCell[0], ty) + v, err := Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } @@ -118,9 +119,9 @@ func TestRuntime_UnmarshalBigUInt(t *testing.T) { } func TestRuntime_UnmarshalVarInt(t *testing.T) { - ty := Ty{ + ty := tolkParser.Ty{ SumType: "VarIntN", - VarIntN: &VarIntN{ + VarIntN: &tolkParser.VarIntN{ N: 16, }, } @@ -129,7 +130,7 @@ func TestRuntime_UnmarshalVarInt(t *testing.T) { if err != nil { t.Fatal(err) } - v, err := UnmarshalTolk(currCell[0], ty) + v, err := Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } @@ -144,9 +145,9 @@ func TestRuntime_UnmarshalVarInt(t *testing.T) { } func TestRuntime_UnmarshalVarUInt(t *testing.T) { - ty := Ty{ + ty := tolkParser.Ty{ SumType: "VarUintN", - VarUintN: &VarUintN{ + VarUintN: &tolkParser.VarUintN{ N: 32, }, } @@ -155,7 +156,7 @@ func TestRuntime_UnmarshalVarUInt(t *testing.T) { if err != nil { t.Fatal(err) } - v, err := UnmarshalTolk(currCell[0], ty) + v, err := Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } @@ -170,9 +171,9 @@ func TestRuntime_UnmarshalVarUInt(t *testing.T) { } func TestRuntime_UnmarshalBits(t *testing.T) { - ty := Ty{ + ty := tolkParser.Ty{ SumType: "BitsN", - BitsN: &BitsN{ + BitsN: &tolkParser.BitsN{ N: 24, }, } @@ -181,7 +182,7 @@ func TestRuntime_UnmarshalBits(t *testing.T) { if err != nil { t.Fatal(err) } - v, err := UnmarshalTolk(currCell[0], ty) + v, err := Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } @@ -196,16 +197,16 @@ func TestRuntime_UnmarshalBits(t *testing.T) { } func TestRuntime_UnmarshalCoins(t *testing.T) { - ty := Ty{ + ty := tolkParser.Ty{ SumType: "Coins", - Coins: &Coins{}, + Coins: &tolkParser.Coins{}, } currCell, err := boc.DeserializeBocHex("b5ee9c72410101010007000009436ec6e0189ebbd7f4") if err != nil { t.Fatal(err) } - v, err := UnmarshalTolk(currCell[0], ty) + v, err := Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } @@ -220,16 +221,16 @@ func TestRuntime_UnmarshalCoins(t *testing.T) { } func TestRuntime_UnmarshalBool(t *testing.T) { - ty := Ty{ + ty := tolkParser.Ty{ SumType: "Bool", - Bool: &Bool{}, + Bool: &tolkParser.Bool{}, } currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000300000140f6d24034") if err != nil { t.Fatal(err) } - v, err := UnmarshalTolk(currCell[0], ty) + v, err := Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } @@ -244,16 +245,16 @@ func TestRuntime_UnmarshalBool(t *testing.T) { } func TestRuntime_UnmarshalCell(t *testing.T) { - ty := Ty{ + ty := tolkParser.Ty{ SumType: "Cell", - Cell: &Cell{}, + Cell: &tolkParser.Cell{}, } currCell, err := boc.DeserializeBocHex("b5ee9c724101020100090001000100080000007ba52a3292") if err != nil { t.Fatal(err) } - v, err := UnmarshalTolk(currCell[0], ty) + v, err := Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } @@ -272,16 +273,16 @@ func TestRuntime_UnmarshalCell(t *testing.T) { } func TestRuntime_UnmarshalRemaining(t *testing.T) { - ty := Ty{ + ty := tolkParser.Ty{ SumType: "Remaining", - Remaining: &Remaining{}, + Remaining: &tolkParser.Remaining{}, } currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000900000dc0800000000ab8d04726e4") if err != nil { t.Fatal(err) } - v, err := UnmarshalTolk(currCell[0], ty) + v, err := Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } @@ -300,16 +301,16 @@ func TestRuntime_UnmarshalRemaining(t *testing.T) { } func TestRuntime_UnmarshalAddress(t *testing.T) { - ty := Ty{ + ty := tolkParser.Ty{ SumType: "Address", - Address: &Address{}, + Address: &tolkParser.Address{}, } currCell, err := boc.DeserializeBocHex("b5ee9c7241010101002400004380107bfaaa5cc6e5368e5f9799188bd798cd22e04ab16d1d8ea4fc37480741e6351064a3e1a6") if err != nil { t.Fatal(err) } - v, err := UnmarshalTolk(currCell[0], ty) + v, err := Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } @@ -324,16 +325,16 @@ func TestRuntime_UnmarshalAddress(t *testing.T) { } func TestRuntime_UnmarshalNotExitsOptionalAddress(t *testing.T) { - ty := Ty{ + ty := tolkParser.Ty{ SumType: "AddressOpt", - AddressOpt: &AddressOpt{}, + AddressOpt: &tolkParser.AddressOpt{}, } currCell, err := boc.DeserializeBocHex("b5ee9c724101010100030000012094418655") if err != nil { t.Fatal(err) } - v, err := UnmarshalTolk(currCell[0], ty) + v, err := Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } @@ -349,16 +350,16 @@ func TestRuntime_UnmarshalNotExitsOptionalAddress(t *testing.T) { } func TestRuntime_UnmarshalExistsOptionalAddress(t *testing.T) { - ty := Ty{ + ty := tolkParser.Ty{ SumType: "AddressOpt", - AddressOpt: &AddressOpt{}, + AddressOpt: &tolkParser.AddressOpt{}, } currCell, err := boc.DeserializeBocHex("b5ee9c7241010101002400004380107bfaaa5cc6e5368e5f9799188bd798cd22e04ab16d1d8ea4fc37480741e6351064a3e1a6") if err != nil { t.Fatal(err) } - v, err := UnmarshalTolk(currCell[0], ty) + v, err := Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } @@ -374,16 +375,16 @@ func TestRuntime_UnmarshalExistsOptionalAddress(t *testing.T) { } func TestRuntime_UnmarshalExternalAddress(t *testing.T) { - ty := Ty{ + ty := tolkParser.Ty{ SumType: "AddressExt", - AddressExt: &AddressExt{}, + AddressExt: &tolkParser.AddressExt{}, } currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000600000742082850fcbd94fd") if err != nil { t.Fatal(err) } - v, err := UnmarshalTolk(currCell[0], ty) + v, err := Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } @@ -403,16 +404,16 @@ func TestRuntime_UnmarshalExternalAddress(t *testing.T) { } func TestRuntime_UnmarshalAnyNoneAddress(t *testing.T) { - ty := Ty{ + ty := tolkParser.Ty{ SumType: "AddressAny", - AddressAny: &AddressAny{}, + AddressAny: &tolkParser.AddressAny{}, } currCell, err := boc.DeserializeBocHex("b5ee9c724101010100030000012094418655") if err != nil { t.Fatal(err) } - v, err := UnmarshalTolk(currCell[0], ty) + v, err := Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } @@ -427,16 +428,16 @@ func TestRuntime_UnmarshalAnyNoneAddress(t *testing.T) { } func TestRuntime_UnmarshalAnyInternalAddress(t *testing.T) { - ty := Ty{ + ty := tolkParser.Ty{ SumType: "AddressAny", - AddressAny: &AddressAny{}, + AddressAny: &tolkParser.AddressAny{}, } currCell, err := boc.DeserializeBocHex("b5ee9c7241010101002400004380107bfaaa5cc6e5368e5f9799188bd798cd22e04ab16d1d8ea4fc37480741e6351064a3e1a6") if err != nil { t.Fatal(err) } - v, err := UnmarshalTolk(currCell[0], ty) + v, err := Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } @@ -451,16 +452,16 @@ func TestRuntime_UnmarshalAnyInternalAddress(t *testing.T) { } func TestRuntime_UnmarshalAnyExternalAddress(t *testing.T) { - ty := Ty{ + ty := tolkParser.Ty{ SumType: "AddressAny", - AddressAny: &AddressAny{}, + AddressAny: &tolkParser.AddressAny{}, } currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000600000742082850fcbd94fd") if err != nil { t.Fatal(err) } - v, err := UnmarshalTolk(currCell[0], ty) + v, err := Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } @@ -480,16 +481,16 @@ func TestRuntime_UnmarshalAnyExternalAddress(t *testing.T) { } func TestRuntime_UnmarshalAnyVarAddress(t *testing.T) { - ty := Ty{ + ty := tolkParser.Ty{ SumType: "AddressAny", - AddressAny: &AddressAny{}, + AddressAny: &tolkParser.AddressAny{}, } currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000900000dc0800000000ab8d04726e4") if err != nil { t.Fatal(err) } - v, err := UnmarshalTolk(currCell[0], ty) + v, err := Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } @@ -513,12 +514,12 @@ func TestRuntime_UnmarshalAnyVarAddress(t *testing.T) { } func TestRuntime_UnmarshalNotExistsNullable(t *testing.T) { - ty := Ty{ + ty := tolkParser.Ty{ SumType: "Nullable", - Nullable: &Nullable{ - Inner: Ty{ + Nullable: &tolkParser.Nullable{ + Inner: tolkParser.Ty{ SumType: "Remaining", - Remaining: &Remaining{}, + Remaining: &tolkParser.Remaining{}, }, }, } @@ -527,7 +528,7 @@ func TestRuntime_UnmarshalNotExistsNullable(t *testing.T) { if err != nil { t.Fatal(err) } - v, err := UnmarshalTolk(currCell[0], ty) + v, err := Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } @@ -542,12 +543,12 @@ func TestRuntime_UnmarshalNotExistsNullable(t *testing.T) { } func TestRuntime_UnmarshalExistsNullable(t *testing.T) { - ty := Ty{ + ty := tolkParser.Ty{ SumType: "Nullable", - Nullable: &Nullable{ - Inner: Ty{ + Nullable: &tolkParser.Nullable{ + Inner: tolkParser.Ty{ SumType: "Cell", - Cell: &Cell{}, + Cell: &tolkParser.Cell{}, }, }, } @@ -556,7 +557,7 @@ func TestRuntime_UnmarshalExistsNullable(t *testing.T) { if err != nil { t.Fatal(err) } - v, err := UnmarshalTolk(currCell[0], ty) + v, err := Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } @@ -582,12 +583,12 @@ func TestRuntime_UnmarshalExistsNullable(t *testing.T) { } func TestRuntime_UnmarshalRef(t *testing.T) { - ty := Ty{ + ty := tolkParser.Ty{ SumType: "CellOf", - CellOf: &CellOf{ - Inner: Ty{ + CellOf: &tolkParser.CellOf{ + Inner: tolkParser.Ty{ SumType: "IntN", - IntN: &IntN{ + IntN: &tolkParser.IntN{ N: 65, }, }, @@ -598,7 +599,7 @@ func TestRuntime_UnmarshalRef(t *testing.T) { if err != nil { t.Fatal(err) } - v, err := UnmarshalTolk(currCell[0], ty) + v, err := Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } @@ -617,16 +618,16 @@ func TestRuntime_UnmarshalRef(t *testing.T) { } func TestRuntime_UnmarshalEmptyTensor(t *testing.T) { - ty := Ty{ + ty := tolkParser.Ty{ SumType: "Tensor", - Tensor: &Tensor{}, + Tensor: &tolkParser.Tensor{}, } currCell, err := boc.DeserializeBocHex("b5ee9c724101010100020000004cacb9cd") if err != nil { t.Fatal(err) } - v, err := UnmarshalTolk(currCell[0], ty) + v, err := Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } @@ -642,40 +643,40 @@ func TestRuntime_UnmarshalEmptyTensor(t *testing.T) { } func TestRuntime_UnmarshalTensor(t *testing.T) { - ty := Ty{ + ty := tolkParser.Ty{ SumType: "Tensor", - Tensor: &Tensor{ - Items: []Ty{ + Tensor: &tolkParser.Tensor{ + Items: []tolkParser.Ty{ { SumType: "UintN", - UintN: &UintN{ + UintN: &tolkParser.UintN{ N: 123, }, }, { SumType: "Bool", - Bool: &Bool{}, + Bool: &tolkParser.Bool{}, }, { SumType: "Coins", - Coins: &Coins{}, + Coins: &tolkParser.Coins{}, }, { SumType: "Tensor", - Tensor: &Tensor{ - Items: []Ty{ + Tensor: &tolkParser.Tensor{ + Items: []tolkParser.Ty{ { SumType: "IntN", - IntN: &IntN{ + IntN: &tolkParser.IntN{ N: 23, }, }, { SumType: "Nullable", - Nullable: &Nullable{ - Inner: Ty{ + Nullable: &tolkParser.Nullable{ + Inner: tolkParser.Ty{ SumType: "IntN", - IntN: &IntN{ + IntN: &tolkParser.IntN{ N: 2, }, }, @@ -686,7 +687,7 @@ func TestRuntime_UnmarshalTensor(t *testing.T) { }, { SumType: "VarIntN", - VarIntN: &VarIntN{ + VarIntN: &tolkParser.VarIntN{ N: 32, }, }, @@ -698,7 +699,7 @@ func TestRuntime_UnmarshalTensor(t *testing.T) { if err != nil { t.Fatal(err) } - v, err := UnmarshalTolk(currCell[0], ty) + v, err := Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } @@ -770,18 +771,18 @@ func TestRuntime_UnmarshalTensor(t *testing.T) { } func TestRuntime_UnmarshalIntKeyMap(t *testing.T) { - ty := Ty{ + ty := tolkParser.Ty{ SumType: "Map", - Map: &Map{ - K: Ty{ + Map: &tolkParser.Map{ + K: tolkParser.Ty{ SumType: "IntN", - IntN: &IntN{ + IntN: &tolkParser.IntN{ N: 32, }, }, - V: Ty{ + V: tolkParser.Ty{ SumType: "Bool", - Bool: &Bool{}, + Bool: &tolkParser.Bool{}, }, }, } @@ -790,7 +791,7 @@ func TestRuntime_UnmarshalIntKeyMap(t *testing.T) { if err != nil { t.Fatal(err) } - v, err := UnmarshalTolk(currCell[0], ty) + v, err := Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } @@ -818,18 +819,18 @@ func TestRuntime_UnmarshalIntKeyMap(t *testing.T) { } func TestRuntime_UnmarshalUIntKeyMap(t *testing.T) { - ty := Ty{ + ty := tolkParser.Ty{ SumType: "Map", - Map: &Map{ - K: Ty{ + Map: &tolkParser.Map{ + K: tolkParser.Ty{ SumType: "UintN", - UintN: &UintN{ + UintN: &tolkParser.UintN{ N: 16, }, }, - V: Ty{ + V: tolkParser.Ty{ SumType: "Address", - Address: &Address{}, + Address: &tolkParser.Address{}, }, }, } @@ -838,7 +839,7 @@ func TestRuntime_UnmarshalUIntKeyMap(t *testing.T) { if err != nil { t.Fatal(err) } - v, err := UnmarshalTolk(currCell[0], ty) + v, err := Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } @@ -878,18 +879,18 @@ func TestRuntime_UnmarshalUIntKeyMap(t *testing.T) { } func TestRuntime_UnmarshalBigIntKeyMap(t *testing.T) { - ty := Ty{ + ty := tolkParser.Ty{ SumType: "Map", - Map: &Map{ - K: Ty{ + Map: &tolkParser.Map{ + K: tolkParser.Ty{ SumType: "UintN", - UintN: &UintN{ + UintN: &tolkParser.UintN{ N: 78, }, }, - V: Ty{ + V: tolkParser.Ty{ SumType: "Cell", - Cell: &Cell{}, + Cell: &tolkParser.Cell{}, }, }, } @@ -898,7 +899,7 @@ func TestRuntime_UnmarshalBigIntKeyMap(t *testing.T) { if err != nil { t.Fatal(err) } - v, err := UnmarshalTolk(currCell[0], ty) + v, err := Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } @@ -930,35 +931,35 @@ func TestRuntime_UnmarshalBigIntKeyMap(t *testing.T) { } func TestRuntime_UnmarshalBitsKeyMap(t *testing.T) { - ty := Ty{ + ty := tolkParser.Ty{ SumType: "Map", - Map: &Map{ - K: Ty{ + Map: &tolkParser.Map{ + K: tolkParser.Ty{ SumType: "BitsN", - BitsN: &BitsN{ + BitsN: &tolkParser.BitsN{ N: 16, }, }, - V: Ty{ + V: tolkParser.Ty{ SumType: "Map", - Map: &Map{ - K: Ty{ + Map: &tolkParser.Map{ + K: tolkParser.Ty{ SumType: "IntN", - IntN: &IntN{ + IntN: &tolkParser.IntN{ N: 64, }, }, - V: Ty{ + V: tolkParser.Ty{ SumType: "Tensor", - Tensor: &Tensor{ - Items: []Ty{ + Tensor: &tolkParser.Tensor{ + Items: []tolkParser.Ty{ { SumType: "Address", - Address: &Address{}, + Address: &tolkParser.Address{}, }, { SumType: "Coins", - Coins: &Coins{}, + Coins: &tolkParser.Coins{}, }, }, }, @@ -972,7 +973,7 @@ func TestRuntime_UnmarshalBitsKeyMap(t *testing.T) { if err != nil { t.Fatal(err) } - v, err := UnmarshalTolk(currCell[0], ty) + v, err := Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } @@ -1031,16 +1032,16 @@ func TestRuntime_UnmarshalBitsKeyMap(t *testing.T) { } func TestRuntime_UnmarshalAddressKeyMap(t *testing.T) { - ty := Ty{ + ty := tolkParser.Ty{ SumType: "Map", - Map: &Map{ - K: Ty{ + Map: &tolkParser.Map{ + K: tolkParser.Ty{ SumType: "Address", - Address: &Address{}, + Address: &tolkParser.Address{}, }, - V: Ty{ + V: tolkParser.Ty{ SumType: "Coins", - Coins: &Coins{}, + Coins: &tolkParser.Coins{}, }, }, } @@ -1049,7 +1050,7 @@ func TestRuntime_UnmarshalAddressKeyMap(t *testing.T) { if err != nil { t.Fatal(err) } - v, err := UnmarshalTolk(currCell[0], ty) + v, err := Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } @@ -1086,17 +1087,17 @@ func TestRuntime_UnmarshalAddressKeyMap(t *testing.T) { } func TestRuntime_UnmarshalUnionWithDecPrefix(t *testing.T) { - ty := Ty{ + ty := tolkParser.Ty{ SumType: "Union", - Union: &Union{ - Variants: []UnionVariant{ + Union: &tolkParser.Union{ + Variants: []tolkParser.UnionVariant{ { PrefixStr: "0", PrefixLen: 1, PrefixEatInPlace: true, - VariantTy: Ty{ + VariantTy: tolkParser.Ty{ SumType: "IntN", - IntN: &IntN{ + IntN: &tolkParser.IntN{ N: 16, }, }, @@ -1105,9 +1106,9 @@ func TestRuntime_UnmarshalUnionWithDecPrefix(t *testing.T) { PrefixStr: "1", PrefixLen: 1, PrefixEatInPlace: true, - VariantTy: Ty{ + VariantTy: tolkParser.Ty{ SumType: "IntN", - IntN: &IntN{ + IntN: &tolkParser.IntN{ N: 128, }, }, @@ -1120,7 +1121,7 @@ func TestRuntime_UnmarshalUnionWithDecPrefix(t *testing.T) { if err != nil { t.Fatal(err) } - v, err := UnmarshalTolk(currCell[0], ty) + v, err := Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } @@ -1152,22 +1153,22 @@ func TestRuntime_UnmarshalUnionWithBinPrefix(t *testing.T) { t.Fatal(err) } - var abi ABI + var abi tolkParser.ABI err = json.Unmarshal(data, &abi) if err != nil { t.Fatal(err) } - ty := Ty{ + ty := tolkParser.Ty{ SumType: "Union", - Union: &Union{ - Variants: []UnionVariant{ + Union: &tolkParser.Union{ + Variants: []tolkParser.UnionVariant{ { PrefixStr: "0b001", PrefixLen: 3, - VariantTy: Ty{ + VariantTy: tolkParser.Ty{ SumType: "StructRef", - StructRef: &StructRef{ + StructRef: &tolkParser.StructRef{ StructName: "AddressWithPrefix", }, }, @@ -1175,9 +1176,9 @@ func TestRuntime_UnmarshalUnionWithBinPrefix(t *testing.T) { { PrefixStr: "0b011", PrefixLen: 3, - VariantTy: Ty{ + VariantTy: tolkParser.Ty{ SumType: "StructRef", - StructRef: &StructRef{ + StructRef: &tolkParser.StructRef{ StructName: "MapWithPrefix", }, }, @@ -1185,9 +1186,9 @@ func TestRuntime_UnmarshalUnionWithBinPrefix(t *testing.T) { { PrefixStr: "0b111", PrefixLen: 3, - VariantTy: Ty{ + VariantTy: tolkParser.Ty{ SumType: "StructRef", - StructRef: &StructRef{ + StructRef: &tolkParser.StructRef{ StructName: "CellWithPrefix", }, }, @@ -1202,7 +1203,7 @@ func TestRuntime_UnmarshalUnionWithBinPrefix(t *testing.T) { } decoder := NewDecoder() decoder.WithABI(abi) - v, err := decoder.UnmarshalTolk(currCell[0], ty) + v, err := decoder.Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } @@ -1254,22 +1255,22 @@ func TestRuntime_UnmarshalUnionWithHexPrefix(t *testing.T) { t.Fatal(err) } - var abi ABI + var abi tolkParser.ABI err = json.Unmarshal(data, &abi) if err != nil { t.Fatal(err) } - ty := Ty{ + ty := tolkParser.Ty{ SumType: "Union", - Union: &Union{ - Variants: []UnionVariant{ + Union: &tolkParser.Union{ + Variants: []tolkParser.UnionVariant{ { PrefixStr: "0x12345678", PrefixLen: 32, - VariantTy: Ty{ + VariantTy: tolkParser.Ty{ SumType: "StructRef", - StructRef: &StructRef{ + StructRef: &tolkParser.StructRef{ StructName: "UInt66WithPrefix", }, }, @@ -1277,9 +1278,9 @@ func TestRuntime_UnmarshalUnionWithHexPrefix(t *testing.T) { { PrefixStr: "0xdeadbeef", PrefixLen: 32, - VariantTy: Ty{ + VariantTy: tolkParser.Ty{ SumType: "StructRef", - StructRef: &StructRef{ + StructRef: &tolkParser.StructRef{ StructName: "UInt33WithPrefix", }, }, @@ -1287,9 +1288,9 @@ func TestRuntime_UnmarshalUnionWithHexPrefix(t *testing.T) { { PrefixStr: "0x89abcdef", PrefixLen: 32, - VariantTy: Ty{ + VariantTy: tolkParser.Ty{ SumType: "StructRef", - StructRef: &StructRef{ + StructRef: &tolkParser.StructRef{ StructName: "UInt4WithPrefix", }, }, @@ -1304,7 +1305,7 @@ func TestRuntime_UnmarshalUnionWithHexPrefix(t *testing.T) { } decoder := NewDecoder() decoder.WithABI(abi) - v, err := decoder.UnmarshalTolk(currCell[0], ty) + v, err := decoder.Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } @@ -1344,15 +1345,15 @@ func TestRuntime_UnmarshalALotRefsFromAlias(t *testing.T) { t.Fatal(err) } - var abi ABI + var abi tolkParser.ABI err = json.Unmarshal(data, &abi) if err != nil { t.Fatal(err) } - ty := Ty{ + ty := tolkParser.Ty{ SumType: "AliasRef", - AliasRef: &AliasRef{ + AliasRef: &tolkParser.AliasRef{ AliasName: "GoodNamingForMsg", }, } @@ -1363,7 +1364,7 @@ func TestRuntime_UnmarshalALotRefsFromAlias(t *testing.T) { } decoder := NewDecoder() decoder.WithABI(abi) - v, err := decoder.UnmarshalTolk(currCell[0], ty) + v, err := decoder.Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } @@ -1605,15 +1606,15 @@ func TestRuntime_UnmarshalALotRefsFromStruct(t *testing.T) { t.Fatal(err) } - var abi ABI + var abi tolkParser.ABI err = json.Unmarshal(data, &abi) if err != nil { t.Fatal(err) } - ty := Ty{ + ty := tolkParser.Ty{ SumType: "StructRef", - StructRef: &StructRef{ + StructRef: &tolkParser.StructRef{ StructName: "ManyRefsMsg", }, } @@ -1624,7 +1625,7 @@ func TestRuntime_UnmarshalALotRefsFromStruct(t *testing.T) { } decoder := NewDecoder() decoder.WithABI(abi) - v, err := decoder.UnmarshalTolk(currCell[0], ty) + v, err := decoder.Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } @@ -1862,20 +1863,20 @@ func TestRuntime_UnmarshalALotGenericsFromStruct(t *testing.T) { t.Fatal(err) } - var abi ABI + var abi tolkParser.ABI err = json.Unmarshal(data, &abi) if err != nil { t.Fatal(err) } - ty := Ty{ + ty := tolkParser.Ty{ SumType: "StructRef", - StructRef: &StructRef{ + StructRef: &tolkParser.StructRef{ StructName: "ManyRefsMsg", - TypeArgs: []Ty{ + TypeArgs: []tolkParser.Ty{ { SumType: "UintN", - UintN: &UintN{ + UintN: &tolkParser.UintN{ N: 16, }, }, @@ -1889,7 +1890,7 @@ func TestRuntime_UnmarshalALotGenericsFromStruct(t *testing.T) { } decoder := NewDecoder() decoder.WithABI(abi) - v, err := decoder.UnmarshalTolk(currCell[0], ty) + v, err := decoder.Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } @@ -2108,20 +2109,20 @@ func TestRuntime_UnmarshalALotGenericsFromAlias(t *testing.T) { t.Fatal(err) } - var abi ABI + var abi tolkParser.ABI err = json.Unmarshal(data, &abi) if err != nil { t.Fatal(err) } - ty := Ty{ + ty := tolkParser.Ty{ SumType: "AliasRef", - AliasRef: &AliasRef{ + AliasRef: &tolkParser.AliasRef{ AliasName: "GoodNamingForMsg", - TypeArgs: []Ty{ + TypeArgs: []tolkParser.Ty{ { SumType: "UintN", - UintN: &UintN{ + UintN: &tolkParser.UintN{ N: 16, }, }, @@ -2135,7 +2136,7 @@ func TestRuntime_UnmarshalALotGenericsFromAlias(t *testing.T) { } decoder := NewDecoder() decoder.WithABI(abi) - v, err := decoder.UnmarshalTolk(currCell[0], ty) + v, err := decoder.Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } @@ -2358,15 +2359,15 @@ func TestRuntime_UnmarshalStructWithDefaultValues(t *testing.T) { t.Fatal(err) } - var abi ABI + var abi tolkParser.ABI err = json.Unmarshal(data, &abi) if err != nil { t.Fatal(err) } - ty := Ty{ + ty := tolkParser.Ty{ SumType: "StructRef", - StructRef: &StructRef{ + StructRef: &tolkParser.StructRef{ StructName: "DefaultTest", }, } @@ -2377,7 +2378,7 @@ func TestRuntime_UnmarshalStructWithDefaultValues(t *testing.T) { } decoder := NewDecoder() decoder.WithABI(abi) - v, err := decoder.UnmarshalTolk(currCell[0], ty) + v, err := decoder.Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } @@ -2530,15 +2531,15 @@ func TestRuntime_UnmarshalALotNumbers(t *testing.T) { t.Fatal(err) } - var abi ABI + var abi tolkParser.ABI err = json.Unmarshal(data, &abi) if err != nil { t.Fatal(err) } - ty := Ty{ + ty := tolkParser.Ty{ SumType: "StructRef", - StructRef: &StructRef{ + StructRef: &tolkParser.StructRef{ StructName: "Numbers", }, } @@ -2549,7 +2550,7 @@ func TestRuntime_UnmarshalALotNumbers(t *testing.T) { } decoder := NewDecoder() decoder.WithABI(abi) - v, err := decoder.UnmarshalTolk(currCell[0], ty) + v, err := decoder.Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } @@ -2650,15 +2651,15 @@ func TestRuntime_UnmarshalALotRandomFields(t *testing.T) { t.Fatal(err) } - var abi ABI + var abi tolkParser.ABI err = json.Unmarshal(data, &abi) if err != nil { t.Fatal(err) } - ty := Ty{ + ty := tolkParser.Ty{ SumType: "StructRef", - StructRef: &StructRef{ + StructRef: &tolkParser.StructRef{ StructName: "RandomFields", }, } @@ -2669,7 +2670,7 @@ func TestRuntime_UnmarshalALotRandomFields(t *testing.T) { } decoder := NewDecoder() decoder.WithABI(abi) - v, err := decoder.UnmarshalTolk(currCell[0], ty) + v, err := decoder.Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } @@ -2867,9 +2868,9 @@ func TestRuntime_UnmarshalALotRandomFields(t *testing.T) { } func TestRuntime_MarshalSmallInt(t *testing.T) { - ty := Ty{ + ty := tolkParser.Ty{ SumType: "IntN", - IntN: &IntN{ + IntN: &tolkParser.IntN{ N: 24, }, } @@ -2878,13 +2879,12 @@ func TestRuntime_MarshalSmallInt(t *testing.T) { if err != nil { t.Fatal(err) } - v, err := UnmarshalTolk(currCell[0], ty) + v, err := Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } - newCell := boc.NewCell() - err = MarshalTolk(newCell, v) + newCell, err := Marshal(v, ty) if err != nil { t.Error(err) } @@ -2903,9 +2903,9 @@ func TestRuntime_MarshalSmallInt(t *testing.T) { } func TestRuntime_MarshalBigInt(t *testing.T) { - ty := Ty{ + ty := tolkParser.Ty{ SumType: "IntN", - IntN: &IntN{ + IntN: &tolkParser.IntN{ N: 183, }, } @@ -2914,13 +2914,12 @@ func TestRuntime_MarshalBigInt(t *testing.T) { if err != nil { t.Fatal(err) } - v, err := UnmarshalTolk(currCell[0], ty) + v, err := Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } - newCell := boc.NewCell() - err = MarshalTolk(newCell, v) + newCell, err := Marshal(v, ty) if err != nil { t.Error(err) } @@ -2939,9 +2938,9 @@ func TestRuntime_MarshalBigInt(t *testing.T) { } func TestRuntime_MarshalSmallUInt(t *testing.T) { - ty := Ty{ + ty := tolkParser.Ty{ SumType: "UintN", - UintN: &UintN{ + UintN: &tolkParser.UintN{ N: 53, }, } @@ -2950,13 +2949,12 @@ func TestRuntime_MarshalSmallUInt(t *testing.T) { if err != nil { t.Fatal(err) } - v, err := UnmarshalTolk(currCell[0], ty) + v, err := Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } - newCell := boc.NewCell() - err = MarshalTolk(newCell, v) + newCell, err := Marshal(v, ty) if err != nil { t.Error(err) } @@ -2975,9 +2973,9 @@ func TestRuntime_MarshalSmallUInt(t *testing.T) { } func TestRuntime_MarshalBigUInt(t *testing.T) { - ty := Ty{ + ty := tolkParser.Ty{ SumType: "UintN", - UintN: &UintN{ + UintN: &tolkParser.UintN{ N: 257, }, } @@ -2986,13 +2984,12 @@ func TestRuntime_MarshalBigUInt(t *testing.T) { if err != nil { t.Fatal(err) } - v, err := UnmarshalTolk(currCell[0], ty) + v, err := Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } - newCell := boc.NewCell() - err = MarshalTolk(newCell, v) + newCell, err := Marshal(v, ty) if err != nil { t.Error(err) } @@ -3011,9 +3008,9 @@ func TestRuntime_MarshalBigUInt(t *testing.T) { } func TestRuntime_MarshalVarInt(t *testing.T) { - ty := Ty{ + ty := tolkParser.Ty{ SumType: "VarIntN", - VarIntN: &VarIntN{ + VarIntN: &tolkParser.VarIntN{ N: 16, }, } @@ -3022,13 +3019,12 @@ func TestRuntime_MarshalVarInt(t *testing.T) { if err != nil { t.Fatal(err) } - v, err := UnmarshalTolk(currCell[0], ty) + v, err := Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } - newCell := boc.NewCell() - err = MarshalTolk(newCell, v) + newCell, err := Marshal(v, ty) if err != nil { t.Error(err) } @@ -3047,9 +3043,9 @@ func TestRuntime_MarshalVarInt(t *testing.T) { } func TestRuntime_MarshalVarUInt(t *testing.T) { - ty := Ty{ + ty := tolkParser.Ty{ SumType: "VarUintN", - VarUintN: &VarUintN{ + VarUintN: &tolkParser.VarUintN{ N: 32, }, } @@ -3058,13 +3054,12 @@ func TestRuntime_MarshalVarUInt(t *testing.T) { if err != nil { t.Fatal(err) } - v, err := UnmarshalTolk(currCell[0], ty) + v, err := Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } - newCell := boc.NewCell() - err = MarshalTolk(newCell, v) + newCell, err := Marshal(v, ty) if err != nil { t.Error(err) } @@ -3083,9 +3078,9 @@ func TestRuntime_MarshalVarUInt(t *testing.T) { } func TestRuntime_MarshalBits(t *testing.T) { - ty := Ty{ + ty := tolkParser.Ty{ SumType: "BitsN", - BitsN: &BitsN{ + BitsN: &tolkParser.BitsN{ N: 24, }, } @@ -3094,13 +3089,12 @@ func TestRuntime_MarshalBits(t *testing.T) { if err != nil { t.Fatal(err) } - v, err := UnmarshalTolk(currCell[0], ty) + v, err := Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } - newCell := boc.NewCell() - err = MarshalTolk(newCell, v) + newCell, err := Marshal(v, ty) if err != nil { t.Error(err) } @@ -3119,22 +3113,21 @@ func TestRuntime_MarshalBits(t *testing.T) { } func TestRuntime_MarshalCoins(t *testing.T) { - ty := Ty{ + ty := tolkParser.Ty{ SumType: "Coins", - Coins: &Coins{}, + Coins: &tolkParser.Coins{}, } currCell, err := boc.DeserializeBocHex("b5ee9c72410101010007000009436ec6e0189ebbd7f4") if err != nil { t.Fatal(err) } - v, err := UnmarshalTolk(currCell[0], ty) + v, err := Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } - newCell := boc.NewCell() - err = MarshalTolk(newCell, v) + newCell, err := Marshal(v, ty) if err != nil { t.Error(err) } @@ -3153,22 +3146,21 @@ func TestRuntime_MarshalCoins(t *testing.T) { } func TestRuntime_MarshalBool(t *testing.T) { - ty := Ty{ + ty := tolkParser.Ty{ SumType: "Bool", - Bool: &Bool{}, + Bool: &tolkParser.Bool{}, } currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000300000140f6d24034") if err != nil { t.Fatal(err) } - v, err := UnmarshalTolk(currCell[0], ty) + v, err := Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } - newCell := boc.NewCell() - err = MarshalTolk(newCell, v) + newCell, err := Marshal(v, ty) if err != nil { t.Error(err) } @@ -3187,22 +3179,21 @@ func TestRuntime_MarshalBool(t *testing.T) { } func TestRuntime_MarshalCell(t *testing.T) { - ty := Ty{ + ty := tolkParser.Ty{ SumType: "Cell", - Cell: &Cell{}, + Cell: &tolkParser.Cell{}, } currCell, err := boc.DeserializeBocHex("b5ee9c724101020100090001000100080000007ba52a3292") if err != nil { t.Fatal(err) } - v, err := UnmarshalTolk(currCell[0], ty) + v, err := Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } - newCell := boc.NewCell() - err = MarshalTolk(newCell, v) + newCell, err := Marshal(v, ty) if err != nil { t.Error(err) } @@ -3221,22 +3212,21 @@ func TestRuntime_MarshalCell(t *testing.T) { } func TestRuntime_MarshalRemaining(t *testing.T) { - ty := Ty{ + ty := tolkParser.Ty{ SumType: "Remaining", - Remaining: &Remaining{}, + Remaining: &tolkParser.Remaining{}, } currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000900000dc0800000000ab8d04726e4") if err != nil { t.Fatal(err) } - v, err := UnmarshalTolk(currCell[0], ty) + v, err := Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } - newCell := boc.NewCell() - err = MarshalTolk(newCell, v) + newCell, err := Marshal(v, ty) if err != nil { t.Error(err) } @@ -3255,22 +3245,21 @@ func TestRuntime_MarshalRemaining(t *testing.T) { } func TestRuntime_MarshalAddress(t *testing.T) { - ty := Ty{ + ty := tolkParser.Ty{ SumType: "Address", - Address: &Address{}, + Address: &tolkParser.Address{}, } currCell, err := boc.DeserializeBocHex("b5ee9c7241010101002400004380107bfaaa5cc6e5368e5f9799188bd798cd22e04ab16d1d8ea4fc37480741e6351064a3e1a6") if err != nil { t.Fatal(err) } - v, err := UnmarshalTolk(currCell[0], ty) + v, err := Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } - newCell := boc.NewCell() - err = MarshalTolk(newCell, v) + newCell, err := Marshal(v, ty) if err != nil { t.Error(err) } @@ -3289,22 +3278,21 @@ func TestRuntime_MarshalAddress(t *testing.T) { } func TestRuntime_MarshalNotExitsOptionalAddress(t *testing.T) { - ty := Ty{ + ty := tolkParser.Ty{ SumType: "AddressOpt", - AddressOpt: &AddressOpt{}, + AddressOpt: &tolkParser.AddressOpt{}, } currCell, err := boc.DeserializeBocHex("b5ee9c724101010100030000012094418655") if err != nil { t.Fatal(err) } - v, err := UnmarshalTolk(currCell[0], ty) + v, err := Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } - newCell := boc.NewCell() - err = MarshalTolk(newCell, v) + newCell, err := Marshal(v, ty) if err != nil { t.Error(err) } @@ -3323,22 +3311,21 @@ func TestRuntime_MarshalNotExitsOptionalAddress(t *testing.T) { } func TestRuntime_MarshalExistsOptionalAddress(t *testing.T) { - ty := Ty{ + ty := tolkParser.Ty{ SumType: "AddressOpt", - AddressOpt: &AddressOpt{}, + AddressOpt: &tolkParser.AddressOpt{}, } currCell, err := boc.DeserializeBocHex("b5ee9c7241010101002400004380107bfaaa5cc6e5368e5f9799188bd798cd22e04ab16d1d8ea4fc37480741e6351064a3e1a6") if err != nil { t.Fatal(err) } - v, err := UnmarshalTolk(currCell[0], ty) + v, err := Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } - newCell := boc.NewCell() - err = MarshalTolk(newCell, v) + newCell, err := Marshal(v, ty) if err != nil { t.Error(err) } @@ -3357,22 +3344,21 @@ func TestRuntime_MarshalExistsOptionalAddress(t *testing.T) { } func TestRuntime_MarshalExternalAddress(t *testing.T) { - ty := Ty{ + ty := tolkParser.Ty{ SumType: "AddressExt", - AddressExt: &AddressExt{}, + AddressExt: &tolkParser.AddressExt{}, } currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000600000742082850fcbd94fd") if err != nil { t.Fatal(err) } - v, err := UnmarshalTolk(currCell[0], ty) + v, err := Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } - newCell := boc.NewCell() - err = MarshalTolk(newCell, v) + newCell, err := Marshal(v, ty) if err != nil { t.Error(err) } @@ -3391,22 +3377,21 @@ func TestRuntime_MarshalExternalAddress(t *testing.T) { } func TestRuntime_MarshalAnyNoneAddress(t *testing.T) { - ty := Ty{ + ty := tolkParser.Ty{ SumType: "AddressAny", - AddressAny: &AddressAny{}, + AddressAny: &tolkParser.AddressAny{}, } currCell, err := boc.DeserializeBocHex("b5ee9c724101010100030000012094418655") if err != nil { t.Fatal(err) } - v, err := UnmarshalTolk(currCell[0], ty) + v, err := Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } - newCell := boc.NewCell() - err = MarshalTolk(newCell, v) + newCell, err := Marshal(v, ty) if err != nil { t.Error(err) } @@ -3425,22 +3410,21 @@ func TestRuntime_MarshalAnyNoneAddress(t *testing.T) { } func TestRuntime_MarshalAnyInternalAddress(t *testing.T) { - ty := Ty{ + ty := tolkParser.Ty{ SumType: "AddressAny", - AddressAny: &AddressAny{}, + AddressAny: &tolkParser.AddressAny{}, } currCell, err := boc.DeserializeBocHex("b5ee9c7241010101002400004380107bfaaa5cc6e5368e5f9799188bd798cd22e04ab16d1d8ea4fc37480741e6351064a3e1a6") if err != nil { t.Fatal(err) } - v, err := UnmarshalTolk(currCell[0], ty) + v, err := Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } - newCell := boc.NewCell() - err = MarshalTolk(newCell, v) + newCell, err := Marshal(v, ty) if err != nil { t.Error(err) } @@ -3459,22 +3443,21 @@ func TestRuntime_MarshalAnyInternalAddress(t *testing.T) { } func TestRuntime_MarshalAnyExternalAddress(t *testing.T) { - ty := Ty{ + ty := tolkParser.Ty{ SumType: "AddressAny", - AddressAny: &AddressAny{}, + AddressAny: &tolkParser.AddressAny{}, } currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000600000742082850fcbd94fd") if err != nil { t.Fatal(err) } - v, err := UnmarshalTolk(currCell[0], ty) + v, err := Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } - newCell := boc.NewCell() - err = MarshalTolk(newCell, v) + newCell, err := Marshal(v, ty) if err != nil { t.Error(err) } @@ -3493,22 +3476,21 @@ func TestRuntime_MarshalAnyExternalAddress(t *testing.T) { } func TestRuntime_MarshalAnyVarAddress(t *testing.T) { - ty := Ty{ + ty := tolkParser.Ty{ SumType: "AddressAny", - AddressAny: &AddressAny{}, + AddressAny: &tolkParser.AddressAny{}, } currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000900000dc0800000000ab8d04726e4") if err != nil { t.Fatal(err) } - v, err := UnmarshalTolk(currCell[0], ty) + v, err := Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } - newCell := boc.NewCell() - err = MarshalTolk(newCell, v) + newCell, err := Marshal(v, ty) if err != nil { t.Error(err) } @@ -3527,12 +3509,12 @@ func TestRuntime_MarshalAnyVarAddress(t *testing.T) { } func TestRuntime_MarshalNotExistsNullable(t *testing.T) { - ty := Ty{ + ty := tolkParser.Ty{ SumType: "Nullable", - Nullable: &Nullable{ - Inner: Ty{ + Nullable: &tolkParser.Nullable{ + Inner: tolkParser.Ty{ SumType: "Remaining", - Remaining: &Remaining{}, + Remaining: &tolkParser.Remaining{}, }, }, } @@ -3541,13 +3523,12 @@ func TestRuntime_MarshalNotExistsNullable(t *testing.T) { if err != nil { t.Fatal(err) } - v, err := UnmarshalTolk(currCell[0], ty) + v, err := Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } - newCell := boc.NewCell() - err = MarshalTolk(newCell, v) + newCell, err := Marshal(v, ty) if err != nil { t.Error(err) } @@ -3566,12 +3547,12 @@ func TestRuntime_MarshalNotExistsNullable(t *testing.T) { } func TestRuntime_MarshalExistsNullable(t *testing.T) { - ty := Ty{ + ty := tolkParser.Ty{ SumType: "Nullable", - Nullable: &Nullable{ - Inner: Ty{ + Nullable: &tolkParser.Nullable{ + Inner: tolkParser.Ty{ SumType: "Cell", - Cell: &Cell{}, + Cell: &tolkParser.Cell{}, }, }, } @@ -3580,13 +3561,12 @@ func TestRuntime_MarshalExistsNullable(t *testing.T) { if err != nil { t.Fatal(err) } - v, err := UnmarshalTolk(currCell[0], ty) + v, err := Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } - newCell := boc.NewCell() - err = MarshalTolk(newCell, v) + newCell, err := Marshal(v, ty) if err != nil { t.Error(err) } @@ -3605,12 +3585,12 @@ func TestRuntime_MarshalExistsNullable(t *testing.T) { } func TestRuntime_MarshalRef(t *testing.T) { - ty := Ty{ + ty := tolkParser.Ty{ SumType: "CellOf", - CellOf: &CellOf{ - Inner: Ty{ + CellOf: &tolkParser.CellOf{ + Inner: tolkParser.Ty{ SumType: "IntN", - IntN: &IntN{ + IntN: &tolkParser.IntN{ N: 65, }, }, @@ -3621,13 +3601,12 @@ func TestRuntime_MarshalRef(t *testing.T) { if err != nil { t.Fatal(err) } - v, err := UnmarshalTolk(currCell[0], ty) + v, err := Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } - newCell := boc.NewCell() - err = MarshalTolk(newCell, v) + newCell, err := Marshal(v, ty) if err != nil { t.Error(err) } @@ -3646,22 +3625,21 @@ func TestRuntime_MarshalRef(t *testing.T) { } func TestRuntime_MarshalEmptyTensor(t *testing.T) { - ty := Ty{ + ty := tolkParser.Ty{ SumType: "Tensor", - Tensor: &Tensor{}, + Tensor: &tolkParser.Tensor{}, } currCell, err := boc.DeserializeBocHex("b5ee9c724101010100020000004cacb9cd") if err != nil { t.Fatal(err) } - v, err := UnmarshalTolk(currCell[0], ty) + v, err := Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } - newCell := boc.NewCell() - err = MarshalTolk(newCell, v) + newCell, err := Marshal(v, ty) if err != nil { t.Error(err) } @@ -3680,40 +3658,40 @@ func TestRuntime_MarshalEmptyTensor(t *testing.T) { } func TestRuntime_MarshalTensor(t *testing.T) { - ty := Ty{ + ty := tolkParser.Ty{ SumType: "Tensor", - Tensor: &Tensor{ - Items: []Ty{ + Tensor: &tolkParser.Tensor{ + Items: []tolkParser.Ty{ { SumType: "UintN", - UintN: &UintN{ + UintN: &tolkParser.UintN{ N: 123, }, }, { SumType: "Bool", - Bool: &Bool{}, + Bool: &tolkParser.Bool{}, }, { SumType: "Coins", - Coins: &Coins{}, + Coins: &tolkParser.Coins{}, }, { SumType: "Tensor", - Tensor: &Tensor{ - Items: []Ty{ + Tensor: &tolkParser.Tensor{ + Items: []tolkParser.Ty{ { SumType: "IntN", - IntN: &IntN{ + IntN: &tolkParser.IntN{ N: 23, }, }, { SumType: "Nullable", - Nullable: &Nullable{ - Inner: Ty{ + Nullable: &tolkParser.Nullable{ + Inner: tolkParser.Ty{ SumType: "IntN", - IntN: &IntN{ + IntN: &tolkParser.IntN{ N: 2, }, }, @@ -3724,7 +3702,7 @@ func TestRuntime_MarshalTensor(t *testing.T) { }, { SumType: "VarIntN", - VarIntN: &VarIntN{ + VarIntN: &tolkParser.VarIntN{ N: 32, }, }, @@ -3736,13 +3714,12 @@ func TestRuntime_MarshalTensor(t *testing.T) { if err != nil { t.Fatal(err) } - v, err := UnmarshalTolk(currCell[0], ty) + v, err := Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } - newCell := boc.NewCell() - err = MarshalTolk(newCell, v) + newCell, err := Marshal(v, ty) if err != nil { t.Error(err) } @@ -3761,18 +3738,18 @@ func TestRuntime_MarshalTensor(t *testing.T) { } func TestRuntime_MarshalIntKeyMap(t *testing.T) { - ty := Ty{ + ty := tolkParser.Ty{ SumType: "Map", - Map: &Map{ - K: Ty{ + Map: &tolkParser.Map{ + K: tolkParser.Ty{ SumType: "IntN", - IntN: &IntN{ + IntN: &tolkParser.IntN{ N: 32, }, }, - V: Ty{ + V: tolkParser.Ty{ SumType: "Bool", - Bool: &Bool{}, + Bool: &tolkParser.Bool{}, }, }, } @@ -3781,13 +3758,12 @@ func TestRuntime_MarshalIntKeyMap(t *testing.T) { if err != nil { t.Fatal(err) } - v, err := UnmarshalTolk(currCell[0], ty) + v, err := Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } - newCell := boc.NewCell() - err = MarshalTolk(newCell, v) + newCell, err := Marshal(v, ty) if err != nil { t.Error(err) } @@ -3806,18 +3782,18 @@ func TestRuntime_MarshalIntKeyMap(t *testing.T) { } func TestRuntime_MarshalUIntKeyMap(t *testing.T) { - ty := Ty{ + ty := tolkParser.Ty{ SumType: "Map", - Map: &Map{ - K: Ty{ + Map: &tolkParser.Map{ + K: tolkParser.Ty{ SumType: "UintN", - UintN: &UintN{ + UintN: &tolkParser.UintN{ N: 16, }, }, - V: Ty{ + V: tolkParser.Ty{ SumType: "Address", - Address: &Address{}, + Address: &tolkParser.Address{}, }, }, } @@ -3826,13 +3802,12 @@ func TestRuntime_MarshalUIntKeyMap(t *testing.T) { if err != nil { t.Fatal(err) } - v, err := UnmarshalTolk(currCell[0], ty) + v, err := Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } - newCell := boc.NewCell() - err = MarshalTolk(newCell, v) + newCell, err := Marshal(v, ty) if err != nil { t.Fatal(err) } @@ -3851,18 +3826,18 @@ func TestRuntime_MarshalUIntKeyMap(t *testing.T) { } func TestRuntime_MarshalBigIntKeyMap(t *testing.T) { - ty := Ty{ + ty := tolkParser.Ty{ SumType: "Map", - Map: &Map{ - K: Ty{ + Map: &tolkParser.Map{ + K: tolkParser.Ty{ SumType: "UintN", - UintN: &UintN{ + UintN: &tolkParser.UintN{ N: 78, }, }, - V: Ty{ + V: tolkParser.Ty{ SumType: "Cell", - Cell: &Cell{}, + Cell: &tolkParser.Cell{}, }, }, } @@ -3871,13 +3846,12 @@ func TestRuntime_MarshalBigIntKeyMap(t *testing.T) { if err != nil { t.Fatal(err) } - v, err := UnmarshalTolk(currCell[0], ty) + v, err := Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } - newCell := boc.NewCell() - err = MarshalTolk(newCell, v) + newCell, err := Marshal(v, ty) if err != nil { t.Error(err) } @@ -3896,35 +3870,35 @@ func TestRuntime_MarshalBigIntKeyMap(t *testing.T) { } func TestRuntime_MarshalBitsKeyMap(t *testing.T) { - ty := Ty{ + ty := tolkParser.Ty{ SumType: "Map", - Map: &Map{ - K: Ty{ + Map: &tolkParser.Map{ + K: tolkParser.Ty{ SumType: "BitsN", - BitsN: &BitsN{ + BitsN: &tolkParser.BitsN{ N: 16, }, }, - V: Ty{ + V: tolkParser.Ty{ SumType: "Map", - Map: &Map{ - K: Ty{ + Map: &tolkParser.Map{ + K: tolkParser.Ty{ SumType: "IntN", - IntN: &IntN{ + IntN: &tolkParser.IntN{ N: 64, }, }, - V: Ty{ + V: tolkParser.Ty{ SumType: "Tensor", - Tensor: &Tensor{ - Items: []Ty{ + Tensor: &tolkParser.Tensor{ + Items: []tolkParser.Ty{ { SumType: "Address", - Address: &Address{}, + Address: &tolkParser.Address{}, }, { SumType: "Coins", - Coins: &Coins{}, + Coins: &tolkParser.Coins{}, }, }, }, @@ -3938,13 +3912,12 @@ func TestRuntime_MarshalBitsKeyMap(t *testing.T) { if err != nil { t.Fatal(err) } - v, err := UnmarshalTolk(currCell[0], ty) + v, err := Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } - newCell := boc.NewCell() - err = MarshalTolk(newCell, v) + newCell, err := Marshal(v, ty) if err != nil { t.Error(err) } @@ -3963,16 +3936,16 @@ func TestRuntime_MarshalBitsKeyMap(t *testing.T) { } func TestRuntime_MarshalAddressKeyMap(t *testing.T) { - ty := Ty{ + ty := tolkParser.Ty{ SumType: "Map", - Map: &Map{ - K: Ty{ + Map: &tolkParser.Map{ + K: tolkParser.Ty{ SumType: "Address", - Address: &Address{}, + Address: &tolkParser.Address{}, }, - V: Ty{ + V: tolkParser.Ty{ SumType: "Coins", - Coins: &Coins{}, + Coins: &tolkParser.Coins{}, }, }, } @@ -3981,13 +3954,12 @@ func TestRuntime_MarshalAddressKeyMap(t *testing.T) { if err != nil { t.Fatal(err) } - v, err := UnmarshalTolk(currCell[0], ty) + v, err := Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } - newCell := boc.NewCell() - err = MarshalTolk(newCell, v) + newCell, err := Marshal(v, ty) if err != nil { t.Error(err) } @@ -4006,17 +3978,17 @@ func TestRuntime_MarshalAddressKeyMap(t *testing.T) { } func TestRuntime_MarshalUnionWithDecPrefix(t *testing.T) { - ty := Ty{ + ty := tolkParser.Ty{ SumType: "Union", - Union: &Union{ - Variants: []UnionVariant{ + Union: &tolkParser.Union{ + Variants: []tolkParser.UnionVariant{ { PrefixStr: "0", PrefixLen: 1, PrefixEatInPlace: true, - VariantTy: Ty{ + VariantTy: tolkParser.Ty{ SumType: "IntN", - IntN: &IntN{ + IntN: &tolkParser.IntN{ N: 16, }, }, @@ -4025,9 +3997,9 @@ func TestRuntime_MarshalUnionWithDecPrefix(t *testing.T) { PrefixStr: "1", PrefixLen: 1, PrefixEatInPlace: true, - VariantTy: Ty{ + VariantTy: tolkParser.Ty{ SumType: "IntN", - IntN: &IntN{ + IntN: &tolkParser.IntN{ N: 128, }, }, @@ -4040,13 +4012,12 @@ func TestRuntime_MarshalUnionWithDecPrefix(t *testing.T) { if err != nil { t.Fatal(err) } - v, err := UnmarshalTolk(currCell[0], ty) + v, err := Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } - newCell := boc.NewCell() - err = MarshalTolk(newCell, v) + newCell, err := Marshal(v, ty) if err != nil { t.Error(err) } @@ -4071,22 +4042,22 @@ func TestRuntime_MarshalUnionWithBinPrefix(t *testing.T) { t.Fatal(err) } - var abi ABI + var abi tolkParser.ABI err = json.Unmarshal(data, &abi) if err != nil { t.Fatal(err) } - ty := Ty{ + ty := tolkParser.Ty{ SumType: "Union", - Union: &Union{ - Variants: []UnionVariant{ + Union: &tolkParser.Union{ + Variants: []tolkParser.UnionVariant{ { PrefixStr: "0b001", PrefixLen: 3, - VariantTy: Ty{ + VariantTy: tolkParser.Ty{ SumType: "StructRef", - StructRef: &StructRef{ + StructRef: &tolkParser.StructRef{ StructName: "AddressWithPrefix", }, }, @@ -4094,9 +4065,9 @@ func TestRuntime_MarshalUnionWithBinPrefix(t *testing.T) { { PrefixStr: "0b011", PrefixLen: 3, - VariantTy: Ty{ + VariantTy: tolkParser.Ty{ SumType: "StructRef", - StructRef: &StructRef{ + StructRef: &tolkParser.StructRef{ StructName: "MapWithPrefix", }, }, @@ -4104,9 +4075,9 @@ func TestRuntime_MarshalUnionWithBinPrefix(t *testing.T) { { PrefixStr: "0b111", PrefixLen: 3, - VariantTy: Ty{ + VariantTy: tolkParser.Ty{ SumType: "StructRef", - StructRef: &StructRef{ + StructRef: &tolkParser.StructRef{ StructName: "CellWithPrefix", }, }, @@ -4121,13 +4092,14 @@ func TestRuntime_MarshalUnionWithBinPrefix(t *testing.T) { } decoder := NewDecoder() decoder.WithABI(abi) - v, err := decoder.UnmarshalTolk(currCell[0], ty) + v, err := decoder.Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } - newCell := boc.NewCell() - err = MarshalTolk(newCell, v) + encoder := NewEncoder() + encoder.WithABI(abi) + newCell, err := encoder.Marshal(v, ty) if err != nil { t.Error(err) } @@ -4152,22 +4124,22 @@ func TestRuntime_MarshalUnionWithHexPrefix(t *testing.T) { t.Fatal(err) } - var abi ABI + var abi tolkParser.ABI err = json.Unmarshal(data, &abi) if err != nil { t.Fatal(err) } - ty := Ty{ + ty := tolkParser.Ty{ SumType: "Union", - Union: &Union{ - Variants: []UnionVariant{ + Union: &tolkParser.Union{ + Variants: []tolkParser.UnionVariant{ { PrefixStr: "0x12345678", PrefixLen: 32, - VariantTy: Ty{ + VariantTy: tolkParser.Ty{ SumType: "StructRef", - StructRef: &StructRef{ + StructRef: &tolkParser.StructRef{ StructName: "UInt66WithPrefix", }, }, @@ -4175,9 +4147,9 @@ func TestRuntime_MarshalUnionWithHexPrefix(t *testing.T) { { PrefixStr: "0xdeadbeef", PrefixLen: 32, - VariantTy: Ty{ + VariantTy: tolkParser.Ty{ SumType: "StructRef", - StructRef: &StructRef{ + StructRef: &tolkParser.StructRef{ StructName: "UInt33WithPrefix", }, }, @@ -4185,9 +4157,9 @@ func TestRuntime_MarshalUnionWithHexPrefix(t *testing.T) { { PrefixStr: "0x89abcdef", PrefixLen: 32, - VariantTy: Ty{ + VariantTy: tolkParser.Ty{ SumType: "StructRef", - StructRef: &StructRef{ + StructRef: &tolkParser.StructRef{ StructName: "UInt4WithPrefix", }, }, @@ -4202,13 +4174,14 @@ func TestRuntime_MarshalUnionWithHexPrefix(t *testing.T) { } decoder := NewDecoder() decoder.WithABI(abi) - v, err := decoder.UnmarshalTolk(currCell[0], ty) + v, err := decoder.Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } - newCell := boc.NewCell() - err = MarshalTolk(newCell, v) + encoder := NewEncoder() + encoder.WithABI(abi) + newCell, err := encoder.Marshal(v, ty) if err != nil { t.Error(err) } @@ -4233,15 +4206,15 @@ func TestRuntime_MarshalALotRefsFromAlias(t *testing.T) { t.Fatal(err) } - var abi ABI + var abi tolkParser.ABI err = json.Unmarshal(data, &abi) if err != nil { t.Fatal(err) } - ty := Ty{ + ty := tolkParser.Ty{ SumType: "AliasRef", - AliasRef: &AliasRef{ + AliasRef: &tolkParser.AliasRef{ AliasName: "GoodNamingForMsg", }, } @@ -4252,13 +4225,14 @@ func TestRuntime_MarshalALotRefsFromAlias(t *testing.T) { } decoder := NewDecoder() decoder.WithABI(abi) - v, err := decoder.UnmarshalTolk(currCell[0], ty) + v, err := decoder.Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } - newCell := boc.NewCell() - err = MarshalTolk(newCell, v) + encoder := NewEncoder() + encoder.WithABI(abi) + newCell, err := encoder.Marshal(v, ty) if err != nil { t.Fatal(err) } @@ -4289,15 +4263,15 @@ func TestRuntime_MarshalALotRefsFromStruct(t *testing.T) { t.Fatal(err) } - var abi ABI + var abi tolkParser.ABI err = json.Unmarshal(data, &abi) if err != nil { t.Fatal(err) } - ty := Ty{ + ty := tolkParser.Ty{ SumType: "StructRef", - StructRef: &StructRef{ + StructRef: &tolkParser.StructRef{ StructName: "ManyRefsMsg", }, } @@ -4308,13 +4282,14 @@ func TestRuntime_MarshalALotRefsFromStruct(t *testing.T) { } decoder := NewDecoder() decoder.WithABI(abi) - v, err := decoder.UnmarshalTolk(currCell[0], ty) + v, err := decoder.Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } - newCell := boc.NewCell() - err = MarshalTolk(newCell, v) + encoder := NewEncoder() + encoder.WithABI(abi) + newCell, err := encoder.Marshal(v, ty) if err != nil { t.Error(err) } @@ -4339,20 +4314,20 @@ func TestRuntime_MarshalALotGenericsFromStruct(t *testing.T) { t.Fatal(err) } - var abi ABI + var abi tolkParser.ABI err = json.Unmarshal(data, &abi) if err != nil { t.Fatal(err) } - ty := Ty{ + ty := tolkParser.Ty{ SumType: "StructRef", - StructRef: &StructRef{ + StructRef: &tolkParser.StructRef{ StructName: "ManyRefsMsg", - TypeArgs: []Ty{ + TypeArgs: []tolkParser.Ty{ { SumType: "UintN", - UintN: &UintN{ + UintN: &tolkParser.UintN{ N: 16, }, }, @@ -4366,13 +4341,14 @@ func TestRuntime_MarshalALotGenericsFromStruct(t *testing.T) { } decoder := NewDecoder() decoder.WithABI(abi) - v, err := decoder.UnmarshalTolk(currCell[0], ty) + v, err := decoder.Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } - newCell := boc.NewCell() - err = MarshalTolk(newCell, v) + encoder := NewEncoder() + encoder.WithABI(abi) + newCell, err := encoder.Marshal(v, ty) if err != nil { t.Error(err) } @@ -4397,20 +4373,20 @@ func TestRuntime_MarshalALotGenericsFromAlias(t *testing.T) { t.Fatal(err) } - var abi ABI + var abi tolkParser.ABI err = json.Unmarshal(data, &abi) if err != nil { t.Fatal(err) } - ty := Ty{ + ty := tolkParser.Ty{ SumType: "AliasRef", - AliasRef: &AliasRef{ + AliasRef: &tolkParser.AliasRef{ AliasName: "GoodNamingForMsg", - TypeArgs: []Ty{ + TypeArgs: []tolkParser.Ty{ { SumType: "UintN", - UintN: &UintN{ + UintN: &tolkParser.UintN{ N: 16, }, }, @@ -4424,13 +4400,14 @@ func TestRuntime_MarshalALotGenericsFromAlias(t *testing.T) { } decoder := NewDecoder() decoder.WithABI(abi) - v, err := decoder.UnmarshalTolk(currCell[0], ty) + v, err := decoder.Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } - newCell := boc.NewCell() - err = MarshalTolk(newCell, v) + encoder := NewEncoder() + encoder.WithABI(abi) + newCell, err := encoder.Marshal(v, ty) if err != nil { t.Error(err) } @@ -4455,15 +4432,15 @@ func TestRuntime_MarshalStructWithDefaultValues(t *testing.T) { t.Fatal(err) } - var abi ABI + var abi tolkParser.ABI err = json.Unmarshal(data, &abi) if err != nil { t.Fatal(err) } - ty := Ty{ + ty := tolkParser.Ty{ SumType: "StructRef", - StructRef: &StructRef{ + StructRef: &tolkParser.StructRef{ StructName: "DefaultTest", }, } @@ -4474,13 +4451,14 @@ func TestRuntime_MarshalStructWithDefaultValues(t *testing.T) { } decoder := NewDecoder() decoder.WithABI(abi) - v, err := decoder.UnmarshalTolk(currCell[0], ty) + v, err := decoder.Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } - newCell := boc.NewCell() - err = MarshalTolk(newCell, v) + encoder := NewEncoder() + encoder.WithABI(abi) + newCell, err := encoder.Marshal(v, ty) if err != nil { t.Error(err) } @@ -4505,15 +4483,15 @@ func TestRuntime_MarshalALotNumbers(t *testing.T) { t.Fatal(err) } - var abi ABI + var abi tolkParser.ABI err = json.Unmarshal(data, &abi) if err != nil { t.Fatal(err) } - ty := Ty{ + ty := tolkParser.Ty{ SumType: "StructRef", - StructRef: &StructRef{ + StructRef: &tolkParser.StructRef{ StructName: "Numbers", }, } @@ -4524,13 +4502,14 @@ func TestRuntime_MarshalALotNumbers(t *testing.T) { } decoder := NewDecoder() decoder.WithABI(abi) - v, err := decoder.UnmarshalTolk(currCell[0], ty) + v, err := decoder.Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } - newCell := boc.NewCell() - err = MarshalTolk(newCell, v) + encoder := NewEncoder() + encoder.WithABI(abi) + newCell, err := encoder.Marshal(v, ty) if err != nil { t.Error(err) } @@ -4555,15 +4534,15 @@ func TestRuntime_MarshalALotRandomFields(t *testing.T) { t.Fatal(err) } - var abi ABI + var abi tolkParser.ABI err = json.Unmarshal(data, &abi) if err != nil { t.Fatal(err) } - ty := Ty{ + ty := tolkParser.Ty{ SumType: "StructRef", - StructRef: &StructRef{ + StructRef: &tolkParser.StructRef{ StructName: "RandomFields", }, } @@ -4574,13 +4553,14 @@ func TestRuntime_MarshalALotRandomFields(t *testing.T) { } decoder := NewDecoder() decoder.WithABI(abi) - v, err := decoder.UnmarshalTolk(currCell[0], ty) + v, err := decoder.Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } - newCell := boc.NewCell() - err = MarshalTolk(newCell, v) + encoder := NewEncoder() + encoder.WithABI(abi) + newCell, err := encoder.Marshal(v, ty) if err != nil { t.Error(err) } diff --git a/tolk/tuples.go b/tolk/tuples.go index 48515b2f..034c62e7 100644 --- a/tolk/tuples.go +++ b/tolk/tuples.go @@ -1,112 +1,60 @@ package tolk import ( - "fmt" - "github.com/tonkeeper/tongo/boc" + "github.com/tonkeeper/tongo/tolk/parser" ) -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 -} +type TupleValues []Value -func (t Tensor) UnmarshalTolk(cell *boc.Cell, v *Value, decoder *Decoder) error { - list := make(TensorValues, len(t.Items)) - for i, item := range t.Items { +func (v *TupleValues) Unmarshal(cell *boc.Cell, ty tolkParser.TupleWith, decoder *Decoder) error { + list := make(TupleValues, len(ty.Items)) + for i, item := range ty.Items { inner := Value{} - err := inner.UnmarshalTolk(cell, item, decoder) + err := inner.Unmarshal(cell, item, decoder) if err != nil { return err } list[i] = inner } - err := t.SetValue(v, list) - if err != nil { - return err - } + *v = list 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) +func (v *TupleValues) Marshal(cell *boc.Cell, ty tolkParser.TupleWith, encoder *Encoder) error { + for i, item := range []Value(*v) { + err := item.Marshal(cell, ty.Items[i], encoder) 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) +func (v *TupleValues) Equal(other any) bool { + otherTupleValues, ok := other.(TupleValues) if !ok { - return fmt.Errorf("value is not a tuple") + return false } - 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 + wV := *v + if len(otherTupleValues) != len(wV) { + return false } - err := t.SetValue(v, list) - if err != nil { - return err + for i := range wV { + if !wV[i].Equal(otherTupleValues[i]) { + return false + } } - - return nil + return true } -func (v *TupleValues) UnmarshalTolk(cell *boc.Cell, ty TupleWith, decoder *Decoder) error { - list := make(TupleValues, len(ty.Items)) +type TensorValues []Value + +func (v *TensorValues) Unmarshal(cell *boc.Cell, ty tolkParser.Tensor, decoder *Decoder) error { + list := make(TensorValues, len(ty.Items)) for i, item := range ty.Items { inner := Value{} - err := inner.UnmarshalTolk(cell, item, decoder) + err := inner.Unmarshal(cell, item, decoder) if err != nil { return err } @@ -116,39 +64,29 @@ func (v *TupleValues) UnmarshalTolk(cell *boc.Cell, ty TupleWith, decoder *Decod 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 - // } - //} - +func (v *TensorValues) Marshal(cell *boc.Cell, ty tolkParser.Tensor, encoder *Encoder) error { + for i, item := range []Value(*v) { + err := item.Marshal(cell, ty.Items[i], encoder) + 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 +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 } diff --git a/tolk/union.go b/tolk/union.go index 4cc3824d..a8c840be 100644 --- a/tolk/union.go +++ b/tolk/union.go @@ -4,29 +4,21 @@ import ( "fmt" "github.com/tonkeeper/tongo/boc" + "github.com/tonkeeper/tongo/tolk/parser" ) -type Union struct { - Variants []UnionVariant `json:"variants"` +type UnionValue struct { + Prefix Prefix + Val Value } -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 { +func (u *UnionValue) Unmarshal(cell *boc.Cell, ty tolkParser.Union, decoder *Decoder) error { unionV := UnionValue{} - if len(u.Variants) < 2 { + if len(ty.Variants) < 2 { return fmt.Errorf("union length must be at least 2") } - prefixLen := u.Variants[0].PrefixLen - eatPrefix := u.Variants[0].PrefixEatInPlace + 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") @@ -47,27 +39,24 @@ func (u Union) UnmarshalTolk(cell *boc.Cell, v *Value, decoder *Decoder) error { } } - for _, variant := range u.Variants { - variantPrefix, err := PrefixToUint(variant.PrefixStr) + for _, variant := range ty.Variants { + variantPrefix, err := tolkParser.PrefixToUint(variant.PrefixStr) if err != nil { return err } if prefix == variantPrefix { - unionV.Prefix = TolkPrefix{ + unionV.Prefix = Prefix{ Len: int16(variant.PrefixLen), Prefix: prefix, } innerV := Value{} - err = innerV.UnmarshalTolk(cell, variant.VariantTy, decoder) + err = innerV.Unmarshal(cell, variant.VariantTy, decoder) if err != nil { return err } unionV.Val = innerV - err = u.SetValue(v, unionV) - if err != nil { - return err - } + *u = unionV return nil } @@ -76,83 +65,42 @@ func (u Union) UnmarshalTolk(cell *boc.Cell, v *Value, decoder *Decoder) error { return fmt.Errorf("none of union prefixes matched") } -func (u *UnionValue) UnmarshalTolk(cell *boc.Cell, ty Union, decoder *Decoder) error { - unionV := UnionValue{} +func (u *UnionValue) Marshal(cell *boc.Cell, ty tolkParser.Union, encoder *Encoder) error { 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? + if u.Prefix.Len > 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 ty.Variants[0].PrefixEatInPlace { + err := cell.WriteUint(u.Prefix.Prefix, int(u.Prefix.Len)) if err != nil { return err } } for _, variant := range ty.Variants { - variantPrefix, err := PrefixToUint(variant.PrefixStr) + variantPrefix, err := tolkParser.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 + if u.Prefix.Prefix == variantPrefix { + return u.Val.Marshal(cell, variant.VariantTy, encoder) } } 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 +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) } diff --git a/tolk/utils.go b/tolk/utils.go index 1aeed3fc..4e37012c 100644 --- a/tolk/utils.go +++ b/tolk/utils.go @@ -62,40 +62,3 @@ func binDecHexToUint(num string) (*big.Int, error) { 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/tolk/runtime_types.go b/tolk/value.go similarity index 52% rename from tolk/runtime_types.go rename to tolk/value.go index 86f292d3..7088212b 100644 --- a/tolk/runtime_types.go +++ b/tolk/value.go @@ -3,66 +3,17 @@ package tolk // todo: move this to some package or rename somehow. import ( - "bytes" + "encoding/hex" "fmt" - "maps" "math/big" "github.com/tonkeeper/tongo/boc" + "github.com/tonkeeper/tongo/tolk/parser" + "github.com/tonkeeper/tongo/ton" ) 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 @@ -101,6 +52,13 @@ func (v *Value) GetBool() (bool, bool) { return bool(*v.bool), true } +func (v *Value) MustGetBool() bool { + if v.bool == nil { + panic("value is not a bool") + } + return bool(*v.bool) +} + func (v *Value) GetSmallInt() (int64, bool) { if v.smallInt == nil { return 0, false @@ -108,6 +66,13 @@ func (v *Value) GetSmallInt() (int64, bool) { return int64(*v.smallInt), true } +func (v *Value) MustGetSmallInt() int64 { + if v.smallInt == nil { + panic("value is not a small int") + } + return int64(*v.smallInt) +} + func (v *Value) GetBigInt() (big.Int, bool) { if v.bigInt == nil { return big.Int{}, false @@ -115,6 +80,13 @@ func (v *Value) GetBigInt() (big.Int, bool) { return big.Int(*v.bigInt), true } +func (v *Value) MustGetBigInt() big.Int { + if v.bigInt == nil { + panic("value is not a big int") + } + return big.Int(*v.bigInt) +} + func (v *Value) GetSmallUInt() (uint64, bool) { if v.smallUint == nil { return 0, false @@ -122,6 +94,13 @@ func (v *Value) GetSmallUInt() (uint64, bool) { return uint64(*v.smallUint), true } +func (v *Value) MustGetSmallUInt() uint64 { + if v.smallUint == nil { + panic("value is not a small uint") + } + return uint64(*v.smallUint) +} + func (v *Value) GetBigUInt() (big.Int, bool) { if v.bigUint == nil { return big.Int{}, false @@ -129,6 +108,13 @@ func (v *Value) GetBigUInt() (big.Int, bool) { return big.Int(*v.bigUint), true } +func (v *Value) MustGetBigUInt() big.Int { + if v.bigUint == nil { + panic("value is not a big uint") + } + return big.Int(*v.bigUint) +} + func (v *Value) GetVarInt() (big.Int, bool) { if v.varInt == nil { return big.Int{}, false @@ -136,6 +122,13 @@ func (v *Value) GetVarInt() (big.Int, bool) { return big.Int(*v.varInt), true } +func (v *Value) MustGetVarInt() big.Int { + if v.varInt == nil { + panic("value is not a var int") + } + return big.Int(*v.varInt) +} + func (v *Value) GetVarUInt() (big.Int, bool) { if v.varUint == nil { return big.Int{}, false @@ -143,6 +136,13 @@ func (v *Value) GetVarUInt() (big.Int, bool) { return big.Int(*v.varUint), true } +func (v *Value) MustGetVarUInt() big.Int { + if v.varUint == nil { + panic("value is not a var uint") + } + return big.Int(*v.varUint) +} + func (v *Value) GetCoins() (big.Int, bool) { if v.coins == nil { return big.Int{}, false @@ -150,6 +150,13 @@ func (v *Value) GetCoins() (big.Int, bool) { return big.Int(*v.coins), true } +func (v *Value) MustGetCoins() big.Int { + if v.coins == nil { + panic("value is not a coins") + } + return big.Int(*v.coins) +} + func (v *Value) GetBits() (boc.BitString, bool) { if v.bits == nil { return boc.BitString{}, false @@ -157,6 +164,13 @@ func (v *Value) GetBits() (boc.BitString, bool) { return boc.BitString(*v.bits), true } +func (v *Value) MustGetBits() boc.BitString { + if v.bits == nil { + panic("value is not a bits") + } + return boc.BitString(*v.bits) +} + func (v *Value) GetAddress() (InternalAddress, bool) { if v.internalAddress == nil { return InternalAddress{}, false @@ -164,6 +178,13 @@ func (v *Value) GetAddress() (InternalAddress, bool) { return *v.internalAddress, true } +func (v *Value) MustGetAddress() InternalAddress { + if v.internalAddress == nil { + panic("value is not an internal address") + } + return *v.internalAddress +} + func (v *Value) GetOptionalAddress() (OptionalAddress, bool) { if v.optionalAddress == nil { return OptionalAddress{}, false @@ -171,6 +192,13 @@ func (v *Value) GetOptionalAddress() (OptionalAddress, bool) { return *v.optionalAddress, true } +func (v *Value) MustGetOptionalAddress() OptionalAddress { + if v.optionalAddress == nil { + panic("value is not an optional address") + } + return *v.optionalAddress +} + func (v *Value) GetExternalAddress() (ExternalAddress, bool) { if v.externalAddress == nil { return ExternalAddress{}, false @@ -178,6 +206,13 @@ func (v *Value) GetExternalAddress() (ExternalAddress, bool) { return *v.externalAddress, true } +func (v *Value) MustGetExternalAddress() ExternalAddress { + if v.externalAddress == nil { + panic("value is not an external address") + } + return *v.externalAddress +} + func (v *Value) GetAnyAddress() (AnyAddress, bool) { if v.anyAddress == nil { return AnyAddress{}, false @@ -185,6 +220,13 @@ func (v *Value) GetAnyAddress() (AnyAddress, bool) { return *v.anyAddress, true } +func (v *Value) MustGetAnyAddress() AnyAddress { + if v.anyAddress == nil { + panic("value is not an any address") + } + return *v.anyAddress +} + func (v *Value) GetOptionalValue() (OptValue, bool) { if v.optionalValue == nil { return OptValue{}, false @@ -192,6 +234,13 @@ func (v *Value) GetOptionalValue() (OptValue, bool) { return *v.optionalValue, true } +func (v *Value) MustGetOptionalValue() OptValue { + if v.optionalValue == nil { + panic("value is not an optional value") + } + return *v.optionalValue +} + func (v *Value) GetRefValue() (Value, bool) { if v.refValue == nil { return Value{}, false @@ -199,6 +248,13 @@ func (v *Value) GetRefValue() (Value, bool) { return Value(*v.refValue), true } +func (v *Value) MustGetRefValue() Value { + if v.refValue == nil { + panic("value is not a reference") + } + return Value(*v.refValue) +} + func (v *Value) GetTensor() ([]Value, bool) { if v.tensor == nil { return TensorValues{}, false @@ -206,6 +262,13 @@ func (v *Value) GetTensor() ([]Value, bool) { return *v.tensor, true } +func (v *Value) MustGetTensor() []Value { + if v.tensor == nil { + panic("value is not a tensor") + } + return *v.tensor +} + func (v *Value) GetMap() (MapValue, bool) { if v.mp == nil { return MapValue{}, false @@ -213,6 +276,13 @@ func (v *Value) GetMap() (MapValue, bool) { return *v.mp, true } +func (v *Value) MustGetMap() MapValue { + if v.mp == nil { + panic("value is not a map") + } + return *v.mp +} + func (v *Value) GetStruct() (Struct, bool) { if v.structValue == nil { return Struct{}, false @@ -220,6 +290,13 @@ func (v *Value) GetStruct() (Struct, bool) { return *v.structValue, true } +func (v *Value) MustGetStruct() Struct { + if v.structValue == nil { + panic("value is not a struct") + } + return *v.structValue +} + func (v *Value) GetAlias() (Value, bool) { if v.alias == nil { return Value{}, false @@ -227,6 +304,13 @@ func (v *Value) GetAlias() (Value, bool) { return Value(*v.alias), true } +func (v *Value) MustGetAlias() Value { + if v.alias == nil { + panic("value is not an alias") + } + return Value(*v.alias) +} + func (v *Value) GetGeneric() (Value, bool) { if v.generic == nil { return Value{}, false @@ -234,6 +318,13 @@ func (v *Value) GetGeneric() (Value, bool) { return Value(*v.generic), true } +func (v *Value) MustGetGeneric() Value { + if v.generic == nil { + panic("value is not a generic") + } + return Value(*v.generic) +} + func (v *Value) GetEnum() (EnumValue, bool) { if v.enum == nil { return EnumValue{}, false @@ -241,6 +332,13 @@ func (v *Value) GetEnum() (EnumValue, bool) { return *v.enum, true } +func (v *Value) MustGetEnum() EnumValue { + if v.enum == nil { + panic("value is not an enum") + } + return *v.enum +} + func (v *Value) GetUnion() (UnionValue, bool) { if v.union == nil { return UnionValue{}, false @@ -248,6 +346,13 @@ func (v *Value) GetUnion() (UnionValue, bool) { return *v.union, true } +func (v *Value) MustGetUnion() UnionValue { + if v.union == nil { + panic("value is not an union") + } + return *v.union +} + func (v *Value) GetTupleValues() ([]Value, bool) { if v.tupleWith == nil { return TupleValues{}, false @@ -255,6 +360,13 @@ func (v *Value) GetTupleValues() ([]Value, bool) { return *v.tupleWith, true } +func (v *Value) MustGetTupleValues() []Value { + if v.tupleWith == nil { + panic("value is not a tuple") + } + return *v.tupleWith +} + func (v *Value) GetCell() (boc.Cell, bool) { if v.cell == nil { return boc.Cell{}, false @@ -262,6 +374,13 @@ func (v *Value) GetCell() (boc.Cell, bool) { return boc.Cell(*v.cell), true } +func (v *Value) MustGetCell() boc.Cell { + if v.cell == nil { + panic("value is not a cell") + } + return boc.Cell(*v.cell) +} + func (v *Value) GetRemaining() (boc.Cell, bool) { if v.remaining == nil { return boc.Cell{}, false @@ -269,154 +388,198 @@ func (v *Value) GetRemaining() (boc.Cell, bool) { return boc.Cell(*v.remaining), true } -func (v *Value) Equal(o any) bool { - otherValue, ok := o.(Value) - if !ok { - return false +func (v *Value) MustGetRemaining() boc.Cell { + if v.remaining == nil { + panic("value is not a remaining") } + return boc.Cell(*v.remaining) +} - switch v.sumType { - case "bool": - if otherValue.bool == nil { - return false +func (v *Value) GetType() string { + return string(v.sumType) +} + +func (v *Value) SetValue(val any, ty tolkParser.Ty) error { + switch ty.SumType { + case "IntN": + bi, ok := val.(BigInt) + if !ok { + return fmt.Errorf("cannot convert %v to BigInt", val) } - return v.bool.Equal(*otherValue.bool) - case "smallInt": - if otherValue.smallInt == nil { - return false + if ty.IntN.N <= 64 { + b := big.Int(bi) + wVal := Int64(b.Int64()) + v.smallInt = &wVal + } else { + v.bigInt = &bi } - return v.smallInt.Equal(*otherValue.smallInt) - case "smallUint": - if otherValue.smallUint == nil { - return false + case "UintN": + bi, ok := val.(BigUInt) + if !ok { + return fmt.Errorf("cannot convert %v to BigUInt", val) } - return v.smallUint.Equal(*otherValue.smallUint) - case "bigInt": - if otherValue.bigInt == nil { - return false + if ty.UintN.N <= 64 { + b := big.Int(bi) + wVal := UInt64(b.Uint64()) + v.smallUint = &wVal + } else { + v.bigUint = &bi } - return v.bigInt.Equal(*otherValue.bigInt) - case "bigUint": - if otherValue.bigUint == nil { - return false + case "VarIntN": + vi, ok := val.(VarInt) + if !ok { + return fmt.Errorf("cannot convert %v to VarInt", val) } - return v.bigUint.Equal(*otherValue.bigUint) - case "varInt": - if otherValue.varInt == nil { - return false + v.varInt = &vi + case "VarUintN": + vi, ok := val.(VarUInt) + if !ok { + return fmt.Errorf("cannot convert %v to VarUInt", val) } - return v.varInt.Equal(*otherValue.varInt) - case "varUint": - if otherValue.varUint == nil { - return false + v.varUint = &vi + case "BitsN": + b, ok := val.(Bits) + if !ok { + return fmt.Errorf("cannot convert %v to Bits", val) } - return v.varUint.Equal(*otherValue.varUint) - case "coins": - if otherValue.coins == nil { - return false + v.bits = &b + case "Nullable": + o, ok := val.(OptValue) + if !ok { + return fmt.Errorf("cannot convert %v to OptValue", val) } - return v.coins.Equal(*otherValue.coins) - case "bits": - if otherValue.bits == nil { - return false + v.optionalValue = &o + case "CellOf": + r, ok := val.(RefValue) + if !ok { + return fmt.Errorf("cannot convert %v to RefValue", val) } - return v.bits.Equal(*otherValue.bits) - case "cell": - if otherValue.cell == nil { - return false + v.refValue = &r + case "Tensor": + t, ok := val.(TensorValues) + if !ok { + return fmt.Errorf("cannot convert %v to TensorValues", val) } - return v.cell.Equal(*otherValue.cell) - case "remaining": - if otherValue.remaining == nil { - return false + v.tensor = &t + case "TupleWith": + t, ok := val.(TupleValues) + if !ok { + return fmt.Errorf("cannot convert %v to TupleValues", val) } - return v.remaining.Equal(*otherValue.remaining) - case "internalAddress": - if otherValue.internalAddress == nil { - return false + v.tupleWith = &t + case "Map": + m, ok := val.(MapValue) + if !ok { + return fmt.Errorf("cannot convert %v to MapValue", val) } - return v.internalAddress.Equal(*otherValue.internalAddress) - case "optionalAddress": - if otherValue.optionalAddress == nil { - return false + v.mp = &m + case "EnumRef": + e, ok := val.(EnumValue) + if !ok { + return fmt.Errorf("cannot convert %v to EnumValue", val) } - return v.optionalAddress.Equal(*otherValue.optionalAddress) - case "externalAddress": - if otherValue.externalAddress == nil { - return false + v.enum = &e + case "StructRef": + s, ok := val.(Struct) + if !ok { + return fmt.Errorf("cannot convert %v to Struct", val) } - return v.externalAddress.Equal(*otherValue.externalAddress) - case "anyAddress": - if otherValue.anyAddress == nil { - return false + v.structValue = &s + case "AliasRef": + a, ok := val.(AliasValue) + if !ok { + return fmt.Errorf("cannot convert %v to AliasValue", val) } - return v.anyAddress.Equal(*otherValue.anyAddress) - case "optionalValue": - if otherValue.optionalValue == nil { - return false + v.alias = &a + case "Generic": + g, ok := val.(GenericValue) + if !ok { + return fmt.Errorf("cannot convert %v to GenericValue", val) } - return v.optionalValue.Equal(*otherValue.optionalValue) - case "refValue": - if otherValue.refValue == nil { - return false + v.generic = &g + case "Union": + u, ok := val.(UnionValue) + if !ok { + return fmt.Errorf("cannot convert %v to UnionValue", val) } - return v.refValue.Equal(*otherValue.refValue) - case "tupleWith": - if otherValue.tupleWith == nil { - return false + 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) } - return v.tupleWith.Equal(*otherValue.tupleWith) - case "tensor": - if otherValue.tensor == nil { - return false + v.coins = &c + case "Bool": + b, ok := val.(BoolValue) + if !ok { + return fmt.Errorf("cannot convert %v to BoolValue", val) } - return v.tensor.Equal(*otherValue.tensor) - case "mp": - if otherValue.mp == nil { - return false + v.bool = &b + case "Cell": + a, ok := val.(Any) + if !ok { + return fmt.Errorf("cannot convert %v to Any", val) } - return v.mp.Equal(*otherValue.mp) - case "structValue": - if otherValue.structValue == nil { - return false + 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) } - return v.structValue.Equal(*otherValue.structValue) - case "alias": - if otherValue.alias == nil { - return false + v.remaining = &r + case "Address": + i, ok := val.(InternalAddress) + if !ok { + return fmt.Errorf("cannot convert %v to InternalAddress", val) } - return v.alias.Equal(*otherValue.alias) - case "enum": - if otherValue.enum == nil { - return false + v.internalAddress = &i + case "AddressOpt": + o, ok := val.(OptionalAddress) + if !ok { + return fmt.Errorf("cannot convert %v to OptionalAddress", val) } - return v.enum.Equal(*otherValue.enum) - case "generic": - if otherValue.generic == nil { - return false + v.optionalAddress = &o + case "AddressExt": + e, ok := val.(ExternalAddress) + if !ok { + return fmt.Errorf("cannot convert %v to ExternalAddress", val) } - return v.generic.Equal(*otherValue.generic) - case "union": - if otherValue.union == nil { - return false + v.externalAddress = &e + case "AddressAny": + a, ok := val.(AnyAddress) + if !ok { + return fmt.Errorf("cannot convert %v to AnyAddress", val) } - return v.union.Equal(*otherValue.union) - case "null": - if otherValue.null == nil { - return false + 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) } - return v.null.Equal(*otherValue.null) - case "void": - if otherValue.void == nil { - return false + v.null = &n + case "Void": + vo, ok := val.(VoidValue) + if !ok { + return fmt.Errorf("cannot convert %v to VoidValue", val) } - return v.void.Equal(*otherValue.void) + v.void = &vo default: - return false + return fmt.Errorf("unknown ty type %q", ty.SumType) } + return nil } -func (v *Value) UnmarshalTolk(cell *boc.Cell, ty Ty, decoder *Decoder) error { +func (v *Value) Unmarshal(cell *boc.Cell, ty tolkParser.Ty, decoder *Decoder) error { var err error switch ty.SumType { case "IntN": @@ -424,90 +587,90 @@ func (v *Value) UnmarshalTolk(cell *boc.Cell, ty Ty, decoder *Decoder) error { v.sumType = "smallInt" def := Int64(0) v.smallInt = &def - err = v.smallInt.UnmarshalTolk(cell, *ty.IntN, decoder) + err = v.smallInt.Unmarshal(cell, *ty.IntN, decoder) } else { v.sumType = "bigInt" v.bigInt = &BigInt{} - err = v.bigInt.UnmarshalTolk(cell, *ty.IntN, decoder) + err = v.bigInt.Unmarshal(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) + err = v.smallUint.Unmarshal(cell, *ty.UintN, decoder) } else { v.sumType = "bigUint" v.bigUint = &BigUInt{} - err = v.bigUint.UnmarshalTolk(cell, *ty.UintN, decoder) + err = v.bigUint.Unmarshal(cell, *ty.UintN, decoder) } case "VarIntN": v.sumType = "varInt" v.varInt = &VarInt{} - err = v.varInt.UnmarshalTolk(cell, *ty.VarIntN, decoder) + err = v.varInt.Unmarshal(cell, *ty.VarIntN, decoder) case "VarUintN": v.sumType = "varUint" v.varUint = &VarUInt{} - err = v.varUint.UnmarshalTolk(cell, *ty.VarUintN, decoder) + err = v.varUint.Unmarshal(cell, *ty.VarUintN, decoder) case "BitsN": v.sumType = "bits" v.bits = &Bits{} - err = v.bits.UnmarshalTolk(cell, *ty.BitsN, decoder) + err = v.bits.Unmarshal(cell, *ty.BitsN, decoder) case "Nullable": v.sumType = "optionalValue" v.optionalValue = &OptValue{} - err = v.optionalValue.UnmarshalTolk(cell, *ty.Nullable, decoder) + err = v.optionalValue.Unmarshal(cell, *ty.Nullable, decoder) case "CellOf": v.sumType = "refValue" v.refValue = &RefValue{} - err = v.refValue.UnmarshalTolk(cell, *ty.CellOf, decoder) + err = v.refValue.Unmarshal(cell, *ty.CellOf, decoder) case "Tensor": v.sumType = "tensor" v.tensor = &TensorValues{} - err = v.tensor.UnmarshalTolk(cell, *ty.Tensor, decoder) + err = v.tensor.Unmarshal(cell, *ty.Tensor, decoder) case "TupleWith": v.sumType = "tupleWith" v.tupleWith = &TupleValues{} - err = v.tupleWith.UnmarshalTolk(cell, *ty.TupleWith, decoder) + err = v.tupleWith.Unmarshal(cell, *ty.TupleWith, decoder) case "Map": v.sumType = "mp" v.mp = &MapValue{} - err = v.mp.UnmarshalTolk(cell, *ty.Map, decoder) + err = v.mp.Unmarshal(cell, *ty.Map, decoder) case "EnumRef": v.sumType = "enum" v.enum = &EnumValue{} - err = v.enum.UnmarshalTolk(cell, *ty.EnumRef, decoder) + err = v.enum.Unmarshal(cell, *ty.EnumRef, decoder) case "StructRef": v.sumType = "structValue" v.structValue = &Struct{} - err = v.structValue.UnmarshalTolk(cell, *ty.StructRef, decoder) + err = v.structValue.Unmarshal(cell, *ty.StructRef, decoder) case "AliasRef": v.sumType = "alias" v.alias = &AliasValue{} - err = v.alias.UnmarshalTolk(cell, *ty.AliasRef, decoder) + err = v.alias.Unmarshal(cell, *ty.AliasRef, decoder) case "Generic": v.sumType = "generic" v.generic = &GenericValue{} - err = v.generic.UnmarshalTolk(cell, *ty.Generic, decoder) + err = v.generic.Unmarshal(cell, *ty.Generic, decoder) case "Union": v.sumType = "union" v.union = &UnionValue{} - err = v.union.UnmarshalTolk(cell, *ty.Union, decoder) + err = v.union.Unmarshal(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) + err = v.coins.Unmarshal(cell, *ty.Coins, decoder) case "Bool": v.sumType = "bool" def := BoolValue(false) v.bool = &def - err = v.bool.UnmarshalTolk(cell, *ty.Bool, decoder) + err = v.bool.Unmarshal(cell, *ty.Bool, decoder) case "Cell": v.sumType = "cell" v.cell = &Any{} - err = v.cell.UnmarshalTolk(cell, *ty.Cell, decoder) + err = v.cell.Unmarshal(cell, *ty.Cell, decoder) case "Slice": err = fmt.Errorf("slice not supported") case "Builder": @@ -517,33 +680,33 @@ func (v *Value) UnmarshalTolk(cell *boc.Cell, ty Ty, decoder *Decoder) error { case "Remaining": v.sumType = "remaining" v.remaining = &RemainingValue{} - err = v.remaining.UnmarshalTolk(cell, *ty.Remaining, decoder) + err = v.remaining.Unmarshal(cell, *ty.Remaining, decoder) case "Address": v.sumType = "internalAddress" v.internalAddress = &InternalAddress{} - err = v.internalAddress.UnmarshalTolk(cell, *ty.Address, decoder) + err = v.internalAddress.Unmarshal(cell, *ty.Address, decoder) case "AddressOpt": v.sumType = "optionalAddress" v.optionalAddress = &OptionalAddress{} - err = v.optionalAddress.UnmarshalTolk(cell, *ty.AddressOpt, decoder) + err = v.optionalAddress.Unmarshal(cell, *ty.AddressOpt, decoder) case "AddressExt": v.sumType = "externalAddress" v.externalAddress = &ExternalAddress{} - err = v.externalAddress.UnmarshalTolk(cell, *ty.AddressExt, decoder) + err = v.externalAddress.Unmarshal(cell, *ty.AddressExt, decoder) case "AddressAny": v.sumType = "anyAddress" v.anyAddress = &AnyAddress{} - err = v.anyAddress.UnmarshalTolk(cell, *ty.AddressAny, decoder) + err = v.anyAddress.Unmarshal(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) + err = v.null.Unmarshal(cell, *ty.NullLiteral, decoder) case "Void": v.sumType = "void" v.void = &VoidValue{} - err = v.void.UnmarshalTolk(cell, *ty.Void, decoder) + err = v.void.Unmarshal(cell, *ty.Void, decoder) default: return fmt.Errorf("unknown ty type %q", ty.SumType) } @@ -553,783 +716,378 @@ func (v *Value) UnmarshalTolk(cell *boc.Cell, ty Ty, decoder *Decoder) error { return nil } -func (v *Value) SetValue(val any, ty Ty) error { +func (v *Value) Marshal(cell *boc.Cell, ty tolkParser.Ty, encoder *Encoder) error { + var err 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 + if v.sumType != "smallInt" { + return fmt.Errorf("expected smallInt, but got %v", v.sumType) + } + return v.smallInt.Marshal(cell, *ty.IntN, encoder) } else { - v.bigInt = &bi + if v.sumType != "bigInt" { + return fmt.Errorf("expected bigInt, but got %v", v.sumType) + } + return v.bigInt.Marshal(cell, *ty.IntN, encoder) } 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 + if v.sumType != "smallUint" { + return fmt.Errorf("expected smallUint, but got %v", v.sumType) + } + return v.smallUint.Marshal(cell, *ty.UintN, encoder) } else { - v.bigUint = &bi + if v.sumType != "bigUint" { + return fmt.Errorf("expected bigUint, but got %v", v.sumType) + } + return v.bigUint.Marshal(cell, *ty.UintN, encoder) } case "VarIntN": - vi, ok := val.(VarInt) - if !ok { - return fmt.Errorf("cannot convert %v to VarInt", val) + if v.sumType != "varInt" { + return fmt.Errorf("expected varInt, but got %v", v.sumType) } - v.varInt = &vi + return v.varInt.Marshal(cell, *ty.VarIntN, encoder) case "VarUintN": - vi, ok := val.(VarUInt) - if !ok { - return fmt.Errorf("cannot convert %v to VarUInt", val) + if v.sumType != "varUint" { + return fmt.Errorf("expected varUint, but got %v", v.sumType) } - v.varUint = &vi + return v.varUint.Marshal(cell, *ty.VarUintN, encoder) case "BitsN": - b, ok := val.(Bits) - if !ok { - return fmt.Errorf("cannot convert %v to Bits", val) + if v.sumType != "bits" { + return fmt.Errorf("expected bits, but got %v", v.sumType) } - v.bits = &b + return v.bits.Marshal(cell, *ty.BitsN, encoder) case "Nullable": - o, ok := val.(OptValue) - if !ok { - return fmt.Errorf("cannot convert %v to OptValue", val) + if v.sumType != "optionalValue" { + return fmt.Errorf("expected optionalValue, but got %v", v.sumType) } - v.optionalValue = &o + return v.optionalValue.Marshal(cell, *ty.Nullable, encoder) case "CellOf": - r, ok := val.(RefValue) - if !ok { - return fmt.Errorf("cannot convert %v to RefValue", val) + if v.sumType != "refValue" { + return fmt.Errorf("expected refValue, but got %v", v.sumType) } - v.refValue = &r + return v.refValue.Marshal(cell, *ty.CellOf, encoder) case "Tensor": - t, ok := val.(TensorValues) - if !ok { - return fmt.Errorf("cannot convert %v to TensorValues", val) + if v.sumType != "tensor" { + return fmt.Errorf("expected tensor, but got %v", v.sumType) } - v.tensor = &t + return v.tensor.Marshal(cell, *ty.Tensor, encoder) case "TupleWith": - t, ok := val.(TupleValues) - if !ok { - return fmt.Errorf("cannot convert %v to TupleValues", val) + if v.sumType != "tupleWith" { + return fmt.Errorf("expected tupleWith, but got %v", v.sumType) } - v.tupleWith = &t + return v.tupleWith.Marshal(cell, *ty.TupleWith, encoder) case "Map": - m, ok := val.(MapValue) - if !ok { - return fmt.Errorf("cannot convert %v to MapValue", val) + if v.sumType != "mp" { + return fmt.Errorf("expected mp, but got %v", v.sumType) } - v.mp = &m + return v.mp.Marshal(cell, *ty.Map, encoder) case "EnumRef": - e, ok := val.(EnumValue) - if !ok { - return fmt.Errorf("cannot convert %v to EnumValue", val) + if v.sumType != "enum" { + return fmt.Errorf("expected enum, but got %v", v.sumType) } - v.enum = &e + return v.enum.Marshal(cell, *ty.EnumRef, encoder) case "StructRef": - s, ok := val.(Struct) - if !ok { - return fmt.Errorf("cannot convert %v to Struct", val) + if v.sumType != "structValue" { + return fmt.Errorf("expected structValue, but got %v", v.sumType) } - v.structValue = &s + return v.structValue.Marshal(cell, *ty.StructRef, encoder) case "AliasRef": - a, ok := val.(AliasValue) - if !ok { - return fmt.Errorf("cannot convert %v to AliasValue", val) + if v.sumType != "alias" { + return fmt.Errorf("expected alias, but got %v", v.sumType) } - v.alias = &a + return v.alias.Marshal(cell, *ty.AliasRef, encoder) case "Generic": - g, ok := val.(GenericValue) - if !ok { - return fmt.Errorf("cannot convert %v to GenericValue", val) + if v.sumType != "generic" { + return fmt.Errorf("expected generic, but got %v", v.sumType) } - v.generic = &g + return v.generic.Marshal(cell, *ty.Generic, encoder) case "Union": - u, ok := val.(UnionValue) - if !ok { - return fmt.Errorf("cannot convert %v to UnionValue", val) + if v.sumType != "union" { + return fmt.Errorf("expected union, but got %v", v.sumType) } - v.union = &u + return v.union.Marshal(cell, *ty.Union, encoder) case "Int": - return fmt.Errorf("int not supported") + err = fmt.Errorf("int not supported") case "Coins": - c, ok := val.(CoinsValue) - if !ok { - return fmt.Errorf("cannot convert %v to CoinsValue", val) + if v.sumType != "coins" { + return fmt.Errorf("expected coins, but got %v", v.sumType) } - v.coins = &c + return v.coins.Marshal(cell, *ty.Coins, encoder) case "Bool": - b, ok := val.(BoolValue) - if !ok { - return fmt.Errorf("cannot convert %v to BoolValue", val) + if v.sumType != "bool" { + return fmt.Errorf("expected bool, but got %v", v.sumType) } - v.bool = &b + return v.bool.Marshal(cell, *ty.Bool, encoder) case "Cell": - a, ok := val.(Any) - if !ok { - return fmt.Errorf("cannot convert %v to Any", val) + if v.sumType != "cell" { + return fmt.Errorf("expected cell, but got %v", v.sumType) } - v.cell = &a + return v.cell.Marshal(cell, *ty.Cell, encoder) case "Slice": - return fmt.Errorf("slice not supported") + err = fmt.Errorf("slice not supported") case "Builder": - return fmt.Errorf("builder not supported") + err = fmt.Errorf("builder not supported") case "Callable": - return fmt.Errorf("callable not supported") + err = fmt.Errorf("callable not supported") case "Remaining": - r, ok := val.(RemainingValue) - if !ok { - return fmt.Errorf("cannot convert %v to RemainingValue", val) + if v.sumType != "remaining" { + return fmt.Errorf("expected remaining, but got %v", v.sumType) } - v.remaining = &r + return v.remaining.Marshal(cell, *ty.Remaining, encoder) case "Address": - i, ok := val.(InternalAddress) - if !ok { - return fmt.Errorf("cannot convert %v to InternalAddress", val) + if v.sumType != "internalAddress" { + return fmt.Errorf("expected internalAddress, but got %v", v.sumType) } - v.internalAddress = &i + return v.internalAddress.Marshal(cell, *ty.Address, encoder) case "AddressOpt": - o, ok := val.(OptionalAddress) - if !ok { - return fmt.Errorf("cannot convert %v to OptionalAddress", val) + if v.sumType != "optionalAddress" { + return fmt.Errorf("expected optionalAddress, but got %v", v.sumType) } - v.optionalAddress = &o + return v.optionalAddress.Marshal(cell, *ty.AddressOpt, encoder) case "AddressExt": - e, ok := val.(ExternalAddress) - if !ok { - return fmt.Errorf("cannot convert %v to ExternalAddress", val) + if v.sumType != "externalAddress" { + return fmt.Errorf("expected externalAddress, but got %v", v.sumType) } - v.externalAddress = &e + return v.externalAddress.Marshal(cell, *ty.AddressExt, encoder) case "AddressAny": - a, ok := val.(AnyAddress) - if !ok { - return fmt.Errorf("cannot convert %v to AnyAddress", val) + if v.sumType != "anyAddress" { + return fmt.Errorf("expected anyAddress, but got %v", v.sumType) } - v.anyAddress = &a + return v.anyAddress.Marshal(cell, *ty.AddressAny, encoder) case "TupleAny": - return fmt.Errorf("tuple any not supported") + err = fmt.Errorf("tuple any not supported") case "NullLiteral": - n, ok := val.(NullValue) - if !ok { - return fmt.Errorf("cannot convert %v to NullValue", val) + if v.sumType != "null" { + return fmt.Errorf("expected null, but got %v", v.sumType) } - v.null = &n + return v.null.Marshal(cell, *ty.NullLiteral, encoder) case "Void": - vo, ok := val.(VoidValue) - if !ok { - return fmt.Errorf("cannot convert %v to VoidValue", val) + if v.sumType != "void" { + return fmt.Errorf("expected void, but got %v", v.sumType) } - v.void = &vo + return v.void.Marshal(cell, *ty.Void, encoder) default: - return fmt.Errorf("unknown ty type %q", ty.SumType) + err = fmt.Errorf("unknown ty type %q", ty.SumType) + } + if err != nil { + return err } return nil } -type BoolValue bool +func (v *Value) unmarshalDefaultValue(d *tolkParser.DefaultValue, vType tolkParser.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 := v.unmarshalDefaultValue(&item, 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) + } -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 + return true, nil } -func (o *OptionalAddress) Equal(other any) bool { - otherOptionalAddress, ok := other.(OptionalAddress) +func (v *Value) Equal(o any) bool { + otherValue, ok := o.(Value) 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]) { + switch v.sumType { + case "bool": + if otherValue.bool == nil { 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 v.bool.Equal(*otherValue.bool) + case "smallInt": + if otherValue.smallInt == nil { 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 v.smallInt.Equal(*otherValue.smallInt) + case "smallUint": + if otherValue.smallUint == nil { return false } - if !m.values[i].Equal(otherMapValue.values[i]) { + return v.smallUint.Equal(*otherValue.smallUint) + case "bigInt": + if otherValue.bigInt == nil { 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 v.bigInt.Equal(*otherValue.bigInt) + case "bigUint": + if otherValue.bigUint == nil { + return false } - } - - 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 + return v.bigUint.Equal(*otherValue.bigUint) + case "varInt": + if otherValue.varInt == nil { + return false } - } - - 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-- + return v.varInt.Equal(*otherValue.varInt) + case "varUint": + if otherValue.varUint == nil { + return false } - } -} - -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 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 } - return true } From 282facbc14771633f9ad391c2087bb2ace401c7a Mon Sep 17 00:00:00 2001 From: Pavel Levchenko Date: Fri, 6 Feb 2026 17:12:02 +0300 Subject: [PATCH 05/16] add missing method --- tolk/addresses.go | 43 +++++- tolk/cells.go | 9 ++ tolk/map.go | 18 +++ tolk/null.go | 8 ++ tolk/parser/types.go | 22 +-- tolk/tuples.go | 33 +++++ tolk/union.go | 4 +- tolk/utils.go | 37 +++++ tolk/value.go | 332 +++++++++++++++++++++++++++++++++++++++++++ utils/json.go | 13 ++ 10 files changed, 499 insertions(+), 20 deletions(-) create mode 100644 utils/json.go diff --git a/tolk/addresses.go b/tolk/addresses.go index 43d87d37..10736c17 100644 --- a/tolk/addresses.go +++ b/tolk/addresses.go @@ -2,6 +2,7 @@ package tolk import ( "bytes" + "encoding/json" "fmt" "github.com/tonkeeper/tongo/boc" @@ -61,6 +62,10 @@ func (i *InternalAddress) ToRaw() string { return fmt.Sprintf("%v:%x", i.Workchain, i.Address) } +func (i *InternalAddress) MarshalJSON() ([]byte, error) { + return []byte(i.ToRaw()), nil +} + type NoneAddress struct { } @@ -81,6 +86,10 @@ func (n *NoneAddress) Marshal(cell *boc.Cell, ty tolkParser.AddressOpt, encoder return nil } +func (n *NoneAddress) MarshalJSON() ([]byte, error) { + return []byte(""), nil +} + type OptionalAddress struct { SumType NoneAddress *NoneAddress @@ -121,9 +130,19 @@ func (o *OptionalAddress) Unmarshal(cell *boc.Cell, ty tolkParser.AddressOpt, de func (o *OptionalAddress) Marshal(cell *boc.Cell, ty tolkParser.AddressOpt, encoder *Encoder) error { if o.SumType == "NoneAddress" { return o.NoneAddress.Marshal(cell, ty, encoder) + } else if o.SumType == "InternalAddress" { + return o.InternalAddress.Marshal(cell, tolkParser.Address{}, encoder) } + return fmt.Errorf("unknown any address SumType: %v", o.SumType) +} - return o.InternalAddress.Marshal(cell, tolkParser.Address{}, encoder) +func (o *OptionalAddress) MarshalJSON() ([]byte, error) { + if o.SumType == "NoneAddress" { + return json.Marshal(o.NoneAddress) + } else if o.SumType == "InternalAddress" { + return json.Marshal(o.InternalAddress) + } + return nil, fmt.Errorf("unknown any address SumType: %v", o.SumType) } type ExternalAddress struct { @@ -179,6 +198,10 @@ func (e *ExternalAddress) Equal(other any) bool { return bytes.Equal(e.Address.Buffer(), otherExternalAddress.Address.Buffer()) } +func (e *ExternalAddress) MarshalJSON() ([]byte, error) { + return []byte(e.Address.ToFiftHex()), nil +} + type AnyAddress struct { SumType InternalAddress *InternalAddress @@ -251,6 +274,20 @@ func (a *AnyAddress) Equal(other any) bool { return false } +func (a *AnyAddress) MarshalJSON() ([]byte, error) { + switch a.SumType { + case "NoneAddress": + return json.Marshal(a.NoneAddress) + case "InternalAddress": + return json.Marshal(a.InternalAddress) + case "ExternalAddress": + return json.Marshal(a.ExternalAddress) + case "VarAddress": + return json.Marshal(a.VarAddress) + } + return nil, fmt.Errorf("unknown any address SumType: %v", a.SumType) +} + type VarAddress struct { Len int16 Workchain int32 @@ -316,3 +353,7 @@ func (va *VarAddress) Marshal(cell *boc.Cell, ty tolkParser.AddressAny, encoder } return nil } + +func (va *VarAddress) MarshalJSON() ([]byte, error) { + return []byte(fmt.Sprintf("%d:%s", va.Workchain, va.Address.ToFiftHex())), nil +} diff --git a/tolk/cells.go b/tolk/cells.go index 644363cc..df708c9b 100644 --- a/tolk/cells.go +++ b/tolk/cells.go @@ -1,6 +1,8 @@ package tolk import ( + "encoding/json" + "github.com/tonkeeper/tongo/boc" "github.com/tonkeeper/tongo/tolk/parser" ) @@ -136,6 +138,13 @@ func (o *OptValue) Equal(other any) bool { return true } +func (o *OptValue) MarshalJSON() ([]byte, error) { + if o.IsExists { + return json.Marshal(o.Val) + } + return []byte("null"), nil +} + type RefValue Value func (r *RefValue) Unmarshal(cell *boc.Cell, ty tolkParser.CellOf, decoder *Decoder) error { diff --git a/tolk/map.go b/tolk/map.go index 45e17220..8c5da343 100644 --- a/tolk/map.go +++ b/tolk/map.go @@ -1,8 +1,10 @@ package tolk import ( + "encoding/json" "fmt" "math" + "strings" "github.com/tonkeeper/tongo/boc" "github.com/tonkeeper/tongo/tolk/parser" @@ -614,3 +616,19 @@ func (m *MapValue) DeleteByInternalAddress(k InternalAddress) { func (m *MapValue) Len() int { return m.len } + +func (m *MapValue) MarshalJSON() ([]byte, error) { + s := strings.Builder{} + s.WriteString("{\n") + for i, k := range m.keys { + s.WriteString(fmt.Sprintf("\"%v\":", k)) + val, err := json.Marshal(m.values[i]) + if err != nil { + return nil, err + } + s.WriteString(string(val)) + } + s.WriteString("}") + + return []byte(s.String()), nil +} diff --git a/tolk/null.go b/tolk/null.go index c6c6b054..ac970dcf 100644 --- a/tolk/null.go +++ b/tolk/null.go @@ -23,6 +23,10 @@ func (n *NullValue) Marshal(cell *boc.Cell, ty tolkParser.NullLiteral, encoder * return nil } +func (n *NullValue) MarshalJSON() ([]byte, error) { + return []byte("null"), nil +} + type VoidValue struct{} func (v *VoidValue) Equal(other any) bool { @@ -40,3 +44,7 @@ func (v *VoidValue) Unmarshal(cell *boc.Cell, ty tolkParser.Void, decoder *Decod func (v *VoidValue) Marshal(cell *boc.Cell, ty tolkParser.Void, encoder *Encoder) error { return nil } + +func (v *VoidValue) MarshalJSON() ([]byte, error) { + return []byte("null"), nil +} diff --git a/tolk/parser/types.go b/tolk/parser/types.go index e31fb4a3..61654727 100644 --- a/tolk/parser/types.go +++ b/tolk/parser/types.go @@ -95,19 +95,19 @@ func (d Declaration) MarshalJSON() ([]byte, error) { if err != nil { return nil, err } - return concatPrefixAndPayload(prefix, payload), nil + return utils.ConcatPrefixAndSuffixIfExists(prefix, payload), nil case "Alias": payload, err = json.Marshal(d.AliasDeclaration) if err != nil { return nil, err } - return concatPrefixAndPayload(prefix, payload), nil + return utils.ConcatPrefixAndSuffixIfExists(prefix, payload), nil case "Enum": payload, err = json.Marshal(d.EnumDeclaration) if err != nil { return nil, err } - return concatPrefixAndPayload(prefix, payload), nil + return utils.ConcatPrefixAndSuffixIfExists(prefix, payload), nil default: return nil, fmt.Errorf("unknown declaration type %q", d.SumType) } @@ -241,7 +241,7 @@ func (d *DefaultValue) MarshalJSON() ([]byte, error) { if err != nil { return nil, err } - return concatPrefixAndPayload(prefix, payload), nil + return utils.ConcatPrefixAndSuffixIfExists(prefix, payload), nil } type AliasDeclaration struct { @@ -660,7 +660,7 @@ func (t *Ty) MarshalJSON() ([]byte, error) { if err != nil { return nil, err } - return concatPrefixAndPayload(prefix, payload), nil + return utils.ConcatPrefixAndSuffixIfExists(prefix, payload), nil } func (t *Ty) GetFixedSize() (int, bool) { @@ -762,15 +762,3 @@ 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/tuples.go b/tolk/tuples.go index 034c62e7..c6b3d672 100644 --- a/tolk/tuples.go +++ b/tolk/tuples.go @@ -1,6 +1,9 @@ package tolk import ( + "encoding/json" + "strings" + "github.com/tonkeeper/tongo/boc" "github.com/tonkeeper/tongo/tolk/parser" ) @@ -31,6 +34,21 @@ func (v *TupleValues) Marshal(cell *boc.Cell, ty tolkParser.TupleWith, encoder * return nil } +func (v *TupleValues) MarshalJSON() ([]byte, error) { + s := strings.Builder{} + s.WriteString("[\n") + for _, item := range *v { + val, err := json.Marshal(item) + if err != nil { + return nil, err + } + s.WriteString(string(val)) + s.WriteString(",\n") + } + s.WriteString("]") + return []byte("null"), nil +} + func (v *TupleValues) Equal(other any) bool { otherTupleValues, ok := other.(TupleValues) if !ok { @@ -90,3 +108,18 @@ func (v *TensorValues) Equal(other any) bool { } return true } + +func (v *TensorValues) MarshalJSON() ([]byte, error) { + s := strings.Builder{} + s.WriteString("[\n") + for _, item := range *v { + val, err := json.Marshal(item) + if err != nil { + return nil, err + } + s.WriteString(string(val)) + s.WriteString(",\n") + } + s.WriteString("]") + return []byte("null"), nil +} diff --git a/tolk/union.go b/tolk/union.go index a8c840be..87e6bf84 100644 --- a/tolk/union.go +++ b/tolk/union.go @@ -40,7 +40,7 @@ func (u *UnionValue) Unmarshal(cell *boc.Cell, ty tolkParser.Union, decoder *Dec } for _, variant := range ty.Variants { - variantPrefix, err := tolkParser.PrefixToUint(variant.PrefixStr) + variantPrefix, err := PrefixToUint(variant.PrefixStr) if err != nil { return err } @@ -81,7 +81,7 @@ func (u *UnionValue) Marshal(cell *boc.Cell, ty tolkParser.Union, encoder *Encod } for _, variant := range ty.Variants { - variantPrefix, err := tolkParser.PrefixToUint(variant.PrefixStr) + variantPrefix, err := PrefixToUint(variant.PrefixStr) if err != nil { return err } diff --git a/tolk/utils.go b/tolk/utils.go index 4e37012c..1aeed3fc 100644 --- a/tolk/utils.go +++ b/tolk/utils.go @@ -62,3 +62,40 @@ func binDecHexToUint(num string) (*big.Int, error) { 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/tolk/value.go b/tolk/value.go index 7088212b..e8d2e9e0 100644 --- a/tolk/value.go +++ b/tolk/value.go @@ -4,12 +4,14 @@ package tolk import ( "encoding/hex" + "encoding/json" "fmt" "math/big" "github.com/tonkeeper/tongo/boc" "github.com/tonkeeper/tongo/tolk/parser" "github.com/tonkeeper/tongo/ton" + "github.com/tonkeeper/tongo/utils" ) type SumType string @@ -1091,3 +1093,333 @@ func (v *Value) Equal(o any) bool { return false } } + +type JSONSumType struct { + SumType string `json:"sumType"` +} + +//func (v *Value) UnmarshalJSON(b []byte) error { +// 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) MarshalJSON() ([]byte, error) { + st := JSONSumType{} + var payload []byte + var err error + + switch v.sumType { + case "bool": + st.SumType = "bool" + if v.bool == nil { + return nil, fmt.Errorf("bool value not found") + } + payload, err = json.Marshal(v.bool) + case "smallInt": + st.SumType = "smallInt" + if v.smallInt == nil { + return nil, fmt.Errorf("smallInt value not found") + } + payload, err = json.Marshal(v.smallInt) + case "smallUint": + st.SumType = "smallUint" + if v.smallUint == nil { + return nil, fmt.Errorf("smallUint value not found") + } + payload, err = json.Marshal(v.smallUint) + case "bigInt": + st.SumType = "bigInt" + if v.bigInt == nil { + return nil, fmt.Errorf("bigInt value not found") + } + payload, err = json.Marshal(v.bigInt) + case "bigUint": + st.SumType = "bigUint" + if v.bigUint == nil { + return nil, fmt.Errorf("bigUint value not found") + } + payload, err = json.Marshal(v.bigUint) + case "varInt": + st.SumType = "varInt" + if v.varInt == nil { + return nil, fmt.Errorf("varInt value not found") + } + payload, err = json.Marshal(v.varInt) + case "varUint": + st.SumType = "varUint" + if v.varUint == nil { + return nil, fmt.Errorf("varUint value not found") + } + payload, err = json.Marshal(v.varUint) + case "coins": + st.SumType = "coins" + if v.coins == nil { + return nil, fmt.Errorf("coins value not found") + } + payload, err = json.Marshal(v.coins) + case "bits": + st.SumType = "bits" + if v.bits == nil { + return nil, fmt.Errorf("bits value not found") + } + payload, err = json.Marshal(v.bits) + case "cell": + st.SumType = "cell" + if v.cell == nil { + return nil, fmt.Errorf("cell value not found") + } + payload, err = json.Marshal(v.cell) + case "remaining": + st.SumType = "remaining" + if v.remaining == nil { + return nil, fmt.Errorf("remaining value not found") + } + payload, err = json.Marshal(v.remaining) + case "internalAddress": + st.SumType = "internalAddress" + if v.internalAddress == nil { + return nil, fmt.Errorf("internalAddress value not found") + } + payload, err = json.Marshal(v.internalAddress) + case "optionalAddress": + st.SumType = "optionalAddress" + if v.optionalAddress == nil { + return nil, fmt.Errorf("optionalAddress value not found") + } + payload, err = json.Marshal(v.optionalAddress) + case "externalAddress": + st.SumType = "externalAddress" + if v.externalAddress == nil { + return nil, fmt.Errorf("externalAddress value not found") + } + payload, err = json.Marshal(v.externalAddress) + case "anyAddress": + st.SumType = "anyAddress" + if v.anyAddress == nil { + return nil, fmt.Errorf("anyAddress value not found") + } + payload, err = json.Marshal(v.anyAddress) + case "optionalValue": + st.SumType = "optionalValue" + if v.optionalValue == nil { + return nil, fmt.Errorf("optionalValue value not found") + } + payload, err = json.Marshal(v.optionalValue) + case "refValue": + st.SumType = "refValue" + if v.refValue == nil { + return nil, fmt.Errorf("refValue value not found") + } + payload, err = json.Marshal(v.refValue) + case "tupleWith": + st.SumType = "tuple" + if v.tupleWith == nil { + return nil, fmt.Errorf("tupleWith value not found") + } + payload, err = json.Marshal(v.tupleWith) + case "tensor": + st.SumType = "bool" + if v.tensor == nil { + return nil, fmt.Errorf("tensor value not found") + } + payload, err = json.Marshal(v.tensor) + case "mp": + st.SumType = "map" + if v.mp == nil { + return nil, fmt.Errorf("mp value not found") + } + payload, err = json.Marshal(v.mp) + case "structValue": + st.SumType = "struct" + if v.structValue == nil { + return nil, fmt.Errorf("structValue value not found") + } + payload, err = json.Marshal(v.structValue) + case "alias": + st.SumType = "alias" + if v.alias == nil { + return nil, fmt.Errorf("alias value not found") + } + payload, err = json.Marshal(v.alias) + case "enum": + st.SumType = "enum" + if v.enum == nil { + return nil, fmt.Errorf("enum value not found") + } + payload, err = json.Marshal(v.enum) + case "generic": + st.SumType = "generic" + if v.generic == nil { + return nil, fmt.Errorf("generic value not found") + } + payload, err = json.Marshal(v.generic) + case "union": + st.SumType = "union" + if v.union == nil { + return nil, fmt.Errorf("union value not found") + } + payload, err = json.Marshal(v.union) + case "null": + st.SumType = "null" + if v.null == nil { + return nil, fmt.Errorf("null value not found") + } + payload, err = json.Marshal(v.null) + case "void": + st.SumType = "void" + if v.void == nil { + return nil, fmt.Errorf("void value not found") + } + payload, err = json.Marshal(v.void) + default: + return nil, fmt.Errorf("unknown value type: %s", v.sumType) + } + + prefix, err := json.Marshal(st) + if err != nil { + return nil, err + } + return utils.ConcatPrefixAndSuffixIfExists(prefix, payload), nil +} diff --git a/utils/json.go b/utils/json.go new file mode 100644 index 00000000..2682e770 --- /dev/null +++ b/utils/json.go @@ -0,0 +1,13 @@ +package utils + +func ConcatPrefixAndSuffixIfExists(prefix, suffix []byte) []byte { + if len(suffix) == 0 { + return prefix + } + prefix = prefix[:len(prefix)-1] // remove '}' + suffix[0] = ',' // replace '{' with ',' + result := make([]byte, 0, len(prefix)+len(suffix)) + result = append(result, prefix...) + result = append(result, suffix...) + return result +} From edb7139abbbe58c87b2129c3c8d8cd93fb3a280c Mon Sep 17 00:00:00 2001 From: Pavel Levchenko Date: Wed, 11 Feb 2026 15:18:11 +0300 Subject: [PATCH 06/16] add json marshaling and unmarshaling for tolk runtime --- examples/tolk/main.go | 26 +- examples/tolk/output.json | 37 + tolk/addresses.go | 152 +- tolk/cells.go | 56 +- tolk/integers.go | 91 +- tolk/map.go | 199 ++- tolk/refs.go | 126 +- tolk/runtime_test.go | 1278 ++++++++++++++++- .../json/a_lot_generics_from_alias.json | 158 ++ .../json/a_lot_generics_from_struct.json | 155 ++ .../a_lot_generics_with_default_values.json | 78 + tolk/testdata/json/a_lot_numbers.json | 35 + tolk/testdata/json/a_lot_random_fields.json | 93 ++ tolk/testdata/json/a_lot_refs_from_alias.json | 131 ++ .../testdata/json/a_lot_refs_from_struct.json | 128 ++ tolk/testdata/json/address_key_map.json | 10 + tolk/testdata/json/any_external_address.json | 7 + tolk/testdata/json/any_internal_address.json | 7 + tolk/testdata/json/any_none_address.json | 6 + tolk/testdata/json/any_var_address.json | 7 + tolk/testdata/json/big_int.json | 4 + tolk/testdata/json/big_int_key_map.json | 10 + tolk/testdata/json/big_uint.json | 4 + tolk/testdata/json/bits.json | 4 + tolk/testdata/json/bits_int_key_map.json | 25 + tolk/testdata/json/bool.json | 4 + tolk/testdata/json/cell.json | 4 + tolk/testdata/json/coins.json | 4 + tolk/testdata/json/empty_tensor.json | 4 + tolk/testdata/json/exists_nullable.json | 10 + .../json/exists_optional_address.json | 7 + tolk/testdata/json/external_address.json | 4 + tolk/testdata/json/int_key_map.json | 10 + tolk/testdata/json/internal_address.json | 4 + tolk/testdata/json/not_exists_nullable.json | 6 + .../json/not_exists_optional_address.json | 6 + tolk/testdata/json/ref.json | 7 + tolk/testdata/json/remaining.json | 4 + tolk/testdata/json/small_int.json | 4 + tolk/testdata/json/small_uint.json | 4 + tolk/testdata/json/tensor.json | 40 + tolk/testdata/json/uint_key_map.json | 14 + tolk/testdata/json/union_with_bin_prefix.json | 30 + tolk/testdata/json/union_with_dec_prefix.json | 13 + tolk/testdata/json/union_with_hex_prefix.json | 24 + tolk/testdata/json/var_int.json | 4 + tolk/testdata/json/var_uint.json | 4 + tolk/tuples.go | 33 - tolk/union.go | 4 +- tolk/value.go | 1082 +++++--------- 50 files changed, 3304 insertions(+), 853 deletions(-) create mode 100755 examples/tolk/output.json create mode 100755 tolk/testdata/json/a_lot_generics_from_alias.json create mode 100755 tolk/testdata/json/a_lot_generics_from_struct.json create mode 100755 tolk/testdata/json/a_lot_generics_with_default_values.json create mode 100755 tolk/testdata/json/a_lot_numbers.json create mode 100755 tolk/testdata/json/a_lot_random_fields.json create mode 100755 tolk/testdata/json/a_lot_refs_from_alias.json create mode 100755 tolk/testdata/json/a_lot_refs_from_struct.json create mode 100755 tolk/testdata/json/address_key_map.json create mode 100755 tolk/testdata/json/any_external_address.json create mode 100755 tolk/testdata/json/any_internal_address.json create mode 100755 tolk/testdata/json/any_none_address.json create mode 100755 tolk/testdata/json/any_var_address.json create mode 100755 tolk/testdata/json/big_int.json create mode 100755 tolk/testdata/json/big_int_key_map.json create mode 100755 tolk/testdata/json/big_uint.json create mode 100755 tolk/testdata/json/bits.json create mode 100755 tolk/testdata/json/bits_int_key_map.json create mode 100755 tolk/testdata/json/bool.json create mode 100755 tolk/testdata/json/cell.json create mode 100755 tolk/testdata/json/coins.json create mode 100755 tolk/testdata/json/empty_tensor.json create mode 100755 tolk/testdata/json/exists_nullable.json create mode 100755 tolk/testdata/json/exists_optional_address.json create mode 100755 tolk/testdata/json/external_address.json create mode 100755 tolk/testdata/json/int_key_map.json create mode 100755 tolk/testdata/json/internal_address.json create mode 100755 tolk/testdata/json/not_exists_nullable.json create mode 100755 tolk/testdata/json/not_exists_optional_address.json create mode 100755 tolk/testdata/json/ref.json create mode 100755 tolk/testdata/json/remaining.json create mode 100644 tolk/testdata/json/small_int.json create mode 100755 tolk/testdata/json/small_uint.json create mode 100755 tolk/testdata/json/tensor.json create mode 100755 tolk/testdata/json/uint_key_map.json create mode 100755 tolk/testdata/json/union_with_bin_prefix.json create mode 100755 tolk/testdata/json/union_with_dec_prefix.json create mode 100755 tolk/testdata/json/union_with_hex_prefix.json create mode 100755 tolk/testdata/json/var_int.json create mode 100755 tolk/testdata/json/var_uint.json diff --git a/examples/tolk/main.go b/examples/tolk/main.go index a0924a0e..106d83c2 100644 --- a/examples/tolk/main.go +++ b/examples/tolk/main.go @@ -4,6 +4,7 @@ import ( "encoding/hex" "encoding/json" "fmt" + "os" "github.com/tonkeeper/tongo/boc" "github.com/tonkeeper/tongo/tolk" @@ -51,14 +52,8 @@ func main() { 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") - } + queryId := tolkStruct.MustGetField("queryId") + queryIdValue := queryId.MustGetSmallUInt() newOwner, ok := tolkStruct.GetField("newOwner") if !ok { @@ -105,6 +100,21 @@ func main() { panic("cannot get transfer.forwardPayload value") } + val, err := json.MarshalIndent(res, "", " ") + if err != nil { + panic(err) + } + inputFilename := "examples/tolk/output.json" + err = os.WriteFile(inputFilename, val, os.ModePerm) + if err != nil { + panic(err) + } + + tolkValue := tolk.Value{} + if err := json.Unmarshal(val, &tolkValue); err != nil { + panic(err) + } + 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()) diff --git a/examples/tolk/output.json b/examples/tolk/output.json new file mode 100755 index 00000000..3447074d --- /dev/null +++ b/examples/tolk/output.json @@ -0,0 +1,37 @@ +{ + "sumType": "struct", + "struct": { + "prefix": { + "len": 32, + "prefix": 1607220500 + }, + "fields": { + "queryId": { + "sumType": "smallUint", + "smallUint": 0 + }, + "newOwner": { + "sumType": "internalAddress", + "internalAddress": "0:6033a6e8071d39188423c4220e6439f3075c340fa2480e5d1d4883e2e1916e22" + }, + "responseDestination": { + "sumType": "internalAddress", + "internalAddress": "0:0d28df199ccd0ecd838435390e120ed55601688397c159d0ada90ae8d4c46653" + }, + "customPayload": { + "sumType": "optionalValue", + "optionalValue": { + "isExists": false + } + }, + "forwardAmount": { + "sumType": "coins", + "coins": "20000000" + }, + "forwardPayload": { + "sumType": "remaining", + "remaining": "b5ee9c7201010101000300000140" + } + } + } +} \ No newline at end of file diff --git a/tolk/addresses.go b/tolk/addresses.go index 10736c17..0472f74c 100644 --- a/tolk/addresses.go +++ b/tolk/addresses.go @@ -2,8 +2,11 @@ package tolk import ( "bytes" + "encoding/hex" "encoding/json" "fmt" + "strconv" + "strings" "github.com/tonkeeper/tongo/boc" "github.com/tonkeeper/tongo/tolk/parser" @@ -63,7 +66,25 @@ func (i *InternalAddress) ToRaw() string { } func (i *InternalAddress) MarshalJSON() ([]byte, error) { - return []byte(i.ToRaw()), nil + return []byte(fmt.Sprintf("\"%v:%x\"", i.Workchain, i.Address)), nil +} + +func (i *InternalAddress) UnmarshalJSON(b []byte) error { + addr := strings.Split(string(b[1:len(b)-1]), ":") + if len(addr) != 2 { + return fmt.Errorf("invalid address") + } + workchain, err := strconv.ParseInt(addr[0], 10, 32) + if err != nil { + return err + } + hexAddr, err := hex.DecodeString(addr[1]) + if err != nil { + return err + } + i.Workchain = int8(workchain) + i.Address = [32]byte(hexAddr) + return nil } type NoneAddress struct { @@ -86,10 +107,6 @@ func (n *NoneAddress) Marshal(cell *boc.Cell, ty tolkParser.AddressOpt, encoder return nil } -func (n *NoneAddress) MarshalJSON() ([]byte, error) { - return []byte(""), nil -} - type OptionalAddress struct { SumType NoneAddress *NoneAddress @@ -105,7 +122,7 @@ func (o *OptionalAddress) Equal(other any) bool { return false } if o.SumType == "InternalAddress" { - return o.InternalAddress.Equal(otherOptionalAddress.InternalAddress) + return o.InternalAddress.Equal(*otherOptionalAddress.InternalAddress) } return true } @@ -137,12 +154,39 @@ func (o *OptionalAddress) Marshal(cell *boc.Cell, ty tolkParser.AddressOpt, enco } func (o *OptionalAddress) MarshalJSON() ([]byte, error) { + var optinalAddress = struct { + SumType SumType `json:"sumType"` + InternalAddress *InternalAddress `json:"internalAddress,omitempty"` + }{} + optinalAddress.SumType = o.SumType if o.SumType == "NoneAddress" { - return json.Marshal(o.NoneAddress) + optinalAddress.SumType = "noneAddress" } else if o.SumType == "InternalAddress" { - return json.Marshal(o.InternalAddress) + optinalAddress.SumType = "internalAddress" + optinalAddress.InternalAddress = o.InternalAddress } - return nil, fmt.Errorf("unknown any address SumType: %v", o.SumType) + return json.Marshal(optinalAddress) +} + +func (o *OptionalAddress) UnmarshalJSON(b []byte) error { + var optinalAddress = struct { + SumType SumType `json:"sumType"` + InternalAddress *InternalAddress `json:"internalAddress,omitempty"` + }{} + if err := json.Unmarshal(b, &optinalAddress); err != nil { + return err + } + + if optinalAddress.SumType == "noneAddress" { + o.SumType = "NoneAddress" + o.NoneAddress = &NoneAddress{} + } else if optinalAddress.SumType == "internalAddress" { + o.SumType = "InternalAddress" + o.InternalAddress = optinalAddress.InternalAddress + } else { + return fmt.Errorf("unknown optional address SumType: %v", o.SumType) + } + return nil } type ExternalAddress struct { @@ -199,7 +243,18 @@ func (e *ExternalAddress) Equal(other any) bool { } func (e *ExternalAddress) MarshalJSON() ([]byte, error) { - return []byte(e.Address.ToFiftHex()), nil + return []byte(fmt.Sprintf("\"%s\"", e.Address.ToFiftHex())), nil +} + +func (e *ExternalAddress) UnmarshalJSON(b []byte) error { + addr, err := boc.BitStringFromFiftHex(string(b[1 : len(b)-1])) + if err != nil { + return fmt.Errorf("invalid external address format: %v", string(b)) + } + e.Len = int16(addr.BitsAvailableForRead()) + e.Address = *addr + + return nil } type AnyAddress struct { @@ -265,27 +320,67 @@ func (a *AnyAddress) Equal(other any) bool { case "NoneAddress": return true case "InternalAddress": - return a.InternalAddress.Equal(otherAnyAddress.InternalAddress) + return a.InternalAddress.Equal(*otherAnyAddress.InternalAddress) case "ExternalAddress": - return a.ExternalAddress.Equal(otherAnyAddress.ExternalAddress) + return a.ExternalAddress.Equal(*otherAnyAddress.ExternalAddress) case "VarAddress": - return a.VarAddress.Equal(otherAnyAddress.VarAddress) + return a.VarAddress.Equal(*otherAnyAddress.VarAddress) } return false } func (a *AnyAddress) MarshalJSON() ([]byte, error) { + var jsonAnyAddress = struct { + SumType string `json:"sumType"` + InternalAddress *InternalAddress `json:"internalAddress,omitempty"` + ExternalAddress *ExternalAddress `json:"externalAddress,omitempty"` + VarAddress *VarAddress `json:"varAddress,omitempty"` + }{} switch a.SumType { case "NoneAddress": - return json.Marshal(a.NoneAddress) + jsonAnyAddress.SumType = "noneAddress" case "InternalAddress": - return json.Marshal(a.InternalAddress) + jsonAnyAddress.SumType = "internalAddress" + jsonAnyAddress.InternalAddress = a.InternalAddress case "ExternalAddress": - return json.Marshal(a.ExternalAddress) + jsonAnyAddress.SumType = "externalAddress" + jsonAnyAddress.ExternalAddress = a.ExternalAddress case "VarAddress": - return json.Marshal(a.VarAddress) + jsonAnyAddress.SumType = "varAddress" + jsonAnyAddress.VarAddress = a.VarAddress + default: + return nil, fmt.Errorf("unknown any address SumType: %v", a.SumType) + } + return json.Marshal(&jsonAnyAddress) +} + +func (a *AnyAddress) UnmarshalJSON(b []byte) error { + var anyAddress = struct { + SumType string `json:"sumType"` + InternalAddress *InternalAddress `json:"internalAddress,omitempty"` + ExternalAddress *ExternalAddress `json:"externalAddress,omitempty"` + VarAddress *VarAddress `json:"varAddress,omitempty"` + }{} + if err := json.Unmarshal(b, &anyAddress); err != nil { + return err + } + switch anyAddress.SumType { + case "noneAddress": + a.SumType = "NoneAddress" + a.NoneAddress = &NoneAddress{} + case "internalAddress": + a.SumType = "InternalAddress" + a.InternalAddress = anyAddress.InternalAddress + case "externalAddress": + a.SumType = "ExternalAddress" + a.ExternalAddress = anyAddress.ExternalAddress + case "varAddress": + a.SumType = "VarAddress" + a.VarAddress = anyAddress.VarAddress + default: + return fmt.Errorf("unknown anyAddress SumType: %v", anyAddress.SumType) } - return nil, fmt.Errorf("unknown any address SumType: %v", a.SumType) + return nil } type VarAddress struct { @@ -355,5 +450,24 @@ func (va *VarAddress) Marshal(cell *boc.Cell, ty tolkParser.AddressAny, encoder } func (va *VarAddress) MarshalJSON() ([]byte, error) { - return []byte(fmt.Sprintf("%d:%s", va.Workchain, va.Address.ToFiftHex())), nil + return []byte(fmt.Sprintf("\"%d:%s\"", va.Workchain, va.Address.ToFiftHex())), nil +} + +func (va *VarAddress) UnmarshalJSON(b []byte) error { + parts := bytes.Split(b[1:len(b)-1], []byte(":")) + if len(parts) != 2 { + return fmt.Errorf("invalid var address format: %v", string(b)) + } + workchain, err := strconv.ParseInt(string(parts[0]), 10, 32) + if err != nil { + return err + } + bs, err := boc.BitStringFromFiftHex(string(parts[1])) + if err != nil { + return err + } + va.Workchain = int32(workchain) + va.Len = int16(bs.BitsAvailableForRead()) + va.Address = *bs + return nil } diff --git a/tolk/cells.go b/tolk/cells.go index df708c9b..6d7b4147 100644 --- a/tolk/cells.go +++ b/tolk/cells.go @@ -48,6 +48,19 @@ func (a *Any) Equal(o any) bool { return oHash == vHash } +func (a *Any) MarshalJSON() ([]byte, error) { + return boc.Cell(*a).MarshalJSON() +} + +func (a *Any) UnmarshalJSON(b []byte) error { + v := &boc.Cell{} + if err := json.Unmarshal(b, v); err != nil { + return err + } + *a = Any(*v) + return nil +} + type RemainingValue boc.Cell func (r *RemainingValue) Unmarshal(cell *boc.Cell, ty tolkParser.Remaining, decoder *Decoder) error { @@ -92,6 +105,19 @@ func (r *RemainingValue) Equal(o any) bool { return oHash == vHash } +func (r *RemainingValue) MarshalJSON() ([]byte, error) { + return boc.Cell(*r).MarshalJSON() +} + +func (r *RemainingValue) UnmarshalJSON(b []byte) error { + v := &boc.Cell{} + if err := json.Unmarshal(b, v); err != nil { + return err + } + *r = RemainingValue(*v) + return nil +} + type OptValue struct { IsExists bool Val Value @@ -139,10 +165,33 @@ func (o *OptValue) Equal(other any) bool { } func (o *OptValue) MarshalJSON() ([]byte, error) { + var jsonOptValue = struct { + IsExists bool `json:"isExists"` + Val *Value `json:"value,omitempty"` + }{ + IsExists: o.IsExists, + } + if o.IsExists { + jsonOptValue.Val = &o.Val + } + + return json.Marshal(jsonOptValue) +} + +func (o *OptValue) UnmarshalJSON(b []byte) error { + var jsonOptValue = struct { + IsExists bool `json:"isExists"` + Val *Value `json:"value,omitempty"` + }{} + if err := json.Unmarshal(b, &jsonOptValue); err != nil { + return err + } + o.IsExists = jsonOptValue.IsExists if o.IsExists { - return json.Marshal(o.Val) + o.Val = *jsonOptValue.Val } - return []byte("null"), nil + + return nil } type RefValue Value @@ -182,5 +231,6 @@ func (r *RefValue) Equal(other any) bool { if !ok { return false } - return r.Equal(otherRefValue) + v := Value(*r) + return v.Equal(Value(otherRefValue)) } diff --git a/tolk/integers.go b/tolk/integers.go index 6efafa05..adb00916 100644 --- a/tolk/integers.go +++ b/tolk/integers.go @@ -2,6 +2,8 @@ package tolk import ( "bytes" + "encoding/json" + "fmt" "math/big" "github.com/tonkeeper/tongo/boc" @@ -57,6 +59,20 @@ func (b *BigInt) Equal(other any) bool { return bi.Cmp(&otherBi) == 0 } +func (b *BigInt) MarshalJSON() ([]byte, error) { + bi := big.Int(*b) + return []byte(`"` + bi.String() + `"`), nil +} + +func (b *BigInt) UnmarshalJSON(bytes []byte) error { + bi, ok := new(big.Int).SetString(string(bytes[1:len(bytes)-1]), 10) + if !ok { + return fmt.Errorf("failed to unmarshal big.Int from %v", string(bytes[1:len(bytes)-1])) + } + *b = BigInt(*bi) + return nil +} + type UInt64 uint64 func (i *UInt64) Unmarshal(cell *boc.Cell, ty tolkParser.UintN, decoder *Decoder) error { @@ -106,6 +122,20 @@ func (b *BigUInt) Equal(other any) bool { return bi.Cmp(&otherBi) == 0 } +func (b *BigUInt) MarshalJSON() ([]byte, error) { + bi := big.Int(*b) + return []byte(`"` + bi.String() + `"`), nil +} + +func (b *BigUInt) UnmarshalJSON(bytes []byte) error { + bi, ok := new(big.Int).SetString(string(bytes[1:len(bytes)-1]), 10) + if !ok { + return fmt.Errorf("failed to unmarshal big.Int from %v", string(bytes[1:len(bytes)-1])) + } + *b = BigUInt(*bi) + return nil +} + type VarInt big.Int func (vi *VarInt) Unmarshal(cell *boc.Cell, ty tolkParser.VarIntN, decoder *Decoder) error { @@ -146,6 +176,20 @@ func (vi *VarInt) Equal(other any) bool { return bi.Cmp(&otherBi) == 0 } +func (vi *VarInt) MarshalJSON() ([]byte, error) { + bi := big.Int(*vi) + return []byte(`"` + bi.String() + `"`), nil +} + +func (vi *VarInt) UnmarshalJSON(bytes []byte) error { + bi, ok := new(big.Int).SetString(string(bytes[1:len(bytes)-1]), 10) + if !ok { + return fmt.Errorf("failed to unmarshal big.Int from %v", string(bytes[1:len(bytes)-1])) + } + *vi = VarInt(*bi) + return nil +} + type VarUInt big.Int func (vu *VarUInt) Unmarshal(cell *boc.Cell, ty tolkParser.VarUintN, decoder *Decoder) error { @@ -186,6 +230,20 @@ func (vu *VarUInt) Equal(other any) bool { return bi.Cmp(&otherBi) == 0 } +func (vu *VarUInt) MarshalJSON() ([]byte, error) { + bi := big.Int(*vu) + return []byte(`"` + bi.String() + `"`), nil +} + +func (vu *VarUInt) UnmarshalJSON(bytes []byte) error { + bi, ok := new(big.Int).SetString(string(bytes[1:len(bytes)-1]), 10) + if !ok { + return fmt.Errorf("failed to unmarshal big.Int from %v", string(bytes[1:len(bytes)-1])) + } + *vu = VarUInt(*bi) + return nil +} + type Bits boc.BitString func (b *Bits) Unmarshal(cell *boc.Cell, ty tolkParser.BitsN, decoder *Decoder) error { @@ -217,6 +275,19 @@ func (b *Bits) Equal(other any) bool { return bytes.Equal(bs.Buffer(), otherBs.Buffer()) } +func (b *Bits) MarshalJSON() ([]byte, error) { + return boc.BitString(*b).MarshalJSON() +} + +func (b *Bits) UnmarshalJSON(bytes []byte) error { + bs := boc.BitString{} + if err := json.Unmarshal(bytes, &bs); err != nil { + return err + } + *b = Bits(bs) + return nil +} + type CoinsValue big.Int func (c *CoinsValue) Unmarshal(cell *boc.Cell, ty tolkParser.Coins, decoder *Decoder) error { @@ -224,7 +295,7 @@ func (c *CoinsValue) Unmarshal(cell *boc.Cell, ty tolkParser.Coins, decoder *Dec if err != nil { return err } - val, err := cell.ReadBigInt(int(ln) * 8) + val, err := cell.ReadBigUint(int(ln) * 8) if err != nil { return err } @@ -233,8 +304,8 @@ func (c *CoinsValue) Unmarshal(cell *boc.Cell, ty tolkParser.Coins, decoder *Dec } func (c *CoinsValue) Marshal(cell *boc.Cell, ty tolkParser.Coins, encoder *Encoder) error { - varInt := VarInt(*c) - return varInt.Marshal(cell, tolkParser.VarIntN{N: 16}, encoder) // coins is actually varint16 + varInt := VarUInt(*c) + return varInt.Marshal(cell, tolkParser.VarUintN{N: 16}, encoder) // coins is actually varint16 } func (c *CoinsValue) Equal(other any) bool { @@ -247,6 +318,20 @@ func (c *CoinsValue) Equal(other any) bool { return bi.Cmp(&otherBi) == 0 } +func (c *CoinsValue) MarshalJSON() ([]byte, error) { + bi := big.Int(*c) + return []byte(`"` + bi.String() + `"`), nil +} + +func (c *CoinsValue) UnmarshalJSON(bytes []byte) error { + bi, ok := new(big.Int).SetString(string(bytes[1:len(bytes)-1]), 10) + if !ok { + return fmt.Errorf("failed to unmarshal big.Int from %v", string(bytes[1:len(bytes)-1])) + } + *c = CoinsValue(*bi) + return nil +} + type BoolValue bool func (b *BoolValue) Equal(o any) bool { diff --git a/tolk/map.go b/tolk/map.go index 8c5da343..2062be26 100644 --- a/tolk/map.go +++ b/tolk/map.go @@ -447,48 +447,48 @@ func (m *MapValue) Get(key Value) (Value, bool) { func (m *MapValue) GetBySmallInt(v Int64) (Value, bool) { key := Value{ - sumType: "smallInt", - smallInt: &v, + SumType: "smallInt", + SmallInt: &v, } return m.Get(key) } func (m *MapValue) GetBySmallUInt(v UInt64) (Value, bool) { key := Value{ - sumType: "smallUint", - smallUint: &v, + SumType: "smallUint", + SmallUint: &v, } return m.Get(key) } func (m *MapValue) GetByBigInt(v BigInt) (Value, bool) { key := Value{ - sumType: "bigInt", - bigInt: &v, + SumType: "bigInt", + BigInt: &v, } return m.Get(key) } func (m *MapValue) GetByBigUInt(v BigUInt) (Value, bool) { key := Value{ - sumType: "bigUint", - bigUint: &v, + SumType: "bigUint", + BigUint: &v, } return m.Get(key) } func (m *MapValue) GetByBits(v Bits) (Value, bool) { key := Value{ - sumType: "bits", - bits: &v, + SumType: "bits", + Bits: &v, } return m.Get(key) } func (m *MapValue) GetByInternalAddress(v InternalAddress) (Value, bool) { key := Value{ - sumType: "internalAddress", - internalAddress: &v, + SumType: "internalAddress", + InternalAddress: &v, } return m.Get(key) } @@ -509,48 +509,48 @@ func (m *MapValue) Set(key Value, value Value) (bool, error) { func (m *MapValue) SetBySmallInt(k Int64, value Value) (bool, error) { key := Value{ - sumType: "smallInt", - smallInt: &k, + SumType: "smallInt", + SmallInt: &k, } return m.Set(key, value) } func (m *MapValue) SetBySmallUInt(k UInt64, value Value) (bool, error) { key := Value{ - sumType: "smallUint", - smallUint: &k, + SumType: "smallUint", + SmallUint: &k, } return m.Set(key, value) } func (m *MapValue) SetByBigInt(k BigInt, value Value) (bool, error) { key := Value{ - sumType: "bigInt", - bigInt: &k, + SumType: "bigInt", + BigInt: &k, } return m.Set(key, value) } func (m *MapValue) SetByBigUInt(k BigUInt, value Value) (bool, error) { key := Value{ - sumType: "bigUint", - bigUint: &k, + SumType: "bigUint", + BigUint: &k, } return m.Set(key, value) } func (m *MapValue) SetByBits(k Bits, value Value) (bool, error) { key := Value{ - sumType: "bits", - bits: &k, + SumType: "bits", + Bits: &k, } return m.Set(key, value) } func (m *MapValue) SetByInternalAddress(k InternalAddress, value Value) (bool, error) { key := Value{ - sumType: "internalAddress", - internalAddress: &k, + SumType: "internalAddress", + InternalAddress: &k, } return m.Set(key, value) } @@ -567,48 +567,48 @@ func (m *MapValue) Delete(key Value) { func (m *MapValue) DeleteBySmallInt(k Int64) { key := Value{ - sumType: "smallInt", - smallInt: &k, + SumType: "smallInt", + SmallInt: &k, } m.Delete(key) } func (m *MapValue) DeleteBySmallUInt(k UInt64) { key := Value{ - sumType: "smallUint", - smallUint: &k, + SumType: "smallUint", + SmallUint: &k, } m.Delete(key) } func (m *MapValue) DeleteByBigInt(k BigInt) { key := Value{ - sumType: "bigInt", - bigInt: &k, + SumType: "bigInt", + BigInt: &k, } m.Delete(key) } func (m *MapValue) DeleteByBigUInt(k BigUInt) { key := Value{ - sumType: "bigUint", - bigUint: &k, + SumType: "bigUint", + BigUint: &k, } m.Delete(key) } func (m *MapValue) DeleteByBits(k Bits) { key := Value{ - sumType: "bits", - bits: &k, + SumType: "bits", + Bits: &k, } m.Delete(key) } func (m *MapValue) DeleteByInternalAddress(k InternalAddress) { key := Value{ - sumType: "internalAddress", - internalAddress: &k, + SumType: "internalAddress", + InternalAddress: &k, } m.Delete(key) } @@ -619,16 +619,129 @@ func (m *MapValue) Len() int { func (m *MapValue) MarshalJSON() ([]byte, error) { s := strings.Builder{} - s.WriteString("{\n") - for i, k := range m.keys { - s.WriteString(fmt.Sprintf("\"%v\":", k)) - val, err := json.Marshal(m.values[i]) - if err != nil { - return nil, err + s.WriteString("{") + if len(m.keys) > 0 { + s.WriteString("\"keySumType\":") + s.WriteString(fmt.Sprintf("\"%s\",", m.keys[0].SumType)) + for i, k := range m.keys { + if i != 0 { + s.WriteString(",") + } + key, err := json.Marshal(k) + if err != nil { + return nil, err + } + validKey, err := getKeyValue(string(key)) + if err != nil { + return nil, err + } + if validKey[0] == '{' { + return nil, fmt.Errorf("cannot use %v as a map key", key) + } + if validKey[0] != '"' { + validKey = fmt.Sprintf("\"%s\"", validKey) + } + s.WriteString(fmt.Sprintf("%v:", validKey)) + val, err := json.Marshal(m.values[i]) + if err != nil { + return nil, err + } + s.WriteString(string(val)) } - s.WriteString(string(val)) } s.WriteString("}") return []byte(s.String()), nil } + +func getKeyValue(key string) (string, error) { + foundComma := false + start := -1 + end := -1 + for i, v := range key { + if v == ',' { + foundComma = true + } + if v == ':' && foundComma && start == -1 { + start = i + } + if v == '}' { + end = i + break + } + } + if start == -1 || end == -1 || end < start { + return "", fmt.Errorf("invalid key") + } + return strings.ReplaceAll(key[start+1:end], " ", ""), nil +} + +func (m *MapValue) UnmarshalJSON(bytes []byte) error { + decoder := json.NewDecoder(strings.NewReader(string(bytes))) + _, err := decoder.Token() + if err != nil { + return err + } + + keyTypeDeclr, err := decoder.Token() + if err != nil { + return err + } + stringKeyTypeDeclr, ok := keyTypeDeclr.(string) + if !ok { + return fmt.Errorf("expected key type as a string") + } + if stringKeyTypeDeclr != "keySumType" { + return fmt.Errorf("map does not have key sum type") + } + + keyType, err := decoder.Token() + if err != nil { + return err + } + stringKeyType, ok := keyType.(string) + if !ok { + return fmt.Errorf("expected map value as a string") + } + valueTemplate := strings.Builder{} + valueTemplate.WriteString("{\"sumType\":\"") + valueTemplate.WriteString(stringKeyType) + valueTemplate.WriteString("\",\"") + valueTemplate.WriteString(stringKeyType) + valueTemplate.WriteString("\":%s}") + tmpl := valueTemplate.String() + + for decoder.More() { + keyValue, err := decoder.Token() + if err != nil { + return err + } + stringKeyValue, ok := keyValue.(string) + if !ok { + return fmt.Errorf("expected map key as a string") + } + keyValueJson := fmt.Sprintf(tmpl, getKeyAsValue(stringKeyType, stringKeyValue)) + key := Value{} + if err = json.Unmarshal([]byte(keyValueJson), &key); err != nil { + return err + } + + value := Value{} + if err = decoder.Decode(&value); err != nil { + return err + } + m.keys = append(m.keys, key) + m.values = append(m.values, value) + m.len++ + } + + return nil +} + +func getKeyAsValue(sumType, key string) string { + switch sumType { + case "smallInt", "smallUint": + return key + } + return fmt.Sprintf("\"%v\"", key) +} diff --git a/tolk/refs.go b/tolk/refs.go index be2cf601..d0b50005 100644 --- a/tolk/refs.go +++ b/tolk/refs.go @@ -1,9 +1,11 @@ package tolk import ( + "encoding/json" "fmt" "math/big" "slices" + "strings" "github.com/tonkeeper/tongo/boc" "github.com/tonkeeper/tongo/tolk/parser" @@ -11,8 +13,8 @@ import ( ) type Prefix struct { - Len int16 - Prefix uint64 + Len int16 `json:"len"` + Prefix uint64 `json:"prefix"` } type Struct struct { @@ -74,7 +76,7 @@ func (s *Struct) Unmarshal(cell *boc.Cell, ty tolkParser.StructRef, decoder *Dec } if field.Ty.SumType == "Nullable" { - optVal := *fieldVal.optionalValue + optVal := *fieldVal.OptionalValue defVal := field.DefaultValue if !optVal.IsExists && defVal != nil { val := Value{} @@ -157,6 +159,15 @@ func (s *Struct) GetField(field string) (Value, bool) { return Value{}, false } +func (s *Struct) MustGetField(field string) Value { + for i, name := range s.fieldNames { + if name == field { + return s.fieldValues[i] + } + } + panic("field with name " + field + " is not found") +} + func (s *Struct) SetField(field string, v Value) bool { for i, name := range s.fieldNames { if name == field { @@ -200,13 +211,86 @@ func (s *Struct) Equal(o any) bool { if !slices.Equal(s.fieldNames, otherStruct.fieldNames) { return false } - return slices.Equal(s.fieldValues, otherStruct.fieldValues) + for i, value := range s.fieldValues { + if !value.Equal(otherStruct.fieldValues[i]) { + return false + } + } + return true +} + +func (s *Struct) MarshalJSON() ([]byte, error) { + builder := strings.Builder{} + builder.WriteString("{") + if s.hasPrefix { + builder.WriteString("\"prefix\":") + prefix, err := json.Marshal(s.prefix) + if err != nil { + return nil, err + } + builder.Write(prefix) + builder.WriteRune(',') + } + builder.WriteString("\"fields\": {") + for i, name := range s.fieldNames { + if i != 0 { + builder.WriteRune(',') + } + builder.WriteString(fmt.Sprintf("\"%s\":", name)) + val, err := json.Marshal(&s.fieldValues[i]) + if err != nil { + return nil, err + } + builder.Write(val) + } + builder.WriteString("}}") + return []byte(builder.String()), nil +} + +func (s *Struct) UnmarshalJSON(bytes []byte) error { + var jsonStruct = struct { + Prefix *Prefix `json:"prefix,omitempty"` + Fields json.RawMessage `json:"fields"` + }{} + if err := json.Unmarshal(bytes, &jsonStruct); err != nil { + return err + } + if jsonStruct.Prefix != nil { + s.hasPrefix = true + s.prefix = *jsonStruct.Prefix + } + + decoder := json.NewDecoder(strings.NewReader(string(jsonStruct.Fields))) + + _, err := decoder.Token() // { + if err != nil { + return err + } + for decoder.More() { + key, err := decoder.Token() + if err != nil { + return err + } + stringKey, ok := key.(string) + if !ok { + return fmt.Errorf("expected string key") + } + var val Value + if err = decoder.Decode(&val); err != nil { + return err + } + + s.fieldNames = append(s.fieldNames, stringKey) + s.fieldValues = append(s.fieldValues, val) + } + + return nil } type EnumValue struct { - val Value - Name string - Value big.Int + ActualValue Value `json:"actualValue"` + Name string `json:"name"` + Value big.Int `json:"value"` } func (e *EnumValue) Unmarshal(cell *boc.Cell, ty tolkParser.EnumRef, decoder *Decoder) error { @@ -227,20 +311,20 @@ func (e *EnumValue) Unmarshal(cell *boc.Cell, ty tolkParser.EnumRef, decoder *De switch enum.EncodedAs.SumType { case "IntN": if enum.EncodedAs.IntN.N > 64 { - bigEnumVal = big.Int(*enumVal.bigInt) + bigEnumVal = big.Int(*enumVal.BigInt) } else { - bigEnumVal = *big.NewInt(int64(*enumVal.smallInt)) + bigEnumVal = *big.NewInt(int64(*enumVal.SmallInt)) } case "UintN": if enum.EncodedAs.UintN.N > 64 { - bigEnumVal = big.Int(*enumVal.bigUint) + bigEnumVal = big.Int(*enumVal.BigUint) } else { - bigEnumVal = *new(big.Int).SetUint64(uint64(*enumVal.smallUint)) + bigEnumVal = *new(big.Int).SetUint64(uint64(*enumVal.SmallUint)) } case "VarIntN": - bigEnumVal = big.Int(*enumVal.varInt) + bigEnumVal = big.Int(*enumVal.VarInt) case "VarUintN": - bigEnumVal = big.Int(*enumVal.varUint) + bigEnumVal = big.Int(*enumVal.VarUint) default: return fmt.Errorf("enum encode type must be integer, got: %s", enum.EncodedAs.SumType) } @@ -253,9 +337,9 @@ func (e *EnumValue) Unmarshal(cell *boc.Cell, ty tolkParser.EnumRef, decoder *De if val.Cmp(&bigEnumVal) == 0 { *e = EnumValue{ - val: enumVal, - Name: member.Name, - Value: *val, + ActualValue: enumVal, + Name: member.Name, + Value: *val, } return nil @@ -263,9 +347,9 @@ func (e *EnumValue) Unmarshal(cell *boc.Cell, ty tolkParser.EnumRef, decoder *De } // todo: maybe return err? *e = EnumValue{ - val: enumVal, - Name: "Unknown", - Value: bigEnumVal, + ActualValue: enumVal, + Name: "Unknown", + Value: bigEnumVal, } return nil @@ -280,7 +364,7 @@ func (e *EnumValue) Marshal(cell *boc.Cell, ty tolkParser.EnumRef, encoder *Enco return fmt.Errorf("no enum with name %s was found in given abi", ty.EnumName) } - err := e.val.Marshal(cell, enum.EncodedAs, encoder) + err := e.ActualValue.Marshal(cell, enum.EncodedAs, encoder) if err != nil { return err } @@ -309,7 +393,7 @@ func (e *EnumValue) Equal(other any) bool { if e.Value.Cmp(&otherEnumValue.Value) != 0 { return false } - return e.val.Equal(otherEnumValue.val) + return e.ActualValue.Equal(otherEnumValue.ActualValue) } type AliasValue Value diff --git a/tolk/runtime_test.go b/tolk/runtime_test.go index c56dfbf2..5c134800 100644 --- a/tolk/runtime_test.go +++ b/tolk/runtime_test.go @@ -14,7 +14,10 @@ import ( "github.com/tonkeeper/tongo/ton" ) +const jsonFilesPath = "testdata/json/" + func TestRuntime_UnmarshalSmallInt(t *testing.T) { + inputFilename := "small_int" ty := tolkParser.Ty{ SumType: "IntN", IntN: &tolkParser.IntN{ @@ -38,9 +41,27 @@ func TestRuntime_UnmarshalSmallInt(t *testing.T) { if val != -35132 { t.Errorf("val != -35132, got %v", val) } + + pathPrefix := jsonFilesPath + inputFilename + actual, err := json.MarshalIndent(v, "", " ") + if err != nil { + t.Fatal(err) + } + err = os.WriteFile(pathPrefix+".output.json", actual, os.ModePerm) + if err != nil { + t.Fatal(err) + } + expected, err := os.ReadFile(pathPrefix + ".json") + if err != nil { + t.Fatal(err) + } + if !bytes.Equal(actual, expected) { + t.Errorf("%s got different results", pathPrefix) + } } func TestRuntime_UnmarshalBigInt(t *testing.T) { + inputFilename := "big_int" ty := tolkParser.Ty{ SumType: "IntN", IntN: &tolkParser.IntN{ @@ -64,9 +85,27 @@ func TestRuntime_UnmarshalBigInt(t *testing.T) { if val.Cmp(big.NewInt(-3513294376431)) != 0 { t.Errorf("val != -3513294376431, got %v", val) } + + pathPrefix := jsonFilesPath + inputFilename + actual, err := json.MarshalIndent(v, "", " ") + if err != nil { + t.Fatal(err) + } + err = os.WriteFile(pathPrefix+".output.json", actual, os.ModePerm) + if err != nil { + t.Fatal(err) + } + expected, err := os.ReadFile(pathPrefix + ".json") + if err != nil { + t.Fatal(err) + } + if !bytes.Equal(actual, expected) { + t.Errorf("%s got different results", pathPrefix) + } } func TestRuntime_UnmarshalSmallUInt(t *testing.T) { + inputFilename := "small_uint" ty := tolkParser.Ty{ SumType: "UintN", UintN: &tolkParser.UintN{ @@ -90,9 +129,27 @@ func TestRuntime_UnmarshalSmallUInt(t *testing.T) { if val != 934 { t.Errorf("val != 934, got %v", val) } + + pathPrefix := jsonFilesPath + inputFilename + actual, err := json.MarshalIndent(v, "", " ") + if err != nil { + t.Fatal(err) + } + err = os.WriteFile(pathPrefix+".output.json", actual, os.ModePerm) + if err != nil { + t.Fatal(err) + } + expected, err := os.ReadFile(pathPrefix + ".json") + if err != nil { + t.Fatal(err) + } + if !bytes.Equal(actual, expected) { + t.Errorf("%s got different results", pathPrefix) + } } func TestRuntime_UnmarshalBigUInt(t *testing.T) { + inputFilename := "big_uint" ty := tolkParser.Ty{ SumType: "UintN", UintN: &tolkParser.UintN{ @@ -116,9 +173,27 @@ func TestRuntime_UnmarshalBigUInt(t *testing.T) { if val.Cmp(big.NewInt(351329437643124)) != 0 { t.Errorf("val != 351329437643124, got %v", val.String()) } + + pathPrefix := jsonFilesPath + inputFilename + actual, err := json.MarshalIndent(v, "", " ") + if err != nil { + t.Fatal(err) + } + err = os.WriteFile(pathPrefix+".output.json", actual, os.ModePerm) + if err != nil { + t.Fatal(err) + } + expected, err := os.ReadFile(pathPrefix + ".json") + if err != nil { + t.Fatal(err) + } + if !bytes.Equal(actual, expected) { + t.Errorf("%s got different results", pathPrefix) + } } func TestRuntime_UnmarshalVarInt(t *testing.T) { + inputFilename := "var_int" ty := tolkParser.Ty{ SumType: "VarIntN", VarIntN: &tolkParser.VarIntN{ @@ -142,9 +217,27 @@ func TestRuntime_UnmarshalVarInt(t *testing.T) { if val.Cmp(big.NewInt(825432)) != 0 { t.Errorf("val != 825432, got %v", val.String()) } + + pathPrefix := jsonFilesPath + inputFilename + actual, err := json.MarshalIndent(v, "", " ") + if err != nil { + t.Fatal(err) + } + err = os.WriteFile(pathPrefix+".output.json", actual, os.ModePerm) + if err != nil { + t.Fatal(err) + } + expected, err := os.ReadFile(pathPrefix + ".json") + if err != nil { + t.Fatal(err) + } + if !bytes.Equal(actual, expected) { + t.Errorf("%s got different results", pathPrefix) + } } func TestRuntime_UnmarshalVarUInt(t *testing.T) { + inputFilename := "var_uint" ty := tolkParser.Ty{ SumType: "VarUintN", VarUintN: &tolkParser.VarUintN{ @@ -168,9 +261,27 @@ func TestRuntime_UnmarshalVarUInt(t *testing.T) { if val.Cmp(big.NewInt(9451236712)) != 0 { t.Errorf("val != 9451236712, got %v", val.String()) } + + pathPrefix := jsonFilesPath + inputFilename + actual, err := json.MarshalIndent(v, "", " ") + if err != nil { + t.Fatal(err) + } + err = os.WriteFile(pathPrefix+".output.json", actual, os.ModePerm) + if err != nil { + t.Fatal(err) + } + expected, err := os.ReadFile(pathPrefix + ".json") + if err != nil { + t.Fatal(err) + } + if !bytes.Equal(actual, expected) { + t.Errorf("%s got different results", pathPrefix) + } } func TestRuntime_UnmarshalBits(t *testing.T) { + inputFilename := "bits" ty := tolkParser.Ty{ SumType: "BitsN", BitsN: &tolkParser.BitsN{ @@ -194,9 +305,27 @@ func TestRuntime_UnmarshalBits(t *testing.T) { if bytes.Equal(val.Buffer(), []byte{55, 56, 57}) { t.Errorf("val != {55, 56, 57}, got %v", val) } + + pathPrefix := jsonFilesPath + inputFilename + actual, err := json.MarshalIndent(v, "", " ") + if err != nil { + t.Fatal(err) + } + err = os.WriteFile(pathPrefix+".output.json", actual, os.ModePerm) + if err != nil { + t.Fatal(err) + } + expected, err := os.ReadFile(pathPrefix + ".json") + if err != nil { + t.Fatal(err) + } + if !bytes.Equal(actual, expected) { + t.Errorf("%s got different results", pathPrefix) + } } func TestRuntime_UnmarshalCoins(t *testing.T) { + inputFilename := "coins" ty := tolkParser.Ty{ SumType: "Coins", Coins: &tolkParser.Coins{}, @@ -218,9 +347,27 @@ func TestRuntime_UnmarshalCoins(t *testing.T) { if val.Cmp(big.NewInt(921464321)) != 0 { t.Errorf("val != 921464321, got %v", val) } + + pathPrefix := jsonFilesPath + inputFilename + actual, err := json.MarshalIndent(v, "", " ") + if err != nil { + t.Fatal(err) + } + err = os.WriteFile(pathPrefix+".output.json", actual, os.ModePerm) + if err != nil { + t.Fatal(err) + } + expected, err := os.ReadFile(pathPrefix + ".json") + if err != nil { + t.Fatal(err) + } + if !bytes.Equal(actual, expected) { + t.Errorf("%s got different results", pathPrefix) + } } func TestRuntime_UnmarshalBool(t *testing.T) { + inputFilename := "bool" ty := tolkParser.Ty{ SumType: "Bool", Bool: &tolkParser.Bool{}, @@ -242,9 +389,27 @@ func TestRuntime_UnmarshalBool(t *testing.T) { if val { t.Error("val is true") } + + pathPrefix := jsonFilesPath + inputFilename + actual, err := json.MarshalIndent(v, "", " ") + if err != nil { + t.Fatal(err) + } + err = os.WriteFile(pathPrefix+".output.json", actual, os.ModePerm) + if err != nil { + t.Fatal(err) + } + expected, err := os.ReadFile(pathPrefix + ".json") + if err != nil { + t.Fatal(err) + } + if !bytes.Equal(actual, expected) { + t.Errorf("%s got different results", pathPrefix) + } } func TestRuntime_UnmarshalCell(t *testing.T) { + inputFilename := "cell" ty := tolkParser.Ty{ SumType: "Cell", Cell: &tolkParser.Cell{}, @@ -270,9 +435,27 @@ func TestRuntime_UnmarshalCell(t *testing.T) { if hs != "644e68a539c5107401d194bc82169cbf0ad1635796891551e0750705ab2d74ae" { t.Errorf("val.Hash() != 644e68a539c5107401d194bc82169cbf0ad1635796891551e0750705ab2d74ae, got %v", hs) } + + pathPrefix := jsonFilesPath + inputFilename + actual, err := json.MarshalIndent(v, "", " ") + if err != nil { + t.Fatal(err) + } + err = os.WriteFile(pathPrefix+".output.json", actual, os.ModePerm) + if err != nil { + t.Fatal(err) + } + expected, err := os.ReadFile(pathPrefix + ".json") + if err != nil { + t.Fatal(err) + } + if !bytes.Equal(actual, expected) { + t.Errorf("%s got different results", pathPrefix) + } } func TestRuntime_UnmarshalRemaining(t *testing.T) { + inputFilename := "remaining" ty := tolkParser.Ty{ SumType: "Remaining", Remaining: &tolkParser.Remaining{}, @@ -298,9 +481,27 @@ func TestRuntime_UnmarshalRemaining(t *testing.T) { if hs != "f1c4e07fbd1786411c2caa9ac9f5d7240aa2007a2a1d5e5ac44f8a168cd4e36b" { t.Errorf("val.Hash() != f1c4e07fbd1786411c2caa9ac9f5d7240aa2007a2a1d5e5ac44f8a168cd4e36b, got %v", hs) } + + pathPrefix := jsonFilesPath + inputFilename + actual, err := json.MarshalIndent(v, "", " ") + if err != nil { + t.Fatal(err) + } + err = os.WriteFile(pathPrefix+".output.json", actual, os.ModePerm) + if err != nil { + t.Fatal(err) + } + expected, err := os.ReadFile(pathPrefix + ".json") + if err != nil { + t.Fatal(err) + } + if !bytes.Equal(actual, expected) { + t.Errorf("%s got different results", pathPrefix) + } } func TestRuntime_UnmarshalAddress(t *testing.T) { + inputFilename := "internal_address" ty := tolkParser.Ty{ SumType: "Address", Address: &tolkParser.Address{}, @@ -322,9 +523,27 @@ func TestRuntime_UnmarshalAddress(t *testing.T) { if val.ToRaw() != "0:83dfd552e63729b472fcbcc8c45ebcc6691702558b68ec7527e1ba403a0f31a8" { t.Errorf("val.GetAddress() != 0:83dfd552e63729b472fcbcc8c45ebcc6691702558b68ec7527e1ba403a0f31a8, got %v", val.ToRaw()) } + + pathPrefix := jsonFilesPath + inputFilename + actual, err := json.MarshalIndent(v, "", " ") + if err != nil { + t.Fatal(err) + } + err = os.WriteFile(pathPrefix+".output.json", actual, os.ModePerm) + if err != nil { + t.Fatal(err) + } + expected, err := os.ReadFile(pathPrefix + ".json") + if err != nil { + t.Fatal(err) + } + if !bytes.Equal(actual, expected) { + t.Errorf("%s got different results", pathPrefix) + } } func TestRuntime_UnmarshalNotExitsOptionalAddress(t *testing.T) { + inputFilename := "not_exists_optional_address" ty := tolkParser.Ty{ SumType: "AddressOpt", AddressOpt: &tolkParser.AddressOpt{}, @@ -347,9 +566,27 @@ func TestRuntime_UnmarshalNotExitsOptionalAddress(t *testing.T) { if val.SumType != "NoneAddress" { t.Errorf("val.GetAddress() != none address") } + + pathPrefix := jsonFilesPath + inputFilename + actual, err := json.MarshalIndent(v, "", " ") + if err != nil { + t.Fatal(err) + } + err = os.WriteFile(pathPrefix+".output.json", actual, os.ModePerm) + if err != nil { + t.Fatal(err) + } + expected, err := os.ReadFile(pathPrefix + ".json") + if err != nil { + t.Fatal(err) + } + if !bytes.Equal(actual, expected) { + t.Errorf("%s got different results", pathPrefix) + } } func TestRuntime_UnmarshalExistsOptionalAddress(t *testing.T) { + inputFilename := "exists_optional_address" ty := tolkParser.Ty{ SumType: "AddressOpt", AddressOpt: &tolkParser.AddressOpt{}, @@ -372,9 +609,27 @@ func TestRuntime_UnmarshalExistsOptionalAddress(t *testing.T) { if val.SumType == "InternalAddress" && val.InternalAddress.ToRaw() != "0:83dfd552e63729b472fcbcc8c45ebcc6691702558b68ec7527e1ba403a0f31a8" { t.Errorf("val.GetAddress() != 0:83dfd552e63729b472fcbcc8c45ebcc6691702558b68ec7527e1ba403a0f31a8, got %v", val.InternalAddress.ToRaw()) } + + pathPrefix := jsonFilesPath + inputFilename + actual, err := json.MarshalIndent(v, "", " ") + if err != nil { + t.Fatal(err) + } + err = os.WriteFile(pathPrefix+".output.json", actual, os.ModePerm) + if err != nil { + t.Fatal(err) + } + expected, err := os.ReadFile(pathPrefix + ".json") + if err != nil { + t.Fatal(err) + } + if !bytes.Equal(actual, expected) { + t.Errorf("%s got different results", pathPrefix) + } } func TestRuntime_UnmarshalExternalAddress(t *testing.T) { + inputFilename := "external_address" ty := tolkParser.Ty{ SumType: "AddressExt", AddressExt: &tolkParser.AddressExt{}, @@ -401,9 +656,27 @@ func TestRuntime_UnmarshalExternalAddress(t *testing.T) { if val.Len != 8 && bytes.Equal(val.Address.Buffer(), []byte{97, 98}) { t.Errorf("val.GetExternalAddress() != {97, 98}, got %v", val.Address.Buffer()) } + + pathPrefix := jsonFilesPath + inputFilename + actual, err := json.MarshalIndent(v, "", " ") + if err != nil { + t.Fatal(err) + } + err = os.WriteFile(pathPrefix+".output.json", actual, os.ModePerm) + if err != nil { + t.Fatal(err) + } + expected, err := os.ReadFile(pathPrefix + ".json") + if err != nil { + t.Fatal(err) + } + if !bytes.Equal(actual, expected) { + t.Errorf("%s got different results", pathPrefix) + } } func TestRuntime_UnmarshalAnyNoneAddress(t *testing.T) { + inputFilename := "any_none_address" ty := tolkParser.Ty{ SumType: "AddressAny", AddressAny: &tolkParser.AddressAny{}, @@ -425,9 +698,27 @@ func TestRuntime_UnmarshalAnyNoneAddress(t *testing.T) { if val.SumType != "NoneAddress" { t.Errorf("val.GetAddress() != none address") } + + pathPrefix := jsonFilesPath + inputFilename + actual, err := json.MarshalIndent(v, "", " ") + if err != nil { + t.Fatal(err) + } + err = os.WriteFile(pathPrefix+".output.json", actual, os.ModePerm) + if err != nil { + t.Fatal(err) + } + expected, err := os.ReadFile(pathPrefix + ".json") + if err != nil { + t.Fatal(err) + } + if !bytes.Equal(actual, expected) { + t.Errorf("%s got different results", pathPrefix) + } } func TestRuntime_UnmarshalAnyInternalAddress(t *testing.T) { + inputFilename := "any_internal_address" ty := tolkParser.Ty{ SumType: "AddressAny", AddressAny: &tolkParser.AddressAny{}, @@ -449,9 +740,27 @@ func TestRuntime_UnmarshalAnyInternalAddress(t *testing.T) { if val.SumType == "InternalAddress" && val.InternalAddress.ToRaw() != "0:83dfd552e63729b472fcbcc8c45ebcc6691702558b68ec7527e1ba403a0f31a8" { t.Errorf("val.GetAddress() != 0:83dfd552e63729b472fcbcc8c45ebcc6691702558b68ec7527e1ba403a0f31a8, got %v", val.InternalAddress.ToRaw()) } + + pathPrefix := jsonFilesPath + inputFilename + actual, err := json.MarshalIndent(v, "", " ") + if err != nil { + t.Fatal(err) + } + err = os.WriteFile(pathPrefix+".output.json", actual, os.ModePerm) + if err != nil { + t.Fatal(err) + } + expected, err := os.ReadFile(pathPrefix + ".json") + if err != nil { + t.Fatal(err) + } + if !bytes.Equal(actual, expected) { + t.Errorf("%s got different results", pathPrefix) + } } func TestRuntime_UnmarshalAnyExternalAddress(t *testing.T) { + inputFilename := "any_external_address" ty := tolkParser.Ty{ SumType: "AddressAny", AddressAny: &tolkParser.AddressAny{}, @@ -478,9 +787,27 @@ func TestRuntime_UnmarshalAnyExternalAddress(t *testing.T) { 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()) } + + pathPrefix := jsonFilesPath + inputFilename + actual, err := json.MarshalIndent(v, "", " ") + if err != nil { + t.Fatal(err) + } + err = os.WriteFile(pathPrefix+".output.json", actual, os.ModePerm) + if err != nil { + t.Fatal(err) + } + expected, err := os.ReadFile(pathPrefix + ".json") + if err != nil { + t.Fatal(err) + } + if !bytes.Equal(actual, expected) { + t.Errorf("%s got different results", pathPrefix) + } } func TestRuntime_UnmarshalAnyVarAddress(t *testing.T) { + inputFilename := "any_var_address" ty := tolkParser.Ty{ SumType: "AddressAny", AddressAny: &tolkParser.AddressAny{}, @@ -511,9 +838,27 @@ func TestRuntime_UnmarshalAnyVarAddress(t *testing.T) { if bytes.Equal(val.VarAddress.Address.Buffer(), []byte{97, 98}) { t.Errorf("val.GetExternalAddress() != {97, 98}, got %v", val.ExternalAddress.Address.Buffer()) } + + pathPrefix := jsonFilesPath + inputFilename + actual, err := json.MarshalIndent(v, "", " ") + if err != nil { + t.Fatal(err) + } + err = os.WriteFile(pathPrefix+".output.json", actual, os.ModePerm) + if err != nil { + t.Fatal(err) + } + expected, err := os.ReadFile(pathPrefix + ".json") + if err != nil { + t.Fatal(err) + } + if !bytes.Equal(actual, expected) { + t.Errorf("%s got different results", pathPrefix) + } } func TestRuntime_UnmarshalNotExistsNullable(t *testing.T) { + inputFilename := "not_exists_nullable" ty := tolkParser.Ty{ SumType: "Nullable", Nullable: &tolkParser.Nullable{ @@ -540,9 +885,27 @@ func TestRuntime_UnmarshalNotExistsNullable(t *testing.T) { if val.IsExists { t.Errorf("v.GetOptionalValue() is exists") } + + pathPrefix := jsonFilesPath + inputFilename + actual, err := json.MarshalIndent(v, "", " ") + if err != nil { + t.Fatal(err) + } + err = os.WriteFile(pathPrefix+".output.json", actual, os.ModePerm) + if err != nil { + t.Fatal(err) + } + expected, err := os.ReadFile(pathPrefix + ".json") + if err != nil { + t.Fatal(err) + } + if !bytes.Equal(actual, expected) { + t.Errorf("%s got different results", pathPrefix) + } } func TestRuntime_UnmarshalExistsNullable(t *testing.T) { + inputFilename := "exists_nullable" ty := tolkParser.Ty{ SumType: "Nullable", Nullable: &tolkParser.Nullable{ @@ -580,9 +943,27 @@ func TestRuntime_UnmarshalExistsNullable(t *testing.T) { if hs != "df05386a55563049a4834a4cc1ec0dc22f3dcb63c04f7258ae475c5d28981773" { t.Errorf("v.GetOptionalValue().GetCell() != df05386a55563049a4834a4cc1ec0dc22f3dcb63c04f7258ae475c5d28981773, got %v", hs) } + + pathPrefix := jsonFilesPath + inputFilename + actual, err := json.MarshalIndent(v, "", " ") + if err != nil { + t.Fatal(err) + } + err = os.WriteFile(pathPrefix+".output.json", actual, os.ModePerm) + if err != nil { + t.Fatal(err) + } + expected, err := os.ReadFile(pathPrefix + ".json") + if err != nil { + t.Fatal(err) + } + if !bytes.Equal(actual, expected) { + t.Errorf("%s got different results", pathPrefix) + } } func TestRuntime_UnmarshalRef(t *testing.T) { + inputFilename := "ref" ty := tolkParser.Ty{ SumType: "CellOf", CellOf: &tolkParser.CellOf{ @@ -615,9 +996,27 @@ func TestRuntime_UnmarshalRef(t *testing.T) { if innerVal.Cmp(big.NewInt(1233212)) != 0 { t.Errorf("v.GetRefValue().GetBigInt() != 1233212, got %v", innerVal.String()) } + + pathPrefix := jsonFilesPath + inputFilename + actual, err := json.MarshalIndent(v, "", " ") + if err != nil { + t.Fatal(err) + } + err = os.WriteFile(pathPrefix+".output.json", actual, os.ModePerm) + if err != nil { + t.Fatal(err) + } + expected, err := os.ReadFile(pathPrefix + ".json") + if err != nil { + t.Fatal(err) + } + if !bytes.Equal(actual, expected) { + t.Errorf("%s got different results", pathPrefix) + } } func TestRuntime_UnmarshalEmptyTensor(t *testing.T) { + inputFilename := "empty_tensor" ty := tolkParser.Ty{ SumType: "Tensor", Tensor: &tolkParser.Tensor{}, @@ -640,9 +1039,27 @@ func TestRuntime_UnmarshalEmptyTensor(t *testing.T) { if len(val) != 0 { t.Errorf("v.GetTensor() != empty") } + + pathPrefix := jsonFilesPath + inputFilename + actual, err := json.MarshalIndent(v, "", " ") + if err != nil { + t.Fatal(err) + } + err = os.WriteFile(pathPrefix+".output.json", actual, os.ModePerm) + if err != nil { + t.Fatal(err) + } + expected, err := os.ReadFile(pathPrefix + ".json") + if err != nil { + t.Fatal(err) + } + if !bytes.Equal(actual, expected) { + t.Errorf("%s got different results", pathPrefix) + } } func TestRuntime_UnmarshalTensor(t *testing.T) { + inputFilename := "tensor" ty := tolkParser.Ty{ SumType: "Tensor", Tensor: &tolkParser.Tensor{ @@ -768,9 +1185,27 @@ func TestRuntime_UnmarshalTensor(t *testing.T) { if val4.Cmp(big.NewInt(-9_304_000_000)) != 0 { t.Errorf("val[4].GetVarInt() != -9304000000, got %v", val4.String()) } + + pathPrefix := jsonFilesPath + inputFilename + actual, err := json.MarshalIndent(v, "", " ") + if err != nil { + t.Fatal(err) + } + err = os.WriteFile(pathPrefix+".output.json", actual, os.ModePerm) + if err != nil { + t.Fatal(err) + } + expected, err := os.ReadFile(pathPrefix + ".json") + if err != nil { + t.Fatal(err) + } + if !bytes.Equal(actual, expected) { + t.Errorf("%s got different results", pathPrefix) + } } func TestRuntime_UnmarshalIntKeyMap(t *testing.T) { + inputFilename := "int_key_map" ty := tolkParser.Ty{ SumType: "Map", Map: &tolkParser.Map{ @@ -816,9 +1251,27 @@ func TestRuntime_UnmarshalIntKeyMap(t *testing.T) { if ok { t.Errorf("val[0] was found") } + + pathPrefix := jsonFilesPath + inputFilename + actual, err := json.MarshalIndent(v, "", " ") + if err != nil { + t.Fatal(err) + } + err = os.WriteFile(pathPrefix+".output.json", actual, os.ModePerm) + if err != nil { + t.Fatal(err) + } + expected, err := os.ReadFile(pathPrefix + ".json") + if err != nil { + t.Fatal(err) + } + if !bytes.Equal(actual, expected) { + t.Errorf("%s got different results", pathPrefix) + } } func TestRuntime_UnmarshalUIntKeyMap(t *testing.T) { + inputFilename := "uint_key_map" ty := tolkParser.Ty{ SumType: "Map", Map: &tolkParser.Map{ @@ -876,9 +1329,27 @@ func TestRuntime_UnmarshalUIntKeyMap(t *testing.T) { if ok { t.Errorf("val[0] was found") } + + pathPrefix := jsonFilesPath + inputFilename + actual, err := json.MarshalIndent(v, "", " ") + if err != nil { + t.Fatal(err) + } + err = os.WriteFile(pathPrefix+".output.json", actual, os.ModePerm) + if err != nil { + t.Fatal(err) + } + expected, err := os.ReadFile(pathPrefix + ".json") + if err != nil { + t.Fatal(err) + } + if !bytes.Equal(actual, expected) { + t.Errorf("%s got different results", pathPrefix) + } } func TestRuntime_UnmarshalBigIntKeyMap(t *testing.T) { + inputFilename := "big_int_key_map" ty := tolkParser.Ty{ SumType: "Map", Map: &tolkParser.Map{ @@ -928,9 +1399,27 @@ func TestRuntime_UnmarshalBigIntKeyMap(t *testing.T) { if ok { t.Errorf("val[34] was found") } + + pathPrefix := jsonFilesPath + inputFilename + actual, err := json.MarshalIndent(v, "", " ") + if err != nil { + t.Fatal(err) + } + err = os.WriteFile(pathPrefix+".output.json", actual, os.ModePerm) + if err != nil { + t.Fatal(err) + } + expected, err := os.ReadFile(pathPrefix + ".json") + if err != nil { + t.Fatal(err) + } + if !bytes.Equal(actual, expected) { + t.Errorf("%s got different results", pathPrefix) + } } func TestRuntime_UnmarshalBitsKeyMap(t *testing.T) { + inputFilename := "bits_int_key_map" ty := tolkParser.Ty{ SumType: "Map", Map: &tolkParser.Map{ @@ -1029,9 +1518,27 @@ func TestRuntime_UnmarshalBitsKeyMap(t *testing.T) { if ok { t.Errorf("val[{98, 99}] was found") } + + pathPrefix := jsonFilesPath + inputFilename + actual, err := json.MarshalIndent(v, "", " ") + if err != nil { + t.Fatal(err) + } + err = os.WriteFile(pathPrefix+".output.json", actual, os.ModePerm) + if err != nil { + t.Fatal(err) + } + expected, err := os.ReadFile(pathPrefix + ".json") + if err != nil { + t.Fatal(err) + } + if !bytes.Equal(actual, expected) { + t.Errorf("%s got different results", pathPrefix) + } } func TestRuntime_UnmarshalAddressKeyMap(t *testing.T) { + inputFilename := "address_key_map" ty := tolkParser.Ty{ SumType: "Map", Map: &tolkParser.Map{ @@ -1084,9 +1591,27 @@ func TestRuntime_UnmarshalAddressKeyMap(t *testing.T) { if ok { t.Errorf("val[\"UQCD39VS5jcptHL8vMjEXrzGaRcCVYto7HUn4bpAOg8xqEBI\"] was found") } + + pathPrefix := jsonFilesPath + inputFilename + actual, err := json.MarshalIndent(v, "", " ") + if err != nil { + t.Fatal(err) + } + err = os.WriteFile(pathPrefix+".output.json", actual, os.ModePerm) + if err != nil { + t.Fatal(err) + } + expected, err := os.ReadFile(pathPrefix + ".json") + if err != nil { + t.Fatal(err) + } + if !bytes.Equal(actual, expected) { + t.Errorf("%s got different results", pathPrefix) + } } func TestRuntime_UnmarshalUnionWithDecPrefix(t *testing.T) { + jsonInputFilename := "union_with_dec_prefix" ty := tolkParser.Ty{ SumType: "Union", Union: &tolkParser.Union{ @@ -1144,9 +1669,27 @@ func TestRuntime_UnmarshalUnionWithDecPrefix(t *testing.T) { if unionVal.Cmp(big.NewInt(124432123)) != 0 { t.Errorf("val.Val.GetBigInt() != 124432123, got %v", unionVal.String()) } + + pathPrefix := jsonFilesPath + jsonInputFilename + actual, err := json.MarshalIndent(v, "", " ") + if err != nil { + t.Fatal(err) + } + err = os.WriteFile(pathPrefix+".output.json", actual, os.ModePerm) + if err != nil { + t.Fatal(err) + } + expected, err := os.ReadFile(pathPrefix + ".json") + if err != nil { + t.Fatal(err) + } + if !bytes.Equal(actual, expected) { + t.Errorf("%s got different results", pathPrefix) + } } func TestRuntime_UnmarshalUnionWithBinPrefix(t *testing.T) { + jsonInputFilename := "union_with_bin_prefix" inputFilename := "testdata/bin_union.json" data, err := os.ReadFile(inputFilename) if err != nil { @@ -1246,9 +1789,27 @@ func TestRuntime_UnmarshalUnionWithBinPrefix(t *testing.T) { if mapCoins.Cmp(big.NewInt(43213412)) != 0 { t.Errorf("val.GetMap()[\"EQCxE6mUtQJKFnGfaROTKOt1lZbDiiX1kCixRv7Nw2Id_sDs\"].GetCoins() != 43213412, got %v", mapCoins.String()) } + + pathPrefix := jsonFilesPath + jsonInputFilename + actual, err := json.MarshalIndent(v, "", " ") + if err != nil { + t.Fatal(err) + } + err = os.WriteFile(pathPrefix+".output.json", actual, os.ModePerm) + if err != nil { + t.Fatal(err) + } + expected, err := os.ReadFile(pathPrefix + ".json") + if err != nil { + t.Fatal(err) + } + if !bytes.Equal(actual, expected) { + t.Errorf("%s got different results", pathPrefix) + } } func TestRuntime_UnmarshalUnionWithHexPrefix(t *testing.T) { + jsonInputFilename := "union_with_hex_prefix" inputFilename := "testdata/hex_union.json" data, err := os.ReadFile(inputFilename) if err != nil { @@ -1336,9 +1897,27 @@ func TestRuntime_UnmarshalUnionWithHexPrefix(t *testing.T) { if unionVal != 1 { t.Errorf("val.GetSmallUInt() != 1, got %v", unionVal) } + + pathPrefix := jsonFilesPath + jsonInputFilename + actual, err := json.MarshalIndent(v, "", " ") + if err != nil { + t.Fatal(err) + } + err = os.WriteFile(pathPrefix+".output.json", actual, os.ModePerm) + if err != nil { + t.Fatal(err) + } + expected, err := os.ReadFile(pathPrefix + ".json") + if err != nil { + t.Fatal(err) + } + if !bytes.Equal(actual, expected) { + t.Errorf("%s got different results", pathPrefix) + } } func TestRuntime_UnmarshalALotRefsFromAlias(t *testing.T) { + jsonInputFilename := "a_lot_refs_from_alias" inputFilename := "testdata/refs.json" data, err := os.ReadFile(inputFilename) if err != nil { @@ -1597,9 +2176,27 @@ func TestRuntime_UnmarshalALotRefsFromAlias(t *testing.T) { if oper3Enum.Name != "Something" { t.Errorf("currStruct[oper3].GetEnum().Name != Something, got %v", oper3Enum.Name) } + + pathPrefix := jsonFilesPath + jsonInputFilename + actual, err := json.MarshalIndent(v, "", " ") + if err != nil { + t.Fatal(err) + } + err = os.WriteFile(pathPrefix+".output.json", actual, os.ModePerm) + if err != nil { + t.Fatal(err) + } + expected, err := os.ReadFile(pathPrefix + ".json") + if err != nil { + t.Fatal(err) + } + if !bytes.Equal(actual, expected) { + t.Errorf("%s got different results", pathPrefix) + } } func TestRuntime_UnmarshalALotRefsFromStruct(t *testing.T) { + jsonInputFilename := "a_lot_refs_from_struct" inputFilename := "testdata/refs.json" data, err := os.ReadFile(inputFilename) if err != nil { @@ -1854,9 +2451,27 @@ func TestRuntime_UnmarshalALotRefsFromStruct(t *testing.T) { if oper3Enum.Name != "Something" { t.Errorf("currStruct[oper3].GetEnum().Name != Something, got %v", oper3Enum.Name) } + + pathPrefix := jsonFilesPath + jsonInputFilename + actual, err := json.MarshalIndent(v, "", " ") + if err != nil { + t.Fatal(err) + } + err = os.WriteFile(pathPrefix+".output.json", actual, os.ModePerm) + if err != nil { + t.Fatal(err) + } + expected, err := os.ReadFile(pathPrefix + ".json") + if err != nil { + t.Fatal(err) + } + if !bytes.Equal(actual, expected) { + t.Errorf("%s got different results", pathPrefix) + } } func TestRuntime_UnmarshalALotGenericsFromStruct(t *testing.T) { + jsonInputFilename := "a_lot_generics_from_struct" inputFilename := "testdata/generics.json" data, err := os.ReadFile(inputFilename) if err != nil { @@ -2100,9 +2715,27 @@ func TestRuntime_UnmarshalALotGenericsFromStruct(t *testing.T) { if myValVal != 16 { t.Fatalf("currStruct[myVal] != 16, got %v", myValVal) } + + pathPrefix := jsonFilesPath + jsonInputFilename + actual, err := json.MarshalIndent(v, "", " ") + if err != nil { + t.Fatal(err) + } + err = os.WriteFile(pathPrefix+".output.json", actual, os.ModePerm) + if err != nil { + t.Fatal(err) + } + expected, err := os.ReadFile(pathPrefix + ".json") + if err != nil { + t.Fatal(err) + } + if !bytes.Equal(actual, expected) { + t.Errorf("%s got different results", pathPrefix) + } } func TestRuntime_UnmarshalALotGenericsFromAlias(t *testing.T) { + jsonInputFilename := "a_lot_generics_from_alias" inputFilename := "testdata/generics.json" data, err := os.ReadFile(inputFilename) if err != nil { @@ -2350,9 +2983,27 @@ func TestRuntime_UnmarshalALotGenericsFromAlias(t *testing.T) { if myValVal != 16 { t.Fatalf("currStruct[myVal] != 16, got %v", myValVal) } + + pathPrefix := jsonFilesPath + jsonInputFilename + actual, err := json.MarshalIndent(v, "", " ") + if err != nil { + t.Fatal(err) + } + err = os.WriteFile(pathPrefix+".output.json", actual, os.ModePerm) + if err != nil { + t.Fatal(err) + } + expected, err := os.ReadFile(pathPrefix + ".json") + if err != nil { + t.Fatal(err) + } + if !bytes.Equal(actual, expected) { + t.Errorf("%s got different results", pathPrefix) + } } func TestRuntime_UnmarshalStructWithDefaultValues(t *testing.T) { + jsonInputFilename := "a_lot_generics_with_default_values" inputFilename := "testdata/default_values.json" data, err := os.ReadFile(inputFilename) if err != nil { @@ -2522,9 +3173,27 @@ func TestRuntime_UnmarshalStructWithDefaultValues(t *testing.T) { if num7.IsExists { t.Fatalf("currStruct[num7] exists") } + + pathPrefix := jsonFilesPath + jsonInputFilename + actual, err := json.MarshalIndent(v, "", " ") + if err != nil { + t.Fatal(err) + } + err = os.WriteFile(pathPrefix+".output.json", actual, os.ModePerm) + if err != nil { + t.Fatal(err) + } + expected, err := os.ReadFile(pathPrefix + ".json") + if err != nil { + t.Fatal(err) + } + if !bytes.Equal(actual, expected) { + t.Errorf("%s got different results", pathPrefix) + } } func TestRuntime_UnmarshalALotNumbers(t *testing.T) { + jsonInputFilename := "a_lot_numbers" inputFilename := "testdata/numbers.json" data, err := os.ReadFile(inputFilename) if err != nil { @@ -2642,9 +3311,27 @@ func TestRuntime_UnmarshalALotNumbers(t *testing.T) { if val9.Cmp(big.NewInt(2342)) != 0 { t.Fatalf("num9 != 2342, got %s", val9.String()) } + + pathPrefix := jsonFilesPath + jsonInputFilename + actual, err := json.MarshalIndent(v, "", " ") + if err != nil { + t.Fatal(err) + } + err = os.WriteFile(pathPrefix+".output.json", actual, os.ModePerm) + if err != nil { + t.Fatal(err) + } + expected, err := os.ReadFile(pathPrefix + ".json") + if err != nil { + t.Fatal(err) + } + if !bytes.Equal(actual, expected) { + t.Errorf("%s got different results", pathPrefix) + } } func TestRuntime_UnmarshalALotRandomFields(t *testing.T) { + jsonInputFilename := "a_lot_random_fields" inputFilename := "testdata/random_fields.json" data, err := os.ReadFile(inputFilename) if err != nil { @@ -2865,9 +3552,27 @@ func TestRuntime_UnmarshalALotRandomFields(t *testing.T) { if default2Val != 55 { t.Fatalf("default2 != 55, got %v", default2Val) } + + pathPrefix := jsonFilesPath + jsonInputFilename + actual, err := json.MarshalIndent(v, "", " ") + if err != nil { + t.Fatal(err) + } + err = os.WriteFile(pathPrefix+".output.json", actual, os.ModePerm) + if err != nil { + t.Fatal(err) + } + expected, err := os.ReadFile(pathPrefix + ".json") + if err != nil { + t.Fatal(err) + } + if !bytes.Equal(actual, expected) { + t.Errorf("%s got different results", pathPrefix) + } } func TestRuntime_MarshalSmallInt(t *testing.T) { + jsonInputFilename := "small_int" ty := tolkParser.Ty{ SumType: "IntN", IntN: &tolkParser.IntN{ @@ -2900,17 +3605,31 @@ func TestRuntime_MarshalSmallInt(t *testing.T) { if oldHs != newHs { t.Errorf("input and output cells are different") } + + pathPrefix := jsonFilesPath + jsonInputFilename + actualJson, err := os.ReadFile(pathPrefix + ".json") + if err != nil { + t.Fatal(err) + } + var jsonV Value + if err := json.Unmarshal(actualJson, &jsonV); err != nil { + t.Fatal(err) + } + if !v.Equal(jsonV) { + t.Errorf("%s got different results", pathPrefix) + } } -func TestRuntime_MarshalBigInt(t *testing.T) { +func TestRuntime_MarshalSmallUInt(t *testing.T) { + jsonInputFilename := "small_uint" ty := tolkParser.Ty{ - SumType: "IntN", - IntN: &tolkParser.IntN{ - N: 183, + SumType: "UintN", + UintN: &tolkParser.UintN{ + N: 53, }, } - currCell, err := boc.DeserializeBocHex("b5ee9c7241010101001900002dfffffffffffffffffffffffffffffffffff99bfeac6423a6f0b50c") + currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000900000d00000000001d34e435eafd") if err != nil { t.Fatal(err) } @@ -2935,17 +3654,31 @@ func TestRuntime_MarshalBigInt(t *testing.T) { if oldHs != newHs { t.Errorf("input and output cells are different") } + + pathPrefix := jsonFilesPath + jsonInputFilename + actualJson, err := os.ReadFile(pathPrefix + ".json") + if err != nil { + t.Fatal(err) + } + var jsonV Value + if err := json.Unmarshal(actualJson, &jsonV); err != nil { + t.Fatal(err) + } + if !v.Equal(jsonV) { + t.Errorf("%s got different results", pathPrefix) + } } -func TestRuntime_MarshalSmallUInt(t *testing.T) { +func TestRuntime_MarshalBigInt(t *testing.T) { + jsonInputFilename := "big_int" ty := tolkParser.Ty{ - SumType: "UintN", - UintN: &tolkParser.UintN{ - N: 53, + SumType: "IntN", + IntN: &tolkParser.IntN{ + N: 183, }, } - currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000900000d00000000001d34e435eafd") + currCell, err := boc.DeserializeBocHex("b5ee9c7241010101001900002dfffffffffffffffffffffffffffffffffff99bfeac6423a6f0b50c") if err != nil { t.Fatal(err) } @@ -2963,16 +3696,30 @@ func TestRuntime_MarshalSmallUInt(t *testing.T) { if err != nil { t.Fatal(err) } - newHs, err := newCell.HashString() - if err != nil { + newHs, err := newCell.HashString() + if err != nil { + t.Fatal(err) + } + if oldHs != newHs { + t.Errorf("input and output cells are different") + } + + pathPrefix := jsonFilesPath + jsonInputFilename + actualJson, err := os.ReadFile(pathPrefix + ".json") + if err != nil { + t.Fatal(err) + } + var jsonV Value + if err := json.Unmarshal(actualJson, &jsonV); err != nil { t.Fatal(err) } - if oldHs != newHs { - t.Errorf("input and output cells are different") + if !v.Equal(jsonV) { + t.Errorf("%s got different results", pathPrefix) } } func TestRuntime_MarshalBigUInt(t *testing.T) { + jsonInputFilename := "big_uint" ty := tolkParser.Ty{ SumType: "UintN", UintN: &tolkParser.UintN{ @@ -3005,9 +3752,23 @@ func TestRuntime_MarshalBigUInt(t *testing.T) { if oldHs != newHs { t.Errorf("input and output cells are different") } + + pathPrefix := jsonFilesPath + jsonInputFilename + actualJson, err := os.ReadFile(pathPrefix + ".json") + if err != nil { + t.Fatal(err) + } + var jsonV Value + if err := json.Unmarshal(actualJson, &jsonV); err != nil { + t.Fatal(err) + } + if !v.Equal(jsonV) { + t.Errorf("%s got different results", pathPrefix) + } } func TestRuntime_MarshalVarInt(t *testing.T) { + jsonInputFilename := "var_int" ty := tolkParser.Ty{ SumType: "VarIntN", VarIntN: &tolkParser.VarIntN{ @@ -3040,9 +3801,23 @@ func TestRuntime_MarshalVarInt(t *testing.T) { if oldHs != newHs { t.Errorf("input and output cells are different") } + + pathPrefix := jsonFilesPath + jsonInputFilename + actualJson, err := os.ReadFile(pathPrefix + ".json") + if err != nil { + t.Fatal(err) + } + var jsonV Value + if err := json.Unmarshal(actualJson, &jsonV); err != nil { + t.Fatal(err) + } + if !v.Equal(jsonV) { + t.Errorf("%s got different results", pathPrefix) + } } func TestRuntime_MarshalVarUInt(t *testing.T) { + jsonInputFilename := "var_uint" ty := tolkParser.Ty{ SumType: "VarUintN", VarUintN: &tolkParser.VarUintN{ @@ -3075,9 +3850,23 @@ func TestRuntime_MarshalVarUInt(t *testing.T) { if oldHs != newHs { t.Errorf("input and output cells are different") } + + pathPrefix := jsonFilesPath + jsonInputFilename + actualJson, err := os.ReadFile(pathPrefix + ".json") + if err != nil { + t.Fatal(err) + } + var jsonV Value + if err := json.Unmarshal(actualJson, &jsonV); err != nil { + t.Fatal(err) + } + if !v.Equal(jsonV) { + t.Errorf("%s got different results", pathPrefix) + } } func TestRuntime_MarshalBits(t *testing.T) { + jsonInputFilename := "bits" ty := tolkParser.Ty{ SumType: "BitsN", BitsN: &tolkParser.BitsN{ @@ -3110,9 +3899,23 @@ func TestRuntime_MarshalBits(t *testing.T) { if oldHs != newHs { t.Errorf("input and output cells are different") } + + pathPrefix := jsonFilesPath + jsonInputFilename + actualJson, err := os.ReadFile(pathPrefix + ".json") + if err != nil { + t.Fatal(err) + } + var jsonV Value + if err := json.Unmarshal(actualJson, &jsonV); err != nil { + t.Fatal(err) + } + if !v.Equal(jsonV) { + t.Errorf("%s got different results", pathPrefix) + } } func TestRuntime_MarshalCoins(t *testing.T) { + jsonInputFilename := "coins" ty := tolkParser.Ty{ SumType: "Coins", Coins: &tolkParser.Coins{}, @@ -3143,9 +3946,23 @@ func TestRuntime_MarshalCoins(t *testing.T) { if oldHs != newHs { t.Errorf("input and output cells are different") } + + pathPrefix := jsonFilesPath + jsonInputFilename + actualJson, err := os.ReadFile(pathPrefix + ".json") + if err != nil { + t.Fatal(err) + } + var jsonV Value + if err := json.Unmarshal(actualJson, &jsonV); err != nil { + t.Fatal(err) + } + if !v.Equal(jsonV) { + t.Errorf("%s got different results", pathPrefix) + } } func TestRuntime_MarshalBool(t *testing.T) { + jsonInputFilename := "bool" ty := tolkParser.Ty{ SumType: "Bool", Bool: &tolkParser.Bool{}, @@ -3176,9 +3993,23 @@ func TestRuntime_MarshalBool(t *testing.T) { if oldHs != newHs { t.Errorf("input and output cells are different") } + + pathPrefix := jsonFilesPath + jsonInputFilename + actualJson, err := os.ReadFile(pathPrefix + ".json") + if err != nil { + t.Fatal(err) + } + var jsonV Value + if err := json.Unmarshal(actualJson, &jsonV); err != nil { + t.Fatal(err) + } + if !v.Equal(jsonV) { + t.Errorf("%s got different results", pathPrefix) + } } func TestRuntime_MarshalCell(t *testing.T) { + jsonInputFilename := "cell" ty := tolkParser.Ty{ SumType: "Cell", Cell: &tolkParser.Cell{}, @@ -3209,9 +4040,23 @@ func TestRuntime_MarshalCell(t *testing.T) { if oldHs != newHs { t.Errorf("input and output cells are different") } + + pathPrefix := jsonFilesPath + jsonInputFilename + actualJson, err := os.ReadFile(pathPrefix + ".json") + if err != nil { + t.Fatal(err) + } + var jsonV Value + if err := json.Unmarshal(actualJson, &jsonV); err != nil { + t.Fatal(err) + } + if !v.Equal(jsonV) { + t.Errorf("%s got different results", pathPrefix) + } } func TestRuntime_MarshalRemaining(t *testing.T) { + jsonInputFilename := "remaining" ty := tolkParser.Ty{ SumType: "Remaining", Remaining: &tolkParser.Remaining{}, @@ -3242,9 +4087,23 @@ func TestRuntime_MarshalRemaining(t *testing.T) { if oldHs != newHs { t.Errorf("input and output cells are different") } + + pathPrefix := jsonFilesPath + jsonInputFilename + actualJson, err := os.ReadFile(pathPrefix + ".json") + if err != nil { + t.Fatal(err) + } + var jsonV Value + if err := json.Unmarshal(actualJson, &jsonV); err != nil { + t.Fatal(err) + } + if !v.Equal(jsonV) { + t.Errorf("%s got different results", pathPrefix) + } } func TestRuntime_MarshalAddress(t *testing.T) { + jsonInputFilename := "internal_address" ty := tolkParser.Ty{ SumType: "Address", Address: &tolkParser.Address{}, @@ -3275,9 +4134,23 @@ func TestRuntime_MarshalAddress(t *testing.T) { if oldHs != newHs { t.Errorf("input and output cells are different") } + + pathPrefix := jsonFilesPath + jsonInputFilename + actualJson, err := os.ReadFile(pathPrefix + ".json") + if err != nil { + t.Fatal(err) + } + var jsonV Value + if err := json.Unmarshal(actualJson, &jsonV); err != nil { + t.Fatal(err) + } + if !v.Equal(jsonV) { + t.Errorf("%s got different results", pathPrefix) + } } func TestRuntime_MarshalNotExitsOptionalAddress(t *testing.T) { + jsonInputFilename := "not_exists_optional_address" ty := tolkParser.Ty{ SumType: "AddressOpt", AddressOpt: &tolkParser.AddressOpt{}, @@ -3308,9 +4181,23 @@ func TestRuntime_MarshalNotExitsOptionalAddress(t *testing.T) { if oldHs != newHs { t.Errorf("input and output cells are different") } + + pathPrefix := jsonFilesPath + jsonInputFilename + actualJson, err := os.ReadFile(pathPrefix + ".json") + if err != nil { + t.Fatal(err) + } + var jsonV Value + if err := json.Unmarshal(actualJson, &jsonV); err != nil { + t.Fatal(err) + } + if !v.Equal(jsonV) { + t.Errorf("%s got different results", pathPrefix) + } } func TestRuntime_MarshalExistsOptionalAddress(t *testing.T) { + jsonInputFilename := "exists_optional_address" ty := tolkParser.Ty{ SumType: "AddressOpt", AddressOpt: &tolkParser.AddressOpt{}, @@ -3341,9 +4228,23 @@ func TestRuntime_MarshalExistsOptionalAddress(t *testing.T) { if oldHs != newHs { t.Errorf("input and output cells are different") } + + pathPrefix := jsonFilesPath + jsonInputFilename + actualJson, err := os.ReadFile(pathPrefix + ".json") + if err != nil { + t.Fatal(err) + } + var jsonV Value + if err := json.Unmarshal(actualJson, &jsonV); err != nil { + t.Fatal(err) + } + if !v.Equal(jsonV) { + t.Errorf("%s got different results", pathPrefix) + } } func TestRuntime_MarshalExternalAddress(t *testing.T) { + jsonInputFilename := "external_address" ty := tolkParser.Ty{ SumType: "AddressExt", AddressExt: &tolkParser.AddressExt{}, @@ -3374,9 +4275,23 @@ func TestRuntime_MarshalExternalAddress(t *testing.T) { if oldHs != newHs { t.Errorf("input and output cells are different") } + + pathPrefix := jsonFilesPath + jsonInputFilename + actualJson, err := os.ReadFile(pathPrefix + ".json") + if err != nil { + t.Fatal(err) + } + var jsonV Value + if err := json.Unmarshal(actualJson, &jsonV); err != nil { + t.Fatal(err) + } + if !v.Equal(jsonV) { + t.Errorf("%s got different results", pathPrefix) + } } func TestRuntime_MarshalAnyNoneAddress(t *testing.T) { + jsonInputFilename := "any_none_address" ty := tolkParser.Ty{ SumType: "AddressAny", AddressAny: &tolkParser.AddressAny{}, @@ -3407,9 +4322,23 @@ func TestRuntime_MarshalAnyNoneAddress(t *testing.T) { if oldHs != newHs { t.Errorf("input and output cells are different") } + + pathPrefix := jsonFilesPath + jsonInputFilename + actualJson, err := os.ReadFile(pathPrefix + ".json") + if err != nil { + t.Fatal(err) + } + var jsonV Value + if err := json.Unmarshal(actualJson, &jsonV); err != nil { + t.Fatal(err) + } + if !v.Equal(jsonV) { + t.Errorf("%s got different results", pathPrefix) + } } func TestRuntime_MarshalAnyInternalAddress(t *testing.T) { + jsonInputFilename := "any_internal_address" ty := tolkParser.Ty{ SumType: "AddressAny", AddressAny: &tolkParser.AddressAny{}, @@ -3440,9 +4369,23 @@ func TestRuntime_MarshalAnyInternalAddress(t *testing.T) { if oldHs != newHs { t.Errorf("input and output cells are different") } + + pathPrefix := jsonFilesPath + jsonInputFilename + actualJson, err := os.ReadFile(pathPrefix + ".json") + if err != nil { + t.Fatal(err) + } + var jsonV Value + if err := json.Unmarshal(actualJson, &jsonV); err != nil { + t.Fatal(err) + } + if !v.Equal(jsonV) { + t.Errorf("%s got different results", pathPrefix) + } } func TestRuntime_MarshalAnyExternalAddress(t *testing.T) { + jsonInputFilename := "any_external_address" ty := tolkParser.Ty{ SumType: "AddressAny", AddressAny: &tolkParser.AddressAny{}, @@ -3473,9 +4416,23 @@ func TestRuntime_MarshalAnyExternalAddress(t *testing.T) { if oldHs != newHs { t.Errorf("input and output cells are different") } + + pathPrefix := jsonFilesPath + jsonInputFilename + actualJson, err := os.ReadFile(pathPrefix + ".json") + if err != nil { + t.Fatal(err) + } + var jsonV Value + if err := json.Unmarshal(actualJson, &jsonV); err != nil { + t.Fatal(err) + } + if !v.Equal(jsonV) { + t.Errorf("%s got different results", pathPrefix) + } } func TestRuntime_MarshalAnyVarAddress(t *testing.T) { + jsonInputFilename := "any_var_address" ty := tolkParser.Ty{ SumType: "AddressAny", AddressAny: &tolkParser.AddressAny{}, @@ -3506,9 +4463,23 @@ func TestRuntime_MarshalAnyVarAddress(t *testing.T) { if oldHs != newHs { t.Errorf("input and output cells are different") } + + pathPrefix := jsonFilesPath + jsonInputFilename + actualJson, err := os.ReadFile(pathPrefix + ".json") + if err != nil { + t.Fatal(err) + } + var jsonV Value + if err := json.Unmarshal(actualJson, &jsonV); err != nil { + t.Fatal(err) + } + if !v.Equal(jsonV) { + t.Errorf("%s got different results", pathPrefix) + } } func TestRuntime_MarshalNotExistsNullable(t *testing.T) { + jsonInputFilename := "not_exists_nullable" ty := tolkParser.Ty{ SumType: "Nullable", Nullable: &tolkParser.Nullable{ @@ -3544,9 +4515,23 @@ func TestRuntime_MarshalNotExistsNullable(t *testing.T) { if oldHs != newHs { t.Errorf("input and output cells are different") } + + pathPrefix := jsonFilesPath + jsonInputFilename + actualJson, err := os.ReadFile(pathPrefix + ".json") + if err != nil { + t.Fatal(err) + } + var jsonV Value + if err := json.Unmarshal(actualJson, &jsonV); err != nil { + t.Fatal(err) + } + if !v.Equal(jsonV) { + t.Errorf("%s got different results", pathPrefix) + } } func TestRuntime_MarshalExistsNullable(t *testing.T) { + jsonInputFilename := "exists_nullable" ty := tolkParser.Ty{ SumType: "Nullable", Nullable: &tolkParser.Nullable{ @@ -3582,9 +4567,23 @@ func TestRuntime_MarshalExistsNullable(t *testing.T) { if oldHs != newHs { t.Errorf("input and output cells are different") } + + pathPrefix := jsonFilesPath + jsonInputFilename + actualJson, err := os.ReadFile(pathPrefix + ".json") + if err != nil { + t.Fatal(err) + } + var jsonV Value + if err := json.Unmarshal(actualJson, &jsonV); err != nil { + t.Fatal(err) + } + if !v.Equal(jsonV) { + t.Errorf("%s got different results", pathPrefix) + } } func TestRuntime_MarshalRef(t *testing.T) { + jsonInputFilename := "ref" ty := tolkParser.Ty{ SumType: "CellOf", CellOf: &tolkParser.CellOf{ @@ -3622,9 +4621,23 @@ func TestRuntime_MarshalRef(t *testing.T) { if oldHs != newHs { t.Errorf("input and output cells are different") } + + pathPrefix := jsonFilesPath + jsonInputFilename + actualJson, err := os.ReadFile(pathPrefix + ".json") + if err != nil { + t.Fatal(err) + } + var jsonV Value + if err := json.Unmarshal(actualJson, &jsonV); err != nil { + t.Fatal(err) + } + if !v.Equal(jsonV) { + t.Errorf("%s got different results", pathPrefix) + } } func TestRuntime_MarshalEmptyTensor(t *testing.T) { + jsonInputFilename := "empty_tensor" ty := tolkParser.Ty{ SumType: "Tensor", Tensor: &tolkParser.Tensor{}, @@ -3655,9 +4668,23 @@ func TestRuntime_MarshalEmptyTensor(t *testing.T) { if oldHs != newHs { t.Errorf("input and output cells are different") } + + pathPrefix := jsonFilesPath + jsonInputFilename + actualJson, err := os.ReadFile(pathPrefix + ".json") + if err != nil { + t.Fatal(err) + } + var jsonV Value + if err := json.Unmarshal(actualJson, &jsonV); err != nil { + t.Fatal(err) + } + if !v.Equal(jsonV) { + t.Errorf("%s got different results", pathPrefix) + } } func TestRuntime_MarshalTensor(t *testing.T) { + jsonInputFilename := "tensor" ty := tolkParser.Ty{ SumType: "Tensor", Tensor: &tolkParser.Tensor{ @@ -3735,9 +4762,23 @@ func TestRuntime_MarshalTensor(t *testing.T) { if oldHs != newHs { t.Errorf("input and output cells are different") } + + pathPrefix := jsonFilesPath + jsonInputFilename + actualJson, err := os.ReadFile(pathPrefix + ".json") + if err != nil { + t.Fatal(err) + } + var jsonV Value + if err := json.Unmarshal(actualJson, &jsonV); err != nil { + t.Fatal(err) + } + if !v.Equal(jsonV) { + t.Errorf("%s got different results", pathPrefix) + } } func TestRuntime_MarshalIntKeyMap(t *testing.T) { + jsonInputFilename := "int_key_map" ty := tolkParser.Ty{ SumType: "Map", Map: &tolkParser.Map{ @@ -3779,9 +4820,23 @@ func TestRuntime_MarshalIntKeyMap(t *testing.T) { if oldHs != newHs { t.Errorf("input and output cells are different") } + + pathPrefix := jsonFilesPath + jsonInputFilename + actualJson, err := os.ReadFile(pathPrefix + ".json") + if err != nil { + t.Fatal(err) + } + var jsonV Value + if err := json.Unmarshal(actualJson, &jsonV); err != nil { + t.Fatal(err) + } + if !v.Equal(jsonV) { + t.Errorf("%s got different results", pathPrefix) + } } func TestRuntime_MarshalUIntKeyMap(t *testing.T) { + jsonInputFilename := "uint_key_map" ty := tolkParser.Ty{ SumType: "Map", Map: &tolkParser.Map{ @@ -3823,9 +4878,23 @@ func TestRuntime_MarshalUIntKeyMap(t *testing.T) { if oldHs != newHs { t.Errorf("input and output cells are different") } + + pathPrefix := jsonFilesPath + jsonInputFilename + actualJson, err := os.ReadFile(pathPrefix + ".json") + if err != nil { + t.Fatal(err) + } + var jsonV Value + if err := json.Unmarshal(actualJson, &jsonV); err != nil { + t.Fatal(err) + } + if !v.Equal(jsonV) { + t.Errorf("%s got different results", pathPrefix) + } } func TestRuntime_MarshalBigIntKeyMap(t *testing.T) { + jsonInputFilename := "big_int_key_map" ty := tolkParser.Ty{ SumType: "Map", Map: &tolkParser.Map{ @@ -3867,9 +4936,23 @@ func TestRuntime_MarshalBigIntKeyMap(t *testing.T) { if oldHs != newHs { t.Errorf("input and output cells are different") } + + pathPrefix := jsonFilesPath + jsonInputFilename + actualJson, err := os.ReadFile(pathPrefix + ".json") + if err != nil { + t.Fatal(err) + } + var jsonV Value + if err := json.Unmarshal(actualJson, &jsonV); err != nil { + t.Fatal(err) + } + if !v.Equal(jsonV) { + t.Errorf("%s got different results", pathPrefix) + } } func TestRuntime_MarshalBitsKeyMap(t *testing.T) { + jsonInputFilename := "bits_int_key_map" ty := tolkParser.Ty{ SumType: "Map", Map: &tolkParser.Map{ @@ -3933,9 +5016,23 @@ func TestRuntime_MarshalBitsKeyMap(t *testing.T) { if oldHs != newHs { t.Errorf("input and output cells are different") } + + pathPrefix := jsonFilesPath + jsonInputFilename + actualJson, err := os.ReadFile(pathPrefix + ".json") + if err != nil { + t.Fatal(err) + } + var jsonV Value + if err := json.Unmarshal(actualJson, &jsonV); err != nil { + t.Fatal(err) + } + if !v.Equal(jsonV) { + t.Errorf("%s got different results", pathPrefix) + } } func TestRuntime_MarshalAddressKeyMap(t *testing.T) { + jsonInputFilename := "address_key_map" ty := tolkParser.Ty{ SumType: "Map", Map: &tolkParser.Map{ @@ -3975,9 +5072,23 @@ func TestRuntime_MarshalAddressKeyMap(t *testing.T) { if oldHs != newHs { t.Errorf("input and output cells are different") } + + pathPrefix := jsonFilesPath + jsonInputFilename + actualJson, err := os.ReadFile(pathPrefix + ".json") + if err != nil { + t.Fatal(err) + } + var jsonV Value + if err := json.Unmarshal(actualJson, &jsonV); err != nil { + t.Fatal(err) + } + if !v.Equal(jsonV) { + t.Errorf("%s got different results", pathPrefix) + } } func TestRuntime_MarshalUnionWithDecPrefix(t *testing.T) { + jsonInputFilename := "union_with_dec_prefix" ty := tolkParser.Ty{ SumType: "Union", Union: &tolkParser.Union{ @@ -4033,9 +5144,23 @@ func TestRuntime_MarshalUnionWithDecPrefix(t *testing.T) { if oldHs != newHs { t.Errorf("input and output cells are different") } + + pathPrefix := jsonFilesPath + jsonInputFilename + actualJson, err := os.ReadFile(pathPrefix + ".json") + if err != nil { + t.Fatal(err) + } + var jsonV Value + if err := json.Unmarshal(actualJson, &jsonV); err != nil { + t.Fatal(err) + } + if !v.Equal(jsonV) { + t.Errorf("%s got different results", pathPrefix) + } } func TestRuntime_MarshalUnionWithBinPrefix(t *testing.T) { + jsonInputFilename := "union_with_bin_prefix" inputFilename := "testdata/bin_union.json" data, err := os.ReadFile(inputFilename) if err != nil { @@ -4115,9 +5240,23 @@ func TestRuntime_MarshalUnionWithBinPrefix(t *testing.T) { if oldHs != newHs { t.Errorf("input and output cells are different") } + + pathPrefix := jsonFilesPath + jsonInputFilename + actualJson, err := os.ReadFile(pathPrefix + ".json") + if err != nil { + t.Fatal(err) + } + var jsonV Value + if err := json.Unmarshal(actualJson, &jsonV); err != nil { + t.Fatal(err) + } + if !v.Equal(jsonV) { + t.Errorf("%s got different results", pathPrefix) + } } func TestRuntime_MarshalUnionWithHexPrefix(t *testing.T) { + jsonInputFilename := "union_with_hex_prefix" inputFilename := "testdata/hex_union.json" data, err := os.ReadFile(inputFilename) if err != nil { @@ -4197,9 +5336,23 @@ func TestRuntime_MarshalUnionWithHexPrefix(t *testing.T) { if oldHs != newHs { t.Errorf("input and output cells are different") } + + pathPrefix := jsonFilesPath + jsonInputFilename + actualJson, err := os.ReadFile(pathPrefix + ".json") + if err != nil { + t.Fatal(err) + } + var jsonV Value + if err := json.Unmarshal(actualJson, &jsonV); err != nil { + t.Fatal(err) + } + if !v.Equal(jsonV) { + t.Errorf("%s got different results", pathPrefix) + } } func TestRuntime_MarshalALotRefsFromAlias(t *testing.T) { + jsonInputFilename := "a_lot_refs_from_alias" inputFilename := "testdata/refs.json" data, err := os.ReadFile(inputFilename) if err != nil { @@ -4254,9 +5407,23 @@ func TestRuntime_MarshalALotRefsFromAlias(t *testing.T) { if oldHs != newHs { t.Errorf("input and output cells are different") } + + pathPrefix := jsonFilesPath + jsonInputFilename + actualJson, err := os.ReadFile(pathPrefix + ".json") + if err != nil { + t.Fatal(err) + } + var jsonV Value + if err := json.Unmarshal(actualJson, &jsonV); err != nil { + t.Fatal(err) + } + if !v.Equal(jsonV) { + t.Errorf("%s got different results", pathPrefix) + } } func TestRuntime_MarshalALotRefsFromStruct(t *testing.T) { + jsonInputFilename := "a_lot_refs_from_struct" inputFilename := "testdata/refs.json" data, err := os.ReadFile(inputFilename) if err != nil { @@ -4305,9 +5472,23 @@ func TestRuntime_MarshalALotRefsFromStruct(t *testing.T) { if oldHs != newHs { t.Errorf("input and output cells are different") } + + pathPrefix := jsonFilesPath + jsonInputFilename + actualJson, err := os.ReadFile(pathPrefix + ".json") + if err != nil { + t.Fatal(err) + } + var jsonV Value + if err := json.Unmarshal(actualJson, &jsonV); err != nil { + t.Fatal(err) + } + if !v.Equal(jsonV) { + t.Errorf("%s got different results", pathPrefix) + } } func TestRuntime_MarshalALotGenericsFromStruct(t *testing.T) { + jsonInputFilename := "a_lot_generics_from_struct" inputFilename := "testdata/generics.json" data, err := os.ReadFile(inputFilename) if err != nil { @@ -4364,9 +5545,23 @@ func TestRuntime_MarshalALotGenericsFromStruct(t *testing.T) { if oldHs != newHs { t.Errorf("input and output cells are different") } + + pathPrefix := jsonFilesPath + jsonInputFilename + actualJson, err := os.ReadFile(pathPrefix + ".json") + if err != nil { + t.Fatal(err) + } + var jsonV Value + if err := json.Unmarshal(actualJson, &jsonV); err != nil { + t.Fatal(err) + } + if !v.Equal(jsonV) { + t.Errorf("%s got different results", pathPrefix) + } } func TestRuntime_MarshalALotGenericsFromAlias(t *testing.T) { + jsonInputFilename := "a_lot_generics_from_alias" inputFilename := "testdata/generics.json" data, err := os.ReadFile(inputFilename) if err != nil { @@ -4423,9 +5618,23 @@ func TestRuntime_MarshalALotGenericsFromAlias(t *testing.T) { if oldHs != newHs { t.Errorf("input and output cells are different") } + + pathPrefix := jsonFilesPath + jsonInputFilename + actualJson, err := os.ReadFile(pathPrefix + ".json") + if err != nil { + t.Fatal(err) + } + var jsonV Value + if err := json.Unmarshal(actualJson, &jsonV); err != nil { + t.Fatal(err) + } + if !v.Equal(jsonV) { + t.Errorf("%s got different results", pathPrefix) + } } func TestRuntime_MarshalStructWithDefaultValues(t *testing.T) { + jsonInputFilename := "a_lot_generics_with_default_values" inputFilename := "testdata/default_values.json" data, err := os.ReadFile(inputFilename) if err != nil { @@ -4474,9 +5683,23 @@ func TestRuntime_MarshalStructWithDefaultValues(t *testing.T) { if oldHs != newHs { t.Errorf("input and output cells are different") } + + pathPrefix := jsonFilesPath + jsonInputFilename + actualJson, err := os.ReadFile(pathPrefix + ".json") + if err != nil { + t.Fatal(err) + } + var jsonV Value + if err := json.Unmarshal(actualJson, &jsonV); err != nil { + t.Fatal(err) + } + if !v.Equal(jsonV) { + t.Errorf("%s got different results", pathPrefix) + } } func TestRuntime_MarshalALotNumbers(t *testing.T) { + jsonInputFilename := "a_lot_numbers" inputFilename := "testdata/numbers.json" data, err := os.ReadFile(inputFilename) if err != nil { @@ -4525,9 +5748,23 @@ func TestRuntime_MarshalALotNumbers(t *testing.T) { if oldHs != newHs { t.Errorf("input and output cells are different") } + + pathPrefix := jsonFilesPath + jsonInputFilename + actualJson, err := os.ReadFile(pathPrefix + ".json") + if err != nil { + t.Fatal(err) + } + var jsonV Value + if err := json.Unmarshal(actualJson, &jsonV); err != nil { + t.Fatal(err) + } + if !v.Equal(jsonV) { + t.Errorf("%s got different results", pathPrefix) + } } func TestRuntime_MarshalALotRandomFields(t *testing.T) { + jsonInputFilename := "a_lot_random_fields" inputFilename := "testdata/random_fields.json" data, err := os.ReadFile(inputFilename) if err != nil { @@ -4576,4 +5813,17 @@ func TestRuntime_MarshalALotRandomFields(t *testing.T) { if oldHs != newHs { t.Errorf("input and output cells are different") } + + pathPrefix := jsonFilesPath + jsonInputFilename + actualJson, err := os.ReadFile(pathPrefix + ".json") + if err != nil { + t.Fatal(err) + } + var jsonV Value + if err := json.Unmarshal(actualJson, &jsonV); err != nil { + t.Fatal(err) + } + if !v.Equal(jsonV) { + t.Errorf("%s got different results", pathPrefix) + } } diff --git a/tolk/testdata/json/a_lot_generics_from_alias.json b/tolk/testdata/json/a_lot_generics_from_alias.json new file mode 100755 index 00000000..441a8831 --- /dev/null +++ b/tolk/testdata/json/a_lot_generics_from_alias.json @@ -0,0 +1,158 @@ +{ + "sumType": "alias", + "alias": { + "sumType": "struct", + "struct": { + "fields": { + "payload": { + "sumType": "struct", + "struct": { + "fields": { + "value": { + "sumType": "union", + "union": { + "prefix": { + "len": 1, + "prefix": 1 + }, + "value": { + "sumType": "refValue", + "refValue": { + "sumType": "generic", + "generic": { + "sumType": "smallUint", + "smallUint": 123 + } + } + } + } + } + } + } + }, + "either": { + "sumType": "alias", + "alias": { + "sumType": "union", + "union": { + "prefix": { + "len": 1, + "prefix": 1 + }, + "value": { + "sumType": "struct", + "struct": { + "fields": { + "value": { + "sumType": "generic", + "generic": { + "sumType": "coins", + "coins": "100000000" + } + } + } + } + } + } + } + }, + "anotherEither": { + "sumType": "alias", + "alias": { + "sumType": "alias", + "alias": { + "sumType": "union", + "union": { + "prefix": { + "len": 1, + "prefix": 1 + }, + "value": { + "sumType": "struct", + "struct": { + "fields": { + "value": { + "sumType": "generic", + "generic": { + "sumType": "tensor", + "tensor": [ + { + "sumType": "bool", + "bool": true + }, + { + "sumType": "coins", + "coins": "1000000000" + } + ] + } + } + } + } + } + } + } + } + }, + "doubler": { + "sumType": "refValue", + "refValue": { + "sumType": "alias", + "alias": { + "sumType": "tensor", + "tensor": [ + { + "sumType": "generic", + "generic": { + "sumType": "tensor", + "tensor": [ + { + "sumType": "coins", + "coins": "1000000000" + }, + { + "sumType": "optionalAddress", + "optionalAddress": { + "sumType": "noneAddress" + } + } + ] + } + }, + { + "sumType": "generic", + "generic": { + "sumType": "tensor", + "tensor": [ + { + "sumType": "coins", + "coins": "100000000" + }, + { + "sumType": "optionalAddress", + "optionalAddress": { + "sumType": "internalAddress", + "internalAddress": "0:b113a994b5024a16719f69139328eb759596c38a25f59028b146fecdc3621dfe" + } + } + ] + } + } + ] + } + } + }, + "myVal": { + "sumType": "alias", + "alias": { + "sumType": "generic", + "generic": { + "sumType": "smallUint", + "smallUint": 16 + } + } + } + } + } + } +} \ No newline at end of file diff --git a/tolk/testdata/json/a_lot_generics_from_struct.json b/tolk/testdata/json/a_lot_generics_from_struct.json new file mode 100755 index 00000000..5f371da4 --- /dev/null +++ b/tolk/testdata/json/a_lot_generics_from_struct.json @@ -0,0 +1,155 @@ +{ + "sumType": "struct", + "struct": { + "fields": { + "payload": { + "sumType": "struct", + "struct": { + "fields": { + "value": { + "sumType": "union", + "union": { + "prefix": { + "len": 1, + "prefix": 1 + }, + "value": { + "sumType": "refValue", + "refValue": { + "sumType": "generic", + "generic": { + "sumType": "smallUint", + "smallUint": 123 + } + } + } + } + } + } + } + }, + "either": { + "sumType": "alias", + "alias": { + "sumType": "union", + "union": { + "prefix": { + "len": 1, + "prefix": 1 + }, + "value": { + "sumType": "struct", + "struct": { + "fields": { + "value": { + "sumType": "generic", + "generic": { + "sumType": "coins", + "coins": "100000000" + } + } + } + } + } + } + } + }, + "anotherEither": { + "sumType": "alias", + "alias": { + "sumType": "alias", + "alias": { + "sumType": "union", + "union": { + "prefix": { + "len": 1, + "prefix": 1 + }, + "value": { + "sumType": "struct", + "struct": { + "fields": { + "value": { + "sumType": "generic", + "generic": { + "sumType": "tensor", + "tensor": [ + { + "sumType": "bool", + "bool": true + }, + { + "sumType": "coins", + "coins": "1000000000" + } + ] + } + } + } + } + } + } + } + } + }, + "doubler": { + "sumType": "refValue", + "refValue": { + "sumType": "alias", + "alias": { + "sumType": "tensor", + "tensor": [ + { + "sumType": "generic", + "generic": { + "sumType": "tensor", + "tensor": [ + { + "sumType": "coins", + "coins": "1000000000" + }, + { + "sumType": "optionalAddress", + "optionalAddress": { + "sumType": "noneAddress" + } + } + ] + } + }, + { + "sumType": "generic", + "generic": { + "sumType": "tensor", + "tensor": [ + { + "sumType": "coins", + "coins": "100000000" + }, + { + "sumType": "optionalAddress", + "optionalAddress": { + "sumType": "internalAddress", + "internalAddress": "0:b113a994b5024a16719f69139328eb759596c38a25f59028b146fecdc3621dfe" + } + } + ] + } + } + ] + } + } + }, + "myVal": { + "sumType": "alias", + "alias": { + "sumType": "generic", + "generic": { + "sumType": "smallUint", + "smallUint": 16 + } + } + } + } + } +} \ No newline at end of file diff --git a/tolk/testdata/json/a_lot_generics_with_default_values.json b/tolk/testdata/json/a_lot_generics_with_default_values.json new file mode 100755 index 00000000..c10149ff --- /dev/null +++ b/tolk/testdata/json/a_lot_generics_with_default_values.json @@ -0,0 +1,78 @@ +{ + "sumType": "struct", + "struct": { + "fields": { + "num1": { + "sumType": "optionalValue", + "optionalValue": { + "isExists": true, + "value": { + "sumType": "smallUint", + "smallUint": 4 + } + } + }, + "num2": { + "sumType": "optionalValue", + "optionalValue": { + "isExists": true, + "value": { + "sumType": "alias", + "alias": { + "sumType": "smallInt", + "smallInt": 5 + } + } + } + }, + "addr4": { + "sumType": "optionalAddress", + "optionalAddress": { + "sumType": "noneAddress" + } + }, + "addr5": { + "sumType": "optionalAddress", + "optionalAddress": { + "sumType": "internalAddress", + "internalAddress": "0:b113a994b5024a16719f69139328eb759596c38a25f59028b146fecdc3621dfe" + } + }, + "tensor6": { + "sumType": "optionalValue", + "optionalValue": { + "isExists": true, + "value": { + "sumType": "tensor", + "tensor": [ + { + "sumType": "smallInt", + "smallInt": 342 + }, + { + "sumType": "bool", + "bool": true + } + ] + } + } + }, + "num7": { + "sumType": "optionalValue", + "optionalValue": { + "isExists": false + } + }, + "slice3": { + "sumType": "optionalValue", + "optionalValue": { + "isExists": true, + "value": { + "sumType": "remaining", + "remaining": "b5ee9c72010101010005000006616263" + } + } + } + } + } +} \ No newline at end of file diff --git a/tolk/testdata/json/a_lot_numbers.json b/tolk/testdata/json/a_lot_numbers.json new file mode 100755 index 00000000..c3e8a257 --- /dev/null +++ b/tolk/testdata/json/a_lot_numbers.json @@ -0,0 +1,35 @@ +{ + "sumType": "struct", + "struct": { + "fields": { + "num1": { + "sumType": "smallUint", + "smallUint": 0 + }, + "num3": { + "sumType": "bigUint", + "bigUint": "241" + }, + "num4": { + "sumType": "varUint", + "varUint": "3421" + }, + "num5": { + "sumType": "bool", + "bool": true + }, + "num7": { + "sumType": "bits", + "bits": "3132" + }, + "num8": { + "sumType": "smallInt", + "smallInt": 0 + }, + "num9": { + "sumType": "varInt", + "varInt": "2342" + } + } + } +} \ No newline at end of file diff --git a/tolk/testdata/json/a_lot_random_fields.json b/tolk/testdata/json/a_lot_random_fields.json new file mode 100755 index 00000000..7246626a --- /dev/null +++ b/tolk/testdata/json/a_lot_random_fields.json @@ -0,0 +1,93 @@ +{ + "sumType": "struct", + "struct": { + "prefix": { + "len": 12, + "prefix": 1940 + }, + "fields": { + "dest_int": { + "sumType": "internalAddress", + "internalAddress": "0:83dfd552e63729b472fcbcc8c45ebcc6691702558b68ec7527e1ba403a0f31a8" + }, + "amount": { + "sumType": "coins", + "coins": "500000123400000" + }, + "dest_ext": { + "sumType": "anyAddress", + "anyAddress": { + "sumType": "noneAddress" + } + }, + "intVector": { + "sumType": "tensor", + "tensor": [ + { + "sumType": "smallInt", + "smallInt": 342 + }, + { + "sumType": "optionalValue", + "optionalValue": { + "isExists": true, + "value": { + "sumType": "coins", + "coins": "1000000000" + } + } + }, + { + "sumType": "smallUint", + "smallUint": 23443 + } + ] + }, + "needs_more": { + "sumType": "refValue", + "refValue": { + "sumType": "bool", + "bool": true + } + }, + "some_payload": { + "sumType": "cell", + "cell": "b5ee9c7201010101002b000051000000000005120041efeaa9731b94da397e5e64622f5e63348b812ac5b4763a93f0dd201d0798d440" + }, + "my_int": { + "sumType": "alias", + "alias": { + "sumType": "smallInt", + "smallInt": 432 + } + }, + "some_union": { + "sumType": "union", + "union": { + "prefix": { + "len": 2, + "prefix": 1 + }, + "value": { + "sumType": "smallInt", + "smallInt": 30000 + } + } + }, + "default_1": { + "sumType": "smallInt", + "smallInt": 1 + }, + "default_2": { + "sumType": "optionalValue", + "optionalValue": { + "isExists": true, + "value": { + "sumType": "smallInt", + "smallInt": 55 + } + } + } + } + } +} \ No newline at end of file diff --git a/tolk/testdata/json/a_lot_refs_from_alias.json b/tolk/testdata/json/a_lot_refs_from_alias.json new file mode 100755 index 00000000..b8d1b5bf --- /dev/null +++ b/tolk/testdata/json/a_lot_refs_from_alias.json @@ -0,0 +1,131 @@ +{ + "sumType": "alias", + "alias": { + "sumType": "struct", + "struct": { + "prefix": { + "len": 32, + "prefix": 3735928559 + }, + "fields": { + "user1": { + "sumType": "alias", + "alias": { + "sumType": "struct", + "struct": { + "fields": { + "addr": { + "sumType": "internalAddress", + "internalAddress": "0:83dfd552e63729b472fcbcc8c45ebcc6691702558b68ec7527e1ba403a0f31a8" + }, + "balance": { + "sumType": "coins", + "coins": "1000000000" + } + } + } + } + }, + "user2": { + "sumType": "optionalValue", + "optionalValue": { + "isExists": true, + "value": { + "sumType": "refValue", + "refValue": { + "sumType": "alias", + "alias": { + "sumType": "struct", + "struct": { + "fields": { + "addr": { + "sumType": "internalAddress", + "internalAddress": "0:086fa2a675f74347b08dd4606a549b8fdb98829cb282bc1949d3b12fbaed9dcc" + }, + "balance": { + "sumType": "coins", + "coins": "100000000" + } + } + } + } + } + } + } + }, + "user3": { + "sumType": "cell", + "cell": "b5ee9c720101010100240000438006e05909e22b2e5e6087533314ee56505f85212914bd5547941a2a658ac62fe101" + }, + "user4": { + "sumType": "optionalValue", + "optionalValue": { + "isExists": false + } + }, + "user5": { + "sumType": "refValue", + "refValue": { + "sumType": "struct", + "struct": { + "fields": { + "addr": { + "sumType": "internalAddress", + "internalAddress": "0:b113a994b5024a16719f69139328eb759596c38a25f59028b146fecdc3621dfe" + }, + "balance": { + "sumType": "coins", + "coins": "10000000000000" + } + } + } + } + }, + "role": { + "sumType": "enum", + "enum": { + "actualValue": { + "sumType": "smallUint", + "smallUint": 1 + }, + "name": "Aboba", + "value": 1 + } + }, + "oper1": { + "sumType": "enum", + "enum": { + "actualValue": { + "sumType": "varUint", + "varUint": "0" + }, + "name": "Add", + "value": 0 + } + }, + "oper2": { + "sumType": "enum", + "enum": { + "actualValue": { + "sumType": "bigInt", + "bigInt": "-10000" + }, + "name": "TopUp", + "value": -10000 + } + }, + "oper3": { + "sumType": "enum", + "enum": { + "actualValue": { + "sumType": "smallUint", + "smallUint": 1 + }, + "name": "Something", + "value": 1 + } + } + } + } + } +} \ No newline at end of file diff --git a/tolk/testdata/json/a_lot_refs_from_struct.json b/tolk/testdata/json/a_lot_refs_from_struct.json new file mode 100755 index 00000000..bf3fa2c9 --- /dev/null +++ b/tolk/testdata/json/a_lot_refs_from_struct.json @@ -0,0 +1,128 @@ +{ + "sumType": "struct", + "struct": { + "prefix": { + "len": 32, + "prefix": 3735928559 + }, + "fields": { + "user1": { + "sumType": "alias", + "alias": { + "sumType": "struct", + "struct": { + "fields": { + "addr": { + "sumType": "internalAddress", + "internalAddress": "0:83dfd552e63729b472fcbcc8c45ebcc6691702558b68ec7527e1ba403a0f31a8" + }, + "balance": { + "sumType": "coins", + "coins": "1000000000" + } + } + } + } + }, + "user2": { + "sumType": "optionalValue", + "optionalValue": { + "isExists": true, + "value": { + "sumType": "refValue", + "refValue": { + "sumType": "alias", + "alias": { + "sumType": "struct", + "struct": { + "fields": { + "addr": { + "sumType": "internalAddress", + "internalAddress": "0:086fa2a675f74347b08dd4606a549b8fdb98829cb282bc1949d3b12fbaed9dcc" + }, + "balance": { + "sumType": "coins", + "coins": "100000000" + } + } + } + } + } + } + } + }, + "user3": { + "sumType": "cell", + "cell": "b5ee9c720101010100240000438006e05909e22b2e5e6087533314ee56505f85212914bd5547941a2a658ac62fe101" + }, + "user4": { + "sumType": "optionalValue", + "optionalValue": { + "isExists": false + } + }, + "user5": { + "sumType": "refValue", + "refValue": { + "sumType": "struct", + "struct": { + "fields": { + "addr": { + "sumType": "internalAddress", + "internalAddress": "0:b113a994b5024a16719f69139328eb759596c38a25f59028b146fecdc3621dfe" + }, + "balance": { + "sumType": "coins", + "coins": "10000000000000" + } + } + } + } + }, + "role": { + "sumType": "enum", + "enum": { + "actualValue": { + "sumType": "smallUint", + "smallUint": 1 + }, + "name": "Aboba", + "value": 1 + } + }, + "oper1": { + "sumType": "enum", + "enum": { + "actualValue": { + "sumType": "varUint", + "varUint": "0" + }, + "name": "Add", + "value": 0 + } + }, + "oper2": { + "sumType": "enum", + "enum": { + "actualValue": { + "sumType": "bigInt", + "bigInt": "-10000" + }, + "name": "TopUp", + "value": -10000 + } + }, + "oper3": { + "sumType": "enum", + "enum": { + "actualValue": { + "sumType": "smallUint", + "smallUint": 1 + }, + "name": "Something", + "value": 1 + } + } + } + } +} \ No newline at end of file diff --git a/tolk/testdata/json/address_key_map.json b/tolk/testdata/json/address_key_map.json new file mode 100755 index 00000000..5f88aca0 --- /dev/null +++ b/tolk/testdata/json/address_key_map.json @@ -0,0 +1,10 @@ +{ + "sumType": "map", + "map": { + "keySumType": "internalAddress", + "0:b113a994b5024a16719f69139328eb759596c38a25f59028b146fecdc3621dfe": { + "sumType": "coins", + "coins": "10000000000" + } + } +} \ No newline at end of file diff --git a/tolk/testdata/json/any_external_address.json b/tolk/testdata/json/any_external_address.json new file mode 100755 index 00000000..480656a6 --- /dev/null +++ b/tolk/testdata/json/any_external_address.json @@ -0,0 +1,7 @@ +{ + "sumType": "anyAddress", + "anyAddress": { + "sumType": "externalAddress", + "externalAddress": "4142" + } +} \ No newline at end of file diff --git a/tolk/testdata/json/any_internal_address.json b/tolk/testdata/json/any_internal_address.json new file mode 100755 index 00000000..69c0840a --- /dev/null +++ b/tolk/testdata/json/any_internal_address.json @@ -0,0 +1,7 @@ +{ + "sumType": "anyAddress", + "anyAddress": { + "sumType": "internalAddress", + "internalAddress": "0:83dfd552e63729b472fcbcc8c45ebcc6691702558b68ec7527e1ba403a0f31a8" + } +} \ No newline at end of file diff --git a/tolk/testdata/json/any_none_address.json b/tolk/testdata/json/any_none_address.json new file mode 100755 index 00000000..67f28334 --- /dev/null +++ b/tolk/testdata/json/any_none_address.json @@ -0,0 +1,6 @@ +{ + "sumType": "anyAddress", + "anyAddress": { + "sumType": "noneAddress" + } +} \ No newline at end of file diff --git a/tolk/testdata/json/any_var_address.json b/tolk/testdata/json/any_var_address.json new file mode 100755 index 00000000..ee38dfc7 --- /dev/null +++ b/tolk/testdata/json/any_var_address.json @@ -0,0 +1,7 @@ +{ + "sumType": "anyAddress", + "anyAddress": { + "sumType": "varAddress", + "varAddress": "0:AB" + } +} \ No newline at end of file diff --git a/tolk/testdata/json/big_int.json b/tolk/testdata/json/big_int.json new file mode 100755 index 00000000..ab271aba --- /dev/null +++ b/tolk/testdata/json/big_int.json @@ -0,0 +1,4 @@ +{ + "sumType": "bigInt", + "bigInt": "-3513294376431" +} \ No newline at end of file diff --git a/tolk/testdata/json/big_int_key_map.json b/tolk/testdata/json/big_int_key_map.json new file mode 100755 index 00000000..68e83aa5 --- /dev/null +++ b/tolk/testdata/json/big_int_key_map.json @@ -0,0 +1,10 @@ +{ + "sumType": "map", + "map": { + "keySumType": "bigUint", + "2337412": { + "sumType": "cell", + "cell": "b5ee9c7201010101000800000b000000001ab0" + } + } +} \ No newline at end of file diff --git a/tolk/testdata/json/big_uint.json b/tolk/testdata/json/big_uint.json new file mode 100755 index 00000000..ffdb6c53 --- /dev/null +++ b/tolk/testdata/json/big_uint.json @@ -0,0 +1,4 @@ +{ + "sumType": "bigUint", + "bigUint": "351329437643124" +} \ No newline at end of file diff --git a/tolk/testdata/json/bits.json b/tolk/testdata/json/bits.json new file mode 100755 index 00000000..39b3f8f1 --- /dev/null +++ b/tolk/testdata/json/bits.json @@ -0,0 +1,4 @@ +{ + "sumType": "bits", + "bits": "313233" +} \ No newline at end of file diff --git a/tolk/testdata/json/bits_int_key_map.json b/tolk/testdata/json/bits_int_key_map.json new file mode 100755 index 00000000..a58852cc --- /dev/null +++ b/tolk/testdata/json/bits_int_key_map.json @@ -0,0 +1,25 @@ +{ + "sumType": "map", + "map": { + "keySumType": "bits", + "4142": { + "sumType": "map", + "map": { + "keySumType": "smallInt", + "124": { + "sumType": "tensor", + "tensor": [ + { + "sumType": "internalAddress", + "internalAddress": "0:b113a994b5024a16719f69139328eb759596c38a25f59028b146fecdc3621dfe" + }, + { + "sumType": "coins", + "coins": "1000000000" + } + ] + } + } + } + } +} \ No newline at end of file diff --git a/tolk/testdata/json/bool.json b/tolk/testdata/json/bool.json new file mode 100755 index 00000000..eb057212 --- /dev/null +++ b/tolk/testdata/json/bool.json @@ -0,0 +1,4 @@ +{ + "sumType": "bool", + "bool": false +} \ No newline at end of file diff --git a/tolk/testdata/json/cell.json b/tolk/testdata/json/cell.json new file mode 100755 index 00000000..d0638305 --- /dev/null +++ b/tolk/testdata/json/cell.json @@ -0,0 +1,4 @@ +{ + "sumType": "cell", + "cell": "b5ee9c720101010100060000080000007b" +} \ No newline at end of file diff --git a/tolk/testdata/json/coins.json b/tolk/testdata/json/coins.json new file mode 100755 index 00000000..50706fcd --- /dev/null +++ b/tolk/testdata/json/coins.json @@ -0,0 +1,4 @@ +{ + "sumType": "coins", + "coins": "921464321" +} \ No newline at end of file diff --git a/tolk/testdata/json/empty_tensor.json b/tolk/testdata/json/empty_tensor.json new file mode 100755 index 00000000..e455ca5d --- /dev/null +++ b/tolk/testdata/json/empty_tensor.json @@ -0,0 +1,4 @@ +{ + "sumType": "tensor", + "tensor": [] +} \ No newline at end of file diff --git a/tolk/testdata/json/exists_nullable.json b/tolk/testdata/json/exists_nullable.json new file mode 100755 index 00000000..563b409d --- /dev/null +++ b/tolk/testdata/json/exists_nullable.json @@ -0,0 +1,10 @@ +{ + "sumType": "optionalValue", + "optionalValue": { + "isExists": true, + "value": { + "sumType": "cell", + "cell": "b5ee9c7201010101000700000900000c0ae0" + } + } +} \ No newline at end of file diff --git a/tolk/testdata/json/exists_optional_address.json b/tolk/testdata/json/exists_optional_address.json new file mode 100755 index 00000000..4d4d5c2e --- /dev/null +++ b/tolk/testdata/json/exists_optional_address.json @@ -0,0 +1,7 @@ +{ + "sumType": "optionalAddress", + "optionalAddress": { + "sumType": "internalAddress", + "internalAddress": "0:83dfd552e63729b472fcbcc8c45ebcc6691702558b68ec7527e1ba403a0f31a8" + } +} \ No newline at end of file diff --git a/tolk/testdata/json/external_address.json b/tolk/testdata/json/external_address.json new file mode 100755 index 00000000..4797a6f5 --- /dev/null +++ b/tolk/testdata/json/external_address.json @@ -0,0 +1,4 @@ +{ + "sumType": "externalAddress", + "externalAddress": "4142" +} \ No newline at end of file diff --git a/tolk/testdata/json/int_key_map.json b/tolk/testdata/json/int_key_map.json new file mode 100755 index 00000000..71cdafac --- /dev/null +++ b/tolk/testdata/json/int_key_map.json @@ -0,0 +1,10 @@ +{ + "sumType": "map", + "map": { + "keySumType": "smallInt", + "123": { + "sumType": "bool", + "bool": true + } + } +} \ No newline at end of file diff --git a/tolk/testdata/json/internal_address.json b/tolk/testdata/json/internal_address.json new file mode 100755 index 00000000..6bc2e7d5 --- /dev/null +++ b/tolk/testdata/json/internal_address.json @@ -0,0 +1,4 @@ +{ + "sumType": "internalAddress", + "internalAddress": "0:83dfd552e63729b472fcbcc8c45ebcc6691702558b68ec7527e1ba403a0f31a8" +} \ No newline at end of file diff --git a/tolk/testdata/json/not_exists_nullable.json b/tolk/testdata/json/not_exists_nullable.json new file mode 100755 index 00000000..d84e0bae --- /dev/null +++ b/tolk/testdata/json/not_exists_nullable.json @@ -0,0 +1,6 @@ +{ + "sumType": "optionalValue", + "optionalValue": { + "isExists": false + } +} \ No newline at end of file diff --git a/tolk/testdata/json/not_exists_optional_address.json b/tolk/testdata/json/not_exists_optional_address.json new file mode 100755 index 00000000..762edc5f --- /dev/null +++ b/tolk/testdata/json/not_exists_optional_address.json @@ -0,0 +1,6 @@ +{ + "sumType": "optionalAddress", + "optionalAddress": { + "sumType": "noneAddress" + } +} \ No newline at end of file diff --git a/tolk/testdata/json/ref.json b/tolk/testdata/json/ref.json new file mode 100755 index 00000000..1a9b216e --- /dev/null +++ b/tolk/testdata/json/ref.json @@ -0,0 +1,7 @@ +{ + "sumType": "refValue", + "refValue": { + "sumType": "bigInt", + "bigInt": "1233212" + } +} \ No newline at end of file diff --git a/tolk/testdata/json/remaining.json b/tolk/testdata/json/remaining.json new file mode 100755 index 00000000..4c21ecc1 --- /dev/null +++ b/tolk/testdata/json/remaining.json @@ -0,0 +1,4 @@ +{ + "sumType": "remaining", + "remaining": "b5ee9c7201010101000900000dc0800000000ab8" +} \ No newline at end of file diff --git a/tolk/testdata/json/small_int.json b/tolk/testdata/json/small_int.json new file mode 100644 index 00000000..1b54d8bf --- /dev/null +++ b/tolk/testdata/json/small_int.json @@ -0,0 +1,4 @@ +{ + "sumType": "smallInt", + "smallInt": -35132 +} \ No newline at end of file diff --git a/tolk/testdata/json/small_uint.json b/tolk/testdata/json/small_uint.json new file mode 100755 index 00000000..4b79d99e --- /dev/null +++ b/tolk/testdata/json/small_uint.json @@ -0,0 +1,4 @@ +{ + "sumType": "smallUint", + "smallUint": 934 +} \ No newline at end of file diff --git a/tolk/testdata/json/tensor.json b/tolk/testdata/json/tensor.json new file mode 100755 index 00000000..13548954 --- /dev/null +++ b/tolk/testdata/json/tensor.json @@ -0,0 +1,40 @@ +{ + "sumType": "tensor", + "tensor": [ + { + "sumType": "bigUint", + "bigUint": "4325" + }, + { + "sumType": "bool", + "bool": true + }, + { + "sumType": "coins", + "coins": "1000000000" + }, + { + "sumType": "tensor", + "tensor": [ + { + "sumType": "smallInt", + "smallInt": -342 + }, + { + "sumType": "optionalValue", + "optionalValue": { + "isExists": true, + "value": { + "sumType": "smallInt", + "smallInt": 0 + } + } + } + ] + }, + { + "sumType": "varInt", + "varInt": "-9304000000" + } + ] +} \ No newline at end of file diff --git a/tolk/testdata/json/uint_key_map.json b/tolk/testdata/json/uint_key_map.json new file mode 100755 index 00000000..c62848b2 --- /dev/null +++ b/tolk/testdata/json/uint_key_map.json @@ -0,0 +1,14 @@ +{ + "sumType": "map", + "map": { + "keySumType": "smallUint", + "14": { + "sumType": "internalAddress", + "internalAddress": "0:b113a994b5024a16719f69139328eb759596c38a25f59028b146fecdc3621dfe" + }, + "23": { + "sumType": "internalAddress", + "internalAddress": "-1:5555555555555555555555555555555555555555555555555555555555555555" + } + } +} \ No newline at end of file diff --git a/tolk/testdata/json/union_with_bin_prefix.json b/tolk/testdata/json/union_with_bin_prefix.json new file mode 100755 index 00000000..91d08ef9 --- /dev/null +++ b/tolk/testdata/json/union_with_bin_prefix.json @@ -0,0 +1,30 @@ +{ + "sumType": "union", + "union": { + "prefix": { + "len": 3, + "prefix": 3 + }, + "value": { + "sumType": "struct", + "struct": { + "prefix": { + "len": 3, + "prefix": 3 + }, + "fields": { + "v": { + "sumType": "map", + "map": { + "keySumType": "internalAddress", + "0:b113a994b5024a16719f69139328eb759596c38a25f59028b146fecdc3621dfe": { + "sumType": "coins", + "coins": "43213412" + } + } + } + } + } + } + } +} \ No newline at end of file diff --git a/tolk/testdata/json/union_with_dec_prefix.json b/tolk/testdata/json/union_with_dec_prefix.json new file mode 100755 index 00000000..401d82e6 --- /dev/null +++ b/tolk/testdata/json/union_with_dec_prefix.json @@ -0,0 +1,13 @@ +{ + "sumType": "union", + "union": { + "prefix": { + "len": 1, + "prefix": 1 + }, + "value": { + "sumType": "bigInt", + "bigInt": "124432123" + } + } +} \ No newline at end of file diff --git a/tolk/testdata/json/union_with_hex_prefix.json b/tolk/testdata/json/union_with_hex_prefix.json new file mode 100755 index 00000000..617c3591 --- /dev/null +++ b/tolk/testdata/json/union_with_hex_prefix.json @@ -0,0 +1,24 @@ +{ + "sumType": "union", + "union": { + "prefix": { + "len": 32, + "prefix": 3735928559 + }, + "value": { + "sumType": "struct", + "struct": { + "prefix": { + "len": 32, + "prefix": 3735928559 + }, + "fields": { + "v": { + "sumType": "smallUint", + "smallUint": 1 + } + } + } + } + } +} \ No newline at end of file diff --git a/tolk/testdata/json/var_int.json b/tolk/testdata/json/var_int.json new file mode 100755 index 00000000..4857f6d4 --- /dev/null +++ b/tolk/testdata/json/var_int.json @@ -0,0 +1,4 @@ +{ + "sumType": "varInt", + "varInt": "825432" +} \ No newline at end of file diff --git a/tolk/testdata/json/var_uint.json b/tolk/testdata/json/var_uint.json new file mode 100755 index 00000000..5439ae38 --- /dev/null +++ b/tolk/testdata/json/var_uint.json @@ -0,0 +1,4 @@ +{ + "sumType": "varUint", + "varUint": "9451236712" +} \ No newline at end of file diff --git a/tolk/tuples.go b/tolk/tuples.go index c6b3d672..034c62e7 100644 --- a/tolk/tuples.go +++ b/tolk/tuples.go @@ -1,9 +1,6 @@ package tolk import ( - "encoding/json" - "strings" - "github.com/tonkeeper/tongo/boc" "github.com/tonkeeper/tongo/tolk/parser" ) @@ -34,21 +31,6 @@ func (v *TupleValues) Marshal(cell *boc.Cell, ty tolkParser.TupleWith, encoder * return nil } -func (v *TupleValues) MarshalJSON() ([]byte, error) { - s := strings.Builder{} - s.WriteString("[\n") - for _, item := range *v { - val, err := json.Marshal(item) - if err != nil { - return nil, err - } - s.WriteString(string(val)) - s.WriteString(",\n") - } - s.WriteString("]") - return []byte("null"), nil -} - func (v *TupleValues) Equal(other any) bool { otherTupleValues, ok := other.(TupleValues) if !ok { @@ -108,18 +90,3 @@ func (v *TensorValues) Equal(other any) bool { } return true } - -func (v *TensorValues) MarshalJSON() ([]byte, error) { - s := strings.Builder{} - s.WriteString("[\n") - for _, item := range *v { - val, err := json.Marshal(item) - if err != nil { - return nil, err - } - s.WriteString(string(val)) - s.WriteString(",\n") - } - s.WriteString("]") - return []byte("null"), nil -} diff --git a/tolk/union.go b/tolk/union.go index 87e6bf84..7ffd3065 100644 --- a/tolk/union.go +++ b/tolk/union.go @@ -8,8 +8,8 @@ import ( ) type UnionValue struct { - Prefix Prefix - Val Value + Prefix Prefix `json:"prefix"` + Val Value `json:"value"` } func (u *UnionValue) Unmarshal(cell *boc.Cell, ty tolkParser.Union, decoder *Decoder) error { diff --git a/tolk/value.go b/tolk/value.go index e8d2e9e0..ddb9d71c 100644 --- a/tolk/value.go +++ b/tolk/value.go @@ -4,401 +4,399 @@ package tolk import ( "encoding/hex" - "encoding/json" "fmt" "math/big" "github.com/tonkeeper/tongo/boc" "github.com/tonkeeper/tongo/tolk/parser" "github.com/tonkeeper/tongo/ton" - "github.com/tonkeeper/tongo/utils" ) type SumType string 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 + SumType SumType `json:"sumType"` + Bool *BoolValue `json:"bool,omitempty"` + SmallInt *Int64 `json:"smallInt,omitempty"` + SmallUint *UInt64 `json:"smallUint,omitempty"` + BigInt *BigInt `json:"bigInt,omitempty"` + BigUint *BigUInt `json:"bigUint,omitempty"` + VarInt *VarInt `json:"varInt,omitempty"` + VarUint *VarUInt `json:"varUint,omitempty"` + Coins *CoinsValue `json:"coins,omitempty"` + Bits *Bits `json:"bits,omitempty"` + Cell *Any `json:"cell,omitempty"` + Remaining *RemainingValue `json:"remaining,omitempty"` + InternalAddress *InternalAddress `json:"internalAddress,omitempty"` + OptionalAddress *OptionalAddress `json:"optionalAddress,omitempty"` + ExternalAddress *ExternalAddress `json:"externalAddress,omitempty"` + AnyAddress *AnyAddress `json:"anyAddress,omitempty"` + OptionalValue *OptValue `json:"optionalValue,omitempty"` + RefValue *RefValue `json:"refValue,omitempty"` + TupleWith *TupleValues `json:"tupleWith,omitempty"` + Tensor *TensorValues `json:"tensor,omitempty"` + Map *MapValue `json:"map,omitempty"` + Struct *Struct `json:"struct,omitempty"` + Alias *AliasValue `json:"alias,omitempty"` + Enum *EnumValue `json:"enum,omitempty"` + Generic *GenericValue `json:"generic,omitempty"` + Union *UnionValue `json:"union,omitempty"` + Null *NullValue `json:"null,omitempty"` + Void *VoidValue `json:"void,omitempty"` } func (v *Value) GetBool() (bool, bool) { - if v.bool == nil { + if v.Bool == nil { return false, false } - return bool(*v.bool), true + return bool(*v.Bool), true } func (v *Value) MustGetBool() bool { - if v.bool == nil { + if v.Bool == nil { panic("value is not a bool") } - return bool(*v.bool) + return bool(*v.Bool) } func (v *Value) GetSmallInt() (int64, bool) { - if v.smallInt == nil { + if v.SmallInt == nil { return 0, false } - return int64(*v.smallInt), true + return int64(*v.SmallInt), true } func (v *Value) MustGetSmallInt() int64 { - if v.smallInt == nil { + if v.SmallInt == nil { panic("value is not a small int") } - return int64(*v.smallInt) + return int64(*v.SmallInt) } func (v *Value) GetBigInt() (big.Int, bool) { - if v.bigInt == nil { + if v.BigInt == nil { return big.Int{}, false } - return big.Int(*v.bigInt), true + return big.Int(*v.BigInt), true } func (v *Value) MustGetBigInt() big.Int { - if v.bigInt == nil { + if v.BigInt == nil { panic("value is not a big int") } - return big.Int(*v.bigInt) + return big.Int(*v.BigInt) } func (v *Value) GetSmallUInt() (uint64, bool) { - if v.smallUint == nil { + if v.SmallUint == nil { return 0, false } - return uint64(*v.smallUint), true + return uint64(*v.SmallUint), true } func (v *Value) MustGetSmallUInt() uint64 { - if v.smallUint == nil { + if v.SmallUint == nil { panic("value is not a small uint") } - return uint64(*v.smallUint) + return uint64(*v.SmallUint) } func (v *Value) GetBigUInt() (big.Int, bool) { - if v.bigUint == nil { + if v.BigUint == nil { return big.Int{}, false } - return big.Int(*v.bigUint), true + return big.Int(*v.BigUint), true } func (v *Value) MustGetBigUInt() big.Int { - if v.bigUint == nil { + if v.BigUint == nil { panic("value is not a big uint") } - return big.Int(*v.bigUint) + return big.Int(*v.BigUint) } func (v *Value) GetVarInt() (big.Int, bool) { - if v.varInt == nil { + if v.VarInt == nil { return big.Int{}, false } - return big.Int(*v.varInt), true + return big.Int(*v.VarInt), true } func (v *Value) MustGetVarInt() big.Int { - if v.varInt == nil { + if v.VarInt == nil { panic("value is not a var int") } - return big.Int(*v.varInt) + return big.Int(*v.VarInt) } func (v *Value) GetVarUInt() (big.Int, bool) { - if v.varUint == nil { + if v.VarUint == nil { return big.Int{}, false } - return big.Int(*v.varUint), true + return big.Int(*v.VarUint), true } func (v *Value) MustGetVarUInt() big.Int { - if v.varUint == nil { + if v.VarUint == nil { panic("value is not a var uint") } - return big.Int(*v.varUint) + return big.Int(*v.VarUint) } func (v *Value) GetCoins() (big.Int, bool) { - if v.coins == nil { + if v.Coins == nil { return big.Int{}, false } - return big.Int(*v.coins), true + return big.Int(*v.Coins), true } func (v *Value) MustGetCoins() big.Int { - if v.coins == nil { + if v.Coins == nil { panic("value is not a coins") } - return big.Int(*v.coins) + return big.Int(*v.Coins) } func (v *Value) GetBits() (boc.BitString, bool) { - if v.bits == nil { + if v.Bits == nil { return boc.BitString{}, false } - return boc.BitString(*v.bits), true + return boc.BitString(*v.Bits), true } func (v *Value) MustGetBits() boc.BitString { - if v.bits == nil { + if v.Bits == nil { panic("value is not a bits") } - return boc.BitString(*v.bits) + return boc.BitString(*v.Bits) } func (v *Value) GetAddress() (InternalAddress, bool) { - if v.internalAddress == nil { + if v.InternalAddress == nil { return InternalAddress{}, false } - return *v.internalAddress, true + return *v.InternalAddress, true } func (v *Value) MustGetAddress() InternalAddress { - if v.internalAddress == nil { + if v.InternalAddress == nil { panic("value is not an internal address") } - return *v.internalAddress + return *v.InternalAddress } func (v *Value) GetOptionalAddress() (OptionalAddress, bool) { - if v.optionalAddress == nil { + if v.OptionalAddress == nil { return OptionalAddress{}, false } - return *v.optionalAddress, true + return *v.OptionalAddress, true } func (v *Value) MustGetOptionalAddress() OptionalAddress { - if v.optionalAddress == nil { + if v.OptionalAddress == nil { panic("value is not an optional address") } - return *v.optionalAddress + return *v.OptionalAddress } func (v *Value) GetExternalAddress() (ExternalAddress, bool) { - if v.externalAddress == nil { + if v.ExternalAddress == nil { return ExternalAddress{}, false } - return *v.externalAddress, true + return *v.ExternalAddress, true } func (v *Value) MustGetExternalAddress() ExternalAddress { - if v.externalAddress == nil { + if v.ExternalAddress == nil { panic("value is not an external address") } - return *v.externalAddress + return *v.ExternalAddress } func (v *Value) GetAnyAddress() (AnyAddress, bool) { - if v.anyAddress == nil { + if v.AnyAddress == nil { return AnyAddress{}, false } - return *v.anyAddress, true + return *v.AnyAddress, true } func (v *Value) MustGetAnyAddress() AnyAddress { - if v.anyAddress == nil { + if v.AnyAddress == nil { panic("value is not an any address") } - return *v.anyAddress + return *v.AnyAddress } func (v *Value) GetOptionalValue() (OptValue, bool) { - if v.optionalValue == nil { + if v.OptionalValue == nil { return OptValue{}, false } - return *v.optionalValue, true + return *v.OptionalValue, true } func (v *Value) MustGetOptionalValue() OptValue { - if v.optionalValue == nil { + if v.OptionalValue == nil { panic("value is not an optional value") } - return *v.optionalValue + return *v.OptionalValue } func (v *Value) GetRefValue() (Value, bool) { - if v.refValue == nil { + if v.RefValue == nil { return Value{}, false } - return Value(*v.refValue), true + return Value(*v.RefValue), true } func (v *Value) MustGetRefValue() Value { - if v.refValue == nil { + if v.RefValue == nil { panic("value is not a reference") } - return Value(*v.refValue) + return Value(*v.RefValue) } func (v *Value) GetTensor() ([]Value, bool) { - if v.tensor == nil { + if v.Tensor == nil { return TensorValues{}, false } - return *v.tensor, true + return *v.Tensor, true } func (v *Value) MustGetTensor() []Value { - if v.tensor == nil { + if v.Tensor == nil { panic("value is not a tensor") } - return *v.tensor + return *v.Tensor } func (v *Value) GetMap() (MapValue, bool) { - if v.mp == nil { + if v.Map == nil { return MapValue{}, false } - return *v.mp, true + return *v.Map, true } func (v *Value) MustGetMap() MapValue { - if v.mp == nil { + if v.Map == nil { panic("value is not a map") } - return *v.mp + return *v.Map } func (v *Value) GetStruct() (Struct, bool) { - if v.structValue == nil { + if v.Struct == nil { return Struct{}, false } - return *v.structValue, true + return *v.Struct, true } func (v *Value) MustGetStruct() Struct { - if v.structValue == nil { + if v.Struct == nil { panic("value is not a struct") } - return *v.structValue + return *v.Struct } func (v *Value) GetAlias() (Value, bool) { - if v.alias == nil { + if v.Alias == nil { return Value{}, false } - return Value(*v.alias), true + return Value(*v.Alias), true } func (v *Value) MustGetAlias() Value { - if v.alias == nil { + if v.Alias == nil { panic("value is not an alias") } - return Value(*v.alias) + return Value(*v.Alias) } func (v *Value) GetGeneric() (Value, bool) { - if v.generic == nil { + if v.Generic == nil { return Value{}, false } - return Value(*v.generic), true + return Value(*v.Generic), true } func (v *Value) MustGetGeneric() Value { - if v.generic == nil { + if v.Generic == nil { panic("value is not a generic") } - return Value(*v.generic) + return Value(*v.Generic) } func (v *Value) GetEnum() (EnumValue, bool) { - if v.enum == nil { + if v.Enum == nil { return EnumValue{}, false } - return *v.enum, true + return *v.Enum, true } func (v *Value) MustGetEnum() EnumValue { - if v.enum == nil { + if v.Enum == nil { panic("value is not an enum") } - return *v.enum + return *v.Enum } func (v *Value) GetUnion() (UnionValue, bool) { - if v.union == nil { + if v.Union == nil { return UnionValue{}, false } - return *v.union, true + return *v.Union, true } func (v *Value) MustGetUnion() UnionValue { - if v.union == nil { + if v.Union == nil { panic("value is not an union") } - return *v.union + return *v.Union } func (v *Value) GetTupleValues() ([]Value, bool) { - if v.tupleWith == nil { + if v.TupleWith == nil { return TupleValues{}, false } - return *v.tupleWith, true + return *v.TupleWith, true } func (v *Value) MustGetTupleValues() []Value { - if v.tupleWith == nil { + if v.TupleWith == nil { panic("value is not a tuple") } - return *v.tupleWith + return *v.TupleWith } func (v *Value) GetCell() (boc.Cell, bool) { - if v.cell == nil { + if v.Cell == nil { return boc.Cell{}, false } - return boc.Cell(*v.cell), true + return boc.Cell(*v.Cell), true } func (v *Value) MustGetCell() boc.Cell { - if v.cell == nil { + if v.Cell == nil { panic("value is not a cell") } - return boc.Cell(*v.cell) + return boc.Cell(*v.Cell) } func (v *Value) GetRemaining() (boc.Cell, bool) { - if v.remaining == nil { + if v.Remaining == nil { return boc.Cell{}, false } - return boc.Cell(*v.remaining), true + return boc.Cell(*v.Remaining), true } func (v *Value) MustGetRemaining() boc.Cell { - if v.remaining == nil { + if v.Remaining == nil { panic("value is not a remaining") } - return boc.Cell(*v.remaining) + return boc.Cell(*v.Remaining) } func (v *Value) GetType() string { - return string(v.sumType) + return string(v.SumType) } func (v *Value) SetValue(val any, ty tolkParser.Ty) error { @@ -411,9 +409,9 @@ func (v *Value) SetValue(val any, ty tolkParser.Ty) error { if ty.IntN.N <= 64 { b := big.Int(bi) wVal := Int64(b.Int64()) - v.smallInt = &wVal + v.SmallInt = &wVal } else { - v.bigInt = &bi + v.BigInt = &bi } case "UintN": bi, ok := val.(BigUInt) @@ -423,88 +421,88 @@ func (v *Value) SetValue(val any, ty tolkParser.Ty) error { if ty.UintN.N <= 64 { b := big.Int(bi) wVal := UInt64(b.Uint64()) - v.smallUint = &wVal + v.SmallUint = &wVal } else { - v.bigUint = &bi + v.BigUint = &bi } case "VarIntN": vi, ok := val.(VarInt) if !ok { return fmt.Errorf("cannot convert %v to VarInt", val) } - v.varInt = &vi + v.VarInt = &vi case "VarUintN": vi, ok := val.(VarUInt) if !ok { return fmt.Errorf("cannot convert %v to VarUInt", val) } - v.varUint = &vi + v.VarUint = &vi case "BitsN": b, ok := val.(Bits) if !ok { return fmt.Errorf("cannot convert %v to Bits", val) } - v.bits = &b + v.Bits = &b case "Nullable": o, ok := val.(OptValue) if !ok { return fmt.Errorf("cannot convert %v to OptValue", val) } - v.optionalValue = &o + v.OptionalValue = &o case "CellOf": r, ok := val.(RefValue) if !ok { return fmt.Errorf("cannot convert %v to RefValue", val) } - v.refValue = &r + v.RefValue = &r case "Tensor": t, ok := val.(TensorValues) if !ok { return fmt.Errorf("cannot convert %v to TensorValues", val) } - v.tensor = &t + v.Tensor = &t case "TupleWith": t, ok := val.(TupleValues) if !ok { return fmt.Errorf("cannot convert %v to TupleValues", val) } - v.tupleWith = &t + v.TupleWith = &t case "Map": m, ok := val.(MapValue) if !ok { return fmt.Errorf("cannot convert %v to MapValue", val) } - v.mp = &m + v.Map = &m case "EnumRef": e, ok := val.(EnumValue) if !ok { return fmt.Errorf("cannot convert %v to EnumValue", val) } - v.enum = &e + v.Enum = &e case "StructRef": s, ok := val.(Struct) if !ok { return fmt.Errorf("cannot convert %v to Struct", val) } - v.structValue = &s + v.Struct = &s case "AliasRef": a, ok := val.(AliasValue) if !ok { return fmt.Errorf("cannot convert %v to AliasValue", val) } - v.alias = &a + v.Alias = &a case "Generic": g, ok := val.(GenericValue) if !ok { return fmt.Errorf("cannot convert %v to GenericValue", val) } - v.generic = &g + v.Generic = &g case "Union": u, ok := val.(UnionValue) if !ok { return fmt.Errorf("cannot convert %v to UnionValue", val) } - v.union = &u + v.Union = &u case "Int": return fmt.Errorf("int not supported") case "Coins": @@ -512,19 +510,19 @@ func (v *Value) SetValue(val any, ty tolkParser.Ty) error { if !ok { return fmt.Errorf("cannot convert %v to CoinsValue", val) } - v.coins = &c + v.Coins = &c case "Bool": b, ok := val.(BoolValue) if !ok { return fmt.Errorf("cannot convert %v to BoolValue", val) } - v.bool = &b + v.Bool = &b case "Cell": a, ok := val.(Any) if !ok { return fmt.Errorf("cannot convert %v to Any", val) } - v.cell = &a + v.Cell = &a case "Slice": return fmt.Errorf("slice not supported") case "Builder": @@ -536,31 +534,31 @@ func (v *Value) SetValue(val any, ty tolkParser.Ty) error { if !ok { return fmt.Errorf("cannot convert %v to RemainingValue", val) } - v.remaining = &r + v.Remaining = &r case "Address": i, ok := val.(InternalAddress) if !ok { return fmt.Errorf("cannot convert %v to InternalAddress", val) } - v.internalAddress = &i + v.InternalAddress = &i case "AddressOpt": o, ok := val.(OptionalAddress) if !ok { return fmt.Errorf("cannot convert %v to OptionalAddress", val) } - v.optionalAddress = &o + v.OptionalAddress = &o case "AddressExt": e, ok := val.(ExternalAddress) if !ok { return fmt.Errorf("cannot convert %v to ExternalAddress", val) } - v.externalAddress = &e + v.ExternalAddress = &e case "AddressAny": a, ok := val.(AnyAddress) if !ok { return fmt.Errorf("cannot convert %v to AnyAddress", val) } - v.anyAddress = &a + v.AnyAddress = &a case "TupleAny": return fmt.Errorf("tuple any not supported") case "NullLiteral": @@ -568,13 +566,13 @@ func (v *Value) SetValue(val any, ty tolkParser.Ty) error { if !ok { return fmt.Errorf("cannot convert %v to NullValue", val) } - v.null = &n + v.Null = &n case "Void": vo, ok := val.(VoidValue) if !ok { return fmt.Errorf("cannot convert %v to VoidValue", val) } - v.void = &vo + v.Void = &vo default: return fmt.Errorf("unknown ty type %q", ty.SumType) } @@ -586,93 +584,93 @@ func (v *Value) Unmarshal(cell *boc.Cell, ty tolkParser.Ty, decoder *Decoder) er switch ty.SumType { case "IntN": if ty.IntN.N <= 64 { - v.sumType = "smallInt" + v.SumType = "smallInt" def := Int64(0) - v.smallInt = &def - err = v.smallInt.Unmarshal(cell, *ty.IntN, decoder) + v.SmallInt = &def + err = v.SmallInt.Unmarshal(cell, *ty.IntN, decoder) } else { - v.sumType = "bigInt" - v.bigInt = &BigInt{} - err = v.bigInt.Unmarshal(cell, *ty.IntN, decoder) + v.SumType = "bigInt" + v.BigInt = &BigInt{} + err = v.BigInt.Unmarshal(cell, *ty.IntN, decoder) } case "UintN": if ty.UintN.N <= 64 { - v.sumType = "smallUint" + v.SumType = "smallUint" def := UInt64(0) - v.smallUint = &def - err = v.smallUint.Unmarshal(cell, *ty.UintN, decoder) + v.SmallUint = &def + err = v.SmallUint.Unmarshal(cell, *ty.UintN, decoder) } else { - v.sumType = "bigUint" - v.bigUint = &BigUInt{} - err = v.bigUint.Unmarshal(cell, *ty.UintN, decoder) + v.SumType = "bigUint" + v.BigUint = &BigUInt{} + err = v.BigUint.Unmarshal(cell, *ty.UintN, decoder) } case "VarIntN": - v.sumType = "varInt" - v.varInt = &VarInt{} - err = v.varInt.Unmarshal(cell, *ty.VarIntN, decoder) + v.SumType = "varInt" + v.VarInt = &VarInt{} + err = v.VarInt.Unmarshal(cell, *ty.VarIntN, decoder) case "VarUintN": - v.sumType = "varUint" - v.varUint = &VarUInt{} - err = v.varUint.Unmarshal(cell, *ty.VarUintN, decoder) + v.SumType = "varUint" + v.VarUint = &VarUInt{} + err = v.VarUint.Unmarshal(cell, *ty.VarUintN, decoder) case "BitsN": - v.sumType = "bits" - v.bits = &Bits{} - err = v.bits.Unmarshal(cell, *ty.BitsN, decoder) + v.SumType = "bits" + v.Bits = &Bits{} + err = v.Bits.Unmarshal(cell, *ty.BitsN, decoder) case "Nullable": - v.sumType = "optionalValue" - v.optionalValue = &OptValue{} - err = v.optionalValue.Unmarshal(cell, *ty.Nullable, decoder) + v.SumType = "optionalValue" + v.OptionalValue = &OptValue{} + err = v.OptionalValue.Unmarshal(cell, *ty.Nullable, decoder) case "CellOf": - v.sumType = "refValue" - v.refValue = &RefValue{} - err = v.refValue.Unmarshal(cell, *ty.CellOf, decoder) + v.SumType = "refValue" + v.RefValue = &RefValue{} + err = v.RefValue.Unmarshal(cell, *ty.CellOf, decoder) case "Tensor": - v.sumType = "tensor" - v.tensor = &TensorValues{} - err = v.tensor.Unmarshal(cell, *ty.Tensor, decoder) + v.SumType = "tensor" + v.Tensor = &TensorValues{} + err = v.Tensor.Unmarshal(cell, *ty.Tensor, decoder) case "TupleWith": - v.sumType = "tupleWith" - v.tupleWith = &TupleValues{} - err = v.tupleWith.Unmarshal(cell, *ty.TupleWith, decoder) + v.SumType = "tupleWith" + v.TupleWith = &TupleValues{} + err = v.TupleWith.Unmarshal(cell, *ty.TupleWith, decoder) case "Map": - v.sumType = "mp" - v.mp = &MapValue{} - err = v.mp.Unmarshal(cell, *ty.Map, decoder) + v.SumType = "map" + v.Map = &MapValue{} + err = v.Map.Unmarshal(cell, *ty.Map, decoder) case "EnumRef": - v.sumType = "enum" - v.enum = &EnumValue{} - err = v.enum.Unmarshal(cell, *ty.EnumRef, decoder) + v.SumType = "enum" + v.Enum = &EnumValue{} + err = v.Enum.Unmarshal(cell, *ty.EnumRef, decoder) case "StructRef": - v.sumType = "structValue" - v.structValue = &Struct{} - err = v.structValue.Unmarshal(cell, *ty.StructRef, decoder) + v.SumType = "struct" + v.Struct = &Struct{} + err = v.Struct.Unmarshal(cell, *ty.StructRef, decoder) case "AliasRef": - v.sumType = "alias" - v.alias = &AliasValue{} - err = v.alias.Unmarshal(cell, *ty.AliasRef, decoder) + v.SumType = "alias" + v.Alias = &AliasValue{} + err = v.Alias.Unmarshal(cell, *ty.AliasRef, decoder) case "Generic": - v.sumType = "generic" - v.generic = &GenericValue{} - err = v.generic.Unmarshal(cell, *ty.Generic, decoder) + v.SumType = "generic" + v.Generic = &GenericValue{} + err = v.Generic.Unmarshal(cell, *ty.Generic, decoder) case "Union": - v.sumType = "union" - v.union = &UnionValue{} - err = v.union.Unmarshal(cell, *ty.Union, decoder) + v.SumType = "union" + v.Union = &UnionValue{} + err = v.Union.Unmarshal(cell, *ty.Union, decoder) case "Int": err = fmt.Errorf("int not supported") case "Coins": - v.sumType = "coins" - v.coins = &CoinsValue{} - err = v.coins.Unmarshal(cell, *ty.Coins, decoder) + v.SumType = "coins" + v.Coins = &CoinsValue{} + err = v.Coins.Unmarshal(cell, *ty.Coins, decoder) case "Bool": - v.sumType = "bool" + v.SumType = "bool" def := BoolValue(false) - v.bool = &def - err = v.bool.Unmarshal(cell, *ty.Bool, decoder) + v.Bool = &def + err = v.Bool.Unmarshal(cell, *ty.Bool, decoder) case "Cell": - v.sumType = "cell" - v.cell = &Any{} - err = v.cell.Unmarshal(cell, *ty.Cell, decoder) + v.SumType = "cell" + v.Cell = &Any{} + err = v.Cell.Unmarshal(cell, *ty.Cell, decoder) case "Slice": err = fmt.Errorf("slice not supported") case "Builder": @@ -680,35 +678,35 @@ func (v *Value) Unmarshal(cell *boc.Cell, ty tolkParser.Ty, decoder *Decoder) er case "Callable": err = fmt.Errorf("callable not supported") case "Remaining": - v.sumType = "remaining" - v.remaining = &RemainingValue{} - err = v.remaining.Unmarshal(cell, *ty.Remaining, decoder) + v.SumType = "remaining" + v.Remaining = &RemainingValue{} + err = v.Remaining.Unmarshal(cell, *ty.Remaining, decoder) case "Address": - v.sumType = "internalAddress" - v.internalAddress = &InternalAddress{} - err = v.internalAddress.Unmarshal(cell, *ty.Address, decoder) + v.SumType = "internalAddress" + v.InternalAddress = &InternalAddress{} + err = v.InternalAddress.Unmarshal(cell, *ty.Address, decoder) case "AddressOpt": - v.sumType = "optionalAddress" - v.optionalAddress = &OptionalAddress{} - err = v.optionalAddress.Unmarshal(cell, *ty.AddressOpt, decoder) + v.SumType = "optionalAddress" + v.OptionalAddress = &OptionalAddress{} + err = v.OptionalAddress.Unmarshal(cell, *ty.AddressOpt, decoder) case "AddressExt": - v.sumType = "externalAddress" - v.externalAddress = &ExternalAddress{} - err = v.externalAddress.Unmarshal(cell, *ty.AddressExt, decoder) + v.SumType = "externalAddress" + v.ExternalAddress = &ExternalAddress{} + err = v.ExternalAddress.Unmarshal(cell, *ty.AddressExt, decoder) case "AddressAny": - v.sumType = "anyAddress" - v.anyAddress = &AnyAddress{} - err = v.anyAddress.Unmarshal(cell, *ty.AddressAny, decoder) + v.SumType = "anyAddress" + v.AnyAddress = &AnyAddress{} + err = v.AnyAddress.Unmarshal(cell, *ty.AddressAny, decoder) case "TupleAny": err = fmt.Errorf("tuple any not supported") case "NullLiteral": - v.sumType = "null" - v.null = &NullValue{} - err = v.null.Unmarshal(cell, *ty.NullLiteral, decoder) + v.SumType = "null" + v.Null = &NullValue{} + err = v.Null.Unmarshal(cell, *ty.NullLiteral, decoder) case "Void": - v.sumType = "void" - v.void = &VoidValue{} - err = v.void.Unmarshal(cell, *ty.Void, decoder) + v.SumType = "void" + v.Void = &VoidValue{} + err = v.Void.Unmarshal(cell, *ty.Void, decoder) default: return fmt.Errorf("unknown ty type %q", ty.SumType) } @@ -723,110 +721,110 @@ func (v *Value) Marshal(cell *boc.Cell, ty tolkParser.Ty, encoder *Encoder) erro switch ty.SumType { case "IntN": if ty.IntN.N <= 64 { - if v.sumType != "smallInt" { - return fmt.Errorf("expected smallInt, but got %v", v.sumType) + if v.SumType != "smallInt" { + return fmt.Errorf("expected smallInt, but got %v", v.SumType) } - return v.smallInt.Marshal(cell, *ty.IntN, encoder) + return v.SmallInt.Marshal(cell, *ty.IntN, encoder) } else { - if v.sumType != "bigInt" { - return fmt.Errorf("expected bigInt, but got %v", v.sumType) + if v.SumType != "bigInt" { + return fmt.Errorf("expected bigInt, but got %v", v.SumType) } - return v.bigInt.Marshal(cell, *ty.IntN, encoder) + return v.BigInt.Marshal(cell, *ty.IntN, encoder) } case "UintN": if ty.UintN.N <= 64 { - if v.sumType != "smallUint" { - return fmt.Errorf("expected smallUint, but got %v", v.sumType) + if v.SumType != "smallUint" { + return fmt.Errorf("expected smallUint, but got %v", v.SumType) } - return v.smallUint.Marshal(cell, *ty.UintN, encoder) + return v.SmallUint.Marshal(cell, *ty.UintN, encoder) } else { - if v.sumType != "bigUint" { - return fmt.Errorf("expected bigUint, but got %v", v.sumType) + if v.SumType != "bigUint" { + return fmt.Errorf("expected bigUint, but got %v", v.SumType) } - return v.bigUint.Marshal(cell, *ty.UintN, encoder) + return v.BigUint.Marshal(cell, *ty.UintN, encoder) } case "VarIntN": - if v.sumType != "varInt" { - return fmt.Errorf("expected varInt, but got %v", v.sumType) + if v.SumType != "varInt" { + return fmt.Errorf("expected varInt, but got %v", v.SumType) } - return v.varInt.Marshal(cell, *ty.VarIntN, encoder) + return v.VarInt.Marshal(cell, *ty.VarIntN, encoder) case "VarUintN": - if v.sumType != "varUint" { - return fmt.Errorf("expected varUint, but got %v", v.sumType) + if v.SumType != "varUint" { + return fmt.Errorf("expected varUint, but got %v", v.SumType) } - return v.varUint.Marshal(cell, *ty.VarUintN, encoder) + return v.VarUint.Marshal(cell, *ty.VarUintN, encoder) case "BitsN": - if v.sumType != "bits" { - return fmt.Errorf("expected bits, but got %v", v.sumType) + if v.SumType != "bits" { + return fmt.Errorf("expected bits, but got %v", v.SumType) } - return v.bits.Marshal(cell, *ty.BitsN, encoder) + return v.Bits.Marshal(cell, *ty.BitsN, encoder) case "Nullable": - if v.sumType != "optionalValue" { - return fmt.Errorf("expected optionalValue, but got %v", v.sumType) + if v.SumType != "optionalValue" { + return fmt.Errorf("expected optionalValue, but got %v", v.SumType) } - return v.optionalValue.Marshal(cell, *ty.Nullable, encoder) + return v.OptionalValue.Marshal(cell, *ty.Nullable, encoder) case "CellOf": - if v.sumType != "refValue" { - return fmt.Errorf("expected refValue, but got %v", v.sumType) + if v.SumType != "refValue" { + return fmt.Errorf("expected refValue, but got %v", v.SumType) } - return v.refValue.Marshal(cell, *ty.CellOf, encoder) + return v.RefValue.Marshal(cell, *ty.CellOf, encoder) case "Tensor": - if v.sumType != "tensor" { - return fmt.Errorf("expected tensor, but got %v", v.sumType) + if v.SumType != "tensor" { + return fmt.Errorf("expected tensor, but got %v", v.SumType) } - return v.tensor.Marshal(cell, *ty.Tensor, encoder) + return v.Tensor.Marshal(cell, *ty.Tensor, encoder) case "TupleWith": - if v.sumType != "tupleWith" { - return fmt.Errorf("expected tupleWith, but got %v", v.sumType) + if v.SumType != "tupleWith" { + return fmt.Errorf("expected tupleWith, but got %v", v.SumType) } - return v.tupleWith.Marshal(cell, *ty.TupleWith, encoder) + return v.TupleWith.Marshal(cell, *ty.TupleWith, encoder) case "Map": - if v.sumType != "mp" { - return fmt.Errorf("expected mp, but got %v", v.sumType) + if v.SumType != "map" { + return fmt.Errorf("expected map, but got %v", v.SumType) } - return v.mp.Marshal(cell, *ty.Map, encoder) + return v.Map.Marshal(cell, *ty.Map, encoder) case "EnumRef": - if v.sumType != "enum" { - return fmt.Errorf("expected enum, but got %v", v.sumType) + if v.SumType != "enum" { + return fmt.Errorf("expected enum, but got %v", v.SumType) } - return v.enum.Marshal(cell, *ty.EnumRef, encoder) + return v.Enum.Marshal(cell, *ty.EnumRef, encoder) case "StructRef": - if v.sumType != "structValue" { - return fmt.Errorf("expected structValue, but got %v", v.sumType) + if v.SumType != "struct" { + return fmt.Errorf("expected struct, but got %v", v.SumType) } - return v.structValue.Marshal(cell, *ty.StructRef, encoder) + return v.Struct.Marshal(cell, *ty.StructRef, encoder) case "AliasRef": - if v.sumType != "alias" { - return fmt.Errorf("expected alias, but got %v", v.sumType) + if v.SumType != "alias" { + return fmt.Errorf("expected alias, but got %v", v.SumType) } - return v.alias.Marshal(cell, *ty.AliasRef, encoder) + return v.Alias.Marshal(cell, *ty.AliasRef, encoder) case "Generic": - if v.sumType != "generic" { - return fmt.Errorf("expected generic, but got %v", v.sumType) + if v.SumType != "generic" { + return fmt.Errorf("expected generic, but got %v", v.SumType) } - return v.generic.Marshal(cell, *ty.Generic, encoder) + return v.Generic.Marshal(cell, *ty.Generic, encoder) case "Union": - if v.sumType != "union" { - return fmt.Errorf("expected union, but got %v", v.sumType) + if v.SumType != "union" { + return fmt.Errorf("expected union, but got %v", v.SumType) } - return v.union.Marshal(cell, *ty.Union, encoder) + return v.Union.Marshal(cell, *ty.Union, encoder) case "Int": err = fmt.Errorf("int not supported") case "Coins": - if v.sumType != "coins" { - return fmt.Errorf("expected coins, but got %v", v.sumType) + if v.SumType != "coins" { + return fmt.Errorf("expected coins, but got %v", v.SumType) } - return v.coins.Marshal(cell, *ty.Coins, encoder) + return v.Coins.Marshal(cell, *ty.Coins, encoder) case "Bool": - if v.sumType != "bool" { - return fmt.Errorf("expected bool, but got %v", v.sumType) + if v.SumType != "bool" { + return fmt.Errorf("expected bool, but got %v", v.SumType) } - return v.bool.Marshal(cell, *ty.Bool, encoder) + return v.Bool.Marshal(cell, *ty.Bool, encoder) case "Cell": - if v.sumType != "cell" { - return fmt.Errorf("expected cell, but got %v", v.sumType) + if v.SumType != "cell" { + return fmt.Errorf("expected cell, but got %v", v.SumType) } - return v.cell.Marshal(cell, *ty.Cell, encoder) + return v.Cell.Marshal(cell, *ty.Cell, encoder) case "Slice": err = fmt.Errorf("slice not supported") case "Builder": @@ -834,42 +832,42 @@ func (v *Value) Marshal(cell *boc.Cell, ty tolkParser.Ty, encoder *Encoder) erro case "Callable": err = fmt.Errorf("callable not supported") case "Remaining": - if v.sumType != "remaining" { - return fmt.Errorf("expected remaining, but got %v", v.sumType) + if v.SumType != "remaining" { + return fmt.Errorf("expected remaining, but got %v", v.SumType) } - return v.remaining.Marshal(cell, *ty.Remaining, encoder) + return v.Remaining.Marshal(cell, *ty.Remaining, encoder) case "Address": - if v.sumType != "internalAddress" { - return fmt.Errorf("expected internalAddress, but got %v", v.sumType) + if v.SumType != "internalAddress" { + return fmt.Errorf("expected internalAddress, but got %v", v.SumType) } - return v.internalAddress.Marshal(cell, *ty.Address, encoder) + return v.InternalAddress.Marshal(cell, *ty.Address, encoder) case "AddressOpt": - if v.sumType != "optionalAddress" { - return fmt.Errorf("expected optionalAddress, but got %v", v.sumType) + if v.SumType != "optionalAddress" { + return fmt.Errorf("expected optionalAddress, but got %v", v.SumType) } - return v.optionalAddress.Marshal(cell, *ty.AddressOpt, encoder) + return v.OptionalAddress.Marshal(cell, *ty.AddressOpt, encoder) case "AddressExt": - if v.sumType != "externalAddress" { - return fmt.Errorf("expected externalAddress, but got %v", v.sumType) + if v.SumType != "externalAddress" { + return fmt.Errorf("expected externalAddress, but got %v", v.SumType) } - return v.externalAddress.Marshal(cell, *ty.AddressExt, encoder) + return v.ExternalAddress.Marshal(cell, *ty.AddressExt, encoder) case "AddressAny": - if v.sumType != "anyAddress" { - return fmt.Errorf("expected anyAddress, but got %v", v.sumType) + if v.SumType != "anyAddress" { + return fmt.Errorf("expected anyAddress, but got %v", v.SumType) } - return v.anyAddress.Marshal(cell, *ty.AddressAny, encoder) + return v.AnyAddress.Marshal(cell, *ty.AddressAny, encoder) case "TupleAny": err = fmt.Errorf("tuple any not supported") case "NullLiteral": - if v.sumType != "null" { - return fmt.Errorf("expected null, but got %v", v.sumType) + if v.SumType != "null" { + return fmt.Errorf("expected null, but got %v", v.SumType) } - return v.null.Marshal(cell, *ty.NullLiteral, encoder) + return v.Null.Marshal(cell, *ty.NullLiteral, encoder) case "Void": - if v.sumType != "void" { - return fmt.Errorf("expected void, but got %v", v.sumType) + if v.SumType != "void" { + return fmt.Errorf("expected void, but got %v", v.SumType) } - return v.void.Marshal(cell, *ty.Void, encoder) + return v.Void.Marshal(cell, *ty.Void, encoder) default: err = fmt.Errorf("unknown ty type %q", ty.SumType) } @@ -953,473 +951,143 @@ func (v *Value) Equal(o any) bool { return false } - switch v.sumType { + switch v.SumType { case "bool": - if otherValue.bool == nil { + if otherValue.Bool == nil { return false } - return v.bool.Equal(*otherValue.bool) + return v.Bool.Equal(*otherValue.Bool) case "smallInt": - if otherValue.smallInt == nil { + if otherValue.SmallInt == nil { return false } - return v.smallInt.Equal(*otherValue.smallInt) + return v.SmallInt.Equal(*otherValue.SmallInt) case "smallUint": - if otherValue.smallUint == nil { + if otherValue.SmallUint == nil { return false } - return v.smallUint.Equal(*otherValue.smallUint) + return v.SmallUint.Equal(*otherValue.SmallUint) case "bigInt": - if otherValue.bigInt == nil { + if otherValue.BigInt == nil { return false } - return v.bigInt.Equal(*otherValue.bigInt) + return v.BigInt.Equal(*otherValue.BigInt) case "bigUint": - if otherValue.bigUint == nil { + if otherValue.BigUint == nil { return false } - return v.bigUint.Equal(*otherValue.bigUint) + return v.BigUint.Equal(*otherValue.BigUint) case "varInt": - if otherValue.varInt == nil { + if otherValue.VarInt == nil { return false } - return v.varInt.Equal(*otherValue.varInt) + return v.VarInt.Equal(*otherValue.VarInt) case "varUint": - if otherValue.varUint == nil { + if otherValue.VarUint == nil { return false } - return v.varUint.Equal(*otherValue.varUint) + return v.VarUint.Equal(*otherValue.VarUint) case "coins": - if otherValue.coins == nil { + if otherValue.Coins == nil { return false } - return v.coins.Equal(*otherValue.coins) + return v.Coins.Equal(*otherValue.Coins) case "bits": - if otherValue.bits == nil { + if otherValue.Bits == nil { return false } - return v.bits.Equal(*otherValue.bits) + return v.Bits.Equal(*otherValue.Bits) case "cell": - if otherValue.cell == nil { + if otherValue.Cell == nil { return false } - return v.cell.Equal(*otherValue.cell) + return v.Cell.Equal(*otherValue.Cell) case "remaining": - if otherValue.remaining == nil { + if otherValue.Remaining == nil { return false } - return v.remaining.Equal(*otherValue.remaining) + return v.Remaining.Equal(*otherValue.Remaining) case "internalAddress": - if otherValue.internalAddress == nil { + if otherValue.InternalAddress == nil { return false } - return v.internalAddress.Equal(*otherValue.internalAddress) + return v.InternalAddress.Equal(*otherValue.InternalAddress) case "optionalAddress": - if otherValue.optionalAddress == nil { + if otherValue.OptionalAddress == nil { return false } - return v.optionalAddress.Equal(*otherValue.optionalAddress) + return v.OptionalAddress.Equal(*otherValue.OptionalAddress) case "externalAddress": - if otherValue.externalAddress == nil { + if otherValue.ExternalAddress == nil { return false } - return v.externalAddress.Equal(*otherValue.externalAddress) + return v.ExternalAddress.Equal(*otherValue.ExternalAddress) case "anyAddress": - if otherValue.anyAddress == nil { + if otherValue.AnyAddress == nil { return false } - return v.anyAddress.Equal(*otherValue.anyAddress) + return v.AnyAddress.Equal(*otherValue.AnyAddress) case "optionalValue": - if otherValue.optionalValue == nil { + if otherValue.OptionalValue == nil { return false } - return v.optionalValue.Equal(*otherValue.optionalValue) + return v.OptionalValue.Equal(*otherValue.OptionalValue) case "refValue": - if otherValue.refValue == nil { + if otherValue.RefValue == nil { return false } - return v.refValue.Equal(*otherValue.refValue) + return v.RefValue.Equal(*otherValue.RefValue) case "tupleWith": - if otherValue.tupleWith == nil { + if otherValue.TupleWith == nil { return false } - return v.tupleWith.Equal(*otherValue.tupleWith) + return v.TupleWith.Equal(*otherValue.TupleWith) case "tensor": - if otherValue.tensor == nil { + if otherValue.Tensor == nil { return false } - return v.tensor.Equal(*otherValue.tensor) - case "mp": - if otherValue.mp == nil { + return v.Tensor.Equal(*otherValue.Tensor) + case "map": + if otherValue.Map == nil { return false } - return v.mp.Equal(*otherValue.mp) - case "structValue": - if otherValue.structValue == nil { + return v.Map.Equal(*otherValue.Map) + case "struct": + if otherValue.Struct == nil { return false } - return v.structValue.Equal(*otherValue.structValue) + return v.Struct.Equal(*otherValue.Struct) case "alias": - if otherValue.alias == nil { + if otherValue.Alias == nil { return false } - return v.alias.Equal(*otherValue.alias) + return v.Alias.Equal(*otherValue.Alias) case "enum": - if otherValue.enum == nil { + if otherValue.Enum == nil { return false } - return v.enum.Equal(*otherValue.enum) + return v.Enum.Equal(*otherValue.Enum) case "generic": - if otherValue.generic == nil { + if otherValue.Generic == nil { return false } - return v.generic.Equal(*otherValue.generic) + return v.Generic.Equal(*otherValue.Generic) case "union": - if otherValue.union == nil { + if otherValue.Union == nil { return false } - return v.union.Equal(*otherValue.union) + return v.Union.Equal(*otherValue.Union) case "null": - if otherValue.null == nil { + if otherValue.Null == nil { return false } - return v.null.Equal(*otherValue.null) + return v.Null.Equal(*otherValue.Null) case "void": - if otherValue.void == nil { + if otherValue.Void == nil { return false } - return v.void.Equal(*otherValue.void) + return v.Void.Equal(*otherValue.Void) default: return false } } - -type JSONSumType struct { - SumType string `json:"sumType"` -} - -//func (v *Value) UnmarshalJSON(b []byte) error { -// 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) MarshalJSON() ([]byte, error) { - st := JSONSumType{} - var payload []byte - var err error - - switch v.sumType { - case "bool": - st.SumType = "bool" - if v.bool == nil { - return nil, fmt.Errorf("bool value not found") - } - payload, err = json.Marshal(v.bool) - case "smallInt": - st.SumType = "smallInt" - if v.smallInt == nil { - return nil, fmt.Errorf("smallInt value not found") - } - payload, err = json.Marshal(v.smallInt) - case "smallUint": - st.SumType = "smallUint" - if v.smallUint == nil { - return nil, fmt.Errorf("smallUint value not found") - } - payload, err = json.Marshal(v.smallUint) - case "bigInt": - st.SumType = "bigInt" - if v.bigInt == nil { - return nil, fmt.Errorf("bigInt value not found") - } - payload, err = json.Marshal(v.bigInt) - case "bigUint": - st.SumType = "bigUint" - if v.bigUint == nil { - return nil, fmt.Errorf("bigUint value not found") - } - payload, err = json.Marshal(v.bigUint) - case "varInt": - st.SumType = "varInt" - if v.varInt == nil { - return nil, fmt.Errorf("varInt value not found") - } - payload, err = json.Marshal(v.varInt) - case "varUint": - st.SumType = "varUint" - if v.varUint == nil { - return nil, fmt.Errorf("varUint value not found") - } - payload, err = json.Marshal(v.varUint) - case "coins": - st.SumType = "coins" - if v.coins == nil { - return nil, fmt.Errorf("coins value not found") - } - payload, err = json.Marshal(v.coins) - case "bits": - st.SumType = "bits" - if v.bits == nil { - return nil, fmt.Errorf("bits value not found") - } - payload, err = json.Marshal(v.bits) - case "cell": - st.SumType = "cell" - if v.cell == nil { - return nil, fmt.Errorf("cell value not found") - } - payload, err = json.Marshal(v.cell) - case "remaining": - st.SumType = "remaining" - if v.remaining == nil { - return nil, fmt.Errorf("remaining value not found") - } - payload, err = json.Marshal(v.remaining) - case "internalAddress": - st.SumType = "internalAddress" - if v.internalAddress == nil { - return nil, fmt.Errorf("internalAddress value not found") - } - payload, err = json.Marshal(v.internalAddress) - case "optionalAddress": - st.SumType = "optionalAddress" - if v.optionalAddress == nil { - return nil, fmt.Errorf("optionalAddress value not found") - } - payload, err = json.Marshal(v.optionalAddress) - case "externalAddress": - st.SumType = "externalAddress" - if v.externalAddress == nil { - return nil, fmt.Errorf("externalAddress value not found") - } - payload, err = json.Marshal(v.externalAddress) - case "anyAddress": - st.SumType = "anyAddress" - if v.anyAddress == nil { - return nil, fmt.Errorf("anyAddress value not found") - } - payload, err = json.Marshal(v.anyAddress) - case "optionalValue": - st.SumType = "optionalValue" - if v.optionalValue == nil { - return nil, fmt.Errorf("optionalValue value not found") - } - payload, err = json.Marshal(v.optionalValue) - case "refValue": - st.SumType = "refValue" - if v.refValue == nil { - return nil, fmt.Errorf("refValue value not found") - } - payload, err = json.Marshal(v.refValue) - case "tupleWith": - st.SumType = "tuple" - if v.tupleWith == nil { - return nil, fmt.Errorf("tupleWith value not found") - } - payload, err = json.Marshal(v.tupleWith) - case "tensor": - st.SumType = "bool" - if v.tensor == nil { - return nil, fmt.Errorf("tensor value not found") - } - payload, err = json.Marshal(v.tensor) - case "mp": - st.SumType = "map" - if v.mp == nil { - return nil, fmt.Errorf("mp value not found") - } - payload, err = json.Marshal(v.mp) - case "structValue": - st.SumType = "struct" - if v.structValue == nil { - return nil, fmt.Errorf("structValue value not found") - } - payload, err = json.Marshal(v.structValue) - case "alias": - st.SumType = "alias" - if v.alias == nil { - return nil, fmt.Errorf("alias value not found") - } - payload, err = json.Marshal(v.alias) - case "enum": - st.SumType = "enum" - if v.enum == nil { - return nil, fmt.Errorf("enum value not found") - } - payload, err = json.Marshal(v.enum) - case "generic": - st.SumType = "generic" - if v.generic == nil { - return nil, fmt.Errorf("generic value not found") - } - payload, err = json.Marshal(v.generic) - case "union": - st.SumType = "union" - if v.union == nil { - return nil, fmt.Errorf("union value not found") - } - payload, err = json.Marshal(v.union) - case "null": - st.SumType = "null" - if v.null == nil { - return nil, fmt.Errorf("null value not found") - } - payload, err = json.Marshal(v.null) - case "void": - st.SumType = "void" - if v.void == nil { - return nil, fmt.Errorf("void value not found") - } - payload, err = json.Marshal(v.void) - default: - return nil, fmt.Errorf("unknown value type: %s", v.sumType) - } - - prefix, err := json.Marshal(st) - if err != nil { - return nil, err - } - return utils.ConcatPrefixAndSuffixIfExists(prefix, payload), nil -} From b7d0a6f5256ff878f0183b3a189d9f303f74747c Mon Sep 17 00:00:00 2001 From: Pavel Levchenko Date: Thu, 12 Feb 2026 11:21:02 +0300 Subject: [PATCH 07/16] clean up --- abi/messages_test.go | 41 ++--------------------------------------- boc/cell.go | 25 ------------------------- boc/immutable_cell.go | 10 +++++----- tlb/decoder.go | 20 ++++---------------- tlb/primitives.go | 23 ----------------------- tlb/stack.go | 8 -------- 6 files changed, 11 insertions(+), 116 deletions(-) diff --git a/abi/messages_test.go b/abi/messages_test.go index feca10bf..b08fd50f 100644 --- a/abi/messages_test.go +++ b/abi/messages_test.go @@ -43,7 +43,7 @@ func TestEncodeAndDecodeInMsgBody(t *testing.T) { } func TestDecodeAndEncodeUnknownInMsgBody(t *testing.T) { - data := "b5ee9c7201010101005c0000b3178d45190000000000000000a0165ceda7f1e7eda8000801b26778d9535dc370f56d2e34225d4619deb1e0f4080a7bdde114618639d1574b001643971209f95b121f5600b0fd68e03bdb7b0994f0dfdd4a9550a2a3e56e23f382" + data := "b5ee9c720101010100350000650000022800000000000000005012a05f200800c46663fd6592a0ca9ff0f04ed928fe74019bac1756d06092c14464fb3ce8d373" boc1, _ := boc.DeserializeBocHex(data) var x InMsgBody @@ -63,7 +63,7 @@ func TestDecodeAndEncodeUnknownInMsgBody(t *testing.T) { } } -func TestDecodeAndEncodeUnknownInMsgBody1(t *testing.T) { +func TestDecodeAndEncodeHashMap(t *testing.T) { data := "b5ee9c7241010b0100f4000202c8010a0201620209020120030802012004070201580506004327fd889d4ca5a81250b38cfb489c99475bacacb61c512fac81458a37f66e1b10eff400432002aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaac0044d4ff53355555555555555555555555555555555555555555555555555555555555550045bd002c44ea652d4092859c67da44e4ca3add6565b0e2897d640a2c51bfb370d8877fa00045a3cff555555555555555555555555555555555555555555555555555555555555555580045bd5800aa6aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab8a1b898e" boc1, _ := boc.DeserializeBocHex(data) @@ -77,46 +77,9 @@ func TestDecodeAndEncodeUnknownInMsgBody1(t *testing.T) { t.Fatalf("Unable to marshal: %v", err) } - curr1 := boc1[0] - curr2 := boc2 - fmt.Println(equal(*curr1, *curr2)) - hs1, _ := boc1[0].HashString() hs2, _ := boc2.HashString() if hs1 != hs2 { t.Fatalf("got different result") } } - -func equal(curr1 boc.Cell, curr2 boc.Cell) bool { - curr1.ResetCounters() - curr2.ResetCounters() - bits1 := curr1.ReadRemainingBits() - bits2 := curr2.ReadRemainingBits() - if bits1.BinaryString() != bits2.BinaryString() { - //fmt.Println(bits1.BinaryString()) - //fmt.Println(bits2.BinaryString()) - return false - } - - if len(curr1.Refs()) != len(curr2.Refs()) { - fmt.Println(len(curr1.Refs()), len(curr2.Refs())) - return false - } - - for i := range curr1.Refs() { - if !equal(*curr1.Refs()[i], *curr2.Refs()[i]) { - curr1.Refs()[1].ResetCounters() - curr2.Refs()[1].ResetCounters() - bits3 := curr1.Refs()[1].ReadRemainingBits() - bits4 := curr2.Refs()[1].ReadRemainingBits() - if bits3.BitsAvailableForRead() == 269 { - fmt.Println(bits3.BinaryString()) - fmt.Println(bits4.BinaryString()) - } - return false - } - } - - return true -} diff --git a/boc/cell.go b/boc/cell.go index 75f73550..f4ce1e70 100644 --- a/boc/cell.go +++ b/boc/cell.go @@ -107,10 +107,6 @@ func (c *Cell) Hash() ([]byte, error) { return c.hash(map[*Cell]*immutableCell{}) } -func (c *Cell) HashWithLevel(level int) ([]byte, error) { - return c.hashWithLevel(map[*Cell]*immutableCell{}, level) -} - func (c *Cell) Hash256() ([32]byte, error) { b, err := c.hash(map[*Cell]*immutableCell{}) if err != nil { @@ -129,19 +125,6 @@ func (c *Cell) HashString() (string, error) { return hex.EncodeToString(h), nil } -func (c *Cell) HashStringWithLevel(level int) (string, error) { - h, err := c.hashWithLevel(map[*Cell]*immutableCell{}, level) - if err != nil { - return "", err - } - return hex.EncodeToString(h), nil -} - -func (c *Cell) Depth() int { - imc, _ := newImmutableCell(c, make(map[*Cell]*immutableCell)) - return imc.Depth(0) -} - func (c *Cell) hash(cache map[*Cell]*immutableCell) ([]byte, error) { imc, err := newImmutableCell(c, cache) if err != nil { @@ -150,14 +133,6 @@ func (c *Cell) hash(cache map[*Cell]*immutableCell) ([]byte, error) { return imc.Hash(maxLevel), nil } -func (c *Cell) hashWithLevel(cache map[*Cell]*immutableCell, level int) ([]byte, error) { - imc, err := newImmutableCell(c, cache) - if err != nil { - return nil, err - } - return imc.Hash(level), nil -} - func (c *Cell) ToBoc() ([]byte, error) { bag := newBagOfCells() return bag.serializeBoc([]*Cell{c}, false, false, false, 0) diff --git a/boc/immutable_cell.go b/boc/immutable_cell.go index 5213ea86..ca7b49ad 100644 --- a/boc/immutable_cell.go +++ b/boc/immutable_cell.go @@ -137,11 +137,11 @@ func newImmutableCell(c *Cell, cache map[*Cell]*immutableCell) (*immutableCell, func (ic *immutableCell) Hash(level int) []byte { index := ic.mask.Apply(level).HashIndex() if ic.cellType == PrunedBranchCell { - //offset := ic.mask.HashIndex() - //if index != offset { - return ic.bitsBuf[2+(index)*32 : 2+(index+1)*32] - //} - //index = 0 + offset := ic.mask.HashIndex() + if index != offset { + return ic.bitsBuf[2+(index)*32 : 2+(index+1)*32] + } + index = 0 } return ic.hashes[index] } diff --git a/tlb/decoder.go b/tlb/decoder.go index 5d460009..09fecf00 100644 --- a/tlb/decoder.go +++ b/tlb/decoder.go @@ -9,15 +9,12 @@ 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 - contractInterfaces []ContractInterface + hasher *boc.Hasher + withDebug bool + debugPath []string + resolveLib resolveLib } func (d *Decoder) WithDebug() *Decoder { @@ -31,11 +28,6 @@ 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{ @@ -48,10 +40,6 @@ 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/primitives.go b/tlb/primitives.go index 0cdd51cd..7a5c5db6 100644 --- a/tlb/primitives.go +++ b/tlb/primitives.go @@ -15,10 +15,6 @@ type SumType string type Magic uint32 -type Void struct{} - -type NullLiteral = Void - type Maybe[T any] struct { Exists bool Value T @@ -101,25 +97,6 @@ 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 14c644f5..86987952 100644 --- a/tlb/stack.go +++ b/tlb/stack.go @@ -621,14 +621,6 @@ 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() From e5ae9942bf9983f7c8a0357464343c690c4a324e Mon Sep 17 00:00:00 2001 From: Pavel Levchenko Date: Sun, 15 Feb 2026 12:35:37 +0300 Subject: [PATCH 08/16] refactoring --- tolk/addresses.go | 144 +++--- tolk/cells.go | 54 ++- tolk/integers.go | 110 +++-- tolk/map.go | 239 +++++----- tolk/refs.go | 112 ++--- tolk/runtime.go | 6 +- tolk/runtime_test.go | 969 +++++----------------------------------- tolk/tuples.go | 10 +- tolk/union.go | 27 +- tolk/utils.go | 45 +- tolk/value.go | 715 +++++++++++++---------------- utils/generator_test.go | 4 + utils/json.go | 3 + 13 files changed, 830 insertions(+), 1608 deletions(-) diff --git a/tolk/addresses.go b/tolk/addresses.go index 0472f74c..e033d7a1 100644 --- a/tolk/addresses.go +++ b/tolk/addresses.go @@ -20,15 +20,15 @@ type InternalAddress struct { func (i *InternalAddress) Unmarshal(cell *boc.Cell, ty tolkParser.Address, decoder *Decoder) error { err := cell.Skip(3) // skip addr type ($10) and anycast (0) if err != nil { - return err + return fmt.Errorf("failed to skip internal address type and anycast: %w", err) } workchain, err := cell.ReadInt(8) if err != nil { - return err + return fmt.Errorf("failed to read internal address workchain: %w", err) } address, err := cell.ReadBytes(32) if err != nil { - return err + return fmt.Errorf("failed to read internal address hash: %w", err) } *i = InternalAddress{ Workchain: int8(workchain), @@ -40,15 +40,15 @@ func (i *InternalAddress) Unmarshal(cell *boc.Cell, ty tolkParser.Address, decod func (i *InternalAddress) Marshal(cell *boc.Cell, ty tolkParser.Address, encoder *Encoder) error { err := cell.WriteUint(0b100, 3) // internal addr type ($10) and anycast (0) if err != nil { - return err + return fmt.Errorf("failed to write internal address type and anycast: %w", err) } err = cell.WriteInt(int64(i.Workchain), 8) if err != nil { - return err + return fmt.Errorf("failed to write internal address workchain: %w", err) } err = cell.WriteBytes(i.Address[:]) if err != nil { - return err + return fmt.Errorf("failed to write internal address hash: %w", err) } return nil } @@ -70,17 +70,20 @@ func (i *InternalAddress) MarshalJSON() ([]byte, error) { } func (i *InternalAddress) UnmarshalJSON(b []byte) error { + if len(b) < 2 { + return fmt.Errorf("invalid internal address format: %s", string(b)) + } addr := strings.Split(string(b[1:len(b)-1]), ":") if len(addr) != 2 { - return fmt.Errorf("invalid address") + return fmt.Errorf("invalid internal address format: %s", string(b)) } workchain, err := strconv.ParseInt(addr[0], 10, 32) if err != nil { - return err + return fmt.Errorf("failed to parse internal address workchain: %w", err) } hexAddr, err := hex.DecodeString(addr[1]) if err != nil { - return err + return fmt.Errorf("failed to parse internal address hash: %w", err) } i.Workchain = int8(workchain) i.Address = [32]byte(hexAddr) @@ -93,7 +96,7 @@ type NoneAddress struct { func (n *NoneAddress) Unmarshal(cell *boc.Cell, ty tolkParser.AddressOpt, decoder *Decoder) error { _, err := cell.ReadUint(2) if err != nil { - return err + return fmt.Errorf("failed to read none address type: %w", err) } return nil @@ -102,7 +105,7 @@ func (n *NoneAddress) Unmarshal(cell *boc.Cell, ty tolkParser.AddressOpt, decode func (n *NoneAddress) Marshal(cell *boc.Cell, ty tolkParser.AddressOpt, encoder *Encoder) error { err := cell.WriteUint(0, 2) // none addr type ($00) if err != nil { - return err + return fmt.Errorf("failed to write none address type: %w", err) } return nil } @@ -131,26 +134,42 @@ func (o *OptionalAddress) Unmarshal(cell *boc.Cell, ty tolkParser.AddressOpt, de copyCell := cell.CopyRemaining() tag, err := copyCell.ReadUint(2) if err != nil { - return err + return fmt.Errorf("failed to read optional address type: %w", err) } if tag == 0 { o.SumType = "NoneAddress" o.NoneAddress = &NoneAddress{} - return o.NoneAddress.Unmarshal(cell, ty, decoder) + err = o.NoneAddress.Unmarshal(cell, ty, decoder) + if err != nil { + return fmt.Errorf("failed to unmarshal optional address: %w", err) + } + return err } o.SumType = "InternalAddress" o.InternalAddress = &InternalAddress{} - return o.InternalAddress.Unmarshal(cell, tolkParser.Address{}, decoder) + err = o.InternalAddress.Unmarshal(cell, tolkParser.Address{}, decoder) + if err != nil { + return fmt.Errorf("failed to unmarshal optional address: %w", err) + } + return nil } func (o *OptionalAddress) Marshal(cell *boc.Cell, ty tolkParser.AddressOpt, encoder *Encoder) error { if o.SumType == "NoneAddress" { - return o.NoneAddress.Marshal(cell, ty, encoder) + err := o.NoneAddress.Marshal(cell, ty, encoder) + if err != nil { + return fmt.Errorf("failed to marshal optional address: %w", err) + } + return nil } else if o.SumType == "InternalAddress" { - return o.InternalAddress.Marshal(cell, tolkParser.Address{}, encoder) + err := o.InternalAddress.Marshal(cell, tolkParser.Address{}, encoder) + if err != nil { + return fmt.Errorf("failed to marshal optional address: %w", err) + } + return nil } - return fmt.Errorf("unknown any address SumType: %v", o.SumType) + return fmt.Errorf("unknown optional address SumType: %v", o.SumType) } func (o *OptionalAddress) MarshalJSON() ([]byte, error) { @@ -164,25 +183,31 @@ func (o *OptionalAddress) MarshalJSON() ([]byte, error) { } else if o.SumType == "InternalAddress" { optinalAddress.SumType = "internalAddress" optinalAddress.InternalAddress = o.InternalAddress + } else { + return nil, fmt.Errorf("unknown optional address SumType: %v", o.SumType) + } + data, err := json.Marshal(optinalAddress) + if err != nil { + return nil, fmt.Errorf("failed to marshal optional address: %w", err) } - return json.Marshal(optinalAddress) + return data, nil } func (o *OptionalAddress) UnmarshalJSON(b []byte) error { - var optinalAddress = struct { + var optionalAddress = struct { SumType SumType `json:"sumType"` InternalAddress *InternalAddress `json:"internalAddress,omitempty"` }{} - if err := json.Unmarshal(b, &optinalAddress); err != nil { - return err + if err := json.Unmarshal(b, &optionalAddress); err != nil { + return fmt.Errorf("failed to unmarshal optional address: %w", err) } - if optinalAddress.SumType == "noneAddress" { + if optionalAddress.SumType == "noneAddress" { o.SumType = "NoneAddress" o.NoneAddress = &NoneAddress{} - } else if optinalAddress.SumType == "internalAddress" { + } else if optionalAddress.SumType == "internalAddress" { o.SumType = "InternalAddress" - o.InternalAddress = optinalAddress.InternalAddress + o.InternalAddress = optionalAddress.InternalAddress } else { return fmt.Errorf("unknown optional address SumType: %v", o.SumType) } @@ -197,15 +222,15 @@ type ExternalAddress struct { func (e *ExternalAddress) Unmarshal(cell *boc.Cell, ty tolkParser.AddressExt, decoder *Decoder) error { err := cell.Skip(2) if err != nil { - return err + return fmt.Errorf("failed to skip external address type: %w", err) } ln, err := cell.ReadUint(9) if err != nil { - return err + return fmt.Errorf("failed to read external address length: %w", err) } bs, err := cell.ReadBits(int(ln)) if err != nil { - return err + return fmt.Errorf("failed to read external address bytes: %w", err) } *e = ExternalAddress{ Len: int16(ln), @@ -218,15 +243,15 @@ func (e *ExternalAddress) Unmarshal(cell *boc.Cell, ty tolkParser.AddressExt, de func (e *ExternalAddress) Marshal(cell *boc.Cell, ty tolkParser.AddressExt, encoder *Encoder) error { err := cell.WriteUint(1, 2) // external addr type ($01) if err != nil { - return err + return fmt.Errorf("failed to write external address type: %w", err) } err = cell.WriteUint(uint64(e.Len), 9) if err != nil { - return err + return fmt.Errorf("failed to write external address length: %w", err) } err = cell.WriteBitString(e.Address) if err != nil { - return err + return fmt.Errorf("failed to write external address bytes: %w", err) } return nil } @@ -269,40 +294,48 @@ func (a *AnyAddress) Unmarshal(cell *boc.Cell, ty tolkParser.AddressAny, decoder copyCell := cell.CopyRemaining() tag, err := copyCell.ReadUint(2) if err != nil { - return err + return fmt.Errorf("failed to read any address type: %w", err) } switch tag { case 0: a.SumType = "NoneAddress" a.NoneAddress = &NoneAddress{} - return a.NoneAddress.Unmarshal(cell, tolkParser.AddressOpt{}, decoder) + err = a.NoneAddress.Unmarshal(cell, tolkParser.AddressOpt{}, decoder) case 1: a.SumType = "ExternalAddress" a.ExternalAddress = &ExternalAddress{} - return a.ExternalAddress.Unmarshal(cell, tolkParser.AddressExt{}, decoder) + err = a.ExternalAddress.Unmarshal(cell, tolkParser.AddressExt{}, decoder) case 2: a.SumType = "InternalAddress" a.InternalAddress = &InternalAddress{} - return a.InternalAddress.Unmarshal(cell, tolkParser.Address{}, decoder) + err = a.InternalAddress.Unmarshal(cell, tolkParser.Address{}, decoder) case 3: a.SumType = "VarAddress" a.VarAddress = &VarAddress{} - return a.VarAddress.Unmarshal(cell, tolkParser.AddressExt{}, decoder) + err = a.VarAddress.Unmarshal(cell, tolkParser.AddressExt{}, decoder) + } + if err != nil { + return fmt.Errorf("failed to unmarshal any address: %w", err) } - return nil } func (a *AnyAddress) Marshal(cell *boc.Cell, ty tolkParser.AddressAny, encoder *Encoder) error { + var err error switch a.SumType { case "NoneAddress": - return a.NoneAddress.Marshal(cell, tolkParser.AddressOpt{}, encoder) + err = a.NoneAddress.Marshal(cell, tolkParser.AddressOpt{}, encoder) case "InternalAddress": - return a.InternalAddress.Marshal(cell, tolkParser.Address{}, encoder) + err = a.InternalAddress.Marshal(cell, tolkParser.Address{}, encoder) case "ExternalAddress": - return a.ExternalAddress.Marshal(cell, tolkParser.AddressExt{}, encoder) + err = a.ExternalAddress.Marshal(cell, tolkParser.AddressExt{}, encoder) case "VarAddress": - return a.VarAddress.Marshal(cell, tolkParser.AddressAny{}, encoder) + err = a.VarAddress.Marshal(cell, tolkParser.AddressAny{}, encoder) + default: + return fmt.Errorf("unknown any address SumType: %v", a.SumType) + } + if err != nil { + return fmt.Errorf("failed to marshal any address: %w", err) } return nil @@ -351,7 +384,11 @@ func (a *AnyAddress) MarshalJSON() ([]byte, error) { default: return nil, fmt.Errorf("unknown any address SumType: %v", a.SumType) } - return json.Marshal(&jsonAnyAddress) + data, err := json.Marshal(jsonAnyAddress) + if err != nil { + return nil, fmt.Errorf("failed to marshal any address: %w", err) + } + return data, nil } func (a *AnyAddress) UnmarshalJSON(b []byte) error { @@ -362,7 +399,7 @@ func (a *AnyAddress) UnmarshalJSON(b []byte) error { VarAddress *VarAddress `json:"varAddress,omitempty"` }{} if err := json.Unmarshal(b, &anyAddress); err != nil { - return err + return fmt.Errorf("failed to unmarshal any address: %w", err) } switch anyAddress.SumType { case "noneAddress": @@ -406,19 +443,19 @@ func (va *VarAddress) Equal(other any) bool { func (va *VarAddress) Unmarshal(cell *boc.Cell, ty tolkParser.AddressExt, decoder *Decoder) error { err := cell.Skip(3) // skip var type ($11) and anycast (0) if err != nil { - return err + return fmt.Errorf("failed to skip var address type and anycast: %w", err) } ln, err := cell.ReadUint(9) if err != nil { - return err + return fmt.Errorf("failed to read var address length: %w", err) } workchain, err := cell.ReadInt(32) if err != nil { - return err + return fmt.Errorf("failed to read var address workchain: %w", err) } bs, err := cell.ReadBits(int(ln)) if err != nil { - return err + return fmt.Errorf("failed to read var address bytes: %w", err) } *va = VarAddress{ Len: int16(ln), @@ -432,19 +469,19 @@ func (va *VarAddress) Unmarshal(cell *boc.Cell, ty tolkParser.AddressExt, decode func (va *VarAddress) Marshal(cell *boc.Cell, ty tolkParser.AddressAny, encoder *Encoder) error { err := cell.WriteUint(0b110, 3) // var addr type ($11) and anycast (0) if err != nil { - return err + return fmt.Errorf("failed to write var address type and anycast: %w", err) } err = cell.WriteUint(uint64(va.Len), 9) if err != nil { - return err + return fmt.Errorf("failed to write var address length: %w", err) } err = cell.WriteInt(int64(va.Workchain), 32) if err != nil { - return err + return fmt.Errorf("failed to write var address workchain: %w", err) } err = cell.WriteBitString(va.Address) if err != nil { - return err + return fmt.Errorf("failed to write var address bytes: %w", err) } return nil } @@ -454,17 +491,20 @@ func (va *VarAddress) MarshalJSON() ([]byte, error) { } func (va *VarAddress) UnmarshalJSON(b []byte) error { + if len(b) < 2 { + return fmt.Errorf("invalid var address format: %v", string(b)) + } parts := bytes.Split(b[1:len(b)-1], []byte(":")) if len(parts) != 2 { return fmt.Errorf("invalid var address format: %v", string(b)) } workchain, err := strconv.ParseInt(string(parts[0]), 10, 32) if err != nil { - return err + return fmt.Errorf("failed to parse var address workchain: %w", err) } bs, err := boc.BitStringFromFiftHex(string(parts[1])) if err != nil { - return err + return fmt.Errorf("failed to parse var address bytes: %w", err) } va.Workchain = int32(workchain) va.Len = int16(bs.BitsAvailableForRead()) diff --git a/tolk/cells.go b/tolk/cells.go index 6d7b4147..0e30177a 100644 --- a/tolk/cells.go +++ b/tolk/cells.go @@ -2,6 +2,7 @@ package tolk import ( "encoding/json" + "fmt" "github.com/tonkeeper/tongo/boc" "github.com/tonkeeper/tongo/tolk/parser" @@ -12,7 +13,7 @@ type Any boc.Cell func (a *Any) Unmarshal(cell *boc.Cell, ty tolkParser.Cell, decoder *Decoder) error { ref, err := cell.NextRef() if err != nil { - return err + return fmt.Errorf("failed to get next ref: %w", err) } *a = Any(*ref) @@ -24,7 +25,7 @@ func (a *Any) Marshal(cell *boc.Cell, ty tolkParser.Cell, encoder *Encoder) erro ref := c.CopyRemaining() err := cell.AddRef(ref) if err != nil { - return err + return fmt.Errorf("failed to add ref: %w", err) } return nil @@ -49,13 +50,17 @@ func (a *Any) Equal(o any) bool { } func (a *Any) MarshalJSON() ([]byte, error) { - return boc.Cell(*a).MarshalJSON() + data, err := boc.Cell(*a).MarshalJSON() + if err != nil { + return nil, fmt.Errorf("failed to marshal any: %w", err) + } + return data, nil } func (a *Any) UnmarshalJSON(b []byte) error { v := &boc.Cell{} if err := json.Unmarshal(b, v); err != nil { - return err + return fmt.Errorf("failed to unmarshal ref: %w", err) } *a = Any(*v) return nil @@ -75,12 +80,12 @@ func (r *RemainingValue) Marshal(cell *boc.Cell, ty tolkParser.Remaining, encode c := boc.Cell(*r) err := cell.WriteBitString(c.ReadRemainingBits()) if err != nil { - return err + return fmt.Errorf("failed to write remaining bits: %w", err) } - for _, ref := range c.Refs() { + for i, ref := range c.Refs() { err = cell.AddRef(ref) if err != nil { - return err + return fmt.Errorf("failed to add %v remaining ref: %w", i, err) } } @@ -106,13 +111,17 @@ func (r *RemainingValue) Equal(o any) bool { } func (r *RemainingValue) MarshalJSON() ([]byte, error) { - return boc.Cell(*r).MarshalJSON() + data, err := boc.Cell(*r).MarshalJSON() + if err != nil { + return nil, fmt.Errorf("failed to marshal remainings: %w", err) + } + return data, nil } func (r *RemainingValue) UnmarshalJSON(b []byte) error { v := &boc.Cell{} if err := json.Unmarshal(b, v); err != nil { - return err + return fmt.Errorf("failed to unmarshal remainigs: %w", err) } *r = RemainingValue(*v) return nil @@ -126,13 +135,13 @@ type OptValue struct { func (o *OptValue) Unmarshal(cell *boc.Cell, ty tolkParser.Nullable, decoder *Decoder) error { isExists, err := cell.ReadBit() if err != nil { - return err + return fmt.Errorf("failed to read optinal value existance bit: %w", err) } o.IsExists = isExists if isExists { err = o.Val.Unmarshal(cell, ty.Inner, decoder) if err != nil { - return err + return fmt.Errorf("failed to unmarshal optinal value: %w", err) } } return nil @@ -141,10 +150,13 @@ func (o *OptValue) Unmarshal(cell *boc.Cell, ty tolkParser.Nullable, decoder *De func (o *OptValue) Marshal(cell *boc.Cell, ty tolkParser.Nullable, encoder *Encoder) error { err := cell.WriteBit(o.IsExists) if err != nil { - return err + return fmt.Errorf("failed to write optinal value existance bit: %w", err) } if o.IsExists { - return o.Val.Marshal(cell, ty.Inner, encoder) + err = o.Val.Marshal(cell, ty.Inner, encoder) + if err != nil { + return fmt.Errorf("failed to marshal optinal value: %w", err) + } } return nil @@ -175,7 +187,11 @@ func (o *OptValue) MarshalJSON() ([]byte, error) { jsonOptValue.Val = &o.Val } - return json.Marshal(jsonOptValue) + data, err := json.Marshal(jsonOptValue) + if err != nil { + return nil, fmt.Errorf("failed to marshal optinal value: %w", err) + } + return data, nil } func (o *OptValue) UnmarshalJSON(b []byte) error { @@ -184,7 +200,7 @@ func (o *OptValue) UnmarshalJSON(b []byte) error { Val *Value `json:"value,omitempty"` }{} if err := json.Unmarshal(b, &jsonOptValue); err != nil { - return err + return fmt.Errorf("failed to unmarshal optinal value: %w", err) } o.IsExists = jsonOptValue.IsExists if o.IsExists { @@ -199,12 +215,12 @@ type RefValue Value func (r *RefValue) Unmarshal(cell *boc.Cell, ty tolkParser.CellOf, decoder *Decoder) error { ref, err := cell.NextRef() if err != nil { - return err + return fmt.Errorf("failed to get next ref: %w", err) } innerV := Value{} err = innerV.Unmarshal(ref, ty.Inner, decoder) if err != nil { - return err + return fmt.Errorf("failed to unmarshal ref: %w", err) } *r = RefValue(innerV) @@ -216,11 +232,11 @@ func (r *RefValue) Marshal(cell *boc.Cell, ty tolkParser.CellOf, encoder *Encode ref := boc.NewCell() err := val.Marshal(ref, ty.Inner, encoder) if err != nil { - return err + return fmt.Errorf("failed to marshal ref: %w", err) } err = cell.AddRef(ref) if err != nil { - return err + return fmt.Errorf("failed to add ref: %w", err) } return nil diff --git a/tolk/integers.go b/tolk/integers.go index adb00916..992172b2 100644 --- a/tolk/integers.go +++ b/tolk/integers.go @@ -15,14 +15,18 @@ type Int64 int64 func (i *Int64) Unmarshal(cell *boc.Cell, ty tolkParser.IntN, decoder *Decoder) error { num, err := cell.ReadInt(ty.N) if err != nil { - return err + return fmt.Errorf("failed to read %v-bit integer: %w", ty.N, err) } *i = Int64(num) return nil } func (i *Int64) Marshal(cell *boc.Cell, ty tolkParser.IntN, encoder *Encoder) error { - return cell.WriteInt(int64(*i), ty.N) + err := cell.WriteInt(int64(*i), ty.N) + if err != nil { + return fmt.Errorf("failed to write %v-bit integer: %w", ty.N, err) + } + return nil } func (i *Int64) Equal(other any) bool { @@ -38,7 +42,7 @@ type BigInt big.Int func (b *BigInt) Unmarshal(cell *boc.Cell, ty tolkParser.IntN, decoder *Decoder) error { num, err := cell.ReadBigInt(ty.N) if err != nil { - return err + return fmt.Errorf("failed to read %v-bit big integer: %w", ty.N, err) } *b = BigInt(*num) return nil @@ -46,7 +50,11 @@ func (b *BigInt) Unmarshal(cell *boc.Cell, ty tolkParser.IntN, decoder *Decoder) func (b *BigInt) Marshal(cell *boc.Cell, ty tolkParser.IntN, encoder *Encoder) error { bi := big.Int(*b) - return cell.WriteBigInt(&bi, ty.N) + err := cell.WriteBigInt(&bi, ty.N) + if err != nil { + return fmt.Errorf("failed to write %v-bit big integer: %w", ty.N, err) + } + return nil } func (b *BigInt) Equal(other any) bool { @@ -65,9 +73,12 @@ func (b *BigInt) MarshalJSON() ([]byte, error) { } func (b *BigInt) UnmarshalJSON(bytes []byte) error { + if len(bytes) < 2 { + return fmt.Errorf("invalid big int format: %s", string(bytes)) + } bi, ok := new(big.Int).SetString(string(bytes[1:len(bytes)-1]), 10) if !ok { - return fmt.Errorf("failed to unmarshal big.Int from %v", string(bytes[1:len(bytes)-1])) + return fmt.Errorf("failed to parse big integer from %v", string(bytes[1:len(bytes)-1])) } *b = BigInt(*bi) return nil @@ -78,14 +89,18 @@ type UInt64 uint64 func (i *UInt64) Unmarshal(cell *boc.Cell, ty tolkParser.UintN, decoder *Decoder) error { num, err := cell.ReadUint(ty.N) if err != nil { - return err + return fmt.Errorf("failed to read %v-bit unsigned integer: %w", ty.N, err) } *i = UInt64(num) return nil } func (i *UInt64) Marshal(cell *boc.Cell, ty tolkParser.UintN, encoder *Encoder) error { - return cell.WriteUint(uint64(*i), ty.N) + err := cell.WriteUint(uint64(*i), ty.N) + if err != nil { + return fmt.Errorf("failed to write %v-bit unsigned integer: %w", ty.N, err) + } + return nil } func (i *UInt64) Equal(other any) bool { @@ -101,7 +116,7 @@ type BigUInt big.Int func (b *BigUInt) Unmarshal(cell *boc.Cell, ty tolkParser.UintN, decoder *Decoder) error { num, err := cell.ReadBigUint(ty.N) if err != nil { - return err + return fmt.Errorf("failed to read %v-bit usigned big integer: %w", ty.N, err) } *b = BigUInt(*num) return nil @@ -109,7 +124,11 @@ func (b *BigUInt) Unmarshal(cell *boc.Cell, ty tolkParser.UintN, decoder *Decode func (b *BigUInt) Marshal(cell *boc.Cell, ty tolkParser.UintN, encoder *Encoder) error { bi := big.Int(*b) - return cell.WriteBigUint(&bi, ty.N) + err := cell.WriteBigUint(&bi, ty.N) + if err != nil { + return fmt.Errorf("failed to write %v-bit usigned big integer: %w", ty.N, err) + } + return nil } func (b *BigUInt) Equal(other any) bool { @@ -128,9 +147,12 @@ func (b *BigUInt) MarshalJSON() ([]byte, error) { } func (b *BigUInt) UnmarshalJSON(bytes []byte) error { + if len(bytes) < 2 { + return fmt.Errorf("invalid usigned big int format: %s", string(bytes)) + } bi, ok := new(big.Int).SetString(string(bytes[1:len(bytes)-1]), 10) if !ok { - return fmt.Errorf("failed to unmarshal big.Int from %v", string(bytes[1:len(bytes)-1])) + return fmt.Errorf("failed to parse usigned big interger from %v", string(bytes[1:len(bytes)-1])) } *b = BigUInt(*bi) return nil @@ -141,11 +163,11 @@ type VarInt big.Int func (vi *VarInt) Unmarshal(cell *boc.Cell, ty tolkParser.VarIntN, decoder *Decoder) error { ln, err := cell.ReadLimUint(ty.N - 1) if err != nil { - return err + return fmt.Errorf("failed to read var integer length: %w", err) } val, err := cell.ReadBigInt(int(ln) * 8) if err != nil { - return err + return fmt.Errorf("failed to read var integer value: %w", err) } *vi = VarInt(*val) return nil @@ -156,11 +178,11 @@ func (vi *VarInt) Marshal(cell *boc.Cell, ty tolkParser.VarIntN, encoder *Encode num := bi.Bytes() err := cell.WriteLimUint(len(num), ty.N-1) if err != nil { - return err + return fmt.Errorf("failed to write var integer length: %w", err) } err = cell.WriteBigInt(&bi, len(num)*8) if err != nil { - return err + return fmt.Errorf("failed to write var integer value: %w", err) } return nil @@ -182,9 +204,12 @@ func (vi *VarInt) MarshalJSON() ([]byte, error) { } func (vi *VarInt) UnmarshalJSON(bytes []byte) error { + if len(bytes) < 2 { + return fmt.Errorf("invalid var integer format: %s", string(bytes)) + } bi, ok := new(big.Int).SetString(string(bytes[1:len(bytes)-1]), 10) if !ok { - return fmt.Errorf("failed to unmarshal big.Int from %v", string(bytes[1:len(bytes)-1])) + return fmt.Errorf("failed to parse var integer from %v", string(bytes[1:len(bytes)-1])) } *vi = VarInt(*bi) return nil @@ -195,11 +220,11 @@ type VarUInt big.Int func (vu *VarUInt) Unmarshal(cell *boc.Cell, ty tolkParser.VarUintN, decoder *Decoder) error { ln, err := cell.ReadLimUint(ty.N - 1) if err != nil { - return err + return fmt.Errorf("failed to read usigned var integer length: %w", err) } val, err := cell.ReadBigInt(int(ln) * 8) if err != nil { - return err + return fmt.Errorf("failed to read usigned var integer value: %w", err) } *vu = VarUInt(*val) return nil @@ -210,11 +235,11 @@ func (vu *VarUInt) Marshal(cell *boc.Cell, ty tolkParser.VarUintN, encoder *Enco num := bi.Bytes() err := cell.WriteLimUint(len(num), ty.N-1) if err != nil { - return err + return fmt.Errorf("failed to write usigned var integer length: %w", err) } err = cell.WriteBytes(num) if err != nil { - return err + return fmt.Errorf("failed to write usigned var integer value: %w", err) } return nil @@ -236,9 +261,12 @@ func (vu *VarUInt) MarshalJSON() ([]byte, error) { } func (vu *VarUInt) UnmarshalJSON(bytes []byte) error { + if len(bytes) < 2 { + return fmt.Errorf("invalid var integer format: %s", string(bytes)) + } bi, ok := new(big.Int).SetString(string(bytes[1:len(bytes)-1]), 10) if !ok { - return fmt.Errorf("failed to unmarshal big.Int from %v", string(bytes[1:len(bytes)-1])) + return fmt.Errorf("failed to parse usigned var integer from %v", string(bytes[1:len(bytes)-1])) } *vu = VarUInt(*bi) return nil @@ -249,7 +277,7 @@ type Bits boc.BitString func (b *Bits) Unmarshal(cell *boc.Cell, ty tolkParser.BitsN, decoder *Decoder) error { val, err := cell.ReadBits(ty.N) if err != nil { - return err + return fmt.Errorf("failed to read bits value: %w", err) } *b = Bits(val) return nil @@ -259,7 +287,7 @@ func (b *Bits) Marshal(cell *boc.Cell, ty tolkParser.BitsN, encoder *Encoder) er bi := boc.BitString(*b) err := cell.WriteBitString(bi) if err != nil { - return err + return fmt.Errorf("failed to write bits value: %w", err) } return nil @@ -276,13 +304,17 @@ func (b *Bits) Equal(other any) bool { } func (b *Bits) MarshalJSON() ([]byte, error) { - return boc.BitString(*b).MarshalJSON() + data, err := boc.BitString(*b).MarshalJSON() + if err != nil { + return nil, fmt.Errorf("failed to marshal bits value: %w", err) + } + return data, nil } func (b *Bits) UnmarshalJSON(bytes []byte) error { bs := boc.BitString{} if err := json.Unmarshal(bytes, &bs); err != nil { - return err + return fmt.Errorf("failed to unmarshal bits value: %w", err) } *b = Bits(bs) return nil @@ -291,21 +323,21 @@ func (b *Bits) UnmarshalJSON(bytes []byte) error { type CoinsValue big.Int func (c *CoinsValue) Unmarshal(cell *boc.Cell, ty tolkParser.Coins, decoder *Decoder) error { - ln, err := cell.ReadLimUint(15) - if err != nil { - return err + varUint := VarUInt{} + if err := varUint.Unmarshal(cell, tolkParser.VarUintN{N: 16}, decoder); err != nil { + return fmt.Errorf("failed to unmarshal coins value: %w", err) } - val, err := cell.ReadBigUint(int(ln) * 8) - if err != nil { - return err - } - *c = CoinsValue(*val) + *c = CoinsValue(varUint) return nil } func (c *CoinsValue) Marshal(cell *boc.Cell, ty tolkParser.Coins, encoder *Encoder) error { - varInt := VarUInt(*c) - return varInt.Marshal(cell, tolkParser.VarUintN{N: 16}, encoder) // coins is actually varint16 + varUint := VarUInt(*c) + err := varUint.Marshal(cell, tolkParser.VarUintN{N: 16}, encoder) // coins is actually varuint16 + if err != nil { + return fmt.Errorf("failed to marshal coins value: %w", err) + } + return nil } func (c *CoinsValue) Equal(other any) bool { @@ -324,9 +356,12 @@ func (c *CoinsValue) MarshalJSON() ([]byte, error) { } func (c *CoinsValue) UnmarshalJSON(bytes []byte) error { + if len(bytes) < 2 { + return fmt.Errorf("invalid coins format: %s", string(bytes)) + } bi, ok := new(big.Int).SetString(string(bytes[1:len(bytes)-1]), 10) if !ok { - return fmt.Errorf("failed to unmarshal big.Int from %v", string(bytes[1:len(bytes)-1])) + return fmt.Errorf("failed to parse coins from %v", string(bytes[1:len(bytes)-1])) } *c = CoinsValue(*bi) return nil @@ -345,7 +380,7 @@ func (b *BoolValue) Equal(o any) bool { func (b *BoolValue) Unmarshal(cell *boc.Cell, ty tolkParser.Bool, decoder *Decoder) error { val, err := cell.ReadBit() if err != nil { - return err + return fmt.Errorf("failed to read bool value: %w", err) } *b = BoolValue(val) return nil @@ -354,8 +389,7 @@ func (b *BoolValue) Unmarshal(cell *boc.Cell, ty tolkParser.Bool, decoder *Decod func (b *BoolValue) Marshal(cell *boc.Cell, ty tolkParser.Bool, encoder *Encoder) error { err := cell.WriteBit(bool(*b)) if err != nil { - return err + return fmt.Errorf("failed to write bool value: %w", err) } - return nil } diff --git a/tolk/map.go b/tolk/map.go index 2062be26..7842a173 100644 --- a/tolk/map.go +++ b/tolk/map.go @@ -2,12 +2,14 @@ package tolk import ( "encoding/json" + "errors" "fmt" "math" "strings" "github.com/tonkeeper/tongo/boc" "github.com/tonkeeper/tongo/tolk/parser" + "github.com/tonkeeper/tongo/utils" ) type MapValue struct { @@ -19,7 +21,7 @@ type MapValue struct { func (m *MapValue) Unmarshal(cell *boc.Cell, ty tolkParser.Map, decoder *Decoder) error { keySize, ok := ty.K.GetFixedSize() if !ok { - return fmt.Errorf("%v is not comparable", ty.K.SumType) + return fmt.Errorf("%v type is not comparable", ty.K.SumType) } keyPrefix := boc.NewBitString(keySize) @@ -34,11 +36,11 @@ func (m *MapValue) Unmarshal(cell *boc.Cell, ty tolkParser.Map, decoder *Decoder if isNotEmpty { mpCell, err := cell.NextRef() if err != nil { - return err + return fmt.Errorf("failed to get map's next ref: %w", err) } err = mapInner(keySize, keySize, mpCell, &keyPrefix, ty.K, ty.V, &mp.keys, &mp.values, decoder) if err != nil { - return err + return fmt.Errorf("failed to parse map value: %w", err) } } @@ -64,37 +66,37 @@ func mapInner( } size, keyPrefix, err = loadLabel(leftKeySize, c, keyPrefix) if err != nil { - return err + return fmt.Errorf("failed to load map's label: %w", 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 + return fmt.Errorf("failed to get map's left branch: %w", err) } lp := keyPrefix.Copy() err = lp.WriteBit(false) if err != nil { - return err + return fmt.Errorf("failed to write map's left branch key prefix: %w", err) } err = mapInner(keySize, leftKeySize-(1+size), left, &lp, kt, vt, keys, values, decoder) if err != nil { - return err + return fmt.Errorf("failed to get map's left value: %w", err) } // 1 bit branch right, err := c.NextRef() if err != nil { - return err + return fmt.Errorf("failed to get map's right branch: %w", err) } rp := keyPrefix.Copy() err = rp.WriteBit(true) if err != nil { - return err + return fmt.Errorf("failed to write map's right branch key prefix: %w", err) } err = mapInner(keySize, leftKeySize-(1+size), right, &rp, kt, vt, keys, values, decoder) if err != nil { - return err + return fmt.Errorf("failed to get map's right value: %w", err) } return nil } @@ -102,19 +104,19 @@ func mapInner( v := Value{} err = v.Unmarshal(c, vt, decoder) if err != nil { - return err + return fmt.Errorf("failed to unmarshal map's value: %w", err) } *values = append(*values, v) key, err := keyPrefix.ReadBits(keySize) if err != nil { - return err + return fmt.Errorf("failed to get map's key: %w", err) } k := Value{} cell := boc.NewCellWithBits(key) err = k.Unmarshal(cell, kt, decoder) if err != nil { - return err + return fmt.Errorf("failed to unmarshal map's key: %w", err) } *keys = append(*keys, k) @@ -124,46 +126,46 @@ func mapInner( 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 + return 0, nil, fmt.Errorf("failed to read map's first bit of label's type: %w", err) } // hml_short$0 if !first { // Unary, while 1, add to ln ln, err := c.ReadUnary() if err != nil { - return 0, nil, err + return 0, nil, fmt.Errorf("failed to read map's short label's length: %w", err) } // add bits to key for i := 0; i < int(ln); i++ { bit, err := c.ReadBit() if err != nil { - return 0, nil, err + return 0, nil, fmt.Errorf("failed to read map's short label's %v-bit: %w", i, err) } err = key.WriteBit(bit) if err != nil { - return 0, nil, err + return 0, nil, fmt.Errorf("failed to write map's short label's %v-bit: %w", i, err) } } return int(ln), key, nil } second, err := c.ReadBit() if err != nil { - return 0, nil, err + return 0, nil, fmt.Errorf("failed to read map's second bit of label's type: %w", err) } // hml_long$10 if !second { ln, err := c.ReadLimUint(size) if err != nil { - return 0, nil, err + return 0, nil, fmt.Errorf("failed to read map's long label's length: %w", err) } for i := 0; i < int(ln); i++ { bit, err := c.ReadBit() if err != nil { - return 0, nil, err + return 0, nil, fmt.Errorf("failed to read map's long label's %v-bit: %w", i, err) } err = key.WriteBit(bit) if err != nil { - return 0, nil, err + return 0, nil, fmt.Errorf("failed to write map's long label's %v-bit: %w", i, err) } } return int(ln), key, nil @@ -171,16 +173,16 @@ func loadLabel(size int, c *boc.Cell, key *boc.BitString) (int, *boc.BitString, // hml_same$11 bitType, err := c.ReadBit() if err != nil { - return 0, nil, err + return 0, nil, fmt.Errorf("failed to read map's same label's bit: %w", err) } ln, err := c.ReadLimUint(size) if err != nil { - return 0, nil, err + return 0, nil, fmt.Errorf("failed to read map's same label's length: %w", err) } for i := 0; i < int(ln); i++ { err = key.WriteBit(bitType) if err != nil { - return 0, nil, err + return 0, nil, fmt.Errorf("failed to write map's same label's %v-bit: %w", i, err) } } return int(ln), key, nil @@ -189,7 +191,7 @@ func loadLabel(size int, c *boc.Cell, key *boc.BitString) (int, *boc.BitString, func (m *MapValue) Marshal(cell *boc.Cell, ty tolkParser.Map, encoder *Encoder) error { keySize, ok := ty.K.GetFixedSize() if !ok { - return fmt.Errorf("map key is not a comparable type, got %v", ty.K.SumType) + return fmt.Errorf("%s type is not comparable", ty.K.SumType) } if len(m.keys) != len(m.values) { @@ -199,14 +201,14 @@ func (m *MapValue) Marshal(cell *boc.Cell, ty tolkParser.Map, encoder *Encoder) if len(m.values) == 0 { err := cell.WriteBit(false) if err != nil { - return err + return fmt.Errorf("failed to write map's emptiness bit: %w", err) } return nil } err := cell.WriteBit(true) if err != nil { - return err + return fmt.Errorf("failed to write map's not-emptiness bit: %w", err) } keys := make([]boc.BitString, len(m.keys)) @@ -214,7 +216,7 @@ func (m *MapValue) Marshal(cell *boc.Cell, ty tolkParser.Map, encoder *Encoder) keyCell := boc.NewCell() err = k.Marshal(keyCell, ty.K, encoder) if err != nil { - return err + return fmt.Errorf("failed to marshal map's %v key: %w", i, err) } keys[i] = keyCell.RawBitString() } @@ -222,12 +224,12 @@ func (m *MapValue) Marshal(cell *boc.Cell, ty tolkParser.Map, encoder *Encoder) ref := boc.NewCell() err = encodeMap(ref, keys, m.values, keySize, ty.V, encoder) if err != nil { - return err + return fmt.Errorf("failed to encode map: %w", err) } err = cell.AddRef(ref) if err != nil { - return err + return fmt.Errorf("failed to add map's ref value: %w", err) } return nil @@ -239,20 +241,20 @@ func encodeMap(c *boc.Cell, keys []boc.BitString, values []Value, keySize int, v } label, err := encodeLabel(c, &keys[0], &keys[len(keys)-1], keySize) if err != nil { - return err + return fmt.Errorf("failed to encode map's label: %w", 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 + err = keys[i].Skip(label.BitsAvailableForRead()) // skip common label if err != nil { - return err + return fmt.Errorf("failed to skip map's key common label: %w", err) } isRight, err := keys[i].ReadBit() if err != nil { - return err + return fmt.Errorf("failed to read map's is right bit: %w", err) } if isRight { rightKeys = append(rightKeys, keys[i].ReadRemainingBits()) @@ -264,26 +266,26 @@ func encodeMap(c *boc.Cell, keys []boc.BitString, values []Value, keySize int, v } l, err := c.NewRef() if err != nil { - return err + return fmt.Errorf("failed to create map's left value: %w", err) } err = encodeMap(l, leftKeys, leftValues, keySize, vt, encoder) if err != nil { - return err + return fmt.Errorf("failed to encode map's left value: %w", err) } r, err := c.NewRef() if err != nil { - return err + return fmt.Errorf("failed to create map's right value: %w", err) } err = encodeMap(r, rightKeys, rightValues, keySize, vt, encoder) if err != nil { - return err + return fmt.Errorf("failed to encode map's right value: %w", err) } - return err + return nil } // marshal value err = values[0].Marshal(c, vt, encoder) if err != nil { - return err + return fmt.Errorf("failed to marshal map's values: %w", err) } return nil } @@ -293,22 +295,22 @@ func encodeLabel(c *boc.Cell, keyFirst, keyLast *boc.BitString, keySize int) (bo if keyFirst != keyLast { bitLeft, err := keyFirst.ReadBit() if err != nil { - return boc.BitString{}, err + return boc.BitString{}, fmt.Errorf("failed to read map's first label's bit: %w", err) } for keyFirst.BitsAvailableForRead() > 0 { bitRight, err := keyLast.ReadBit() if err != nil { - return boc.BitString{}, err + return boc.BitString{}, fmt.Errorf("failed to read map's last label's bit: %w", err) } if bitLeft != bitRight { break } if err := label.WriteBit(bitLeft); err != nil { - return boc.BitString{}, err + return boc.BitString{}, fmt.Errorf("failed to write map's label bit: %w", err) } bitLeft, err = keyFirst.ReadBit() if err != nil { - return boc.BitString{}, err + return boc.BitString{}, fmt.Errorf("failed to read map's first label's bit: %w", err) } } } else { @@ -336,7 +338,7 @@ func encodeLabel(c *boc.Cell, keyFirst, keyLast *boc.BitString, keySize int) (bo for label.BitsAvailableForRead() > 0 { bit, err := label.ReadBit() if err != nil { - return boc.BitString{}, err + return boc.BitString{}, fmt.Errorf("failed to read map's label's bit: %w", err) } if bit { isAllZero = false @@ -356,7 +358,7 @@ func encodeLabel(c *boc.Cell, keyFirst, keyLast *boc.BitString, keySize int) (bo err := encodeFunc(c, keySize, label) if err != nil { - return boc.BitString{}, err + return boc.BitString{}, fmt.Errorf("failed to encode map's label: %w", err) } return label, nil } @@ -365,36 +367,32 @@ func encodeShortLabel(c *boc.Cell, keySize int, label boc.BitString) error { //hml_short$0 {m:#} {n:#} len:(Unary ~n) {n <= m} s:(n * Bit) = HmLabel ~n m; err := c.WriteBit(false) if err != nil { - return err + return fmt.Errorf("failed to write map's short label type: %w", err) } err = c.WriteUnary(uint(label.BitsAvailableForRead())) if err != nil { - return err + return fmt.Errorf("failed to write map's short label length: %w", err) } err = c.WriteBitString(label) if err != nil { - return err + return fmt.Errorf("failed to write map's short label value: %w", err) } return nil } func encodeLongLabel(c *boc.Cell, keySize int, label boc.BitString) error { // hml_long$10 {m:#} n:(#<= m) s:(n * Bit) = HmLabel ~n m; - err := c.WriteBit(true) - if err != nil { - return err - } - err = c.WriteBit(false) + err := c.WriteUint(0b10, 2) if err != nil { - return err + return fmt.Errorf("failed to write map's long label type: %w", err) } err = c.WriteLimUint(label.BitsAvailableForRead(), keySize) if err != nil { - return err + return fmt.Errorf("failed to write map's long label length: %w", err) } err = c.WriteBitString(label) if err != nil { - return err + return fmt.Errorf("failed to write map's long label value: %w", err) } return nil } @@ -403,15 +401,15 @@ func encodeSameLabel(c *boc.Cell, keySize int, label boc.BitString) error { //hml_same$11 {m:#} v:Bit n:(#<= m) = HmLabel ~n m; err := c.WriteUint(0b11, 2) if err != nil { - return err + return fmt.Errorf("failed to write map's same label type: %w", err) } err = c.WriteBit(label.BinaryString()[0] == '1') if err != nil { - return err + return fmt.Errorf("failed to write map's same label bit: %w", err) } err = c.WriteLimUint(label.BitsAvailableForRead(), keySize) if err != nil { - return err + return fmt.Errorf("failed to write map's same label length: %w", err) } return nil } @@ -435,9 +433,9 @@ func (m *MapValue) Equal(other any) bool { return true } -func (m *MapValue) Get(key Value) (Value, bool) { +func (m *MapValue) get(key Value) (Value, bool) { for i, k := range m.keys { - if k.Equal(Value(key)) { + if k.Equal(key) { return m.values[i], true } } @@ -450,7 +448,7 @@ func (m *MapValue) GetBySmallInt(v Int64) (Value, bool) { SumType: "smallInt", SmallInt: &v, } - return m.Get(key) + return m.get(key) } func (m *MapValue) GetBySmallUInt(v UInt64) (Value, bool) { @@ -458,7 +456,7 @@ func (m *MapValue) GetBySmallUInt(v UInt64) (Value, bool) { SumType: "smallUint", SmallUint: &v, } - return m.Get(key) + return m.get(key) } func (m *MapValue) GetByBigInt(v BigInt) (Value, bool) { @@ -466,7 +464,7 @@ func (m *MapValue) GetByBigInt(v BigInt) (Value, bool) { SumType: "bigInt", BigInt: &v, } - return m.Get(key) + return m.get(key) } func (m *MapValue) GetByBigUInt(v BigUInt) (Value, bool) { @@ -474,7 +472,7 @@ func (m *MapValue) GetByBigUInt(v BigUInt) (Value, bool) { SumType: "bigUint", BigUint: &v, } - return m.Get(key) + return m.get(key) } func (m *MapValue) GetByBits(v Bits) (Value, bool) { @@ -482,7 +480,7 @@ func (m *MapValue) GetByBits(v Bits) (Value, bool) { SumType: "bits", Bits: &v, } - return m.Get(key) + return m.get(key) } func (m *MapValue) GetByInternalAddress(v InternalAddress) (Value, bool) { @@ -490,18 +488,18 @@ func (m *MapValue) GetByInternalAddress(v InternalAddress) (Value, bool) { SumType: "internalAddress", InternalAddress: &v, } - return m.Get(key) + return m.get(key) } -func (m *MapValue) Set(key Value, value Value) (bool, error) { +func (m *MapValue) set(key Value, value Value) (bool, error) { for i, k := range m.keys { - if k.Equal(Value(key)) { + if k.Equal(key) { m.values[i] = value return true, nil } } - m.keys = append(m.keys, Value(key)) + m.keys = append(m.keys, key) m.values = append(m.values, value) m.len++ return true, nil @@ -512,7 +510,7 @@ func (m *MapValue) SetBySmallInt(k Int64, value Value) (bool, error) { SumType: "smallInt", SmallInt: &k, } - return m.Set(key, value) + return m.set(key, value) } func (m *MapValue) SetBySmallUInt(k UInt64, value Value) (bool, error) { @@ -520,7 +518,7 @@ func (m *MapValue) SetBySmallUInt(k UInt64, value Value) (bool, error) { SumType: "smallUint", SmallUint: &k, } - return m.Set(key, value) + return m.set(key, value) } func (m *MapValue) SetByBigInt(k BigInt, value Value) (bool, error) { @@ -528,7 +526,7 @@ func (m *MapValue) SetByBigInt(k BigInt, value Value) (bool, error) { SumType: "bigInt", BigInt: &k, } - return m.Set(key, value) + return m.set(key, value) } func (m *MapValue) SetByBigUInt(k BigUInt, value Value) (bool, error) { @@ -536,7 +534,7 @@ func (m *MapValue) SetByBigUInt(k BigUInt, value Value) (bool, error) { SumType: "bigUint", BigUint: &k, } - return m.Set(key, value) + return m.set(key, value) } func (m *MapValue) SetByBits(k Bits, value Value) (bool, error) { @@ -544,7 +542,7 @@ func (m *MapValue) SetByBits(k Bits, value Value) (bool, error) { SumType: "bits", Bits: &k, } - return m.Set(key, value) + return m.set(key, value) } func (m *MapValue) SetByInternalAddress(k InternalAddress, value Value) (bool, error) { @@ -552,12 +550,12 @@ func (m *MapValue) SetByInternalAddress(k InternalAddress, value Value) (bool, e SumType: "internalAddress", InternalAddress: &k, } - return m.Set(key, value) + return m.set(key, value) } -func (m *MapValue) Delete(key Value) { +func (m *MapValue) delete(key Value) { for i, k := range m.keys { - if k.Equal(Value(key)) { + if k.Equal(key) { m.keys[i] = Value{} m.values[i] = Value{} m.len-- @@ -570,7 +568,7 @@ func (m *MapValue) DeleteBySmallInt(k Int64) { SumType: "smallInt", SmallInt: &k, } - m.Delete(key) + m.delete(key) } func (m *MapValue) DeleteBySmallUInt(k UInt64) { @@ -578,7 +576,7 @@ func (m *MapValue) DeleteBySmallUInt(k UInt64) { SumType: "smallUint", SmallUint: &k, } - m.Delete(key) + m.delete(key) } func (m *MapValue) DeleteByBigInt(k BigInt) { @@ -586,7 +584,7 @@ func (m *MapValue) DeleteByBigInt(k BigInt) { SumType: "bigInt", BigInt: &k, } - m.Delete(key) + m.delete(key) } func (m *MapValue) DeleteByBigUInt(k BigUInt) { @@ -594,7 +592,7 @@ func (m *MapValue) DeleteByBigUInt(k BigUInt) { SumType: "bigUint", BigUint: &k, } - m.Delete(key) + m.delete(key) } func (m *MapValue) DeleteByBits(k Bits) { @@ -602,7 +600,7 @@ func (m *MapValue) DeleteByBits(k Bits) { SumType: "bits", Bits: &k, } - m.Delete(key) + m.delete(key) } func (m *MapValue) DeleteByInternalAddress(k InternalAddress) { @@ -610,7 +608,7 @@ func (m *MapValue) DeleteByInternalAddress(k InternalAddress) { SumType: "internalAddress", InternalAddress: &k, } - m.Delete(key) + m.delete(key) } func (m *MapValue) Len() int { @@ -618,23 +616,27 @@ func (m *MapValue) Len() int { } func (m *MapValue) MarshalJSON() ([]byte, error) { + if len(m.keys) != len(m.values) { + return nil, errors.New("map values and keys must contain equal length") + } s := strings.Builder{} s.WriteString("{") if len(m.keys) > 0 { s.WriteString("\"keySumType\":") - s.WriteString(fmt.Sprintf("\"%s\",", m.keys[0].SumType)) + s.WriteString(fmt.Sprintf("\"%s\",", utils.ToCamelCasePrivate(string(m.keys[0].SumType)))) for i, k := range m.keys { if i != 0 { s.WriteString(",") } key, err := json.Marshal(k) if err != nil { - return nil, err + return nil, fmt.Errorf("failed to marshal map's key: %w", err) } - validKey, err := getKeyValue(string(key)) + validKey, err := getJustValue(string(key)) if err != nil { - return nil, err + return nil, fmt.Errorf("failed to get map's key value: %w", err) } + // there is no case that key's value may start with '[' since tensors and tuples are not fixed sizes if validKey[0] == '{' { return nil, fmt.Errorf("cannot use %v as a map key", key) } @@ -644,9 +646,9 @@ func (m *MapValue) MarshalJSON() ([]byte, error) { s.WriteString(fmt.Sprintf("%v:", validKey)) val, err := json.Marshal(m.values[i]) if err != nil { - return nil, err + return nil, fmt.Errorf("failed to marshal map's value: %w", err) } - s.WriteString(string(val)) + s.Write(val) } } s.WriteString("}") @@ -654,38 +656,34 @@ func (m *MapValue) MarshalJSON() ([]byte, error) { return []byte(s.String()), nil } -func getKeyValue(key string) (string, error) { +func getJustValue(key string) (string, error) { foundComma := false start := -1 - end := -1 for i, v := range key { if v == ',' { foundComma = true } - if v == ':' && foundComma && start == -1 { + if v == ':' && foundComma { start = i - } - if v == '}' { - end = i break } } - if start == -1 || end == -1 || end < start { - return "", fmt.Errorf("invalid key") + if start == -1 { + return "", fmt.Errorf("invalid key: %v", key) } - return strings.ReplaceAll(key[start+1:end], " ", ""), nil + return strings.ReplaceAll(key[start+1:len(key)-1], " ", ""), nil } func (m *MapValue) UnmarshalJSON(bytes []byte) error { decoder := json.NewDecoder(strings.NewReader(string(bytes))) _, err := decoder.Token() if err != nil { - return err + return fmt.Errorf("failed to unmarshal map: %w", err) } keyTypeDeclr, err := decoder.Token() if err != nil { - return err + return fmt.Errorf("failed to unmarshal map key type declaration: %w", err) } stringKeyTypeDeclr, ok := keyTypeDeclr.(string) if !ok { @@ -697,39 +695,40 @@ func (m *MapValue) UnmarshalJSON(bytes []byte) error { keyType, err := decoder.Token() if err != nil { - return err + return fmt.Errorf("failed to unmarshal map key type: %w", err) } stringKeyType, ok := keyType.(string) if !ok { - return fmt.Errorf("expected map value as a string") + return fmt.Errorf("expected map key type value as a string") } - valueTemplate := strings.Builder{} - valueTemplate.WriteString("{\"sumType\":\"") - valueTemplate.WriteString(stringKeyType) - valueTemplate.WriteString("\",\"") - valueTemplate.WriteString(stringKeyType) - valueTemplate.WriteString("\":%s}") - tmpl := valueTemplate.String() + keyTemplate := strings.Builder{} + keyTemplate.WriteString("{\"sumType\":\"") + keyTemplate.WriteString(stringKeyType) + keyTemplate.WriteString("\",\"") + keyTemplate.WriteString(stringKeyType) + keyTemplate.WriteString("\":%s}") + keyTmpl := keyTemplate.String() for decoder.More() { keyValue, err := decoder.Token() if err != nil { - return err + return fmt.Errorf("failed to unmarshal map key's value: %w", err) } stringKeyValue, ok := keyValue.(string) if !ok { return fmt.Errorf("expected map key as a string") } - keyValueJson := fmt.Sprintf(tmpl, getKeyAsValue(stringKeyType, stringKeyValue)) + keyValueJson := fmt.Sprintf(keyTmpl, wrapValue(stringKeyType, stringKeyValue)) key := Value{} if err = json.Unmarshal([]byte(keyValueJson), &key); err != nil { - return err + return fmt.Errorf("failed to unmarshal map key value: %w", err) } - value := Value{} + var value Value if err = decoder.Decode(&value); err != nil { - return err + return fmt.Errorf("failed to unmarshal map value: %w", err) } + m.keys = append(m.keys, key) m.values = append(m.values, value) m.len++ @@ -738,10 +737,10 @@ func (m *MapValue) UnmarshalJSON(bytes []byte) error { return nil } -func getKeyAsValue(sumType, key string) string { +func wrapValue(sumType string, v any) any { switch sumType { - case "smallInt", "smallUint": - return key + case "smallInt", "smallUint", "bool", "optionalValue", "tupleWith", "tensor", "map", "struct", "enum", "union", "refValue", "alias", "generic": + return v } - return fmt.Sprintf("\"%v\"", key) + return fmt.Sprintf("\"%v\"", v) } diff --git a/tolk/refs.go b/tolk/refs.go index d0b50005..13354909 100644 --- a/tolk/refs.go +++ b/tolk/refs.go @@ -26,11 +26,11 @@ type Struct struct { func (s *Struct) Unmarshal(cell *boc.Cell, ty tolkParser.StructRef, decoder *Decoder) error { if decoder.abiRefs.structRefs == nil { - return fmt.Errorf("struct has struct reference, but no abi has been given") + 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) + return fmt.Errorf("struct with name %s was not found in given abi", ty.StructName) } tolkStruct := Struct{ fieldNames: make([]string, 0), @@ -44,11 +44,11 @@ func (s *Struct) Unmarshal(cell *boc.Cell, ty tolkParser.StructRef, decoder *Dec prefix, err := cell.ReadUint(prefixLen) if err != nil { - return err + return fmt.Errorf("failed to read struct's %v-bit length prefix: %w", prefixLen, err) } actualPrefix, err := binHexToUint64(strct.Prefix.PrefixStr) if err != nil { - return err + return fmt.Errorf("failed to parse struct's prefix %v to integer: %w", prefix, err) } if prefix != actualPrefix { @@ -64,7 +64,7 @@ func (s *Struct) Unmarshal(cell *boc.Cell, ty tolkParser.StructRef, decoder *Dec oldGenericMap := decoder.abiRefs.genericRefs genericMap, err := resolveGeneric(ty.TypeArgs, strct.TypeParams, &decoder.abiRefs) if err != nil { - return err + return fmt.Errorf("failed to resolve struct's generic value: %w", err) } decoder.abiRefs.genericRefs = genericMap @@ -72,23 +72,7 @@ func (s *Struct) Unmarshal(cell *boc.Cell, ty tolkParser.StructRef, decoder *Dec fieldVal := Value{} err = fieldVal.Unmarshal(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 := val.unmarshalDefaultValue(defVal, field.Ty) - if err != nil { - return err - } - if exists { - optVal.IsExists = true - optVal.Val = val - } - } + return fmt.Errorf("failed to unmarshal struct's field %s: %w", field.Name, err) } tolkStruct.fieldNames = append(tolkStruct.fieldNames, field.Name) @@ -103,17 +87,17 @@ func (s *Struct) Unmarshal(cell *boc.Cell, ty tolkParser.StructRef, decoder *Dec func (s *Struct) Marshal(cell *boc.Cell, ty tolkParser.StructRef, encoder *Encoder) error { if encoder.abiRefs.structRefs == nil { - return fmt.Errorf("struct has struct reference, but no abi has been given") + return fmt.Errorf("struct has struct reference but no abi has been given") } strct, found := encoder.abiRefs.structRefs[ty.StructName] if !found { - return fmt.Errorf("no struct with name %s was found in given abi", ty.StructName) + return fmt.Errorf("struct with name %s was not found in given abi", ty.StructName) } if strct.Prefix != nil { actualPrefix, err := binHexToUint64(strct.Prefix.PrefixStr) if err != nil { - return err + return fmt.Errorf("failed to parse struct's prefix %v to integer: %w", strct.Prefix.PrefixStr, err) } if s.prefix.Prefix != actualPrefix { @@ -122,14 +106,14 @@ func (s *Struct) Marshal(cell *boc.Cell, ty tolkParser.StructRef, encoder *Encod err = cell.WriteUint(s.prefix.Prefix, int(s.prefix.Len)) if err != nil { - return err + return fmt.Errorf("failed to write struct's %v-bit prefix %v: %w", s.prefix.Len, s.prefix.Prefix, err) } } oldGenericMap := encoder.abiRefs.genericRefs genericMap, err := resolveGeneric(ty.TypeArgs, strct.TypeParams, &encoder.abiRefs) if err != nil { - return err + return fmt.Errorf("failed to resolve struct's generic value: %w", err) } encoder.abiRefs.genericRefs = genericMap @@ -141,7 +125,7 @@ func (s *Struct) Marshal(cell *boc.Cell, ty tolkParser.StructRef, encoder *Encod err = val.Marshal(cell, field.Ty, encoder) if err != nil { - return err + return fmt.Errorf("failed to marshal struct's field %s: %w", field.Name, err) } } @@ -181,8 +165,8 @@ func (s *Struct) SetField(field string, v Value) bool { func (s *Struct) RemoveField(field string) { for i, name := range s.fieldNames { if name == field { - s.fieldNames[i] = "|" // impossible symbol for field name in Tolk language - s.fieldValues[i] = Value{} + s.fieldNames = append(s.fieldNames[:i], s.fieldNames[i+1:]...) + s.fieldValues = append(s.fieldValues[:i], s.fieldValues[i+1:]...) } } } @@ -226,7 +210,7 @@ func (s *Struct) MarshalJSON() ([]byte, error) { builder.WriteString("\"prefix\":") prefix, err := json.Marshal(s.prefix) if err != nil { - return nil, err + return nil, fmt.Errorf("failed to marshal struct's prefix: %w", err) } builder.Write(prefix) builder.WriteRune(',') @@ -239,7 +223,7 @@ func (s *Struct) MarshalJSON() ([]byte, error) { builder.WriteString(fmt.Sprintf("\"%s\":", name)) val, err := json.Marshal(&s.fieldValues[i]) if err != nil { - return nil, err + return nil, fmt.Errorf("failed to marshal struct's field %s: %w", name, err) } builder.Write(val) } @@ -253,7 +237,7 @@ func (s *Struct) UnmarshalJSON(bytes []byte) error { Fields json.RawMessage `json:"fields"` }{} if err := json.Unmarshal(bytes, &jsonStruct); err != nil { - return err + return fmt.Errorf("failed to unmarshal struct's prefix: %w", err) } if jsonStruct.Prefix != nil { s.hasPrefix = true @@ -264,12 +248,12 @@ func (s *Struct) UnmarshalJSON(bytes []byte) error { _, err := decoder.Token() // { if err != nil { - return err + return fmt.Errorf("failed to unmarshal struct's fields value declrataion: %w", err) } for decoder.More() { key, err := decoder.Token() if err != nil { - return err + return fmt.Errorf("failed to unmarshal struct's key: %w", err) } stringKey, ok := key.(string) if !ok { @@ -277,7 +261,7 @@ func (s *Struct) UnmarshalJSON(bytes []byte) error { } var val Value if err = decoder.Decode(&val); err != nil { - return err + return fmt.Errorf("failed to unmarshal struct's field %s value: %w", stringKey, err) } s.fieldNames = append(s.fieldNames, stringKey) @@ -295,17 +279,17 @@ type EnumValue struct { func (e *EnumValue) Unmarshal(cell *boc.Cell, ty tolkParser.EnumRef, decoder *Decoder) error { if decoder.abiRefs.enumRefs == nil { - return fmt.Errorf("struct has enum reference, but no abi has been given") + 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) + return fmt.Errorf("enum with name %s was not found in given abi", ty.EnumName) } enumVal := Value{} err := enumVal.Unmarshal(cell, enum.EncodedAs, decoder) if err != nil { - return err + return fmt.Errorf("failed to unmarshal enum's value: %w", err) } var bigEnumVal big.Int switch enum.EncodedAs.SumType { @@ -345,28 +329,22 @@ func (e *EnumValue) Unmarshal(cell *boc.Cell, ty tolkParser.EnumRef, decoder *De return nil } } - // todo: maybe return err? - *e = EnumValue{ - ActualValue: enumVal, - Name: "Unknown", - Value: bigEnumVal, - } - return nil + return fmt.Errorf("enum value didn't match any values") } func (e *EnumValue) Marshal(cell *boc.Cell, ty tolkParser.EnumRef, encoder *Encoder) error { if encoder.abiRefs.enumRefs == nil { - return fmt.Errorf("struct has enum reference, but no abi has been given") + return fmt.Errorf("struct has enum reference but no abi has been given") } enum, found := encoder.abiRefs.enumRefs[ty.EnumName] if !found { - return fmt.Errorf("no enum with name %s was found in given abi", ty.EnumName) + return fmt.Errorf("enum with name %s was not found in given abi", ty.EnumName) } err := e.ActualValue.Marshal(cell, enum.EncodedAs, encoder) if err != nil { - return err + return fmt.Errorf("failed to marshal enum's value: %w", err) } for _, member := range enum.Members { @@ -379,7 +357,7 @@ func (e *EnumValue) Marshal(cell *boc.Cell, ty tolkParser.EnumRef, encoder *Enco return nil } } - return fmt.Errorf("enum value not matcher, got: %s", e.Value.String()) + return fmt.Errorf("enum value not matched, got: %s", e.Value.String()) } func (e *EnumValue) Equal(other any) bool { @@ -409,29 +387,28 @@ func (a *AliasValue) Equal(other any) bool { func (a *AliasValue) Unmarshal(cell *boc.Cell, ty tolkParser.AliasRef, decoder *Decoder) error { if decoder.abiRefs.aliasRefs == nil { - return fmt.Errorf("struct has alias reference, but no abi has been given") + 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) + return fmt.Errorf("alias with name %s was not found in given abi", ty.AliasName) } if alias.CustomUnpackFromSlice { - // todo: maybe simply return error? - fmt.Println("WARNING! alias has custom unpack method. Default unpacking can be incorrect!") + return fmt.Errorf("alias has custom unpack from slice") } oldGenericMap := decoder.abiRefs.genericRefs genericMap, err := resolveGeneric(ty.TypeArgs, alias.TypeParams, &decoder.abiRefs) if err != nil { - return err + return fmt.Errorf("failed to resolve alias' generic value: %w", err) } decoder.abiRefs.genericRefs = genericMap val := Value{} err = val.Unmarshal(cell, alias.TargetTy, decoder) if err != nil { - return err + return fmt.Errorf("failed to unmarshal alias value: %w", err) } decoder.abiRefs.genericRefs = oldGenericMap @@ -442,29 +419,28 @@ func (a *AliasValue) Unmarshal(cell *boc.Cell, ty tolkParser.AliasRef, decoder * func (a *AliasValue) Marshal(cell *boc.Cell, ty tolkParser.AliasRef, encoder *Encoder) error { if encoder.abiRefs.aliasRefs == nil { - return fmt.Errorf("struct has alias reference, but no abi has been given") + return fmt.Errorf("struct has alias reference but no abi has been given") } alias, found := encoder.abiRefs.aliasRefs[ty.AliasName] if !found { - return fmt.Errorf("no alias with name %s was found in given abi", ty.AliasName) + return fmt.Errorf("alias with name %s was not found in given abi", ty.AliasName) } if alias.CustomPackToBuilder { - // todo: maybe simply return error? - fmt.Println("WARNING! alias has custom pack method. Default packing can be incorrect!") + return fmt.Errorf("alias has custom pack to builder") } oldGenericMap := encoder.abiRefs.genericRefs genericMap, err := resolveGeneric(ty.TypeArgs, alias.TypeParams, &encoder.abiRefs) if err != nil { - return err + return fmt.Errorf("failed to resolve alias' generic value: %w", err) } encoder.abiRefs.genericRefs = genericMap val := Value(*a) err = val.Marshal(cell, alias.TargetTy, encoder) if err != nil { - return err + return fmt.Errorf("failed to marshal alias value: %w", err) } encoder.abiRefs.genericRefs = oldGenericMap @@ -486,12 +462,12 @@ func (g *GenericValue) Equal(other any) bool { func (g *GenericValue) Unmarshal(cell *boc.Cell, ty tolkParser.Generic, decoder *Decoder) error { currentTy, found := decoder.abiRefs.genericRefs[ty.NameT] if !found { - return fmt.Errorf("cannot resolve generic type %v ", ty.NameT) + return fmt.Errorf("cannot resolve generic's type %v ", ty.NameT) } val := Value{} err := val.Unmarshal(cell, currentTy, decoder) if err != nil { - return err + return fmt.Errorf("failed to unmarshal generic's value: %w", err) } *g = GenericValue(val) @@ -502,12 +478,12 @@ func (g *GenericValue) Unmarshal(cell *boc.Cell, ty tolkParser.Generic, decoder func (g *GenericValue) Marshal(cell *boc.Cell, ty tolkParser.Generic, encoder *Encoder) error { currentTy, found := encoder.abiRefs.genericRefs[ty.NameT] if !found { - return fmt.Errorf("cannot resolve generic type %v ", ty.NameT) + return fmt.Errorf("cannot resolve generic's type %v ", ty.NameT) } val := Value(*g) err := val.Marshal(cell, currentTy, encoder) if err != nil { - return err + return fmt.Errorf("failed to marshal generic's value: %w", err) } return nil @@ -524,12 +500,12 @@ func resolveGeneric(typeArgs []tolkParser.Ty, typeParams []string, abiRefs *abiR if genericTy.SumType == "Generic" { if abiRefs.genericRefs == nil { - return nil, fmt.Errorf("cannot resolve generic type %v", genericTy.Generic.NameT) + return nil, fmt.Errorf("cannot resolve generic's type %v", genericTy.Generic.NameT) } ty, found := abiRefs.genericRefs[genericTy.Generic.NameT] if !found { - return nil, fmt.Errorf("generic type %v not found", genericTy.Generic.NameT) + return nil, fmt.Errorf("generic's type %v not found", genericTy.Generic.NameT) } genericMap[typeParams[i]] = ty } diff --git a/tolk/runtime.go b/tolk/runtime.go index a438db9d..b341caec 100644 --- a/tolk/runtime.go +++ b/tolk/runtime.go @@ -1,6 +1,8 @@ package tolk import ( + "fmt" + "github.com/tonkeeper/tongo/boc" "github.com/tonkeeper/tongo/tolk/parser" ) @@ -54,7 +56,7 @@ func (a *Decoder) Unmarshal(cell *boc.Cell, ty tolkParser.Ty) (*Value, error) { res := &Value{} err := res.Unmarshal(cell, ty, a) if err != nil { - return nil, err + return nil, fmt.Errorf("failed to unmarshal tolk value: %w", err) } return res, nil } @@ -91,7 +93,7 @@ func (a *Encoder) Marshal(v *Value, ty tolkParser.Ty) (*boc.Cell, error) { cell := boc.NewCell() err := v.Marshal(cell, ty, a) if err != nil { - return nil, err + return nil, fmt.Errorf("failed to marshal tolk value: %w", err) } return cell, nil } diff --git a/tolk/runtime_test.go b/tolk/runtime_test.go index 5c134800..1d2efede 100644 --- a/tolk/runtime_test.go +++ b/tolk/runtime_test.go @@ -42,22 +42,15 @@ func TestRuntime_UnmarshalSmallInt(t *testing.T) { t.Errorf("val != -35132, got %v", val) } - pathPrefix := jsonFilesPath + inputFilename - actual, err := json.MarshalIndent(v, "", " ") - if err != nil { - t.Fatal(err) - } - err = os.WriteFile(pathPrefix+".output.json", actual, os.ModePerm) + err = compareExpectedJson(inputFilename, *v) if err != nil { t.Fatal(err) } - expected, err := os.ReadFile(pathPrefix + ".json") + + err = compareExpectedJson(inputFilename, *v) if err != nil { t.Fatal(err) } - if !bytes.Equal(actual, expected) { - t.Errorf("%s got different results", pathPrefix) - } } func TestRuntime_UnmarshalBigInt(t *testing.T) { @@ -86,22 +79,10 @@ func TestRuntime_UnmarshalBigInt(t *testing.T) { t.Errorf("val != -3513294376431, got %v", val) } - pathPrefix := jsonFilesPath + inputFilename - actual, err := json.MarshalIndent(v, "", " ") + err = compareExpectedJson(inputFilename, *v) if err != nil { t.Fatal(err) } - err = os.WriteFile(pathPrefix+".output.json", actual, os.ModePerm) - if err != nil { - t.Fatal(err) - } - expected, err := os.ReadFile(pathPrefix + ".json") - if err != nil { - t.Fatal(err) - } - if !bytes.Equal(actual, expected) { - t.Errorf("%s got different results", pathPrefix) - } } func TestRuntime_UnmarshalSmallUInt(t *testing.T) { @@ -130,22 +111,10 @@ func TestRuntime_UnmarshalSmallUInt(t *testing.T) { t.Errorf("val != 934, got %v", val) } - pathPrefix := jsonFilesPath + inputFilename - actual, err := json.MarshalIndent(v, "", " ") + err = compareExpectedJson(inputFilename, *v) if err != nil { t.Fatal(err) } - err = os.WriteFile(pathPrefix+".output.json", actual, os.ModePerm) - if err != nil { - t.Fatal(err) - } - expected, err := os.ReadFile(pathPrefix + ".json") - if err != nil { - t.Fatal(err) - } - if !bytes.Equal(actual, expected) { - t.Errorf("%s got different results", pathPrefix) - } } func TestRuntime_UnmarshalBigUInt(t *testing.T) { @@ -174,22 +143,10 @@ func TestRuntime_UnmarshalBigUInt(t *testing.T) { t.Errorf("val != 351329437643124, got %v", val.String()) } - pathPrefix := jsonFilesPath + inputFilename - actual, err := json.MarshalIndent(v, "", " ") - if err != nil { - t.Fatal(err) - } - err = os.WriteFile(pathPrefix+".output.json", actual, os.ModePerm) - if err != nil { - t.Fatal(err) - } - expected, err := os.ReadFile(pathPrefix + ".json") + err = compareExpectedJson(inputFilename, *v) if err != nil { t.Fatal(err) } - if !bytes.Equal(actual, expected) { - t.Errorf("%s got different results", pathPrefix) - } } func TestRuntime_UnmarshalVarInt(t *testing.T) { @@ -218,22 +175,10 @@ func TestRuntime_UnmarshalVarInt(t *testing.T) { t.Errorf("val != 825432, got %v", val.String()) } - pathPrefix := jsonFilesPath + inputFilename - actual, err := json.MarshalIndent(v, "", " ") - if err != nil { - t.Fatal(err) - } - err = os.WriteFile(pathPrefix+".output.json", actual, os.ModePerm) + err = compareExpectedJson(inputFilename, *v) if err != nil { t.Fatal(err) } - expected, err := os.ReadFile(pathPrefix + ".json") - if err != nil { - t.Fatal(err) - } - if !bytes.Equal(actual, expected) { - t.Errorf("%s got different results", pathPrefix) - } } func TestRuntime_UnmarshalVarUInt(t *testing.T) { @@ -262,22 +207,10 @@ func TestRuntime_UnmarshalVarUInt(t *testing.T) { t.Errorf("val != 9451236712, got %v", val.String()) } - pathPrefix := jsonFilesPath + inputFilename - actual, err := json.MarshalIndent(v, "", " ") - if err != nil { - t.Fatal(err) - } - err = os.WriteFile(pathPrefix+".output.json", actual, os.ModePerm) + err = compareExpectedJson(inputFilename, *v) if err != nil { t.Fatal(err) } - expected, err := os.ReadFile(pathPrefix + ".json") - if err != nil { - t.Fatal(err) - } - if !bytes.Equal(actual, expected) { - t.Errorf("%s got different results", pathPrefix) - } } func TestRuntime_UnmarshalBits(t *testing.T) { @@ -306,22 +239,10 @@ func TestRuntime_UnmarshalBits(t *testing.T) { t.Errorf("val != {55, 56, 57}, got %v", val) } - pathPrefix := jsonFilesPath + inputFilename - actual, err := json.MarshalIndent(v, "", " ") + err = compareExpectedJson(inputFilename, *v) if err != nil { t.Fatal(err) } - err = os.WriteFile(pathPrefix+".output.json", actual, os.ModePerm) - if err != nil { - t.Fatal(err) - } - expected, err := os.ReadFile(pathPrefix + ".json") - if err != nil { - t.Fatal(err) - } - if !bytes.Equal(actual, expected) { - t.Errorf("%s got different results", pathPrefix) - } } func TestRuntime_UnmarshalCoins(t *testing.T) { @@ -348,22 +269,10 @@ func TestRuntime_UnmarshalCoins(t *testing.T) { t.Errorf("val != 921464321, got %v", val) } - pathPrefix := jsonFilesPath + inputFilename - actual, err := json.MarshalIndent(v, "", " ") + err = compareExpectedJson(inputFilename, *v) if err != nil { t.Fatal(err) } - err = os.WriteFile(pathPrefix+".output.json", actual, os.ModePerm) - if err != nil { - t.Fatal(err) - } - expected, err := os.ReadFile(pathPrefix + ".json") - if err != nil { - t.Fatal(err) - } - if !bytes.Equal(actual, expected) { - t.Errorf("%s got different results", pathPrefix) - } } func TestRuntime_UnmarshalBool(t *testing.T) { @@ -390,22 +299,10 @@ func TestRuntime_UnmarshalBool(t *testing.T) { t.Error("val is true") } - pathPrefix := jsonFilesPath + inputFilename - actual, err := json.MarshalIndent(v, "", " ") - if err != nil { - t.Fatal(err) - } - err = os.WriteFile(pathPrefix+".output.json", actual, os.ModePerm) + err = compareExpectedJson(inputFilename, *v) if err != nil { t.Fatal(err) } - expected, err := os.ReadFile(pathPrefix + ".json") - if err != nil { - t.Fatal(err) - } - if !bytes.Equal(actual, expected) { - t.Errorf("%s got different results", pathPrefix) - } } func TestRuntime_UnmarshalCell(t *testing.T) { @@ -436,22 +333,10 @@ func TestRuntime_UnmarshalCell(t *testing.T) { t.Errorf("val.Hash() != 644e68a539c5107401d194bc82169cbf0ad1635796891551e0750705ab2d74ae, got %v", hs) } - pathPrefix := jsonFilesPath + inputFilename - actual, err := json.MarshalIndent(v, "", " ") - if err != nil { - t.Fatal(err) - } - err = os.WriteFile(pathPrefix+".output.json", actual, os.ModePerm) - if err != nil { - t.Fatal(err) - } - expected, err := os.ReadFile(pathPrefix + ".json") + err = compareExpectedJson(inputFilename, *v) if err != nil { t.Fatal(err) } - if !bytes.Equal(actual, expected) { - t.Errorf("%s got different results", pathPrefix) - } } func TestRuntime_UnmarshalRemaining(t *testing.T) { @@ -482,22 +367,10 @@ func TestRuntime_UnmarshalRemaining(t *testing.T) { t.Errorf("val.Hash() != f1c4e07fbd1786411c2caa9ac9f5d7240aa2007a2a1d5e5ac44f8a168cd4e36b, got %v", hs) } - pathPrefix := jsonFilesPath + inputFilename - actual, err := json.MarshalIndent(v, "", " ") + err = compareExpectedJson(inputFilename, *v) if err != nil { t.Fatal(err) } - err = os.WriteFile(pathPrefix+".output.json", actual, os.ModePerm) - if err != nil { - t.Fatal(err) - } - expected, err := os.ReadFile(pathPrefix + ".json") - if err != nil { - t.Fatal(err) - } - if !bytes.Equal(actual, expected) { - t.Errorf("%s got different results", pathPrefix) - } } func TestRuntime_UnmarshalAddress(t *testing.T) { @@ -524,22 +397,10 @@ func TestRuntime_UnmarshalAddress(t *testing.T) { t.Errorf("val.GetAddress() != 0:83dfd552e63729b472fcbcc8c45ebcc6691702558b68ec7527e1ba403a0f31a8, got %v", val.ToRaw()) } - pathPrefix := jsonFilesPath + inputFilename - actual, err := json.MarshalIndent(v, "", " ") - if err != nil { - t.Fatal(err) - } - err = os.WriteFile(pathPrefix+".output.json", actual, os.ModePerm) + err = compareExpectedJson(inputFilename, *v) if err != nil { t.Fatal(err) } - expected, err := os.ReadFile(pathPrefix + ".json") - if err != nil { - t.Fatal(err) - } - if !bytes.Equal(actual, expected) { - t.Errorf("%s got different results", pathPrefix) - } } func TestRuntime_UnmarshalNotExitsOptionalAddress(t *testing.T) { @@ -567,22 +428,10 @@ func TestRuntime_UnmarshalNotExitsOptionalAddress(t *testing.T) { t.Errorf("val.GetAddress() != none address") } - pathPrefix := jsonFilesPath + inputFilename - actual, err := json.MarshalIndent(v, "", " ") - if err != nil { - t.Fatal(err) - } - err = os.WriteFile(pathPrefix+".output.json", actual, os.ModePerm) - if err != nil { - t.Fatal(err) - } - expected, err := os.ReadFile(pathPrefix + ".json") + err = compareExpectedJson(inputFilename, *v) if err != nil { t.Fatal(err) } - if !bytes.Equal(actual, expected) { - t.Errorf("%s got different results", pathPrefix) - } } func TestRuntime_UnmarshalExistsOptionalAddress(t *testing.T) { @@ -610,22 +459,10 @@ func TestRuntime_UnmarshalExistsOptionalAddress(t *testing.T) { t.Errorf("val.GetAddress() != 0:83dfd552e63729b472fcbcc8c45ebcc6691702558b68ec7527e1ba403a0f31a8, got %v", val.InternalAddress.ToRaw()) } - pathPrefix := jsonFilesPath + inputFilename - actual, err := json.MarshalIndent(v, "", " ") - if err != nil { - t.Fatal(err) - } - err = os.WriteFile(pathPrefix+".output.json", actual, os.ModePerm) - if err != nil { - t.Fatal(err) - } - expected, err := os.ReadFile(pathPrefix + ".json") + err = compareExpectedJson(inputFilename, *v) if err != nil { t.Fatal(err) } - if !bytes.Equal(actual, expected) { - t.Errorf("%s got different results", pathPrefix) - } } func TestRuntime_UnmarshalExternalAddress(t *testing.T) { @@ -657,22 +494,10 @@ func TestRuntime_UnmarshalExternalAddress(t *testing.T) { t.Errorf("val.GetExternalAddress() != {97, 98}, got %v", val.Address.Buffer()) } - pathPrefix := jsonFilesPath + inputFilename - actual, err := json.MarshalIndent(v, "", " ") - if err != nil { - t.Fatal(err) - } - err = os.WriteFile(pathPrefix+".output.json", actual, os.ModePerm) - if err != nil { - t.Fatal(err) - } - expected, err := os.ReadFile(pathPrefix + ".json") + err = compareExpectedJson(inputFilename, *v) if err != nil { t.Fatal(err) } - if !bytes.Equal(actual, expected) { - t.Errorf("%s got different results", pathPrefix) - } } func TestRuntime_UnmarshalAnyNoneAddress(t *testing.T) { @@ -699,22 +524,10 @@ func TestRuntime_UnmarshalAnyNoneAddress(t *testing.T) { t.Errorf("val.GetAddress() != none address") } - pathPrefix := jsonFilesPath + inputFilename - actual, err := json.MarshalIndent(v, "", " ") + err = compareExpectedJson(inputFilename, *v) if err != nil { t.Fatal(err) } - err = os.WriteFile(pathPrefix+".output.json", actual, os.ModePerm) - if err != nil { - t.Fatal(err) - } - expected, err := os.ReadFile(pathPrefix + ".json") - if err != nil { - t.Fatal(err) - } - if !bytes.Equal(actual, expected) { - t.Errorf("%s got different results", pathPrefix) - } } func TestRuntime_UnmarshalAnyInternalAddress(t *testing.T) { @@ -741,22 +554,10 @@ func TestRuntime_UnmarshalAnyInternalAddress(t *testing.T) { t.Errorf("val.GetAddress() != 0:83dfd552e63729b472fcbcc8c45ebcc6691702558b68ec7527e1ba403a0f31a8, got %v", val.InternalAddress.ToRaw()) } - pathPrefix := jsonFilesPath + inputFilename - actual, err := json.MarshalIndent(v, "", " ") - if err != nil { - t.Fatal(err) - } - err = os.WriteFile(pathPrefix+".output.json", actual, os.ModePerm) - if err != nil { - t.Fatal(err) - } - expected, err := os.ReadFile(pathPrefix + ".json") + err = compareExpectedJson(inputFilename, *v) if err != nil { t.Fatal(err) } - if !bytes.Equal(actual, expected) { - t.Errorf("%s got different results", pathPrefix) - } } func TestRuntime_UnmarshalAnyExternalAddress(t *testing.T) { @@ -788,22 +589,10 @@ func TestRuntime_UnmarshalAnyExternalAddress(t *testing.T) { t.Errorf("val.GetExternalAddress() != {97, 98}, got %v", val.ExternalAddress.Address.Buffer()) } - pathPrefix := jsonFilesPath + inputFilename - actual, err := json.MarshalIndent(v, "", " ") - if err != nil { - t.Fatal(err) - } - err = os.WriteFile(pathPrefix+".output.json", actual, os.ModePerm) + err = compareExpectedJson(inputFilename, *v) if err != nil { t.Fatal(err) } - expected, err := os.ReadFile(pathPrefix + ".json") - if err != nil { - t.Fatal(err) - } - if !bytes.Equal(actual, expected) { - t.Errorf("%s got different results", pathPrefix) - } } func TestRuntime_UnmarshalAnyVarAddress(t *testing.T) { @@ -839,22 +628,10 @@ func TestRuntime_UnmarshalAnyVarAddress(t *testing.T) { t.Errorf("val.GetExternalAddress() != {97, 98}, got %v", val.ExternalAddress.Address.Buffer()) } - pathPrefix := jsonFilesPath + inputFilename - actual, err := json.MarshalIndent(v, "", " ") - if err != nil { - t.Fatal(err) - } - err = os.WriteFile(pathPrefix+".output.json", actual, os.ModePerm) - if err != nil { - t.Fatal(err) - } - expected, err := os.ReadFile(pathPrefix + ".json") + err = compareExpectedJson(inputFilename, *v) if err != nil { t.Fatal(err) } - if !bytes.Equal(actual, expected) { - t.Errorf("%s got different results", pathPrefix) - } } func TestRuntime_UnmarshalNotExistsNullable(t *testing.T) { @@ -886,22 +663,10 @@ func TestRuntime_UnmarshalNotExistsNullable(t *testing.T) { t.Errorf("v.GetOptionalValue() is exists") } - pathPrefix := jsonFilesPath + inputFilename - actual, err := json.MarshalIndent(v, "", " ") + err = compareExpectedJson(inputFilename, *v) if err != nil { t.Fatal(err) } - err = os.WriteFile(pathPrefix+".output.json", actual, os.ModePerm) - if err != nil { - t.Fatal(err) - } - expected, err := os.ReadFile(pathPrefix + ".json") - if err != nil { - t.Fatal(err) - } - if !bytes.Equal(actual, expected) { - t.Errorf("%s got different results", pathPrefix) - } } func TestRuntime_UnmarshalExistsNullable(t *testing.T) { @@ -944,22 +709,10 @@ func TestRuntime_UnmarshalExistsNullable(t *testing.T) { t.Errorf("v.GetOptionalValue().GetCell() != df05386a55563049a4834a4cc1ec0dc22f3dcb63c04f7258ae475c5d28981773, got %v", hs) } - pathPrefix := jsonFilesPath + inputFilename - actual, err := json.MarshalIndent(v, "", " ") + err = compareExpectedJson(inputFilename, *v) if err != nil { t.Fatal(err) } - err = os.WriteFile(pathPrefix+".output.json", actual, os.ModePerm) - if err != nil { - t.Fatal(err) - } - expected, err := os.ReadFile(pathPrefix + ".json") - if err != nil { - t.Fatal(err) - } - if !bytes.Equal(actual, expected) { - t.Errorf("%s got different results", pathPrefix) - } } func TestRuntime_UnmarshalRef(t *testing.T) { @@ -997,22 +750,10 @@ func TestRuntime_UnmarshalRef(t *testing.T) { t.Errorf("v.GetRefValue().GetBigInt() != 1233212, got %v", innerVal.String()) } - pathPrefix := jsonFilesPath + inputFilename - actual, err := json.MarshalIndent(v, "", " ") + err = compareExpectedJson(inputFilename, *v) if err != nil { t.Fatal(err) } - err = os.WriteFile(pathPrefix+".output.json", actual, os.ModePerm) - if err != nil { - t.Fatal(err) - } - expected, err := os.ReadFile(pathPrefix + ".json") - if err != nil { - t.Fatal(err) - } - if !bytes.Equal(actual, expected) { - t.Errorf("%s got different results", pathPrefix) - } } func TestRuntime_UnmarshalEmptyTensor(t *testing.T) { @@ -1040,22 +781,10 @@ func TestRuntime_UnmarshalEmptyTensor(t *testing.T) { t.Errorf("v.GetTensor() != empty") } - pathPrefix := jsonFilesPath + inputFilename - actual, err := json.MarshalIndent(v, "", " ") - if err != nil { - t.Fatal(err) - } - err = os.WriteFile(pathPrefix+".output.json", actual, os.ModePerm) - if err != nil { - t.Fatal(err) - } - expected, err := os.ReadFile(pathPrefix + ".json") + err = compareExpectedJson(inputFilename, *v) if err != nil { t.Fatal(err) } - if !bytes.Equal(actual, expected) { - t.Errorf("%s got different results", pathPrefix) - } } func TestRuntime_UnmarshalTensor(t *testing.T) { @@ -1186,22 +915,10 @@ func TestRuntime_UnmarshalTensor(t *testing.T) { t.Errorf("val[4].GetVarInt() != -9304000000, got %v", val4.String()) } - pathPrefix := jsonFilesPath + inputFilename - actual, err := json.MarshalIndent(v, "", " ") - if err != nil { - t.Fatal(err) - } - err = os.WriteFile(pathPrefix+".output.json", actual, os.ModePerm) + err = compareExpectedJson(inputFilename, *v) if err != nil { t.Fatal(err) } - expected, err := os.ReadFile(pathPrefix + ".json") - if err != nil { - t.Fatal(err) - } - if !bytes.Equal(actual, expected) { - t.Errorf("%s got different results", pathPrefix) - } } func TestRuntime_UnmarshalIntKeyMap(t *testing.T) { @@ -1252,22 +969,10 @@ func TestRuntime_UnmarshalIntKeyMap(t *testing.T) { t.Errorf("val[0] was found") } - pathPrefix := jsonFilesPath + inputFilename - actual, err := json.MarshalIndent(v, "", " ") - if err != nil { - t.Fatal(err) - } - err = os.WriteFile(pathPrefix+".output.json", actual, os.ModePerm) + err = compareExpectedJson(inputFilename, *v) if err != nil { t.Fatal(err) } - expected, err := os.ReadFile(pathPrefix + ".json") - if err != nil { - t.Fatal(err) - } - if !bytes.Equal(actual, expected) { - t.Errorf("%s got different results", pathPrefix) - } } func TestRuntime_UnmarshalUIntKeyMap(t *testing.T) { @@ -1330,22 +1035,10 @@ func TestRuntime_UnmarshalUIntKeyMap(t *testing.T) { t.Errorf("val[0] was found") } - pathPrefix := jsonFilesPath + inputFilename - actual, err := json.MarshalIndent(v, "", " ") + err = compareExpectedJson(inputFilename, *v) if err != nil { t.Fatal(err) } - err = os.WriteFile(pathPrefix+".output.json", actual, os.ModePerm) - if err != nil { - t.Fatal(err) - } - expected, err := os.ReadFile(pathPrefix + ".json") - if err != nil { - t.Fatal(err) - } - if !bytes.Equal(actual, expected) { - t.Errorf("%s got different results", pathPrefix) - } } func TestRuntime_UnmarshalBigIntKeyMap(t *testing.T) { @@ -1400,22 +1093,10 @@ func TestRuntime_UnmarshalBigIntKeyMap(t *testing.T) { t.Errorf("val[34] was found") } - pathPrefix := jsonFilesPath + inputFilename - actual, err := json.MarshalIndent(v, "", " ") + err = compareExpectedJson(inputFilename, *v) if err != nil { t.Fatal(err) } - err = os.WriteFile(pathPrefix+".output.json", actual, os.ModePerm) - if err != nil { - t.Fatal(err) - } - expected, err := os.ReadFile(pathPrefix + ".json") - if err != nil { - t.Fatal(err) - } - if !bytes.Equal(actual, expected) { - t.Errorf("%s got different results", pathPrefix) - } } func TestRuntime_UnmarshalBitsKeyMap(t *testing.T) { @@ -1519,22 +1200,10 @@ func TestRuntime_UnmarshalBitsKeyMap(t *testing.T) { t.Errorf("val[{98, 99}] was found") } - pathPrefix := jsonFilesPath + inputFilename - actual, err := json.MarshalIndent(v, "", " ") - if err != nil { - t.Fatal(err) - } - err = os.WriteFile(pathPrefix+".output.json", actual, os.ModePerm) + err = compareExpectedJson(inputFilename, *v) if err != nil { t.Fatal(err) } - expected, err := os.ReadFile(pathPrefix + ".json") - if err != nil { - t.Fatal(err) - } - if !bytes.Equal(actual, expected) { - t.Errorf("%s got different results", pathPrefix) - } } func TestRuntime_UnmarshalAddressKeyMap(t *testing.T) { @@ -1592,22 +1261,10 @@ func TestRuntime_UnmarshalAddressKeyMap(t *testing.T) { t.Errorf("val[\"UQCD39VS5jcptHL8vMjEXrzGaRcCVYto7HUn4bpAOg8xqEBI\"] was found") } - pathPrefix := jsonFilesPath + inputFilename - actual, err := json.MarshalIndent(v, "", " ") - if err != nil { - t.Fatal(err) - } - err = os.WriteFile(pathPrefix+".output.json", actual, os.ModePerm) - if err != nil { - t.Fatal(err) - } - expected, err := os.ReadFile(pathPrefix + ".json") + err = compareExpectedJson(inputFilename, *v) if err != nil { t.Fatal(err) } - if !bytes.Equal(actual, expected) { - t.Errorf("%s got different results", pathPrefix) - } } func TestRuntime_UnmarshalUnionWithDecPrefix(t *testing.T) { @@ -1670,22 +1327,10 @@ func TestRuntime_UnmarshalUnionWithDecPrefix(t *testing.T) { t.Errorf("val.Val.GetBigInt() != 124432123, got %v", unionVal.String()) } - pathPrefix := jsonFilesPath + jsonInputFilename - actual, err := json.MarshalIndent(v, "", " ") + err = compareExpectedJson(jsonInputFilename, *v) if err != nil { t.Fatal(err) } - err = os.WriteFile(pathPrefix+".output.json", actual, os.ModePerm) - if err != nil { - t.Fatal(err) - } - expected, err := os.ReadFile(pathPrefix + ".json") - if err != nil { - t.Fatal(err) - } - if !bytes.Equal(actual, expected) { - t.Errorf("%s got different results", pathPrefix) - } } func TestRuntime_UnmarshalUnionWithBinPrefix(t *testing.T) { @@ -1790,22 +1435,10 @@ func TestRuntime_UnmarshalUnionWithBinPrefix(t *testing.T) { t.Errorf("val.GetMap()[\"EQCxE6mUtQJKFnGfaROTKOt1lZbDiiX1kCixRv7Nw2Id_sDs\"].GetCoins() != 43213412, got %v", mapCoins.String()) } - pathPrefix := jsonFilesPath + jsonInputFilename - actual, err := json.MarshalIndent(v, "", " ") - if err != nil { - t.Fatal(err) - } - err = os.WriteFile(pathPrefix+".output.json", actual, os.ModePerm) - if err != nil { - t.Fatal(err) - } - expected, err := os.ReadFile(pathPrefix + ".json") + err = compareExpectedJson(jsonInputFilename, *v) if err != nil { t.Fatal(err) } - if !bytes.Equal(actual, expected) { - t.Errorf("%s got different results", pathPrefix) - } } func TestRuntime_UnmarshalUnionWithHexPrefix(t *testing.T) { @@ -1898,22 +1531,10 @@ func TestRuntime_UnmarshalUnionWithHexPrefix(t *testing.T) { t.Errorf("val.GetSmallUInt() != 1, got %v", unionVal) } - pathPrefix := jsonFilesPath + jsonInputFilename - actual, err := json.MarshalIndent(v, "", " ") + err = compareExpectedJson(jsonInputFilename, *v) if err != nil { t.Fatal(err) } - err = os.WriteFile(pathPrefix+".output.json", actual, os.ModePerm) - if err != nil { - t.Fatal(err) - } - expected, err := os.ReadFile(pathPrefix + ".json") - if err != nil { - t.Fatal(err) - } - if !bytes.Equal(actual, expected) { - t.Errorf("%s got different results", pathPrefix) - } } func TestRuntime_UnmarshalALotRefsFromAlias(t *testing.T) { @@ -2177,22 +1798,10 @@ func TestRuntime_UnmarshalALotRefsFromAlias(t *testing.T) { t.Errorf("currStruct[oper3].GetEnum().Name != Something, got %v", oper3Enum.Name) } - pathPrefix := jsonFilesPath + jsonInputFilename - actual, err := json.MarshalIndent(v, "", " ") - if err != nil { - t.Fatal(err) - } - err = os.WriteFile(pathPrefix+".output.json", actual, os.ModePerm) - if err != nil { - t.Fatal(err) - } - expected, err := os.ReadFile(pathPrefix + ".json") + err = compareExpectedJson(jsonInputFilename, *v) if err != nil { t.Fatal(err) } - if !bytes.Equal(actual, expected) { - t.Errorf("%s got different results", pathPrefix) - } } func TestRuntime_UnmarshalALotRefsFromStruct(t *testing.T) { @@ -2452,22 +2061,10 @@ func TestRuntime_UnmarshalALotRefsFromStruct(t *testing.T) { t.Errorf("currStruct[oper3].GetEnum().Name != Something, got %v", oper3Enum.Name) } - pathPrefix := jsonFilesPath + jsonInputFilename - actual, err := json.MarshalIndent(v, "", " ") - if err != nil { - t.Fatal(err) - } - err = os.WriteFile(pathPrefix+".output.json", actual, os.ModePerm) - if err != nil { - t.Fatal(err) - } - expected, err := os.ReadFile(pathPrefix + ".json") + err = compareExpectedJson(jsonInputFilename, *v) if err != nil { t.Fatal(err) } - if !bytes.Equal(actual, expected) { - t.Errorf("%s got different results", pathPrefix) - } } func TestRuntime_UnmarshalALotGenericsFromStruct(t *testing.T) { @@ -2716,22 +2313,10 @@ func TestRuntime_UnmarshalALotGenericsFromStruct(t *testing.T) { t.Fatalf("currStruct[myVal] != 16, got %v", myValVal) } - pathPrefix := jsonFilesPath + jsonInputFilename - actual, err := json.MarshalIndent(v, "", " ") - if err != nil { - t.Fatal(err) - } - err = os.WriteFile(pathPrefix+".output.json", actual, os.ModePerm) + err = compareExpectedJson(jsonInputFilename, *v) if err != nil { t.Fatal(err) } - expected, err := os.ReadFile(pathPrefix + ".json") - if err != nil { - t.Fatal(err) - } - if !bytes.Equal(actual, expected) { - t.Errorf("%s got different results", pathPrefix) - } } func TestRuntime_UnmarshalALotGenericsFromAlias(t *testing.T) { @@ -2984,22 +2569,10 @@ func TestRuntime_UnmarshalALotGenericsFromAlias(t *testing.T) { t.Fatalf("currStruct[myVal] != 16, got %v", myValVal) } - pathPrefix := jsonFilesPath + jsonInputFilename - actual, err := json.MarshalIndent(v, "", " ") + err = compareExpectedJson(jsonInputFilename, *v) if err != nil { t.Fatal(err) } - err = os.WriteFile(pathPrefix+".output.json", actual, os.ModePerm) - if err != nil { - t.Fatal(err) - } - expected, err := os.ReadFile(pathPrefix + ".json") - if err != nil { - t.Fatal(err) - } - if !bytes.Equal(actual, expected) { - t.Errorf("%s got different results", pathPrefix) - } } func TestRuntime_UnmarshalStructWithDefaultValues(t *testing.T) { @@ -3174,22 +2747,10 @@ func TestRuntime_UnmarshalStructWithDefaultValues(t *testing.T) { t.Fatalf("currStruct[num7] exists") } - pathPrefix := jsonFilesPath + jsonInputFilename - actual, err := json.MarshalIndent(v, "", " ") - if err != nil { - t.Fatal(err) - } - err = os.WriteFile(pathPrefix+".output.json", actual, os.ModePerm) + err = compareExpectedJson(jsonInputFilename, *v) if err != nil { t.Fatal(err) } - expected, err := os.ReadFile(pathPrefix + ".json") - if err != nil { - t.Fatal(err) - } - if !bytes.Equal(actual, expected) { - t.Errorf("%s got different results", pathPrefix) - } } func TestRuntime_UnmarshalALotNumbers(t *testing.T) { @@ -3312,22 +2873,10 @@ func TestRuntime_UnmarshalALotNumbers(t *testing.T) { t.Fatalf("num9 != 2342, got %s", val9.String()) } - pathPrefix := jsonFilesPath + jsonInputFilename - actual, err := json.MarshalIndent(v, "", " ") - if err != nil { - t.Fatal(err) - } - err = os.WriteFile(pathPrefix+".output.json", actual, os.ModePerm) - if err != nil { - t.Fatal(err) - } - expected, err := os.ReadFile(pathPrefix + ".json") + err = compareExpectedJson(jsonInputFilename, *v) if err != nil { t.Fatal(err) } - if !bytes.Equal(actual, expected) { - t.Errorf("%s got different results", pathPrefix) - } } func TestRuntime_UnmarshalALotRandomFields(t *testing.T) { @@ -3549,26 +3098,14 @@ func TestRuntime_UnmarshalALotRandomFields(t *testing.T) { if !ok { t.Fatalf("default2.GetSmallInt() not successeded") } - if default2Val != 55 { - t.Fatalf("default2 != 55, got %v", default2Val) - } - - pathPrefix := jsonFilesPath + jsonInputFilename - actual, err := json.MarshalIndent(v, "", " ") - if err != nil { - t.Fatal(err) - } - err = os.WriteFile(pathPrefix+".output.json", actual, os.ModePerm) - if err != nil { - t.Fatal(err) + if default2Val != 55 { + t.Fatalf("default2 != 55, got %v", default2Val) } - expected, err := os.ReadFile(pathPrefix + ".json") + + err = compareExpectedJson(jsonInputFilename, *v) if err != nil { t.Fatal(err) } - if !bytes.Equal(actual, expected) { - t.Errorf("%s got different results", pathPrefix) - } } func TestRuntime_MarshalSmallInt(t *testing.T) { @@ -3606,18 +3143,10 @@ func TestRuntime_MarshalSmallInt(t *testing.T) { t.Errorf("input and output cells are different") } - pathPrefix := jsonFilesPath + jsonInputFilename - actualJson, err := os.ReadFile(pathPrefix + ".json") + err = compareActualJson(jsonInputFilename, *v) if err != nil { t.Fatal(err) } - var jsonV Value - if err := json.Unmarshal(actualJson, &jsonV); err != nil { - t.Fatal(err) - } - if !v.Equal(jsonV) { - t.Errorf("%s got different results", pathPrefix) - } } func TestRuntime_MarshalSmallUInt(t *testing.T) { @@ -3655,18 +3184,10 @@ func TestRuntime_MarshalSmallUInt(t *testing.T) { t.Errorf("input and output cells are different") } - pathPrefix := jsonFilesPath + jsonInputFilename - actualJson, err := os.ReadFile(pathPrefix + ".json") + err = compareActualJson(jsonInputFilename, *v) if err != nil { t.Fatal(err) } - var jsonV Value - if err := json.Unmarshal(actualJson, &jsonV); err != nil { - t.Fatal(err) - } - if !v.Equal(jsonV) { - t.Errorf("%s got different results", pathPrefix) - } } func TestRuntime_MarshalBigInt(t *testing.T) { @@ -3704,18 +3225,10 @@ func TestRuntime_MarshalBigInt(t *testing.T) { t.Errorf("input and output cells are different") } - pathPrefix := jsonFilesPath + jsonInputFilename - actualJson, err := os.ReadFile(pathPrefix + ".json") + err = compareActualJson(jsonInputFilename, *v) if err != nil { t.Fatal(err) } - var jsonV Value - if err := json.Unmarshal(actualJson, &jsonV); err != nil { - t.Fatal(err) - } - if !v.Equal(jsonV) { - t.Errorf("%s got different results", pathPrefix) - } } func TestRuntime_MarshalBigUInt(t *testing.T) { @@ -3753,18 +3266,10 @@ func TestRuntime_MarshalBigUInt(t *testing.T) { t.Errorf("input and output cells are different") } - pathPrefix := jsonFilesPath + jsonInputFilename - actualJson, err := os.ReadFile(pathPrefix + ".json") + err = compareActualJson(jsonInputFilename, *v) if err != nil { t.Fatal(err) } - var jsonV Value - if err := json.Unmarshal(actualJson, &jsonV); err != nil { - t.Fatal(err) - } - if !v.Equal(jsonV) { - t.Errorf("%s got different results", pathPrefix) - } } func TestRuntime_MarshalVarInt(t *testing.T) { @@ -3802,18 +3307,10 @@ func TestRuntime_MarshalVarInt(t *testing.T) { t.Errorf("input and output cells are different") } - pathPrefix := jsonFilesPath + jsonInputFilename - actualJson, err := os.ReadFile(pathPrefix + ".json") + err = compareActualJson(jsonInputFilename, *v) if err != nil { t.Fatal(err) } - var jsonV Value - if err := json.Unmarshal(actualJson, &jsonV); err != nil { - t.Fatal(err) - } - if !v.Equal(jsonV) { - t.Errorf("%s got different results", pathPrefix) - } } func TestRuntime_MarshalVarUInt(t *testing.T) { @@ -3851,18 +3348,10 @@ func TestRuntime_MarshalVarUInt(t *testing.T) { t.Errorf("input and output cells are different") } - pathPrefix := jsonFilesPath + jsonInputFilename - actualJson, err := os.ReadFile(pathPrefix + ".json") + err = compareActualJson(jsonInputFilename, *v) if err != nil { t.Fatal(err) } - var jsonV Value - if err := json.Unmarshal(actualJson, &jsonV); err != nil { - t.Fatal(err) - } - if !v.Equal(jsonV) { - t.Errorf("%s got different results", pathPrefix) - } } func TestRuntime_MarshalBits(t *testing.T) { @@ -3900,18 +3389,10 @@ func TestRuntime_MarshalBits(t *testing.T) { t.Errorf("input and output cells are different") } - pathPrefix := jsonFilesPath + jsonInputFilename - actualJson, err := os.ReadFile(pathPrefix + ".json") + err = compareActualJson(jsonInputFilename, *v) if err != nil { t.Fatal(err) } - var jsonV Value - if err := json.Unmarshal(actualJson, &jsonV); err != nil { - t.Fatal(err) - } - if !v.Equal(jsonV) { - t.Errorf("%s got different results", pathPrefix) - } } func TestRuntime_MarshalCoins(t *testing.T) { @@ -3947,18 +3428,10 @@ func TestRuntime_MarshalCoins(t *testing.T) { t.Errorf("input and output cells are different") } - pathPrefix := jsonFilesPath + jsonInputFilename - actualJson, err := os.ReadFile(pathPrefix + ".json") + err = compareActualJson(jsonInputFilename, *v) if err != nil { t.Fatal(err) } - var jsonV Value - if err := json.Unmarshal(actualJson, &jsonV); err != nil { - t.Fatal(err) - } - if !v.Equal(jsonV) { - t.Errorf("%s got different results", pathPrefix) - } } func TestRuntime_MarshalBool(t *testing.T) { @@ -3994,18 +3467,10 @@ func TestRuntime_MarshalBool(t *testing.T) { t.Errorf("input and output cells are different") } - pathPrefix := jsonFilesPath + jsonInputFilename - actualJson, err := os.ReadFile(pathPrefix + ".json") + err = compareActualJson(jsonInputFilename, *v) if err != nil { t.Fatal(err) } - var jsonV Value - if err := json.Unmarshal(actualJson, &jsonV); err != nil { - t.Fatal(err) - } - if !v.Equal(jsonV) { - t.Errorf("%s got different results", pathPrefix) - } } func TestRuntime_MarshalCell(t *testing.T) { @@ -4041,18 +3506,10 @@ func TestRuntime_MarshalCell(t *testing.T) { t.Errorf("input and output cells are different") } - pathPrefix := jsonFilesPath + jsonInputFilename - actualJson, err := os.ReadFile(pathPrefix + ".json") + err = compareActualJson(jsonInputFilename, *v) if err != nil { t.Fatal(err) } - var jsonV Value - if err := json.Unmarshal(actualJson, &jsonV); err != nil { - t.Fatal(err) - } - if !v.Equal(jsonV) { - t.Errorf("%s got different results", pathPrefix) - } } func TestRuntime_MarshalRemaining(t *testing.T) { @@ -4088,18 +3545,10 @@ func TestRuntime_MarshalRemaining(t *testing.T) { t.Errorf("input and output cells are different") } - pathPrefix := jsonFilesPath + jsonInputFilename - actualJson, err := os.ReadFile(pathPrefix + ".json") + err = compareActualJson(jsonInputFilename, *v) if err != nil { t.Fatal(err) } - var jsonV Value - if err := json.Unmarshal(actualJson, &jsonV); err != nil { - t.Fatal(err) - } - if !v.Equal(jsonV) { - t.Errorf("%s got different results", pathPrefix) - } } func TestRuntime_MarshalAddress(t *testing.T) { @@ -4135,18 +3584,10 @@ func TestRuntime_MarshalAddress(t *testing.T) { t.Errorf("input and output cells are different") } - pathPrefix := jsonFilesPath + jsonInputFilename - actualJson, err := os.ReadFile(pathPrefix + ".json") + err = compareActualJson(jsonInputFilename, *v) if err != nil { t.Fatal(err) } - var jsonV Value - if err := json.Unmarshal(actualJson, &jsonV); err != nil { - t.Fatal(err) - } - if !v.Equal(jsonV) { - t.Errorf("%s got different results", pathPrefix) - } } func TestRuntime_MarshalNotExitsOptionalAddress(t *testing.T) { @@ -4182,18 +3623,10 @@ func TestRuntime_MarshalNotExitsOptionalAddress(t *testing.T) { t.Errorf("input and output cells are different") } - pathPrefix := jsonFilesPath + jsonInputFilename - actualJson, err := os.ReadFile(pathPrefix + ".json") + err = compareActualJson(jsonInputFilename, *v) if err != nil { t.Fatal(err) } - var jsonV Value - if err := json.Unmarshal(actualJson, &jsonV); err != nil { - t.Fatal(err) - } - if !v.Equal(jsonV) { - t.Errorf("%s got different results", pathPrefix) - } } func TestRuntime_MarshalExistsOptionalAddress(t *testing.T) { @@ -4229,18 +3662,10 @@ func TestRuntime_MarshalExistsOptionalAddress(t *testing.T) { t.Errorf("input and output cells are different") } - pathPrefix := jsonFilesPath + jsonInputFilename - actualJson, err := os.ReadFile(pathPrefix + ".json") + err = compareActualJson(jsonInputFilename, *v) if err != nil { t.Fatal(err) } - var jsonV Value - if err := json.Unmarshal(actualJson, &jsonV); err != nil { - t.Fatal(err) - } - if !v.Equal(jsonV) { - t.Errorf("%s got different results", pathPrefix) - } } func TestRuntime_MarshalExternalAddress(t *testing.T) { @@ -4276,18 +3701,10 @@ func TestRuntime_MarshalExternalAddress(t *testing.T) { t.Errorf("input and output cells are different") } - pathPrefix := jsonFilesPath + jsonInputFilename - actualJson, err := os.ReadFile(pathPrefix + ".json") + err = compareActualJson(jsonInputFilename, *v) if err != nil { t.Fatal(err) } - var jsonV Value - if err := json.Unmarshal(actualJson, &jsonV); err != nil { - t.Fatal(err) - } - if !v.Equal(jsonV) { - t.Errorf("%s got different results", pathPrefix) - } } func TestRuntime_MarshalAnyNoneAddress(t *testing.T) { @@ -4323,18 +3740,10 @@ func TestRuntime_MarshalAnyNoneAddress(t *testing.T) { t.Errorf("input and output cells are different") } - pathPrefix := jsonFilesPath + jsonInputFilename - actualJson, err := os.ReadFile(pathPrefix + ".json") + err = compareActualJson(jsonInputFilename, *v) if err != nil { t.Fatal(err) } - var jsonV Value - if err := json.Unmarshal(actualJson, &jsonV); err != nil { - t.Fatal(err) - } - if !v.Equal(jsonV) { - t.Errorf("%s got different results", pathPrefix) - } } func TestRuntime_MarshalAnyInternalAddress(t *testing.T) { @@ -4370,18 +3779,10 @@ func TestRuntime_MarshalAnyInternalAddress(t *testing.T) { t.Errorf("input and output cells are different") } - pathPrefix := jsonFilesPath + jsonInputFilename - actualJson, err := os.ReadFile(pathPrefix + ".json") + err = compareActualJson(jsonInputFilename, *v) if err != nil { t.Fatal(err) } - var jsonV Value - if err := json.Unmarshal(actualJson, &jsonV); err != nil { - t.Fatal(err) - } - if !v.Equal(jsonV) { - t.Errorf("%s got different results", pathPrefix) - } } func TestRuntime_MarshalAnyExternalAddress(t *testing.T) { @@ -4417,18 +3818,10 @@ func TestRuntime_MarshalAnyExternalAddress(t *testing.T) { t.Errorf("input and output cells are different") } - pathPrefix := jsonFilesPath + jsonInputFilename - actualJson, err := os.ReadFile(pathPrefix + ".json") + err = compareActualJson(jsonInputFilename, *v) if err != nil { t.Fatal(err) } - var jsonV Value - if err := json.Unmarshal(actualJson, &jsonV); err != nil { - t.Fatal(err) - } - if !v.Equal(jsonV) { - t.Errorf("%s got different results", pathPrefix) - } } func TestRuntime_MarshalAnyVarAddress(t *testing.T) { @@ -4464,18 +3857,10 @@ func TestRuntime_MarshalAnyVarAddress(t *testing.T) { t.Errorf("input and output cells are different") } - pathPrefix := jsonFilesPath + jsonInputFilename - actualJson, err := os.ReadFile(pathPrefix + ".json") + err = compareActualJson(jsonInputFilename, *v) if err != nil { t.Fatal(err) } - var jsonV Value - if err := json.Unmarshal(actualJson, &jsonV); err != nil { - t.Fatal(err) - } - if !v.Equal(jsonV) { - t.Errorf("%s got different results", pathPrefix) - } } func TestRuntime_MarshalNotExistsNullable(t *testing.T) { @@ -4516,18 +3901,10 @@ func TestRuntime_MarshalNotExistsNullable(t *testing.T) { t.Errorf("input and output cells are different") } - pathPrefix := jsonFilesPath + jsonInputFilename - actualJson, err := os.ReadFile(pathPrefix + ".json") + err = compareActualJson(jsonInputFilename, *v) if err != nil { t.Fatal(err) } - var jsonV Value - if err := json.Unmarshal(actualJson, &jsonV); err != nil { - t.Fatal(err) - } - if !v.Equal(jsonV) { - t.Errorf("%s got different results", pathPrefix) - } } func TestRuntime_MarshalExistsNullable(t *testing.T) { @@ -4568,18 +3945,10 @@ func TestRuntime_MarshalExistsNullable(t *testing.T) { t.Errorf("input and output cells are different") } - pathPrefix := jsonFilesPath + jsonInputFilename - actualJson, err := os.ReadFile(pathPrefix + ".json") + err = compareActualJson(jsonInputFilename, *v) if err != nil { t.Fatal(err) } - var jsonV Value - if err := json.Unmarshal(actualJson, &jsonV); err != nil { - t.Fatal(err) - } - if !v.Equal(jsonV) { - t.Errorf("%s got different results", pathPrefix) - } } func TestRuntime_MarshalRef(t *testing.T) { @@ -4622,18 +3991,10 @@ func TestRuntime_MarshalRef(t *testing.T) { t.Errorf("input and output cells are different") } - pathPrefix := jsonFilesPath + jsonInputFilename - actualJson, err := os.ReadFile(pathPrefix + ".json") + err = compareActualJson(jsonInputFilename, *v) if err != nil { t.Fatal(err) } - var jsonV Value - if err := json.Unmarshal(actualJson, &jsonV); err != nil { - t.Fatal(err) - } - if !v.Equal(jsonV) { - t.Errorf("%s got different results", pathPrefix) - } } func TestRuntime_MarshalEmptyTensor(t *testing.T) { @@ -4669,18 +4030,10 @@ func TestRuntime_MarshalEmptyTensor(t *testing.T) { t.Errorf("input and output cells are different") } - pathPrefix := jsonFilesPath + jsonInputFilename - actualJson, err := os.ReadFile(pathPrefix + ".json") + err = compareActualJson(jsonInputFilename, *v) if err != nil { t.Fatal(err) } - var jsonV Value - if err := json.Unmarshal(actualJson, &jsonV); err != nil { - t.Fatal(err) - } - if !v.Equal(jsonV) { - t.Errorf("%s got different results", pathPrefix) - } } func TestRuntime_MarshalTensor(t *testing.T) { @@ -4763,18 +4116,10 @@ func TestRuntime_MarshalTensor(t *testing.T) { t.Errorf("input and output cells are different") } - pathPrefix := jsonFilesPath + jsonInputFilename - actualJson, err := os.ReadFile(pathPrefix + ".json") + err = compareActualJson(jsonInputFilename, *v) if err != nil { t.Fatal(err) } - var jsonV Value - if err := json.Unmarshal(actualJson, &jsonV); err != nil { - t.Fatal(err) - } - if !v.Equal(jsonV) { - t.Errorf("%s got different results", pathPrefix) - } } func TestRuntime_MarshalIntKeyMap(t *testing.T) { @@ -4821,18 +4166,10 @@ func TestRuntime_MarshalIntKeyMap(t *testing.T) { t.Errorf("input and output cells are different") } - pathPrefix := jsonFilesPath + jsonInputFilename - actualJson, err := os.ReadFile(pathPrefix + ".json") + err = compareActualJson(jsonInputFilename, *v) if err != nil { t.Fatal(err) } - var jsonV Value - if err := json.Unmarshal(actualJson, &jsonV); err != nil { - t.Fatal(err) - } - if !v.Equal(jsonV) { - t.Errorf("%s got different results", pathPrefix) - } } func TestRuntime_MarshalUIntKeyMap(t *testing.T) { @@ -4879,18 +4216,10 @@ func TestRuntime_MarshalUIntKeyMap(t *testing.T) { t.Errorf("input and output cells are different") } - pathPrefix := jsonFilesPath + jsonInputFilename - actualJson, err := os.ReadFile(pathPrefix + ".json") + err = compareActualJson(jsonInputFilename, *v) if err != nil { t.Fatal(err) } - var jsonV Value - if err := json.Unmarshal(actualJson, &jsonV); err != nil { - t.Fatal(err) - } - if !v.Equal(jsonV) { - t.Errorf("%s got different results", pathPrefix) - } } func TestRuntime_MarshalBigIntKeyMap(t *testing.T) { @@ -4937,18 +4266,10 @@ func TestRuntime_MarshalBigIntKeyMap(t *testing.T) { t.Errorf("input and output cells are different") } - pathPrefix := jsonFilesPath + jsonInputFilename - actualJson, err := os.ReadFile(pathPrefix + ".json") + err = compareActualJson(jsonInputFilename, *v) if err != nil { t.Fatal(err) } - var jsonV Value - if err := json.Unmarshal(actualJson, &jsonV); err != nil { - t.Fatal(err) - } - if !v.Equal(jsonV) { - t.Errorf("%s got different results", pathPrefix) - } } func TestRuntime_MarshalBitsKeyMap(t *testing.T) { @@ -5017,18 +4338,10 @@ func TestRuntime_MarshalBitsKeyMap(t *testing.T) { t.Errorf("input and output cells are different") } - pathPrefix := jsonFilesPath + jsonInputFilename - actualJson, err := os.ReadFile(pathPrefix + ".json") + err = compareActualJson(jsonInputFilename, *v) if err != nil { t.Fatal(err) } - var jsonV Value - if err := json.Unmarshal(actualJson, &jsonV); err != nil { - t.Fatal(err) - } - if !v.Equal(jsonV) { - t.Errorf("%s got different results", pathPrefix) - } } func TestRuntime_MarshalAddressKeyMap(t *testing.T) { @@ -5073,18 +4386,10 @@ func TestRuntime_MarshalAddressKeyMap(t *testing.T) { t.Errorf("input and output cells are different") } - pathPrefix := jsonFilesPath + jsonInputFilename - actualJson, err := os.ReadFile(pathPrefix + ".json") + err = compareActualJson(jsonInputFilename, *v) if err != nil { t.Fatal(err) } - var jsonV Value - if err := json.Unmarshal(actualJson, &jsonV); err != nil { - t.Fatal(err) - } - if !v.Equal(jsonV) { - t.Errorf("%s got different results", pathPrefix) - } } func TestRuntime_MarshalUnionWithDecPrefix(t *testing.T) { @@ -5145,18 +4450,10 @@ func TestRuntime_MarshalUnionWithDecPrefix(t *testing.T) { t.Errorf("input and output cells are different") } - pathPrefix := jsonFilesPath + jsonInputFilename - actualJson, err := os.ReadFile(pathPrefix + ".json") + err = compareActualJson(jsonInputFilename, *v) if err != nil { t.Fatal(err) } - var jsonV Value - if err := json.Unmarshal(actualJson, &jsonV); err != nil { - t.Fatal(err) - } - if !v.Equal(jsonV) { - t.Errorf("%s got different results", pathPrefix) - } } func TestRuntime_MarshalUnionWithBinPrefix(t *testing.T) { @@ -5241,18 +4538,10 @@ func TestRuntime_MarshalUnionWithBinPrefix(t *testing.T) { t.Errorf("input and output cells are different") } - pathPrefix := jsonFilesPath + jsonInputFilename - actualJson, err := os.ReadFile(pathPrefix + ".json") + err = compareActualJson(jsonInputFilename, *v) if err != nil { t.Fatal(err) } - var jsonV Value - if err := json.Unmarshal(actualJson, &jsonV); err != nil { - t.Fatal(err) - } - if !v.Equal(jsonV) { - t.Errorf("%s got different results", pathPrefix) - } } func TestRuntime_MarshalUnionWithHexPrefix(t *testing.T) { @@ -5337,18 +4626,10 @@ func TestRuntime_MarshalUnionWithHexPrefix(t *testing.T) { t.Errorf("input and output cells are different") } - pathPrefix := jsonFilesPath + jsonInputFilename - actualJson, err := os.ReadFile(pathPrefix + ".json") + err = compareActualJson(jsonInputFilename, *v) if err != nil { t.Fatal(err) } - var jsonV Value - if err := json.Unmarshal(actualJson, &jsonV); err != nil { - t.Fatal(err) - } - if !v.Equal(jsonV) { - t.Errorf("%s got different results", pathPrefix) - } } func TestRuntime_MarshalALotRefsFromAlias(t *testing.T) { @@ -5408,18 +4689,10 @@ func TestRuntime_MarshalALotRefsFromAlias(t *testing.T) { t.Errorf("input and output cells are different") } - pathPrefix := jsonFilesPath + jsonInputFilename - actualJson, err := os.ReadFile(pathPrefix + ".json") + err = compareActualJson(jsonInputFilename, *v) if err != nil { t.Fatal(err) } - var jsonV Value - if err := json.Unmarshal(actualJson, &jsonV); err != nil { - t.Fatal(err) - } - if !v.Equal(jsonV) { - t.Errorf("%s got different results", pathPrefix) - } } func TestRuntime_MarshalALotRefsFromStruct(t *testing.T) { @@ -5473,18 +4746,10 @@ func TestRuntime_MarshalALotRefsFromStruct(t *testing.T) { t.Errorf("input and output cells are different") } - pathPrefix := jsonFilesPath + jsonInputFilename - actualJson, err := os.ReadFile(pathPrefix + ".json") + err = compareActualJson(jsonInputFilename, *v) if err != nil { t.Fatal(err) } - var jsonV Value - if err := json.Unmarshal(actualJson, &jsonV); err != nil { - t.Fatal(err) - } - if !v.Equal(jsonV) { - t.Errorf("%s got different results", pathPrefix) - } } func TestRuntime_MarshalALotGenericsFromStruct(t *testing.T) { @@ -5546,18 +4811,10 @@ func TestRuntime_MarshalALotGenericsFromStruct(t *testing.T) { t.Errorf("input and output cells are different") } - pathPrefix := jsonFilesPath + jsonInputFilename - actualJson, err := os.ReadFile(pathPrefix + ".json") + err = compareActualJson(jsonInputFilename, *v) if err != nil { t.Fatal(err) } - var jsonV Value - if err := json.Unmarshal(actualJson, &jsonV); err != nil { - t.Fatal(err) - } - if !v.Equal(jsonV) { - t.Errorf("%s got different results", pathPrefix) - } } func TestRuntime_MarshalALotGenericsFromAlias(t *testing.T) { @@ -5619,18 +4876,10 @@ func TestRuntime_MarshalALotGenericsFromAlias(t *testing.T) { t.Errorf("input and output cells are different") } - pathPrefix := jsonFilesPath + jsonInputFilename - actualJson, err := os.ReadFile(pathPrefix + ".json") + err = compareActualJson(jsonInputFilename, *v) if err != nil { t.Fatal(err) } - var jsonV Value - if err := json.Unmarshal(actualJson, &jsonV); err != nil { - t.Fatal(err) - } - if !v.Equal(jsonV) { - t.Errorf("%s got different results", pathPrefix) - } } func TestRuntime_MarshalStructWithDefaultValues(t *testing.T) { @@ -5684,18 +4933,10 @@ func TestRuntime_MarshalStructWithDefaultValues(t *testing.T) { t.Errorf("input and output cells are different") } - pathPrefix := jsonFilesPath + jsonInputFilename - actualJson, err := os.ReadFile(pathPrefix + ".json") + err = compareActualJson(jsonInputFilename, *v) if err != nil { t.Fatal(err) } - var jsonV Value - if err := json.Unmarshal(actualJson, &jsonV); err != nil { - t.Fatal(err) - } - if !v.Equal(jsonV) { - t.Errorf("%s got different results", pathPrefix) - } } func TestRuntime_MarshalALotNumbers(t *testing.T) { @@ -5749,18 +4990,10 @@ func TestRuntime_MarshalALotNumbers(t *testing.T) { t.Errorf("input and output cells are different") } - pathPrefix := jsonFilesPath + jsonInputFilename - actualJson, err := os.ReadFile(pathPrefix + ".json") + err = compareActualJson(jsonInputFilename, *v) if err != nil { t.Fatal(err) } - var jsonV Value - if err := json.Unmarshal(actualJson, &jsonV); err != nil { - t.Fatal(err) - } - if !v.Equal(jsonV) { - t.Errorf("%s got different results", pathPrefix) - } } func TestRuntime_MarshalALotRandomFields(t *testing.T) { @@ -5814,16 +5047,44 @@ func TestRuntime_MarshalALotRandomFields(t *testing.T) { t.Errorf("input and output cells are different") } - pathPrefix := jsonFilesPath + jsonInputFilename - actualJson, err := os.ReadFile(pathPrefix + ".json") + err = compareActualJson(jsonInputFilename, *v) if err != nil { t.Fatal(err) } +} + +func compareActualJson(inputFilename string, v Value) error { + pathPrefix := jsonFilesPath + inputFilename + actualJson, err := os.ReadFile(pathPrefix + ".json") + if err != nil { + return err + } var jsonV Value - if err := json.Unmarshal(actualJson, &jsonV); err != nil { - t.Fatal(err) + if err = json.Unmarshal(actualJson, &jsonV); err != nil { + return err } if !v.Equal(jsonV) { - t.Errorf("%s got different results", pathPrefix) + return fmt.Errorf("%s got different results", pathPrefix) + } + return nil +} + +func compareExpectedJson(inputFilename string, v Value) error { + pathPrefix := jsonFilesPath + inputFilename + actual, err := json.MarshalIndent(v, "", " ") + if err != nil { + return err + } + err = os.WriteFile(pathPrefix+".output.json", actual, os.ModePerm) + if err != nil { + return err + } + expected, err := os.ReadFile(pathPrefix + ".json") + if err != nil { + return err + } + if !bytes.Equal(actual, expected) { + return fmt.Errorf("%s got different results", pathPrefix) } + return nil } diff --git a/tolk/tuples.go b/tolk/tuples.go index 034c62e7..885acdfb 100644 --- a/tolk/tuples.go +++ b/tolk/tuples.go @@ -1,6 +1,8 @@ package tolk import ( + "fmt" + "github.com/tonkeeper/tongo/boc" "github.com/tonkeeper/tongo/tolk/parser" ) @@ -13,7 +15,7 @@ func (v *TupleValues) Unmarshal(cell *boc.Cell, ty tolkParser.TupleWith, decoder inner := Value{} err := inner.Unmarshal(cell, item, decoder) if err != nil { - return err + return fmt.Errorf("failed to unmarshal %v tuple's value: %w", i, err) } list[i] = inner } @@ -25,7 +27,7 @@ func (v *TupleValues) Marshal(cell *boc.Cell, ty tolkParser.TupleWith, encoder * for i, item := range []Value(*v) { err := item.Marshal(cell, ty.Items[i], encoder) if err != nil { - return err + return fmt.Errorf("failed to marshal %v tuple's value: %w", i, err) } } return nil @@ -56,7 +58,7 @@ func (v *TensorValues) Unmarshal(cell *boc.Cell, ty tolkParser.Tensor, decoder * inner := Value{} err := inner.Unmarshal(cell, item, decoder) if err != nil { - return err + return fmt.Errorf("failed to unmarshal %v tensor's value: %w", i, err) } list[i] = inner } @@ -68,7 +70,7 @@ func (v *TensorValues) Marshal(cell *boc.Cell, ty tolkParser.Tensor, encoder *En for i, item := range []Value(*v) { err := item.Marshal(cell, ty.Items[i], encoder) if err != nil { - return err + return fmt.Errorf("failed to marshal %v tensor's value: %w", i, err) } } return nil diff --git a/tolk/union.go b/tolk/union.go index 7ffd3065..4730f35b 100644 --- a/tolk/union.go +++ b/tolk/union.go @@ -21,7 +21,7 @@ func (u *UnionValue) Unmarshal(cell *boc.Cell, ty tolkParser.Union, decoder *Dec 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") + return fmt.Errorf("union prefix length must be less than or equal to 64") } var prefix uint64 @@ -29,20 +29,17 @@ func (u *UnionValue) Unmarshal(cell *boc.Cell, ty tolkParser.Union, decoder *Dec 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 - } + } + if err != nil { + return fmt.Errorf("failed to read union's %v-length prefix: %w", prefixLen, err) } for _, variant := range ty.Variants { variantPrefix, err := PrefixToUint(variant.PrefixStr) if err != nil { - return err + return fmt.Errorf("failed to read union's variant prefi %v: %w", variant.PrefixStr, err) } if prefix == variantPrefix { @@ -53,7 +50,7 @@ func (u *UnionValue) Unmarshal(cell *boc.Cell, ty tolkParser.Union, decoder *Dec innerV := Value{} err = innerV.Unmarshal(cell, variant.VariantTy, decoder) if err != nil { - return err + return fmt.Errorf("failed to unmarshal union value: %w", err) } unionV.Val = innerV *u = unionV @@ -70,24 +67,28 @@ func (u *UnionValue) Marshal(cell *boc.Cell, ty tolkParser.Union, encoder *Encod return fmt.Errorf("union length must be at least 2") } if u.Prefix.Len > 64 { - return fmt.Errorf("union prefix length must be less than 64") + return fmt.Errorf("union prefix length must be less then or equals to 64") } if ty.Variants[0].PrefixEatInPlace { err := cell.WriteUint(u.Prefix.Prefix, int(u.Prefix.Len)) if err != nil { - return err + return fmt.Errorf("failed to write union's %v-length prefix: %w", u.Prefix.Len, err) } } for _, variant := range ty.Variants { variantPrefix, err := PrefixToUint(variant.PrefixStr) if err != nil { - return err + return fmt.Errorf("failed to parse union's variant prefix %v: %w", variant.PrefixStr, err) } if u.Prefix.Prefix == variantPrefix { - return u.Val.Marshal(cell, variant.VariantTy, encoder) + err = u.Val.Marshal(cell, variant.VariantTy, encoder) + if err != nil { + return fmt.Errorf("failed to marshal union value: %w", err) + } + return nil } } diff --git a/tolk/utils.go b/tolk/utils.go index 1aeed3fc..88df53e7 100644 --- a/tolk/utils.go +++ b/tolk/utils.go @@ -3,7 +3,6 @@ package tolk import ( "errors" "fmt" - "math/big" "strconv" ) @@ -15,13 +14,13 @@ func binHexToUint64(s string) (uint64, error) { if s[1] == 'b' { val, err := strconv.ParseUint(s[2:], 2, 64) if err != nil { - return 0, err + return 0, fmt.Errorf("invalid bin number: %v", err) } return val, nil } else if s[1] == 'x' { val, err := strconv.ParseUint(s[2:], 16, 64) if err != nil { - return 0, err + return 0, fmt.Errorf("invalid hex number: %v", err) } return val, nil } else { @@ -29,40 +28,6 @@ func binHexToUint64(s string) (uint64, error) { } } -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") @@ -71,7 +36,7 @@ func PrefixToUint(prefix string) (uint64, error) { if len(prefix) == 1 { intPrefix, err := strconv.ParseUint(prefix, 10, 64) if err != nil { - return 0, err + return 0, fmt.Errorf("invalid dec prefix: %v", err) } return intPrefix, nil @@ -86,12 +51,12 @@ func PrefixToUint(prefix string) (uint64, error) { if prefix[1] == 'b' { intPrefix, err = strconv.ParseUint(prefix[2:], 2, 64) if err != nil { - return 0, err + return 0, fmt.Errorf("invalid bin prefix: %v", err) } } else if prefix[1] == 'x' { intPrefix, err = strconv.ParseUint(prefix[2:], 16, 64) if err != nil { - return 0, err + return 0, fmt.Errorf("invalid hex prefix: %v", err) } } else { return 0, fmt.Errorf("prefix tag must be either binary or hex format") diff --git a/tolk/value.go b/tolk/value.go index ddb9d71c..ef350b63 100644 --- a/tolk/value.go +++ b/tolk/value.go @@ -3,17 +3,28 @@ package tolk // todo: move this to some package or rename somehow. import ( - "encoding/hex" "fmt" "math/big" "github.com/tonkeeper/tongo/boc" "github.com/tonkeeper/tongo/tolk/parser" - "github.com/tonkeeper/tongo/ton" + "github.com/tonkeeper/tongo/utils" ) type SumType string +func (s SumType) MarshalJSON() ([]byte, error) { + return []byte(`"` + utils.ToCamelCasePrivate(string(s)) + `"`), nil +} + +func (s *SumType) UnmarshalJSON(bytes []byte) error { + if len(bytes) < 2 { + return fmt.Errorf("invalid SumType value: %s", string(bytes)) + } + *s = SumType(bytes[1 : len(bytes)-1]) + return nil +} + type Value struct { SumType SumType `json:"sumType"` Bool *BoolValue `json:"bool,omitempty"` @@ -399,320 +410,218 @@ func (v *Value) GetType() string { return string(v.SumType) } -func (v *Value) SetValue(val any, ty tolkParser.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.Map = &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.Struct = &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 -} - func (v *Value) Unmarshal(cell *boc.Cell, ty tolkParser.Ty, decoder *Decoder) error { var err error switch ty.SumType { case "IntN": if ty.IntN.N <= 64 { - v.SumType = "smallInt" + v.SumType = "SmallInt" def := Int64(0) v.SmallInt = &def err = v.SmallInt.Unmarshal(cell, *ty.IntN, decoder) + if err != nil { + return fmt.Errorf("failed to unmarshal small int value: %w", err) + } } else { - v.SumType = "bigInt" + v.SumType = "BigInt" v.BigInt = &BigInt{} err = v.BigInt.Unmarshal(cell, *ty.IntN, decoder) + if err != nil { + return fmt.Errorf("failed to unmarshal big int value: %w", err) + } } case "UintN": if ty.UintN.N <= 64 { - v.SumType = "smallUint" + v.SumType = "SmallUint" def := UInt64(0) v.SmallUint = &def err = v.SmallUint.Unmarshal(cell, *ty.UintN, decoder) + if err != nil { + return fmt.Errorf("failed to unmarshal small uint value: %w", err) + } } else { - v.SumType = "bigUint" + v.SumType = "BigUint" v.BigUint = &BigUInt{} err = v.BigUint.Unmarshal(cell, *ty.UintN, decoder) + if err != nil { + return fmt.Errorf("failed to unmarshal big uint value: %w", err) + } } case "VarIntN": - v.SumType = "varInt" + v.SumType = "VarInt" v.VarInt = &VarInt{} err = v.VarInt.Unmarshal(cell, *ty.VarIntN, decoder) + if err != nil { + return fmt.Errorf("failed to unmarshal var int value: %w", err) + } case "VarUintN": - v.SumType = "varUint" + v.SumType = "VarUint" v.VarUint = &VarUInt{} err = v.VarUint.Unmarshal(cell, *ty.VarUintN, decoder) + if err != nil { + return fmt.Errorf("failed to unmarshal var uint value: %w", err) + } case "BitsN": - v.SumType = "bits" + v.SumType = "Bits" v.Bits = &Bits{} err = v.Bits.Unmarshal(cell, *ty.BitsN, decoder) + if err != nil { + return fmt.Errorf("failed to unmarshal bits value: %w", err) + } case "Nullable": - v.SumType = "optionalValue" + v.SumType = "OptionalValue" v.OptionalValue = &OptValue{} err = v.OptionalValue.Unmarshal(cell, *ty.Nullable, decoder) + if err != nil { + return fmt.Errorf("failed to unmarshal nullable value: %w", err) + } case "CellOf": - v.SumType = "refValue" + v.SumType = "RefValue" v.RefValue = &RefValue{} err = v.RefValue.Unmarshal(cell, *ty.CellOf, decoder) + if err != nil { + return fmt.Errorf("failed to unmarshal cell of: %w", err) + } case "Tensor": - v.SumType = "tensor" + v.SumType = "Tensor" v.Tensor = &TensorValues{} err = v.Tensor.Unmarshal(cell, *ty.Tensor, decoder) + if err != nil { + return fmt.Errorf("failed to unmarshal tensor value: %w", err) + } case "TupleWith": - v.SumType = "tupleWith" + v.SumType = "TupleWith" v.TupleWith = &TupleValues{} err = v.TupleWith.Unmarshal(cell, *ty.TupleWith, decoder) + if err != nil { + return fmt.Errorf("failed to unmarshal tuple value: %w", err) + } case "Map": - v.SumType = "map" + v.SumType = "Map" v.Map = &MapValue{} err = v.Map.Unmarshal(cell, *ty.Map, decoder) + if err != nil { + return fmt.Errorf("failed to unmarshal map value: %w", err) + } case "EnumRef": - v.SumType = "enum" + v.SumType = "Enum" v.Enum = &EnumValue{} err = v.Enum.Unmarshal(cell, *ty.EnumRef, decoder) + if err != nil { + return fmt.Errorf("failed to unmarshal enum value: %w", err) + } case "StructRef": - v.SumType = "struct" + v.SumType = "Struct" v.Struct = &Struct{} err = v.Struct.Unmarshal(cell, *ty.StructRef, decoder) + if err != nil { + return fmt.Errorf("failed to unmarshal struct value: %w", err) + } case "AliasRef": - v.SumType = "alias" + v.SumType = "Alias" v.Alias = &AliasValue{} err = v.Alias.Unmarshal(cell, *ty.AliasRef, decoder) + if err != nil { + return fmt.Errorf("failed to unmarshal alias value: %w", err) + } case "Generic": - v.SumType = "generic" + v.SumType = "Generic" v.Generic = &GenericValue{} err = v.Generic.Unmarshal(cell, *ty.Generic, decoder) + if err != nil { + return fmt.Errorf("failed to unmarshal generic value: %w", err) + } case "Union": - v.SumType = "union" + v.SumType = "Union" v.Union = &UnionValue{} err = v.Union.Unmarshal(cell, *ty.Union, decoder) + if err != nil { + return fmt.Errorf("failed to unmarshal union value: %w", err) + } case "Int": - err = fmt.Errorf("int not supported") + err = fmt.Errorf("failed to unmarshal int value: int is not supported") case "Coins": - v.SumType = "coins" + v.SumType = "Coins" v.Coins = &CoinsValue{} err = v.Coins.Unmarshal(cell, *ty.Coins, decoder) + if err != nil { + return fmt.Errorf("failed to unmarshal coins value: %w", err) + } case "Bool": - v.SumType = "bool" + v.SumType = "Bool" def := BoolValue(false) v.Bool = &def err = v.Bool.Unmarshal(cell, *ty.Bool, decoder) + if err != nil { + return fmt.Errorf("failed to unmarshal bool value: %w", err) + } case "Cell": - v.SumType = "cell" + v.SumType = "Cell" v.Cell = &Any{} err = v.Cell.Unmarshal(cell, *ty.Cell, decoder) + if err != nil { + return fmt.Errorf("failed to unmarshal cell value: %w", err) + } case "Slice": - err = fmt.Errorf("slice not supported") + err = fmt.Errorf("failed to unmarshal slice value: slice is not supported") case "Builder": - err = fmt.Errorf("builder not supported") + err = fmt.Errorf("failed to unmarshal builder value: builder is not supported") case "Callable": - err = fmt.Errorf("callable not supported") + err = fmt.Errorf("failed to unmarshal callable value: callable is not supported") case "Remaining": - v.SumType = "remaining" + v.SumType = "Remaining" v.Remaining = &RemainingValue{} err = v.Remaining.Unmarshal(cell, *ty.Remaining, decoder) + if err != nil { + return fmt.Errorf("failed to unmarshal remaining value: %w", err) + } case "Address": - v.SumType = "internalAddress" + v.SumType = "InternalAddress" v.InternalAddress = &InternalAddress{} err = v.InternalAddress.Unmarshal(cell, *ty.Address, decoder) + if err != nil { + return fmt.Errorf("failed to unmarshal internal address value: %w", err) + } case "AddressOpt": - v.SumType = "optionalAddress" + v.SumType = "OptionalAddress" v.OptionalAddress = &OptionalAddress{} err = v.OptionalAddress.Unmarshal(cell, *ty.AddressOpt, decoder) + if err != nil { + return fmt.Errorf("failed to unmarshal optional address value: %w", err) + } case "AddressExt": - v.SumType = "externalAddress" + v.SumType = "ExternalAddress" v.ExternalAddress = &ExternalAddress{} err = v.ExternalAddress.Unmarshal(cell, *ty.AddressExt, decoder) + if err != nil { + return fmt.Errorf("failed to unmarshal external address value: %w", err) + } case "AddressAny": - v.SumType = "anyAddress" + v.SumType = "AnyAddress" v.AnyAddress = &AnyAddress{} err = v.AnyAddress.Unmarshal(cell, *ty.AddressAny, decoder) + if err != nil { + return fmt.Errorf("failed to unmarshal any address value: %w", err) + } case "TupleAny": - err = fmt.Errorf("tuple any not supported") + err = fmt.Errorf("failed to unmarshal tuple any value: tuple any is not supported") case "NullLiteral": - v.SumType = "null" + v.SumType = "Null" v.Null = &NullValue{} err = v.Null.Unmarshal(cell, *ty.NullLiteral, decoder) + if err != nil { + return fmt.Errorf("failed to unmarshal null value: %w", err) + } case "Void": - v.SumType = "void" + v.SumType = "Void" v.Void = &VoidValue{} err = v.Void.Unmarshal(cell, *ty.Void, decoder) + if err != nil { + return fmt.Errorf("failed to unmarshal void value: %w", err) + } default: return fmt.Errorf("unknown ty type %q", ty.SumType) } - if err != nil { - return err - } return nil } @@ -721,228 +630,238 @@ func (v *Value) Marshal(cell *boc.Cell, ty tolkParser.Ty, encoder *Encoder) erro switch ty.SumType { case "IntN": if ty.IntN.N <= 64 { - if v.SumType != "smallInt" { - return fmt.Errorf("expected smallInt, but got %v", v.SumType) + if v.SumType != "SmallInt" { + return fmt.Errorf("expected SmallInt, but got %v", v.SumType) + } + err = v.SmallInt.Marshal(cell, *ty.IntN, encoder) + if err != nil { + return fmt.Errorf("failed to marshal small int value: %w", err) } - return v.SmallInt.Marshal(cell, *ty.IntN, encoder) } else { - if v.SumType != "bigInt" { - return fmt.Errorf("expected bigInt, but got %v", v.SumType) + if v.SumType != "BigInt" { + return fmt.Errorf("expected BigInt, but got %v", v.SumType) + } + err = v.BigInt.Marshal(cell, *ty.IntN, encoder) + if err != nil { + return fmt.Errorf("failed to marshal big int value: %w", err) } - return v.BigInt.Marshal(cell, *ty.IntN, encoder) } case "UintN": if ty.UintN.N <= 64 { - if v.SumType != "smallUint" { - return fmt.Errorf("expected smallUint, but got %v", v.SumType) + if v.SumType != "SmallUint" { + return fmt.Errorf("expected SmallUint, but got %v", v.SumType) + } + err = v.SmallUint.Marshal(cell, *ty.UintN, encoder) + if err != nil { + return fmt.Errorf("failed to marshal small uint value: %w", err) } - return v.SmallUint.Marshal(cell, *ty.UintN, encoder) } else { - if v.SumType != "bigUint" { - return fmt.Errorf("expected bigUint, but got %v", v.SumType) + if v.SumType != "BigUint" { + return fmt.Errorf("expected BigUint, but got %v", v.SumType) + } + err = v.BigUint.Marshal(cell, *ty.UintN, encoder) + if err != nil { + return fmt.Errorf("failed to marshal big uint value: %w", err) } - return v.BigUint.Marshal(cell, *ty.UintN, encoder) } case "VarIntN": - if v.SumType != "varInt" { - return fmt.Errorf("expected varInt, but got %v", v.SumType) + if v.SumType != "VarInt" { + return fmt.Errorf("expected VarInt, but got %v", v.SumType) + } + err = v.VarInt.Marshal(cell, *ty.VarIntN, encoder) + if err != nil { + return fmt.Errorf("failed to marshal var int value: %w", err) } - return v.VarInt.Marshal(cell, *ty.VarIntN, encoder) case "VarUintN": - if v.SumType != "varUint" { - return fmt.Errorf("expected varUint, but got %v", v.SumType) + if v.SumType != "VarUint" { + return fmt.Errorf("expected VarUint, but got %v", v.SumType) + } + err = v.VarUint.Marshal(cell, *ty.VarUintN, encoder) + if err != nil { + return fmt.Errorf("failed to marshal var uint value: %w", err) } - return v.VarUint.Marshal(cell, *ty.VarUintN, encoder) case "BitsN": - if v.SumType != "bits" { - return fmt.Errorf("expected bits, but got %v", v.SumType) + if v.SumType != "Bits" { + return fmt.Errorf("expected Bits, but got %v", v.SumType) + } + err = v.Bits.Marshal(cell, *ty.BitsN, encoder) + if err != nil { + return fmt.Errorf("failed to marshal bits value: %w", err) } - return v.Bits.Marshal(cell, *ty.BitsN, encoder) case "Nullable": - if v.SumType != "optionalValue" { - return fmt.Errorf("expected optionalValue, but got %v", v.SumType) + if v.SumType != "OptionalValue" { + return fmt.Errorf("expected OptionalValue, but got %v", v.SumType) + } + err = v.OptionalValue.Marshal(cell, *ty.Nullable, encoder) + if err != nil { + return fmt.Errorf("failed to marshal nullable value: %w", err) } - return v.OptionalValue.Marshal(cell, *ty.Nullable, encoder) case "CellOf": - if v.SumType != "refValue" { - return fmt.Errorf("expected refValue, but got %v", v.SumType) + if v.SumType != "RefValue" { + return fmt.Errorf("expected RefValue, but got %v", v.SumType) + } + err = v.RefValue.Marshal(cell, *ty.CellOf, encoder) + if err != nil { + return fmt.Errorf("failed to marshal cell of value: %w", err) } - return v.RefValue.Marshal(cell, *ty.CellOf, encoder) case "Tensor": - if v.SumType != "tensor" { - return fmt.Errorf("expected tensor, but got %v", v.SumType) + if v.SumType != "Tensor" { + return fmt.Errorf("expected Tensor, but got %v", v.SumType) + } + err = v.Tensor.Marshal(cell, *ty.Tensor, encoder) + if err != nil { + return fmt.Errorf("failed to marshal tensor value: %w", err) } - return v.Tensor.Marshal(cell, *ty.Tensor, encoder) case "TupleWith": - if v.SumType != "tupleWith" { - return fmt.Errorf("expected tupleWith, but got %v", v.SumType) + if v.SumType != "TupleWith" { + return fmt.Errorf("expected TupleWith, but got %v", v.SumType) + } + err = v.TupleWith.Marshal(cell, *ty.TupleWith, encoder) + if err != nil { + return fmt.Errorf("failed to marshal tuple value: %w", err) } - return v.TupleWith.Marshal(cell, *ty.TupleWith, encoder) case "Map": - if v.SumType != "map" { - return fmt.Errorf("expected map, but got %v", v.SumType) + if v.SumType != "Map" { + return fmt.Errorf("expected Map, but got %v", v.SumType) + } + err = v.Map.Marshal(cell, *ty.Map, encoder) + if err != nil { + return fmt.Errorf("failed to marshal map value: %w", err) } - return v.Map.Marshal(cell, *ty.Map, encoder) case "EnumRef": - if v.SumType != "enum" { - return fmt.Errorf("expected enum, but got %v", v.SumType) + if v.SumType != "Enum" { + return fmt.Errorf("expected Enum, but got %v", v.SumType) + } + err = v.Enum.Marshal(cell, *ty.EnumRef, encoder) + if err != nil { + return fmt.Errorf("failed to marshal enum value: %w", err) } - return v.Enum.Marshal(cell, *ty.EnumRef, encoder) case "StructRef": - if v.SumType != "struct" { - return fmt.Errorf("expected struct, but got %v", v.SumType) + if v.SumType != "Struct" { + return fmt.Errorf("expected Struct, but got %v", v.SumType) + } + err = v.Struct.Marshal(cell, *ty.StructRef, encoder) + if err != nil { + return fmt.Errorf("failed to marshal struct value: %w", err) } - return v.Struct.Marshal(cell, *ty.StructRef, encoder) case "AliasRef": - if v.SumType != "alias" { - return fmt.Errorf("expected alias, but got %v", v.SumType) + if v.SumType != "Alias" { + return fmt.Errorf("expected Alias, but got %v", v.SumType) + } + err = v.Alias.Marshal(cell, *ty.AliasRef, encoder) + if err != nil { + return fmt.Errorf("failed to marshal alias value: %w", err) } - return v.Alias.Marshal(cell, *ty.AliasRef, encoder) case "Generic": - if v.SumType != "generic" { - return fmt.Errorf("expected generic, but got %v", v.SumType) + if v.SumType != "Generic" { + return fmt.Errorf("expected Generic, but got %v", v.SumType) + } + err = v.Generic.Marshal(cell, *ty.Generic, encoder) + if err != nil { + return fmt.Errorf("failed to marshal generic value: %w", err) } - return v.Generic.Marshal(cell, *ty.Generic, encoder) case "Union": - if v.SumType != "union" { - return fmt.Errorf("expected union, but got %v", v.SumType) + if v.SumType != "Union" { + return fmt.Errorf("expected Union, but got %v", v.SumType) + } + err = v.Union.Marshal(cell, *ty.Union, encoder) + if err != nil { + return fmt.Errorf("failed to marshal union value: %w", err) } - return v.Union.Marshal(cell, *ty.Union, encoder) case "Int": - err = fmt.Errorf("int not supported") + err = fmt.Errorf("failed to marshal int value: int is not supported") case "Coins": - if v.SumType != "coins" { - return fmt.Errorf("expected coins, but got %v", v.SumType) + if v.SumType != "Coins" { + return fmt.Errorf("expected Coins, but got %v", v.SumType) + } + err = v.Coins.Marshal(cell, *ty.Coins, encoder) + if err != nil { + return fmt.Errorf("failed to marshal coins value: %w", err) } - return v.Coins.Marshal(cell, *ty.Coins, encoder) case "Bool": - if v.SumType != "bool" { - return fmt.Errorf("expected bool, but got %v", v.SumType) + if v.SumType != "Bool" { + return fmt.Errorf("expected Bool, but got %v", v.SumType) + } + err = v.Bool.Marshal(cell, *ty.Bool, encoder) + if err != nil { + return fmt.Errorf("failed to marshal bool value: %w", err) } - return v.Bool.Marshal(cell, *ty.Bool, encoder) case "Cell": - if v.SumType != "cell" { - return fmt.Errorf("expected cell, but got %v", v.SumType) + if v.SumType != "Cell" { + return fmt.Errorf("expected Cell, but got %v", v.SumType) + } + err = v.Cell.Marshal(cell, *ty.Cell, encoder) + if err != nil { + return fmt.Errorf("failed to marshal cell value: %w", err) } - return v.Cell.Marshal(cell, *ty.Cell, encoder) case "Slice": - err = fmt.Errorf("slice not supported") + err = fmt.Errorf("failed to marshal slice value: slice is not supported") case "Builder": - err = fmt.Errorf("builder not supported") + err = fmt.Errorf("failed to marshal builder value: builder is not supported") case "Callable": - err = fmt.Errorf("callable not supported") + err = fmt.Errorf("failed to marshal int callable: callable is not supported") case "Remaining": - if v.SumType != "remaining" { - return fmt.Errorf("expected remaining, but got %v", v.SumType) + if v.SumType != "Remaining" { + return fmt.Errorf("expected Remaining, but got %v", v.SumType) } - return v.Remaining.Marshal(cell, *ty.Remaining, encoder) - case "Address": - if v.SumType != "internalAddress" { - return fmt.Errorf("expected internalAddress, but got %v", v.SumType) - } - return v.InternalAddress.Marshal(cell, *ty.Address, encoder) - case "AddressOpt": - if v.SumType != "optionalAddress" { - return fmt.Errorf("expected optionalAddress, but got %v", v.SumType) - } - return v.OptionalAddress.Marshal(cell, *ty.AddressOpt, encoder) - case "AddressExt": - if v.SumType != "externalAddress" { - return fmt.Errorf("expected externalAddress, but got %v", v.SumType) - } - return v.ExternalAddress.Marshal(cell, *ty.AddressExt, encoder) - case "AddressAny": - if v.SumType != "anyAddress" { - return fmt.Errorf("expected anyAddress, but got %v", v.SumType) - } - return v.AnyAddress.Marshal(cell, *ty.AddressAny, encoder) - case "TupleAny": - err = fmt.Errorf("tuple any not supported") - case "NullLiteral": - if v.SumType != "null" { - return fmt.Errorf("expected null, but got %v", v.SumType) + err = v.Remaining.Marshal(cell, *ty.Remaining, encoder) + if err != nil { + return fmt.Errorf("failed to marshal remaining value: %w", err) } - return v.Null.Marshal(cell, *ty.NullLiteral, encoder) - case "Void": - if v.SumType != "void" { - return fmt.Errorf("expected void, but got %v", v.SumType) + case "Address": + if v.SumType != "InternalAddress" { + return fmt.Errorf("expected InternalAddress, but got %v", v.SumType) } - return v.Void.Marshal(cell, *ty.Void, encoder) - default: - err = fmt.Errorf("unknown ty type %q", ty.SumType) - } - if err != nil { - return err - } - return nil -} - -func (v *Value) unmarshalDefaultValue(d *tolkParser.DefaultValue, vType tolkParser.Ty) (bool, error) { - switch d.SumType { - case "IntDefaultValue": - val, err := binDecHexToUint(d.IntDefaultValue.V) + err = v.InternalAddress.Marshal(cell, *ty.Address, encoder) if err != nil { - return false, err + return fmt.Errorf("failed to marshal internal address value: %w", err) } - err = v.SetValue(BigInt(*val), vType) - if err != nil { - return false, err + case "AddressOpt": + if v.SumType != "OptionalAddress" { + return fmt.Errorf("expected OptionalAddress, but got %v", v.SumType) } - case "BoolDefaultValue": - err := v.SetValue(BoolValue(d.BoolDefaultValue.V), vType) + err = v.OptionalAddress.Marshal(cell, *ty.AddressOpt, encoder) if err != nil { - return false, err + return fmt.Errorf("failed to marshal optional address value: %w", err) } - case "SliceDefaultValue": - val, err := hex.DecodeString(d.SliceDefaultValue.Hex) - if err != nil { - return false, err + case "AddressExt": + if v.SumType != "ExternalAddress" { + return fmt.Errorf("expected ExternalAddress, but got %v", v.SumType) } - bs := boc.NewBitString(hex.DecodedLen(len(val))) - err = bs.WriteBytes(val) + err = v.ExternalAddress.Marshal(cell, *ty.AddressExt, encoder) if err != nil { - return false, err + return fmt.Errorf("failed to marshal external address value: %w", err) } - err = v.SetValue(*boc.NewCellWithBits(bs), vType) - if err != nil { - return false, err + case "AddressAny": + if v.SumType != "AnyAddress" { + return fmt.Errorf("expected AnyAddress, but got %v", v.SumType) } - case "AddressDefaultValue": - accountID, err := ton.ParseAccountID(d.AddressDefaultValue.Address) + err = v.AnyAddress.Marshal(cell, *ty.AddressAny, encoder) if err != nil { - return false, err + return fmt.Errorf("failed to marshal any address value: %w", err) } - err = v.SetValue(InternalAddress{ - Workchain: int8(accountID.Workchain), - Address: accountID.Address, - }, vType) - if err != nil { - return false, err + case "TupleAny": + err = fmt.Errorf("failed to marshal tuple any value: tuple any not supported") + case "NullLiteral": + if v.SumType != "Null" { + return fmt.Errorf("expected Null, but got %v", v.SumType) } - case "TensorDefaultValue": - if vType.SumType != "Tensor" { - return false, fmt.Errorf("tensor default value type must be tensor, got %q", d.SumType) + err = v.Null.Marshal(cell, *ty.NullLiteral, encoder) + if err != nil { + return fmt.Errorf("failed to marshal null value: %w", err) } - tensor := make([]Value, len(d.TensorDefaultValue.Items)) - for i, item := range d.TensorDefaultValue.Items { - val := Value{} - _, err := v.unmarshalDefaultValue(&item, vType.Tensor.Items[i]) - if err != nil { - return false, err - } - tensor[i] = val + case "Void": + if v.SumType != "Void" { + return fmt.Errorf("expected Void, but got %v", v.SumType) } - err := v.SetValue(tensor, vType) + err = v.Void.Marshal(cell, *ty.Void, encoder) if err != nil { - return false, err + return fmt.Errorf("failed to marshal void value: %w", err) } - case "NullDefaultValue": - return false, nil default: - return false, fmt.Errorf("unknown default value type %q", d.SumType) + err = fmt.Errorf("unknown ty type %q", ty.SumType) } - - return true, nil + return nil } func (v *Value) Equal(o any) bool { @@ -952,137 +871,137 @@ func (v *Value) Equal(o any) bool { } switch v.SumType { - case "bool": + case "Bool": if otherValue.Bool == nil { return false } return v.Bool.Equal(*otherValue.Bool) - case "smallInt": + case "SmallInt": if otherValue.SmallInt == nil { return false } return v.SmallInt.Equal(*otherValue.SmallInt) - case "smallUint": + case "SmallUint": if otherValue.SmallUint == nil { return false } return v.SmallUint.Equal(*otherValue.SmallUint) - case "bigInt": + case "BigInt": if otherValue.BigInt == nil { return false } return v.BigInt.Equal(*otherValue.BigInt) - case "bigUint": + case "BigUint": if otherValue.BigUint == nil { return false } return v.BigUint.Equal(*otherValue.BigUint) - case "varInt": + case "VarInt": if otherValue.VarInt == nil { return false } return v.VarInt.Equal(*otherValue.VarInt) - case "varUint": + case "VarUint": if otherValue.VarUint == nil { return false } return v.VarUint.Equal(*otherValue.VarUint) - case "coins": + case "Coins": if otherValue.Coins == nil { return false } return v.Coins.Equal(*otherValue.Coins) - case "bits": + case "Bits": if otherValue.Bits == nil { return false } return v.Bits.Equal(*otherValue.Bits) - case "cell": + case "Cell": if otherValue.Cell == nil { return false } return v.Cell.Equal(*otherValue.Cell) - case "remaining": + case "Remaining": if otherValue.Remaining == nil { return false } return v.Remaining.Equal(*otherValue.Remaining) - case "internalAddress": + case "InternalAddress": if otherValue.InternalAddress == nil { return false } return v.InternalAddress.Equal(*otherValue.InternalAddress) - case "optionalAddress": + case "OptionalAddress": if otherValue.OptionalAddress == nil { return false } return v.OptionalAddress.Equal(*otherValue.OptionalAddress) - case "externalAddress": + case "ExternalAddress": if otherValue.ExternalAddress == nil { return false } return v.ExternalAddress.Equal(*otherValue.ExternalAddress) - case "anyAddress": + case "AnyAddress": if otherValue.AnyAddress == nil { return false } return v.AnyAddress.Equal(*otherValue.AnyAddress) - case "optionalValue": + case "OptionalValue": if otherValue.OptionalValue == nil { return false } return v.OptionalValue.Equal(*otherValue.OptionalValue) - case "refValue": + case "RefValue": if otherValue.RefValue == nil { return false } return v.RefValue.Equal(*otherValue.RefValue) - case "tupleWith": + case "TupleWith": if otherValue.TupleWith == nil { return false } return v.TupleWith.Equal(*otherValue.TupleWith) - case "tensor": + case "Tensor": if otherValue.Tensor == nil { return false } return v.Tensor.Equal(*otherValue.Tensor) - case "map": + case "Map": if otherValue.Map == nil { return false } return v.Map.Equal(*otherValue.Map) - case "struct": + case "Struct": if otherValue.Struct == nil { return false } return v.Struct.Equal(*otherValue.Struct) - case "alias": + case "Alias": if otherValue.Alias == nil { return false } return v.Alias.Equal(*otherValue.Alias) - case "enum": + case "Enum": if otherValue.Enum == nil { return false } return v.Enum.Equal(*otherValue.Enum) - case "generic": + case "Generic": if otherValue.Generic == nil { return false } return v.Generic.Equal(*otherValue.Generic) - case "union": + case "Union": if otherValue.Union == nil { return false } return v.Union.Equal(*otherValue.Union) - case "null": + case "Null": if otherValue.Null == nil { return false } return v.Null.Equal(*otherValue.Null) - case "void": + case "Void": if otherValue.Void == nil { return false } diff --git a/utils/generator_test.go b/utils/generator_test.go index 916e0600..729c8ecb 100644 --- a/utils/generator_test.go +++ b/utils/generator_test.go @@ -31,6 +31,10 @@ func TestToSnakeCaseString(t *testing.T) { data: "COcoon123Test", want: "c_ocoon123_test", }, + { + data: "FunC", + want: "fun_c", + }, } for _, tt := range tests { t.Run(tt.data, func(t *testing.T) { diff --git a/utils/json.go b/utils/json.go index 2682e770..66f87248 100644 --- a/utils/json.go +++ b/utils/json.go @@ -4,6 +4,9 @@ func ConcatPrefixAndSuffixIfExists(prefix, suffix []byte) []byte { if len(suffix) == 0 { return prefix } + if len(prefix) == 0 { + return suffix + } prefix = prefix[:len(prefix)-1] // remove '}' suffix[0] = ',' // replace '{' with ',' result := make([]byte, 0, len(prefix)+len(suffix)) From 6be3eb02bb33482ccf807213f5c787509b3262fd Mon Sep 17 00:00:00 2001 From: Pavel Levchenko Date: Sun, 15 Feb 2026 17:59:41 +0300 Subject: [PATCH 09/16] add shortcuts for tolk type creation --- examples/tolk/main.go | 7 +- tolk/parser/shortcuts.go | 243 +++++++++ tolk/runtime_test.go | 1004 ++++++-------------------------------- 3 files changed, 386 insertions(+), 868 deletions(-) create mode 100644 tolk/parser/shortcuts.go diff --git a/examples/tolk/main.go b/examples/tolk/main.go index 106d83c2..0d427460 100644 --- a/examples/tolk/main.go +++ b/examples/tolk/main.go @@ -22,12 +22,7 @@ func main() { panic(err) } - ty := tolkParser.Ty{ - SumType: "StructRef", - StructRef: &tolkParser.StructRef{ - StructName: "Transfer", - }, - } + ty := tolkParser.NewStructType("Transfer") b, err := hex.DecodeString("b5ee9c72c10101010056000000a75fcc3d140000000000000000800c0674dd00e3a7231084788441cc873e60eb8681f44901cba3a9107c5c322dc4500034a37c6673343b360e10d4e438483b555805a20e5f056742b6a42ba35311994c802625a008a90c976e") if err != nil { panic(err) diff --git a/tolk/parser/shortcuts.go b/tolk/parser/shortcuts.go new file mode 100644 index 00000000..cbe090f2 --- /dev/null +++ b/tolk/parser/shortcuts.go @@ -0,0 +1,243 @@ +package tolkParser + +func NewIntNType(n int) Ty { + return Ty{ + SumType: "IntN", + IntN: &IntN{ + N: n, + }, + } +} + +func NewUIntNType(n int) Ty { + return Ty{ + SumType: "UintN", + UintN: &UintN{ + N: n, + }, + } +} + +func NewVarInt16Type() Ty { + return Ty{ + SumType: "VarIntN", + VarIntN: &VarIntN{ + N: 16, + }, + } +} + +func NewVarInt32Type() Ty { + return Ty{ + SumType: "VarIntN", + VarIntN: &VarIntN{ + N: 32, + }, + } +} + +func NewVarIntType(n int) Ty { + return Ty{ + SumType: "VarIntN", + VarIntN: &VarIntN{ + N: n, + }, + } +} + +func NewVarUInt16Type() Ty { + return Ty{ + SumType: "VarUintN", + VarUintN: &VarUintN{ + N: 16, + }, + } +} + +func NewVarUInt32Type() Ty { + return Ty{ + SumType: "VarUintN", + VarUintN: &VarUintN{ + N: 32, + }, + } +} + +func NewVarUIntType(n int) Ty { + return Ty{ + SumType: "VarUintN", + VarUintN: &VarUintN{ + N: n, + }, + } +} + +func NewBitsNType(n int) Ty { + return Ty{ + SumType: "BitsN", + BitsN: &BitsN{ + N: n, + }, + } +} + +func NewCoinsType() Ty { + return Ty{ + SumType: "Coins", + Coins: &Coins{}, + } +} + +func NewBoolType() Ty { + return Ty{ + SumType: "Bool", + Bool: &Bool{}, + } +} + +func NewCellType() Ty { + return Ty{ + SumType: "Cell", + Cell: &Cell{}, + } +} + +func NewRemainingType() Ty { + return Ty{ + SumType: "Remaining", + Remaining: &Remaining{}, + } +} + +func NewAddressType() Ty { + return Ty{ + SumType: "Address", + Address: &Address{}, + } +} + +func NewAddressOptType() Ty { + return Ty{ + SumType: "AddressOpt", + AddressOpt: &AddressOpt{}, + } +} + +func NewAddressExtType() Ty { + return Ty{ + SumType: "AddressExt", + AddressExt: &AddressExt{}, + } +} + +func NewAddressAnyType() Ty { + return Ty{ + SumType: "AddressAny", + AddressAny: &AddressAny{}, + } +} + +func NewNullableType(of Ty) Ty { + return Ty{ + SumType: "Nullable", + Nullable: &Nullable{ + Inner: of, + }, + } +} + +func NewCellOfType(of Ty) Ty { + return Ty{ + SumType: "CellOf", + CellOf: &CellOf{ + Inner: of, + }, + } +} + +func NewTensorType(of ...Ty) Ty { + return Ty{ + SumType: "Tensor", + Tensor: &Tensor{ + Items: of, + }, + } +} + +func NewTupleWithType(of ...Ty) Ty { + return Ty{ + SumType: "TupleWith", + TupleWith: &TupleWith{ + Items: of, + }, + } +} + +func NewMapType(key, value Ty) Ty { + return Ty{ + SumType: "Map", + Map: &Map{ + K: key, + V: value, + }, + } +} + +func NewEnumType(name string) Ty { + return Ty{ + SumType: "EnumRef", + EnumRef: &EnumRef{ + EnumName: name, + }, + } +} + +func NewAliasType(name string, typeArgs ...Ty) Ty { + return Ty{ + SumType: "AliasRef", + AliasRef: &AliasRef{ + AliasName: name, + TypeArgs: typeArgs, + }, + } +} + +func NewStructType(name string, typeArgs ...Ty) Ty { + return Ty{ + SumType: "StructRef", + StructRef: &StructRef{ + StructName: name, + TypeArgs: typeArgs, + }, + } +} + +func NewGenericType(nameT string) Ty { + return Ty{ + SumType: "Generic", + Generic: &Generic{ + NameT: nameT, + }, + } +} + +func NewUnionVariant(variant Ty, prefixValue string) UnionVariant { + return UnionVariant{ + PrefixStr: prefixValue, + VariantTy: variant, + } +} + +func NewUnionType(prefixLen int, prefixEatIntPlace bool, variants ...UnionVariant) Ty { + for i := range variants { + variants[i].PrefixLen = prefixLen + variants[i].PrefixEatInPlace = prefixEatIntPlace + } + + return Ty{ + SumType: "Union", + Union: &Union{ + Variants: variants, + }, + } +} diff --git a/tolk/runtime_test.go b/tolk/runtime_test.go index 1d2efede..08f783fa 100644 --- a/tolk/runtime_test.go +++ b/tolk/runtime_test.go @@ -18,12 +18,7 @@ const jsonFilesPath = "testdata/json/" func TestRuntime_UnmarshalSmallInt(t *testing.T) { inputFilename := "small_int" - ty := tolkParser.Ty{ - SumType: "IntN", - IntN: &tolkParser.IntN{ - N: 24, - }, - } + ty := tolkParser.NewIntNType(24) currCell, err := boc.DeserializeBocHex("b5ee9c72410101010005000006ff76c41616db06") if err != nil { @@ -55,12 +50,7 @@ func TestRuntime_UnmarshalSmallInt(t *testing.T) { func TestRuntime_UnmarshalBigInt(t *testing.T) { inputFilename := "big_int" - ty := tolkParser.Ty{ - SumType: "IntN", - IntN: &tolkParser.IntN{ - N: 183, - }, - } + ty := tolkParser.NewIntNType(183) currCell, err := boc.DeserializeBocHex("b5ee9c7241010101001900002dfffffffffffffffffffffffffffffffffff99bfeac6423a6f0b50c") if err != nil { @@ -87,12 +77,7 @@ func TestRuntime_UnmarshalBigInt(t *testing.T) { func TestRuntime_UnmarshalSmallUInt(t *testing.T) { inputFilename := "small_uint" - ty := tolkParser.Ty{ - SumType: "UintN", - UintN: &tolkParser.UintN{ - N: 53, - }, - } + ty := tolkParser.NewUIntNType(53) currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000900000d00000000001d34e435eafd") if err != nil { @@ -119,12 +104,7 @@ func TestRuntime_UnmarshalSmallUInt(t *testing.T) { func TestRuntime_UnmarshalBigUInt(t *testing.T) { inputFilename := "big_uint" - ty := tolkParser.Ty{ - SumType: "UintN", - UintN: &tolkParser.UintN{ - N: 257, - }, - } + ty := tolkParser.NewUIntNType(257) currCell, err := boc.DeserializeBocHex("b5ee9c7241010101002300004100000000000000000000000000000000000000000000000000009fc4212a38ba40b11cce12") if err != nil { @@ -151,13 +131,7 @@ func TestRuntime_UnmarshalBigUInt(t *testing.T) { func TestRuntime_UnmarshalVarInt(t *testing.T) { inputFilename := "var_int" - ty := tolkParser.Ty{ - SumType: "VarIntN", - VarIntN: &tolkParser.VarIntN{ - N: 16, - }, - } - + ty := tolkParser.NewVarInt16Type() currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000600000730c98588449b6923") if err != nil { t.Fatal(err) @@ -183,12 +157,7 @@ func TestRuntime_UnmarshalVarInt(t *testing.T) { func TestRuntime_UnmarshalVarUInt(t *testing.T) { inputFilename := "var_uint" - ty := tolkParser.Ty{ - SumType: "VarUintN", - VarUintN: &tolkParser.VarUintN{ - N: 32, - }, - } + ty := tolkParser.NewVarUInt32Type() currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000800000b28119ab36b44d3a86c0f") if err != nil { @@ -215,12 +184,7 @@ func TestRuntime_UnmarshalVarUInt(t *testing.T) { func TestRuntime_UnmarshalBits(t *testing.T) { inputFilename := "bits" - ty := tolkParser.Ty{ - SumType: "BitsN", - BitsN: &tolkParser.BitsN{ - N: 24, - }, - } + ty := tolkParser.NewBitsNType(24) currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000500000631323318854035") if err != nil { @@ -247,10 +211,7 @@ func TestRuntime_UnmarshalBits(t *testing.T) { func TestRuntime_UnmarshalCoins(t *testing.T) { inputFilename := "coins" - ty := tolkParser.Ty{ - SumType: "Coins", - Coins: &tolkParser.Coins{}, - } + ty := tolkParser.NewCoinsType() currCell, err := boc.DeserializeBocHex("b5ee9c72410101010007000009436ec6e0189ebbd7f4") if err != nil { @@ -277,10 +238,7 @@ func TestRuntime_UnmarshalCoins(t *testing.T) { func TestRuntime_UnmarshalBool(t *testing.T) { inputFilename := "bool" - ty := tolkParser.Ty{ - SumType: "Bool", - Bool: &tolkParser.Bool{}, - } + ty := tolkParser.NewBoolType() currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000300000140f6d24034") if err != nil { @@ -307,10 +265,7 @@ func TestRuntime_UnmarshalBool(t *testing.T) { func TestRuntime_UnmarshalCell(t *testing.T) { inputFilename := "cell" - ty := tolkParser.Ty{ - SumType: "Cell", - Cell: &tolkParser.Cell{}, - } + ty := tolkParser.NewCellType() currCell, err := boc.DeserializeBocHex("b5ee9c724101020100090001000100080000007ba52a3292") if err != nil { @@ -341,10 +296,7 @@ func TestRuntime_UnmarshalCell(t *testing.T) { func TestRuntime_UnmarshalRemaining(t *testing.T) { inputFilename := "remaining" - ty := tolkParser.Ty{ - SumType: "Remaining", - Remaining: &tolkParser.Remaining{}, - } + ty := tolkParser.NewRemainingType() currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000900000dc0800000000ab8d04726e4") if err != nil { @@ -375,10 +327,7 @@ func TestRuntime_UnmarshalRemaining(t *testing.T) { func TestRuntime_UnmarshalAddress(t *testing.T) { inputFilename := "internal_address" - ty := tolkParser.Ty{ - SumType: "Address", - Address: &tolkParser.Address{}, - } + ty := tolkParser.NewAddressType() currCell, err := boc.DeserializeBocHex("b5ee9c7241010101002400004380107bfaaa5cc6e5368e5f9799188bd798cd22e04ab16d1d8ea4fc37480741e6351064a3e1a6") if err != nil { @@ -405,10 +354,7 @@ func TestRuntime_UnmarshalAddress(t *testing.T) { func TestRuntime_UnmarshalNotExitsOptionalAddress(t *testing.T) { inputFilename := "not_exists_optional_address" - ty := tolkParser.Ty{ - SumType: "AddressOpt", - AddressOpt: &tolkParser.AddressOpt{}, - } + ty := tolkParser.NewAddressOptType() currCell, err := boc.DeserializeBocHex("b5ee9c724101010100030000012094418655") if err != nil { @@ -436,10 +382,7 @@ func TestRuntime_UnmarshalNotExitsOptionalAddress(t *testing.T) { func TestRuntime_UnmarshalExistsOptionalAddress(t *testing.T) { inputFilename := "exists_optional_address" - ty := tolkParser.Ty{ - SumType: "AddressOpt", - AddressOpt: &tolkParser.AddressOpt{}, - } + ty := tolkParser.NewAddressOptType() currCell, err := boc.DeserializeBocHex("b5ee9c7241010101002400004380107bfaaa5cc6e5368e5f9799188bd798cd22e04ab16d1d8ea4fc37480741e6351064a3e1a6") if err != nil { @@ -467,10 +410,7 @@ func TestRuntime_UnmarshalExistsOptionalAddress(t *testing.T) { func TestRuntime_UnmarshalExternalAddress(t *testing.T) { inputFilename := "external_address" - ty := tolkParser.Ty{ - SumType: "AddressExt", - AddressExt: &tolkParser.AddressExt{}, - } + ty := tolkParser.NewAddressExtType() currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000600000742082850fcbd94fd") if err != nil { @@ -502,10 +442,7 @@ func TestRuntime_UnmarshalExternalAddress(t *testing.T) { func TestRuntime_UnmarshalAnyNoneAddress(t *testing.T) { inputFilename := "any_none_address" - ty := tolkParser.Ty{ - SumType: "AddressAny", - AddressAny: &tolkParser.AddressAny{}, - } + ty := tolkParser.NewAddressAnyType() currCell, err := boc.DeserializeBocHex("b5ee9c724101010100030000012094418655") if err != nil { @@ -532,10 +469,7 @@ func TestRuntime_UnmarshalAnyNoneAddress(t *testing.T) { func TestRuntime_UnmarshalAnyInternalAddress(t *testing.T) { inputFilename := "any_internal_address" - ty := tolkParser.Ty{ - SumType: "AddressAny", - AddressAny: &tolkParser.AddressAny{}, - } + ty := tolkParser.NewAddressAnyType() currCell, err := boc.DeserializeBocHex("b5ee9c7241010101002400004380107bfaaa5cc6e5368e5f9799188bd798cd22e04ab16d1d8ea4fc37480741e6351064a3e1a6") if err != nil { @@ -562,10 +496,7 @@ func TestRuntime_UnmarshalAnyInternalAddress(t *testing.T) { func TestRuntime_UnmarshalAnyExternalAddress(t *testing.T) { inputFilename := "any_external_address" - ty := tolkParser.Ty{ - SumType: "AddressAny", - AddressAny: &tolkParser.AddressAny{}, - } + ty := tolkParser.NewAddressAnyType() currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000600000742082850fcbd94fd") if err != nil { @@ -597,10 +528,7 @@ func TestRuntime_UnmarshalAnyExternalAddress(t *testing.T) { func TestRuntime_UnmarshalAnyVarAddress(t *testing.T) { inputFilename := "any_var_address" - ty := tolkParser.Ty{ - SumType: "AddressAny", - AddressAny: &tolkParser.AddressAny{}, - } + ty := tolkParser.NewAddressAnyType() currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000900000dc0800000000ab8d04726e4") if err != nil { @@ -636,15 +564,7 @@ func TestRuntime_UnmarshalAnyVarAddress(t *testing.T) { func TestRuntime_UnmarshalNotExistsNullable(t *testing.T) { inputFilename := "not_exists_nullable" - ty := tolkParser.Ty{ - SumType: "Nullable", - Nullable: &tolkParser.Nullable{ - Inner: tolkParser.Ty{ - SumType: "Remaining", - Remaining: &tolkParser.Remaining{}, - }, - }, - } + ty := tolkParser.NewNullableType(tolkParser.NewRemainingType()) currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000300000140f6d24034") if err != nil { @@ -671,15 +591,7 @@ func TestRuntime_UnmarshalNotExistsNullable(t *testing.T) { func TestRuntime_UnmarshalExistsNullable(t *testing.T) { inputFilename := "exists_nullable" - ty := tolkParser.Ty{ - SumType: "Nullable", - Nullable: &tolkParser.Nullable{ - Inner: tolkParser.Ty{ - SumType: "Cell", - Cell: &tolkParser.Cell{}, - }, - }, - } + ty := tolkParser.NewNullableType(tolkParser.NewCellType()) currCell, err := boc.DeserializeBocHex("b5ee9c7241010201000b000101c001000900000c0ae007880db9") if err != nil { @@ -717,17 +629,7 @@ func TestRuntime_UnmarshalExistsNullable(t *testing.T) { func TestRuntime_UnmarshalRef(t *testing.T) { inputFilename := "ref" - ty := tolkParser.Ty{ - SumType: "CellOf", - CellOf: &tolkParser.CellOf{ - Inner: tolkParser.Ty{ - SumType: "IntN", - IntN: &tolkParser.IntN{ - N: 65, - }, - }, - }, - } + ty := tolkParser.NewCellOfType(tolkParser.NewIntNType(65)) currCell, err := boc.DeserializeBocHex("b5ee9c7241010201000e000100010011000000000009689e40e150b4c5") if err != nil { @@ -758,10 +660,7 @@ func TestRuntime_UnmarshalRef(t *testing.T) { func TestRuntime_UnmarshalEmptyTensor(t *testing.T) { inputFilename := "empty_tensor" - ty := tolkParser.Ty{ - SumType: "Tensor", - Tensor: &tolkParser.Tensor{}, - } + ty := tolkParser.NewTensorType() currCell, err := boc.DeserializeBocHex("b5ee9c724101010100020000004cacb9cd") if err != nil { @@ -789,57 +688,16 @@ func TestRuntime_UnmarshalEmptyTensor(t *testing.T) { func TestRuntime_UnmarshalTensor(t *testing.T) { inputFilename := "tensor" - ty := tolkParser.Ty{ - SumType: "Tensor", - Tensor: &tolkParser.Tensor{ - Items: []tolkParser.Ty{ - { - SumType: "UintN", - UintN: &tolkParser.UintN{ - N: 123, - }, - }, - { - SumType: "Bool", - Bool: &tolkParser.Bool{}, - }, - { - SumType: "Coins", - Coins: &tolkParser.Coins{}, - }, - { - SumType: "Tensor", - Tensor: &tolkParser.Tensor{ - Items: []tolkParser.Ty{ - { - SumType: "IntN", - IntN: &tolkParser.IntN{ - N: 23, - }, - }, - { - SumType: "Nullable", - Nullable: &tolkParser.Nullable{ - Inner: tolkParser.Ty{ - SumType: "IntN", - IntN: &tolkParser.IntN{ - N: 2, - }, - }, - }, - }, - }, - }, - }, - { - SumType: "VarIntN", - VarIntN: &tolkParser.VarIntN{ - N: 32, - }, - }, - }, - }, - } + ty := tolkParser.NewTensorType( + tolkParser.NewUIntNType(123), + tolkParser.NewBoolType(), + tolkParser.NewCoinsType(), + tolkParser.NewTensorType( + tolkParser.NewIntNType(23), + tolkParser.NewNullableType(tolkParser.NewIntNType(2)), + ), + tolkParser.NewVarIntType(32), + ) currCell, err := boc.DeserializeBocHex("b5ee9c7241010101001f00003900000000000000000000000000021cb43b9aca00fffd550bfbaae07401a2a98117") if err != nil { @@ -923,21 +781,7 @@ func TestRuntime_UnmarshalTensor(t *testing.T) { func TestRuntime_UnmarshalIntKeyMap(t *testing.T) { inputFilename := "int_key_map" - ty := tolkParser.Ty{ - SumType: "Map", - Map: &tolkParser.Map{ - K: tolkParser.Ty{ - SumType: "IntN", - IntN: &tolkParser.IntN{ - N: 32, - }, - }, - V: tolkParser.Ty{ - SumType: "Bool", - Bool: &tolkParser.Bool{}, - }, - }, - } + ty := tolkParser.NewMapType(tolkParser.NewIntNType(32), tolkParser.NewBoolType()) currCell, err := boc.DeserializeBocHex("b5ee9c7241010201000c000101c001000ba00000007bc09a662c32") if err != nil { @@ -977,21 +821,7 @@ func TestRuntime_UnmarshalIntKeyMap(t *testing.T) { func TestRuntime_UnmarshalUIntKeyMap(t *testing.T) { inputFilename := "uint_key_map" - ty := tolkParser.Ty{ - SumType: "Map", - Map: &tolkParser.Map{ - K: tolkParser.Ty{ - SumType: "UintN", - UintN: &tolkParser.UintN{ - N: 16, - }, - }, - V: tolkParser.Ty{ - SumType: "Address", - Address: &tolkParser.Address{}, - }, - }, - } + ty := tolkParser.NewMapType(tolkParser.NewUIntNType(16), tolkParser.NewAddressType()) currCell, err := boc.DeserializeBocHex("b5ee9c72410104010053000101c0010202cb02030045a7400b113a994b5024a16719f69139328eb759596c38a25f59028b146fecdc3621dfe80045a3cff5555555555555555555555555555555555555555555555555555555555555555888440ce8") if err != nil { @@ -1043,21 +873,7 @@ func TestRuntime_UnmarshalUIntKeyMap(t *testing.T) { func TestRuntime_UnmarshalBigIntKeyMap(t *testing.T) { inputFilename := "big_int_key_map" - ty := tolkParser.Ty{ - SumType: "Map", - Map: &tolkParser.Map{ - K: tolkParser.Ty{ - SumType: "UintN", - UintN: &tolkParser.UintN{ - N: 78, - }, - }, - V: tolkParser.Ty{ - SumType: "Cell", - Cell: &tolkParser.Cell{}, - }, - }, - } + ty := tolkParser.NewMapType(tolkParser.NewUIntNType(78), tolkParser.NewCellType()) currCell, err := boc.DeserializeBocHex("b5ee9c7241010301001a000101c0010115a70000000000000047550902000b000000001ab01d5bf1a9") if err != nil { @@ -1101,43 +917,16 @@ func TestRuntime_UnmarshalBigIntKeyMap(t *testing.T) { func TestRuntime_UnmarshalBitsKeyMap(t *testing.T) { inputFilename := "bits_int_key_map" - ty := tolkParser.Ty{ - SumType: "Map", - Map: &tolkParser.Map{ - K: tolkParser.Ty{ - SumType: "BitsN", - BitsN: &tolkParser.BitsN{ - N: 16, - }, - }, - V: tolkParser.Ty{ - SumType: "Map", - Map: &tolkParser.Map{ - K: tolkParser.Ty{ - SumType: "IntN", - IntN: &tolkParser.IntN{ - N: 64, - }, - }, - V: tolkParser.Ty{ - SumType: "Tensor", - Tensor: &tolkParser.Tensor{ - Items: []tolkParser.Ty{ - { - SumType: "Address", - Address: &tolkParser.Address{}, - }, - { - SumType: "Coins", - Coins: &tolkParser.Coins{}, - }, - }, - }, - }, - }, - }, - }, - } + ty := tolkParser.NewMapType( + tolkParser.NewBitsNType(16), + tolkParser.NewMapType( + tolkParser.NewIntNType(64), + tolkParser.NewTensorType( + tolkParser.NewAddressType(), + tolkParser.NewCoinsType(), + ), + ), + ) currCell, err := boc.DeserializeBocHex("b5ee9c7241010301003b000101c0010106a0828502005ea0000000000000003e400b113a994b5024a16719f69139328eb759596c38a25f59028b146fecdc3621dfe43b9aca00b89cdc86") if err != nil { @@ -1208,19 +997,7 @@ func TestRuntime_UnmarshalBitsKeyMap(t *testing.T) { func TestRuntime_UnmarshalAddressKeyMap(t *testing.T) { inputFilename := "address_key_map" - ty := tolkParser.Ty{ - SumType: "Map", - Map: &tolkParser.Map{ - K: tolkParser.Ty{ - SumType: "Address", - Address: &tolkParser.Address{}, - }, - V: tolkParser.Ty{ - SumType: "Coins", - Coins: &tolkParser.Coins{}, - }, - }, - } + ty := tolkParser.NewMapType(tolkParser.NewAddressType(), tolkParser.NewCoinsType()) currCell, err := boc.DeserializeBocHex("b5ee9c7241010201002f000101c0010051a17002c44ea652d4092859c67da44e4ca3add6565b0e2897d640a2c51bfb370d8877f9409502f9002016fdc16e") if err != nil { @@ -1269,35 +1046,11 @@ func TestRuntime_UnmarshalAddressKeyMap(t *testing.T) { func TestRuntime_UnmarshalUnionWithDecPrefix(t *testing.T) { jsonInputFilename := "union_with_dec_prefix" - ty := tolkParser.Ty{ - SumType: "Union", - Union: &tolkParser.Union{ - Variants: []tolkParser.UnionVariant{ - { - PrefixStr: "0", - PrefixLen: 1, - PrefixEatInPlace: true, - VariantTy: tolkParser.Ty{ - SumType: "IntN", - IntN: &tolkParser.IntN{ - N: 16, - }, - }, - }, - { - PrefixStr: "1", - PrefixLen: 1, - PrefixEatInPlace: true, - VariantTy: tolkParser.Ty{ - SumType: "IntN", - IntN: &tolkParser.IntN{ - N: 128, - }, - }, - }, - }, - }, - } + ty := tolkParser.NewUnionType( + 1, true, + tolkParser.NewUnionVariant(tolkParser.NewIntNType(16), "0"), + tolkParser.NewUnionVariant(tolkParser.NewIntNType(128), "1"), + ) currCell, err := boc.DeserializeBocHex("b5ee9c7241010101001300002180000000000000000000000003b5577dc0660d6029") if err != nil { @@ -1347,43 +1100,12 @@ func TestRuntime_UnmarshalUnionWithBinPrefix(t *testing.T) { t.Fatal(err) } - ty := tolkParser.Ty{ - SumType: "Union", - Union: &tolkParser.Union{ - Variants: []tolkParser.UnionVariant{ - { - PrefixStr: "0b001", - PrefixLen: 3, - VariantTy: tolkParser.Ty{ - SumType: "StructRef", - StructRef: &tolkParser.StructRef{ - StructName: "AddressWithPrefix", - }, - }, - }, - { - PrefixStr: "0b011", - PrefixLen: 3, - VariantTy: tolkParser.Ty{ - SumType: "StructRef", - StructRef: &tolkParser.StructRef{ - StructName: "MapWithPrefix", - }, - }, - }, - { - PrefixStr: "0b111", - PrefixLen: 3, - VariantTy: tolkParser.Ty{ - SumType: "StructRef", - StructRef: &tolkParser.StructRef{ - StructName: "CellWithPrefix", - }, - }, - }, - }, - }, - } + ty := tolkParser.NewUnionType( + 3, false, + tolkParser.NewUnionVariant(tolkParser.NewStructType("AddressWithPrefix"), "0b001"), + tolkParser.NewUnionVariant(tolkParser.NewStructType("MapWithPrefix"), "0b011"), + tolkParser.NewUnionVariant(tolkParser.NewStructType("CellWithPrefix"), "0b111"), + ) currCell, err := boc.DeserializeBocHex("b5ee9c7241010201002e0001017801004fa17002c44ea652d4092859c67da44e4ca3add6565b0e2897d640a2c51bfb370d8877f900a4d89920c413c650") if err != nil { @@ -1455,43 +1177,12 @@ func TestRuntime_UnmarshalUnionWithHexPrefix(t *testing.T) { t.Fatal(err) } - ty := tolkParser.Ty{ - SumType: "Union", - Union: &tolkParser.Union{ - Variants: []tolkParser.UnionVariant{ - { - PrefixStr: "0x12345678", - PrefixLen: 32, - VariantTy: tolkParser.Ty{ - SumType: "StructRef", - StructRef: &tolkParser.StructRef{ - StructName: "UInt66WithPrefix", - }, - }, - }, - { - PrefixStr: "0xdeadbeef", - PrefixLen: 32, - VariantTy: tolkParser.Ty{ - SumType: "StructRef", - StructRef: &tolkParser.StructRef{ - StructName: "UInt33WithPrefix", - }, - }, - }, - { - PrefixStr: "0x89abcdef", - PrefixLen: 32, - VariantTy: tolkParser.Ty{ - SumType: "StructRef", - StructRef: &tolkParser.StructRef{ - StructName: "UInt4WithPrefix", - }, - }, - }, - }, - }, - } + ty := tolkParser.NewUnionType( + 32, false, + tolkParser.NewUnionVariant(tolkParser.NewStructType("UInt66WithPrefix"), "0x12345678"), + tolkParser.NewUnionVariant(tolkParser.NewStructType("UInt33WithPrefix"), "0xdeadbeef"), + tolkParser.NewUnionVariant(tolkParser.NewStructType("UInt4WithPrefix"), "0x89abcdef"), + ) currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000b000011deadbeef00000000c0d75977b9") if err != nil { @@ -1551,12 +1242,7 @@ func TestRuntime_UnmarshalALotRefsFromAlias(t *testing.T) { t.Fatal(err) } - ty := tolkParser.Ty{ - SumType: "AliasRef", - AliasRef: &tolkParser.AliasRef{ - AliasName: "GoodNamingForMsg", - }, - } + ty := tolkParser.NewAliasType("GoodNamingForMsg") currCell, err := boc.DeserializeBocHex("b5ee9c724101040100b7000377deadbeef80107bfaaa5cc6e5368e5f9799188bd798cd22e04ab16d1d8ea4fc37480741e635087735940143ffffffffffffffffffffffffffff63c006010203004b80010df454cebee868f611ba8c0d4a9371fb73105396505783293a7625f75db3b9880bebc20100438006e05909e22b2e5e6087533314ee56505f85212914bd5547941a2a658ac62fe101004f801622753296a04942ce33ed2272651d6eb2b2d87144beb2051628dfd9b86c43bfcc12309ce54001e09a48b8") if err != nil { @@ -1818,12 +1504,7 @@ func TestRuntime_UnmarshalALotRefsFromStruct(t *testing.T) { t.Fatal(err) } - ty := tolkParser.Ty{ - SumType: "StructRef", - StructRef: &tolkParser.StructRef{ - StructName: "ManyRefsMsg", - }, - } + ty := tolkParser.NewStructType("ManyRefsMsg") currCell, err := boc.DeserializeBocHex("b5ee9c724101040100b7000377deadbeef80107bfaaa5cc6e5368e5f9799188bd798cd22e04ab16d1d8ea4fc37480741e635087735940143ffffffffffffffffffffffffffff63c006010203004b80010df454cebee868f611ba8c0d4a9371fb73105396505783293a7625f75db3b9880bebc20100438006e05909e22b2e5e6087533314ee56505f85212914bd5547941a2a658ac62fe101004f801622753296a04942ce33ed2272651d6eb2b2d87144beb2051628dfd9b86c43bfcc12309ce54001e09a48b8") if err != nil { @@ -2081,20 +1762,7 @@ func TestRuntime_UnmarshalALotGenericsFromStruct(t *testing.T) { t.Fatal(err) } - ty := tolkParser.Ty{ - SumType: "StructRef", - StructRef: &tolkParser.StructRef{ - StructName: "ManyRefsMsg", - TypeArgs: []tolkParser.Ty{ - { - SumType: "UintN", - UintN: &tolkParser.UintN{ - N: 16, - }, - }, - }, - }, - } + ty := tolkParser.NewStructType("ManyRefsMsg", tolkParser.NewUIntNType(16)) currCell, err := boc.DeserializeBocHex("b5ee9c72410103010043000217d017d7840343b9aca0000108010200080000007b005543b9aca001017d78402005889d4ca5a81250b38cfb489c99475bacacb61c512fac81458a37f66e1b10eff422fc7647") if err != nil { @@ -2333,20 +2001,7 @@ func TestRuntime_UnmarshalALotGenericsFromAlias(t *testing.T) { t.Fatal(err) } - ty := tolkParser.Ty{ - SumType: "AliasRef", - AliasRef: &tolkParser.AliasRef{ - AliasName: "GoodNamingForMsg", - TypeArgs: []tolkParser.Ty{ - { - SumType: "UintN", - UintN: &tolkParser.UintN{ - N: 16, - }, - }, - }, - }, - } + ty := tolkParser.NewAliasType("GoodNamingForMsg", tolkParser.NewUIntNType(16)) currCell, err := boc.DeserializeBocHex("b5ee9c72410103010043000217d017d7840343b9aca0000108010200080000007b005543b9aca001017d78402005889d4ca5a81250b38cfb489c99475bacacb61c512fac81458a37f66e1b10eff422fc7647") if err != nil { @@ -2589,12 +2244,7 @@ func TestRuntime_UnmarshalStructWithDefaultValues(t *testing.T) { t.Fatal(err) } - ty := tolkParser.Ty{ - SumType: "StructRef", - StructRef: &tolkParser.StructRef{ - StructName: "DefaultTest", - }, - } + ty := tolkParser.NewStructType("DefaultTest") currCell, err := boc.DeserializeBocHex("b5ee9c7241010101003100005d80000002414801622753296a04942ce33ed2272651d6eb2b2d87144beb2051628dfd9b86c43bfd00000156ac2c4c70811a9dde") if err != nil { @@ -2767,12 +2417,7 @@ func TestRuntime_UnmarshalALotNumbers(t *testing.T) { t.Fatal(err) } - ty := tolkParser.Ty{ - SumType: "StructRef", - StructRef: &tolkParser.StructRef{ - StructName: "Numbers", - }, - } + ty := tolkParser.NewStructType("Numbers") currCell, err := boc.DeserializeBocHex("b5ee9c72410101010033000062000000000000000000000000000000000000000000000000000000000000000000000000000000f1106aecc4c800020926dc62f014") if err != nil { @@ -2893,12 +2538,7 @@ func TestRuntime_UnmarshalALotRandomFields(t *testing.T) { t.Fatal(err) } - ty := tolkParser.Ty{ - SumType: "StructRef", - StructRef: &tolkParser.StructRef{ - StructName: "RandomFields", - }, - } + ty := tolkParser.NewStructType("RandomFields") currCell, err := boc.DeserializeBocHex("b5ee9c7241010301007800028b79480107bfaaa5cc6e5368e5f9799188bd798cd22e04ab16d1d8ea4fc37480741e6350e038d7eb37c5e80000000ab50ee6b28000000000000016e4c000006c175300001801bc01020001c00051000000000005120041efeaa9731b94da397e5e64622f5e63348b812ac5b4763a93f0dd201d0798d4409e337ceb") if err != nil { @@ -3110,12 +2750,7 @@ func TestRuntime_UnmarshalALotRandomFields(t *testing.T) { func TestRuntime_MarshalSmallInt(t *testing.T) { jsonInputFilename := "small_int" - ty := tolkParser.Ty{ - SumType: "IntN", - IntN: &tolkParser.IntN{ - N: 24, - }, - } + ty := tolkParser.NewIntNType(24) currCell, err := boc.DeserializeBocHex("b5ee9c72410101010005000006ff76c41616db06") if err != nil { @@ -3151,12 +2786,7 @@ func TestRuntime_MarshalSmallInt(t *testing.T) { func TestRuntime_MarshalSmallUInt(t *testing.T) { jsonInputFilename := "small_uint" - ty := tolkParser.Ty{ - SumType: "UintN", - UintN: &tolkParser.UintN{ - N: 53, - }, - } + ty := tolkParser.NewUIntNType(53) currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000900000d00000000001d34e435eafd") if err != nil { @@ -3192,12 +2822,7 @@ func TestRuntime_MarshalSmallUInt(t *testing.T) { func TestRuntime_MarshalBigInt(t *testing.T) { jsonInputFilename := "big_int" - ty := tolkParser.Ty{ - SumType: "IntN", - IntN: &tolkParser.IntN{ - N: 183, - }, - } + ty := tolkParser.NewIntNType(183) currCell, err := boc.DeserializeBocHex("b5ee9c7241010101001900002dfffffffffffffffffffffffffffffffffff99bfeac6423a6f0b50c") if err != nil { @@ -3233,12 +2858,7 @@ func TestRuntime_MarshalBigInt(t *testing.T) { func TestRuntime_MarshalBigUInt(t *testing.T) { jsonInputFilename := "big_uint" - ty := tolkParser.Ty{ - SumType: "UintN", - UintN: &tolkParser.UintN{ - N: 257, - }, - } + ty := tolkParser.NewUIntNType(257) currCell, err := boc.DeserializeBocHex("b5ee9c7241010101002300004100000000000000000000000000000000000000000000000000009fc4212a38ba40b11cce12") if err != nil { @@ -3274,12 +2894,7 @@ func TestRuntime_MarshalBigUInt(t *testing.T) { func TestRuntime_MarshalVarInt(t *testing.T) { jsonInputFilename := "var_int" - ty := tolkParser.Ty{ - SumType: "VarIntN", - VarIntN: &tolkParser.VarIntN{ - N: 16, - }, - } + ty := tolkParser.NewVarInt16Type() currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000600000730c98588449b6923") if err != nil { @@ -3315,12 +2930,7 @@ func TestRuntime_MarshalVarInt(t *testing.T) { func TestRuntime_MarshalVarUInt(t *testing.T) { jsonInputFilename := "var_uint" - ty := tolkParser.Ty{ - SumType: "VarUintN", - VarUintN: &tolkParser.VarUintN{ - N: 32, - }, - } + ty := tolkParser.NewVarUInt32Type() currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000800000b28119ab36b44d3a86c0f") if err != nil { @@ -3356,12 +2966,7 @@ func TestRuntime_MarshalVarUInt(t *testing.T) { func TestRuntime_MarshalBits(t *testing.T) { jsonInputFilename := "bits" - ty := tolkParser.Ty{ - SumType: "BitsN", - BitsN: &tolkParser.BitsN{ - N: 24, - }, - } + ty := tolkParser.NewBitsNType(24) currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000500000631323318854035") if err != nil { @@ -3397,10 +3002,7 @@ func TestRuntime_MarshalBits(t *testing.T) { func TestRuntime_MarshalCoins(t *testing.T) { jsonInputFilename := "coins" - ty := tolkParser.Ty{ - SumType: "Coins", - Coins: &tolkParser.Coins{}, - } + ty := tolkParser.NewCoinsType() currCell, err := boc.DeserializeBocHex("b5ee9c72410101010007000009436ec6e0189ebbd7f4") if err != nil { @@ -3436,10 +3038,7 @@ func TestRuntime_MarshalCoins(t *testing.T) { func TestRuntime_MarshalBool(t *testing.T) { jsonInputFilename := "bool" - ty := tolkParser.Ty{ - SumType: "Bool", - Bool: &tolkParser.Bool{}, - } + ty := tolkParser.NewBoolType() currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000300000140f6d24034") if err != nil { @@ -3475,10 +3074,7 @@ func TestRuntime_MarshalBool(t *testing.T) { func TestRuntime_MarshalCell(t *testing.T) { jsonInputFilename := "cell" - ty := tolkParser.Ty{ - SumType: "Cell", - Cell: &tolkParser.Cell{}, - } + ty := tolkParser.NewCellType() currCell, err := boc.DeserializeBocHex("b5ee9c724101020100090001000100080000007ba52a3292") if err != nil { @@ -3514,10 +3110,7 @@ func TestRuntime_MarshalCell(t *testing.T) { func TestRuntime_MarshalRemaining(t *testing.T) { jsonInputFilename := "remaining" - ty := tolkParser.Ty{ - SumType: "Remaining", - Remaining: &tolkParser.Remaining{}, - } + ty := tolkParser.NewRemainingType() currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000900000dc0800000000ab8d04726e4") if err != nil { @@ -3553,10 +3146,7 @@ func TestRuntime_MarshalRemaining(t *testing.T) { func TestRuntime_MarshalAddress(t *testing.T) { jsonInputFilename := "internal_address" - ty := tolkParser.Ty{ - SumType: "Address", - Address: &tolkParser.Address{}, - } + ty := tolkParser.NewAddressType() currCell, err := boc.DeserializeBocHex("b5ee9c7241010101002400004380107bfaaa5cc6e5368e5f9799188bd798cd22e04ab16d1d8ea4fc37480741e6351064a3e1a6") if err != nil { @@ -3592,10 +3182,7 @@ func TestRuntime_MarshalAddress(t *testing.T) { func TestRuntime_MarshalNotExitsOptionalAddress(t *testing.T) { jsonInputFilename := "not_exists_optional_address" - ty := tolkParser.Ty{ - SumType: "AddressOpt", - AddressOpt: &tolkParser.AddressOpt{}, - } + ty := tolkParser.NewAddressOptType() currCell, err := boc.DeserializeBocHex("b5ee9c724101010100030000012094418655") if err != nil { @@ -3631,10 +3218,7 @@ func TestRuntime_MarshalNotExitsOptionalAddress(t *testing.T) { func TestRuntime_MarshalExistsOptionalAddress(t *testing.T) { jsonInputFilename := "exists_optional_address" - ty := tolkParser.Ty{ - SumType: "AddressOpt", - AddressOpt: &tolkParser.AddressOpt{}, - } + ty := tolkParser.NewAddressOptType() currCell, err := boc.DeserializeBocHex("b5ee9c7241010101002400004380107bfaaa5cc6e5368e5f9799188bd798cd22e04ab16d1d8ea4fc37480741e6351064a3e1a6") if err != nil { @@ -3670,10 +3254,7 @@ func TestRuntime_MarshalExistsOptionalAddress(t *testing.T) { func TestRuntime_MarshalExternalAddress(t *testing.T) { jsonInputFilename := "external_address" - ty := tolkParser.Ty{ - SumType: "AddressExt", - AddressExt: &tolkParser.AddressExt{}, - } + ty := tolkParser.NewAddressExtType() currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000600000742082850fcbd94fd") if err != nil { @@ -3709,10 +3290,7 @@ func TestRuntime_MarshalExternalAddress(t *testing.T) { func TestRuntime_MarshalAnyNoneAddress(t *testing.T) { jsonInputFilename := "any_none_address" - ty := tolkParser.Ty{ - SumType: "AddressAny", - AddressAny: &tolkParser.AddressAny{}, - } + ty := tolkParser.NewAddressAnyType() currCell, err := boc.DeserializeBocHex("b5ee9c724101010100030000012094418655") if err != nil { @@ -3748,10 +3326,7 @@ func TestRuntime_MarshalAnyNoneAddress(t *testing.T) { func TestRuntime_MarshalAnyInternalAddress(t *testing.T) { jsonInputFilename := "any_internal_address" - ty := tolkParser.Ty{ - SumType: "AddressAny", - AddressAny: &tolkParser.AddressAny{}, - } + ty := tolkParser.NewAddressAnyType() currCell, err := boc.DeserializeBocHex("b5ee9c7241010101002400004380107bfaaa5cc6e5368e5f9799188bd798cd22e04ab16d1d8ea4fc37480741e6351064a3e1a6") if err != nil { @@ -3787,10 +3362,7 @@ func TestRuntime_MarshalAnyInternalAddress(t *testing.T) { func TestRuntime_MarshalAnyExternalAddress(t *testing.T) { jsonInputFilename := "any_external_address" - ty := tolkParser.Ty{ - SumType: "AddressAny", - AddressAny: &tolkParser.AddressAny{}, - } + ty := tolkParser.NewAddressAnyType() currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000600000742082850fcbd94fd") if err != nil { @@ -3826,10 +3398,7 @@ func TestRuntime_MarshalAnyExternalAddress(t *testing.T) { func TestRuntime_MarshalAnyVarAddress(t *testing.T) { jsonInputFilename := "any_var_address" - ty := tolkParser.Ty{ - SumType: "AddressAny", - AddressAny: &tolkParser.AddressAny{}, - } + ty := tolkParser.NewAddressAnyType() currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000900000dc0800000000ab8d04726e4") if err != nil { @@ -3865,15 +3434,7 @@ func TestRuntime_MarshalAnyVarAddress(t *testing.T) { func TestRuntime_MarshalNotExistsNullable(t *testing.T) { jsonInputFilename := "not_exists_nullable" - ty := tolkParser.Ty{ - SumType: "Nullable", - Nullable: &tolkParser.Nullable{ - Inner: tolkParser.Ty{ - SumType: "Remaining", - Remaining: &tolkParser.Remaining{}, - }, - }, - } + ty := tolkParser.NewNullableType(tolkParser.NewRemainingType()) currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000300000140f6d24034") if err != nil { @@ -3909,15 +3470,7 @@ func TestRuntime_MarshalNotExistsNullable(t *testing.T) { func TestRuntime_MarshalExistsNullable(t *testing.T) { jsonInputFilename := "exists_nullable" - ty := tolkParser.Ty{ - SumType: "Nullable", - Nullable: &tolkParser.Nullable{ - Inner: tolkParser.Ty{ - SumType: "Cell", - Cell: &tolkParser.Cell{}, - }, - }, - } + ty := tolkParser.NewNullableType(tolkParser.NewCellType()) currCell, err := boc.DeserializeBocHex("b5ee9c7241010201000b000101c001000900000c0ae007880db9") if err != nil { @@ -3953,17 +3506,7 @@ func TestRuntime_MarshalExistsNullable(t *testing.T) { func TestRuntime_MarshalRef(t *testing.T) { jsonInputFilename := "ref" - ty := tolkParser.Ty{ - SumType: "CellOf", - CellOf: &tolkParser.CellOf{ - Inner: tolkParser.Ty{ - SumType: "IntN", - IntN: &tolkParser.IntN{ - N: 65, - }, - }, - }, - } + ty := tolkParser.NewCellOfType(tolkParser.NewIntNType(65)) currCell, err := boc.DeserializeBocHex("b5ee9c7241010201000e000100010011000000000009689e40e150b4c5") if err != nil { @@ -3999,10 +3542,7 @@ func TestRuntime_MarshalRef(t *testing.T) { func TestRuntime_MarshalEmptyTensor(t *testing.T) { jsonInputFilename := "empty_tensor" - ty := tolkParser.Ty{ - SumType: "Tensor", - Tensor: &tolkParser.Tensor{}, - } + ty := tolkParser.NewTensorType() currCell, err := boc.DeserializeBocHex("b5ee9c724101010100020000004cacb9cd") if err != nil { @@ -4038,57 +3578,16 @@ func TestRuntime_MarshalEmptyTensor(t *testing.T) { func TestRuntime_MarshalTensor(t *testing.T) { jsonInputFilename := "tensor" - ty := tolkParser.Ty{ - SumType: "Tensor", - Tensor: &tolkParser.Tensor{ - Items: []tolkParser.Ty{ - { - SumType: "UintN", - UintN: &tolkParser.UintN{ - N: 123, - }, - }, - { - SumType: "Bool", - Bool: &tolkParser.Bool{}, - }, - { - SumType: "Coins", - Coins: &tolkParser.Coins{}, - }, - { - SumType: "Tensor", - Tensor: &tolkParser.Tensor{ - Items: []tolkParser.Ty{ - { - SumType: "IntN", - IntN: &tolkParser.IntN{ - N: 23, - }, - }, - { - SumType: "Nullable", - Nullable: &tolkParser.Nullable{ - Inner: tolkParser.Ty{ - SumType: "IntN", - IntN: &tolkParser.IntN{ - N: 2, - }, - }, - }, - }, - }, - }, - }, - { - SumType: "VarIntN", - VarIntN: &tolkParser.VarIntN{ - N: 32, - }, - }, - }, - }, - } + ty := tolkParser.NewTensorType( + tolkParser.NewUIntNType(123), + tolkParser.NewBoolType(), + tolkParser.NewCoinsType(), + tolkParser.NewTensorType( + tolkParser.NewIntNType(23), + tolkParser.NewNullableType(tolkParser.NewIntNType(2)), + ), + tolkParser.NewVarIntType(32), + ) currCell, err := boc.DeserializeBocHex("b5ee9c7241010101001f00003900000000000000000000000000021cb43b9aca00fffd550bfbaae07401a2a98117") if err != nil { @@ -4124,21 +3623,7 @@ func TestRuntime_MarshalTensor(t *testing.T) { func TestRuntime_MarshalIntKeyMap(t *testing.T) { jsonInputFilename := "int_key_map" - ty := tolkParser.Ty{ - SumType: "Map", - Map: &tolkParser.Map{ - K: tolkParser.Ty{ - SumType: "IntN", - IntN: &tolkParser.IntN{ - N: 32, - }, - }, - V: tolkParser.Ty{ - SumType: "Bool", - Bool: &tolkParser.Bool{}, - }, - }, - } + ty := tolkParser.NewMapType(tolkParser.NewIntNType(32), tolkParser.NewBoolType()) currCell, err := boc.DeserializeBocHex("b5ee9c7241010201000c000101c001000ba00000007bc09a662c32") if err != nil { @@ -4174,21 +3659,7 @@ func TestRuntime_MarshalIntKeyMap(t *testing.T) { func TestRuntime_MarshalUIntKeyMap(t *testing.T) { jsonInputFilename := "uint_key_map" - ty := tolkParser.Ty{ - SumType: "Map", - Map: &tolkParser.Map{ - K: tolkParser.Ty{ - SumType: "UintN", - UintN: &tolkParser.UintN{ - N: 16, - }, - }, - V: tolkParser.Ty{ - SumType: "Address", - Address: &tolkParser.Address{}, - }, - }, - } + ty := tolkParser.NewMapType(tolkParser.NewUIntNType(16), tolkParser.NewAddressType()) currCell, err := boc.DeserializeBocHex("b5ee9c72410104010053000101c0010202cb02030045a7400b113a994b5024a16719f69139328eb759596c38a25f59028b146fecdc3621dfe80045a3cff5555555555555555555555555555555555555555555555555555555555555555888440ce8") if err != nil { @@ -4224,21 +3695,7 @@ func TestRuntime_MarshalUIntKeyMap(t *testing.T) { func TestRuntime_MarshalBigIntKeyMap(t *testing.T) { jsonInputFilename := "big_int_key_map" - ty := tolkParser.Ty{ - SumType: "Map", - Map: &tolkParser.Map{ - K: tolkParser.Ty{ - SumType: "UintN", - UintN: &tolkParser.UintN{ - N: 78, - }, - }, - V: tolkParser.Ty{ - SumType: "Cell", - Cell: &tolkParser.Cell{}, - }, - }, - } + ty := tolkParser.NewMapType(tolkParser.NewUIntNType(78), tolkParser.NewCellType()) currCell, err := boc.DeserializeBocHex("b5ee9c7241010301001a000101c0010115a70000000000000047550902000b000000001ab01d5bf1a9") if err != nil { @@ -4274,43 +3731,16 @@ func TestRuntime_MarshalBigIntKeyMap(t *testing.T) { func TestRuntime_MarshalBitsKeyMap(t *testing.T) { jsonInputFilename := "bits_int_key_map" - ty := tolkParser.Ty{ - SumType: "Map", - Map: &tolkParser.Map{ - K: tolkParser.Ty{ - SumType: "BitsN", - BitsN: &tolkParser.BitsN{ - N: 16, - }, - }, - V: tolkParser.Ty{ - SumType: "Map", - Map: &tolkParser.Map{ - K: tolkParser.Ty{ - SumType: "IntN", - IntN: &tolkParser.IntN{ - N: 64, - }, - }, - V: tolkParser.Ty{ - SumType: "Tensor", - Tensor: &tolkParser.Tensor{ - Items: []tolkParser.Ty{ - { - SumType: "Address", - Address: &tolkParser.Address{}, - }, - { - SumType: "Coins", - Coins: &tolkParser.Coins{}, - }, - }, - }, - }, - }, - }, - }, - } + ty := tolkParser.NewMapType( + tolkParser.NewBitsNType(16), + tolkParser.NewMapType( + tolkParser.NewIntNType(64), + tolkParser.NewTensorType( + tolkParser.NewAddressType(), + tolkParser.NewCoinsType(), + ), + ), + ) currCell, err := boc.DeserializeBocHex("b5ee9c7241010301003b000101c0010106a0828502005ea0000000000000003e400b113a994b5024a16719f69139328eb759596c38a25f59028b146fecdc3621dfe43b9aca00b89cdc86") if err != nil { @@ -4346,19 +3776,7 @@ func TestRuntime_MarshalBitsKeyMap(t *testing.T) { func TestRuntime_MarshalAddressKeyMap(t *testing.T) { jsonInputFilename := "address_key_map" - ty := tolkParser.Ty{ - SumType: "Map", - Map: &tolkParser.Map{ - K: tolkParser.Ty{ - SumType: "Address", - Address: &tolkParser.Address{}, - }, - V: tolkParser.Ty{ - SumType: "Coins", - Coins: &tolkParser.Coins{}, - }, - }, - } + ty := tolkParser.NewMapType(tolkParser.NewAddressType(), tolkParser.NewCoinsType()) currCell, err := boc.DeserializeBocHex("b5ee9c7241010201002f000101c0010051a17002c44ea652d4092859c67da44e4ca3add6565b0e2897d640a2c51bfb370d8877f9409502f9002016fdc16e") if err != nil { @@ -4394,35 +3812,11 @@ func TestRuntime_MarshalAddressKeyMap(t *testing.T) { func TestRuntime_MarshalUnionWithDecPrefix(t *testing.T) { jsonInputFilename := "union_with_dec_prefix" - ty := tolkParser.Ty{ - SumType: "Union", - Union: &tolkParser.Union{ - Variants: []tolkParser.UnionVariant{ - { - PrefixStr: "0", - PrefixLen: 1, - PrefixEatInPlace: true, - VariantTy: tolkParser.Ty{ - SumType: "IntN", - IntN: &tolkParser.IntN{ - N: 16, - }, - }, - }, - { - PrefixStr: "1", - PrefixLen: 1, - PrefixEatInPlace: true, - VariantTy: tolkParser.Ty{ - SumType: "IntN", - IntN: &tolkParser.IntN{ - N: 128, - }, - }, - }, - }, - }, - } + ty := tolkParser.NewUnionType( + 1, true, + tolkParser.NewUnionVariant(tolkParser.NewIntNType(16), "0"), + tolkParser.NewUnionVariant(tolkParser.NewIntNType(128), "1"), + ) currCell, err := boc.DeserializeBocHex("b5ee9c7241010101001300002180000000000000000000000003b5577dc0660d6029") if err != nil { @@ -4470,43 +3864,12 @@ func TestRuntime_MarshalUnionWithBinPrefix(t *testing.T) { t.Fatal(err) } - ty := tolkParser.Ty{ - SumType: "Union", - Union: &tolkParser.Union{ - Variants: []tolkParser.UnionVariant{ - { - PrefixStr: "0b001", - PrefixLen: 3, - VariantTy: tolkParser.Ty{ - SumType: "StructRef", - StructRef: &tolkParser.StructRef{ - StructName: "AddressWithPrefix", - }, - }, - }, - { - PrefixStr: "0b011", - PrefixLen: 3, - VariantTy: tolkParser.Ty{ - SumType: "StructRef", - StructRef: &tolkParser.StructRef{ - StructName: "MapWithPrefix", - }, - }, - }, - { - PrefixStr: "0b111", - PrefixLen: 3, - VariantTy: tolkParser.Ty{ - SumType: "StructRef", - StructRef: &tolkParser.StructRef{ - StructName: "CellWithPrefix", - }, - }, - }, - }, - }, - } + ty := tolkParser.NewUnionType( + 3, false, + tolkParser.NewUnionVariant(tolkParser.NewStructType("AddressWithPrefix"), "0b001"), + tolkParser.NewUnionVariant(tolkParser.NewStructType("MapWithPrefix"), "0b011"), + tolkParser.NewUnionVariant(tolkParser.NewStructType("CellWithPrefix"), "0b111"), + ) currCell, err := boc.DeserializeBocHex("b5ee9c7241010201002e0001017801004fa17002c44ea652d4092859c67da44e4ca3add6565b0e2897d640a2c51bfb370d8877f900a4d89920c413c650") if err != nil { @@ -4558,43 +3921,12 @@ func TestRuntime_MarshalUnionWithHexPrefix(t *testing.T) { t.Fatal(err) } - ty := tolkParser.Ty{ - SumType: "Union", - Union: &tolkParser.Union{ - Variants: []tolkParser.UnionVariant{ - { - PrefixStr: "0x12345678", - PrefixLen: 32, - VariantTy: tolkParser.Ty{ - SumType: "StructRef", - StructRef: &tolkParser.StructRef{ - StructName: "UInt66WithPrefix", - }, - }, - }, - { - PrefixStr: "0xdeadbeef", - PrefixLen: 32, - VariantTy: tolkParser.Ty{ - SumType: "StructRef", - StructRef: &tolkParser.StructRef{ - StructName: "UInt33WithPrefix", - }, - }, - }, - { - PrefixStr: "0x89abcdef", - PrefixLen: 32, - VariantTy: tolkParser.Ty{ - SumType: "StructRef", - StructRef: &tolkParser.StructRef{ - StructName: "UInt4WithPrefix", - }, - }, - }, - }, - }, - } + ty := tolkParser.NewUnionType( + 32, false, + tolkParser.NewUnionVariant(tolkParser.NewStructType("UInt66WithPrefix"), "0x12345678"), + tolkParser.NewUnionVariant(tolkParser.NewStructType("UInt33WithPrefix"), "0xdeadbeef"), + tolkParser.NewUnionVariant(tolkParser.NewStructType("UInt4WithPrefix"), "0x89abcdef"), + ) currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000b000011deadbeef00000000c0d75977b9") if err != nil { @@ -4646,12 +3978,7 @@ func TestRuntime_MarshalALotRefsFromAlias(t *testing.T) { t.Fatal(err) } - ty := tolkParser.Ty{ - SumType: "AliasRef", - AliasRef: &tolkParser.AliasRef{ - AliasName: "GoodNamingForMsg", - }, - } + ty := tolkParser.NewAliasType("GoodNamingForMsg") currCell, err := boc.DeserializeBocHex("b5ee9c724101040100b7000377deadbeef80107bfaaa5cc6e5368e5f9799188bd798cd22e04ab16d1d8ea4fc37480741e635087735940143ffffffffffffffffffffffffffff63c006010203004b80010df454cebee868f611ba8c0d4a9371fb73105396505783293a7625f75db3b9880bebc20100438006e05909e22b2e5e6087533314ee56505f85212914bd5547941a2a658ac62fe101004f801622753296a04942ce33ed2272651d6eb2b2d87144beb2051628dfd9b86c43bfcc12309ce54001e09a48b8") if err != nil { @@ -4708,13 +4035,7 @@ func TestRuntime_MarshalALotRefsFromStruct(t *testing.T) { if err != nil { t.Fatal(err) } - - ty := tolkParser.Ty{ - SumType: "StructRef", - StructRef: &tolkParser.StructRef{ - StructName: "ManyRefsMsg", - }, - } + ty := tolkParser.NewStructType("ManyRefsMsg") currCell, err := boc.DeserializeBocHex("b5ee9c724101040100b7000377deadbeef80107bfaaa5cc6e5368e5f9799188bd798cd22e04ab16d1d8ea4fc37480741e635087735940143ffffffffffffffffffffffffffff63c006010203004b80010df454cebee868f611ba8c0d4a9371fb73105396505783293a7625f75db3b9880bebc20100438006e05909e22b2e5e6087533314ee56505f85212914bd5547941a2a658ac62fe101004f801622753296a04942ce33ed2272651d6eb2b2d87144beb2051628dfd9b86c43bfcc12309ce54001e09a48b8") if err != nil { @@ -4766,20 +4087,7 @@ func TestRuntime_MarshalALotGenericsFromStruct(t *testing.T) { t.Fatal(err) } - ty := tolkParser.Ty{ - SumType: "StructRef", - StructRef: &tolkParser.StructRef{ - StructName: "ManyRefsMsg", - TypeArgs: []tolkParser.Ty{ - { - SumType: "UintN", - UintN: &tolkParser.UintN{ - N: 16, - }, - }, - }, - }, - } + ty := tolkParser.NewStructType("ManyRefsMsg", tolkParser.NewUIntNType(16)) currCell, err := boc.DeserializeBocHex("b5ee9c72410103010043000217d017d7840343b9aca0000108010200080000007b005543b9aca001017d78402005889d4ca5a81250b38cfb489c99475bacacb61c512fac81458a37f66e1b10eff422fc7647") if err != nil { @@ -4831,20 +4139,7 @@ func TestRuntime_MarshalALotGenericsFromAlias(t *testing.T) { t.Fatal(err) } - ty := tolkParser.Ty{ - SumType: "AliasRef", - AliasRef: &tolkParser.AliasRef{ - AliasName: "GoodNamingForMsg", - TypeArgs: []tolkParser.Ty{ - { - SumType: "UintN", - UintN: &tolkParser.UintN{ - N: 16, - }, - }, - }, - }, - } + ty := tolkParser.NewAliasType("GoodNamingForMsg", tolkParser.NewUIntNType(16)) currCell, err := boc.DeserializeBocHex("b5ee9c72410103010043000217d017d7840343b9aca0000108010200080000007b005543b9aca001017d78402005889d4ca5a81250b38cfb489c99475bacacb61c512fac81458a37f66e1b10eff422fc7647") if err != nil { @@ -4896,12 +4191,7 @@ func TestRuntime_MarshalStructWithDefaultValues(t *testing.T) { t.Fatal(err) } - ty := tolkParser.Ty{ - SumType: "StructRef", - StructRef: &tolkParser.StructRef{ - StructName: "DefaultTest", - }, - } + ty := tolkParser.NewStructType("DefaultTest") currCell, err := boc.DeserializeBocHex("b5ee9c7241010101003100005d80000002414801622753296a04942ce33ed2272651d6eb2b2d87144beb2051628dfd9b86c43bfd00000156ac2c4c70811a9dde") if err != nil { @@ -4953,12 +4243,7 @@ func TestRuntime_MarshalALotNumbers(t *testing.T) { t.Fatal(err) } - ty := tolkParser.Ty{ - SumType: "StructRef", - StructRef: &tolkParser.StructRef{ - StructName: "Numbers", - }, - } + ty := tolkParser.NewStructType("Numbers") currCell, err := boc.DeserializeBocHex("b5ee9c72410101010033000062000000000000000000000000000000000000000000000000000000000000000000000000000000f1106aecc4c800020926dc62f014") if err != nil { @@ -5010,12 +4295,7 @@ func TestRuntime_MarshalALotRandomFields(t *testing.T) { t.Fatal(err) } - ty := tolkParser.Ty{ - SumType: "StructRef", - StructRef: &tolkParser.StructRef{ - StructName: "RandomFields", - }, - } + ty := tolkParser.NewStructType("RandomFields") currCell, err := boc.DeserializeBocHex("b5ee9c7241010301007800028b79480107bfaaa5cc6e5368e5f9799188bd798cd22e04ab16d1d8ea4fc37480741e6350e038d7eb37c5e80000000ab50ee6b28000000000000016e4c000006c175300001801bc01020001c00051000000000005120041efeaa9731b94da397e5e64622f5e63348b812ac5b4763a93f0dd201d0798d4409e337ceb") if err != nil { From 8212daae96b384a41ced37a200de32f358c14229 Mon Sep 17 00:00:00 2001 From: Pavel Levchenko Date: Sun, 15 Feb 2026 19:43:48 +0300 Subject: [PATCH 10/16] add custom pack/unpack resolvers --- tolk/refs.go | 16 ++- tolk/runtime.go | 20 ++- tolk/runtime_test.go | 152 +++++++++++++++++++++ tolk/testdata/custom_pack_unpack.json | 40 ++++++ tolk/testdata/json/custom_pack_unpack.json | 14 ++ 5 files changed, 238 insertions(+), 4 deletions(-) create mode 100644 tolk/testdata/custom_pack_unpack.json create mode 100755 tolk/testdata/json/custom_pack_unpack.json diff --git a/tolk/refs.go b/tolk/refs.go index 13354909..07b28512 100644 --- a/tolk/refs.go +++ b/tolk/refs.go @@ -395,7 +395,13 @@ func (a *AliasValue) Unmarshal(cell *boc.Cell, ty tolkParser.AliasRef, decoder * } if alias.CustomUnpackFromSlice { - return fmt.Errorf("alias has custom unpack from slice") + if decoder.customUnpackResolver == nil { + return fmt.Errorf("custom unmarshal alias %v with custom unpack method", ty.AliasName) + } + if err := decoder.customUnpackResolver(ty, cell, a); err != nil { + return fmt.Errorf("failed to unmarshal alias with custom unpack: %w", err) + } + return nil } oldGenericMap := decoder.abiRefs.genericRefs @@ -427,7 +433,13 @@ func (a *AliasValue) Marshal(cell *boc.Cell, ty tolkParser.AliasRef, encoder *En } if alias.CustomPackToBuilder { - return fmt.Errorf("alias has custom pack to builder") + if encoder.customPackResolver == nil { + return fmt.Errorf("custom marshal alias %v with custom pack method", ty.AliasName) + } + if err := encoder.customPackResolver(ty, cell, a); err != nil { + return fmt.Errorf("failed to marshal alias with custom pack: %w", err) + } + return nil } oldGenericMap := encoder.abiRefs.genericRefs diff --git a/tolk/runtime.go b/tolk/runtime.go index b341caec..7cc35c0b 100644 --- a/tolk/runtime.go +++ b/tolk/runtime.go @@ -24,8 +24,11 @@ type abiRefs struct { genericRefs map[string]tolkParser.Ty } +type customUnpackResolver = func(tolkParser.AliasRef, *boc.Cell, *AliasValue) error + type Decoder struct { - abiRefs abiRefs + abiRefs abiRefs + customUnpackResolver customUnpackResolver } func NewDecoder() *Decoder { @@ -52,6 +55,11 @@ func (a *Decoder) WithABI(abi tolkParser.ABI) *Decoder { return a } +func (a *Decoder) WithCustomUnpackResolver(customUnpackResolver customUnpackResolver) *Decoder { + a.customUnpackResolver = customUnpackResolver + return a +} + func (a *Decoder) Unmarshal(cell *boc.Cell, ty tolkParser.Ty) (*Value, error) { res := &Value{} err := res.Unmarshal(cell, ty, a) @@ -61,8 +69,11 @@ func (a *Decoder) Unmarshal(cell *boc.Cell, ty tolkParser.Ty) (*Value, error) { return res, nil } +type customPackResolver = func(tolkParser.AliasRef, *boc.Cell, *AliasValue) error + type Encoder struct { - abiRefs abiRefs + abiRefs abiRefs + customPackResolver customPackResolver } func NewEncoder() *Encoder { @@ -89,6 +100,11 @@ func (a *Encoder) WithABI(abi tolkParser.ABI) *Encoder { return a } +func (a *Encoder) WithCustomPackResolver(customPackResolver customPackResolver) *Encoder { + a.customPackResolver = customPackResolver + return a +} + func (a *Encoder) Marshal(v *Value, ty tolkParser.Ty) (*boc.Cell, error) { cell := boc.NewCell() err := v.Marshal(cell, ty, a) diff --git a/tolk/runtime_test.go b/tolk/runtime_test.go index 08f783fa..a2f74c1a 100644 --- a/tolk/runtime_test.go +++ b/tolk/runtime_test.go @@ -2748,6 +2748,68 @@ func TestRuntime_UnmarshalALotRandomFields(t *testing.T) { } } +func TestRuntime_UnmarshalAliasWithCustomUnpack(t *testing.T) { + jsonInputFilename := "custom_pack_unpack" + inputFilename := "testdata/custom_pack_unpack.json" + data, err := os.ReadFile(inputFilename) + if err != nil { + t.Fatal(err) + } + + var abi tolkParser.ABI + err = json.Unmarshal(data, &abi) + if err != nil { + t.Fatal(err) + } + + ty := tolkParser.NewAliasType("MyAlias") + + currCell, err := boc.DeserializeBocHex("b5ee9c724101010100470000890000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000043b9aca00886e91196") + if err != nil { + t.Fatal(err) + } + decoder := NewDecoder() + decoder.WithABI(abi) + decoder.WithCustomUnpackResolver(func(alias tolkParser.AliasRef, cell *boc.Cell, value *AliasValue) error { + err := cell.Skip(512) + if err != nil { + return fmt.Errorf("failed to 512 bits from alias") + } + val, err := decoder.Unmarshal(cell, tolkParser.NewStructType("My")) + if err != nil { + return fmt.Errorf("failed to unmarshal alias' coins") + } + *value = AliasValue(*val) + return nil + }) + v, err := decoder.Unmarshal(currCell[0], ty) + if err != nil { + t.Fatal(err) + } + + currAlias, ok := v.GetAlias() + if !ok { + t.Fatalf("alias not found") + } + currStruct, ok := currAlias.GetStruct() + if !ok { + t.Fatalf("num1 not found") + } + amount, ok := currStruct.GetField("amount") + if !ok { + t.Fatalf("struct[amount] not found") + } + amountVal := amount.MustGetCoins() + if amountVal.Cmp(big.NewInt(1_000_000_000)) != 0 { + t.Fatalf("amount != 1_000_000_000, got %v", amountVal) + } + + err = compareExpectedJson(jsonInputFilename, *v) + if err != nil { + t.Fatal(err) + } +} + func TestRuntime_MarshalSmallInt(t *testing.T) { jsonInputFilename := "small_int" ty := tolkParser.NewIntNType(24) @@ -4333,6 +4395,96 @@ func TestRuntime_MarshalALotRandomFields(t *testing.T) { } } +func TestRuntime_MarshalAliasWithCustomUnpack(t *testing.T) { + jsonInputFilename := "custom_pack_unpack" + inputFilename := "testdata/custom_pack_unpack.json" + data, err := os.ReadFile(inputFilename) + if err != nil { + t.Fatal(err) + } + + var abi tolkParser.ABI + err = json.Unmarshal(data, &abi) + if err != nil { + t.Fatal(err) + } + + ty := tolkParser.NewAliasType("MyAlias") + + currCell, err := boc.DeserializeBocHex("b5ee9c724101010100470000890000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000043b9aca00886e91196") + if err != nil { + t.Fatal(err) + } + decoder := NewDecoder() + decoder.WithABI(abi) + decoder.WithCustomUnpackResolver(func(alias tolkParser.AliasRef, cell *boc.Cell, value *AliasValue) error { + err := cell.Skip(512) + if err != nil { + return fmt.Errorf("failed to 512 bits from alias") + } + val, err := decoder.Unmarshal(cell, tolkParser.NewStructType("My")) + if err != nil { + return fmt.Errorf("failed to unmarshal alias' coins") + } + *value = AliasValue(*val) + return nil + }) + v, err := decoder.Unmarshal(currCell[0], ty) + if err != nil { + t.Fatal(err) + } + + encoder := NewEncoder() + encoder.WithABI(abi) + encoder.WithCustomPackResolver(func(ref tolkParser.AliasRef, cell *boc.Cell, value *AliasValue) error { + err := cell.WriteUint(0, 256) + if err != nil { + return fmt.Errorf("failed to write 256 bits to alias") + } + err = cell.WriteUint(0, 256) + if err != nil { + return fmt.Errorf("failed to write 256 bits to alias again") + } + val := Value(*value) + cl, err := encoder.Marshal(&val, tolkParser.NewStructType("My")) + if err != nil { + return fmt.Errorf("failed to marshal alias' coins") + } + err = cell.WriteBitString(cl.ReadRemainingBits()) + if err != nil { + return fmt.Errorf("failed to write marshalled bits to alias") + } + for _, clRef := range cl.Refs() { + err = cell.AddRef(clRef) + if err != nil { + return fmt.Errorf("failed to add ref to alias") + } + } + return nil + }) + newCell, err := encoder.Marshal(v, ty) + 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") + } + + err = compareActualJson(jsonInputFilename, *v) + if err != nil { + t.Fatal(err) + } +} + func compareActualJson(inputFilename string, v Value) error { pathPrefix := jsonFilesPath + inputFilename actualJson, err := os.ReadFile(pathPrefix + ".json") diff --git a/tolk/testdata/custom_pack_unpack.json b/tolk/testdata/custom_pack_unpack.json new file mode 100644 index 00000000..be9bfcab --- /dev/null +++ b/tolk/testdata/custom_pack_unpack.json @@ -0,0 +1,40 @@ +{ + "contractName": "Test", + "declarations": [ + { + "kind": "Struct", + "name": "My", + "fields": [ + { + "name": "amount", + "ty": { + "kind": "coins" + } + } + ] + }, + { + "kind": "Alias", + "name": "MyAlias", + "targetTy": { + "kind": "StructRef", + "structName": "My" + }, + "customPackToBuilder": true, + "customUnpackFromSlice": true + } + ], + "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/json/custom_pack_unpack.json b/tolk/testdata/json/custom_pack_unpack.json new file mode 100755 index 00000000..d594e067 --- /dev/null +++ b/tolk/testdata/json/custom_pack_unpack.json @@ -0,0 +1,14 @@ +{ + "sumType": "alias", + "alias": { + "sumType": "struct", + "struct": { + "fields": { + "amount": { + "sumType": "coins", + "coins": "1000000000" + } + } + } + } +} \ No newline at end of file From 67720881cab2a57c107b104759ca3ad05c6ca3f9 Mon Sep 17 00:00:00 2001 From: Pavel Levchenko Date: Fri, 27 Feb 2026 17:30:19 +0300 Subject: [PATCH 11/16] add runtime unmarshaling payloads from known ABIs --- examples/tolk/output.json | 37 ----- .../abi/jetton_wallet.json} | 13 +- .../payload-unmarshal/abi/swap_coffee.json | 156 ++++++++++++++++++ examples/tolk/payload-unmarshal/main.go | 127 ++++++++++++++ examples/tolk/payload-unmarshal/output.json | 148 +++++++++++++++++ .../simple-unmarshal/abi/jetton_wallet.json | 75 +++++++++ examples/tolk/{ => simple-unmarshal}/main.go | 30 ++-- examples/tolk/simple-unmarshal/output.json | 41 +++++ tolk/cells.go | 1 + tolk/refs.go | 76 ++++++++- tolk/runtime.go | 67 +++++--- tolk/runtime_test.go | 150 +++++++++++++---- 12 files changed, 808 insertions(+), 113 deletions(-) delete mode 100755 examples/tolk/output.json rename examples/tolk/{abi.json => payload-unmarshal/abi/jetton_wallet.json} (84%) create mode 100644 examples/tolk/payload-unmarshal/abi/swap_coffee.json create mode 100644 examples/tolk/payload-unmarshal/main.go create mode 100755 examples/tolk/payload-unmarshal/output.json create mode 100644 examples/tolk/simple-unmarshal/abi/jetton_wallet.json rename examples/tolk/{ => simple-unmarshal}/main.go (67%) create mode 100755 examples/tolk/simple-unmarshal/output.json diff --git a/examples/tolk/output.json b/examples/tolk/output.json deleted file mode 100755 index 3447074d..00000000 --- a/examples/tolk/output.json +++ /dev/null @@ -1,37 +0,0 @@ -{ - "sumType": "struct", - "struct": { - "prefix": { - "len": 32, - "prefix": 1607220500 - }, - "fields": { - "queryId": { - "sumType": "smallUint", - "smallUint": 0 - }, - "newOwner": { - "sumType": "internalAddress", - "internalAddress": "0:6033a6e8071d39188423c4220e6439f3075c340fa2480e5d1d4883e2e1916e22" - }, - "responseDestination": { - "sumType": "internalAddress", - "internalAddress": "0:0d28df199ccd0ecd838435390e120ed55601688397c159d0ada90ae8d4c46653" - }, - "customPayload": { - "sumType": "optionalValue", - "optionalValue": { - "isExists": false - } - }, - "forwardAmount": { - "sumType": "coins", - "coins": "20000000" - }, - "forwardPayload": { - "sumType": "remaining", - "remaining": "b5ee9c7201010101000300000140" - } - } - } -} \ No newline at end of file diff --git a/examples/tolk/abi.json b/examples/tolk/payload-unmarshal/abi/jetton_wallet.json similarity index 84% rename from examples/tolk/abi.json rename to examples/tolk/payload-unmarshal/abi/jetton_wallet.json index 41207cdd..56311fca 100644 --- a/examples/tolk/abi.json +++ b/examples/tolk/payload-unmarshal/abi/jetton_wallet.json @@ -1,11 +1,11 @@ { - "contractName": "Example", + "contractName": "Jetton", "declarations": [ { "kind": "Struct", "name": "Transfer", "prefix": { - "prefixStr": "0x5fcc3d14", + "prefixStr": "0x0f8a7ea5", "prefixLen": 32 }, "fields": [ @@ -17,7 +17,13 @@ } }, { - "name": "newOwner", + "name": "amount", + "ty": { + "kind": "coins" + } + }, + { + "name": "destination", "ty": { "kind": "address" } @@ -45,6 +51,7 @@ }, { "name": "forwardPayload", + "isPayload": true, "ty": { "kind": "remaining" } diff --git a/examples/tolk/payload-unmarshal/abi/swap_coffee.json b/examples/tolk/payload-unmarshal/abi/swap_coffee.json new file mode 100644 index 00000000..337cc270 --- /dev/null +++ b/examples/tolk/payload-unmarshal/abi/swap_coffee.json @@ -0,0 +1,156 @@ +{ + "contractName": "Test", + "declarations": [ + { + "kind": "Struct", + "name": "CoffeeCrossDexResend", + "prefix": { + "prefixStr": "0x4ee9b106", + "prefixLen": 32 + }, + "fields": [ + { + "name": "next", + "isPayload": true, + "ty": { + "kind": "cell" + } + } + ] + }, + { + "kind": "Struct", + "name": "CoffeeSwap", + "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": "CoffeeSwapStepParams", + "fields": [ + { + "name": "poolAddressHash", + "ty": { + "kind": "uintN", + "n": 256 + } + }, + { + "name": "minOutputAmount", + "ty": { + "kind": "coins" + } + }, + { + "name": "next", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cellOf", + "inner": { + "kind": "StructRef", + "structName": "CoffeeSwapStepParams" + } + } + } + } + ] + }, + { + "kind": "Struct", + "name": "CoffeeSwapParams", + "fields": [ + { + "name": "deadline", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "recipient", + "ty": { + "kind": "address" + } + }, + { + "name": "referral", + "ty": { + "kind": "addressOpt" + } + }, + { + "name": "notificationData", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cellOf", + "inner": { + "kind": "StructRef", + "structName": "CoffeeNotificationData" + } + } + } + } + ] + }, + { + "kind": "Struct", + "name": "CoffeeNotificationData", + "fields": [ + { + "name": "reciever", + "ty": { + "kind": "address" + } + }, + { + "name": "fwdGas", + "ty": { + "kind": "coins" + } + }, + { + "name": "payload", + "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/examples/tolk/payload-unmarshal/main.go b/examples/tolk/payload-unmarshal/main.go new file mode 100644 index 00000000..128e02d2 --- /dev/null +++ b/examples/tolk/payload-unmarshal/main.go @@ -0,0 +1,127 @@ +package main + +import ( + "encoding/hex" + "encoding/json" + "fmt" + "os" + + "github.com/tonkeeper/tongo/boc" + "github.com/tonkeeper/tongo/tolk" + "github.com/tonkeeper/tongo/tolk/parser" +) +import _ "embed" + +//go:embed abi/jetton_wallet.json +var jettonWalletAbiData []byte + +//go:embed abi/swap_coffee.json +var swapCoffeeAbiData []byte + +func main() { + var jettonWalletABI tolkParser.ABI + err := json.Unmarshal(jettonWalletAbiData, &jettonWalletABI) + if err != nil { + panic(err) + } + + var swapCoffeeABI tolkParser.ABI + err = json.Unmarshal(swapCoffeeAbiData, &swapCoffeeABI) + if err != nil { + panic(err) + } + + ty := tolkParser.NewStructType("Transfer") + b, err := hex.DecodeString("b5ee9c72010205010001310001ae0f8a7ea5003c0fe80d6334813ef1895801d9d00dc43cb19c9bfa417f874e7be3670825205a6e50d3490a0aec1194fe2e8f003ffffbc78bb7c4bb37210cfa7f64397ff32df53ce36c46934e21a1e315c93137482ed968810101084ee9b1060201ae0f8a7ea5003c0fe80d6334813ef189d801fe7933ccc21619bc6f1800071d12d4e7aae8d68f637fcdb8facdca753b08c859003ffffbc78bb7c4bb37210cfa7f64397ff32df53ce36c46934e21a1e315c93137481823cf41030153c0ffee10c44cf0b64eb9dedfb010c7b24a508140d86f6e07789f9383bb9b2141ea9c08ea502d0bbc060404008d69a178e5801ffffde3c5dbe25d9b90867d3fb21cbff996fa9e71b62349a710d0f18ae4989bb00021706f0b21587534d776380d79ce6fcbef538e7aacc3f949f91149c80db932bd") + if err != nil { + panic(err) + } + cell, err := boc.DeserializeBoc(b) + if err != nil { + panic(err) + } + + decoder := tolk.NewDecoder() + err = decoder.WithABIs(jettonWalletABI, swapCoffeeABI) + if err != nil { + panic(err) + } + res, err := decoder.Unmarshal(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 := tolkStruct.MustGetField("queryId") + queryIdValue := queryId.MustGetSmallUInt() + + newOwner, ok := tolkStruct.GetField("destination") + if !ok { + panic("transfer.destination not found") + } + newOwnerValue, ok := newOwner.GetAddress() + if !ok { + panic("cannot get transfer.destination 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") + } + + _, ok = tolkStruct.GetField("forwardPayload") + if !ok { + panic("transfer.forwardPayload not found") + } + + val, err := json.MarshalIndent(res, "", " ") + if err != nil { + panic(err) + } + inputFilename := "examples/tolk/payload-unmarshal/output.json" + err = os.WriteFile(inputFilename, val, os.ModePerm) + if err != nil { + panic(err) + } + + tolkValue := tolk.Value{} + if err := json.Unmarshal(val, &tolkValue); err != nil { + panic(err) + } + + 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()) +} diff --git a/examples/tolk/payload-unmarshal/output.json b/examples/tolk/payload-unmarshal/output.json new file mode 100755 index 00000000..9eeab089 --- /dev/null +++ b/examples/tolk/payload-unmarshal/output.json @@ -0,0 +1,148 @@ +{ + "sumType": "struct", + "struct": { + "prefix": { + "len": 32, + "prefix": 260734629 + }, + "fields": { + "queryId": { + "sumType": "smallUint", + "smallUint": 16905987934073985 + }, + "amount": { + "sumType": "coins", + "coins": "-1107819" + }, + "destination": { + "sumType": "internalAddress", + "internalAddress": "0:ece806e21e58ce4dfd20bfc3a73df1b38412902d372869a485057608ca7f1747" + }, + "responseDestination": { + "sumType": "internalAddress", + "internalAddress": "0:ffffef1e2edf12ecdc8433e9fd90e5ffccb7d4f38db11a4d3886878c5724c4dd" + }, + "customPayload": { + "sumType": "optionalValue", + "optionalValue": { + "isExists": false + } + }, + "forwardAmount": { + "sumType": "coins", + "coins": "393000000" + }, + "forwardPayload": { + "sumType": "struct", + "struct": { + "prefix": { + "len": 32, + "prefix": 1323938054 + }, + "fields": { + "next": { + "sumType": "struct", + "struct": { + "prefix": { + "len": 32, + "prefix": 260734629 + }, + "fields": { + "queryId": { + "sumType": "smallUint", + "smallUint": 16905987934073985 + }, + "amount": { + "sumType": "coins", + "coins": "-1107811" + }, + "destination": { + "sumType": "internalAddress", + "internalAddress": "0:ff3c99e6610b0cde378c00038e896a73d5746b47b1bfe6dc7d66e53a9d84642c" + }, + "responseDestination": { + "sumType": "internalAddress", + "internalAddress": "0:ffffef1e2edf12ecdc8433e9fd90e5ffccb7d4f38db11a4d3886878c5724c4dd" + }, + "customPayload": { + "sumType": "optionalValue", + "optionalValue": { + "isExists": false + } + }, + "forwardAmount": { + "sumType": "coins", + "coins": "202500000" + }, + "forwardPayload": { + "sumType": "struct", + "struct": { + "prefix": { + "len": 32, + "prefix": 3237998096 + }, + "fields": { + "step": { + "sumType": "struct", + "struct": { + "fields": { + "poolAddressHash": { + "sumType": "bigUint", + "bigUint": "88789260033367713967225486461025260896651147011656566896934426357962362325226" + }, + "minOutputAmount": { + "sumType": "coins", + "coins": "12091900000" + }, + "next": { + "sumType": "optionalValue", + "optionalValue": { + "isExists": false + } + } + } + } + }, + "params": { + "sumType": "refValue", + "refValue": { + "sumType": "struct", + "struct": { + "fields": { + "deadline": { + "sumType": "smallUint", + "smallUint": 1772189925 + }, + "recipient": { + "sumType": "internalAddress", + "internalAddress": "0:ffffef1e2edf12ecdc8433e9fd90e5ffccb7d4f38db11a4d3886878c5724c4dd" + }, + "referral": { + "sumType": "optionalAddress", + "optionalAddress": { + "sumType": "internalAddress", + "internalAddress": "0:085c1bc2c8561d4d35dd8e035e739bf2fbd4e39eab30fe527e445272036e4caf" + } + }, + "notificationData": { + "sumType": "optionalValue", + "optionalValue": { + "isExists": false + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } +} \ No newline at end of file diff --git a/examples/tolk/simple-unmarshal/abi/jetton_wallet.json b/examples/tolk/simple-unmarshal/abi/jetton_wallet.json new file mode 100644 index 00000000..56311fca --- /dev/null +++ b/examples/tolk/simple-unmarshal/abi/jetton_wallet.json @@ -0,0 +1,75 @@ +{ + "contractName": "Jetton", + "declarations": [ + { + "kind": "Struct", + "name": "Transfer", + "prefix": { + "prefixStr": "0x0f8a7ea5", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "amount", + "ty": { + "kind": "coins" + } + }, + { + "name": "destination", + "ty": { + "kind": "address" + } + }, + { + "name": "responseDestination", + "ty": { + "kind": "address" + } + }, + { + "name": "customPayload", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cell" + } + } + }, + { + "name": "forwardAmount", + "ty": { + "kind": "coins" + } + }, + { + "name": "forwardPayload", + "isPayload": true, + "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/simple-unmarshal/main.go similarity index 67% rename from examples/tolk/main.go rename to examples/tolk/simple-unmarshal/main.go index 0d427460..ae2f6a74 100644 --- a/examples/tolk/main.go +++ b/examples/tolk/simple-unmarshal/main.go @@ -12,18 +12,18 @@ import ( ) import _ "embed" -//go:embed abi.json -var abiData []byte +//go:embed abi/jetton_wallet.json +var jettonWalletAbiData []byte func main() { - var abi tolkParser.ABI - err := json.Unmarshal(abiData, &abi) + var jettonWalletABI tolkParser.ABI + err := json.Unmarshal(jettonWalletAbiData, &jettonWalletABI) if err != nil { panic(err) } ty := tolkParser.NewStructType("Transfer") - b, err := hex.DecodeString("b5ee9c72c10101010056000000a75fcc3d140000000000000000800c0674dd00e3a7231084788441cc873e60eb8681f44901cba3a9107c5c322dc4500034a37c6673343b360e10d4e438483b555805a20e5f056742b6a42ba35311994c802625a008a90c976e") + b, err := hex.DecodeString("b5ee9c720102030100011b0001ae0f8a7ea5bf4e20320df05dd0318537180125c28235ca8d125e676591513d520721b1fe99f7722f4c87723ce7ee0dfb73a3001f8cc4cadf3be6b14e892d7aa31f5be355c1eab776f0e1d61a46644ddc17e68b881908b1010101e16664de2a801244183034d9fd59a236f71ec4271be377399056dda4cc3a5ebf5dc40967df641001f8cc4cadf3be6b14e892d7aa31f5be355c1eab776f0e1d61a46644ddc17e68ba003f198995be77cd629d125af5463eb7c6ab83d56eede1c3ac348cc89bb82fcd17000000007fffffffc0020095446cf7101800fc662656f9df358a74496bd518fadf1aae0f55bbb7870eb0d233226ee0bf345c00000540095e99c8dc6a438526df4961936ff51209f307a28c37c6c78310ce140ab78ab658") if err != nil { panic(err) } @@ -33,7 +33,10 @@ func main() { } decoder := tolk.NewDecoder() - decoder.WithABI(abi) + err = decoder.WithABIs(jettonWalletABI) + if err != nil { + panic(err) + } res, err := decoder.Unmarshal(cell[0], ty) if err != nil { panic(err) @@ -50,13 +53,13 @@ func main() { queryId := tolkStruct.MustGetField("queryId") queryIdValue := queryId.MustGetSmallUInt() - newOwner, ok := tolkStruct.GetField("newOwner") + newOwner, ok := tolkStruct.GetField("destination") if !ok { - panic("transfer.newOwner not found") + panic("transfer.destination not found") } newOwnerValue, ok := newOwner.GetAddress() if !ok { - panic("cannot get transfer.newOwner value") + panic("cannot get transfer.destination value") } responseDestination, ok := tolkStruct.GetField("responseDestination") @@ -86,20 +89,16 @@ func main() { panic("cannot get transfer.forwardAmount value") } - forwardPayload, ok := tolkStruct.GetField("forwardPayload") + _, ok = tolkStruct.GetField("forwardPayload") if !ok { panic("transfer.forwardPayload not found") } - forwardPayloadValue, ok := forwardPayload.GetRemaining() - if !ok { - panic("cannot get transfer.forwardPayload value") - } val, err := json.MarshalIndent(res, "", " ") if err != nil { panic(err) } - inputFilename := "examples/tolk/output.json" + inputFilename := "examples/tolk/simple-unmarshal/output.json" err = os.WriteFile(inputFilename, val, os.ModePerm) if err != nil { panic(err) @@ -116,5 +115,4 @@ func main() { 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/examples/tolk/simple-unmarshal/output.json b/examples/tolk/simple-unmarshal/output.json new file mode 100755 index 00000000..b0a10c01 --- /dev/null +++ b/examples/tolk/simple-unmarshal/output.json @@ -0,0 +1,41 @@ +{ + "sumType": "struct", + "struct": { + "prefix": { + "len": 32, + "prefix": 260734629 + }, + "fields": { + "queryId": { + "sumType": "smallUint", + "smallUint": 13784990908781977040 + }, + "amount": { + "sumType": "coins", + "coins": "1594225" + }, + "destination": { + "sumType": "internalAddress", + "internalAddress": "0:92e1411ae546892f33b2c8a89ea90390d8ff4cfbb917a643b91e73f706fdb9d1" + }, + "responseDestination": { + "sumType": "internalAddress", + "internalAddress": "0:7e33132b7cef9ac53a24b5ea8c7d6f8d5707aadddbc3875869199137705f9a2e" + }, + "customPayload": { + "sumType": "optionalValue", + "optionalValue": { + "isExists": false + } + }, + "forwardAmount": { + "sumType": "coins", + "coins": "210000000" + }, + "forwardPayload": { + "sumType": "remaining", + "remaining": "b5ee9c720101030100c40001000101e16664de2a801244183034d9fd59a236f71ec4271be377399056dda4cc3a5ebf5dc40967df641001f8cc4cadf3be6b14e892d7aa31f5be355c1eab776f0e1d61a46644ddc17e68ba003f198995be77cd629d125af5463eb7c6ab83d56eede1c3ac348cc89bb82fcd17000000007fffffffc0020095446cf7101800fc662656f9df358a74496bd518fadf1aae0f55bbb7870eb0d233226ee0bf345c00000540095e99c8dc6a438526df4961936ff51209f307a28c37c6c78310ce140ab78ab658" + } + } + } +} \ No newline at end of file diff --git a/tolk/cells.go b/tolk/cells.go index 0e30177a..840e6dfd 100644 --- a/tolk/cells.go +++ b/tolk/cells.go @@ -70,6 +70,7 @@ type RemainingValue boc.Cell func (r *RemainingValue) Unmarshal(cell *boc.Cell, ty tolkParser.Remaining, decoder *Decoder) error { rem := cell.CopyRemaining() + cell.ReadRemainingBits() if rem != nil { *r = RemainingValue(*rem) } diff --git a/tolk/refs.go b/tolk/refs.go index 07b28512..5ea8431b 100644 --- a/tolk/refs.go +++ b/tolk/refs.go @@ -70,9 +70,19 @@ func (s *Struct) Unmarshal(cell *boc.Cell, ty tolkParser.StructRef, decoder *Dec for _, field := range strct.Fields { fieldVal := Value{} - err = fieldVal.Unmarshal(cell, field.Ty, decoder) - if err != nil { - return fmt.Errorf("failed to unmarshal struct's field %s: %w", field.Name, err) + + isPayloadResolved := false + if field.IsPayload != nil && *field.IsPayload { + fieldVal, isPayloadResolved, err = s.resolvePayload(cell, field.Ty, decoder) + if err != nil { + return fmt.Errorf("failed to resolve payload for field %v: %w", field.Name, err) + } + } + if !isPayloadResolved { + err = fieldVal.Unmarshal(cell, field.Ty, decoder) + if err != nil { + return fmt.Errorf("failed to unmarshal struct's field %s: %w", field.Name, err) + } } tolkStruct.fieldNames = append(tolkStruct.fieldNames, field.Name) @@ -85,6 +95,66 @@ func (s *Struct) Unmarshal(cell *boc.Cell, ty tolkParser.StructRef, decoder *Dec return nil } +// try to resolve payload from all known abi in trace +func (s *Struct) resolvePayload(cell *boc.Cell, ty tolkParser.Ty, decoder *Decoder) (Value, bool, error) { + switch ty.SumType { + case "Remaining": + isRef, err := cell.ReadBit() + if err != nil { + return Value{}, false, fmt.Errorf("failed to read isRef prefix: %w", err) + } + payload := cell.CopyRemaining() + if isRef { + payload, err = payload.NextRef() + if err != nil { + return Value{}, false, fmt.Errorf("failed to read payload ref: %w", err) + } + } + v, isResolved, err := resolvePayload(payload, decoder) + if err != nil { + return Value{}, false, fmt.Errorf("failed to resolve payload: %w", err) + } + if isResolved { + return v, true, nil + } + case "Cell": + payload, err := cell.NextRef() + if err != nil { + return Value{}, false, fmt.Errorf("failed to read payload ref: %w", err) + } + payload = payload.CopyRemaining() + v, isResolved, err := resolvePayload(payload, decoder) + if err != nil { + return Value{}, false, fmt.Errorf("failed to resolve payload: %w", err) + } + if isResolved { + return v, true, nil + } + } + + return Value{}, false, nil +} + +func resolvePayload(payload *boc.Cell, decoder *Decoder) (Value, bool, error) { + payloadOpcode, err := payload.ReadUint(32) // payload always 32 bit length + if err != nil { + return Value{}, false, fmt.Errorf("failed to read payload's opcode: %w", err) + } + payload.ResetCounters() // reset opcode + + guessedStructs := decoder.abiRefs.opcodeRefs[payloadOpcode] + for _, strct := range guessedStructs { + v, err := decoder.Unmarshal(payload, tolkParser.NewStructType(strct.Name)) + if err != nil { + continue + } + return *v, true, nil + } + + // todo: maybe try every known struct to unmarshal to? + return Value{}, false, nil +} + func (s *Struct) Marshal(cell *boc.Cell, ty tolkParser.StructRef, encoder *Encoder) error { if encoder.abiRefs.structRefs == nil { return fmt.Errorf("struct has struct reference but no abi has been given") diff --git a/tolk/runtime.go b/tolk/runtime.go index 7cc35c0b..4f128593 100644 --- a/tolk/runtime.go +++ b/tolk/runtime.go @@ -22,6 +22,7 @@ type abiRefs struct { aliasRefs map[string]tolkParser.AliasDeclaration enumRefs map[string]tolkParser.EnumDeclaration genericRefs map[string]tolkParser.Ty + opcodeRefs map[uint64][]tolkParser.StructDeclaration } type customUnpackResolver = func(tolkParser.AliasRef, *boc.Cell, *AliasValue) error @@ -35,29 +36,38 @@ func NewDecoder() *Decoder { return &Decoder{} } -func (a *Decoder) WithABI(abi tolkParser.ABI) *Decoder { +func (a *Decoder) WithABIs(abis ...tolkParser.ABI) error { a.abiRefs = abiRefs{ structRefs: make(map[string]tolkParser.StructDeclaration), aliasRefs: make(map[string]tolkParser.AliasDeclaration), enumRefs: make(map[string]tolkParser.EnumDeclaration), genericRefs: make(map[string]tolkParser.Ty), + opcodeRefs: make(map[uint64][]tolkParser.StructDeclaration), } - 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 + for _, abi := range abis { + for _, declr := range abi.Declarations { + switch declr.SumType { + case "Struct": + a.abiRefs.structRefs[declr.StructDeclaration.Name] = declr.StructDeclaration + if declr.StructDeclaration.Prefix != nil { + prefix, err := binHexToUint64(declr.StructDeclaration.Prefix.PrefixStr) + if err != nil { + return fmt.Errorf("failed to parse prefix struct %v prefix: %w", declr.StructDeclaration.Name, err) + } + a.abiRefs.opcodeRefs[prefix] = append(a.abiRefs.opcodeRefs[prefix], declr.StructDeclaration) + } + case "Alias": + a.abiRefs.aliasRefs[declr.AliasDeclaration.Name] = declr.AliasDeclaration + case "Enum": + a.abiRefs.enumRefs[declr.EnumDeclaration.Name] = declr.EnumDeclaration + } } } - return a + return nil } -func (a *Decoder) WithCustomUnpackResolver(customUnpackResolver customUnpackResolver) *Decoder { +func (a *Decoder) WithCustomUnpackResolver(customUnpackResolver customUnpackResolver) { a.customUnpackResolver = customUnpackResolver - return a } func (a *Decoder) Unmarshal(cell *boc.Cell, ty tolkParser.Ty) (*Value, error) { @@ -80,29 +90,38 @@ func NewEncoder() *Encoder { return &Encoder{} } -func (a *Encoder) WithABI(abi tolkParser.ABI) *Encoder { +func (a *Encoder) WithABIs(abis ...tolkParser.ABI) error { a.abiRefs = abiRefs{ structRefs: make(map[string]tolkParser.StructDeclaration), aliasRefs: make(map[string]tolkParser.AliasDeclaration), enumRefs: make(map[string]tolkParser.EnumDeclaration), genericRefs: make(map[string]tolkParser.Ty), + opcodeRefs: make(map[uint64][]tolkParser.StructDeclaration), } - 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 + for _, abi := range abis { + for _, declr := range abi.Declarations { + switch declr.SumType { + case "Struct": + a.abiRefs.structRefs[declr.StructDeclaration.Name] = declr.StructDeclaration + if declr.StructDeclaration.Prefix != nil { + prefix, err := binHexToUint64(declr.StructDeclaration.Prefix.PrefixStr) + if err != nil { + return fmt.Errorf("failed to parse prefix struct %v prefix: %w", declr.StructDeclaration.Name, err) + } + a.abiRefs.opcodeRefs[prefix] = append(a.abiRefs.opcodeRefs[prefix], declr.StructDeclaration) + } + case "Alias": + a.abiRefs.aliasRefs[declr.AliasDeclaration.Name] = declr.AliasDeclaration + case "Enum": + a.abiRefs.enumRefs[declr.EnumDeclaration.Name] = declr.EnumDeclaration + } } } - return a + return nil } -func (a *Encoder) WithCustomPackResolver(customPackResolver customPackResolver) *Encoder { +func (a *Encoder) WithCustomPackResolver(customPackResolver customPackResolver) { a.customPackResolver = customPackResolver - return a } func (a *Encoder) Marshal(v *Value, ty tolkParser.Ty) (*boc.Cell, error) { diff --git a/tolk/runtime_test.go b/tolk/runtime_test.go index a2f74c1a..9bea10bc 100644 --- a/tolk/runtime_test.go +++ b/tolk/runtime_test.go @@ -1112,7 +1112,10 @@ func TestRuntime_UnmarshalUnionWithBinPrefix(t *testing.T) { t.Fatal(err) } decoder := NewDecoder() - decoder.WithABI(abi) + err = decoder.WithABIs(abi) + if err != nil { + t.Fatal(err) + } v, err := decoder.Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) @@ -1189,7 +1192,10 @@ func TestRuntime_UnmarshalUnionWithHexPrefix(t *testing.T) { t.Fatal(err) } decoder := NewDecoder() - decoder.WithABI(abi) + err = decoder.WithABIs(abi) + if err != nil { + t.Fatal(err) + } v, err := decoder.Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) @@ -1249,7 +1255,10 @@ func TestRuntime_UnmarshalALotRefsFromAlias(t *testing.T) { t.Fatal(err) } decoder := NewDecoder() - decoder.WithABI(abi) + err = decoder.WithABIs(abi) + if err != nil { + t.Fatal(err) + } v, err := decoder.Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) @@ -1511,7 +1520,10 @@ func TestRuntime_UnmarshalALotRefsFromStruct(t *testing.T) { t.Fatal(err) } decoder := NewDecoder() - decoder.WithABI(abi) + err = decoder.WithABIs(abi) + if err != nil { + t.Fatal(err) + } v, err := decoder.Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) @@ -1769,7 +1781,10 @@ func TestRuntime_UnmarshalALotGenericsFromStruct(t *testing.T) { t.Fatal(err) } decoder := NewDecoder() - decoder.WithABI(abi) + err = decoder.WithABIs(abi) + if err != nil { + t.Fatal(err) + } v, err := decoder.Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) @@ -2008,7 +2023,10 @@ func TestRuntime_UnmarshalALotGenericsFromAlias(t *testing.T) { t.Fatal(err) } decoder := NewDecoder() - decoder.WithABI(abi) + err = decoder.WithABIs(abi) + if err != nil { + t.Fatal(err) + } v, err := decoder.Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) @@ -2251,7 +2269,10 @@ func TestRuntime_UnmarshalStructWithDefaultValues(t *testing.T) { t.Fatal(err) } decoder := NewDecoder() - decoder.WithABI(abi) + err = decoder.WithABIs(abi) + if err != nil { + t.Fatal(err) + } v, err := decoder.Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) @@ -2424,7 +2445,10 @@ func TestRuntime_UnmarshalALotNumbers(t *testing.T) { t.Fatal(err) } decoder := NewDecoder() - decoder.WithABI(abi) + err = decoder.WithABIs(abi) + if err != nil { + t.Fatal(err) + } v, err := decoder.Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) @@ -2545,7 +2569,10 @@ func TestRuntime_UnmarshalALotRandomFields(t *testing.T) { t.Fatal(err) } decoder := NewDecoder() - decoder.WithABI(abi) + err = decoder.WithABIs(abi) + if err != nil { + t.Fatal(err) + } v, err := decoder.Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) @@ -2769,7 +2796,10 @@ func TestRuntime_UnmarshalAliasWithCustomUnpack(t *testing.T) { t.Fatal(err) } decoder := NewDecoder() - decoder.WithABI(abi) + err = decoder.WithABIs(abi) + if err != nil { + t.Fatal(err) + } decoder.WithCustomUnpackResolver(func(alias tolkParser.AliasRef, cell *boc.Cell, value *AliasValue) error { err := cell.Skip(512) if err != nil { @@ -3938,14 +3968,20 @@ func TestRuntime_MarshalUnionWithBinPrefix(t *testing.T) { t.Fatal(err) } decoder := NewDecoder() - decoder.WithABI(abi) + err = decoder.WithABIs(abi) + if err != nil { + t.Fatal(err) + } v, err := decoder.Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } encoder := NewEncoder() - encoder.WithABI(abi) + err = encoder.WithABIs(abi) + if err != nil { + t.Fatal(err) + } newCell, err := encoder.Marshal(v, ty) if err != nil { t.Error(err) @@ -3995,14 +4031,20 @@ func TestRuntime_MarshalUnionWithHexPrefix(t *testing.T) { t.Fatal(err) } decoder := NewDecoder() - decoder.WithABI(abi) + err = decoder.WithABIs(abi) + if err != nil { + t.Fatal(err) + } v, err := decoder.Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } encoder := NewEncoder() - encoder.WithABI(abi) + err = encoder.WithABIs(abi) + if err != nil { + t.Fatal(err) + } newCell, err := encoder.Marshal(v, ty) if err != nil { t.Error(err) @@ -4047,14 +4089,20 @@ func TestRuntime_MarshalALotRefsFromAlias(t *testing.T) { t.Fatal(err) } decoder := NewDecoder() - decoder.WithABI(abi) + err = decoder.WithABIs(abi) + if err != nil { + t.Fatal(err) + } v, err := decoder.Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } encoder := NewEncoder() - encoder.WithABI(abi) + err = encoder.WithABIs(abi) + if err != nil { + t.Fatal(err) + } newCell, err := encoder.Marshal(v, ty) if err != nil { t.Fatal(err) @@ -4104,14 +4152,20 @@ func TestRuntime_MarshalALotRefsFromStruct(t *testing.T) { t.Fatal(err) } decoder := NewDecoder() - decoder.WithABI(abi) + err = decoder.WithABIs(abi) + if err != nil { + t.Fatal(err) + } v, err := decoder.Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } encoder := NewEncoder() - encoder.WithABI(abi) + err = encoder.WithABIs(abi) + if err != nil { + t.Fatal(err) + } newCell, err := encoder.Marshal(v, ty) if err != nil { t.Error(err) @@ -4156,14 +4210,20 @@ func TestRuntime_MarshalALotGenericsFromStruct(t *testing.T) { t.Fatal(err) } decoder := NewDecoder() - decoder.WithABI(abi) + err = decoder.WithABIs(abi) + if err != nil { + t.Fatal(err) + } v, err := decoder.Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } encoder := NewEncoder() - encoder.WithABI(abi) + err = encoder.WithABIs(abi) + if err != nil { + t.Fatal(err) + } newCell, err := encoder.Marshal(v, ty) if err != nil { t.Error(err) @@ -4208,14 +4268,20 @@ func TestRuntime_MarshalALotGenericsFromAlias(t *testing.T) { t.Fatal(err) } decoder := NewDecoder() - decoder.WithABI(abi) + err = decoder.WithABIs(abi) + if err != nil { + t.Fatal(err) + } v, err := decoder.Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } encoder := NewEncoder() - encoder.WithABI(abi) + err = encoder.WithABIs(abi) + if err != nil { + t.Fatal(err) + } newCell, err := encoder.Marshal(v, ty) if err != nil { t.Error(err) @@ -4260,14 +4326,20 @@ func TestRuntime_MarshalStructWithDefaultValues(t *testing.T) { t.Fatal(err) } decoder := NewDecoder() - decoder.WithABI(abi) + err = decoder.WithABIs(abi) + if err != nil { + t.Fatal(err) + } v, err := decoder.Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } encoder := NewEncoder() - encoder.WithABI(abi) + err = encoder.WithABIs(abi) + if err != nil { + t.Fatal(err) + } newCell, err := encoder.Marshal(v, ty) if err != nil { t.Error(err) @@ -4312,14 +4384,20 @@ func TestRuntime_MarshalALotNumbers(t *testing.T) { t.Fatal(err) } decoder := NewDecoder() - decoder.WithABI(abi) + err = decoder.WithABIs(abi) + if err != nil { + t.Fatal(err) + } v, err := decoder.Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } encoder := NewEncoder() - encoder.WithABI(abi) + err = encoder.WithABIs(abi) + if err != nil { + t.Fatal(err) + } newCell, err := encoder.Marshal(v, ty) if err != nil { t.Error(err) @@ -4364,14 +4442,20 @@ func TestRuntime_MarshalALotRandomFields(t *testing.T) { t.Fatal(err) } decoder := NewDecoder() - decoder.WithABI(abi) + err = decoder.WithABIs(abi) + if err != nil { + t.Fatal(err) + } v, err := decoder.Unmarshal(currCell[0], ty) if err != nil { t.Fatal(err) } encoder := NewEncoder() - encoder.WithABI(abi) + err = encoder.WithABIs(abi) + if err != nil { + t.Fatal(err) + } newCell, err := encoder.Marshal(v, ty) if err != nil { t.Error(err) @@ -4416,7 +4500,10 @@ func TestRuntime_MarshalAliasWithCustomUnpack(t *testing.T) { t.Fatal(err) } decoder := NewDecoder() - decoder.WithABI(abi) + err = decoder.WithABIs(abi) + if err != nil { + t.Fatal(err) + } decoder.WithCustomUnpackResolver(func(alias tolkParser.AliasRef, cell *boc.Cell, value *AliasValue) error { err := cell.Skip(512) if err != nil { @@ -4435,7 +4522,10 @@ func TestRuntime_MarshalAliasWithCustomUnpack(t *testing.T) { } encoder := NewEncoder() - encoder.WithABI(abi) + err = encoder.WithABIs(abi) + if err != nil { + t.Fatal(err) + } encoder.WithCustomPackResolver(func(ref tolkParser.AliasRef, cell *boc.Cell, value *AliasValue) error { err := cell.WriteUint(0, 256) if err != nil { From c306e885def67ff9b20bd4cc2965f5fcd8574d78 Mon Sep 17 00:00:00 2001 From: Pavel Levchenko Date: Fri, 27 Feb 2026 18:07:02 +0300 Subject: [PATCH 12/16] add method for message unmarshalling --- boc/cell.go | 15 +++++++++++++++ tolk/runtime.go | 35 +++++++++++++++++++++++++---------- 2 files changed, 40 insertions(+), 10 deletions(-) diff --git a/boc/cell.go b/boc/cell.go index f4ce1e70..d69ebbbe 100644 --- a/boc/cell.go +++ b/boc/cell.go @@ -341,6 +341,21 @@ func (c *Cell) CopyRemaining() *Cell { return c2 } +func (c *Cell) CopyCell() *Cell { + if c == nil { + return nil + } + c2 := NewCellWithBits(c.RawBitString()) + for _, ref := range c.Refs() { + refCopy := ref.CopyCell() + if err := c2.AddRef(refCopy); err != nil { + // this should never happen but anyway + panic(err) + } + } + return c2 +} + func (c *Cell) WriteBytes(b []byte) error { return c.bits.WriteBytes(b) } diff --git a/tolk/runtime.go b/tolk/runtime.go index 4f128593..be245dad 100644 --- a/tolk/runtime.go +++ b/tolk/runtime.go @@ -36,8 +36,8 @@ func NewDecoder() *Decoder { return &Decoder{} } -func (a *Decoder) WithABIs(abis ...tolkParser.ABI) error { - a.abiRefs = abiRefs{ +func (d *Decoder) WithABIs(abis ...tolkParser.ABI) error { + d.abiRefs = abiRefs{ structRefs: make(map[string]tolkParser.StructDeclaration), aliasRefs: make(map[string]tolkParser.AliasDeclaration), enumRefs: make(map[string]tolkParser.EnumDeclaration), @@ -48,37 +48,52 @@ func (a *Decoder) WithABIs(abis ...tolkParser.ABI) error { for _, declr := range abi.Declarations { switch declr.SumType { case "Struct": - a.abiRefs.structRefs[declr.StructDeclaration.Name] = declr.StructDeclaration + d.abiRefs.structRefs[declr.StructDeclaration.Name] = declr.StructDeclaration if declr.StructDeclaration.Prefix != nil { prefix, err := binHexToUint64(declr.StructDeclaration.Prefix.PrefixStr) if err != nil { return fmt.Errorf("failed to parse prefix struct %v prefix: %w", declr.StructDeclaration.Name, err) } - a.abiRefs.opcodeRefs[prefix] = append(a.abiRefs.opcodeRefs[prefix], declr.StructDeclaration) + d.abiRefs.opcodeRefs[prefix] = append(d.abiRefs.opcodeRefs[prefix], declr.StructDeclaration) } case "Alias": - a.abiRefs.aliasRefs[declr.AliasDeclaration.Name] = declr.AliasDeclaration + d.abiRefs.aliasRefs[declr.AliasDeclaration.Name] = declr.AliasDeclaration case "Enum": - a.abiRefs.enumRefs[declr.EnumDeclaration.Name] = declr.EnumDeclaration + d.abiRefs.enumRefs[declr.EnumDeclaration.Name] = declr.EnumDeclaration } } } return nil } -func (a *Decoder) WithCustomUnpackResolver(customUnpackResolver customUnpackResolver) { - a.customUnpackResolver = customUnpackResolver +func (d *Decoder) WithCustomUnpackResolver(customUnpackResolver customUnpackResolver) { + d.customUnpackResolver = customUnpackResolver } -func (a *Decoder) Unmarshal(cell *boc.Cell, ty tolkParser.Ty) (*Value, error) { +func (d *Decoder) Unmarshal(cell *boc.Cell, ty tolkParser.Ty) (*Value, error) { res := &Value{} - err := res.Unmarshal(cell, ty, a) + err := res.Unmarshal(cell, ty, d) if err != nil { return nil, fmt.Errorf("failed to unmarshal tolk value: %w", err) } return res, nil } +func (d *Decoder) UnmarshalMessage(cell *boc.Cell) (*Value, error) { + res, isResolved, err := resolvePayload(cell, d) + if err != nil { + return nil, fmt.Errorf("failed to unmarshal tolk value: %w", err) + } + if isResolved { + return &res, nil + } + res = Value{ + SumType: "Remaining", + Remaining: (*RemainingValue)(cell), + } + return &res, nil +} + type customPackResolver = func(tolkParser.AliasRef, *boc.Cell, *AliasValue) error type Encoder struct { From 4689031579bb9d6eda7f3778b56c466290fd0d92 Mon Sep 17 00:00:00 2001 From: Pavel Levchenko Date: Sun, 1 Mar 2026 15:22:19 +0300 Subject: [PATCH 13/16] marshal json in convinient way --- tolk/addresses.go | 113 ++++----- tolk/cells.go | 19 +- tolk/integers.go | 24 +- tolk/map.go | 129 ++-------- tolk/null.go | 4 +- tolk/refs.go | 94 ++------ tolk/runtime.go | 42 +++- tolk/runtime_test.go | 223 +----------------- .../json/a_lot_generics_from_alias.json | 179 ++------------ .../json/a_lot_generics_from_struct.json | 176 ++------------ .../a_lot_generics_with_default_values.json | 98 ++------ tolk/testdata/json/a_lot_numbers.json | 40 +--- tolk/testdata/json/a_lot_random_fields.json | 109 ++------- tolk/testdata/json/a_lot_refs_from_alias.json | 150 ++---------- .../testdata/json/a_lot_refs_from_struct.json | 145 ++---------- tolk/testdata/json/address_key_map.json | 9 +- tolk/testdata/json/any_external_address.json | 6 +- tolk/testdata/json/any_internal_address.json | 6 +- tolk/testdata/json/any_none_address.json | 5 +- tolk/testdata/json/any_var_address.json | 6 +- tolk/testdata/json/big_int.json | 3 +- tolk/testdata/json/big_int_key_map.json | 9 +- tolk/testdata/json/big_uint.json | 3 +- tolk/testdata/json/bits.json | 3 +- tolk/testdata/json/bits_int_key_map.json | 25 +- tolk/testdata/json/bool.json | 3 +- tolk/testdata/json/cell.json | 3 +- tolk/testdata/json/coins.json | 3 +- tolk/testdata/json/custom_pack_unpack.json | 13 +- tolk/testdata/json/empty_tensor.json | 3 +- tolk/testdata/json/exists_nullable.json | 8 +- .../json/exists_optional_address.json | 6 +- tolk/testdata/json/external_address.json | 3 +- tolk/testdata/json/int_key_map.json | 9 +- tolk/testdata/json/internal_address.json | 3 +- tolk/testdata/json/not_exists_nullable.json | 3 +- .../json/not_exists_optional_address.json | 5 +- tolk/testdata/json/ref.json | 6 +- tolk/testdata/json/remaining.json | 3 +- tolk/testdata/json/small_int.json | 3 +- tolk/testdata/json/small_uint.json | 3 +- tolk/testdata/json/tensor.json | 49 +--- tolk/testdata/json/uint_key_map.json | 14 +- tolk/testdata/json/union_with_bin_prefix.json | 29 +-- tolk/testdata/json/union_with_dec_prefix.json | 12 +- tolk/testdata/json/union_with_hex_prefix.json | 23 +- tolk/testdata/json/var_int.json | 3 +- tolk/testdata/json/var_uint.json | 3 +- tolk/tuples.go | 19 ++ tolk/union.go | 12 +- tolk/value.go | 130 +++++++--- 51 files changed, 482 insertions(+), 1509 deletions(-) mode change 100644 => 100755 tolk/testdata/json/small_int.json diff --git a/tolk/addresses.go b/tolk/addresses.go index e033d7a1..379d26e9 100644 --- a/tolk/addresses.go +++ b/tolk/addresses.go @@ -65,7 +65,7 @@ func (i *InternalAddress) ToRaw() string { return fmt.Sprintf("%v:%x", i.Workchain, i.Address) } -func (i *InternalAddress) MarshalJSON() ([]byte, error) { +func (i InternalAddress) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf("\"%v:%x\"", i.Workchain, i.Address)), nil } @@ -110,6 +110,14 @@ func (n *NoneAddress) Marshal(cell *boc.Cell, ty tolkParser.AddressOpt, encoder return nil } +func (n NoneAddress) MarshalJSON() ([]byte, error) { + return []byte("\"\""), nil +} + +func (n *NoneAddress) UnmarshalJSON(b []byte) error { + return nil +} + type OptionalAddress struct { SumType NoneAddress *NoneAddress @@ -172,45 +180,26 @@ func (o *OptionalAddress) Marshal(cell *boc.Cell, ty tolkParser.AddressOpt, enco return fmt.Errorf("unknown optional address SumType: %v", o.SumType) } -func (o *OptionalAddress) MarshalJSON() ([]byte, error) { - var optinalAddress = struct { - SumType SumType `json:"sumType"` - InternalAddress *InternalAddress `json:"internalAddress,omitempty"` - }{} - optinalAddress.SumType = o.SumType +func (o OptionalAddress) MarshalJSON() ([]byte, error) { if o.SumType == "NoneAddress" { - optinalAddress.SumType = "noneAddress" + return json.Marshal(o.NoneAddress) } else if o.SumType == "InternalAddress" { - optinalAddress.SumType = "internalAddress" - optinalAddress.InternalAddress = o.InternalAddress + return json.Marshal(o.InternalAddress) } else { return nil, fmt.Errorf("unknown optional address SumType: %v", o.SumType) } - data, err := json.Marshal(optinalAddress) - if err != nil { - return nil, fmt.Errorf("failed to marshal optional address: %w", err) - } - return data, nil } func (o *OptionalAddress) UnmarshalJSON(b []byte) error { - var optionalAddress = struct { - SumType SumType `json:"sumType"` - InternalAddress *InternalAddress `json:"internalAddress,omitempty"` - }{} - if err := json.Unmarshal(b, &optionalAddress); err != nil { - return fmt.Errorf("failed to unmarshal optional address: %w", err) - } - - if optionalAddress.SumType == "noneAddress" { + var internalAddress *InternalAddress + if err := json.Unmarshal(b, &internalAddress); err != nil { o.SumType = "NoneAddress" o.NoneAddress = &NoneAddress{} - } else if optionalAddress.SumType == "internalAddress" { - o.SumType = "InternalAddress" - o.InternalAddress = optionalAddress.InternalAddress - } else { - return fmt.Errorf("unknown optional address SumType: %v", o.SumType) + return nil } + + o.SumType = "InternalAddress" + o.InternalAddress = internalAddress return nil } @@ -267,7 +256,7 @@ func (e *ExternalAddress) Equal(other any) bool { return bytes.Equal(e.Address.Buffer(), otherExternalAddress.Address.Buffer()) } -func (e *ExternalAddress) MarshalJSON() ([]byte, error) { +func (e ExternalAddress) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf("\"%s\"", e.Address.ToFiftHex())), nil } @@ -362,61 +351,49 @@ func (a *AnyAddress) Equal(other any) bool { return false } -func (a *AnyAddress) MarshalJSON() ([]byte, error) { - var jsonAnyAddress = struct { - SumType string `json:"sumType"` - InternalAddress *InternalAddress `json:"internalAddress,omitempty"` - ExternalAddress *ExternalAddress `json:"externalAddress,omitempty"` - VarAddress *VarAddress `json:"varAddress,omitempty"` - }{} +func (a AnyAddress) MarshalJSON() ([]byte, error) { + var data []byte + var err error switch a.SumType { case "NoneAddress": - jsonAnyAddress.SumType = "noneAddress" + data, err = json.Marshal(a.NoneAddress) case "InternalAddress": - jsonAnyAddress.SumType = "internalAddress" - jsonAnyAddress.InternalAddress = a.InternalAddress + data, err = json.Marshal(a.InternalAddress) case "ExternalAddress": - jsonAnyAddress.SumType = "externalAddress" - jsonAnyAddress.ExternalAddress = a.ExternalAddress + data, err = json.Marshal(a.ExternalAddress) case "VarAddress": - jsonAnyAddress.SumType = "varAddress" - jsonAnyAddress.VarAddress = a.VarAddress + data, err = json.Marshal(a.VarAddress) default: return nil, fmt.Errorf("unknown any address SumType: %v", a.SumType) } - data, err := json.Marshal(jsonAnyAddress) if err != nil { - return nil, fmt.Errorf("failed to marshal any address: %w", err) + return nil, fmt.Errorf("failed to marshal AnyAddress: %w", err) } return data, nil } func (a *AnyAddress) UnmarshalJSON(b []byte) error { - var anyAddress = struct { - SumType string `json:"sumType"` - InternalAddress *InternalAddress `json:"internalAddress,omitempty"` - ExternalAddress *ExternalAddress `json:"externalAddress,omitempty"` - VarAddress *VarAddress `json:"varAddress,omitempty"` - }{} - if err := json.Unmarshal(b, &anyAddress); err != nil { - return fmt.Errorf("failed to unmarshal any address: %w", err) - } - switch anyAddress.SumType { - case "noneAddress": - a.SumType = "NoneAddress" - a.NoneAddress = &NoneAddress{} - case "internalAddress": + var internalAddress *InternalAddress + if err := json.Unmarshal(b, &internalAddress); err == nil { a.SumType = "InternalAddress" - a.InternalAddress = anyAddress.InternalAddress - case "externalAddress": + a.InternalAddress = internalAddress + return nil + } + + var externalAddress *ExternalAddress + if err := json.Unmarshal(b, &externalAddress); err == nil { a.SumType = "ExternalAddress" - a.ExternalAddress = anyAddress.ExternalAddress - case "varAddress": + a.ExternalAddress = externalAddress + } + + var varAddress *VarAddress + if err := json.Unmarshal(b, &varAddress); err == nil { a.SumType = "VarAddress" - a.VarAddress = anyAddress.VarAddress - default: - return fmt.Errorf("unknown anyAddress SumType: %v", anyAddress.SumType) + a.VarAddress = varAddress } + + a.SumType = "NoneAddress" + a.NoneAddress = &NoneAddress{} return nil } @@ -486,7 +463,7 @@ func (va *VarAddress) Marshal(cell *boc.Cell, ty tolkParser.AddressAny, encoder return nil } -func (va *VarAddress) MarshalJSON() ([]byte, error) { +func (va VarAddress) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf("\"%d:%s\"", va.Workchain, va.Address.ToFiftHex())), nil } diff --git a/tolk/cells.go b/tolk/cells.go index 840e6dfd..39e71137 100644 --- a/tolk/cells.go +++ b/tolk/cells.go @@ -49,8 +49,8 @@ func (a *Any) Equal(o any) bool { return oHash == vHash } -func (a *Any) MarshalJSON() ([]byte, error) { - data, err := boc.Cell(*a).MarshalJSON() +func (a Any) MarshalJSON() ([]byte, error) { + data, err := boc.Cell(a).MarshalJSON() if err != nil { return nil, fmt.Errorf("failed to marshal any: %w", err) } @@ -111,8 +111,8 @@ func (r *RemainingValue) Equal(o any) bool { return oHash == vHash } -func (r *RemainingValue) MarshalJSON() ([]byte, error) { - data, err := boc.Cell(*r).MarshalJSON() +func (r RemainingValue) MarshalJSON() ([]byte, error) { + data, err := boc.Cell(r).MarshalJSON() if err != nil { return nil, fmt.Errorf("failed to marshal remainings: %w", err) } @@ -177,7 +177,7 @@ func (o *OptValue) Equal(other any) bool { return true } -func (o *OptValue) MarshalJSON() ([]byte, error) { +func (o OptValue) MarshalJSON() ([]byte, error) { var jsonOptValue = struct { IsExists bool `json:"isExists"` Val *Value `json:"value,omitempty"` @@ -251,3 +251,12 @@ func (r *RefValue) Equal(other any) bool { v := Value(*r) return v.Equal(Value(otherRefValue)) } + +func (r RefValue) MarshalJSON() ([]byte, error) { + v := Value(r) + data, err := v.MarshalJSON() + if err != nil { + return nil, fmt.Errorf("failed to marshal ref: %w", err) + } + return data, nil +} diff --git a/tolk/integers.go b/tolk/integers.go index 992172b2..9f9a38ad 100644 --- a/tolk/integers.go +++ b/tolk/integers.go @@ -67,8 +67,8 @@ func (b *BigInt) Equal(other any) bool { return bi.Cmp(&otherBi) == 0 } -func (b *BigInt) MarshalJSON() ([]byte, error) { - bi := big.Int(*b) +func (b BigInt) MarshalJSON() ([]byte, error) { + bi := big.Int(b) return []byte(`"` + bi.String() + `"`), nil } @@ -141,8 +141,8 @@ func (b *BigUInt) Equal(other any) bool { return bi.Cmp(&otherBi) == 0 } -func (b *BigUInt) MarshalJSON() ([]byte, error) { - bi := big.Int(*b) +func (b BigUInt) MarshalJSON() ([]byte, error) { + bi := big.Int(b) return []byte(`"` + bi.String() + `"`), nil } @@ -198,8 +198,8 @@ func (vi *VarInt) Equal(other any) bool { return bi.Cmp(&otherBi) == 0 } -func (vi *VarInt) MarshalJSON() ([]byte, error) { - bi := big.Int(*vi) +func (vi VarInt) MarshalJSON() ([]byte, error) { + bi := big.Int(vi) return []byte(`"` + bi.String() + `"`), nil } @@ -255,8 +255,8 @@ func (vu *VarUInt) Equal(other any) bool { return bi.Cmp(&otherBi) == 0 } -func (vu *VarUInt) MarshalJSON() ([]byte, error) { - bi := big.Int(*vu) +func (vu VarUInt) MarshalJSON() ([]byte, error) { + bi := big.Int(vu) return []byte(`"` + bi.String() + `"`), nil } @@ -303,8 +303,8 @@ func (b *Bits) Equal(other any) bool { return bytes.Equal(bs.Buffer(), otherBs.Buffer()) } -func (b *Bits) MarshalJSON() ([]byte, error) { - data, err := boc.BitString(*b).MarshalJSON() +func (b Bits) MarshalJSON() ([]byte, error) { + data, err := boc.BitString(b).MarshalJSON() if err != nil { return nil, fmt.Errorf("failed to marshal bits value: %w", err) } @@ -350,8 +350,8 @@ func (c *CoinsValue) Equal(other any) bool { return bi.Cmp(&otherBi) == 0 } -func (c *CoinsValue) MarshalJSON() ([]byte, error) { - bi := big.Int(*c) +func (c CoinsValue) MarshalJSON() ([]byte, error) { + bi := big.Int(c) return []byte(`"` + bi.String() + `"`), nil } diff --git a/tolk/map.go b/tolk/map.go index 7842a173..b74b962a 100644 --- a/tolk/map.go +++ b/tolk/map.go @@ -9,7 +9,6 @@ import ( "github.com/tonkeeper/tongo/boc" "github.com/tonkeeper/tongo/tolk/parser" - "github.com/tonkeeper/tongo/utils" ) type MapValue struct { @@ -445,7 +444,7 @@ func (m *MapValue) get(key Value) (Value, bool) { func (m *MapValue) GetBySmallInt(v Int64) (Value, bool) { key := Value{ - SumType: "smallInt", + SumType: "SmallInt", SmallInt: &v, } return m.get(key) @@ -453,7 +452,7 @@ func (m *MapValue) GetBySmallInt(v Int64) (Value, bool) { func (m *MapValue) GetBySmallUInt(v UInt64) (Value, bool) { key := Value{ - SumType: "smallUint", + SumType: "SmallUint", SmallUint: &v, } return m.get(key) @@ -461,7 +460,7 @@ func (m *MapValue) GetBySmallUInt(v UInt64) (Value, bool) { func (m *MapValue) GetByBigInt(v BigInt) (Value, bool) { key := Value{ - SumType: "bigInt", + SumType: "BigInt", BigInt: &v, } return m.get(key) @@ -469,7 +468,7 @@ func (m *MapValue) GetByBigInt(v BigInt) (Value, bool) { func (m *MapValue) GetByBigUInt(v BigUInt) (Value, bool) { key := Value{ - SumType: "bigUint", + SumType: "BigUint", BigUint: &v, } return m.get(key) @@ -477,7 +476,7 @@ func (m *MapValue) GetByBigUInt(v BigUInt) (Value, bool) { func (m *MapValue) GetByBits(v Bits) (Value, bool) { key := Value{ - SumType: "bits", + SumType: "Bits", Bits: &v, } return m.get(key) @@ -485,7 +484,7 @@ func (m *MapValue) GetByBits(v Bits) (Value, bool) { func (m *MapValue) GetByInternalAddress(v InternalAddress) (Value, bool) { key := Value{ - SumType: "internalAddress", + SumType: "InternalAddress", InternalAddress: &v, } return m.get(key) @@ -507,7 +506,7 @@ func (m *MapValue) set(key Value, value Value) (bool, error) { func (m *MapValue) SetBySmallInt(k Int64, value Value) (bool, error) { key := Value{ - SumType: "smallInt", + SumType: "SmallInt", SmallInt: &k, } return m.set(key, value) @@ -515,7 +514,7 @@ func (m *MapValue) SetBySmallInt(k Int64, value Value) (bool, error) { func (m *MapValue) SetBySmallUInt(k UInt64, value Value) (bool, error) { key := Value{ - SumType: "smallUint", + SumType: "SmallUint", SmallUint: &k, } return m.set(key, value) @@ -523,7 +522,7 @@ func (m *MapValue) SetBySmallUInt(k UInt64, value Value) (bool, error) { func (m *MapValue) SetByBigInt(k BigInt, value Value) (bool, error) { key := Value{ - SumType: "bigInt", + SumType: "BigInt", BigInt: &k, } return m.set(key, value) @@ -531,7 +530,7 @@ func (m *MapValue) SetByBigInt(k BigInt, value Value) (bool, error) { func (m *MapValue) SetByBigUInt(k BigUInt, value Value) (bool, error) { key := Value{ - SumType: "bigUint", + SumType: "BigUint", BigUint: &k, } return m.set(key, value) @@ -539,7 +538,7 @@ func (m *MapValue) SetByBigUInt(k BigUInt, value Value) (bool, error) { func (m *MapValue) SetByBits(k Bits, value Value) (bool, error) { key := Value{ - SumType: "bits", + SumType: "Bits", Bits: &k, } return m.set(key, value) @@ -547,7 +546,7 @@ func (m *MapValue) SetByBits(k Bits, value Value) (bool, error) { func (m *MapValue) SetByInternalAddress(k InternalAddress, value Value) (bool, error) { key := Value{ - SumType: "internalAddress", + SumType: "InternalAddress", InternalAddress: &k, } return m.set(key, value) @@ -565,7 +564,7 @@ func (m *MapValue) delete(key Value) { func (m *MapValue) DeleteBySmallInt(k Int64) { key := Value{ - SumType: "smallInt", + SumType: "SmallInt", SmallInt: &k, } m.delete(key) @@ -573,7 +572,7 @@ func (m *MapValue) DeleteBySmallInt(k Int64) { func (m *MapValue) DeleteBySmallUInt(k UInt64) { key := Value{ - SumType: "smallUint", + SumType: "SmallUint", SmallUint: &k, } m.delete(key) @@ -581,7 +580,7 @@ func (m *MapValue) DeleteBySmallUInt(k UInt64) { func (m *MapValue) DeleteByBigInt(k BigInt) { key := Value{ - SumType: "bigInt", + SumType: "BigInt", BigInt: &k, } m.delete(key) @@ -589,7 +588,7 @@ func (m *MapValue) DeleteByBigInt(k BigInt) { func (m *MapValue) DeleteByBigUInt(k BigUInt) { key := Value{ - SumType: "bigUint", + SumType: "BigUint", BigUint: &k, } m.delete(key) @@ -597,7 +596,7 @@ func (m *MapValue) DeleteByBigUInt(k BigUInt) { func (m *MapValue) DeleteByBits(k Bits) { key := Value{ - SumType: "bits", + SumType: "Bits", Bits: &k, } m.delete(key) @@ -605,7 +604,7 @@ func (m *MapValue) DeleteByBits(k Bits) { func (m *MapValue) DeleteByInternalAddress(k InternalAddress) { key := Value{ - SumType: "internalAddress", + SumType: "InternalAddress", InternalAddress: &k, } m.delete(key) @@ -615,15 +614,13 @@ func (m *MapValue) Len() int { return m.len } -func (m *MapValue) MarshalJSON() ([]byte, error) { +func (m MapValue) MarshalJSON() ([]byte, error) { if len(m.keys) != len(m.values) { return nil, errors.New("map values and keys must contain equal length") } s := strings.Builder{} s.WriteString("{") if len(m.keys) > 0 { - s.WriteString("\"keySumType\":") - s.WriteString(fmt.Sprintf("\"%s\",", utils.ToCamelCasePrivate(string(m.keys[0].SumType)))) for i, k := range m.keys { if i != 0 { s.WriteString(",") @@ -657,90 +654,8 @@ func (m *MapValue) MarshalJSON() ([]byte, error) { } func getJustValue(key string) (string, error) { - foundComma := false - start := -1 - for i, v := range key { - if v == ',' { - foundComma = true - } - if v == ':' && foundComma { - start = i - break - } - } - if start == -1 { - return "", fmt.Errorf("invalid key: %v", key) - } - return strings.ReplaceAll(key[start+1:len(key)-1], " ", ""), nil -} - -func (m *MapValue) UnmarshalJSON(bytes []byte) error { - decoder := json.NewDecoder(strings.NewReader(string(bytes))) - _, err := decoder.Token() - if err != nil { - return fmt.Errorf("failed to unmarshal map: %w", err) - } - - keyTypeDeclr, err := decoder.Token() - if err != nil { - return fmt.Errorf("failed to unmarshal map key type declaration: %w", err) - } - stringKeyTypeDeclr, ok := keyTypeDeclr.(string) - if !ok { - return fmt.Errorf("expected key type as a string") - } - if stringKeyTypeDeclr != "keySumType" { - return fmt.Errorf("map does not have key sum type") - } - - keyType, err := decoder.Token() - if err != nil { - return fmt.Errorf("failed to unmarshal map key type: %w", err) - } - stringKeyType, ok := keyType.(string) - if !ok { - return fmt.Errorf("expected map key type value as a string") - } - keyTemplate := strings.Builder{} - keyTemplate.WriteString("{\"sumType\":\"") - keyTemplate.WriteString(stringKeyType) - keyTemplate.WriteString("\",\"") - keyTemplate.WriteString(stringKeyType) - keyTemplate.WriteString("\":%s}") - keyTmpl := keyTemplate.String() - - for decoder.More() { - keyValue, err := decoder.Token() - if err != nil { - return fmt.Errorf("failed to unmarshal map key's value: %w", err) - } - stringKeyValue, ok := keyValue.(string) - if !ok { - return fmt.Errorf("expected map key as a string") - } - keyValueJson := fmt.Sprintf(keyTmpl, wrapValue(stringKeyType, stringKeyValue)) - key := Value{} - if err = json.Unmarshal([]byte(keyValueJson), &key); err != nil { - return fmt.Errorf("failed to unmarshal map key value: %w", err) - } - - var value Value - if err = decoder.Decode(&value); err != nil { - return fmt.Errorf("failed to unmarshal map value: %w", err) - } - - m.keys = append(m.keys, key) - m.values = append(m.values, value) - m.len++ - } - - return nil -} - -func wrapValue(sumType string, v any) any { - switch sumType { - case "smallInt", "smallUint", "bool", "optionalValue", "tupleWith", "tensor", "map", "struct", "enum", "union", "refValue", "alias", "generic": - return v + if key[0] != '"' { + key = fmt.Sprintf("\"%s\"", key) } - return fmt.Sprintf("\"%v\"", v) + return strings.ReplaceAll(key, " ", ""), nil } diff --git a/tolk/null.go b/tolk/null.go index ac970dcf..92e30770 100644 --- a/tolk/null.go +++ b/tolk/null.go @@ -23,7 +23,7 @@ func (n *NullValue) Marshal(cell *boc.Cell, ty tolkParser.NullLiteral, encoder * return nil } -func (n *NullValue) MarshalJSON() ([]byte, error) { +func (n NullValue) MarshalJSON() ([]byte, error) { return []byte("null"), nil } @@ -45,6 +45,6 @@ func (v *VoidValue) Marshal(cell *boc.Cell, ty tolkParser.Void, encoder *Encoder return nil } -func (v *VoidValue) MarshalJSON() ([]byte, error) { +func (v VoidValue) MarshalJSON() ([]byte, error) { return []byte("null"), nil } diff --git a/tolk/refs.go b/tolk/refs.go index 5ea8431b..14790a45 100644 --- a/tolk/refs.go +++ b/tolk/refs.go @@ -110,7 +110,7 @@ func (s *Struct) resolvePayload(cell *boc.Cell, ty tolkParser.Ty, decoder *Decod return Value{}, false, fmt.Errorf("failed to read payload ref: %w", err) } } - v, isResolved, err := resolvePayload(payload, decoder) + v, isResolved, err := decoder.resolvePayload(payload) if err != nil { return Value{}, false, fmt.Errorf("failed to resolve payload: %w", err) } @@ -123,7 +123,7 @@ func (s *Struct) resolvePayload(cell *boc.Cell, ty tolkParser.Ty, decoder *Decod return Value{}, false, fmt.Errorf("failed to read payload ref: %w", err) } payload = payload.CopyRemaining() - v, isResolved, err := resolvePayload(payload, decoder) + v, isResolved, err := decoder.resolvePayload(payload) if err != nil { return Value{}, false, fmt.Errorf("failed to resolve payload: %w", err) } @@ -135,26 +135,6 @@ func (s *Struct) resolvePayload(cell *boc.Cell, ty tolkParser.Ty, decoder *Decod return Value{}, false, nil } -func resolvePayload(payload *boc.Cell, decoder *Decoder) (Value, bool, error) { - payloadOpcode, err := payload.ReadUint(32) // payload always 32 bit length - if err != nil { - return Value{}, false, fmt.Errorf("failed to read payload's opcode: %w", err) - } - payload.ResetCounters() // reset opcode - - guessedStructs := decoder.abiRefs.opcodeRefs[payloadOpcode] - for _, strct := range guessedStructs { - v, err := decoder.Unmarshal(payload, tolkParser.NewStructType(strct.Name)) - if err != nil { - continue - } - return *v, true, nil - } - - // todo: maybe try every known struct to unmarshal to? - return Value{}, false, nil -} - func (s *Struct) Marshal(cell *boc.Cell, ty tolkParser.StructRef, encoder *Encoder) error { if encoder.abiRefs.structRefs == nil { return fmt.Errorf("struct has struct reference but no abi has been given") @@ -273,19 +253,9 @@ func (s *Struct) Equal(o any) bool { return true } -func (s *Struct) MarshalJSON() ([]byte, error) { +func (s Struct) MarshalJSON() ([]byte, error) { builder := strings.Builder{} - builder.WriteString("{") - if s.hasPrefix { - builder.WriteString("\"prefix\":") - prefix, err := json.Marshal(s.prefix) - if err != nil { - return nil, fmt.Errorf("failed to marshal struct's prefix: %w", err) - } - builder.Write(prefix) - builder.WriteRune(',') - } - builder.WriteString("\"fields\": {") + builder.WriteRune('{') for i, name := range s.fieldNames { if i != 0 { builder.WriteRune(',') @@ -297,54 +267,14 @@ func (s *Struct) MarshalJSON() ([]byte, error) { } builder.Write(val) } - builder.WriteString("}}") + builder.WriteRune('}') return []byte(builder.String()), nil } -func (s *Struct) UnmarshalJSON(bytes []byte) error { - var jsonStruct = struct { - Prefix *Prefix `json:"prefix,omitempty"` - Fields json.RawMessage `json:"fields"` - }{} - if err := json.Unmarshal(bytes, &jsonStruct); err != nil { - return fmt.Errorf("failed to unmarshal struct's prefix: %w", err) - } - if jsonStruct.Prefix != nil { - s.hasPrefix = true - s.prefix = *jsonStruct.Prefix - } - - decoder := json.NewDecoder(strings.NewReader(string(jsonStruct.Fields))) - - _, err := decoder.Token() // { - if err != nil { - return fmt.Errorf("failed to unmarshal struct's fields value declrataion: %w", err) - } - for decoder.More() { - key, err := decoder.Token() - if err != nil { - return fmt.Errorf("failed to unmarshal struct's key: %w", err) - } - stringKey, ok := key.(string) - if !ok { - return fmt.Errorf("expected string key") - } - var val Value - if err = decoder.Decode(&val); err != nil { - return fmt.Errorf("failed to unmarshal struct's field %s value: %w", stringKey, err) - } - - s.fieldNames = append(s.fieldNames, stringKey) - s.fieldValues = append(s.fieldValues, val) - } - - return nil -} - type EnumValue struct { - ActualValue Value `json:"actualValue"` - Name string `json:"name"` - Value big.Int `json:"value"` + ActualValue Value + Name string + Value big.Int } func (e *EnumValue) Unmarshal(cell *boc.Cell, ty tolkParser.EnumRef, decoder *Decoder) error { @@ -403,6 +333,14 @@ func (e *EnumValue) Unmarshal(cell *boc.Cell, ty tolkParser.EnumRef, decoder *De return fmt.Errorf("enum value didn't match any values") } +func (e EnumValue) MarshalJSON() ([]byte, error) { + data, err := json.Marshal(e.Name) + if err != nil { + return nil, fmt.Errorf("failed to marshal enum's value: %w", err) + } + return data, nil +} + func (e *EnumValue) Marshal(cell *boc.Cell, ty tolkParser.EnumRef, encoder *Encoder) error { if encoder.abiRefs.enumRefs == nil { return fmt.Errorf("struct has enum reference but no abi has been given") diff --git a/tolk/runtime.go b/tolk/runtime.go index be245dad..71b41936 100644 --- a/tolk/runtime.go +++ b/tolk/runtime.go @@ -80,7 +80,7 @@ func (d *Decoder) Unmarshal(cell *boc.Cell, ty tolkParser.Ty) (*Value, error) { } func (d *Decoder) UnmarshalMessage(cell *boc.Cell) (*Value, error) { - res, isResolved, err := resolvePayload(cell, d) + res, isResolved, err := d.resolvePayload(cell) if err != nil { return nil, fmt.Errorf("failed to unmarshal tolk value: %w", err) } @@ -94,6 +94,26 @@ func (d *Decoder) UnmarshalMessage(cell *boc.Cell) (*Value, error) { return &res, nil } +func (d *Decoder) resolvePayload(payload *boc.Cell) (Value, bool, error) { + payloadOpcode, err := payload.ReadUint(32) // payload always 32 bit length + if err != nil { + return Value{}, false, fmt.Errorf("failed to read payload's opcode: %w", err) + } + payload.ResetCounters() // reset opcode + + guessedStructs := d.abiRefs.opcodeRefs[payloadOpcode] + for _, strct := range guessedStructs { + v, err := d.Unmarshal(payload, tolkParser.NewStructType(strct.Name)) + if err != nil { + continue + } + return *v, true, nil + } + + // todo: maybe try every known struct to unmarshal to? + return Value{}, false, nil +} + type customPackResolver = func(tolkParser.AliasRef, *boc.Cell, *AliasValue) error type Encoder struct { @@ -105,8 +125,8 @@ func NewEncoder() *Encoder { return &Encoder{} } -func (a *Encoder) WithABIs(abis ...tolkParser.ABI) error { - a.abiRefs = abiRefs{ +func (e *Encoder) WithABIs(abis ...tolkParser.ABI) error { + e.abiRefs = abiRefs{ structRefs: make(map[string]tolkParser.StructDeclaration), aliasRefs: make(map[string]tolkParser.AliasDeclaration), enumRefs: make(map[string]tolkParser.EnumDeclaration), @@ -117,31 +137,31 @@ func (a *Encoder) WithABIs(abis ...tolkParser.ABI) error { for _, declr := range abi.Declarations { switch declr.SumType { case "Struct": - a.abiRefs.structRefs[declr.StructDeclaration.Name] = declr.StructDeclaration + e.abiRefs.structRefs[declr.StructDeclaration.Name] = declr.StructDeclaration if declr.StructDeclaration.Prefix != nil { prefix, err := binHexToUint64(declr.StructDeclaration.Prefix.PrefixStr) if err != nil { return fmt.Errorf("failed to parse prefix struct %v prefix: %w", declr.StructDeclaration.Name, err) } - a.abiRefs.opcodeRefs[prefix] = append(a.abiRefs.opcodeRefs[prefix], declr.StructDeclaration) + e.abiRefs.opcodeRefs[prefix] = append(e.abiRefs.opcodeRefs[prefix], declr.StructDeclaration) } case "Alias": - a.abiRefs.aliasRefs[declr.AliasDeclaration.Name] = declr.AliasDeclaration + e.abiRefs.aliasRefs[declr.AliasDeclaration.Name] = declr.AliasDeclaration case "Enum": - a.abiRefs.enumRefs[declr.EnumDeclaration.Name] = declr.EnumDeclaration + e.abiRefs.enumRefs[declr.EnumDeclaration.Name] = declr.EnumDeclaration } } } return nil } -func (a *Encoder) WithCustomPackResolver(customPackResolver customPackResolver) { - a.customPackResolver = customPackResolver +func (e *Encoder) WithCustomPackResolver(customPackResolver customPackResolver) { + e.customPackResolver = customPackResolver } -func (a *Encoder) Marshal(v *Value, ty tolkParser.Ty) (*boc.Cell, error) { +func (e *Encoder) Marshal(v *Value, ty tolkParser.Ty) (*boc.Cell, error) { cell := boc.NewCell() - err := v.Marshal(cell, ty, a) + err := v.Marshal(cell, ty, e) if err != nil { return nil, fmt.Errorf("failed to marshal tolk value: %w", err) } diff --git a/tolk/runtime_test.go b/tolk/runtime_test.go index 9bea10bc..8fdcbcfa 100644 --- a/tolk/runtime_test.go +++ b/tolk/runtime_test.go @@ -2841,7 +2841,6 @@ func TestRuntime_UnmarshalAliasWithCustomUnpack(t *testing.T) { } func TestRuntime_MarshalSmallInt(t *testing.T) { - jsonInputFilename := "small_int" ty := tolkParser.NewIntNType(24) currCell, err := boc.DeserializeBocHex("b5ee9c72410101010005000006ff76c41616db06") @@ -2870,14 +2869,9 @@ func TestRuntime_MarshalSmallInt(t *testing.T) { t.Errorf("input and output cells are different") } - err = compareActualJson(jsonInputFilename, *v) - if err != nil { - t.Fatal(err) - } } func TestRuntime_MarshalSmallUInt(t *testing.T) { - jsonInputFilename := "small_uint" ty := tolkParser.NewUIntNType(53) currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000900000d00000000001d34e435eafd") @@ -2906,14 +2900,9 @@ func TestRuntime_MarshalSmallUInt(t *testing.T) { t.Errorf("input and output cells are different") } - err = compareActualJson(jsonInputFilename, *v) - if err != nil { - t.Fatal(err) - } } func TestRuntime_MarshalBigInt(t *testing.T) { - jsonInputFilename := "big_int" ty := tolkParser.NewIntNType(183) currCell, err := boc.DeserializeBocHex("b5ee9c7241010101001900002dfffffffffffffffffffffffffffffffffff99bfeac6423a6f0b50c") @@ -2942,14 +2931,9 @@ func TestRuntime_MarshalBigInt(t *testing.T) { t.Errorf("input and output cells are different") } - err = compareActualJson(jsonInputFilename, *v) - if err != nil { - t.Fatal(err) - } } func TestRuntime_MarshalBigUInt(t *testing.T) { - jsonInputFilename := "big_uint" ty := tolkParser.NewUIntNType(257) currCell, err := boc.DeserializeBocHex("b5ee9c7241010101002300004100000000000000000000000000000000000000000000000000009fc4212a38ba40b11cce12") @@ -2978,14 +2962,9 @@ func TestRuntime_MarshalBigUInt(t *testing.T) { t.Errorf("input and output cells are different") } - err = compareActualJson(jsonInputFilename, *v) - if err != nil { - t.Fatal(err) - } } func TestRuntime_MarshalVarInt(t *testing.T) { - jsonInputFilename := "var_int" ty := tolkParser.NewVarInt16Type() currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000600000730c98588449b6923") @@ -3014,14 +2993,9 @@ func TestRuntime_MarshalVarInt(t *testing.T) { t.Errorf("input and output cells are different") } - err = compareActualJson(jsonInputFilename, *v) - if err != nil { - t.Fatal(err) - } } func TestRuntime_MarshalVarUInt(t *testing.T) { - jsonInputFilename := "var_uint" ty := tolkParser.NewVarUInt32Type() currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000800000b28119ab36b44d3a86c0f") @@ -3050,14 +3024,9 @@ func TestRuntime_MarshalVarUInt(t *testing.T) { t.Errorf("input and output cells are different") } - err = compareActualJson(jsonInputFilename, *v) - if err != nil { - t.Fatal(err) - } } func TestRuntime_MarshalBits(t *testing.T) { - jsonInputFilename := "bits" ty := tolkParser.NewBitsNType(24) currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000500000631323318854035") @@ -3086,14 +3055,9 @@ func TestRuntime_MarshalBits(t *testing.T) { t.Errorf("input and output cells are different") } - err = compareActualJson(jsonInputFilename, *v) - if err != nil { - t.Fatal(err) - } } func TestRuntime_MarshalCoins(t *testing.T) { - jsonInputFilename := "coins" ty := tolkParser.NewCoinsType() currCell, err := boc.DeserializeBocHex("b5ee9c72410101010007000009436ec6e0189ebbd7f4") @@ -3122,14 +3086,9 @@ func TestRuntime_MarshalCoins(t *testing.T) { t.Errorf("input and output cells are different") } - err = compareActualJson(jsonInputFilename, *v) - if err != nil { - t.Fatal(err) - } } func TestRuntime_MarshalBool(t *testing.T) { - jsonInputFilename := "bool" ty := tolkParser.NewBoolType() currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000300000140f6d24034") @@ -3158,14 +3117,9 @@ func TestRuntime_MarshalBool(t *testing.T) { t.Errorf("input and output cells are different") } - err = compareActualJson(jsonInputFilename, *v) - if err != nil { - t.Fatal(err) - } } func TestRuntime_MarshalCell(t *testing.T) { - jsonInputFilename := "cell" ty := tolkParser.NewCellType() currCell, err := boc.DeserializeBocHex("b5ee9c724101020100090001000100080000007ba52a3292") @@ -3194,14 +3148,9 @@ func TestRuntime_MarshalCell(t *testing.T) { t.Errorf("input and output cells are different") } - err = compareActualJson(jsonInputFilename, *v) - if err != nil { - t.Fatal(err) - } } func TestRuntime_MarshalRemaining(t *testing.T) { - jsonInputFilename := "remaining" ty := tolkParser.NewRemainingType() currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000900000dc0800000000ab8d04726e4") @@ -3230,14 +3179,9 @@ func TestRuntime_MarshalRemaining(t *testing.T) { t.Errorf("input and output cells are different") } - err = compareActualJson(jsonInputFilename, *v) - if err != nil { - t.Fatal(err) - } } func TestRuntime_MarshalAddress(t *testing.T) { - jsonInputFilename := "internal_address" ty := tolkParser.NewAddressType() currCell, err := boc.DeserializeBocHex("b5ee9c7241010101002400004380107bfaaa5cc6e5368e5f9799188bd798cd22e04ab16d1d8ea4fc37480741e6351064a3e1a6") @@ -3266,14 +3210,9 @@ func TestRuntime_MarshalAddress(t *testing.T) { t.Errorf("input and output cells are different") } - err = compareActualJson(jsonInputFilename, *v) - if err != nil { - t.Fatal(err) - } } func TestRuntime_MarshalNotExitsOptionalAddress(t *testing.T) { - jsonInputFilename := "not_exists_optional_address" ty := tolkParser.NewAddressOptType() currCell, err := boc.DeserializeBocHex("b5ee9c724101010100030000012094418655") @@ -3302,14 +3241,9 @@ func TestRuntime_MarshalNotExitsOptionalAddress(t *testing.T) { t.Errorf("input and output cells are different") } - err = compareActualJson(jsonInputFilename, *v) - if err != nil { - t.Fatal(err) - } } func TestRuntime_MarshalExistsOptionalAddress(t *testing.T) { - jsonInputFilename := "exists_optional_address" ty := tolkParser.NewAddressOptType() currCell, err := boc.DeserializeBocHex("b5ee9c7241010101002400004380107bfaaa5cc6e5368e5f9799188bd798cd22e04ab16d1d8ea4fc37480741e6351064a3e1a6") @@ -3338,14 +3272,9 @@ func TestRuntime_MarshalExistsOptionalAddress(t *testing.T) { t.Errorf("input and output cells are different") } - err = compareActualJson(jsonInputFilename, *v) - if err != nil { - t.Fatal(err) - } } func TestRuntime_MarshalExternalAddress(t *testing.T) { - jsonInputFilename := "external_address" ty := tolkParser.NewAddressExtType() currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000600000742082850fcbd94fd") @@ -3374,14 +3303,9 @@ func TestRuntime_MarshalExternalAddress(t *testing.T) { t.Errorf("input and output cells are different") } - err = compareActualJson(jsonInputFilename, *v) - if err != nil { - t.Fatal(err) - } } func TestRuntime_MarshalAnyNoneAddress(t *testing.T) { - jsonInputFilename := "any_none_address" ty := tolkParser.NewAddressAnyType() currCell, err := boc.DeserializeBocHex("b5ee9c724101010100030000012094418655") @@ -3410,14 +3334,9 @@ func TestRuntime_MarshalAnyNoneAddress(t *testing.T) { t.Errorf("input and output cells are different") } - err = compareActualJson(jsonInputFilename, *v) - if err != nil { - t.Fatal(err) - } } func TestRuntime_MarshalAnyInternalAddress(t *testing.T) { - jsonInputFilename := "any_internal_address" ty := tolkParser.NewAddressAnyType() currCell, err := boc.DeserializeBocHex("b5ee9c7241010101002400004380107bfaaa5cc6e5368e5f9799188bd798cd22e04ab16d1d8ea4fc37480741e6351064a3e1a6") @@ -3446,14 +3365,9 @@ func TestRuntime_MarshalAnyInternalAddress(t *testing.T) { t.Errorf("input and output cells are different") } - err = compareActualJson(jsonInputFilename, *v) - if err != nil { - t.Fatal(err) - } } func TestRuntime_MarshalAnyExternalAddress(t *testing.T) { - jsonInputFilename := "any_external_address" ty := tolkParser.NewAddressAnyType() currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000600000742082850fcbd94fd") @@ -3482,14 +3396,9 @@ func TestRuntime_MarshalAnyExternalAddress(t *testing.T) { t.Errorf("input and output cells are different") } - err = compareActualJson(jsonInputFilename, *v) - if err != nil { - t.Fatal(err) - } } func TestRuntime_MarshalAnyVarAddress(t *testing.T) { - jsonInputFilename := "any_var_address" ty := tolkParser.NewAddressAnyType() currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000900000dc0800000000ab8d04726e4") @@ -3518,14 +3427,9 @@ func TestRuntime_MarshalAnyVarAddress(t *testing.T) { t.Errorf("input and output cells are different") } - err = compareActualJson(jsonInputFilename, *v) - if err != nil { - t.Fatal(err) - } } func TestRuntime_MarshalNotExistsNullable(t *testing.T) { - jsonInputFilename := "not_exists_nullable" ty := tolkParser.NewNullableType(tolkParser.NewRemainingType()) currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000300000140f6d24034") @@ -3554,14 +3458,9 @@ func TestRuntime_MarshalNotExistsNullable(t *testing.T) { t.Errorf("input and output cells are different") } - err = compareActualJson(jsonInputFilename, *v) - if err != nil { - t.Fatal(err) - } } func TestRuntime_MarshalExistsNullable(t *testing.T) { - jsonInputFilename := "exists_nullable" ty := tolkParser.NewNullableType(tolkParser.NewCellType()) currCell, err := boc.DeserializeBocHex("b5ee9c7241010201000b000101c001000900000c0ae007880db9") @@ -3590,14 +3489,9 @@ func TestRuntime_MarshalExistsNullable(t *testing.T) { t.Errorf("input and output cells are different") } - err = compareActualJson(jsonInputFilename, *v) - if err != nil { - t.Fatal(err) - } } func TestRuntime_MarshalRef(t *testing.T) { - jsonInputFilename := "ref" ty := tolkParser.NewCellOfType(tolkParser.NewIntNType(65)) currCell, err := boc.DeserializeBocHex("b5ee9c7241010201000e000100010011000000000009689e40e150b4c5") @@ -3626,14 +3520,9 @@ func TestRuntime_MarshalRef(t *testing.T) { t.Errorf("input and output cells are different") } - err = compareActualJson(jsonInputFilename, *v) - if err != nil { - t.Fatal(err) - } } func TestRuntime_MarshalEmptyTensor(t *testing.T) { - jsonInputFilename := "empty_tensor" ty := tolkParser.NewTensorType() currCell, err := boc.DeserializeBocHex("b5ee9c724101010100020000004cacb9cd") @@ -3662,14 +3551,9 @@ func TestRuntime_MarshalEmptyTensor(t *testing.T) { t.Errorf("input and output cells are different") } - err = compareActualJson(jsonInputFilename, *v) - if err != nil { - t.Fatal(err) - } } func TestRuntime_MarshalTensor(t *testing.T) { - jsonInputFilename := "tensor" ty := tolkParser.NewTensorType( tolkParser.NewUIntNType(123), tolkParser.NewBoolType(), @@ -3707,14 +3591,9 @@ func TestRuntime_MarshalTensor(t *testing.T) { t.Errorf("input and output cells are different") } - err = compareActualJson(jsonInputFilename, *v) - if err != nil { - t.Fatal(err) - } } func TestRuntime_MarshalIntKeyMap(t *testing.T) { - jsonInputFilename := "int_key_map" ty := tolkParser.NewMapType(tolkParser.NewIntNType(32), tolkParser.NewBoolType()) currCell, err := boc.DeserializeBocHex("b5ee9c7241010201000c000101c001000ba00000007bc09a662c32") @@ -3743,14 +3622,9 @@ func TestRuntime_MarshalIntKeyMap(t *testing.T) { t.Errorf("input and output cells are different") } - err = compareActualJson(jsonInputFilename, *v) - if err != nil { - t.Fatal(err) - } } func TestRuntime_MarshalUIntKeyMap(t *testing.T) { - jsonInputFilename := "uint_key_map" ty := tolkParser.NewMapType(tolkParser.NewUIntNType(16), tolkParser.NewAddressType()) currCell, err := boc.DeserializeBocHex("b5ee9c72410104010053000101c0010202cb02030045a7400b113a994b5024a16719f69139328eb759596c38a25f59028b146fecdc3621dfe80045a3cff5555555555555555555555555555555555555555555555555555555555555555888440ce8") @@ -3779,14 +3653,9 @@ func TestRuntime_MarshalUIntKeyMap(t *testing.T) { t.Errorf("input and output cells are different") } - err = compareActualJson(jsonInputFilename, *v) - if err != nil { - t.Fatal(err) - } } func TestRuntime_MarshalBigIntKeyMap(t *testing.T) { - jsonInputFilename := "big_int_key_map" ty := tolkParser.NewMapType(tolkParser.NewUIntNType(78), tolkParser.NewCellType()) currCell, err := boc.DeserializeBocHex("b5ee9c7241010301001a000101c0010115a70000000000000047550902000b000000001ab01d5bf1a9") @@ -3815,14 +3684,9 @@ func TestRuntime_MarshalBigIntKeyMap(t *testing.T) { t.Errorf("input and output cells are different") } - err = compareActualJson(jsonInputFilename, *v) - if err != nil { - t.Fatal(err) - } } func TestRuntime_MarshalBitsKeyMap(t *testing.T) { - jsonInputFilename := "bits_int_key_map" ty := tolkParser.NewMapType( tolkParser.NewBitsNType(16), tolkParser.NewMapType( @@ -3860,14 +3724,9 @@ func TestRuntime_MarshalBitsKeyMap(t *testing.T) { t.Errorf("input and output cells are different") } - err = compareActualJson(jsonInputFilename, *v) - if err != nil { - t.Fatal(err) - } } func TestRuntime_MarshalAddressKeyMap(t *testing.T) { - jsonInputFilename := "address_key_map" ty := tolkParser.NewMapType(tolkParser.NewAddressType(), tolkParser.NewCoinsType()) currCell, err := boc.DeserializeBocHex("b5ee9c7241010201002f000101c0010051a17002c44ea652d4092859c67da44e4ca3add6565b0e2897d640a2c51bfb370d8877f9409502f9002016fdc16e") @@ -3896,14 +3755,9 @@ func TestRuntime_MarshalAddressKeyMap(t *testing.T) { t.Errorf("input and output cells are different") } - err = compareActualJson(jsonInputFilename, *v) - if err != nil { - t.Fatal(err) - } } func TestRuntime_MarshalUnionWithDecPrefix(t *testing.T) { - jsonInputFilename := "union_with_dec_prefix" ty := tolkParser.NewUnionType( 1, true, tolkParser.NewUnionVariant(tolkParser.NewIntNType(16), "0"), @@ -3936,14 +3790,9 @@ func TestRuntime_MarshalUnionWithDecPrefix(t *testing.T) { t.Errorf("input and output cells are different") } - err = compareActualJson(jsonInputFilename, *v) - if err != nil { - t.Fatal(err) - } } func TestRuntime_MarshalUnionWithBinPrefix(t *testing.T) { - jsonInputFilename := "union_with_bin_prefix" inputFilename := "testdata/bin_union.json" data, err := os.ReadFile(inputFilename) if err != nil { @@ -3999,14 +3848,9 @@ func TestRuntime_MarshalUnionWithBinPrefix(t *testing.T) { t.Errorf("input and output cells are different") } - err = compareActualJson(jsonInputFilename, *v) - if err != nil { - t.Fatal(err) - } } func TestRuntime_MarshalUnionWithHexPrefix(t *testing.T) { - jsonInputFilename := "union_with_hex_prefix" inputFilename := "testdata/hex_union.json" data, err := os.ReadFile(inputFilename) if err != nil { @@ -4062,14 +3906,9 @@ func TestRuntime_MarshalUnionWithHexPrefix(t *testing.T) { t.Errorf("input and output cells are different") } - err = compareActualJson(jsonInputFilename, *v) - if err != nil { - t.Fatal(err) - } } func TestRuntime_MarshalALotRefsFromAlias(t *testing.T) { - jsonInputFilename := "a_lot_refs_from_alias" inputFilename := "testdata/refs.json" data, err := os.ReadFile(inputFilename) if err != nil { @@ -4126,14 +3965,9 @@ func TestRuntime_MarshalALotRefsFromAlias(t *testing.T) { t.Errorf("input and output cells are different") } - err = compareActualJson(jsonInputFilename, *v) - if err != nil { - t.Fatal(err) - } } func TestRuntime_MarshalALotRefsFromStruct(t *testing.T) { - jsonInputFilename := "a_lot_refs_from_struct" inputFilename := "testdata/refs.json" data, err := os.ReadFile(inputFilename) if err != nil { @@ -4183,14 +4017,9 @@ func TestRuntime_MarshalALotRefsFromStruct(t *testing.T) { t.Errorf("input and output cells are different") } - err = compareActualJson(jsonInputFilename, *v) - if err != nil { - t.Fatal(err) - } } func TestRuntime_MarshalALotGenericsFromStruct(t *testing.T) { - jsonInputFilename := "a_lot_generics_from_struct" inputFilename := "testdata/generics.json" data, err := os.ReadFile(inputFilename) if err != nil { @@ -4241,14 +4070,9 @@ func TestRuntime_MarshalALotGenericsFromStruct(t *testing.T) { t.Errorf("input and output cells are different") } - err = compareActualJson(jsonInputFilename, *v) - if err != nil { - t.Fatal(err) - } } func TestRuntime_MarshalALotGenericsFromAlias(t *testing.T) { - jsonInputFilename := "a_lot_generics_from_alias" inputFilename := "testdata/generics.json" data, err := os.ReadFile(inputFilename) if err != nil { @@ -4299,14 +4123,9 @@ func TestRuntime_MarshalALotGenericsFromAlias(t *testing.T) { t.Errorf("input and output cells are different") } - err = compareActualJson(jsonInputFilename, *v) - if err != nil { - t.Fatal(err) - } } func TestRuntime_MarshalStructWithDefaultValues(t *testing.T) { - jsonInputFilename := "a_lot_generics_with_default_values" inputFilename := "testdata/default_values.json" data, err := os.ReadFile(inputFilename) if err != nil { @@ -4357,14 +4176,9 @@ func TestRuntime_MarshalStructWithDefaultValues(t *testing.T) { t.Errorf("input and output cells are different") } - err = compareActualJson(jsonInputFilename, *v) - if err != nil { - t.Fatal(err) - } } func TestRuntime_MarshalALotNumbers(t *testing.T) { - jsonInputFilename := "a_lot_numbers" inputFilename := "testdata/numbers.json" data, err := os.ReadFile(inputFilename) if err != nil { @@ -4415,14 +4229,9 @@ func TestRuntime_MarshalALotNumbers(t *testing.T) { t.Errorf("input and output cells are different") } - err = compareActualJson(jsonInputFilename, *v) - if err != nil { - t.Fatal(err) - } } func TestRuntime_MarshalALotRandomFields(t *testing.T) { - jsonInputFilename := "a_lot_random_fields" inputFilename := "testdata/random_fields.json" data, err := os.ReadFile(inputFilename) if err != nil { @@ -4473,14 +4282,9 @@ func TestRuntime_MarshalALotRandomFields(t *testing.T) { t.Errorf("input and output cells are different") } - err = compareActualJson(jsonInputFilename, *v) - if err != nil { - t.Fatal(err) - } } func TestRuntime_MarshalAliasWithCustomUnpack(t *testing.T) { - jsonInputFilename := "custom_pack_unpack" inputFilename := "testdata/custom_pack_unpack.json" data, err := os.ReadFile(inputFilename) if err != nil { @@ -4569,31 +4373,16 @@ func TestRuntime_MarshalAliasWithCustomUnpack(t *testing.T) { t.Errorf("input and output cells are different") } - err = compareActualJson(jsonInputFilename, *v) - if err != nil { - t.Fatal(err) - } -} - -func compareActualJson(inputFilename string, v Value) error { - pathPrefix := jsonFilesPath + inputFilename - actualJson, err := os.ReadFile(pathPrefix + ".json") - if err != nil { - return err - } - var jsonV Value - if err = json.Unmarshal(actualJson, &jsonV); err != nil { - return err - } - if !v.Equal(jsonV) { - return fmt.Errorf("%s got different results", pathPrefix) - } - return nil } func compareExpectedJson(inputFilename string, v Value) error { + val := struct { + Value Value `json:"value"` + }{ + Value: v, + } pathPrefix := jsonFilesPath + inputFilename - actual, err := json.MarshalIndent(v, "", " ") + actual, err := json.MarshalIndent(val, "", " ") if err != nil { return err } diff --git a/tolk/testdata/json/a_lot_generics_from_alias.json b/tolk/testdata/json/a_lot_generics_from_alias.json index 441a8831..2d54a0fc 100755 --- a/tolk/testdata/json/a_lot_generics_from_alias.json +++ b/tolk/testdata/json/a_lot_generics_from_alias.json @@ -1,158 +1,27 @@ { - "sumType": "alias", - "alias": { - "sumType": "struct", - "struct": { - "fields": { - "payload": { - "sumType": "struct", - "struct": { - "fields": { - "value": { - "sumType": "union", - "union": { - "prefix": { - "len": 1, - "prefix": 1 - }, - "value": { - "sumType": "refValue", - "refValue": { - "sumType": "generic", - "generic": { - "sumType": "smallUint", - "smallUint": 123 - } - } - } - } - } - } - } - }, - "either": { - "sumType": "alias", - "alias": { - "sumType": "union", - "union": { - "prefix": { - "len": 1, - "prefix": 1 - }, - "value": { - "sumType": "struct", - "struct": { - "fields": { - "value": { - "sumType": "generic", - "generic": { - "sumType": "coins", - "coins": "100000000" - } - } - } - } - } - } - } - }, - "anotherEither": { - "sumType": "alias", - "alias": { - "sumType": "alias", - "alias": { - "sumType": "union", - "union": { - "prefix": { - "len": 1, - "prefix": 1 - }, - "value": { - "sumType": "struct", - "struct": { - "fields": { - "value": { - "sumType": "generic", - "generic": { - "sumType": "tensor", - "tensor": [ - { - "sumType": "bool", - "bool": true - }, - { - "sumType": "coins", - "coins": "1000000000" - } - ] - } - } - } - } - } - } - } - } - }, - "doubler": { - "sumType": "refValue", - "refValue": { - "sumType": "alias", - "alias": { - "sumType": "tensor", - "tensor": [ - { - "sumType": "generic", - "generic": { - "sumType": "tensor", - "tensor": [ - { - "sumType": "coins", - "coins": "1000000000" - }, - { - "sumType": "optionalAddress", - "optionalAddress": { - "sumType": "noneAddress" - } - } - ] - } - }, - { - "sumType": "generic", - "generic": { - "sumType": "tensor", - "tensor": [ - { - "sumType": "coins", - "coins": "100000000" - }, - { - "sumType": "optionalAddress", - "optionalAddress": { - "sumType": "internalAddress", - "internalAddress": "0:b113a994b5024a16719f69139328eb759596c38a25f59028b146fecdc3621dfe" - } - } - ] - } - } - ] - } - } - }, - "myVal": { - "sumType": "alias", - "alias": { - "sumType": "generic", - "generic": { - "sumType": "smallUint", - "smallUint": 16 - } - } - } - } - } + "value": { + "payload": { + "value": 123 + }, + "either": { + "value": "100000000" + }, + "anotherEither": { + "value": [ + true, + "1000000000" + ] + }, + "doubler": [ + [ + "1000000000", + "" + ], + [ + "100000000", + "0:b113a994b5024a16719f69139328eb759596c38a25f59028b146fecdc3621dfe" + ] + ], + "myVal": 16 } } \ No newline at end of file diff --git a/tolk/testdata/json/a_lot_generics_from_struct.json b/tolk/testdata/json/a_lot_generics_from_struct.json index 5f371da4..2d54a0fc 100755 --- a/tolk/testdata/json/a_lot_generics_from_struct.json +++ b/tolk/testdata/json/a_lot_generics_from_struct.json @@ -1,155 +1,27 @@ { - "sumType": "struct", - "struct": { - "fields": { - "payload": { - "sumType": "struct", - "struct": { - "fields": { - "value": { - "sumType": "union", - "union": { - "prefix": { - "len": 1, - "prefix": 1 - }, - "value": { - "sumType": "refValue", - "refValue": { - "sumType": "generic", - "generic": { - "sumType": "smallUint", - "smallUint": 123 - } - } - } - } - } - } - } - }, - "either": { - "sumType": "alias", - "alias": { - "sumType": "union", - "union": { - "prefix": { - "len": 1, - "prefix": 1 - }, - "value": { - "sumType": "struct", - "struct": { - "fields": { - "value": { - "sumType": "generic", - "generic": { - "sumType": "coins", - "coins": "100000000" - } - } - } - } - } - } - } - }, - "anotherEither": { - "sumType": "alias", - "alias": { - "sumType": "alias", - "alias": { - "sumType": "union", - "union": { - "prefix": { - "len": 1, - "prefix": 1 - }, - "value": { - "sumType": "struct", - "struct": { - "fields": { - "value": { - "sumType": "generic", - "generic": { - "sumType": "tensor", - "tensor": [ - { - "sumType": "bool", - "bool": true - }, - { - "sumType": "coins", - "coins": "1000000000" - } - ] - } - } - } - } - } - } - } - } - }, - "doubler": { - "sumType": "refValue", - "refValue": { - "sumType": "alias", - "alias": { - "sumType": "tensor", - "tensor": [ - { - "sumType": "generic", - "generic": { - "sumType": "tensor", - "tensor": [ - { - "sumType": "coins", - "coins": "1000000000" - }, - { - "sumType": "optionalAddress", - "optionalAddress": { - "sumType": "noneAddress" - } - } - ] - } - }, - { - "sumType": "generic", - "generic": { - "sumType": "tensor", - "tensor": [ - { - "sumType": "coins", - "coins": "100000000" - }, - { - "sumType": "optionalAddress", - "optionalAddress": { - "sumType": "internalAddress", - "internalAddress": "0:b113a994b5024a16719f69139328eb759596c38a25f59028b146fecdc3621dfe" - } - } - ] - } - } - ] - } - } - }, - "myVal": { - "sumType": "alias", - "alias": { - "sumType": "generic", - "generic": { - "sumType": "smallUint", - "smallUint": 16 - } - } - } - } + "value": { + "payload": { + "value": 123 + }, + "either": { + "value": "100000000" + }, + "anotherEither": { + "value": [ + true, + "1000000000" + ] + }, + "doubler": [ + [ + "1000000000", + "" + ], + [ + "100000000", + "0:b113a994b5024a16719f69139328eb759596c38a25f59028b146fecdc3621dfe" + ] + ], + "myVal": 16 } } \ No newline at end of file diff --git a/tolk/testdata/json/a_lot_generics_with_default_values.json b/tolk/testdata/json/a_lot_generics_with_default_values.json index c10149ff..a54dc88b 100755 --- a/tolk/testdata/json/a_lot_generics_with_default_values.json +++ b/tolk/testdata/json/a_lot_generics_with_default_values.json @@ -1,78 +1,28 @@ { - "sumType": "struct", - "struct": { - "fields": { - "num1": { - "sumType": "optionalValue", - "optionalValue": { - "isExists": true, - "value": { - "sumType": "smallUint", - "smallUint": 4 - } - } - }, - "num2": { - "sumType": "optionalValue", - "optionalValue": { - "isExists": true, - "value": { - "sumType": "alias", - "alias": { - "sumType": "smallInt", - "smallInt": 5 - } - } - } - }, - "addr4": { - "sumType": "optionalAddress", - "optionalAddress": { - "sumType": "noneAddress" - } - }, - "addr5": { - "sumType": "optionalAddress", - "optionalAddress": { - "sumType": "internalAddress", - "internalAddress": "0:b113a994b5024a16719f69139328eb759596c38a25f59028b146fecdc3621dfe" - } - }, - "tensor6": { - "sumType": "optionalValue", - "optionalValue": { - "isExists": true, - "value": { - "sumType": "tensor", - "tensor": [ - { - "sumType": "smallInt", - "smallInt": 342 - }, - { - "sumType": "bool", - "bool": true - } - ] - } - } - }, - "num7": { - "sumType": "optionalValue", - "optionalValue": { - "isExists": false - } - }, - "slice3": { - "sumType": "optionalValue", - "optionalValue": { - "isExists": true, - "value": { - "sumType": "remaining", - "remaining": "b5ee9c72010101010005000006616263" - } - } - } + "value": { + "num1": { + "isExists": true, + "value": 4 + }, + "num2": { + "isExists": true, + "value": 5 + }, + "addr4": "", + "addr5": "0:b113a994b5024a16719f69139328eb759596c38a25f59028b146fecdc3621dfe", + "tensor6": { + "isExists": true, + "value": [ + 342, + true + ] + }, + "num7": { + "isExists": false + }, + "slice3": { + "isExists": true, + "value": "b5ee9c72010101010005000006616263" } } } \ No newline at end of file diff --git a/tolk/testdata/json/a_lot_numbers.json b/tolk/testdata/json/a_lot_numbers.json index c3e8a257..af649dd6 100755 --- a/tolk/testdata/json/a_lot_numbers.json +++ b/tolk/testdata/json/a_lot_numbers.json @@ -1,35 +1,11 @@ { - "sumType": "struct", - "struct": { - "fields": { - "num1": { - "sumType": "smallUint", - "smallUint": 0 - }, - "num3": { - "sumType": "bigUint", - "bigUint": "241" - }, - "num4": { - "sumType": "varUint", - "varUint": "3421" - }, - "num5": { - "sumType": "bool", - "bool": true - }, - "num7": { - "sumType": "bits", - "bits": "3132" - }, - "num8": { - "sumType": "smallInt", - "smallInt": 0 - }, - "num9": { - "sumType": "varInt", - "varInt": "2342" - } - } + "value": { + "num1": 0, + "num3": "241", + "num4": "3421", + "num5": true, + "num7": "3132", + "num8": 0, + "num9": "2342" } } \ No newline at end of file diff --git a/tolk/testdata/json/a_lot_random_fields.json b/tolk/testdata/json/a_lot_random_fields.json index 7246626a..a8ee2b73 100755 --- a/tolk/testdata/json/a_lot_random_fields.json +++ b/tolk/testdata/json/a_lot_random_fields.json @@ -1,93 +1,24 @@ { - "sumType": "struct", - "struct": { - "prefix": { - "len": 12, - "prefix": 1940 - }, - "fields": { - "dest_int": { - "sumType": "internalAddress", - "internalAddress": "0:83dfd552e63729b472fcbcc8c45ebcc6691702558b68ec7527e1ba403a0f31a8" - }, - "amount": { - "sumType": "coins", - "coins": "500000123400000" - }, - "dest_ext": { - "sumType": "anyAddress", - "anyAddress": { - "sumType": "noneAddress" - } - }, - "intVector": { - "sumType": "tensor", - "tensor": [ - { - "sumType": "smallInt", - "smallInt": 342 - }, - { - "sumType": "optionalValue", - "optionalValue": { - "isExists": true, - "value": { - "sumType": "coins", - "coins": "1000000000" - } - } - }, - { - "sumType": "smallUint", - "smallUint": 23443 - } - ] - }, - "needs_more": { - "sumType": "refValue", - "refValue": { - "sumType": "bool", - "bool": true - } - }, - "some_payload": { - "sumType": "cell", - "cell": "b5ee9c7201010101002b000051000000000005120041efeaa9731b94da397e5e64622f5e63348b812ac5b4763a93f0dd201d0798d440" - }, - "my_int": { - "sumType": "alias", - "alias": { - "sumType": "smallInt", - "smallInt": 432 - } - }, - "some_union": { - "sumType": "union", - "union": { - "prefix": { - "len": 2, - "prefix": 1 - }, - "value": { - "sumType": "smallInt", - "smallInt": 30000 - } - } - }, - "default_1": { - "sumType": "smallInt", - "smallInt": 1 - }, - "default_2": { - "sumType": "optionalValue", - "optionalValue": { - "isExists": true, - "value": { - "sumType": "smallInt", - "smallInt": 55 - } - } - } + "value": { + "dest_int": "0:83dfd552e63729b472fcbcc8c45ebcc6691702558b68ec7527e1ba403a0f31a8", + "amount": "500000123400000", + "dest_ext": "", + "intVector": [ + 342, + { + "isExists": true, + "value": "1000000000" + }, + 23443 + ], + "needs_more": true, + "some_payload": "b5ee9c7201010101002b000051000000000005120041efeaa9731b94da397e5e64622f5e63348b812ac5b4763a93f0dd201d0798d440", + "my_int": 432, + "some_union": 30000, + "default_1": 1, + "default_2": { + "isExists": true, + "value": 55 } } } \ No newline at end of file diff --git a/tolk/testdata/json/a_lot_refs_from_alias.json b/tolk/testdata/json/a_lot_refs_from_alias.json index b8d1b5bf..00319064 100755 --- a/tolk/testdata/json/a_lot_refs_from_alias.json +++ b/tolk/testdata/json/a_lot_refs_from_alias.json @@ -1,131 +1,27 @@ { - "sumType": "alias", - "alias": { - "sumType": "struct", - "struct": { - "prefix": { - "len": 32, - "prefix": 3735928559 - }, - "fields": { - "user1": { - "sumType": "alias", - "alias": { - "sumType": "struct", - "struct": { - "fields": { - "addr": { - "sumType": "internalAddress", - "internalAddress": "0:83dfd552e63729b472fcbcc8c45ebcc6691702558b68ec7527e1ba403a0f31a8" - }, - "balance": { - "sumType": "coins", - "coins": "1000000000" - } - } - } - } - }, - "user2": { - "sumType": "optionalValue", - "optionalValue": { - "isExists": true, - "value": { - "sumType": "refValue", - "refValue": { - "sumType": "alias", - "alias": { - "sumType": "struct", - "struct": { - "fields": { - "addr": { - "sumType": "internalAddress", - "internalAddress": "0:086fa2a675f74347b08dd4606a549b8fdb98829cb282bc1949d3b12fbaed9dcc" - }, - "balance": { - "sumType": "coins", - "coins": "100000000" - } - } - } - } - } - } - } - }, - "user3": { - "sumType": "cell", - "cell": "b5ee9c720101010100240000438006e05909e22b2e5e6087533314ee56505f85212914bd5547941a2a658ac62fe101" - }, - "user4": { - "sumType": "optionalValue", - "optionalValue": { - "isExists": false - } - }, - "user5": { - "sumType": "refValue", - "refValue": { - "sumType": "struct", - "struct": { - "fields": { - "addr": { - "sumType": "internalAddress", - "internalAddress": "0:b113a994b5024a16719f69139328eb759596c38a25f59028b146fecdc3621dfe" - }, - "balance": { - "sumType": "coins", - "coins": "10000000000000" - } - } - } - } - }, - "role": { - "sumType": "enum", - "enum": { - "actualValue": { - "sumType": "smallUint", - "smallUint": 1 - }, - "name": "Aboba", - "value": 1 - } - }, - "oper1": { - "sumType": "enum", - "enum": { - "actualValue": { - "sumType": "varUint", - "varUint": "0" - }, - "name": "Add", - "value": 0 - } - }, - "oper2": { - "sumType": "enum", - "enum": { - "actualValue": { - "sumType": "bigInt", - "bigInt": "-10000" - }, - "name": "TopUp", - "value": -10000 - } - }, - "oper3": { - "sumType": "enum", - "enum": { - "actualValue": { - "sumType": "smallUint", - "smallUint": 1 - }, - "name": "Something", - "value": 1 - } - } + "value": { + "user1": { + "addr": "0:83dfd552e63729b472fcbcc8c45ebcc6691702558b68ec7527e1ba403a0f31a8", + "balance": "1000000000" + }, + "user2": { + "isExists": true, + "value": { + "addr": "0:086fa2a675f74347b08dd4606a549b8fdb98829cb282bc1949d3b12fbaed9dcc", + "balance": "100000000" } - } + }, + "user3": "b5ee9c720101010100240000438006e05909e22b2e5e6087533314ee56505f85212914bd5547941a2a658ac62fe101", + "user4": { + "isExists": false + }, + "user5": { + "addr": "0:b113a994b5024a16719f69139328eb759596c38a25f59028b146fecdc3621dfe", + "balance": "10000000000000" + }, + "role": "Aboba", + "oper1": "Add", + "oper2": "TopUp", + "oper3": "Something" } } \ No newline at end of file diff --git a/tolk/testdata/json/a_lot_refs_from_struct.json b/tolk/testdata/json/a_lot_refs_from_struct.json index bf3fa2c9..00319064 100755 --- a/tolk/testdata/json/a_lot_refs_from_struct.json +++ b/tolk/testdata/json/a_lot_refs_from_struct.json @@ -1,128 +1,27 @@ { - "sumType": "struct", - "struct": { - "prefix": { - "len": 32, - "prefix": 3735928559 + "value": { + "user1": { + "addr": "0:83dfd552e63729b472fcbcc8c45ebcc6691702558b68ec7527e1ba403a0f31a8", + "balance": "1000000000" }, - "fields": { - "user1": { - "sumType": "alias", - "alias": { - "sumType": "struct", - "struct": { - "fields": { - "addr": { - "sumType": "internalAddress", - "internalAddress": "0:83dfd552e63729b472fcbcc8c45ebcc6691702558b68ec7527e1ba403a0f31a8" - }, - "balance": { - "sumType": "coins", - "coins": "1000000000" - } - } - } - } - }, - "user2": { - "sumType": "optionalValue", - "optionalValue": { - "isExists": true, - "value": { - "sumType": "refValue", - "refValue": { - "sumType": "alias", - "alias": { - "sumType": "struct", - "struct": { - "fields": { - "addr": { - "sumType": "internalAddress", - "internalAddress": "0:086fa2a675f74347b08dd4606a549b8fdb98829cb282bc1949d3b12fbaed9dcc" - }, - "balance": { - "sumType": "coins", - "coins": "100000000" - } - } - } - } - } - } - } - }, - "user3": { - "sumType": "cell", - "cell": "b5ee9c720101010100240000438006e05909e22b2e5e6087533314ee56505f85212914bd5547941a2a658ac62fe101" - }, - "user4": { - "sumType": "optionalValue", - "optionalValue": { - "isExists": false - } - }, - "user5": { - "sumType": "refValue", - "refValue": { - "sumType": "struct", - "struct": { - "fields": { - "addr": { - "sumType": "internalAddress", - "internalAddress": "0:b113a994b5024a16719f69139328eb759596c38a25f59028b146fecdc3621dfe" - }, - "balance": { - "sumType": "coins", - "coins": "10000000000000" - } - } - } - } - }, - "role": { - "sumType": "enum", - "enum": { - "actualValue": { - "sumType": "smallUint", - "smallUint": 1 - }, - "name": "Aboba", - "value": 1 - } - }, - "oper1": { - "sumType": "enum", - "enum": { - "actualValue": { - "sumType": "varUint", - "varUint": "0" - }, - "name": "Add", - "value": 0 - } - }, - "oper2": { - "sumType": "enum", - "enum": { - "actualValue": { - "sumType": "bigInt", - "bigInt": "-10000" - }, - "name": "TopUp", - "value": -10000 - } - }, - "oper3": { - "sumType": "enum", - "enum": { - "actualValue": { - "sumType": "smallUint", - "smallUint": 1 - }, - "name": "Something", - "value": 1 - } + "user2": { + "isExists": true, + "value": { + "addr": "0:086fa2a675f74347b08dd4606a549b8fdb98829cb282bc1949d3b12fbaed9dcc", + "balance": "100000000" } - } + }, + "user3": "b5ee9c720101010100240000438006e05909e22b2e5e6087533314ee56505f85212914bd5547941a2a658ac62fe101", + "user4": { + "isExists": false + }, + "user5": { + "addr": "0:b113a994b5024a16719f69139328eb759596c38a25f59028b146fecdc3621dfe", + "balance": "10000000000000" + }, + "role": "Aboba", + "oper1": "Add", + "oper2": "TopUp", + "oper3": "Something" } } \ No newline at end of file diff --git a/tolk/testdata/json/address_key_map.json b/tolk/testdata/json/address_key_map.json index 5f88aca0..4bf2f6df 100755 --- a/tolk/testdata/json/address_key_map.json +++ b/tolk/testdata/json/address_key_map.json @@ -1,10 +1,5 @@ { - "sumType": "map", - "map": { - "keySumType": "internalAddress", - "0:b113a994b5024a16719f69139328eb759596c38a25f59028b146fecdc3621dfe": { - "sumType": "coins", - "coins": "10000000000" - } + "value": { + "0:b113a994b5024a16719f69139328eb759596c38a25f59028b146fecdc3621dfe": "10000000000" } } \ No newline at end of file diff --git a/tolk/testdata/json/any_external_address.json b/tolk/testdata/json/any_external_address.json index 480656a6..087c7896 100755 --- a/tolk/testdata/json/any_external_address.json +++ b/tolk/testdata/json/any_external_address.json @@ -1,7 +1,3 @@ { - "sumType": "anyAddress", - "anyAddress": { - "sumType": "externalAddress", - "externalAddress": "4142" - } + "value": "4142" } \ No newline at end of file diff --git a/tolk/testdata/json/any_internal_address.json b/tolk/testdata/json/any_internal_address.json index 69c0840a..447ee205 100755 --- a/tolk/testdata/json/any_internal_address.json +++ b/tolk/testdata/json/any_internal_address.json @@ -1,7 +1,3 @@ { - "sumType": "anyAddress", - "anyAddress": { - "sumType": "internalAddress", - "internalAddress": "0:83dfd552e63729b472fcbcc8c45ebcc6691702558b68ec7527e1ba403a0f31a8" - } + "value": "0:83dfd552e63729b472fcbcc8c45ebcc6691702558b68ec7527e1ba403a0f31a8" } \ No newline at end of file diff --git a/tolk/testdata/json/any_none_address.json b/tolk/testdata/json/any_none_address.json index 67f28334..90bee0a3 100755 --- a/tolk/testdata/json/any_none_address.json +++ b/tolk/testdata/json/any_none_address.json @@ -1,6 +1,3 @@ { - "sumType": "anyAddress", - "anyAddress": { - "sumType": "noneAddress" - } + "value": "" } \ No newline at end of file diff --git a/tolk/testdata/json/any_var_address.json b/tolk/testdata/json/any_var_address.json index ee38dfc7..5b416318 100755 --- a/tolk/testdata/json/any_var_address.json +++ b/tolk/testdata/json/any_var_address.json @@ -1,7 +1,3 @@ { - "sumType": "anyAddress", - "anyAddress": { - "sumType": "varAddress", - "varAddress": "0:AB" - } + "value": "0:AB" } \ No newline at end of file diff --git a/tolk/testdata/json/big_int.json b/tolk/testdata/json/big_int.json index ab271aba..562c45b5 100755 --- a/tolk/testdata/json/big_int.json +++ b/tolk/testdata/json/big_int.json @@ -1,4 +1,3 @@ { - "sumType": "bigInt", - "bigInt": "-3513294376431" + "value": "-3513294376431" } \ No newline at end of file diff --git a/tolk/testdata/json/big_int_key_map.json b/tolk/testdata/json/big_int_key_map.json index 68e83aa5..4134f51e 100755 --- a/tolk/testdata/json/big_int_key_map.json +++ b/tolk/testdata/json/big_int_key_map.json @@ -1,10 +1,5 @@ { - "sumType": "map", - "map": { - "keySumType": "bigUint", - "2337412": { - "sumType": "cell", - "cell": "b5ee9c7201010101000800000b000000001ab0" - } + "value": { + "2337412": "b5ee9c7201010101000800000b000000001ab0" } } \ No newline at end of file diff --git a/tolk/testdata/json/big_uint.json b/tolk/testdata/json/big_uint.json index ffdb6c53..d2b3b1df 100755 --- a/tolk/testdata/json/big_uint.json +++ b/tolk/testdata/json/big_uint.json @@ -1,4 +1,3 @@ { - "sumType": "bigUint", - "bigUint": "351329437643124" + "value": "351329437643124" } \ No newline at end of file diff --git a/tolk/testdata/json/bits.json b/tolk/testdata/json/bits.json index 39b3f8f1..21020d3c 100755 --- a/tolk/testdata/json/bits.json +++ b/tolk/testdata/json/bits.json @@ -1,4 +1,3 @@ { - "sumType": "bits", - "bits": "313233" + "value": "313233" } \ No newline at end of file diff --git a/tolk/testdata/json/bits_int_key_map.json b/tolk/testdata/json/bits_int_key_map.json index a58852cc..2f21c450 100755 --- a/tolk/testdata/json/bits_int_key_map.json +++ b/tolk/testdata/json/bits_int_key_map.json @@ -1,25 +1,10 @@ { - "sumType": "map", - "map": { - "keySumType": "bits", + "value": { "4142": { - "sumType": "map", - "map": { - "keySumType": "smallInt", - "124": { - "sumType": "tensor", - "tensor": [ - { - "sumType": "internalAddress", - "internalAddress": "0:b113a994b5024a16719f69139328eb759596c38a25f59028b146fecdc3621dfe" - }, - { - "sumType": "coins", - "coins": "1000000000" - } - ] - } - } + "124": [ + "0:b113a994b5024a16719f69139328eb759596c38a25f59028b146fecdc3621dfe", + "1000000000" + ] } } } \ No newline at end of file diff --git a/tolk/testdata/json/bool.json b/tolk/testdata/json/bool.json index eb057212..78211002 100755 --- a/tolk/testdata/json/bool.json +++ b/tolk/testdata/json/bool.json @@ -1,4 +1,3 @@ { - "sumType": "bool", - "bool": false + "value": false } \ No newline at end of file diff --git a/tolk/testdata/json/cell.json b/tolk/testdata/json/cell.json index d0638305..4cb88fe4 100755 --- a/tolk/testdata/json/cell.json +++ b/tolk/testdata/json/cell.json @@ -1,4 +1,3 @@ { - "sumType": "cell", - "cell": "b5ee9c720101010100060000080000007b" + "value": "b5ee9c720101010100060000080000007b" } \ No newline at end of file diff --git a/tolk/testdata/json/coins.json b/tolk/testdata/json/coins.json index 50706fcd..0ccf8f03 100755 --- a/tolk/testdata/json/coins.json +++ b/tolk/testdata/json/coins.json @@ -1,4 +1,3 @@ { - "sumType": "coins", - "coins": "921464321" + "value": "921464321" } \ No newline at end of file diff --git a/tolk/testdata/json/custom_pack_unpack.json b/tolk/testdata/json/custom_pack_unpack.json index d594e067..190bf906 100755 --- a/tolk/testdata/json/custom_pack_unpack.json +++ b/tolk/testdata/json/custom_pack_unpack.json @@ -1,14 +1,5 @@ { - "sumType": "alias", - "alias": { - "sumType": "struct", - "struct": { - "fields": { - "amount": { - "sumType": "coins", - "coins": "1000000000" - } - } - } + "value": { + "amount": "1000000000" } } \ No newline at end of file diff --git a/tolk/testdata/json/empty_tensor.json b/tolk/testdata/json/empty_tensor.json index e455ca5d..bcd37241 100755 --- a/tolk/testdata/json/empty_tensor.json +++ b/tolk/testdata/json/empty_tensor.json @@ -1,4 +1,3 @@ { - "sumType": "tensor", - "tensor": [] + "value": [] } \ No newline at end of file diff --git a/tolk/testdata/json/exists_nullable.json b/tolk/testdata/json/exists_nullable.json index 563b409d..b6eef495 100755 --- a/tolk/testdata/json/exists_nullable.json +++ b/tolk/testdata/json/exists_nullable.json @@ -1,10 +1,6 @@ { - "sumType": "optionalValue", - "optionalValue": { + "value": { "isExists": true, - "value": { - "sumType": "cell", - "cell": "b5ee9c7201010101000700000900000c0ae0" - } + "value": "b5ee9c7201010101000700000900000c0ae0" } } \ No newline at end of file diff --git a/tolk/testdata/json/exists_optional_address.json b/tolk/testdata/json/exists_optional_address.json index 4d4d5c2e..447ee205 100755 --- a/tolk/testdata/json/exists_optional_address.json +++ b/tolk/testdata/json/exists_optional_address.json @@ -1,7 +1,3 @@ { - "sumType": "optionalAddress", - "optionalAddress": { - "sumType": "internalAddress", - "internalAddress": "0:83dfd552e63729b472fcbcc8c45ebcc6691702558b68ec7527e1ba403a0f31a8" - } + "value": "0:83dfd552e63729b472fcbcc8c45ebcc6691702558b68ec7527e1ba403a0f31a8" } \ No newline at end of file diff --git a/tolk/testdata/json/external_address.json b/tolk/testdata/json/external_address.json index 4797a6f5..087c7896 100755 --- a/tolk/testdata/json/external_address.json +++ b/tolk/testdata/json/external_address.json @@ -1,4 +1,3 @@ { - "sumType": "externalAddress", - "externalAddress": "4142" + "value": "4142" } \ No newline at end of file diff --git a/tolk/testdata/json/int_key_map.json b/tolk/testdata/json/int_key_map.json index 71cdafac..8d0d1c9b 100755 --- a/tolk/testdata/json/int_key_map.json +++ b/tolk/testdata/json/int_key_map.json @@ -1,10 +1,5 @@ { - "sumType": "map", - "map": { - "keySumType": "smallInt", - "123": { - "sumType": "bool", - "bool": true - } + "value": { + "123": true } } \ No newline at end of file diff --git a/tolk/testdata/json/internal_address.json b/tolk/testdata/json/internal_address.json index 6bc2e7d5..447ee205 100755 --- a/tolk/testdata/json/internal_address.json +++ b/tolk/testdata/json/internal_address.json @@ -1,4 +1,3 @@ { - "sumType": "internalAddress", - "internalAddress": "0:83dfd552e63729b472fcbcc8c45ebcc6691702558b68ec7527e1ba403a0f31a8" + "value": "0:83dfd552e63729b472fcbcc8c45ebcc6691702558b68ec7527e1ba403a0f31a8" } \ No newline at end of file diff --git a/tolk/testdata/json/not_exists_nullable.json b/tolk/testdata/json/not_exists_nullable.json index d84e0bae..dd9b57fc 100755 --- a/tolk/testdata/json/not_exists_nullable.json +++ b/tolk/testdata/json/not_exists_nullable.json @@ -1,6 +1,5 @@ { - "sumType": "optionalValue", - "optionalValue": { + "value": { "isExists": false } } \ No newline at end of file diff --git a/tolk/testdata/json/not_exists_optional_address.json b/tolk/testdata/json/not_exists_optional_address.json index 762edc5f..90bee0a3 100755 --- a/tolk/testdata/json/not_exists_optional_address.json +++ b/tolk/testdata/json/not_exists_optional_address.json @@ -1,6 +1,3 @@ { - "sumType": "optionalAddress", - "optionalAddress": { - "sumType": "noneAddress" - } + "value": "" } \ No newline at end of file diff --git a/tolk/testdata/json/ref.json b/tolk/testdata/json/ref.json index 1a9b216e..84623158 100755 --- a/tolk/testdata/json/ref.json +++ b/tolk/testdata/json/ref.json @@ -1,7 +1,3 @@ { - "sumType": "refValue", - "refValue": { - "sumType": "bigInt", - "bigInt": "1233212" - } + "value": "1233212" } \ No newline at end of file diff --git a/tolk/testdata/json/remaining.json b/tolk/testdata/json/remaining.json index 4c21ecc1..8285abe4 100755 --- a/tolk/testdata/json/remaining.json +++ b/tolk/testdata/json/remaining.json @@ -1,4 +1,3 @@ { - "sumType": "remaining", - "remaining": "b5ee9c7201010101000900000dc0800000000ab8" + "value": "b5ee9c7201010101000900000dc0800000000ab8" } \ No newline at end of file diff --git a/tolk/testdata/json/small_int.json b/tolk/testdata/json/small_int.json old mode 100644 new mode 100755 index 1b54d8bf..fc28d5c8 --- a/tolk/testdata/json/small_int.json +++ b/tolk/testdata/json/small_int.json @@ -1,4 +1,3 @@ { - "sumType": "smallInt", - "smallInt": -35132 + "value": -35132 } \ No newline at end of file diff --git a/tolk/testdata/json/small_uint.json b/tolk/testdata/json/small_uint.json index 4b79d99e..a14d14d9 100755 --- a/tolk/testdata/json/small_uint.json +++ b/tolk/testdata/json/small_uint.json @@ -1,4 +1,3 @@ { - "sumType": "smallUint", - "smallUint": 934 + "value": 934 } \ No newline at end of file diff --git a/tolk/testdata/json/tensor.json b/tolk/testdata/json/tensor.json index 13548954..e9ce69e8 100755 --- a/tolk/testdata/json/tensor.json +++ b/tolk/testdata/json/tensor.json @@ -1,40 +1,15 @@ { - "sumType": "tensor", - "tensor": [ - { - "sumType": "bigUint", - "bigUint": "4325" - }, - { - "sumType": "bool", - "bool": true - }, - { - "sumType": "coins", - "coins": "1000000000" - }, - { - "sumType": "tensor", - "tensor": [ - { - "sumType": "smallInt", - "smallInt": -342 - }, - { - "sumType": "optionalValue", - "optionalValue": { - "isExists": true, - "value": { - "sumType": "smallInt", - "smallInt": 0 - } - } - } - ] - }, - { - "sumType": "varInt", - "varInt": "-9304000000" - } + "value": [ + "4325", + true, + "1000000000", + [ + -342, + { + "isExists": true, + "value": 0 + } + ], + "-9304000000" ] } \ No newline at end of file diff --git a/tolk/testdata/json/uint_key_map.json b/tolk/testdata/json/uint_key_map.json index c62848b2..d17c8b46 100755 --- a/tolk/testdata/json/uint_key_map.json +++ b/tolk/testdata/json/uint_key_map.json @@ -1,14 +1,6 @@ { - "sumType": "map", - "map": { - "keySumType": "smallUint", - "14": { - "sumType": "internalAddress", - "internalAddress": "0:b113a994b5024a16719f69139328eb759596c38a25f59028b146fecdc3621dfe" - }, - "23": { - "sumType": "internalAddress", - "internalAddress": "-1:5555555555555555555555555555555555555555555555555555555555555555" - } + "value": { + "14": "0:b113a994b5024a16719f69139328eb759596c38a25f59028b146fecdc3621dfe", + "23": "-1:5555555555555555555555555555555555555555555555555555555555555555" } } \ No newline at end of file diff --git a/tolk/testdata/json/union_with_bin_prefix.json b/tolk/testdata/json/union_with_bin_prefix.json index 91d08ef9..8c54575c 100755 --- a/tolk/testdata/json/union_with_bin_prefix.json +++ b/tolk/testdata/json/union_with_bin_prefix.json @@ -1,30 +1,7 @@ { - "sumType": "union", - "union": { - "prefix": { - "len": 3, - "prefix": 3 - }, - "value": { - "sumType": "struct", - "struct": { - "prefix": { - "len": 3, - "prefix": 3 - }, - "fields": { - "v": { - "sumType": "map", - "map": { - "keySumType": "internalAddress", - "0:b113a994b5024a16719f69139328eb759596c38a25f59028b146fecdc3621dfe": { - "sumType": "coins", - "coins": "43213412" - } - } - } - } - } + "value": { + "v": { + "0:b113a994b5024a16719f69139328eb759596c38a25f59028b146fecdc3621dfe": "43213412" } } } \ No newline at end of file diff --git a/tolk/testdata/json/union_with_dec_prefix.json b/tolk/testdata/json/union_with_dec_prefix.json index 401d82e6..c003e116 100755 --- a/tolk/testdata/json/union_with_dec_prefix.json +++ b/tolk/testdata/json/union_with_dec_prefix.json @@ -1,13 +1,3 @@ { - "sumType": "union", - "union": { - "prefix": { - "len": 1, - "prefix": 1 - }, - "value": { - "sumType": "bigInt", - "bigInt": "124432123" - } - } + "value": "124432123" } \ No newline at end of file diff --git a/tolk/testdata/json/union_with_hex_prefix.json b/tolk/testdata/json/union_with_hex_prefix.json index 617c3591..f25445e2 100755 --- a/tolk/testdata/json/union_with_hex_prefix.json +++ b/tolk/testdata/json/union_with_hex_prefix.json @@ -1,24 +1,5 @@ { - "sumType": "union", - "union": { - "prefix": { - "len": 32, - "prefix": 3735928559 - }, - "value": { - "sumType": "struct", - "struct": { - "prefix": { - "len": 32, - "prefix": 3735928559 - }, - "fields": { - "v": { - "sumType": "smallUint", - "smallUint": 1 - } - } - } - } + "value": { + "v": 1 } } \ No newline at end of file diff --git a/tolk/testdata/json/var_int.json b/tolk/testdata/json/var_int.json index 4857f6d4..3174bfa2 100755 --- a/tolk/testdata/json/var_int.json +++ b/tolk/testdata/json/var_int.json @@ -1,4 +1,3 @@ { - "sumType": "varInt", - "varInt": "825432" + "value": "825432" } \ No newline at end of file diff --git a/tolk/testdata/json/var_uint.json b/tolk/testdata/json/var_uint.json index 5439ae38..4cedbbca 100755 --- a/tolk/testdata/json/var_uint.json +++ b/tolk/testdata/json/var_uint.json @@ -1,4 +1,3 @@ { - "sumType": "varUint", - "varUint": "9451236712" + "value": "9451236712" } \ No newline at end of file diff --git a/tolk/tuples.go b/tolk/tuples.go index 885acdfb..c316aa88 100644 --- a/tolk/tuples.go +++ b/tolk/tuples.go @@ -1,7 +1,9 @@ package tolk import ( + "encoding/json" "fmt" + "strings" "github.com/tonkeeper/tongo/boc" "github.com/tonkeeper/tongo/tolk/parser" @@ -92,3 +94,20 @@ func (v *TensorValues) Equal(other any) bool { } return true } + +func (v TensorValues) MarshalJSON() ([]byte, error) { + var s strings.Builder + s.WriteRune('[') + for i, item := range []Value(v) { + data, err := json.Marshal(item) + if err != nil { + return nil, fmt.Errorf("failed to marshal %v tensor's value: %w", i, err) + } + s.Write(data) + if i != len([]Value(v))-1 { + s.WriteRune(',') + } + } + s.WriteRune(']') + return []byte(s.String()), nil +} diff --git a/tolk/union.go b/tolk/union.go index 4730f35b..f2a68e3f 100644 --- a/tolk/union.go +++ b/tolk/union.go @@ -8,8 +8,8 @@ import ( ) type UnionValue struct { - Prefix Prefix `json:"prefix"` - Val Value `json:"value"` + Prefix Prefix + Val Value } func (u *UnionValue) Unmarshal(cell *boc.Cell, ty tolkParser.Union, decoder *Decoder) error { @@ -105,3 +105,11 @@ func (u *UnionValue) Equal(other any) bool { } return u.Val.Equal(otherUnionValue.Val) } + +func (u UnionValue) MarshalJSON() ([]byte, error) { + data, err := u.Val.MarshalJSON() + if err != nil { + return nil, fmt.Errorf("failed to marshal ref: %w", err) + } + return data, nil +} diff --git a/tolk/value.go b/tolk/value.go index ef350b63..90b7bd8d 100644 --- a/tolk/value.go +++ b/tolk/value.go @@ -3,8 +3,10 @@ package tolk // todo: move this to some package or rename somehow. import ( + "encoding/json" "fmt" "math/big" + "strings" "github.com/tonkeeper/tongo/boc" "github.com/tonkeeper/tongo/tolk/parser" @@ -26,34 +28,34 @@ func (s *SumType) UnmarshalJSON(bytes []byte) error { } type Value struct { - SumType SumType `json:"sumType"` - Bool *BoolValue `json:"bool,omitempty"` - SmallInt *Int64 `json:"smallInt,omitempty"` - SmallUint *UInt64 `json:"smallUint,omitempty"` - BigInt *BigInt `json:"bigInt,omitempty"` - BigUint *BigUInt `json:"bigUint,omitempty"` - VarInt *VarInt `json:"varInt,omitempty"` - VarUint *VarUInt `json:"varUint,omitempty"` - Coins *CoinsValue `json:"coins,omitempty"` - Bits *Bits `json:"bits,omitempty"` - Cell *Any `json:"cell,omitempty"` - Remaining *RemainingValue `json:"remaining,omitempty"` - InternalAddress *InternalAddress `json:"internalAddress,omitempty"` - OptionalAddress *OptionalAddress `json:"optionalAddress,omitempty"` - ExternalAddress *ExternalAddress `json:"externalAddress,omitempty"` - AnyAddress *AnyAddress `json:"anyAddress,omitempty"` - OptionalValue *OptValue `json:"optionalValue,omitempty"` - RefValue *RefValue `json:"refValue,omitempty"` - TupleWith *TupleValues `json:"tupleWith,omitempty"` - Tensor *TensorValues `json:"tensor,omitempty"` - Map *MapValue `json:"map,omitempty"` - Struct *Struct `json:"struct,omitempty"` - Alias *AliasValue `json:"alias,omitempty"` - Enum *EnumValue `json:"enum,omitempty"` - Generic *GenericValue `json:"generic,omitempty"` - Union *UnionValue `json:"union,omitempty"` - Null *NullValue `json:"null,omitempty"` - Void *VoidValue `json:"void,omitempty"` + 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 + Map *MapValue + Struct *Struct + Alias *AliasValue + Enum *EnumValue + Generic *GenericValue + Union *UnionValue + Null *NullValue + Void *VoidValue } func (v *Value) GetBool() (bool, bool) { @@ -1010,3 +1012,75 @@ func (v *Value) Equal(o any) bool { return false } } + +func (v Value) MarshalJSON() ([]byte, error) { + var s strings.Builder + var data []byte + var err error + switch v.SumType { + case "Bool": + data, err = json.Marshal(v.Bool) + case "SmallInt": + data, err = json.Marshal(v.SmallInt) + case "SmallUint": + data, err = json.Marshal(v.SmallUint) + case "BigInt": + data, err = json.Marshal(v.BigInt) + case "BigUint": + data, err = json.Marshal(v.BigUint) + case "VarInt": + data, err = json.Marshal(v.VarInt) + case "VarUint": + data, err = json.Marshal(v.VarUint) + case "Coins": + data, err = json.Marshal(v.Coins) + case "Bits": + data, err = json.Marshal(v.Bits) + case "Cell": + data, err = json.Marshal(v.Cell) + case "Remaining": + data, err = json.Marshal(v.Remaining) + case "InternalAddress": + data, err = json.Marshal(v.InternalAddress) + case "OptionalAddress": + data, err = json.Marshal(v.OptionalAddress) + case "ExternalAddress": + data, err = json.Marshal(v.ExternalAddress) + case "AnyAddress": + data, err = json.Marshal(v.AnyAddress) + case "OptionalValue": + data, err = json.Marshal(v.OptionalValue) + case "RefValue": + data, err = json.Marshal(v.RefValue) + case "TupleWith": + data, err = json.Marshal(v.TupleWith) + case "Tensor": + data, err = json.Marshal(v.Tensor) + case "Map": + data, err = json.Marshal(v.Map) + case "Struct": + data, err = json.Marshal(v.Struct) + case "Alias": + val := Value(*v.Alias) + data, err = json.Marshal(val) + case "Enum": + data, err = json.Marshal(v.Enum) + case "Generic": + val := Value(*v.Generic) + data, err = json.Marshal(val) + case "Union": + data, err = json.Marshal(v.Union) + case "Null": + data, err = json.Marshal(v.Null) + case "Void": + data, err = json.Marshal(v.Void) + default: + err = fmt.Errorf("unknown value type: %s", v.SumType) + } + if err != nil { + return nil, fmt.Errorf("failed to marshal value: %w", err) + } + + s.Write(data) + return []byte(s.String()), err +} From 22451bc4d9f916843e926df1cfb2d453f8982a0d Mon Sep 17 00:00:00 2001 From: Pavel Levchenko Date: Sun, 1 Mar 2026 18:15:05 +0300 Subject: [PATCH 14/16] add struct info --- tolk/refs.go | 10 +++++++++- .../testdata/json/a_lot_generics_from_alias.json | 16 ++++++++++++++++ .../json/a_lot_generics_from_struct.json | 16 ++++++++++++++++ .../json/a_lot_generics_with_default_values.json | 4 ++++ tolk/testdata/json/a_lot_numbers.json | 4 ++++ tolk/testdata/json/a_lot_random_fields.json | 4 ++++ tolk/testdata/json/a_lot_refs_from_alias.json | 16 ++++++++++++++++ tolk/testdata/json/a_lot_refs_from_struct.json | 16 ++++++++++++++++ tolk/testdata/json/custom_pack_unpack.json | 4 ++++ tolk/testdata/json/union_with_bin_prefix.json | 4 ++++ tolk/testdata/json/union_with_hex_prefix.json | 4 ++++ 11 files changed, 97 insertions(+), 1 deletion(-) diff --git a/tolk/refs.go b/tolk/refs.go index 14790a45..b443f3b4 100644 --- a/tolk/refs.go +++ b/tolk/refs.go @@ -5,10 +5,12 @@ import ( "fmt" "math/big" "slices" + "strconv" "strings" "github.com/tonkeeper/tongo/boc" "github.com/tonkeeper/tongo/tolk/parser" + "github.com/tonkeeper/tongo/utils" "golang.org/x/exp/maps" ) @@ -19,6 +21,7 @@ type Prefix struct { type Struct struct { hasPrefix bool + name string prefix Prefix fieldNames []string fieldValues []Value @@ -35,6 +38,7 @@ func (s *Struct) Unmarshal(cell *boc.Cell, ty tolkParser.StructRef, decoder *Dec tolkStruct := Struct{ fieldNames: make([]string, 0), fieldValues: make([]Value, 0), + name: ty.StructName, } if strct.Prefix != nil { prefixLen := strct.Prefix.PrefixLen @@ -255,7 +259,11 @@ func (s *Struct) Equal(o any) bool { func (s Struct) MarshalJSON() ([]byte, error) { builder := strings.Builder{} - builder.WriteRune('{') + builder.WriteString("{\"tag\":{\"name\":\"") + builder.WriteString(utils.ToSnakeCase(s.name)) + builder.WriteString("\",\"prefix\":\"0x") + builder.WriteString(strconv.FormatInt(int64(s.prefix.Prefix), 16)) + builder.WriteString("\"},") for i, name := range s.fieldNames { if i != 0 { builder.WriteRune(',') diff --git a/tolk/testdata/json/a_lot_generics_from_alias.json b/tolk/testdata/json/a_lot_generics_from_alias.json index 2d54a0fc..e4fcebcf 100755 --- a/tolk/testdata/json/a_lot_generics_from_alias.json +++ b/tolk/testdata/json/a_lot_generics_from_alias.json @@ -1,12 +1,28 @@ { "value": { + "tag": { + "name": "many_refs_msg", + "prefix": "0x0" + }, "payload": { + "tag": { + "name": "either_ref", + "prefix": "0x0" + }, "value": 123 }, "either": { + "tag": { + "name": "either_right", + "prefix": "0x0" + }, "value": "100000000" }, "anotherEither": { + "tag": { + "name": "either_right", + "prefix": "0x0" + }, "value": [ true, "1000000000" diff --git a/tolk/testdata/json/a_lot_generics_from_struct.json b/tolk/testdata/json/a_lot_generics_from_struct.json index 2d54a0fc..e4fcebcf 100755 --- a/tolk/testdata/json/a_lot_generics_from_struct.json +++ b/tolk/testdata/json/a_lot_generics_from_struct.json @@ -1,12 +1,28 @@ { "value": { + "tag": { + "name": "many_refs_msg", + "prefix": "0x0" + }, "payload": { + "tag": { + "name": "either_ref", + "prefix": "0x0" + }, "value": 123 }, "either": { + "tag": { + "name": "either_right", + "prefix": "0x0" + }, "value": "100000000" }, "anotherEither": { + "tag": { + "name": "either_right", + "prefix": "0x0" + }, "value": [ true, "1000000000" diff --git a/tolk/testdata/json/a_lot_generics_with_default_values.json b/tolk/testdata/json/a_lot_generics_with_default_values.json index a54dc88b..307117a6 100755 --- a/tolk/testdata/json/a_lot_generics_with_default_values.json +++ b/tolk/testdata/json/a_lot_generics_with_default_values.json @@ -1,5 +1,9 @@ { "value": { + "tag": { + "name": "default_test", + "prefix": "0x0" + }, "num1": { "isExists": true, "value": 4 diff --git a/tolk/testdata/json/a_lot_numbers.json b/tolk/testdata/json/a_lot_numbers.json index af649dd6..7ffc5f54 100755 --- a/tolk/testdata/json/a_lot_numbers.json +++ b/tolk/testdata/json/a_lot_numbers.json @@ -1,5 +1,9 @@ { "value": { + "tag": { + "name": "numbers", + "prefix": "0x0" + }, "num1": 0, "num3": "241", "num4": "3421", diff --git a/tolk/testdata/json/a_lot_random_fields.json b/tolk/testdata/json/a_lot_random_fields.json index a8ee2b73..3d101023 100755 --- a/tolk/testdata/json/a_lot_random_fields.json +++ b/tolk/testdata/json/a_lot_random_fields.json @@ -1,5 +1,9 @@ { "value": { + "tag": { + "name": "random_fields", + "prefix": "0x794" + }, "dest_int": "0:83dfd552e63729b472fcbcc8c45ebcc6691702558b68ec7527e1ba403a0f31a8", "amount": "500000123400000", "dest_ext": "", diff --git a/tolk/testdata/json/a_lot_refs_from_alias.json b/tolk/testdata/json/a_lot_refs_from_alias.json index 00319064..8b77a28f 100755 --- a/tolk/testdata/json/a_lot_refs_from_alias.json +++ b/tolk/testdata/json/a_lot_refs_from_alias.json @@ -1,12 +1,24 @@ { "value": { + "tag": { + "name": "many_refs_msg", + "prefix": "0xdeadbeef" + }, "user1": { + "tag": { + "name": "address_and_balance", + "prefix": "0x0" + }, "addr": "0:83dfd552e63729b472fcbcc8c45ebcc6691702558b68ec7527e1ba403a0f31a8", "balance": "1000000000" }, "user2": { "isExists": true, "value": { + "tag": { + "name": "address_and_balance", + "prefix": "0x0" + }, "addr": "0:086fa2a675f74347b08dd4606a549b8fdb98829cb282bc1949d3b12fbaed9dcc", "balance": "100000000" } @@ -16,6 +28,10 @@ "isExists": false }, "user5": { + "tag": { + "name": "address_and_balance", + "prefix": "0x0" + }, "addr": "0:b113a994b5024a16719f69139328eb759596c38a25f59028b146fecdc3621dfe", "balance": "10000000000000" }, diff --git a/tolk/testdata/json/a_lot_refs_from_struct.json b/tolk/testdata/json/a_lot_refs_from_struct.json index 00319064..8b77a28f 100755 --- a/tolk/testdata/json/a_lot_refs_from_struct.json +++ b/tolk/testdata/json/a_lot_refs_from_struct.json @@ -1,12 +1,24 @@ { "value": { + "tag": { + "name": "many_refs_msg", + "prefix": "0xdeadbeef" + }, "user1": { + "tag": { + "name": "address_and_balance", + "prefix": "0x0" + }, "addr": "0:83dfd552e63729b472fcbcc8c45ebcc6691702558b68ec7527e1ba403a0f31a8", "balance": "1000000000" }, "user2": { "isExists": true, "value": { + "tag": { + "name": "address_and_balance", + "prefix": "0x0" + }, "addr": "0:086fa2a675f74347b08dd4606a549b8fdb98829cb282bc1949d3b12fbaed9dcc", "balance": "100000000" } @@ -16,6 +28,10 @@ "isExists": false }, "user5": { + "tag": { + "name": "address_and_balance", + "prefix": "0x0" + }, "addr": "0:b113a994b5024a16719f69139328eb759596c38a25f59028b146fecdc3621dfe", "balance": "10000000000000" }, diff --git a/tolk/testdata/json/custom_pack_unpack.json b/tolk/testdata/json/custom_pack_unpack.json index 190bf906..6b3f2aa8 100755 --- a/tolk/testdata/json/custom_pack_unpack.json +++ b/tolk/testdata/json/custom_pack_unpack.json @@ -1,5 +1,9 @@ { "value": { + "tag": { + "name": "my", + "prefix": "0x0" + }, "amount": "1000000000" } } \ No newline at end of file diff --git a/tolk/testdata/json/union_with_bin_prefix.json b/tolk/testdata/json/union_with_bin_prefix.json index 8c54575c..70ba7c5c 100755 --- a/tolk/testdata/json/union_with_bin_prefix.json +++ b/tolk/testdata/json/union_with_bin_prefix.json @@ -1,5 +1,9 @@ { "value": { + "tag": { + "name": "map_with_prefix", + "prefix": "0x3" + }, "v": { "0:b113a994b5024a16719f69139328eb759596c38a25f59028b146fecdc3621dfe": "43213412" } diff --git a/tolk/testdata/json/union_with_hex_prefix.json b/tolk/testdata/json/union_with_hex_prefix.json index f25445e2..10eceb5e 100755 --- a/tolk/testdata/json/union_with_hex_prefix.json +++ b/tolk/testdata/json/union_with_hex_prefix.json @@ -1,5 +1,9 @@ { "value": { + "tag": { + "name": "u_int33_with_prefix", + "prefix": "0xdeadbeef" + }, "v": 1 } } \ No newline at end of file From 110b2c3b7c74c0d6e296f1a48603368438b81142 Mon Sep 17 00:00:00 2001 From: Pavel Levchenko Date: Wed, 4 Mar 2026 09:24:27 +0300 Subject: [PATCH 15/16] add benchmarks --- examples/tolk/payload-unmarshal/main.go | 6 +- examples/tolk/simple-unmarshal/main.go | 4 +- tolk/addresses.go | 44 +- tolk/cells.go | 16 +- tolk/integers.go | 40 +- tolk/map.go | 8 +- tolk/null.go | 8 +- tolk/parser/shortcuts.go | 2 +- tolk/parser/types.go | 2 +- tolk/refs.go | 22 +- tolk/runtime.go | 48 +- tolk/runtime_benchmark_test.go | 368 ++++ tolk/runtime_test.go | 296 +-- tolk/testdata/jetton_transfer.json | 75 + tolk/testdata/payloads.json | 2421 +++++++++++++++++++++++ tolk/testdata/swap_coffee.json | 156 ++ tolk/tuples.go | 8 +- tolk/union.go | 4 +- tolk/value.go | 4 +- 19 files changed, 3276 insertions(+), 256 deletions(-) create mode 100644 tolk/runtime_benchmark_test.go create mode 100644 tolk/testdata/jetton_transfer.json create mode 100644 tolk/testdata/payloads.json create mode 100644 tolk/testdata/swap_coffee.json diff --git a/examples/tolk/payload-unmarshal/main.go b/examples/tolk/payload-unmarshal/main.go index 128e02d2..73e221d7 100644 --- a/examples/tolk/payload-unmarshal/main.go +++ b/examples/tolk/payload-unmarshal/main.go @@ -19,19 +19,19 @@ var jettonWalletAbiData []byte var swapCoffeeAbiData []byte func main() { - var jettonWalletABI tolkParser.ABI + var jettonWalletABI parser.ABI err := json.Unmarshal(jettonWalletAbiData, &jettonWalletABI) if err != nil { panic(err) } - var swapCoffeeABI tolkParser.ABI + var swapCoffeeABI parser.ABI err = json.Unmarshal(swapCoffeeAbiData, &swapCoffeeABI) if err != nil { panic(err) } - ty := tolkParser.NewStructType("Transfer") + ty := parser.NewStructType("Transfer") b, err := hex.DecodeString("b5ee9c72010205010001310001ae0f8a7ea5003c0fe80d6334813ef1895801d9d00dc43cb19c9bfa417f874e7be3670825205a6e50d3490a0aec1194fe2e8f003ffffbc78bb7c4bb37210cfa7f64397ff32df53ce36c46934e21a1e315c93137482ed968810101084ee9b1060201ae0f8a7ea5003c0fe80d6334813ef189d801fe7933ccc21619bc6f1800071d12d4e7aae8d68f637fcdb8facdca753b08c859003ffffbc78bb7c4bb37210cfa7f64397ff32df53ce36c46934e21a1e315c93137481823cf41030153c0ffee10c44cf0b64eb9dedfb010c7b24a508140d86f6e07789f9383bb9b2141ea9c08ea502d0bbc060404008d69a178e5801ffffde3c5dbe25d9b90867d3fb21cbff996fa9e71b62349a710d0f18ae4989bb00021706f0b21587534d776380d79ce6fcbef538e7aacc3f949f91149c80db932bd") if err != nil { panic(err) diff --git a/examples/tolk/simple-unmarshal/main.go b/examples/tolk/simple-unmarshal/main.go index ae2f6a74..5149808f 100644 --- a/examples/tolk/simple-unmarshal/main.go +++ b/examples/tolk/simple-unmarshal/main.go @@ -16,13 +16,13 @@ import _ "embed" var jettonWalletAbiData []byte func main() { - var jettonWalletABI tolkParser.ABI + var jettonWalletABI parser.ABI err := json.Unmarshal(jettonWalletAbiData, &jettonWalletABI) if err != nil { panic(err) } - ty := tolkParser.NewStructType("Transfer") + ty := parser.NewStructType("Transfer") b, err := hex.DecodeString("b5ee9c720102030100011b0001ae0f8a7ea5bf4e20320df05dd0318537180125c28235ca8d125e676591513d520721b1fe99f7722f4c87723ce7ee0dfb73a3001f8cc4cadf3be6b14e892d7aa31f5be355c1eab776f0e1d61a46644ddc17e68b881908b1010101e16664de2a801244183034d9fd59a236f71ec4271be377399056dda4cc3a5ebf5dc40967df641001f8cc4cadf3be6b14e892d7aa31f5be355c1eab776f0e1d61a46644ddc17e68ba003f198995be77cd629d125af5463eb7c6ab83d56eede1c3ac348cc89bb82fcd17000000007fffffffc0020095446cf7101800fc662656f9df358a74496bd518fadf1aae0f55bbb7870eb0d233226ee0bf345c00000540095e99c8dc6a438526df4961936ff51209f307a28c37c6c78310ce140ab78ab658") if err != nil { panic(err) diff --git a/tolk/addresses.go b/tolk/addresses.go index 379d26e9..1dcd6971 100644 --- a/tolk/addresses.go +++ b/tolk/addresses.go @@ -17,7 +17,7 @@ type InternalAddress struct { Address [32]byte } -func (i *InternalAddress) Unmarshal(cell *boc.Cell, ty tolkParser.Address, decoder *Decoder) error { +func (i *InternalAddress) Unmarshal(cell *boc.Cell, ty parser.Address, decoder *Decoder) error { err := cell.Skip(3) // skip addr type ($10) and anycast (0) if err != nil { return fmt.Errorf("failed to skip internal address type and anycast: %w", err) @@ -37,7 +37,7 @@ func (i *InternalAddress) Unmarshal(cell *boc.Cell, ty tolkParser.Address, decod return nil } -func (i *InternalAddress) Marshal(cell *boc.Cell, ty tolkParser.Address, encoder *Encoder) error { +func (i *InternalAddress) Marshal(cell *boc.Cell, ty parser.Address, encoder *Encoder) error { err := cell.WriteUint(0b100, 3) // internal addr type ($10) and anycast (0) if err != nil { return fmt.Errorf("failed to write internal address type and anycast: %w", err) @@ -93,7 +93,7 @@ func (i *InternalAddress) UnmarshalJSON(b []byte) error { type NoneAddress struct { } -func (n *NoneAddress) Unmarshal(cell *boc.Cell, ty tolkParser.AddressOpt, decoder *Decoder) error { +func (n *NoneAddress) Unmarshal(cell *boc.Cell, ty parser.AddressOpt, decoder *Decoder) error { _, err := cell.ReadUint(2) if err != nil { return fmt.Errorf("failed to read none address type: %w", err) @@ -102,7 +102,7 @@ func (n *NoneAddress) Unmarshal(cell *boc.Cell, ty tolkParser.AddressOpt, decode return nil } -func (n *NoneAddress) Marshal(cell *boc.Cell, ty tolkParser.AddressOpt, encoder *Encoder) error { +func (n *NoneAddress) Marshal(cell *boc.Cell, ty parser.AddressOpt, encoder *Encoder) error { err := cell.WriteUint(0, 2) // none addr type ($00) if err != nil { return fmt.Errorf("failed to write none address type: %w", err) @@ -138,7 +138,7 @@ func (o *OptionalAddress) Equal(other any) bool { return true } -func (o *OptionalAddress) Unmarshal(cell *boc.Cell, ty tolkParser.AddressOpt, decoder *Decoder) error { +func (o *OptionalAddress) Unmarshal(cell *boc.Cell, ty parser.AddressOpt, decoder *Decoder) error { copyCell := cell.CopyRemaining() tag, err := copyCell.ReadUint(2) if err != nil { @@ -156,14 +156,14 @@ func (o *OptionalAddress) Unmarshal(cell *boc.Cell, ty tolkParser.AddressOpt, de o.SumType = "InternalAddress" o.InternalAddress = &InternalAddress{} - err = o.InternalAddress.Unmarshal(cell, tolkParser.Address{}, decoder) + err = o.InternalAddress.Unmarshal(cell, parser.Address{}, decoder) if err != nil { return fmt.Errorf("failed to unmarshal optional address: %w", err) } return nil } -func (o *OptionalAddress) Marshal(cell *boc.Cell, ty tolkParser.AddressOpt, encoder *Encoder) error { +func (o *OptionalAddress) Marshal(cell *boc.Cell, ty parser.AddressOpt, encoder *Encoder) error { if o.SumType == "NoneAddress" { err := o.NoneAddress.Marshal(cell, ty, encoder) if err != nil { @@ -171,7 +171,7 @@ func (o *OptionalAddress) Marshal(cell *boc.Cell, ty tolkParser.AddressOpt, enco } return nil } else if o.SumType == "InternalAddress" { - err := o.InternalAddress.Marshal(cell, tolkParser.Address{}, encoder) + err := o.InternalAddress.Marshal(cell, parser.Address{}, encoder) if err != nil { return fmt.Errorf("failed to marshal optional address: %w", err) } @@ -208,7 +208,7 @@ type ExternalAddress struct { Address boc.BitString } -func (e *ExternalAddress) Unmarshal(cell *boc.Cell, ty tolkParser.AddressExt, decoder *Decoder) error { +func (e *ExternalAddress) Unmarshal(cell *boc.Cell, ty parser.AddressExt, decoder *Decoder) error { err := cell.Skip(2) if err != nil { return fmt.Errorf("failed to skip external address type: %w", err) @@ -229,7 +229,7 @@ func (e *ExternalAddress) Unmarshal(cell *boc.Cell, ty tolkParser.AddressExt, de return nil } -func (e *ExternalAddress) Marshal(cell *boc.Cell, ty tolkParser.AddressExt, encoder *Encoder) error { +func (e *ExternalAddress) Marshal(cell *boc.Cell, ty parser.AddressExt, encoder *Encoder) error { err := cell.WriteUint(1, 2) // external addr type ($01) if err != nil { return fmt.Errorf("failed to write external address type: %w", err) @@ -279,7 +279,7 @@ type AnyAddress struct { VarAddress *VarAddress } -func (a *AnyAddress) Unmarshal(cell *boc.Cell, ty tolkParser.AddressAny, decoder *Decoder) error { +func (a *AnyAddress) Unmarshal(cell *boc.Cell, ty parser.AddressAny, decoder *Decoder) error { copyCell := cell.CopyRemaining() tag, err := copyCell.ReadUint(2) if err != nil { @@ -289,19 +289,19 @@ func (a *AnyAddress) Unmarshal(cell *boc.Cell, ty tolkParser.AddressAny, decoder case 0: a.SumType = "NoneAddress" a.NoneAddress = &NoneAddress{} - err = a.NoneAddress.Unmarshal(cell, tolkParser.AddressOpt{}, decoder) + err = a.NoneAddress.Unmarshal(cell, parser.AddressOpt{}, decoder) case 1: a.SumType = "ExternalAddress" a.ExternalAddress = &ExternalAddress{} - err = a.ExternalAddress.Unmarshal(cell, tolkParser.AddressExt{}, decoder) + err = a.ExternalAddress.Unmarshal(cell, parser.AddressExt{}, decoder) case 2: a.SumType = "InternalAddress" a.InternalAddress = &InternalAddress{} - err = a.InternalAddress.Unmarshal(cell, tolkParser.Address{}, decoder) + err = a.InternalAddress.Unmarshal(cell, parser.Address{}, decoder) case 3: a.SumType = "VarAddress" a.VarAddress = &VarAddress{} - err = a.VarAddress.Unmarshal(cell, tolkParser.AddressExt{}, decoder) + err = a.VarAddress.Unmarshal(cell, parser.AddressExt{}, decoder) } if err != nil { return fmt.Errorf("failed to unmarshal any address: %w", err) @@ -309,17 +309,17 @@ func (a *AnyAddress) Unmarshal(cell *boc.Cell, ty tolkParser.AddressAny, decoder return nil } -func (a *AnyAddress) Marshal(cell *boc.Cell, ty tolkParser.AddressAny, encoder *Encoder) error { +func (a *AnyAddress) Marshal(cell *boc.Cell, ty parser.AddressAny, encoder *Encoder) error { var err error switch a.SumType { case "NoneAddress": - err = a.NoneAddress.Marshal(cell, tolkParser.AddressOpt{}, encoder) + err = a.NoneAddress.Marshal(cell, parser.AddressOpt{}, encoder) case "InternalAddress": - err = a.InternalAddress.Marshal(cell, tolkParser.Address{}, encoder) + err = a.InternalAddress.Marshal(cell, parser.Address{}, encoder) case "ExternalAddress": - err = a.ExternalAddress.Marshal(cell, tolkParser.AddressExt{}, encoder) + err = a.ExternalAddress.Marshal(cell, parser.AddressExt{}, encoder) case "VarAddress": - err = a.VarAddress.Marshal(cell, tolkParser.AddressAny{}, encoder) + err = a.VarAddress.Marshal(cell, parser.AddressAny{}, encoder) default: return fmt.Errorf("unknown any address SumType: %v", a.SumType) } @@ -417,7 +417,7 @@ func (va *VarAddress) Equal(other any) bool { return bytes.Equal(va.Address.Buffer(), otherVarAddress.Address.Buffer()) } -func (va *VarAddress) Unmarshal(cell *boc.Cell, ty tolkParser.AddressExt, decoder *Decoder) error { +func (va *VarAddress) Unmarshal(cell *boc.Cell, ty parser.AddressExt, decoder *Decoder) error { err := cell.Skip(3) // skip var type ($11) and anycast (0) if err != nil { return fmt.Errorf("failed to skip var address type and anycast: %w", err) @@ -443,7 +443,7 @@ func (va *VarAddress) Unmarshal(cell *boc.Cell, ty tolkParser.AddressExt, decode return nil } -func (va *VarAddress) Marshal(cell *boc.Cell, ty tolkParser.AddressAny, encoder *Encoder) error { +func (va *VarAddress) Marshal(cell *boc.Cell, ty parser.AddressAny, encoder *Encoder) error { err := cell.WriteUint(0b110, 3) // var addr type ($11) and anycast (0) if err != nil { return fmt.Errorf("failed to write var address type and anycast: %w", err) diff --git a/tolk/cells.go b/tolk/cells.go index 39e71137..51b34d2c 100644 --- a/tolk/cells.go +++ b/tolk/cells.go @@ -10,7 +10,7 @@ import ( type Any boc.Cell -func (a *Any) Unmarshal(cell *boc.Cell, ty tolkParser.Cell, decoder *Decoder) error { +func (a *Any) Unmarshal(cell *boc.Cell, ty parser.Cell, decoder *Decoder) error { ref, err := cell.NextRef() if err != nil { return fmt.Errorf("failed to get next ref: %w", err) @@ -20,7 +20,7 @@ func (a *Any) Unmarshal(cell *boc.Cell, ty tolkParser.Cell, decoder *Decoder) er return nil } -func (a *Any) Marshal(cell *boc.Cell, ty tolkParser.Cell, encoder *Encoder) error { +func (a *Any) Marshal(cell *boc.Cell, ty parser.Cell, encoder *Encoder) error { c := boc.Cell(*a) ref := c.CopyRemaining() err := cell.AddRef(ref) @@ -68,7 +68,7 @@ func (a *Any) UnmarshalJSON(b []byte) error { type RemainingValue boc.Cell -func (r *RemainingValue) Unmarshal(cell *boc.Cell, ty tolkParser.Remaining, decoder *Decoder) error { +func (r *RemainingValue) Unmarshal(cell *boc.Cell, ty parser.Remaining, decoder *Decoder) error { rem := cell.CopyRemaining() cell.ReadRemainingBits() if rem != nil { @@ -77,7 +77,7 @@ func (r *RemainingValue) Unmarshal(cell *boc.Cell, ty tolkParser.Remaining, deco return nil } -func (r *RemainingValue) Marshal(cell *boc.Cell, ty tolkParser.Remaining, encoder *Encoder) error { +func (r *RemainingValue) Marshal(cell *boc.Cell, ty parser.Remaining, encoder *Encoder) error { c := boc.Cell(*r) err := cell.WriteBitString(c.ReadRemainingBits()) if err != nil { @@ -133,7 +133,7 @@ type OptValue struct { Val Value } -func (o *OptValue) Unmarshal(cell *boc.Cell, ty tolkParser.Nullable, decoder *Decoder) error { +func (o *OptValue) Unmarshal(cell *boc.Cell, ty parser.Nullable, decoder *Decoder) error { isExists, err := cell.ReadBit() if err != nil { return fmt.Errorf("failed to read optinal value existance bit: %w", err) @@ -148,7 +148,7 @@ func (o *OptValue) Unmarshal(cell *boc.Cell, ty tolkParser.Nullable, decoder *De return nil } -func (o *OptValue) Marshal(cell *boc.Cell, ty tolkParser.Nullable, encoder *Encoder) error { +func (o *OptValue) Marshal(cell *boc.Cell, ty parser.Nullable, encoder *Encoder) error { err := cell.WriteBit(o.IsExists) if err != nil { return fmt.Errorf("failed to write optinal value existance bit: %w", err) @@ -213,7 +213,7 @@ func (o *OptValue) UnmarshalJSON(b []byte) error { type RefValue Value -func (r *RefValue) Unmarshal(cell *boc.Cell, ty tolkParser.CellOf, decoder *Decoder) error { +func (r *RefValue) Unmarshal(cell *boc.Cell, ty parser.CellOf, decoder *Decoder) error { ref, err := cell.NextRef() if err != nil { return fmt.Errorf("failed to get next ref: %w", err) @@ -228,7 +228,7 @@ func (r *RefValue) Unmarshal(cell *boc.Cell, ty tolkParser.CellOf, decoder *Deco return nil } -func (r *RefValue) Marshal(cell *boc.Cell, ty tolkParser.CellOf, encoder *Encoder) error { +func (r *RefValue) Marshal(cell *boc.Cell, ty parser.CellOf, encoder *Encoder) error { val := Value(*r) ref := boc.NewCell() err := val.Marshal(ref, ty.Inner, encoder) diff --git a/tolk/integers.go b/tolk/integers.go index 9f9a38ad..ed11b901 100644 --- a/tolk/integers.go +++ b/tolk/integers.go @@ -12,7 +12,7 @@ import ( type Int64 int64 -func (i *Int64) Unmarshal(cell *boc.Cell, ty tolkParser.IntN, decoder *Decoder) error { +func (i *Int64) Unmarshal(cell *boc.Cell, ty parser.IntN, decoder *Decoder) error { num, err := cell.ReadInt(ty.N) if err != nil { return fmt.Errorf("failed to read %v-bit integer: %w", ty.N, err) @@ -21,7 +21,7 @@ func (i *Int64) Unmarshal(cell *boc.Cell, ty tolkParser.IntN, decoder *Decoder) return nil } -func (i *Int64) Marshal(cell *boc.Cell, ty tolkParser.IntN, encoder *Encoder) error { +func (i *Int64) Marshal(cell *boc.Cell, ty parser.IntN, encoder *Encoder) error { err := cell.WriteInt(int64(*i), ty.N) if err != nil { return fmt.Errorf("failed to write %v-bit integer: %w", ty.N, err) @@ -39,7 +39,7 @@ func (i *Int64) Equal(other any) bool { type BigInt big.Int -func (b *BigInt) Unmarshal(cell *boc.Cell, ty tolkParser.IntN, decoder *Decoder) error { +func (b *BigInt) Unmarshal(cell *boc.Cell, ty parser.IntN, decoder *Decoder) error { num, err := cell.ReadBigInt(ty.N) if err != nil { return fmt.Errorf("failed to read %v-bit big integer: %w", ty.N, err) @@ -48,7 +48,7 @@ func (b *BigInt) Unmarshal(cell *boc.Cell, ty tolkParser.IntN, decoder *Decoder) return nil } -func (b *BigInt) Marshal(cell *boc.Cell, ty tolkParser.IntN, encoder *Encoder) error { +func (b *BigInt) Marshal(cell *boc.Cell, ty parser.IntN, encoder *Encoder) error { bi := big.Int(*b) err := cell.WriteBigInt(&bi, ty.N) if err != nil { @@ -86,7 +86,7 @@ func (b *BigInt) UnmarshalJSON(bytes []byte) error { type UInt64 uint64 -func (i *UInt64) Unmarshal(cell *boc.Cell, ty tolkParser.UintN, decoder *Decoder) error { +func (i *UInt64) Unmarshal(cell *boc.Cell, ty parser.UintN, decoder *Decoder) error { num, err := cell.ReadUint(ty.N) if err != nil { return fmt.Errorf("failed to read %v-bit unsigned integer: %w", ty.N, err) @@ -95,7 +95,7 @@ func (i *UInt64) Unmarshal(cell *boc.Cell, ty tolkParser.UintN, decoder *Decoder return nil } -func (i *UInt64) Marshal(cell *boc.Cell, ty tolkParser.UintN, encoder *Encoder) error { +func (i *UInt64) Marshal(cell *boc.Cell, ty parser.UintN, encoder *Encoder) error { err := cell.WriteUint(uint64(*i), ty.N) if err != nil { return fmt.Errorf("failed to write %v-bit unsigned integer: %w", ty.N, err) @@ -113,7 +113,7 @@ func (i *UInt64) Equal(other any) bool { type BigUInt big.Int -func (b *BigUInt) Unmarshal(cell *boc.Cell, ty tolkParser.UintN, decoder *Decoder) error { +func (b *BigUInt) Unmarshal(cell *boc.Cell, ty parser.UintN, decoder *Decoder) error { num, err := cell.ReadBigUint(ty.N) if err != nil { return fmt.Errorf("failed to read %v-bit usigned big integer: %w", ty.N, err) @@ -122,7 +122,7 @@ func (b *BigUInt) Unmarshal(cell *boc.Cell, ty tolkParser.UintN, decoder *Decode return nil } -func (b *BigUInt) Marshal(cell *boc.Cell, ty tolkParser.UintN, encoder *Encoder) error { +func (b *BigUInt) Marshal(cell *boc.Cell, ty parser.UintN, encoder *Encoder) error { bi := big.Int(*b) err := cell.WriteBigUint(&bi, ty.N) if err != nil { @@ -160,7 +160,7 @@ func (b *BigUInt) UnmarshalJSON(bytes []byte) error { type VarInt big.Int -func (vi *VarInt) Unmarshal(cell *boc.Cell, ty tolkParser.VarIntN, decoder *Decoder) error { +func (vi *VarInt) Unmarshal(cell *boc.Cell, ty parser.VarIntN, decoder *Decoder) error { ln, err := cell.ReadLimUint(ty.N - 1) if err != nil { return fmt.Errorf("failed to read var integer length: %w", err) @@ -173,7 +173,7 @@ func (vi *VarInt) Unmarshal(cell *boc.Cell, ty tolkParser.VarIntN, decoder *Deco return nil } -func (vi *VarInt) Marshal(cell *boc.Cell, ty tolkParser.VarIntN, encoder *Encoder) error { +func (vi *VarInt) Marshal(cell *boc.Cell, ty parser.VarIntN, encoder *Encoder) error { bi := big.Int(*vi) num := bi.Bytes() err := cell.WriteLimUint(len(num), ty.N-1) @@ -217,7 +217,7 @@ func (vi *VarInt) UnmarshalJSON(bytes []byte) error { type VarUInt big.Int -func (vu *VarUInt) Unmarshal(cell *boc.Cell, ty tolkParser.VarUintN, decoder *Decoder) error { +func (vu *VarUInt) Unmarshal(cell *boc.Cell, ty parser.VarUintN, decoder *Decoder) error { ln, err := cell.ReadLimUint(ty.N - 1) if err != nil { return fmt.Errorf("failed to read usigned var integer length: %w", err) @@ -230,7 +230,7 @@ func (vu *VarUInt) Unmarshal(cell *boc.Cell, ty tolkParser.VarUintN, decoder *De return nil } -func (vu *VarUInt) Marshal(cell *boc.Cell, ty tolkParser.VarUintN, encoder *Encoder) error { +func (vu *VarUInt) Marshal(cell *boc.Cell, ty parser.VarUintN, encoder *Encoder) error { bi := big.Int(*vu) num := bi.Bytes() err := cell.WriteLimUint(len(num), ty.N-1) @@ -274,7 +274,7 @@ func (vu *VarUInt) UnmarshalJSON(bytes []byte) error { type Bits boc.BitString -func (b *Bits) Unmarshal(cell *boc.Cell, ty tolkParser.BitsN, decoder *Decoder) error { +func (b *Bits) Unmarshal(cell *boc.Cell, ty parser.BitsN, decoder *Decoder) error { val, err := cell.ReadBits(ty.N) if err != nil { return fmt.Errorf("failed to read bits value: %w", err) @@ -283,7 +283,7 @@ func (b *Bits) Unmarshal(cell *boc.Cell, ty tolkParser.BitsN, decoder *Decoder) return nil } -func (b *Bits) Marshal(cell *boc.Cell, ty tolkParser.BitsN, encoder *Encoder) error { +func (b *Bits) Marshal(cell *boc.Cell, ty parser.BitsN, encoder *Encoder) error { bi := boc.BitString(*b) err := cell.WriteBitString(bi) if err != nil { @@ -322,18 +322,18 @@ func (b *Bits) UnmarshalJSON(bytes []byte) error { type CoinsValue big.Int -func (c *CoinsValue) Unmarshal(cell *boc.Cell, ty tolkParser.Coins, decoder *Decoder) error { +func (c *CoinsValue) Unmarshal(cell *boc.Cell, ty parser.Coins, decoder *Decoder) error { varUint := VarUInt{} - if err := varUint.Unmarshal(cell, tolkParser.VarUintN{N: 16}, decoder); err != nil { + if err := varUint.Unmarshal(cell, parser.VarUintN{N: 16}, decoder); err != nil { return fmt.Errorf("failed to unmarshal coins value: %w", err) } *c = CoinsValue(varUint) return nil } -func (c *CoinsValue) Marshal(cell *boc.Cell, ty tolkParser.Coins, encoder *Encoder) error { +func (c *CoinsValue) Marshal(cell *boc.Cell, ty parser.Coins, encoder *Encoder) error { varUint := VarUInt(*c) - err := varUint.Marshal(cell, tolkParser.VarUintN{N: 16}, encoder) // coins is actually varuint16 + err := varUint.Marshal(cell, parser.VarUintN{N: 16}, encoder) // coins is actually varuint16 if err != nil { return fmt.Errorf("failed to marshal coins value: %w", err) } @@ -377,7 +377,7 @@ func (b *BoolValue) Equal(o any) bool { return *b == otherBool } -func (b *BoolValue) Unmarshal(cell *boc.Cell, ty tolkParser.Bool, decoder *Decoder) error { +func (b *BoolValue) Unmarshal(cell *boc.Cell, ty parser.Bool, decoder *Decoder) error { val, err := cell.ReadBit() if err != nil { return fmt.Errorf("failed to read bool value: %w", err) @@ -386,7 +386,7 @@ func (b *BoolValue) Unmarshal(cell *boc.Cell, ty tolkParser.Bool, decoder *Decod return nil } -func (b *BoolValue) Marshal(cell *boc.Cell, ty tolkParser.Bool, encoder *Encoder) error { +func (b *BoolValue) Marshal(cell *boc.Cell, ty parser.Bool, encoder *Encoder) error { err := cell.WriteBit(bool(*b)) if err != nil { return fmt.Errorf("failed to write bool value: %w", err) diff --git a/tolk/map.go b/tolk/map.go index b74b962a..fdb66361 100644 --- a/tolk/map.go +++ b/tolk/map.go @@ -17,7 +17,7 @@ type MapValue struct { len int } -func (m *MapValue) Unmarshal(cell *boc.Cell, ty tolkParser.Map, decoder *Decoder) error { +func (m *MapValue) Unmarshal(cell *boc.Cell, ty parser.Map, decoder *Decoder) error { keySize, ok := ty.K.GetFixedSize() if !ok { return fmt.Errorf("%v type is not comparable", ty.K.SumType) @@ -54,7 +54,7 @@ func mapInner( keySize, leftKeySize int, c *boc.Cell, keyPrefix *boc.BitString, - kt, vt tolkParser.Ty, + kt, vt parser.Ty, keys, values *[]Value, decoder *Decoder, ) error { @@ -187,7 +187,7 @@ func loadLabel(size int, c *boc.Cell, key *boc.BitString) (int, *boc.BitString, return int(ln), key, nil } -func (m *MapValue) Marshal(cell *boc.Cell, ty tolkParser.Map, encoder *Encoder) error { +func (m *MapValue) Marshal(cell *boc.Cell, ty parser.Map, encoder *Encoder) error { keySize, ok := ty.K.GetFixedSize() if !ok { return fmt.Errorf("%s type is not comparable", ty.K.SumType) @@ -234,7 +234,7 @@ func (m *MapValue) Marshal(cell *boc.Cell, ty tolkParser.Map, encoder *Encoder) return nil } -func encodeMap(c *boc.Cell, keys []boc.BitString, values []Value, keySize int, vt tolkParser.Ty, encoder *Encoder) error { +func encodeMap(c *boc.Cell, keys []boc.BitString, values []Value, keySize int, vt parser.Ty, encoder *Encoder) error { if len(keys) == 0 || len(values) == 0 { return fmt.Errorf("keys or values are empty") } diff --git a/tolk/null.go b/tolk/null.go index 92e30770..2235799b 100644 --- a/tolk/null.go +++ b/tolk/null.go @@ -15,11 +15,11 @@ func (n *NullValue) Equal(other any) bool { return true } -func (n *NullValue) Unmarshal(cell *boc.Cell, ty tolkParser.NullLiteral, decoder *Decoder) error { +func (n *NullValue) Unmarshal(cell *boc.Cell, ty parser.NullLiteral, decoder *Decoder) error { return nil } -func (n *NullValue) Marshal(cell *boc.Cell, ty tolkParser.NullLiteral, encoder *Encoder) error { +func (n *NullValue) Marshal(cell *boc.Cell, ty parser.NullLiteral, encoder *Encoder) error { return nil } @@ -37,11 +37,11 @@ func (v *VoidValue) Equal(other any) bool { return true } -func (v *VoidValue) Unmarshal(cell *boc.Cell, ty tolkParser.Void, decoder *Decoder) error { +func (v *VoidValue) Unmarshal(cell *boc.Cell, ty parser.Void, decoder *Decoder) error { return nil } -func (v *VoidValue) Marshal(cell *boc.Cell, ty tolkParser.Void, encoder *Encoder) error { +func (v *VoidValue) Marshal(cell *boc.Cell, ty parser.Void, encoder *Encoder) error { return nil } diff --git a/tolk/parser/shortcuts.go b/tolk/parser/shortcuts.go index cbe090f2..8bedb6e3 100644 --- a/tolk/parser/shortcuts.go +++ b/tolk/parser/shortcuts.go @@ -1,4 +1,4 @@ -package tolkParser +package parser func NewIntNType(n int) Ty { return Ty{ diff --git a/tolk/parser/types.go b/tolk/parser/types.go index 61654727..31ee23f1 100644 --- a/tolk/parser/types.go +++ b/tolk/parser/types.go @@ -1,4 +1,4 @@ -package tolkParser +package parser import ( "encoding/json" diff --git a/tolk/refs.go b/tolk/refs.go index b443f3b4..23226d2e 100644 --- a/tolk/refs.go +++ b/tolk/refs.go @@ -27,7 +27,7 @@ type Struct struct { fieldValues []Value } -func (s *Struct) Unmarshal(cell *boc.Cell, ty tolkParser.StructRef, decoder *Decoder) error { +func (s *Struct) Unmarshal(cell *boc.Cell, ty parser.StructRef, decoder *Decoder) error { if decoder.abiRefs.structRefs == nil { return fmt.Errorf("struct has struct reference but no abi has been given") } @@ -100,7 +100,7 @@ func (s *Struct) Unmarshal(cell *boc.Cell, ty tolkParser.StructRef, decoder *Dec } // try to resolve payload from all known abi in trace -func (s *Struct) resolvePayload(cell *boc.Cell, ty tolkParser.Ty, decoder *Decoder) (Value, bool, error) { +func (s *Struct) resolvePayload(cell *boc.Cell, ty parser.Ty, decoder *Decoder) (Value, bool, error) { switch ty.SumType { case "Remaining": isRef, err := cell.ReadBit() @@ -139,7 +139,7 @@ func (s *Struct) resolvePayload(cell *boc.Cell, ty tolkParser.Ty, decoder *Decod return Value{}, false, nil } -func (s *Struct) Marshal(cell *boc.Cell, ty tolkParser.StructRef, encoder *Encoder) error { +func (s *Struct) Marshal(cell *boc.Cell, ty parser.StructRef, encoder *Encoder) error { if encoder.abiRefs.structRefs == nil { return fmt.Errorf("struct has struct reference but no abi has been given") } @@ -285,7 +285,7 @@ type EnumValue struct { Value big.Int } -func (e *EnumValue) Unmarshal(cell *boc.Cell, ty tolkParser.EnumRef, decoder *Decoder) error { +func (e *EnumValue) Unmarshal(cell *boc.Cell, ty parser.EnumRef, decoder *Decoder) error { if decoder.abiRefs.enumRefs == nil { return fmt.Errorf("struct has enum reference but no abi has been given") } @@ -349,7 +349,7 @@ func (e EnumValue) MarshalJSON() ([]byte, error) { return data, nil } -func (e *EnumValue) Marshal(cell *boc.Cell, ty tolkParser.EnumRef, encoder *Encoder) error { +func (e *EnumValue) Marshal(cell *boc.Cell, ty parser.EnumRef, encoder *Encoder) error { if encoder.abiRefs.enumRefs == nil { return fmt.Errorf("struct has enum reference but no abi has been given") } @@ -401,7 +401,7 @@ func (a *AliasValue) Equal(other any) bool { return v.Equal(Value(otherAlias)) } -func (a *AliasValue) Unmarshal(cell *boc.Cell, ty tolkParser.AliasRef, decoder *Decoder) error { +func (a *AliasValue) Unmarshal(cell *boc.Cell, ty parser.AliasRef, decoder *Decoder) error { if decoder.abiRefs.aliasRefs == nil { return fmt.Errorf("struct has alias reference but no abi has been given") } @@ -439,7 +439,7 @@ func (a *AliasValue) Unmarshal(cell *boc.Cell, ty tolkParser.AliasRef, decoder * return nil } -func (a *AliasValue) Marshal(cell *boc.Cell, ty tolkParser.AliasRef, encoder *Encoder) error { +func (a *AliasValue) Marshal(cell *boc.Cell, ty parser.AliasRef, encoder *Encoder) error { if encoder.abiRefs.aliasRefs == nil { return fmt.Errorf("struct has alias reference but no abi has been given") } @@ -487,7 +487,7 @@ func (g *GenericValue) Equal(other any) bool { return v.Equal(Value(otherGeneric)) } -func (g *GenericValue) Unmarshal(cell *boc.Cell, ty tolkParser.Generic, decoder *Decoder) error { +func (g *GenericValue) Unmarshal(cell *boc.Cell, ty parser.Generic, decoder *Decoder) error { currentTy, found := decoder.abiRefs.genericRefs[ty.NameT] if !found { return fmt.Errorf("cannot resolve generic's type %v ", ty.NameT) @@ -503,7 +503,7 @@ func (g *GenericValue) Unmarshal(cell *boc.Cell, ty tolkParser.Generic, decoder return nil } -func (g *GenericValue) Marshal(cell *boc.Cell, ty tolkParser.Generic, encoder *Encoder) error { +func (g *GenericValue) Marshal(cell *boc.Cell, ty parser.Generic, encoder *Encoder) error { currentTy, found := encoder.abiRefs.genericRefs[ty.NameT] if !found { return fmt.Errorf("cannot resolve generic's type %v ", ty.NameT) @@ -517,8 +517,8 @@ func (g *GenericValue) Marshal(cell *boc.Cell, ty tolkParser.Generic, encoder *E return nil } -func resolveGeneric(typeArgs []tolkParser.Ty, typeParams []string, abiRefs *abiRefs) (map[string]tolkParser.Ty, error) { - genericMap := make(map[string]tolkParser.Ty) +func resolveGeneric(typeArgs []parser.Ty, typeParams []string, abiRefs *abiRefs) (map[string]parser.Ty, error) { + genericMap := make(map[string]parser.Ty) if abiRefs.genericRefs != nil { maps.Copy(genericMap, abiRefs.genericRefs) } diff --git a/tolk/runtime.go b/tolk/runtime.go index 71b41936..5c0cdd55 100644 --- a/tolk/runtime.go +++ b/tolk/runtime.go @@ -7,25 +7,25 @@ import ( "github.com/tonkeeper/tongo/tolk/parser" ) -func Unmarshal(cell *boc.Cell, ty tolkParser.Ty) (*Value, error) { +func Unmarshal(cell *boc.Cell, ty parser.Ty) (*Value, error) { d := NewDecoder() return d.Unmarshal(cell, ty) } -func Marshal(v *Value, ty tolkParser.Ty) (*boc.Cell, error) { +func Marshal(v *Value, ty parser.Ty) (*boc.Cell, error) { e := NewEncoder() return e.Marshal(v, ty) } type abiRefs struct { - structRefs map[string]tolkParser.StructDeclaration - aliasRefs map[string]tolkParser.AliasDeclaration - enumRefs map[string]tolkParser.EnumDeclaration - genericRefs map[string]tolkParser.Ty - opcodeRefs map[uint64][]tolkParser.StructDeclaration + structRefs map[string]parser.StructDeclaration + aliasRefs map[string]parser.AliasDeclaration + enumRefs map[string]parser.EnumDeclaration + genericRefs map[string]parser.Ty + opcodeRefs map[uint64][]parser.StructDeclaration } -type customUnpackResolver = func(tolkParser.AliasRef, *boc.Cell, *AliasValue) error +type customUnpackResolver = func(parser.AliasRef, *boc.Cell, *AliasValue) error type Decoder struct { abiRefs abiRefs @@ -36,13 +36,13 @@ func NewDecoder() *Decoder { return &Decoder{} } -func (d *Decoder) WithABIs(abis ...tolkParser.ABI) error { +func (d *Decoder) WithABIs(abis ...parser.ABI) error { d.abiRefs = abiRefs{ - structRefs: make(map[string]tolkParser.StructDeclaration), - aliasRefs: make(map[string]tolkParser.AliasDeclaration), - enumRefs: make(map[string]tolkParser.EnumDeclaration), - genericRefs: make(map[string]tolkParser.Ty), - opcodeRefs: make(map[uint64][]tolkParser.StructDeclaration), + structRefs: make(map[string]parser.StructDeclaration), + aliasRefs: make(map[string]parser.AliasDeclaration), + enumRefs: make(map[string]parser.EnumDeclaration), + genericRefs: make(map[string]parser.Ty), + opcodeRefs: make(map[uint64][]parser.StructDeclaration), } for _, abi := range abis { for _, declr := range abi.Declarations { @@ -70,7 +70,7 @@ func (d *Decoder) WithCustomUnpackResolver(customUnpackResolver customUnpackReso d.customUnpackResolver = customUnpackResolver } -func (d *Decoder) Unmarshal(cell *boc.Cell, ty tolkParser.Ty) (*Value, error) { +func (d *Decoder) Unmarshal(cell *boc.Cell, ty parser.Ty) (*Value, error) { res := &Value{} err := res.Unmarshal(cell, ty, d) if err != nil { @@ -103,7 +103,7 @@ func (d *Decoder) resolvePayload(payload *boc.Cell) (Value, bool, error) { guessedStructs := d.abiRefs.opcodeRefs[payloadOpcode] for _, strct := range guessedStructs { - v, err := d.Unmarshal(payload, tolkParser.NewStructType(strct.Name)) + v, err := d.Unmarshal(payload, parser.NewStructType(strct.Name)) if err != nil { continue } @@ -114,7 +114,7 @@ func (d *Decoder) resolvePayload(payload *boc.Cell) (Value, bool, error) { return Value{}, false, nil } -type customPackResolver = func(tolkParser.AliasRef, *boc.Cell, *AliasValue) error +type customPackResolver = func(parser.AliasRef, *boc.Cell, *AliasValue) error type Encoder struct { abiRefs abiRefs @@ -125,13 +125,13 @@ func NewEncoder() *Encoder { return &Encoder{} } -func (e *Encoder) WithABIs(abis ...tolkParser.ABI) error { +func (e *Encoder) WithABIs(abis ...parser.ABI) error { e.abiRefs = abiRefs{ - structRefs: make(map[string]tolkParser.StructDeclaration), - aliasRefs: make(map[string]tolkParser.AliasDeclaration), - enumRefs: make(map[string]tolkParser.EnumDeclaration), - genericRefs: make(map[string]tolkParser.Ty), - opcodeRefs: make(map[uint64][]tolkParser.StructDeclaration), + structRefs: make(map[string]parser.StructDeclaration), + aliasRefs: make(map[string]parser.AliasDeclaration), + enumRefs: make(map[string]parser.EnumDeclaration), + genericRefs: make(map[string]parser.Ty), + opcodeRefs: make(map[uint64][]parser.StructDeclaration), } for _, abi := range abis { for _, declr := range abi.Declarations { @@ -159,7 +159,7 @@ func (e *Encoder) WithCustomPackResolver(customPackResolver customPackResolver) e.customPackResolver = customPackResolver } -func (e *Encoder) Marshal(v *Value, ty tolkParser.Ty) (*boc.Cell, error) { +func (e *Encoder) Marshal(v *Value, ty parser.Ty) (*boc.Cell, error) { cell := boc.NewCell() err := v.Marshal(cell, ty, e) if err != nil { diff --git a/tolk/runtime_benchmark_test.go b/tolk/runtime_benchmark_test.go new file mode 100644 index 00000000..e3b2e8f1 --- /dev/null +++ b/tolk/runtime_benchmark_test.go @@ -0,0 +1,368 @@ +package tolk + +import ( + "encoding/json" + "fmt" + "os" + "testing" + + "github.com/tonkeeper/tongo/abi" + "github.com/tonkeeper/tongo/boc" + "github.com/tonkeeper/tongo/tlb" + "github.com/tonkeeper/tongo/tolk/parser" +) + +func BenchmarkRuntimeUnmarshalling(b *testing.B) { + type Case struct { + name string + ty parser.Ty + cell boc.Cell + abiFiles []string + customUnpackResolver func(decoder *Decoder) func(alias parser.AliasRef, cell *boc.Cell, value *AliasValue) error + } + for _, curr := range []Case{ + { + name: "unmarshal small int", + ty: parser.NewIntNType(24), + cell: *boc.MustDeserializeSinglRootHex("b5ee9c72410101010005000006ff76c41616db06"), + }, + { + name: "unmarshal big int", + ty: parser.NewIntNType(183), + cell: *boc.MustDeserializeSinglRootHex("b5ee9c7241010101001900002dfffffffffffffffffffffffffffffffffff99bfeac6423a6f0b50c"), + }, + { + name: "unmarshal small uint", + ty: parser.NewUIntNType(53), + cell: *boc.MustDeserializeSinglRootHex("b5ee9c7241010101000900000d00000000001d34e435eafd"), + }, + { + name: "unmarshal big uint", + ty: parser.NewUIntNType(257), + cell: *boc.MustDeserializeSinglRootHex("b5ee9c7241010101002300004100000000000000000000000000000000000000000000000000009fc4212a38ba40b11cce12"), + }, + { + name: "unmarshal var int 16", + ty: parser.NewVarInt16Type(), + cell: *boc.MustDeserializeSinglRootHex("b5ee9c7241010101000600000730c98588449b6923"), + }, + { + name: "unmarshal var uint 32", + ty: parser.NewVarUInt32Type(), + cell: *boc.MustDeserializeSinglRootHex("b5ee9c7241010101000800000b28119ab36b44d3a86c0f"), + }, + { + name: "unmarshal bits24", + ty: parser.NewBitsNType(24), + cell: *boc.MustDeserializeSinglRootHex("b5ee9c7241010101000500000631323318854035"), + }, + { + name: "unmarshal coins", + ty: parser.NewCoinsType(), + cell: *boc.MustDeserializeSinglRootHex("b5ee9c72410101010007000009436ec6e0189ebbd7f4"), + }, + { + name: "unmarshal bool", + ty: parser.NewBoolType(), + cell: *boc.MustDeserializeSinglRootHex("b5ee9c7241010101000300000140f6d24034"), + }, + { + name: "unmarshal cell", + ty: parser.NewCellType(), + cell: *boc.MustDeserializeSinglRootHex("b5ee9c724101020100090001000100080000007ba52a3292"), + }, + { + name: "unmarshal remaining", + ty: parser.NewRemainingType(), + cell: *boc.MustDeserializeSinglRootHex("b5ee9c7241010101000900000dc0800000000ab8d04726e4"), + }, + { + name: "unmarshal internal address", + ty: parser.NewAddressType(), + cell: *boc.MustDeserializeSinglRootHex("b5ee9c7241010101002400004380107bfaaa5cc6e5368e5f9799188bd798cd22e04ab16d1d8ea4fc37480741e6351064a3e1a6"), + }, + { + name: "unmarshal not exists optional address", + ty: parser.NewAddressOptType(), + cell: *boc.MustDeserializeSinglRootHex("b5ee9c724101010100030000012094418655"), + }, + { + name: "unmarshal exists optional address", + ty: parser.NewAddressOptType(), + cell: *boc.MustDeserializeSinglRootHex("b5ee9c7241010101002400004380107bfaaa5cc6e5368e5f9799188bd798cd22e04ab16d1d8ea4fc37480741e6351064a3e1a6"), + }, + { + name: "unmarshal external address", + ty: parser.NewAddressExtType(), + cell: *boc.MustDeserializeSinglRootHex("b5ee9c7241010101000600000742082850fcbd94fd"), + }, + { + name: "unmarshal none address any", + ty: parser.NewAddressAnyType(), + cell: *boc.MustDeserializeSinglRootHex("b5ee9c724101010100030000012094418655"), + }, + { + name: "unmarshal internal address any", + ty: parser.NewAddressAnyType(), + cell: *boc.MustDeserializeSinglRootHex("b5ee9c7241010101002400004380107bfaaa5cc6e5368e5f9799188bd798cd22e04ab16d1d8ea4fc37480741e6351064a3e1a6"), + }, + { + name: "unmarshal external address any", + ty: parser.NewAddressAnyType(), + cell: *boc.MustDeserializeSinglRootHex("b5ee9c7241010101000600000742082850fcbd94fd"), + }, + { + name: "unmarshal var address any", + ty: parser.NewAddressAnyType(), + cell: *boc.MustDeserializeSinglRootHex("b5ee9c7241010101000900000dc0800000000ab8d04726e4"), + }, + { + name: "unmarshal not exists nullable", + ty: parser.NewNullableType(parser.NewRemainingType()), + cell: *boc.MustDeserializeSinglRootHex("b5ee9c7241010101000300000140f6d24034"), + }, + { + name: "unmarshal exists nullable", + ty: parser.NewNullableType(parser.NewCellType()), + cell: *boc.MustDeserializeSinglRootHex("b5ee9c7241010201000b000101c001000900000c0ae007880db9"), + }, + { + name: "unmarshal ref", + ty: parser.NewCellOfType(parser.NewIntNType(65)), + cell: *boc.MustDeserializeSinglRootHex("b5ee9c7241010201000e000100010011000000000009689e40e150b4c5"), + }, + { + name: "unmarshal empty tensor", + ty: parser.NewTensorType(), + cell: *boc.MustDeserializeSinglRootHex("b5ee9c724101010100020000004cacb9cd"), + }, + { + name: "unmarshal not empty tensor", + ty: parser.NewTensorType( + parser.NewUIntNType(123), + parser.NewBoolType(), + parser.NewCoinsType(), + parser.NewTensorType( + parser.NewIntNType(23), + parser.NewNullableType(parser.NewIntNType(2)), + ), + parser.NewVarIntType(32), + ), + cell: *boc.MustDeserializeSinglRootHex("b5ee9c7241010101001f00003900000000000000000000000000021cb43b9aca00fffd550bfbaae07401a2a98117"), + }, + { + name: "unmarshal small-int-key map", + ty: parser.NewMapType(parser.NewIntNType(32), parser.NewBoolType()), + cell: *boc.MustDeserializeSinglRootHex("b5ee9c7241010201000c000101c001000ba00000007bc09a662c32"), + }, + { + name: "unmarshal small-uint-key map", + ty: parser.NewMapType(parser.NewUIntNType(16), parser.NewAddressType()), + cell: *boc.MustDeserializeSinglRootHex("b5ee9c72410104010053000101c0010202cb02030045a7400b113a994b5024a16719f69139328eb759596c38a25f59028b146fecdc3621dfe80045a3cff5555555555555555555555555555555555555555555555555555555555555555888440ce8"), + }, + { + name: "unmarshal big-uint-key map", + ty: parser.NewMapType(parser.NewUIntNType(78), parser.NewCellType()), + cell: *boc.MustDeserializeSinglRootHex("b5ee9c7241010301001a000101c0010115a70000000000000047550902000b000000001ab01d5bf1a9"), + }, + { + name: "unmarshal bits-key map", + ty: parser.NewMapType( + parser.NewBitsNType(16), + parser.NewMapType( + parser.NewIntNType(64), + parser.NewTensorType( + parser.NewAddressType(), + parser.NewCoinsType(), + ), + ), + ), + cell: *boc.MustDeserializeSinglRootHex("b5ee9c7241010301003b000101c0010106a0828502005ea0000000000000003e400b113a994b5024a16719f69139328eb759596c38a25f59028b146fecdc3621dfe43b9aca00b89cdc86"), + }, + { + name: "unmarshal address-key map", + ty: parser.NewMapType(parser.NewAddressType(), parser.NewCoinsType()), + cell: *boc.MustDeserializeSinglRootHex("b5ee9c7241010201002f000101c0010051a17002c44ea652d4092859c67da44e4ca3add6565b0e2897d640a2c51bfb370d8877f9409502f9002016fdc16e"), + }, + { + name: "unmarshal union with dec prefix", + ty: parser.NewUnionType( + 1, true, + parser.NewUnionVariant(parser.NewIntNType(16), "0"), + parser.NewUnionVariant(parser.NewIntNType(128), "1"), + ), + cell: *boc.MustDeserializeSinglRootHex("b5ee9c7241010101001300002180000000000000000000000003b5577dc0660d6029"), + }, + { + name: "unmarshal union with bin prefix", + ty: parser.NewUnionType( + 3, false, + parser.NewUnionVariant(parser.NewStructType("AddressWithPrefix"), "0b001"), + parser.NewUnionVariant(parser.NewStructType("MapWithPrefix"), "0b011"), + parser.NewUnionVariant(parser.NewStructType("CellWithPrefix"), "0b111"), + ), + cell: *boc.MustDeserializeSinglRootHex("b5ee9c7241010201002e0001017801004fa17002c44ea652d4092859c67da44e4ca3add6565b0e2897d640a2c51bfb370d8877f900a4d89920c413c650"), + abiFiles: []string{"testdata/bin_union.json"}, + }, + { + name: "unmarshal union with hex prefix", + ty: parser.NewUnionType( + 32, false, + parser.NewUnionVariant(parser.NewStructType("UInt66WithPrefix"), "0x12345678"), + parser.NewUnionVariant(parser.NewStructType("UInt33WithPrefix"), "0xdeadbeef"), + parser.NewUnionVariant(parser.NewStructType("UInt4WithPrefix"), "0x89abcdef"), + ), + cell: *boc.MustDeserializeSinglRootHex("b5ee9c7241010101000b000011deadbeef00000000c0d75977b9"), + abiFiles: []string{"testdata/hex_union.json"}, + }, + { + name: "unmarshal a-lot-refs from alias", + ty: parser.NewAliasType("GoodNamingForMsg"), + cell: *boc.MustDeserializeSinglRootHex("b5ee9c724101040100b7000377deadbeef80107bfaaa5cc6e5368e5f9799188bd798cd22e04ab16d1d8ea4fc37480741e635087735940143ffffffffffffffffffffffffffff63c006010203004b80010df454cebee868f611ba8c0d4a9371fb73105396505783293a7625f75db3b9880bebc20100438006e05909e22b2e5e6087533314ee56505f85212914bd5547941a2a658ac62fe101004f801622753296a04942ce33ed2272651d6eb2b2d87144beb2051628dfd9b86c43bfcc12309ce54001e09a48b8"), + abiFiles: []string{"testdata/refs.json"}, + }, + { + name: "unmarshal a-lot-refs from struct", + ty: parser.NewStructType("ManyRefsMsg"), + cell: *boc.MustDeserializeSinglRootHex("b5ee9c724101040100b7000377deadbeef80107bfaaa5cc6e5368e5f9799188bd798cd22e04ab16d1d8ea4fc37480741e635087735940143ffffffffffffffffffffffffffff63c006010203004b80010df454cebee868f611ba8c0d4a9371fb73105396505783293a7625f75db3b9880bebc20100438006e05909e22b2e5e6087533314ee56505f85212914bd5547941a2a658ac62fe101004f801622753296a04942ce33ed2272651d6eb2b2d87144beb2051628dfd9b86c43bfcc12309ce54001e09a48b8"), + abiFiles: []string{"testdata/refs.json"}, + }, + { + name: "unmarshal a-lot-generics from struct", + ty: parser.NewStructType("ManyRefsMsg", parser.NewUIntNType(16)), + cell: *boc.MustDeserializeSinglRootHex("b5ee9c72410103010043000217d017d7840343b9aca0000108010200080000007b005543b9aca001017d78402005889d4ca5a81250b38cfb489c99475bacacb61c512fac81458a37f66e1b10eff422fc7647"), + abiFiles: []string{"testdata/generics.json"}, + }, + { + name: "unmarshal a-lot-generics from alias", + ty: parser.NewAliasType("GoodNamingForMsg", parser.NewUIntNType(16)), + cell: *boc.MustDeserializeSinglRootHex("b5ee9c72410103010043000217d017d7840343b9aca0000108010200080000007b005543b9aca001017d78402005889d4ca5a81250b38cfb489c99475bacacb61c512fac81458a37f66e1b10eff422fc7647"), + abiFiles: []string{"testdata/generics.json"}, + }, + { + name: "unmarshal struct with default values", + ty: parser.NewStructType("DefaultTest"), + cell: *boc.MustDeserializeSinglRootHex("b5ee9c7241010101003100005d80000002414801622753296a04942ce33ed2272651d6eb2b2d87144beb2051628dfd9b86c43bfd00000156ac2c4c70811a9dde"), + abiFiles: []string{"testdata/default_values.json"}, + }, + { + name: "unmarshal a-lot-numbers", + ty: parser.NewStructType("Numbers"), + cell: *boc.MustDeserializeSinglRootHex("b5ee9c72410101010033000062000000000000000000000000000000000000000000000000000000000000000000000000000000f1106aecc4c800020926dc62f014"), + abiFiles: []string{"testdata/numbers.json"}, + }, + { + name: "unmarshal a-lot-random-fields", + ty: parser.NewStructType("RandomFields"), + cell: *boc.MustDeserializeSinglRootHex("b5ee9c7241010301007800028b79480107bfaaa5cc6e5368e5f9799188bd798cd22e04ab16d1d8ea4fc37480741e6350e038d7eb37c5e80000000ab50ee6b28000000000000016e4c000006c175300001801bc01020001c00051000000000005120041efeaa9731b94da397e5e64622f5e63348b812ac5b4763a93f0dd201d0798d4409e337ceb"), + abiFiles: []string{"testdata/random_fields.json"}, + }, + { + name: "unmarshal alias with custom unpack", + ty: parser.NewAliasType("MyAlias"), + cell: *boc.MustDeserializeSinglRootHex("b5ee9c724101010100470000890000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000043b9aca00886e91196"), + abiFiles: []string{"testdata/custom_pack_unpack.json"}, + customUnpackResolver: func(decoder *Decoder) func(alias parser.AliasRef, cell *boc.Cell, value *AliasValue) error { + return func(alias parser.AliasRef, cell *boc.Cell, value *AliasValue) error { + err := cell.Skip(512) + if err != nil { + return fmt.Errorf("failed to 512 bits from alias") + } + val, err := decoder.Unmarshal(cell, parser.NewStructType("My")) + if err != nil { + return fmt.Errorf("failed to unmarshal alias' coins") + } + *value = AliasValue(*val) + return nil + } + }, + }, + } { + abis := make([]parser.ABI, len(curr.abiFiles)) + for i, abiFile := range curr.abiFiles { + data, err := os.ReadFile(abiFile) + if err != nil { + b.Fatal(err) + } + + var abi parser.ABI + err = json.Unmarshal(data, &abi) + if err != nil { + b.Fatal(err) + } + abis[i] = abi + } + b.Run(curr.name, func(b *testing.B) { + b.ResetTimer() + for i := 0; i < b.N; i++ { + curr.cell.ResetCounters() + decoder := NewDecoder() + if err := decoder.WithABIs(abis...); err != nil { + b.Fatal(err) + } + if curr.customUnpackResolver != nil { + decoder.WithCustomUnpackResolver(curr.customUnpackResolver(decoder)) + } + _, err := decoder.Unmarshal(&curr.cell, curr.ty) + if err != nil { + b.Fatal(err) + } + } + }) + } +} + +func BenchmarkRuntimeMessageUnmarshalling(b *testing.B) { + type Case struct { + name string + cell boc.Cell + abiFiles []string + } + for _, curr := range []Case{ + { + name: "unmarshal jetton transfer message stonfi", + cell: *boc.MustDeserializeSinglRootHex("b5ee9c720102030100011b0001ae0f8a7ea5546de4efb35a04c230f424080125c28235ca8d125e676591513d520721b1fe99f7722f4c87723ce7ee0dfb73a300268806c2c709c47ec1b610073c38ef75cf6066e9e4368b10ddbdc015d0e59c98881c9c38010101e16664de2a801244183034d9fd59a236f71ec4271be377399056dda4cc3a5ebf5dc40967df64100268806c2c709c47ec1b610073c38ef75cf6066e9e4368b10ddbdc015d0e59c98a004d100d858e1388fd836c200e7871deeb9ec0cdd3c86d1621bb7b802ba1cb39310000000034d3e7f3c002009542ecec75480134403616384e23f60db08039e1c77bae7b03374f21b45886edee00ae872ce4c4000005400f4684b10a661eaa395f87d4a660e6dfc3bec187a8b24f6f362c0c6b1d20f1b5d8"), + abiFiles: []string{"testdata/jetton_transfer.json", "testdata/payloads.json"}, + }, + } { + abis := make([]parser.ABI, len(curr.abiFiles)) + for i, abiFile := range curr.abiFiles { + data, err := os.ReadFile(abiFile) + if err != nil { + b.Fatal(err) + } + + var abi parser.ABI + err = json.Unmarshal(data, &abi) + if err != nil { + b.Fatal(err) + } + abis[i] = abi + } + b.Run(curr.name, func(b *testing.B) { + for i := 0; i < b.N; i++ { + curr.cell.ResetCounters() + decoder := NewDecoder() + if err := decoder.WithABIs(abis...); err != nil { + b.Fatal(err) + } + _, err := decoder.UnmarshalMessage(&curr.cell) + if err != nil { + b.Fatal(err) + } + } + }) + } +} + +func BenchmarkTLBMessageUnmarshalling(b *testing.B) { + cell := boc.MustDeserializeSinglRootHex("b5ee9c720102030100011b0001ae0f8a7ea5546de4efb35a04c230f424080125c28235ca8d125e676591513d520721b1fe99f7722f4c87723ce7ee0dfb73a300268806c2c709c47ec1b610073c38ef75cf6066e9e4368b10ddbdc015d0e59c98881c9c38010101e16664de2a801244183034d9fd59a236f71ec4271be377399056dda4cc3a5ebf5dc40967df64100268806c2c709c47ec1b610073c38ef75cf6066e9e4368b10ddbdc015d0e59c98a004d100d858e1388fd836c200e7871deeb9ec0cdd3c86d1621bb7b802ba1cb39310000000034d3e7f3c002009542ecec75480134403616384e23f60db08039e1c77bae7b03374f21b45886edee00ae872ce4c4000005400f4684b10a661eaa395f87d4a660e6dfc3bec187a8b24f6f362c0c6b1d20f1b5d8") + for i := 0; i < b.N; i++ { + cell.ResetCounters() + var body abi.InMsgBody + decoder := tlb.NewDecoder() + if err := decoder.Unmarshal(cell, &body); err != nil { + b.Fatal(err) + } + } +} diff --git a/tolk/runtime_test.go b/tolk/runtime_test.go index 8fdcbcfa..2ce2d354 100644 --- a/tolk/runtime_test.go +++ b/tolk/runtime_test.go @@ -18,7 +18,7 @@ const jsonFilesPath = "testdata/json/" func TestRuntime_UnmarshalSmallInt(t *testing.T) { inputFilename := "small_int" - ty := tolkParser.NewIntNType(24) + ty := parser.NewIntNType(24) currCell, err := boc.DeserializeBocHex("b5ee9c72410101010005000006ff76c41616db06") if err != nil { @@ -50,7 +50,7 @@ func TestRuntime_UnmarshalSmallInt(t *testing.T) { func TestRuntime_UnmarshalBigInt(t *testing.T) { inputFilename := "big_int" - ty := tolkParser.NewIntNType(183) + ty := parser.NewIntNType(183) currCell, err := boc.DeserializeBocHex("b5ee9c7241010101001900002dfffffffffffffffffffffffffffffffffff99bfeac6423a6f0b50c") if err != nil { @@ -77,7 +77,7 @@ func TestRuntime_UnmarshalBigInt(t *testing.T) { func TestRuntime_UnmarshalSmallUInt(t *testing.T) { inputFilename := "small_uint" - ty := tolkParser.NewUIntNType(53) + ty := parser.NewUIntNType(53) currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000900000d00000000001d34e435eafd") if err != nil { @@ -104,7 +104,7 @@ func TestRuntime_UnmarshalSmallUInt(t *testing.T) { func TestRuntime_UnmarshalBigUInt(t *testing.T) { inputFilename := "big_uint" - ty := tolkParser.NewUIntNType(257) + ty := parser.NewUIntNType(257) currCell, err := boc.DeserializeBocHex("b5ee9c7241010101002300004100000000000000000000000000000000000000000000000000009fc4212a38ba40b11cce12") if err != nil { @@ -131,7 +131,7 @@ func TestRuntime_UnmarshalBigUInt(t *testing.T) { func TestRuntime_UnmarshalVarInt(t *testing.T) { inputFilename := "var_int" - ty := tolkParser.NewVarInt16Type() + ty := parser.NewVarInt16Type() currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000600000730c98588449b6923") if err != nil { t.Fatal(err) @@ -157,7 +157,7 @@ func TestRuntime_UnmarshalVarInt(t *testing.T) { func TestRuntime_UnmarshalVarUInt(t *testing.T) { inputFilename := "var_uint" - ty := tolkParser.NewVarUInt32Type() + ty := parser.NewVarUInt32Type() currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000800000b28119ab36b44d3a86c0f") if err != nil { @@ -184,7 +184,7 @@ func TestRuntime_UnmarshalVarUInt(t *testing.T) { func TestRuntime_UnmarshalBits(t *testing.T) { inputFilename := "bits" - ty := tolkParser.NewBitsNType(24) + ty := parser.NewBitsNType(24) currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000500000631323318854035") if err != nil { @@ -211,7 +211,7 @@ func TestRuntime_UnmarshalBits(t *testing.T) { func TestRuntime_UnmarshalCoins(t *testing.T) { inputFilename := "coins" - ty := tolkParser.NewCoinsType() + ty := parser.NewCoinsType() currCell, err := boc.DeserializeBocHex("b5ee9c72410101010007000009436ec6e0189ebbd7f4") if err != nil { @@ -238,7 +238,7 @@ func TestRuntime_UnmarshalCoins(t *testing.T) { func TestRuntime_UnmarshalBool(t *testing.T) { inputFilename := "bool" - ty := tolkParser.NewBoolType() + ty := parser.NewBoolType() currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000300000140f6d24034") if err != nil { @@ -265,7 +265,7 @@ func TestRuntime_UnmarshalBool(t *testing.T) { func TestRuntime_UnmarshalCell(t *testing.T) { inputFilename := "cell" - ty := tolkParser.NewCellType() + ty := parser.NewCellType() currCell, err := boc.DeserializeBocHex("b5ee9c724101020100090001000100080000007ba52a3292") if err != nil { @@ -296,7 +296,7 @@ func TestRuntime_UnmarshalCell(t *testing.T) { func TestRuntime_UnmarshalRemaining(t *testing.T) { inputFilename := "remaining" - ty := tolkParser.NewRemainingType() + ty := parser.NewRemainingType() currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000900000dc0800000000ab8d04726e4") if err != nil { @@ -327,7 +327,7 @@ func TestRuntime_UnmarshalRemaining(t *testing.T) { func TestRuntime_UnmarshalAddress(t *testing.T) { inputFilename := "internal_address" - ty := tolkParser.NewAddressType() + ty := parser.NewAddressType() currCell, err := boc.DeserializeBocHex("b5ee9c7241010101002400004380107bfaaa5cc6e5368e5f9799188bd798cd22e04ab16d1d8ea4fc37480741e6351064a3e1a6") if err != nil { @@ -354,7 +354,7 @@ func TestRuntime_UnmarshalAddress(t *testing.T) { func TestRuntime_UnmarshalNotExitsOptionalAddress(t *testing.T) { inputFilename := "not_exists_optional_address" - ty := tolkParser.NewAddressOptType() + ty := parser.NewAddressOptType() currCell, err := boc.DeserializeBocHex("b5ee9c724101010100030000012094418655") if err != nil { @@ -382,7 +382,7 @@ func TestRuntime_UnmarshalNotExitsOptionalAddress(t *testing.T) { func TestRuntime_UnmarshalExistsOptionalAddress(t *testing.T) { inputFilename := "exists_optional_address" - ty := tolkParser.NewAddressOptType() + ty := parser.NewAddressOptType() currCell, err := boc.DeserializeBocHex("b5ee9c7241010101002400004380107bfaaa5cc6e5368e5f9799188bd798cd22e04ab16d1d8ea4fc37480741e6351064a3e1a6") if err != nil { @@ -410,7 +410,7 @@ func TestRuntime_UnmarshalExistsOptionalAddress(t *testing.T) { func TestRuntime_UnmarshalExternalAddress(t *testing.T) { inputFilename := "external_address" - ty := tolkParser.NewAddressExtType() + ty := parser.NewAddressExtType() currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000600000742082850fcbd94fd") if err != nil { @@ -442,7 +442,7 @@ func TestRuntime_UnmarshalExternalAddress(t *testing.T) { func TestRuntime_UnmarshalAnyNoneAddress(t *testing.T) { inputFilename := "any_none_address" - ty := tolkParser.NewAddressAnyType() + ty := parser.NewAddressAnyType() currCell, err := boc.DeserializeBocHex("b5ee9c724101010100030000012094418655") if err != nil { @@ -469,7 +469,7 @@ func TestRuntime_UnmarshalAnyNoneAddress(t *testing.T) { func TestRuntime_UnmarshalAnyInternalAddress(t *testing.T) { inputFilename := "any_internal_address" - ty := tolkParser.NewAddressAnyType() + ty := parser.NewAddressAnyType() currCell, err := boc.DeserializeBocHex("b5ee9c7241010101002400004380107bfaaa5cc6e5368e5f9799188bd798cd22e04ab16d1d8ea4fc37480741e6351064a3e1a6") if err != nil { @@ -496,7 +496,7 @@ func TestRuntime_UnmarshalAnyInternalAddress(t *testing.T) { func TestRuntime_UnmarshalAnyExternalAddress(t *testing.T) { inputFilename := "any_external_address" - ty := tolkParser.NewAddressAnyType() + ty := parser.NewAddressAnyType() currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000600000742082850fcbd94fd") if err != nil { @@ -528,7 +528,7 @@ func TestRuntime_UnmarshalAnyExternalAddress(t *testing.T) { func TestRuntime_UnmarshalAnyVarAddress(t *testing.T) { inputFilename := "any_var_address" - ty := tolkParser.NewAddressAnyType() + ty := parser.NewAddressAnyType() currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000900000dc0800000000ab8d04726e4") if err != nil { @@ -564,7 +564,7 @@ func TestRuntime_UnmarshalAnyVarAddress(t *testing.T) { func TestRuntime_UnmarshalNotExistsNullable(t *testing.T) { inputFilename := "not_exists_nullable" - ty := tolkParser.NewNullableType(tolkParser.NewRemainingType()) + ty := parser.NewNullableType(parser.NewRemainingType()) currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000300000140f6d24034") if err != nil { @@ -591,7 +591,7 @@ func TestRuntime_UnmarshalNotExistsNullable(t *testing.T) { func TestRuntime_UnmarshalExistsNullable(t *testing.T) { inputFilename := "exists_nullable" - ty := tolkParser.NewNullableType(tolkParser.NewCellType()) + ty := parser.NewNullableType(parser.NewCellType()) currCell, err := boc.DeserializeBocHex("b5ee9c7241010201000b000101c001000900000c0ae007880db9") if err != nil { @@ -629,7 +629,7 @@ func TestRuntime_UnmarshalExistsNullable(t *testing.T) { func TestRuntime_UnmarshalRef(t *testing.T) { inputFilename := "ref" - ty := tolkParser.NewCellOfType(tolkParser.NewIntNType(65)) + ty := parser.NewCellOfType(parser.NewIntNType(65)) currCell, err := boc.DeserializeBocHex("b5ee9c7241010201000e000100010011000000000009689e40e150b4c5") if err != nil { @@ -660,7 +660,7 @@ func TestRuntime_UnmarshalRef(t *testing.T) { func TestRuntime_UnmarshalEmptyTensor(t *testing.T) { inputFilename := "empty_tensor" - ty := tolkParser.NewTensorType() + ty := parser.NewTensorType() currCell, err := boc.DeserializeBocHex("b5ee9c724101010100020000004cacb9cd") if err != nil { @@ -688,15 +688,15 @@ func TestRuntime_UnmarshalEmptyTensor(t *testing.T) { func TestRuntime_UnmarshalTensor(t *testing.T) { inputFilename := "tensor" - ty := tolkParser.NewTensorType( - tolkParser.NewUIntNType(123), - tolkParser.NewBoolType(), - tolkParser.NewCoinsType(), - tolkParser.NewTensorType( - tolkParser.NewIntNType(23), - tolkParser.NewNullableType(tolkParser.NewIntNType(2)), + ty := parser.NewTensorType( + parser.NewUIntNType(123), + parser.NewBoolType(), + parser.NewCoinsType(), + parser.NewTensorType( + parser.NewIntNType(23), + parser.NewNullableType(parser.NewIntNType(2)), ), - tolkParser.NewVarIntType(32), + parser.NewVarIntType(32), ) currCell, err := boc.DeserializeBocHex("b5ee9c7241010101001f00003900000000000000000000000000021cb43b9aca00fffd550bfbaae07401a2a98117") @@ -781,7 +781,7 @@ func TestRuntime_UnmarshalTensor(t *testing.T) { func TestRuntime_UnmarshalIntKeyMap(t *testing.T) { inputFilename := "int_key_map" - ty := tolkParser.NewMapType(tolkParser.NewIntNType(32), tolkParser.NewBoolType()) + ty := parser.NewMapType(parser.NewIntNType(32), parser.NewBoolType()) currCell, err := boc.DeserializeBocHex("b5ee9c7241010201000c000101c001000ba00000007bc09a662c32") if err != nil { @@ -821,7 +821,7 @@ func TestRuntime_UnmarshalIntKeyMap(t *testing.T) { func TestRuntime_UnmarshalUIntKeyMap(t *testing.T) { inputFilename := "uint_key_map" - ty := tolkParser.NewMapType(tolkParser.NewUIntNType(16), tolkParser.NewAddressType()) + ty := parser.NewMapType(parser.NewUIntNType(16), parser.NewAddressType()) currCell, err := boc.DeserializeBocHex("b5ee9c72410104010053000101c0010202cb02030045a7400b113a994b5024a16719f69139328eb759596c38a25f59028b146fecdc3621dfe80045a3cff5555555555555555555555555555555555555555555555555555555555555555888440ce8") if err != nil { @@ -873,7 +873,7 @@ func TestRuntime_UnmarshalUIntKeyMap(t *testing.T) { func TestRuntime_UnmarshalBigIntKeyMap(t *testing.T) { inputFilename := "big_int_key_map" - ty := tolkParser.NewMapType(tolkParser.NewUIntNType(78), tolkParser.NewCellType()) + ty := parser.NewMapType(parser.NewUIntNType(78), parser.NewCellType()) currCell, err := boc.DeserializeBocHex("b5ee9c7241010301001a000101c0010115a70000000000000047550902000b000000001ab01d5bf1a9") if err != nil { @@ -917,13 +917,13 @@ func TestRuntime_UnmarshalBigIntKeyMap(t *testing.T) { func TestRuntime_UnmarshalBitsKeyMap(t *testing.T) { inputFilename := "bits_int_key_map" - ty := tolkParser.NewMapType( - tolkParser.NewBitsNType(16), - tolkParser.NewMapType( - tolkParser.NewIntNType(64), - tolkParser.NewTensorType( - tolkParser.NewAddressType(), - tolkParser.NewCoinsType(), + ty := parser.NewMapType( + parser.NewBitsNType(16), + parser.NewMapType( + parser.NewIntNType(64), + parser.NewTensorType( + parser.NewAddressType(), + parser.NewCoinsType(), ), ), ) @@ -997,7 +997,7 @@ func TestRuntime_UnmarshalBitsKeyMap(t *testing.T) { func TestRuntime_UnmarshalAddressKeyMap(t *testing.T) { inputFilename := "address_key_map" - ty := tolkParser.NewMapType(tolkParser.NewAddressType(), tolkParser.NewCoinsType()) + ty := parser.NewMapType(parser.NewAddressType(), parser.NewCoinsType()) currCell, err := boc.DeserializeBocHex("b5ee9c7241010201002f000101c0010051a17002c44ea652d4092859c67da44e4ca3add6565b0e2897d640a2c51bfb370d8877f9409502f9002016fdc16e") if err != nil { @@ -1046,10 +1046,10 @@ func TestRuntime_UnmarshalAddressKeyMap(t *testing.T) { func TestRuntime_UnmarshalUnionWithDecPrefix(t *testing.T) { jsonInputFilename := "union_with_dec_prefix" - ty := tolkParser.NewUnionType( + ty := parser.NewUnionType( 1, true, - tolkParser.NewUnionVariant(tolkParser.NewIntNType(16), "0"), - tolkParser.NewUnionVariant(tolkParser.NewIntNType(128), "1"), + parser.NewUnionVariant(parser.NewIntNType(16), "0"), + parser.NewUnionVariant(parser.NewIntNType(128), "1"), ) currCell, err := boc.DeserializeBocHex("b5ee9c7241010101001300002180000000000000000000000003b5577dc0660d6029") @@ -1094,17 +1094,17 @@ func TestRuntime_UnmarshalUnionWithBinPrefix(t *testing.T) { t.Fatal(err) } - var abi tolkParser.ABI + var abi parser.ABI err = json.Unmarshal(data, &abi) if err != nil { t.Fatal(err) } - ty := tolkParser.NewUnionType( + ty := parser.NewUnionType( 3, false, - tolkParser.NewUnionVariant(tolkParser.NewStructType("AddressWithPrefix"), "0b001"), - tolkParser.NewUnionVariant(tolkParser.NewStructType("MapWithPrefix"), "0b011"), - tolkParser.NewUnionVariant(tolkParser.NewStructType("CellWithPrefix"), "0b111"), + parser.NewUnionVariant(parser.NewStructType("AddressWithPrefix"), "0b001"), + parser.NewUnionVariant(parser.NewStructType("MapWithPrefix"), "0b011"), + parser.NewUnionVariant(parser.NewStructType("CellWithPrefix"), "0b111"), ) currCell, err := boc.DeserializeBocHex("b5ee9c7241010201002e0001017801004fa17002c44ea652d4092859c67da44e4ca3add6565b0e2897d640a2c51bfb370d8877f900a4d89920c413c650") @@ -1174,17 +1174,17 @@ func TestRuntime_UnmarshalUnionWithHexPrefix(t *testing.T) { t.Fatal(err) } - var abi tolkParser.ABI + var abi parser.ABI err = json.Unmarshal(data, &abi) if err != nil { t.Fatal(err) } - ty := tolkParser.NewUnionType( + ty := parser.NewUnionType( 32, false, - tolkParser.NewUnionVariant(tolkParser.NewStructType("UInt66WithPrefix"), "0x12345678"), - tolkParser.NewUnionVariant(tolkParser.NewStructType("UInt33WithPrefix"), "0xdeadbeef"), - tolkParser.NewUnionVariant(tolkParser.NewStructType("UInt4WithPrefix"), "0x89abcdef"), + parser.NewUnionVariant(parser.NewStructType("UInt66WithPrefix"), "0x12345678"), + parser.NewUnionVariant(parser.NewStructType("UInt33WithPrefix"), "0xdeadbeef"), + parser.NewUnionVariant(parser.NewStructType("UInt4WithPrefix"), "0x89abcdef"), ) currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000b000011deadbeef00000000c0d75977b9") @@ -1242,13 +1242,13 @@ func TestRuntime_UnmarshalALotRefsFromAlias(t *testing.T) { t.Fatal(err) } - var abi tolkParser.ABI + var abi parser.ABI err = json.Unmarshal(data, &abi) if err != nil { t.Fatal(err) } - ty := tolkParser.NewAliasType("GoodNamingForMsg") + ty := parser.NewAliasType("GoodNamingForMsg") currCell, err := boc.DeserializeBocHex("b5ee9c724101040100b7000377deadbeef80107bfaaa5cc6e5368e5f9799188bd798cd22e04ab16d1d8ea4fc37480741e635087735940143ffffffffffffffffffffffffffff63c006010203004b80010df454cebee868f611ba8c0d4a9371fb73105396505783293a7625f75db3b9880bebc20100438006e05909e22b2e5e6087533314ee56505f85212914bd5547941a2a658ac62fe101004f801622753296a04942ce33ed2272651d6eb2b2d87144beb2051628dfd9b86c43bfcc12309ce54001e09a48b8") if err != nil { @@ -1507,13 +1507,13 @@ func TestRuntime_UnmarshalALotRefsFromStruct(t *testing.T) { t.Fatal(err) } - var abi tolkParser.ABI + var abi parser.ABI err = json.Unmarshal(data, &abi) if err != nil { t.Fatal(err) } - ty := tolkParser.NewStructType("ManyRefsMsg") + ty := parser.NewStructType("ManyRefsMsg") currCell, err := boc.DeserializeBocHex("b5ee9c724101040100b7000377deadbeef80107bfaaa5cc6e5368e5f9799188bd798cd22e04ab16d1d8ea4fc37480741e635087735940143ffffffffffffffffffffffffffff63c006010203004b80010df454cebee868f611ba8c0d4a9371fb73105396505783293a7625f75db3b9880bebc20100438006e05909e22b2e5e6087533314ee56505f85212914bd5547941a2a658ac62fe101004f801622753296a04942ce33ed2272651d6eb2b2d87144beb2051628dfd9b86c43bfcc12309ce54001e09a48b8") if err != nil { @@ -1768,13 +1768,13 @@ func TestRuntime_UnmarshalALotGenericsFromStruct(t *testing.T) { t.Fatal(err) } - var abi tolkParser.ABI + var abi parser.ABI err = json.Unmarshal(data, &abi) if err != nil { t.Fatal(err) } - ty := tolkParser.NewStructType("ManyRefsMsg", tolkParser.NewUIntNType(16)) + ty := parser.NewStructType("ManyRefsMsg", parser.NewUIntNType(16)) currCell, err := boc.DeserializeBocHex("b5ee9c72410103010043000217d017d7840343b9aca0000108010200080000007b005543b9aca001017d78402005889d4ca5a81250b38cfb489c99475bacacb61c512fac81458a37f66e1b10eff422fc7647") if err != nil { @@ -2010,13 +2010,13 @@ func TestRuntime_UnmarshalALotGenericsFromAlias(t *testing.T) { t.Fatal(err) } - var abi tolkParser.ABI + var abi parser.ABI err = json.Unmarshal(data, &abi) if err != nil { t.Fatal(err) } - ty := tolkParser.NewAliasType("GoodNamingForMsg", tolkParser.NewUIntNType(16)) + ty := parser.NewAliasType("GoodNamingForMsg", parser.NewUIntNType(16)) currCell, err := boc.DeserializeBocHex("b5ee9c72410103010043000217d017d7840343b9aca0000108010200080000007b005543b9aca001017d78402005889d4ca5a81250b38cfb489c99475bacacb61c512fac81458a37f66e1b10eff422fc7647") if err != nil { @@ -2256,13 +2256,13 @@ func TestRuntime_UnmarshalStructWithDefaultValues(t *testing.T) { t.Fatal(err) } - var abi tolkParser.ABI + var abi parser.ABI err = json.Unmarshal(data, &abi) if err != nil { t.Fatal(err) } - ty := tolkParser.NewStructType("DefaultTest") + ty := parser.NewStructType("DefaultTest") currCell, err := boc.DeserializeBocHex("b5ee9c7241010101003100005d80000002414801622753296a04942ce33ed2272651d6eb2b2d87144beb2051628dfd9b86c43bfd00000156ac2c4c70811a9dde") if err != nil { @@ -2432,13 +2432,13 @@ func TestRuntime_UnmarshalALotNumbers(t *testing.T) { t.Fatal(err) } - var abi tolkParser.ABI + var abi parser.ABI err = json.Unmarshal(data, &abi) if err != nil { t.Fatal(err) } - ty := tolkParser.NewStructType("Numbers") + ty := parser.NewStructType("Numbers") currCell, err := boc.DeserializeBocHex("b5ee9c72410101010033000062000000000000000000000000000000000000000000000000000000000000000000000000000000f1106aecc4c800020926dc62f014") if err != nil { @@ -2556,13 +2556,13 @@ func TestRuntime_UnmarshalALotRandomFields(t *testing.T) { t.Fatal(err) } - var abi tolkParser.ABI + var abi parser.ABI err = json.Unmarshal(data, &abi) if err != nil { t.Fatal(err) } - ty := tolkParser.NewStructType("RandomFields") + ty := parser.NewStructType("RandomFields") currCell, err := boc.DeserializeBocHex("b5ee9c7241010301007800028b79480107bfaaa5cc6e5368e5f9799188bd798cd22e04ab16d1d8ea4fc37480741e6350e038d7eb37c5e80000000ab50ee6b28000000000000016e4c000006c175300001801bc01020001c00051000000000005120041efeaa9731b94da397e5e64622f5e63348b812ac5b4763a93f0dd201d0798d4409e337ceb") if err != nil { @@ -2783,13 +2783,13 @@ func TestRuntime_UnmarshalAliasWithCustomUnpack(t *testing.T) { t.Fatal(err) } - var abi tolkParser.ABI + var abi parser.ABI err = json.Unmarshal(data, &abi) if err != nil { t.Fatal(err) } - ty := tolkParser.NewAliasType("MyAlias") + ty := parser.NewAliasType("MyAlias") currCell, err := boc.DeserializeBocHex("b5ee9c724101010100470000890000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000043b9aca00886e91196") if err != nil { @@ -2800,12 +2800,12 @@ func TestRuntime_UnmarshalAliasWithCustomUnpack(t *testing.T) { if err != nil { t.Fatal(err) } - decoder.WithCustomUnpackResolver(func(alias tolkParser.AliasRef, cell *boc.Cell, value *AliasValue) error { + decoder.WithCustomUnpackResolver(func(alias parser.AliasRef, cell *boc.Cell, value *AliasValue) error { err := cell.Skip(512) if err != nil { return fmt.Errorf("failed to 512 bits from alias") } - val, err := decoder.Unmarshal(cell, tolkParser.NewStructType("My")) + val, err := decoder.Unmarshal(cell, parser.NewStructType("My")) if err != nil { return fmt.Errorf("failed to unmarshal alias' coins") } @@ -2841,7 +2841,7 @@ func TestRuntime_UnmarshalAliasWithCustomUnpack(t *testing.T) { } func TestRuntime_MarshalSmallInt(t *testing.T) { - ty := tolkParser.NewIntNType(24) + ty := parser.NewIntNType(24) currCell, err := boc.DeserializeBocHex("b5ee9c72410101010005000006ff76c41616db06") if err != nil { @@ -2872,7 +2872,7 @@ func TestRuntime_MarshalSmallInt(t *testing.T) { } func TestRuntime_MarshalSmallUInt(t *testing.T) { - ty := tolkParser.NewUIntNType(53) + ty := parser.NewUIntNType(53) currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000900000d00000000001d34e435eafd") if err != nil { @@ -2903,7 +2903,7 @@ func TestRuntime_MarshalSmallUInt(t *testing.T) { } func TestRuntime_MarshalBigInt(t *testing.T) { - ty := tolkParser.NewIntNType(183) + ty := parser.NewIntNType(183) currCell, err := boc.DeserializeBocHex("b5ee9c7241010101001900002dfffffffffffffffffffffffffffffffffff99bfeac6423a6f0b50c") if err != nil { @@ -2934,7 +2934,7 @@ func TestRuntime_MarshalBigInt(t *testing.T) { } func TestRuntime_MarshalBigUInt(t *testing.T) { - ty := tolkParser.NewUIntNType(257) + ty := parser.NewUIntNType(257) currCell, err := boc.DeserializeBocHex("b5ee9c7241010101002300004100000000000000000000000000000000000000000000000000009fc4212a38ba40b11cce12") if err != nil { @@ -2965,7 +2965,7 @@ func TestRuntime_MarshalBigUInt(t *testing.T) { } func TestRuntime_MarshalVarInt(t *testing.T) { - ty := tolkParser.NewVarInt16Type() + ty := parser.NewVarInt16Type() currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000600000730c98588449b6923") if err != nil { @@ -2996,7 +2996,7 @@ func TestRuntime_MarshalVarInt(t *testing.T) { } func TestRuntime_MarshalVarUInt(t *testing.T) { - ty := tolkParser.NewVarUInt32Type() + ty := parser.NewVarUInt32Type() currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000800000b28119ab36b44d3a86c0f") if err != nil { @@ -3027,7 +3027,7 @@ func TestRuntime_MarshalVarUInt(t *testing.T) { } func TestRuntime_MarshalBits(t *testing.T) { - ty := tolkParser.NewBitsNType(24) + ty := parser.NewBitsNType(24) currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000500000631323318854035") if err != nil { @@ -3058,7 +3058,7 @@ func TestRuntime_MarshalBits(t *testing.T) { } func TestRuntime_MarshalCoins(t *testing.T) { - ty := tolkParser.NewCoinsType() + ty := parser.NewCoinsType() currCell, err := boc.DeserializeBocHex("b5ee9c72410101010007000009436ec6e0189ebbd7f4") if err != nil { @@ -3089,7 +3089,7 @@ func TestRuntime_MarshalCoins(t *testing.T) { } func TestRuntime_MarshalBool(t *testing.T) { - ty := tolkParser.NewBoolType() + ty := parser.NewBoolType() currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000300000140f6d24034") if err != nil { @@ -3120,7 +3120,7 @@ func TestRuntime_MarshalBool(t *testing.T) { } func TestRuntime_MarshalCell(t *testing.T) { - ty := tolkParser.NewCellType() + ty := parser.NewCellType() currCell, err := boc.DeserializeBocHex("b5ee9c724101020100090001000100080000007ba52a3292") if err != nil { @@ -3151,7 +3151,7 @@ func TestRuntime_MarshalCell(t *testing.T) { } func TestRuntime_MarshalRemaining(t *testing.T) { - ty := tolkParser.NewRemainingType() + ty := parser.NewRemainingType() currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000900000dc0800000000ab8d04726e4") if err != nil { @@ -3182,7 +3182,7 @@ func TestRuntime_MarshalRemaining(t *testing.T) { } func TestRuntime_MarshalAddress(t *testing.T) { - ty := tolkParser.NewAddressType() + ty := parser.NewAddressType() currCell, err := boc.DeserializeBocHex("b5ee9c7241010101002400004380107bfaaa5cc6e5368e5f9799188bd798cd22e04ab16d1d8ea4fc37480741e6351064a3e1a6") if err != nil { @@ -3213,7 +3213,7 @@ func TestRuntime_MarshalAddress(t *testing.T) { } func TestRuntime_MarshalNotExitsOptionalAddress(t *testing.T) { - ty := tolkParser.NewAddressOptType() + ty := parser.NewAddressOptType() currCell, err := boc.DeserializeBocHex("b5ee9c724101010100030000012094418655") if err != nil { @@ -3244,7 +3244,7 @@ func TestRuntime_MarshalNotExitsOptionalAddress(t *testing.T) { } func TestRuntime_MarshalExistsOptionalAddress(t *testing.T) { - ty := tolkParser.NewAddressOptType() + ty := parser.NewAddressOptType() currCell, err := boc.DeserializeBocHex("b5ee9c7241010101002400004380107bfaaa5cc6e5368e5f9799188bd798cd22e04ab16d1d8ea4fc37480741e6351064a3e1a6") if err != nil { @@ -3275,7 +3275,7 @@ func TestRuntime_MarshalExistsOptionalAddress(t *testing.T) { } func TestRuntime_MarshalExternalAddress(t *testing.T) { - ty := tolkParser.NewAddressExtType() + ty := parser.NewAddressExtType() currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000600000742082850fcbd94fd") if err != nil { @@ -3306,7 +3306,7 @@ func TestRuntime_MarshalExternalAddress(t *testing.T) { } func TestRuntime_MarshalAnyNoneAddress(t *testing.T) { - ty := tolkParser.NewAddressAnyType() + ty := parser.NewAddressAnyType() currCell, err := boc.DeserializeBocHex("b5ee9c724101010100030000012094418655") if err != nil { @@ -3337,7 +3337,7 @@ func TestRuntime_MarshalAnyNoneAddress(t *testing.T) { } func TestRuntime_MarshalAnyInternalAddress(t *testing.T) { - ty := tolkParser.NewAddressAnyType() + ty := parser.NewAddressAnyType() currCell, err := boc.DeserializeBocHex("b5ee9c7241010101002400004380107bfaaa5cc6e5368e5f9799188bd798cd22e04ab16d1d8ea4fc37480741e6351064a3e1a6") if err != nil { @@ -3368,7 +3368,7 @@ func TestRuntime_MarshalAnyInternalAddress(t *testing.T) { } func TestRuntime_MarshalAnyExternalAddress(t *testing.T) { - ty := tolkParser.NewAddressAnyType() + ty := parser.NewAddressAnyType() currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000600000742082850fcbd94fd") if err != nil { @@ -3399,7 +3399,7 @@ func TestRuntime_MarshalAnyExternalAddress(t *testing.T) { } func TestRuntime_MarshalAnyVarAddress(t *testing.T) { - ty := tolkParser.NewAddressAnyType() + ty := parser.NewAddressAnyType() currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000900000dc0800000000ab8d04726e4") if err != nil { @@ -3430,7 +3430,7 @@ func TestRuntime_MarshalAnyVarAddress(t *testing.T) { } func TestRuntime_MarshalNotExistsNullable(t *testing.T) { - ty := tolkParser.NewNullableType(tolkParser.NewRemainingType()) + ty := parser.NewNullableType(parser.NewRemainingType()) currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000300000140f6d24034") if err != nil { @@ -3461,7 +3461,7 @@ func TestRuntime_MarshalNotExistsNullable(t *testing.T) { } func TestRuntime_MarshalExistsNullable(t *testing.T) { - ty := tolkParser.NewNullableType(tolkParser.NewCellType()) + ty := parser.NewNullableType(parser.NewCellType()) currCell, err := boc.DeserializeBocHex("b5ee9c7241010201000b000101c001000900000c0ae007880db9") if err != nil { @@ -3492,7 +3492,7 @@ func TestRuntime_MarshalExistsNullable(t *testing.T) { } func TestRuntime_MarshalRef(t *testing.T) { - ty := tolkParser.NewCellOfType(tolkParser.NewIntNType(65)) + ty := parser.NewCellOfType(parser.NewIntNType(65)) currCell, err := boc.DeserializeBocHex("b5ee9c7241010201000e000100010011000000000009689e40e150b4c5") if err != nil { @@ -3523,7 +3523,7 @@ func TestRuntime_MarshalRef(t *testing.T) { } func TestRuntime_MarshalEmptyTensor(t *testing.T) { - ty := tolkParser.NewTensorType() + ty := parser.NewTensorType() currCell, err := boc.DeserializeBocHex("b5ee9c724101010100020000004cacb9cd") if err != nil { @@ -3554,15 +3554,15 @@ func TestRuntime_MarshalEmptyTensor(t *testing.T) { } func TestRuntime_MarshalTensor(t *testing.T) { - ty := tolkParser.NewTensorType( - tolkParser.NewUIntNType(123), - tolkParser.NewBoolType(), - tolkParser.NewCoinsType(), - tolkParser.NewTensorType( - tolkParser.NewIntNType(23), - tolkParser.NewNullableType(tolkParser.NewIntNType(2)), + ty := parser.NewTensorType( + parser.NewUIntNType(123), + parser.NewBoolType(), + parser.NewCoinsType(), + parser.NewTensorType( + parser.NewIntNType(23), + parser.NewNullableType(parser.NewIntNType(2)), ), - tolkParser.NewVarIntType(32), + parser.NewVarIntType(32), ) currCell, err := boc.DeserializeBocHex("b5ee9c7241010101001f00003900000000000000000000000000021cb43b9aca00fffd550bfbaae07401a2a98117") @@ -3594,7 +3594,7 @@ func TestRuntime_MarshalTensor(t *testing.T) { } func TestRuntime_MarshalIntKeyMap(t *testing.T) { - ty := tolkParser.NewMapType(tolkParser.NewIntNType(32), tolkParser.NewBoolType()) + ty := parser.NewMapType(parser.NewIntNType(32), parser.NewBoolType()) currCell, err := boc.DeserializeBocHex("b5ee9c7241010201000c000101c001000ba00000007bc09a662c32") if err != nil { @@ -3625,7 +3625,7 @@ func TestRuntime_MarshalIntKeyMap(t *testing.T) { } func TestRuntime_MarshalUIntKeyMap(t *testing.T) { - ty := tolkParser.NewMapType(tolkParser.NewUIntNType(16), tolkParser.NewAddressType()) + ty := parser.NewMapType(parser.NewUIntNType(16), parser.NewAddressType()) currCell, err := boc.DeserializeBocHex("b5ee9c72410104010053000101c0010202cb02030045a7400b113a994b5024a16719f69139328eb759596c38a25f59028b146fecdc3621dfe80045a3cff5555555555555555555555555555555555555555555555555555555555555555888440ce8") if err != nil { @@ -3656,7 +3656,7 @@ func TestRuntime_MarshalUIntKeyMap(t *testing.T) { } func TestRuntime_MarshalBigIntKeyMap(t *testing.T) { - ty := tolkParser.NewMapType(tolkParser.NewUIntNType(78), tolkParser.NewCellType()) + ty := parser.NewMapType(parser.NewUIntNType(78), parser.NewCellType()) currCell, err := boc.DeserializeBocHex("b5ee9c7241010301001a000101c0010115a70000000000000047550902000b000000001ab01d5bf1a9") if err != nil { @@ -3687,13 +3687,13 @@ func TestRuntime_MarshalBigIntKeyMap(t *testing.T) { } func TestRuntime_MarshalBitsKeyMap(t *testing.T) { - ty := tolkParser.NewMapType( - tolkParser.NewBitsNType(16), - tolkParser.NewMapType( - tolkParser.NewIntNType(64), - tolkParser.NewTensorType( - tolkParser.NewAddressType(), - tolkParser.NewCoinsType(), + ty := parser.NewMapType( + parser.NewBitsNType(16), + parser.NewMapType( + parser.NewIntNType(64), + parser.NewTensorType( + parser.NewAddressType(), + parser.NewCoinsType(), ), ), ) @@ -3727,7 +3727,7 @@ func TestRuntime_MarshalBitsKeyMap(t *testing.T) { } func TestRuntime_MarshalAddressKeyMap(t *testing.T) { - ty := tolkParser.NewMapType(tolkParser.NewAddressType(), tolkParser.NewCoinsType()) + ty := parser.NewMapType(parser.NewAddressType(), parser.NewCoinsType()) currCell, err := boc.DeserializeBocHex("b5ee9c7241010201002f000101c0010051a17002c44ea652d4092859c67da44e4ca3add6565b0e2897d640a2c51bfb370d8877f9409502f9002016fdc16e") if err != nil { @@ -3758,10 +3758,10 @@ func TestRuntime_MarshalAddressKeyMap(t *testing.T) { } func TestRuntime_MarshalUnionWithDecPrefix(t *testing.T) { - ty := tolkParser.NewUnionType( + ty := parser.NewUnionType( 1, true, - tolkParser.NewUnionVariant(tolkParser.NewIntNType(16), "0"), - tolkParser.NewUnionVariant(tolkParser.NewIntNType(128), "1"), + parser.NewUnionVariant(parser.NewIntNType(16), "0"), + parser.NewUnionVariant(parser.NewIntNType(128), "1"), ) currCell, err := boc.DeserializeBocHex("b5ee9c7241010101001300002180000000000000000000000003b5577dc0660d6029") @@ -3799,17 +3799,17 @@ func TestRuntime_MarshalUnionWithBinPrefix(t *testing.T) { t.Fatal(err) } - var abi tolkParser.ABI + var abi parser.ABI err = json.Unmarshal(data, &abi) if err != nil { t.Fatal(err) } - ty := tolkParser.NewUnionType( + ty := parser.NewUnionType( 3, false, - tolkParser.NewUnionVariant(tolkParser.NewStructType("AddressWithPrefix"), "0b001"), - tolkParser.NewUnionVariant(tolkParser.NewStructType("MapWithPrefix"), "0b011"), - tolkParser.NewUnionVariant(tolkParser.NewStructType("CellWithPrefix"), "0b111"), + parser.NewUnionVariant(parser.NewStructType("AddressWithPrefix"), "0b001"), + parser.NewUnionVariant(parser.NewStructType("MapWithPrefix"), "0b011"), + parser.NewUnionVariant(parser.NewStructType("CellWithPrefix"), "0b111"), ) currCell, err := boc.DeserializeBocHex("b5ee9c7241010201002e0001017801004fa17002c44ea652d4092859c67da44e4ca3add6565b0e2897d640a2c51bfb370d8877f900a4d89920c413c650") @@ -3857,17 +3857,17 @@ func TestRuntime_MarshalUnionWithHexPrefix(t *testing.T) { t.Fatal(err) } - var abi tolkParser.ABI + var abi parser.ABI err = json.Unmarshal(data, &abi) if err != nil { t.Fatal(err) } - ty := tolkParser.NewUnionType( + ty := parser.NewUnionType( 32, false, - tolkParser.NewUnionVariant(tolkParser.NewStructType("UInt66WithPrefix"), "0x12345678"), - tolkParser.NewUnionVariant(tolkParser.NewStructType("UInt33WithPrefix"), "0xdeadbeef"), - tolkParser.NewUnionVariant(tolkParser.NewStructType("UInt4WithPrefix"), "0x89abcdef"), + parser.NewUnionVariant(parser.NewStructType("UInt66WithPrefix"), "0x12345678"), + parser.NewUnionVariant(parser.NewStructType("UInt33WithPrefix"), "0xdeadbeef"), + parser.NewUnionVariant(parser.NewStructType("UInt4WithPrefix"), "0x89abcdef"), ) currCell, err := boc.DeserializeBocHex("b5ee9c7241010101000b000011deadbeef00000000c0d75977b9") @@ -3915,13 +3915,13 @@ func TestRuntime_MarshalALotRefsFromAlias(t *testing.T) { t.Fatal(err) } - var abi tolkParser.ABI + var abi parser.ABI err = json.Unmarshal(data, &abi) if err != nil { t.Fatal(err) } - ty := tolkParser.NewAliasType("GoodNamingForMsg") + ty := parser.NewAliasType("GoodNamingForMsg") currCell, err := boc.DeserializeBocHex("b5ee9c724101040100b7000377deadbeef80107bfaaa5cc6e5368e5f9799188bd798cd22e04ab16d1d8ea4fc37480741e635087735940143ffffffffffffffffffffffffffff63c006010203004b80010df454cebee868f611ba8c0d4a9371fb73105396505783293a7625f75db3b9880bebc20100438006e05909e22b2e5e6087533314ee56505f85212914bd5547941a2a658ac62fe101004f801622753296a04942ce33ed2272651d6eb2b2d87144beb2051628dfd9b86c43bfcc12309ce54001e09a48b8") if err != nil { @@ -3974,12 +3974,12 @@ func TestRuntime_MarshalALotRefsFromStruct(t *testing.T) { t.Fatal(err) } - var abi tolkParser.ABI + var abi parser.ABI err = json.Unmarshal(data, &abi) if err != nil { t.Fatal(err) } - ty := tolkParser.NewStructType("ManyRefsMsg") + ty := parser.NewStructType("ManyRefsMsg") currCell, err := boc.DeserializeBocHex("b5ee9c724101040100b7000377deadbeef80107bfaaa5cc6e5368e5f9799188bd798cd22e04ab16d1d8ea4fc37480741e635087735940143ffffffffffffffffffffffffffff63c006010203004b80010df454cebee868f611ba8c0d4a9371fb73105396505783293a7625f75db3b9880bebc20100438006e05909e22b2e5e6087533314ee56505f85212914bd5547941a2a658ac62fe101004f801622753296a04942ce33ed2272651d6eb2b2d87144beb2051628dfd9b86c43bfcc12309ce54001e09a48b8") if err != nil { @@ -4026,13 +4026,13 @@ func TestRuntime_MarshalALotGenericsFromStruct(t *testing.T) { t.Fatal(err) } - var abi tolkParser.ABI + var abi parser.ABI err = json.Unmarshal(data, &abi) if err != nil { t.Fatal(err) } - ty := tolkParser.NewStructType("ManyRefsMsg", tolkParser.NewUIntNType(16)) + ty := parser.NewStructType("ManyRefsMsg", parser.NewUIntNType(16)) currCell, err := boc.DeserializeBocHex("b5ee9c72410103010043000217d017d7840343b9aca0000108010200080000007b005543b9aca001017d78402005889d4ca5a81250b38cfb489c99475bacacb61c512fac81458a37f66e1b10eff422fc7647") if err != nil { @@ -4079,13 +4079,13 @@ func TestRuntime_MarshalALotGenericsFromAlias(t *testing.T) { t.Fatal(err) } - var abi tolkParser.ABI + var abi parser.ABI err = json.Unmarshal(data, &abi) if err != nil { t.Fatal(err) } - ty := tolkParser.NewAliasType("GoodNamingForMsg", tolkParser.NewUIntNType(16)) + ty := parser.NewAliasType("GoodNamingForMsg", parser.NewUIntNType(16)) currCell, err := boc.DeserializeBocHex("b5ee9c72410103010043000217d017d7840343b9aca0000108010200080000007b005543b9aca001017d78402005889d4ca5a81250b38cfb489c99475bacacb61c512fac81458a37f66e1b10eff422fc7647") if err != nil { @@ -4132,13 +4132,13 @@ func TestRuntime_MarshalStructWithDefaultValues(t *testing.T) { t.Fatal(err) } - var abi tolkParser.ABI + var abi parser.ABI err = json.Unmarshal(data, &abi) if err != nil { t.Fatal(err) } - ty := tolkParser.NewStructType("DefaultTest") + ty := parser.NewStructType("DefaultTest") currCell, err := boc.DeserializeBocHex("b5ee9c7241010101003100005d80000002414801622753296a04942ce33ed2272651d6eb2b2d87144beb2051628dfd9b86c43bfd00000156ac2c4c70811a9dde") if err != nil { @@ -4185,13 +4185,13 @@ func TestRuntime_MarshalALotNumbers(t *testing.T) { t.Fatal(err) } - var abi tolkParser.ABI + var abi parser.ABI err = json.Unmarshal(data, &abi) if err != nil { t.Fatal(err) } - ty := tolkParser.NewStructType("Numbers") + ty := parser.NewStructType("Numbers") currCell, err := boc.DeserializeBocHex("b5ee9c72410101010033000062000000000000000000000000000000000000000000000000000000000000000000000000000000f1106aecc4c800020926dc62f014") if err != nil { @@ -4238,13 +4238,13 @@ func TestRuntime_MarshalALotRandomFields(t *testing.T) { t.Fatal(err) } - var abi tolkParser.ABI + var abi parser.ABI err = json.Unmarshal(data, &abi) if err != nil { t.Fatal(err) } - ty := tolkParser.NewStructType("RandomFields") + ty := parser.NewStructType("RandomFields") currCell, err := boc.DeserializeBocHex("b5ee9c7241010301007800028b79480107bfaaa5cc6e5368e5f9799188bd798cd22e04ab16d1d8ea4fc37480741e6350e038d7eb37c5e80000000ab50ee6b28000000000000016e4c000006c175300001801bc01020001c00051000000000005120041efeaa9731b94da397e5e64622f5e63348b812ac5b4763a93f0dd201d0798d4409e337ceb") if err != nil { @@ -4291,13 +4291,13 @@ func TestRuntime_MarshalAliasWithCustomUnpack(t *testing.T) { t.Fatal(err) } - var abi tolkParser.ABI + var abi parser.ABI err = json.Unmarshal(data, &abi) if err != nil { t.Fatal(err) } - ty := tolkParser.NewAliasType("MyAlias") + ty := parser.NewAliasType("MyAlias") currCell, err := boc.DeserializeBocHex("b5ee9c724101010100470000890000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000043b9aca00886e91196") if err != nil { @@ -4308,12 +4308,12 @@ func TestRuntime_MarshalAliasWithCustomUnpack(t *testing.T) { if err != nil { t.Fatal(err) } - decoder.WithCustomUnpackResolver(func(alias tolkParser.AliasRef, cell *boc.Cell, value *AliasValue) error { + decoder.WithCustomUnpackResolver(func(alias parser.AliasRef, cell *boc.Cell, value *AliasValue) error { err := cell.Skip(512) if err != nil { return fmt.Errorf("failed to 512 bits from alias") } - val, err := decoder.Unmarshal(cell, tolkParser.NewStructType("My")) + val, err := decoder.Unmarshal(cell, parser.NewStructType("My")) if err != nil { return fmt.Errorf("failed to unmarshal alias' coins") } @@ -4330,7 +4330,7 @@ func TestRuntime_MarshalAliasWithCustomUnpack(t *testing.T) { if err != nil { t.Fatal(err) } - encoder.WithCustomPackResolver(func(ref tolkParser.AliasRef, cell *boc.Cell, value *AliasValue) error { + encoder.WithCustomPackResolver(func(ref parser.AliasRef, cell *boc.Cell, value *AliasValue) error { err := cell.WriteUint(0, 256) if err != nil { return fmt.Errorf("failed to write 256 bits to alias") @@ -4340,7 +4340,7 @@ func TestRuntime_MarshalAliasWithCustomUnpack(t *testing.T) { return fmt.Errorf("failed to write 256 bits to alias again") } val := Value(*value) - cl, err := encoder.Marshal(&val, tolkParser.NewStructType("My")) + cl, err := encoder.Marshal(&val, parser.NewStructType("My")) if err != nil { return fmt.Errorf("failed to marshal alias' coins") } diff --git a/tolk/testdata/jetton_transfer.json b/tolk/testdata/jetton_transfer.json new file mode 100644 index 00000000..56311fca --- /dev/null +++ b/tolk/testdata/jetton_transfer.json @@ -0,0 +1,75 @@ +{ + "contractName": "Jetton", + "declarations": [ + { + "kind": "Struct", + "name": "Transfer", + "prefix": { + "prefixStr": "0x0f8a7ea5", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "amount", + "ty": { + "kind": "coins" + } + }, + { + "name": "destination", + "ty": { + "kind": "address" + } + }, + { + "name": "responseDestination", + "ty": { + "kind": "address" + } + }, + { + "name": "customPayload", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cell" + } + } + }, + { + "name": "forwardAmount", + "ty": { + "kind": "coins" + } + }, + { + "name": "forwardPayload", + "isPayload": true, + "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/tolk/testdata/payloads.json b/tolk/testdata/payloads.json new file mode 100644 index 00000000..7ed9eff4 --- /dev/null +++ b/tolk/testdata/payloads.json @@ -0,0 +1,2421 @@ +{ + "contractName": "Payloads", + "declarations": [ + { + "kind": "Struct", + "name": "CoffeeStakingLockJettonPayload", + "prefix": { + "prefixStr": "0x0c0ffede", + "prefixLen": 32 + }, + "fields": [ + { + "name": "periodID", + "ty": { + "kind": "uintN", + "n": 32 + } + } + ] + }, + { + "kind": "Struct", + "name": "TextCommentJettonPayload", + "prefix": { + "prefixStr": "0x00000000", + "prefixLen": 32 + }, + "fields": [ + { + "name": "text", + "ty": { + "kind": "slice" + } + } + ] + }, + { + "kind": "Struct", + "name": "TegroJettonSwapJettonPayload", + "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": "EncryptedTextCommentJettonPayload", + "prefix": { + "prefixStr": "0x2167da4b", + "prefixLen": 32 + }, + "fields": [ + { + "name": "cipherText", + "ty": { + "kind": "slice" + } + } + ] + }, + { + "kind": "Struct", + "name": "StonfiSwapJettonPayload", + "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": "TegroAddLiquidityJettonPayload", + "prefix": { + "prefixStr": "0x287e167a", + "prefixLen": 32 + }, + "fields": [ + { + "name": "amountA", + "ty": { + "kind": "coins" + } + }, + { + "name": "amountB", + "ty": { + "kind": "coins" + } + } + ] + }, + { + "kind": "Struct", + "name": "StonfiProvideLpV2JettonPayload", + "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": "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" + } + } + } + ] + }, + { + "kind": "Struct", + "name": "BidaskProvideBothJettonPayload", + "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": "DedustDepositLiquidityJettonPayload", + "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": "PoolFundAccountJettonPayload", + "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": "StonfiSwapOkRefJettonPayload", + "prefix": { + "prefixStr": "0x45078540", + "prefixLen": 32 + }, + "fields": [] + }, + { + "kind": "Struct", + "name": "CoffeeCrossDexResendJettonPayload", + "prefix": { + "prefixStr": "0x4ee9b106", + "prefixLen": 32 + }, + "fields": [ + { + "name": "next", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cell" + } + } + } + ] + }, + { + "kind": "Struct", + "name": "BidaskDammProvideJettonPayload", + "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": "StonfiSwapV2JettonPayload", + "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" + } + } + } + ] + }, + { + "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" + } + } + ] + }, + { + "kind": "Struct", + "name": "BidaskDammProvideOneSideJettonPayload", + "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": "StormDepositJettonJettonPayload", + "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": "InvoicePayloadJettonPayload", + "prefix": { + "prefixStr": "0x7aa23eb5", + "prefixLen": 32 + }, + "fields": [ + { + "name": "id", + "ty": { + "kind": "bitsN", + "n": 128 + } + }, + { + "name": "url", + "ty": { + "kind": "AliasRef", + "aliasName": "InvoiceUrl" + } + } + ] + }, + { + "kind": "Struct", + "name": "TonkeeperRelayerFeeJettonPayload", + "prefix": { + "prefixStr": "0x878da6e3", + "prefixLen": 32 + }, + "fields": [] + }, + { + "kind": "Struct", + "name": "AdditionalData", + "fields": [ + { + "name": "fromAddress", + "ty": { + "kind": "address" + } + }, + { + "name": "refAddress", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "BidaskSwapV2JettonPayload", + "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": "MoonBoostPoolJettonPayload", + "prefix": { + "prefixStr": "0x96aa1586", + "prefixLen": 32 + }, + "fields": [] + }, + { + "kind": "Struct", + "name": "BidaskProvideJettonPayload", + "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": "MoonFillOrderJettonPayload", + "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": "BidaskDammProvideBothJettonPayload", + "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": "MoonDepositLiquidityJettonPayload", + "prefix": { + "prefixStr": "0xb31db781", + "prefixLen": 32 + }, + "fields": [ + { + "name": "minLpOut", + "ty": { + "kind": "coins" + } + } + ] + }, + { + "kind": "Struct", + "name": "MoonNextPayload", + "fields": [ + { + "name": "recipient", + "ty": { + "kind": "address" + } + }, + { + "name": "payload", + "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": "MoonSwapJettonPayload", + "prefix": { + "prefixStr": "0xb37a900b", + "prefixLen": 32 + }, + "fields": [ + { + "name": "moonSwap", + "ty": { + "kind": "StructRef", + "structName": "MoonSwapParams" + } + } + ] + }, + { + "kind": "Struct", + "name": "CoffeeCrossDexFailureJettonPayload", + "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": "CoffeeSwapJettonPayload", + "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": "CoffeeCreatePoolJettonPayload", + "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": "CoffeeDepositLiquidityJettonPayload", + "prefix": { + "prefixStr": "0xc0ffee12", + "prefixLen": 32 + }, + "fields": [ + { + "name": "params", + "ty": { + "kind": "StructRef", + "structName": "CoffeeDepositLiquidityParams" + } + } + ] + }, + { + "kind": "Struct", + "name": "CoffeeNotificationJettonPayload", + "prefix": { + "prefixStr": "0xc0ffee36", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "body", + "ty": { + "kind": "cell" + } + } + ] + }, + { + "kind": "Struct", + "name": "MoonSwapFailedJettonPayload", + "prefix": { + "prefixStr": "0xc47c1f57", + "prefixLen": 32 + }, + "fields": [] + }, + { + "kind": "Struct", + "name": "StonfiSwapOkJettonPayload", + "prefix": { + "prefixStr": "0xc64370e5", + "prefixLen": 32 + }, + "fields": [] + }, + { + "kind": "Struct", + "name": "StormStakeJettonPayload", + "prefix": { + "prefixStr": "0xc89a3ee4", + "prefixLen": 32 + }, + "fields": [] + }, + { + "kind": "Struct", + "name": "WithdrawPayloadJettonPayload", + "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": "MoonSwapSucceedJettonPayload", + "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": "MoonCreateOrderJettonPayload", + "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": "BidaskDammSwapJettonPayload", + "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": "DedustSwapJettonPayload", + "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": "CoffeeMevProtectFailedSwapJettonPayload", + "prefix": { + "prefixStr": "0xee51ce51", + "prefixLen": 32 + }, + "fields": [ + { + "name": "queryId", + "ty": { + "kind": "uintN", + "n": 64 + } + }, + { + "name": "recipient", + "ty": { + "kind": "address" + } + } + ] + }, + { + "kind": "Struct", + "name": "BidaskSwapJettonPayload", + "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": "DepositPayloadJettonPayload", + "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" + } + } + } + ] + }, + { + "kind": "Struct", + "name": "StonfiProvideLiquidityJettonPayload", + "prefix": { + "prefixStr": "0xfcf9e58f", + "prefixLen": 32 + }, + "fields": [ + { + "name": "tokenWallet", + "ty": { + "kind": "address" + } + }, + { + "name": "minLpOut", + "ty": { + "kind": "coins" + } + } + ] + } + ], + "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/swap_coffee.json b/tolk/testdata/swap_coffee.json new file mode 100644 index 00000000..337cc270 --- /dev/null +++ b/tolk/testdata/swap_coffee.json @@ -0,0 +1,156 @@ +{ + "contractName": "Test", + "declarations": [ + { + "kind": "Struct", + "name": "CoffeeCrossDexResend", + "prefix": { + "prefixStr": "0x4ee9b106", + "prefixLen": 32 + }, + "fields": [ + { + "name": "next", + "isPayload": true, + "ty": { + "kind": "cell" + } + } + ] + }, + { + "kind": "Struct", + "name": "CoffeeSwap", + "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": "CoffeeSwapStepParams", + "fields": [ + { + "name": "poolAddressHash", + "ty": { + "kind": "uintN", + "n": 256 + } + }, + { + "name": "minOutputAmount", + "ty": { + "kind": "coins" + } + }, + { + "name": "next", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cellOf", + "inner": { + "kind": "StructRef", + "structName": "CoffeeSwapStepParams" + } + } + } + } + ] + }, + { + "kind": "Struct", + "name": "CoffeeSwapParams", + "fields": [ + { + "name": "deadline", + "ty": { + "kind": "uintN", + "n": 32 + } + }, + { + "name": "recipient", + "ty": { + "kind": "address" + } + }, + { + "name": "referral", + "ty": { + "kind": "addressOpt" + } + }, + { + "name": "notificationData", + "ty": { + "kind": "nullable", + "inner": { + "kind": "cellOf", + "inner": { + "kind": "StructRef", + "structName": "CoffeeNotificationData" + } + } + } + } + ] + }, + { + "kind": "Struct", + "name": "CoffeeNotificationData", + "fields": [ + { + "name": "reciever", + "ty": { + "kind": "address" + } + }, + { + "name": "fwdGas", + "ty": { + "kind": "coins" + } + }, + { + "name": "payload", + "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/tuples.go b/tolk/tuples.go index c316aa88..2fcd9d22 100644 --- a/tolk/tuples.go +++ b/tolk/tuples.go @@ -11,7 +11,7 @@ import ( type TupleValues []Value -func (v *TupleValues) Unmarshal(cell *boc.Cell, ty tolkParser.TupleWith, decoder *Decoder) error { +func (v *TupleValues) Unmarshal(cell *boc.Cell, ty parser.TupleWith, decoder *Decoder) error { list := make(TupleValues, len(ty.Items)) for i, item := range ty.Items { inner := Value{} @@ -25,7 +25,7 @@ func (v *TupleValues) Unmarshal(cell *boc.Cell, ty tolkParser.TupleWith, decoder return nil } -func (v *TupleValues) Marshal(cell *boc.Cell, ty tolkParser.TupleWith, encoder *Encoder) error { +func (v *TupleValues) Marshal(cell *boc.Cell, ty parser.TupleWith, encoder *Encoder) error { for i, item := range []Value(*v) { err := item.Marshal(cell, ty.Items[i], encoder) if err != nil { @@ -54,7 +54,7 @@ func (v *TupleValues) Equal(other any) bool { type TensorValues []Value -func (v *TensorValues) Unmarshal(cell *boc.Cell, ty tolkParser.Tensor, decoder *Decoder) error { +func (v *TensorValues) Unmarshal(cell *boc.Cell, ty parser.Tensor, decoder *Decoder) error { list := make(TensorValues, len(ty.Items)) for i, item := range ty.Items { inner := Value{} @@ -68,7 +68,7 @@ func (v *TensorValues) Unmarshal(cell *boc.Cell, ty tolkParser.Tensor, decoder * return nil } -func (v *TensorValues) Marshal(cell *boc.Cell, ty tolkParser.Tensor, encoder *Encoder) error { +func (v *TensorValues) Marshal(cell *boc.Cell, ty parser.Tensor, encoder *Encoder) error { for i, item := range []Value(*v) { err := item.Marshal(cell, ty.Items[i], encoder) if err != nil { diff --git a/tolk/union.go b/tolk/union.go index f2a68e3f..b7bbadc8 100644 --- a/tolk/union.go +++ b/tolk/union.go @@ -12,7 +12,7 @@ type UnionValue struct { Val Value } -func (u *UnionValue) Unmarshal(cell *boc.Cell, ty tolkParser.Union, decoder *Decoder) error { +func (u *UnionValue) Unmarshal(cell *boc.Cell, ty parser.Union, decoder *Decoder) error { unionV := UnionValue{} if len(ty.Variants) < 2 { return fmt.Errorf("union length must be at least 2") @@ -62,7 +62,7 @@ func (u *UnionValue) Unmarshal(cell *boc.Cell, ty tolkParser.Union, decoder *Dec return fmt.Errorf("none of union prefixes matched") } -func (u *UnionValue) Marshal(cell *boc.Cell, ty tolkParser.Union, encoder *Encoder) error { +func (u *UnionValue) Marshal(cell *boc.Cell, ty parser.Union, encoder *Encoder) error { if len(ty.Variants) < 2 { return fmt.Errorf("union length must be at least 2") } diff --git a/tolk/value.go b/tolk/value.go index 90b7bd8d..488796d0 100644 --- a/tolk/value.go +++ b/tolk/value.go @@ -412,7 +412,7 @@ func (v *Value) GetType() string { return string(v.SumType) } -func (v *Value) Unmarshal(cell *boc.Cell, ty tolkParser.Ty, decoder *Decoder) error { +func (v *Value) Unmarshal(cell *boc.Cell, ty parser.Ty, decoder *Decoder) error { var err error switch ty.SumType { case "IntN": @@ -627,7 +627,7 @@ func (v *Value) Unmarshal(cell *boc.Cell, ty tolkParser.Ty, decoder *Decoder) er return nil } -func (v *Value) Marshal(cell *boc.Cell, ty tolkParser.Ty, encoder *Encoder) error { +func (v *Value) Marshal(cell *boc.Cell, ty parser.Ty, encoder *Encoder) error { var err error switch ty.SumType { case "IntN": From 3967d0d897e526a9f7917d637dc826ec0700224b Mon Sep 17 00:00:00 2001 From: Pavel Levchenko Date: Wed, 4 Mar 2026 11:52:28 +0300 Subject: [PATCH 16/16] remove tags for tolk messages --- tolk/refs.go | 8 +------- .../testdata/json/a_lot_generics_from_alias.json | 16 ---------------- .../json/a_lot_generics_from_struct.json | 16 ---------------- .../json/a_lot_generics_with_default_values.json | 4 ---- tolk/testdata/json/a_lot_numbers.json | 4 ---- tolk/testdata/json/a_lot_random_fields.json | 4 ---- tolk/testdata/json/a_lot_refs_from_alias.json | 16 ---------------- tolk/testdata/json/a_lot_refs_from_struct.json | 16 ---------------- tolk/testdata/json/custom_pack_unpack.json | 4 ---- tolk/testdata/json/union_with_bin_prefix.json | 4 ---- tolk/testdata/json/union_with_hex_prefix.json | 4 ---- 11 files changed, 1 insertion(+), 95 deletions(-) diff --git a/tolk/refs.go b/tolk/refs.go index 23226d2e..0897a8dd 100644 --- a/tolk/refs.go +++ b/tolk/refs.go @@ -5,12 +5,10 @@ import ( "fmt" "math/big" "slices" - "strconv" "strings" "github.com/tonkeeper/tongo/boc" "github.com/tonkeeper/tongo/tolk/parser" - "github.com/tonkeeper/tongo/utils" "golang.org/x/exp/maps" ) @@ -259,11 +257,7 @@ func (s *Struct) Equal(o any) bool { func (s Struct) MarshalJSON() ([]byte, error) { builder := strings.Builder{} - builder.WriteString("{\"tag\":{\"name\":\"") - builder.WriteString(utils.ToSnakeCase(s.name)) - builder.WriteString("\",\"prefix\":\"0x") - builder.WriteString(strconv.FormatInt(int64(s.prefix.Prefix), 16)) - builder.WriteString("\"},") + builder.WriteRune('{') for i, name := range s.fieldNames { if i != 0 { builder.WriteRune(',') diff --git a/tolk/testdata/json/a_lot_generics_from_alias.json b/tolk/testdata/json/a_lot_generics_from_alias.json index e4fcebcf..2d54a0fc 100755 --- a/tolk/testdata/json/a_lot_generics_from_alias.json +++ b/tolk/testdata/json/a_lot_generics_from_alias.json @@ -1,28 +1,12 @@ { "value": { - "tag": { - "name": "many_refs_msg", - "prefix": "0x0" - }, "payload": { - "tag": { - "name": "either_ref", - "prefix": "0x0" - }, "value": 123 }, "either": { - "tag": { - "name": "either_right", - "prefix": "0x0" - }, "value": "100000000" }, "anotherEither": { - "tag": { - "name": "either_right", - "prefix": "0x0" - }, "value": [ true, "1000000000" diff --git a/tolk/testdata/json/a_lot_generics_from_struct.json b/tolk/testdata/json/a_lot_generics_from_struct.json index e4fcebcf..2d54a0fc 100755 --- a/tolk/testdata/json/a_lot_generics_from_struct.json +++ b/tolk/testdata/json/a_lot_generics_from_struct.json @@ -1,28 +1,12 @@ { "value": { - "tag": { - "name": "many_refs_msg", - "prefix": "0x0" - }, "payload": { - "tag": { - "name": "either_ref", - "prefix": "0x0" - }, "value": 123 }, "either": { - "tag": { - "name": "either_right", - "prefix": "0x0" - }, "value": "100000000" }, "anotherEither": { - "tag": { - "name": "either_right", - "prefix": "0x0" - }, "value": [ true, "1000000000" diff --git a/tolk/testdata/json/a_lot_generics_with_default_values.json b/tolk/testdata/json/a_lot_generics_with_default_values.json index 307117a6..a54dc88b 100755 --- a/tolk/testdata/json/a_lot_generics_with_default_values.json +++ b/tolk/testdata/json/a_lot_generics_with_default_values.json @@ -1,9 +1,5 @@ { "value": { - "tag": { - "name": "default_test", - "prefix": "0x0" - }, "num1": { "isExists": true, "value": 4 diff --git a/tolk/testdata/json/a_lot_numbers.json b/tolk/testdata/json/a_lot_numbers.json index 7ffc5f54..af649dd6 100755 --- a/tolk/testdata/json/a_lot_numbers.json +++ b/tolk/testdata/json/a_lot_numbers.json @@ -1,9 +1,5 @@ { "value": { - "tag": { - "name": "numbers", - "prefix": "0x0" - }, "num1": 0, "num3": "241", "num4": "3421", diff --git a/tolk/testdata/json/a_lot_random_fields.json b/tolk/testdata/json/a_lot_random_fields.json index 3d101023..a8ee2b73 100755 --- a/tolk/testdata/json/a_lot_random_fields.json +++ b/tolk/testdata/json/a_lot_random_fields.json @@ -1,9 +1,5 @@ { "value": { - "tag": { - "name": "random_fields", - "prefix": "0x794" - }, "dest_int": "0:83dfd552e63729b472fcbcc8c45ebcc6691702558b68ec7527e1ba403a0f31a8", "amount": "500000123400000", "dest_ext": "", diff --git a/tolk/testdata/json/a_lot_refs_from_alias.json b/tolk/testdata/json/a_lot_refs_from_alias.json index 8b77a28f..00319064 100755 --- a/tolk/testdata/json/a_lot_refs_from_alias.json +++ b/tolk/testdata/json/a_lot_refs_from_alias.json @@ -1,24 +1,12 @@ { "value": { - "tag": { - "name": "many_refs_msg", - "prefix": "0xdeadbeef" - }, "user1": { - "tag": { - "name": "address_and_balance", - "prefix": "0x0" - }, "addr": "0:83dfd552e63729b472fcbcc8c45ebcc6691702558b68ec7527e1ba403a0f31a8", "balance": "1000000000" }, "user2": { "isExists": true, "value": { - "tag": { - "name": "address_and_balance", - "prefix": "0x0" - }, "addr": "0:086fa2a675f74347b08dd4606a549b8fdb98829cb282bc1949d3b12fbaed9dcc", "balance": "100000000" } @@ -28,10 +16,6 @@ "isExists": false }, "user5": { - "tag": { - "name": "address_and_balance", - "prefix": "0x0" - }, "addr": "0:b113a994b5024a16719f69139328eb759596c38a25f59028b146fecdc3621dfe", "balance": "10000000000000" }, diff --git a/tolk/testdata/json/a_lot_refs_from_struct.json b/tolk/testdata/json/a_lot_refs_from_struct.json index 8b77a28f..00319064 100755 --- a/tolk/testdata/json/a_lot_refs_from_struct.json +++ b/tolk/testdata/json/a_lot_refs_from_struct.json @@ -1,24 +1,12 @@ { "value": { - "tag": { - "name": "many_refs_msg", - "prefix": "0xdeadbeef" - }, "user1": { - "tag": { - "name": "address_and_balance", - "prefix": "0x0" - }, "addr": "0:83dfd552e63729b472fcbcc8c45ebcc6691702558b68ec7527e1ba403a0f31a8", "balance": "1000000000" }, "user2": { "isExists": true, "value": { - "tag": { - "name": "address_and_balance", - "prefix": "0x0" - }, "addr": "0:086fa2a675f74347b08dd4606a549b8fdb98829cb282bc1949d3b12fbaed9dcc", "balance": "100000000" } @@ -28,10 +16,6 @@ "isExists": false }, "user5": { - "tag": { - "name": "address_and_balance", - "prefix": "0x0" - }, "addr": "0:b113a994b5024a16719f69139328eb759596c38a25f59028b146fecdc3621dfe", "balance": "10000000000000" }, diff --git a/tolk/testdata/json/custom_pack_unpack.json b/tolk/testdata/json/custom_pack_unpack.json index 6b3f2aa8..190bf906 100755 --- a/tolk/testdata/json/custom_pack_unpack.json +++ b/tolk/testdata/json/custom_pack_unpack.json @@ -1,9 +1,5 @@ { "value": { - "tag": { - "name": "my", - "prefix": "0x0" - }, "amount": "1000000000" } } \ No newline at end of file diff --git a/tolk/testdata/json/union_with_bin_prefix.json b/tolk/testdata/json/union_with_bin_prefix.json index 70ba7c5c..8c54575c 100755 --- a/tolk/testdata/json/union_with_bin_prefix.json +++ b/tolk/testdata/json/union_with_bin_prefix.json @@ -1,9 +1,5 @@ { "value": { - "tag": { - "name": "map_with_prefix", - "prefix": "0x3" - }, "v": { "0:b113a994b5024a16719f69139328eb759596c38a25f59028b146fecdc3621dfe": "43213412" } diff --git a/tolk/testdata/json/union_with_hex_prefix.json b/tolk/testdata/json/union_with_hex_prefix.json index 10eceb5e..f25445e2 100755 --- a/tolk/testdata/json/union_with_hex_prefix.json +++ b/tolk/testdata/json/union_with_hex_prefix.json @@ -1,9 +1,5 @@ { "value": { - "tag": { - "name": "u_int33_with_prefix", - "prefix": "0xdeadbeef" - }, "v": 1 } } \ No newline at end of file