Skip to content

Commit

Permalink
add precompiles for v5
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-tron committed Dec 1, 2024
1 parent b593ec5 commit 492b98e
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 3 deletions.
2 changes: 0 additions & 2 deletions abi/schemas/ston-fi.xml
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,7 @@
<int name="collected_token0_protocol_fee">int257</int>
<int name="collected_token1_protocol_fee">int257</int>
</output>
</get_method>

<get_method name="get_pool_data">
<output version="stonfi_v2" fixed_length="true">
<int name="is_locked">bool</int>
<slice name="router_address">msgaddress</slice>
Expand Down
1 change: 1 addition & 0 deletions abi/schemas/wallets.xml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
<code_hash>20834b7b72b112147e1b2fb457b84e74d1a30f04f737d4f62a668e9552d2b72f</code_hash>
<get_method name="seqno"/>
<get_method name="get_public_key"/>
<get_method name="get_subwallet_id"/>
<msg_in>
<ext_in name="wallet_signed_external_v5r1"/>
<internal name="wallet_signed_internal_v5r1"/>
Expand Down
7 changes: 6 additions & 1 deletion tvm/precompiled/precompiled.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Expand Down
21 changes: 21 additions & 0 deletions tvm/precompiled/precompiled_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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+1E0HHXIdcLH4AARsmL7UTQ1woAgAR4g1wsfghBzaWduuvLgin8PAeaO8O2i7fshgwjXIgKDC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y0IgikvgA3gGkf8jKAMsfAc8Wye1UIJL4D95w2zzYEAP27aLt+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==",
Expand Down
62 changes: 62 additions & 0 deletions tvm/precompiled/wallets.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit 492b98e

Please sign in to comment.