diff --git a/abi/inspect_test.go b/abi/inspect_test.go index becbfca9..844d9298 100644 --- a/abi/inspect_test.go +++ b/abi/inspect_test.go @@ -231,6 +231,40 @@ func Test_contractInspector_InspectContract(t *testing.T) { WalletVesting, }, }, + { + name: "stonfi v2", + account: "0:8649cad97b5c5bc96a960ef748ea6ccff8601c01616fe995ee6893ae4aa7a6c6", + code: "b5ee9c7201010101002300084202a9338ecd624ca15d37e4a8d9bf677ddc9b84f0e98f05f2fb84c7afe332a281b4", + data: "b5ee9c720101040100d7000149301bc3bb69e12b82156e4fb859fa31b951d2d995caa1e5f97c6631f5c520727f90002800150102c980125c28235ca8d125e676591513d520721b1fe99f7722f4c87723ce7ee0dfb73a300248b589f5f63b6f4039388ef6c31529dbb9787d195ce86bd105e15fe8f88fa47e00491060c0d367f56688dbdc7b109c6f8ddce6415b769330e97afd7710259f7d90400203084202c00836440d084e44fb94316132ac5a21417ef4f429ee09b5560b5678b334c3e8084202c95a2ed22ab516f77f9d4898dc4578e72f18a2448e8f6832334b0b4bf501bc79", + hasLibrary: true, + want: []ContractInterface{ + JettonMaster, StonfiPoolV2, + }, + }, + { + name: "stonfi stableswap", + account: "0:52518e14586245029b342b01d8e2da4e1aacd4e350d9872ad3f0ebb20165ad9d", + code: "b5ee9c72010101010023000842023c882eb9ede6be2459b2d2e469680af9f8e48ab16ec0726f0d07b0e5686be718", + data: "b5ee9c720101040100f800018c301d59a3a8c17b01e8a10c6375b03be1eff87dda2b29c23d22bd483fe400000000000000000000000000000000000000000000000000000000000000000000000001000000640102c9800a46afff33251480ab6dab42434437a3fe464a9dbe5f525f9642ab4d2ef6eac89001466aa0b3a89e00a1dd7ccf9e8a225962fc32536722c3351274978f9861d9e8ee0029ee48e6b746e6db45008d68a4de088ac64064b6fcbb98f3a46f9583bb409e2a400203084202c00836440d084e44fb94316132ac5a21417ef4f429ee09b5560b5678b334c3e8084202c3b3ef256ddc9bd4e35db3e3863c048b18465c9f403f1d5a2b559395e11cfee6", + hasLibrary: true, + want: []ContractInterface{ + JettonMaster, StonfiPoolV2, + }, + }, + { + name: "stonfi weighted stableswap", + account: "0:05ea635b2a168cadfca174d72b12744a5b57d70378e6912e8a33b6b39bd3ee9d", + code: "b5ee9c72010101010023000842029e5038ab735973d5450fae1a14e7707b332dcd8e744f5dbb3b6a0d994d400c59", + data: "b5ee9c720102050100012700023f2eb83040934b00e0b0fd70b83205d77620ca9a0ce7c76e20601218e800080003010200a30000000000000002b5e3af16b18800000000000000000000111c7ef7a00e8000000000000000000003782dace9d900008000000000000000000000000000000000000000000000000000000000000000001002c98000cafb7e1aeb694b6c81c13012e24c43b95cf99bd3c84fb900ee31e9b144096fb0001aa0db2d3fc8f1224da5badf8994c74a05048d50963e42b0d8d71fe2b849569a0003770d21f96c46cd550df24da7d76c88d13cbed0cc691d4e91c69706ae47137bc00304084202c00836440d084e44fb94316132ac5a21417ef4f429ee09b5560b5678b334c3e8084202e398c874e2bb0017b7447c3cbc534ca368d96533c1b120101d4c8c097d12c6e3", + hasLibrary: true, + want: []ContractInterface{ + JettonMaster, StonfiPoolV2, + }, + }, + } + cli, err := liteapi.NewClient(liteapi.Mainnet()) + if err != nil { + t.Fatalf("failed to create liteapi client: %v", err) } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -243,10 +277,6 @@ func Test_contractInspector_InspectContract(t *testing.T) { if tt.emulatorConfig == nil { emulatorConfig = mainnetConfig[0] } - 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.WithLazyC7Optimization(), tvm.WithLibraryResolver(cli), tvm.WithIgnoreLibraryCells(true)) if err != nil { diff --git a/abi/interfaces.go b/abi/interfaces.go index dd3b8bd4..cf572024 100644 --- a/abi/interfaces.go +++ b/abi/interfaces.go @@ -71,6 +71,8 @@ const ( StonfiLpAccountV2 StonfiPool StonfiPoolV2 + StonfiPoolV2Stableswap + StonfiPoolV2WeightedStableswap StonfiRouter StonfiRouterV2 StonfiVaultV2 @@ -243,6 +245,10 @@ func (c ContractInterface) String() string { return "stonfi_pool" case StonfiPoolV2: return "stonfi_pool_v2" + case StonfiPoolV2Stableswap: + return "stonfi_pool_v2_stableswap" + case StonfiPoolV2WeightedStableswap: + return "stonfi_pool_v2_weighted_stableswap" case StonfiRouter: return "stonfi_router" case StonfiRouterV2: @@ -460,6 +466,10 @@ func ContractInterfaceFromString(s string) ContractInterface { return StonfiPool case "stonfi_pool_v2": return StonfiPoolV2 + case "stonfi_pool_v2_stableswap": + return StonfiPoolV2Stableswap + case "stonfi_pool_v2_weighted_stableswap": + return StonfiPoolV2WeightedStableswap case "stonfi_router": return StonfiRouter case "stonfi_router_v2": @@ -1230,6 +1240,18 @@ var contractInterfacesOrder = []InterfaceDescription{ "GetPoolData_StonfiV2Result", }, }, + { + Name: StonfiPoolV2, + Results: []string{ + "GetPoolData_StonfiV2StableswapResult", + }, + }, + { + Name: StonfiPoolV2, + Results: []string{ + "GetPoolData_StonfiV2WeightedStableswapResult", + }, + }, { Name: StonfiRouter, Results: []string{ @@ -2019,6 +2041,22 @@ func (c ContractInterface) IntMsgs() []msgDecoderFunc { decodeFuncPtonResetGasMsgBody, decodeFuncStonfiCbAddLiquidityV2MsgBody, } + case StonfiPoolV2Stableswap: + return []msgDecoderFunc{ + decodeFuncStonfiBurnNotificationExtV2MsgBody, + decodeFuncStonfiSwapV2MsgBody, + decodeFuncStonfiProvideLpV2MsgBody, + decodeFuncPtonResetGasMsgBody, + decodeFuncStonfiCbAddLiquidityV2MsgBody, + } + case StonfiPoolV2WeightedStableswap: + return []msgDecoderFunc{ + decodeFuncStonfiBurnNotificationExtV2MsgBody, + decodeFuncStonfiSwapV2MsgBody, + decodeFuncStonfiProvideLpV2MsgBody, + decodeFuncPtonResetGasMsgBody, + decodeFuncStonfiCbAddLiquidityV2MsgBody, + } case StonfiRouterV2: return []msgDecoderFunc{ decodeFuncJettonNotifyMsgBody, diff --git a/abi/parser/generator.go b/abi/parser/generator.go index 51b292d1..a508abf5 100644 --- a/abi/parser/generator.go +++ b/abi/parser/generator.go @@ -604,11 +604,13 @@ func (g *Generator) RenderInvocationOrderList(simpleMethods []string) (string, e InterfaceOrder []interfaceDescription KnownHashes map[string]interfaceDescription Inheritance map[string]string + TransformTo map[string]string IntMsgs, ExtInMsgs, ExtOutMsgs map[string][]string }{ Interfaces: map[string]string{}, KnownHashes: map[string]interfaceDescription{}, Inheritance: map[string]string{}, + TransformTo: map[string]string{}, IntMsgs: map[string][]string{}, ExtInMsgs: map[string][]string{}, ExtOutMsgs: map[string][]string{}, @@ -633,6 +635,7 @@ func (g *Generator) RenderInvocationOrderList(simpleMethods []string) (string, e descriptions[invokeFnName] = desc } + transformTo := map[string]string{} inheritance := map[string]string{} // interface name -> parent interface methodsByIface := map[string]map[string]string{} // interface name -> method name -> result name @@ -642,6 +645,9 @@ func (g *Generator) RenderInvocationOrderList(simpleMethods []string) (string, e if iface.Inherits != "" { inheritance[ifaceName] = utils.ToCamelCase(iface.Inherits) } + if iface.TransformTo != "" { + transformTo[ifaceName] = utils.ToCamelCase(iface.TransformTo) + } for _, method := range iface.Methods { if !slices.Contains(simpleMethods, method.Name) { continue @@ -657,6 +663,7 @@ func (g *Generator) RenderInvocationOrderList(simpleMethods []string) (string, e methodsByIface[ifaceName][methodName] = resultName } } + context.TransformTo = transformTo context.Inheritance = inheritance for _, iface := range g.abi.Interfaces { @@ -669,8 +676,12 @@ func (g *Generator) RenderInvocationOrderList(simpleMethods []string) (string, e ifaceMethods[methodName] = resultName } } + ifaceDescrName := ifaceName + if transformToName, ok := context.TransformTo[ifaceName]; ok { + ifaceDescrName = transformToName + } description := interfaceDescription{ - Name: ifaceName, + Name: ifaceDescrName, } methodNames := maps.Keys(ifaceMethods) sort.Strings(methodNames) diff --git a/abi/parser/parser.go b/abi/parser/parser.go index 8a588eed..d64284ed 100644 --- a/abi/parser/parser.go +++ b/abi/parser/parser.go @@ -31,9 +31,10 @@ type Interface struct { Internals []InterfaceMessage `xml:"internal"` Externals []InterfaceMessage `xml:"ext_out"` } `xml:"msg_out"` - CodeHashes []string `xml:"code_hash"` - Inherits string `xml:"inherits,attr"` - Errors []struct { + CodeHashes []string `xml:"code_hash"` + Inherits string `xml:"inherits,attr"` + TransformTo string `xml:"transform_to,attr"` + Errors []struct { Text string `xml:",chardata"` Code int `xml:"code,attr"` } `xml:"error"` diff --git a/abi/schemas/ston-fi.xml b/abi/schemas/ston-fi.xml index 572122e2..4b859e36 100644 --- a/abi/schemas/ston-fi.xml +++ b/abi/schemas/ston-fi.xml @@ -17,6 +17,28 @@ + + + + + + + + + + + + + + + + + + + + + +