From d2d63ee353690064f63d04fd69b49c39dd98d4fc Mon Sep 17 00:00:00 2001 From: Denis Subbotin Date: Wed, 29 Jan 2025 15:43:59 +0300 Subject: [PATCH] add new gg contracts --- abi/contracts_errors.go | 13 +++++++++++ abi/get_methods.go | 48 ++++++++++++++++++++++++++++++++++++++++ abi/interfaces.go | 24 ++++++++++++++++++++ abi/schemas/nft_sale.xml | 36 ++++++++++++++++++++++++++++++ 4 files changed, 121 insertions(+) diff --git a/abi/contracts_errors.go b/abi/contracts_errors.go index 08aef8b3..5499f05c 100644 --- a/abi/contracts_errors.go +++ b/abi/contracts_errors.go @@ -57,6 +57,19 @@ var contractErrors = map[ContractInterface]map[int32]string{ 501: "Invalid op, expected ownership_assigned", 65535: "Unknown operation", }, + NftSaleGetgemsV4: {404: "Already sold or cancelled", + 405: "Mode 32 not allowed", + 406: "Can't execute command at this time", + 408: "Inconsistent price and fees", + 409: "Inconsistent price and fees", + 410: "Inconsistent price and fees", + 450: "Not enough TONs for sale", + 457: "Not enough TONs for cancellation", + 458: "Unauthorized cancellation", + 500: "Unauthorized initiation", + 501: "Invalid op, expected ownership_assigned", + 65535: "Unknown operation", + }, WalletV4R2: {33: "Invalid seqno", 34: "Invalid subwallet ID", 35: "Invalid signature", diff --git a/abi/get_methods.go b/abi/get_methods.go index 4c0c18ef..c86b911c 100644 --- a/abi/get_methods.go +++ b/abi/get_methods.go @@ -33,6 +33,7 @@ var KnownGetMethodsDecoder = map[string][]func(tlb.VmStack) (string, any, error) "get_executor_collection_address": {DecodeGetExecutorCollectionAddress_StormResult}, "get_executor_vaults_whitelist": {DecodeGetExecutorVaultsWhitelist_StormResult}, "get_expected_outputs": {DecodeGetExpectedOutputs_StonfiResult}, + "get_fix_price_data_v4": {DecodeGetFixPriceDataV4Result}, "get_full_domain": {DecodeGetFullDomainResult}, "get_jetton_data": {DecodeGetJettonDataResult}, "get_last_clean_time": {DecodeGetLastCleanTimeResult}, @@ -189,6 +190,7 @@ var KnownSimpleGetMethods = map[int][]func(ctx context.Context, executor Executo 122058: {IsActive}, 122166: {GetLpAccountData}, 122284: {IsClaimed}, + 122483: {GetFixPriceDataV4}, 122496: {GetAmmName}, 122498: {GetTelemintAuctionState}, 123832: {GetOrderData}, @@ -227,6 +229,7 @@ var resultTypes = []interface{}{ &GetExecutorCollectionAddress_StormResult{}, &GetExecutorVaultsWhitelist_StormResult{}, &GetExpectedOutputs_StonfiResult{}, + &GetFixPriceDataV4Result{}, &GetFullDomainResult{}, &GetJettonDataResult{}, &GetLastCleanTimeResult{}, @@ -1177,6 +1180,51 @@ func DecodeGetExpectedOutputs_StonfiResult(stack tlb.VmStack) (resultType string return "GetExpectedOutputs_StonfiResult", result, err } +type GetFixPriceDataV4Result struct { + IsComplete bool + CreatedAt uint32 + MarketplaceAddress tlb.MsgAddress + NftAddress tlb.MsgAddress + NftOwnerAddress *tlb.MsgAddress + FullPrice tlb.Int257 + FeeAddress tlb.MsgAddress + FeePercent uint32 + RoyaltyAddress tlb.MsgAddress + RoyaltyPercent uint32 + SoldAt uint32 + SoldQueryId uint64 + JettonPriceDict *boc.Cell +} + +func GetFixPriceDataV4(ctx context.Context, executor Executor, reqAccountID ton.AccountID) (string, any, error) { + stack := tlb.VmStack{} + + // MethodID = 122483 for "get_fix_price_data_v4" method + errCode, stack, err := executor.RunSmcMethodByID(ctx, reqAccountID, 122483, 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){DecodeGetFixPriceDataV4Result} { + s, r, err := f(stack) + if err == nil { + return s, r, nil + } + } + return "", nil, fmt.Errorf("can not decode outputs") +} + +func DecodeGetFixPriceDataV4Result(stack tlb.VmStack) (resultType string, resultAny any, err error) { + if len(stack) != 13 || (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 != "VmStkSlice" && stack[4].SumType != "VmStkNull") || (stack[5].SumType != "VmStkTinyInt" && stack[5].SumType != "VmStkInt") || (stack[6].SumType != "VmStkSlice") || (stack[7].SumType != "VmStkTinyInt" && stack[7].SumType != "VmStkInt") || (stack[8].SumType != "VmStkSlice") || (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 != "VmStkCell" && stack[12].SumType != "VmStkNull") { + return "", nil, fmt.Errorf("invalid stack format") + } + var result GetFixPriceDataV4Result + err = stack.Unmarshal(&result) + return "GetFixPriceDataV4Result", result, err +} + type GetFullDomainResult struct { Domain string } diff --git a/abi/interfaces.go b/abi/interfaces.go index 51279168..4032c7ad 100644 --- a/abi/interfaces.go +++ b/abi/interfaces.go @@ -34,9 +34,11 @@ const ( NftCollection NftItem NftItemSimple + NftOfferGetgemsV1 NftSale NftSaleGetgemsV2 NftSaleGetgemsV3 + NftSaleGetgemsV4 NftSaleV1 NftSaleV2 PaymentChannel @@ -137,12 +139,16 @@ func (c ContractInterface) String() string { return "nft_item" case NftItemSimple: return "nft_item_simple" + case NftOfferGetgemsV1: + return "nft_offer_getgems_v1" case NftSale: return "nft_sale" case NftSaleGetgemsV2: return "nft_sale_getgems_v2" case NftSaleGetgemsV3: return "nft_sale_getgems_v3" + case NftSaleGetgemsV4: + return "nft_sale_getgems_v4" case NftSaleV1: return "nft_sale_v1" case NftSaleV2: @@ -290,12 +296,16 @@ func ContractInterfaceFromString(s string) ContractInterface { return NftItem case "nft_item_simple": return NftItemSimple + case "nft_offer_getgems_v1": + return NftOfferGetgemsV1 case "nft_sale": return NftSale case "nft_sale_getgems_v2": return NftSaleGetgemsV2 case "nft_sale_getgems_v3": return NftSaleGetgemsV3 + case "nft_sale_getgems_v4": + return NftSaleGetgemsV4 case "nft_sale_v1": return NftSaleV1 case "nft_sale_v2": @@ -462,6 +472,10 @@ var methodInvocationOrder = []MethodDescription{ Name: "get_executor_vaults_whitelist", InvokeFn: GetExecutorVaultsWhitelist, }, + { + Name: "get_fix_price_data_v4", + InvokeFn: GetFixPriceDataV4, + }, { Name: "get_full_domain", InvokeFn: GetFullDomain, @@ -1160,6 +1174,16 @@ var knownContracts = map[ton.Bits256]knownContractDescription{ GetSaleData, }, }, + ton.MustParseHash("6b95a6418b9c9d2359045d1e7559b8d549ae0e506f24caab58fa30c8fb1feb86"): { + contractInterfaces: []ContractInterface{NftSaleGetgemsV4}, + getMethods: []InvokeFn{ + GetFixPriceDataV4, + }, + }, + ton.MustParseHash("6e5d667fa6efa8187c6d029efd4015601232fd2e36c291dbc346dedab6dc8024"): { + contractInterfaces: []ContractInterface{NftOfferGetgemsV1}, + getMethods: []InvokeFn{}, + }, ton.MustParseHash("8278f4c5233de6fbedc969af519344a7a9bffc544856dba986a95c0bcf8571c9"): { contractInterfaces: []ContractInterface{NftSaleGetgemsV2}, getMethods: []InvokeFn{ diff --git a/abi/schemas/nft_sale.xml b/abi/schemas/nft_sale.xml index 876146b1..12829ed2 100644 --- a/abi/schemas/nft_sale.xml +++ b/abi/schemas/nft_sale.xml @@ -10,6 +10,25 @@ + + 6e5d667fa6efa8187c6d029efd4015601232fd2e36c291dbc346dedab6dc8024 + + + 6b95a6418b9c9d2359045d1e7559b8d549ae0e506f24caab58fa30c8fb1feb86 + + Already sold or cancelled + Mode 32 not allowed + Can't execute command at this time + Inconsistent price and fees + Inconsistent price and fees + Inconsistent price and fees + Unauthorized initiation + Invalid op, expected ownership_assigned + Not enough TONs for sale + Not enough TONs for cancellation + Unauthorized cancellation + Unknown operation + 24221fa571e542e055c77bedfdbf527c7af460cfdc7f344c450787b4cfa1eb4d deb53b6c5765c1e6cd238bf47bc5e83ba596bdcc04b0b84cd50ab1e474a08f31 @@ -52,6 +71,23 @@ Auction in progress Unknown operation + + + bool + uint32 + msgaddress + msgaddress + msgaddress + int257 + msgaddress + uint32 + msgaddress + uint32 + uint32 + uint64 + cell + + msgaddress