Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/feat/approval_add_tx_status' int…
Browse files Browse the repository at this point in the history
…o dev
  • Loading branch information
sjatsh committed Dec 18, 2023
2 parents 5142519 + c5f5cec commit e049e8f
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 208 deletions.
183 changes: 12 additions & 171 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -522,163 +522,16 @@ Please familiarize yourself with the meaning of some common parameters before re
#### Request

* path: /v1/transaction/send

PersonalSign
```json
{
"action": "create_approval",
"sign_key": "18feccf2347ed980f07bd3277f9ce626",
"list": [
{
"sign_list": [
{
"sign_type": 8,
"sign_msg": "From .bit: 0ea5ffd13bddbdb3f5a8b492cd6653816d371b9afebb7e6d4ecd8e2962d6b4ca"
}
]
}
]
}
```

SignWith712
```json
{
"action": "delay_approval",
"sub_action": "",
"sign_key": "e6358f9798aea2182329657029e6ff84",
"sign_address": "",
"is_712": true,
"sign_list": [
{
"sign_type": 5,
"sign_msg": "0xa67ee3e2a14602ca7dfa8d720c5c59c0769c8535575b4832aa46bd8f0023b476"
"sign_type": 8,
"sign_msg": "0x0ea5ffd13bddbdb3f5a8b492cd6653816d371b9afebb7e6d4ecd8e2962d6b4ca"
}
],
"mm_json": {
"types": {
"EIP712Domain": [
{
"name": "chainId",
"type": "uint256"
},
{
"name": "name",
"type": "string"
},
{
"name": "verifyingContract",
"type": "address"
},
{
"name": "version",
"type": "string"
}
],
"Action": [
{
"name": "action",
"type": "string"
},
{
"name": "params",
"type": "string"
}
],
"Cell": [
{
"name": "capacity",
"type": "string"
},
{
"name": "lock",
"type": "string"
},
{
"name": "type",
"type": "string"
},
{
"name": "data",
"type": "string"
},
{
"name": "extraData",
"type": "string"
}
],
"Transaction": [
{
"name": "DAS_MESSAGE",
"type": "string"
},
{
"name": "inputsCapacity",
"type": "string"
},
{
"name": "outputsCapacity",
"type": "string"
},
{
"name": "fee",
"type": "string"
},
{
"name": "action",
"type": "Action"
},
{
"name": "inputs",
"type": "Cell[]"
},
{
"name": "outputs",
"type": "Cell[]"
},
{
"name": "digest",
"type": "bytes32"
}
]
},
"primaryType": "Transaction",
"domain": {
"chainId": 5,
"name": "da.systems",
"verifyingContract": "0x0000000000000000000000000000000020210722",
"version": "1"
},
"message": {
"DAS_MESSAGE": "DELAY THE TRANSFER APPROVAL OF sub-account-test.bit TO 1693022303",
"inputsCapacity": "226.99983611 CKB",
"outputsCapacity": "226.99978213 CKB",
"fee": "0.00005398 CKB",
"digest": "",
"action": {
"action": "delay_approval",
"params": "0x00"
},
"inputs": [
{
"capacity": "226.99983611 CKB",
"lock": "das-lock,0x01,0x05deefc10a42cd84c072f2b0e2fa99061a74a069...",
"type": "account-cell-type,0x01,0x",
"data": "{ account: sub-account-test.bit, expired_at: 2028621581 }",
"extraData": "{ status: 4, records_hash: 0x0a5e0d314f2871334d8e3f5d49b2af60c49ac9af594debc705522448c5722ebf }"
}
],
"outputs": [
{
"capacity": "226.99978213 CKB",
"lock": "das-lock,0x01,0x05deefc10a42cd84c072f2b0e2fa99061a74a069...",
"type": "account-cell-type,0x01,0x",
"data": "{ account: sub-account-test.bit, expired_at: 2028621581 }",
"extraData": "{ status: 4, records_hash: 0x0a5e0d314f2871334d8e3f5d49b2af60c49ac9af594debc705522448c5722ebf }"
}
]
}
}
]
}
```

Expand Down Expand Up @@ -2017,14 +1870,10 @@ SignWith712
"sign_key": "c5d332a1cf42cf066c49849cc91f83d6",
"sign_address": "",
"is_712": false,
"list": [
"sign_list": [
{
"sign_list": [
{
"sign_type": 3,
"sign_msg": "From .bit: 0x63c1d729b4e293ecef164dabceb1ab3e2be62f5117a036ab1c37d4eb1698ff85"
}
]
"sign_type": 3,
"sign_msg": "From .bit: 0x63c1d729b4e293ecef164dabceb1ab3e2be62f5117a036ab1c37d4eb1698ff85"
}
]
}
Expand Down Expand Up @@ -2208,14 +2057,10 @@ SignWith712
"sign_key": "c5d332a1cf42cf066c49849cc91f83d6",
"sign_address": "",
"is_712": false,
"list": [
"sign_list": [
{
"sign_list": [
{
"sign_type": 3,
"sign_msg": "From .bit: 0x63c1d729b4e293ecef164dabceb1ab3e2be62f5117a036ab1c37d4eb1698ff85"
}
]
"sign_type": 3,
"sign_msg": "From .bit: 0x63c1d729b4e293ecef164dabceb1ab3e2be62f5117a036ab1c37d4eb1698ff85"
}
]
}
Expand Down Expand Up @@ -2437,14 +2282,10 @@ SignWith712
"sign_key": "c5d332a1cf42cf066c49849cc91f83d6",
"sign_address": "",
"is_712": false,
"list": [
"sign_list": [
{
"sign_list": [
{
"sign_type": 3,
"sign_msg": "From .bit: 0x63c1d729b4e293ecef164dabceb1ab3e2be62f5117a036ab1c37d4eb1698ff85"
}
]
"sign_type": 3,
"sign_msg": "From .bit: 0x63c1d729b4e293ecef164dabceb1ab3e2be62f5117a036ab1c37d4eb1698ff85"
}
]
}
Expand Down
10 changes: 3 additions & 7 deletions http_server/handle/approval_delay.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,9 @@ func (h *HttpHandle) doApprovalDelayMainAccount(req *ReqApprovalDelay, apiResp *
}
log.Info("doApprovalEnableAccount: ", txHash)

if len(signList.List) > 0 {
signList.List = nil
}
resp := RespApprovalEnable{
SignInfoList: *signList,
}
Expand Down Expand Up @@ -278,13 +281,6 @@ func (h *HttpHandle) doApprovalDelaySubAccount(req *ReqApprovalDelay, apiResp *a
Action: common.DasActionUpdateSubAccount,
SubAction: common.DasActionDelayApproval,
SignKey: signKey,
List: []SignInfo{
{
SignList: []txbuilder.SignData{
signData,
},
},
},
SignList: []txbuilder.SignData{
signData,
},
Expand Down
10 changes: 3 additions & 7 deletions http_server/handle/approval_enable.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,9 @@ func (h *HttpHandle) doApprovalEnableMainAccount(req *ReqApprovalEnable, apiResp
}
log.Info("doApprovalEnableAccount: ", txHash)

if len(signList.List) > 0 {
signList.List = nil
}
resp := RespApprovalEnable{
SignInfoList: *signList,
}
Expand Down Expand Up @@ -303,13 +306,6 @@ func (h *HttpHandle) doApprovalEnableSubAccount(req *ReqApprovalEnable, apiResp
Action: common.DasActionUpdateSubAccount,
SubAction: common.DasActionCreateApproval,
SignKey: signKey,
List: []SignInfo{
{
SignList: []txbuilder.SignData{
signData,
},
},
},
SignList: []txbuilder.SignData{
signData,
},
Expand Down
11 changes: 4 additions & 7 deletions http_server/handle/approval_fulfill.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@ func (h *HttpHandle) doApprovalFulfillMainAccount(req *ReqApprovalFulfill, apiRe
resp := RespApprovalEnable{
SignInfoList: *signList,
}

if len(signList.List) > 0 {
signList.List = nil
}
apiResp.ApiRespOK(resp)
return nil
}
Expand Down Expand Up @@ -261,13 +265,6 @@ func (h *HttpHandle) doApprovalFulfillSubAccount(req *ReqApprovalFulfill, apiRes
Action: common.DasActionUpdateSubAccount,
SubAction: common.SubActionFullfillApproval,
SignKey: signKey,
List: []SignInfo{
{
SignList: []txbuilder.SignData{
signData,
},
},
},
SignList: []txbuilder.SignData{
signData,
},
Expand Down
10 changes: 3 additions & 7 deletions http_server/handle/approval_revoke.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@ func (h *HttpHandle) doApprovalRevokeMainAccount(req *ReqApprovalRevoke, apiResp
}
log.Info("doApprovalEnableAccount: ", txHash)

if len(signList.List) > 0 {
signList.List = nil
}
resp := RespApprovalEnable{
SignInfoList: *signList,
}
Expand Down Expand Up @@ -272,13 +275,6 @@ func (h *HttpHandle) doApprovalRevokeSubAccount(req *ReqApprovalRevoke, apiResp
Action: common.DasActionUpdateSubAccount,
SubAction: common.SubActionRevokeApproval,
SignKey: signKey,
List: []SignInfo{
{
SignList: []txbuilder.SignData{
signData,
},
},
},
SignList: []txbuilder.SignData{
signData,
},
Expand Down
1 change: 1 addition & 0 deletions http_server/handle/custom_script.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ func (h *HttpHandle) buildTx(p *paramBuildTx) (*SignInfoList, string, error) {
signListInfo.Is712 = true
} else {
signListInfo.List = append(signListInfo.List, SignInfo{signList})
signListInfo.SignList = signList
}
return &signListInfo, txHash.Hex(), nil
}
Expand Down
17 changes: 8 additions & 9 deletions http_server/handle/transaction_send_new.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,17 +303,16 @@ func (h *HttpHandle) doApproval(req *ReqTransactionSend, apiResp *api_code.ApiRe
return fmt.Errorf("json.Unmarshal err: %s", err.Error())
}

txBuilder := txbuilder.NewDasTxBuilderFromBase(h.TxBuilderBase, sic.BuilderTx)
signList := make([]txbuilder.SignData, 0)
if len(req.List) > 0 {
if err := txBuilder.AddSignatureForTx(req.List[0].SignList); err != nil {
apiResp.ApiRespErr(api_code.ApiCodeError500, "add signature fail")
return fmt.Errorf("AddSignatureForTx err: %s", err.Error())
}
signList = req.List[0].SignList
} else {
if err := txBuilder.AddSignatureForTx(req.SignList); err != nil {
apiResp.ApiRespErr(api_code.ApiCodeError500, "add signature fail")
return fmt.Errorf("AddSignatureForTx err: %s", err.Error())
}
signList = req.SignList
}
txBuilder := txbuilder.NewDasTxBuilderFromBase(h.TxBuilderBase, sic.BuilderTx)
if err := txBuilder.AddSignatureForTx(signList); err != nil {
apiResp.ApiRespErr(api_code.ApiCodeError500, "add signature fail")
return fmt.Errorf("AddSignatureForTx err: %s", err.Error())
}

hash, err := txBuilder.SendTransaction()
Expand Down

0 comments on commit e049e8f

Please sign in to comment.