Skip to content

Commit

Permalink
ledger
Browse files Browse the repository at this point in the history
  • Loading branch information
lovelycs committed Sep 19, 2018
1 parent d973e42 commit 81e0f53
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 19 deletions.
4 changes: 3 additions & 1 deletion src/Vite/account/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,7 @@ function getRawTokenid(tokenId) {
if (tokenId.indexOf('tti_') !== 0) {
return null;
}
return tokenId.slice(4);
console.log(tokenId);
console.log(tokenId.slice(4, tokenId.length - 2));
return tokenId.slice(4, tokenId.length - 2);
}
32 changes: 16 additions & 16 deletions src/Vite/ledger/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,23 @@ class Ledger extends basicStruct {
super(provider);
}

createTx(AccountBlock) {
return this.provider.request('ledger_createTx', [AccountBlock]);
sendTx(accountBlock) {
return this.provider.request('ledger_sendTx', [ accountBlock ]);
}

// SelfAddr: string of addr
// ToAddr: string of addr
// Passphrase: string
// TokenTypeId: string of tokentypeid
// Amount:big int
createTxWithPassphrase(AccountBlock) {
return this.provider.request('ledger_createTxWithPassphrase', AccountBlock);
createTxWithPassphrase({
selfAddr, toAddr, passphrase, tokenTypeId, amount
}) {
return this.provider.request('ledger_createTxWithPassphrase', {
selfAddr, toAddr, passphrase, tokenTypeId, amount
});
}

getBlocksByAccAddr ({
accAddr, index, count = 20
accAddr, index, count = 20, needTokenInfo = false
}) {
return this.provider.request('ledger_getBlocksByAccAddr', {
Addr: accAddr,
Index: index,
Count: count
accAddr, index, count, needTokenInfo
});
}

Expand Down Expand Up @@ -97,20 +94,23 @@ class Ledger extends basicStruct {
}
let block = blocks[0];

let height = latestBlock.meta.height ? new BigNumber(block.meta.height).plus(1).toFormat() : 1;
let height = latestBlock.meta.height ? new BigNumber(latestBlock.meta.height).plus(1).toFormat() : 1;
let timestamp = new BigNumber(new Date().getTime()).dividedToIntegerBy(1000).toFormat();

return {
meta: {
height
},
accountAddress: addr,
fromHash: block.hash,
prevHash: latestBlock.hash,
timestamp: new Date().getTime(),
timestamp,
tokenId: block.tokenId,
data: block.data,
snapshotTimestamp: latestSnapshotChainHash,
nonce: '0000000000',
difficulty: '0000000000'
difficulty: '0000000000',
fAmount: '0'
};
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/Wallet/account.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class Account {

// [TODO]
console.log(accountBlock);
this.Vite.Ledger.createTx(accountBlock).then((data)=>{
this.Vite.Ledger.sendTx(accountBlock).then((data)=>{
console.log(data);
}).catch((err)=>{
console.log(err);
Expand Down
1 change: 0 additions & 1 deletion src/Wallet/keystore.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ class keystore {
privKey = decipher.update(libUtils.hexToBytes(ciphertext), 'utf8', 'hex');
privKey += decipher.final('hex');
} catch(err) {
console.warn(err);
return false;
}

Expand Down

0 comments on commit 81e0f53

Please sign in to comment.