@dynamic-labs/ethereum-core
Advanced tools
Comparing version 4.3.2 to 4.4.0
'use client' | ||
var version = "4.3.2"; | ||
var version = "4.4.0"; | ||
export { version }; |
{ | ||
"name": "@dynamic-labs/ethereum-core", | ||
"version": "4.3.2", | ||
"version": "4.4.0", | ||
"description": "Core package for utilities and types for viem", | ||
@@ -25,10 +25,10 @@ "author": "Dynamic Labs, Inc.", | ||
"viem": "^2.21.55", | ||
"@dynamic-labs/assert-package-version": "4.3.2", | ||
"@dynamic-labs/logger": "4.3.2", | ||
"@dynamic-labs/rpc-providers": "4.3.2", | ||
"@dynamic-labs/types": "4.3.2", | ||
"@dynamic-labs/utils": "4.3.2", | ||
"@dynamic-labs/wallet-book": "4.3.2", | ||
"@dynamic-labs/wallet-connector-core": "4.3.2" | ||
"@dynamic-labs/assert-package-version": "4.4.0", | ||
"@dynamic-labs/logger": "4.4.0", | ||
"@dynamic-labs/rpc-providers": "4.4.0", | ||
"@dynamic-labs/types": "4.4.0", | ||
"@dynamic-labs/utils": "4.4.0", | ||
"@dynamic-labs/wallet-book": "4.4.0", | ||
"@dynamic-labs/wallet-connector-core": "4.4.0" | ||
} | ||
} |
@@ -9,7 +9,14 @@ import { Account, Chain, PublicClient, Transport, WalletClient } from 'viem'; | ||
* @param toAddress - The address to send the balance to. | ||
* @param token - The token to send (optional) — for example, an ERC20 token. | ||
* @param token.address - The address of the token contract. | ||
* @param token.decimals - The decimals of the token (defaults to 18). | ||
* @returns The transaction hash of the sent transaction. | ||
*/ | ||
sendBalance({ amount, toAddress, }: { | ||
sendBalance({ amount, toAddress, token, }: { | ||
amount: string; | ||
toAddress: string; | ||
token?: { | ||
address: string; | ||
decimals?: number; | ||
}; | ||
}): Promise<`0x${string}`>; | ||
@@ -16,0 +23,0 @@ /** |
'use client' | ||
import { __awaiter } from '../../_virtual/_tslib.js'; | ||
import { parseEther, createWalletClient, custom } from 'viem'; | ||
import { getContract, parseUnits, parseEther, createWalletClient, custom } from 'viem'; | ||
import { Wallet } from '@dynamic-labs/wallet-connector-core'; | ||
@@ -10,2 +10,3 @@ import '@dynamic-labs/utils'; | ||
import { interceptTransport } from '../utils/viem/interceptTransport/interceptTransport.js'; | ||
import { erc20Abi } from '../utils/viem/erc20/abi.js'; | ||
import 'viem/accounts'; | ||
@@ -19,7 +20,22 @@ import { getChain } from '../utils/viem/getOrMapViemChain/getOrMapViemChain.js'; | ||
* @param toAddress - The address to send the balance to. | ||
* @param token - The token to send (optional) — for example, an ERC20 token. | ||
* @param token.address - The address of the token contract. | ||
* @param token.decimals - The decimals of the token (defaults to 18). | ||
* @returns The transaction hash of the sent transaction. | ||
*/ | ||
sendBalance(_a) { | ||
return __awaiter(this, arguments, void 0, function* ({ amount, toAddress, }) { | ||
return __awaiter(this, arguments, void 0, function* ({ amount, toAddress, token, }) { | ||
const provider = yield this.getWalletClient(); | ||
if (token && token.address) { | ||
const erc20Contract = getContract({ | ||
abi: erc20Abi, | ||
address: token.address, | ||
client: provider, | ||
}); | ||
const transfer = yield erc20Contract.write['transfer']([ | ||
toAddress, | ||
parseUnits(amount, token.decimals || 18), | ||
]); | ||
return transfer; | ||
} | ||
const transaction = { | ||
@@ -26,0 +42,0 @@ account: this.address, |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1069790
15405