diff --git a/macros/udfs/create_udtf_call_contract_block_height.yml b/macros/udfs/create_udtf_call_contract_block_height.yml new file mode 100644 index 0000000..b8a8167 --- /dev/null +++ b/macros/udfs/create_udtf_call_contract_block_height.yml @@ -0,0 +1,19 @@ +version: 2 + +macros: + - name: create_UDTF_CALL_CONTRACT_FUNCTION_BY_HEIGHT + description: Creates the Snowflake function `UDTF_CALL_CONTRACT_FUNCTION` with a height parameter input + arguments: + - name: CONTRACT_ADDRESS + type: string + description: The contract address to call a function on, also called `account_id` in the Near docs. + - name: METHOD_NAME + type: string + description: The method to call, refer to the deployed contract or Nearblocks.io + - name: ARGS + type: object + description: The parameters to pass to the method call. + - name: BLOCK_ID + type: number + description: The block height at which to call the method. + \ No newline at end of file diff --git a/macros/udfs/create_udtf_call_contract_finality.yml b/macros/udfs/create_udtf_call_contract_finality.yml new file mode 100644 index 0000000..3881831 --- /dev/null +++ b/macros/udfs/create_udtf_call_contract_finality.yml @@ -0,0 +1,15 @@ +version: 2 + +macros: + - name: create_UDTF_CALL_CONTRACT_FUNCTION + description: Creates the Snowflake function `UDTF_CALL_CONTRACT_FUNCTION` assuming `final` finality. See the documentation overview page for links to NEAR docs. + arguments: + - name: CONTRACT_ADDRESS + type: string + description: The contract address to call a function on, also called `account_id` in the Near docs. + - name: METHOD_NAME + type: string + description: The method to call, refer to the deployed contract or Nearblocks.io + - name: ARGS + type: object + description: The parameters to pass to the method call. diff --git a/models/descriptions/__overview__.md b/models/descriptions/__overview__.md index 9e64c41..9181331 100644 --- a/models/descriptions/__overview__.md +++ b/models/descriptions/__overview__.md @@ -54,22 +54,26 @@ There is more information on how to use dbt docs in the last section of this doc - [github_activity](https://github.com/forgxyz/developer_report_near) ### Custom Functions -- `NEAR`.`CORE`.`UDTF_CALL_CONTRACT_FUNCTION` +- `NEAR`.`CORE`.`UDTF_CALL_CONTRACT_FUNCTION` + Call a contract method via the [public NEAR RPC endpoint](https://docs.near.org/api/rpc/setup), modeled after the official documentation, [here](https://docs.near.org/api/rpc/contracts#call-a-contract-function). This function accepts 3 or 4 parameters: - - (required) `account_id` STR + - `account_id` STR (required) - This is the deployed contract_address you want to call. - - (required) `method_name` STR + + - `method_name` STR (required) - This is the method on the contract to call. - - (required) `args` OBJ + + - `args` OBJ (required) - Any requred or optional input parameters that the contract method accepts. - For best results, this should be formed by using the Snowflake function [`OBJECT_CONSTRUCT()`](https://docs.snowflake.com/en/sql-reference/functions/object_construct) -- (optional) `block_id` INT + +- `block_id` INT (optional) - Pass a block height (note - hash not accepted) to call the method at a certain block in time. - If nothing is passed, the default behavior is `final` per the explanation [here](https://docs.near.org/api/rpc/setup#using-finality-param). - Note - when passing in a block id parameter, the archive node is called which may be considerably slower than the primary access node. - + **Important Note** - this is the public access endpoint, use responsibly.