Skip to content

Commit 34ccc8b

Browse files
committed
rofl: Ignore non-existent accounts if --unsigned provided
1 parent d316dcd commit 34ccc8b

3 files changed

Lines changed: 12 additions & 10 deletions

File tree

cmd/common/transaction.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ var (
3939
txGasPrice string
4040
txFeeDenom string
4141
txEncrypted bool
42-
txUnsigned bool
42+
TxUnsigned bool
4343
txFormat string
4444
txOutputFile string
4545
)
@@ -80,7 +80,7 @@ func GetTransactionConfig() *TransactionConfig {
8080

8181
// shouldExportTransaction returns true if the transaction should be exported instead of broadcast.
8282
func shouldExportTransaction() bool {
83-
return txOffline || txUnsigned || txOutputFile != ""
83+
return txOffline || TxUnsigned || txOutputFile != ""
8484
}
8585

8686
// isRuntimeTx returns true, if given object is a signed or unsigned runtime transaction.
@@ -184,7 +184,7 @@ func SignConsensusTransaction(
184184
if tx.Nonce == invalidNonce || tx.Fee.Gas == invalidGasLimit {
185185
return nil, fmt.Errorf("nonce and/or gas limit must be specified in offline mode")
186186
}
187-
if txUnsigned {
187+
if TxUnsigned {
188188
// Return an unsigned transaction.
189189
return tx, nil
190190
}
@@ -341,7 +341,7 @@ func SignParaTimeTransaction(
341341
tx.Call = *encCall
342342
}
343343

344-
if txUnsigned {
344+
if TxUnsigned {
345345
// Return an unsigned transaction.
346346
return tx, meta, nil
347347
}
@@ -630,7 +630,7 @@ func init() {
630630
RuntimeTxFlags.StringVar(&txFeeDenom, "fee-denom", "", "override fee denomination (defaults to native)")
631631
RuntimeTxFlags.BoolVar(&txEncrypted, "encrypted", false, "encrypt transaction call data (requires online mode)")
632632
RuntimeTxFlags.AddFlagSet(AnswerYesFlag)
633-
RuntimeTxFlags.BoolVar(&txUnsigned, "unsigned", false, "do not sign transaction")
633+
RuntimeTxFlags.BoolVar(&TxUnsigned, "unsigned", false, "do not sign transaction")
634634
RuntimeTxFlags.StringVar(&txFormat, "format", "json", "transaction output format (for offline/unsigned modes) [json, cbor, safe]")
635635
RuntimeTxFlags.StringVarP(&txOutputFile, "output-file", "o", "", "output transaction into specified file instead of broadcasting")
636636

@@ -640,7 +640,7 @@ func init() {
640640
TxFlags.Uint64Var(&txGasLimit, "gas-limit", invalidGasLimit, "override gas limit to use (disable estimation)")
641641
TxFlags.StringVar(&txGasPrice, "gas-price", "", "override gas price to use")
642642
TxFlags.AddFlagSet(AnswerYesFlag)
643-
TxFlags.BoolVar(&txUnsigned, "unsigned", false, "do not sign transaction")
643+
TxFlags.BoolVar(&TxUnsigned, "unsigned", false, "do not sign transaction")
644644
TxFlags.StringVar(&txFormat, "format", "json", "transaction output format (for offline/unsigned modes) [json, cbor]")
645645
TxFlags.StringVarP(&txOutputFile, "output-file", "o", "", "output transaction into specified file instead of broadcasting")
646646
}

cmd/rofl/common/manifest.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ func MaybeLoadManifestAndSetNPA(cfg *cliConfig.Config, npa *common.NPASelection,
105105
}
106106
switch {
107107
case d.Admin == "":
108-
// No admin in manifest, leave unchanged.
109-
case npa.AccountSetExplicitly:
108+
// No admin in manifest, leave unchanged; ignore for unsigned transactions entirely.
109+
case npa.AccountSetExplicitly, common.TxUnsigned:
110110
// Account explicitly overridden on the command line, leave unchanged.
111111
default:
112112
accCfg, err := common.LoadAccountConfig(cfg, d.Admin)

cmd/rofl/deploy.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,6 @@ var (
147147
return
148148
}
149149

150-
acc := common.LoadAccount(cliConfig.Global(), npa.AccountName)
151-
152150
ociRepository := ociRepository(deployment)
153151
orcFilename := roflCommon.GetOrcFilename(manifest, roflCommon.DeploymentName)
154152
fmt.Printf("Pushing ROFL app to OCI repository '%s'...\n", ociRepository)
@@ -178,6 +176,10 @@ var (
178176
machineDeployment.Metadata[scheduler.MetadataKeyProxyCustomDomains] = customDomains
179177
}
180178

179+
acc := common.LoadAccount(cliConfig.Global(), cliConfig.Global().Wallet.Default)
180+
if !common.TxUnsigned {
181+
acc = common.LoadAccount(cliConfig.Global(), npa.AccountName)
182+
}
181183
obtainMachine := func() (*buildRofl.Machine, *roflmarket.Instance, error) {
182184
if deployOffer != "" {
183185
machine.Offer = deployOffer

0 commit comments

Comments
 (0)