Conversation
866b45b to
9f6b6a1
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #3799 +/- ##
==========================================
- Coverage 25.52% 25.41% -0.12%
==========================================
Files 660 662 +2
Lines 42636 42822 +186
==========================================
- Hits 10884 10883 -1
- Misses 30749 30937 +188
+ Partials 1003 1002 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
9f6b6a1 to
fccb48d
Compare
Instead of several `neo-go` commands to create update contract transaction in the main chain and sign them, it allows using a single `adm` command. Closes #3464. Signed-off-by: Andrey Butusov <andrey@nspcc.io>
|
|
||
| gasWalletPath, _ := cmd.Flags().GetString(gasWalletFlag) | ||
| if gasWalletPath == "" { | ||
| return errors.New("gas wallet is required (use --gas-wallet flag)") |
There was a problem hiding this comment.
can be a flag const and fmt.Errorf
| } | ||
|
|
||
| w := io2.NewBufBinWriter() | ||
| emit.AppCall(w.BinWriter, contractHash, "update", callflag.All, nefBytes, manifestBytes, data) |
There was a problem hiding this comment.
@roman-khimov , @AnnaShaleva, cant this be simpler to update a contract? rpc bingings or smth. likely, no emit package and manual invocation scripts should be used, and most of the things should be done much easier, try to look at https://github.com/nspcc-dev/neofs-contract/blob/f228d5018923fa9d6d14bf363670e9159c0e79c7/rpc/neofs/rpcbinding.go#L106
There was a problem hiding this comment.
Yes, NEP-22 bindings better be used here.
| cmd.Printf("Transaction sent successfully!\n") | ||
| cmd.Printf("Transaction hash: %s\n", txHash.StringLE()) | ||
|
|
||
| await, _ := cmd.Flags().GetBool(awaitFlag) |
There was a problem hiding this comment.
i feel like any update should be in await mode always, no need for this to be flag'ed
|
|
||
| func waitForTxMainChain(c fschain.Client, hash util.Uint256, vub uint32) error { | ||
| for range maxAttemptsTxWait { | ||
| time.Sleep(time.Second) |
There was a problem hiding this comment.
no Waiter functionality used? manual for and sleep? i think we need to try to use the new neo-go API for such things
|
|
||
| func getN3Client(v *viper.Viper) (*rpcclient.Client, error) { | ||
| // GetN3Client creates and initializes neo-go RPC client using configuration from viper. | ||
| func GetN3Client(v *viper.Viper) (*rpcclient.Client, error) { |
There was a problem hiding this comment.
I'd suggest moving this into some common package reused by fschain and mainchain.
| "github.com/nspcc-dev/neo-go/pkg/config/netmode" | ||
| "github.com/nspcc-dev/neo-go/pkg/core/transaction" | ||
| "github.com/nspcc-dev/neo-go/pkg/encoding/address" | ||
| io2 "github.com/nspcc-dev/neo-go/pkg/io" |
| } | ||
|
|
||
| w := io2.NewBufBinWriter() | ||
| emit.AppCall(w.BinWriter, contractHash, "update", callflag.All, nefBytes, manifestBytes, data) |
There was a problem hiding this comment.
Yes, NEP-22 bindings better be used here.
| manifestFlag = "manifest" | ||
| dataFlag = "data" | ||
| awaitFlag = "await" | ||
| gasWalletFlag = "gas-wallet" |
| if err != nil { | ||
| return fmt.Errorf("can't open gas wallet: %w", err) | ||
| } | ||
| gasAcc, err := fschain.GetWalletAccount(gasWallet, "single") |
There was a problem hiding this comment.
Most likely it has no label. Just pick the default one from the wallet.
| return fmt.Errorf("can't create N3 client: %w", err) | ||
| } | ||
|
|
||
| committeeAcc, err := fschain.GetWalletAccount(wallets[0], committeeAccountName) |
There was a problem hiding this comment.
In this context it's not committee, it's IR. Although wallets do have it normally (at least until nodes remain the same).
| { | ||
| Signer: transaction.Signer{ | ||
| Account: gasAcc.Contract.ScriptHash(), | ||
| Scopes: transaction.CalledByEntry, |
There was a problem hiding this comment.
None, it doesn't need any proper scope.
| VerificationScript: gasAcc.Contract.Script, | ||
| } | ||
| gasScriptHash := gasAcc.Contract.ScriptHash() | ||
| for i := range tx.Signers { |
There was a problem hiding this comment.
But there is acc.SignTx() that should do the thing.
| return fmt.Errorf("incomplete signature: %w", err) | ||
| } | ||
|
|
||
| for i := range tx.Signers { |
There was a problem hiding this comment.
You know your signers exactly.
Closes #3464.