Skip to content

feat: retryable ticket viem wrapper and transferOwnership example #684

Description

@yahgwai

Context

The chain-sdk needs viem-friendly wrappers around new arbitrum-sdk retryable primitives to support cross-chain scripting workflows like ownership transfer. The bridging pattern already exists in createTokenBridge-ethers.ts using publicClientToProvider.

Depends on: OffchainLabs/arbitrum-sdk#639

Scope

Viem wrappers (in src/)

  • encodeRetryableTicket -- wraps the arbitrum-sdk function, accepts viem PublicClient, converts via publicClientToProvider, returns viem-friendly types (bigint, hex)
  • encodeSendL2Message -- thin wrapper if needed (may just re-export since it's pure encoding)

Schemas (in src/scripting/schemas/)

  • Schema for encodeRetryableTicket params (addresses, gas params, calldata)
  • Schema for arbOwnerPrepareTransactionRequest params (functionName, upgradeExecutor, account)
  • Type tests verifying schema outputs match function params
  • Export from schemas/index.ts

Example script: transferOwnership.ts

  • Accepts: parentChainRpcUrl, privateKey, upgradeExecutorAddress, childUpgradeExecutorAddress, inboxAddress, newOwnerAddress, maxGasLimit, maxGasPrice, nativeToken (defaults to zeroAddress)
  • Implements all 6 steps of the ownership transfer:
    1. Add new owner as executor on parent-chain UpgradeExecutor
    2. Grant new owner executor role on child-chain UpgradeExecutor (retryable ticket through parent UE)
    3. Add child-chain UpgradeExecutor as chain owner via ArbOwner (signed L2 message through Inbox)
    4. Remove deployer as chain owner via ArbOwner (signed L2 message through Inbox)
    5. Revoke deployer executor role on child-chain UpgradeExecutor (retryable ticket through parent UE)
    6. Remove deployer as executor on parent-chain UpgradeExecutor
  • Uses runScript harness with zod schema + transform

Out of scope

  • Generic prepareRetryableTicketTransactionRequest (callers compose encodeRetryableTicket output with either direct Inbox call or UpgradeExecutor wrapping as needed)

Motivation

Mirrors the transferOwnership script from chains-playground, but using SDK functions and the scripting harness. Steps 1 and 6 already work with existing upgradeExecutorPrepareAdd/RemoveExecutorTransactionRequest functions. Steps 2-5 need the new retryable/L2 message primitives from OffchainLabs/arbitrum-sdk#639.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions