diff --git a/go.mod b/go.mod index 505710e4..5c175073 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module das_sub_account go 1.15 require ( - github.com/DeAccountSystems/das-lib v0.0.0-20220531040850-ea68b195348f + github.com/DeAccountSystems/das-lib v0.0.0-20220607033455-1b6e6e92f767 github.com/elazarl/goproxy v0.0.0-20220115173737-adb46da277ac // indirect github.com/fsnotify/fsnotify v1.4.9 github.com/gin-gonic/gin v1.7.2 diff --git a/go.sum b/go.sum index 76b684d8..23e88337 100644 --- a/go.sum +++ b/go.sum @@ -27,8 +27,8 @@ github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= -github.com/DeAccountSystems/das-lib v0.0.0-20220531040850-ea68b195348f h1:oXB2ZKFGInqU7e4AhFOrkHuMEG47vTH6l8uiBQ4BHzk= -github.com/DeAccountSystems/das-lib v0.0.0-20220531040850-ea68b195348f/go.mod h1:ige8f+izCtnfXlKpc4iLR4CJHoaqYIoypL531X/KJp0= +github.com/DeAccountSystems/das-lib v0.0.0-20220607033455-1b6e6e92f767 h1:kvLl8SOlreDvs9zUnocjjQgiY6YoFD1HDO+o9pH5waU= +github.com/DeAccountSystems/das-lib v0.0.0-20220607033455-1b6e6e92f767/go.mod h1:ige8f+izCtnfXlKpc4iLR4CJHoaqYIoypL531X/KJp0= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc= github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 h1:fLjPD/aNc3UIOA6tDi6QXUemppXK3P9BI7mr2hd6gx8= diff --git a/txtool/edit_sub_account.go b/txtool/edit_sub_account.go index f03ab185..eef00dcc 100644 --- a/txtool/edit_sub_account.go +++ b/txtool/edit_sub_account.go @@ -120,6 +120,24 @@ func (s *SubAccountTxTool) BuildEditSubAccountTx(p *ParamBuildEditSubAccountTx) txParams.Witnesses = append(txParams.Witnesses, v) // smt witness } + // account cell witness + accTx, err := s.DasCore.Client().GetTransaction(s.Ctx, p.AccountOutPoint.TxHash) + if err != nil { + return nil, fmt.Errorf("GetTransaction acc tx err: %s", err.Error()) + } + accBuilderMap, err := witness.AccountIdCellDataBuilderFromTx(accTx.Transaction, common.DataTypeNew) + if err != nil { + return nil, fmt.Errorf("AccountIdCellDataBuilderFromTx err: %s", err.Error()) + } + accBuilder, ok := accBuilderMap[p.Account.AccountId] + if !ok { + return nil, fmt.Errorf("accBuilderMap is nil: %s", p.Account.AccountId) + } + accWitness, _, _ := accBuilder.GenWitness(&witness.AccountCellParam{ + OldIndex: 0, + Action: common.DasActionEditSubAccount, + }) + txParams.Witnesses = append(txParams.Witnesses, accWitness) // so soEd25519, _ := core.GetDasSoScript(common.SoScriptTypeEd25519) soEth, _ := core.GetDasSoScript(common.SoScriptTypeEth) @@ -127,6 +145,10 @@ func (s *SubAccountTxTool) BuildEditSubAccountTx(p *ParamBuildEditSubAccountTx) // cell deps txParams.CellDeps = append(txParams.CellDeps, + &types.CellDep{ + OutPoint: p.AccountOutPoint, + DepType: types.DepTypeCode, + }, p.BaseInfo.ConfigCellAcc.ToCellDep(), p.BaseInfo.ContractDas.ToCellDep(), p.BaseInfo.ContractSubAcc.ToCellDep(), @@ -134,10 +156,6 @@ func (s *SubAccountTxTool) BuildEditSubAccountTx(p *ParamBuildEditSubAccountTx) p.BaseInfo.TimeCell.ToCellDep(), p.BaseInfo.ConfigCellSubAcc.ToCellDep(), p.BaseInfo.ConfigCellRecordNamespace.ToCellDep(), - &types.CellDep{ - OutPoint: p.AccountOutPoint, - DepType: types.DepTypeCode, - }, soEd25519.ToCellDep(), soEth.ToCellDep(), soTron.ToCellDep(), diff --git a/vendor/github.com/DeAccountSystems/das-lib/core/env.go b/vendor/github.com/DeAccountSystems/das-lib/core/env.go index 95a3c13c..ea13433f 100644 --- a/vendor/github.com/DeAccountSystems/das-lib/core/env.go +++ b/vendor/github.com/DeAccountSystems/das-lib/core/env.go @@ -71,7 +71,7 @@ var EnvTestnet3 = Env{ common.DasContractNameReverseRecordCellType: "0x80963278cbdc61cdafd5250555984b71ad016798b8879adc0e6b1ee7e01b7912", common.DASContractNameOfferCellType: "0xc69186c17e41fead0f87eb1f94829778e98a398be202655ac59fdb9567d05bae", common.DASContractNameSubAccountCellType: "0x57498a2df0c0137146ced681fa1854599e404da5804c1a5ff45d954c3cc89bfd", - common.DASContractNameEip712LibCellType: "", + common.DASContractNameEip712LibCellType: "0xd21b1f02b6057d6776bf7f1c7a26f550f1b383a930349620507f328e4cc07f2e", }, } diff --git a/vendor/github.com/DeAccountSystems/das-lib/witness/account_cell.go b/vendor/github.com/DeAccountSystems/das-lib/witness/account_cell.go index 082e19fe..6a056795 100644 --- a/vendor/github.com/DeAccountSystems/das-lib/witness/account_cell.go +++ b/vendor/github.com/DeAccountSystems/das-lib/witness/account_cell.go @@ -305,7 +305,7 @@ func (a *AccountCellDataBuilder) GenWitness(p *AccountCellParam) ([]byte, []byte tmp := molecule.NewDataBuilder().Old(*oldDataEntityOpt).New(newDataEntityOpt).Build() witness := GenDasDataWitness(common.ActionDataTypeAccountCell, &tmp) return witness, common.Blake2b(newAccountCellData.AsSlice()), nil - case common.DasActionPropose, common.DasActionDeclareReverseRecord, common.DasActionRedeclareReverseRecord: + case common.DasActionPropose, common.DasActionDeclareReverseRecord, common.DasActionRedeclareReverseRecord, common.DasActionEditSubAccount: oldDataEntityOpt := a.getOldDataEntityOpt(p) tmp := molecule.NewDataBuilder().Dep(*oldDataEntityOpt).Build() witness := GenDasDataWitness(common.ActionDataTypeAccountCell, &tmp) diff --git a/vendor/modules.txt b/vendor/modules.txt index b3e09cb4..844115e6 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1,6 +1,6 @@ # github.com/Andrew-M-C/go.emoji v0.0.0-20211011074904-61cf526972e1 github.com/Andrew-M-C/go.emoji/official -# github.com/DeAccountSystems/das-lib v0.0.0-20220531040850-ea68b195348f +# github.com/DeAccountSystems/das-lib v0.0.0-20220607033455-1b6e6e92f767 ## explicit github.com/DeAccountSystems/das-lib/common github.com/DeAccountSystems/das-lib/core