Skip to content

Commit

Permalink
Merge 4c2c50a into 4bbe644
Browse files Browse the repository at this point in the history
  • Loading branch information
charles-liu committed Jan 21, 2022
2 parents 4bbe644 + 4c2c50a commit 6265a00
Show file tree
Hide file tree
Showing 18 changed files with 183 additions and 117 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,17 @@
## [2.3.17-alpha.5](https://github.com/vitelabs/vite.js/compare/v2.3.17-alpha.2...v2.3.17-alpha.5) (2022-01-02)


### fix

* fix lint ([c62ba88](https://github.com/vitelabs/vite.js/commit/c62ba88903dc084510a00a7dd64e9973cd2ae764))



## [2.3.17-alpha.4](https://github.com/vitelabs/vite.js/compare/v2.3.17-alpha.1...v2.3.17-alpha.4) (2022-01-01)




## [2.3.16](https://github.com/vitelabs/vite.js/compare/v2.3.15...v2.3.16) (2021-10-27)


Expand Down
2 changes: 1 addition & 1 deletion lerna.json
@@ -1,5 +1,5 @@
{
"version": "2.3.17-alpha.4",
"version": "2.3.17",
"packages": [
"src/*"
],
Expand Down
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -13,6 +13,7 @@
"build:all": "yarn run build:node && yarn run build:web",
"build": "yarn run build:vitejs && yarn run build:all && node build/writePkgJson.js",
"test:rpc": "cross-env NODE_ENV=test nyc mocha --reporter=list --require ts-node/register -r tsconfig-paths/register test/rpc/index.js",
"test:abi": "cross-env NODE_ENV=test nyc mocha --reporter=list --require ts-node/register -r tsconfig-paths/register test/packages/abi.js",
"test:buildTs": "cross-env NODE_ENV=test nyc mocha --reporter=progress --require ts-node/register -r tsconfig-paths/register test/envTest/testTs.ts",
"test:coverage": "cross-env NODE_ENV=test nyc mocha --reporter=progress --require ts-node/register -r tsconfig-paths/register test/cover.js --no-timeouts",
"test": "yarn run format-type && cross-env NODE_ENV=test nyc mocha --reporter=progress --require ts-node/register -r tsconfig-paths/register test/index.js --no-timeouts",
Expand Down
2 changes: 1 addition & 1 deletion src/HTTP/package.json
@@ -1,6 +1,6 @@
{
"name": "@vite/vitejs-http",
"version": "2.3.17-alpha.4",
"version": "2.3.17",
"main": "dist/index.node.js",
"browser": "dist/index.web.js",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion src/IPC/package.json
@@ -1,6 +1,6 @@
{
"name": "@vite/vitejs-ipc",
"version": "2.3.17-alpha.4",
"version": "2.3.17",
"main": "dist/index.node.js",
"browser": "dist/index.web.js",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion src/WS/package.json
@@ -1,6 +1,6 @@
{
"name": "@vite/vitejs-ws",
"version": "2.3.17-alpha.4",
"version": "2.3.17",
"main": "dist/index.node.js",
"browser": "dist/index.web.js",
"repository": {
Expand Down
59 changes: 28 additions & 31 deletions src/abi/index.ts
Expand Up @@ -45,40 +45,37 @@ export function decodeParameters(types, params, methodName?: string) {
return _decodeParameters(getTypes(types), params);
}

export function decodeLog(inputs, data = '', topics, methodName?: string) {
let topicCount = 0;
topics = isArray(topics) ? topics : [topics];

const notIndexedInputsShow = [];
const indexedParams = [];

inputs = getInputs(inputs, methodName);
export function decodeLog(abi, data = '', topics, methodName?: string) {
const nonIndexedInputs = [];
const nonIndexedTypes = [];
const inputs = getInputs(abi, methodName);
const returnValues = {};
let topicIndex = abi.anonymous ? 0 : 1; // for non-anonymous events, topics[0] always refers to the hash of the event signature
inputs.forEach((input, i) => {
indexedParams[i] = input;

if (!input.indexed) {
notIndexedInputsShow.push(input.type);
return;
if (input.indexed) {
// parse indexed params from topics
// if it's a reference type such as a string for an indexed argument, the blake2b hash of the value is stored as a topic instead.
const param = ([ 'bool', 'int', 'uint', 'address', 'fixed', 'ufixed' ].find(function (staticType) {
return input.type.indexOf(staticType) !== -1;
})) ? decodeParameter(input.type, topics[topicIndex]) : topics[topicIndex];
topicIndex++;
// add the indexed param to the return values
returnValues[i] = param;
if (input.name) returnValues[input.name] = param;
} else {
nonIndexedInputs.push(input);
nonIndexedTypes.push(input.type);
}

indexedParams[i].result = decodeParameter(input.type, topics[topicCount]);
topicCount++;
});

const notIndexedParams = data ? decodeParameters(notIndexedInputsShow, data) : [];

const returnValues = {};
let notIndexedCount = 0;

indexedParams.forEach(({ indexed, name, result }, i) => {
if (!indexed) {
result = notIndexedParams[notIndexedCount];
notIndexedCount++;
}

returnValues[i] = result;
if (name) {
returnValues[name] = result;
// parse non-indexed params from data
const nonIndexedParams = decodeParameters(nonIndexedTypes, data);
// add non-indexed params to the return values
let index = 0;
inputs.forEach((input, i) => {
if (!input.indexed) {
returnValues[i] = nonIndexedParams[index];
if (input.name) returnValues[input.name] = nonIndexedParams[index];
index++;
}
});

Expand Down
2 changes: 1 addition & 1 deletion src/abi/package.json
@@ -1,6 +1,6 @@
{
"name": "@vite/vitejs-abi",
"version": "2.3.17-alpha.4",
"version": "2.3.17",
"main": "dist/index.node.js",
"browser": "dist/index.web.js",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion src/accountBlock/package.json
@@ -1,6 +1,6 @@
{
"name": "@vite/vitejs-accountblock",
"version": "2.3.17-alpha.4",
"version": "2.3.17",
"main": "dist/index.node.js",
"browser": "dist/index.web.js",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion src/communication/package.json
@@ -1,6 +1,6 @@
{
"name": "@vite/vitejs-communication",
"version": "2.3.17-alpha.4",
"version": "2.3.17",
"main": "dist/index.node.js",
"browser": "dist/index.web.js",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion src/constant/package.json
@@ -1,6 +1,6 @@
{
"name": "@vite/vitejs-constant",
"version": "2.3.17-alpha.4",
"version": "2.3.17",
"main": "dist/index.node.js",
"browser": "dist/index.web.js",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion src/error/package.json
@@ -1,6 +1,6 @@
{
"name": "@vite/vitejs-error",
"version": "2.3.17-alpha.4",
"version": "2.3.17",
"main": "dist/index.node.js",
"browser": "dist/index.web.js",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion src/keystore/package.json
@@ -1,6 +1,6 @@
{
"name": "@vite/vitejs-keystore",
"version": "2.3.17-alpha.4",
"version": "2.3.17",
"main": "dist/index.node.js",
"browser": "dist/index.web.js",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/package.json
@@ -1,6 +1,6 @@
{
"name": "@vite/vitejs-utils",
"version": "2.3.17-alpha.4",
"version": "2.3.17",
"main": "dist/index.node.js",
"browser": "dist/index.web.js",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion src/viteAPI/package.json
@@ -1,6 +1,6 @@
{
"name": "@vite/vitejs-viteapi",
"version": "2.3.17-alpha.4",
"version": "2.3.17",
"main": "dist/index.node.js",
"browser": "dist/index.web.js",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion src/vitejs/package.json
@@ -1,6 +1,6 @@
{
"name": "@vite/vitejs",
"version": "2.3.17-alpha.4",
"version": "2.3.17",
"main": "dist/index.node.js",
"browser": "dist/index.web.js",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion src/wallet/package.json
@@ -1,6 +1,6 @@
{
"name": "@vite/vitejs-wallet",
"version": "2.3.17-alpha.4",
"version": "2.3.17",
"main": "dist/index.node.js",
"browser": "dist/index.web.js",
"repository": {
Expand Down

0 comments on commit 6265a00

Please sign in to comment.