onflow / flow-interaction-template-service

https://flix.flow.com
Apache License 2.0
11 stars 4 forks source link

Adds ability to search for templates by title/description messages. #28

Open JeffreyDoyle opened 8 months ago

JeffreyDoyle commented 8 months ago

Adds ability to search for templates by title/description messages.

eg:

POST /v2/templates/search/messages

Body: 
{
    "searchMessagesTitleENUS": "tokens",
    "searchMessagesDescriptionENUS": "transfer"
}

returns:

{
    "page": 0,
    "range": 100,
    "count": 1,
    "results": [
        {
            "f_type": "InteractionTemplate",
            "f_version": "1.0.0",
            "id": "290b6b6222b2a77b16db896a80ddf29ebd1fa3038c9e6625a933fa213fce51fa",
            "data": {
                "type": "transaction",
                "interface": "",
                "messages": {
                    "title": {
                        "i18n": {
                            "en-US": "Transfer Tokens"
                        }
                    },
                    "description": {
                        "i18n": {
                            "en-US": "Transfer tokens from one account to another"
                        }
                    }
                },
                "cadence": "import FungibleToken from 0xFUNGIBLETOKENADDRESS\ntransaction(amount: UFix64, to: Address) {\nlet vault: @FungibleToken.Vault\nprepare(signer: AuthAccount) {\nself.vault <- signer\n.borrow<&{FungibleToken.Provider}>(from: /storage/flowTokenVault)!\n.withdraw(amount: amount)\n}\nexecute {\ngetAccount(to)\n.getCapability(/public/flowTokenReceiver)!\n.borrow<&{FungibleToken.Receiver}>()!\n.deposit(from: <-self.vault)\n}\n}",
                "dependencies": {
                    "0xFUNGIBLETOKENADDRESS": {
                        "FungibleToken": {
                            "mainnet": {
                                "address": "0xf233dcee88fe0abe",
                                "fq_address": "A.0xf233dcee88fe0abe.FungibleToken",
                                "contract": "FungibleToken",
                                "pin": "83c9e3d61d3b5ebf24356a9f17b5b57b12d6d56547abc73e05f820a0ae7d9cf5",
                                "pin_block_height": 34166296
                            },
                            "testnet": {
                                "address": "0x9a0766d93b6608b7",
                                "fq_address": "A.0x9a0766d93b6608b7.FungibleToken",
                                "contract": "FungibleToken",
                                "pin": "83c9e3d61d3b5ebf24356a9f17b5b57b12d6d56547abc73e05f820a0ae7d9cf5",
                                "pin_block_height": 74776482
                            }
                        }
                    }
                },
                "arguments": {
                    "amount": {
                        "index": 0,
                        "type": "UFix64",
                        "messages": {
                            "title": {
                                "i18n": {
                                    "en-US": "The amount of FLOW tokens to send"
                                }
                            }
                        },
                        "balance": ""
                    },
                    "to": {
                        "index": 1,
                        "type": "Address",
                        "messages": {
                            "title": {
                                "i18n": {
                                    "en-US": "The Flow account the tokens will go to"
                                }
                            }
                        },
                        "balance": ""
                    }
                }
            }
        }
    ]
}
vercel[bot] commented 8 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
flow-interaction-template-service ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 18, 2023 10:56pm
chasefleming commented 8 months ago

@JeffreyDoyle this also needs documentation on the readme or something

bthaile commented 8 months ago

Vercel preview link doesn't work. Is it suppose to?

chasefleming commented 8 months ago

Also, is there a library you can use to make search better? Exact text match does not seem ideal. Tagging may be a better option since search is hard.