diff --git a/docker-compose.yml b/docker-compose.yml index 18592e8..ad19462 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,7 +2,7 @@ version: '3.7' services: ajna-testnet: - image: ghcr.io/builtbymom/ajna-testnet:rc10 + image: ghcr.io/builtbymom/ajna-testnet:v0.1.0.rc10 ports: - 8555:8555 container_name: ajna-testnet-sdk diff --git a/package.json b/package.json index aa13c8c..e3179d3 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@ajna-finance/sdk", "description": "A typescript SDK that can be used to create Dapps in Ajna ecosystem.", - "version": "0.4.0", + "version": "0.4.1", "repository": { "type": "git", "url": "https://github.com/ajna-finance/sdk.git" diff --git a/src/abis/AjnaLenderHelper.json b/src/abis/AjnaLenderHelper.json index 467189b..755f9f6 100644 --- a/src/abis/AjnaLenderHelper.json +++ b/src/abis/AjnaLenderHelper.json @@ -1,176 +1,84 @@ [ { - "inputs": [], - "name": "BucketIndexOutOfBounds", - "type": "error" - }, - { - "inputs": [], - "name": "InsufficientLP", - "type": "error" + "type": "function", + "name": "addQuoteToken", + "inputs": [ + { "name": "pool_", "type": "address", "internalType": "address" }, + { "name": "maxAmount_", "type": "uint256", "internalType": "uint256" }, + { "name": "index_", "type": "uint256", "internalType": "uint256" }, + { "name": "expiry_", "type": "uint256", "internalType": "uint256" } + ], + "outputs": [ + { "name": "bucketLP_", "type": "uint256", "internalType": "uint256" }, + { "name": "addedAmount_", "type": "uint256", "internalType": "uint256" } + ], + "stateMutability": "nonpayable" }, { + "type": "function", + "name": "moveQuoteToken", "inputs": [ + { "name": "pool_", "type": "address", "internalType": "address" }, + { "name": "maxAmount_", "type": "uint256", "internalType": "uint256" }, + { "name": "fromIndex_", "type": "uint256", "internalType": "uint256" }, + { "name": "toIndex_", "type": "uint256", "internalType": "uint256" }, + { "name": "expiry_", "type": "uint256", "internalType": "uint256" } + ], + "outputs": [ { - "internalType": "int256", - "name": "x", - "type": "int256" - } + "name": "fromBucketRedeemedLP_", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "toBucketAwardedLP_", + "type": "uint256", + "internalType": "uint256" + }, + { "name": "movedAmount_", "type": "uint256", "internalType": "uint256" } ], + "stateMutability": "nonpayable" + }, + { "type": "error", "name": "BucketIndexOutOfBounds", "inputs": [] }, + { "type": "error", "name": "InsufficientLP", "inputs": [] }, + { + "type": "error", "name": "PRBMathSD59x18__Exp2InputTooBig", - "type": "error" + "inputs": [{ "name": "x", "type": "int256", "internalType": "int256" }] }, { - "inputs": [ - { - "internalType": "int256", - "name": "x", - "type": "int256" - } - ], + "type": "error", "name": "PRBMathSD59x18__FromIntOverflow", - "type": "error" + "inputs": [{ "name": "x", "type": "int256", "internalType": "int256" }] }, { - "inputs": [ - { - "internalType": "int256", - "name": "x", - "type": "int256" - } - ], + "type": "error", "name": "PRBMathSD59x18__FromIntUnderflow", - "type": "error" + "inputs": [{ "name": "x", "type": "int256", "internalType": "int256" }] }, { - "inputs": [ - { - "internalType": "int256", - "name": "x", - "type": "int256" - } - ], + "type": "error", "name": "PRBMathSD59x18__LogInputTooSmall", - "type": "error" + "inputs": [{ "name": "x", "type": "int256", "internalType": "int256" }] }, { - "inputs": [], + "type": "error", "name": "PRBMathSD59x18__MulInputTooSmall", - "type": "error" + "inputs": [] }, { - "inputs": [ - { - "internalType": "uint256", - "name": "rAbs", - "type": "uint256" - } - ], + "type": "error", "name": "PRBMathSD59x18__MulOverflow", - "type": "error" + "inputs": [{ "name": "rAbs", "type": "uint256", "internalType": "uint256" }] }, { - "inputs": [ - { - "internalType": "uint256", - "name": "prod1", - "type": "uint256" - } - ], + "type": "error", "name": "PRBMath__MulDivFixedPointOverflow", - "type": "error" + "inputs": [{ "name": "prod1", "type": "uint256", "internalType": "uint256" }] }, { - "inputs": [], + "type": "error", "name": "RoundedAmountExceededRequestedMaximum", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "pool_", - "type": "address" - }, - { - "internalType": "uint256", - "name": "maxAmount_", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "index_", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "expiry_", - "type": "uint256" - } - ], - "name": "addQuoteToken", - "outputs": [ - { - "internalType": "uint256", - "name": "bucketLP_", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "addedAmount_", - "type": "uint256" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "pool_", - "type": "address" - }, - { - "internalType": "uint256", - "name": "maxAmount_", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "fromIndex_", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "toIndex_", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "expiry_", - "type": "uint256" - } - ], - "name": "moveQuoteToken", - "outputs": [ - { - "internalType": "uint256", - "name": "fromBucketRedeemedLP_", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "toBucketAwardedLP_", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "movedAmount_", - "type": "uint256" - } - ], - "stateMutability": "nonpayable", - "type": "function" + "inputs": [] } ] diff --git a/src/types/contracts/factories/AjnaLenderHelper__factory.ts b/src/types/contracts/factories/AjnaLenderHelper__factory.ts index e3ae050..07b5c26 100644 --- a/src/types/contracts/factories/AjnaLenderHelper__factory.ts +++ b/src/types/contracts/factories/AjnaLenderHelper__factory.ts @@ -8,178 +8,178 @@ import type { AjnaLenderHelper, AjnaLenderHelperInterface } from '../AjnaLenderH const _abi = [ { - inputs: [], - name: 'BucketIndexOutOfBounds', - type: 'error', - }, - { - inputs: [], - name: 'InsufficientLP', - type: 'error', - }, - { - inputs: [ - { - internalType: 'int256', - name: 'x', - type: 'int256', - }, - ], - name: 'PRBMathSD59x18__Exp2InputTooBig', - type: 'error', - }, - { - inputs: [ - { - internalType: 'int256', - name: 'x', - type: 'int256', - }, - ], - name: 'PRBMathSD59x18__FromIntOverflow', - type: 'error', - }, - { - inputs: [ - { - internalType: 'int256', - name: 'x', - type: 'int256', - }, - ], - name: 'PRBMathSD59x18__FromIntUnderflow', - type: 'error', - }, - { - inputs: [ - { - internalType: 'int256', - name: 'x', - type: 'int256', - }, - ], - name: 'PRBMathSD59x18__LogInputTooSmall', - type: 'error', - }, - { - inputs: [], - name: 'PRBMathSD59x18__MulInputTooSmall', - type: 'error', - }, - { - inputs: [ - { - internalType: 'uint256', - name: 'rAbs', - type: 'uint256', - }, - ], - name: 'PRBMathSD59x18__MulOverflow', - type: 'error', - }, - { - inputs: [ - { - internalType: 'uint256', - name: 'prod1', - type: 'uint256', - }, - ], - name: 'PRBMath__MulDivFixedPointOverflow', - type: 'error', - }, - { - inputs: [], - name: 'RoundedAmountExceededRequestedMaximum', - type: 'error', - }, - { + type: 'function', + name: 'addQuoteToken', inputs: [ { - internalType: 'address', name: 'pool_', type: 'address', + internalType: 'address', }, { - internalType: 'uint256', name: 'maxAmount_', type: 'uint256', + internalType: 'uint256', }, { - internalType: 'uint256', name: 'index_', type: 'uint256', + internalType: 'uint256', }, { - internalType: 'uint256', name: 'expiry_', type: 'uint256', + internalType: 'uint256', }, ], - name: 'addQuoteToken', outputs: [ { - internalType: 'uint256', name: 'bucketLP_', type: 'uint256', + internalType: 'uint256', }, { - internalType: 'uint256', name: 'addedAmount_', type: 'uint256', + internalType: 'uint256', }, ], stateMutability: 'nonpayable', - type: 'function', }, { + type: 'function', + name: 'moveQuoteToken', inputs: [ { - internalType: 'address', name: 'pool_', type: 'address', + internalType: 'address', }, { - internalType: 'uint256', name: 'maxAmount_', type: 'uint256', + internalType: 'uint256', }, { - internalType: 'uint256', name: 'fromIndex_', type: 'uint256', + internalType: 'uint256', }, { - internalType: 'uint256', name: 'toIndex_', type: 'uint256', + internalType: 'uint256', }, { - internalType: 'uint256', name: 'expiry_', type: 'uint256', + internalType: 'uint256', }, ], - name: 'moveQuoteToken', outputs: [ { - internalType: 'uint256', name: 'fromBucketRedeemedLP_', type: 'uint256', + internalType: 'uint256', }, { - internalType: 'uint256', name: 'toBucketAwardedLP_', type: 'uint256', + internalType: 'uint256', }, { - internalType: 'uint256', name: 'movedAmount_', type: 'uint256', + internalType: 'uint256', }, ], stateMutability: 'nonpayable', - type: 'function', + }, + { + type: 'error', + name: 'BucketIndexOutOfBounds', + inputs: [], + }, + { + type: 'error', + name: 'InsufficientLP', + inputs: [], + }, + { + type: 'error', + name: 'PRBMathSD59x18__Exp2InputTooBig', + inputs: [ + { + name: 'x', + type: 'int256', + internalType: 'int256', + }, + ], + }, + { + type: 'error', + name: 'PRBMathSD59x18__FromIntOverflow', + inputs: [ + { + name: 'x', + type: 'int256', + internalType: 'int256', + }, + ], + }, + { + type: 'error', + name: 'PRBMathSD59x18__FromIntUnderflow', + inputs: [ + { + name: 'x', + type: 'int256', + internalType: 'int256', + }, + ], + }, + { + type: 'error', + name: 'PRBMathSD59x18__LogInputTooSmall', + inputs: [ + { + name: 'x', + type: 'int256', + internalType: 'int256', + }, + ], + }, + { + type: 'error', + name: 'PRBMathSD59x18__MulInputTooSmall', + inputs: [], + }, + { + type: 'error', + name: 'PRBMathSD59x18__MulOverflow', + inputs: [ + { + name: 'rAbs', + type: 'uint256', + internalType: 'uint256', + }, + ], + }, + { + type: 'error', + name: 'PRBMath__MulDivFixedPointOverflow', + inputs: [ + { + name: 'prod1', + type: 'uint256', + internalType: 'uint256', + }, + ], + }, + { + type: 'error', + name: 'RoundedAmountExceededRequestedMaximum', + inputs: [], }, ] as const; diff --git a/src/utils/transactions.ts b/src/utils/transactions.ts index bcd6e55..77557ef 100644 --- a/src/utils/transactions.ts +++ b/src/utils/transactions.ts @@ -171,6 +171,17 @@ class WrappedTransactionClass implements WrappedTransaction { ); } + // hardhat + if (error?.error?.data?.data?.data) { + const errorHash = error.error.data.data.data; + + return ( + this.getCustomErrorFromHash(contract, errorHash) ?? + error.error.data?.cause ?? + error.error.data?.message + ); + } + // works with some L2 chains (Base, Polygon, Optimism) if (error?.error?.data) { const errorHash = error.error.data.data;