diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 125d2c8..3ea1274 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,65 +16,70 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 20 steps: - - uses: actions/checkout@v3 - - - name: Install Docker Compose via Package Manager - run: | - sudo apt-get update - sudo apt-get install -y docker-compose - shell: bash - - - name: Verify Docker Compose Installation - run: docker-compose --version - shell: bash - - - name: Start a private ethereum network - uses: ./.github/actions/geth - id: geth - - - name: Sleep for 20 seconds - run: sleep 20s - shell: bash - - - name: Get latest block from geth node - run: | - curl -X POST "http://127.0.0.1:8546" --header 'Content-Type: application/json' --data '{"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["latest", true],"id":1}' - shell: bash - - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install web3 - - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install web3==5.31.3 - shell: bash - - - name: deploy erc20 USDC - run: .github/scripts/init_erc20.sh - shell: bash - - - name: Get erc20 infos - run: python .github/scripts/contract_infos.py - shell: bash - - - name: Populate transactions - run: python .github/scripts/populate_txns.py - shell: bash - - - name: Start Rosetta Server - run: .github/scripts/setup.sh - shell: bash - - - name: Run Check:construction test - run: .github/scripts/construction.sh - shell: bash - - - name: Run Check:data test - run: .github/scripts/cli.sh - shell: bash + - uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v3 + with: + python-version: "3.9" + + - name: Install Docker Compose via Package Manager + run: | + sudo apt-get update + sudo apt-get install -y docker-compose + shell: bash + + - name: Verify Docker Compose Installation + run: docker-compose --version + shell: bash + + - name: Start a private ethereum network + uses: ./.github/actions/geth + id: geth + + - name: Sleep for 20 seconds + run: sleep 20s + shell: bash + + - name: Get latest block from geth node + run: | + curl -X POST "http://127.0.0.1:8546" --header 'Content-Type: application/json' --data '{"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["latest", true],"id":1}' + shell: bash + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install web3 + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install web3==5.31.3 + shell: bash + + - name: deploy erc20 USDC + run: .github/scripts/init_erc20.sh + shell: bash + + - name: Get erc20 infos + run: python .github/scripts/contract_infos.py + shell: bash + + - name: Populate transactions + run: python .github/scripts/populate_txns.py + shell: bash + + - name: Start Rosetta Server + run: .github/scripts/setup.sh + shell: bash + + - name: Run Check:construction test + run: .github/scripts/construction.sh + shell: bash + + - name: Run Check:data test + run: .github/scripts/cli.sh + shell: bash Test: runs-on: ubuntu-latest diff --git a/configuration/configuration.go b/configuration/configuration.go index d531d8e..08fbb90 100644 --- a/configuration/configuration.go +++ b/configuration/configuration.go @@ -131,6 +131,10 @@ type RosettaConfig struct { // ForwardHeaders is the list of headers to forward to and from the native node ForwardHeaders []string + + // Functor to access allowlisted tokens. + // This should be defined in rosetta-xxx implementation if needed + TokenWhitelistAccessor func() ([]Token, error) } type Token struct { diff --git a/services/block_service.go b/services/block_service.go index fd2e2d5..036077a 100644 --- a/services/block_service.go +++ b/services/block_service.go @@ -132,9 +132,21 @@ func (s *BlockAPIService) PopulateTransaction( receiptLogs = tx.Receipt.Logs } - filterTokens := s.client.GetRosettaConfig().FilterTokens - tokenWhiteList := s.client.GetRosettaConfig().TokenWhiteList - useTokenWhiteListMetadata := s.client.GetRosettaConfig().UseTokenWhiteListMetadata + rosettaConfig := s.client.GetRosettaConfig() + filterTokens := rosettaConfig.FilterTokens + + if rosettaConfig.TokenWhitelistAccessor != nil { + whitelist, err := rosettaConfig.TokenWhitelistAccessor() + if err != nil { + return nil, fmt.Errorf("could not get token whitelist: %w", err) + } + + rosettaConfig.TokenWhiteList = whitelist + } + + tokenWhiteList := rosettaConfig.TokenWhiteList + + useTokenWhiteListMetadata := rosettaConfig.UseTokenWhiteListMetadata indexUnknownTokens := s.config.RosettaCfg.IndexUnknownTokens // Compute tx operations via tx.Receipt logs for ERC20 transfer, mint and burn