@heyanon/sdk 1.0.5 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -105,6 +105,9 @@ function getWrappedNative(chainId) {
105
105
  }
106
106
  return token;
107
107
  }
108
+ var ZERO_ALLOWANCE = [
109
+ { chainId: 1 /* ETHEREUM */, address: "0xdAC17F958D2ee523a2206206994597C13D831ec7" }
110
+ ];
108
111
  async function checkToApprove({ args, transactions, provider }) {
109
112
  const { account, target, spender, amount } = args;
110
113
  const allowance = await provider.readContract({
@@ -113,6 +116,18 @@ async function checkToApprove({ args, transactions, provider }) {
113
116
  functionName: "allowance",
114
117
  args: [account, spender]
115
118
  });
119
+ if (ZERO_ALLOWANCE.some(({ chainId, address }) => chainId === provider.chain?.id && address.toLowerCase() === target.toLowerCase())) {
120
+ if (allowance < amount && allowance > 0n) {
121
+ transactions.push({
122
+ target,
123
+ data: viem.encodeFunctionData({
124
+ abi: viem.erc20Abi,
125
+ functionName: "approve",
126
+ args: [spender, 0n]
127
+ })
128
+ });
129
+ }
130
+ }
116
131
  if (allowance < amount) {
117
132
  transactions.push({
118
133
  target,
package/dist/index.mjs CHANGED
@@ -103,6 +103,9 @@ function getWrappedNative(chainId) {
103
103
  }
104
104
  return token;
105
105
  }
106
+ var ZERO_ALLOWANCE = [
107
+ { chainId: 1 /* ETHEREUM */, address: "0xdAC17F958D2ee523a2206206994597C13D831ec7" }
108
+ ];
106
109
  async function checkToApprove({ args, transactions, provider }) {
107
110
  const { account, target, spender, amount } = args;
108
111
  const allowance = await provider.readContract({
@@ -111,6 +114,18 @@ async function checkToApprove({ args, transactions, provider }) {
111
114
  functionName: "allowance",
112
115
  args: [account, spender]
113
116
  });
117
+ if (ZERO_ALLOWANCE.some(({ chainId, address }) => chainId === provider.chain?.id && address.toLowerCase() === target.toLowerCase())) {
118
+ if (allowance < amount && allowance > 0n) {
119
+ transactions.push({
120
+ target,
121
+ data: encodeFunctionData({
122
+ abi: erc20Abi,
123
+ functionName: "approve",
124
+ args: [spender, 0n]
125
+ })
126
+ });
127
+ }
128
+ }
114
129
  if (allowance < amount) {
115
130
  transactions.push({
116
131
  target,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heyanon/sdk",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",