lotus/lotuspond/front/src/chain/send.js

46 lines
967 B
JavaScript
Raw Normal View History

2019-08-09 15:59:12 +00:00
import util from 'ipld-dag-cbor'
import { Buffer } from 'buffer'
import { Tagged } from 'borc'
async function pushMessage(client, from, inmsg) {
if(!inmsg.GasLimit) {
2019-08-19 14:47:09 +00:00
inmsg.GasLimit = "1000"
2019-08-09 15:59:12 +00:00
}
if(!inmsg.GasPrice) {
inmsg.GasPrice = "0"
}
if(!inmsg.Params) {
inmsg.Params = "oA==" // 0b101_00000: empty cbor map: {}
}
if(!inmsg.Value) {
inmsg.Value = "0"
}
if(!inmsg.Method) {
inmsg.Method = 0
}
inmsg.Nonce = await client.call('Filecoin.MpoolGetNonce', [from])
/* const msg = [
inmsg.To,
inmsg.From,
inmsg.Nonce,
inmsg.Value,
inmsg.GasPrice,
inmsg.GasLimit,
inmsg.Method,
Buffer.from(inmsg.Params, 'base64'),
]*/
const signed = await client.call('Filecoin.WalletSignMessage', [from, inmsg])
console.log(signed)
await client.call('Filecoin.MpoolPush', [signed])
}
export default pushMessage