上个commit不够对,actorAddress 是在 packMe 中被赋值的,不需要提前检测。
This commit is contained in:
@@ -82,7 +82,7 @@ DAD.verifyHash = function (actionData) {
|
||||
return typedAction.verifyHash()
|
||||
}
|
||||
|
||||
MOM.validateMe = function() { // Applicable on chain server. 子类应当覆盖本方法,静态的检查事务内容的格式和语义,是否符合该子类事务的特性要求。To validate an action's content format.
|
||||
MOM.validateMe = function() { // Applicable on both client and chain server. 子类应当覆盖本方法,静态的检查事务内容的格式。不能检查 balance 等需要全链数据库的东西,因为本方法也要用在前端检查。
|
||||
// to implement in subclasses: 检查子类事务内容的格式
|
||||
let typedAction = new wo[this.type](this)
|
||||
return typedAction.validateMe()
|
||||
@@ -124,11 +124,11 @@ DAD._initTypeDict = function(typedActionDict) {
|
||||
}
|
||||
|
||||
DAD.build = async function (action, keypair) { // Applicable on client. 客户端调用 Action.build,即可新建、并打包成一个完整的子事务,不需要亲自调用 constructor, packMe 等方法。
|
||||
if (action && action.type && keypair && keypair.seckey && keypair.pubkey) {
|
||||
if (action && action.type && keypair && keypair.seckey && keypair.pubkey && ticCrypto.seckey2pubkey(keypair.seckey)===keypair.pubkey) {
|
||||
let typedAction = new wo[action.type](action)
|
||||
typedAction.actorPubkey = keypair.pubkey
|
||||
if (typedAction.validateMe()) {
|
||||
await typedAction.packMe(keypair)
|
||||
await typedAction.packMe(keypair) // 在 packMe 里,会把 actorPubkey 转存为 actorAddress。
|
||||
return typedAction
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user