From e0ad67d5e345cb3cfee3244fe4fd5fa7dcf88686 Mon Sep 17 00:00:00 2001 From: spsjvc Date: Wed, 30 Oct 2024 21:48:55 +0100 Subject: [PATCH 1/4] refactor: bump @arbitrum/sdk to 4.0.2-beta.1 (#223) --- src/package.json | 2 +- src/utils/decimals.ts | 16 +++++++++++----- yarn.lock | 38 ++++++++++++++++++++++++++++---------- 3 files changed, 40 insertions(+), 16 deletions(-) diff --git a/src/package.json b/src/package.json index bf24b2bd..d15a2282 100644 --- a/src/package.json +++ b/src/package.json @@ -51,7 +51,7 @@ "viem": "^1.20.0" }, "dependencies": { - "@arbitrum/sdk": "^4.0.2-beta.0", + "@arbitrum/sdk": "^4.0.2-beta.1", "@arbitrum/token-bridge-contracts": "^1.2.2", "@offchainlabs/fund-distribution-contracts": "^1.0.1", "@safe-global/protocol-kit": "^4.0.2", diff --git a/src/utils/decimals.ts b/src/utils/decimals.ts index c1090aaa..fc8a57bd 100644 --- a/src/utils/decimals.ts +++ b/src/utils/decimals.ts @@ -1,8 +1,8 @@ import { BigNumber } from 'ethers'; import { - scaleToNativeTokenDecimals as ethers_scaleToNativeTokenDecimals, - nativeTokenDecimalsTo18Decimals as ethers_nativeTokenDecimalsTo18Decimals, -} from '@arbitrum/sdk/dist/lib/utils/lib'; + scaleFrom18DecimalsToNativeTokenDecimals as ethers_scaleFrom18DecimalsToNativeTokenDecimals, + scaleFromNativeTokenDecimalsTo18Decimals as ethers_scaleFromNativeTokenDecimalsTo18Decimals, +} from '@arbitrum/sdk'; /** * Scales a value from 18 decimals to the number of decimals of the native token. @@ -20,7 +20,10 @@ export function scaleFrom18DecimalsToNativeTokenDecimals({ decimals: number; }): bigint { const amountBigNumber = BigNumber.from(amount); - const result = ethers_scaleToNativeTokenDecimals({ amount: amountBigNumber, decimals }); + const result = ethers_scaleFrom18DecimalsToNativeTokenDecimals({ + amount: amountBigNumber, + decimals, + }); return BigInt(result.toString()); } @@ -40,6 +43,9 @@ export function scaleFromNativeTokenDecimalsTo18Decimals({ decimals: number; }): bigint { const amountBigNumber = BigNumber.from(amount); - const result = ethers_nativeTokenDecimalsTo18Decimals({ amount: amountBigNumber, decimals }); + const result = ethers_scaleFromNativeTokenDecimalsTo18Decimals({ + amount: amountBigNumber, + decimals, + }); return BigInt(result.toString()); } diff --git a/yarn.lock b/yarn.lock index 77b52ca1..c5672ad5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -22,10 +22,10 @@ "@openzeppelin/contracts-upgradeable" "4.5.2" patch-package "^6.4.7" -"@arbitrum/sdk@^4.0.2-beta.0": - version "4.0.2-beta.0" - resolved "https://registry.yarnpkg.com/@arbitrum/sdk/-/sdk-4.0.2-beta.0.tgz#864e38797d9f25e0b0d6a5f0147d60bd5b5db3b6" - integrity sha512-Q22DqEYzlkspvx6h9LUgTFgpUr9PNtPiyp4hTaODOdNl+cbpVAz6G9x04iMAnNia9sP0KffhDD5WxS4CzFrFFw== +"@arbitrum/sdk@^4.0.2-beta.1": + version "4.0.2-beta.1" + resolved "https://registry.yarnpkg.com/@arbitrum/sdk/-/sdk-4.0.2-beta.1.tgz#c6c6c5784a8eaa6a4edab3600f765e9f82ce5988" + integrity sha512-a5DG6+Ld3X4L8H3CTUl3gc27Bj/Pqjo+5UZiCI97SM2mHtHKWF1BgQ+FCk/8bgFUP5nS9dXBl5tPJRtCFfOe0A== dependencies: "@ethersproject/address" "^5.0.8" "@ethersproject/bignumber" "^5.1.1" @@ -1596,7 +1596,20 @@ duplexer@^0.1.1, duplexer@~0.1.1: resolved "https://registry.yarnpkg.com/duplexer/-/duplexer-0.1.2.tgz#3abe43aef3835f8ae077d136ddce0f276b0400e6" integrity sha512-jtD6YG370ZCIi/9GTaJKQxWTZD045+4R4hTk/x1UyoqadyJ9x9CgSi1RlVDQF8U2sxLLSnFkCaMihqljHIWgMg== -elliptic@6.5.4, elliptic@6.5.7, elliptic@^6.5.4: +elliptic@6.5.4: + version "6.5.4" + resolved "https://registry.yarnpkg.com/elliptic/-/elliptic-6.5.4.tgz#da37cebd31e79a1367e941b592ed1fbebd58abbb" + integrity sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ== + dependencies: + bn.js "^4.11.9" + brorand "^1.1.0" + hash.js "^1.0.0" + hmac-drbg "^1.0.1" + inherits "^2.0.4" + minimalistic-assert "^1.0.1" + minimalistic-crypto-utils "^1.0.1" + +elliptic@^6.5.4: version "6.5.7" resolved "https://registry.yarnpkg.com/elliptic/-/elliptic-6.5.7.tgz#8ec4da2cb2939926a1b9a73619d768207e647c8b" integrity sha512-ESVCtTwiA+XhY3wyh24QqRGBoP3rEdDUl3EDUUo9tft074fi19IrdpH7hLCMMP3CIj7jb3W96rn8lt/BqIlt5Q== @@ -3703,12 +3716,17 @@ wrappy@1: resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" integrity sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ== -ws@7.4.6, ws@7.5.10: - version "7.5.10" - resolved "https://registry.yarnpkg.com/ws/-/ws-7.5.10.tgz#58b5c20dc281633f6c19113f39b349bd8bd558d9" - integrity sha512-+dbF1tHwZpXcbOJdVOkzLDxZP1ailvSxM6ZweXTegylPny803bFhA+vqBYw4s31NSAk4S2Qz+AKXK9a4wkdjcQ== +ws@7.4.6: + version "7.4.6" + resolved "https://registry.yarnpkg.com/ws/-/ws-7.4.6.tgz#5654ca8ecdeee47c33a9a4bf6d28e2be2980377c" + integrity sha512-YmhHDO4MzaDLB+M9ym/mDA5z0naX8j7SIlT8f8z+I0VtzsRbekxEutHSme7NPS2qE8StCYQNUnfWdXta/Yu85A== + +ws@8.13.0: + version "8.13.0" + resolved "https://registry.yarnpkg.com/ws/-/ws-8.13.0.tgz#9a9fb92f93cf41512a0735c8f4dd09b8a1211cd0" + integrity sha512-x9vcZYTrFPC7aSIbj7sRCYo7L/Xb8Iy+pW0ng0wt2vCJv7M9HOMy0UoN3rr+IFC7hb7vXoqS+P9ktyLLLhO+LA== -ws@8.13.0, ws@8.17.1: +ws@8.17.1: version "8.17.1" resolved "https://registry.yarnpkg.com/ws/-/ws-8.17.1.tgz#9293da530bb548febc95371d90f9c878727d919b" integrity sha512-6XQFvXTkbfUOZOKKILFG1PDK2NDQs4azKQl26T0YS5CxqWLgXajbPZ+h4gZekJyRqFU8pvnbAbbs/3TgRPy+GQ== From f66e47e9645cc99a31df2bb18ff3719ca2da1622 Mon Sep 17 00:00:00 2001 From: spsjvc Date: Thu, 31 Oct 2024 10:41:15 +0100 Subject: [PATCH 2/4] feat: export erc-20 utils (#224) --- src/index.ts | 11 +++++++++++ src/utils/erc20.ts | 10 ++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/index.ts b/src/index.ts index 51e2f9b3..995f6afb 100644 --- a/src/index.ts +++ b/src/index.ts @@ -159,6 +159,12 @@ import { createRollupGetRetryablesFees, createRollupGetRetryablesFeesWithDefaults, } from './createRollupGetRetryablesFees'; +import { + fetchAllowance, + FetchAllowanceProps, + fetchDecimals, + FetchDecimalsProps, +} from './utils/erc20'; export { arbOwnerPublicActions, @@ -290,4 +296,9 @@ export { CreateRollupGetRetryablesFeesParams, // createTokenBridgeDefaultRetryablesFees, + // + fetchAllowance, + FetchAllowanceProps, + fetchDecimals, + FetchDecimalsProps, }; diff --git a/src/utils/erc20.ts b/src/utils/erc20.ts index 830f2621..cdc96b2e 100644 --- a/src/utils/erc20.ts +++ b/src/utils/erc20.ts @@ -90,13 +90,15 @@ export async function fetchAllowance({ }); } +export type FetchDecimalsProps = { + address: Address; + publicClient: PublicClient; +}; + export function fetchDecimals({ address, publicClient, -}: { - address: Address; - publicClient: PublicClient; -}) { +}: FetchDecimalsProps) { return publicClient.readContract({ address, abi: erc20ABI, From 650a3ce328374531c04cc78bb789e99d0cbacb78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dragi=C5=A1a=20Spasojevi=C4=87?= Date: Thu, 31 Oct 2024 10:45:21 +0100 Subject: [PATCH 3/4] chore: update yarn.lock --- yarn.lock | 30 ++++++------------------------ 1 file changed, 6 insertions(+), 24 deletions(-) diff --git a/yarn.lock b/yarn.lock index c5672ad5..11047932 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1596,20 +1596,7 @@ duplexer@^0.1.1, duplexer@~0.1.1: resolved "https://registry.yarnpkg.com/duplexer/-/duplexer-0.1.2.tgz#3abe43aef3835f8ae077d136ddce0f276b0400e6" integrity sha512-jtD6YG370ZCIi/9GTaJKQxWTZD045+4R4hTk/x1UyoqadyJ9x9CgSi1RlVDQF8U2sxLLSnFkCaMihqljHIWgMg== -elliptic@6.5.4: - version "6.5.4" - resolved "https://registry.yarnpkg.com/elliptic/-/elliptic-6.5.4.tgz#da37cebd31e79a1367e941b592ed1fbebd58abbb" - integrity sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ== - dependencies: - bn.js "^4.11.9" - brorand "^1.1.0" - hash.js "^1.0.0" - hmac-drbg "^1.0.1" - inherits "^2.0.4" - minimalistic-assert "^1.0.1" - minimalistic-crypto-utils "^1.0.1" - -elliptic@^6.5.4: +elliptic@6.5.4, elliptic@6.5.7, elliptic@^6.5.4: version "6.5.7" resolved "https://registry.yarnpkg.com/elliptic/-/elliptic-6.5.7.tgz#8ec4da2cb2939926a1b9a73619d768207e647c8b" integrity sha512-ESVCtTwiA+XhY3wyh24QqRGBoP3rEdDUl3EDUUo9tft074fi19IrdpH7hLCMMP3CIj7jb3W96rn8lt/BqIlt5Q== @@ -3716,17 +3703,12 @@ wrappy@1: resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" integrity sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ== -ws@7.4.6: - version "7.4.6" - resolved "https://registry.yarnpkg.com/ws/-/ws-7.4.6.tgz#5654ca8ecdeee47c33a9a4bf6d28e2be2980377c" - integrity sha512-YmhHDO4MzaDLB+M9ym/mDA5z0naX8j7SIlT8f8z+I0VtzsRbekxEutHSme7NPS2qE8StCYQNUnfWdXta/Yu85A== - -ws@8.13.0: - version "8.13.0" - resolved "https://registry.yarnpkg.com/ws/-/ws-8.13.0.tgz#9a9fb92f93cf41512a0735c8f4dd09b8a1211cd0" - integrity sha512-x9vcZYTrFPC7aSIbj7sRCYo7L/Xb8Iy+pW0ng0wt2vCJv7M9HOMy0UoN3rr+IFC7hb7vXoqS+P9ktyLLLhO+LA== +ws@7.4.6, ws@7.5.10: + version "7.5.10" + resolved "https://registry.yarnpkg.com/ws/-/ws-7.5.10.tgz#58b5c20dc281633f6c19113f39b349bd8bd558d9" + integrity sha512-+dbF1tHwZpXcbOJdVOkzLDxZP1ailvSxM6ZweXTegylPny803bFhA+vqBYw4s31NSAk4S2Qz+AKXK9a4wkdjcQ== -ws@8.17.1: +ws@8.13.0, ws@8.17.1: version "8.17.1" resolved "https://registry.yarnpkg.com/ws/-/ws-8.17.1.tgz#9293da530bb548febc95371d90f9c878727d919b" integrity sha512-6XQFvXTkbfUOZOKKILFG1PDK2NDQs4azKQl26T0YS5CxqWLgXajbPZ+h4gZekJyRqFU8pvnbAbbs/3TgRPy+GQ== From be6a3d7449d4658e3af3f7d085047bb22d0f4407 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dragi=C5=A1a=20Spasojevi=C4=87?= Date: Thu, 31 Oct 2024 10:45:28 +0100 Subject: [PATCH 4/4] chore: bump version --- src/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/package.json b/src/package.json index d15a2282..d822475c 100644 --- a/src/package.json +++ b/src/package.json @@ -1,7 +1,7 @@ { "name": "@arbitrum/orbit-sdk", "description": "TypeScript SDK for building Arbitrum Orbit chains", - "version": "0.21.2-beta.1", + "version": "0.21.2-beta.2", "main": "./dist/index.js", "files": [ "./dist"