Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Did unless that deleted partialSingMintInstuction, and exmples code #171

Merged
merged 1 commit into from
Apr 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions examples/integration8-feepayer-partial-sign-transfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,15 @@ import assert from 'assert';
import { Airdrop, SolNative, SplToken } from '@solana-suite/core';

import {
PartialSignInstruction,
sleep,
KeypairAccount,
PartialSignInstruction,
Pubkey,
} from '@solana-suite/shared';
import { requestTransferByKeypair } from './requestTransferByKeypair';
import { RandomAsset } from '@solana-suite/storage/test/randomAsset';
import { StorageType } from '@solana-suite/shared-metaplex';

(async () => {
////////////////////////////////////////////// CREATE WALLET
//////////////////////////////////////////////

// random create
const owner = KeypairAccount.create();
const tokenOwner = KeypairAccount.create();
Expand All @@ -35,10 +31,6 @@ import { StorageType } from '@solana-suite/shared-metaplex';
}

console.log('# owner: ', owner.pubkey);

await sleep(10); // Avoid 429 error

await Airdrop.request(feePayer.pubkey);
console.log('# feePayer: ', feePayer);
console.log('# tokenOwner: ', tokenOwner);
console.log('# dest: ', dest);
Expand Down
76 changes: 76 additions & 0 deletions examples/integration9-feepayer-partial-sign-nft-mint.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
//////////////////////////////////////////////
// $ npx ts-node examples/integration9-feepayer-partial-sign-nft-mint.ts
//////////////////////////////////////////////

import assert from 'assert';
import { Airdrop } from '@solana-suite/core';

import { KeypairAccount, PartialSignInstruction } from '@solana-suite/shared';
import { requestTransferByKeypair } from './requestTransferByKeypair';
import { RandomAsset } from '@solana-suite/storage/test/randomAsset';
import { StorageType } from '@solana-suite/shared-metaplex';
import { Metaplex } from '@solana-suite/nft';

(async () => {
// random create
const owner = KeypairAccount.create();
const feePayer = KeypairAccount.create();

// faucet
if (process.env.AIR_DROP) {
await Airdrop.request(owner.pubkey);
await Airdrop.request(feePayer.pubkey);
} else {
await requestTransferByKeypair(owner.pubkey);
await requestTransferByKeypair(feePayer.pubkey);
}

console.log('# owner: ', owner.pubkey);
console.log('# feePayer: ', feePayer);

//////////////////////////////////////////////
// CREATE HEX INSTRUCTION(Client side)
//////////////////////////////////////////////

const metadata = {
name: 'solana-suite-nft',
symbol: 'SSN',
royalty: 10,
description: 'solana suite nft',
filePath: RandomAsset.get().filePath as string,
storageType: 'nftStorage' as StorageType,
isMutable: false,
};

const inst = await Metaplex.feePayerPartialSignMint(
owner.pubkey,
owner.secret,
metadata,
feePayer.pubkey
);

let hex: string = '';
inst.match(
(ok) => {
hex = ok.hexInstruction;
console.log('# hex instruction: ', hex);
console.log('# mint: ', ok.data);
},
(err) => assert.fail(err.message)
);

// =============================================== //
// == SEND HEX VALUE(Client side => Sever side) == //
// =============================================== //

//////////////////////////////////////////////
// SIGN FEE PAYER AND SUBMIT (Server side)
//////////////////////////////////////////////

const obj = new PartialSignInstruction(hex);
const res = await obj.submit(feePayer.secret);
res.match(
(ok) => console.log('# tx signature: ', ok),
(err) => assert.fail(err.message)
);
})();
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Secret, Pubkey, PartialSignMintInstruction, Result } from '@solana-suite/shared';
import { PartialSignInstruction, Pubkey, Result, Secret } from '@solana-suite/shared';
import { InputNftMetadata } from '@solana-suite/shared-metaplex';
export declare namespace Metaplex {
const feePayerPartialSignMint: (owner: Pubkey, signer: Secret, input: InputNftMetadata, feePayer: Pubkey) => Promise<Result<PartialSignMintInstruction, Error>>;
const feePayerPartialSignMint: (owner: Pubkey, signer: Secret, input: InputNftMetadata, feePayer: Pubkey) => Promise<Result<PartialSignInstruction, Error>>;
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { PartialSignInstruction, Pubkey, Result, Secret } from '@solana-suite/shared';
export declare namespace Metaplex {
const feePayerPartialSignTransferNft: (mint: Pubkey, owner: Pubkey, dest: Pubkey, signers: Secret[], feePayer: Pubkey) => Promise<Result<PartialSignInstruction, Error>>;
}
22 changes: 22 additions & 0 deletions packages/nft/dist/cjs/metaplex/fee-payer-partial-sign-transfer.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/nft/dist/cjs/metaplex/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
export declare const Metaplex: {
transfer: (mint: import("@solana-suite/shared").Pubkey, owner: import("@solana-suite/shared").Pubkey, dest: import("@solana-suite/shared").Pubkey, signers: import("@solana-suite/shared").Secret[], feePayer?: import("@solana-suite/shared").Secret | undefined) => Promise<import("@solana-suite/shared").Result<import("@solana-suite/shared").Instruction, Error>>;
feePayerPartialSignTransferNft: (mint: import("@solana-suite/shared").Pubkey, owner: import("@solana-suite/shared").Pubkey, dest: import("@solana-suite/shared").Pubkey, signers: import("@solana-suite/shared").Secret[], feePayer: import("@solana-suite/shared").Pubkey) => Promise<import("@solana-suite/shared").Result<import("@solana-suite/shared").PartialSignInstruction, Error>>;
feePayerPartialSignMint: (owner: import("@solana-suite/shared").Pubkey, signer: import("@solana-suite/shared").Secret, input: import("@solana-suite/shared-metaplex").InputNftMetadata, feePayer: import("@solana-suite/shared").Pubkey) => Promise<import("@solana-suite/shared").Result<import("@solana-suite/shared").PartialSignMintInstruction, Error>>;
feePayerPartialSignMint: (owner: import("@solana-suite/shared").Pubkey, signer: import("@solana-suite/shared").Secret, input: import("@solana-suite/shared-metaplex").InputNftMetadata, feePayer: import("@solana-suite/shared").Pubkey) => Promise<import("@solana-suite/shared").Result<import("@solana-suite/shared").PartialSignInstruction, Error>>;
findByOwner: (owner: import("@solana-suite/shared").Pubkey) => Promise<import("@solana-suite/shared").Result<import("@solana-suite/shared-metaplex").OutputNftMetadata[], Error>>;
createMintInstructions: (mint: import("@solana/web3.js").PublicKey, owner: import("@solana/web3.js").PublicKey, nftMetadata: import("@metaplex-foundation/mpl-token-metadata").DataV2, feePayer: import("@solana/web3.js").PublicKey, isMutable: boolean) => Promise<import("@solana/web3.js").TransactionInstruction[]>;
mint: (owner: import("@solana-suite/shared").Pubkey, signer: import("@solana-suite/shared").Secret, input: import("@solana-suite/shared-metaplex").InputNftMetadata, feePayer?: import("@solana-suite/shared").Secret | undefined) => Promise<import("@solana-suite/shared").Result<import("@solana-suite/shared").MintInstruction, Error>>;
Expand Down
3 changes: 2 additions & 1 deletion packages/nft/dist/cjs/metaplex/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/nft/dist/cjs/metaplex/index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions packages/nft/dist/cjs/metaplex/transfer.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Instruction, Result, PartialSignInstruction, Pubkey, Secret } from '@solana-suite/shared';
import { Instruction, Pubkey, Result, Secret } from '@solana-suite/shared';
export declare namespace Metaplex {
const transfer: (mint: Pubkey, owner: Pubkey, dest: Pubkey, signers: Secret[], feePayer?: Secret) => Promise<Result<Instruction, Error>>;
const feePayerPartialSignTransferNft: (mint: Pubkey, owner: Pubkey, dest: Pubkey, signers: Secret[], feePayer: Pubkey) => Promise<Result<PartialSignInstruction, Error>>;
}
3 changes: 0 additions & 3 deletions packages/nft/dist/cjs/metaplex/transfer.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/nft/dist/cjs/metaplex/transfer.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Secret, Pubkey, PartialSignMintInstruction, Result } from '@solana-suite/shared';
import { PartialSignInstruction, Pubkey, Result, Secret } from '@solana-suite/shared';
import { InputNftMetadata } from '@solana-suite/shared-metaplex';
export declare namespace Metaplex {
const feePayerPartialSignMint: (owner: Pubkey, signer: Secret, input: InputNftMetadata, feePayer: Pubkey) => Promise<Result<PartialSignMintInstruction, Error>>;
const feePayerPartialSignMint: (owner: Pubkey, signer: Secret, input: InputNftMetadata, feePayer: Pubkey) => Promise<Result<PartialSignInstruction, Error>>;
}
6 changes: 3 additions & 3 deletions packages/nft/dist/esm/metaplex/fee-payer-partial-sign-mint.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading