From 0f466bb2794fccba9afdb19de1948a84d4166aa0 Mon Sep 17 00:00:00 2001 From: josemarinas <36479864+josemarinas@users.noreply.github.com> Date: Tue, 21 Feb 2023 14:02:28 +0100 Subject: [PATCH] Fix: Add transfer to available functions (#161) * add transfer to available functions * update changelog and package.json * update subgraph url --- modules/client/CHANGELOG.md | 4 ++++ modules/client/package.json | 2 +- modules/client/src/internal/constants.ts | 4 ++++ .../test/integration/client/decoding.test.ts | 20 +++++++++++++++++++ modules/client/test/integration/constants.ts | 2 +- 5 files changed, 30 insertions(+), 2 deletions(-) diff --git a/modules/client/CHANGELOG.md b/modules/client/CHANGELOG.md index adf11f0ce..6da933738 100644 --- a/modules/client/CHANGELOG.md +++ b/modules/client/CHANGELOG.md @@ -13,6 +13,10 @@ TEMPLATE: --> +## [0.21.2-beta] +### Fixed +- Add `transfer` to available functions + ## [0.21.1-beta] ### Fixed - `startDate` and `endDate` swapped on `getProposal` funtion of the multisig client diff --git a/modules/client/package.json b/modules/client/package.json index 01965558b..38cb1d29c 100644 --- a/modules/client/package.json +++ b/modules/client/package.json @@ -1,7 +1,7 @@ { "name": "@aragon/sdk-client", "author": "Aragon Association", - "version": "0.21.1-beta", + "version": "0.21.2-beta", "license": "MIT", "main": "dist/index.js", "module": "dist/sdk-client.esm.js", diff --git a/modules/client/src/internal/constants.ts b/modules/client/src/internal/constants.ts index 2de6cd98d..b69c98a4a 100644 --- a/modules/client/src/internal/constants.ts +++ b/modules/client/src/internal/constants.ts @@ -1,7 +1,11 @@ import { DAO__factory } from "@aragon/core-contracts-ethers"; +import { AddressZero } from "@ethersproject/constants"; +import { Contract } from "@ethersproject/contracts"; import { DaoMetadata } from "../interfaces"; +import { erc20ContractAbi } from "./abi/erc20"; export const AVAILABLE_FUNCTION_SIGNATURES: string[] = [ + new Contract(AddressZero, erc20ContractAbi).interface.getFunction("transfer").format("minimal"), DAO__factory.createInterface().getFunction("grant").format("minimal"), DAO__factory.createInterface().getFunction("grantWithCondition").format("minimal"), DAO__factory.createInterface().getFunction("revoke").format("minimal"), diff --git a/modules/client/test/integration/client/decoding.test.ts b/modules/client/test/integration/client/decoding.test.ts index ad5864dbe..4be607a4e 100644 --- a/modules/client/test/integration/client/decoding.test.ts +++ b/modules/client/test/integration/client/decoding.test.ts @@ -271,6 +271,26 @@ describe("Client", () => { expect(iface?.hash).toBe("0xee57e36f"); }); + it("Should get the function for a withdraw action data", async () => { + const context = new Context(contextParamsLocalChain); + const client = new Client(context); + const params: WithdrawParams = { + type: TokenType.ERC20, + amount: BigInt(1), + tokenAddress: "0x1234567890123456789012345678901234567890", + recipientAddressOrEns: "0x2345678901234567890123456789012345678901" + }; + + const updateDaoMetadataAction = await client.encoding + .withdrawAction( + params, + ); + const iface = client.decoding.findInterface(updateDaoMetadataAction.data); + expect(iface?.id).toBe("function transfer(address,uint256) returns (bool)"); + expect(iface?.functionName).toBe("transfer"); + expect(iface?.hash).toBe("0xa9059cbb"); + }); + it("Should try to get the function of an invalid data and return null", async () => { const context = new Context(contextParamsLocalChain); const client = new Client(context); diff --git a/modules/client/test/integration/constants.ts b/modules/client/test/integration/constants.ts index 888c681e3..ee46a70db 100644 --- a/modules/client/test/integration/constants.ts +++ b/modules/client/test/integration/constants.ts @@ -39,7 +39,7 @@ const grapqhlEndpoints = { working: [ { url: - "https://subgraph.satsuma-prod.com/qHR2wGfc5RLi6/aragon/core-goerli/version/v0.9.1-alpha-old-contr-sig/api", + "https://subgraph.satsuma-prod.com/qHR2wGfc5RLi6/aragon/core-goerli/api", }, ], failing: [{ url: "https://bad-url-gateway.io/" }],