perfectmak / libra-core

A javascript client for libra built with typescript
https://npmjs.com/package/libra-core
136 stars 31 forks source link

transferCoins does not work anymore #39

Open manihagh opened 5 years ago

manihagh commented 5 years ago

Just tried the transferCoins example and seems does not work anymore.

LibraTransactionResponse { signedTransaction: LibraSignedTransaction { transaction: LibraTransaction { program: [Object], gasContraint: [Object], expirationTime: [BigNumber], sendersAddress: [AccountAddress], sequenceNumber: [BigNumber] }, publicKey: Uint8Array [ 126, 142, 165, 73, 194, 136, 153, 77, 213, 61, 211, 220, 2, 180, 195, 48, 128, 186, 113, 104, 203, 53, 60, 113, 224, 54, 74, 205, 207, 172, 13, 60 ], signature: Uint8Array [ 220, 207, 1, 86, 178, 236, 48, 138, 181, 91, 106, 88, 206, 56, 244, 57, 205, 75, 11, 128, 153, 75, 131, 223, 121, 86, 171, 73, 149, 72, 123, 214, 43, 157, 175, 199, 127, 108, 6, 30, 178, 143, 220, 214, 65, 137, 141, 43, 137, 213, 238, 231, 103, 27, 125, 197, 32, 14, 113, 135, 229, 120, 95, 9 ] }, validatorId: Uint8Array [], acStatus: -1, mempoolStatus: -1, vmStatus: LibraVMStatusError { errorType: 1, validationStatusError: { code: 2, message: 'none' }, verificationStatusErrors: undefined, invariantViolationError: undefined, deserializationError: undefined, executionError: undefined } }

perfectmak commented 5 years ago

Yes, this has come to my attention recently too, but I'm quite busy this week and won't be able to look into this until weekend.

If you have some time and know what the issue is, I would appreciate your contribution, or else you will have to wait a little while before I can get a fix for it. Thank you for using libra-core.

manihagh commented 5 years ago

Thanks, the error indicates error type: 1 ("VALIDATION") and validationStatusError: 2 ( "INVALIDAUTHKEY"). Also looking at LibraTransaction object seems the senders address is not valid: sendersAddress: AccountAddress { addressBytes: Uint8Array [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] }

The issue seems to be be the signed transaction does not contain correct sender address before encoding within execute.

For now, I resolved this by adding below line in 'lib/client/index.ts': transaction.sendersAddress = sender.getAddress();

After this: public async execute(transaction: LibraTransaction, sender: Account): Promise<LibraTransactionResponse> {

However, I prefer not create a PR as the root cause could be within lib/transaction

zoeyTM commented 5 years ago

@manihagh I'm honestly not sure how to reproduce this error. I just tried the transferring libra coins example and it worked for me.

mmsqe commented 5 years ago

transferCoins works but mintWithFaucetService not, seems related to mintAddress change in c5cce923cb3e076341cff5e1ac83069b29628d73, updated in https://github.com/perfectmak/libra-core/pull/40

totiz commented 5 years ago

@mmsqe yes you're right the problem is come from this, I gonna make PR to fix this soon.

totiz commented 5 years ago

@mmsqe Oh you just make a PR, nice!

totiz commented 5 years ago

I suggest to change constant of MinterAddress to AssociationAddress, It'll more clear what the constant represent. Reference to this https://github.com/libra/libra/blob/testnet/types/src/account_config.rs#L49

And kula-libra just update as well https://github.com/kulapio/libra-core/pull/7/files