-
Notifications
You must be signed in to change notification settings - Fork 397
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sign load packages on integration tests
- Loading branch information
1 parent
9f59ccb
commit 1c49150
Showing
2 changed files
with
34 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package integration | ||
|
||
import ( | ||
"github.com/gnolang/gno/gno.land/pkg/gnoland" | ||
"github.com/gnolang/gno/tm2/pkg/crypto/keys" | ||
"github.com/gnolang/gno/tm2/pkg/std" | ||
) | ||
|
||
func SignTxs(txs []gnoland.TxWithMetadata, chainID string) error { | ||
kb := keys.NewInMemory() | ||
_, err := kb.CreateAccount(DefaultAccount_Name, DefaultAccount_Seed, "", "", 0, 0) | ||
if err != nil { | ||
return err | ||
} | ||
for index, tx := range txs { | ||
bytes, err := tx.Tx.GetSignBytes(chainID, 0, 0) | ||
if err != nil { | ||
return err | ||
} | ||
signature, publicKey, err := kb.Sign(DefaultAccount_Name, "", bytes) | ||
if err != nil { | ||
return err | ||
} | ||
txs[index].Tx.Signatures = []std.Signature{ | ||
{ | ||
PubKey: publicKey, | ||
Signature: signature, | ||
}, | ||
} | ||
} | ||
return nil | ||
} |