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

Develop/v0.7 modify #197

Merged
merged 3 commits into from
Dec 5, 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
7 changes: 6 additions & 1 deletion packages/account/dist/index.js

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion packages/account/dist/index.mjs

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions packages/account/src/associated.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { TransactionInstruction } from '@solana/web3.js';
import { debugLog, sleep } from '~/shared';
import { Node } from '~/node';
import { Transaction } from '~/transaction';
import { StructTransaction, TransactionBuilder } from '~/transaction-builder';
import { Pubkey, Secret } from '~/types/account';

import {
Expand Down Expand Up @@ -36,7 +36,7 @@ export namespace Account {
owner: Pubkey,
feePayer: Secret,
allowOwnerOffCurve = false,
): Promise<string | Transaction> => {
): Promise<string | StructTransaction> => {
const res = await makeOrCreateInstruction(
mint,
owner,
Expand All @@ -48,7 +48,7 @@ export namespace Account {
return res.tokenAccount;
}

return new Transaction(
return new TransactionBuilder.Common(
[res.inst],
[],
feePayer.toKeypair(),
Expand Down Expand Up @@ -77,13 +77,13 @@ export namespace Account {
if (inst && typeof inst === 'string') {
debugLog('# associatedTokenAccount: ', inst);
return inst;
} else if (inst instanceof Transaction) {
} else if (inst instanceof TransactionBuilder.Common) {
(await inst.submit()).map(
async (ok) => {
async (ok: string) => {
await Node.confirmedSig(ok);
return inst.data as string;
},
(err) => {
(err: Error) => {
debugLog('# Error submit retryGetOrCreate: ', err);
throw err;
},
Expand Down
16 changes: 14 additions & 2 deletions packages/suite-spl-token/dist/index.d.mts
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,19 @@ declare class Transaction {
submit: () => Promise<Result<TransactionSignature, Error>>;
}

declare class MintTransaction<T> {
interface StructPartialSignTransaction {
hexInstruction: string;
submit: (feePayer: Secret) => Promise<Result<string, Error>>;
}
interface StructTransaction {
instructions: TransactionInstruction[];
signers: Keypair[];
feePayer?: Keypair;
data?: unknown;
submit: () => Promise<Result<TransactionSignature, Error>>;
}

declare class MintTransaction<T> implements StructTransaction {
instructions: TransactionInstruction[];
signers: Keypair[];
feePayer?: Keypair;
Expand All @@ -870,7 +882,7 @@ declare class MintTransaction<T> {
submit: () => Promise<Result<TransactionSignature, Error>>;
}

declare class PartialSignTransaction {
declare class PartialSignTransaction implements StructPartialSignTransaction {
hexInstruction: string;
data?: Pubkey;
canSubmit?: boolean;
Expand Down
16 changes: 14 additions & 2 deletions packages/suite-spl-token/dist/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,19 @@ declare class Transaction {
submit: () => Promise<Result<TransactionSignature, Error>>;
}

declare class MintTransaction<T> {
interface StructPartialSignTransaction {
hexInstruction: string;
submit: (feePayer: Secret) => Promise<Result<string, Error>>;
}
interface StructTransaction {
instructions: TransactionInstruction[];
signers: Keypair[];
feePayer?: Keypair;
data?: unknown;
submit: () => Promise<Result<TransactionSignature, Error>>;
}

declare class MintTransaction<T> implements StructTransaction {
instructions: TransactionInstruction[];
signers: Keypair[];
feePayer?: Keypair;
Expand All @@ -870,7 +882,7 @@ declare class MintTransaction<T> {
submit: () => Promise<Result<TransactionSignature, Error>>;
}

declare class PartialSignTransaction {
declare class PartialSignTransaction implements StructPartialSignTransaction {
hexInstruction: string;
data?: Pubkey;
canSubmit?: boolean;
Expand Down
7 changes: 6 additions & 1 deletion packages/suite-spl-token/dist/index.js

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion packages/suite-spl-token/dist/index.mjs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { TransactionSignature, PublicKey, Keypair, TransactionInstruction } from '@solana/web3.js';
import * as _solana_web3_js from '@solana/web3.js';
import { TransactionSignature, PublicKey, Keypair, TransactionInstruction, Transaction } from '@solana/web3.js';

declare abstract class AbstractResult<T, E extends Error> {
protected abstract _chain<X, U extends Error>(ok: (value: T) => Result<X, U>, err: (error: E) => Result<X, U>): Result<X, U>;
Expand Down Expand Up @@ -241,34 +242,68 @@ type ExplorerOptions = {
replacePath: string;
};

declare class Transaction {
interface StructPartialSignTransaction {
hexInstruction: string;
submit: (feePayer: Secret) => Promise<Result<string, Error>>;
}
interface StructTransaction {
instructions: TransactionInstruction[];
signers: Keypair[];
feePayer?: Keypair;
data?: unknown;
constructor(instructions: TransactionInstruction[], signers: Keypair[], feePayer?: Keypair, data?: unknown);
submit: () => Promise<Result<TransactionSignature, Error>>;
}
declare namespace TransactionBuilder$4 {
class Common implements StructTransaction {
static MAX_TRANSACTION_SIZE: number;
instructions: TransactionInstruction[];
signers: Keypair[];
feePayer?: Keypair;
data?: unknown;
constructor(instructions: TransactionInstruction[], signers: Keypair[], feePayer?: Keypair, data?: unknown);
submit: () => Promise<Result<TransactionSignature, Error>>;
}
/**
* @param tx a solana transaction
* @param feePayer the publicKey of the signer
* @returns size in bytes of the transaction
*/
const getTxSize: (tx: Transaction, feePayer: PublicKey) => number;
}

declare class BatchTransaction {
submit: (arr: Transaction[]) => Promise<TransactionSignature>;
declare namespace TransactionBuilder$3 {
class BatchTransaction {
submit: (arr: TransactionBuilder$4.Common[]) => Promise<TransactionSignature>;
}
}

declare class MintTransaction<T> {
instructions: TransactionInstruction[];
signers: Keypair[];
feePayer?: Keypair;
data?: T;
constructor(instructions: TransactionInstruction[], signers: Keypair[], feePayer?: Keypair, data?: T);
submit: () => Promise<Result<TransactionSignature, Error>>;
declare namespace TransactionBuilder$2 {
class Mint<T> implements StructTransaction {
instructions: TransactionInstruction[];
signers: Keypair[];
feePayer?: Keypair;
data?: T;
constructor(instructions: TransactionInstruction[], signers: Keypair[], feePayer?: Keypair, data?: T);
submit: () => Promise<Result<TransactionSignature, Error>>;
}
}

declare class PartialSignTransaction {
hexInstruction: string;
data?: Pubkey;
canSubmit?: boolean;
constructor(instructions: string, mint?: Pubkey, canSubmit?: boolean);
submit: (feePayer: Secret) => Promise<Result<TransactionSignature, Error>>;
declare namespace TransactionBuilder$1 {
class PartialSignTransaction implements StructPartialSignTransaction {
hexInstruction: string;
data?: Pubkey;
canSubmit?: boolean;
constructor(instructions: string, mint?: Pubkey, canSubmit?: boolean);
submit: (feePayer: Secret) => Promise<Result<TransactionSignature, Error>>;
}
}

export { BatchTransaction, MintTransaction, PartialSignTransaction, Transaction };
declare const TransactionBuilder: {
PartialSignTransaction: typeof TransactionBuilder$1.PartialSignTransaction;
Common: typeof TransactionBuilder$4.Common;
getTxSize: (tx: _solana_web3_js.Transaction, feePayer: _solana_web3_js.PublicKey) => number;
Mint: typeof TransactionBuilder$2.Mint;
BatchTransaction: typeof TransactionBuilder$3.BatchTransaction;
};

export { StructTransaction, TransactionBuilder };
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { TransactionSignature, PublicKey, Keypair, TransactionInstruction } from '@solana/web3.js';
import * as _solana_web3_js from '@solana/web3.js';
import { TransactionSignature, PublicKey, Keypair, TransactionInstruction, Transaction } from '@solana/web3.js';

declare abstract class AbstractResult<T, E extends Error> {
protected abstract _chain<X, U extends Error>(ok: (value: T) => Result<X, U>, err: (error: E) => Result<X, U>): Result<X, U>;
Expand Down Expand Up @@ -241,34 +242,68 @@ type ExplorerOptions = {
replacePath: string;
};

declare class Transaction {
interface StructPartialSignTransaction {
hexInstruction: string;
submit: (feePayer: Secret) => Promise<Result<string, Error>>;
}
interface StructTransaction {
instructions: TransactionInstruction[];
signers: Keypair[];
feePayer?: Keypair;
data?: unknown;
constructor(instructions: TransactionInstruction[], signers: Keypair[], feePayer?: Keypair, data?: unknown);
submit: () => Promise<Result<TransactionSignature, Error>>;
}
declare namespace TransactionBuilder$4 {
class Common implements StructTransaction {
static MAX_TRANSACTION_SIZE: number;
instructions: TransactionInstruction[];
signers: Keypair[];
feePayer?: Keypair;
data?: unknown;
constructor(instructions: TransactionInstruction[], signers: Keypair[], feePayer?: Keypair, data?: unknown);
submit: () => Promise<Result<TransactionSignature, Error>>;
}
/**
* @param tx a solana transaction
* @param feePayer the publicKey of the signer
* @returns size in bytes of the transaction
*/
const getTxSize: (tx: Transaction, feePayer: PublicKey) => number;
}

declare class BatchTransaction {
submit: (arr: Transaction[]) => Promise<TransactionSignature>;
declare namespace TransactionBuilder$3 {
class BatchTransaction {
submit: (arr: TransactionBuilder$4.Common[]) => Promise<TransactionSignature>;
}
}

declare class MintTransaction<T> {
instructions: TransactionInstruction[];
signers: Keypair[];
feePayer?: Keypair;
data?: T;
constructor(instructions: TransactionInstruction[], signers: Keypair[], feePayer?: Keypair, data?: T);
submit: () => Promise<Result<TransactionSignature, Error>>;
declare namespace TransactionBuilder$2 {
class Mint<T> implements StructTransaction {
instructions: TransactionInstruction[];
signers: Keypair[];
feePayer?: Keypair;
data?: T;
constructor(instructions: TransactionInstruction[], signers: Keypair[], feePayer?: Keypair, data?: T);
submit: () => Promise<Result<TransactionSignature, Error>>;
}
}

declare class PartialSignTransaction {
hexInstruction: string;
data?: Pubkey;
canSubmit?: boolean;
constructor(instructions: string, mint?: Pubkey, canSubmit?: boolean);
submit: (feePayer: Secret) => Promise<Result<TransactionSignature, Error>>;
declare namespace TransactionBuilder$1 {
class PartialSignTransaction implements StructPartialSignTransaction {
hexInstruction: string;
data?: Pubkey;
canSubmit?: boolean;
constructor(instructions: string, mint?: Pubkey, canSubmit?: boolean);
submit: (feePayer: Secret) => Promise<Result<TransactionSignature, Error>>;
}
}

export { BatchTransaction, MintTransaction, PartialSignTransaction, Transaction };
declare const TransactionBuilder: {
PartialSignTransaction: typeof TransactionBuilder$1.PartialSignTransaction;
Common: typeof TransactionBuilder$4.Common;
getTxSize: (tx: _solana_web3_js.Transaction, feePayer: _solana_web3_js.PublicKey) => number;
Mint: typeof TransactionBuilder$2.Mint;
BatchTransaction: typeof TransactionBuilder$3.BatchTransaction;
};

export { StructTransaction, TransactionBuilder };
Loading