-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add Whitelist message ability to whitelist SPL tokens on Solana (…
…#2984) * whitelist spl mint wip * whitelist test wip * test fixes * fmt * small refactoring * add protocol contracts solana pkg * bump go idl pkg * revert back to development gateway keypair * fix e2e test * add tss signature to whitelist spl mint * CI fixes * changelog * cleanup parse code instruction for whitelist * cleanup * cleanup comments * add whitelist candidate to msg hash * PR comments * fix after merge * move back to tests solana and add todo * PR comments
- Loading branch information
Showing
32 changed files
with
1,573 additions
and
162 deletions.
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
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
Binary file not shown.
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,68 @@ | ||
package e2etests | ||
|
||
import ( | ||
"github.com/gagliardetto/solana-go" | ||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/zeta-chain/node/e2e/runner" | ||
"github.com/zeta-chain/node/e2e/txserver" | ||
"github.com/zeta-chain/node/e2e/utils" | ||
"github.com/zeta-chain/node/pkg/chains" | ||
crosschaintypes "github.com/zeta-chain/node/x/crosschain/types" | ||
) | ||
|
||
func TestSolanaWhitelistSPL(r *runner.E2ERunner, _ []string) { | ||
// Deploy a new SPL | ||
r.Logger.Info("Deploying new SPL") | ||
|
||
// load deployer private key | ||
privkey, err := solana.PrivateKeyFromBase58(r.Account.SolanaPrivateKey.String()) | ||
require.NoError(r, err) | ||
|
||
spl := r.DeploySPL(&privkey) | ||
|
||
// check that whitelist entry doesn't exist for this spl | ||
seed := [][]byte{[]byte("whitelist"), spl.PublicKey().Bytes()} | ||
whitelistEntryPDA, _, err := solana.FindProgramAddress(seed, r.GatewayProgram) | ||
require.NoError(r, err) | ||
|
||
whitelistEntryInfo, err := r.SolanaClient.GetAccountInfo(r.Ctx, whitelistEntryPDA) | ||
require.Error(r, err) | ||
require.Nil(r, whitelistEntryInfo) | ||
|
||
// whitelist sol zrc20 | ||
r.Logger.Info("whitelisting spl on new network") | ||
res, err := r.ZetaTxServer.BroadcastTx(utils.AdminPolicyName, crosschaintypes.NewMsgWhitelistERC20( | ||
r.ZetaTxServer.MustGetAccountAddressFromName(utils.AdminPolicyName), | ||
spl.PublicKey().String(), | ||
chains.SolanaLocalnet.ChainId, | ||
"TESTSPL", | ||
"TESTSPL", | ||
6, | ||
100000, | ||
)) | ||
require.NoError(r, err) | ||
|
||
event, ok := txserver.EventOfType[*crosschaintypes.EventERC20Whitelist](res.Events) | ||
require.True(r, ok, "no EventERC20Whitelist in %s", res.TxHash) | ||
erc20zrc20Addr := event.Zrc20Address | ||
whitelistCCTXIndex := event.WhitelistCctxIndex | ||
|
||
err = r.ZetaTxServer.InitializeLiquidityCaps(erc20zrc20Addr) | ||
require.NoError(r, err) | ||
|
||
// ensure CCTX created | ||
resCCTX, err := r.CctxClient.Cctx(r.Ctx, &crosschaintypes.QueryGetCctxRequest{Index: whitelistCCTXIndex}) | ||
require.NoError(r, err) | ||
|
||
cctx := resCCTX.CrossChainTx | ||
r.Logger.CCTX(*cctx, "whitelist_cctx") | ||
|
||
// wait for the whitelist cctx to be mined | ||
r.WaitForMinedCCTXFromIndex(whitelistCCTXIndex) | ||
|
||
// check that whitelist entry exists for this spl | ||
whitelistEntryInfo, err = r.SolanaClient.GetAccountInfo(r.Ctx, whitelistEntryPDA) | ||
require.NoError(r, err) | ||
require.NotNil(r, whitelistEntryInfo) | ||
} |
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
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
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
Oops, something went wrong.