Skip to content

Commit

Permalink
fix: 🐛 Fix bugs about multisignature and dao
Browse files Browse the repository at this point in the history
  • Loading branch information
limsbase committed Jun 14, 2020
1 parent b8376d1 commit 54d6fcc
Show file tree
Hide file tree
Showing 21 changed files with 1,746 additions and 2,760 deletions.
761 changes: 0 additions & 761 deletions packages/asset-aob/test/unit/1.aob.test.js

This file was deleted.

1,833 changes: 760 additions & 1,073 deletions packages/asset-aob/test/unit/aob.test.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions packages/asset-base/src/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ class AssetBase {
// ---!wly修改
pageIndex = pageIndex || 1;
pageSize = pageSize || 50;

let limit = pageSize;
let offset = (pageIndex - 1) * pageSize;

Expand Down
27 changes: 15 additions & 12 deletions packages/asset-dao/src/confirmation.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import DdnCrypto from '@ddn/crypto';
import Asset from '@ddn/asset-base';
import DdnUtils from '@ddn/utils';
import daoUtil from './daoUtil';
// import crypto from 'crypto';
// import ed from 'ed25519';

/**
* 确认交易
Expand All @@ -22,23 +20,23 @@ class Confirmation extends Asset.Base {
// eslint-disable-next-line class-methods-use-this
async propsMapping() {
return [{
field: 'str4',
field: 'str2', // 34 < 64
prop: 'received_address',
},
{
field: 'str5',
field: 'str3',
prop: 'sender_address',
},
{
field: 'str6',
field: 'str6', // 256
prop: 'url',
},
{
field: 'int1',
prop: 'state',
},
{
field: 'str2',
field: 'str4', // 128
prop: 'contribution_trs_id',
}
];
Expand All @@ -64,13 +62,18 @@ class Confirmation extends Asset.Base {

async calculateFee(trs) {
const confirmation = await this.getAssetObject(trs);
let feeBase;
if (confirmation.state === 0) {
return '0'; // 拒绝稿件时手续费为0
feeBase = '0'; // 拒绝稿件时手续费为0
}
return "100000000";

const result = DdnUtils.bignum.multiply(feeBase, this.constants.fixedPoint).toString();

return result;
}

async verify(trs) {

const confirmation = await this.getAssetObject(trs);
if (!trs.asset || !confirmation) {
throw new Error('Invalid transaction asset "Contribution"');
Expand All @@ -95,8 +98,8 @@ class Confirmation extends Asset.Base {
}

if (!confirmation.received_address
|| confirmation.received_address.length > 128) {
throw new Error('received_address is undefined or too long, don`t more than 128 characters.');
|| confirmation.received_address.length > 34) {
throw new Error('received_address is undefined or too long, don`t more than 34 characters.');
}
if (!this.address.isAddress(confirmation.received_address)) {
throw new Error("Invalid confirmation's received_address");
Expand All @@ -117,8 +120,8 @@ class Confirmation extends Asset.Base {
}

if (!confirmation.contribution_trs_id
|| confirmation.contribution_trs_id.length > 64) {
throw new Error('contribution_trs_id is undefined or too long, don`t more than 256 characters.');
|| confirmation.contribution_trs_id.length > 128) {
throw new Error('contribution_trs_id is undefined or too long, don`t more than 128 characters.');
}

// (1)查询getConfirmation是否存在
Expand Down
1 change: 0 additions & 1 deletion packages/asset-dao/src/exchange.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ class Exchange extends Asset.Base {

async getBytes(trs) {
const asset = await this.getAssetObject(trs); // trs.asset.exchange;
console.log("trs", trs);

const bb = new ByteBuffer();
bb.writeString(asset.orgId.toLowerCase());
Expand Down
3 changes: 1 addition & 2 deletions packages/asset-dao/src/org.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,7 @@ class Org extends Asset.Base {
if (assetObj.state === 1) {
feeBase = parseInt(feeBase / 10, 10); // change info
}
// DdnUtils.bignum update
const result = DdnUtils.bignum.multiply(feeBase, 100000000).toString();
const result = DdnUtils.bignum.multiply(feeBase, this.constants.fixedPoint).toString();
return result;
}

Expand Down
188 changes: 0 additions & 188 deletions packages/asset-dao/test/unit/confirmation.test.js

This file was deleted.

Loading

0 comments on commit 54d6fcc

Please sign in to comment.