Skip to content

Commit

Permalink
add new gg contracts
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-tron committed Jan 29, 2025
1 parent 353341e commit d2d63ee
Show file tree
Hide file tree
Showing 4 changed files with 121 additions and 0 deletions.
13 changes: 13 additions & 0 deletions abi/contracts_errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
48 changes: 48 additions & 0 deletions abi/get_methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -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},
Expand Down Expand Up @@ -227,6 +229,7 @@ var resultTypes = []interface{}{
&GetExecutorCollectionAddress_StormResult{},
&GetExecutorVaultsWhitelist_StormResult{},
&GetExpectedOutputs_StonfiResult{},
&GetFixPriceDataV4Result{},
&GetFullDomainResult{},
&GetJettonDataResult{},
&GetLastCleanTimeResult{},
Expand Down Expand Up @@ -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
}
Expand Down
24 changes: 24 additions & 0 deletions abi/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@ const (
NftCollection
NftItem
NftItemSimple
NftOfferGetgemsV1
NftSale
NftSaleGetgemsV2
NftSaleGetgemsV3
NftSaleGetgemsV4
NftSaleV1
NftSaleV2
PaymentChannel
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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":
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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{
Expand Down
36 changes: 36 additions & 0 deletions abi/schemas/nft_sale.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,25 @@
<interface name="nft_auction_v1" inherits="nft_sale">
<get_method name="get_sale_data" version="getgems_auction"/>
</interface>
<interface name="nft_offer_getgems_v1">
<code_hash>6e5d667fa6efa8187c6d029efd4015601232fd2e36c291dbc346dedab6dc8024</code_hash>
</interface>
<interface name="nft_sale_getgems_v4">
<code_hash>6b95a6418b9c9d2359045d1e7559b8d549ae0e506f24caab58fa30c8fb1feb86</code_hash>
<get_method name="get_fix_price_data_v4"/>
<error code="404">Already sold or cancelled</error>
<error code="405">Mode 32 not allowed</error>
<error code="406">Can't execute command at this time</error>
<error code="408">Inconsistent price and fees</error>
<error code="409">Inconsistent price and fees</error>
<error code="410">Inconsistent price and fees</error>
<error code="500">Unauthorized initiation</error>
<error code="501">Invalid op, expected ownership_assigned</error>
<error code="450">Not enough TONs for sale</error>
<error code="457">Not enough TONs for cancellation</error>
<error code="458">Unauthorized cancellation</error>
<error code="65535">Unknown operation</error>
</interface>
<interface name="nft_sale_getgems_v3" inherits="nft_sale_v2">
<code_hash>24221fa571e542e055c77bedfdbf527c7af460cfdc7f344c450787b4cfa1eb4d</code_hash> <!-- https://github.com/getgems-io/nft-contracts/blob/main/packages%2Fcontracts%2Fsources%2Fnft-fixprice-sale-v3r3.fc -->
<code_hash>deb53b6c5765c1e6cd238bf47bc5e83ba596bdcc04b0b84cd50ab1e474a08f31</code_hash> <!-- https://github.com/getgems-io/nft-contracts/blob/main/packages%2Fcontracts%2Fsources%2Fnft-fixprice-sale-v3r2.fc -->
Expand Down Expand Up @@ -52,6 +71,23 @@
<error code="1010">Auction in progress</error>
<error code="65535">Unknown operation</error>
</interface>
<get_method name="get_fix_price_data_v4">
<output fixed_length="true">
<int name="is_complete">bool</int>
<int name="created_at">uint32</int>
<slice name="marketplace_address">msgaddress</slice>
<slice name="nft_address">msgaddress</slice>
<slice name="nft_owner_address" nullable="true">msgaddress</slice>
<int name="full_price">int257</int>
<slice name="fee_address">msgaddress</slice>
<int name="fee_percent">uint32</int>
<slice name="royalty_address">msgaddress</slice>
<int name="royalty_percent">uint32</int>
<int name="sold_at">uint32</int>
<int name="sold_query_id">uint64</int>
<cell name="jetton_price_dict" nullable="true">cell</cell>
</output>
</get_method>
<get_method name="get_sale_data">
<output version="basic" fixed_length="true">
<slice name="marketplace">msgaddress</slice>
Expand Down

0 comments on commit d2d63ee

Please sign in to comment.