Browse Source

Minor fixes to the Solana library (#1472)

I fixed an incorrect comment and a wrong index when encoding data.

---------

Signed-off-by: Lucas Steuernagel <lucas.tnagel@gmail.com>
Lucas Steuernagel 2 years ago
parent
commit
3c759be021

+ 2 - 2
integration/solana/simple_collectible.spec.ts

@@ -51,7 +51,7 @@ describe('Simple collectible', function () {
             .remainingAccounts([
             .remainingAccounts([
                 { pubkey: mint, isSigner: false, isWritable: true },
                 { pubkey: mint, isSigner: false, isWritable: true },
                 { pubkey: owner_token_account.address, isSigner: false, isWritable: true },
                 { pubkey: owner_token_account.address, isSigner: false, isWritable: true },
-                { pubkey: mint_authority.publicKey, isSigner: true, isWritable: true },
+                { pubkey: mint_authority.publicKey, isSigner: true, isWritable: false },
                 { pubkey: metadata_authority.publicKey, isSigner: true, isWritable: true }
                 { pubkey: metadata_authority.publicKey, isSigner: true, isWritable: true }
             ])
             ])
             .signers([mint_authority, metadata_authority])
             .signers([mint_authority, metadata_authority])
@@ -76,7 +76,7 @@ describe('Simple collectible', function () {
             .remainingAccounts([
             .remainingAccounts([
                 { pubkey: new_owner_token_account.address, isSigner: false, isWritable: true },
                 { pubkey: new_owner_token_account.address, isSigner: false, isWritable: true },
                 { pubkey: owner_token_account.address, isSigner: false, isWritable: true },
                 { pubkey: owner_token_account.address, isSigner: false, isWritable: true },
-                { pubkey: nft_owner.publicKey, isSigner: true, isWritable: true },
+                { pubkey: nft_owner.publicKey, isSigner: true, isWritable: false },
             ])
             ])
             .signers([nft_owner])
             .signers([nft_owner])
             .rpc();
             .rpc();

+ 3 - 3
integration/solana/token.spec.ts

@@ -58,7 +58,7 @@ describe('Create spl-token and use from solidity', function () {
             .remainingAccounts([
             .remainingAccounts([
                 { pubkey: mint, isSigner: false, isWritable: true },
                 { pubkey: mint, isSigner: false, isWritable: true },
                 { pubkey: tokenAccount.address, isSigner: false, isWritable: true },
                 { pubkey: tokenAccount.address, isSigner: false, isWritable: true },
-                { pubkey: mintAuthority.publicKey, isSigner: true, isWritable: true },
+                { pubkey: mintAuthority.publicKey, isSigner: true, isWritable: false },
             ])
             ])
             .signers([mintAuthority])
             .signers([mintAuthority])
             .rpc();
             .rpc();
@@ -96,7 +96,7 @@ describe('Create spl-token and use from solidity', function () {
             .remainingAccounts([
             .remainingAccounts([
                 { pubkey: otherTokenAccount.address, isSigner: false, isWritable: true },
                 { pubkey: otherTokenAccount.address, isSigner: false, isWritable: true },
                 { pubkey: tokenAccount.address, isSigner: false, isWritable: true },
                 { pubkey: tokenAccount.address, isSigner: false, isWritable: true },
-                { pubkey: payer.publicKey, isSigner: true, isWritable: true },
+                { pubkey: payer.publicKey, isSigner: true, isWritable: false },
             ])
             ])
             .signers([payer])
             .signers([payer])
             .rpc();
             .rpc();
@@ -130,7 +130,7 @@ describe('Create spl-token and use from solidity', function () {
             .remainingAccounts([
             .remainingAccounts([
                 { pubkey: otherTokenAccount.address, isSigner: false, isWritable: true },
                 { pubkey: otherTokenAccount.address, isSigner: false, isWritable: true },
                 { pubkey: mint, isSigner: false, isWritable: true },
                 { pubkey: mint, isSigner: false, isWritable: true },
-                { pubkey: theOutsider.publicKey, isSigner: true, isWritable: true },
+                { pubkey: theOutsider.publicKey, isSigner: true, isWritable: false },
             ])
             ])
             .signers([theOutsider])
             .signers([theOutsider])
             .rpc();
             .rpc();

+ 6 - 6
solana-library/spl_token.sol

@@ -57,7 +57,7 @@ library SplToken {
 		AccountMeta[3] metas = [
 		AccountMeta[3] metas = [
 			AccountMeta({pubkey: mint, is_writable: true, is_signer: false}),
 			AccountMeta({pubkey: mint, is_writable: true, is_signer: false}),
 			AccountMeta({pubkey: account, is_writable: true, is_signer: false}),
 			AccountMeta({pubkey: account, is_writable: true, is_signer: false}),
-			AccountMeta({pubkey: authority, is_writable: true, is_signer: true})
+			AccountMeta({pubkey: authority, is_writable: false, is_signer: true})
 		];
 		];
 
 
 		tokenProgramId.call{accounts: metas}(instr);
 		tokenProgramId.call{accounts: metas}(instr);
@@ -79,7 +79,7 @@ library SplToken {
 		AccountMeta[3] metas = [
 		AccountMeta[3] metas = [
 			AccountMeta({pubkey: from, is_writable: true, is_signer: false}),
 			AccountMeta({pubkey: from, is_writable: true, is_signer: false}),
 			AccountMeta({pubkey: to, is_writable: true, is_signer: false}),
 			AccountMeta({pubkey: to, is_writable: true, is_signer: false}),
-			AccountMeta({pubkey: owner, is_writable: true, is_signer: true})
+			AccountMeta({pubkey: owner, is_writable: false, is_signer: true})
 		];
 		];
 
 
 		tokenProgramId.call{accounts: metas}(instr);
 		tokenProgramId.call{accounts: metas}(instr);
@@ -90,7 +90,7 @@ library SplToken {
 	/// @param account the acount for which tokens should be burned
 	/// @param account the acount for which tokens should be burned
 	/// @param mint the mint for this token
 	/// @param mint the mint for this token
 	/// @param owner the publickey of the account owner keypair
 	/// @param owner the publickey of the account owner keypair
-	/// @param amount the amount to transfer
+	/// @param amount the amount to burn
 	function burn(address account, address mint, address owner, uint64 amount) internal {
 	function burn(address account, address mint, address owner, uint64 amount) internal {
 		bytes instr = new bytes(9);
 		bytes instr = new bytes(9);
 
 
@@ -100,7 +100,7 @@ library SplToken {
 		AccountMeta[3] metas = [
 		AccountMeta[3] metas = [
 			AccountMeta({pubkey: account, is_writable: true, is_signer: false}),
 			AccountMeta({pubkey: account, is_writable: true, is_signer: false}),
 			AccountMeta({pubkey: mint, is_writable: true, is_signer: false}),
 			AccountMeta({pubkey: mint, is_writable: true, is_signer: false}),
-			AccountMeta({pubkey: owner, is_writable: true, is_signer: true})
+			AccountMeta({pubkey: owner, is_writable: false, is_signer: true})
 		];
 		];
 
 
 		tokenProgramId.call{accounts: metas}(instr);
 		tokenProgramId.call{accounts: metas}(instr);
@@ -276,10 +276,10 @@ library SplToken {
 			AccountMeta({pubkey: mintAuthority, is_signer: true, is_writable: false})
 			AccountMeta({pubkey: mintAuthority, is_signer: true, is_writable: false})
 		];
 		];
 
 
-		bytes data = new bytes(9);
+		bytes data = new bytes(3);
 		data[0] = uint8(TokenInstruction.SetAuthority);
 		data[0] = uint8(TokenInstruction.SetAuthority);
 		data[1] = uint8(AuthorityType.MintTokens);
 		data[1] = uint8(AuthorityType.MintTokens);
-		data[3] = 0;
+		data[2] = 0;
 		
 		
 		tokenProgramId.call{accounts: metas}(data);
 		tokenProgramId.call{accounts: metas}(data);
 	}
 	}