Skip to content

IBC Packet Trigger #1189

IBC Packet Trigger

IBC Packet Trigger #1189

name: IBC Packet Trigger
on:
workflow_dispatch:
schedule:
- cron: '0 */2 * * *' # runs every 2 hour
pull_request:
paths:
- .github/workflows/ibc-packet-trigger.yaml
- e2e/schedule/**
jobs:
schedule-run-packet-send:
runs-on: ubuntu-latest
timeout-minutes: 30
env:
# for forcerelay-ckb-sdk
FORCERELAY_CKB_SDK_COMMIT: ${{ vars.FORCERELAY_CKB_SDK_COMMIT || 'main' }}
AXON_RECEIVER: ${{ vars.AXON_RECEIVER || 'f39fd6e51aad88f6f4ce6ab8827279cfffb92266' }}
SUDT_AMOUNT: ${{ vars.SUDT_TRANSFER_AMOUNT || 1000 }}
SDK_WORKSPACE: ${{ github.workspace }}/forcerelay-ckb-sdk
SDK_CONFIG: ${{ github.workspace }}/e2e/schedule/sdk.config.toml
# for ibc-solidity-contract
AXON_HTTP_RPC_URL: https://rpc-alphanet-axon.ckbapp.dev
IBC_SOLIDITY_CONTRACT_COMMIT: ${{ vars.IBC_SOLIDITY_CONTRACT_COMMIT || 'master' }}
CONTRACT_WORKSPACE: ${{ github.workspace }}/ibc-solidity-contract
TRANSFER_CONTRACT_ADDRESS: ${{ vars.TRANSFER_CONTRACT_ADDRESS || '0x5FeaeBfB4439F3516c74939A9D04e95AFE82C4ae' }}
CHANNEL: ${{ vars.AXON_CHANNEL || 'channel-0' }}
DENOM: ${{ vars.AXON_DENOM || 'f2a14f50a56b9aab8e960cb1b2c7f1152d7523e6cacb45b1ab2a94acb83e0233' }}
AMOUNT: ${{ vars.AXON_TRANSFER_AMOUNT || 990 }}
# 1. firstly, run ibc-solidity-contract script to send SendPacket to Axon and then, trigger RecvPacket process via forcerleay-ckb-sdk
# 2. secondly, directly run forcerelay-ckb-sdk to send SendPacket to CKB, and then, it'll automatically listen AckPacket
steps:
- name: Prepare start-time for ibc-solidity-contract
uses: actions/github-script@v6
id: start-time
with:
script: return Date.now()
result-encoding: string
- name: Checkout Forcerelay
uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Set Node.js 18.x
uses: actions/setup-node@v4
with:
node-version: 18.x
- name: Git checkout IBC solidity contracts synapseweb3/ibc-solidity-contract@${{ env.IBC_SOLIDITY_CONTRACT_COMMIT }}
run: git clone --recursive https://github.com/synapseweb3/ibc-solidity-contract.git $CONTRACT_WORKSPACE && cd $CONTRACT_WORKSPACE && git checkout $IBC_SOLIDITY_CONTRACT_COMMIT
- name: Build and compile IBC solidity contracts
working-directory: ${{ env.CONTRACT_WORKSPACE }}
run: yarn install && yarn compile
- name: Git checkout forcerelay-ckb-sdk@${{ env.FORCERELAY_CKB_SDK_COMMIT }}
run: git clone --recursive https://github.com/synapseweb3/forcerelay-ckb-sdk.git $SDK_WORKSPACE && cd $SDK_WORKSPACE && git checkout $FORCERELAY_CKB_SDK_COMMIT
- name: Install forcerelay-ckb-sdk example (sudt-transfer)
uses: actions-rs/cargo@v1
with:
command: install
args: --path ${{ env.SDK_WORKSPACE }} --example sudt-transfer
- name: Print schedule start-time
run: echo "${{ steps.start-time.outputs.result }}"
- name: 0. Trigger SendPacket on CKB (sUDT)
env:
SUDT_TRANSFER_PRIVATE_KEY: ${{ secrets.SUDT_TRANSFER_PRIVATE_KEY }}
run: sudt-transfer --config $SDK_CONFIG send --receiver $AXON_RECEIVER --amount $SUDT_AMOUNT --sudt yukun_li
# TODO: need some verification steps
# script: https://github.com/synapseweb3/ibc-solidity-contract/blob/e0d1f4bf20c40aad721bff5838d8a3fa80c94585/scripts/send_erc20_packet_back.js
# sender: https://explorer-alphanet-axon.ckbapp.dev/address/0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266
# receiver: https://explorer-alphanet-axon.ckbapp.dev/address/0xbb559cdd754bed4637293c65bf5fdd1e43c8241e
# Note: The address of the receiver on CKB chain is `ckb_blake2b(packed CKB lock script)[..20]`.
- name: 1. Trigger SendPacket event on Axon (ERC20)
working-directory: ${{ env.CONTRACT_WORKSPACE }}
env:
RECEIVER: ${{ vars.SUDT_RECEIVER }}
run: yarn send
- name: 2. Listen RecvPacket event on CKB
env:
SUDT_TRANSFER_PRIVATE_KEY: ${{ secrets.SUDT_TRANSFER_PRIVATE_KEY }}
run: sudt-transfer --config $SDK_CONFIG recv
# TODO: need some verification steps