From 0230e9d37847b9cf865e4c8538f73fee36c1d3fe Mon Sep 17 00:00:00 2001 From: Rohan Agarwal Date: Fri, 18 Oct 2024 15:56:05 -0700 Subject: [PATCH 1/5] Hotfix for readContract --- src/coinbase/read_contract.ts | 4 ++-- src/coinbase/types/contract.ts | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/coinbase/read_contract.ts b/src/coinbase/read_contract.ts index 4cf3fb79..3eaa1bd9 100644 --- a/src/coinbase/read_contract.ts +++ b/src/coinbase/read_contract.ts @@ -114,7 +114,7 @@ function parseSolidityValue(solidityValue: SolidityValue): T { export async function readContract< TAbi extends Abi | undefined, TFunctionName extends TAbi extends Abi ? ContractFunctionName : string, - TArgs extends Record, + TArgs extends Record, >(params: { networkId: string; contractAddress: `0x${string}`; @@ -128,7 +128,7 @@ export async function readContract< Extract>, TArgs > - : unknown + : any > { const response = await Coinbase.apiClients.smartContract!.readContract( params.networkId, diff --git a/src/coinbase/types/contract.ts b/src/coinbase/types/contract.ts index dce02174..4b739d19 100644 --- a/src/coinbase/types/contract.ts +++ b/src/coinbase/types/contract.ts @@ -12,7 +12,7 @@ import { ContractFunctionName } from "viem"; * Each parameter name becomes a key in the resulting dictionary, with a string value. */ type AbiParametersToDictionary = { - [K in T[number]["name"] as K extends string ? K : never]: string; + [K in T[number]["name"] as K extends string ? K : any]: string; }; /** @@ -38,9 +38,9 @@ type MatchArgsToFunction< ? TFunctions extends AbiFunction ? MatchesParams> extends true ? TFunctions - : never - : never - : never; + : any + : any + : any; /** * Determines the return type of a contract function based on the ABI, function name, and arguments. @@ -68,6 +68,6 @@ export type ContractFunctionReturnType< : TOutputs extends readonly [infer TOutput] ? TOutput : TOutputs - : never - : unknown - : unknown; + : any + : any + : any; From c5f7f381429ab0a07da5bc88d3e9fa539e4ef747 Mon Sep 17 00:00:00 2001 From: Rohan Agarwal Date: Fri, 18 Oct 2024 18:16:37 -0700 Subject: [PATCH 2/5] Changelog, bump version --- CHANGELOG.md | 5 +++++ package.json | 2 +- quickstart-template/package.json | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 98d69a30..f28b95b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ ## Unreleased +## [0.9.1] - 2024-10-18 + +### Fixed +- Fixed a bug where readContract was not working for nested types + ## [0.9.0] - 2024-10-17 ### Added diff --git a/package.json b/package.json index fc3c4760..81255375 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "license": "ISC", "description": "Coinbase Platform SDK", "repository": "https://github.com/coinbase/coinbase-sdk-nodejs", - "version": "0.9.0", + "version": "0.9.1", "main": "dist/index.js", "types": "dist/index.d.ts", "scripts": { diff --git a/quickstart-template/package.json b/quickstart-template/package.json index 1fa4b042..43884c1d 100644 --- a/quickstart-template/package.json +++ b/quickstart-template/package.json @@ -22,7 +22,7 @@ "dependencies": { "@solana/web3.js": "^2.0.0-rc.1", "bs58": "^6.0.0", - "@coinbase/coinbase-sdk": "^0.9.0", + "@coinbase/coinbase-sdk": "^0.9.1", "csv-parse": "^5.5.6", "csv-writer": "^1.6.0", "viem": "^2.21.6" From 5870b695ce62622c86e40d4cb201e34512c9b588 Mon Sep 17 00:00:00 2001 From: Rohan Agarwal Date: Fri, 18 Oct 2024 18:20:07 -0700 Subject: [PATCH 3/5] Fix --- src/coinbase/read_contract.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/coinbase/read_contract.ts b/src/coinbase/read_contract.ts index 3eaa1bd9..7af4ec53 100644 --- a/src/coinbase/read_contract.ts +++ b/src/coinbase/read_contract.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ import type { Abi } from "abitype"; import { Coinbase } from "./coinbase"; import { ContractFunctionName } from "viem"; @@ -109,7 +110,7 @@ function parseSolidityValue(solidityValue: SolidityValue): T { * @param {TFunctionName} params.method - The contract method to call. * @param {TArgs} params.args - The arguments for the contract method. * @param {TAbi} [params.abi] - The contract ABI (optional). - * @returns {Promise} The result of the contract call. + * @returns {Promise} The result of the contract call. */ export async function readContract< TAbi extends Abi | undefined, From 2cf0726be661d3f6e63365c4addc4177dc493acf Mon Sep 17 00:00:00 2001 From: Rohan Agarwal Date: Fri, 18 Oct 2024 18:25:57 -0700 Subject: [PATCH 4/5] Change to any --- src/coinbase/read_contract.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/coinbase/read_contract.ts b/src/coinbase/read_contract.ts index 7af4ec53..a52cc845 100644 --- a/src/coinbase/read_contract.ts +++ b/src/coinbase/read_contract.ts @@ -110,7 +110,7 @@ function parseSolidityValue(solidityValue: SolidityValue): T { * @param {TFunctionName} params.method - The contract method to call. * @param {TArgs} params.args - The arguments for the contract method. * @param {TAbi} [params.abi] - The contract ABI (optional). - * @returns {Promise} The result of the contract call. + * @returns {Promise>, TArgs> : unknown>} The result of the contract call. */ export async function readContract< TAbi extends Abi | undefined, @@ -148,6 +148,6 @@ export async function readContract< Extract>, TArgs > - : unknown + : any >(response.data); } From e908c9f56c63d841b916404f753d189406d3eda7 Mon Sep 17 00:00:00 2001 From: Rohan Agarwal Date: Fri, 18 Oct 2024 18:26:30 -0700 Subject: [PATCH 5/5] docs --- src/coinbase/read_contract.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coinbase/read_contract.ts b/src/coinbase/read_contract.ts index a52cc845..6e5691cb 100644 --- a/src/coinbase/read_contract.ts +++ b/src/coinbase/read_contract.ts @@ -110,7 +110,7 @@ function parseSolidityValue(solidityValue: SolidityValue): T { * @param {TFunctionName} params.method - The contract method to call. * @param {TArgs} params.args - The arguments for the contract method. * @param {TAbi} [params.abi] - The contract ABI (optional). - * @returns {Promise>, TArgs> : unknown>} The result of the contract call. + * @returns {Promise} The result of the contract call. */ export async function readContract< TAbi extends Abi | undefined,