Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: non-18 decimal custom gas token support #530

Merged
merged 176 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
176 commits
Select commit Hold shift + click to select a range
d5bd73e
init
brtkx Apr 3, 2024
0a3ac4c
unused import
brtkx Apr 3, 2024
938f285
update
brtkx Apr 10, 2024
95abec9
clean up
brtkx Apr 10, 2024
831a66f
unused var
brtkx Apr 11, 2024
22de060
non-18 decimals tests
brtkx Apr 17, 2024
7fd4fdb
fix
brtkx Apr 17, 2024
01e38b8
update
brtkx Apr 24, 2024
2e03bad
fix
brtkx Apr 24, 2024
ac74a83
fix
brtkx Apr 24, 2024
a9ce5ff
fix
brtkx Apr 24, 2024
f185565
Merge branch 'main' of ssh://github.com/OffchainLabs/arbitrum-sdk int…
brtkx Apr 25, 2024
0edd090
try
brtkx Apr 26, 2024
a092305
remove option
brtkx Apr 26, 2024
e96140f
Merge branch 'main' of ssh://github.com/OffchainLabs/arbitrum-sdk int…
brtkx May 10, 2024
f8b5b82
fix
brtkx May 10, 2024
4ea46d5
fix
brtkx May 10, 2024
97e9503
fix decimals
brtkx May 16, 2024
ec69bc9
fix
brtkx May 16, 2024
3d24c3a
try fix decimals
brtkx May 16, 2024
fdd51b5
try fix decimals
brtkx May 16, 2024
2b6b3e8
try
brtkx May 16, 2024
4dd8b9f
try
brtkx May 16, 2024
5a44827
try
brtkx May 16, 2024
7fa6fd1
try
brtkx May 16, 2024
27bda5d
try
brtkx May 16, 2024
702293c
fix
brtkx May 16, 2024
970cc0b
logs
brtkx May 16, 2024
11b5cad
logs
brtkx May 17, 2024
b58ad44
try different amount
brtkx May 17, 2024
6b544a9
bump nitro
brtkx May 17, 2024
420b0d0
fix
brtkx May 17, 2024
9b81d9b
log
brtkx May 17, 2024
0f391a1
check balance
brtkx May 20, 2024
dc848e1
check balance
brtkx May 20, 2024
a0b7458
increase funds
brtkx May 20, 2024
898e94f
nit
brtkx May 20, 2024
a18372d
try
brtkx May 20, 2024
9c7b5e6
clean up and logs
brtkx May 20, 2024
70052d1
try
brtkx May 20, 2024
0be4f9f
try
brtkx May 20, 2024
03263d2
try
brtkx May 20, 2024
6069dc0
fix
brtkx May 20, 2024
0872e0f
fix
brtkx May 20, 2024
596d624
fix
brtkx May 20, 2024
249c8a4
clean up
brtkx May 20, 2024
8343b27
clean up
brtkx May 20, 2024
d5afac6
update build
brtkx May 20, 2024
b9b00b5
config
brtkx May 20, 2024
d9b83cb
fix decimals
brtkx May 20, 2024
54b58d5
try
brtkx May 20, 2024
b193202
fix
brtkx May 20, 2024
f4832fa
clean up
brtkx May 21, 2024
ea82f65
clean up
brtkx May 21, 2024
e6a6a81
addressing comments
brtkx Jun 11, 2024
433e151
fix
brtkx Jun 11, 2024
ebd8546
fix
brtkx Jun 11, 2024
fca5738
enable custom gateway register
brtkx Jun 11, 2024
d9a0a30
24 decimals tests
brtkx Jun 11, 2024
4f9f8bd
fixes
brtkx Jun 11, 2024
130f71e
fixes
brtkx Jun 11, 2024
71c9877
fixes
brtkx Jun 11, 2024
1844511
Merge branch 'main' of ssh://github.com/OffchainLabs/arbitrum-sdk int…
brtkx Jun 14, 2024
2ba0b21
try 20 decimals
brtkx Jun 14, 2024
6aeb47e
scale funding
brtkx Jun 14, 2024
58117a4
fixes
brtkx Jun 14, 2024
2cc774b
fix
brtkx Jun 14, 2024
bc6fabd
try fix
brtkx Jun 17, 2024
23c8b4f
add some logs
brtkx Jun 17, 2024
15dbfcc
more logs
brtkx Jun 17, 2024
f95bad7
logs
brtkx Jun 17, 2024
0ee68e3
log
brtkx Jun 17, 2024
bcd921c
try fix
brtkx Jun 17, 2024
9608131
logs
brtkx Jun 17, 2024
104bff0
try
brtkx Jun 17, 2024
8842179
try
brtkx Jun 18, 2024
5dca1b7
try
brtkx Jun 18, 2024
45eb655
check balance
brtkx Jun 18, 2024
b9242c7
remove double fund
brtkx Jun 18, 2024
447b58b
fix balances
brtkx Jun 18, 2024
da25e3f
try
brtkx Jun 18, 2024
b1aa4d0
try fund
brtkx Jun 18, 2024
4e3c294
try
brtkx Jun 18, 2024
71f6394
Merge branch 'main' of ssh://github.com/OffchainLabs/arbitrum-sdk int…
brtkx Jun 18, 2024
5595c8f
try
brtkx Jun 18, 2024
a6c7829
try
brtkx Jun 18, 2024
4df99df
check rpc urls
brtkx Jun 19, 2024
efc2553
clean up
brtkx Jun 19, 2024
83cc83f
check before and after balances
brtkx Jun 19, 2024
4d27dfb
tests for rescaled gas
brtkx Jun 19, 2024
88d9914
bump gas
brtkx Jun 19, 2024
2fa378b
Merge branch 'main' of ssh://github.com/OffchainLabs/arbitrum-sdk int…
brtkx Jun 19, 2024
690f2ad
clean up
brtkx Jun 19, 2024
fb7b87e
cleanup
brtkx Jun 19, 2024
a8d5173
cleanup
brtkx Jun 19, 2024
40a2c52
cleanup
brtkx Jun 19, 2024
f556c88
18 decimals tests
brtkx Jun 19, 2024
ba40b53
fixes
brtkx Jun 19, 2024
908f551
fixes
brtkx Jun 19, 2024
a584a58
fix
brtkx Jun 19, 2024
6cc45ec
fix
brtkx Jun 19, 2024
c7d969d
try fund
brtkx Jun 19, 2024
49a0bd5
try
brtkx Jun 19, 2024
1652717
try
brtkx Jun 19, 2024
e44e760
try
brtkx Jun 19, 2024
d03ea37
clean up
brtkx Jun 19, 2024
5b6cf50
try
brtkx Jun 19, 2024
bcb6452
clean up
brtkx Jun 20, 2024
ae45f1a
clean up build
brtkx Jun 20, 2024
65836b2
skip custom gas token
brtkx Jul 2, 2024
e16aa17
fix eth
brtkx Jul 2, 2024
bf721bf
unit tests
brtkx Jul 3, 2024
a9b7d61
remove async
brtkx Jul 3, 2024
ab57c2f
retryable data run
brtkx Jul 4, 2024
9d7e343
build fix
brtkx Jul 8, 2024
18df208
build fix
brtkx Jul 8, 2024
a346f2b
build fix
brtkx Jul 8, 2024
ad507e7
build fix
brtkx Jul 8, 2024
acf2317
build fix
brtkx Jul 8, 2024
8f915e4
build fix
brtkx Jul 8, 2024
9f4c551
build fix
brtkx Jul 8, 2024
bc911f2
build fix
brtkx Jul 8, 2024
b97aabe
build fix
brtkx Jul 8, 2024
00da206
build fix
brtkx Jul 8, 2024
0caaf60
fix
brtkx Jul 8, 2024
b9bee8c
fix
brtkx Jul 8, 2024
6e26a1f
fix
brtkx Jul 8, 2024
aeefffa
fix
brtkx Jul 8, 2024
9571717
try
brtkx Jul 8, 2024
b606ede
Merge branch 'main' into non-18-decimal-rescale
brtkx Jul 8, 2024
aff4ccc
fix
brtkx Jul 9, 2024
fd82f48
Merge branch 'non-18-decimal-rescale' of ssh://github.com/OffchainLab…
brtkx Jul 9, 2024
72fa130
fix
brtkx Jul 9, 2024
6b59204
fix
brtkx Jul 9, 2024
3e7e73c
fix
brtkx Jul 9, 2024
6b69913
fixes
brtkx Jul 9, 2024
e160c5f
Merge branch 'main' of ssh://github.com/OffchainLabs/arbitrum-sdk int…
brtkx Jul 9, 2024
e7e005a
fix
brtkx Jul 9, 2024
f56ab96
fix l2callvalue
brtkx Jul 9, 2024
1c985e9
fix
brtkx Jul 9, 2024
fff9d5f
fix
brtkx Jul 9, 2024
a1c34df
fix
brtkx Jul 9, 2024
1866990
fix
brtkx Jul 9, 2024
0ff5862
try
brtkx Jul 15, 2024
37a0197
try
brtkx Jul 15, 2024
4199ec9
try testnode ref
brtkx Jul 15, 2024
a7aa3e2
disable some tests
brtkx Jul 15, 2024
f135552
try no overrides
brtkx Jul 15, 2024
f96ac29
try
brtkx Jul 15, 2024
e5104aa
try
brtkx Jul 15, 2024
ca70e38
clean up
brtkx Jul 15, 2024
2bdc2f0
clean up
brtkx Jul 15, 2024
358f50f
fix
brtkx Jul 15, 2024
072653e
fix
brtkx Jul 15, 2024
7474bc9
log
brtkx Jul 15, 2024
1a45cff
try fix
brtkx Jul 15, 2024
e563099
try
brtkx Jul 15, 2024
ac68c25
logs
brtkx Jul 15, 2024
4dd1fe1
logs
brtkx Jul 15, 2024
8d09fb0
fixes l1l3
brtkx Jul 17, 2024
43988b7
Merge branch 'main' of ssh://github.com/OffchainLabs/arbitrum-sdk int…
brtkx Jul 17, 2024
f85d9e4
try
brtkx Jul 17, 2024
322dd95
try
brtkx Jul 17, 2024
63cf5aa
fixes
brtkx Jul 17, 2024
c3bb004
fixes
brtkx Jul 17, 2024
31c5355
fixes and more tests
brtkx Jul 17, 2024
bde2893
fix tests
brtkx Jul 17, 2024
75b1294
clean up
brtkx Jul 17, 2024
75649e2
fix tests matrix
brtkx Jul 17, 2024
b1a7f5e
revert
brtkx Jul 17, 2024
2ea4226
fix
brtkx Jul 18, 2024
6f93771
Merge branch 'main' of ssh://github.com/OffchainLabs/arbitrum-sdk int…
brtkx Aug 7, 2024
5ea3124
Merge branch 'main' of ssh://github.com/OffchainLabs/arbitrum-sdk int…
brtkx Oct 15, 2024
ac5b73c
Updated
brtkx Oct 15, 2024
78610f5
fixes
brtkx Oct 15, 2024
b2b0624
Merge branch 'main' of ssh://github.com/OffchainLabs/arbitrum-sdk int…
brtkx Oct 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/lib/assetBridger/erc20Bridger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -685,8 +685,8 @@ export class Erc20Bridger extends AssetBridger<
}

const decimals = await getNativeTokenDecimals({
l1Provider: parentProvider,
l2Network: this.childNetwork,
parentProvider,
childNetwork: this.childNetwork,
})

const depositFunc = (
Expand Down Expand Up @@ -1096,8 +1096,8 @@ export class AdminErc20Bridger extends Erc20Bridger {
}

const nativeTokenDecimals = await getNativeTokenDecimals({
l1Provider: parentProvider,
l2Network: this.childNetwork,
parentProvider,
childNetwork: this.childNetwork,
})

type GasParams = {
Expand Down
4 changes: 2 additions & 2 deletions src/lib/assetBridger/ethBridger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,8 @@ export class EthBridger extends AssetBridger<
params: EthDepositToRequestParams
): Promise<ParentToChildTransactionRequest> {
const decimals = await getNativeTokenDecimals({
l1Provider: params.parentProvider,
l2Network: this.childNetwork,
parentProvider: params.parentProvider,
childNetwork: this.childNetwork,
})

const amountToBeMintedOnChildChain = nativeTokenDecimalsTo18Decimals({
Expand Down
6 changes: 3 additions & 3 deletions src/lib/message/ParentToChildMessageGasEstimator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,10 @@ export class ParentToChildMessageGasEstimator {
const { data } = retryableEstimateData
const gasLimitDefaults = this.applyGasLimitDefaults(options?.gasLimit)

const l2Network = await getArbitrumNetwork(this.childProvider)
const childNetwork = await getArbitrumNetwork(this.childProvider)
const decimals = await getNativeTokenDecimals({
l1Provider: parentProvider,
l2Network,
parentProvider,
childNetwork,
})

// estimate the child gas price
Expand Down
12 changes: 6 additions & 6 deletions src/lib/utils/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,21 +198,21 @@ export const getBlockRangesForL1Block = async (
}

export async function getNativeTokenDecimals({
l1Provider,
l2Network,
parentProvider,
childNetwork,
}: {
l1Provider: Provider
l2Network: ArbitrumNetwork
parentProvider: Provider
childNetwork: ArbitrumNetwork
}) {
const nativeTokenAddress = l2Network.nativeToken
const nativeTokenAddress = childNetwork.nativeToken

if (!nativeTokenAddress || nativeTokenAddress === constants.AddressZero) {
return 18
}

const nativeTokenContract = ERC20__factory.connect(
nativeTokenAddress,
l1Provider
parentProvider
)

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ describeOnlyWhenCustomGasToken(
childChain,
} = await testSetup()
const decimals = await getNativeTokenDecimals({
l1Provider: parentProvider,
l2Network: childChain,
parentProvider,
childNetwork: childChain,
})
const amount = ethers.utils.parseUnits('1', decimals)

Expand Down Expand Up @@ -179,8 +179,8 @@ describeOnlyWhenCustomGasToken(
nativeTokenContract,
} = await testSetup()
const decimals = await getNativeTokenDecimals({
l1Provider: parentProvider,
l2Network: childChain,
parentProvider,
childNetwork: childChain,
})

const bridge = ethBridger.childNetwork.ethBridge.bridge
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ export async function fundChildCustomFeeToken(childSigner: Signer) {
const deployerWallet = new Wallet(config.arbKey, arbProvider())

const decimals = await getNativeTokenDecimals({
l1Provider: ethProvider(),
l2Network: localNetworks().l2Network,
parentProvider: ethProvider(),
childNetwork: localNetworks().l2Network,
})

const tx = await deployerWallet.sendTransaction({
Expand Down
9 changes: 1 addition & 8 deletions tests/integration/customerc20.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,7 @@ import {
import { AdminErc20Bridger } from '../../src/lib/assetBridger/erc20Bridger'
import { testSetup } from '../../scripts/testSetup'
import { ERC20__factory } from '../../src/lib/abi/factories/ERC20__factory'
import {
fundParentCustomFeeToken,
isArbitrumNetworkWithCustomFeeToken,
} from './custom-fee-token/customFeeTokenTestHelpers'
import { isArbitrumNetworkWithCustomFeeToken } from './custom-fee-token/customFeeTokenTestHelpers'

const depositAmount = BigNumber.from(100)
const withdrawalAmount = BigNumber.from(10)
Expand All @@ -75,10 +72,6 @@ describe('Custom ERC20', () => {
}
await fundParentSigner(testState.parentSigner)
await fundChildSigner(testState.childSigner)

if (isArbitrumNetworkWithCustomFeeToken()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need this, fundParentSigner and fundChildSigner cover this

await fundParentCustomFeeToken(testState.parentSigner)
}
})

it('register custom token', async () => {
Expand Down
16 changes: 8 additions & 8 deletions tests/integration/eth.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ describe('Ether', async () => {
childSigner,
} = await testSetup()
const decimals = await getNativeTokenDecimals({
l1Provider: parentProvider,
l2Network: childChain,
parentProvider,
childNetwork: childChain,
})

await fundParentSigner(parentSigner)
Expand Down Expand Up @@ -181,8 +181,8 @@ describe('Ether', async () => {
childSigner,
} = await testSetup()
const decimals = await getNativeTokenDecimals({
l1Provider: parentProvider,
l2Network: childChain,
parentProvider,
childNetwork: childChain,
})

await fundParentSigner(parentSigner)
Expand Down Expand Up @@ -271,8 +271,8 @@ describe('Ether', async () => {
childSigner,
} = await testSetup()
const decimals = await getNativeTokenDecimals({
l1Provider: parentProvider,
l2Network: childChain,
parentProvider,
childNetwork: childChain,
})

await fundParentSigner(parentSigner)
Expand Down Expand Up @@ -447,8 +447,8 @@ describe('Ether', async () => {
).to.eq(ChildToParentMessageStatus.EXECUTED)

const decimals = await getNativeTokenDecimals({
l1Provider: parentProvider,
l2Network: childChain,
parentProvider,
childNetwork: childChain,
})

const finalRandomBalance = isArbitrumNetworkWithCustomFeeToken()
Expand Down
24 changes: 12 additions & 12 deletions tests/integration/l1l3Bridger.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -383,8 +383,8 @@ describe('L1 to L3 Bridging', () => {
'should properly get l2 and l1 fee token addresses',
async function () {
const decimals = await getNativeTokenDecimals({
l1Provider: l1Signer.provider!,
l2Network: l3Network,
parentProvider: l1Signer.provider!,
childNetwork: l3Network,
})

if (decimals !== 18) {
Expand Down Expand Up @@ -413,8 +413,8 @@ describe('L1 to L3 Bridging', () => {
'should throw getting l1 gas token address when it is unavailable',
async function () {
const decimals = await getNativeTokenDecimals({
l1Provider: l1Signer.provider!,
l2Network: l3Network,
parentProvider: l1Signer.provider!,
childNetwork: l3Network,
})

if (decimals !== 18) {
Expand All @@ -441,8 +441,8 @@ describe('L1 to L3 Bridging', () => {
'should throw when the fee token does not use 18 decimals on L1 or L2',
async function () {
const decimals = await getNativeTokenDecimals({
l1Provider: l1Signer.provider!,
l2Network: l3Network,
parentProvider: l1Signer.provider!,
childNetwork: l3Network,
})

if (decimals !== 18) {
Expand Down Expand Up @@ -938,8 +938,8 @@ describe('L1 to L3 Bridging', () => {

it('happy path non fee token or standard', async function () {
const decimals = await getNativeTokenDecimals({
l1Provider: l1Signer.provider!,
l2Network: l3Network,
parentProvider: l1Signer.provider!,
childNetwork: l3Network,
})

if (decimals !== 18) {
Expand All @@ -961,8 +961,8 @@ describe('L1 to L3 Bridging', () => {

it('happy path weth', async function () {
const decimals = await getNativeTokenDecimals({
l1Provider: l1Signer.provider!,
l2Network: l3Network,
parentProvider: l1Signer.provider!,
childNetwork: l3Network,
})

if (decimals !== 18) {
Expand Down Expand Up @@ -1000,8 +1000,8 @@ describe('L1 to L3 Bridging', () => {

itOnlyWhenCustomGasToken('happy path OnlyCustomFee', async function () {
const decimals = await getNativeTokenDecimals({
l1Provider: l1Signer.provider!,
l2Network: l3Network,
parentProvider: l1Signer.provider!,
childNetwork: l3Network,
})

if (decimals !== 18) {
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/retryableData.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ describe('RevertData', () => {

const { parentProvider, childChain } = await testSetup()
const decimals = await getNativeTokenDecimals({
l1Provider: parentProvider,
l2Network: childChain,
parentProvider,
childNetwork: childChain,
})

return {
Expand Down
Loading