diff --git a/CHANGELOG.md b/CHANGELOG.md
index b6ecf44..c46c4f1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,10 @@
# Changelog
+## [0.7.5] - 2024-02-21
+
+### Added Changes
+- Added missing `tokenDecimals` param to `` and `` components
+
## [0.7.4] - 2024-02-20
### Added Changes
diff --git a/__tests__/components/EtherspotApprovalTransaction.test.js b/__tests__/components/EtherspotApprovalTransaction.test.js
index c00a14a..4e3406f 100644
--- a/__tests__/components/EtherspotApprovalTransaction.test.js
+++ b/__tests__/components/EtherspotApprovalTransaction.test.js
@@ -69,7 +69,13 @@ describe('EtherspotApprovalTransaction', () => {
+
@@ -80,8 +86,9 @@ describe('EtherspotApprovalTransaction', () => {
const { result: { current } } = renderHook(() => useEtherspotTransactions(), { wrapper });
expect(current.batches[0].batches[0].transactions[0].to).toBe('0xe3818504c1b32bf1557b16c238b2e01fd3149c17');
- expect(current.batches[0].batches[0].transactions[0].data).toBe('0x095ea7b30000000000000000000000007f30b1960d5556929b03a0339814fe903c55a347000000000000000000000000000000000000000000000006aaf7c8516d0c0000');
+ expect(current.batches[0].batches[0].transactions[0].data).toBe('0x095ea7b30000000000000000000000007f30b1960d5556929b03a0339814fe903c55a3470000000000000000000000000000000000000000000000000000011e61b68c00');
expect(current.batches[0].batches[0].transactions[0].value).toBe(undefined);
+ expect(current.batches[0].batches[0].transactions[1].data).toBe('0x095ea7b30000000000000000000000007f30b1960d5556929b03a0339814fe903c55a3470000000000000000000000000000000000000000000000000000011e61b68c00');
});
})
diff --git a/__tests__/components/EtherspotTokenTransferTransaction.test.js b/__tests__/components/EtherspotTokenTransferTransaction.test.js
index ff27914..0876780 100644
--- a/__tests__/components/EtherspotTokenTransferTransaction.test.js
+++ b/__tests__/components/EtherspotTokenTransferTransaction.test.js
@@ -74,7 +74,13 @@ describe('EtherspotTokenTransferTransaction', () => {
+
@@ -88,7 +94,8 @@ describe('EtherspotTokenTransferTransaction', () => {
await waitFor(() => expect(result.current.batches[0].batches[0].transactions[0]).not.toBe(undefined));
expect(result.current.batches[0].batches[0].transactions[0].to).toBe('0xe3818504c1b32bf1557b16c238b2e01fd3149c17');
- expect(result.current.batches[0].batches[0].transactions[0].data).toBe('0xa9059cbb0000000000000000000000007f30b1960d5556929b03a0339814fe903c55a347000000000000000000000000000000000000000000000006aaf7c8516d0c0000');
+ expect(result.current.batches[0].batches[0].transactions[0].data).toBe('0xa9059cbb0000000000000000000000007f30b1960d5556929b03a0339814fe903c55a3470000000000000000000000000000000000000000000000000000011e61b68c00');
expect(result.current.batches[0].batches[0].transactions[0].value).toBe(undefined);
+ expect(result.current.batches[0].batches[0].transactions[1].data).toBe('0xa9059cbb0000000000000000000000007f30b1960d5556929b03a0339814fe903c55a3470000000000000000000000000000000000000000000000000000011e61b68c00');
});
})
diff --git a/package-lock.json b/package-lock.json
index 1358071..0015b5c 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "@etherspot/transaction-kit",
- "version": "0.7.4",
+ "version": "0.7.5",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@etherspot/transaction-kit",
- "version": "0.7.4",
+ "version": "0.7.5",
"license": "MIT",
"dependencies": {
"@etherspot/eip1271-verification-util": "0.1.2",
diff --git a/package.json b/package.json
index 8ac2355..d9f4d8b 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"name": "@etherspot/transaction-kit",
"description": "React Etherspot Transaction Kit",
- "version": "0.7.4",
+ "version": "0.7.5",
"main": "dist/cjs/index.js",
"scripts": {
"rollup:build": "NODE_OPTIONS=--max-old-space-size=8192 rollup -c",
diff --git a/src/components/EtherspotApprovalTransaction.tsx b/src/components/EtherspotApprovalTransaction.tsx
index 6b1ab7d..0f98ff8 100644
--- a/src/components/EtherspotApprovalTransaction.tsx
+++ b/src/components/EtherspotApprovalTransaction.tsx
@@ -28,8 +28,9 @@ const EtherspotApprovalTransaction = ({
value,
tokenAddress,
receiverAddress,
- id: transactionId
-}: EtherspotApprovalTransactionProps) => {
+ id: transactionId,
+ tokenDecimals = 18,
+}: EtherspotApprovalTransactionProps): React.ReactNode => {
const context = useContext(EtherspotBatchContext);
const componentId = useId();
@@ -40,7 +41,7 @@ const EtherspotApprovalTransaction = ({
let valueBN;
try {
valueBN = typeof value === 'string' && !ethers.BigNumber.isBigNumber(value)
- ? ethers.utils.parseEther(value)
+ ? ethers.utils.parseUnits(value, tokenDecimals)
: value;
} catch (e) {
if (e instanceof Error && e?.message) {
diff --git a/src/components/EtherspotTokenTransferTransaction.tsx b/src/components/EtherspotTokenTransferTransaction.tsx
index a654d03..a5026aa 100644
--- a/src/components/EtherspotTokenTransferTransaction.tsx
+++ b/src/components/EtherspotTokenTransferTransaction.tsx
@@ -29,8 +29,9 @@ const EtherspotTokenTransferTransaction = ({
value,
tokenAddress,
receiverAddress,
- id: transactionId
-}: EtherspotTokenTransferTransactionProps): JSX.Element => {
+ id: transactionId,
+ tokenDecimals = 18,
+}: EtherspotTokenTransferTransactionProps): React.ReactNode => {
const context = useContext(EtherspotBatchContext);
const componentId = useId();
const senderAddress = useWalletAddress('etherspot-prime', context?.chainId);
@@ -42,7 +43,7 @@ const EtherspotTokenTransferTransaction = ({
let valueBN;
try {
valueBN = typeof value === 'string' && !ethers.BigNumber.isBigNumber(value)
- ? ethers.utils.parseEther(value)
+ ? ethers.utils.parseUnits(value, tokenDecimals)
: value;
} catch (e) {
if (e instanceof Error && e?.message) {
diff --git a/src/types/EtherspotTransactionKit.ts b/src/types/EtherspotTransactionKit.ts
index 14ba4ed..f3d1cb0 100644
--- a/src/types/EtherspotTransactionKit.ts
+++ b/src/types/EtherspotTransactionKit.ts
@@ -66,6 +66,7 @@ export interface IEtherspotTokenTransferTransaction {
value: BigNumberish;
tokenAddress: string;
receiverAddress: string;
+ tokenDecimals?: number;
}
export interface ISmartWalletAddress {
@@ -79,6 +80,7 @@ export interface IEtherspotApprovalTransaction {
value: BigNumberish;
tokenAddress: string;
receiverAddress: string;
+ tokenDecimals?: number;
}
export interface ISameChainSwapOffers {