Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

EOSJS v22.1.0 Release Notes

Latest
Compare
Choose a tag to compare
@eosio-cicd eosio-cicd released this 13 Jul 13:01
· 16 commits to master since this release
1fa93d4

This release is the stable release of EOSJS v22.1.0 and contains features, security, stability and miscellaneous fixes.

Support for Read Only Transactions

This release introduces support for the new feature of read only transactions within smart contracts. This feature provides a contract-supported method of read-only queries from external clients via HTTP-RPC. Prior to this release, access was limited to data stored in a single table in DB or KV tables via the get_table_rows or get_kv_table_rows API, a mechanism which is exacting and inefficient. Read-only queries enable developers to perform more complex, cross-table queries natively via contract code with the assurance that table data is from the same block height. It can also be used to understand the consequences of a transaction before it is sent. More information can be found here in the documentation for cleos and here in the documentation specific to eosjs.

The transaction_trace has been modified with the addition of a bill_to_accounts field, so that it is clear which account paid for cpu/net for the transaction. Additionally, in the case of a failed transaction, available traces are returned to assist in the understanding of why the transaction failed. You can find the failure traces by using the new details field in the RPCError object.

An example transaction using eosjs might look like:

await api.transact({
    actions: [{
        account: 'readonly',
        name: 'get',
        authorization: [{
            actor: 'readonly',
            permission: 'active',
        }],
        data: {},
    }],
}, {
    useLastIrreversible: true,
    expireSeconds: 30,
    readOnlyTrx: true,
    returnFailureTraces: true,
});

The above transaction calls this action that is able to retrieve entries in two tables instead of needing to run get_kv_table_rows multiple times:

[[eosio::action, eosio::read_only]]
std::vector<my_struct> get() {
   my_table_m tm{get_self()};
   my_table_f tf{get_self()};

   std::vector<my_struct> ret;
   auto itm = tm.id.begin();
   auto itm_e = tm.id.end();
   eosio::cout << "Males: \n";
   while(itm != itm_e){
      auto row = itm.value(); 
      eosio::cout << "id=" << row.id << ", name=" << row.name << ",gender=" << row.gender << ", age=" << row.age << "\n"; 
      my_struct s;
      s.id = row.id;
      s.name = row.name;
      s.gender = row.gender;
      s.age = row.age;
      ret.push_back(s);
      ++itm;
   }
   eosio::cout << "Females: \n"; 
   auto itf = tf.id.begin();
   auto itf_e = tf.id.end();
   while(itf != itf_e){
      auto row = itf.value();
      eosio::cout << "id=" << row.id << ", name=" << row.name << ",gender=" << row.gender << ", age=" << row.age << "\n"; 
      my_struct s;
      s.id = row.id;
      s.name = row.name;
      s.gender = row.gender;
      s.age = row.age;
      ret.push_back(s);
     ++itf; 
  }
  return ret;
}

Support for Resource Payer

This release introduces support for the new resource payer feature. Currently the resource costs for transactions on EOSIO-based public networks are paid by the end user of the application, which can make attracting and onboarding new users very difficult. There is a workaround available, but it’s not a straightforward process for either app developers or their end users. If configured per our reference, the additional transaction extension allows a third party to pay for a transactions net and cpu usage. The transaction must be signed by the payer. There is also the ability to limit the amount of cpu and net that the payer is willing to pay. This feature requires that the RESOURCE_PAYER protocol feature is activated. More information can be found here in the documentation for eosio.cdt and here in the documentation specific to eosjs.

Due to difference in the format of transaction_extensions in the transaction compared to other formats, transaction.abi.json has been removed and added directly into the code of eosjs-serialize.ts.

An example transaction using eosjs might look like:

await api.transact({
    resource_payer: {
        payer: 'alice',
        max_net_bytes: 4096,
        max_cpu_us: 400,
        max_memory_bytes: 0
    },
    actions: [{
        account: 'eosio.token',
        name: 'transfer',
        authorization: [{
            actor: 'bob',
            permission: 'active',
        }, {
            actor: 'alice',
            permission: 'active',
        }],
        data: {
            from: 'bob',
            to: 'alice',
            quantity: '0.0001 SYS',
            memo: 'resource payer',
        },
    }]
}, {
    useLastIrreversible: true,
    expireSeconds: 30
});

Other Changes

  • (#829) CI/CD to use new bios/boot systems
  • (#827) Webpack separating external packages and cross-platform building
  • (#826) Additional types for JsonRPC endpoints
  • (#835) New CI/CD workflows to automate docker builds/integration tests
  • (#839) Adjusting scheduled workflows cron (develop branch)
  • (#840) Adding two pipelines for release branch for ci/cd
  • (#843) Updating dependencies of eosjs to latest possible versions
  • (#848) Updating first example to use indexValue in key value documentation
  • (#846) Switching to eosio/eosio docker image in CI/CD
  • (#855) Adding first_block_num to GetInfoResult type
  • (#862) Bump docker/setup-buildx-action from 154c24e1f33dbb5865a021c99f1318cfebf27b32 to 1.1.2
  • (#868) Bump actions/checkout from f90c7b395dac7c5a277c1a6d93d5057c1cddb74e to 2.3.4
  • (#871) Bump actions/setup-node from c6fd00ceb9747fb23ffdf72987450a2664414867 to 2.1.5
  • (#874) Bump docker/setup-qemu-action from 6520a2d2cb6db42c90c297c8025839c98e531268 to 1.0.2
  • (#875) Bump cypress-io/github-action from 6e9b583c9652e99b72b042a3957980fc6166efae to 2.9.11
  • (#888) Bump cypress from 6.9.1 to 7.1.0
  • (#905) Bump webpack from 5.33.2 to 5.34.0
  • (#908) Bump ts-loader from 8.1.0 to 9.0.2
  • (#899) Bump cypress-io/github-action from 89161930792c0050baeba2737caa058c395ecfcb to 2.9.12
  • (#893) Bump docker/build-push-action from 4a531fa5a603bab87dfa56578bd82b28508c9547 to 2.4.0
  • (#922) Bump docker/setup-qemu-action from 25f0500ff22e406f7191a2a8ba8cda16901ca018 to 1.1.0
  • (#923) Bump docker/setup-buildx-action from 2a4b53665e15ce7d7049afb11ff1f70ff1610609 to 1.2.0
  • (#924) Adjusting types to not require data in action from nodeos response
  • (#930) Bump docker/setup-buildx-action from 012185ccbeb554a7f5f987bea0f1a73519b3cdf5 to 1.3.0
  • (#931) Bump docker/login-action from f3364599c6aa293cdc2b8391b1b56d0c30e45c8a to 1.9.0
  • (#932) Bump cypress-io/github-action from 62779d1ffd6210d6f246a8f708cf937d2beac1e9 to 2.10.1
  • (#936) Adjusting the eosjs key value documentation
  • (#941) Bumping version to v22.1.0
  • (#943) Bump cypress-io/github-action from 2.10.1 to 2.10.2
  • (#956) Bump cypress-io/github-action from 2.10.2 to 2.11.0
  • (#955) Bump docker/setup-qemu-action from 1.1.0 to 1.2.0
  • (#954) Bump docker/build-push-action from 2.4.0 to 2.5.0
  • (#970) Adding new bill_to_accounts variable to some endpoint responses
  • (#965) CI/CD changes for PRs #937/#963/#964
  • (#963) Support for Read Only Transactions
  • (#968) Bump docker/login-action from 1.9.0 to 1.10.0
  • (#960) Bump cypress-io/github-action from 2.11.0 to 2.11.5
  • (#964) Support for transaction sponsorship/resource payer
  • (#972) Feature adjustments to resource payer and read only
  • (#986) Separates the web tests to separate tests and adds conditionals
  • (#973) Bump cypress-io/github-action from 2.11.5 to 2.11.6
  • (#974) Bump docker/build-push-action from 2.5.0 to 2.6.1 #974
  • (#975) Bump actions/setup-node from 2.1.5 to 2.2.0 #975
  • (#976) Bump docker/setup-buildx-action from 1.3.0 to 1.5.0

Disclaimer: All repositories and other materials are provided subject to this IMPORTANT notice and you must familiarize yourself with its terms. The notice contains important information, limitations and restrictions relating to our software, publications, trademarks, third-party resources, and forward-looking statements. By accessing any of our repositories and other materials, you accept and agree to the terms of the notice.