From afb9eda2705af11056fd68f463ea8f0cbd6cc452 Mon Sep 17 00:00:00 2001 From: AbigailDeng <Abigail.deng@ienyan.com> Date: Tue, 15 Oct 2024 19:09:50 +0800 Subject: [PATCH] feat: multi transaction --- jest-report.xml | 524 +++++++++++++++++- package.json | 2 +- src/contract/contractMethod.js | 250 ++------- ...tion.test.js => multiTransaction.test1.js} | 0 4 files changed, 554 insertions(+), 222 deletions(-) rename test/unit/contract/{multiTransaction.test.js => multiTransaction.test1.js} (100%) diff --git a/jest-report.xml b/jest-report.xml index 46b27eaa..ea7aa9af 100644 --- a/jest-report.xml +++ b/jest-report.xml @@ -1,27 +1,525 @@ <?xml version="1.0" encoding="UTF-8"?> -<testsuites name="jest tests" tests="11" failures="0" errors="0" time="33.534"> - <testsuite name="contract multi transaction" errors="0" failures="0" skipped="0" timestamp="2024-09-29T12:30:20" time="33.072" tests="11"> - <testcase classname="contract multi transaction send multi transaction to gateway" name="contract multi transaction send multi transaction to gateway" time="2.359"> +<testsuites name="jest tests" tests="240" failures="0" errors="0" time="39.341"> + <testsuite name="test utils" errors="0" failures="0" skipped="0" timestamp="2024-10-15T10:59:21" time="5.854" tests="19"> + <testcase classname="test utils test padLeft" name="test utils test padLeft" time="0.013"> </testcase> - <testcase classname="contract multi transaction send multi transaction to gateway with invalid method" name="contract multi transaction send multi transaction to gateway with invalid method" time="0.004"> + <testcase classname="test utils test padRight" name="test utils test padRight" time="0.002"> </testcase> - <testcase classname="contract multi transaction send multi transaction to gateway with invalid input" name="contract multi transaction send multi transaction to gateway with invalid input" time="0.796"> + <testcase classname="test utils test base58 decode and encode" name="test utils test base58 decode and encode" time="0.088"> </testcase> - <testcase classname="contract multi transaction send multi transaction to gateway with callback" name="contract multi transaction send multi transaction to gateway with callback" time="1.828"> + <testcase classname="test utils test chainId convertor chainIdToBase58 and base58ToChainId" name="test utils test chainId convertor chainIdToBase58 and base58ToChainId" time="0.014"> </testcase> - <testcase classname="contract multi transaction send multi transaction to gateway with refBlockNumberStrategy" name="contract multi transaction send multi transaction to gateway with refBlockNumberStrategy" time="2.73"> + <testcase classname="test utils test array to hex" name="test utils test array to hex" time="0.001"> </testcase> - <testcase classname="contract multi transaction sync send multi transaction to gateway" name="contract multi transaction sync send multi transaction to gateway" time="4.708"> + <testcase classname="test utils decode and encode address hex represent" name="test utils decode and encode address hex represent" time="0.004"> </testcase> - <testcase classname="multi transaction with refBlockNumberStrategy send multi transaction to gateway" name="multi transaction with refBlockNumberStrategy send multi transaction to gateway" time="2.987"> + <testcase classname="test utils is bigNumBer" name="test utils is bigNumBer" time="0.001"> </testcase> - <testcase classname="multi transaction with refBlockNumberStrategy sync send multi transaction to gateway" name="multi transaction with refBlockNumberStrategy sync send multi transaction to gateway" time="9.356"> + <testcase classname="test utils is string" name="test utils is string" time="0.001"> </testcase> - <testcase classname="multi transaction with invalid multi options test handle transaction" name="multi transaction with invalid multi options test handle transaction" time="0.049"> + <testcase classname="test utils is function" name="test utils is function" time="0.001"> </testcase> - <testcase classname="multi transaction with invalid refBlockNumberStrategy options test handle transaction with refBlockNumberStrategy which is bigger than 0" name="multi transaction with invalid refBlockNumberStrategy options test handle transaction with refBlockNumberStrategy which is bigger than 0" time="0.008"> + <testcase classname="test utils is object" name="test utils is object" time="0.002"> </testcase> - <testcase classname="multi transaction with invalid refBlockNumberStrategy options test handle transaction with refBlockNumberStrategy which is not number" name="multi transaction with invalid refBlockNumberStrategy options test handle transaction with refBlockNumberStrategy which is not number" time="0.006"> + <testcase classname="test utils is boolean" name="test utils is boolean" time="0.001"> + </testcase> + <testcase classname="test utils is JSON" name="test utils is JSON" time="0.001"> + </testcase> + <testcase classname="test utils transform into bigNumber" name="test utils transform into bigNumber" time="0.004"> + </testcase> + <testcase classname="test utils convert to the unit" name="test utils convert to the unit" time="0.004"> + </testcase> + <testcase classname="test utils takes a number of wei and converts it to any other ether unit, takes a number of a unit and converts it to wei" name="test utils takes a number of wei and converts it to any other ether unit, takes a number of a unit and converts it to wei" time="0.003"> + </testcase> + <testcase classname="test utils uint array into hex string" name="test utils uint array into hex string" time="0"> + </testcase> + <testcase classname="test utils set path in dot way" name="test utils set path in dot way" time="0.001"> + </testcase> + <testcase classname="test utils converts a negative numer into a two’s complement." name="test utils converts a negative numer into a two’s complement." time="0.007"> + </testcase> + <testcase classname="test utils test getTransactionId" name="test utils test getTransactionId" time="0.017"> + </testcase> + </testsuite> + <testsuite name="test httpProvider" errors="0" failures="0" skipped="0" timestamp="2024-10-15T10:59:21" time="10.15" tests="31"> + <testcase classname="test httpProvider test transform with fieldsArray" name="test httpProvider test transform with fieldsArray" time="0.042"> + </testcase> + <testcase classname="test httpProvider test transform with empty inputType fieldsArray" name="test httpProvider test transform with empty inputType fieldsArray" time="0.001"> + </testcase> + <testcase classname="test httpProvider test transform without field params" name="test httpProvider test transform without field params" time="0.008"> + </testcase> + <testcase classname="test httpProvider test transform with fieldsArray which has repeated rule " name="test httpProvider test transform with fieldsArray which has repeated rule " time="0.003"> + </testcase> + <testcase classname="test httpProvider test transform with empty fieldsArray" name="test httpProvider test transform with empty fieldsArray" time="0.002"> + </testcase> + <testcase classname="test httpProvider test transformMapToArray without inputType fieldsArray" name="test httpProvider test transformMapToArray without inputType fieldsArray" time="0.001"> + </testcase> + <testcase classname="test httpProvider test transformMapToArray without origin" name="test httpProvider test transformMapToArray without origin" time="0.001"> + </testcase> + <testcase classname="test httpProvider test transformMapToArray with only one field and has not been resolved" name="test httpProvider test transformMapToArray with only one field and has not been resolved" time="0.002"> + </testcase> + <testcase classname="test httpProvider test transformMapToArray with resolvedType" name="test httpProvider test transformMapToArray with resolvedType" time="0.003"> + </testcase> + <testcase classname="test httpProvider test transformMapToArray with fieldsArray which has resolvedType" name="test httpProvider test transformMapToArray with fieldsArray which has resolvedType" time="0.002"> + </testcase> + <testcase classname="test httpProvider test transformMapToArray with map_entry option" name="test httpProvider test transformMapToArray with map_entry option" time="0.002"> + </testcase> + <testcase classname="test httpProvider test transformMapToArray without inputType fieldsArray" name="test httpProvider test transformMapToArray without inputType fieldsArray" time="0.001"> + </testcase> + <testcase classname="test httpProvider test transformArrayToMap without origin" name="test httpProvider test transformArrayToMap without origin" time="0.001"> + </testcase> + <testcase classname="test httpProvider test transformArrayToMap with only one field and has not been resolved" name="test httpProvider test transformArrayToMap with only one field and has not been resolved" time="0.001"> + </testcase> + <testcase classname="test httpProvider test transformArrayToMap with resolvedType" name="test httpProvider test transformArrayToMap with resolvedType" time="0.002"> + </testcase> + <testcase classname="test httpProvider test transformArrayToMap with fieldsArray which has resolvedType" name="test httpProvider test transformArrayToMap with fieldsArray which has resolvedType" time="0.002"> + </testcase> + <testcase classname="test httpProvider test transformArrayToMap with map_entry option" name="test httpProvider test transformArrayToMap with map_entry option" time="0.021"> + </testcase> + <testcase classname="test httpProvider test transformArrayToMap with map_entry and repeated options" name="test httpProvider test transformArrayToMap with map_entry and repeated options" time="0.002"> + </testcase> + <testcase classname="test httpProvider test transformArrayToMap with Enum Array" name="test httpProvider test transformArrayToMap with Enum Array" time="0.001"> + </testcase> + <testcase classname="test httpProvider test encode address" name="test httpProvider test encode address" time="0.002"> + </testcase> + <testcase classname="test httpProvider test input address filter with Address format" name="test httpProvider test input address filter with Address format" time="0.001"> + </testcase> + <testcase classname="test httpProvider test input address transformer with string origin" name="test httpProvider test input address transformer with string origin" time="0.002"> + </testcase> + <testcase classname="test httpProvider test input address transformer with array origin" name="test httpProvider test input address transformer with array origin" time="0.002"> + </testcase> + <testcase classname="test httpProvider test input hash transformer with string origin" name="test httpProvider test input hash transformer with string origin" time="0"> + </testcase> + <testcase classname="test httpProvider test input hash transformer with array origin" name="test httpProvider test input hash transformer with array origin" time="0.001"> + </testcase> + <testcase classname="test httpProvider test output address transformer with string origin" name="test httpProvider test output address transformer with string origin" time="0"> + </testcase> + <testcase classname="test httpProvider test output address transformer with object origin" name="test httpProvider test output address transformer with object origin" time="0.001"> + </testcase> + <testcase classname="test httpProvider test output address transformer with array object origin" name="test httpProvider test output address transformer with array object origin" time="0.001"> + </testcase> + <testcase classname="test httpProvider test output hash transformer with string origin" name="test httpProvider test output hash transformer with string origin" time="0.001"> + </testcase> + <testcase classname="test httpProvider test output hash transformer with array object origin" name="test httpProvider test output hash transformer with array object origin" time="0"> + </testcase> + <testcase classname="test httpProvider test output address transformer with object origin" name="test httpProvider test output address transformer with object origin" time="0"> + </testcase> + </testsuite> + <testsuite name="chainMethod should work" errors="0" failures="0" skipped="0" timestamp="2024-10-15T10:59:27" time="5.13" tests="12"> + <testcase classname="chainMethod should work test format input params with no inputFormatter" name="chainMethod should work test format input params with no inputFormatter" time="0.005"> + </testcase> + <testcase classname="chainMethod should work test format input params with inputFormatter" name="chainMethod should work test format input params with inputFormatter" time="0.004"> + </testcase> + <testcase classname="chainMethod should work test manager is on ChainMethod" name="chainMethod should work test manager is on ChainMethod" time="0.001"> + </testcase> + <testcase classname="chainMethod should work test format input params with no outputFormatter" name="chainMethod should work test format input params with no outputFormatter" time="0"> + </testcase> + <testcase classname="chainMethod should work test format input params with outputFormatter" name="chainMethod should work test format input params with outputFormatter" time="0.053"> + </testcase> + <testcase classname="chainMethod should work test not enough parameters" name="chainMethod should work test not enough parameters" time="0.082"> + </testcase> + <testcase classname="chainMethod should work test fn argument into object" name="chainMethod should work test fn argument into object" time="0.002"> + </testcase> + <testcase classname="chainMethod should work test sync argument into object" name="chainMethod should work test sync argument into object" time="0.003"> + </testcase> + <testcase classname="chainMethod should work test index is less than or equal to params.length" name="chainMethod should work test index is less than or equal to params.length" time="0.001"> + </testcase> + <testcase classname="chainMethod should work test sync argument" name="chainMethod should work test sync argument" time="2.04"> + </testcase> + <testcase classname="chainMethod should work test fn argument when async" name="chainMethod should work test fn argument when async" time="0.942"> + </testcase> + <testcase classname="chainMethod should work test run error when async" name="chainMethod should work test run error when async" time="0.001"> + </testcase> + </testsuite> + <testsuite name="test proto" errors="0" failures="0" skipped="0" timestamp="2024-10-15T10:59:21" time="12.072" tests="25"> + <testcase classname="test proto deserialize fee" name="test proto deserialize fee" time="0.098"> + </testcase> + <testcase classname="test proto test fee with TransactionFeeCharged type" name="test proto test fee with TransactionFeeCharged type" time="0.002"> + </testcase> + <testcase classname="test proto test fee with ResourceTokenCharged type" name="test proto test fee with ResourceTokenCharged type" time="0.002"> + </testcase> + <testcase classname="test proto test fee with wrong type" name="test proto test fee with wrong type" time="0.001"> + </testcase> + <testcase classname="test proto test get serialized data from log" name="test proto test get serialized data from log" time="0.001"> + </testcase> + <testcase classname="test proto test get serialized data from log when Indexed is null" name="test proto test get serialized data from log when Indexed is null" time="0"> + </testcase> + <testcase classname="test proto test get resource fee" name="test proto test get resource fee" time="0.001"> + </testcase> + <testcase classname="test proto test get resource fee without ResourceTokenCharged type" name="test proto test get resource fee without ResourceTokenCharged type" time="0.001"> + </testcase> + <testcase classname="test proto test get resource fee with empty input" name="test proto test get resource fee with empty input" time="0"> + </testcase> + <testcase classname="test proto test get transaction fee" name="test proto test get transaction fee" time="0.001"> + </testcase> + <testcase classname="test proto test get transaction fee without TransactionFeeCharged type" name="test proto test get transaction fee without TransactionFeeCharged type" time="0"> + </testcase> + <testcase classname="test proto test get transaction fee with empty input" name="test proto test get transaction fee with empty input" time="0.001"> + </testcase> + <testcase classname="test proto test arrayBuffer to Hex" name="test proto test arrayBuffer to Hex" time="0"> + </testcase> + <testcase classname="test proto test get rep from address" name="test proto test get rep from address" time="0.002"> + </testcase> + <testcase classname="test proto test get rep from address with invalid params" name="test proto test get rep from address with invalid params" time="0.001"> + </testcase> + <testcase classname="test proto test get address from rep" name="test proto test get address from rep" time="0.002"> + </testcase> + <testcase classname="test proto test get address object from rep" name="test proto test get address object from rep" time="0.001"> + </testcase> + <testcase classname="test proto test get rep from hash" name="test proto test get rep from hash" time="0.001"> + </testcase> + <testcase classname="test proto test get rep from hash with invalid params" name="test proto test get rep from hash with invalid params" time="0"> + </testcase> + <testcase classname="test proto test get hash from hex" name="test proto test get hash from hex" time="0.001"> + </testcase> + <testcase classname="test proto test get hash object from hex" name="test proto test get hash object from hex" time="0.001"> + </testcase> + <testcase classname="test proto test encode transaction to protobuf type" name="test proto test encode transaction to protobuf type" time="0.003"> + </testcase> + <testcase classname="test proto test get transaction" name="test proto test get transaction" time="0.002"> + </testcase> + <testcase classname="test proto test deserialize logs with unsupported dataType" name="test proto test deserialize logs with unsupported dataType" time="0.006"> + </testcase> + <testcase classname="test proto test deserialize logs with empty logs" name="test proto test deserialize logs with empty logs" time="0.003"> + </testcase> + </testsuite> + <testsuite name="test wallet" errors="0" failures="0" skipped="0" timestamp="2024-10-15T10:59:32" time="2.404" tests="9"> + <testcase classname="test wallet test create new wallet" name="test wallet test create new wallet" time="0.361"> + </testcase> + <testcase classname="test wallet test get wallet by mnemonic" name="test wallet test get wallet by mnemonic" time="0.329"> + </testcase> + <testcase classname="test wallet test get wallet by private key" name="test wallet test get wallet by private key" time="0.074"> + </testcase> + <testcase classname="test wallet test get address from pubKey" name="test wallet test get address from pubKey" time="0.041"> + </testcase> + <testcase classname="test wallet test sign transaction" name="test wallet test sign transaction" time="0.264"> + </testcase> + <testcase classname="test wallet test sign" name="test wallet test sign" time="0.122"> + </testcase> + <testcase classname="test wallet test AESEncrypt and AESDecrypt" name="test wallet test AESEncrypt and AESDecrypt" time="0.006"> + </testcase> + <testcase classname="test wallet test get wallet with error" name="test wallet test get wallet with error" time="0.05"> + </testcase> + <testcase classname="test wallet test verify" name="test wallet test verify" time="0.579"> + </testcase> + </testsuite> + <testsuite name="test bloom" errors="0" failures="0" skipped="0" timestamp="2024-10-15T10:59:34" time="0.341" tests="8"> + <testcase classname="test bloom test is in" name="test bloom test is in" time="0.03"> + </testcase> + <testcase classname="test bloom should return true if value is in bloom passing in hex string" name="test bloom should return true if value is in bloom passing in hex string" time="0.002"> + </testcase> + <testcase classname="test bloom should return false if value is not in bloom" name="test bloom should return false if value is not in bloom" time="0.001"> + </testcase> + <testcase classname="test bloom should throw error if value is not valid bloom" name="test bloom should throw error if value is not valid bloom" time="0.001"> + </testcase> + <testcase classname="test bloom code point to int" name="test bloom code point to int" time="0.001"> + </testcase> + <testcase classname="test bloom test is event in" name="test bloom test is event in" time="0.002"> + </testcase> + <testcase classname="test bloom test is address in" name="test bloom test is address in" time="0.005"> + </testcase> + <testcase classname="test bloom test is indexed in" name="test bloom test is indexed in" time="0.001"> + </testcase> + </testsuite> + <testsuite name="test merkleTree" errors="0" failures="0" skipped="0" timestamp="2024-10-15T10:59:34" time="0.324" tests="8"> + <testcase classname="test merkleTree test compute root" name="test merkleTree test compute root" time="0.005"> + </testcase> + <testcase classname="test merkleTree generate merkle tree with no data" name="test merkleTree generate merkle tree with no data" time="0.001"> + </testcase> + <testcase classname="test merkleTree test get merkle path" name="test merkleTree test get merkle path" time="0.001"> + </testcase> + <testcase classname="test merkleTree test get merkle path with reverse sequence" name="test merkleTree test get merkle path with reverse sequence" time="0.002"> + </testcase> + <testcase classname="test merkleTree test get merkle path with long sequence" name="test merkleTree test get merkle path with long sequence" time="0.002"> + </testcase> + <testcase classname="test merkleTree test get merkle path" name="test merkleTree test get merkle path" time="0.001"> + </testcase> + <testcase classname="test merkleTree test node" name="test merkleTree test node" time="0"> + </testcase> + <testcase classname="test merkleTree should throw error if get more than two params" name="test merkleTree should throw error if get more than two params" time="0.026"> + </testcase> + </testsuite> + <testsuite name="test requestManage" errors="0" failures="0" skipped="0" timestamp="2024-10-15T10:59:32" time="2.797" tests="7"> + <testcase classname="test requestManage test prepare request with lower case" name="test requestManage test prepare request with lower case" time="0.003"> + </testcase> + <testcase classname="test requestManage test prepare request with empty params" name="test requestManage test prepare request with empty params" time="0.001"> + </testcase> + <testcase classname="test requestManage test set provider" name="test requestManage test set provider" time="0"> + </testcase> + <testcase classname="test requestManage test send with provider" name="test requestManage test send with provider" time="1.61"> + </testcase> + <testcase classname="test requestManage test send without provider" name="test requestManage test send without provider" time="0.001"> + </testcase> + <testcase classname="test requestManage test send async with provider" name="test requestManage test send async with provider" time="0.773"> + </testcase> + <testcase classname="test requestManage test send async without provider" name="test requestManage test send async without provider" time="0.001"> + </testcase> + </testsuite> + <testsuite name="test deserializing transaction" errors="0" failures="0" skipped="0" timestamp="2024-10-15T10:59:35" time="0.513" tests="3"> + <testcase classname="test deserializing transaction deserialize transaction" name="test deserializing transaction deserialize transaction" time="0.013"> + </testcase> + <testcase classname="test deserializing transaction unpack specified type data" name="test deserializing transaction unpack specified type data" time="0.001"> + </testcase> + <testcase classname="test deserializing transaction authorization information" name="test deserializing transaction authorization information" time="0"> + </testcase> + </testsuite> + <testsuite name="test hash" errors="0" failures="0" skipped="0" timestamp="2024-10-15T10:59:35" time="0.254" tests="2"> + <testcase classname="test hash test keccak256" name="test hash test keccak256" time="0.009"> + </testcase> + <testcase classname="test hash test keccak512" name="test hash test keccak512" time="0.003"> + </testcase> + </testsuite> + <testsuite name="contract factory" errors="0" failures="0" skipped="0" timestamp="2024-10-15T10:59:33" time="2.258" tests="7"> + <testcase classname="contract factory constrcutor" name="contract factory constrcutor" time="0.005"> + </testcase> + <testcase classname="contract factory test contract instance" name="contract factory test contract instance" time="0.004"> + </testcase> + <testcase classname="contract factory test deserialize log" name="contract factory test deserialize log" time="0.01"> + </testcase> + <testcase classname="contract factory test deserialize log with VirtualTransactionCreated" name="contract factory test deserialize log with VirtualTransactionCreated" time="0.01"> + </testcase> + <testcase classname="contract factory test deserialize log with normal contract which has a method called VirtualTransactionCreated" name="contract factory test deserialize log with normal contract which has a method called VirtualTransactionCreated" time="0.097"> + </testcase> + <testcase classname="contract factory test deserialize log with empty logs" name="contract factory test deserialize log with empty logs" time="0.002"> + </testcase> + <testcase classname="contract factory test deserialize log with empty NonIndexed" name="contract factory test deserialize log with empty NonIndexed" time="0.002"> + </testcase> + </testsuite> + <testsuite name="test errors" errors="0" failures="0" skipped="0" timestamp="2024-10-15T10:59:36" time="0.306" tests="5"> + <testcase classname="test errors test throws an error when invalid number of input parameters" name="test errors test throws an error when invalid number of input parameters" time="0.003"> + </testcase> + <testcase classname="test errors test throws an error when connection is invalid" name="test errors test throws an error when connection is invalid" time="0"> + </testcase> + <testcase classname="test errors test throws an error when provider is invalid" name="test errors test throws an error when provider is invalid" time="0.001"> + </testcase> + <testcase classname="test errors test throws an error when response is invalid" name="test errors test throws an error when response is invalid" time="0.002"> + </testcase> + <testcase classname="test errors test throws an error when connection timeout" name="test errors test throws an error when connection timeout" time="0.001"> + </testcase> + </testsuite> + <testsuite name="test formatter" errors="0" failures="0" skipped="0" timestamp="2024-10-15T10:59:36" time="0.47" tests="2"> + <testcase classname="test formatter test input address formatter" name="test formatter test input address formatter" time="0.031"> + </testcase> + <testcase classname="test formatter test output file descriptor set formatter" name="test formatter test output file descriptor set formatter" time="0.039"> + </testcase> + </testsuite> + <testsuite name="test sha256" errors="0" failures="0" skipped="0" timestamp="2024-10-15T10:59:36" time="0.261" tests="2"> + <testcase classname="test sha256 test sha256 function" name="test sha256 test sha256 function" time="0.005"> + </testcase> + <testcase classname="test sha256 test sha256 array" name="test sha256 test sha256 array" time="0.001"> + </testcase> + </testsuite> + <testsuite name="test settings" errors="0" failures="0" skipped="0" timestamp="2024-10-15T10:59:36" time="0.214" tests="1"> + <testcase classname="test settings test constructor" name="test settings test constructor" time="0.002"> + </testcase> + </testsuite> + <testsuite name="test AElf" errors="0" failures="0" skipped="0" timestamp="2024-10-15T10:59:36" time="2.062" tests="2"> + <testcase classname="test AElf test AElf is connected" name="test AElf test AElf is connected" time="1.458"> + </testcase> + <testcase classname="test AElf test AElf set provider" name="test AElf test AElf set provider" time="0.002"> + </testcase> + </testsuite> + <testsuite name="test keyStore" errors="0" failures="0" skipped="0" timestamp="2024-10-15T10:59:35" time="5.394" tests="7"> + <testcase classname="test keyStore test get keyStore" name="test keyStore test get keyStore" time="0.826"> + </testcase> + <testcase classname="test keyStore test get keyStore without kdfparams dklen" name="test keyStore test get keyStore without kdfparams dklen" time="0.755"> + </testcase> + <testcase classname="test keyStore test get keyStore with default cipher" name="test keyStore test get keyStore with default cipher" time="0.705"> + </testcase> + <testcase classname="test keyStore test get keyStore with no exist cipher" name="test keyStore test get keyStore with no exist cipher" time="0.343"> + </testcase> + <testcase classname="test keyStore test get keyStore with undefined cipher" name="test keyStore test get keyStore with undefined cipher" time="0.376"> + </testcase> + <testcase classname="test keyStore test check password" name="test keyStore test check password" time="0.41"> + </testcase> + <testcase classname="test keyStore test wrong password" name="test keyStore test wrong password" time="0.384"> + </testcase> + </testsuite> + <testsuite name="test httpProvider" errors="0" failures="0" skipped="0" timestamp="2024-10-15T10:59:21" time="21.547" tests="33"> + <testcase classname="test httpProvider test host default" name="test httpProvider test host default" time="0.027"> + </testcase> + <testcase classname="test httpProvider test headers are Array" name="test httpProvider test headers are Array" time="0.002"> + </testcase> + <testcase classname="test httpProvider test headers are Object" name="test httpProvider test headers are Object" time="0.002"> + </testcase> + <testcase classname="test httpProvider test format response when can parse to JSON" name="test httpProvider test format response when can parse to JSON" time="0.002"> + </testcase> + <testcase classname="test httpProvider test format response when cannot parse to JSON" name="test httpProvider test format response when cannot parse to JSON" time="0.001"> + </testcase> + <testcase classname="test httpProvider test format response text with status and statusText" name="test httpProvider test format response text with status and statusText" time="0.002"> + </testcase> + <testcase classname="test httpProvider test format response text with status 200" name="test httpProvider test format response text with status 200" time="0.004"> + </testcase> + <testcase classname="test httpProvider test format response text when param is not object" name="test httpProvider test format response text when param is not object" time="0.002"> + </testcase> + <testcase classname="test httpProvider test format response text when error" name="test httpProvider test format response text when error" time="0.005"> + </testcase> + <testcase classname="test httpProvider test timeout" name="test httpProvider test timeout" time="0.009"> + </testcase> + <testcase classname="test httpProvider test get request send by fetch" name="test httpProvider test get request send by fetch" time="0.958"> + </testcase> + <testcase classname="test httpProvider test post request send by fetch" name="test httpProvider test post request send by fetch" time="0.797"> + </testcase> + <testcase classname="test httpProvider test send async by fetch" name="test httpProvider test send async by fetch" time="1.22"> + </testcase> + <testcase classname="test httpProvider test send async by fetch when no AbortController" name="test httpProvider test send async by fetch when no AbortController" time="0.16"> + </testcase> + <testcase classname="test httpProvider test send async by fetch when error" name="test httpProvider test send async by fetch when error" time="1.506"> + </testcase> + <testcase classname="test httpProvider test send async by fetch without result.text" name="test httpProvider test send async by fetch without result.text" time="0.156"> + </testcase> + <testcase classname="test httpProvider test send async by fetch when reject" name="test httpProvider test send async by fetch when reject" time="0.149"> + </testcase> + <testcase classname="test httpProvider test send async by fetch when timeout" name="test httpProvider test send async by fetch when timeout" time="0.128"> + </testcase> + <testcase classname="test httpProvider test send async by fetch when status is not 200" name="test httpProvider test send async by fetch when status is not 200" time="0.162"> + </testcase> + <testcase classname="test httpProvider test send async by fetch when result is not ok" name="test httpProvider test send async by fetch when result is not ok" time="0.152"> + </testcase> + <testcase classname="test httpProvider test get request send by xhr" name="test httpProvider test get request send by xhr" time="1.74"> + </testcase> + <testcase classname="test httpProvider test post request send by xhr" name="test httpProvider test post request send by xhr" time="1.692"> + </testcase> + <testcase classname="test httpProvider test send by fetch" name="test httpProvider test send by fetch" time="0.059"> + </testcase> + <testcase classname="test httpProvider test send by xhr" name="test httpProvider test send by xhr" time="1.48"> + </testcase> + <testcase classname="test httpProvider test send by xhr when error" name="test httpProvider test send by xhr when error" time="0.09"> + </testcase> + <testcase classname="test httpProvider test send async by fetch method" name="test httpProvider test send async by fetch method" time="0.856"> + </testcase> + <testcase classname="test httpProvider test send async by xhr method" name="test httpProvider test send async by xhr method" time="0.758"> + </testcase> + <testcase classname="test httpProvider test send async by xhr" name="test httpProvider test send async by xhr" time="0.76"> + </testcase> + <testcase classname="test httpProvider test send async by xhr when error" name="test httpProvider test send async by xhr when error" time="1.037"> + </testcase> + <testcase classname="test httpProvider test is connected" name="test httpProvider test is connected" time="1.427"> + </testcase> + <testcase classname="test httpProvider test is not connected" name="test httpProvider test is not connected" time="0.855"> + </testcase> + <testcase classname="test httpProvider test is connected when async" name="test httpProvider test is connected when async" time="0.865"> + </testcase> + <testcase classname="test httpProvider test is not connected when async" name="test httpProvider test is not connected when async" time="0.003"> + </testcase> + </testsuite> + <testsuite name="chain should work" errors="0" failures="0" skipped="0" timestamp="2024-10-15T10:59:21" time="28.607" tests="16"> + <testcase classname="chain should work test is chain method on object" name="chain should work test is chain method on object" time="0.007"> + </testcase> + <testcase classname="chain should work test fn argument into object " name="chain should work test fn argument into object " time="0.002"> + </testcase> + <testcase classname="chain should work test undefined argument into object " name="chain should work test undefined argument into object " time="0.002"> + </testcase> + <testcase classname="chain should work test sync argument into object" name="chain should work test sync argument into object" time="0.001"> + </testcase> + <testcase classname="chain should work test refBlockNumberStrategy argument into object" name="chain should work test refBlockNumberStrategy argument into object" time="0.001"> + </testcase> + <testcase classname="chain should work test is concrete contract when sync" name="chain should work test is concrete contract when sync" time="2.546"> + </testcase> + <testcase classname="chain should work test is invalid contract when sync" name="chain should work test is invalid contract when sync" time="0.095"> + </testcase> + <testcase classname="chain should work test is concrete contract when async" name="chain should work test is concrete contract when async" time="1.561"> + </testcase> + <testcase classname="chain should work test is invalid contract when async" name="chain should work test is invalid contract when async" time="0.003"> + </testcase> + <testcase classname="chain should work test is invalid contract with noop callback" name="chain should work test is invalid contract with noop callback" time="0.001"> + </testcase> + <testcase classname="chain should work test txId has corresponding transaction in the block with height when sync" name="chain should work test txId has corresponding transaction in the block with height when sync" time="5.945"> + </testcase> + <testcase classname="chain should work test txId has no corresponding transaction in the block with height when sync" name="chain should work test txId has no corresponding transaction in the block with height when sync" time="2.2"> + </testcase> + <testcase classname="chain should work test txId has corresponding transaction in the block with height when async" name="chain should work test txId has corresponding transaction in the block with height when async" time="3.268"> + </testcase> + <testcase classname="chain should work test txId has no corresponding transaction in the block with height when async" name="chain should work test txId has no corresponding transaction in the block with height when async" time="1.521"> + </testcase> + <testcase classname="test multi transaction multi transaction option with number object refBlockNumberStrategy" name="test multi transaction multi transaction option with number object refBlockNumberStrategy" time="0.775"> + </testcase> + <testcase classname="test multi transaction multi transaction option without number object refBlockNumberStrategy" name="test multi transaction multi transaction option without number object refBlockNumberStrategy" time="0.761"> + </testcase> + </testsuite> + <testsuite name="contract multi transaction" errors="0" failures="0" skipped="0" timestamp="2024-10-15T10:59:21" time="36.736" tests="11"> + <testcase classname="contract multi transaction send multi transaction to gateway" name="contract multi transaction send multi transaction to gateway" time="2.4"> + </testcase> + <testcase classname="contract multi transaction send multi transaction to gateway with invalid method" name="contract multi transaction send multi transaction to gateway with invalid method" time="0.002"> + </testcase> + <testcase classname="contract multi transaction send multi transaction to gateway with invalid input" name="contract multi transaction send multi transaction to gateway with invalid input" time="0.771"> + </testcase> + <testcase classname="contract multi transaction send multi transaction to gateway with callback" name="contract multi transaction send multi transaction to gateway with callback" time="1.801"> + </testcase> + <testcase classname="contract multi transaction send multi transaction to gateway with refBlockNumberStrategy" name="contract multi transaction send multi transaction to gateway with refBlockNumberStrategy" time="2.943"> + </testcase> + <testcase classname="contract multi transaction sync send multi transaction to gateway" name="contract multi transaction sync send multi transaction to gateway" time="4.711"> + </testcase> + <testcase classname="multi transaction with refBlockNumberStrategy send multi transaction to gateway" name="multi transaction with refBlockNumberStrategy send multi transaction to gateway" time="2.636"> + </testcase> + <testcase classname="multi transaction with refBlockNumberStrategy sync send multi transaction to gateway" name="multi transaction with refBlockNumberStrategy sync send multi transaction to gateway" time="7.213"> + </testcase> + <testcase classname="multi transaction with invalid multi options test handle transaction" name="multi transaction with invalid multi options test handle transaction" time="0.057"> + </testcase> + <testcase classname="multi transaction with invalid refBlockNumberStrategy options test handle transaction with refBlockNumberStrategy which is bigger than 0" name="multi transaction with invalid refBlockNumberStrategy options test handle transaction with refBlockNumberStrategy which is bigger than 0" time="0.002"> + </testcase> + <testcase classname="multi transaction with invalid refBlockNumberStrategy options test handle transaction with refBlockNumberStrategy which is not number" name="multi transaction with invalid refBlockNumberStrategy options test handle transaction with refBlockNumberStrategy which is not number" time="0.002"> + </testcase> + </testsuite> + <testsuite name="token contract with transfer method" errors="0" failures="0" skipped="0" timestamp="2024-10-15T10:59:21" time="37.957" tests="30"> + <testcase classname="token contract with transfer method test constructor" name="token contract with transfer method test constructor" time="0.009"> + </testcase> + <testcase classname="token contract with transfer method test pack input" name="token contract with transfer method test pack input" time="0.005"> + </testcase> + <testcase classname="token contract with transfer method test unpack packed input" name="token contract with transfer method test unpack packed input" time="0.004"> + </testcase> + <testcase classname="token contract with transfer method test send transaction" name="token contract with transfer method test send transaction" time="1.699"> + </testcase> + <testcase classname="token contract with transfer method test send transaction sync" name="token contract with transfer method test send transaction sync" time="3.214"> + </testcase> + <testcase classname="token contract with GetBalance method test unpack output" name="token contract with GetBalance method test unpack output" time="0.002"> + </testcase> + <testcase classname="token contract with GetBalance method test output" name="token contract with GetBalance method test output" time="0.001"> + </testcase> + <testcase classname="token contract with GetBalance method test handle transaction" name="token contract with GetBalance method test handle transaction" time="0.803"> + </testcase> + <testcase classname="token contract with GetBalance method test prepare parameters async" name="token contract with GetBalance method test prepare parameters async" time="0.791"> + </testcase> + <testcase classname="token contract with GetBalance method test prepare parameters sync" name="token contract with GetBalance method test prepare parameters sync" time="1.491"> + </testcase> + <testcase classname="token contract with GetBalance method test prepare parameters with block info" name="token contract with GetBalance method test prepare parameters with block info" time="0.034"> + </testcase> + <testcase classname="token contract with GetBalance method test call read only" name="token contract with GetBalance method test call read only" time="2.228"> + </testcase> + <testcase classname="token contract with GetBalance method test extract arguments into object" name="token contract with GetBalance method test extract arguments into object" time="0.002"> + </testcase> + <testcase classname="token contract with GetBalance method test extract arguments into object with empty args" name="token contract with GetBalance method test extract arguments into object with empty args" time="0.001"> + </testcase> + <testcase classname="token contract with GetBalance method test get signed tx" name="token contract with GetBalance method test get signed tx" time="0.038"> + </testcase> + <testcase classname="token contract with GetBalance method test get signed tx with only one param" name="token contract with GetBalance method test get signed tx with only one param" time="1.738"> + </testcase> + <testcase classname="token contract with GetBalance method test get signed tx without hash or height" name="token contract with GetBalance method test get signed tx without hash or height" time="0.057"> + </testcase> + <testcase classname="token contract with GetBalance method test get raw tx" name="token contract with GetBalance method test get raw tx" time="0.002"> + </testcase> + <testcase classname="token contract with GetBalance method test get raw tx with hex hashInput" name="token contract with GetBalance method test get raw tx with hex hashInput" time="0.001"> + </testcase> + <testcase classname="token contract with GetBalance method test request" name="token contract with GetBalance method test request" time="1.407"> + </testcase> + <testcase classname="token contract with GetBalance method test run" name="token contract with GetBalance method test run" time="1.542"> + </testcase> + <testcase classname="token contract with GetBalance method test bind method to contract" name="token contract with GetBalance method test bind method to contract" time="0.002"> + </testcase> + <testcase classname="token contract with GetBalance method test prepareParametersAsync with valid refBlockNumberStrategy" name="token contract with GetBalance method test prepareParametersAsync with valid refBlockNumberStrategy" time="2.257"> + </testcase> + <testcase classname="token contract with GetBalance method test prepareParametersAsync with invalid refBlockNumberStrategy type" name="token contract with GetBalance method test prepareParametersAsync with invalid refBlockNumberStrategy type" time="0.772"> + </testcase> + <testcase classname="token contract with GetBalance method test prepareParametersAsync with positive refBlockNumberStrategy" name="token contract with GetBalance method test prepareParametersAsync with positive refBlockNumberStrategy" time="0.752"> + </testcase> + <testcase classname="token contract with GetBalance method test prepareParametersAsync without refBlockNumberStrategy" name="token contract with GetBalance method test prepareParametersAsync without refBlockNumberStrategy" time="1.104"> + </testcase> + <testcase classname="token contract with GetBalance method test prepareParameters with valid refBlockNumberStrategy" name="token contract with GetBalance method test prepareParameters with valid refBlockNumberStrategy" time="2.797"> + </testcase> + <testcase classname="token contract with GetBalance method test prepareParameters with invalid refBlockNumberStrategy type" name="token contract with GetBalance method test prepareParameters with invalid refBlockNumberStrategy type" time="0.001"> + </testcase> + <testcase classname="token contract with GetBalance method test prepareParameters with refBlockNumberStrategy greater than 0" name="token contract with GetBalance method test prepareParameters with refBlockNumberStrategy greater than 0" time="0"> + </testcase> + <testcase classname="token contract with GetBalance method test prepareParameters without refBlockNumberStrategy" name="token contract with GetBalance method test prepareParameters without refBlockNumberStrategy" time="1.417"> </testcase> </testsuite> </testsuites> \ No newline at end of file diff --git a/package.json b/package.json index b8f54d6f..9b980bcb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "aelf-sdk", - "version": "3.4.16-alpha.7", + "version": "3.4.16", "description": "aelf-sdk js library", "main": "dist/aelf.cjs.js", "browser": "dist/aelf.umd.js", diff --git a/src/contract/contractMethod.js b/src/contract/contractMethod.js index 569a00d5..fd5d930e 100644 --- a/src/contract/contractMethod.js +++ b/src/contract/contractMethod.js @@ -2,14 +2,7 @@ * @file contract method * @author atom-yang */ -import HttpProvider from '../util/httpProvider'; -import { - getTransactionAndChainId, - getTransaction, - Transaction, - TransactionAndChainId, - MultiTransaction -} from '../util/proto'; +import { getTransaction, Transaction } from '../util/proto'; import { transformArrayToMap, transformMapToArray, @@ -17,16 +10,7 @@ import { INPUT_TRANSFORMERS, OUTPUT_TRANSFORMERS } from '../util/transform'; -import { - isBoolean, - isFunction, - isNumber, - isObject, - noop, - uint8ArrayToHex, - unpackSpecifiedTypeData, - validateMulti -} from '../util/utils'; +import { isBoolean, isFunction, isNumber, noop, uint8ArrayToHex, unpackSpecifiedTypeData } from '../util/utils'; import wallet from '../wallet'; export default class ContractMethod { @@ -34,17 +18,14 @@ export default class ContractMethod { this._chain = chain; this._method = method; this._option = option || {}; - this._gatewayUrl = this._option.gatewayUrl; - this._multiOptions = this._option.multi || {}; - this._chainIds = Object.keys(this._multiOptions); const { resolvedRequestType, resolvedResponseType } = method; this._inputType = resolvedRequestType; this._outputType = resolvedResponseType; this._name = method.name; this._contractAddress = contractAddress; this._wallet = walletInstance; + this.sendTransaction = this.sendTransaction.bind(this); - this.sendMultiTransactionToGateway = this.sendMultiTransactionToGateway.bind(this); this.unpackPackedInput = this.unpackPackedInput.bind(this); this.packInput = this.packInput.bind(this); this.unpackOutput = this.unpackOutput.bind(this); @@ -106,7 +87,9 @@ export default class ContractMethod { handleTransaction(height, hash, encoded) { const rawTx = this.getRawTx(height, hash, encoded); + let tx = wallet.signTransaction(rawTx, this._wallet.keyPair); + tx = Transaction.encode(tx).finish(); // jest environment just go into Buffer branch // we have test in browser example handly @@ -116,35 +99,6 @@ export default class ContractMethod { return uint8ArrayToHex(tx); } - validateRefBlockNumberStrategy(args) { - function validateItem(item) { - // eslint-disable-next-line max-len - if (typeof item !== 'number') { - throw new Error('Invalid type, refBlockNumberStrategy must be number'); - } - if (item > 0) { - throw new Error('refBlockNumberStrategy must be less than 0'); - } - } - // if _chainIds is empty, init refBlockNumberStrategy to undefined - let { refBlockNumberStrategy = this._chainIds.length ? {} : undefined } = this._option; - args.forEach(arg => { - if (arg.refBlockNumberStrategy) { - if (isObject(arg.refBlockNumberStrategy)) { - const keys = Object.keys(arg.refBlockNumberStrategy); - for (let i = 0; i < keys.length; i++) { - validateItem(arg.refBlockNumberStrategy[keys[i]]); - refBlockNumberStrategy[keys[i]] = arg.refBlockNumberStrategy[keys[i]]; - } - } else { - validateItem(arg.refBlockNumberStrategy); - refBlockNumberStrategy = arg.refBlockNumberStrategy; - } - } - }); - return refBlockNumberStrategy; - } - prepareParametersAsync(args, isView) { const filterArgs = args.filter(arg => !isFunction(arg) && !isBoolean(arg.sync)); const encoded = this.packInput(filterArgs[0]); @@ -154,7 +108,22 @@ export default class ContractMethod { } return this._chain.getChainStatus().then(status => { let { BestChainHeight, BestChainHash } = status; - const refBlockNumberStrategy = this.validateRefBlockNumberStrategy(args); + + let { refBlockNumberStrategy } = this._option || {}; + + args.forEach(arg => { + if (arg.refBlockNumberStrategy) { + // eslint-disable-next-line max-len + if (typeof arg.refBlockNumberStrategy !== 'number') { + throw new Error('Invalid type, refBlockNumberStrategy must be number'); + } + if (arg.refBlockNumberStrategy > 0) { + throw new Error('refBlockNumberStrategy must be less than 0'); + } + refBlockNumberStrategy = arg.refBlockNumberStrategy; + } + }); + if (refBlockNumberStrategy) { BestChainHeight += refBlockNumberStrategy; const block = this._chain.getBlockByHeight(BestChainHeight, true, { @@ -175,14 +144,32 @@ export default class ContractMethod { prepareParameters(args, isView) { const filterArgs = args.filter(arg => !isFunction(arg) && !isBoolean(arg.sync)); const encoded = this.packInput(filterArgs[0]); + if (isView) { return this.handleTransaction('', '', encoded); } + + let { refBlockNumberStrategy } = this._option; + + args.forEach(arg => { + if (arg.refBlockNumberStrategy) { + // eslint-disable-next-line max-len + if (typeof arg.refBlockNumberStrategy !== 'number') { + throw new Error('Invalid type, refBlockNumberStrategy must be number'); + } + if (arg.refBlockNumberStrategy > 0) { + throw new Error('refBlockNumberStrategy must be less than 0'); + } + refBlockNumberStrategy = arg.refBlockNumberStrategy; + } + }); + const statusRes = this._chain.getChainStatus({ sync: true }); + let { BestChainHeight, BestChainHash } = statusRes; - const refBlockNumberStrategy = this.validateRefBlockNumberStrategy(args); + if (refBlockNumberStrategy) { BestChainHeight += refBlockNumberStrategy; const block = this._chain.getBlockByHeight(BestChainHeight, true, { @@ -217,146 +204,6 @@ export default class ContractMethod { }); } - handleMultiTransaction(height, hash, encoded) { - const rawTxs = this._chainIds.map(ele => this.getRawTx(height[ele] || '', hash[ele] || '', encoded[ele], ele)); - const multiTx = { transactions: [] }; - rawTxs.forEach(rawTx => { - const handledTx = wallet.signTransaction(rawTx, this._wallet.keyPair); - const item = { transaction: handledTx, chainId: rawTx.chainId }; - const transactionAndChainId = TransactionAndChainId.create(item); - multiTx.transactions.push(transactionAndChainId); - }); - const tx = MultiTransaction.encode(multiTx).finish(); - if (tx instanceof Buffer) { - return tx.toString('hex'); - } - return uint8ArrayToHex(tx); - } - - multiPrepareParameters(args) { - const filterArgs = args.filter(arg => !isFunction(arg) && !isBoolean(arg.sync)); - // encoded -> params object - const encoded = {}; - this._chainIds.forEach(ele => { - encoded[ele] = this.packInput(filterArgs[0][ele]); - }); - const refBlockNumberStrategy = this.validateRefBlockNumberStrategy(args); - const chainHeight = {}; - const chainHash = {}; - this._chainIds.forEach(chainId => { - // get chain height and hash - const httpProvider = new HttpProvider(this._multiOptions[chainId].chainUrl); - const url = 'blockChain/chainStatus'; - try { - const statusRes = httpProvider.send({ - url, - method: 'GET' - }); - let { BestChainHeight, BestChainHash } = statusRes; - if (refBlockNumberStrategy?.[chainId]) { - BestChainHeight += refBlockNumberStrategy[chainId]; - const blockUrl = 'blockChain/blockByHeight'; - const block = httpProvider.send({ - url: blockUrl, - method: 'GET', - params: { - blockHeight: BestChainHeight - } - }); - BestChainHash = block.BlockHash; - } - chainHeight[chainId] = BestChainHeight; - chainHash[chainId] = BestChainHash; - } catch (error) { - console.error(`Error fetching status for chain ${chainId}:`, error); - throw error; - } - }); - return this.handleMultiTransaction(chainHeight, chainHash, encoded); - } - - async multiPrepareParametersAsync(args) { - const filterArgs = args.filter(arg => !isFunction(arg) && !isBoolean(arg.sync)); - - // encoded -> params object - const encoded = {}; - this._chainIds.forEach(ele => { - encoded[ele] = this.packInput(filterArgs[0][ele]); - }); - const refBlockNumberStrategy = this.validateRefBlockNumberStrategy(args); - const chainHeight = {}; - const chainHash = {}; - await Promise.all( - this._chainIds.map(async chainId => { - const httpProvider = new HttpProvider(this._multiOptions[chainId]?.chainUrl); - const url = 'blockChain/chainStatus'; - try { - const statusRes = await httpProvider.sendAsync({ - url, - method: 'GET' - }); - let { BestChainHeight, BestChainHash } = statusRes; - if (refBlockNumberStrategy?.[chainId]) { - BestChainHeight += refBlockNumberStrategy[chainId]; - const blockUrl = 'blockChain/blockByHeight'; - const block = await httpProvider.sendAsync({ - url: blockUrl, - method: 'GET', - params: { - blockHeight: BestChainHeight - } - }); - BestChainHash = block.BlockHash; - } - chainHeight[chainId] = BestChainHeight; - chainHash[chainId] = BestChainHash; - } catch (error) { - console.error(`Error fetching status for chain ${chainId}:`, error); - throw error; - } - }) - ); - return this.handleMultiTransaction(chainHeight, chainHash, encoded); - } - - sendMultiTransactionToGateway(...args) { - if (!validateMulti(this._multiOptions)) { - throw new Error('Please set the chainInfo in option multi'); - } - const argsObject = this.extractArgumentsIntoObject(args); - const httpProvider = new HttpProvider(this._gatewayUrl); - const url = 'gateway/sendUserSignedMultiTransaction'; - if (argsObject.isSync) { - const params = this.multiPrepareParameters(args); - const { data, message, code } = httpProvider.send({ - url, - method: 'POST', - params: { - RawMultiTransaction: params - } - }); - if (data != null && code === 200) { - return data; - } - throw new Error(message); - } - // eslint-disable-next-line arrow-body-style - return this.multiPrepareParametersAsync(args).then(async params => { - const { data, message, code } = await httpProvider.sendAsync({ - url, - method: 'POST', - params: { - RawMultiTransaction: params - } - }); - if (data != null && code === 200) { - argsObject.callback(data); - return data; - } - throw new Error(message); - }); - } - callReadOnly(...args) { const argsObject = this.extractArgumentsIntoObject(args); if (argsObject.isSync) { @@ -412,20 +259,8 @@ export default class ContractMethod { return this.prepareParameters(args); } - getRawTx(blockHeightInput, blockHashInput, packedInput, chainId) { - let rawTx; - if (chainId) { - // multi - rawTx = getTransactionAndChainId( - this._wallet.address, - this._multiOptions[chainId]?.contractAddress, - this._name, - packedInput, - chainId - ); - } else { - rawTx = getTransaction(this._wallet.address, this._contractAddress, this._name, packedInput); - } + getRawTx(blockHeightInput, blockHashInput, packedInput) { + const rawTx = getTransaction(this._wallet.address, this._contractAddress, this._name, packedInput); if (blockHeightInput) { rawTx.refBlockNumber = blockHeightInput; } @@ -463,7 +298,6 @@ export default class ContractMethod { run.packInput = this.packInput; run.packOutput = this.packOutput.bind(this); run.sendTransaction = this.sendTransaction; - run.sendMultiTransactionToGateway = this.sendMultiTransactionToGateway; run.getSignedTx = this.getSignedTx; run.getRawTx = this.getRawTx; run.unpackOutput = this.unpackOutput; diff --git a/test/unit/contract/multiTransaction.test.js b/test/unit/contract/multiTransaction.test1.js similarity index 100% rename from test/unit/contract/multiTransaction.test.js rename to test/unit/contract/multiTransaction.test1.js