Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@arbitrum/sdk",
"version": "3.0.0-beta.2",
"version": "3.0.0-beta.3",
"description": "Typescript library client-side interactions with Arbitrum",
"author": "Offchain Labs, Inc.",
"license": "Apache-2.0",
Expand Down
42 changes: 30 additions & 12 deletions src/lib/message/L1ToL2Message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { Signer } from '@ethersproject/abstract-signer'
import { ContractTransaction } from '@ethersproject/contracts'
import { BigNumber } from '@ethersproject/bignumber'
import { zeroPad } from '@ethersproject/bytes'
import { getAddress } from '@ethersproject/address'

import { ArbRetryableTx__factory } from '../abi/factories/ArbRetryableTx__factory'
import { ARB_RETRYABLE_TX_ADDRESS } from '../dataEntities/constants'
Expand Down Expand Up @@ -647,6 +648,7 @@ export class EthDepositMessage {
public static calculateDepositTxId(
l2ChainId: number,
messageNumber: BigNumber,
fromAddress: string,
toAddress: string,
value: BigNumber
): string {
Expand All @@ -657,10 +659,12 @@ export class EthDepositMessage {
const chainId = BigNumber.from(l2ChainId)
const msgNum = BigNumber.from(messageNumber)

const fields: any[] = [
// https://github.com/OffchainLabs/go-ethereum/blob/07e017aa73e32be92aadb52fa327c552e1b7b118/core/types/arb_types.go#L302-L308
const fields = [
formatNumber(chainId),
zeroPad(formatNumber(msgNum), 32),
toAddress,
getAddress(fromAddress),
getAddress(toAddress),
formatNumber(value),
]

Expand All @@ -677,16 +681,19 @@ export class EthDepositMessage {
* Parse the data field in
* event InboxMessageDelivered(uint256 indexed messageNum, bytes data);
* @param eventData
* @returns
* @returns destination and amount
*/
private static parseEthDepositData(eventData: string): BigNumber {
// https://github.com/OffchainLabs/nitro/blob/9f16d082496aef9de66b9e8653531d467d685560/contracts/src/bridge/Inbox.sol#L230
private static parseEthDepositData(eventData: string): {
to: string
value: BigNumber
} {
// https://github.com/OffchainLabs/nitro/blob/aa84e899cbc902bf6da753b1d66668a1def2c106/contracts/src/bridge/Inbox.sol#L242
const parsed = ethers.utils.defaultAbiCoder.decode(
['uint256'],
['address', 'uint256'],
eventData
) as [BigNumber]
) as [string, BigNumber]

return parsed[0]
return { to: parsed[0], value: parsed[1] }
}

/**
Expand All @@ -704,15 +711,16 @@ export class EthDepositMessage {
inboxMessageEventData: string
) {
const chainId = (await l2Provider.getNetwork()).chainId
const value = EthDepositMessage.parseEthDepositData(inboxMessageEventData)
const { to, value } = EthDepositMessage.parseEthDepositData(
inboxMessageEventData
)

return new EthDepositMessage(
l2Provider,
chainId,
messageNumber,
// arb-os always applies an alias to the address it gets from the event
// before it forms that into a transaction
new Address(senderAddr).applyAlias().value,
senderAddr,
to,
value
)
}
Expand All @@ -729,17 +737,27 @@ export class EthDepositMessage {
private readonly l2Provider: Provider,
public readonly l2ChainId: number,
public readonly messageNumber: BigNumber,
public readonly from: string,
public readonly to: string,
public readonly value: BigNumber
) {
this.l2DepositTxHash = EthDepositMessage.calculateDepositTxId(
l2ChainId,
messageNumber,
from,
to,
value
)
}

public async status(): Promise<L1ToL2MessageStatus> {
const receipt = await this.l2Provider.getTransactionReceipt(
this.l2DepositTxHash
)
if (receipt === null) return L1ToL2MessageStatus.NOT_YET_CREATED
else return L1ToL2MessageStatus.FUNDS_DEPOSITED_ON_L2
}

public async wait(confirmations?: number, timeout = 900000) {
if (!this.l2DepositTxReceipt) {
this.l2DepositTxReceipt = await getTransactionReceipt(
Expand Down
10 changes: 9 additions & 1 deletion src/lib/message/L1Transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,18 @@ export class L1TransactionReceipt implements TransactionReceipt {
}
}

public async getAllDeposits<T extends SignerOrProvider>(l2SignerOrProvider: T) {
Comment thread
fredlacs marked this conversation as resolved.
Outdated
const provider = SignerProviderUtils.getProviderOrThrow(l2SignerOrProvider)
return await Promise.all([
this.getEthDepositMessages(provider),
this.getL1ToL2Messages(l2SignerOrProvider)
]).then(arr => arr.flat(1))
}

public async getEthDepositMessages(
l2Provider: Provider
): Promise<EthDepositMessage[]> {
return Promise.all(
return await Promise.all(
this.getMessageEvents()
.filter(
e =>
Expand Down
96 changes: 20 additions & 76 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1014,12 +1014,6 @@
"@typescript-eslint/types" "5.21.0"
"@typescript-eslint/visitor-keys" "5.21.0"

<<<<<<< HEAD
"@typescript-eslint/type-utils@5.21.0":
version "5.21.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-5.21.0.tgz#ff89668786ad596d904c21b215e5285da1b6262e"
integrity sha512-MxmLZj0tkGlkcZCSE17ORaHl8Th3JQwBzyXL/uvC6sNmu128LsgjTX0NIzy+wdH2J7Pd02GN8FaoudJntFvSOw==
=======
"@typescript-eslint/scope-manager@5.27.1":
version "5.27.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-5.27.1.tgz#4d1504392d01fe5f76f4a5825991ec78b7b7894d"
Expand All @@ -1028,11 +1022,10 @@
"@typescript-eslint/types" "5.27.1"
"@typescript-eslint/visitor-keys" "5.27.1"

"@typescript-eslint/type-utils@5.14.0":
version "5.14.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-5.14.0.tgz#711f08105860b12988454e91df433567205a8f0b"
integrity sha512-d4PTJxsqaUpv8iERTDSQBKUCV7Q5yyXjqXUl3XF7Sd9ogNLuKLkxz82qxokqQ4jXdTPZudWpmNtr/JjbbvUixw==
>>>>>>> master
"@typescript-eslint/type-utils@5.21.0":
version "5.21.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-5.21.0.tgz#ff89668786ad596d904c21b215e5285da1b6262e"
integrity sha512-MxmLZj0tkGlkcZCSE17ORaHl8Th3JQwBzyXL/uvC6sNmu128LsgjTX0NIzy+wdH2J7Pd02GN8FaoudJntFvSOw==
dependencies:
"@typescript-eslint/utils" "5.21.0"
debug "^4.3.2"
Expand All @@ -1043,22 +1036,15 @@
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.21.0.tgz#8cdb9253c0dfce3f2ab655b9d36c03f72e684017"
integrity sha512-XnOOo5Wc2cBlq8Lh5WNvAgHzpjnEzxn4CJBwGkcau7b/tZ556qrWXQz4DJyChYg8JZAD06kczrdgFPpEQZfDsA==

<<<<<<< HEAD
"@typescript-eslint/typescript-estree@5.21.0":
version "5.21.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.21.0.tgz#9f0c233e28be2540eaed3df050f0d54fb5aa52de"
integrity sha512-Y8Y2T2FNvm08qlcoSMoNchh9y2Uj3QmjtwNMdRQkcFG7Muz//wfJBGBxh8R7HAGQFpgYpdHqUpEoPQk+q9Kjfg==
=======
"@typescript-eslint/types@5.27.1":
version "5.27.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.27.1.tgz#34e3e629501349d38be6ae97841298c03a6ffbf1"
integrity sha512-LgogNVkBhCTZU/m8XgEYIWICD6m4dmEDbKXESCbqOXfKZxRKeqpiJXQIErv66sdopRKZPo5l32ymNqibYEH/xg==

"@typescript-eslint/typescript-estree@5.14.0":
version "5.14.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.14.0.tgz#78b7f7385d5b6f2748aacea5c9b7f6ae62058314"
integrity sha512-QGnxvROrCVtLQ1724GLTHBTR0lZVu13izOp9njRvMkCBgWX26PKvmMP8k82nmXBRD3DQcFFq2oj3cKDwr0FaUA==
>>>>>>> master
"@typescript-eslint/typescript-estree@5.21.0":
version "5.21.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.21.0.tgz#9f0c233e28be2540eaed3df050f0d54fb5aa52de"
integrity sha512-Y8Y2T2FNvm08qlcoSMoNchh9y2Uj3QmjtwNMdRQkcFG7Muz//wfJBGBxh8R7HAGQFpgYpdHqUpEoPQk+q9Kjfg==
dependencies:
"@typescript-eslint/types" "5.21.0"
"@typescript-eslint/visitor-keys" "5.21.0"
Expand All @@ -1068,12 +1054,6 @@
semver "^7.3.5"
tsutils "^3.21.0"

<<<<<<< HEAD
"@typescript-eslint/utils@5.21.0":
version "5.21.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-5.21.0.tgz#51d7886a6f0575e23706e5548c7e87bce42d7c18"
integrity sha512-q/emogbND9wry7zxy7VYri+7ydawo2HDZhRZ5k6yggIvXa7PvBbAAZ4PFH/oZLem72ezC4Pr63rJvDK/sTlL8Q==
=======
"@typescript-eslint/typescript-estree@5.27.1":
version "5.27.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.27.1.tgz#7621ee78607331821c16fffc21fc7a452d7bc808"
Expand All @@ -1087,11 +1067,10 @@
semver "^7.3.7"
tsutils "^3.21.0"

"@typescript-eslint/utils@5.14.0":
version "5.14.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-5.14.0.tgz#6c8bc4f384298cbbb32b3629ba7415f9f80dc8c4"
integrity sha512-EHwlII5mvUA0UsKYnVzySb/5EE/t03duUTweVy8Zqt3UQXBrpEVY144OTceFKaOe4xQXZJrkptCf7PjEBeGK4w==
>>>>>>> master
"@typescript-eslint/utils@5.21.0":
version "5.21.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-5.21.0.tgz#51d7886a6f0575e23706e5548c7e87bce42d7c18"
integrity sha512-q/emogbND9wry7zxy7VYri+7ydawo2HDZhRZ5k6yggIvXa7PvBbAAZ4PFH/oZLem72ezC4Pr63rJvDK/sTlL8Q==
dependencies:
"@types/json-schema" "^7.0.9"
"@typescript-eslint/scope-manager" "5.21.0"
Expand All @@ -1100,12 +1079,6 @@
eslint-scope "^5.1.1"
eslint-utils "^3.0.0"

<<<<<<< HEAD
"@typescript-eslint/visitor-keys@5.21.0":
version "5.21.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.21.0.tgz#453fb3662409abaf2f8b1f65d515699c888dd8ae"
integrity sha512-SX8jNN+iHqAF0riZQMkm7e8+POXa/fXw5cxL+gjpyP+FI+JVNhii53EmQgDAfDcBpFekYSlO0fGytMQwRiMQCA==
=======
"@typescript-eslint/utils@5.27.1":
version "5.27.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-5.27.1.tgz#b4678b68a94bc3b85bf08f243812a6868ac5128f"
Expand All @@ -1118,11 +1091,10 @@
eslint-scope "^5.1.1"
eslint-utils "^3.0.0"

"@typescript-eslint/visitor-keys@5.14.0":
version "5.14.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.14.0.tgz#1927005b3434ccd0d3ae1b2ecf60e65943c36986"
integrity sha512-yL0XxfzR94UEkjBqyymMLgCBdojzEuy/eim7N9/RIcTNxpJudAcqsU8eRyfzBbcEzGoPWfdM3AGak3cN08WOIw==
>>>>>>> master
"@typescript-eslint/visitor-keys@5.21.0":
version "5.21.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.21.0.tgz#453fb3662409abaf2f8b1f65d515699c888dd8ae"
integrity sha512-SX8jNN+iHqAF0riZQMkm7e8+POXa/fXw5cxL+gjpyP+FI+JVNhii53EmQgDAfDcBpFekYSlO0fGytMQwRiMQCA==
dependencies:
"@typescript-eslint/types" "5.21.0"
eslint-visitor-keys "^3.0.0"
Expand Down Expand Up @@ -1316,7 +1288,7 @@ arb-bridge-peripherals@1.0.10:
optionalDependencies:
"@openzeppelin/upgrades-core" "^1.7.6"

arbos-precompiles@^1.0.2:
arbos-precompiles@1.0.2, arbos-precompiles@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/arbos-precompiles/-/arbos-precompiles-1.0.2.tgz#7bebd5963aef972cd259eb41f3116ea065013ea6"
integrity sha512-1dOFYFJUN0kKoofh6buZJ8qCqTs+oLGSsGzHI0trA/Pka/TCERflCRsNVxez2lihOvK7MT/a2RA8AepKtBXdPQ==
Expand Down Expand Up @@ -1821,7 +1793,7 @@ cross-spawn@^7.0.0, cross-spawn@^7.0.2, cross-spawn@^7.0.3:
shebang-command "^2.0.0"
which "^2.0.1"

debug@4, debug@^4.0.1, debug@^4.1.0, debug@^4.1.1, debug@^4.3.2, debug@^4.3.3:
debug@4, debug@^4.0.1, debug@^4.1.0, debug@^4.1.1, debug@^4.3.2, debug@^4.3.3, debug@^4.3.4:
version "4.3.4"
resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865"
integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==
Expand All @@ -1835,23 +1807,6 @@ debug@4.3.3:
dependencies:
ms "2.1.2"

<<<<<<< HEAD
=======
debug@^2.2.0:
version "2.6.9"
resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f"
integrity sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==
dependencies:
ms "2.0.0"

debug@^4.3.4:
version "4.3.4"
resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865"
integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==
dependencies:
ms "2.1.2"

>>>>>>> master
decamelize@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290"
Expand Down Expand Up @@ -4076,14 +4031,7 @@ semver@^6.0.0, semver@^6.3.0:
resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d"
integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==

semver@^7.0.0, semver@^7.2.1, semver@^7.3.5:
version "7.3.7"
resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.7.tgz#12c5b649afdbf9049707796e22a4028814ce523f"
integrity sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==
dependencies:
lru-cache "^6.0.0"

semver@^7.3.7:
semver@^7.0.0, semver@^7.2.1, semver@^7.3.5, semver@^7.3.7:
version "7.3.7"
resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.7.tgz#12c5b649afdbf9049707796e22a4028814ce523f"
integrity sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==
Expand Down Expand Up @@ -4343,16 +4291,12 @@ supports-color@^7.1.0:
dependencies:
has-flag "^4.0.0"

<<<<<<< HEAD
table-layout@^1.0.2:
=======
supports-preserve-symlinks-flag@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz#6eda4bd344a3c94aea376d4cc31bc77311039e09"
integrity sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==

table-layout@^1.0.1:
>>>>>>> master
table-layout@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/table-layout/-/table-layout-1.0.2.tgz#c4038a1853b0136d63365a734b6931cf4fad4a04"
integrity sha512-qd/R7n5rQTRFi+Zf2sk5XVVd9UQl6ZkduPFC3S7WEGJAmetDTjY3qPN50eSKzwuzEyQKy5TN2TiZdkIjos2L6A==
Expand Down