From 492b98e0c5c9c4fc2ffd9e50f1f4e807273b6c31 Mon Sep 17 00:00:00 2001 From: Denis Subbotin Date: Sun, 1 Dec 2024 23:06:35 +0300 Subject: [PATCH] add precompiles for v5 --- abi/schemas/ston-fi.xml | 2 - abi/schemas/wallets.xml | 1 + tvm/precompiled/precompiled.go | 7 +++- tvm/precompiled/precompiled_test.go | 21 ++++++++++ tvm/precompiled/wallets.go | 62 +++++++++++++++++++++++++++++ 5 files changed, 90 insertions(+), 3 deletions(-) diff --git a/abi/schemas/ston-fi.xml b/abi/schemas/ston-fi.xml index 7fae470f..5a03d56c 100644 --- a/abi/schemas/ston-fi.xml +++ b/abi/schemas/ston-fi.xml @@ -151,9 +151,7 @@ int257 int257 - - bool msgaddress diff --git a/abi/schemas/wallets.xml b/abi/schemas/wallets.xml index b1681d18..848b1d17 100644 --- a/abi/schemas/wallets.xml +++ b/abi/schemas/wallets.xml @@ -104,6 +104,7 @@ 20834b7b72b112147e1b2fb457b84e74d1a30f04f737d4f62a668e9552d2b72f + diff --git a/tvm/precompiled/precompiled.go b/tvm/precompiled/precompiled.go index c2497d7f..bf81342b 100644 --- a/tvm/precompiled/precompiled.go +++ b/tvm/precompiled/precompiled.go @@ -24,12 +24,17 @@ var KnownMethods = map[MethodCode]tvmPrecompiled{ {MethodID: 85143, CodeHash: ton.MustParseHash("84dafa449f98a6987789ba232358072bc0f76dc4524002a5d0918b9a75d2d599")}: walletv3seqno, {MethodID: 78748, CodeHash: ton.MustParseHash("84dafa449f98a6987789ba232358072bc0f76dc4524002a5d0918b9a75d2d599")}: walletv3r2publicKey, - //wallet v4r2 seqno + //wallet v4r2 {MethodID: 85143, CodeHash: ton.MustParseHash("feb5ff6820e2ff0d9483e7e0d62c817d846789fb4ae580c878866d959dabd5c0")}: walletv4r2seqno, {MethodID: 81467, CodeHash: ton.MustParseHash("feb5ff6820e2ff0d9483e7e0d62c817d846789fb4ae580c878866d959dabd5c0")}: walletv4r2SubwalletID, {MethodID: 78748, CodeHash: ton.MustParseHash("feb5ff6820e2ff0d9483e7e0d62c817d846789fb4ae580c878866d959dabd5c0")}: walletv4r2publicKey, {MethodID: 107653, CodeHash: ton.MustParseHash("feb5ff6820e2ff0d9483e7e0d62c817d846789fb4ae580c878866d959dabd5c0")}: walletv4r2getPluginList, + //wallet v5r1 + {MethodID: 85143, CodeHash: ton.MustParseHash("20834b7b72b112147e1b2fb457b84e74d1a30f04f737d4f62a668e9552d2b72f")}: walletv5r1seqno, + {MethodID: 81467, CodeHash: ton.MustParseHash("20834b7b72b112147e1b2fb457b84e74d1a30f04f737d4f62a668e9552d2b72f")}: walletv5r1SubwalletID, + {MethodID: 78748, CodeHash: ton.MustParseHash("20834b7b72b112147e1b2fb457b84e74d1a30f04f737d4f62a668e9552d2b72f")}: walletv5r1publicKey, + //jetton v1 get_wallet_data {MethodID: 97026, CodeHash: ton.MustParseHash("beb0683ebeb8927fe9fc8ec0a18bc7dd17899689825a121eab46c5a3a860d0ce")}: jettonV1getWalletData, diff --git a/tvm/precompiled/precompiled_test.go b/tvm/precompiled/precompiled_test.go index 52629a54..9d4a764b 100644 --- a/tvm/precompiled/precompiled_test.go +++ b/tvm/precompiled/precompiled_test.go @@ -81,6 +81,27 @@ func TestPrecompiles(t *testing.T) { method: 107653, account: "UQAs87W4yJHlF8mt29ocA4agnMrLsOP69jC1HPyBUjJay7Mg", }, + { + name: "v5r1_seqno", + code: "te6ccgECFAEAAoEAART/APSkE/S88sgLAQIBIAIDAgFIBAUBAvIOAtzQINdJwSCRW49jINcLHyCCEGV4dG69IYIQc2ludL2wkl8D4IIQZXh0brqOtIAg1yEB0HTXIfpAMPpE+Cj6RDBYvZFb4O1E0IEBQdch9AWDB/QOb6ExkTDhgEDXIXB/2zzgMSDXSYECgLmRMOBw4hAPAgEgBgcCASAICQAZvl8PaiaECAoOuQ+gLAIBbgoLAgFIDA0AGa3OdqJoQCDrkOuF/8AAGa8d9qJoQBDrkOuFj8AAF7Ml+1E0HHXIdcLH4AARsmL7UTQ1woAgAR4g1wsfghBzaWduuvLgin8PAeaO8O2i7fshgwjXIgKDCNcjIIAg1yHTH9Mf0x/tRNDSANMfINMf0//XCgAK+QFAzPkQmiiUXwrbMeHywIffArNQB7Dy0IRRJbry4IVQNrry4Ib4I7vy0IgikvgA3gGkf8jKAMsfAc8Wye1UIJL4D95w2zzYEAP27aLt+wL0BCFukmwhjkwCIdc5MHCUIccAs44tAdcoIHYeQ2wg10nACPLgkyDXSsAC8uCTINcdBscSwgBSMLDy0InXTNc5MAGk6GwShAe78uCT10rAAPLgk+1V4tIAAcAAkVvg69csCBQgkXCWAdcsCBwS4lIQseMPINdKERITAJYB+kAB+kT4KPpEMFi68uCR7UTQgQFB1xj0BQSdf8jKAEAEgwf0U/Lgi44UA4MH9Fvy4Iwi1woAIW4Bs7Dy0JDiyFADzxYS9ADJ7VQAcjDXLAgkji0h8uCS0gDtRNDSAFETuvLQj1RQMJExnAGBAUDXIdcKAPLgjuLIygBYzxbJ7VST8sCN4gAQk1vbMeHXTNA=", + data: "te6ccgEBAQEAKwAAUYAAAAE///+IhwL/NGAdqz9BwOQpHNXySSYmbxioYEv8cVer4tmjFhMg", + method: 85143, + account: "UQAQoxHkAhIfBrx0C3X7qTExchRCMwABlymYNFYhw4bwDC8m", + }, + { + name: "v5r1_get_public_key", + code: "te6ccgECFAEAAoEAART/APSkE/S88sgLAQIBIAIDAgFIBAUBAvIOAtzQINdJwSCRW49jINcLHyCCEGV4dG69IYIQc2ludL2wkl8D4IIQZXh0brqOtIAg1yEB0HTXIfpAMPpE+Cj6RDBYvZFb4O1E0IEBQdch9AWDB/QOb6ExkTDhgEDXIXB/2zzgMSDXSYECgLmRMOBw4hAPAgEgBgcCASAICQAZvl8PaiaECAoOuQ+gLAIBbgoLAgFIDA0AGa3OdqJoQCDrkOuF/8AAGa8d9qJoQBDrkOuFj8AAF7Ml+1E0HHXIdcLH4AARsmL7UTQ1woAgAR4g1wsfghBzaWduuvLgin8PAeaO8O2i7fshgwjXIgKDCNcjIIAg1yHTH9Mf0x/tRNDSANMfINMf0//XCgAK+QFAzPkQmiiUXwrbMeHywIffArNQB7Dy0IRRJbry4IVQNrry4Ib4I7vy0IgikvgA3gGkf8jKAMsfAc8Wye1UIJL4D95w2zzYEAP27aLt+wL0BCFukmwhjkwCIdc5MHCUIccAs44tAdcoIHYeQ2wg10nACPLgkyDXSsAC8uCTINcdBscSwgBSMLDy0InXTNc5MAGk6GwShAe78uCT10rAAPLgk+1V4tIAAcAAkVvg69csCBQgkXCWAdcsCBwS4lIQseMPINdKERITAJYB+kAB+kT4KPpEMFi68uCR7UTQgQFB1xj0BQSdf8jKAEAEgwf0U/Lgi44UA4MH9Fvy4Iwi1woAIW4Bs7Dy0JDiyFADzxYS9ADJ7VQAcjDXLAgkji0h8uCS0gDtRNDSAFETuvLQj1RQMJExnAGBAUDXIdcKAPLgjuLIygBYzxbJ7VST8sCN4gAQk1vbMeHXTNA=", + data: "te6ccgEBAQEAKwAAUYAAAAE///+IhwL/NGAdqz9BwOQpHNXySSYmbxioYEv8cVer4tmjFhMg", + method: 78748, + account: "UQAQoxHkAhIfBrx0C3X7qTExchRCMwABlymYNFYhw4bwDC8m", + }, + { + name: "v5r1_get_subwallet_id", + code: "te6ccgECFAEAAoEAART/APSkE/S88sgLAQIBIAIDAgFIBAUBAvIOAtzQINdJwSCRW49jINcLHyCCEGV4dG69IYIQc2ludL2wkl8D4IIQZXh0brqOtIAg1yEB0HTXIfpAMPpE+Cj6RDBYvZFb4O1E0IEBQdch9AWDB/QOb6ExkTDhgEDXIXB/2zzgMSDXSYECgLmRMOBw4hAPAgEgBgcCASAICQAZvl8PaiaECAoOuQ+gLAIBbgoLAgFIDA0AGa3OdqJoQCDrkOuF/8AAGa8d9qJoQBDrkOuFj8AAF7Ml+1E0HHXIdcLH4AARsmL7UTQ1woAgAR4g1wsfghBzaWduuvLgin8PAeaO8O2i7fshgwjXIgKDCNcjIIAg1yHTH9Mf0x/tRNDSANMfINMf0//XCgAK+QFAzPkQmiiUXwrbMeHywIffArNQB7Dy0IRRJbry4IVQNrry4Ib4I7vy0IgikvgA3gGkf8jKAMsfAc8Wye1UIJL4D95w2zzYEAP27aLt+wL0BCFukmwhjkwCIdc5MHCUIccAs44tAdcoIHYeQ2wg10nACPLgkyDXSsAC8uCTINcdBscSwgBSMLDy0InXTNc5MAGk6GwShAe78uCT10rAAPLgk+1V4tIAAcAAkVvg69csCBQgkXCWAdcsCBwS4lIQseMPINdKERITAJYB+kAB+kT4KPpEMFi68uCR7UTQgQFB1xj0BQSdf8jKAEAEgwf0U/Lgi44UA4MH9Fvy4Iwi1woAIW4Bs7Dy0JDiyFADzxYS9ADJ7VQAcjDXLAgkji0h8uCS0gDtRNDSAFETuvLQj1RQMJExnAGBAUDXIdcKAPLgjuLIygBYzxbJ7VST8sCN4gAQk1vbMeHXTNA=", + data: "te6ccgEBAQEAKwAAUYAAAAE///+IhwL/NGAdqz9BwOQpHNXySSYmbxioYEv8cVer4tmjFhMg", + method: 81467, + account: "UQAQoxHkAhIfBrx0C3X7qTExchRCMwABlymYNFYhw4bwDC8m", + }, //{ // name: "get_plugin_list_non_empty", // code: "te6ccgECFAEAAtQAART/APSkE/S88sgLAQIBIAIDAgFIBAUE+PKDCNcYINMf0x/THwL4I7vyZO1E0NMf0x/T//QE0VFDuvKhUVG68qIF+QFUEGT5EPKj+AAkpMjLH1JAyx9SMMv/UhD0AMntVPgPAdMHIcAAn2xRkyDXSpbTB9QC+wDoMOAhwAHjACHAAuMAAcADkTDjDQOkyMsfEssfy/8QERITAubQAdDTAyFxsJJfBOAi10nBIJJfBOAC0x8hghBwbHVnvSKCEGRzdHK9sJJfBeAD+kAwIPpEAcjKB8v/ydDtRNCBAUDXIfQEMFyBAQj0Cm+hMbOSXwfgBdM/yCWCEHBsdWe6kjgw4w0DghBkc3RyupJfBuMNBgcCASAICQB4AfoA9AQw+CdvIjBQCqEhvvLgUIIQcGx1Z4MesXCAGFAEywUmzxZY+gIZ9ADLaRfLH1Jgyz8gyYBA+wAGAIpQBIEBCPRZMO1E0IEBQNcgyAHPFvQAye1UAXKwjiOCEGRzdHKDHrFwgBhQBcsFUAPPFiP6AhPLassfyz/JgED7AJJfA+ICASAKCwBZvSQrb2omhAgKBrkPoCGEcNQICEekk30pkQzmkD6f+YN4EoAbeBAUiYcVnzGEAgFYDA0AEbjJftRNDXCx+AA9sp37UTQgQFA1yH0BDACyMoHy//J0AGBAQj0Cm+hMYAIBIA4PABmtznaiaEAga5Drhf/AABmvHfaiaEAQa5DrhY/AAG7SB/oA1NQi+QAFyMoHFcv/ydB3dIAYyMsFywIizxZQBfoCFMtrEszMyXP7AMhAFIEBCPRR8qcCAHCBAQjXGPoA0z/IVCBHgQEI9FHyp4IQbm90ZXB0gBjIywXLAlAGzxZQBPoCFMtqEssfyz/Jc/sAAgBsgQEI1xj6ANM/MFIkgQEI9Fnyp4IQZHN0cnB0gBjIywXLAlAFzxZQA/oCE8tqyx8Syz/Jc/sAAAr0AMntVA==", diff --git a/tvm/precompiled/wallets.go b/tvm/precompiled/wallets.go index 075ca89e..b0f7aeba 100644 --- a/tvm/precompiled/wallets.go +++ b/tvm/precompiled/wallets.go @@ -121,3 +121,65 @@ var walletv4r2getPluginList = func(data *boc.Cell, args tlb.VmStack) (tlb.VmStac //todo: implement return nil, fmt.Errorf("not implented not empty dict") } + +func walletv5r1seqno(data *boc.Cell, args tlb.VmStack) (tlb.VmStack, error) { + var dataV5 struct { + IsSignatureAllowed bool + Seqno uint32 + WalletID uint32 + PublicKey tlb.Bits256 + Extensions tlb.HashmapE[tlb.Bits256, tlb.Uint1] + } + err := tlb.Unmarshal(data, &dataV5) + if err != nil { + return nil, err + } + return tlb.VmStack{ + { + SumType: "VmStkTinyInt", + VmStkTinyInt: int64(dataV5.Seqno), + }, + }, nil +} + +func walletv5r1SubwalletID(data *boc.Cell, args tlb.VmStack) (tlb.VmStack, error) { + var dataV5 struct { + IsSignatureAllowed bool + Seqno uint32 + WalletID uint32 + PublicKey tlb.Bits256 + Extensions tlb.HashmapE[tlb.Bits256, tlb.Uint1] + } + err := tlb.Unmarshal(data, &dataV5) + if err != nil { + return nil, err + } + return tlb.VmStack{ + { + SumType: "VmStkTinyInt", + VmStkTinyInt: int64(dataV5.WalletID), + }, + }, nil +} + +func walletv5r1publicKey(data *boc.Cell, args tlb.VmStack) (tlb.VmStack, error) { + var dataV5 struct { + IsSignatureAllowed bool + Seqno uint32 + WalletID uint32 + PublicKey tlb.Bits256 + Extensions tlb.HashmapE[tlb.Bits256, tlb.Uint1] + } + err := tlb.Unmarshal(data, &dataV5) + if err != nil { + return nil, err + } + var b big.Int + b.SetBytes(dataV5.PublicKey[:]) + return tlb.VmStack{ + { + SumType: "VmStkInt", + VmStkInt: tlb.Int257(b), + }, + }, nil +}